slepc-3.7.4/0000755000175000017500000000000013107004621012163 5ustar jromanjromanslepc-3.7.4/makefile0000644000175000017500000004537513107004621013701 0ustar jromanjroman# # This is the makefile for installing SLEPc. See the Users Manual # for directions on installing SLEPc. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: all LOCDIR = . DIRS = src include docs # Include the rest of makefiles include ./${PETSC_ARCH}/lib/slepc/conf/slepcvariables include ${SLEPC_DIR}/lib/slepc/conf/slepc_common # # Basic targets to build SLEPc library all: chk_makej @${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} chk_petscdir chk_slepcdir | tee ./${PETSC_ARCH}/lib/slepc/conf/make.log @if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \ ${OMAKE_PRINTDIR} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} all-gnumake-local 2>&1 | tee -a ./${PETSC_ARCH}/lib/slepc/conf/make.log; \ elif [ "${SLEPC_BUILD_USING_CMAKE}" != "" ]; then \ if [ "${SLEPC_DESTDIR}" = "${SLEPC_DIR}/${PETSC_ARCH}" ]; then \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} cmakegen; \ fi; \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} all-cmake-local 2>&1 | tee ./${PETSC_ARCH}/lib/slepc/conf/make.log \ | egrep -v '( --check-build-system |cmake -E | -o CMakeFiles/slepc[[:lower:]]*.dir/| -o lib/libslepc|CMakeFiles/slepc[[:lower:]]*\.dir/(build|depend|requires)|-f CMakeFiles/Makefile2|Dependee .* is newer than depender |provides\.build. is up to date)'; \ else \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} all-legacy-local 2>&1 | tee ./${PETSC_ARCH}/lib/slepc/conf/make.log | ${GREP} -v "has no symbols"; \ fi @egrep -i "( error | error: |no such file or directory)" ${PETSC_ARCH}/lib/slepc/conf/make.log | tee ./${PETSC_ARCH}/lib/slepc/conf/error.log > /dev/null @if test -s ./${PETSC_ARCH}/lib/slepc/conf/error.log; then \ printf ${PETSC_TEXT_HILIGHT}"*******************************ERROR************************************\n" 2>&1 | tee -a ./${PETSC_ARCH}/lib/slepc/conf/make.log; \ echo " Error during compile, check ./${PETSC_ARCH}/lib/slepc/conf/make.log" 2>&1 | tee -a ./${PETSC_ARCH}/lib/slepc/conf/make.log; \ echo " Send all contents of ./${PETSC_ARCH}/lib/slepc/conf to slepc-maint@upv.es" 2>&1 | tee -a ./${PETSC_ARCH}/lib/slepc/conf/make.log;\ printf "************************************************************************"${PETSC_TEXT_NORMAL}"\n" 2>&1 | tee -a ./${PETSC_ARCH}/lib/slepc/conf/make.log; \ elif [ "${SLEPC_DESTDIR}" = "${SLEPC_DIR}/${PETSC_ARCH}" ]; then \ echo "Now to check if the library is working do: make test";\ echo "=========================================";\ else \ echo "Now to install the library do:";\ echo "make SLEPC_DIR=${PWD} PETSC_DIR=${PETSC_DIR} install";\ echo "=========================================";\ fi @if test -s ./${PETSC_ARCH}/lib/slepc/conf/error.log; then exit 1; fi cmakegen: -@${PYTHON} config/cmakegen.py all-gnumake: @if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \ ${OMAKE_PRINTDIR} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} SLEPC_BUILD_USING_CMAKE="" all;\ else printf ${PETSC_TEXT_HILIGHT}"Build not configured for GNUMAKE. Quiting"${PETSC_TEXT_NORMAL}"\n"; exit 1; fi all-cmake: @if [ "${SLEPC_BUILD_USING_CMAKE}" != "" ]; then \ if [ "${SLEPC_DESTDIR}" = "${SLEPC_DIR}/${PETSC_ARCH}" ]; then \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} cmakegen; \ fi; \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} MAKE_IS_GNUMAKE="" all;\ else printf ${PETSC_TEXT_HILIGHT}"Build not configured for CMAKE. Quiting"${PETSC_TEXT_NORMAL}"\n"; exit 1; fi all-legacy: @${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} SLEPC_BUILD_USING_CMAKE="" MAKE_IS_GNUMAKE="" all all-gnumake-local: chk_makej info slepc_gnumake all-cmake-local: chk_makej info cmakegen slepc_cmake all-legacy-local: chk_makej chk_petsc_dir chk_slepc_dir chklib_dir info deletelibs deletemods build slepc_shared # # Prints information about the system and version of SLEPc being compiled # info: chk_makej -@echo "==========================================" -@echo Starting on `hostname` at `date` -@echo Machine characteristics: `uname -a` -@echo "-----------------------------------------" -@echo "Using SLEPc directory: ${SLEPC_DIR}" -@echo "Using PETSc directory: ${PETSC_DIR}" -@echo "Using PETSc arch: ${PETSC_ARCH}" -@echo "-----------------------------------------" -@grep "define SLEPC_VERSION" ${SLEPC_DIR}/include/slepcversion.h | ${SED} "s/........//" -@echo "-----------------------------------------" -@grep "define PETSC_VERSION" ${PETSC_DIR}/include/petscversion.h | ${SED} "s/........//" -@echo "-----------------------------------------" -@echo "Using PETSc configure options: ${CONFIGURE_OPTIONS}" -@echo "Using SLEPc configuration flags:" -@cat ${SLEPC_DIR}/${PETSC_ARCH}/lib/slepc/conf/slepcvariables -@grep "\#define " ${SLEPC_DIR}/${PETSC_ARCH}/include/slepcconf.h -@echo "Using PETSc configuration flags:" -@if [ "${INSTALLED_PETSC}" != "" ]; then \ grep "\#define " ${PETSC_DIR}/include/petscconf.h; \ else \ grep "\#define " ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h; \ fi -@echo "-----------------------------------------" -@echo "Using C/C++ include paths: ${SLEPC_CC_INCLUDES}" -@echo "Using C/C++ compiler: ${PCC} ${PCC_FLAGS} ${COPTFLAGS} ${CFLAGS}" -@if [ "${FC}" != "" ]; then \ echo "Using Fortran include/module paths: ${SLEPC_FC_INCLUDES}";\ echo "Using Fortran compiler: ${FC} ${FC_FLAGS} ${FFLAGS} ${FPP_FLAGS}";\ fi -@echo "-----------------------------------------" -@echo "Using C/C++ linker: ${PCC_LINKER}" -@echo "Using C/C++ flags: ${PCC_LINKER_FLAGS}" -@if [ "${FC}" != "" ]; then \ echo "Using Fortran linker: ${FC_LINKER}";\ echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\ fi -@echo "-----------------------------------------" -@echo "Using libraries: ${SLEPC_LIB}" -@echo "------------------------------------------" -@echo "Using mpiexec: ${MPIEXEC}" -@echo "==========================================" # # Builds the SLEPc library # build: chk_makej -@echo "BEGINNING TO COMPILE LIBRARIES IN ALL DIRECTORIES" -@echo "=========================================" -@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} ACTION=libfast slepc_tree -@${RANLIB} ${SLEPC_LIB_DIR}/*.${AR_LIB_SUFFIX} > tmpf 2>&1 ; ${GREP} -v "has no symbols" tmpf; ${RM} tmpf; -@echo "Completed building libraries" -@echo "=========================================" # Simple test examples for checking a correct installation check: test test: -@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} test_build 2>&1 | tee ./${PETSC_ARCH}/lib/slepc/conf/test.log test_build: -@echo "Running test examples to verify correct installation" -@echo "Using SLEPC_DIR=${SLEPC_DIR}, PETSC_DIR=${PETSC_DIR} and PETSC_ARCH=${PETSC_ARCH}" @cd src/eps/examples/tests; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} testtest10 @if [ "${FC}" != "" ]; then cd src/eps/examples/tests; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} testtest7f; fi; -@if [ "${BLOPEX_LIB}" != "" ]; then cd src/eps/examples/tests; ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} testtest5_blopex; fi; -@echo "Completed test examples" # Builds SLEPc test examples for C testexamples: info -@echo "BEGINNING TO COMPILE AND RUN SLEPc TEST EXAMPLES" -@echo "Due to different numerical round-off on certain" -@echo "machines some of the numbers may not match exactly." -@echo "=========================================" -@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} \ ACTION=testexamples_C slepc_tree -@echo "Completed compiling and running test examples" -@echo "=========================================" # Builds SLEPc test examples for Fortran testfortran: info -@echo "BEGINNING TO COMPILE AND RUN SLEPc FORTRAN TEST EXAMPLES" -@echo "=========================================" -@echo "Due to different numerical round-off on certain" -@echo "machines or the way Fortran formats numbers" -@echo "some of the results may not match exactly." -@echo "=========================================" -@if [ "${FC}" != "" ]; then \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} \ ACTION=testexamples_Fortran slepc_tree ; \ echo "Completed compiling and running Fortran test examples"; \ else \ echo "Error: No FORTRAN compiler available"; \ fi -@echo "=========================================" # Test BLOPEX use testblopex: -@echo "BEGINNING TO COMPILE AND RUN SLEPc BLOPEX TEST EXAMPLES" -@echo "=========================================" -@echo "Due to different numerical round-off on certain" -@echo "machines some of the results may not match exactly." -@echo "=========================================" -@if [ "${BLOPEX_LIB}" != "" ]; then \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} \ ACTION=testexamples_BLOPEX slepc_tree ; \ echo "Completed compiling and running BLOPEX test examples"; \ else \ echo "Error: SLEPc has not been configured with BLOPEX"; \ fi -@echo "=========================================" # Ranlib on the library ranlib: ${RANLIB} ${SLEPC_LIB_DIR}/*.${AR_LIB_SUFFIX} # Deletes SLEPc library deletelibs: chk_makej -${RM} -r ${SLEPC_LIB_DIR}/libslepc*.* deletemods: chk_makej -${RM} -f ${SLEPC_DIR}/${PETSC_ARCH}/include/slepc*.mod # Cleans up build allclean-legacy: deletelibs deletemods -@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} ACTION=clean slepc_tree allclean-cmake: -@cd ./${PETSC_ARCH} && ${OMAKE} clean allclean-gnumake: -@${OMAKE} -f gmakefile clean allclean: @if [ "${MAKE_IS_GNUMAKE}" != "" ]; then \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} allclean-gnumake; \ elif [ "${PETSC_BUILD_USING_CMAKE}" != "" ]; then \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} allclean-cmake; \ else \ ${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} allclean-legacy; \ fi clean:: allclean # # Check if PETSC_DIR variable specified is valid # chk_petsc_dir: @if [ ! -f ${PETSC_DIR}/include/petscversion.h ]; then \ printf ${PETSC_TEXT_HILIGHT}"*************************ERROR**************************************\n"; \ echo "Incorrect PETSC_DIR specified: ${PETSC_DIR}! "; \ echo "You need to use / to separate directories, not \\! "; \ echo "Aborting build "; \ printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n"; \ false; fi # # Check if SLEPC_DIR variable specified is valid # chk_slepc_dir: @if [ ! -f ${SLEPC_DIR}/include/slepcversion.h ]; then \ printf ${PETSC_TEXT_HILIGHT}"*************************ERROR**************************************\n"; \ echo "Incorrect SLEPC_DIR specified: ${SLEPC_DIR}! "; \ echo "You need to use / to separate directories, not \\! "; \ echo "Aborting build "; \ printf "********************************************************************"${PETSC_TEXT_NORMAL}"\n"; \ false; fi # # Install relevant files in the prefix directory # install: -@${PYTHON} ./config/install.py ${SLEPC_DIR} ${PETSC_DIR} ${SLEPC_DESTDIR} ${PETSC_ARCH} ${AR_LIB_SUFFIX} ${RANLIB}; # ------------------------------------------------------------------ # # All remaining actions are intended for SLEPc developers only. # SLEPc users should not generally need to use these commands. # # Builds all the documentation alldoc: alldoc1 alldoc2 # Build everything that goes into 'doc' dir except html sources alldoc1: chk_loc deletemanualpages -${OMAKE} ACTION=manualpages_buildcite tree_basic LOC=${LOC} -@sed -e s%man+../%man+manualpages/% ${LOC}/docs/manualpages/manualpages.cit > ${LOC}/docs/manualpages/htmlmap -@cat ${PETSC_DIR}/src/docs/mpi.www.index >> ${LOC}/docs/manualpages/htmlmap -${OMAKE} ACTION=slepc_manualpages tree_basic LOC=${LOC} -${PYTHON} ${PETSC_DIR}/bin/maint/wwwindex.py ${SLEPC_DIR} ${LOC} -${OMAKE} ACTION=slepc_manexamples tree_basic LOC=${LOC} # Builds .html versions of the source alldoc2: chk_loc -${OMAKE} ACTION=slepc_html PETSC_DIR=${PETSC_DIR} alltree LOC=${LOC} cp ${LOC}/docs/manual.htm ${LOC}/docs/index.html # modify all generated html files and add in version number, date, canonical URL info. docsetdate: chk_petscdir @echo "Updating generated html files with slepc version, date, canonical URL info";\ version_release=`grep '^#define SLEPC_VERSION_RELEASE ' include/slepcversion.h |tr -s ' ' | cut -d ' ' -f 3`; \ version_major=`grep '^#define SLEPC_VERSION_MAJOR ' include/slepcversion.h |tr -s ' ' | cut -d ' ' -f 3`; \ version_minor=`grep '^#define SLEPC_VERSION_MINOR ' include/slepcversion.h |tr -s ' ' | cut -d ' ' -f 3`; \ version_subminor=`grep '^#define SLEPC_VERSION_SUBMINOR ' include/slepcversion.h |tr -s ' ' | cut -d ' ' -f 3`; \ if [ $${version_release} = 0 ]; then \ slepcversion=slepc-dev; \ export slepcversion; \ elif [ $${version_release} = 1 ]; then \ slepcversion=slepc-$${version_major}.$${version_minor}.$${version_subminor}; \ export slepcversion; \ else \ echo "Unknown SLEPC_VERSION_RELEASE: $${version_release}"; \ exit; \ fi; \ datestr=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1`; \ export datestr; \ gitver=`git describe`; \ export gitver; \ find * -type d -wholename 'arch-*' -prune -o -type f -name \*.html \ -exec perl -pi -e 's^()^$$1\n
$$ENV{slepcversion} $$ENV{datestr}
\n ^i' {} \; \ -exec perl -pi -e 's^()^$$1 ^i' {} \; ; \ echo "Done fixing version number, date, canonical URL info" # Deletes documentation alldocclean: deletemanualpages allcleanhtml deletemanualpages: chk_loc -@if [ -d ${LOC} -a -d ${LOC}/docs/manualpages ]; then \ find ${LOC}/docs/manualpages -type f -name "*.html" -exec ${RM} {} \; ;\ ${RM} ${LOC}/docs/manualpages/manualpages.cit ;\ fi allcleanhtml: -${OMAKE} ACTION=cleanhtml PETSC_DIR=${PETSC_DIR} alltree # Builds Fortran stub files allfortranstubs: -@${RM} -rf include/slepc/finclude/ftn-auto/*-tmpdir -@${PYTHON} ${SLEPC_DIR}/bin/maint/generatefortranstubs.py ${BFORT} -@${PYTHON} ${SLEPC_DIR}/bin/maint/generatefortranstubs.py -merge ${VERBOSE} -@${RM} -rf include/slepc/finclude/ftn-auto/*-tmpdir deletefortranstubs: -@find . -type d -name ftn-auto | xargs rm -rf # ------------------------------------------------------------------------------- # # Some macros to check if the Fortran interface is up-to-date. # countfortranfunctions: -@for D in `find ${SLEPC_DIR}/src -name ftn-auto` \ `find ${SLEPC_DIR}/src -name ftn-custom`; do cd $$D; \ egrep '^void' *.c | \ cut -d'(' -f1 | tr -s ' ' | cut -d' ' -f3 | uniq | egrep -v "(^$$|Petsc)" | \ sed "s/_$$//"; done | sort > /tmp/countfortranfunctions countcfunctions: -@ ls ${SLEPC_DIR}/include/*.h | grep -v slepcblaslapack.h | \ xargs grep extern | grep "(" | tr -s ' ' | \ cut -d'(' -f1 | cut -d' ' -f3 | grep -v "\*" | tr -s '\012' | \ tr 'A-Z' 'a-z' | sort > /tmp/countcfunctions difffortranfunctions: countfortranfunctions countcfunctions -@echo -------------- Functions missing in the Fortran interface --------------------- -@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^<" | cut -d' ' -f2 -@echo ----------------- Functions missing in the C interface ------------------------ -@${DIFF} /tmp/countcfunctions /tmp/countfortranfunctions | grep "^>" | cut -d' ' -f2 -@${RM} /tmp/countcfunctions /tmp/countfortranfunctions checkbadfortranstubs: -@echo "=========================================" -@echo "Functions with MPI_Comm as an Argument" -@echo "=========================================" -@for D in `find ${SLEPC_DIR}/src -name ftn-auto`; do cd $$D; \ grep '^void' *.c | grep 'MPI_Comm' | \ tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3; done -@echo "=========================================" -@echo "Functions with a String as an Argument" -@echo "=========================================" -@for D in `find ${SLEPC_DIR}/src -name ftn-auto`; do cd $$D; \ grep '^void' *.c | grep 'char \*' | \ tr -s ' ' | tr -s ':' ' ' |cut -d'(' -f1 | cut -d' ' -f1,3; done -@echo "=========================================" -@echo "Functions with Pointers to PETSc Objects as Argument" -@echo "=========================================" -@_p_OBJ=`grep _p_ ${PETSC_DIR}/include/*.h | tr -s ' ' | \ cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \ sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \ _p_OBJS=`grep _p_ ${SLEPC_DIR}/include/*.h | tr -s ' ' | \ cut -d' ' -f 3 | tr -s '\012' | grep -v '{' | cut -d'*' -f1 | \ sed "s/_p_//g" | tr -s '\012 ' ' *|' ` ; \ for D in `find ${SLEPC_DIR}/src -name ftn-auto`; do cd $$D; \ for OBJ in $$_p_OBJ $$_p_OBJS; do \ grep "$$OBJ \*" *.c | tr -s ' ' | tr -s ':' ' ' | \ cut -d'(' -f1 | cut -d' ' -f1,4; \ done; done # Generate tags alletags: -@${PYTHON} ${SLEPC_DIR}/bin/maint/generateetags.py -@find config -type f -name "*.py" |grep -v SCCS | xargs etags -o TAGS_PYTHON slepc-3.7.4/configure0000755000175000017500000000052413107004621014073 0ustar jromanjroman#!/usr/bin/env python import sys if not type(sys.version_info) is tuple and sys.version_info.major > 2: print('Configure does not support Python 3 yet, please run as') print(' python2 ' + ' '.join(["'" + a + "'" for a in sys.argv])) sys.exit(1) import os execfile(os.path.join(os.path.dirname(__file__), 'config', 'configure.py')) slepc-3.7.4/CTAGS0000644000175000017500000361071313107004621012762 0ustar jromanjroman!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ !_TAG_PROGRAM_NAME Exuberant Ctags // !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ !_TAG_PROGRAM_VERSION 5.9~svn20110310 // 10 src/eps/examples/tutorials/ex6f.F /^ 10 CONTINUE$/;" l subroutine:MVMISG file: 100 docs/manual/ex1f.F /^ 100 format (\/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')$/;" l program:main file: 100 src/eps/examples/tests/test14f.F /^ 100 format (\/'Diagonal Eigenproblem, n =',I3,' (Fortran)')$/;" l program:main file: 100 src/eps/examples/tests/test15f.F /^ 100 format (\/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')$/;" l program:main file: 100 src/eps/examples/tests/test7f.F /^ 100 format (\/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')$/;" l program:main file: 100 src/eps/examples/tutorials/ex1f.F /^ 100 format (\/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')$/;" l program:main file: 100 src/eps/examples/tutorials/ex1f90.F90 /^ 100 format (\/'1-D Laplacian Eigenproblem, n =',I4,' (Fortran)')$/;" l program:main file: 100 src/pep/examples/tests/test3f.F /^ 100 format (\/'Diagonal Quadratic Eigenproblem, n =',I3,' (Fortran)')$/;" l program:main file: 100 src/pep/examples/tutorials/ex16f90.F90 /^ 100 format (\/'Quadratic Eigenproblem, N=',I6,' (',I4,'x',I4,' grid)')$/;" l program:main file: 100 src/svd/examples/tutorials/ex15f.F /^ 100 format (\/'Lauchli SVD, n =',I3,', mu=',E12.4,' (Fortran)')$/;" l program:main file: 100 src/sys/classes/ds/examples/tests/test14f.F /^ 100 format (\/'Program currently limited to n=100, you set n=',I3)$/;" l program:main file: 110 docs/manual/ex1f.F /^ 110 format (\/' Number of iterations of the method:',I4)$/;" l program:main file: 110 src/eps/examples/tests/test14f.F /^ 110 format (' Type set to ',A)$/;" l program:main file: 110 src/eps/examples/tutorials/ex1f.F /^ 110 format (\/' Number of iterations of the method:',I4)$/;" l program:main file: 110 src/pep/examples/tests/test3f.F /^ 110 format (' Polynomial of degree ',I2)$/;" l program:main file: 110 src/svd/examples/tutorials/ex15f.F /^ 110 format (\/' Number of iterations of the method:',I4)$/;" l program:main file: 110 src/sys/classes/ds/examples/tests/test14f.F /^ 110 format (\/'Solve a Dense System of type NHEP, n =',I3,' (Fortran)')$/;" l program:main file: 120 docs/manual/ex1f.F /^ 120 format (' Solution method: ',A)$/;" l program:main file: 120 src/eps/examples/tests/test14f.F /^ 120 format (' Problem type before changing = ',I2)$/;" l program:main file: 120 src/eps/examples/tests/test15f.F /^ 120 format (' Solution method: ',A)$/;" l program:main file: 120 src/eps/examples/tests/test7f.F /^ 120 format (' Solution method: ',A)$/;" l program:main file: 120 src/eps/examples/tutorials/ex1f.F /^ 120 format (' Solution method: ',A)$/;" l program:main file: 120 src/eps/examples/tutorials/ex1f90.F90 /^ 120 format (' Solution method: ',A)$/;" l program:main file: 120 src/pep/examples/tests/test3f.F /^ 120 format (' Type set to ',A)$/;" l program:main file: 120 src/pep/examples/tutorials/ex16f90.F90 /^ 120 format (' Solution method: ',A)$/;" l program:main file: 120 src/svd/examples/tutorials/ex15f.F /^ 120 format (' Solution method: ',A)$/;" l program:main file: 120 src/sys/classes/ds/examples/tests/test14f.F /^ 120 format (' ',F8.5)$/;" l program:main file: 130 docs/manual/ex1f.F /^ 130 format (' Number of requested eigenvalues:',I2)$/;" l program:main file: 130 src/eps/examples/tests/test14f.F /^ 130 format (' ... changed to ',I2)$/;" l program:main file: 130 src/eps/examples/tests/test15f.F /^ 130 format (' Number of requested eigenvalues:',I2)$/;" l program:main file: 130 src/eps/examples/tests/test7f.F /^ 130 format (' Number of requested eigenvalues:',I2)$/;" l program:main file: 130 src/eps/examples/tutorials/ex1f.F /^ 130 format (' Number of requested eigenvalues:',I2)$/;" l program:main file: 130 src/eps/examples/tutorials/ex1f90.F90 /^ 130 format (' Number of requested eigenvalues:',I4)$/;" l program:main file: 130 src/pep/examples/tests/test3f.F /^ 130 format (' Problem type before changing = ',I2)$/;" l program:main file: 130 src/pep/examples/tutorials/ex16f90.F90 /^ 130 format (' Number of requested eigenvalues:',I4)$/;" l program:main file: 130 src/svd/examples/tutorials/ex15f.F /^ 130 format (' Number of requested singular values:',I2)$/;" l program:main file: 130 src/sys/classes/ds/examples/tests/test14f.F /^ 130 format (' ',F8.5,SP,F8.5,'i')$/;" l program:main file: 140 docs/manual/ex1f.F /^ 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)$/;" l program:main file: 140 src/eps/examples/tests/test14f.F /^ 140 format (' Extraction before changing = ',I2)$/;" l program:main file: 140 src/eps/examples/tests/test15f.F /^ 140 format(i3,' EPS nconv=',i2,' first unconverged value (error) ', &$/;" l subroutine:MyEPSMonitor file: 140 src/eps/examples/tutorials/ex1f.F /^ 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)$/;" l program:main file: 140 src/pep/examples/tests/test3f.F /^ 140 format (' ... changed to ',I2)$/;" l program:main file: 140 src/svd/examples/tutorials/ex15f.F /^ 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)$/;" l program:main file: 150 docs/manual/ex1f.F /^ 150 format (' Number of converged eigenpairs:',I2\/)$/;" l program:main file: 150 src/eps/examples/tests/test14f.F /^ 150 format (' ... changed to ',I2)$/;" l program:main file: 150 src/eps/examples/tutorials/ex1f.F /^ 150 format (' Number of converged eigenpairs:',I2\/)$/;" l program:main file: 150 src/pep/examples/tests/test3f.F /^ 150 format (' Extraction before changing = ',I2)$/;" l program:main file: 150 src/svd/examples/tutorials/ex15f.F /^ 150 format (' Number of converged approximate singular triplets:',I2\/)$/;" l program:main file: 160 docs/manual/ex1f.F /^ 160 format (1P,' ',E12.4,' ',E12.4)$/;" l program:main file: 160 src/eps/examples/tests/test14f.F /^ 160 format (' Balance: ',I2,', its=',I2,', cutoff=',F8.6)$/;" l program:main file: 160 src/eps/examples/tutorials/ex1f.F /^ 160 format (1P,' ',E12.4,' ',E12.4)$/;" l program:main file: 160 src/pep/examples/tests/test3f.F /^ 160 format (' ... changed to ',I2)$/;" l program:main file: 160 src/svd/examples/tutorials/ex15f.F /^ 160 format (1P,' ',E12.4,' ',E12.4)$/;" l program:main file: 170 src/eps/examples/tests/test14f.F /^ 170 format (' Which = ',I2,', target = ',F3.1)$/;" l program:main file: 170 src/pep/examples/tests/test3f.F /^ 170 format (' Scaling: ',I2,', alpha=',F6.4,', its=',I2)$/;" l program:main file: 180 src/eps/examples/tests/test14f.F /^ 180 format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2)$/;" l program:main file: 180 src/pep/examples/tests/test3f.F /^ 180 format (' Polynomial basis: ',I2)$/;" l program:main file: 190 src/eps/examples/tests/test14f.F /^ 190 format (' Tolerance =',F7.5,', max_its =',I4)$/;" l program:main file: 190 src/pep/examples/tests/test3f.F /^ 190 format (' Refinement: ',I2,', tol=',F6.4,', its=',I2', schem=',I2)$/;" l program:main file: 20 src/eps/examples/tutorials/ex6f.F /^ 20 CONTINUE $/;" l subroutine:MVMISG file: 200 src/eps/examples/tests/test14f.F /^ 200 format (' Convergence test =',I2)$/;" l program:main file: 200 src/pep/examples/tests/test3f.F /^ 200 format (' Which = ',I2,', target = ',F3.1)$/;" l program:main file: 210 src/eps/examples/tests/test14f.F /^ 210 format (' Finished - converged reason =',I2,', its=',I4)$/;" l program:main file: 210 src/pep/examples/tests/test3f.F /^ 210 format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2)$/;" l program:main file: 220 src/pep/examples/tests/test3f.F /^ 220 format (' Tolerance =',F7.5,', max_its =',I4)$/;" l program:main file: 230 src/pep/examples/tests/test3f.F /^ 230 format (' Convergence test =',I2,', stopping test =',I2)$/;" l program:main file: 240 src/pep/examples/tests/test3f.F /^ 240 format (' Finished - converged reason =',I2,', its=',I4)$/;" l program:main file: 30 src/eps/examples/tutorials/ex6f.F /^ 30 CONTINUE $/;" l subroutine:MVMISG file: 40 src/eps/examples/tutorials/ex6f.F /^ 40 CONTINUE $/;" l subroutine:MVMISG file: 50 src/eps/examples/tutorials/ex6f.F /^ 50 CONTINUE$/;" l subroutine:MVMISG file: 60 src/eps/examples/tutorials/ex6f.F /^ 60 CONTINUE$/;" l subroutine:MVMISG file: 999 src/eps/examples/tutorials/ex6f.F /^ 999 continue$/;" l program:main file: A include/slepc/private/mfnimpl.h /^ Mat A; \/* the problem matrix *\/$/;" m struct:_p_MFN A include/slepc/private/nepimpl.h /^ Mat *A; \/* matrix coefficients of split form *\/$/;" m struct:_p_NEP A include/slepc/private/pepimpl.h /^ Mat *A; \/* coefficient matrices of the polynomial *\/$/;" m struct:_p_PEP A include/slepc/private/stimpl.h /^ Mat *A; \/* matrices that define the eigensystem *\/$/;" m struct:_p_ST A include/slepc/private/svdimpl.h /^ Mat A; \/* problem matrix (m>n) *\/$/;" m struct:_p_SVD A src/eps/examples/tutorials/ex1f90.F90 /^ type(Mat) A$/;" v program:main A src/eps/examples/tutorials/ex24.c /^ Mat A;$/;" m struct:__anon55 file: A src/eps/impls/davidson/davidson.h /^ Mat A,B; \/* problem matrices *\/$/;" m struct:_dvdDashboard A src/eps/impls/external/primme/primme.c /^ Mat A; \/* problem matrix *\/$/;" m struct:__anon78 file: A src/nep/impls/nleigs/nleigs.c /^ Mat A[MAX_NSHIFTS];$/;" m struct:__anon93 file: A src/nep/interface/neprefine.c /^ Mat *A;$/;" m struct:__anon97 file: A src/pep/examples/tutorials/ex16f90.F90 /^ type(Mat) M, C, K, A(/;" v program:main A src/pep/impls/krylov/toar/nrefine.c /^ Mat *A,M1;$/;" m struct:__anon104 file: A src/pep/impls/krylov/toar/nrefine.c /^ Mat *A;$/;" m struct:__anon105 file: A src/pep/impls/linear/linearp.h /^ Mat A,B; \/* matrices of generalized eigenproblem *\/$/;" m struct:__anon106 A src/pep/interface/peprefine.c /^ Mat *A;$/;" m struct:__anon108 file: A src/sys/classes/bv/impls/mat/bvmat.c /^ Mat A;$/;" m struct:__anon116 file: ARPACKnaupd_ src/eps/impls/external/arpack/arpackp.h 152;" d ARPACKnaupd_ src/eps/impls/external/arpack/arpackp.h 159;" d ARPACKnaupd_ src/eps/impls/external/arpack/arpackp.h 170;" d ARPACKnaupd_ src/eps/impls/external/arpack/arpackp.h 177;" d ARPACKneupd_ src/eps/impls/external/arpack/arpackp.h 153;" d ARPACKneupd_ src/eps/impls/external/arpack/arpackp.h 160;" d ARPACKneupd_ src/eps/impls/external/arpack/arpackp.h 171;" d ARPACKneupd_ src/eps/impls/external/arpack/arpackp.h 178;" d ARPACKsaupd_ src/eps/impls/external/arpack/arpackp.h 154;" d ARPACKsaupd_ src/eps/impls/external/arpack/arpackp.h 172;" d ARPACKseupd_ src/eps/impls/external/arpack/arpackp.h 155;" d ARPACKseupd_ src/eps/impls/external/arpack/arpackp.h 173;" d AT include/slepc/private/svdimpl.h /^ Mat AT; \/* transposed matrix *\/$/;" m struct:_p_SVD AUTODIRS config/cmakegen.py /^AUTODIRS = set('ftn-auto ftn-custom f90-custom'.split()) # Automatically recurse into these, if they exist$/;" v AV src/eps/impls/cg/rqcg/rqcg.c /^ BV AV,W,P,G;$/;" m struct:__anon60 file: AV src/eps/impls/krylov/lanczos/lanczos.c /^ BV AV;$/;" m struct:__anon82 file: AX src/eps/impls/davidson/davidson.h /^ BV AX; \/* A*V *\/$/;" m struct:_dvdDashboard AX src/pep/impls/jd/pjdp.h /^ BV *AX; \/* work basis vectors to store A_i*X for locked eigenvectors *\/$/;" m struct:__anon99 AddDefine config/configure.py /^def AddDefine(conffile,name,value,prefix='SLEPC_'):$/;" f AddNorm2 src/sys/vec/veccomp.c /^PETSC_STATIC_INLINE void AddNorm2(PetscReal *ssq,PetscReal *scale,PetscReal x)$/;" f Aid include/slepc/private/bvimpl.h /^ PetscObjectId Aid; \/* object id of matrix A of matmult operation *\/$/;" m struct:_p_BV Aid src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscObjectId Aid,Bid; \/* Id of subcommunicator matrices *\/$/;" m struct:__anon81 ApplicationCtx src/nep/examples/tutorials/ex20.c /^} ApplicationCtx;$/;" t typeref:struct:__anon86 file: ApplicationCtx src/nep/examples/tutorials/ex21.c /^} ApplicationCtx;$/;" t typeref:struct:__anon88 file: Apply_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode Apply_Linear(ST st,Vec x,Vec y)$/;" f file: Aq src/eps/impls/external/feast/feastp.h /^ PetscScalar *work1,*work2,*Aq,*Bq; \/* workspace *\/$/;" m struct:__anon77 ArgDB config/argdb.py /^class ArgDB:$/;" c Arpack config/packages/arpack.py /^class Arpack(package.Package):$/;" c ArrowTridiag src/sys/classes/ds/impls/hep/dshep.c /^static PetscErrorCode ArrowTridiag(PetscBLASInt n,PetscReal *d,PetscReal *e,PetscScalar *Q,PetscBLASInt ld)$/;" f file: Astate include/slepc/private/stimpl.h /^ PetscObjectState *Astate; \/* state (to identify the original matrices) *\/$/;" m struct:_p_ST Astate src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscObjectState Astate,Bstate; \/* state of subcommunicator matrices *\/$/;" m struct:__anon81 B include/slepc/private/bvimpl.h /^ Mat B,C; \/* auxiliary dense matrices for matmult operation *\/$/;" m struct:_p_BV B src/eps/impls/davidson/davidson.h /^ Mat A,B; \/* problem matrices *\/$/;" m struct:_dvdDashboard B src/pep/impls/linear/linearp.h /^ Mat A,B; \/* matrices of generalized eigenproblem *\/$/;" m struct:__anon106 BDC_dibtdc_ src/sys/classes/ds/impls/hep/bdc/dibtdc.c /^PetscErrorCode BDC_dibtdc_(const char *jobz,PetscBLASInt n,PetscBLASInt nblks, $/;" f BDC_dlaed3m_ src/sys/classes/ds/impls/hep/bdc/dlaed3m.c /^PetscErrorCode BDC_dlaed3m_(const char *jobz,const char *defl,PetscBLASInt k,PetscBLASInt n,$/;" f BDC_dmerg2_ src/sys/classes/ds/impls/hep/bdc/dmerg2.c /^PetscErrorCode BDC_dmerg2_(const char *jobz,PetscBLASInt rkct,PetscBLASInt n, $/;" f BDC_dsbtdc_ src/sys/classes/ds/impls/hep/bdc/dsbtdc.c /^PetscErrorCode BDC_dsbtdc_(const char *jobz,const char *jobacc,PetscBLASInt n, $/;" f BDC_dsrtdf_ src/sys/classes/ds/impls/hep/bdc/dsrtdf.c /^PetscErrorCode BDC_dsrtdf_(PetscBLASInt *k,PetscBLASInt n,PetscBLASInt n1, $/;" f BLASrot_ include/slepcblaslapack.h 132;" d BLASrot_ include/slepcblaslapack.h 135;" d BLASrot_ include/slepcblaslapack.h 137;" d BLASrot_ include/slepcblaslapack.h 139;" d BLAStrmm_ include/slepcblaslapack.h 153;" d BLAStrmm_ include/slepcblaslapack.h 209;" d BLOCKSIZE src/sys/classes/bv/interface/bvblas.c 27;" d file: BLOCKSIZE src/sys/classes/fn/impls/fnutil.c 91;" d file: BLZistorr_ src/eps/impls/external/blzpack/blzpackp.h 64;" d BLZpack_ src/eps/impls/external/blzpack/blzpackp.h 59;" d BLZpack_ src/eps/impls/external/blzpack/blzpackp.h 61;" d BLZrstorr_ src/eps/impls/external/blzpack/blzpackp.h 65;" d BV include/slepc/finclude/slepcbvdef.h 27;" d BV include/slepcbv.h /^typedef struct _p_BV* BV;$/;" t typeref:struct:_p_BV BVAXPY_BLAS_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVAXPY_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,PetscScalar alpha,const PetscScalar *A,PetscScalar beta,PetscScalar *B)$/;" f BVAllocateWork_Private src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVAllocateWork_Private(BV bv,PetscInt s)$/;" f BVAppendOptionsPrefix src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVAppendOptionsPrefix(BV bv,const char *prefix)$/;" f BVApplyMatrix src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVApplyMatrix(BV bv,Vec x,Vec y)$/;" f BVApplyMatrixBV src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVApplyMatrixBV(BV X,BV Y)$/;" f BVAvailableVec include/slepc/private/bvimpl.h 271;" d BVCONTIGUOUS include/slepc/finclude/slepcbvdef.h 39;" d BVCONTIGUOUS include/slepcbv.h 50;" d BVCheckSizes include/slepc/private/bvimpl.h 278;" d BVCheckSizes include/slepc/private/bvimpl.h 282;" d BVCopy src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVCopy(BV V,BV W)$/;" f BVCopyColumn src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVCopyColumn(BV V,PetscInt j,PetscInt i)$/;" f BVCopyVec src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVCopyVec(BV V,PetscInt j,Vec w)$/;" f BVCopy_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVCopy_Contiguous(BV V,BV W)$/;" f BVCopy_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVCopy_Mat(BV V,BV W)$/;" f BVCopy_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVCopy_Svec(BV V,BV W)$/;" f BVCopy_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVCopy_Vecs(BV V,BV W)$/;" f BVCreate src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVCreate(MPI_Comm comm,BV *newbv)$/;" f BVCreateVec src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVCreateVec(BV bv,Vec *v)$/;" f BVCreate_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PETSC_EXTERN PetscErrorCode BVCreate_Contiguous(BV bv)$/;" f BVCreate_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PETSC_EXTERN PetscErrorCode BVCreate_Mat(BV bv)$/;" f BVCreate_Svec src/sys/classes/bv/impls/svec/svec.c /^PETSC_EXTERN PetscErrorCode BVCreate_Svec(BV bv)$/;" f BVCreate_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PETSC_EXTERN PetscErrorCode BVCreate_Vecs(BV bv)$/;" f BVDestroy src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVDestroy(BV *bv)$/;" f BVDestroy_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVDestroy_Contiguous(BV bv)$/;" f BVDestroy_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVDestroy_Mat(BV bv)$/;" f BVDestroy_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVDestroy_Svec(BV bv)$/;" f BVDestroy_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVDestroy_Vecs(BV bv)$/;" f BVDot src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVDot(BV X,BV Y,Mat M)$/;" f BVDotColumn src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVDotColumn(BV X,PetscInt j,PetscScalar *m)$/;" f BVDotColumnBegin src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVDotColumnBegin(BV X,PetscInt j,PetscScalar *m)$/;" f BVDotColumnEnd src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVDotColumnEnd(BV X,PetscInt j,PetscScalar *m)$/;" f BVDotVec src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVDotVec(BV X,Vec y,PetscScalar *m)$/;" f BVDotVecBegin src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVDotVecBegin(BV X,Vec y,PetscScalar *m)$/;" f BVDotVecEnd src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVDotVecEnd(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_BLAS_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVDotVec_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,const PetscScalar *A,const PetscScalar *x,PetscScalar *y,PetscBool mpi)$/;" f BVDotVec_Begin_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVDotVec_Begin_Vecs(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVDotVec_Contiguous(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_End_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVDotVec_End_Vecs(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_Local_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVDotVec_Local_Contiguous(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_Local_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVDotVec_Local_Mat(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_Local_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVDotVec_Local_Svec(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVDotVec_Mat(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVDotVec_Svec(BV X,Vec y,PetscScalar *m)$/;" f BVDotVec_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVDotVec_Vecs(BV X,Vec y,PetscScalar *m)$/;" f BVDot_BLAS_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVDot_BLAS_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,PetscInt ldc_,const PetscScalar *A,const PetscScalar *B,PetscScalar *C,PetscBool mpi)$/;" f BVDot_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVDot_Contiguous(BV X,BV Y,Mat M)$/;" f BVDot_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVDot_Mat(BV X,BV Y,Mat M)$/;" f BVDot_Private src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVDot_Private(BV X,BV Y,Mat M)$/;" f BVDot_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVDot_Svec(BV X,BV Y,Mat M)$/;" f BVDot_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVDot_Vecs(BV X,BV Y,Mat M)$/;" f BVDuplicate src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVDuplicate(BV V,BV *W)$/;" f BVDuplicateResize src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVDuplicateResize(BV V,PetscInt m,BV *W)$/;" f BVDuplicate_Private src/sys/classes/bv/interface/bvbasic.c /^PETSC_STATIC_INLINE PetscErrorCode BVDuplicate_Private(BV V,PetscInt m,BV *W)$/;" f BVDuplicate_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVDuplicate_Vecs(BV V,BV *W)$/;" f BVFinalizePackage src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVFinalizePackage(void)$/;" f BVGetActiveColumns src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetActiveColumns(BV bv,PetscInt *l,PetscInt *k)$/;" f BVGetArray src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetArray(BV bv,PetscScalar **a)$/;" f BVGetArrayRead src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetArrayRead(BV bv,const PetscScalar **a)$/;" f BVGetArrayRead_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVGetArrayRead_Contiguous(BV bv,const PetscScalar **a)$/;" f BVGetArrayRead_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVGetArrayRead_Mat(BV bv,const PetscScalar **a)$/;" f BVGetArrayRead_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVGetArrayRead_Svec(BV bv,const PetscScalar **a)$/;" f BVGetArrayRead_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVGetArrayRead_Vecs(BV bv,const PetscScalar **a)$/;" f BVGetArray_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVGetArray_Contiguous(BV bv,PetscScalar **a)$/;" f BVGetArray_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVGetArray_Mat(BV bv,PetscScalar **a)$/;" f BVGetArray_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVGetArray_Svec(BV bv,PetscScalar **a)$/;" f BVGetArray_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVGetArray_Vecs(BV bv,PetscScalar **a)$/;" f BVGetCachedBV src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetCachedBV(BV bv,BV *cached)$/;" f BVGetColumn src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetColumn(BV bv,PetscInt j,Vec *v)$/;" f BVGetColumn_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVGetColumn_Contiguous(BV bv,PetscInt j,Vec *v)$/;" f BVGetColumn_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVGetColumn_Mat(BV bv,PetscInt j,Vec *v)$/;" f BVGetColumn_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVGetColumn_Svec(BV bv,PetscInt j,Vec *v)$/;" f BVGetColumn_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVGetColumn_Vecs(BV bv,PetscInt j,Vec *v)$/;" f BVGetMatMultMethod src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetMatMultMethod(BV bv,BVMatMultType *method)$/;" f BVGetMatrix src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetMatrix(BV bv,Mat *B,PetscBool *indef)$/;" f BVGetNumConstraints src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetNumConstraints(BV bv,PetscInt *nc)$/;" f BVGetOptionsPrefix src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVGetOptionsPrefix(BV bv,const char *prefix[])$/;" f BVGetOrthogonalization src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetOrthogonalization(BV bv,BVOrthogType *type,BVOrthogRefineType *refine,PetscReal *eta,BVOrthogBlockType *block)$/;" f BVGetRandomContext src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetRandomContext(BV bv,PetscRandom* rand)$/;" f BVGetSignature src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetSignature(BV bv,Vec omega)$/;" f BVGetSizes src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetSizes(BV bv,PetscInt *n,PetscInt *N,PetscInt *m)$/;" f BVGetType src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVGetType(BV bv,BVType *type)$/;" f BVInitializePackage src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVInitializePackage(void)$/;" f BVInsertConstraints src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVInsertConstraints(BV V,PetscInt *nc,Vec *C)$/;" f BVInsertVec src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVInsertVec(BV V,PetscInt j,Vec w)$/;" f BVInsertVecs src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVInsertVecs(BV V,PetscInt s,PetscInt *m,Vec *W,PetscBool orth)$/;" f BVList include/slepcbv.h /^PETSC_EXTERN PetscFunctionList BVList;$/;" v BVList src/sys/classes/bv/interface/bvbasic.c /^PetscFunctionList BVList = 0;$/;" v BVMAT include/slepc/finclude/slepcbvdef.h 36;" d BVMAT include/slepcbv.h 47;" d BVMatMult src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMatMult(BV V,Mat A,BV Y)$/;" f BVMatMultColumn src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMatMultColumn(BV V,Mat A,PetscInt j)$/;" f BVMatMultHermitianTranspose src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMatMultHermitianTranspose(BV V,Mat A,BV Y)$/;" f BVMatMultType include/slepc/finclude/slepcbvdef.h 34;" d BVMatMultType include/slepcbv.h /^ BV_MATMULT_MAT_SAVE } BVMatMultType;$/;" t typeref:enum:__anon12 BVMatMultTypes include/slepcbv.h /^PETSC_EXTERN const char *BVMatMultTypes[];$/;" v BVMatMultTypes src/sys/classes/bv/interface/bvfunc.c /^const char *BVMatMultTypes[] = {"VECS","MAT","MAT_SAVE","BVMatMultType","BV_MATMULT_",0};$/;" v BVMatMult_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVMatMult_Contiguous(BV V,Mat A,BV W)$/;" f BVMatMult_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVMatMult_Mat(BV V,Mat A,BV W)$/;" f BVMatMult_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVMatMult_Svec(BV V,Mat A,BV W)$/;" f BVMatMult_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVMatMult_Vecs(BV V,Mat A,BV W)$/;" f BVMatProject src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVMatProject(BV X,Mat A,BV Y,Mat M)$/;" f BVMatProject_Dot src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Dot(BV X,BV Y,PetscScalar *marray,PetscInt ldm)$/;" f BVMatProject_MatMult src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm)$/;" f BVMatProject_MatMult_2 src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult_2(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm)$/;" f BVMatProject_Vec src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Vec(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm)$/;" f BVMult src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMult(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)$/;" f BVMultColumn src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMultColumn(BV X,PetscScalar alpha,PetscScalar beta,PetscInt j,PetscScalar *q)$/;" f BVMultInPlace src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMultInPlace(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlaceTranspose src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMultInPlaceTranspose(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlaceTranspose_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVMultInPlaceTranspose_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlaceTranspose_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVMultInPlaceTranspose_Mat(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlaceTranspose_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVMultInPlaceTranspose_Svec(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlaceTranspose_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVMultInPlaceTranspose_Vecs(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlace_BLAS_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVMultInPlace_BLAS_Private(BV bv,PetscInt m_,PetscInt k_,PetscInt ldb_,PetscInt s,PetscInt e,PetscScalar *A,const PetscScalar *B,PetscBool btrans)$/;" f BVMultInPlace_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVMultInPlace_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlace_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVMultInPlace_Mat(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlace_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVMultInPlace_Svec(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlace_Vecs_Alloc src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVMultInPlace_Vecs_Alloc(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlace_Vecs_ME src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVMultInPlace_Vecs_ME(BV V,Mat Q,PetscInt s,PetscInt e)$/;" f BVMultInPlace_Vecs_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVMultInPlace_Vecs_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,Vec *V,const PetscScalar *B,PetscBool btrans)$/;" f BVMultVec src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVMultVec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)$/;" f BVMultVec_BLAS_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVMultVec_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,PetscScalar alpha,const PetscScalar *A,const PetscScalar *x,PetscScalar beta,PetscScalar *y)$/;" f BVMultVec_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVMultVec_Contiguous(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)$/;" f BVMultVec_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVMultVec_Mat(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)$/;" f BVMultVec_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVMultVec_Svec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)$/;" f BVMultVec_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVMultVec_Vecs(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)$/;" f BVMult_BLAS_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVMult_BLAS_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,PetscInt ldb_,PetscScalar alpha,const PetscScalar *A,const PetscScalar *B,PetscScalar beta,PetscScalar *C)$/;" f BVMult_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVMult_Contiguous(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)$/;" f BVMult_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVMult_Mat(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)$/;" f BVMult_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVMult_Svec(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)$/;" f BVMult_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVMult_Vecs(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)$/;" f BVNorm src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVNorm(BV bv,NormType type,PetscReal *val)$/;" f BVNormColumn src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVNormColumn(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNormColumnBegin src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVNormColumnBegin(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNormColumnEnd src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVNormColumnEnd(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNormVec src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVNormVec(BV bv,Vec v,NormType type,PetscReal *val)$/;" f BVNormVecBegin src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVNormVecBegin(BV bv,Vec v,NormType type,PetscReal *val)$/;" f BVNormVecEnd src/sys/classes/bv/interface/bvglobal.c /^PetscErrorCode BVNormVecEnd(BV bv,Vec v,NormType type,PetscReal *val)$/;" f BVNorm_Begin_Private src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVNorm_Begin_Private(BV bv,Vec z,NormType type,PetscReal *val)$/;" f BVNorm_Begin_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVNorm_Begin_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVNorm_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_End_Private src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVNorm_End_Private(BV bv,Vec z,NormType type,PetscReal *val)$/;" f BVNorm_End_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVNorm_End_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_LAPACK_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVNorm_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,const PetscScalar *A,NormType type,PetscReal *nrm,PetscBool mpi)$/;" f BVNorm_Local_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVNorm_Local_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_Local_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVNorm_Local_Mat(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_Local_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVNorm_Local_Svec(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVNorm_Mat(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_Private src/sys/classes/bv/interface/bvglobal.c /^PETSC_STATIC_INLINE PetscErrorCode BVNorm_Private(BV bv,Vec z,NormType type,PetscReal *val)$/;" f BVNorm_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVNorm_Svec(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVNorm_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVNorm_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)$/;" f BVOps include/slepc/private/bvimpl.h /^typedef struct _BVOps *BVOps;$/;" t typeref:struct:_BVOps BVOrthogBlockType include/slepc/finclude/slepcbvdef.h 33;" d BVOrthogBlockType include/slepcbv.h /^ BV_ORTHOG_BLOCK_CHOL } BVOrthogBlockType;$/;" t typeref:enum:__anon11 BVOrthogBlockTypes include/slepcbv.h /^PETSC_EXTERN const char *BVOrthogBlockTypes[];$/;" v BVOrthogBlockTypes src/sys/classes/bv/interface/bvfunc.c /^const char *BVOrthogBlockTypes[] = {"GS","CHOL","BVOrthogBlockType","BV_ORTHOG_BLOCK_",0};$/;" v BVOrthogRefineType include/slepc/finclude/slepcbvdef.h 32;" d BVOrthogRefineType include/slepcbv.h /^ BV_ORTHOG_REFINE_ALWAYS } BVOrthogRefineType;$/;" t typeref:enum:__anon10 BVOrthogRefineTypes include/slepcbv.h /^PETSC_EXTERN const char *BVOrthogRefineTypes[];$/;" v BVOrthogRefineTypes src/sys/classes/bv/interface/bvfunc.c /^const char *BVOrthogRefineTypes[] = {"IFNEEDED","NEVER","ALWAYS","BVOrthogRefineType","BV_ORTHOG_REFINE_",0};$/;" v BVOrthogType include/slepc/finclude/slepcbvdef.h 31;" d BVOrthogType include/slepcbv.h /^ BV_ORTHOG_MGS } BVOrthogType;$/;" t typeref:enum:__anon9 BVOrthogTypes include/slepcbv.h /^PETSC_EXTERN const char *BVOrthogTypes[];$/;" v BVOrthogTypes src/sys/classes/bv/interface/bvfunc.c /^const char *BVOrthogTypes[] = {"CGS","MGS","BVOrthogType","BV_ORTHOG_",0};$/;" v BVOrthogonalize src/sys/classes/bv/interface/bvorthog.c /^PetscErrorCode BVOrthogonalize(BV V,Mat R)$/;" f BVOrthogonalizeCGS src/sys/classes/bv/interface/bvorthog.c /^static PetscErrorCode BVOrthogonalizeCGS(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep)$/;" f file: BVOrthogonalizeCGS1 src/sys/classes/bv/interface/bvorthog.c /^PetscErrorCode BVOrthogonalizeCGS1(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *onorm,PetscReal *norm)$/;" f BVOrthogonalizeColumn src/sys/classes/bv/interface/bvorthog.c /^PetscErrorCode BVOrthogonalizeColumn(BV bv,PetscInt j,PetscScalar *H,PetscReal *norm,PetscBool *lindep)$/;" f BVOrthogonalizeMGS src/sys/classes/bv/interface/bvorthog.c /^static PetscErrorCode BVOrthogonalizeMGS(BV bv,PetscInt j,Vec v,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep)$/;" f file: BVOrthogonalizeMGS1 src/sys/classes/bv/interface/bvorthog.c /^static PetscErrorCode BVOrthogonalizeMGS1(BV bv,PetscInt k,Vec v,PetscBool *which,PetscScalar *H)$/;" f file: BVOrthogonalizeSomeColumn src/sys/classes/bv/interface/bvorthog.c /^PetscErrorCode BVOrthogonalizeSomeColumn(BV bv,PetscInt j,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep)$/;" f BVOrthogonalizeVec src/sys/classes/bv/interface/bvorthog.c /^PetscErrorCode BVOrthogonalizeVec(BV bv,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep)$/;" f BVOrthogonalize_Chol src/sys/classes/bv/interface/bvorthog.c /^static PetscErrorCode BVOrthogonalize_Chol(BV V,Mat Rin)$/;" f file: BVOrthogonalize_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVOrthogonalize_Contiguous(BV V,Mat R)$/;" f BVOrthogonalize_GS src/sys/classes/bv/interface/bvorthog.c /^static PetscErrorCode BVOrthogonalize_GS(BV V,Mat R)$/;" f file: BVOrthogonalize_LAPACK_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVOrthogonalize_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,PetscScalar *Q,PetscScalar *R,PetscBool mpi)$/;" f BVOrthogonalize_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVOrthogonalize_Mat(BV V,Mat R)$/;" f BVOrthogonalize_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVOrthogonalize_Svec(BV V,Mat R)$/;" f BVPackageInitialized src/sys/classes/bv/interface/bvfunc.c /^static PetscBool BVPackageInitialized = PETSC_FALSE;$/;" v file: BVRegister src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVRegister(const char *name,PetscErrorCode (*function)(BV))$/;" f BVRegisterAll src/sys/classes/bv/interface/bvregis.c /^PetscErrorCode BVRegisterAll(void)$/;" f BVRegisterAllCalled include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscBool BVRegisterAllCalled;$/;" v BVRegisterAllCalled src/sys/classes/bv/interface/bvbasic.c /^PetscBool BVRegisterAllCalled = PETSC_FALSE;$/;" v BVResize src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVResize(BV bv,PetscInt m,PetscBool copy)$/;" f BVResize_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVResize_Contiguous(BV bv,PetscInt m,PetscBool copy)$/;" f BVResize_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVResize_Mat(BV bv,PetscInt m,PetscBool copy)$/;" f BVResize_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVResize_Svec(BV bv,PetscInt m,PetscBool copy)$/;" f BVResize_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVResize_Vecs(BV bv,PetscInt m,PetscBool copy)$/;" f BVRestoreArray src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVRestoreArray(BV bv,PetscScalar **a)$/;" f BVRestoreArrayRead src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVRestoreArrayRead(BV bv,const PetscScalar **a)$/;" f BVRestoreArrayRead_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVRestoreArrayRead_Mat(BV bv,const PetscScalar **a)$/;" f BVRestoreArrayRead_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVRestoreArrayRead_Svec(BV bv,const PetscScalar **a)$/;" f BVRestoreArrayRead_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVRestoreArrayRead_Vecs(BV bv,const PetscScalar **a)$/;" f BVRestoreArray_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVRestoreArray_Mat(BV bv,PetscScalar **a)$/;" f BVRestoreArray_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVRestoreArray_Svec(BV bv,PetscScalar **a)$/;" f BVRestoreArray_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVRestoreArray_Vecs(BV bv,PetscScalar **a)$/;" f BVRestoreColumn src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVRestoreColumn(BV bv,PetscInt j,Vec *v)$/;" f BVRestoreColumn_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVRestoreColumn_Mat(BV bv,PetscInt j,Vec *v)$/;" f BVRestoreColumn_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVRestoreColumn_Svec(BV bv,PetscInt j,Vec *v)$/;" f BVSVEC include/slepc/finclude/slepcbvdef.h 37;" d BVSVEC include/slepcbv.h 48;" d BVScale src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVScale(BV bv,PetscScalar alpha)$/;" f BVScaleColumn src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVScaleColumn(BV bv,PetscInt j,PetscScalar alpha)$/;" f BVScale_BLAS_Private src/sys/classes/bv/interface/bvblas.c /^PetscErrorCode BVScale_BLAS_Private(BV bv,PetscInt n_,PetscScalar *A,PetscScalar alpha)$/;" f BVScale_Contiguous src/sys/classes/bv/impls/contiguous/contig.c /^PetscErrorCode BVScale_Contiguous(BV bv,PetscInt j,PetscScalar alpha)$/;" f BVScale_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVScale_Mat(BV bv,PetscInt j,PetscScalar alpha)$/;" f BVScale_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVScale_Svec(BV bv,PetscInt j,PetscScalar alpha)$/;" f BVScale_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVScale_Vecs(BV bv,PetscInt j,PetscScalar alpha)$/;" f BVSetActiveColumns src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetActiveColumns(BV bv,PetscInt l,PetscInt k)$/;" f BVSetFromOptions src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetFromOptions(BV bv)$/;" f BVSetFromOptions_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVSetFromOptions_Vecs(PetscOptionItems *PetscOptionsObject,BV bv)$/;" f BVSetMatMultMethod src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetMatMultMethod(BV bv,BVMatMultType method)$/;" f BVSetMatrix src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetMatrix(BV bv,Mat B,PetscBool indef)$/;" f BVSetNumConstraints src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetNumConstraints(BV V,PetscInt nc)$/;" f BVSetOptionsPrefix src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVSetOptionsPrefix(BV bv,const char *prefix)$/;" f BVSetOrthogonalization src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetOrthogonalization(BV bv,BVOrthogType type,BVOrthogRefineType refine,PetscReal eta,BVOrthogBlockType block)$/;" f BVSetRandom src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVSetRandom(BV bv)$/;" f BVSetRandomColumn src/sys/classes/bv/interface/bvops.c /^PetscErrorCode BVSetRandomColumn(BV bv,PetscInt j)$/;" f BVSetRandomContext src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetRandomContext(BV bv,PetscRandom rand)$/;" f BVSetSignature src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetSignature(BV bv,Vec omega)$/;" f BVSetSizes src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetSizes(BV bv,PetscInt n,PetscInt N,PetscInt m)$/;" f BVSetSizesFromVec src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetSizesFromVec(BV bv,Vec t,PetscInt m)$/;" f BVSetType src/sys/classes/bv/interface/bvbasic.c /^PetscErrorCode BVSetType(BV bv,BVType type)$/;" f BVType include/slepc/finclude/slepcbvdef.h 30;" d BVType include/slepcbv.h /^typedef const char* BVType;$/;" t BVVECS include/slepc/finclude/slepcbvdef.h 38;" d BVVECS include/slepcbv.h 49;" d BVVecsSetVmip src/sys/classes/bv/impls/vecs/vecs.c /^PETSC_STATIC_INLINE PetscErrorCode BVVecsSetVmip(BV bv,PetscInt vmip)$/;" f BVView src/sys/classes/bv/interface/bvfunc.c /^PetscErrorCode BVView(BV bv,PetscViewer viewer)$/;" f BVView_Default src/sys/classes/bv/interface/bvfunc.c /^static PetscErrorCode BVView_Default(BV bv,PetscViewer viewer)$/;" f file: BVView_Mat src/sys/classes/bv/impls/mat/bvmat.c /^PetscErrorCode BVView_Mat(BV bv,PetscViewer viewer)$/;" f BVView_Svec src/sys/classes/bv/impls/svec/svec.c /^PetscErrorCode BVView_Svec(BV bv,PetscViewer viewer)$/;" f BVView_Vecs src/sys/classes/bv/impls/vecs/vecs.c /^PetscErrorCode BVView_Vecs(BV bv,PetscViewer viewer)$/;" f BV_AllocateCachedBV include/slepc/private/bvimpl.h /^PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCachedBV(BV V)$/;" f BV_AllocateCoeffs include/slepc/private/bvimpl.h /^PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCoeffs(BV bv)$/;" f BV_AllocateMatMult include/slepc/private/bvimpl.h /^PETSC_STATIC_INLINE PetscErrorCode BV_AllocateMatMult(BV bv,Mat A,PetscInt m)$/;" f BV_AllocateSignature include/slepc/private/bvimpl.h /^PETSC_STATIC_INLINE PetscErrorCode BV_AllocateSignature(BV bv)$/;" f BV_CLASSID include/slepcbv.h /^PETSC_EXTERN PetscClassId BV_CLASSID;$/;" v BV_CLASSID src/sys/classes/bv/interface/bvfunc.c /^PetscClassId BV_CLASSID = 0;$/;" v BV_CONTIGUOUS src/sys/classes/bv/impls/contiguous/contig.c /^} BV_CONTIGUOUS;$/;" t typeref:struct:__anon115 file: BV_Copy include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_Copy src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_Create include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_Create src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_Dot include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_Dot src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_DotVec include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_DotVec src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_IPMatMult include/slepc/private/bvimpl.h /^PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMult(BV bv,Vec x)$/;" f BV_IPMatMultBV include/slepc/private/bvimpl.h /^PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMultBV(BV bv)$/;" f BV_MAT src/sys/classes/bv/impls/mat/bvmat.c /^} BV_MAT;$/;" t typeref:struct:__anon116 file: BV_MATMULT_MAT include/slepcbv.h /^ BV_MATMULT_MAT,$/;" e enum:__anon12 BV_MATMULT_MAT_SAVE include/slepcbv.h /^ BV_MATMULT_MAT_SAVE } BVMatMultType;$/;" e enum:__anon12 BV_MATMULT_VECS include/slepcbv.h /^typedef enum { BV_MATMULT_VECS,$/;" e enum:__anon12 BV_MatMult include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_MatMult src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_MatMultVec include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_MatMultVec src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_MatProject include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_MatProject src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_Mult include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_Mult src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_MultInPlace include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_MultInPlace src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_MultVec include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_MultVec src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_Norm include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_Norm src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_NormVec include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_NormVec src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_ORTHOG_BLOCK_CHOL include/slepcbv.h /^ BV_ORTHOG_BLOCK_CHOL } BVOrthogBlockType;$/;" e enum:__anon11 BV_ORTHOG_BLOCK_GS include/slepcbv.h /^typedef enum { BV_ORTHOG_BLOCK_GS,$/;" e enum:__anon11 BV_ORTHOG_CGS include/slepcbv.h /^typedef enum { BV_ORTHOG_CGS,$/;" e enum:__anon9 BV_ORTHOG_MGS include/slepcbv.h /^ BV_ORTHOG_MGS } BVOrthogType;$/;" e enum:__anon9 BV_ORTHOG_REFINE_ALWAYS include/slepcbv.h /^ BV_ORTHOG_REFINE_ALWAYS } BVOrthogRefineType;$/;" e enum:__anon10 BV_ORTHOG_REFINE_IFNEEDED include/slepcbv.h /^typedef enum { BV_ORTHOG_REFINE_IFNEEDED,$/;" e enum:__anon10 BV_ORTHOG_REFINE_NEVER include/slepcbv.h /^ BV_ORTHOG_REFINE_NEVER,$/;" e enum:__anon10 BV_Orthogonalize include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_Orthogonalize src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_OrthogonalizeVec include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_OrthogonalizeVec src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_SVEC src/sys/classes/bv/impls/svec/svec.c /^} BV_SVEC;$/;" t typeref:struct:__anon117 file: BV_SafeSqrt include/slepc/private/bvimpl.h /^PETSC_STATIC_INLINE PetscErrorCode BV_SafeSqrt(BV bv,PetscScalar alpha,PetscReal *res)$/;" f BV_Scale include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_Scale src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_SetRandom include/slepc/private/bvimpl.h /^PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;$/;" v BV_SetRandom src/sys/classes/bv/interface/bvfunc.c /^PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;$/;" v BV_VECS src/sys/classes/bv/impls/vecs/vecs.c /^} BV_VECS;$/;" t typeref:struct:__anon118 file: BV_shift src/eps/impls/davidson/davidson.h /^ PetscBool BV_shift; \/* if true BV is shifted when vectors converge *\/$/;" m struct:_dvdDashboard BX src/eps/impls/davidson/davidson.h /^ BV BX; \/* B*V *\/$/;" m struct:_dvdDashboard BackTransform_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode BackTransform_Linear(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)$/;" f file: Bid src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscObjectId Aid,Bid; \/* Id of subcommunicator matrices *\/$/;" m struct:__anon81 BlockHankel src/eps/impls/ciss/ciss.c /^static PetscErrorCode BlockHankel(EPS eps,PetscScalar *Mu,PetscInt s,PetscScalar *H)$/;" f file: BlockHankel src/nep/impls/ciss/nciss.c /^static PetscErrorCode BlockHankel(NEP nep,PetscScalar *Mu,PetscInt s,PetscScalar *H)$/;" f file: Blopex config/packages/blopex.py /^class Blopex(package.Package):$/;" c Blzpack config/packages/blzpack.py /^class Blzpack(package.Package):$/;" c Bp src/pep/impls/jd/pjdp.h /^ Vec Bp; \/* preconditioned residual of derivative polynomial, B\\p *\/$/;" m struct:__anon100 Bq src/eps/impls/external/feast/feastp.h /^ PetscScalar *work1,*work2,*Aq,*Bq; \/* workspace *\/$/;" m struct:__anon77 Bstate src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscObjectState Astate,Bstate; \/* state of subcommunicator matrices *\/$/;" m struct:__anon81 Bx include/slepc/private/bvimpl.h /^ Vec Bx; \/* result of matrix times a vector x *\/$/;" m struct:_p_BV C include/slepc/private/bvimpl.h /^ Mat B,C; \/* auxiliary dense matrices for matmult operation *\/$/;" m struct:_p_BV C src/pep/examples/tutorials/ex16f90.F90 /^ type(Mat) M, C,/;" v program:main C src/pep/impls/linear/linearp.h /^ Mat M,C,K; \/* copy of PEP coefficient matrices *\/$/;" m struct:__anon106 CFLAGS docs/makefile /^CFLAGS =$/;" m CFLAGS include/makefile /^CFLAGS =$/;" m CFLAGS include/slepc/finclude/makefile /^CFLAGS =$/;" m CFLAGS include/slepc/private/makefile /^CFLAGS =$/;" m CFLAGS src/eps/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/eps/examples/tutorials/makefile /^CFLAGS =$/;" m CFLAGS src/eps/f90-mod/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/cg/lobpcg/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/cg/rqcg/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/ciss/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/davidson/gd/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/davidson/jd/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/davidson/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/external/arpack/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/external/blopex/makefile /^CFLAGS = ${BLOPEX_INCLUDE} -DBlopexInt=PetscInt$/;" m CFLAGS src/eps/impls/external/blzpack/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/external/feast/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/external/primme/makefile /^CFLAGS = ${PRIMME_FLAGS}$/;" m CFLAGS src/eps/impls/external/trlan/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/krylov/arnoldi/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/krylov/krylovschur/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/krylov/lanczos/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/krylov/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/lapack/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/power/makefile /^CFLAGS =$/;" m CFLAGS src/eps/impls/subspace/makefile /^CFLAGS =$/;" m CFLAGS src/eps/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/eps/interface/makefile /^CFLAGS =$/;" m CFLAGS src/mfn/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/mfn/examples/tutorials/makefile /^CFLAGS =$/;" m CFLAGS src/mfn/f90-mod/makefile /^CFLAGS =$/;" m CFLAGS src/mfn/impls/expokit/makefile /^CFLAGS =$/;" m CFLAGS src/mfn/impls/krylov/makefile /^CFLAGS =$/;" m CFLAGS src/mfn/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/mfn/interface/makefile /^CFLAGS =$/;" m CFLAGS src/nep/examples/nlevp/makefile /^CFLAGS =$/;" m CFLAGS src/nep/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/nep/examples/tutorials/makefile /^CFLAGS =$/;" m CFLAGS src/nep/f90-mod/makefile /^CFLAGS =$/;" m CFLAGS src/nep/impls/ciss/makefile /^CFLAGS =$/;" m CFLAGS src/nep/impls/interpol/makefile /^CFLAGS =$/;" m CFLAGS src/nep/impls/narnoldi/makefile /^CFLAGS =$/;" m CFLAGS src/nep/impls/nleigs/makefile /^CFLAGS =$/;" m CFLAGS src/nep/impls/rii/makefile /^CFLAGS =$/;" m CFLAGS src/nep/impls/slp/makefile /^CFLAGS =$/;" m CFLAGS src/nep/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/nep/interface/makefile /^CFLAGS =$/;" m CFLAGS src/pep/examples/nlevp/makefile /^CFLAGS =$/;" m CFLAGS src/pep/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/pep/examples/tutorials/makefile /^CFLAGS =$/;" m CFLAGS src/pep/f90-mod/makefile /^CFLAGS =$/;" m CFLAGS src/pep/impls/jd/makefile /^CFLAGS =$/;" m CFLAGS src/pep/impls/krylov/makefile /^CFLAGS =$/;" m CFLAGS src/pep/impls/krylov/qarnoldi/makefile /^CFLAGS =$/;" m CFLAGS src/pep/impls/krylov/stoar/makefile /^CFLAGS =$/;" m CFLAGS src/pep/impls/krylov/toar/makefile /^CFLAGS =$/;" m CFLAGS src/pep/impls/linear/makefile /^CFLAGS =$/;" m CFLAGS src/pep/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/pep/interface/makefile /^CFLAGS =$/;" m CFLAGS src/svd/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/svd/examples/tutorials/makefile /^CFLAGS =$/;" m CFLAGS src/svd/f90-mod/makefile /^CFLAGS =$/;" m CFLAGS src/svd/impls/cross/makefile /^CFLAGS =$/;" m CFLAGS src/svd/impls/cyclic/makefile /^CFLAGS =$/;" m CFLAGS src/svd/impls/lanczos/makefile /^CFLAGS =$/;" m CFLAGS src/svd/impls/lapack/makefile /^CFLAGS =$/;" m CFLAGS src/svd/impls/trlanczos/makefile /^CFLAGS =$/;" m CFLAGS src/svd/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/svd/interface/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/bv/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/bv/impls/contiguous/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/bv/impls/mat/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/bv/impls/svec/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/bv/impls/vecs/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/bv/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/bv/interface/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/ghep/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/ghiep/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/gnhep/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/hep/bdc/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/hep/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/nep/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/nhep/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/pep/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/impls/svd/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/ds/interface/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/combine/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/exp/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/invsqrt/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/log/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/phi/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/rational/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/impls/sqrt/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/fn/interface/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/rg/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/rg/impls/ellipse/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/rg/impls/interval/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/rg/impls/polygon/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/rg/impls/ring/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/rg/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/rg/interface/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/examples/tests/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/impls/cayley/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/impls/precond/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/impls/shell/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/impls/shell/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/impls/shift/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/impls/sinvert/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/interface/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/sys/classes/st/interface/makefile /^CFLAGS =$/;" m CFLAGS src/sys/f90-mod/makefile /^CFLAGS =$/;" m CFLAGS src/sys/ftn-custom/makefile /^CFLAGS =$/;" m CFLAGS src/sys/makefile /^CFLAGS =$/;" m CFLAGS src/sys/vec/makefile /^CFLAGS =$/;" m CISSRedundantMat src/eps/impls/ciss/ciss.c /^static PetscErrorCode CISSRedundantMat(EPS eps)$/;" f file: CISSScatterVec src/eps/impls/ciss/ciss.c /^static PetscErrorCode CISSScatterVec(EPS eps)$/;" f file: CISSVecSetRandom src/eps/impls/ciss/ciss.c /^static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1)$/;" f file: CISSVecSetRandom src/nep/impls/ciss/nciss.c /^static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1)$/;" f file: CLEANFILES src/eps/f90-mod/makefile /^CLEANFILES = *.mod$/;" m CLEANFILES src/mfn/f90-mod/makefile /^CLEANFILES = *.mod$/;" m CLEANFILES src/nep/f90-mod/makefile /^CLEANFILES = *.mod$/;" m CLEANFILES src/pep/f90-mod/makefile /^CLEANFILES = *.mod$/;" m CLEANFILES src/svd/f90-mod/makefile /^CLEANFILES = *.mod$/;" m CLEANFILES src/sys/f90-mod/makefile /^CLEANFILES = *.mod$/;" m COMM_ARG src/eps/impls/external/arpack/arpackp.h 148;" d COMM_ARG src/eps/impls/external/arpack/arpackp.h 166;" d CONFIGURE_OPTIONS setup.py /^CONFIGURE_OPTIONS = []$/;" v CPPFLAGS src/eps/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/eps/examples/tutorials/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/mfn/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/mfn/examples/tutorials/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/nep/examples/nlevp/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/nep/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/nep/examples/tutorials/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/pep/examples/nlevp/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/pep/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/pep/examples/tutorials/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/svd/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/svd/examples/tutorials/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/sys/classes/bv/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/sys/classes/ds/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/sys/classes/fn/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/sys/classes/rg/examples/tests/makefile /^CPPFLAGS =$/;" m CPPFLAGS src/sys/classes/st/examples/tests/makefile /^CPPFLAGS =$/;" m CTX_BRUSSEL src/eps/examples/tutorials/ex30.c /^} CTX_BRUSSEL;$/;" t typeref:struct:__anon56 file: CTX_BRUSSEL src/eps/examples/tutorials/ex9.c /^} CTX_BRUSSEL;$/;" t typeref:struct:__anon58 file: CTX_FOLD src/eps/examples/tutorials/ex24.c /^} CTX_FOLD;$/;" t typeref:struct:__anon55 file: CalcMu src/eps/impls/ciss/ciss.c /^static PetscErrorCode CalcMu(EPS eps,PetscScalar *Mu)$/;" f file: CalcMu src/nep/impls/ciss/nciss.c /^static PetscErrorCode CalcMu(NEP nep, PetscScalar *Mu)$/;" f file: ChebyshevNodes src/nep/impls/interpol/interpol.c /^static PetscErrorCode ChebyshevNodes(PetscInt d,PetscReal a,PetscReal b,PetscScalar *x,PetscReal *dct2)$/;" f file: Check config/packages/arpack.py /^ def Check(self,conf,vars,cmake,petsc):$/;" m class:Arpack Check config/packages/blzpack.py /^ def Check(self,conf,vars,cmake,petsc):$/;" m class:Blzpack Check config/packages/feast.py /^ def Check(self,conf,vars,cmake,petsc):$/;" m class:Feast Check config/packages/lapack.py /^ def Check(self,conf,vars,cmake,petsc):$/;" m class:Lapack Check config/packages/petsc.py /^ def Check(self):$/;" m class:PETSc Check config/packages/primme.py /^ def Check(self,conf,vars,cmake,petsc):$/;" m class:Primme Check config/packages/trlan.py /^ def Check(self,conf,vars,cmake,petsc):$/;" m class:Trlan CheckSolution src/nep/examples/tutorials/ex20.c /^PetscErrorCode CheckSolution(PetscScalar lambda,Vec y,PetscReal *error,void *ctx)$/;" f CleanDenseSchur src/sys/classes/ds/impls/gnhep/dsgnhep.c /^static PetscErrorCode CleanDenseSchur(PetscInt n,PetscInt k,PetscScalar *S,PetscInt ldS,PetscScalar *T,PetscInt ldT,PetscScalar *X,PetscInt ldX,PetscScalar *Y,PetscInt ldY,PetscBool doProd)$/;" f file: ComputeResidualNorm src/eps/examples/tutorials/ex24.c /^PetscErrorCode ComputeResidualNorm(Mat A,PetscScalar lambda,Vec x,PetscReal *r)$/;" f ComputeSingularities src/nep/examples/nlevp/gun.c /^PetscErrorCode ComputeSingularities(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *pt)$/;" f ComputeSingularities src/nep/examples/tutorials/ex27.c /^PetscErrorCode ComputeSingularities(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *pt)$/;" f ConstructS src/eps/impls/ciss/ciss.c /^static PetscErrorCode ConstructS(EPS eps)$/;" f file: ConstructS src/nep/impls/ciss/nciss.c /^static PetscErrorCode ConstructS(NEP nep)$/;" f file: CreateDir config/configure.py /^def CreateDir(basedir,dirname,log):$/;" f CreateDirTest config/configure.py /^def CreateDirTest(basedir,dirname,log):$/;" f CreateDirTwo config/configure.py /^def CreateDirTwo(basedir,dir1,dir2,log):$/;" f CreateFile config/configure.py /^def CreateFile(basedir,fname,log):$/;" f D include/slepc/private/epsimpl.h /^ Vec D; \/* diagonal matrix for balancing *\/$/;" m struct:_p_EPS D include/slepc/private/stimpl.h /^ Vec D; \/* diagonal matrix for balancing *\/$/;" m struct:_p_ST D src/eps/examples/tutorials/ex31.c /^PetscScalar D[3]; \/* D = 0.1*M *\/$/;" v D src/nep/impls/nleigs/nleigs.c /^ Mat *D; \/* divided difference matrices *\/$/;" m struct:__anon92 file: DATAPATH src/eps/examples/tutorials/makefile /^DATAPATH = ${SLEPC_DIR}\/share\/slepc\/datafiles\/matrices$/;" m DATAPATH src/mfn/examples/tests/makefile /^DATAPATH = ${SLEPC_DIR}\/share\/slepc\/datafiles\/matrices$/;" m DATAPATH src/pep/examples/tutorials/makefile /^DATAPATH = ${SLEPC_DIR}\/share\/slepc\/datafiles\/matrices$/;" m DATAPATH src/svd/examples/tutorials/makefile /^DATAPATH = ${SLEPC_DIR}\/share\/slepc\/datafiles\/matrices$/;" m DIRS docs/makefile /^DIRS = $/;" m DIRS include/makefile /^DIRS = slepc\/finclude slepc\/private$/;" m DIRS include/slepc/finclude/makefile /^DIRS = $/;" m DIRS include/slepc/private/makefile /^DIRS = $/;" m DIRS makefile /^DIRS = src include docs$/;" m DIRS src/eps/examples/makefile /^DIRS = tests tutorials$/;" m DIRS src/eps/impls/cg/lobpcg/makefile /^DIRS =$/;" m DIRS src/eps/impls/cg/makefile /^DIRS = rqcg lobpcg$/;" m DIRS src/eps/impls/cg/rqcg/makefile /^DIRS =$/;" m DIRS src/eps/impls/ciss/makefile /^DIRS =$/;" m DIRS src/eps/impls/davidson/gd/makefile /^DIRS =$/;" m DIRS src/eps/impls/davidson/jd/makefile /^DIRS =$/;" m DIRS src/eps/impls/davidson/makefile /^DIRS = gd jd$/;" m DIRS src/eps/impls/external/arpack/makefile /^DIRS =$/;" m DIRS src/eps/impls/external/blopex/makefile /^DIRS =$/;" m DIRS src/eps/impls/external/blzpack/makefile /^DIRS =$/;" m DIRS src/eps/impls/external/feast/makefile /^DIRS =$/;" m DIRS src/eps/impls/external/makefile /^DIRS = arpack blopex blzpack primme trlan feast$/;" m DIRS src/eps/impls/external/primme/makefile /^DIRS =$/;" m DIRS src/eps/impls/external/trlan/makefile /^DIRS =$/;" m DIRS src/eps/impls/krylov/arnoldi/makefile /^DIRS =$/;" m DIRS src/eps/impls/krylov/krylovschur/makefile /^DIRS =$/;" m DIRS src/eps/impls/krylov/lanczos/makefile /^DIRS =$/;" m DIRS src/eps/impls/krylov/makefile /^DIRS = arnoldi lanczos krylovschur$/;" m DIRS src/eps/impls/lapack/makefile /^DIRS =$/;" m DIRS src/eps/impls/makefile /^DIRS = power subspace krylov davidson cg ciss lapack external$/;" m DIRS src/eps/impls/power/makefile /^DIRS =$/;" m DIRS src/eps/impls/subspace/makefile /^DIRS =$/;" m DIRS src/eps/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/eps/interface/makefile /^DIRS =$/;" m DIRS src/eps/makefile /^DIRS = interface impls examples f90-mod$/;" m DIRS src/makefile /^DIRS = sys eps svd pep nep mfn$/;" m DIRS src/mfn/examples/makefile /^DIRS = tests tutorials$/;" m DIRS src/mfn/impls/expokit/makefile /^DIRS =$/;" m DIRS src/mfn/impls/krylov/makefile /^DIRS =$/;" m DIRS src/mfn/impls/makefile /^DIRS = krylov expokit$/;" m DIRS src/mfn/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/mfn/interface/makefile /^DIRS =$/;" m DIRS src/mfn/makefile /^DIRS = interface impls examples f90-mod$/;" m DIRS src/nep/examples/makefile /^DIRS = tests tutorials nlevp$/;" m DIRS src/nep/impls/ciss/makefile /^DIRS =$/;" m DIRS src/nep/impls/interpol/makefile /^DIRS =$/;" m DIRS src/nep/impls/makefile /^DIRS = rii slp narnoldi interpol ciss nleigs$/;" m DIRS src/nep/impls/narnoldi/makefile /^DIRS =$/;" m DIRS src/nep/impls/nleigs/makefile /^DIRS =$/;" m DIRS src/nep/impls/rii/makefile /^DIRS =$/;" m DIRS src/nep/impls/slp/makefile /^DIRS =$/;" m DIRS src/nep/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/nep/interface/makefile /^DIRS =$/;" m DIRS src/nep/makefile /^DIRS = interface impls examples f90-mod$/;" m DIRS src/pep/examples/makefile /^DIRS = tests tutorials nlevp$/;" m DIRS src/pep/impls/jd/makefile /^DIRS =$/;" m DIRS src/pep/impls/krylov/makefile /^DIRS = qarnoldi toar stoar$/;" m DIRS src/pep/impls/krylov/qarnoldi/makefile /^DIRS =$/;" m DIRS src/pep/impls/krylov/stoar/makefile /^DIRS =$/;" m DIRS src/pep/impls/krylov/toar/makefile /^DIRS =$/;" m DIRS src/pep/impls/linear/makefile /^DIRS =$/;" m DIRS src/pep/impls/makefile /^DIRS = linear krylov jd$/;" m DIRS src/pep/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/pep/interface/makefile /^DIRS =$/;" m DIRS src/pep/makefile /^DIRS = interface impls examples f90-mod$/;" m DIRS src/svd/examples/makefile /^DIRS = tests tutorials$/;" m DIRS src/svd/impls/cross/makefile /^DIRS =$/;" m DIRS src/svd/impls/cyclic/makefile /^DIRS =$/;" m DIRS src/svd/impls/lanczos/makefile /^DIRS =$/;" m DIRS src/svd/impls/lapack/makefile /^DIRS =$/;" m DIRS src/svd/impls/makefile /^DIRS = cross cyclic lapack lanczos trlanczos$/;" m DIRS src/svd/impls/trlanczos/makefile /^DIRS =$/;" m DIRS src/svd/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/svd/interface/makefile /^DIRS =$/;" m DIRS src/svd/makefile /^DIRS = interface impls examples f90-mod$/;" m DIRS src/sys/classes/bv/examples/makefile /^DIRS = tests$/;" m DIRS src/sys/classes/bv/impls/contiguous/makefile /^DIRS =$/;" m DIRS src/sys/classes/bv/impls/makefile /^DIRS = vecs contiguous svec mat$/;" m DIRS src/sys/classes/bv/impls/mat/makefile /^DIRS =$/;" m DIRS src/sys/classes/bv/impls/svec/makefile /^DIRS =$/;" m DIRS src/sys/classes/bv/impls/vecs/makefile /^DIRS =$/;" m DIRS src/sys/classes/bv/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/sys/classes/bv/interface/makefile /^DIRS =$/;" m DIRS src/sys/classes/bv/makefile /^DIRS = interface impls examples$/;" m DIRS src/sys/classes/ds/examples/makefile /^DIRS = tests$/;" m DIRS src/sys/classes/ds/impls/ghep/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/impls/ghiep/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/impls/gnhep/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/impls/hep/bdc/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/impls/hep/makefile /^DIRS = bdc$/;" m DIRS src/sys/classes/ds/impls/makefile /^DIRS = hep nhep ghep ghiep gnhep svd pep nep$/;" m DIRS src/sys/classes/ds/impls/nep/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/impls/nhep/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/impls/pep/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/impls/svd/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/interface/makefile /^DIRS =$/;" m DIRS src/sys/classes/ds/makefile /^DIRS = interface impls examples$/;" m DIRS src/sys/classes/fn/examples/makefile /^DIRS = tests$/;" m DIRS src/sys/classes/fn/impls/combine/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/impls/exp/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/impls/invsqrt/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/impls/log/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/impls/makefile /^DIRS = combine exp log phi rational sqrt invsqrt$/;" m DIRS src/sys/classes/fn/impls/phi/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/impls/rational/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/impls/sqrt/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/interface/makefile /^DIRS =$/;" m DIRS src/sys/classes/fn/makefile /^DIRS = interface impls examples$/;" m DIRS src/sys/classes/makefile /^DIRS = ds fn st bv rg$/;" m DIRS src/sys/classes/rg/examples/makefile /^DIRS = tests$/;" m DIRS src/sys/classes/rg/impls/ellipse/makefile /^DIRS =$/;" m DIRS src/sys/classes/rg/impls/interval/makefile /^DIRS =$/;" m DIRS src/sys/classes/rg/impls/makefile /^DIRS = ellipse interval polygon ring$/;" m DIRS src/sys/classes/rg/impls/polygon/makefile /^DIRS =$/;" m DIRS src/sys/classes/rg/impls/ring/makefile /^DIRS =$/;" m DIRS src/sys/classes/rg/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/sys/classes/rg/interface/makefile /^DIRS =$/;" m DIRS src/sys/classes/rg/makefile /^DIRS = interface impls examples$/;" m DIRS src/sys/classes/st/examples/makefile /^DIRS = tests$/;" m DIRS src/sys/classes/st/impls/cayley/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/impls/makefile /^DIRS = shell shift sinvert cayley precond$/;" m DIRS src/sys/classes/st/impls/precond/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/impls/shell/ftn-custom/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/impls/shell/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/impls/shift/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/impls/sinvert/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/interface/ftn-custom/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/interface/makefile /^DIRS =$/;" m DIRS src/sys/classes/st/makefile /^DIRS = interface impls examples$/;" m DIRS src/sys/ftn-custom/makefile /^DIRS =$/;" m DIRS src/sys/makefile /^DIRS = classes vec f90-mod$/;" m DIRS src/sys/vec/makefile /^DIRS =$/;" m DOCS docs/makefile /^DOCS = $/;" m DOC_GEN docs/manual/makefile /^DOC_GEN = $(subst .tex,.aux,$(DOC_TEX)) \\$/;" m DOC_SRC docs/manual/makefile /^DOC_SRC = $(DOC_TEX) slepc.bbl$/;" m DOC_TEX docs/manual/makefile /^DOC_TEX = slepc.tex \\$/;" m DS include/slepc/finclude/slepcdsdef.h 27;" d DS include/slepcds.h /^typedef struct _p_DS* DS;$/;" t typeref:struct:_p_DS DSAllocate src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSAllocate(DS ds,PetscInt ld)$/;" f DSAllocateMatReal_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSAllocateMatReal_Private(DS ds,DSMatType m)$/;" f DSAllocateMat_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSAllocateMat_Private(DS ds,DSMatType m)$/;" f DSAllocateWork_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSAllocateWork_Private(DS ds,PetscInt s,PetscInt r,PetscInt i)$/;" f DSAllocate_GHEP src/sys/classes/ds/impls/ghep/dsghep.c /^PetscErrorCode DSAllocate_GHEP(DS ds,PetscInt ld)$/;" f DSAllocate_GHIEP src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSAllocate_GHIEP(DS ds,PetscInt ld)$/;" f DSAllocate_GNHEP src/sys/classes/ds/impls/gnhep/dsgnhep.c /^PetscErrorCode DSAllocate_GNHEP(DS ds,PetscInt ld)$/;" f DSAllocate_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSAllocate_HEP(DS ds,PetscInt ld)$/;" f DSAllocate_NEP src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSAllocate_NEP(DS ds,PetscInt ld)$/;" f DSAllocate_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSAllocate_NHEP(DS ds,PetscInt ld)$/;" f DSAllocate_PEP src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSAllocate_PEP(DS ds,PetscInt ld)$/;" f DSAllocate_SVD src/sys/classes/ds/impls/svd/dssvd.c /^PetscErrorCode DSAllocate_SVD(DS ds,PetscInt ld)$/;" f DSAppendOptionsPrefix src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSAppendOptionsPrefix(DS ds,const char *prefix)$/;" f DSCheckAlloc include/slepc/private/dsimpl.h 84;" d DSCheckAlloc include/slepc/private/dsimpl.h 89;" d DSCheckSolved include/slepc/private/dsimpl.h 85;" d DSCheckSolved include/slepc/private/dsimpl.h 94;" d DSCond src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSCond(DS ds,PetscReal *cond)$/;" f DSCond_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSCond_HEP(DS ds,PetscReal *cond)$/;" f DSCond_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSCond_NHEP(DS ds,PetscReal *cond)$/;" f DSCopyMat src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSCopyMat(DS ds,DSMatType m,PetscInt mr,PetscInt mc,Mat A,PetscInt Ar,PetscInt Ac,PetscInt rows,PetscInt cols,PetscBool out)$/;" f DSCopyMatrix_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSCopyMatrix_Private(DS ds,DSMatType dst,DSMatType src)$/;" f DSCreate src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSCreate(MPI_Comm comm,DS *newds)$/;" f DSCreate_GHEP src/sys/classes/ds/impls/ghep/dsghep.c /^PETSC_EXTERN PetscErrorCode DSCreate_GHEP(DS ds)$/;" f DSCreate_GHIEP src/sys/classes/ds/impls/ghiep/dsghiep.c /^PETSC_EXTERN PetscErrorCode DSCreate_GHIEP(DS ds)$/;" f DSCreate_GNHEP src/sys/classes/ds/impls/gnhep/dsgnhep.c /^PETSC_EXTERN PetscErrorCode DSCreate_GNHEP(DS ds)$/;" f DSCreate_HEP src/sys/classes/ds/impls/hep/dshep.c /^PETSC_EXTERN PetscErrorCode DSCreate_HEP(DS ds)$/;" f DSCreate_NEP src/sys/classes/ds/impls/nep/dsnep.c /^PETSC_EXTERN PetscErrorCode DSCreate_NEP(DS ds)$/;" f DSCreate_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PETSC_EXTERN PetscErrorCode DSCreate_NHEP(DS ds)$/;" f DSCreate_PEP src/sys/classes/ds/impls/pep/dspep.c /^PETSC_EXTERN PetscErrorCode DSCreate_PEP(DS ds)$/;" f DSCreate_SVD src/sys/classes/ds/impls/svd/dssvd.c /^PETSC_EXTERN PetscErrorCode DSCreate_SVD(DS ds)$/;" f DSDestroy src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSDestroy(DS *ds)$/;" f DSDestroy_NEP src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSDestroy_NEP(DS ds)$/;" f DSDestroy_PEP src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSDestroy_PEP(DS ds)$/;" f DSFinalizePackage src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSFinalizePackage(void)$/;" f DSGHEP include/slepc/finclude/slepcdsdef.h 36;" d DSGHEP include/slepcds.h 52;" d DSGHIEP include/slepc/finclude/slepcdsdef.h 37;" d DSGHIEP include/slepcds.h 53;" d DSGHIEPComplexEigs src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSGHIEPComplexEigs(DS ds,PetscInt n0,PetscInt n1,PetscScalar *wr,PetscScalar *wi)$/;" f DSGHIEPInverseIteration src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSGHIEPInverseIteration(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSGHIEPOrthogEigenv src/sys/classes/ds/impls/ghiep/invit.c /^PetscErrorCode DSGHIEPOrthogEigenv(DS ds,DSMatType mat,PetscScalar *wr,PetscScalar *wi,PetscBool accum)$/;" f DSGHIEPRealBlocks src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSGHIEPRealBlocks(DS ds)$/;" f DSGHIEP_Eigen3DQDS src/sys/classes/ds/impls/ghiep/dqds.c /^static PetscErrorCode DSGHIEP_Eigen3DQDS(PetscInt n,PetscReal *a,PetscReal *b,PetscReal *c,PetscScalar *wr,PetscScalar *wi,PetscReal *work)$/;" f file: DSGNHEP include/slepc/finclude/slepcdsdef.h 38;" d DSGNHEP include/slepcds.h 54;" d DSGetArray src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSGetArray(DS ds,DSMatType m,PetscScalar *a[])$/;" f DSGetArrayReal src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSGetArrayReal(DS ds,DSMatType m,PetscReal *a[])$/;" f DSGetBlockSize src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetBlockSize(DS ds,PetscInt *bs)$/;" f DSGetCompact src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetCompact(DS ds,PetscBool *comp)$/;" f DSGetDimensions src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSGetDimensions(DS ds,PetscInt *n,PetscInt *m,PetscInt *l,PetscInt *k,PetscInt *t)$/;" f DSGetExtraRow src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetExtraRow(DS ds,PetscBool *ext)$/;" f DSGetLeadingDimension src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSGetLeadingDimension(DS ds,PetscInt *ld)$/;" f DSGetMat src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSGetMat(DS ds,DSMatType m,Mat *A)$/;" f DSGetMethod src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetMethod(DS ds,PetscInt *meth)$/;" f DSGetOptionsPrefix src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetOptionsPrefix(DS ds,const char *prefix[])$/;" f DSGetRefined src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetRefined(DS ds,PetscBool *ref)$/;" f DSGetSlepcSC src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetSlepcSC(DS ds,SlepcSC *sc)$/;" f DSGetState src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSGetState(DS ds,DSStateType *state)$/;" f DSGetType src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSGetType(DS ds,DSType *type)$/;" f DSHEP include/slepc/finclude/slepcdsdef.h 34;" d DSHEP include/slepcds.h 50;" d DSInitializePackage src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSInitializePackage()$/;" f DSIntermediate_GHIEP src/sys/classes/ds/impls/ghiep/invit.c /^PetscErrorCode DSIntermediate_GHIEP(DS ds)$/;" f DSIntermediate_HEP src/sys/classes/ds/impls/hep/dshep.c /^static PetscErrorCode DSIntermediate_HEP(DS ds)$/;" f file: DSList include/slepcds.h /^PETSC_EXTERN PetscFunctionList DSList;$/;" v DSList src/sys/classes/ds/interface/dsbasic.c /^PetscFunctionList DSList = 0;$/;" v DSMatExtra include/slepcds.h /^PETSC_EXTERN DSMatType DSMatExtra[];$/;" v DSMatExtra src/sys/classes/ds/interface/dsbasic.c /^DSMatType DSMatExtra[DS_NUM_EXTRA] = {DS_MAT_E0,DS_MAT_E1,DS_MAT_E2,DS_MAT_E3,DS_MAT_E4,DS_MAT_E5,DS_MAT_E6,DS_MAT_E7,DS_MAT_E8,DS_MAT_E9};$/;" v DSMatName include/slepc/private/dsimpl.h /^PETSC_INTERN const char *DSMatName[];$/;" v DSMatName src/sys/classes/ds/interface/dsbasic.c /^const char *DSMatName[DS_NUM_MAT] = {"A","B","C","T","D","Q","Z","X","Y","U","VT","W","E0","E1","E2","E3","E4","E5","E6","E7","E8","E9"};$/;" v DSMatType include/slepc/finclude/slepcdsdef.h 32;" d DSMatType include/slepcds.h /^ DS_NUM_MAT } DSMatType;$/;" t typeref:enum:__anon14 DSNEP include/slepc/finclude/slepcdsdef.h 41;" d DSNEP include/slepcds.h 57;" d DSNEPComputeMatrix src/sys/classes/ds/impls/nep/dsnep.c /^static PetscErrorCode DSNEPComputeMatrix(DS ds,PetscScalar lambda,PetscBool deriv,DSMatType mat)$/;" f file: DSNEPGetFN src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSNEPGetFN(DS ds,PetscInt k,FN *fn)$/;" f DSNEPGetFN_NEP src/sys/classes/ds/impls/nep/dsnep.c /^static PetscErrorCode DSNEPGetFN_NEP(DS ds,PetscInt k,FN *fn)$/;" f file: DSNEPGetNumFN src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSNEPGetNumFN(DS ds,PetscInt *n)$/;" f DSNEPGetNumFN_NEP src/sys/classes/ds/impls/nep/dsnep.c /^static PetscErrorCode DSNEPGetNumFN_NEP(DS ds,PetscInt *n)$/;" f file: DSNEPSetFN src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSNEPSetFN(DS ds,PetscInt n,FN fn[])$/;" f DSNEPSetFN_NEP src/sys/classes/ds/impls/nep/dsnep.c /^static PetscErrorCode DSNEPSetFN_NEP(DS ds,PetscInt n,FN fn[])$/;" f file: DSNHEP include/slepc/finclude/slepcdsdef.h 35;" d DSNHEP include/slepcds.h 51;" d DSNormalize src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSNormalize(DS ds,DSMatType mat,PetscInt col)$/;" f DSNormalize_GHEP src/sys/classes/ds/impls/ghep/dsghep.c /^PetscErrorCode DSNormalize_GHEP(DS ds,DSMatType mat,PetscInt col)$/;" f DSNormalize_GHIEP src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSNormalize_GHIEP(DS ds,DSMatType mat,PetscInt col)$/;" f DSNormalize_GNHEP src/sys/classes/ds/impls/gnhep/dsgnhep.c /^PetscErrorCode DSNormalize_GNHEP(DS ds,DSMatType mat,PetscInt col)$/;" f DSNormalize_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSNormalize_HEP(DS ds,DSMatType mat,PetscInt col)$/;" f DSNormalize_NEP src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSNormalize_NEP(DS ds,DSMatType mat,PetscInt col)$/;" f DSNormalize_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSNormalize_NHEP(DS ds,DSMatType mat,PetscInt col)$/;" f DSNormalize_PEP src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSNormalize_PEP(DS ds,DSMatType mat,PetscInt col)$/;" f DSOps include/slepc/private/dsimpl.h /^typedef struct _DSOps *DSOps;$/;" t typeref:struct:_DSOps DSOrthogonalize src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscInt *lindcols)$/;" f DSPEP include/slepc/finclude/slepcdsdef.h 40;" d DSPEP include/slepcds.h 56;" d DSPEPGetDegree src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSPEPGetDegree(DS ds,PetscInt *d)$/;" f DSPEPGetDegree_PEP src/sys/classes/ds/impls/pep/dspep.c /^static PetscErrorCode DSPEPGetDegree_PEP(DS ds,PetscInt *d)$/;" f file: DSPEPSetDegree src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSPEPSetDegree(DS ds,PetscInt d)$/;" f DSPEPSetDegree_PEP src/sys/classes/ds/impls/pep/dspep.c /^static PetscErrorCode DSPEPSetDegree_PEP(DS ds,PetscInt d)$/;" f file: DSPackageInitialized src/sys/classes/ds/interface/dsbasic.c /^static PetscBool DSPackageInitialized = PETSC_FALSE;$/;" v file: DSPermuteBoth_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSPermuteBoth_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat1,DSMatType mat2,PetscInt *perm)$/;" f DSPermuteColumns_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSPermuteColumns_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat,PetscInt *perm)$/;" f DSPermuteRows_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSPermuteRows_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat,PetscInt *perm)$/;" f DSPseudoOrthogonalize src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSPseudoOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscReal *s,PetscInt *lindcols,PetscReal *ns)$/;" f DSRegister src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSRegister(const char *name,PetscErrorCode (*function)(DS))$/;" f DSRegisterAll src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSRegisterAll(void)$/;" f DSRegisterAllCalled include/slepc/private/dsimpl.h /^PETSC_EXTERN PetscBool DSRegisterAllCalled;$/;" v DSRegisterAllCalled src/sys/classes/ds/interface/dsbasic.c /^PetscBool DSRegisterAllCalled = PETSC_FALSE;$/;" v DSReset src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSReset(DS ds)$/;" f DSRestoreArray src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSRestoreArray(DS ds,DSMatType m,PetscScalar *a[])$/;" f DSRestoreArrayReal src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSRestoreArrayReal(DS ds,DSMatType m,PetscReal *a[])$/;" f DSRestoreMat src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSRestoreMat(DS ds,DSMatType m,Mat *A)$/;" f DSSVD include/slepc/finclude/slepcdsdef.h 39;" d DSSVD include/slepcds.h 55;" d DSSetBlockSize src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetBlockSize(DS ds,PetscInt bs)$/;" f DSSetCompact src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetCompact(DS ds,PetscBool comp)$/;" f DSSetDimensions src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSSetDimensions(DS ds,PetscInt n,PetscInt m,PetscInt l,PetscInt k)$/;" f DSSetExtraRow src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetExtraRow(DS ds,PetscBool ext)$/;" f DSSetFromOptions src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetFromOptions(DS ds)$/;" f DSSetIdentity src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSSetIdentity(DS ds,DSMatType mat)$/;" f DSSetMethod src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetMethod(DS ds,PetscInt meth)$/;" f DSSetOptionsPrefix src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetOptionsPrefix(DS ds,const char *prefix)$/;" f DSSetRefined src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetRefined(DS ds,PetscBool ref)$/;" f DSSetSlepcSC src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetSlepcSC(DS ds,SlepcSC sc)$/;" f DSSetState src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSSetState(DS ds,DSStateType state)$/;" f DSSetType src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSSetType(DS ds,DSType type)$/;" f DSSolve src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSSolve(DS ds,PetscScalar *eigr,PetscScalar *eigi)$/;" f DSSolve_GHEP src/sys/classes/ds/impls/ghep/dsghep.c /^PetscErrorCode DSSolve_GHEP(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_GHIEP_DQDS_II src/sys/classes/ds/impls/ghiep/dqds.c /^PetscErrorCode DSSolve_GHIEP_DQDS_II(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_GHIEP_HZ src/sys/classes/ds/impls/ghiep/hz.c /^PetscErrorCode DSSolve_GHIEP_HZ(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_GHIEP_QR src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSSolve_GHIEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_GHIEP_QR_II src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSSolve_GHIEP_QR_II(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_GNHEP src/sys/classes/ds/impls/gnhep/dsgnhep.c /^PetscErrorCode DSSolve_GNHEP(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_HEP_BDC src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSSolve_HEP_BDC(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_HEP_DC src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSSolve_HEP_DC(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_HEP_MRRR src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSSolve_HEP_MRRR(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_HEP_QR src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSSolve_HEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_NEP_SLP src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSSolve_NEP_SLP(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSSolve_NHEP(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_PEP_QZ src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSSolve_PEP_QZ(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSolve_SVD_DC src/sys/classes/ds/impls/svd/dssvd.c /^PetscErrorCode DSSolve_SVD_DC(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f DSSort src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSSort(DS ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSSortEigenvaluesReal_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSSortEigenvaluesReal_Private(DS ds,PetscReal *eig,PetscInt *perm)$/;" f DSSortEigenvalues_Private src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSSortEigenvalues_Private(DS ds,PetscScalar *wr,PetscScalar *wi,PetscInt *perm,PetscBool isghiep)$/;" f DSSort_GHEP src/sys/classes/ds/impls/ghep/dsghep.c /^PetscErrorCode DSSort_GHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSSort_GHIEP src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSSort_GHIEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSSort_GNHEP src/sys/classes/ds/impls/gnhep/dsgnhep.c /^PetscErrorCode DSSort_GNHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSSort_GNHEP_Arbitrary src/sys/classes/ds/impls/gnhep/dsgnhep.c /^static PetscErrorCode DSSort_GNHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f file: DSSort_GNHEP_Total src/sys/classes/ds/impls/gnhep/dsgnhep.c /^static PetscErrorCode DSSort_GNHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f file: DSSort_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSSort_HEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSSort_NEP src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSSort_NEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSSort_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSSort_NHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSSort_NHEP_Arbitrary src/sys/classes/ds/impls/nhep/dsnhep.c /^static PetscErrorCode DSSort_NHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f file: DSSort_NHEP_Total src/sys/classes/ds/impls/nhep/dsnhep.c /^static PetscErrorCode DSSort_NHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi)$/;" f file: DSSort_PEP src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSSort_PEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *kout)$/;" f DSSort_SVD src/sys/classes/ds/impls/svd/dssvd.c /^PetscErrorCode DSSort_SVD(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)$/;" f DSStateType include/slepc/finclude/slepcdsdef.h 31;" d DSStateType include/slepcds.h /^ DS_STATE_TRUNCATED } DSStateType;$/;" t typeref:enum:__anon13 DSSwitchFormat_GHIEP src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSSwitchFormat_GHIEP(DS ds,PetscBool tocompact)$/;" f DSSwitchFormat_HEP src/sys/classes/ds/impls/hep/dshep.c /^static PetscErrorCode DSSwitchFormat_HEP(DS ds,PetscBool tocompact)$/;" f file: DSSwitchFormat_SVD src/sys/classes/ds/impls/svd/dssvd.c /^static PetscErrorCode DSSwitchFormat_SVD(DS ds,PetscBool tocompact)$/;" f file: DSTranslateHarmonic src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSTranslateHarmonic(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *g,PetscReal *gamma)$/;" f DSTranslateHarmonic_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSTranslateHarmonic_NHEP(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *gin,PetscReal *gamma)$/;" f DSTranslateRKS src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSTranslateRKS(DS ds,PetscScalar alpha)$/;" f DSTranslateRKS_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSTranslateRKS_HEP(DS ds,PetscScalar alpha)$/;" f DSTruncate src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSTruncate(DS ds,PetscInt n)$/;" f DSTruncate_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSTruncate_HEP(DS ds,PetscInt n)$/;" f DSTruncate_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSTruncate_NHEP(DS ds,PetscInt n)$/;" f DSType include/slepc/finclude/slepcdsdef.h 30;" d DSType include/slepcds.h /^typedef const char* DSType;$/;" t DSUpdateExtraRow src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSUpdateExtraRow(DS ds)$/;" f DSUpdateExtraRow_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSUpdateExtraRow_HEP(DS ds)$/;" f DSUpdateExtraRow_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSUpdateExtraRow_NHEP(DS ds)$/;" f DSVectors src/sys/classes/ds/interface/dsops.c /^PetscErrorCode DSVectors(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)$/;" f DSVectors_GHEP src/sys/classes/ds/impls/ghep/dsghep.c /^PetscErrorCode DSVectors_GHEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)$/;" f DSVectors_GHIEP src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSVectors_GHIEP(DS ds,DSMatType mat,PetscInt *k,PetscReal *rnorm)$/;" f DSVectors_GHIEP_Eigen_Some src/sys/classes/ds/impls/ghiep/dsghiep.c /^static PetscErrorCode DSVectors_GHIEP_Eigen_Some(DS ds,PetscInt *idx,PetscReal *rnorm)$/;" f file: DSVectors_GNHEP src/sys/classes/ds/impls/gnhep/dsgnhep.c /^PetscErrorCode DSVectors_GNHEP(DS ds,DSMatType mat,PetscInt *k,PetscReal *rnorm)$/;" f DSVectors_GNHEP_Eigen_All src/sys/classes/ds/impls/gnhep/dsgnhep.c /^static PetscErrorCode DSVectors_GNHEP_Eigen_All(DS ds,PetscBool left)$/;" f file: DSVectors_GNHEP_Eigen_Some src/sys/classes/ds/impls/gnhep/dsgnhep.c /^static PetscErrorCode DSVectors_GNHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)$/;" f file: DSVectors_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSVectors_HEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)$/;" f DSVectors_NEP src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSVectors_NEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)$/;" f DSVectors_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSVectors_NHEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)$/;" f DSVectors_NHEP_Eigen_All src/sys/classes/ds/impls/nhep/dsnhep.c /^static PetscErrorCode DSVectors_NHEP_Eigen_All(DS ds,PetscBool left)$/;" f file: DSVectors_NHEP_Eigen_Some src/sys/classes/ds/impls/nhep/dsnhep.c /^static PetscErrorCode DSVectors_NHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)$/;" f file: DSVectors_NHEP_Refined_All src/sys/classes/ds/impls/nhep/dsnhep.c /^static PetscErrorCode DSVectors_NHEP_Refined_All(DS ds,PetscBool left)$/;" f file: DSVectors_NHEP_Refined_Some src/sys/classes/ds/impls/nhep/dsnhep.c /^static PetscErrorCode DSVectors_NHEP_Refined_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)$/;" f file: DSVectors_PEP src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSVectors_PEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)$/;" f DSVectors_SVD src/sys/classes/ds/impls/svd/dssvd.c /^PetscErrorCode DSVectors_SVD(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)$/;" f DSView src/sys/classes/ds/interface/dsbasic.c /^PetscErrorCode DSView(DS ds,PetscViewer viewer)$/;" f DSViewMat src/sys/classes/ds/interface/dspriv.c /^PetscErrorCode DSViewMat(DS ds,PetscViewer viewer,DSMatType m)$/;" f DSView_GHEP src/sys/classes/ds/impls/ghep/dsghep.c /^PetscErrorCode DSView_GHEP(DS ds,PetscViewer viewer)$/;" f DSView_GHIEP src/sys/classes/ds/impls/ghiep/dsghiep.c /^PetscErrorCode DSView_GHIEP(DS ds,PetscViewer viewer)$/;" f DSView_GNHEP src/sys/classes/ds/impls/gnhep/dsgnhep.c /^PetscErrorCode DSView_GNHEP(DS ds,PetscViewer viewer)$/;" f DSView_HEP src/sys/classes/ds/impls/hep/dshep.c /^PetscErrorCode DSView_HEP(DS ds,PetscViewer viewer)$/;" f DSView_NEP src/sys/classes/ds/impls/nep/dsnep.c /^PetscErrorCode DSView_NEP(DS ds,PetscViewer viewer)$/;" f DSView_NHEP src/sys/classes/ds/impls/nhep/dsnhep.c /^PetscErrorCode DSView_NHEP(DS ds,PetscViewer viewer)$/;" f DSView_PEP src/sys/classes/ds/impls/pep/dspep.c /^PetscErrorCode DSView_PEP(DS ds,PetscViewer viewer)$/;" f DSView_SVD src/sys/classes/ds/impls/svd/dssvd.c /^PetscErrorCode DSView_SVD(DS ds,PetscViewer viewer)$/;" f DS_CLASSID include/slepcds.h /^PETSC_EXTERN PetscClassId DS_CLASSID;$/;" v DS_CLASSID src/sys/classes/ds/interface/dsbasic.c /^PetscClassId DS_CLASSID = 0;$/;" v DS_MAT_A include/slepcds.h /^typedef enum { DS_MAT_A,$/;" e enum:__anon14 DS_MAT_B include/slepcds.h /^ DS_MAT_B,$/;" e enum:__anon14 DS_MAT_C include/slepcds.h /^ DS_MAT_C,$/;" e enum:__anon14 DS_MAT_D include/slepcds.h /^ DS_MAT_D,$/;" e enum:__anon14 DS_MAT_E0 include/slepcds.h /^ DS_MAT_E0,$/;" e enum:__anon14 DS_MAT_E1 include/slepcds.h /^ DS_MAT_E1,$/;" e enum:__anon14 DS_MAT_E2 include/slepcds.h /^ DS_MAT_E2,$/;" e enum:__anon14 DS_MAT_E3 include/slepcds.h /^ DS_MAT_E3,$/;" e enum:__anon14 DS_MAT_E4 include/slepcds.h /^ DS_MAT_E4,$/;" e enum:__anon14 DS_MAT_E5 include/slepcds.h /^ DS_MAT_E5,$/;" e enum:__anon14 DS_MAT_E6 include/slepcds.h /^ DS_MAT_E6,$/;" e enum:__anon14 DS_MAT_E7 include/slepcds.h /^ DS_MAT_E7,$/;" e enum:__anon14 DS_MAT_E8 include/slepcds.h /^ DS_MAT_E8,$/;" e enum:__anon14 DS_MAT_E9 include/slepcds.h /^ DS_MAT_E9,$/;" e enum:__anon14 DS_MAT_Q include/slepcds.h /^ DS_MAT_Q,$/;" e enum:__anon14 DS_MAT_T include/slepcds.h /^ DS_MAT_T,$/;" e enum:__anon14 DS_MAT_U include/slepcds.h /^ DS_MAT_U,$/;" e enum:__anon14 DS_MAT_VT include/slepcds.h /^ DS_MAT_VT,$/;" e enum:__anon14 DS_MAT_W include/slepcds.h /^ DS_MAT_W,$/;" e enum:__anon14 DS_MAT_X include/slepcds.h /^ DS_MAT_X,$/;" e enum:__anon14 DS_MAT_Y include/slepcds.h /^ DS_MAT_Y,$/;" e enum:__anon14 DS_MAT_Z include/slepcds.h /^ DS_MAT_Z,$/;" e enum:__anon14 DS_MAX_SOLVE include/slepcds.h 27;" d DS_NEP src/sys/classes/ds/impls/nep/dsnep.c /^} DS_NEP;$/;" t typeref:struct:__anon119 file: DS_NUM_EXTRA include/slepcds.h 130;" d DS_NUM_MAT include/slepcds.h /^ DS_NUM_MAT } DSMatType;$/;" e enum:__anon14 DS_Other include/slepc/private/dsimpl.h /^PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other;$/;" v DS_Other src/sys/classes/ds/interface/dsbasic.c /^PetscLogEvent DS_Solve = 0,DS_Vectors = 0,DS_Other = 0;$/;" v DS_PEP src/sys/classes/ds/impls/pep/dspep.c /^} DS_PEP;$/;" t typeref:struct:__anon120 file: DS_STATE_CONDENSED include/slepcds.h /^ DS_STATE_CONDENSED,$/;" e enum:__anon13 DS_STATE_INTERMEDIATE include/slepcds.h /^ DS_STATE_INTERMEDIATE,$/;" e enum:__anon13 DS_STATE_RAW include/slepcds.h /^typedef enum { DS_STATE_RAW,$/;" e enum:__anon13 DS_STATE_TRUNCATED include/slepcds.h /^ DS_STATE_TRUNCATED } DSStateType;$/;" e enum:__anon13 DS_Solve include/slepc/private/dsimpl.h /^PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other;$/;" v DS_Solve src/sys/classes/ds/interface/dsbasic.c /^PetscLogEvent DS_Solve = 0,DS_Vectors = 0,DS_Other = 0;$/;" v DS_Vectors include/slepc/private/dsimpl.h /^PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other;$/;" v DS_Vectors src/sys/classes/ds/interface/dsbasic.c /^PetscLogEvent DS_Solve = 0,DS_Vectors = 0,DS_Other = 0;$/;" v DVD_CHECKSUM src/eps/impls/davidson/dvdschm.c 24;" d file: DVD_EP_HERMITIAN include/slepc/private/vecimplslepc.h 112;" d DVD_EP_INDEFINITE include/slepc/private/vecimplslepc.h 113;" d DVD_EP_STD include/slepc/private/vecimplslepc.h 111;" d DVD_HARM_LEIGS src/eps/impls/davidson/davidson.h /^ DVD_HARM_LEIGS$/;" e enum:__anon62 DVD_HARM_NONE src/eps/impls/davidson/davidson.h /^ DVD_HARM_NONE,$/;" e enum:__anon62 DVD_HARM_REIGS src/eps/impls/davidson/davidson.h /^ DVD_HARM_REIGS,$/;" e enum:__anon62 DVD_HARM_RR src/eps/impls/davidson/davidson.h /^ DVD_HARM_RR,$/;" e enum:__anon62 DVD_HARM_RRR src/eps/impls/davidson/davidson.h /^ DVD_HARM_RRR,$/;" e enum:__anon62 DVD_INITV_CLASSIC src/eps/impls/davidson/davidson.h /^ DVD_INITV_CLASSIC,$/;" e enum:__anon63 DVD_INITV_KRYLOV src/eps/impls/davidson/davidson.h /^ DVD_INITV_KRYLOV$/;" e enum:__anon63 DVD_IS include/slepc/private/vecimplslepc.h 115;" d DVD_ISNOT include/slepc/private/vecimplslepc.h 116;" d DVD_MAT_COMPLEX include/slepc/private/vecimplslepc.h 101;" d DVD_MAT_DIAG include/slepc/private/vecimplslepc.h 104;" d DVD_MAT_HERMITIAN include/slepc/private/vecimplslepc.h 97;" d DVD_MAT_IDENTITY include/slepc/private/vecimplslepc.h 103;" d DVD_MAT_IMPLICIT include/slepc/private/vecimplslepc.h 102;" d DVD_MAT_LTRIANG include/slepc/private/vecimplslepc.h 107;" d DVD_MAT_NEG_DEF include/slepc/private/vecimplslepc.h 98;" d DVD_MAT_POS_DEF include/slepc/private/vecimplslepc.h 99;" d DVD_MAT_SINGULAR include/slepc/private/vecimplslepc.h 100;" d DVD_MAT_TRIANG include/slepc/private/vecimplslepc.h 105;" d DVD_MAT_UNITARY include/slepc/private/vecimplslepc.h 108;" d DVD_MAT_UTRIANG include/slepc/private/vecimplslepc.h 106;" d DVD_PROJ_KXX src/eps/impls/davidson/davidson.h /^ DVD_PROJ_KXX,$/;" e enum:__anon64 DVD_PROJ_KZX src/eps/impls/davidson/davidson.h /^ DVD_PROJ_KZX$/;" e enum:__anon64 DVD_STATE_CONF src/eps/impls/davidson/davidson.h 263;" d DVD_STATE_PRECONF src/eps/impls/davidson/davidson.h 262;" d DVD_STATE_RUN src/eps/impls/davidson/davidson.h 264;" d DenseTridiagonal src/eps/impls/krylov/lanczos/lanczos.c /^static PetscErrorCode DenseTridiagonal(PetscInt n_,PetscReal *D,PetscReal *E,PetscReal *w,PetscScalar *V)$/;" f file: Dl include/slepc/private/pepimpl.h /^ Vec Dl,Dr; \/* diagonal matrices for balancing *\/$/;" m struct:_p_PEP Download config/package.py /^ def Download(self,externdir,builddir,prefix=None):$/;" m class:Package Dr include/slepc/private/pepimpl.h /^ Vec Dl,Dr; \/* diagonal matrices for balancing *\/$/;" m struct:_p_PEP DvOps src/sys/vec/veccomp.c /^static struct _VecOps DvOps = {VecDuplicate_Comp, \/* 1 *\/$/;" v typeref:struct:_VecOps file: E src/pep/impls/krylov/toar/nrefine.c /^ Mat E[2],M1;$/;" m struct:__anon105 file: EPS include/slepc/finclude/slepcepsdef.h 32;" d EPS include/slepceps.h /^typedef struct _p_EPS* EPS;$/;" t typeref:struct:_p_EPS EPS src/pep/examples/tests/makefile /^EPS = krylovschur gd$/;" m EPS src/svd/examples/tests/makefile /^EPS = krylovschur arnoldi lanczos gd jd$/;" m EPSALL src/eps/examples/tests/makefile /^EPSALL = krylovschur arnoldi lanczos gd jd gd2$/;" m EPSAR src/eps/examples/tests/makefile /^EPSAR = gd jd gd2$/;" m EPSARNOLDI include/slepc/finclude/slepcepsdef.h 52;" d EPSARNOLDI include/slepceps.h 53;" d EPSARPACK include/slepc/finclude/slepcepsdef.h 61;" d EPSARPACK include/slepceps.h 62;" d EPSAllocateSolution src/eps/interface/epssetup.c /^PetscErrorCode EPSAllocateSolution(EPS eps,PetscInt extra)$/;" f EPSAppendOptionsPrefix src/eps/interface/epsopts.c /^PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix)$/;" f EPSArnoldiGetDelayed src/eps/impls/krylov/arnoldi/arnoldi.c /^PetscErrorCode EPSArnoldiGetDelayed(EPS eps,PetscBool *delayed)$/;" f EPSArnoldiGetDelayed_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^static PetscErrorCode EPSArnoldiGetDelayed_Arnoldi(EPS eps,PetscBool *delayed)$/;" f file: EPSArnoldiSetDelayed src/eps/impls/krylov/arnoldi/arnoldi.c /^PetscErrorCode EPSArnoldiSetDelayed(EPS eps,PetscBool delayed)$/;" f EPSArnoldiSetDelayed_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^static PetscErrorCode EPSArnoldiSetDelayed_Arnoldi(EPS eps,PetscBool delayed)$/;" f file: EPSBLOPEX include/slepc/finclude/slepcepsdef.h 64;" d EPSBLOPEX include/slepceps.h 65;" d EPSBLOPEXGetBlockSize src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSBLOPEXGetBlockSize(EPS eps,PetscInt *bs)$/;" f EPSBLOPEXGetBlockSize_BLOPEX src/eps/impls/external/blopex/blopex.c /^static PetscErrorCode EPSBLOPEXGetBlockSize_BLOPEX(EPS eps,PetscInt *bs)$/;" f file: EPSBLOPEXSetBlockSize src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSBLOPEXSetBlockSize(EPS eps,PetscInt bs)$/;" f EPSBLOPEXSetBlockSize_BLOPEX src/eps/impls/external/blopex/blopex.c /^static PetscErrorCode EPSBLOPEXSetBlockSize_BLOPEX(EPS eps,PetscInt bs)$/;" f file: EPSBLZPACK include/slepc/finclude/slepcepsdef.h 62;" d EPSBLZPACK include/slepceps.h 63;" d EPSBackTransform_ARPACK src/eps/impls/external/arpack/arpack.c /^PetscErrorCode EPSBackTransform_ARPACK(EPS eps)$/;" f EPSBackTransform_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSBackTransform_BLZPACK(EPS eps)$/;" f EPSBackTransform_Default src/eps/interface/epsdefault.c /^PetscErrorCode EPSBackTransform_Default(EPS eps)$/;" f EPSBackTransform_Power src/eps/impls/power/power.c /^PetscErrorCode EPSBackTransform_Power(EPS eps)$/;" f EPSBalance include/slepc/finclude/slepcepsdef.h 41;" d EPSBalance include/slepceps.h /^ EPS_BALANCE_USER } EPSBalance;$/;" t typeref:enum:__anon18 EPSBalanceTypes include/slepceps.h /^PETSC_EXTERN const char *EPSBalanceTypes[];$/;" v EPSBalanceTypes src/eps/interface/dlregiseps.c /^const char *EPSBalanceTypes[] = {"NONE","ONESIDE","TWOSIDE","USER","EPSBalance","EPS_BALANCE_",0};$/;" v EPSBasicArnoldi src/eps/impls/krylov/epskrylov.c /^PetscErrorCode EPSBasicArnoldi(EPS eps,PetscBool trans,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)$/;" f EPSBasicLanczos src/eps/impls/krylov/lanczos/lanczos.c /^static PetscErrorCode EPSBasicLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *m,PetscBool *breakdown,PetscReal anorm)$/;" f file: EPSBlzpackSetBlockSize src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,PetscInt bs)$/;" f EPSBlzpackSetBlockSize_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^static PetscErrorCode EPSBlzpackSetBlockSize_BLZPACK(EPS eps,PetscInt bs)$/;" f file: EPSBlzpackSetNSteps src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSBlzpackSetNSteps(EPS eps,PetscInt nsteps)$/;" f EPSBlzpackSetNSteps_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^static PetscErrorCode EPSBlzpackSetNSteps_BLZPACK(EPS eps,PetscInt nsteps)$/;" f file: EPSBuildBalance_Krylov src/eps/interface/epsdefault.c /^PetscErrorCode EPSBuildBalance_Krylov(EPS eps)$/;" f EPSCISS include/slepc/finclude/slepcepsdef.h 59;" d EPSCISS include/slepceps.h 60;" d EPSCISSExtraction include/slepc/finclude/slepcepsdef.h 48;" d EPSCISSExtraction include/slepceps.h /^ EPS_CISS_EXTRACTION_HANKEL } EPSCISSExtraction;$/;" t typeref:enum:__anon27 EPSCISSExtractions include/slepceps.h /^PETSC_EXTERN const char *EPSCISSExtractions[];$/;" v EPSCISSExtractions src/eps/interface/dlregiseps.c /^const char *EPSCISSExtractions[] = {"RITZ","HANKEL","EPSCISSExtraction","EPS_CISS_EXTRACTION_",0};$/;" v EPSCISSGetExtraction src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSGetExtraction(EPS eps,EPSCISSExtraction *extraction)$/;" f EPSCISSGetExtraction_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSGetExtraction_CISS(EPS eps,EPSCISSExtraction *extraction)$/;" f file: EPSCISSGetQuadRule src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSGetQuadRule(EPS eps, EPSCISSQuadRule *quad)$/;" f EPSCISSGetQuadRule_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSGetQuadRule_CISS(EPS eps,EPSCISSQuadRule *quad)$/;" f file: EPSCISSGetRefinement src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSGetRefinement(EPS eps, PetscInt *inner, PetscInt *blsize)$/;" f EPSCISSGetRefinement_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSGetRefinement_CISS(EPS eps,PetscInt *inner,PetscInt *blsize)$/;" f file: EPSCISSGetSizes src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSGetSizes(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)$/;" f EPSCISSGetSizes_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSGetSizes_CISS(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)$/;" f file: EPSCISSGetThreshold src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSGetThreshold(EPS eps,PetscReal *delta,PetscReal *spur)$/;" f EPSCISSGetThreshold_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSGetThreshold_CISS(EPS eps,PetscReal *delta,PetscReal *spur)$/;" f file: EPSCISSGetUseST src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSGetUseST(EPS eps,PetscBool *usest)$/;" f EPSCISSGetUseST_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSGetUseST_CISS(EPS eps,PetscBool *usest)$/;" f file: EPSCISSQuadRule include/slepc/finclude/slepcepsdef.h 47;" d EPSCISSQuadRule include/slepceps.h /^ EPS_CISS_QUADRULE_CHEBYSHEV } EPSCISSQuadRule;$/;" t typeref:enum:__anon26 EPSCISSQuadRules include/slepceps.h /^PETSC_EXTERN const char *EPSCISSQuadRules[];$/;" v EPSCISSQuadRules src/eps/interface/dlregiseps.c /^const char *EPSCISSQuadRules[] = {"(not set yet)","TRAPEZOIDAL","CHEBYSHEV","EPSCISSQuadRule","EPS_CISS_QUADRULE_",0};$/;" v EPSCISSSetExtraction src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSSetExtraction(EPS eps,EPSCISSExtraction extraction)$/;" f EPSCISSSetExtraction_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSSetExtraction_CISS(EPS eps,EPSCISSExtraction extraction)$/;" f file: EPSCISSSetQuadRule src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSSetQuadRule(EPS eps,EPSCISSQuadRule quad)$/;" f EPSCISSSetQuadRule_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSSetQuadRule_CISS(EPS eps,EPSCISSQuadRule quad)$/;" f file: EPSCISSSetRefinement src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSSetRefinement(EPS eps,PetscInt inner,PetscInt blsize)$/;" f EPSCISSSetRefinement_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSSetRefinement_CISS(EPS eps,PetscInt inner,PetscInt blsize)$/;" f file: EPSCISSSetSizes src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSSetSizes(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)$/;" f EPSCISSSetSizes_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSSetSizes_CISS(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)$/;" f file: EPSCISSSetThreshold src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSSetThreshold(EPS eps,PetscReal delta,PetscReal spur)$/;" f EPSCISSSetThreshold_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSSetThreshold_CISS(EPS eps,PetscReal delta,PetscReal spur)$/;" f file: EPSCISSSetUseST src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSCISSSetUseST(EPS eps,PetscBool usest)$/;" f EPSCISSSetUseST_CISS src/eps/impls/ciss/ciss.c /^static PetscErrorCode EPSCISSSetUseST_CISS(EPS eps,PetscBool usest)$/;" f file: EPSCheckSolved include/slepc/private/epsimpl.h 131;" d EPSCheckSolved include/slepc/private/epsimpl.h 135;" d EPSComputeError src/eps/interface/epssolve.c /^PetscErrorCode EPSComputeError(EPS eps,PetscInt i,EPSErrorType type,PetscReal *error)$/;" f EPSComputeRelativeError include/slepceps.h /^PETSC_DEPRECATED("Use EPSComputeError()") PETSC_STATIC_INLINE PetscErrorCode EPSComputeRelativeError(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_RELATIVE,r);}$/;" f EPSComputeResidualNorm include/slepceps.h /^PETSC_DEPRECATED("Use EPSComputeError() with EPS_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode EPSComputeResidualNorm(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_ABSOLUTE,r);}$/;" f EPSComputeResidualNorm_Private src/eps/interface/epssolve.c /^PetscErrorCode EPSComputeResidualNorm_Private(EPS eps,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm)$/;" f EPSComputeRitzVector src/eps/interface/epsdefault.c /^PetscErrorCode EPSComputeRitzVector(EPS eps,PetscScalar *Zr,PetscScalar *Zi,BV V,Vec x,Vec y)$/;" f EPSComputeVectors src/eps/interface/epssolve.c /^PetscErrorCode EPSComputeVectors(EPS eps)$/;" f EPSComputeVectors_Hermitian src/eps/interface/epsdefault.c /^PetscErrorCode EPSComputeVectors_Hermitian(EPS eps)$/;" f EPSComputeVectors_Indefinite src/eps/interface/epsdefault.c /^PetscErrorCode EPSComputeVectors_Indefinite(EPS eps)$/;" f EPSComputeVectors_Schur src/eps/interface/epsdefault.c /^PetscErrorCode EPSComputeVectors_Schur(EPS eps)$/;" f EPSComputeVectors_Slice src/eps/impls/krylov/krylovschur/ks-slice.c /^PetscErrorCode EPSComputeVectors_Slice(EPS eps)$/;" f EPSComputeVectors_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSComputeVectors_XD(EPS eps)$/;" f EPSConv include/slepc/finclude/slepcepsdef.h 42;" d EPSConv include/slepceps.h /^ EPS_CONV_USER } EPSConv;$/;" t typeref:enum:__anon20 EPSConvMonitorSetFromOptions src/eps/interface/epsopts.c /^PetscErrorCode EPSConvMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))$/;" f EPSConvergedAbsolute src/eps/interface/epsdefault.c /^PetscErrorCode EPSConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f EPSConvergedNorm src/eps/interface/epsdefault.c /^PetscErrorCode EPSConvergedNorm(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f EPSConvergedReason include/slepc/finclude/slepcepsdef.h 36;" d EPSConvergedReason include/slepceps.h /^ EPS_CONVERGED_ITERATING = 0} EPSConvergedReason;$/;" t typeref:enum:__anon22 EPSConvergedReasons include/slepceps.h /^PETSC_EXTERN const char *const*EPSConvergedReasons;$/;" v EPSConvergedReasons src/eps/interface/dlregiseps.c /^const char *const*EPSConvergedReasons = EPSConvergedReasons_Shifted + 4;$/;" v EPSConvergedReasons_Shifted src/eps/interface/dlregiseps.c /^const char *const EPSConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","EPSConvergedReason","EPS_",0};$/;" v EPSConvergedRelative src/eps/interface/epsdefault.c /^PetscErrorCode EPSConvergedRelative(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f EPSCreate src/eps/interface/epsbasic.c /^PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps)$/;" f EPSCreateShift src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSCreateShift(EPS eps,PetscReal val,EPS_shift neighb0,EPS_shift neighb1)$/;" f file: EPSCreate_ARPACK src/eps/impls/external/arpack/arpack.c /^PETSC_EXTERN PetscErrorCode EPSCreate_ARPACK(EPS eps)$/;" f EPSCreate_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^PETSC_EXTERN PetscErrorCode EPSCreate_Arnoldi(EPS eps)$/;" f EPSCreate_BLOPEX src/eps/impls/external/blopex/blopex.c /^PETSC_EXTERN PetscErrorCode EPSCreate_BLOPEX(EPS eps)$/;" f EPSCreate_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PETSC_EXTERN PetscErrorCode EPSCreate_BLZPACK(EPS eps)$/;" f EPSCreate_CISS src/eps/impls/ciss/ciss.c /^PETSC_EXTERN PetscErrorCode EPSCreate_CISS(EPS eps)$/;" f EPSCreate_FEAST src/eps/impls/external/feast/feast.c /^PETSC_EXTERN PetscErrorCode EPSCreate_FEAST(EPS eps)$/;" f EPSCreate_GD src/eps/impls/davidson/gd/gd.c /^PETSC_EXTERN PetscErrorCode EPSCreate_GD(EPS eps)$/;" f EPSCreate_JD src/eps/impls/davidson/jd/jd.c /^PETSC_EXTERN PetscErrorCode EPSCreate_JD(EPS eps)$/;" f EPSCreate_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^PETSC_EXTERN PetscErrorCode EPSCreate_KrylovSchur(EPS eps)$/;" f EPSCreate_LAPACK src/eps/impls/lapack/lapack.c /^PETSC_EXTERN PetscErrorCode EPSCreate_LAPACK(EPS eps)$/;" f EPSCreate_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^PETSC_EXTERN PetscErrorCode EPSCreate_LOBPCG(EPS eps)$/;" f EPSCreate_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^PETSC_EXTERN PetscErrorCode EPSCreate_Lanczos(EPS eps)$/;" f EPSCreate_PRIMME src/eps/impls/external/primme/primme.c /^PETSC_EXTERN PetscErrorCode EPSCreate_PRIMME(EPS eps)$/;" f EPSCreate_Power src/eps/impls/power/power.c /^PETSC_EXTERN PetscErrorCode EPSCreate_Power(EPS eps)$/;" f EPSCreate_RQCG src/eps/impls/cg/rqcg/rqcg.c /^PETSC_EXTERN PetscErrorCode EPSCreate_RQCG(EPS eps)$/;" f EPSCreate_Subspace src/eps/impls/subspace/subspace.c /^PETSC_EXTERN PetscErrorCode EPSCreate_Subspace(EPS eps)$/;" f EPSCreate_TRLAN src/eps/impls/external/trlan/trlan.c /^PETSC_EXTERN PetscErrorCode EPSCreate_TRLAN(EPS eps)$/;" f EPSDavidsonFLAdd src/eps/impls/davidson/davidson.h /^PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLAdd(dvdFunctionList **fl,dvdCallback f)$/;" f EPSDavidsonFLCall src/eps/impls/davidson/davidson.h /^PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLCall(dvdFunctionList *fl,dvdDashboard *d)$/;" f EPSDavidsonFLDestroy src/eps/impls/davidson/davidson.h /^PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLDestroy(dvdFunctionList **fl)$/;" f EPSDelayedArnoldi src/eps/impls/krylov/epskrylov.c /^PetscErrorCode EPSDelayedArnoldi(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)$/;" f EPSDelayedArnoldi1 src/eps/impls/krylov/epskrylov.c /^PetscErrorCode EPSDelayedArnoldi1(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)$/;" f EPSDestroy src/eps/interface/epsbasic.c /^PetscErrorCode EPSDestroy(EPS *eps)$/;" f EPSDestroy_ARPACK src/eps/impls/external/arpack/arpack.c /^PetscErrorCode EPSDestroy_ARPACK(EPS eps)$/;" f EPSDestroy_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^PetscErrorCode EPSDestroy_Arnoldi(EPS eps)$/;" f EPSDestroy_BLOPEX src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSDestroy_BLOPEX(EPS eps)$/;" f EPSDestroy_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSDestroy_BLZPACK(EPS eps)$/;" f EPSDestroy_CISS src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSDestroy_CISS(EPS eps)$/;" f EPSDestroy_FEAST src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSDestroy_FEAST(EPS eps)$/;" f EPSDestroy_GD src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSDestroy_GD(EPS eps)$/;" f EPSDestroy_JD src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSDestroy_JD(EPS eps)$/;" f EPSDestroy_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSDestroy_KrylovSchur(EPS eps)$/;" f EPSDestroy_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSDestroy_LOBPCG(EPS eps)$/;" f EPSDestroy_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSDestroy_Lanczos(EPS eps)$/;" f EPSDestroy_PRIMME src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSDestroy_PRIMME(EPS eps)$/;" f EPSDestroy_Power src/eps/impls/power/power.c /^PetscErrorCode EPSDestroy_Power(EPS eps)$/;" f EPSDestroy_RQCG src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSDestroy_RQCG(EPS eps)$/;" f EPSDestroy_Subspace src/eps/impls/subspace/subspace.c /^PetscErrorCode EPSDestroy_Subspace(EPS eps)$/;" f EPSDestroy_TRLAN src/eps/impls/external/trlan/trlan.c /^PetscErrorCode EPSDestroy_TRLAN(EPS eps)$/;" f EPSErrorType include/slepc/finclude/slepcepsdef.h 37;" d EPSErrorType include/slepceps.h /^ EPS_ERROR_BACKWARD } EPSErrorType;$/;" t typeref:enum:__anon19 EPSErrorTypes include/slepceps.h /^PETSC_EXTERN const char *EPSErrorTypes[];$/;" v EPSErrorTypes src/eps/interface/dlregiseps.c /^const char *EPSErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","EPSErrorType","EPS_ERROR_",0};$/;" v EPSErrorView src/eps/interface/epsview.c /^PetscErrorCode EPSErrorView(EPS eps,EPSErrorType etype,PetscViewer viewer)$/;" f EPSErrorViewFromOptions src/eps/interface/epsview.c /^PetscErrorCode EPSErrorViewFromOptions(EPS eps)$/;" f EPSErrorView_ASCII src/eps/interface/epsview.c /^static PetscErrorCode EPSErrorView_ASCII(EPS eps,EPSErrorType etype,PetscViewer viewer)$/;" f file: EPSErrorView_DETAIL src/eps/interface/epsview.c /^static PetscErrorCode EPSErrorView_DETAIL(EPS eps,EPSErrorType etype,PetscViewer viewer)$/;" f file: EPSErrorView_MATLAB src/eps/interface/epsview.c /^static PetscErrorCode EPSErrorView_MATLAB(EPS eps,EPSErrorType etype,PetscViewer viewer)$/;" f file: EPSExtractShift src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSExtractShift(EPS eps)$/;" f file: EPSExtraction include/slepc/finclude/slepcepsdef.h 40;" d EPSExtraction include/slepceps.h /^ EPS_REFINED_HARMONIC } EPSExtraction;$/;" t typeref:enum:__anon16 EPSFEAST include/slepc/finclude/slepcepsdef.h 66;" d EPSFEAST include/slepceps.h 67;" d EPSFEASTGetNumPoints src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSFEASTGetNumPoints(EPS eps,PetscInt *npoints)$/;" f EPSFEASTGetNumPoints_FEAST src/eps/impls/external/feast/feast.c /^static PetscErrorCode EPSFEASTGetNumPoints_FEAST(EPS eps,PetscInt *npoints)$/;" f file: EPSFEASTSetNumPoints src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSFEASTSetNumPoints(EPS eps,PetscInt npoints)$/;" f EPSFEASTSetNumPoints_FEAST src/eps/impls/external/feast/feast.c /^static PetscErrorCode EPSFEASTSetNumPoints_FEAST(EPS eps,PetscInt npoints)$/;" f file: EPSFinalizePackage src/eps/interface/dlregiseps.c /^PetscErrorCode EPSFinalizePackage(void)$/;" f EPSFullLanczos src/eps/impls/krylov/epskrylov.c /^PetscErrorCode EPSFullLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown)$/;" f EPSGD include/slepc/finclude/slepcepsdef.h 55;" d EPSGD include/slepceps.h 56;" d EPSGDGetBOrth src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth)$/;" f EPSGDGetBlockSize src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize)$/;" f EPSGDGetDoubleExpansion src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDGetDoubleExpansion(EPS eps,PetscBool *doubleexp)$/;" f EPSGDGetDoubleExpansion_GD src/eps/impls/davidson/gd/gd.c /^static PetscErrorCode EPSGDGetDoubleExpansion_GD(EPS eps,PetscBool *doubleexp)$/;" f file: EPSGDGetInitialSize src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize)$/;" f EPSGDGetKrylovStart src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart)$/;" f EPSGDGetRestart src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)$/;" f EPSGDGetWindowSizes src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)$/;" f EPSGDSetBOrth src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth)$/;" f EPSGDSetBlockSize src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize)$/;" f EPSGDSetDoubleExpansion src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDSetDoubleExpansion(EPS eps,PetscBool doubleexp)$/;" f EPSGDSetDoubleExpansion_GD src/eps/impls/davidson/gd/gd.c /^static PetscErrorCode EPSGDSetDoubleExpansion_GD(EPS eps,PetscBool doubleexp)$/;" f file: EPSGDSetInitialSize src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize)$/;" f EPSGDSetKrylovStart src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart)$/;" f EPSGDSetRestart src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)$/;" f EPSGDSetWindowSizes src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSGDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)$/;" f EPSGetArbitraryValues src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSGetArbitraryValues(EPS eps,PetscScalar *rr,PetscScalar *ri)$/;" f EPSGetBV src/eps/interface/epsbasic.c /^PetscErrorCode EPSGetBV(EPS eps,BV *V)$/;" f EPSGetBalance src/eps/interface/epsopts.c /^PetscErrorCode EPSGetBalance(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff)$/;" f EPSGetConverged src/eps/interface/epssolve.c /^PetscErrorCode EPSGetConverged(EPS eps,PetscInt *nconv)$/;" f EPSGetConvergedReason src/eps/interface/epssolve.c /^PetscErrorCode EPSGetConvergedReason(EPS eps,EPSConvergedReason *reason)$/;" f EPSGetConvergenceTest src/eps/interface/epsopts.c /^PetscErrorCode EPSGetConvergenceTest(EPS eps,EPSConv *conv)$/;" f EPSGetDS src/eps/interface/epsbasic.c /^PetscErrorCode EPSGetDS(EPS eps,DS *ds)$/;" f EPSGetDimensions src/eps/interface/epsopts.c /^PetscErrorCode EPSGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)$/;" f EPSGetEigenpair src/eps/interface/epssolve.c /^PetscErrorCode EPSGetEigenpair(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)$/;" f EPSGetEigenvalue src/eps/interface/epssolve.c /^PetscErrorCode EPSGetEigenvalue(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi)$/;" f EPSGetEigenvector src/eps/interface/epssolve.c /^PetscErrorCode EPSGetEigenvector(EPS eps,PetscInt i,Vec Vr,Vec Vi)$/;" f EPSGetErrorEstimate src/eps/interface/epssolve.c /^PetscErrorCode EPSGetErrorEstimate(EPS eps,PetscInt i,PetscReal *errest)$/;" f EPSGetExtraction src/eps/interface/epsopts.c /^PetscErrorCode EPSGetExtraction(EPS eps,EPSExtraction *extr)$/;" f EPSGetInterval src/eps/interface/epsbasic.c /^PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb)$/;" f EPSGetInvariantSubspace src/eps/interface/epssolve.c /^PetscErrorCode EPSGetInvariantSubspace(EPS eps,Vec *v)$/;" f EPSGetIterationNumber src/eps/interface/epssolve.c /^PetscErrorCode EPSGetIterationNumber(EPS eps,PetscInt *its)$/;" f EPSGetMonitorContext src/eps/interface/epsmon.c /^PetscErrorCode EPSGetMonitorContext(EPS eps,void **ctx)$/;" f EPSGetNewShiftValue src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS)$/;" f file: EPSGetOperators src/eps/interface/epssetup.c /^PetscErrorCode EPSGetOperators(EPS eps,Mat *A,Mat *B)$/;" f EPSGetOptionsPrefix src/eps/interface/epsopts.c /^PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[])$/;" f EPSGetProblemType src/eps/interface/epsopts.c /^PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type)$/;" f EPSGetPurify src/eps/interface/epsopts.c /^PetscErrorCode EPSGetPurify(EPS eps,PetscBool *purify)$/;" f EPSGetRG src/eps/interface/epsbasic.c /^PetscErrorCode EPSGetRG(EPS eps,RG *rg)$/;" f EPSGetST src/eps/interface/epsbasic.c /^PetscErrorCode EPSGetST(EPS eps,ST *st)$/;" f EPSGetStartVector src/eps/interface/epssolve.c /^PetscErrorCode EPSGetStartVector(EPS eps,PetscInt i,PetscBool *breakdown)$/;" f EPSGetStoppingTest src/eps/interface/epsopts.c /^PetscErrorCode EPSGetStoppingTest(EPS eps,EPSStop *stop)$/;" f EPSGetTarget src/eps/interface/epsbasic.c /^PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)$/;" f EPSGetTolerances src/eps/interface/epsopts.c /^PetscErrorCode EPSGetTolerances(EPS eps,PetscReal *tol,PetscInt *maxits)$/;" f EPSGetTrackAll src/eps/interface/epsopts.c /^PetscErrorCode EPSGetTrackAll(EPS eps,PetscBool *trackall)$/;" f EPSGetTrueResidual src/eps/interface/epsopts.c /^PetscErrorCode EPSGetTrueResidual(EPS eps,PetscBool *trueres)$/;" f EPSGetType src/eps/interface/epsbasic.c /^PetscErrorCode EPSGetType(EPS eps,EPSType *type)$/;" f EPSGetWhichEigenpairs src/eps/interface/epsopts.c /^PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which)$/;" f EPSInitializePackage src/eps/interface/dlregiseps.c /^PetscErrorCode EPSInitializePackage()$/;" f EPSIsGeneralized src/eps/interface/epsbasic.c /^PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is)$/;" f EPSIsHermitian src/eps/interface/epsbasic.c /^PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is)$/;" f EPSIsPositive src/eps/interface/epsbasic.c /^PetscErrorCode EPSIsPositive(EPS eps,PetscBool* is)$/;" f EPSJD include/slepc/finclude/slepcepsdef.h 56;" d EPSJD include/slepceps.h 57;" d EPSJDGetBOrth src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetBOrth(EPS eps,PetscBool *borth)$/;" f EPSJDGetBlockSize src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetBlockSize(EPS eps,PetscInt *blocksize)$/;" f EPSJDGetConstCorrectionTol src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetConstCorrectionTol(EPS eps,PetscBool *constant)$/;" f EPSJDGetConstCorrectionTol_JD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSJDGetConstCorrectionTol_JD(EPS eps,PetscBool *constant)$/;" f EPSJDGetFix src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetFix(EPS eps,PetscReal *fix)$/;" f EPSJDGetInitialSize src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetInitialSize(EPS eps,PetscInt *initialsize)$/;" f EPSJDGetKrylovStart src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetKrylovStart(EPS eps,PetscBool *krylovstart)$/;" f EPSJDGetRestart src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)$/;" f EPSJDGetWindowSizes src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)$/;" f EPSJDSetBOrth src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetBOrth(EPS eps,PetscBool borth)$/;" f EPSJDSetBlockSize src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetBlockSize(EPS eps,PetscInt blocksize)$/;" f EPSJDSetConstCorrectionTol src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetConstCorrectionTol(EPS eps,PetscBool constant)$/;" f EPSJDSetConstCorrectionTol_JD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSJDSetConstCorrectionTol_JD(EPS eps,PetscBool constant)$/;" f EPSJDSetFix src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetFix(EPS eps,PetscReal fix)$/;" f EPSJDSetFix_JD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSJDSetFix_JD(EPS eps,PetscReal fix)$/;" f EPSJDSetInitialSize src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetInitialSize(EPS eps,PetscInt initialsize)$/;" f EPSJDSetKrylovStart src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetKrylovStart(EPS eps,PetscBool krylovstart)$/;" f EPSJDSetRestart src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)$/;" f EPSJDSetWindowSizes src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSJDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)$/;" f EPSKRYLOVSCHUR include/slepc/finclude/slepcepsdef.h 54;" d EPSKRYLOVSCHUR include/slepceps.h 55;" d EPSKrylovConvergence src/eps/impls/krylov/epskrylov.c /^PetscErrorCode EPSKrylovConvergence(EPS eps,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscReal corrf,PetscInt *kout)$/;" f EPSKrylovSchurGetDetectZeros src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetDetectZeros(EPS eps,PetscBool *detect)$/;" f EPSKrylovSchurGetDetectZeros_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetDetectZeros_KrylovSchur(EPS eps,PetscBool *detect)$/;" f file: EPSKrylovSchurGetDimensions src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)$/;" f EPSKrylovSchurGetDimensions_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetDimensions_KrylovSchur(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)$/;" f file: EPSKrylovSchurGetInertias src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)$/;" f EPSKrylovSchurGetInertias_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetInertias_KrylovSchur(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)$/;" f file: EPSKrylovSchurGetLocking src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetLocking(EPS eps,PetscBool *lock)$/;" f EPSKrylovSchurGetLocking_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetLocking_KrylovSchur(EPS eps,PetscBool *lock)$/;" f file: EPSKrylovSchurGetPartitions src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetPartitions(EPS eps,PetscInt *npart)$/;" f EPSKrylovSchurGetPartitions_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetPartitions_KrylovSchur(EPS eps,PetscInt *npart)$/;" f file: EPSKrylovSchurGetRestart src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetRestart(EPS eps,PetscReal *keep)$/;" f EPSKrylovSchurGetRestart_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetRestart_KrylovSchur(EPS eps,PetscReal *keep)$/;" f file: EPSKrylovSchurGetSubcommInfo src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetSubcommInfo(EPS eps,PetscInt *k,PetscInt *n,Vec *v)$/;" f EPSKrylovSchurGetSubcommInfo_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetSubcommInfo_KrylovSchur(EPS eps,PetscInt *k,PetscInt *n,Vec *v)$/;" f file: EPSKrylovSchurGetSubcommMats src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetSubcommMats(EPS eps,Mat *A,Mat *B)$/;" f EPSKrylovSchurGetSubcommMats_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetSubcommMats_KrylovSchur(EPS eps,Mat *A,Mat *B)$/;" f file: EPSKrylovSchurGetSubcommPairs src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetSubcommPairs(EPS eps,PetscInt i,PetscScalar *eig,Vec v)$/;" f EPSKrylovSchurGetSubcommPairs_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetSubcommPairs_KrylovSchur(EPS eps,PetscInt i,PetscScalar *eig,Vec v)$/;" f file: EPSKrylovSchurGetSubintervals src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurGetSubintervals(EPS eps,PetscReal** subint)$/;" f EPSKrylovSchurGetSubintervals_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurGetSubintervals_KrylovSchur(EPS eps,PetscReal **subint)$/;" f file: EPSKrylovSchurSetDetectZeros src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurSetDetectZeros(EPS eps,PetscBool detect)$/;" f EPSKrylovSchurSetDetectZeros_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurSetDetectZeros_KrylovSchur(EPS eps,PetscBool detect)$/;" f file: EPSKrylovSchurSetDimensions src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)$/;" f EPSKrylovSchurSetDimensions_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurSetDimensions_KrylovSchur(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)$/;" f file: EPSKrylovSchurSetLocking src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurSetLocking(EPS eps,PetscBool lock)$/;" f EPSKrylovSchurSetLocking_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurSetLocking_KrylovSchur(EPS eps,PetscBool lock)$/;" f file: EPSKrylovSchurSetPartitions src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurSetPartitions(EPS eps,PetscInt npart)$/;" f EPSKrylovSchurSetPartitions_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurSetPartitions_KrylovSchur(EPS eps,PetscInt npart)$/;" f file: EPSKrylovSchurSetRestart src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurSetRestart(EPS eps,PetscReal keep)$/;" f EPSKrylovSchurSetRestart_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurSetRestart_KrylovSchur(EPS eps,PetscReal keep)$/;" f file: EPSKrylovSchurSetSubintervals src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurSetSubintervals(EPS eps,PetscReal *subint)$/;" f EPSKrylovSchurSetSubintervals_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurSetSubintervals_KrylovSchur(EPS eps,PetscReal* subint)$/;" f file: EPSKrylovSchurUpdateSubcommMats src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSKrylovSchurUpdateSubcommMats(EPS eps,PetscScalar s,PetscScalar a,Mat Au,PetscScalar t,PetscScalar b, Mat Bu,MatStructure str,PetscBool globalup)$/;" f EPSKrylovSchurUpdateSubcommMats_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^static PetscErrorCode EPSKrylovSchurUpdateSubcommMats_KrylovSchur(EPS eps,PetscScalar a,PetscScalar ap,Mat Au,PetscScalar b,PetscScalar bp, Mat Bu,MatStructure str,PetscBool globalup)$/;" f file: EPSKrylovSchur_Slice src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSKrylovSchur_Slice(EPS eps)$/;" f file: EPSLANCZOS include/slepc/finclude/slepcepsdef.h 53;" d EPSLANCZOS include/slepceps.h 54;" d EPSLAPACK include/slepc/finclude/slepcepsdef.h 60;" d EPSLAPACK include/slepceps.h 61;" d EPSLOBPCG include/slepc/finclude/slepcepsdef.h 58;" d EPSLOBPCG include/slepceps.h 59;" d EPSLOBPCGGetBlockSize src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSLOBPCGGetBlockSize(EPS eps,PetscInt *bs)$/;" f EPSLOBPCGGetBlockSize_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^static PetscErrorCode EPSLOBPCGGetBlockSize_LOBPCG(EPS eps,PetscInt *bs)$/;" f file: EPSLOBPCGGetLocking src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSLOBPCGGetLocking(EPS eps,PetscBool *lock)$/;" f EPSLOBPCGGetLocking_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^static PetscErrorCode EPSLOBPCGGetLocking_LOBPCG(EPS eps,PetscBool *lock)$/;" f file: EPSLOBPCGGetRestart src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSLOBPCGGetRestart(EPS eps,PetscReal *restart)$/;" f EPSLOBPCGGetRestart_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^static PetscErrorCode EPSLOBPCGGetRestart_LOBPCG(EPS eps,PetscReal *restart)$/;" f file: EPSLOBPCGSetBlockSize src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSLOBPCGSetBlockSize(EPS eps,PetscInt bs)$/;" f EPSLOBPCGSetBlockSize_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^static PetscErrorCode EPSLOBPCGSetBlockSize_LOBPCG(EPS eps,PetscInt bs)$/;" f file: EPSLOBPCGSetLocking src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSLOBPCGSetLocking(EPS eps,PetscBool lock)$/;" f EPSLOBPCGSetLocking_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^static PetscErrorCode EPSLOBPCGSetLocking_LOBPCG(EPS eps,PetscBool lock)$/;" f file: EPSLOBPCGSetRestart src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSLOBPCGSetRestart(EPS eps,PetscReal restart)$/;" f EPSLOBPCGSetRestart_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^static PetscErrorCode EPSLOBPCGSetRestart_LOBPCG(EPS eps,PetscReal restart)$/;" f file: EPSLanczosGetReorthog src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSLanczosGetReorthog(EPS eps,EPSLanczosReorthogType *reorthog)$/;" f EPSLanczosGetReorthog_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^static PetscErrorCode EPSLanczosGetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType *reorthog)$/;" f file: EPSLanczosReorthogType include/slepc/finclude/slepcepsdef.h 45;" d EPSLanczosReorthogType include/slepceps.h /^ EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType;$/;" t typeref:enum:__anon24 EPSLanczosReorthogTypes include/slepceps.h /^PETSC_EXTERN const char *EPSLanczosReorthogTypes[];$/;" v EPSLanczosReorthogTypes src/eps/interface/dlregiseps.c /^const char *EPSLanczosReorthogTypes[] = {"LOCAL","FULL","SELECTIVE","PERIODIC","PARTIAL","DELAYED","EPSLanczosReorthogType","EPS_LANCZOS_REORTHOG_",0};$/;" v EPSLanczosSetReorthog src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSLanczosSetReorthog(EPS eps,EPSLanczosReorthogType reorthog)$/;" f EPSLanczosSetReorthog_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^static PetscErrorCode EPSLanczosSetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType reorthog)$/;" f file: EPSList include/slepceps.h /^PETSC_EXTERN PetscFunctionList EPSList;$/;" v EPSList src/eps/interface/epsbasic.c /^PetscFunctionList EPSList = 0;$/;" v EPSLocalLanczos src/eps/impls/krylov/lanczos/lanczos.c /^static PetscErrorCode EPSLocalLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown)$/;" f file: EPSLookForDeflation src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSLookForDeflation(EPS eps)$/;" f file: EPSMonitor src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitor(EPS eps,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)$/;" f EPSMonitorAll src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f EPSMonitorCancel src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorCancel(EPS eps)$/;" f EPSMonitorConverged src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorConverged(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)$/;" f EPSMonitorFirst src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorFirst(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f EPSMonitorLG src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorLG(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f EPSMonitorLGAll src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorLGAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f EPSMonitorLGCreate src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)$/;" f EPSMonitorSet src/eps/interface/epsmon.c /^PetscErrorCode EPSMonitorSet(EPS eps,PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))$/;" f EPSMonitorSetFromOptions src/eps/interface/epsopts.c /^PetscErrorCode EPSMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)$/;" f EPSMonitor_Cross src/svd/impls/cross/cross.c /^static PetscErrorCode EPSMonitor_Cross(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f file: EPSMonitor_Cyclic src/svd/impls/cyclic/cyclic.c /^static PetscErrorCode EPSMonitor_Cyclic(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f file: EPSMonitor_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode EPSMonitor_Linear(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f file: EPSNS src/eps/examples/tests/makefile /^EPSNS = krylovschur arnoldi gd jd gd2$/;" m EPSOps include/slepc/private/epsimpl.h /^typedef struct _EPSOps *EPSOps;$/;" t typeref:struct:_EPSOps EPSPOWER include/slepc/finclude/slepcepsdef.h 50;" d EPSPOWER include/slepceps.h 51;" d EPSPRIMME include/slepc/finclude/slepcepsdef.h 65;" d EPSPRIMME include/slepceps.h 66;" d EPSPRIMMEGetBlockSize src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSPRIMMEGetBlockSize(EPS eps,PetscInt *bs)$/;" f EPSPRIMMEGetBlockSize_PRIMME src/eps/impls/external/primme/primme.c /^static PetscErrorCode EPSPRIMMEGetBlockSize_PRIMME(EPS eps,PetscInt *bs)$/;" f file: EPSPRIMMEGetMethod src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSPRIMMEGetMethod(EPS eps,EPSPRIMMEMethod *method)$/;" f EPSPRIMMEGetMethod_PRIMME src/eps/impls/external/primme/primme.c /^static PetscErrorCode EPSPRIMMEGetMethod_PRIMME(EPS eps,EPSPRIMMEMethod *method)$/;" f file: EPSPRIMMEMethod include/slepc/finclude/slepcepsdef.h 46;" d EPSPRIMMEMethod include/slepceps.h /^ EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod;$/;" t typeref:enum:__anon25 EPSPRIMMEMethods include/slepceps.h /^PETSC_EXTERN const char *EPSPRIMMEMethods[];$/;" v EPSPRIMMEMethods src/eps/interface/dlregiseps.c /^const char *EPSPRIMMEMethods[] = {"DYNAMIC","DEFAULT_MIN_TIME","DEFAULT_MIN_MATVECS","ARNOLDI","GD","GD_PLUSK","GD_OLSEN_PLUSK","JD_OLSEN_PLUSK","RQI","JDQR","JDQMR","JDQMR_ETOL","SUBSPACE_ITERATION","LOBPCG_ORTHOBASIS","LOBPCG_ORTHOBASISW","EPSPRIMMEMethod","EPS_PRIMME_",0};$/;" v EPSPRIMMESetBlockSize src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSPRIMMESetBlockSize(EPS eps,PetscInt bs)$/;" f EPSPRIMMESetBlockSize_PRIMME src/eps/impls/external/primme/primme.c /^static PetscErrorCode EPSPRIMMESetBlockSize_PRIMME(EPS eps,PetscInt bs)$/;" f file: EPSPRIMMESetMethod src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSPRIMMESetMethod(EPS eps,EPSPRIMMEMethod method)$/;" f EPSPRIMMESetMethod_PRIMME src/eps/impls/external/primme/primme.c /^static PetscErrorCode EPSPRIMMESetMethod_PRIMME(EPS eps,EPSPRIMMEMethod method)$/;" f file: EPSPackageInitialized src/eps/interface/dlregiseps.c /^static PetscBool EPSPackageInitialized = PETSC_FALSE;$/;" v file: EPSPartialLanczos src/eps/impls/krylov/lanczos/lanczos.c /^static PetscErrorCode EPSPartialLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscReal anorm)$/;" f file: EPSPowerGetShiftType src/eps/impls/power/power.c /^PetscErrorCode EPSPowerGetShiftType(EPS eps,EPSPowerShiftType *shift)$/;" f EPSPowerGetShiftType_Power src/eps/impls/power/power.c /^static PetscErrorCode EPSPowerGetShiftType_Power(EPS eps,EPSPowerShiftType *shift)$/;" f file: EPSPowerSetShiftType src/eps/impls/power/power.c /^PetscErrorCode EPSPowerSetShiftType(EPS eps,EPSPowerShiftType shift)$/;" f EPSPowerSetShiftType_Power src/eps/impls/power/power.c /^static PetscErrorCode EPSPowerSetShiftType_Power(EPS eps,EPSPowerShiftType shift)$/;" f file: EPSPowerShiftType include/slepc/finclude/slepcepsdef.h 44;" d EPSPowerShiftType include/slepceps.h /^ EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType;$/;" t typeref:enum:__anon23 EPSPowerShiftTypes include/slepceps.h /^PETSC_EXTERN const char *EPSPowerShiftTypes[];$/;" v EPSPowerShiftTypes src/eps/interface/dlregiseps.c /^const char *EPSPowerShiftTypes[] = {"CONSTANT","RAYLEIGH","WILKINSON","EPSPowerShiftType","EPS_POWER_SHIFT_",0};$/;" v EPSPrepareRational src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSPrepareRational(EPS eps)$/;" f file: EPSPrintSolution include/slepceps.h /^PETSC_DEPRECATED("Use EPSErrorView()") PETSC_STATIC_INLINE PetscErrorCode EPSPrintSolution(EPS eps,PetscViewer v) {return EPSErrorView(eps,EPS_ERROR_RELATIVE,v);}$/;" f EPSProblemType include/slepc/finclude/slepcepsdef.h 38;" d EPSProblemType include/slepceps.h /^ EPS_GHIEP } EPSProblemType;$/;" t typeref:enum:__anon15 EPSPseudoLanczos src/eps/impls/krylov/epskrylov.c /^PetscErrorCode EPSPseudoLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscReal *cos,Vec w)$/;" f EPSRQCG include/slepc/finclude/slepcepsdef.h 57;" d EPSRQCG include/slepceps.h 58;" d EPSRQCGGetReset src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSRQCGGetReset(EPS eps,PetscInt *nrest)$/;" f EPSRQCGGetReset_RQCG src/eps/impls/cg/rqcg/rqcg.c /^static PetscErrorCode EPSRQCGGetReset_RQCG(EPS eps,PetscInt *nrest)$/;" f file: EPSRQCGSetReset src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSRQCGSetReset(EPS eps,PetscInt nrest)$/;" f EPSRQCGSetReset_RQCG src/eps/impls/cg/rqcg/rqcg.c /^static PetscErrorCode EPSRQCGSetReset_RQCG(EPS eps,PetscInt nrest)$/;" f file: EPSReasonView src/eps/interface/epsview.c /^PetscErrorCode EPSReasonView(EPS eps,PetscViewer viewer)$/;" f EPSReasonViewFromOptions src/eps/interface/epsview.c /^PetscErrorCode EPSReasonViewFromOptions(EPS eps)$/;" f EPSRegister src/eps/interface/epsbasic.c /^PetscErrorCode EPSRegister(const char *name,PetscErrorCode (*function)(EPS))$/;" f EPSRegisterAll src/eps/interface/epsregis.c /^PetscErrorCode EPSRegisterAll(void)$/;" f EPSRegisterAllCalled include/slepc/private/epsimpl.h /^PETSC_EXTERN PetscBool EPSRegisterAllCalled;$/;" v EPSRegisterAllCalled src/eps/interface/epsbasic.c /^PetscBool EPSRegisterAllCalled = PETSC_FALSE;$/;" v EPSReset src/eps/interface/epsbasic.c /^PetscErrorCode EPSReset(EPS eps)$/;" f EPSReset_ARPACK src/eps/impls/external/arpack/arpack.c /^PetscErrorCode EPSReset_ARPACK(EPS eps)$/;" f EPSReset_BLOPEX src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSReset_BLOPEX(EPS eps)$/;" f EPSReset_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSReset_BLZPACK(EPS eps)$/;" f EPSReset_CISS src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSReset_CISS(EPS eps)$/;" f EPSReset_FEAST src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSReset_FEAST(EPS eps)$/;" f EPSReset_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSReset_KrylovSchur(EPS eps)$/;" f EPSReset_KrylovSchur_Slice src/eps/impls/krylov/krylovschur/ks-slice.c /^PetscErrorCode EPSReset_KrylovSchur_Slice(EPS eps)$/;" f EPSReset_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSReset_Lanczos(EPS eps)$/;" f EPSReset_PRIMME src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSReset_PRIMME(EPS eps)$/;" f EPSReset_RQCG src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSReset_RQCG(EPS eps)$/;" f EPSReset_TRLAN src/eps/impls/external/trlan/trlan.c /^PetscErrorCode EPSReset_TRLAN(EPS eps)$/;" f EPSReset_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSReset_XD(EPS eps)$/;" f EPSSUBSPACE include/slepc/finclude/slepcepsdef.h 51;" d EPSSUBSPACE include/slepceps.h 52;" d EPSSelectiveLanczos src/eps/impls/krylov/lanczos/lanczos.c /^static PetscErrorCode EPSSelectiveLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscReal anorm)$/;" f file: EPSSetArbitrarySelection src/eps/interface/epsopts.c /^PetscErrorCode EPSSetArbitrarySelection(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*),void* ctx)$/;" f EPSSetBV src/eps/interface/epsbasic.c /^PetscErrorCode EPSSetBV(EPS eps,BV V)$/;" f EPSSetBalance src/eps/interface/epsopts.c /^PetscErrorCode EPSSetBalance(EPS eps,EPSBalance bal,PetscInt its,PetscReal cutoff)$/;" f EPSSetConvergenceTest src/eps/interface/epsopts.c /^PetscErrorCode EPSSetConvergenceTest(EPS eps,EPSConv conv)$/;" f EPSSetConvergenceTestFunction src/eps/interface/epsopts.c /^PetscErrorCode EPSSetConvergenceTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f EPSSetDS src/eps/interface/epsbasic.c /^PetscErrorCode EPSSetDS(EPS eps,DS ds)$/;" f EPSSetDeflationSpace src/eps/interface/epssetup.c /^PetscErrorCode EPSSetDeflationSpace(EPS eps,PetscInt n,Vec *v)$/;" f EPSSetDimensions src/eps/interface/epsopts.c /^PetscErrorCode EPSSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)$/;" f EPSSetDimensions_BLOPEX src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSSetDimensions_BLOPEX(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)$/;" f EPSSetDimensions_Default src/eps/interface/epssetup.c /^PetscErrorCode EPSSetDimensions_Default(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)$/;" f EPSSetDimensions_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSSetDimensions_LOBPCG(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)$/;" f EPSSetEigenvalueComparison src/eps/interface/epsopts.c /^PetscErrorCode EPSSetEigenvalueComparison(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)$/;" f EPSSetExtraction src/eps/interface/epsopts.c /^PetscErrorCode EPSSetExtraction(EPS eps,EPSExtraction extr)$/;" f EPSSetFromOptions src/eps/interface/epsopts.c /^PetscErrorCode EPSSetFromOptions(EPS eps)$/;" f EPSSetFromOptions_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^PetscErrorCode EPSSetFromOptions_Arnoldi(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_BLOPEX src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSSetFromOptions_BLOPEX(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSSetFromOptions_BLZPACK(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_CISS src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_FEAST src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSSetFromOptions_FEAST(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_GD src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSSetFromOptions_GD(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_JD src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSSetFromOptions_KrylovSchur(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSSetFromOptions_LOBPCG(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_PRIMME src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSSetFromOptions_PRIMME(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_Power src/eps/impls/power/power.c /^PetscErrorCode EPSSetFromOptions_Power(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetFromOptions_RQCG src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSSetFromOptions_RQCG(PetscOptionItems *PetscOptionsObject,EPS eps)$/;" f EPSSetInitialSpace src/eps/interface/epssetup.c /^PetscErrorCode EPSSetInitialSpace(EPS eps,PetscInt n,Vec *is)$/;" f EPSSetInterval src/eps/interface/epsbasic.c /^PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb)$/;" f EPSSetOperators src/eps/interface/epssetup.c /^PetscErrorCode EPSSetOperators(EPS eps,Mat A,Mat B)$/;" f EPSSetOptionsPrefix src/eps/interface/epsopts.c /^PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix)$/;" f EPSSetProblemType src/eps/interface/epsopts.c /^PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type)$/;" f EPSSetPurify src/eps/interface/epsopts.c /^PetscErrorCode EPSSetPurify(EPS eps,PetscBool purify)$/;" f EPSSetRG src/eps/interface/epsbasic.c /^PetscErrorCode EPSSetRG(EPS eps,RG rg)$/;" f EPSSetST src/eps/interface/epsbasic.c /^PetscErrorCode EPSSetST(EPS eps,ST st)$/;" f EPSSetStoppingTest src/eps/interface/epsopts.c /^PetscErrorCode EPSSetStoppingTest(EPS eps,EPSStop stop)$/;" f EPSSetStoppingTestFunction src/eps/interface/epsopts.c /^PetscErrorCode EPSSetStoppingTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f EPSSetTarget src/eps/interface/epsbasic.c /^PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)$/;" f EPSSetTolerances src/eps/interface/epsopts.c /^PetscErrorCode EPSSetTolerances(EPS eps,PetscReal tol,PetscInt maxits)$/;" f EPSSetTrackAll src/eps/interface/epsopts.c /^PetscErrorCode EPSSetTrackAll(EPS eps,PetscBool trackall)$/;" f EPSSetTrueResidual src/eps/interface/epsopts.c /^PetscErrorCode EPSSetTrueResidual(EPS eps,PetscBool trueres)$/;" f EPSSetType src/eps/interface/epsbasic.c /^PetscErrorCode EPSSetType(EPS eps,EPSType type)$/;" f EPSSetUp src/eps/interface/epssetup.c /^PetscErrorCode EPSSetUp(EPS eps)$/;" f EPSSetUp_ARPACK src/eps/impls/external/arpack/arpack.c /^PetscErrorCode EPSSetUp_ARPACK(EPS eps)$/;" f EPSSetUp_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^PetscErrorCode EPSSetUp_Arnoldi(EPS eps)$/;" f EPSSetUp_BLOPEX src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSSetUp_BLOPEX(EPS eps)$/;" f EPSSetUp_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSSetUp_BLZPACK(EPS eps)$/;" f EPSSetUp_CISS src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSSetUp_CISS(EPS eps)$/;" f EPSSetUp_FEAST src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSSetUp_FEAST(EPS eps)$/;" f EPSSetUp_GD src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSSetUp_GD(EPS eps)$/;" f EPSSetUp_JD src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSSetUp_JD(EPS eps)$/;" f EPSSetUp_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSSetUp_KrylovSchur(EPS eps)$/;" f EPSSetUp_KrylovSchur_Slice src/eps/impls/krylov/krylovschur/ks-slice.c /^PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS eps)$/;" f EPSSetUp_LAPACK src/eps/impls/lapack/lapack.c /^PetscErrorCode EPSSetUp_LAPACK(EPS eps)$/;" f EPSSetUp_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSSetUp_LOBPCG(EPS eps)$/;" f EPSSetUp_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSSetUp_Lanczos(EPS eps)$/;" f EPSSetUp_PRIMME src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSSetUp_PRIMME(EPS eps)$/;" f EPSSetUp_Power src/eps/impls/power/power.c /^PetscErrorCode EPSSetUp_Power(EPS eps)$/;" f EPSSetUp_RQCG src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSSetUp_RQCG(EPS eps)$/;" f EPSSetUp_Subspace src/eps/impls/subspace/subspace.c /^PetscErrorCode EPSSetUp_Subspace(EPS eps)$/;" f EPSSetUp_TRLAN src/eps/impls/external/trlan/trlan.c /^PetscErrorCode EPSSetUp_TRLAN(EPS eps)$/;" f EPSSetUp_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSSetUp_XD(EPS eps)$/;" f EPSSetWhichEigenpairs src/eps/interface/epsopts.c /^PetscErrorCode EPSSetWhichEigenpairs(EPS eps,EPSWhich which)$/;" f EPSSetWhichEigenpairs_Default src/eps/interface/epsdefault.c /^PetscErrorCode EPSSetWhichEigenpairs_Default(EPS eps)$/;" f EPSSetWorkVecs src/eps/interface/epsdefault.c /^PetscErrorCode EPSSetWorkVecs(EPS eps,PetscInt nw)$/;" f EPSSliceAllocateSolution src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSSliceAllocateSolution(EPS eps,PetscInt extra)$/;" f file: EPSSliceGatherEigenVectors src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSSliceGatherEigenVectors(EPS eps)$/;" f file: EPSSliceGatherSolution src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSSliceGatherSolution(EPS eps)$/;" f file: EPSSliceGetEPS src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSSliceGetEPS(EPS eps)$/;" f file: EPSSliceGetInertia src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSSliceGetInertia(EPS eps,PetscReal shift,PetscInt *inertia,PetscInt *zeros)$/;" f file: EPSSliceGetInertias src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSSliceGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)$/;" f file: EPSSliceResetSR src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSSliceResetSR(EPS eps) {$/;" f file: EPSSolve src/eps/interface/epssolve.c /^PetscErrorCode EPSSolve(EPS eps)$/;" f EPSSolve_ARPACK src/eps/impls/external/arpack/arpack.c /^PetscErrorCode EPSSolve_ARPACK(EPS eps)$/;" f EPSSolve_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^PetscErrorCode EPSSolve_Arnoldi(EPS eps)$/;" f EPSSolve_BLOPEX src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSSolve_BLOPEX(EPS eps)$/;" f EPSSolve_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSSolve_BLZPACK(EPS eps)$/;" f EPSSolve_CISS src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSSolve_CISS(EPS eps)$/;" f EPSSolve_FEAST src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSSolve_FEAST(EPS eps)$/;" f EPSSolve_KrylovSchur_Default src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSSolve_KrylovSchur_Default(EPS eps)$/;" f EPSSolve_KrylovSchur_Indefinite src/eps/impls/krylov/krylovschur/ks-indef.c /^PetscErrorCode EPSSolve_KrylovSchur_Indefinite(EPS eps)$/;" f EPSSolve_KrylovSchur_Slice src/eps/impls/krylov/krylovschur/ks-slice.c /^PetscErrorCode EPSSolve_KrylovSchur_Slice(EPS eps)$/;" f EPSSolve_KrylovSchur_Symm src/eps/impls/krylov/krylovschur/ks-symm.c /^PetscErrorCode EPSSolve_KrylovSchur_Symm(EPS eps)$/;" f EPSSolve_LAPACK src/eps/impls/lapack/lapack.c /^PetscErrorCode EPSSolve_LAPACK(EPS eps)$/;" f EPSSolve_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSSolve_LOBPCG(EPS eps)$/;" f EPSSolve_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSSolve_Lanczos(EPS eps)$/;" f EPSSolve_PRIMME src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSSolve_PRIMME(EPS eps)$/;" f EPSSolve_Power src/eps/impls/power/power.c /^PetscErrorCode EPSSolve_Power(EPS eps)$/;" f EPSSolve_RQCG src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSSolve_RQCG(EPS eps)$/;" f EPSSolve_Subspace src/eps/impls/subspace/subspace.c /^PetscErrorCode EPSSolve_Subspace(EPS eps)$/;" f EPSSolve_TRLAN src/eps/impls/external/trlan/trlan.c /^PetscErrorCode EPSSolve_TRLAN(EPS eps)$/;" f EPSSolve_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSSolve_XD(EPS eps)$/;" f EPSStateType include/slepc/private/epsimpl.h /^ EPS_STATE_EIGENVECTORS } EPSStateType;$/;" t typeref:enum:__anon1 EPSStop include/slepc/finclude/slepcepsdef.h 43;" d EPSStop include/slepceps.h /^ EPS_STOP_USER } EPSStop;$/;" t typeref:enum:__anon21 EPSStoppingBasic src/eps/interface/epsdefault.c /^PetscErrorCode EPSStoppingBasic(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)$/;" f EPSStoreEigenpairs src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode EPSStoreEigenpairs(EPS eps)$/;" f file: EPSSubspaceFindGroup src/eps/impls/subspace/subspace.c /^static PetscErrorCode EPSSubspaceFindGroup(PetscInt l,PetscInt m,PetscScalar *wr,PetscScalar *wi,PetscReal *rsd,PetscReal grptol,PetscInt *ngrp,PetscReal *ctr,PetscReal *ae,PetscReal *arsd)$/;" f file: EPSSubspaceResidualNorms src/eps/impls/subspace/subspace.c /^static PetscErrorCode EPSSubspaceResidualNorms(BV V,BV AV,PetscScalar *T,PetscInt l,PetscInt m,PetscInt ldt,Vec w,PetscReal *rsd)$/;" f file: EPSTRLAN include/slepc/finclude/slepcepsdef.h 63;" d EPSTRLAN include/slepceps.h 64;" d EPSType include/slepc/finclude/slepcepsdef.h 35;" d EPSType include/slepceps.h /^typedef const char* EPSType;$/;" t EPSValuesView src/eps/interface/epsview.c /^PetscErrorCode EPSValuesView(EPS eps,PetscViewer viewer)$/;" f EPSValuesViewFromOptions src/eps/interface/epsview.c /^PetscErrorCode EPSValuesViewFromOptions(EPS eps)$/;" f EPSValuesView_ASCII src/eps/interface/epsview.c /^static PetscErrorCode EPSValuesView_ASCII(EPS eps,PetscViewer viewer)$/;" f file: EPSValuesView_DRAW src/eps/interface/epsview.c /^static PetscErrorCode EPSValuesView_DRAW(EPS eps,PetscViewer viewer)$/;" f file: EPSValuesView_MATLAB src/eps/interface/epsview.c /^static PetscErrorCode EPSValuesView_MATLAB(EPS eps,PetscViewer viewer)$/;" f file: EPSVectorsView src/eps/interface/epsview.c /^PetscErrorCode EPSVectorsView(EPS eps,PetscViewer viewer)$/;" f EPSVectorsViewFromOptions src/eps/interface/epsview.c /^PetscErrorCode EPSVectorsViewFromOptions(EPS eps)$/;" f EPSView src/eps/interface/epsview.c /^PetscErrorCode EPSView(EPS eps,PetscViewer viewer)$/;" f EPSViewFromOptions include/slepceps.h /^PETSC_STATIC_INLINE PetscErrorCode EPSViewFromOptions(EPS eps,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)eps,obj,name);}$/;" f EPSView_Arnoldi src/eps/impls/krylov/arnoldi/arnoldi.c /^PetscErrorCode EPSView_Arnoldi(EPS eps,PetscViewer viewer)$/;" f EPSView_BLOPEX src/eps/impls/external/blopex/blopex.c /^PetscErrorCode EPSView_BLOPEX(EPS eps,PetscViewer viewer)$/;" f EPSView_BLZPACK src/eps/impls/external/blzpack/blzpack.c /^PetscErrorCode EPSView_BLZPACK(EPS eps,PetscViewer viewer)$/;" f EPSView_CISS src/eps/impls/ciss/ciss.c /^PetscErrorCode EPSView_CISS(EPS eps,PetscViewer viewer)$/;" f EPSView_FEAST src/eps/impls/external/feast/feast.c /^PetscErrorCode EPSView_FEAST(EPS eps,PetscViewer viewer)$/;" f EPSView_GD src/eps/impls/davidson/gd/gd.c /^PetscErrorCode EPSView_GD(EPS eps,PetscViewer viewer)$/;" f EPSView_JD src/eps/impls/davidson/jd/jd.c /^PetscErrorCode EPSView_JD(EPS eps,PetscViewer viewer)$/;" f EPSView_KrylovSchur src/eps/impls/krylov/krylovschur/krylovschur.c /^PetscErrorCode EPSView_KrylovSchur(EPS eps,PetscViewer viewer)$/;" f EPSView_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^PetscErrorCode EPSView_LOBPCG(EPS eps,PetscViewer viewer)$/;" f EPSView_Lanczos src/eps/impls/krylov/lanczos/lanczos.c /^PetscErrorCode EPSView_Lanczos(EPS eps,PetscViewer viewer)$/;" f EPSView_PRIMME src/eps/impls/external/primme/primme.c /^PetscErrorCode EPSView_PRIMME(EPS eps,PetscViewer viewer)$/;" f EPSView_Power src/eps/impls/power/power.c /^PetscErrorCode EPSView_Power(EPS eps,PetscViewer viewer)$/;" f EPSView_RQCG src/eps/impls/cg/rqcg/rqcg.c /^PetscErrorCode EPSView_RQCG(EPS eps,PetscViewer viewer)$/;" f EPSWhich include/slepc/finclude/slepcepsdef.h 39;" d EPSWhich include/slepceps.h /^ EPS_WHICH_USER } EPSWhich;$/;" t typeref:enum:__anon17 EPSXDComputeDSConv src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode EPSXDComputeDSConv(dvdDashboard *d)$/;" f file: EPSXDGetBOrth_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDGetBOrth_XD(EPS eps,PetscBool *borth)$/;" f EPSXDGetBlockSize_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDGetBlockSize_XD(EPS eps,PetscInt *blocksize)$/;" f EPSXDGetFix_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDGetFix_XD(EPS eps,PetscReal *fix)$/;" f EPSXDGetInitialSize_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDGetInitialSize_XD(EPS eps,PetscInt *initialsize)$/;" f EPSXDGetKrylovStart_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDGetKrylovStart_XD(EPS eps,PetscBool *krylovstart)$/;" f EPSXDGetRestart_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDGetRestart_XD(EPS eps,PetscInt *minv,PetscInt *plusk)$/;" f EPSXDGetWindowSizes_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDGetWindowSizes_XD(EPS eps,PetscInt *pwindow,PetscInt *qwindow)$/;" f EPSXDSetBOrth_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDSetBOrth_XD(EPS eps,PetscBool borth)$/;" f EPSXDSetBlockSize_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDSetBlockSize_XD(EPS eps,PetscInt blocksize)$/;" f EPSXDSetInitialSize_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDSetInitialSize_XD(EPS eps,PetscInt initialsize)$/;" f EPSXDSetKrylovStart_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDSetKrylovStart_XD(EPS eps,PetscBool krylovstart)$/;" f EPSXDSetRestart_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDSetRestart_XD(EPS eps,PetscInt minv,PetscInt plusk)$/;" f EPSXDSetWindowSizes_XD src/eps/impls/davidson/davidson.c /^PetscErrorCode EPSXDSetWindowSizes_XD(EPS eps,PetscInt pwindow,PetscInt qwindow)$/;" f EPSXDUpdateProj src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode EPSXDUpdateProj(Mat Q,Mat Z,PetscInt l,Mat A,PetscInt lA,PetscInt kA,Mat aux)$/;" f file: EPS_ALL include/slepceps.h /^ EPS_ALL,$/;" e enum:__anon17 EPS_ARNOLDI src/eps/impls/krylov/arnoldi/arnoldi.c /^} EPS_ARNOLDI;$/;" t typeref:struct:__anon80 file: EPS_ARPACK src/eps/impls/external/arpack/arpackp.h /^} EPS_ARPACK;$/;" t typeref:struct:__anon74 EPS_BALANCE_NONE include/slepceps.h /^typedef enum { EPS_BALANCE_NONE,$/;" e enum:__anon18 EPS_BALANCE_ONESIDE include/slepceps.h /^ EPS_BALANCE_ONESIDE,$/;" e enum:__anon18 EPS_BALANCE_TWOSIDE include/slepceps.h /^ EPS_BALANCE_TWOSIDE,$/;" e enum:__anon18 EPS_BALANCE_USER include/slepceps.h /^ EPS_BALANCE_USER } EPSBalance;$/;" e enum:__anon18 EPS_BLOPEX src/eps/impls/external/blopex/blopex.c /^} EPS_BLOPEX;$/;" t typeref:struct:__anon75 file: EPS_BLZPACK src/eps/impls/external/blzpack/blzpackp.h /^} EPS_BLZPACK;$/;" t typeref:struct:__anon76 EPS_CISS src/eps/impls/ciss/ciss.c /^} EPS_CISS;$/;" t typeref:struct:__anon61 file: EPS_CISS_EXTRACTION_HANKEL include/slepceps.h /^ EPS_CISS_EXTRACTION_HANKEL } EPSCISSExtraction;$/;" e enum:__anon27 EPS_CISS_EXTRACTION_RITZ include/slepceps.h /^typedef enum { EPS_CISS_EXTRACTION_RITZ,$/;" e enum:__anon27 EPS_CISS_QUADRULE_CHEBYSHEV include/slepceps.h /^ EPS_CISS_QUADRULE_CHEBYSHEV } EPSCISSQuadRule;$/;" e enum:__anon26 EPS_CISS_QUADRULE_TRAPEZOIDAL include/slepceps.h /^typedef enum { EPS_CISS_QUADRULE_TRAPEZOIDAL=1,$/;" e enum:__anon26 EPS_CLASSID include/slepceps.h /^PETSC_EXTERN PetscClassId EPS_CLASSID;$/;" v EPS_CLASSID src/eps/interface/epsbasic.c /^PetscClassId EPS_CLASSID = 0;$/;" v EPS_CONVERGED_ITERATING include/slepceps.h /^ EPS_CONVERGED_ITERATING = 0} EPSConvergedReason;$/;" e enum:__anon22 EPS_CONVERGED_TOL include/slepceps.h /^ EPS_CONVERGED_TOL = 1,$/;" e enum:__anon22 EPS_CONVERGED_USER include/slepceps.h /^ EPS_CONVERGED_USER = 2,$/;" e enum:__anon22 EPS_CONV_ABS include/slepceps.h /^typedef enum { EPS_CONV_ABS,$/;" e enum:__anon20 EPS_CONV_NORM include/slepceps.h /^ EPS_CONV_NORM,$/;" e enum:__anon20 EPS_CONV_REL include/slepceps.h /^ EPS_CONV_REL,$/;" e enum:__anon20 EPS_CONV_USER include/slepceps.h /^ EPS_CONV_USER } EPSConv;$/;" e enum:__anon20 EPS_DAVIDSON src/eps/impls/davidson/davidson.h /^} EPS_DAVIDSON;$/;" t typeref:struct:__anon65 EPS_DIVERGED_BREAKDOWN include/slepceps.h /^ EPS_DIVERGED_BREAKDOWN = -2,$/;" e enum:__anon22 EPS_DIVERGED_ITS include/slepceps.h /^ EPS_DIVERGED_ITS = -1,$/;" e enum:__anon22 EPS_DIVERGED_SYMMETRY_LOST include/slepceps.h /^ EPS_DIVERGED_SYMMETRY_LOST = -3,$/;" e enum:__anon22 EPS_ERROR_ABSOLUTE include/slepceps.h /^typedef enum { EPS_ERROR_ABSOLUTE,$/;" e enum:__anon19 EPS_ERROR_BACKWARD include/slepceps.h /^ EPS_ERROR_BACKWARD } EPSErrorType;$/;" e enum:__anon19 EPS_ERROR_RELATIVE include/slepceps.h /^ EPS_ERROR_RELATIVE,$/;" e enum:__anon19 EPS_FEAST src/eps/impls/external/feast/feastp.h /^} EPS_FEAST;$/;" t typeref:struct:__anon77 EPS_GHEP include/slepceps.h /^ EPS_GHEP,$/;" e enum:__anon15 EPS_GHIEP include/slepceps.h /^ EPS_GHIEP } EPSProblemType;$/;" e enum:__anon15 EPS_GNHEP include/slepceps.h /^ EPS_GNHEP,$/;" e enum:__anon15 EPS_HARMONIC include/slepceps.h /^ EPS_HARMONIC,$/;" e enum:__anon16 EPS_HARMONIC_LARGEST include/slepceps.h /^ EPS_HARMONIC_LARGEST,$/;" e enum:__anon16 EPS_HARMONIC_RELATIVE include/slepceps.h /^ EPS_HARMONIC_RELATIVE,$/;" e enum:__anon16 EPS_HARMONIC_RIGHT include/slepceps.h /^ EPS_HARMONIC_RIGHT,$/;" e enum:__anon16 EPS_HEP include/slepceps.h /^typedef enum { EPS_HEP=1,$/;" e enum:__anon15 EPS_KRYLOVSCHUR src/eps/impls/krylov/krylovschur/krylovschur.h /^} EPS_KRYLOVSCHUR;$/;" t typeref:struct:__anon81 EPS_LANCZOS src/eps/impls/krylov/lanczos/lanczos.c /^} EPS_LANCZOS;$/;" t typeref:struct:__anon82 file: EPS_LANCZOS_REORTHOG_DELAYED include/slepceps.h /^ EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType;$/;" e enum:__anon24 EPS_LANCZOS_REORTHOG_FULL include/slepceps.h /^ EPS_LANCZOS_REORTHOG_FULL,$/;" e enum:__anon24 EPS_LANCZOS_REORTHOG_LOCAL include/slepceps.h /^typedef enum { EPS_LANCZOS_REORTHOG_LOCAL,$/;" e enum:__anon24 EPS_LANCZOS_REORTHOG_PARTIAL include/slepceps.h /^ EPS_LANCZOS_REORTHOG_PARTIAL,$/;" e enum:__anon24 EPS_LANCZOS_REORTHOG_PERIODIC include/slepceps.h /^ EPS_LANCZOS_REORTHOG_PERIODIC,$/;" e enum:__anon24 EPS_LANCZOS_REORTHOG_SELECTIVE include/slepceps.h /^ EPS_LANCZOS_REORTHOG_SELECTIVE,$/;" e enum:__anon24 EPS_LARGEST_IMAGINARY include/slepceps.h /^ EPS_LARGEST_IMAGINARY,$/;" e enum:__anon17 EPS_LARGEST_MAGNITUDE include/slepceps.h /^typedef enum { EPS_LARGEST_MAGNITUDE=1,$/;" e enum:__anon17 EPS_LARGEST_REAL include/slepceps.h /^ EPS_LARGEST_REAL,$/;" e enum:__anon17 EPS_LOBPCG src/eps/impls/cg/lobpcg/lobpcg.c /^} EPS_LOBPCG;$/;" t typeref:struct:__anon59 file: EPS_NHEP include/slepceps.h /^ EPS_NHEP,$/;" e enum:__anon15 EPS_PGNHEP include/slepceps.h /^ EPS_PGNHEP,$/;" e enum:__anon15 EPS_POWER src/eps/impls/power/power.c /^} EPS_POWER;$/;" t typeref:struct:__anon83 file: EPS_POWER_SHIFT_CONSTANT include/slepceps.h /^typedef enum { EPS_POWER_SHIFT_CONSTANT,$/;" e enum:__anon23 EPS_POWER_SHIFT_RAYLEIGH include/slepceps.h /^ EPS_POWER_SHIFT_RAYLEIGH,$/;" e enum:__anon23 EPS_POWER_SHIFT_WILKINSON include/slepceps.h /^ EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType;$/;" e enum:__anon23 EPS_PRIMME src/eps/impls/external/primme/primme.c /^} EPS_PRIMME;$/;" t typeref:struct:__anon78 file: EPS_PRIMME_ARNOLDI include/slepceps.h /^ EPS_PRIMME_ARNOLDI,$/;" e enum:__anon25 EPS_PRIMME_DEFAULT_MIN_MATVECS include/slepceps.h /^ EPS_PRIMME_DEFAULT_MIN_MATVECS,$/;" e enum:__anon25 EPS_PRIMME_DEFAULT_MIN_TIME include/slepceps.h /^ EPS_PRIMME_DEFAULT_MIN_TIME,$/;" e enum:__anon25 EPS_PRIMME_DYNAMIC include/slepceps.h /^typedef enum { EPS_PRIMME_DYNAMIC,$/;" e enum:__anon25 EPS_PRIMME_GD include/slepceps.h /^ EPS_PRIMME_GD,$/;" e enum:__anon25 EPS_PRIMME_GD_OLSEN_PLUSK include/slepceps.h /^ EPS_PRIMME_GD_OLSEN_PLUSK,$/;" e enum:__anon25 EPS_PRIMME_GD_PLUSK include/slepceps.h /^ EPS_PRIMME_GD_PLUSK,$/;" e enum:__anon25 EPS_PRIMME_JDQMR include/slepceps.h /^ EPS_PRIMME_JDQMR,$/;" e enum:__anon25 EPS_PRIMME_JDQMR_ETOL include/slepceps.h /^ EPS_PRIMME_JDQMR_ETOL,$/;" e enum:__anon25 EPS_PRIMME_JDQR include/slepceps.h /^ EPS_PRIMME_JDQR,$/;" e enum:__anon25 EPS_PRIMME_JD_OLSEN_PLUSK include/slepceps.h /^ EPS_PRIMME_JD_OLSEN_PLUSK,$/;" e enum:__anon25 EPS_PRIMME_LOBPCG_ORTHOBASIS include/slepceps.h /^ EPS_PRIMME_LOBPCG_ORTHOBASIS,$/;" e enum:__anon25 EPS_PRIMME_LOBPCG_ORTHOBASISW include/slepceps.h /^ EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod;$/;" e enum:__anon25 EPS_PRIMME_RQI include/slepceps.h /^ EPS_PRIMME_RQI,$/;" e enum:__anon25 EPS_PRIMME_SUBSPACE_ITERATION include/slepceps.h /^ EPS_PRIMME_SUBSPACE_ITERATION,$/;" e enum:__anon25 EPS_REFINED include/slepceps.h /^ EPS_REFINED,$/;" e enum:__anon16 EPS_REFINED_HARMONIC include/slepceps.h /^ EPS_REFINED_HARMONIC } EPSExtraction;$/;" e enum:__anon16 EPS_RITZ include/slepceps.h /^typedef enum { EPS_RITZ,$/;" e enum:__anon16 EPS_RQCG src/eps/impls/cg/rqcg/rqcg.c /^} EPS_RQCG;$/;" t typeref:struct:__anon60 file: EPS_SMALLEST_IMAGINARY include/slepceps.h /^ EPS_SMALLEST_IMAGINARY,$/;" e enum:__anon17 EPS_SMALLEST_MAGNITUDE include/slepceps.h /^ EPS_SMALLEST_MAGNITUDE,$/;" e enum:__anon17 EPS_SMALLEST_REAL include/slepceps.h /^ EPS_SMALLEST_REAL,$/;" e enum:__anon17 EPS_SR src/eps/impls/krylov/krylovschur/krylovschur.h /^typedef struct _n_SR *EPS_SR;$/;" t typeref:struct:_n_SR EPS_STATE_EIGENVECTORS include/slepc/private/epsimpl.h /^ EPS_STATE_EIGENVECTORS } EPSStateType;$/;" e enum:__anon1 EPS_STATE_INITIAL include/slepc/private/epsimpl.h /^typedef enum { EPS_STATE_INITIAL,$/;" e enum:__anon1 EPS_STATE_SETUP include/slepc/private/epsimpl.h /^ EPS_STATE_SETUP,$/;" e enum:__anon1 EPS_STATE_SOLVED include/slepc/private/epsimpl.h /^ EPS_STATE_SOLVED,$/;" e enum:__anon1 EPS_STOP_BASIC include/slepceps.h /^typedef enum { EPS_STOP_BASIC,$/;" e enum:__anon21 EPS_STOP_USER include/slepceps.h /^ EPS_STOP_USER } EPSStop;$/;" e enum:__anon21 EPS_SetInnerProduct include/slepc/private/epsimpl.h /^PETSC_STATIC_INLINE PetscErrorCode EPS_SetInnerProduct(EPS eps)$/;" f EPS_SetUp include/slepc/private/epsimpl.h /^PETSC_EXTERN PetscLogEvent EPS_SetUp,EPS_Solve;$/;" v EPS_SetUp src/eps/interface/epsbasic.c /^PetscLogEvent EPS_SetUp = 0,EPS_Solve = 0;$/;" v EPS_Solve include/slepc/private/epsimpl.h /^PETSC_EXTERN PetscLogEvent EPS_SetUp,EPS_Solve;$/;" v EPS_Solve src/eps/interface/epsbasic.c /^PetscLogEvent EPS_SetUp = 0,EPS_Solve = 0;$/;" v EPS_TARGET_IMAGINARY include/slepceps.h /^ EPS_TARGET_IMAGINARY,$/;" e enum:__anon17 EPS_TARGET_MAGNITUDE include/slepceps.h /^ EPS_TARGET_MAGNITUDE,$/;" e enum:__anon17 EPS_TARGET_REAL include/slepceps.h /^ EPS_TARGET_REAL,$/;" e enum:__anon17 EPS_TRLAN src/eps/impls/external/trlan/trlanp.h /^} EPS_TRLAN;$/;" t typeref:struct:__anon79 EPS_WHICH_USER include/slepceps.h /^ EPS_WHICH_USER } EPSWhich;$/;" e enum:__anon17 EPS_shift src/eps/impls/krylov/krylovschur/krylovschur.h /^typedef struct _n_shift *EPS_shift;$/;" t typeref:struct:_n_shift EPType_t include/slepc/private/vecimplslepc.h /^typedef PetscInt EPType_t;$/;" t EXAMPLESC src/eps/examples/tests/makefile /^EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c \\$/;" m EXAMPLESC src/eps/examples/tutorials/makefile /^EXAMPLESC = ex1.c ex2.c ex3.c ex4.c ex5.c ex7.c ex9.c ex10.c ex11.c ex12.c ex13.c \\$/;" m EXAMPLESC src/mfn/examples/tests/makefile /^EXAMPLESC = test1.c$/;" m EXAMPLESC src/mfn/examples/tutorials/makefile /^EXAMPLESC = ex23.c ex26.c$/;" m EXAMPLESC src/nep/examples/nlevp/makefile /^EXAMPLESC = loaded_string.c gun.c$/;" m EXAMPLESC src/nep/examples/tests/makefile /^EXAMPLESC =$/;" m EXAMPLESC src/nep/examples/tutorials/makefile /^EXAMPLESC = ex20.c ex21.c ex22.c ex27.c$/;" m EXAMPLESC src/pep/examples/nlevp/makefile /^EXAMPLESC = acoustic_wave_1d.c acoustic_wave_2d.c butterfly.c damped_beam.c \\$/;" m EXAMPLESC src/pep/examples/tests/makefile /^EXAMPLESC = test1.c test2.c test3.c$/;" m EXAMPLESC src/pep/examples/tutorials/makefile /^EXAMPLESC = ex16.c ex17.c ex28.c$/;" m EXAMPLESC src/svd/examples/tests/makefile /^EXAMPLESC = test1.c test2.c test3.c$/;" m EXAMPLESC src/svd/examples/tutorials/makefile /^EXAMPLESC = ex8.c ex14.c ex15.c$/;" m EXAMPLESC src/sys/classes/bv/examples/tests/makefile /^EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c test10.c test11.c test12.c$/;" m EXAMPLESC src/sys/classes/ds/examples/tests/makefile /^EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c \\$/;" m EXAMPLESC src/sys/classes/fn/examples/tests/makefile /^EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c$/;" m EXAMPLESC src/sys/classes/rg/examples/tests/makefile /^EXAMPLESC = test1.c$/;" m EXAMPLESC src/sys/classes/st/examples/tests/makefile /^EXAMPLESC = test1.c test2.c test3.c test4.c$/;" m EXAMPLESF src/eps/examples/tests/makefile /^EXAMPLESF = test7f.F test14f.F test15f.F$/;" m EXAMPLESF src/eps/examples/tutorials/makefile /^EXAMPLESF = ex1f.F ex1f90.F90 ex6f.F$/;" m EXAMPLESF src/mfn/examples/tests/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/mfn/examples/tutorials/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/nep/examples/nlevp/makefile /^EXAMPLESF = $/;" m EXAMPLESF src/nep/examples/tests/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/nep/examples/tutorials/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/pep/examples/nlevp/makefile /^EXAMPLESF = $/;" m EXAMPLESF src/pep/examples/tests/makefile /^EXAMPLESF = test3f.F$/;" m EXAMPLESF src/pep/examples/tutorials/makefile /^EXAMPLESF = ex16f90.F90$/;" m EXAMPLESF src/svd/examples/tests/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/svd/examples/tutorials/makefile /^EXAMPLESF = ex15f.F$/;" m EXAMPLESF src/sys/classes/bv/examples/tests/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/sys/classes/ds/examples/tests/makefile /^EXAMPLESF = test14f.F$/;" m EXAMPLESF src/sys/classes/fn/examples/tests/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/sys/classes/rg/examples/tests/makefile /^EXAMPLESF =$/;" m EXAMPLESF src/sys/classes/st/examples/tests/makefile /^EXAMPLESF =$/;" m EXLEN src/eps/interface/epsview.c 371;" d file: EXLEN src/nep/interface/nepview.c 325;" d file: EXLEN src/pep/interface/pepview.c 345;" d file: EXLEN src/svd/interface/svdview.c 235;" d file: ErrorIfNotEmpty config/argdb.py /^ def ErrorIfNotEmpty(self):$/;" m class:ArgDB EstimateNumberEigs src/eps/impls/ciss/ciss.c /^static PetscErrorCode EstimateNumberEigs(EPS eps,PetscInt *L_add)$/;" f file: EstimateNumberEigs src/nep/impls/ciss/nciss.c /^static PetscErrorCode EstimateNumberEigs(NEP nep,PetscInt *L_add)$/;" f file: Exit config/log.py /^ def Exit(self,string):$/;" m class:Log ExtractSubmatrix src/eps/impls/cg/rqcg/rqcg.c /^static PetscErrorCode ExtractSubmatrix(Mat A,PetscInt k,Mat *B)$/;" f file: FEASTinit_ src/eps/impls/external/feast/feastp.h 94;" d FEASTrci_ src/eps/impls/external/feast/feastp.h 95;" d FFLAGS docs/makefile /^FFLAGS =$/;" m FFLAGS include/makefile /^FFLAGS =$/;" m FFLAGS include/slepc/finclude/makefile /^FFLAGS =$/;" m FFLAGS include/slepc/private/makefile /^FFLAGS =$/;" m FFLAGS src/eps/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/eps/examples/tutorials/makefile /^FFLAGS =$/;" m FFLAGS src/eps/f90-mod/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/cg/lobpcg/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/cg/rqcg/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/ciss/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/davidson/gd/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/davidson/jd/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/davidson/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/external/arpack/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/external/blopex/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/external/blzpack/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/external/feast/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/external/primme/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/external/trlan/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/krylov/arnoldi/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/krylov/krylovschur/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/krylov/lanczos/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/krylov/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/lapack/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/power/makefile /^FFLAGS =$/;" m FFLAGS src/eps/impls/subspace/makefile /^FFLAGS =$/;" m FFLAGS src/eps/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/eps/interface/makefile /^FFLAGS =$/;" m FFLAGS src/mfn/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/mfn/examples/tutorials/makefile /^FFLAGS =$/;" m FFLAGS src/mfn/f90-mod/makefile /^FFLAGS =$/;" m FFLAGS src/mfn/impls/expokit/makefile /^FFLAGS =$/;" m FFLAGS src/mfn/impls/krylov/makefile /^FFLAGS =$/;" m FFLAGS src/mfn/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/mfn/interface/makefile /^FFLAGS =$/;" m FFLAGS src/nep/examples/nlevp/makefile /^FFLAGS =$/;" m FFLAGS src/nep/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/nep/examples/tutorials/makefile /^FFLAGS =$/;" m FFLAGS src/nep/f90-mod/makefile /^FFLAGS =$/;" m FFLAGS src/nep/impls/ciss/makefile /^FFLAGS =$/;" m FFLAGS src/nep/impls/interpol/makefile /^FFLAGS =$/;" m FFLAGS src/nep/impls/narnoldi/makefile /^FFLAGS =$/;" m FFLAGS src/nep/impls/nleigs/makefile /^FFLAGS =$/;" m FFLAGS src/nep/impls/rii/makefile /^FFLAGS =$/;" m FFLAGS src/nep/impls/slp/makefile /^FFLAGS =$/;" m FFLAGS src/nep/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/nep/interface/makefile /^FFLAGS =$/;" m FFLAGS src/pep/examples/nlevp/makefile /^FFLAGS =$/;" m FFLAGS src/pep/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/pep/examples/tutorials/makefile /^FFLAGS =$/;" m FFLAGS src/pep/f90-mod/makefile /^FFLAGS =$/;" m FFLAGS src/pep/impls/jd/makefile /^FFLAGS =$/;" m FFLAGS src/pep/impls/krylov/makefile /^FFLAGS =$/;" m FFLAGS src/pep/impls/krylov/qarnoldi/makefile /^FFLAGS =$/;" m FFLAGS src/pep/impls/krylov/stoar/makefile /^FFLAGS =$/;" m FFLAGS src/pep/impls/krylov/toar/makefile /^FFLAGS =$/;" m FFLAGS src/pep/impls/linear/makefile /^FFLAGS =$/;" m FFLAGS src/pep/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/pep/interface/makefile /^FFLAGS =$/;" m FFLAGS src/svd/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/svd/examples/tutorials/makefile /^FFLAGS =$/;" m FFLAGS src/svd/f90-mod/makefile /^FFLAGS =$/;" m FFLAGS src/svd/impls/cross/makefile /^FFLAGS =$/;" m FFLAGS src/svd/impls/cyclic/makefile /^FFLAGS =$/;" m FFLAGS src/svd/impls/lanczos/makefile /^FFLAGS =$/;" m FFLAGS src/svd/impls/lapack/makefile /^FFLAGS =$/;" m FFLAGS src/svd/impls/trlanczos/makefile /^FFLAGS =$/;" m FFLAGS src/svd/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/svd/interface/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/bv/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/bv/impls/contiguous/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/bv/impls/mat/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/bv/impls/svec/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/bv/impls/vecs/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/bv/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/bv/interface/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/ghep/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/ghiep/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/gnhep/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/hep/bdc/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/hep/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/nep/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/nhep/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/pep/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/impls/svd/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/ds/interface/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/combine/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/exp/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/invsqrt/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/log/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/phi/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/rational/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/impls/sqrt/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/fn/interface/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/rg/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/rg/impls/ellipse/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/rg/impls/interval/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/rg/impls/polygon/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/rg/impls/ring/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/rg/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/rg/interface/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/examples/tests/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/impls/cayley/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/impls/precond/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/impls/shell/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/impls/shell/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/impls/shift/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/impls/sinvert/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/interface/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/sys/classes/st/interface/makefile /^FFLAGS =$/;" m FFLAGS src/sys/f90-mod/makefile /^FFLAGS =$/;" m FFLAGS src/sys/ftn-custom/makefile /^FFLAGS =$/;" m FFLAGS src/sys/makefile /^FFLAGS =$/;" m FFLAGS src/sys/vec/makefile /^FFLAGS =$/;" m FN include/slepc/finclude/slepcfndef.h 27;" d FN include/slepcfn.h /^typedef struct _p_FN* FN;$/;" t typeref:struct:_p_FN FNAppendOptionsPrefix src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNAppendOptionsPrefix(FN fn,const char *prefix)$/;" f FNCOMBINE include/slepc/finclude/slepcfndef.h 33;" d FNCOMBINE include/slepcfn.h 44;" d FNCombineGetChildren src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNCombineGetChildren(FN fn,FNCombineType *comb,FN *f1,FN *f2)$/;" f FNCombineGetChildren_Combine src/sys/classes/fn/impls/combine/fncombine.c /^static PetscErrorCode FNCombineGetChildren_Combine(FN fn,FNCombineType *comb,FN *f1,FN *f2)$/;" f file: FNCombineSetChildren src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNCombineSetChildren(FN fn,FNCombineType comb,FN f1,FN f2)$/;" f FNCombineSetChildren_Combine src/sys/classes/fn/impls/combine/fncombine.c /^static PetscErrorCode FNCombineSetChildren_Combine(FN fn,FNCombineType comb,FN f1,FN f2)$/;" f file: FNCombineType include/slepc/finclude/slepcfndef.h 31;" d FNCombineType include/slepcfn.h /^ FN_COMBINE_COMPOSE } FNCombineType;$/;" t typeref:enum:__anon28 FNCreate src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNCreate(MPI_Comm comm,FN *newfn)$/;" f FNCreate_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PETSC_EXTERN PetscErrorCode FNCreate_Combine(FN fn)$/;" f FNCreate_Exp src/sys/classes/fn/impls/exp/fnexp.c /^PETSC_EXTERN PetscErrorCode FNCreate_Exp(FN fn)$/;" f FNCreate_Invsqrt src/sys/classes/fn/impls/invsqrt/fninvsqrt.c /^PETSC_EXTERN PetscErrorCode FNCreate_Invsqrt(FN fn)$/;" f FNCreate_Log src/sys/classes/fn/impls/log/fnlog.c /^PETSC_EXTERN PetscErrorCode FNCreate_Log(FN fn)$/;" f FNCreate_Phi src/sys/classes/fn/impls/phi/fnphi.c /^PETSC_EXTERN PetscErrorCode FNCreate_Phi(FN fn)$/;" f FNCreate_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PETSC_EXTERN PetscErrorCode FNCreate_Rational(FN fn)$/;" f FNCreate_Sqrt src/sys/classes/fn/impls/sqrt/fnsqrt.c /^PETSC_EXTERN PetscErrorCode FNCreate_Sqrt(FN fn)$/;" f FNDestroy src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNDestroy(FN *fn)$/;" f FNDestroy_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNDestroy_Combine(FN fn)$/;" f FNDestroy_Phi src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNDestroy_Phi(FN fn)$/;" f FNDestroy_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNDestroy_Rational(FN fn)$/;" f FNDuplicate src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNDuplicate(FN fn,MPI_Comm comm,FN *newfn)$/;" f FNDuplicate_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNDuplicate_Combine(FN fn,MPI_Comm comm,FN *newfn)$/;" f FNDuplicate_Phi src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNDuplicate_Phi(FN fn,MPI_Comm comm,FN *newfn)$/;" f FNDuplicate_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNDuplicate_Rational(FN fn,MPI_Comm comm,FN *newfn)$/;" f FNEXP include/slepc/finclude/slepcfndef.h 35;" d FNEXP include/slepcfn.h 46;" d FNEvaluateDerivative src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNEvaluateDerivative(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateDerivative_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNEvaluateDerivative_Combine(FN fn,PetscScalar x,PetscScalar *yp)$/;" f FNEvaluateDerivative_Exp src/sys/classes/fn/impls/exp/fnexp.c /^PetscErrorCode FNEvaluateDerivative_Exp(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateDerivative_Invsqrt src/sys/classes/fn/impls/invsqrt/fninvsqrt.c /^PetscErrorCode FNEvaluateDerivative_Invsqrt(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateDerivative_Log src/sys/classes/fn/impls/log/fnlog.c /^PetscErrorCode FNEvaluateDerivative_Log(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateDerivative_Phi src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNEvaluateDerivative_Phi(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateDerivative_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNEvaluateDerivative_Rational(FN fn,PetscScalar x,PetscScalar *yp)$/;" f FNEvaluateDerivative_Sqrt src/sys/classes/fn/impls/sqrt/fnsqrt.c /^PetscErrorCode FNEvaluateDerivative_Sqrt(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunction src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNEvaluateFunction(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunctionMat src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNEvaluateFunctionMat(FN fn,Mat A,Mat B)$/;" f FNEvaluateFunctionMatVec src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNEvaluateFunctionMatVec(FN fn,Mat A,Vec v)$/;" f FNEvaluateFunctionMatVec_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNEvaluateFunctionMatVec_Combine(FN fn,Mat A,Vec v)$/;" f FNEvaluateFunctionMatVec_Default src/sys/classes/fn/interface/fnbasic.c /^static PetscErrorCode FNEvaluateFunctionMatVec_Default(FN fn,Mat A,Vec v)$/;" f file: FNEvaluateFunctionMatVec_Invsqrt src/sys/classes/fn/impls/invsqrt/fninvsqrt.c /^PetscErrorCode FNEvaluateFunctionMatVec_Invsqrt(FN fn,Mat A,Vec v)$/;" f FNEvaluateFunctionMatVec_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNEvaluateFunctionMatVec_Rational(FN fn,Mat A,Vec v)$/;" f FNEvaluateFunctionMatVec_Sqrt src/sys/classes/fn/impls/sqrt/fnsqrt.c /^PetscErrorCode FNEvaluateFunctionMatVec_Sqrt(FN fn,Mat A,Vec v)$/;" f FNEvaluateFunctionMatVec_Sym_Default src/sys/classes/fn/interface/fnbasic.c /^static PetscErrorCode FNEvaluateFunctionMatVec_Sym_Default(FN fn,Mat A,Vec v)$/;" f file: FNEvaluateFunctionMat_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNEvaluateFunctionMat_Combine(FN fn,Mat A,Mat B)$/;" f FNEvaluateFunctionMat_Exp src/sys/classes/fn/impls/exp/fnexp.c /^PetscErrorCode FNEvaluateFunctionMat_Exp(FN fn,Mat A,Mat B)$/;" f FNEvaluateFunctionMat_Invsqrt src/sys/classes/fn/impls/invsqrt/fninvsqrt.c /^PetscErrorCode FNEvaluateFunctionMat_Invsqrt(FN fn,Mat A,Mat B)$/;" f FNEvaluateFunctionMat_Private src/sys/classes/fn/impls/rational/fnrational.c /^static PetscErrorCode FNEvaluateFunctionMat_Private(FN fn,PetscScalar *Aa,PetscScalar *Ba,PetscInt m,PetscBool firstonly)$/;" f file: FNEvaluateFunctionMat_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNEvaluateFunctionMat_Rational(FN fn,Mat A,Mat B)$/;" f FNEvaluateFunctionMat_Sqrt src/sys/classes/fn/impls/sqrt/fnsqrt.c /^PetscErrorCode FNEvaluateFunctionMat_Sqrt(FN fn,Mat A,Mat B)$/;" f FNEvaluateFunctionMat_Sym_Default src/sys/classes/fn/interface/fnbasic.c /^static PetscErrorCode FNEvaluateFunctionMat_Sym_Default(FN fn,Mat A,Mat B)$/;" f file: FNEvaluateFunctionMat_Sym_Private src/sys/classes/fn/interface/fnbasic.c /^static PetscErrorCode FNEvaluateFunctionMat_Sym_Private(FN fn,PetscScalar *As,PetscScalar *Bs,PetscInt m,PetscBool firstonly)$/;" f file: FNEvaluateFunction_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNEvaluateFunction_Combine(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunction_Exp src/sys/classes/fn/impls/exp/fnexp.c /^PetscErrorCode FNEvaluateFunction_Exp(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunction_Invsqrt src/sys/classes/fn/impls/invsqrt/fninvsqrt.c /^PetscErrorCode FNEvaluateFunction_Invsqrt(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunction_Log src/sys/classes/fn/impls/log/fnlog.c /^PetscErrorCode FNEvaluateFunction_Log(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunction_Phi src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNEvaluateFunction_Phi(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunction_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNEvaluateFunction_Rational(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNEvaluateFunction_Sqrt src/sys/classes/fn/impls/sqrt/fnsqrt.c /^PetscErrorCode FNEvaluateFunction_Sqrt(FN fn,PetscScalar x,PetscScalar *y)$/;" f FNFinalizePackage src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNFinalizePackage(void)$/;" f FNGetOptionsPrefix src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNGetOptionsPrefix(FN fn,const char *prefix[])$/;" f FNGetScale src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNGetScale(FN fn,PetscScalar *alpha,PetscScalar *beta)$/;" f FNGetType src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNGetType(FN fn,FNType *type)$/;" f FNINVSQRT include/slepc/finclude/slepcfndef.h 39;" d FNINVSQRT include/slepcfn.h 50;" d FNInitializePackage src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNInitializePackage(void)$/;" f FNLOG include/slepc/finclude/slepcfndef.h 36;" d FNLOG include/slepcfn.h 47;" d FNList include/slepcfn.h /^PETSC_EXTERN PetscFunctionList FNList;$/;" v FNList src/sys/classes/fn/interface/fnbasic.c /^PetscFunctionList FNList = 0;$/;" v FNOps include/slepc/private/fnimpl.h /^typedef struct _FNOps *FNOps;$/;" t typeref:struct:_FNOps FNPHI include/slepc/finclude/slepcfndef.h 37;" d FNPHI include/slepcfn.h 48;" d FNPackageInitialized src/sys/classes/fn/interface/fnbasic.c /^static PetscBool FNPackageInitialized = PETSC_FALSE;$/;" v file: FNPhiGetIndex src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNPhiGetIndex(FN fn,PetscInt *k)$/;" f FNPhiGetIndex_Phi src/sys/classes/fn/impls/phi/fnphi.c /^static PetscErrorCode FNPhiGetIndex_Phi(FN fn,PetscInt *k)$/;" f file: FNPhiSetIndex src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNPhiSetIndex(FN fn,PetscInt k)$/;" f FNPhiSetIndex_Phi src/sys/classes/fn/impls/phi/fnphi.c /^static PetscErrorCode FNPhiSetIndex_Phi(FN fn,PetscInt k)$/;" f file: FNRATIONAL include/slepc/finclude/slepcfndef.h 34;" d FNRATIONAL include/slepcfn.h 45;" d FNRationalGetDenominator src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNRationalGetDenominator(FN fn,PetscInt *nq,PetscScalar *qcoeff[])$/;" f FNRationalGetDenominator_Rational src/sys/classes/fn/impls/rational/fnrational.c /^static PetscErrorCode FNRationalGetDenominator_Rational(FN fn,PetscInt *nq,PetscScalar *qcoeff[])$/;" f file: FNRationalGetNumerator src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNRationalGetNumerator(FN fn,PetscInt *np,PetscScalar *pcoeff[])$/;" f FNRationalGetNumerator_Rational src/sys/classes/fn/impls/rational/fnrational.c /^static PetscErrorCode FNRationalGetNumerator_Rational(FN fn,PetscInt *np,PetscScalar *pcoeff[])$/;" f file: FNRationalSetDenominator src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNRationalSetDenominator(FN fn,PetscInt nq,PetscScalar *qcoeff)$/;" f FNRationalSetDenominator_Rational src/sys/classes/fn/impls/rational/fnrational.c /^static PetscErrorCode FNRationalSetDenominator_Rational(FN fn,PetscInt nq,PetscScalar *qcoeff)$/;" f file: FNRationalSetNumerator src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNRationalSetNumerator(FN fn,PetscInt np,PetscScalar *pcoeff)$/;" f FNRationalSetNumerator_Rational src/sys/classes/fn/impls/rational/fnrational.c /^static PetscErrorCode FNRationalSetNumerator_Rational(FN fn,PetscInt np,PetscScalar *pcoeff)$/;" f file: FNRegister src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNRegister(const char *name,PetscErrorCode (*function)(FN))$/;" f FNRegisterAll src/sys/classes/fn/interface/fnregis.c /^PetscErrorCode FNRegisterAll(void)$/;" f FNRegisterAllCalled include/slepc/private/fnimpl.h /^PETSC_EXTERN PetscBool FNRegisterAllCalled;$/;" v FNRegisterAllCalled src/sys/classes/fn/interface/fnbasic.c /^PetscBool FNRegisterAllCalled = PETSC_FALSE;$/;" v FNSQRT include/slepc/finclude/slepcfndef.h 38;" d FNSQRT include/slepcfn.h 49;" d FNSetFromOptions src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNSetFromOptions(FN fn)$/;" f FNSetFromOptions_Phi src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNSetFromOptions_Phi(PetscOptionItems *PetscOptionsObject,FN fn)$/;" f FNSetFromOptions_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNSetFromOptions_Rational(PetscOptionItems *PetscOptionsObject,FN fn)$/;" f FNSetOptionsPrefix src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNSetOptionsPrefix(FN fn,const char *prefix)$/;" f FNSetScale src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNSetScale(FN fn,PetscScalar alpha,PetscScalar beta)$/;" f FNSetType src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNSetType(FN fn,FNType type)$/;" f FNType include/slepc/finclude/slepcfndef.h 30;" d FNType include/slepcfn.h /^typedef const char* FNType;$/;" t FNView src/sys/classes/fn/interface/fnbasic.c /^PetscErrorCode FNView(FN fn,PetscViewer viewer)$/;" f FNView_Combine src/sys/classes/fn/impls/combine/fncombine.c /^PetscErrorCode FNView_Combine(FN fn,PetscViewer viewer)$/;" f FNView_Exp src/sys/classes/fn/impls/exp/fnexp.c /^PetscErrorCode FNView_Exp(FN fn,PetscViewer viewer)$/;" f FNView_Invsqrt src/sys/classes/fn/impls/invsqrt/fninvsqrt.c /^PetscErrorCode FNView_Invsqrt(FN fn,PetscViewer viewer)$/;" f FNView_Log src/sys/classes/fn/impls/log/fnlog.c /^PetscErrorCode FNView_Log(FN fn,PetscViewer viewer)$/;" f FNView_Phi src/sys/classes/fn/impls/phi/fnphi.c /^PetscErrorCode FNView_Phi(FN fn,PetscViewer viewer)$/;" f FNView_Rational src/sys/classes/fn/impls/rational/fnrational.c /^PetscErrorCode FNView_Rational(FN fn,PetscViewer viewer)$/;" f FNView_Sqrt src/sys/classes/fn/impls/sqrt/fnsqrt.c /^PetscErrorCode FNView_Sqrt(FN fn,PetscViewer viewer)$/;" f FN_AllocateWorkMat include/slepc/private/fnimpl.h /^PETSC_STATIC_INLINE PetscErrorCode FN_AllocateWorkMat(FN fn,Mat A,Mat *M)$/;" f FN_CLASSID include/slepcfn.h /^PETSC_EXTERN PetscClassId FN_CLASSID;$/;" v FN_CLASSID src/sys/classes/fn/interface/fnbasic.c /^PetscClassId FN_CLASSID = 0;$/;" v FN_COMBINE src/sys/classes/fn/impls/combine/fncombine.c /^} FN_COMBINE;$/;" t typeref:struct:__anon121 file: FN_COMBINE_ADD include/slepcfn.h /^typedef enum { FN_COMBINE_ADD,$/;" e enum:__anon28 FN_COMBINE_COMPOSE include/slepcfn.h /^ FN_COMBINE_COMPOSE } FNCombineType;$/;" e enum:__anon28 FN_COMBINE_DIVIDE include/slepcfn.h /^ FN_COMBINE_DIVIDE,$/;" e enum:__anon28 FN_COMBINE_MULTIPLY include/slepcfn.h /^ FN_COMBINE_MULTIPLY,$/;" e enum:__anon28 FN_Evaluate include/slepc/private/fnimpl.h /^PETSC_EXTERN PetscLogEvent FN_Evaluate;$/;" v FN_Evaluate src/sys/classes/fn/interface/fnbasic.c /^PetscLogEvent FN_Evaluate = 0;$/;" v FN_FreeWorkMat include/slepc/private/fnimpl.h /^PETSC_STATIC_INLINE PetscErrorCode FN_FreeWorkMat(FN fn,Mat *M)$/;" f FN_MAX_W include/slepc/private/fnimpl.h 47;" d FN_PHI src/sys/classes/fn/impls/phi/fnphi.c /^} FN_PHI;$/;" t typeref:struct:__anon122 file: FN_RATIONAL src/sys/classes/fn/impls/rational/fnrational.c /^} FN_RATIONAL;$/;" t typeref:struct:__anon123 file: FPPFLAGS src/eps/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/eps/examples/tutorials/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/mfn/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/mfn/examples/tutorials/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/nep/examples/nlevp/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/nep/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/nep/examples/tutorials/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/pep/examples/nlevp/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/pep/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/pep/examples/tutorials/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/svd/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/svd/examples/tutorials/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/sys/classes/bv/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/sys/classes/ds/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/sys/classes/fn/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/sys/classes/rg/examples/tests/makefile /^FPPFLAGS =$/;" m FPPFLAGS src/sys/classes/st/examples/tests/makefile /^FPPFLAGS =$/;" m FSubctx src/nep/interface/neprefine.c /^} FSubctx;$/;" t typeref:struct:__anon98 file: FSubctx src/pep/impls/krylov/toar/nrefine.c /^} FSubctx;$/;" t typeref:struct:__anon104 file: FSubctx src/pep/interface/peprefine.c /^} FSubctx;$/;" t typeref:struct:__anon109 file: Feast config/packages/feast.py /^class Feast(package.Package):$/;" c FillMatrix src/eps/examples/tutorials/ex19.c /^PetscErrorCode FillMatrix(DM da,Mat A)$/;" f FillUpMatrix src/sys/classes/ds/examples/tests/test14f.F /^ subroutine FillUpMatrix(/;" s FindSource bin/maint/generatefortranstubs.py /^def FindSource(filename):$/;" f FixDir bin/maint/generatefortranstubs.py /^def FixDir(petscdir,dir,verbose):$/;" f FixFile bin/maint/generatefortranstubs.py /^def FixFile(filename):$/;" f FixSign src/nep/examples/tutorials/ex20.c /^PetscErrorCode FixSign(Vec x)$/;" f FormFunction src/nep/examples/tutorials/ex20.c /^PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)$/;" f FormFunction src/nep/examples/tutorials/ex21.c /^PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)$/;" f FormFunction src/nep/examples/tutorials/ex27.c /^PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)$/;" f FormInitialGuess src/nep/examples/tutorials/ex20.c /^PetscErrorCode FormInitialGuess(Vec x)$/;" f FormInitialGuess src/nep/examples/tutorials/ex21.c /^PetscErrorCode FormInitialGuess(Vec x)$/;" f FormJacobian src/nep/examples/tutorials/ex20.c /^PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx)$/;" f FormJacobian src/nep/examples/tutorials/ex21.c /^PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx)$/;" f FortranLib config/package.py /^ def FortranLib(self,conf,vars,cmake,dirs,libs,functions,callbacks = []):$/;" m class:Package FortranLink config/package.py /^ def FortranLink(self,functions,callbacks,flags):$/;" m class:Package Functions config/packages/arpack.py /^ def Functions(self,petsc):$/;" m class:Arpack G src/eps/impls/cg/rqcg/rqcg.c /^ BV AV,W,P,G;$/;" m struct:__anon60 file: G src/eps/impls/davidson/davidson.h /^ Mat H,G; \/* projected problem matrices *\/$/;" m struct:_dvdDashboard GenerateGuesses config/package.py /^ def GenerateGuesses(self,name):$/;" m class:Package GetExactEigenvalues src/eps/examples/tutorials/ex19.c /^PetscErrorCode GetExactEigenvalues(PetscInt M,PetscInt N,PetscInt P,PetscInt nconv,PetscReal *exact)$/;" f GetNorm2 src/sys/vec/veccomp.c /^PETSC_STATIC_INLINE PetscReal GetNorm2(PetscReal ssq,PetscReal scale)$/;" f H src/eps/examples/tutorials/ex31.c /^const PetscScalar H[3] = {23.64,6.4,3.01}; \/* Inertia constant *\/$/;" v H src/eps/impls/davidson/davidson.h /^ Mat H,G; \/* projected problem matrices *\/$/;" m struct:_dvdDashboard HERM src/eps/interface/epsview.c 70;" d file: HERM src/pep/interface/pepview.c 72;" d file: HRApply src/sys/classes/ds/impls/ghiep/invit.c /^static PetscErrorCode HRApply(PetscInt n,PetscScalar *x1,PetscInt inc1,PetscScalar *x2,PetscInt inc2,PetscReal c,PetscReal s)$/;" f file: HRGen src/sys/classes/ds/impls/ghiep/invit.c /^static PetscErrorCode HRGen(PetscReal x1,PetscReal x2,PetscInt *type,PetscReal *c,PetscReal *s,PetscReal *r,PetscReal *cond)$/;" f file: HRtr src/sys/classes/ds/impls/ghiep/invit.c /^struct HRtr$/;" s file: HZIteration src/sys/classes/ds/impls/ghiep/hz.c /^static PetscErrorCode HZIteration(PetscBLASInt nn,PetscBLASInt cgd,PetscReal *aa,PetscReal *bb,PetscReal *dd,PetscScalar *uu,PetscBLASInt ld)$/;" f file: HZStep src/sys/classes/ds/impls/ghiep/hz.c /^static PetscErrorCode HZStep(PetscBLASInt ntop,PetscBLASInt nn,PetscReal tr,PetscReal dt,PetscReal *aa,PetscReal *bb,PetscReal *dd,PetscScalar *uu,PetscInt n,PetscInt ld,PetscBool *flag)$/;" f file: HarmType_t src/eps/impls/davidson/davidson.h /^} HarmType_t;$/;" t typeref:enum:__anon62 IS include/slepc/private/epsimpl.h /^ Vec *IS; \/* references to user-provided initial space *\/$/;" m struct:_p_EPS IS include/slepc/private/nepimpl.h /^ Vec *IS; \/* references to user-provided initial space *\/$/;" m struct:_p_NEP IS include/slepc/private/pepimpl.h /^ Vec *IS; \/* references to user-provided initial space *\/$/;" m struct:_p_PEP IS include/slepc/private/svdimpl.h /^ Vec *IS,*ISL; \/* placeholder for references to user initial space *\/$/;" m struct:_p_SVD ISL include/slepc/private/svdimpl.h /^ Vec *IS,*ISL; \/* placeholder for references to user initial space *\/$/;" m struct:_p_SVD InitDir config/packages/petsc.py /^ def InitDir(self,prefixdir):$/;" m class:PETSc InitDir config/packages/slepc.py /^ def InitDir(self):$/;" m class:SLEPc InitType_t src/eps/impls/davidson/davidson.h /^} InitType_t;$/;" t typeref:enum:__anon63 Install config/packages/arpack.py /^ def Install(self,conf,vars,cmake,petsc,archdir):$/;" m class:Arpack Install config/packages/blopex.py /^ def Install(self,conf,vars,cmake,petsc,archdir):$/;" m class:Blopex Install config/packages/primme.py /^ def Install(self,conf,vars,cmake,petsc,archdir):$/;" m class:Primme Install config/packages/sowing.py /^ def Install(self,archdir,make):$/;" m class:Sowing Install config/packages/trlan.py /^ def Install(self,conf,vars,cmake,petsc,archdir):$/;" m class:Trlan Installer config/install.py /^class Installer:$/;" c K src/pep/examples/tutorials/ex16f90.F90 /^ type(Mat) M, C, K,/;" v program:main K src/pep/impls/linear/linearp.h /^ Mat M,C,K; \/* copy of PEP coefficient matrices *\/$/;" m struct:__anon106 KA src/eps/examples/tutorials/ex31.c /^const PetscScalar KA[3] = {20.0,20.0,20.0}; \/* Voltage regulartor gain constant *\/$/;" v KE src/eps/examples/tutorials/ex31.c /^const PetscScalar KE[3] = {1.0,1.0,1.0}; \/* Exciter gain constant *\/$/;" v KF src/eps/examples/tutorials/ex31.c /^const PetscScalar KF[3] = {0.063,0.063,0.063}; \/* Feedback stabilizer gain constant *\/$/;" v KZ src/eps/impls/davidson/dvdimprovex.c /^ BV KZ; \/* KZ vecs for the projector KZ*inv(X'*KZ)*X' *\/$/;" m struct:__anon68 file: L src/eps/impls/ciss/ciss.c /^ PetscInt L; \/* block size (16) *\/$/;" m struct:__anon61 file: L src/nep/impls/ciss/nciss.c /^ PetscInt L; \/* block size (16) *\/$/;" m struct:__anon89 file: LANGS config/gmakegen.py /^LANGS = dict(c='C', cxx='CXX', cu='CU', F='F')$/;" v LAPACKbdsdc_ include/slepcblaslapack.h 162;" d LAPACKbdsdc_ include/slepcblaslapack.h 218;" d LAPACKgees_ include/slepcblaslapack.h 176;" d LAPACKgees_ include/slepcblaslapack.h 192;" d LAPACKgees_ include/slepcblaslapack.h 232;" d LAPACKgees_ include/slepcblaslapack.h 248;" d LAPACKgeevx_ include/slepcblaslapack.h 175;" d LAPACKgeevx_ include/slepcblaslapack.h 191;" d LAPACKgeevx_ include/slepcblaslapack.h 231;" d LAPACKgeevx_ include/slepcblaslapack.h 247;" d LAPACKgehrd_ include/slepcblaslapack.h 112;" d LAPACKgelqf_ include/slepcblaslapack.h 113;" d LAPACKgeqp3_ include/slepcblaslapack.h 114;" d LAPACKgesdd_ include/slepcblaslapack.h 178;" d LAPACKgesdd_ include/slepcblaslapack.h 194;" d LAPACKgesdd_ include/slepcblaslapack.h 234;" d LAPACKgesdd_ include/slepcblaslapack.h 250;" d LAPACKggev_ include/slepcblaslapack.h 150;" d LAPACKggev_ include/slepcblaslapack.h 206;" d LAPACKggevx_ include/slepcblaslapack.h 149;" d LAPACKggevx_ include/slepcblaslapack.h 205;" d LAPACKhsein_ include/slepcblaslapack.h 180;" d LAPACKhsein_ include/slepcblaslapack.h 196;" d LAPACKhsein_ include/slepcblaslapack.h 236;" d LAPACKhsein_ include/slepcblaslapack.h 252;" d LAPACKlacpy_ include/slepcblaslapack.h 154;" d LAPACKlacpy_ include/slepcblaslapack.h 210;" d LAPACKlaed4_ include/slepcblaslapack.h 121;" d LAPACKlaev2_ include/slepcblaslapack.h 111;" d LAPACKlag2_ include/slepcblaslapack.h 117;" d LAPACKlaln2_ include/slepcblaslapack.h 120;" d LAPACKlamc3_ include/slepcblaslapack.h 164;" d LAPACKlamc3_ include/slepcblaslapack.h 220;" d LAPACKlamch_ include/slepcblaslapack.h 163;" d LAPACKlamch_ include/slepcblaslapack.h 219;" d LAPACKlamrg_ include/slepcblaslapack.h 122;" d LAPACKlange_ include/slepcblaslapack.h 148;" d LAPACKlange_ include/slepcblaslapack.h 204;" d LAPACKlanhs_ include/slepcblaslapack.h 147;" d LAPACKlanhs_ include/slepcblaslapack.h 203;" d LAPACKlansy_ include/slepcblaslapack.h 156;" d LAPACKlansy_ include/slepcblaslapack.h 212;" d LAPACKlapy2_ include/slepcblaslapack.h 123;" d LAPACKlarf_ include/slepcblaslapack.h 152;" d LAPACKlarf_ include/slepcblaslapack.h 208;" d LAPACKlarfg_ include/slepcblaslapack.h 116;" d LAPACKlartg_ include/slepcblaslapack.h 119;" d LAPACKlascl_ include/slepcblaslapack.h 155;" d LAPACKlascl_ include/slepcblaslapack.h 211;" d LAPACKlaset_ include/slepcblaslapack.h 157;" d LAPACKlaset_ include/slepcblaslapack.h 213;" d LAPACKlasv2_ include/slepcblaslapack.h 118;" d LAPACKorghr_ include/slepcblaslapack.h 125;" d LAPACKorghr_ include/slepcblaslapack.h 127;" d LAPACKorgtr_ include/slepcblaslapack.h 172;" d LAPACKorgtr_ include/slepcblaslapack.h 188;" d LAPACKorgtr_ include/slepcblaslapack.h 228;" d LAPACKorgtr_ include/slepcblaslapack.h 244;" d LAPACKormlq_ include/slepcblaslapack.h 171;" d LAPACKormlq_ include/slepcblaslapack.h 187;" d LAPACKormlq_ include/slepcblaslapack.h 227;" d LAPACKormlq_ include/slepcblaslapack.h 243;" d LAPACKpbtrf_ include/slepcblaslapack.h 151;" d LAPACKpbtrf_ include/slepcblaslapack.h 207;" d LAPACKstedc_ include/slepcblaslapack.h 181;" d LAPACKstedc_ include/slepcblaslapack.h 197;" d LAPACKstedc_ include/slepcblaslapack.h 237;" d LAPACKstedc_ include/slepcblaslapack.h 253;" d LAPACKstevr_ include/slepcblaslapack.h 161;" d LAPACKstevr_ include/slepcblaslapack.h 217;" d LAPACKsyevd_ include/slepcblaslapack.h 169;" d LAPACKsyevd_ include/slepcblaslapack.h 185;" d LAPACKsyevd_ include/slepcblaslapack.h 225;" d LAPACKsyevd_ include/slepcblaslapack.h 241;" d LAPACKsyevr_ include/slepcblaslapack.h 168;" d LAPACKsyevr_ include/slepcblaslapack.h 184;" d LAPACKsyevr_ include/slepcblaslapack.h 224;" d LAPACKsyevr_ include/slepcblaslapack.h 240;" d LAPACKsygvd_ include/slepcblaslapack.h 170;" d LAPACKsygvd_ include/slepcblaslapack.h 186;" d LAPACKsygvd_ include/slepcblaslapack.h 226;" d LAPACKsygvd_ include/slepcblaslapack.h 242;" d LAPACKsytrd_ include/slepcblaslapack.h 173;" d LAPACKsytrd_ include/slepcblaslapack.h 189;" d LAPACKsytrd_ include/slepcblaslapack.h 229;" d LAPACKsytrd_ include/slepcblaslapack.h 245;" d LAPACKtgevc_ include/slepcblaslapack.h 179;" d LAPACKtgevc_ include/slepcblaslapack.h 195;" d LAPACKtgevc_ include/slepcblaslapack.h 235;" d LAPACKtgevc_ include/slepcblaslapack.h 251;" d LAPACKtgexc_ include/slepcblaslapack.h 115;" d LAPACKtrevc_ include/slepcblaslapack.h 174;" d LAPACKtrevc_ include/slepcblaslapack.h 190;" d LAPACKtrevc_ include/slepcblaslapack.h 230;" d LAPACKtrevc_ include/slepcblaslapack.h 246;" d LAPACKtrexc_ include/slepcblaslapack.h 177;" d LAPACKtrexc_ include/slepcblaslapack.h 193;" d LAPACKtrexc_ include/slepcblaslapack.h 233;" d LAPACKtrexc_ include/slepcblaslapack.h 249;" d LAPACKtrsyl_ include/slepcblaslapack.h 158;" d LAPACKtrsyl_ include/slepcblaslapack.h 214;" d LAPACKtrtri_ include/slepcblaslapack.h 159;" d LAPACKtrtri_ include/slepcblaslapack.h 215;" d LATEX docs/manual/makefile /^LATEX = pdflatex --shell-escape$/;" m LIBBASE docs/makefile /^LIBBASE =$/;" m LIBBASE include/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE include/slepc/finclude/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE include/slepc/private/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/eps/f90-mod/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/cg/lobpcg/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/cg/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/cg/rqcg/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/ciss/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/davidson/gd/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/davidson/jd/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/davidson/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/external/arpack/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/external/blopex/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/external/blzpack/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/external/feast/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/external/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/external/primme/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/external/trlan/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/krylov/arnoldi/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/krylov/krylovschur/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/krylov/lanczos/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/krylov/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/lapack/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/power/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/impls/subspace/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/interface/ftn-custom/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/eps/interface/makefile /^LIBBASE = libslepceps$/;" m LIBBASE src/mfn/f90-mod/makefile /^LIBBASE = libslepcmfn$/;" m LIBBASE src/mfn/impls/expokit/makefile /^LIBBASE = libslepcmfn$/;" m LIBBASE src/mfn/impls/krylov/makefile /^LIBBASE = libslepcmfn$/;" m LIBBASE src/mfn/impls/makefile /^LIBBASE = libslepcmfn$/;" m LIBBASE src/mfn/interface/ftn-custom/makefile /^LIBBASE = libslepcmfn$/;" m LIBBASE src/mfn/interface/makefile /^LIBBASE = libslepcmfn$/;" m LIBBASE src/nep/f90-mod/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/impls/ciss/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/impls/interpol/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/impls/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/impls/narnoldi/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/impls/nleigs/makefile /^LIBBASE = libslepc$/;" m LIBBASE src/nep/impls/rii/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/impls/slp/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/interface/ftn-custom/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/nep/interface/makefile /^LIBBASE = libslepcnep$/;" m LIBBASE src/pep/f90-mod/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/impls/jd/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/impls/krylov/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/impls/krylov/qarnoldi/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/impls/krylov/stoar/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/impls/krylov/toar/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/impls/linear/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/impls/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/interface/ftn-custom/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/pep/interface/makefile /^LIBBASE = libslepcpep$/;" m LIBBASE src/svd/f90-mod/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/impls/cross/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/impls/cyclic/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/impls/lanczos/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/impls/lapack/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/impls/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/impls/trlanczos/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/interface/ftn-custom/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/svd/interface/makefile /^LIBBASE = libslepcsvd$/;" m LIBBASE src/sys/classes/bv/impls/contiguous/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/bv/impls/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/bv/impls/mat/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/bv/impls/svec/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/bv/impls/vecs/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/bv/interface/ftn-custom/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/bv/interface/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/ghep/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/ghiep/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/gnhep/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/hep/bdc/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/hep/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/nep/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/nhep/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/pep/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/impls/svd/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/interface/ftn-custom/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/ds/interface/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/combine/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/exp/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/invsqrt/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/log/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/phi/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/rational/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/impls/sqrt/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/interface/ftn-custom/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/fn/interface/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/rg/impls/ellipse/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/rg/impls/interval/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/rg/impls/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/rg/impls/polygon/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/rg/impls/ring/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/rg/interface/ftn-custom/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/rg/interface/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/impls/cayley/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/impls/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/impls/precond/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/impls/shell/ftn-custom/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/impls/shell/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/impls/shift/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/impls/sinvert/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/interface/ftn-custom/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/classes/st/interface/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/f90-mod/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/ftn-custom/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/makefile /^LIBBASE = libslepcsys$/;" m LIBBASE src/sys/vec/makefile /^LIBBASE = libslepcsys$/;" m LINCLUDE docs/makefile /^LINCLUDE = ${SOURCEH}$/;" m LOBPCG_DestroyRandomContext src/eps/impls/external/blopex/petsc-interface.c /^int LOBPCG_DestroyRandomContext(void)$/;" f LOBPCG_InitRandomContext src/eps/impls/external/blopex/petsc-interface.c /^int LOBPCG_InitRandomContext(MPI_Comm comm,PetscRandom rand)$/;" f LOBPCG_RandomContext src/eps/impls/external/blopex/petsc-interface.c /^static PetscRandom LOBPCG_RandomContext = NULL;$/;" v file: LOBPCG_SetFromOptionsRandomContext src/eps/impls/external/blopex/petsc-interface.c /^int LOBPCG_SetFromOptionsRandomContext(void)$/;" f LOCDIR docs/makefile /^LOCDIR = docs\/$/;" m LOCDIR docs/manual/makefile /^LOCDIR = docs\/manual\/$/;" m LOCDIR include/makefile /^LOCDIR = include\/$/;" m LOCDIR include/slepc/finclude/ftn-custom/makefile /^LOCDIR = include\/slepc\/finclude\/ftn-custom\/$/;" m LOCDIR include/slepc/finclude/makefile /^LOCDIR = include\/slepc\/finclude\/$/;" m LOCDIR include/slepc/private/makefile /^LOCDIR = include\/slepc\/private\/$/;" m LOCDIR makefile /^LOCDIR = .$/;" m LOCDIR src/eps/examples/makefile /^LOCDIR = src\/eps\/examples\/$/;" m LOCDIR src/eps/examples/tests/makefile /^LOCDIR = src\/eps\/examples\/tests\/$/;" m LOCDIR src/eps/examples/tutorials/makefile /^LOCDIR = src\/eps\/examples\/tutorials\/$/;" m LOCDIR src/eps/f90-mod/makefile /^LOCDIR = src\/eps\/f90-mod\/$/;" m LOCDIR src/eps/impls/cg/lobpcg/makefile /^LOCDIR = src\/eps\/impls\/cg\/lobpcg\/$/;" m LOCDIR src/eps/impls/cg/makefile /^LOCDIR = src\/eps\/impls\/cg\/$/;" m LOCDIR src/eps/impls/cg/rqcg/makefile /^LOCDIR = src\/eps\/impls\/cg\/rqcg\/$/;" m LOCDIR src/eps/impls/ciss/makefile /^LOCDIR = src\/eps\/impls\/ciss\/$/;" m LOCDIR src/eps/impls/davidson/gd/makefile /^LOCDIR = src\/eps\/impls\/davidson\/gd\/$/;" m LOCDIR src/eps/impls/davidson/jd/makefile /^LOCDIR = src\/eps\/impls\/davidson\/jd\/$/;" m LOCDIR src/eps/impls/davidson/makefile /^LOCDIR = src\/eps\/impls\/davidson\/$/;" m LOCDIR src/eps/impls/external/arpack/makefile /^LOCDIR = src\/eps\/impls\/external\/arpack\/$/;" m LOCDIR src/eps/impls/external/blopex/makefile /^LOCDIR = src\/eps\/impls\/external\/blopex\/$/;" m LOCDIR src/eps/impls/external/blzpack/makefile /^LOCDIR = src\/eps\/impls\/external\/blzpack\/$/;" m LOCDIR src/eps/impls/external/feast/makefile /^LOCDIR = src\/eps\/impls\/external\/feast\/$/;" m LOCDIR src/eps/impls/external/makefile /^LOCDIR = src\/eps\/impls\/external\/$/;" m LOCDIR src/eps/impls/external/primme/makefile /^LOCDIR = src\/eps\/impls\/external\/primme\/$/;" m LOCDIR src/eps/impls/external/trlan/makefile /^LOCDIR = src\/eps\/impls\/external\/trlan\/$/;" m LOCDIR src/eps/impls/krylov/arnoldi/makefile /^LOCDIR = src\/eps\/impls\/krylov\/arnoldi\/$/;" m LOCDIR src/eps/impls/krylov/krylovschur/makefile /^LOCDIR = src\/eps\/impls\/krylov\/krylovschur\/$/;" m LOCDIR src/eps/impls/krylov/lanczos/makefile /^LOCDIR = src\/eps\/impls\/krylov\/lanczos\/$/;" m LOCDIR src/eps/impls/krylov/makefile /^LOCDIR = src\/eps\/impls\/krylov\/$/;" m LOCDIR src/eps/impls/lapack/makefile /^LOCDIR = src\/eps\/impls\/lapack\/$/;" m LOCDIR src/eps/impls/makefile /^LOCDIR = src\/eps\/impls\/$/;" m LOCDIR src/eps/impls/power/makefile /^LOCDIR = src\/eps\/impls\/power\/$/;" m LOCDIR src/eps/impls/subspace/makefile /^LOCDIR = src\/eps\/impls\/subspace\/$/;" m LOCDIR src/eps/interface/ftn-custom/makefile /^LOCDIR = src\/eps\/interface\/ftn-custom\/$/;" m LOCDIR src/eps/interface/makefile /^LOCDIR = src\/eps\/interface\/$/;" m LOCDIR src/eps/makefile /^LOCDIR = src\/eps\/$/;" m LOCDIR src/makefile /^LOCDIR = src\/$/;" m LOCDIR src/mfn/examples/makefile /^LOCDIR = src\/mfn\/examples\/$/;" m LOCDIR src/mfn/examples/tests/makefile /^LOCDIR = src\/mfn\/examples\/tests\/$/;" m LOCDIR src/mfn/examples/tutorials/makefile /^LOCDIR = src\/mfn\/examples\/tutorials\/$/;" m LOCDIR src/mfn/f90-mod/makefile /^LOCDIR = src\/mfn\/f90-mod\/$/;" m LOCDIR src/mfn/impls/expokit/makefile /^LOCDIR = src\/mfn\/impls\/expokit\/$/;" m LOCDIR src/mfn/impls/krylov/makefile /^LOCDIR = src\/mfn\/impls\/krylov\/$/;" m LOCDIR src/mfn/impls/makefile /^LOCDIR = src\/mfn\/impls\/$/;" m LOCDIR src/mfn/interface/ftn-custom/makefile /^LOCDIR = src\/mfn\/interface\/ftn-custom\/$/;" m LOCDIR src/mfn/interface/makefile /^LOCDIR = src\/mfn\/interface\/$/;" m LOCDIR src/mfn/makefile /^LOCDIR = src\/mfn\/$/;" m LOCDIR src/nep/examples/makefile /^LOCDIR = src\/nep\/examples\/$/;" m LOCDIR src/nep/examples/nlevp/makefile /^LOCDIR = src\/nep\/examples\/nlevp\/$/;" m LOCDIR src/nep/examples/tests/makefile /^LOCDIR = src\/nep\/examples\/tests\/$/;" m LOCDIR src/nep/examples/tutorials/makefile /^LOCDIR = src\/nep\/examples\/tutorials\/$/;" m LOCDIR src/nep/f90-mod/makefile /^LOCDIR = src\/nep\/f90-mod\/$/;" m LOCDIR src/nep/impls/ciss/makefile /^LOCDIR = src\/nep\/impls\/ciss\/$/;" m LOCDIR src/nep/impls/interpol/makefile /^LOCDIR = src\/nep\/impls\/interpol\/$/;" m LOCDIR src/nep/impls/makefile /^LOCDIR = src\/nep\/impls\/$/;" m LOCDIR src/nep/impls/narnoldi/makefile /^LOCDIR = src\/nep\/impls\/narnoldi\/$/;" m LOCDIR src/nep/impls/nleigs/makefile /^LOCDIR = src\/nep\/impls\/nleigs\/$/;" m LOCDIR src/nep/impls/rii/makefile /^LOCDIR = src\/nep\/impls\/rii\/$/;" m LOCDIR src/nep/impls/slp/makefile /^LOCDIR = src\/nep\/impls\/slp\/$/;" m LOCDIR src/nep/interface/ftn-custom/makefile /^LOCDIR = src\/nep\/interface\/ftn-custom\/$/;" m LOCDIR src/nep/interface/makefile /^LOCDIR = src\/nep\/interface\/$/;" m LOCDIR src/nep/makefile /^LOCDIR = src\/nep\/$/;" m LOCDIR src/pep/examples/makefile /^LOCDIR = src\/pep\/examples\/$/;" m LOCDIR src/pep/examples/nlevp/makefile /^LOCDIR = src\/pep\/examples\/nlevp\/$/;" m LOCDIR src/pep/examples/tests/makefile /^LOCDIR = src\/pep\/examples\/tests\/$/;" m LOCDIR src/pep/examples/tutorials/makefile /^LOCDIR = src\/pep\/examples\/tutorials\/$/;" m LOCDIR src/pep/f90-mod/makefile /^LOCDIR = src\/pep\/f90-mod\/$/;" m LOCDIR src/pep/impls/jd/makefile /^LOCDIR = src\/pep\/impls\/jd\/$/;" m LOCDIR src/pep/impls/krylov/makefile /^LOCDIR = src\/pep\/impls\/krylov\/$/;" m LOCDIR src/pep/impls/krylov/qarnoldi/makefile /^LOCDIR = src\/pep\/impls\/krylov\/qarnoldi\/$/;" m LOCDIR src/pep/impls/krylov/stoar/makefile /^LOCDIR = src\/pep\/impls\/krylov\/stoar\/$/;" m LOCDIR src/pep/impls/krylov/toar/makefile /^LOCDIR = src\/pep\/impls\/krylov\/toar\/$/;" m LOCDIR src/pep/impls/linear/makefile /^LOCDIR = src\/pep\/impls\/linear\/$/;" m LOCDIR src/pep/impls/makefile /^LOCDIR = src\/pep\/impls\/$/;" m LOCDIR src/pep/interface/ftn-custom/makefile /^LOCDIR = src\/pep\/interface\/ftn-custom\/$/;" m LOCDIR src/pep/interface/makefile /^LOCDIR = src\/pep\/interface\/$/;" m LOCDIR src/pep/makefile /^LOCDIR = src\/pep\/$/;" m LOCDIR src/svd/examples/makefile /^LOCDIR = src\/svd\/examples\/$/;" m LOCDIR src/svd/examples/tests/makefile /^LOCDIR = src\/svd\/examples\/tests\/$/;" m LOCDIR src/svd/examples/tutorials/makefile /^LOCDIR = src\/svd\/examples\/tutorials\/$/;" m LOCDIR src/svd/f90-mod/makefile /^LOCDIR = src\/svd\/f90-mod\/$/;" m LOCDIR src/svd/impls/cross/makefile /^LOCDIR = src\/svd\/impls\/cross\/$/;" m LOCDIR src/svd/impls/cyclic/makefile /^LOCDIR = src\/svd\/impls\/cyclic\/$/;" m LOCDIR src/svd/impls/lanczos/makefile /^LOCDIR = src\/svd\/impls\/lanczos\/$/;" m LOCDIR src/svd/impls/lapack/makefile /^LOCDIR = src\/svd\/impls\/lapack\/$/;" m LOCDIR src/svd/impls/makefile /^LOCDIR = src\/svd\/impls\/$/;" m LOCDIR src/svd/impls/trlanczos/makefile /^LOCDIR = src\/svd\/impls\/trlanczos\/$/;" m LOCDIR src/svd/interface/ftn-custom/makefile /^LOCDIR = src\/svd\/interface\/ftn-custom\/$/;" m LOCDIR src/svd/interface/makefile /^LOCDIR = src\/svd\/interface\/$/;" m LOCDIR src/svd/makefile /^LOCDIR = src\/svd\/$/;" m LOCDIR src/sys/classes/bv/examples/makefile /^LOCDIR = src\/sys\/classes\/bv\/examples\/$/;" m LOCDIR src/sys/classes/bv/examples/tests/makefile /^LOCDIR = src\/sys\/classes\/bv\/examples\/tests\/$/;" m LOCDIR src/sys/classes/bv/impls/contiguous/makefile /^LOCDIR = src\/sys\/classes\/bv\/impls\/contiguous\/$/;" m LOCDIR src/sys/classes/bv/impls/makefile /^LOCDIR = src\/sys\/classes\/bv\/impls\/$/;" m LOCDIR src/sys/classes/bv/impls/mat/makefile /^LOCDIR = src\/sys\/classes\/bv\/impls\/svec\/$/;" m LOCDIR src/sys/classes/bv/impls/svec/makefile /^LOCDIR = src\/sys\/classes\/bv\/impls\/svec\/$/;" m LOCDIR src/sys/classes/bv/impls/vecs/makefile /^LOCDIR = src\/sys\/classes\/bv\/impls\/vecs\/$/;" m LOCDIR src/sys/classes/bv/interface/ftn-custom/makefile /^LOCDIR = src\/sys\/classes\/bv\/interface\/ftn-custom\/$/;" m LOCDIR src/sys/classes/bv/interface/makefile /^LOCDIR = src\/sys\/classes\/bv\/interface\/$/;" m LOCDIR src/sys/classes/bv/makefile /^LOCDIR = src\/sys\/classes\/bv\/$/;" m LOCDIR src/sys/classes/ds/examples/makefile /^LOCDIR = src\/sys\/classes\/ds\/examples\/$/;" m LOCDIR src/sys/classes/ds/examples/tests/makefile /^LOCDIR = src\/sys\/classes\/ds\/examples\/tests\/$/;" m LOCDIR src/sys/classes/ds/impls/ghep/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/ghep\/$/;" m LOCDIR src/sys/classes/ds/impls/ghiep/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/ghiep\/$/;" m LOCDIR src/sys/classes/ds/impls/gnhep/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/gnhep\/$/;" m LOCDIR src/sys/classes/ds/impls/hep/bdc/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/hep\/bdc\/$/;" m LOCDIR src/sys/classes/ds/impls/hep/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/hep\/$/;" m LOCDIR src/sys/classes/ds/impls/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/$/;" m LOCDIR src/sys/classes/ds/impls/nep/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/nep\/$/;" m LOCDIR src/sys/classes/ds/impls/nhep/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/nhep\/$/;" m LOCDIR src/sys/classes/ds/impls/pep/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/pep\/$/;" m LOCDIR src/sys/classes/ds/impls/svd/makefile /^LOCDIR = src\/sys\/classes\/ds\/impls\/svd\/$/;" m LOCDIR src/sys/classes/ds/interface/ftn-custom/makefile /^LOCDIR = src\/sys\/classes\/ds\/interface\/ftn-custom\/$/;" m LOCDIR src/sys/classes/ds/interface/makefile /^LOCDIR = src\/sys\/classes\/ds\/interface\/$/;" m LOCDIR src/sys/classes/ds/makefile /^LOCDIR = src\/sys\/classes\/ds\/$/;" m LOCDIR src/sys/classes/fn/examples/makefile /^LOCDIR = src\/sys\/classes\/fn\/examples\/$/;" m LOCDIR src/sys/classes/fn/examples/tests/makefile /^LOCDIR = src\/sys\/classes\/fn\/examples\/tests\/$/;" m LOCDIR src/sys/classes/fn/impls/combine/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/combine\/$/;" m LOCDIR src/sys/classes/fn/impls/exp/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/exp\/$/;" m LOCDIR src/sys/classes/fn/impls/invsqrt/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/invsqrt\/$/;" m LOCDIR src/sys/classes/fn/impls/log/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/log\/$/;" m LOCDIR src/sys/classes/fn/impls/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/$/;" m LOCDIR src/sys/classes/fn/impls/phi/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/phi\/$/;" m LOCDIR src/sys/classes/fn/impls/rational/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/rational\/$/;" m LOCDIR src/sys/classes/fn/impls/sqrt/makefile /^LOCDIR = src\/sys\/classes\/fn\/impls\/sqrt\/$/;" m LOCDIR src/sys/classes/fn/interface/ftn-custom/makefile /^LOCDIR = src\/sys\/classes\/fn\/ftn-custom\/$/;" m LOCDIR src/sys/classes/fn/interface/makefile /^LOCDIR = src\/sys\/classes\/fn\/interface\/$/;" m LOCDIR src/sys/classes/fn/makefile /^LOCDIR = src\/sys\/classes\/fn\/$/;" m LOCDIR src/sys/classes/makefile /^LOCDIR = src\/sys\/classes\/$/;" m LOCDIR src/sys/classes/rg/examples/makefile /^LOCDIR = src\/sys\/classes\/rg\/examples\/$/;" m LOCDIR src/sys/classes/rg/examples/tests/makefile /^LOCDIR = src\/sys\/classes\/rg\/examples\/tests\/$/;" m LOCDIR src/sys/classes/rg/impls/ellipse/makefile /^LOCDIR = src\/sys\/classes\/rg\/impls\/ellipse\/$/;" m LOCDIR src/sys/classes/rg/impls/interval/makefile /^LOCDIR = src\/sys\/classes\/rg\/impls\/interval\/$/;" m LOCDIR src/sys/classes/rg/impls/makefile /^LOCDIR = src\/sys\/classes\/rg\/impls\/$/;" m LOCDIR src/sys/classes/rg/impls/polygon/makefile /^LOCDIR = src\/sys\/classes\/rg\/impls\/polygon\/$/;" m LOCDIR src/sys/classes/rg/impls/ring/makefile /^LOCDIR = src\/sys\/classes\/rg\/impls\/ring\/$/;" m LOCDIR src/sys/classes/rg/interface/ftn-custom/makefile /^LOCDIR = src\/sys\/classes\/rg\/interface\/ftn-custom\/$/;" m LOCDIR src/sys/classes/rg/interface/makefile /^LOCDIR = src\/sys\/classes\/rg\/$/;" m LOCDIR src/sys/classes/rg/makefile /^LOCDIR = src\/sys\/classes\/rg\/$/;" m LOCDIR src/sys/classes/st/examples/makefile /^LOCDIR = src\/sys\/classes\/st\/examples\/$/;" m LOCDIR src/sys/classes/st/examples/tests/makefile /^LOCDIR = src\/sys\/classes\/st\/examples\/tests\/$/;" m LOCDIR src/sys/classes/st/impls/cayley/makefile /^LOCDIR = src\/sys\/classes\/st\/impls\/cayley\/$/;" m LOCDIR src/sys/classes/st/impls/makefile /^LOCDIR = src\/sys\/classes\/st\/impls\/$/;" m LOCDIR src/sys/classes/st/impls/precond/makefile /^LOCDIR = src\/sys\/classes\/st\/impls\/precond\/$/;" m LOCDIR src/sys/classes/st/impls/shell/ftn-custom/makefile /^LOCDIR = src\/sys\/classes\/st\/impls\/shell\/ftn-custom\/$/;" m LOCDIR src/sys/classes/st/impls/shell/makefile /^LOCDIR = src\/sys\/classes\/st\/impls\/shell\/$/;" m LOCDIR src/sys/classes/st/impls/shift/makefile /^LOCDIR = src\/sys\/classes\/st\/impls\/shift\/$/;" m LOCDIR src/sys/classes/st/impls/sinvert/makefile /^LOCDIR = src\/sys\/classes\/st\/impls\/sinvert\/$/;" m LOCDIR src/sys/classes/st/interface/ftn-custom/makefile /^LOCDIR = src\/sys\/classes\/st\/interface\/ftn-custom\/$/;" m LOCDIR src/sys/classes/st/interface/makefile /^LOCDIR = src\/sys\/classes\/st\/interface\/$/;" m LOCDIR src/sys/classes/st/makefile /^LOCDIR = src\/sys\/classes\/st\/$/;" m LOCDIR src/sys/f90-mod/makefile /^LOCDIR = src\/sys\/f90-mod\/$/;" m LOCDIR src/sys/ftn-custom/makefile /^LOCDIR = src\/sys\/ftn-custom\/$/;" m LOCDIR src/sys/makefile /^LOCDIR = src\/sys\/$/;" m LOCDIR src/sys/vec/makefile /^LOCDIR = src\/sys\/vec\/$/;" m LUfac src/sys/classes/ds/impls/ghiep/dqds.c /^static PetscErrorCode LUfac(PetscInt n,PetscReal *a,PetscReal *b,PetscReal shift,PetscReal tol,PetscReal norm,PetscReal *L,PetscReal *U,PetscInt *fail,PetscReal *work)$/;" f file: L_max src/eps/impls/ciss/ciss.c /^ PetscInt L_max; \/* maximum number of columns of the source matrix V *\/$/;" m struct:__anon61 file: L_max src/nep/impls/ciss/nciss.c /^ PetscInt L_max; \/* maximum number of columns of the source matrix V *\/$/;" m struct:__anon89 file: Lapack config/packages/lapack.py /^class Lapack(package.Package):$/;" c Link config/package.py /^ def Link(self,functions,callbacks,flags):$/;" m class:Package LinkWithOutput config/package.py /^ def LinkWithOutput(self,functions,callbacks,flags):$/;" m class:Package LoadConf config/packages/petsc.py /^ def LoadConf(self):$/;" m class:PETSc LoadVersion config/packages/petsc.py /^ def LoadVersion(self):$/;" m class:PETSc LoadVersion config/packages/slepc.py /^ def LoadVersion(self):$/;" m class:SLEPc Log config/log.py /^class Log:$/;" c M src/eps/examples/tutorials/ex31.c /^PetscScalar M[3]; \/* M = 2*H\/w_s *\/$/;" v M src/eps/impls/ciss/ciss.c /^ PetscInt M; \/* moment degree (N\/4 = 4) *\/$/;" m struct:__anon61 file: M src/nep/impls/ciss/nciss.c /^ PetscInt M; \/* moment degree (N\/4 = 4) *\/$/;" m struct:__anon89 file: M src/pep/examples/tutorials/ex16f90.F90 /^ type(Ma/;" v program:main M src/pep/impls/jd/pjdp.h /^ PetscScalar *M;$/;" m struct:__anon100 M src/pep/impls/linear/linearp.h /^ Mat M,C,K; \/* copy of PEP coefficient matrices *\/$/;" m struct:__anon106 M1 src/nep/interface/neprefine.c /^ Mat M1;$/;" m struct:__anon98 file: M1 src/pep/impls/krylov/toar/nrefine.c /^ Mat *A,M1;$/;" m struct:__anon104 file: M1 src/pep/impls/krylov/toar/nrefine.c /^ Mat E[2],M1;$/;" m struct:__anon105 file: M1 src/pep/interface/peprefine.c /^ Mat M1;$/;" m struct:__anon109 file: M2 src/nep/interface/neprefine.c /^ Vec M2,M3;$/;" m struct:__anon98 file: M2 src/pep/impls/krylov/toar/nrefine.c /^ BV V,M2,M3,W;$/;" m struct:__anon104 file: M2 src/pep/impls/krylov/toar/nrefine.c /^ BV V,W,M2,M3,Wt;$/;" m struct:__anon105 file: M2 src/pep/interface/peprefine.c /^ Vec M2,M3;$/;" m struct:__anon109 file: M3 src/nep/interface/neprefine.c /^ Vec M2,M3;$/;" m struct:__anon98 file: M3 src/pep/impls/krylov/toar/nrefine.c /^ BV V,M2,M3,W;$/;" m struct:__anon104 file: M3 src/pep/impls/krylov/toar/nrefine.c /^ BV V,W,M2,M3,Wt;$/;" m struct:__anon105 file: M3 src/pep/interface/peprefine.c /^ Vec M2,M3;$/;" m struct:__anon109 file: M4 src/nep/interface/neprefine.c /^ PetscScalar M4,m3;$/;" m struct:__anon98 file: M4 src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *M4,*w,*wt,*d,*dt;$/;" m struct:__anon105 file: M4 src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *fih,*work,*M4;$/;" m struct:__anon104 file: M4 src/pep/interface/peprefine.c /^ PetscScalar M4,m3;$/;" m struct:__anon109 file: MANSEC include/makefile /^MANSEC = $/;" m MANSEC include/slepc/finclude/makefile /^MANSEC = $/;" m MANSEC include/slepc/private/makefile /^MANSEC = $/;" m MANSEC src/eps/examples/tests/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/examples/tutorials/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/f90-mod/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/cg/lobpcg/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/cg/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/cg/rqcg/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/ciss/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/davidson/gd/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/davidson/jd/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/davidson/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/external/arpack/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/external/blopex/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/external/blzpack/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/external/feast/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/external/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/external/primme/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/external/trlan/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/krylov/arnoldi/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/krylov/krylovschur/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/krylov/lanczos/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/krylov/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/lapack/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/power/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/impls/subspace/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/interface/makefile /^MANSEC = EPS$/;" m MANSEC src/eps/makefile /^MANSEC = EPS$/;" m MANSEC src/mfn/examples/tests/makefile /^MANSEC = MFN$/;" m MANSEC src/mfn/examples/tutorials/makefile /^MANSEC = MFN$/;" m MANSEC src/mfn/f90-mod/makefile /^MANSEC = MFN$/;" m MANSEC src/mfn/impls/expokit/makefile /^MANSEC = MFN$/;" m MANSEC src/mfn/impls/krylov/makefile /^MANSEC = MFN$/;" m MANSEC src/mfn/impls/makefile /^MANSEC = MFN$/;" m MANSEC src/mfn/interface/makefile /^MANSEC = MFN$/;" m MANSEC src/mfn/makefile /^MANSEC = MFN$/;" m MANSEC src/nep/examples/nlevp/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/examples/tests/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/examples/tutorials/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/f90-mod/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/impls/ciss/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/impls/interpol/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/impls/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/impls/narnoldi/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/impls/nleigs/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/impls/rii/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/impls/slp/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/interface/makefile /^MANSEC = NEP$/;" m MANSEC src/nep/makefile /^MANSEC = NEP$/;" m MANSEC src/pep/examples/nlevp/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/examples/tests/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/examples/tutorials/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/f90-mod/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/impls/jd/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/impls/krylov/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/impls/krylov/qarnoldi/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/impls/krylov/stoar/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/impls/krylov/toar/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/impls/linear/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/impls/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/interface/makefile /^MANSEC = PEP$/;" m MANSEC src/pep/makefile /^MANSEC = PEP$/;" m MANSEC src/svd/examples/tests/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/examples/tutorials/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/f90-mod/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/impls/cross/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/impls/cyclic/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/impls/lanczos/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/impls/lapack/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/impls/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/impls/trlanczos/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/interface/makefile /^MANSEC = SVD$/;" m MANSEC src/svd/makefile /^MANSEC = SVD$/;" m MANSEC src/sys/classes/bv/examples/tests/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/bv/impls/contiguous/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/bv/impls/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/bv/impls/mat/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/bv/impls/svec/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/bv/impls/vecs/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/bv/interface/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/bv/makefile /^MANSEC = BV$/;" m MANSEC src/sys/classes/ds/examples/tests/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/ghep/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/ghiep/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/gnhep/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/hep/bdc/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/hep/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/nep/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/nhep/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/pep/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/impls/svd/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/interface/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/ds/makefile /^MANSEC = DS$/;" m MANSEC src/sys/classes/fn/examples/tests/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/combine/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/exp/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/invsqrt/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/log/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/phi/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/rational/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/impls/sqrt/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/interface/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/fn/makefile /^MANSEC = FN$/;" m MANSEC src/sys/classes/makefile /^MANSEC = sys$/;" m MANSEC src/sys/classes/rg/examples/tests/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/rg/impls/ellipse/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/rg/impls/interval/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/rg/impls/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/rg/impls/polygon/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/rg/impls/ring/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/rg/interface/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/rg/makefile /^MANSEC = RG$/;" m MANSEC src/sys/classes/st/examples/tests/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/impls/cayley/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/impls/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/impls/precond/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/impls/shell/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/impls/shift/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/impls/sinvert/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/interface/makefile /^MANSEC = ST$/;" m MANSEC src/sys/classes/st/makefile /^MANSEC = ST$/;" m MANSEC src/sys/f90-mod/makefile /^MANSEC = sys$/;" m MANSEC src/sys/ftn-custom/makefile /^MANSEC = sys$/;" m MANSEC src/sys/makefile /^MANSEC = sys$/;" m MANSEC src/sys/vec/makefile /^MANSEC = sys$/;" m MAXEPSMONITORS include/slepc/private/epsimpl.h 49;" d MAXMFNMONITORS include/slepc/private/mfnimpl.h 47;" d MAXNEPMONITORS include/slepc/private/nepimpl.h 48;" d MAXPEPMONITORS include/slepc/private/pepimpl.h 50;" d MAXSVDMONITORS include/slepc/private/svdimpl.h 47;" d MAX_LBPOINTS src/nep/impls/nleigs/nleigs.c 40;" d file: MAX_MATRICES src/pep/examples/tutorials/ex17.c 28;" d file: MAX_NSHIFTS src/nep/impls/nleigs/nleigs.c 42;" d file: MAX_PADE src/sys/classes/fn/impls/exp/fnexp.c 45;" d file: MFN include/slepc/finclude/slepcmfndef.h 31;" d MFN include/slepcmfn.h /^typedef struct _p_MFN* MFN;$/;" t typeref:struct:_p_MFN MFNAllocateSolution src/mfn/interface/mfnsetup.c /^PetscErrorCode MFNAllocateSolution(MFN mfn,PetscInt extra)$/;" f MFNAppendOptionsPrefix src/mfn/interface/mfnopts.c /^PetscErrorCode MFNAppendOptionsPrefix(MFN mfn,const char *prefix)$/;" f MFNBasicArnoldi src/mfn/impls/krylov/mfnkrylov.c /^PetscErrorCode MFNBasicArnoldi(MFN mfn,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)$/;" f MFNConvergedReason include/slepc/finclude/slepcmfndef.h 35;" d MFNConvergedReason include/slepcmfn.h /^ MFN_CONVERGED_ITERATING = 0} MFNConvergedReason;$/;" t typeref:enum:__anon29 MFNConvergedReasons include/slepcmfn.h /^PETSC_EXTERN const char *const*MFNConvergedReasons;$/;" v MFNConvergedReasons src/mfn/interface/dlregismfn.c /^const char *const*MFNConvergedReasons = MFNConvergedReasons_Shifted + 4;$/;" v MFNConvergedReasons_Shifted src/mfn/interface/dlregismfn.c /^const char *const MFNConvergedReasons_Shifted[] = {"DIVERGED_BREAKDOWN","DIVERGED_ITS","","","CONVERGED_ITERATING","","CONVERGED_TOL","CONVERGED_ITS","MFNConvergedReason","MFN_",0};$/;" v MFNCreate src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNCreate(MPI_Comm comm,MFN *outmfn)$/;" f MFNCreate_Expokit src/mfn/impls/expokit/mfnexpokit.c /^PETSC_EXTERN PetscErrorCode MFNCreate_Expokit(MFN mfn)$/;" f MFNCreate_Krylov src/mfn/impls/krylov/mfnkrylov.c /^PETSC_EXTERN PetscErrorCode MFNCreate_Krylov(MFN mfn)$/;" f MFNDestroy src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNDestroy(MFN *mfn)$/;" f MFNEXPOKIT include/slepc/finclude/slepcmfndef.h 38;" d MFNEXPOKIT include/slepcmfn.h 49;" d MFNFinalizePackage src/mfn/interface/dlregismfn.c /^PetscErrorCode MFNFinalizePackage(void)$/;" f MFNGetBV src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNGetBV(MFN mfn,BV *bv)$/;" f MFNGetConvergedReason src/mfn/interface/mfnsolve.c /^PetscErrorCode MFNGetConvergedReason(MFN mfn,MFNConvergedReason *reason)$/;" f MFNGetDimensions src/mfn/interface/mfnopts.c /^PetscErrorCode MFNGetDimensions(MFN mfn,PetscInt *ncv)$/;" f MFNGetErrorIfNotConverged src/mfn/interface/mfnopts.c /^PetscErrorCode MFNGetErrorIfNotConverged(MFN mfn,PetscBool *flag)$/;" f MFNGetFN src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNGetFN(MFN mfn,FN *fn)$/;" f MFNGetIterationNumber src/mfn/interface/mfnsolve.c /^PetscErrorCode MFNGetIterationNumber(MFN mfn,PetscInt *its)$/;" f MFNGetMonitorContext src/mfn/interface/mfnmon.c /^PetscErrorCode MFNGetMonitorContext(MFN mfn,void **ctx)$/;" f MFNGetOperator src/mfn/interface/mfnsetup.c /^PetscErrorCode MFNGetOperator(MFN mfn,Mat *A)$/;" f MFNGetOptionsPrefix src/mfn/interface/mfnopts.c /^PetscErrorCode MFNGetOptionsPrefix(MFN mfn,const char *prefix[])$/;" f MFNGetTolerances src/mfn/interface/mfnopts.c /^PetscErrorCode MFNGetTolerances(MFN mfn,PetscReal *tol,PetscInt *maxits)$/;" f MFNGetType src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNGetType(MFN mfn,MFNType *type)$/;" f MFNInitializePackage src/mfn/interface/dlregismfn.c /^PetscErrorCode MFNInitializePackage(void)$/;" f MFNKRYLOV include/slepc/finclude/slepcmfndef.h 37;" d MFNKRYLOV include/slepcmfn.h 48;" d MFNList include/slepcmfn.h /^PETSC_EXTERN PetscFunctionList MFNList;$/;" v MFNList src/mfn/interface/mfnbasic.c /^PetscFunctionList MFNList = 0;$/;" v MFNMonitor src/mfn/interface/mfnmon.c /^PetscErrorCode MFNMonitor(MFN mfn,PetscInt it,PetscReal errest)$/;" f MFNMonitorCancel src/mfn/interface/mfnmon.c /^PetscErrorCode MFNMonitorCancel(MFN mfn)$/;" f MFNMonitorDefault src/mfn/interface/mfnmon.c /^PetscErrorCode MFNMonitorDefault(MFN mfn,PetscInt its,PetscReal errest,PetscViewerAndFormat *vf)$/;" f MFNMonitorLG src/mfn/interface/mfnmon.c /^PetscErrorCode MFNMonitorLG(MFN mfn,PetscInt its,PetscReal errest,void *ctx)$/;" f MFNMonitorLGCreate src/mfn/interface/mfnmon.c /^PetscErrorCode MFNMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)$/;" f MFNMonitorSet src/mfn/interface/mfnmon.c /^PetscErrorCode MFNMonitorSet(MFN mfn,PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))$/;" f MFNMonitorSetFromOptions src/mfn/interface/mfnopts.c /^PetscErrorCode MFNMonitorSetFromOptions(MFN mfn,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,PetscViewerAndFormat*))$/;" f MFNOps include/slepc/private/mfnimpl.h /^typedef struct _MFNOps *MFNOps;$/;" t typeref:struct:_MFNOps MFNPackageInitialized src/mfn/interface/dlregismfn.c /^static PetscBool MFNPackageInitialized = PETSC_FALSE;$/;" v file: MFNReasonView src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNReasonView(MFN mfn,PetscViewer viewer)$/;" f MFNReasonViewFromOptions src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNReasonViewFromOptions(MFN mfn)$/;" f MFNRegister src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNRegister(const char *name,PetscErrorCode (*function)(MFN))$/;" f MFNRegisterAll src/mfn/interface/mfnregis.c /^PetscErrorCode MFNRegisterAll(void)$/;" f MFNRegisterAllCalled include/slepc/private/mfnimpl.h /^PETSC_EXTERN PetscBool MFNRegisterAllCalled;$/;" v MFNRegisterAllCalled src/mfn/interface/mfnbasic.c /^PetscBool MFNRegisterAllCalled = PETSC_FALSE;$/;" v MFNReset src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNReset(MFN mfn)$/;" f MFNSetBV src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNSetBV(MFN mfn,BV bv)$/;" f MFNSetDimensions src/mfn/interface/mfnopts.c /^PetscErrorCode MFNSetDimensions(MFN mfn,PetscInt ncv)$/;" f MFNSetErrorIfNotConverged src/mfn/interface/mfnopts.c /^PetscErrorCode MFNSetErrorIfNotConverged(MFN mfn,PetscBool flg)$/;" f MFNSetFN src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNSetFN(MFN mfn,FN fn)$/;" f MFNSetFromOptions src/mfn/interface/mfnopts.c /^PetscErrorCode MFNSetFromOptions(MFN mfn)$/;" f MFNSetOperator src/mfn/interface/mfnsetup.c /^PetscErrorCode MFNSetOperator(MFN mfn,Mat A)$/;" f MFNSetOptionsPrefix src/mfn/interface/mfnopts.c /^PetscErrorCode MFNSetOptionsPrefix(MFN mfn,const char *prefix)$/;" f MFNSetTolerances src/mfn/interface/mfnopts.c /^PetscErrorCode MFNSetTolerances(MFN mfn,PetscReal tol,PetscInt maxits)$/;" f MFNSetType src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNSetType(MFN mfn,MFNType type)$/;" f MFNSetUp src/mfn/interface/mfnsetup.c /^PetscErrorCode MFNSetUp(MFN mfn)$/;" f MFNSetUp_Expokit src/mfn/impls/expokit/mfnexpokit.c /^PetscErrorCode MFNSetUp_Expokit(MFN mfn)$/;" f MFNSetUp_Krylov src/mfn/impls/krylov/mfnkrylov.c /^PetscErrorCode MFNSetUp_Krylov(MFN mfn)$/;" f MFNSolve src/mfn/interface/mfnsolve.c /^PetscErrorCode MFNSolve(MFN mfn,Vec b,Vec x)$/;" f MFNSolve_Expokit src/mfn/impls/expokit/mfnexpokit.c /^PetscErrorCode MFNSolve_Expokit(MFN mfn,Vec b,Vec x)$/;" f MFNSolve_Krylov src/mfn/impls/krylov/mfnkrylov.c /^PetscErrorCode MFNSolve_Krylov(MFN mfn,Vec b,Vec x)$/;" f MFNType include/slepc/finclude/slepcmfndef.h 34;" d MFNType include/slepcmfn.h /^typedef const char* MFNType;$/;" t MFNView src/mfn/interface/mfnbasic.c /^PetscErrorCode MFNView(MFN mfn,PetscViewer viewer)$/;" f MFNViewFromOptions include/slepcmfn.h /^PETSC_STATIC_INLINE PetscErrorCode MFNViewFromOptions(MFN mfn,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)mfn,obj,name);}$/;" f MFN_CLASSID include/slepcmfn.h /^PETSC_EXTERN PetscClassId MFN_CLASSID;$/;" v MFN_CLASSID src/mfn/interface/mfnbasic.c /^PetscClassId MFN_CLASSID = 0;$/;" v MFN_CONVERGED_ITERATING include/slepcmfn.h /^ MFN_CONVERGED_ITERATING = 0} MFNConvergedReason;$/;" e enum:__anon29 MFN_CONVERGED_ITS include/slepcmfn.h /^ MFN_CONVERGED_ITS = 3,$/;" e enum:__anon29 MFN_CONVERGED_TOL include/slepcmfn.h /^ MFN_CONVERGED_TOL = 2,$/;" e enum:__anon29 MFN_CreateDenseMat include/slepc/private/mfnimpl.h /^PETSC_STATIC_INLINE PetscErrorCode MFN_CreateDenseMat(PetscInt k,Mat *A)$/;" f MFN_CreateVec include/slepc/private/mfnimpl.h /^PETSC_STATIC_INLINE PetscErrorCode MFN_CreateVec(PetscInt k,Vec *v)$/;" f MFN_DIVERGED_BREAKDOWN include/slepcmfn.h /^ MFN_DIVERGED_BREAKDOWN = -4,$/;" e enum:__anon29 MFN_DIVERGED_ITS include/slepcmfn.h /^ MFN_DIVERGED_ITS = -3,$/;" e enum:__anon29 MFN_SetUp include/slepc/private/mfnimpl.h /^PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve;$/;" v MFN_SetUp src/mfn/interface/mfnbasic.c /^PetscLogEvent MFN_SetUp = 0,MFN_Solve = 0;$/;" v MFN_Solve include/slepc/private/mfnimpl.h /^PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve;$/;" v MFN_Solve src/mfn/interface/mfnbasic.c /^PetscLogEvent MFN_SetUp = 0,MFN_Solve = 0;$/;" v MPIU_NORM1_AND_2 src/sys/vec/veccomp.c /^static MPI_Datatype MPIU_NORM2=0, MPIU_NORM1_AND_2=0;$/;" v file: MPIU_NORM2 src/sys/vec/veccomp.c /^static MPI_Datatype MPIU_NORM2=0, MPIU_NORM1_AND_2=0;$/;" v file: MPIU_NORM2_SUM src/sys/vec/veccomp.c /^static MPI_Op MPIU_NORM2_SUM=0;$/;" v file: MVMISG src/eps/examples/tutorials/ex6f.F /^ SUBROUTINE MVMISG(/;" s MadeHRtr src/sys/classes/ds/impls/ghiep/invit.c /^static PetscErrorCode MadeHRtr(PetscInt sz,PetscInt n,PetscInt idx0,PetscInt n0,PetscInt idx1,PetscInt n1,struct HRtr *tr1,struct HRtr *tr2,PetscReal *ncond,PetscScalar *work)$/;" f file: MatAXPY_Fun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode MatAXPY_Fun(Mat Y,PetscScalar a,Mat X,MatStructure str)$/;" f file: MatCholeskyFactorInvert src/sys/classes/bv/interface/bvorthog.c /^static PetscErrorCode MatCholeskyFactorInvert(Mat R,PetscInt l,Mat *S)$/;" f file: MatCreateExplicit_Linear_H1A src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)$/;" f MatCreateExplicit_Linear_H1B src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)$/;" f MatCreateExplicit_Linear_H2A src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)$/;" f MatCreateExplicit_Linear_H2B src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)$/;" f MatCreateExplicit_Linear_N1A src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)$/;" f MatCreateExplicit_Linear_N1B src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)$/;" f MatCreateExplicit_Linear_N2A src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_N2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)$/;" f MatCreateExplicit_Linear_N2B src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_N2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)$/;" f MatCreateExplicit_Linear_S1A src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_S1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)$/;" f MatCreateExplicit_Linear_S1B src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_S1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)$/;" f MatCreateExplicit_Linear_S2A src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_S2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)$/;" f MatCreateExplicit_Linear_S2B src/pep/impls/linear/qeplin.c /^PetscErrorCode MatCreateExplicit_Linear_S2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)$/;" f MatCreateVecs_Cross src/svd/impls/cross/cross.c /^static PetscErrorCode MatCreateVecs_Cross(Mat B,Vec *right,Vec *left)$/;" f file: MatCreateVecs_dvd_jd src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode MatCreateVecs_dvd_jd(Mat A,Vec *right,Vec *left)$/;" f file: MatCtx src/nep/examples/tutorials/ex21.c /^} MatCtx;$/;" t typeref:struct:__anon87 file: MatDestroy_Fun src/nep/examples/tutorials/ex21.c /^PetscErrorCode MatDestroy_Fun(Mat A)$/;" f MatDestroy_Fun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode MatDestroy_Fun(Mat A)$/;" f file: MatDestroy_Jac src/nep/examples/tutorials/ex21.c /^PetscErrorCode MatDestroy_Jac(Mat A)$/;" f MatDestroy_Shell src/sys/classes/st/interface/stshellmat.c /^static PetscErrorCode MatDestroy_Shell(Mat A)$/;" f file: MatDuplicate_Fun src/nep/examples/tutorials/ex21.c /^PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B)$/;" f MatDuplicate_Fun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B)$/;" f file: MatDuplicate_Shell src/sys/classes/st/examples/tests/test1.c /^static PetscErrorCode MatDuplicate_Shell(Mat S,MatDuplicateOption op,Mat *M)$/;" f file: MatExplicitCtx src/pep/impls/krylov/toar/nrefine.c /^} MatExplicitCtx;$/;" t typeref:struct:__anon105 file: MatFSMult src/nep/interface/neprefine.c /^static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)$/;" f file: MatFSMult src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)$/;" f file: MatFSMult src/pep/interface/peprefine.c /^static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)$/;" f file: MatGetDiagonal_Brussel src/eps/examples/tutorials/ex30.c /^PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag)$/;" f MatGetDiagonal_Brussel src/eps/examples/tutorials/ex9.c /^PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag)$/;" f MatGetDiagonal_Cross src/svd/impls/cross/cross.c /^static PetscErrorCode MatGetDiagonal_Cross(Mat B,Vec d)$/;" f file: MatGetDiagonal_Cyclic src/svd/impls/cyclic/cyclic.c /^static PetscErrorCode MatGetDiagonal_Cyclic(Mat B,Vec diag)$/;" f file: MatGetDiagonal_Fun src/nep/examples/tutorials/ex21.c /^PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag)$/;" f MatGetDiagonal_Fun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag)$/;" f file: MatGetDiagonal_Identity src/pep/examples/tutorials/ex28.c /^PetscErrorCode MatGetDiagonal_Identity(Mat A,Vec diag)$/;" f MatGetDiagonal_Laplacian2D src/eps/examples/tests/test8.c /^PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)$/;" f MatGetDiagonal_Laplacian2D src/eps/examples/tutorials/ex3.c /^PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)$/;" f MatGetDiagonal_Laplacian2D src/pep/examples/tutorials/ex28.c /^PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)$/;" f MatGetDiagonal_Shell src/sys/classes/st/examples/tests/test1.c /^static PetscErrorCode MatGetDiagonal_Shell(Mat S,Vec diag)$/;" f file: MatGetDiagonal_Shell src/sys/classes/st/interface/stshellmat.c /^static PetscErrorCode MatGetDiagonal_Shell(Mat A,Vec diag)$/;" f file: MatGetDiagonal_Zero src/pep/examples/tutorials/ex28.c /^PetscErrorCode MatGetDiagonal_Zero(Mat A,Vec diag)$/;" f MatIsing_Mult src/eps/examples/tutorials/ex6f.F /^ subroutine MatIsing_Mult(/;" s MatMarkovModel src/eps/examples/tests/test11.c /^PetscErrorCode MatMarkovModel(PetscInt m,Mat A)$/;" f MatMarkovModel src/eps/examples/tests/test9.c /^PetscErrorCode MatMarkovModel(PetscInt m,Mat A)$/;" f MatMarkovModel src/eps/examples/tutorials/ex18.c /^PetscErrorCode MatMarkovModel(PetscInt m,Mat A)$/;" f MatMarkovModel src/eps/examples/tutorials/ex29.c /^PetscErrorCode MatMarkovModel(PetscInt m,Mat A)$/;" f MatMarkovModel src/eps/examples/tutorials/ex5.c /^PetscErrorCode MatMarkovModel(PetscInt m,Mat A)$/;" f MatMarkovModel src/mfn/examples/tutorials/ex23.c /^PetscErrorCode MatMarkovModel(PetscInt m,Mat A)$/;" f MatMultTranspose_Fun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode MatMultTranspose_Fun(Mat A,Vec x,Vec y)$/;" f file: MatMultTranspose_Shell src/sys/classes/st/examples/tests/test1.c /^static PetscErrorCode MatMultTranspose_Shell(Mat S,Vec x,Vec y)$/;" f file: MatMultTranspose_Shell src/sys/classes/st/interface/stshellmat.c /^static PetscErrorCode MatMultTranspose_Shell(Mat A,Vec x,Vec y)$/;" f file: MatMultTranspose_dvd_jd src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode MatMultTranspose_dvd_jd(Mat A,Vec in,Vec out)$/;" f file: MatMult_Brussel src/eps/examples/tutorials/ex30.c /^PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y)$/;" f MatMult_Brussel src/eps/examples/tutorials/ex9.c /^PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y)$/;" f MatMult_Cayley src/sys/classes/st/impls/cayley/cayley.c /^static PetscErrorCode MatMult_Cayley(Mat B,Vec x,Vec y)$/;" f file: MatMult_Cross src/svd/impls/cross/cross.c /^static PetscErrorCode MatMult_Cross(Mat B,Vec x,Vec y)$/;" f file: MatMult_Cyclic src/svd/impls/cyclic/cyclic.c /^static PetscErrorCode MatMult_Cyclic(Mat B,Vec x,Vec y)$/;" f file: MatMult_Fold src/eps/examples/tutorials/ex24.c /^PetscErrorCode MatMult_Fold(Mat M,Vec x,Vec y)$/;" f MatMult_Fun src/nep/examples/tutorials/ex21.c /^PetscErrorCode MatMult_Fun(Mat A,Vec x,Vec y)$/;" f MatMult_Fun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode MatMult_Fun(Mat A,Vec x,Vec y)$/;" f file: MatMult_Identity src/pep/examples/tutorials/ex28.c /^PetscErrorCode MatMult_Identity(Mat A,Vec x,Vec y)$/;" f MatMult_Jac src/nep/examples/tutorials/ex21.c /^PetscErrorCode MatMult_Jac(Mat A,Vec x,Vec y)$/;" f MatMult_Laplacian2D src/eps/examples/tests/test8.c /^PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)$/;" f MatMult_Laplacian2D src/eps/examples/tutorials/ex3.c /^PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)$/;" f MatMult_Laplacian2D src/pep/examples/tutorials/ex28.c /^PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)$/;" f MatMult_Linear_Shift src/pep/impls/linear/linear.c /^static PetscErrorCode MatMult_Linear_Shift(Mat M,Vec x,Vec y)$/;" f file: MatMult_Linear_Sinvert src/pep/impls/linear/linear.c /^static PetscErrorCode MatMult_Linear_Sinvert(Mat M,Vec x,Vec y)$/;" f file: MatMult_Shell src/sys/classes/st/examples/tests/test1.c /^static PetscErrorCode MatMult_Shell(Mat S,Vec x,Vec y)$/;" f file: MatMult_Shell src/sys/classes/st/interface/stshellmat.c /^static PetscErrorCode MatMult_Shell(Mat A,Vec x,Vec y)$/;" f file: MatMult_TRLAN src/eps/impls/external/trlan/trlan.c /^static PetscBLASInt MatMult_TRLAN(PetscBLASInt *n,PetscBLASInt *m,PetscReal *xin,PetscBLASInt *ldx,PetscReal *yout,PetscBLASInt *ldy)$/;" f file: MatMult_Zero src/pep/examples/tutorials/ex28.c /^PetscErrorCode MatMult_Zero(Mat A,Vec x,Vec y)$/;" f MatMult_dvd_jd src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode MatMult_dvd_jd(Mat A,Vec in,Vec out)$/;" f file: MatScale_Fun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode MatScale_Fun(Mat M,PetscScalar a)$/;" f file: MatShift_Brussel src/eps/examples/tutorials/ex30.c /^PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y)$/;" f MatShift_Brussel src/eps/examples/tutorials/ex9.c /^PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y)$/;" f MatType_t include/slepc/private/vecimplslepc.h /^typedef PetscInt MatType_t;$/;" t Mistakes config/cmakegen.py /^class Mistakes(object):$/;" c MyArbitrarySelection src/eps/examples/tests/test13.c /^PetscErrorCode MyArbitrarySelection(PetscScalar eigr,PetscScalar eigi,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)$/;" f MyConvergedAbsolute src/eps/examples/tests/test16.c /^PetscErrorCode MyConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f MyEPSMonitor src/eps/examples/tests/test15f.F /^ subroutine MyEPSMonitor(/;" s MyEigenSort src/eps/examples/tests/test11.c /^PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)$/;" f MyEigenSort src/eps/examples/tests/test9.c /^PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)$/;" f MyEigenSort src/eps/examples/tutorials/ex18.c /^PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)$/;" f MyEigenSort src/pep/examples/nlevp/pdde_stability.c /^PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)$/;" f MyShellMatCreate src/sys/classes/st/examples/tests/test1.c /^static PetscErrorCode MyShellMatCreate(Mat *A,Mat *M)$/;" f file: MyStoppingTest src/eps/examples/tutorials/ex29.c /^PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)$/;" f MyStoppingTest src/eps/examples/tutorials/ex30.c /^PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ptr)$/;" f N include/slepc/private/bvimpl.h /^ PetscInt n,N; \/* dimensions of vectors (local, global) *\/$/;" m struct:_p_BV N include/slepc/private/vecimplslepc.h /^ PetscInt N; \/* virtual global size *\/$/;" m struct:__anon7 N src/eps/impls/ciss/ciss.c /^ PetscInt N; \/* number of integration points (32) *\/$/;" m struct:__anon61 file: N src/nep/impls/ciss/nciss.c /^ PetscInt N; \/* number of integration points (32) *\/$/;" m struct:__anon89 file: NDPOINTS src/nep/impls/nleigs/nleigs.c 41;" d file: NEP include/slepc/finclude/slepcnepdef.h 34;" d NEP include/slepcnep.h /^typedef struct _p_NEP* NEP;$/;" t typeref:struct:_p_NEP NEPAllocateSolution src/nep/interface/nepsetup.c /^PetscErrorCode NEPAllocateSolution(NEP nep,PetscInt extra)$/;" f NEPAppendOptionsPrefix src/nep/interface/nepopts.c /^PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char *prefix)$/;" f NEPApplyFunction src/nep/interface/nepsolve.c /^PetscErrorCode NEPApplyFunction(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A,Mat B)$/;" f NEPApplyJacobian src/nep/interface/nepsolve.c /^PetscErrorCode NEPApplyJacobian(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A)$/;" f NEPCISS include/slepc/finclude/slepcnepdef.h 49;" d NEPCISS include/slepcnep.h 53;" d NEPCISSGetRefinement src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPCISSGetRefinement(NEP nep, PetscInt *inner, PetscInt *blsize)$/;" f NEPCISSGetRefinement_CISS src/nep/impls/ciss/nciss.c /^static PetscErrorCode NEPCISSGetRefinement_CISS(NEP nep,PetscInt *inner,PetscInt *blsize)$/;" f file: NEPCISSGetSizes src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPCISSGetSizes(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)$/;" f NEPCISSGetSizes_CISS src/nep/impls/ciss/nciss.c /^static PetscErrorCode NEPCISSGetSizes_CISS(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)$/;" f file: NEPCISSGetThreshold src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPCISSGetThreshold(NEP nep,PetscReal *delta,PetscReal *spur)$/;" f NEPCISSGetThreshold_CISS src/nep/impls/ciss/nciss.c /^static PetscErrorCode NEPCISSGetThreshold_CISS(NEP nep,PetscReal *delta,PetscReal *spur)$/;" f file: NEPCISSSetRefinement src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPCISSSetRefinement(NEP nep,PetscInt inner,PetscInt blsize)$/;" f NEPCISSSetRefinement_CISS src/nep/impls/ciss/nciss.c /^static PetscErrorCode NEPCISSSetRefinement_CISS(NEP nep,PetscInt inner,PetscInt blsize)$/;" f file: NEPCISSSetSizes src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPCISSSetSizes(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)$/;" f NEPCISSSetSizes_CISS src/nep/impls/ciss/nciss.c /^static PetscErrorCode NEPCISSSetSizes_CISS(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)$/;" f file: NEPCISSSetThreshold src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPCISSSetThreshold(NEP nep,PetscReal delta,PetscReal spur)$/;" f NEPCISSSetThreshold_CISS src/nep/impls/ciss/nciss.c /^static PetscErrorCode NEPCISSSetThreshold_CISS(NEP nep,PetscReal delta,PetscReal spur)$/;" f file: NEPCheckCallback include/slepc/private/nepimpl.h 145;" d NEPCheckCallback include/slepc/private/nepimpl.h 157;" d NEPCheckDerivatives include/slepc/private/nepimpl.h 147;" d NEPCheckDerivatives include/slepc/private/nepimpl.h 167;" d NEPCheckProblem include/slepc/private/nepimpl.h 144;" d NEPCheckProblem include/slepc/private/nepimpl.h 152;" d NEPCheckSolved include/slepc/private/nepimpl.h 148;" d NEPCheckSolved include/slepc/private/nepimpl.h 172;" d NEPCheckSplit include/slepc/private/nepimpl.h 146;" d NEPCheckSplit include/slepc/private/nepimpl.h 162;" d NEPComputeError src/nep/interface/nepsolve.c /^PetscErrorCode NEPComputeError(NEP nep,PetscInt i,NEPErrorType type,PetscReal *error)$/;" f NEPComputeFunction src/nep/interface/nepsolve.c /^PetscErrorCode NEPComputeFunction(NEP nep,PetscScalar lambda,Mat A,Mat B)$/;" f NEPComputeJacobian src/nep/interface/nepsolve.c /^PetscErrorCode NEPComputeJacobian(NEP nep,PetscScalar lambda,Mat A)$/;" f NEPComputeRelativeError include/slepcnep.h /^PETSC_DEPRECATED("Use NEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode NEPComputeRelativeError(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_RELATIVE,r);}$/;" f NEPComputeResidualNorm include/slepcnep.h /^PETSC_DEPRECATED("Use NEPComputeError() with NEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode NEPComputeResidualNorm(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_ABSOLUTE,r);}$/;" f NEPComputeResidualNorm_Private src/nep/interface/nepsolve.c /^PetscErrorCode NEPComputeResidualNorm_Private(NEP nep,PetscScalar lambda,Vec x,Vec *w,PetscReal *norm)$/;" f NEPComputeVectors src/nep/interface/nepsolve.c /^PetscErrorCode NEPComputeVectors(NEP nep)$/;" f NEPComputeVectors_Schur src/nep/interface/nepdefault.c /^PetscErrorCode NEPComputeVectors_Schur(NEP nep)$/;" f NEPConv include/slepc/finclude/slepcnepdef.h 41;" d NEPConv include/slepcnep.h /^ NEP_CONV_USER } NEPConv;$/;" t typeref:enum:__anon34 NEPConvMonitorSetFromOptions src/nep/interface/nepopts.c /^PetscErrorCode NEPConvMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))$/;" f NEPConvergedAbsolute src/nep/interface/nepdefault.c /^PetscErrorCode NEPConvergedAbsolute(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f NEPConvergedNorm src/nep/interface/nepdefault.c /^PetscErrorCode NEPConvergedNorm(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f NEPConvergedReason include/slepc/finclude/slepcnepdef.h 38;" d NEPConvergedReason include/slepcnep.h /^ NEP_CONVERGED_ITERATING = 0} NEPConvergedReason;$/;" t typeref:enum:__anon36 NEPConvergedReasons include/slepcnep.h /^PETSC_EXTERN const char *const*NEPConvergedReasons;$/;" v NEPConvergedReasons src/nep/interface/dlregisnep.c /^const char *const*NEPConvergedReasons = NEPConvergedReasons_Shifted + 4;$/;" v NEPConvergedReasons_Shifted src/nep/interface/dlregisnep.c /^const char *const NEPConvergedReasons_Shifted[] = {"DIVERGED_LINEAR_SOLVE","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","NEPConvergedReason","NEP_",0};$/;" v NEPConvergedRelative src/nep/interface/nepdefault.c /^PetscErrorCode NEPConvergedRelative(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f NEPCreate src/nep/interface/nepbasic.c /^PetscErrorCode NEPCreate(MPI_Comm comm,NEP *outnep)$/;" f NEPCreate_CISS src/nep/impls/ciss/nciss.c /^PETSC_EXTERN PetscErrorCode NEPCreate_CISS(NEP nep)$/;" f NEPCreate_Interpol src/nep/impls/interpol/interpol.c /^PETSC_EXTERN PetscErrorCode NEPCreate_Interpol(NEP nep)$/;" f NEPCreate_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^PETSC_EXTERN PetscErrorCode NEPCreate_NArnoldi(NEP nep)$/;" f NEPCreate_NLEIGS src/nep/impls/nleigs/nleigs.c /^PETSC_EXTERN PetscErrorCode NEPCreate_NLEIGS(NEP nep)$/;" f NEPCreate_RII src/nep/impls/rii/rii.c /^PETSC_EXTERN PetscErrorCode NEPCreate_RII(NEP nep)$/;" f NEPCreate_SLP src/nep/impls/slp/slp.c /^PETSC_EXTERN PetscErrorCode NEPCreate_SLP(NEP nep)$/;" f NEPDestroy src/nep/interface/nepbasic.c /^PetscErrorCode NEPDestroy(NEP *nep)$/;" f NEPDestroy_CISS src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPDestroy_CISS(NEP nep)$/;" f NEPDestroy_Interpol src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPDestroy_Interpol(NEP nep)$/;" f NEPDestroy_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^PetscErrorCode NEPDestroy_NArnoldi(NEP nep)$/;" f NEPDestroy_NLEIGS src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPDestroy_NLEIGS(NEP nep)$/;" f NEPDestroy_RII src/nep/impls/rii/rii.c /^PetscErrorCode NEPDestroy_RII(NEP nep)$/;" f NEPDestroy_SLP src/nep/impls/slp/slp.c /^PetscErrorCode NEPDestroy_SLP(NEP nep)$/;" f NEPErrorType include/slepc/finclude/slepcnepdef.h 39;" d NEPErrorType include/slepcnep.h /^ NEP_ERROR_BACKWARD } NEPErrorType;$/;" t typeref:enum:__anon31 NEPErrorTypes include/slepcnep.h /^PETSC_EXTERN const char *NEPErrorTypes[];$/;" v NEPErrorTypes src/nep/interface/dlregisnep.c /^const char *NEPErrorTypes[] = {"ABSOLUTE","RELATIVE","NEPErrorType","NEP_ERROR_",0};$/;" v NEPErrorView src/nep/interface/nepview.c /^PetscErrorCode NEPErrorView(NEP nep,NEPErrorType etype,PetscViewer viewer)$/;" f NEPErrorViewFromOptions src/nep/interface/nepview.c /^PetscErrorCode NEPErrorViewFromOptions(NEP nep)$/;" f NEPErrorView_ASCII src/nep/interface/nepview.c /^static PetscErrorCode NEPErrorView_ASCII(NEP nep,NEPErrorType etype,PetscViewer viewer)$/;" f file: NEPErrorView_DETAIL src/nep/interface/nepview.c /^static PetscErrorCode NEPErrorView_DETAIL(NEP nep,NEPErrorType etype,PetscViewer viewer)$/;" f file: NEPErrorView_MATLAB src/nep/interface/nepview.c /^static PetscErrorCode NEPErrorView_MATLAB(NEP nep,NEPErrorType etype,PetscViewer viewer)$/;" f file: NEPFinalizePackage src/nep/interface/dlregisnep.c /^PetscErrorCode NEPFinalizePackage(void)$/;" f NEPGetBV src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetBV(NEP nep,BV *bv)$/;" f NEPGetConverged src/nep/interface/nepsolve.c /^PetscErrorCode NEPGetConverged(NEP nep,PetscInt *nconv)$/;" f NEPGetConvergedReason src/nep/interface/nepsolve.c /^PetscErrorCode NEPGetConvergedReason(NEP nep,NEPConvergedReason *reason)$/;" f NEPGetConvergenceTest src/nep/interface/nepopts.c /^PetscErrorCode NEPGetConvergenceTest(NEP nep,NEPConv *conv)$/;" f NEPGetDS src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetDS(NEP nep,DS *ds)$/;" f NEPGetDefaultShift src/nep/interface/nepdefault.c /^PetscErrorCode NEPGetDefaultShift(NEP nep,PetscScalar *sigma)$/;" f NEPGetDerivatives src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetDerivatives(NEP nep,Mat *A,PetscErrorCode (**der)(NEP,PetscScalar,PetscInt,Mat,void*),void **ctx)$/;" f NEPGetDimensions src/nep/interface/nepopts.c /^PetscErrorCode NEPGetDimensions(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)$/;" f NEPGetEigenpair src/nep/interface/nepsolve.c /^PetscErrorCode NEPGetEigenpair(NEP nep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)$/;" f NEPGetErrorEstimate src/nep/interface/nepsolve.c /^PetscErrorCode NEPGetErrorEstimate(NEP nep,PetscInt i,PetscReal *errest)$/;" f NEPGetFunction src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetFunction(NEP nep,Mat *A,Mat *B,PetscErrorCode (**fun)(NEP,PetscScalar,Mat,Mat,void*),void **ctx)$/;" f NEPGetIterationNumber src/nep/interface/nepsolve.c /^PetscErrorCode NEPGetIterationNumber(NEP nep,PetscInt *its)$/;" f NEPGetJacobian src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetJacobian(NEP nep,Mat *A,PetscErrorCode (**jac)(NEP,PetscScalar,Mat,void*),void **ctx)$/;" f NEPGetMonitorContext src/nep/interface/nepmon.c /^PetscErrorCode NEPGetMonitorContext(NEP nep,void **ctx)$/;" f NEPGetOptionsPrefix src/nep/interface/nepopts.c /^PetscErrorCode NEPGetOptionsPrefix(NEP nep,const char *prefix[])$/;" f NEPGetRG src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetRG(NEP nep,RG *rg)$/;" f NEPGetRefine src/nep/interface/nepopts.c /^PetscErrorCode NEPGetRefine(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme)$/;" f NEPGetSplitOperatorInfo src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetSplitOperatorInfo(NEP nep,PetscInt *n,MatStructure *str)$/;" f NEPGetSplitOperatorTerm src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetSplitOperatorTerm(NEP nep,PetscInt k,Mat *A,FN *f)$/;" f NEPGetStoppingTest src/nep/interface/nepopts.c /^PetscErrorCode NEPGetStoppingTest(NEP nep,NEPStop *stop)$/;" f NEPGetTarget src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetTarget(NEP nep,PetscScalar* target)$/;" f NEPGetTolerances src/nep/interface/nepopts.c /^PetscErrorCode NEPGetTolerances(NEP nep,PetscReal *tol,PetscInt *maxits)$/;" f NEPGetTrackAll src/nep/interface/nepopts.c /^PetscErrorCode NEPGetTrackAll(NEP nep,PetscBool *trackall)$/;" f NEPGetType src/nep/interface/nepbasic.c /^PetscErrorCode NEPGetType(NEP nep,NEPType *type)$/;" f NEPGetWhichEigenpairs src/nep/interface/nepopts.c /^PetscErrorCode NEPGetWhichEigenpairs(NEP nep,NEPWhich *which)$/;" f NEPINTERPOL include/slepc/finclude/slepcnepdef.h 50;" d NEPINTERPOL include/slepcnep.h 54;" d NEPInitializePackage src/nep/interface/dlregisnep.c /^PetscErrorCode NEPInitializePackage(void)$/;" f NEPInterpolGetDegree src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPInterpolGetDegree(NEP nep,PetscInt *deg)$/;" f NEPInterpolGetDegree_Interpol src/nep/impls/interpol/interpol.c /^static PetscErrorCode NEPInterpolGetDegree_Interpol(NEP nep,PetscInt *deg)$/;" f file: NEPInterpolGetPEP src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPInterpolGetPEP(NEP nep,PEP *pep)$/;" f NEPInterpolGetPEP_Interpol src/nep/impls/interpol/interpol.c /^static PetscErrorCode NEPInterpolGetPEP_Interpol(NEP nep,PEP *pep)$/;" f file: NEPInterpolSetDegree src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPInterpolSetDegree(NEP nep,PetscInt deg)$/;" f NEPInterpolSetDegree_Interpol src/nep/impls/interpol/interpol.c /^static PetscErrorCode NEPInterpolSetDegree_Interpol(NEP nep,PetscInt deg)$/;" f file: NEPInterpolSetPEP src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPInterpolSetPEP(NEP nep,PEP pep)$/;" f NEPInterpolSetPEP_Interpol src/nep/impls/interpol/interpol.c /^static PetscErrorCode NEPInterpolSetPEP_Interpol(NEP nep,PEP pep)$/;" f file: NEPList include/slepcnep.h /^PETSC_EXTERN PetscFunctionList NEPList;$/;" v NEPList src/nep/interface/nepbasic.c /^PetscFunctionList NEPList = 0;$/;" v NEPMonitor src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitor(NEP nep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)$/;" f NEPMonitorAll src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f NEPMonitorCancel src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorCancel(NEP nep)$/;" f NEPMonitorConverged src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorConverged(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)$/;" f NEPMonitorFirst src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorFirst(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f NEPMonitorLG src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorLG(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f NEPMonitorLGAll src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorLGAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f NEPMonitorLGCreate src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)$/;" f NEPMonitorSet src/nep/interface/nepmon.c /^PetscErrorCode NEPMonitorSet(NEP nep,PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))$/;" f NEPMonitorSetFromOptions src/nep/interface/nepopts.c /^PetscErrorCode NEPMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)$/;" f NEPNARNOLDI include/slepc/finclude/slepcnepdef.h 48;" d NEPNARNOLDI include/slepcnep.h 52;" d NEPNArnoldiGetKSP src/nep/impls/narnoldi/narnoldi.c /^PetscErrorCode NEPNArnoldiGetKSP(NEP nep,KSP *ksp)$/;" f NEPNArnoldiGetKSP_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^static PetscErrorCode NEPNArnoldiGetKSP_NArnoldi(NEP nep,KSP *ksp)$/;" f file: NEPNArnoldiSetKSP src/nep/impls/narnoldi/narnoldi.c /^PetscErrorCode NEPNArnoldiSetKSP(NEP nep,KSP ksp)$/;" f NEPNArnoldiSetKSP_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^static PetscErrorCode NEPNArnoldiSetKSP_NArnoldi(NEP nep,KSP ksp)$/;" f file: NEPNArnoldi_KSPSolve src/nep/impls/narnoldi/narnoldi.c /^PETSC_STATIC_INLINE PetscErrorCode NEPNArnoldi_KSPSolve(NEP nep,Vec b,Vec x)$/;" f NEPNLEIGS include/slepc/finclude/slepcnepdef.h 51;" d NEPNLEIGS include/slepcnep.h 55;" d NEPNLEIGSBackTransform src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSBackTransform(PetscObject ob,PetscInt n,PetscScalar *valr,PetscScalar *vali)$/;" f file: NEPNLEIGSDividedDifferences_callback src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSDividedDifferences_callback(NEP nep)$/;" f file: NEPNLEIGSDividedDifferences_split src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSDividedDifferences_split(NEP nep)$/;" f file: NEPNLEIGSEvalNRTFunct src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSEvalNRTFunct(NEP nep,PetscInt k,PetscScalar sigma,PetscScalar *b)$/;" f file: NEPNLEIGSGetInterpolation src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSGetInterpolation(NEP nep,PetscReal *tol,PetscInt *maxits)$/;" f NEPNLEIGSGetInterpolation_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSGetInterpolation_NLEIGS(NEP nep,PetscReal *tol,PetscInt *maxits)$/;" f file: NEPNLEIGSGetKSPs src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSGetKSPs(NEP nep,KSP **ksp)$/;" f NEPNLEIGSGetKSPs_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSGetKSPs_NLEIGS(NEP nep,KSP **ksp)$/;" f file: NEPNLEIGSGetLocking src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSGetLocking(NEP nep,PetscBool *lock)$/;" f NEPNLEIGSGetLocking_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSGetLocking_NLEIGS(NEP nep,PetscBool *lock)$/;" f file: NEPNLEIGSGetRKShifts src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSGetRKShifts(NEP nep,PetscInt *ns,PetscScalar **shifts)$/;" f NEPNLEIGSGetRKShifts_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSGetRKShifts_NLEIGS(NEP nep,PetscInt *ns,PetscScalar **shifts)$/;" f file: NEPNLEIGSGetRestart src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSGetRestart(NEP nep,PetscReal *keep)$/;" f NEPNLEIGSGetRestart_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSGetRestart_NLEIGS(NEP nep,PetscReal *keep)$/;" f file: NEPNLEIGSGetSingularitiesFunction src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx)$/;" f NEPNLEIGSGetSingularitiesFunction_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSGetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx)$/;" f file: NEPNLEIGSGetTrueResidual src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSGetTrueResidual(NEP nep,PetscBool *trueres)$/;" f NEPNLEIGSGetTrueResidual_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSGetTrueResidual_NLEIGS(NEP nep,PetscBool *trueres)$/;" f file: NEPNLEIGSKrylovConvergence src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSKrylovConvergence(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscBool getall,PetscInt kini,PetscInt nits,PetscScalar betak,PetscReal betah,PetscInt *kout,Vec *w)$/;" f file: NEPNLEIGSLejaBagbyPoints src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSLejaBagbyPoints(NEP nep)$/;" f file: NEPNLEIGSNormEstimation src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSNormEstimation(NEP nep,Mat M,PetscReal *norm,Vec *w)$/;" f file: NEPNLEIGSRitzVector src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSRitzVector(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscInt k,Vec t)$/;" f file: NEPNLEIGSSetInterpolation src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSSetInterpolation(NEP nep,PetscReal tol,PetscInt maxits)$/;" f NEPNLEIGSSetInterpolation_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSSetInterpolation_NLEIGS(NEP nep,PetscReal tol,PetscInt maxits)$/;" f file: NEPNLEIGSSetLocking src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSSetLocking(NEP nep,PetscBool lock)$/;" f NEPNLEIGSSetLocking_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSSetLocking_NLEIGS(NEP nep,PetscBool lock)$/;" f file: NEPNLEIGSSetRKShifts src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSSetRKShifts(NEP nep,PetscInt ns,PetscScalar *shifts)$/;" f NEPNLEIGSSetRKShifts_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSSetRKShifts_NLEIGS(NEP nep,PetscInt ns,PetscScalar *shifts)$/;" f file: NEPNLEIGSSetRestart src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSSetRestart(NEP nep,PetscReal keep)$/;" f NEPNLEIGSSetRestart_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSSetRestart_NLEIGS(NEP nep,PetscReal keep)$/;" f file: NEPNLEIGSSetShifts src/nep/impls/nleigs/nleigs.c /^PETSC_STATIC_INLINE PetscErrorCode NEPNLEIGSSetShifts(NEP nep)$/;" f NEPNLEIGSSetSingularitiesFunction src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx)$/;" f NEPNLEIGSSetSingularitiesFunction_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSSetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx)$/;" f file: NEPNLEIGSSetTrueResidual src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPNLEIGSSetTrueResidual(NEP nep,PetscBool trueres)$/;" f NEPNLEIGSSetTrueResidual_NLEIGS src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSSetTrueResidual_NLEIGS(NEP nep,PetscBool trueres)$/;" f file: NEPNLEIGSTOARrun src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGSTOARrun(NEP nep,PetscInt *nq,PetscScalar *S,PetscInt ld,PetscScalar *K,PetscScalar *H,PetscInt ldh,BV V,PetscInt k,PetscInt *M,PetscBool *breakdown,Vec *t_)$/;" f file: NEPNLEIGS_RKcontinuation src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPNLEIGS_RKcontinuation(NEP nep,PetscInt ini,PetscInt end,PetscScalar *K,PetscScalar *H,PetscInt ld,PetscScalar sigma,PetscScalar *S,PetscInt lds,PetscScalar *cont,PetscScalar *t,PetscScalar *work)$/;" f file: NEPNewtonRefinementSimple src/nep/interface/neprefine.c /^PetscErrorCode NEPNewtonRefinementSimple(NEP nep,PetscInt *maxits,PetscReal tol,PetscInt k)$/;" f NEPOps include/slepc/private/nepimpl.h /^typedef struct _NEPOps *NEPOps;$/;" t typeref:struct:_NEPOps NEPPackageInitialized src/nep/interface/dlregisnep.c /^static PetscBool NEPPackageInitialized = PETSC_FALSE;$/;" v file: NEPProjectOperator src/nep/interface/nepsolve.c /^PetscErrorCode NEPProjectOperator(NEP nep,PetscInt j0,PetscInt j1)$/;" f NEPRII include/slepc/finclude/slepcnepdef.h 46;" d NEPRII include/slepcnep.h 50;" d NEPRIIGetConstCorrectionTol src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIIGetConstCorrectionTol(NEP nep,PetscBool *cct)$/;" f NEPRIIGetConstCorrectionTol_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIIGetConstCorrectionTol_RII(NEP nep,PetscBool *cct)$/;" f file: NEPRIIGetKSP src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIIGetKSP(NEP nep,KSP *ksp)$/;" f NEPRIIGetKSP_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIIGetKSP_RII(NEP nep,KSP *ksp)$/;" f file: NEPRIIGetLagPreconditioner src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIIGetLagPreconditioner(NEP nep,PetscInt *lag)$/;" f NEPRIIGetLagPreconditioner_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIIGetLagPreconditioner_RII(NEP nep,PetscInt *lag)$/;" f file: NEPRIIGetMaximumIterations src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIIGetMaximumIterations(NEP nep,PetscInt *its)$/;" f NEPRIIGetMaximumIterations_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIIGetMaximumIterations_RII(NEP nep,PetscInt *its)$/;" f file: NEPRIISetConstCorrectionTol src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIISetConstCorrectionTol(NEP nep,PetscBool cct)$/;" f NEPRIISetConstCorrectionTol_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIISetConstCorrectionTol_RII(NEP nep,PetscBool cct)$/;" f file: NEPRIISetKSP src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIISetKSP(NEP nep,KSP ksp)$/;" f NEPRIISetKSP_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIISetKSP_RII(NEP nep,KSP ksp)$/;" f file: NEPRIISetLagPreconditioner src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIISetLagPreconditioner(NEP nep,PetscInt lag)$/;" f NEPRIISetLagPreconditioner_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIISetLagPreconditioner_RII(NEP nep,PetscInt lag)$/;" f file: NEPRIISetMaximumIterations src/nep/impls/rii/rii.c /^PetscErrorCode NEPRIISetMaximumIterations(NEP nep,PetscInt its)$/;" f NEPRIISetMaximumIterations_RII src/nep/impls/rii/rii.c /^static PetscErrorCode NEPRIISetMaximumIterations_RII(NEP nep,PetscInt its)$/;" f file: NEPRII_KSPSolve src/nep/impls/rii/rii.c /^PETSC_STATIC_INLINE PetscErrorCode NEPRII_KSPSolve(NEP nep,Vec b,Vec x)$/;" f NEPReasonView src/nep/interface/nepview.c /^PetscErrorCode NEPReasonView(NEP nep,PetscViewer viewer)$/;" f NEPReasonViewFromOptions src/nep/interface/nepview.c /^PetscErrorCode NEPReasonViewFromOptions(NEP nep)$/;" f NEPRefine include/slepc/finclude/slepcnepdef.h 43;" d NEPRefine include/slepcnep.h /^ NEP_REFINE_MULTIPLE } NEPRefine;$/;" t typeref:enum:__anon32 NEPRefineGetKSP src/nep/interface/nepbasic.c /^PetscErrorCode NEPRefineGetKSP(NEP nep,KSP *ksp)$/;" f NEPRefineScheme include/slepc/finclude/slepcnepdef.h 44;" d NEPRefineScheme include/slepcnep.h /^ NEP_REFINE_SCHEME_EXPLICIT } NEPRefineScheme;$/;" t typeref:enum:__anon33 NEPRefineSchemes include/slepcnep.h /^PETSC_EXTERN const char *NEPRefineSchemes[];$/;" v NEPRefineSchemes src/nep/interface/dlregisnep.c /^const char *NEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","NEPRefineScheme","NEP_REFINE_SCHEME_",0};$/;" v NEPRefineTypes include/slepcnep.h /^PETSC_EXTERN const char *NEPRefineTypes[];$/;" v NEPRefineTypes src/nep/interface/dlregisnep.c /^const char *NEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","NEPRefine","NEP_REFINE_",0};$/;" v NEPRegister src/nep/interface/nepbasic.c /^PetscErrorCode NEPRegister(const char *name,PetscErrorCode (*function)(NEP))$/;" f NEPRegisterAll src/nep/interface/nepregis.c /^PetscErrorCode NEPRegisterAll(void)$/;" f NEPRegisterAllCalled include/slepc/private/nepimpl.h /^PETSC_EXTERN PetscBool NEPRegisterAllCalled;$/;" v NEPRegisterAllCalled src/nep/interface/nepbasic.c /^PetscBool NEPRegisterAllCalled = PETSC_FALSE;$/;" v NEPReset src/nep/interface/nepbasic.c /^PetscErrorCode NEPReset(NEP nep)$/;" f NEPReset_CISS src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPReset_CISS(NEP nep)$/;" f NEPReset_Interpol src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPReset_Interpol(NEP nep)$/;" f NEPReset_NLEIGS src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPReset_NLEIGS(NEP nep)$/;" f NEPReset_Problem src/nep/interface/nepbasic.c /^PetscErrorCode NEPReset_Problem(NEP nep)$/;" f NEPReset_SLP src/nep/impls/slp/slp.c /^PetscErrorCode NEPReset_SLP(NEP nep)$/;" f NEPSLP include/slepc/finclude/slepcnepdef.h 47;" d NEPSLP include/slepcnep.h 51;" d NEPSLPGetEPS src/nep/impls/slp/slp.c /^PetscErrorCode NEPSLPGetEPS(NEP nep,EPS *eps)$/;" f NEPSLPGetEPS_SLP src/nep/impls/slp/slp.c /^static PetscErrorCode NEPSLPGetEPS_SLP(NEP nep,EPS *eps)$/;" f file: NEPSLPSetEPS src/nep/impls/slp/slp.c /^PetscErrorCode NEPSLPSetEPS(NEP nep,EPS eps)$/;" f NEPSLPSetEPS_SLP src/nep/impls/slp/slp.c /^static PetscErrorCode NEPSLPSetEPS_SLP(NEP nep,EPS eps)$/;" f file: NEPSetBV src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetBV(NEP nep,BV bv)$/;" f NEPSetConvergenceTest src/nep/interface/nepopts.c /^PetscErrorCode NEPSetConvergenceTest(NEP nep,NEPConv conv)$/;" f NEPSetConvergenceTestFunction src/nep/interface/nepopts.c /^PetscErrorCode NEPSetConvergenceTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f NEPSetDS src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetDS(NEP nep,DS ds)$/;" f NEPSetDerivatives src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetDerivatives(NEP nep,Mat A,PetscErrorCode (*der)(NEP,PetscScalar,PetscInt,Mat,void*),void *ctx)$/;" f NEPSetDimensions src/nep/interface/nepopts.c /^PetscErrorCode NEPSetDimensions(NEP nep,PetscInt nev,PetscInt ncv,PetscInt mpd)$/;" f NEPSetDimensions_Default src/nep/interface/nepsetup.c /^PetscErrorCode NEPSetDimensions_Default(NEP nep,PetscInt nev,PetscInt *ncv,PetscInt *mpd)$/;" f NEPSetEigenvalueComparison src/nep/interface/nepopts.c /^PetscErrorCode NEPSetEigenvalueComparison(NEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)$/;" f NEPSetFromOptions src/nep/interface/nepopts.c /^PetscErrorCode NEPSetFromOptions(NEP nep)$/;" f NEPSetFromOptions_CISS src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,NEP nep)$/;" f NEPSetFromOptions_Interpol src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPSetFromOptions_Interpol(PetscOptionItems *PetscOptionsObject,NEP nep)$/;" f NEPSetFromOptions_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^PetscErrorCode NEPSetFromOptions_NArnoldi(PetscOptionItems *PetscOptionsObject,NEP nep)$/;" f NEPSetFromOptions_NLEIGS src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPSetFromOptions_NLEIGS(PetscOptionItems *PetscOptionsObject,NEP nep)$/;" f NEPSetFromOptions_RII src/nep/impls/rii/rii.c /^PetscErrorCode NEPSetFromOptions_RII(PetscOptionItems *PetscOptionsObject,NEP nep)$/;" f NEPSetFromOptions_SLP src/nep/impls/slp/slp.c /^PetscErrorCode NEPSetFromOptions_SLP(PetscOptionItems *PetscOptionsObject,NEP nep)$/;" f NEPSetFunction src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetFunction(NEP nep,Mat A,Mat B,PetscErrorCode (*fun)(NEP,PetscScalar,Mat,Mat,void*),void *ctx)$/;" f NEPSetInitialSpace src/nep/interface/nepsetup.c /^PetscErrorCode NEPSetInitialSpace(NEP nep,PetscInt n,Vec *is)$/;" f NEPSetJacobian src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetJacobian(NEP nep,Mat A,PetscErrorCode (*jac)(NEP,PetscScalar,Mat,void*),void *ctx)$/;" f NEPSetOptionsPrefix src/nep/interface/nepopts.c /^PetscErrorCode NEPSetOptionsPrefix(NEP nep,const char *prefix)$/;" f NEPSetRG src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetRG(NEP nep,RG rg)$/;" f NEPSetRefine src/nep/interface/nepopts.c /^PetscErrorCode NEPSetRefine(NEP nep,NEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,NEPRefineScheme scheme)$/;" f NEPSetSplitOperator src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetSplitOperator(NEP nep,PetscInt n,Mat A[],FN f[],MatStructure str)$/;" f NEPSetStoppingTest src/nep/interface/nepopts.c /^PetscErrorCode NEPSetStoppingTest(NEP nep,NEPStop stop)$/;" f NEPSetStoppingTestFunction src/nep/interface/nepopts.c /^PetscErrorCode NEPSetStoppingTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f NEPSetTarget src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetTarget(NEP nep,PetscScalar target)$/;" f NEPSetTolerances src/nep/interface/nepopts.c /^PetscErrorCode NEPSetTolerances(NEP nep,PetscReal tol,PetscInt maxits)$/;" f NEPSetTrackAll src/nep/interface/nepopts.c /^PetscErrorCode NEPSetTrackAll(NEP nep,PetscBool trackall)$/;" f NEPSetType src/nep/interface/nepbasic.c /^PetscErrorCode NEPSetType(NEP nep,NEPType type)$/;" f NEPSetUp src/nep/interface/nepsetup.c /^PetscErrorCode NEPSetUp(NEP nep)$/;" f NEPSetUp_CISS src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPSetUp_CISS(NEP nep)$/;" f NEPSetUp_Interpol src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPSetUp_Interpol(NEP nep)$/;" f NEPSetUp_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^PetscErrorCode NEPSetUp_NArnoldi(NEP nep)$/;" f NEPSetUp_NLEIGS src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPSetUp_NLEIGS(NEP nep)$/;" f NEPSetUp_RII src/nep/impls/rii/rii.c /^PetscErrorCode NEPSetUp_RII(NEP nep)$/;" f NEPSetUp_SLP src/nep/impls/slp/slp.c /^PetscErrorCode NEPSetUp_SLP(NEP nep)$/;" f NEPSetWhichEigenpairs src/nep/interface/nepopts.c /^PetscErrorCode NEPSetWhichEigenpairs(NEP nep,NEPWhich which)$/;" f NEPSetWorkVecs src/nep/interface/nepdefault.c /^PetscErrorCode NEPSetWorkVecs(NEP nep,PetscInt nw)$/;" f NEPSimpNRefctx src/nep/interface/neprefine.c /^} NEPSimpNRefctx;$/;" t typeref:struct:__anon97 file: NEPSimpleNRefGatherEigenpair src/nep/interface/neprefine.c /^static PetscErrorCode NEPSimpleNRefGatherEigenpair(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail)$/;" f file: NEPSimpleNRefScatterEigenvector src/nep/interface/neprefine.c /^static PetscErrorCode NEPSimpleNRefScatterEigenvector(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx)$/;" f file: NEPSimpleNRefSetUp src/nep/interface/neprefine.c /^static PetscErrorCode NEPSimpleNRefSetUp(NEP nep,NEPSimpNRefctx **ctx_)$/;" f file: NEPSimpleNRefSetUpSystem src/nep/interface/neprefine.c /^static PetscErrorCode NEPSimpleNRefSetUpSystem(NEP nep,NEPSimpNRefctx *ctx,Mat *A,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v)$/;" f file: NEPSolve src/nep/interface/nepsolve.c /^PetscErrorCode NEPSolve(NEP nep)$/;" f NEPSolve_CISS src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPSolve_CISS(NEP nep)$/;" f NEPSolve_Interpol src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPSolve_Interpol(NEP nep)$/;" f NEPSolve_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^PetscErrorCode NEPSolve_NArnoldi(NEP nep)$/;" f NEPSolve_NLEIGS src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPSolve_NLEIGS(NEP nep)$/;" f NEPSolve_RII src/nep/impls/rii/rii.c /^PetscErrorCode NEPSolve_RII(NEP nep)$/;" f NEPSolve_SLP src/nep/impls/slp/slp.c /^PetscErrorCode NEPSolve_SLP(NEP nep)$/;" f NEPStateType include/slepc/private/nepimpl.h /^ NEP_STATE_EIGENVECTORS } NEPStateType;$/;" t typeref:enum:__anon2 NEPStop include/slepc/finclude/slepcnepdef.h 42;" d NEPStop include/slepcnep.h /^ NEP_STOP_USER } NEPStop;$/;" t typeref:enum:__anon35 NEPStoppingBasic src/nep/interface/nepdefault.c /^PetscErrorCode NEPStoppingBasic(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)$/;" f NEPTOARCoefficients src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPTOARCoefficients(NEP nep,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x,PetscScalar *work)$/;" f file: NEPTOARExtendBasis src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPTOARExtendBasis(NEP nep,PetscInt idxrktg,PetscScalar *S,PetscInt ls,PetscInt nv,BV V,Vec t,PetscScalar *r,PetscInt lr,Vec *t_)$/;" f file: NEPTOAROrth2 src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPTOAROrth2(NEP nep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work)$/;" f file: NEPTOARSNorm2 src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm)$/;" f file: NEPTOARSupdate src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)$/;" f file: NEPTOARTrunc src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NEPTOARTrunc(NEP nep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt *nq,PetscInt cs1,PetscScalar *work,PetscReal *rwork)$/;" f file: NEPType include/slepc/finclude/slepcnepdef.h 37;" d NEPType include/slepcnep.h /^typedef const char* NEPType;$/;" t NEPUserInterface include/slepc/private/nepimpl.h /^ NEP_USER_INTERFACE_DERIVATIVES } NEPUserInterface;$/;" t typeref:enum:__anon3 NEPValuesView src/nep/interface/nepview.c /^PetscErrorCode NEPValuesView(NEP nep,PetscViewer viewer)$/;" f NEPValuesViewFromOptions src/nep/interface/nepview.c /^PetscErrorCode NEPValuesViewFromOptions(NEP nep)$/;" f NEPValuesView_ASCII src/nep/interface/nepview.c /^static PetscErrorCode NEPValuesView_ASCII(NEP nep,PetscViewer viewer)$/;" f file: NEPValuesView_DRAW src/nep/interface/nepview.c /^static PetscErrorCode NEPValuesView_DRAW(NEP nep,PetscViewer viewer)$/;" f file: NEPValuesView_MATLAB src/nep/interface/nepview.c /^static PetscErrorCode NEPValuesView_MATLAB(NEP nep,PetscViewer viewer)$/;" f file: NEPVectorsView src/nep/interface/nepview.c /^PetscErrorCode NEPVectorsView(NEP nep,PetscViewer viewer)$/;" f NEPVectorsViewFromOptions src/nep/interface/nepview.c /^PetscErrorCode NEPVectorsViewFromOptions(NEP nep)$/;" f NEPView src/nep/interface/nepview.c /^PetscErrorCode NEPView(NEP nep,PetscViewer viewer)$/;" f NEPViewFromOptions include/slepcnep.h /^PETSC_STATIC_INLINE PetscErrorCode NEPViewFromOptions(NEP nep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)nep,obj,name);}$/;" f NEPView_CISS src/nep/impls/ciss/nciss.c /^PetscErrorCode NEPView_CISS(NEP nep,PetscViewer viewer)$/;" f NEPView_Interpol src/nep/impls/interpol/interpol.c /^PetscErrorCode NEPView_Interpol(NEP nep,PetscViewer viewer)$/;" f NEPView_NArnoldi src/nep/impls/narnoldi/narnoldi.c /^PetscErrorCode NEPView_NArnoldi(NEP nep,PetscViewer viewer)$/;" f NEPView_NLEIGS src/nep/impls/nleigs/nleigs.c /^PetscErrorCode NEPView_NLEIGS(NEP nep,PetscViewer viewer)$/;" f NEPView_RII src/nep/impls/rii/rii.c /^PetscErrorCode NEPView_RII(NEP nep,PetscViewer viewer)$/;" f NEPView_SLP src/nep/impls/slp/slp.c /^PetscErrorCode NEPView_SLP(NEP nep,PetscViewer viewer)$/;" f NEPWhich include/slepc/finclude/slepcnepdef.h 40;" d NEPWhich include/slepcnep.h /^ NEP_WHICH_USER } NEPWhich;$/;" t typeref:enum:__anon30 NEP_ALL include/slepcnep.h /^ NEP_ALL,$/;" e enum:__anon30 NEP_CISS src/nep/impls/ciss/nciss.c /^} NEP_CISS;$/;" t typeref:struct:__anon89 file: NEP_CLASSID include/slepcnep.h /^PETSC_EXTERN PetscClassId NEP_CLASSID;$/;" v NEP_CLASSID src/nep/interface/nepbasic.c /^PetscClassId NEP_CLASSID = 0;$/;" v NEP_CONVERGED_ITERATING include/slepcnep.h /^ NEP_CONVERGED_ITERATING = 0} NEPConvergedReason;$/;" e enum:__anon36 NEP_CONVERGED_TOL include/slepcnep.h /^ NEP_CONVERGED_TOL = 1,$/;" e enum:__anon36 NEP_CONVERGED_USER include/slepcnep.h /^ NEP_CONVERGED_USER = 2,$/;" e enum:__anon36 NEP_CONV_ABS include/slepcnep.h /^typedef enum { NEP_CONV_ABS,$/;" e enum:__anon34 NEP_CONV_NORM include/slepcnep.h /^ NEP_CONV_NORM,$/;" e enum:__anon34 NEP_CONV_REL include/slepcnep.h /^ NEP_CONV_REL,$/;" e enum:__anon34 NEP_CONV_USER include/slepcnep.h /^ NEP_CONV_USER } NEPConv;$/;" e enum:__anon34 NEP_DIVERGED_BREAKDOWN include/slepcnep.h /^ NEP_DIVERGED_BREAKDOWN = -2,$/;" e enum:__anon36 NEP_DIVERGED_ITS include/slepcnep.h /^ NEP_DIVERGED_ITS = -1,$/;" e enum:__anon36 NEP_DIVERGED_LINEAR_SOLVE include/slepcnep.h /^ NEP_DIVERGED_LINEAR_SOLVE = -4,$/;" e enum:__anon36 NEP_DerivativesEval include/slepc/private/nepimpl.h /^PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;$/;" v NEP_DerivativesEval src/nep/interface/nepbasic.c /^PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;$/;" v NEP_ERROR_ABSOLUTE include/slepcnep.h /^typedef enum { NEP_ERROR_ABSOLUTE,$/;" e enum:__anon31 NEP_ERROR_BACKWARD include/slepcnep.h /^ NEP_ERROR_BACKWARD } NEPErrorType;$/;" e enum:__anon31 NEP_ERROR_RELATIVE include/slepcnep.h /^ NEP_ERROR_RELATIVE,$/;" e enum:__anon31 NEP_FunctionEval include/slepc/private/nepimpl.h /^PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;$/;" v NEP_FunctionEval src/nep/interface/nepbasic.c /^PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;$/;" v NEP_INTERPOL src/nep/impls/interpol/interpol.c /^} NEP_INTERPOL;$/;" t typeref:struct:__anon90 file: NEP_JacobianEval include/slepc/private/nepimpl.h /^PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;$/;" v NEP_JacobianEval src/nep/interface/nepbasic.c /^PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;$/;" v NEP_LARGEST_IMAGINARY include/slepcnep.h /^ NEP_LARGEST_IMAGINARY,$/;" e enum:__anon30 NEP_LARGEST_MAGNITUDE include/slepcnep.h /^typedef enum { NEP_LARGEST_MAGNITUDE=1,$/;" e enum:__anon30 NEP_LARGEST_REAL include/slepcnep.h /^ NEP_LARGEST_REAL,$/;" e enum:__anon30 NEP_NARNOLDI src/nep/impls/narnoldi/narnoldi.c /^} NEP_NARNOLDI;$/;" t typeref:struct:__anon91 file: NEP_NLEIGS src/nep/impls/nleigs/nleigs.c /^} NEP_NLEIGS;$/;" t typeref:struct:__anon92 file: NEP_REFINE_MULTIPLE include/slepcnep.h /^ NEP_REFINE_MULTIPLE } NEPRefine;$/;" e enum:__anon32 NEP_REFINE_NONE include/slepcnep.h /^typedef enum { NEP_REFINE_NONE,$/;" e enum:__anon32 NEP_REFINE_SCHEME_EXPLICIT include/slepcnep.h /^ NEP_REFINE_SCHEME_EXPLICIT } NEPRefineScheme;$/;" e enum:__anon33 NEP_REFINE_SCHEME_MBE include/slepcnep.h /^ NEP_REFINE_SCHEME_MBE,$/;" e enum:__anon33 NEP_REFINE_SCHEME_SCHUR include/slepcnep.h /^typedef enum { NEP_REFINE_SCHEME_SCHUR=1,$/;" e enum:__anon33 NEP_REFINE_SIMPLE include/slepcnep.h /^ NEP_REFINE_SIMPLE,$/;" e enum:__anon32 NEP_RII src/nep/impls/rii/rii.c /^} NEP_RII;$/;" t typeref:struct:__anon94 file: NEP_Refine include/slepc/private/nepimpl.h /^PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;$/;" v NEP_Refine src/nep/interface/nepbasic.c /^PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;$/;" v NEP_SLP src/nep/impls/slp/slp.c /^} NEP_SLP;$/;" t typeref:struct:__anon95 file: NEP_SMALLEST_IMAGINARY include/slepcnep.h /^ NEP_SMALLEST_IMAGINARY,$/;" e enum:__anon30 NEP_SMALLEST_MAGNITUDE include/slepcnep.h /^ NEP_SMALLEST_MAGNITUDE,$/;" e enum:__anon30 NEP_SMALLEST_REAL include/slepcnep.h /^ NEP_SMALLEST_REAL,$/;" e enum:__anon30 NEP_STATE_EIGENVECTORS include/slepc/private/nepimpl.h /^ NEP_STATE_EIGENVECTORS } NEPStateType;$/;" e enum:__anon2 NEP_STATE_INITIAL include/slepc/private/nepimpl.h /^typedef enum { NEP_STATE_INITIAL,$/;" e enum:__anon2 NEP_STATE_SETUP include/slepc/private/nepimpl.h /^ NEP_STATE_SETUP,$/;" e enum:__anon2 NEP_STATE_SOLVED include/slepc/private/nepimpl.h /^ NEP_STATE_SOLVED,$/;" e enum:__anon2 NEP_STOP_BASIC include/slepcnep.h /^typedef enum { NEP_STOP_BASIC,$/;" e enum:__anon35 NEP_STOP_USER include/slepcnep.h /^ NEP_STOP_USER } NEPStop;$/;" e enum:__anon35 NEP_SetUp include/slepc/private/nepimpl.h /^PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;$/;" v NEP_SetUp src/nep/interface/nepbasic.c /^PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;$/;" v NEP_Solve include/slepc/private/nepimpl.h /^PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;$/;" v NEP_Solve src/nep/interface/nepbasic.c /^PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;$/;" v NEP_TARGET_IMAGINARY include/slepcnep.h /^ NEP_TARGET_IMAGINARY,$/;" e enum:__anon30 NEP_TARGET_MAGNITUDE include/slepcnep.h /^ NEP_TARGET_MAGNITUDE,$/;" e enum:__anon30 NEP_TARGET_REAL include/slepcnep.h /^ NEP_TARGET_REAL,$/;" e enum:__anon30 NEP_USER_INTERFACE_CALLBACK include/slepc/private/nepimpl.h /^typedef enum { NEP_USER_INTERFACE_CALLBACK=1,$/;" e enum:__anon3 NEP_USER_INTERFACE_DERIVATIVES include/slepc/private/nepimpl.h /^ NEP_USER_INTERFACE_DERIVATIVES } NEPUserInterface;$/;" e enum:__anon3 NEP_USER_INTERFACE_SPLIT include/slepc/private/nepimpl.h /^ NEP_USER_INTERFACE_SPLIT,$/;" e enum:__anon3 NEP_WHICH_USER include/slepcnep.h /^ NEP_WHICH_USER } NEPWhich;$/;" e enum:__anon30 NL src/pep/examples/nlevp/planar_waveguide.c 41;" d file: NLEIGSMatToMatShellArray src/nep/impls/nleigs/nleigs.c /^static PetscErrorCode NLEIGSMatToMatShellArray(Mat M,Mat *Ms)$/;" f file: NMAT src/nep/examples/nlevp/gun.c 42;" d file: NMAT src/nep/examples/nlevp/loaded_string.c 41;" d file: NMAT src/pep/examples/nlevp/butterfly.c 39;" d file: NMAT src/pep/examples/nlevp/pdde_stability.c 41;" d file: NMAT src/pep/examples/nlevp/planar_waveguide.c 40;" d file: NMLEN src/eps/interface/epsview.c 748;" d file: NMLEN src/nep/interface/nepview.c 702;" d file: NMLEN src/pep/interface/pepview.c 722;" d file: NMLEN src/svd/interface/svdview.c 550;" d file: NOWARNDIRS config/cmakegen.py /^NOWARNDIRS = set('tests tutorials'.split()) # Do not warn about mismatch in these$/;" v NREF_MAXIT src/nep/interface/neprefine.c 27;" d file: NREF_MAXIT src/pep/interface/peprefine.c 27;" d file: NRefOrthogStep src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefOrthogStep(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscInt *prs)$/;" f file: NRefRightSide src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefRightSide(PetscInt nmat,PetscReal *pcf,Mat *A,PetscInt k,BV V,PetscScalar *S,PetscInt lds,PetscInt j,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *DfH,PetscScalar *dH,BV dV,PetscScalar *dVS,PetscInt rds,Vec Rv,PetscScalar *Rh,BV W,Vec t)$/;" f file: NRefSubcommDestroy src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSubcommDestroy(PEP pep,MatExplicitCtx *matctx)$/;" f file: NRefSubcommSetup src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSubcommSetup(PEP pep,PetscInt k,MatExplicitCtx *matctx,PetscInt nsubc)$/;" f file: NRefSysIter src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSysIter(PetscInt i,PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar *H,PetscInt ldh,Vec Rv,PetscScalar *Rh,BV V,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx,BV W)$/;" f file: NRefSysSetup_explicit src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSysSetup_explicit(PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,BV V,MatExplicitCtx *matctx,BV W)$/;" f file: NRefSysSetup_mbe src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSysSetup_mbe(PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,BV V,MatExplicitCtx *matctx)$/;" f file: NRefSysSetup_shell src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSysSetup_shell(PEP pep,PetscInt k,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,FSubctx *ctx)$/;" f file: NRefSysSolve_explicit src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSysSolve_explicit(PetscInt k,KSP ksp,Vec Rv,PetscScalar *Rh,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx)$/;" f file: NRefSysSolve_mbe src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSysSolve_mbe(PetscInt k,PetscInt sz,BV W,PetscScalar *w,BV Wt,PetscScalar *wt,PetscScalar *d,PetscScalar *dt,KSP ksp,BV T2,BV T3 ,PetscScalar *T4,PetscBool trans,Vec x1,PetscScalar *x2,Vec sol1,PetscScalar *sol2,Vec vw)$/;" f file: NRefSysSolve_shell src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode NRefSysSolve_shell(KSP ksp,PetscInt nmat,Vec Rv,PetscScalar *Rh,PetscInt k,Vec dVi,PetscScalar *dHi)$/;" f file: NewSection config/log.py /^ def NewSection(self,string):$/;" m class:Log OP include/slepc/private/svdimpl.h /^ Mat OP; \/* problem matrix *\/$/;" m struct:_p_SVD OPTLEN src/pep/interface/pepsolve.c 112;" d file: Open config/log.py /^ def Open(self,filename):$/;" m class:Log OperatorAMultiVector src/eps/impls/external/blopex/blopex.c /^static void OperatorAMultiVector(void *data,void *x,void *y)$/;" f file: OperatorASingleVector src/eps/impls/external/blopex/blopex.c /^static void OperatorASingleVector(void *data,void *x,void *y)$/;" f file: OperatorBMultiVector src/eps/impls/external/blopex/blopex.c /^static void OperatorBMultiVector(void *data,void *x,void *y)$/;" f file: OperatorBSingleVector src/eps/impls/external/blopex/blopex.c /^static void OperatorBSingleVector(void *data,void *x,void *y)$/;" f file: P include/slepc/private/stimpl.h /^ Mat P; \/* matrix from which preconditioner is built *\/$/;" m struct:_p_ST P src/eps/impls/cg/rqcg/rqcg.c /^ BV AV,W,P,G;$/;" m struct:__anon60 file: P src/pep/impls/jd/pjdp.h /^ Mat P; \/* *\/$/;" m struct:__anon101 PARMAX src/sys/classes/fn/impls/rational/fnrational.c 488;" d file: PCApplyBA_dvd src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode PCApplyBA_dvd(PC pc,PCSide side,Vec in,Vec out,Vec w)$/;" f file: PCApplyTranspose_dvd src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode PCApplyTranspose_dvd(PC pc,Vec in,Vec out)$/;" f file: PCApply_User src/eps/examples/tests/test12.c /^PetscErrorCode PCApply_User(PC pc,Vec x,Vec y)$/;" f PCApply_dvd src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode PCApply_dvd(PC pc,Vec in,Vec out)$/;" f file: PCShellApply_PEPJD src/pep/impls/jd/pjd.c /^static PetscErrorCode PCShellApply_PEPJD(PC pc,Vec x,Vec y)$/;" f file: PD0 src/eps/examples/tutorials/ex31.c /^const PetscScalar PD0[3] = {1.25,0.9,1.0};$/;" v PEP include/slepc/finclude/slepcpepdef.h 33;" d PEP include/slepcpep.h /^typedef struct _p_PEP* PEP;$/;" t typeref:struct:_p_PEP PEP src/pep/examples/tests/makefile /^PEP = toar qarnoldi$/;" m PEPAllocateSolution src/pep/interface/pepsetup.c /^PetscErrorCode PEPAllocateSolution(PEP pep,PetscInt extra)$/;" f PEPAppendOptionsPrefix src/pep/interface/pepopts.c /^PetscErrorCode PEPAppendOptionsPrefix(PEP pep,const char *prefix)$/;" f PEPBackTransform_Default src/pep/interface/pepdefault.c /^PetscErrorCode PEPBackTransform_Default(PEP pep)$/;" f PEPBasis include/slepc/finclude/slepcpepdef.h 39;" d PEPBasis include/slepcpep.h /^ PEP_BASIS_HERMITE } PEPBasis;$/;" t typeref:enum:__anon39 PEPBasisCoefficients src/pep/interface/pepdefault.c /^PetscErrorCode PEPBasisCoefficients(PEP pep,PetscReal *pbc)$/;" f PEPBasisTypes include/slepcpep.h /^PETSC_EXTERN const char *PEPBasisTypes[];$/;" v PEPBasisTypes src/pep/interface/dlregispep.c /^const char *PEPBasisTypes[] = {"MONOMIAL","CHEBYSHEV1","CHEBYSHEV2","LEGENDRE","LAGUERRE","HERMITE","PEPBasis","PEP_BASIS_",0};$/;" v PEPBuildDiagonalScaling src/pep/interface/pepdefault.c /^PetscErrorCode PEPBuildDiagonalScaling(PEP pep)$/;" f PEPCheckSolved include/slepc/private/pepimpl.h 137;" d PEPCheckSolved include/slepc/private/pepimpl.h 141;" d PEPComputeError src/pep/interface/pepsolve.c /^PetscErrorCode PEPComputeError(PEP pep,PetscInt i,PEPErrorType type,PetscReal *error)$/;" f PEPComputeRelativeError include/slepcpep.h /^PETSC_DEPRECATED("Use PEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode PEPComputeRelativeError(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_BACKWARD,r);}$/;" f PEPComputeResidualNorm include/slepcpep.h /^PETSC_DEPRECATED("Use PEPComputeError() with PEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode PEPComputeResidualNorm(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_ABSOLUTE,r);}$/;" f PEPComputeResidualNorm_Private src/pep/interface/pepsolve.c /^PetscErrorCode PEPComputeResidualNorm_Private(PEP pep,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm)$/;" f PEPComputeScaleFactor src/pep/interface/pepdefault.c /^PetscErrorCode PEPComputeScaleFactor(PEP pep)$/;" f PEPComputeVectors src/pep/interface/pepsolve.c /^PetscErrorCode PEPComputeVectors(PEP pep)$/;" f PEPComputeVectors_Default src/pep/interface/pepdefault.c /^PetscErrorCode PEPComputeVectors_Default(PEP pep)$/;" f PEPConv include/slepc/finclude/slepcpepdef.h 44;" d PEPConv include/slepcpep.h /^ PEP_CONV_USER } PEPConv;$/;" t typeref:enum:__anon45 PEPConvMonitorSetFromOptions src/pep/interface/pepopts.c /^PetscErrorCode PEPConvMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))$/;" f PEPConvergedAbsolute src/pep/interface/pepdefault.c /^PetscErrorCode PEPConvergedAbsolute(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f PEPConvergedNorm src/pep/interface/pepdefault.c /^PetscErrorCode PEPConvergedNorm(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f PEPConvergedReason include/slepc/finclude/slepcpepdef.h 47;" d PEPConvergedReason include/slepcpep.h /^ PEP_CONVERGED_ITERATING = 0} PEPConvergedReason;$/;" t typeref:enum:__anon47 PEPConvergedReasons include/slepcpep.h /^PETSC_EXTERN const char *const*PEPConvergedReasons;$/;" v PEPConvergedReasons src/pep/interface/dlregispep.c /^const char *const*PEPConvergedReasons = PEPConvergedReasons_Shifted + 4;$/;" v PEPConvergedReasons_Shifted src/pep/interface/dlregispep.c /^const char *const PEPConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","PEPConvergedReason","PEP_",0};$/;" v PEPConvergedRelative src/pep/interface/pepdefault.c /^PetscErrorCode PEPConvergedRelative(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f PEPCreate src/pep/interface/pepbasic.c /^PetscErrorCode PEPCreate(MPI_Comm comm,PEP *outpep)$/;" f PEPCreate_JD src/pep/impls/jd/pjd.c /^PETSC_EXTERN PetscErrorCode PEPCreate_JD(PEP pep)$/;" f PEPCreate_Linear src/pep/impls/linear/linear.c /^PETSC_EXTERN PetscErrorCode PEPCreate_Linear(PEP pep)$/;" f PEPCreate_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PETSC_EXTERN PetscErrorCode PEPCreate_QArnoldi(PEP pep)$/;" f PEPCreate_STOAR src/pep/impls/krylov/stoar/stoar.c /^PETSC_EXTERN PetscErrorCode PEPCreate_STOAR(PEP pep)$/;" f PEPCreate_TOAR src/pep/impls/krylov/toar/ptoar.c /^PETSC_EXTERN PetscErrorCode PEPCreate_TOAR(PEP pep)$/;" f PEPDestroy src/pep/interface/pepbasic.c /^PetscErrorCode PEPDestroy(PEP *pep)$/;" f PEPDestroy_JD src/pep/impls/jd/pjd.c /^PetscErrorCode PEPDestroy_JD(PEP pep)$/;" f PEPDestroy_Linear src/pep/impls/linear/linear.c /^PetscErrorCode PEPDestroy_Linear(PEP pep)$/;" f PEPDestroy_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPDestroy_QArnoldi(PEP pep)$/;" f PEPDestroy_STOAR src/pep/impls/krylov/stoar/stoar.c /^PetscErrorCode PEPDestroy_STOAR(PEP pep)$/;" f PEPDestroy_TOAR src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPDestroy_TOAR(PEP pep)$/;" f PEPErrorType include/slepc/finclude/slepcpepdef.h 46;" d PEPErrorType include/slepcpep.h /^ PEP_ERROR_BACKWARD } PEPErrorType;$/;" t typeref:enum:__anon44 PEPErrorTypes include/slepcpep.h /^PETSC_EXTERN const char *PEPErrorTypes[];$/;" v PEPErrorTypes src/pep/interface/dlregispep.c /^const char *PEPErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","PEPErrorType","PEP_ERROR_",0};$/;" v PEPErrorView src/pep/interface/pepview.c /^PetscErrorCode PEPErrorView(PEP pep,PEPErrorType etype,PetscViewer viewer)$/;" f PEPErrorViewFromOptions src/pep/interface/pepview.c /^PetscErrorCode PEPErrorViewFromOptions(PEP pep)$/;" f PEPErrorView_ASCII src/pep/interface/pepview.c /^static PetscErrorCode PEPErrorView_ASCII(PEP pep,PEPErrorType etype,PetscViewer viewer)$/;" f file: PEPErrorView_DETAIL src/pep/interface/pepview.c /^static PetscErrorCode PEPErrorView_DETAIL(PEP pep,PEPErrorType etype,PetscViewer viewer)$/;" f file: PEPErrorView_MATLAB src/pep/interface/pepview.c /^static PetscErrorCode PEPErrorView_MATLAB(PEP pep,PEPErrorType etype,PetscViewer viewer)$/;" f file: PEPEvaluateBasis src/pep/interface/pepdefault.c /^PetscErrorCode PEPEvaluateBasis(PEP pep,PetscScalar sigma,PetscScalar isigma,PetscScalar *vals,PetscScalar *ivals)$/;" f PEPEvaluateBasisM src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPEvaluateBasisM(PEP pep,PetscInt k,PetscScalar *T,PetscInt ldt,PetscInt idx,PetscScalar **Tp,PetscScalar **Tj)$/;" f file: PEPEvaluateBasisforMatrix src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode PEPEvaluateBasisforMatrix(PEP pep,PetscInt nm,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH)$/;" f file: PEPEvaluateFunctionDerivatives src/pep/interface/peprefine.c /^static PetscErrorCode PEPEvaluateFunctionDerivatives(PEP pep,PetscScalar alpha,PetscScalar *vals)$/;" f file: PEPExtract include/slepc/finclude/slepcpepdef.h 43;" d PEPExtract include/slepcpep.h /^ PEP_EXTRACT_STRUCTURED } PEPExtract;$/;" t typeref:enum:__anon43 PEPExtractInvariantPair src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPExtractInvariantPair(PEP pep,PetscScalar sigma,PetscInt sr,PetscInt k,PetscScalar *S,PetscInt ld,PetscInt deg,PetscScalar *H,PetscInt ldh,PetscScalar *work)$/;" f file: PEPExtractTypes include/slepcpep.h /^PETSC_EXTERN const char *PEPExtractTypes[];$/;" v PEPExtractTypes src/pep/interface/dlregispep.c /^const char *PEPExtractTypes[] = {"","NONE","NORM","RESIDUAL","STRUCTURED","PEPExtract","PEP_EXTRACT_",0};$/;" v PEPExtractVectors src/pep/interface/pepsolve.c /^PetscErrorCode PEPExtractVectors(PEP pep)$/;" f PEPExtractVectors_Linear src/pep/impls/linear/linear.c /^PetscErrorCode PEPExtractVectors_Linear(PEP pep)$/;" f PEPExtractVectors_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPExtractVectors_QArnoldi(PEP pep)$/;" f PEPExtractVectors_TOAR src/pep/impls/krylov/pepkrylov.c /^PetscErrorCode PEPExtractVectors_TOAR(PEP pep)$/;" f PEPFinalizePackage src/pep/interface/dlregispep.c /^PetscErrorCode PEPFinalizePackage(void)$/;" f PEPGetBV src/pep/interface/pepbasic.c /^PetscErrorCode PEPGetBV(PEP pep,BV *bv)$/;" f PEPGetBasis src/pep/interface/pepopts.c /^PetscErrorCode PEPGetBasis(PEP pep,PEPBasis *basis)$/;" f PEPGetConverged src/pep/interface/pepsolve.c /^PetscErrorCode PEPGetConverged(PEP pep,PetscInt *nconv)$/;" f PEPGetConvergedReason src/pep/interface/pepsolve.c /^PetscErrorCode PEPGetConvergedReason(PEP pep,PEPConvergedReason *reason)$/;" f PEPGetConvergenceTest src/pep/interface/pepopts.c /^PetscErrorCode PEPGetConvergenceTest(PEP pep,PEPConv *conv)$/;" f PEPGetDS src/pep/interface/pepbasic.c /^PetscErrorCode PEPGetDS(PEP pep,DS *ds)$/;" f PEPGetDimensions src/pep/interface/pepopts.c /^PetscErrorCode PEPGetDimensions(PEP pep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)$/;" f PEPGetEigenpair src/pep/interface/pepsolve.c /^PetscErrorCode PEPGetEigenpair(PEP pep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)$/;" f PEPGetErrorEstimate src/pep/interface/pepsolve.c /^PetscErrorCode PEPGetErrorEstimate(PEP pep,PetscInt i,PetscReal *errest)$/;" f PEPGetExtract src/pep/interface/pepopts.c /^PetscErrorCode PEPGetExtract(PEP pep,PEPExtract *extract)$/;" f PEPGetIterationNumber src/pep/interface/pepsolve.c /^PetscErrorCode PEPGetIterationNumber(PEP pep,PetscInt *its)$/;" f PEPGetMonitorContext src/pep/interface/pepmon.c /^PetscErrorCode PEPGetMonitorContext(PEP pep,void **ctx)$/;" f PEPGetNumMatrices src/pep/interface/pepsetup.c /^PetscErrorCode PEPGetNumMatrices(PEP pep,PetscInt *nmat)$/;" f PEPGetOperators src/pep/interface/pepsetup.c /^PetscErrorCode PEPGetOperators(PEP pep,PetscInt k,Mat *A)$/;" f PEPGetOptionsPrefix src/pep/interface/pepopts.c /^PetscErrorCode PEPGetOptionsPrefix(PEP pep,const char *prefix[])$/;" f PEPGetProblemType src/pep/interface/pepopts.c /^PetscErrorCode PEPGetProblemType(PEP pep,PEPProblemType *type)$/;" f PEPGetRG src/pep/interface/pepbasic.c /^PetscErrorCode PEPGetRG(PEP pep,RG *rg)$/;" f PEPGetRefine src/pep/interface/pepopts.c /^PetscErrorCode PEPGetRefine(PEP pep,PEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,PEPRefineScheme *scheme)$/;" f PEPGetST src/pep/interface/pepbasic.c /^PetscErrorCode PEPGetST(PEP pep,ST *st)$/;" f PEPGetScale src/pep/interface/pepopts.c /^PetscErrorCode PEPGetScale(PEP pep,PEPScale *scale,PetscReal *alpha,Vec *Dl,Vec *Dr,PetscInt *its,PetscReal *lambda)$/;" f PEPGetStoppingTest src/pep/interface/pepopts.c /^PetscErrorCode PEPGetStoppingTest(PEP pep,PEPStop *stop)$/;" f PEPGetTarget src/pep/interface/pepbasic.c /^PetscErrorCode PEPGetTarget(PEP pep,PetscScalar* target)$/;" f PEPGetTolerances src/pep/interface/pepopts.c /^PetscErrorCode PEPGetTolerances(PEP pep,PetscReal *tol,PetscInt *maxits)$/;" f PEPGetTrackAll src/pep/interface/pepopts.c /^PetscErrorCode PEPGetTrackAll(PEP pep,PetscBool *trackall)$/;" f PEPGetType src/pep/interface/pepbasic.c /^PetscErrorCode PEPGetType(PEP pep,PEPType *type)$/;" f PEPGetWhichEigenpairs src/pep/interface/pepopts.c /^PetscErrorCode PEPGetWhichEigenpairs(PEP pep,PEPWhich *which)$/;" f PEPInitializePackage src/pep/interface/dlregispep.c /^PetscErrorCode PEPInitializePackage(void)$/;" f PEPJD include/slepc/finclude/slepcpepdef.h 53;" d PEPJD include/slepcpep.h 52;" d PEPJDComputePResidual src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDComputePResidual(PEP pep,Vec u,PetscScalar theta,Vec p,Vec *work)$/;" f file: PEPJDCopyToExtendedVec src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDCopyToExtendedVec(PEP pep,Vec v,PetscScalar *a,PetscInt na,PetscInt off,Vec vex,PetscBool back)$/;" f file: PEPJDCreateShellPC src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDCreateShellPC(PEP pep)$/;" f file: PEPJDDuplicateBasis src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDDuplicateBasis(PEP pep,BV *basis)$/;" f file: PEPJDEigenvectors src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDEigenvectors(PEP pep)$/;" f file: PEPJDExtendedPCApply src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDExtendedPCApply(PC pc,Vec x,Vec y)$/;" f file: PEPJDGetRestart src/pep/impls/jd/pjdopt.c /^PetscErrorCode PEPJDGetRestart(PEP pep,PetscReal *keep)$/;" f PEPJDGetRestart_JD src/pep/impls/jd/pjdopt.c /^PetscErrorCode PEPJDGetRestart_JD(PEP pep,PetscReal *keep)$/;" f PEPJDLockConverged src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDLockConverged(PEP pep,PetscInt *nv)$/;" f file: PEPJDOrthogonalize src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDOrthogonalize(PetscInt row,PetscInt col,PetscScalar *X,PetscInt ldx,PetscInt *rk,PetscInt *P,PetscScalar *R,PetscInt ldr)$/;" f file: PEPJDPCMatSetUp src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDPCMatSetUp(PEP pep,PetscScalar theta)$/;" f file: PEPJDProcessInitialSpace src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDProcessInitialSpace(PEP pep,Vec *w)$/;" f file: PEPJDSetRestart src/pep/impls/jd/pjdopt.c /^PetscErrorCode PEPJDSetRestart(PEP pep,PetscReal keep)$/;" f PEPJDSetRestart_JD src/pep/impls/jd/pjdopt.c /^PetscErrorCode PEPJDSetRestart_JD(PEP pep,PetscReal keep)$/;" f PEPJDShellMatMult src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDShellMatMult(Mat P,Vec x,Vec y)$/;" f file: PEPJDUpdateExtendedPC src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDUpdateExtendedPC(PEP pep,PetscScalar theta)$/;" f file: PEPJDUpdateTV src/pep/impls/jd/pjd.c /^static PetscErrorCode PEPJDUpdateTV(PEP pep,PetscInt low,PetscInt high,Vec *w)$/;" f file: PEPKrylovConvergence src/pep/interface/pepdefault.c /^PetscErrorCode PEPKrylovConvergence(PEP pep,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscInt *kout)$/;" f PEPLINEAR include/slepc/finclude/slepcpepdef.h 49;" d PEPLINEAR include/slepcpep.h 48;" d PEPLinearExtract_None src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearExtract_None(PEP pep,EPS eps)$/;" f file: PEPLinearExtract_Norm src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearExtract_Norm(PEP pep,EPS eps)$/;" f file: PEPLinearExtract_Residual src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearExtract_Residual(PEP pep,EPS eps)$/;" f file: PEPLinearGetCompanionForm src/pep/impls/linear/linear.c /^PetscErrorCode PEPLinearGetCompanionForm(PEP pep,PetscInt *cform)$/;" f PEPLinearGetCompanionForm_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearGetCompanionForm_Linear(PEP pep,PetscInt *cform)$/;" f file: PEPLinearGetEPS src/pep/impls/linear/linear.c /^PetscErrorCode PEPLinearGetEPS(PEP pep,EPS *eps)$/;" f PEPLinearGetEPS_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearGetEPS_Linear(PEP pep,EPS *eps)$/;" f file: PEPLinearGetExplicitMatrix src/pep/impls/linear/linear.c /^PetscErrorCode PEPLinearGetExplicitMatrix(PEP pep,PetscBool *explicitmatrix)$/;" f PEPLinearGetExplicitMatrix_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearGetExplicitMatrix_Linear(PEP pep,PetscBool *explicitmatrix)$/;" f file: PEPLinearSetCompanionForm src/pep/impls/linear/linear.c /^PetscErrorCode PEPLinearSetCompanionForm(PEP pep,PetscInt cform)$/;" f PEPLinearSetCompanionForm_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearSetCompanionForm_Linear(PEP pep,PetscInt cform)$/;" f file: PEPLinearSetEPS src/pep/impls/linear/linear.c /^PetscErrorCode PEPLinearSetEPS(PEP pep,EPS eps)$/;" f PEPLinearSetEPS_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearSetEPS_Linear(PEP pep,EPS eps)$/;" f file: PEPLinearSetExplicitMatrix src/pep/impls/linear/linear.c /^PetscErrorCode PEPLinearSetExplicitMatrix(PEP pep,PetscBool explicitmatrix)$/;" f PEPLinearSetExplicitMatrix_Linear src/pep/impls/linear/linear.c /^static PetscErrorCode PEPLinearSetExplicitMatrix_Linear(PEP pep,PetscBool explicitmatrix)$/;" f file: PEPList include/slepcpep.h /^PETSC_EXTERN PetscFunctionList PEPList;$/;" v PEPList src/pep/interface/pepbasic.c /^PetscFunctionList PEPList = 0;$/;" v PEPMonitor src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitor(PEP pep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)$/;" f PEPMonitorAll src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f PEPMonitorCancel src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorCancel(PEP pep)$/;" f PEPMonitorConverged src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorConverged(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)$/;" f PEPMonitorFirst src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorFirst(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f PEPMonitorGetTrueEig src/pep/interface/pepmon.c /^static PetscErrorCode PEPMonitorGetTrueEig(PEP pep,PetscScalar *er,PetscScalar *ei)$/;" f file: PEPMonitorLG src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorLG(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f PEPMonitorLGAll src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorLGAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f PEPMonitorLGCreate src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)$/;" f PEPMonitorSet src/pep/interface/pepmon.c /^PetscErrorCode PEPMonitorSet(PEP pep,PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))$/;" f PEPMonitorSetFromOptions src/pep/interface/pepopts.c /^PetscErrorCode PEPMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)$/;" f PEPMonitor_Interpol src/nep/impls/interpol/interpol.c /^static PetscErrorCode PEPMonitor_Interpol(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)$/;" f file: PEPNRefForwardSubstitution src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode PEPNRefForwardSubstitution(PEP pep,PetscInt k,PetscScalar *S,PetscInt lds,PetscScalar *H,PetscInt ldh,PetscScalar *fH,BV dV,PetscScalar *dVS,PetscInt *rds,PetscScalar *dH,PetscInt lddh,KSP ksp,MatExplicitCtx *matctx)$/;" f file: PEPNRefSetUp src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode PEPNRefSetUp(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,MatExplicitCtx *matctx,PetscBool ini)$/;" f file: PEPNRefUpdateInvPair src/pep/impls/krylov/toar/nrefine.c /^static PetscErrorCode PEPNRefUpdateInvPair(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *dH,PetscScalar *S,PetscInt lds,BV dV,PetscScalar *dVS,PetscInt rds)$/;" f file: PEPNewtonRefinementSimple src/pep/interface/peprefine.c /^PetscErrorCode PEPNewtonRefinementSimple(PEP pep,PetscInt *maxits,PetscReal tol,PetscInt k)$/;" f PEPNewtonRefinement_TOAR src/pep/impls/krylov/toar/nrefine.c /^PetscErrorCode PEPNewtonRefinement_TOAR(PEP pep,PetscScalar sigma,PetscInt *maxits,PetscReal *tol,PetscInt k,PetscScalar *S,PetscInt lds,PetscInt *prs)$/;" f PEPOps include/slepc/private/pepimpl.h /^typedef struct _PEPOps *PEPOps;$/;" t typeref:struct:_PEPOps PEPPackageInitialized src/pep/interface/dlregispep.c /^static PetscBool PEPPackageInitialized = PETSC_FALSE;$/;" v file: PEPPrintSolution include/slepcpep.h /^PETSC_DEPRECATED("Use PEPErrorView()") PETSC_STATIC_INLINE PetscErrorCode PEPPrintSolution(PEP pep,PetscViewer v) {return PEPErrorView(pep,PEP_ERROR_BACKWARD,v);}$/;" f PEPProblemType include/slepc/finclude/slepcpepdef.h 37;" d PEPProblemType include/slepcpep.h /^ } PEPProblemType;$/;" t typeref:enum:__anon37 PEPQARNOLDI include/slepc/finclude/slepcpepdef.h 50;" d PEPQARNOLDI include/slepcpep.h 49;" d PEPQArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^static PetscErrorCode PEPQArnoldi(PEP pep,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,Vec v,Vec w,PetscReal *beta,PetscBool *breakdown,PetscScalar *work)$/;" f file: PEPQArnoldiCGS src/pep/impls/krylov/qarnoldi/qarnoldi.c /^static PetscErrorCode PEPQArnoldiCGS(PEP pep,PetscScalar *H,PetscBLASInt ldh,PetscScalar *h,PetscBLASInt j,BV V,Vec t,Vec v,Vec w,PetscReal *onorm,PetscReal *norm,PetscScalar *work)$/;" f file: PEPQArnoldiGetLocking src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPQArnoldiGetLocking(PEP pep,PetscBool *lock)$/;" f PEPQArnoldiGetLocking_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^static PetscErrorCode PEPQArnoldiGetLocking_QArnoldi(PEP pep,PetscBool *lock)$/;" f file: PEPQArnoldiGetRestart src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPQArnoldiGetRestart(PEP pep,PetscReal *keep)$/;" f PEPQArnoldiGetRestart_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^static PetscErrorCode PEPQArnoldiGetRestart_QArnoldi(PEP pep,PetscReal *keep)$/;" f file: PEPQArnoldiSetLocking src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPQArnoldiSetLocking(PEP pep,PetscBool lock)$/;" f PEPQArnoldiSetLocking_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^static PetscErrorCode PEPQArnoldiSetLocking_QArnoldi(PEP pep,PetscBool lock)$/;" f file: PEPQArnoldiSetRestart src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPQArnoldiSetRestart(PEP pep,PetscReal keep)$/;" f PEPQArnoldiSetRestart_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^static PetscErrorCode PEPQArnoldiSetRestart_QArnoldi(PEP pep,PetscReal keep)$/;" f file: PEPReasonView src/pep/interface/pepview.c /^PetscErrorCode PEPReasonView(PEP pep,PetscViewer viewer)$/;" f PEPReasonViewFromOptions src/pep/interface/pepview.c /^PetscErrorCode PEPReasonViewFromOptions(PEP pep)$/;" f PEPRefine include/slepc/finclude/slepcpepdef.h 41;" d PEPRefine include/slepcpep.h /^ PEP_REFINE_MULTIPLE } PEPRefine;$/;" t typeref:enum:__anon41 PEPRefineGetKSP src/pep/interface/pepbasic.c /^PetscErrorCode PEPRefineGetKSP(PEP pep,KSP *ksp)$/;" f PEPRefineScheme include/slepc/finclude/slepcpepdef.h 42;" d PEPRefineScheme include/slepcpep.h /^ PEP_REFINE_SCHEME_EXPLICIT } PEPRefineScheme;$/;" t typeref:enum:__anon42 PEPRefineSchemes include/slepcpep.h /^PETSC_EXTERN const char *PEPRefineSchemes[];$/;" v PEPRefineSchemes src/pep/interface/dlregispep.c /^const char *PEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","PEPRefineScheme","PEP_REFINE_SCHEME_",0};$/;" v PEPRefineTypes include/slepcpep.h /^PETSC_EXTERN const char *PEPRefineTypes[];$/;" v PEPRefineTypes src/pep/interface/dlregispep.c /^const char *PEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","PEPRefine","PEP_REFINE_",0};$/;" v PEPRegister src/pep/interface/pepbasic.c /^PetscErrorCode PEPRegister(const char *name,PetscErrorCode (*function)(PEP))$/;" f PEPRegisterAll src/pep/interface/pepregis.c /^PetscErrorCode PEPRegisterAll(void)$/;" f PEPRegisterAllCalled include/slepc/private/pepimpl.h /^PETSC_EXTERN PetscBool PEPRegisterAllCalled;$/;" v PEPRegisterAllCalled src/pep/interface/pepbasic.c /^PetscBool PEPRegisterAllCalled = PETSC_FALSE;$/;" v PEPReset src/pep/interface/pepbasic.c /^PetscErrorCode PEPReset(PEP pep)$/;" f PEPReset_JD src/pep/impls/jd/pjd.c /^PetscErrorCode PEPReset_JD(PEP pep)$/;" f PEPReset_Linear src/pep/impls/linear/linear.c /^PetscErrorCode PEPReset_Linear(PEP pep)$/;" f PEPReset_TOAR src/pep/impls/krylov/pepkrylov.c /^PetscErrorCode PEPReset_TOAR(PEP pep)$/;" f PEPSTOAR include/slepc/finclude/slepcpepdef.h 52;" d PEPSTOAR include/slepcpep.h 51;" d PEPSTOARGetLocking src/pep/impls/krylov/stoar/stoar.c /^PetscErrorCode PEPSTOARGetLocking(PEP pep,PetscBool *lock)$/;" f PEPSTOARGetLocking_STOAR src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOARGetLocking_STOAR(PEP pep,PetscBool *lock)$/;" f file: PEPSTOARNorm src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOARNorm(PEP pep,PetscInt j,PetscReal *norm)$/;" f file: PEPSTOAROrth2 src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOAROrth2(PEP pep,PetscInt k,PetscReal *Omega,PetscScalar *y)$/;" f file: PEPSTOARSetLocking src/pep/impls/krylov/stoar/stoar.c /^PetscErrorCode PEPSTOARSetLocking(PEP pep,PetscBool lock)$/;" f PEPSTOARSetLocking_STOAR src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOARSetLocking_STOAR(PEP pep,PetscBool lock)$/;" f file: PEPSTOARSupdate src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)$/;" f file: PEPSTOARTrunc src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOARTrunc(PEP pep,PetscInt rs1,PetscInt cs1,PetscScalar *work,PetscReal *rwork)$/;" f file: PEPSTOARqKqMupdates src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOARqKqMupdates(PEP pep,PetscInt j,Vec *wv)$/;" f file: PEPSTOARrun src/pep/impls/krylov/stoar/stoar.c /^static PetscErrorCode PEPSTOARrun(PEP pep,PetscReal *a,PetscReal *b,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscScalar *work,Vec *t_)$/;" f file: PEPScale include/slepc/finclude/slepcpepdef.h 40;" d PEPScale include/slepcpep.h /^ PEP_SCALE_BOTH } PEPScale;$/;" t typeref:enum:__anon40 PEPScaleTypes include/slepcpep.h /^PETSC_EXTERN const char *PEPScaleTypes[];$/;" v PEPScaleTypes src/pep/interface/dlregispep.c /^const char *PEPScaleTypes[] = {"NONE","SCALAR","DIAGONAL","BOTH","PEPScale","PEP_SCALE_",0};$/;" v PEPSetBV src/pep/interface/pepbasic.c /^PetscErrorCode PEPSetBV(PEP pep,BV bv)$/;" f PEPSetBasis src/pep/interface/pepopts.c /^PetscErrorCode PEPSetBasis(PEP pep,PEPBasis basis)$/;" f PEPSetConvergenceTest src/pep/interface/pepopts.c /^PetscErrorCode PEPSetConvergenceTest(PEP pep,PEPConv conv)$/;" f PEPSetConvergenceTestFunction src/pep/interface/pepopts.c /^PetscErrorCode PEPSetConvergenceTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f PEPSetDS src/pep/interface/pepbasic.c /^PetscErrorCode PEPSetDS(PEP pep,DS ds)$/;" f PEPSetDimensions src/pep/interface/pepopts.c /^PetscErrorCode PEPSetDimensions(PEP pep,PetscInt nev,PetscInt ncv,PetscInt mpd)$/;" f PEPSetDimensions_Default src/pep/interface/pepsetup.c /^PetscErrorCode PEPSetDimensions_Default(PEP pep,PetscInt nev,PetscInt *ncv,PetscInt *mpd)$/;" f PEPSetEigenvalueComparison src/pep/interface/pepopts.c /^PetscErrorCode PEPSetEigenvalueComparison(PEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)$/;" f PEPSetExtract src/pep/interface/pepopts.c /^PetscErrorCode PEPSetExtract(PEP pep,PEPExtract extract)$/;" f PEPSetFromOptions src/pep/interface/pepopts.c /^PetscErrorCode PEPSetFromOptions(PEP pep)$/;" f PEPSetFromOptions_JD src/pep/impls/jd/pjdopt.c /^PetscErrorCode PEPSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,PEP pep)$/;" f PEPSetFromOptions_Linear src/pep/impls/linear/linear.c /^PetscErrorCode PEPSetFromOptions_Linear(PetscOptionItems *PetscOptionsObject,PEP pep)$/;" f PEPSetFromOptions_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPSetFromOptions_QArnoldi(PetscOptionItems *PetscOptionsObject,PEP pep)$/;" f PEPSetFromOptions_STOAR src/pep/impls/krylov/stoar/stoar.c /^PetscErrorCode PEPSetFromOptions_STOAR(PetscOptionItems *PetscOptionsObject,PEP pep)$/;" f PEPSetFromOptions_TOAR src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPSetFromOptions_TOAR(PetscOptionItems *PetscOptionsObject,PEP pep)$/;" f PEPSetInitialSpace src/pep/interface/pepsetup.c /^PetscErrorCode PEPSetInitialSpace(PEP pep,PetscInt n,Vec *is)$/;" f PEPSetOperators src/pep/interface/pepsetup.c /^PetscErrorCode PEPSetOperators(PEP pep,PetscInt nmat,Mat A[])$/;" f PEPSetOptionsPrefix src/pep/interface/pepopts.c /^PetscErrorCode PEPSetOptionsPrefix(PEP pep,const char *prefix)$/;" f PEPSetProblemType src/pep/interface/pepopts.c /^PetscErrorCode PEPSetProblemType(PEP pep,PEPProblemType type)$/;" f PEPSetRG src/pep/interface/pepbasic.c /^PetscErrorCode PEPSetRG(PEP pep,RG rg)$/;" f PEPSetRefine src/pep/interface/pepopts.c /^PetscErrorCode PEPSetRefine(PEP pep,PEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,PEPRefineScheme scheme)$/;" f PEPSetST src/pep/interface/pepbasic.c /^PetscErrorCode PEPSetST(PEP pep,ST st)$/;" f PEPSetScale src/pep/interface/pepopts.c /^PetscErrorCode PEPSetScale(PEP pep,PEPScale scale,PetscReal alpha,Vec Dl,Vec Dr,PetscInt its,PetscReal lambda)$/;" f PEPSetStoppingTest src/pep/interface/pepopts.c /^PetscErrorCode PEPSetStoppingTest(PEP pep,PEPStop stop)$/;" f PEPSetStoppingTestFunction src/pep/interface/pepopts.c /^PetscErrorCode PEPSetStoppingTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f PEPSetTarget src/pep/interface/pepbasic.c /^PetscErrorCode PEPSetTarget(PEP pep,PetscScalar target)$/;" f PEPSetTolerances src/pep/interface/pepopts.c /^PetscErrorCode PEPSetTolerances(PEP pep,PetscReal tol,PetscInt maxits)$/;" f PEPSetTrackAll src/pep/interface/pepopts.c /^PetscErrorCode PEPSetTrackAll(PEP pep,PetscBool trackall)$/;" f PEPSetType src/pep/interface/pepbasic.c /^PetscErrorCode PEPSetType(PEP pep,PEPType type)$/;" f PEPSetUp src/pep/interface/pepsetup.c /^PetscErrorCode PEPSetUp(PEP pep)$/;" f PEPSetUp_JD src/pep/impls/jd/pjd.c /^PetscErrorCode PEPSetUp_JD(PEP pep)$/;" f PEPSetUp_Linear src/pep/impls/linear/linear.c /^PetscErrorCode PEPSetUp_Linear(PEP pep)$/;" f PEPSetUp_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPSetUp_QArnoldi(PEP pep)$/;" f PEPSetUp_STOAR src/pep/impls/krylov/stoar/stoar.c /^PetscErrorCode PEPSetUp_STOAR(PEP pep)$/;" f PEPSetUp_TOAR src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPSetUp_TOAR(PEP pep)$/;" f PEPSetWhichEigenpairs src/pep/interface/pepopts.c /^PetscErrorCode PEPSetWhichEigenpairs(PEP pep,PEPWhich which)$/;" f PEPSetWorkVecs src/pep/interface/pepdefault.c /^PetscErrorCode PEPSetWorkVecs(PEP pep,PetscInt nw)$/;" f PEPSimpNRefctx src/pep/interface/peprefine.c /^} PEPSimpNRefctx;$/;" t typeref:struct:__anon108 file: PEPSimpleNRefGatherEigenpair src/pep/interface/peprefine.c /^static PetscErrorCode PEPSimpleNRefGatherEigenpair(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail)$/;" f file: PEPSimpleNRefScatterEigenvector src/pep/interface/peprefine.c /^static PetscErrorCode PEPSimpleNRefScatterEigenvector(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx)$/;" f file: PEPSimpleNRefSetUp src/pep/interface/peprefine.c /^static PetscErrorCode PEPSimpleNRefSetUp(PEP pep,PEPSimpNRefctx **ctx_)$/;" f file: PEPSimpleNRefSetUpSystem src/pep/interface/peprefine.c /^static PetscErrorCode PEPSimpleNRefSetUpSystem(PEP pep,Mat *A,PEPSimpNRefctx *ctx,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v)$/;" f file: PEPSolve src/pep/interface/pepsolve.c /^PetscErrorCode PEPSolve(PEP pep)$/;" f PEPSolve_JD src/pep/impls/jd/pjd.c /^PetscErrorCode PEPSolve_JD(PEP pep)$/;" f PEPSolve_Linear src/pep/impls/linear/linear.c /^PetscErrorCode PEPSolve_Linear(PEP pep)$/;" f PEPSolve_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPSolve_QArnoldi(PEP pep)$/;" f PEPSolve_STOAR src/pep/impls/krylov/stoar/stoar.c /^PetscErrorCode PEPSolve_STOAR(PEP pep)$/;" f PEPSolve_TOAR src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPSolve_TOAR(PEP pep)$/;" f PEPStateType include/slepc/private/pepimpl.h /^ PEP_STATE_EIGENVECTORS } PEPStateType;$/;" t typeref:enum:__anon4 PEPStop include/slepc/finclude/slepcpepdef.h 45;" d PEPStop include/slepcpep.h /^ PEP_STOP_USER } PEPStop;$/;" t typeref:enum:__anon46 PEPStoppingBasic src/pep/interface/pepdefault.c /^PetscErrorCode PEPStoppingBasic(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)$/;" f PEPTOAR include/slepc/finclude/slepcpepdef.h 51;" d PEPTOAR include/slepcpep.h 50;" d PEPTOARCoefficients src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARCoefficients(PEP pep,PetscBool sinvert,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x)$/;" f file: PEPTOARExtendBasis src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARExtendBasis(PEP pep,PetscBool sinvert,PetscScalar sigma,PetscScalar *S,PetscInt ls,PetscInt nv,BV V,Vec t,PetscScalar *r,PetscInt lr,Vec *t_)$/;" f file: PEPTOARGetLocking src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPTOARGetLocking(PEP pep,PetscBool *lock)$/;" f PEPTOARGetLocking_TOAR src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARGetLocking_TOAR(PEP pep,PetscBool *lock)$/;" f file: PEPTOARGetRestart src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPTOARGetRestart(PEP pep,PetscReal *keep)$/;" f PEPTOARGetRestart_TOAR src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARGetRestart_TOAR(PEP pep,PetscReal *keep)$/;" f file: PEPTOAROrth2 src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOAROrth2(PEP pep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work)$/;" f file: PEPTOARSNorm2 src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm)$/;" f file: PEPTOARSetLocking src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPTOARSetLocking(PEP pep,PetscBool lock)$/;" f PEPTOARSetLocking_TOAR src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARSetLocking_TOAR(PEP pep,PetscBool lock)$/;" f file: PEPTOARSetRestart src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPTOARSetRestart(PEP pep,PetscReal keep)$/;" f PEPTOARSetRestart_TOAR src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARSetRestart_TOAR(PEP pep,PetscReal keep)$/;" f file: PEPTOARSupdate src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)$/;" f file: PEPTOARTrunc src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARTrunc(PEP pep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt *rs1a,PetscInt cs1,PetscInt lock,PetscInt newc,PetscBool final,PetscScalar *work,PetscReal *rwork)$/;" f file: PEPTOARrun src/pep/impls/krylov/toar/ptoar.c /^static PetscErrorCode PEPTOARrun(PEP pep,PetscScalar sigma,PetscInt *nq,PetscScalar *S,PetscInt ld,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscScalar *work,Vec *t_)$/;" f file: PEPType include/slepc/finclude/slepcpepdef.h 36;" d PEPType include/slepcpep.h /^typedef const char* PEPType;$/;" t PEPValuesView src/pep/interface/pepview.c /^PetscErrorCode PEPValuesView(PEP pep,PetscViewer viewer)$/;" f PEPValuesViewFromOptions src/pep/interface/pepview.c /^PetscErrorCode PEPValuesViewFromOptions(PEP pep)$/;" f PEPValuesView_ASCII src/pep/interface/pepview.c /^static PetscErrorCode PEPValuesView_ASCII(PEP pep,PetscViewer viewer)$/;" f file: PEPValuesView_DRAW src/pep/interface/pepview.c /^static PetscErrorCode PEPValuesView_DRAW(PEP pep,PetscViewer viewer)$/;" f file: PEPValuesView_MATLAB src/pep/interface/pepview.c /^static PetscErrorCode PEPValuesView_MATLAB(PEP pep,PetscViewer viewer)$/;" f file: PEPVectorsView src/pep/interface/pepview.c /^PetscErrorCode PEPVectorsView(PEP pep,PetscViewer viewer)$/;" f PEPVectorsViewFromOptions src/pep/interface/pepview.c /^PetscErrorCode PEPVectorsViewFromOptions(PEP pep)$/;" f PEPView src/pep/interface/pepview.c /^PetscErrorCode PEPView(PEP pep,PetscViewer viewer)$/;" f PEPViewFromOptions include/slepcpep.h /^PETSC_STATIC_INLINE PetscErrorCode PEPViewFromOptions(PEP pep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)pep,obj,name);}$/;" f PEPView_JD src/pep/impls/jd/pjdopt.c /^PetscErrorCode PEPView_JD(PEP pep,PetscViewer viewer)$/;" f PEPView_Linear src/pep/impls/linear/linear.c /^PetscErrorCode PEPView_Linear(PEP pep,PetscViewer viewer)$/;" f PEPView_QArnoldi src/pep/impls/krylov/qarnoldi/qarnoldi.c /^PetscErrorCode PEPView_QArnoldi(PEP pep,PetscViewer viewer)$/;" f PEPView_STOAR src/pep/impls/krylov/stoar/stoar.c /^PetscErrorCode PEPView_STOAR(PEP pep,PetscViewer viewer)$/;" f PEPView_TOAR src/pep/impls/krylov/toar/ptoar.c /^PetscErrorCode PEPView_TOAR(PEP pep,PetscViewer viewer)$/;" f PEPWhich include/slepc/finclude/slepcpepdef.h 38;" d PEPWhich include/slepcpep.h /^ PEP_WHICH_USER } PEPWhich;$/;" t typeref:enum:__anon38 PEP_BASIS_CHEBYSHEV1 include/slepcpep.h /^ PEP_BASIS_CHEBYSHEV1,$/;" e enum:__anon39 PEP_BASIS_CHEBYSHEV2 include/slepcpep.h /^ PEP_BASIS_CHEBYSHEV2,$/;" e enum:__anon39 PEP_BASIS_HERMITE include/slepcpep.h /^ PEP_BASIS_HERMITE } PEPBasis;$/;" e enum:__anon39 PEP_BASIS_LAGUERRE include/slepcpep.h /^ PEP_BASIS_LAGUERRE,$/;" e enum:__anon39 PEP_BASIS_LEGENDRE include/slepcpep.h /^ PEP_BASIS_LEGENDRE,$/;" e enum:__anon39 PEP_BASIS_MONOMIAL include/slepcpep.h /^typedef enum { PEP_BASIS_MONOMIAL,$/;" e enum:__anon39 PEP_CLASSID include/slepcpep.h /^PETSC_EXTERN PetscClassId PEP_CLASSID;$/;" v PEP_CLASSID src/pep/interface/pepbasic.c /^PetscClassId PEP_CLASSID = 0;$/;" v PEP_CONVERGED_ITERATING include/slepcpep.h /^ PEP_CONVERGED_ITERATING = 0} PEPConvergedReason;$/;" e enum:__anon47 PEP_CONVERGED_TOL include/slepcpep.h /^ PEP_CONVERGED_TOL = 1,$/;" e enum:__anon47 PEP_CONVERGED_USER include/slepcpep.h /^ PEP_CONVERGED_USER = 2,$/;" e enum:__anon47 PEP_CONV_ABS include/slepcpep.h /^typedef enum { PEP_CONV_ABS,$/;" e enum:__anon45 PEP_CONV_NORM include/slepcpep.h /^ PEP_CONV_NORM,$/;" e enum:__anon45 PEP_CONV_REL include/slepcpep.h /^ PEP_CONV_REL,$/;" e enum:__anon45 PEP_CONV_USER include/slepcpep.h /^ PEP_CONV_USER } PEPConv;$/;" e enum:__anon45 PEP_DIVERGED_BREAKDOWN include/slepcpep.h /^ PEP_DIVERGED_BREAKDOWN = -2,$/;" e enum:__anon47 PEP_DIVERGED_ITS include/slepcpep.h /^ PEP_DIVERGED_ITS = -1,$/;" e enum:__anon47 PEP_DIVERGED_SYMMETRY_LOST include/slepcpep.h /^ PEP_DIVERGED_SYMMETRY_LOST = -3,$/;" e enum:__anon47 PEP_ERROR_ABSOLUTE include/slepcpep.h /^typedef enum { PEP_ERROR_ABSOLUTE,$/;" e enum:__anon44 PEP_ERROR_BACKWARD include/slepcpep.h /^ PEP_ERROR_BACKWARD } PEPErrorType;$/;" e enum:__anon44 PEP_ERROR_RELATIVE include/slepcpep.h /^ PEP_ERROR_RELATIVE,$/;" e enum:__anon44 PEP_EXTRACT_NONE include/slepcpep.h /^typedef enum { PEP_EXTRACT_NONE=1,$/;" e enum:__anon43 PEP_EXTRACT_NORM include/slepcpep.h /^ PEP_EXTRACT_NORM,$/;" e enum:__anon43 PEP_EXTRACT_RESIDUAL include/slepcpep.h /^ PEP_EXTRACT_RESIDUAL,$/;" e enum:__anon43 PEP_EXTRACT_STRUCTURED include/slepcpep.h /^ PEP_EXTRACT_STRUCTURED } PEPExtract;$/;" e enum:__anon43 PEP_GENERAL include/slepcpep.h /^typedef enum { PEP_GENERAL=1,$/;" e enum:__anon37 PEP_GYROSCOPIC include/slepcpep.h /^ PEP_GYROSCOPIC \/* QEP with M, K Hermitian, M>0, C skew-Hermitian *\/$/;" e enum:__anon37 PEP_HERMITIAN include/slepcpep.h /^ PEP_HERMITIAN, \/* All A_i Hermitian *\/$/;" e enum:__anon37 PEP_JD src/pep/impls/jd/pjdp.h /^} PEP_JD;$/;" t typeref:struct:__anon99 PEP_JD_MATSHELL src/pep/impls/jd/pjdp.h /^} PEP_JD_MATSHELL;$/;" t typeref:struct:__anon101 PEP_JD_PCSHELL src/pep/impls/jd/pjdp.h /^} PEP_JD_PCSHELL;$/;" t typeref:struct:__anon100 PEP_LARGEST_IMAGINARY include/slepcpep.h /^ PEP_LARGEST_IMAGINARY,$/;" e enum:__anon38 PEP_LARGEST_MAGNITUDE include/slepcpep.h /^typedef enum { PEP_LARGEST_MAGNITUDE=1,$/;" e enum:__anon38 PEP_LARGEST_REAL include/slepcpep.h /^ PEP_LARGEST_REAL,$/;" e enum:__anon38 PEP_LINEAR src/pep/impls/linear/linearp.h /^} PEP_LINEAR;$/;" t typeref:struct:__anon106 PEP_QARNOLDI src/pep/impls/krylov/qarnoldi/qarnoldi.c /^} PEP_QARNOLDI;$/;" t typeref:struct:__anon103 file: PEP_REFINE_MULTIPLE include/slepcpep.h /^ PEP_REFINE_MULTIPLE } PEPRefine;$/;" e enum:__anon41 PEP_REFINE_NONE include/slepcpep.h /^typedef enum { PEP_REFINE_NONE,$/;" e enum:__anon41 PEP_REFINE_SCHEME_EXPLICIT include/slepcpep.h /^ PEP_REFINE_SCHEME_EXPLICIT } PEPRefineScheme;$/;" e enum:__anon42 PEP_REFINE_SCHEME_MBE include/slepcpep.h /^ PEP_REFINE_SCHEME_MBE,$/;" e enum:__anon42 PEP_REFINE_SCHEME_SCHUR include/slepcpep.h /^typedef enum { PEP_REFINE_SCHEME_SCHUR=1,$/;" e enum:__anon42 PEP_REFINE_SIMPLE include/slepcpep.h /^ PEP_REFINE_SIMPLE,$/;" e enum:__anon41 PEP_Refine include/slepc/private/pepimpl.h /^PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine;$/;" v PEP_Refine src/pep/interface/pepbasic.c /^PetscLogEvent PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0;$/;" v PEP_SCALE_BOTH include/slepcpep.h /^ PEP_SCALE_BOTH } PEPScale;$/;" e enum:__anon40 PEP_SCALE_DIAGONAL include/slepcpep.h /^ PEP_SCALE_DIAGONAL,$/;" e enum:__anon40 PEP_SCALE_NONE include/slepcpep.h /^typedef enum { PEP_SCALE_NONE,$/;" e enum:__anon40 PEP_SCALE_SCALAR include/slepcpep.h /^ PEP_SCALE_SCALAR,$/;" e enum:__anon40 PEP_SMALLEST_IMAGINARY include/slepcpep.h /^ PEP_SMALLEST_IMAGINARY,$/;" e enum:__anon38 PEP_SMALLEST_MAGNITUDE include/slepcpep.h /^ PEP_SMALLEST_MAGNITUDE,$/;" e enum:__anon38 PEP_SMALLEST_REAL include/slepcpep.h /^ PEP_SMALLEST_REAL,$/;" e enum:__anon38 PEP_STATE_EIGENVECTORS include/slepc/private/pepimpl.h /^ PEP_STATE_EIGENVECTORS } PEPStateType;$/;" e enum:__anon4 PEP_STATE_INITIAL include/slepc/private/pepimpl.h /^typedef enum { PEP_STATE_INITIAL,$/;" e enum:__anon4 PEP_STATE_SETUP include/slepc/private/pepimpl.h /^ PEP_STATE_SETUP,$/;" e enum:__anon4 PEP_STATE_SOLVED include/slepc/private/pepimpl.h /^ PEP_STATE_SOLVED,$/;" e enum:__anon4 PEP_STOP_BASIC include/slepcpep.h /^typedef enum { PEP_STOP_BASIC,$/;" e enum:__anon46 PEP_STOP_USER include/slepcpep.h /^ PEP_STOP_USER } PEPStop;$/;" e enum:__anon46 PEP_SetUp include/slepc/private/pepimpl.h /^PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine;$/;" v PEP_SetUp src/pep/interface/pepbasic.c /^PetscLogEvent PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0;$/;" v PEP_Solve include/slepc/private/pepimpl.h /^PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine;$/;" v PEP_Solve src/pep/interface/pepbasic.c /^PetscLogEvent PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0;$/;" v PEP_TARGET_IMAGINARY include/slepcpep.h /^ PEP_TARGET_IMAGINARY,$/;" e enum:__anon38 PEP_TARGET_MAGNITUDE include/slepcpep.h /^ PEP_TARGET_MAGNITUDE,$/;" e enum:__anon38 PEP_TARGET_REAL include/slepcpep.h /^ PEP_TARGET_REAL,$/;" e enum:__anon38 PEP_TOAR src/pep/impls/krylov/pepkrylov.h /^} PEP_TOAR;$/;" t typeref:struct:__anon102 PEP_WHICH_USER include/slepcpep.h /^ PEP_WHICH_USER } PEPWhich;$/;" e enum:__anon38 PETSCSetupInterpreter src/eps/impls/external/blopex/petsc-interface.c /^int PETSCSetupInterpreter(mv_InterfaceInterpreter *i)$/;" f PETSC_Axpy src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_Axpy(void *alpha,void *x,void *y)$/;" f PETSC_ClearVector src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_ClearVector(void *x)$/;" f PETSC_CopyVector src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_CopyVector(void *x,void *y)$/;" f PETSC_DestroyVector src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_DestroyVector(void *vvector)$/;" f PETSC_END_LEN src/sys/ftn-custom/zslepc_start.c /^PETSC_EXTERN void PETSC_STDCALL slepcinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f PETSC_INTERFACE_HEADER src/eps/impls/external/blopex/petsc-interface.h 7;" d PETSC_InnerProd src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_InnerProd(void *x,void *y,void *result)$/;" f PETSC_MimicVector src/eps/impls/external/blopex/petsc-interface.c /^void *PETSC_MimicVector(void *vvector)$/;" f PETSC_ScaleVector src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_ScaleVector(double alpha,void *x)$/;" f PETSC_SetRandomValues src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_SetRandomValues(void* v,BlopexInt seed)$/;" f PETSC_VectorSize src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_VectorSize(void *x)$/;" f PETSC_dpotrf_interface src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_dpotrf_interface (char *uplo,BlopexInt *n,double *a,BlopexInt * lda,BlopexInt *info)$/;" f PETSC_dsygv_interface src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_dsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,double *a,BlopexInt *lda,double *b,BlopexInt *ldb,double *w,double *work,BlopexInt *lwork,BlopexInt *info)$/;" f PETSC_zpotrf_interface src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_zpotrf_interface (char *uplo,BlopexInt *n,komplex *a,BlopexInt* lda,BlopexInt *info)$/;" f PETSC_zsygv_interface src/eps/impls/external/blopex/petsc-interface.c /^BlopexInt PETSC_zsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,komplex *a,BlopexInt *lda,komplex *b,BlopexInt *ldb,double *w,komplex *work,BlopexInt *lwork,double *rwork,BlopexInt *info)$/;" f PETSc config/packages/petsc.py /^class PETSc(package.Package):$/;" c PETScMaker config/cmakeboot.py /^class PETScMaker(script.Script):$/;" c PG src/eps/examples/tutorials/ex31.c /^const PetscScalar PG[3] = {0.716786142395021,1.630000000000000,0.850000000000000};$/;" v PKGS config/gmakegen.py /^PKGS = 'sys eps svd pep nep mfn'.split()$/;" v Pa src/eps/impls/davidson/dvdutils.c /^ PetscScalar Pa,Pb; \/* H=W'*(Pa*AV - Pb*BV), G=W'*(Wa*AV - Wb*BV) *\/$/;" m struct:__anon72 file: Package config/package.py /^class Package:$/;" c Pb src/eps/impls/davidson/dvdutils.c /^ PetscScalar Pa,Pb; \/* H=W'*(Pa*AV - Pb*BV), G=W'*(Wa*AV - Wb*BV) *\/$/;" m struct:__anon72 file: PetscBeganMPI src/sys/slepcinit.c /^PETSC_EXTERN PetscBool PetscBeganMPI;$/;" v PetscDLLibraryRegister_slepc src/sys/dlregisslepc.c /^PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepc(void)$/;" f PetscDLLibraryRegister_slepceps src/eps/interface/dlregiseps.c /^PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepceps()$/;" f PetscDLLibraryRegister_slepcmfn src/mfn/interface/dlregismfn.c /^PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn()$/;" f PetscDLLibraryRegister_slepcnep src/nep/interface/dlregisnep.c /^PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcnep()$/;" f PetscDLLibraryRegister_slepcpep src/pep/interface/dlregispep.c /^PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcpep()$/;" f PetscDLLibraryRegister_slepcsvd src/svd/interface/dlregissvd.c /^PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsvd()$/;" f PhiDerivative src/sys/classes/fn/impls/phi/fnphi.c /^static void PhiDerivative(PetscScalar x,PetscScalar *y,PetscInt k)$/;" f file: PhiFunction src/sys/classes/fn/impls/phi/fnphi.c /^static void PhiFunction(PetscScalar x,PetscScalar *y,PetscInt k)$/;" f file: PopBool config/argdb.py /^ def PopBool(self,keyword):$/;" m class:ArgDB PopHelp config/argdb.py /^ def PopHelp(self):$/;" m class:ArgDB PopPath config/argdb.py /^ def PopPath(self,keyword):$/;" m class:ArgDB PopString config/argdb.py /^ def PopString(self,keyword):$/;" m class:ArgDB PopUrl config/argdb.py /^ def PopUrl(self,keyword):$/;" m class:ArgDB PreallocateJacobian src/eps/examples/tutorials/ex31.c /^PetscErrorCode PreallocateJacobian(Mat J,Userctx *user)$/;" f Precond_FnMultiVector src/eps/impls/external/blopex/blopex.c /^static void Precond_FnMultiVector(void *data,void *x,void *y)$/;" f file: Precond_FnSingleVector src/eps/impls/external/blopex/blopex.c /^static void Precond_FnSingleVector(void *data,void *x,void *y)$/;" f file: Precondition config/package.py /^ def Precondition(self,petsc):$/;" m class:Package PrepFtnDir bin/maint/generatefortranstubs.py /^def PrepFtnDir(dir):$/;" f Primme config/packages/primme.py /^class Primme(package.Package):$/;" c Print config/log.py /^ def Print(self,string):$/;" m class:Log Println config/log.py /^ def Println(self,string):$/;" m class:Log Process config/package.py /^ def Process(self,conf,vars,cmake,petsc,archdir=''):$/;" m class:Package Process config/packages/lapack.py /^ def Process(self,conf,vars,cmake,petsc,archdir=''):$/;" m class:Lapack ProcessArgs config/package.py /^ def ProcessArgs(self,argdb):$/;" m class:Package ProjType_t src/eps/impls/davidson/davidson.h /^} ProjType_t;$/;" t typeref:enum:__anon64 Prologue src/sys/classes/ds/impls/ghiep/dqds.c /^static PetscErrorCode Prologue(PetscInt n,PetscReal *a,PetscReal *b,PetscReal gl,PetscReal gr,PetscInt *m,PetscReal *shift,PetscReal *work)$/;" f file: PseudoOrthog_HR src/sys/classes/ds/impls/ghiep/invit.c /^static PetscErrorCode PseudoOrthog_HR(PetscInt *nv,PetscScalar *V,PetscInt ldv,PetscReal *s,PetscScalar *R,PetscInt ldr,PetscBLASInt *perm,PetscBLASInt *cmplxEig,PetscBool *breakdown,PetscScalar *work)$/;" f file: Pshell src/pep/impls/jd/pjdp.h /^ Mat Pshell; \/* auxiliary shell matrix *\/$/;" m struct:__anon99 QD0 src/eps/examples/tutorials/ex31.c /^const PetscScalar QD0[3] = {0.5,0.3,0.35};$/;" v QG src/eps/examples/tutorials/ex31.c /^const PetscScalar QG[3] = {0.270702180178785,0.066120127797275,-0.108402221791588};$/;" v RG include/slepc/finclude/slepcrgdef.h 27;" d RG include/slepcrgtypes.h /^typedef struct _p_RG* RG;$/;" t typeref:struct:_p_RG RGAppendOptionsPrefix src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGAppendOptionsPrefix(RG rg,const char *prefix)$/;" f RGCheckInside src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGCheckInside(RG rg,PetscInt n,PetscScalar *ar,PetscScalar *ai,PetscInt *inside)$/;" f RGCheckInside_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGCheckInside_Ellipse(RG rg,PetscReal px,PetscReal py,PetscInt *inside)$/;" f RGCheckInside_Interval src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGCheckInside_Interval(RG rg,PetscReal dx,PetscReal dy,PetscInt *inside)$/;" f RGCheckInside_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGCheckInside_Polygon(RG rg,PetscReal px,PetscReal py,PetscInt *inout)$/;" f RGCheckInside_Ring src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGCheckInside_Ring(RG rg,PetscReal px,PetscReal py,PetscInt *inside)$/;" f RGComputeContour src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGComputeContour(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)$/;" f RGComputeContour_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGComputeContour_Ellipse(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)$/;" f RGComputeContour_Interval src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGComputeContour_Interval(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)$/;" f RGComputeContour_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGComputeContour_Polygon(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)$/;" f RGComputeContour_Ring src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGComputeContour_Ring(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)$/;" f RGCreate src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGCreate(MPI_Comm comm,RG *newrg)$/;" f RGCreate_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^PETSC_EXTERN PetscErrorCode RGCreate_Ellipse(RG rg)$/;" f RGCreate_Interval src/sys/classes/rg/impls/interval/rginterval.c /^PETSC_EXTERN PetscErrorCode RGCreate_Interval(RG rg)$/;" f RGCreate_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^PETSC_EXTERN PetscErrorCode RGCreate_Polygon(RG rg)$/;" f RGCreate_Ring src/sys/classes/rg/impls/ring/rgring.c /^PETSC_EXTERN PetscErrorCode RGCreate_Ring(RG rg)$/;" f RGDestroy src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGDestroy(RG *rg)$/;" f RGDestroy_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGDestroy_Ellipse(RG rg)$/;" f RGDestroy_Interval src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGDestroy_Interval(RG rg)$/;" f RGDestroy_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGDestroy_Polygon(RG rg)$/;" f RGDestroy_Ring src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGDestroy_Ring(RG rg)$/;" f RGELLIPSE include/slepc/finclude/slepcrgdef.h 34;" d RGELLIPSE include/slepcrg.h 39;" d RGEllipseGetParameters src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGEllipseGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale)$/;" f RGEllipseGetParameters_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^static PetscErrorCode RGEllipseGetParameters_Ellipse(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale)$/;" f file: RGEllipseSetParameters src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGEllipseSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale)$/;" f RGEllipseSetParameters_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^static PetscErrorCode RGEllipseSetParameters_Ellipse(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale)$/;" f file: RGFinalizePackage src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGFinalizePackage(void)$/;" f RGGetComplement src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGGetComplement(RG rg,PetscBool *flg)$/;" f RGGetOptionsPrefix src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGGetOptionsPrefix(RG rg,const char *prefix[])$/;" f RGGetScale src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGGetScale(RG rg,PetscReal *sfactor)$/;" f RGGetType src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGGetType(RG rg,RGType *type)$/;" f RGINTERVAL include/slepc/finclude/slepcrgdef.h 32;" d RGINTERVAL include/slepcrg.h 37;" d RGInitializePackage src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGInitializePackage(void)$/;" f RGIntervalGetEndpoints src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGIntervalGetEndpoints(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d)$/;" f RGIntervalGetEndpoints_Interval src/sys/classes/rg/impls/interval/rginterval.c /^static PetscErrorCode RGIntervalGetEndpoints_Interval(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d)$/;" f file: RGIntervalSetEndpoints src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGIntervalSetEndpoints(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d)$/;" f RGIntervalSetEndpoints_Interval src/sys/classes/rg/impls/interval/rginterval.c /^static PetscErrorCode RGIntervalSetEndpoints_Interval(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d)$/;" f file: RGIsTrivial src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGIsTrivial(RG rg,PetscBool *trivial)$/;" f RGIsTrivial_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGIsTrivial_Ellipse(RG rg,PetscBool *trivial)$/;" f RGIsTrivial_Interval src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGIsTrivial_Interval(RG rg,PetscBool *trivial)$/;" f RGIsTrivial_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGIsTrivial_Polygon(RG rg,PetscBool *trivial)$/;" f RGIsTrivial_Ring src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGIsTrivial_Ring(RG rg,PetscBool *trivial)$/;" f RGList include/slepcrg.h /^PETSC_EXTERN PetscFunctionList RGList;$/;" v RGList src/sys/classes/rg/interface/rgbasic.c /^PetscFunctionList RGList = 0;$/;" v RGOps include/slepc/private/rgimpl.h /^typedef struct _RGOps *RGOps;$/;" t typeref:struct:_RGOps RGPOLYGON include/slepc/finclude/slepcrgdef.h 33;" d RGPOLYGON include/slepcrg.h 38;" d RGPackageInitialized src/sys/classes/rg/interface/rgbasic.c /^static PetscBool RGPackageInitialized = PETSC_FALSE;$/;" v file: RGPolygonGetVertices src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGPolygonGetVertices(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi)$/;" f RGPolygonGetVertices_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^static PetscErrorCode RGPolygonGetVertices_Polygon(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi)$/;" f file: RGPolygonSetVertices src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGPolygonSetVertices(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi)$/;" f RGPolygonSetVertices_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^static PetscErrorCode RGPolygonSetVertices_Polygon(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi)$/;" f file: RGPopScale src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGPopScale(RG rg)$/;" f RGPushScale src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGPushScale(RG rg,PetscReal sfactor)$/;" f RGRING include/slepc/finclude/slepcrgdef.h 35;" d RGRING include/slepcrg.h 40;" d RGRegister src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGRegister(const char *name,PetscErrorCode (*function)(RG))$/;" f RGRegisterAll src/sys/classes/rg/interface/rgregis.c /^PetscErrorCode RGRegisterAll(void)$/;" f RGRegisterAllCalled include/slepc/private/rgimpl.h /^PETSC_EXTERN PetscBool RGRegisterAllCalled;$/;" v RGRegisterAllCalled src/sys/classes/rg/interface/rgbasic.c /^PetscBool RGRegisterAllCalled = PETSC_FALSE;$/;" v RGRingGetParameters src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGRingGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width)$/;" f RGRingGetParameters_Ring src/sys/classes/rg/impls/ring/rgring.c /^static PetscErrorCode RGRingGetParameters_Ring(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width)$/;" f file: RGRingSetParameters src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGRingSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width)$/;" f RGRingSetParameters_Ring src/sys/classes/rg/impls/ring/rgring.c /^static PetscErrorCode RGRingSetParameters_Ring(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width)$/;" f file: RGSetComplement src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGSetComplement(RG rg,PetscBool flg)$/;" f RGSetFromOptions src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGSetFromOptions(RG rg)$/;" f RGSetFromOptions_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGSetFromOptions_Ellipse(PetscOptionItems *PetscOptionsObject,RG rg)$/;" f RGSetFromOptions_Interval src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGSetFromOptions_Interval(PetscOptionItems *PetscOptionsObject,RG rg)$/;" f RGSetFromOptions_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGSetFromOptions_Polygon(PetscOptionItems *PetscOptionsObject,RG rg)$/;" f RGSetFromOptions_Ring src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGSetFromOptions_Ring(PetscOptionItems *PetscOptionsObject,RG rg)$/;" f RGSetOptionsPrefix src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGSetOptionsPrefix(RG rg,const char *prefix)$/;" f RGSetScale src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGSetScale(RG rg,PetscReal sfactor)$/;" f RGSetType src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGSetType(RG rg,RGType type)$/;" f RGShowReal include/slepc/private/rgimpl.h 51;" d RGType include/slepc/finclude/slepcrgdef.h 30;" d RGType include/slepcrg.h /^typedef const char* RGType;$/;" t RGView src/sys/classes/rg/interface/rgbasic.c /^PetscErrorCode RGView(RG rg,PetscViewer viewer)$/;" f RGView_Ellipse src/sys/classes/rg/impls/ellipse/rgellipse.c /^PetscErrorCode RGView_Ellipse(RG rg,PetscViewer viewer)$/;" f RGView_Interval src/sys/classes/rg/impls/interval/rginterval.c /^PetscErrorCode RGView_Interval(RG rg,PetscViewer viewer)$/;" f RGView_Polygon src/sys/classes/rg/impls/polygon/rgpolygon.c /^PetscErrorCode RGView_Polygon(RG rg,PetscViewer viewer)$/;" f RGView_Ring src/sys/classes/rg/impls/ring/rgring.c /^PetscErrorCode RGView_Ring(RG rg,PetscViewer viewer)$/;" f RG_CLASSID include/slepcrg.h /^PETSC_EXTERN PetscClassId RG_CLASSID;$/;" v RG_CLASSID src/sys/classes/rg/interface/rgbasic.c /^PetscClassId RG_CLASSID = 0;$/;" v RG_ELLIPSE src/sys/classes/rg/impls/ellipse/rgellipse.c /^} RG_ELLIPSE;$/;" t typeref:struct:__anon124 file: RG_INTERVAL src/sys/classes/rg/impls/interval/rginterval.c /^} RG_INTERVAL;$/;" t typeref:struct:__anon125 file: RG_POLYGON src/sys/classes/rg/impls/polygon/rgpolygon.c /^} RG_POLYGON;$/;" t typeref:struct:__anon126 file: RG_RING src/sys/classes/rg/impls/ring/rgring.c /^} RG_RING;$/;" t typeref:struct:__anon127 file: RayleighQuotient src/eps/examples/tutorials/ex24.c /^PetscErrorCode RayleighQuotient(Mat A,Vec x,PetscScalar *r)$/;" f RealDQDS src/sys/classes/ds/impls/ghiep/dqds.c /^static PetscErrorCode RealDQDS(PetscInt n,PetscReal *L,PetscReal *U,PetscReal shift,PetscReal tol,PetscReal norm,PetscReal *L1,PetscReal *U1,PetscInt *fail)$/;" f file: ResidualJacobian src/eps/examples/tutorials/ex31.c /^PetscErrorCode ResidualJacobian(Vec X,Mat J,void *ctx)$/;" f Rs src/eps/examples/tutorials/ex31.c /^const PetscScalar Rs[3] = {0.0,0.0,0.0}; \/* Stator Resistance *\/$/;" v Rv src/pep/impls/krylov/toar/nrefine.c /^ Vec t,tg,Rv,Vi,tp,tpg;$/;" m struct:__anon105 file: S src/eps/impls/ciss/ciss.c /^ BV S;$/;" m struct:__anon61 file: S src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscScalar *S; \/* Matrix for projected problem *\/$/;" m struct:_n_SR S src/nep/impls/ciss/nciss.c /^ BV S;$/;" m struct:__anon89 file: S src/pep/impls/krylov/pepkrylov.h /^ PetscScalar *S,*qB; \/* auxiliary matrices *\/$/;" m struct:__anon102 SHIFTMAX src/nep/impls/nleigs/nleigs.c 1831;" d file: SIGMA src/nep/examples/nlevp/gun.c 43;" d file: SKIPDIRS config/cmakegen.py /^SKIPDIRS = set('benchmarks'.split()) # Skip these during the build$/;" v SLEPCSetupInterpreter src/eps/impls/external/blopex/slepc-interface.c /^int SLEPCSetupInterpreter(mv_InterfaceInterpreter *i)$/;" f SLEPCSetupInterpreterForDignifiedDeath src/eps/impls/external/blopex/slepc-interface.c /^void SLEPCSetupInterpreterForDignifiedDeath(mv_InterfaceInterpreter *i)$/;" f SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 101;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 103;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 109;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 111;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 113;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 123;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 125;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 127;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 133;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 135;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 137;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 47;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 49;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 51;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 57;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 59;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 61;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 71;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 73;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 75;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 81;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 83;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 85;" d SLEPC_ARPACK src/eps/impls/external/arpack/arpackp.h 99;" d SLEPC_AUTHOR_INFO include/slepcsys.h 38;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 33;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 35;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 40;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 42;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 47;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 49;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 57;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 59;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 64;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 66;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 71;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 73;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 81;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 83;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 88;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 90;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 95;" d SLEPC_BLASLAPACK include/slepcblaslapack.h 97;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 31;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 38;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 45;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 55;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 62;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 69;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 79;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 86;" d SLEPC_BLASLAPACKREAL include/slepcblaslapack.h 93;" d SLEPC_BLZPACK src/eps/impls/external/blzpack/blzpackp.h 43;" d SLEPC_BLZPACK src/eps/impls/external/blzpack/blzpackp.h 45;" d SLEPC_BLZPACK src/eps/impls/external/blzpack/blzpackp.h 47;" d SLEPC_DEFAULT_TOL include/slepcmath.h 32;" d SLEPC_DEFAULT_TOL include/slepcmath.h 34;" d SLEPC_DEFAULT_TOL include/slepcmath.h 36;" d SLEPC_DEFAULT_TOL include/slepcmath.h 38;" d SLEPC_FEAST src/eps/impls/external/feast/feastp.h 37;" d SLEPC_FEAST src/eps/impls/external/feast/feastp.h 39;" d SLEPC_FEAST src/eps/impls/external/feast/feastp.h 41;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 49;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 51;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 53;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 59;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 61;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 63;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 73;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 75;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 77;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 83;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 85;" d SLEPC_FEASTM src/eps/impls/external/feast/feastp.h 87;" d SLEPC_INTERFACE_HEADER src/eps/impls/external/blopex/slepc-interface.h 26;" d SLEPC_RELEASE_DATE include/slepcversion.h 9;" d SLEPC_VERSION makefile /^ -@grep "define SLEPC_VERSION" ${SLEPC_DIR}\/include\/slepcversion.h | ${SED} "s\/........\/\/"$/;" m SLEPC_VERSION_ include/slepcversion.h 20;" d SLEPC_VERSION_DATE include/slepcversion.h 10;" d SLEPC_VERSION_DATE_GIT include/slepcversion.h 17;" d SLEPC_VERSION_GE include/slepcversion.h 41;" d SLEPC_VERSION_GIT include/slepcversion.h 13;" d SLEPC_VERSION_GT include/slepcversion.h 38;" d SLEPC_VERSION_LE include/slepcversion.h 34;" d SLEPC_VERSION_LT include/slepcversion.h 26;" d SLEPC_VERSION_MAJOR include/slepcversion.h 5;" d SLEPC_VERSION_MINOR include/slepcversion.h 6;" d SLEPC_VERSION_PATCH include/slepcversion.h 8;" d SLEPC_VERSION_RELEASE include/slepcversion.h 4;" d SLEPC_VERSION_SUBMINOR include/slepcversion.h 7;" d SLEPc config/packages/slepc.py /^class SLEPc:$/;" c SLICE_PTOL src/eps/impls/krylov/krylovschur/ks-slice.c 53;" d file: SOURCEC docs/makefile /^SOURCEC =$/;" m SOURCEC include/makefile /^SOURCEC =$/;" m SOURCEC include/slepc/finclude/makefile /^SOURCEC =$/;" m SOURCEC include/slepc/private/makefile /^SOURCEC =$/;" m SOURCEC src/eps/f90-mod/makefile /^SOURCEC =$/;" m SOURCEC src/eps/impls/cg/lobpcg/makefile /^SOURCEC = lobpcg.c$/;" m SOURCEC src/eps/impls/cg/rqcg/makefile /^SOURCEC = rqcg.c$/;" m SOURCEC src/eps/impls/ciss/makefile /^SOURCEC = ciss.c$/;" m SOURCEC src/eps/impls/davidson/gd/makefile /^SOURCEC = gd.c$/;" m SOURCEC src/eps/impls/davidson/jd/makefile /^SOURCEC = jd.c$/;" m SOURCEC src/eps/impls/davidson/makefile /^SOURCEC = davidson.c dvdcalcpairs.c dvdimprovex.c dvdinitv.c \\$/;" m SOURCEC src/eps/impls/external/arpack/makefile /^SOURCEC = arpack.c$/;" m SOURCEC src/eps/impls/external/blopex/makefile /^SOURCEC = blopex.c slepc-interface.c petsc-interface.c$/;" m SOURCEC src/eps/impls/external/blzpack/makefile /^SOURCEC = blzpack.c$/;" m SOURCEC src/eps/impls/external/feast/makefile /^SOURCEC = feast.c$/;" m SOURCEC src/eps/impls/external/primme/makefile /^SOURCEC = primme.c$/;" m SOURCEC src/eps/impls/external/trlan/makefile /^SOURCEC = trlan.c$/;" m SOURCEC src/eps/impls/krylov/arnoldi/makefile /^SOURCEC = arnoldi.c$/;" m SOURCEC src/eps/impls/krylov/krylovschur/makefile /^SOURCEC = krylovschur.c ks-symm.c ks-slice.c ks-indef.c$/;" m SOURCEC src/eps/impls/krylov/lanczos/makefile /^SOURCEC = lanczos.c$/;" m SOURCEC src/eps/impls/krylov/makefile /^SOURCEC = epskrylov.c$/;" m SOURCEC src/eps/impls/lapack/makefile /^SOURCEC = lapack.c$/;" m SOURCEC src/eps/impls/power/makefile /^SOURCEC = power.c$/;" m SOURCEC src/eps/impls/subspace/makefile /^SOURCEC = subspace.c$/;" m SOURCEC src/eps/interface/ftn-custom/makefile /^SOURCEC = zepsf.c$/;" m SOURCEC src/eps/interface/makefile /^SOURCEC = epsmon.c epsbasic.c epsview.c epsdefault.c epsregis.c epsopts.c epssetup.c epssolve.c dlregiseps.c$/;" m SOURCEC src/mfn/f90-mod/makefile /^SOURCEC =$/;" m SOURCEC src/mfn/impls/expokit/makefile /^SOURCEC = mfnexpokit.c$/;" m SOURCEC src/mfn/impls/krylov/makefile /^SOURCEC = mfnkrylov.c$/;" m SOURCEC src/mfn/interface/ftn-custom/makefile /^SOURCEC = zmfnf.c$/;" m SOURCEC src/mfn/interface/makefile /^SOURCEC = mfnmon.c mfnbasic.c mfnregis.c mfnopts.c mfnsetup.c mfnsolve.c dlregismfn.c$/;" m SOURCEC src/nep/f90-mod/makefile /^SOURCEC =$/;" m SOURCEC src/nep/impls/ciss/makefile /^SOURCEC = nciss.c$/;" m SOURCEC src/nep/impls/interpol/makefile /^SOURCEC = interpol.c$/;" m SOURCEC src/nep/impls/narnoldi/makefile /^SOURCEC = narnoldi.c$/;" m SOURCEC src/nep/impls/nleigs/makefile /^SOURCEC = nleigs.c$/;" m SOURCEC src/nep/impls/rii/makefile /^SOURCEC = rii.c$/;" m SOURCEC src/nep/impls/slp/makefile /^SOURCEC = slp.c$/;" m SOURCEC src/nep/interface/ftn-custom/makefile /^SOURCEC = znepf.c$/;" m SOURCEC src/nep/interface/makefile /^SOURCEC = nepmon.c nepbasic.c nepview.c nepdefault.c nepregis.c nepopts.c nepsetup.c nepsolve.c neprefine.c dlregisnep.c$/;" m SOURCEC src/pep/f90-mod/makefile /^SOURCEC =$/;" m SOURCEC src/pep/impls/jd/makefile /^SOURCEC = pjd.c pjdopt.c$/;" m SOURCEC src/pep/impls/krylov/makefile /^SOURCEC = pepkrylov.c$/;" m SOURCEC src/pep/impls/krylov/qarnoldi/makefile /^SOURCEC = qarnoldi.c$/;" m SOURCEC src/pep/impls/krylov/stoar/makefile /^SOURCEC = stoar.c$/;" m SOURCEC src/pep/impls/krylov/toar/makefile /^SOURCEC = ptoar.c nrefine.c$/;" m SOURCEC src/pep/impls/linear/makefile /^SOURCEC = linear.c qeplin.c$/;" m SOURCEC src/pep/interface/ftn-custom/makefile /^SOURCEC = zpepf.c$/;" m SOURCEC src/pep/interface/makefile /^SOURCEC = pepmon.c pepbasic.c pepview.c pepdefault.c pepregis.c pepopts.c pepsetup.c pepsolve.c peprefine.c dlregispep.c$/;" m SOURCEC src/svd/f90-mod/makefile /^SOURCEC =$/;" m SOURCEC src/svd/impls/cross/makefile /^SOURCEC = cross.c$/;" m SOURCEC src/svd/impls/cyclic/makefile /^SOURCEC = cyclic.c$/;" m SOURCEC src/svd/impls/lanczos/makefile /^SOURCEC = gklanczos.c$/;" m SOURCEC src/svd/impls/lapack/makefile /^SOURCEC = svdlapack.c$/;" m SOURCEC src/svd/impls/trlanczos/makefile /^SOURCEC = trlanczos.c$/;" m SOURCEC src/svd/interface/ftn-custom/makefile /^SOURCEC = zsvdf.c$/;" m SOURCEC src/svd/interface/makefile /^SOURCEC = svdregis.c svdbasic.c svddefault.c svdview.c svdopts.c svdsetup.c svdsolve.c svdmon.c dlregissvd.c$/;" m SOURCEC src/sys/classes/bv/impls/contiguous/makefile /^SOURCEC = contig.c$/;" m SOURCEC src/sys/classes/bv/impls/mat/makefile /^SOURCEC = bvmat.c$/;" m SOURCEC src/sys/classes/bv/impls/svec/makefile /^SOURCEC = svec.c$/;" m SOURCEC src/sys/classes/bv/impls/vecs/makefile /^SOURCEC = vecs.c$/;" m SOURCEC src/sys/classes/bv/interface/ftn-custom/makefile /^SOURCEC = zbvf.c$/;" m SOURCEC src/sys/classes/bv/interface/makefile /^SOURCEC = bvbasic.c bvfunc.c bvops.c bvglobal.c bvblas.c bvorthog.c bvregis.c$/;" m SOURCEC src/sys/classes/ds/impls/ghep/makefile /^SOURCEC = dsghep.c$/;" m SOURCEC src/sys/classes/ds/impls/ghiep/makefile /^SOURCEC = dsghiep.c invit.c hz.c dqds.c$/;" m SOURCEC src/sys/classes/ds/impls/gnhep/makefile /^SOURCEC = dsgnhep.c$/;" m SOURCEC src/sys/classes/ds/impls/hep/bdc/makefile /^SOURCEC = dibtdc.c dlaed3m.c dmerg2.c dsbtdc.c dsrtdf.c$/;" m SOURCEC src/sys/classes/ds/impls/hep/makefile /^SOURCEC = dshep.c$/;" m SOURCEC src/sys/classes/ds/impls/nep/makefile /^SOURCEC = dsnep.c$/;" m SOURCEC src/sys/classes/ds/impls/nhep/makefile /^SOURCEC = dsnhep.c$/;" m SOURCEC src/sys/classes/ds/impls/pep/makefile /^SOURCEC = dspep.c$/;" m SOURCEC src/sys/classes/ds/impls/svd/makefile /^SOURCEC = dssvd.c$/;" m SOURCEC src/sys/classes/ds/interface/ftn-custom/makefile /^SOURCEC = zdsf.c$/;" m SOURCEC src/sys/classes/ds/interface/makefile /^SOURCEC = dsbasic.c dsops.c dspriv.c$/;" m SOURCEC src/sys/classes/fn/impls/combine/makefile /^SOURCEC = fncombine.c$/;" m SOURCEC src/sys/classes/fn/impls/exp/makefile /^SOURCEC = fnexp.c$/;" m SOURCEC src/sys/classes/fn/impls/invsqrt/makefile /^SOURCEC = fninvsqrt.c$/;" m SOURCEC src/sys/classes/fn/impls/log/makefile /^SOURCEC = fnlog.c$/;" m SOURCEC src/sys/classes/fn/impls/makefile /^SOURCEC = fnutil.c$/;" m SOURCEC src/sys/classes/fn/impls/phi/makefile /^SOURCEC = fnphi.c$/;" m SOURCEC src/sys/classes/fn/impls/rational/makefile /^SOURCEC = fnrational.c$/;" m SOURCEC src/sys/classes/fn/impls/sqrt/makefile /^SOURCEC = fnsqrt.c$/;" m SOURCEC src/sys/classes/fn/interface/ftn-custom/makefile /^SOURCEC = zfnf.c$/;" m SOURCEC src/sys/classes/fn/interface/makefile /^SOURCEC = fnbasic.c fnregis.c$/;" m SOURCEC src/sys/classes/makefile /^SOURCEC =$/;" m SOURCEC src/sys/classes/rg/impls/ellipse/makefile /^SOURCEC = rgellipse.c$/;" m SOURCEC src/sys/classes/rg/impls/interval/makefile /^SOURCEC = rginterval.c$/;" m SOURCEC src/sys/classes/rg/impls/polygon/makefile /^SOURCEC = rgpolygon.c$/;" m SOURCEC src/sys/classes/rg/impls/ring/makefile /^SOURCEC = rgring.c$/;" m SOURCEC src/sys/classes/rg/interface/ftn-custom/makefile /^SOURCEC = zrgf.c$/;" m SOURCEC src/sys/classes/rg/interface/makefile /^SOURCEC = rgbasic.c rgregis.c$/;" m SOURCEC src/sys/classes/st/impls/cayley/makefile /^SOURCEC = cayley.c$/;" m SOURCEC src/sys/classes/st/impls/precond/makefile /^SOURCEC = precond.c$/;" m SOURCEC src/sys/classes/st/impls/shell/ftn-custom/makefile /^SOURCEC = zshell.c$/;" m SOURCEC src/sys/classes/st/impls/shell/makefile /^SOURCEC = shell.c$/;" m SOURCEC src/sys/classes/st/impls/shift/makefile /^SOURCEC = shift.c$/;" m SOURCEC src/sys/classes/st/impls/sinvert/makefile /^SOURCEC = sinvert.c$/;" m SOURCEC src/sys/classes/st/interface/ftn-custom/makefile /^SOURCEC = zstf.c$/;" m SOURCEC src/sys/classes/st/interface/makefile /^SOURCEC = stfunc.c stset.c stsolve.c stsles.c stregis.c stshellmat.c$/;" m SOURCEC src/sys/f90-mod/makefile /^SOURCEC =$/;" m SOURCEC src/sys/ftn-custom/makefile /^SOURCEC = zslepcutil.c zslepc_start.c zslepc_startf.c$/;" m SOURCEC src/sys/makefile /^SOURCEC = slepcinit.c slepcutil.c slepcsc.c dlregisslepc.c$/;" m SOURCEC src/sys/vec/makefile /^SOURCEC = veccomp.c pool.c$/;" m SOURCEF docs/makefile /^SOURCEF =$/;" m SOURCEF include/makefile /^SOURCEF =$/;" m SOURCEF include/slepc/finclude/makefile /^SOURCEF =$/;" m SOURCEF include/slepc/private/makefile /^SOURCEF =$/;" m SOURCEF src/eps/f90-mod/makefile /^SOURCEF = slepcepsmod.F$/;" m SOURCEF src/eps/impls/cg/lobpcg/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/cg/rqcg/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/ciss/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/davidson/gd/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/davidson/jd/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/davidson/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/external/arpack/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/external/blopex/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/external/blzpack/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/external/feast/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/external/primme/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/external/trlan/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/krylov/arnoldi/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/krylov/krylovschur/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/krylov/lanczos/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/krylov/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/lapack/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/power/makefile /^SOURCEF =$/;" m SOURCEF src/eps/impls/subspace/makefile /^SOURCEF =$/;" m SOURCEF src/eps/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/eps/interface/makefile /^SOURCEF =$/;" m SOURCEF src/mfn/f90-mod/makefile /^SOURCEF = slepcmfnmod.F$/;" m SOURCEF src/mfn/impls/expokit/makefile /^SOURCEF =$/;" m SOURCEF src/mfn/impls/krylov/makefile /^SOURCEF =$/;" m SOURCEF src/mfn/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/mfn/interface/makefile /^SOURCEF =$/;" m SOURCEF src/nep/f90-mod/makefile /^SOURCEF = slepcnepmod.F$/;" m SOURCEF src/nep/impls/ciss/makefile /^SOURCEF =$/;" m SOURCEF src/nep/impls/interpol/makefile /^SOURCEF =$/;" m SOURCEF src/nep/impls/narnoldi/makefile /^SOURCEF = $/;" m SOURCEF src/nep/impls/nleigs/makefile /^SOURCEF = $/;" m SOURCEF src/nep/impls/rii/makefile /^SOURCEF =$/;" m SOURCEF src/nep/impls/slp/makefile /^SOURCEF =$/;" m SOURCEF src/nep/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/nep/interface/makefile /^SOURCEF =$/;" m SOURCEF src/pep/f90-mod/makefile /^SOURCEF = slepcpepmod.F$/;" m SOURCEF src/pep/impls/jd/makefile /^SOURCEF =$/;" m SOURCEF src/pep/impls/krylov/makefile /^SOURCEF =$/;" m SOURCEF src/pep/impls/krylov/qarnoldi/makefile /^SOURCEF =$/;" m SOURCEF src/pep/impls/krylov/stoar/makefile /^SOURCEF =$/;" m SOURCEF src/pep/impls/krylov/toar/makefile /^SOURCEF =$/;" m SOURCEF src/pep/impls/linear/makefile /^SOURCEF =$/;" m SOURCEF src/pep/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/pep/interface/makefile /^SOURCEF =$/;" m SOURCEF src/svd/f90-mod/makefile /^SOURCEF = slepcsvdmod.F$/;" m SOURCEF src/svd/impls/cross/makefile /^SOURCEF =$/;" m SOURCEF src/svd/impls/cyclic/makefile /^SOURCEF =$/;" m SOURCEF src/svd/impls/lanczos/makefile /^SOURCEF =$/;" m SOURCEF src/svd/impls/lapack/makefile /^SOURCEF =$/;" m SOURCEF src/svd/impls/trlanczos/makefile /^SOURCEF =$/;" m SOURCEF src/svd/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/svd/interface/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/bv/impls/contiguous/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/bv/impls/mat/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/bv/impls/svec/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/bv/impls/vecs/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/bv/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/bv/interface/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/ghep/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/ghiep/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/gnhep/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/hep/bdc/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/hep/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/nep/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/nhep/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/pep/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/impls/svd/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/ds/interface/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/combine/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/exp/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/invsqrt/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/log/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/phi/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/rational/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/impls/sqrt/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/fn/interface/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/rg/impls/ellipse/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/rg/impls/interval/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/rg/impls/polygon/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/rg/impls/ring/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/rg/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/rg/interface/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/impls/cayley/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/impls/precond/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/impls/shell/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/impls/shell/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/impls/shift/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/impls/sinvert/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/interface/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/sys/classes/st/interface/makefile /^SOURCEF =$/;" m SOURCEF src/sys/f90-mod/makefile /^SOURCEF = slepcsysmod.F$/;" m SOURCEF src/sys/ftn-custom/makefile /^SOURCEF =$/;" m SOURCEF src/sys/makefile /^SOURCEF =$/;" m SOURCEF src/sys/vec/makefile /^SOURCEF =$/;" m SOURCEH docs/makefile /^SOURCEH = $/;" m SOURCEH include/makefile /^SOURCEH = slepc.h slepcsys.h slepcmath.h slepcversion.h slepcblaslapack.h \\$/;" m SOURCEH include/slepc/finclude/makefile /^SOURCEH = slepc.h slepceps.h slepcst.h slepcsvd.h slepcpep.h \\$/;" m SOURCEH include/slepc/private/makefile /^SOURCEH = epsimpl.h stimpl.h svdimpl.h pepimpl.h \\$/;" m SOURCEH src/eps/f90-mod/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/cg/lobpcg/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/cg/rqcg/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/ciss/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/davidson/gd/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/davidson/jd/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/davidson/makefile /^SOURCEH = davidson.h$/;" m SOURCEH src/eps/impls/external/arpack/makefile /^SOURCEH = arpackp.h$/;" m SOURCEH src/eps/impls/external/blopex/makefile /^SOURCEH = slepc-interface.h petsc-interface.h$/;" m SOURCEH src/eps/impls/external/blzpack/makefile /^SOURCEH = blzpackp.h$/;" m SOURCEH src/eps/impls/external/feast/makefile /^SOURCEH = feastp.h$/;" m SOURCEH src/eps/impls/external/primme/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/external/trlan/makefile /^SOURCEH = trlanp.h$/;" m SOURCEH src/eps/impls/krylov/arnoldi/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/krylov/krylovschur/makefile /^SOURCEH = krylovschur.h$/;" m SOURCEH src/eps/impls/krylov/lanczos/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/krylov/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/lapack/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/power/makefile /^SOURCEH =$/;" m SOURCEH src/eps/impls/subspace/makefile /^SOURCEH =$/;" m SOURCEH src/eps/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/eps/interface/makefile /^SOURCEH =$/;" m SOURCEH src/eps/makefile /^SOURCEH = ..\/..\/include\/slepc\/private\/epsimpl.h ..\/..\/include\/slepceps.h$/;" m SOURCEH src/mfn/f90-mod/makefile /^SOURCEH =$/;" m SOURCEH src/mfn/impls/expokit/makefile /^SOURCEH =$/;" m SOURCEH src/mfn/impls/krylov/makefile /^SOURCEH =$/;" m SOURCEH src/mfn/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/mfn/interface/makefile /^SOURCEH =$/;" m SOURCEH src/mfn/makefile /^SOURCEH = ..\/..\/include\/slepc\/private\/mfnimpl.h ..\/..\/include\/slepcmfn.h$/;" m SOURCEH src/nep/f90-mod/makefile /^SOURCEH =$/;" m SOURCEH src/nep/impls/ciss/makefile /^SOURCEH =$/;" m SOURCEH src/nep/impls/interpol/makefile /^SOURCEH =$/;" m SOURCEH src/nep/impls/narnoldi/makefile /^SOURCEH =$/;" m SOURCEH src/nep/impls/nleigs/makefile /^SOURCEH =$/;" m SOURCEH src/nep/impls/rii/makefile /^SOURCEH =$/;" m SOURCEH src/nep/impls/slp/makefile /^SOURCEH =$/;" m SOURCEH src/nep/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/nep/interface/makefile /^SOURCEH =$/;" m SOURCEH src/nep/makefile /^SOURCEH = ..\/..\/include\/slepc\/private\/nepimpl.h ..\/..\/include\/slepcnep.h$/;" m SOURCEH src/pep/f90-mod/makefile /^SOURCEH =$/;" m SOURCEH src/pep/impls/jd/makefile /^SOURCEH = pjdp.h$/;" m SOURCEH src/pep/impls/krylov/makefile /^SOURCEH = pepkrylov.h$/;" m SOURCEH src/pep/impls/krylov/qarnoldi/makefile /^SOURCEH =$/;" m SOURCEH src/pep/impls/krylov/stoar/makefile /^SOURCEH =$/;" m SOURCEH src/pep/impls/krylov/toar/makefile /^SOURCEH =$/;" m SOURCEH src/pep/impls/linear/makefile /^SOURCEH = linearp.h$/;" m SOURCEH src/pep/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/pep/interface/makefile /^SOURCEH =$/;" m SOURCEH src/pep/makefile /^SOURCEH = ..\/..\/include\/slepc\/private\/pepimpl.h ..\/..\/include\/slepcpep.h$/;" m SOURCEH src/svd/f90-mod/makefile /^SOURCEH =$/;" m SOURCEH src/svd/impls/cross/makefile /^SOURCEH =$/;" m SOURCEH src/svd/impls/cyclic/makefile /^SOURCEH =$/;" m SOURCEH src/svd/impls/lanczos/makefile /^SOURCEH =$/;" m SOURCEH src/svd/impls/lapack/makefile /^SOURCEH =$/;" m SOURCEH src/svd/impls/trlanczos/makefile /^SOURCEH =$/;" m SOURCEH src/svd/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/svd/interface/makefile /^SOURCEH =$/;" m SOURCEH src/svd/makefile /^SOURCEH = ..\/..\/include\/slepc\/private\/svdimpl.h ..\/..\/include\/slepcsvd.h$/;" m SOURCEH src/sys/classes/bv/impls/contiguous/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/bv/impls/mat/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/bv/impls/svec/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/bv/impls/vecs/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/bv/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/bv/interface/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/bv/makefile /^SOURCEH = ..\/..\/..\/..\/include\/slepc\/private\/bvimpl.h ..\/..\/..\/..\/include\/slepcbv.h$/;" m SOURCEH src/sys/classes/ds/impls/ghep/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/ghiep/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/gnhep/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/hep/bdc/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/hep/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/nep/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/nhep/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/pep/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/impls/svd/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/interface/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/ds/makefile /^SOURCEH = ..\/..\/..\/..\/include\/slepc\/private\/dsimpl.h ..\/..\/..\/..\/include\/slepcds.h$/;" m SOURCEH src/sys/classes/fn/impls/combine/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/impls/exp/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/impls/invsqrt/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/impls/log/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/impls/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/impls/phi/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/impls/rational/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/impls/sqrt/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/interface/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/fn/makefile /^SOURCEH = ..\/..\/..\/..\/include\/slepc\/private\/fnimpl.h ..\/..\/..\/..\/include\/slepcfn.h$/;" m SOURCEH src/sys/classes/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/rg/impls/ellipse/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/rg/impls/interval/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/rg/impls/polygon/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/rg/impls/ring/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/rg/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/rg/interface/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/rg/makefile /^SOURCEH = ..\/..\/..\/..\/include\/slepc\/private\/rgimpl.h ..\/..\/..\/..\/include\/slepcrg.h ..\/..\/..\/..\/include\/slepcrgtypes.h$/;" m SOURCEH src/sys/classes/st/impls/cayley/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/impls/precond/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/impls/shell/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/impls/shell/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/impls/shift/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/impls/sinvert/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/interface/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/interface/makefile /^SOURCEH =$/;" m SOURCEH src/sys/classes/st/makefile /^SOURCEH = ..\/..\/..\/..\/include\/slepc\/private\/stimpl.h ..\/..\/..\/..\/include\/slepcst.h$/;" m SOURCEH src/sys/f90-mod/makefile /^SOURCEH =$/;" m SOURCEH src/sys/ftn-custom/makefile /^SOURCEH =$/;" m SOURCEH src/sys/makefile /^SOURCEH =$/;" m SOURCEH src/sys/vec/makefile /^SOURCEH = veccomp0.h$/;" m SPECIALFASTLIB src/eps/f90-mod/makefile /^SPECIALFASTLIB = yes$/;" m SPECIALFASTLIB src/mfn/f90-mod/makefile /^SPECIALFASTLIB = yes$/;" m SPECIALFASTLIB src/nep/f90-mod/makefile /^SPECIALFASTLIB = yes$/;" m SPECIALFASTLIB src/pep/f90-mod/makefile /^SPECIALFASTLIB = yes$/;" m SPECIALFASTLIB src/svd/f90-mod/makefile /^SPECIALFASTLIB = yes$/;" m SPECIALFASTLIB src/sys/f90-mod/makefile /^SPECIALFASTLIB = yes$/;" m SPECIALLIB src/eps/f90-mod/makefile /^SPECIALLIB = yes$/;" m SPECIALLIB src/mfn/f90-mod/makefile /^SPECIALLIB = yes$/;" m SPECIALLIB src/nep/f90-mod/makefile /^SPECIALLIB = yes$/;" m SPECIALLIB src/pep/f90-mod/makefile /^SPECIALLIB = yes$/;" m SPECIALLIB src/svd/f90-mod/makefile /^SPECIALLIB = yes$/;" m SPECIALLIB src/sys/f90-mod/makefile /^SPECIALLIB = yes$/;" m ST include/slepc/finclude/slepcstdef.h 29;" d ST include/slepcst.h /^typedef struct _p_ST* ST;$/;" t typeref:struct:_p_ST STAppendOptionsPrefix src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix)$/;" f STApply src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STApply(ST st,Vec x,Vec y)$/;" f STApplyTranspose src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STApplyTranspose(ST st,Vec x,Vec y)$/;" f STApplyTranspose_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STApplyTranspose_Cayley(ST st,Vec x,Vec y)$/;" f STApplyTranspose_Shell src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y)$/;" f STApplyTranspose_Shift src/sys/classes/st/impls/shift/shift.c /^PetscErrorCode STApplyTranspose_Shift(ST st,Vec x,Vec y)$/;" f STApplyTranspose_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PetscErrorCode STApplyTranspose_Sinvert(ST st,Vec x,Vec y)$/;" f STApply_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STApply_Cayley(ST st,Vec x,Vec y)$/;" f STApply_Shell src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STApply_Shell(ST st,Vec x,Vec y)$/;" f STApply_Shift src/sys/classes/st/impls/shift/shift.c /^PetscErrorCode STApply_Shift(ST st,Vec x,Vec y)$/;" f STApply_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PetscErrorCode STApply_Sinvert(ST st,Vec x,Vec y)$/;" f STApply_User src/eps/examples/tutorials/ex10.c /^PetscErrorCode STApply_User(ST st,Vec x,Vec y)$/;" f STBackTransform src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STBackTransform(ST st,PetscInt n,PetscScalar* eigr,PetscScalar* eigi)$/;" f STBackTransform_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STBackTransform_Cayley(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)$/;" f STBackTransform_Shell src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)$/;" f STBackTransform_Shift src/sys/classes/st/impls/shift/shift.c /^PetscErrorCode STBackTransform_Shift(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)$/;" f STBackTransform_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PetscErrorCode STBackTransform_Sinvert(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)$/;" f STBackTransform_User src/eps/examples/tutorials/ex10.c /^PetscErrorCode STBackTransform_User(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)$/;" f STCAYLEY include/slepc/finclude/slepcstdef.h 38;" d STCAYLEY include/slepcst.h 53;" d STCayleyGetAntishift src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STCayleyGetAntishift(ST st,PetscScalar *nu)$/;" f STCayleyGetAntishift_Cayley src/sys/classes/st/impls/cayley/cayley.c /^static PetscErrorCode STCayleyGetAntishift_Cayley(ST st,PetscScalar *nu)$/;" f file: STCayleySetAntishift src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STCayleySetAntishift(ST st,PetscScalar nu)$/;" f STCayleySetAntishift_Cayley src/sys/classes/st/impls/cayley/cayley.c /^static PetscErrorCode STCayleySetAntishift_Cayley(ST st,PetscScalar newshift)$/;" f file: STCheckFactorPackage src/sys/classes/st/interface/stsles.c /^PetscErrorCode STCheckFactorPackage(ST st)$/;" f STCheckMatrices include/slepc/private/stimpl.h 103;" d STCheckMatrices include/slepc/private/stimpl.h 107;" d STCheckNullSpace src/sys/classes/st/interface/stsles.c /^PetscErrorCode STCheckNullSpace(ST st,BV V)$/;" f STCheckNullSpace_Default src/sys/classes/st/interface/stsles.c /^PetscErrorCode STCheckNullSpace_Default(ST st,BV V)$/;" f STCoeffs_Monomial src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STCoeffs_Monomial(ST st, PetscScalar *coeffs)$/;" f STComputeExplicitOperator src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STComputeExplicitOperator(ST st,Mat *mat)$/;" f STCreate src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STCreate(MPI_Comm comm,ST *newst)$/;" f STCreate_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PETSC_EXTERN PetscErrorCode STCreate_Cayley(ST st)$/;" f STCreate_Precond src/sys/classes/st/impls/precond/precond.c /^PETSC_EXTERN PetscErrorCode STCreate_Precond(ST st)$/;" f STCreate_Shell src/sys/classes/st/impls/shell/shell.c /^PETSC_EXTERN PetscErrorCode STCreate_Shell(ST st)$/;" f STCreate_Shift src/sys/classes/st/impls/shift/shift.c /^PETSC_EXTERN PetscErrorCode STCreate_Shift(ST st)$/;" f STCreate_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PETSC_EXTERN PetscErrorCode STCreate_Sinvert(ST st)$/;" f STCreate_User src/eps/examples/tutorials/ex10.c /^PetscErrorCode STCreate_User(SampleShellST **shell)$/;" f STDestroy src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STDestroy(ST *st)$/;" f STDestroy_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STDestroy_Cayley(ST st)$/;" f STDestroy_Precond src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STDestroy_Precond(ST st)$/;" f STDestroy_Shell src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STDestroy_Shell(ST st)$/;" f STDestroy_User src/eps/examples/tutorials/ex10.c /^PetscErrorCode STDestroy_User(SampleShellST *shell)$/;" f STFinalizePackage src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STFinalizePackage(void)$/;" f STGetBalanceMatrix src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STGetBalanceMatrix(ST st,Vec *D)$/;" f STGetBilinearForm src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STGetBilinearForm(ST st,Mat *B)$/;" f STGetBilinearForm_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STGetBilinearForm_Cayley(ST st,Mat *B)$/;" f STGetBilinearForm_Default src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STGetBilinearForm_Default(ST st,Mat *B)$/;" f STGetKSP src/sys/classes/st/interface/stsles.c /^PetscErrorCode STGetKSP(ST st,KSP* ksp)$/;" f STGetMatMode src/sys/classes/st/interface/stset.c /^PetscErrorCode STGetMatMode(ST st,STMatMode *mode)$/;" f STGetMatStructure src/sys/classes/st/interface/stset.c /^PetscErrorCode STGetMatStructure(ST st,MatStructure *str)$/;" f STGetNumMatrices src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STGetNumMatrices(ST st,PetscInt *n)$/;" f STGetOperators src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STGetOperators(ST st,PetscInt k,Mat *A)$/;" f STGetOptionsPrefix src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[])$/;" f STGetShift src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STGetShift(ST st,PetscScalar* shift)$/;" f STGetTOperators src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STGetTOperators(ST st,PetscInt k,Mat *T)$/;" f STGetTransform src/sys/classes/st/interface/stset.c /^PetscErrorCode STGetTransform(ST st,PetscBool *flg)$/;" f STGetType src/sys/classes/st/interface/stset.c /^PetscErrorCode STGetType(ST st,STType *type)$/;" f STInitializePackage src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STInitializePackage(void)$/;" f STList include/slepcst.h /^PETSC_EXTERN PetscFunctionList STList;$/;" v STList src/sys/classes/st/interface/stset.c /^PetscFunctionList STList = 0;$/;" v STMatCreateVecs src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STMatCreateVecs(ST st,Vec *right,Vec *left)$/;" f STMatGetLocalSize src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STMatGetLocalSize(ST st,PetscInt *m,PetscInt *n)$/;" f STMatGetSize src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STMatGetSize(ST st,PetscInt *m,PetscInt *n)$/;" f STMatMAXPY_Private src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STMatMAXPY_Private(ST st,PetscScalar alpha,PetscScalar beta,PetscInt k,PetscScalar *coeffs,PetscBool initial,Mat *S)$/;" f STMatMode include/slepc/finclude/slepcstdef.h 33;" d STMatMode include/slepcst.h /^ ST_MATMODE_SHELL } STMatMode;$/;" t typeref:enum:__anon48 STMatMult src/sys/classes/st/interface/stsles.c /^PetscErrorCode STMatMult(ST st,PetscInt k,Vec x,Vec y)$/;" f STMatMultTranspose src/sys/classes/st/interface/stsles.c /^PetscErrorCode STMatMultTranspose(ST st,PetscInt k,Vec x,Vec y)$/;" f STMatSetHermitian src/sys/classes/st/interface/stsles.c /^PetscErrorCode STMatSetHermitian(ST st,Mat M)$/;" f STMatSetUp src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STMatSetUp(ST st,PetscScalar sigma,PetscScalar *coeffs)$/;" f STMatShellCreate src/sys/classes/st/interface/stshellmat.c /^PetscErrorCode STMatShellCreate(ST st,PetscScalar alpha,PetscInt nmat,PetscInt *matIdx,PetscScalar *coeffs,Mat *mat)$/;" f STMatShellShift src/sys/classes/st/interface/stshellmat.c /^PetscErrorCode STMatShellShift(Mat A,PetscScalar alpha)$/;" f STMatSolve src/sys/classes/st/interface/stsles.c /^PetscErrorCode STMatSolve(ST st,Vec b,Vec x)$/;" f STMatSolveTranspose src/sys/classes/st/interface/stsles.c /^PetscErrorCode STMatSolveTranspose(ST st,Vec b,Vec x)$/;" f STOps include/slepc/private/stimpl.h /^typedef struct _STOps *STOps;$/;" t typeref:struct:_STOps STPRECOND include/slepc/finclude/slepcstdef.h 39;" d STPRECOND include/slepcst.h 54;" d STPackageInitialized src/sys/classes/st/interface/stfunc.c /^static PetscBool STPackageInitialized = PETSC_FALSE;$/;" v file: STPostSolve src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STPostSolve(ST st)$/;" f STPostSolve_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STPostSolve_Cayley(ST st)$/;" f STPostSolve_Shift src/sys/classes/st/impls/shift/shift.c /^PetscErrorCode STPostSolve_Shift(ST st)$/;" f STPostSolve_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PetscErrorCode STPostSolve_Sinvert(ST st)$/;" f STPrecondGetKSPHasMat src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STPrecondGetKSPHasMat(ST st,PetscBool *setmat)$/;" f STPrecondGetKSPHasMat_Precond src/sys/classes/st/impls/precond/precond.c /^static PetscErrorCode STPrecondGetKSPHasMat_Precond(ST st,PetscBool *setmat)$/;" f file: STPrecondGetMatForPC src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STPrecondGetMatForPC(ST st,Mat *mat)$/;" f STPrecondGetMatForPC_Precond src/sys/classes/st/impls/precond/precond.c /^static PetscErrorCode STPrecondGetMatForPC_Precond(ST st,Mat *mat)$/;" f file: STPrecondSetKSPHasMat src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STPrecondSetKSPHasMat(ST st,PetscBool setmat)$/;" f STPrecondSetKSPHasMat_Precond src/sys/classes/st/impls/precond/precond.c /^static PetscErrorCode STPrecondSetKSPHasMat_Precond(ST st,PetscBool setmat)$/;" f file: STPrecondSetMatForPC src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STPrecondSetMatForPC(ST st,Mat mat)$/;" f STPrecondSetMatForPC_Precond src/sys/classes/st/impls/precond/precond.c /^static PetscErrorCode STPrecondSetMatForPC_Precond(ST st,Mat mat)$/;" f file: STRegister src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STRegister(const char *name,PetscErrorCode (*function)(ST))$/;" f STRegisterAll src/sys/classes/st/interface/stregis.c /^PetscErrorCode STRegisterAll(void)$/;" f STRegisterAllCalled include/slepc/private/stimpl.h /^PETSC_EXTERN PetscBool STRegisterAllCalled;$/;" v STRegisterAllCalled src/sys/classes/st/interface/stset.c /^PetscBool STRegisterAllCalled = PETSC_FALSE;$/;" v STReset src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STReset(ST st)$/;" f STReset_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STReset_Cayley(ST st)$/;" f STSHELL include/slepc/finclude/slepcstdef.h 35;" d STSHELL include/slepcst.h 50;" d STSHIFT include/slepc/finclude/slepcstdef.h 36;" d STSHIFT include/slepcst.h 51;" d STSINVERT include/slepc/finclude/slepcstdef.h 37;" d STSINVERT include/slepcst.h 52;" d STScaleShift src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STScaleShift(ST st,PetscScalar factor)$/;" f STSetBalanceMatrix src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STSetBalanceMatrix(ST st,Vec D)$/;" f STSetDefaultPrecond src/sys/classes/st/impls/precond/precond.c /^static PetscErrorCode STSetDefaultPrecond(ST st)$/;" f file: STSetDefaultShift src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STSetDefaultShift(ST st,PetscScalar defaultshift)$/;" f STSetFromOptions src/sys/classes/st/interface/stset.c /^PetscErrorCode STSetFromOptions(ST st)$/;" f STSetFromOptions_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STSetFromOptions_Cayley(PetscOptionItems *PetscOptionsObject,ST st)$/;" f STSetFromOptions_Precond src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STSetFromOptions_Precond(PetscOptionItems *PetscOptionsObject,ST st)$/;" f STSetFromOptions_Shell src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STSetFromOptions_Shell(PetscOptionItems *PetscOptionsObject,ST st)$/;" f STSetFromOptions_Shift src/sys/classes/st/impls/shift/shift.c /^PetscErrorCode STSetFromOptions_Shift(PetscOptionItems *PetscOptionsObject,ST st)$/;" f STSetFromOptions_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PetscErrorCode STSetFromOptions_Sinvert(PetscOptionItems *PetscOptionsObject,ST st)$/;" f STSetKSP src/sys/classes/st/interface/stsles.c /^PetscErrorCode STSetKSP(ST st,KSP ksp)$/;" f STSetMatMode src/sys/classes/st/interface/stset.c /^PetscErrorCode STSetMatMode(ST st,STMatMode mode)$/;" f STSetMatStructure src/sys/classes/st/interface/stset.c /^PetscErrorCode STSetMatStructure(ST st,MatStructure str)$/;" f STSetOperators src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STSetOperators(ST st,PetscInt n,Mat A[])$/;" f STSetOptionsPrefix src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix)$/;" f STSetShift src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STSetShift(ST st,PetscScalar shift)$/;" f STSetShift_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STSetShift_Cayley(ST st,PetscScalar newshift)$/;" f STSetShift_Precond src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STSetShift_Precond(ST st,PetscScalar newshift)$/;" f STSetShift_Shift src/sys/classes/st/impls/shift/shift.c /^PetscErrorCode STSetShift_Shift(ST st,PetscScalar newshift)$/;" f STSetShift_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PetscErrorCode STSetShift_Sinvert(ST st,PetscScalar newshift)$/;" f STSetTransform src/sys/classes/st/interface/stset.c /^PetscErrorCode STSetTransform(ST st,PetscBool flg)$/;" f STSetType src/sys/classes/st/interface/stset.c /^PetscErrorCode STSetType(ST st,STType type)$/;" f STSetUp src/sys/classes/st/interface/stsolve.c /^PetscErrorCode STSetUp(ST st)$/;" f STSetUp_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STSetUp_Cayley(ST st)$/;" f STSetUp_Precond src/sys/classes/st/impls/precond/precond.c /^PetscErrorCode STSetUp_Precond(ST st)$/;" f STSetUp_Shift src/sys/classes/st/impls/shift/shift.c /^PetscErrorCode STSetUp_Shift(ST st)$/;" f STSetUp_Sinvert src/sys/classes/st/impls/sinvert/sinvert.c /^PetscErrorCode STSetUp_Sinvert(ST st)$/;" f STSetUp_User src/eps/examples/tutorials/ex10.c /^PetscErrorCode STSetUp_User(SampleShellST *shell,ST st)$/;" f STShellGetContext src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STShellGetContext(ST st,void **ctx)$/;" f STShellSetApply src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))$/;" f STShellSetApplyTranspose src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))$/;" f STShellSetApplyTranspose_Shell src/sys/classes/st/impls/shell/shell.c /^static PetscErrorCode STShellSetApplyTranspose_Shell(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))$/;" f file: STShellSetApply_Shell src/sys/classes/st/impls/shell/shell.c /^static PetscErrorCode STShellSetApply_Shell(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))$/;" f file: STShellSetBackTransform src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))$/;" f STShellSetBackTransform_Shell src/sys/classes/st/impls/shell/shell.c /^static PetscErrorCode STShellSetBackTransform_Shell(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))$/;" f file: STShellSetContext src/sys/classes/st/impls/shell/shell.c /^PetscErrorCode STShellSetContext(ST st,void *ctx)$/;" f STStateType include/slepc/private/stimpl.h /^ ST_STATE_UPDATED } STStateType;$/;" t typeref:enum:__anon5 STType include/slepc/finclude/slepcstdef.h 32;" d STType include/slepcst.h /^typedef const char* STType;$/;" t STView src/sys/classes/st/interface/stfunc.c /^PetscErrorCode STView(ST st,PetscViewer viewer)$/;" f STView_Cayley src/sys/classes/st/impls/cayley/cayley.c /^PetscErrorCode STView_Cayley(ST st,PetscViewer viewer)$/;" f ST_AllocateWorkVec include/slepc/private/stimpl.h /^PETSC_STATIC_INLINE PetscErrorCode ST_AllocateWorkVec(ST st)$/;" f ST_Apply include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_Apply src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v ST_ApplyTranspose include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_ApplyTranspose src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v ST_CAYLEY src/sys/classes/st/impls/cayley/cayley.c /^} ST_CAYLEY;$/;" t typeref:struct:__anon128 file: ST_CLASSID include/slepcst.h /^PETSC_EXTERN PetscClassId ST_CLASSID;$/;" v ST_CLASSID src/sys/classes/st/interface/stfunc.c /^PetscClassId ST_CLASSID = 0;$/;" v ST_MATMODE_COPY include/slepcst.h /^typedef enum { ST_MATMODE_COPY,$/;" e enum:__anon48 ST_MATMODE_INPLACE include/slepcst.h /^ ST_MATMODE_INPLACE,$/;" e enum:__anon48 ST_MATMODE_SHELL include/slepcst.h /^ ST_MATMODE_SHELL } STMatMode;$/;" e enum:__anon48 ST_MatMult include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_MatMult src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v ST_MatMultTranspose include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_MatMultTranspose src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v ST_MatSetUp include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_MatSetUp src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v ST_MatSolve include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_MatSolve src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v ST_MatSolveTranspose include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_MatSolveTranspose src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v ST_PRECOND src/sys/classes/st/impls/precond/precond.c /^} ST_PRECOND;$/;" t typeref:struct:__anon129 file: ST_SHELL src/sys/classes/st/impls/shell/shell.c /^} ST_SHELL;$/;" t typeref:struct:__anon131 file: ST_SHELLMAT src/sys/classes/st/interface/stshellmat.c /^} ST_SHELLMAT;$/;" t typeref:struct:__anon132 file: ST_STATE_INITIAL include/slepc/private/stimpl.h /^typedef enum { ST_STATE_INITIAL,$/;" e enum:__anon5 ST_STATE_SETUP include/slepc/private/stimpl.h /^ ST_STATE_SETUP,$/;" e enum:__anon5 ST_STATE_UPDATED include/slepc/private/stimpl.h /^ ST_STATE_UPDATED } STStateType;$/;" e enum:__anon5 ST_SetUp include/slepc/private/stimpl.h /^PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;$/;" v ST_SetUp src/sys/classes/st/interface/stfunc.c /^PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;$/;" v SVD include/slepc/finclude/slepcsvddef.h 31;" d SVD include/slepcsvd.h /^typedef struct _p_SVD* SVD;$/;" t typeref:struct:_p_SVD SVD src/svd/examples/tests/makefile /^SVD = lanczos lapack trlanczos$/;" m SVDAllocateSolution src/svd/interface/svdsetup.c /^PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra)$/;" f SVDAppendOptionsPrefix src/svd/interface/svdopts.c /^PetscErrorCode SVDAppendOptionsPrefix(SVD svd,const char *prefix)$/;" f SVDCROSS include/slepc/finclude/slepcsvddef.h 41;" d SVDCROSS include/slepcsvd.h 50;" d SVDCYCLIC include/slepc/finclude/slepcsvddef.h 42;" d SVDCYCLIC include/slepcsvd.h 51;" d SVDCheckSolved include/slepc/private/svdimpl.h 110;" d SVDCheckSolved include/slepc/private/svdimpl.h 114;" d SVDComputeError src/svd/interface/svdsolve.c /^PetscErrorCode SVDComputeError(SVD svd,PetscInt i,SVDErrorType type,PetscReal *error)$/;" f SVDComputeRelativeError include/slepcsvd.h /^PETSC_DEPRECATED("Use SVDComputeError()") PETSC_STATIC_INLINE PetscErrorCode SVDComputeRelativeError(SVD svd,PetscInt i,PetscReal *r) {return SVDComputeError(svd,i,SVD_ERROR_RELATIVE,r);}$/;" f SVDComputeResidualNorms include/slepcsvd.h /^PETSC_DEPRECATED("Use SVDComputeError() with SVD_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode SVDComputeResidualNorms(SVD svd,PetscInt i,PetscReal *r1,PETSC_UNUSED PetscReal *r2) {return SVDComputeError(svd,i,SVD_ERROR_ABSOLUTE,r1);}$/;" f SVDComputeResidualNorms_Private src/svd/interface/svdsolve.c /^static PetscErrorCode SVDComputeResidualNorms_Private(SVD svd,PetscInt i,PetscReal *norm1,PetscReal *norm2)$/;" f file: SVDComputeVectors src/svd/interface/svdsolve.c /^PetscErrorCode SVDComputeVectors(SVD svd)$/;" f SVDConv include/slepc/finclude/slepcsvddef.h 38;" d SVDConv include/slepcsvd.h /^ SVD_CONV_USER } SVDConv;$/;" t typeref:enum:__anon51 SVDConvMonitorSetFromOptions src/svd/interface/svdopts.c /^PetscErrorCode SVDConvMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor))$/;" f SVDConvergedAbsolute src/svd/interface/svddefault.c /^PetscErrorCode SVDConvergedAbsolute(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)$/;" f SVDConvergedReason include/slepc/finclude/slepcsvddef.h 35;" d SVDConvergedReason include/slepcsvd.h /^ SVD_CONVERGED_ITERATING = 0 } SVDConvergedReason;$/;" t typeref:enum:__anon53 SVDConvergedReasons include/slepcsvd.h /^PETSC_EXTERN const char *const*SVDConvergedReasons;$/;" v SVDConvergedReasons src/svd/interface/dlregissvd.c /^const char *const*SVDConvergedReasons = SVDConvergedReasons_Shifted + 4;$/;" v SVDConvergedReasons_Shifted src/svd/interface/dlregissvd.c /^const char *const SVDConvergedReasons_Shifted[] = {"","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","SVDConvergedReason","SVD_",0};$/;" v SVDConvergedRelative src/svd/interface/svddefault.c /^PetscErrorCode SVDConvergedRelative(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)$/;" f SVDCreate src/svd/interface/svdbasic.c /^PetscErrorCode SVDCreate(MPI_Comm comm,SVD *outsvd)$/;" f SVDCreate_Cross src/svd/impls/cross/cross.c /^PETSC_EXTERN PetscErrorCode SVDCreate_Cross(SVD svd)$/;" f SVDCreate_Cyclic src/svd/impls/cyclic/cyclic.c /^PETSC_EXTERN PetscErrorCode SVDCreate_Cyclic(SVD svd)$/;" f SVDCreate_LAPACK src/svd/impls/lapack/svdlapack.c /^PETSC_EXTERN PetscErrorCode SVDCreate_LAPACK(SVD svd)$/;" f SVDCreate_Lanczos src/svd/impls/lanczos/gklanczos.c /^PETSC_EXTERN PetscErrorCode SVDCreate_Lanczos(SVD svd)$/;" f SVDCreate_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^PETSC_EXTERN PetscErrorCode SVDCreate_TRLanczos(SVD svd)$/;" f SVDCrossGetEPS src/svd/impls/cross/cross.c /^PetscErrorCode SVDCrossGetEPS(SVD svd,EPS *eps)$/;" f SVDCrossGetEPS_Cross src/svd/impls/cross/cross.c /^static PetscErrorCode SVDCrossGetEPS_Cross(SVD svd,EPS *eps)$/;" f file: SVDCrossSetEPS src/svd/impls/cross/cross.c /^PetscErrorCode SVDCrossSetEPS(SVD svd,EPS eps)$/;" f SVDCrossSetEPS_Cross src/svd/impls/cross/cross.c /^static PetscErrorCode SVDCrossSetEPS_Cross(SVD svd,EPS eps)$/;" f file: SVDCyclicGetEPS src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDCyclicGetEPS(SVD svd,EPS *eps)$/;" f SVDCyclicGetEPS_Cyclic src/svd/impls/cyclic/cyclic.c /^static PetscErrorCode SVDCyclicGetEPS_Cyclic(SVD svd,EPS *eps)$/;" f file: SVDCyclicGetExplicitMatrix src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDCyclicGetExplicitMatrix(SVD svd,PetscBool *explicitmatrix)$/;" f SVDCyclicGetExplicitMatrix_Cyclic src/svd/impls/cyclic/cyclic.c /^static PetscErrorCode SVDCyclicGetExplicitMatrix_Cyclic(SVD svd,PetscBool *explicitmatrix)$/;" f file: SVDCyclicSetEPS src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDCyclicSetEPS(SVD svd,EPS eps)$/;" f SVDCyclicSetEPS_Cyclic src/svd/impls/cyclic/cyclic.c /^static PetscErrorCode SVDCyclicSetEPS_Cyclic(SVD svd,EPS eps)$/;" f file: SVDCyclicSetExplicitMatrix src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDCyclicSetExplicitMatrix(SVD svd,PetscBool explicitmatrix)$/;" f SVDCyclicSetExplicitMatrix_Cyclic src/svd/impls/cyclic/cyclic.c /^static PetscErrorCode SVDCyclicSetExplicitMatrix_Cyclic(SVD svd,PetscBool explicitmatrix)$/;" f file: SVDDestroy src/svd/interface/svdbasic.c /^PetscErrorCode SVDDestroy(SVD *svd)$/;" f SVDDestroy_Cross src/svd/impls/cross/cross.c /^PetscErrorCode SVDDestroy_Cross(SVD svd)$/;" f SVDDestroy_Cyclic src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDDestroy_Cyclic(SVD svd)$/;" f SVDDestroy_Lanczos src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDDestroy_Lanczos(SVD svd)$/;" f SVDDestroy_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^PetscErrorCode SVDDestroy_TRLanczos(SVD svd)$/;" f SVDEPS src/svd/examples/tests/makefile /^SVDEPS = cross cyclic$/;" m SVDErrorType include/slepc/finclude/slepcsvddef.h 36;" d SVDErrorType include/slepcsvd.h /^ SVD_ERROR_RELATIVE } SVDErrorType;$/;" t typeref:enum:__anon50 SVDErrorTypes include/slepcsvd.h /^PETSC_EXTERN const char *SVDErrorTypes[];$/;" v SVDErrorTypes src/svd/interface/dlregissvd.c /^const char *SVDErrorTypes[] = {"ABSOLUTE","RELATIVE","SVDErrorType","SVD_ERROR_",0};$/;" v SVDErrorView src/svd/interface/svdview.c /^PetscErrorCode SVDErrorView(SVD svd,SVDErrorType etype,PetscViewer viewer)$/;" f SVDErrorViewFromOptions src/svd/interface/svdview.c /^PetscErrorCode SVDErrorViewFromOptions(SVD svd)$/;" f SVDErrorView_ASCII src/svd/interface/svdview.c /^static PetscErrorCode SVDErrorView_ASCII(SVD svd,SVDErrorType etype,PetscViewer viewer)$/;" f file: SVDErrorView_DETAIL src/svd/interface/svdview.c /^static PetscErrorCode SVDErrorView_DETAIL(SVD svd,SVDErrorType etype,PetscViewer viewer)$/;" f file: SVDErrorView_MATLAB src/svd/interface/svdview.c /^static PetscErrorCode SVDErrorView_MATLAB(SVD svd,SVDErrorType etype,PetscViewer viewer)$/;" f file: SVDFinalizePackage src/svd/interface/dlregissvd.c /^PetscErrorCode SVDFinalizePackage(void)$/;" f SVDGetBV src/svd/interface/svdbasic.c /^PetscErrorCode SVDGetBV(SVD svd,BV *V,BV *U)$/;" f SVDGetConverged src/svd/interface/svdsolve.c /^PetscErrorCode SVDGetConverged(SVD svd,PetscInt *nconv)$/;" f SVDGetConvergedReason src/svd/interface/svdsolve.c /^PetscErrorCode SVDGetConvergedReason(SVD svd,SVDConvergedReason *reason)$/;" f SVDGetConvergenceTest src/svd/interface/svdopts.c /^PetscErrorCode SVDGetConvergenceTest(SVD svd,SVDConv *conv)$/;" f SVDGetDS src/svd/interface/svdbasic.c /^PetscErrorCode SVDGetDS(SVD svd,DS *ds)$/;" f SVDGetDimensions src/svd/interface/svdopts.c /^PetscErrorCode SVDGetDimensions(SVD svd,PetscInt *nsv,PetscInt *ncv,PetscInt *mpd)$/;" f SVDGetImplicitTranspose src/svd/interface/svdopts.c /^PetscErrorCode SVDGetImplicitTranspose(SVD svd,PetscBool *impl)$/;" f SVDGetIterationNumber src/svd/interface/svdsolve.c /^PetscErrorCode SVDGetIterationNumber(SVD svd,PetscInt *its)$/;" f SVDGetMonitorContext src/svd/interface/svdmon.c /^PetscErrorCode SVDGetMonitorContext(SVD svd,void **ctx)$/;" f SVDGetOperator src/svd/interface/svdsetup.c /^PetscErrorCode SVDGetOperator(SVD svd,Mat *A)$/;" f SVDGetOptionsPrefix src/svd/interface/svdopts.c /^PetscErrorCode SVDGetOptionsPrefix(SVD svd,const char *prefix[])$/;" f SVDGetSingularTriplet src/svd/interface/svdsolve.c /^PetscErrorCode SVDGetSingularTriplet(SVD svd,PetscInt i,PetscReal *sigma,Vec u,Vec v)$/;" f SVDGetStoppingTest src/svd/interface/svdopts.c /^PetscErrorCode SVDGetStoppingTest(SVD svd,SVDStop *stop)$/;" f SVDGetTolerances src/svd/interface/svdopts.c /^PetscErrorCode SVDGetTolerances(SVD svd,PetscReal *tol,PetscInt *maxits)$/;" f SVDGetTrackAll src/svd/interface/svdopts.c /^PetscErrorCode SVDGetTrackAll(SVD svd,PetscBool *trackall)$/;" f SVDGetType src/svd/interface/svdbasic.c /^PetscErrorCode SVDGetType(SVD svd,SVDType *type)$/;" f SVDGetWhichSingularTriplets src/svd/interface/svdopts.c /^PetscErrorCode SVDGetWhichSingularTriplets(SVD svd,SVDWhich *which)$/;" f SVDInitializePackage src/svd/interface/dlregissvd.c /^PetscErrorCode SVDInitializePackage(void)$/;" f SVDLANCZOS include/slepc/finclude/slepcsvddef.h 44;" d SVDLANCZOS include/slepcsvd.h 53;" d SVDLAPACK include/slepc/finclude/slepcsvddef.h 43;" d SVDLAPACK include/slepcsvd.h 52;" d SVDLanczosGetOneSide src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDLanczosGetOneSide(SVD svd,PetscBool *oneside)$/;" f SVDLanczosGetOneSide_Lanczos src/svd/impls/lanczos/gklanczos.c /^static PetscErrorCode SVDLanczosGetOneSide_Lanczos(SVD svd,PetscBool *oneside)$/;" f file: SVDLanczosSetOneSide src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDLanczosSetOneSide(SVD svd,PetscBool oneside)$/;" f SVDLanczosSetOneSide_Lanczos src/svd/impls/lanczos/gklanczos.c /^static PetscErrorCode SVDLanczosSetOneSide_Lanczos(SVD svd,PetscBool oneside)$/;" f file: SVDList include/slepcsvd.h /^PETSC_EXTERN PetscFunctionList SVDList;$/;" v SVDList src/svd/interface/svdbasic.c /^PetscFunctionList SVDList = 0;$/;" v SVDMatCreateVecs include/slepc/private/svdimpl.h /^PETSC_STATIC_INLINE PetscErrorCode SVDMatCreateVecs(SVD svd,Vec *x,Vec *y)$/;" f SVDMatGetLocalSize include/slepc/private/svdimpl.h /^PETSC_STATIC_INLINE PetscErrorCode SVDMatGetLocalSize(SVD svd,PetscInt *m,PetscInt *n)$/;" f SVDMatGetSize include/slepc/private/svdimpl.h /^PETSC_STATIC_INLINE PetscErrorCode SVDMatGetSize(SVD svd,PetscInt *m,PetscInt *n)$/;" f SVDMatMult include/slepc/private/svdimpl.h /^PETSC_STATIC_INLINE PetscErrorCode SVDMatMult(SVD svd,PetscBool trans,Vec x,Vec y)$/;" f SVDMonitor src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitor(SVD svd,PetscInt it,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest)$/;" f SVDMonitorAll src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f SVDMonitorCancel src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorCancel(SVD svd)$/;" f SVDMonitorConverged src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorConverged(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)$/;" f SVDMonitorFirst src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorFirst(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)$/;" f SVDMonitorLG src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorLG(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx)$/;" f SVDMonitorLGAll src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorLGAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx)$/;" f SVDMonitorLGCreate src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)$/;" f SVDMonitorSet src/svd/interface/svdmon.c /^PetscErrorCode SVDMonitorSet(SVD svd,PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))$/;" f SVDMonitorSetFromOptions src/svd/interface/svdopts.c /^PetscErrorCode SVDMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)$/;" f SVDOneSideLanczos src/svd/impls/lanczos/gklanczos.c /^static PetscErrorCode SVDOneSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,Vec u,Vec u_1,PetscInt k,PetscInt n,PetscScalar* work)$/;" f file: SVDOneSideTRLanczosCGS src/svd/impls/trlanczos/trlanczos.c /^static PetscErrorCode SVDOneSideTRLanczosCGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work)$/;" f file: SVDOneSideTRLanczosMGS src/svd/impls/trlanczos/trlanczos.c /^static PetscErrorCode SVDOneSideTRLanczosMGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work)$/;" f file: SVDOps include/slepc/private/svdimpl.h /^typedef struct _SVDOps *SVDOps;$/;" t typeref:struct:_SVDOps SVDOrthogonalizeCGS src/svd/impls/trlanczos/trlanczos.c /^static PetscErrorCode SVDOrthogonalizeCGS(BV V,PetscInt i,PetscScalar* h,PetscReal a,BVOrthogRefineType refine,PetscReal eta,PetscReal *norm)$/;" f file: SVDPackageInitialized src/svd/interface/dlregissvd.c /^static PetscBool SVDPackageInitialized = PETSC_FALSE;$/;" v file: SVDPrintSolution include/slepcsvd.h /^PETSC_DEPRECATED("Use SVDErrorView()") PETSC_STATIC_INLINE PetscErrorCode SVDPrintSolution(SVD svd,PetscViewer v) {return SVDErrorView(svd,SVD_ERROR_RELATIVE,v);}$/;" f SVDReasonView src/svd/interface/svdview.c /^PetscErrorCode SVDReasonView(SVD svd,PetscViewer viewer)$/;" f SVDReasonViewFromOptions src/svd/interface/svdview.c /^PetscErrorCode SVDReasonViewFromOptions(SVD svd)$/;" f SVDRegister src/svd/interface/svdbasic.c /^PetscErrorCode SVDRegister(const char *name,PetscErrorCode (*function)(SVD))$/;" f SVDRegisterAll src/svd/interface/svdregis.c /^PetscErrorCode SVDRegisterAll(void)$/;" f SVDRegisterAllCalled include/slepc/private/svdimpl.h /^PETSC_EXTERN PetscBool SVDRegisterAllCalled;$/;" v SVDRegisterAllCalled src/svd/interface/svdbasic.c /^PetscBool SVDRegisterAllCalled = PETSC_FALSE;$/;" v SVDReset src/svd/interface/svdbasic.c /^PetscErrorCode SVDReset(SVD svd)$/;" f SVDReset_Cross src/svd/impls/cross/cross.c /^PetscErrorCode SVDReset_Cross(SVD svd)$/;" f SVDReset_Cyclic src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDReset_Cyclic(SVD svd)$/;" f SVDSetBV src/svd/interface/svdbasic.c /^PetscErrorCode SVDSetBV(SVD svd,BV V,BV U)$/;" f SVDSetConvergenceTest src/svd/interface/svdopts.c /^PetscErrorCode SVDSetConvergenceTest(SVD svd,SVDConv conv)$/;" f SVDSetConvergenceTestFunction src/svd/interface/svdopts.c /^PetscErrorCode SVDSetConvergenceTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscReal,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f SVDSetDS src/svd/interface/svdbasic.c /^PetscErrorCode SVDSetDS(SVD svd,DS ds)$/;" f SVDSetDimensions src/svd/interface/svdopts.c /^PetscErrorCode SVDSetDimensions(SVD svd,PetscInt nsv,PetscInt ncv,PetscInt mpd)$/;" f SVDSetDimensions_Default src/svd/interface/svdsetup.c /^PetscErrorCode SVDSetDimensions_Default(SVD svd)$/;" f SVDSetFromOptions src/svd/interface/svdopts.c /^PetscErrorCode SVDSetFromOptions(SVD svd)$/;" f SVDSetFromOptions_Cross src/svd/impls/cross/cross.c /^PetscErrorCode SVDSetFromOptions_Cross(PetscOptionItems *PetscOptionsObject,SVD svd)$/;" f SVDSetFromOptions_Cyclic src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDSetFromOptions_Cyclic(PetscOptionItems *PetscOptionsObject,SVD svd)$/;" f SVDSetFromOptions_Lanczos src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,SVD svd)$/;" f SVDSetFromOptions_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^PetscErrorCode SVDSetFromOptions_TRLanczos(PetscOptionItems *PetscOptionsObject,SVD svd)$/;" f SVDSetImplicitTranspose src/svd/interface/svdopts.c /^PetscErrorCode SVDSetImplicitTranspose(SVD svd,PetscBool impl)$/;" f SVDSetInitialSpace src/svd/interface/svdsetup.c /^PetscErrorCode SVDSetInitialSpace(SVD svd,PetscInt n,Vec *is)$/;" f SVDSetInitialSpaceLeft src/svd/interface/svdsetup.c /^PetscErrorCode SVDSetInitialSpaceLeft(SVD svd,PetscInt n,Vec *is)$/;" f SVDSetOperator src/svd/interface/svdsetup.c /^PetscErrorCode SVDSetOperator(SVD svd,Mat mat)$/;" f SVDSetOptionsPrefix src/svd/interface/svdopts.c /^PetscErrorCode SVDSetOptionsPrefix(SVD svd,const char *prefix)$/;" f SVDSetStoppingTest src/svd/interface/svdopts.c /^PetscErrorCode SVDSetStoppingTest(SVD svd,SVDStop stop)$/;" f SVDSetStoppingTestFunction src/svd/interface/svdopts.c /^PetscErrorCode SVDSetStoppingTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))$/;" f SVDSetTolerances src/svd/interface/svdopts.c /^PetscErrorCode SVDSetTolerances(SVD svd,PetscReal tol,PetscInt maxits)$/;" f SVDSetTrackAll src/svd/interface/svdopts.c /^PetscErrorCode SVDSetTrackAll(SVD svd,PetscBool trackall)$/;" f SVDSetType src/svd/interface/svdbasic.c /^PetscErrorCode SVDSetType(SVD svd,SVDType type)$/;" f SVDSetUp src/svd/interface/svdsetup.c /^PetscErrorCode SVDSetUp(SVD svd)$/;" f SVDSetUp_Cross src/svd/impls/cross/cross.c /^PetscErrorCode SVDSetUp_Cross(SVD svd)$/;" f SVDSetUp_Cyclic src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDSetUp_Cyclic(SVD svd)$/;" f SVDSetUp_LAPACK src/svd/impls/lapack/svdlapack.c /^PetscErrorCode SVDSetUp_LAPACK(SVD svd)$/;" f SVDSetUp_Lanczos src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDSetUp_Lanczos(SVD svd)$/;" f SVDSetUp_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^PetscErrorCode SVDSetUp_TRLanczos(SVD svd)$/;" f SVDSetWhichSingularTriplets src/svd/interface/svdopts.c /^PetscErrorCode SVDSetWhichSingularTriplets(SVD svd,SVDWhich which)$/;" f SVDSolve src/svd/interface/svdsolve.c /^PetscErrorCode SVDSolve(SVD svd)$/;" f SVDSolve_Cross src/svd/impls/cross/cross.c /^PetscErrorCode SVDSolve_Cross(SVD svd)$/;" f SVDSolve_Cyclic src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDSolve_Cyclic(SVD svd)$/;" f SVDSolve_LAPACK src/svd/impls/lapack/svdlapack.c /^PetscErrorCode SVDSolve_LAPACK(SVD svd)$/;" f SVDSolve_Lanczos src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDSolve_Lanczos(SVD svd)$/;" f SVDSolve_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^PetscErrorCode SVDSolve_TRLanczos(SVD svd)$/;" f SVDStateType include/slepc/private/svdimpl.h /^ SVD_STATE_VECTORS } SVDStateType;$/;" t typeref:enum:__anon6 SVDStop include/slepc/finclude/slepcsvddef.h 39;" d SVDStop include/slepcsvd.h /^ SVD_STOP_USER } SVDStop;$/;" t typeref:enum:__anon52 SVDStoppingBasic src/svd/interface/svddefault.c /^PetscErrorCode SVDStoppingBasic(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)$/;" f SVDTRLANCZOS include/slepc/finclude/slepcsvddef.h 45;" d SVDTRLANCZOS include/slepcsvd.h 54;" d SVDTRLanczosGetOneSide src/svd/impls/trlanczos/trlanczos.c /^PetscErrorCode SVDTRLanczosGetOneSide(SVD svd,PetscBool *oneside)$/;" f SVDTRLanczosGetOneSide_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^static PetscErrorCode SVDTRLanczosGetOneSide_TRLanczos(SVD svd,PetscBool *oneside)$/;" f file: SVDTRLanczosSetOneSide src/svd/impls/trlanczos/trlanczos.c /^PetscErrorCode SVDTRLanczosSetOneSide(SVD svd,PetscBool oneside)$/;" f SVDTRLanczosSetOneSide_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^static PetscErrorCode SVDTRLanczosSetOneSide_TRLanczos(SVD svd,PetscBool oneside)$/;" f file: SVDTwoSideLanczos src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDTwoSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt k,PetscInt n)$/;" f SVDType include/slepc/finclude/slepcsvddef.h 34;" d SVDType include/slepcsvd.h /^typedef const char* SVDType;$/;" t SVDValuesView src/svd/interface/svdview.c /^PetscErrorCode SVDValuesView(SVD svd,PetscViewer viewer)$/;" f SVDValuesViewFromOptions src/svd/interface/svdview.c /^PetscErrorCode SVDValuesViewFromOptions(SVD svd)$/;" f SVDValuesView_ASCII src/svd/interface/svdview.c /^static PetscErrorCode SVDValuesView_ASCII(SVD svd,PetscViewer viewer)$/;" f file: SVDValuesView_DRAW src/svd/interface/svdview.c /^static PetscErrorCode SVDValuesView_DRAW(SVD svd,PetscViewer viewer)$/;" f file: SVDValuesView_MATLAB src/svd/interface/svdview.c /^static PetscErrorCode SVDValuesView_MATLAB(SVD svd,PetscViewer viewer)$/;" f file: SVDVectorsView src/svd/interface/svdview.c /^PetscErrorCode SVDVectorsView(SVD svd,PetscViewer viewer)$/;" f SVDVectorsViewFromOptions src/svd/interface/svdview.c /^PetscErrorCode SVDVectorsViewFromOptions(SVD svd)$/;" f SVDView src/svd/interface/svdview.c /^PetscErrorCode SVDView(SVD svd,PetscViewer viewer)$/;" f SVDViewFromOptions include/slepcsvd.h /^PETSC_STATIC_INLINE PetscErrorCode SVDViewFromOptions(SVD svd,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)svd,obj,name);}$/;" f SVDView_Cross src/svd/impls/cross/cross.c /^PetscErrorCode SVDView_Cross(SVD svd,PetscViewer viewer)$/;" f SVDView_Cyclic src/svd/impls/cyclic/cyclic.c /^PetscErrorCode SVDView_Cyclic(SVD svd,PetscViewer viewer)$/;" f SVDView_Lanczos src/svd/impls/lanczos/gklanczos.c /^PetscErrorCode SVDView_Lanczos(SVD svd,PetscViewer viewer)$/;" f SVDView_TRLanczos src/svd/impls/trlanczos/trlanczos.c /^PetscErrorCode SVDView_TRLanczos(SVD svd,PetscViewer viewer)$/;" f SVDWhich include/slepc/finclude/slepcsvddef.h 37;" d SVDWhich include/slepcsvd.h /^ SVD_SMALLEST } SVDWhich;$/;" t typeref:enum:__anon49 SVD_CLASSID include/slepcsvd.h /^PETSC_EXTERN PetscClassId SVD_CLASSID;$/;" v SVD_CLASSID src/svd/interface/svdbasic.c /^PetscClassId SVD_CLASSID = 0;$/;" v SVD_CONVERGED_ITERATING include/slepcsvd.h /^ SVD_CONVERGED_ITERATING = 0 } SVDConvergedReason;$/;" e enum:__anon53 SVD_CONVERGED_TOL include/slepcsvd.h /^ SVD_CONVERGED_TOL = 1,$/;" e enum:__anon53 SVD_CONVERGED_USER include/slepcsvd.h /^ SVD_CONVERGED_USER = 2,$/;" e enum:__anon53 SVD_CONV_ABS include/slepcsvd.h /^typedef enum { SVD_CONV_ABS,$/;" e enum:__anon51 SVD_CONV_REL include/slepcsvd.h /^ SVD_CONV_REL,$/;" e enum:__anon51 SVD_CONV_USER include/slepcsvd.h /^ SVD_CONV_USER } SVDConv;$/;" e enum:__anon51 SVD_CROSS src/svd/impls/cross/cross.c /^} SVD_CROSS;$/;" t typeref:struct:__anon110 file: SVD_CYCLIC src/svd/impls/cyclic/cyclic.c /^} SVD_CYCLIC;$/;" t typeref:struct:__anon111 file: SVD_DIVERGED_BREAKDOWN include/slepcsvd.h /^ SVD_DIVERGED_BREAKDOWN = -2,$/;" e enum:__anon53 SVD_DIVERGED_ITS include/slepcsvd.h /^ SVD_DIVERGED_ITS = -1,$/;" e enum:__anon53 SVD_ERROR_ABSOLUTE include/slepcsvd.h /^typedef enum { SVD_ERROR_ABSOLUTE,$/;" e enum:__anon50 SVD_ERROR_RELATIVE include/slepcsvd.h /^ SVD_ERROR_RELATIVE } SVDErrorType;$/;" e enum:__anon50 SVD_H0 src/eps/impls/ciss/ciss.c /^static PetscErrorCode SVD_H0(EPS eps,PetscScalar *S,PetscInt *K)$/;" f file: SVD_H0 src/nep/impls/ciss/nciss.c /^static PetscErrorCode SVD_H0(NEP nep,PetscScalar *S,PetscInt *K)$/;" f file: SVD_LANCZOS src/svd/impls/lanczos/gklanczos.c /^} SVD_LANCZOS;$/;" t typeref:struct:__anon112 file: SVD_LARGEST include/slepcsvd.h /^typedef enum { SVD_LARGEST,$/;" e enum:__anon49 SVD_S src/eps/impls/ciss/ciss.c /^static PetscErrorCode SVD_S(BV S,PetscInt ml,PetscReal delta,PetscReal *sigma,PetscInt *K)$/;" f file: SVD_SMALLEST include/slepcsvd.h /^ SVD_SMALLEST } SVDWhich;$/;" e enum:__anon49 SVD_STATE_INITIAL include/slepc/private/svdimpl.h /^typedef enum { SVD_STATE_INITIAL,$/;" e enum:__anon6 SVD_STATE_SETUP include/slepc/private/svdimpl.h /^ SVD_STATE_SETUP,$/;" e enum:__anon6 SVD_STATE_SOLVED include/slepc/private/svdimpl.h /^ SVD_STATE_SOLVED,$/;" e enum:__anon6 SVD_STATE_VECTORS include/slepc/private/svdimpl.h /^ SVD_STATE_VECTORS } SVDStateType;$/;" e enum:__anon6 SVD_STOP_BASIC include/slepcsvd.h /^typedef enum { SVD_STOP_BASIC,$/;" e enum:__anon52 SVD_STOP_USER include/slepcsvd.h /^ SVD_STOP_USER } SVDStop;$/;" e enum:__anon52 SVD_SetUp include/slepc/private/svdimpl.h /^PETSC_EXTERN PetscLogEvent SVD_SetUp,SVD_Solve;$/;" v SVD_SetUp src/svd/interface/svdbasic.c /^PetscLogEvent SVD_SetUp = 0,SVD_Solve = 0;$/;" v SVD_Solve include/slepc/private/svdimpl.h /^PETSC_EXTERN PetscLogEvent SVD_SetUp,SVD_Solve;$/;" v SVD_Solve src/svd/interface/svdbasic.c /^PetscLogEvent SVD_SetUp = 0,SVD_Solve = 0;$/;" v SVD_TRLANCZOS src/svd/impls/trlanczos/trlanczos.c /^} SVD_TRLANCZOS;$/;" t typeref:struct:__anon113 file: SWAP src/eps/impls/krylov/krylovschur/ks-slice.c 619;" d file: SWAP src/sys/classes/fn/impls/exp/fnexp.c 46;" d file: SampleShellST src/eps/examples/tutorials/ex10.c /^} SampleShellST;$/;" t typeref:struct:__anon54 file: ScanJ src/sys/classes/ds/impls/ghiep/dqds.c /^static PetscErrorCode ScanJ(PetscInt n,PetscReal *a,PetscReal *b,PetscReal *gl,PetscReal *gr,PetscReal *sigma)$/;" f file: SetInitialGuess src/eps/examples/tutorials/ex31.c /^PetscErrorCode SetInitialGuess(Vec X,Userctx *user)$/;" f SetPathParameter src/eps/impls/ciss/ciss.c /^static PetscErrorCode SetPathParameter(EPS eps)$/;" f file: SetPathParameter src/nep/impls/ciss/nciss.c /^static PetscErrorCode SetPathParameter(NEP nep)$/;" f file: SetSolverComm src/eps/impls/ciss/ciss.c /^static PetscErrorCode SetSolverComm(EPS eps)$/;" f file: SetSolverComm src/nep/impls/ciss/nciss.c /^static PetscErrorCode SetSolverComm(NEP nep)$/;" f file: ShellMatCtx src/nep/impls/nleigs/nleigs.c /^} ShellMatCtx;$/;" t typeref:struct:__anon93 file: ShowHelp config/package.py /^ def ShowHelp(self):$/;" m class:Package ShowHelp config/packages/slepc.py /^ def ShowHelp(self):$/;" m class:SLEPc ShowInfo config/package.py /^ def ShowInfo(self):$/;" m class:Package ShowInfo config/packages/lapack.py /^ def ShowInfo(self):$/;" m class:Lapack Slepc config/gmakegen.py /^class Slepc(object):$/;" c SlepcAbs include/slepcmath.h /^PETSC_STATIC_INLINE PetscReal SlepcAbs(PetscReal x,PetscReal y)$/;" f SlepcAbsEigenvalue include/slepcmath.h 91;" d SlepcAbsEigenvalue include/slepcmath.h 93;" d SlepcBasisDestroy_Private src/sys/slepcutil.c /^PetscErrorCode SlepcBasisDestroy_Private(PetscInt *m,Vec **W)$/;" f SlepcBasisReference_Private src/sys/slepcutil.c /^PetscErrorCode SlepcBasisReference_Private(PetscInt n,Vec *V,PetscInt *m,Vec **W)$/;" f SlepcBeganPetsc include/slepc/private/slepcimpl.h /^PETSC_INTERN PetscBool SlepcBeganPetsc;$/;" v SlepcBeganPetsc src/sys/slepcinit.c /^PetscBool SlepcBeganPetsc = PETSC_FALSE;$/;" v SlepcCheckOrthogonality src/sys/slepcutil.c /^PetscErrorCode SlepcCheckOrthogonality(Vec *V,PetscInt nv,Vec *W,PetscInt nw,Mat B,PetscViewer viewer,PetscReal *lev)$/;" f SlepcCitationsInitialize src/sys/slepcinit.c /^PetscErrorCode SlepcCitationsInitialize()$/;" f SlepcCompareLargestImaginary src/sys/slepcsc.c /^PetscErrorCode SlepcCompareLargestImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareLargestMagnitude src/sys/slepcsc.c /^PetscErrorCode SlepcCompareLargestMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareLargestReal src/sys/slepcsc.c /^PetscErrorCode SlepcCompareLargestReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareSmallestImaginary src/sys/slepcsc.c /^PetscErrorCode SlepcCompareSmallestImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareSmallestMagnitude src/sys/slepcsc.c /^PetscErrorCode SlepcCompareSmallestMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareSmallestPosReal src/sys/slepcsc.c /^PetscErrorCode SlepcCompareSmallestPosReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareSmallestReal src/sys/slepcsc.c /^PetscErrorCode SlepcCompareSmallestReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareTargetImaginary src/sys/slepcsc.c /^PetscErrorCode SlepcCompareTargetImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareTargetMagnitude src/sys/slepcsc.c /^PetscErrorCode SlepcCompareTargetMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcCompareTargetReal src/sys/slepcsc.c /^PetscErrorCode SlepcCompareTargetReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)$/;" f SlepcConvMonitor include/slepc/finclude/slepcsysdef.h 27;" d SlepcConvMonitor include/slepcsys.h /^typedef struct _n_SlepcConvMonitor* SlepcConvMonitor;$/;" t typeref:struct:_n_SlepcConvMonitor SlepcConvMonitorCreate src/sys/slepcutil.c /^PetscErrorCode SlepcConvMonitorCreate(PetscViewer viewer,PetscViewerFormat format,SlepcConvMonitor *ctx)$/;" f SlepcConvMonitorDestroy src/sys/slepcutil.c /^PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor *ctx)$/;" f SlepcFinalize src/sys/slepcinit.c /^PetscErrorCode SlepcFinalize(void)$/;" f SlepcGetVersion src/sys/slepcinit.c /^PetscErrorCode SlepcGetVersion(char version[],size_t len)$/;" f SlepcHeaderCreate include/slepc/private/slepcimpl.h 51;" d SlepcInitialize src/sys/slepcinit.c /^PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[])$/;" f SlepcInitializeCalled include/slepcsys.h /^PETSC_EXTERN PetscBool SlepcInitializeCalled;$/;" v SlepcInitializeCalled src/sys/slepcinit.c /^PetscBool SlepcInitializeCalled = PETSC_FALSE;$/;" v SlepcInitializeFortran src/sys/ftn-custom/zslepc_startf.c /^PetscErrorCode SlepcInitializeFortran(void)$/;" f SlepcInitializeNoArguments src/sys/slepcinit.c /^PetscErrorCode SlepcInitializeNoArguments(void)$/;" f SlepcInitializeNoPointers src/sys/slepcinit.c /^PetscErrorCode SlepcInitializeNoPointers(int argc,char **args,const char *filename,const char *help)$/;" f SlepcInitialize_DynamicLibraries src/sys/slepcinit.c /^PetscErrorCode SlepcInitialize_DynamicLibraries(void)$/;" f SlepcInitialized src/sys/slepcinit.c /^PetscErrorCode SlepcInitialized(PetscBool *isInitialized)$/;" f SlepcLRT include/slepcblaslapack.h 105;" d SlepcLRT include/slepcblaslapack.h 107;" d SlepcLoadDynamicLibrary src/sys/slepcinit.c /^static PetscErrorCode SlepcLoadDynamicLibrary(const char *name,PetscBool *found)$/;" f file: SlepcMap_ST src/sys/slepcsc.c /^PetscErrorCode SlepcMap_ST(PetscObject obj,PetscInt n,PetscScalar* eigr,PetscScalar* eigi)$/;" f SlepcMatConvertSeqDense src/sys/slepcutil.c /^PetscErrorCode SlepcMatConvertSeqDense(Mat mat,Mat *newmat)$/;" f SlepcMatDenseMult src/sys/classes/ds/interface/dspriv.c /^static PetscErrorCode SlepcMatDenseMult(PetscScalar *C,PetscInt _ldC,PetscScalar b,PetscScalar a,const PetscScalar *A,PetscInt _ldA,PetscInt rA,PetscInt cA,PetscBool At,const PetscScalar *B,PetscInt _ldB,PetscInt rB,PetscInt cB,PetscBool Bt)$/;" f file: SlepcMatDenseSqrt src/sys/classes/fn/impls/fnutil.c /^PetscErrorCode SlepcMatDenseSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld)$/;" f SlepcMatTile src/sys/slepcutil.c /^PetscErrorCode SlepcMatTile(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat *G)$/;" f SlepcMatTile_MPIAIJ src/sys/slepcutil.c /^static PetscErrorCode SlepcMatTile_MPIAIJ(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat G)$/;" f file: SlepcMatTile_SeqAIJ src/sys/slepcutil.c /^static PetscErrorCode SlepcMatTile_SeqAIJ(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat G)$/;" f file: SlepcPrintHelpIntro src/sys/slepcinit.c /^static PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)$/;" f file: SlepcPrintVersion src/sys/slepcinit.c /^static PetscErrorCode SlepcPrintVersion(MPI_Comm comm)$/;" f file: SlepcSC include/slepcsc.h /^typedef struct _n_SlepcSC* SlepcSC;$/;" t typeref:struct:_n_SlepcSC SlepcSCCompare src/sys/slepcsc.c /^PetscErrorCode SlepcSCCompare(SlepcSC sc,PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res)$/;" f SlepcSNPrintfScalar src/sys/slepcutil.c /^PetscErrorCode SlepcSNPrintfScalar(char *str,size_t len,PetscScalar val,PetscBool exp)$/;" f SlepcSchurParlettSqrt src/sys/classes/fn/impls/fnutil.c /^PetscErrorCode SlepcSchurParlettSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld,PetscBool firstonly)$/;" f SlepcSortEigenvalues src/sys/slepcsc.c /^PetscErrorCode SlepcSortEigenvalues(SlepcSC sc,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm)$/;" f SlepcSumNorm2_Local src/sys/vec/veccomp.c /^static void SlepcSumNorm2_Local(void *in,void *out,PetscMPIInt *cnt,MPI_Datatype *datatype)$/;" f file: SlepcValidVecComp include/slepc/private/vecimplslepc.h 30;" d SlepcValidVecComp include/slepc/private/vecimplslepc.h 34;" d SlepcVecNormalize src/sys/slepcutil.c /^PetscErrorCode SlepcVecNormalize(Vec xr,Vec xi,PetscBool iscomplex,PetscReal *norm)$/;" f SlepcVecPoolCreate src/sys/vec/pool.c /^PetscErrorCode SlepcVecPoolCreate(Vec v,PetscInt init_size,VecPool *p)$/;" f SlepcVecPoolDestroy src/sys/vec/pool.c /^PetscErrorCode SlepcVecPoolDestroy(VecPool *p)$/;" f SlepcVecPoolGetVecs src/sys/vec/pool.c /^PetscErrorCode SlepcVecPoolGetVecs(VecPool p,PetscInt n,Vec **vecs)$/;" f SlepcVecPoolRestoreVecs src/sys/vec/pool.c /^PetscErrorCode SlepcVecPoolRestoreVecs(VecPool p,PetscInt n,Vec **vecs)$/;" f SolveLinearSystem src/eps/impls/ciss/ciss.c /^static PetscErrorCode SolveLinearSystem(EPS eps,Mat A,Mat B,BV V,PetscInt L_start,PetscInt L_end,PetscBool initksp)$/;" f file: SolveLinearSystem src/nep/impls/ciss/nciss.c /^static PetscErrorCode SolveLinearSystem(NEP nep,Mat T,Mat dT,BV V,PetscInt L_start,PetscInt L_end,PetscBool initksp)$/;" f file: Sowing config/packages/sowing.py /^class Sowing(package.Package):$/;" c StdoutLogger config/cmakeboot.py /^class StdoutLogger(object):$/;" c StdoutLogger config/cmakegen.py /^class StdoutLogger(object):$/;" c SumNorm2 src/sys/vec/veccomp.c /^PETSC_STATIC_INLINE void SumNorm2(PetscReal *ssq0,PetscReal *scale0,PetscReal *ssq1,PetscReal *scale1)$/;" f T include/slepc/private/stimpl.h /^ Mat *T; \/* matrices resulting from transformation *\/$/;" m struct:_p_ST T src/eps/examples/tutorials/ex30.c /^ Mat T;$/;" m struct:__anon56 file: T src/eps/examples/tutorials/ex9.c /^ Mat T;$/;" m struct:__anon58 file: T src/pep/impls/jd/pjdp.h /^ PetscScalar *T; \/* matrix of the invariant pair *\/$/;" m struct:__anon99 TA src/eps/examples/tutorials/ex31.c /^const PetscScalar TA[3] = {0.2,0.2,0.2}; \/* Voltage regulator time constant *\/$/;" v TE src/eps/examples/tutorials/ex31.c /^const PetscScalar TE[3] = {0.314,0.314,0.314}; \/* Exciter time constant *\/$/;" v TESTCODE src/eps/examples/tests/makefile /^TESTCODE = \\$/;" m TESTCODE src/pep/examples/tests/makefile /^TESTCODE = \\$/;" m TESTCODE src/sys/classes/bv/examples/tests/makefile /^TESTCODE = \\$/;" m TESTCODE src/sys/classes/st/examples/tests/makefile /^TESTCODE = \\$/;" m TESTEXAMPLES_BLOPEX src/eps/examples/tests/makefile /^TESTEXAMPLES_BLOPEX = test5.PETSc runtest5_blopex test5.rm$/;" m TESTEXAMPLES_C src/eps/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \\$/;" m TESTEXAMPLES_C src/eps/examples/tutorials/makefile /^TESTEXAMPLES_C = ex2.PETSc runex2_1 runex2_ciss_1 runex2_ciss_2 ex2.rm \\$/;" m TESTEXAMPLES_C src/mfn/examples/tutorials/makefile /^TESTEXAMPLES_C = ex23.PETSc runex23_1 ex23.rm ex26.PETSc runex26_1 ex26.rm$/;" m TESTEXAMPLES_C src/nep/examples/nlevp/makefile /^TESTEXAMPLES_C = loaded_string.PETSc runloaded_string loaded_string.rm$/;" m TESTEXAMPLES_C src/nep/examples/tests/makefile /^TESTEXAMPLES_C =$/;" m TESTEXAMPLES_C src/nep/examples/tutorials/makefile /^TESTEXAMPLES_C = ex21.PETSc runex21_1 ex21.rm \\$/;" m TESTEXAMPLES_C src/pep/examples/nlevp/makefile /^TESTEXAMPLES_C = acoustic_wave_1d.PETSc runacoustic_wave_1d_1 acoustic_wave_1d.rm \\$/;" m TESTEXAMPLES_C src/pep/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \\$/;" m TESTEXAMPLES_C src/pep/examples/tutorials/makefile /^TESTEXAMPLES_C = ex16.PETSc runex16_1 ex16.rm \\$/;" m TESTEXAMPLES_C src/svd/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \\$/;" m TESTEXAMPLES_C src/svd/examples/tutorials/makefile /^TESTEXAMPLES_C = ex8.PETSc runex8_1 ex8.rm$/;" m TESTEXAMPLES_C src/sys/classes/bv/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 runtest1_2 runtest1_3 runtest1_4 test1.rm \\$/;" m TESTEXAMPLES_C src/sys/classes/ds/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \\$/;" m TESTEXAMPLES_C src/sys/classes/fn/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \\$/;" m TESTEXAMPLES_C src/sys/classes/rg/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm$/;" m TESTEXAMPLES_C src/sys/classes/st/examples/tests/makefile /^TESTEXAMPLES_C = test1.PETSc runtest1_1 runtest1_2 test1.rm \\$/;" m TESTEXAMPLES_C_COMPLEX src/nep/examples/tutorials/makefile /^TESTEXAMPLES_C_COMPLEX = ex22.PETSc runex22_ciss_1 ex22.rm$/;" m TESTEXAMPLES_C_COMPLEX src/pep/examples/nlevp/makefile /^TESTEXAMPLES_C_COMPLEX = pdde_stability.PETSc runpdde_stability pdde_stability.rm$/;" m TESTEXAMPLES_C_NOCOMPLEX src/eps/examples/tests/makefile /^TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_2 test1.rm$/;" m TESTEXAMPLES_C_NOCOMPLEX src/eps/examples/tutorials/makefile /^TESTEXAMPLES_C_NOCOMPLEX = ex4.PETSc runex4_1 ex4.rm \\$/;" m TESTEXAMPLES_C_NOCOMPLEX src/mfn/examples/tests/makefile /^TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_1 runtest1_2 test1.rm$/;" m TESTEXAMPLES_C_NOCOMPLEX src/pep/examples/tutorials/makefile /^TESTEXAMPLES_C_NOCOMPLEX = ex17.PETSc runex17_1 ex17.rm$/;" m TESTEXAMPLES_C_NOCOMPLEX src/svd/examples/tutorials/makefile /^TESTEXAMPLES_C_NOCOMPLEX = ex14.PETSc runex14_1 ex14.rm$/;" m TESTEXAMPLES_C_NOCOMPLEX src/sys/classes/ds/examples/tests/makefile /^TESTEXAMPLES_C_NOCOMPLEX = test13.PETSc runtest13_1 test13.rm$/;" m TESTEXAMPLES_C_NOF128 src/eps/examples/tests/makefile /^TESTEXAMPLES_C_NOF128 = test5.PETSc runtest5_1 test5.rm$/;" m TESTEXAMPLES_C_NOF128 src/svd/examples/tests/makefile /^TESTEXAMPLES_C_NOF128= test2.PETSc runtest2_1 test2.rm$/;" m TESTEXAMPLES_DATAFILESPATH_COMPLEX src/eps/examples/tutorials/makefile /^TESTEXAMPLES_DATAFILESPATH_COMPLEX = ex4.PETSc runex4_ciss_1 ex4.rm \\$/;" m TESTEXAMPLES_DATAFILESPATH_COMPLEX src/nep/examples/nlevp/makefile /^TESTEXAMPLES_DATAFILESPATH_COMPLEX = gun.PETSc rungun gun.rm$/;" m TESTEXAMPLES_F90 src/eps/examples/tutorials/makefile /^TESTEXAMPLES_F90 = ex1f90.PETSc runex1f90_1 ex1f90.rm$/;" m TESTEXAMPLES_F90 src/nep/examples/tutorials/makefile /^TESTEXAMPLES_F90 =$/;" m TESTEXAMPLES_F90 src/pep/examples/tutorials/makefile /^TESTEXAMPLES_F90 = ex16f90.PETSc runex16f90_1 ex16f90.rm$/;" m TESTEXAMPLES_FORTRAN src/eps/examples/tests/makefile /^TESTEXAMPLES_FORTRAN = test7f.PETSc runtest7f_1 test7f.rm \\$/;" m TESTEXAMPLES_FORTRAN src/pep/examples/tests/makefile /^TESTEXAMPLES_FORTRAN = test3f.PETSc runtest3f_1 test3f.rm \\$/;" m TESTEXAMPLES_FORTRAN src/svd/examples/tutorials/makefile /^TESTEXAMPLES_FORTRAN =$/;" m TESTEXAMPLES_FORTRAN src/sys/classes/ds/examples/tests/makefile /^TESTEXAMPLES_FORTRAN = test14f.PETSc runtest14f_1 test14f.rm$/;" m TESTEXAMPLES_FORTRAN_NOCOMPLEX src/eps/examples/tutorials/makefile /^TESTEXAMPLES_FORTRAN_NOCOMPLEX = ex6f.PETSc runex6f_1 ex6f.rm$/;" m TESTS src/eps/examples/tests/makefile /^TESTS = test1 test2 test3 test4 test5 test6 test7f test8 test9 test10 \\$/;" m TESTS src/mfn/examples/tests/makefile /^TESTS =$/;" m TESTS src/nep/examples/nlevp/makefile /^TESTS = loaded_string gun$/;" m TESTS src/nep/examples/tests/makefile /^TESTS =$/;" m TESTS src/pep/examples/nlevp/makefile /^TESTS = acoustic_wave_1d acoustic_wave_2d butterfly damped_beam \\$/;" m TESTS src/pep/examples/tests/makefile /^TESTS = test1 test2 test3 test3f$/;" m TESTS src/svd/examples/tests/makefile /^TESTS = test1 test2 test3$/;" m TESTS src/sys/classes/bv/examples/tests/makefile /^TESTS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12$/;" m TESTS src/sys/classes/ds/examples/tests/makefile /^TESTS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test12 test13 \\$/;" m TESTS src/sys/classes/fn/examples/tests/makefile /^TESTS = test1 test2 test3 test4 test5 test6 test7 test8$/;" m TESTS src/sys/classes/rg/examples/tests/makefile /^TESTS = test1$/;" m TESTS src/sys/classes/st/examples/tests/makefile /^TESTS = test1 test2 test3 test4$/;" m TF src/eps/examples/tutorials/ex31.c /^const PetscScalar TF[3] = {0.35,0.35,0.35}; \/* Feedback stabilizer time constant *\/$/;" v TM src/eps/examples/tutorials/ex31.c /^PetscScalar TM[3]; \/* Mechanical Torque *\/$/;" v TOLMAX src/sys/classes/ds/impls/hep/bdc/dsbtdc.c 264;" d file: TRLan_ src/eps/impls/external/trlan/trlanp.h 40;" d TRLan_ src/eps/impls/external/trlan/trlanp.h 42;" d TRLan_ src/eps/impls/external/trlan/trlanp.h 44;" d TV src/pep/impls/jd/pjdp.h /^ BV *TV; \/* work basis vectors to store T*V (each TV[i] is the coefficient for \\lambda^i of T*V for the extended T) *\/$/;" m struct:__anon99 Td0p src/eps/examples/tutorials/ex31.c /^const PetscScalar Td0p[3] = {8.96,6.0,5.89}; \/* d-axis open circuit time constant *\/$/;" v TestMatCombine src/sys/classes/fn/examples/tests/test6.c /^PetscErrorCode TestMatCombine(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)$/;" f TestMatExp src/sys/classes/fn/examples/tests/test3.c /^PetscErrorCode TestMatExp(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)$/;" f TestMatInvSqrt src/sys/classes/fn/examples/tests/test8.c /^PetscErrorCode TestMatInvSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)$/;" f TestMatRational src/sys/classes/fn/examples/tests/test5.c /^PetscErrorCode TestMatRational(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)$/;" f TestMatSqrt src/sys/classes/fn/examples/tests/test7.c /^PetscErrorCode TestMatSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)$/;" f Tj src/pep/impls/jd/pjdp.h /^ PetscScalar *Tj; \/* matrix containing the powers of the invariant pair matrix *\/$/;" m struct:__anon99 Tq0p src/eps/examples/tutorials/ex31.c /^const PetscScalar Tq0p[3] = {0.31,0.535,0.6}; \/* q-axis open circuit time constant *\/$/;" v TridiagDiag_HHR src/sys/classes/ds/impls/ghiep/invit.c /^static PetscErrorCode TridiagDiag_HHR(PetscInt n,PetscScalar *A,PetscInt lda,PetscReal *s,PetscScalar* Q,PetscInt ldq,PetscBool flip,PetscReal *d,PetscReal *e,PetscInt *perm_,PetscScalar *work,PetscReal *rwork,PetscBLASInt *iwork)$/;" f file: TridqdsZhuang src/sys/classes/ds/impls/ghiep/dqds.c /^static PetscErrorCode TridqdsZhuang(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscReal *e1,PetscReal *q1,PetscInt *fail)$/;" f file: TridqdsZhuang3 src/sys/classes/ds/impls/ghiep/dqds.c /^static PetscErrorCode TridqdsZhuang3(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscInt *fail)$/;" f file: Trlan config/packages/trlan.py /^class Trlan(package.Package):$/;" c TryHRIt src/sys/classes/ds/impls/ghiep/invit.c /^static PetscErrorCode TryHRIt(PetscInt n,PetscInt j,PetscInt sz,PetscScalar *H,PetscInt ldh,PetscScalar *R,PetscInt ldr,PetscReal *s,PetscBool *exg,PetscBool *ok,PetscInt *n0,PetscInt *n1,PetscInt *idx0,PetscInt *idx1,PetscReal *cond,PetscScalar *work)$/;" f file: U include/slepc/private/svdimpl.h /^ BV U,V; \/* left and right singular vectors *\/$/;" m struct:_p_SVD U src/eps/impls/davidson/dvdimprovex.c /^ BV U; \/* new X vectors *\/$/;" m struct:__anon68 file: UnifiedRotation src/sys/classes/ds/impls/ghiep/hz.c /^static PetscErrorCode UnifiedRotation(PetscReal x,PetscReal y,PetscReal sygn,PetscReal *rot,PetscReal *rcond,PetscBool *swap)$/;" f file: Userctx src/eps/examples/tutorials/ex31.c /^} Userctx;$/;" t typeref:struct:__anon57 file: V include/slepc/private/epsimpl.h /^ BV V; \/* set of basis vectors and computed eigenvectors *\/$/;" m struct:_p_EPS V include/slepc/private/mfnimpl.h /^ BV V; \/* set of basis vectors *\/$/;" m struct:_p_MFN V include/slepc/private/nepimpl.h /^ BV V; \/* set of basis vectors and computed eigenvectors *\/$/;" m struct:_p_NEP V include/slepc/private/pepimpl.h /^ BV V; \/* set of basis vectors and computed eigenvectors *\/$/;" m struct:_p_PEP V include/slepc/private/svdimpl.h /^ BV U,V; \/* left and right singular vectors *\/$/;" m struct:_p_SVD V src/eps/impls/ciss/ciss.c /^ BV V;$/;" m struct:__anon61 file: V src/eps/impls/krylov/krylovschur/krylovschur.h /^ BV V; \/* working basis (for subsolve) *\/$/;" m struct:_n_SR V src/nep/impls/ciss/nciss.c /^ BV V;$/;" m struct:__anon89 file: V src/pep/impls/jd/pjdp.h /^ BV V; \/* work basis vectors to store the search space *\/$/;" m struct:__anon99 V src/pep/impls/krylov/toar/nrefine.c /^ BV V,M2,M3,W;$/;" m struct:__anon104 file: V src/pep/impls/krylov/toar/nrefine.c /^ BV V,W,M2,M3,Wt;$/;" m struct:__anon105 file: V src/sys/classes/bv/impls/contiguous/contig.c /^ Vec *V;$/;" m struct:__anon115 file: V src/sys/classes/bv/impls/vecs/vecs.c /^ Vec *V;$/;" m struct:__anon118 file: V0 src/eps/examples/tutorials/ex31.c /^ Vec V0; \/* Initial voltage vector (Power flow solution) *\/$/;" m struct:__anon57 file: VECCOMP include/slepcvec.h 30;" d VERTMAX src/sys/classes/rg/impls/polygon/rgpolygon.c 26;" d file: V_new_e src/eps/impls/davidson/davidson.h /^ PetscInt V_new_e; \/* added to V the columns V_new_s:V_new_e *\/$/;" m struct:_dvdDashboard V_new_s src/eps/impls/davidson/davidson.h /^ PetscInt V_new_s;$/;" m struct:_dvdDashboard V_tra_e src/eps/impls/davidson/davidson.h /^ PetscInt V_tra_e; \/* cX <- [cX V*MT(0:V_tra_s-1)], V <- V*MT(V_tra_s:V_tra_e) *\/$/;" m struct:_dvdDashboard V_tra_s src/eps/impls/davidson/davidson.h /^ PetscInt V_tra_s;$/;" m struct:_dvdDashboard Valencia include/slepc/finclude/slepc.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcbv.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcbvdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcds.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcdsdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepceps.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcepsdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcfn.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcfndef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcmfn.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcmfndef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcnep.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcnepdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcpep.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcpepdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcrg.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcrgdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcst.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcstdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcsvd.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcsvddef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcsys.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v Valencia include/slepc/finclude/slepcsysdef.h /^! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain$/;" v VecAXPBYPCZ_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecAXPBYPCZ_Comp(Vec v,PetscScalar alpha,PetscScalar beta,PetscScalar gamma,Vec w,Vec z)$/;" f VecAXPBY_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecAXPBY_Comp(Vec v,PetscScalar alpha,PetscScalar beta,Vec w)$/;" f VecAXPY_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecAXPY_Comp(Vec v,PetscScalar alpha,Vec w)$/;" f VecAYPX_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecAYPX_Comp(Vec v,PetscScalar alpha,Vec w)$/;" f VecCompGetSubVecs src/sys/vec/veccomp.c /^PetscErrorCode VecCompGetSubVecs(Vec win,PetscInt *n,const Vec **x)$/;" f VecCompInitialized src/sys/vec/veccomp.c /^static PetscBool VecCompInitialized = PETSC_FALSE;$/;" v file: VecCompSetSubVecs src/sys/vec/veccomp.c /^PetscErrorCode VecCompSetSubVecs(Vec win,PetscInt n,Vec *x)$/;" f VecCreateComp src/sys/vec/veccomp.c /^PetscErrorCode VecCreateComp(MPI_Comm comm,PetscInt *Nx,PetscInt n,VecType t,Vec Vparent,Vec *V)$/;" f VecCreateCompWithVecs src/sys/vec/veccomp.c /^PetscErrorCode VecCreateCompWithVecs(Vec *x,PetscInt n,Vec Vparent,Vec *V)$/;" f VecCreate_Comp src/sys/vec/veccomp.c /^PETSC_EXTERN PetscErrorCode VecCreate_Comp(Vec V)$/;" f VecCreate_Comp_Private src/sys/vec/veccomp.c /^static PetscErrorCode VecCreate_Comp_Private(Vec v,Vec *x,PetscInt nx,PetscBool x_to_me,Vec_Comp_N *n)$/;" f file: VecDestroyVecs_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecDestroyVecs_Comp(PetscInt m,Vec v[])$/;" f VecDestroy_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecDestroy_Comp(Vec v)$/;" f VecDotNorm2_Comp src/sys/vec/veccomp0.h /^PetscErrorCode __SUF__(VecDotNorm2_Comp)(Vec v,Vec w,PetscScalar *dp,PetscScalar *nm)$/;" f VecDot_Comp src/sys/vec/veccomp0.h /^PetscErrorCode __SUF__(VecDot_Comp)(Vec a,Vec b,PetscScalar *z)$/;" f VecDuplicateVecs_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecDuplicateVecs_Comp(Vec w,PetscInt m,Vec *V[])$/;" f VecDuplicate_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecDuplicate_Comp(Vec win,Vec *V)$/;" f VecGetLocalSize_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecGetLocalSize_Comp(Vec v,PetscInt *size)$/;" f VecGetSize_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecGetSize_Comp(Vec v,PetscInt *size)$/;" f VecMAXPY_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecMAXPY_Comp(Vec v,PetscInt n,const PetscScalar *alpha,Vec *w)$/;" f VecMDot_Comp src/sys/vec/veccomp0.h /^PetscErrorCode __SUF__(VecMDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z)$/;" f VecMTDot_Comp src/sys/vec/veccomp0.h /^PetscErrorCode __SUF__(VecMTDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z)$/;" f VecMaxPointwiseDivide_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecMaxPointwiseDivide_Comp(Vec v,Vec w,PetscReal *m)$/;" f VecMax_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecMax_Comp(Vec v,PetscInt *idx,PetscReal *z)$/;" f VecMin_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecMin_Comp(Vec v,PetscInt *idx,PetscReal *z)$/;" f VecNormCompEnd src/sys/vec/veccomp.c /^static PetscErrorCode VecNormCompEnd(void)$/;" f file: VecNormCompInit src/sys/vec/veccomp.c /^static PetscErrorCode VecNormCompInit()$/;" f file: VecNorm_Comp src/sys/vec/veccomp0.h /^PetscErrorCode __SUF__(VecNorm_Comp)(Vec a,NormType t,PetscReal *norm)$/;" f VecPool include/slepc/private/vecimplslepc.h /^typedef VecPool_* VecPool;$/;" t VecPool_ include/slepc/private/vecimplslepc.h /^typedef struct VecPool_ {$/;" s VecPool_ include/slepc/private/vecimplslepc.h /^} VecPool_;$/;" t typeref:struct:VecPool_ VecScatterVecs src/eps/impls/ciss/ciss.c /^static PetscErrorCode VecScatterVecs(EPS eps,BV Vin,PetscInt n)$/;" f file: VecTDot_Comp src/sys/vec/veccomp0.h /^PetscErrorCode __SUF__(VecTDot_Comp)(Vec a,Vec b,PetscScalar *z)$/;" f VecWAXPY_Comp src/sys/vec/veccomp.c /^PetscErrorCode VecWAXPY_Comp(Vec v,PetscScalar alpha,Vec w,Vec z)$/;" f Vec_Comp include/slepc/private/vecimplslepc.h /^} Vec_Comp;$/;" t typeref:struct:__anon8 Vec_Comp_N include/slepc/private/vecimplslepc.h /^} Vec_Comp_N;$/;" t typeref:struct:__anon7 Vi src/pep/impls/krylov/toar/nrefine.c /^ Vec t,tg,Rv,Vi,tp,tpg;$/;" m struct:__anon105 file: Vnext src/eps/impls/krylov/krylovschur/krylovschur.h /^ BV Vnext; \/* temporary working basis during change of shift *\/$/;" m struct:_n_SR Vref src/eps/examples/tutorials/ex31.c /^PetscScalar Vref[3];$/;" v W include/slepc/private/fnimpl.h /^ Mat W[FN_MAX_W]; \/* workspace matrices *\/$/;" m struct:_p_FN W src/eps/impls/cg/rqcg/rqcg.c /^ BV AV,W,P,G;$/;" m struct:__anon60 file: W src/eps/impls/davidson/davidson.h /^ BV W; \/* left basis for harmonic case *\/$/;" m struct:_dvdDashboard W src/nep/impls/nleigs/nleigs.c /^ BV W; \/* auxiliary BV object *\/$/;" m struct:__anon92 file: W src/pep/impls/jd/pjdp.h /^ BV W; \/* work basis vectors to store the test space *\/$/;" m struct:__anon99 W src/pep/impls/krylov/toar/nrefine.c /^ BV V,M2,M3,W;$/;" m struct:__anon104 file: W src/pep/impls/krylov/toar/nrefine.c /^ BV V,W,M2,M3,Wt;$/;" m struct:__anon105 file: WARRANTY include/slepc/finclude/slepc.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcbv.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcbvdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcds.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcdsdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepceps.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcepsdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcfn.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcfndef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcmfn.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcmfndef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcnep.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcnepdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcpep.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcpepdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcrg.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcrgdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcst.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcstdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcsvd.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcsvddef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcsys.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v WARRANTY include/slepc/finclude/slepcsysdef.h /^! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS$/;" v W_shift src/eps/impls/davidson/davidson.h /^ PetscBool W_shift; \/* if true W is shifted when vectors converge *\/$/;" m struct:_dvdDashboard Wa src/eps/impls/davidson/dvdutils.c /^ PetscScalar Wa,Wb; \/* span{W} = span{Wa*AV - Wb*BV} *\/$/;" m struct:__anon72 file: Wb src/eps/impls/davidson/dvdutils.c /^ PetscScalar Wa,Wb; \/* span{W} = span{Wa*AV - Wb*BV} *\/$/;" m struct:__anon72 file: WindowsError config/install.py /^ WindowsError = None$/;" v WriteCMakeConfigFile config/configure.py /^def WriteCMakeConfigFile(cmakeconf):$/;" f WriteGnuMake config/gmakegen.py /^def WriteGnuMake(slepc):$/;" f WriteModulesFile config/configure.py /^def WriteModulesFile(modules,version,sdir):$/;" f WritePkgconfigFile config/configure.py /^def WritePkgconfigFile(pkgconfig,version,pversion,sdir,isinstall,prefixdir):$/;" f Wt src/pep/impls/krylov/toar/nrefine.c /^ BV V,W,M2,M3,Wt;$/;" m struct:__anon105 file: X src/pep/impls/jd/pjdp.h /^ BV X; \/* locked eigenvectors *\/$/;" m struct:__anon99 X src/pep/impls/jd/pjdp.h /^ BV X;$/;" m struct:__anon100 XKZ src/eps/impls/davidson/dvdimprovex.c /^ PetscScalar *XKZ; \/* X'*KZ *\/$/;" m struct:__anon68 file: Xd src/eps/examples/tutorials/ex31.c /^const PetscScalar Xd[3] = {0.146,0.8958,1.3125}; \/* d-axis reactance *\/$/;" v Xdp src/eps/examples/tutorials/ex31.c /^const PetscScalar Xdp[3] = {0.0608,0.1198,0.1813}; \/* d-axis transient reactance *\/$/;" v XpX src/pep/impls/jd/pjdp.h /^ PetscScalar *XpX; \/* X^H*X *\/$/;" m struct:__anon99 Xq src/eps/examples/tutorials/ex31.c /^const PetscScalar Xq[3] = {0.0969,0.8645,1.2578}; \/* q-axis reactance Xq(1) set to 0.4360, value given in text 0.0969 *\/$/;" v Xqp src/eps/examples/tutorials/ex31.c /^const PetscScalar Xqp[3] = {0.0969,0.1969,0.25}; \/* q-axis transient reactance *\/$/;" v Y src/eps/impls/ciss/ciss.c /^ BV Y;$/;" m struct:__anon61 file: Y src/nep/impls/ciss/nciss.c /^ BV Y;$/;" m struct:__anon89 file: Ybus src/eps/examples/tutorials/ex31.c /^ Mat Ybus; \/* Network admittance matrix *\/$/;" m struct:__anon57 file: _BVIMPL include/slepc/private/bvimpl.h 23;" d _BVOps include/slepc/private/bvimpl.h /^struct _BVOps {$/;" s _DSIMPL include/slepc/private/dsimpl.h 23;" d _DSOps include/slepc/private/dsimpl.h /^struct _DSOps {$/;" s _EPSIMPL include/slepc/private/epsimpl.h 23;" d _EPSOps include/slepc/private/epsimpl.h /^struct _EPSOps {$/;" s _FNIMPL include/slepc/private/fnimpl.h 23;" d _FNOps include/slepc/private/fnimpl.h /^struct _FNOps {$/;" s _MFNIMPL include/slepc/private/mfnimpl.h 23;" d _MFNOps include/slepc/private/mfnimpl.h /^struct _MFNOps {$/;" s _NEPIMPL include/slepc/private/nepimpl.h 23;" d _NEPOps include/slepc/private/nepimpl.h /^struct _NEPOps {$/;" s _PEPIMPL include/slepc/private/pepimpl.h 23;" d _PEPOps include/slepc/private/pepimpl.h /^struct _PEPOps {$/;" s _RGIMPL include/slepc/private/rgimpl.h 23;" d _RGOps include/slepc/private/rgimpl.h /^struct _RGOps {$/;" s _SLEPCIMPL include/slepc/private/slepcimpl.h 23;" d _STIMPL include/slepc/private/stimpl.h 23;" d _STOps include/slepc/private/stimpl.h /^struct _STOps {$/;" s _SVDIMPL include/slepc/private/svdimpl.h 23;" d _SVDOps include/slepc/private/svdimpl.h /^struct _SVDOps {$/;" s _VECIMPLSLEPC include/slepc/private/vecimplslepc.h 23;" d __ARPACKP_H src/eps/impls/external/arpack/arpackp.h 25;" d __BLZPACKP_H src/eps/impls/external/blzpack/blzpackp.h 25;" d __COMPOSE2__ src/sys/vec/veccomp.c 704;" d file: __COMPOSE3__ src/sys/vec/veccomp.c 705;" d file: __FEASTP_H src/eps/impls/external/feast/feastp.h 25;" d __FUNCT__ docs/manual/ex1.c 28;" d file: __FUNCT__ docs/manual/ex1.c 29;" d file: __FUNCT__ include/slepc/private/bvimpl.h 106;" d __FUNCT__ include/slepc/private/bvimpl.h 107;" d __FUNCT__ include/slepc/private/bvimpl.h 137;" d __FUNCT__ include/slepc/private/bvimpl.h 138;" d __FUNCT__ include/slepc/private/bvimpl.h 156;" d __FUNCT__ include/slepc/private/bvimpl.h 157;" d __FUNCT__ include/slepc/private/bvimpl.h 175;" d __FUNCT__ include/slepc/private/bvimpl.h 176;" d __FUNCT__ include/slepc/private/bvimpl.h 199;" d __FUNCT__ include/slepc/private/bvimpl.h 200;" d __FUNCT__ include/slepc/private/bvimpl.h 216;" d __FUNCT__ include/slepc/private/bvimpl.h 217;" d __FUNCT__ include/slepc/private/bvimpl.h 235;" d __FUNCT__ include/slepc/private/bvimpl.h 236;" d __FUNCT__ include/slepc/private/epsimpl.h 142;" d __FUNCT__ include/slepc/private/epsimpl.h 143;" d __FUNCT__ include/slepc/private/fnimpl.h 100;" d __FUNCT__ include/slepc/private/fnimpl.h 101;" d __FUNCT__ include/slepc/private/fnimpl.h 62;" d __FUNCT__ include/slepc/private/fnimpl.h 63;" d __FUNCT__ include/slepc/private/mfnimpl.h 109;" d __FUNCT__ include/slepc/private/mfnimpl.h 110;" d __FUNCT__ include/slepc/private/mfnimpl.h 83;" d __FUNCT__ include/slepc/private/mfnimpl.h 84;" d __FUNCT__ include/slepc/private/stimpl.h 81;" d __FUNCT__ include/slepc/private/stimpl.h 82;" d __FUNCT__ include/slepc/private/svdimpl.h 121;" d __FUNCT__ include/slepc/private/svdimpl.h 122;" d __FUNCT__ include/slepc/private/svdimpl.h 152;" d __FUNCT__ include/slepc/private/svdimpl.h 153;" d __FUNCT__ include/slepc/private/svdimpl.h 167;" d __FUNCT__ include/slepc/private/svdimpl.h 168;" d __FUNCT__ include/slepc/private/svdimpl.h 182;" d __FUNCT__ include/slepc/private/svdimpl.h 183;" d __FUNCT__ src/eps/examples/tests/test1.c 26;" d file: __FUNCT__ src/eps/examples/tests/test1.c 27;" d file: __FUNCT__ src/eps/examples/tests/test10.c 30;" d file: __FUNCT__ src/eps/examples/tests/test10.c 31;" d file: __FUNCT__ src/eps/examples/tests/test11.c 138;" d file: __FUNCT__ src/eps/examples/tests/test11.c 139;" d file: __FUNCT__ src/eps/examples/tests/test11.c 204;" d file: __FUNCT__ src/eps/examples/tests/test11.c 205;" d file: __FUNCT__ src/eps/examples/tests/test11.c 37;" d file: __FUNCT__ src/eps/examples/tests/test11.c 38;" d file: __FUNCT__ src/eps/examples/tests/test12.c 29;" d file: __FUNCT__ src/eps/examples/tests/test12.c 30;" d file: __FUNCT__ src/eps/examples/tests/test12.c 40;" d file: __FUNCT__ src/eps/examples/tests/test12.c 41;" d file: __FUNCT__ src/eps/examples/tests/test13.c 26;" d file: __FUNCT__ src/eps/examples/tests/test13.c 27;" d file: __FUNCT__ src/eps/examples/tests/test14.c 26;" d file: __FUNCT__ src/eps/examples/tests/test14.c 27;" d file: __FUNCT__ src/eps/examples/tests/test16.c 27;" d file: __FUNCT__ src/eps/examples/tests/test16.c 28;" d file: __FUNCT__ src/eps/examples/tests/test16.c 40;" d file: __FUNCT__ src/eps/examples/tests/test16.c 41;" d file: __FUNCT__ src/eps/examples/tests/test2.c 26;" d file: __FUNCT__ src/eps/examples/tests/test2.c 27;" d file: __FUNCT__ src/eps/examples/tests/test3.c 26;" d file: __FUNCT__ src/eps/examples/tests/test3.c 27;" d file: __FUNCT__ src/eps/examples/tests/test4.c 29;" d file: __FUNCT__ src/eps/examples/tests/test4.c 30;" d file: __FUNCT__ src/eps/examples/tests/test5.c 29;" d file: __FUNCT__ src/eps/examples/tests/test5.c 30;" d file: __FUNCT__ src/eps/examples/tests/test6.c 29;" d file: __FUNCT__ src/eps/examples/tests/test6.c 30;" d file: __FUNCT__ src/eps/examples/tests/test8.c 132;" d file: __FUNCT__ src/eps/examples/tests/test8.c 133;" d file: __FUNCT__ src/eps/examples/tests/test8.c 182;" d file: __FUNCT__ src/eps/examples/tests/test8.c 183;" d file: __FUNCT__ src/eps/examples/tests/test8.c 36;" d file: __FUNCT__ src/eps/examples/tests/test8.c 37;" d file: __FUNCT__ src/eps/examples/tests/test9.c 130;" d file: __FUNCT__ src/eps/examples/tests/test9.c 131;" d file: __FUNCT__ src/eps/examples/tests/test9.c 196;" d file: __FUNCT__ src/eps/examples/tests/test9.c 197;" d file: __FUNCT__ src/eps/examples/tests/test9.c 36;" d file: __FUNCT__ src/eps/examples/tests/test9.c 37;" d file: __FUNCT__ src/eps/examples/tutorials/ex1.c 28;" d file: __FUNCT__ src/eps/examples/tutorials/ex1.c 29;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 167;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 168;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 189;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 190;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 220;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 221;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 249;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 250;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 280;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 281;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 42;" d file: __FUNCT__ src/eps/examples/tutorials/ex10.c 43;" d file: __FUNCT__ src/eps/examples/tutorials/ex11.c 30;" d file: __FUNCT__ src/eps/examples/tutorials/ex11.c 31;" d file: __FUNCT__ src/eps/examples/tutorials/ex12.c 29;" d file: __FUNCT__ src/eps/examples/tutorials/ex12.c 30;" d file: __FUNCT__ src/eps/examples/tutorials/ex13.c 33;" d file: __FUNCT__ src/eps/examples/tutorials/ex13.c 34;" d file: __FUNCT__ src/eps/examples/tutorials/ex18.c 131;" d file: __FUNCT__ src/eps/examples/tutorials/ex18.c 132;" d file: __FUNCT__ src/eps/examples/tutorials/ex18.c 197;" d file: __FUNCT__ src/eps/examples/tutorials/ex18.c 198;" d file: __FUNCT__ src/eps/examples/tutorials/ex18.c 37;" d file: __FUNCT__ src/eps/examples/tutorials/ex18.c 38;" d file: __FUNCT__ src/eps/examples/tutorials/ex19.c 30;" d file: __FUNCT__ src/eps/examples/tutorials/ex19.c 31;" d file: __FUNCT__ src/eps/examples/tutorials/ex19.c 61;" d file: __FUNCT__ src/eps/examples/tutorials/ex19.c 62;" d file: __FUNCT__ src/eps/examples/tutorials/ex19.c 96;" d file: __FUNCT__ src/eps/examples/tutorials/ex19.c 97;" d file: __FUNCT__ src/eps/examples/tutorials/ex2.c 29;" d file: __FUNCT__ src/eps/examples/tutorials/ex2.c 30;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 206;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 207;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 228;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 229;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 247;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 248;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 46;" d file: __FUNCT__ src/eps/examples/tutorials/ex24.c 47;" d file: __FUNCT__ src/eps/examples/tutorials/ex25.c 30;" d file: __FUNCT__ src/eps/examples/tutorials/ex25.c 31;" d file: __FUNCT__ src/eps/examples/tutorials/ex29.c 116;" d file: __FUNCT__ src/eps/examples/tutorials/ex29.c 117;" d file: __FUNCT__ src/eps/examples/tutorials/ex29.c 182;" d file: __FUNCT__ src/eps/examples/tutorials/ex29.c 183;" d file: __FUNCT__ src/eps/examples/tutorials/ex29.c 39;" d file: __FUNCT__ src/eps/examples/tutorials/ex29.c 40;" d file: __FUNCT__ src/eps/examples/tutorials/ex3.c 140;" d file: __FUNCT__ src/eps/examples/tutorials/ex3.c 141;" d file: __FUNCT__ src/eps/examples/tutorials/ex3.c 190;" d file: __FUNCT__ src/eps/examples/tutorials/ex3.c 191;" d file: __FUNCT__ src/eps/examples/tutorials/ex3.c 36;" d file: __FUNCT__ src/eps/examples/tutorials/ex3.c 37;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 195;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 196;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 234;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 235;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 247;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 248;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 275;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 276;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 54;" d file: __FUNCT__ src/eps/examples/tutorials/ex30.c 55;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 149;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 150;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 160;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 161;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 170;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 171;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 257;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 258;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 308;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 309;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 540;" d file: __FUNCT__ src/eps/examples/tutorials/ex31.c 541;" d file: __FUNCT__ src/eps/examples/tutorials/ex4.c 29;" d file: __FUNCT__ src/eps/examples/tutorials/ex4.c 30;" d file: __FUNCT__ src/eps/examples/tutorials/ex5.c 126;" d file: __FUNCT__ src/eps/examples/tutorials/ex5.c 127;" d file: __FUNCT__ src/eps/examples/tutorials/ex5.c 35;" d file: __FUNCT__ src/eps/examples/tutorials/ex5.c 36;" d file: __FUNCT__ src/eps/examples/tutorials/ex7.c 33;" d file: __FUNCT__ src/eps/examples/tutorials/ex7.c 34;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 207;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 208;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 246;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 247;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 259;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 260;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 60;" d file: __FUNCT__ src/eps/examples/tutorials/ex9.c 61;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 102;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 103;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 412;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 413;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 423;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 424;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 452;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 453;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 463;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 464;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 491;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 492;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 506;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 507;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 50;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 51;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 541;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 542;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 552;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 553;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 580;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 581;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 591;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 592;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 626;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 627;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 637;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 638;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 665;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 666;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 67;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 683;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 684;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 68;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 722;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 723;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 739;" d file: __FUNCT__ src/eps/impls/cg/lobpcg/lobpcg.c 740;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 118;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 119;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 298;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 299;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 309;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 310;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 339;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 340;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 350;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 351;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 378;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 379;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 394;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 395;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 412;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 413;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 425;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 426;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 441;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 442;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 47;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 48;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 94;" d file: __FUNCT__ src/eps/impls/cg/rqcg/rqcg.c 95;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 108;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 109;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1184;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1185;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1231;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1232;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1280;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1281;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1296;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1297;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1328;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1329;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 133;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 134;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1350;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1351;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1383;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1384;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1395;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1396;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1424;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1425;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1446;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1447;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1479;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1480;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1491;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1492;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1520;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1521;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1532;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1533;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1562;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1563;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1573;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1574;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1602;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1603;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1613;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1614;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1649;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1650;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1660;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1661;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1688;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1689;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1699;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1700;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 171;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 172;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1735;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1736;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1746;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1747;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1775;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1776;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1809;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1810;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1856;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1857;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1879;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1880;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1909;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 1910;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 261;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 262;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 287;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 288;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 314;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 315;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 378;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 379;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 429;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 430;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 484;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 485;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 499;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 500;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 543;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 544;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 593;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 594;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 705;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 706;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 742;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 743;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 812;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 813;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 85;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 86;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 963;" d file: __FUNCT__ src/eps/impls/ciss/ciss.c 964;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 221;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 222;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 263;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 264;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 280;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 281;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 291;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 292;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 302;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 303;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 315;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 316;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 326;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 327;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 342;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 343;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 354;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 355;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 365;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 366;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 378;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 379;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 389;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 390;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 39;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 402;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 403;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 40;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 413;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 414;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 424;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 425;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 435;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 436;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 446;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 447;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 462;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 463;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 474;" d file: __FUNCT__ src/eps/impls/davidson/davidson.c 475;" d file: __FUNCT__ src/eps/impls/davidson/davidson.h 185;" d __FUNCT__ src/eps/impls/davidson/davidson.h 186;" d __FUNCT__ src/eps/impls/davidson/davidson.h 200;" d __FUNCT__ src/eps/impls/davidson/davidson.h 201;" d __FUNCT__ src/eps/impls/davidson/davidson.h 212;" d __FUNCT__ src/eps/impls/davidson/davidson.h 213;" d __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 108;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 109;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 167;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 168;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 215;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 216;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 238;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 239;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 332;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 333;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 36;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 37;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 397;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 398;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 442;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 443;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 485;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 486;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 50;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 517;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 518;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 51;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 552;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 553;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 70;" d file: __FUNCT__ src/eps/impls/davidson/dvdcalcpairs.c 71;" d file: __FUNCT__ src/eps/impls/davidson/dvdgd2.c 215;" d file: __FUNCT__ src/eps/impls/davidson/dvdgd2.c 216;" d file: __FUNCT__ src/eps/impls/davidson/dvdgd2.c 32;" d file: __FUNCT__ src/eps/impls/davidson/dvdgd2.c 33;" d file: __FUNCT__ src/eps/impls/davidson/dvdgd2.c 45;" d file: __FUNCT__ src/eps/impls/davidson/dvdgd2.c 46;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1084;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1085;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1174;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1175;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 117;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 118;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1206;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1207;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1223;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1224;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1242;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 1243;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 178;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 179;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 196;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 197;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 214;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 215;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 262;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 263;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 309;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 310;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 370;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 371;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 395;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 396;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 427;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 428;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 452;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 453;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 487;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 488;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 530;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 531;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 57;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 58;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 603;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 604;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 694;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 695;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 825;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 826;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 893;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 894;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 931;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 932;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 965;" d file: __FUNCT__ src/eps/impls/davidson/dvdimprovex.c 966;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 108;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 109;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 124;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 125;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 149;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 150;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 34;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 35;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 58;" d file: __FUNCT__ src/eps/impls/davidson/dvdinitv.c 59;" d file: __FUNCT__ src/eps/impls/davidson/dvdschm.c 26;" d file: __FUNCT__ src/eps/impls/davidson/dvdschm.c 27;" d file: __FUNCT__ src/eps/impls/davidson/dvdschm.c 66;" d file: __FUNCT__ src/eps/impls/davidson/dvdschm.c 67;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 28;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 29;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 43;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 44;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 58;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 59;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 69;" d file: __FUNCT__ src/eps/impls/davidson/dvdtestconv.c 70;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 102;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 103;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 167;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 168;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 223;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 224;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 265;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 266;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 314;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 315;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 351;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 352;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 40;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 41;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 61;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 62;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 82;" d file: __FUNCT__ src/eps/impls/davidson/dvdupdatev.c 83;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 143;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 144;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 166;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 167;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 180;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 181;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 222;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 223;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 234;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 235;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 267;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 268;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 297;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 298;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 337;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 338;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 376;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 377;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 402;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 403;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 416;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 417;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 432;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 433;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 54;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 55;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 68;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 69;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 80;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 81;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 94;" d file: __FUNCT__ src/eps/impls/davidson/dvdutils.c 95;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 106;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 107;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 130;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 131;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 167;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 168;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 192;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 193;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 223;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 224;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 253;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 254;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 283;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 284;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 312;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 313;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 341;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 342;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 374;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 375;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 410;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 411;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 447;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 448;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 44;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 45;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 477;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 478;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 506;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 507;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 536;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 537;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 570;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 571;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 581;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 582;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 610;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 611;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 621;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 622;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 651;" d file: __FUNCT__ src/eps/impls/davidson/gd/gd.c 652;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 114;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 115;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 139;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 140;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 172;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 173;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 199;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 200;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 230;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 231;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 260;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 261;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 290;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 291;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 319;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 320;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 348;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 349;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 381;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 382;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 417;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 418;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 454;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 455;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 45;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 46;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 488;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 489;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 523;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 524;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 554;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 555;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 584;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 585;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 614;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 615;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 648;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 649;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 678;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 679;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 707;" d file: __FUNCT__ src/eps/impls/davidson/jd/jd.c 708;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 294;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 295;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 29;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 309;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 30;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 310;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 327;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 328;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 338;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 339;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 95;" d file: __FUNCT__ src/eps/impls/external/arpack/arpack.c 96;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 109;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 110;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 124;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 125;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 135;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 136;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 153;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 154;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 217;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 218;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 319;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 320;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 330;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 331;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 359;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 360;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 370;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 371;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 398;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 399;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 410;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 411;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 424;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 425;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 440;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 441;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 44;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 45;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 472;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 473;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 59;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 60;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 70;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 71;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 98;" d file: __FUNCT__ src/eps/impls/external/blopex/blopex.c 99;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 152;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 153;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 284;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 285;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 298;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 299;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 314;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 315;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 327;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 328;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 347;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 348;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 375;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 376;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 391;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 392;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 418;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 419;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 433;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 434;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 462;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 463;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 65;" d file: __FUNCT__ src/eps/impls/external/blzpack/blzpack.c 66;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 179;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 180;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 191;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 192;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 204;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 205;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 226;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 227;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 242;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 243;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 257;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 258;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 287;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 288;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 298;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 299;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 29;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 30;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 327;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 328;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 80;" d file: __FUNCT__ src/eps/impls/external/feast/feast.c 81;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 149;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 150;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 191;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 192;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 215;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 216;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 236;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 237;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 250;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 251;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 265;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 266;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 289;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 290;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 326;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 327;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 339;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 340;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 377;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 378;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 388;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 389;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 416;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 417;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 427;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 428;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 459;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 460;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 470;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 471;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 498;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 499;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 51;" d file: __FUNCT__ src/eps/impls/external/primme/primme.c 52;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 101;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 102;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 160;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 161;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 172;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 173;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 183;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 184;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 32;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 33;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 77;" d file: __FUNCT__ src/eps/impls/external/trlan/trlan.c 78;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 163;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 164;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 181;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 182;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 192;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 193;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 227;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 228;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 238;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 239;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 267;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 268;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 280;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 281;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 298;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 299;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 44;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 45;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 77;" d file: __FUNCT__ src/eps/impls/krylov/arnoldi/arnoldi.c 78;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 186;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 187;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 235;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 236;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 28;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 29;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 331;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 332;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 385;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 386;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 72;" d file: __FUNCT__ src/eps/impls/krylov/epskrylov.c 73;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1034;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1035;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1051;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1052;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1090;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1091;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1104;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1105;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1139;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1140;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1197;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1198;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1255;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1256;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1297;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1298;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1321;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1322;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1349;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1350;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1361;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 1362;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 173;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 174;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 296;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 297;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 311;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 312;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 345;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 346;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 356;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 357;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 385;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 386;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 396;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 397;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 432;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 433;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 443;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 444;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 46;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 472;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 473;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 47;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 496;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 497;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 536;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 537;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 547;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 548;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 576;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 577;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 588;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 589;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 627;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 628;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 638;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 639;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 667;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 668;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 692;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 693;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 729;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 730;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 742;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 743;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 75;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 76;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 772;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 773;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 791;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 792;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 827;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 828;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 845;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 846;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 891;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 892;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 936;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 937;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 978;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 979;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 997;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/krylovschur.c 998;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-indef.c 29;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-indef.c 30;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1120;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1121;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 117;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 118;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1200;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1201;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1221;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1222;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1278;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1279;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1350;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 1351;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 169;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 170;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 328;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 329;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 359;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 360;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 537;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 538;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 55;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 56;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 601;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 602;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 621;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 622;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 677;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 678;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 773;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 774;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 812;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 813;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 84;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 858;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 859;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 85;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 897;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-slice.c 898;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-symm.c 30;" d file: __FUNCT__ src/eps/impls/krylov/krylovschur/ks-symm.c 31;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 100;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 101;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 152;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 153;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 218;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 219;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 302;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 303;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 339;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 340;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 381;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 382;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 48;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 493;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 494;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 49;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 558;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 559;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 746;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 747;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 765;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 766;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 787;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 788;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 818;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 819;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 829;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 830;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 858;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 859;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 870;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 871;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 883;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 884;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 899;" d file: __FUNCT__ src/eps/impls/krylov/lanczos/lanczos.c 900;" d file: __FUNCT__ src/eps/impls/lapack/lapack.c 134;" d file: __FUNCT__ src/eps/impls/lapack/lapack.c 135;" d file: __FUNCT__ src/eps/impls/lapack/lapack.c 166;" d file: __FUNCT__ src/eps/impls/lapack/lapack.c 167;" d file: __FUNCT__ src/eps/impls/lapack/lapack.c 27;" d file: __FUNCT__ src/eps/impls/lapack/lapack.c 28;" d file: __FUNCT__ src/eps/impls/power/power.c 214;" d file: __FUNCT__ src/eps/impls/power/power.c 215;" d file: __FUNCT__ src/eps/impls/power/power.c 228;" d file: __FUNCT__ src/eps/impls/power/power.c 229;" d file: __FUNCT__ src/eps/impls/power/power.c 250;" d file: __FUNCT__ src/eps/impls/power/power.c 251;" d file: __FUNCT__ src/eps/impls/power/power.c 269;" d file: __FUNCT__ src/eps/impls/power/power.c 270;" d file: __FUNCT__ src/eps/impls/power/power.c 310;" d file: __FUNCT__ src/eps/impls/power/power.c 311;" d file: __FUNCT__ src/eps/impls/power/power.c 321;" d file: __FUNCT__ src/eps/impls/power/power.c 322;" d file: __FUNCT__ src/eps/impls/power/power.c 350;" d file: __FUNCT__ src/eps/impls/power/power.c 351;" d file: __FUNCT__ src/eps/impls/power/power.c 363;" d file: __FUNCT__ src/eps/impls/power/power.c 364;" d file: __FUNCT__ src/eps/impls/power/power.c 379;" d file: __FUNCT__ src/eps/impls/power/power.c 380;" d file: __FUNCT__ src/eps/impls/power/power.c 48;" d file: __FUNCT__ src/eps/impls/power/power.c 49;" d file: __FUNCT__ src/eps/impls/power/power.c 82;" d file: __FUNCT__ src/eps/impls/power/power.c 83;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 118;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 119;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 156;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 157;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 322;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 323;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 333;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 334;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 39;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 40;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 69;" d file: __FUNCT__ src/eps/impls/subspace/subspace.c 70;" d file: __FUNCT__ src/eps/interface/dlregiseps.c 107;" d file: __FUNCT__ src/eps/interface/dlregiseps.c 108;" d file: __FUNCT__ src/eps/interface/dlregiseps.c 36;" d file: __FUNCT__ src/eps/interface/dlregiseps.c 37;" d file: __FUNCT__ src/eps/interface/dlregiseps.c 57;" d file: __FUNCT__ src/eps/interface/dlregiseps.c 58;" d file: __FUNCT__ src/eps/interface/epsbasic.c 127;" d file: __FUNCT__ src/eps/interface/epsbasic.c 128;" d file: __FUNCT__ src/eps/interface/epsbasic.c 182;" d file: __FUNCT__ src/eps/interface/epsbasic.c 183;" d file: __FUNCT__ src/eps/interface/epsbasic.c 208;" d file: __FUNCT__ src/eps/interface/epsbasic.c 209;" d file: __FUNCT__ src/eps/interface/epsbasic.c 245;" d file: __FUNCT__ src/eps/interface/epsbasic.c 246;" d file: __FUNCT__ src/eps/interface/epsbasic.c 283;" d file: __FUNCT__ src/eps/interface/epsbasic.c 284;" d file: __FUNCT__ src/eps/interface/epsbasic.c 31;" d file: __FUNCT__ src/eps/interface/epsbasic.c 322;" d file: __FUNCT__ src/eps/interface/epsbasic.c 323;" d file: __FUNCT__ src/eps/interface/epsbasic.c 32;" d file: __FUNCT__ src/eps/interface/epsbasic.c 361;" d file: __FUNCT__ src/eps/interface/epsbasic.c 362;" d file: __FUNCT__ src/eps/interface/epsbasic.c 390;" d file: __FUNCT__ src/eps/interface/epsbasic.c 391;" d file: __FUNCT__ src/eps/interface/epsbasic.c 433;" d file: __FUNCT__ src/eps/interface/epsbasic.c 434;" d file: __FUNCT__ src/eps/interface/epsbasic.c 465;" d file: __FUNCT__ src/eps/interface/epsbasic.c 466;" d file: __FUNCT__ src/eps/interface/epsbasic.c 499;" d file: __FUNCT__ src/eps/interface/epsbasic.c 500;" d file: __FUNCT__ src/eps/interface/epsbasic.c 532;" d file: __FUNCT__ src/eps/interface/epsbasic.c 533;" d file: __FUNCT__ src/eps/interface/epsbasic.c 566;" d file: __FUNCT__ src/eps/interface/epsbasic.c 567;" d file: __FUNCT__ src/eps/interface/epsbasic.c 598;" d file: __FUNCT__ src/eps/interface/epsbasic.c 599;" d file: __FUNCT__ src/eps/interface/epsbasic.c 632;" d file: __FUNCT__ src/eps/interface/epsbasic.c 633;" d file: __FUNCT__ src/eps/interface/epsbasic.c 664;" d file: __FUNCT__ src/eps/interface/epsbasic.c 665;" d file: __FUNCT__ src/eps/interface/epsbasic.c 698;" d file: __FUNCT__ src/eps/interface/epsbasic.c 699;" d file: __FUNCT__ src/eps/interface/epsbasic.c 730;" d file: __FUNCT__ src/eps/interface/epsbasic.c 731;" d file: __FUNCT__ src/eps/interface/epsbasic.c 757;" d file: __FUNCT__ src/eps/interface/epsbasic.c 758;" d file: __FUNCT__ src/eps/interface/epsbasic.c 784;" d file: __FUNCT__ src/eps/interface/epsbasic.c 785;" d file: __FUNCT__ src/eps/interface/epsdefault.c 131;" d file: __FUNCT__ src/eps/interface/epsdefault.c 132;" d file: __FUNCT__ src/eps/interface/epsdefault.c 221;" d file: __FUNCT__ src/eps/interface/epsdefault.c 222;" d file: __FUNCT__ src/eps/interface/epsdefault.c 255;" d file: __FUNCT__ src/eps/interface/epsdefault.c 256;" d file: __FUNCT__ src/eps/interface/epsdefault.c 273;" d file: __FUNCT__ src/eps/interface/epsdefault.c 274;" d file: __FUNCT__ src/eps/interface/epsdefault.c 27;" d file: __FUNCT__ src/eps/interface/epsdefault.c 288;" d file: __FUNCT__ src/eps/interface/epsdefault.c 289;" d file: __FUNCT__ src/eps/interface/epsdefault.c 28;" d file: __FUNCT__ src/eps/interface/epsdefault.c 300;" d file: __FUNCT__ src/eps/interface/epsdefault.c 301;" d file: __FUNCT__ src/eps/interface/epsdefault.c 316;" d file: __FUNCT__ src/eps/interface/epsdefault.c 317;" d file: __FUNCT__ src/eps/interface/epsdefault.c 366;" d file: __FUNCT__ src/eps/interface/epsdefault.c 367;" d file: __FUNCT__ src/eps/interface/epsdefault.c 38;" d file: __FUNCT__ src/eps/interface/epsdefault.c 39;" d file: __FUNCT__ src/eps/interface/epsdefault.c 427;" d file: __FUNCT__ src/eps/interface/epsdefault.c 428;" d file: __FUNCT__ src/eps/interface/epsdefault.c 68;" d file: __FUNCT__ src/eps/interface/epsdefault.c 69;" d file: __FUNCT__ src/eps/interface/epsmon.c 104;" d file: __FUNCT__ src/eps/interface/epsmon.c 105;" d file: __FUNCT__ src/eps/interface/epsmon.c 139;" d file: __FUNCT__ src/eps/interface/epsmon.c 140;" d file: __FUNCT__ src/eps/interface/epsmon.c 165;" d file: __FUNCT__ src/eps/interface/epsmon.c 166;" d file: __FUNCT__ src/eps/interface/epsmon.c 224;" d file: __FUNCT__ src/eps/interface/epsmon.c 225;" d file: __FUNCT__ src/eps/interface/epsmon.c 27;" d file: __FUNCT__ src/eps/interface/epsmon.c 281;" d file: __FUNCT__ src/eps/interface/epsmon.c 282;" d file: __FUNCT__ src/eps/interface/epsmon.c 28;" d file: __FUNCT__ src/eps/interface/epsmon.c 343;" d file: __FUNCT__ src/eps/interface/epsmon.c 344;" d file: __FUNCT__ src/eps/interface/epsmon.c 389;" d file: __FUNCT__ src/eps/interface/epsmon.c 390;" d file: __FUNCT__ src/eps/interface/epsmon.c 415;" d file: __FUNCT__ src/eps/interface/epsmon.c 416;" d file: __FUNCT__ src/eps/interface/epsmon.c 44;" d file: __FUNCT__ src/eps/interface/epsmon.c 45;" d file: __FUNCT__ src/eps/interface/epsopts.c 1032;" d file: __FUNCT__ src/eps/interface/epsopts.c 1033;" d file: __FUNCT__ src/eps/interface/epsopts.c 1058;" d file: __FUNCT__ src/eps/interface/epsopts.c 1059;" d file: __FUNCT__ src/eps/interface/epsopts.c 106;" d file: __FUNCT__ src/eps/interface/epsopts.c 107;" d file: __FUNCT__ src/eps/interface/epsopts.c 1102;" d file: __FUNCT__ src/eps/interface/epsopts.c 1103;" d file: __FUNCT__ src/eps/interface/epsopts.c 1128;" d file: __FUNCT__ src/eps/interface/epsopts.c 1129;" d file: __FUNCT__ src/eps/interface/epsopts.c 1202;" d file: __FUNCT__ src/eps/interface/epsopts.c 1203;" d file: __FUNCT__ src/eps/interface/epsopts.c 1235;" d file: __FUNCT__ src/eps/interface/epsopts.c 1236;" d file: __FUNCT__ src/eps/interface/epsopts.c 1273;" d file: __FUNCT__ src/eps/interface/epsopts.c 1274;" d file: __FUNCT__ src/eps/interface/epsopts.c 1300;" d file: __FUNCT__ src/eps/interface/epsopts.c 1301;" d file: __FUNCT__ src/eps/interface/epsopts.c 1334;" d file: __FUNCT__ src/eps/interface/epsopts.c 1335;" d file: __FUNCT__ src/eps/interface/epsopts.c 1361;" d file: __FUNCT__ src/eps/interface/epsopts.c 1362;" d file: __FUNCT__ src/eps/interface/epsopts.c 1394;" d file: __FUNCT__ src/eps/interface/epsopts.c 1395;" d file: __FUNCT__ src/eps/interface/epsopts.c 1421;" d file: __FUNCT__ src/eps/interface/epsopts.c 1422;" d file: __FUNCT__ src/eps/interface/epsopts.c 1467;" d file: __FUNCT__ src/eps/interface/epsopts.c 1468;" d file: __FUNCT__ src/eps/interface/epsopts.c 1505;" d file: __FUNCT__ src/eps/interface/epsopts.c 1506;" d file: __FUNCT__ src/eps/interface/epsopts.c 28;" d file: __FUNCT__ src/eps/interface/epsopts.c 29;" d file: __FUNCT__ src/eps/interface/epsopts.c 311;" d file: __FUNCT__ src/eps/interface/epsopts.c 312;" d file: __FUNCT__ src/eps/interface/epsopts.c 342;" d file: __FUNCT__ src/eps/interface/epsopts.c 343;" d file: __FUNCT__ src/eps/interface/epsopts.c 389;" d file: __FUNCT__ src/eps/interface/epsopts.c 390;" d file: __FUNCT__ src/eps/interface/epsopts.c 419;" d file: __FUNCT__ src/eps/interface/epsopts.c 420;" d file: __FUNCT__ src/eps/interface/epsopts.c 484;" d file: __FUNCT__ src/eps/interface/epsopts.c 485;" d file: __FUNCT__ src/eps/interface/epsopts.c 576;" d file: __FUNCT__ src/eps/interface/epsopts.c 577;" d file: __FUNCT__ src/eps/interface/epsopts.c 606;" d file: __FUNCT__ src/eps/interface/epsopts.c 607;" d file: __FUNCT__ src/eps/interface/epsopts.c 649;" d file: __FUNCT__ src/eps/interface/epsopts.c 650;" d file: __FUNCT__ src/eps/interface/epsopts.c 69;" d file: __FUNCT__ src/eps/interface/epsopts.c 708;" d file: __FUNCT__ src/eps/interface/epsopts.c 709;" d file: __FUNCT__ src/eps/interface/epsopts.c 70;" d file: __FUNCT__ src/eps/interface/epsopts.c 759;" d file: __FUNCT__ src/eps/interface/epsopts.c 760;" d file: __FUNCT__ src/eps/interface/epsopts.c 805;" d file: __FUNCT__ src/eps/interface/epsopts.c 806;" d file: __FUNCT__ src/eps/interface/epsopts.c 832;" d file: __FUNCT__ src/eps/interface/epsopts.c 833;" d file: __FUNCT__ src/eps/interface/epsopts.c 884;" d file: __FUNCT__ src/eps/interface/epsopts.c 885;" d file: __FUNCT__ src/eps/interface/epsopts.c 924;" d file: __FUNCT__ src/eps/interface/epsopts.c 925;" d file: __FUNCT__ src/eps/interface/epsopts.c 951;" d file: __FUNCT__ src/eps/interface/epsopts.c 952;" d file: __FUNCT__ src/eps/interface/epsregis.c 54;" d file: __FUNCT__ src/eps/interface/epsregis.c 55;" d file: __FUNCT__ src/eps/interface/epssetup.c 235;" d file: __FUNCT__ src/eps/interface/epssetup.c 236;" d file: __FUNCT__ src/eps/interface/epssetup.c 26;" d file: __FUNCT__ src/eps/interface/epssetup.c 27;" d file: __FUNCT__ src/eps/interface/epssetup.c 292;" d file: __FUNCT__ src/eps/interface/epssetup.c 293;" d file: __FUNCT__ src/eps/interface/epssetup.c 330;" d file: __FUNCT__ src/eps/interface/epssetup.c 331;" d file: __FUNCT__ src/eps/interface/epssetup.c 372;" d file: __FUNCT__ src/eps/interface/epssetup.c 373;" d file: __FUNCT__ src/eps/interface/epssetup.c 415;" d file: __FUNCT__ src/eps/interface/epssetup.c 416;" d file: __FUNCT__ src/eps/interface/epssetup.c 447;" d file: __FUNCT__ src/eps/interface/epssetup.c 448;" d file: __FUNCT__ src/eps/interface/epssolve.c 176;" d file: __FUNCT__ src/eps/interface/epssolve.c 177;" d file: __FUNCT__ src/eps/interface/epssolve.c 211;" d file: __FUNCT__ src/eps/interface/epssolve.c 212;" d file: __FUNCT__ src/eps/interface/epssolve.c 241;" d file: __FUNCT__ src/eps/interface/epssolve.c 242;" d file: __FUNCT__ src/eps/interface/epssolve.c 27;" d file: __FUNCT__ src/eps/interface/epssolve.c 280;" d file: __FUNCT__ src/eps/interface/epssolve.c 281;" d file: __FUNCT__ src/eps/interface/epssolve.c 28;" d file: __FUNCT__ src/eps/interface/epssolve.c 332;" d file: __FUNCT__ src/eps/interface/epssolve.c 333;" d file: __FUNCT__ src/eps/interface/epssolve.c 387;" d file: __FUNCT__ src/eps/interface/epssolve.c 388;" d file: __FUNCT__ src/eps/interface/epssolve.c 434;" d file: __FUNCT__ src/eps/interface/epssolve.c 435;" d file: __FUNCT__ src/eps/interface/epssolve.c 48;" d file: __FUNCT__ src/eps/interface/epssolve.c 49;" d file: __FUNCT__ src/eps/interface/epssolve.c 507;" d file: __FUNCT__ src/eps/interface/epssolve.c 508;" d file: __FUNCT__ src/eps/interface/epssolve.c 542;" d file: __FUNCT__ src/eps/interface/epssolve.c 543;" d file: __FUNCT__ src/eps/interface/epssolve.c 605;" d file: __FUNCT__ src/eps/interface/epssolve.c 606;" d file: __FUNCT__ src/eps/interface/epssolve.c 695;" d file: __FUNCT__ src/eps/interface/epssolve.c 696;" d file: __FUNCT__ src/eps/interface/epsview.c 236;" d file: __FUNCT__ src/eps/interface/epsview.c 237;" d file: __FUNCT__ src/eps/interface/epsview.c 273;" d file: __FUNCT__ src/eps/interface/epsview.c 274;" d file: __FUNCT__ src/eps/interface/epsview.c 27;" d file: __FUNCT__ src/eps/interface/epsview.c 28;" d file: __FUNCT__ src/eps/interface/epsview.c 308;" d file: __FUNCT__ src/eps/interface/epsview.c 309;" d file: __FUNCT__ src/eps/interface/epsview.c 363;" d file: __FUNCT__ src/eps/interface/epsview.c 364;" d file: __FUNCT__ src/eps/interface/epsview.c 408;" d file: __FUNCT__ src/eps/interface/epsview.c 409;" d file: __FUNCT__ src/eps/interface/epsview.c 428;" d file: __FUNCT__ src/eps/interface/epsview.c 429;" d file: __FUNCT__ src/eps/interface/epsview.c 489;" d file: __FUNCT__ src/eps/interface/epsview.c 490;" d file: __FUNCT__ src/eps/interface/epsview.c 538;" d file: __FUNCT__ src/eps/interface/epsview.c 539;" d file: __FUNCT__ src/eps/interface/epsview.c 571;" d file: __FUNCT__ src/eps/interface/epsview.c 572;" d file: __FUNCT__ src/eps/interface/epsview.c 602;" d file: __FUNCT__ src/eps/interface/epsview.c 603;" d file: __FUNCT__ src/eps/interface/epsview.c 633;" d file: __FUNCT__ src/eps/interface/epsview.c 634;" d file: __FUNCT__ src/eps/interface/epsview.c 685;" d file: __FUNCT__ src/eps/interface/epsview.c 686;" d file: __FUNCT__ src/eps/interface/epsview.c 720;" d file: __FUNCT__ src/eps/interface/epsview.c 721;" d file: __FUNCT__ src/eps/interface/epsview.c 773;" d file: __FUNCT__ src/eps/interface/epsview.c 774;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 123;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 124;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 130;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 131;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 138;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 139;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 145;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 146;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 153;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 154;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 160;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 161;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 168;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 169;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 176;" d file: __FUNCT__ src/eps/interface/ftn-custom/zepsf.c 177;" d file: __FUNCT__ src/mfn/examples/tests/test1.c 28;" d file: __FUNCT__ src/mfn/examples/tests/test1.c 29;" d file: __FUNCT__ src/mfn/examples/tutorials/ex23.c 136;" d file: __FUNCT__ src/mfn/examples/tutorials/ex23.c 137;" d file: __FUNCT__ src/mfn/examples/tutorials/ex23.c 34;" d file: __FUNCT__ src/mfn/examples/tutorials/ex23.c 35;" d file: __FUNCT__ src/mfn/examples/tutorials/ex26.c 29;" d file: __FUNCT__ src/mfn/examples/tutorials/ex26.c 30;" d file: __FUNCT__ src/mfn/impls/expokit/mfnexpokit.c 198;" d file: __FUNCT__ src/mfn/impls/expokit/mfnexpokit.c 199;" d file: __FUNCT__ src/mfn/impls/expokit/mfnexpokit.c 39;" d file: __FUNCT__ src/mfn/impls/expokit/mfnexpokit.c 40;" d file: __FUNCT__ src/mfn/impls/expokit/mfnexpokit.c 58;" d file: __FUNCT__ src/mfn/impls/expokit/mfnexpokit.c 59;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 179;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 180;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 41;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 42;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 56;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 57;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 84;" d file: __FUNCT__ src/mfn/impls/krylov/mfnkrylov.c 85;" d file: __FUNCT__ src/mfn/interface/dlregismfn.c 100;" d file: __FUNCT__ src/mfn/interface/dlregismfn.c 101;" d file: __FUNCT__ src/mfn/interface/dlregismfn.c 29;" d file: __FUNCT__ src/mfn/interface/dlregismfn.c 30;" d file: __FUNCT__ src/mfn/interface/dlregismfn.c 50;" d file: __FUNCT__ src/mfn/interface/dlregismfn.c 51;" d file: __FUNCT__ src/mfn/interface/ftn-custom/zmfnf.c 69;" d file: __FUNCT__ src/mfn/interface/ftn-custom/zmfnf.c 70;" d file: __FUNCT__ src/mfn/interface/ftn-custom/zmfnf.c 76;" d file: __FUNCT__ src/mfn/interface/ftn-custom/zmfnf.c 77;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 133;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 134;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 168;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 169;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 223;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 224;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 278;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 279;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 304;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 305;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 31;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 32;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 341;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 342;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 367;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 368;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 399;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 400;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 433;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 434;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 466;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 467;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 500;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 501;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 96;" d file: __FUNCT__ src/mfn/interface/mfnbasic.c 97;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 129;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 130;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 155;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 156;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 194;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 195;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 239;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 240;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 27;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 28;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 44;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 45;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 94;" d file: __FUNCT__ src/mfn/interface/mfnmon.c 95;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 160;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 161;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 191;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 192;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 238;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 239;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 264;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 265;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 28;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 29;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 301;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 302;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 333;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 334;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 360;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 361;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 402;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 403;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 436;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 437;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 66;" d file: __FUNCT__ src/mfn/interface/mfnopts.c 67;" d file: __FUNCT__ src/mfn/interface/mfnregis.c 27;" d file: __FUNCT__ src/mfn/interface/mfnregis.c 28;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 123;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 124;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 149;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 150;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 26;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 27;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 85;" d file: __FUNCT__ src/mfn/interface/mfnsetup.c 86;" d file: __FUNCT__ src/mfn/interface/mfnsolve.c 100;" d file: __FUNCT__ src/mfn/interface/mfnsolve.c 101;" d file: __FUNCT__ src/mfn/interface/mfnsolve.c 135;" d file: __FUNCT__ src/mfn/interface/mfnsolve.c 136;" d file: __FUNCT__ src/mfn/interface/mfnsolve.c 26;" d file: __FUNCT__ src/mfn/interface/mfnsolve.c 27;" d file: __FUNCT__ src/nep/examples/nlevp/gun.c 159;" d file: __FUNCT__ src/nep/examples/nlevp/gun.c 160;" d file: __FUNCT__ src/nep/examples/nlevp/gun.c 47;" d file: __FUNCT__ src/nep/examples/nlevp/gun.c 48;" d file: __FUNCT__ src/nep/examples/nlevp/loaded_string.c 43;" d file: __FUNCT__ src/nep/examples/nlevp/loaded_string.c 44;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 214;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 215;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 232;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 233;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 306;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 307;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 375;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 376;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 416;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 417;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 53;" d file: __FUNCT__ src/nep/examples/tutorials/ex20.c 54;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 181;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 182;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 199;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 200;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 225;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 226;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 251;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 252;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 284;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 285;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 308;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 309;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 322;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 323;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 350;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 351;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 382;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 383;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 65;" d file: __FUNCT__ src/nep/examples/tutorials/ex21.c 66;" d file: __FUNCT__ src/nep/examples/tutorials/ex22.c 46;" d file: __FUNCT__ src/nep/examples/tutorials/ex22.c 47;" d file: __FUNCT__ src/nep/examples/tutorials/ex27.c 179;" d file: __FUNCT__ src/nep/examples/tutorials/ex27.c 180;" d file: __FUNCT__ src/nep/examples/tutorials/ex27.c 226;" d file: __FUNCT__ src/nep/examples/tutorials/ex27.c 227;" d file: __FUNCT__ src/nep/examples/tutorials/ex27.c 43;" d file: __FUNCT__ src/nep/examples/tutorials/ex27.c 44;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1006;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1007;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 100;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 101;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1032;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1033;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1067;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1068;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1084;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1085;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1108;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 1109;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 126;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 127;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 152;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 153;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 212;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 213;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 255;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 256;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 305;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 306;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 320;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 321;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 364;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 365;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 408;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 409;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 445;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 446;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 517;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 518;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 668;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 669;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 713;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 714;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 766;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 767;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 77;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 782;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 783;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 78;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 814;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 815;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 836;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 837;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 869;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 870;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 881;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 882;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 910;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 911;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 932;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 933;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 965;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 966;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 977;" d file: __FUNCT__ src/nep/impls/ciss/nciss.c 978;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 103;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 104;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 127;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 128;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 187;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 188;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 215;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 216;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 231;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 232;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 242;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 243;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 268;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 269;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 279;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 280;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 307;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 308;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 323;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 324;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 351;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 352;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 374;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 375;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 403;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 404;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 423;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 424;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 435;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 436;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 452;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 453;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 45;" d file: __FUNCT__ src/nep/impls/interpol/interpol.c 46;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 181;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 182;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 195;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 196;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 211;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 212;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 239;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 240;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 259;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 260;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 288;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 289;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 307;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 308;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 322;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 323;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 42;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 43;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 57;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 58;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 86;" d file: __FUNCT__ src/nep/impls/narnoldi/narnoldi.c 87;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1064;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1065;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1095;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1096;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 116;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 117;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1267;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1268;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1279;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1280;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1318;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1319;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1330;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1331;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1359;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1360;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1374;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1375;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1408;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1409;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1419;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1420;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1447;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1448;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1458;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1459;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1494;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1495;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1505;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1506;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1533;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1534;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1557;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1558;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1593;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1594;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1605;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1606;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1634;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1635;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1645;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1646;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1681;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1682;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1692;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1693;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1721;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1722;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1742;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1743;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 176;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 177;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1783;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1784;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1800;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1801;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1833;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1834;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1891;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1892;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1916;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1917;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 192;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 193;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1943;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1944;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1979;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1980;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 1999;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 2000;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 2029;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 2030;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 211;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 212;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 230;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 231;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 249;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 250;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 285;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 286;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 305;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 306;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 334;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 335;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 348;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 349;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 377;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 378;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 422;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 423;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 493;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 494;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 578;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 579;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 609;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 610;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 664;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 665;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 721;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 722;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 737;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 738;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 73;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 74;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 790;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 791;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 860;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 861;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 87;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 881;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 882;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 88;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 936;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 937;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 997;" d file: __FUNCT__ src/nep/impls/nleigs/nleigs.c 998;" d file: __FUNCT__ src/nep/impls/rii/rii.c 180;" d file: __FUNCT__ src/nep/impls/rii/rii.c 181;" d file: __FUNCT__ src/nep/impls/rii/rii.c 203;" d file: __FUNCT__ src/nep/impls/rii/rii.c 204;" d file: __FUNCT__ src/nep/impls/rii/rii.c 214;" d file: __FUNCT__ src/nep/impls/rii/rii.c 215;" d file: __FUNCT__ src/nep/impls/rii/rii.c 242;" d file: __FUNCT__ src/nep/impls/rii/rii.c 243;" d file: __FUNCT__ src/nep/impls/rii/rii.c 253;" d file: __FUNCT__ src/nep/impls/rii/rii.c 254;" d file: __FUNCT__ src/nep/impls/rii/rii.c 281;" d file: __FUNCT__ src/nep/impls/rii/rii.c 282;" d file: __FUNCT__ src/nep/impls/rii/rii.c 293;" d file: __FUNCT__ src/nep/impls/rii/rii.c 294;" d file: __FUNCT__ src/nep/impls/rii/rii.c 329;" d file: __FUNCT__ src/nep/impls/rii/rii.c 330;" d file: __FUNCT__ src/nep/impls/rii/rii.c 340;" d file: __FUNCT__ src/nep/impls/rii/rii.c 341;" d file: __FUNCT__ src/nep/impls/rii/rii.c 368;" d file: __FUNCT__ src/nep/impls/rii/rii.c 369;" d file: __FUNCT__ src/nep/impls/rii/rii.c 379;" d file: __FUNCT__ src/nep/impls/rii/rii.c 380;" d file: __FUNCT__ src/nep/impls/rii/rii.c 415;" d file: __FUNCT__ src/nep/impls/rii/rii.c 416;" d file: __FUNCT__ src/nep/impls/rii/rii.c 426;" d file: __FUNCT__ src/nep/impls/rii/rii.c 427;" d file: __FUNCT__ src/nep/impls/rii/rii.c 454;" d file: __FUNCT__ src/nep/impls/rii/rii.c 455;" d file: __FUNCT__ src/nep/impls/rii/rii.c 45;" d file: __FUNCT__ src/nep/impls/rii/rii.c 46;" d file: __FUNCT__ src/nep/impls/rii/rii.c 470;" d file: __FUNCT__ src/nep/impls/rii/rii.c 471;" d file: __FUNCT__ src/nep/impls/rii/rii.c 498;" d file: __FUNCT__ src/nep/impls/rii/rii.c 499;" d file: __FUNCT__ src/nep/impls/rii/rii.c 518;" d file: __FUNCT__ src/nep/impls/rii/rii.c 519;" d file: __FUNCT__ src/nep/impls/rii/rii.c 547;" d file: __FUNCT__ src/nep/impls/rii/rii.c 548;" d file: __FUNCT__ src/nep/impls/rii/rii.c 573;" d file: __FUNCT__ src/nep/impls/rii/rii.c 574;" d file: __FUNCT__ src/nep/impls/rii/rii.c 594;" d file: __FUNCT__ src/nep/impls/rii/rii.c 595;" d file: __FUNCT__ src/nep/impls/rii/rii.c 60;" d file: __FUNCT__ src/nep/impls/rii/rii.c 61;" d file: __FUNCT__ src/nep/impls/rii/rii.c 84;" d file: __FUNCT__ src/nep/impls/rii/rii.c 85;" d file: __FUNCT__ src/nep/impls/slp/slp.c 139;" d file: __FUNCT__ src/nep/impls/slp/slp.c 140;" d file: __FUNCT__ src/nep/impls/slp/slp.c 154;" d file: __FUNCT__ src/nep/impls/slp/slp.c 155;" d file: __FUNCT__ src/nep/impls/slp/slp.c 170;" d file: __FUNCT__ src/nep/impls/slp/slp.c 171;" d file: __FUNCT__ src/nep/impls/slp/slp.c 198;" d file: __FUNCT__ src/nep/impls/slp/slp.c 199;" d file: __FUNCT__ src/nep/impls/slp/slp.c 220;" d file: __FUNCT__ src/nep/impls/slp/slp.c 221;" d file: __FUNCT__ src/nep/impls/slp/slp.c 249;" d file: __FUNCT__ src/nep/impls/slp/slp.c 250;" d file: __FUNCT__ src/nep/impls/slp/slp.c 268;" d file: __FUNCT__ src/nep/impls/slp/slp.c 269;" d file: __FUNCT__ src/nep/impls/slp/slp.c 280;" d file: __FUNCT__ src/nep/impls/slp/slp.c 281;" d file: __FUNCT__ src/nep/impls/slp/slp.c 295;" d file: __FUNCT__ src/nep/impls/slp/slp.c 296;" d file: __FUNCT__ src/nep/impls/slp/slp.c 42;" d file: __FUNCT__ src/nep/impls/slp/slp.c 43;" d file: __FUNCT__ src/nep/impls/slp/slp.c 76;" d file: __FUNCT__ src/nep/impls/slp/slp.c 77;" d file: __FUNCT__ src/nep/interface/dlregisnep.c 107;" d file: __FUNCT__ src/nep/interface/dlregisnep.c 108;" d file: __FUNCT__ src/nep/interface/dlregisnep.c 32;" d file: __FUNCT__ src/nep/interface/dlregisnep.c 33;" d file: __FUNCT__ src/nep/interface/dlregisnep.c 53;" d file: __FUNCT__ src/nep/interface/dlregisnep.c 54;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 112;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 113;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 119;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 120;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 127;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 128;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 134;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 135;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 142;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 143;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 149;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 150;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 157;" d file: __FUNCT__ src/nep/interface/ftn-custom/znepf.c 158;" d file: __FUNCT__ src/nep/interface/nepbasic.c 1006;" d file: __FUNCT__ src/nep/interface/nepbasic.c 1007;" d file: __FUNCT__ src/nep/interface/nepbasic.c 124;" d file: __FUNCT__ src/nep/interface/nepbasic.c 125;" d file: __FUNCT__ src/nep/interface/nepbasic.c 178;" d file: __FUNCT__ src/nep/interface/nepbasic.c 179;" d file: __FUNCT__ src/nep/interface/nepbasic.c 204;" d file: __FUNCT__ src/nep/interface/nepbasic.c 205;" d file: __FUNCT__ src/nep/interface/nepbasic.c 241;" d file: __FUNCT__ src/nep/interface/nepbasic.c 242;" d file: __FUNCT__ src/nep/interface/nepbasic.c 267;" d file: __FUNCT__ src/nep/interface/nepbasic.c 268;" d file: __FUNCT__ src/nep/interface/nepbasic.c 305;" d file: __FUNCT__ src/nep/interface/nepbasic.c 306;" d file: __FUNCT__ src/nep/interface/nepbasic.c 31;" d file: __FUNCT__ src/nep/interface/nepbasic.c 32;" d file: __FUNCT__ src/nep/interface/nepbasic.c 342;" d file: __FUNCT__ src/nep/interface/nepbasic.c 343;" d file: __FUNCT__ src/nep/interface/nepbasic.c 376;" d file: __FUNCT__ src/nep/interface/nepbasic.c 377;" d file: __FUNCT__ src/nep/interface/nepbasic.c 409;" d file: __FUNCT__ src/nep/interface/nepbasic.c 410;" d file: __FUNCT__ src/nep/interface/nepbasic.c 443;" d file: __FUNCT__ src/nep/interface/nepbasic.c 444;" d file: __FUNCT__ src/nep/interface/nepbasic.c 476;" d file: __FUNCT__ src/nep/interface/nepbasic.c 477;" d file: __FUNCT__ src/nep/interface/nepbasic.c 510;" d file: __FUNCT__ src/nep/interface/nepbasic.c 511;" d file: __FUNCT__ src/nep/interface/nepbasic.c 543;" d file: __FUNCT__ src/nep/interface/nepbasic.c 544;" d file: __FUNCT__ src/nep/interface/nepbasic.c 586;" d file: __FUNCT__ src/nep/interface/nepbasic.c 587;" d file: __FUNCT__ src/nep/interface/nepbasic.c 621;" d file: __FUNCT__ src/nep/interface/nepbasic.c 622;" d file: __FUNCT__ src/nep/interface/nepbasic.c 650;" d file: __FUNCT__ src/nep/interface/nepbasic.c 651;" d file: __FUNCT__ src/nep/interface/nepbasic.c 712;" d file: __FUNCT__ src/nep/interface/nepbasic.c 713;" d file: __FUNCT__ src/nep/interface/nepbasic.c 745;" d file: __FUNCT__ src/nep/interface/nepbasic.c 746;" d file: __FUNCT__ src/nep/interface/nepbasic.c 798;" d file: __FUNCT__ src/nep/interface/nepbasic.c 799;" d file: __FUNCT__ src/nep/interface/nepbasic.c 829;" d file: __FUNCT__ src/nep/interface/nepbasic.c 830;" d file: __FUNCT__ src/nep/interface/nepbasic.c 901;" d file: __FUNCT__ src/nep/interface/nepbasic.c 902;" d file: __FUNCT__ src/nep/interface/nepbasic.c 932;" d file: __FUNCT__ src/nep/interface/nepbasic.c 933;" d file: __FUNCT__ src/nep/interface/nepbasic.c 961;" d file: __FUNCT__ src/nep/interface/nepbasic.c 962;" d file: __FUNCT__ src/nep/interface/nepdefault.c 110;" d file: __FUNCT__ src/nep/interface/nepdefault.c 111;" d file: __FUNCT__ src/nep/interface/nepdefault.c 122;" d file: __FUNCT__ src/nep/interface/nepdefault.c 123;" d file: __FUNCT__ src/nep/interface/nepdefault.c 153;" d file: __FUNCT__ src/nep/interface/nepdefault.c 154;" d file: __FUNCT__ src/nep/interface/nepdefault.c 203;" d file: __FUNCT__ src/nep/interface/nepdefault.c 204;" d file: __FUNCT__ src/nep/interface/nepdefault.c 26;" d file: __FUNCT__ src/nep/interface/nepdefault.c 27;" d file: __FUNCT__ src/nep/interface/nepdefault.c 60;" d file: __FUNCT__ src/nep/interface/nepdefault.c 61;" d file: __FUNCT__ src/nep/interface/nepdefault.c 95;" d file: __FUNCT__ src/nep/interface/nepdefault.c 96;" d file: __FUNCT__ src/nep/interface/nepmon.c 105;" d file: __FUNCT__ src/nep/interface/nepmon.c 106;" d file: __FUNCT__ src/nep/interface/nepmon.c 140;" d file: __FUNCT__ src/nep/interface/nepmon.c 141;" d file: __FUNCT__ src/nep/interface/nepmon.c 166;" d file: __FUNCT__ src/nep/interface/nepmon.c 167;" d file: __FUNCT__ src/nep/interface/nepmon.c 222;" d file: __FUNCT__ src/nep/interface/nepmon.c 223;" d file: __FUNCT__ src/nep/interface/nepmon.c 276;" d file: __FUNCT__ src/nep/interface/nepmon.c 277;" d file: __FUNCT__ src/nep/interface/nepmon.c 27;" d file: __FUNCT__ src/nep/interface/nepmon.c 28;" d file: __FUNCT__ src/nep/interface/nepmon.c 335;" d file: __FUNCT__ src/nep/interface/nepmon.c 336;" d file: __FUNCT__ src/nep/interface/nepmon.c 381;" d file: __FUNCT__ src/nep/interface/nepmon.c 382;" d file: __FUNCT__ src/nep/interface/nepmon.c 407;" d file: __FUNCT__ src/nep/interface/nepmon.c 408;" d file: __FUNCT__ src/nep/interface/nepmon.c 44;" d file: __FUNCT__ src/nep/interface/nepmon.c 45;" d file: __FUNCT__ src/nep/interface/nepopts.c 1028;" d file: __FUNCT__ src/nep/interface/nepopts.c 1029;" d file: __FUNCT__ src/nep/interface/nepopts.c 106;" d file: __FUNCT__ src/nep/interface/nepopts.c 1072;" d file: __FUNCT__ src/nep/interface/nepopts.c 1073;" d file: __FUNCT__ src/nep/interface/nepopts.c 107;" d file: __FUNCT__ src/nep/interface/nepopts.c 1108;" d file: __FUNCT__ src/nep/interface/nepopts.c 1109;" d file: __FUNCT__ src/nep/interface/nepopts.c 271;" d file: __FUNCT__ src/nep/interface/nepopts.c 272;" d file: __FUNCT__ src/nep/interface/nepopts.c 28;" d file: __FUNCT__ src/nep/interface/nepopts.c 29;" d file: __FUNCT__ src/nep/interface/nepopts.c 302;" d file: __FUNCT__ src/nep/interface/nepopts.c 303;" d file: __FUNCT__ src/nep/interface/nepopts.c 349;" d file: __FUNCT__ src/nep/interface/nepopts.c 350;" d file: __FUNCT__ src/nep/interface/nepopts.c 382;" d file: __FUNCT__ src/nep/interface/nepopts.c 383;" d file: __FUNCT__ src/nep/interface/nepopts.c 443;" d file: __FUNCT__ src/nep/interface/nepopts.c 444;" d file: __FUNCT__ src/nep/interface/nepopts.c 527;" d file: __FUNCT__ src/nep/interface/nepopts.c 528;" d file: __FUNCT__ src/nep/interface/nepopts.c 557;" d file: __FUNCT__ src/nep/interface/nepopts.c 558;" d file: __FUNCT__ src/nep/interface/nepopts.c 600;" d file: __FUNCT__ src/nep/interface/nepopts.c 601;" d file: __FUNCT__ src/nep/interface/nepopts.c 651;" d file: __FUNCT__ src/nep/interface/nepopts.c 652;" d file: __FUNCT__ src/nep/interface/nepopts.c 696;" d file: __FUNCT__ src/nep/interface/nepopts.c 697;" d file: __FUNCT__ src/nep/interface/nepopts.c 69;" d file: __FUNCT__ src/nep/interface/nepopts.c 70;" d file: __FUNCT__ src/nep/interface/nepopts.c 723;" d file: __FUNCT__ src/nep/interface/nepopts.c 724;" d file: __FUNCT__ src/nep/interface/nepopts.c 775;" d file: __FUNCT__ src/nep/interface/nepopts.c 776;" d file: __FUNCT__ src/nep/interface/nepopts.c 815;" d file: __FUNCT__ src/nep/interface/nepopts.c 816;" d file: __FUNCT__ src/nep/interface/nepopts.c 842;" d file: __FUNCT__ src/nep/interface/nepopts.c 843;" d file: __FUNCT__ src/nep/interface/nepopts.c 875;" d file: __FUNCT__ src/nep/interface/nepopts.c 876;" d file: __FUNCT__ src/nep/interface/nepopts.c 902;" d file: __FUNCT__ src/nep/interface/nepopts.c 903;" d file: __FUNCT__ src/nep/interface/nepopts.c 991;" d file: __FUNCT__ src/nep/interface/nepopts.c 992;" d file: __FUNCT__ src/nep/interface/neprefine.c 143;" d file: __FUNCT__ src/nep/interface/neprefine.c 144;" d file: __FUNCT__ src/nep/interface/neprefine.c 186;" d file: __FUNCT__ src/nep/interface/neprefine.c 187;" d file: __FUNCT__ src/nep/interface/neprefine.c 212;" d file: __FUNCT__ src/nep/interface/neprefine.c 213;" d file: __FUNCT__ src/nep/interface/neprefine.c 389;" d file: __FUNCT__ src/nep/interface/neprefine.c 390;" d file: __FUNCT__ src/nep/interface/neprefine.c 43;" d file: __FUNCT__ src/nep/interface/neprefine.c 44;" d file: __FUNCT__ src/nep/interface/neprefine.c 60;" d file: __FUNCT__ src/nep/interface/neprefine.c 61;" d file: __FUNCT__ src/nep/interface/nepregis.c 31;" d file: __FUNCT__ src/nep/interface/nepregis.c 32;" d file: __FUNCT__ src/nep/interface/nepsetup.c 220;" d file: __FUNCT__ src/nep/interface/nepsetup.c 221;" d file: __FUNCT__ src/nep/interface/nepsetup.c 261;" d file: __FUNCT__ src/nep/interface/nepsetup.c 262;" d file: __FUNCT__ src/nep/interface/nepsetup.c 26;" d file: __FUNCT__ src/nep/interface/nepsetup.c 27;" d file: __FUNCT__ src/nep/interface/nepsetup.c 285;" d file: __FUNCT__ src/nep/interface/nepsetup.c 286;" d file: __FUNCT__ src/nep/interface/nepsolve.c 119;" d file: __FUNCT__ src/nep/interface/nepsolve.c 120;" d file: __FUNCT__ src/nep/interface/nepsolve.c 166;" d file: __FUNCT__ src/nep/interface/nepsolve.c 167;" d file: __FUNCT__ src/nep/interface/nepsolve.c 224;" d file: __FUNCT__ src/nep/interface/nepsolve.c 225;" d file: __FUNCT__ src/nep/interface/nepsolve.c 27;" d file: __FUNCT__ src/nep/interface/nepsolve.c 280;" d file: __FUNCT__ src/nep/interface/nepsolve.c 281;" d file: __FUNCT__ src/nep/interface/nepsolve.c 28;" d file: __FUNCT__ src/nep/interface/nepsolve.c 315;" d file: __FUNCT__ src/nep/interface/nepsolve.c 316;" d file: __FUNCT__ src/nep/interface/nepsolve.c 345;" d file: __FUNCT__ src/nep/interface/nepsolve.c 346;" d file: __FUNCT__ src/nep/interface/nepsolve.c 384;" d file: __FUNCT__ src/nep/interface/nepsolve.c 385;" d file: __FUNCT__ src/nep/interface/nepsolve.c 467;" d file: __FUNCT__ src/nep/interface/nepsolve.c 468;" d file: __FUNCT__ src/nep/interface/nepsolve.c 48;" d file: __FUNCT__ src/nep/interface/nepsolve.c 49;" d file: __FUNCT__ src/nep/interface/nepsolve.c 501;" d file: __FUNCT__ src/nep/interface/nepsolve.c 502;" d file: __FUNCT__ src/nep/interface/nepsolve.c 525;" d file: __FUNCT__ src/nep/interface/nepsolve.c 526;" d file: __FUNCT__ src/nep/interface/nepsolve.c 623;" d file: __FUNCT__ src/nep/interface/nepsolve.c 624;" d file: __FUNCT__ src/nep/interface/nepsolve.c 685;" d file: __FUNCT__ src/nep/interface/nepsolve.c 686;" d file: __FUNCT__ src/nep/interface/nepview.c 190;" d file: __FUNCT__ src/nep/interface/nepview.c 191;" d file: __FUNCT__ src/nep/interface/nepview.c 227;" d file: __FUNCT__ src/nep/interface/nepview.c 228;" d file: __FUNCT__ src/nep/interface/nepview.c 262;" d file: __FUNCT__ src/nep/interface/nepview.c 263;" d file: __FUNCT__ src/nep/interface/nepview.c 27;" d file: __FUNCT__ src/nep/interface/nepview.c 28;" d file: __FUNCT__ src/nep/interface/nepview.c 317;" d file: __FUNCT__ src/nep/interface/nepview.c 318;" d file: __FUNCT__ src/nep/interface/nepview.c 362;" d file: __FUNCT__ src/nep/interface/nepview.c 363;" d file: __FUNCT__ src/nep/interface/nepview.c 382;" d file: __FUNCT__ src/nep/interface/nepview.c 383;" d file: __FUNCT__ src/nep/interface/nepview.c 443;" d file: __FUNCT__ src/nep/interface/nepview.c 444;" d file: __FUNCT__ src/nep/interface/nepview.c 492;" d file: __FUNCT__ src/nep/interface/nepview.c 493;" d file: __FUNCT__ src/nep/interface/nepview.c 525;" d file: __FUNCT__ src/nep/interface/nepview.c 526;" d file: __FUNCT__ src/nep/interface/nepview.c 556;" d file: __FUNCT__ src/nep/interface/nepview.c 557;" d file: __FUNCT__ src/nep/interface/nepview.c 587;" d file: __FUNCT__ src/nep/interface/nepview.c 588;" d file: __FUNCT__ src/nep/interface/nepview.c 639;" d file: __FUNCT__ src/nep/interface/nepview.c 640;" d file: __FUNCT__ src/nep/interface/nepview.c 674;" d file: __FUNCT__ src/nep/interface/nepview.c 675;" d file: __FUNCT__ src/nep/interface/nepview.c 727;" d file: __FUNCT__ src/nep/interface/nepview.c 728;" d file: __FUNCT__ src/pep/examples/nlevp/acoustic_wave_1d.c 42;" d file: __FUNCT__ src/pep/examples/nlevp/acoustic_wave_1d.c 43;" d file: __FUNCT__ src/pep/examples/nlevp/acoustic_wave_2d.c 40;" d file: __FUNCT__ src/pep/examples/nlevp/acoustic_wave_2d.c 41;" d file: __FUNCT__ src/pep/examples/nlevp/butterfly.c 41;" d file: __FUNCT__ src/pep/examples/nlevp/butterfly.c 42;" d file: __FUNCT__ src/pep/examples/nlevp/damped_beam.c 39;" d file: __FUNCT__ src/pep/examples/nlevp/damped_beam.c 40;" d file: __FUNCT__ src/pep/examples/nlevp/pdde_stability.c 43;" d file: __FUNCT__ src/pep/examples/nlevp/pdde_stability.c 44;" d file: __FUNCT__ src/pep/examples/nlevp/pdde_stability.c 63;" d file: __FUNCT__ src/pep/examples/nlevp/pdde_stability.c 64;" d file: __FUNCT__ src/pep/examples/nlevp/planar_waveguide.c 43;" d file: __FUNCT__ src/pep/examples/nlevp/planar_waveguide.c 44;" d file: __FUNCT__ src/pep/examples/nlevp/sleeper.c 39;" d file: __FUNCT__ src/pep/examples/nlevp/sleeper.c 40;" d file: __FUNCT__ src/pep/examples/nlevp/spring.c 45;" d file: __FUNCT__ src/pep/examples/nlevp/spring.c 46;" d file: __FUNCT__ src/pep/examples/tests/test1.c 31;" d file: __FUNCT__ src/pep/examples/tests/test1.c 32;" d file: __FUNCT__ src/pep/examples/tests/test2.c 41;" d file: __FUNCT__ src/pep/examples/tests/test2.c 42;" d file: __FUNCT__ src/pep/examples/tests/test3.c 26;" d file: __FUNCT__ src/pep/examples/tests/test3.c 27;" d file: __FUNCT__ src/pep/examples/tutorials/ex16.c 29;" d file: __FUNCT__ src/pep/examples/tutorials/ex16.c 30;" d file: __FUNCT__ src/pep/examples/tutorials/ex17.c 30;" d file: __FUNCT__ src/pep/examples/tutorials/ex17.c 31;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 162;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 163;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 212;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 213;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 223;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 224;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 237;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 238;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 248;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 249;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 262;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 263;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 38;" d file: __FUNCT__ src/pep/examples/tutorials/ex28.c 39;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 1042;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 1043;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 1067;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 1068;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 1080;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 1081;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 141;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 142;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 211;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 212;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 271;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 272;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 333;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 334;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 360;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 361;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 402;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 403;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 478;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 479;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 47;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 48;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 514;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 515;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 593;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 594;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 638;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 639;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 707;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 708;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 735;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 736;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 773;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 774;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 82;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 83;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 855;" d file: __FUNCT__ src/pep/impls/jd/pjd.c 856;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 115;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 116;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 146;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 147;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 27;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 28;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 42;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 43;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 76;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 77;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 87;" d file: __FUNCT__ src/pep/impls/jd/pjdopt.c 88;" d file: __FUNCT__ src/pep/impls/krylov/pepkrylov.c 183;" d file: __FUNCT__ src/pep/impls/krylov/pepkrylov.c 184;" d file: __FUNCT__ src/pep/impls/krylov/pepkrylov.c 28;" d file: __FUNCT__ src/pep/impls/krylov/pepkrylov.c 29;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 104;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 105;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 132;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 133;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 177;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 178;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 255;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 256;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 355;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 356;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 370;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 371;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 404;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 405;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 415;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 416;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 443;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 444;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 454;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 455;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 45;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 46;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 492;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 493;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 503;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 504;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 531;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 532;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 553;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 554;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 570;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 571;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 585;" d file: __FUNCT__ src/pep/impls/krylov/qarnoldi/qarnoldi.c 586;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 121;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 122;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 198;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 199;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 246;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 247;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 321;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 322;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 397;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 398;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 460;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 461;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 54;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 55;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 601;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 602;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 618;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 619;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 629;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 630;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 665;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 666;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 676;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 677;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 704;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 705;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 720;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 721;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 733;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 734;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 85;" d file: __FUNCT__ src/pep/impls/krylov/stoar/stoar.c 86;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1029;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1030;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1092;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1093;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1310;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1311;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1401;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1402;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 142;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1433;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 1434;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 143;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 250;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 251;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 285;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 286;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 376;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 377;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 439;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 440;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 572;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 573;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 62;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 63;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 719;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 720;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 762;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 763;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 874;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 875;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 92;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 93;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 965;" d file: __FUNCT__ src/pep/impls/krylov/toar/nrefine.c 966;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1000;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1027;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1028;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1038;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1039;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1074;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1075;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1085;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1086;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1113;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1114;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1135;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1136;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1152;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1153;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1167;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 1168;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 152;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 153;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 205;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 206;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 291;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 292;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 320;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 321;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 377;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 378;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 524;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 525;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 555;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 556;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 57;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 589;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 58;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 590;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 73;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 74;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 765;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 766;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 939;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 940;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 954;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 955;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 988;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 989;" d file: __FUNCT__ src/pep/impls/krylov/toar/ptoar.c 999;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1015;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1016;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1044;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1045;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1065;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1066;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1085;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1086;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1104;" d file: __FUNCT__ src/pep/impls/linear/linear.c 1105;" d file: __FUNCT__ src/pep/impls/linear/linear.c 111;" d file: __FUNCT__ src/pep/impls/linear/linear.c 112;" d file: __FUNCT__ src/pep/impls/linear/linear.c 227;" d file: __FUNCT__ src/pep/impls/linear/linear.c 228;" d file: __FUNCT__ src/pep/impls/linear/linear.c 242;" d file: __FUNCT__ src/pep/impls/linear/linear.c 243;" d file: __FUNCT__ src/pep/impls/linear/linear.c 255;" d file: __FUNCT__ src/pep/impls/linear/linear.c 256;" d file: __FUNCT__ src/pep/impls/linear/linear.c 27;" d file: __FUNCT__ src/pep/impls/linear/linear.c 28;" d file: __FUNCT__ src/pep/impls/linear/linear.c 455;" d file: __FUNCT__ src/pep/impls/linear/linear.c 456;" d file: __FUNCT__ src/pep/impls/linear/linear.c 555;" d file: __FUNCT__ src/pep/impls/linear/linear.c 556;" d file: __FUNCT__ src/pep/impls/linear/linear.c 608;" d file: __FUNCT__ src/pep/impls/linear/linear.c 609;" d file: __FUNCT__ src/pep/impls/linear/linear.c 673;" d file: __FUNCT__ src/pep/impls/linear/linear.c 674;" d file: __FUNCT__ src/pep/impls/linear/linear.c 697;" d file: __FUNCT__ src/pep/impls/linear/linear.c 698;" d file: __FUNCT__ src/pep/impls/linear/linear.c 744;" d file: __FUNCT__ src/pep/impls/linear/linear.c 745;" d file: __FUNCT__ src/pep/impls/linear/linear.c 756;" d file: __FUNCT__ src/pep/impls/linear/linear.c 757;" d file: __FUNCT__ src/pep/impls/linear/linear.c 781;" d file: __FUNCT__ src/pep/impls/linear/linear.c 782;" d file: __FUNCT__ src/pep/impls/linear/linear.c 797;" d file: __FUNCT__ src/pep/impls/linear/linear.c 798;" d file: __FUNCT__ src/pep/impls/linear/linear.c 827;" d file: __FUNCT__ src/pep/impls/linear/linear.c 828;" d file: __FUNCT__ src/pep/impls/linear/linear.c 838;" d file: __FUNCT__ src/pep/impls/linear/linear.c 839;" d file: __FUNCT__ src/pep/impls/linear/linear.c 867;" d file: __FUNCT__ src/pep/impls/linear/linear.c 868;" d file: __FUNCT__ src/pep/impls/linear/linear.c 878;" d file: __FUNCT__ src/pep/impls/linear/linear.c 879;" d file: __FUNCT__ src/pep/impls/linear/linear.c 908;" d file: __FUNCT__ src/pep/impls/linear/linear.c 909;" d file: __FUNCT__ src/pep/impls/linear/linear.c 919;" d file: __FUNCT__ src/pep/impls/linear/linear.c 920;" d file: __FUNCT__ src/pep/impls/linear/linear.c 948;" d file: __FUNCT__ src/pep/impls/linear/linear.c 949;" d file: __FUNCT__ src/pep/impls/linear/linear.c 964;" d file: __FUNCT__ src/pep/impls/linear/linear.c 965;" d file: __FUNCT__ src/pep/impls/linear/linear.c 992;" d file: __FUNCT__ src/pep/impls/linear/linear.c 993;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 114;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 115;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 140;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 141;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 168;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 169;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 179;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 180;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 192;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 193;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 203;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 204;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 216;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 217;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 227;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 228;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 240;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 241;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 251;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 252;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 60;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 61;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 86;" d file: __FUNCT__ src/pep/impls/linear/qeplin.c 87;" d file: __FUNCT__ src/pep/interface/dlregispep.c 107;" d file: __FUNCT__ src/pep/interface/dlregispep.c 108;" d file: __FUNCT__ src/pep/interface/dlregispep.c 35;" d file: __FUNCT__ src/pep/interface/dlregispep.c 36;" d file: __FUNCT__ src/pep/interface/dlregispep.c 56;" d file: __FUNCT__ src/pep/interface/dlregispep.c 57;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 112;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 113;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 119;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 120;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 127;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 128;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 134;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 135;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 142;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 143;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 149;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 150;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 157;" d file: __FUNCT__ src/pep/interface/ftn-custom/zpepf.c 158;" d file: __FUNCT__ src/pep/interface/pepbasic.c 131;" d file: __FUNCT__ src/pep/interface/pepbasic.c 132;" d file: __FUNCT__ src/pep/interface/pepbasic.c 186;" d file: __FUNCT__ src/pep/interface/pepbasic.c 187;" d file: __FUNCT__ src/pep/interface/pepbasic.c 212;" d file: __FUNCT__ src/pep/interface/pepbasic.c 213;" d file: __FUNCT__ src/pep/interface/pepbasic.c 249;" d file: __FUNCT__ src/pep/interface/pepbasic.c 250;" d file: __FUNCT__ src/pep/interface/pepbasic.c 295;" d file: __FUNCT__ src/pep/interface/pepbasic.c 296;" d file: __FUNCT__ src/pep/interface/pepbasic.c 31;" d file: __FUNCT__ src/pep/interface/pepbasic.c 32;" d file: __FUNCT__ src/pep/interface/pepbasic.c 333;" d file: __FUNCT__ src/pep/interface/pepbasic.c 334;" d file: __FUNCT__ src/pep/interface/pepbasic.c 367;" d file: __FUNCT__ src/pep/interface/pepbasic.c 368;" d file: __FUNCT__ src/pep/interface/pepbasic.c 400;" d file: __FUNCT__ src/pep/interface/pepbasic.c 401;" d file: __FUNCT__ src/pep/interface/pepbasic.c 434;" d file: __FUNCT__ src/pep/interface/pepbasic.c 435;" d file: __FUNCT__ src/pep/interface/pepbasic.c 467;" d file: __FUNCT__ src/pep/interface/pepbasic.c 468;" d file: __FUNCT__ src/pep/interface/pepbasic.c 501;" d file: __FUNCT__ src/pep/interface/pepbasic.c 502;" d file: __FUNCT__ src/pep/interface/pepbasic.c 534;" d file: __FUNCT__ src/pep/interface/pepbasic.c 535;" d file: __FUNCT__ src/pep/interface/pepbasic.c 568;" d file: __FUNCT__ src/pep/interface/pepbasic.c 569;" d file: __FUNCT__ src/pep/interface/pepbasic.c 601;" d file: __FUNCT__ src/pep/interface/pepbasic.c 602;" d file: __FUNCT__ src/pep/interface/pepbasic.c 643;" d file: __FUNCT__ src/pep/interface/pepbasic.c 644;" d file: __FUNCT__ src/pep/interface/pepbasic.c 682;" d file: __FUNCT__ src/pep/interface/pepbasic.c 683;" d file: __FUNCT__ src/pep/interface/pepdefault.c 104;" d file: __FUNCT__ src/pep/interface/pepdefault.c 105;" d file: __FUNCT__ src/pep/interface/pepdefault.c 116;" d file: __FUNCT__ src/pep/interface/pepdefault.c 117;" d file: __FUNCT__ src/pep/interface/pepdefault.c 166;" d file: __FUNCT__ src/pep/interface/pepdefault.c 167;" d file: __FUNCT__ src/pep/interface/pepdefault.c 177;" d file: __FUNCT__ src/pep/interface/pepdefault.c 178;" d file: __FUNCT__ src/pep/interface/pepdefault.c 221;" d file: __FUNCT__ src/pep/interface/pepdefault.c 222;" d file: __FUNCT__ src/pep/interface/pepdefault.c 26;" d file: __FUNCT__ src/pep/interface/pepdefault.c 273;" d file: __FUNCT__ src/pep/interface/pepdefault.c 274;" d file: __FUNCT__ src/pep/interface/pepdefault.c 27;" d file: __FUNCT__ src/pep/interface/pepdefault.c 425;" d file: __FUNCT__ src/pep/interface/pepdefault.c 426;" d file: __FUNCT__ src/pep/interface/pepdefault.c 484;" d file: __FUNCT__ src/pep/interface/pepdefault.c 485;" d file: __FUNCT__ src/pep/interface/pepdefault.c 540;" d file: __FUNCT__ src/pep/interface/pepdefault.c 541;" d file: __FUNCT__ src/pep/interface/pepdefault.c 60;" d file: __FUNCT__ src/pep/interface/pepdefault.c 61;" d file: __FUNCT__ src/pep/interface/pepdefault.c 75;" d file: __FUNCT__ src/pep/interface/pepdefault.c 76;" d file: __FUNCT__ src/pep/interface/pepmon.c 104;" d file: __FUNCT__ src/pep/interface/pepmon.c 105;" d file: __FUNCT__ src/pep/interface/pepmon.c 139;" d file: __FUNCT__ src/pep/interface/pepmon.c 140;" d file: __FUNCT__ src/pep/interface/pepmon.c 165;" d file: __FUNCT__ src/pep/interface/pepmon.c 166;" d file: __FUNCT__ src/pep/interface/pepmon.c 187;" d file: __FUNCT__ src/pep/interface/pepmon.c 188;" d file: __FUNCT__ src/pep/interface/pepmon.c 246;" d file: __FUNCT__ src/pep/interface/pepmon.c 247;" d file: __FUNCT__ src/pep/interface/pepmon.c 27;" d file: __FUNCT__ src/pep/interface/pepmon.c 28;" d file: __FUNCT__ src/pep/interface/pepmon.c 303;" d file: __FUNCT__ src/pep/interface/pepmon.c 304;" d file: __FUNCT__ src/pep/interface/pepmon.c 365;" d file: __FUNCT__ src/pep/interface/pepmon.c 366;" d file: __FUNCT__ src/pep/interface/pepmon.c 411;" d file: __FUNCT__ src/pep/interface/pepmon.c 412;" d file: __FUNCT__ src/pep/interface/pepmon.c 437;" d file: __FUNCT__ src/pep/interface/pepmon.c 438;" d file: __FUNCT__ src/pep/interface/pepmon.c 44;" d file: __FUNCT__ src/pep/interface/pepmon.c 45;" d file: __FUNCT__ src/pep/interface/pepopts.c 1028;" d file: __FUNCT__ src/pep/interface/pepopts.c 1029;" d file: __FUNCT__ src/pep/interface/pepopts.c 1055;" d file: __FUNCT__ src/pep/interface/pepopts.c 1056;" d file: __FUNCT__ src/pep/interface/pepopts.c 106;" d file: __FUNCT__ src/pep/interface/pepopts.c 107;" d file: __FUNCT__ src/pep/interface/pepopts.c 1146;" d file: __FUNCT__ src/pep/interface/pepopts.c 1147;" d file: __FUNCT__ src/pep/interface/pepopts.c 1188;" d file: __FUNCT__ src/pep/interface/pepopts.c 1189;" d file: __FUNCT__ src/pep/interface/pepopts.c 1215;" d file: __FUNCT__ src/pep/interface/pepopts.c 1216;" d file: __FUNCT__ src/pep/interface/pepopts.c 1240;" d file: __FUNCT__ src/pep/interface/pepopts.c 1241;" d file: __FUNCT__ src/pep/interface/pepopts.c 1333;" d file: __FUNCT__ src/pep/interface/pepopts.c 1334;" d file: __FUNCT__ src/pep/interface/pepopts.c 1370;" d file: __FUNCT__ src/pep/interface/pepopts.c 1371;" d file: __FUNCT__ src/pep/interface/pepopts.c 1416;" d file: __FUNCT__ src/pep/interface/pepopts.c 1417;" d file: __FUNCT__ src/pep/interface/pepopts.c 1462;" d file: __FUNCT__ src/pep/interface/pepopts.c 1463;" d file: __FUNCT__ src/pep/interface/pepopts.c 28;" d file: __FUNCT__ src/pep/interface/pepopts.c 295;" d file: __FUNCT__ src/pep/interface/pepopts.c 296;" d file: __FUNCT__ src/pep/interface/pepopts.c 29;" d file: __FUNCT__ src/pep/interface/pepopts.c 326;" d file: __FUNCT__ src/pep/interface/pepopts.c 327;" d file: __FUNCT__ src/pep/interface/pepopts.c 373;" d file: __FUNCT__ src/pep/interface/pepopts.c 374;" d file: __FUNCT__ src/pep/interface/pepopts.c 406;" d file: __FUNCT__ src/pep/interface/pepopts.c 407;" d file: __FUNCT__ src/pep/interface/pepopts.c 467;" d file: __FUNCT__ src/pep/interface/pepopts.c 468;" d file: __FUNCT__ src/pep/interface/pepopts.c 548;" d file: __FUNCT__ src/pep/interface/pepopts.c 549;" d file: __FUNCT__ src/pep/interface/pepopts.c 578;" d file: __FUNCT__ src/pep/interface/pepopts.c 579;" d file: __FUNCT__ src/pep/interface/pepopts.c 621;" d file: __FUNCT__ src/pep/interface/pepopts.c 622;" d file: __FUNCT__ src/pep/interface/pepopts.c 665;" d file: __FUNCT__ src/pep/interface/pepopts.c 666;" d file: __FUNCT__ src/pep/interface/pepopts.c 691;" d file: __FUNCT__ src/pep/interface/pepopts.c 692;" d file: __FUNCT__ src/pep/interface/pepopts.c 69;" d file: __FUNCT__ src/pep/interface/pepopts.c 70;" d file: __FUNCT__ src/pep/interface/pepopts.c 726;" d file: __FUNCT__ src/pep/interface/pepopts.c 727;" d file: __FUNCT__ src/pep/interface/pepopts.c 752;" d file: __FUNCT__ src/pep/interface/pepopts.c 753;" d file: __FUNCT__ src/pep/interface/pepopts.c 785;" d file: __FUNCT__ src/pep/interface/pepopts.c 786;" d file: __FUNCT__ src/pep/interface/pepopts.c 812;" d file: __FUNCT__ src/pep/interface/pepopts.c 813;" d file: __FUNCT__ src/pep/interface/pepopts.c 863;" d file: __FUNCT__ src/pep/interface/pepopts.c 864;" d file: __FUNCT__ src/pep/interface/pepopts.c 909;" d file: __FUNCT__ src/pep/interface/pepopts.c 910;" d file: __FUNCT__ src/pep/interface/pepopts.c 936;" d file: __FUNCT__ src/pep/interface/pepopts.c 937;" d file: __FUNCT__ src/pep/interface/pepopts.c 988;" d file: __FUNCT__ src/pep/interface/pepopts.c 989;" d file: __FUNCT__ src/pep/interface/peprefine.c 135;" d file: __FUNCT__ src/pep/interface/peprefine.c 136;" d file: __FUNCT__ src/pep/interface/peprefine.c 178;" d file: __FUNCT__ src/pep/interface/peprefine.c 179;" d file: __FUNCT__ src/pep/interface/peprefine.c 204;" d file: __FUNCT__ src/pep/interface/peprefine.c 205;" d file: __FUNCT__ src/pep/interface/peprefine.c 225;" d file: __FUNCT__ src/pep/interface/peprefine.c 226;" d file: __FUNCT__ src/pep/interface/peprefine.c 396;" d file: __FUNCT__ src/pep/interface/peprefine.c 397;" d file: __FUNCT__ src/pep/interface/peprefine.c 41;" d file: __FUNCT__ src/pep/interface/peprefine.c 42;" d file: __FUNCT__ src/pep/interface/peprefine.c 58;" d file: __FUNCT__ src/pep/interface/peprefine.c 59;" d file: __FUNCT__ src/pep/interface/pepregis.c 30;" d file: __FUNCT__ src/pep/interface/pepregis.c 31;" d file: __FUNCT__ src/pep/interface/pepsetup.c 227;" d file: __FUNCT__ src/pep/interface/pepsetup.c 228;" d file: __FUNCT__ src/pep/interface/pepsetup.c 26;" d file: __FUNCT__ src/pep/interface/pepsetup.c 27;" d file: __FUNCT__ src/pep/interface/pepsetup.c 281;" d file: __FUNCT__ src/pep/interface/pepsetup.c 282;" d file: __FUNCT__ src/pep/interface/pepsetup.c 309;" d file: __FUNCT__ src/pep/interface/pepsetup.c 310;" d file: __FUNCT__ src/pep/interface/pepsetup.c 335;" d file: __FUNCT__ src/pep/interface/pepsetup.c 336;" d file: __FUNCT__ src/pep/interface/pepsetup.c 376;" d file: __FUNCT__ src/pep/interface/pepsetup.c 377;" d file: __FUNCT__ src/pep/interface/pepsetup.c 410;" d file: __FUNCT__ src/pep/interface/pepsetup.c 411;" d file: __FUNCT__ src/pep/interface/pepsolve.c 194;" d file: __FUNCT__ src/pep/interface/pepsolve.c 195;" d file: __FUNCT__ src/pep/interface/pepsolve.c 229;" d file: __FUNCT__ src/pep/interface/pepsolve.c 230;" d file: __FUNCT__ src/pep/interface/pepsolve.c 259;" d file: __FUNCT__ src/pep/interface/pepsolve.c 260;" d file: __FUNCT__ src/pep/interface/pepsolve.c 298;" d file: __FUNCT__ src/pep/interface/pepsolve.c 299;" d file: __FUNCT__ src/pep/interface/pepsolve.c 381;" d file: __FUNCT__ src/pep/interface/pepsolve.c 382;" d file: __FUNCT__ src/pep/interface/pepsolve.c 40;" d file: __FUNCT__ src/pep/interface/pepsolve.c 416;" d file: __FUNCT__ src/pep/interface/pepsolve.c 417;" d file: __FUNCT__ src/pep/interface/pepsolve.c 41;" d file: __FUNCT__ src/pep/interface/pepsolve.c 502;" d file: __FUNCT__ src/pep/interface/pepsolve.c 503;" d file: __FUNCT__ src/pep/interface/pepsolve.c 61;" d file: __FUNCT__ src/pep/interface/pepsolve.c 62;" d file: __FUNCT__ src/pep/interface/pepsolve.c 82;" d file: __FUNCT__ src/pep/interface/pepsolve.c 83;" d file: __FUNCT__ src/pep/interface/pepview.c 215;" d file: __FUNCT__ src/pep/interface/pepview.c 216;" d file: __FUNCT__ src/pep/interface/pepview.c 252;" d file: __FUNCT__ src/pep/interface/pepview.c 253;" d file: __FUNCT__ src/pep/interface/pepview.c 27;" d file: __FUNCT__ src/pep/interface/pepview.c 287;" d file: __FUNCT__ src/pep/interface/pepview.c 288;" d file: __FUNCT__ src/pep/interface/pepview.c 28;" d file: __FUNCT__ src/pep/interface/pepview.c 337;" d file: __FUNCT__ src/pep/interface/pepview.c 338;" d file: __FUNCT__ src/pep/interface/pepview.c 382;" d file: __FUNCT__ src/pep/interface/pepview.c 383;" d file: __FUNCT__ src/pep/interface/pepview.c 402;" d file: __FUNCT__ src/pep/interface/pepview.c 403;" d file: __FUNCT__ src/pep/interface/pepview.c 463;" d file: __FUNCT__ src/pep/interface/pepview.c 464;" d file: __FUNCT__ src/pep/interface/pepview.c 512;" d file: __FUNCT__ src/pep/interface/pepview.c 513;" d file: __FUNCT__ src/pep/interface/pepview.c 545;" d file: __FUNCT__ src/pep/interface/pepview.c 546;" d file: __FUNCT__ src/pep/interface/pepview.c 576;" d file: __FUNCT__ src/pep/interface/pepview.c 577;" d file: __FUNCT__ src/pep/interface/pepview.c 607;" d file: __FUNCT__ src/pep/interface/pepview.c 608;" d file: __FUNCT__ src/pep/interface/pepview.c 659;" d file: __FUNCT__ src/pep/interface/pepview.c 660;" d file: __FUNCT__ src/pep/interface/pepview.c 694;" d file: __FUNCT__ src/pep/interface/pepview.c 695;" d file: __FUNCT__ src/pep/interface/pepview.c 747;" d file: __FUNCT__ src/pep/interface/pepview.c 748;" d file: __FUNCT__ src/svd/examples/tests/test1.c 45;" d file: __FUNCT__ src/svd/examples/tests/test1.c 46;" d file: __FUNCT__ src/svd/examples/tests/test2.c 27;" d file: __FUNCT__ src/svd/examples/tests/test2.c 28;" d file: __FUNCT__ src/svd/examples/tests/test3.c 42;" d file: __FUNCT__ src/svd/examples/tests/test3.c 43;" d file: __FUNCT__ src/svd/examples/tutorials/ex14.c 29;" d file: __FUNCT__ src/svd/examples/tutorials/ex14.c 30;" d file: __FUNCT__ src/svd/examples/tutorials/ex15.c 29;" d file: __FUNCT__ src/svd/examples/tutorials/ex15.c 30;" d file: __FUNCT__ src/svd/examples/tutorials/ex8.c 45;" d file: __FUNCT__ src/svd/examples/tutorials/ex8.c 46;" d file: __FUNCT__ src/svd/impls/cross/cross.c 122;" d file: __FUNCT__ src/svd/impls/cross/cross.c 123;" d file: __FUNCT__ src/svd/impls/cross/cross.c 175;" d file: __FUNCT__ src/svd/impls/cross/cross.c 176;" d file: __FUNCT__ src/svd/impls/cross/cross.c 200;" d file: __FUNCT__ src/svd/impls/cross/cross.c 201;" d file: __FUNCT__ src/svd/impls/cross/cross.c 220;" d file: __FUNCT__ src/svd/impls/cross/cross.c 221;" d file: __FUNCT__ src/svd/impls/cross/cross.c 235;" d file: __FUNCT__ src/svd/impls/cross/cross.c 236;" d file: __FUNCT__ src/svd/impls/cross/cross.c 251;" d file: __FUNCT__ src/svd/impls/cross/cross.c 252;" d file: __FUNCT__ src/svd/impls/cross/cross.c 279;" d file: __FUNCT__ src/svd/impls/cross/cross.c 280;" d file: __FUNCT__ src/svd/impls/cross/cross.c 303;" d file: __FUNCT__ src/svd/impls/cross/cross.c 304;" d file: __FUNCT__ src/svd/impls/cross/cross.c 332;" d file: __FUNCT__ src/svd/impls/cross/cross.c 333;" d file: __FUNCT__ src/svd/impls/cross/cross.c 351;" d file: __FUNCT__ src/svd/impls/cross/cross.c 352;" d file: __FUNCT__ src/svd/impls/cross/cross.c 366;" d file: __FUNCT__ src/svd/impls/cross/cross.c 367;" d file: __FUNCT__ src/svd/impls/cross/cross.c 36;" d file: __FUNCT__ src/svd/impls/cross/cross.c 37;" d file: __FUNCT__ src/svd/impls/cross/cross.c 381;" d file: __FUNCT__ src/svd/impls/cross/cross.c 382;" d file: __FUNCT__ src/svd/impls/cross/cross.c 52;" d file: __FUNCT__ src/svd/impls/cross/cross.c 53;" d file: __FUNCT__ src/svd/impls/cross/cross.c 70;" d file: __FUNCT__ src/svd/impls/cross/cross.c 71;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 214;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 215;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 261;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 262;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 287;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 288;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 313;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 314;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 324;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 325;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 354;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 355;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 365;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 366;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 37;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 38;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 393;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 394;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 409;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 410;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 437;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 438;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 458;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 459;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 487;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 488;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 507;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 508;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 524;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 525;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 541;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 542;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 69;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 70;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 80;" d file: __FUNCT__ src/svd/impls/cyclic/cyclic.c 81;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 113;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 114;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 179;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 180;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 284;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 285;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 302;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 303;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 316;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 317;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 352;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 353;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 363;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 364;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 392;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 393;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 405;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 406;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 421;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 422;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 48;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 49;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 69;" d file: __FUNCT__ src/svd/impls/lanczos/gklanczos.c 70;" d file: __FUNCT__ src/svd/impls/lapack/svdlapack.c 109;" d file: __FUNCT__ src/svd/impls/lapack/svdlapack.c 110;" d file: __FUNCT__ src/svd/impls/lapack/svdlapack.c 26;" d file: __FUNCT__ src/svd/impls/lapack/svdlapack.c 27;" d file: __FUNCT__ src/svd/impls/lapack/svdlapack.c 46;" d file: __FUNCT__ src/svd/impls/lapack/svdlapack.c 47;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 135;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 136;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 181;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 182;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 280;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 281;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 398;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 399;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 416;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 417;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 427;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 428;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 462;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 463;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 473;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 474;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 502;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 503;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 515;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 516;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 531;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 532;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 59;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 60;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 79;" d file: __FUNCT__ src/svd/impls/trlanczos/trlanczos.c 80;" d file: __FUNCT__ src/svd/interface/dlregissvd.c 101;" d file: __FUNCT__ src/svd/interface/dlregissvd.c 102;" d file: __FUNCT__ src/svd/interface/dlregissvd.c 30;" d file: __FUNCT__ src/svd/interface/dlregissvd.c 31;" d file: __FUNCT__ src/svd/interface/dlregissvd.c 51;" d file: __FUNCT__ src/svd/interface/dlregissvd.c 52;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 109;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 110;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 116;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 117;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 124;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 125;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 131;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 132;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 139;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 140;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 146;" d file: __FUNCT__ src/svd/interface/ftn-custom/zsvdf.c 147;" d file: __FUNCT__ src/svd/interface/svdbasic.c 107;" d file: __FUNCT__ src/svd/interface/svdbasic.c 108;" d file: __FUNCT__ src/svd/interface/svdbasic.c 144;" d file: __FUNCT__ src/svd/interface/svdbasic.c 145;" d file: __FUNCT__ src/svd/interface/svdbasic.c 178;" d file: __FUNCT__ src/svd/interface/svdbasic.c 179;" d file: __FUNCT__ src/svd/interface/svdbasic.c 233;" d file: __FUNCT__ src/svd/interface/svdbasic.c 234;" d file: __FUNCT__ src/svd/interface/svdbasic.c 259;" d file: __FUNCT__ src/svd/interface/svdbasic.c 260;" d file: __FUNCT__ src/svd/interface/svdbasic.c 296;" d file: __FUNCT__ src/svd/interface/svdbasic.c 297;" d file: __FUNCT__ src/svd/interface/svdbasic.c 31;" d file: __FUNCT__ src/svd/interface/svdbasic.c 32;" d file: __FUNCT__ src/svd/interface/svdbasic.c 341;" d file: __FUNCT__ src/svd/interface/svdbasic.c 342;" d file: __FUNCT__ src/svd/interface/svdbasic.c 383;" d file: __FUNCT__ src/svd/interface/svdbasic.c 384;" d file: __FUNCT__ src/svd/interface/svdbasic.c 417;" d file: __FUNCT__ src/svd/interface/svdbasic.c 418;" d file: __FUNCT__ src/svd/interface/svddefault.c 26;" d file: __FUNCT__ src/svd/interface/svddefault.c 27;" d file: __FUNCT__ src/svd/interface/svddefault.c 38;" d file: __FUNCT__ src/svd/interface/svddefault.c 39;" d file: __FUNCT__ src/svd/interface/svddefault.c 50;" d file: __FUNCT__ src/svd/interface/svddefault.c 51;" d file: __FUNCT__ src/svd/interface/svdmon.c 102;" d file: __FUNCT__ src/svd/interface/svdmon.c 103;" d file: __FUNCT__ src/svd/interface/svdmon.c 137;" d file: __FUNCT__ src/svd/interface/svdmon.c 138;" d file: __FUNCT__ src/svd/interface/svdmon.c 163;" d file: __FUNCT__ src/svd/interface/svdmon.c 164;" d file: __FUNCT__ src/svd/interface/svdmon.c 212;" d file: __FUNCT__ src/svd/interface/svdmon.c 213;" d file: __FUNCT__ src/svd/interface/svdmon.c 259;" d file: __FUNCT__ src/svd/interface/svdmon.c 260;" d file: __FUNCT__ src/svd/interface/svdmon.c 27;" d file: __FUNCT__ src/svd/interface/svdmon.c 28;" d file: __FUNCT__ src/svd/interface/svdmon.c 310;" d file: __FUNCT__ src/svd/interface/svdmon.c 311;" d file: __FUNCT__ src/svd/interface/svdmon.c 356;" d file: __FUNCT__ src/svd/interface/svdmon.c 357;" d file: __FUNCT__ src/svd/interface/svdmon.c 382;" d file: __FUNCT__ src/svd/interface/svdmon.c 383;" d file: __FUNCT__ src/svd/interface/svdmon.c 44;" d file: __FUNCT__ src/svd/interface/svdmon.c 45;" d file: __FUNCT__ src/svd/interface/svdopts.c 143;" d file: __FUNCT__ src/svd/interface/svdopts.c 144;" d file: __FUNCT__ src/svd/interface/svdopts.c 174;" d file: __FUNCT__ src/svd/interface/svdopts.c 175;" d file: __FUNCT__ src/svd/interface/svdopts.c 235;" d file: __FUNCT__ src/svd/interface/svdopts.c 236;" d file: __FUNCT__ src/svd/interface/svdopts.c 268;" d file: __FUNCT__ src/svd/interface/svdopts.c 269;" d file: __FUNCT__ src/svd/interface/svdopts.c 27;" d file: __FUNCT__ src/svd/interface/svdopts.c 28;" d file: __FUNCT__ src/svd/interface/svdopts.c 315;" d file: __FUNCT__ src/svd/interface/svdopts.c 316;" d file: __FUNCT__ src/svd/interface/svdopts.c 345;" d file: __FUNCT__ src/svd/interface/svdopts.c 346;" d file: __FUNCT__ src/svd/interface/svdopts.c 394;" d file: __FUNCT__ src/svd/interface/svdopts.c 395;" d file: __FUNCT__ src/svd/interface/svdopts.c 437;" d file: __FUNCT__ src/svd/interface/svdopts.c 438;" d file: __FUNCT__ src/svd/interface/svdopts.c 464;" d file: __FUNCT__ src/svd/interface/svdopts.c 465;" d file: __FUNCT__ src/svd/interface/svdopts.c 516;" d file: __FUNCT__ src/svd/interface/svdopts.c 517;" d file: __FUNCT__ src/svd/interface/svdopts.c 556;" d file: __FUNCT__ src/svd/interface/svdopts.c 557;" d file: __FUNCT__ src/svd/interface/svdopts.c 583;" d file: __FUNCT__ src/svd/interface/svdopts.c 584;" d file: __FUNCT__ src/svd/interface/svdopts.c 624;" d file: __FUNCT__ src/svd/interface/svdopts.c 625;" d file: __FUNCT__ src/svd/interface/svdopts.c 661;" d file: __FUNCT__ src/svd/interface/svdopts.c 662;" d file: __FUNCT__ src/svd/interface/svdopts.c 68;" d file: __FUNCT__ src/svd/interface/svdopts.c 69;" d file: __FUNCT__ src/svd/interface/svdopts.c 790;" d file: __FUNCT__ src/svd/interface/svdopts.c 791;" d file: __FUNCT__ src/svd/interface/svdopts.c 824;" d file: __FUNCT__ src/svd/interface/svdopts.c 825;" d file: __FUNCT__ src/svd/interface/svdopts.c 852;" d file: __FUNCT__ src/svd/interface/svdopts.c 853;" d file: __FUNCT__ src/svd/interface/svdopts.c 908;" d file: __FUNCT__ src/svd/interface/svdopts.c 909;" d file: __FUNCT__ src/svd/interface/svdopts.c 956;" d file: __FUNCT__ src/svd/interface/svdopts.c 957;" d file: __FUNCT__ src/svd/interface/svdopts.c 95;" d file: __FUNCT__ src/svd/interface/svdopts.c 96;" d file: __FUNCT__ src/svd/interface/svdregis.c 30;" d file: __FUNCT__ src/svd/interface/svdregis.c 31;" d file: __FUNCT__ src/svd/interface/svdsetup.c 214;" d file: __FUNCT__ src/svd/interface/svdsetup.c 215;" d file: __FUNCT__ src/svd/interface/svdsetup.c 258;" d file: __FUNCT__ src/svd/interface/svdsetup.c 259;" d file: __FUNCT__ src/svd/interface/svdsetup.c 26;" d file: __FUNCT__ src/svd/interface/svdsetup.c 27;" d file: __FUNCT__ src/svd/interface/svdsetup.c 302;" d file: __FUNCT__ src/svd/interface/svdsetup.c 303;" d file: __FUNCT__ src/svd/interface/svdsetup.c 330;" d file: __FUNCT__ src/svd/interface/svdsetup.c 331;" d file: __FUNCT__ src/svd/interface/svdsetup.c 56;" d file: __FUNCT__ src/svd/interface/svdsetup.c 57;" d file: __FUNCT__ src/svd/interface/svdsetup.c 82;" d file: __FUNCT__ src/svd/interface/svdsetup.c 83;" d file: __FUNCT__ src/svd/interface/svdsolve.c 140;" d file: __FUNCT__ src/svd/interface/svdsolve.c 141;" d file: __FUNCT__ src/svd/interface/svdsolve.c 175;" d file: __FUNCT__ src/svd/interface/svdsolve.c 176;" d file: __FUNCT__ src/svd/interface/svdsolve.c 214;" d file: __FUNCT__ src/svd/interface/svdsolve.c 215;" d file: __FUNCT__ src/svd/interface/svdsolve.c 243;" d file: __FUNCT__ src/svd/interface/svdsolve.c 244;" d file: __FUNCT__ src/svd/interface/svdsolve.c 26;" d file: __FUNCT__ src/svd/interface/svdsolve.c 27;" d file: __FUNCT__ src/svd/interface/svdsolve.c 300;" d file: __FUNCT__ src/svd/interface/svdsolve.c 301;" d file: __FUNCT__ src/svd/interface/svdsolve.c 351;" d file: __FUNCT__ src/svd/interface/svdsolve.c 352;" d file: __FUNCT__ src/svd/interface/svdsolve.c 67;" d file: __FUNCT__ src/svd/interface/svdsolve.c 68;" d file: __FUNCT__ src/svd/interface/svdview.c 120;" d file: __FUNCT__ src/svd/interface/svdview.c 121;" d file: __FUNCT__ src/svd/interface/svdview.c 157;" d file: __FUNCT__ src/svd/interface/svdview.c 158;" d file: __FUNCT__ src/svd/interface/svdview.c 192;" d file: __FUNCT__ src/svd/interface/svdview.c 193;" d file: __FUNCT__ src/svd/interface/svdview.c 228;" d file: __FUNCT__ src/svd/interface/svdview.c 229;" d file: __FUNCT__ src/svd/interface/svdview.c 258;" d file: __FUNCT__ src/svd/interface/svdview.c 259;" d file: __FUNCT__ src/svd/interface/svdview.c 278;" d file: __FUNCT__ src/svd/interface/svdview.c 279;" d file: __FUNCT__ src/svd/interface/svdview.c 27;" d file: __FUNCT__ src/svd/interface/svdview.c 28;" d file: __FUNCT__ src/svd/interface/svdview.c 338;" d file: __FUNCT__ src/svd/interface/svdview.c 339;" d file: __FUNCT__ src/svd/interface/svdview.c 380;" d file: __FUNCT__ src/svd/interface/svdview.c 381;" d file: __FUNCT__ src/svd/interface/svdview.c 406;" d file: __FUNCT__ src/svd/interface/svdview.c 407;" d file: __FUNCT__ src/svd/interface/svdview.c 422;" d file: __FUNCT__ src/svd/interface/svdview.c 423;" d file: __FUNCT__ src/svd/interface/svdview.c 440;" d file: __FUNCT__ src/svd/interface/svdview.c 441;" d file: __FUNCT__ src/svd/interface/svdview.c 492;" d file: __FUNCT__ src/svd/interface/svdview.c 493;" d file: __FUNCT__ src/svd/interface/svdview.c 527;" d file: __FUNCT__ src/svd/interface/svdview.c 528;" d file: __FUNCT__ src/svd/interface/svdview.c 580;" d file: __FUNCT__ src/svd/interface/svdview.c 581;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test1.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test1.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test10.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test10.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test11.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test11.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test12.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test12.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test2.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test2.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test3.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test3.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test4.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test4.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test5.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test5.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test6.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test6.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test7.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test7.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test8.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test8.c 27;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test9.c 26;" d file: __FUNCT__ src/sys/classes/bv/examples/tests/test9.c 27;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 102;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 103;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 119;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 120;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 139;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 140;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 159;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 160;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 175;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 176;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 191;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 192;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 207;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 208;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 222;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 223;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 263;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 264;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 278;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 279;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 318;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 319;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 32;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 331;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 332;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 33;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 342;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 343;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 353;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 354;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 367;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 368;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 53;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 54;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 68;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 69;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 85;" d file: __FUNCT__ src/sys/classes/bv/impls/contiguous/contig.c 86;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 111;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 112;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 132;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 133;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 155;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 156;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 177;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 178;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 196;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 197;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 215;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 216;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 234;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 235;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 251;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 252;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 300;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 301;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 319;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 31;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 320;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 32;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 350;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 351;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 366;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 367;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 382;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 383;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 394;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 395;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 406;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 407;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 418;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 419;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 430;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 431;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 457;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 458;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 472;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 473;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 56;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 57;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 73;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 74;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 92;" d file: __FUNCT__ src/sys/classes/bv/impls/mat/bvmat.c 93;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 112;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 113;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 134;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 135;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 156;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 157;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 178;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 179;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 197;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 198;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 216;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 217;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 235;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 236;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 252;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 253;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 301;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 302;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 31;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 320;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 321;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 32;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 354;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 355;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 370;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 371;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 385;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 386;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 397;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 398;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 409;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 410;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 421;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 422;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 433;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 434;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 460;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 461;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 475;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 476;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 57;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 58;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 74;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 75;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 93;" d file: __FUNCT__ src/sys/classes/bv/impls/svec/svec.c 94;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 125;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 126;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 155;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 156;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 185;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 186;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 204;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 205;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 221;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 222;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 238;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 239;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 250;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 251;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 269;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 270;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 298;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 299;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 317;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 318;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 336;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 337;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 33;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 34;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 352;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 353;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 367;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 368;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 396;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 397;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 409;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 410;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 428;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 429;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 447;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 448;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 466;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 467;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 477;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 478;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 494;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 495;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 510;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 511;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 541;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 542;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 554;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 555;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 566;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 567;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 67;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 68;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 89;" d file: __FUNCT__ src/sys/classes/bv/impls/vecs/vecs.c 90;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 102;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1031;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1032;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 103;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1057;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1058;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1111;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1112;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1164;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1165;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1202;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1203;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1237;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1238;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1275;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1276;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1306;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1307;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1337;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1338;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1356;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1357;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1395;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1396;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1432;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1433;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1482;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1483;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1529;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 1530;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 162;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 163;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 208;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 209;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 250;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 251;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 29;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 30;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 310;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 311;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 336;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 337;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 391;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 392;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 442;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 443;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 469;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 470;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 525;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 526;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 552;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 553;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 591;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 592;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 635;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 636;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 665;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 666;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 708;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 709;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 752;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 753;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 76;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 77;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 783;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 784;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 819;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 820;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 877;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 878;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 958;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 959;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 989;" d file: __FUNCT__ src/sys/classes/bv/interface/bvbasic.c 990;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 127;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 128;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 182;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 183;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 205;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 206;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 248;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 249;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 280;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 281;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 29;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 301;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 302;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 30;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 358;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 359;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 62;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 63;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 82;" d file: __FUNCT__ src/sys/classes/bv/interface/bvblas.c 83;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 118;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 119;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 155;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 156;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 228;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 229;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 270;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 271;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 345;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 346;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 35;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 36;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 412;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 413;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 443;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 444;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 474;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 475;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 507;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 508;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 540;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 541;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 56;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 57;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 638;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 639;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 666;" d file: __FUNCT__ src/sys/classes/bv/interface/bvfunc.c 667;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 1049;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 1050;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 1100;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 1101;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 143;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 144;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 196;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 197;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 253;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 254;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 26;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 27;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 305;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 306;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 358;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 359;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 419;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 420;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 481;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 482;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 495;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 496;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 508;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 509;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 521;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 522;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 566;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 567;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 620;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 621;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 62;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 63;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 667;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 668;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 706;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 707;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 759;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 760;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 821;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 822;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 881;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 882;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 926;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 927;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 983;" d file: __FUNCT__ src/sys/classes/bv/interface/bvglobal.c 984;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 154;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 155;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 209;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 210;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 268;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 269;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 26;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 27;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 322;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 323;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 360;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 361;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 399;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 400;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 450;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 451;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 499;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 500;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 549;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 550;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 608;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 609;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 96;" d file: __FUNCT__ src/sys/classes/bv/interface/bvops.c 97;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 125;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 126;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 197;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 198;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 253;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 254;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 27;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 28;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 314;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 315;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 384;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 385;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 443;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 444;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 484;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 485;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 551;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 552;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 575;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 576;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 60;" d file: __FUNCT__ src/sys/classes/bv/interface/bvorthog.c 61;" d file: __FUNCT__ src/sys/classes/bv/interface/bvregis.c 29;" d file: __FUNCT__ src/sys/classes/bv/interface/bvregis.c 30;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test1.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test1.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test12.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test12.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test13.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test13.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test15.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test15.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test2.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test2.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test3.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test3.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test4.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test4.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test5.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test5.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test6.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test6.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test7.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test7.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test8.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test8.c 27;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test9.c 26;" d file: __FUNCT__ src/sys/classes/ds/examples/tests/test9.c 27;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 135;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 136;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 161;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 162;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 220;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 221;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 25;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 26;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 41;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 42;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 56;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 57;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 95;" d file: __FUNCT__ src/sys/classes/ds/impls/ghep/dsghep.c 96;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 161;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 162;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 194;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 195;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 225;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 226;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 303;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 304;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 35;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 36;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 444;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 445;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 741;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 742;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 84;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dqds.c 85;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 179;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 180;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 24;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 25;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 280;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 281;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 320;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 321;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 406;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 407;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 42;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 43;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 451;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 452;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 537;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 538;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 662;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 663;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 773;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 774;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 88;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 89;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 911;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 912;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 968;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/dsghiep.c 969;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 236;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 237;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 304;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 305;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 36;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 37;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 77;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/hz.c 78;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 122;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 123;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 309;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 310;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 38;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 391;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 392;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 39;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 547;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 548;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 646;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 647;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 744;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 745;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 90;" d file: __FUNCT__ src/sys/classes/ds/impls/ghiep/invit.c 91;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 165;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 166;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 237;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 238;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 259;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 260;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 317;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 318;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 370;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 371;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 44;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 45;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 469;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 470;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 484;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 485;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 586;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 587;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 61;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 62;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 639;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 640;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 83;" d file: __FUNCT__ src/sys/classes/ds/impls/gnhep/dsgnhep.c 84;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 106;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 107;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 178;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 179;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 217;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 218;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 238;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 239;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 25;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 26;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 336;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 337;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 396;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 397;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 426;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 427;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 459;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 460;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 514;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 515;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 599;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 600;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 667;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 668;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 66;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 67;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 736;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 737;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 755;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 756;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 801;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 802;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 855;" d file: __FUNCT__ src/sys/classes/ds/impls/hep/dshep.c 856;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 109;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 110;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 127;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 128;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 162;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 163;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 188;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 189;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 30;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 312;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 313;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 31;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 335;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 336;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 377;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 378;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 389;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 390;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 418;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 419;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 429;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 430;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 458;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 459;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 477;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 478;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 66;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 67;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 86;" d file: __FUNCT__ src/sys/classes/ds/impls/nep/dsnep.c 87;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 117;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 118;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 131;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 132;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 204;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 205;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 25;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 268;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 269;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 26;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 313;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 314;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 370;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 371;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 40;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 41;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 420;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 421;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 509;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 510;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 524;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 525;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 548;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 549;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 60;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 61;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 626;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 627;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 652;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 653;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 698;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 699;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 781;" d file: __FUNCT__ src/sys/classes/ds/impls/nhep/dsnhep.c 782;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 107;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 108;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 154;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 155;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 277;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 278;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 290;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 291;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 29;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 30;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 316;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 317;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 327;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 328;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 355;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 356;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 368;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 369;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 50;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 51;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 74;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 75;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 91;" d file: __FUNCT__ src/sys/classes/ds/impls/pep/dspep.c 92;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 104;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 105;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 158;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 159;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 173;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 174;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 203;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 204;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 25;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 26;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 302;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 303;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 67;" d file: __FUNCT__ src/sys/classes/ds/impls/svd/dssvd.c 68;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 104;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 105;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 169;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 170;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 200;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 201;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 230;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 231;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 263;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 264;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 300;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 301;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 326;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 327;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 34;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 352;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 353;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 35;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 378;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 379;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 410;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 411;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 436;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 437;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 470;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 471;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 496;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 497;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 531;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 532;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 557;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 558;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 55;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 56;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 582;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 583;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 608;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 609;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 637;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 638;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 668;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 669;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 706;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 707;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 779;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 780;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 808;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 809;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 853;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 854;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 882;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 883;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 919;" d file: __FUNCT__ src/sys/classes/ds/interface/dsbasic.c 920;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 124;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 125;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 187;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 188;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 225;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 226;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 265;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 266;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 26;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 27;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 333;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 334;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 383;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 384;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 416;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 417;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 447;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 448;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 480;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 481;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 511;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 512;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 53;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 54;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 551;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 552;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 611;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 612;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 670;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 671;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 712;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 713;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 744;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 745;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 777;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 778;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 827;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 828;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 872;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 873;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 98;" d file: __FUNCT__ src/sys/classes/ds/interface/dsops.c 99;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 116;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 117;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 200;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 201;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 255;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 256;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 27;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 281;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 282;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 28;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 305;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 306;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 330;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 331;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 356;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 357;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 387;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 388;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 421;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 422;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 491;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 492;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 539;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 540;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 69;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 70;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 88;" d file: __FUNCT__ src/sys/classes/ds/interface/dspriv.c 89;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test1.c 26;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test1.c 27;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test2.c 26;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test2.c 27;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test3.c 26;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test3.c 27;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test3.c 77;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test3.c 78;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test4.c 26;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test4.c 27;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test5.c 26;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test5.c 27;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test5.c 77;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test5.c 78;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test6.c 39;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test6.c 40;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test6.c 90;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test6.c 91;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test7.c 26;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test7.c 27;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test7.c 92;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test7.c 93;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test8.c 26;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test8.c 27;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test8.c 97;" d file: __FUNCT__ src/sys/classes/fn/examples/tests/test8.c 98;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 109;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 110;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 171;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 172;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 236;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 237;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 269;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 270;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 289;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 290;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 320;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 321;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 346;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 347;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 376;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 377;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 38;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 390;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 391;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 39;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 406;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 407;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 69;" d file: __FUNCT__ src/sys/classes/fn/impls/combine/fncombine.c 70;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 143;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 144;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 177;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 178;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 27;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 28;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 36;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 37;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 48;" d file: __FUNCT__ src/sys/classes/fn/impls/exp/fnexp.c 49;" d file: __FUNCT__ src/sys/classes/fn/impls/fnutil.c 27;" d file: __FUNCT__ src/sys/classes/fn/impls/fnutil.c 28;" d file: __FUNCT__ src/sys/classes/fn/impls/fnutil.c 93;" d file: __FUNCT__ src/sys/classes/fn/impls/fnutil.c 94;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 111;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 112;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 145;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 146;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 27;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 28;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 37;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 38;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 47;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 48;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 78;" d file: __FUNCT__ src/sys/classes/fn/impls/invsqrt/fninvsqrt.c 79;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 26;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 27;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 35;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 36;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 45;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 46;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 79;" d file: __FUNCT__ src/sys/classes/fn/impls/log/fnlog.c 80;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 133;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 134;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 144;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 145;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 172;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 173;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 208;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 209;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 227;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 228;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 238;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 239;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 251;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 252;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 48;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 49;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 75;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 76;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 86;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 87;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 97;" d file: __FUNCT__ src/sys/classes/fn/impls/phi/fnphi.c 98;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 116;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 117;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 134;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 135;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 156;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 157;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 190;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 191;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 259;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 260;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 278;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 279;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 317;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 318;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 337;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 338;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 34;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 35;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 371;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 372;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 390;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 391;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 429;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 430;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 449;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 450;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 483;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 484;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 514;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 515;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 538;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 539;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 556;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 557;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 60;" d file: __FUNCT__ src/sys/classes/fn/impls/rational/fnrational.c 61;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 121;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 122;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 27;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 28;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 36;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 37;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 46;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 47;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 65;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 66;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 87;" d file: __FUNCT__ src/sys/classes/fn/impls/sqrt/fnsqrt.c 88;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 101;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 102;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 140;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 141;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 171;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 172;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 201;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 202;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 234;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 235;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 276;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 277;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 302;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 303;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 339;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 33;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 340;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 34;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 366;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 367;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 406;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 407;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 446;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 447;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 506;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 507;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 529;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 530;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 54;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 55;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 630;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 631;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 651;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 652;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 674;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 675;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 756;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 757;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 810;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 811;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 856;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 857;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 900;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 901;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 931;" d file: __FUNCT__ src/sys/classes/fn/interface/fnbasic.c 932;" d file: __FUNCT__ src/sys/classes/fn/interface/fnregis.c 32;" d file: __FUNCT__ src/sys/classes/fn/interface/fnregis.c 33;" d file: __FUNCT__ src/sys/classes/rg/examples/tests/test1.c 26;" d file: __FUNCT__ src/sys/classes/rg/examples/tests/test1.c 27;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 106;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 107;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 135;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 136;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 153;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 154;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 165;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 166;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 186;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 187;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 206;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 207;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 230;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 231;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 243;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 244;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 32;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 33;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 51;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 52;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 93;" d file: __FUNCT__ src/sys/classes/rg/impls/ellipse/rgellipse.c 94;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 106;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 107;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 134;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 135;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 150;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 151;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 162;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 163;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 214;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 215;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 232;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 233;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 255;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 256;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 268;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 269;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 32;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 33;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 54;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 55;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 92;" d file: __FUNCT__ src/sys/classes/rg/impls/interval/rginterval.c 93;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 110;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 111;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 123;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 124;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 155;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 156;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 188;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 189;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 199;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 200;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 267;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 268;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 307;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 308;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 33;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 342;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 343;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 34;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 362;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 363;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 64;" d file: __FUNCT__ src/sys/classes/rg/impls/polygon/rgpolygon.c 65;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 135;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 136;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 151;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 152;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 183;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 184;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 201;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 202;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 213;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 214;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 244;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 245;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 294;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 295;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 321;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 322;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 334;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 335;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 36;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 37;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 76;" d file: __FUNCT__ src/sys/classes/rg/impls/ring/rgring.c 77;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 133;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 134;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 164;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 165;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 194;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 195;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 227;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 228;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 265;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 266;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 291;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 292;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 31;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 32;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 342;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 343;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 394;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 395;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 425;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 426;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 485;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 486;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 523;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 524;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 52;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 53;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 551;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 552;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 578;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 579;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 610;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 611;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 636;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 637;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 670;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 671;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 694;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 695;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 721;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 722;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 97;" d file: __FUNCT__ src/sys/classes/rg/interface/rgbasic.c 98;" d file: __FUNCT__ src/sys/classes/rg/interface/rgregis.c 29;" d file: __FUNCT__ src/sys/classes/rg/interface/rgregis.c 30;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 155;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 156;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 168;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 169;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 181;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 182;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 194;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 195;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 31;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 32;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 51;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test1.c 52;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test2.c 26;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test2.c 27;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test3.c 26;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test3.c 27;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test4.c 26;" d file: __FUNCT__ src/sys/classes/st/examples/tests/test4.c 27;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 102;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 103;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 134;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 135;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 153;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 154;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 198;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 199;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 225;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 226;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 263;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 264;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 279;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 280;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 313;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 314;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 324;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 325;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 32;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 33;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 353;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 354;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 371;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 372;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 383;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 384;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 396;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 397;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 46;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 47;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 60;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 61;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 89;" d file: __FUNCT__ src/sys/classes/st/impls/cayley/cayley.c 90;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 157;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 158;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 173;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 174;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 191;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 192;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 220;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 221;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 247;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 248;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 280;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 281;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 291;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 292;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 30;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 31;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 324;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 325;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 335;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 336;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 365;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 366;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 380;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 381;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 60;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 61;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 71;" d file: __FUNCT__ src/sys/classes/st/impls/precond/precond.c 72;" d file: __FUNCT__ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 44;" d file: __FUNCT__ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 45;" d file: __FUNCT__ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 51;" d file: __FUNCT__ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 52;" d file: __FUNCT__ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 58;" d file: __FUNCT__ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 59;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 102;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 103;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 122;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 123;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 142;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 143;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 154;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 155;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 168;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 169;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 179;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 180;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 190;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 191;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 201;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 202;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 234;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 235;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 267;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 268;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 301;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 302;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 348;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 349;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 35;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 36;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 69;" d file: __FUNCT__ src/sys/classes/st/impls/shell/shell.c 70;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 145;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 146;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 171;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 172;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 199;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 200;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 27;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 28;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 45;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 46;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 63;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 64;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 76;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 77;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 95;" d file: __FUNCT__ src/sys/classes/st/impls/shift/shift.c 96;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 108;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 109;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 158;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 159;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 194;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 195;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 222;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 223;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 26;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 27;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 44;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 45;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 62;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 63;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 89;" d file: __FUNCT__ src/sys/classes/st/impls/sinvert/sinvert.c 90;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 105;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 106;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 134;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 135;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 167;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 168;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 218;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 219;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 282;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 283;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 30;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 313;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 314;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 31;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 344;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 345;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 370;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 371;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 409;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 410;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 435;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 436;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 460;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 461;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 488;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 489;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 51;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 524;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 525;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 52;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 553;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 554;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 579;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 580;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 605;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 606;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 631;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 632;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 665;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 666;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 699;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 700;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 732;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 733;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 821;" d file: __FUNCT__ src/sys/classes/st/interface/stfunc.c 822;" d file: __FUNCT__ src/sys/classes/st/interface/stregis.c 30;" d file: __FUNCT__ src/sys/classes/st/interface/stregis.c 31;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 109;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 110;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 177;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 178;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 224;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 225;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 252;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 253;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 29;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 302;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 303;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 30;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 329;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 330;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 366;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 367;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 82;" d file: __FUNCT__ src/sys/classes/st/interface/stset.c 83;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 116;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 117;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 151;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 152;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 167;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 168;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 37;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 38;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 50;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 51;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 85;" d file: __FUNCT__ src/sys/classes/st/interface/stshellmat.c 86;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 123;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 124;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 174;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 175;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 225;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 226;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 257;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 258;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 279;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 27;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 280;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 28;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 308;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 309;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 343;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 344;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 387;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 388;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 75;" d file: __FUNCT__ src/sys/classes/st/interface/stsles.c 76;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 126;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 127;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 159;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 160;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 174;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 175;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 254;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 255;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 26;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 27;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 307;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 308;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 401;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 402;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 424;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 425;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 452;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 453;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 481;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 482;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 76;" d file: __FUNCT__ src/sys/classes/st/interface/stsolve.c 77;" d file: __FUNCT__ src/sys/dlregisslepc.c 38;" d file: __FUNCT__ src/sys/dlregisslepc.c 40;" d file: __FUNCT__ src/sys/dlregisslepc.c 42;" d file: __FUNCT__ src/sys/slepcinit.c 104;" d file: __FUNCT__ src/sys/slepcinit.c 105;" d file: __FUNCT__ src/sys/slepcinit.c 122;" d file: __FUNCT__ src/sys/slepcinit.c 123;" d file: __FUNCT__ src/sys/slepcinit.c 173;" d file: __FUNCT__ src/sys/slepcinit.c 174;" d file: __FUNCT__ src/sys/slepcinit.c 200;" d file: __FUNCT__ src/sys/slepcinit.c 201;" d file: __FUNCT__ src/sys/slepcinit.c 253;" d file: __FUNCT__ src/sys/slepcinit.c 254;" d file: __FUNCT__ src/sys/slepcinit.c 25;" d file: __FUNCT__ src/sys/slepcinit.c 26;" d file: __FUNCT__ src/sys/slepcinit.c 278;" d file: __FUNCT__ src/sys/slepcinit.c 279;" d file: __FUNCT__ src/sys/slepcinit.c 301;" d file: __FUNCT__ src/sys/slepcinit.c 302;" d file: __FUNCT__ src/sys/slepcinit.c 320;" d file: __FUNCT__ src/sys/slepcinit.c 321;" d file: __FUNCT__ src/sys/slepcinit.c 54;" d file: __FUNCT__ src/sys/slepcinit.c 55;" d file: __FUNCT__ src/sys/slepcinit.c 76;" d file: __FUNCT__ src/sys/slepcinit.c 77;" d file: __FUNCT__ src/sys/slepcsc.c 165;" d file: __FUNCT__ src/sys/slepcsc.c 166;" d file: __FUNCT__ src/sys/slepcsc.c 179;" d file: __FUNCT__ src/sys/slepcsc.c 180;" d file: __FUNCT__ src/sys/slepcsc.c 194;" d file: __FUNCT__ src/sys/slepcsc.c 195;" d file: __FUNCT__ src/sys/slepcsc.c 209;" d file: __FUNCT__ src/sys/slepcsc.c 210;" d file: __FUNCT__ src/sys/slepcsc.c 224;" d file: __FUNCT__ src/sys/slepcsc.c 225;" d file: __FUNCT__ src/sys/slepcsc.c 239;" d file: __FUNCT__ src/sys/slepcsc.c 240;" d file: __FUNCT__ src/sys/slepcsc.c 259;" d file: __FUNCT__ src/sys/slepcsc.c 260;" d file: __FUNCT__ src/sys/slepcsc.c 26;" d file: __FUNCT__ src/sys/slepcsc.c 279;" d file: __FUNCT__ src/sys/slepcsc.c 27;" d file: __FUNCT__ src/sys/slepcsc.c 280;" d file: __FUNCT__ src/sys/slepcsc.c 296;" d file: __FUNCT__ src/sys/slepcsc.c 297;" d file: __FUNCT__ src/sys/slepcsc.c 312;" d file: __FUNCT__ src/sys/slepcsc.c 313;" d file: __FUNCT__ src/sys/slepcsc.c 336;" d file: __FUNCT__ src/sys/slepcsc.c 337;" d file: __FUNCT__ src/sys/slepcsc.c 85;" d file: __FUNCT__ src/sys/slepcsc.c 86;" d file: __FUNCT__ src/sys/slepcutil.c 124;" d file: __FUNCT__ src/sys/slepcutil.c 125;" d file: __FUNCT__ src/sys/slepcutil.c 231;" d file: __FUNCT__ src/sys/slepcutil.c 232;" d file: __FUNCT__ src/sys/slepcutil.c 24;" d file: __FUNCT__ src/sys/slepcutil.c 25;" d file: __FUNCT__ src/sys/slepcutil.c 370;" d file: __FUNCT__ src/sys/slepcutil.c 371;" d file: __FUNCT__ src/sys/slepcutil.c 461;" d file: __FUNCT__ src/sys/slepcutil.c 462;" d file: __FUNCT__ src/sys/slepcutil.c 548;" d file: __FUNCT__ src/sys/slepcutil.c 549;" d file: __FUNCT__ src/sys/slepcutil.c 585;" d file: __FUNCT__ src/sys/slepcutil.c 586;" d file: __FUNCT__ src/sys/slepcutil.c 610;" d file: __FUNCT__ src/sys/slepcutil.c 611;" d file: __FUNCT__ src/sys/slepcutil.c 634;" d file: __FUNCT__ src/sys/slepcutil.c 635;" d file: __FUNCT__ src/sys/slepcutil.c 656;" d file: __FUNCT__ src/sys/slepcutil.c 657;" d file: __FUNCT__ src/sys/slepcutil.c 70;" d file: __FUNCT__ src/sys/slepcutil.c 71;" d file: __FUNCT__ src/sys/vec/pool.c 139;" d file: __FUNCT__ src/sys/vec/pool.c 140;" d file: __FUNCT__ src/sys/vec/pool.c 26;" d file: __FUNCT__ src/sys/vec/pool.c 27;" d file: __FUNCT__ src/sys/vec/pool.c 62;" d file: __FUNCT__ src/sys/vec/pool.c 63;" d file: __FUNCT__ src/sys/vec/pool.c 94;" d file: __FUNCT__ src/sys/vec/pool.c 95;" d file: __FUNCT__ src/sys/vec/veccomp.c 112;" d file: __FUNCT__ src/sys/vec/veccomp.c 113;" d file: __FUNCT__ src/sys/vec/veccomp.c 128;" d file: __FUNCT__ src/sys/vec/veccomp.c 129;" d file: __FUNCT__ src/sys/vec/veccomp.c 213;" d file: __FUNCT__ src/sys/vec/veccomp.c 214;" d file: __FUNCT__ src/sys/vec/veccomp.c 229;" d file: __FUNCT__ src/sys/vec/veccomp.c 230;" d file: __FUNCT__ src/sys/vec/veccomp.c 244;" d file: __FUNCT__ src/sys/vec/veccomp.c 245;" d file: __FUNCT__ src/sys/vec/veccomp.c 300;" d file: __FUNCT__ src/sys/vec/veccomp.c 301;" d file: __FUNCT__ src/sys/vec/veccomp.c 311;" d file: __FUNCT__ src/sys/vec/veccomp.c 312;" d file: __FUNCT__ src/sys/vec/veccomp.c 356;" d file: __FUNCT__ src/sys/vec/veccomp.c 357;" d file: __FUNCT__ src/sys/vec/veccomp.c 390;" d file: __FUNCT__ src/sys/vec/veccomp.c 391;" d file: __FUNCT__ src/sys/vec/veccomp.c 413;" d file: __FUNCT__ src/sys/vec/veccomp.c 414;" d file: __FUNCT__ src/sys/vec/veccomp.c 443;" d file: __FUNCT__ src/sys/vec/veccomp.c 444;" d file: __FUNCT__ src/sys/vec/veccomp.c 478;" d file: __FUNCT__ src/sys/vec/veccomp.c 479;" d file: __FUNCT__ src/sys/vec/veccomp.c 495;" d file: __FUNCT__ src/sys/vec/veccomp.c 496;" d file: __FUNCT__ src/sys/vec/veccomp.c 512;" d file: __FUNCT__ src/sys/vec/veccomp.c 513;" d file: __FUNCT__ src/sys/vec/veccomp.c 529;" d file: __FUNCT__ src/sys/vec/veccomp.c 530;" d file: __FUNCT__ src/sys/vec/veccomp.c 553;" d file: __FUNCT__ src/sys/vec/veccomp.c 554;" d file: __FUNCT__ src/sys/vec/veccomp.c 571;" d file: __FUNCT__ src/sys/vec/veccomp.c 572;" d file: __FUNCT__ src/sys/vec/veccomp.c 589;" d file: __FUNCT__ src/sys/vec/veccomp.c 590;" d file: __FUNCT__ src/sys/vec/veccomp.c 602;" d file: __FUNCT__ src/sys/vec/veccomp.c 603;" d file: __FUNCT__ src/sys/vec/veccomp.c 615;" d file: __FUNCT__ src/sys/vec/veccomp.c 616;" d file: __FUNCT__ src/sys/vec/veccomp.c 648;" d file: __FUNCT__ src/sys/vec/veccomp.c 649;" d file: __FUNCT__ src/sys/vec/veccomp.c 681;" d file: __FUNCT__ src/sys/vec/veccomp.c 682;" d file: __FUNCT__ src/sys/vec/veccomp.c 722;" d file: __FUNCT__ src/sys/vec/veccomp.c 723;" d file: __FUNCT__ src/sys/vec/veccomp.c 726;" d file: __FUNCT__ src/sys/vec/veccomp.c 727;" d file: __FUNCT__ src/sys/vec/veccomp.c 730;" d file: __FUNCT__ src/sys/vec/veccomp.c 731;" d file: __FUNCT__ src/sys/vec/veccomp.c 734;" d file: __FUNCT__ src/sys/vec/veccomp.c 735;" d file: __FUNCT__ src/sys/vec/veccomp.c 738;" d file: __FUNCT__ src/sys/vec/veccomp.c 739;" d file: __FUNCT__ src/sys/vec/veccomp.c 73;" d file: __FUNCT__ src/sys/vec/veccomp.c 742;" d file: __FUNCT__ src/sys/vec/veccomp.c 743;" d file: __FUNCT__ src/sys/vec/veccomp.c 74;" d file: __FUNCT__ src/sys/vec/veccomp.c 762;" d file: __FUNCT__ src/sys/vec/veccomp.c 763;" d file: __FUNCT__ src/sys/vec/veccomp.c 766;" d file: __FUNCT__ src/sys/vec/veccomp.c 767;" d file: __FUNCT__ src/sys/vec/veccomp.c 770;" d file: __FUNCT__ src/sys/vec/veccomp.c 771;" d file: __FUNCT__ src/sys/vec/veccomp.c 774;" d file: __FUNCT__ src/sys/vec/veccomp.c 775;" d file: __FUNCT__ src/sys/vec/veccomp.c 778;" d file: __FUNCT__ src/sys/vec/veccomp.c 779;" d file: __FUNCT__ src/sys/vec/veccomp.c 800;" d file: __FUNCT__ src/sys/vec/veccomp.c 801;" d file: __FUNCT__ src/sys/vec/veccomp.c 804;" d file: __FUNCT__ src/sys/vec/veccomp.c 805;" d file: __FUNCT__ src/sys/vec/veccomp.c 828;" d file: __FUNCT__ src/sys/vec/veccomp.c 829;" d file: __FUNCT__ src/sys/vec/veccomp.c 832;" d file: __FUNCT__ src/sys/vec/veccomp.c 833;" d file: __FUNCT__ src/sys/vec/veccomp.c 836;" d file: __FUNCT__ src/sys/vec/veccomp.c 837;" d file: __FUNCT__ src/sys/vec/veccomp.c 840;" d file: __FUNCT__ src/sys/vec/veccomp.c 841;" d file: __FUNCT__ src/sys/vec/veccomp.c 844;" d file: __FUNCT__ src/sys/vec/veccomp.c 845;" d file: __FUNCT__ src/sys/vec/veccomp.c 98;" d file: __FUNCT__ src/sys/vec/veccomp.c 99;" d file: __FUNCT__ src/sys/vec/veccomp0.h 124;" d __FUNCT__ src/sys/vec/veccomp0.h 125;" d __FUNCT__ src/sys/vec/veccomp0.h 155;" d __FUNCT__ src/sys/vec/veccomp0.h 156;" d __FUNCT__ src/sys/vec/veccomp0.h 214;" d __FUNCT__ src/sys/vec/veccomp0.h 215;" d __FUNCT__ src/sys/vec/veccomp0.h 284;" d __FUNCT__ src/sys/vec/veccomp0.h 285;" d __FUNCT__ src/sys/vec/veccomp0.h 34;" d __FUNCT__ src/sys/vec/veccomp0.h 35;" d __FUNCT__ src/sys/vec/veccomp0.h 65;" d __FUNCT__ src/sys/vec/veccomp0.h 66;" d __FUNC_TEMPLATE1__ src/sys/vec/veccomp.c 707;" d file: __FUNC_TEMPLATE2__ src/sys/vec/veccomp.c 747;" d file: __FUNC_TEMPLATE3__ src/sys/vec/veccomp.c 783;" d file: __FUNC_TEMPLATE4__ src/sys/vec/veccomp.c 809;" d file: __KRYLOVSCHUR_H src/eps/impls/krylov/krylovschur/krylovschur.h 25;" d __LINEARP_H src/pep/impls/linear/linearp.h 25;" d __PJDP_H src/pep/impls/jd/pjdp.h 25;" d __QUOTEME src/sys/vec/veccomp0.h 30;" d __QUOTEME src/sys/vec/veccomp0.h 335;" d __QUOTEME_ src/sys/vec/veccomp0.h 29;" d __QUOTEME__ src/sys/vec/veccomp.c 703;" d file: __SLEPCBLASLAPACK_H include/slepcblaslapack.h 25;" d __SLEPCBVDEF_H include/slepc/finclude/slepcbvdef.h 24;" d __SLEPCBV_H include/slepcbv.h 23;" d __SLEPCDSDEF_H include/slepc/finclude/slepcdsdef.h 24;" d __SLEPCDS_H include/slepcds.h 23;" d __SLEPCEPSDEF_H include/slepc/finclude/slepcepsdef.h 24;" d __SLEPCEPS_H include/slepceps.h 25;" d __SLEPCFNDEF_H include/slepc/finclude/slepcfndef.h 24;" d __SLEPCFN_H include/slepcfn.h 23;" d __SLEPCMATH_H include/slepcmath.h 26;" d __SLEPCMFNDEF_H include/slepc/finclude/slepcmfndef.h 24;" d __SLEPCMFN_H include/slepcmfn.h 25;" d __SLEPCNEPDEF_H include/slepc/finclude/slepcnepdef.h 24;" d __SLEPCNEP_H include/slepcnep.h 25;" d __SLEPCPEPDEF_H include/slepc/finclude/slepcpepdef.h 24;" d __SLEPCPEP_H include/slepcpep.h 25;" d __SLEPCRGDEF_H include/slepc/finclude/slepcrgdef.h 24;" d __SLEPCRGTYPES_H include/slepcrgtypes.h 23;" d __SLEPCRG_H include/slepcrg.h 23;" d __SLEPCSC_H include/slepcsc.h 25;" d __SLEPCSTDEF_H include/slepc/finclude/slepcstdef.h 24;" d __SLEPCST_H include/slepcst.h 25;" d __SLEPCSVDDEF_H include/slepc/finclude/slepcsvddef.h 24;" d __SLEPCSVD_H include/slepcsvd.h 25;" d __SLEPCSYSDEF_H include/slepc/finclude/slepcsysdef.h 25;" d __SLEPCSYS_H include/slepcsys.h 26;" d __SLEPCVEC_H include/slepcvec.h 25;" d __SLEPCVERSION_H include/slepcversion.h 2;" d __SUF_C__ src/sys/vec/veccomp0.h 31;" d __SUF_C__ src/sys/vec/veccomp0.h 336;" d __SUF__ src/sys/vec/veccomp0.h 25;" d __SUF__ src/sys/vec/veccomp0.h 27;" d __SUF__ src/sys/vec/veccomp0.h 334;" d __TOAR_H src/pep/impls/krylov/pepkrylov.h 25;" d __TRLANP_H src/eps/impls/external/trlan/trlanp.h 25;" d __WITH_MPI__ src/sys/vec/veccomp.c 36;" d file: __copy__ config/cmakegen.py /^ def __copy__(self):$/;" m class:defaultdict file: __deepcopy__ config/cmakegen.py /^ def __deepcopy__(self, memo):$/;" m class:defaultdict file: __funct__ src/eps/examples/tests/test13.c 40;" d file: __funct__ src/eps/examples/tests/test13.c 41;" d file: __getitem__ config/cmakegen.py /^ def __getitem__(self, key):$/;" m class:defaultdict file: __init__ config/argdb.py /^ def __init__(self,argv):$/;" m class:ArgDB __init__ config/cmakeboot.py /^ def __init__(self, slepcdir, petscdir, petscarch, argDB = None, framework = None):$/;" m class:PETScMaker __init__ config/cmakegen.py /^ def __init__(self, default_factory=None, *a, **kw):$/;" m class:defaultdict __init__ config/cmakegen.py /^ def __init__(self, log, verbose=False):$/;" m class:Mistakes __init__ config/gmakegen.py /^ def __init__(self, log):$/;" m class:debuglogger __init__ config/gmakegen.py /^ def __init__(self, slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, verbose=False):$/;" m class:Slepc __init__ config/install.py /^ def __init__(self, args = None):$/;" m class:Installer __init__ config/package.py /^ def __init__(self,argdb,log):$/;" m class:Package __init__ config/packages/arpack.py /^ def __init__(self,argdb,log):$/;" m class:Arpack __init__ config/packages/blopex.py /^ def __init__(self,argdb,log):$/;" m class:Blopex __init__ config/packages/blzpack.py /^ def __init__(self,argdb,log):$/;" m class:Blzpack __init__ config/packages/feast.py /^ def __init__(self,argdb,log):$/;" m class:Feast __init__ config/packages/lapack.py /^ def __init__(self,argdb,log):$/;" m class:Lapack __init__ config/packages/petsc.py /^ def __init__(self,argdb,log):$/;" m class:PETSc __init__ config/packages/primme.py /^ def __init__(self,argdb,log):$/;" m class:Primme __init__ config/packages/slepc.py /^ def __init__(self,argdb,log):$/;" m class:SLEPc __init__ config/packages/sowing.py /^ def __init__(self,argdb,log):$/;" m class:Sowing __init__ config/packages/trlan.py /^ def __init__(self,argdb,log):$/;" m class:Trlan __init__ setup.py /^ def __init__(self):$/;" m class:context __missing__ config/cmakegen.py /^ def __missing__(self, key):$/;" m class:defaultdict file: __reduce__ config/cmakegen.py /^ def __reduce__(self):$/;" m class:defaultdict file: __repr__ config/cmakegen.py /^ def __repr__(self):$/;" m class:defaultdict file: __str__ config/cmakeboot.py /^ def __str__(self):$/;" m class:PETScMaker file: _cb src/eps/interface/ftn-custom/zepsf.c /^} _cb;$/;" v typeref:struct:__anon84 file: _cb src/mfn/interface/ftn-custom/zmfnf.c /^} _cb;$/;" v typeref:struct:__anon85 file: _cb src/nep/interface/ftn-custom/znepf.c /^} _cb;$/;" v typeref:struct:__anon96 file: _cb src/pep/interface/ftn-custom/zpepf.c /^} _cb;$/;" v typeref:struct:__anon107 file: _cb src/svd/interface/ftn-custom/zsvdf.c /^} _cb;$/;" v typeref:struct:__anon114 file: _cb src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^} _cb;$/;" v typeref:struct:__anon130 file: _dvdDashboard src/eps/impls/davidson/davidson.h /^typedef struct _dvdDashboard {$/;" s _dvdFunctionList src/eps/impls/davidson/davidson.h /^typedef struct _dvdFunctionList {$/;" s _n_SR src/eps/impls/krylov/krylovschur/krylovschur.h /^struct _n_SR {$/;" s _n_SlepcConvMonitor include/slepc/private/slepcimpl.h /^struct _n_SlepcConvMonitor {$/;" s _n_SlepcSC include/slepcsc.h /^struct _n_SlepcSC {$/;" s _n_shift src/eps/impls/krylov/krylovschur/krylovschur.h /^struct _n_shift {$/;" s _p_BV include/slepc/private/bvimpl.h /^struct _p_BV {$/;" s _p_DS include/slepc/private/dsimpl.h /^struct _p_DS {$/;" s _p_EPS include/slepc/private/epsimpl.h /^struct _p_EPS {$/;" s _p_FN include/slepc/private/fnimpl.h /^struct _p_FN {$/;" s _p_MFN include/slepc/private/mfnimpl.h /^struct _p_MFN {$/;" s _p_NEP include/slepc/private/nepimpl.h /^struct _p_NEP {$/;" s _p_PEP include/slepc/private/pepimpl.h /^struct _p_PEP {$/;" s _p_RG include/slepc/private/rgimpl.h /^struct _p_RG {$/;" s _p_ST include/slepc/private/stimpl.h /^struct _p_ST {$/;" s _p_SVD include/slepc/private/svdimpl.h /^struct _p_SVD {$/;" s _relpath config/gmakegen.py /^ def _relpath(path, start=os.path.curdir):$/;" f a src/sys/classes/rg/impls/interval/rginterval.c /^ PetscReal a,b; \/* interval in the real axis *\/$/;" m struct:__anon125 file: addFileNameTags bin/maint/generateetags.py /^def addFileNameTags(filename):$/;" f all config/gmakegen.py /^ def all(iterable):$/;" f allResiduals src/eps/impls/davidson/dvdupdatev.c /^ PetscBool allResiduals; \/* if computing all the residuals *\/$/;" m struct:__anon70 file: allocate include/slepc/private/dsimpl.h /^ PetscErrorCode (*allocate)(DS,PetscInt);$/;" m struct:_DSOps alpha include/slepc/private/fnimpl.h /^ PetscScalar alpha; \/* inner scaling (argument) *\/$/;" m struct:_p_FN alpha src/eps/examples/tutorials/ex30.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon56 file: alpha src/eps/examples/tutorials/ex9.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon58 file: alpha src/sys/classes/ds/impls/ghiep/invit.c /^ PetscReal alpha;$/;" m struct:HRtr file: alpha src/sys/classes/st/interface/stshellmat.c /^ PetscScalar alpha;$/;" m struct:__anon132 file: apply include/slepc/private/stimpl.h /^ PetscErrorCode (*apply)(ST,Vec,Vec);$/;" m struct:_STOps apply src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^ PetscFortranCallbackId apply;$/;" m struct:__anon130 file: apply src/sys/classes/st/impls/shell/shell.c /^ PetscErrorCode (*apply)(ST,Vec,Vec);$/;" m struct:__anon131 file: applyPreconditioner_PRIMME src/eps/impls/external/primme/primme.c /^static void applyPreconditioner_PRIMME(void *in,void *out,int *blockSize,struct primme_params *primme)$/;" f file: applytrans include/slepc/private/stimpl.h /^ PetscErrorCode (*applytrans)(ST,Vec,Vec);$/;" m struct:_STOps applytrans src/sys/classes/st/impls/shell/shell.c /^ PetscErrorCode (*applytrans)(ST,Vec,Vec);$/;" m struct:__anon131 file: applytranspose src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^ PetscFortranCallbackId applytranspose;$/;" m struct:__anon130 file: arbitrary include/slepc/private/epsimpl.h /^ PetscErrorCode (*arbitrary)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*);$/;" m struct:_p_EPS arbitrary src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId arbitrary;$/;" m struct:__anon84 file: arbitraryctx include/slepc/private/epsimpl.h /^ void *arbitraryctx;$/;" m struct:_p_EPS arch_path config/gmakegen.py /^ def arch_path(self, *args):$/;" m class:Slepc archname config/configure.py /^ archname = petsc.arch$/;" v argdb config/configure.py /^argdb = argdb.ArgDB(sys.argv)$/;" v arpack config/configure.py /^arpack = arpack.Arpack(argdb,log)$/;" v array src/sys/classes/bv/impls/contiguous/contig.c /^ PetscScalar *array;$/;" m struct:__anon115 file: author setup.py /^ author='SLEPc Team',$/;" v author_email setup.py /^ author_email='slepc-maint@upv.es',$/;" v auxBV src/eps/impls/davidson/davidson.h /^ BV auxBV; \/* auxiliary vectors *\/$/;" m struct:_dvdDashboard auxM src/eps/impls/davidson/davidson.h /^ Mat auxM; \/* auxiliary dense matrix *\/$/;" m struct:_dvdDashboard auxV src/eps/impls/davidson/davidson.h /^ VecPool auxV; \/* auxiliary vectors *\/$/;" m struct:_dvdDashboard b src/sys/classes/rg/impls/interval/rginterval.c /^ PetscReal a,b; \/* interval in the real axis *\/$/;" m struct:__anon125 file: back src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscScalar *back;$/;" m struct:_n_SR backtransform include/slepc/private/epsimpl.h /^ PetscErrorCode (*backtransform)(EPS);$/;" m struct:_EPSOps backtransform include/slepc/private/pepimpl.h /^ PetscErrorCode (*backtransform)(PEP);$/;" m struct:_PEPOps backtransform include/slepc/private/stimpl.h /^ PetscErrorCode (*backtransform)(ST,PetscInt,PetscScalar*,PetscScalar*);$/;" m struct:_STOps backtransform src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^ PetscFortranCallbackId backtransform;$/;" m struct:__anon130 file: backtransform src/sys/classes/st/impls/shell/shell.c /^ PetscErrorCode (*backtransform)(ST,PetscInt n,PetscScalar*,PetscScalar*);$/;" m struct:__anon131 file: badWebIndex bin/maint/generateetags.py /^def badWebIndex(dirname,file):$/;" f balance include/slepc/private/epsimpl.h /^ EPSBalance balance; \/* the balancing method *\/$/;" m struct:_p_EPS balance_cutoff include/slepc/private/epsimpl.h /^ PetscReal balance_cutoff; \/* cutoff value for balancing *\/$/;" m struct:_p_EPS balance_its include/slepc/private/epsimpl.h /^ PetscInt balance_its; \/* number of iterations of the balancing method *\/$/;" m struct:_p_EPS basis include/slepc/private/pepimpl.h /^ PEPBasis basis; \/* polynomial basis used to represent the problem *\/$/;" m struct:_p_PEP beta include/slepc/private/fnimpl.h /^ PetscScalar beta; \/* outer scaling (result) *\/$/;" m struct:_p_FN beta src/eps/examples/tutorials/ex30.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon56 file: beta src/eps/examples/tutorials/ex9.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon58 file: beta src/nep/impls/nleigs/nleigs.c /^ PetscScalar *beta; \/* scaling factors *\/$/;" m struct:__anon92 file: bfort config/configure.py /^ bfort = os.path.join(archdir,'bin','bfort')$/;" v bfort config/configure.py /^ bfort = sowing.Install(archdir,petsc.make)$/;" v bfort config/configure.py /^ bfort = sowing.Install(archdir,petsc.make)$/;" v bfort config/configure.py /^bfort = petsc.bfort$/;" v blap_fn src/eps/impls/external/blopex/blopex.c /^ lobpcg_BLASLAPACKFunctions blap_fn;$/;" m struct:__anon75 file: block_size src/eps/impls/external/blzpack/blzpackp.h /^ PetscBLASInt block_size; \/* block size *\/$/;" m struct:__anon76 blocksize src/eps/impls/davidson/davidson.h /^ PetscInt blocksize; \/* block size *\/$/;" m struct:__anon65 blopex config/configure.py /^blopex = blopex.Blopex(argdb,log)$/;" v blzpack config/configure.py /^blzpack = blzpack.Blzpack(argdb,log)$/;" v blzpack_error src/eps/impls/external/blzpack/blzpack.c /^const char* blzpack_error[33] = {$/;" v bnorm include/slepc/private/mfnimpl.h /^ PetscReal bnorm; \/* computed norm of right-hand side in current solve *\/$/;" m struct:_p_MFN body config/cmakegen.py /^ def body(indentlevel):$/;" f function:writePackage bootstrap setup.py /^def bootstrap():$/;" f bs include/slepc/private/dsimpl.h /^ PetscInt bs; \/* block size *\/$/;" m struct:_p_DS bs src/eps/impls/cg/lobpcg/lobpcg.c /^ PetscInt bs; \/* block size *\/$/;" m struct:__anon59 file: bs src/eps/impls/davidson/davidson.h /^ PetscInt bs; \/* max vectors that expands the subspace every iteration *\/$/;" m struct:_dvdDashboard bs src/eps/impls/external/blopex/blopex.c /^ PetscInt bs; \/* block size *\/$/;" m struct:__anon75 file: build setup.py /^def build(dry_run=False):$/;" f bvappendoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c /^PETSC_EXTERN void PETSC_STDCALL bvappendoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f bvappendoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 29;" d file: bvappendoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 36;" d file: bvgetoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c /^PETSC_EXTERN void PETSC_STDCALL bvgetoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f bvgetoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 30;" d file: bvgetoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 37;" d file: bvgettype_ src/sys/classes/bv/interface/ftn-custom/zbvf.c /^PETSC_EXTERN void PETSC_STDCALL bvgettype_(BV *bv,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f bvgettype_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 27;" d file: bvgettype_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 34;" d file: bvsetoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c /^PETSC_EXTERN void PETSC_STDCALL bvsetoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f bvsetoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 28;" d file: bvsetoptionsprefix_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 35;" d file: bvsettype_ src/sys/classes/bv/interface/ftn-custom/zbvf.c /^PETSC_EXTERN void PETSC_STDCALL bvsettype_(BV *bv,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f bvsettype_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 26;" d file: bvsettype_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 33;" d file: bvstate include/slepc/private/bvimpl.h /^ PetscObjectState bvstate; \/* state of BV when BVApplyMatrixBV() was called *\/$/;" m struct:_p_BV bvview_ src/sys/classes/bv/interface/ftn-custom/zbvf.c /^PETSC_EXTERN void PETSC_STDCALL bvview_(BV *bv,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f bvview_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 31;" d file: bvview_ src/sys/classes/bv/interface/ftn-custom/zbvf.c 38;" d file: c include/slepc/private/bvimpl.h /^ PetscScalar *h,*c; \/* orthogonalization coefficients *\/$/;" m struct:_p_BV c src/sys/classes/rg/impls/interval/rginterval.c /^ PetscReal c,d; \/* interval in the imaginary axis *\/$/;" m struct:__anon125 file: cX_in_impr src/eps/impls/davidson/davidson.h /^ PetscInt cX_in_impr; \/* converged vectors in the projector *\/$/;" m struct:__anon65 cX_in_proj src/eps/impls/davidson/davidson.h /^ PetscInt cX_in_proj; \/* converged vectors in the projected problem *\/$/;" m struct:__anon65 cached include/slepc/private/bvimpl.h /^ BV cached; \/* cached BV to store result of matrix times BV *\/$/;" m struct:_p_BV calcPairs src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcPairs)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard calcPairs_data src/eps/impls/davidson/davidson.h /^ void *calcPairs_data;$/;" m struct:_dvdDashboard calcpairs_W src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcpairs_W)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard calcpairs_W_data src/eps/impls/davidson/davidson.h /^ void *calcpairs_W_data;$/;" m struct:_dvdDashboard calcpairs_eig_backtrans src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcpairs_eig_backtrans)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscScalar*,PetscScalar*);$/;" m struct:_dvdDashboard calcpairs_eigs_trans src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcpairs_eigs_trans)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard calcpairs_proj_res src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcpairs_proj_res)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*);$/;" m struct:_dvdDashboard calcpairs_proj_trans src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcpairs_proj_trans)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard calcpairs_residual src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcpairs_residual)(struct _dvdDashboard*,PetscInt,PetscInt);$/;" m struct:_dvdDashboard calcpairs_residual_data src/eps/impls/davidson/davidson.h /^ void *calcpairs_residual_data;$/;" m struct:_dvdDashboard calcpairs_selectPairs src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*calcpairs_selectPairs)(struct _dvdDashboard*,PetscInt);$/;" m struct:_dvdDashboard cctol src/nep/impls/rii/rii.c /^ PetscBool cctol; \/* constant correction tolerance *\/$/;" m struct:__anon94 file: ceigi src/eps/impls/davidson/davidson.h /^ PetscScalar *ceigr,*ceigi; \/* converged eigenvalues *\/$/;" m struct:_dvdDashboard ceigr src/eps/impls/davidson/davidson.h /^ PetscScalar *ceigr,*ceigi; \/* converged eigenvalues *\/$/;" m struct:_dvdDashboard center src/sys/classes/rg/impls/ellipse/rgellipse.c /^ PetscScalar center; \/* center of the ellipse *\/$/;" m struct:__anon124 file: center src/sys/classes/rg/impls/ring/rgring.c /^ PetscScalar center; \/* center of the ellipse *\/$/;" m struct:__anon127 file: cform src/pep/impls/linear/linearp.h /^ PetscInt cform; \/* companion form *\/$/;" m struct:__anon106 checkDestdir config/install.py /^ def checkDestdir(self):$/;" m class:Installer checkinside include/slepc/private/rgimpl.h /^ PetscErrorCode (*checkinside)(RG,PetscReal,PetscReal,PetscInt*);$/;" m struct:_RGOps checknullspace include/slepc/private/stimpl.h /^ PetscErrorCode (*checknullspace)(ST,BV);$/;" m struct:_STOps checkpackages config/configure.py /^checkpackages = [arpack, blopex, blzpack, feast, primme, trlan, lapack]$/;" v ci include/slepc/private/bvimpl.h /^ PetscInt ci[2]; \/* column indices of obtained vectors *\/$/;" m struct:_p_BV citation src/eps/impls/davidson/davidson.c /^static const char citation[] =$/;" v file: citation src/eps/impls/krylov/krylovschur/ks-slice.c /^static const char citation[] =$/;" v file: citation src/pep/impls/krylov/stoar/stoar.c /^static const char citation[] =$/;" v file: citation src/pep/impls/krylov/toar/ptoar.c /^static const char citation[] =$/;" v file: citation src/pep/interface/pepsolve.c /^static const char citation[] =$/;" v file: citation src/svd/impls/trlanczos/trlanczos.c /^static const char citation[] =$/;" v file: cited src/eps/impls/davidson/davidson.c /^static PetscBool cited = PETSC_FALSE;$/;" v file: cited src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscBool cited = PETSC_FALSE;$/;" v file: cited src/pep/impls/krylov/stoar/stoar.c /^static PetscBool cited = PETSC_FALSE;$/;" v file: cited src/pep/impls/krylov/toar/ptoar.c /^static PetscBool cited = PETSC_FALSE;$/;" v file: cited src/pep/interface/pepsolve.c /^static PetscBool cited = PETSC_FALSE;$/;" v file: cited src/svd/impls/trlanczos/trlanczos.c /^static PetscBool cited = PETSC_FALSE;$/;" v file: classifiers setup.py /^ classifiers= classifiers.split('\\n')[1:-1],$/;" v cmakeboot config/cmakeboot.py /^ def cmakeboot(self, args, log):$/;" m class:PETScMaker cmakeconditional config/cmakegen.py /^def cmakeconditional(key,val):$/;" f cmakeconf config/configure.py /^cmakeconf = CreateFile(confdir,'SLEPcBuildInternal.cmake',log)$/;" v cmakeok config/configure.py /^ cmakeok = cmakeboot.main(slepc.dir,petsc.dir,log=log)$/;" v cmakeok config/configure.py /^cmakeok = False$/;" v cmd_install setup.py /^class cmd_install(_install):$/;" c cmdclass setup.py /^ cmdclass={'install': cmd_install},$/;" v coeff src/nep/impls/nleigs/nleigs.c /^ PetscScalar coeff[MAX_NSHIFTS];$/;" m struct:__anon93 file: coeffD src/nep/impls/nleigs/nleigs.c /^ PetscScalar *coeffD; \/* coefficients for divided differences in split form *\/$/;" m struct:__anon92 file: coeffs src/sys/classes/st/interface/stshellmat.c /^ PetscScalar *coeffs;$/;" m struct:__anon132 file: cols src/pep/impls/krylov/toar/nrefine.c /^ PetscInt idx,*cols;$/;" m struct:__anon105 file: comb src/sys/classes/fn/impls/combine/fncombine.c /^ FNCombineType comb; \/* how the functions are combined *\/$/;" m struct:__anon121 file: commrank src/eps/impls/krylov/krylovschur/krylovschur.h /^ MPI_Comm commrank; \/* group processes with same rank in subcommunicators *\/$/;" m struct:__anon81 commset src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscBool commset; \/* flag indicating that commrank was created *\/$/;" m struct:__anon81 comp src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscBool comp[2]; \/* Shows completion of subintervals (left and right) *\/$/;" m struct:_n_shift compM1 src/pep/impls/krylov/toar/nrefine.c /^ PetscBool compM1;$/;" m struct:__anon104 file: compM1 src/pep/impls/krylov/toar/nrefine.c /^ PetscBool compM1;$/;" m struct:__anon105 file: compact include/slepc/private/dsimpl.h /^ PetscBool compact; \/* whether the matrices are stored in compact form *\/$/;" m struct:_p_DS compareDirLists config/cmakegen.py /^ def compareDirLists(self,root, mdirs, dirs):$/;" m class:Mistakes compareSourceLists config/cmakegen.py /^ def compareSourceLists(self, root, msources, files):$/;" m class:Mistakes comparison include/slepcsc.h /^ PetscErrorCode (*comparison)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*);$/;" m struct:_n_SlepcSC comparison src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId comparison;$/;" m struct:__anon84 file: comparison src/nep/interface/ftn-custom/znepf.c /^ PetscFortranCallbackId comparison;$/;" m struct:__anon96 file: comparison src/pep/interface/ftn-custom/zpepf.c /^ PetscFortranCallbackId comparison;$/;" m struct:__anon107 file: comparisonctx include/slepcsc.h /^ void *comparisonctx;$/;" m struct:_n_SlepcSC complement include/slepc/private/rgimpl.h /^ PetscBool complement; \/* region is the complement of the specified one *\/$/;" m struct:_p_RG compute_int src/eps/impls/krylov/lanczos/lanczos.c /^static void compute_int(PetscBool *which,PetscReal *mu,PetscInt j,PetscReal delta,PetscReal eta)$/;" f file: computecontour include/slepc/private/rgimpl.h /^ PetscErrorCode (*computecontour)(RG,PetscInt,PetscScalar*,PetscScalar*);$/;" m struct:_RGOps computederivatives include/slepc/private/nepimpl.h /^ PetscErrorCode (*computederivatives)(NEP,PetscScalar,PetscInt,Mat,void*);$/;" m struct:_p_NEP computefunction include/slepc/private/nepimpl.h /^ PetscErrorCode (*computefunction)(NEP,PetscScalar,Mat,Mat,void*);$/;" m struct:_p_NEP computejacobian include/slepc/private/nepimpl.h /^ PetscErrorCode (*computejacobian)(NEP,PetscScalar,Mat,void*);$/;" m struct:_p_NEP computesingularities src/nep/impls/nleigs/nleigs.c /^ PetscErrorCode (*computesingularities)(NEP,PetscInt*,PetscScalar*,void*);$/;" m struct:__anon92 file: computevectors include/slepc/private/epsimpl.h /^ PetscErrorCode (*computevectors)(EPS);$/;" m struct:_EPSOps computevectors include/slepc/private/nepimpl.h /^ PetscErrorCode (*computevectors)(NEP);$/;" m struct:_NEPOps computevectors include/slepc/private/pepimpl.h /^ PetscErrorCode (*computevectors)(PEP);$/;" m struct:_PEPOps cond include/slepc/private/dsimpl.h /^ PetscErrorCode (*cond)(DS,PetscReal*);$/;" m struct:_DSOps confdir config/configure.py /^confdir = CreateDirTwo(libdir,'slepc','conf',log)$/;" v config setup.py /^def config(prefix, dry_run=False):$/;" f configdir config/configure.py /^configdir = os.path.abspath('config')$/;" v context setup.py /^class context(object):$/;" c conv include/slepc/private/epsimpl.h /^ EPSConv conv; \/* convergence test *\/$/;" m struct:_p_EPS conv include/slepc/private/nepimpl.h /^ NEPConv conv; \/* convergence test *\/$/;" m struct:_p_NEP conv include/slepc/private/pepimpl.h /^ PEPConv conv; \/* convergence test *\/$/;" m struct:_p_PEP conv include/slepc/private/svdimpl.h /^ SVDConv conv; \/* convergence test *\/$/;" m struct:_p_SVD convdestroy src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId convdestroy;$/;" m struct:__anon84 file: convdestroy src/nep/interface/ftn-custom/znepf.c /^ PetscFortranCallbackId convdestroy;$/;" m struct:__anon96 file: convdestroy src/pep/interface/ftn-custom/zpepf.c /^ PetscFortranCallbackId convdestroy;$/;" m struct:__anon107 file: convdestroy src/svd/interface/ftn-custom/zsvdf.c /^ PetscFortranCallbackId convdestroy;$/;" m struct:__anon114 file: converged include/slepc/private/epsimpl.h /^ PetscErrorCode (*converged)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);$/;" m struct:_p_EPS converged include/slepc/private/nepimpl.h /^ PetscErrorCode (*converged)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);$/;" m struct:_p_NEP converged include/slepc/private/pepimpl.h /^ PetscErrorCode (*converged)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);$/;" m struct:_p_PEP converged include/slepc/private/svdimpl.h /^ PetscErrorCode (*converged)(SVD,PetscReal,PetscReal,PetscReal*,void*);$/;" m struct:_p_SVD convergedctx include/slepc/private/epsimpl.h /^ void *convergedctx;$/;" m struct:_p_EPS convergedctx include/slepc/private/nepimpl.h /^ void *convergedctx;$/;" m struct:_p_NEP convergedctx include/slepc/private/pepimpl.h /^ void *convergedctx;$/;" m struct:_p_PEP convergedctx include/slepc/private/svdimpl.h /^ void *convergedctx;$/;" m struct:_p_SVD convergeddestroy include/slepc/private/epsimpl.h /^ PetscErrorCode (*convergeddestroy)(void*);$/;" m struct:_p_EPS convergeddestroy include/slepc/private/nepimpl.h /^ PetscErrorCode (*convergeddestroy)(void*);$/;" m struct:_p_NEP convergeddestroy include/slepc/private/pepimpl.h /^ PetscErrorCode (*convergeddestroy)(void*);$/;" m struct:_p_PEP convergeddestroy include/slepc/private/svdimpl.h /^ PetscErrorCode (*convergeddestroy)(void*);$/;" m struct:_p_SVD convergence src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId convergence;$/;" m struct:__anon84 file: convergence src/nep/interface/ftn-custom/znepf.c /^ PetscFortranCallbackId convergence;$/;" m struct:__anon96 file: convergence src/pep/interface/ftn-custom/zpepf.c /^ PetscFortranCallbackId convergence;$/;" m struct:__anon107 file: convergence src/svd/interface/ftn-custom/zsvdf.c /^ PetscFortranCallbackId convergence;$/;" m struct:__anon114 file: copy config/cmakegen.py /^ def copy(self):$/;" m class:defaultdict copy include/slepc/private/bvimpl.h /^ PetscErrorCode (*copy)(BV,BV);$/;" m struct:_BVOps copyLib config/install.py /^ def copyLib(self, src, dst):$/;" m class:Installer copytree config/install.py /^ def copytree(self, src, dst, symlinks = False, copyFunc = shutil.copy2, exclude = []):$/;" m class:Installer correctXnorm src/eps/impls/davidson/davidson.h /^ PetscBool correctXnorm; \/* if true, norm of X are computed *\/$/;" m struct:_dvdDashboard create include/slepc/private/bvimpl.h /^ PetscErrorCode (*create)(BV);$/;" m struct:_BVOps createTags bin/maint/generateetags.py /^def createTags(flist,etagfile,ctagfile):$/;" f createUninstaller config/install.py /^ def createUninstaller(self):$/;" m class:Installer cs src/sys/classes/ds/impls/ghiep/invit.c /^ PetscReal cs;$/;" m struct:HRtr file: ctx src/sys/classes/st/impls/shell/shell.c /^ void *ctx; \/* user provided context *\/$/;" m struct:__anon131 file: cutlr_ src/sys/classes/ds/impls/hep/bdc/dibtdc.c /^static PetscErrorCode cutlr_(PetscBLASInt start,PetscBLASInt n,PetscBLASInt blkct, $/;" f file: cv include/slepc/private/bvimpl.h /^ Vec cv[2]; \/* column vectors obtained with BVGetColumn() *\/$/;" m struct:_p_BV cw include/slepc/private/fnimpl.h /^ PetscInt cw; \/* current W matrix *\/$/;" m struct:_p_FN d src/eps/impls/davidson/dvdimprovex.c /^ dvdDashboard *d; \/* the currect dvdDashboard reference *\/$/;" m struct:__anon68 file: d src/pep/impls/krylov/pepkrylov.h /^ PetscInt d; \/* polynomial degree *\/$/;" m struct:__anon102 d src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *M4,*w,*wt,*d,*dt;$/;" m struct:__anon105 file: d src/sys/classes/ds/impls/pep/dspep.c /^ PetscInt d; \/* polynomial degree *\/$/;" m struct:__anon120 file: d src/sys/classes/rg/impls/interval/rginterval.c /^ PetscReal c,d; \/* interval in the imaginary axis *\/$/;" m struct:__anon125 file: data include/slepc/private/bvimpl.h /^ void *data;$/;" m struct:_p_BV data include/slepc/private/dsimpl.h /^ void *data; \/* placeholder for solver-specific stuff *\/$/;" m struct:_p_DS data include/slepc/private/epsimpl.h /^ void *data; \/* placeholder for solver-specific stuff *\/$/;" m struct:_p_EPS data include/slepc/private/fnimpl.h /^ void *data;$/;" m struct:_p_FN data include/slepc/private/mfnimpl.h /^ void *data; \/* placeholder for solver-specific stuff *\/$/;" m struct:_p_MFN data include/slepc/private/nepimpl.h /^ void *data; \/* placeholder for solver-specific stuff *\/$/;" m struct:_p_NEP data include/slepc/private/pepimpl.h /^ void *data; \/* placeholder for solver-specific stuff *\/$/;" m struct:_p_PEP data include/slepc/private/rgimpl.h /^ void *data;$/;" m struct:_p_RG data include/slepc/private/stimpl.h /^ void *data;$/;" m struct:_p_ST data include/slepc/private/svdimpl.h /^ void *data; \/* placeholder for solver-specific stuff *\/$/;" m struct:_p_SVD data src/sys/classes/ds/impls/ghiep/invit.c /^ PetscScalar *data;$/;" m struct:HRtr file: ddb src/eps/impls/davidson/davidson.h /^ dvdDashboard ddb;$/;" m struct:__anon65 ddmaxit src/nep/impls/nleigs/nleigs.c /^ PetscInt ddmaxit; \/* maximum number of divided difference terms *\/$/;" m struct:__anon92 file: ddtol src/nep/impls/nleigs/nleigs.c /^ PetscReal ddtol; \/* tolerance for divided difference convergence *\/$/;" m struct:__anon92 file: debuglogger config/gmakegen.py /^class debuglogger(object):$/;" c defaultdict config/cmakegen.py /^ class defaultdict(dict):$/;" c defersfo include/slepc/private/bvimpl.h /^ PetscBool defersfo; \/* deferred call to setfromoptions *\/$/;" m struct:_p_BV defl include/slepc/private/epsimpl.h /^ Vec *defl; \/* references to user-provided deflation space *\/$/;" m struct:_p_EPS defsigma include/slepc/private/stimpl.h /^ PetscScalar defsigma; \/* default value of the shift *\/$/;" m struct:_p_ST deg src/nep/impls/interpol/interpol.c /^ PetscInt deg;$/;" m struct:__anon90 file: delayed src/eps/impls/krylov/arnoldi/arnoldi.c /^ PetscBool delayed;$/;" m struct:__anon80 file: delta src/eps/impls/ciss/ciss.c /^ PetscReal delta; \/* threshold of singular value (1e-12) *\/$/;" m struct:__anon61 file: delta src/nep/impls/ciss/nciss.c /^ PetscReal delta; \/* threshold of singular value (1e-12) *\/$/;" m struct:__anon89 file: derivatives include/slepc/private/nepimpl.h /^ Mat derivatives; \/* derivatives matrix *\/$/;" m struct:_p_NEP derivativesctx include/slepc/private/nepimpl.h /^ void *derivativesctx;$/;" m struct:_p_NEP description setup.py /^ description=description.pop(0),$/;" v description setup.py /^description = __doc__.split('\\n')[1:-1]; del description[1:3]$/;" v destroy include/slepc/private/bvimpl.h /^ PetscErrorCode (*destroy)(BV);$/;" m struct:_BVOps destroy include/slepc/private/dsimpl.h /^ PetscErrorCode (*destroy)(DS);$/;" m struct:_DSOps destroy include/slepc/private/epsimpl.h /^ PetscErrorCode (*destroy)(EPS);$/;" m struct:_EPSOps destroy include/slepc/private/fnimpl.h /^ PetscErrorCode (*destroy)(FN);$/;" m struct:_FNOps destroy include/slepc/private/mfnimpl.h /^ PetscErrorCode (*destroy)(MFN);$/;" m struct:_MFNOps destroy include/slepc/private/nepimpl.h /^ PetscErrorCode (*destroy)(NEP);$/;" m struct:_NEPOps destroy include/slepc/private/pepimpl.h /^ PetscErrorCode (*destroy)(PEP);$/;" m struct:_PEPOps destroy include/slepc/private/rgimpl.h /^ PetscErrorCode (*destroy)(RG);$/;" m struct:_RGOps destroy include/slepc/private/stimpl.h /^ PetscErrorCode (*destroy)(ST);$/;" m struct:_STOps destroy include/slepc/private/svdimpl.h /^ PetscErrorCode (*destroy)(SVD);$/;" m struct:_SVDOps destroyList src/eps/impls/davidson/davidson.h /^ dvdFunctionList *destroyList;\/* destructor list *\/$/;" m struct:_dvdDashboard detect src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscBool detect; \/* check for zeros during factorizations *\/$/;" m struct:__anon81 diag src/svd/impls/cross/cross.c /^ Vec w,diag;$/;" m struct:__anon110 file: diagA src/eps/impls/davidson/dvdutils.c /^ Vec diagA, diagB;$/;" m struct:__anon73 file: diagB src/eps/impls/davidson/dvdutils.c /^ Vec diagA, diagB;$/;" m struct:__anon73 file: dir src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt dir; \/* Determines the order of values in eig (+1 incr, -1 decr) *\/$/;" m struct:_n_SR dmgen src/eps/examples/tutorials/ex31.c /^ DM dmgen, dmnet; \/* DMs to manage generator and network subsystem *\/$/;" m struct:__anon57 file: dmnet src/eps/examples/tutorials/ex31.c /^ DM dmgen, dmnet; \/* DMs to manage generator and network subsystem *\/$/;" m struct:__anon57 file: dmpgrid src/eps/examples/tutorials/ex31.c /^ DM dmpgrid; \/* Composite DM to manage the entire power grid *\/$/;" m struct:__anon57 file: dot include/slepc/private/bvimpl.h /^ PetscErrorCode (*dot)(BV,BV,Mat);$/;" m struct:_BVOps dotvec include/slepc/private/bvimpl.h /^ PetscErrorCode (*dotvec)(BV,Vec,PetscScalar*);$/;" m struct:_BVOps dotvec_begin include/slepc/private/bvimpl.h /^ PetscErrorCode (*dotvec_begin)(BV,Vec,PetscScalar*);$/;" m struct:_BVOps dotvec_end include/slepc/private/bvimpl.h /^ PetscErrorCode (*dotvec_end)(BV,Vec,PetscScalar*);$/;" m struct:_BVOps dotvec_local include/slepc/private/bvimpl.h /^ PetscErrorCode (*dotvec_local)(BV,Vec,PetscScalar*);$/;" m struct:_BVOps doubleexp src/eps/impls/davidson/davidson.h /^ PetscBool doubleexp; \/* double expansion in GD (GD2) *\/$/;" m struct:__anon65 download_url setup.py /^ download_url=tarball(),$/;" v dq2ri src/eps/examples/tutorials/ex31.c /^PetscErrorCode dq2ri(PetscScalar Fd,PetscScalar Fq,PetscScalar delta,PetscScalar *Fr,PetscScalar *Fi)$/;" f ds include/slepc/private/epsimpl.h /^ DS ds; \/* direct solver object *\/$/;" m struct:_p_EPS ds include/slepc/private/nepimpl.h /^ DS ds; \/* direct solver object *\/$/;" m struct:_p_NEP ds include/slepc/private/pepimpl.h /^ DS ds; \/* direct solver object *\/$/;" m struct:_p_PEP ds include/slepc/private/svdimpl.h /^ DS ds; \/* direct solver object *\/$/;" m struct:_p_SVD dsappendoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dsappendoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f dsappendoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 29;" d file: dsappendoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 39;" d file: dsfactor include/slepc/private/pepimpl.h /^ PetscReal sfactor,dsfactor; \/* scaling factors *\/$/;" m struct:_p_PEP dsfactor src/pep/impls/linear/linearp.h /^ PetscReal sfactor,dsfactor; \/* scaling factors *\/$/;" m struct:__anon106 dsgetoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dsgetoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f dsgetoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 30;" d file: dsgetoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 40;" d file: dsgettype_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dsgettype_(DS *ds,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f dsgettype_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 27;" d file: dsgettype_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 37;" d file: dssetoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dssetoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f dssetoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 28;" d file: dssetoptionsprefix_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 38;" d file: dssettype_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dssettype_(DS *ds,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f dssettype_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 26;" d file: dssettype_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 36;" d file: dssort_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dssort_(DS *ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k,PetscErrorCode *ierr)$/;" f dssort_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 34;" d file: dssort_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 44;" d file: dsvectors_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dsvectors_(DS *ds,DSMatType *mat,PetscInt *j,PetscReal *rnorm,PetscErrorCode *ierr)$/;" f dsvectors_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 33;" d file: dsvectors_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 43;" d file: dsview_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dsview_(DS *ds,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f dsview_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 31;" d file: dsview_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 41;" d file: dsviewmat_ src/sys/classes/ds/interface/ftn-custom/zdsf.c /^PETSC_EXTERN void PETSC_STDCALL dsviewmat_(DS *ds,PetscViewer *viewer,DSMatType *m,PetscErrorCode *ierr)$/;" f dsviewmat_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 32;" d file: dsviewmat_ src/sys/classes/ds/interface/ftn-custom/zdsf.c 42;" d file: dt src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *M4,*w,*wt,*d,*dt;$/;" m struct:__anon105 file: dtol src/pep/impls/krylov/pepkrylov.h /^ PetscReal dtol; \/* tolerance for deflation *\/$/;" m struct:__anon102 duplicate include/slepc/private/bvimpl.h /^ PetscErrorCode (*duplicate)(BV,BV*);$/;" m struct:_BVOps duplicate include/slepc/private/fnimpl.h /^ PetscErrorCode (*duplicate)(FN,MPI_Comm,FN*);$/;" m struct:_FNOps dvdBlackboard src/eps/impls/davidson/davidson.h /^} dvdBlackboard;$/;" t typeref:struct:__anon66 dvdCallback src/eps/impls/davidson/davidson.h /^typedef PetscErrorCode (*dvdCallback)(struct _dvdDashboard*);$/;" t dvdDashboard src/eps/impls/davidson/davidson.h /^} dvdDashboard;$/;" t typeref:struct:_dvdDashboard dvdFunctionList src/eps/impls/davidson/davidson.h /^} dvdFunctionList;$/;" t typeref:struct:_dvdFunctionList dvdHarmonic src/eps/impls/davidson/dvdutils.c /^} dvdHarmonic;$/;" t typeref:struct:__anon72 file: dvdImprovex_gd2 src/eps/impls/davidson/dvdgd2.c /^} dvdImprovex_gd2;$/;" t typeref:struct:__anon67 file: dvdImprovex_jd src/eps/impls/davidson/dvdimprovex.c /^} dvdImprovex_jd;$/;" t typeref:struct:__anon68 file: dvdInitV src/eps/impls/davidson/dvdinitv.c /^} dvdInitV;$/;" t typeref:struct:__anon69 file: dvdJacobiPrecond src/eps/impls/davidson/dvdutils.c /^} dvdJacobiPrecond;$/;" t typeref:struct:__anon73 file: dvdManagV_basic src/eps/impls/davidson/dvdupdatev.c /^} dvdManagV_basic;$/;" t typeref:struct:__anon70 file: dvdPCWrapper src/eps/impls/davidson/dvdutils.c /^} dvdPCWrapper;$/;" t typeref:struct:__anon71 file: dvd_aux_matmult src/eps/impls/davidson/dvdimprovex.c /^PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmult(dvdImprovex_jd *data,const Vec *x,const Vec *y)$/;" f dvd_aux_matmulttrans src/eps/impls/davidson/dvdimprovex.c /^PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmulttrans(dvdImprovex_jd *data,const Vec *x,const Vec *y)$/;" f dvd_calcpairs_apply_arbitrary src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_apply_arbitrary(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscScalar *rr,PetscScalar *ri)$/;" f file: dvd_calcpairs_proj src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_proj(dvdDashboard *d)$/;" f file: dvd_calcpairs_proj_res src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_proj_res(dvdDashboard *d,PetscInt r_s,PetscInt r_e,Vec *R)$/;" f file: dvd_calcpairs_projeig_solve src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_projeig_solve(dvdDashboard *d)$/;" f file: dvd_calcpairs_qz src/eps/impls/davidson/dvdcalcpairs.c /^PetscErrorCode dvd_calcpairs_qz(dvdDashboard *d,dvdBlackboard *b,PetscBool borth,PetscInt cX_proj,PetscBool harm)$/;" f dvd_calcpairs_qz_d src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_qz_d(dvdDashboard *d)$/;" f file: dvd_calcpairs_qz_start src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_qz_start(dvdDashboard *d)$/;" f file: dvd_calcpairs_res_0 src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_res_0(dvdDashboard *d,PetscInt r_s,PetscInt r_e)$/;" f file: dvd_calcpairs_selectPairs src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_selectPairs(dvdDashboard *d,PetscInt n)$/;" f file: dvd_calcpairs_updateBV0_gen src/eps/impls/davidson/dvdcalcpairs.c /^PETSC_STATIC_INLINE PetscErrorCode dvd_calcpairs_updateBV0_gen(dvdDashboard *d,BV bv,DSMatType mat)$/;" f dvd_calcpairs_updateproj src/eps/impls/davidson/dvdcalcpairs.c /^static PetscErrorCode dvd_calcpairs_updateproj(dvdDashboard *d)$/;" f file: dvd_complex_rayleigh_quotient src/eps/impls/davidson/dvdimprovex.c /^PETSC_STATIC_INLINE PetscErrorCode dvd_complex_rayleigh_quotient(Vec ur,Vec ui,Vec Axr,Vec Axi,Vec Bxr,Vec Bxi,PetscScalar *eigr,PetscScalar *eigi)$/;" f dvd_compute_n_rr src/eps/impls/davidson/dvdimprovex.c /^PETSC_STATIC_INLINE PetscErrorCode dvd_compute_n_rr(PetscInt i_s,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,Vec *u,Vec *Ax,Vec *Bx)$/;" f dvd_harm_backtrans src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_harm_backtrans(dvdHarmonic *data,PetscScalar *ar,PetscScalar *ai)$/;" f file: dvd_harm_conf src/eps/impls/davidson/dvdutils.c /^PetscErrorCode dvd_harm_conf(dvdDashboard *d,dvdBlackboard *b,HarmType_t mode,PetscBool fixedTarget,PetscScalar t)$/;" f dvd_harm_d src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_harm_d(dvdDashboard *d)$/;" f file: dvd_harm_eig_backtrans src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_harm_eig_backtrans(dvdDashboard *d,PetscScalar ar,PetscScalar ai,PetscScalar *br,PetscScalar *bi)$/;" f file: dvd_harm_eigs_trans src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_harm_eigs_trans(dvdDashboard *d)$/;" f file: dvd_harm_proj src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_harm_proj(dvdDashboard *d)$/;" f file: dvd_harm_transf src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_harm_transf(dvdHarmonic *dvdh,PetscScalar t)$/;" f file: dvd_harm_updateW src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_harm_updateW(dvdDashboard *d)$/;" f file: dvd_harm_updateproj src/eps/impls/davidson/dvdutils.c /^PetscErrorCode dvd_harm_updateproj(dvdDashboard *d)$/;" f dvd_improvex_apply_proj src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_apply_proj(dvdDashboard *d,Vec *V,PetscInt cV)$/;" f file: dvd_improvex_applytrans_proj src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_applytrans_proj(dvdDashboard *d,Vec *V,PetscInt cV)$/;" f file: dvd_improvex_compute_X src/eps/impls/davidson/dvdimprovex.c /^PetscErrorCode dvd_improvex_compute_X(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u_,PetscScalar *pX,PetscInt ld)$/;" f dvd_improvex_gd2 src/eps/impls/davidson/dvdgd2.c /^PetscErrorCode dvd_improvex_gd2(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs)$/;" f dvd_improvex_gd2_d src/eps/impls/davidson/dvdgd2.c /^static PetscErrorCode dvd_improvex_gd2_d(dvdDashboard *d)$/;" f file: dvd_improvex_gd2_gen src/eps/impls/davidson/dvdgd2.c /^static PetscErrorCode dvd_improvex_gd2_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D)$/;" f file: dvd_improvex_jd src/eps/impls/davidson/dvdimprovex.c /^PetscErrorCode dvd_improvex_jd(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs,PetscInt cX_impr,PetscBool dynamic)$/;" f dvd_improvex_jd_d src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_d(dvdDashboard *d)$/;" f file: dvd_improvex_jd_end src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_end(dvdDashboard *d)$/;" f file: dvd_improvex_jd_gen src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D)$/;" f file: dvd_improvex_jd_lit_const src/eps/impls/davidson/dvdimprovex.c /^PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard *d,dvdBlackboard *b,PetscInt maxits,PetscReal tol,PetscReal fix)$/;" f dvd_improvex_jd_lit_const_0 src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_lit_const_0(dvdDashboard *d,PetscInt i,PetscScalar* theta,PetscScalar* thetai,PetscInt *maxits,PetscReal *tol)$/;" f file: dvd_improvex_jd_proj_cuv src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_proj_cuv(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)$/;" f file: dvd_improvex_jd_proj_uv src/eps/impls/davidson/dvdimprovex.c /^PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard *d,dvdBlackboard *b,ProjType_t p)$/;" f dvd_improvex_jd_proj_uv_KXX src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_proj_uv_KXX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)$/;" f file: dvd_improvex_jd_proj_uv_KZX src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_proj_uv_KZX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)$/;" f file: dvd_improvex_jd_start src/eps/impls/davidson/dvdimprovex.c /^static PetscErrorCode dvd_improvex_jd_start(dvdDashboard *d)$/;" f file: dvd_improvex_precond_d src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_improvex_precond_d(dvdDashboard *d)$/;" f file: dvd_initV src/eps/impls/davidson/dvdinitv.c /^PetscErrorCode dvd_initV(dvdDashboard *d, dvdBlackboard *b, PetscInt k,PetscInt user, PetscBool krylov)$/;" f dvd_initV_classic_0 src/eps/impls/davidson/dvdinitv.c /^static PetscErrorCode dvd_initV_classic_0(dvdDashboard *d)$/;" f file: dvd_initV_d src/eps/impls/davidson/dvdinitv.c /^static PetscErrorCode dvd_initV_d(dvdDashboard *d)$/;" f file: dvd_initV_krylov_0 src/eps/impls/davidson/dvdinitv.c /^static PetscErrorCode dvd_initV_krylov_0(dvdDashboard *d)$/;" f file: dvd_isrestarting_fullV src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_isrestarting_fullV(dvdDashboard *d,PetscBool *r)$/;" f file: dvd_jacobi_precond src/eps/impls/davidson/dvdutils.c /^PetscErrorCode dvd_jacobi_precond(dvdDashboard *d,dvdBlackboard *b)$/;" f dvd_jacobi_precond_0 src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_jacobi_precond_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px)$/;" f file: dvd_jacobi_precond_d src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_jacobi_precond_d(dvdDashboard *d)$/;" f file: dvd_managementV_basic src/eps/impls/davidson/dvdupdatev.c /^PetscErrorCode dvd_managementV_basic(dvdDashboard *d,dvdBlackboard *b,PetscInt bs,PetscInt mpd,PetscInt min_size_V,PetscInt plusk,PetscBool harm,PetscBool allResiduals)$/;" f dvd_managementV_basic_d src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_managementV_basic_d(dvdDashboard *d)$/;" f file: dvd_orthV src/eps/impls/davidson/dvdinitv.c /^PetscErrorCode dvd_orthV(BV V,PetscInt V_new_s,PetscInt V_new_e)$/;" f dvd_precond_none src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_precond_none(dvdDashboard *d,PetscInt i,Vec x,Vec Px)$/;" f file: dvd_schm_basic_conf src/eps/impls/davidson/dvdschm.c /^PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,PetscBool fixedTarget,PetscScalar t,KSP ksp,PetscReal fix,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool dynamic,PetscBool doubleexp)$/;" f dvd_schm_basic_preconf src/eps/impls/davidson/dvdschm.c /^PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,KSP ksp,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool doubleexp)$/;" f dvd_static_precond_PC src/eps/impls/davidson/dvdutils.c /^PetscErrorCode dvd_static_precond_PC(dvdDashboard *d,dvdBlackboard *b,PC pc)$/;" f dvd_static_precond_PC_0 src/eps/impls/davidson/dvdutils.c /^static PetscErrorCode dvd_static_precond_PC_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px)$/;" f file: dvd_testconv_basic src/eps/impls/davidson/dvdtestconv.c /^PetscErrorCode dvd_testconv_basic(dvdDashboard *d, dvdBlackboard *b)$/;" f dvd_testconv_basic_0 src/eps/impls/davidson/dvdtestconv.c /^static PetscBool dvd_testconv_basic_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err)$/;" f file: dvd_testconv_slepc src/eps/impls/davidson/dvdtestconv.c /^PetscErrorCode dvd_testconv_slepc(dvdDashboard *d, dvdBlackboard *b)$/;" f dvd_testconv_slepc_0 src/eps/impls/davidson/dvdtestconv.c /^static PetscBool dvd_testconv_slepc_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err)$/;" f file: dvd_updateV_conv_gen src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_updateV_conv_gen(dvdDashboard *d)$/;" f file: dvd_updateV_extrapol src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_updateV_extrapol(dvdDashboard *d)$/;" f file: dvd_updateV_restart_gen src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_updateV_restart_gen(dvdDashboard *d)$/;" f file: dvd_updateV_start src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_updateV_start(dvdDashboard *d)$/;" f file: dvd_updateV_testConv src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_updateV_testConv(dvdDashboard *d,PetscInt s,PetscInt pre,PetscInt e,PetscInt *nConv)$/;" f file: dvd_updateV_update_gen src/eps/impls/davidson/dvdupdatev.c /^static PetscErrorCode dvd_updateV_update_gen(dvdDashboard *d)$/;" f file: dynamic src/eps/impls/davidson/davidson.h /^ PetscBool dynamic; \/* true if dynamic stopping criterion is used *\/$/;" m struct:__anon65 dynamic src/eps/impls/davidson/dvdimprovex.c /^ PetscBool dynamic; \/* if the dynamic stopping criterion is applied *\/$/;" m struct:__anon68 file: e_Vchanged src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*e_Vchanged)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt);$/;" m struct:_dvdDashboard e_Vchanged_data src/eps/impls/davidson/davidson.h /^ void *e_Vchanged_data;$/;" m struct:_dvdDashboard e_newIteration src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*e_newIteration)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard e_newIteration_data src/eps/impls/davidson/davidson.h /^ void *e_newIteration_data;$/;" m struct:_dvdDashboard eig src/eps/impls/external/blzpack/blzpackp.h /^ PetscScalar *eig;$/;" m struct:__anon76 eigi include/slepc/private/epsimpl.h /^ PetscScalar *eigr,*eigi; \/* real and imaginary parts of eigenvalues *\/$/;" m struct:_p_EPS eigi include/slepc/private/nepimpl.h /^ PetscScalar *eigr,*eigi; \/* real and imaginary parts of eigenvalues *\/$/;" m struct:_p_NEP eigi include/slepc/private/pepimpl.h /^ PetscScalar *eigr,*eigi; \/* real and imaginary parts of eigenvalues *\/$/;" m struct:_p_PEP eigi src/eps/impls/davidson/davidson.h /^ PetscScalar *eigr,*eigi; \/* current eigenvalues *\/$/;" m struct:_dvdDashboard eigi src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscScalar *eigr,*eigi; \/* eigenvalues (for subsolve) *\/$/;" m struct:_n_SR eigr include/slepc/private/epsimpl.h /^ PetscScalar *eigr,*eigi; \/* real and imaginary parts of eigenvalues *\/$/;" m struct:_p_EPS eigr include/slepc/private/nepimpl.h /^ PetscScalar *eigr,*eigi; \/* real and imaginary parts of eigenvalues *\/$/;" m struct:_p_NEP eigr include/slepc/private/pepimpl.h /^ PetscScalar *eigr,*eigi; \/* real and imaginary parts of eigenvalues *\/$/;" m struct:_p_PEP eigr src/eps/impls/davidson/davidson.h /^ PetscScalar *eigr,*eigi; \/* current eigenvalues *\/$/;" m struct:_dvdDashboard eigr src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscScalar *eigr,*eigi; \/* eigenvalues (for subsolve) *\/$/;" m struct:_n_SR emptyarch config/configure.py /^emptyarch = not ('PETSC_ARCH' in os.environ and os.environ['PETSC_ARCH'])$/;" v endList src/eps/impls/davidson/davidson.h /^ dvdFunctionList *endList; \/* ending list *\/$/;" m struct:_dvdDashboard end_ang src/sys/classes/rg/impls/ring/rgring.c /^ PetscReal end_ang; \/* end angle *\/$/;" m struct:__anon127 file: endsWithSuffix bin/maint/generateetags.py /^def endsWithSuffix(file,suffixes):$/;" f enter setup.py /^ def enter(self):$/;" m class:context eps src/eps/examples/tutorials/ex1f90.F90 /^ type(EPS) eps$/;" v program:main eps src/eps/impls/davidson/davidson.h /^ EPS eps; \/* connection to SLEPc *\/$/;" m struct:_dvdDashboard eps src/eps/impls/external/primme/primme.c /^ EPS eps; \/* EPS current context *\/$/;" m struct:__anon78 file: eps src/eps/impls/krylov/krylovschur/krylovschur.h /^ EPS eps; \/* additional eps for slice runs *\/$/;" m struct:__anon81 eps src/nep/impls/slp/slp.c /^ EPS eps; \/* linear eigensolver for T*z = mu*Tp*z *\/$/;" m struct:__anon95 file: eps src/pep/impls/linear/linearp.h /^ EPS eps; \/* linear eigensolver for Az=lBz *\/$/;" m struct:__anon106 eps src/svd/impls/cross/cross.c /^ EPS eps;$/;" m struct:__anon110 file: eps src/svd/impls/cyclic/cyclic.c /^ EPS eps;$/;" m struct:__anon111 file: epsappendoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsappendoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f epsappendoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c 33;" d file: epsappendoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c 60;" d file: epsconvergedabsolute_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsconvergedabsolute_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f epsconvergedabsolute_ src/eps/interface/ftn-custom/zepsf.c 43;" d file: epsconvergedabsolute_ src/eps/interface/ftn-custom/zepsf.c 70;" d file: epsconvergednorm_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsconvergednorm_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f epsconvergednorm_ src/eps/interface/ftn-custom/zepsf.c 45;" d file: epsconvergednorm_ src/eps/interface/ftn-custom/zepsf.c 72;" d file: epsconvergedrelative_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsconvergedrelative_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f epsconvergedrelative_ src/eps/interface/ftn-custom/zepsf.c 44;" d file: epsconvergedrelative_ src/eps/interface/ftn-custom/zepsf.c 71;" d file: epserrorview_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epserrorview_(EPS *eps,EPSErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f epserrorview_ src/eps/interface/ftn-custom/zepsf.c 28;" d file: epserrorview_ src/eps/interface/ftn-custom/zepsf.c 55;" d file: epsgetoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsgetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f epsgetoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c 34;" d file: epsgetoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c 61;" d file: epsgettype_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsgettype_(EPS *eps,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f epsgettype_ src/eps/interface/ftn-custom/zepsf.c 36;" d file: epsgettype_ src/eps/interface/ftn-custom/zepsf.c 63;" d file: epskrylovschurgetinertias_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetinertias_(EPS *eps,PetscInt *nshift,PetscReal *shifts,PetscInt *inertias,PetscErrorCode *ierr)$/;" f epskrylovschurgetinertias_ src/eps/interface/ftn-custom/zepsf.c 52;" d file: epskrylovschurgetinertias_ src/eps/interface/ftn-custom/zepsf.c 79;" d file: epskrylovschurgetsubintervals_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetsubintervals_(EPS *eps,PetscReal *subint,PetscErrorCode *ierr)$/;" f epskrylovschurgetsubintervals_ src/eps/interface/ftn-custom/zepsf.c 51;" d file: epskrylovschurgetsubintervals_ src/eps/interface/ftn-custom/zepsf.c 78;" d file: epskrylovschursetsubintervals_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epskrylovschursetsubintervals_(EPS *eps,PetscReal *subint,PetscErrorCode *ierr)$/;" f epskrylovschursetsubintervals_ src/eps/interface/ftn-custom/zepsf.c 50;" d file: epskrylovschursetsubintervals_ src/eps/interface/ftn-custom/zepsf.c 77;" d file: epsmonitorall_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void epsmonitorall_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f epsmonitorall_ src/eps/interface/ftn-custom/zepsf.c 37;" d file: epsmonitorall_ src/eps/interface/ftn-custom/zepsf.c 64;" d file: epsmonitorconverged_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void epsmonitorconverged_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)$/;" f epsmonitorconverged_ src/eps/interface/ftn-custom/zepsf.c 41;" d file: epsmonitorconverged_ src/eps/interface/ftn-custom/zepsf.c 68;" d file: epsmonitorfirst_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void epsmonitorfirst_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f epsmonitorfirst_ src/eps/interface/ftn-custom/zepsf.c 42;" d file: epsmonitorfirst_ src/eps/interface/ftn-custom/zepsf.c 69;" d file: epsmonitorlg_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void epsmonitorlg_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f epsmonitorlg_ src/eps/interface/ftn-custom/zepsf.c 38;" d file: epsmonitorlg_ src/eps/interface/ftn-custom/zepsf.c 65;" d file: epsmonitorlgall_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void epsmonitorlgall_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f epsmonitorlgall_ src/eps/interface/ftn-custom/zepsf.c 39;" d file: epsmonitorlgall_ src/eps/interface/ftn-custom/zepsf.c 66;" d file: epsmonitorset_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsmonitorset_(EPS *eps,void (PETSC_STDCALL *monitor)(EPS*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)$/;" f epsmonitorset_ src/eps/interface/ftn-custom/zepsf.c 40;" d file: epsmonitorset_ src/eps/interface/ftn-custom/zepsf.c 67;" d file: epsreasonview_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsreasonview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f epsreasonview_ src/eps/interface/ftn-custom/zepsf.c 29;" d file: epsreasonview_ src/eps/interface/ftn-custom/zepsf.c 56;" d file: epssetarbitraryselection_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epssetarbitraryselection_(EPS *eps,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,Vec*,Vec*,PetscScalar*,PetscScalar*,void*,PetscErrorCode*),void *ctx,PetscErrorCode *ierr)$/;" f epssetarbitraryselection_ src/eps/interface/ftn-custom/zepsf.c 49;" d file: epssetarbitraryselection_ src/eps/interface/ftn-custom/zepsf.c 76;" d file: epssetconvergencetestfunction_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epssetconvergencetestfunction_(EPS *eps,void (PETSC_STDCALL *func)(EPS*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f epssetconvergencetestfunction_ src/eps/interface/ftn-custom/zepsf.c 46;" d file: epssetconvergencetestfunction_ src/eps/interface/ftn-custom/zepsf.c 73;" d file: epsseteigenvaluecomparison_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsseteigenvaluecomparison_(EPS *eps,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr)$/;" f epsseteigenvaluecomparison_ src/eps/interface/ftn-custom/zepsf.c 48;" d file: epsseteigenvaluecomparison_ src/eps/interface/ftn-custom/zepsf.c 75;" d file: epssetoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epssetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f epssetoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c 32;" d file: epssetoptionsprefix_ src/eps/interface/ftn-custom/zepsf.c 59;" d file: epssetstoppingtestfunction_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epssetstoppingtestfunction_(EPS *eps,void (PETSC_STDCALL *func)(EPS*,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f epssetstoppingtestfunction_ src/eps/interface/ftn-custom/zepsf.c 47;" d file: epssetstoppingtestfunction_ src/eps/interface/ftn-custom/zepsf.c 74;" d file: epssettype_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epssettype_(EPS *eps,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f epssettype_ src/eps/interface/ftn-custom/zepsf.c 35;" d file: epssettype_ src/eps/interface/ftn-custom/zepsf.c 62;" d file: epsstoppingbasic_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsstoppingbasic_(EPS *eps,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,EPSConvergedReason *reason,void *ctx,PetscErrorCode *ierr)$/;" f epsvaluesview_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsvaluesview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f epsvaluesview_ src/eps/interface/ftn-custom/zepsf.c 30;" d file: epsvaluesview_ src/eps/interface/ftn-custom/zepsf.c 57;" d file: epsvectorsview_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsvectorsview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f epsvectorsview_ src/eps/interface/ftn-custom/zepsf.c 31;" d file: epsvectorsview_ src/eps/interface/ftn-custom/zepsf.c 58;" d file: epsview_ src/eps/interface/ftn-custom/zepsf.c /^PETSC_EXTERN void PETSC_STDCALL epsview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f epsview_ src/eps/interface/ftn-custom/zepsf.c 27;" d file: epsview_ src/eps/interface/ftn-custom/zepsf.c 54;" d file: errest include/slepc/private/epsimpl.h /^ PetscReal *errest; \/* error estimates *\/$/;" m struct:_p_EPS errest include/slepc/private/mfnimpl.h /^ PetscReal errest; \/* error estimate *\/$/;" m struct:_p_MFN errest include/slepc/private/nepimpl.h /^ PetscReal *errest; \/* error estimates *\/$/;" m struct:_p_NEP errest include/slepc/private/pepimpl.h /^ PetscReal *errest; \/* error estimates *\/$/;" m struct:_p_PEP errest include/slepc/private/svdimpl.h /^ PetscReal *errest; \/* error estimates *\/$/;" m struct:_p_SVD errest src/eps/impls/davidson/davidson.h /^ PetscReal *errest; \/* relative error eigenpairs *\/$/;" m struct:_dvdDashboard errest src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal *errest; \/* error estimates (for subsolve) *\/$/;" m struct:_n_SR errorifnotconverged include/slepc/private/mfnimpl.h /^ PetscBool errorifnotconverged; \/* error out if MFNSolve() does not converge *\/$/;" m struct:_p_MFN est_eig src/eps/impls/ciss/ciss.c /^ PetscReal est_eig;$/;" m struct:__anon61 file: est_eig src/nep/impls/ciss/nciss.c /^ PetscReal est_eig;$/;" m struct:__anon89 file: evaluatederivative include/slepc/private/fnimpl.h /^ PetscErrorCode (*evaluatederivative)(FN,PetscScalar,PetscScalar*);$/;" m struct:_FNOps evaluatefunction include/slepc/private/fnimpl.h /^ PetscErrorCode (*evaluatefunction)(FN,PetscScalar,PetscScalar*);$/;" m struct:_FNOps evaluatefunctionmat include/slepc/private/fnimpl.h /^ PetscErrorCode (*evaluatefunctionmat)(FN,Mat,Mat);$/;" m struct:_FNOps evaluatefunctionmatsym include/slepc/private/fnimpl.h /^ PetscErrorCode (*evaluatefunctionmatsym)(FN,Mat,Mat);$/;" m struct:_FNOps evaluatefunctionmatvec include/slepc/private/fnimpl.h /^ PetscErrorCode (*evaluatefunctionmatvec)(FN,Mat,Vec);$/;" m struct:_FNOps evaluatefunctionmatvecsym include/slepc/private/fnimpl.h /^ PetscErrorCode (*evaluatefunctionmatvecsym)(FN,Mat,Vec);$/;" m struct:_FNOps exit setup.py /^ def exit(self):$/;" m class:context explicitmatrix src/pep/impls/linear/linearp.h /^ PetscBool explicitmatrix;$/;" m struct:__anon106 explicitmatrix src/svd/impls/cyclic/cyclic.c /^ PetscBool explicitmatrix;$/;" m struct:__anon111 file: ext src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal ext[2]; \/* Limits for accepted values *\/$/;" m struct:_n_shift externalpackages config/configure.py /^externalpackages = [arpack, blopex, blzpack, feast, primme, trlan]$/;" v extract include/slepc/private/pepimpl.h /^ PEPExtract extract; \/* type of extraction used *\/$/;" m struct:_p_PEP extraction include/slepc/private/epsimpl.h /^ EPSExtraction extraction; \/* which kind of extraction to be applied *\/$/;" m struct:_p_EPS extraction src/eps/impls/ciss/ciss.c /^ EPSCISSExtraction extraction;$/;" m struct:__anon61 file: extractvectors include/slepc/private/pepimpl.h /^ PetscErrorCode (*extractvectors)(PEP);$/;" m struct:_PEPOps extrarow include/slepc/private/dsimpl.h /^ PetscBool extrarow; \/* assume the matrix dimension is (n+1) x n *\/$/;" m struct:_p_DS f config/configure.py /^ f = open(os.path.join(confdir,'slepcvariables'),'r')$/;" v f include/slepc/private/nepimpl.h /^ FN *f; \/* matrix functions of split form *\/$/;" m struct:_p_NEP f src/eps/impls/davidson/davidson.h /^ dvdCallback f;$/;" m struct:_dvdFunctionList f src/sys/classes/ds/impls/nep/dsnep.c /^ FN f[DS_NUM_EXTRA]; \/* functions defining the nonlinear operator *\/$/;" m struct:__anon119 file: f1 src/sys/classes/fn/impls/combine/fncombine.c /^ FN f1,f2; \/* functions *\/$/;" m struct:__anon121 file: f2 src/sys/classes/fn/impls/combine/fncombine.c /^ FN f1,f2; \/* functions *\/$/;" m struct:__anon121 file: feast config/configure.py /^feast = feast.Feast(argdb,log)$/;" v fih src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *fih,*work,*M4;$/;" m struct:__anon104 file: finalize_options setup.py /^ def finalize_options(self):$/;" m class:cmd_install fix src/eps/impls/davidson/davidson.h /^ PetscReal fix; \/* the fix parameter *\/$/;" m struct:__anon65 fix src/eps/impls/davidson/dvdimprovex.c /^ PetscReal fix; \/* tolerance for using the approx. eigenvalue *\/$/;" m struct:__anon68 file: fixConf config/install.py /^ def fixConf(self):$/;" m class:Installer fixConfFile config/install.py /^ def fixConfFile(self, src):$/;" m class:Installer fn include/slepc/private/mfnimpl.h /^ FN fn; \/* which function to compute *\/$/;" m struct:_p_MFN fn src/nep/interface/neprefine.c /^ FN *fn;$/;" m struct:__anon97 file: fnappendoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c /^PETSC_EXTERN void PETSC_STDCALL fnappendoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f fnappendoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 29;" d file: fnappendoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 36;" d file: fngetoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c /^PETSC_EXTERN void PETSC_STDCALL fngetoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f fngetoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 30;" d file: fngetoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 37;" d file: fngettype_ src/sys/classes/fn/interface/ftn-custom/zfnf.c /^PETSC_EXTERN void PETSC_STDCALL fngettype_(FN *fn,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f fngettype_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 32;" d file: fngettype_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 39;" d file: fnsetoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c /^PETSC_EXTERN void PETSC_STDCALL fnsetoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f fnsetoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 28;" d file: fnsetoptionsprefix_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 35;" d file: fnsettype_ src/sys/classes/fn/interface/ftn-custom/zfnf.c /^PETSC_EXTERN void PETSC_STDCALL fnsettype_(FN *fn,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f fnsettype_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 31;" d file: fnsettype_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 38;" d file: fnview_ src/sys/classes/fn/interface/ftn-custom/zfnf.c /^PETSC_EXTERN void PETSC_STDCALL fnview_(FN *fn,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f fnview_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 27;" d file: fnview_ src/sys/classes/fn/interface/ftn-custom/zfnf.c 34;" d file: format include/slepc/private/slepcimpl.h /^ PetscViewerFormat format;$/;" m struct:_n_SlepcConvMonitor freq src/eps/examples/tutorials/ex31.c 77;" d file: friends include/slepc/private/vecimplslepc.h /^ PetscInt friends; \/* number of vectors sharing this structure *\/$/;" m struct:__anon7 friends src/eps/impls/davidson/dvdimprovex.c /^ Vec friends; \/* reference vector for composite vectors *\/$/;" m struct:__anon68 file: fui include/slepc/private/nepimpl.h /^ NEPUserInterface fui; \/* how the user has defined the nonlinear operator *\/$/;" m struct:_p_NEP function include/slepc/private/nepimpl.h /^ Mat function; \/* function matrix *\/$/;" m struct:_p_NEP function_pre include/slepc/private/nepimpl.h /^ Mat function_pre; \/* function matrix (preconditioner) *\/$/;" m struct:_p_NEP functionctx include/slepc/private/nepimpl.h /^ void *functionctx;$/;" m struct:_p_NEP gamma src/pep/impls/jd/pjdp.h /^ PetscScalar gamma; \/* precomputed scalar u'*B\\p *\/$/;" m struct:__anon100 gbus src/eps/examples/tutorials/ex31.c /^const PetscInt gbus[3] = {0,1,2}; \/* Buses at which generators are incident *\/$/;" v gen_gnumake config/gmakegen.py /^ def gen_gnumake(self, fd):$/;" m class:Slepc gen_pkg config/gmakegen.py /^ def gen_pkg(self, pkg):$/;" m class:Slepc get_outputs setup.py /^ def get_outputs(self):$/;" m class:cmd_install get_petsc_arch setup.py /^def get_petsc_arch():$/;" f get_petsc_dir setup.py /^def get_petsc_dir():$/;" f get_sources config/gmakegen.py /^ def get_sources(self, makevars):$/;" m class:Slepc getarray include/slepc/private/bvimpl.h /^ PetscErrorCode (*getarray)(BV,PetscScalar**);$/;" m struct:_BVOps getarrayread include/slepc/private/bvimpl.h /^ PetscErrorCode (*getarrayread)(BV,const PetscScalar**);$/;" m struct:_BVOps getbilinearform include/slepc/private/stimpl.h /^ PetscErrorCode (*getbilinearform)(ST,Mat*);$/;" m struct:_STOps getcolumn include/slepc/private/bvimpl.h /^ PetscErrorCode (*getcolumn)(BV,PetscInt,Vec*);$/;" m struct:_BVOps global src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscBool global; \/* flag distinguishing global from local eps *\/$/;" m struct:__anon81 globaleps src/eps/impls/external/trlan/trlan.c /^static EPS globaleps;$/;" v file: globconf config/configure.py /^ globconf = CreateFile(os.path.join(slepc.dir,'lib','slepc','conf'),'slepcvariables',log)$/;" v guess include/slepc/private/vecimplslepc.h /^ PetscInt guess; \/* expected maximum number of vectors *\/$/;" m struct:VecPool_ h include/slepc/private/bvimpl.h /^ PetscScalar *h,*c; \/* orthogonalization coefficients *\/$/;" m struct:_p_BV h src/nep/examples/tutorials/ex20.c /^ PetscReal h; \/* mesh spacing *\/$/;" m struct:__anon86 file: h src/nep/examples/tutorials/ex21.c /^ PetscReal h; \/* mesh spacing *\/$/;" m struct:__anon88 file: h src/nep/examples/tutorials/ex21.c /^ PetscReal h;$/;" m struct:__anon87 file: hasEnd src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscBool hasEnd; \/* Tells whether the interval has an end *\/$/;" m struct:_n_SR help docs/manual/ex1.c /^static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension.\\n\\n"$/;" v file: help src/eps/examples/tests/test1.c /^static char help[] = "Tests B-orthonormality of eigenvectors in a GHEP problem.\\n\\n";$/;" v file: help src/eps/examples/tests/test10.c /^static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\\n\\n"$/;" v file: help src/eps/examples/tests/test11.c /^static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion."$/;" v file: help src/eps/examples/tests/test12.c /^static char help[] = "Diagonal eigenproblem. Illustrates use of shell preconditioner.\\n\\n"$/;" v file: help src/eps/examples/tests/test13.c /^static char help[] = "Test EPSSetArbitrarySelection.\\n\\n";$/;" v file: help src/eps/examples/tests/test14.c /^static char help[] = "Test EPS interface functions.\\n\\n";$/;" v file: help src/eps/examples/tests/test16.c /^static char help[] = "Tests a user-defined convergence test.\\n\\n";$/;" v file: help src/eps/examples/tests/test2.c /^static char help[] = "Tests multiple calls to EPSSolve with the same matrix.\\n\\n";$/;" v file: help src/eps/examples/tests/test3.c /^static char help[] = "Tests multiple calls to EPSSolve with different matrix.\\n\\n";$/;" v file: help src/eps/examples/tests/test4.c /^static char help[] = "Test the solution of a HEP without calling EPSSetFromOptions (based on ex1.c).\\n\\n"$/;" v file: help src/eps/examples/tests/test5.c /^static char help[] = "Test EPS with different builds with a matrix loaded from a file.\\n"$/;" v file: help src/eps/examples/tests/test6.c /^static char help[] = "Diagonal eigenproblem.\\n\\n"$/;" v file: help src/eps/examples/tests/test8.c /^static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. "$/;" v file: help src/eps/examples/tests/test9.c /^static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. "$/;" v file: help src/eps/examples/tutorials/ex1.c /^static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex10.c /^static char help[] = "Illustrates the use of shell spectral transformations. "$/;" v file: help src/eps/examples/tutorials/ex11.c /^static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex12.c /^static char help[] = "Compute all eigenvalues in an interval of a symmetric-definite problem.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex13.c /^static char help[] = "Generalized Symmetric eigenproblem.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex18.c /^static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion."$/;" v file: help src/eps/examples/tutorials/ex19.c /^static char help[] = "Standard symmetric eigenproblem for the 3-D Laplacian built with the DM interface.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex2.c /^static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 2 dimensions.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex24.c /^static char help[] = "Spectrum folding for a standard symmetric eigenproblem.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex25.c /^static char help[] = "Spectrum slicing on generalized symmetric eigenproblem.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex29.c /^static char help[] = "Solves the same problem as in ex5, with a user-defined stopping test."$/;" v file: help src/eps/examples/tutorials/ex3.c /^static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. "$/;" v file: help src/eps/examples/tutorials/ex30.c /^static char help[] = "Illustrates the use of a region for filtering; the number of wanted eigenvalues in not known a priori.\\n\\n"$/;" v file: help src/eps/examples/tutorials/ex31.c /^static char help[] = "Power grid small signal stability analysis of WECC 9 bus system.\\n\\$/;" v file: help src/eps/examples/tutorials/ex4.c /^static char help[] = "Solves a standard eigensystem Ax=kx with the matrix loaded from a file.\\n"$/;" v file: help src/eps/examples/tutorials/ex5.c /^static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. "$/;" v file: help src/eps/examples/tutorials/ex7.c /^static char help[] = "Solves a generalized eigensystem Ax=kBx with matrices loaded from a file.\\n"$/;" v file: help src/eps/examples/tutorials/ex9.c /^static char help[] = "Solves a problem associated to the Brusselator wave model in chemical reactions, illustrating the use of shell matrices.\\n\\n"$/;" v file: help src/mfn/examples/tests/test1.c /^static char help[] = "Computes exp(A)*v for a matrix loaded from file.\\n\\n"$/;" v file: help src/mfn/examples/tutorials/ex23.c /^static char help[] = "Computes exp(t*A)*v for a matrix associated with a Markov model.\\n\\n"$/;" v file: help src/mfn/examples/tutorials/ex26.c /^static char help[] = "Computes the action of the square root of the 2-D Laplacian.\\n\\n"$/;" v file: help src/nep/examples/nlevp/gun.c /^static char help[] = "Radio-frequency gun cavity.\\n\\n"$/;" v file: help src/nep/examples/nlevp/loaded_string.c /^static char help[] = "Finite element model of a loaded vibrating string.\\n\\n"$/;" v file: help src/nep/examples/tutorials/ex20.c /^static char help[] = "Simple 1-D nonlinear eigenproblem.\\n\\n"$/;" v file: help src/nep/examples/tutorials/ex21.c /^static char help[] = "Simple 1-D nonlinear eigenproblem (matrix-free version, sequential).\\n\\n"$/;" v file: help src/nep/examples/tutorials/ex22.c /^static char help[] = "Delay differential equation.\\n\\n"$/;" v file: help src/nep/examples/tutorials/ex27.c /^static char help[] = "Simple nonlinear eigenproblem using the NLEIGS solver.\\n\\n"$/;" v file: help src/pep/examples/nlevp/acoustic_wave_1d.c /^static char help[] = "Quadratic eigenproblem from an acoustics application (1-D).\\n\\n"$/;" v file: help src/pep/examples/nlevp/acoustic_wave_2d.c /^static char help[] = "Quadratic eigenproblem from an acoustics application (2-D).\\n\\n"$/;" v file: help src/pep/examples/nlevp/butterfly.c /^static char help[] = "Quartic polynomial eigenproblem with T-even structure.\\n\\n"$/;" v file: help src/pep/examples/nlevp/damped_beam.c /^static char help[] = "Quadratic eigenproblem from the vibrarion analysis of a beam.\\n\\n"$/;" v file: help src/pep/examples/nlevp/pdde_stability.c /^static char help[] = "Stability analysis of a discretized partial delay-differential equation.\\n\\n"$/;" v file: help src/pep/examples/nlevp/planar_waveguide.c /^static char help[] = "FEM solution of the propagation constants in a six-layer planar waveguide.\\n\\n"$/;" v file: help src/pep/examples/nlevp/sleeper.c /^static char help[] = "Oscillations of a rail track resting on sleepers.\\n\\n"$/;" v file: help src/pep/examples/nlevp/spring.c /^static char help[] = "FEM model of a damped mass-spring system.\\n\\n"$/;" v file: help src/pep/examples/tests/test1.c /^static char help[] = "Test the solution of a PEP without calling PEPSetFromOptions (based on ex16.c).\\n\\n"$/;" v file: help src/pep/examples/tests/test2.c /^static char help[] = "Test the solution of a PEP from a finite element model of "$/;" v file: help src/pep/examples/tests/test3.c /^static char help[] = "Test PEP interface functions.\\n\\n";$/;" v file: help src/pep/examples/tutorials/ex16.c /^static char help[] = "Simple quadratic eigenvalue problem.\\n\\n"$/;" v file: help src/pep/examples/tutorials/ex17.c /^static char help[] = "Solves a polynomial eigenproblem P(l)x = 0 with matrices loaded from a file.\\n\\n"$/;" v file: help src/pep/examples/tutorials/ex28.c /^static char help[] = "A quadratic eigenproblem defined using shell matrices.\\n\\n"$/;" v file: help src/svd/examples/tests/test1.c /^static char help[] = "Test the solution of a SVD without calling SVDSetFromOptions (based on ex8.c).\\n\\n"$/;" v file: help src/svd/examples/tests/test2.c /^static char help[] = "Test SVD with different builds with a matrix loaded from a file"$/;" v file: help src/svd/examples/tests/test3.c /^static char help[] = "Test SVD with user-provided initial vectors.\\n\\n"$/;" v file: help src/svd/examples/tutorials/ex14.c /^static char help[] = "Solves a singular value problem with the matrix loaded from a file.\\n"$/;" v file: help src/svd/examples/tutorials/ex15.c /^static char help[] = "Singular value decomposition of the Lauchli matrix.\\n"$/;" v file: help src/svd/examples/tutorials/ex8.c /^static char help[] = "Estimates the 2-norm condition number of a matrix A, that is, the ratio of the largest to the smallest singular values of A. "$/;" v file: help src/sys/classes/bv/examples/tests/test1.c /^static char help[] = "Test BV operations.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test10.c /^static char help[] = "Test split reductions in BV.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test11.c /^static char help[] = "Test BV block orthogonalization.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test12.c /^static char help[] = "Test block orthogonalization on a rank-deficient BV.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test2.c /^static char help[] = "Test BV orthogonalization functions.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test3.c /^static char help[] = "Test BV operations with non-standard inner product.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test4.c /^static char help[] = "Test BV operations, changing the number of active columns.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test5.c /^static char help[] = "Test BV operations with indefinite inner product.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test6.c /^static char help[] = "Test BV orthogonalization functions with constraints.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test7.c /^static char help[] = "Test multiplication of a Mat times a BV.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test8.c /^static char help[] = "Test BV orthogonalization with selected columns.\\n\\n";$/;" v file: help src/sys/classes/bv/examples/tests/test9.c /^static char help[] = "Test BV matrix projection.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test1.c /^static char help[] = "Test DSNHEP.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test12.c /^static char help[] = "Test DSNEP.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test13.c /^static char help[] = "Test DSHEP with block size larger than one.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test15.c /^static char help[] = "Test DSPEP.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test2.c /^static char help[] = "Test DSHEP.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test3.c /^static char help[] = "Test DSHEP with compact storage.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test4.c /^static char help[] = "Test DSGNHEP.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test5.c /^static char help[] = "Test DSGHIEP.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test6.c /^static char help[] = "Test DSGHIEP with compact storage.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test7.c /^static char help[] = "Test DSSVD.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test8.c /^static char help[] = "Test DSSVD with compact storage.\\n\\n";$/;" v file: help src/sys/classes/ds/examples/tests/test9.c /^static char help[] = "Test DSGHEP.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test1.c /^static char help[] = "Test rational function.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test2.c /^static char help[] = "Test exponential function.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test3.c /^static char help[] = "Test matrix exponential.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test4.c /^static char help[] = "Test setting FN parameters from the command line.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test5.c /^static char help[] = "Test matrix rational function.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test6.c /^static char help[] = "Test combined function.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test7.c /^static char help[] = "Test matrix square root.\\n\\n";$/;" v file: help src/sys/classes/fn/examples/tests/test8.c /^static char help[] = "Test matrix inverse square root.\\n\\n";$/;" v file: help src/sys/classes/rg/examples/tests/test1.c /^static char help[] = "Test RG interface functions.\\n\\n";$/;" v file: help src/sys/classes/st/examples/tests/test1.c /^static char help[] = "Test ST with shell matrices.\\n\\n";$/;" v file: help src/sys/classes/st/examples/tests/test2.c /^static char help[] = "Test ST with one matrix.\\n\\n";$/;" v file: help src/sys/classes/st/examples/tests/test3.c /^static char help[] = "Test ST with two matrices.\\n\\n";$/;" v file: help src/sys/classes/st/examples/tests/test4.c /^static char help[] = "Test ST with four matrices.\\n\\n";$/;" v file: iXKZ src/eps/impls/davidson/dvdimprovex.c /^ PetscScalar *iXKZ; \/* inverse of XKZ *\/$/;" m struct:__anon68 file: iXKZPivots src/eps/impls/davidson/dvdimprovex.c /^ PetscBLASInt *iXKZPivots; \/* array of pivots *\/$/;" m struct:__anon68 file: id include/slepc/private/bvimpl.h /^ PetscObjectId id[2]; \/* object id of obtained vectors *\/$/;" m struct:_p_BV idx src/pep/impls/krylov/toar/nrefine.c /^ PetscInt idx,*cols;$/;" m struct:__anon105 file: idx src/sys/classes/ds/impls/ghiep/invit.c /^ PetscInt idx[2];$/;" m struct:HRtr file: idxDef src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt *idxDef; \/* For deflation *\/$/;" m struct:_n_SR idxg src/pep/impls/krylov/toar/nrefine.c /^ PetscInt *map0,*map1,*idxg,*idxp;$/;" m struct:__anon105 file: idxp src/pep/impls/krylov/toar/nrefine.c /^ PetscInt *map0,*map1,*idxg,*idxp;$/;" m struct:__anon105 file: idxrk src/nep/impls/nleigs/nleigs.c /^ PetscInt idxrk; \/* index of next shift to use *\/$/;" m struct:__anon92 file: ii src/eps/impls/external/blopex/blopex.c /^ mv_InterfaceInterpreter ii;$/;" m struct:__anon75 file: impltrans include/slepc/private/svdimpl.h /^ PetscBool impltrans; \/* implicit transpose mode *\/$/;" m struct:_p_SVD improveX src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*improveX)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt*);$/;" m struct:_dvdDashboard improveX_data src/eps/impls/davidson/davidson.h /^ void *improveX_data;$/;" m struct:_dvdDashboard improvex_jd_lit src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*improvex_jd_lit)(struct _dvdDashboard*,PetscInt,PetscScalar*,PetscScalar*,PetscInt*,PetscReal*);$/;" m struct:_dvdDashboard improvex_jd_proj_uv src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*improvex_jd_proj_uv)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*,Vec*,Vec*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt);$/;" m struct:_dvdDashboard improvex_precond src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*improvex_precond)(struct _dvdDashboard*,PetscInt,Vec,Vec);$/;" m struct:_dvdDashboard improvex_precond_data src/eps/impls/davidson/davidson.h /^ void *improvex_precond_data;$/;" m struct:_dvdDashboard includedir config/configure.py /^includedir = CreateDir(archdir,'include',log)$/;" v inconf config/gmakegen.py /^ def inconf(self, key, val):$/;" m class:Slepc indef include/slepc/private/bvimpl.h /^ PetscBool indef; \/* matrix is indefinite *\/$/;" m struct:_p_BV index src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt index; \/* Index in eig where found values are stored *\/$/;" m struct:_n_shift indexEig src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt indexEig;$/;" m struct:_n_SR inertia src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt inertia;$/;" m struct:_n_shift inertia0 src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt inertia0,inertia1;$/;" m struct:_n_SR inertia1 src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt inertia0,inertia1;$/;" m struct:_n_SR inertias src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt *inertias; \/* array containing global inertias *\/$/;" m struct:__anon81 initV src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*initV)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard initV_data src/eps/impls/davidson/davidson.h /^ void *initV_data;$/;" m struct:_dvdDashboard initialize_options setup.py /^ def initialize_options(self):$/;" m class:cmd_install initialsize src/eps/impls/davidson/davidson.h /^ PetscInt initialsize; \/* initial size of V *\/$/;" m struct:__anon65 install setup.py /^def install(dest_dir, dry_run=False):$/;" f installBin config/install.py /^ def installBin(self):$/;" m class:Installer installConf config/install.py /^ def installConf(self):$/;" m class:Installer installIncludes config/install.py /^ def installIncludes(self):$/;" m class:Installer installLib config/install.py /^ def installLib(self):$/;" m class:Installer installShare config/install.py /^ def installShare(self):$/;" m class:Installer int0 src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal int0,int1; \/* Extremes of the interval *\/$/;" m struct:_n_SR int1 src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal int0,int1; \/* Extremes of the interval *\/$/;" m struct:_n_SR inta include/slepc/private/epsimpl.h /^ PetscReal inta,intb; \/* interval [a,b] for spectrum slicing *\/$/;" m struct:_p_EPS intb include/slepc/private/epsimpl.h /^ PetscReal inta,intb; \/* interval [a,b] for spectrum slicing *\/$/;" m struct:_p_EPS ipB src/eps/impls/davidson/davidson.h /^ PetscBool ipB; \/* true if B-ortho is used *\/$/;" m struct:__anon65 isGhost src/eps/impls/ciss/ciss.c /^static PetscErrorCode isGhost(EPS eps,PetscInt ld,PetscInt nv,PetscBool *fl)$/;" f file: isGhost src/nep/impls/ciss/nciss.c /^static PetscErrorCode isGhost(NEP nep,PetscInt ld,PetscInt nv,PetscBool *fl)$/;" f file: isRestarting src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*isRestarting)(struct _dvdDashboard*,PetscBool*);$/;" m struct:_dvdDashboard isRestarting_data src/eps/impls/davidson/davidson.h /^ void *isRestarting_data;$/;" m struct:_dvdDashboard is_alg src/eps/examples/tutorials/ex31.c /^ IS is_alg; \/* indices for algebraic equations *\/$/;" m struct:__anon57 file: is_diff src/eps/examples/tutorials/ex31.c /^ IS is_diff; \/* indices for differential equations *\/$/;" m struct:__anon57 file: iscol src/eps/impls/krylov/krylovschur/krylovschur.h /^ IS isrow,iscol; \/* index sets used in update of subcomm mats *\/$/;" m struct:__anon81 isgeneralized include/slepc/private/epsimpl.h /^ PetscBool isgeneralized;$/;" m struct:_p_EPS ishermitian include/slepc/private/epsimpl.h /^ PetscBool ishermitian;$/;" m struct:_p_EPS ispositive include/slepc/private/epsimpl.h /^ PetscBool ispositive;$/;" m struct:_p_EPS isreal src/eps/impls/ciss/ciss.c /^ PetscBool isreal; \/* A and B are real *\/$/;" m struct:__anon61 file: isreal src/nep/impls/ciss/nciss.c /^ PetscBool isreal; \/* T(z) is real for real z *\/$/;" m struct:__anon89 file: isrow src/eps/impls/krylov/krylovschur/krylovschur.h /^ IS isrow,iscol; \/* index sets used in update of subcomm mats *\/$/;" m struct:__anon81 istor src/eps/impls/external/blzpack/blzpackp.h /^ PetscBLASInt *istor;$/;" m struct:__anon76 istrivial include/slepc/private/rgimpl.h /^ PetscErrorCode (*istrivial)(RG,PetscBool*);$/;" m struct:_RGOps iterCompl src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt iterCompl;$/;" m struct:_n_SR its include/slepc/private/epsimpl.h /^ PetscInt its; \/* number of iterations so far computed *\/$/;" m struct:_p_EPS its include/slepc/private/mfnimpl.h /^ PetscInt its; \/* number of iterations so far computed *\/$/;" m struct:_p_MFN its include/slepc/private/nepimpl.h /^ PetscInt its; \/* number of iterations so far computed *\/$/;" m struct:_p_NEP its include/slepc/private/pepimpl.h /^ PetscInt its; \/* number of iterations so far computed *\/$/;" m struct:_p_PEP its include/slepc/private/svdimpl.h /^ PetscInt its; \/* iteration counter *\/$/;" m struct:_p_SVD itsKs src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt itsKs; \/* Krylovschur restarts *\/$/;" m struct:_n_SR iwork include/slepc/private/dsimpl.h /^ PetscBLASInt *iwork;$/;" m struct:_p_DS jacobian include/slepc/private/nepimpl.h /^ Mat jacobian; \/* Jacobian matrix *\/$/;" m struct:_p_NEP jacobianctx include/slepc/private/nepimpl.h /^ void *jacobianctx;$/;" m struct:_p_NEP k include/slepc/private/bvimpl.h /^ PetscInt k; \/* number of active columns *\/$/;" m struct:_p_BV k include/slepc/private/dsimpl.h /^ PetscInt k; \/* intermediate dimension (e.g. position of arrow) *\/$/;" m struct:_p_DS k src/eps/impls/davidson/dvdinitv.c /^ PetscInt k; \/* desired initial subspace size *\/$/;" m struct:__anon69 file: k src/pep/impls/krylov/toar/nrefine.c /^ PetscInt k,nmat;$/;" m struct:__anon104 file: k src/sys/classes/fn/impls/phi/fnphi.c /^ PetscInt k; \/* index of the phi-function, defaults to k=1 *\/$/;" m struct:__anon122 file: k1 src/eps/examples/tutorials/ex31.c /^const PetscScalar k1[3] = {0.0039,0.0039,0.0039};$/;" v k2 src/eps/examples/tutorials/ex31.c /^const PetscScalar k2[3] = {1.555,1.555,1.555}; \/* k1 and k2 for calculating the saturation function SE = k1*exp(k2*Efd) *\/$/;" v kappa src/nep/examples/tutorials/ex20.c /^ PetscScalar kappa; \/* ratio between stiffness of spring and attached mass *\/$/;" m struct:__anon86 file: kappa src/nep/examples/tutorials/ex21.c /^ PetscScalar kappa; \/* ratio between stiffness of spring and attached mass *\/$/;" m struct:__anon88 file: kappa src/nep/examples/tutorials/ex21.c /^ PetscScalar lambda,kappa;$/;" m struct:__anon87 file: keep src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal keep; \/* restart parameter *\/$/;" m struct:__anon81 keep src/nep/impls/nleigs/nleigs.c /^ PetscReal keep; \/* restart parameter *\/$/;" m struct:__anon92 file: keep src/pep/impls/jd/pjdp.h /^ PetscReal keep; \/* restart parameter *\/$/;" m struct:__anon99 keep src/pep/impls/krylov/pepkrylov.h /^ PetscReal keep; \/* restart parameter *\/$/;" m struct:__anon102 keep src/pep/impls/krylov/qarnoldi/qarnoldi.c /^ PetscReal keep; \/* restart parameter *\/$/;" m struct:__anon103 file: keywords setup.py /^ keywords = ['SLEPc','PETSc', 'MPI'],$/;" v krylovstart src/eps/impls/davidson/davidson.h /^ PetscBool krylovstart; \/* true if the starting subspace is a Krylov basis *\/$/;" m struct:__anon65 ksp include/slepc/private/stimpl.h /^ KSP ksp;$/;" m struct:_p_ST ksp src/eps/examples/tutorials/ex10.c /^ KSP ksp;$/;" m struct:__anon54 file: ksp src/eps/impls/ciss/ciss.c /^ KSP *ksp;$/;" m struct:__anon61 file: ksp src/eps/impls/davidson/dvdimprovex.c /^ KSP ksp; \/* correction equation solver *\/$/;" m struct:__anon68 file: ksp src/eps/impls/external/primme/primme.c /^ KSP ksp; \/* linear solver and preconditioner *\/$/;" m struct:__anon78 file: ksp src/nep/impls/ciss/nciss.c /^ KSP *ksp;$/;" m struct:__anon89 file: ksp src/nep/impls/narnoldi/narnoldi.c /^ KSP ksp; \/* linear solver object *\/$/;" m struct:__anon91 file: ksp src/nep/impls/nleigs/nleigs.c /^ KSP *ksp; \/* ksp array for storing shift factorizations *\/$/;" m struct:__anon92 file: ksp src/nep/impls/rii/rii.c /^ KSP ksp; \/* linear solver object *\/$/;" m struct:__anon94 file: kspMat src/eps/impls/ciss/ciss.c /^ Mat *kspMat;$/;" m struct:__anon61 file: kspMat src/nep/impls/ciss/nciss.c /^ Mat *kspMat;$/;" m struct:__anon89 file: ksp_max_size src/eps/impls/davidson/dvdimprovex.c /^ PetscInt ksp_max_size; \/* the ksp maximum subvectors size *\/$/;" m struct:__anon68 file: l include/slepc/private/bvimpl.h /^ PetscInt l; \/* number of leading columns *\/$/;" m struct:_p_BV l include/slepc/private/dsimpl.h /^ PetscInt l; \/* number of locked (inactive) leading columns *\/$/;" m struct:_p_DS lN include/slepc/private/vecimplslepc.h /^ PetscInt lN; \/* virtual local size *\/$/;" m struct:__anon7 lag src/nep/impls/rii/rii.c /^ PetscInt lag; \/* interval to rebuild preconditioner *\/$/;" m struct:__anon94 file: lambda src/nep/examples/tutorials/ex21.c /^ PetscScalar lambda,kappa;$/;" m struct:__anon87 file: lapack config/configure.py /^lapack = lapack.Lapack(argdb,log)$/;" v lastTol src/eps/impls/davidson/dvdimprovex.c /^ PetscReal lastTol; \/* last tol for dynamic stopping criterion *\/$/;" m struct:__anon68 file: lastnconv src/eps/examples/tutorials/ex30.c /^ PetscInt lastnconv; \/* last value of nconv; used in stopping test *\/$/;" m struct:__anon56 file: lbus src/eps/examples/tutorials/ex31.c /^const PetscInt lbus[3] = {4,5,7}; \/* Buses at which loads are incident *\/$/;" v ld include/slepc/private/dsimpl.h /^ PetscInt ld; \/* leading dimension *\/$/;" m struct:_p_DS ld src/pep/impls/jd/pjdp.h /^ PetscInt ld;$/;" m struct:__anon100 ld src/pep/impls/krylov/pepkrylov.h /^ PetscInt ld; \/* leading dimension of auxiliary matrices *\/$/;" m struct:__anon102 ldXKZ src/eps/impls/davidson/dvdimprovex.c /^ PetscInt ldXKZ; \/* leading dimension of XKZ *\/$/;" m struct:__anon68 file: ld_alphap src/eps/examples/tutorials/ex31.c /^const PetscScalar ld_alphap[3] = {0.0,0.0,1.0};$/;" v ld_alphaq src/eps/examples/tutorials/ex31.c /^const PetscScalar ld_alphaq[3] = {0.0,0.0,1.0};$/;" v ld_betap src/eps/examples/tutorials/ex31.c /^const PetscScalar ld_betap[3] = {2.0,1.0,0.0};$/;" v ld_betaq src/eps/examples/tutorials/ex31.c /^const PetscScalar ld_betaq[3] = {2.0,1.0,0.0};$/;" v ld_nsegsp src/eps/examples/tutorials/ex31.c /^const PetscInt ld_nsegsp[3] = {3,3,3};$/;" v ld_nsegsq src/eps/examples/tutorials/ex31.c /^const PetscInt ld_nsegsq[3] = {3,3,3};$/;" v ldiXKZ src/eps/impls/davidson/dvdimprovex.c /^ PetscInt ldiXKZ; \/* leading dimension of iXKZ *\/$/;" m struct:__anon68 file: leftbasis include/slepc/private/svdimpl.h /^ PetscBool leftbasis; \/* if U is filled by the solver *\/$/;" m struct:_p_SVD libdir config/configure.py /^libdir = CreateDir(archdir,'lib',log)$/;" v license setup.py /^ license='LGPL',$/;" v lineariz include/slepc/private/pepimpl.h /^ PetscBool lineariz; \/* current solver is based on linearization *\/$/;" m struct:_p_PEP liwork include/slepc/private/dsimpl.h /^ PetscInt lwork,lrwork,liwork;$/;" m struct:_p_DS lock src/eps/impls/cg/lobpcg/lobpcg.c /^ PetscBool lock; \/* soft locking active\/inactive *\/$/;" m struct:__anon59 file: lock src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscBool lock; \/* locking\/non-locking variant *\/$/;" m struct:__anon81 lock src/nep/impls/nleigs/nleigs.c /^ PetscBool lock; \/* locking\/non-locking variant *\/$/;" m struct:__anon92 file: lock src/pep/impls/krylov/pepkrylov.h /^ PetscBool lock; \/* locking\/non-locking variant *\/$/;" m struct:__anon102 lock src/pep/impls/krylov/qarnoldi/qarnoldi.c /^ PetscBool lock; \/* locking\/non-locking variant *\/$/;" m struct:__anon103 file: log config/configure.py /^log = log.Log()$/;" v long_description setup.py /^ long_description='\\n'.join(description),$/;" v lrwork include/slepc/private/dsimpl.h /^ PetscInt lwork,lrwork,liwork;$/;" m struct:_p_DS lwork include/slepc/private/bvimpl.h /^ PetscInt lwork;$/;" m struct:_p_BV lwork include/slepc/private/dsimpl.h /^ PetscInt lwork,lrwork,liwork;$/;" m struct:_p_DS lwork src/eps/impls/external/trlan/trlanp.h /^ PetscBLASInt lwork;$/;" m struct:__anon79 lworkl src/eps/impls/external/arpack/arpackp.h /^ PetscBLASInt lworkl;$/;" m struct:__anon74 m include/slepc/private/bvimpl.h /^ PetscInt m; \/* number of vectors *\/$/;" m struct:_p_BV m include/slepc/private/dsimpl.h /^ PetscInt m; \/* current column dimension (for SVD only) *\/$/;" m struct:_p_DS m src/sys/classes/ds/impls/ghiep/invit.c /^ PetscInt m;$/;" m struct:HRtr file: m3 src/nep/interface/neprefine.c /^ PetscScalar M4,m3;$/;" m struct:__anon98 file: m3 src/pep/interface/peprefine.c /^ PetscScalar M4,m3;$/;" m struct:__anon109 file: main bin/maint/generateetags.py /^def main(ctags):$/;" f main bin/maint/generatefortranstubs.py /^def main(petscdir,bfort,dir,verbose):$/;" f main config/cmakeboot.py /^def main(slepcdir, petscdir, petscarch=os.environ['PETSC_ARCH'], argDB=None, framework=None, log=StdoutLogger(), args=[]):$/;" f main config/cmakegen.py /^def main(slepcdir,petscdir,petscdestdir,log=StdoutLogger(), verbose=False):$/;" f main config/gmakegen.py /^def main(slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, output=None, verbose=False):$/;" f main docs/manual/ex1.c /^int main(int argc,char **argv)$/;" f main docs/manual/ex1f.F /^ program main$/;" p main src/eps/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test10.c /^int main (int argc,char **argv)$/;" f main src/eps/examples/tests/test11.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test12.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test13.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test14.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test14f.F /^ program main$/;" p main src/eps/examples/tests/test15f.F /^ program main$/;" p main src/eps/examples/tests/test16.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test2.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test3.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test4.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test5.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test6.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test7f.F /^ program main$/;" p main src/eps/examples/tests/test8.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tests/test9.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex1.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex10.c /^int main (int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex11.c /^int main (int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex12.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex13.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex18.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex19.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex1f.F /^ program main$/;" p main src/eps/examples/tutorials/ex1f90.F90 /^ program main$/;" p main src/eps/examples/tutorials/ex2.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex24.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex25.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex29.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex3.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex30.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex31.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex4.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex5.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex6f.F /^ program main$/;" p main src/eps/examples/tutorials/ex7.c /^int main(int argc,char **argv)$/;" f main src/eps/examples/tutorials/ex9.c /^int main(int argc,char **argv)$/;" f main src/mfn/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/mfn/examples/tutorials/ex23.c /^int main(int argc,char **argv)$/;" f main src/mfn/examples/tutorials/ex26.c /^int main(int argc,char **argv)$/;" f main src/nep/examples/nlevp/gun.c /^int main(int argc,char **argv)$/;" f main src/nep/examples/nlevp/loaded_string.c /^int main(int argc,char **argv)$/;" f main src/nep/examples/tutorials/ex20.c /^int main(int argc,char **argv)$/;" f main src/nep/examples/tutorials/ex21.c /^int main(int argc,char **argv)$/;" f main src/nep/examples/tutorials/ex22.c /^int main(int argc,char **argv)$/;" f main src/nep/examples/tutorials/ex27.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/acoustic_wave_1d.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/acoustic_wave_2d.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/butterfly.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/damped_beam.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/pdde_stability.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/planar_waveguide.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/sleeper.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/nlevp/spring.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/tests/test2.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/tests/test3.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/tests/test3f.F /^ program main$/;" p main src/pep/examples/tutorials/ex16.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/tutorials/ex16f90.F90 /^ program main$/;" p main src/pep/examples/tutorials/ex17.c /^int main(int argc,char **argv)$/;" f main src/pep/examples/tutorials/ex28.c /^int main(int argc,char **argv)$/;" f main src/svd/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/svd/examples/tests/test2.c /^int main(int argc,char **argv)$/;" f main src/svd/examples/tests/test3.c /^int main(int argc,char **argv)$/;" f main src/svd/examples/tutorials/ex14.c /^int main(int argc,char **argv)$/;" f main src/svd/examples/tutorials/ex15.c /^int main(int argc,char **argv)$/;" f main src/svd/examples/tutorials/ex15f.F /^ program main$/;" p main src/svd/examples/tutorials/ex8.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test10.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test11.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test12.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test2.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test3.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test4.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test5.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test6.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test7.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test8.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/bv/examples/tests/test9.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test12.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test13.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test14f.F /^ program main$/;" p main src/sys/classes/ds/examples/tests/test15.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test2.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test3.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test4.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test5.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test6.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test7.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test8.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/ds/examples/tests/test9.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test2.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test3.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test4.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test5.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test6.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test7.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/fn/examples/tests/test8.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/rg/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/st/examples/tests/test1.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/st/examples/tests/test2.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/st/examples/tests/test3.c /^int main(int argc,char **argv)$/;" f main src/sys/classes/st/examples/tests/test4.c /^int main(int argc,char **argv)$/;" f maintainer setup.py /^ maintainer='Lisandro Dalcin',$/;" v maintainer_email setup.py /^ maintainer_email='dalcinl@gmail.com',$/;" v map include/slepcsc.h /^ PetscErrorCode (*map)(PetscObject,PetscInt,PetscScalar*,PetscScalar*);$/;" m struct:_n_SlepcSC map0 src/pep/impls/krylov/toar/nrefine.c /^ PetscInt *map0,*map1,*idxg,*idxp;$/;" m struct:__anon105 file: map1 src/pep/impls/krylov/toar/nrefine.c /^ PetscInt *map0,*map1,*idxg,*idxp;$/;" m struct:__anon105 file: mapobj include/slepcsc.h /^ PetscObject mapobj;$/;" m struct:_n_SlepcSC mat include/slepc/private/dsimpl.h /^ PetscScalar *mat[DS_NUM_MAT]; \/* the matrices *\/$/;" m struct:_p_DS mat src/svd/impls/cross/cross.c /^ Mat mat;$/;" m struct:__anon110 file: mat src/svd/impls/cyclic/cyclic.c /^ Mat mat;$/;" m struct:__anon111 file: matIdx src/sys/classes/st/interface/stshellmat.c /^ PetscInt *matIdx;$/;" m struct:__anon132 file: matmult include/slepc/private/bvimpl.h /^ PetscErrorCode (*matmult)(BV,Mat,BV);$/;" m struct:_BVOps matrix include/slepc/private/bvimpl.h /^ Mat matrix; \/* inner product matrix *\/$/;" m struct:_p_BV maxPend src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt maxPend; \/* Size of "pending" array *\/$/;" m struct:_n_SR max_cX_in_impr src/eps/impls/davidson/davidson.h /^ PetscInt max_cX_in_impr; \/* max vectros from cX in the projector *\/$/;" m struct:_dvdDashboard max_cX_in_proj src/eps/impls/davidson/davidson.h /^ PetscInt max_cX_in_proj; \/* max vectors from cX in the projected problem *\/$/;" m struct:_dvdDashboard max_inner_it src/nep/impls/rii/rii.c /^ PetscInt max_inner_it; \/* maximum number of Newton iterations *\/$/;" m struct:__anon94 file: max_it include/slepc/private/epsimpl.h /^ PetscInt max_it; \/* maximum number of iterations *\/$/;" m struct:_p_EPS max_it include/slepc/private/mfnimpl.h /^ PetscInt max_it; \/* maximum number of iterations *\/$/;" m struct:_p_MFN max_it include/slepc/private/nepimpl.h /^ PetscInt max_it; \/* maximum number of iterations *\/$/;" m struct:_p_NEP max_it include/slepc/private/pepimpl.h /^ PetscInt max_it; \/* maximum number of iterations *\/$/;" m struct:_p_PEP max_it include/slepc/private/svdimpl.h /^ PetscInt max_it; \/* max iterations *\/$/;" m struct:_p_SVD max_nev src/eps/impls/davidson/davidson.h /^ PetscInt max_nev; \/* max number of converged pairs *\/$/;" m struct:__anon66 max_size_P src/eps/impls/davidson/davidson.h /^ PetscInt max_size_P; \/* number of computed vectors for the projector *\/$/;" m struct:__anon66 max_size_P src/eps/impls/davidson/davidson.h /^ PetscInt max_size_P; \/* max unconverged vectors in the projector *\/$/;" m struct:_dvdDashboard max_size_V src/eps/impls/davidson/davidson.h /^ PetscInt max_size_V; \/* max size of the searching subspace (mpd) *\/$/;" m struct:__anon66 max_size_X src/eps/impls/davidson/davidson.h /^ PetscInt max_size_X; \/* max size of X (bs) *\/$/;" m struct:__anon66 max_size_cP src/eps/impls/davidson/davidson.h /^ PetscInt max_size_cP; \/* number of converged vectors in the projectors *\/$/;" m struct:__anon66 max_size_cX_proj src/eps/impls/davidson/davidson.h /^ PetscInt max_size_cX_proj; \/* max converged vectors in the projected problem *\/$/;" m struct:__anon66 max_size_oldX src/eps/impls/davidson/davidson.h /^ PetscInt max_size_oldX; \/* max size of oldX *\/$/;" m struct:__anon66 max_size_proj src/eps/impls/davidson/davidson.h /^ PetscInt max_size_proj; \/* max size projected problem *\/$/;" m struct:__anon66 max_size_proj src/eps/impls/davidson/davidson.h /^ PetscInt max_size_proj; \/* max size projected problem *\/$/;" m struct:_dvdDashboard maxits src/eps/impls/davidson/dvdimprovex.c /^ PetscInt maxits; \/* maximum number of iterations *\/$/;" m struct:__anon68 file: maxlan src/eps/impls/external/trlan/trlanp.h /^ PetscBLASInt maxlan;$/;" m struct:__anon79 metadata setup.py /^metadata = {$/;" v method include/slepc/private/dsimpl.h /^ PetscInt method; \/* identifies the variant to be used *\/$/;" m struct:_p_DS method src/eps/impls/external/primme/primme.c /^ primme_preset_method method; \/* primme method *\/$/;" m struct:__anon78 file: mfnappendoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfnappendoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f mfnappendoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c 29;" d file: mfnappendoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c 40;" d file: mfngetoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfngetoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f mfngetoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c 30;" d file: mfngetoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c 41;" d file: mfngettype_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfngettype_(MFN *mfn,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f mfngettype_ src/mfn/interface/ftn-custom/zmfnf.c 32;" d file: mfngettype_ src/mfn/interface/ftn-custom/zmfnf.c 43;" d file: mfnmonitordefault_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void mfnmonitordefault_(MFN *mfn,PetscInt *it,PetscReal *errest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f mfnmonitordefault_ src/mfn/interface/ftn-custom/zmfnf.c 33;" d file: mfnmonitordefault_ src/mfn/interface/ftn-custom/zmfnf.c 44;" d file: mfnmonitorlg_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void mfnmonitorlg_(MFN *mfn,PetscInt *it,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f mfnmonitorlg_ src/mfn/interface/ftn-custom/zmfnf.c 34;" d file: mfnmonitorlg_ src/mfn/interface/ftn-custom/zmfnf.c 45;" d file: mfnmonitorset_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfnmonitorset_(MFN *mfn,void (PETSC_STDCALL *monitor)(MFN*,PetscInt*,PetscReal*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)$/;" f mfnmonitorset_ src/mfn/interface/ftn-custom/zmfnf.c 35;" d file: mfnmonitorset_ src/mfn/interface/ftn-custom/zmfnf.c 46;" d file: mfnreasonview_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfnreasonview_(MFN *mfn,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f mfnreasonview_ src/mfn/interface/ftn-custom/zmfnf.c 27;" d file: mfnreasonview_ src/mfn/interface/ftn-custom/zmfnf.c 38;" d file: mfnsetoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfnsetoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f mfnsetoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c 28;" d file: mfnsetoptionsprefix_ src/mfn/interface/ftn-custom/zmfnf.c 39;" d file: mfnsettype_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfnsettype_(MFN *mfn,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f mfnsettype_ src/mfn/interface/ftn-custom/zmfnf.c 31;" d file: mfnsettype_ src/mfn/interface/ftn-custom/zmfnf.c 42;" d file: mfnview_ src/mfn/interface/ftn-custom/zmfnf.c /^PETSC_EXTERN void PETSC_STDCALL mfnview_(MFN *mfn,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f mfnview_ src/mfn/interface/ftn-custom/zmfnf.c 26;" d file: mfnview_ src/mfn/interface/ftn-custom/zmfnf.c 37;" d file: min_size_V src/eps/impls/davidson/dvdupdatev.c /^ PetscInt min_size_V; \/* restart with this number of eigenvectors *\/$/;" m struct:__anon70 file: minv src/eps/impls/davidson/davidson.h /^ PetscInt minv; \/* size of V after restarting *\/$/;" m struct:__anon65 mkrel config/gmakegen.py /^ def mkrel(src):$/;" f function:Slepc.gen_pkg mode src/eps/impls/davidson/dvdutils.c /^ HarmType_t mode;$/;" m struct:__anon72 file: modules config/configure.py /^ modules = CreateFile(modulesdir,slepc.lversion+'-'+archname,log)$/;" v modules config/configure.py /^ modules = CreateFile(modulesdir,slepc.lversion,log)$/;" v modulesdir config/configure.py /^modulesdir = CreateDirTwo(confdir,'modules','slepc',log)$/;" v monitor include/slepc/private/epsimpl.h /^ PetscErrorCode (*monitor[MAXEPSMONITORS])(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);$/;" m struct:_p_EPS monitor include/slepc/private/mfnimpl.h /^ PetscErrorCode (*monitor[MAXMFNMONITORS])(MFN,PetscInt,PetscReal,void*);$/;" m struct:_p_MFN monitor include/slepc/private/nepimpl.h /^ PetscErrorCode (*monitor[MAXNEPMONITORS])(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);$/;" m struct:_p_NEP monitor include/slepc/private/pepimpl.h /^ PetscErrorCode (*monitor[MAXPEPMONITORS])(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);$/;" m struct:_p_PEP monitor include/slepc/private/svdimpl.h /^ PetscErrorCode (*monitor[MAXSVDMONITORS])(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*);$/;" m struct:_p_SVD monitor src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId monitor;$/;" m struct:__anon84 file: monitor src/mfn/interface/ftn-custom/zmfnf.c /^ PetscFortranCallbackId monitor;$/;" m struct:__anon85 file: monitor src/nep/interface/ftn-custom/znepf.c /^ PetscFortranCallbackId monitor;$/;" m struct:__anon96 file: monitor src/pep/interface/ftn-custom/zpepf.c /^ PetscFortranCallbackId monitor;$/;" m struct:__anon107 file: monitor src/svd/interface/ftn-custom/zsvdf.c /^ PetscFortranCallbackId monitor;$/;" m struct:__anon114 file: monitorcontext include/slepc/private/epsimpl.h /^ void *monitorcontext[MAXEPSMONITORS];$/;" m struct:_p_EPS monitorcontext include/slepc/private/mfnimpl.h /^ void *monitorcontext[MAXMFNMONITORS];$/;" m struct:_p_MFN monitorcontext include/slepc/private/nepimpl.h /^ void *monitorcontext[MAXNEPMONITORS];$/;" m struct:_p_NEP monitorcontext include/slepc/private/pepimpl.h /^ void *monitorcontext[MAXPEPMONITORS];$/;" m struct:_p_PEP monitorcontext include/slepc/private/svdimpl.h /^ void *monitorcontext[MAXSVDMONITORS];$/;" m struct:_p_SVD monitordestroy include/slepc/private/epsimpl.h /^ PetscErrorCode (*monitordestroy[MAXEPSMONITORS])(void**);$/;" m struct:_p_EPS monitordestroy include/slepc/private/mfnimpl.h /^ PetscErrorCode (*monitordestroy[MAXMFNMONITORS])(void**);$/;" m struct:_p_MFN monitordestroy include/slepc/private/nepimpl.h /^ PetscErrorCode (*monitordestroy[MAXNEPMONITORS])(void**);$/;" m struct:_p_NEP monitordestroy include/slepc/private/pepimpl.h /^ PetscErrorCode (*monitordestroy[MAXPEPMONITORS])(void**);$/;" m struct:_p_PEP monitordestroy include/slepc/private/svdimpl.h /^ PetscErrorCode (*monitordestroy[MAXSVDMONITORS])(void**);$/;" m struct:_p_SVD monitordestroy src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId monitordestroy;$/;" m struct:__anon84 file: monitordestroy src/mfn/interface/ftn-custom/zmfnf.c /^ PetscFortranCallbackId monitordestroy;$/;" m struct:__anon85 file: monitordestroy src/nep/interface/ftn-custom/znepf.c /^ PetscFortranCallbackId monitordestroy;$/;" m struct:__anon96 file: monitordestroy src/pep/interface/ftn-custom/zpepf.c /^ PetscFortranCallbackId monitordestroy;$/;" m struct:__anon107 file: monitordestroy src/svd/interface/ftn-custom/zsvdf.c /^ PetscFortranCallbackId monitordestroy;$/;" m struct:__anon114 file: mpd include/slepc/private/epsimpl.h /^ PetscInt mpd; \/* maximum dimension of projected problem *\/$/;" m struct:_p_EPS mpd include/slepc/private/nepimpl.h /^ PetscInt mpd; \/* maximum dimension of projected problem *\/$/;" m struct:_p_NEP mpd include/slepc/private/pepimpl.h /^ PetscInt mpd; \/* maximum dimension of projected problem *\/$/;" m struct:_p_PEP mpd include/slepc/private/svdimpl.h /^ PetscInt mpd; \/* maximum dimension of projected problem *\/$/;" m struct:_p_SVD mpd src/eps/impls/davidson/dvdupdatev.c /^ PetscInt mpd; \/* max size of the searching subspace *\/$/;" m struct:__anon70 file: mpd src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt mpd; \/* maximum dimension of projected problem *\/$/;" m struct:__anon81 mpi src/sys/classes/bv/impls/contiguous/contig.c /^ PetscBool mpi;$/;" m struct:__anon115 file: mpi src/sys/classes/bv/impls/mat/bvmat.c /^ PetscBool mpi;$/;" m struct:__anon116 file: mpi src/sys/classes/bv/impls/svec/svec.c /^ PetscBool mpi;$/;" m struct:__anon117 file: mstr include/slepc/private/nepimpl.h /^ MatStructure mstr; \/* pattern of split matrices *\/$/;" m struct:_p_NEP mult include/slepc/private/bvimpl.h /^ PetscErrorCode (*mult)(BV,PetscScalar,PetscScalar,BV,Mat);$/;" m struct:_BVOps multMatvec_PRIMME src/eps/impls/external/primme/primme.c /^static void multMatvec_PRIMME(void *in,void *out,int *blockSize,primme_params *primme)$/;" f file: multinplace include/slepc/private/bvimpl.h /^ PetscErrorCode (*multinplace)(BV,Mat,PetscInt,PetscInt);$/;" m struct:_BVOps multinplacetrans include/slepc/private/bvimpl.h /^ PetscErrorCode (*multinplacetrans)(BV,Mat,PetscInt,PetscInt);$/;" m struct:_BVOps multvec include/slepc/private/bvimpl.h /^ PetscErrorCode (*multvec)(BV,PetscScalar,PetscScalar,Vec,PetscScalar*);$/;" m struct:_BVOps mv_TempMultiPETSCVectorDestroy src/eps/impls/external/blopex/slepc-interface.c /^static void mv_TempMultiPETSCVectorDestroy(void* x_)$/;" f file: mv_TempMultiVectorCreateFromBV src/eps/impls/external/blopex/slepc-interface.c /^static void* mv_TempMultiVectorCreateFromBV(void* ii_,BlopexInt n,void* sample)$/;" f file: n include/slepc/private/bvimpl.h /^ PetscInt n,N; \/* dimensions of vectors (local, global) *\/$/;" m struct:_p_BV n include/slepc/private/dsimpl.h /^ PetscInt n; \/* current dimension *\/$/;" m struct:_p_DS n include/slepc/private/epsimpl.h /^ PetscInt n,nloc; \/* problem dimensions (global, local) *\/$/;" m struct:_p_EPS n include/slepc/private/nepimpl.h /^ PetscInt n,nloc; \/* problem dimensions (global, local) *\/$/;" m struct:_p_NEP n include/slepc/private/pepimpl.h /^ PetscInt n,nloc; \/* problem dimensions (global, local) *\/$/;" m struct:_p_PEP n include/slepc/private/vecimplslepc.h /^ PetscInt n; \/* number of active subvectors *\/$/;" m struct:__anon7 n include/slepc/private/vecimplslepc.h /^ PetscInt n; \/* size of vecs *\/$/;" m struct:VecPool_ n include/slepc/private/vecimplslepc.h /^ Vec_Comp_N *n; \/* structure shared by friend vectors *\/$/;" m struct:__anon8 n src/pep/impls/jd/pjdp.h /^ PetscInt n;$/;" m struct:__anon100 n src/sys/classes/ds/impls/ghiep/invit.c /^ PetscInt n[2];$/;" m struct:HRtr file: n src/sys/classes/rg/impls/polygon/rgpolygon.c /^ PetscInt n; \/* number of vertices *\/$/;" m struct:__anon126 file: nBds src/eps/impls/davidson/davidson.h /^ PetscReal *nBds; \/* B-norms of projected problem *\/$/;" m struct:_dvdDashboard nMAXCompl src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nMAXCompl;$/;" m struct:_n_SR nPend src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nPend; \/* Number of pending shifts *\/$/;" m struct:_n_SR nR src/eps/impls/davidson/davidson.h /^ PetscReal *nR; \/* residual norm *\/$/;" m struct:_dvdDashboard nS src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nS;$/;" m struct:_n_SR nX src/eps/impls/davidson/davidson.h /^ PetscReal *nX; \/* X norm *\/$/;" m struct:_dvdDashboard nbus src/eps/examples/tutorials/ex31.c /^const PetscInt nbus = 9; \/* Number of network buses *\/$/;" v nc include/slepc/private/bvimpl.h /^ PetscInt nc; \/* number of constraints *\/$/;" m struct:_p_BV nconv include/slepc/private/epsimpl.h /^ PetscInt nconv; \/* number of converged eigenvalues *\/$/;" m struct:_p_EPS nconv include/slepc/private/nepimpl.h /^ PetscInt nconv; \/* number of converged eigenvalues *\/$/;" m struct:_p_NEP nconv include/slepc/private/pepimpl.h /^ PetscInt nconv; \/* number of converged eigenvalues *\/$/;" m struct:_p_PEP nconv include/slepc/private/svdimpl.h /^ PetscInt nconv; \/* number of converged values *\/$/;" m struct:_p_SVD nconv src/eps/impls/davidson/davidson.h /^ PetscInt nconv; \/* number of converged eigenpairs *\/$/;" m struct:_dvdDashboard nconv src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nconv[2]; \/* Converged on each side (accepted or not) *\/$/;" m struct:_n_shift nconv src/pep/impls/jd/pjdp.h /^ PetscInt nconv; \/* number of locked vectors in the invariant pair *\/$/;" m struct:__anon99 nconv_loc src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscMPIInt *nconv_loc; \/* converged eigenpairs for each subinterval *\/$/;" m struct:__anon81 ncv include/slepc/private/epsimpl.h /^ PetscInt ncv; \/* number of basis vectors *\/$/;" m struct:_p_EPS ncv include/slepc/private/mfnimpl.h /^ PetscInt ncv; \/* number of basis vectors *\/$/;" m struct:_p_MFN ncv include/slepc/private/nepimpl.h /^ PetscInt ncv; \/* number of basis vectors *\/$/;" m struct:_p_NEP ncv include/slepc/private/pepimpl.h /^ PetscInt ncv; \/* number of basis vectors *\/$/;" m struct:_p_PEP ncv include/slepc/private/svdimpl.h /^ PetscInt ncv; \/* basis size *\/$/;" m struct:_p_SVD ncv src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt ncv; \/* number of basis vectors *\/$/;" m struct:__anon81 nds include/slepc/private/epsimpl.h /^ PetscInt nds; \/* number of basis vectors of deflation space *\/$/;" m struct:_p_EPS neighb src/eps/impls/krylov/krylovschur/krylovschur.h /^ EPS_shift neighb[2]; \/* Adjacent shifts *\/$/;" m struct:_n_shift neigs src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt neigs; \/* Number of values found *\/$/;" m struct:_n_shift nepappendoptionsprefix_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepappendoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f nepappendoptionsprefix_ src/nep/interface/ftn-custom/znepf.c 33;" d file: nepappendoptionsprefix_ src/nep/interface/ftn-custom/znepf.c 55;" d file: nepconvergedabsolute_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepconvergedabsolute_(NEP *nep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f nepconvergedabsolute_ src/nep/interface/ftn-custom/znepf.c 43;" d file: nepconvergedabsolute_ src/nep/interface/ftn-custom/znepf.c 65;" d file: nepconvergedrelative_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepconvergedrelative_(NEP *nep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f nepconvergedrelative_ src/nep/interface/ftn-custom/znepf.c 44;" d file: nepconvergedrelative_ src/nep/interface/ftn-custom/znepf.c 66;" d file: neperrorview_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL neperrorview_(NEP *nep,NEPErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f neperrorview_ src/nep/interface/ftn-custom/znepf.c 28;" d file: neperrorview_ src/nep/interface/ftn-custom/znepf.c 50;" d file: nepgetoptionsprefix_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepgetoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f nepgetoptionsprefix_ src/nep/interface/ftn-custom/znepf.c 34;" d file: nepgetoptionsprefix_ src/nep/interface/ftn-custom/znepf.c 56;" d file: nepgettype_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepgettype_(NEP *nep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f nepgettype_ src/nep/interface/ftn-custom/znepf.c 36;" d file: nepgettype_ src/nep/interface/ftn-custom/znepf.c 58;" d file: nepmonitorall_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void nepmonitorall_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f nepmonitorall_ src/nep/interface/ftn-custom/znepf.c 37;" d file: nepmonitorall_ src/nep/interface/ftn-custom/znepf.c 59;" d file: nepmonitorconverged_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void nepmonitorconverged_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)$/;" f nepmonitorconverged_ src/nep/interface/ftn-custom/znepf.c 41;" d file: nepmonitorconverged_ src/nep/interface/ftn-custom/znepf.c 63;" d file: nepmonitorfirst_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void nepmonitorfirst_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f nepmonitorfirst_ src/nep/interface/ftn-custom/znepf.c 42;" d file: nepmonitorfirst_ src/nep/interface/ftn-custom/znepf.c 64;" d file: nepmonitorlg_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void nepmonitorlg_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f nepmonitorlg_ src/nep/interface/ftn-custom/znepf.c 38;" d file: nepmonitorlg_ src/nep/interface/ftn-custom/znepf.c 60;" d file: nepmonitorlgall_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void nepmonitorlgall_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f nepmonitorlgall_ src/nep/interface/ftn-custom/znepf.c 39;" d file: nepmonitorlgall_ src/nep/interface/ftn-custom/znepf.c 61;" d file: nepmonitorset_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepmonitorset_(NEP *nep,void (PETSC_STDCALL *monitor)(NEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)$/;" f nepmonitorset_ src/nep/interface/ftn-custom/znepf.c 40;" d file: nepmonitorset_ src/nep/interface/ftn-custom/znepf.c 62;" d file: nepreasonview_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepreasonview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f nepreasonview_ src/nep/interface/ftn-custom/znepf.c 29;" d file: nepreasonview_ src/nep/interface/ftn-custom/znepf.c 51;" d file: nepsetconvergencetestfunction_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepsetconvergencetestfunction_(NEP *nep,void (PETSC_STDCALL *func)(NEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f nepsetconvergencetestfunction_ src/nep/interface/ftn-custom/znepf.c 45;" d file: nepsetconvergencetestfunction_ src/nep/interface/ftn-custom/znepf.c 67;" d file: nepseteigenvaluecomparison_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepseteigenvaluecomparison_(NEP *nep,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr)$/;" f nepseteigenvaluecomparison_ src/nep/interface/ftn-custom/znepf.c 47;" d file: nepseteigenvaluecomparison_ src/nep/interface/ftn-custom/znepf.c 69;" d file: nepsetoptionsprefix_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepsetoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f nepsetoptionsprefix_ src/nep/interface/ftn-custom/znepf.c 32;" d file: nepsetoptionsprefix_ src/nep/interface/ftn-custom/znepf.c 54;" d file: nepsetstoppingtestfunction_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepsetstoppingtestfunction_(NEP *nep,void (PETSC_STDCALL *func)(NEP*,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f nepsetstoppingtestfunction_ src/nep/interface/ftn-custom/znepf.c 46;" d file: nepsetstoppingtestfunction_ src/nep/interface/ftn-custom/znepf.c 68;" d file: nepsettype_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepsettype_(NEP *nep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f nepsettype_ src/nep/interface/ftn-custom/znepf.c 35;" d file: nepsettype_ src/nep/interface/ftn-custom/znepf.c 57;" d file: nepstoppingbasic_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepstoppingbasic_(NEP *nep,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,NEPConvergedReason *reason,void *ctx,PetscErrorCode *ierr)$/;" f nepvaluesview_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepvaluesview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f nepvaluesview_ src/nep/interface/ftn-custom/znepf.c 30;" d file: nepvaluesview_ src/nep/interface/ftn-custom/znepf.c 52;" d file: nepvectorsview_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepvectorsview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f nepvectorsview_ src/nep/interface/ftn-custom/znepf.c 31;" d file: nepvectorsview_ src/nep/interface/ftn-custom/znepf.c 53;" d file: nepview_ src/nep/interface/ftn-custom/znepf.c /^PETSC_EXTERN void PETSC_STDCALL nepview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f nepview_ src/nep/interface/ftn-custom/znepf.c 27;" d file: nepview_ src/nep/interface/ftn-custom/znepf.c 49;" d file: neqs_gen src/eps/examples/tutorials/ex31.c /^ PetscInt neqs_gen,neqs_net,neqs_pgrid;$/;" m struct:__anon57 file: neqs_net src/eps/examples/tutorials/ex31.c /^ PetscInt neqs_gen,neqs_net,neqs_pgrid;$/;" m struct:__anon57 file: neqs_pgrid src/eps/examples/tutorials/ex31.c /^ PetscInt neqs_gen,neqs_net,neqs_pgrid;$/;" m struct:__anon57 file: nev include/slepc/private/epsimpl.h /^ PetscInt nev; \/* number of eigenvalues to compute *\/$/;" m struct:_p_EPS nev include/slepc/private/nepimpl.h /^ PetscInt nev; \/* number of eigenvalues to compute *\/$/;" m struct:_p_NEP nev include/slepc/private/pepimpl.h /^ PetscInt nev; \/* number of eigenvalues to compute *\/$/;" m struct:_p_PEP nev src/eps/impls/davidson/davidson.h /^ PetscInt nev; \/* number of eigenpairs *\/$/;" m struct:_dvdDashboard nev src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nev; \/* number of eigenvalues to compute *\/$/;" m struct:__anon81 next include/slepc/private/vecimplslepc.h /^ struct VecPool_ *next; \/* list of pool of vectors *\/$/;" m struct:VecPool_ typeref:struct:VecPool_::VecPool_ next src/eps/impls/davidson/davidson.h /^ struct _dvdFunctionList *next;$/;" m struct:_dvdFunctionList typeref:struct:_dvdFunctionList::_dvdFunctionList nf src/sys/classes/ds/impls/nep/dsnep.c /^ PetscInt nf; \/* number of functions in f[] *\/$/;" m struct:__anon119 file: ngen src/eps/examples/tutorials/ex31.c /^const PetscInt ngen = 3; \/* Number of generators *\/$/;" v nini include/slepc/private/epsimpl.h /^ PetscInt nini; \/* number of initial vectors (negative means not copied yet) *\/$/;" m struct:_p_EPS nini include/slepc/private/nepimpl.h /^ PetscInt nini; \/* number of initial vectors (negative means not copied yet) *\/$/;" m struct:_p_NEP nini include/slepc/private/pepimpl.h /^ PetscInt nini; \/* number of initial vectors (negative means not copied yet) *\/$/;" m struct:_p_PEP nini include/slepc/private/svdimpl.h /^ PetscInt nini,ninil; \/* number of initial vecs (negative means not copied yet) *\/$/;" m struct:_p_SVD ninil include/slepc/private/svdimpl.h /^ PetscInt nini,ninil; \/* number of initial vecs (negative means not copied yet) *\/$/;" m struct:_p_SVD nleap src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nleap;$/;" m struct:_n_SR nload src/eps/examples/tutorials/ex31.c /^const PetscInt nload = 3; \/* Number of loads *\/$/;" v nloc include/slepc/private/epsimpl.h /^ PetscInt n,nloc; \/* problem dimensions (global, local) *\/$/;" m struct:_p_EPS nloc include/slepc/private/nepimpl.h /^ PetscInt n,nloc; \/* problem dimensions (global, local) *\/$/;" m struct:_p_NEP nloc include/slepc/private/pepimpl.h /^ PetscInt n,nloc; \/* problem dimensions (global, local) *\/$/;" m struct:_p_PEP nmat include/slepc/private/pepimpl.h /^ PetscInt nmat; \/* number of matrices *\/$/;" m struct:_p_PEP nmat include/slepc/private/stimpl.h /^ PetscInt nmat; \/* number of matrices *\/$/;" m struct:_p_ST nmat src/nep/impls/nleigs/nleigs.c /^ PetscInt nmat; \/* number of interpolation points *\/$/;" m struct:__anon92 file: nmat src/nep/impls/nleigs/nleigs.c /^ PetscInt nmat;$/;" m struct:__anon93 file: nmat src/pep/impls/krylov/toar/nrefine.c /^ PetscInt k,nmat;$/;" m struct:__anon104 file: nmat src/sys/classes/st/interface/stshellmat.c /^ PetscInt nmat;$/;" m struct:__anon132 file: noCheck config/cmakeboot.py /^def noCheck(command, status, output, error):$/;" f norm include/slepc/private/bvimpl.h /^ PetscErrorCode (*norm)(BV,PetscInt,NormType,PetscReal*);$/;" m struct:_BVOps norm_begin include/slepc/private/bvimpl.h /^ PetscErrorCode (*norm_begin)(BV,PetscInt,NormType,PetscReal*);$/;" m struct:_BVOps norm_end include/slepc/private/bvimpl.h /^ PetscErrorCode (*norm_end)(BV,PetscInt,NormType,PetscReal*);$/;" m struct:_BVOps norm_local include/slepc/private/bvimpl.h /^ PetscErrorCode (*norm_local)(BV,PetscInt,NormType,PetscReal*);$/;" m struct:_BVOps normalize include/slepc/private/dsimpl.h /^ PetscErrorCode (*normalize)(DS,DSMatType,PetscInt);$/;" m struct:_DSOps np src/sys/classes/fn/impls/rational/fnrational.c /^ PetscInt np; \/* length of array pcoeff, p(x) has degree np-1 *\/$/;" m struct:__anon123 file: npart include/slepc/private/nepimpl.h /^ PetscInt npart; \/* number of partitions of the communicator *\/$/;" m struct:_p_NEP npart include/slepc/private/pepimpl.h /^ PetscInt npart; \/* number of partitions of the communicator *\/$/;" m struct:_p_PEP npart src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt npart; \/* number of partitions of subcommunicator *\/$/;" m struct:__anon81 npoints src/eps/impls/external/feast/feastp.h /^ PetscBLASInt npoints; \/* number of contour points *\/$/;" m struct:__anon77 npreconv src/eps/impls/davidson/davidson.h /^ PetscInt npreconv; \/* number of pairs ready to converge *\/$/;" m struct:_dvdDashboard nq src/pep/impls/krylov/pepkrylov.h /^ PetscInt nq; \/* number of TOAR Vectors *\/$/;" m struct:__anon102 nq src/sys/classes/fn/impls/rational/fnrational.c /^ PetscInt nq; \/* length of array qcoeff, q(x) has degree nq-1 *\/$/;" m struct:__anon123 file: nreps src/eps/examples/tutorials/ex30.c /^ PetscInt nreps; \/* number of repetitions of nconv; used in stopping test *\/$/;" m struct:__anon56 file: nrest src/eps/impls/cg/rqcg/rqcg.c /^ PetscInt nrest;$/;" m struct:__anon60 file: nrma include/slepc/private/epsimpl.h /^ PetscReal nrma,nrmb; \/* computed matrix norms *\/$/;" m struct:_p_EPS nrma include/slepc/private/nepimpl.h /^ PetscReal *nrma; \/* computed matrix norms *\/$/;" m struct:_p_NEP nrma include/slepc/private/pepimpl.h /^ PetscReal *nrma; \/* computed matrix norms *\/$/;" m struct:_p_PEP nrmb include/slepc/private/epsimpl.h /^ PetscReal nrma,nrmb; \/* computed matrix norms *\/$/;" m struct:_p_EPS nrml include/slepc/private/pepimpl.h /^ PetscReal nrml[2]; \/* computed matrix norms for the linearization *\/$/;" m struct:_p_PEP nsch src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nsch[2]; \/* Number of missing values for each subinterval *\/$/;" m struct:_n_shift nshifts src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nshifts; \/* elements in the arrays of shifts and inertias *\/$/;" m struct:__anon81 nshifts src/nep/impls/nleigs/nleigs.c /^ PetscInt nshifts; \/* provided number of shifts *\/$/;" m struct:__anon92 file: nshiftsw src/nep/impls/nleigs/nleigs.c /^ PetscInt nshiftsw; \/* actual number of shifts (1 if Krylov-Schur) *\/$/;" m struct:__anon92 file: nst src/nep/interface/neprefine.c /^ VecScatter *scatter_id,nst;$/;" m struct:__anon97 file: nst src/pep/interface/peprefine.c /^ VecScatter *scatter_id,nst;$/;" m struct:__anon108 file: nsteps src/eps/impls/external/blzpack/blzpackp.h /^ PetscBLASInt nsteps; \/* maximum number of steps per run *\/$/;" m struct:__anon76 nsv include/slepc/private/svdimpl.h /^ PetscInt nsv; \/* number of requested values *\/$/;" m struct:_p_SVD nt include/slepc/private/nepimpl.h /^ PetscInt nt; \/* number of terms in split form *\/$/;" m struct:_p_NEP nu src/sys/classes/st/impls/cayley/cayley.c /^ PetscScalar nu;$/;" m struct:__anon128 file: nu_set src/sys/classes/st/impls/cayley/cayley.c /^ PetscBool nu_set;$/;" m struct:__anon128 file: numEigs src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt numEigs; \/* Number of eigenvalues in the interval *\/$/;" m struct:_n_SR num_solve_point src/eps/impls/ciss/ciss.c /^ PetscInt num_solve_point;$/;" m struct:__anon61 file: num_solve_point src/nep/impls/ciss/nciss.c /^ PetscInt num_solve_point;$/;" m struct:__anon89 file: num_subcomm src/eps/impls/ciss/ciss.c /^ PetscInt num_subcomm;$/;" m struct:__anon61 file: num_subcomm src/nep/impls/ciss/nciss.c /^ PetscInt num_subcomm;$/;" m struct:__anon89 file: numbermonitors include/slepc/private/epsimpl.h /^ PetscInt numbermonitors;$/;" m struct:_p_EPS numbermonitors include/slepc/private/mfnimpl.h /^ PetscInt numbermonitors;$/;" m struct:_p_MFN numbermonitors include/slepc/private/nepimpl.h /^ PetscInt numbermonitors;$/;" m struct:_p_NEP numbermonitors include/slepc/private/pepimpl.h /^ PetscInt numbermonitors;$/;" m struct:_p_PEP numbermonitors include/slepc/private/svdimpl.h /^ PetscInt numbermonitors;$/;" m struct:_p_SVD nv include/slepc/private/mfnimpl.h /^ PetscInt nv; \/* size of current Schur decomposition *\/$/;" m struct:_p_MFN nv src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt nv; \/* position of restart vector *\/$/;" m struct:_n_SR nv src/nep/interface/neprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon97 file: nv src/pep/interface/peprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon108 file: nw include/slepc/private/fnimpl.h /^ PetscInt nw; \/* number of allocated W matrices *\/$/;" m struct:_p_FN nwork include/slepc/private/epsimpl.h /^ PetscInt nwork; \/* number of work vectors *\/$/;" m struct:_p_EPS nwork include/slepc/private/mfnimpl.h /^ PetscInt nwork; \/* number of work vectors *\/$/;" m struct:_p_MFN nwork include/slepc/private/nepimpl.h /^ PetscInt nwork; \/* number of work vectors *\/$/;" m struct:_p_NEP nwork include/slepc/private/pepimpl.h /^ PetscInt nwork; \/* number of work vectors *\/$/;" m struct:_p_PEP nx include/slepc/private/vecimplslepc.h /^ PetscInt nx; \/* number of available subvectors *\/$/;" m struct:__anon8 oldU src/eps/impls/davidson/dvdupdatev.c /^ Mat oldU; \/* previous projected right igenvectors *\/$/;" m struct:__anon70 file: oldV src/eps/impls/davidson/dvdupdatev.c /^ Mat oldV; \/* previous projected left eigenvectors *\/$/;" m struct:__anon70 file: old_initV_data src/eps/impls/davidson/dvdinitv.c /^ void *old_initV_data; \/* old initV data *\/$/;" m struct:__anon69 file: old_isRestarting src/eps/impls/davidson/dvdupdatev.c /^ PetscErrorCode (*old_isRestarting)(dvdDashboard*,PetscBool*); \/* old isRestarting *\/$/;" m struct:__anon70 file: old_pc src/eps/impls/davidson/dvdimprovex.c /^ PC old_pc; \/* old pc in ksp *\/$/;" m struct:__anon68 file: old_size_X src/eps/impls/davidson/dvdimprovex.c /^ PetscInt old_size_X; \/* last number of improved vectors *\/$/;" m struct:__anon68 file: old_updateV_data src/eps/impls/davidson/dvdupdatev.c /^ void *old_updateV_data; \/* old updateV data *\/$/;" m struct:__anon70 file: oldnconv include/slepc/private/slepcimpl.h /^ PetscInt oldnconv;$/;" m struct:_n_SlepcConvMonitor omat include/slepc/private/dsimpl.h /^ Mat omat[DS_NUM_MAT]; \/* the matrices (PETSc object) *\/$/;" m struct:_p_DS omega include/slepc/private/bvimpl.h /^ PetscReal *omega; \/* signature matrix values for indefinite case *\/$/;" m struct:_p_BV omega src/eps/impls/ciss/ciss.c /^ PetscScalar *omega;$/;" m struct:__anon61 file: omega src/nep/impls/ciss/nciss.c /^ PetscScalar *omega;$/;" m struct:__anon89 file: oneside src/svd/impls/lanczos/gklanczos.c /^ PetscBool oneside;$/;" m struct:__anon112 file: oneside src/svd/impls/trlanczos/trlanczos.c /^ PetscBool oneside;$/;" m struct:__anon113 file: optionspackages config/configure.py /^optionspackages = [slepc, arpack, blopex, blzpack, feast, primme, trlan, sowing]$/;" v orthog_block include/slepc/private/bvimpl.h /^ BVOrthogBlockType orthog_block; \/* the method of block orthogonalization *\/$/;" m struct:_p_BV orthog_eta include/slepc/private/bvimpl.h /^ PetscReal orthog_eta; \/* refinement threshold *\/$/;" m struct:_p_BV orthog_ref include/slepc/private/bvimpl.h /^ BVOrthogRefineType orthog_ref; \/* refinement method *\/$/;" m struct:_p_BV orthog_type include/slepc/private/bvimpl.h /^ BVOrthogType orthog_type; \/* the method of vector orthogonalization *\/$/;" m struct:_p_BV orthogonalize include/slepc/private/bvimpl.h /^ PetscErrorCode (*orthogonalize)(BV,Mat);$/;" m struct:_BVOps osfactor include/slepc/private/rgimpl.h /^ PetscReal osfactor; \/* old scaling factor, before RGPushScale *\/$/;" m struct:_p_RG ourarbitraryfunc src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode ourarbitraryfunc(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)$/;" f file: ourconvdestroy src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode ourconvdestroy(void *ctx)$/;" f file: ourconvdestroy src/nep/interface/ftn-custom/znepf.c /^static PetscErrorCode ourconvdestroy(void *ctx)$/;" f file: ourconvdestroy src/pep/interface/ftn-custom/zpepf.c /^static PetscErrorCode ourconvdestroy(void *ctx)$/;" f file: ourconvdestroy src/svd/interface/ftn-custom/zsvdf.c /^static PetscErrorCode ourconvdestroy(void *ctx)$/;" f file: ourconvergence src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode ourconvergence(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f file: ourconvergence src/nep/interface/ftn-custom/znepf.c /^static PetscErrorCode ourconvergence(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f file: ourconvergence src/pep/interface/ftn-custom/zpepf.c /^static PetscErrorCode ourconvergence(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)$/;" f file: ourconvergence src/svd/interface/ftn-custom/zsvdf.c /^static PetscErrorCode ourconvergence(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)$/;" f file: ourdestroy src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode ourdestroy(void** ctx)$/;" f file: ourdestroy src/mfn/interface/ftn-custom/zmfnf.c /^static PetscErrorCode ourdestroy(void** ctx)$/;" f file: ourdestroy src/nep/interface/ftn-custom/znepf.c /^static PetscErrorCode ourdestroy(void** ctx)$/;" f file: ourdestroy src/pep/interface/ftn-custom/zpepf.c /^static PetscErrorCode ourdestroy(void** ctx)$/;" f file: ourdestroy src/svd/interface/ftn-custom/zsvdf.c /^static PetscErrorCode ourdestroy(void** ctx)$/;" f file: oureigenvaluecomparison src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)$/;" f file: oureigenvaluecomparison src/nep/interface/ftn-custom/znepf.c /^static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)$/;" f file: oureigenvaluecomparison src/pep/interface/ftn-custom/zpepf.c /^static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)$/;" f file: ourmonitor src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode ourmonitor(EPS eps,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx)$/;" f file: ourmonitor src/mfn/interface/ftn-custom/zmfnf.c /^static PetscErrorCode ourmonitor(MFN mfn,PetscInt i,PetscReal d,void* ctx)$/;" f file: ourmonitor src/nep/interface/ftn-custom/znepf.c /^static PetscErrorCode ourmonitor(NEP nep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx)$/;" f file: ourmonitor src/pep/interface/ftn-custom/zpepf.c /^static PetscErrorCode ourmonitor(PEP pep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx)$/;" f file: ourmonitor src/svd/interface/ftn-custom/zsvdf.c /^static PetscErrorCode ourmonitor(SVD svd,PetscInt i,PetscInt nc,PetscReal *sigma,PetscReal *d,PetscInt l,void* ctx)$/;" f file: ourshellapply src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^static PetscErrorCode ourshellapply(ST st,Vec x,Vec y)$/;" f file: ourshellapplytranspose src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^static PetscErrorCode ourshellapplytranspose(ST st,Vec x,Vec y)$/;" f file: ourshellbacktransform src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^static PetscErrorCode ourshellbacktransform(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)$/;" f file: ourstopdestroy src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode ourstopdestroy(void *ctx)$/;" f file: ourstopdestroy src/nep/interface/ftn-custom/znepf.c /^static PetscErrorCode ourstopdestroy(void *ctx)$/;" f file: ourstopdestroy src/pep/interface/ftn-custom/zpepf.c /^static PetscErrorCode ourstopdestroy(void *ctx)$/;" f file: ourstopdestroy src/svd/interface/ftn-custom/zsvdf.c /^static PetscErrorCode ourstopdestroy(void *ctx)$/;" f file: ourstopping src/eps/interface/ftn-custom/zepsf.c /^static PetscErrorCode ourstopping(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)$/;" f file: ourstopping src/nep/interface/ftn-custom/znepf.c /^static PetscErrorCode ourstopping(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)$/;" f file: ourstopping src/pep/interface/ftn-custom/zpepf.c /^static PetscErrorCode ourstopping(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)$/;" f file: ourstopping src/svd/interface/ftn-custom/zsvdf.c /^static PetscErrorCode ourstopping(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)$/;" f file: outputDestDirDone config/install.py /^ def outputDestDirDone(self):$/;" f outputInstallDone config/install.py /^ def outputInstallDone(self):$/;" m class:Installer pA src/eps/impls/ciss/ciss.c /^ Mat pA,pB;$/;" m struct:__anon61 file: pB src/eps/impls/ciss/ciss.c /^ Mat pA,pB;$/;" m struct:__anon61 file: pM4 src/pep/impls/krylov/toar/nrefine.c /^ PetscBLASInt *pM4;$/;" m struct:__anon104 file: pV src/eps/impls/ciss/ciss.c /^ BV pV;$/;" m struct:__anon61 file: package_dir setup.py /^ package_dir = {'slepc': 'pypi'},$/;" v packages setup.py /^ packages = ['slepc'],$/;" v par_GlobalSumDouble src/eps/impls/external/primme/primme.c /^static void par_GlobalSumDouble(void *sendBuf,void *recvBuf,int *count,primme_params *primme)$/;" f file: parser config/cmakegen.py /^ parser = optparse.OptionParser()$/;" v parser config/gmakegen.py /^ parser = optparse.OptionParser()$/;" v pathsplit config/cmakegen.py /^def pathsplit(path):$/;" f pbc include/slepc/private/pepimpl.h /^ PetscReal *pbc; \/* coefficients defining the polynomial basis *\/$/;" m struct:_p_PEP pc src/eps/impls/davidson/dvdutils.c /^ PC pc;$/;" m struct:__anon71 file: pc src/pep/impls/jd/pjdp.h /^ PC pc; \/* basic preconditioner *\/$/;" m struct:__anon100 pcoeff src/sys/classes/fn/impls/rational/fnrational.c /^ PetscScalar *pcoeff; \/* numerator coefficients *\/$/;" m struct:__anon123 file: pcshell src/pep/impls/jd/pjdp.h /^ PC pcshell; \/* preconditioner including basic precond+projector *\/$/;" m struct:__anon99 pending src/eps/impls/krylov/krylovschur/krylovschur.h /^ EPS_shift *pending; \/* Pending shifts array *\/$/;" m struct:_n_SR pep src/nep/impls/interpol/interpol.c /^ PEP pep;$/;" m struct:__anon90 file: pep src/pep/examples/tutorials/ex16f90.F90 /^ type(PEP) pep$/;" v program:main pep src/pep/impls/jd/pjdp.h /^ PEP pep;$/;" m struct:__anon101 pep src/pep/impls/linear/linearp.h /^ PEP pep;$/;" m struct:__anon106 pepappendoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepappendoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f pepappendoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c 33;" d file: pepappendoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c 55;" d file: pepconvergedabsolute_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepconvergedabsolute_(PEP *pep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f pepconvergedabsolute_ src/pep/interface/ftn-custom/zpepf.c 43;" d file: pepconvergedabsolute_ src/pep/interface/ftn-custom/zpepf.c 65;" d file: pepconvergedrelative_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepconvergedrelative_(PEP *pep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f pepconvergedrelative_ src/pep/interface/ftn-custom/zpepf.c 44;" d file: pepconvergedrelative_ src/pep/interface/ftn-custom/zpepf.c 66;" d file: peperrorview_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL peperrorview_(PEP *pep,PEPErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f peperrorview_ src/pep/interface/ftn-custom/zpepf.c 28;" d file: peperrorview_ src/pep/interface/ftn-custom/zpepf.c 50;" d file: pepgetoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepgetoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f pepgetoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c 34;" d file: pepgetoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c 56;" d file: pepgettype_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepgettype_(PEP *pep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f pepgettype_ src/pep/interface/ftn-custom/zpepf.c 36;" d file: pepgettype_ src/pep/interface/ftn-custom/zpepf.c 58;" d file: pepmonitorall_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void pepmonitorall_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f pepmonitorall_ src/pep/interface/ftn-custom/zpepf.c 37;" d file: pepmonitorall_ src/pep/interface/ftn-custom/zpepf.c 59;" d file: pepmonitorconverged_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void pepmonitorconverged_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)$/;" f pepmonitorconverged_ src/pep/interface/ftn-custom/zpepf.c 41;" d file: pepmonitorconverged_ src/pep/interface/ftn-custom/zpepf.c 63;" d file: pepmonitorfirst_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void pepmonitorfirst_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f pepmonitorfirst_ src/pep/interface/ftn-custom/zpepf.c 42;" d file: pepmonitorfirst_ src/pep/interface/ftn-custom/zpepf.c 64;" d file: pepmonitorlg_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void pepmonitorlg_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f pepmonitorlg_ src/pep/interface/ftn-custom/zpepf.c 38;" d file: pepmonitorlg_ src/pep/interface/ftn-custom/zpepf.c 60;" d file: pepmonitorlgall_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void pepmonitorlgall_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f pepmonitorlgall_ src/pep/interface/ftn-custom/zpepf.c 39;" d file: pepmonitorlgall_ src/pep/interface/ftn-custom/zpepf.c 61;" d file: pepmonitorset_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepmonitorset_(PEP *pep,void (PETSC_STDCALL *monitor)(PEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)$/;" f pepmonitorset_ src/pep/interface/ftn-custom/zpepf.c 40;" d file: pepmonitorset_ src/pep/interface/ftn-custom/zpepf.c 62;" d file: pepreasonview_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepreasonview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f pepreasonview_ src/pep/interface/ftn-custom/zpepf.c 29;" d file: pepreasonview_ src/pep/interface/ftn-custom/zpepf.c 51;" d file: pepsetconvergencetestfunction_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepsetconvergencetestfunction_(PEP *pep,void (PETSC_STDCALL *func)(PEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f pepsetconvergencetestfunction_ src/pep/interface/ftn-custom/zpepf.c 45;" d file: pepsetconvergencetestfunction_ src/pep/interface/ftn-custom/zpepf.c 67;" d file: pepseteigenvaluecomparison_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepseteigenvaluecomparison_(PEP *pep,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr)$/;" f pepseteigenvaluecomparison_ src/pep/interface/ftn-custom/zpepf.c 47;" d file: pepseteigenvaluecomparison_ src/pep/interface/ftn-custom/zpepf.c 69;" d file: pepsetoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepsetoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f pepsetoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c 32;" d file: pepsetoptionsprefix_ src/pep/interface/ftn-custom/zpepf.c 54;" d file: pepsetstoppingtestfunction_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepsetstoppingtestfunction_(PEP *pep,void (PETSC_STDCALL *func)(PEP*,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f pepsetstoppingtestfunction_ src/pep/interface/ftn-custom/zpepf.c 46;" d file: pepsetstoppingtestfunction_ src/pep/interface/ftn-custom/zpepf.c 68;" d file: pepsettype_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepsettype_(PEP *pep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f pepsettype_ src/pep/interface/ftn-custom/zpepf.c 35;" d file: pepsettype_ src/pep/interface/ftn-custom/zpepf.c 57;" d file: pepstoppingbasic_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepstoppingbasic_(PEP *pep,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,PEPConvergedReason *reason,void *ctx,PetscErrorCode *ierr)$/;" f pepvaluesview_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepvaluesview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f pepvaluesview_ src/pep/interface/ftn-custom/zpepf.c 30;" d file: pepvaluesview_ src/pep/interface/ftn-custom/zpepf.c 52;" d file: pepvectorsview_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepvectorsview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f pepvectorsview_ src/pep/interface/ftn-custom/zpepf.c 31;" d file: pepvectorsview_ src/pep/interface/ftn-custom/zpepf.c 53;" d file: pepview_ src/pep/interface/ftn-custom/zpepf.c /^PETSC_EXTERN void PETSC_STDCALL pepview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f pepview_ src/pep/interface/ftn-custom/zpepf.c 27;" d file: pepview_ src/pep/interface/ftn-custom/zpepf.c 49;" d file: perm include/slepc/private/dsimpl.h /^ PetscInt *perm; \/* permutation *\/$/;" m struct:_p_DS perm include/slepc/private/epsimpl.h /^ PetscInt *perm; \/* permutation for eigenvalue ordering *\/$/;" m struct:_p_EPS perm include/slepc/private/nepimpl.h /^ PetscInt *perm; \/* permutation for eigenvalue ordering *\/$/;" m struct:_p_NEP perm include/slepc/private/pepimpl.h /^ PetscInt *perm; \/* permutation for eigenvalue ordering *\/$/;" m struct:_p_PEP perm include/slepc/private/svdimpl.h /^ PetscInt *perm; \/* permutation for singular value ordering *\/$/;" m struct:_p_SVD perm src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscInt *perm; \/* permutation (for subsolve) *\/$/;" m struct:_n_SR petsc config/configure.py /^petsc = petsc.PETSc(argdb,log)$/;" v petsc_path config/gmakegen.py /^ def petsc_path(self, *args):$/;" m class:Slepc petscdate config/configure.py /^ petscdate = dateutil.parser.parse(petsc.gitdate)$/;" v petscinitialize_ src/sys/ftn-custom/zslepc_start.c 28;" d file: petscinitialize_ src/sys/ftn-custom/zslepc_start.c 31;" d file: pkgconfdir config/configure.py /^pkgconfdir = CreateDir(libdir,'pkgconfig',log)$/;" v pkgconfig config/configure.py /^pkgconfig = CreateFile(pkgconfdir,'SLEPc.pc',log)$/;" v pkgsources config/cmakegen.py /^def pkgsources(pkg, mistakes):$/;" f platforms setup.py /^ platforms=['POSIX'],$/;" v plusk src/eps/impls/davidson/davidson.h /^ PetscInt plusk; \/* keep plusk eigenvectors from the last iteration *\/$/;" m struct:__anon65 plusk src/eps/impls/davidson/dvdupdatev.c /^ PetscInt plusk; \/* at restart, save plusk vectors from last iteration *\/$/;" m struct:__anon70 file: postsolve include/slepc/private/stimpl.h /^ PetscErrorCode (*postsolve)(ST);$/;" m struct:_STOps pp src/eps/impls/ciss/ciss.c /^ PetscScalar *pp;$/;" m struct:__anon61 file: pp src/nep/impls/ciss/nciss.c /^ PetscScalar *pp;$/;" m struct:__anon89 file: preTestConv src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*preTestConv)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt*);$/;" m struct:_dvdDashboard primme config/configure.py /^primme = primme.Primme(argdb,log)$/;" v primme src/eps/impls/external/primme/primme.c /^ primme_params primme; \/* param struc *\/$/;" m struct:__anon78 file: problem_type include/slepc/private/epsimpl.h /^ EPSProblemType problem_type; \/* which kind of problem to be solved *\/$/;" m struct:_p_EPS problem_type include/slepc/private/pepimpl.h /^ PEPProblemType problem_type; \/* which kind of problem to be solved *\/$/;" m struct:_p_PEP processDir bin/maint/generateetags.py /^def processDir(flist,dirname,names):$/;" f processDir bin/maint/generatefortranstubs.py /^def processDir(arg,dirname,names):$/;" f processFiles bin/maint/generateetags.py /^def processFiles(dirname,flist):$/;" f processf90interfaces bin/maint/generatefortranstubs.py /^def processf90interfaces(petscdir,verbose):$/;" f ps src/pep/impls/jd/pjdp.h /^ PetscScalar *ps;$/;" m struct:__anon100 publishoptions include/slepc/private/epsimpl.h /^ PetscErrorCode (*publishoptions)(EPS);$/;" m struct:_EPSOps publishoptions include/slepc/private/mfnimpl.h /^ PetscErrorCode (*publishoptions)(MFN);$/;" m struct:_MFNOps publishoptions include/slepc/private/nepimpl.h /^ PetscErrorCode (*publishoptions)(NEP);$/;" m struct:_NEPOps publishoptions include/slepc/private/pepimpl.h /^ PetscErrorCode (*publishoptions)(PEP);$/;" m struct:_PEPOps publishoptions include/slepc/private/svdimpl.h /^ PetscErrorCode (*publishoptions)(SVD);$/;" m struct:_SVDOps purify include/slepc/private/epsimpl.h /^ PetscBool purify; \/* whether eigenvectors need to be purified *\/$/;" m struct:_p_EPS qB src/pep/impls/krylov/pepkrylov.h /^ PetscScalar *S,*qB; \/* auxiliary matrices *\/$/;" m struct:__anon102 qcoeff src/sys/classes/fn/impls/rational/fnrational.c /^ PetscScalar *qcoeff; \/* denominator coefficients *\/$/;" m struct:__anon123 file: quad src/eps/impls/ciss/ciss.c /^ EPSCISSQuadRule quad;$/;" m struct:__anon61 file: quoteIfNeeded config/cmakeboot.py /^def quoteIfNeeded(path):$/;" f r_e src/eps/impls/davidson/dvdimprovex.c /^ PetscInt r_s,r_e; \/* the selected eigenpairs to improve *\/$/;" m struct:__anon68 file: r_s src/eps/impls/davidson/dvdimprovex.c /^ PetscInt r_s,r_e; \/* the selected eigenpairs to improve *\/$/;" m struct:__anon68 file: radius src/sys/classes/rg/impls/ellipse/rgellipse.c /^ PetscReal radius; \/* radius of the ellipse *\/$/;" m struct:__anon124 file: radius src/sys/classes/rg/impls/ring/rgring.c /^ PetscReal radius; \/* radius of the ellipse *\/$/;" m struct:__anon127 file: rand include/slepc/private/bvimpl.h /^ PetscRandom rand; \/* random number generator *\/$/;" m struct:_p_BV read_conf config/gmakegen.py /^ def read_conf(self):$/;" m class:Slepc real_nR src/eps/impls/davidson/davidson.h /^ PetscReal *real_nR; \/* original nR *\/$/;" m struct:_dvdDashboard real_nX src/eps/impls/davidson/davidson.h /^ PetscReal *real_nX; \/* original nX *\/$/;" m struct:_dvdDashboard reason include/slepc/private/epsimpl.h /^ EPSConvergedReason reason;$/;" m struct:_p_EPS reason include/slepc/private/mfnimpl.h /^ MFNConvergedReason reason;$/;" m struct:_p_MFN reason include/slepc/private/nepimpl.h /^ NEPConvergedReason reason;$/;" m struct:_p_NEP reason include/slepc/private/pepimpl.h /^ PEPConvergedReason reason;$/;" m struct:_p_PEP reason include/slepc/private/svdimpl.h /^ SVDConvergedReason reason;$/;" m struct:_p_SVD refine include/slepc/private/nepimpl.h /^ NEPRefine refine; \/* type of refinement to be applied after solve *\/$/;" m struct:_p_NEP refine include/slepc/private/pepimpl.h /^ PEPRefine refine; \/* type of refinement to be applied after solve *\/$/;" m struct:_p_PEP refine_blocksize src/eps/impls/ciss/ciss.c /^ PetscInt refine_blocksize;$/;" m struct:__anon61 file: refine_blocksize src/nep/impls/ciss/nciss.c /^ PetscInt refine_blocksize;$/;" m struct:__anon89 file: refine_inner src/eps/impls/ciss/ciss.c /^ PetscInt refine_inner;$/;" m struct:__anon61 file: refine_inner src/nep/impls/ciss/nciss.c /^ PetscInt refine_inner;$/;" m struct:__anon89 file: refined include/slepc/private/dsimpl.h /^ PetscBool refined; \/* get refined vectors instead of regular vectors *\/$/;" m struct:_p_DS refineksp include/slepc/private/nepimpl.h /^ KSP refineksp; \/* ksp used in refinement *\/$/;" m struct:_p_NEP refineksp include/slepc/private/pepimpl.h /^ KSP refineksp; \/* ksp used in refinement *\/$/;" m struct:_p_PEP refinesubc include/slepc/private/nepimpl.h /^ PetscSubcomm refinesubc; \/* context for sub-communicators *\/$/;" m struct:_p_NEP refinesubc include/slepc/private/pepimpl.h /^ PetscSubcomm refinesubc; \/* context for sub-communicators *\/$/;" m struct:_p_PEP relpath config/cmakegen.py /^ def relpath(filename):$/;" f function:pkgsources relpath config/gmakegen.py /^ def relpath(self, root, src):$/;" m class:Slepc reorthog src/eps/impls/krylov/lanczos/lanczos.c /^ EPSLanczosReorthogType reorthog;$/;" m struct:__anon82 file: rescale_eig src/eps/impls/ciss/ciss.c /^static PetscErrorCode rescale_eig(EPS eps,PetscInt nv)$/;" f file: reset include/slepc/private/epsimpl.h /^ PetscErrorCode (*reset)(EPS);$/;" m struct:_EPSOps reset include/slepc/private/mfnimpl.h /^ PetscErrorCode (*reset)(MFN);$/;" m struct:_MFNOps reset include/slepc/private/nepimpl.h /^ PetscErrorCode (*reset)(NEP);$/;" m struct:_NEPOps reset include/slepc/private/pepimpl.h /^ PetscErrorCode (*reset)(PEP);$/;" m struct:_PEPOps reset include/slepc/private/stimpl.h /^ PetscErrorCode (*reset)(ST);$/;" m struct:_STOps reset include/slepc/private/svdimpl.h /^ PetscErrorCode (*reset)(SVD);$/;" m struct:_SVDOps resize include/slepc/private/bvimpl.h /^ PetscErrorCode (*resize)(BV,PetscInt,PetscBool);$/;" m struct:_BVOps restart src/eps/impls/cg/lobpcg/lobpcg.c /^ PetscReal restart; \/* restart parameter *\/$/;" m struct:__anon59 file: restart src/eps/impls/external/trlan/trlanp.h /^ PetscBLASInt restart;$/;" m struct:__anon79 restartV src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*restartV)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard restartV_data src/eps/impls/davidson/davidson.h /^ void *restartV_data;$/;" m struct:_dvdDashboard restorearray include/slepc/private/bvimpl.h /^ PetscErrorCode (*restorearray)(BV,PetscScalar**);$/;" m struct:_BVOps restorearrayread include/slepc/private/bvimpl.h /^ PetscErrorCode (*restorearrayread)(BV,const PetscScalar**);$/;" m struct:_BVOps restorecolumn include/slepc/private/bvimpl.h /^ PetscErrorCode (*restorecolumn)(BV,PetscInt,Vec*);$/;" m struct:_BVOps rfactorial src/sys/classes/fn/impls/phi/fnphi.c /^const static PetscReal rfactorial[] = { 1, 1, 0.5, 1.0\/6, 1.0\/24, 1.0\/120, 1.0\/720, 1.0\/5040, 1.0\/40320, 1.0\/362880 };$/;" v file: rg include/slepc/private/epsimpl.h /^ RG rg; \/* optional region for filtering *\/$/;" m struct:_p_EPS rg include/slepc/private/nepimpl.h /^ RG rg; \/* optional region for filtering *\/$/;" m struct:_p_NEP rg include/slepc/private/pepimpl.h /^ RG rg; \/* optional region for filtering *\/$/;" m struct:_p_PEP rg include/slepcsc.h /^ RG rg;$/;" m struct:_n_SlepcSC rgappendoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c /^PETSC_EXTERN void PETSC_STDCALL rgappendoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f rgappendoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 29;" d file: rgappendoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 36;" d file: rggetoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c /^PETSC_EXTERN void PETSC_STDCALL rggetoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f rggetoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 30;" d file: rggetoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 37;" d file: rggettype_ src/sys/classes/rg/interface/ftn-custom/zrgf.c /^PETSC_EXTERN void PETSC_STDCALL rggettype_(RG *rg,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f rggettype_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 27;" d file: rggettype_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 34;" d file: rgsetoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c /^PETSC_EXTERN void PETSC_STDCALL rgsetoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f rgsetoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 28;" d file: rgsetoptionsprefix_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 35;" d file: rgsettype_ src/sys/classes/rg/interface/ftn-custom/zrgf.c /^PETSC_EXTERN void PETSC_STDCALL rgsettype_(RG *rg,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f rgsettype_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 26;" d file: rgsettype_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 33;" d file: rgview_ src/sys/classes/rg/interface/ftn-custom/zrgf.c /^PETSC_EXTERN void PETSC_STDCALL rgview_(RG *rg,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f rgview_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 31;" d file: rgview_ src/sys/classes/rg/interface/ftn-custom/zrgf.c 38;" d file: ri include/slepc/private/epsimpl.h /^ PetscScalar *rr,*ri; \/* values computed by user's arbitrary selection function *\/$/;" m struct:_p_EPS ri2dq src/eps/examples/tutorials/ex31.c /^PetscErrorCode ri2dq(PetscScalar Fr,PetscScalar Fi,PetscScalar delta,PetscScalar *Fd,PetscScalar *Fq)$/;" f rits include/slepc/private/nepimpl.h /^ PetscInt rits; \/* number of iterations of the refinement method *\/$/;" m struct:_p_NEP rits include/slepc/private/pepimpl.h /^ PetscInt rits; \/* number of iterations of the refinement method *\/$/;" m struct:_p_PEP rmat include/slepc/private/dsimpl.h /^ PetscReal *rmat[DS_NUM_MAT]; \/* the matrices (real) *\/$/;" m struct:_p_DS rr include/slepc/private/epsimpl.h /^ PetscScalar *rr,*ri; \/* values computed by user's arbitrary selection function *\/$/;" m struct:_p_EPS rrandom include/slepc/private/bvimpl.h /^ PetscBool rrandom; \/* reproducible random vectors *\/$/;" m struct:_p_BV rstor src/eps/impls/external/blzpack/blzpackp.h /^ PetscReal *rstor;$/;" m struct:__anon76 rtol include/slepc/private/nepimpl.h /^ PetscReal rtol; \/* tolerance for refinement *\/$/;" m struct:_p_NEP rtol include/slepc/private/pepimpl.h /^ PetscReal rtol; \/* tolerance for refinement *\/$/;" m struct:_p_PEP run config/install.py /^ def run(self):$/;" f run setup.py /^ def run(self):$/;" m class:cmd_install runcopy config/install.py /^ def runcopy(self):$/;" f rundone config/install.py /^ def rundone(self):$/;" f runfix config/install.py /^ def runfix(self):$/;" f runsetup config/install.py /^ def runsetup(self):$/;" f rwork include/slepc/private/dsimpl.h /^ PetscReal *rwork;$/;" m struct:_p_DS rwork src/eps/impls/external/arpack/arpackp.h /^ PetscReal *rwork;$/;" m struct:__anon74 s src/nep/impls/nleigs/nleigs.c /^ PetscScalar *s,*xi; \/* Leja-Bagby points *\/$/;" m struct:__anon92 file: s0 src/eps/impls/krylov/krylovschur/krylovschur.h /^ EPS_shift s0; \/* Initial shift *\/$/;" m struct:_n_SR sA src/eps/impls/davidson/davidson.h /^ MatType_t sA,sB; \/* matrix specifications *\/$/;" m struct:_dvdDashboard sB src/eps/impls/davidson/davidson.h /^ MatType_t sA,sB; \/* matrix specifications *\/$/;" m struct:_dvdDashboard sEP src/eps/impls/davidson/davidson.h /^ EPType_t sEP; \/* problem specifications *\/$/;" m struct:_dvdDashboard sPres src/eps/impls/krylov/krylovschur/krylovschur.h /^ EPS_shift sPres; \/* Present shift *\/$/;" m struct:_n_SR sPrev src/eps/impls/krylov/krylovschur/krylovschur.h /^ EPS_shift sPrev;$/;" m struct:_n_SR sc include/slepc/private/dsimpl.h /^ SlepcSC sc; \/* sorting criterion *\/$/;" m struct:_p_DS sc include/slepc/private/epsimpl.h /^ SlepcSC sc; \/* sorting criterion data *\/$/;" m struct:_p_EPS sc include/slepc/private/nepimpl.h /^ SlepcSC sc; \/* sorting criterion data *\/$/;" m struct:_p_NEP sc include/slepc/private/pepimpl.h /^ SlepcSC sc; \/* sorting criterion data *\/$/;" m struct:_p_PEP sc include/slepc/private/svdimpl.h /^ SlepcSC sc; \/* sorting criterion data *\/$/;" m struct:_p_SVD scale include/slepc/private/bvimpl.h /^ PetscErrorCode (*scale)(BV,PetscInt,PetscScalar);$/;" m struct:_BVOps scale include/slepc/private/pepimpl.h /^ PEPScale scale; \/* scaling strategy to be used *\/$/;" m struct:_p_PEP scatter_id src/nep/interface/neprefine.c /^ VecScatter *scatter_id,nst;$/;" m struct:__anon97 file: scatter_id src/pep/impls/krylov/toar/nrefine.c /^ VecScatter *scatter_id,*scatterp_id;$/;" m struct:__anon105 file: scatter_id src/pep/interface/peprefine.c /^ VecScatter *scatter_id,nst;$/;" m struct:__anon108 file: scatter_sub src/pep/impls/krylov/toar/nrefine.c /^ VecScatter scatter_sub;$/;" m struct:__anon105 file: scatterctx src/pep/impls/krylov/toar/nrefine.c /^ VecScatter scatterctx;$/;" m struct:__anon105 file: scatterin src/eps/impls/ciss/ciss.c /^ VecScatter scatterin;$/;" m struct:__anon61 file: scatterp_id src/pep/impls/krylov/toar/nrefine.c /^ VecScatter *scatter_id,*scatterp_id;$/;" m struct:__anon105 file: scheme include/slepc/private/nepimpl.h /^ NEPRefineScheme scheme; \/* scheme for solving linear systems within refinement *\/$/;" m struct:_p_NEP scheme include/slepc/private/pepimpl.h /^ PEPRefineScheme scheme; \/* scheme for solving linear systems within refinement *\/$/;" m struct:_p_PEP searchlines config/configure.py /^ searchlines = f.readlines()$/;" v select src/eps/impls/external/arpack/arpackp.h /^ PetscBool *select;$/;" m struct:__anon74 setfromoptions include/slepc/private/bvimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,BV);$/;" m struct:_BVOps setfromoptions include/slepc/private/epsimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,EPS);$/;" m struct:_EPSOps setfromoptions include/slepc/private/fnimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,FN);$/;" m struct:_FNOps setfromoptions include/slepc/private/mfnimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,MFN);$/;" m struct:_MFNOps setfromoptions include/slepc/private/nepimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,NEP);$/;" m struct:_NEPOps setfromoptions include/slepc/private/pepimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,PEP);$/;" m struct:_PEPOps setfromoptions include/slepc/private/rgimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,RG);$/;" m struct:_RGOps setfromoptions include/slepc/private/stimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,ST);$/;" m struct:_STOps setfromoptions include/slepc/private/svdimpl.h /^ PetscErrorCode (*setfromoptions)(PetscOptionItems*,SVD);$/;" m struct:_SVDOps setfromoptionscalled src/pep/impls/linear/linearp.h /^ PetscBool setfromoptionscalled;$/;" m struct:__anon106 setmat src/sys/classes/st/impls/precond/precond.c /^ PetscBool setmat;$/;" m struct:__anon129 file: setshift include/slepc/private/stimpl.h /^ PetscErrorCode (*setshift)(ST,PetscScalar);$/;" m struct:_STOps setup config/cmakeboot.py /^ def setup(self):$/;" m class:PETScMaker setup include/slepc/private/epsimpl.h /^ PetscErrorCode (*setup)(EPS);$/;" m struct:_EPSOps setup include/slepc/private/mfnimpl.h /^ PetscErrorCode (*setup)(MFN);$/;" m struct:_MFNOps setup include/slepc/private/nepimpl.h /^ PetscErrorCode (*setup)(NEP);$/;" m struct:_NEPOps setup include/slepc/private/pepimpl.h /^ PetscErrorCode (*setup)(PEP);$/;" m struct:_PEPOps setup include/slepc/private/stimpl.h /^ PetscErrorCode (*setup)(ST);$/;" m struct:_STOps setup include/slepc/private/svdimpl.h /^ PetscErrorCode (*setup)(SVD);$/;" m struct:_SVDOps setupDirectories config/install.py /^ def setupDirectories(self):$/;" m class:Installer setupModules config/cmakeboot.py /^ def setupModules(self):$/;" m class:PETScMaker setupcalled include/slepc/private/mfnimpl.h /^ PetscInt setupcalled;$/;" m struct:_p_MFN sfactor include/slepc/private/pepimpl.h /^ PetscReal sfactor,dsfactor; \/* scaling factors *\/$/;" m struct:_p_PEP sfactor include/slepc/private/rgimpl.h /^ PetscReal sfactor; \/* scaling factor *\/$/;" m struct:_p_RG sfactor src/pep/impls/linear/linearp.h /^ PetscReal sfactor,dsfactor; \/* scaling factors *\/$/;" m struct:__anon106 sfactor_set include/slepc/private/pepimpl.h /^ PetscBool sfactor_set; \/* flag to indicate the user gave sfactor *\/$/;" m struct:_p_PEP shift_matrix include/slepc/private/stimpl.h /^ STMatMode shift_matrix;$/;" m struct:_p_ST shift_type src/eps/impls/power/power.c /^ EPSPowerShiftType shift_type;$/;" m struct:__anon83 file: shifts src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal *shifts; \/* array containing global shifts *\/$/;" m struct:__anon81 shifts src/nep/impls/nleigs/nleigs.c /^ PetscScalar *shifts; \/* user-provided shifts for the Rational Krylov variant *\/$/;" m struct:__anon92 file: sigma include/slepc/private/stimpl.h /^ PetscScalar sigma; \/* value of the shift *\/$/;" m struct:_p_ST sigma include/slepc/private/svdimpl.h /^ PetscReal *sigma; \/* singular values *\/$/;" m struct:_p_SVD sigma src/eps/examples/tutorials/ex30.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon56 file: sigma src/eps/examples/tutorials/ex9.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon58 file: sigma src/eps/impls/ciss/ciss.c /^ PetscReal *sigma; \/* threshold for numerical rank *\/$/;" m struct:__anon61 file: sigma src/nep/impls/ciss/nciss.c /^ PetscReal *sigma; \/* threshold for numerical rank *\/$/;" m struct:__anon89 file: sigma_set include/slepc/private/stimpl.h /^ PetscBool sigma_set; \/* whether the user provided the shift or not *\/$/;" m struct:_p_ST singularitiesctx src/nep/impls/nleigs/nleigs.c /^ void *singularitiesctx;$/;" m struct:__anon92 file: sits include/slepc/private/pepimpl.h /^ PetscInt sits; \/* number of iterations of the scaling method *\/$/;" m struct:_p_PEP size_D src/eps/impls/davidson/davidson.h /^ PetscInt size_D; \/* active vectors *\/$/;" m struct:_dvdDashboard size_MT src/eps/impls/davidson/davidson.h /^ PetscInt size_MT; \/* rows in MT *\/$/;" m struct:_dvdDashboard size_V src/eps/impls/davidson/davidson.h /^ PetscInt size_V; \/* real size of V (nev+size_P+mpd) *\/$/;" m struct:__anon66 size_X src/eps/impls/davidson/dvdgd2.c /^ PetscInt size_X;$/;" m struct:__anon67 file: size_X src/eps/impls/davidson/dvdimprovex.c /^ PetscInt size_X;$/;" m struct:__anon68 file: size_cX src/eps/impls/davidson/dvdimprovex.c /^ PetscInt size_cX; \/* last value of d->size_cX *\/$/;" m struct:__anon68 file: size_iXKZ src/eps/impls/davidson/dvdimprovex.c /^ PetscInt size_iXKZ; \/* size of iXKZ *\/$/;" m struct:__anon68 file: size_oldU src/eps/impls/davidson/dvdupdatev.c /^ PetscInt size_oldU; \/* size of oldU *\/$/;" m struct:__anon70 file: slambda include/slepc/private/pepimpl.h /^ PetscReal slambda; \/* norm eigenvalue approximation for scaling *\/$/;" m struct:_p_PEP slepc config/configure.py /^slepc = slepc.SLEPc(argdb,log)$/;" v slepc_blopex_useconstr src/eps/impls/external/blopex/blopex.c /^PetscInt slepc_blopex_useconstr = -1;$/;" v slepc_blopex_useconstr src/eps/impls/external/blopex/slepc-interface.h /^PETSC_INTERN PetscInt slepc_blopex_useconstr;$/;" v slepcbv src/sys/f90-mod/slepcsysmod.F /^ module slepcbv$/;" m slepcbvdef src/sys/f90-mod/slepcsysmod.F /^ module slepcbvdef$/;" m slepcconf config/configure.py /^slepcconf = CreateFile(includedir,'slepcconf.h',log)$/;" v slepcconvmonitorcreate_ src/sys/ftn-custom/zslepcutil.c /^PETSC_EXTERN void PETSC_STDCALL slepcconvmonitorcreate_(PetscViewer *vin,PetscViewerFormat *format,SlepcConvMonitor *ctx,PetscErrorCode *ierr)$/;" f slepcconvmonitorcreate_ src/sys/ftn-custom/zslepcutil.c 26;" d file: slepcconvmonitorcreate_ src/sys/ftn-custom/zslepcutil.c 29;" d file: slepcconvmonitordestroy_ src/sys/ftn-custom/zslepcutil.c /^PETSC_EXTERN void slepcconvmonitordestroy_(SlepcConvMonitor *ctx,PetscErrorCode *ierr)$/;" f slepcconvmonitordestroy_ src/sys/ftn-custom/zslepcutil.c 27;" d file: slepcconvmonitordestroy_ src/sys/ftn-custom/zslepcutil.c 30;" d file: slepcdate config/configure.py /^ slepcdate = dateutil.parser.parse(slepc.gitdate)$/;" v slepcds src/sys/f90-mod/slepcsysmod.F /^ module slepcds$/;" m slepcdsdef src/sys/f90-mod/slepcsysmod.F /^ module slepcdsdef$/;" m slepceps src/eps/f90-mod/slepcepsmod.F /^ module slepceps$/;" m slepcepsdef src/eps/f90-mod/slepcepsmod.F /^ module slepcepsdef$/;" m slepcfn src/sys/f90-mod/slepcsysmod.F /^ module slepcfn$/;" m slepcfndef src/sys/f90-mod/slepcsysmod.F /^ module slepcfndef$/;" m slepcinitialize_ src/sys/ftn-custom/zslepc_start.c 29;" d file: slepcinitialize_ src/sys/ftn-custom/zslepc_start.c 32;" d file: slepcinitializefortran_ src/sys/ftn-custom/zslepc_startf.c /^PETSC_EXTERN void PETSC_STDCALL slepcinitializefortran_(PetscErrorCode *info)$/;" f slepcinitializefortran_ src/sys/ftn-custom/zslepc_startf.c 25;" d file: slepcinitializefortran_ src/sys/ftn-custom/zslepc_startf.c 27;" d file: slepcmfn src/mfn/f90-mod/slepcmfnmod.F /^ module slepcmfn$/;" m slepcmfndef src/mfn/f90-mod/slepcmfnmod.F /^ module slepcmfndef$/;" m slepcnep src/nep/f90-mod/slepcnepmod.F /^ module slepcnep$/;" m slepcnepdef src/nep/f90-mod/slepcnepmod.F /^ module slepcnepdef$/;" m slepcpep src/pep/f90-mod/slepcpepmod.F /^ module slepcpep$/;" m slepcpepdef src/pep/f90-mod/slepcpepmod.F /^ module slepcpepdef$/;" m slepcrg src/sys/f90-mod/slepcsysmod.F /^ module slepcrg$/;" m slepcrgdef src/sys/f90-mod/slepcsysmod.F /^ module slepcrgdef$/;" m slepcrules config/configure.py /^slepcrules = CreateFile(confdir,'slepcrules',log)$/;" v slepcst src/sys/f90-mod/slepcsysmod.F /^ module slepcst$/;" m slepcstdef src/sys/f90-mod/slepcsysmod.F /^ module slepcstdef$/;" m slepcsvd src/svd/f90-mod/slepcsvdmod.F /^ module slepcsvd$/;" m slepcsvddef src/svd/f90-mod/slepcsvdmod.F /^ module slepcsvddef$/;" m slepcsys src/sys/f90-mod/slepcsysmod.F /^ module slepcsys$/;" m slepcsysdef src/sys/f90-mod/slepcsysmod.F /^ module slepcsysdef$/;" m slepcvars config/configure.py /^slepcvars = CreateFile(confdir,'slepcvariables',log)$/;" v slice src/eps/impls/external/blzpack/blzpackp.h /^ PetscBLASInt slice; \/* use spectrum slicing *\/$/;" m struct:__anon76 sn src/sys/classes/ds/impls/ghiep/invit.c /^ PetscReal sn;$/;" m struct:HRtr file: solve include/slepc/private/dsimpl.h /^ PetscErrorCode (*solve[DS_MAX_SOLVE])(DS,PetscScalar*,PetscScalar*);$/;" m struct:_DSOps solve include/slepc/private/epsimpl.h /^ PetscErrorCode (*solve)(EPS);$/;" m struct:_EPSOps solve include/slepc/private/mfnimpl.h /^ PetscErrorCode (*solve)(MFN,Vec,Vec);$/;" m struct:_MFNOps solve include/slepc/private/nepimpl.h /^ PetscErrorCode (*solve)(NEP);$/;" m struct:_NEPOps solve include/slepc/private/pepimpl.h /^ PetscErrorCode (*solve)(PEP);$/;" m struct:_PEPOps solve include/slepc/private/svdimpl.h /^ PetscErrorCode (*solve)(SVD);$/;" m struct:_SVDOps solvematcoeffs include/slepc/private/pepimpl.h /^ PetscScalar *solvematcoeffs; \/* coefficients to compute the matrix to be inverted *\/$/;" m struct:_p_PEP sort include/slepc/private/dsimpl.h /^ PetscErrorCode (*sort)(DS,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*);$/;" m struct:_DSOps sortRealEigenvalues src/eps/impls/krylov/krylovschur/ks-slice.c /^static PetscErrorCode sortRealEigenvalues(PetscScalar *r,PetscInt *perm,PetscInt nr,PetscBool prev,PetscInt dir)$/;" f file: sowing config/configure.py /^sowing = sowing.Sowing(argdb,log)$/;" v spurious_threshold src/eps/impls/ciss/ciss.c /^ PetscReal spurious_threshold; \/* discard spurious eigenpairs *\/$/;" m struct:__anon61 file: spurious_threshold src/nep/impls/ciss/nciss.c /^ PetscReal spurious_threshold; \/* discard spurious eigenpairs *\/$/;" m struct:__anon89 file: sr src/eps/impls/krylov/krylovschur/krylovschur.h /^ EPS_SR sr; \/* spectrum slicing context *\/$/;" m struct:__anon81 st include/slepc/private/bvimpl.h /^ PetscObjectState st[2]; \/* state of obtained vectors *\/$/;" m struct:_p_BV st include/slepc/private/epsimpl.h /^ ST st; \/* spectral transformation object *\/$/;" m struct:_p_EPS st include/slepc/private/pepimpl.h /^ ST st; \/* spectral transformation object *\/$/;" m struct:_p_PEP st src/eps/impls/external/blopex/blopex.c /^ ST st;$/;" m struct:__anon75 file: st src/sys/classes/st/interface/stshellmat.c /^ ST st;$/;" m struct:__anon132 file: stappendoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c /^PETSC_EXTERN void PETSC_STDCALL stappendoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f stappendoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c 29;" d file: stappendoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c 36;" d file: startList src/eps/impls/davidson/davidson.h /^ dvdFunctionList *startList; \/* starting list *\/$/;" m struct:_dvdDashboard start_ang src/sys/classes/rg/impls/ring/rgring.c /^ PetscReal start_ang; \/* start angle *\/$/;" m struct:__anon127 file: startsWithPrefix bin/maint/generateetags.py /^def startsWithPrefix(file,prefixes):$/;" f state include/slepc/private/dsimpl.h /^ DSStateType state; \/* the current state *\/$/;" m struct:_p_DS state include/slepc/private/epsimpl.h /^ EPSStateType state; \/* initial -> setup -> solved -> eigenvectors *\/$/;" m struct:_p_EPS state include/slepc/private/nepimpl.h /^ NEPStateType state; \/* initial -> setup -> solved -> eigenvectors *\/$/;" m struct:_p_NEP state include/slepc/private/pepimpl.h /^ PEPStateType state; \/* initial -> setup -> solved -> eigenvectors *\/$/;" m struct:_p_PEP state include/slepc/private/stimpl.h /^ STStateType state; \/* initial -> setup -> with updated matrices *\/$/;" m struct:_p_ST state include/slepc/private/svdimpl.h /^ SVDStateType state; \/* initial -> setup -> solved -> vectors *\/$/;" m struct:_p_SVD state src/eps/impls/davidson/davidson.h /^ PetscInt state; \/* method states:$/;" m struct:__anon66 stgetoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c /^PETSC_EXTERN void PETSC_STDCALL stgetoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f stgetoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c 30;" d file: stgetoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c 37;" d file: stgettype_ src/sys/classes/st/interface/ftn-custom/zstf.c /^PETSC_EXTERN void PETSC_STDCALL stgettype_(ST *st,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f stgettype_ src/sys/classes/st/interface/ftn-custom/zstf.c 27;" d file: stgettype_ src/sys/classes/st/interface/ftn-custom/zstf.c 34;" d file: stop include/slepc/private/epsimpl.h /^ EPSStop stop; \/* stopping test *\/$/;" m struct:_p_EPS stop include/slepc/private/nepimpl.h /^ NEPStop stop; \/* stopping test *\/$/;" m struct:_p_NEP stop include/slepc/private/pepimpl.h /^ PEPStop stop; \/* stopping test *\/$/;" m struct:_p_PEP stop include/slepc/private/svdimpl.h /^ SVDStop stop; \/* stopping test *\/$/;" m struct:_p_SVD stopdestroy src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId stopdestroy;$/;" m struct:__anon84 file: stopdestroy src/nep/interface/ftn-custom/znepf.c /^ PetscFortranCallbackId stopdestroy;$/;" m struct:__anon96 file: stopdestroy src/pep/interface/ftn-custom/zpepf.c /^ PetscFortranCallbackId stopdestroy;$/;" m struct:__anon107 file: stopdestroy src/svd/interface/ftn-custom/zsvdf.c /^ PetscFortranCallbackId stopdestroy;$/;" m struct:__anon114 file: stopping include/slepc/private/epsimpl.h /^ PetscErrorCode (*stopping)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*);$/;" m struct:_p_EPS stopping include/slepc/private/nepimpl.h /^ PetscErrorCode (*stopping)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*);$/;" m struct:_p_NEP stopping include/slepc/private/pepimpl.h /^ PetscErrorCode (*stopping)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*);$/;" m struct:_p_PEP stopping include/slepc/private/svdimpl.h /^ PetscErrorCode (*stopping)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*);$/;" m struct:_p_SVD stopping src/eps/interface/ftn-custom/zepsf.c /^ PetscFortranCallbackId stopping;$/;" m struct:__anon84 file: stopping src/nep/interface/ftn-custom/znepf.c /^ PetscFortranCallbackId stopping;$/;" m struct:__anon96 file: stopping src/pep/interface/ftn-custom/zpepf.c /^ PetscFortranCallbackId stopping;$/;" m struct:__anon107 file: stopping src/svd/interface/ftn-custom/zsvdf.c /^ PetscFortranCallbackId stopping;$/;" m struct:__anon114 file: stoppingctx include/slepc/private/epsimpl.h /^ void *stoppingctx;$/;" m struct:_p_EPS stoppingctx include/slepc/private/nepimpl.h /^ void *stoppingctx;$/;" m struct:_p_NEP stoppingctx include/slepc/private/pepimpl.h /^ void *stoppingctx;$/;" m struct:_p_PEP stoppingctx include/slepc/private/svdimpl.h /^ void *stoppingctx;$/;" m struct:_p_SVD stoppingdestroy include/slepc/private/epsimpl.h /^ PetscErrorCode (*stoppingdestroy)(void*);$/;" m struct:_p_EPS stoppingdestroy include/slepc/private/nepimpl.h /^ PetscErrorCode (*stoppingdestroy)(void*);$/;" m struct:_p_NEP stoppingdestroy include/slepc/private/pepimpl.h /^ PetscErrorCode (*stoppingdestroy)(void*);$/;" m struct:_p_PEP stoppingdestroy include/slepc/private/svdimpl.h /^ PetscErrorCode (*stoppingdestroy)(void*);$/;" m struct:_p_SVD str include/slepc/private/stimpl.h /^ MatStructure str; \/* whether matrices have the same pattern or not *\/$/;" m struct:_p_ST stripsplit config/cmakegen.py /^def stripsplit(line):$/;" f stsetoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c /^PETSC_EXTERN void PETSC_STDCALL stsetoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f stsetoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c 28;" d file: stsetoptionsprefix_ src/sys/classes/st/interface/ftn-custom/zstf.c 35;" d file: stsettype_ src/sys/classes/st/interface/ftn-custom/zstf.c /^PETSC_EXTERN void PETSC_STDCALL stsettype_(ST *st,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f stsettype_ src/sys/classes/st/interface/ftn-custom/zstf.c 26;" d file: stsettype_ src/sys/classes/st/interface/ftn-custom/zstf.c 33;" d file: stshellgetcontext_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^PETSC_EXTERN void PETSC_STDCALL stshellgetcontext_(ST *st,void **ctx,PetscErrorCode *ierr)$/;" f stshellgetcontext_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 26;" d file: stshellgetcontext_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 31;" d file: stshellsetapply_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^PETSC_EXTERN void PETSC_STDCALL stshellsetapply_(ST *st,void (PETSC_STDCALL *apply)(void*,Vec*,Vec*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f stshellsetapply_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 27;" d file: stshellsetapply_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 32;" d file: stshellsetapplytranspose_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^PETSC_EXTERN void PETSC_STDCALL stshellsetapplytranspose_(ST *st,void (PETSC_STDCALL *applytranspose)(void*,Vec*,Vec*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f stshellsetapplytranspose_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 28;" d file: stshellsetapplytranspose_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 33;" d file: stshellsetbacktransform_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c /^PETSC_EXTERN void PETSC_STDCALL stshellsetbacktransform_(ST *st,void (PETSC_STDCALL *backtransform)(void*,PetscScalar*,PetscScalar*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f stshellsetbacktransform_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 29;" d file: stshellsetbacktransform_ src/sys/classes/st/impls/shell/ftn-custom/zshell.c 34;" d file: stview_ src/sys/classes/st/interface/ftn-custom/zstf.c /^PETSC_EXTERN void PETSC_STDCALL stview_(ST *st,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f stview_ src/sys/classes/st/interface/ftn-custom/zstf.c 31;" d file: stview_ src/sys/classes/st/interface/ftn-custom/zstf.c 38;" d file: subc src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscSubcomm subc; \/* context for subcommunicators *\/$/;" m struct:__anon81 subc src/nep/interface/neprefine.c /^ PetscSubcomm subc;$/;" m struct:__anon97 file: subc src/pep/impls/krylov/toar/nrefine.c /^ PetscSubcomm subc;$/;" m struct:__anon105 file: subcomm src/eps/impls/ciss/ciss.c /^ PetscSubcomm subcomm;$/;" m struct:__anon61 file: subcomm src/nep/impls/ciss/nciss.c /^ PetscSubcomm subcomm;$/;" m struct:__anon89 file: subcomm_id src/eps/impls/ciss/ciss.c /^ PetscInt subcomm_id;$/;" m struct:__anon61 file: subcomm_id src/nep/impls/ciss/nciss.c /^ PetscInt subcomm_id;$/;" m struct:__anon89 file: subintervals src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal *subintervals; \/* partition of global interval *\/$/;" m struct:__anon81 subintset src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscBool subintset; \/* subintervals set by user *\/$/;" m struct:__anon81 submata src/eps/impls/krylov/krylovschur/krylovschur.h /^ Mat *submata,*submatb; \/* seq matrices used in update of subcomm mats *\/$/;" m struct:__anon81 submatb src/eps/impls/krylov/krylovschur/krylovschur.h /^ Mat *submata,*submatb; \/* seq matrices used in update of subcomm mats *\/$/;" m struct:__anon81 summary config/cmakegen.py /^ def summary(self):$/;" m class:Mistakes summary config/gmakegen.py /^ def summary(self):$/;" m class:Slepc svdappendoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdappendoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f svdappendoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c 41;" d file: svdappendoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c 62;" d file: svdconvergedabsolute_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdconvergedabsolute_(SVD *svd,PetscReal *sigma,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f svdconvergedabsolute_ src/svd/interface/ftn-custom/zsvdf.c 43;" d file: svdconvergedabsolute_ src/svd/interface/ftn-custom/zsvdf.c 64;" d file: svdconvergedrelative_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdconvergedrelative_(SVD *svd,PetscReal *sigma,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)$/;" f svdconvergedrelative_ src/svd/interface/ftn-custom/zsvdf.c 44;" d file: svdconvergedrelative_ src/svd/interface/ftn-custom/zsvdf.c 65;" d file: svderrorview_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svderrorview_(SVD *svd,SVDErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f svderrorview_ src/svd/interface/ftn-custom/zsvdf.c 33;" d file: svderrorview_ src/svd/interface/ftn-custom/zsvdf.c 54;" d file: svdgetoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdgetoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f svdgetoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c 42;" d file: svdgetoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c 63;" d file: svdgettype_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdgettype_(SVD *svd,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f svdgettype_ src/svd/interface/ftn-custom/zsvdf.c 38;" d file: svdgettype_ src/svd/interface/ftn-custom/zsvdf.c 59;" d file: svdmonitorall_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void svdmonitorall_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f svdmonitorall_ src/svd/interface/ftn-custom/zsvdf.c 27;" d file: svdmonitorall_ src/svd/interface/ftn-custom/zsvdf.c 48;" d file: svdmonitorconverged_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void svdmonitorconverged_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)$/;" f svdmonitorconverged_ src/svd/interface/ftn-custom/zsvdf.c 30;" d file: svdmonitorconverged_ src/svd/interface/ftn-custom/zsvdf.c 51;" d file: svdmonitorfirst_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void svdmonitorfirst_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)$/;" f svdmonitorfirst_ src/svd/interface/ftn-custom/zsvdf.c 31;" d file: svdmonitorfirst_ src/svd/interface/ftn-custom/zsvdf.c 52;" d file: svdmonitorlg_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void svdmonitorlg_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f svdmonitorlg_ src/svd/interface/ftn-custom/zsvdf.c 28;" d file: svdmonitorlg_ src/svd/interface/ftn-custom/zsvdf.c 49;" d file: svdmonitorlgall_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void svdmonitorlgall_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)$/;" f svdmonitorlgall_ src/svd/interface/ftn-custom/zsvdf.c 29;" d file: svdmonitorlgall_ src/svd/interface/ftn-custom/zsvdf.c 50;" d file: svdmonitorset_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdmonitorset_(SVD *svd,void (PETSC_STDCALL *monitor)(SVD*,PetscInt*,PetscInt*,PetscReal*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)$/;" f svdmonitorset_ src/svd/interface/ftn-custom/zsvdf.c 39;" d file: svdmonitorset_ src/svd/interface/ftn-custom/zsvdf.c 60;" d file: svdreasonview_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdreasonview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f svdreasonview_ src/svd/interface/ftn-custom/zsvdf.c 34;" d file: svdreasonview_ src/svd/interface/ftn-custom/zsvdf.c 55;" d file: svdsetconvergencetestfunction_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdsetconvergencetestfunction_(SVD *svd,void (PETSC_STDCALL *func)(SVD*,PetscReal*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f svdsetconvergencetestfunction_ src/svd/interface/ftn-custom/zsvdf.c 45;" d file: svdsetconvergencetestfunction_ src/svd/interface/ftn-custom/zsvdf.c 66;" d file: svdsetoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdsetoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f svdsetoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c 40;" d file: svdsetoptionsprefix_ src/svd/interface/ftn-custom/zsvdf.c 61;" d file: svdsetstoppingtestfunction_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdsetstoppingtestfunction_(SVD *svd,void (PETSC_STDCALL *func)(SVD*,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)$/;" f svdsetstoppingtestfunction_ src/svd/interface/ftn-custom/zsvdf.c 46;" d file: svdsetstoppingtestfunction_ src/svd/interface/ftn-custom/zsvdf.c 67;" d file: svdsettype_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdsettype_(SVD *svd,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))$/;" f svdsettype_ src/svd/interface/ftn-custom/zsvdf.c 37;" d file: svdsettype_ src/svd/interface/ftn-custom/zsvdf.c 58;" d file: svdstoppingbasic_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdstoppingbasic_(SVD *svd,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nsv,SVDConvergedReason *reason,void *ctx,PetscErrorCode *ierr)$/;" f svdvaluesview_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdvaluesview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f svdvaluesview_ src/svd/interface/ftn-custom/zsvdf.c 35;" d file: svdvaluesview_ src/svd/interface/ftn-custom/zsvdf.c 56;" d file: svdvectorsview_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdvectorsview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f svdvectorsview_ src/svd/interface/ftn-custom/zsvdf.c 36;" d file: svdvectorsview_ src/svd/interface/ftn-custom/zsvdf.c 57;" d file: svdview_ src/svd/interface/ftn-custom/zsvdf.c /^PETSC_EXTERN void PETSC_STDCALL svdview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)$/;" f svdview_ src/svd/interface/ftn-custom/zsvdf.c 32;" d file: svdview_ src/svd/interface/ftn-custom/zsvdf.c 53;" d file: t include/slepc/private/bvimpl.h /^ Vec t; \/* template vector *\/$/;" m struct:_p_BV t include/slepc/private/dsimpl.h /^ PetscInt t; \/* length of decomposition when it was truncated *\/$/;" m struct:_p_DS t src/nep/impls/nleigs/nleigs.c /^ Vec t;$/;" m struct:__anon93 file: t src/pep/impls/krylov/toar/nrefine.c /^ Vec t,tg,Rv,Vi,tp,tpg;$/;" m struct:__anon105 file: t src/pep/impls/krylov/toar/nrefine.c /^ Vec t;$/;" m struct:__anon104 file: t1 src/pep/impls/krylov/toar/nrefine.c /^ Vec tN,ttN,t1,vseq;$/;" m struct:__anon105 file: tN src/pep/impls/krylov/toar/nrefine.c /^ Vec tN,ttN,t1,vseq;$/;" m struct:__anon105 file: tarball setup.py /^def tarball():$/;" f target include/slepc/private/epsimpl.h /^ PetscScalar target; \/* target value *\/$/;" m struct:_p_EPS target include/slepc/private/nepimpl.h /^ PetscScalar target; \/* target value *\/$/;" m struct:_p_NEP target include/slepc/private/pepimpl.h /^ PetscScalar target; \/* target value *\/$/;" m struct:_p_PEP target src/eps/examples/tutorials/ex24.c /^ PetscReal target;$/;" m struct:__anon55 file: target src/eps/impls/davidson/davidson.h /^ PetscScalar target[2]; \/* target value *\/$/;" m struct:_dvdDashboard target src/eps/impls/external/primme/primme.c /^ PetscReal target; \/* a copy of eps's target *\/$/;" m struct:__anon78 file: tau src/sys/classes/ds/impls/ghiep/invit.c /^ PetscScalar tau[2];$/;" m struct:HRtr file: tau1 src/eps/examples/tutorials/ex30.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon56 file: tau1 src/eps/examples/tutorials/ex9.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon58 file: tau2 src/eps/examples/tutorials/ex30.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon56 file: tau2 src/eps/examples/tutorials/ex9.c /^ PetscScalar alpha,beta,tau1,tau2,sigma;$/;" m struct:__anon58 file: testConv src/eps/impls/davidson/davidson.h /^ PetscBool (*testConv)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscReal,PetscReal*);$/;" m struct:_dvdDashboard testConv_data src/eps/impls/davidson/davidson.h /^ void *testConv_data;$/;" m struct:_dvdDashboard testruns config/configure.py /^ testruns = testruns.union(set(['DATAFILESPATH']))$/;" v testruns config/configure.py /^ testruns = testruns.union(set(['DATAFILESPATH_Complex']))$/;" v testruns config/configure.py /^ testruns = testruns.union(set(['C_NoF128']))$/;" v testruns config/configure.py /^testruns = set(petsc.test_runs.split())$/;" v testruns config/configure.py /^testruns = testruns.intersection(set(['C','F90','Fortran','C_Complex','Fortran_Complex','C_NoComplex','Fortran_NoComplex']))$/;" v tg src/pep/impls/krylov/toar/nrefine.c /^ Vec t,tg,Rv,Vi,tp,tpg;$/;" m struct:__anon105 file: theta src/eps/impls/davidson/dvdimprovex.c /^ PetscScalar theta[4],thetai[2]; \/* the shifts used in the correction eq. *\/$/;" m struct:__anon68 file: theta src/pep/impls/jd/pjdp.h /^ PetscScalar theta;$/;" m struct:__anon101 thetai src/eps/impls/davidson/dvdimprovex.c /^ PetscScalar theta[4],thetai[2]; \/* the shifts used in the correction eq. *\/$/;" m struct:__anon68 file: tol include/slepc/private/epsimpl.h /^ PetscReal tol; \/* tolerance *\/$/;" m struct:_p_EPS tol include/slepc/private/mfnimpl.h /^ PetscReal tol; \/* tolerance *\/$/;" m struct:_p_MFN tol include/slepc/private/nepimpl.h /^ PetscReal tol; \/* tolerance *\/$/;" m struct:_p_NEP tol include/slepc/private/pepimpl.h /^ PetscReal tol; \/* tolerance *\/$/;" m struct:_p_PEP tol include/slepc/private/svdimpl.h /^ PetscReal tol; \/* tolerance *\/$/;" m struct:_p_SVD tol src/eps/impls/davidson/davidson.h /^ PetscReal tol; \/* tolerance *\/$/;" m struct:_dvdDashboard tol src/eps/impls/davidson/dvdimprovex.c /^ PetscReal tol; \/* the maximum solution tolerance *\/$/;" m struct:__anon68 file: tol src/eps/impls/external/blopex/blopex.c /^ lobpcg_Tolerance tol;$/;" m struct:__anon75 file: tp src/pep/impls/krylov/toar/nrefine.c /^ Vec t,tg,Rv,Vi,tp,tpg;$/;" m struct:__anon105 file: tpg src/pep/impls/krylov/toar/nrefine.c /^ Vec t,tg,Rv,Vi,tp,tpg;$/;" m struct:__anon105 file: trackall include/slepc/private/epsimpl.h /^ PetscBool trackall; \/* whether all the residuals must be computed *\/$/;" m struct:_p_EPS trackall include/slepc/private/nepimpl.h /^ PetscBool trackall; \/* whether all the residuals must be computed *\/$/;" m struct:_p_NEP trackall include/slepc/private/pepimpl.h /^ PetscBool trackall; \/* whether all the residuals must be computed *\/$/;" m struct:_p_PEP trackall include/slepc/private/svdimpl.h /^ PetscBool trackall; \/* whether all the residuals must be computed *\/$/;" m struct:_p_SVD transform include/slepc/private/stimpl.h /^ PetscBool transform; \/* whether transformed matrices are computed *\/$/;" m struct:_p_ST transharm include/slepc/private/dsimpl.h /^ PetscErrorCode (*transharm)(DS,PetscScalar,PetscReal,PetscBool,PetscScalar*,PetscReal*);$/;" m struct:_DSOps transrks include/slepc/private/dsimpl.h /^ PetscErrorCode (*transrks)(DS,PetscScalar);$/;" m struct:_DSOps trlan config/configure.py /^trlan = trlan.Trlan(argdb,log)$/;" v trueres include/slepc/private/epsimpl.h /^ PetscBool trueres; \/* whether the true residual norm must be computed *\/$/;" m struct:_p_EPS trueres src/nep/impls/nleigs/nleigs.c /^ PetscBool trueres; \/* whether the true residual norm must be computed *\/$/;" m struct:__anon92 file: truncate include/slepc/private/dsimpl.h /^ PetscErrorCode (*truncate)(DS,PetscInt);$/;" m struct:_DSOps ttN src/pep/impls/krylov/toar/nrefine.c /^ Vec tN,ttN,t1,vseq;$/;" m struct:__anon105 file: tv src/eps/examples/tests/test8.c /^static void tv(int nx,const PetscScalar *x,PetscScalar *y)$/;" f file: tv src/eps/examples/tutorials/ex3.c /^static void tv(int nx,const PetscScalar *x,PetscScalar *y)$/;" f file: tv src/pep/examples/tutorials/ex28.c /^static void tv(int nx,const PetscScalar *x,PetscScalar *y)$/;" f file: type src/sys/classes/ds/impls/ghiep/invit.c /^ PetscInt type;$/;" m struct:HRtr file: u src/eps/impls/external/blzpack/blzpackp.h /^ PetscScalar *u;$/;" m struct:__anon76 u src/pep/impls/jd/pjdp.h /^ Vec u; \/* Ritz vector *\/$/;" m struct:__anon100 unexpected config/cmakegen.py /^ def unexpected():$/;" f function:cmakeconditional update include/slepc/private/dsimpl.h /^ PetscErrorCode (*update)(DS);$/;" m struct:_DSOps updateV src/eps/impls/davidson/davidson.h /^ PetscErrorCode (*updateV)(struct _dvdDashboard*);$/;" m struct:_dvdDashboard updateV_data src/eps/impls/davidson/davidson.h /^ void *updateV_data;$/;" m struct:_dvdDashboard update_omega src/eps/impls/krylov/lanczos/lanczos.c /^static void update_omega(PetscReal *omega,PetscReal *omega_old,PetscInt j,PetscReal *alpha,PetscReal *beta,PetscReal eps1,PetscReal anorm)$/;" f file: url setup.py /^ url='http:\/\/slepc.upv.es\/',$/;" v useconj src/eps/impls/ciss/ciss.c /^ PetscBool useconj;$/;" m struct:__anon61 file: useconj src/nep/impls/ciss/nciss.c /^ PetscBool useconj;$/;" m struct:__anon89 file: used include/slepc/private/vecimplslepc.h /^ PetscInt used; \/* number of already used vectors *\/$/;" m struct:VecPool_ user src/eps/impls/davidson/dvdinitv.c /^ PetscInt user; \/* number of user initial vectors *\/$/;" m struct:__anon69 file: usest src/eps/impls/ciss/ciss.c /^ PetscBool usest;$/;" m struct:__anon61 file: usest src/nep/impls/ciss/nciss.c /^ PetscBool usest;$/;" m struct:__anon89 file: usest_set src/eps/impls/ciss/ciss.c /^ PetscBool usest_set; \/* whether the user set the usest flag or not *\/$/;" m struct:__anon61 file: v include/slepc/private/vecimplslepc.h /^ Vec v; \/* template vector *\/$/;" m struct:VecPool_ v src/eps/impls/external/blzpack/blzpackp.h /^ PetscScalar *v;$/;" m struct:__anon76 v src/nep/interface/neprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon97 file: v src/pep/interface/peprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon108 file: v src/sys/classes/bv/impls/svec/svec.c /^ Vec v;$/;" m struct:__anon117 file: value src/eps/impls/krylov/krylovschur/krylovschur.h /^ PetscReal value;$/;" m struct:_n_shift vecs include/slepc/private/vecimplslepc.h /^ Vec *vecs; \/* pool of vectors *\/$/;" m struct:VecPool_ vectors include/slepc/private/dsimpl.h /^ PetscErrorCode (*vectors)(DS,DSMatType,PetscInt*,PetscReal*);$/;" m struct:_DSOps version setup.py /^ version=version(),$/;" v version setup.py /^def version():$/;" f vg src/nep/interface/neprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon97 file: vg src/pep/interface/peprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon108 file: vi src/sys/classes/rg/impls/polygon/rgpolygon.c /^ PetscScalar *vr,*vi; \/* array of vertices (vi not used in complex scalars) *\/$/;" m struct:__anon126 file: view include/slepc/private/bvimpl.h /^ PetscErrorCode (*view)(BV,PetscViewer);$/;" m struct:_BVOps view include/slepc/private/dsimpl.h /^ PetscErrorCode (*view)(DS,PetscViewer);$/;" m struct:_DSOps view include/slepc/private/epsimpl.h /^ PetscErrorCode (*view)(EPS,PetscViewer);$/;" m struct:_EPSOps view include/slepc/private/fnimpl.h /^ PetscErrorCode (*view)(FN,PetscViewer);$/;" m struct:_FNOps view include/slepc/private/mfnimpl.h /^ PetscErrorCode (*view)(MFN,PetscViewer);$/;" m struct:_MFNOps view include/slepc/private/nepimpl.h /^ PetscErrorCode (*view)(NEP,PetscViewer);$/;" m struct:_NEPOps view include/slepc/private/pepimpl.h /^ PetscErrorCode (*view)(PEP,PetscViewer);$/;" m struct:_PEPOps view include/slepc/private/rgimpl.h /^ PetscErrorCode (*view)(RG,PetscViewer);$/;" m struct:_RGOps view include/slepc/private/stimpl.h /^ PetscErrorCode (*view)(ST,PetscViewer);$/;" m struct:_STOps view include/slepc/private/svdimpl.h /^ PetscErrorCode (*view)(SVD,PetscViewer);$/;" m struct:_SVDOps viewer include/slepc/private/slepcimpl.h /^ PetscViewer viewer;$/;" m struct:_n_SlepcConvMonitor vmip src/sys/classes/bv/impls/vecs/vecs.c /^ PetscInt vmip; \/* Version of BVMultInPlace:$/;" m struct:__anon118 file: vmm include/slepc/private/bvimpl.h /^ BVMatMultType vmm; \/* version of matmult operation *\/$/;" m struct:_p_BV vr src/sys/classes/rg/impls/polygon/rgpolygon.c /^ PetscScalar *vr,*vi; \/* array of vertices (vi not used in complex scalars) *\/$/;" m struct:__anon126 file: vrn src/nep/impls/nleigs/nleigs.c /^ Vec vrn; \/* random vector with normally distributed value *\/$/;" m struct:__anon92 file: vscale src/sys/classes/rg/impls/ellipse/rgellipse.c /^ PetscReal vscale; \/* vertical scale of the ellipse *\/$/;" m struct:__anon124 file: vscale src/sys/classes/rg/impls/ring/rgring.c /^ PetscReal vscale; \/* vertical scale of the ellipse *\/$/;" m struct:__anon127 file: vseq src/pep/impls/krylov/toar/nrefine.c /^ Vec tN,ttN,t1,vseq;$/;" m struct:__anon105 file: w include/slepc/private/stimpl.h /^ Vec w; \/* work vector used in apply operation *\/$/;" m struct:_p_ST w src/eps/examples/tutorials/ex24.c /^ Vec w;$/;" m struct:__anon55 file: w src/eps/impls/external/blopex/blopex.c /^ Vec w;$/;" m struct:__anon75 file: w src/nep/interface/neprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon97 file: w src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *M4,*w,*wt,*d,*dt;$/;" m struct:__anon105 file: w src/pep/impls/linear/linearp.h /^ Vec w[6]; \/* work vectors *\/$/;" m struct:__anon106 w src/pep/interface/peprefine.c /^ Vec nv,vg,v,w;$/;" m struct:__anon108 file: w src/svd/impls/cross/cross.c /^ Vec w,diag;$/;" m struct:__anon110 file: w2 src/sys/classes/st/impls/cayley/cayley.c /^ Vec w2;$/;" m struct:__anon128 file: w_s src/eps/examples/tutorials/ex31.c 78;" d file: wb include/slepc/private/stimpl.h /^ Vec wb; \/* balancing requires an extra work vector *\/$/;" m struct:_p_ST weight src/eps/impls/ciss/ciss.c /^ PetscScalar *weight;$/;" m struct:__anon61 file: weight src/nep/impls/ciss/nciss.c /^ PetscScalar *weight;$/;" m struct:__anon89 file: which include/slepc/private/epsimpl.h /^ EPSWhich which; \/* which part of the spectrum to be sought *\/$/;" m struct:_p_EPS which include/slepc/private/nepimpl.h /^ NEPWhich which; \/* which part of the spectrum to be sought *\/$/;" m struct:_p_NEP which include/slepc/private/pepimpl.h /^ PEPWhich which; \/* which part of the spectrum to be sought *\/$/;" m struct:_p_PEP which include/slepc/private/svdimpl.h /^ SVDWhich which; \/* which singular values are computed *\/$/;" m struct:_p_SVD which src/eps/impls/davidson/davidson.h /^ EPSWhich which; \/* spectrum selection *\/$/;" m struct:_dvdDashboard width src/sys/classes/rg/impls/ring/rgring.c /^ PetscReal width; \/* ring width *\/$/;" m struct:__anon127 file: withTarget src/eps/impls/davidson/davidson.h /^ PetscBool withTarget; \/* if there is a target *\/$/;" m struct:_dvdDashboard withTarget src/eps/impls/davidson/dvdutils.c /^ PetscBool withTarget;$/;" m struct:__anon72 file: work include/slepc/private/bvimpl.h /^ PetscScalar *work;$/;" m struct:_p_BV work include/slepc/private/dsimpl.h /^ PetscScalar *work;$/;" m struct:_p_DS work include/slepc/private/epsimpl.h /^ Vec *work; \/* work vectors *\/$/;" m struct:_p_EPS work include/slepc/private/mfnimpl.h /^ Vec *work; \/* work vectors *\/$/;" m struct:_p_MFN work include/slepc/private/nepimpl.h /^ Vec *work; \/* work vectors *\/$/;" m struct:_p_NEP work include/slepc/private/pepimpl.h /^ Vec *work; \/* work vectors *\/$/;" m struct:_p_PEP work src/eps/impls/external/trlan/trlanp.h /^ PetscReal *work;$/;" m struct:__anon79 work src/pep/impls/jd/pjdp.h /^ Vec *work;$/;" m struct:__anon100 work src/pep/impls/jd/pjdp.h /^ Vec *work;$/;" m struct:__anon101 work src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *fih,*work,*M4;$/;" m struct:__anon104 file: work1 src/eps/impls/external/feast/feastp.h /^ PetscScalar *work1,*work2,*Aq,*Bq; \/* workspace *\/$/;" m struct:__anon77 work2 src/eps/impls/external/feast/feastp.h /^ PetscScalar *work1,*work2,*Aq,*Bq; \/* workspace *\/$/;" m struct:__anon77 workd src/eps/impls/external/arpack/arpackp.h /^ PetscScalar *workd;$/;" m struct:__anon74 workev src/eps/impls/external/arpack/arpackp.h /^ PetscScalar *workev;$/;" m struct:__anon74 workl src/eps/impls/external/arpack/arpackp.h /^ PetscScalar *workl;$/;" m struct:__anon74 write config/cmakeboot.py /^ def write(self,str):$/;" m class:StdoutLogger write config/cmakegen.py /^ def write(self,str):$/;" m class:StdoutLogger write config/gmakegen.py /^ def write(stem, srcs):$/;" f function:Slepc.gen_gnumake write config/gmakegen.py /^ def write(self, string):$/;" m class:debuglogger write config/log.py /^ def write(self,string):$/;" m class:Log writePackage config/cmakegen.py /^def writePackage(f,pkg,pkgdeps,mistakes):$/;" f writeRoot config/cmakegen.py /^def writeRoot(f,petscdir,petscdestdir):$/;" f written config/cmakegen.py /^ written = True$/;" v wt src/pep/impls/krylov/toar/nrefine.c /^ PetscScalar *M4,*w,*wt,*d,*dt;$/;" m struct:__anon105 file: x include/slepc/private/vecimplslepc.h /^ Vec *x; \/* the vectors *\/$/;" m struct:__anon8 x src/eps/impls/external/primme/primme.c /^ Vec x,y; \/* auxiliary vectors *\/$/;" m struct:__anon78 file: x1 src/eps/examples/tutorials/ex30.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon56 file: x1 src/eps/examples/tutorials/ex9.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon58 file: x1 src/svd/impls/cyclic/cyclic.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon111 file: x2 src/eps/examples/tutorials/ex30.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon56 file: x2 src/eps/examples/tutorials/ex9.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon58 file: x2 src/svd/impls/cyclic/cyclic.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon111 file: xdup src/eps/impls/ciss/ciss.c /^ Vec xdup;$/;" m struct:__anon61 file: xi src/nep/impls/nleigs/nleigs.c /^ PetscScalar *s,*xi; \/* Leja-Bagby points *\/$/;" m struct:__anon92 file: xid include/slepc/private/bvimpl.h /^ PetscObjectId xid; \/* object id of vector x *\/$/;" m struct:_p_BV xstate include/slepc/private/bvimpl.h /^ PetscObjectState xstate; \/* state of vector x *\/$/;" m struct:_p_BV xsub src/eps/impls/ciss/ciss.c /^ Vec xsub;$/;" m struct:__anon61 file: y src/eps/impls/external/primme/primme.c /^ Vec x,y; \/* auxiliary vectors *\/$/;" m struct:__anon78 file: y1 src/eps/examples/tutorials/ex30.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon56 file: y1 src/eps/examples/tutorials/ex9.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon58 file: y1 src/svd/impls/cyclic/cyclic.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon111 file: y2 src/eps/examples/tutorials/ex30.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon56 file: y2 src/eps/examples/tutorials/ex9.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon58 file: y2 src/svd/impls/cyclic/cyclic.c /^ Vec x1,x2,y1,y2;$/;" m struct:__anon111 file: z src/sys/classes/st/interface/stshellmat.c /^ Vec z;$/;" m struct:__anon132 file: slepc-3.7.4/docs/0000755000175000017500000000000013107004621013113 5ustar jromanjromanslepc-3.7.4/docs/makefile0000644000175000017500000000215113107004621014612 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = SOURCEC = SOURCEF = SOURCEH = DOCS = LIBBASE = LINCLUDE = ${SOURCEH} DIRS = LOCDIR = docs/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common runexamples: slepc-3.7.4/docs/faq.htm0000644000175000017500000000436413107004621014403 0ustar jromanjroman FAQ
[ Manual | Installation | Changes | FAQ | Contact ]

A longer list of frequently asked questions can be found here.
 

Where should I send SLEPc bug reports and questions?

Send all maintenance requests to the SLEPc developers via the email address slepc-maint@upv.es.

 

How can I subscribe to the SLEPc users mailing list?

You can join the SLEPc users mailing list by following the instructions in the Contact section. We will update users regarding new releases, changes, etc. through this mailing list.

 

Apart from PETSc, is it necessary to install other software to use SLEPc?

No, the only requirement to use SLEPc is to have PETSc installed in your system. Additionally, if you want to have access to eigensolvers not included in SLEPc, then you will have to install other libraries (e.g. ARPACK).

 

Which is the recommended way of learning SLEPc?

Possibly, the best way of learning to use SLEPc is to follow these steps:

  • First of all, get acquainted with PETSc if you are not already familiar with it (see the PETSc tutorials page).
  • Read through the entire SLEPc Users Manual. In a first reading, one may skip the "advanced usage" sections.
  • Follow the steps provided by the hands-on exercises, trying the examples in an available SLEPc installation.
  • Use the example programs available in src/<classname>/examples as a basis for your own programs.
  • Use the on-line manual pages for reference for individual routines.

slepc-3.7.4/docs/mail_list.htm0000644000175000017500000000175513107004621015612 0ustar jromanjroman mailing list
[ Manual | Installation | Changes | FAQ | Contact ]

SLEPc home: http://slepc.upv.es

We will update users regarding new releases, changes, etc. through a mailing list. This is a low traffic mailing list, with messages sent only from time to time. We encourage all the users to subscribe to this mailing list. The number of subscribed users is also a feedback for us indicating how many users are interested in SLEPc.

For subscription and other information related to the mailing list follow this link: http://slepc.upv.es/contact/mail_list.htm.

slepc-3.7.4/docs/makefile.html0000644000175000017500000000452613107004621015565 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#     
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS   =
FFLAGS   =
SOURCEC  =
SOURCEF  =
SOURCEH  = 
DOCS     = 
LIBBASE  =
LINCLUDE = ${SOURCEH}
DIRS     = 
LOCDIR   = docs/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

runexamples:

slepc-3.7.4/docs/instal.htm0000644000175000017500000001423113107004621015120 0ustar jromanjroman installation
[ Manual | Installation | Changes | FAQ | Contact ]

Basic Installation Instructions

The following is a quick-start guide for installing SLEPc. For further details, the user is referred to the SLEPc Users Manual.

Previously to the installation of SLEPc, the system must have an appropriate version of PETSc installed (see the PETSc installation documentation for details). Check the Changes section for a list of SLEPc versions and their corresponding PETSc versions.

The installation process for SLEPc is very similar to PETSc, with two main stages: configuration and compilation. SLEPc configuration is much simpler because most of the configuration information is taken from PETSc, including compiler options and scalar type (real or complex). Several configurations can coexist in the same directory tree, being selected by different values of PETSC_ARCH, so that one can, for instance, have a SLEPc compiled with real scalars and another one with complex scalars.

The main steps for the installation are:

  1. Unbundle the distribution file slepc-3.7.0.tgz with a usual command such as tar xzf slepc-3.7.0.tgz. This will create a directory and unpack the software there.
  2. Set the environment variable SLEPC_DIR to the full path of the SLEPc home directory, for example,
    export SLEPC_DIR=/home/username/slepc-3.7.0
    In addition to this variable, PETSC_DIR and PETSC_ARCH must also be set appropriately.
  3. In the SLEPc directory, execute
    ./configure
    Note that in order to enable external packages (see below), this command must be run with appropiate options. To see all available options use ./configure --help
  4. In the SLEPc home directory, type
    make
  5. Optionally, if an installation directory has been specified during configuration (with option --prefix in step 3 above), then type
    make install
    This is useful for building as a regular user and then copying the libraries and include files to the system directories as root.
  6. If the installation went smoothly, then try running some test examples with
    make test
    Examine the output for any obvious errors or problems.

 

Optional Software

SLEPc provides an interface to several software packages. These should be installed before installing SLEPc. These packages are not developed, maintained, or supported by the SLEPc team; we merely provide an interface to them. To integrate one of these libraries in SLEPc:

  • First install the external package following its instructions. Make sure you use the same compilers and MPI that you plan to use with PETSc/SLEPc.
  • Enable the utilization of the external software from SLEPc by adding specific command-line parameters when executing configure. For example, to use ARPACK, specify the following options (with the appropriate paths):
    ./configure --with-arpack-dir=/usr/software/ARPACK --with-arpack-flags=-lparpack,-larpack
  • Build the SLEPc libraries.

SLEPc currently interfaces to the following libraries:

  • ARPACK (Implicitly Restarted Arnoldi/Lanczos solver).
  • PRIMME (PReconditioned Iterative MultiMethod Eigensolver).
  • BLZPACK (Block Lanczos with selective and partial reorthogonalization).
  • TRLAN (Dynamic Thick Restart Lanczos solver).
  • BLOPEX (Block Locally Optimal Preconditioned Eigenvalue Xolvers).
  • FEAST eigensolver.

Additional information about these packages can be found in the SLEPc Users Manual.

 

slepc-3.7.4/docs/index.html0000644000175000017500000000605313107004621015114 0ustar jromanjroman SLEPc - Manual
slepc-3.7.4 2017-05-17
[ Manual | Installation | Changes | FAQ | Contact ]

SLEPc is based on PETSc and therefore users are recommended to use this documentation together with the one provided with PETSc. Application programmers can easily begin to use SLEPc from a high level (starting from the tutorial examples) and then gradually learn more details according to their needs.

SLEPc Manual Pages

Main solver classes:

Auxiliary classes and system routines:

The manual pages are split into four categories; we recommend that you begin with basic functionality and then gradually explore more sophisticated library features.

  • Beginner - Basic usage
  • Intermediate - Setting options for algorithms and data structures
  • Advanced - Setting more advanced options and customization
  • Developer - Interfaces intended primarily for library developers, not for typical applications programmers

PETSc Manual Pages

PETSc Documentation: [PETSc website]

Additional Documentation

Additional documentation including hands-on exercises and SLEPc Technical Reports can be found at the [SLEPc website]. slepc-3.7.4/docs/manual.htm0000644000175000017500000000521313107004621015103 0ustar jromanjroman SLEPc - Manual

[ Manual | Installation | Changes | FAQ | Contact ]

SLEPc is based on PETSc and therefore users are recommended to use this documentation together with the one provided with PETSc. Application programmers can easily begin to use SLEPc from a high level (starting from the tutorial examples) and then gradually learn more details according to their needs.

SLEPc Manual Pages

Main solver classes:

Auxiliary classes and system routines:

The manual pages are split into four categories; we recommend that you begin with basic functionality and then gradually explore more sophisticated library features.

  • Beginner - Basic usage
  • Intermediate - Setting options for algorithms and data structures
  • Advanced - Setting more advanced options and customization
  • Developer - Interfaces intended primarily for library developers, not for typical applications programmers

PETSc Manual Pages

PETSc Documentation: [PETSc website]

Additional Documentation

Additional documentation including hands-on exercises and SLEPc Technical Reports can be found at the [SLEPc website]. slepc-3.7.4/docs/manualpages/0000755000175000017500000000000013107004621015410 5ustar jromanjromanslepc-3.7.4/docs/manualpages/PEP/0000755000175000017500000000000013107004621016034 5ustar jromanjromanslepc-3.7.4/docs/manualpages/PEP/PEPSTOARSetLocking.html0000644000175000017500000000456313107004621022152 0ustar jromanjroman PEPSTOARSetLocking

slepc-3.7.4 2017-05-17

PEPSTOARSetLocking

Choose between locking and non-locking variants of the STOAR method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSTOARSetLocking(PEP pep,PetscBool lock)
Logically Collective on PEP

Input Parameters

pep  - the eigenproblem solver context
lock  - true if the locking variant must be selected

Options Database Key

-pep_stoar_locking  - Sets the locking flag

Notes

The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant).

See Also

PEPSTOARGetLocking()

Location: src/pep/impls/krylov/stoar/stoar.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPErrorView.html0000644000175000017500000001017213107004621021214 0ustar jromanjroman PEPErrorView

slepc-3.7.4 2017-05-17

PEPErrorView

Displays the errors associated with the computed solution (as well as the eigenvalues).

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPErrorView(PEP pep,PEPErrorType etype,PetscViewer viewer)
Collective on PEP

Input Parameters

pep  - the eigensolver context
etype  - error type
viewer  - optional visualization context

Options Database Key

-pep_error_absolute  - print absolute errors of each eigenpair
-pep_error_relative  - print relative errors of each eigenpair
-pep_error_backward  - print backward errors of each eigenpair

Notes

By default, this function checks the error of all eigenpairs and prints the eigenvalues if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with eigenvalues and corresponding errors is printed.

See Also

PEPSolve(), PEPValuesView(), PEPVectorsView()

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
src/pep/examples/nlevp/butterfly.c.html
src/pep/examples/nlevp/damped_beam.c.html
src/pep/examples/nlevp/pdde_stability.c.html
src/pep/examples/nlevp/planar_waveguide.c.html
src/pep/examples/nlevp/sleeper.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPGetWhichEigenpairs.html0000644000175000017500000000431513107004621023003 0ustar jromanjroman PEPGetWhichEigenpairs
slepc-3.7.4 2017-05-17

PEPGetWhichEigenpairs

Returns which portion of the spectrum is to be sought.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetWhichEigenpairs(PEP pep,PEPWhich *which)
Not Collective

Input Parameter

pep  - eigensolver context obtained from PEPCreate()

Output Parameter

which  - the portion of the spectrum to be sought

Notes

See PEPSetWhichEigenpairs() for possible values of 'which'.

See Also

PEPSetWhichEigenpairs(), PEPWhich

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetExtract.html0000644000175000017500000000355213107004621021346 0ustar jromanjroman PEPGetExtract

slepc-3.7.4 2017-05-17

PEPGetExtract

Gets the extraction strategy used by the PEP object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetExtract(PEP pep,PEPExtract *extract)
Not Collective

Input Parameter

pep  - the eigensolver context

Output Parameter

extract  - extraction strategy

See Also

PEPSetExtract()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetDS.html0000644000175000017500000000355613107004621020246 0ustar jromanjroman PEPGetDS

slepc-3.7.4 2017-05-17

PEPGetDS

Obtain the direct solver object associated to the polynomial eigensolver object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetDS(PEP pep,DS *ds)
Not Collective

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Output Parameter

ds  - direct solver context

See Also

PEPSetDS()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPValuesView.html0000644000175000017500000000414313107004621021363 0ustar jromanjroman PEPValuesView

slepc-3.7.4 2017-05-17

PEPValuesView

Displays the computed eigenvalues in a viewer.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPValuesView(PEP pep,PetscViewer viewer)
Collective on PEP

Input Parameters

pep  - the eigensolver context
viewer  - the viewer

Options Database Key

-pep_view_values  - print computed eigenvalues

See Also

PEPSolve(), PEPVectorsView(), PEPErrorView()

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetDimensions.html0000644000175000017500000000665713107004621022071 0ustar jromanjroman PEPSetDimensions

slepc-3.7.4 2017-05-17

PEPSetDimensions

Sets the number of eigenvalues to compute and the dimension of the subspace.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetDimensions(PEP pep,PetscInt nev,PetscInt ncv,PetscInt mpd)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

Options Database Keys

-pep_nev <nev>  - Sets the number of eigenvalues
-pep_ncv <ncv>  - Sets the dimension of the subspace
-pep_mpd <mpd>  - Sets the maximum projected dimension

Notes

Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method.

The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and (b) in cases where nev is large, the user sets mpd.

The value of ncv should always be between nev and (nev+mpd), typically ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise a smaller value should be used.

See Also

PEPGetDimensions()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/nlevp/pdde_stability.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPStop.html0000644000175000017500000000273713107004621020225 0ustar jromanjroman PEPStop
slepc-3.7.4 2017-05-17

PEPStop

Determines the stopping test

Synopsis

typedef enum { PEP_STOP_BASIC,
               PEP_STOP_USER } PEPStop;

See Also

PEPSetStoppingTest(), PEPSetStoppingTestFunction()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetTolerances.html0000644000175000017500000000447713107004621022042 0ustar jromanjroman PEPGetTolerances

slepc-3.7.4 2017-05-17

PEPGetTolerances

Gets the tolerance and maximum iteration count used by the PEP convergence tests.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetTolerances(PEP pep,PetscReal *tol,PetscInt *maxits)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameters

tol  - the convergence tolerance
maxits  - maximum number of iterations

Notes

The user can specify NULL for any parameter that is not needed.

See Also

PEPSetTolerances()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex17.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPGetConverged.html0000644000175000017500000000431713107004621021650 0ustar jromanjroman PEPGetConverged
slepc-3.7.4 2017-05-17

PEPGetConverged

Gets the number of converged eigenpairs.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetConverged(PEP pep,PetscInt *nconv)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameter

nconv  - number of converged eigenpairs

Note

This function should be called after PEPSolve() has finished.

See Also

PEPSetDimensions(), PEPSolve()

Location: src/pep/interface/pepsolve.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPGetTarget.html0000644000175000017500000000362613107004621021164 0ustar jromanjroman PEPGetTarget
slepc-3.7.4 2017-05-17

PEPGetTarget

Gets the value of the target.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetTarget(PEP pep,PetscScalar* target)
Not Collective

Input Parameter

pep  - eigensolver context

Output Parameter

target  - the value of the target

Note

If the target was not set by the user, then zero is returned.

See Also

PEPSetTarget()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPExtract.html0000644000175000017500000000270413107004621020704 0ustar jromanjroman PEPExtract

slepc-3.7.4 2017-05-17

PEPExtract

The extraction type

Synopsis

typedef enum { PEP_EXTRACT_NONE=1,
               PEP_EXTRACT_NORM,
               PEP_EXTRACT_RESIDUAL,
               PEP_EXTRACT_STRUCTURED } PEPExtract;

See Also

PEPSetExtract()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetTarget.html0000644000175000017500000000476413107004621021204 0ustar jromanjroman PEPSetTarget

slepc-3.7.4 2017-05-17

PEPSetTarget

Sets the value of the target.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetTarget(PEP pep,PetscScalar target)
Logically Collective on PEP

Input Parameters

pep  - eigensolver context
target  - the value of the target

Options Database Key

-pep_target <scalar>  - the value of the target

Notes

The target is a scalar value used to determine the portion of the spectrum of interest. It is used in combination with PEPSetWhichEigenpairs().

In the case of complex scalars, a complex value can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -pep_target 1.0+2.0i

See Also

PEPGetTarget(), PEPSetWhichEigenpairs()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPLinearSetCompanionForm.html0000644000175000017500000000427313107004621023653 0ustar jromanjroman PEPLinearSetCompanionForm

slepc-3.7.4 2017-05-17

PEPLinearSetCompanionForm

Choose between the two companion forms available for the linearization of a quadratic eigenproblem.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPLinearSetCompanionForm(PEP pep,PetscInt cform)
Logically Collective on PEP

Input Parameters

pep  - polynomial eigenvalue solver
cform  - 1 or 2 (first or second companion form)

Options Database Key

-pep_linear_cform <int>  - Choose the companion form

See Also

PEPLinearGetCompanionForm()

Location: src/pep/impls/linear/linear.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPReasonView.html0000644000175000017500000000700013107004621021346 0ustar jromanjroman PEPReasonView

slepc-3.7.4 2017-05-17

PEPReasonView

Displays the reason a PEP solve converged or diverged.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPReasonView(PEP pep,PetscViewer viewer)
Collective on PEP

Parameter

pep  - the eigensolver context
viewer  - the viewer to display the reason

Options Database Keys

-pep_converged_reason  - print reason for convergence, and number of iterations

See Also

PEPSetConvergenceTest(), PEPSetTolerances(), PEPGetIterationNumber()

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
src/pep/examples/nlevp/butterfly.c.html
src/pep/examples/nlevp/damped_beam.c.html
src/pep/examples/nlevp/pdde_stability.c.html
src/pep/examples/nlevp/planar_waveguide.c.html
src/pep/examples/nlevp/sleeper.c.html
src/pep/examples/nlevp/spring.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPStoppingBasic.html0000644000175000017500000000673413107004621022046 0ustar jromanjroman PEPStoppingBasic
slepc-3.7.4 2017-05-17

PEPStoppingBasic

Default routine to determine whether the outer eigensolver iteration must be stopped.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPStoppingBasic(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)
Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged eigenpairs
nev  - number of requested eigenpairs
ctx  - context (not used here)

Output Parameter

reason  - result of the stopping test

Notes

A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to PEP_CONVERGED_ITERATING (zero).

PEPStoppingBasic() will stop if all requested eigenvalues are converged, or if the maximum number of iterations has been reached.

Use PEPSetStoppingTest() to provide your own test instead of using this one.

See Also

PEPSetStoppingTest(), PEPConvergedReason, PEPGetConvergedReason()

Location: src/pep/interface/pepdefault.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPLinearSetEPS.html0000644000175000017500000000350013107004621021523 0ustar jromanjroman PEPLinearSetEPS

slepc-3.7.4 2017-05-17

PEPLinearSetEPS

Associate an eigensolver object (EPS) to the polynomial eigenvalue solver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPLinearSetEPS(PEP pep,EPS eps)
Collective on PEP

Input Parameters

pep  - polynomial eigenvalue solver
eps  - the eigensolver object

See Also

PEPLinearGetEPS()

Location: src/pep/impls/linear/linear.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPAllocateSolution.html0000644000175000017500000000367213107004621022560 0ustar jromanjroman PEPAllocateSolution

slepc-3.7.4 2017-05-17

PEPAllocateSolution

Allocate memory storage for common variables such as eigenvalues and eigenvectors.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPAllocateSolution(PEP pep,PetscInt extra)
Collective on PEP

Input Parameters

pep  - eigensolver context
extra  - number of additional positions, used for methods that require a working basis slightly larger than ncv

Developers Note

This is PETSC_EXTERN because it may be required by user plugin PEP implementations.

Location: src/pep/interface/pepsetup.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPRefine.html0000644000175000017500000000261713107004621020505 0ustar jromanjroman PEPRefine

slepc-3.7.4 2017-05-17

PEPRefine

The refinement type

Synopsis

typedef enum { PEP_REFINE_NONE,
               PEP_REFINE_SIMPLE,
               PEP_REFINE_MULTIPLE } PEPRefine;

See Also

PEPSetRefine()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetExtract.html0000644000175000017500000000404513107004621021360 0ustar jromanjroman PEPSetExtract

slepc-3.7.4 2017-05-17

PEPSetExtract

Specifies the extraction strategy to be used.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetExtract(PEP pep,PEPExtract extract)
Logically Collective on PEP

Input Parameters

pep  - the eigensolver context
extract  - extraction strategy

Options Database Keys

-pep_extract <type>  - extraction type, one of <none,norm,residual,structured>

See Also

PEPGetExtract()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPAppendOptionsPrefix.html0000644000175000017500000000435313107004621023235 0ustar jromanjroman PEPAppendOptionsPrefix

slepc-3.7.4 2017-05-17

PEPAppendOptionsPrefix

Appends to the prefix used for searching for all PEP options in the database.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPAppendOptionsPrefix(PEP pep,const char *prefix)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
prefix  - the prefix string to prepend to all PEP option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

PEPSetOptionsPrefix(), PEPGetOptionsPrefix()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetOperators.html0000644000175000017500000000730713107004621021730 0ustar jromanjroman PEPSetOperators

slepc-3.7.4 2017-05-17

PEPSetOperators

Sets the coefficient matrices associated with the polynomial eigenvalue problem.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetOperators(PEP pep,PetscInt nmat,Mat A[])
Collective on PEP and Mat

Input Parameters

pep  - the eigenproblem solver context
nmat  - number of matrices in array A
A  - the array of matrices associated with the eigenproblem

Notes

The polynomial eigenproblem is defined as P(l)*x=0, where l is the eigenvalue, x is the eigenvector, and P(l) is defined as P(l) = A_0 + l*A_1 + ... + l^d*A_d, with d=nmat-1 (the degree of P). For non-monomial bases, this expression is different.

See Also

PEPSolve(), PEPGetOperators(), PEPGetNumMatrices(), PEPSetBasis()

Location: src/pep/interface/pepsetup.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
src/pep/examples/nlevp/butterfly.c.html
src/pep/examples/nlevp/damped_beam.c.html
src/pep/examples/nlevp/pdde_stability.c.html
src/pep/examples/nlevp/planar_waveguide.c.html
src/pep/examples/nlevp/sleeper.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPSetType.html0000644000175000017500000000535413107004621020673 0ustar jromanjroman PEPSetType
slepc-3.7.4 2017-05-17

PEPSetType

Selects the particular solver to be used in the PEP object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetType(PEP pep,PEPType type)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
type  - a known method

Options Database Key

-pep_type <method>  - Sets the method; use -help for a list of available methods

Notes

See "slepc/include/slepcpep.h" for available methods. The default is PEPTOAR.

Normally, it is best to use the PEPSetFromOptions() command and then set the PEP type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The PEPSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database.

See Also

PEPType

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPJDGetRestart.html0000644000175000017500000000354313107004621021576 0ustar jromanjroman PEPJDGetRestart

slepc-3.7.4 2017-05-17

PEPJDGetRestart

Gets the restart parameter used in the Jacobi-Davidson method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPJDGetRestart(PEP pep,PetscReal *keep)
Not Collective

Input Parameter

pep  - the eigenproblem solver context

Output Parameter

keep  - the restart parameter

See Also

PEPJDSetRestart()

Location: src/pep/impls/jd/pjdopt.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPMonitorConverged.html0000644000175000017500000000535313107004621022561 0ustar jromanjroman PEPMonitorConverged

slepc-3.7.4 2017-05-17

PEPMonitorConverged

Print the approximate values and error estimates as they converge.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPMonitorConverged(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
Collective on PEP

Input Parameters

pep  - polynomial eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
ctx  - monitor context

See Also

PEPMonitorSet(), PEPMonitorFirst(), PEPMonitorAll()

Location: src/pep/interface/pepmon.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetConvergenceTestFunction.html0000644000175000017500000000745413107004621024561 0ustar jromanjroman PEPSetConvergenceTestFunction

slepc-3.7.4 2017-05-17

PEPSetConvergenceTestFunction

Sets a function to compute the error estimate used in the convergence test.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetConvergenceTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
func  - a pointer to the convergence test function
ctx  - context for private data for the convergence routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)

pep  - eigensolver context obtained from PEPCreate()
eigr  - real part of the eigenvalue
eigi  - imaginary part of the eigenvalue
res  - residual norm associated to the eigenpair
errest  - (output) computed error estimate
ctx  - optional context, as set by PEPSetConvergenceTestFunction()

Note

If the error estimate returned by the convergence test function is less than the tolerance, then the eigenvalue is accepted as converged.

See Also

PEPSetConvergenceTest(), PEPSetTolerances()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetOptionsPrefix.html0000644000175000017500000000511513107004621022556 0ustar jromanjroman PEPSetOptionsPrefix

slepc-3.7.4 2017-05-17

PEPSetOptionsPrefix

Sets the prefix used for searching for all PEP options in the database.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetOptionsPrefix(PEP pep,const char *prefix)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
prefix  - the prefix string to prepend to all PEP option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

For example, to distinguish between the runtime options for two different PEP contexts, one could call

      PEPSetOptionsPrefix(pep1,"qeig1_")
      PEPSetOptionsPrefix(pep2,"qeig2_")

See Also

PEPAppendOptionsPrefix(), PEPGetOptionsPrefix()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetEigenvalueComparison.html0000644000175000017500000001012713107004621024063 0ustar jromanjroman PEPSetEigenvalueComparison

slepc-3.7.4 2017-05-17

PEPSetEigenvalueComparison

Specifies the eigenvalue comparison function when PEPSetWhichEigenpairs() is set to PEP_WHICH_USER.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetEigenvalueComparison(PEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
func  - a pointer to the comparison function
ctx  - a context pointer (the last parameter to the comparison function)

Calling Sequence of func

  func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx)

ar  - real part of the 1st eigenvalue
ai  - imaginary part of the 1st eigenvalue
br  - real part of the 2nd eigenvalue
bi  - imaginary part of the 2nd eigenvalue
res  - result of comparison
ctx  - optional context, as set by PEPSetEigenvalueComparison()

Note

The returning parameter 'res' can be
negative  - if the 1st eigenvalue is preferred to the 2st one
zero  - if both eigenvalues are equally preferred
positive  - if the 2st eigenvalue is preferred to the 1st one

See Also

PEPSetWhichEigenpairs(), PEPWhich

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/nlevp/pdde_stability.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPQArnoldiSetLocking.html0000644000175000017500000000502313107004621022763 0ustar jromanjroman PEPQArnoldiSetLocking
slepc-3.7.4 2017-05-17

PEPQArnoldiSetLocking

Choose between locking and non-locking variants of the Q-Arnoldi method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPQArnoldiSetLocking(PEP pep,PetscBool lock)
Logically Collective on PEP

Input Parameters

pep  - the eigenproblem solver context
lock  - true if the locking variant must be selected

Options Database Key

-pep_qarnoldi_locking  - Sets the locking flag

Notes

The default is to keep all directions in the working subspace even if already converged to working accuracy (the non-locking variant). This behaviour can be changed so that converged eigenpairs are locked when the method restarts.

Note that the default behaviour is the opposite to Krylov solvers in EPS.

See Also

PEPQArnoldiGetLocking()

Location: src/pep/impls/krylov/qarnoldi/qarnoldi.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetRefine.html0000644000175000017500000001062213107004621021154 0ustar jromanjroman PEPSetRefine

slepc-3.7.4 2017-05-17

PEPSetRefine

Specifies the refinement type (and options) to be used after the solve.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetRefine(PEP pep,PEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,PEPRefineScheme scheme)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
refine  - refinement type
npart  - number of partitions of the communicator
tol  - the convergence tolerance
its  - maximum number of refinement iterations
scheme  - which scheme to be used for solving the involved linear systems

Options Database Keys

-pep_refine <type>  - refinement type, one of <none,simple,multiple>
-pep_refine_partitions <n>  - the number of partitions
-pep_refine_tol <tol>  - the tolerance
-pep_refine_its <its>  - number of iterations
-pep_refine_scheme  - to set the scheme for the linear solves

Notes

By default, iterative refinement is disabled, since it may be very costly. There are two possible refinement strategies: simple and multiple. The simple approach performs iterative refinement on each of the converged eigenpairs individually, whereas the multiple strategy works with the invariant pair as a whole, refining all eigenpairs simultaneously. The latter may be required for the case of multiple eigenvalues.

In some cases, especially when using direct solvers within the iterative refinement method, it may be helpful for improved scalability to split the communicator in several partitions. The npart parameter indicates how many partitions to use (defaults to 1).

The tol and its parameters specify the stopping criterion. In the simple method, refinement continues until the residual of each eigenpair is below the tolerance (tol defaults to the PEP tol, but may be set to a different value). In contrast, the multiple method simply performs its refinement iterations (just one by default).

The scheme argument is used to change the way in which linear systems are solved. Possible choices are: explicit, mixed block elimination (MBE), and Schur complement.

See Also

PEPGetRefine()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPTOARGetLocking.html0000644000175000017500000000356013107004621022007 0ustar jromanjroman PEPTOARGetLocking

slepc-3.7.4 2017-05-17

PEPTOARGetLocking

Gets the locking flag used in the TOAR method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPTOARGetLocking(PEP pep,PetscBool *lock)
Not Collective

Input Parameter

pep  - the eigenproblem solver context

Output Parameter

lock  - the locking flag

See Also

PEPTOARSetLocking()

Location: src/pep/impls/krylov/toar/ptoar.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetScale.html0000644000175000017500000001033113107004621020770 0ustar jromanjroman PEPSetScale

slepc-3.7.4 2017-05-17

PEPSetScale

Specifies the scaling strategy to be used.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetScale(PEP pep,PEPScale scale,PetscReal alpha,Vec Dl,Vec Dr,PetscInt its,PetscReal lambda)
Logically Collective on PEP

Input Parameters

pep  - the eigensolver context
scale  - scaling strategy
alpha  - the scaling factor used in the scalar strategy
Dl  - the left diagonal matrix of the diagonal scaling algorithm
Dr  - the right diagonal matrix of the diagonal scaling algorithm
its  - number of iterations of the diagonal scaling algorithm
lambda  - approximation to wanted eigenvalues (modulus)

Options Database Keys

-pep_scale <type>  - scaling type, one of <none,scalar,diagonal,both>
-pep_scale_factor <alpha>  - the scaling factor
-pep_scale_its <its>  - number of iterations
-pep_scale_lambda <lambda>  - approximation to eigenvalues

Notes

There are two non-exclusive scaling strategies: scalar and diagonal.

In the scalar strategy, scaling is applied to the eigenvalue, that is, mu = lambda/alpha is the new eigenvalue and all matrices are scaled accordingly. After solving the scaled problem, the original lambda is recovered. Parameter 'alpha' must be positive. Use PETSC_DECIDE to let the solver compute a reasonable scaling factor.

In the diagonal strategy, the solver works implicitly with matrix Dl*A*Dr, where Dl and Dr are appropriate diagonal matrices. This improves the accuracy of the computed results in some cases. The user may provide the Dr and Dl matrices represented as Vec objects storing diagonal elements. If not provided, these matrices are computed internally. This option requires that the polynomial coefficient matrices are of MATAIJ type. The parameter 'its' is the number of iterations performed by the method. Parameter 'lambda' must be positive. Use PETSC_DECIDE or set lambda = 1.0 if no information about eigenvalues is available.

See Also

PEPGetScale()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPTOARGetRestart.html0000644000175000017500000000357213107004621022050 0ustar jromanjroman PEPTOARGetRestart

slepc-3.7.4 2017-05-17

PEPTOARGetRestart

Gets the restart parameter used in the TOAR method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPTOARGetRestart(PEP pep,PetscReal *keep)
Not Collective

Input Parameter

pep  - the eigenproblem solver context

Output Parameter

keep  - the restart parameter

See Also

PEPTOARSetRestart()

Location: src/pep/impls/krylov/toar/ptoar.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetStoppingTest.html0000644000175000017500000000401613107004621022373 0ustar jromanjroman PEPGetStoppingTest

slepc-3.7.4 2017-05-17

PEPGetStoppingTest

Gets the method used to decide the termination of the outer loop of the eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetStoppingTest(PEP pep,PEPStop *stop)
Not Collective

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Output Parameters

stop  - the type of stopping test

See Also

PEPSetStoppingTest(), PEPStop

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetStoppingTestFunction.html0000644000175000017500000001021013107004621024106 0ustar jromanjroman PEPSetStoppingTestFunction

slepc-3.7.4 2017-05-17

PEPSetStoppingTestFunction

Sets a function to decide when to stop the outer iteration of the eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetStoppingTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
func  - pointer to the stopping test function
ctx  - context for private data for the stopping routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)

pep  - eigensolver context obtained from PEPCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged eigenpairs
nev  - number of requested eigenpairs
reason  - (output) result of the stopping test
ctx  - optional context, as set by PEPSetStoppingTestFunction()

Note

Normal usage is to first call the default routine PEPStoppingBasic() and then set reason to PEP_CONVERGED_USER if some user-defined conditions have been met. To let the eigensolver continue iterating, the result must be left as PEP_CONVERGED_ITERATING.

See Also

PEPSetStoppingTest(), PEPStoppingBasic()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetErrorEstimate.html0000644000175000017500000000441513107004621022520 0ustar jromanjroman PEPGetErrorEstimate

slepc-3.7.4 2017-05-17

PEPGetErrorEstimate

Returns the error estimate associated to the i-th computed eigenpair.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetErrorEstimate(PEP pep,PetscInt i,PetscReal *errest)
Not Collective

Input Parameter

pep  - polynomial eigensolver context
i  - index of eigenpair

Output Parameter

errest  - the error estimate

Notes

This is the error estimate used internally by the eigensolver. The actual error bound can be computed with PEPComputeError(). See also the users manual for details.

See Also

PEPComputeError()

Location: src/pep/interface/pepsolve.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetProblemType.html0000644000175000017500000000377413107004621022204 0ustar jromanjroman PEPGetProblemType

slepc-3.7.4 2017-05-17

PEPGetProblemType

Gets the problem type from the PEP object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetProblemType(PEP pep,PEPProblemType *type)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameter

type  - name of PEP problem type

See Also

PEPSetProblemType(), PEPProblemType

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetST.html0000644000175000017500000000376013107004621020277 0ustar jromanjroman PEPSetST

slepc-3.7.4 2017-05-17

PEPSetST

Associates a spectral transformation object to the eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetST(PEP pep,ST st)
Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
st  - the spectral transformation object

Note

Use PEPGetST() to retrieve the spectral transformation context (for example, to free it at the end of the computations).

See Also

PEPGetST()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetBasis.html0000644000175000017500000000362613107004621020777 0ustar jromanjroman PEPGetBasis

slepc-3.7.4 2017-05-17

PEPGetBasis

Gets the type of polynomial basis from the PEP object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetBasis(PEP pep,PEPBasis *basis)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameter

basis  - the polynomial basis

See Also

PEPSetBasis(), PEPBasis

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPRegisterAll.html0000644000175000017500000000261013107004621021503 0ustar jromanjroman PEPRegisterAll

slepc-3.7.4 2017-05-17

PEPRegisterAll

Registers all the solvers in the PEP package.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPRegisterAll(void)
Not Collective

See Also

PEPRegister()

Location: src/pep/interface/pepregis.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPJDSetRestart.html0000644000175000017500000000434613107004621021614 0ustar jromanjroman PEPJDSetRestart

slepc-3.7.4 2017-05-17

PEPJDSetRestart

Sets the restart parameter for the Jacobi-Davidson method, in particular the proportion of basis vectors that must be kept after restart.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPJDSetRestart(PEP pep,PetscReal keep)
Logically Collective on PEP

Input Parameters

pep  - the eigenproblem solver context
keep  - the number of vectors to be kept at restart

Options Database Key

-pep_jd_restart  - Sets the restart parameter

Notes

Allowed values are in the range [0.1,0.9]. The default is 0.5.

See Also

PEPJDGetRestart()

Location: src/pep/impls/jd/pjdopt.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPLinearSetExplicitMatrix.html0000644000175000017500000000436313107004621024052 0ustar jromanjroman PEPLinearSetExplicitMatrix

slepc-3.7.4 2017-05-17

PEPLinearSetExplicitMatrix

Indicate if the matrices A and B for the linearization of the problem must be built explicitly.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPLinearSetExplicitMatrix(PEP pep,PetscBool explicitmatrix)
Logically Collective on PEP

Input Parameters

pep  - polynomial eigenvalue solver
explicit  - boolean flag indicating if the matrices are built explicitly

Options Database Key

-pep_linear_explicitmatrix <boolean>  - Indicates the boolean flag

See Also

PEPLinearGetExplicitMatrix()

Location: src/pep/impls/linear/linear.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetEigenpair.html0000644000175000017500000000720313107004621021634 0ustar jromanjroman PEPGetEigenpair

slepc-3.7.4 2017-05-17

PEPGetEigenpair

Gets the i-th solution of the eigenproblem as computed by PEPSolve(). The solution consists in both the eigenvalue and the eigenvector.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetEigenpair(PEP pep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)
Logically Collective on EPS

Input Parameters

pep  - polynomial eigensolver context
i  - index of the solution

Output Parameters

eigr  - real part of eigenvalue
eigi  - imaginary part of eigenvalue
Vr  - real part of eigenvector
Vi  - imaginary part of eigenvector

Notes

It is allowed to pass NULL for Vr and Vi, if the eigenvector is not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs().

If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is set to zero). In both cases, the user can pass NULL in eigi and Vi.

The index i should be a value between 0 and nconv-1 (see PEPGetConverged()). Eigenpairs are indexed according to the ordering criterion established with PEPSetWhichEigenpairs().

See Also

PEPSolve(), PEPGetConverged(), PEPSetWhichEigenpairs()

Location: src/pep/interface/pepsolve.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPRefineGetKSP.html0000644000175000017500000000363213107004621021521 0ustar jromanjroman PEPRefineGetKSP
slepc-3.7.4 2017-05-17

PEPRefineGetKSP

Obtain the ksp object used by the eigensolver object in the refinement phase.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPRefineGetKSP(PEP pep,KSP *ksp)
Not Collective

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Output Parameter

ksp  - ksp context

See Also

PEPSetRefine()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetBV.html0000644000175000017500000000355613107004621020247 0ustar jromanjroman PEPGetBV

slepc-3.7.4 2017-05-17

PEPGetBV

Obtain the basis vectors object associated to the polynomial eigensolver object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetBV(PEP pep,BV *bv)
Not Collective

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Output Parameter

bv  - basis vectors context

See Also

PEPSetBV()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPLinearGetCompanionForm.html0000644000175000017500000000400013107004621023623 0ustar jromanjroman PEPLinearGetCompanionForm

slepc-3.7.4 2017-05-17

PEPLinearGetCompanionForm

Returns the number of the companion form that will be used for the linearization of a quadratic eigenproblem.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPLinearGetCompanionForm(PEP pep,PetscInt *cform)
Not Collective

Input Parameter

pep  - polynomial eigenvalue solver

Output Parameter

cform  - the companion form number (1 or 2)

See Also

PEPLinearSetCompanionForm()

Location: src/pep/impls/linear/linear.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetTolerances.html0000644000175000017500000000501213107004621022040 0ustar jromanjroman PEPSetTolerances

slepc-3.7.4 2017-05-17

PEPSetTolerances

Sets the tolerance and maximum iteration count used by the PEP convergence tests.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetTolerances(PEP pep,PetscReal tol,PetscInt maxits)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
tol  - the convergence tolerance
maxits  - maximum number of iterations to use

Options Database Keys

-pep_tol <tol>  - Sets the convergence tolerance
-pep_max_it <maxits>  - Sets the maximum number of iterations allowed

Notes

Use PETSC_DEFAULT for either argument to assign a reasonably good value.

See Also

PEPGetTolerances()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetScale.html0000644000175000017500000000606513107004621020765 0ustar jromanjroman PEPGetScale

slepc-3.7.4 2017-05-17

PEPGetScale

Gets the scaling strategy used by the PEP object, and the associated parameters.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetScale(PEP pep,PEPScale *scale,PetscReal *alpha,Vec *Dl,Vec *Dr,PetscInt *its,PetscReal *lambda)
Not Collectiv, but vectors are shared by all processors that share the PEP

Input Parameter

pep  - the eigensolver context

Output Parameters

scale  - scaling strategy
alpha  - the scaling factor used in the scalar strategy
Dl  - the left diagonal matrix of the diagonal scaling algorithm
Dr  - the right diagonal matrix of the diagonal scaling algorithm
its  - number of iterations of the diagonal scaling algorithm
lambda  - approximation to wanted eigenvalues (modulus)

Note

The user can specify NULL for any parameter that is not needed.

If Dl or Dr were not set by the user, then the ones computed internally are returned (or a null pointer if called before PEPSetUp).

See Also

PEPSetScale(), PEPSetUp()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetDS.html0000644000175000017500000000373413107004621020260 0ustar jromanjroman PEPSetDS

slepc-3.7.4 2017-05-17

PEPSetDS

Associates a direct solver object to the polynomial eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetDS(PEP pep,DS ds)
Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
ds  - the direct solver object

Note

Use PEPGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations).

See Also

PEPGetDS()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetTrackAll.html0000644000175000017500000000433513107004621021445 0ustar jromanjroman PEPSetTrackAll

slepc-3.7.4 2017-05-17

PEPSetTrackAll

Specifies if the solver must compute the residual of all approximate eigenpairs or not.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetTrackAll(PEP pep,PetscBool trackall)
Logically Collective on PEP

Input Parameters

pep  - the eigensolver context
trackall  - whether compute all residuals or not

Notes

If the user sets trackall=PETSC_TRUE then the solver explicitly computes the residual for each eigenpair approximation. Computing the residual is usually an expensive operation and solvers commonly compute the associated residual to the first unconverged eigenpair. The options '-pep_monitor_all' and '-pep_monitor_lg_all' automatically activate this option.

See Also

PEPGetTrackAll()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPVectorsView.html0000644000175000017500000000451113107004621021550 0ustar jromanjroman PEPVectorsView

slepc-3.7.4 2017-05-17

PEPVectorsView

Outputs computed eigenvectors to a viewer.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPVectorsView(PEP pep,PetscViewer viewer)
Collective on PEP

Parameter

pep  - the eigensolver context
viewer  - the viewer

Options Database Keys

-pep_view_vectors  - output eigenvectors.

Note

If PETSc was configured with real scalars, complex conjugate eigenvectors will be viewed as two separate real vectors, one containing the real part and another one containing the imaginary part.

See Also

PEPSolve(), PEPValuesView(), PEPErrorView()

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPMonitorFirst.html0000644000175000017500000000544313107004621021734 0ustar jromanjroman PEPMonitorFirst

slepc-3.7.4 2017-05-17

PEPMonitorFirst

Print the first unconverged approximate value and error estimate at each iteration of the polynomial eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPMonitorFirst(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on PEP

Input Parameters

pep  - polynomial eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

PEPMonitorSet(), PEPMonitorAll(), PEPMonitorConverged()

Location: src/pep/interface/pepmon.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPView.html0000644000175000017500000000526213107004621020206 0ustar jromanjroman PEPView

slepc-3.7.4 2017-05-17

PEPView

Prints the PEP data structure.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPView(PEP pep,PetscViewer viewer)
Collective on PEP

Input Parameters

pep  - the polynomial eigenproblem solver context
viewer  - optional visualization context

Options Database Key

-pep_view  - Calls PEPView() at end of PEPSolve()

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

See Also

PetscViewerASCIIOpen()

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPMonitorSetFromOptions.html0000644000175000017500000000540113107004621023572 0ustar jromanjroman PEPMonitorSetFromOptions

slepc-3.7.4 2017-05-17

PEPMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a PetscViewerAndFormat
trackall  - whether this monitor tracks all eigenvalues or not

See Also

PEPMonitorSet(), PEPSetTrackAll(), PEPConvMonitorSetFromOptions()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetDimensions.html0000644000175000017500000000543413107004621022045 0ustar jromanjroman PEPGetDimensions

slepc-3.7.4 2017-05-17

PEPGetDimensions

Gets the number of eigenvalues to compute and the dimension of the subspace.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetDimensions(PEP pep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameters

nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

Notes

The user can specify NULL for any parameter that is not needed.

See Also

PEPSetDimensions()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
slepc-3.7.4/docs/manualpages/PEP/PEPSetRG.html0000644000175000017500000000370713107004621020262 0ustar jromanjroman PEPSetRG
slepc-3.7.4 2017-05-17

PEPSetRG

Associates a region object to the polynomial eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetRG(PEP pep,RG rg)
Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
rg  - the region object

Note

Use PEPGetRG() to retrieve the region context (for example, to free it at the end of the computations).

See Also

PEPGetRG()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetType.html0000644000175000017500000000455113107004621020655 0ustar jromanjroman PEPGetType

slepc-3.7.4 2017-05-17

PEPGetType

Gets the PEP type as a string from the PEP object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetType(PEP pep,PEPType *type)
Not Collective

Input Parameter

pep  - the eigensolver context

Output Parameter

name  - name of PEP method

See Also

PEPSetType()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
slepc-3.7.4/docs/manualpages/PEP/PEPLinearGetExplicitMatrix.html0000644000175000017500000000377113107004621024040 0ustar jromanjroman PEPLinearGetExplicitMatrix
slepc-3.7.4 2017-05-17

PEPLinearGetExplicitMatrix

Returns the flag indicating if the matrices A and B for the linearization are built explicitly.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPLinearGetExplicitMatrix(PEP pep,PetscBool *explicitmatrix)
Not Collective

Input Parameter

pep  - polynomial eigenvalue solver

Output Parameter

explicitmatrix  - the mode flag

See Also

PEPLinearSetExplicitMatrix()

Location: src/pep/impls/linear/linear.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPQArnoldiGetRestart.html0000644000175000017500000000366113107004621023013 0ustar jromanjroman PEPQArnoldiGetRestart

slepc-3.7.4 2017-05-17

PEPQArnoldiGetRestart

Gets the restart parameter used in the Q-Arnoldi method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPQArnoldiGetRestart(PEP pep,PetscReal *keep)
Not Collective

Input Parameter

pep  - the eigenproblem solver context

Output Parameter

keep  - the restart parameter

See Also

PEPQArnoldiSetRestart()

Location: src/pep/impls/krylov/qarnoldi/qarnoldi.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPType.html0000644000175000017500000000277413107004621020222 0ustar jromanjroman PEPType

slepc-3.7.4 2017-05-17

PEPType

String with the name of a polynomial eigensolver

Synopsis

typedef const char* PEPType;
#define PEPLINEAR    "linear"
#define PEPQARNOLDI  "qarnoldi"
#define PEPTOAR      "toar"
#define PEPSTOAR     "stoar"
#define PEPJD        "jd"

See Also

PEPSetType(), PEP

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetInitialSpace.html0000644000175000017500000000466713107004621022325 0ustar jromanjroman PEPSetInitialSpace

slepc-3.7.4 2017-05-17

PEPSetInitialSpace

Specify a basis of vectors that constitute the initial space, that is, the subspace from which the solver starts to iterate.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetInitialSpace(PEP pep,PetscInt n,Vec *is)
Collective on PEP and Vec

Input Parameter

pep  - the polynomial eigensolver context
n  - number of vectors
is  - set of basis vectors of the initial space

Notes

Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored.

These vectors do not persist from one PEPSolve() call to the other, so the initial space should be set every time.

The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally.

Common usage of this function is when the user can provide a rough approximation of the wanted eigenspace. Then, convergence may be faster.

Location: src/pep/interface/pepsetup.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetST.html0000644000175000017500000000406613107004621020263 0ustar jromanjroman PEPGetST

slepc-3.7.4 2017-05-17

PEPGetST

Obtain the spectral transformation (ST) object associated to the eigensolver object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetST(PEP pep,ST *st)
Not Collective

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Output Parameter

st  - spectral transformation context

See Also

PEPSetST()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex28.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPSetStoppingTest.html0000644000175000017500000000600513107004621022407 0ustar jromanjroman PEPSetStoppingTest
slepc-3.7.4 2017-05-17

PEPSetStoppingTest

Specifies how to decide the termination of the outer loop of the eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetStoppingTest(PEP pep,PEPStop stop)
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
stop  - the type of stopping test

Options Database Keys

-pep_stop_basic  - Sets the default stopping test
-pep_stop_user  - Selects the user-defined stopping test

Note

The parameter 'stop' can have one of these values
PEP_STOP_BASIC  - default stopping test
PEP_STOP_USER  - function set by PEPSetStoppingTestFunction()

See Also

PEPGetStoppingTest(), PEPSetStoppingTestFunction(), PEPSetConvergenceTest(), PEPStop

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPVectorsViewFromOptions.html0000644000175000017500000000315313107004621023751 0ustar jromanjroman PEPVectorsViewFromOptions

slepc-3.7.4 2017-05-17

PEPVectorsViewFromOptions

Processes command line options to determine if/how the computed eigenvectors are to be viewed.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPVectorsViewFromOptions(PEP pep)
Collective on PEP

Input Parameters

pep  - the eigensolver context

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPConvergedReason.html0000644000175000017500000000366513107004621022365 0ustar jromanjroman PEPConvergedReason

slepc-3.7.4 2017-05-17

PEPConvergedReason

Reason an eigensolver was said to have converged or diverged

Synopsis

typedef enum {/* converged */
              PEP_CONVERGED_TOL                =  1,
              PEP_CONVERGED_USER               =  2,
              /* diverged */
              PEP_DIVERGED_ITS                 = -1,
              PEP_DIVERGED_BREAKDOWN           = -2,
              PEP_DIVERGED_SYMMETRY_LOST       = -3,
              PEP_CONVERGED_ITERATING          =  0} PEPConvergedReason;

See Also

PEPSolve(), PEPGetConvergedReason(), PEPSetTolerances()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPQArnoldiGetLocking.html0000644000175000017500000000364713107004621022761 0ustar jromanjroman PEPQArnoldiGetLocking

slepc-3.7.4 2017-05-17

PEPQArnoldiGetLocking

Gets the locking flag used in the Q-Arnoldi method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPQArnoldiGetLocking(PEP pep,PetscBool *lock)
Not Collective

Input Parameter

pep  - the eigenproblem solver context

Output Parameter

lock  - the locking flag

See Also

PEPQArnoldiSetLocking()

Location: src/pep/impls/krylov/qarnoldi/qarnoldi.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPProblemType.html0000644000175000017500000000322013107004621021526 0ustar jromanjroman PEPProblemType

slepc-3.7.4 2017-05-17

PEPProblemType

Determines the type of the polynomial eigenproblem

Synopsis

typedef enum { PEP_GENERAL=1,
               PEP_HERMITIAN,   /* All A_i  Hermitian */
               PEP_GYROSCOPIC   /* QEP with M, K  Hermitian, M>0, C skew-Hermitian */
             } PEPProblemType;

See Also

PEPSetProblemType(), PEPGetProblemType()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPComputeError.html0000644000175000017500000000526313107004621021723 0ustar jromanjroman PEPComputeError

slepc-3.7.4 2017-05-17

PEPComputeError

Computes the error (based on the residual norm) associated with the i-th computed eigenpair.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPComputeError(PEP pep,PetscInt i,PEPErrorType type,PetscReal *error)
Collective on PEP

Input Parameter

pep  - the polynomial eigensolver context
i  - the solution index
type  - the type of error to compute

Output Parameter

error  - the error

Notes

The error can be computed in various ways, all of them based on the residual norm ||P(l)x||_2 where l is the eigenvalue and x is the eigenvector. See the users guide for additional details.

See Also

PEPErrorType, PEPSolve(), PEPGetErrorEstimate()

Location: src/pep/interface/pepsolve.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPSetBV.html0000644000175000017500000000373413107004621020261 0ustar jromanjroman PEPSetBV
slepc-3.7.4 2017-05-17

PEPSetBV

Associates a basis vectors object to the polynomial eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetBV(PEP pep,BV bv)
Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
bv  - the basis vectors object

Note

Use PEPGetBV() to retrieve the basis vectors context (for example, to free it at the end of the computations).

See Also

PEPGetBV()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSolve.html0000644000175000017500000001062513107004621020363 0ustar jromanjroman PEPSolve

slepc-3.7.4 2017-05-17

PEPSolve

Solves the polynomial eigensystem.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSolve(PEP pep)
Collective on PEP

Input Parameter

pep  - eigensolver context obtained from PEPCreate()

Options Database Keys

-pep_view  - print information about the solver used
-pep_view_matk binary  - save any of the coefficient matrices (Ak) to the default binary viewer (replace k by an integer from 0 to nmat-1)
-pep_view_vectors binary  - save the computed eigenvectors to the default binary viewer
-pep_view_values  - print computed eigenvalues
-pep_converged_reason  - print reason for convergence, and number of iterations
-pep_error_absolute  - print absolute errors of each eigenpair
-pep_error_relative  - print relative errors of each eigenpair
-pep_error_backward  - print backward errors of each eigenpair

See Also

PEPCreate(), PEPSetUp(), PEPDestroy(), PEPSetTolerances()

Location: src/pep/interface/pepsolve.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
src/pep/examples/nlevp/butterfly.c.html
src/pep/examples/nlevp/damped_beam.c.html
src/pep/examples/nlevp/pdde_stability.c.html
src/pep/examples/nlevp/planar_waveguide.c.html
src/pep/examples/nlevp/sleeper.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPReasonViewFromOptions.html0000644000175000017500000000320513107004621023551 0ustar jromanjroman PEPReasonViewFromOptions
slepc-3.7.4 2017-05-17

PEPReasonViewFromOptions

Processes command line options to determine if/how the PEP converged reason is to be viewed.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPReasonViewFromOptions(PEP pep)
Collective on PEP

Input Parameters

pep  - the eigensolver context

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPValuesViewFromOptions.html0000644000175000017500000000314413107004621023563 0ustar jromanjroman PEPValuesViewFromOptions

slepc-3.7.4 2017-05-17

PEPValuesViewFromOptions

Processes command line options to determine if/how the computed eigenvalues are to be viewed.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPValuesViewFromOptions(PEP pep)
Collective on PEP

Input Parameters

pep  - the eigensolver context

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPCreate.html0000644000175000017500000000655213107004621020502 0ustar jromanjroman PEPCreate

slepc-3.7.4 2017-05-17

PEPCreate

Creates the default PEP context.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPCreate(MPI_Comm comm,PEP *outpep)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

pep  - location to put the PEP context

Note

The default PEP type is PEPTOAR

See Also

PEPSetUp(), PEPSolve(), PEPDestroy(), PEP

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
src/pep/examples/nlevp/butterfly.c.html
src/pep/examples/nlevp/damped_beam.c.html
src/pep/examples/nlevp/pdde_stability.c.html
src/pep/examples/nlevp/planar_waveguide.c.html
src/pep/examples/nlevp/sleeper.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPLinearGetEPS.html0000644000175000017500000000363213107004621021515 0ustar jromanjroman PEPLinearGetEPS
slepc-3.7.4 2017-05-17

PEPLinearGetEPS

Retrieve the eigensolver object (EPS) associated to the polynomial eigenvalue solver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPLinearGetEPS(PEP pep,EPS *eps)
Not Collective

Input Parameter

pep  - polynomial eigenvalue solver

Output Parameter

eps  - the eigensolver object

See Also

PEPLinearSetEPS()

Location: src/pep/impls/linear/linear.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPQArnoldiSetRestart.html0000644000175000017500000000447213107004621023030 0ustar jromanjroman PEPQArnoldiSetRestart

slepc-3.7.4 2017-05-17

PEPQArnoldiSetRestart

Sets the restart parameter for the Q-Arnoldi method, in particular the proportion of basis vectors that must be kept after restart.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPQArnoldiSetRestart(PEP pep,PetscReal keep)
Logically Collective on PEP

Input Parameters

pep  - the eigenproblem solver context
keep  - the number of vectors to be kept at restart

Options Database Key

-pep_qarnoldi_restart  - Sets the restart parameter

Notes

Allowed values are in the range [0.1,0.9]. The default is 0.5.

See Also

PEPQArnoldiGetRestart()

Location: src/pep/impls/krylov/qarnoldi/qarnoldi.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPConvMonitorSetFromOptions.html0000644000175000017500000000512713107004621024425 0ustar jromanjroman PEPConvMonitorSetFromOptions

slepc-3.7.4 2017-05-17

PEPConvMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence).

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPConvMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))
Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a SlepcConvMonitor

See Also

PEPMonitorSet(), PEPMonitorSetFromOptions()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPTOARSetRestart.html0000644000175000017500000000437713107004621022070 0ustar jromanjroman PEPTOARSetRestart

slepc-3.7.4 2017-05-17

PEPTOARSetRestart

Sets the restart parameter for the TOAR method, in particular the proportion of basis vectors that must be kept after restart.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPTOARSetRestart(PEP pep,PetscReal keep)
Logically Collective on PEP

Input Parameters

pep  - the eigenproblem solver context
keep  - the number of vectors to be kept at restart

Options Database Key

-pep_toar_restart  - Sets the restart parameter

Notes

Allowed values are in the range [0.1,0.9]. The default is 0.5.

See Also

PEPTOARGetRestart()

Location: src/pep/impls/krylov/toar/ptoar.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetFromOptions.html0000644000175000017500000000606013107004621022224 0ustar jromanjroman PEPSetFromOptions

slepc-3.7.4 2017-05-17

PEPSetFromOptions

Sets PEP options from the options database. This routine must be called before PEPSetUp() if the user is to be allowed to set the solver type.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetFromOptions(PEP pep)
Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context

Notes

To see all options, run your program with the -help option.

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
src/pep/examples/nlevp/butterfly.c.html
src/pep/examples/nlevp/damped_beam.c.html
src/pep/examples/nlevp/pdde_stability.c.html
src/pep/examples/nlevp/planar_waveguide.c.html
src/pep/examples/nlevp/sleeper.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPGetMonitorContext.html0000644000175000017500000000401113107004621022717 0ustar jromanjroman PEPGetMonitorContext
slepc-3.7.4 2017-05-17

PEPGetMonitorContext

Gets the monitor context, as set by PEPMonitorSet() for the FIRST monitor only.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetMonitorContext(PEP pep,void **ctx)
Not Collective

Input Parameter

pep  - eigensolver context obtained from PEPCreate()

Output Parameter

ctx  - monitor context

See Also

PEPMonitorSet(), PEPDefaultMonitor()

Location: src/pep/interface/pepmon.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetConvergenceTest.html0000644000175000017500000000722013107004621023042 0ustar jromanjroman PEPSetConvergenceTest

slepc-3.7.4 2017-05-17

PEPSetConvergenceTest

Specifies how to compute the error estimate used in the convergence test.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetConvergenceTest(PEP pep,PEPConv conv)
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
conv  - the type of convergence test

Options Database Keys

-pep_conv_abs  - Sets the absolute convergence test
-pep_conv_rel  - Sets the convergence test relative to the eigenvalue
-pep_conv_norm  - Sets the convergence test relative to the matrix norms
-pep_conv_user  - Selects the user-defined convergence test

Note

The parameter 'conv' can have one of these values
PEP_CONV_ABS  - absolute error ||r||
PEP_CONV_REL  - error relative to the eigenvalue l, ||r||/|l|
PEP_CONV_NORM  - error relative matrix norms, ||r||/sum_i(l^i*||A_i||)
PEP_CONV_USER  - function set by PEPSetConvergenceTestFunction()

See Also

PEPGetConvergenceTest(), PEPSetConvergenceTestFunction(), PEPSetStoppingTest(), PEPConv

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/index.html0000644000175000017500000002521613107004621020037 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP

slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

Beginner - Basic usage
PEP PEPGetConverged PEPSolve
PEPComputeError PEPGetEigenpair PEPType
PEPCreate PEPSetFromOptions PEPView
PEPDestroy PEPSetOperators
Intermediate - Setting options for algorithms and data structures
PEPBasis PEPGetST PEPSetBasis
PEPConv PEPGetScale PEPSetConvergenceTest
PEPConvergedReason PEPGetTarget PEPSetDimensions
PEPErrorType PEPGetTolerances PEPSetExtract
PEPErrorView PEPGetType PEPSetInitialSpace
PEPExtract PEPGetWhichEigenpairs PEPSetProblemType
PEPGetBasis PEPMonitorAll PEPSetRefine
PEPGetConvergedReason PEPMonitorCancel PEPSetScale
PEPGetConvergenceTest PEPMonitorConverged PEPSetTarget
PEPGetDimensions PEPMonitorFirst PEPSetTolerances
PEPGetExtract PEPMonitorLGCreate PEPSetType
PEPGetIterationNumber PEPMonitorSet PEPSetWhichEigenpairs
PEPGetMonitorContext PEPProblemType PEPValuesView
PEPGetNumMatrices PEPReasonView PEPVectorsView
PEPGetOperators PEPRefine PEPWhich
PEPGetProblemType PEPRefineScheme
PEPGetRefine PEPScale
Advanced - Setting more advanced options and customization
PEPAppendOptionsPrefix PEPLinearSetExplicitMatrix PEPSetEigenvalueComparison
PEPGetBV PEPQArnoldiGetLocking PEPSetOptionsPrefix
PEPGetDS PEPQArnoldiGetRestart PEPSetRG
PEPGetErrorEstimate PEPQArnoldiSetLocking PEPSetST
PEPGetOptionsPrefix PEPQArnoldiSetRestart PEPSetStoppingTest
PEPGetRG PEPRefineGetKSP PEPSetStoppingTestFunction
PEPGetStoppingTest PEPRegister PEPStop
PEPJDGetRestart PEPRegisterAll PEPStoppingBasic
PEPJDSetRestart PEPReset PEPTOARGetLocking
PEPLinearGetCompanionForm PEPSTOARGetLocking PEPTOARGetRestart
PEPLinearGetEPS PEPSTOARSetLocking PEPTOARSetLocking
PEPLinearGetExplicitMatrix PEPSetBV PEPTOARSetRestart
PEPLinearSetCompanionForm PEPSetConvergenceTestFunction
PEPLinearSetEPS PEPSetDS
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
PEPAllocateSolution PEPInitializePackage PEPSetWorkVecs
PEPConvMonitorSetFromOptions PEPMonitorSetFromOptions PEPValuesViewFromOptions
PEPErrorViewFromOptions PEPReasonViewFromOptions PEPVectorsViewFromOptions
PEPFinalizePackage PEPSetTrackAll
PEPGetTrackAll PEPSetUp
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/PEP/PEPErrorType.html0000644000175000017500000000273413107004621021230 0ustar jromanjroman PEPErrorType

slepc-3.7.4 2017-05-17

PEPErrorType

The error type used to assess accuracy of computed solutions

Synopsis

typedef enum { PEP_ERROR_ABSOLUTE,
               PEP_ERROR_RELATIVE,
               PEP_ERROR_BACKWARD } PEPErrorType;

See Also

PEPComputeError()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetProblemType.html0000644000175000017500000000652713107004621022217 0ustar jromanjroman PEPSetProblemType

slepc-3.7.4 2017-05-17

PEPSetProblemType

Specifies the type of the polynomial eigenvalue problem.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetProblemType(PEP pep,PEPProblemType type)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
type  - a known type of polynomial eigenvalue problem

Options Database Keys

-pep_general  - general problem with no particular structure
-pep_hermitian  - problem whose coefficient matrices are Hermitian
-pep_gyroscopic  - problem with Hamiltonian structure

Notes

Allowed values for the problem type are: general (PEP_GENERAL), Hermitian (PEP_HERMITIAN), and gyroscopic (PEP_GYROSCOPIC).

This function is used to instruct SLEPc to exploit certain structure in the polynomial eigenproblem. By default, no particular structure is assumed.

If the problem matrices are Hermitian (symmetric in the real case) or Hermitian/skew-Hermitian then the solver can exploit this fact to perform less operations or provide better stability.

See Also

PEPSetOperators(), PEPSetType(), PEPGetProblemType(), PEPProblemType

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex16f90.F90.html
slepc-3.7.4/docs/manualpages/PEP/PEPReset.html0000644000175000017500000000332013107004621020347 0ustar jromanjroman PEPReset
slepc-3.7.4 2017-05-17

PEPReset

Resets the PEP context to the initial state and removes any allocated objects.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPReset(PEP pep)
Collective on PEP

Input Parameter

pep  - eigensolver context obtained from PEPCreate()

See Also

PEPDestroy()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetWorkVecs.html0000644000175000017500000000354013107004621021510 0ustar jromanjroman PEPSetWorkVecs

slepc-3.7.4 2017-05-17

PEPSetWorkVecs

Sets a number of work vectors into a PEP object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetWorkVecs(PEP pep,PetscInt nw)
Collective on PEP

Input Parameters

pep  - polynomial eigensolver context
nw  - number of work vectors to allocate

Developers Note

This is PETSC_EXTERN because it may be required by user plugin PEP implementations.

Location: src/pep/interface/pepdefault.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetNumMatrices.html0000644000175000017500000000376313107004621022167 0ustar jromanjroman PEPGetNumMatrices

slepc-3.7.4 2017-05-17

PEPGetNumMatrices

Returns the number of matrices stored in the PEP.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetNumMatrices(PEP pep,PetscInt *nmat)
Not collective

Input Parameter

pep  - the PEP context

Output Parameters

nmat  - the number of matrices passed in PEPSetOperators()

See Also

PEPSetOperators()

Location: src/pep/interface/pepsetup.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEP.html0000644000175000017500000000275213107004621017354 0ustar jromanjroman PEP

slepc-3.7.4 2017-05-17

PEP

Abstract SLEPc object that manages all the polynomial eigenvalue problem solvers.

Synopsis

typedef struct _p_PEP* PEP;

See Also

PEPCreate()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16f90.F90.html
slepc-3.7.4/docs/manualpages/PEP/PEPSTOARGetLocking.html0000644000175000017500000000357413107004621022137 0ustar jromanjroman PEPSTOARGetLocking
slepc-3.7.4 2017-05-17

PEPSTOARGetLocking

Gets the locking flag used in the STOAR method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSTOARGetLocking(PEP pep,PetscBool *lock)
Not Collective

Input Parameter

pep  - the eigenproblem solver context

Output Parameter

lock  - the locking flag

See Also

PEPSTOARSetLocking()

Location: src/pep/impls/krylov/stoar/stoar.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetRG.html0000644000175000017500000000354013107004621020241 0ustar jromanjroman PEPGetRG

slepc-3.7.4 2017-05-17

PEPGetRG

Obtain the region object associated to the polynomial eigensolver object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetRG(PEP pep,RG *rg)
Not Collective

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Output Parameter

rg  - region context

See Also

PEPSetRG()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPInitializePackage.html0000644000175000017500000000312513107004621022645 0ustar jromanjroman PEPInitializePackage

slepc-3.7.4 2017-05-17

PEPInitializePackage

This function initializes everything in the PEP package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PEPCreate() when using static libraries.

Synopsis

PetscErrorCode PEPInitializePackage(void)

See Also

SlepcInitialize()

Location: src/pep/interface/dlregispep.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetTrackAll.html0000644000175000017500000000355313107004621021432 0ustar jromanjroman PEPGetTrackAll

slepc-3.7.4 2017-05-17

PEPGetTrackAll

Returns the flag indicating whether all residual norms must be computed or not.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetTrackAll(PEP pep,PetscBool *trackall)
Not Collective

Input Parameter

pep  - the eigensolver context

Output Parameter

trackall  - the returned flag

See Also

PEPSetTrackAll()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetOptionsPrefix.html0000644000175000017500000000432313107004621022542 0ustar jromanjroman PEPGetOptionsPrefix

slepc-3.7.4 2017-05-17

PEPGetOptionsPrefix

Gets the prefix used for searching for all PEP options in the database.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetOptionsPrefix(PEP pep,const char *prefix[])
Not Collective

Input Parameters

pep  - the polynomial eigensolver context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

PEPSetOptionsPrefix(), PEPAppendOptionsPrefix()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPMonitorSet.html0000644000175000017500000001257013107004621021377 0ustar jromanjroman PEPMonitorSet

slepc-3.7.4 2017-05-17

PEPMonitorSet

Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested eigenpair.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPMonitorSet(PEP pep,PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
monitor  - pointer to function (if this is NULL, it turns off monitoring)
mctx  - [optional] context for private data for the monitor routine (use NULL if no context is desired)
monitordestroy  - [optional] routine that frees monitor context (may be NULL)

Calling Sequence of monitor

  monitor(PEP pep,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx)

pep  - polynomial eigensolver context obtained from PEPCreate()
its  - iteration number
nconv  - number of converged eigenpairs
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - relative error estimates for each eigenpair
nest  - number of error estimates
mctx  - optional monitoring context, as set by PEPMonitorSet()

Options Database Keys

-pep_monitor  - print only the first error estimate
-pep_monitor_all  - print error estimates at each iteration
-pep_monitor_conv  - print the eigenvalue approximations only when convergence has been reached
-pep_monitor_lg  - sets line graph monitor for the first unconverged approximate eigenvalue
-pep_monitor_lg_all  - sets line graph monitor for all unconverged approximate eigenvalues
-pep_monitor_cancel  - cancels all monitors that have been hardwired into a code by calls to PEPMonitorSet(), but does not cancel those set via the options database.

Notes

Several different monitoring routines may be set by calling PEPMonitorSet() multiple times; all will be called in the order in which they were set.

See Also

PEPMonitorFirst(), PEPMonitorAll(), PEPMonitorCancel()

Location: src/pep/interface/pepmon.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetConvergedReason.html0000644000175000017500000000610213107004621023012 0ustar jromanjroman PEPGetConvergedReason

slepc-3.7.4 2017-05-17

PEPGetConvergedReason

Gets the reason why the PEPSolve() iteration was stopped.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetConvergedReason(PEP pep,PEPConvergedReason *reason)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameter

reason  - negative value indicates diverged, positive value converged

Notes

Possible values for reason are
PEP_CONVERGED_TOL  - converged up to tolerance
PEP_CONVERGED_USER  - converged due to a user-defined condition
PEP_DIVERGED_ITS  - required more than max_it iterations to reach convergence
PEP_DIVERGED_BREAKDOWN  - generic breakdown in method
PEP_DIVERGED_SYMMETRY_LOST  - pseudo-Lanczos was not able to keep symmetry

Can only be called after the call to PEPSolve() is complete.

See Also

PEPSetTolerances(), PEPSolve(), PEPConvergedReason

Location: src/pep/interface/pepsolve.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetUp.html0000644000175000017500000000401613107004621020330 0ustar jromanjroman PEPSetUp

slepc-3.7.4 2017-05-17

PEPSetUp

Sets up all the internal data structures necessary for the execution of the PEP solver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetUp(PEP pep)
Collective on PEP

Input Parameter

pep  - solver context

Notes

This function need not be called explicitly in most cases, since PEPSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time.

See Also

PEPCreate(), PEPSolve(), PEPDestroy()

Location: src/pep/interface/pepsetup.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPConv.html0000644000175000017500000000305513107004621020177 0ustar jromanjroman PEPConv

slepc-3.7.4 2017-05-17

PEPConv

Determines the convergence test

Synopsis

typedef enum { PEP_CONV_ABS,
               PEP_CONV_REL,
               PEP_CONV_NORM,
               PEP_CONV_USER } PEPConv;

See Also

PEPSetConvergenceTest(), PEPSetConvergenceTestFunction()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPMonitorAll.html0000644000175000017500000000542513107004621021355 0ustar jromanjroman PEPMonitorAll

slepc-3.7.4 2017-05-17

PEPMonitorAll

Print the current approximate values and error estimates at each iteration of the polynomial eigensolver.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPMonitorAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on PEP

Input Parameters

pep  - polynomial eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

PEPMonitorSet(), PEPMonitorFirst(), PEPMonitorConverged()

Location: src/pep/interface/pepmon.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPMonitorLGCreate.html0000644000175000017500000000600213107004621022263 0ustar jromanjroman PEPMonitorLGCreate

slepc-3.7.4 2017-05-17

PEPMonitorLGCreate

Creates a line graph context for use with PEP to monitor convergence.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
Collective on MPI_Comm

Input Parameters

comm  - communicator context
host  - the X display to open, or null for the local machine
label  - the title to put in the title bar
x, y  - the screen coordinates of the upper left coordinate of the window
m, n  - the screen width and height in pixels

Output Parameter

lgctx  - the drawing context

Options Database Keys

-pep_monitor_lg  - Sets line graph monitor for the first residual
-pep_monitor_lg_all  - Sets line graph monitor for all residuals

Notes

Use PetscDrawLGDestroy() to destroy this line graph.

See Also

PEPMonitorSet()

Location: src/pep/interface/pepmon.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetBasis.html0000644000175000017500000000507313107004621021011 0ustar jromanjroman PEPSetBasis

slepc-3.7.4 2017-05-17

PEPSetBasis

Specifies the type of polynomial basis used to describe the polynomial eigenvalue problem.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetBasis(PEP pep,PEPBasis basis)
Logically Collective on PEP

Input Parameters

pep  - the polynomial eigensolver context
basis  - the type of polynomial basis

Options Database Key

-pep_basis <basis>  - Select the basis type

Notes

By default, the coefficient matrices passed via PEPSetOperators() are expressed in the monomial basis, i.e. P(lambda) = A_0 + lambda*A_1 + lambda^2*A_2 + ... + lambda^d*A_d. Other polynomial bases may have better numerical behaviour, but the user must then pass the coefficient matrices accordingly.

See Also

PEPSetOperators(), PEPGetBasis(), PEPBasis

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPRegister.html0000644000175000017500000000450313107004621021055 0ustar jromanjroman PEPRegister

slepc-3.7.4 2017-05-17

PEPRegister

Adds a method to the polynomial eigenproblem solver package.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPRegister(const char *name,PetscErrorCode (*function)(PEP))
Not Collective

Input Parameters

name  - name of a new user-defined solver
function  - routine to create the solver context

Notes

PEPRegister() may be called multiple times to add several user-defined solvers.

Sample usage

    PEPRegister("my_solver",MySolverCreate);

Then, your solver can be chosen with the procedural interface via

    PEPSetType(pep,"my_solver")
or at runtime via the option
    -pep_type my_solver

See Also

PEPRegisterAll()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPSetWhichEigenpairs.html0000644000175000017500000001317413107004621023022 0ustar jromanjroman PEPSetWhichEigenpairs

slepc-3.7.4 2017-05-17

PEPSetWhichEigenpairs

Specifies which portion of the spectrum is to be sought.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPSetWhichEigenpairs(PEP pep,PEPWhich which)
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()
which  - the portion of the spectrum to be sought

Possible values

The parameter 'which' can have one of these values

PEP_LARGEST_MAGNITUDE  - largest eigenvalues in magnitude (default)
PEP_SMALLEST_MAGNITUDE  - smallest eigenvalues in magnitude
PEP_LARGEST_REAL  - largest real parts
PEP_SMALLEST_REAL  - smallest real parts
PEP_LARGEST_IMAGINARY  - largest imaginary parts
PEP_SMALLEST_IMAGINARY  - smallest imaginary parts
PEP_TARGET_MAGNITUDE  - eigenvalues closest to the target (in magnitude)
PEP_TARGET_REAL  - eigenvalues with real part closest to target
PEP_TARGET_IMAGINARY  - eigenvalues with imaginary part closest to target
PEP_WHICH_USER  - user defined ordering set with PEPSetEigenvalueComparison()

Options Database Keys

-pep_largest_magnitude  - Sets largest eigenvalues in magnitude
-pep_smallest_magnitude  - Sets smallest eigenvalues in magnitude
-pep_largest_real  - Sets largest real parts
-pep_smallest_real  - Sets smallest real parts
-pep_largest_imaginary  - Sets largest imaginary parts
-pep_smallest_imaginary  - Sets smallest imaginary parts
-pep_target_magnitude  - Sets eigenvalues closest to target
-pep_target_real  - Sets real parts closest to target
-pep_target_imaginary  - Sets imaginary parts closest to target

Notes

Not all eigensolvers implemented in PEP account for all the possible values stated above. If SLEPc is compiled for real numbers PEP_LARGEST_IMAGINARY and PEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part for eigenvalue selection.

The target is a scalar value provided with PEPSetTarget().

The criterion PEP_TARGET_IMAGINARY is available only in case PETSc and SLEPc have been built with complex scalars.

See Also

PEPGetWhichEigenpairs(), PEPSetTarget(), PEPSetEigenvalueComparison(), PEPWhich

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPFinalizePackage.html0000644000175000017500000000276713107004621022320 0ustar jromanjroman PEPFinalizePackage

slepc-3.7.4 2017-05-17

PEPFinalizePackage

This function destroys everything in the Slepc interface to the PEP package. It is called from SlepcFinalize().

Synopsis

PetscErrorCode PEPFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/pep/interface/dlregispep.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPErrorViewFromOptions.html0000644000175000017500000000315113107004621023413 0ustar jromanjroman PEPErrorViewFromOptions

slepc-3.7.4 2017-05-17

PEPErrorViewFromOptions

Processes command line options to determine if/how the errors of the computed solution are to be viewed.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPErrorViewFromOptions(PEP pep)
Collective on PEP

Input Parameters

pep  - the eigensolver context

Location: src/pep/interface/pepview.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPScale.html0000644000175000017500000000264113107004621020321 0ustar jromanjroman PEPScale

slepc-3.7.4 2017-05-17

PEPScale

The scaling strategy

Synopsis

typedef enum { PEP_SCALE_NONE,
               PEP_SCALE_SCALAR,
               PEP_SCALE_DIAGONAL,
               PEP_SCALE_BOTH } PEPScale;

See Also

PEPSetScale()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPTOARSetLocking.html0000644000175000017500000000454613107004621022030 0ustar jromanjroman PEPTOARSetLocking

slepc-3.7.4 2017-05-17

PEPTOARSetLocking

Choose between locking and non-locking variants of the TOAR method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPTOARSetLocking(PEP pep,PetscBool lock)
Logically Collective on PEP

Input Parameters

pep  - the eigenproblem solver context
lock  - true if the locking variant must be selected

Options Database Key

-pep_toar_locking  - Sets the locking flag

Notes

The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant).

See Also

PEPTOARGetLocking()

Location: src/pep/impls/krylov/toar/ptoar.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPRefineScheme.html0000644000175000017500000000300713107004621021624 0ustar jromanjroman PEPRefineScheme

slepc-3.7.4 2017-05-17

PEPRefineScheme

The scheme used for solving linear systems during iterative refinement

Synopsis

typedef enum { PEP_REFINE_SCHEME_SCHUR=1,
               PEP_REFINE_SCHEME_MBE,
               PEP_REFINE_SCHEME_EXPLICIT } PEPRefineScheme;

See Also

PEPSetRefine()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetRefine.html0000644000175000017500000000507013107004621021141 0ustar jromanjroman PEPGetRefine

slepc-3.7.4 2017-05-17

PEPGetRefine

Gets the refinement strategy used by the PEP object, and the associated parameters.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetRefine(PEP pep,PEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,PEPRefineScheme *scheme)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameters

refine  - refinement type
npart  - number of partitions of the communicator
tol  - the convergence tolerance
its  - maximum number of refinement iterations
scheme  - the scheme used for solving linear systems

Note

The user can specify NULL for any parameter that is not needed.

See Also

PEPSetRefine()

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetConvergenceTest.html0000644000175000017500000000405013107004621023024 0ustar jromanjroman PEPGetConvergenceTest

slepc-3.7.4 2017-05-17

PEPGetConvergenceTest

Gets the method used to compute the error estimate used in the convergence test.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetConvergenceTest(PEP pep,PEPConv *conv)
Not Collective

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Output Parameters

conv  - the type of convergence test

See Also

PEPSetConvergenceTest(), PEPConv

Location: src/pep/interface/pepopts.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPMonitorCancel.html0000644000175000017500000000421413107004621022025 0ustar jromanjroman PEPMonitorCancel

slepc-3.7.4 2017-05-17

PEPMonitorCancel

Clears all monitors for a PEP object.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPMonitorCancel(PEP pep)
Logically Collective on PEP

Input Parameters

pep  - eigensolver context obtained from PEPCreate()

Options Database Key

-pep_monitor_cancel  - Cancels all monitors that have been hardwired into a code by calls to PEPMonitorSet(), but does not cancel those set via the options database.

See Also

PEPMonitorSet()

Location: src/pep/interface/pepmon.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetIterationNumber.html0000644000175000017500000000532113107004621023037 0ustar jromanjroman PEPGetIterationNumber

slepc-3.7.4 2017-05-17

PEPGetIterationNumber

Gets the current iteration number. If the call to PEPSolve() is complete, then it returns the number of iterations carried out by the solution method.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetIterationNumber(PEP pep,PetscInt *its)
Not Collective

Input Parameter

pep  - the polynomial eigensolver context

Output Parameter

its  - number of iterations

Note

During the i-th iteration this call returns i-1. If PEPSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call PEPGetConvergedReason() to determine if the solver converged or failed and why.

See Also

PEPGetConvergedReason(), PEPSetTolerances()

Location: src/pep/interface/pepsolve.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex17.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPWhich.html0000644000175000017500000000344213107004621020334 0ustar jromanjroman PEPWhich
slepc-3.7.4 2017-05-17

PEPWhich

Determines which part of the spectrum is requested

Synopsis

typedef enum { PEP_LARGEST_MAGNITUDE=1,
               PEP_SMALLEST_MAGNITUDE,
               PEP_LARGEST_REAL,
               PEP_SMALLEST_REAL,
               PEP_LARGEST_IMAGINARY,
               PEP_SMALLEST_IMAGINARY,
               PEP_TARGET_MAGNITUDE,
               PEP_TARGET_REAL,
               PEP_TARGET_IMAGINARY,
               PEP_WHICH_USER } PEPWhich;

See Also

PEPSetWhichEigenpairs(), PEPGetWhichEigenpairs()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPGetOperators.html0000644000175000017500000000435213107004621021711 0ustar jromanjroman PEPGetOperators

slepc-3.7.4 2017-05-17

PEPGetOperators

Gets the matrices associated with the polynomial eigensystem.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPGetOperators(PEP pep,PetscInt k,Mat *A)
Not collective, though parallel Mats are returned if the PEP is parallel

Input Parameters

pep  - the PEP context
k  - the index of the requested matrix (starting in 0)

Output Parameter

A  - the requested matrix

See Also

PEPSolve(), PEPSetOperators(), PEPGetNumMatrices()

Location: src/pep/interface/pepsetup.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/PEP/PEPDestroy.html0000644000175000017500000000602613107004621020724 0ustar jromanjroman PEPDestroy

slepc-3.7.4 2017-05-17

PEPDestroy

Destroys the PEP context.

Synopsis

#include "slepcpep.h" 
PetscErrorCode PEPDestroy(PEP *pep)
Collective on PEP

Input Parameter

pep  - eigensolver context obtained from PEPCreate()

See Also

PEPCreate(), PEPSetUp(), PEPSolve()

Location: src/pep/interface/pepbasic.c
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex16.c.html
src/pep/examples/tutorials/ex17.c.html
src/pep/examples/tutorials/ex28.c.html
src/pep/examples/tutorials/ex16f90.F90.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
src/pep/examples/nlevp/butterfly.c.html
src/pep/examples/nlevp/damped_beam.c.html
src/pep/examples/nlevp/pdde_stability.c.html
src/pep/examples/nlevp/planar_waveguide.c.html
src/pep/examples/nlevp/sleeper.c.html
slepc-3.7.4/docs/manualpages/PEP/PEPBasis.html0000644000175000017500000000305213107004621020330 0ustar jromanjroman PEPBasis
slepc-3.7.4 2017-05-17

PEPBasis

The type of polynomial basis used to represent the polynomial eigenproblem

Synopsis

typedef enum { PEP_BASIS_MONOMIAL,
               PEP_BASIS_CHEBYSHEV1,
               PEP_BASIS_CHEBYSHEV2,
               PEP_BASIS_LEGENDRE,
               PEP_BASIS_LAGUERRE,
               PEP_BASIS_HERMITE } PEPBasis;

See Also

PEPSetBasis()

Location: src/pep/../../include/slepcpep.h
Index of all PEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/0000755000175000017500000000000013107004621016032 5ustar jromanjromanslepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSGetSingularitiesFunction.html0000644000175000017500000000442313107004621025160 0ustar jromanjroman NEPNLEIGSGetSingularitiesFunction

slepc-3.7.4 2017-05-17

NEPNLEIGSGetSingularitiesFunction

Returns the Function and optionally the user provided context for computing a discretization of the singularity set.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

fun  - location to put the function (or NULL)
ctx  - location to stash the function context (or NULL)

See Also

NEPNLEIGSSetSingularitiesFunction()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPCISSGetThreshold.html0000644000175000017500000000406613107004621022347 0ustar jromanjroman NEPCISSGetThreshold

slepc-3.7.4 2017-05-17

NEPCISSGetThreshold

Gets the values of various threshold parameters in the CISS solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPCISSGetThreshold(NEP nep,PetscReal *delta,PetscReal *spur)
Not Collective

Input Parameter

nep  - the eigenproblem solver context

Output Parameters

delta  - threshold for numerical rank
spur  - spurious threshold (to discard spurious eigenpairs)

See Also

NEPCISSSetThreshold()

Location: src/nep/impls/ciss/nciss.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSGetLocking.html0000644000175000017500000000357613107004621022226 0ustar jromanjroman NEPNLEIGSGetLocking

slepc-3.7.4 2017-05-17

NEPNLEIGSGetLocking

Gets the locking flag used in the NLEIGS method.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSGetLocking(NEP nep,PetscBool *lock)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

lock  - the locking flag

See Also

NEPNLEIGSSetLocking()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetOptionsPrefix.html0000644000175000017500000000511413107004621022551 0ustar jromanjroman NEPSetOptionsPrefix

slepc-3.7.4 2017-05-17

NEPSetOptionsPrefix

Sets the prefix used for searching for all NEP options in the database.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetOptionsPrefix(NEP nep,const char *prefix)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
prefix  - the prefix string to prepend to all NEP option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

For example, to distinguish between the runtime options for two different NEP contexts, one could call

      NEPSetOptionsPrefix(nep1,"neig1_")
      NEPSetOptionsPrefix(nep2,"neig2_")

See Also

NEPAppendOptionsPrefix(), NEPGetOptionsPrefix()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPCISSSetSizes.html0000644000175000017500000000752613107004621021530 0ustar jromanjroman NEPCISSSetSizes

slepc-3.7.4 2017-05-17

NEPCISSSetSizes

Sets the values of various size parameters in the CISS solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPCISSSetSizes(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)
Logically Collective on NEP

Input Parameters

nep  - the eigenproblem solver context
ip  - number of integration points
bs  - block size
ms  - moment size
npart  - number of partitions when splitting the communicator
bsmax  - max block size
realmats  - T(z) is real for real z

Options Database Keys

-nep_ciss_integration_points  - Sets the number of integration points
-nep_ciss_blocksize  - Sets the block size
-nep_ciss_moments  - Sets the moment size
-nep_ciss_partitions  - Sets the number of partitions
-nep_ciss_maxblocksize  - Sets the maximum block size
-nep_ciss_realmats  - T(z) is real for real z

Note

The default number of partitions is 1. This means the internal KSP object is shared among all processes of the NEP communicator. Otherwise, the communicator is split into npart communicators, so that npart KSP solves proceed simultaneously.

The realmats flag can be set to true when T(.) is guaranteed to be real when the argument is a real value, for example, when all matrices in the split form are real. When set to true, the solver avoids some computations.

See Also

NEPCISSGetSizes()

Location: src/nep/impls/ciss/nciss.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRIISetConstCorrectionTol.html0000644000175000017500000000466213107004621024110 0ustar jromanjroman NEPRIISetConstCorrectionTol

slepc-3.7.4 2017-05-17

NEPRIISetConstCorrectionTol

Sets a flag to keep the tolerance used in the linear solver constant.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIISetConstCorrectionTol(NEP nep,PetscBool cct)
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigenvalue solver
cct  - a boolean value

Options Database Keys

-nep_rii_const_correction_tol <bool>  - set the boolean flag

Notes

By default, an exponentially decreasing tolerance is set in the KSP used within the nonlinear iteration, so that each Newton iteration requests better accuracy than the previous one. The constant correction tolerance flag stops this behaviour.

See Also

NEPRIIGetConstCorrectionTol()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNArnoldiGetKSP.html0000644000175000017500000000362613107004621022016 0ustar jromanjroman NEPNArnoldiGetKSP

slepc-3.7.4 2017-05-17

NEPNArnoldiGetKSP

Retrieve the linear solver object (KSP) associated with the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNArnoldiGetKSP(NEP nep,KSP *ksp)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

ksp  - the linear solver object

See Also

NEPNArnoldiSetKSP()

Location: src/nep/impls/narnoldi/narnoldi.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetMonitorContext.html0000644000175000017500000000401113107004621022713 0ustar jromanjroman NEPGetMonitorContext

slepc-3.7.4 2017-05-17

NEPGetMonitorContext

Gets the monitor context, as set by NEPMonitorSet() for the FIRST monitor only.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetMonitorContext(NEP nep,void **ctx)
Not Collective

Input Parameter

nep  - eigensolver context obtained from NEPCreate()

Output Parameter

ctx  - monitor context

See Also

NEPMonitorSet(), NEPDefaultMonitor()

Location: src/nep/interface/nepmon.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRIIGetLagPreconditioner.html0000644000175000017500000000365313107004621023706 0ustar jromanjroman NEPRIIGetLagPreconditioner

slepc-3.7.4 2017-05-17

NEPRIIGetLagPreconditioner

Indicates how often the preconditioner is rebuilt.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIIGetLagPreconditioner(NEP nep,PetscInt *lag)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

lag  - the lag parameter

See Also

NEPRIISetLagPreconditioner()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetRefine.html0000644000175000017500000000517213107004621021140 0ustar jromanjroman NEPGetRefine

slepc-3.7.4 2017-05-17

NEPGetRefine

Gets the refinement strategy used by the NEP object, and the associated parameters.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetRefine(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

refine  - refinement type
npart  - number of partitions of the communicator
tol  - the convergence tolerance
its  - maximum number of refinement iterations
scheme  - the scheme used for solving linear systems

Note

The user can specify NULL for any parameter that is not needed.

See Also

NEPSetRefine()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPInterpolGetPEP.html0000644000175000017500000000374113107004621022071 0ustar jromanjroman NEPInterpolGetPEP

slepc-3.7.4 2017-05-17

NEPInterpolGetPEP

Retrieve the polynomial eigensolver object (PEP) associated with the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
#include "slepcpep.h" 
PetscErrorCode NEPInterpolGetPEP(NEP nep,PEP *pep)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

pep  - the polynomial eigensolver object

See Also

NEPInterpolSetPEP()

Location: src/nep/impls/interpol/interpol.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetDerivatives.html0000644000175000017500000000504113107004621022224 0ustar jromanjroman NEPSetDerivatives

slepc-3.7.4 2017-05-17

NEPSetDerivatives

Sets the function to compute the k-th derivative T^(k)(lambda) for any value of k (including 0), as well as the location to store the matrix.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetDerivatives(NEP nep,Mat A,PetscErrorCode (*der)(NEP,PetscScalar,PetscInt,Mat,void*),void *ctx)
Logically Collective on NEP and Mat

Input Parameters

nep  - the NEP context
A  - the matrix to store the computed derivative
der  - routing to evaluate the k-th derivative (if NULL then NEP retains any previously set value)
ctx  - [optional] user-defined context for private data for the derivatives evaluation routine (may be NULL) (if NULL then NEP retains any previously set value)

See Also

NEPSetFunction(), NEPGetDerivatives()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetSplitOperatorTerm.html0000644000175000017500000000463113107004621023366 0ustar jromanjroman NEPGetSplitOperatorTerm

slepc-3.7.4 2017-05-17

NEPGetSplitOperatorTerm

Gets the matrices and functions associated with the nonlinear operator in split form.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetSplitOperatorTerm(NEP nep,PetscInt k,Mat *A,FN *f)
Not collective, though parallel Mats and FNs are returned if the NEP is parallel

Input Parameter

nep  - the nonlinear eigensolver context
k  - the index of the requested term (starting in 0)

Output Parameters

A  - the matrix of the requested term
f  - the function of the requested term

See Also

NEPSetSplitOperator(), NEPGetSplitOperatorInfo()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRIIGetMaximumIterations.html0000644000175000017500000000366313107004621023756 0ustar jromanjroman NEPRIIGetMaximumIterations

slepc-3.7.4 2017-05-17

NEPRIIGetMaximumIterations

Gets the maximum number of inner iterations of RII.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIIGetMaximumIterations(NEP nep,PetscInt *its)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

its  - maximum inner iterations

See Also

NEPRIISetMaximumIterations()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPMonitorAll.html0000644000175000017500000000542313107004621021347 0ustar jromanjroman NEPMonitorAll

slepc-3.7.4 2017-05-17

NEPMonitorAll

Print the current approximate values and error estimates at each iteration of the nonlinear eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPMonitorAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

NEPMonitorSet(), NEPMonitorFirst(), NEPMonitorConverged()

Location: src/nep/interface/nepmon.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPCISSGetSizes.html0000644000175000017500000000475513107004621021515 0ustar jromanjroman NEPCISSGetSizes

slepc-3.7.4 2017-05-17

NEPCISSGetSizes

Gets the values of various size parameters in the CISS solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPCISSGetSizes(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)
Not Collective

Input Parameter

nep  - the eigenproblem solver context

Output Parameters

ip  - number of integration points
bs  - block size
ms  - moment size
npart  - number of partitions when splitting the communicator
bsmax  - max block size
realmats  - T(z) is real for real z

See Also

NEPCISSSetSizes()

Location: src/nep/impls/ciss/nciss.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetJacobian.html0000644000175000017500000000446713107004621021444 0ustar jromanjroman NEPGetJacobian

slepc-3.7.4 2017-05-17

NEPGetJacobian

Returns the Jacobian matrix and optionally the user provided routine and context for evaluating the Jacobian.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetJacobian(NEP nep,Mat *A,PetscErrorCode (**jac)(NEP,PetscScalar,Mat,void*),void **ctx)
Not Collective, but Mat object will be parallel if NEP object is

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

A  - location to stash Jacobian matrix (or NULL)
jac  - location to put Jacobian function (or NULL)
ctx  - location to stash Jacobian context (or NULL)

See Also

NEPSetJacobian()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSLPGetEPS.html0000644000175000017500000000357013107004621020736 0ustar jromanjroman NEPSLPGetEPS

slepc-3.7.4 2017-05-17

NEPSLPGetEPS

Retrieve the linear eigensolver object (EPS) associated to the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSLPGetEPS(NEP nep,EPS *eps)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

eps  - the eigensolver object

See Also

NEPSLPSetEPS()

Location: src/nep/impls/slp/slp.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetDimensions.html0000644000175000017500000000701313107004621022050 0ustar jromanjroman NEPSetDimensions

slepc-3.7.4 2017-05-17

NEPSetDimensions

Sets the number of eigenvalues to compute and the dimension of the subspace.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetDimensions(NEP nep,PetscInt nev,PetscInt ncv,PetscInt mpd)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

Options Database Keys

-nep_nev <nev>  - Sets the number of eigenvalues
-nep_ncv <ncv>  - Sets the dimension of the subspace
-nep_mpd <mpd>  - Sets the maximum projected dimension

Notes

Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method.

The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and (b) in cases where nev is large, the user sets mpd.

The value of ncv should always be between nev and (nev+mpd), typically ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise a smaller value should be used.

See Also

NEPGetDimensions()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex22.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPRIISetLagPreconditioner.html0000644000175000017500000000515613107004621023722 0ustar jromanjroman NEPRIISetLagPreconditioner
slepc-3.7.4 2017-05-17

NEPRIISetLagPreconditioner

Determines when the preconditioner is rebuilt in the nonlinear solve.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIISetLagPreconditioner(NEP nep,PetscInt lag)
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigenvalue solver
lag  - 0 indicates NEVER rebuild, 1 means rebuild every time the Jacobian is computed within the nonlinear iteration, 2 means every second time the Jacobian is built, etc.

Options Database Keys

-nep_rii_lag_preconditioner <lag> - Notes: The default is 1. The preconditioner is ALWAYS built in the first iteration of a nonlinear solve.

See Also

NEPRIIGetLagPreconditioner()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPSetConvergenceTestFunction.html0000644000175000017500000000750013107004621024545 0ustar jromanjroman NEPSetConvergenceTestFunction
slepc-3.7.4 2017-05-17

NEPSetConvergenceTestFunction

Sets a function to compute the error estimate used in the convergence test.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetConvergenceTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context obtained from NEPCreate()
func  - a pointer to the convergence test function
ctx  - context for private data for the convergence routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)

nep  - nonlinear eigensolver context obtained from NEPCreate()
eigr  - real part of the eigenvalue
eigi  - imaginary part of the eigenvalue
res  - residual norm associated to the eigenpair
errest  - (output) computed error estimate
ctx  - optional context, as set by NEPSetConvergenceTestFunction()

Note

If the error estimate returned by the convergence test function is less than the tolerance, then the eigenvalue is accepted as converged.

See Also

NEPSetConvergenceTest(), NEPSetTolerances()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPComputeError.html0000644000175000017500000000523413107004621021715 0ustar jromanjroman NEPComputeError

slepc-3.7.4 2017-05-17

NEPComputeError

Computes the error (based on the residual norm) associated with the i-th computed eigenpair.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPComputeError(NEP nep,PetscInt i,NEPErrorType type,PetscReal *error)
Collective on NEP

Input Parameter

nep  - the nonlinear eigensolver context
i  - the solution index
type  - the type of error to compute

Output Parameter

error  - the error

Notes

The error can be computed in various ways, all of them based on the residual norm computed as ||T(lambda)x||_2 where lambda is the eigenvalue and x is the eigenvector.

See Also

NEPErrorType, NEPSolve(), NEPGetErrorEstimate()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPComputeJacobian.html0000644000175000017500000000455113107004621022333 0ustar jromanjroman NEPComputeJacobian
slepc-3.7.4 2017-05-17

NEPComputeJacobian

Computes the Jacobian matrix T'(lambda) that has been set with NEPSetJacobian().

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPComputeJacobian(NEP nep,PetscScalar lambda,Mat A)
Collective on NEP and Mat

Input Parameters

nep  - the NEP context
lambda  - the scalar argument

Output Parameters

A  - Jacobian matrix

Notes

Most users should not need to explicitly call this routine, as it is used internally within the nonlinear eigensolvers.

See Also

NEPSetJacobian(), NEPGetJacobian()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetWhichEigenpairs.html0000644000175000017500000001356613107004621023023 0ustar jromanjroman NEPSetWhichEigenpairs

slepc-3.7.4 2017-05-17

NEPSetWhichEigenpairs

Specifies which portion of the spectrum is to be sought.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetWhichEigenpairs(NEP nep,NEPWhich which)
Logically Collective on NEP

Input Parameters

nep  - eigensolver context obtained from NEPCreate()
which  - the portion of the spectrum to be sought

Possible values

The parameter 'which' can have one of these values

NEP_LARGEST_MAGNITUDE  - largest eigenvalues in magnitude (default)
NEP_SMALLEST_MAGNITUDE  - smallest eigenvalues in magnitude
NEP_LARGEST_REAL  - largest real parts
NEP_SMALLEST_REAL  - smallest real parts
NEP_LARGEST_IMAGINARY  - largest imaginary parts
NEP_SMALLEST_IMAGINARY  - smallest imaginary parts
NEP_TARGET_MAGNITUDE  - eigenvalues closest to the target (in magnitude)
NEP_TARGET_REAL  - eigenvalues with real part closest to target
NEP_TARGET_IMAGINARY  - eigenvalues with imaginary part closest to target
NEP_ALL  - all eigenvalues contained in a given region
NEP_WHICH_USER  - user defined ordering set with NEPSetEigenvalueComparison()

Options Database Keys

-nep_largest_magnitude  - Sets largest eigenvalues in magnitude
-nep_smallest_magnitude  - Sets smallest eigenvalues in magnitude
-nep_largest_real  - Sets largest real parts
-nep_smallest_real  - Sets smallest real parts
-nep_largest_imaginary  - Sets largest imaginary parts
-nep_smallest_imaginary  - Sets smallest imaginary parts
-nep_target_magnitude  - Sets eigenvalues closest to target
-nep_target_real  - Sets real parts closest to target
-nep_target_imaginary  - Sets imaginary parts closest to target
-nep_all  - Sets all eigenvalues in a region

Notes

Not all eigensolvers implemented in NEP account for all the possible values stated above. If SLEPc is compiled for real numbers NEP_LARGEST_IMAGINARY and NEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part for eigenvalue selection.

The target is a scalar value provided with NEPSetTarget().

NEP_ALL is intended for use in the context of the CISS solver for computing all eigenvalues in a region.

See Also

NEPGetWhichEigenpairs(), NEPSetTarget(), NEPSetEigenvalueComparison(), NEPWhich

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPStoppingBasic.html0000644000175000017500000000674613107004621022045 0ustar jromanjroman NEPStoppingBasic

slepc-3.7.4 2017-05-17

NEPStoppingBasic

Default routine to determine whether the outer eigensolver iteration must be stopped.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPStoppingBasic(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)
Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context obtained from NEPCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged eigenpairs
nev  - number of requested eigenpairs
ctx  - context (not used here)

Output Parameter

reason  - result of the stopping test

Notes

A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to NEP_CONVERGED_ITERATING (zero).

NEPStoppingBasic() will stop if all requested eigenvalues are converged, or if the maximum number of iterations has been reached.

Use NEPSetStoppingTest() to provide your own test instead of using this one.

See Also

NEPSetStoppingTest(), NEPConvergedReason, NEPGetConvergedReason()

Location: src/nep/interface/nepdefault.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRIISetMaximumIterations.html0000644000175000017500000000374513107004621023773 0ustar jromanjroman NEPRIISetMaximumIterations

slepc-3.7.4 2017-05-17

NEPRIISetMaximumIterations

Sets the maximum number of inner iterations to be used in the RII solver. These are the Newton iterations related to the computation of the nonlinear Rayleigh functional.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIISetMaximumIterations(NEP nep,PetscInt its)
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigenvalue solver
its  - maximum inner iterations

See Also

NEPRIIGetMaximumIterations()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPMonitorCancel.html0000644000175000017500000000421413107004621022021 0ustar jromanjroman NEPMonitorCancel

slepc-3.7.4 2017-05-17

NEPMonitorCancel

Clears all monitors for a NEP object.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPMonitorCancel(NEP nep)
Logically Collective on NEP

Input Parameters

nep  - eigensolver context obtained from NEPCreate()

Options Database Key

-nep_monitor_cancel  - Cancels all monitors that have been hardwired into a code by calls to NEPMonitorSet(), but does not cancel those set via the options database.

See Also

NEPMonitorSet()

Location: src/nep/interface/nepmon.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetType.html0000644000175000017500000000453713107004621020655 0ustar jromanjroman NEPGetType

slepc-3.7.4 2017-05-17

NEPGetType

Gets the NEP type as a string from the NEP object.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetType(NEP nep,NEPType *type)
Not Collective

Input Parameter

nep  - the eigensolver context

Output Parameter

name  - name of NEP method

See Also

NEPSetType()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPErrorView.html0000644000175000017500000000670213107004621021214 0ustar jromanjroman NEPErrorView
slepc-3.7.4 2017-05-17

NEPErrorView

Displays the errors associated with the computed solution (as well as the eigenvalues).

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPErrorView(NEP nep,NEPErrorType etype,PetscViewer viewer)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
etype  - error type
viewer  - optional visualization context

Options Database Key

-nep_error_absolute  - print absolute errors of each eigenpair
-nep_error_relative  - print relative errors of each eigenpair
-nep_error_backward  - print backward errors of each eigenpair

Notes

By default, this function checks the error of all eigenpairs and prints the eigenvalues if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with eigenvalues and corresponding errors is printed.

See Also

NEPSolve(), NEPValuesView(), NEPVectorsView()

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetRG.html0000644000175000017500000000377213107004621020244 0ustar jromanjroman NEPGetRG
slepc-3.7.4 2017-05-17

NEPGetRG

Obtain the region object associated to the nonlinear eigensolver object.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetRG(NEP nep,RG *rg)
Not Collective

Input Parameters

nep  - eigensolver context obtained from NEPCreate()

Output Parameter

rg  - region context

See Also

NEPSetRG()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPValuesView.html0000644000175000017500000000415513107004621021362 0ustar jromanjroman NEPValuesView
slepc-3.7.4 2017-05-17

NEPValuesView

Displays the computed eigenvalues in a viewer.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPValuesView(NEP nep,PetscViewer viewer)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
viewer  - the viewer

Options Database Key

-nep_view_values  - print computed eigenvalues

See Also

NEPSolve(), NEPVectorsView(), NEPErrorView()

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPType.html0000644000175000017500000000303213107004621020202 0ustar jromanjroman NEPType

slepc-3.7.4 2017-05-17

NEPType

String with the name of a nonlinear eigensolver

Synopsis

typedef const char* NEPType;
#define NEPRII       "rii"
#define NEPSLP       "slp"
#define NEPNARNOLDI  "narnoldi"
#define NEPCISS      "ciss"
#define NEPINTERPOL  "interpol"
#define NEPNLEIGS    "nleigs"

See Also

NEPSetType(), NEP

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRefineScheme.html0000644000175000017500000000300713107004621021620 0ustar jromanjroman NEPRefineScheme

slepc-3.7.4 2017-05-17

NEPRefineScheme

The scheme used for solving linear systems during iterative refinement

Synopsis

typedef enum { NEP_REFINE_SCHEME_SCHUR=1,
               NEP_REFINE_SCHEME_MBE,
               NEP_REFINE_SCHEME_EXPLICIT } NEPRefineScheme;

See Also

NEPSetRefine()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSGetRestart.html0000644000175000017500000000361013107004621022251 0ustar jromanjroman NEPNLEIGSGetRestart

slepc-3.7.4 2017-05-17

NEPNLEIGSGetRestart

Gets the restart parameter used in the NLEIGS method.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSGetRestart(NEP nep,PetscReal *keep)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

keep  - the restart parameter

See Also

NEPNLEIGSSetRestart()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSSetRKShifts.html0000644000175000017500000000520413107004621022337 0ustar jromanjroman NEPNLEIGSSetRKShifts

slepc-3.7.4 2017-05-17

NEPNLEIGSSetRKShifts

Sets a list of shifts to be used in the Rational Krylov method.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSSetRKShifts(NEP nep,PetscInt ns,PetscScalar *shifts)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
ns  - number of shifts
shifts  - array of scalar values specifying the shifts

Options Database Key

-nep_nleigs_rk_shifts  - Sets the list of shifts

Notes

If only one shift is provided, the subspace is built with the simpler shift-and-invert Krylov-Schur.

In the case of real scalars, complex shifts are not allowed. In the command line, a comma-separated list of complex values can be provided with the format [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -nep_nleigs_rk_shifts 1.0+2.0i,1.5+2.0i,1.0+1.5i

See Also

NEPNLEIGSGetRKShifts()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetBV.html0000644000175000017500000000355513107004621020242 0ustar jromanjroman NEPGetBV

slepc-3.7.4 2017-05-17

NEPGetBV

Obtain the basis vectors object associated to the nonlinear eigensolver object.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetBV(NEP nep,BV *bv)
Not Collective

Input Parameters

nep  - eigensolver context obtained from NEPCreate()

Output Parameter

bv  - basis vectors context

See Also

NEPSetBV()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSSetSingularitiesFunction.html0000644000175000017500000000717213107004621025200 0ustar jromanjroman NEPNLEIGSSetSingularitiesFunction

slepc-3.7.4 2017-05-17

NEPNLEIGSSetSingularitiesFunction

Sets a user function to compute a discretization of the singularity set (where T(.) is not analytic).

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx)
Logically Collective on NEP

Input Parameters

nep  - the NEP context
fun  - user function (if NULL then NEP retains any previously set value)
ctx  - [optional] user-defined context for private data for the function (may be NULL, in which case NEP retains any previously set value)

Calling Sequence of fun

  fun(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *ctx)

nep  - the NEP context
maxnp  - on input number of requested points in the discretization (can be set)
xi  - computed values of the discretization
ctx  - optional context, as set by NEPNLEIGSSetSingularitiesFunction()

Note

The user-defined function can set a smaller value of maxnp if necessary.

See Also

NEPNLEIGSGetSingularitiesFunction()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPApplyFunction.html0000644000175000017500000000601213107004621022055 0ustar jromanjroman NEPApplyFunction
slepc-3.7.4 2017-05-17

NEPApplyFunction

Applies the nonlinear function T(lambda) to a given vector.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPApplyFunction(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A,Mat B)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
lambda  - scalar argument
x  - vector to be multiplied against
v  - workspace vector (used only in the case of split form)

Output Parameters

y  - result vector
A  - Function matrix
B  - optional preconditioning matrix

Note

If the nonlinear operator is represented in split form, the result y = T(lambda)*x is computed without building T(lambda) explicitly. In that case, parameters A and B are not used. Otherwise, the matrix T(lambda) is built and the effect is the same as a call to NEPComputeFunction() followed by a MatMult().

See Also

NEPSetSplitOperator(), NEPComputeFunction()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetTrackAll.html0000644000175000017500000000355313107004621021426 0ustar jromanjroman NEPGetTrackAll

slepc-3.7.4 2017-05-17

NEPGetTrackAll

Returns the flag indicating whether all residual norms must be computed or not.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetTrackAll(NEP nep,PetscBool *trackall)
Not Collective

Input Parameter

nep  - the eigensolver context

Output Parameter

trackall  - the returned flag

See Also

NEPSetTrackAll()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSSetInterpolation.html0000644000175000017500000000522313107004621023472 0ustar jromanjroman NEPNLEIGSSetInterpolation

slepc-3.7.4 2017-05-17

NEPNLEIGSSetInterpolation

Sets the tolerance and maximum iteration count used by the NLEIGS method when building the interpolation via divided differences.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSSetInterpolation(NEP nep,PetscReal tol,PetscInt maxits)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
tol  - the convergence tolerance
maxits  - maximum number of iterations to use

Options Database Key

-nep_nleigs_interpolation_tol <tol>  - Sets the convergence tolerance
-nep_nleigs_interpolation_max_it <maxits>  - Sets the maximum number of iterations

Notes

Use PETSC_DEFAULT for either argument to assign a reasonably good value.

See Also

NEPNLEIGSGetInterpolation()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPConvergedReason.html0000644000175000017500000000376513107004621022362 0ustar jromanjroman NEPConvergedReason

slepc-3.7.4 2017-05-17

NEPConvergedReason

Reason a nonlinear eigensolver was said to have converged or diverged

Synopsis

typedef enum {/* converged */
              NEP_CONVERGED_TOL                =  1,
              NEP_CONVERGED_USER               =  2,
              /* diverged */
              NEP_DIVERGED_ITS                 = -1,
              NEP_DIVERGED_BREAKDOWN           = -2,
                    /* unused                  = -3 */
              NEP_DIVERGED_LINEAR_SOLVE        = -4,
              NEP_CONVERGED_ITERATING          =  0} NEPConvergedReason;

See Also

NEPSolve(), NEPGetConvergedReason(), NEPSetTolerances()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetStoppingTestFunction.html0000644000175000017500000001023413107004621024110 0ustar jromanjroman NEPSetStoppingTestFunction

slepc-3.7.4 2017-05-17

NEPSetStoppingTestFunction

Sets a function to decide when to stop the outer iteration of the eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetStoppingTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context obtained from NEPCreate()
func  - pointer to the stopping test function
ctx  - context for private data for the stopping routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)

nep  - nonlinear eigensolver context obtained from NEPCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged eigenpairs
nev  - number of requested eigenpairs
reason  - (output) result of the stopping test
ctx  - optional context, as set by NEPSetStoppingTestFunction()

Note

Normal usage is to first call the default routine NEPStoppingBasic() and then set reason to NEP_CONVERGED_USER if some user-defined conditions have been met. To let the eigensolver continue iterating, the result must be left as NEP_CONVERGED_ITERATING.

See Also

NEPSetStoppingTest(), NEPStoppingBasic()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPReasonView.html0000644000175000017500000000551413107004621021352 0ustar jromanjroman NEPReasonView

slepc-3.7.4 2017-05-17

NEPReasonView

Displays the reason a NEP solve converged or diverged.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPReasonView(NEP nep,PetscViewer viewer)
Collective on NEP

Parameter

nep  - the nonlinear eigensolver context
viewer  - the viewer to display the reason

Options Database Keys

-nep_converged_reason  - print reason for convergence, and number of iterations

See Also

NEPSetConvergenceTest(), NEPSetTolerances(), NEPGetIterationNumber()

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetDerivatives.html0000644000175000017500000000455613107004621022222 0ustar jromanjroman NEPGetDerivatives
slepc-3.7.4 2017-05-17

NEPGetDerivatives

Returns the derivatives matrix and optionally the user provided routine and context for evaluating the derivatives.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetDerivatives(NEP nep,Mat *A,PetscErrorCode (**der)(NEP,PetscScalar,PetscInt,Mat,void*),void **ctx)
Not Collective, but Mat object will be parallel if NEP object is

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

A  - location to stash the derivatives matrix (or NULL)
der  - location to put derivatives function (or NULL)
ctx  - location to stash derivatives context (or NULL)

See Also

NEPSetDerivatives()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRegisterAll.html0000644000175000017500000000261013107004621021477 0ustar jromanjroman NEPRegisterAll

slepc-3.7.4 2017-05-17

NEPRegisterAll

Registers all the solvers in the NEP package.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRegisterAll(void)
Not Collective

See Also

NEPRegister()

Location: src/nep/interface/nepregis.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetFunction.html0000644000175000017500000000761613107004621021536 0ustar jromanjroman NEPSetFunction

slepc-3.7.4 2017-05-17

NEPSetFunction

Sets the function to compute the nonlinear Function T(lambda) as well as the location to store the matrix.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetFunction(NEP nep,Mat A,Mat B,PetscErrorCode (*fun)(NEP,PetscScalar,Mat,Mat,void*),void *ctx)
Logically Collective on NEP and Mat

Input Parameters

nep  - the NEP context
A  - Function matrix
B  - preconditioner matrix (usually same as the Function)
fun  - Function evaluation routine (if NULL then NEP retains any previously set value)
ctx  - [optional] user-defined context for private data for the Function evaluation routine (may be NULL) (if NULL then NEP retains any previously set value)

Calling Sequence of fun

  fun(NEP nep,PetscScalar lambda,Mat F,Mat P,void *ctx)

nep  - the NEP context
lambda  - the scalar argument where T(.) must be evaluated
T  - matrix that will contain T(lambda)
P  - (optional) different matrix to build the preconditioner
ctx  - (optional) user-defined context, as set by NEPSetFunction()

See Also

NEPGetFunction(), NEPSetJacobian()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPRefineGetKSP.html0000644000175000017500000000363213107004621021515 0ustar jromanjroman NEPRefineGetKSP
slepc-3.7.4 2017-05-17

NEPRefineGetKSP

Obtain the ksp object used by the eigensolver object in the refinement phase.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRefineGetKSP(NEP nep,KSP *ksp)
Not Collective

Input Parameters

nep  - eigensolver context obtained from NEPCreate()

Output Parameter

ksp  - ksp context

See Also

NEPSetRefine()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetFromOptions.html0000644000175000017500000000472613107004621022227 0ustar jromanjroman NEPSetFromOptions

slepc-3.7.4 2017-05-17

NEPSetFromOptions

Sets NEP options from the options database. This routine must be called before NEPSetUp() if the user is to be allowed to set the solver type.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetFromOptions(NEP nep)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context

Notes

To see all options, run your program with the -help option.

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPSetInitialSpace.html0000644000175000017500000000512113107004621022303 0ustar jromanjroman NEPSetInitialSpace
slepc-3.7.4 2017-05-17

NEPSetInitialSpace

Specify a basis of vectors that constitute the initial space, that is, the subspace from which the solver starts to iterate.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetInitialSpace(NEP nep,PetscInt n,Vec *is)
Collective on NEP and Vec

Input Parameter

nep  - the nonlinear eigensolver context
n  - number of vectors
is  - set of basis vectors of the initial space

Notes

Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored.

These vectors do not persist from one NEPSolve() call to the other, so the initial space should be set every time.

The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally.

Common usage of this function is when the user can provide a rough approximation of the wanted eigenspace. Then, convergence may be faster.

Location: src/nep/interface/nepsetup.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPSetRG.html0000644000175000017500000000370613107004621020255 0ustar jromanjroman NEPSetRG
slepc-3.7.4 2017-05-17

NEPSetRG

Associates a region object to the nonlinear eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetRG(NEP nep,RG rg)
Collective on NEP

Input Parameters

nep  - eigensolver context obtained from NEPCreate()
rg  - the region object

Note

Use NEPGetRG() to retrieve the region context (for example, to free it at the end of the computations).

See Also

NEPGetRG()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPCISSSetThreshold.html0000644000175000017500000000455113107004621022362 0ustar jromanjroman NEPCISSSetThreshold

slepc-3.7.4 2017-05-17

NEPCISSSetThreshold

Sets the values of various threshold parameters in the CISS solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPCISSSetThreshold(NEP nep,PetscReal delta,PetscReal spur)
Logically Collective on NEP

Input Parameters

nep  - the eigenproblem solver context
delta  - threshold for numerical rank
spur  - spurious threshold (to discard spurious eigenpairs)

Options Database Keys

-nep_ciss_delta  - Sets the delta
-nep_ciss_spurious_threshold  - Sets the spurious threshold

See Also

NEPCISSGetThreshold()

Location: src/nep/impls/ciss/nciss.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSolve.html0000644000175000017500000000672113107004621020361 0ustar jromanjroman NEPSolve

slepc-3.7.4 2017-05-17

NEPSolve

Solves the nonlinear eigensystem.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSolve(NEP nep)
Collective on NEP

Input Parameter

nep  - eigensolver context obtained from NEPCreate()

Options Database Keys

-nep_view  - print information about the solver used
-nep_view_vectors binary  - save the computed eigenvectors to the default binary viewer
-nep_view_values  - print computed eigenvalues
-nep_converged_reason  - print reason for convergence, and number of iterations
-nep_error_absolute  - print absolute errors of each eigenpair
-nep_error_relative  - print relative errors of each eigenpair

See Also

NEPCreate(), NEPSetUp(), NEPDestroy(), NEPSetTolerances()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPRefine.html0000644000175000017500000000261713107004621020501 0ustar jromanjroman NEPRefine
slepc-3.7.4 2017-05-17

NEPRefine

The refinement type

Synopsis

typedef enum { NEP_REFINE_NONE,
               NEP_REFINE_SIMPLE,
               NEP_REFINE_MULTIPLE } NEPRefine;

See Also

NEPSetRefine()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPInterpolGetDegree.html0000644000175000017500000000364213107004621022640 0ustar jromanjroman NEPInterpolGetDegree

slepc-3.7.4 2017-05-17

NEPInterpolGetDegree

Gets the degree of the interpolation polynomial.

Synopsis

#include "slepcnep.h" 
#include "slepcpep.h" 
PetscErrorCode NEPInterpolGetDegree(NEP nep,PetscInt *deg)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

deg  - the polynomial degree

See Also

NEPInterpolSetDegree()

Location: src/nep/impls/interpol/interpol.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPReasonViewFromOptions.html0000644000175000017500000000321713107004621023550 0ustar jromanjroman NEPReasonViewFromOptions

slepc-3.7.4 2017-05-17

NEPReasonViewFromOptions

Processes command line options to determine if/how the NEP converged reason is to be viewed.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPReasonViewFromOptions(NEP nep)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPInterpolSetDegree.html0000644000175000017500000000351713107004621022655 0ustar jromanjroman NEPInterpolSetDegree

slepc-3.7.4 2017-05-17

NEPInterpolSetDegree

Sets the degree of the interpolation polynomial.

Synopsis

#include "slepcnep.h" 
#include "slepcpep.h" 
PetscErrorCode NEPInterpolSetDegree(NEP nep,PetscInt deg)
Collective on NEP

Input Parameters

nep  - nonlinear eigenvalue solver
deg  - polynomial degree

See Also

NEPInterpolGetDegree()

Location: src/nep/impls/interpol/interpol.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetUp.html0000644000175000017500000000401613107004621020324 0ustar jromanjroman NEPSetUp

slepc-3.7.4 2017-05-17

NEPSetUp

Sets up all the internal data structures necessary for the execution of the NEP solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetUp(NEP nep)
Collective on NEP

Input Parameter

nep  - solver context

Notes

This function need not be called explicitly in most cases, since NEPSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time.

See Also

NEPCreate(), NEPSolve(), NEPDestroy()

Location: src/nep/interface/nepsetup.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRIIGetConstCorrectionTol.html0000644000175000017500000000367613107004621024100 0ustar jromanjroman NEPRIIGetConstCorrectionTol

slepc-3.7.4 2017-05-17

NEPRIIGetConstCorrectionTol

Returns the constant tolerance flag.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIIGetConstCorrectionTol(NEP nep,PetscBool *cct)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

cct  - the value of the constant tolerance flag

See Also

NEPRIISetConstCorrectionTol()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetDS.html0000644000175000017500000000355513107004621020241 0ustar jromanjroman NEPGetDS

slepc-3.7.4 2017-05-17

NEPGetDS

Obtain the direct solver object associated to the nonlinear eigensolver object.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetDS(NEP nep,DS *ds)
Not Collective

Input Parameters

nep  - eigensolver context obtained from NEPCreate()

Output Parameter

ds  - direct solver context

See Also

NEPSetDS()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPConv.html0000644000175000017500000000305513107004621020173 0ustar jromanjroman NEPConv

slepc-3.7.4 2017-05-17

NEPConv

Determines the convergence test

Synopsis

typedef enum { NEP_CONV_ABS,
               NEP_CONV_REL,
               NEP_CONV_NORM,
               NEP_CONV_USER } NEPConv;

See Also

NEPSetConvergenceTest(), NEPSetConvergenceTestFunction()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEP.html0000644000175000017500000000374313107004621017351 0ustar jromanjroman NEP

slepc-3.7.4 2017-05-17

NEP

Abstract SLEPc object that manages all solvers for nonlinear eigenvalue problems.

Synopsis

typedef struct _p_NEP* NEP;

See Also

NEPCreate()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex6f.F.html
src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSGetKSPs.html0000644000175000017500000000341013107004621021443 0ustar jromanjroman NEPNLEIGSGetKSPs
slepc-3.7.4 2017-05-17

NEPNLEIGSGetKSPs

Retrieve the array of linear solver objects associated with the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSGetKSPs(NEP nep,KSP **ksp)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

ksp  - array of linear solver object

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetEigenvalueComparison.html0000644000175000017500000000766013107004621024067 0ustar jromanjroman NEPSetEigenvalueComparison

slepc-3.7.4 2017-05-17

NEPSetEigenvalueComparison

Specifies the eigenvalue comparison function when NEPSetWhichEigenpairs() is set to NEP_WHICH_USER.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetEigenvalueComparison(NEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)
Logically Collective on NEP

Input Parameters

pep  - eigensolver context obtained from NEPCreate()
func  - a pointer to the comparison function
ctx  - a context pointer (the last parameter to the comparison function)

Calling Sequence of func

  func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx)

ar  - real part of the 1st eigenvalue
ai  - imaginary part of the 1st eigenvalue
br  - real part of the 2nd eigenvalue
bi  - imaginary part of the 2nd eigenvalue
res  - result of comparison
ctx  - optional context, as set by NEPSetEigenvalueComparison()

Note

The returning parameter 'res' can be
negative  - if the 1st eigenvalue is preferred to the 2st one
zero  - if both eigenvalues are equally preferred
positive  - if the 2st eigenvalue is preferred to the 1st one

See Also

NEPSetWhichEigenpairs(), NEPWhich

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetWorkVecs.html0000644000175000017500000000353613107004621021511 0ustar jromanjroman NEPSetWorkVecs

slepc-3.7.4 2017-05-17

NEPSetWorkVecs

Sets a number of work vectors into a NEP object

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetWorkVecs(NEP nep,PetscInt nw)
Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context
nw  - number of work vectors to allocate

Developers Note

This is PETSC_EXTERN because it may be required by user plugin NEP implementations.

Location: src/nep/interface/nepdefault.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPMonitorLGCreate.html0000644000175000017500000000600213107004621022257 0ustar jromanjroman NEPMonitorLGCreate

slepc-3.7.4 2017-05-17

NEPMonitorLGCreate

Creates a line graph context for use with NEP to monitor convergence.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
Collective on MPI_Comm

Input Parameters

comm  - communicator context
host  - the X display to open, or null for the local machine
label  - the title to put in the title bar
x, y  - the screen coordinates of the upper left coordinate of the window
m, n  - the screen width and height in pixels

Output Parameter

lgctx  - the drawing context

Options Database Keys

-nep_monitor_lg  - Sets line graph monitor for the first residual
-nep_monitor_lg_all  - Sets line graph monitor for all residuals

Notes

Use PetscDrawLGDestroy() to destroy this line graph.

See Also

NEPMonitorSet()

Location: src/nep/interface/nepmon.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPCISSGetRefinement.html0000644000175000017500000000414513107004621022505 0ustar jromanjroman NEPCISSGetRefinement

slepc-3.7.4 2017-05-17

NEPCISSGetRefinement

Gets the values of various refinement parameters in the CISS solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPCISSGetRefinement(NEP nep, PetscInt *inner, PetscInt *blsize)
Not Collective

Input Parameter

nep  - the eigenproblem solver context

Output Parameters

inner  - number of iterative refinement iterations (inner loop)
blsize  - number of iterative refinement iterations (blocksize loop)

See Also

NEPCISSSetRefinement()

Location: src/nep/impls/ciss/nciss.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRIISetKSP.html0000644000175000017500000000335613107004621020747 0ustar jromanjroman NEPRIISetKSP

slepc-3.7.4 2017-05-17

NEPRIISetKSP

Associate a linear solver object (KSP) to the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIISetKSP(NEP nep,KSP ksp)
Collective on NEP

Input Parameters

nep  - eigenvalue solver
ksp  - the linear solver object

See Also

NEPRIIGetKSP()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPConvMonitorSetFromOptions.html0000644000175000017500000000512613107004621024420 0ustar jromanjroman NEPConvMonitorSetFromOptions

slepc-3.7.4 2017-05-17

NEPConvMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence).

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPConvMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a SlepcConvMonitor

See Also

NEPMonitorSet(), NEPMonitorSetFromOptions()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetErrorEstimate.html0000644000175000017500000000420113107004621022505 0ustar jromanjroman NEPGetErrorEstimate

slepc-3.7.4 2017-05-17

NEPGetErrorEstimate

Returns the error estimate associated to the i-th computed eigenpair.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetErrorEstimate(NEP nep,PetscInt i,PetscReal *errest)
Not Collective

Input Parameter

nep  - nonlinear eigensolver context
i  - index of eigenpair

Output Parameter

errest  - the error estimate

Notes

This is the error estimate used internally by the eigensolver. The actual error bound can be computed with NEPComputeRelativeError().

See Also

NEPComputeRelativeError()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPView.html0000644000175000017500000000526113107004621020201 0ustar jromanjroman NEPView

slepc-3.7.4 2017-05-17

NEPView

Prints the NEP data structure.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPView(NEP nep,PetscViewer viewer)
Collective on NEP

Input Parameters

nep  - the nonlinear eigenproblem solver context
viewer  - optional visualization context

Options Database Key

-nep_view  - Calls NEPView() at end of NEPSolve()

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

See Also

PetscViewerASCIIOpen()

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSSetLocking.html0000644000175000017500000000456613107004621022242 0ustar jromanjroman NEPNLEIGSSetLocking

slepc-3.7.4 2017-05-17

NEPNLEIGSSetLocking

Choose between locking and non-locking variants of the NLEIGS method.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSSetLocking(NEP nep,PetscBool lock)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
lock  - true if the locking variant must be selected

Options Database Key

-nep_nleigs_locking  - Sets the locking flag

Notes

The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant).

See Also

NEPNLEIGSGetLocking()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPMonitorConverged.html0000644000175000017500000000535213107004621022554 0ustar jromanjroman NEPMonitorConverged

slepc-3.7.4 2017-05-17

NEPMonitorConverged

Print the approximate values and error estimates as they converge.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPMonitorConverged(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
ctx  - monitor context

See Also

NEPMonitorSet(), NEPMonitorFirst(), NEPMonitorAll()

Location: src/nep/interface/nepmon.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPInitializePackage.html0000644000175000017500000000312513107004621022641 0ustar jromanjroman NEPInitializePackage

slepc-3.7.4 2017-05-17

NEPInitializePackage

This function initializes everything in the NEP package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to NEPCreate() when using static libraries.

Synopsis

PetscErrorCode NEPInitializePackage(void)

See Also

SlepcInitialize()

Location: src/nep/interface/dlregisnep.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPStop.html0000644000175000017500000000273713107004621020221 0ustar jromanjroman NEPStop

slepc-3.7.4 2017-05-17

NEPStop

Determines the stopping test

Synopsis

typedef enum { NEP_STOP_BASIC,
               NEP_STOP_USER } NEPStop;

See Also

NEPSetStoppingTest(), NEPSetStoppingTestFunction()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPCreate.html0000644000175000017500000000524013107004621020467 0ustar jromanjroman NEPCreate

slepc-3.7.4 2017-05-17

NEPCreate

Creates the default NEP context.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPCreate(MPI_Comm comm,NEP *outnep)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

nep  - location to put the NEP context

See Also

NEPSetUp(), NEPSolve(), NEPDestroy(), NEP

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPInterpolSetPEP.html0000644000175000017500000000360413107004621022103 0ustar jromanjroman NEPInterpolSetPEP
slepc-3.7.4 2017-05-17

NEPInterpolSetPEP

Associate a polynomial eigensolver object (PEP) to the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
#include "slepcpep.h" 
PetscErrorCode NEPInterpolSetPEP(NEP nep,PEP pep)
Collective on NEP

Input Parameters

nep  - nonlinear eigenvalue solver
pep  - the polynomial eigensolver object

See Also

NEPInterpolGetPEP()

Location: src/nep/impls/interpol/interpol.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetTolerances.html0000644000175000017500000000542313107004621022042 0ustar jromanjroman NEPSetTolerances

slepc-3.7.4 2017-05-17

NEPSetTolerances

Sets the tolerance and maximum iteration count used by the NEP convergence tests.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetTolerances(NEP nep,PetscReal tol,PetscInt maxits)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
tol  - the convergence tolerance
maxits  - maximum number of iterations to use

Options Database Keys

-nep_tol <tol>  - Sets the convergence tolerance
-nep_max_it <maxits>  - Sets the maximum number of iterations allowed

Notes

Use PETSC_DEFAULT for either argument to assign a reasonably good value.

See Also

NEPGetTolerances()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex22.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPVectorsView.html0000644000175000017500000000452313107004621021547 0ustar jromanjroman NEPVectorsView
slepc-3.7.4 2017-05-17

NEPVectorsView

Outputs computed eigenvectors to a viewer.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPVectorsView(NEP nep,PetscViewer viewer)
Collective on NEP

Parameter

nep  - the nonlinear eigensolver context
viewer  - the viewer

Options Database Keys

-nep_view_vectors  - output eigenvectors.

Note

If PETSc was configured with real scalars, complex conjugate eigenvectors will be viewed as two separate real vectors, one containing the real part and another one containing the imaginary part.

See Also

NEPSolve(), NEPValuesView(), NEPErrorView()

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPDestroy.html0000644000175000017500000000467513107004621020730 0ustar jromanjroman NEPDestroy

slepc-3.7.4 2017-05-17

NEPDestroy

Destroys the NEP context.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPDestroy(NEP *nep)
Collective on NEP

Input Parameter

nep  - eigensolver context obtained from NEPCreate()

See Also

NEPCreate(), NEPSetUp(), NEPSolve()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPSetTrackAll.html0000644000175000017500000000433513107004621021441 0ustar jromanjroman NEPSetTrackAll
slepc-3.7.4 2017-05-17

NEPSetTrackAll

Specifies if the solver must compute the residual of all approximate eigenpairs or not.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetTrackAll(NEP nep,PetscBool trackall)
Logically Collective on NEP

Input Parameters

nep  - the eigensolver context
trackall  - whether compute all residuals or not

Notes

If the user sets trackall=PETSC_TRUE then the solver explicitly computes the residual for each eigenpair approximation. Computing the residual is usually an expensive operation and solvers commonly compute the associated residual to the first unconverged eigenpair. The options '-nep_monitor_all' and '-nep_monitor_lg_all' automatically activate this option.

See Also

NEPGetTrackAll()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNArnoldiSetKSP.html0000644000175000017500000000345713107004621022034 0ustar jromanjroman NEPNArnoldiSetKSP

slepc-3.7.4 2017-05-17

NEPNArnoldiSetKSP

Associate a linear solver object (KSP) to the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNArnoldiSetKSP(NEP nep,KSP ksp)
Collective on NEP

Input Parameters

nep  - eigenvalue solver
ksp  - the linear solver object

See Also

NEPNArnoldiGetKSP()

Location: src/nep/impls/narnoldi/narnoldi.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSSetRestart.html0000644000175000017500000000441713107004621022273 0ustar jromanjroman NEPNLEIGSSetRestart

slepc-3.7.4 2017-05-17

NEPNLEIGSSetRestart

Sets the restart parameter for the NLEIGS method, in particular the proportion of basis vectors that must be kept after restart.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSSetRestart(NEP nep,PetscReal keep)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
keep  - the number of vectors to be kept at restart

Options Database Key

-nep_nleigs_restart  - Sets the restart parameter

Notes

Allowed values are in the range [0.1,0.9]. The default is 0.5.

See Also

NEPNLEIGSGetRestart()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetRefine.html0000644000175000017500000001062113107004621021147 0ustar jromanjroman NEPSetRefine

slepc-3.7.4 2017-05-17

NEPSetRefine

Specifies the refinement type (and options) to be used after the solve.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetRefine(NEP nep,NEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,NEPRefineScheme scheme)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
refine  - refinement type
npart  - number of partitions of the communicator
tol  - the convergence tolerance
its  - maximum number of refinement iterations
scheme  - which scheme to be used for solving the involved linear systems

Options Database Keys

-nep_refine <type>  - refinement type, one of <none,simple,multiple>
-nep_refine_partitions <n>  - the number of partitions
-nep_refine_tol <tol>  - the tolerance
-nep_refine_its <its>  - number of iterations
-nep_refine_scheme  - to set the scheme for the linear solves

Notes

By default, iterative refinement is disabled, since it may be very costly. There are two possible refinement strategies: simple and multiple. The simple approach performs iterative refinement on each of the converged eigenpairs individually, whereas the multiple strategy works with the invariant pair as a whole, refining all eigenpairs simultaneously. The latter may be required for the case of multiple eigenvalues.

In some cases, especially when using direct solvers within the iterative refinement method, it may be helpful for improved scalability to split the communicator in several partitions. The npart parameter indicates how many partitions to use (defaults to 1).

The tol and its parameters specify the stopping criterion. In the simple method, refinement continues until the residual of each eigenpair is below the tolerance (tol defaults to the NEP tol, but may be set to a different value). In contrast, the multiple method simply performs its refinement iterations (just one by default).

The scheme argument is used to change the way in which linear systems are solved. Possible choices are: explicit, mixed block elimination (MBE), and Schur complement.

See Also

NEPGetRefine()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPVectorsViewFromOptions.html0000644000175000017500000000316513107004621023750 0ustar jromanjroman NEPVectorsViewFromOptions

slepc-3.7.4 2017-05-17

NEPVectorsViewFromOptions

Processes command line options to determine if/how the computed eigenvectors are to be viewed.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPVectorsViewFromOptions(NEP nep)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPMonitorSet.html0000644000175000017500000001255613107004621021377 0ustar jromanjroman NEPMonitorSet

slepc-3.7.4 2017-05-17

NEPMonitorSet

Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested eigenpair.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPMonitorSet(NEP nep,PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
Logically Collective on NEP

Input Parameters

nep  - eigensolver context obtained from NEPCreate()
monitor  - pointer to function (if this is NULL, it turns off monitoring)
mctx  - [optional] context for private data for the monitor routine (use NULL if no context is desired)
monitordestroy  - [optional] routine that frees monitor context (may be NULL)

Calling Sequence of monitor

  monitor(NEP nep,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx)

nep  - nonlinear eigensolver context obtained from NEPCreate()
its  - iteration number
nconv  - number of converged eigenpairs
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates for each eigenpair
nest  - number of error estimates
mctx  - optional monitoring context, as set by NEPMonitorSet()

Options Database Keys

-nep_monitor  - print only the first error estimate
-nep_monitor_all  - print error estimates at each iteration
-nep_monitor_conv  - print the eigenvalue approximations only when convergence has been reached
-nep_monitor_lg  - sets line graph monitor for the first unconverged approximate eigenvalue
-nep_monitor_lg_all  - sets line graph monitor for all unconverged approximate eigenvalues
-nep_monitor_cancel  - cancels all monitors that have been hardwired into a code by calls to NEPMonitorSet(), but does not cancel those set via the options database.

Notes

Several different monitoring routines may be set by calling NEPMonitorSet() multiple times; all will be called in the order in which they were set.

See Also

NEPMonitorFirst(), NEPMonitorAll(), NEPMonitorCancel()

Location: src/nep/interface/nepmon.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSGetRKShifts.html0000644000175000017500000000402113107004621022317 0ustar jromanjroman NEPNLEIGSGetRKShifts

slepc-3.7.4 2017-05-17

NEPNLEIGSGetRKShifts

Gets the list of shifts used in the Rational Krylov method.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSGetRKShifts(NEP nep,PetscInt *ns,PetscScalar **shifts)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

ns  - number of shifts
shifts  - array of shifts

See Also

NEPNLEIGSSetRKShifts()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSGetInterpolation.html0000644000175000017500000000423013107004621023453 0ustar jromanjroman NEPNLEIGSGetInterpolation

slepc-3.7.4 2017-05-17

NEPNLEIGSGetInterpolation

Gets the tolerance and maximum iteration count used by the NLEIGS method when building the interpolation via divided differences.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSGetInterpolation(NEP nep,PetscReal *tol,PetscInt *maxits)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

tol  - the convergence tolerance
maxits  - maximum number of iterations

See Also

NEPNLEIGSSetInterpolation()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPComputeFunction.html0000644000175000017500000000510413107004621022405 0ustar jromanjroman NEPComputeFunction

slepc-3.7.4 2017-05-17

NEPComputeFunction

Computes the function matrix T(lambda) that has been set with NEPSetFunction().

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPComputeFunction(NEP nep,PetscScalar lambda,Mat A,Mat B)
Collective on NEP and Mat

Input Parameters

nep  - the NEP context
lambda  - the scalar argument

Output Parameters

A  - Function matrix
B  - optional preconditioning matrix

Notes

NEPComputeFunction() is typically used within nonlinear eigensolvers implementations, so most users would not generally call this routine themselves.

See Also

NEPSetFunction(), NEPGetFunction()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPValuesViewFromOptions.html0000644000175000017500000000315613107004621023562 0ustar jromanjroman NEPValuesViewFromOptions

slepc-3.7.4 2017-05-17

NEPValuesViewFromOptions

Processes command line options to determine if/how the computed eigenvalues are to be viewed.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPValuesViewFromOptions(NEP nep)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPFinalizePackage.html0000644000175000017500000000276713107004621022314 0ustar jromanjroman NEPFinalizePackage

slepc-3.7.4 2017-05-17

NEPFinalizePackage

This function destroys everything in the Slepc interface to the NEP package. It is called from SlepcFinalize().

Synopsis

PetscErrorCode NEPFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/nep/interface/dlregisnep.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetConvergenceTest.html0000644000175000017500000000676613107004621023054 0ustar jromanjroman NEPSetConvergenceTest

slepc-3.7.4 2017-05-17

NEPSetConvergenceTest

Specifies how to compute the error estimate used in the convergence test.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetConvergenceTest(NEP nep,NEPConv conv)
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context obtained from NEPCreate()
conv  - the type of convergence test

Options Database Keys

-nep_conv_abs  - Sets the absolute convergence test
-nep_conv_rel  - Sets the convergence test relative to the eigenvalue
-nep_conv_user  - Selects the user-defined convergence test

Note

The parameter 'conv' can have one of these values
NEP_CONV_ABS  - absolute error ||r||
NEP_CONV_REL  - error relative to the eigenvalue l, ||r||/|l|
NEP_CONV_NORM  - error relative matrix norms, ||r||/sum_i(|f_i(l)|*||A_i||)
NEP_CONV_USER  - function set by NEPSetConvergenceTestFunction()

See Also

NEPGetConvergenceTest(), NEPSetConvergenceTestFunction(), NEPSetStoppingTest(), NEPConv

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPApplyJacobian.html0000644000175000017500000000561113107004621022002 0ustar jromanjroman NEPApplyJacobian

slepc-3.7.4 2017-05-17

NEPApplyJacobian

Applies the nonlinear Jacobian T'(lambda) to a given vector.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPApplyJacobian(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
lambda  - scalar argument
x  - vector to be multiplied against
v  - workspace vector (used only in the case of split form)

Output Parameters

y  - result vector
A  - Jacobian matrix

Note

If the nonlinear operator is represented in split form, the result y = T'(lambda)*x is computed without building T'(lambda) explicitly. In that case, parameter A is not used. Otherwise, the matrix T'(lambda) is built and the effect is the same as a call to NEPComputeJacobian() followed by a MatMult().

See Also

NEPSetSplitOperator(), NEPComputeJacobian()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSLPSetEPS.html0000644000175000017500000000343513107004621020752 0ustar jromanjroman NEPSLPSetEPS

slepc-3.7.4 2017-05-17

NEPSLPSetEPS

Associate a linear eigensolver object (EPS) to the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSLPSetEPS(NEP nep,EPS eps)
Collective on NEP

Input Parameters

nep  - nonlinear eigenvalue solver
eps  - the eigensolver object

See Also

NEPSLPGetEPS()

Location: src/nep/impls/slp/slp.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetSplitOperatorInfo.html0000644000175000017500000000460413107004621023352 0ustar jromanjroman NEPGetSplitOperatorInfo

slepc-3.7.4 2017-05-17

NEPGetSplitOperatorInfo

Returns the number of terms of the split form of the nonlinear operator, as well as the structure flag for matrices.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetSplitOperatorInfo(NEP nep,PetscInt *n,MatStructure *str)
Not collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

n  - the number of terms passed in NEPSetSplitOperator()
str  - the matrix structure flag passed in NEPSetSplitOperator()

See Also

NEPSetSplitOperator(), NEPGetSplitOperatorTerm()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetEigenpair.html0000644000175000017500000000720213107004621021627 0ustar jromanjroman NEPGetEigenpair

slepc-3.7.4 2017-05-17

NEPGetEigenpair

Gets the i-th solution of the eigenproblem as computed by NEPSolve(). The solution consists in both the eigenvalue and the eigenvector.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetEigenpair(NEP nep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context
i  - index of the solution

Output Parameters

eigr  - real part of eigenvalue
eigi  - imaginary part of eigenvalue
Vr  - real part of eigenvector
Vi  - imaginary part of eigenvector

Notes

It is allowed to pass NULL for Vr and Vi, if the eigenvector is not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs().

If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is set to zero). In both cases, the user can pass NULL in eigi and Vi.

The index i should be a value between 0 and nconv-1 (see NEPGetConverged()). Eigenpairs are indexed according to the ordering criterion established with NEPSetWhichEigenpairs().

See Also

NEPSolve(), NEPGetConverged(), NEPSetWhichEigenpairs()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPErrorType.html0000644000175000017500000000273413107004621021224 0ustar jromanjroman NEPErrorType
slepc-3.7.4 2017-05-17

NEPErrorType

The error type used to assess accuracy of computed solutions

Synopsis

typedef enum { NEP_ERROR_ABSOLUTE,
               NEP_ERROR_RELATIVE,
               NEP_ERROR_BACKWARD } NEPErrorType;

See Also

NEPComputeError()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPAppendOptionsPrefix.html0000644000175000017500000000435213107004621023230 0ustar jromanjroman NEPAppendOptionsPrefix

slepc-3.7.4 2017-05-17

NEPAppendOptionsPrefix

Appends to the prefix used for searching for all NEP options in the database.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char *prefix)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
prefix  - the prefix string to prepend to all NEP option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

NEPSetOptionsPrefix(), NEPGetOptionsPrefix()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/index.html0000644000175000017500000002753113107004621020037 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP

slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

Beginner - Basic usage
NEP NEPGetEigenpair NEPSetSplitOperator
NEPComputeError NEPSetDerivatives NEPSolve
NEPCreate NEPSetFromOptions NEPType
NEPDestroy NEPSetFunction NEPView
NEPGetConverged NEPSetJacobian
Intermediate - Setting options for algorithms and data structures
NEPConv NEPGetType NEPRefine
NEPConvergedReason NEPGetWhichEigenpairs NEPRefineScheme
NEPErrorType NEPMonitorAll NEPSetConvergenceTest
NEPErrorView NEPMonitorCancel NEPSetDimensions
NEPGetConvergedReason NEPMonitorConverged NEPSetInitialSpace
NEPGetConvergenceTest NEPMonitorFirst NEPSetRefine
NEPGetDimensions NEPMonitorLGCreate NEPSetTarget
NEPGetIterationNumber NEPMonitorSet NEPSetTolerances
NEPGetMonitorContext NEPNLEIGSSetSingularitiesFunction NEPSetType
NEPGetRefine NEPRIIGetConstCorrectionTol NEPSetWhichEigenpairs
NEPGetSplitOperatorInfo NEPRIIGetLagPreconditioner NEPValuesView
NEPGetSplitOperatorTerm NEPRIISetConstCorrectionTol NEPVectorsView
NEPGetTarget NEPRIISetLagPreconditioner NEPWhich
NEPGetTolerances NEPReasonView
Advanced - Setting more advanced options and customization
NEPAppendOptionsPrefix NEPInterpolSetDegree NEPRIISetKSP
NEPCISSGetRefinement NEPInterpolSetPEP NEPRIISetMaximumIterations
NEPCISSGetSizes NEPNArnoldiGetKSP NEPRefineGetKSP
NEPCISSGetThreshold NEPNArnoldiSetKSP NEPRegister
NEPCISSSetRefinement NEPNLEIGSGetInterpolation NEPRegisterAll
NEPCISSSetSizes NEPNLEIGSGetKSPs NEPReset
NEPCISSSetThreshold NEPNLEIGSGetLocking NEPSLPGetEPS
NEPGetBV NEPNLEIGSGetRKShifts NEPSLPSetEPS
NEPGetDS NEPNLEIGSGetRestart NEPSetBV
NEPGetDerivatives NEPNLEIGSGetSingularitiesFunction NEPSetConvergenceTestFunction
NEPGetErrorEstimate NEPNLEIGSGetTrueResidual NEPSetDS
NEPGetFunction NEPNLEIGSSetInterpolation NEPSetEigenvalueComparison
NEPGetJacobian NEPNLEIGSSetLocking NEPSetOptionsPrefix
NEPGetOptionsPrefix NEPNLEIGSSetRKShifts NEPSetRG
NEPGetRG NEPNLEIGSSetRestart NEPSetStoppingTest
NEPGetStoppingTest NEPNLEIGSSetTrueResidual NEPSetStoppingTestFunction
NEPInterpolGetDegree NEPRIIGetKSP NEPStop
NEPInterpolGetPEP NEPRIIGetMaximumIterations NEPStoppingBasic
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
NEPAllocateSolution NEPErrorViewFromOptions NEPReasonViewFromOptions
NEPApplyFunction NEPFinalizePackage NEPSetTrackAll
NEPApplyJacobian NEPGetTrackAll NEPSetUp
NEPComputeFunction NEPInitializePackage NEPSetWorkVecs
NEPComputeJacobian NEPMonitorSetFromOptions NEPValuesViewFromOptions
NEPConvMonitorSetFromOptions NEPProjectOperator NEPVectorsViewFromOptions
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/NEP/NEPMonitorSetFromOptions.html0000644000175000017500000000540013107004621023565 0ustar jromanjroman NEPMonitorSetFromOptions

slepc-3.7.4 2017-05-17

NEPMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a PetscViewerAndFormat
trackall  - whether this monitor tracks all eigenvalues or not

See Also

NEPMonitorSet(), NEPSetTrackAll(), NEPConvMonitorSetFromOptions()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetIterationNumber.html0000644000175000017500000000532013107004621023032 0ustar jromanjroman NEPGetIterationNumber

slepc-3.7.4 2017-05-17

NEPGetIterationNumber

Gets the current iteration number. If the call to NEPSolve() is complete, then it returns the number of iterations carried out by the solution method.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetIterationNumber(NEP nep,PetscInt *its)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

its  - number of iterations

Note

During the i-th iteration this call returns i-1. If NEPSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call NEPGetConvergedReason() to determine if the solver converged or failed and why.

See Also

NEPGetConvergedReason(), NEPSetTolerances()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetStoppingTest.html0000644000175000017500000000403013107004621022363 0ustar jromanjroman NEPGetStoppingTest
slepc-3.7.4 2017-05-17

NEPGetStoppingTest

Gets the method used to decide the termination of the outer loop of the eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetStoppingTest(NEP nep,NEPStop *stop)
Not Collective

Input Parameters

nep  - nonlinear eigensolver context obtained from NEPCreate()

Output Parameters

stop  - the type of stopping test

See Also

NEPSetStoppingTest(), NEPStop

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetStoppingTest.html0000644000175000017500000000601713107004621022406 0ustar jromanjroman NEPSetStoppingTest

slepc-3.7.4 2017-05-17

NEPSetStoppingTest

Specifies how to decide the termination of the outer loop of the eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetStoppingTest(NEP nep,NEPStop stop)
Logically Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context obtained from NEPCreate()
stop  - the type of stopping test

Options Database Keys

-nep_stop_basic  - Sets the default stopping test
-nep_stop_user  - Selects the user-defined stopping test

Note

The parameter 'stop' can have one of these values
NEP_STOP_BASIC  - default stopping test
NEP_STOP_USER  - function set by NEPSetStoppingTestFunction()

See Also

NEPGetStoppingTest(), NEPSetStoppingTestFunction(), NEPSetConvergenceTest(), NEPStop

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSGetTrueResidual.html0000644000175000017500000000373013107004621023240 0ustar jromanjroman NEPNLEIGSGetTrueResidual

slepc-3.7.4 2017-05-17

NEPNLEIGSGetTrueResidual

Returns the flag indicating whether true residuals must be computed explicitly or not.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSGetTrueResidual(NEP nep,PetscBool *trueres)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

trueres  - the returned flag

See Also

NEPNLEIGSSetTrueResidual()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetType.html0000644000175000017500000000572713107004621020673 0ustar jromanjroman NEPSetType

slepc-3.7.4 2017-05-17

NEPSetType

Selects the particular solver to be used in the NEP object.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetType(NEP nep,NEPType type)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
type  - a known method

Options Database Key

-nep_type <method>  - Sets the method; use -help for a list of available methods

Notes

See "slepc/include/slepcnep.h" for available methods.

Normally, it is best to use the NEPSetFromOptions() command and then set the NEP type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The NEPSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database.

See Also

NEPType

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetTolerances.html0000644000175000017500000000447613107004621022035 0ustar jromanjroman NEPGetTolerances
slepc-3.7.4 2017-05-17

NEPGetTolerances

Gets the tolerance and maximum iteration count used by the NEP convergence tests.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetTolerances(NEP nep,PetscReal *tol,PetscInt *maxits)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

tol  - the convergence tolerance
maxits  - maximum number of iterations

Notes

The user can specify NULL for any parameter that is not needed.

See Also

NEPSetTolerances()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPErrorViewFromOptions.html0000644000175000017500000000316313107004621023412 0ustar jromanjroman NEPErrorViewFromOptions
slepc-3.7.4 2017-05-17

NEPErrorViewFromOptions

Processes command line options to determine if/how the errors of the computed solution are to be viewed.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPErrorViewFromOptions(NEP nep)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context

Location: src/nep/interface/nepview.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPProjectOperator.html0000644000175000017500000000463713107004621022417 0ustar jromanjroman NEPProjectOperator

slepc-3.7.4 2017-05-17

NEPProjectOperator

Computes the projection of the nonlinear operator.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPProjectOperator(NEP nep,PetscInt j0,PetscInt j1)
Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
j0  - initial index
j1  - final index

Notes

This is available for split operator only.

The nonlinear operator T(lambda) is projected onto span(V), where V is an orthonormal basis built internally by the solver. The projected operator is equal to sum_i V'*A_i*V*f_i(lambda), so this function computes all matrices Ei = V'*A_i*V, and stores them in the extra matrices inside DS. Only rows/columns in the range [j0,j1-1] are computed, the previous ones are assumed to be available already.

See Also

NEPSetSplitOperator()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPWhich.html0000644000175000017500000000347213107004621020333 0ustar jromanjroman NEPWhich

slepc-3.7.4 2017-05-17

NEPWhich

Determines which part of the spectrum is requested

Synopsis

typedef enum { NEP_LARGEST_MAGNITUDE=1,
               NEP_SMALLEST_MAGNITUDE,
               NEP_LARGEST_REAL,
               NEP_SMALLEST_REAL,
               NEP_LARGEST_IMAGINARY,
               NEP_SMALLEST_IMAGINARY,
               NEP_TARGET_MAGNITUDE,
               NEP_TARGET_REAL,
               NEP_TARGET_IMAGINARY,
               NEP_ALL,
               NEP_WHICH_USER } NEPWhich;

See Also

NEPSetWhichEigenpairs(), NEPGetWhichEigenpairs()

Location: src/nep/../../include/slepcnep.h
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPMonitorFirst.html0000644000175000017500000000544113107004621021726 0ustar jromanjroman NEPMonitorFirst

slepc-3.7.4 2017-05-17

NEPMonitorFirst

Print the first unconverged approximate value and error estimate at each iteration of the nonlinear eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPMonitorFirst(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on NEP

Input Parameters

nep  - nonlinear eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

NEPMonitorSet(), NEPMonitorAll(), NEPMonitorConverged()

Location: src/nep/interface/nepmon.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRegister.html0000644000175000017500000000450213107004621021050 0ustar jromanjroman NEPRegister

slepc-3.7.4 2017-05-17

NEPRegister

Adds a method to the nonlinear eigenproblem solver package.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRegister(const char *name,PetscErrorCode (*function)(NEP))
Not Collective

Input Parameters

name  - name of a new user-defined solver
function  - routine to create the solver context

Notes

NEPRegister() may be called multiple times to add several user-defined solvers.

Sample usage

    NEPRegister("my_solver",MySolverCreate);

Then, your solver can be chosen with the procedural interface via

    NEPSetType(nep,"my_solver")
or at runtime via the option
    -nep_type my_solver

See Also

NEPRegisterAll()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPCISSSetRefinement.html0000644000175000017500000000466513107004621022530 0ustar jromanjroman NEPCISSSetRefinement

slepc-3.7.4 2017-05-17

NEPCISSSetRefinement

Sets the values of various refinement parameters in the CISS solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPCISSSetRefinement(NEP nep,PetscInt inner,PetscInt blsize)
Logically Collective on NEP

Input Parameters

nep  - the eigenproblem solver context
inner  - number of iterative refinement iterations (inner loop)
blsize  - number of iterative refinement iterations (blocksize loop)

Options Database Keys

-nep_ciss_refine_inner  - Sets number of inner iterations
-nep_ciss_refine_blocksize  - Sets number of blocksize iterations

See Also

NEPCISSGetRefinement()

Location: src/nep/impls/ciss/nciss.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetBV.html0000644000175000017500000000373313107004621020254 0ustar jromanjroman NEPSetBV

slepc-3.7.4 2017-05-17

NEPSetBV

Associates a basis vectors object to the nonlinear eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetBV(NEP nep,BV bv)
Collective on NEP

Input Parameters

nep  - eigensolver context obtained from NEPCreate()
bv  - the basis vectors object

Note

Use NEPGetBV() to retrieve the basis vectors context (for example, to free it at the end of the computations).

See Also

NEPGetBV()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetJacobian.html0000644000175000017500000000675413107004621021461 0ustar jromanjroman NEPSetJacobian

slepc-3.7.4 2017-05-17

NEPSetJacobian

Sets the function to compute Jacobian T'(lambda) as well as the location to store the matrix.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetJacobian(NEP nep,Mat A,PetscErrorCode (*jac)(NEP,PetscScalar,Mat,void*),void *ctx)
Logically Collective on NEP and Mat

Input Parameters

nep  - the NEP context
A  - Jacobian matrix
jac  - Jacobian evaluation routine (if NULL then NEP retains any previously set value)
ctx  - [optional] user-defined context for private data for the Jacobian evaluation routine (may be NULL) (if NULL then NEP retains any previously set value)

Calling Sequence of jac

  jac(NEP nep,PetscScalar lambda,Mat J,void *ctx)

nep  - the NEP context
lambda  - the scalar argument where T'(.) must be evaluated
J  - matrix that will contain T'(lambda)
ctx  - (optional) user-defined context, as set by NEPSetJacobian()

See Also

NEPSetFunction(), NEPGetJacobian()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetConverged.html0000644000175000017500000000431613107004621021643 0ustar jromanjroman NEPGetConverged
slepc-3.7.4 2017-05-17

NEPGetConverged

Gets the number of converged eigenpairs.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetConverged(NEP nep,PetscInt *nconv)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

nconv  - number of converged eigenpairs

Note

This function should be called after NEPSolve() has finished.

See Also

NEPSetDimensions(), NEPSolve()

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPSetTarget.html0000644000175000017500000000521713107004621021172 0ustar jromanjroman NEPSetTarget
slepc-3.7.4 2017-05-17

NEPSetTarget

Sets the value of the target.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetTarget(NEP nep,PetscScalar target)
Logically Collective on NEP

Input Parameters

nep  - eigensolver context
target  - the value of the target

Options Database Key

-nep_target <scalar>  - the value of the target

Notes

The target is a scalar value used to determine the portion of the spectrum of interest. It is used in combination with NEPSetWhichEigenpairs().

In the case of complex scalars, a complex value can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -nep_target 1.0+2.0i

See Also

NEPGetTarget(), NEPSetWhichEigenpairs()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetWhichEigenpairs.html0000644000175000017500000000431513107004621022777 0ustar jromanjroman NEPGetWhichEigenpairs
slepc-3.7.4 2017-05-17

NEPGetWhichEigenpairs

Returns which portion of the spectrum is to be sought.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetWhichEigenpairs(NEP nep,NEPWhich *which)
Not Collective

Input Parameter

nep  - eigensolver context obtained from NEPCreate()

Output Parameter

which  - the portion of the spectrum to be sought

Notes

See NEPSetWhichEigenpairs() for possible values of 'which'.

See Also

NEPSetWhichEigenpairs(), NEPWhich

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPSetSplitOperator.html0000644000175000017500000000704513107004621022554 0ustar jromanjroman NEPSetSplitOperator

slepc-3.7.4 2017-05-17

NEPSetSplitOperator

Sets the operator of the nonlinear eigenvalue problem in split form.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetSplitOperator(NEP nep,PetscInt n,Mat A[],FN f[],MatStructure str)
Collective on NEP, Mat and FN

Input Parameters

nep  - the nonlinear eigensolver context
n  - number of terms in the split form
A  - array of matrices
f  - array of functions
str  - structure flag for matrices

Notes

The nonlinear operator is written as T(lambda) = sum_i A_i*f_i(lambda), for i=1,...,n. The derivative T'(lambda) can be obtained using the derivatives of f_i.

The structure flag provides information about A_i's nonzero pattern (see MatStructure enum). If all matrices have the same pattern, then use SAME_NONZERO_PATTERN. If the patterns are different but contained in the pattern of the first one, then use SUBSET_NONZERO_PATTERN. Otherwise use DIFFERENT_NONZERO_PATTERN.

This function must be called before NEPSetUp(). If it is called again after NEPSetUp() then the NEP object is reset.

See Also

NEPGetSplitOperatorTerm(), NEPGetSplitOperatorInfo()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetConvergedReason.html0000644000175000017500000000605513107004621023015 0ustar jromanjroman NEPGetConvergedReason
slepc-3.7.4 2017-05-17

NEPGetConvergedReason

Gets the reason why the NEPSolve() iteration was stopped.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetConvergedReason(NEP nep,NEPConvergedReason *reason)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameter

reason  - negative value indicates diverged, positive value converged

Notes

Possible values for reason are
NEP_CONVERGED_TOL  - converged up to tolerance
NEP_CONVERGED_USER  - converged due to a user-defined condition
NEP_DIVERGED_ITS  - required more than max_it iterations to reach convergence
NEP_DIVERGED_BREAKDOWN  - generic breakdown in method
NEP_DIVERGED_LINEAR_SOLVE  - inner linear solve failed

Can only be called after the call to NEPSolve() is complete.

See Also

NEPSetTolerances(), NEPSolve(), NEPConvergedReason

Location: src/nep/interface/nepsolve.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPAllocateSolution.html0000644000175000017500000000367213107004621022554 0ustar jromanjroman NEPAllocateSolution

slepc-3.7.4 2017-05-17

NEPAllocateSolution

Allocate memory storage for common variables such as eigenvalues and eigenvectors.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPAllocateSolution(NEP nep,PetscInt extra)
Collective on NEP

Input Parameters

nep  - eigensolver context
extra  - number of additional positions, used for methods that require a working basis slightly larger than ncv

Developers Note

This is PETSC_EXTERN because it may be required by user plugin NEP implementations.

Location: src/nep/interface/nepsetup.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPNLEIGSSetTrueResidual.html0000644000175000017500000000476213107004621023262 0ustar jromanjroman NEPNLEIGSSetTrueResidual

slepc-3.7.4 2017-05-17

NEPNLEIGSSetTrueResidual

Specifies if the solver must compute the true residual explicitly or not.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPNLEIGSSetTrueResidual(NEP nep,PetscBool trueres)
Logically Collective on NEP

Input Parameters

nep  - the nonlinear eigensolver context
trueres  - whether true residuals are required or not

Options Database Key

-nep_nleigs_true_residual <boolean>  - Sets/resets the boolean flag 'trueres'

Notes

If the user sets trueres=PETSC_TRUE then the solver explicitly computes the true residual norm for each eigenpair approximation, and uses it for convergence testing. The default is to use the cheaper approximation available from the (rational) Krylov iteration.

See Also

NEPNLEIGSGetTrueResidual()

Location: src/nep/impls/nleigs/nleigs.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPRIIGetKSP.html0000644000175000017500000000376013107004621020732 0ustar jromanjroman NEPRIIGetKSP

slepc-3.7.4 2017-05-17

NEPRIIGetKSP

Retrieve the linear solver object (KSP) associated with the nonlinear eigenvalue solver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPRIIGetKSP(NEP nep,KSP *ksp)
Not Collective

Input Parameter

nep  - nonlinear eigenvalue solver

Output Parameter

ksp  - the linear solver object

See Also

NEPRIISetKSP()

Location: src/nep/impls/rii/rii.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex21.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPGetTarget.html0000644000175000017500000000362613107004621021160 0ustar jromanjroman NEPGetTarget
slepc-3.7.4 2017-05-17

NEPGetTarget

Gets the value of the target.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetTarget(NEP nep,PetscScalar* target)
Not Collective

Input Parameter

nep  - eigensolver context

Output Parameter

target  - the value of the target

Note

If the target was not set by the user, then zero is returned.

See Also

NEPSetTarget()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetConvergenceTest.html0000644000175000017500000000406213107004621023023 0ustar jromanjroman NEPGetConvergenceTest

slepc-3.7.4 2017-05-17

NEPGetConvergenceTest

Gets the method used to compute the error estimate used in the convergence test.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetConvergenceTest(NEP nep,NEPConv *conv)
Not Collective

Input Parameters

nep  - nonlinear eigensolver context obtained from NEPCreate()

Output Parameters

conv  - the type of convergence test

See Also

NEPSetConvergenceTest(), NEPConv

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetFunction.html0000644000175000017500000000467713107004621021526 0ustar jromanjroman NEPGetFunction

slepc-3.7.4 2017-05-17

NEPGetFunction

Returns the Function matrix and optionally the user provided context for evaluating the Function.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetFunction(NEP nep,Mat *A,Mat *B,PetscErrorCode (**fun)(NEP,PetscScalar,Mat,Mat,void*),void **ctx)
Not Collective, but Mat object will be parallel if NEP object is

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

A  - location to stash Function matrix (or NULL)
B  - location to stash preconditioner matrix (or NULL)
fun  - location to put Function function (or NULL)
ctx  - location to stash Function context (or NULL)

See Also

NEPSetFunction()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPReset.html0000644000175000017500000000332013107004621020343 0ustar jromanjroman NEPReset

slepc-3.7.4 2017-05-17

NEPReset

Resets the NEP context to the initial state and removes any allocated objects.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPReset(NEP nep)
Collective on NEP

Input Parameter

nep  - eigensolver context obtained from NEPCreate()

See Also

NEPDestroy()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetOptionsPrefix.html0000644000175000017500000000432213107004621022535 0ustar jromanjroman NEPGetOptionsPrefix

slepc-3.7.4 2017-05-17

NEPGetOptionsPrefix

Gets the prefix used for searching for all NEP options in the database.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetOptionsPrefix(NEP nep,const char *prefix[])
Not Collective

Input Parameters

nep  - the nonlinear eigensolver context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

NEPSetOptionsPrefix(), NEPAppendOptionsPrefix()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/NEP/NEPGetDimensions.html0000644000175000017500000000542113107004621022035 0ustar jromanjroman NEPGetDimensions

slepc-3.7.4 2017-05-17

NEPGetDimensions

Gets the number of eigenvalues to compute and the dimension of the subspace.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPGetDimensions(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
Not Collective

Input Parameter

nep  - the nonlinear eigensolver context

Output Parameters

nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

Notes

The user can specify NULL for any parameter that is not needed.

See Also

NEPSetDimensions()

Location: src/nep/interface/nepopts.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex20.c.html
src/nep/examples/tutorials/ex21.c.html
src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/manualpages/NEP/NEPSetDS.html0000644000175000017500000000373313107004621020253 0ustar jromanjroman NEPSetDS
slepc-3.7.4 2017-05-17

NEPSetDS

Associates a direct solver object to the nonlinear eigensolver.

Synopsis

#include "slepcnep.h" 
PetscErrorCode NEPSetDS(NEP nep,DS ds)
Collective on NEP

Input Parameters

nep  - eigensolver context obtained from NEPCreate()
ds  - the direct solver object

Note

Use NEPGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations).

See Also

NEPGetDS()

Location: src/nep/interface/nepbasic.c
Index of all NEP routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/0000755000175000017500000000000013107004621016044 5ustar jromanjromanslepc-3.7.4/docs/manualpages/SVD/SVDAppendOptionsPrefix.html0000644000175000017500000000435213107004621023254 0ustar jromanjroman SVDAppendOptionsPrefix

slepc-3.7.4 2017-05-17

SVDAppendOptionsPrefix

Appends to the prefix used for searching for all SVD options in the database.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDAppendOptionsPrefix(SVD svd,const char *prefix)
Logically Collective on SVD

Input Parameters

svd  - the singular value solver context
prefix  - the prefix string to prepend to all SVD option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

SVDSetOptionsPrefix(), SVDGetOptionsPrefix()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetBV.html0000644000175000017500000000403513107004621020260 0ustar jromanjroman SVDGetBV

slepc-3.7.4 2017-05-17

SVDGetBV

Obtain the basis vectors objects associated to the singular value solver object.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetBV(SVD svd,BV *V,BV *U)
Not Collective

Input Parameters

svd  - singular value solver context obtained from SVDCreate()

Output Parameter

V  - basis vectors context for right singular vectors
U  - basis vectors context for left singular vectors

See Also

SVDSetBV()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetOptionsPrefix.html0000644000175000017500000000511213107004621022573 0ustar jromanjroman SVDSetOptionsPrefix

slepc-3.7.4 2017-05-17

SVDSetOptionsPrefix

Sets the prefix used for searching for all SVD options in the database.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetOptionsPrefix(SVD svd,const char *prefix)
Logically Collective on SVD

Input Parameters

svd  - the singular value solver context
prefix  - the prefix string to prepend to all SVD option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

For example, to distinguish between the runtime options for two different SVD contexts, one could call

      SVDSetOptionsPrefix(svd1,"svd1_")
      SVDSetOptionsPrefix(svd2,"svd2_")

See Also

SVDAppendOptionsPrefix(), SVDGetOptionsPrefix()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetIterationNumber.html0000644000175000017500000000564413107004621023067 0ustar jromanjroman SVDGetIterationNumber

slepc-3.7.4 2017-05-17

SVDGetIterationNumber

Gets the current iteration number. If the call to SVDSolve() is complete, then it returns the number of iterations carried out by the solution method.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetIterationNumber(SVD svd,PetscInt *its)
Not Collective

Input Parameter

svd  - the singular value solver context

Output Parameter

its  - number of iterations

Note

During the i-th iteration this call returns i-1. If SVDSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call SVDGetConvergedReason() to determine if the solver converged or failed and why.

See Also

SVDGetConvergedReason(), SVDSetTolerances()

Location: src/svd/interface/svdsolve.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDConvergedReason.html0000644000175000017500000000361213107004621022375 0ustar jromanjroman SVDConvergedReason
slepc-3.7.4 2017-05-17

SVDConvergedReason

Reason a singular value solver was said to have converged or diverged

Synopsis

typedef enum {/* converged */
              SVD_CONVERGED_TOL                =  1,
              SVD_CONVERGED_USER               =  2,
              /* diverged */
              SVD_DIVERGED_ITS                 = -1,
              SVD_DIVERGED_BREAKDOWN           = -2,
              SVD_CONVERGED_ITERATING          =  0 } SVDConvergedReason;

See Also

SVDSolve(), SVDGetConvergedReason(), SVDSetTolerances()

Location: src/svd/../../include/slepcsvd.h
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDErrorView.html0000644000175000017500000000566013107004621021242 0ustar jromanjroman SVDErrorView

slepc-3.7.4 2017-05-17

SVDErrorView

Displays the errors associated with the computed solution (as well as the singular values).

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDErrorView(SVD svd,SVDErrorType etype,PetscViewer viewer)
Collective on SVD

Input Parameters

svd  - the singular value solver context
etype  - error type
viewer  - optional visualization context

Options Database Key

-svd_error_absolute  - print absolute errors of each singular triplet
-svd_error_relative  - print relative errors of each singular triplet

Notes

By default, this function checks the error of all singular triplets and prints the singular values if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with singular values and corresponding errors is printed.

See Also

SVDSolve(), SVDValuesView(), SVDVectorsView()

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex14.c.html
slepc-3.7.4/docs/manualpages/SVD/SVDCyclicSetEPS.html0000644000175000017500000000351113107004621021541 0ustar jromanjroman SVDCyclicSetEPS
slepc-3.7.4 2017-05-17

SVDCyclicSetEPS

Associate an eigensolver object (EPS) to the singular value solver.

Synopsis

#include "slepcsvd.h" 
#include "slepceps.h" 
PetscErrorCode SVDCyclicSetEPS(SVD svd,EPS eps)
Collective on SVD

Input Parameters

svd  - singular value solver
eps  - the eigensolver object

See Also

SVDCyclicGetEPS()

Location: src/svd/impls/cyclic/cyclic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDConv.html0000644000175000017500000000301713107004621020215 0ustar jromanjroman SVDConv

slepc-3.7.4 2017-05-17

SVDConv

Determines the convergence test

Synopsis

typedef enum { SVD_CONV_ABS,
               SVD_CONV_REL,
               SVD_CONV_USER } SVDConv;

See Also

SVDSetConvergenceTest(), SVDSetConvergenceTestFunction()

Location: src/svd/../../include/slepcsvd.h
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDErrorType.html0000644000175000017500000000267113107004621021250 0ustar jromanjroman SVDErrorType

slepc-3.7.4 2017-05-17

SVDErrorType

The error type used to assess accuracy of computed solutions

Synopsis

typedef enum { SVD_ERROR_ABSOLUTE,
               SVD_ERROR_RELATIVE } SVDErrorType;

See Also

SVDComputeError()

Location: src/svd/../../include/slepcsvd.h
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetSingularTriplet.html0000644000175000017500000000706613107004621023110 0ustar jromanjroman SVDGetSingularTriplet

slepc-3.7.4 2017-05-17

SVDGetSingularTriplet

Gets the i-th triplet of the singular value decomposition as computed by SVDSolve(). The solution consists in the singular value and its left and right singular vectors.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetSingularTriplet(SVD svd,PetscInt i,PetscReal *sigma,Vec u,Vec v)
Not Collective, but vectors are shared by all processors that share the SVD

Input Parameters

svd  - singular value solver context
i  - index of the solution

Output Parameters

sigma  - singular value
u  - left singular vector
v  - right singular vector

Note

Both U or V can be NULL if singular vectors are not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs().

The index i should be a value between 0 and nconv-1 (see SVDGetConverged()). Singular triplets are indexed according to the ordering criterion established with SVDSetWhichSingularTriplets().

See Also

SVDSolve(), SVDGetConverged(), SVDSetWhichSingularTriplets()

Location: src/svd/interface/svdsolve.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVD.html0000644000175000017500000000273313107004621017373 0ustar jromanjroman SVD
slepc-3.7.4 2017-05-17

SVD

Abstract SLEPc object that manages all the singular value problem solvers.

Synopsis

typedef struct _p_SVD* SVD;

See Also

SVDCreate()

Location: src/svd/../../include/slepcsvd.h
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDValuesViewFromOptions.html0000644000175000017500000000316213107004621023603 0ustar jromanjroman SVDValuesViewFromOptions
slepc-3.7.4 2017-05-17

SVDValuesViewFromOptions

Processes command line options to determine if/how the computed singular values are to be viewed.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDValuesViewFromOptions(SVD svd)
Collective on SVD

Input Parameters

svd  - the singular value solver context

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDMonitorCancel.html0000644000175000017500000000421513107004621022046 0ustar jromanjroman SVDMonitorCancel

slepc-3.7.4 2017-05-17

SVDMonitorCancel

Clears all monitors for an SVD object.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDMonitorCancel(SVD svd)
Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()

Options Database Key

-svd_monitor_cancel  - Cancels all monitors that have been hardwired into a code by calls to SVDMonitorSet(), but does not cancel those set via the options database.

See Also

SVDMonitorSet()

Location: src/svd/interface/svdmon.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDErrorViewFromOptions.html0000644000175000017500000000316313107004621023436 0ustar jromanjroman SVDErrorViewFromOptions

slepc-3.7.4 2017-05-17

SVDErrorViewFromOptions

Processes command line options to determine if/how the errors of the computed solution are to be viewed.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDErrorViewFromOptions(SVD svd)
Collective on SVD

Input Parameters

svd  - the singular value solver context

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetBV.html0000644000175000017500000000422013107004621020270 0ustar jromanjroman SVDSetBV

slepc-3.7.4 2017-05-17

SVDSetBV

Associates basis vectors objects to the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetBV(SVD svd,BV V,BV U)
Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
V  - the basis vectors object for right singular vectors
U  - the basis vectors object for left singular vectors

Note

Use SVDGetBV() to retrieve the basis vectors contexts (for example, to free them at the end of the computations).

See Also

SVDGetBV()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetImplicitTranspose.html0000644000175000017500000000416413107004621023425 0ustar jromanjroman SVDGetImplicitTranspose

slepc-3.7.4 2017-05-17

SVDGetImplicitTranspose

Gets the mode used to handle the transpose of the matrix associated with the singular value problem.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetImplicitTranspose(SVD svd,PetscBool *impl)
Not Collective

Input Parameter

svd  - the singular value solver context

Output Parameter

impl  - how to handle the transpose (implicitly or not)

See Also

SVDSetImplicitTranspose(), SVDSolve(), SVDSetOperator()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDStoppingBasic.html0000644000175000017500000000700213107004621022053 0ustar jromanjroman SVDStoppingBasic

slepc-3.7.4 2017-05-17

SVDStoppingBasic

Default routine to determine whether the outer singular value solver iteration must be stopped.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDStoppingBasic(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)
Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged singular triplets
nsv  - number of requested singular triplets
ctx  - context (not used here)

Output Parameter

reason  - result of the stopping test

Notes

A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to SVD_CONVERGED_ITERATING (zero).

SVDStoppingBasic() will stop if all requested singular values are converged, or if the maximum number of iterations has been reached.

Use SVDSetStoppingTest() to provide your own test instead of using this one.

See Also

SVDSetStoppingTest(), SVDConvergedReason, SVDGetConvergedReason()

Location: src/svd/interface/svddefault.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetDS.html0000644000175000017500000000356713107004621020270 0ustar jromanjroman SVDGetDS

slepc-3.7.4 2017-05-17

SVDGetDS

Obtain the direct solver object associated to the singular value solver object.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetDS(SVD svd,DS *ds)
Not Collective

Input Parameters

svd  - singular value solver context obtained from SVDCreate()

Output Parameter

ds  - direct solver context

See Also

SVDSetDS()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetInitialSpaceLeft.html0000644000175000017500000000521313107004621023144 0ustar jromanjroman SVDSetInitialSpaceLeft

slepc-3.7.4 2017-05-17

SVDSetInitialSpaceLeft

Specify a basis of vectors that constitute the initial left space, that is, a rough approximation to the left singular subspace from which the solver starts to iterate.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetInitialSpaceLeft(SVD svd,PetscInt n,Vec *is)
Collective on SVD and Vec

Input Parameter

svd  - the singular value solver context
n  - number of vectors
is  - set of basis vectors of the initial space

Notes

Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored.

These vectors do not persist from one SVDSolve() call to the other, so the initial space should be set every time.

The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally.

Common usage of this function is when the user can provide a rough approximation of the wanted singular space. Then, convergence may be faster.

See Also

SVDSetInitialSpace()

Location: src/svd/interface/svdsetup.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetOptionsPrefix.html0000644000175000017500000000432213107004621022561 0ustar jromanjroman SVDGetOptionsPrefix

slepc-3.7.4 2017-05-17

SVDGetOptionsPrefix

Gets the prefix used for searching for all SVD options in the database.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetOptionsPrefix(SVD svd,const char *prefix[])
Not Collective

Input Parameters

svd  - the singular value solver context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

SVDSetOptionsPrefix(), SVDAppendOptionsPrefix()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDDestroy.html0000644000175000017500000000436513107004621020750 0ustar jromanjroman SVDDestroy

slepc-3.7.4 2017-05-17

SVDDestroy

Destroys the SVD context.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDDestroy(SVD *svd)
Collective on SVD

Input Parameter

svd  - singular value solver context obtained from SVDCreate()

See Also

SVDCreate(), SVDSetUp(), SVDSolve()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDSetFromOptions.html0000644000175000017500000000447413107004621022253 0ustar jromanjroman SVDSetFromOptions
slepc-3.7.4 2017-05-17

SVDSetFromOptions

Sets SVD options from the options database. This routine must be called before SVDSetUp() if the user is to be allowed to set the solver type.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetFromOptions(SVD svd)
Collective on SVD

Input Parameters

svd  - the singular value solver context

Notes

To see all options, run your program with the -help option.

See Also


Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDGetMonitorContext.html0000644000175000017500000000377613107004621022760 0ustar jromanjroman SVDGetMonitorContext
slepc-3.7.4 2017-05-17

SVDGetMonitorContext

Gets the monitor context, as set by SVDMonitorSet() for the FIRST monitor only.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetMonitorContext(SVD svd,void **ctx)
Not Collective

Input Parameter

svd  - singular value solver context obtained from SVDCreate()

Output Parameter

ctx  - monitor context

See Also

SVDMonitorSet()

Location: src/svd/interface/svdmon.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDWhich.html0000644000175000017500000000306013107004621020350 0ustar jromanjroman SVDWhich

slepc-3.7.4 2017-05-17

SVDWhich

Determines whether largest or smallest singular triplets are to be computed

Synopsis

typedef enum { SVD_LARGEST,
               SVD_SMALLEST } SVDWhich;

See Also

SVDSetWhichSingularTriplets(), SVDGetWhichSingularTriplets()

Location: src/svd/../../include/slepcsvd.h
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDVectorsView.html0000644000175000017500000000415013107004621021567 0ustar jromanjroman SVDVectorsView

slepc-3.7.4 2017-05-17

SVDVectorsView

Outputs computed singular vectors to a viewer.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDVectorsView(SVD svd,PetscViewer viewer)
Collective on SVD

Parameter

svd  - the singular value solver context
viewer  - the viewer

Options Database Keys

-svd_view_vectors  - output singular vectors

See Also

SVDSolve(), SVDValuesView(), SVDErrorView()

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDTRLanczosSetOneSide.html0000644000175000017500000000465513107004621023123 0ustar jromanjroman SVDTRLanczosSetOneSide

slepc-3.7.4 2017-05-17

SVDTRLanczosSetOneSide

Indicate if the variant of the Lanczos method to be used is one-sided or two-sided.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDTRLanczosSetOneSide(SVD svd,PetscBool oneside)
Logically Collective on SVD

Input Parameters

svd  - singular value solver
oneside  - boolean flag indicating if the method is one-sided or not

Options Database Key

-svd_trlanczos_oneside <boolean>  - Indicates the boolean flag

Note

By default, a two-sided variant is selected, which is sometimes slightly more robust. However, the one-sided variant is faster because it avoids the orthogonalization associated to left singular vectors.

See Also

SVDLanczosSetOneSide()

Location: src/svd/impls/trlanczos/trlanczos.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDMonitorSetFromOptions.html0000644000175000017500000000536513107004621023623 0ustar jromanjroman SVDMonitorSetFromOptions

slepc-3.7.4 2017-05-17

SVDMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
Collective on SVD

Input Parameters

svd  - the singular value solver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a PetscViewerAndFormat
trackall  - whether this monitor tracks all singular values or not

See Also

SVDMonitorSet(), SVDSetTrackAll(), SVDConvMonitorSetFromOptions()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDMonitorAll.html0000644000175000017500000000517613107004621021400 0ustar jromanjroman SVDMonitorAll

slepc-3.7.4 2017-05-17

SVDMonitorAll

Print the current approximate values and error estimates at each iteration of the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDMonitorAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on SVD

Input Parameters

svd  - singular value solver context
its  - iteration number
nconv  - number of converged singular triplets so far
sigma  - singular values
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

SVDMonitorSet(), SVDMonitorFirst(), SVDMonitorConverged()

Location: src/svd/interface/svdmon.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDReasonViewFromOptions.html0000644000175000017500000000321713107004621023574 0ustar jromanjroman SVDReasonViewFromOptions

slepc-3.7.4 2017-05-17

SVDReasonViewFromOptions

Processes command line options to determine if/how the SVD converged reason is to be viewed.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDReasonViewFromOptions(SVD svd)
Collective on SVD

Input Parameters

svd  - the singular value solver context

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDConvMonitorSetFromOptions.html0000644000175000017500000000510713107004621024443 0ustar jromanjroman SVDConvMonitorSetFromOptions

slepc-3.7.4 2017-05-17

SVDConvMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence).

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDConvMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor))
Collective on SVD

Input Parameters

svd  - the singular value solver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a SlepcConvMonitor

See Also

SVDMonitorSet(), SVDMonitorSetFromOptions()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDCyclicGetEPS.html0000644000175000017500000000364313107004621021533 0ustar jromanjroman SVDCyclicGetEPS

slepc-3.7.4 2017-05-17

SVDCyclicGetEPS

Retrieve the eigensolver object (EPS) associated to the singular value solver.

Synopsis

#include "slepcsvd.h" 
#include "slepceps.h" 
PetscErrorCode SVDCyclicGetEPS(SVD svd,EPS *eps)
Not Collective

Input Parameter

svd  - singular value solver

Output Parameter

eps  - the eigensolver object

See Also

SVDCyclicSetEPS()

Location: src/svd/impls/cyclic/cyclic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDMonitorFirst.html0000644000175000017500000000521613107004621021752 0ustar jromanjroman SVDMonitorFirst

slepc-3.7.4 2017-05-17

SVDMonitorFirst

Print the first unconverged approximate values and error estimates at each iteration of the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDMonitorFirst(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on SVD

Input Parameters

svd  - singular value solver context
its  - iteration number
nconv  - number of converged singular triplets so far
sigma  - singular values
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

SVDMonitorSet(), SVDMonitorAll(), SVDMonitorConverged()

Location: src/svd/interface/svdmon.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSolve.html0000644000175000017500000000654513107004621020411 0ustar jromanjroman SVDSolve

slepc-3.7.4 2017-05-17

SVDSolve

Solves the singular value problem.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSolve(SVD svd)
Collective on SVD

Input Parameter

svd  - singular value solver context obtained from SVDCreate()

Options Database Keys

-svd_view  - print information about the solver used
-svd_view_mat binary  - save the matrix to the default binary viewer
-svd_view_vectors binary  - save the computed singular vectors to the default binary viewer
-svd_view_values  - print computed singular values
-svd_converged_reason  - print reason for convergence, and number of iterations
-svd_error_absolute  - print absolute errors of each singular triplet
-svd_error_relative  - print relative errors of each singular triplet

See Also

SVDCreate(), SVDSetUp(), SVDDestroy()

Location: src/svd/interface/svdsolve.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDSetDimensions.html0000644000175000017500000000672713107004621022107 0ustar jromanjroman SVDSetDimensions
slepc-3.7.4 2017-05-17

SVDSetDimensions

Sets the number of singular values to compute and the dimension of the subspace.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetDimensions(SVD svd,PetscInt nsv,PetscInt ncv,PetscInt mpd)
Logically Collective on SVD

Input Parameters

svd  - the singular value solver context
nsv  - number of singular values to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

Options Database Keys

-svd_nsv <nsv>  - Sets the number of singular values
-svd_ncv <ncv>  - Sets the dimension of the subspace
-svd_mpd <mpd>  - Sets the maximum projected dimension

Notes

Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method and the number of singular values required.

The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nsv is small, the user sets ncv (a reasonable default is 2*nsv); and (b) in cases where nsv is large, the user sets mpd.

The value of ncv should always be between nsv and (nsv+mpd), typically ncv=nsv+mpd. If nsv is not too large, mpd=nsv is a reasonable choice, otherwise a smaller value should be used.

See Also

SVDGetDimensions()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
slepc-3.7.4/docs/manualpages/SVD/SVDMonitorSet.html0000644000175000017500000001213613107004621021415 0ustar jromanjroman SVDMonitorSet
slepc-3.7.4 2017-05-17

SVDMonitorSet

Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested singular triplet.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDMonitorSet(SVD svd,PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
monitor  - pointer to function (if this is NULL, it turns off monitoring)
mctx  - [optional] context for private data for the monitor routine (use NULL if no context is desired)

Calling Sequence of monitor

  monitor(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *mctx)

svd  - singular value solver context obtained from SVDCreate()
its  - iteration number
nconv  - number of converged singular triplets
sigma  - singular values
errest  - relative error estimates for each singular triplet
nest  - number of error estimates
mctx  - optional monitoring context, as set by SVDMonitorSet()

Options Database Keys

-svd_monitor  - print only the first error estimate
-svd_monitor_all  - print error estimates at each iteration
-svd_monitor_conv  - print the singular value approximations only when convergence has been reached
-svd_monitor_lg  - sets line graph monitor for the first unconverged approximate singular value
-svd_monitor_lg_all  - sets line graph monitor for all unconverged approximate singular values
-svd_monitor_cancel  - cancels all monitors that have been hardwired into a code by calls to SVDMonitorSet(), but does not cancel those set via the options database.

Notes

Several different monitoring routines may be set by calling SVDMonitorSet() multiple times; all will be called in the order in which they were set.

See Also

SVDMonitorFirst(), SVDMonitorAll(), SVDMonitorCancel()

Location: src/svd/interface/svdmon.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDTRLanczosGetOneSide.html0000644000175000017500000000375513107004621023107 0ustar jromanjroman SVDTRLanczosGetOneSide

slepc-3.7.4 2017-05-17

SVDTRLanczosGetOneSide

Gets if the variant of the Lanczos method to be used is one-sided or two-sided.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDTRLanczosGetOneSide(SVD svd,PetscBool *oneside)
Not Collective

Input Parameters

svd  - singular value solver

Output Parameters

oneside  - boolean flag indicating if the method is one-sided or not

See Also

SVDTRLanczosSetOneSide()

Location: src/svd/impls/trlanczos/trlanczos.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetDS.html0000644000175000017500000000374513107004621020302 0ustar jromanjroman SVDSetDS

slepc-3.7.4 2017-05-17

SVDSetDS

Associates a direct solver object to the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetDS(SVD svd,DS ds)
Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
ds  - the direct solver object

Note

Use SVDGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations).

See Also

SVDGetDS()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDInitializePackage.html0000644000175000017500000000312513107004621022665 0ustar jromanjroman SVDInitializePackage

slepc-3.7.4 2017-05-17

SVDInitializePackage

This function initializes everything in the SVD package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to SVDCreate() when using static libraries.

Synopsis

PetscErrorCode SVDInitializePackage(void)

See Also

SlepcInitialize()

Location: src/svd/interface/dlregissvd.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDType.html0000644000175000017500000000302313107004621020226 0ustar jromanjroman SVDType

slepc-3.7.4 2017-05-17

SVDType

String with the name of a SLEPc singular value solver

Synopsis

typedef const char* SVDType;
#define SVDCROSS       "cross"
#define SVDCYCLIC      "cyclic"
#define SVDLAPACK      "lapack"
#define SVDLANCZOS     "lanczos"
#define SVDTRLANCZOS   "trlanczos"

See Also

SVDSetType(), SVD

Location: src/svd/../../include/slepcsvd.h
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetDimensions.html0000644000175000017500000000525313107004621022064 0ustar jromanjroman SVDGetDimensions

slepc-3.7.4 2017-05-17

SVDGetDimensions

Gets the number of singular values to compute and the dimension of the subspace.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetDimensions(SVD svd,PetscInt *nsv,PetscInt *ncv,PetscInt *mpd)
Not Collective

Input Parameter

svd  - the singular value context

Output Parameters

nsv  - number of singular values to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

Notes

The user can specify NULL for any parameter that is not needed.

See Also

SVDSetDimensions()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDLanczosGetOneSide.html0000644000175000017500000000372713107004621022640 0ustar jromanjroman SVDLanczosGetOneSide
slepc-3.7.4 2017-05-17

SVDLanczosGetOneSide

Gets if the variant of the Lanczos method to be used is one-sided or two-sided.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDLanczosGetOneSide(SVD svd,PetscBool *oneside)
Not Collective

Input Parameters

svd  - singular value solver

Output Parameters

oneside  - boolean flag indicating if the method is one-sided or not

See Also

SVDLanczosSetOneSide()

Location: src/svd/impls/lanczos/gklanczos.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetTolerances.html0000644000175000017500000000514213107004621022064 0ustar jromanjroman SVDSetTolerances

slepc-3.7.4 2017-05-17

SVDSetTolerances

Sets the tolerance and maximum iteration count used by the default SVD convergence testers.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetTolerances(SVD svd,PetscReal tol,PetscInt maxits)
Logically Collective on SVD

Input Parameters

svd  - the singular value solver context
tol  - the convergence tolerance
maxits  - maximum number of iterations to use

Options Database Keys

-svd_tol <tol>  - Sets the convergence tolerance
-svd_max_it <maxits>  - Sets the maximum number of iterations allowed (use PETSC_DECIDE to compute an educated guess based on basis and matrix sizes)

Note

Use PETSC_DEFAULT for either argument to assign a reasonably good value.

See Also

SVDGetTolerances()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDRegisterAll.html0000644000175000017500000000262713107004621021533 0ustar jromanjroman SVDRegisterAll

slepc-3.7.4 2017-05-17

SVDRegisterAll

Registers all the singular value solvers in the SVD package.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDRegisterAll(void)
Not Collective

See Also

SVDRegister()

Location: src/svd/interface/svdregis.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetUp.html0000644000175000017500000000400613107004621020347 0ustar jromanjroman SVDSetUp

slepc-3.7.4 2017-05-17

SVDSetUp

Sets up all the internal data structures necessary for the execution of the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetUp(SVD svd)
Collective on SVD

Input Parameter

svd  - singular value solver context

Notes

This function need not be called explicitly in most cases, since SVDSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time.

See Also

SVDCreate(), SVDSolve(), SVDDestroy()

Location: src/svd/interface/svdsetup.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetWhichSingularTriplets.html0000644000175000017500000000442713107004621024254 0ustar jromanjroman SVDGetWhichSingularTriplets

slepc-3.7.4 2017-05-17

SVDGetWhichSingularTriplets

Returns which singular triplets are to be sought.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetWhichSingularTriplets(SVD svd,SVDWhich *which)
Not Collective

Input Parameter

svd  - singular value solver context obtained from SVDCreate()

Output Parameter

which  - which singular triplets are to be sought

Notes

See SVDSetWhichSingularTriplets() for possible values of which

See Also

SVDSetWhichSingularTriplets(), SVDWhich

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDComputeError.html0000644000175000017500000000542113107004621021737 0ustar jromanjroman SVDComputeError

slepc-3.7.4 2017-05-17

SVDComputeError

Computes the error (based on the residual norm) associated with the i-th singular triplet.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDComputeError(SVD svd,PetscInt i,SVDErrorType type,PetscReal *error)
Collective on SVD

Input Parameter

svd  - the singular value solver context
i  - the solution index
type  - the type of error to compute

Output Parameter

error  - the error

Notes

The error can be computed in various ways, all of them based on the residual norm obtained as sqrt(n1^2+n2^2) with n1 = ||A*v-sigma*u||_2 and n2 = ||A^T*u-sigma*v||_2, where sigma is the singular value, u is the left singular vector and v is the right singular vector.

See Also

SVDErrorType, SVDSolve()

Location: src/svd/interface/svdsolve.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDLanczosSetOneSide.html0000644000175000017500000000473513107004621022654 0ustar jromanjroman SVDLanczosSetOneSide
slepc-3.7.4 2017-05-17

SVDLanczosSetOneSide

Indicate if the variant of the Lanczos method to be used is one-sided or two-sided.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDLanczosSetOneSide(SVD svd,PetscBool oneside)
Logically Collective on SVD

Input Parameters

svd  - singular value solver
oneside  - boolean flag indicating if the method is one-sided or not

Options Database Key

-svd_lanczos_oneside <boolean>  - Indicates the boolean flag

Note

By default, a two-sided variant is selected, which is sometimes slightly more robust. However, the one-sided variant is faster because it avoids the orthogonalization associated to left singular vectors. It also saves the memory required for storing such vectors.

See Also

SVDTRLanczosSetOneSide()

Location: src/svd/impls/lanczos/gklanczos.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetOperator.html0000644000175000017500000000447413107004621021567 0ustar jromanjroman SVDSetOperator

slepc-3.7.4 2017-05-17

SVDSetOperator

Set the matrix associated with the singular value problem.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetOperator(SVD svd,Mat mat)
Collective on SVD and Mat

Input Parameters

svd  - the singular value solver context
A  - the matrix associated with the singular value problem

See Also

SVDSolve(), SVDGetOperator()

Location: src/svd/interface/svdsetup.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDSetInitialSpace.html0000644000175000017500000000520313107004621022330 0ustar jromanjroman SVDSetInitialSpace
slepc-3.7.4 2017-05-17

SVDSetInitialSpace

Specify a basis of vectors that constitute the initial (right) space, that is, a rough approximation to the right singular subspace from which the solver starts to iterate.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetInitialSpace(SVD svd,PetscInt n,Vec *is)
Collective on SVD and Vec

Input Parameter

svd  - the singular value solver context
n  - number of vectors
is  - set of basis vectors of the initial space

Notes

Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored.

These vectors do not persist from one SVDSolve() call to the other, so the initial space should be set every time.

The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally.

Common usage of this function is when the user can provide a rough approximation of the wanted singular space. Then, convergence may be faster.

See Also

SVDSetInitialSpaceLeft()

Location: src/svd/interface/svdsetup.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDReasonView.html0000644000175000017500000000451213107004621021373 0ustar jromanjroman SVDReasonView

slepc-3.7.4 2017-05-17

SVDReasonView

Displays the reason an SVD solve converged or diverged.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDReasonView(SVD svd,PetscViewer viewer)
Collective on SVD

Parameter

svd  - the singular value solver context
viewer  - the viewer to display the reason

Options Database Keys

-svd_converged_reason  - print reason for convergence, and number of iterations

See Also

SVDSetTolerances(), SVDGetIterationNumber()

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex14.c.html
slepc-3.7.4/docs/manualpages/SVD/SVDRegister.html0000644000175000017500000000447213107004621021102 0ustar jromanjroman SVDRegister
slepc-3.7.4 2017-05-17

SVDRegister

Adds a method to the singular value solver package.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDRegister(const char *name,PetscErrorCode (*function)(SVD))
Not Collective

Input Parameters

name  - name of a new user-defined solver
function  - routine to create the solver context

Notes

SVDRegister() may be called multiple times to add several user-defined solvers.

Sample usage

    SVDRegister("my_solver",MySolverCreate);

Then, your solver can be chosen with the procedural interface via

    SVDSetType(svd,"my_solver")
or at runtime via the option
    -svd_type my_solver

See Also

SVDRegisterAll()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetConvergenceTestFunction.html0000644000175000017500000000725413107004621024577 0ustar jromanjroman SVDSetConvergenceTestFunction

slepc-3.7.4 2017-05-17

SVDSetConvergenceTestFunction

Sets a function to compute the error estimate used in the convergence test.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetConvergenceTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscReal,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
func  - a pointer to the convergence test function
ctx  - context for private data for the convergence routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)

svd  - singular value solver context obtained from SVDCreate()
sigma  - computed singular value
res  - residual norm associated to the singular triplet
errest  - (output) computed error estimate
ctx  - optional context, as set by SVDSetConvergenceTestFunction()

Note

If the error estimate returned by the convergence test function is less than the tolerance, then the singular value is accepted as converged.

See Also

SVDSetConvergenceTest(), SVDSetTolerances()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetConvergenceTest.html0000644000175000017500000000406213107004621023047 0ustar jromanjroman SVDGetConvergenceTest

slepc-3.7.4 2017-05-17

SVDGetConvergenceTest

Gets the method used to compute the error estimate used in the convergence test.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetConvergenceTest(SVD svd,SVDConv *conv)
Not Collective

Input Parameters

svd  - singular value solver context obtained from SVDCreate()

Output Parameters

conv  - the type of convergence test

See Also

SVDSetConvergenceTest(), SVDConv

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/index.html0000644000175000017500000002033013107004621020037 0ustar jromanjroman Singular Value Decomposition Solvers - SVD

slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

Beginner - Basic usage
SVD SVDGetConverged SVDSolve
SVDComputeError SVDGetSingularTriplet SVDType
SVDCreate SVDSetFromOptions SVDView
SVDDestroy SVDSetOperator
Intermediate - Setting options for algorithms and data structures
SVDConv SVDGetType SVDSetDimensions
SVDConvergedReason SVDGetWhichSingularTriplets SVDSetInitialSpace
SVDErrorType SVDMonitorAll SVDSetInitialSpaceLeft
SVDErrorView SVDMonitorCancel SVDSetTolerances
SVDGetConvergedReason SVDMonitorConverged SVDSetType
SVDGetConvergenceTest SVDMonitorFirst SVDSetWhichSingularTriplets
SVDGetDimensions SVDMonitorLGCreate SVDValuesView
SVDGetIterationNumber SVDMonitorSet SVDVectorsView
SVDGetMonitorContext SVDReasonView SVDWhich
SVDGetTolerances SVDSetConvergenceTest
Advanced - Setting more advanced options and customization
SVDAppendOptionsPrefix SVDGetOperator SVDSetDS
SVDCrossGetEPS SVDGetOptionsPrefix SVDSetImplicitTranspose
SVDCrossSetEPS SVDGetStoppingTest SVDSetOptionsPrefix
SVDCyclicGetEPS SVDLanczosGetOneSide SVDSetStoppingTest
SVDCyclicGetExplicitMatrix SVDLanczosSetOneSide SVDSetStoppingTestFunction
SVDCyclicSetEPS SVDRegister SVDStop
SVDCyclicSetExplicitMatrix SVDRegisterAll SVDStoppingBasic
SVDGetBV SVDReset SVDTRLanczosGetOneSide
SVDGetDS SVDSetBV SVDTRLanczosSetOneSide
SVDGetImplicitTranspose SVDSetConvergenceTestFunction
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
SVDAllocateSolution SVDGetTrackAll SVDSetTrackAll
SVDConvMonitorSetFromOptions SVDInitializePackage SVDSetUp
SVDErrorViewFromOptions SVDMonitorSetFromOptions SVDValuesViewFromOptions
SVDFinalizePackage SVDReasonViewFromOptions SVDVectorsViewFromOptions
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/SVD/SVDMonitorConverged.html0000644000175000017500000000512513107004621022576 0ustar jromanjroman SVDMonitorConverged

slepc-3.7.4 2017-05-17

SVDMonitorConverged

Print the approximate values and error estimates as they converge.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDMonitorConverged(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
Collective on SVD

Input Parameters

svd  - singular value solver context
its  - iteration number
nconv  - number of converged singular triplets so far
sigma  - singular values
errest  - error estimates
nest  - number of error estimates to display
ctx  - monitor context

See Also

SVDMonitorSet(), SVDMonitorFirst(), SVDMonitorAll()

Location: src/svd/interface/svdmon.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDValuesView.html0000644000175000017500000000416513107004621021407 0ustar jromanjroman SVDValuesView

slepc-3.7.4 2017-05-17

SVDValuesView

Displays the computed singular values in a viewer.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDValuesView(SVD svd,PetscViewer viewer)
Collective on SVD

Input Parameters

svd  - the singular value solver context
viewer  - the viewer

Options Database Key

-svd_view_values  - print computed singular values

See Also

SVDSolve(), SVDVectorsView(), SVDErrorView()

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDAllocateSolution.html0000644000175000017500000000403313107004621022570 0ustar jromanjroman SVDAllocateSolution

slepc-3.7.4 2017-05-17

SVDAllocateSolution

Allocate memory storage for common variables such as the singular values and the basis vectors.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra)
Collective on SVD

Input Parameters

svd  - eigensolver context
extra  - number of additional positions, used for methods that require a working basis slightly larger than ncv

Developers Notes

This is PETSC_EXTERN because it may be required by user plugin SVD implementations.

This is called at setup after setting the value of ncv and the flag leftbasis.

Location: src/svd/interface/svdsetup.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDStop.html0000644000175000017500000000273713107004621020245 0ustar jromanjroman SVDStop

slepc-3.7.4 2017-05-17

SVDStop

Determines the stopping test

Synopsis

typedef enum { SVD_STOP_BASIC,
               SVD_STOP_USER } SVDStop;

See Also

SVDSetStoppingTest(), SVDSetStoppingTestFunction()

Location: src/svd/../../include/slepcsvd.h
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetStoppingTest.html0000644000175000017500000000603113107004621022426 0ustar jromanjroman SVDSetStoppingTest

slepc-3.7.4 2017-05-17

SVDSetStoppingTest

Specifies how to decide the termination of the outer loop of the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetStoppingTest(SVD svd,SVDStop stop)
Logically Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
stop  - the type of stopping test

Options Database Keys

-svd_stop_basic  - Sets the default stopping test
-svd_stop_user  - Selects the user-defined stopping test

Note

The parameter 'stop' can have one of these values
SVD_STOP_BASIC  - default stopping test
SVD_STOP_USER  - function set by SVDSetStoppingTestFunction()

See Also

SVDGetStoppingTest(), SVDSetStoppingTestFunction(), SVDSetConvergenceTest(), SVDStop

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetType.html0000644000175000017500000000576213107004621020716 0ustar jromanjroman SVDSetType

slepc-3.7.4 2017-05-17

SVDSetType

Selects the particular solver to be used in the SVD object.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetType(SVD svd,SVDType type)
Logically Collective on SVD

Input Parameters

svd  - the singular value solver context
type  - a known method

Options Database Key

-svd_type <method>  - Sets the method; use -help for a list of available methods

Notes

See "slepc/include/slepcsvd.h" for available methods. The default is SVDCROSS.

Normally, it is best to use the SVDSetFromOptions() command and then set the SVD type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The SVDSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database.

See Also

SVDType

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDSetTrackAll.html0000644000175000017500000000441713107004621021466 0ustar jromanjroman SVDSetTrackAll
slepc-3.7.4 2017-05-17

SVDSetTrackAll

Specifies if the solver must compute the residual norm of all approximate singular value or not.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetTrackAll(SVD svd,PetscBool trackall)
Logically Collective on SVD

Input Parameters

svd  - the singular value solver context
trackall  - whether to compute all residuals or not

Notes

If the user sets trackall=PETSC_TRUE then the solver computes (or estimates) the residual norm for each singular value approximation. Computing the residual is usually an expensive operation and solvers commonly compute only the residual associated to the first unconverged singular value.

The options '-svd_monitor_all' and '-svd_monitor_lg_all' automatically activate this option.

See Also

SVDGetTrackAll()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetOperator.html0000644000175000017500000000401213107004621021537 0ustar jromanjroman SVDGetOperator

slepc-3.7.4 2017-05-17

SVDGetOperator

Get the matrix associated with the singular value problem.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetOperator(SVD svd,Mat *A)
Not collective, though parallel Mats are returned if the SVD is parallel

Input Parameter

svd  - the singular value solver context

Output Parameters

A  - the matrix associated with the singular value problem

See Also

SVDSolve(), SVDSetOperator()

Location: src/svd/interface/svdsetup.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetWhichSingularTriplets.html0000644000175000017500000000606413107004621024267 0ustar jromanjroman SVDSetWhichSingularTriplets

slepc-3.7.4 2017-05-17

SVDSetWhichSingularTriplets

Specifies which singular triplets are to be sought.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetWhichSingularTriplets(SVD svd,SVDWhich which)
Logically Collective on SVD

Input Parameter

svd  - singular value solver context obtained from SVDCreate()

Output Parameter

which  - which singular triplets are to be sought

Possible values

The parameter 'which' can have one of these values

SVD_LARGEST  - largest singular values
SVD_SMALLEST  - smallest singular values

Options Database Keys

-svd_largest  - Sets largest singular values
-svd_smallest  - Sets smallest singular values

See Also

SVDGetWhichSingularTriplets(), SVDWhich

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
slepc-3.7.4/docs/manualpages/SVD/SVDCyclicGetExplicitMatrix.html0000644000175000017500000000373313107004621024052 0ustar jromanjroman SVDCyclicGetExplicitMatrix
slepc-3.7.4 2017-05-17

SVDCyclicGetExplicitMatrix

Returns the flag indicating if H(A) is built explicitly

Synopsis

#include "slepcsvd.h" 
#include "slepceps.h" 
PetscErrorCode SVDCyclicGetExplicitMatrix(SVD svd,PetscBool *explicitmatrix)
Not Collective

Input Parameter

svd  - singular value solver

Output Parameter

explicit  - the mode flag

See Also

SVDCyclicSetExplicitMatrix()

Location: src/svd/impls/cyclic/cyclic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDFinalizePackage.html0000644000175000017500000000276713107004621022340 0ustar jromanjroman SVDFinalizePackage

slepc-3.7.4 2017-05-17

SVDFinalizePackage

This function destroys everything in the Slepc interface to the SVD package. It is called from SlepcFinalize().

Synopsis

PetscErrorCode SVDFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/svd/interface/dlregissvd.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDView.html0000644000175000017500000000533213107004621020224 0ustar jromanjroman SVDView

slepc-3.7.4 2017-05-17

SVDView

Prints the SVD data structure.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDView(SVD svd,PetscViewer viewer)
Collective on SVD

Input Parameters

svd  - the singular value solver context
viewer  - optional visualization context

Options Database Key

-svd_view  - Calls SVDView() at end of SVDSolve()

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

See Also

STView(), PetscViewerASCIIOpen()

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDVectorsViewFromOptions.html0000644000175000017500000000317113107004621023771 0ustar jromanjroman SVDVectorsViewFromOptions

slepc-3.7.4 2017-05-17

SVDVectorsViewFromOptions

Processes command line options to determine if/how the computed singular vectors are to be viewed.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDVectorsViewFromOptions(SVD svd)
Collective on SVD

Input Parameters

svd  - the singular value solver context

Location: src/svd/interface/svdview.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDMonitorLGCreate.html0000644000175000017500000000600213107004621022303 0ustar jromanjroman SVDMonitorLGCreate

slepc-3.7.4 2017-05-17

SVDMonitorLGCreate

Creates a line graph context for use with SVD to monitor convergence.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
Collective on MPI_Comm

Input Parameters

comm  - communicator context
host  - the X display to open, or null for the local machine
label  - the title to put in the title bar
x, y  - the screen coordinates of the upper left coordinate of the window
m, n  - the screen width and height in pixels

Output Parameter

lgctx  - the drawing context

Options Database Keys

-svd_monitor_lg  - Sets line graph monitor for the first residual
-svd_monitor_lg_all  - Sets line graph monitor for all residuals

Notes

Use PetscDrawLGDestroy() to destroy this line graph.

See Also

SVDMonitorSet()

Location: src/svd/interface/svdmon.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetConvergedReason.html0000644000175000017500000000577713107004621023053 0ustar jromanjroman SVDGetConvergedReason

slepc-3.7.4 2017-05-17

SVDGetConvergedReason

Gets the reason why the SVDSolve() iteration was stopped.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetConvergedReason(SVD svd,SVDConvergedReason *reason)
Not Collective

Input Parameter

svd  - the singular value solver context

Output Parameter

reason  - negative value indicates diverged, positive value converged (see SVDConvergedReason)

Notes

Possible values for reason are
SVD_CONVERGED_TOL  - converged up to tolerance
SVD_CONVERGED_USER  - converged due to a user-defined condition
SVD_DIVERGED_ITS  - required more than max_it iterations to reach convergence
SVD_DIVERGED_BREAKDOWN  - generic breakdown in method

Can only be called after the call to SVDSolve() is complete.

See Also

SVDSetTolerances(), SVDSolve(), SVDConvergedReason

Location: src/svd/interface/svdsolve.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDCyclicSetExplicitMatrix.html0000644000175000017500000000436413107004621024067 0ustar jromanjroman SVDCyclicSetExplicitMatrix

slepc-3.7.4 2017-05-17

SVDCyclicSetExplicitMatrix

Indicate if the eigensolver operator H(A) = [ 0 A ; A^T 0 ] must be computed explicitly.

Synopsis

#include "slepcsvd.h" 
#include "slepceps.h" 
PetscErrorCode SVDCyclicSetExplicitMatrix(SVD svd,PetscBool explicitmatrix)
Logically Collective on SVD

Input Parameters

svd  - singular value solver
explicit  - boolean flag indicating if H(A) is built explicitly

Options Database Key

-svd_cyclic_explicitmatrix <boolean>  - Indicates the boolean flag

See Also

SVDCyclicGetExplicitMatrix()

Location: src/svd/impls/cyclic/cyclic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetTolerances.html0000644000175000017500000000503213107004621022046 0ustar jromanjroman SVDGetTolerances

slepc-3.7.4 2017-05-17

SVDGetTolerances

Gets the tolerance and maximum iteration count used by the default SVD convergence tests.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetTolerances(SVD svd,PetscReal *tol,PetscInt *maxits)
Not Collective

Input Parameter

svd  - the singular value solver context

Output Parameters

tol  - the convergence tolerance
maxits  - maximum number of iterations

Notes

The user can specify NULL for any parameter that is not needed.

See Also

SVDSetTolerances()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDSetImplicitTranspose.html0000644000175000017500000000542413107004621023441 0ustar jromanjroman SVDSetImplicitTranspose
slepc-3.7.4 2017-05-17

SVDSetImplicitTranspose

Indicates how to handle the transpose of the matrix associated with the singular value problem.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetImplicitTranspose(SVD svd,PetscBool impl)
Logically Collective on SVD

Input Parameters

svd  - the singular value solver context
impl  - how to handle the transpose (implicitly or not)

Options Database Key

-svd_implicittranspose  - Activate the implicit transpose mode.

Notes

By default, the transpose of the matrix is explicitly built (if the matrix has defined the MatTranspose operation).

If this flag is set to true, the solver does not build the transpose, but handles it implicitly via MatMultTranspose() (or MatMultHermitianTranspose() in the complex case) operations. This is likely to be more inefficient than the default behaviour, both in sequential and in parallel, but requires less storage.

See Also

SVDGetImplicitTranspose(), SVDSolve(), SVDSetOperator()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetConverged.html0000644000175000017500000000435713107004621021674 0ustar jromanjroman SVDGetConverged

slepc-3.7.4 2017-05-17

SVDGetConverged

Gets the number of converged singular values.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetConverged(SVD svd,PetscInt *nconv)
Not Collective

Input Parameter

svd  - the singular value solver context

Output Parameter

nconv  - number of converged singular values

Note

This function should be called after SVDSolve() has finished.

Location: src/svd/interface/svdsolve.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDCrossSetEPS.html0000644000175000017500000000347413107004621021434 0ustar jromanjroman SVDCrossSetEPS
slepc-3.7.4 2017-05-17

SVDCrossSetEPS

Associate an eigensolver object (EPS) to the singular value solver.

Synopsis

#include "slepcsvd.h" 
#include "slepceps.h" 
PetscErrorCode SVDCrossSetEPS(SVD svd,EPS eps)
Collective on SVD

Input Parameters

svd  - singular value solver
eps  - the eigensolver object

See Also

SVDCrossGetEPS()

Location: src/svd/impls/cross/cross.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetType.html0000644000175000017500000000440213107004621020670 0ustar jromanjroman SVDGetType

slepc-3.7.4 2017-05-17

SVDGetType

Gets the SVD type as a string from the SVD object.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetType(SVD svd,SVDType *type)
Not Collective

Input Parameter

svd  - the singular value solver context

Output Parameter

name  - name of SVD method

See Also

SVDSetType()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDGetTrackAll.html0000644000175000017500000000356513107004621021455 0ustar jromanjroman SVDGetTrackAll
slepc-3.7.4 2017-05-17

SVDGetTrackAll

Returns the flag indicating whether all residual norms must be computed or not.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetTrackAll(SVD svd,PetscBool *trackall)
Not Collective

Input Parameter

svd  - the singular value solver context

Output Parameter

trackall  - the returned flag

See Also

SVDSetTrackAll()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDGetStoppingTest.html0000644000175000017500000000404213107004621022412 0ustar jromanjroman SVDGetStoppingTest

slepc-3.7.4 2017-05-17

SVDGetStoppingTest

Gets the method used to decide the termination of the outer loop of the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDGetStoppingTest(SVD svd,SVDStop *stop)
Not Collective

Input Parameters

svd  - singular value solver context obtained from SVDCreate()

Output Parameters

stop  - the type of stopping test

See Also

SVDSetStoppingTest(), SVDStop

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetStoppingTestFunction.html0000644000175000017500000001027613107004621024142 0ustar jromanjroman SVDSetStoppingTestFunction

slepc-3.7.4 2017-05-17

SVDSetStoppingTestFunction

Sets a function to decide when to stop the outer iteration of the singular value solver.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetStoppingTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
func  - pointer to the stopping test function
ctx  - context for private data for the stopping routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)

svd  - singular value solver context obtained from SVDCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged singular triplets
nsv  - number of requested singular triplets
reason  - (output) result of the stopping test
ctx  - optional context, as set by SVDSetStoppingTestFunction()

Note

Normal usage is to first call the default routine SVDStoppingBasic() and then set reason to SVD_CONVERGED_USER if some user-defined conditions have been met. To let the singular value solver continue iterating, the result must be left as SVD_CONVERGED_ITERATING.

See Also

SVDSetStoppingTest(), SVDStoppingBasic()

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDSetConvergenceTest.html0000644000175000017500000000654413107004621023072 0ustar jromanjroman SVDSetConvergenceTest

slepc-3.7.4 2017-05-17

SVDSetConvergenceTest

Specifies how to compute the error estimate used in the convergence test.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDSetConvergenceTest(SVD svd,SVDConv conv)
Logically Collective on SVD

Input Parameters

svd  - singular value solver context obtained from SVDCreate()
conv  - the type of convergence test

Options Database Keys

-svd_conv_abs  - Sets the absolute convergence test
-svd_conv_rel  - Sets the convergence test relative to the singular value
-svd_conv_user  - Selects the user-defined convergence test

Note

The parameter 'conv' can have one of these values
SVD_CONV_ABS  - absolute error ||r||
SVD_CONV_REL  - error relative to the singular value l, ||r||/sigma
SVD_CONV_USER  - function set by SVDSetConvergenceTestFunction()

See Also

SVDGetConvergenceTest(), SVDSetConvergenceTestFunction(), SVDSetStoppingTest(), SVDConv

Location: src/svd/interface/svdopts.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDCrossGetEPS.html0000644000175000017500000000362613107004621021417 0ustar jromanjroman SVDCrossGetEPS

slepc-3.7.4 2017-05-17

SVDCrossGetEPS

Retrieve the eigensolver object (EPS) associated to the singular value solver.

Synopsis

#include "slepcsvd.h" 
#include "slepceps.h" 
PetscErrorCode SVDCrossGetEPS(SVD svd,EPS *eps)
Not Collective

Input Parameter

svd  - singular value solver

Output Parameter

eps  - the eigensolver object

See Also

SVDCrossSetEPS()

Location: src/svd/impls/cross/cross.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/SVD/SVDCreate.html0000644000175000017500000000510013107004621020506 0ustar jromanjroman SVDCreate

slepc-3.7.4 2017-05-17

SVDCreate

Creates the default SVD context.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDCreate(MPI_Comm comm,SVD *outsvd)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

svd  - location to put the SVD context

Note

The default SVD type is SVDCROSS

See Also

SVDSetUp(), SVDSolve(), SVDDestroy(), SVD

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/svd/examples/tutorials/ex8.c.html
src/svd/examples/tutorials/ex14.c.html
src/svd/examples/tutorials/ex15.c.html
src/svd/examples/tutorials/ex15f.F.html
slepc-3.7.4/docs/manualpages/SVD/SVDReset.html0000644000175000017500000000333213107004621020372 0ustar jromanjroman SVDReset
slepc-3.7.4 2017-05-17

SVDReset

Resets the SVD context to the initial state and removes any allocated objects.

Synopsis

#include "slepcsvd.h" 
PetscErrorCode SVDReset(SVD svd)
Collective on SVD

Input Parameter

svd  - singular value solver context obtained from SVDCreate()

See Also

SVDDestroy()

Location: src/svd/interface/svdbasic.c
Index of all SVD routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/0000755000175000017500000000000013107004621016030 5ustar jromanjromanslepc-3.7.4/docs/manualpages/MFN/MFNReasonView.html0000644000175000017500000000425313107004621021345 0ustar jromanjroman MFNReasonView

slepc-3.7.4 2017-05-17

MFNReasonView

Displays the reason an MFN solve converged or diverged.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNReasonView(MFN mfn,PetscViewer viewer)
Collective on MFN

Parameter

mfn  - the matrix function context
viewer  - the viewer to display the reason

Options Database Keys

-mfn_converged_reason  - print reason for convergence, and number of iterations

See Also

MFNSetTolerances(), MFNGetIterationNumber()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetIterationNumber.html0000644000175000017500000000531213107004621023027 0ustar jromanjroman MFNGetIterationNumber

slepc-3.7.4 2017-05-17

MFNGetIterationNumber

Gets the current iteration number. If the call to MFNSolve() is complete, then it returns the number of iterations carried out by the solution method.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetIterationNumber(MFN mfn,PetscInt *its)
Not Collective

Input Parameter

mfn  - the matrix function context

Output Parameter

its  - number of iterations

Note

During the i-th iteration this call returns i-1. If MFNSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call MFNGetConvergedReason() to determine if the solver converged or failed and why.

See Also

MFNGetConvergedReason(), MFNSetTolerances()

Location: src/mfn/interface/mfnsolve.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNRegisterAll.html0000644000175000017500000000262113107004621021475 0ustar jromanjroman MFNRegisterAll
slepc-3.7.4 2017-05-17

MFNRegisterAll

Registers all the matrix functions in the MFN package.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNRegisterAll(void)
Not Collective

See Also

MFNRegister()

Location: src/mfn/interface/mfnregis.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetMonitorContext.html0000644000175000017500000000377013107004621022722 0ustar jromanjroman MFNGetMonitorContext

slepc-3.7.4 2017-05-17

MFNGetMonitorContext

Gets the monitor context, as set by MFNMonitorSet() for the FIRST monitor only.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetMonitorContext(MFN mfn,void **ctx)
Not Collective

Input Parameter

mfn  - matrix function context obtained from MFNCreate()

Output Parameter

ctx  - monitor context

See Also

MFNMonitorSet()

Location: src/mfn/interface/mfnmon.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNFinalizePackage.html0000644000175000017500000000276713107004621022310 0ustar jromanjroman MFNFinalizePackage

slepc-3.7.4 2017-05-17

MFNFinalizePackage

This function destroys everything in the SLEPc interface to the MFN package. It is called from SlepcFinalize().

Synopsis

PetscErrorCode MFNFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/mfn/interface/dlregismfn.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNType.html0000644000175000017500000000266613107004621020212 0ustar jromanjroman MFNType

slepc-3.7.4 2017-05-17

MFNType

String with the name of a method for computing matrix functions.

Synopsis

typedef const char* MFNType;
#define MFNKRYLOV   "krylov"
#define MFNEXPOKIT  "expokit"

See Also

MFNSetType(), MFN

Location: src/mfn/../../include/slepcmfn.h
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNRegister.html0000644000175000017500000000447313107004621021053 0ustar jromanjroman MFNRegister

slepc-3.7.4 2017-05-17

MFNRegister

Adds a method to the matrix function solver package.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNRegister(const char *name,PetscErrorCode (*function)(MFN))
Not Collective

Input Parameters

name  - name of a new user-defined solver
function  - routine to create the solver context

Notes

MFNRegister() may be called multiple times to add several user-defined solvers.

Sample usage

    MFNRegister("my_solver",MySolverCreate);

Then, your solver can be chosen with the procedural interface via

    MFNSetType(mfn,"my_solver")
or at runtime via the option
    -mfn_type my_solver

See Also

MFNRegisterAll()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSetBV.html0000644000175000017500000000374013107004621020246 0ustar jromanjroman MFNSetBV

slepc-3.7.4 2017-05-17

MFNSetBV

Associates a basis vectors object to the matrix function solver.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetBV(MFN mfn,BV bv)
Collective on MFN

Input Parameters

mfn  - matrix function context obtained from MFNCreate()
bv  - the basis vectors object

Note

Use MFNGetBV() to retrieve the basis vectors context (for example, to free it at the end of the computations).

See Also

MFNGetBV()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSetFN.html0000644000175000017500000000370613107004621020244 0ustar jromanjroman MFNSetFN

slepc-3.7.4 2017-05-17

MFNSetFN

Specifies the function to be computed.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetFN(MFN mfn,FN fn)
Collective on MFN

Input Parameters

mfn  - matrix function context obtained from MFNCreate()
fn  - the math function object

Note

Use MFNGetFN() to retrieve the math function context (for example, to free it at the end of the computations).

See Also

MFNGetFN()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetOptionsPrefix.html0000644000175000017500000000431413107004621022532 0ustar jromanjroman MFNGetOptionsPrefix

slepc-3.7.4 2017-05-17

MFNGetOptionsPrefix

Gets the prefix used for searching for all MFN options in the database.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetOptionsPrefix(MFN mfn,const char *prefix[])
Not Collective

Input Parameters

mfn  - the matrix function context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

MFNSetOptionsPrefix(), MFNAppendOptionsPrefix()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNMonitorCancel.html0000644000175000017500000000422113107004621022013 0ustar jromanjroman MFNMonitorCancel

slepc-3.7.4 2017-05-17

MFNMonitorCancel

Clears all monitors for an MFN object.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNMonitorCancel(MFN mfn)
Logically Collective on MFN

Input Parameters

mfn  - matrix function context obtained from MFNCreate()

Options Database Key

-mfn_monitor_cancel  - Cancels all monitors that have been hardwired into a code by calls to MFNMonitorSet(), but does not cancel those set via the options database.

See Also

MFNMonitorSet()

Location: src/mfn/interface/mfnmon.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetDimensions.html0000644000175000017500000000404513107004621022032 0ustar jromanjroman MFNGetDimensions

slepc-3.7.4 2017-05-17

MFNGetDimensions

Gets the dimension of the subspace used by the solver.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetDimensions(MFN mfn,PetscInt *ncv)
Not Collective

Input Parameter

mfn  - the matrix function context

Output Parameter

ncv  - the maximum dimension of the subspace to be used by the solver

See Also

MFNSetDimensions()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNGetTolerances.html0000644000175000017500000000447013107004621022023 0ustar jromanjroman MFNGetTolerances
slepc-3.7.4 2017-05-17

MFNGetTolerances

Gets the tolerance and maximum iteration count used by the MFN convergence tests.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetTolerances(MFN mfn,PetscReal *tol,PetscInt *maxits)
Not Collective

Input Parameter

mfn  - the matrix function context

Output Parameters

tol  - the convergence tolerance
maxits  - maximum number of iterations

Notes

The user can specify NULL for any parameter that is not needed.

See Also

MFNSetTolerances()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNView.html0000644000175000017500000000525413107004621020177 0ustar jromanjroman MFNView
slepc-3.7.4 2017-05-17

MFNView

Prints the MFN data structure.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNView(MFN mfn,PetscViewer viewer)
Collective on MFN

Input Parameters

mfn  - the matrix function solver context
viewer  - optional visualization context

Options Database Key

-mfn_view  - Calls MFNView() at end of MFNSolve()

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

See Also

PetscViewerASCIIOpen()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSetFromOptions.html0000644000175000017500000000405413107004621022215 0ustar jromanjroman MFNSetFromOptions

slepc-3.7.4 2017-05-17

MFNSetFromOptions

Sets MFN options from the options database. This routine must be called before MFNSetUp() if the user is to be allowed to set the solver type.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetFromOptions(MFN mfn)
Collective on MFN

Input Parameters

mfn  - the matrix function context

Notes

To see all options, run your program with the -help option.

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNSetDimensions.html0000644000175000017500000000435013107004621022045 0ustar jromanjroman MFNSetDimensions
slepc-3.7.4 2017-05-17

MFNSetDimensions

Sets the dimension of the subspace to be used by the solver.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetDimensions(MFN mfn,PetscInt ncv)
Logically Collective on MFN

Input Parameters

mfn  - the matrix function context
ncv  - the maximum dimension of the subspace to be used by the solver

Options Database Keys

-mfn_ncv <ncv>  - Sets the dimension of the subspace

Notes

Use PETSC_DEFAULT for ncv to assign a reasonably good value, which is dependent on the solution method.

See Also

MFNGetDimensions()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSetUp.html0000644000175000017500000000400113107004621020312 0ustar jromanjroman MFNSetUp

slepc-3.7.4 2017-05-17

MFNSetUp

Sets up all the internal data structures necessary for the execution of the matrix function solver.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetUp(MFN mfn)
Collective on MFN

Input Parameter

mfn  - matrix function context

Notes

This function need not be called explicitly in most cases, since MFNSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time.

See Also

MFNCreate(), MFNSolve(), MFNDestroy()

Location: src/mfn/interface/mfnsetup.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSetOperator.html0000644000175000017500000000460013107004621021526 0ustar jromanjroman MFNSetOperator

slepc-3.7.4 2017-05-17

MFNSetOperator

Sets the matrix for which the matrix function is to be computed.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetOperator(MFN mfn,Mat A)
Collective on MFN and Mat

Input Parameters

mfn  - the matrix function context
A  - the problem matrix

Notes

It must be called before MFNSetUp(). If it is called again after MFNSetUp() then the MFN object is reset.

See Also

MFNSolve(), MFNSetUp(), MFNReset()

Location: src/mfn/interface/mfnsetup.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNAppendOptionsPrefix.html0000644000175000017500000000434413107004621023225 0ustar jromanjroman MFNAppendOptionsPrefix
slepc-3.7.4 2017-05-17

MFNAppendOptionsPrefix

Appends to the prefix used for searching for all MFN options in the database.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNAppendOptionsPrefix(MFN mfn,const char *prefix)
Logically Collective on MFN

Input Parameters

mfn  - the matrix function context
prefix  - the prefix string to prepend to all MFN option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

MFNSetOptionsPrefix(), MFNGetOptionsPrefix()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNDestroy.html0000644000175000017500000000403513107004621020712 0ustar jromanjroman MFNDestroy

slepc-3.7.4 2017-05-17

MFNDestroy

Destroys the MFN context.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNDestroy(MFN *mfn)
Collective on MFN

Input Parameter

mfn  - matrix function context obtained from MFNCreate()

See Also

MFNCreate(), MFNSetUp(), MFNSolve()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNGetBV.html0000644000175000017500000000355313107004621020234 0ustar jromanjroman MFNGetBV
slepc-3.7.4 2017-05-17

MFNGetBV

Obtain the basis vectors object associated to the matrix function solver.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetBV(MFN mfn,BV *bv)
Not Collective

Input Parameters

mfn  - matrix function context obtained from MFNCreate()

Output Parameter

bv  - basis vectors context

See Also

MFNSetBV()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNMonitorSetFromOptions.html0000644000175000017500000000505213107004621023564 0ustar jromanjroman MFNMonitorSetFromOptions

slepc-3.7.4 2017-05-17

MFNMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNMonitorSetFromOptions(MFN mfn,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,PetscViewerAndFormat*))
Collective on MFN

Input Parameters

mfn  - the eigensolver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a PetscViewerAndFormat
trackall  - whether this monitor tracks all eigenvalues or not

See Also

MFNMonitorSet(), MFNSetTrackAll(), MFNConvMonitorSetFromOptions()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetOperator.html0000644000175000017500000000400513107004621021511 0ustar jromanjroman MFNGetOperator

slepc-3.7.4 2017-05-17

MFNGetOperator

Gets the matrix associated with the MFN object.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetOperator(MFN mfn,Mat *A)
Collective on MFN and Mat

Input Parameter

mfn  - the MFN context

Output Parameters

A  - the matrix for which the matrix function is to be computed

See Also

MFNSolve(), MFNSetOperator()

Location: src/mfn/interface/mfnsetup.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSolve.html0000644000175000017500000000743513107004621020360 0ustar jromanjroman MFNSolve

slepc-3.7.4 2017-05-17

MFNSolve

Solves the matrix function problem. Given a vector b, the vector x = f(A)*b is returned.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSolve(MFN mfn,Vec b,Vec x)
Collective on MFN

Input Parameters

mfn  - matrix function context obtained from MFNCreate()
b  - the right hand side vector

Output Parameter

x  - the solution (this may be the same vector as b, then b will be overwritten with the answer)

Options Database Keys

-mfn_view  - print information about the solver used
-mfn_view_mat binary  - save the matrix to the default binary viewer
-mfn_view_rhs binary  - save right hand side vector to the default binary viewer
-mfn_view_solution binary  - save computed solution vector to the default binary viewer
-mfn_converged_reason  - print reason for convergence, and number of iterations

Notes

The matrix A is specified with MFNSetOperator(). The function f is specified with MFNSetFN().

See Also

MFNCreate(), MFNSetUp(), MFNDestroy(), MFNSetTolerances(),
MFNSetOperator(), MFNSetFN()

Location: src/mfn/interface/mfnsolve.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNGetErrorIfNotConverged.html0000644000175000017500000000406313107004621023610 0ustar jromanjroman MFNGetErrorIfNotConverged
slepc-3.7.4 2017-05-17

MFNGetErrorIfNotConverged

Return a flag indicating whether MFNSolve() will generate an error if the solver does not converge.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetErrorIfNotConverged(MFN mfn,PetscBool *flag)
Not Collective

Input Parameter

mfn  - the matrix function context

Output Parameter

flag  - PETSC_TRUE if it will generate an error, else PETSC_FALSE

See Also

MFNSetErrorIfNotConverged()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNMonitorDefault.html0000644000175000017500000000411013107004621022207 0ustar jromanjroman MFNMonitorDefault

slepc-3.7.4 2017-05-17

MFNMonitorDefault

Print the error estimate of the current approximation at each iteration of the matrix function solver.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNMonitorDefault(MFN mfn,PetscInt its,PetscReal errest,PetscViewerAndFormat *vf)
Collective on MFN

Input Parameters

mfn  - matrix function context
its  - iteration number
errest  - error estimate
vf  - viewer and format for monitoring

See Also

MFNMonitorSet()

Location: src/mfn/interface/mfnmon.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/index.html0000644000175000017500000001131213107004621020023 0ustar jromanjroman Matrix Function - MFN

slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

Beginner - Basic usage
MFN MFNSetFN MFNType
MFNCreate MFNSetFromOptions MFNView
MFNDestroy MFNSetOperator
MFNGetFN MFNSolve
Intermediate - Setting options for algorithms and data structures
MFNConvergedReason MFNGetOperator MFNMonitorSet
MFNGetConvergedReason MFNGetTolerances MFNReasonView
MFNGetDimensions MFNGetType MFNSetDimensions
MFNGetErrorIfNotConverged MFNMonitorCancel MFNSetErrorIfNotConverged
MFNGetIterationNumber MFNMonitorDefault MFNSetTolerances
MFNGetMonitorContext MFNMonitorLGCreate MFNSetType
Advanced - Setting more advanced options and customization
MFNAppendOptionsPrefix MFNRegister MFNSetBV
MFNGetBV MFNRegisterAll MFNSetOptionsPrefix
MFNGetOptionsPrefix MFNReset
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
MFNAllocateSolution MFNInitializePackage MFNReasonViewFromOptions
MFNFinalizePackage MFNMonitorSetFromOptions MFNSetUp
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/MFN/MFNSetType.html0000644000175000017500000000533613107004621020663 0ustar jromanjroman MFNSetType

slepc-3.7.4 2017-05-17

MFNSetType

Selects the particular solver to be used in the MFN object.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetType(MFN mfn,MFNType type)
Logically Collective on MFN

Input Parameters

mfn  - the matrix function context
type  - a known method

Options Database Key

-mfn_type <method>  - Sets the method; use -help for a list of available methods

Notes

See "slepc/include/slepcmfn.h" for available methods. The default is MFNKRYLOV

Normally, it is best to use the MFNSetFromOptions() command and then set the MFN type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The MFNSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database.

See Also

MFNType

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNReset.html0000644000175000017500000000333213107004621020342 0ustar jromanjroman MFNReset

slepc-3.7.4 2017-05-17

MFNReset

Resets the MFN context to the setupcalled=0 state and removes any allocated objects.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNReset(MFN mfn)
Collective on MFN

Input Parameter

mfn  - matrix function context obtained from MFNCreate()

See Also

MFNDestroy()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFN.html0000644000175000017500000000246613107004621017346 0ustar jromanjroman MFN

slepc-3.7.4 2017-05-17

MFN

SLEPc object that encapsulates functionality for matrix functions.

Synopsis

typedef struct _p_MFN* MFN;

See Also

MFNCreate()

Location: src/mfn/../../include/slepcmfn.h
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNInitializePackage.html0000644000175000017500000000312513107004621022635 0ustar jromanjroman MFNInitializePackage

slepc-3.7.4 2017-05-17

MFNInitializePackage

This function initializes everything in the MFN package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to MFNCreate() when using static libraries.

Synopsis

PetscErrorCode MFNInitializePackage(void)

See Also

SlepcInitialize()

Location: src/mfn/interface/dlregismfn.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNReasonViewFromOptions.html0000644000175000017500000000321313107004621023540 0ustar jromanjroman MFNReasonViewFromOptions

slepc-3.7.4 2017-05-17

MFNReasonViewFromOptions

Processes command line options to determine if/how the MFN converged reason is to be viewed.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNReasonViewFromOptions(MFN mfn)
Collective on MFN

Input Parameters

mfn  - the matrix function context

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNCreate.html0000644000175000017500000000455713107004621020475 0ustar jromanjroman MFNCreate

slepc-3.7.4 2017-05-17

MFNCreate

Creates the default MFN context.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNCreate(MPI_Comm comm,MFN *outmfn)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

mfn  - location to put the MFN context

Note

The default MFN type is MFNKRYLOV

See Also

MFNSetUp(), MFNSolve(), MFNDestroy(), MFN

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNAllocateSolution.html0000644000175000017500000000365713107004621022553 0ustar jromanjroman MFNAllocateSolution
slepc-3.7.4 2017-05-17

MFNAllocateSolution

Allocate memory storage for common variables such as the basis vectors.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNAllocateSolution(MFN mfn,PetscInt extra)
Collective on MFN

Input Parameters

mfn  - eigensolver context
extra  - number of additional positions, used for methods that require a working basis slightly larger than ncv

Developers Note

This is PETSC_EXTERN because it may be required by user plugin MFN implementations.

Location: src/mfn/interface/mfnsetup.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNMonitorSet.html0000644000175000017500000001015513107004621021364 0ustar jromanjroman MFNMonitorSet

slepc-3.7.4 2017-05-17

MFNMonitorSet

Sets an ADDITIONAL function to be called at every iteration to monitor convergence.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNMonitorSet(MFN mfn,PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
Logically Collective on MFN

Input Parameters

mfn  - matrix function context obtained from MFNCreate()
monitor  - pointer to function (if this is NULL, it turns off monitoring)
mctx  - [optional] context for private data for the monitor routine (use NULL if no context is desired)
monitordestroy  - [optional] routine that frees monitor context (may be NULL)

Calling Sequence of monitor

  monitor(MFN mfn,int its,PetscReal errest,void *mctx)

mfn  - matrix function context obtained from MFNCreate()
its  - iteration number
errest  - error estimate
mctx  - optional monitoring context, as set by MFNMonitorSet()

Options Database Keys

-mfn_monitor  - print the error estimate
-mfn_monitor_lg  - sets line graph monitor for the error estimate
-mfn_monitor_cancel  - cancels all monitors that have been hardwired into a code by calls to MFNMonitorSet(), but does not cancel those set via the options database.

Notes

Several different monitoring routines may be set by calling MFNMonitorSet() multiple times; all will be called in the order in which they were set.

See Also

MFNMonitorFirst(), MFNMonitorAll(), MFNMonitorCancel()

Location: src/mfn/interface/mfnmon.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSetOptionsPrefix.html0000644000175000017500000000510413107004621022544 0ustar jromanjroman MFNSetOptionsPrefix

slepc-3.7.4 2017-05-17

MFNSetOptionsPrefix

Sets the prefix used for searching for all MFN options in the database.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetOptionsPrefix(MFN mfn,const char *prefix)
Logically Collective on MFN

Input Parameters

mfn  - the matrix function context
prefix  - the prefix string to prepend to all MFN option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

For example, to distinguish between the runtime options for two different MFN contexts, one could call

      MFNSetOptionsPrefix(mfn1,"fun1_")
      MFNSetOptionsPrefix(mfn2,"fun2_")

See Also

MFNAppendOptionsPrefix(), MFNGetOptionsPrefix()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetFN.html0000644000175000017500000000420513107004621020223 0ustar jromanjroman MFNGetFN

slepc-3.7.4 2017-05-17

MFNGetFN

Obtain the math function object associated to the MFN object.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetFN(MFN mfn,FN *fn)
Not Collective

Input Parameters

mfn  - matrix function context obtained from MFNCreate()

Output Parameter

fn  - math function context

See Also

MFNSetFN()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNConvergedReason.html0000644000175000017500000000361513107004621022350 0ustar jromanjroman MFNConvergedReason
slepc-3.7.4 2017-05-17

MFNConvergedReason

reason a matrix function iteration was said to have converged or diverged

Synopsis

typedef enum {/* converged */
              MFN_CONVERGED_TOL                =  2,
              MFN_CONVERGED_ITS                =  3,
              /* diverged */
              MFN_DIVERGED_ITS                 = -3,
              MFN_DIVERGED_BREAKDOWN           = -4,
              MFN_CONVERGED_ITERATING          =  0} MFNConvergedReason;

See Also

MFNSolve(), MFNGetConvergedReason(), MFNSetTolerances()

Location: src/mfn/../../include/slepcmfn.h
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNSetTolerances.html0000644000175000017500000000523613107004621022040 0ustar jromanjroman MFNSetTolerances

slepc-3.7.4 2017-05-17

MFNSetTolerances

Sets the tolerance and maximum iteration count used by the MFN convergence tests.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetTolerances(MFN mfn,PetscReal tol,PetscInt maxits)
Logically Collective on MFN

Input Parameters

mfn  - the matrix function context
tol  - the convergence tolerance
maxits  - maximum number of iterations to use

Options Database Keys

-mfn_tol <tol>  - Sets the convergence tolerance
-mfn_max_it <maxits>  - Sets the maximum number of iterations allowed

Notes

Use PETSC_DEFAULT for either argument to assign a reasonably good value.

See Also

MFNGetTolerances()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNSetErrorIfNotConverged.html0000644000175000017500000000504013107004621023620 0ustar jromanjroman MFNSetErrorIfNotConverged
slepc-3.7.4 2017-05-17

MFNSetErrorIfNotConverged

Causes MFNSolve() to generate an error if the solver has not converged.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNSetErrorIfNotConverged(MFN mfn,PetscBool flg)
Logically Collective on MFN

Input Parameters

mfn  - the matrix function context
flg  - PETSC_TRUE indicates you want the error generated

Options Database Keys

-mfn_error_if_not_converged  - this takes an optional truth value (0/1/no/yes/true/false)

Note

Normally SLEPc continues if the solver fails to converge, you can call MFNGetConvergedReason() after a MFNSolve() to determine if it has converged.

See Also

MFNGetErrorIfNotConverged()

Location: src/mfn/interface/mfnopts.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetConvergedReason.html0000644000175000017500000000712713107004621023012 0ustar jromanjroman MFNGetConvergedReason

slepc-3.7.4 2017-05-17

MFNGetConvergedReason

Gets the reason why the MFNSolve() iteration was stopped.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetConvergedReason(MFN mfn,MFNConvergedReason *reason)
Not Collective

Input Parameter

mfn  - the matrix function context

Output Parameter

reason  - negative value indicates diverged, positive value converged

Notes

Possible values for reason are
MFN_CONVERGED_TOL  - converged up to tolerance
MFN_CONVERGED_ITS  - solver completed the requested number of steps
MFN_DIVERGED_ITS  - required more than max_it iterations to reach convergence
MFN_DIVERGED_BREAKDOWN  - generic breakdown in method

Can only be called after the call to MFNSolve() is complete.

Basic solvers (e.g. unrestarted Krylov iterations) cannot determine if the computation is accurate up to the requested tolerance. In that case, the converged reason is set to MFN_CONVERGED_ITS if the requested number of steps (for instance, the ncv value in unrestarted Krylov methods) have been completed successfully.

See Also

MFNSetTolerances(), MFNSolve(), MFNConvergedReason, MFNSetErrorIfNotConverged()

Location: src/mfn/interface/mfnsolve.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/MFN/MFNMonitorLGCreate.html0000644000175000017500000000553113107004621022261 0ustar jromanjroman MFNMonitorLGCreate
slepc-3.7.4 2017-05-17

MFNMonitorLGCreate

Creates a line graph context for use with MFN to monitor convergence.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
Collective on MPI_Comm

Input Parameters

comm  - communicator context
host  - the X display to open, or null for the local machine
label  - the title to put in the title bar
x, y  - the screen coordinates of the upper left coordinate of the window
m, n  - the screen width and height in pixels

Output Parameter

lgctx  - the drawing context

Options Database Keys

-mfn_monitor_lg  - Sets line graph monitor

Notes

Use PetscDrawLGDestroy() to destroy this line graph.

See Also

MFNMonitorSet()

Location: src/mfn/interface/mfnmon.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/MFN/MFNGetType.html0000644000175000017500000000361513107004621020645 0ustar jromanjroman MFNGetType

slepc-3.7.4 2017-05-17

MFNGetType

Gets the MFN type as a string from the MFN object.

Synopsis

#include "slepcmfn.h" 
PetscErrorCode MFNGetType(MFN mfn,MFNType *type)
Not Collective

Input Parameter

mfn  - the matrix function context

Output Parameter

name  - name of MFN method

See Also

MFNSetType()

Location: src/mfn/interface/mfnbasic.c
Index of all MFN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/0000755000175000017500000000000013107004621015736 5ustar jromanjromanslepc-3.7.4/docs/manualpages/ST/STGetOperators.html0000644000175000017500000000446513107004621021522 0ustar jromanjroman STGetOperators

slepc-3.7.4 2017-05-17

STGetOperators

Gets the matrices associated with the original eigensystem.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetOperators(ST st,PetscInt k,Mat *A)
Not collective, though parallel Mats are returned if the ST is parallel

Input Parameter

st  - the spectral transformation context
k  - the index of the requested matrix (starting in 0)

Output Parameters

A  - the requested matrix

See Also

STSetOperators(), STGetNumMatrices()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/STGetTOperators.html0000644000175000017500000000424313107004621021640 0ustar jromanjroman STGetTOperators
slepc-3.7.4 2017-05-17

STGetTOperators

Gets the matrices associated with the transformed eigensystem.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetTOperators(ST st,PetscInt k,Mat *T)
Not collective, though parallel Mats are returned if the ST is parallel

Input Parameter

st  - the spectral transformation context
k  - the index of the requested matrix (starting in 0)

Output Parameters

T  - the requested matrix

See Also

STGetOperators(), STGetNumMatrices()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetOptionsPrefix.html0000644000175000017500000000432013107004621022343 0ustar jromanjroman STGetOptionsPrefix

slepc-3.7.4 2017-05-17

STGetOptionsPrefix

Gets the prefix used for searching for all ST options in the database.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[])
Not Collective

Input Parameters

st  - the spectral transformation context

Output Parameters

prefix  - pointer to the prefix string used, is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

STSetOptionsPrefix(), STAppendOptionsPrefix()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STCayleySetAntishift.html0000644000175000017500000000466113107004621022656 0ustar jromanjroman STCayleySetAntishift

slepc-3.7.4 2017-05-17

STCayleySetAntishift

Sets the value of the anti-shift for the Cayley spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STCayleySetAntishift(ST st,PetscScalar nu)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
nu  - the anti-shift

Options Database Key

-st_cayley_antishift  - Sets the value of the anti-shift

Note

In the generalized Cayley transform, the operator can be expressed as OP = inv(A - sigma B)*(A + nu B). This function sets the value of nu. Use STSetShift() for setting sigma.

See Also

STSetShift(), STCayleyGetAntishift()

Location: src/sys/classes/st/impls/cayley/cayley.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STApply.html0000644000175000017500000000406213107004621020162 0ustar jromanjroman STApply

slepc-3.7.4 2017-05-17

STApply

Applies the spectral transformation operator to a vector, for instance (A - sB)^-1 B in the case of the shift-and-invert transformation and generalized eigenproblem.

Synopsis

#include "slepcst.h" 
PetscErrorCode STApply(ST st,Vec x,Vec y)
Collective on ST and Vec

Input Parameters

st  - the spectral transformation context
x  - input vector

Output Parameter

y  - output vector

See Also

STApplyTranspose()

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetNumMatrices.html0000644000175000017500000000373013107004621021765 0ustar jromanjroman STGetNumMatrices

slepc-3.7.4 2017-05-17

STGetNumMatrices

Returns the number of matrices stored in the ST.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetNumMatrices(ST st,PetscInt *n)
Not collective

Input Parameter

st  - the spectral transformation context

Output Parameters

n  - the number of matrices passed in STSetOperators()

See Also

STSetOperators()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STRegister.html0000644000175000017500000000453613107004621020667 0ustar jromanjroman STRegister

slepc-3.7.4 2017-05-17

STRegister

Adds a method to the spectral transformation package.

Synopsis

#include "slepcst.h" 
PetscErrorCode STRegister(const char *name,PetscErrorCode (*function)(ST))
Not collective

Input Parameters

name  - name of a new user-defined transformation
function  - routine to create method context

Notes

STRegister() may be called multiple times to add several user-defined spectral transformations.

Sample usage

    STRegister("my_transform",MyTransformCreate);

Then, your spectral transform can be chosen with the procedural interface via

    STSetType(st,"my_transform")
or at runtime via the option
    -st_type my_transform

See Also

STRegisterAll()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STPrecondGetKSPHasMat.html0000644000175000017500000000406713107004621022610 0ustar jromanjroman STPrecondGetKSPHasMat

slepc-3.7.4 2017-05-17

STPrecondGetKSPHasMat

Returns the flag indicating if the coefficient matrix of the KSP linear system (A) is set to be the same matrix as the preconditioner (P).

Synopsis

#include "slepcst.h" 
PetscErrorCode STPrecondGetKSPHasMat(ST st,PetscBool *setmat)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameter

setmat  - the flag

See Also

STPrecondSetKSPHasMat(), STSetShift()

Location: src/sys/classes/st/impls/precond/precond.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STApplyTranspose.html0000644000175000017500000000410713107004621022061 0ustar jromanjroman STApplyTranspose

slepc-3.7.4 2017-05-17

STApplyTranspose

Applies the transpose of the operator to a vector, for instance B^T(A - sB)^-T in the case of the shift-and-invert transformation and generalized eigenproblem.

Synopsis

#include "slepcst.h" 
PetscErrorCode STApplyTranspose(ST st,Vec x,Vec y)
Collective on ST and Vec

Input Parameters

st  - the spectral transformation context
x  - input vector

Output Parameter

y  - output vector

See Also

STApply()

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetFromOptions.html0000644000175000017500000000330713107004621022031 0ustar jromanjroman STSetFromOptions

slepc-3.7.4 2017-05-17

STSetFromOptions

Sets ST options from the options database. This routine must be called before STSetUp() if the user is to be allowed to set the type of transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetFromOptions(ST st)
Collective on ST

Input Parameter

st  - the spectral transformation context

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STShellGetContext.html0000644000175000017500000000425413107004621022154 0ustar jromanjroman STShellGetContext

slepc-3.7.4 2017-05-17

STShellGetContext

Returns the user-provided context associated with a shell ST

Synopsis

#include "slepcst.h" 
PetscErrorCode STShellGetContext(ST st,void **ctx)
Not Collective

Input Parameter

st  - spectral transformation context

Output Parameter

ctx  - the user provided context

Notes

This routine is intended for use within various shell routines

See Also

STShellSetContext()

Location: src/sys/classes/st/impls/shell/shell.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/ST.html0000644000175000017500000000307013107004621017152 0ustar jromanjroman ST
slepc-3.7.4 2017-05-17

ST

Abstract SLEPc object that manages spectral transformations. This object is accessed only in advanced applications.

Synopsis

typedef struct _p_ST* ST;

See Also

STCreate(), EPS

Location: src/sys/classes/st/../../../../include/slepcst.h
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/STMatMultTranspose.html0000644000175000017500000000424113107004621022356 0ustar jromanjroman STMatMultTranspose
slepc-3.7.4 2017-05-17

STMatMultTranspose

Computes the matrix-vector product y = T[k]' x, where T[k] is the k-th matrix of the spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatMultTranspose(ST st,PetscInt k,Vec x,Vec y)
Collective on ST

Input Parameters

st  - the spectral transformation context
k  - index of matrix to use
x  - the vector to be multiplied

Output Parameter

y  - the result

See Also

STMatMult()

Location: src/sys/classes/st/interface/stsles.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STFinalizePackage.html0000644000175000017500000000301613107004621022110 0ustar jromanjroman STFinalizePackage

slepc-3.7.4 2017-05-17

STFinalizePackage

This function destroys everything in the Slepc interface to the ST package. It is called from SlepcFinalize().

Synopsis

#include "slepcst.h" 
PetscErrorCode STFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetMatStructure.html0000644000175000017500000000411713107004621022200 0ustar jromanjroman STGetMatStructure

slepc-3.7.4 2017-05-17

STGetMatStructure

Gets the internal MatStructure attribute to indicate which is the relation of the sparsity pattern of the matrices.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetMatStructure(ST st,MatStructure *str)
Not Collective

Input Parameters

st  - the spectral transformation context

Output Parameters

str  - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or SUBSET_NONZERO_PATTERN

See Also

STSetMatStructure(), STSetOperators(), MatAXPY()

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetBalanceMatrix.html0000644000175000017500000000414113107004621022245 0ustar jromanjroman STGetBalanceMatrix

slepc-3.7.4 2017-05-17

STGetBalanceMatrix

Gets the balance matrix used by the spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetBalanceMatrix(ST st,Vec *D)
Not collective, but vector is shared by all processors that share the ST

Input Parameter

st  - the spectral transformation context

Output Parameter

D  - the diagonal matrix (represented as a vector)

Note

If the matrix was not set, a null pointer will be returned.

See Also

STSetBalanceMatrix()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STCreate.html0000644000175000017500000000370713107004621020305 0ustar jromanjroman STCreate

slepc-3.7.4 2017-05-17

STCreate

Creates a spectral transformation context.

Synopsis

#include "slepcst.h" 
PetscErrorCode STCreate(MPI_Comm comm,ST *newst)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

st  - location to put the spectral transformation context

See Also

STSetUp(), STApply(), STDestroy(), ST

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STMatCreateVecs.html0000644000175000017500000000375513107004621021573 0ustar jromanjroman STMatCreateVecs

slepc-3.7.4 2017-05-17

STMatCreateVecs

Get vector(s) compatible with the ST matrices.

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatCreateVecs(ST st,Vec *right,Vec *left)
Collective on ST

Input Parameter

st  - the spectral transformation context

Output Parameters

right  - (optional) vector that the matrix can be multiplied against
left  - (optional) vector that the matrix vector product can be stored in

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STMatSetUp.html0000644000175000017500000000443413107004621020602 0ustar jromanjroman STMatSetUp

slepc-3.7.4 2017-05-17

STMatSetUp

Build the preconditioner matrix used in STMatSolve().

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatSetUp(ST st,PetscScalar sigma,PetscScalar *coeffs)
Collective on ST

Input Parameters

st  - the spectral transformation context
sigma  - the shift
coeffs  - the coefficients (may be NULL)

Note

This function is not intended to be called by end users, but by SLEPc solvers that use ST. It builds matrix st->P as follows, then calls KSPSetUp().
    If (coeffs):  st->P = Sum_{i=0:nmat-1} coeffs[i]*sigma^i*A_i.
    else          st->P = Sum_{i=0:nmat-1} sigma^i*A_i

See Also

STMatSolve()

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STAppendOptionsPrefix.html0000644000175000017500000000434313107004621023040 0ustar jromanjroman STAppendOptionsPrefix

slepc-3.7.4 2017-05-17

STAppendOptionsPrefix

Appends to the prefix used for searching for all ST options in the database.

Synopsis

#include "slepcst.h" 
PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
prefix  - the prefix string to prepend to all ST option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

STSetOptionsPrefix(), STGetOptionsPrefix()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetUp.html0000644000175000017500000000330413107004621020133 0ustar jromanjroman STSetUp

slepc-3.7.4 2017-05-17

STSetUp

Prepares for the use of a spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetUp(ST st)
Collective on ST

Input Parameter

st  - the spectral transformation context

See Also

STCreate(), STApply(), STDestroy()

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STMatGetLocalSize.html0000644000175000017500000000363413107004621022070 0ustar jromanjroman STMatGetLocalSize

slepc-3.7.4 2017-05-17

STMatGetLocalSize

Returns the number of local rows and columns of the ST matrices.

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatGetLocalSize(ST st,PetscInt *m,PetscInt *n)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameters

m  - the number of local rows
n  - the number of local columns

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STScaleShift.html0000644000175000017500000000366213107004621021127 0ustar jromanjroman STScaleShift

slepc-3.7.4 2017-05-17

STScaleShift

Multiply the shift with a given factor.

Synopsis

#include "slepcst.h" 
PetscErrorCode STScaleShift(ST st,PetscScalar factor)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
factor  - the scaling factor

Note

This function does not update the transformation matrices, as opposed to STSetShift().

See Also

STSetShift()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STComputeExplicitOperator.html0000644000175000017500000000453313107004621023732 0ustar jromanjroman STComputeExplicitOperator

slepc-3.7.4 2017-05-17

STComputeExplicitOperator

Computes the explicit operator associated to the eigenvalue problem with the specified spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STComputeExplicitOperator(ST st,Mat *mat)
Collective on ST

Input Parameter

st  - the spectral transform context

Output Parameter

mat  - the explicit operator

Notes

This routine builds a matrix containing the explicit operator. For example, in generalized problems with shift-and-invert spectral transformation the result would be matrix (A - s B)^-1 B.

This computation is done by applying the operator to columns of the identity matrix. This is analogous to MatComputeExplicitOperator().

See Also

STApply()

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STShellSetBackTransform.html0000644000175000017500000000553613107004621023304 0ustar jromanjroman STShellSetBackTransform

slepc-3.7.4 2017-05-17

STShellSetBackTransform

Sets the routine to be called after the eigensolution process has finished in order to transform back the computed eigenvalues.

Synopsis

#include "slepcst.h" 
PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
backtr  - the application-provided backtransform routine

Calling sequence of backtr

  backtr(ST st,PetscScalar *eigr,PetscScalar *eigi)

st  - the spectral transformation context
eigr  - pointer ot the real part of the eigenvalue to transform back
eigi  - pointer ot the imaginary part

See Also

STShellSetApply(), STShellSetApplyTranspose()

Location: src/sys/classes/st/impls/shell/shell.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/STShellSetApply.html0000644000175000017500000000530413107004621021626 0ustar jromanjroman STShellSetApply
slepc-3.7.4 2017-05-17

STShellSetApply

Sets routine to use as the application of the operator to a vector in the user-defined spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
apply  - the application-provided transformation routine

Calling sequence of apply

  apply(ST st,Vec xin,Vec xout)

st  - the spectral transformation context
xin  - input vector
xout  - output vector

See Also

STShellSetBackTransform(), STShellSetApplyTranspose()

Location: src/sys/classes/st/impls/shell/shell.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/STGetType.html0000644000175000017500000000360713107004621020462 0ustar jromanjroman STGetType
slepc-3.7.4 2017-05-17

STGetType

Gets the ST type name (as a string) from the ST context.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetType(ST st,STType *type)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameter

name  - name of the spectral transformation

See Also

STSetType()

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetMatStructure.html0000644000175000017500000000532713107004621022220 0ustar jromanjroman STSetMatStructure

slepc-3.7.4 2017-05-17

STSetMatStructure

Sets an internal MatStructure attribute to indicate which is the relation of the sparsity pattern of all ST matrices.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetMatStructure(ST st,MatStructure str)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
str  - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or SUBSET_NONZERO_PATTERN

Options Database Key

-st_matstructure <str>  - Indicates the structure flag, where <str> is one of 'same' (matrices have the same nonzero pattern), 'different' (different nonzero pattern) or 'subset' (pattern is a subset of the first one).

Notes

By default, the sparsity patterns are assumed to be different. If the patterns are equal or a subset then it is recommended to set this attribute for efficiency reasons (in particular, for internal MatAXPY() operations).

This function has no effect in the case of standard eigenproblems.

See Also

STSetOperators(), MatAXPY()

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetType.html0000644000175000017500000000577313107004621020504 0ustar jromanjroman STSetType

slepc-3.7.4 2017-05-17

STSetType

Builds ST for a particular spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetType(ST st,STType type)
Logically Collective on ST

Input Parameter

st  - the spectral transformation context.
type  - a known type

Options Database Key

-st_type <type>  - Sets ST type

Use -help for a list of available transformations

Notes

See "slepc/include/slepcst.h" for available transformations

Normally, it is best to use the EPSSetFromOptions() command and then set the ST type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the many different transformations.

See Also

EPSSetType()

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex24.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/ST/STSetBalanceMatrix.html0000644000175000017500000000443013107004621022262 0ustar jromanjroman STSetBalanceMatrix
slepc-3.7.4 2017-05-17

STSetBalanceMatrix

Sets the diagonal matrix to be used for balancing.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetBalanceMatrix(ST st,Vec D)
Collective on ST and Vec

Input Parameters

st  - the spectral transformation context
D  - the diagonal matrix (represented as a vector)

Notes

If this matrix is set, STApply will effectively apply D*OP*D^{-1}.

Balancing is usually set via EPSSetBalance, but the advanced user may use this function to bypass the usual balancing methods.

See Also

EPSSetBalance(), STApply(), STGetBalanceMatrix()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STDestroy.html0000644000175000017500000000334213107004621020526 0ustar jromanjroman STDestroy

slepc-3.7.4 2017-05-17

STDestroy

Destroys ST context that was created with STCreate().

Synopsis

#include "slepcst.h" 
PetscErrorCode STDestroy(ST *st)
Collective on ST

Input Parameter

st  - the spectral transformation context

See Also

STCreate(), STSetUp()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetMatMode.html0000644000175000017500000000365313107004621021070 0ustar jromanjroman STGetMatMode

slepc-3.7.4 2017-05-17

STGetMatMode

Gets a flag that indicates how the transformed matrices are stored in spectral transformations.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetMatMode(ST st,STMatMode *mode)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameter

mode  - the mode flag

See Also

STSetMatMode(), STMatMode

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STType.html0000644000175000017500000000307013107004621020014 0ustar jromanjroman STType

slepc-3.7.4 2017-05-17

STType

String with the name of a SLEPc spectral transformation

Synopsis

typedef const char* STType;
#define STSHELL     "shell"
#define STSHIFT     "shift"
#define STSINVERT   "sinvert"
#define STCAYLEY    "cayley"
#define STPRECOND   "precond"

See Also

STSetType(), ST

Location: src/sys/classes/st/../../../../include/slepcst.h
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STShellSetApplyTranspose.html0000644000175000017500000000514313107004621023526 0ustar jromanjroman STShellSetApplyTranspose

slepc-3.7.4 2017-05-17

STShellSetApplyTranspose

Sets routine to use as the application of the transposed operator to a vector in the user-defined spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
applytrans  - the application-provided transformation routine

Calling sequence of applytrans

  applytrans(ST st,Vec xin,Vec xout)

st  - the spectral transformation context
xin  - input vector
xout  - output vector

See Also

STShellSetApply(), STShellSetBackTransform()

Location: src/sys/classes/st/impls/shell/shell.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STView.html0000644000175000017500000000506413107004621020012 0ustar jromanjroman STView

slepc-3.7.4 2017-05-17

STView

Prints the ST data structure.

Synopsis

#include "slepcst.h" 
PetscErrorCode STView(ST st,PetscViewer viewer)
Collective on ST

Input Parameters

st  - the ST context
viewer  - optional visualization context

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization contexts with PetscViewerASCIIOpen() (output to a specified file).

See Also

EPSView(), PetscViewerASCIIOpen()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/STGetTransform.html0000644000175000017500000000356413107004621021516 0ustar jromanjroman STGetTransform
slepc-3.7.4 2017-05-17

STGetTransform

Gets a flag that that indicates whether the transformed matrices are computed or not.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetTransform(ST st,PetscBool *flg)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameter

flg  - the flag

See Also

STSetTransform()

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STPostSolve.html0000644000175000017500000000333513107004621021035 0ustar jromanjroman STPostSolve

slepc-3.7.4 2017-05-17

STPostSolve

Optional post-solve phase, intended for any actions that must be performed on the ST object after the eigensolver has finished.

Synopsis

#include "slepcst.h" 
PetscErrorCode STPostSolve(ST st)
Collective on ST

Input Parameters

st  - the spectral transformation context

See Also

EPSSolve()

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STShellSetContext.html0000644000175000017500000000430413107004621022164 0ustar jromanjroman STShellSetContext

slepc-3.7.4 2017-05-17

STShellSetContext

Sets the context for a shell ST

Synopsis

#include "slepcst.h" 
PetscErrorCode STShellSetContext(ST st,void *ctx)
Logically Collective on ST

Input Parameters

st  - the shell ST
ctx  - the context

Fortran Notes

To use this from Fortran you must write a Fortran interface definition for this function that tells Fortran the Fortran derived data type that you are passing in as the ctx argument.

See Also

STShellGetContext()

Location: src/sys/classes/st/impls/shell/shell.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/STMatSolveTranspose.html0000644000175000017500000000417313107004621022531 0ustar jromanjroman STMatSolveTranspose
slepc-3.7.4 2017-05-17

STMatSolveTranspose

Solves P' x = b, where P is the preconditioner matrix of the spectral transformation, using a KSP object stored internally.

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatSolveTranspose(ST st,Vec b,Vec x)
Collective on ST

Input Parameters

st  - the spectral transformation context
b  - right hand side vector

Output Parameter

x  - computed solution

See Also

STMatSolve()

Location: src/sys/classes/st/interface/stsles.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetMatMode.html0000644000175000017500000000711513107004621021101 0ustar jromanjroman STSetMatMode

slepc-3.7.4 2017-05-17

STSetMatMode

Sets a flag to indicate how the transformed matrices are being stored in the spectral transformations.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetMatMode(ST st,STMatMode mode)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
mode  - the mode flag, one of ST_MATMODE_COPY, ST_MATMODE_INPLACE, or ST_MATMODE_SHELL

Options Database Key

-st_matmode <mode>  - Indicates the mode flag, where <mode> is one of 'copy', 'inplace', 'shell' (see explanation below).

Notes

By default (ST_MATMODE_COPY), a copy of matrix A is made and then this copy is modified explicitly, e.g. A <- (A - s B).

With ST_MATMODE_INPLACE, the original matrix A is modified at STSetUp() and changes are reverted at the end of the computations. With respect to the previous one, this mode avoids a copy of matrix A. However, a drawback is that the recovered matrix might be slightly different from the original one (due to roundoff).

With ST_MATMODE_SHELL, the solver works with an implicit shell matrix that represents the shifted matrix. This mode is the most efficient in creating the shifted matrix but it places serious limitations to the linear solves performed in each iteration of the eigensolver (typically, only interative solvers with Jacobi preconditioning can be used).

In the two first modes the efficiency of the computation can be controlled with STSetMatStructure().

See Also

STSetOperators(), STSetMatStructure(), STGetMatMode(), STMatMode

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/pep/examples/tutorials/ex28.c.html
slepc-3.7.4/docs/manualpages/ST/STPrecondGetMatForPC.html0000644000175000017500000000434613107004621022470 0ustar jromanjroman STPrecondGetMatForPC
slepc-3.7.4 2017-05-17

STPrecondGetMatForPC

Returns the matrix previously set by STPrecondSetMatForPC().

Synopsis

#include "slepcst.h" 
PetscErrorCode STPrecondGetMatForPC(ST st,Mat *mat)
Not Collective, but the Mat is shared by all processors that share the ST

Input Parameter

st  - the spectral transformation context

Output Parameter

mat  - the matrix that will be used in constructing the preconditioner or NULL if no matrix was set by STPrecondSetMatForPC().

See Also

STPrecondSetMatForPC()

Location: src/sys/classes/st/impls/precond/precond.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetOperators.html0000644000175000017500000000456313107004621021535 0ustar jromanjroman STSetOperators

slepc-3.7.4 2017-05-17

STSetOperators

Sets the matrices associated with the eigenvalue problem.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetOperators(ST st,PetscInt n,Mat A[])
Collective on ST and Mat

Input Parameters

st  - the spectral transformation context
n  - number of matrices in array A
A  - the array of matrices associated with the eigensystem

Notes

It must be called before STSetUp(). If it is called again after STSetUp() then the ST object is reset.

See Also

STGetOperators(), STGetNumMatrices(), STSetUp(), STReset()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STInitializePackage.html0000644000175000017500000000315013107004621022447 0ustar jromanjroman STInitializePackage

slepc-3.7.4 2017-05-17

STInitializePackage

This function initializes everything in the ST package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to STCreate() when using static libraries.

Synopsis

#include "slepcst.h" 
PetscErrorCode STInitializePackage(void)

See Also

SlepcInitialize()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetKSP.html0000644000175000017500000000317013107004621020205 0ustar jromanjroman STSetKSP

slepc-3.7.4 2017-05-17

STSetKSP

Sets the KSP object associated with the spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetKSP(ST st,KSP ksp)
Collective on ST

Input Parameters

st  - the spectral transformation context
ksp  - the linear system context

Location: src/sys/classes/st/interface/stsles.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetShift.html0000644000175000017500000000351413107004621020613 0ustar jromanjroman STGetShift

slepc-3.7.4 2017-05-17

STGetShift

Gets the shift associated with the spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetShift(ST st,PetscScalar* shift)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameter

shift  - the value of the shift

See Also

STSetShift()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STMatSolve.html0000644000175000017500000000404613107004621020631 0ustar jromanjroman STMatSolve

slepc-3.7.4 2017-05-17

STMatSolve

Solves P x = b, where P is the preconditioner matrix of the spectral transformation, using a KSP object stored internally.

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatSolve(ST st,Vec b,Vec x)
Collective on ST

Input Parameters

st  - the spectral transformation context
b  - right hand side vector

Output Parameter

x  - computed solution

See Also

STMatSolveTranspose()

Location: src/sys/classes/st/interface/stsles.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/index.html0000644000175000017500000001621213107004621017735 0ustar jromanjroman Spectral Transformation - ST

slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

Beginner - Basic usage
ST STSetFromOptions STView
STCreate STSetType
STDestroy STType
Intermediate - Setting options for algorithms and data structures
STCayleyGetAntishift STGetNumMatrices STMatMode
STCayleySetAntishift STGetOperators STSetMatMode
STGetKSP STGetShift STSetOperators
STGetMatMode STGetType STSetShift
Advanced - Setting more advanced options and customization
STAppendOptionsPrefix STRegisterAll STShellGetContext
STComputeExplicitOperator STReset STShellSetApply
STGetMatStructure STSHELL STShellSetApplyTranspose
STGetOptionsPrefix STSetKSP STShellSetBackTransform
STPrecondGetMatForPC STSetMatStructure STShellSetContext
STPrecondSetMatForPC STSetOptionsPrefix
STRegister STSetUp
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
STApply STInitializePackage STPostSolve
STApplyTranspose STMatCreateVecs STPrecondGetKSPHasMat
STBackTransform STMatGetLocalSize STPrecondSetKSPHasMat
STCheckNullSpace STMatGetSize STScaleShift
STFinalizePackage STMatMult STSetBalanceMatrix
STGetBalanceMatrix STMatMultTranspose STSetDefaultShift
STGetBilinearForm STMatSetUp STSetTransform
STGetTOperators STMatSolve
STGetTransform STMatSolveTranspose
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/ST/STSetOptionsPrefix.html0000644000175000017500000000432413107004621022363 0ustar jromanjroman STSetOptionsPrefix

slepc-3.7.4 2017-05-17

STSetOptionsPrefix

Sets the prefix used for searching for all ST options in the database.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
prefix  - the prefix string to prepend to all ST option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

STAppendOptionsPrefix(), STGetOptionsPrefix()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STMatMode.html0000644000175000017500000000306113107004621020421 0ustar jromanjroman STMatMode

slepc-3.7.4 2017-05-17

STMatMode

Determines how to handle the coefficient matrix associated to the spectral transformation

Synopsis

typedef enum { ST_MATMODE_COPY,
               ST_MATMODE_INPLACE,
               ST_MATMODE_SHELL } STMatMode;

See Also

STSetMatMode(), STGetMatMode()

Location: src/sys/classes/st/../../../../include/slepcst.h
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STCayleyGetAntishift.html0000644000175000017500000000375613107004621022646 0ustar jromanjroman STCayleyGetAntishift

slepc-3.7.4 2017-05-17

STCayleyGetAntishift

Gets the value of the anti-shift used in the Cayley spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STCayleyGetAntishift(ST st,PetscScalar *nu)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameter

nu  - the anti-shift

See Also

STGetShift(), STCayleySetAntishift()

Location: src/sys/classes/st/impls/cayley/cayley.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetShift.html0000644000175000017500000000435713107004621020635 0ustar jromanjroman STSetShift

slepc-3.7.4 2017-05-17

STSetShift

Sets the shift associated with the spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetShift(ST st,PetscScalar shift)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
shift  - the value of the shift

Notes

In some spectral transformations, changing the shift may have associated a lot of work, for example recomputing a factorization.

This function is normally not directly called by users, since the shift is indirectly set by EPSSetTarget().

See Also

EPSSetTarget(), STGetShift(), STSetDefaultShift()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STPrecondSetKSPHasMat.html0000644000175000017500000000436213107004621022622 0ustar jromanjroman STPrecondSetKSPHasMat

slepc-3.7.4 2017-05-17

STPrecondSetKSPHasMat

Sets a flag indicating that during STSetUp the coefficient matrix of the KSP linear system (A) must be set to be the same matrix as the preconditioner (P).

Synopsis

#include "slepcst.h" 
PetscErrorCode STPrecondSetKSPHasMat(ST st,PetscBool setmat)
Collective on ST

Input Parameter

st  - the spectral transformation context
setmat  - the flag

Notes

In most cases, the preconditioner matrix is used only in the PC object, but in external solvers this matrix must be provided also as the A-matrix in the KSP object.

See Also

STPrecondGetKSPHasMat(), STSetShift()

Location: src/sys/classes/st/impls/precond/precond.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetTransform.html0000644000175000017500000000507713107004621021533 0ustar jromanjroman STSetTransform

slepc-3.7.4 2017-05-17

STSetTransform

Sets a flag to indicate whether the transformed matrices are computed or not.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetTransform(ST st,PetscBool flg)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
flg  - the boolean flag

Options Database Key

-st_transform <bool>  - Activate/deactivate the computation of matrices.

Notes

This flag is intended for the case of polynomial eigenproblems solved via linearization. If this flag is off (default) the spectral transformation is applied to the linearization (handled by the eigensolver), otherwise it is applied to the original problem.

See Also

STMatSolve(), STMatMult(), STSetMatStructure(), STGetTransform()

Location: src/sys/classes/st/interface/stset.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STMatGetSize.html0000644000175000017500000000357213107004621021116 0ustar jromanjroman STMatGetSize

slepc-3.7.4 2017-05-17

STMatGetSize

Returns the number of rows and columns of the ST matrices.

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatGetSize(ST st,PetscInt *m,PetscInt *n)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameters

m  - the number of global rows
n  - the number of global columns

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STRegisterAll.html0000644000175000017500000000263713107004621021320 0ustar jromanjroman STRegisterAll

slepc-3.7.4 2017-05-17

STRegisterAll

Registers all of the spectral transformations in the ST package.

Synopsis

#include "slepcst.h"   
PetscErrorCode STRegisterAll(void)
Not Collective

See Also

STRegister()

Location: src/sys/classes/st/interface/stregis.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetBilinearForm.html0000644000175000017500000000371113107004621022106 0ustar jromanjroman STGetBilinearForm

slepc-3.7.4 2017-05-17

STGetBilinearForm

Returns the matrix used in the bilinear form with a generalized problem with semi-definite B.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetBilinearForm(ST st,Mat *B)
Not collective, though a parallel Mat may be returned

Input Parameters

st  - the spectral transformation context

Output Parameter

B  - output matrix

Notes

The output matrix B must be destroyed after use. It will be NULL in case of standard eigenproblems.

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSetDefaultShift.html0000644000175000017500000000353413107004621022136 0ustar jromanjroman STSetDefaultShift

slepc-3.7.4 2017-05-17

STSetDefaultShift

Sets the value of the shift that should be employed if the user did not specify one.

Synopsis

#include "slepcst.h" 
PetscErrorCode STSetDefaultShift(ST st,PetscScalar defaultshift)
Logically Collective on ST

Input Parameters

st  - the spectral transformation context
defaultshift  - the default value of the shift

See Also

STSetShift()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STPrecondSetMatForPC.html0000644000175000017500000000472313107004621022503 0ustar jromanjroman STPrecondSetMatForPC

slepc-3.7.4 2017-05-17

STPrecondSetMatForPC

Sets the matrix that must be used to build the preconditioner.

Synopsis

#include "slepcst.h" 
PetscErrorCode STPrecondSetMatForPC(ST st,Mat mat)
Logically Collective on ST and Mat

Input Parameter

st  - the spectral transformation context
mat  - the matrix that will be used in constructing the preconditioner

Notes

This matrix will be passed to the KSP object (via KSPSetOperators) as the matrix to be used when constructing the preconditioner. If no matrix is set or mat is set to NULL, A - sigma*B will be used to build the preconditioner, being sigma the value set by STSetShift().

See Also

STPrecondSetMatForPC(), STSetShift()

Location: src/sys/classes/st/impls/precond/precond.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex24.c.html
slepc-3.7.4/docs/manualpages/ST/STBackTransform.html0000644000175000017500000000314213107004621021627 0ustar jromanjroman STBackTransform
slepc-3.7.4 2017-05-17

STBackTransform

Back-transformation phase, intended for spectral transformations which require to transform the computed eigenvalues back to the original eigenvalue problem.

Synopsis

#include "slepcst.h" 
PetscErrorCode STBackTransform(ST st,PetscInt n,PetscScalar* eigr,PetscScalar* eigi)
Not Collective

Input Parameters

st - the spectral transformation context eigr - real part of a computed eigenvalue eigi - imaginary part of a computed eigenvalue

Location: src/sys/classes/st/interface/stsolve.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STSHELL.html0000644000175000017500000000440513107004621017745 0ustar jromanjroman STSHELL

slepc-3.7.4 2017-05-17

STSHELL

Creates a new spectral transformation class. This is intended to provide a simple class to use with EPS. You should not use this if you plan to make a complete class.

Usage

            PetscErrorCode (*apply)(void*,Vec,Vec);
            PetscErrorCode (*applytrans)(void*,Vec,Vec);
            PetscErrorCode (*backtr)(void*,PetscScalar*,PetscScalar*);
            STCreate(comm,&st);
            STSetType(st,STSHELL);
            STShellSetApply(st,apply);
            STShellSetApplyTranspose(st,applytrans);
            STShellSetBackTransform(st,backtr);    (optional)

Location: src/sys/classes/st/impls/shell/shell.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex10.c.html
slepc-3.7.4/docs/manualpages/ST/STReset.html0000644000175000017500000000317413107004621020162 0ustar jromanjroman STReset
slepc-3.7.4 2017-05-17

STReset

Resets the ST context and removes any allocated objects.

Synopsis

#include "slepcst.h" 
PetscErrorCode STReset(ST st)
Collective on ST

Input Parameter

st  - the spectral transformation context

See Also

STDestroy()

Location: src/sys/classes/st/interface/stfunc.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STCheckNullSpace.html0000644000175000017500000000422213107004621021717 0ustar jromanjroman STCheckNullSpace

slepc-3.7.4 2017-05-17

STCheckNullSpace

Given a basis vectors object, this function tests each of its constraint vectors to be a nullspace vector of the coefficient matrix of the associated KSP object. All these nullspace vectors are passed to the KSP object.

Synopsis

#include "slepcst.h" 
PetscErrorCode STCheckNullSpace(ST st,BV V)
Collective on ST

Input Parameters

st  - the spectral transformation context
V  - basis vectors to be checked

Note

This function allows to handle singular pencils and to solve some problems in which the nullspace is important (see the users guide for details).

See Also

EPSSetDeflationSpace()

Location: src/sys/classes/st/interface/stsles.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STMatMult.html0000644000175000017500000000420513107004621020457 0ustar jromanjroman STMatMult

slepc-3.7.4 2017-05-17

STMatMult

Computes the matrix-vector product y = T[k] x, where T[k] is the k-th matrix of the spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STMatMult(ST st,PetscInt k,Vec x,Vec y)
Collective on ST

Input Parameters

st  - the spectral transformation context
k  - index of matrix to use
x  - the vector to be multiplied

Output Parameter

y  - the result

See Also

STMatMultTranspose()

Location: src/sys/classes/st/interface/stsles.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/ST/STGetKSP.html0000644000175000017500000000423513107004621020174 0ustar jromanjroman STGetKSP

slepc-3.7.4 2017-05-17

STGetKSP

Gets the KSP object associated with the spectral transformation.

Synopsis

#include "slepcst.h" 
PetscErrorCode STGetKSP(ST st,KSP* ksp)
Not Collective

Input Parameter

st  - the spectral transformation context

Output Parameter

ksp  - the linear system context

Location: src/sys/classes/st/interface/stsles.c
Index of all ST routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex24.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/0000755000175000017500000000000013107004621016037 5ustar jromanjromanslepc-3.7.4/docs/manualpages/EPS/EPSConv.html0000644000175000017500000000305513107004621020205 0ustar jromanjroman EPSConv
slepc-3.7.4 2017-05-17

EPSConv

Determines the convergence test

Synopsis

typedef enum { EPS_CONV_ABS,
               EPS_CONV_REL,
               EPS_CONV_NORM,
               EPS_CONV_USER } EPSConv;

See Also

EPSSetConvergenceTest(), EPSSetConvergenceTestFunction()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetIterationNumber.html0000644000175000017500000000646613107004621023060 0ustar jromanjroman EPSGetIterationNumber

slepc-3.7.4 2017-05-17

EPSGetIterationNumber

Gets the current iteration number. If the call to EPSSolve() is complete, then it returns the number of iterations carried out by the solution method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetIterationNumber(EPS eps,PetscInt *its)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

its  - number of iterations

Note

During the i-th iteration this call returns i-1. If EPSSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call EPSGetConvergedReason() to determine if the solver converged or failed and why.

See Also

EPSGetConvergedReason(), EPSSetTolerances()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex31.c.html
src/eps/examples/tutorials/ex1f.F.html
src/eps/examples/tutorials/ex6f.F.html
slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetRestart.html0000644000175000017500000000373313107004621023603 0ustar jromanjroman EPSKrylovSchurGetRestart
slepc-3.7.4 2017-05-17

EPSKrylovSchurGetRestart

Gets the restart parameter used in the Krylov-Schur method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetRestart(EPS eps,PetscReal *keep)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

keep  - the restart parameter

See Also

EPSKrylovSchurSetRestart()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSErrorType.html0000644000175000017500000000273413107004621021236 0ustar jromanjroman EPSErrorType

slepc-3.7.4 2017-05-17

EPSErrorType

The error type used to assess accuracy of computed solutions

Synopsis

typedef enum { EPS_ERROR_ABSOLUTE,
               EPS_ERROR_RELATIVE,
               EPS_ERROR_BACKWARD } EPSErrorType;

See Also

EPSComputeError()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDSetKrylovStart.html0000644000175000017500000000417713107004621022501 0ustar jromanjroman EPSGDSetKrylovStart

slepc-3.7.4 2017-05-17

EPSGDSetKrylovStart

Activates or deactivates starting the searching subspace with a Krylov basis.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
krylovstart  - boolean flag

Options Database Key

-eps_gd_krylov_start  - Activates starting the searching subspace with a Krylov basis

See Also

EPSGDGetKrylovStart()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetProblemType.html0000644000175000017500000001137013107004621022215 0ustar jromanjroman EPSSetProblemType

slepc-3.7.4 2017-05-17

EPSSetProblemType

Specifies the type of the eigenvalue problem.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
type  - a known type of eigenvalue problem

Options Database Keys

-eps_hermitian  - Hermitian eigenvalue problem
-eps_gen_hermitian  - generalized Hermitian eigenvalue problem
-eps_non_hermitian  - non-Hermitian eigenvalue problem
-eps_gen_non_hermitian  - generalized non-Hermitian eigenvalue problem
-eps_pos_gen_non_hermitian  - generalized non-Hermitian eigenvalue problem with positive semi-definite B

Notes

Allowed values for the problem type are: Hermitian (EPS_HEP), non-Hermitian (EPS_NHEP), generalized Hermitian (EPS_GHEP), generalized non-Hermitian (EPS_GNHEP), generalized non-Hermitian with positive semi-definite B (EPS_PGNHEP), and generalized Hermitian-indefinite (EPS_GHIEP).

This function must be used to instruct SLEPc to exploit symmetry. If no problem type is specified, by default a non-Hermitian problem is assumed (either standard or generalized). If the user knows that the problem is Hermitian (i.e. A=A^H) or generalized Hermitian (i.e. A=A^H, B=B^H, and B positive definite) then it is recommended to set the problem type so that eigensolver can exploit these properties.

See Also

EPSSetOperators(), EPSSetType(), EPSGetProblemType(), EPSProblemType

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex18.c.html
src/eps/examples/tutorials/ex19.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetBV.html0000644000175000017500000000354113107004621020247 0ustar jromanjroman EPSGetBV
slepc-3.7.4 2017-05-17

EPSGetBV

Obtain the basis vectors object associated to the eigensolver object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetBV(EPS eps,BV *V)
Not Collective

Input Parameters

eps  - eigensolver context obtained from EPSCreate()

Output Parameter

V  - basis vectors context

See Also

EPSSetBV()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetInertias.html0000644000175000017500000000641713107004621023737 0ustar jromanjroman EPSKrylovSchurGetInertias

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetInertias

Gets the values of the shifts and their corresponding inertias in case of doing spectrum slicing for a computational interval.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

n  - number of shifts, including the endpoints of the interval
shifts  - the values of the shifts used internally in the solver
inertias  - the values of the inertia in each shift

Notes

If called after EPSSolve(), all shifts used internally by the solver are returned (including both endpoints and any intermediate ones). If called before EPSSolve() and after EPSSetUp() then only the information of the endpoints of subintervals is available.

This function is only available for spectrum slicing runs.

The returned arrays should be freed by the user.

See Also

EPSSetInterval(), EPSKrylovSchurSetSubintervals()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSPowerGetShiftType.html0000644000175000017500000000374413107004621022701 0ustar jromanjroman EPSPowerGetShiftType
slepc-3.7.4 2017-05-17

EPSPowerGetShiftType

Gets the type of shifts used during the power iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSPowerGetShiftType(EPS eps,EPSPowerShiftType *shift)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Input Parameter

shift  - the type of shift

See Also

EPSPowerSetShiftType(), EPSPowerShiftType

Location: src/eps/impls/power/power.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetPurify.html0000644000175000017500000000351313107004621021215 0ustar jromanjroman EPSGetPurify

slepc-3.7.4 2017-05-17

EPSGetPurify

Returns the flag indicating whether purification is activated or not.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetPurify(EPS eps,PetscBool *purify)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

purify  - the returned flag

See Also

EPSSetPurify()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurSetDimensions.html0000644000175000017500000000620513107004621024300 0ustar jromanjroman EPSKrylovSchurSetDimensions

slepc-3.7.4 2017-05-17

EPSKrylovSchurSetDimensions

Sets the dimensions used for each subsolve step in case of doing spectrum slicing for a computational interval. The meaning of the parameters is the same as in EPSSetDimensions().

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the subsolve
mpd  - the maximum dimension allowed for the projected problem

Options Database Key

-eps_krylovschur_nev <nev>  - Sets the number of eigenvalues
-eps_krylovschur_ncv <ncv>  - Sets the dimension of the subspace
-eps_krylovschur_mpd <mpd>  - Sets the maximum projected dimension

See Also

EPSKrylovSchurGetDimensions(), EPSSetDimensions(), EPSSetInterval()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDSetBOrth.html0000644000175000017500000000416613107004621021214 0ustar jromanjroman EPSJDSetBOrth

slepc-3.7.4 2017-05-17

EPSJDSetBOrth

Selects the orthogonalization that will be used in the search subspace in case of generalized Hermitian problems.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetBOrth(EPS eps,PetscBool borth)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
borth  - whether to B-orthogonalize the search subspace

Options Database Key

-eps_jd_borth  - Set the orthogonalization used in the search subspace

See Also

EPSJDGetBOrth()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDSetDoubleExpansion.html0000644000175000017500000000422113107004621023262 0ustar jromanjroman EPSGDSetDoubleExpansion

slepc-3.7.4 2017-05-17

EPSGDSetDoubleExpansion

Activate a variant where the search subspace is expanded with K*[A*x B*x] (double expansion) instead of the classic K*r, where K is the preconditioner, x the selected approximate eigenvector and r its associated residual vector.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDSetDoubleExpansion(EPS eps,PetscBool doubleexp)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
doubleexp  - the boolean flag

Options Database Keys

-eps_gd_double_expansion  - activate the double-expansion variant of GD

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDSetInitialSize.html0000644000175000017500000000560013107004621022411 0ustar jromanjroman EPSGDSetInitialSize

slepc-3.7.4 2017-05-17

EPSGDSetInitialSize

Sets the initial size of the searching space.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
initialsize  - number of vectors of the initial searching subspace

Options Database Key

-eps_gd_initial_size  - number of vectors of the initial searching subspace

Notes

If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors.

See Also

EPSGDGetInitialSize(), EPSGDGetKrylovStart()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDSetConstCorrectionTol.html0000644000175000017500000000455413107004621023774 0ustar jromanjroman EPSJDSetConstCorrectionTol

slepc-3.7.4 2017-05-17

EPSJDSetConstCorrectionTol

If true, deactivates the dynamic stopping criterion (also called Newton) that sets the KSP relative tolerance to 0.5**i, where i is the number of EPS iterations from the last converged value.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetConstCorrectionTol(EPS eps,PetscBool constant)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
constant  - if false, the KSP relative tolerance is set to 0.5**i.

Options Database Key

-eps_jd_const_correction_tol  - Deactivates the dynamic stopping criterion.

See Also

EPSJDGetConstCorrectionTol()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSReasonViewFromOptions.html0000644000175000017500000000320513107004621023557 0ustar jromanjroman EPSReasonViewFromOptions

slepc-3.7.4 2017-05-17

EPSReasonViewFromOptions

Processes command line options to determine if/how the EPS converged reason is to be viewed.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSReasonViewFromOptions(EPS eps)
Collective on EPS

Input Parameters

eps  - the eigensolver context

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSValuesView.html0000644000175000017500000000414313107004621021371 0ustar jromanjroman EPSValuesView

slepc-3.7.4 2017-05-17

EPSValuesView

Displays the computed eigenvalues in a viewer.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSValuesView(EPS eps,PetscViewer viewer)
Collective on EPS

Input Parameters

eps  - the eigensolver context
viewer  - the viewer

Options Database Key

-eps_view_values  - print computed eigenvalues

See Also

EPSSolve(), EPSVectorsView(), EPSErrorView()

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSPRIMMEGetMethod.html0000644000175000017500000000374313107004621022076 0ustar jromanjroman EPSPRIMMEGetMethod

slepc-3.7.4 2017-05-17

EPSPRIMMEGetMethod

Gets the method for the PRIMME library.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSPRIMMEGetMethod(EPS eps,EPSPRIMMEMethod *method)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

method  - method that will be used by PRIMME

See Also

EPSPRIMMESetMethod(), EPSPRIMMEMethod

Location: src/eps/impls/external/primme/primme.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSType.html0000644000175000017500000000360113107004621020216 0ustar jromanjroman EPSType

slepc-3.7.4 2017-05-17

EPSType

String with the name of a SLEPc eigensolver

Synopsis

typedef const char* EPSType;
#define EPSPOWER       "power"
#define EPSSUBSPACE    "subspace"
#define EPSARNOLDI     "arnoldi"
#define EPSLANCZOS     "lanczos"
#define EPSKRYLOVSCHUR "krylovschur"
#define EPSGD          "gd"
#define EPSJD          "jd"
#define EPSRQCG        "rqcg"
#define EPSLOBPCG      "lobpcg"
#define EPSCISS        "ciss"
#define EPSLAPACK      "lapack"
#define EPSARPACK      "arpack"
#define EPSBLZPACK     "blzpack"
#define EPSTRLAN       "trlan"
#define EPSBLOPEX      "blopex"
#define EPSPRIMME      "primme"
#define EPSFEAST       "feast"

See Also

EPSSetType(), EPS

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSLOBPCGSetLocking.html0000644000175000017500000000447013107004621022233 0ustar jromanjroman EPSLOBPCGSetLocking

slepc-3.7.4 2017-05-17

EPSLOBPCGSetLocking

Choose between locking and non-locking variants of the LOBPCG method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLOBPCGSetLocking(EPS eps,PetscBool lock)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
lock  - true if the locking variant must be selected

Options Database Key

-eps_lobpcg_locking  - Sets the locking flag

Notes

This flag refers to soft locking (converged vectors within the current block iterate), since hard locking is always used (when nev is larger than the block size).

See Also

EPSLOBPCGGetLocking()

Location: src/eps/impls/cg/lobpcg/lobpcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetDS.html0000644000175000017500000000372113107004621020262 0ustar jromanjroman EPSSetDS

slepc-3.7.4 2017-05-17

EPSSetDS

Associates a direct solver object to the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetDS(EPS eps,DS ds)
Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
ds  - the direct solver object

Note

Use EPSGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations).

See Also

EPSGetDS()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSInitializePackage.html0000644000175000017500000000312113107004621022647 0ustar jromanjroman EPSInitializePackage

slepc-3.7.4 2017-05-17

EPSInitializePackage

This function initializes everything in the EPS package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to EPSCreate() when using static libraries.

Synopsis

PetscErrorCode EPSInitializePackage()

See Also

SlepcInitialize()

Location: src/eps/interface/dlregiseps.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSSetThreshold.html0000644000175000017500000000454713107004621022401 0ustar jromanjroman EPSCISSSetThreshold

slepc-3.7.4 2017-05-17

EPSCISSSetThreshold

Sets the values of various threshold parameters in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSSetThreshold(EPS eps,PetscReal delta,PetscReal spur)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
delta  - threshold for numerical rank
spur  - spurious threshold (to discard spurious eigenpairs)

Options Database Keys

-eps_ciss_delta  - Sets the delta
-eps_ciss_spurious_threshold  - Sets the spurious threshold

See Also

EPSCISSGetThreshold()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSLanczosSetReorthog.html0000644000175000017500000000450413107004621023077 0ustar jromanjroman EPSLanczosSetReorthog

slepc-3.7.4 2017-05-17

EPSLanczosSetReorthog

Sets the type of reorthogonalization used during the Lanczos iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLanczosSetReorthog(EPS eps,EPSLanczosReorthogType reorthog)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
reorthog  - the type of reorthogonalization

Options Database Key

-eps_lanczos_reorthog  - Sets the reorthogonalization type (either 'local', 'selective', 'periodic', 'partial', 'full' or 'delayed')

See Also

EPSLanczosGetReorthog(), EPSLanczosReorthogType

Location: src/eps/impls/krylov/lanczos/lanczos.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetStoppingTestFunction.html0000644000175000017500000001061413107004621024124 0ustar jromanjroman EPSSetStoppingTestFunction

slepc-3.7.4 2017-05-17

EPSSetStoppingTestFunction

Sets a function to decide when to stop the outer iteration of the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetStoppingTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
func  - pointer to the stopping test function
ctx  - context for private data for the stopping routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)

eps  - eigensolver context obtained from EPSCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged eigenpairs
nev  - number of requested eigenpairs
reason  - (output) result of the stopping test
ctx  - optional context, as set by EPSSetStoppingTestFunction()

Note

Normal usage is to first call the default routine EPSStoppingBasic() and then set reason to EPS_CONVERGED_USER if some user-defined conditions have been met. To let the eigensolver continue iterating, the result must be left as EPS_CONVERGED_ITERATING.

See Also

EPSSetStoppingTest(), EPSStoppingBasic()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex29.c.html
src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSJDGetFix.html0000644000175000017500000000411213107004621020677 0ustar jromanjroman EPSJDGetFix
slepc-3.7.4 2017-05-17

EPSJDGetFix

Returns the threshold for changing the target in the correction equation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetFix(EPS eps,PetscReal *fix)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

fix  - threshold for changing the target

Note

The target in the correction equation is fixed at the first iterations. When the norm of the residual vector is lower than the fix value, the target is set to the corresponding eigenvalue.

See Also

EPSJDSetFix()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSErrorViewFromOptions.html0000644000175000017500000000315113107004621023421 0ustar jromanjroman EPSErrorViewFromOptions

slepc-3.7.4 2017-05-17

EPSErrorViewFromOptions

Processes command line options to determine if/how the errors of the computed solution are to be viewed.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSErrorViewFromOptions(EPS eps)
Collective on EPS

Input Parameters

eps  - the eigensolver context

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurSetRestart.html0000644000175000017500000000454613107004621023622 0ustar jromanjroman EPSKrylovSchurSetRestart

slepc-3.7.4 2017-05-17

EPSKrylovSchurSetRestart

Sets the restart parameter for the Krylov-Schur method, in particular the proportion of basis vectors that must be kept after restart.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurSetRestart(EPS eps,PetscReal keep)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
keep  - the number of vectors to be kept at restart

Options Database Key

-eps_krylovschur_restart  - Sets the restart parameter

Notes

Allowed values are in the range [0.1,0.9]. The default is 0.5.

See Also

EPSKrylovSchurGetRestart()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSProblemType.html0000644000175000017500000000314413107004621021541 0ustar jromanjroman EPSProblemType

slepc-3.7.4 2017-05-17

EPSProblemType

Determines the type of eigenvalue problem

Synopsis

typedef enum { EPS_HEP=1,
               EPS_GHEP,
               EPS_NHEP,
               EPS_GNHEP,
               EPS_PGNHEP,
               EPS_GHIEP } EPSProblemType;

See Also

EPSSetProblemType(), EPSGetProblemType()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetInterval.html0000644000175000017500000000450713107004621021527 0ustar jromanjroman EPSGetInterval

slepc-3.7.4 2017-05-17

EPSGetInterval

Gets the computational interval for spectrum slicing.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb)
Not Collective

Input Parameter

eps  - eigensolver context

Output Parameters

inta  - left end of the interval
intb  - right end of the interval

Note

If the interval was not set by the user, then zeros are returned.

See Also

EPSSetInterval()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSMonitorAll.html0000644000175000017500000000537713107004621021371 0ustar jromanjroman EPSMonitorAll
slepc-3.7.4 2017-05-17

EPSMonitorAll

Print the current approximate values and error estimates at each iteration of the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSMonitorAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on EPS

Input Parameters

eps  - eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorConverged()

Location: src/eps/interface/epsmon.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetPartitions.html0000644000175000017500000000401113107004621024301 0ustar jromanjroman EPSKrylovSchurGetPartitions

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetPartitions

Gets the number of partitions of the communicator in case of spectrum slicing.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetPartitions(EPS eps,PetscInt *npart)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

npart  - number of partitions

See Also

EPSKrylovSchurSetPartitions()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetBalance.html0000644000175000017500000000750013107004621021300 0ustar jromanjroman EPSSetBalance

slepc-3.7.4 2017-05-17

EPSSetBalance

Specifies the balancing technique to be employed by the eigensolver, and some parameters associated to it.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetBalance(EPS eps,EPSBalance bal,PetscInt its,PetscReal cutoff)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
bal  - the balancing method, one of EPS_BALANCE_NONE, EPS_BALANCE_ONESIDE, EPS_BALANCE_TWOSIDE, or EPS_BALANCE_USER
its  - number of iterations of the balancing algorithm
cutoff  - cutoff value

Options Database Keys

-eps_balance <method>  - the balancing method, where <method> is one of 'none', 'oneside', 'twoside', or 'user'
-eps_balance_its <its>  - number of iterations
-eps_balance_cutoff <cutoff>  - cutoff value

Notes

When balancing is enabled, the solver works implicitly with matrix DAD^-1, where D is an appropriate diagonal matrix. This improves the accuracy of the computed results in some cases. See the SLEPc Users Manual for details.

Balancing makes sense only for non-Hermitian problems when the required precision is high (i.e. a small tolerance such as 1e-15).

By default, balancing is disabled. The two-sided method is much more effective than the one-sided counterpart, but it requires the system matrices to have the MatMultTranspose operation defined.

The parameter 'its' is the number of iterations performed by the method. The cutoff value is used only in the two-side variant. Use PETSC_DEFAULT to assign a reasonably good value.

User-defined balancing is allowed provided that the corresponding matrix is set via STSetBalanceMatrix.

See Also

EPSGetBalance(), EPSBalance, STSetBalanceMatrix()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSMonitorCancel.html0000644000175000017500000000421513107004621022034 0ustar jromanjroman EPSMonitorCancel

slepc-3.7.4 2017-05-17

EPSMonitorCancel

Clears all monitors for an EPS object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSMonitorCancel(EPS eps)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()

Options Database Key

-eps_monitor_cancel  - Cancels all monitors that have been hardwired into a code by calls to EPSMonitorSet(), but does not cancel those set via the options database.

See Also

EPSMonitorSet()

Location: src/eps/interface/epsmon.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurSetLocking.html0000644000175000017500000000471613107004621023563 0ustar jromanjroman EPSKrylovSchurSetLocking

slepc-3.7.4 2017-05-17

EPSKrylovSchurSetLocking

Choose between locking and non-locking variants of the Krylov-Schur method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurSetLocking(EPS eps,PetscBool lock)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
lock  - true if the locking variant must be selected

Options Database Key

-eps_krylovschur_locking  - Sets the locking flag

Notes

The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant).

See Also

EPSKrylovSchurGetLocking()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetBalance.html0000644000175000017500000000447613107004621021275 0ustar jromanjroman EPSGetBalance

slepc-3.7.4 2017-05-17

EPSGetBalance

Gets the balancing type used by the EPS object, and the associated parameters.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetBalance(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameters

bal  - the balancing method
its  - number of iterations of the balancing algorithm
cutoff  - cutoff value

Note

The user can specify NULL for any parameter that is not needed.

See Also

EPSSetBalance(), EPSBalance

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurSetDetectZeros.html0000644000175000017500000000557313107004621024432 0ustar jromanjroman EPSKrylovSchurSetDetectZeros

slepc-3.7.4 2017-05-17

EPSKrylovSchurSetDetectZeros

Sets a flag to enforce detection of zeros during the factorizations throughout the spectrum slicing computation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurSetDetectZeros(EPS eps,PetscBool detect)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
detect  - check for zeros

Options Database Key

-eps_krylovschur_detect_zeros  - Check for zeros; this takes an optional bool value (0/1/no/yes/true/false)

Notes

A zero in the factorization indicates that a shift coincides with an eigenvalue.

This flag is turned off by default, and may be necessary in some cases, especially when several partitions are being used. This feature currently requires an external package for factorizations with support for zero detection, e.g. MUMPS.

See Also

EPSKrylovSchurSetPartitions(), EPSSetInterval()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetTrueResidual.html0000644000175000017500000000362413107004621022352 0ustar jromanjroman EPSGetTrueResidual
slepc-3.7.4 2017-05-17

EPSGetTrueResidual

Returns the flag indicating whether true residuals must be computed explicitly or not.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetTrueResidual(EPS eps,PetscBool *trueres)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

trueres  - the returned flag

See Also

EPSSetTrueResidual()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDGetConstCorrectionTol.html0000644000175000017500000000434113107004621023752 0ustar jromanjroman EPSJDGetConstCorrectionTol

slepc-3.7.4 2017-05-17

EPSJDGetConstCorrectionTol

Returns a flag indicating if the dynamic stopping is being used for solving the correction equation. If the flag is false the KSP relative tolerance is set to 0.5**i, where i is the number of EPS iterations from the last converged value.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetConstCorrectionTol(EPS eps,PetscBool *constant)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

constant  - boolean flag indicating if the dynamic stopping criterion is not being used.

See Also

EPSJDGetConstCorrectionTol()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSGetUseST.html0000644000175000017500000000370013107004621021422 0ustar jromanjroman EPSCISSGetUseST

slepc-3.7.4 2017-05-17

EPSCISSGetUseST

Gets the flag for using the ST object in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSGetUseST(EPS eps,PetscBool *usest)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

usest  - boolean flag indicating if the ST object is being used

See Also

EPSCISSSetUseST()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSBLOPEXSetBlockSize.html0000644000175000017500000000410413107004621022547 0ustar jromanjroman EPSBLOPEXSetBlockSize

slepc-3.7.4 2017-05-17

EPSBLOPEXSetBlockSize

Sets the block size of the BLOPEX solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSBLOPEXSetBlockSize(EPS eps,PetscInt bs)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
bs  - the block size

Options Database Key

-eps_blopex_blocksize  - Sets the block size

See Also

EPSBLOPEXGetBlockSize()

Location: src/eps/impls/external/blopex/blopex.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetDetectZeros.html0000644000175000017500000000405313107004621024406 0ustar jromanjroman EPSKrylovSchurGetDetectZeros

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetDetectZeros

Gets the flag that enforces zero detection in spectrum slicing.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetDetectZeros(EPS eps,PetscBool *detect)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

detect  - whether zeros detection is enforced during factorizations

See Also

EPSKrylovSchurSetDetectZeros()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDSetWindowSizes.html0000644000175000017500000000501413107004621022454 0ustar jromanjroman EPSJDSetWindowSizes

slepc-3.7.4 2017-05-17

EPSJDSetWindowSizes

Sets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
pwindow  - number of converged vectors in the projector
qwindow  - number of converged vectors in the projected problem

Options Database Keys

-eps_jd_pwindow  - set the number of converged vectors in the projector
-eps_jd_qwindow  - set the number of converged vectors in the projected problem

See Also

EPSJDGetWindowSizes()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSIsHermitian.html0000644000175000017500000000413713107004621021516 0ustar jromanjroman EPSIsHermitian

slepc-3.7.4 2017-05-17

EPSIsHermitian

Ask if the EPS object corresponds to a Hermitian eigenvalue problem.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is)
Not collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

is  - the answer

See Also

EPSIsGeneralized(), EPSIsPositive()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex7.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetConvergedReason.html0000644000175000017500000000632213107004621023024 0ustar jromanjroman EPSGetConvergedReason
slepc-3.7.4 2017-05-17

EPSGetConvergedReason

Gets the reason why the EPSSolve() iteration was stopped.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetConvergedReason(EPS eps,EPSConvergedReason *reason)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

reason  - negative value indicates diverged, positive value converged

Notes

Possible values for reason are
EPS_CONVERGED_TOL  - converged up to tolerance
EPS_CONVERGED_USER  - converged due to a user-defined condition
EPS_DIVERGED_ITS  - required more than max_it iterations to reach convergence
EPS_DIVERGED_BREAKDOWN  - generic breakdown in method
EPS_DIVERGED_SYMMETRY_LOST  - pseudo-Lanczos was not able to keep symmetry

Can only be called after the call to EPSSolve() is complete.

See Also

EPSSetTolerances(), EPSSolve(), EPSConvergedReason

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex29.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetDimensions.html0000644000175000017500000000456713107004621024275 0ustar jromanjroman EPSKrylovSchurGetDimensions
slepc-3.7.4 2017-05-17

EPSKrylovSchurGetDimensions

Gets the dimensions used for each subsolve step in case of doing spectrum slicing for a computational interval.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the subsolve
mpd  - the maximum dimension allowed for the projected problem

See Also

EPSKrylovSchurSetDimensions()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSVectorsView.html0000644000175000017500000000451113107004621021556 0ustar jromanjroman EPSVectorsView

slepc-3.7.4 2017-05-17

EPSVectorsView

Outputs computed eigenvectors to a viewer.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSVectorsView(EPS eps,PetscViewer viewer)
Collective on EPS

Parameter

eps  - the eigensolver context
viewer  - the viewer

Options Database Keys

-eps_view_vectors  - output eigenvectors.

Note

If PETSc was configured with real scalars, complex conjugate eigenvectors will be viewed as two separate real vectors, one containing the real part and another one containing the imaginary part.

See Also

EPSSolve(), EPSValuesView(), EPSErrorView()

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSConvergedReason.html0000644000175000017500000000427113107004621022365 0ustar jromanjroman EPSConvergedReason

slepc-3.7.4 2017-05-17

EPSConvergedReason

Reason an eigensolver was said to have converged or diverged

Synopsis

typedef enum {/* converged */
              EPS_CONVERGED_TOL                =  1,
              EPS_CONVERGED_USER               =  2,
              /* diverged */
              EPS_DIVERGED_ITS                 = -1,
              EPS_DIVERGED_BREAKDOWN           = -2,
              EPS_DIVERGED_SYMMETRY_LOST       = -3,
              EPS_CONVERGED_ITERATING          =  0} EPSConvergedReason;

See Also

EPSSolve(), EPSGetConvergedReason(), EPSSetTolerances()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex29.c.html
src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSLOBPCGSetBlockSize.html0000644000175000017500000000407013107004621022526 0ustar jromanjroman EPSLOBPCGSetBlockSize
slepc-3.7.4 2017-05-17

EPSLOBPCGSetBlockSize

Sets the block size of the LOBPCG method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLOBPCGSetBlockSize(EPS eps,PetscInt bs)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
bs  - the block size

Options Database Key

-eps_lobpcg_blocksize  - Sets the block size

See Also

EPSLOBPCGGetBlockSize()

Location: src/eps/impls/cg/lobpcg/lobpcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSSetSizes.html0000644000175000017500000000714513107004621021537 0ustar jromanjroman EPSCISSSetSizes

slepc-3.7.4 2017-05-17

EPSCISSSetSizes

Sets the values of various size parameters in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSSetSizes(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
ip  - number of integration points
bs  - block size
ms  - moment size
npart  - number of partitions when splitting the communicator
bsmax  - max block size
realmats  - A and B are real

Options Database Keys

-eps_ciss_integration_points  - Sets the number of integration points
-eps_ciss_blocksize  - Sets the block size
-eps_ciss_moments  - Sets the moment size
-eps_ciss_partitions  - Sets the number of partitions
-eps_ciss_maxblocksize  - Sets the maximum block size
-eps_ciss_realmats  - A and B are real

Note

The default number of partitions is 1. This means the internal KSP object is shared among all processes of the EPS communicator. Otherwise, the communicator is split into npart communicators, so that npart KSP solves proceed simultaneously.

See Also

EPSCISSGetSizes()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetSubcommPairs.html0000644000175000017500000000624113107004621024560 0ustar jromanjroman EPSKrylovSchurGetSubcommPairs

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetSubcommPairs

Gets the i-th eigenpair stored internally in the subcommunicator to which the calling process belongs.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetSubcommPairs(EPS eps,PetscInt i,PetscScalar *eig,Vec v)
Collective on the subcommunicator (if v is given)

Input Parameter

eps  - the eigenproblem solver context
i  - index of the solution

Output Parameters

eig  - the eigenvalue
v  - the eigenvector

Notes

It is allowed to pass NULL for v if the eigenvector is not required. Otherwise, the caller must provide a valid Vec objects, i.e., it must be created by the calling program with EPSKrylovSchurGetSubcommInfo().

The index i should be a value between 0 and n-1, where n is the number of vectors in the local subinterval, see EPSKrylovSchurGetSubcommInfo().

See Also

EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommInfo(), EPSKrylovSchurGetSubcommMats()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDGetWindowSizes.html0000644000175000017500000000424013107004621022440 0ustar jromanjroman EPSJDGetWindowSizes

slepc-3.7.4 2017-05-17

EPSJDGetWindowSizes

Gets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

pwindow  - number of converged vectors in the projector
qwindow  - number of converged vectors in the projected problem

See Also

EPSJDSetWindowSizes()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSBlzpackSetBlockSize.html0000644000175000017500000000367313107004621023156 0ustar jromanjroman EPSBlzpackSetBlockSize

slepc-3.7.4 2017-05-17

EPSBlzpackSetBlockSize

Sets the block size for the BLZPACK package.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,PetscInt bs)
Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
bs  - block size

Options Database Key

-eps_blzpack_block_size  - Sets the value of the block size

Location: src/eps/impls/external/blzpack/blzpack.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSIsGeneralized.html0000644000175000017500000000371613107004621022031 0ustar jromanjroman EPSIsGeneralized

slepc-3.7.4 2017-05-17

EPSIsGeneralized

Ask if the EPS object corresponds to a generalized eigenvalue problem.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is)
Not collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

is  - the answer

See Also

EPSIsHermitian(), EPSIsPositive()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetArbitrarySelection.html0000644000175000017500000001121713107004621023560 0ustar jromanjroman EPSSetArbitrarySelection

slepc-3.7.4 2017-05-17

EPSSetArbitrarySelection

Specifies a function intended to look for eigenvalues according to an arbitrary selection criterion. This criterion can be based on a computation involving the current eigenvector approximation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetArbitrarySelection(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*),void* ctx)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
func  - a pointer to the evaluation function
ctx  - a context pointer (the last parameter to the evaluation function)

Calling Sequence of func

  func(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)

er  - real part of the current eigenvalue approximation
ei  - imaginary part of the current eigenvalue approximation
xr  - real part of the current eigenvector approximation
xi  - imaginary part of the current eigenvector approximation
rr  - result of evaluation (real part)
ri  - result of evaluation (imaginary part)
ctx  - optional context, as set by EPSSetArbitrarySelection()

Notes

This provides a mechanism to select eigenpairs by evaluating a user-defined function. When a function has been provided, the default selection based on sorting the eigenvalues is replaced by the sorting of the results of this function (with the same sorting criterion given in EPSSetWhichEigenpairs()).

For instance, suppose you want to compute those eigenvectors that maximize a certain computable expression. Then implement the computation using the arguments xr and xi, and return the result in rr. Then set the standard sorting by magnitude so that the eigenpair with largest value of rr is selected.

This evaluation function is collective, that is, all processes call it and it can use collective operations; furthermore, the computed result must be the same in all processes.

The result of func is expressed as a complex number so that it is possible to use the standard eigenvalue sorting functions, but normally only rr is used. Set ri to zero unless it is meaningful in your application.

See Also

EPSSetWhichEigenpairs()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSGetQuadRule.html0000644000175000017500000000367513107004621022154 0ustar jromanjroman EPSCISSGetQuadRule

slepc-3.7.4 2017-05-17

EPSCISSGetQuadRule

Gets the quadrature rule used in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSGetQuadRule(EPS eps, EPSCISSQuadRule *quad)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

quad  - quadrature rule

See Also

EPSCISSSetQuadRule() EPSCISSQuadRule

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetTolerances.html0000644000175000017500000000564413107004621022045 0ustar jromanjroman EPSGetTolerances

slepc-3.7.4 2017-05-17

EPSGetTolerances

Gets the tolerance and maximum iteration count used by the EPS convergence tests.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetTolerances(EPS eps,PetscReal *tol,PetscInt *maxits)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameters

tol  - the convergence tolerance
maxits  - maximum number of iterations

Notes

The user can specify NULL for any parameter that is not needed.

See Also

EPSSetTolerances()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex24.c.html
src/eps/examples/tutorials/ex1f.F.html
src/eps/examples/tutorials/ex6f.F.html
slepc-3.7.4/docs/manualpages/EPS/EPSJDSetRestart.html0000644000175000017500000000473013107004621021617 0ustar jromanjroman EPSJDSetRestart
slepc-3.7.4 2017-05-17

EPSJDSetRestart

Sets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
minv  - number of vectors of the searching subspace after restarting
plusk  - number of vectors saved from the previous iteration

Options Database Keys

-eps_jd_minv  - number of vectors of the searching subspace after restarting
-eps_jd_plusk  - number of vectors saved from the previous iteration

See Also

EPSJDGetRestart()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetPurify.html0000644000175000017500000000474713107004621021243 0ustar jromanjroman EPSSetPurify

slepc-3.7.4 2017-05-17

EPSSetPurify

Deactivate eigenvector purification (which is activated by default).

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetPurify(EPS eps,PetscBool purify)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
purify  - whether purification is required or not

Options Database Keys

-eps_purify <boolean>  - Sets/resets the boolean flag 'purify'

Notes

By default, eigenvectors of generalized symmetric eigenproblems are purified in order to purge directions in the nullspace of matrix B. If the user knows that B is non-singular, then purification can be safely deactivated and some computational cost is avoided (this is particularly important in interval computations).

See Also

EPSGetPurify(), EPSSetInterval()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSFEASTGetNumPoints.html0000644000175000017500000000376213107004621022464 0ustar jromanjroman EPSFEASTGetNumPoints

slepc-3.7.4 2017-05-17

EPSFEASTGetNumPoints

Gets the number of contour integration points for the FEAST package.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSFEASTGetNumPoints(EPS eps,PetscInt *npoints)
Collective on EPS

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

npoints  - number of contour integration points

See Also

EPSFEASTSetNumPoints()

Location: src/eps/impls/external/feast/feast.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSMonitorFirst.html0000644000175000017500000000540113107004621021734 0ustar jromanjroman EPSMonitorFirst

slepc-3.7.4 2017-05-17

EPSMonitorFirst

Print the first approximate value and error estimate at each iteration of the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSMonitorFirst(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
Collective on EPS

Input Parameters

eps  - eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
vf  - viewer and format for monitoring

See Also

EPSMonitorSet(), EPSMonitorAll(), EPSMonitorConverged()

Location: src/eps/interface/epsmon.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetSubcommMats.html0000644000175000017500000000533713107004621024413 0ustar jromanjroman EPSKrylovSchurGetSubcommMats

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetSubcommMats

Gets the eigenproblem matrices stored internally in the subcommunicator to which the calling process belongs.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetSubcommMats(EPS eps,Mat *A,Mat *B)
Collective on the subcommunicator

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

A  - the matrix associated with the eigensystem
B  - the second matrix in the case of generalized eigenproblems

Notes

This is the analog of EPSGetOperators(), but returns the matrices distributed differently (in the subcommunicator rather than in the parent communicator).

These matrices should not be modified by the user.

See Also

EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommInfo()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetDeflationSpace.html0000644000175000017500000000544613107004621022643 0ustar jromanjroman EPSSetDeflationSpace

slepc-3.7.4 2017-05-17

EPSSetDeflationSpace

Specify a basis of vectors that constitute the deflation space.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetDeflationSpace(EPS eps,PetscInt n,Vec *v)
Collective on EPS and Vec

Input Parameter

eps  - the eigenproblem solver context
n  - number of vectors
v  - set of basis vectors of the deflation space

Notes

When a deflation space is given, the eigensolver seeks the eigensolution in the restriction of the problem to the orthogonal complement of this space. This can be used for instance in the case that an invariant subspace is known beforehand (such as the nullspace of the matrix).

These vectors do not persist from one EPSSolve() call to the other, so the deflation space should be set every time.

The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally.

See Also

EPSSetInitialSpace()

Location: src/eps/interface/epssetup.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex11.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSReasonView.html0000644000175000017500000000665513107004621021373 0ustar jromanjroman EPSReasonView
slepc-3.7.4 2017-05-17

EPSReasonView

Displays the reason an EPS solve converged or diverged.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSReasonView(EPS eps,PetscViewer viewer)
Collective on EPS

Parameter

eps  - the eigensolver context
viewer  - the viewer to display the reason

Options Database Keys

-eps_converged_reason  - print reason for convergence, and number of iterations

See Also

EPSSetConvergenceTest(), EPSSetTolerances(), EPSGetIterationNumber()

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex18.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSJDSetBlockSize.html0000644000175000017500000000424213107004621022056 0ustar jromanjroman EPSJDSetBlockSize
slepc-3.7.4 2017-05-17

EPSJDSetBlockSize

Sets the number of vectors to be added to the searching space in every iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetBlockSize(EPS eps,PetscInt blocksize)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
blocksize  - number of vectors added to the search space in every iteration

Options Database Key

-eps_jd_blocksize  - number of vectors added to the searching space every iteration

See Also

EPSJDSetKrylovStart()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSPRIMMEMethod.html0000644000175000017500000000405013107004621021426 0ustar jromanjroman EPSPRIMMEMethod

slepc-3.7.4 2017-05-17

EPSPRIMMEMethod

determines the method selected in the PRIMME library

Synopsis

typedef enum { EPS_PRIMME_DYNAMIC,
               EPS_PRIMME_DEFAULT_MIN_TIME,
               EPS_PRIMME_DEFAULT_MIN_MATVECS,
               EPS_PRIMME_ARNOLDI,
               EPS_PRIMME_GD,
               EPS_PRIMME_GD_PLUSK,
               EPS_PRIMME_GD_OLSEN_PLUSK,
               EPS_PRIMME_JD_OLSEN_PLUSK,
               EPS_PRIMME_RQI,
               EPS_PRIMME_JDQR,
               EPS_PRIMME_JDQMR,
               EPS_PRIMME_JDQMR_ETOL,
               EPS_PRIMME_SUBSPACE_ITERATION,
               EPS_PRIMME_LOBPCG_ORTHOBASIS,
               EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod;

See Also

EPSPRIMMESetMethod(), EPSPRIMMEGetMethod()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetSubintervals.html0000644000175000017500000000616713107004621024644 0ustar jromanjroman EPSKrylovSchurGetSubintervals

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetSubintervals

Returns the points that delimit the subintervals used in spectrum slicing with several partitions.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetSubintervals(EPS eps,PetscReal** subint)
Logically Collective on EPS

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

subint  - array of real values specifying subintervals

Notes

If the user passed values with EPSKrylovSchurSetSubintervals(), then the same values are returned. Otherwise, the values computed internally are obtained.

This function is only available for spectrum slicing runs.

The returned array has length npart+1 (see EPSKrylovSchurGetPartitions()) and should be freed by the user.

Fortran Notes

The calling sequence from Fortran is
   EPSKrylovSchurGetSubintervals(eps,subint,ierr)
   double precision subint(npart+1) output

See Also

EPSKrylovSchurSetSubintervals(), EPSKrylovSchurGetPartitions(), EPSSetInterval()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetRG.html0000644000175000017500000000367413107004621020273 0ustar jromanjroman EPSSetRG

slepc-3.7.4 2017-05-17

EPSSetRG

Associates a region object to the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetRG(EPS eps,RG rg)
Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
rg  - the region object

Note

Use EPSGetRG() to retrieve the region context (for example, to free it at the end of the computations).

See Also

EPSGetRG()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDGetRestart.html0000644000175000017500000000416213107004621021602 0ustar jromanjroman EPSJDGetRestart

slepc-3.7.4 2017-05-17

EPSJDGetRestart

Gets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

minv  - number of vectors of the searching subspace after restarting
plusk  - number of vectors saved from the previous iteration

See Also

EPSJDSetRestart()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSErrorView.html0000644000175000017500000001004213107004621021216 0ustar jromanjroman EPSErrorView

slepc-3.7.4 2017-05-17

EPSErrorView

Displays the errors associated with the computed solution (as well as the eigenvalues).

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSErrorView(EPS eps,EPSErrorType etype,PetscViewer viewer)
Collective on EPS

Input Parameters

eps  - the eigensolver context
etype  - error type
viewer  - optional visualization context

Options Database Key

-eps_error_absolute  - print absolute errors of each eigenpair
-eps_error_relative  - print relative errors of each eigenpair
-eps_error_backward  - print backward errors of each eigenpair

Notes

By default, this function checks the error of all eigenpairs and prints the eigenvalues if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with eigenvalues and corresponding errors is printed.

See Also

EPSSolve(), EPSValuesView(), EPSVectorsView()

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex18.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGDSetBOrth.html0000644000175000017500000000416613107004621021211 0ustar jromanjroman EPSGDSetBOrth
slepc-3.7.4 2017-05-17

EPSGDSetBOrth

Selects the orthogonalization that will be used in the search subspace in case of generalized Hermitian problems.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
borth  - whether to B-orthogonalize the search subspace

Options Database Key

-eps_gd_borth  - Set the orthogonalization used in the search subspace

See Also

EPSGDGetBOrth()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetWhichEigenpairs.html0000644000175000017500000001704313107004621023027 0ustar jromanjroman EPSSetWhichEigenpairs

slepc-3.7.4 2017-05-17

EPSSetWhichEigenpairs

Specifies which portion of the spectrum is to be sought.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetWhichEigenpairs(EPS eps,EPSWhich which)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
which  - the portion of the spectrum to be sought

Possible values

The parameter 'which' can have one of these values

EPS_LARGEST_MAGNITUDE  - largest eigenvalues in magnitude (default)
EPS_SMALLEST_MAGNITUDE  - smallest eigenvalues in magnitude
EPS_LARGEST_REAL  - largest real parts
EPS_SMALLEST_REAL  - smallest real parts
EPS_LARGEST_IMAGINARY  - largest imaginary parts
EPS_SMALLEST_IMAGINARY  - smallest imaginary parts
EPS_TARGET_MAGNITUDE  - eigenvalues closest to the target (in magnitude)
EPS_TARGET_REAL  - eigenvalues with real part closest to target
EPS_TARGET_IMAGINARY  - eigenvalues with imaginary part closest to target
EPS_ALL  - all eigenvalues contained in a given interval or region
EPS_WHICH_USER  - user defined ordering set with EPSSetEigenvalueComparison()

Options Database Keys

-eps_largest_magnitude  - Sets largest eigenvalues in magnitude
-eps_smallest_magnitude  - Sets smallest eigenvalues in magnitude
-eps_largest_real  - Sets largest real parts
-eps_smallest_real  - Sets smallest real parts
-eps_largest_imaginary  - Sets largest imaginary parts
-eps_smallest_imaginary  - Sets smallest imaginary parts
-eps_target_magnitude  - Sets eigenvalues closest to target
-eps_target_real  - Sets real parts closest to target
-eps_target_imaginary  - Sets imaginary parts closest to target
-eps_all  - Sets all eigenvalues in an interval or region

Notes

Not all eigensolvers implemented in EPS account for all the possible values stated above. Also, some values make sense only for certain types of problems. If SLEPc is compiled for real numbers EPS_LARGEST_IMAGINARY and EPS_SMALLEST_IMAGINARY use the absolute value of the imaginary part for eigenvalue selection.

The target is a scalar value provided with EPSSetTarget().

The criterion EPS_TARGET_IMAGINARY is available only in case PETSc and SLEPc have been built with complex scalars.

EPS_ALL is intended for use in combination with an interval (see EPSSetInterval()), when all eigenvalues within the interval are requested, or in the context of the CISS solver for computing all eigenvalues in a region. In those cases, the number of eigenvalues is unknown, so the nev parameter has a different sense, see EPSSetDimensions().

See Also

EPSGetWhichEigenpairs(), EPSSetTarget(), EPSSetInterval(),
EPSSetDimensions(), EPSSetEigenvalueComparison(), EPSWhich

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex24.c.html
src/eps/examples/tutorials/ex25.c.html
src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSLOBPCGGetLocking.html0000644000175000017500000000360213107004621022213 0ustar jromanjroman EPSLOBPCGGetLocking
slepc-3.7.4 2017-05-17

EPSLOBPCGGetLocking

Gets the locking flag used in the LOBPCG method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLOBPCGGetLocking(EPS eps,PetscBool *lock)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

lock  - the locking flag

See Also

EPSLOBPCGSetLocking()

Location: src/eps/impls/cg/lobpcg/lobpcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetMonitorContext.html0000644000175000017500000000376413107004621022743 0ustar jromanjroman EPSGetMonitorContext

slepc-3.7.4 2017-05-17

EPSGetMonitorContext

Gets the monitor context, as set by EPSMonitorSet() for the FIRST monitor only.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetMonitorContext(EPS eps,void **ctx)
Not Collective

Input Parameter

eps  - eigensolver context obtained from EPSCreate()

Output Parameter

ctx  - monitor context

See Also

EPSMonitorSet()

Location: src/eps/interface/epsmon.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetConvergenceTest.html0000644000175000017500000000405013107004621023032 0ustar jromanjroman EPSGetConvergenceTest

slepc-3.7.4 2017-05-17

EPSGetConvergenceTest

Gets the method used to compute the error estimate used in the convergence test.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetConvergenceTest(EPS eps,EPSConv *conv)
Not Collective

Input Parameters

eps  - eigensolver context obtained from EPSCreate()

Output Parameters

conv  - the type of convergence test

See Also

EPSSetConvergenceTest(), EPSConv

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSPowerShiftType.html0000644000175000017500000000317613107004621022240 0ustar jromanjroman EPSPowerShiftType

slepc-3.7.4 2017-05-17

EPSPowerShiftType

determines the type of shift used in the Power iteration

Synopsis

typedef enum { EPS_POWER_SHIFT_CONSTANT,
               EPS_POWER_SHIFT_RAYLEIGH,
               EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType;

See Also

EPSPowerSetShiftType(), EPSPowerGetShiftType()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetDimensions.html0000644000175000017500000000655013107004621022053 0ustar jromanjroman EPSGetDimensions

slepc-3.7.4 2017-05-17

EPSGetDimensions

Gets the number of eigenvalues to compute and the dimension of the subspace.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameters

nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

See Also

EPSSetDimensions()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSSetOptionsPrefix.html0000644000175000017500000000510013107004621022556 0ustar jromanjroman EPSSetOptionsPrefix
slepc-3.7.4 2017-05-17

EPSSetOptionsPrefix

Sets the prefix used for searching for all EPS options in the database.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
prefix  - the prefix string to prepend to all EPS option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

For example, to distinguish between the runtime options for two different EPS contexts, one could call

      EPSSetOptionsPrefix(eps1,"eig1_")
      EPSSetOptionsPrefix(eps2,"eig2_")

See Also

EPSAppendOptionsPrefix(), EPSGetOptionsPrefix()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDGetRestart.html0000644000175000017500000000416213107004621021577 0ustar jromanjroman EPSGDGetRestart

slepc-3.7.4 2017-05-17

EPSGDGetRestart

Gets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

minv  - number of vectors of the searching subspace after restarting
plusk  - number of vectors saved from the previous iteration

See Also

EPSGDSetRestart()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPS.html0000644000175000017500000000332213107004621017354 0ustar jromanjroman EPS

slepc-3.7.4 2017-05-17

EPS

Abstract SLEPc object that manages all the eigenvalue problem solvers.

Synopsis

typedef struct _p_EPS* EPS;

See Also

EPSCreate(), ST

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex29.c.html
src/eps/examples/tutorials/ex30.c.html
src/eps/examples/tutorials/ex1f90.F90.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetErrorEstimate.html0000644000175000017500000000440213107004621022522 0ustar jromanjroman EPSGetErrorEstimate
slepc-3.7.4 2017-05-17

EPSGetErrorEstimate

Returns the error estimate associated to the i-th computed eigenpair.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetErrorEstimate(EPS eps,PetscInt i,PetscReal *errest)
Not Collective

Input Parameter

eps  - eigensolver context
i  - index of eigenpair

Output Parameter

errest  - the error estimate

Notes

This is the error estimate used internally by the eigensolver. The actual error bound can be computed with EPSComputeError(). See also the users manual for details.

See Also

EPSComputeError()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSView.html0000644000175000017500000000533013107004621020210 0ustar jromanjroman EPSView

slepc-3.7.4 2017-05-17

EPSView

Prints the EPS data structure.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSView(EPS eps,PetscViewer viewer)
Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
viewer  - optional visualization context

Options Database Key

-eps_view  - Calls EPSView() at end of EPSSolve()

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

See Also

STView(), PetscViewerASCIIOpen()

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurUpdateSubcommMats.html0000644000175000017500000001002513107004621025104 0ustar jromanjroman EPSKrylovSchurUpdateSubcommMats

slepc-3.7.4 2017-05-17

EPSKrylovSchurUpdateSubcommMats

Update the eigenproblem matrices stored internally in the subcommunicator to which the calling process belongs.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurUpdateSubcommMats(EPS eps,PetscScalar s,PetscScalar a,Mat Au,PetscScalar t,PetscScalar b, Mat Bu,MatStructure str,PetscBool globalup)
Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
s  - scalar that multiplies the existing A matrix
a  - scalar used in the axpy operation on A
Au  - matrix used in the axpy operation on A
t  - scalar that multiplies the existing B matrix
b  - scalar used in the axpy operation on B
Bu  - matrix used in the axpy operation on B
str  - structure flag
globalup  - flag indicating if global matrices must be updated

Notes

This function modifies the eigenproblem matrices at the subcommunicator level, and optionally updates the global matrices in the parent communicator. The updates are expressed as A <-- s*A + a*Au, B <-- t*B + b*Bu.

It is possible to update one of the matrices, or both.

The matrices Au and Bu must be equal in all subcommunicators.

The str flag is passed to the MatAXPY() operations to perform the updates.

If globalup is true, communication is carried out to reconstruct the updated matrices in the parent communicator. The user must be warned that if global matrices are not in sync with subcommunicator matrices, the errors computed by EPSComputeError() will be wrong even if the computed solution is correct (the synchronization may be done only once at the end).

See Also

EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommMats()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetTrueResidual.html0000644000175000017500000000535013107004621022364 0ustar jromanjroman EPSSetTrueResidual

slepc-3.7.4 2017-05-17

EPSSetTrueResidual

Specifies if the solver must compute the true residual explicitly or not.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetTrueResidual(EPS eps,PetscBool trueres)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
trueres  - whether true residuals are required or not

Options Database Keys

-eps_true_residual <boolean>  - Sets/resets the boolean flag 'trueres'

Notes

If the user sets trueres=PETSC_TRUE then the solver explicitly computes the true residual for each eigenpair approximation, and uses it for convergence testing. Computing the residual is usually an expensive operation. Some solvers (e.g., Krylov solvers) can avoid this computation by using a cheap estimate of the residual norm, but this may sometimes give inaccurate results (especially if a spectral transform is being used). On the contrary, preconditioned eigensolvers (e.g., Davidson solvers) do rely on computing the true residual, so this option is irrelevant for them.

See Also

EPSGetTrueResidual()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSAppendOptionsPrefix.html0000644000175000017500000000434013107004621023237 0ustar jromanjroman EPSAppendOptionsPrefix

slepc-3.7.4 2017-05-17

EPSAppendOptionsPrefix

Appends to the prefix used for searching for all EPS options in the database.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
prefix  - the prefix string to prepend to all EPS option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

EPSSetOptionsPrefix(), EPSGetOptionsPrefix()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDSetFix.html0000644000175000017500000000435013107004621020717 0ustar jromanjroman EPSJDSetFix

slepc-3.7.4 2017-05-17

EPSJDSetFix

Sets the threshold for changing the target in the correction equation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetFix(EPS eps,PetscReal fix)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
fix  - threshold for changing the target

Options Database Key

-eps_jd_fix  - the fix value

Note

The target in the correction equation is fixed at the first iterations. When the norm of the residual vector is lower than the fix value, the target is set to the corresponding eigenvalue.

See Also

EPSJDGetFix()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSPowerSetShiftType.html0000644000175000017500000000540413107004621022710 0ustar jromanjroman EPSPowerSetShiftType

slepc-3.7.4 2017-05-17

EPSPowerSetShiftType

Sets the type of shifts used during the power iteration. This can be used to emulate the Rayleigh Quotient Iteration (RQI) method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSPowerSetShiftType(EPS eps,EPSPowerShiftType shift)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
shift  - the type of shift

Options Database Key

-eps_power_shift_type  - Sets the shift type (either 'constant' or 'rayleigh' or 'wilkinson')

Notes

By default, shifts are constant (EPS_POWER_SHIFT_CONSTANT) and the iteration is the simple power method (or inverse iteration if a shift-and-invert transformation is being used).

A variable shift can be specified (EPS_POWER_SHIFT_RAYLEIGH or EPS_POWER_SHIFT_WILKINSON). In this case, the iteration behaves rather like a cubic converging method as RQI. See the users manual for details.

See Also

EPSPowerGetShiftType(), STSetShift(), EPSPowerShiftType

Location: src/eps/impls/power/power.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetStoppingTest.html0000644000175000017500000000401613107004621022401 0ustar jromanjroman EPSGetStoppingTest

slepc-3.7.4 2017-05-17

EPSGetStoppingTest

Gets the method used to decide the termination of the outer loop of the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetStoppingTest(EPS eps,EPSStop *stop)
Not Collective

Input Parameters

eps  - eigensolver context obtained from EPSCreate()

Output Parameters

stop  - the type of stopping test

See Also

EPSSetStoppingTest(), EPSStop

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSGetThreshold.html0000644000175000017500000000406413107004621022357 0ustar jromanjroman EPSCISSGetThreshold

slepc-3.7.4 2017-05-17

EPSCISSGetThreshold

Gets the values of various threshold parameters in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSGetThreshold(EPS eps,PetscReal *delta,PetscReal *spur)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

delta  - threshold for numerical rank
spur  - spurious threshold (to discard spurious eigenpairs)

See Also

EPSCISSSetThreshold()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetWorkVecs.html0000644000175000017500000000352613107004621021522 0ustar jromanjroman EPSSetWorkVecs

slepc-3.7.4 2017-05-17

EPSSetWorkVecs

Sets a number of work vectors into an EPS object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetWorkVecs(EPS eps,PetscInt nw)
Collective on EPS

Input Parameters

eps  - eigensolver context
nw  - number of work vectors to allocate

Developers Note

This is PETSC_EXTERN because it may be required by user plugin EPS implementations.

Location: src/eps/interface/epsdefault.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetTrackAll.html0000644000175000017500000000355313107004621021440 0ustar jromanjroman EPSGetTrackAll

slepc-3.7.4 2017-05-17

EPSGetTrackAll

Returns the flag indicating whether all residual norms must be computed or not.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetTrackAll(EPS eps,PetscBool *trackall)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

trackall  - the returned flag

See Also

EPSSetTrackAll()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetLocking.html0000644000175000017500000000372113107004621023542 0ustar jromanjroman EPSKrylovSchurGetLocking

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetLocking

Gets the locking flag used in the Krylov-Schur method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetLocking(EPS eps,PetscBool *lock)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

lock  - the locking flag

See Also

EPSKrylovSchurSetLocking()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSBalance.html0000644000175000017500000000274013107004621020625 0ustar jromanjroman EPSBalance

slepc-3.7.4 2017-05-17

EPSBalance

The type of balancing used for non-Hermitian problems

Synopsis

typedef enum { EPS_BALANCE_NONE,
               EPS_BALANCE_ONESIDE,
               EPS_BALANCE_TWOSIDE,
               EPS_BALANCE_USER } EPSBalance;

See Also

EPSSetBalance()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetType.html0000644000175000017500000000606013107004621020660 0ustar jromanjroman EPSGetType

slepc-3.7.4 2017-05-17

EPSGetType

Gets the EPS type as a string from the EPS object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetType(EPS eps,EPSType *type)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

name  - name of EPS method

See Also

EPSSetType()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex18.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetDS.html0000644000175000017500000000354313107004621020250 0ustar jromanjroman EPSGetDS
slepc-3.7.4 2017-05-17

EPSGetDS

Obtain the direct solver object associated to the eigensolver object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetDS(EPS eps,DS *ds)
Not Collective

Input Parameters

eps  - eigensolver context obtained from EPSCreate()

Output Parameter

ds  - direct solver context

See Also

EPSSetDS()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSGetExtraction.html0000644000175000017500000000374513107004621022550 0ustar jromanjroman EPSCISSGetExtraction

slepc-3.7.4 2017-05-17

EPSCISSGetExtraction

Gets the extraction technique used in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSGetExtraction(EPS eps,EPSCISSExtraction *extraction)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

See Also

EPSCISSSetExtraction() EPSCISSExtraction

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurSetSubintervals.html0000644000175000017500000000545313107004621024655 0ustar jromanjroman EPSKrylovSchurSetSubintervals

slepc-3.7.4 2017-05-17

EPSKrylovSchurSetSubintervals

Sets the points that delimit the subintervals to be used in spectrum slicing with several partitions.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurSetSubintervals(EPS eps,PetscReal *subint)
Logically Collective on EPS

Input Parameters

extraction  - extraction technique
eps  - the eigenproblem solver context
subint  - array of real values specifying subintervals

Notes

This function must be called after EPSKrylovSchurSetPartitions(). For npart partitions, the argument subint must contain npart+1 real values sorted in ascending order: subint_0, subint_1, ..., subint_npart, where the first and last values must coincide with the interval endpoints set with EPSSetInterval().

The subintervals are then defined by two consecutive points: [subint_0,subint_1], [subint_1,subint_2], and so on.

See Also

EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubintervals(), EPSSetInterval()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSMonitorSetFromOptions.html0000644000175000017500000000536613107004621023612 0ustar jromanjroman EPSMonitorSetFromOptions

slepc-3.7.4 2017-05-17

EPSMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
Collective on EPS

Input Parameters

eps  - the eigensolver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a PetscViewerAndFormat
trackall  - whether this monitor tracks all eigenvalues or not

See Also

EPSMonitorSet(), EPSSetTrackAll(), EPSConvMonitorSetFromOptions()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSPRIMMEGetBlockSize.html0000644000175000017500000000364213107004621022541 0ustar jromanjroman EPSPRIMMEGetBlockSize

slepc-3.7.4 2017-05-17

EPSPRIMMEGetBlockSize

Get the maximum block size the code will try to use.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSPRIMMEGetBlockSize(EPS eps,PetscInt *bs)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

bs  - returned block size

See Also

EPSPRIMMESetBlockSize()

Location: src/eps/impls/external/primme/primme.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDGetBlockSize.html0000644000175000017500000000370713107004621022044 0ustar jromanjroman EPSGDGetBlockSize

slepc-3.7.4 2017-05-17

EPSGDGetBlockSize

Returns the number of vectors to be added to the searching space in every iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

blocksize  - number of vectors added to the search space in every iteration

See Also

EPSGDSetBlockSize()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSSetExtraction.html0000644000175000017500000000472113107004621022557 0ustar jromanjroman EPSCISSSetExtraction

slepc-3.7.4 2017-05-17

EPSCISSSetExtraction

Sets the extraction technique used in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSSetExtraction(EPS eps,EPSCISSExtraction extraction)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
extraction  - the extraction technique

Options Database Key

-eps_ciss_extraction  - Sets the extraction technique (either 'ritz' or 'hankel')

Notes

By default, the Rayleigh-Ritz extraction is used (EPS_CISS_EXTRACTION_RITZ).

If the 'hankel' option is specified (EPS_CISS_EXTRACTION_HANKEL), then the Block Hankel method is used for extracting eigenpairs.

See Also

EPSCISSGetExtraction(), EPSCISSExtraction

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSGetSizes.html0000644000175000017500000000474413107004621021525 0ustar jromanjroman EPSCISSGetSizes

slepc-3.7.4 2017-05-17

EPSCISSGetSizes

Gets the values of various size parameters in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSGetSizes(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

ip  - number of integration points
bs  - block size
ms  - moment size
npart  - number of partitions when splitting the communicator
bsmax  - max block size
realmats  - A and B are real

See Also

EPSCISSSetSizes()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetInterval.html0000644000175000017500000000616713107004621021547 0ustar jromanjroman EPSSetInterval

slepc-3.7.4 2017-05-17

EPSSetInterval

Defines the computational interval for spectrum slicing.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context
inta  - left end of the interval
intb  - right end of the interval

Options Database Key

-eps_interval <a,b>  - set [a,b] as the interval of interest

Notes

Spectrum slicing is a technique employed for computing all eigenvalues of symmetric eigenproblems in a given interval. This function provides the interval to be considered. It must be used in combination with EPS_ALL, see EPSSetWhichEigenpairs().

In the command-line option, two values must be provided. For an open interval, one can give an infinite, e.g., -eps_interval 1.0,inf or -eps_interval -inf,1.0. An open interval in the programmatic interface can be specified with PETSC_MAX_REAL and -PETSC_MAX_REAL.

See Also

EPSGetInterval(), EPSSetWhichEigenpairs()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSBLOPEXGetBlockSize.html0000644000175000017500000000362713107004621022544 0ustar jromanjroman EPSBLOPEXGetBlockSize
slepc-3.7.4 2017-05-17

EPSBLOPEXGetBlockSize

Gets the block size used in the BLOPEX solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSBLOPEXGetBlockSize(EPS eps,PetscInt *bs)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

bs  - the block size

See Also

EPSBLOPEXSetBlockSize()

Location: src/eps/impls/external/blopex/blopex.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSSetUseST.html0000644000175000017500000000430313107004621021436 0ustar jromanjroman EPSCISSSetUseST

slepc-3.7.4 2017-05-17

EPSCISSSetUseST

Sets a flag indicating that the CISS solver will use the ST object for the linear solves.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSSetUseST(EPS eps,PetscBool usest)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
usest  - boolean flag to use the ST object or not

Options Database Keys

-eps_ciss_usest <bool>  - whether the ST object will be used or not

See Also

EPSCISSGetUseST()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDGetDoubleExpansion.html0000644000175000017500000000371213107004621023252 0ustar jromanjroman EPSGDGetDoubleExpansion

slepc-3.7.4 2017-05-17

EPSGDGetDoubleExpansion

Gets a flag indicating whether the double expansion variant has been activated or not.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDGetDoubleExpansion(EPS eps,PetscBool *doubleexp)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

doubleexp  - the flag

See Also

EPSGDSetDoubleExpansion()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSPRIMMESetBlockSize.html0000644000175000017500000000477613107004621022566 0ustar jromanjroman EPSPRIMMESetBlockSize

slepc-3.7.4 2017-05-17

EPSPRIMMESetBlockSize

The maximum block size that PRIMME will try to use.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSPRIMMESetBlockSize(EPS eps,PetscInt bs)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
bs  - block size

Options Database Key

-eps_primme_block_size  - Sets the max allowed block size value

Notes

If the block size is not set, the value established by primme_initialize is used.

The user should set the block size based on the architecture specifics of the target computer, as well as any a priori knowledge of multiplicities. The code does NOT require bs > 1 to find multiple eigenvalues. For some methods, keeping bs = 1 yields the best overall performance.

See Also

EPSPRIMMEGetBlockSize()

Location: src/eps/impls/external/primme/primme.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSAllocateSolution.html0000644000175000017500000000367213107004621022566 0ustar jromanjroman EPSAllocateSolution

slepc-3.7.4 2017-05-17

EPSAllocateSolution

Allocate memory storage for common variables such as eigenvalues and eigenvectors.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSAllocateSolution(EPS eps,PetscInt extra)
Collective on EPS

Input Parameters

eps  - eigensolver context
extra  - number of additional positions, used for methods that require a working basis slightly larger than ncv

Developers Note

This is PETSC_EXTERN because it may be required by user plugin EPS implementations.

Location: src/eps/interface/epssetup.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDGetBOrth.html0000644000175000017500000000363513107004621021175 0ustar jromanjroman EPSGDGetBOrth

slepc-3.7.4 2017-05-17

EPSGDGetBOrth

Returns the orthogonalization used in the search subspace in case of generalized Hermitian problems.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

borth  - whether to B-orthogonalize the search subspace

See Also

EPSGDSetBOrth()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSLOBPCGSetRestart.html0000644000175000017500000000457313107004621022275 0ustar jromanjroman EPSLOBPCGSetRestart

slepc-3.7.4 2017-05-17

EPSLOBPCGSetRestart

Sets the restart parameter for the LOBPCG method. The meaning of this parameter is the proportion of vectors within the current block iterate that must have converged in order to force a restart with hard locking.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLOBPCGSetRestart(EPS eps,PetscReal restart)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
restart  - the percentage of the block of vectors to force a restart

Options Database Key

-eps_lobpcg_restart  - Sets the restart parameter

Notes

Allowed values are in the range [0.1,1.0]. The default is 0.6.

See Also

EPSLOBPCGGetRestart()

Location: src/eps/impls/cg/lobpcg/lobpcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSExtraction.html0000644000175000017500000000312413107004621022077 0ustar jromanjroman EPSCISSExtraction

slepc-3.7.4 2017-05-17

EPSCISSExtraction

determines the extraction technique in the CISS solver

Synopsis

typedef enum { EPS_CISS_EXTRACTION_RITZ,
               EPS_CISS_EXTRACTION_HANKEL } EPSCISSExtraction;

See Also

EPSCISSSetExtraction(), EPSCISSGetExtraction()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSQuadRule.html0000644000175000017500000000307313107004621021504 0ustar jromanjroman EPSCISSQuadRule

slepc-3.7.4 2017-05-17

EPSCISSQuadRule

determines the quadrature rule in the CISS solver

Synopsis

typedef enum { EPS_CISS_QUADRULE_TRAPEZOIDAL=1,
               EPS_CISS_QUADRULE_CHEBYSHEV } EPSCISSQuadRule;

See Also

EPSCISSSetQuadRule(), EPSCISSGetQuadRule()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSFEASTSetNumPoints.html0000644000175000017500000000416113107004621022472 0ustar jromanjroman EPSFEASTSetNumPoints

slepc-3.7.4 2017-05-17

EPSFEASTSetNumPoints

Sets the number of contour integration points for the FEAST package.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSFEASTSetNumPoints(EPS eps,PetscInt npoints)
Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
npoints  - number of contour integration points

Options Database Key

-eps_feast_num_points  - Sets the number of points

See Also

EPSFEASTGetNumPoints()

Location: src/eps/impls/external/feast/feast.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSArnoldiGetDelayed.html0000644000175000017500000000375213107004621022624 0ustar jromanjroman EPSArnoldiGetDelayed

slepc-3.7.4 2017-05-17

EPSArnoldiGetDelayed

Gets the type of reorthogonalization used during the Arnoldi iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSArnoldiGetDelayed(EPS eps,PetscBool *delayed)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Input Parameter

delayed  - boolean flag indicating if delayed reorthogonalization has been enabled

See Also

EPSArnoldiSetDelayed()

Location: src/eps/impls/krylov/arnoldi/arnoldi.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSLOBPCGGetRestart.html0000644000175000017500000000362213107004621022253 0ustar jromanjroman EPSLOBPCGGetRestart

slepc-3.7.4 2017-05-17

EPSLOBPCGGetRestart

Gets the restart parameter used in the LOBPCG method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLOBPCGGetRestart(EPS eps,PetscReal *restart)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

restart  - the restart parameter

See Also

EPSLOBPCGSetRestart()

Location: src/eps/impls/cg/lobpcg/lobpcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetExtraction.html0000644000175000017500000000655213107004621022101 0ustar jromanjroman EPSSetExtraction

slepc-3.7.4 2017-05-17

EPSSetExtraction

Specifies the type of extraction technique to be employed by the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetExtraction(EPS eps,EPSExtraction extr)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
extr  - a known type of extraction

Options Database Keys

-eps_ritz  - Rayleigh-Ritz extraction
-eps_harmonic  - harmonic Ritz extraction
-eps_harmonic_relative  - harmonic Ritz extraction relative to the eigenvalue
-eps_harmonic_right  - harmonic Ritz extraction for rightmost eigenvalues
-eps_harmonic_largest  - harmonic Ritz extraction for largest magnitude (without target)
-eps_refined  - refined Ritz extraction
-eps_refined_harmonic  - refined harmonic Ritz extraction

Notes

Not all eigensolvers support all types of extraction. See the SLEPc Users Manual for details.

By default, a standard Rayleigh-Ritz extraction is used. Other extractions may be useful when computing interior eigenvalues.

Harmonic-type extractions are used in combination with a 'target'.

See Also

EPSSetTarget(), EPSGetExtraction(), EPSExtraction

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetDimensions.html0000644000175000017500000000760313107004621022067 0ustar jromanjroman EPSSetDimensions

slepc-3.7.4 2017-05-17

EPSSetDimensions

Sets the number of eigenvalues to compute and the dimension of the subspace.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
nev  - number of eigenvalues to compute
ncv  - the maximum dimension of the subspace to be used by the solver
mpd  - the maximum dimension allowed for the projected problem

Options Database Keys

-eps_nev <nev>  - Sets the number of eigenvalues
-eps_ncv <ncv>  - Sets the dimension of the subspace
-eps_mpd <mpd>  - Sets the maximum projected dimension

Notes

Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method.

The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and (b) in cases where nev is large, the user sets mpd.

The value of ncv should always be between nev and (nev+mpd), typically ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise a smaller value should be used.

When computing all eigenvalues in an interval, see EPSSetInterval(), these parameters lose relevance, and tuning must be done with EPSKrylovSchurSetDimensions().

See Also

EPSGetDimensions(), EPSSetInterval(), EPSKrylovSchurSetDimensions()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSJDGetInitialSize.html0000644000175000017500000000526313107004621022405 0ustar jromanjroman EPSJDGetInitialSize
slepc-3.7.4 2017-05-17

EPSJDGetInitialSize

Returns the initial size of the searching space.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetInitialSize(EPS eps,PetscInt *initialsize)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

initialsize  - number of vectors of the initial searching subspace

Notes

If EPSJDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSJDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors.

See Also

EPSJDSetInitialSize(), EPSJDGetKrylovStart()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSGetRefinement.html0000644000175000017500000000414313107004621022515 0ustar jromanjroman EPSCISSGetRefinement

slepc-3.7.4 2017-05-17

EPSCISSGetRefinement

Gets the values of various refinement parameters in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSGetRefinement(EPS eps, PetscInt *inner, PetscInt *blsize)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

inner  - number of iterative refinement iterations (inner loop)
blsize  - number of iterative refinement iterations (blocksize loop)

See Also

EPSCISSSetRefinement()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSStop.html0000644000175000017500000000273713107004621020233 0ustar jromanjroman EPSStop

slepc-3.7.4 2017-05-17

EPSStop

Determines the stopping test

Synopsis

typedef enum { EPS_STOP_BASIC,
               EPS_STOP_USER } EPSStop;

See Also

EPSSetStoppingTest(), EPSSetStoppingTestFunction()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSMonitorSet.html0000644000175000017500000001255513107004621021410 0ustar jromanjroman EPSMonitorSet

slepc-3.7.4 2017-05-17

EPSMonitorSet

Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested eigenpair.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSMonitorSet(EPS eps,PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
monitor  - pointer to function (if this is NULL, it turns off monitoring)
mctx  - [optional] context for private data for the monitor routine (use NULL if no context is desired)
monitordestroy  - [optional] routine that frees monitor context (may be NULL)

Calling Sequence of monitor

  monitor(EPS eps,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx)

eps  - eigensolver context obtained from EPSCreate()
its  - iteration number
nconv  - number of converged eigenpairs
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - relative error estimates for each eigenpair
nest  - number of error estimates
mctx  - optional monitoring context, as set by EPSMonitorSet()

Options Database Keys

-eps_monitor  - print only the first error estimate
-eps_monitor_all  - print error estimates at each iteration
-eps_monitor_conv  - print the eigenvalue approximations only when convergence has been reached
-eps_monitor_lg  - sets line graph monitor for the first unconverged approximate eigenvalue
-eps_monitor_lg_all  - sets line graph monitor for all unconverged approximate eigenvalues
-eps_monitor_cancel  - cancels all monitors that have been hardwired into a code by calls to EPSMonitorSet(), but does not cancel those set via the options database.

Notes

Several different monitoring routines may be set by calling EPSMonitorSet() multiple times; all will be called in the order in which they were set.

See Also

EPSMonitorFirst(), EPSMonitorAll(), EPSMonitorCancel()

Location: src/eps/interface/epsmon.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSCISSSetQuadRule.html0000644000175000017500000000462413107004621022163 0ustar jromanjroman EPSCISSSetQuadRule

slepc-3.7.4 2017-05-17

EPSCISSSetQuadRule

Sets the quadrature rule used in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSSetQuadRule(EPS eps,EPSCISSQuadRule quad)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
quad  - the quadrature rule

Options Database Key

-eps_ciss_quadrule  - Sets the quadrature rule (either 'trapezoidal' or 'chebyshev')

Notes

By default, the trapezoidal rule is used (EPS_CISS_QUADRULE_TRAPEZOIDAL).

If the 'chebyshev' option is specified (EPS_CISS_QUADRULE_CHEBYSHEV), then Chebyshev points are used as quadrature points.

See Also

EPSCISSGetQuadRule(), EPSCISSQuadRule

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDGetKrylovStart.html0000644000175000017500000000375213107004621022463 0ustar jromanjroman EPSGDGetKrylovStart

slepc-3.7.4 2017-05-17

EPSGDGetKrylovStart

Returns a flag indicating if the search subspace is started with a Krylov basis.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

krylovstart  - boolean flag indicating if the search subspace is started with a Krylov basis

See Also

EPSGDGetKrylovStart()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSRQCGSetReset.html0000644000175000017500000000415213107004621021512 0ustar jromanjroman EPSRQCGSetReset

slepc-3.7.4 2017-05-17

EPSRQCGSetReset

Sets the reset parameter of the RQCG iteration. Every nrest iterations, the solver performs a Rayleigh-Ritz projection step.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSRQCGSetReset(EPS eps,PetscInt nrest)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
nrest  - the number of iterations between resets

Options Database Key

-eps_rqcg_reset  - Sets the reset parameter

See Also

EPSRQCGGetReset()

Location: src/eps/impls/cg/rqcg/rqcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetBV.html0000644000175000017500000000372213107004621020264 0ustar jromanjroman EPSSetBV

slepc-3.7.4 2017-05-17

EPSSetBV

Associates a basis vectors object to the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetBV(EPS eps,BV V)
Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
V  - the basis vectors object

Note

Use EPSGetBV() to retrieve the basis vectors context (for example, to free them at the end of the computations).

See Also

EPSGetBV()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetTrackAll.html0000644000175000017500000000436713107004621021460 0ustar jromanjroman EPSSetTrackAll

slepc-3.7.4 2017-05-17

EPSSetTrackAll

Specifies if the solver must compute the residual norm of all approximate eigenpairs or not.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetTrackAll(EPS eps,PetscBool trackall)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
trackall  - whether to compute all residuals or not

Notes

If the user sets trackall=PETSC_TRUE then the solver computes (or estimates) the residual norm for each eigenpair approximation. Computing the residual is usually an expensive operation and solvers commonly compute only the residual associated to the first unconverged eigenpair.

The options '-eps_monitor_all' and '-eps_monitor_lg_all' automatically activate this option.

See Also

EPSGetTrackAll()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurGetSubcommInfo.html0000644000175000017500000000547713107004621024407 0ustar jromanjroman EPSKrylovSchurGetSubcommInfo

slepc-3.7.4 2017-05-17

EPSKrylovSchurGetSubcommInfo

Gets information related to the case of doing spectrum slicing for a computational interval with multiple communicators.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurGetSubcommInfo(EPS eps,PetscInt *k,PetscInt *n,Vec *v)
Collective on the subcommunicator (if v is given)

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

k  - index of the subinterval for the calling process
n  - number of eigenvalues found in the k-th subinterval
v  - a vector owned by processes in the subcommunicator with dimensions compatible for locally computed eigenvectors (or NULL)

Notes

This function is only available for spectrum slicing runs.

The returned Vec should be destroyed by the user.

See Also

EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommPairs()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSRegister.html0000644000175000017500000000447013107004621021066 0ustar jromanjroman EPSRegister

slepc-3.7.4 2017-05-17

EPSRegister

Adds a method to the eigenproblem solver package.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSRegister(const char *name,PetscErrorCode (*function)(EPS))
Not Collective

Input Parameters

name  - name of a new user-defined solver
function  - routine to create the solver context

Notes

EPSRegister() may be called multiple times to add several user-defined solvers.

Sample usage

    EPSRegister("my_solver",MySolverCreate);

Then, your solver can be chosen with the procedural interface via

    EPSSetType(eps,"my_solver")
or at runtime via the option
    -eps_type my_solver

See Also

EPSRegisterAll()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetEigenvalueComparison.html0000644000175000017500000001011313107004621024064 0ustar jromanjroman EPSSetEigenvalueComparison

slepc-3.7.4 2017-05-17

EPSSetEigenvalueComparison

Specifies the eigenvalue comparison function when EPSSetWhichEigenpairs() is set to EPS_WHICH_USER.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetEigenvalueComparison(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
func  - a pointer to the comparison function
ctx  - a context pointer (the last parameter to the comparison function)

Calling Sequence of func

  func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx)

ar  - real part of the 1st eigenvalue
ai  - imaginary part of the 1st eigenvalue
br  - real part of the 2nd eigenvalue
bi  - imaginary part of the 2nd eigenvalue
res  - result of comparison
ctx  - optional context, as set by EPSSetEigenvalueComparison()

Note

The returning parameter 'res' can be
negative  - if the 1st eigenvalue is preferred to the 2st one
zero  - if both eigenvalues are equally preferred
positive  - if the 2st eigenvalue is preferred to the 1st one

See Also

EPSSetWhichEigenpairs(), EPSWhich

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex18.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSRQCGGetReset.html0000644000175000017500000000353313107004621021500 0ustar jromanjroman EPSRQCGGetReset
slepc-3.7.4 2017-05-17

EPSRQCGGetReset

Gets the reset parameter used in the RQCG method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSRQCGGetReset(EPS eps,PetscInt *nrest)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

nrest  - the reset parameter

See Also

EPSRQCGSetReset()

Location: src/eps/impls/cg/rqcg/rqcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/index.html0000644000175000017500000004140513107004621020040 0ustar jromanjroman Eigenvalue Problem Solver - EPS

slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

Beginner - Basic usage
EPS EPSGetEigenpair EPSSetOperators
EPSComputeError EPSGetEigenvalue EPSSolve
EPSCreate EPSGetEigenvector EPSType
EPSDestroy EPSProblemType EPSView
EPSGetConverged EPSSetFromOptions
Intermediate - Setting options for algorithms and data structures
EPSBalance EPSGetST EPSSetConvergenceTest
EPSConv EPSGetTarget EPSSetDeflationSpace
EPSConvergedReason EPSGetTolerances EPSSetDimensions
EPSErrorType EPSGetType EPSSetInitialSpace
EPSErrorView EPSGetWhichEigenpairs EPSSetInterval
EPSGetBalance EPSIsGeneralized EPSSetProblemType
EPSGetConvergedReason EPSIsHermitian EPSSetPurify
EPSGetConvergenceTest EPSIsPositive EPSSetTarget
EPSGetDimensions EPSMonitorAll EPSSetTolerances
EPSGetInterval EPSMonitorCancel EPSSetType
EPSGetInvariantSubspace EPSMonitorConverged EPSSetWhichEigenpairs
EPSGetIterationNumber EPSMonitorFirst EPSValuesView
EPSGetMonitorContext EPSMonitorLGCreate EPSVectorsView
EPSGetOperators EPSMonitorSet EPSWhich
EPSGetProblemType EPSReasonView
EPSGetPurify EPSSetBalance
Advanced - Setting more advanced options and customization
EPSAppendOptionsPrefix EPSGetDS EPSKrylovSchurUpdateSubcommMats
EPSArnoldiGetDelayed EPSGetErrorEstimate EPSLOBPCGGetBlockSize
EPSArnoldiSetDelayed EPSGetExtraction EPSLOBPCGGetLocking
EPSBLOPEXGetBlockSize EPSGetOptionsPrefix EPSLOBPCGGetRestart
EPSBLOPEXSetBlockSize EPSGetRG EPSLOBPCGSetBlockSize
EPSBlzpackSetBlockSize EPSGetStoppingTest EPSLOBPCGSetLocking
EPSBlzpackSetNSteps EPSGetTrueResidual EPSLOBPCGSetRestart
EPSCISSExtraction EPSJDGetBOrth EPSLanczosGetReorthog
EPSCISSGetExtraction EPSJDGetBlockSize EPSLanczosReorthogType
EPSCISSGetQuadRule EPSJDGetConstCorrectionTol EPSLanczosSetReorthog
EPSCISSGetRefinement EPSJDGetFix EPSPRIMMEGetBlockSize
EPSCISSGetSizes EPSJDGetInitialSize EPSPRIMMEGetMethod
EPSCISSGetThreshold EPSJDGetKrylovStart EPSPRIMMEMethod
EPSCISSGetUseST EPSJDGetRestart EPSPRIMMESetBlockSize
EPSCISSQuadRule EPSJDGetWindowSizes EPSPRIMMESetMethod
EPSCISSSetExtraction EPSJDSetBOrth EPSPowerGetShiftType
EPSCISSSetQuadRule EPSJDSetBlockSize EPSPowerSetShiftType
EPSCISSSetRefinement EPSJDSetConstCorrectionTol EPSPowerShiftType
EPSCISSSetSizes EPSJDSetFix EPSRQCGGetReset
EPSCISSSetThreshold EPSJDSetInitialSize EPSRQCGSetReset
EPSCISSSetUseST EPSJDSetKrylovStart EPSRegister
EPSExtraction EPSJDSetRestart EPSRegisterAll
EPSFEASTGetNumPoints EPSJDSetWindowSizes EPSReset
EPSFEASTSetNumPoints EPSKrylovSchurGetDetectZeros EPSSetArbitrarySelection
EPSGDGetBOrth EPSKrylovSchurGetDimensions EPSSetBV
EPSGDGetBlockSize EPSKrylovSchurGetInertias EPSSetConvergenceTestFunction
EPSGDGetDoubleExpansion EPSKrylovSchurGetLocking EPSSetDS
EPSGDGetInitialSize EPSKrylovSchurGetPartitions EPSSetEigenvalueComparison
EPSGDGetKrylovStart EPSKrylovSchurGetRestart EPSSetExtraction
EPSGDGetRestart EPSKrylovSchurGetSubcommInfo EPSSetOptionsPrefix
EPSGDGetWindowSizes EPSKrylovSchurGetSubcommMats EPSSetRG
EPSGDSetBOrth EPSKrylovSchurGetSubcommPairs EPSSetST
EPSGDSetBlockSize EPSKrylovSchurGetSubintervals EPSSetStoppingTest
EPSGDSetDoubleExpansion EPSKrylovSchurSetDetectZeros EPSSetStoppingTestFunction
EPSGDSetInitialSize EPSKrylovSchurSetDimensions EPSSetTrueResidual
EPSGDSetKrylovStart EPSKrylovSchurSetLocking EPSStop
EPSGDSetRestart EPSKrylovSchurSetPartitions EPSStoppingBasic
EPSGDSetWindowSizes EPSKrylovSchurSetRestart
EPSGetBV EPSKrylovSchurSetSubintervals
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
EPSAllocateSolution EPSInitializePackage EPSSetWorkVecs
EPSConvMonitorSetFromOptions EPSMonitorSetFromOptions EPSValuesViewFromOptions
EPSErrorViewFromOptions EPSReasonViewFromOptions EPSVectorsViewFromOptions
EPSFinalizePackage EPSSetTrackAll
EPSGetTrackAll EPSSetUp
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/EPS/EPSStoppingBasic.html0000644000175000017500000000734013107004621022046 0ustar jromanjroman EPSStoppingBasic

slepc-3.7.4 2017-05-17

EPSStoppingBasic

Default routine to determine whether the outer eigensolver iteration must be stopped.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSStoppingBasic(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)
Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
its  - current number of iterations
max_it  - maximum number of iterations
nconv  - number of currently converged eigenpairs
nev  - number of requested eigenpairs
ctx  - context (not used here)

Output Parameter

reason  - result of the stopping test

Notes

A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to EPS_CONVERGED_ITERATING (zero).

EPSStoppingBasic() will stop if all requested eigenvalues are converged, or if the maximum number of iterations has been reached.

Use EPSSetStoppingTest() to provide your own test instead of using this one.

See Also

EPSSetStoppingTest(), EPSConvergedReason, EPSGetConvergedReason()

Location: src/eps/interface/epsdefault.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex29.c.html
src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSSetInitialSpace.html0000644000175000017500000000565213107004621022326 0ustar jromanjroman EPSSetInitialSpace
slepc-3.7.4 2017-05-17

EPSSetInitialSpace

Specify a basis of vectors that constitute the initial space, that is, the subspace from which the solver starts to iterate.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetInitialSpace(EPS eps,PetscInt n,Vec *is)
Collective on EPS and Vec

Input Parameter

eps  - the eigenproblem solver context
n  - number of vectors
is  - set of basis vectors of the initial space

Notes

Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored.

These vectors do not persist from one EPSSolve() call to the other, so the initial space should be set every time.

The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally.

Common usage of this function is when the user can provide a rough approximation of the wanted eigenspace. Then, convergence may be faster.

See Also

EPSSetDeflationSpace()

Location: src/eps/interface/epssetup.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex19.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSCISSSetRefinement.html0000644000175000017500000000466313107004621022540 0ustar jromanjroman EPSCISSSetRefinement
slepc-3.7.4 2017-05-17

EPSCISSSetRefinement

Sets the values of various refinement parameters in the CISS solver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCISSSetRefinement(EPS eps,PetscInt inner,PetscInt blsize)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
inner  - number of iterative refinement iterations (inner loop)
blsize  - number of iterative refinement iterations (blocksize loop)

Options Database Keys

-eps_ciss_refine_inner  - Sets number of inner iterations
-eps_ciss_refine_blocksize  - Sets number of blocksize iterations

See Also

EPSCISSGetRefinement()

Location: src/eps/impls/ciss/ciss.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDGetKrylovStart.html0000644000175000017500000000376013107004621022465 0ustar jromanjroman EPSJDGetKrylovStart

slepc-3.7.4 2017-05-17

EPSJDGetKrylovStart

Returns a flag indicating if the searching subspace is started with a Krylov basis.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetKrylovStart(EPS eps,PetscBool *krylovstart)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

krylovstart  - boolean flag indicating if the searching subspace is started with a Krylov basis

See Also

EPSJDGetKrylovStart()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetEigenpair.html0000644000175000017500000001072513107004621021645 0ustar jromanjroman EPSGetEigenpair

slepc-3.7.4 2017-05-17

EPSGetEigenpair

Gets the i-th solution of the eigenproblem as computed by EPSSolve(). The solution consists in both the eigenvalue and the eigenvector.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetEigenpair(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context
i  - index of the solution

Output Parameters

eigr  - real part of eigenvalue
eigi  - imaginary part of eigenvalue
Vr  - real part of eigenvector
Vi  - imaginary part of eigenvector

Notes

It is allowed to pass NULL for Vr and Vi, if the eigenvector is not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs().

If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is set to zero). In both cases, the user can pass NULL in eigi and Vi.

The index i should be a value between 0 and nconv-1 (see EPSGetConverged()). Eigenpairs are indexed according to the ordering criterion established with EPSSetWhichEigenpairs().

The 2-norm of the eigenvector is one unless the problem is generalized Hermitian. In this case the eigenvector is normalized with respect to the norm defined by the B matrix.

See Also

EPSGetEigenvalue(), EPSGetEigenvector(), EPSSolve(),
EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetInvariantSubspace()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex24.c.html
src/eps/examples/tutorials/ex31.c.html
src/eps/examples/tutorials/ex1f.F.html
slepc-3.7.4/docs/manualpages/EPS/EPSSetStoppingTest.html0000644000175000017500000000600513107004621022415 0ustar jromanjroman EPSSetStoppingTest
slepc-3.7.4 2017-05-17

EPSSetStoppingTest

Specifies how to decide the termination of the outer loop of the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetStoppingTest(EPS eps,EPSStop stop)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
stop  - the type of stopping test

Options Database Keys

-eps_stop_basic  - Sets the default stopping test
-eps_stop_user  - Selects the user-defined stopping test

Note

The parameter 'stop' can have one of these values
EPS_STOP_BASIC  - default stopping test
EPS_STOP_USER  - function set by EPSSetStoppingTestFunction()

See Also

EPSGetStoppingTest(), EPSSetStoppingTestFunction(), EPSSetConvergenceTest(), EPSStop

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSExtraction.html0000644000175000017500000000327613107004621021425 0ustar jromanjroman EPSExtraction

slepc-3.7.4 2017-05-17

EPSExtraction

Determines the type of extraction technique employed by the eigensolver

Synopsis

typedef enum { EPS_RITZ,
               EPS_HARMONIC,
               EPS_HARMONIC_RELATIVE,
               EPS_HARMONIC_RIGHT,
               EPS_HARMONIC_LARGEST,
               EPS_REFINED,
               EPS_REFINED_HARMONIC } EPSExtraction;

See Also

EPSSetExtraction(), EPSGetExtraction()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetConverged.html0000644000175000017500000000546613107004621021664 0ustar jromanjroman EPSGetConverged

slepc-3.7.4 2017-05-17

EPSGetConverged

Gets the number of converged eigenpairs.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetConverged(EPS eps,PetscInt *nconv)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

nconv  - number of converged eigenpairs

Note

This function should be called after EPSSolve() has finished.

See Also

EPSSetDimensions(), EPSSolve()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex24.c.html
src/eps/examples/tutorials/ex29.c.html
src/eps/examples/tutorials/ex31.c.html
src/eps/examples/tutorials/ex1f.F.html
slepc-3.7.4/docs/manualpages/EPS/EPSCreate.html0000644000175000017500000000642713107004621020511 0ustar jromanjroman EPSCreate
slepc-3.7.4 2017-05-17

EPSCreate

Creates the default EPS context.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

eps  - location to put the EPS context

Note

The default EPS type is EPSKRYLOVSCHUR

See Also

EPSSetUp(), EPSSolve(), EPSDestroy(), EPS

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSValuesViewFromOptions.html0000644000175000017500000000314413107004621023571 0ustar jromanjroman EPSValuesViewFromOptions
slepc-3.7.4 2017-05-17

EPSValuesViewFromOptions

Processes command line options to determine if/how the computed eigenvalues are to be viewed.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSValuesViewFromOptions(EPS eps)
Collective on EPS

Input Parameters

eps  - the eigensolver context

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDSetWindowSizes.html0000644000175000017500000000501413107004621022451 0ustar jromanjroman EPSGDSetWindowSizes

slepc-3.7.4 2017-05-17

EPSGDSetWindowSizes

Sets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
pwindow  - number of converged vectors in the projector
qwindow  - number of converged vectors in the projected problem

Options Database Keys

-eps_gd_pwindow  - set the number of converged vectors in the projector
-eps_gd_qwindow  - set the number of converged vectors in the projected problem

See Also

EPSGDGetWindowSizes()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSLanczosReorthogType.html0000644000175000017500000000351113107004621023262 0ustar jromanjroman EPSLanczosReorthogType

slepc-3.7.4 2017-05-17

EPSLanczosReorthogType

determines the type of reorthogonalization used in the Lanczos method

Synopsis

typedef enum { EPS_LANCZOS_REORTHOG_LOCAL,
               EPS_LANCZOS_REORTHOG_FULL,
               EPS_LANCZOS_REORTHOG_SELECTIVE,
               EPS_LANCZOS_REORTHOG_PERIODIC,
               EPS_LANCZOS_REORTHOG_PARTIAL,
               EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType;

See Also

EPSLanczosSetReorthog(), EPSLanczosGetReorthog()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetProblemType.html0000644000175000017500000000376113107004621022206 0ustar jromanjroman EPSGetProblemType

slepc-3.7.4 2017-05-17

EPSGetProblemType

Gets the problem type from the EPS object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

type  - name of EPS problem type

See Also

EPSSetProblemType(), EPSProblemType

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetEigenvector.html0000644000175000017500000000663513107004621022221 0ustar jromanjroman EPSGetEigenvector

slepc-3.7.4 2017-05-17

EPSGetEigenvector

Gets the i-th right eigenvector as computed by EPSSolve().

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetEigenvector(EPS eps,PetscInt i,Vec Vr,Vec Vi)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context
i  - index of the solution

Output Parameters

Vr  - real part of eigenvector
Vi  - imaginary part of eigenvector

Notes

The caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs().

If the corresponding eigenvalue is real, then Vi is set to zero. If PETSc is configured with complex scalars the eigenvector is stored directly in Vr (Vi is set to zero). In both cases, the user can pass NULL in Vi.

The index i should be a value between 0 and nconv-1 (see EPSGetConverged()). Eigenpairs are indexed according to the ordering criterion established with EPSSetWhichEigenpairs().

The 2-norm of the eigenvector is one unless the problem is generalized Hermitian. In this case the eigenvector is normalized with respect to the norm defined by the B matrix.

See Also

EPSSolve(), EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetEigenpair()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex7.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSDestroy.html0000644000175000017500000000567413107004621020742 0ustar jromanjroman EPSDestroy
slepc-3.7.4 2017-05-17

EPSDestroy

Destroys the EPS context.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSDestroy(EPS *eps)
Collective on EPS

Input Parameter

eps  - eigensolver context obtained from EPSCreate()

See Also

EPSCreate(), EPSSetUp(), EPSSolve()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetOperators.html0000644000175000017500000000436513107004621021723 0ustar jromanjroman EPSGetOperators
slepc-3.7.4 2017-05-17

EPSGetOperators

Gets the matrices associated with the eigensystem.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetOperators(EPS eps,Mat *A,Mat *B)
Collective on EPS and Mat

Input Parameter

eps  - the EPS context

Output Parameters

A  - the matrix associated with the eigensystem
B  - the second matrix in the case of generalized eigenproblems

See Also

EPSSolve(), EPSGetST(), STGetOperators(), STSetOperators()

Location: src/eps/interface/epssetup.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetOptionsPrefix.html0000644000175000017500000000431013107004621022544 0ustar jromanjroman EPSGetOptionsPrefix

slepc-3.7.4 2017-05-17

EPSGetOptionsPrefix

Gets the prefix used for searching for all EPS options in the database.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[])
Not Collective

Input Parameters

eps  - the eigensolver context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

EPSSetOptionsPrefix(), EPSAppendOptionsPrefix()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSConvMonitorSetFromOptions.html0000644000175000017500000000511413107004621024427 0ustar jromanjroman EPSConvMonitorSetFromOptions

slepc-3.7.4 2017-05-17

EPSConvMonitorSetFromOptions

Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence).

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSConvMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))
Collective on EPS

Input Parameters

eps  - the eigensolver context
name  - the monitor option name
help  - message indicating what monitoring is done
manual  - manual page for the monitor
monitor  - the monitor function, whose context is a SlepcConvMonitor

See Also

EPSMonitorSet(), EPSMonitorSetFromOptions()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDGetWindowSizes.html0000644000175000017500000000424013107004621022435 0ustar jromanjroman EPSGDGetWindowSizes

slepc-3.7.4 2017-05-17

EPSGDGetWindowSizes

Gets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

pwindow  - number of converged vectors in the projector
qwindow  - number of converged vectors in the projected problem

See Also

EPSGDSetWindowSizes()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetST.html0000644000175000017500000000510113107004621020260 0ustar jromanjroman EPSGetST

slepc-3.7.4 2017-05-17

EPSGetST

Obtain the spectral transformation (ST) object associated to the eigensolver object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetST(EPS eps,ST *st)
Not Collective

Input Parameters

eps  - eigensolver context obtained from EPSCreate()

Output Parameter

st  - spectral transformation context

See Also

EPSSetST()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex24.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSMonitorConverged.html0000644000175000017500000000534013107004621022563 0ustar jromanjroman EPSMonitorConverged
slepc-3.7.4 2017-05-17

EPSMonitorConverged

Print the approximate values and error estimates as they converge.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSMonitorConverged(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
Collective on EPS

Input Parameters

eps  - eigensolver context
its  - iteration number
nconv  - number of converged eigenpairs so far
eigr  - real part of the eigenvalues
eigi  - imaginary part of the eigenvalues
errest  - error estimates
nest  - number of error estimates to display
ctx  - monitor context

See Also

EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorAll()

Location: src/eps/interface/epsmon.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDSetBlockSize.html0000644000175000017500000000424213107004621022053 0ustar jromanjroman EPSGDSetBlockSize

slepc-3.7.4 2017-05-17

EPSGDSetBlockSize

Sets the number of vectors to be added to the searching space in every iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
blocksize  - number of vectors added to the search space in every iteration

Options Database Key

-eps_gd_blocksize  - number of vectors added to the search space in every iteration

See Also

EPSGDSetKrylovStart()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDSetKrylovStart.html0000644000175000017500000000417713107004621022504 0ustar jromanjroman EPSJDSetKrylovStart

slepc-3.7.4 2017-05-17

EPSJDSetKrylovStart

Activates or deactivates starting the searching subspace with a Krylov basis.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetKrylovStart(EPS eps,PetscBool krylovstart)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
krylovstart  - boolean flag

Options Database Key

-eps_jd_krylov_start  - Activates starting the searching subspace with a Krylov basis

See Also

EPSJDGetKrylovStart()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSVectorsViewFromOptions.html0000644000175000017500000000315313107004621023757 0ustar jromanjroman EPSVectorsViewFromOptions

slepc-3.7.4 2017-05-17

EPSVectorsViewFromOptions

Processes command line options to determine if/how the computed eigenvectors are to be viewed.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSVectorsViewFromOptions(EPS eps)
Collective on EPS

Input Parameters

eps  - the eigensolver context

Location: src/eps/interface/epsview.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDSetInitialSize.html0000644000175000017500000000560013107004621022414 0ustar jromanjroman EPSJDSetInitialSize

slepc-3.7.4 2017-05-17

EPSJDSetInitialSize

Sets the initial size of the searching space.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDSetInitialSize(EPS eps,PetscInt initialsize)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
initialsize  - number of vectors of the initial searching subspace

Options Database Key

-eps_jd_initial_size  - number of vectors of the initial searching subspace

Notes

If EPSJDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSJDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors.

See Also

EPSJDGetInitialSize(), EPSJDGetKrylovStart()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSArnoldiSetDelayed.html0000644000175000017500000000456713107004621022645 0ustar jromanjroman EPSArnoldiSetDelayed

slepc-3.7.4 2017-05-17

EPSArnoldiSetDelayed

Activates or deactivates delayed reorthogonalization in the Arnoldi iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSArnoldiSetDelayed(EPS eps,PetscBool delayed)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
delayed  - boolean flag

Options Database Key

-eps_arnoldi_delayed  - Activates delayed reorthogonalization in Arnoldi

Note

Delayed reorthogonalization is an aggressive optimization for the Arnoldi eigensolver than may provide better scalability, but sometimes makes the solver converge less than the default algorithm.

See Also

EPSArnoldiGetDelayed()

Location: src/eps/impls/krylov/arnoldi/arnoldi.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDGetBOrth.html0000644000175000017500000000363513107004621021200 0ustar jromanjroman EPSJDGetBOrth

slepc-3.7.4 2017-05-17

EPSJDGetBOrth

Returns the orthogonalization used in the search subspace in case of generalized Hermitian problems.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetBOrth(EPS eps,PetscBool *borth)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameters

borth  - whether to B-orthogonalize the search subspace

See Also

EPSJDSetBOrth()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetEigenvalue.html0000644000175000017500000000556713107004621022036 0ustar jromanjroman EPSGetEigenvalue

slepc-3.7.4 2017-05-17

EPSGetEigenvalue

Gets the i-th eigenvalue as computed by EPSSolve().

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetEigenvalue(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi)
Not Collective

Input Parameters

eps  - eigensolver context
i  - index of the solution

Output Parameters

eigr  - real part of eigenvalue
eigi  - imaginary part of eigenvalue

Notes

If the eigenvalue is real, then eigi is set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero).

The index i should be a value between 0 and nconv-1 (see EPSGetConverged()). Eigenpairs are indexed according to the ordering criterion established with EPSSetWhichEigenpairs().

See Also

EPSSolve(), EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetEigenpair()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetType.html0000644000175000017500000000566513107004621020706 0ustar jromanjroman EPSSetType

slepc-3.7.4 2017-05-17

EPSSetType

Selects the particular solver to be used in the EPS object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetType(EPS eps,EPSType type)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
type  - a known method

Options Database Key

-eps_type <method>  - Sets the method; use -help for a list of available methods

Notes

See "slepc/include/slepceps.h" for available methods. The default is EPSKRYLOVSCHUR.

Normally, it is best to use the EPSSetFromOptions() command and then set the EPS type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The EPSSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database.

See Also

STSetType(), EPSType

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetTarget.html0000644000175000017500000000362613107004621021172 0ustar jromanjroman EPSGetTarget
slepc-3.7.4 2017-05-17

EPSGetTarget

Gets the value of the target.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)
Not Collective

Input Parameter

eps  - eigensolver context

Output Parameter

target  - the value of the target

Note

If the target was not set by the user, then zero is returned.

See Also

EPSSetTarget()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDSetRestart.html0000644000175000017500000000473013107004621021614 0ustar jromanjroman EPSGDSetRestart

slepc-3.7.4 2017-05-17

EPSGDSetRestart

Sets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
minv  - number of vectors of the searching subspace after restarting
plusk  - number of vectors saved from the previous iteration

Options Database Keys

-eps_gd_minv  - number of vectors of the searching subspace after restarting
-eps_gd_plusk  - number of vectors saved from the previous iteration

See Also

EPSGDSetRestart()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSolve.html0000644000175000017500000001062613107004621020372 0ustar jromanjroman EPSSolve

slepc-3.7.4 2017-05-17

EPSSolve

Solves the eigensystem.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSolve(EPS eps)
Collective on EPS

Input Parameter

eps  - eigensolver context obtained from EPSCreate()

Options Database Keys

-eps_view  - print information about the solver used
-eps_view_mat0 binary  - save the first matrix (A) to the default binary viewer
-eps_view_mat1 binary  - save the second matrix (B) to the default binary viewer
-eps_view_vectors binary  - save the computed eigenvectors to the default binary viewer
-eps_view_values  - print computed eigenvalues
-eps_converged_reason  - print reason for convergence, and number of iterations
-eps_error_absolute  - print absolute errors of each eigenpair
-eps_error_relative  - print relative errors of each eigenpair
-eps_error_backward  - print backward errors of each eigenpair

See Also

EPSCreate(), EPSSetUp(), EPSDestroy(), EPSSetTolerances()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSIsPositive.html0000644000175000017500000000376213107004621021403 0ustar jromanjroman EPSIsPositive
slepc-3.7.4 2017-05-17

EPSIsPositive

Ask if the EPS object corresponds to an eigenvalue problem type that requires a positive (semi-) definite matrix B.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSIsPositive(EPS eps,PetscBool* is)
Not collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

is  - the answer

See Also

EPSIsGeneralized(), EPSIsHermitian()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSBlzpackSetNSteps.html0000644000175000017500000000374013107004621022500 0ustar jromanjroman EPSBlzpackSetNSteps

slepc-3.7.4 2017-05-17

EPSBlzpackSetNSteps

Sets the maximum number of steps per run for the BLZPACK package.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSBlzpackSetNSteps(EPS eps,PetscInt nsteps)
Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
nsteps  - maximum number of steps

Options Database Key

-eps_blzpack_nsteps  - Sets the maximum number of steps per run

Location: src/eps/impls/external/blzpack/blzpack.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGDGetInitialSize.html0000644000175000017500000000526313107004621022402 0ustar jromanjroman EPSGDGetInitialSize

slepc-3.7.4 2017-05-17

EPSGDGetInitialSize

Returns the initial size of the searching space.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

initialsize  - number of vectors of the initial searching subspace

Notes

If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors.

See Also

EPSGDSetInitialSize(), EPSGDGetKrylovStart()

Location: src/eps/impls/davidson/gd/gd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetST.html0000644000175000017500000000376013107004621020305 0ustar jromanjroman EPSSetST

slepc-3.7.4 2017-05-17

EPSSetST

Associates a spectral transformation object to the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetST(EPS eps,ST st)
Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
st  - the spectral transformation object

Note

Use EPSGetST() to retrieve the spectral transformation context (for example, to free it at the end of the computations).

See Also

EPSGetST()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetWhichEigenpairs.html0000644000175000017500000000431513107004621023011 0ustar jromanjroman EPSGetWhichEigenpairs

slepc-3.7.4 2017-05-17

EPSGetWhichEigenpairs

Returns which portion of the spectrum is to be sought.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which)
Not Collective

Input Parameter

eps  - eigensolver context obtained from EPSCreate()

Output Parameter

which  - the portion of the spectrum to be sought

Notes

See EPSSetWhichEigenpairs() for possible values of 'which'.

See Also

EPSSetWhichEigenpairs(), EPSWhich

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSJDGetBlockSize.html0000644000175000017500000000370713107004621022047 0ustar jromanjroman EPSJDGetBlockSize

slepc-3.7.4 2017-05-17

EPSJDGetBlockSize

Returns the number of vectors to be added to the searching space in every iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSJDGetBlockSize(EPS eps,PetscInt *blocksize)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

blocksize  - number of vectors added to the search space in every iteration

See Also

EPSJDSetBlockSize()

Location: src/eps/impls/davidson/jd/jd.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetFromOptions.html0000644000175000017500000000571313107004621022236 0ustar jromanjroman EPSSetFromOptions

slepc-3.7.4 2017-05-17

EPSSetFromOptions

Sets EPS options from the options database. This routine must be called before EPSSetUp() if the user is to be allowed to set the solver type.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetFromOptions(EPS eps)
Collective on EPS

Input Parameters

eps  - the eigensolver context

Notes

To see all options, run your program with the -help option.

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSPRIMMESetMethod.html0000644000175000017500000000442313107004621022106 0ustar jromanjroman EPSPRIMMESetMethod
slepc-3.7.4 2017-05-17

EPSPRIMMESetMethod

Sets the method for the PRIMME library.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSPRIMMESetMethod(EPS eps,EPSPRIMMEMethod method)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
method  - method that will be used by PRIMME

Options Database Key

-eps_primme_method  - Sets the method for the PRIMME library

Note

If not set, the method defaults to EPS_PRIMME_DEFAULT_MIN_TIME.

See Also

EPSPRIMMEGetMethod(), EPSPRIMMEMethod

Location: src/eps/impls/external/primme/primme.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetTolerances.html0000644000175000017500000000540313107004621022052 0ustar jromanjroman EPSSetTolerances

slepc-3.7.4 2017-05-17

EPSSetTolerances

Sets the tolerance and maximum iteration count used by the EPS convergence tests.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetTolerances(EPS eps,PetscReal tol,PetscInt maxits)
Logically Collective on EPS

Input Parameters

eps  - the eigensolver context
tol  - the convergence tolerance
maxits  - maximum number of iterations to use

Options Database Keys

-eps_tol <tol>  - Sets the convergence tolerance
-eps_max_it <maxits>  - Sets the maximum number of iterations allowed

Notes

Use PETSC_DEFAULT for either argument to assign a reasonably good value.

See Also

EPSGetTolerances()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSSetUp.html0000644000175000017500000000503413107004621020337 0ustar jromanjroman EPSSetUp
slepc-3.7.4 2017-05-17

EPSSetUp

Sets up all the internal data structures necessary for the execution of the eigensolver. Then calls STSetUp() for any set-up operations associated to the ST object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetUp(EPS eps)
Collective on EPS

Input Parameter

eps  - eigenproblem solver context

Notes

This function need not be called explicitly in most cases, since EPSSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time.

See Also

EPSCreate(), EPSSolve(), EPSDestroy(), STSetUp(), EPSSetInitialSpace()

Location: src/eps/interface/epssetup.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex25.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSGetInvariantSubspace.html0000644000175000017500000000544413107004621023365 0ustar jromanjroman EPSGetInvariantSubspace
slepc-3.7.4 2017-05-17

EPSGetInvariantSubspace

Gets an orthonormal basis of the computed invariant subspace.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetInvariantSubspace(EPS eps,Vec *v)
Not Collective, but vectors are shared by all processors that share the EPS

Input Parameter

eps  - the eigensolver context

Output Parameter

v  - an array of vectors

Notes

This function should be called after EPSSolve() has finished.

The user should provide in v an array of nconv vectors, where nconv is the value returned by EPSGetConverged().

The first k vectors returned in v span an invariant subspace associated with the first k computed eigenvalues (note that this is not true if the k-th eigenvalue is complex and matrix A is real; in this case the first k+1 vectors should be used). An invariant subspace X of A satisfies Ax in X for all x in X (a similar definition applies for generalized eigenproblems).

See Also

EPSGetEigenpair(), EPSGetConverged(), EPSSolve()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSKrylovSchurSetPartitions.html0000644000175000017500000000554013107004621024325 0ustar jromanjroman EPSKrylovSchurSetPartitions

slepc-3.7.4 2017-05-17

EPSKrylovSchurSetPartitions

Sets the number of partitions for the case of doing spectrum slicing for a computational interval with the communicator split in several sub-communicators.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSKrylovSchurSetPartitions(EPS eps,PetscInt npart)
Logically Collective on EPS

Input Parameters

eps  - the eigenproblem solver context
npart  - number of partitions

Options Database Key

-eps_krylovschur_partitions <npart>  - Sets the number of partitions

Notes

By default, npart=1 so all processes in the communicator participate in the processing of the whole interval. If npart>1 then the interval is divided into npart subintervals, each of them being processed by a subset of processes.

The interval is split proportionally unless the separation points are specified with EPSKrylovSchurSetSubintervals().

See Also

EPSKrylovSchurSetSubintervals(), EPSSetInterval()

Location: src/eps/impls/krylov/krylovschur/krylovschur.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSLOBPCGGetBlockSize.html0000644000175000017500000000361313107004621022514 0ustar jromanjroman EPSLOBPCGGetBlockSize

slepc-3.7.4 2017-05-17

EPSLOBPCGGetBlockSize

Gets the block size used in the LOBPCG method.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLOBPCGGetBlockSize(EPS eps,PetscInt *bs)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

bs  - the block size

See Also

EPSLOBPCGSetBlockSize()

Location: src/eps/impls/cg/lobpcg/lobpcg.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetConvergenceTest.html0000644000175000017500000000720613107004621023054 0ustar jromanjroman EPSSetConvergenceTest

slepc-3.7.4 2017-05-17

EPSSetConvergenceTest

Specifies how to compute the error estimate used in the convergence test.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetConvergenceTest(EPS eps,EPSConv conv)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
conv  - the type of convergence test

Options Database Keys

-eps_conv_abs  - Sets the absolute convergence test
-eps_conv_rel  - Sets the convergence test relative to the eigenvalue
-eps_conv_norm  - Sets the convergence test relative to the matrix norms
-eps_conv_user  - Selects the user-defined convergence test

Note

The parameter 'conv' can have one of these values
EPS_CONV_ABS  - absolute error ||r||
EPS_CONV_REL  - error relative to the eigenvalue l, ||r||/|l|
EPS_CONV_NORM  - error relative to the matrix norms, ||r||/(||A||+|l|*||B||)
EPS_CONV_USER  - function set by EPSSetConvergenceTestFunction()

See Also

EPSGetConvergenceTest(), EPSSetConvergenceTestFunction(), EPSSetStoppingTest(), EPSConv

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSMonitorLGCreate.html0000644000175000017500000000600213107004621022271 0ustar jromanjroman EPSMonitorLGCreate

slepc-3.7.4 2017-05-17

EPSMonitorLGCreate

Creates a line graph context for use with EPS to monitor convergence.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
Collective on MPI_Comm

Input Parameters

comm  - communicator context
host  - the X display to open, or null for the local machine
label  - the title to put in the title bar
x, y  - the screen coordinates of the upper left coordinate of the window
m, n  - the screen width and height in pixels

Output Parameter

lgctx  - the drawing context

Options Database Keys

-eps_monitor_lg  - Sets line graph monitor for the first residual
-eps_monitor_lg_all  - Sets line graph monitor for all residuals

Notes

Use PetscDrawLGDestroy() to destroy this line graph.

See Also

EPSMonitorSet()

Location: src/eps/interface/epsmon.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSComputeError.html0000644000175000017500000000566613107004621021740 0ustar jromanjroman EPSComputeError

slepc-3.7.4 2017-05-17

EPSComputeError

Computes the error (based on the residual norm) associated with the i-th computed eigenpair.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSComputeError(EPS eps,PetscInt i,EPSErrorType type,PetscReal *error)
Collective on EPS

Input Parameter

eps  - the eigensolver context
i  - the solution index
type  - the type of error to compute

Output Parameter

error  - the error

Notes

The error can be computed in various ways, all of them based on the residual norm ||Ax-kBx||_2 where k is the eigenvalue and x is the eigenvector.

See Also

EPSErrorType, EPSSolve(), EPSGetErrorEstimate()

Location: src/eps/interface/epssolve.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex19.c.html
src/eps/examples/tutorials/ex31.c.html
src/eps/examples/tutorials/ex1f.F.html
slepc-3.7.4/docs/manualpages/EPS/EPSReset.html0000644000175000017500000000332013107004621020355 0ustar jromanjroman EPSReset
slepc-3.7.4 2017-05-17

EPSReset

Resets the EPS context to the initial state and removes any allocated objects.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSReset(EPS eps)
Collective on EPS

Input Parameter

eps  - eigensolver context obtained from EPSCreate()

See Also

EPSDestroy()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetRG.html0000644000175000017500000000375113107004621020253 0ustar jromanjroman EPSGetRG

slepc-3.7.4 2017-05-17

EPSGetRG

Obtain the region object associated to the eigensolver.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetRG(EPS eps,RG *rg)
Not Collective

Input Parameters

eps  - eigensolver context obtained from EPSCreate()

Output Parameter

rg  - region context

See Also

EPSSetRG()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSLanczosGetReorthog.html0000644000175000017500000000407313107004621023064 0ustar jromanjroman EPSLanczosGetReorthog
slepc-3.7.4 2017-05-17

EPSLanczosGetReorthog

Gets the type of reorthogonalization used during the Lanczos iteration.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSLanczosGetReorthog(EPS eps,EPSLanczosReorthogType *reorthog)
Not Collective

Input Parameter

eps  - the eigenproblem solver context

Output Parameter

reorthog  - the type of reorthogonalization

See Also

EPSLanczosSetReorthog(), EPSLanczosReorthogType

Location: src/eps/impls/krylov/lanczos/lanczos.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetConvergenceTestFunction.html0000644000175000017500000000745413107004621024567 0ustar jromanjroman EPSSetConvergenceTestFunction

slepc-3.7.4 2017-05-17

EPSSetConvergenceTestFunction

Sets a function to compute the error estimate used in the convergence test.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetConvergenceTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
Logically Collective on EPS

Input Parameters

eps  - eigensolver context obtained from EPSCreate()
func  - a pointer to the convergence test function
ctx  - context for private data for the convergence routine (may be null)
destroy  - a routine for destroying the context (may be null)

Calling Sequence of func

  func(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)

eps  - eigensolver context obtained from EPSCreate()
eigr  - real part of the eigenvalue
eigi  - imaginary part of the eigenvalue
res  - residual norm associated to the eigenpair
errest  - (output) computed error estimate
ctx  - optional context, as set by EPSSetConvergenceTestFunction()

Note

If the error estimate returned by the convergence test function is less than the tolerance, then the eigenvalue is accepted as converged.

See Also

EPSSetConvergenceTest(), EPSSetTolerances()

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSWhich.html0000644000175000017500000000347213107004621020345 0ustar jromanjroman EPSWhich

slepc-3.7.4 2017-05-17

EPSWhich

Determines which part of the spectrum is requested

Synopsis

typedef enum { EPS_LARGEST_MAGNITUDE=1,
               EPS_SMALLEST_MAGNITUDE,
               EPS_LARGEST_REAL,
               EPS_SMALLEST_REAL,
               EPS_LARGEST_IMAGINARY,
               EPS_SMALLEST_IMAGINARY,
               EPS_TARGET_MAGNITUDE,
               EPS_TARGET_REAL,
               EPS_TARGET_IMAGINARY,
               EPS_ALL,
               EPS_WHICH_USER } EPSWhich;

See Also

EPSSetWhichEigenpairs(), EPSGetWhichEigenpairs()

Location: src/eps/../../include/slepceps.h
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSGetExtraction.html0000644000175000017500000000370713107004621022064 0ustar jromanjroman EPSGetExtraction

slepc-3.7.4 2017-05-17

EPSGetExtraction

Gets the extraction type used by the EPS object.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSGetExtraction(EPS eps,EPSExtraction *extr)
Not Collective

Input Parameter

eps  - the eigensolver context

Output Parameter

extr  - name of extraction type

See Also

EPSSetExtraction(), EPSExtraction

Location: src/eps/interface/epsopts.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetOperators.html0000644000175000017500000000722713107004621021737 0ustar jromanjroman EPSSetOperators

slepc-3.7.4 2017-05-17

EPSSetOperators

Sets the matrices associated with the eigenvalue problem.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetOperators(EPS eps,Mat A,Mat B)
Collective on EPS and Mat

Input Parameters

eps  - the eigenproblem solver context
A  - the matrix associated with the eigensystem
B  - the second matrix in the case of generalized eigenproblems

Notes

To specify a standard eigenproblem, use NULL for parameter B.

It must be called before EPSSetUp(). If it is called again after EPSSetUp() then the EPS object is reset.

See Also

EPSSolve(), EPSSetUp(), EPSReset(), EPSGetST(), STGetOperators()

Location: src/eps/interface/epssetup.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSRegisterAll.html0000644000175000017500000000262313107004621021515 0ustar jromanjroman EPSRegisterAll
slepc-3.7.4 2017-05-17

EPSRegisterAll

Registers all the eigenvalue solvers in the EPS package.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSRegisterAll(void)
Not Collective

See Also

EPSRegister()

Location: src/eps/interface/epsregis.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/EPS/EPSSetTarget.html0000644000175000017500000000537013107004621021204 0ustar jromanjroman EPSSetTarget

slepc-3.7.4 2017-05-17

EPSSetTarget

Sets the value of the target.

Synopsis

#include "slepceps.h" 
PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)
Logically Collective on EPS

Input Parameters

eps  - eigensolver context
target  - the value of the target

Options Database Key

-eps_target <scalar>  - the value of the target

Notes

The target is a scalar value used to determine the portion of the spectrum of interest. It is used in combination with EPSSetWhichEigenpairs().

In the case of complex scalars, a complex value can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -eps_target 1.0+2.0i

See Also

EPSGetTarget(), EPSSetWhichEigenpairs()

Location: src/eps/interface/epsbasic.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex13.c.html
src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/EPS/EPSFinalizePackage.html0000644000175000017500000000276713107004621022326 0ustar jromanjroman EPSFinalizePackage
slepc-3.7.4 2017-05-17

EPSFinalizePackage

This function destroys everything in the SLEPc interface to the EPS package. It is called from SlepcFinalize().

Synopsis

PetscErrorCode EPSFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/eps/interface/dlregiseps.c
Index of all EPS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/singleindex.html0000644000175000017500000021532613107004621020620 0ustar jromanjroman Subroutine Index

| B | D | E | F | M | N | P | R | S | V |

BV BVGetOrthogonalization BVOrthogonalize
BVAppendOptionsPrefix BVGetRandomContext BVOrthogonalizeColumn
BVApplyMatrix BVGetSignature BVOrthogonalizeSomeColumn
BVApplyMatrixBV BVGetSizes BVOrthogonalizeVec
BVCopy BVGetType BVRegister
BVCopyColumn BVInitializePackage BVRegisterAll
BVCopyVec BVInsertConstraints BVResize
BVCreate BVInsertVec BVRestoreArray
BVCreateVec BVInsertVecs BVRestoreArrayRead
BVDestroy BVMatMult BVRestoreColumn
BVDot BVMatMultColumn BVScale
BVDotColumn BVMatMultHermitianTranspose BVScaleColumn
BVDotColumnBegin BVMatMultType BVSetActiveColumns
BVDotColumnEnd BVMatProject BVSetFromOptions
BVDotVec BVMult BVSetMatMultMethod
BVDotVecBegin BVMultColumn BVSetMatrix
BVDotVecEnd BVMultInPlace BVSetNumConstraints
BVDuplicate BVMultInPlaceTranspose BVSetOptionsPrefix
BVDuplicateResize BVMultVec BVSetOrthogonalization
BVFinalizePackage BVNorm BVSetRandom
BVGetActiveColumns BVNormColumn BVSetRandomColumn
BVGetArray BVNormColumnBegin BVSetRandomContext
BVGetArrayRead BVNormColumnEnd BVSetSignature
BVGetCachedBV BVNormVec BVSetSizes
BVGetColumn BVNormVecBegin BVSetSizesFromVec
BVGetMatMultMethod BVNormVecEnd BVSetType
BVGetMatrix BVOrthogBlockType BVType
BVGetNumConstraints BVOrthogRefineType BVView
BVGetOptionsPrefix BVOrthogType

| B | D | E | F | M | N | P | R | S | V |

DS DSGetType DSSetFromOptions
DSAllocate DSInitializePackage DSSetIdentity
DSAppendOptionsPrefix DSMatType DSSetMethod
DSCond DSNEPGetFN DSSetOptionsPrefix
DSCopyMat DSNEPGetNumFN DSSetRefined
DSCreate DSNEPSetFN DSSetSlepcSC
DSDestroy DSNormalize DSSetState
DSFinalizePackage DSOrthogonalize DSSetType
DSGetArray DSPEPGetDegree DSSolve
DSGetArrayReal DSPEPSetDegree DSSort
DSGetBlockSize DSPseudoOrthogonalize DSStateType
DSGetCompact DSRegister DSTranslateHarmonic
DSGetDimensions DSRegisterAll DSTranslateRKS
DSGetExtraRow DSReset DSTruncate
DSGetLeadingDimension DSRestoreArray DSType
DSGetMat DSRestoreArrayReal DSUpdateExtraRow
DSGetMethod DSRestoreMat DSVectors
DSGetOptionsPrefix DSSetBlockSize DSView
DSGetRefined DSSetCompact DSViewMat
DSGetSlepcSC DSSetDimensions
DSGetState DSSetExtraRow

| B | D | E | F | M | N | P | R | S | V |

EPS EPSGetInterval EPSMonitorAll
EPSAllocateSolution EPSGetInvariantSubspace EPSMonitorCancel
EPSAppendOptionsPrefix EPSGetIterationNumber EPSMonitorConverged
EPSArnoldiGetDelayed EPSGetMonitorContext EPSMonitorFirst
EPSArnoldiSetDelayed EPSGetOperators EPSMonitorLGCreate
EPSBLOPEXGetBlockSize EPSGetOptionsPrefix EPSMonitorSet
EPSBLOPEXSetBlockSize EPSGetProblemType EPSMonitorSetFromOptions
EPSBalance EPSGetPurify EPSPRIMMEGetBlockSize
EPSBlzpackSetBlockSize EPSGetRG EPSPRIMMEGetMethod
EPSBlzpackSetNSteps EPSGetST EPSPRIMMEMethod
EPSCISSExtraction EPSGetStoppingTest EPSPRIMMESetBlockSize
EPSCISSGetExtraction EPSGetTarget EPSPRIMMESetMethod
EPSCISSGetQuadRule EPSGetTolerances EPSPowerGetShiftType
EPSCISSGetRefinement EPSGetTrackAll EPSPowerSetShiftType
EPSCISSGetSizes EPSGetTrueResidual EPSPowerShiftType
EPSCISSGetThreshold EPSGetType EPSProblemType
EPSCISSGetUseST EPSGetWhichEigenpairs EPSRQCGGetReset
EPSCISSQuadRule EPSInitializePackage EPSRQCGSetReset
EPSCISSSetExtraction EPSIsGeneralized EPSReasonView
EPSCISSSetQuadRule EPSIsHermitian EPSReasonViewFromOptions
EPSCISSSetRefinement EPSIsPositive EPSRegister
EPSCISSSetSizes EPSJDGetBOrth EPSRegisterAll
EPSCISSSetThreshold EPSJDGetBlockSize EPSReset
EPSCISSSetUseST EPSJDGetConstCorrectionTol EPSSetArbitrarySelection
EPSComputeError EPSJDGetFix EPSSetBV
EPSConv EPSJDGetInitialSize EPSSetBalance
EPSConvMonitorSetFromOptions EPSJDGetKrylovStart EPSSetConvergenceTest
EPSConvergedReason EPSJDGetRestart EPSSetConvergenceTestFunction
EPSCreate EPSJDGetWindowSizes EPSSetDS
EPSDestroy EPSJDSetBOrth EPSSetDeflationSpace
EPSErrorType EPSJDSetBlockSize EPSSetDimensions
EPSErrorView EPSJDSetConstCorrectionTol EPSSetEigenvalueComparison
EPSErrorViewFromOptions EPSJDSetFix EPSSetExtraction
EPSExtraction EPSJDSetInitialSize EPSSetFromOptions
EPSFEASTGetNumPoints EPSJDSetKrylovStart EPSSetInitialSpace
EPSFEASTSetNumPoints EPSJDSetRestart EPSSetInterval
EPSFinalizePackage EPSJDSetWindowSizes EPSSetOperators
EPSGDGetBOrth EPSKrylovSchurGetDetectZeros EPSSetOptionsPrefix
EPSGDGetBlockSize EPSKrylovSchurGetDimensions EPSSetProblemType
EPSGDGetDoubleExpansion EPSKrylovSchurGetInertias EPSSetPurify
EPSGDGetInitialSize EPSKrylovSchurGetLocking EPSSetRG
EPSGDGetKrylovStart EPSKrylovSchurGetPartitions EPSSetST
EPSGDGetRestart EPSKrylovSchurGetRestart EPSSetStoppingTest
EPSGDGetWindowSizes EPSKrylovSchurGetSubcommInfo EPSSetStoppingTestFunction
EPSGDSetBOrth EPSKrylovSchurGetSubcommMats EPSSetTarget
EPSGDSetBlockSize EPSKrylovSchurGetSubcommPairs EPSSetTolerances
EPSGDSetDoubleExpansion EPSKrylovSchurGetSubintervals EPSSetTrackAll
EPSGDSetInitialSize EPSKrylovSchurSetDetectZeros EPSSetTrueResidual
EPSGDSetKrylovStart EPSKrylovSchurSetDimensions EPSSetType
EPSGDSetRestart EPSKrylovSchurSetLocking EPSSetUp
EPSGDSetWindowSizes EPSKrylovSchurSetPartitions EPSSetWhichEigenpairs
EPSGetBV EPSKrylovSchurSetRestart EPSSetWorkVecs
EPSGetBalance EPSKrylovSchurSetSubintervals EPSSolve
EPSGetConverged EPSKrylovSchurUpdateSubcommMats EPSStop
EPSGetConvergedReason EPSLOBPCGGetBlockSize EPSStoppingBasic
EPSGetConvergenceTest EPSLOBPCGGetLocking EPSType
EPSGetDS EPSLOBPCGGetRestart EPSValuesView
EPSGetDimensions EPSLOBPCGSetBlockSize EPSValuesViewFromOptions
EPSGetEigenpair EPSLOBPCGSetLocking EPSVectorsView
EPSGetEigenvalue EPSLOBPCGSetRestart EPSVectorsViewFromOptions
EPSGetEigenvector EPSLanczosGetReorthog EPSView
EPSGetErrorEstimate EPSLanczosReorthogType EPSWhich
EPSGetExtraction EPSLanczosSetReorthog

| B | D | E | F | M | N | P | R | S | V |

FN FNEvaluateFunctionMatVec FNRationalSetNumerator
FNAppendOptionsPrefix FNFinalizePackage FNRegister
FNCombineGetChildren FNGetOptionsPrefix FNRegisterAll
FNCombineSetChildren FNGetScale FNSetFromOptions
FNCombineType FNGetType FNSetOptionsPrefix
FNCreate FNInitializePackage FNSetScale
FNDestroy FNPhiGetIndex FNSetType
FNDuplicate FNPhiSetIndex FNType
FNEvaluateDerivative FNRationalGetDenominator FNView
FNEvaluateFunction FNRationalGetNumerator
FNEvaluateFunctionMat FNRationalSetDenominator

| B | D | E | F | M | N | P | R | S | V |

MFN MFNGetOperator MFNReset
MFNAllocateSolution MFNGetOptionsPrefix MFNSetBV
MFNAppendOptionsPrefix MFNGetTolerances MFNSetDimensions
MFNConvergedReason MFNGetType MFNSetErrorIfNotConverged
MFNCreate MFNInitializePackage MFNSetFN
MFNDestroy MFNMonitorCancel MFNSetFromOptions
MFNFinalizePackage MFNMonitorDefault MFNSetOperator
MFNGetBV MFNMonitorLGCreate MFNSetOptionsPrefix
MFNGetConvergedReason MFNMonitorSet MFNSetTolerances
MFNGetDimensions MFNMonitorSetFromOptions MFNSetType
MFNGetErrorIfNotConverged MFNReasonView MFNSetUp
MFNGetFN MFNReasonViewFromOptions MFNSolve
MFNGetIterationNumber MFNRegister MFNType
MFNGetMonitorContext MFNRegisterAll MFNView

| B | D | E | F | M | N | P | R | S | V |

NEP NEPGetTolerances NEPRefineGetKSP
NEPAllocateSolution NEPGetTrackAll NEPRefineScheme
NEPAppendOptionsPrefix NEPGetType NEPRegister
NEPApplyFunction NEPGetWhichEigenpairs NEPRegisterAll
NEPApplyJacobian NEPInitializePackage NEPReset
NEPCISSGetRefinement NEPInterpolGetDegree NEPSLPGetEPS
NEPCISSGetSizes NEPInterpolGetPEP NEPSLPSetEPS
NEPCISSGetThreshold NEPInterpolSetDegree NEPSetBV
NEPCISSSetRefinement NEPInterpolSetPEP NEPSetConvergenceTest
NEPCISSSetSizes NEPMonitorAll NEPSetConvergenceTestFunction
NEPCISSSetThreshold NEPMonitorCancel NEPSetDS
NEPComputeError NEPMonitorConverged NEPSetDerivatives
NEPComputeFunction NEPMonitorFirst NEPSetDimensions
NEPComputeJacobian NEPMonitorLGCreate NEPSetEigenvalueComparison
NEPConv NEPMonitorSet NEPSetFromOptions
NEPConvMonitorSetFromOptions NEPMonitorSetFromOptions NEPSetFunction
NEPConvergedReason NEPNArnoldiGetKSP NEPSetInitialSpace
NEPCreate NEPNArnoldiSetKSP NEPSetJacobian
NEPDestroy NEPNLEIGSGetInterpolation NEPSetOptionsPrefix
NEPErrorType NEPNLEIGSGetKSPs NEPSetRG
NEPErrorView NEPNLEIGSGetLocking NEPSetRefine
NEPErrorViewFromOptions NEPNLEIGSGetRKShifts NEPSetSplitOperator
NEPFinalizePackage NEPNLEIGSGetRestart NEPSetStoppingTest
NEPGetBV NEPNLEIGSGetSingularitiesFunction NEPSetStoppingTestFunction
NEPGetConverged NEPNLEIGSGetTrueResidual NEPSetTarget
NEPGetConvergedReason NEPNLEIGSSetInterpolation NEPSetTolerances
NEPGetConvergenceTest NEPNLEIGSSetLocking NEPSetTrackAll
NEPGetDS NEPNLEIGSSetRKShifts NEPSetType
NEPGetDerivatives NEPNLEIGSSetRestart NEPSetUp
NEPGetDimensions NEPNLEIGSSetSingularitiesFunction NEPSetWhichEigenpairs
NEPGetEigenpair NEPNLEIGSSetTrueResidual NEPSetWorkVecs
NEPGetErrorEstimate NEPProjectOperator NEPSolve
NEPGetFunction NEPRIIGetConstCorrectionTol NEPStop
NEPGetIterationNumber NEPRIIGetKSP NEPStoppingBasic
NEPGetJacobian NEPRIIGetLagPreconditioner NEPType
NEPGetMonitorContext NEPRIIGetMaximumIterations NEPValuesView
NEPGetOptionsPrefix NEPRIISetConstCorrectionTol NEPValuesViewFromOptions
NEPGetRG NEPRIISetKSP NEPVectorsView
NEPGetRefine NEPRIISetLagPreconditioner NEPVectorsViewFromOptions
NEPGetSplitOperatorInfo NEPRIISetMaximumIterations NEPView
NEPGetSplitOperatorTerm NEPReasonView NEPWhich
NEPGetStoppingTest NEPReasonViewFromOptions
NEPGetTarget NEPRefine

| B | D | E | F | M | N | P | R | S | V |

PEP PEPGetTrackAll PEPSetConvergenceTestFunction
PEPAllocateSolution PEPGetType PEPSetDS
PEPAppendOptionsPrefix PEPGetWhichEigenpairs PEPSetDimensions
PEPBasis PEPInitializePackage PEPSetEigenvalueComparison
PEPComputeError PEPJDGetRestart PEPSetExtract
PEPConv PEPJDSetRestart PEPSetFromOptions
PEPConvMonitorSetFromOptions PEPLinearGetCompanionForm PEPSetInitialSpace
PEPConvergedReason PEPLinearGetEPS PEPSetOperators
PEPCreate PEPLinearGetExplicitMatrix PEPSetOptionsPrefix
PEPDestroy PEPLinearSetCompanionForm PEPSetProblemType
PEPErrorType PEPLinearSetEPS PEPSetRG
PEPErrorView PEPLinearSetExplicitMatrix PEPSetRefine
PEPErrorViewFromOptions PEPMonitorAll PEPSetST
PEPExtract PEPMonitorCancel PEPSetScale
PEPFinalizePackage PEPMonitorConverged PEPSetStoppingTest
PEPGetBV PEPMonitorFirst PEPSetStoppingTestFunction
PEPGetBasis PEPMonitorLGCreate PEPSetTarget
PEPGetConverged PEPMonitorSet PEPSetTolerances
PEPGetConvergedReason PEPMonitorSetFromOptions PEPSetTrackAll
PEPGetConvergenceTest PEPProblemType PEPSetType
PEPGetDS PEPQArnoldiGetLocking PEPSetUp
PEPGetDimensions PEPQArnoldiGetRestart PEPSetWhichEigenpairs
PEPGetEigenpair PEPQArnoldiSetLocking PEPSetWorkVecs
PEPGetErrorEstimate PEPQArnoldiSetRestart PEPSolve
PEPGetExtract PEPReasonView PEPStop
PEPGetIterationNumber PEPReasonViewFromOptions PEPStoppingBasic
PEPGetMonitorContext PEPRefine PEPTOARGetLocking
PEPGetNumMatrices PEPRefineGetKSP PEPTOARGetRestart
PEPGetOperators PEPRefineScheme PEPTOARSetLocking
PEPGetOptionsPrefix PEPRegister PEPTOARSetRestart
PEPGetProblemType PEPRegisterAll PEPType
PEPGetRG PEPReset PEPValuesView
PEPGetRefine PEPSTOARGetLocking PEPValuesViewFromOptions
PEPGetST PEPSTOARSetLocking PEPVectorsView
PEPGetScale PEPScale PEPVectorsViewFromOptions
PEPGetStoppingTest PEPSetBV PEPView
PEPGetTarget PEPSetBasis PEPWhich
PEPGetTolerances PEPSetConvergenceTest

| B | D | E | F | M | N | P | R | S | V |

RG RGGetScale RGRegisterAll
RGAppendOptionsPrefix RGGetType RGRingGetParameters
RGCheckInside RGInitializePackage RGRingSetParameters
RGComputeContour RGIntervalGetEndpoints RGSetComplement
RGCreate RGIntervalSetEndpoints RGSetFromOptions
RGDestroy RGIsTrivial RGSetOptionsPrefix
RGEllipseGetParameters RGPolygonGetVertices RGSetScale
RGEllipseSetParameters RGPolygonSetVertices RGSetType
RGFinalizePackage RGPopScale RGType
RGGetComplement RGPushScale RGView
RGGetOptionsPrefix RGRegister

| B | D | E | F | M | N | P | R | S | V |

ST STSetUp SVDReasonViewFromOptions
STAppendOptionsPrefix STShellGetContext SVDRegister
STApply STShellSetApply SVDRegisterAll
STApplyTranspose STShellSetApplyTranspose SVDReset
STBackTransform STShellSetBackTransform SVDSetBV
STCayleyGetAntishift STShellSetContext SVDSetConvergenceTest
STCayleySetAntishift STType SVDSetConvergenceTestFunction
STCheckNullSpace STView SVDSetDS
STComputeExplicitOperator SVD SVDSetDimensions
STCreate SVDAllocateSolution SVDSetFromOptions
STDestroy SVDAppendOptionsPrefix SVDSetImplicitTranspose
STFinalizePackage SVDComputeError SVDSetInitialSpace
STGetBalanceMatrix SVDConv SVDSetInitialSpaceLeft
STGetBilinearForm SVDConvMonitorSetFromOptions SVDSetOperator
STGetKSP SVDConvergedReason SVDSetOptionsPrefix
STGetMatMode SVDCreate SVDSetStoppingTest
STGetMatStructure SVDCrossGetEPS SVDSetStoppingTestFunction
STGetNumMatrices SVDCrossSetEPS SVDSetTolerances
STGetOperators SVDCyclicGetEPS SVDSetTrackAll
STGetOptionsPrefix SVDCyclicGetExplicitMatrix SVDSetType
STGetShift SVDCyclicSetEPS SVDSetUp
STGetTOperators SVDCyclicSetExplicitMatrix SVDSetWhichSingularTriplets
STGetTransform SVDDestroy SVDSolve
STGetType SVDErrorType SVDStop
STInitializePackage SVDErrorView SVDStoppingBasic
STMatCreateVecs SVDErrorViewFromOptions SVDTRLanczosGetOneSide
STMatGetLocalSize SVDFinalizePackage SVDTRLanczosSetOneSide
STMatGetSize SVDGetBV SVDType
STMatMode SVDGetConverged SVDValuesView
STMatMult SVDGetConvergedReason SVDValuesViewFromOptions
STMatMultTranspose SVDGetConvergenceTest SVDVectorsView
STMatSetUp SVDGetDS SVDVectorsViewFromOptions
STMatSolve SVDGetDimensions SVDView
STMatSolveTranspose SVDGetImplicitTranspose SVDWhich
STPostSolve SVDGetIterationNumber SlepcCheckOrthogonality
STPrecondGetKSPHasMat SVDGetMonitorContext SlepcConvMonitorCreate
STPrecondGetMatForPC SVDGetOperator SlepcConvMonitorDestroy
STPrecondSetKSPHasMat SVDGetOptionsPrefix SlepcFinalize
STPrecondSetMatForPC SVDGetSingularTriplet SlepcGetVersion
STRegister SVDGetStoppingTest SlepcInitialize
STRegisterAll SVDGetTolerances SlepcInitializeFortran
STReset SVDGetTrackAll SlepcInitializeNoArguments
STSHELL SVDGetType SlepcInitialized
STScaleShift SVDGetWhichSingularTriplets SlepcMatConvertSeqDense
STSetBalanceMatrix SVDInitializePackage SlepcMatTile
STSetDefaultShift SVDLanczosGetOneSide SlepcSCCompare
STSetFromOptions SVDLanczosSetOneSide SlepcSNPrintfScalar
STSetKSP SVDMonitorAll SlepcSortEigenvalues
STSetMatMode SVDMonitorCancel SlepcVecNormalize
STSetMatStructure SVDMonitorConverged SlepcVecPoolCreate
STSetOperators SVDMonitorFirst SlepcVecPoolDestroy
STSetOptionsPrefix SVDMonitorLGCreate SlepcVecPoolGetVecs
STSetShift SVDMonitorSet SlepcVecPoolRestoreVecs
STSetTransform SVDMonitorSetFromOptions
STSetType SVDReasonView

| B | D | E | F | M | N | P | R | S | V |

VecCompGetSubVecs VecCreateComp
VecCompSetSubVecs VecCreateCompWithVecs
slepc-3.7.4/docs/manualpages/BV/0000755000175000017500000000000013107004621015717 5ustar jromanjromanslepc-3.7.4/docs/manualpages/BV/BVSetSizes.html0000644000175000017500000000447613107004621020621 0ustar jromanjroman BVSetSizes
slepc-3.7.4 2017-05-17

BVSetSizes

Sets the local and global sizes, and the number of columns.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetSizes(BV bv,PetscInt n,PetscInt N,PetscInt m)
Collective on BV

Input Parameters

bv  - the basis vectors
n  - the local size (or PETSC_DECIDE to have it set)
N  - the global size (or PETSC_DECIDE)
m  - the number of columns

Notes

n and N cannot be both PETSC_DECIDE. If one processor calls this with N of PETSC_DECIDE then all processors must, otherwise the program will hang.

See Also

BVSetSizesFromVec(), BVGetSizes(), BVResize()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVView.html0000644000175000017500000000455013107004621017753 0ustar jromanjroman BVView

slepc-3.7.4 2017-05-17

BVView

Prints the BV data structure.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVView(BV bv,PetscViewer viewer)
Collective on BV

Input Parameters

bv  - the BV context
viewer  - optional visualization context

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization contexts with PetscViewerASCIIOpen() (output to a specified file).

See Also

PetscViewerASCIIOpen()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVOrthogonalize.html0000644000175000017500000000675413107004621021675 0ustar jromanjroman BVOrthogonalize

slepc-3.7.4 2017-05-17

BVOrthogonalize

Orthogonalize all columns (except leading ones), that is, compute the QR decomposition.

Synopsis

#include "slepcbv.h"   
PetscErrorCode BVOrthogonalize(BV V,Mat R)
Collective on BV

Input Parameter

V  - basis vectors

Output Parameters

V  - the modified basis vectors
R  - a sequential dense matrix (or NULL)

Notes

On input, matrix R must be a sequential dense Mat, with at least as many rows and columns as the number of active columns of V. The output satisfies V0 = V*R (where V0 represent the input V) and V'*V = I.

If V has leading columns, then they are not modified (are assumed to be already orthonormal) and the corresponding part of R is not referenced.

Can pass NULL if R is not required.

The method to be used for block orthogonalization can be set with BVSetOrthogonalization(). If set to GS, the computation is done column by column with successive calls to BVOrthogonalizeColumn().

If V is rank-deficient or very ill-conditioned, that is, one or more columns are (almost) linearly dependent with respect to the rest, then the algorithm may break down or result in larger numerical error. Linearly dependent columns are essentially replaced by random directions, and the corresponding diagonal entry in R is set to (nearly) zero.

See Also

BVOrthogonalizeColumn(), BVOrthogonalizeVec(), BVSetActiveColumns(), BVSetOrthogonalization(), BVOrthogBlockType

Location: src/sys/classes/bv/interface/bvorthog.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVRegister.html0000644000175000017500000000374213107004621020627 0ustar jromanjroman BVRegister

slepc-3.7.4 2017-05-17

BVRegister

Adds a new storage format to the BV package.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVRegister(const char *name,PetscErrorCode (*function)(BV))
Not collective

Input Parameters

name  - name of a new user-defined BV
function  - routine to create context

Notes

BVRegister() may be called multiple times to add several user-defined basis vectors.

See Also

BVRegisterAll()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVOrthogonalizeVec.html0000644000175000017500000000571413107004621022326 0ustar jromanjroman BVOrthogonalizeVec

slepc-3.7.4 2017-05-17

BVOrthogonalizeVec

Orthogonalize a given vector with respect to all active columns.

Synopsis

#include "slepcbv.h"   
PetscErrorCode BVOrthogonalizeVec(BV bv,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
Collective on BV

Input Parameters

bv  - the basis vectors context
v  - the vector

Output Parameters

H  - (optional) coefficients computed during orthogonalization
norm  - (optional) norm of the vector after being orthogonalized
lindep  - (optional) flag indicating that refinement did not improve the quality of orthogonalization

Notes

This function is equivalent to BVOrthogonalizeColumn() but orthogonalizes a vector as an argument rather than taking one of the BV columns. The vector is orthogonalized against all active columns.

See Also

BVOrthogonalizeColumn(), BVSetOrthogonalization(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvorthog.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetSizesFromVec.html0000644000175000017500000000407213107004621022073 0ustar jromanjroman BVSetSizesFromVec

slepc-3.7.4 2017-05-17

BVSetSizesFromVec

Sets the local and global sizes, and the number of columns. Local and global sizes are specified indirectly by passing a template vector.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetSizesFromVec(BV bv,Vec t,PetscInt m)
Collective on BV

Input Parameters

bv  - the basis vectors
t  - the template vector
m  - the number of columns

See Also

BVSetSizes(), BVGetSizes(), BVResize()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetCachedBV.html0000644000175000017500000000425213107004621021077 0ustar jromanjroman BVGetCachedBV

slepc-3.7.4 2017-05-17

BVGetCachedBV

Returns a BV object stored internally that holds the result of B*X after a call to BVApplyMatrixBV().

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetCachedBV(BV bv,BV *cached)
Not collective

Input Parameter

bv  - the basis vectors context

Output Parameter

cached  - the cached BV

Note

The function will return a NULL if BVApplyMatrixBV() was not called yet.

See Also

BVApplyMatrixBV()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetOrthogonalization.html0000644000175000017500000001005713107004621023226 0ustar jromanjroman BVSetOrthogonalization

slepc-3.7.4 2017-05-17

BVSetOrthogonalization

Specifies the method used for the orthogonalization of vectors (classical or modified Gram-Schmidt with or without refinement), and for the block-orthogonalization (simultaneous orthogonalization of a set of vectors).

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetOrthogonalization(BV bv,BVOrthogType type,BVOrthogRefineType refine,PetscReal eta,BVOrthogBlockType block)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
type  - the method of vector orthogonalization
refine  - type of refinement
eta  - parameter for selective refinement
block  - the method of block orthogonalization

Options Database Keys

-bv_orthog_type <type>  - Where <type> is cgs for Classical Gram-Schmidt orthogonalization (default) or mgs for Modified Gram-Schmidt orthogonalization
-bv_orthog_refine <ref>  - Where <ref> is one of never, ifneeded (default) or always
-bv_orthog_eta <eta>  - For setting the value of eta
-bv_orthog_block <block>  - Where <block> is the block-orthogonalization method

Notes

The default settings work well for most problems.

The parameter eta should be a real value between 0 and 1 (or PETSC_DEFAULT). The value of eta is used only when the refinement type is "ifneeded".

When using several processors, MGS is likely to result in bad scalability.

If the method set for block orthogonalization is GS, then the computation is done column by column with the vector orthogonalization.

See Also

BVOrthogonalizeColumn(), BVGetOrthogonalization(), BVOrthogType, BVOrthogRefineType, BVOrthogBlockType

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVRestoreArrayRead.html0000644000175000017500000000374313107004621022262 0ustar jromanjroman BVRestoreArrayRead

slepc-3.7.4 2017-05-17

BVRestoreArrayRead

Restore the BV object after BVGetArrayRead() has been called.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVRestoreArrayRead(BV bv,const PetscScalar **a)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
a  - location of pointer to array obtained from BVGetArrayRead()

See Also

BVGetColumn()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetMatrix.html0000644000175000017500000000403313107004621020741 0ustar jromanjroman BVGetMatrix

slepc-3.7.4 2017-05-17

BVGetMatrix

Retrieves the matrix representation of the inner product.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetMatrix(BV bv,Mat *B,PetscBool *indef)
Not collective, though a parallel Mat may be returned

Input Parameter

bv  - the basis vectors context

Output Parameter

B  - the matrix of the inner product (may be NULL)
indef  - the flag indicating if the matrix is indefinite

See Also

BVSetMatrix()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDotVecEnd.html0000644000175000017500000000406013107004621020650 0ustar jromanjroman BVDotVecEnd

slepc-3.7.4 2017-05-17

BVDotVecEnd

Ends a split phase dot product computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDotVecEnd(BV X,Vec y,PetscScalar *m)

Input Parameters

X  - basis vectors
y  - a vector
m  - an array where the result will go

Note

Each call to BVDotVecBegin() should be paired with a call to BVDotVecEnd().

See Also

BVDotVecBegin(), BVDotVec()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetRandomContext.html0000644000175000017500000000410013107004621022255 0ustar jromanjroman BVGetRandomContext

slepc-3.7.4 2017-05-17

BVGetRandomContext

Gets the PetscRandom object associated with the BV.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetRandomContext(BV bv,PetscRandom* rand)
Not Collective

Input Parameter

bv  - the basis vectors context

Output Parameter

rand  - the random number generator context

See Also

BVSetRandomContext(), BVSetRandom(), BVSetRandomColumn()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVFinalizePackage.html0000644000175000017500000000301613107004621022052 0ustar jromanjroman BVFinalizePackage

slepc-3.7.4 2017-05-17

BVFinalizePackage

This function destroys everything in the Slepc interface to the BV package. It is called from SlepcFinalize().

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDuplicate.html0000644000175000017500000000506213107004621020752 0ustar jromanjroman BVDuplicate

slepc-3.7.4 2017-05-17

BVDuplicate

Creates a new basis vector object of the same type and dimensions as an existing one.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDuplicate(BV V,BV *W)
Collective on BV

Input Parameter

V  - basis vectors context

Output Parameter

W  - location to put the new BV

Notes

The new BV has the same type and dimensions as V, and it shares the same template vector. Also, the inner product matrix and orthogonalization options are copied.

BVDuplicate() DOES NOT COPY the entries, but rather allocates storage for the new basis vectors. Use BVCopy() to copy the contents.

See Also

BVDuplicateResize(), BVCreate(), BVSetSizesFromVec(), BVCopy()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetArray.html0000644000175000017500000000500713107004621020555 0ustar jromanjroman BVGetArray

slepc-3.7.4 2017-05-17

BVGetArray

Returns a pointer to a contiguous array that contains this processor's portion of the BV data.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetArray(BV bv,PetscScalar **a)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context

Output Parameter

a  - location to put pointer to the array

Notes

BVRestoreArray() must be called when access to the array is no longer needed. This operation may imply a data copy, for BV types that do not store data contiguously in memory.

The pointer will normally point to the first entry of the first column, but if the BV has constraints then these go before the regular columns.

See Also

BVRestoreArray(), BVInsertConstraints()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVOrthogType.html0000644000175000017500000000336313107004621021146 0ustar jromanjroman BVOrthogType

slepc-3.7.4 2017-05-17

BVOrthogType

Determines the method used in the orthogonalization of vectors

Synopsis

typedef enum { BV_ORTHOG_CGS,
               BV_ORTHOG_MGS } BVOrthogType;

See Also

BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalizeColumn(), BVOrthogRefineType

Location: src/sys/classes/bv/../../../../include/slepcbv.h
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetRandom.html0000644000175000017500000000364513107004621020741 0ustar jromanjroman BVSetRandom

slepc-3.7.4 2017-05-17

BVSetRandom

Set the columns of a BV to random numbers.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetRandom(BV bv)
Logically Collective on BV

Input Parameters

bv  - basis vectors

Note

All active columns (except the leading ones) are modified.

See Also

BVSetRandomContext(), BVSetRandomColumn(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetOptionsPrefix.html0000644000175000017500000000430613107004621022311 0ustar jromanjroman BVGetOptionsPrefix

slepc-3.7.4 2017-05-17

BVGetOptionsPrefix

Gets the prefix used for searching for all BV options in the database.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetOptionsPrefix(BV bv,const char *prefix[])
Not Collective

Input Parameters

bv  - the basis vectors context

Output Parameters

prefix  - pointer to the prefix string used, is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

BVSetOptionsPrefix(), BVAppendOptionsPrefix()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVCopy.html0000644000175000017500000000444613107004621017757 0ustar jromanjroman BVCopy

slepc-3.7.4 2017-05-17

BVCopy

Copies a basis vector object into another one, W <- V.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVCopy(BV V,BV W)
Logically Collective on BV

Input Parameter

V  - basis vectors context

Output Parameter

W  - the copy

Note

Both V and W must be distributed in the same manner; local copies are done. Only active columns (excluding the leading ones) are copied. In the destination W, columns are overwritten starting from the leading ones. Constraints are not copied.

See Also

BVCopyVec(), BVCopyColumn(), BVDuplicate(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetArrayRead.html0000644000175000017500000000502013107004621021344 0ustar jromanjroman BVGetArrayRead

slepc-3.7.4 2017-05-17

BVGetArrayRead

Returns a read-only pointer to a contiguous array that contains this processor's portion of the BV data.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetArrayRead(BV bv,const PetscScalar **a)
Not Collective

Input Parameters

bv  - the basis vectors context

Output Parameter

a  - location to put pointer to the array

Notes

BVRestoreArrayRead() must be called when access to the array is no longer needed. This operation may imply a data copy, for BV types that do not store data contiguously in memory.

The pointer will normally point to the first entry of the first column, but if the BV has constraints then these go before the regular columns.

See Also

BVRestoreArray(), BVInsertConstraints()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BV.html0000644000175000017500000000256413107004621017123 0ustar jromanjroman BV

slepc-3.7.4 2017-05-17

BV

Basis vectors, SLEPc object representing a collection of vectors that typically constitute a basis of a subspace.

Synopsis

typedef struct _p_BV* BV;

See Also

BVCreate()

Location: src/sys/classes/bv/../../../../include/slepcbv.h
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMultColumn.html0000644000175000017500000000527213107004621021142 0ustar jromanjroman BVMultColumn

slepc-3.7.4 2017-05-17

BVMultColumn

Computes y = beta*y + alpha*X*q, where y is the j-th column of X.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMultColumn(BV X,PetscScalar alpha,PetscScalar beta,PetscInt j,PetscScalar *q)
Logically Collective on BV

Input Parameters

X  - a basis vectors object
alpha,beta  - scalars
j  - the column index
q  - an array of scalars

Notes

This operation is equivalent to BVMultVec() but it uses column j of X rather than taking a Vec as an argument. The number of active columns of X is set to j before the computation, and restored afterwards. If X has leading columns specified, then these columns do not participate in the computation. Therefore, the length of array q must be equal to j minus the number of leading columns.

See Also

BVMult(), BVMultVec(), BVMultInPlace(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVCreate.html0000644000175000017500000000352613107004621020246 0ustar jromanjroman BVCreate

slepc-3.7.4 2017-05-17

BVCreate

Creates a basis vectors context.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVCreate(MPI_Comm comm,BV *newbv)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

bv  - location to put the basis vectors context

See Also

BVSetUp(), BVDestroy(), BV

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDot.html0000644000175000017500000000567313107004621017576 0ustar jromanjroman BVDot

slepc-3.7.4 2017-05-17

BVDot

Computes the 'block-dot' product of two basis vectors objects.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDot(BV X,BV Y,Mat M)
Collective on BV

Input Parameters

X, Y  - basis vectors
M  - Mat object where the result must be placed

Output Parameter

M  - the resulting matrix

Notes

This is the generalization of VecDot() for a collection of vectors, M = Y^H*X. The result is a matrix M whose entry m_ij is equal to y_i^H x_j (where y_i^H denotes the conjugate transpose of y_i).

If a non-standard inner product has been specified with BVSetMatrix(), then the result is M = Y^H*B*X. In this case, both X and Y must have the same associated matrix.

On entry, M must be a sequential dense Mat with dimensions m,n at least, where m is the number of active columns of Y and n is the number of active columns of X. Only rows (resp. columns) of M starting from ly (resp. lx) are computed, where ly (resp. lx) is the number of leading columns of Y (resp. X).

X and Y need not be different objects.

See Also

BVDotVec(), BVDotColumn(), BVSetActiveColumns(), BVSetMatrix()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetNumConstraints.html0000644000175000017500000000365413107004621022474 0ustar jromanjroman BVGetNumConstraints

slepc-3.7.4 2017-05-17

BVGetNumConstraints

Returns the number of constraints.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetNumConstraints(BV bv,PetscInt *nc)
Not Collective

Input Parameter

bv  - the basis vectors

Output Parameters

nc  - the number of constraints

See Also

BVGetSizes(), BVInsertConstraints()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMatMultColumn.html0000644000175000017500000000416113107004621021600 0ustar jromanjroman BVMatMultColumn

slepc-3.7.4 2017-05-17

BVMatMultColumn

Computes the matrix-vector product for a specified column, storing the result in the next column: v_{j+1}=A*v_j.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMatMultColumn(BV V,Mat A,PetscInt j)
Neighbor-wise Collective on Mat and BV

Input Parameters

V  - basis vectors context
A  - the matrix
j  - the column

Output Parameter

Y  - the result

See Also

BVMatMult()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMatMultType.html0000644000175000017500000000341113107004621021261 0ustar jromanjroman BVMatMultType

slepc-3.7.4 2017-05-17

BVMatMultType

Determines how to perform the BVMatMult() operation: BV_MATMULT_VECS: perform a matrix-vector multiply per each column; BV_MATMULT_MAT: carry out a MatMatMult() product with a dense matrix (default); BV_MATMULT_MAT_SAVE: call MatMatMult() and keep auxiliary matrices (more efficient but needs more memory)

Synopsis

typedef enum { BV_MATMULT_VECS,
               BV_MATMULT_MAT,
               BV_MATMULT_MAT_SAVE } BVMatMultType;

See Also

BVMatMult()

Location: src/sys/classes/bv/../../../../include/slepcbv.h
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVInitializePackage.html0000644000175000017500000000315013107004621022411 0ustar jromanjroman BVInitializePackage

slepc-3.7.4 2017-05-17

BVInitializePackage

This function initializes everything in the BV package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to BVCreate() when using static libraries.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVInitializePackage(void)

See Also

SlepcInitialize()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetRandomContext.html0000644000175000017500000000404213107004621022276 0ustar jromanjroman BVSetRandomContext

slepc-3.7.4 2017-05-17

BVSetRandomContext

Sets the PetscRandom object associated with the BV, to be used in operations that need random numbers.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetRandomContext(BV bv,PetscRandom rand)
Collective on BV

Input Parameters

bv  - the basis vectors context
rand  - the random number generator context

See Also

BVGetRandomContext(), BVSetRandom(), BVSetRandomColumn()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetType.html0000644000175000017500000000376713107004621020447 0ustar jromanjroman BVSetType

slepc-3.7.4 2017-05-17

BVSetType

Selects the type for the BV object.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetType(BV bv,BVType type)
Logically Collective on BV

Input Parameter

bv  - the basis vectors context
type  - a known type

Options Database Key

-bv_type <type>  - Sets BV type

See Also

BVGetType()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetNumConstraints.html0000644000175000017500000000433313107004621022503 0ustar jromanjroman BVSetNumConstraints

slepc-3.7.4 2017-05-17

BVSetNumConstraints

Set the number of constraints.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetNumConstraints(BV V,PetscInt nc)
Logically Collective on BV

Input Parameters

V  - basis vectors
nc  - number of constraints

Notes

This function sets the number of constraints to nc and marks all remaining columns as regular. Normal user would call BVInsertConstraints() instead.

If nc is smaller than the previously set value, then some of the constraints are discarded. In particular, using nc=0 removes all constraints preserving the content of regular columns.

See Also

BVInsertConstraints()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVApplyMatrixBV.html0000644000175000017500000000507113107004621021542 0ustar jromanjroman BVApplyMatrixBV

slepc-3.7.4 2017-05-17

BVApplyMatrixBV

Multiplies the BV vectors by the matrix representation of the inner product.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVApplyMatrixBV(BV X,BV Y)
Neighbor-wise Collective on BV

Input Parameter

X  - the basis vectors context

Output Parameter

Y  - the basis vectors to store the result (optional)

Note

This function computes Y = B*X, where B is the matrix given with BVSetMatrix(). This operation is computed as in BVMatMult(). If no matrix was specified, then it just copies Y = X.

If no Y is given, the result is stored internally in the cached BV.

See Also

BVSetMatrix(), BVApplyMatrix(), BVMatMult(), BVGetCachedBV()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMultInPlaceTranspose.html0000644000175000017500000000454513107004621023121 0ustar jromanjroman BVMultInPlaceTranspose

slepc-3.7.4 2017-05-17

BVMultInPlaceTranspose

Update a set of vectors as V(:,s:e-1) = V*Q'(:,s:e-1).

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMultInPlaceTranspose(BV V,Mat Q,PetscInt s,PetscInt e)
Logically Collective on BV

Input Parameters

Q  - a sequential dense matrix
s  - first column of V to be overwritten
e  - first column of V not to be overwritten

Input/Output Parameter

V  - basis vectors

Notes

This is a variant of BVMultInPlace() where the conjugate transpose of Q is used.

See Also

BVMultInPlace()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMult.html0000644000175000017500000000621113107004621017756 0ustar jromanjroman BVMult

slepc-3.7.4 2017-05-17

BVMult

Computes Y = beta*Y + alpha*X*Q.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMult(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)
Logically Collective on BV

Input Parameters

Y,X  - basis vectors
alpha,beta  - scalars
Q  - (optional) sequential dense matrix

Output Parameter

Y  - the modified basis vectors

Notes

X and Y must be different objects. The case X=Y can be addressed with BVMultInPlace().

If matrix Q is NULL, then an AXPY operation Y = beta*Y + alpha*X is done (i.e. results as if Q = identity). If provided, the matrix Q must be a sequential dense Mat, with all entries equal on all processes (otherwise each process will compute a different update). The dimensions of Q must be at least m,n where m is the number of active columns of X and n is the number of active columns of Y.

The leading columns of Y are not modified. Also, if X has leading columns specified, then these columns do not participate in the computation. Hence, only rows (resp. columns) of Q starting from lx (resp. ly) are used, where lx (resp. ly) is the number of leading columns of X (resp. Y).

See Also

BVMultVec(), BVMultColumn(), BVMultInPlace(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDotColumnBegin.html0000644000175000017500000000431413107004621021710 0ustar jromanjroman BVDotColumnBegin

slepc-3.7.4 2017-05-17

BVDotColumnBegin

Starts a split phase dot product computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDotColumnBegin(BV X,PetscInt j,PetscScalar *m)

Input Parameters

X  - basis vectors
j  - the column index
m  - an array where the result will go (can be NULL)

Note

Each call to BVDotColumnBegin() should be paired with a call to BVDotColumnEnd().

See Also

BVDotColumnEnd(), BVDotColumn()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVOrthogonalizeColumn.html0000644000175000017500000000677613107004621023057 0ustar jromanjroman BVOrthogonalizeColumn

slepc-3.7.4 2017-05-17

BVOrthogonalizeColumn

Orthogonalize one of the column vectors with respect to the previous ones.

Synopsis

#include "slepcbv.h"   
PetscErrorCode BVOrthogonalizeColumn(BV bv,PetscInt j,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
Collective on BV

Input Parameters

bv  - the basis vectors context
j  - index of column to be orthogonalized

Output Parameters

H  - (optional) coefficients computed during orthogonalization
norm  - (optional) norm of the vector after being orthogonalized
lindep  - (optional) flag indicating that refinement did not improve the quality of orthogonalization

Notes

This function applies an orthogonal projector to project vector V[j] onto the orthogonal complement of the span of the columns of V[0..j-1], where V[.] are the vectors of BV. The columns V[0..j-1] are assumed to be mutually orthonormal.

Leading columns V[0..l-1] also participate in the orthogonalization.

If a non-standard inner product has been specified with BVSetMatrix(), then the vector is B-orthogonalized, using the non-standard inner product defined by matrix B. The output vector satisfies V[j]'*B*V[0..j-1] = 0.

This routine does not normalize the resulting vector.

See Also

BVSetOrthogonalization(), BVSetMatrix(), BVSetActiveColumns(), BVOrthogonalize(), BVOrthogonalizeVec()

Location: src/sys/classes/bv/interface/bvorthog.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetType.html0000644000175000017500000000357213107004621020425 0ustar jromanjroman BVGetType

slepc-3.7.4 2017-05-17

BVGetType

Gets the BV type name (as a string) from the BV context.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetType(BV bv,BVType *type)
Not Collective

Input Parameter

bv  - the basis vectors context

Output Parameter

name  - name of the type of basis vectors

See Also

BVSetType()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVApplyMatrix.html0000644000175000017500000000423613107004621021314 0ustar jromanjroman BVApplyMatrix

slepc-3.7.4 2017-05-17

BVApplyMatrix

Multiplies a vector by the matrix representation of the inner product.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVApplyMatrix(BV bv,Vec x,Vec y)
Neighbor-wise Collective on BV and Vec

Input Parameter

bv  - the basis vectors context
x  - the vector

Output Parameter

y  - the result

Note

If no matrix was specified this function copies the vector.

See Also

BVSetMatrix(), BVApplyMatrixBV()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMatMult.html0000644000175000017500000000527313107004621020427 0ustar jromanjroman BVMatMult

slepc-3.7.4 2017-05-17

BVMatMult

Computes the matrix-vector product for each column, Y=A*V.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMatMult(BV V,Mat A,BV Y)
Neighbor-wise Collective on Mat and BV

Input Parameters

V  - basis vectors context
A  - the matrix

Output Parameter

Y  - the result

Note

Both V and Y must be distributed in the same manner. Only active columns (excluding the leading ones) are processed. In the result Y, columns are overwritten starting from the leading ones.

It is possible to choose whether the computation is done column by column or as a Mat-Mat product, see BVSetMatMultMethod().

See Also

BVCopy(), BVSetActiveColumns(), BVMatMultColumn(), BVMatMultHermitianTranspose(), BVSetMatMultMethod()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVOrthogonalizeSomeColumn.html0000644000175000017500000000620213107004621023663 0ustar jromanjroman BVOrthogonalizeSomeColumn

slepc-3.7.4 2017-05-17

BVOrthogonalizeSomeColumn

Orthogonalize one of the column vectors with respect to some of the previous ones.

Synopsis

#include "slepcbv.h"   
PetscErrorCode BVOrthogonalizeSomeColumn(BV bv,PetscInt j,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
Collective on BV

Input Parameters

bv  - the basis vectors context
j  - index of column to be orthogonalized
which  - logical array indicating selected columns

Output Parameters

H  - (optional) coefficients computed during orthogonalization
norm  - (optional) norm of the vector after being orthogonalized
lindep  - (optional) flag indicating that refinement did not improve the quality of orthogonalization

Notes

This function is similar to BVOrthogonalizeColumn(), but V[j] is orthogonalized only against columns V[i] having which[i]=PETSC_TRUE. The length of array which must be j at least.

The use of this operation is restricted to MGS orthogonalization type.

See Also

BVOrthogonalizeColumn(), BVSetOrthogonalization()

Location: src/sys/classes/bv/interface/bvorthog.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVScale.html0000644000175000017500000000365013107004621020070 0ustar jromanjroman BVScale

slepc-3.7.4 2017-05-17

BVScale

Multiply the BV entries by a scalar value.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVScale(BV bv,PetscScalar alpha)
Logically Collective on BV

Input Parameters

bv  - basis vectors
alpha  - scaling factor

Note

All active columns (except the leading ones) are scaled.

See Also

BVScaleColumn(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVInsertConstraints.html0000644000175000017500000000661413107004621022540 0ustar jromanjroman BVInsertConstraints

slepc-3.7.4 2017-05-17

BVInsertConstraints

Insert a set of vectors as constraints.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVInsertConstraints(BV V,PetscInt *nc,Vec *C)
Collective on BV

Input Parameters

V  - basis vectors
C  - set of vectors to be inserted as constraints

Input/Output Parameter

nc  - number of input vectors, on output the number of linearly independent vectors

Notes

The constraints are relevant only during orthogonalization. Constraint vectors span a subspace that is deflated in every orthogonalization operation, so they are intended for removing those directions from the orthogonal basis computed in regular BV columns.

Constraints are not stored in regular BV colums, but in a special part of the storage. They can be accessed with negative indices in BVGetColumn().

This operation is DESTRUCTIVE, meaning that all data contained in the columns of V is lost. This is typically invoked just after creating the BV. Once a set of constraints has been set, it is not allowed to call this function again.

The vectors are copied one by one and then orthogonalized against the previous ones. If any of them is linearly dependent then it is discarded and the value of nc is decreased. The behaviour is similar to BVInsertVecs().

See Also

BVInsertVecs(), BVOrthogonalizeColumn(), BVGetColumn(), BVGetNumConstraints()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVNorm.html0000644000175000017500000000471713107004621017761 0ustar jromanjroman BVNorm

slepc-3.7.4 2017-05-17

BVNorm

Computes the matrix norm of the BV.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVNorm(BV bv,NormType type,PetscReal *val)
Collective on BV

Input Parameters

bv  - basis vectors
type  - the norm type

Output Parameter

val  - the norm

Notes

All active columns (except the leading ones) are considered as a matrix. The allowed norms are NORM_1, NORM_FROBENIUS, and NORM_INFINITY.

This operation fails if a non-standard inner product has been specified with BVSetMatrix().

See Also

BVNormVec(), BVNormColumn(), BVSetActiveColumns(), BVSetMatrix()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMatMultHermitianTranspose.html0000644000175000017500000000527413107004621024170 0ustar jromanjroman BVMatMultHermitianTranspose

slepc-3.7.4 2017-05-17

BVMatMultHermitianTranspose

Computes the matrix-vector product with the conjugate transpose of a matrix for each column, Y=A^H*V.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMatMultHermitianTranspose(BV V,Mat A,BV Y)
Neighbor-wise Collective on Mat and BV

Input Parameters

V  - basis vectors context
A  - the matrix

Output Parameter

Y  - the result

Note

Both V and Y must be distributed in the same manner. Only active columns (excluding the leading ones) are processed. In the result Y, columns are overwritten starting from the leading ones.

As opposed to BVMatMult(), this operation is always done column by column, with a sequence of calls to MatMultHermitianTranspose().

See Also

BVCopy(), BVSetActiveColumns(), BVMatMult(), BVMatMultColumn()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMultVec.html0000644000175000017500000000600613107004621020416 0ustar jromanjroman BVMultVec

slepc-3.7.4 2017-05-17

BVMultVec

Computes y = beta*y + alpha*X*q.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMultVec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)
Logically Collective on BV and Vec

Input Parameters

X  - a basis vectors object
alpha,beta  - scalars
y  - a vector
q  - an array of scalars

Output Parameter

y  - the modified vector

Notes

This operation is the analogue of BVMult() but with a BV and a Vec, instead of two BV. Note that arguments are listed in different order with respect to BVMult().

If X has leading columns specified, then these columns do not participate in the computation.

The length of array q must be equal to the number of active columns of X minus the number of leading columns, i.e. the first entry of q multiplies the first non-leading column.

See Also

BVMult(), BVMultColumn(), BVMultInPlace(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVOrthogBlockType.html0000644000175000017500000000335613107004621022123 0ustar jromanjroman BVOrthogBlockType

slepc-3.7.4 2017-05-17

BVOrthogBlockType

Determines the method used in block orthogonalization (simultaneous orthogonalization of a set of vectors)

Synopsis

typedef enum { BV_ORTHOG_BLOCK_GS,
               BV_ORTHOG_BLOCK_CHOL } BVOrthogBlockType;

See Also

BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalize()

Location: src/sys/classes/bv/../../../../include/slepcbv.h
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVInsertVecs.html0000644000175000017500000000530213107004621021122 0ustar jromanjroman BVInsertVecs

slepc-3.7.4 2017-05-17

BVInsertVecs

Insert a set of vectors into the specified columns.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVInsertVecs(BV V,PetscInt s,PetscInt *m,Vec *W,PetscBool orth)
Collective on BV

Input Parameters

V  - basis vectors
s  - first column of V to be overwritten
W  - set of vectors to be copied
orth  - flag indicating if the vectors must be orthogonalized

Input/Output Parameter

m  - number of input vectors, on output the number of linearly independent vectors

Notes

Copies the contents of vectors W to V(:,s:s+n). If the orthogonalization flag is set, then the vectors are copied one by one and then orthogonalized against the previous ones. If any of them is linearly dependent then it is discarded and the value of m is decreased.

See Also

BVInsertVec(), BVOrthogonalizeColumn()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVRestoreArray.html0000644000175000017500000000413513107004621021462 0ustar jromanjroman BVRestoreArray

slepc-3.7.4 2017-05-17

BVRestoreArray

Restore the BV object after BVGetArray() has been called.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVRestoreArray(BV bv,PetscScalar **a)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
a  - location of pointer to array obtained from BVGetArray()

Note

This operation may imply a data copy, for BV types that do not store data contiguously in memory.

See Also

BVGetColumn()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVType.html0000644000175000017500000000307213107004621017760 0ustar jromanjroman BVType

slepc-3.7.4 2017-05-17

BVType

String with the name of the type of BV. Each type differs in the way data is stored internally.

Synopsis

typedef const char* BVType;
#define BVMAT        "mat"
#define BVSVEC       "svec"
#define BVVECS       "vecs"
#define BVCONTIGUOUS "contiguous"

See Also

BVSetType(), BV

Location: src/sys/classes/bv/../../../../include/slepcbv.h
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDuplicateResize.html0000644000175000017500000000462113107004621022134 0ustar jromanjroman BVDuplicateResize

slepc-3.7.4 2017-05-17

BVDuplicateResize

Creates a new basis vector object of the same type and dimensions as an existing one, but with possibly different number of columns.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDuplicateResize(BV V,PetscInt m,BV *W)
Collective on BV

Input Parameter

V  - basis vectors context
m  - the new number of columns

Output Parameter

W  - location to put the new BV

Note

This is equivalent of a call to BVDuplicate() followed by BVResize(). The contents of V are not copied to W.

See Also

BVDuplicate(), BVResize()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetSignature.html0000644000175000017500000000376513107004621021465 0ustar jromanjroman BVSetSignature

slepc-3.7.4 2017-05-17

BVSetSignature

Sets the signature matrix to be used in orthogonalization.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetSignature(BV bv,Vec omega)
Logically Collective on BV

Input Parameter

bv  - the basis vectors context
omega  - a vector representing the diagonal of the signature matrix

Note

The signature matrix Omega = V'*B*V is relevant only for an indefinite B.

See Also

BVSetMatrix(), BVGetSignature()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVAppendOptionsPrefix.html0000644000175000017500000000433113107004621022777 0ustar jromanjroman BVAppendOptionsPrefix

slepc-3.7.4 2017-05-17

BVAppendOptionsPrefix

Appends to the prefix used for searching for all BV options in the database.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVAppendOptionsPrefix(BV bv,const char *prefix)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
prefix  - the prefix string to prepend to all BV option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

BVSetOptionsPrefix(), BVGetOptionsPrefix()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetActiveColumns.html0000644000175000017500000000534113107004621022270 0ustar jromanjroman BVSetActiveColumns

slepc-3.7.4 2017-05-17

BVSetActiveColumns

Specify the columns that will be involved in operations.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetActiveColumns(BV bv,PetscInt l,PetscInt k)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
l  - number of leading columns
k  - number of active columns

Notes

In operations such as BVMult() or BVDot(), only the first k columns are considered. This is useful when the BV is filled from left to right, so the last m-k columns do not have relevant information.

Also in operations such as BVMult() or BVDot(), the first l columns are normally not included in the computation. See the manpage of each operation.

In orthogonalization operations, the first l columns are treated differently: they participate in the orthogonalization but the computed coefficients are not stored.

See Also

BVGetActiveColumns(), BVSetSizes()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetMatrix.html0000644000175000017500000000561213107004621020761 0ustar jromanjroman BVSetMatrix

slepc-3.7.4 2017-05-17

BVSetMatrix

Specifies the inner product to be used in orthogonalization.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetMatrix(BV bv,Mat B,PetscBool indef)
Collective on BV

Input Parameters

bv  - the basis vectors context
B  - a symmetric matrix (may be NULL)
indef  - a flag indicating if the matrix is indefinite

Notes

This is used to specify a non-standard inner product, whose matrix representation is given by B. Then, all inner products required during orthogonalization are computed as (x,y)_B=y^H*B*x rather than the standard form (x,y)=y^H*x.

Matrix B must be real symmetric (or complex Hermitian). A genuine inner product requires that B is also positive (semi-)definite. However, we also allow for an indefinite B (setting indef=PETSC_TRUE), in which case the orthogonalization uses an indefinite inner product.

This affects operations BVDot(), BVNorm(), BVOrthogonalize(), and variants.

Setting B=NULL has the same effect as if the identity matrix was passed.

See Also

BVGetMatrix(), BVDot(), BVNorm(), BVOrthogonalize()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDotColumn.html0000644000175000017500000000526013107004621020744 0ustar jromanjroman BVDotColumn

slepc-3.7.4 2017-05-17

BVDotColumn

Computes multiple dot products of a column against all the previous columns of a BV.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDotColumn(BV X,PetscInt j,PetscScalar *m)
Collective on BV

Input Parameters

X  - basis vectors
j  - the column index

Output Parameter

m  - an array where the result must be placed

Notes

This operation is equivalent to BVDotVec() but it uses column j of X rather than taking a Vec as an argument. The number of active columns of X is set to j before the computation, and restored afterwards. If X has leading columns specified, then these columns do not participate in the computation. Therefore, the length of array m must be equal to j minus the number of leading columns.

See Also

BVDot(), BVDotVec(), BVSetActiveColumns(), BVSetMatrix()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVNormColumnBegin.html0000644000175000017500000000436313107004621022101 0ustar jromanjroman BVNormColumnBegin

slepc-3.7.4 2017-05-17

BVNormColumnBegin

Starts a split phase norm computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVNormColumnBegin(BV bv,PetscInt j,NormType type,PetscReal *val)

Input Parameters

bv  - basis vectors
j  - column number to be used
type  - the norm type
val  - the norm

Note

Each call to BVNormColumnBegin() should be paired with a call to BVNormColumnEnd().

See Also

BVNormColumnEnd(), BVNormColumn()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVCopyColumn.html0000644000175000017500000000365713107004621021140 0ustar jromanjroman BVCopyColumn

slepc-3.7.4 2017-05-17

BVCopyColumn

Copies the values from one of the columns to another one.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVCopyColumn(BV V,PetscInt j,PetscInt i)
Logically Collective on BV

Input Parameter

V  - basis vectors context
j  - the number of the source column
i  - the number of the destination column

See Also

BVCopy(), BVCopyVec()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVScaleColumn.html0000644000175000017500000000370013107004621021242 0ustar jromanjroman BVScaleColumn

slepc-3.7.4 2017-05-17

BVScaleColumn

Scale one column of a BV.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVScaleColumn(BV bv,PetscInt j,PetscScalar alpha)
Logically Collective on BV

Input Parameters

bv  - basis vectors
j  - column number to be scaled
alpha  - scaling factor

See Also

BVScale(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/index.html0000644000175000017500000001727413107004621017727 0ustar jromanjroman Basis Vectors - BV

slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

Beginner - Basic usage
BV BVDestroy BVRestoreColumn
BVCopy BVGetColumn BVSetFromOptions
BVCopyColumn BVGetSizes BVSetSizes
BVCopyVec BVMatMult BVSetSizesFromVec
BVCreate BVMatMultColumn BVType
BVCreateVec BVMatMultHermitianTranspose BVView
Intermediate - Setting options for algorithms and data structures
BVDot BVInsertVecs BVNormColumn
BVDotVec BVMatProject BVOrthogonalize
BVDuplicate BVMult BVScale
BVDuplicateResize BVMultInPlace BVScaleColumn
BVGetActiveColumns BVMultInPlaceTranspose BVSetActiveColumns
BVGetType BVMultVec BVSetType
BVInsertVec BVNorm
Advanced - Setting more advanced options and customization
BVAppendOptionsPrefix BVGetRandomContext BVRegister
BVApplyMatrix BVInsertConstraints BVRegisterAll
BVDotColumn BVMatMultType BVResize
BVDotColumnBegin BVMultColumn BVRestoreArray
BVDotColumnEnd BVNormColumnBegin BVRestoreArrayRead
BVDotVecBegin BVNormColumnEnd BVSetMatMultMethod
BVDotVecEnd BVNormVecBegin BVSetMatrix
BVGetArray BVNormVecEnd BVSetOptionsPrefix
BVGetArrayRead BVOrthogBlockType BVSetOrthogonalization
BVGetMatMultMethod BVOrthogRefineType BVSetRandom
BVGetMatrix BVOrthogType BVSetRandomColumn
BVGetNumConstraints BVOrthogonalizeColumn BVSetRandomContext
BVGetOptionsPrefix BVOrthogonalizeSomeColumn
BVGetOrthogonalization BVOrthogonalizeVec
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
BVApplyMatrixBV BVGetSignature BVSetNumConstraints
BVFinalizePackage BVInitializePackage BVSetSignature
BVGetCachedBV BVNormVec
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/BV/BVResize.html0000644000175000017500000000414113107004621020276 0ustar jromanjroman BVResize

slepc-3.7.4 2017-05-17

BVResize

Change the number of columns.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVResize(BV bv,PetscInt m,PetscBool copy)
Collective on BV

Input Parameters

bv  - the basis vectors
m  - the new number of columns
copy  - a flag indicating whether current values should be kept

Note

Internal storage is reallocated. If the copy flag is set to true, then the contents are copied to the leading part of the new space.

See Also

BVSetSizes(), BVSetSizesFromVec()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVNormColumn.html0000644000175000017500000000513013107004621021125 0ustar jromanjroman BVNormColumn

slepc-3.7.4 2017-05-17

BVNormColumn

Computes the vector norm of a selected column.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVNormColumn(BV bv,PetscInt j,NormType type,PetscReal *val)
Collective on BV

Input Parameters

bv  - basis vectors
j  - column number to be used
type  - the norm type

Output Parameter

val  - the norm

Notes

The norm of V[j] is computed (NORM_1, NORM_2, or NORM_INFINITY). If a non-standard inner product has been specified with BVSetMatrix(), then the returned value is sqrt(V[j]'*B*V[j]), where B is the inner product matrix (argument 'type' is ignored).

See Also

BVNorm(), BVNormVec(), BVSetActiveColumns(), BVSetMatrix()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetMatMultMethod.html0000644000175000017500000000571113107004621022241 0ustar jromanjroman BVSetMatMultMethod

slepc-3.7.4 2017-05-17

BVSetMatMultMethod

Specifies the method used for the BVMatMult() operation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetMatMultMethod(BV bv,BVMatMultType method)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
method  - the method for the BVMatMult() operation

Options Database Keys

-bv_matmult <meth>  - choose one of the methods: vecs, mat, mat_save

Note

Allowed values are

BV_MATMULT_VECS  - perform a matrix-vector multiply per each column
BV_MATMULT_MAT  - carry out a MatMatMult() product with a dense matrix
BV_MATMULT_MAT_SAVE  - call MatMatMult() and keep auxiliary matrices The default is BV_MATMULT_MAT.

See Also

BVMatMult(), BVGetMatMultMethod(), BVMatMultType

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetRandomColumn.html0000644000175000017500000000370613107004621022115 0ustar jromanjroman BVSetRandomColumn

slepc-3.7.4 2017-05-17

BVSetRandomColumn

Set one column of a BV to random numbers.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetRandomColumn(BV bv,PetscInt j)
Logically Collective on BV

Input Parameters

bv  - basis vectors
j  - column number to be set

See Also

BVSetRandomContext(), BVSetRandom(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVRegisterAll.html0000644000175000017500000000262713107004621021261 0ustar jromanjroman BVRegisterAll

slepc-3.7.4 2017-05-17

BVRegisterAll

Registers all of the storage variants in the BV package.

Synopsis

#include "slepcbv.h"   
PetscErrorCode BVRegisterAll(void)
Not Collective

See Also

BVRegister()

Location: src/sys/classes/bv/interface/bvregis.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetMatMultMethod.html0000644000175000017500000000415613107004621022227 0ustar jromanjroman BVGetMatMultMethod

slepc-3.7.4 2017-05-17

BVGetMatMultMethod

Gets the method used for the BVMatMult() operation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetMatMultMethod(BV bv,BVMatMultType *method)
Not Collective

Input Parameter

bv  - basis vectors context

Output Parameter

method  - the method for the BVMatMult() operation

See Also

BVMatMult(), BVSetMatMultMethod(), BVMatMultType

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMatProject.html0000644000175000017500000000740213107004621021110 0ustar jromanjroman BVMatProject

slepc-3.7.4 2017-05-17

BVMatProject

Computes the projection of a matrix onto a subspace.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMatProject(BV X,Mat A,BV Y,Mat M)
Collective on BV

Input Parameters

X  - basis vectors
A  - (optional) matrix to be projected
Y  - left basis vectors, can be equal to X
M  - Mat object where the result must be placed

Output Parameter

M  - the resulting matrix

Notes

If A=NULL, then it is assumed that X already contains A*X.

This operation is similar to BVDot(), with important differences. The goal is to compute the matrix resulting from the orthogonal projection of A onto the subspace spanned by the columns of X, M = X^H*A*X, or the oblique projection onto X along Y, M = Y^H*A*X.

A difference with respect to BVDot() is that the standard inner product is always used, regardless of a non-standard inner product being specified with BVSetMatrix().

On entry, M must be a sequential dense Mat with dimensions ky,kx at least, where ky (resp. kx) is the number of active columns of Y (resp. X). Another difference with respect to BVDot() is that all entries of M are computed except the leading ly,lx part, where ly (resp. lx) is the number of leading columns of Y (resp. X). Hence, the leading columns of X and Y participate in the computation, as opposed to BVDot(). The leading part of M is assumed to be already available from previous computations.

In the orthogonal projection case, Y=X, some computation can be saved if A is real symmetric (or complex Hermitian). In order to exploit this property, the symmetry flag of A must be set with MatSetOption().

See Also

BVDot(), BVSetActiveColumns(), BVSetMatrix()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVNormColumnEnd.html0000644000175000017500000000435313107004621021562 0ustar jromanjroman BVNormColumnEnd

slepc-3.7.4 2017-05-17

BVNormColumnEnd

Ends a split phase norm computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVNormColumnEnd(BV bv,PetscInt j,NormType type,PetscReal *val)

Input Parameters

bv  - basis vectors
j  - column number to be used
type  - the norm type
val  - the norm

Note

Each call to BVNormColumnBegin() should be paired with a call to BVNormColumnEnd().

See Also

BVNormColumnBegin(), BVNormColumn()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVRestoreColumn.html0000644000175000017500000000421113107004621021634 0ustar jromanjroman BVRestoreColumn

slepc-3.7.4 2017-05-17

BVRestoreColumn

Restore a column obtained with BVGetColumn().

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVRestoreColumn(BV bv,PetscInt j,Vec *v)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
j  - the index of the column
v  - vector obtained with BVGetColumn()

Note

The arguments must match the corresponding call to BVGetColumn().

See Also

BVGetColumn()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetOrthogonalization.html0000644000175000017500000000531013107004621023206 0ustar jromanjroman BVGetOrthogonalization

slepc-3.7.4 2017-05-17

BVGetOrthogonalization

Gets the orthogonalization settings from the BV object.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetOrthogonalization(BV bv,BVOrthogType *type,BVOrthogRefineType *refine,PetscReal *eta,BVOrthogBlockType *block)
Not Collective

Input Parameter

bv  - basis vectors context

Output Parameter

type  - the method of vector orthogonalization
refine  - type of refinement
eta  - parameter for selective refinement
block  - the method of block orthogonalization

See Also

BVOrthogonalizeColumn(), BVSetOrthogonalization(), BVOrthogType, BVOrthogRefineType, BVOrthogBlockType

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDestroy.html0000644000175000017500000000324413107004621020471 0ustar jromanjroman BVDestroy

slepc-3.7.4 2017-05-17

BVDestroy

Destroys BV context that was created with BVCreate().

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDestroy(BV *bv)
Collective on BV

Input Parameter

bv  - the basis vectors context

See Also

BVCreate()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetOptionsPrefix.html0000644000175000017500000000431213107004621022322 0ustar jromanjroman BVSetOptionsPrefix

slepc-3.7.4 2017-05-17

BVSetOptionsPrefix

Sets the prefix used for searching for all BV options in the database.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetOptionsPrefix(BV bv,const char *prefix)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
prefix  - the prefix string to prepend to all BV option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

BVAppendOptionsPrefix(), BVGetOptionsPrefix()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetActiveColumns.html0000644000175000017500000000375413107004621022262 0ustar jromanjroman BVGetActiveColumns

slepc-3.7.4 2017-05-17

BVGetActiveColumns

Returns the current active dimensions.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetActiveColumns(BV bv,PetscInt *l,PetscInt *k)
Not Collective

Input Parameter

bv  - the basis vectors context

Output Parameter

l  - number of leading columns
k  - number of active columns

See Also

BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVInsertVec.html0000644000175000017500000000351713107004621020745 0ustar jromanjroman BVInsertVec

slepc-3.7.4 2017-05-17

BVInsertVec

Insert a vector into the specified column.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVInsertVec(BV V,PetscInt j,Vec w)
Collective on BV

Input Parameters

V  - basis vectors
j  - the column of V to be overwritten
w  - the vector to be copied

See Also

BVInsertVecs()

Location: src/sys/classes/bv/interface/bvfunc.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDotColumnEnd.html0000644000175000017500000000416413107004621021375 0ustar jromanjroman BVDotColumnEnd

slepc-3.7.4 2017-05-17

BVDotColumnEnd

Ends a split phase dot product computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDotColumnEnd(BV X,PetscInt j,PetscScalar *m)

Input Parameters

X  - basis vectors
j  - the column index
m  - an array where the result will go

Notes

Each call to BVDotColumnBegin() should be paired with a call to BVDotColumnEnd().

See Also

BVDotColumnBegin(), BVDotColumn()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetSizes.html0000644000175000017500000000504113107004621020572 0ustar jromanjroman BVGetSizes

slepc-3.7.4 2017-05-17

BVGetSizes

Returns the local and global sizes, and the number of columns.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetSizes(BV bv,PetscInt *n,PetscInt *N,PetscInt *m)
Not Collective

Input Parameter

bv  - the basis vectors

Output Parameters

n  - the local size
N  - the global size
m  - the number of columns

Note

Normal usage requires that bv has already been given its sizes, otherwise the call fails. However, this function can also be used to determine if a BV object has been initialized completely (sizes and type). For this, call with n=NULL and N=NULL, then a return value of m=0 indicates that the BV object is not ready for use yet.

See Also

BVSetSizes(), BVSetSizesFromVec()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVCreateVec.html0000644000175000017500000000356513107004621020707 0ustar jromanjroman BVCreateVec

slepc-3.7.4 2017-05-17

BVCreateVec

Creates a new Vec object with the same type and dimensions as the columns of the basis vectors object.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVCreateVec(BV bv,Vec *v)
Collective on BV

Input Parameter

bv  - the basis vectors context

Output Parameter

v  - the new vector

Note

The user is responsible of destroying the returned vector.

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetSignature.html0000644000175000017500000000407713107004621021446 0ustar jromanjroman BVGetSignature

slepc-3.7.4 2017-05-17

BVGetSignature

Retrieves the signature matrix from last orthogonalization.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetSignature(BV bv,Vec omega)
Not collective

Input Parameter

bv  - the basis vectors context

Output Parameter

omega  - a vector representing the diagonal of the signature matrix

Note

The signature matrix Omega = V'*B*V is relevant only for an indefinite B.

See Also

BVSetMatrix(), BVSetSignature()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDotVec.html0000644000175000017500000000552113107004621020224 0ustar jromanjroman BVDotVec

slepc-3.7.4 2017-05-17

BVDotVec

Computes multiple dot products of a vector against all the column vectors of a BV.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDotVec(BV X,Vec y,PetscScalar *m)
Collective on BV and Vec

Input Parameters

X  - basis vectors
y  - a vector

Output Parameter

m  - an array where the result must be placed

Notes

This is analogue to VecMDot(), but using BV to represent a collection of vectors. The result is m = X^H*y, so m_i is equal to x_j^H y. Note that here X is transposed as opposed to BVDot().

If a non-standard inner product has been specified with BVSetMatrix(), then the result is m = X^H*B*y.

The length of array m must be equal to the number of active columns of X minus the number of leading columns, i.e. the first entry of m is the product of the first non-leading column with y.

See Also

BVDot(), BVDotColumn(), BVSetActiveColumns(), BVSetMatrix()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVDotVecBegin.html0000644000175000017500000000410613107004621021167 0ustar jromanjroman BVDotVecBegin

slepc-3.7.4 2017-05-17

BVDotVecBegin

Starts a split phase dot product computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVDotVecBegin(BV X,Vec y,PetscScalar *m)

Input Parameters

X  - basis vectors
y  - a vector
m  - an array where the result will go (can be NULL)

Note

Each call to BVDotVecBegin() should be paired with a call to BVDotVecEnd().

See Also

BVDotVecEnd(), BVDotVec()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVNormVec.html0000644000175000017500000000512713107004621020413 0ustar jromanjroman BVNormVec

slepc-3.7.4 2017-05-17

BVNormVec

Computes the norm of a given vector.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVNormVec(BV bv,Vec v,NormType type,PetscReal *val)
Collective on BV

Input Parameters

bv  - basis vectors
v  - the vector
type  - the norm type

Output Parameter

val  - the norm

Notes

This is the analogue of BVNormColumn() but for a vector that is not in the BV. If a non-standard inner product has been specified with BVSetMatrix(), then the returned value is sqrt(v'*B*v), where B is the inner product matrix (argument 'type' is ignored). Otherwise, VecNorm() is called.

See Also

BVNorm(), BVNormColumn(), BVSetMatrix()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVSetFromOptions.html0000644000175000017500000000305313107004621021771 0ustar jromanjroman BVSetFromOptions

slepc-3.7.4 2017-05-17

BVSetFromOptions

Sets BV options from the options database.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVSetFromOptions(BV bv)
Collective on BV

Input Parameter

bv  - the basis vectors context

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVMultInPlace.html0000644000175000017500000000537113107004621021220 0ustar jromanjroman BVMultInPlace

slepc-3.7.4 2017-05-17

BVMultInPlace

Update a set of vectors as V(:,s:e-1) = V*Q(:,s:e-1).

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVMultInPlace(BV V,Mat Q,PetscInt s,PetscInt e)
Logically Collective on BV

Input Parameters

Q  - a sequential dense matrix
s  - first column of V to be overwritten
e  - first column of V not to be overwritten

Input/Output Parameter

V  - basis vectors

Notes

The matrix Q must be a sequential dense Mat, with all entries equal on all processes (otherwise each process will compute a different update).

This function computes V(:,s:e-1) = V*Q(:,s:e-1), that is, given a set of vectors V, columns from s to e-1 are overwritten with columns from s to e-1 of the matrix-matrix product V*Q. Only columns s to e-1 of Q are referenced.

See Also

BVMult(), BVMultVec(), BVMultInPlaceTranspose(), BVSetActiveColumns()

Location: src/sys/classes/bv/interface/bvops.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVNormVecBegin.html0000644000175000017500000000425213107004621021356 0ustar jromanjroman BVNormVecBegin

slepc-3.7.4 2017-05-17

BVNormVecBegin

Starts a split phase norm computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVNormVecBegin(BV bv,Vec v,NormType type,PetscReal *val)

Input Parameters

bv  - basis vectors
v  - the vector
type  - the norm type
val  - the norm

Note

Each call to BVNormVecBegin() should be paired with a call to BVNormVecEnd().

See Also

BVNormVecEnd(), BVNormVec()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVOrthogRefineType.html0000644000175000017500000000343413107004621022276 0ustar jromanjroman BVOrthogRefineType

slepc-3.7.4 2017-05-17

BVOrthogRefineType

Determines what type of refinement to use during orthogonalization of vectors

Synopsis

typedef enum { BV_ORTHOG_REFINE_IFNEEDED,
               BV_ORTHOG_REFINE_NEVER,
               BV_ORTHOG_REFINE_ALWAYS } BVOrthogRefineType;

See Also

BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalizeColumn()

Location: src/sys/classes/bv/../../../../include/slepcbv.h
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVGetColumn.html0000644000175000017500000000551113107004621020734 0ustar jromanjroman BVGetColumn

slepc-3.7.4 2017-05-17

BVGetColumn

Returns a Vec object that contains the entries of the requested column of the basis vectors object.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVGetColumn(BV bv,PetscInt j,Vec *v)
Logically Collective on BV

Input Parameters

bv  - the basis vectors context
j  - the index of the requested column

Output Parameter

v  - vector containing the jth column

Notes

The returned Vec must be seen as a reference (not a copy) of the BV column, that is, modifying the Vec will change the BV entries as well.

The returned Vec must not be destroyed. BVRestoreColumn() must be called when it is no longer needed. At most, two columns can be fetched, that is, this function can only be called twice before the corresponding BVRestoreColumn() is invoked.

A negative index j selects the i-th constraint, where i=-j. Constraints should not be modified.

See Also

BVRestoreColumn(), BVInsertConstraints()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVCopyVec.html0000644000175000017500000000430313107004621020405 0ustar jromanjroman BVCopyVec

slepc-3.7.4 2017-05-17

BVCopyVec

Copies one of the columns of a basis vectors object into a Vec.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVCopyVec(BV V,PetscInt j,Vec w)
Logically Collective on BV

Input Parameter

V  - basis vectors context
j  - the column number to be copied

Output Parameter

w  - the copied column

Note

Both V and w must be distributed in the same manner; local copies are done.

See Also

BVCopy(), BVCopyColumn(), BVInsertVec()

Location: src/sys/classes/bv/interface/bvbasic.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/BV/BVNormVecEnd.html0000644000175000017500000000424213107004621021037 0ustar jromanjroman BVNormVecEnd

slepc-3.7.4 2017-05-17

BVNormVecEnd

Ends a split phase norm computation.

Synopsis

#include "slepcbv.h" 
PetscErrorCode BVNormVecEnd(BV bv,Vec v,NormType type,PetscReal *val)

Input Parameters

bv  - basis vectors
v  - the vector
type  - the norm type
val  - the norm

Note

Each call to BVNormVecBegin() should be paired with a call to BVNormVecEnd().

See Also

BVNormVecBegin(), BVNormVec()

Location: src/sys/classes/bv/interface/bvglobal.c
Index of all BV routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/0000755000175000017500000000000013107004621015713 5ustar jromanjromanslepc-3.7.4/docs/manualpages/FN/FNRationalGetNumerator.html0000644000175000017500000000461413107004621023140 0ustar jromanjroman FNRationalGetNumerator

slepc-3.7.4 2017-05-17

FNRationalGetNumerator

Gets the parameters that define the numerator of the rational function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNRationalGetNumerator(FN fn,PetscInt *np,PetscScalar *pcoeff[])
Not Collective

Input Parameter

fn  - the math function context

Output Parameters

np  - number of coefficients
pcoeff  - coefficients (array of scalar values, length nq)

Notes

The values passed by user with FNRationalSetNumerator() are returned (or null pointers otherwise). The pcoeff array should be freed by the user when no longer needed.

See Also

FNRationalSetNumerator()

Location: src/sys/classes/fn/impls/rational/fnrational.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNDestroy.html0000644000175000017500000000417413107004621020464 0ustar jromanjroman FNDestroy

slepc-3.7.4 2017-05-17

FNDestroy

Destroys FN context that was created with FNCreate().

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNDestroy(FN *fn)
Collective on FN

Input Parameter

fn  - the math function context

See Also

FNCreate()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/FN/FNInitializePackage.html0000644000175000017500000000315213107004621022403 0ustar jromanjroman FNInitializePackage
slepc-3.7.4 2017-05-17

FNInitializePackage

This function initializes everything in the FN package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to FNCreate() when using static libraries.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNInitializePackage(void)

See Also

SlepcInitialize()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNCombineGetChildren.html0000644000175000017500000000435513107004621022521 0ustar jromanjroman FNCombineGetChildren

slepc-3.7.4 2017-05-17

FNCombineGetChildren

Gets the two child functions that constitute this combined function, and the way they are combined.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNCombineGetChildren(FN fn,FNCombineType *comb,FN *f1,FN *f2)
Not Collective

Input Parameter

fn  - the math function context

Output Parameters

comb  - how to combine the functions (addition, multiplication, division or composition)
f1  - first function
f2  - second function

See Also

FNCombineSetChildren()

Location: src/sys/classes/fn/impls/combine/fncombine.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNPhiGetIndex.html0000644000175000017500000000345413107004621021203 0ustar jromanjroman FNPhiGetIndex

slepc-3.7.4 2017-05-17

FNPhiGetIndex

Gets the index of the phi-function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNPhiGetIndex(FN fn,PetscInt *k)
Not Collective

Input Parameter

fn  - the math function context

Output Parameter

k  - the index

See Also

FNPhiSetIndex()

Location: src/sys/classes/fn/impls/phi/fnphi.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNEvaluateFunctionMatVec.html0000644000175000017500000000471413107004621023407 0ustar jromanjroman FNEvaluateFunctionMatVec

slepc-3.7.4 2017-05-17

FNEvaluateFunctionMatVec

Computes the first column of the matrix f(A) for a given matrix A.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNEvaluateFunctionMatVec(FN fn,Mat A,Vec v)
Logically Collective on FN

Input Parameters

fn  - the math function context
A  - matrix on which the function must be evaluated

Output Parameter

v  - vector to hold the first column of f(A)

Notes

This operation is similar to FNEvaluateFunctionMat() but returns only the first column of f(A), hence saving computations in most cases.

See Also

FNEvaluateFunction(), FNEvaluateFunctionMat()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNSetFromOptions.html0000644000175000017500000000323013107004621021756 0ustar jromanjroman FNSetFromOptions

slepc-3.7.4 2017-05-17

FNSetFromOptions

Sets FN options from the options database.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNSetFromOptions(FN fn)
Collective on FN

Input Parameters

fn  - the math function context

Notes

To see all options, run your program with the -help option.

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNGetScale.html0000644000175000017500000000372313107004621020521 0ustar jromanjroman FNGetScale

slepc-3.7.4 2017-05-17

FNGetScale

Gets the scaling parameters that define the matematical function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNGetScale(FN fn,PetscScalar *alpha,PetscScalar *beta)
Not Collective

Input Parameter

fn  - the math function context

Output Parameters

alpha  - inner scaling (argument)
beta  - outer scaling (result)

See Also

FNSetScale()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNCombineSetChildren.html0000644000175000017500000000446513107004621022537 0ustar jromanjroman FNCombineSetChildren

slepc-3.7.4 2017-05-17

FNCombineSetChildren

Sets the two child functions that constitute this combined function, and the way they must be combined.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNCombineSetChildren(FN fn,FNCombineType comb,FN f1,FN f2)
Logically Collective on FN

Input Parameters

fn  - the math function context
comb  - how to combine the functions (addition, multiplication, division or composition)
f1  - first function
f2  - second function

See Also

FNCombineGetChildren()

Location: src/sys/classes/fn/impls/combine/fncombine.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/FN/FNPhiSetIndex.html0000644000175000017500000000370013107004621021211 0ustar jromanjroman FNPhiSetIndex
slepc-3.7.4 2017-05-17

FNPhiSetIndex

Sets the index of the phi-function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNPhiSetIndex(FN fn,PetscInt k)
Logically Collective on FN

Input Parameters

fn  - the math function context
k  - the index

Notes

The phi-functions are defined as follows. The default is k=1.
      phi_0(x) = exp(x)
      phi_1(x) = (exp(x)-1)/x
      phi_k(x) = (phi_{k-1}(x)-1/(k-1)!)/x

See Also

FNPhiGetIndex()

Location: src/sys/classes/fn/impls/phi/fnphi.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNGetType.html0000644000175000017500000000356213107004621020414 0ustar jromanjroman FNGetType

slepc-3.7.4 2017-05-17

FNGetType

Gets the FN type name (as a string) from the FN context.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNGetType(FN fn,FNType *type)
Not Collective

Input Parameter

fn  - the math function context

Output Parameter

name  - name of the math function

See Also

FNSetType()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNSetType.html0000644000175000017500000000511213107004621020421 0ustar jromanjroman FNSetType

slepc-3.7.4 2017-05-17

FNSetType

Selects the type for the FN object.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNSetType(FN fn,FNType type)
Logically Collective on FN

Input Parameter

fn  - the math function context
type  - a known type

Notes

The default is FNRATIONAL, which includes polynomials as a particular case as well as simple functions such as f(x)=x and f(x)=constant.

See Also

FNGetType()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
src/mfn/examples/tutorials/ex23.c.html
src/mfn/examples/tutorials/ex26.c.html
slepc-3.7.4/docs/manualpages/FN/FNSetOptionsPrefix.html0000644000175000017500000000416313107004621022316 0ustar jromanjroman FNSetOptionsPrefix
slepc-3.7.4 2017-05-17

FNSetOptionsPrefix

Sets the prefix used for searching for all FN options in the database.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNSetOptionsPrefix(FN fn,const char *prefix)
Logically Collective on FN

Input Parameters

fn  - the math function context
prefix  - the prefix string to prepend to all FN option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

FNAppendOptionsPrefix()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNType.html0000644000175000017500000000306613107004621017753 0ustar jromanjroman FNType

slepc-3.7.4 2017-05-17

FNType

String with the name of the mathematical function.

Synopsis

typedef const char* FNType;
#define FNCOMBINE  "combine"
#define FNRATIONAL "rational"
#define FNEXP      "exp"
#define FNLOG      "log"
#define FNPHI      "phi"
#define FNSQRT     "sqrt"
#define FNINVSQRT  "invsqrt"

See Also

FNSetType(), FN

Location: src/sys/classes/fn/../../../../include/slepcfn.h
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNGetOptionsPrefix.html0000644000175000017500000000430713107004621022302 0ustar jromanjroman FNGetOptionsPrefix

slepc-3.7.4 2017-05-17

FNGetOptionsPrefix

Gets the prefix used for searching for all FN options in the database.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNGetOptionsPrefix(FN fn,const char *prefix[])
Not Collective

Input Parameters

fn  - the math function context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

FNSetOptionsPrefix(), FNAppendOptionsPrefix()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNEvaluateDerivative.html0000644000175000017500000000435513107004621022625 0ustar jromanjroman FNEvaluateDerivative

slepc-3.7.4 2017-05-17

FNEvaluateDerivative

Computes the value of the derivative f'(x) for a given x.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNEvaluateDerivative(FN fn,PetscScalar x,PetscScalar *y)
Logically Collective on FN

Input Parameters

fn  - the math function context
x  - the value where the derivative must be evaluated

Output Parameter

y  - the result of f'(x)

Note

Scaling factors are taken into account, so the actual derivative evaluation will return alpha*beta*f'(alpha*x).

See Also

FNEvaluateFunction()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNCreate.html0000644000175000017500000000451713107004621020237 0ustar jromanjroman FNCreate

slepc-3.7.4 2017-05-17

FNCreate

Creates an FN context.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNCreate(MPI_Comm comm,FN *newfn)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

newfn  - location to put the FN context

See Also

FNDestroy(), FN

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/FN/FNView.html0000644000175000017500000000440213107004621017737 0ustar jromanjroman FNView
slepc-3.7.4 2017-05-17

FNView

Prints the FN data structure.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNView(FN fn,PetscViewer viewer)
Collective on FN

Input Parameters

fn  - the math function context
viewer  - optional visualization context

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNRationalGetDenominator.html0000644000175000017500000000464613107004621023450 0ustar jromanjroman FNRationalGetDenominator

slepc-3.7.4 2017-05-17

FNRationalGetDenominator

Gets the parameters that define the denominator of the rational function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNRationalGetDenominator(FN fn,PetscInt *nq,PetscScalar *qcoeff[])
Not Collective

Input Parameter

fn  - the math function context

Output Parameters

nq  - number of coefficients
qcoeff  - coefficients (array of scalar values, length nq)

Notes

The values passed by user with FNRationalSetDenominator() are returned (or null pointers otherwise). The qcoeff array should be freed by the user when no longer needed.

See Also

FNRationalSetDenominator()

Location: src/sys/classes/fn/impls/rational/fnrational.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNSetScale.html0000644000175000017500000000555113107004621020536 0ustar jromanjroman FNSetScale

slepc-3.7.4 2017-05-17

FNSetScale

Sets the scaling parameters that define the matematical function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNSetScale(FN fn,PetscScalar alpha,PetscScalar beta)
Logically Collective on FN

Input Parameters

fn  - the math function context
alpha  - inner scaling (argument)
beta  - outer scaling (result)

Notes

Given a function f(x) specified by the FN type, the scaling parameters can be used to realize the function beta*f(alpha*x). So when these values are given, the procedure for function evaluation will first multiply the argument by alpha, then evaluate the function itself, and finally scale the result by beta. Likewise, these values are also considered when evaluating the derivative.

If you want to provide only one of the two scaling factors, set the other one to 1.0.

See Also

FNGetScale(), FNEvaluateFunction()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex22.c.html
src/nep/examples/nlevp/gun.c.html
src/mfn/examples/tutorials/ex23.c.html
slepc-3.7.4/docs/manualpages/FN/FNEvaluateFunctionMat.html0000644000175000017500000000567213107004621022755 0ustar jromanjroman FNEvaluateFunctionMat
slepc-3.7.4 2017-05-17

FNEvaluateFunctionMat

Computes the value of the function f(A) for a given matrix A, where the result is also a matrix.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNEvaluateFunctionMat(FN fn,Mat A,Mat B)
Logically Collective on FN

Input Parameters

fn  - the math function context
A  - matrix on which the function must be evaluated

Output Parameter

B  - (optional) matrix resulting from evaluating f(A)

Notes

Matrix A must be a square sequential dense Mat, with all entries equal on all processes (otherwise each process will compute different results). If matrix B is provided, it must also be a square sequential dense Mat, and both matrices must have the same dimensions. If B is NULL (or B=A) then the function will perform an in-place computation, overwriting A with f(A).

If A is known to be real symmetric or complex Hermitian then it is recommended to set the appropriate flag with MatSetOption(), so that a different algorithm that exploits symmetry is used.

Scaling factors are taken into account, so the actual function evaluation will return beta*f(alpha*A).

See Also

FNEvaluateFunction(), FNEvaluateFunctionMatVec()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNRegisterAll.html0000644000175000017500000000243713107004621021250 0ustar jromanjroman FNRegisterAll

slepc-3.7.4 2017-05-17

FNRegisterAll

Registers all of the math functions in the FN package.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNRegisterAll(void)
Not Collective

Location: src/sys/classes/fn/interface/fnregis.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/index.html0000644000175000017500000000762513107004621017722 0ustar jromanjroman Mathematical Function - FN

slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

Beginner - Basic usage
FN FNDestroy FNType
FNCreate FNSetFromOptions FNView
Intermediate - Setting options for algorithms and data structures
FNCombineGetChildren FNGetType FNRationalSetDenominator
FNCombineSetChildren FNPhiGetIndex FNRationalSetNumerator
FNEvaluateDerivative FNPhiSetIndex FNSetScale
FNEvaluateFunction FNRationalGetDenominator FNSetType
FNGetScale FNRationalGetNumerator
Advanced - Setting more advanced options and customization
FNAppendOptionsPrefix FNEvaluateFunctionMatVec FNRegisterAll
FNCombineType FNGetOptionsPrefix FNSetOptionsPrefix
FNEvaluateFunctionMat FNRegister
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
FNDuplicate FNFinalizePackage FNInitializePackage
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/FN/FN.html0000644000175000017500000000245113107004621017106 0ustar jromanjroman FN

slepc-3.7.4 2017-05-17

FN

Abstraction of a mathematical function.

Synopsis

typedef struct _p_FN* FN;

See Also

FNCreate()

Location: src/sys/classes/fn/../../../../include/slepcfn.h
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNRegister.html0000644000175000017500000000373713107004621020623 0ustar jromanjroman FNRegister

slepc-3.7.4 2017-05-17

FNRegister

Adds a mathematical function to the FN package.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNRegister(const char *name,PetscErrorCode (*function)(FN))
Not collective

Input Parameters

name  - name of a new user-defined FN
function  - routine to create context

Notes

FNRegister() may be called multiple times to add several user-defined functions.

See Also

FNRegisterAll()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNFinalizePackage.html0000644000175000017500000000302013107004621022035 0ustar jromanjroman FNFinalizePackage

slepc-3.7.4 2017-05-17

FNFinalizePackage

This function destroys everything in the Slepc interface to the FN package. It is called from SlepcFinalize().

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNRationalSetNumerator.html0000644000175000017500000000575413107004621023162 0ustar jromanjroman FNRationalSetNumerator

slepc-3.7.4 2017-05-17

FNRationalSetNumerator

Sets the parameters defining the numerator of the rational function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNRationalSetNumerator(FN fn,PetscInt np,PetscScalar *pcoeff)
Logically Collective on FN

Input Parameters

fn  - the math function context
np  - number of coefficients
pcoeff  - coefficients (array of scalar values)

Notes

Let the rational function r(x) = p(x)/q(x), where p(x) and q(x) are polynomials. This function provides the coefficients of the numerator p(x). Hence, p(x) is of degree np-1. If np is zero, then the numerator is assumed to be p(x)=1.

In polynomials, high order coefficients are stored in the first positions of the array, e.g. to represent x^2-3 use {1,0,-3}.

See Also

FNRationalSetDenominator(), FNRationalGetNumerator()

Location: src/sys/classes/fn/impls/rational/fnrational.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/tutorials/ex22.c.html
src/nep/examples/tutorials/ex27.c.html
src/nep/examples/nlevp/loaded_string.c.html
src/nep/examples/nlevp/gun.c.html
slepc-3.7.4/docs/manualpages/FN/FNEvaluateFunction.html0000644000175000017500000000456313107004621022311 0ustar jromanjroman FNEvaluateFunction
slepc-3.7.4 2017-05-17

FNEvaluateFunction

Computes the value of the function f(x) for a given x.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNEvaluateFunction(FN fn,PetscScalar x,PetscScalar *y)
Logically Collective on FN

Input Parameters

fn  - the math function context
x  - the value where the function must be evaluated

Output Parameter

y  - the result of f(x)

Note

Scaling factors are taken into account, so the actual function evaluation will return beta*f(alpha*x).

See Also

FNEvaluateDerivative(), FNEvaluateFunctionMat(), FNSetScale()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNAppendOptionsPrefix.html0000644000175000017500000000420213107004621022764 0ustar jromanjroman FNAppendOptionsPrefix

slepc-3.7.4 2017-05-17

FNAppendOptionsPrefix

Appends to the prefix used for searching for all FN options in the database.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNAppendOptionsPrefix(FN fn,const char *prefix)
Logically Collective on FN

Input Parameters

fn  - the math function context
prefix  - the prefix string to prepend to all FN option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

FNSetOptionsPrefix()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNRationalSetDenominator.html0000644000175000017500000000533313107004621023456 0ustar jromanjroman FNRationalSetDenominator

slepc-3.7.4 2017-05-17

FNRationalSetDenominator

Sets the parameters defining the denominator of the rational function.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNRationalSetDenominator(FN fn,PetscInt nq,PetscScalar *qcoeff)
Logically Collective on FN

Input Parameters

fn  - the math function context
nq  - number of coefficients
qcoeff  - coefficients (array of scalar values)

Notes

Let the rational function r(x) = p(x)/q(x), where p(x) and q(x) are polynomials. This function provides the coefficients of the denominator q(x). Hence, q(x) is of degree nq-1. If nq is zero, then the function is assumed to be polynomial, r(x) = p(x).

In polynomials, high order coefficients are stored in the first positions of the array, e.g. to represent x^2-3 use {1,0,-3}.

See Also

FNRationalSetNumerator(), FNRationalGetDenominator()

Location: src/sys/classes/fn/impls/rational/fnrational.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/nep/examples/nlevp/loaded_string.c.html
slepc-3.7.4/docs/manualpages/FN/FNDuplicate.html0000644000175000017500000000427413107004621020746 0ustar jromanjroman FNDuplicate
slepc-3.7.4 2017-05-17

FNDuplicate

Duplicates a math function, copying all parameters, possibly with a different communicator.

Synopsis

#include "slepcfn.h" 
PetscErrorCode FNDuplicate(FN fn,MPI_Comm comm,FN *newfn)
Collective on FN

Input Parameters

fn  - the math function context
comm  - MPI communicator

Output Parameter

newfn  - location to put the new FN context

Note

In order to use the same MPI communicator as in the original object, use PetscObjectComm((PetscObject)fn).

See Also

FNCreate()

Location: src/sys/classes/fn/interface/fnbasic.c
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/FN/FNCombineType.html0000644000175000017500000000303213107004621021241 0ustar jromanjroman FNCombineType

slepc-3.7.4 2017-05-17

FNCombineType

Determines how two functions are combined

Synopsis

typedef enum { FN_COMBINE_ADD,
               FN_COMBINE_MULTIPLY,
               FN_COMBINE_DIVIDE,
               FN_COMBINE_COMPOSE } FNCombineType;

See Also

FNCombineSetChildren()

Location: src/sys/classes/fn/../../../../include/slepcfn.h
Index of all FN routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/0000755000175000017500000000000013107004621016226 5ustar jromanjromanslepc-3.7.4/docs/manualpages/sys/SlepcVecPoolRestoreVecs.html0000644000175000017500000000367713107004621023654 0ustar jromanjroman SlepcVecPoolRestoreVecs

slepc-3.7.4 2017-05-17

SlepcVecPoolRestoreVecs

Get back an array of Vec previously returned by SlepcVecPoolGetVecs().

Synopsis

#include "slepcvec.h" 
PetscErrorCode SlepcVecPoolRestoreVecs(VecPool p,PetscInt n,Vec **vecs)
Collective on VecPool

Input Parameters

pool  - pool of Vec.
n  - number of vectors.
vecs  - vectors

See Also

SlepcVecPoolGetVecs()

Location: src/sys/vec/pool.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcInitializeNoArguments.html0000644000175000017500000000313013107004621024364 0ustar jromanjroman SlepcInitializeNoArguments

slepc-3.7.4 2017-05-17

SlepcInitializeNoArguments

Calls SlepcInitialize() from C/C++ without the command line arguments.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcInitializeNoArguments(void)
Collective

See Also

SlepcInitialize(), SlepcInitializeFortran()

Location: src/sys/slepcinit.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcSCCompare.html0000644000175000017500000000512213107004621021717 0ustar jromanjroman SlepcSCCompare

slepc-3.7.4 2017-05-17

SlepcSCCompare

Compares two (possibly complex) values according to a certain criterion.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcSCCompare(SlepcSC sc,PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res)
Not Collective

Input Parameters

sc  - the sorting criterion context
ar  - real part of the 1st value
ai  - imaginary part of the 1st value
br  - real part of the 2nd value
bi  - imaginary part of the 2nd value

Output Parameter

res  - result of comparison

Notes

Returns an integer less than, equal to, or greater than zero if the first value is considered to be respectively less than, equal to, or greater than the second one.

See Also

SlepcSortEigenvalues(), SlepcSC

Location: src/sys/slepcsc.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcVecPoolCreate.html0000644000175000017500000000404013107004621022574 0ustar jromanjroman SlepcVecPoolCreate

slepc-3.7.4 2017-05-17

SlepcVecPoolCreate

Create a pool of Vec.

Synopsis

#include "slepcvec.h" 
PetscErrorCode SlepcVecPoolCreate(Vec v,PetscInt init_size,VecPool *p)
Collective on VecPool

Input Parameters

v  - template vector.
init_size  - first guess of maximum vectors.

Output Parameter

pool  - the pool context.

See Also

SlepcVecPoolGetVecs(), SlepcVecPoolDestroy()

Location: src/sys/vec/pool.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcFinalize.html0000644000175000017500000000512513107004621021647 0ustar jromanjroman SlepcFinalize

slepc-3.7.4 2017-05-17

SlepcFinalize

Checks for options to be called at the conclusion of the SLEPc program and calls PetscFinalize().

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcFinalize(void)
Collective on PETSC_COMM_WORLD

See Also

SlepcInitialize(), PetscFinalize()

Location: src/sys/slepcinit.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/sys/SlepcConvMonitorCreate.html0000644000175000017500000000477213107004621023516 0ustar jromanjroman SlepcConvMonitorCreate
slepc-3.7.4 2017-05-17

SlepcConvMonitorCreate

Creates a SlepcConvMonitor context.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcConvMonitorCreate(PetscViewer viewer,PetscViewerFormat format,SlepcConvMonitor *ctx)
Collective on PetscViewer

Input Parameters

viewer  - the viewer where the monitor must send data
format  - the format

Output Parameter

ctx  - the created context

Notes

The created context is used for EPS, SVD, PEP, and NEP monitor functions that just print the iteration numbers at which convergence takes place (XXXMonitorConverged).

This function increases the reference count of the viewer so you can destroy the viewer object after this call.

See Also

SlepcConvMonitorDestroy()

Location: src/sys/slepcutil.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcSortEigenvalues.html0000644000175000017500000000511313107004621023222 0ustar jromanjroman SlepcSortEigenvalues

slepc-3.7.4 2017-05-17

SlepcSortEigenvalues

Sorts a list of eigenvalues according to the sorting criterion specified in a SlepcSC context.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcSortEigenvalues(SlepcSC sc,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm)
Not Collective

Input Parameters

sc  - the sorting criterion context
n  - number of eigenvalues in the list
eigr  - pointer to the array containing the eigenvalues
eigi  - imaginary part of the eigenvalues (only when using real numbers)

Input/Output Parameter

perm  - permutation array. Must be initialized to 0:n-1 on input.

Note

The result is a list of indices in the original eigenvalue array corresponding to the first n eigenvalues sorted in the specified criterion.

See Also

SlepcSCCompare(), SlepcSC

Location: src/sys/slepcsc.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/VecCreateCompWithVecs.html0000644000175000017500000000416013107004621023252 0ustar jromanjroman VecCreateCompWithVecs

slepc-3.7.4 2017-05-17

VecCreateCompWithVecs

Creates a new vector containing several subvectors, each stored separately, from an array of Vecs.

Synopsis

#include "slepcvec.h" 
PetscErrorCode VecCreateCompWithVecs(Vec *x,PetscInt n,Vec Vparent,Vec *V)
Collective on Vec

Input Parameters

x  - array of Vecs
n  - number of child vectors
Vparent  - (optional) template vector

Output Parameter

V  - new vector

See Also

VecCreateComp()

Location: src/sys/vec/veccomp.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcVecPoolDestroy.html0000644000175000017500000000325713107004621023033 0ustar jromanjroman SlepcVecPoolDestroy

slepc-3.7.4 2017-05-17

SlepcVecPoolDestroy

Destroy the pool of Vec.

Synopsis

#include "slepcvec.h" 
PetscErrorCode SlepcVecPoolDestroy(VecPool *p)
Collective on VecPool

Input Parameters

pool  - pool of Vec.

See Also

SlepcVecPoolGetVecs(), SlepcVecPoolCreate()

Location: src/sys/vec/pool.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcVecNormalize.html0000644000175000017500000000412013107004621022476 0ustar jromanjroman SlepcVecNormalize

slepc-3.7.4 2017-05-17

SlepcVecNormalize

Normalizes a possibly complex vector by the 2-norm.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcVecNormalize(Vec xr,Vec xi,PetscBool iscomplex,PetscReal *norm)
Collective on Vec

Input parameters

xr  - the real part of the vector (overwritten on output)
xi  - the imaginary part of the vector (not referenced if iscomplex is false)
iscomplex  - a flag indicating if the vector is complex

Output parameter

norm  - the vector norm before normalization (can be set to NULL)

Location: src/sys/slepcutil.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcInitializeFortran.html0000644000175000017500000000422113107004621023537 0ustar jromanjroman SlepcInitializeFortran

slepc-3.7.4 2017-05-17

SlepcInitializeFortran

Routine that should be called from C after the call to SlepcInitialize() if one is using a C main program that calls Fortran routines that in turn call SLEPc routines.

Synopsis

PetscErrorCode SlepcInitializeFortran(void)
Collective on PETSC_COMM_WORLD

Notes

SlepcInitializeFortran() initializes some of the default SLEPc variables for use in Fortran if a user's main program is written in C. SlepcInitializeFortran() is NOT needed if a user's main program is written in Fortran; in this case, just calling SlepcInitialize() in the main (Fortran) program is sufficient.

See Also

SlepcInitialize()

Location: src/sys/ftn-custom/zslepc_startf.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcConvMonitorDestroy.html0000644000175000017500000000326713107004621023742 0ustar jromanjroman SlepcConvMonitorDestroy

slepc-3.7.4 2017-05-17

SlepcConvMonitorDestroy

Destroys a SlepcConvMonitor context.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor *ctx)
Collective on PetscViewer

Input Parameters

ctx  - the SlepcConvMonitor context to be destroyed.

See Also

SlepcConvMonitorCreate()

Location: src/sys/slepcutil.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/index.html0000644000175000017500000000742013107004621020226 0ustar jromanjroman SLEPc System Routines

slepc-3.7.4 2017-05-17

SLEPc System routines

SLEPc provides a variety of "system" level routines. These routines are generally tools used by other SLEPc routines and are not intended for application programmers (except the basic SlepcInitialize() / SlepcFinalize()).

Useful tools for application programmers can be found in PETSc's system routines, including parallel file access, synchronized printing to screen, and many other programming aids.

Beginner - Basic usage
SlepcFinalize SlepcInitializeFortran
SlepcInitialize SlepcInitialized
Intermediate - Setting options for algorithms and data structures
SlepcGetVersion
Advanced - Setting more advanced options and customization
SlepcInitializeNoArguments
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
SlepcCheckOrthogonality SlepcSNPrintfScalar SlepcVecPoolRestoreVecs
SlepcConvMonitorCreate SlepcSortEigenvalues VecCompGetSubVecs
SlepcConvMonitorDestroy SlepcVecNormalize VecCompSetSubVecs
SlepcMatConvertSeqDense SlepcVecPoolCreate VecCreateComp
SlepcMatTile SlepcVecPoolDestroy VecCreateCompWithVecs
SlepcSCCompare SlepcVecPoolGetVecs
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/sys/SlepcCheckOrthogonality.html0000644000175000017500000000556313107004621023714 0ustar jromanjroman SlepcCheckOrthogonality

slepc-3.7.4 2017-05-17

SlepcCheckOrthogonality

Checks (or prints) the level of orthogonality of a set of vectors.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcCheckOrthogonality(Vec *V,PetscInt nv,Vec *W,PetscInt nw,Mat B,PetscViewer viewer,PetscReal *lev)
Collective on Vec

Input parameters

V  - a set of vectors
nv  - number of V vectors
W  - an alternative set of vectors (optional)
nw  - number of W vectors
B  - matrix defining the inner product (optional)
viewer  - optional visualization context

Output parameter

lev  - level of orthogonality (optional)

Notes

This function computes W'*V and prints the result. It is intended to check the level of bi-orthogonality of the vectors in the two sets. If W is equal to NULL then V is used, thus checking the orthogonality of the V vectors.

If matrix B is provided then the check uses the B-inner product, W'*B*V.

If lev is not NULL, it will contain the maximum entry of matrix W'*V - I (in absolute value). Otherwise, the matrix W'*V is printed.

Location: src/sys/slepcutil.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/VecCompGetSubVecs.html0000644000175000017500000000371413107004621022410 0ustar jromanjroman VecCompGetSubVecs

slepc-3.7.4 2017-05-17

VecCompGetSubVecs

Returns the entire array of vectors defining a compound vector.

Synopsis

#include "slepcvec.h" 
PetscErrorCode VecCompGetSubVecs(Vec win,PetscInt *n,const Vec **x)
Collective on Vec

Input Parameter

win  - compound vector

Output Parameters

n  - number of child vectors
x  - array of child vectors

See Also

VecCreateComp()

Location: src/sys/vec/veccomp.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcMatTile.html0000644000175000017500000000547213107004621021452 0ustar jromanjroman SlepcMatTile

slepc-3.7.4 2017-05-17

SlepcMatTile

Explicitly build a matrix from four blocks, G = [ a*A b*B; c*C d*D ].

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcMatTile(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat *G)
Collective on Mat

Input parameters

A  - matrix for top-left block
a  - scaling factor for block A
B  - matrix for top-right block
b  - scaling factor for block B
C  - matrix for bottom-left block
c  - scaling factor for block C
D  - matrix for bottom-right block
d  - scaling factor for block D

Output parameter

G  - the resulting matrix

Notes

In the case of a parallel matrix, a permuted version of G is returned. The permutation is a perfect shuffle such that the local parts of A, B, C, D remain in the local part of G for the same process.

Matrix G must be destroyed by the user.

Location: src/sys/slepcutil.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcVecPoolGetVecs.html0000644000175000017500000000370213107004621022735 0ustar jromanjroman SlepcVecPoolGetVecs

slepc-3.7.4 2017-05-17

SlepcVecPoolGetVecs

Get an array of Vec from the pool.

Synopsis

#include "slepcvec.h" 
PetscErrorCode SlepcVecPoolGetVecs(VecPool p,PetscInt n,Vec **vecs)
Collective on VecPool

Input Parameters

pool  - pool of Vec.
n  - number of vectors.

Output Parameter

vecs  - vectors

See Also

SlepcVecPoolRestoreVecs()

Location: src/sys/vec/pool.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/VecCompSetSubVecs.html0000644000175000017500000000354713107004621022430 0ustar jromanjroman VecCompSetSubVecs

slepc-3.7.4 2017-05-17

VecCompSetSubVecs

Resets the number of subvectors defining a compound vector, of replaces the subvectors.

Synopsis

#include "slepcvec.h" 
PetscErrorCode VecCompSetSubVecs(Vec win,PetscInt n,Vec *x)
Collective on Vec

Input Parameters

win  - compound vector
n  - number of child vectors
x  - array of child vectors

See Also

VecCreateComp()

Location: src/sys/vec/veccomp.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/VecCreateComp.html0000644000175000017500000000532713107004621021603 0ustar jromanjroman VecCreateComp

slepc-3.7.4 2017-05-17

VecCreateComp

Creates a new vector containing several subvectors, each stored separately.

Synopsis

#include "slepcvec.h" 
PetscErrorCode VecCreateComp(MPI_Comm comm,PetscInt *Nx,PetscInt n,VecType t,Vec Vparent,Vec *V)
Collective on Vec

Input Parameters

comm  - communicator for the new Vec
Nx  - array of (initial) global sizes of child vectors
n  - number of child vectors
t  - type of the child vectors
Vparent  - (optional) template vector

Output Parameter

V  - new vector

Notes

This is similar to PETSc's VecNest but customized for SLEPc's needs. In particular, the number of child vectors can be modified dynamically, with VecCompSetSubVecs().

See Also

VecCreateCompWithVecs(), VecCompSetSubVecs()

Location: src/sys/vec/veccomp.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcMatConvertSeqDense.html0000644000175000017500000000325313107004621023620 0ustar jromanjroman SlepcMatConvertSeqDense

slepc-3.7.4 2017-05-17

SlepcMatConvertSeqDense

Converts a parallel matrix to another one in sequential dense format replicating the values in every processor.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcMatConvertSeqDense(Mat mat,Mat *newmat)
Collective on Mat

Input parameters

A  - the source matrix
B  - the target matrix

Location: src/sys/slepcutil.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcSNPrintfScalar.html0000644000175000017500000000447513107004621022746 0ustar jromanjroman SlepcSNPrintfScalar

slepc-3.7.4 2017-05-17

SlepcSNPrintfScalar

Prints a PetscScalar variable to a string of given length.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcSNPrintfScalar(char *str,size_t len,PetscScalar val,PetscBool exp)
Not Collective

Input Parameters

str  - the string to print to
len  - the length of str
val  - scalar value to be printed
exp  - to be used within an expression, print leading sign and parentheses in case of nonzero imaginary part

Location: src/sys/slepcutil.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex18.c.html
src/pep/examples/nlevp/acoustic_wave_1d.c.html
src/pep/examples/nlevp/acoustic_wave_2d.c.html
slepc-3.7.4/docs/manualpages/sys/SlepcInitialized.html0000644000175000017500000000271013107004621022350 0ustar jromanjroman SlepcInitialized
slepc-3.7.4 2017-05-17

SlepcInitialized

Determine whether SLEPc is initialized.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcInitialized(PetscBool *isInitialized)

See Also

SlepcInitialize(), SlepcInitializeFortran()

Location: src/sys/slepcinit.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcGetVersion.html0000644000175000017500000000340513107004621022172 0ustar jromanjroman SlepcGetVersion

slepc-3.7.4 2017-05-17

SlepcGetVersion

Gets the SLEPc version information in a string.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcGetVersion(char version[],size_t len)

Input Parameter

len  - length of the string

Output Parameter

version  - version string

Fortran Note

This routine is not supported in Fortran.

Location: src/sys/slepcinit.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/sys/SlepcInitialize.html0000644000175000017500000000714413107004621022212 0ustar jromanjroman SlepcInitialize

slepc-3.7.4 2017-05-17

SlepcInitialize

Initializes the SLEPc library. SlepcInitialize() calls PetscInitialize() if that has not been called yet, so this routine should always be called near the beginning of your program.

Synopsis

#include "slepcsys.h" 
PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[])
Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set

Input Parameters

argc  - count of number of command line arguments
args  - the command line arguments
file  - [optional] PETSc database file, defaults to ~username/.petscrc (use NULL for default)
help  - [optional] Help message to print, use NULL for no message

Fortran Note

Fortran syntax is very similar to that of PetscInitialize()

See Also

SlepcFinalize(), PetscInitialize()

Location: src/sys/slepcinit.c
Index of all sys routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex1.c.html
src/eps/examples/tutorials/ex2.c.html
src/eps/examples/tutorials/ex3.c.html
src/eps/examples/tutorials/ex4.c.html
src/eps/examples/tutorials/ex5.c.html
src/eps/examples/tutorials/ex7.c.html
src/eps/examples/tutorials/ex9.c.html
src/eps/examples/tutorials/ex10.c.html
src/eps/examples/tutorials/ex11.c.html
src/eps/examples/tutorials/ex12.c.html
src/eps/examples/tutorials/ex13.c.html
slepc-3.7.4/docs/manualpages/DS/0000755000175000017500000000000013107004621015716 5ustar jromanjromanslepc-3.7.4/docs/manualpages/DS/DSGetDimensions.html0000644000175000017500000000513413107004621021606 0ustar jromanjroman DSGetDimensions
slepc-3.7.4 2017-05-17

DSGetDimensions

Returns the current dimensions.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetDimensions(DS ds,PetscInt *n,PetscInt *m,PetscInt *l,PetscInt *k,PetscInt *t)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

n  - the current size
m  - the current column size (only for DSSVD)
l  - number of locked (inactive) leading columns
k  - intermediate dimension (e.g., position of arrow)
t  - truncated length

Note

The t parameter makes sense only if DSTruncate() has been called. Otherwise its value equals n.

See Also

DSSetDimensions(), DSTruncate()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetBlockSize.html0000644000175000017500000000334613107004621021402 0ustar jromanjroman DSSetBlockSize

slepc-3.7.4 2017-05-17

DSSetBlockSize

Sets the block size.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetBlockSize(DS ds,PetscInt bs)
Logically Collective on DS

Input Parameter

ds  - the direct solver context
bs  - the block size

See Also

DSGetBlockSize()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetExtraRow.html0000644000175000017500000000345013107004621021250 0ustar jromanjroman DSGetExtraRow

slepc-3.7.4 2017-05-17

DSGetExtraRow

Gets the extra row flag.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetExtraRow(DS ds,PetscBool *ext)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

ext  - the flag

See Also

DSSetExtraRow()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSNormalize.html0000644000175000017500000000430113107004621020771 0ustar jromanjroman DSNormalize

slepc-3.7.4 2017-05-17

DSNormalize

Normalize a column or all the columns of a matrix. Considers the case when the columns represent the real and the imaginary part of a vector.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSNormalize(DS ds,DSMatType mat,PetscInt col)
Logically Collective on DS

Input Parameter

ds  - the direct solver context
mat  - the matrix to be modified
col  - the column to normalize or -1 to normalize all of them

Notes

The columns are normalized with respect to the 2-norm.

If col and col+1 (or col-1 and col) represent the real and the imaginary part of a vector, both columns are scaled.

See Also

DSMatType

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DS.html0000644000175000017500000000271713107004621017121 0ustar jromanjroman DS

slepc-3.7.4 2017-05-17

DS

Direct solver (or dense system), to represent low-dimensional eigenproblems that must be solved within iterative solvers. This is an auxiliary object and is not normally needed by application programmers.

Synopsis

typedef struct _p_DS* DS;

See Also

DSCreate()

Location: src/sys/classes/ds/../../../../include/slepcds.h
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSReset.html0000644000175000017500000000314713107004621020122 0ustar jromanjroman DSReset

slepc-3.7.4 2017-05-17

DSReset

Resets the DS context to the initial state.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSReset(DS ds)
Collective on DS

Input Parameter

ds  - the direct solver context

See Also

DSDestroy()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetSlepcSC.html0000644000175000017500000000340513107004621021005 0ustar jromanjroman DSSetSlepcSC

slepc-3.7.4 2017-05-17

DSSetSlepcSC

Sets the sorting criterion context.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetSlepcSC(DS ds,SlepcSC sc)
Not Collective

Input Parameters

ds  - the direct solver context
sc  - a pointer to the sorting criterion context

See Also

DSGetSlepcSC(), DSSort()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSStateType.html0000644000175000017500000000276113107004621020763 0ustar jromanjroman DSStateType

slepc-3.7.4 2017-05-17

DSStateType

Indicates in which state the direct solver is

Synopsis

typedef enum { DS_STATE_RAW,
               DS_STATE_INTERMEDIATE,
               DS_STATE_CONDENSED,
               DS_STATE_TRUNCATED } DSStateType;

See Also

DSSetState()

Location: src/sys/classes/ds/../../../../include/slepcds.h
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSAppendOptionsPrefix.html0000644000175000017500000000420213107004621022772 0ustar jromanjroman DSAppendOptionsPrefix

slepc-3.7.4 2017-05-17

DSAppendOptionsPrefix

Appends to the prefix used for searching for all DS options in the database.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSAppendOptionsPrefix(DS ds,const char *prefix)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
prefix  - the prefix string to prepend to all DS option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

DSSetOptionsPrefix()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetRefined.html0000644000175000017500000000344513107004621021055 0ustar jromanjroman DSGetRefined

slepc-3.7.4 2017-05-17

DSGetRefined

Gets the refined vectors flag.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetRefined(DS ds,PetscBool *ref)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

ref  - the flag

See Also

DSSetRefined()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSRegister.html0000644000175000017500000000374213107004621020625 0ustar jromanjroman DSRegister

slepc-3.7.4 2017-05-17

DSRegister

Adds a direct solver to the DS package.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSRegister(const char *name,PetscErrorCode (*function)(DS))
Not collective

Input Parameters

name  - name of a new user-defined DS
routine_create  - routine to create context

Notes

DSRegister() may be called multiple times to add several user-defined direct solvers.

See Also

DSRegisterAll()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSFinalizePackage.html0000644000175000017500000000302013107004621022043 0ustar jromanjroman DSFinalizePackage

slepc-3.7.4 2017-05-17

DSFinalizePackage

This function destroys everything in the SLEPc interface to the DS package. It is called from SlepcFinalize().

Synopsis

#include "slepcds.h" 
PetscErrorCode DSFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSView.html0000644000175000017500000000456313107004621017755 0ustar jromanjroman DSView

slepc-3.7.4 2017-05-17

DSView

Prints the DS data structure.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSView(DS ds,PetscViewer viewer)
Collective on DS

Input Parameters

ds  - the direct solver context
viewer  - optional visualization context

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

See Also

DSViewMat()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSNEPSetFN.html0000644000175000017500000000453513107004621020364 0ustar jromanjroman DSNEPSetFN

slepc-3.7.4 2017-05-17

DSNEPSetFN

Sets a number of functions that define the nonlinear eigenproblem.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSNEPSetFN(DS ds,PetscInt n,FN fn[])
Collective on DS and FN

Input Parameters

ds  - the direct solver context
n  - number of functions
fn  - array of functions

Notes

The nonlinear eigenproblem is defined in terms of the split nonlinear operator T(lambda) = sum_i A_i*f_i(lambda).

This function must be called before DSAllocate(). Then DSAllocate() will allocate an extra matrix A_i per each function, that can be filled in the usual way.

See Also

DSNEPGetFN(), DSAllocate()

Location: src/sys/classes/ds/impls/nep/dsnep.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSTranslateHarmonic.html0000644000175000017500000000572513107004621022462 0ustar jromanjroman DSTranslateHarmonic

slepc-3.7.4 2017-05-17

DSTranslateHarmonic

Computes a translation of the dense system.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSTranslateHarmonic(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *g,PetscReal *gamma)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
tau  - the translation amount
beta  - last component of vector b
recover  - boolean flag to indicate whether to recover or not

Output Parameters

g  - the computed vector (optional)
gamma  - scale factor (optional)

Notes

This function is intended for use in the context of Krylov methods only. It computes a translation of a Krylov decomposition in order to extract eigenpair approximations by harmonic Rayleigh-Ritz. The matrix is updated as A + g*b' where g = (A-tau*eye(n))'\b and vector b is assumed to be beta*e_n^T.

The gamma factor is defined as sqrt(1+g'*g) and can be interpreted as the factor by which the residual of the Krylov decomposition is scaled.

If the recover flag is activated, the computed translation undoes the translation done previously. In that case, parameter tau is ignored.

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetLeadingDimension.html0000644000175000017500000000375213107004621022713 0ustar jromanjroman DSGetLeadingDimension

slepc-3.7.4 2017-05-17

DSGetLeadingDimension

Returns the leading dimension of the allocated matrices.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetLeadingDimension(DS ds,PetscInt *ld)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

ld  - leading dimension (maximum allowed dimension for the matrices)

See Also

DSAllocate(), DSSetDimensions()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetArray.html0000644000175000017500000000423313107004621020553 0ustar jromanjroman DSGetArray

slepc-3.7.4 2017-05-17

DSGetArray

Returns a pointer to one of the internal arrays used to represent matrices. You MUST call DSRestoreArray() when you no longer need to access the array.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetArray(DS ds,DSMatType m,PetscScalar *a[])
Not Collective

Input Parameters

ds  - the direct solver context
m  - the requested matrix

Output Parameter

a  - pointer to the values

See Also

DSRestoreArray(), DSGetArrayReal()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSCreate.html0000644000175000017500000000407513107004621020244 0ustar jromanjroman DSCreate

slepc-3.7.4 2017-05-17

DSCreate

Creates a DS context.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSCreate(MPI_Comm comm,DS *newds)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

newds  - location to put the DS context

Note

DS objects are not intended for normal users but only for advanced user that for instance implement their own solvers.

See Also

DSDestroy(), DS

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSTruncate.html0000644000175000017500000000410413107004621020617 0ustar jromanjroman DSTruncate

slepc-3.7.4 2017-05-17

DSTruncate

Truncates the system represented in the DS object.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSTruncate(DS ds,PetscInt n)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
n  - the new size

Note

The new size is set to n. In cases where the extra row is meaningful, the first n elements are kept as the extra row for the new system.

See Also

DSSetDimensions(), DSSetExtraRow(), DSStateType

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSPEPGetDegree.html0000644000175000017500000000347513107004621021244 0ustar jromanjroman DSPEPGetDegree

slepc-3.7.4 2017-05-17

DSPEPGetDegree

Returns the polynomial degree for a DSPEP.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSPEPGetDegree(DS ds,PetscInt *d)
Not collective

Input Parameter

ds  - the direct solver context

Output Parameters

d  - the degree

See Also

DSPEPSetDegree()

Location: src/sys/classes/ds/impls/pep/dspep.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetExtraRow.html0000644000175000017500000000440113107004621021261 0ustar jromanjroman DSSetExtraRow

slepc-3.7.4 2017-05-17

DSSetExtraRow

Sets a flag to indicate that the matrix has one extra row.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetExtraRow(DS ds,PetscBool ext)
Logically Collective on DS

Input Parameter

ds  - the direct solver context
ext  - a boolean flag

Notes

In Krylov methods it is useful that the matrix representing the direct solver has one extra row, i.e., has dimension (n+1) x n. If this flag is activated, all transformations applied to the right of the matrix also affect this additional row. In that case, (n+1) must be less or equal than the leading dimension.

The default is PETSC_FALSE.

See Also

DSSolve(), DSAllocate(), DSGetExtraRow()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetIdentity.html0000644000175000017500000000325213107004621021302 0ustar jromanjroman DSSetIdentity

slepc-3.7.4 2017-05-17

DSSetIdentity

Copy the identity (a diagonal matrix with ones) on the active part of a matrix.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetIdentity(DS ds,DSMatType mat)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
mat  - the matrix to modify

Location: src/sys/classes/ds/interface/dspriv.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSort.html0000644000175000017500000000655113107004621017771 0ustar jromanjroman DSSort

slepc-3.7.4 2017-05-17

DSSort

Sorts the result of DSSolve() according to a given sorting criterion.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSort(DS ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
eigr  - array containing the computed eigenvalues (real part)
eigi  - array containing the computed eigenvalues (imaginary part)
rr  - (optional) array containing auxiliary values (real part)
ri  - (optional) array containing auxiliary values (imaginary part)

Input/Output Parameter

k  - (optional) number of elements in the leading group

Notes

This routine sorts the arrays provided in eigr and eigi, and also sorts the dense system stored inside ds (assumed to be in condensed form). The sorting criterion is specified with DSSetSlepcSC().

If arrays rr and ri are provided, then a (partial) reordering based on these values rather than on the eigenvalues is performed. In symmetric problems a total order is obtained (parameter k is ignored), but otherwise the result is sorted only partially. In this latter case, it is only guaranteed that all the first k elements satisfy the comparison with any of the last n-k elements. The output value of parameter k is the final number of elements in the first set.

See Also

DSSolve(), DSSetSlepcSC()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSUpdateExtraRow.html0000644000175000017500000000337213107004621021756 0ustar jromanjroman DSUpdateExtraRow

slepc-3.7.4 2017-05-17

DSUpdateExtraRow

Performs all necessary operations so that the extra row gets up-to-date after a call to DSSolve().

Synopsis

#include "slepcds.h" 
PetscErrorCode DSUpdateExtraRow(DS ds)
Not Collective

Input Parameters

ds  - the direct solver context

See Also

DSSolve(), DSSetExtraRow()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSMatType.html0000644000175000017500000001022413107004621020415 0ustar jromanjroman DSMatType

slepc-3.7.4 2017-05-17

DSMatType

Used to refer to one of the matrices stored internally in DS

Synopsis

typedef enum { DS_MAT_A,
               DS_MAT_B,
               DS_MAT_C,
               DS_MAT_T,
               DS_MAT_D,
               DS_MAT_Q,
               DS_MAT_Z,
               DS_MAT_X,
               DS_MAT_Y,
               DS_MAT_U,
               DS_MAT_VT,
               DS_MAT_W,
               DS_MAT_E0,
               DS_MAT_E1,
               DS_MAT_E2,
               DS_MAT_E3,
               DS_MAT_E4,
               DS_MAT_E5,
               DS_MAT_E6,
               DS_MAT_E7,
               DS_MAT_E8,
               DS_MAT_E9,
               DS_NUM_MAT } DSMatType;

Notes

The matrices preferently refer to
DS_MAT_A  - first matrix of eigenproblem/singular value problem
DS_MAT_B  - second matrix of a generalized eigenproblem
DS_MAT_C  - third matrix of a quadratic eigenproblem
DS_MAT_T  - tridiagonal matrix
DS_MAT_D  - diagonal matrix
DS_MAT_Q  - orthogonal matrix of (right) Schur vectors
DS_MAT_Z  - orthogonal matrix of left Schur vectors
DS_MAT_X  - right eigenvectors
DS_MAT_Y  - left eigenvectors
DS_MAT_U  - left singular vectors
DS_MAT_VT  - right singular vectors
DS_MAT_W  - workspace matrix
DS_MAT_Ex  - extra matrices (x=0,..,9)

All matrices can have space to hold ld x ld elements, except for DS_MAT_T that has space for 3 x ld elements (ld = leading dimension) and DS_MAT_D that has space for just ld elements.

In DSPEP problems, matrices A, B, W can have space for d*ld x d*ld, where d is the polynomial degree, and X can have ld x d*ld.

See Also

DSAllocate(), DSGetArray(), DSGetArrayReal(), DSVectors()

Location: src/sys/classes/ds/../../../../include/slepcds.h
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetState.html0000644000175000017500000000421313107004621020567 0ustar jromanjroman DSSetState

slepc-3.7.4 2017-05-17

DSSetState

Change the state of the DS object.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetState(DS ds,DSStateType state)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
state  - the new state

Notes

The state indicates that the dense system is in an initial state (raw), in an intermediate state (such as tridiagonal, Hessenberg or Hessenberg-triangular), in a condensed state (such as diagonal, Schur or generalized Schur), or in a truncated state.

This function is normally used to return to the raw state when the condensed structure is destroyed.

See Also

DSGetState()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetMethod.html0000644000175000017500000000352713107004621020722 0ustar jromanjroman DSGetMethod

slepc-3.7.4 2017-05-17

DSGetMethod

Gets the method currently used in the DS.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetMethod(DS ds,PetscInt *meth)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

meth  - identifier of the method

See Also

DSSetMethod()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSTranslateRKS.html0000644000175000017500000000440313107004621021351 0ustar jromanjroman DSTranslateRKS

slepc-3.7.4 2017-05-17

DSTranslateRKS

Computes a modification of the dense system corresponding to an update of the shift in a rational Krylov method.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSTranslateRKS(DS ds,PetscScalar alpha)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
alpha  - the translation amount

Notes

This function is intended for use in the context of Krylov methods only. It takes the leading (k+1,k) submatrix of A, containing the truncated Rayleigh quotient of a Krylov-Schur relation computed from a shift sigma1 and transforms it to obtain a Krylov relation as if computed from a different shift sigma2. The new matrix is computed as 1.0/alpha*(eye(k)-Q*inv(R)), where [Q,R]=qr(eye(k)-alpha*A) and alpha = sigma1-sigma2.

Matrix Q is placed in DS_MAT_Q so that it can be used to update the Krylov basis.

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSPEPSetDegree.html0000644000175000017500000000336113107004621021252 0ustar jromanjroman DSPEPSetDegree

slepc-3.7.4 2017-05-17

DSPEPSetDegree

Sets the polynomial degree for a DSPEP.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSPEPSetDegree(DS ds,PetscInt d)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
d  - the degree

See Also

DSPEPGetDegree()

Location: src/sys/classes/ds/impls/pep/dspep.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetCompact.html0000644000175000017500000000344713107004621021071 0ustar jromanjroman DSGetCompact

slepc-3.7.4 2017-05-17

DSGetCompact

Gets the compact storage flag.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetCompact(DS ds,PetscBool *comp)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

comp  - the flag

See Also

DSSetCompact()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetBlockSize.html0000644000175000017500000000345413107004621021366 0ustar jromanjroman DSGetBlockSize

slepc-3.7.4 2017-05-17

DSGetBlockSize

Gets the block size.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetBlockSize(DS ds,PetscInt *bs)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

bs  - block size

See Also

DSSetBlockSize()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetOptionsPrefix.html0000644000175000017500000000416313107004621022324 0ustar jromanjroman DSSetOptionsPrefix

slepc-3.7.4 2017-05-17

DSSetOptionsPrefix

Sets the prefix used for searching for all DS options in the database.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetOptionsPrefix(DS ds,const char *prefix)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
prefix  - the prefix string to prepend to all DS option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

DSAppendOptionsPrefix()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetOptionsPrefix.html0000644000175000017500000000430713107004621022310 0ustar jromanjroman DSGetOptionsPrefix

slepc-3.7.4 2017-05-17

DSGetOptionsPrefix

Gets the prefix used for searching for all DS options in the database.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetOptionsPrefix(DS ds,const char *prefix[])
Not Collective

Input Parameters

ds  - the direct solver context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

DSSetOptionsPrefix(), DSAppendOptionsPrefix()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSType.html0000644000175000017500000000331513107004621017756 0ustar jromanjroman DSType

slepc-3.7.4 2017-05-17

DSType

String with the name of the type of direct solver. Roughly, there are as many types as problem types are available within SLEPc.

Synopsis

typedef const char* DSType;
#define DSHEP             "hep"
#define DSNHEP            "nhep"
#define DSGHEP            "ghep"
#define DSGHIEP           "ghiep"
#define DSGNHEP           "gnhep"
#define DSSVD             "svd"
#define DSPEP             "pep"
#define DSNEP             "nep"

See Also

DSSetType(), DS

Location: src/sys/classes/ds/../../../../include/slepcds.h
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSRegisterAll.html0000644000175000017500000000243713107004621021256 0ustar jromanjroman DSRegisterAll

slepc-3.7.4 2017-05-17

DSRegisterAll

Registers all of the direct solvers in the DS package.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSRegisterAll(void)
Not Collective

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetArrayReal.html0000644000175000017500000000430213107004621021354 0ustar jromanjroman DSGetArrayReal

slepc-3.7.4 2017-05-17

DSGetArrayReal

Returns a pointer to one of the internal arrays used to represent real matrices. You MUST call DSRestoreArrayReal() when you no longer need to access the array.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetArrayReal(DS ds,DSMatType m,PetscReal *a[])
Not Collective

Input Parameters

ds  - the direct solver context
m  - the requested matrix

Output Parameter

a  - pointer to the values

See Also

DSRestoreArrayReal(), DSGetArray()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSolve.html0000644000175000017500000000421413107004621020124 0ustar jromanjroman DSSolve

slepc-3.7.4 2017-05-17

DSSolve

Solves the problem.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSolve(DS ds,PetscScalar *eigr,PetscScalar *eigi)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
eigr  - array to store the computed eigenvalues (real part)
eigi  - array to store the computed eigenvalues (imaginary part)

Note

This call brings the dense system to condensed form. No ordering of the eigenvalues is enforced (for this, call DSSort() afterwards).

See Also

DSSort(), DSStateType

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetMat.html0000644000175000017500000000567313107004621020227 0ustar jromanjroman DSGetMat

slepc-3.7.4 2017-05-17

DSGetMat

Returns a sequential dense Mat object containing the requested matrix.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetMat(DS ds,DSMatType m,Mat *A)
Not Collective

Input Parameters

ds  - the direct solver context
m  - the requested matrix

Output Parameter

A  - Mat object

Notes

The Mat is created with sizes equal to the current DS dimensions (nxm), then it is filled with the values that would be obtained with DSGetArray() (not DSGetArrayReal()). If the DS was truncated, then the number of rows is equal to the dimension prior to truncation, see DSTruncate(). The communicator is always PETSC_COMM_SELF.

When no longer needed, the user can either destroy the matrix or call DSRestoreMat(). The latter will copy back the modified values.

See Also

DSRestoreMat(), DSSetDimensions(), DSGetArray(), DSGetArrayReal(), DSTruncate()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSRestoreArray.html0000644000175000017500000000370513107004621021462 0ustar jromanjroman DSRestoreArray

slepc-3.7.4 2017-05-17

DSRestoreArray

Restores the matrix after DSGetArray() was called.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSRestoreArray(DS ds,DSMatType m,PetscScalar *a[])
Not Collective

Input Parameters

ds  - the direct solver context
m  - the requested matrix
a  - pointer to the values

See Also

DSGetArray(), DSGetArrayReal()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSAllocate.html0000644000175000017500000000401513107004621020557 0ustar jromanjroman DSAllocate

slepc-3.7.4 2017-05-17

DSAllocate

Allocates memory for internal storage or matrices in DS.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSAllocate(DS ds,PetscInt ld)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
ld  - leading dimension (maximum allowed dimension for the matrices, including the extra row if present)

See Also

DSGetLeadingDimension(), DSSetDimensions(), DSSetExtraRow()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSViewMat.html0000644000175000017500000000376013107004621020415 0ustar jromanjroman DSViewMat

slepc-3.7.4 2017-05-17

DSViewMat

Prints one of the internal DS matrices.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSViewMat(DS ds,PetscViewer viewer,DSMatType m)
Collective on DS

Input Parameters

ds  - the direct solver context
viewer  - visualization context
m  - matrix to display

Note

Works only for ascii viewers. Set the viewer in Matlab format if want to paste into Matlab.

See Also

DSView()

Location: src/sys/classes/ds/interface/dspriv.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetDimensions.html0000644000175000017500000000463713107004621021631 0ustar jromanjroman DSSetDimensions

slepc-3.7.4 2017-05-17

DSSetDimensions

Resize the matrices in the DS object.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetDimensions(DS ds,PetscInt n,PetscInt m,PetscInt l,PetscInt k)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
n  - the new size
m  - the new column size (only for DSSVD)
l  - number of locked (inactive) leading columns
k  - intermediate dimension (e.g., position of arrow)

Notes

The internal arrays are not reallocated.

The value m is not used except in the case of DSSVD, pass 0 otherwise.

See Also

DSGetDimensions(), DSAllocate()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/index.html0000644000175000017500000001360113107004621017714 0ustar jromanjroman Direct Solver (or Dense System) - DS

slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

Beginner - Basic usage
DS DSDestroy DSView
DSCreate DSSetFromOptions
Intermediate - Setting options for algorithms and data structures
DSAllocate DSPEPGetDegree DSSetMethod
DSGetBlockSize DSPEPSetDegree DSSetType
DSGetDimensions DSSetBlockSize DSSolve
DSGetMethod DSSetDimensions DSSort
DSGetType DSSetIdentity DSVectors
Advanced - Setting more advanced options and customization
DSAppendOptionsPrefix DSMatType DSSetCompact
DSCond DSNEPGetFN DSSetExtraRow
DSGetArray DSNEPGetNumFN DSSetOptionsPrefix
DSGetArrayReal DSNEPSetFN DSSetRefined
DSGetCompact DSNormalize DSSetState
DSGetExtraRow DSRegister DSStateType
DSGetLeadingDimension DSRegisterAll DSTruncate
DSGetMat DSReset DSType
DSGetOptionsPrefix DSRestoreArray DSUpdateExtraRow
DSGetRefined DSRestoreArrayReal
DSGetState DSRestoreMat
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
DSCopyMat DSOrthogonalize DSTranslateRKS
DSFinalizePackage DSPseudoOrthogonalize DSViewMat
DSGetSlepcSC DSSetSlepcSC
DSInitializePackage DSTranslateHarmonic
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/DS/DSGetType.html0000644000175000017500000000356213107004621020422 0ustar jromanjroman DSGetType

slepc-3.7.4 2017-05-17

DSGetType

Gets the DS type name (as a string) from the DS context.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetType(DS ds,DSType *type)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

name  - name of the direct solver

See Also

DSSetType()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetSlepcSC.html0000644000175000017500000000357213107004621020776 0ustar jromanjroman DSGetSlepcSC

slepc-3.7.4 2017-05-17

DSGetSlepcSC

Gets the sorting criterion context.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetSlepcSC(DS ds,SlepcSC *sc)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameters

sc  - a pointer to the sorting criterion context

See Also

DSSetSlepcSC(), DSSort()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSNEPGetNumFN.html0000644000175000017500000000365713107004621021034 0ustar jromanjroman DSNEPGetNumFN

slepc-3.7.4 2017-05-17

DSNEPGetNumFN

Returns the number of functions stored internally by the DS.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSNEPGetNumFN(DS ds,PetscInt *n)
Not collective

Input Parameter

ds  - the direct solver context

Output Parameters

n  - the number of functions passed in DSNEPSetFN()

See Also

DSNEPSetFN()

Location: src/sys/classes/ds/impls/nep/dsnep.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSCond.html0000644000175000017500000000332013107004621017714 0ustar jromanjroman DSCond

slepc-3.7.4 2017-05-17

DSCond

Compute the inf-norm condition number of the first matrix as cond(A) = norm(A)*norm(inv(A)).

Synopsis

#include "slepcds.h" 
PetscErrorCode DSCond(DS ds,PetscReal *cond)
Not Collective

Input Parameters

ds  - the direct solver context
cond  - the computed condition number

See Also

DSSolve()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSRestoreArrayReal.html0000644000175000017500000000374713107004621022274 0ustar jromanjroman DSRestoreArrayReal

slepc-3.7.4 2017-05-17

DSRestoreArrayReal

Restores the matrix after DSGetArrayReal() was called.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSRestoreArrayReal(DS ds,DSMatType m,PetscReal *a[])
Not Collective

Input Parameters

ds  - the direct solver context
m  - the requested matrix
a  - pointer to the values

See Also

DSGetArrayReal(), DSGetArray()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetCompact.html0000644000175000017500000000412513107004621021077 0ustar jromanjroman DSSetCompact

slepc-3.7.4 2017-05-17

DSSetCompact

Switch to compact storage of matrices.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetCompact(DS ds,PetscBool comp)
Logically Collective on DS

Input Parameter

ds  - the direct solver context
comp  - a boolean flag

Notes

Compact storage is used in some DS types such as DSHEP when the matrix is tridiagonal. This flag can be used to indicate whether the user provides the matrix entries via the compact form (the tridiagonal DS_MAT_T) or the non-compact one (DS_MAT_A).

The default is PETSC_FALSE.

See Also

DSGetCompact()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSPseudoOrthogonalize.html0000644000175000017500000000513513107004621023043 0ustar jromanjroman DSPseudoOrthogonalize

slepc-3.7.4 2017-05-17

DSPseudoOrthogonalize

Orthogonalize the columns of a matrix with Modified Gram-Schmidt in an indefinite inner product space defined by a signature.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSPseudoOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscReal *s,PetscInt *lindcols,PetscReal *ns)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
mat  - the matrix
cols  - number of columns to orthogonalize (starting from column zero)
s  - the signature that defines the inner product

Output Parameters

lindcols  - (optional) linearly independent columns of the matrix
ns  - (optional) the new norm of the vectors

See Also

DSOrthogonalize()

Location: src/sys/classes/ds/interface/dspriv.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSDestroy.html0000644000175000017500000000324613107004621020471 0ustar jromanjroman DSDestroy

slepc-3.7.4 2017-05-17

DSDestroy

Destroys DS context that was created with DSCreate().

Synopsis

#include "slepcds.h" 
PetscErrorCode DSDestroy(DS *ds)
Collective on DS

Input Parameter

ds  - the direct solver context

See Also

DSCreate()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSNEPGetFN.html0000644000175000017500000000405413107004621020344 0ustar jromanjroman DSNEPGetFN

slepc-3.7.4 2017-05-17

DSNEPGetFN

Gets the functions associated with the nonlinear DS.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSNEPGetFN(DS ds,PetscInt k,FN *fn)
Not collective, though parallel FNs are returned if the DS is parallel

Input Parameter

ds  - the direct solver context
k  - the index of the requested function (starting in 0)

Output Parameter

fn  - the function

See Also

DSNEPSetFN()

Location: src/sys/classes/ds/impls/nep/dsnep.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSCopyMat.html0000644000175000017500000000600113107004621020404 0ustar jromanjroman DSCopyMat

slepc-3.7.4 2017-05-17

DSCopyMat

Copies the contents of a sequential dense Mat object to the indicated DS matrix, or vice versa.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSCopyMat(DS ds,DSMatType m,PetscInt mr,PetscInt mc,Mat A,PetscInt Ar,PetscInt Ac,PetscInt rows,PetscInt cols,PetscBool out)
Not Collective

Input Parameters

ds  - the direct solver context
m  - the requested matrix
mr  - first row of m to be considered
mc  - first column of m to be considered
A  - Mat object
Ar  - first row of A to be considered
Ac  - first column of A to be considered
rows  - number of rows to copy
cols  - number of columns to copy
out  - whether the data is copied out of the DS

Note

If out=true, the values of the DS matrix m are copied to A, otherwise the entries of A are copied to the DS.

See Also

DSGetMat()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetRefined.html0000644000175000017500000000442113107004621021064 0ustar jromanjroman DSSetRefined

slepc-3.7.4 2017-05-17

DSSetRefined

Sets a flag to indicate that refined vectors must be computed.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetRefined(DS ds,PetscBool ref)
Logically Collective on DS

Input Parameter

ds  - the direct solver context
ref  - a boolean flag

Notes

Normally the vectors returned in DS_MAT_X are eigenvectors of the projected matrix. With this flag activated, DSVectors() will return the right singular vector of the smallest singular value of matrix \tilde{A}-theta*I, where \tilde{A} is the extended (n+1)xn matrix and theta is the Ritz value. This is used in the refined Ritz approximation.

The default is PETSC_FALSE.

See Also

DSVectors(), DSGetRefined()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSGetState.html0000644000175000017500000000342613107004621020560 0ustar jromanjroman DSGetState

slepc-3.7.4 2017-05-17

DSGetState

Returns the current state.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSGetState(DS ds,DSStateType *state)
Not Collective

Input Parameter

ds  - the direct solver context

Output Parameter

state  - current state

See Also

DSSetState()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSRestoreMat.html0000644000175000017500000000474213107004621021127 0ustar jromanjroman DSRestoreMat

slepc-3.7.4 2017-05-17

DSRestoreMat

Restores the matrix after DSGetMat() was called.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSRestoreMat(DS ds,DSMatType m,Mat *A)
Not Collective

Input Parameters

ds  - the direct solver context
m  - the requested matrix
A  - the fetched Mat object

Notes

A call to this function must match a previous call of DSGetMat(). The effect is that the contents of the Mat are copied back to the DS internal array, and the matrix is destroyed.

It is not compulsory to call this function, the matrix obtained with DSGetMat() can simply be destroyed if entries need not be copied back.

See Also

DSGetMat(), DSRestoreArray(), DSRestoreArrayReal()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSVectors.html0000644000175000017500000000611013107004621020456 0ustar jromanjroman DSVectors

slepc-3.7.4 2017-05-17

DSVectors

Compute vectors associated to the dense system such as eigenvectors.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSVectors(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
mat  - the matrix, used to indicate which vectors are required

Input/Output Parameter

j  - (optional) index of vector to be computed

Output Parameter

rnorm  - (optional) computed residual norm

Notes

Allowed values for mat are DS_MAT_X, DS_MAT_Y, DS_MAT_U and DS_MAT_VT, to compute right or left eigenvectors, or left or right singular vectors, respectively.

If NULL is passed in argument j then all vectors are computed, otherwise j indicates which vector must be computed. In real non-symmetric problems, on exit the index j will be incremented when a complex conjugate pair is found.

This function can be invoked after the dense problem has been solved, to get the residual norm estimate of the associated Ritz pair. In that case, the relevant information is returned in rnorm.

For computing eigenvectors, LAPACK's _trevc is used so the matrix must be in (quasi-)triangular form, or call DSSolve() first.

See Also

DSSolve()

Location: src/sys/classes/ds/interface/dsops.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSInitializePackage.html0000644000175000017500000000314613107004621022414 0ustar jromanjroman DSInitializePackage

slepc-3.7.4 2017-05-17

DSInitializePackage

This function initializes everything in the DS package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to DSCreate() when using static libraries.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSInitializePackage()

See Also

SlepcInitialize()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetFromOptions.html0000644000175000017500000000323013107004621021764 0ustar jromanjroman DSSetFromOptions

slepc-3.7.4 2017-05-17

DSSetFromOptions

Sets DS options from the options database.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetFromOptions(DS ds)
Collective on DS

Input Parameters

ds  - the direct solver context

Notes

To see all options, run your program with the -help option.

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetMethod.html0000644000175000017500000000340213107004621020726 0ustar jromanjroman DSSetMethod

slepc-3.7.4 2017-05-17

DSSetMethod

Selects the method to be used to solve the problem.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetMethod(DS ds,PetscInt meth)
Logically Collective on DS

Input Parameter

ds  - the direct solver context
meth  - an index indentifying the method

See Also

DSGetMethod()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSOrthogonalize.html0000644000175000017500000000433313107004621021662 0ustar jromanjroman DSOrthogonalize

slepc-3.7.4 2017-05-17

DSOrthogonalize

Orthogonalize the columns of a matrix.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscInt *lindcols)
Logically Collective on DS

Input Parameters

ds  - the direct solver context
mat  - a matrix
cols  - number of columns to orthogonalize (starting from column zero)

Output Parameter

lindcols  - (optional) number of linearly independent columns of the matrix

See Also

DSPseudoOrthogonalize()

Location: src/sys/classes/ds/interface/dspriv.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/DS/DSSetType.html0000644000175000017500000000335113107004621020432 0ustar jromanjroman DSSetType

slepc-3.7.4 2017-05-17

DSSetType

Selects the type for the DS object.

Synopsis

#include "slepcds.h" 
PetscErrorCode DSSetType(DS ds,DSType type)
Logically Collective on DS

Input Parameter

ds  - the direct solver context
type  - a known type

See Also

DSGetType()

Location: src/sys/classes/ds/interface/dsbasic.c
Index of all DS routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/0000755000175000017500000000000013107004621015720 5ustar jromanjromanslepc-3.7.4/docs/manualpages/RG/RGRingGetParameters.html0000644000175000017500000000506113107004621022424 0ustar jromanjroman RGRingGetParameters

slepc-3.7.4 2017-05-17

RGRingGetParameters

Gets the parameters that define the ring region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGRingGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width)
Not Collective

Input Parameter

rg  - the region context

Output Parameters

center  - center of the region
radius  - radius of the region
vscale  - vertical scale of the region
start_ang  - the right-hand side angle
end_ang  - the left-hand side angle
width  - width of the ring

See Also

RGRingSetParameters()

Location: src/sys/classes/rg/impls/ring/rgring.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGGetScale.html0000644000175000017500000000336613107004621020536 0ustar jromanjroman RGGetScale

slepc-3.7.4 2017-05-17

RGGetScale

Gets the scaling factor.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGGetScale(RG rg,PetscReal *sfactor)
Not Collective

Input Parameter

rg  - the region context

Output Parameter

flg  - the flag

See Also

RGSetScale()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGAppendOptionsPrefix.html0000644000175000017500000000415313107004621023003 0ustar jromanjroman RGAppendOptionsPrefix

slepc-3.7.4 2017-05-17

RGAppendOptionsPrefix

Appends to the prefix used for searching for all RG options in the database.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGAppendOptionsPrefix(RG rg,const char *prefix)
Logically Collective on RG

Input Parameters

rg  - the region context
prefix  - the prefix string to prepend to all RG option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

RGSetOptionsPrefix()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGSetType.html0000644000175000017500000000372213107004621020440 0ustar jromanjroman RGSetType

slepc-3.7.4 2017-05-17

RGSetType

Selects the type for the RG object.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGSetType(RG rg,RGType type)
Logically Collective on RG

Input Parameter

rg  - the region context
type  - a known type

See Also

RGGetType()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex30.c.html
src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/manualpages/RG/RGFinalizePackage.html0000644000175000017500000000277413107004621022066 0ustar jromanjroman RGFinalizePackage
slepc-3.7.4 2017-05-17

RGFinalizePackage

This function destroys everything in the Slepc interface to the RG package. It is called from SlepcFinalize().

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGFinalizePackage(void)

See Also

SlepcFinalize()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGGetOptionsPrefix.html0000644000175000017500000000425413107004621022315 0ustar jromanjroman RGGetOptionsPrefix

slepc-3.7.4 2017-05-17

RGGetOptionsPrefix

Gets the prefix used for searching for all RG options in the database.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGGetOptionsPrefix(RG rg,const char *prefix[])
Not Collective

Input Parameters

rg  - the region context

Output Parameters

prefix  - pointer to the prefix string used is returned

Note

On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix.

See Also

RGSetOptionsPrefix(), RGAppendOptionsPrefix()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGCreate.html0000644000175000017500000000354513107004621020251 0ustar jromanjroman RGCreate

slepc-3.7.4 2017-05-17

RGCreate

Creates an RG context.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGCreate(MPI_Comm comm,RG *newrg)
Collective on MPI_Comm

Input Parameter

comm  - MPI communicator

Output Parameter

newrg  - location to put the RG context

See Also

RGDestroy(), RG

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGSetOptionsPrefix.html0000644000175000017500000000413413107004621022326 0ustar jromanjroman RGSetOptionsPrefix

slepc-3.7.4 2017-05-17

RGSetOptionsPrefix

Sets the prefix used for searching for all RG options in the database.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGSetOptionsPrefix(RG rg,const char *prefix)
Logically Collective on RG

Input Parameters

rg  - the region context
prefix  - the prefix string to prepend to all RG option requests

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

See Also

RGAppendOptionsPrefix()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGGetComplement.html0000644000175000017500000000352113107004621021603 0ustar jromanjroman RGGetComplement

slepc-3.7.4 2017-05-17

RGGetComplement

Gets a flag that that indicates whether the region is complemented or not.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGGetComplement(RG rg,PetscBool *flg)
Not Collective

Input Parameter

rg  - the region context

Output Parameter

flg  - the flag

See Also

RGSetComplement()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGIsTrivial.html0000644000175000017500000000347113107004621020752 0ustar jromanjroman RGIsTrivial

slepc-3.7.4 2017-05-17

RGIsTrivial

Whether it is the trivial region (whole complex plane).

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGIsTrivial(RG rg,PetscBool *trivial)
Not Collective

Input Parameter

rg  - the region context

Output Parameter

trivial  - true if the region is equal to the whole complex plane, e.g., an interval region with all four endpoints unbounded or an ellipse with infinite radius.

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGEllipseSetParameters.html0000644000175000017500000000560713107004621023144 0ustar jromanjroman RGEllipseSetParameters

slepc-3.7.4 2017-05-17

RGEllipseSetParameters

Sets the parameters defining the ellipse region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGEllipseSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale)
Logically Collective on RG

Input Parameters

rg  - the region context
center  - center of the ellipse
radius  - radius of the ellipse
vscale  - vertical scale of the ellipse

Options Database Keys

-rg_ellipse_center  - Sets the center
-rg_ellipse_radius  - Sets the radius
-rg_ellipse_vscale  - Sets the vertical scale

Notes

In the case of complex scalars, a complex center can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -rg_ellipse_center 1.0+2.0i

When PETSc is built with real scalars, the center is restricted to a real value.

See Also

RGEllipseGetParameters()

Location: src/sys/classes/rg/impls/ellipse/rgellipse.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGSetComplement.html0000644000175000017500000000431713107004621021623 0ustar jromanjroman RGSetComplement

slepc-3.7.4 2017-05-17

RGSetComplement

Sets a flag to indicate that the region is the complement of the specified one.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGSetComplement(RG rg,PetscBool flg)
Logically Collective on RG

Input Parameters

rg  - the region context
flg  - the boolean flag

Options Database Key

-rg_complement <bool>  - Activate/deactivate the complementation of the region

See Also

RGGetComplement()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex30.c.html
slepc-3.7.4/docs/manualpages/RG/RGGetType.html0000644000175000017500000000352013107004621020420 0ustar jromanjroman RGGetType
slepc-3.7.4 2017-05-17

RGGetType

Gets the RG type name (as a string) from the RG context.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGGetType(RG rg,RGType *type)
Not Collective

Input Parameter

rg  - the region context

Output Parameter

name  - name of the region

See Also

RGSetType()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGPolygonGetVertices.html0000644000175000017500000000440613107004621022637 0ustar jromanjroman RGPolygonGetVertices

slepc-3.7.4 2017-05-17

RGPolygonGetVertices

Gets the vertices that define the polygon region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGPolygonGetVertices(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi)
Not Collective

Input Parameter

rg  - the region context

Output Parameters

n  - number of vertices
vr  - array of vertices
vi  - array of vertices (imaginary part)

Notes

The returned arrays must NOT be freed by the calling application.

See Also

RGPolygonSetVertices()

Location: src/sys/classes/rg/impls/polygon/rgpolygon.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGSetScale.html0000644000175000017500000000413313107004621020543 0ustar jromanjroman RGSetScale

slepc-3.7.4 2017-05-17

RGSetScale

Sets the scaling factor to be used when checking that a point is inside the region and when computing the contour.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGSetScale(RG rg,PetscReal sfactor)
Logically Collective on RG

Input Parameters

rg  - the region context
sfactor  - the scaling factor

Options Database Key

-rg_scale <real>  - Sets the scaling factor

See Also

RGGetScale(), RGCheckInside()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGRegisterAll.html0000644000175000017500000000240413107004621021254 0ustar jromanjroman RGRegisterAll

slepc-3.7.4 2017-05-17

RGRegisterAll

Registers all of the regions in the RG package.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGRegisterAll(void)
Not Collective

Location: src/sys/classes/rg/rgregis.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGCheckInside.html0000644000175000017500000000515613107004621021217 0ustar jromanjroman RGCheckInside

slepc-3.7.4 2017-05-17

RGCheckInside

Determines if a set of given points are inside the region or not.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGCheckInside(RG rg,PetscInt n,PetscScalar *ar,PetscScalar *ai,PetscInt *inside)
Not Collective

Input Parameters

rg  - the region context
n  - number of points to check
ar  - array of real parts
ai  - array of imaginary parts

Output Parameter

inside  - array of results (1=inside, 0=on the contour, -1=outside)

Note

The point a is expressed as a couple of PetscScalar variables ar,ai. If built with complex scalars, the point is supposed to be stored in ar, otherwise ar,ai contain the real and imaginary parts, respectively.

If a scaling factor was set, the points are scaled before checking.

See Also

RGSetScale(), RGSetComplement()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGComputeContour.html0000644000175000017500000000376413107004621022037 0ustar jromanjroman RGComputeContour

slepc-3.7.4 2017-05-17

RGComputeContour

Computes the coordinates of several points lying in the contour of the region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGComputeContour(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)
Not Collective

Input Parameters

rg  - the region context
n  - number of points to compute

Output Parameter

cr  - location to store real parts
ci  - location to store imaginary parts

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGType.html0000644000175000017500000000274013107004621017763 0ustar jromanjroman RGType

slepc-3.7.4 2017-05-17

RGType

String with the name of the region.

Synopsis

typedef const char* RGType;
#define RGINTERVAL  "interval"
#define RGPOLYGON   "polygon"
#define RGELLIPSE   "ellipse"
#define RGRING      "ring"

See Also

RGSetType(), RG

Location: src/sys/classes/rg/../../../../include/slepcrg.h
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGInitializePackage.html0000644000175000017500000000312613107004621022416 0ustar jromanjroman RGInitializePackage

slepc-3.7.4 2017-05-17

RGInitializePackage

This function initializes everything in the RG package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to RGCreate() when using static libraries.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGInitializePackage(void)

See Also

SlepcInitialize()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGRegister.html0000644000175000017500000000367213107004621020633 0ustar jromanjroman RGRegister

slepc-3.7.4 2017-05-17

RGRegister

Adds a region to the RG package.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGRegister(const char *name,PetscErrorCode (*function)(RG))
Not collective

Input Parameters

name  - name of a new user-defined RG
function  - routine to create context

Notes

RGRegister() may be called multiple times to add several user-defined regions.

See Also

RGRegisterAll()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGPushScale.html0000644000175000017500000000404713107004621020733 0ustar jromanjroman RGPushScale

slepc-3.7.4 2017-05-17

RGPushScale

Sets an additional scaling factor, that will multiply the user-defined scaling factor.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGPushScale(RG rg,PetscReal sfactor)
Logically Collective on RG

Input Parameters

rg  - the region context
sfactor  - the scaling factor

Notes

The current implementation does not allow pushing several scaling factors.

This is intended for internal use, for instance in polynomial eigensolvers that use parameter scaling.

See Also

RGPopScale(), RGSetScale()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/index.html0000644000175000017500000000744013107004621017722 0ustar jromanjroman Region - RG

slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

Beginner - Basic usage
RG RGIsTrivial RGView
RGCreate RGSetFromOptions
RGDestroy RGType
Intermediate - Setting options for algorithms and data structures
RGCheckInside RGGetComplement RGSetComplement
RGComputeContour RGGetType RGSetType
Advanced - Setting more advanced options and customization
RGAppendOptionsPrefix RGIntervalGetEndpoints RGRegisterAll
RGEllipseGetParameters RGIntervalSetEndpoints RGRingGetParameters
RGEllipseSetParameters RGPolygonGetVertices RGRingSetParameters
RGGetOptionsPrefix RGPolygonSetVertices RGSetOptionsPrefix
RGGetScale RGRegister RGSetScale
Developer - Interfaces intended primarily for library developers, not for typical applications programmers
RGFinalizePackage RGPopScale
RGInitializePackage RGPushScale
No deprecated routines

Table of Contents slepc-3.7.4/docs/manualpages/RG/RG.html0000644000175000017500000000245013107004621017117 0ustar jromanjroman RG

slepc-3.7.4 2017-05-17

RG

Region of the complex plane.

Synopsis

typedef struct _p_RG* RG;

See Also

RGCreate()

Location: src/sys/classes/rg/../../../../include/slepcrgtypes.h
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGSetFromOptions.html0000644000175000017500000000317513107004621022000 0ustar jromanjroman RGSetFromOptions

slepc-3.7.4 2017-05-17

RGSetFromOptions

Sets RG options from the options database.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGSetFromOptions(RG rg)
Collective on RG

Input Parameters

rg  - the region context

Notes

To see all options, run your program with the -help option.

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGIntervalGetEndpoints.html0000644000175000017500000000415613107004621023155 0ustar jromanjroman RGIntervalGetEndpoints

slepc-3.7.4 2017-05-17

RGIntervalGetEndpoints

Gets the parameters that define the interval region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGIntervalGetEndpoints(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d)
Not Collective

Input Parameter

rg  - the region context

Output Parameters

a,b  - endpoints of the interval in the real axis
c,d  - endpoints of the interval in the imaginary axis

See Also

RGIntervalSetEndpoints()

Location: src/sys/classes/rg/impls/interval/rginterval.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGDestroy.html0000644000175000017500000000321313107004621020467 0ustar jromanjroman RGDestroy

slepc-3.7.4 2017-05-17

RGDestroy

Destroys RG context that was created with RGCreate().

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGDestroy(RG *rg)
Collective on RG

Input Parameter

rg  - the region context

See Also

RGCreate()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGRingSetParameters.html0000644000175000017500000001013213107004621022433 0ustar jromanjroman RGRingSetParameters

slepc-3.7.4 2017-05-17

RGRingSetParameters

Sets the parameters defining the ring region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGRingSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width)
Logically Collective on RG

Input Parameters

rg  - the region context
center  - center of the ellipse
radius  - radius of the ellipse
vscale  - vertical scale of the ellipse
start_ang  - the right-hand side angle
end_ang  - the left-hand side angle
width  - width of the ring

Options Database Keys

-rg_ring_center  - Sets the center
-rg_ring_radius  - Sets the radius
-rg_ring_vscale  - Sets the vertical scale
-rg_ring_startangle  - Sets the right-hand side angle
-rg_ring_endangle  - Sets the left-hand side angle
-rg_ring_width  - Sets the width of the ring

Notes

The values of center, radius and vscale have the same meaning as in the ellipse region. The startangle and endangle define the span of the ring (by default it is the whole ring), while the width is the separation between the two concentric ellipses (above and below the radius by width/2). The start and end angles are expressed as a fraction of the circumference: the allowed range is [0..1], with 0 corresponding to 0 radians, 0.25 to pi/2 radians, and so on.

In the case of complex scalars, a complex center can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -rg_ring_center 1.0+2.0i

When PETSc is built with real scalars, the center is restricted to a real value.

See Also

RGRingGetParameters()

Location: src/sys/classes/rg/impls/ring/rgring.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGPolygonSetVertices.html0000644000175000017500000000561413107004621022655 0ustar jromanjroman RGPolygonSetVertices

slepc-3.7.4 2017-05-17

RGPolygonSetVertices

Sets the vertices that define the polygon region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGPolygonSetVertices(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi)
Logically Collective on RG

Input Parameters

rg  - the region context
n  - number of vertices
vr  - array of vertices
vi  - array of vertices (imaginary part)

Options Database Keys

-rg_polygon_vertices  - Sets the vertices
-rg_polygon_verticesi  - Sets the vertices (imaginary part)

Notes

In the case of complex scalars, only argument vr is used, containing the complex vertices; the list of vertices can be provided in the command line with a comma-separated list of complex values [+/-][realnumber][+/-]realnumberi with no spaces.

When PETSc is built with real scalars, the real and imaginary parts of the vertices must be provided in two separate arrays (or two lists in the command line).

See Also

RGPolygonGetVertices()

Location: src/sys/classes/rg/impls/polygon/rgpolygon.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGView.html0000644000175000017500000000434713107004621017761 0ustar jromanjroman RGView

slepc-3.7.4 2017-05-17

RGView

Prints the RG data structure.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGView(RG rg,PetscViewer viewer)
Collective on RG

Input Parameters

rg  - the region context
viewer  - optional visualization context

Note

The available visualization contexts include
PETSC_VIEWER_STDOUT_SELF  - standard output (default)
PETSC_VIEWER_STDOUT_WORLD  - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print.

The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file.

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGPopScale.html0000644000175000017500000000313113107004621020543 0ustar jromanjroman RGPopScale

slepc-3.7.4 2017-05-17

RGPopScale

Pops the scaling factor set with RGPushScale().

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGPopScale(RG rg)
Not Collective

Input Parameter

rg  - the region context

See Also

RGPushScale()

Location: src/sys/classes/rg/rgbasic.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGEllipseGetParameters.html0000644000175000017500000000427513107004621023130 0ustar jromanjroman RGEllipseGetParameters

slepc-3.7.4 2017-05-17

RGEllipseGetParameters

Gets the parameters that define the ellipse region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGEllipseGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale)
Not Collective

Input Parameter

rg  - the region context

Output Parameters

center  - center of the region
radius  - radius of the region
vscale  - vertical scale of the region

See Also

RGEllipseSetParameters()

Location: src/sys/classes/rg/impls/ellipse/rgellipse.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages slepc-3.7.4/docs/manualpages/RG/RGIntervalSetEndpoints.html0000644000175000017500000000542113107004621023165 0ustar jromanjroman RGIntervalSetEndpoints

slepc-3.7.4 2017-05-17

RGIntervalSetEndpoints

Sets the parameters defining the interval region.

Synopsis

#include "slepcrg.h" 
PetscErrorCode RGIntervalSetEndpoints(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d)
Logically Collective on RG

Input Parameters

rg  - the region context
a,b  - endpoints of the interval in the real axis
c,d  - endpoints of the interval in the imaginary axis

Options Database Keys

-rg_interval_endpoints  - the four endpoints

Note

The region is defined as [a,b]x[c,d]. Particular cases are an interval on the real axis (c=d=0), similar for the imaginary axis (a=b=0), the whole complex plane (a=-inf,b=inf,c=-inf,d=inf), and so on.

See Also

RGIntervalGetEndpoints()

Location: src/sys/classes/rg/impls/interval/rginterval.c
Index of all RG routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/eps/examples/tutorials/ex30.c.html
src/nep/examples/tutorials/ex27.c.html
slepc-3.7.4/docs/changes.htm0000644000175000017500000004746713107004621015257 0ustar jromanjroman SLEPc - Changes
[ Manual | Installation | Changes | FAQ | Contact ]

 

 

The following table lists the versions of SLEPc and shows the correspondence between SLEPc and PETSc releases. Versions marked as major releases are those which incorporate some new functionality. The rest are just adaptations required for a new PETSc release and may also include bug fixes.

SLEPc version PETSc versions Major Release date
2.1.0 2.1.0 * Not released
2.1.1 2.1.1, 2.1.2, 2.1.3 Dec 2002
2.1.5 2.1.5, 2.1.6 May 2003
2.2.0 2.2.0 * Apr 2004
2.2.1 2.2.1 * Aug 2004
2.3.0 2.3.0 * Jun 2005
2.3.1 2.3.1 Mar 2006
2.3.2 2.3.1, 2.3.2 * Oct 2006
2.3.3 2.3.3 * Jun 2007
3.0.0 3.0.0 * Feb 2009
3.1 3.1 * Aug 2010
3.2 3.2 * Oct 2011
3.3 3.3 * Aug 2012
3.4 3.4 * Jul 2013
3.5 3.5 * Jul 2014
3.6 3.6 * Jun 2015
3.7 3.7 * May 2016

Changes in Version 3.7

  • NEP: new solver 'nleigs' that implements a (rational) Krylov method operating on a companion-type linearization of a rational interpolant of the nonlinear function.
  • PEP: the 'jd' solver can now compute more than one eigenpair.
  • MFN: added a new solver 'krylov' that works for different functions, not only the exponential. The solver available in previous versions has been renamed to 'expokit'.
  • EPS: in spectrum slicing in multi-communicator mode now it is possible to update the problem matrices directly on the sub-communicators.
  • EPS: the contour integral solver now provides Chebyshev quadrature rule and Hankel extraction; all options are documented in STR-11.
  • Now most solvers allow a user-defined criterion to stop iterating based on a callback function.
  • Optimized solution of linear systems in Newton refinement for PEP and NEP.
  • Added download option for most external packages.
  • GPU support updated to use VECCUDA instead of VECCUSP, now including complex scalars.
  • Interface changes: EPS_CONV_EIG has been renamed to EPS_CONV_REL; BVAXPY has been removed, use BVMult instead; BVSetRandom no longer takes a PetscRandom argument, use BVSetRandomContext instead.

Changes in Version 3.6

  • New EPS solver: locally optimal block preconditioned conjugate gradient (LOBPCG).
  • New PEP solvers: Jacobi-Davidson (JD), and symmetric TOAR (STOAR).
  • New NEP solver: contour integral spectrum slice (CISS).
  • Improved BLOPEX interface by adding hard locking. Now the user can specify the block size.
  • Spectrum slicing in EPS can now be run in multi-communicator mode, where each process group computes a sub-interval.
  • Added functions and command-line options to view the computed solution after solve, e.g. -eps_view_vectors binary:myvecs.bin
  • The MFN solver class now takes an FN object to define the function. The functionality for computing functions of small, dense matrices has been moved from DS to FN. MFNSetScaleFactor has been removed, now this scale factor must be specified in FN.
  • FN now allows the definition of functions by combining two other functions.
  • Added two new RG regions: "ring" a stripe along an ellipse with optional start and end angles; "polygon" an arbitrary polygon made up of a list of vertices.
  • User makefiles must now include ${SLEPC_DIR}/lib/slepc/conf/slepc_common.
  • Interface changes: EPSComputeRelativeError and EPSComputeResidualNorm have been deprecated (use EPSComputeError instead); the same for PEP, NEP and SVD; PEPSetScale now allows passing two Vecs for diagonal scaling; XXXPrintSolution has been replaced with XXXErrorView; STGetOperationCounters has been removed, its functionality is available via the log summary and with KSPGetTotalIterations; BVGetVec has been renamed to BVCreateVec; the interface for defining FN functions of rational type has changed; BVSetOrthogonalization takes one more argument.

Changes in Version 3.5

  • A new solver class PEP for polynomial eigenvalue problems has been added. It replaces the former QEP class, that has been removed. PEP contains a new solver TOAR that can handle polynomials of arbitrary degree. Q-Lanczos has been removed since it did not have guaranteed stability.
  • New NEP solver: polynomial interpolation using PEP.
  • Added Newton iterative refinement in both PEP and NEP.
  • A new auxiliary class RG allows the user to define a region in the complex plane. This can be used for filtering out unwanted eigenvalues in EPS and PEP.
  • The auxiliary object IP has been removed and a new object BV has been added that subsumes its functionality.
  • Support for requesting left eigenvectors has been removed, since none of the solvers were computing them internally.
  • The STFOLD spectral transformation has been removed. Example ex24.c reproduces this functionality.
  • Interface changes: SVDSetTransposeMode has been renamed to SVDSetImplicitTranspose; in STSHIFT the sign of sigma is the opposite to previous versions; EPSJDSetBOrth now takes a boolean argument instead of an enum.

Changes in Version 3.4

  • Added new class of solvers NEP for the nonlinear eigenvalue problem.
  • Added new class of solvers MFN for computing the action of a matrix function on a vector.
  • New EPS solver: Contour integral spectrum slice (CISS). Allows to compute all eigenvalues inside a region.
  • New QEP solver: Q-Lanczos is a specialized variant of Q-Arnoldi for problems with symmetric matrices.
  • Added support for shift-and-invert in QEP.
  • Added a new auxiliary class FN: Mathematical Function, to be used in the definition of nonlinear eigenproblems.
  • Added interface to external solver FEAST.
  • Changed options -xxx_monitor_draw to -xxx_monitor_lg, and similarly for -xxx_monitor_draw_all.

Changes in Version 3.3

  • New EPS solver: Rayleigh quotient conjugate gradient (RQCG). This is the first CG-type eigensolver in SLEPc. It can be used for computing smallest eigenvalues of symmetric-definite matrix pairs without inverting any matrix (a preconditioner can be used instead).
  • Added a customizable parameter to specify how to restart in Krylov-Schur, see EPSKrylovSchurSetRestart. Tunning this parameter may speed up convergence significantly in some cases.
  • Added support for generalized symmetric-indefinite eigenproblems in Krylov-Schur and the Davidson solvers. To use this, set the problem type to EPS_GHIEP.
  • New variant of Generalized Davidson for generalized eigenproblems that expands the subspace with two vectors (GD2). It can be activated with -eps_gd_double_expansion.
  • Added experimental support for arbitrary selection of eigenpairs, where the solver chooses the most wanted ones based on a user-defined function of the eigenvectors rather than simply sorting the eigenvalues.
  • Added a new auxiliary class DS: Direct Solver (or Dense System), which is intended for developers rather than normal users.

Changes in Version 3.2

  • Computational intervals for symmetric eigenproblems, that activate a spectrum slicing mechanism to obtain all eigenvalues in a given interval, see EPSSetInterval.
  • Partial support (experimental) for GPU computing via PETSc's VECCUSP and MATAIJCUSP.
  • Improved performance and robustness of GD and JD solvers in (generalized) Hermitian problems.
  • Performance improvement of solvers with explicit matrix such as SVDCYCLIC and QEPLINEAR (now use matrix preallocation).
  • Added Matlab interface.
  • Added support for parallel builds with CMake.
  • Added support for quad precision (configure PETSc --with-precision=__float128 with gcc-4.6 or later).
  • Interface changes: now all XXXDestroy() routines take a pointer to the object.

Changes in Version 3.1

  • New EPS solvers: Generalized Davidson (GD) and Jacobi-Davidson (JD). These are the first eigensolvers in SLEPc that belong to the class of preconditioned eigensolvers.
  • Added a new instance of ST called STPRECOND. This is not really a spectral transformation but rather a convenient way of handling the preconditioners in the new eigensolvers.
  • Added a new class QEP for solving quadratic eigenvalue problems. Currently, it contains two solvers: the Q-Arnoldi method and another one that provides a linearization of the problem and then invokes an eigensolver from EPS.
  • Added support for balancing of non-Hermitian problems, see EPSSetBalance.
  • Improved sorting of eigenvalues, now with the possibility of sorting with respect to a target value. With shift-and-invert, now the ordering of eigenvalues is the expected one, relative to the target. Also added support for user-defined orderings. For details, see EPSSetWhichEigenpairs.
  • Added support for user-defined convergence tests, see EPSSetConvergenceTest. Several predefined convergence criteria are available. Also, there is a new flag for computing the true residual for the convergence test, see EPSSetTrueResidual.
  • Monitors have been reorganized and now more possibilities are available. See the Users Manual for details.
  • Changes in user interface: EPSAttachDeflationSpace has been renamed to EPSSetDeflationSpace, EPSSetLeftVectorsWanted replaces EPSSetClass for requesting left eigenvectors; Change in arguments: EPSSetDeflationSpace; Deprecated function: EPSSetInitialVector, replaced by EPSSetInitialSpace; STSINV has been renamed to STSINVERT.

Changes in Version 3.0.0

  • Released under GNU LGPL license.
  • Improved support for the case that many eigenpairs are to be computed. This is especially so in the default eigensolver (Krylov-Schur) for symmetric problems, as well as for SVD computations. The user can control the behaviour of the solver with a new parameter, mpd (see EPSSetDimensions).
  • Support for harmonic projection in the default eigensolver (Krylov-Schur), see EPSSetExtraction. This can be useful for computing interior or rightmost eigenvalues without the need of a spectral transformation.
  • Memory usage has been optimized in most solvers. In some cases, memory requirements have been halved with respect to the previous versions.
  • In the spectral transformations (ST) the linear solver used internally has been changed to a direct solver by default. The user can still employ an iterative linear solver by setting the appropriate options.
  • Added better support for Fortran 90.
  • Improved support for 'make install', see the Users Manual for details.

Changes in Version 2.3.3

  • A new solver class, SVD, has been introduced for computing the singular value decomposition of a rectangular matrix. The structure of this new type is very similar to that of EPS, and it simplifies the computation of singular values and vectors. A complete chapter in the users manual is devoted to SVD.
  • Better support for generalized problems. Eigenvector purification has been added to improve accuracy in the case of generalized eigenproblems with singular B. Also, a new problem type (EPS_PGNHEP) has been added for better addressing generalized problems in which A is non-Hermitian but B is Hermitian and positive definite.
  • Now 'make install' is available thus facilitating system-wide installation.

Changes in Version 2.3.2

  • A new 'krylovschur' eigensolver has been added, that implements the Krylov-Schur method. This method is related to the Arnoldi and Lanczos algorithms, but incorporates a new restarting scheme that makes it competitive with respect to implicit restart. This eigensolver is now the default for both symmetric and non-symmetric problems.
  • A new wrapper has been developed to interface with the PRIMME library. This library provides Davidson-type eigensolvers.
  • The 'lanczos' solver has been improved, in particular, the different reorthogonalization strategies are now more robust.
  • Now the 'arnoldi' eigensolver supports the computation of eigenvalues other than those of largest magnitude.
  • EPSGetLinearIterations has been replaced with EPSGetOperationCounters, providing more statistics about the solution process.
  • EPSGetIterationNumber now returns the number corresponding to outer iterations.
  • The 'lobpcg' wrapper has been renamed to 'blopex'.
  • The 'planso' wrapper has been removed since PLANSO is no longer being distributed.

Changes in Version 2.3.1

  • New variant of the Arnoldi method added to the 'arnoldi' eigensolver (with delayed reorthogonalization, see EPSArnoldiSetDelayed).
  • Several optimizations for improving performance and scalability, in particular the orthogonalization steps.

Changes in Version 2.3.0

  • New 'lanczos' eigensolver, an explicitly restarted version of the Lanczos method for symmetric eigenproblems. Allows the user to choose among 5 reorthogonalization strategies.
  • New spectrum folding spectral transformation.
  • New configuration system, similar to PETSc's configure.py.
  • New interface to an external eigensolver: LOBPCG implemented in Hypre.
  • Added graphical convergence monitor (with -eps_xmonitor).
  • Improvement of Arnoldi solver in terms of efficiency and robustness.
  • Now the 'lapack' solver uses specific Lapack routines for symmetric and generalized problems.
  • Bug fix in the ARPACK interface.

Changes in Version 2.2.1

  • The 'power' eigensolver has been replaced by a simpler implementation.
  • The 'rqi' eigensolver has been removed. Now the Rayleigh Quotient Iteration is embedded in the 'power' method.
  • The 'subspace' eigensolver has been rewritten. Now it follows the SRRIT implementation, which is much faster than the old one.
  • The 'arnoldi' eigensolver has been re-implemented as well. The new implementation is much more robust and efficient.
  • A new Spectral Tranformation (ST) has been added: the generalized Cayley transform.
  • Support for user-provided deflation subspaces has been added (see EPSAttachDeflationSpace).
  • Support for preservation of symmetry in eigensolvers. For this feature, the user must explicitly call EPSSetProblemType in symmetric problems.
  • The two types of monitors (error estimates and values) have been merged in a single one.
  • New function EPSGetInvariantSubspace.
  • Better support for spectrum slicing in 'blzpack'.

Changes in Version 2.2.0

  • EPSSolve does not return the number of iterations. Use EPSGetIterationNumber for this purpose.
  • EPSGetSolution has been replaced by EPSGetEigenpair with a cleaner interface.
  • EPSComputeError has been replaced by EPSComputeRelativeError and EPSComputeResidualNorm with better error computing for zero eigenvalues. These functions now are oriented to single eigenpairs, as well as EPSGetErrorEstimate.
  • The possibilities of EPSSetWhichEigenpairs have been reduced and now are more coherent across problem types.
  • Removed STNONE spectral transformation. The default of STSHIFT with 0 shift is equivalent.
  • Added STSinvertSetMatStructure to optimize performance of MatAXPY in shift-and-invert transformation.
  • Classical and modified Gram-Schmidt orthogonalization use iterative refinement, with user options for parameter adjustment.

Changes in Version 2.1.5

  • Added call to MatGetInertia in BLZPACK interface.

 

slepc-3.7.4/include/0000755000175000017500000000000013107004621013606 5ustar jromanjromanslepc-3.7.4/include/slepcsvd.h0000644000175000017500000002314713107004621015611 0ustar jromanjroman/* User interface for SLEPc's singular value solvers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCSVD_H) #define __SLEPCSVD_H #include #include #include PETSC_EXTERN PetscErrorCode SVDInitializePackage(void); /*S SVD - Abstract SLEPc object that manages all the singular value problem solvers. Level: beginner .seealso: SVDCreate() S*/ typedef struct _p_SVD* SVD; /*J SVDType - String with the name of a SLEPc singular value solver Level: beginner .seealso: SVDSetType(), SVD J*/ typedef const char* SVDType; #define SVDCROSS "cross" #define SVDCYCLIC "cyclic" #define SVDLAPACK "lapack" #define SVDLANCZOS "lanczos" #define SVDTRLANCZOS "trlanczos" /* Logging support */ PETSC_EXTERN PetscClassId SVD_CLASSID; /*E SVDWhich - Determines whether largest or smallest singular triplets are to be computed Level: intermediate .seealso: SVDSetWhichSingularTriplets(), SVDGetWhichSingularTriplets() E*/ typedef enum { SVD_LARGEST, SVD_SMALLEST } SVDWhich; /*E SVDErrorType - The error type used to assess accuracy of computed solutions Level: intermediate .seealso: SVDComputeError() E*/ typedef enum { SVD_ERROR_ABSOLUTE, SVD_ERROR_RELATIVE } SVDErrorType; PETSC_EXTERN const char *SVDErrorTypes[]; /*E SVDConv - Determines the convergence test Level: intermediate .seealso: SVDSetConvergenceTest(), SVDSetConvergenceTestFunction() E*/ typedef enum { SVD_CONV_ABS, SVD_CONV_REL, SVD_CONV_USER } SVDConv; /*E SVDStop - Determines the stopping test Level: advanced .seealso: SVDSetStoppingTest(), SVDSetStoppingTestFunction() E*/ typedef enum { SVD_STOP_BASIC, SVD_STOP_USER } SVDStop; /*E SVDConvergedReason - Reason a singular value solver was said to have converged or diverged Level: intermediate .seealso: SVDSolve(), SVDGetConvergedReason(), SVDSetTolerances() E*/ typedef enum {/* converged */ SVD_CONVERGED_TOL = 1, SVD_CONVERGED_USER = 2, /* diverged */ SVD_DIVERGED_ITS = -1, SVD_DIVERGED_BREAKDOWN = -2, SVD_CONVERGED_ITERATING = 0 } SVDConvergedReason; PETSC_EXTERN const char *const*SVDConvergedReasons; PETSC_EXTERN PetscErrorCode SVDCreate(MPI_Comm,SVD*); PETSC_EXTERN PetscErrorCode SVDSetBV(SVD,BV,BV); PETSC_EXTERN PetscErrorCode SVDGetBV(SVD,BV*,BV*); PETSC_EXTERN PetscErrorCode SVDSetDS(SVD,DS); PETSC_EXTERN PetscErrorCode SVDGetDS(SVD,DS*); PETSC_EXTERN PetscErrorCode SVDSetType(SVD,SVDType); PETSC_EXTERN PetscErrorCode SVDGetType(SVD,SVDType*); PETSC_EXTERN PetscErrorCode SVDSetOperator(SVD,Mat); PETSC_EXTERN PetscErrorCode SVDGetOperator(SVD,Mat*); PETSC_EXTERN PetscErrorCode SVDSetInitialSpace(SVD,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode SVDSetInitialSpaceLeft(SVD,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode SVDSetImplicitTranspose(SVD,PetscBool); PETSC_EXTERN PetscErrorCode SVDGetImplicitTranspose(SVD,PetscBool*); PETSC_EXTERN PetscErrorCode SVDSetDimensions(SVD,PetscInt,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode SVDGetDimensions(SVD,PetscInt*,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode SVDSetTolerances(SVD,PetscReal,PetscInt); PETSC_EXTERN PetscErrorCode SVDGetTolerances(SVD,PetscReal*,PetscInt*); PETSC_EXTERN PetscErrorCode SVDSetWhichSingularTriplets(SVD,SVDWhich); PETSC_EXTERN PetscErrorCode SVDGetWhichSingularTriplets(SVD,SVDWhich*); PETSC_EXTERN PetscErrorCode SVDSetFromOptions(SVD); PETSC_EXTERN PetscErrorCode SVDSetOptionsPrefix(SVD,const char*); PETSC_EXTERN PetscErrorCode SVDAppendOptionsPrefix(SVD,const char*); PETSC_EXTERN PetscErrorCode SVDGetOptionsPrefix(SVD,const char*[]); PETSC_EXTERN PetscErrorCode SVDSetUp(SVD); PETSC_EXTERN PetscErrorCode SVDSolve(SVD); PETSC_EXTERN PetscErrorCode SVDGetIterationNumber(SVD,PetscInt*); PETSC_EXTERN PetscErrorCode SVDSetConvergenceTestFunction(SVD,PetscErrorCode (*)(SVD,PetscReal,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode SVDSetConvergenceTest(SVD,SVDConv); PETSC_EXTERN PetscErrorCode SVDGetConvergenceTest(SVD,SVDConv*); PETSC_EXTERN PetscErrorCode SVDConvergedAbsolute(SVD,PetscReal,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode SVDConvergedRelative(SVD,PetscReal,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode SVDSetStoppingTestFunction(SVD,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode SVDSetStoppingTest(SVD,SVDStop); PETSC_EXTERN PetscErrorCode SVDGetStoppingTest(SVD,SVDStop*); PETSC_EXTERN PetscErrorCode SVDStoppingBasic(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*); PETSC_EXTERN PetscErrorCode SVDGetConvergedReason(SVD,SVDConvergedReason*); PETSC_EXTERN PetscErrorCode SVDGetConverged(SVD,PetscInt*); PETSC_EXTERN PetscErrorCode SVDGetSingularTriplet(SVD,PetscInt,PetscReal*,Vec,Vec); PETSC_EXTERN PetscErrorCode SVDComputeError(SVD,PetscInt,SVDErrorType,PetscReal*); PETSC_DEPRECATED("Use SVDComputeError()") PETSC_STATIC_INLINE PetscErrorCode SVDComputeRelativeError(SVD svd,PetscInt i,PetscReal *r) {return SVDComputeError(svd,i,SVD_ERROR_RELATIVE,r);} PETSC_DEPRECATED("Use SVDComputeError() with SVD_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode SVDComputeResidualNorms(SVD svd,PetscInt i,PetscReal *r1,PETSC_UNUSED PetscReal *r2) {return SVDComputeError(svd,i,SVD_ERROR_ABSOLUTE,r1);} PETSC_EXTERN PetscErrorCode SVDView(SVD,PetscViewer); PETSC_STATIC_INLINE PetscErrorCode SVDViewFromOptions(SVD svd,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)svd,obj,name);} PETSC_EXTERN PetscErrorCode SVDErrorView(SVD,SVDErrorType,PetscViewer); PETSC_DEPRECATED("Use SVDErrorView()") PETSC_STATIC_INLINE PetscErrorCode SVDPrintSolution(SVD svd,PetscViewer v) {return SVDErrorView(svd,SVD_ERROR_RELATIVE,v);} PETSC_EXTERN PetscErrorCode SVDErrorViewFromOptions(SVD); PETSC_EXTERN PetscErrorCode SVDReasonView(SVD,PetscViewer); PETSC_EXTERN PetscErrorCode SVDReasonViewFromOptions(SVD); PETSC_EXTERN PetscErrorCode SVDValuesView(SVD,PetscViewer); PETSC_EXTERN PetscErrorCode SVDValuesViewFromOptions(SVD); PETSC_EXTERN PetscErrorCode SVDVectorsView(SVD,PetscViewer); PETSC_EXTERN PetscErrorCode SVDVectorsViewFromOptions(SVD); PETSC_EXTERN PetscErrorCode SVDDestroy(SVD*); PETSC_EXTERN PetscErrorCode SVDReset(SVD); PETSC_EXTERN PetscErrorCode SVDMonitor(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt); PETSC_EXTERN PetscErrorCode SVDMonitorSet(SVD,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**)); PETSC_EXTERN PetscErrorCode SVDMonitorSetFromOptions(SVD,const char*,const char*,const char*,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool); PETSC_EXTERN PetscErrorCode SVDConvMonitorSetFromOptions(SVD,const char*,const char*,const char*,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor)); PETSC_EXTERN PetscErrorCode SVDMonitorCancel(SVD); PETSC_EXTERN PetscErrorCode SVDGetMonitorContext(SVD,void **); PETSC_EXTERN PetscErrorCode SVDMonitorAll(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode SVDMonitorFirst(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode SVDMonitorConverged(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor); PETSC_EXTERN PetscErrorCode SVDMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*); PETSC_EXTERN PetscErrorCode SVDMonitorLG(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode SVDMonitorLGAll(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode SVDSetTrackAll(SVD,PetscBool); PETSC_EXTERN PetscErrorCode SVDGetTrackAll(SVD,PetscBool*); PETSC_EXTERN PetscErrorCode SVDCrossSetEPS(SVD,EPS); PETSC_EXTERN PetscErrorCode SVDCrossGetEPS(SVD,EPS*); PETSC_EXTERN PetscErrorCode SVDCyclicSetExplicitMatrix(SVD,PetscBool); PETSC_EXTERN PetscErrorCode SVDCyclicGetExplicitMatrix(SVD,PetscBool*); PETSC_EXTERN PetscErrorCode SVDCyclicSetEPS(SVD,EPS); PETSC_EXTERN PetscErrorCode SVDCyclicGetEPS(SVD,EPS*); PETSC_EXTERN PetscErrorCode SVDLanczosSetOneSide(SVD,PetscBool); PETSC_EXTERN PetscErrorCode SVDLanczosGetOneSide(SVD,PetscBool*); PETSC_EXTERN PetscErrorCode SVDTRLanczosSetOneSide(SVD,PetscBool); PETSC_EXTERN PetscErrorCode SVDTRLanczosGetOneSide(SVD,PetscBool*); PETSC_EXTERN PetscFunctionList SVDList; PETSC_EXTERN PetscErrorCode SVDRegister(const char[],PetscErrorCode(*)(SVD)); PETSC_EXTERN PetscErrorCode SVDAllocateSolution(SVD,PetscInt); #endif slepc-3.7.4/include/makefile0000644000175000017500000000247413107004621015315 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = SOURCEC = SOURCEF = SOURCEH = slepc.h slepcsys.h slepcmath.h slepcversion.h slepcblaslapack.h \ slepceps.h slepcpep.h slepcnep.h slepcmfn.h slepcsvd.h \ slepcst.h slepcds.h slepcfn.h slepcrg.h slepcbv.h slepcvec.h LIBBASE = libslepcsys DIRS = slepc/finclude slepc/private LOCDIR = include/ MANSEC = include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/include/slepcpep.h.html0000644000175000017500000014173613107004621016551 0ustar jromanjroman
Actual source code: slepcpep.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    User interface for SLEPc's polynomial eigenvalue solvers.

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <slepceps.h>

 28: PETSC_EXTERN PetscErrorCode PEPInitializePackage(void);

 30: /*S
 31:      PEP - Abstract SLEPc object that manages all the polynomial eigenvalue
 32:      problem solvers.

 34:    Level: beginner

 36: .seealso:  PEPCreate()
 37: S*/
 38: typedef struct _p_PEP* PEP;

 40: /*J
 41:     PEPType - String with the name of a polynomial eigensolver

 43:    Level: beginner

 45: .seealso: PEPSetType(), PEP
 46: J*/
 47: typedef const char* PEPType;
 48: #define PEPLINEAR    "linear"
 49: #define PEPQARNOLDI  "qarnoldi"
 50: #define PEPTOAR      "toar"
 51: #define PEPSTOAR     "stoar"
 52: #define PEPJD        "jd"

 54: /* Logging support */
 55: PETSC_EXTERN PetscClassId PEP_CLASSID;

 57: /*E
 58:     PEPProblemType - Determines the type of the polynomial eigenproblem

 60:     Level: intermediate

 62: .seealso: PEPSetProblemType(), PEPGetProblemType()
 63: E*/
 64: typedef enum { PEP_GENERAL=1,
 65:                PEP_HERMITIAN,   /* All A_i  Hermitian */
 66:                PEP_GYROSCOPIC   /* QEP with M, K  Hermitian, M>0, C skew-Hermitian */
 67:              } PEPProblemType;

 69: /*E
 70:     PEPWhich - Determines which part of the spectrum is requested

 72:     Level: intermediate

 74: .seealso: PEPSetWhichEigenpairs(), PEPGetWhichEigenpairs()
 75: E*/
 76: typedef enum { PEP_LARGEST_MAGNITUDE=1,
 77:                PEP_SMALLEST_MAGNITUDE,
 78:                PEP_LARGEST_REAL,
 79:                PEP_SMALLEST_REAL,
 80:                PEP_LARGEST_IMAGINARY,
 81:                PEP_SMALLEST_IMAGINARY,
 82:                PEP_TARGET_MAGNITUDE,
 83:                PEP_TARGET_REAL,
 84:                PEP_TARGET_IMAGINARY,
 85:                PEP_WHICH_USER } PEPWhich;

 87: /*E
 88:     PEPBasis - The type of polynomial basis used to represent the polynomial
 89:     eigenproblem

 91:     Level: intermediate

 93: .seealso: PEPSetBasis()
 94: E*/
 95: typedef enum { PEP_BASIS_MONOMIAL,
 96:                PEP_BASIS_CHEBYSHEV1,
 97:                PEP_BASIS_CHEBYSHEV2,
 98:                PEP_BASIS_LEGENDRE,
 99:                PEP_BASIS_LAGUERRE,
100:                PEP_BASIS_HERMITE } PEPBasis;
101: PETSC_EXTERN const char *PEPBasisTypes[];

103: /*E
104:     PEPScale - The scaling strategy

106:     Level: intermediate

108: .seealso: PEPSetScale()
109: E*/
110: typedef enum { PEP_SCALE_NONE,
111:                PEP_SCALE_SCALAR,
112:                PEP_SCALE_DIAGONAL,
113:                PEP_SCALE_BOTH } PEPScale;
114: PETSC_EXTERN const char *PEPScaleTypes[];

116: /*E
117:     PEPRefine - The refinement type

119:     Level: intermediate

121: .seealso: PEPSetRefine()
122: E*/
123: typedef enum { PEP_REFINE_NONE,
124:                PEP_REFINE_SIMPLE,
125:                PEP_REFINE_MULTIPLE } PEPRefine;
126: PETSC_EXTERN const char *PEPRefineTypes[];

128: /*E
129:     PEPRefineScheme - The scheme used for solving linear systems during iterative refinement

131:     Level: intermediate

133: .seealso: PEPSetRefine()
134: E*/
135: typedef enum { PEP_REFINE_SCHEME_SCHUR=1,
136:                PEP_REFINE_SCHEME_MBE,
137:                PEP_REFINE_SCHEME_EXPLICIT } PEPRefineScheme;
138: PETSC_EXTERN const char *PEPRefineSchemes[];

140: /*E
141:     PEPExtract - The extraction type

143:     Level: intermediate

145: .seealso: PEPSetExtract()
146: E*/
147: typedef enum { PEP_EXTRACT_NONE=1,
148:                PEP_EXTRACT_NORM,
149:                PEP_EXTRACT_RESIDUAL,
150:                PEP_EXTRACT_STRUCTURED } PEPExtract;
151: PETSC_EXTERN const char *PEPExtractTypes[];

153: /*E
154:     PEPErrorType - The error type used to assess accuracy of computed solutions

156:     Level: intermediate

158: .seealso: PEPComputeError()
159: E*/
160: typedef enum { PEP_ERROR_ABSOLUTE,
161:                PEP_ERROR_RELATIVE,
162:                PEP_ERROR_BACKWARD } PEPErrorType;
163: PETSC_EXTERN const char *PEPErrorTypes[];

165: /*E
166:     PEPConv - Determines the convergence test

168:     Level: intermediate

170: .seealso: PEPSetConvergenceTest(), PEPSetConvergenceTestFunction()
171: E*/
172: typedef enum { PEP_CONV_ABS,
173:                PEP_CONV_REL,
174:                PEP_CONV_NORM,
175:                PEP_CONV_USER } PEPConv;

177: /*E
178:     PEPStop - Determines the stopping test

180:     Level: advanced

182: .seealso: PEPSetStoppingTest(), PEPSetStoppingTestFunction()
183: E*/
184: typedef enum { PEP_STOP_BASIC,
185:                PEP_STOP_USER } PEPStop;

187: /*E
188:     PEPConvergedReason - Reason an eigensolver was said to
189:          have converged or diverged

191:     Level: intermediate

193: .seealso: PEPSolve(), PEPGetConvergedReason(), PEPSetTolerances()
194: E*/
195: typedef enum {/* converged */
196:               PEP_CONVERGED_TOL                =  1,
197:               PEP_CONVERGED_USER               =  2,
198:               /* diverged */
199:               PEP_DIVERGED_ITS                 = -1,
200:               PEP_DIVERGED_BREAKDOWN           = -2,
201:               PEP_DIVERGED_SYMMETRY_LOST       = -3,
202:               PEP_CONVERGED_ITERATING          =  0} PEPConvergedReason;
203: PETSC_EXTERN const char *const*PEPConvergedReasons;

205: PETSC_EXTERN PetscErrorCode PEPCreate(MPI_Comm,PEP*);
206: PETSC_EXTERN PetscErrorCode PEPDestroy(PEP*);
207: PETSC_EXTERN PetscErrorCode PEPReset(PEP);
208: PETSC_EXTERN PetscErrorCode PEPSetType(PEP,PEPType);
209: PETSC_EXTERN PetscErrorCode PEPGetType(PEP,PEPType*);
210: PETSC_EXTERN PetscErrorCode PEPSetProblemType(PEP,PEPProblemType);
211: PETSC_EXTERN PetscErrorCode PEPGetProblemType(PEP,PEPProblemType*);
212: PETSC_EXTERN PetscErrorCode PEPSetOperators(PEP,PetscInt,Mat[]);
213: PETSC_EXTERN PetscErrorCode PEPGetOperators(PEP,PetscInt,Mat*);
214: PETSC_EXTERN PetscErrorCode PEPGetNumMatrices(PEP,PetscInt*);
215: PETSC_EXTERN PetscErrorCode PEPSetTarget(PEP,PetscScalar);
216: PETSC_EXTERN PetscErrorCode PEPGetTarget(PEP,PetscScalar*);
217: PETSC_EXTERN PetscErrorCode PEPSetFromOptions(PEP);
218: PETSC_EXTERN PetscErrorCode PEPSetUp(PEP);
219: PETSC_EXTERN PetscErrorCode PEPSolve(PEP);
220: PETSC_EXTERN PetscErrorCode PEPView(PEP,PetscViewer);
221: PETSC_STATIC_INLINE PetscErrorCode PEPViewFromOptions(PEP pep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)pep,obj,name);}
222: PETSC_EXTERN PetscErrorCode PEPErrorView(PEP,PEPErrorType,PetscViewer);
223: PETSC_DEPRECATED("Use PEPErrorView()") PETSC_STATIC_INLINE PetscErrorCode PEPPrintSolution(PEP pep,PetscViewer v) {return PEPErrorView(pep,PEP_ERROR_BACKWARD,v);}
224: PETSC_EXTERN PetscErrorCode PEPErrorViewFromOptions(PEP);
225: PETSC_EXTERN PetscErrorCode PEPReasonView(PEP,PetscViewer);
226: PETSC_EXTERN PetscErrorCode PEPReasonViewFromOptions(PEP);
227: PETSC_EXTERN PetscErrorCode PEPValuesView(PEP,PetscViewer);
228: PETSC_EXTERN PetscErrorCode PEPValuesViewFromOptions(PEP);
229: PETSC_EXTERN PetscErrorCode PEPVectorsView(PEP,PetscViewer);
230: PETSC_EXTERN PetscErrorCode PEPVectorsViewFromOptions(PEP);
231: PETSC_EXTERN PetscErrorCode PEPSetBV(PEP,BV);
232: PETSC_EXTERN PetscErrorCode PEPGetBV(PEP,BV*);
233: PETSC_EXTERN PetscErrorCode PEPSetRG(PEP,RG);
234: PETSC_EXTERN PetscErrorCode PEPGetRG(PEP,RG*);
235: PETSC_EXTERN PetscErrorCode PEPSetDS(PEP,DS);
236: PETSC_EXTERN PetscErrorCode PEPGetDS(PEP,DS*);
237: PETSC_EXTERN PetscErrorCode PEPSetST(PEP,ST);
238: PETSC_EXTERN PetscErrorCode PEPGetST(PEP,ST*);
239: PETSC_EXTERN PetscErrorCode PEPRefineGetKSP(PEP,KSP*);

241: PETSC_EXTERN PetscErrorCode PEPSetTolerances(PEP,PetscReal,PetscInt);
242: PETSC_EXTERN PetscErrorCode PEPGetTolerances(PEP,PetscReal*,PetscInt*);
243: PETSC_EXTERN PetscErrorCode PEPSetConvergenceTestFunction(PEP,PetscErrorCode (*)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*));
244: PETSC_EXTERN PetscErrorCode PEPSetConvergenceTest(PEP,PEPConv);
245: PETSC_EXTERN PetscErrorCode PEPGetConvergenceTest(PEP,PEPConv*);
246: PETSC_EXTERN PetscErrorCode PEPConvergedAbsolute(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
247: PETSC_EXTERN PetscErrorCode PEPConvergedRelative(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
248: PETSC_EXTERN PetscErrorCode PEPConvergedNorm(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
249: PETSC_EXTERN PetscErrorCode PEPSetStoppingTestFunction(PEP,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*),void*,PetscErrorCode (*)(void*));
250: PETSC_EXTERN PetscErrorCode PEPSetStoppingTest(PEP,PEPStop);
251: PETSC_EXTERN PetscErrorCode PEPGetStoppingTest(PEP,PEPStop*);
252: PETSC_EXTERN PetscErrorCode PEPStoppingBasic(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*);
253: PETSC_EXTERN PetscErrorCode PEPGetConvergedReason(PEP,PEPConvergedReason *);

255: PETSC_EXTERN PetscErrorCode PEPSetDimensions(PEP,PetscInt,PetscInt,PetscInt);
256: PETSC_EXTERN PetscErrorCode PEPGetDimensions(PEP,PetscInt*,PetscInt*,PetscInt*);
257: PETSC_EXTERN PetscErrorCode PEPSetScale(PEP,PEPScale,PetscReal,Vec,Vec,PetscInt,PetscReal);
258: PETSC_EXTERN PetscErrorCode PEPGetScale(PEP,PEPScale*,PetscReal*,Vec*,Vec*,PetscInt*,PetscReal*);
259: PETSC_EXTERN PetscErrorCode PEPSetRefine(PEP,PEPRefine,PetscInt,PetscReal,PetscInt,PEPRefineScheme);
260: PETSC_EXTERN PetscErrorCode PEPGetRefine(PEP,PEPRefine*,PetscInt*,PetscReal*,PetscInt*,PEPRefineScheme*);
261: PETSC_EXTERN PetscErrorCode PEPSetExtract(PEP,PEPExtract);
262: PETSC_EXTERN PetscErrorCode PEPGetExtract(PEP,PEPExtract*);
263: PETSC_EXTERN PetscErrorCode PEPSetBasis(PEP,PEPBasis);
264: PETSC_EXTERN PetscErrorCode PEPGetBasis(PEP,PEPBasis*);

266: PETSC_EXTERN PetscErrorCode PEPGetConverged(PEP,PetscInt*);
267: PETSC_EXTERN PetscErrorCode PEPGetEigenpair(PEP,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec);
268: PETSC_EXTERN PetscErrorCode PEPComputeError(PEP,PetscInt,PEPErrorType,PetscReal*);
269: PETSC_DEPRECATED("Use PEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode PEPComputeRelativeError(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_BACKWARD,r);}
270: PETSC_DEPRECATED("Use PEPComputeError() with PEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode PEPComputeResidualNorm(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_ABSOLUTE,r);}
271: PETSC_EXTERN PetscErrorCode PEPGetErrorEstimate(PEP,PetscInt,PetscReal*);

273: PETSC_EXTERN PetscErrorCode PEPMonitor(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt);
274: PETSC_EXTERN PetscErrorCode PEPMonitorSet(PEP,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**));
275: PETSC_EXTERN PetscErrorCode PEPMonitorSetFromOptions(PEP,const char*,const char*,const char*,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool);
276: PETSC_EXTERN PetscErrorCode PEPConvMonitorSetFromOptions(PEP,const char*,const char*,const char*,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor));
277: PETSC_EXTERN PetscErrorCode PEPMonitorCancel(PEP);
278: PETSC_EXTERN PetscErrorCode PEPGetMonitorContext(PEP,void **);
279: PETSC_EXTERN PetscErrorCode PEPGetIterationNumber(PEP,PetscInt*);

281: PETSC_EXTERN PetscErrorCode PEPSetInitialSpace(PEP,PetscInt,Vec*);
282: PETSC_EXTERN PetscErrorCode PEPSetWhichEigenpairs(PEP,PEPWhich);
283: PETSC_EXTERN PetscErrorCode PEPGetWhichEigenpairs(PEP,PEPWhich*);
284: PETSC_EXTERN PetscErrorCode PEPSetEigenvalueComparison(PEP,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*);

286: PETSC_EXTERN PetscErrorCode PEPMonitorAll(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*);
287: PETSC_EXTERN PetscErrorCode PEPMonitorFirst(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*);
288: PETSC_EXTERN PetscErrorCode PEPMonitorConverged(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor);
289: PETSC_EXTERN PetscErrorCode PEPMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*);
290: PETSC_EXTERN PetscErrorCode PEPMonitorLG(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
291: PETSC_EXTERN PetscErrorCode PEPMonitorLGAll(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);

293: PETSC_EXTERN PetscErrorCode PEPSetTrackAll(PEP,PetscBool);
294: PETSC_EXTERN PetscErrorCode PEPGetTrackAll(PEP,PetscBool*);

296: PETSC_EXTERN PetscErrorCode PEPSetOptionsPrefix(PEP,const char*);
297: PETSC_EXTERN PetscErrorCode PEPAppendOptionsPrefix(PEP,const char*);
298: PETSC_EXTERN PetscErrorCode PEPGetOptionsPrefix(PEP,const char*[]);

300: PETSC_EXTERN PetscFunctionList PEPList;
301: PETSC_EXTERN PetscErrorCode PEPRegister(const char[],PetscErrorCode(*)(PEP));

303: PETSC_EXTERN PetscErrorCode PEPSetWorkVecs(PEP,PetscInt);
304: PETSC_EXTERN PetscErrorCode PEPAllocateSolution(PEP,PetscInt);

306: /* --------- options specific to particular eigensolvers -------- */

308: PETSC_EXTERN PetscErrorCode PEPLinearSetCompanionForm(PEP,PetscInt);
309: PETSC_EXTERN PetscErrorCode PEPLinearGetCompanionForm(PEP,PetscInt*);
310: PETSC_EXTERN PetscErrorCode PEPLinearSetExplicitMatrix(PEP,PetscBool);
311: PETSC_EXTERN PetscErrorCode PEPLinearGetExplicitMatrix(PEP,PetscBool*);
312: PETSC_EXTERN PetscErrorCode PEPLinearSetEPS(PEP,EPS);
313: PETSC_EXTERN PetscErrorCode PEPLinearGetEPS(PEP,EPS*);

315: PETSC_EXTERN PetscErrorCode PEPQArnoldiSetRestart(PEP,PetscReal);
316: PETSC_EXTERN PetscErrorCode PEPQArnoldiGetRestart(PEP,PetscReal*);
317: PETSC_EXTERN PetscErrorCode PEPQArnoldiSetLocking(PEP,PetscBool);
318: PETSC_EXTERN PetscErrorCode PEPQArnoldiGetLocking(PEP,PetscBool*);

320: PETSC_EXTERN PetscErrorCode PEPTOARSetRestart(PEP,PetscReal);
321: PETSC_EXTERN PetscErrorCode PEPTOARGetRestart(PEP,PetscReal*);
322: PETSC_EXTERN PetscErrorCode PEPTOARSetLocking(PEP,PetscBool);
323: PETSC_EXTERN PetscErrorCode PEPTOARGetLocking(PEP,PetscBool*);

325: PETSC_EXTERN PetscErrorCode PEPSTOARSetLocking(PEP,PetscBool);
326: PETSC_EXTERN PetscErrorCode PEPSTOARGetLocking(PEP,PetscBool*);

328: PETSC_EXTERN PetscErrorCode PEPJDSetRestart(PEP,PetscReal);
329: PETSC_EXTERN PetscErrorCode PEPJDGetRestart(PEP,PetscReal*);

331: #endif

slepc-3.7.4/include/slepc/0000755000175000017500000000000013107004621014714 5ustar jromanjromanslepc-3.7.4/include/slepc/private/0000755000175000017500000000000013107004621016366 5ustar jromanjromanslepc-3.7.4/include/slepc/private/makefile0000644000175000017500000000233013107004621020064 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = SOURCEC = SOURCEF = SOURCEH = epsimpl.h stimpl.h svdimpl.h pepimpl.h \ nepimpl.h mfnimpl.h dsimpl.h fnimpl.h rgimpl.h bvimpl.h slepcimpl.h LIBBASE = libslepcsys DIRS = LOCDIR = include/slepc/private/ MANSEC = include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/include/slepc/private/rgimpl.h0000644000175000017500000000354413107004621020037 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_RGIMPL) #define _RGIMPL #include #include PETSC_EXTERN PetscBool RGRegisterAllCalled; PETSC_EXTERN PetscErrorCode RGRegisterAll(void); typedef struct _RGOps *RGOps; struct _RGOps { PetscErrorCode (*istrivial)(RG,PetscBool*); PetscErrorCode (*computecontour)(RG,PetscInt,PetscScalar*,PetscScalar*); PetscErrorCode (*checkinside)(RG,PetscReal,PetscReal,PetscInt*); PetscErrorCode (*setfromoptions)(PetscOptionItems*,RG); PetscErrorCode (*view)(RG,PetscViewer); PetscErrorCode (*destroy)(RG); }; struct _p_RG { PETSCHEADER(struct _RGOps); PetscBool complement; /* region is the complement of the specified one */ PetscReal sfactor; /* scaling factor */ PetscReal osfactor; /* old scaling factor, before RGPushScale */ void *data; }; /* show an inf instead of PETSC_MAX_REAL */ #define RGShowReal(r) (double)((PetscAbsReal(r)>=PETSC_MAX_REAL)?10*(r):(r)) #endif slepc-3.7.4/include/slepc/private/fnimpl.h.html0000644000175000017500000002313213107004621020770 0ustar jromanjroman
Actual source code: fnimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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 (*evaluatefunctionmatvec)(FN,Mat,Vec);
 40:   PetscErrorCode (*evaluatefunctionmatvecsym)(FN,Mat,Vec);
 41:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,FN);
 42:   PetscErrorCode (*view)(FN,PetscViewer);
 43:   PetscErrorCode (*duplicate)(FN,MPI_Comm,FN*);
 44:   PetscErrorCode (*destroy)(FN);
 45: };

 47: #define FN_MAX_W 6

 49: struct _p_FN {
 50:   PETSCHEADER(struct _FNOps);
 51:   /*------------------------- User parameters --------------------------*/
 52:   PetscScalar alpha;          /* inner scaling (argument) */
 53:   PetscScalar beta;           /* outer scaling (result) */

 55:   /*---------------------- Cached data and workspace -------------------*/
 56:   Mat         W[FN_MAX_W];    /* workspace matrices */
 57:   PetscInt    nw;             /* number of allocated W matrices */
 58:   PetscInt    cw;             /* current W matrix */
 59:   void        *data;
 60: };

 64: /*
 65:   FN_AllocateWorkMat - Allocate a work Mat of the same dimension of A and copy
 66:   its contents. The work matrix is returned in M and should be freed with
 67:   FN_FreeWorkMat().
 68: */
 69: PETSC_STATIC_INLINE PetscErrorCode FN_AllocateWorkMat(FN fn,Mat A,Mat *M)
 70: {
 72:   PetscInt       n,na;
 73:   PetscBool      create=PETSC_FALSE;

 76:   *M = NULL;
 77:   if (fn->cw==FN_MAX_W) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Too many requested work matrices %D",fn->cw);
 78:   if (fn->nw<=fn->cw) {
 79:     create=PETSC_TRUE;
 80:     fn->nw++;
 81:   } else {
 82:     MatGetSize(fn->W[fn->cw],&n,NULL);
 83:     MatGetSize(A,&na,NULL);
 84:     if (n!=na) {
 85:       MatDestroy(&fn->W[fn->cw]);
 86:       create=PETSC_TRUE;
 87:     }
 88:   }
 89:   if (create) {
 90:     MatDuplicate(A,MAT_COPY_VALUES,&fn->W[fn->cw]);
 91:     PetscLogObjectParent((PetscObject)fn,(PetscObject)fn->W[fn->cw]);
 92:   } else {
 93:     MatCopy(A,fn->W[fn->cw],SAME_NONZERO_PATTERN);
 94:   }
 95:   *M = fn->W[fn->cw];
 96:   fn->cw++;
 97:   return(0);
 98: }

102: /*
103:   FN_FreeWorkMat - Release a work matrix created with FN_AllocateWorkMat().
104: */
105: PETSC_STATIC_INLINE PetscErrorCode FN_FreeWorkMat(FN fn,Mat *M)
106: {
108:   if (!fn->cw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"There are no work matrices");
109:   fn->cw--;
110:   if (fn->W[fn->cw]!=*M) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Work matrices must be freed in the reverse order of their creation");
111:   *M = NULL;
112:   return(0);
113: }

115: PETSC_INTERN PetscErrorCode SlepcMatDenseSqrt(PetscBLASInt,PetscScalar*,PetscBLASInt);
116: PETSC_INTERN PetscErrorCode SlepcSchurParlettSqrt(PetscBLASInt,PetscScalar*,PetscBLASInt,PetscBool);

118: #endif
slepc-3.7.4/include/slepc/private/nepimpl.h0000644000175000017500000002115713107004621020211 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_NEPIMPL) #define _NEPIMPL #include #include PETSC_EXTERN PetscBool NEPRegisterAllCalled; PETSC_EXTERN PetscErrorCode NEPRegisterAll(void); PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval; typedef struct _NEPOps *NEPOps; struct _NEPOps { PetscErrorCode (*solve)(NEP); PetscErrorCode (*setup)(NEP); PetscErrorCode (*setfromoptions)(PetscOptionItems*,NEP); PetscErrorCode (*publishoptions)(NEP); PetscErrorCode (*destroy)(NEP); PetscErrorCode (*reset)(NEP); PetscErrorCode (*view)(NEP,PetscViewer); PetscErrorCode (*computevectors)(NEP); }; /* Maximum number of monitors you can run with a single NEP */ #define MAXNEPMONITORS 5 typedef enum { NEP_STATE_INITIAL, NEP_STATE_SETUP, NEP_STATE_SOLVED, NEP_STATE_EIGENVECTORS } NEPStateType; /* How the problem function T(lambda) has been defined by the user - Callback: one callback to build the function matrix, another one for the Jacobian - Split: in split form sum_j(A_j*f_j(lambda)) - Derivatives: a single callback for all the derivatives (including the 0th derivative) */ typedef enum { NEP_USER_INTERFACE_CALLBACK=1, NEP_USER_INTERFACE_SPLIT, NEP_USER_INTERFACE_DERIVATIVES } NEPUserInterface; /* Defines the NEP data structure. */ struct _p_NEP { PETSCHEADER(struct _NEPOps); /*------------------------- User parameters ---------------------------*/ PetscInt max_it; /* maximum number of iterations */ PetscInt nev; /* number of eigenvalues to compute */ PetscInt ncv; /* number of basis vectors */ PetscInt mpd; /* maximum dimension of projected problem */ PetscInt nini; /* number of initial vectors (negative means not copied yet) */ PetscScalar target; /* target value */ PetscReal tol; /* tolerance */ NEPConv conv; /* convergence test */ NEPStop stop; /* stopping test */ NEPWhich which; /* which part of the spectrum to be sought */ NEPRefine refine; /* type of refinement to be applied after solve */ PetscInt npart; /* number of partitions of the communicator */ PetscReal rtol; /* tolerance for refinement */ PetscInt rits; /* number of iterations of the refinement method */ NEPRefineScheme scheme; /* scheme for solving linear systems within refinement */ PetscBool trackall; /* whether all the residuals must be computed */ /*-------------- User-provided functions and contexts -----------------*/ PetscErrorCode (*computefunction)(NEP,PetscScalar,Mat,Mat,void*); PetscErrorCode (*computejacobian)(NEP,PetscScalar,Mat,void*); void *functionctx; void *jacobianctx; PetscErrorCode (*computederivatives)(NEP,PetscScalar,PetscInt,Mat,void*); void *derivativesctx; PetscErrorCode (*converged)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PetscErrorCode (*convergeddestroy)(void*); PetscErrorCode (*stopping)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*); PetscErrorCode (*stoppingdestroy)(void*); void *convergedctx; void *stoppingctx; PetscErrorCode (*monitor[MAXNEPMONITORS])(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PetscErrorCode (*monitordestroy[MAXNEPMONITORS])(void**); void *monitorcontext[MAXNEPMONITORS]; PetscInt numbermonitors; /*----------------- Child objects and working data -------------------*/ DS ds; /* direct solver object */ BV V; /* set of basis vectors and computed eigenvectors */ RG rg; /* optional region for filtering */ SlepcSC sc; /* sorting criterion data */ Mat function; /* function matrix */ Mat function_pre; /* function matrix (preconditioner) */ Mat jacobian; /* Jacobian matrix */ Mat derivatives; /* derivatives matrix */ Mat *A; /* matrix coefficients of split form */ FN *f; /* matrix functions of split form */ PetscInt nt; /* number of terms in split form */ MatStructure mstr; /* pattern of split matrices */ Vec *IS; /* references to user-provided initial space */ PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */ PetscReal *errest; /* error estimates */ PetscInt *perm; /* permutation for eigenvalue ordering */ PetscInt nwork; /* number of work vectors */ Vec *work; /* work vectors */ KSP refineksp; /* ksp used in refinement */ PetscSubcomm refinesubc; /* context for sub-communicators */ void *data; /* placeholder for solver-specific stuff */ /* ----------------------- Status variables --------------------------*/ NEPStateType state; /* initial -> setup -> solved -> eigenvectors */ PetscInt nconv; /* number of converged eigenvalues */ PetscInt its; /* number of iterations so far computed */ PetscInt n,nloc; /* problem dimensions (global, local) */ PetscReal *nrma; /* computed matrix norms */ NEPUserInterface fui; /* how the user has defined the nonlinear operator */ NEPConvergedReason reason; }; /* Macros to test valid NEP arguments */ #if !defined(PETSC_USE_DEBUG) #define NEPCheckProblem(h,arg) do {} while (0) #define NEPCheckCallback(h,arg) do {} while (0) #define NEPCheckSplit(h,arg) do {} while (0) #define NEPCheckDerivatives(h,arg) do {} while (0) #define NEPCheckSolved(h,arg) do {} while (0) #else #define NEPCheckProblem(h,arg) \ do { \ if (!(h->fui)) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"The nonlinear eigenproblem has not been specified yet. Parameter #%d",arg); \ } while (0) #define NEPCheckCallback(h,arg) \ do { \ if (h->fui!=NEP_USER_INTERFACE_CALLBACK) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"This operation requires the nonlinear eigenproblem specified with callbacks. Parameter #%d",arg); \ } while (0) #define NEPCheckSplit(h,arg) \ do { \ if (h->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"This operation requires the nonlinear eigenproblem in split form. Parameter #%d",arg); \ } while (0) #define NEPCheckDerivatives(h,arg) \ do { \ if (h->fui!=NEP_USER_INTERFACE_DERIVATIVES) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"This operation requires the nonlinear eigenproblem specified with derivatives callback. Parameter #%d",arg); \ } while (0) #define NEPCheckSolved(h,arg) \ do { \ if (h->state. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #ifndef _VECIMPLSLEPC #define _VECIMPLSLEPC #include #include #if !defined(PETSC_USE_DEBUG) #define SlepcValidVecComp(y) do {} while (0) #else #define SlepcValidVecComp(y) \ do { \ if (((Vec_Comp*)(y)->data)->nx < ((Vec_Comp*)(y)->data)->n->n) \ SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid number of subvectors required!"); \ } while (0) #endif /* Contexts for VecComp */ typedef struct { PetscInt n; /* number of active subvectors */ PetscInt N; /* virtual global size */ PetscInt lN; /* virtual local size */ PetscInt friends; /* number of vectors sharing this structure */ } Vec_Comp_N; typedef struct { Vec *x; /* the vectors */ PetscInt nx; /* number of available subvectors */ Vec_Comp_N *n; /* structure shared by friend vectors */ } Vec_Comp; /* Operations implemented in VecComp */ PETSC_INTERN PetscErrorCode VecDuplicateVecs_Comp(Vec,PetscInt,Vec*[]); PETSC_INTERN PetscErrorCode VecDestroyVecs_Comp(PetscInt,Vec[]); PETSC_INTERN PetscErrorCode VecDuplicate_Comp(Vec,Vec*); PETSC_INTERN PetscErrorCode VecDestroy_Comp(Vec); PETSC_INTERN PetscErrorCode VecSet_Comp(Vec,PetscScalar); PETSC_INTERN PetscErrorCode VecView_Comp(Vec,PetscViewer); PETSC_INTERN PetscErrorCode VecScale_Comp(Vec,PetscScalar); PETSC_INTERN PetscErrorCode VecCopy_Comp(Vec,Vec); PETSC_INTERN PetscErrorCode VecSwap_Comp(Vec,Vec); PETSC_INTERN PetscErrorCode VecAXPY_Comp(Vec,PetscScalar,Vec); PETSC_INTERN PetscErrorCode VecAYPX_Comp(Vec,PetscScalar,Vec); PETSC_INTERN PetscErrorCode VecAXPBY_Comp(Vec,PetscScalar,PetscScalar,Vec); PETSC_INTERN PetscErrorCode VecMAXPY_Comp(Vec,PetscInt,const PetscScalar*,Vec*); PETSC_INTERN PetscErrorCode VecWAXPY_Comp(Vec,PetscScalar,Vec,Vec); PETSC_INTERN PetscErrorCode VecAXPBYPCZ_Comp(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec); PETSC_INTERN PetscErrorCode VecPointwiseMult_Comp(Vec,Vec,Vec); PETSC_INTERN PetscErrorCode VecPointwiseDivide_Comp(Vec,Vec,Vec); PETSC_INTERN PetscErrorCode VecGetSize_Comp(Vec,PetscInt*); PETSC_INTERN PetscErrorCode VecGetLocalSize_Comp(Vec,PetscInt*); PETSC_INTERN PetscErrorCode VecMax_Comp(Vec,PetscInt*,PetscReal*); PETSC_INTERN PetscErrorCode VecMin_Comp(Vec,PetscInt*,PetscReal*); PETSC_INTERN PetscErrorCode VecSetRandom_Comp(Vec,PetscRandom); PETSC_INTERN PetscErrorCode VecConjugate_Comp(Vec); PETSC_INTERN PetscErrorCode VecReciprocal_Comp(Vec); PETSC_INTERN PetscErrorCode VecMaxPointwiseDivide_Comp(Vec,Vec,PetscReal*); PETSC_INTERN PetscErrorCode VecPointwiseMax_Comp(Vec,Vec,Vec); PETSC_INTERN PetscErrorCode VecPointwiseMaxAbs_Comp(Vec,Vec,Vec); PETSC_INTERN PetscErrorCode VecPointwiseMin_Comp(Vec,Vec,Vec); PETSC_INTERN PetscErrorCode VecDotNorm2_Comp_Seq(Vec,Vec,PetscScalar*,PetscScalar*); PETSC_INTERN PetscErrorCode VecDotNorm2_Comp_MPI(Vec,Vec,PetscScalar*,PetscScalar*); PETSC_INTERN PetscErrorCode VecSqrtAbs_Comp(Vec); PETSC_INTERN PetscErrorCode VecAbs_Comp(Vec); PETSC_INTERN PetscErrorCode VecExp_Comp(Vec); PETSC_INTERN PetscErrorCode VecLog_Comp(Vec); PETSC_INTERN PetscErrorCode VecShift_Comp(Vec,PetscScalar); PETSC_EXTERN PetscErrorCode VecCreate_Comp(Vec); /* Definitions and structures for BLAS-type operations in Davidson solvers */ typedef PetscInt MatType_t; #define DVD_MAT_HERMITIAN (1<<1) #define DVD_MAT_NEG_DEF (1<<2) #define DVD_MAT_POS_DEF (1<<3) #define DVD_MAT_SINGULAR (1<<4) #define DVD_MAT_COMPLEX (1<<5) #define DVD_MAT_IMPLICIT (1<<6) #define DVD_MAT_IDENTITY (1<<7) #define DVD_MAT_DIAG (1<<8) #define DVD_MAT_TRIANG (1<<9) #define DVD_MAT_UTRIANG (1<<9) #define DVD_MAT_LTRIANG (1<<10) #define DVD_MAT_UNITARY (1<<11) typedef PetscInt EPType_t; #define DVD_EP_STD (1<<1) #define DVD_EP_HERMITIAN (1<<2) #define DVD_EP_INDEFINITE (1<<3) #define DVD_IS(T,P) ((T) & (P)) #define DVD_ISNOT(T,P) (((T) & (P)) ^ (P)) /* VecPool */ typedef struct VecPool_ { Vec v; /* template vector */ Vec *vecs; /* pool of vectors */ PetscInt n; /* size of vecs */ PetscInt used; /* number of already used vectors */ PetscInt guess; /* expected maximum number of vectors */ struct VecPool_ *next; /* list of pool of vectors */ } VecPool_; typedef VecPool_* VecPool; PETSC_EXTERN PetscErrorCode SlepcVecPoolCreate(Vec,PetscInt,VecPool*); PETSC_EXTERN PetscErrorCode SlepcVecPoolDestroy(VecPool*); PETSC_EXTERN PetscErrorCode SlepcVecPoolGetVecs(VecPool,PetscInt,Vec**); PETSC_EXTERN PetscErrorCode SlepcVecPoolRestoreVecs(VecPool,PetscInt,Vec**); #endif slepc-3.7.4/include/slepc/private/pepimpl.h.html0000644000175000017500000004540013107004621021153 0ustar jromanjroman
Actual source code: pepimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_PEPIMPL)
 23: #define _PEPIMPL

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

 28: PETSC_EXTERN PetscBool PEPRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode PEPRegisterAll(void);
 30: PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine;

 32: typedef struct _PEPOps *PEPOps;

 34: struct _PEPOps {
 35:   PetscErrorCode (*solve)(PEP);
 36:   PetscErrorCode (*setup)(PEP);
 37:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,PEP);
 38:   PetscErrorCode (*publishoptions)(PEP);
 39:   PetscErrorCode (*destroy)(PEP);
 40:   PetscErrorCode (*reset)(PEP);
 41:   PetscErrorCode (*view)(PEP,PetscViewer);
 42:   PetscErrorCode (*backtransform)(PEP);
 43:   PetscErrorCode (*computevectors)(PEP);
 44:   PetscErrorCode (*extractvectors)(PEP);
 45: };

 47: /*
 48:      Maximum number of monitors you can run with a single PEP
 49: */
 50: #define MAXPEPMONITORS 5

 52: typedef enum { PEP_STATE_INITIAL,
 53:                PEP_STATE_SETUP,
 54:                PEP_STATE_SOLVED,
 55:                PEP_STATE_EIGENVECTORS } PEPStateType;

 57: /*
 58:    Defines the PEP data structure.
 59: */
 60: struct _p_PEP {
 61:   PETSCHEADER(struct _PEPOps);
 62:   /*------------------------- User parameters ---------------------------*/
 63:   PetscInt       max_it;           /* maximum number of iterations */
 64:   PetscInt       nev;              /* number of eigenvalues to compute */
 65:   PetscInt       ncv;              /* number of basis vectors */
 66:   PetscInt       mpd;              /* maximum dimension of projected problem */
 67:   PetscInt       nini;             /* number of initial vectors (negative means not copied yet) */
 68:   PetscScalar    target;           /* target value */
 69:   PetscReal      tol;              /* tolerance */
 70:   PEPConv        conv;             /* convergence test */
 71:   PEPStop        stop;             /* stopping test */
 72:   PEPWhich       which;            /* which part of the spectrum to be sought */
 73:   PEPBasis       basis;            /* polynomial basis used to represent the problem */
 74:   PEPProblemType problem_type;     /* which kind of problem to be solved */
 75:   PEPScale       scale;            /* scaling strategy to be used */
 76:   PetscReal      sfactor,dsfactor; /* scaling factors */
 77:   PetscInt       sits;             /* number of iterations of the scaling method */
 78:   PetscReal      slambda;          /* norm eigenvalue approximation for scaling */
 79:   PEPRefine      refine;           /* type of refinement to be applied after solve */
 80:   PetscInt       npart;            /* number of partitions of the communicator */
 81:   PetscReal      rtol;             /* tolerance for refinement */
 82:   PetscInt       rits;             /* number of iterations of the refinement method */
 83:   PEPRefineScheme scheme;          /* scheme for solving linear systems within refinement */
 84:   PEPExtract     extract;          /* type of extraction used */
 85:   PetscBool      trackall;         /* whether all the residuals must be computed */

 87:   /*-------------- User-provided functions and contexts -----------------*/
 88:   PetscErrorCode (*converged)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
 89:   PetscErrorCode (*convergeddestroy)(void*);
 90:   PetscErrorCode (*stopping)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*);
 91:   PetscErrorCode (*stoppingdestroy)(void*);
 92:   void           *convergedctx;
 93:   void           *stoppingctx;
 94:   PetscErrorCode (*monitor[MAXPEPMONITORS])(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
 95:   PetscErrorCode (*monitordestroy[MAXPEPMONITORS])(void**);
 96:   void           *monitorcontext[MAXPEPMONITORS];
 97:   PetscInt        numbermonitors;

 99:   /*----------------- Child objects and working data -------------------*/
100:   ST             st;               /* spectral transformation object */
101:   DS             ds;               /* direct solver object */
102:   BV             V;                /* set of basis vectors and computed eigenvectors */
103:   RG             rg;               /* optional region for filtering */
104:   SlepcSC        sc;               /* sorting criterion data */
105:   Mat            *A;               /* coefficient matrices of the polynomial */
106:   PetscInt       nmat;             /* number of matrices */
107:   Vec            Dl,Dr;            /* diagonal matrices for balancing */
108:   Vec            *IS;              /* references to user-provided initial space */
109:   PetscScalar    *eigr,*eigi;      /* real and imaginary parts of eigenvalues */
110:   PetscReal      *errest;          /* error estimates */
111:   PetscInt       *perm;            /* permutation for eigenvalue ordering */
112:   PetscReal      *pbc;             /* coefficients defining the polynomial basis */
113:   PetscScalar    *solvematcoeffs;  /* coefficients to compute the matrix to be inverted */
114:   PetscInt       nwork;            /* number of work vectors */
115:   Vec            *work;            /* work vectors */
116:   KSP            refineksp;        /* ksp used in refinement */
117:   PetscSubcomm   refinesubc;       /* context for sub-communicators */
118:   void           *data;            /* placeholder for solver-specific stuff */

120:   /* ----------------------- Status variables --------------------------*/
121:   PEPStateType   state;            /* initial -> setup -> solved -> eigenvectors */
122:   PetscInt       nconv;            /* number of converged eigenvalues */
123:   PetscInt       its;              /* number of iterations so far computed */
124:   PetscInt       n,nloc;           /* problem dimensions (global, local) */
125:   PetscReal      *nrma;            /* computed matrix norms */
126:   PetscReal      nrml[2];          /* computed matrix norms for the linearization */
127:   PetscBool      sfactor_set;      /* flag to indicate the user gave sfactor */
128:   PetscBool      lineariz;         /* current solver is based on linearization */
129:   PEPConvergedReason reason;
130: };

132: /*
133:     Macros to test valid PEP arguments
134: */
135: #if !defined(PETSC_USE_DEBUG)

137: #define PEPCheckSolved(h,arg) do {} while (0)

139: #else

141: #define PEPCheckSolved(h,arg) \
142:   do { \
143:     if (h->state<PEP_STATE_SOLVED) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call PEPSolve() first: Parameter #%d",arg); \
144:   } while (0)

146: #endif

148: PETSC_INTERN PetscErrorCode PEPSetDimensions_Default(PEP,PetscInt,PetscInt*,PetscInt*);
149: PETSC_INTERN PetscErrorCode PEPExtractVectors(PEP);
150: PETSC_INTERN PetscErrorCode PEPBackTransform_Default(PEP);
151: PETSC_INTERN PetscErrorCode PEPComputeVectors(PEP);
152: PETSC_INTERN PetscErrorCode PEPComputeVectors_Default(PEP);
153: PETSC_INTERN PetscErrorCode PEPComputeVectors_Indefinite(PEP);
154: PETSC_INTERN PetscErrorCode PEPComputeResidualNorm_Private(PEP,PetscScalar,PetscScalar,Vec,Vec,Vec*,PetscReal*);
155: PETSC_INTERN PetscErrorCode PEPKrylovConvergence(PEP,PetscBool,PetscInt,PetscInt,PetscReal,PetscInt*);
156: PETSC_INTERN PetscErrorCode PEPComputeScaleFactor(PEP);
157: PETSC_INTERN PetscErrorCode PEPBuildDiagonalScaling(PEP);
158: PETSC_INTERN PetscErrorCode PEPBasisCoefficients(PEP,PetscReal*);
159: PETSC_INTERN PetscErrorCode PEPEvaluateBasis(PEP,PetscScalar,PetscScalar,PetscScalar*,PetscScalar*);
160: PETSC_INTERN PetscErrorCode PEPNewtonRefinement_TOAR(PEP,PetscScalar,PetscInt*,PetscReal*,PetscInt,PetscScalar*,PetscInt,PetscInt*);
161: PETSC_INTERN PetscErrorCode PEPNewtonRefinementSimple(PEP,PetscInt*,PetscReal,PetscInt);

163: #endif
slepc-3.7.4/include/slepc/private/slepcimpl.h0000644000175000017500000000515313107004621020533 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_SLEPCIMPL) #define _SLEPCIMPL #include #include PETSC_INTERN PetscBool SlepcBeganPetsc; /*@C SlepcHeaderCreate - Creates a SLEPc object Input Parameters: + classid - the classid associated with this object . class_name - string name of class; should be static . descr - string containing short description; should be static . mansec - string indicating section in manual pages; should be static . comm - the MPI Communicator . destroy - the destroy routine for this object - view - the view routine for this object Output Parameter: . h - the newly created object Note: This is equivalent to PetscHeaderCreate but makes sure that SlepcInitialize has been called. Level: developer @*/ #define SlepcHeaderCreate(h,classid,class_name,descr,mansec,comm,destroy,view) \ ((!SlepcInitializeCalled && \ PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,1,PETSC_ERROR_INITIAL, \ "Must call SlepcInitialize instead of PetscInitialize to use SLEPc classes")) || \ PetscHeaderCreate(h,classid,class_name,descr,mansec,comm,destroy,view)) /* context for monitors of type XXXMonitorConverged */ struct _n_SlepcConvMonitor { PetscViewer viewer; PetscViewerFormat format; PetscInt oldnconv; }; /* Private functions that are shared by several classes */ PETSC_EXTERN PetscErrorCode SlepcBasisReference_Private(PetscInt,Vec*,PetscInt*,Vec**); PETSC_EXTERN PetscErrorCode SlepcBasisDestroy_Private(PetscInt*,Vec**); PETSC_INTERN PetscErrorCode SlepcCitationsInitialize(void); PETSC_INTERN PetscErrorCode SlepcInitialize_DynamicLibraries(void); PETSC_INTERN PetscErrorCode SlepcInitialize_Packages(void); #endif slepc-3.7.4/include/slepc/private/makefile.html0000644000175000017500000000467113107004621021041 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#     
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS   =
FFLAGS   =
SOURCEC  =
SOURCEF  =
SOURCEH  = epsimpl.h stimpl.h svdimpl.h pepimpl.h \
           nepimpl.h mfnimpl.h dsimpl.h fnimpl.h rgimpl.h bvimpl.h slepcimpl.h
LIBBASE  = libslepcsys
DIRS     = 
LOCDIR   = include/slepc/private/
MANSEC   = 

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/include/slepc/private/mfnimpl.h0000644000175000017500000001071613107004621020206 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_MFNIMPL) #define _MFNIMPL #include #include PETSC_EXTERN PetscBool MFNRegisterAllCalled; PETSC_EXTERN PetscErrorCode MFNRegisterAll(void); PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve; typedef struct _MFNOps *MFNOps; struct _MFNOps { PetscErrorCode (*solve)(MFN,Vec,Vec); PetscErrorCode (*setup)(MFN); PetscErrorCode (*setfromoptions)(PetscOptionItems*,MFN); PetscErrorCode (*publishoptions)(MFN); PetscErrorCode (*destroy)(MFN); PetscErrorCode (*reset)(MFN); PetscErrorCode (*view)(MFN,PetscViewer); }; /* Maximum number of monitors you can run with a single MFN */ #define MAXMFNMONITORS 5 /* Defines the MFN data structure. */ struct _p_MFN { PETSCHEADER(struct _MFNOps); /*------------------------- User parameters ---------------------------*/ Mat A; /* the problem matrix */ FN fn; /* which function to compute */ PetscInt max_it; /* maximum number of iterations */ PetscInt ncv; /* number of basis vectors */ PetscReal tol; /* tolerance */ PetscBool errorifnotconverged; /* error out if MFNSolve() does not converge */ /*-------------- User-provided functions and contexts -----------------*/ PetscErrorCode (*monitor[MAXMFNMONITORS])(MFN,PetscInt,PetscReal,void*); PetscErrorCode (*monitordestroy[MAXMFNMONITORS])(void**); void *monitorcontext[MAXMFNMONITORS]; PetscInt numbermonitors; /*----------------- Child objects and working data -------------------*/ BV V; /* set of basis vectors */ PetscInt nwork; /* number of work vectors */ Vec *work; /* work vectors */ void *data; /* placeholder for solver-specific stuff */ /* ----------------------- Status variables -------------------------- */ PetscInt its; /* number of iterations so far computed */ PetscInt nv; /* size of current Schur decomposition */ PetscReal errest; /* error estimate */ PetscReal bnorm; /* computed norm of right-hand side in current solve */ PetscInt setupcalled; MFNConvergedReason reason; }; #undef __FUNCT__ #define __FUNCT__ "MFN_CreateDenseMat" /* MFN_CreateDenseMat - Creates a dense Mat of size k unless it already has that size */ PETSC_STATIC_INLINE PetscErrorCode MFN_CreateDenseMat(PetscInt k,Mat *A) { PetscErrorCode ierr; PetscBool create=PETSC_FALSE; PetscInt m,n; PetscFunctionBegin; if (!*A) create=PETSC_TRUE; else { ierr = MatGetSize(*A,&m,&n);CHKERRQ(ierr); if (m!=k || n!=k) { ierr = MatDestroy(A);CHKERRQ(ierr); create=PETSC_TRUE; } } if (create) { ierr = MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,A);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFN_CreateVec" /* MFN_CreateVec - Creates a Vec of size k unless it already has that size */ PETSC_STATIC_INLINE PetscErrorCode MFN_CreateVec(PetscInt k,Vec *v) { PetscErrorCode ierr; PetscBool create=PETSC_FALSE; PetscInt n; PetscFunctionBegin; if (!*v) create=PETSC_TRUE; else { ierr = VecGetSize(*v,&n);CHKERRQ(ierr); if (n!=k) { ierr = VecDestroy(v);CHKERRQ(ierr); create=PETSC_TRUE; } } if (create) { ierr = VecCreateSeq(PETSC_COMM_SELF,k,v);CHKERRQ(ierr); } PetscFunctionReturn(0); } PETSC_INTERN PetscErrorCode MFNBasicArnoldi(MFN,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*); #endif slepc-3.7.4/include/slepc/private/stimpl.h0000644000175000017500000001133113107004621020046 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) , Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_STIMPL) #define _STIMPL #include #include PETSC_EXTERN PetscBool STRegisterAllCalled; PETSC_EXTERN PetscErrorCode STRegisterAll(void); PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose; typedef struct _STOps *STOps; struct _STOps { PetscErrorCode (*setup)(ST); PetscErrorCode (*apply)(ST,Vec,Vec); PetscErrorCode (*getbilinearform)(ST,Mat*); PetscErrorCode (*applytrans)(ST,Vec,Vec); PetscErrorCode (*setshift)(ST,PetscScalar); PetscErrorCode (*setfromoptions)(PetscOptionItems*,ST); PetscErrorCode (*postsolve)(ST); PetscErrorCode (*backtransform)(ST,PetscInt,PetscScalar*,PetscScalar*); PetscErrorCode (*destroy)(ST); PetscErrorCode (*reset)(ST); PetscErrorCode (*view)(ST,PetscViewer); PetscErrorCode (*checknullspace)(ST,BV); }; /* 'Updated' state means STSetUp must be called because matrices have been modified, but the pattern is the same (hence reuse symbolic factorization) */ typedef enum { ST_STATE_INITIAL, ST_STATE_SETUP, ST_STATE_UPDATED } STStateType; struct _p_ST { PETSCHEADER(struct _STOps); /*------------------------- User parameters --------------------------*/ Mat *A; /* matrices that define the eigensystem */ PetscObjectState *Astate; /* state (to identify the original matrices) */ Mat *T; /* matrices resulting from transformation */ Mat P; /* matrix from which preconditioner is built */ PetscInt nmat; /* number of matrices */ PetscScalar sigma; /* value of the shift */ PetscBool sigma_set; /* whether the user provided the shift or not */ PetscScalar defsigma; /* default value of the shift */ STMatMode shift_matrix; MatStructure str; /* whether matrices have the same pattern or not */ PetscBool transform; /* whether transformed matrices are computed */ /*------------------------- Misc data --------------------------*/ KSP ksp; Vec w; /* work vector used in apply operation */ Vec D; /* diagonal matrix for balancing */ Vec wb; /* balancing requires an extra work vector */ void *data; STStateType state; /* initial -> setup -> with updated matrices */ }; #undef __FUNCT__ #define __FUNCT__ "ST_AllocateWorkVec" /* ST_AllocateWorkVec - Allocate work vector for the STApply operation. */ PETSC_STATIC_INLINE PetscErrorCode ST_AllocateWorkVec(ST st) { PetscErrorCode ierr; PetscFunctionBegin; if (!st->w) { ierr = MatCreateVecs(st->A[0],&st->w,NULL);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)st,(PetscObject)st->w);CHKERRQ(ierr); } PetscFunctionReturn(0); } /* Macros to test valid ST arguments */ #if !defined(PETSC_USE_DEBUG) #define STCheckMatrices(h,arg) do {} while (0) #else #define STCheckMatrices(h,arg) \ do { \ if (!h->A) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"ST matrices have not been set: Parameter #%d",arg); \ } while (0) #endif PETSC_INTERN PetscErrorCode STGetBilinearForm_Default(ST,Mat*); PETSC_INTERN PetscErrorCode STCheckNullSpace_Default(ST,BV); PETSC_INTERN PetscErrorCode STMatShellCreate(ST,PetscScalar,PetscInt,PetscInt*,PetscScalar*,Mat*); PETSC_INTERN PetscErrorCode STMatShellShift(Mat,PetscScalar); PETSC_INTERN PetscErrorCode STMatSetHermitian(ST,Mat); PETSC_INTERN PetscErrorCode STCheckFactorPackage(ST); PETSC_INTERN PetscErrorCode STMatMAXPY_Private(ST,PetscScalar,PetscScalar,PetscInt,PetscScalar*,PetscBool,Mat*); PETSC_INTERN PetscErrorCode STCoeffs_Monomial(ST,PetscScalar*); #endif slepc-3.7.4/include/slepc/private/svdimpl.h0000644000175000017500000001527613107004621020230 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_SVDIMPL) #define _SVDIMPL #include #include PETSC_EXTERN PetscBool SVDRegisterAllCalled; PETSC_EXTERN PetscErrorCode SVDRegisterAll(void); PETSC_EXTERN PetscLogEvent SVD_SetUp,SVD_Solve; typedef struct _SVDOps *SVDOps; struct _SVDOps { PetscErrorCode (*solve)(SVD); PetscErrorCode (*setup)(SVD); PetscErrorCode (*setfromoptions)(PetscOptionItems*,SVD); PetscErrorCode (*publishoptions)(SVD); PetscErrorCode (*destroy)(SVD); PetscErrorCode (*reset)(SVD); PetscErrorCode (*view)(SVD,PetscViewer); }; /* Maximum number of monitors you can run with a single SVD */ #define MAXSVDMONITORS 5 typedef enum { SVD_STATE_INITIAL, SVD_STATE_SETUP, SVD_STATE_SOLVED, SVD_STATE_VECTORS } SVDStateType; /* Defines the SVD data structure. */ struct _p_SVD { PETSCHEADER(struct _SVDOps); /*------------------------- User parameters ---------------------------*/ Mat OP; /* problem matrix */ PetscInt max_it; /* max iterations */ PetscInt nsv; /* number of requested values */ PetscInt ncv; /* basis size */ PetscInt mpd; /* maximum dimension of projected problem */ PetscInt nini,ninil; /* number of initial vecs (negative means not copied yet) */ PetscReal tol; /* tolerance */ SVDConv conv; /* convergence test */ SVDStop stop; /* stopping test */ SVDWhich which; /* which singular values are computed */ PetscBool impltrans; /* implicit transpose mode */ PetscBool trackall; /* whether all the residuals must be computed */ /*-------------- User-provided functions and contexts -----------------*/ PetscErrorCode (*converged)(SVD,PetscReal,PetscReal,PetscReal*,void*); PetscErrorCode (*convergeddestroy)(void*); PetscErrorCode (*stopping)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*); PetscErrorCode (*stoppingdestroy)(void*); void *convergedctx; void *stoppingctx; PetscErrorCode (*monitor[MAXSVDMONITORS])(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*); PetscErrorCode (*monitordestroy[MAXSVDMONITORS])(void**); void *monitorcontext[MAXSVDMONITORS]; PetscInt numbermonitors; /*----------------- Child objects and working data -------------------*/ DS ds; /* direct solver object */ BV U,V; /* left and right singular vectors */ SlepcSC sc; /* sorting criterion data */ Mat A; /* problem matrix (m>n) */ Mat AT; /* transposed matrix */ Vec *IS,*ISL; /* placeholder for references to user initial space */ PetscReal *sigma; /* singular values */ PetscInt *perm; /* permutation for singular value ordering */ PetscReal *errest; /* error estimates */ void *data; /* placeholder for solver-specific stuff */ /* ----------------------- Status variables -------------------------- */ SVDStateType state; /* initial -> setup -> solved -> vectors */ PetscInt nconv; /* number of converged values */ PetscInt its; /* iteration counter */ PetscBool leftbasis; /* if U is filled by the solver */ SVDConvergedReason reason; }; /* Macros to test valid SVD arguments */ #if !defined(PETSC_USE_DEBUG) #define SVDCheckSolved(h,arg) do {} while (0) #else #define SVDCheckSolved(h,arg) \ do { \ if (h->stateAT) { ierr = MatMult(svd->AT,x,y);CHKERRQ(ierr); } else { #if defined(PETSC_USE_COMPLEX) ierr = MatMultHermitianTranspose(svd->A,x,y);CHKERRQ(ierr); #else ierr = MatMultTranspose(svd->A,x,y);CHKERRQ(ierr); #endif } } else { if (svd->A) { ierr = MatMult(svd->A,x,y);CHKERRQ(ierr); } else { #if defined(PETSC_USE_COMPLEX) ierr = MatMultHermitianTranspose(svd->AT,x,y);CHKERRQ(ierr); #else ierr = MatMultTranspose(svd->AT,x,y);CHKERRQ(ierr); #endif } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMatCreateVecs" PETSC_STATIC_INLINE PetscErrorCode SVDMatCreateVecs(SVD svd,Vec *x,Vec *y) { PetscErrorCode ierr; PetscFunctionBegin; if (svd->A) { ierr = MatCreateVecs(svd->A,x,y);CHKERRQ(ierr); } else { ierr = MatCreateVecs(svd->AT,y,x);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMatGetSize" PETSC_STATIC_INLINE PetscErrorCode SVDMatGetSize(SVD svd,PetscInt *m,PetscInt *n) { PetscErrorCode ierr; PetscFunctionBegin; if (svd->A) { ierr = MatGetSize(svd->A,m,n);CHKERRQ(ierr); } else { ierr = MatGetSize(svd->AT,n,m);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMatGetLocalSize" PETSC_STATIC_INLINE PetscErrorCode SVDMatGetLocalSize(SVD svd,PetscInt *m,PetscInt *n) { PetscErrorCode ierr; PetscFunctionBegin; if (svd->A) { ierr = MatGetLocalSize(svd->A,m,n);CHKERRQ(ierr); } else { ierr = MatGetLocalSize(svd->AT,n,m);CHKERRQ(ierr); } PetscFunctionReturn(0); } PETSC_INTERN PetscErrorCode SVDTwoSideLanczos(SVD,PetscReal*,PetscReal*,BV,BV,PetscInt,PetscInt); PETSC_INTERN PetscErrorCode SVDSetDimensions_Default(SVD); PETSC_INTERN PetscErrorCode SVDComputeVectors(SVD); #endif slepc-3.7.4/include/slepc/private/pepimpl.h0000644000175000017500000001756613107004621020224 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_PEPIMPL) #define _PEPIMPL #include #include PETSC_EXTERN PetscBool PEPRegisterAllCalled; PETSC_EXTERN PetscErrorCode PEPRegisterAll(void); PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine; typedef struct _PEPOps *PEPOps; struct _PEPOps { PetscErrorCode (*solve)(PEP); PetscErrorCode (*setup)(PEP); PetscErrorCode (*setfromoptions)(PetscOptionItems*,PEP); PetscErrorCode (*publishoptions)(PEP); PetscErrorCode (*destroy)(PEP); PetscErrorCode (*reset)(PEP); PetscErrorCode (*view)(PEP,PetscViewer); PetscErrorCode (*backtransform)(PEP); PetscErrorCode (*computevectors)(PEP); PetscErrorCode (*extractvectors)(PEP); }; /* Maximum number of monitors you can run with a single PEP */ #define MAXPEPMONITORS 5 typedef enum { PEP_STATE_INITIAL, PEP_STATE_SETUP, PEP_STATE_SOLVED, PEP_STATE_EIGENVECTORS } PEPStateType; /* Defines the PEP data structure. */ struct _p_PEP { PETSCHEADER(struct _PEPOps); /*------------------------- User parameters ---------------------------*/ PetscInt max_it; /* maximum number of iterations */ PetscInt nev; /* number of eigenvalues to compute */ PetscInt ncv; /* number of basis vectors */ PetscInt mpd; /* maximum dimension of projected problem */ PetscInt nini; /* number of initial vectors (negative means not copied yet) */ PetscScalar target; /* target value */ PetscReal tol; /* tolerance */ PEPConv conv; /* convergence test */ PEPStop stop; /* stopping test */ PEPWhich which; /* which part of the spectrum to be sought */ PEPBasis basis; /* polynomial basis used to represent the problem */ PEPProblemType problem_type; /* which kind of problem to be solved */ PEPScale scale; /* scaling strategy to be used */ PetscReal sfactor,dsfactor; /* scaling factors */ PetscInt sits; /* number of iterations of the scaling method */ PetscReal slambda; /* norm eigenvalue approximation for scaling */ PEPRefine refine; /* type of refinement to be applied after solve */ PetscInt npart; /* number of partitions of the communicator */ PetscReal rtol; /* tolerance for refinement */ PetscInt rits; /* number of iterations of the refinement method */ PEPRefineScheme scheme; /* scheme for solving linear systems within refinement */ PEPExtract extract; /* type of extraction used */ PetscBool trackall; /* whether all the residuals must be computed */ /*-------------- User-provided functions and contexts -----------------*/ PetscErrorCode (*converged)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PetscErrorCode (*convergeddestroy)(void*); PetscErrorCode (*stopping)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*); PetscErrorCode (*stoppingdestroy)(void*); void *convergedctx; void *stoppingctx; PetscErrorCode (*monitor[MAXPEPMONITORS])(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PetscErrorCode (*monitordestroy[MAXPEPMONITORS])(void**); void *monitorcontext[MAXPEPMONITORS]; PetscInt numbermonitors; /*----------------- Child objects and working data -------------------*/ ST st; /* spectral transformation object */ DS ds; /* direct solver object */ BV V; /* set of basis vectors and computed eigenvectors */ RG rg; /* optional region for filtering */ SlepcSC sc; /* sorting criterion data */ Mat *A; /* coefficient matrices of the polynomial */ PetscInt nmat; /* number of matrices */ Vec Dl,Dr; /* diagonal matrices for balancing */ Vec *IS; /* references to user-provided initial space */ PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */ PetscReal *errest; /* error estimates */ PetscInt *perm; /* permutation for eigenvalue ordering */ PetscReal *pbc; /* coefficients defining the polynomial basis */ PetscScalar *solvematcoeffs; /* coefficients to compute the matrix to be inverted */ PetscInt nwork; /* number of work vectors */ Vec *work; /* work vectors */ KSP refineksp; /* ksp used in refinement */ PetscSubcomm refinesubc; /* context for sub-communicators */ void *data; /* placeholder for solver-specific stuff */ /* ----------------------- Status variables --------------------------*/ PEPStateType state; /* initial -> setup -> solved -> eigenvectors */ PetscInt nconv; /* number of converged eigenvalues */ PetscInt its; /* number of iterations so far computed */ PetscInt n,nloc; /* problem dimensions (global, local) */ PetscReal *nrma; /* computed matrix norms */ PetscReal nrml[2]; /* computed matrix norms for the linearization */ PetscBool sfactor_set; /* flag to indicate the user gave sfactor */ PetscBool lineariz; /* current solver is based on linearization */ PEPConvergedReason reason; }; /* Macros to test valid PEP arguments */ #if !defined(PETSC_USE_DEBUG) #define PEPCheckSolved(h,arg) do {} while (0) #else #define PEPCheckSolved(h,arg) \ do { \ if (h->stateActual source code: rgimpl.h
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_RGIMPL)
 23: #define _RGIMPL

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

 28: PETSC_EXTERN PetscBool RGRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode RGRegisterAll(void);

 31: typedef struct _RGOps *RGOps;

 33: struct _RGOps {
 34:   PetscErrorCode (*istrivial)(RG,PetscBool*);
 35:   PetscErrorCode (*computecontour)(RG,PetscInt,PetscScalar*,PetscScalar*);
 36:   PetscErrorCode (*checkinside)(RG,PetscReal,PetscReal,PetscInt*);
 37:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,RG);
 38:   PetscErrorCode (*view)(RG,PetscViewer);
 39:   PetscErrorCode (*destroy)(RG);
 40: };

 42: struct _p_RG {
 43:   PETSCHEADER(struct _RGOps);
 44:   PetscBool   complement;    /* region is the complement of the specified one */
 45:   PetscReal   sfactor;       /* scaling factor */
 46:   PetscReal   osfactor;      /* old scaling factor, before RGPushScale */
 47:   void        *data;
 48: };

 50: /* show an inf instead of PETSC_MAX_REAL */
 51: #define RGShowReal(r) (double)((PetscAbsReal(r)>=PETSC_MAX_REAL)?10*(r):(r))

 53: #endif
slepc-3.7.4/include/slepc/private/svdimpl.h.html0000644000175000017500000004012113107004621021156 0ustar jromanjroman
Actual source code: svdimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_SVDIMPL)
 23: #define _SVDIMPL

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

 28: PETSC_EXTERN PetscBool SVDRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode SVDRegisterAll(void);
 30: PETSC_EXTERN PetscLogEvent SVD_SetUp,SVD_Solve;

 32: typedef struct _SVDOps *SVDOps;

 34: struct _SVDOps {
 35:   PetscErrorCode (*solve)(SVD);
 36:   PetscErrorCode (*setup)(SVD);
 37:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,SVD);
 38:   PetscErrorCode (*publishoptions)(SVD);
 39:   PetscErrorCode (*destroy)(SVD);
 40:   PetscErrorCode (*reset)(SVD);
 41:   PetscErrorCode (*view)(SVD,PetscViewer);
 42: };

 44: /*
 45:      Maximum number of monitors you can run with a single SVD
 46: */
 47: #define MAXSVDMONITORS 5

 49: typedef enum { SVD_STATE_INITIAL,
 50:                SVD_STATE_SETUP,
 51:                SVD_STATE_SOLVED,
 52:                SVD_STATE_VECTORS } SVDStateType;

 54: /*
 55:    Defines the SVD data structure.
 56: */
 57: struct _p_SVD {
 58:   PETSCHEADER(struct _SVDOps);
 59:   /*------------------------- User parameters ---------------------------*/
 60:   Mat            OP;               /* problem matrix */
 61:   PetscInt       max_it;           /* max iterations */
 62:   PetscInt       nsv;              /* number of requested values */
 63:   PetscInt       ncv;              /* basis size */
 64:   PetscInt       mpd;              /* maximum dimension of projected problem */
 65:   PetscInt       nini,ninil;       /* number of initial vecs (negative means not copied yet) */
 66:   PetscReal      tol;              /* tolerance */
 67:   SVDConv        conv;             /* convergence test */
 68:   SVDStop        stop;             /* stopping test */
 69:   SVDWhich       which;            /* which singular values are computed */
 70:   PetscBool      impltrans;        /* implicit transpose mode */
 71:   PetscBool      trackall;         /* whether all the residuals must be computed */

 73:   /*-------------- User-provided functions and contexts -----------------*/
 74:   PetscErrorCode (*converged)(SVD,PetscReal,PetscReal,PetscReal*,void*);
 75:   PetscErrorCode (*convergeddestroy)(void*);
 76:   PetscErrorCode (*stopping)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*);
 77:   PetscErrorCode (*stoppingdestroy)(void*);
 78:   void           *convergedctx;
 79:   void           *stoppingctx;
 80:   PetscErrorCode (*monitor[MAXSVDMONITORS])(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*);
 81:   PetscErrorCode (*monitordestroy[MAXSVDMONITORS])(void**);
 82:   void           *monitorcontext[MAXSVDMONITORS];
 83:   PetscInt       numbermonitors;

 85:   /*----------------- Child objects and working data -------------------*/
 86:   DS             ds;               /* direct solver object */
 87:   BV             U,V;              /* left and right singular vectors */
 88:   SlepcSC        sc;               /* sorting criterion data */
 89:   Mat            A;                /* problem matrix (m>n) */
 90:   Mat            AT;               /* transposed matrix */
 91:   Vec            *IS,*ISL;         /* placeholder for references to user initial space */
 92:   PetscReal      *sigma;           /* singular values */
 93:   PetscInt       *perm;            /* permutation for singular value ordering */
 94:   PetscReal      *errest;          /* error estimates */
 95:   void           *data;            /* placeholder for solver-specific stuff */

 97:   /* ----------------------- Status variables -------------------------- */
 98:   SVDStateType   state;            /* initial -> setup -> solved -> vectors */
 99:   PetscInt       nconv;            /* number of converged values */
100:   PetscInt       its;              /* iteration counter */
101:   PetscBool      leftbasis;        /* if U is filled by the solver */
102:   SVDConvergedReason reason;
103: };

105: /*
106:     Macros to test valid SVD arguments
107: */
108: #if !defined(PETSC_USE_DEBUG)

110: #define SVDCheckSolved(h,arg) do {} while (0)

112: #else

114: #define SVDCheckSolved(h,arg) \
115:   do { \
116:     if (h->state<SVD_STATE_SOLVED) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call SVDSolve() first: Parameter #%d",arg); \
117:   } while (0)

119: #endif

123: PETSC_STATIC_INLINE PetscErrorCode SVDMatMult(SVD svd,PetscBool trans,Vec x,Vec y)
124: {

128:   if (trans) {
129:     if (svd->AT) {
130:       MatMult(svd->AT,x,y);
131:     } else {
132: #if defined(PETSC_USE_COMPLEX)
133:       MatMultHermitianTranspose(svd->A,x,y);
134: #else
135:       MatMultTranspose(svd->A,x,y);
136: #endif
137:     }
138:   } else {
139:     if (svd->A) {
140:       MatMult(svd->A,x,y);
141:     } else {
142: #if defined(PETSC_USE_COMPLEX)
143:       MatMultHermitianTranspose(svd->AT,x,y);
144: #else
145:       MatMultTranspose(svd->AT,x,y);
146: #endif
147:     }
148:   }
149:   return(0);
150: }

154: PETSC_STATIC_INLINE PetscErrorCode SVDMatCreateVecs(SVD svd,Vec *x,Vec *y)
155: {

159:   if (svd->A) {
160:     MatCreateVecs(svd->A,x,y);
161:   } else {
162:     MatCreateVecs(svd->AT,y,x);
163:   }
164:   return(0);
165: }

169: PETSC_STATIC_INLINE PetscErrorCode SVDMatGetSize(SVD svd,PetscInt *m,PetscInt *n)
170: {

174:   if (svd->A) {
175:     MatGetSize(svd->A,m,n);
176:   } else {
177:     MatGetSize(svd->AT,n,m);
178:   }
179:   return(0);
180: }

184: PETSC_STATIC_INLINE PetscErrorCode SVDMatGetLocalSize(SVD svd,PetscInt *m,PetscInt *n)
185: {

189:   if (svd->A) {
190:     MatGetLocalSize(svd->A,m,n);
191:   } else {
192:     MatGetLocalSize(svd->AT,n,m);
193:   }
194:   return(0);
195: } 

197: PETSC_INTERN PetscErrorCode SVDTwoSideLanczos(SVD,PetscReal*,PetscReal*,BV,BV,PetscInt,PetscInt);
198: PETSC_INTERN PetscErrorCode SVDSetDimensions_Default(SVD);
199: PETSC_INTERN PetscErrorCode SVDComputeVectors(SVD);

201: #endif
slepc-3.7.4/include/slepc/private/index.html0000644000175000017500000000210713107004621020363 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

epsimpl.h
stimpl.h
svdimpl.h
pepimpl.h
nepimpl.h
mfnimpl.h
dsimpl.h
fnimpl.h
rgimpl.h
bvimpl.h
slepcimpl.h
makefile
slepc-3.7.4/include/slepc/private/epsimpl.h0000644000175000017500000002071713107004621020217 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_EPSIMPL) #define _EPSIMPL #include #include PETSC_EXTERN PetscBool EPSRegisterAllCalled; PETSC_EXTERN PetscErrorCode EPSRegisterAll(void); PETSC_EXTERN PetscLogEvent EPS_SetUp,EPS_Solve; typedef struct _EPSOps *EPSOps; struct _EPSOps { PetscErrorCode (*solve)(EPS); PetscErrorCode (*setup)(EPS); PetscErrorCode (*setfromoptions)(PetscOptionItems*,EPS); PetscErrorCode (*publishoptions)(EPS); PetscErrorCode (*destroy)(EPS); PetscErrorCode (*reset)(EPS); PetscErrorCode (*view)(EPS,PetscViewer); PetscErrorCode (*backtransform)(EPS); PetscErrorCode (*computevectors)(EPS); }; /* Maximum number of monitors you can run with a single EPS */ #define MAXEPSMONITORS 5 typedef enum { EPS_STATE_INITIAL, EPS_STATE_SETUP, EPS_STATE_SOLVED, EPS_STATE_EIGENVECTORS } EPSStateType; /* Defines the EPS data structure. */ struct _p_EPS { PETSCHEADER(struct _EPSOps); /*------------------------- User parameters ---------------------------*/ PetscInt max_it; /* maximum number of iterations */ PetscInt nev; /* number of eigenvalues to compute */ PetscInt ncv; /* number of basis vectors */ PetscInt mpd; /* maximum dimension of projected problem */ PetscInt nini; /* number of initial vectors (negative means not copied yet) */ PetscInt nds; /* number of basis vectors of deflation space */ PetscScalar target; /* target value */ PetscReal tol; /* tolerance */ EPSConv conv; /* convergence test */ EPSStop stop; /* stopping test */ EPSWhich which; /* which part of the spectrum to be sought */ PetscReal inta,intb; /* interval [a,b] for spectrum slicing */ EPSProblemType problem_type; /* which kind of problem to be solved */ EPSExtraction extraction; /* which kind of extraction to be applied */ EPSBalance balance; /* the balancing method */ PetscInt balance_its; /* number of iterations of the balancing method */ PetscReal balance_cutoff; /* cutoff value for balancing */ PetscBool trueres; /* whether the true residual norm must be computed */ PetscBool trackall; /* whether all the residuals must be computed */ PetscBool purify; /* whether eigenvectors need to be purified */ /*-------------- User-provided functions and contexts -----------------*/ PetscErrorCode (*converged)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PetscErrorCode (*convergeddestroy)(void*); PetscErrorCode (*stopping)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*); PetscErrorCode (*stoppingdestroy)(void*); PetscErrorCode (*arbitrary)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*); void *convergedctx; void *stoppingctx; void *arbitraryctx; PetscErrorCode (*monitor[MAXEPSMONITORS])(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PetscErrorCode (*monitordestroy[MAXEPSMONITORS])(void**); void *monitorcontext[MAXEPSMONITORS]; PetscInt numbermonitors; /*----------------- Child objects and working data -------------------*/ ST st; /* spectral transformation object */ DS ds; /* direct solver object */ BV V; /* set of basis vectors and computed eigenvectors */ RG rg; /* optional region for filtering */ SlepcSC sc; /* sorting criterion data */ Vec D; /* diagonal matrix for balancing */ Vec *IS; /* references to user-provided initial space */ Vec *defl; /* references to user-provided deflation space */ PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */ PetscReal *errest; /* error estimates */ PetscScalar *rr,*ri; /* values computed by user's arbitrary selection function */ PetscInt *perm; /* permutation for eigenvalue ordering */ PetscInt nwork; /* number of work vectors */ Vec *work; /* work vectors */ void *data; /* placeholder for solver-specific stuff */ /* ----------------------- Status variables --------------------------*/ EPSStateType state; /* initial -> setup -> solved -> eigenvectors */ PetscInt nconv; /* number of converged eigenvalues */ PetscInt its; /* number of iterations so far computed */ PetscInt n,nloc; /* problem dimensions (global, local) */ PetscReal nrma,nrmb; /* computed matrix norms */ PetscBool isgeneralized; PetscBool ispositive; PetscBool ishermitian; EPSConvergedReason reason; }; /* Macros to test valid EPS arguments */ #if !defined(PETSC_USE_DEBUG) #define EPSCheckSolved(h,arg) do {} while (0) #else #define EPSCheckSolved(h,arg) \ do { \ if (h->stateV) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } if (eps->ispositive || (eps->isgeneralized && eps->ishermitian)) { ierr = STGetBilinearForm(eps->st,&B);CHKERRQ(ierr); ierr = BVSetMatrix(eps->V,B,PetscNot(eps->ispositive));CHKERRQ(ierr); ierr = MatDestroy(&B);CHKERRQ(ierr); } else { ierr = BVSetMatrix(eps->V,NULL,PETSC_FALSE);CHKERRQ(ierr); } PetscFunctionReturn(0); } PETSC_INTERN PetscErrorCode EPSSetWhichEigenpairs_Default(EPS); PETSC_INTERN PetscErrorCode EPSSetDimensions_Default(EPS,PetscInt,PetscInt*,PetscInt*); PETSC_INTERN PetscErrorCode EPSBackTransform_Default(EPS); PETSC_INTERN PetscErrorCode EPSComputeVectors(EPS); PETSC_INTERN PetscErrorCode EPSComputeVectors_Hermitian(EPS); PETSC_INTERN PetscErrorCode EPSComputeVectors_Schur(EPS); PETSC_INTERN PetscErrorCode EPSComputeVectors_Indefinite(EPS); PETSC_INTERN PetscErrorCode EPSComputeVectors_Slice(EPS); PETSC_INTERN PetscErrorCode EPSComputeResidualNorm_Private(EPS,PetscScalar,PetscScalar,Vec,Vec,Vec*,PetscReal*); PETSC_INTERN PetscErrorCode EPSComputeRitzVector(EPS,PetscScalar*,PetscScalar*,BV,Vec,Vec); PETSC_INTERN PetscErrorCode EPSGetStartVector(EPS,PetscInt,PetscBool*); /* Private functions of the solver implementations */ PETSC_INTERN PetscErrorCode EPSBasicArnoldi(EPS,PetscBool,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*); PETSC_INTERN PetscErrorCode EPSDelayedArnoldi(EPS,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*); PETSC_INTERN PetscErrorCode EPSDelayedArnoldi1(EPS,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*); PETSC_INTERN PetscErrorCode EPSKrylovConvergence(EPS,PetscBool,PetscInt,PetscInt,PetscReal,PetscReal,PetscInt*); PETSC_INTERN PetscErrorCode EPSFullLanczos(EPS,PetscReal*,PetscReal*,PetscInt,PetscInt*,PetscBool*); PETSC_INTERN PetscErrorCode EPSPseudoLanczos(EPS,PetscReal*,PetscReal*,PetscReal*,PetscInt,PetscInt*,PetscBool*,PetscBool*,PetscReal*,Vec); PETSC_INTERN PetscErrorCode EPSBuildBalance_Krylov(EPS); #endif slepc-3.7.4/include/slepc/private/dsimpl.h0000644000175000017500000001553713107004621020042 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_DSIMPL) #define _DSIMPL #include #include PETSC_EXTERN PetscBool DSRegisterAllCalled; PETSC_EXTERN PetscErrorCode DSRegisterAll(void); PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other; PETSC_INTERN const char *DSMatName[]; typedef struct _DSOps *DSOps; struct _DSOps { PetscErrorCode (*allocate)(DS,PetscInt); PetscErrorCode (*view)(DS,PetscViewer); PetscErrorCode (*vectors)(DS,DSMatType,PetscInt*,PetscReal*); PetscErrorCode (*solve[DS_MAX_SOLVE])(DS,PetscScalar*,PetscScalar*); PetscErrorCode (*sort)(DS,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*); PetscErrorCode (*truncate)(DS,PetscInt); PetscErrorCode (*update)(DS); PetscErrorCode (*cond)(DS,PetscReal*); PetscErrorCode (*transharm)(DS,PetscScalar,PetscReal,PetscBool,PetscScalar*,PetscReal*); PetscErrorCode (*transrks)(DS,PetscScalar); PetscErrorCode (*normalize)(DS,DSMatType,PetscInt); PetscErrorCode (*destroy)(DS); }; struct _p_DS { PETSCHEADER(struct _DSOps); /*------------------------- User parameters --------------------------*/ DSStateType state; /* the current state */ PetscInt method; /* identifies the variant to be used */ PetscBool compact; /* whether the matrices are stored in compact form */ PetscBool refined; /* get refined vectors instead of regular vectors */ PetscBool extrarow; /* assume the matrix dimension is (n+1) x n */ PetscInt ld; /* leading dimension */ PetscInt l; /* number of locked (inactive) leading columns */ PetscInt n; /* current dimension */ PetscInt m; /* current column dimension (for SVD only) */ PetscInt k; /* intermediate dimension (e.g. position of arrow) */ PetscInt t; /* length of decomposition when it was truncated */ PetscInt bs; /* block size */ SlepcSC sc; /* sorting criterion */ /*----------------- Status variables and working data ----------------*/ PetscScalar *mat[DS_NUM_MAT]; /* the matrices */ PetscReal *rmat[DS_NUM_MAT]; /* the matrices (real) */ Mat omat[DS_NUM_MAT]; /* the matrices (PETSc object) */ PetscInt *perm; /* permutation */ void *data; /* placeholder for solver-specific stuff */ PetscScalar *work; PetscReal *rwork; PetscBLASInt *iwork; PetscInt lwork,lrwork,liwork; }; /* Macros to test valid DS arguments */ #if !defined(PETSC_USE_DEBUG) #define DSCheckAlloc(h,arg) do {} while (0) #define DSCheckSolved(h,arg) do {} while (0) #else #define DSCheckAlloc(h,arg) \ do { \ if (!h->ld) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call DSAllocate() first: Parameter #%d",arg); \ } while (0) #define DSCheckSolved(h,arg) \ do { \ if (h->stateActual source code: bvimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) , 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(_BVIMPL)
 23: #define _BVIMPL

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

 28: PETSC_EXTERN PetscBool BVRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode BVRegisterAll(void);

 31: PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;

 33: typedef struct _BVOps *BVOps;

 35: struct _BVOps {
 36:   PetscErrorCode (*mult)(BV,PetscScalar,PetscScalar,BV,Mat);
 37:   PetscErrorCode (*multvec)(BV,PetscScalar,PetscScalar,Vec,PetscScalar*);
 38:   PetscErrorCode (*multinplace)(BV,Mat,PetscInt,PetscInt);
 39:   PetscErrorCode (*multinplacetrans)(BV,Mat,PetscInt,PetscInt);
 40:   PetscErrorCode (*dot)(BV,BV,Mat);
 41:   PetscErrorCode (*dotvec)(BV,Vec,PetscScalar*);
 42:   PetscErrorCode (*dotvec_local)(BV,Vec,PetscScalar*);
 43:   PetscErrorCode (*dotvec_begin)(BV,Vec,PetscScalar*);
 44:   PetscErrorCode (*dotvec_end)(BV,Vec,PetscScalar*);
 45:   PetscErrorCode (*scale)(BV,PetscInt,PetscScalar);
 46:   PetscErrorCode (*norm)(BV,PetscInt,NormType,PetscReal*);
 47:   PetscErrorCode (*norm_local)(BV,PetscInt,NormType,PetscReal*);
 48:   PetscErrorCode (*norm_begin)(BV,PetscInt,NormType,PetscReal*);
 49:   PetscErrorCode (*norm_end)(BV,PetscInt,NormType,PetscReal*);
 50:   PetscErrorCode (*orthogonalize)(BV,Mat);
 51:   PetscErrorCode (*matmult)(BV,Mat,BV);
 52:   PetscErrorCode (*copy)(BV,BV);
 53:   PetscErrorCode (*resize)(BV,PetscInt,PetscBool);
 54:   PetscErrorCode (*getcolumn)(BV,PetscInt,Vec*);
 55:   PetscErrorCode (*restorecolumn)(BV,PetscInt,Vec*);
 56:   PetscErrorCode (*getarray)(BV,PetscScalar**);
 57:   PetscErrorCode (*restorearray)(BV,PetscScalar**);
 58:   PetscErrorCode (*getarrayread)(BV,const PetscScalar**);
 59:   PetscErrorCode (*restorearrayread)(BV,const PetscScalar**);
 60:   PetscErrorCode (*duplicate)(BV,BV*);
 61:   PetscErrorCode (*create)(BV);
 62:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,BV);
 63:   PetscErrorCode (*view)(BV,PetscViewer);
 64:   PetscErrorCode (*destroy)(BV);
 65: };

 67: struct _p_BV {
 68:   PETSCHEADER(struct _BVOps);
 69:   /*------------------------- User parameters --------------------------*/
 70:   Vec                t;            /* template vector */
 71:   PetscInt           n,N;          /* dimensions of vectors (local, global) */
 72:   PetscInt           m;            /* number of vectors */
 73:   PetscInt           l;            /* number of leading columns */
 74:   PetscInt           k;            /* number of active columns */
 75:   PetscInt           nc;           /* number of constraints */
 76:   BVOrthogType       orthog_type;  /* the method of vector orthogonalization */
 77:   BVOrthogRefineType orthog_ref;   /* refinement method */
 78:   PetscReal          orthog_eta;   /* refinement threshold */
 79:   BVOrthogBlockType  orthog_block; /* the method of block orthogonalization */
 80:   Mat                matrix;       /* inner product matrix */
 81:   PetscBool          indef;        /* matrix is indefinite */
 82:   BVMatMultType      vmm;          /* version of matmult operation */

 84:   /*---------------------- Cached data and workspace -------------------*/
 85:   Vec                Bx;           /* result of matrix times a vector x */
 86:   PetscObjectId      xid;          /* object id of vector x */
 87:   PetscObjectState   xstate;       /* state of vector x */
 88:   Vec                cv[2];        /* column vectors obtained with BVGetColumn() */
 89:   PetscInt           ci[2];        /* column indices of obtained vectors */
 90:   PetscObjectState   st[2];        /* state of obtained vectors */
 91:   PetscObjectId      id[2];        /* object id of obtained vectors */
 92:   PetscScalar        *h,*c;        /* orthogonalization coefficients */
 93:   PetscReal          *omega;       /* signature matrix values for indefinite case */
 94:   Mat                B,C;          /* auxiliary dense matrices for matmult operation */
 95:   PetscObjectId      Aid;          /* object id of matrix A of matmult operation */
 96:   PetscBool          defersfo;     /* deferred call to setfromoptions */
 97:   BV                 cached;       /* cached BV to store result of matrix times BV */
 98:   PetscObjectState   bvstate;      /* state of BV when BVApplyMatrixBV() was called */
 99:   PetscRandom        rand;         /* random number generator */
100:   PetscBool          rrandom;      /* reproducible random vectors */
101:   PetscScalar        *work;
102:   PetscInt           lwork;
103:   void               *data;
104: };

108: /*
109:   BV_SafeSqrt - Computes the square root of a scalar value alpha, which is
110:   assumed to be z'*B*z. The result is
111:     if definite inner product:     res = sqrt(alpha)
112:     if indefinite inner product:   res = sgn(alpha)*sqrt(abs(alpha))
113: */
114: PETSC_STATIC_INLINE PetscErrorCode BV_SafeSqrt(BV bv,PetscScalar alpha,PetscReal *res)
115: {
117:   PetscReal      absal,realp;

120:   absal = PetscAbsScalar(alpha);
121:   realp = PetscRealPart(alpha);
122:   if (absal<PETSC_MACHINE_EPSILON) {
123:     PetscInfo(bv,"Zero norm, either the vector is zero or a semi-inner product is being used\n");
124:   }
125: #if defined(PETSC_USE_COMPLEX)
126:   if (PetscAbsReal(PetscImaginaryPart(alpha))/absal>PETSC_MACHINE_EPSILON) SETERRQ(PetscObjectComm((PetscObject)bv),1,"The inner product is not well defined: nonzero imaginary part");
127: #endif
128:   if (bv->indef) {
129:     *res = (realp<0.0)? -PetscSqrtReal(-realp): PetscSqrtReal(realp);
130:   } else { 
131:     if (realp<0.0) SETERRQ(PetscObjectComm((PetscObject)bv),1,"The inner product is not well defined: indefinite matrix");
132:     *res = PetscSqrtReal(realp);
133:   }
134:   return(0);
135: }

139: /*
140:   BV_IPMatMult - Multiply a vector x by the inner-product matrix, cache the
141:   result in Bx.
142: */
143: PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMult(BV bv,Vec x)
144: {

148:   if (((PetscObject)x)->id != bv->xid || ((PetscObject)x)->state != bv->xstate) {
149:     MatMult(bv->matrix,x,bv->Bx);
150:     bv->xid = ((PetscObject)x)->id;
151:     bv->xstate = ((PetscObject)x)->state;
152:   }
153:   return(0);
154: }

158: /*
159:   BV_AllocateCachedBV - Allocate auxiliary BV required for BVApplyMatrixBV if not available.
160: */
161: PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCachedBV(BV V)
162: {

166:   if (!V->cached) {
167:     BVCreate(PetscObjectComm((PetscObject)V),&V->cached);
168:     BVSetSizesFromVec(V->cached,V->t,V->m);
169:     BVSetType(V->cached,((PetscObject)V)->type_name);
170:     BVSetOrthogonalization(V->cached,V->orthog_type,V->orthog_ref,V->orthog_eta,V->orthog_block);
171:   }
172:   return(0);
173: }

177: /*
178:   BV_IPMatMultBV - Multiply BV by the inner-product matrix, cache the
179:   result internally in bv->cached.
180: */
181: PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMultBV(BV bv)
182: {

186:   BV_AllocateCachedBV(bv);
187:   BVSetActiveColumns(bv->cached,bv->l,bv->k);
188:   if (((PetscObject)bv)->state != bv->bvstate) {
189:     if (bv->matrix) {
190:       BVMatMult(bv,bv->matrix,bv->cached);
191:     } else {
192:       BVCopy(bv,bv->cached);
193:     }
194:     bv->bvstate = ((PetscObject)bv)->state;
195:   }
196:   return(0);
197: }

201: /*
202:   BV_AllocateCoeffs - Allocate orthogonalization coefficients if not done already.
203: */
204: PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCoeffs(BV bv)
205: {

209:   if (!bv->h) {
210:     PetscMalloc2(bv->nc+bv->m,&bv->h,bv->nc+bv->m,&bv->c);
211:     PetscLogObjectMemory((PetscObject)bv,2*bv->m*sizeof(PetscScalar));
212:   }
213:   return(0);
214: }

218: /*
219:   BV_AllocateSignature - Allocate signature coefficients if not done already.
220: */
221: PETSC_STATIC_INLINE PetscErrorCode BV_AllocateSignature(BV bv)
222: {
224:   PetscInt       i;

227:   if (bv->indef && !bv->omega) {
228:     PetscMalloc1(bv->nc+bv->m,&bv->omega);
229:     PetscLogObjectMemory((PetscObject)bv,bv->m*sizeof(PetscReal));
230:     for (i=-bv->nc;i<bv->m;i++) bv->omega[i] = 1.0;
231:   }
232:   return(0);
233: }

237: /*
238:   BV_AllocateMatMult - Allocate auxiliary matrices required for BVMatMult if not available.
239: */
240: PETSC_STATIC_INLINE PetscErrorCode BV_AllocateMatMult(BV bv,Mat A,PetscInt m)
241: {
243:   PetscObjectId  Aid;
244:   PetscBool      create=PETSC_FALSE;
245:   PetscInt       cols;

248:   if (!bv->B) create=PETSC_TRUE;
249:   else {
250:     MatGetSize(bv->B,NULL,&cols);
251:     PetscObjectGetId((PetscObject)A,&Aid);
252:     if (cols!=m || bv->Aid!=Aid) {
253:       MatDestroy(&bv->B);
254:       MatDestroy(&bv->C);
255:       create=PETSC_TRUE;
256:     }
257:   }
258:   if (create) {
259:     MatCreateDense(PetscObjectComm((PetscObject)bv),bv->n,PETSC_DECIDE,bv->N,m,NULL,&bv->B);
260:     PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->B);
261:     MatAssemblyBegin(bv->B,MAT_FINAL_ASSEMBLY);
262:     MatAssemblyEnd(bv->B,MAT_FINAL_ASSEMBLY);
263:   }
264:   return(0);
265: }

267: /*
268:   BVAvailableVec: First (0) or second (1) vector available for
269:   getcolumn operation (or -1 if both vectors already fetched).
270: */
271: #define BVAvailableVec (((bv->ci[0]==-bv->nc-1)? 0: (bv->ci[1]==-bv->nc-1)? 1: -1))

273: /*
274:     Macros to test valid BV arguments
275: */
276: #if !defined(PETSC_USE_DEBUG)

278: #define BVCheckSizes(h,arg) do {} while (0)

280: #else

282: #define BVCheckSizes(h,arg) \
283:   do { \
284:     if (!h->m) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"BV sizes have not been defined: Parameter #%d",arg); \
285:   } while (0)

287: #endif

289: PETSC_INTERN PetscErrorCode BVView_Vecs(BV,PetscViewer);

291: PETSC_INTERN PetscErrorCode BVAllocateWork_Private(BV,PetscInt);

293: PETSC_INTERN PetscErrorCode BVMult_BLAS_Private(BV,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar,const PetscScalar*,const PetscScalar*,PetscScalar,PetscScalar*);
294: PETSC_INTERN PetscErrorCode BVMultVec_BLAS_Private(BV,PetscInt,PetscInt,PetscScalar,const PetscScalar*,const PetscScalar*,PetscScalar,PetscScalar*);
295: PETSC_INTERN PetscErrorCode BVMultInPlace_BLAS_Private(BV,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar*,const PetscScalar*,PetscBool);
296: PETSC_INTERN PetscErrorCode BVMultInPlace_Vecs_Private(BV,PetscInt,PetscInt,PetscInt,Vec*,const PetscScalar*,PetscBool);
297: PETSC_INTERN PetscErrorCode BVAXPY_BLAS_Private(BV,PetscInt,PetscInt,PetscScalar,const PetscScalar*,PetscScalar,PetscScalar*);
298: PETSC_INTERN PetscErrorCode BVDot_BLAS_Private(BV,PetscInt,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,PetscScalar*,PetscBool);
299: PETSC_INTERN PetscErrorCode BVDotVec_BLAS_Private(BV,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,PetscScalar*,PetscBool);
300: PETSC_INTERN PetscErrorCode BVScale_BLAS_Private(BV,PetscInt,PetscScalar*,PetscScalar);
301: PETSC_INTERN PetscErrorCode BVNorm_LAPACK_Private(BV,PetscInt,PetscInt,const PetscScalar*,NormType,PetscReal*,PetscBool);
302: PETSC_INTERN PetscErrorCode BVOrthogonalize_LAPACK_Private(BV,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscBool);

304: #endif
slepc-3.7.4/include/slepc/private/fnimpl.h0000644000175000017500000001006013107004621020021 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_FNIMPL) #define _FNIMPL #include #include PETSC_EXTERN PetscBool FNRegisterAllCalled; PETSC_EXTERN PetscErrorCode FNRegisterAll(void); PETSC_EXTERN PetscLogEvent FN_Evaluate; typedef struct _FNOps *FNOps; struct _FNOps { PetscErrorCode (*evaluatefunction)(FN,PetscScalar,PetscScalar*); PetscErrorCode (*evaluatederivative)(FN,PetscScalar,PetscScalar*); PetscErrorCode (*evaluatefunctionmat)(FN,Mat,Mat); PetscErrorCode (*evaluatefunctionmatsym)(FN,Mat,Mat); PetscErrorCode (*evaluatefunctionmatvec)(FN,Mat,Vec); PetscErrorCode (*evaluatefunctionmatvecsym)(FN,Mat,Vec); PetscErrorCode (*setfromoptions)(PetscOptionItems*,FN); PetscErrorCode (*view)(FN,PetscViewer); PetscErrorCode (*duplicate)(FN,MPI_Comm,FN*); PetscErrorCode (*destroy)(FN); }; #define FN_MAX_W 6 struct _p_FN { PETSCHEADER(struct _FNOps); /*------------------------- User parameters --------------------------*/ PetscScalar alpha; /* inner scaling (argument) */ PetscScalar beta; /* outer scaling (result) */ /*---------------------- Cached data and workspace -------------------*/ Mat W[FN_MAX_W]; /* workspace matrices */ PetscInt nw; /* number of allocated W matrices */ PetscInt cw; /* current W matrix */ void *data; }; #undef __FUNCT__ #define __FUNCT__ "FN_AllocateWorkMat" /* FN_AllocateWorkMat - Allocate a work Mat of the same dimension of A and copy its contents. The work matrix is returned in M and should be freed with FN_FreeWorkMat(). */ PETSC_STATIC_INLINE PetscErrorCode FN_AllocateWorkMat(FN fn,Mat A,Mat *M) { PetscErrorCode ierr; PetscInt n,na; PetscBool create=PETSC_FALSE; PetscFunctionBegin; *M = NULL; if (fn->cw==FN_MAX_W) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Too many requested work matrices %D",fn->cw); if (fn->nw<=fn->cw) { create=PETSC_TRUE; fn->nw++; } else { ierr = MatGetSize(fn->W[fn->cw],&n,NULL);CHKERRQ(ierr); ierr = MatGetSize(A,&na,NULL);CHKERRQ(ierr); if (n!=na) { ierr = MatDestroy(&fn->W[fn->cw]);CHKERRQ(ierr); create=PETSC_TRUE; } } if (create) { ierr = MatDuplicate(A,MAT_COPY_VALUES,&fn->W[fn->cw]);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)fn,(PetscObject)fn->W[fn->cw]);CHKERRQ(ierr); } else { ierr = MatCopy(A,fn->W[fn->cw],SAME_NONZERO_PATTERN);CHKERRQ(ierr); } *M = fn->W[fn->cw]; fn->cw++; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FN_FreeWorkMat" /* FN_FreeWorkMat - Release a work matrix created with FN_AllocateWorkMat(). */ PETSC_STATIC_INLINE PetscErrorCode FN_FreeWorkMat(FN fn,Mat *M) { PetscFunctionBegin; if (!fn->cw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"There are no work matrices"); fn->cw--; if (fn->W[fn->cw]!=*M) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Work matrices must be freed in the reverse order of their creation"); *M = NULL; PetscFunctionReturn(0); } PETSC_INTERN PetscErrorCode SlepcMatDenseSqrt(PetscBLASInt,PetscScalar*,PetscBLASInt); PETSC_INTERN PetscErrorCode SlepcSchurParlettSqrt(PetscBLASInt,PetscScalar*,PetscBLASInt,PetscBool); #endif slepc-3.7.4/include/slepc/private/nepimpl.h.html0000644000175000017500000005035713107004621021160 0ustar jromanjroman
Actual source code: nepimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_NEPIMPL)
 23: #define _NEPIMPL

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

 28: PETSC_EXTERN PetscBool NEPRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode NEPRegisterAll(void);
 30: PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;

 32: typedef struct _NEPOps *NEPOps;

 34: struct _NEPOps {
 35:   PetscErrorCode (*solve)(NEP);
 36:   PetscErrorCode (*setup)(NEP);
 37:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,NEP);
 38:   PetscErrorCode (*publishoptions)(NEP);
 39:   PetscErrorCode (*destroy)(NEP);
 40:   PetscErrorCode (*reset)(NEP);
 41:   PetscErrorCode (*view)(NEP,PetscViewer);
 42:   PetscErrorCode (*computevectors)(NEP);
 43: };

 45: /*
 46:      Maximum number of monitors you can run with a single NEP
 47: */
 48: #define MAXNEPMONITORS 5

 50: typedef enum { NEP_STATE_INITIAL,
 51:                NEP_STATE_SETUP,
 52:                NEP_STATE_SOLVED,
 53:                NEP_STATE_EIGENVECTORS } NEPStateType;

 55: /*
 56:      How the problem function T(lambda) has been defined by the user
 57:      - Callback: one callback to build the function matrix, another one for the Jacobian
 58:      - Split: in split form sum_j(A_j*f_j(lambda))
 59:      - Derivatives: a single callback for all the derivatives (including the 0th derivative)
 60: */
 61: typedef enum { NEP_USER_INTERFACE_CALLBACK=1,
 62:                NEP_USER_INTERFACE_SPLIT,
 63:                NEP_USER_INTERFACE_DERIVATIVES } NEPUserInterface;

 65: /*
 66:    Defines the NEP data structure.
 67: */
 68: struct _p_NEP {
 69:   PETSCHEADER(struct _NEPOps);
 70:   /*------------------------- User parameters ---------------------------*/
 71:   PetscInt       max_it;           /* maximum number of iterations */
 72:   PetscInt       nev;              /* number of eigenvalues to compute */
 73:   PetscInt       ncv;              /* number of basis vectors */
 74:   PetscInt       mpd;              /* maximum dimension of projected problem */
 75:   PetscInt       nini;             /* number of initial vectors (negative means not copied yet) */
 76:   PetscScalar    target;           /* target value */
 77:   PetscReal      tol;              /* tolerance */
 78:   NEPConv        conv;             /* convergence test */
 79:   NEPStop        stop;             /* stopping test */
 80:   NEPWhich       which;            /* which part of the spectrum to be sought */
 81:   NEPRefine      refine;           /* type of refinement to be applied after solve */
 82:   PetscInt       npart;            /* number of partitions of the communicator */
 83:   PetscReal      rtol;             /* tolerance for refinement */
 84:   PetscInt       rits;             /* number of iterations of the refinement method */
 85:   NEPRefineScheme scheme;          /* scheme for solving linear systems within refinement */
 86:   PetscBool      trackall;         /* whether all the residuals must be computed */

 88:   /*-------------- User-provided functions and contexts -----------------*/
 89:   PetscErrorCode (*computefunction)(NEP,PetscScalar,Mat,Mat,void*);
 90:   PetscErrorCode (*computejacobian)(NEP,PetscScalar,Mat,void*);
 91:   void           *functionctx;
 92:   void           *jacobianctx;
 93:   PetscErrorCode (*computederivatives)(NEP,PetscScalar,PetscInt,Mat,void*);
 94:   void           *derivativesctx;
 95:   PetscErrorCode (*converged)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
 96:   PetscErrorCode (*convergeddestroy)(void*);
 97:   PetscErrorCode (*stopping)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*);
 98:   PetscErrorCode (*stoppingdestroy)(void*);
 99:   void           *convergedctx;
100:   void           *stoppingctx;
101:   PetscErrorCode (*monitor[MAXNEPMONITORS])(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
102:   PetscErrorCode (*monitordestroy[MAXNEPMONITORS])(void**);
103:   void           *monitorcontext[MAXNEPMONITORS];
104:   PetscInt       numbermonitors;

106:   /*----------------- Child objects and working data -------------------*/
107:   DS             ds;               /* direct solver object */
108:   BV             V;                /* set of basis vectors and computed eigenvectors */
109:   RG             rg;               /* optional region for filtering */
110:   SlepcSC        sc;               /* sorting criterion data */
111:   Mat            function;         /* function matrix */
112:   Mat            function_pre;     /* function matrix (preconditioner) */
113:   Mat            jacobian;         /* Jacobian matrix */
114:   Mat            derivatives;      /* derivatives matrix */
115:   Mat            *A;               /* matrix coefficients of split form */
116:   FN             *f;               /* matrix functions of split form */
117:   PetscInt       nt;               /* number of terms in split form */
118:   MatStructure   mstr;             /* pattern of split matrices */
119:   Vec            *IS;              /* references to user-provided initial space */
120:   PetscScalar    *eigr,*eigi;      /* real and imaginary parts of eigenvalues */
121:   PetscReal      *errest;          /* error estimates */
122:   PetscInt       *perm;            /* permutation for eigenvalue ordering */
123:   PetscInt       nwork;            /* number of work vectors */
124:   Vec            *work;            /* work vectors */
125:   KSP            refineksp;        /* ksp used in refinement */
126:   PetscSubcomm   refinesubc;       /* context for sub-communicators */
127:   void           *data;            /* placeholder for solver-specific stuff */

129:   /* ----------------------- Status variables --------------------------*/
130:   NEPStateType   state;            /* initial -> setup -> solved -> eigenvectors */
131:   PetscInt       nconv;            /* number of converged eigenvalues */
132:   PetscInt       its;              /* number of iterations so far computed */
133:   PetscInt       n,nloc;           /* problem dimensions (global, local) */
134:   PetscReal      *nrma;            /* computed matrix norms */
135:   NEPUserInterface fui;            /* how the user has defined the nonlinear operator */
136:   NEPConvergedReason reason;
137: };

139: /*
140:     Macros to test valid NEP arguments
141: */
142: #if !defined(PETSC_USE_DEBUG)

144: #define NEPCheckProblem(h,arg) do {} while (0)
145: #define NEPCheckCallback(h,arg) do {} while (0)
146: #define NEPCheckSplit(h,arg) do {} while (0)
147: #define NEPCheckDerivatives(h,arg) do {} while (0)
148: #define NEPCheckSolved(h,arg) do {} while (0)

150: #else

152: #define NEPCheckProblem(h,arg) \
153:   do { \
154:     if (!(h->fui)) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"The nonlinear eigenproblem has not been specified yet. Parameter #%d",arg); \
155:   } while (0)

157: #define NEPCheckCallback(h,arg) \
158:   do { \
159:     if (h->fui!=NEP_USER_INTERFACE_CALLBACK) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"This operation requires the nonlinear eigenproblem specified with callbacks. Parameter #%d",arg); \
160:   } while (0)

162: #define NEPCheckSplit(h,arg) \
163:   do { \
164:     if (h->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"This operation requires the nonlinear eigenproblem in split form. Parameter #%d",arg); \
165:   } while (0)

167: #define NEPCheckDerivatives(h,arg) \
168:   do { \
169:     if (h->fui!=NEP_USER_INTERFACE_DERIVATIVES) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"This operation requires the nonlinear eigenproblem specified with derivatives callback. Parameter #%d",arg); \
170:   } while (0)

172: #define NEPCheckSolved(h,arg) \
173:   do { \
174:     if (h->state<NEP_STATE_SOLVED) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call NEPSolve() first: Parameter #%d",arg); \
175:   } while (0)

177: #endif

179: PETSC_INTERN PetscErrorCode NEPSetDimensions_Default(NEP,PetscInt,PetscInt*,PetscInt*);
180: PETSC_INTERN PetscErrorCode NEPComputeVectors(NEP);
181: PETSC_INTERN PetscErrorCode NEPReset_Problem(NEP);
182: PETSC_INTERN PetscErrorCode NEPGetDefaultShift(NEP,PetscScalar*);
183: PETSC_INTERN PetscErrorCode NEPComputeVectors_Schur(NEP);
184: PETSC_INTERN PetscErrorCode NEPComputeResidualNorm_Private(NEP,PetscScalar,Vec,Vec*,PetscReal*);
185: PETSC_INTERN PetscErrorCode NEPNewtonRefinementSimple(NEP,PetscInt*,PetscReal,PetscInt);

187: #endif
slepc-3.7.4/include/slepc/private/bvimpl.h0000644000175000017500000003004513107004621020032 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) , Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(_BVIMPL) #define _BVIMPL #include #include PETSC_EXTERN PetscBool BVRegisterAllCalled; PETSC_EXTERN PetscErrorCode BVRegisterAll(void); PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject; typedef struct _BVOps *BVOps; struct _BVOps { PetscErrorCode (*mult)(BV,PetscScalar,PetscScalar,BV,Mat); PetscErrorCode (*multvec)(BV,PetscScalar,PetscScalar,Vec,PetscScalar*); PetscErrorCode (*multinplace)(BV,Mat,PetscInt,PetscInt); PetscErrorCode (*multinplacetrans)(BV,Mat,PetscInt,PetscInt); PetscErrorCode (*dot)(BV,BV,Mat); PetscErrorCode (*dotvec)(BV,Vec,PetscScalar*); PetscErrorCode (*dotvec_local)(BV,Vec,PetscScalar*); PetscErrorCode (*dotvec_begin)(BV,Vec,PetscScalar*); PetscErrorCode (*dotvec_end)(BV,Vec,PetscScalar*); PetscErrorCode (*scale)(BV,PetscInt,PetscScalar); PetscErrorCode (*norm)(BV,PetscInt,NormType,PetscReal*); PetscErrorCode (*norm_local)(BV,PetscInt,NormType,PetscReal*); PetscErrorCode (*norm_begin)(BV,PetscInt,NormType,PetscReal*); PetscErrorCode (*norm_end)(BV,PetscInt,NormType,PetscReal*); PetscErrorCode (*orthogonalize)(BV,Mat); PetscErrorCode (*matmult)(BV,Mat,BV); PetscErrorCode (*copy)(BV,BV); PetscErrorCode (*resize)(BV,PetscInt,PetscBool); PetscErrorCode (*getcolumn)(BV,PetscInt,Vec*); PetscErrorCode (*restorecolumn)(BV,PetscInt,Vec*); PetscErrorCode (*getarray)(BV,PetscScalar**); PetscErrorCode (*restorearray)(BV,PetscScalar**); PetscErrorCode (*getarrayread)(BV,const PetscScalar**); PetscErrorCode (*restorearrayread)(BV,const PetscScalar**); PetscErrorCode (*duplicate)(BV,BV*); PetscErrorCode (*create)(BV); PetscErrorCode (*setfromoptions)(PetscOptionItems*,BV); PetscErrorCode (*view)(BV,PetscViewer); PetscErrorCode (*destroy)(BV); }; struct _p_BV { PETSCHEADER(struct _BVOps); /*------------------------- User parameters --------------------------*/ Vec t; /* template vector */ PetscInt n,N; /* dimensions of vectors (local, global) */ PetscInt m; /* number of vectors */ PetscInt l; /* number of leading columns */ PetscInt k; /* number of active columns */ PetscInt nc; /* number of constraints */ BVOrthogType orthog_type; /* the method of vector orthogonalization */ BVOrthogRefineType orthog_ref; /* refinement method */ PetscReal orthog_eta; /* refinement threshold */ BVOrthogBlockType orthog_block; /* the method of block orthogonalization */ Mat matrix; /* inner product matrix */ PetscBool indef; /* matrix is indefinite */ BVMatMultType vmm; /* version of matmult operation */ /*---------------------- Cached data and workspace -------------------*/ Vec Bx; /* result of matrix times a vector x */ PetscObjectId xid; /* object id of vector x */ PetscObjectState xstate; /* state of vector x */ Vec cv[2]; /* column vectors obtained with BVGetColumn() */ PetscInt ci[2]; /* column indices of obtained vectors */ PetscObjectState st[2]; /* state of obtained vectors */ PetscObjectId id[2]; /* object id of obtained vectors */ PetscScalar *h,*c; /* orthogonalization coefficients */ PetscReal *omega; /* signature matrix values for indefinite case */ Mat B,C; /* auxiliary dense matrices for matmult operation */ PetscObjectId Aid; /* object id of matrix A of matmult operation */ PetscBool defersfo; /* deferred call to setfromoptions */ BV cached; /* cached BV to store result of matrix times BV */ PetscObjectState bvstate; /* state of BV when BVApplyMatrixBV() was called */ PetscRandom rand; /* random number generator */ PetscBool rrandom; /* reproducible random vectors */ PetscScalar *work; PetscInt lwork; void *data; }; #undef __FUNCT__ #define __FUNCT__ "BV_SafeSqrt" /* BV_SafeSqrt - Computes the square root of a scalar value alpha, which is assumed to be z'*B*z. The result is if definite inner product: res = sqrt(alpha) if indefinite inner product: res = sgn(alpha)*sqrt(abs(alpha)) */ PETSC_STATIC_INLINE PetscErrorCode BV_SafeSqrt(BV bv,PetscScalar alpha,PetscReal *res) { PetscErrorCode ierr; PetscReal absal,realp; PetscFunctionBegin; absal = PetscAbsScalar(alpha); realp = PetscRealPart(alpha); if (absalPETSC_MACHINE_EPSILON) SETERRQ(PetscObjectComm((PetscObject)bv),1,"The inner product is not well defined: nonzero imaginary part"); #endif if (bv->indef) { *res = (realp<0.0)? -PetscSqrtReal(-realp): PetscSqrtReal(realp); } else { if (realp<0.0) SETERRQ(PetscObjectComm((PetscObject)bv),1,"The inner product is not well defined: indefinite matrix"); *res = PetscSqrtReal(realp); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BV_IPMatMult" /* BV_IPMatMult - Multiply a vector x by the inner-product matrix, cache the result in Bx. */ PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMult(BV bv,Vec x) { PetscErrorCode ierr; PetscFunctionBegin; if (((PetscObject)x)->id != bv->xid || ((PetscObject)x)->state != bv->xstate) { ierr = MatMult(bv->matrix,x,bv->Bx);CHKERRQ(ierr); bv->xid = ((PetscObject)x)->id; bv->xstate = ((PetscObject)x)->state; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BV_AllocateCachedBV" /* BV_AllocateCachedBV - Allocate auxiliary BV required for BVApplyMatrixBV if not available. */ PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCachedBV(BV V) { PetscErrorCode ierr; PetscFunctionBegin; if (!V->cached) { ierr = BVCreate(PetscObjectComm((PetscObject)V),&V->cached);CHKERRQ(ierr); ierr = BVSetSizesFromVec(V->cached,V->t,V->m);CHKERRQ(ierr); ierr = BVSetType(V->cached,((PetscObject)V)->type_name);CHKERRQ(ierr); ierr = BVSetOrthogonalization(V->cached,V->orthog_type,V->orthog_ref,V->orthog_eta,V->orthog_block);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BV_IPMatMultBV" /* BV_IPMatMultBV - Multiply BV by the inner-product matrix, cache the result internally in bv->cached. */ PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMultBV(BV bv) { PetscErrorCode ierr; PetscFunctionBegin; ierr = BV_AllocateCachedBV(bv);CHKERRQ(ierr); ierr = BVSetActiveColumns(bv->cached,bv->l,bv->k);CHKERRQ(ierr); if (((PetscObject)bv)->state != bv->bvstate) { if (bv->matrix) { ierr = BVMatMult(bv,bv->matrix,bv->cached);CHKERRQ(ierr); } else { ierr = BVCopy(bv,bv->cached);CHKERRQ(ierr); } bv->bvstate = ((PetscObject)bv)->state; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BV_AllocateCoeffs" /* BV_AllocateCoeffs - Allocate orthogonalization coefficients if not done already. */ PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCoeffs(BV bv) { PetscErrorCode ierr; PetscFunctionBegin; if (!bv->h) { ierr = PetscMalloc2(bv->nc+bv->m,&bv->h,bv->nc+bv->m,&bv->c);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)bv,2*bv->m*sizeof(PetscScalar));CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BV_AllocateSignature" /* BV_AllocateSignature - Allocate signature coefficients if not done already. */ PETSC_STATIC_INLINE PetscErrorCode BV_AllocateSignature(BV bv) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; if (bv->indef && !bv->omega) { ierr = PetscMalloc1(bv->nc+bv->m,&bv->omega);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)bv,bv->m*sizeof(PetscReal));CHKERRQ(ierr); for (i=-bv->nc;im;i++) bv->omega[i] = 1.0; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BV_AllocateMatMult" /* BV_AllocateMatMult - Allocate auxiliary matrices required for BVMatMult if not available. */ PETSC_STATIC_INLINE PetscErrorCode BV_AllocateMatMult(BV bv,Mat A,PetscInt m) { PetscErrorCode ierr; PetscObjectId Aid; PetscBool create=PETSC_FALSE; PetscInt cols; PetscFunctionBegin; if (!bv->B) create=PETSC_TRUE; else { ierr = MatGetSize(bv->B,NULL,&cols);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)A,&Aid);CHKERRQ(ierr); if (cols!=m || bv->Aid!=Aid) { ierr = MatDestroy(&bv->B);CHKERRQ(ierr); ierr = MatDestroy(&bv->C);CHKERRQ(ierr); create=PETSC_TRUE; } } if (create) { ierr = MatCreateDense(PetscObjectComm((PetscObject)bv),bv->n,PETSC_DECIDE,bv->N,m,NULL,&bv->B);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->B);CHKERRQ(ierr); ierr = MatAssemblyBegin(bv->B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(bv->B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); } PetscFunctionReturn(0); } /* BVAvailableVec: First (0) or second (1) vector available for getcolumn operation (or -1 if both vectors already fetched). */ #define BVAvailableVec (((bv->ci[0]==-bv->nc-1)? 0: (bv->ci[1]==-bv->nc-1)? 1: -1)) /* Macros to test valid BV arguments */ #if !defined(PETSC_USE_DEBUG) #define BVCheckSizes(h,arg) do {} while (0) #else #define BVCheckSizes(h,arg) \ do { \ if (!h->m) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"BV sizes have not been defined: Parameter #%d",arg); \ } while (0) #endif PETSC_INTERN PetscErrorCode BVView_Vecs(BV,PetscViewer); PETSC_INTERN PetscErrorCode BVAllocateWork_Private(BV,PetscInt); PETSC_INTERN PetscErrorCode BVMult_BLAS_Private(BV,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar,const PetscScalar*,const PetscScalar*,PetscScalar,PetscScalar*); PETSC_INTERN PetscErrorCode BVMultVec_BLAS_Private(BV,PetscInt,PetscInt,PetscScalar,const PetscScalar*,const PetscScalar*,PetscScalar,PetscScalar*); PETSC_INTERN PetscErrorCode BVMultInPlace_BLAS_Private(BV,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar*,const PetscScalar*,PetscBool); PETSC_INTERN PetscErrorCode BVMultInPlace_Vecs_Private(BV,PetscInt,PetscInt,PetscInt,Vec*,const PetscScalar*,PetscBool); PETSC_INTERN PetscErrorCode BVAXPY_BLAS_Private(BV,PetscInt,PetscInt,PetscScalar,const PetscScalar*,PetscScalar,PetscScalar*); PETSC_INTERN PetscErrorCode BVDot_BLAS_Private(BV,PetscInt,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,PetscScalar*,PetscBool); PETSC_INTERN PetscErrorCode BVDotVec_BLAS_Private(BV,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,PetscScalar*,PetscBool); PETSC_INTERN PetscErrorCode BVScale_BLAS_Private(BV,PetscInt,PetscScalar*,PetscScalar); PETSC_INTERN PetscErrorCode BVNorm_LAPACK_Private(BV,PetscInt,PetscInt,const PetscScalar*,NormType,PetscReal*,PetscBool); PETSC_INTERN PetscErrorCode BVOrthogonalize_LAPACK_Private(BV,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscBool); #endif slepc-3.7.4/include/slepc/private/stimpl.h.html0000644000175000017500000002750013107004621021016 0ustar jromanjroman
Actual source code: stimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) , 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(_STIMPL)
 23: #define _STIMPL

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

 28: PETSC_EXTERN PetscBool STRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode STRegisterAll(void);
 30: PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;

 32: typedef struct _STOps *STOps;

 34: struct _STOps {
 35:   PetscErrorCode (*setup)(ST);
 36:   PetscErrorCode (*apply)(ST,Vec,Vec);
 37:   PetscErrorCode (*getbilinearform)(ST,Mat*);
 38:   PetscErrorCode (*applytrans)(ST,Vec,Vec);
 39:   PetscErrorCode (*setshift)(ST,PetscScalar);
 40:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,ST);
 41:   PetscErrorCode (*postsolve)(ST);
 42:   PetscErrorCode (*backtransform)(ST,PetscInt,PetscScalar*,PetscScalar*);
 43:   PetscErrorCode (*destroy)(ST);
 44:   PetscErrorCode (*reset)(ST);
 45:   PetscErrorCode (*view)(ST,PetscViewer);
 46:   PetscErrorCode (*checknullspace)(ST,BV);
 47: };

 49: /*
 50:      'Updated' state means STSetUp must be called because matrices have been
 51:      modified, but the pattern is the same (hence reuse symbolic factorization)
 52: */
 53: typedef enum { ST_STATE_INITIAL,
 54:                ST_STATE_SETUP,
 55:                ST_STATE_UPDATED } STStateType;

 57: struct _p_ST {
 58:   PETSCHEADER(struct _STOps);
 59:   /*------------------------- User parameters --------------------------*/
 60:   Mat              *A;               /* matrices that define the eigensystem */
 61:   PetscObjectState *Astate;          /* state (to identify the original matrices) */
 62:   Mat              *T;               /* matrices resulting from transformation */
 63:   Mat              P;                /* matrix from which preconditioner is built */
 64:   PetscInt         nmat;             /* number of matrices */
 65:   PetscScalar      sigma;            /* value of the shift */
 66:   PetscBool        sigma_set;        /* whether the user provided the shift or not */
 67:   PetscScalar      defsigma;         /* default value of the shift */
 68:   STMatMode        shift_matrix;
 69:   MatStructure     str;              /* whether matrices have the same pattern or not */
 70:   PetscBool        transform;        /* whether transformed matrices are computed */

 72:   /*------------------------- Misc data --------------------------*/
 73:   KSP              ksp;
 74:   Vec              w;                /* work vector used in apply operation */
 75:   Vec              D;                /* diagonal matrix for balancing */
 76:   Vec              wb;               /* balancing requires an extra work vector */
 77:   void             *data;
 78:   STStateType      state;            /* initial -> setup -> with updated matrices */
 79: };

 83: /*
 84:   ST_AllocateWorkVec - Allocate work vector for the STApply operation.
 85: */
 86: PETSC_STATIC_INLINE PetscErrorCode ST_AllocateWorkVec(ST st)
 87: {

 91:   if (!st->w) {
 92:     MatCreateVecs(st->A[0],&st->w,NULL);
 93:     PetscLogObjectParent((PetscObject)st,(PetscObject)st->w);
 94:   }
 95:   return(0);
 96: }

 98: /*
 99:     Macros to test valid ST arguments
100: */
101: #if !defined(PETSC_USE_DEBUG)

103: #define STCheckMatrices(h,arg) do {} while (0)

105: #else

107: #define STCheckMatrices(h,arg) \
108:   do { \
109:     if (!h->A) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"ST matrices have not been set: Parameter #%d",arg); \
110:   } while (0)

112: #endif

114: PETSC_INTERN PetscErrorCode STGetBilinearForm_Default(ST,Mat*);
115: PETSC_INTERN PetscErrorCode STCheckNullSpace_Default(ST,BV);
116: PETSC_INTERN PetscErrorCode STMatShellCreate(ST,PetscScalar,PetscInt,PetscInt*,PetscScalar*,Mat*);
117: PETSC_INTERN PetscErrorCode STMatShellShift(Mat,PetscScalar);
118: PETSC_INTERN PetscErrorCode STMatSetHermitian(ST,Mat);
119: PETSC_INTERN PetscErrorCode STCheckFactorPackage(ST);
120: PETSC_INTERN PetscErrorCode STMatMAXPY_Private(ST,PetscScalar,PetscScalar,PetscInt,PetscScalar*,PetscBool,Mat*);
121: PETSC_INTERN PetscErrorCode STCoeffs_Monomial(ST,PetscScalar*);

123: #endif
slepc-3.7.4/include/slepc/private/dsimpl.h.html0000644000175000017500000004001213107004621020767 0ustar jromanjroman
Actual source code: dsimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_DSIMPL)
 23: #define _DSIMPL

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

 28: PETSC_EXTERN PetscBool DSRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode DSRegisterAll(void);
 30: PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other;
 31: PETSC_INTERN const char *DSMatName[];

 33: typedef struct _DSOps *DSOps;

 35: struct _DSOps {
 36:   PetscErrorCode (*allocate)(DS,PetscInt);
 37:   PetscErrorCode (*view)(DS,PetscViewer);
 38:   PetscErrorCode (*vectors)(DS,DSMatType,PetscInt*,PetscReal*);
 39:   PetscErrorCode (*solve[DS_MAX_SOLVE])(DS,PetscScalar*,PetscScalar*);
 40:   PetscErrorCode (*sort)(DS,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*);
 41:   PetscErrorCode (*truncate)(DS,PetscInt);
 42:   PetscErrorCode (*update)(DS);
 43:   PetscErrorCode (*cond)(DS,PetscReal*);
 44:   PetscErrorCode (*transharm)(DS,PetscScalar,PetscReal,PetscBool,PetscScalar*,PetscReal*);
 45:   PetscErrorCode (*transrks)(DS,PetscScalar);
 46:   PetscErrorCode (*normalize)(DS,DSMatType,PetscInt);
 47:   PetscErrorCode (*destroy)(DS);
 48: };

 50: struct _p_DS {
 51:   PETSCHEADER(struct _DSOps);
 52:   /*------------------------- User parameters --------------------------*/
 53:   DSStateType    state;              /* the current state */
 54:   PetscInt       method;             /* identifies the variant to be used */
 55:   PetscBool      compact;            /* whether the matrices are stored in compact form */
 56:   PetscBool      refined;            /* get refined vectors instead of regular vectors */
 57:   PetscBool      extrarow;           /* assume the matrix dimension is (n+1) x n */
 58:   PetscInt       ld;                 /* leading dimension */
 59:   PetscInt       l;                  /* number of locked (inactive) leading columns */
 60:   PetscInt       n;                  /* current dimension */
 61:   PetscInt       m;                  /* current column dimension (for SVD only) */
 62:   PetscInt       k;                  /* intermediate dimension (e.g. position of arrow) */
 63:   PetscInt       t;                  /* length of decomposition when it was truncated */
 64:   PetscInt       bs;                 /* block size */
 65:   SlepcSC        sc;                 /* sorting criterion */

 67:   /*----------------- Status variables and working data ----------------*/
 68:   PetscScalar    *mat[DS_NUM_MAT];   /* the matrices */
 69:   PetscReal      *rmat[DS_NUM_MAT];  /* the matrices (real) */
 70:   Mat            omat[DS_NUM_MAT];   /* the matrices (PETSc object) */
 71:   PetscInt       *perm;              /* permutation */
 72:   void           *data;              /* placeholder for solver-specific stuff */
 73:   PetscScalar    *work;
 74:   PetscReal      *rwork;
 75:   PetscBLASInt   *iwork;
 76:   PetscInt       lwork,lrwork,liwork;
 77: };

 79: /*
 80:     Macros to test valid DS arguments
 81: */
 82: #if !defined(PETSC_USE_DEBUG)

 84: #define DSCheckAlloc(h,arg) do {} while (0)
 85: #define DSCheckSolved(h,arg) do {} while (0)

 87: #else

 89: #define DSCheckAlloc(h,arg) \
 90:   do { \
 91:     if (!h->ld) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call DSAllocate() first: Parameter #%d",arg); \
 92:   } while (0)

 94: #define DSCheckSolved(h,arg) \
 95:   do { \
 96:     if (h->state<DS_STATE_CONDENSED) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call DSSolve() first: Parameter #%d",arg); \
 97:   } while (0)

 99: #endif

101: PETSC_INTERN PetscErrorCode DSAllocateMat_Private(DS,DSMatType);
102: PETSC_INTERN PetscErrorCode DSAllocateMatReal_Private(DS,DSMatType);
103: PETSC_INTERN PetscErrorCode DSAllocateWork_Private(DS,PetscInt,PetscInt,PetscInt);
104: PETSC_INTERN PetscErrorCode DSSortEigenvalues_Private(DS,PetscScalar*,PetscScalar*,PetscInt*,PetscBool);
105: PETSC_INTERN PetscErrorCode DSSortEigenvaluesReal_Private(DS,PetscReal*,PetscInt*);
106: PETSC_INTERN PetscErrorCode DSPermuteColumns_Private(DS,PetscInt,PetscInt,DSMatType,PetscInt*);
107: PETSC_INTERN PetscErrorCode DSPermuteRows_Private(DS,PetscInt,PetscInt,DSMatType,PetscInt*);
108: PETSC_INTERN PetscErrorCode DSPermuteBoth_Private(DS,PetscInt,PetscInt,DSMatType,DSMatType,PetscInt*);
109: PETSC_INTERN PetscErrorCode DSCopyMatrix_Private(DS,DSMatType,DSMatType);

111: PETSC_INTERN PetscErrorCode DSGHIEPOrthogEigenv(DS,DSMatType,PetscScalar*,PetscScalar*,PetscBool);
112: PETSC_INTERN PetscErrorCode DSGHIEPComplexEigs(DS,PetscInt,PetscInt,PetscScalar*,PetscScalar*);
113: PETSC_INTERN PetscErrorCode DSGHIEPInverseIteration(DS,PetscScalar*,PetscScalar*);
114: PETSC_INTERN PetscErrorCode DSIntermediate_GHIEP(DS);
115: PETSC_INTERN PetscErrorCode DSSwitchFormat_GHIEP(DS,PetscBool);
116: PETSC_INTERN PetscErrorCode DSGHIEPRealBlocks(DS);

118: PETSC_INTERN PetscErrorCode DSSolve_GHIEP_HZ(DS,PetscScalar*,PetscScalar*);
119: PETSC_INTERN PetscErrorCode DSSolve_GHIEP_DQDS_II(DS,PetscScalar*,PetscScalar*);

121: PETSC_INTERN PetscErrorCode BDC_dibtdc_(const char*,PetscBLASInt,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscBLASInt,PetscBLASInt,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscReal,PetscReal*,PetscReal*,PetscBLASInt,PetscReal*,PetscBLASInt,PetscBLASInt*,PetscBLASInt,PetscBLASInt*,PetscBLASInt);
122: PETSC_INTERN PetscErrorCode BDC_dlaed3m_(const char*,const char*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscReal*,PetscReal*,PetscBLASInt,PetscReal,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
123: PETSC_INTERN PetscErrorCode BDC_dmerg2_(const char*,PetscBLASInt,PetscBLASInt,PetscReal*,PetscReal*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt,PetscReal*,PetscBLASInt,PetscBLASInt,PetscReal*,PetscBLASInt,PetscBLASInt*,PetscReal,PetscBLASInt*,PetscBLASInt);
124: PETSC_INTERN PetscErrorCode BDC_dsbtdc_(const char*,const char*,PetscBLASInt,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscBLASInt,PetscBLASInt,PetscReal*,PetscBLASInt,PetscBLASInt,PetscReal,PetscReal,PetscReal,PetscReal*,PetscReal*,PetscBLASInt,PetscReal*,PetscBLASInt,PetscBLASInt*,PetscBLASInt,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
125: PETSC_INTERN PetscErrorCode BDC_dsrtdf_(PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscReal*,PetscReal*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);

127: #endif
slepc-3.7.4/include/slepc/private/slepcimpl.h.html0000644000175000017500000001523213107004621021475 0ustar jromanjroman
Actual source code: slepcimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_SLEPCIMPL)
 23: #define _SLEPCIMPL

 25: #include <slepcsys.h>
 26: #include <petsc/private/petscimpl.h>

 28: PETSC_INTERN PetscBool SlepcBeganPetsc;

 30: /*@C
 31:     SlepcHeaderCreate - Creates a SLEPc object

 33:     Input Parameters:
 34: +   classid - the classid associated with this object
 35: .   class_name - string name of class; should be static
 36: .   descr - string containing short description; should be static
 37: .   mansec - string indicating section in manual pages; should be static
 38: .   comm - the MPI Communicator
 39: .   destroy - the destroy routine for this object
 40: -   view - the view routine for this object

 42:     Output Parameter:
 43: .   h - the newly created object

 45:     Note:
 46:     This is equivalent to PetscHeaderCreate but makes sure that SlepcInitialize
 47:     has been called.

 49:     Level: developer
 50: @*/
 51: #define SlepcHeaderCreate(h,classid,class_name,descr,mansec,comm,destroy,view) \
 52:     ((!SlepcInitializeCalled && \
 53:     PetscError(comm,__LINE__,PETSC_FUNCTION_NAME,__FILE__,1,PETSC_ERROR_INITIAL, \
 54:     "Must call SlepcInitialize instead of PetscInitialize to use SLEPc classes")) ||  \
 55:     PetscHeaderCreate(h,classid,class_name,descr,mansec,comm,destroy,view))

 57: /* context for monitors of type XXXMonitorConverged */
 58: struct _n_SlepcConvMonitor {
 59:   PetscViewer       viewer;
 60:   PetscViewerFormat format;
 61:   PetscInt          oldnconv;
 62: };

 64: /* Private functions that are shared by several classes */
 65: PETSC_EXTERN PetscErrorCode SlepcBasisReference_Private(PetscInt,Vec*,PetscInt*,Vec**);
 66: PETSC_EXTERN PetscErrorCode SlepcBasisDestroy_Private(PetscInt*,Vec**);

 68: PETSC_INTERN PetscErrorCode SlepcCitationsInitialize(void);
 69: PETSC_INTERN PetscErrorCode SlepcInitialize_DynamicLibraries(void);
 70: PETSC_INTERN PetscErrorCode SlepcInitialize_Packages(void);

 72: #endif
slepc-3.7.4/include/slepc/private/epsimpl.h.html0000644000175000017500000005020113107004621021151 0ustar jromanjroman
Actual source code: epsimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_EPSIMPL)
 23: #define _EPSIMPL

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

 28: PETSC_EXTERN PetscBool EPSRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode EPSRegisterAll(void);
 30: PETSC_EXTERN PetscLogEvent EPS_SetUp,EPS_Solve;

 32: typedef struct _EPSOps *EPSOps;

 34: struct _EPSOps {
 35:   PetscErrorCode (*solve)(EPS);
 36:   PetscErrorCode (*setup)(EPS);
 37:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,EPS);
 38:   PetscErrorCode (*publishoptions)(EPS);
 39:   PetscErrorCode (*destroy)(EPS);
 40:   PetscErrorCode (*reset)(EPS);
 41:   PetscErrorCode (*view)(EPS,PetscViewer);
 42:   PetscErrorCode (*backtransform)(EPS);
 43:   PetscErrorCode (*computevectors)(EPS);
 44: };

 46: /*
 47:      Maximum number of monitors you can run with a single EPS
 48: */
 49: #define MAXEPSMONITORS 5

 51: typedef enum { EPS_STATE_INITIAL,
 52:                EPS_STATE_SETUP,
 53:                EPS_STATE_SOLVED,
 54:                EPS_STATE_EIGENVECTORS } EPSStateType;

 56: /*
 57:    Defines the EPS data structure.
 58: */
 59: struct _p_EPS {
 60:   PETSCHEADER(struct _EPSOps);
 61:   /*------------------------- User parameters ---------------------------*/
 62:   PetscInt       max_it;           /* maximum number of iterations */
 63:   PetscInt       nev;              /* number of eigenvalues to compute */
 64:   PetscInt       ncv;              /* number of basis vectors */
 65:   PetscInt       mpd;              /* maximum dimension of projected problem */
 66:   PetscInt       nini;             /* number of initial vectors (negative means not copied yet) */
 67:   PetscInt       nds;              /* number of basis vectors of deflation space */
 68:   PetscScalar    target;           /* target value */
 69:   PetscReal      tol;              /* tolerance */
 70:   EPSConv        conv;             /* convergence test */
 71:   EPSStop        stop;             /* stopping test */
 72:   EPSWhich       which;            /* which part of the spectrum to be sought */
 73:   PetscReal      inta,intb;        /* interval [a,b] for spectrum slicing */
 74:   EPSProblemType problem_type;     /* which kind of problem to be solved */
 75:   EPSExtraction  extraction;       /* which kind of extraction to be applied */
 76:   EPSBalance     balance;          /* the balancing method */
 77:   PetscInt       balance_its;      /* number of iterations of the balancing method */
 78:   PetscReal      balance_cutoff;   /* cutoff value for balancing */
 79:   PetscBool      trueres;          /* whether the true residual norm must be computed */
 80:   PetscBool      trackall;         /* whether all the residuals must be computed */
 81:   PetscBool      purify;           /* whether eigenvectors need to be purified */

 83:   /*-------------- User-provided functions and contexts -----------------*/
 84:   PetscErrorCode (*converged)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
 85:   PetscErrorCode (*convergeddestroy)(void*);
 86:   PetscErrorCode (*stopping)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*);
 87:   PetscErrorCode (*stoppingdestroy)(void*);
 88:   PetscErrorCode (*arbitrary)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*);
 89:   void           *convergedctx;
 90:   void           *stoppingctx;
 91:   void           *arbitraryctx;
 92:   PetscErrorCode (*monitor[MAXEPSMONITORS])(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
 93:   PetscErrorCode (*monitordestroy[MAXEPSMONITORS])(void**);
 94:   void           *monitorcontext[MAXEPSMONITORS];
 95:   PetscInt       numbermonitors;

 97:   /*----------------- Child objects and working data -------------------*/
 98:   ST             st;               /* spectral transformation object */
 99:   DS             ds;               /* direct solver object */
100:   BV             V;                /* set of basis vectors and computed eigenvectors */
101:   RG             rg;               /* optional region for filtering */
102:   SlepcSC        sc;               /* sorting criterion data */
103:   Vec            D;                /* diagonal matrix for balancing */
104:   Vec            *IS;              /* references to user-provided initial space */
105:   Vec            *defl;            /* references to user-provided deflation space */
106:   PetscScalar    *eigr,*eigi;      /* real and imaginary parts of eigenvalues */
107:   PetscReal      *errest;          /* error estimates */
108:   PetscScalar    *rr,*ri;          /* values computed by user's arbitrary selection function */
109:   PetscInt       *perm;            /* permutation for eigenvalue ordering */
110:   PetscInt       nwork;            /* number of work vectors */
111:   Vec            *work;            /* work vectors */
112:   void           *data;            /* placeholder for solver-specific stuff */

114:   /* ----------------------- Status variables --------------------------*/
115:   EPSStateType   state;            /* initial -> setup -> solved -> eigenvectors */
116:   PetscInt       nconv;            /* number of converged eigenvalues */
117:   PetscInt       its;              /* number of iterations so far computed */
118:   PetscInt       n,nloc;           /* problem dimensions (global, local) */
119:   PetscReal      nrma,nrmb;        /* computed matrix norms */
120:   PetscBool      isgeneralized;
121:   PetscBool      ispositive;
122:   PetscBool      ishermitian;
123:   EPSConvergedReason reason;
124: };

126: /*
127:     Macros to test valid EPS arguments
128: */
129: #if !defined(PETSC_USE_DEBUG)

131: #define EPSCheckSolved(h,arg) do {} while (0)

133: #else

135: #define EPSCheckSolved(h,arg) \
136:   do { \
137:     if (h->state<EPS_STATE_SOLVED) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSolve() first: Parameter #%d",arg); \
138:   } while (0)

140: #endif

144: /*
145:   EPS_SetInnerProduct - set B matrix for inner product if appropriate.
146: */
147: PETSC_STATIC_INLINE PetscErrorCode EPS_SetInnerProduct(EPS eps)
148: {
150:   Mat            B;

153:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
154:   if (eps->ispositive || (eps->isgeneralized && eps->ishermitian)) {
155:     STGetBilinearForm(eps->st,&B);
156:     BVSetMatrix(eps->V,B,PetscNot(eps->ispositive));
157:     MatDestroy(&B);
158:   } else {
159:     BVSetMatrix(eps->V,NULL,PETSC_FALSE);
160:   }
161:   return(0);
162: }

164: PETSC_INTERN PetscErrorCode EPSSetWhichEigenpairs_Default(EPS);
165: PETSC_INTERN PetscErrorCode EPSSetDimensions_Default(EPS,PetscInt,PetscInt*,PetscInt*);
166: PETSC_INTERN PetscErrorCode EPSBackTransform_Default(EPS);
167: PETSC_INTERN PetscErrorCode EPSComputeVectors(EPS);
168: PETSC_INTERN PetscErrorCode EPSComputeVectors_Hermitian(EPS);
169: PETSC_INTERN PetscErrorCode EPSComputeVectors_Schur(EPS);
170: PETSC_INTERN PetscErrorCode EPSComputeVectors_Indefinite(EPS);
171: PETSC_INTERN PetscErrorCode EPSComputeVectors_Slice(EPS);
172: PETSC_INTERN PetscErrorCode EPSComputeResidualNorm_Private(EPS,PetscScalar,PetscScalar,Vec,Vec,Vec*,PetscReal*);
173: PETSC_INTERN PetscErrorCode EPSComputeRitzVector(EPS,PetscScalar*,PetscScalar*,BV,Vec,Vec);
174: PETSC_INTERN PetscErrorCode EPSGetStartVector(EPS,PetscInt,PetscBool*);

176: /* Private functions of the solver implementations */

178: PETSC_INTERN PetscErrorCode EPSBasicArnoldi(EPS,PetscBool,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*);
179: PETSC_INTERN PetscErrorCode EPSDelayedArnoldi(EPS,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*);
180: PETSC_INTERN PetscErrorCode EPSDelayedArnoldi1(EPS,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*);
181: PETSC_INTERN PetscErrorCode EPSKrylovConvergence(EPS,PetscBool,PetscInt,PetscInt,PetscReal,PetscReal,PetscInt*);
182: PETSC_INTERN PetscErrorCode EPSFullLanczos(EPS,PetscReal*,PetscReal*,PetscInt,PetscInt*,PetscBool*);
183: PETSC_INTERN PetscErrorCode EPSPseudoLanczos(EPS,PetscReal*,PetscReal*,PetscReal*,PetscInt,PetscInt*,PetscBool*,PetscBool*,PetscReal*,Vec);
184: PETSC_INTERN PetscErrorCode EPSBuildBalance_Krylov(EPS);

186: #endif
slepc-3.7.4/include/slepc/private/mfnimpl.h.html0000644000175000017500000002544013107004621021151 0ustar jromanjroman
Actual source code: mfnimpl.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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(_MFNIMPL)
 23: #define _MFNIMPL

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

 28: PETSC_EXTERN PetscBool MFNRegisterAllCalled;
 29: PETSC_EXTERN PetscErrorCode MFNRegisterAll(void);
 30: PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve;

 32: typedef struct _MFNOps *MFNOps;

 34: struct _MFNOps {
 35:   PetscErrorCode (*solve)(MFN,Vec,Vec);
 36:   PetscErrorCode (*setup)(MFN);
 37:   PetscErrorCode (*setfromoptions)(PetscOptionItems*,MFN);
 38:   PetscErrorCode (*publishoptions)(MFN);
 39:   PetscErrorCode (*destroy)(MFN);
 40:   PetscErrorCode (*reset)(MFN);
 41:   PetscErrorCode (*view)(MFN,PetscViewer);
 42: };

 44: /*
 45:      Maximum number of monitors you can run with a single MFN
 46: */
 47: #define MAXMFNMONITORS 5

 49: /*
 50:    Defines the MFN data structure.
 51: */
 52: struct _p_MFN {
 53:   PETSCHEADER(struct _MFNOps);
 54:   /*------------------------- User parameters ---------------------------*/
 55:   Mat            A;              /* the problem matrix */
 56:   FN             fn;             /* which function to compute */
 57:   PetscInt       max_it;         /* maximum number of iterations */
 58:   PetscInt       ncv;            /* number of basis vectors */
 59:   PetscReal      tol;            /* tolerance */
 60:   PetscBool      errorifnotconverged;    /* error out if MFNSolve() does not converge */

 62:   /*-------------- User-provided functions and contexts -----------------*/
 63:   PetscErrorCode (*monitor[MAXMFNMONITORS])(MFN,PetscInt,PetscReal,void*);
 64:   PetscErrorCode (*monitordestroy[MAXMFNMONITORS])(void**);
 65:   void           *monitorcontext[MAXMFNMONITORS];
 66:   PetscInt       numbermonitors;

 68:   /*----------------- Child objects and working data -------------------*/
 69:   BV             V;              /* set of basis vectors */
 70:   PetscInt       nwork;          /* number of work vectors */
 71:   Vec            *work;          /* work vectors */
 72:   void           *data;          /* placeholder for solver-specific stuff */

 74:   /* ----------------------- Status variables -------------------------- */
 75:   PetscInt       its;            /* number of iterations so far computed */
 76:   PetscInt       nv;             /* size of current Schur decomposition */
 77:   PetscReal      errest;         /* error estimate */
 78:   PetscReal      bnorm;          /* computed norm of right-hand side in current solve */
 79:   PetscInt       setupcalled;
 80:   MFNConvergedReason reason;
 81: };

 85: /*
 86:    MFN_CreateDenseMat - Creates a dense Mat of size k unless it already has that size
 87: */
 88: PETSC_STATIC_INLINE PetscErrorCode MFN_CreateDenseMat(PetscInt k,Mat *A)
 89: {
 91:   PetscBool      create=PETSC_FALSE;
 92:   PetscInt       m,n;

 95:   if (!*A) create=PETSC_TRUE;
 96:   else {
 97:     MatGetSize(*A,&m,&n);
 98:     if (m!=k || n!=k) {
 99:       MatDestroy(A);
100:       create=PETSC_TRUE;
101:     }
102:   }
103:   if (create) {
104:     MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,A);
105:   }
106:   return(0);
107: }

111: /*
112:    MFN_CreateVec - Creates a Vec of size k unless it already has that size
113: */
114: PETSC_STATIC_INLINE PetscErrorCode MFN_CreateVec(PetscInt k,Vec *v)
115: {
117:   PetscBool      create=PETSC_FALSE;
118:   PetscInt       n;

121:   if (!*v) create=PETSC_TRUE;
122:   else {
123:     VecGetSize(*v,&n);
124:     if (n!=k) {
125:       VecDestroy(v);
126:       create=PETSC_TRUE;
127:     }
128:   }
129:   if (create) {
130:     VecCreateSeq(PETSC_COMM_SELF,k,v);
131:   }
132:   return(0);
133: }

135: PETSC_INTERN PetscErrorCode MFNBasicArnoldi(MFN,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*);

137: #endif
slepc-3.7.4/include/slepc/finclude/0000755000175000017500000000000013107004621016505 5ustar jromanjromanslepc-3.7.4/include/slepc/finclude/slepcsvd.h0000644000175000017500000000463113107004621020505 0ustar jromanjroman! ! Include file for Fortran use of the SVD object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcsvddef.h" PetscEnum SVD_CONVERGED_TOL PetscEnum SVD_CONVERGED_USER PetscEnum SVD_DIVERGED_ITS PetscEnum SVD_DIVERGED_BREAKDOWN PetscEnum SVD_CONVERGED_ITERATING parameter (SVD_CONVERGED_TOL = 1) parameter (SVD_CONVERGED_USER = 2) parameter (SVD_DIVERGED_ITS = -1) parameter (SVD_DIVERGED_BREAKDOWN = -2) parameter (SVD_CONVERGED_ITERATING = 0) integer SVD_LARGEST integer SVD_SMALLEST parameter (SVD_LARGEST = 0) parameter (SVD_SMALLEST = 1) PetscEnum SVD_ERROR_ABSOLUTE PetscEnum SVD_ERROR_RELATIVE parameter (SVD_ERROR_ABSOLUTE = 0) parameter (SVD_ERROR_RELATIVE = 1) PetscEnum SVD_CONV_ABS PetscEnum SVD_CONV_REL PetscEnum SVD_CONV_USER parameter (SVD_CONV_ABS = 0) parameter (SVD_CONV_REL = 1) parameter (SVD_CONV_USER = 2) PetscEnum SVD_STOP_BASIC PetscEnum SVD_STOP_USER parameter (SVD_STOP_BASIC = 0) parameter (SVD_STOP_USER = 1) ! ! Possible arguments to SVDMonitorSet() ! external SVDMONITORALL external SVDMONITORLG external SVDMONITORLGALL external SVDMONITORCONVERGED external SVDMONITORFIRST ! ! End of Fortran include file for the SVD package in SLEPc ! slepc-3.7.4/include/slepc/finclude/makefile0000644000175000017500000000320713107004621020207 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_USING_F90' CFLAGS = FFLAGS = SOURCEC = SOURCEF = SOURCEH = slepc.h slepceps.h slepcst.h slepcsvd.h slepcpep.h \ slepcnep.h slepcmfn.h slepcds.h slepcfn.h slepcrg.h slepcbv.h slepcsys.h \ slepc.h90 slepceps.h90 slepcst.h90 slepcsvd.h90 \ slepcpep.h90 slepcnep.h90 slepcmfn.h90 slepcds.h90 \ slepcfn.h90 slepcrg.h90 slepcbv.h90 slepcdef.h slepcepsdef.h slepcstdef.h \ slepcsvddef.h slepcpepdef.h slepcnepdef.h slepcmfndef.h \ slepcdsdef.h slepcfndef.h slepcrgdef.h slepcbvdef.h slepcsysdef.h LIBBASE = libslepcsys DIRS = MANSEC = LOCDIR = include/slepc/finclude/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/include/slepc/finclude/slepcsysdef.h0000644000175000017500000000210513107004621021200 0ustar jromanjroman! ! Basic include file for Fortran use of the SLEPc package ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCSYSDEF_H) #define __SLEPCSYSDEF_H #define SlepcConvMonitor PetscFortranAddr #endif slepc-3.7.4/include/slepc/finclude/slepcpep.h.html0000644000175000017500000002354413107004621021444 0ustar jromanjroman
Actual source code: slepcpep.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the PEP object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcpepdef.h

 26: !  Convergence flags.
 27: !  They should match the flags in $SLEPC_DIR/include/slepcpep.h

 29:       PetscEnum PEP_CONVERGED_TOL
 30:       PetscEnum PEP_CONVERGED_USER
 31:       PetscEnum PEP_DIVERGED_ITS
 32:       PetscEnum PEP_DIVERGED_BREAKDOWN
 33:       PetscEnum PEP_DIVERGED_SYMMETRY_LOST
 34:       PetscEnum PEP_CONVERGED_ITERATING

 36:       parameter (PEP_CONVERGED_TOL          =  1)
 37:       parameter (PEP_CONVERGED_USER         =  2)
 38:       parameter (PEP_DIVERGED_ITS           = -1)
 39:       parameter (PEP_DIVERGED_BREAKDOWN     = -2)
 40:       parameter (PEP_DIVERGED_SYMMETRY_LOST = -3)
 41:       parameter (PEP_CONVERGED_ITERATING    =  0)

 43:       PetscEnum PEP_GENERAL
 44:       PetscEnum PEP_HERMITIAN
 45:       PetscEnum PEP_GYROSCOPIC

 47:       parameter (PEP_GENERAL                =  1)
 48:       parameter (PEP_HERMITIAN              =  2)
 49:       parameter (PEP_GYROSCOPIC             =  3)

 51:       PetscEnum PEP_LARGEST_MAGNITUDE
 52:       PetscEnum PEP_SMALLEST_MAGNITUDE
 53:       PetscEnum PEP_LARGEST_REAL
 54:       PetscEnum PEP_SMALLEST_REAL
 55:       PetscEnum PEP_LARGEST_IMAGINARY
 56:       PetscEnum PEP_SMALLEST_IMAGINARY
 57:       PetscEnum PEP_TARGET_MAGNITUDE
 58:       PetscEnum PEP_TARGET_REAL
 59:       PetscEnum PEP_TARGET_IMAGINARY
 60:       PetscEnum PEP_WHICH_USER

 62:       parameter (PEP_LARGEST_MAGNITUDE      =  1)
 63:       parameter (PEP_SMALLEST_MAGNITUDE     =  2)
 64:       parameter (PEP_LARGEST_REAL           =  3)
 65:       parameter (PEP_SMALLEST_REAL          =  4)
 66:       parameter (PEP_LARGEST_IMAGINARY      =  5)
 67:       parameter (PEP_SMALLEST_IMAGINARY     =  6)
 68:       parameter (PEP_TARGET_MAGNITUDE       =  7)
 69:       parameter (PEP_TARGET_REAL            =  8)
 70:       parameter (PEP_TARGET_IMAGINARY       =  9)
 71:       parameter (PEP_WHICH_USER             = 10)

 73:       PetscEnum PEP_BASIS_MONOMIAL
 74:       PetscEnum PEP_BASIS_CHEBYSHEV1
 75:       PetscEnum PEP_BASIS_CHEBYSHEV2
 76:       PetscEnum PEP_BASIS_LEGENDRE
 77:       PetscEnum PEP_BASIS_LAGUERRE
 78:       PetscEnum PEP_BASIS_HERMITE

 80:       parameter (PEP_BASIS_MONOMIAL         =  0)
 81:       parameter (PEP_BASIS_CHEBYSHEV1       =  1)
 82:       parameter (PEP_BASIS_CHEBYSHEV2       =  2)
 83:       parameter (PEP_BASIS_LEGENDRE         =  3)
 84:       parameter (PEP_BASIS_LAGUERRE         =  4)
 85:       parameter (PEP_BASIS_HERMITE          =  5)

 87:       PetscEnum PEP_SCALE_NONE
 88:       PetscEnum PEP_SCALE_SCALAR
 89:       PetscEnum PEP_SCALE_DIAGONAL
 90:       PetscEnum PEP_SCALE_BOTH

 92:       parameter (PEP_SCALE_NONE             =  0)
 93:       parameter (PEP_SCALE_SCALAR           =  1)
 94:       parameter (PEP_SCALE_DIAGONAL         =  2)
 95:       parameter (PEP_SCALE_BOTH             =  3)

 97:       PetscEnum PEP_REFINE_NONE
 98:       PetscEnum PEP_REFINE_SIMPLE
 99:       PetscEnum PEP_REFINE_MULTIPLE

101:       parameter (PEP_REFINE_NONE            =  0)
102:       parameter (PEP_REFINE_SIMPLE          =  1)
103:       parameter (PEP_REFINE_MULTIPLE        =  2)

105:       PetscEnum PEP_REFINE_SCHEME_SCHUR
106:       PetscEnum PEP_REFINE_SCHEME_MBE
107:       PetscEnum PEP_REFINE_SCHEME_EXPLICIT

109:       parameter (PEP_REFINE_SCHEME_SCHUR    =  1)
110:       parameter (PEP_REFINE_SCHEME_MBE      =  2)
111:       parameter (PEP_REFINE_SCHEME_EXPLICIT =  3)

113:       PetscEnum PEP_EXTRACT_NONE
114:       PetscEnum PEP_EXTRACT_NORM
115:       PetscEnum PEP_EXTRACT_RESIDUAL
116:       PetscEnum PEP_EXTRACT_STRUCTURED

118:       parameter (PEP_EXTRACT_NONE           =  1)
119:       parameter (PEP_EXTRACT_NORM           =  2)
120:       parameter (PEP_EXTRACT_RESIDUAL       =  3)
121:       parameter (PEP_EXTRACT_STRUCTURED     =  4)

123:       PetscEnum PEP_ERROR_ABSOLUTE
124:       PetscEnum PEP_ERROR_RELATIVE
125:       PetscEnum PEP_ERROR_BACKWARD

127:       parameter (PEP_ERROR_ABSOLUTE         =  0)
128:       parameter (PEP_ERROR_RELATIVE         =  1)
129:       parameter (PEP_ERROR_BACKWARD         =  2)

131:       PetscEnum PEP_CONV_ABS
132:       PetscEnum PEP_CONV_REL
133:       PetscEnum PEP_CONV_NORM
134:       PetscEnum PEP_CONV_USER

136:       parameter (PEP_CONV_ABS               =  0)
137:       parameter (PEP_CONV_REL               =  1)
138:       parameter (PEP_CONV_NORM              =  2)
139:       parameter (PEP_CONV_USER              =  3)

141:       PetscEnum PEP_STOP_BASIC
142:       PetscEnum PEP_STOP_USER

144:       parameter (PEP_STOP_BASIC             =  0)
145:       parameter (PEP_STOP_USER              =  1)

147: !
148: !   Possible arguments to PEPMonitorSet()
149: !
150:       external PEPMONITORALL
151:       external PEPMONITORLG
152:       external PEPMONITORLGALL
153:       external PEPMONITORCONVERGED
154:       external PEPMONITORFIRST

156: !
157: !  End of Fortran include file for the PEP package in SLEPc
158: !
slepc-3.7.4/include/slepc/finclude/slepcrg.h0000644000175000017500000000210213107004621020310 0ustar jromanjroman! ! Include file for Fortran use of the RG object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcrgdef.h" ! ! End of Fortran include file for the RG package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepc.h90.html0000644000175000017500000000754613107004621021114 0ustar jromanjroman
Actual source code: slepc.h90

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Single Fortran 90 include file
 21: !

 23:  #include slepc/finclude/slepcsys.h
 24: #include "slepc/finclude/slepcbv.h90"
 25: #include "slepc/finclude/slepcfn.h90"
 26: #include "slepc/finclude/slepcds.h90"
 27: #include "slepc/finclude/slepcrg.h90"
 28: #include "slepc/finclude/slepcst.h90"
 29: #include "slepc/finclude/slepceps.h90"
 30: #include "slepc/finclude/slepcsvd.h90"
 31: #include "slepc/finclude/slepcpep.h90"
 32: #include "slepc/finclude/slepcnep.h90"
 33: #include "slepc/finclude/slepcmfn.h90"
slepc-3.7.4/include/slepc/finclude/slepc.h0000644000175000017500000000254013107004621017765 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Single Fortran include file for all of SLEPc ! #include "slepc/finclude/slepcsys.h" #include "slepc/finclude/slepcbv.h" #include "slepc/finclude/slepcfn.h" #include "slepc/finclude/slepcds.h" #include "slepc/finclude/slepcrg.h" #include "slepc/finclude/slepcst.h" #include "slepc/finclude/slepceps.h" #include "slepc/finclude/slepcsvd.h" #include "slepc/finclude/slepcpep.h" #include "slepc/finclude/slepcnep.h" #include "slepc/finclude/slepcmfn.h" slepc-3.7.4/include/slepc/finclude/slepcbv.h.html0000644000175000017500000001010013107004621021247 0ustar jromanjroman
Actual source code: slepcbv.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the BV object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !
 23:  #include slepc/finclude/slepcbvdef.h

 25:       PetscEnum BV_ORTHOG_CGS
 26:       PetscEnum BV_ORTHOG_MGS

 28:       parameter (BV_ORTHOG_CGS             =  0)
 29:       parameter (BV_ORTHOG_MGS             =  1)

 31:       PetscEnum BV_ORTHOG_REFINE_IFNEEDED
 32:       PetscEnum BV_ORTHOG_REFINE_NEVER
 33:       PetscEnum BV_ORTHOG_REFINE_ALWAYS

 35:       parameter (BV_ORTHOG_REFINE_IFNEEDED =  0)
 36:       parameter (BV_ORTHOG_REFINE_NEVER    =  1)
 37:       parameter (BV_ORTHOG_REFINE_ALWAYS   =  2)

 39:       PetscEnum BV_ORTHOG_BLOCK_GS
 40:       PetscEnum BV_ORTHOG_BLOCK_CHOL

 42:       parameter (BV_ORTHOG_BLOCK_GS        =  0)
 43:       parameter (BV_ORTHOG_BLOCK_CHOL      =  1)

 45:       PetscEnum BV_MATMULT_VECS
 46:       PetscEnum BV_MATMULT_MAT
 47:       PetscEnum BV_MATMULT_MAT_SAVE

 49:       parameter (BV_MATMULT_VECS           =  0)
 50:       parameter (BV_MATMULT_MAT            =  1)
 51:       parameter (BV_MATMULT_MAT_SAVE       =  2)

 53: !
 54: !  End of Fortran include file for the BV package in SLEPc
 55: !
slepc-3.7.4/include/slepc/finclude/slepcdsdef.h.html0000644000175000017500000001004313107004621021733 0ustar jromanjroman
Actual source code: slepcdsdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the DS object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 27: #define DS PetscFortranAddr
 28: #endif

 30: #define DSType      character*(80)
 31: #define DSStateType PetscEnum
 32: #define DSMatType   PetscEnum

 34: #define DSHEP       'hep'
 35: #define DSNHEP      'nhep'
 36: #define DSGHEP      'ghep'
 37: #define DSGHIEP     'ghiep'
 38: #define DSGNHEP     'gnhep'
 39: #define DSSVD       'svd'
 40: #define DSPEP       'pep'
 41: #define DSNEP       'nep'

 43: #endif
slepc-3.7.4/include/slepc/finclude/slepcmfndef.h.html0000644000175000017500000000737213107004621022120 0ustar jromanjroman
Actual source code: slepcmfndef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the MFN object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26: #include "petsc/finclude/petscmatdef.h"
 27:  #include slepc/finclude/slepcfndef.h
 28:  #include slepc/finclude/slepcbvdef.h

 30: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 31: #define MFN PetscFortranAddr
 32: #endif

 34: #define MFNType            character*(80)
 35: #define MFNConvergedReason PetscEnum

 37: #define MFNKRYLOV      'krylov'
 38: #define MFNEXPOKIT     'expokit'

 40: #endif
slepc-3.7.4/include/slepc/finclude/slepcnepdef.h0000644000175000017500000000346313107004621021154 0ustar jromanjroman! ! Include file for Fortran use of the NEP object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCNEPDEF_H) #define __SLEPCNEPDEF_H #include "slepc/finclude/slepcbvdef.h" #include "slepc/finclude/slepcdsdef.h" #include "slepc/finclude/slepcrgdef.h" #include "slepc/finclude/slepcfndef.h" #include "slepc/finclude/slepcepsdef.h" #include "slepc/finclude/slepcpepdef.h" #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define NEP PetscFortranAddr #endif #define NEPType character*(80) #define NEPConvergedReason PetscEnum #define NEPErrorType PetscEnum #define NEPWhich PetscEnum #define NEPConv PetscEnum #define NEPStop PetscEnum #define NEPRefine PetscEnum #define NEPRefineScheme PetscEnum #define NEPRII 'rii' #define NEPSLP 'slp' #define NEPNARNOLDI 'narnoldi' #define NEPCISS 'ciss' #define NEPINTERPOL 'interpol' #define NEPNLEIGS 'nleigs' #endif slepc-3.7.4/include/slepc/finclude/slepceps.h0000644000175000017500000001655013107004621020503 0ustar jromanjroman! ! Include file for Fortran use of the EPS object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcepsdef.h" PetscEnum EPS_CONVERGED_TOL PetscEnum EPS_CONVERGED_USER PetscEnum EPS_DIVERGED_ITS PetscEnum EPS_DIVERGED_BREAKDOWN PetscEnum EPS_DIVERGED_SYMMETRY_LOST PetscEnum EPS_CONVERGED_ITERATING parameter (EPS_CONVERGED_TOL = 1) parameter (EPS_CONVERGED_USER = 2) parameter (EPS_DIVERGED_ITS = -1) parameter (EPS_DIVERGED_BREAKDOWN = -2) parameter (EPS_DIVERGED_SYMMETRY_LOST = -3) parameter (EPS_CONVERGED_ITERATING = 0) PetscEnum EPS_HEP PetscEnum EPS_GHEP PetscEnum EPS_NHEP PetscEnum EPS_GNHEP PetscEnum EPS_PGNHEP PetscEnum EPS_GHIEP parameter (EPS_HEP = 1) parameter (EPS_GHEP = 2) parameter (EPS_NHEP = 3) parameter (EPS_GNHEP = 4) parameter (EPS_PGNHEP = 5) parameter (EPS_GHIEP = 6) PetscEnum EPS_LARGEST_MAGNITUDE PetscEnum EPS_SMALLEST_MAGNITUDE PetscEnum EPS_LARGEST_REAL PetscEnum EPS_SMALLEST_REAL PetscEnum EPS_LARGEST_IMAGINARY PetscEnum EPS_SMALLEST_IMAGINARY PetscEnum EPS_TARGET_MAGNITUDE PetscEnum EPS_TARGET_REAL PetscEnum EPS_TARGET_IMAGINARY PetscEnum EPS_ALL PetscEnum EPS_WHICH_USER parameter (EPS_LARGEST_MAGNITUDE = 1) parameter (EPS_SMALLEST_MAGNITUDE = 2) parameter (EPS_LARGEST_REAL = 3) parameter (EPS_SMALLEST_REAL = 4) parameter (EPS_LARGEST_IMAGINARY = 5) parameter (EPS_SMALLEST_IMAGINARY = 6) parameter (EPS_TARGET_MAGNITUDE = 7) parameter (EPS_TARGET_REAL = 8) parameter (EPS_TARGET_IMAGINARY = 9) parameter (EPS_ALL = 10) parameter (EPS_WHICH_USER = 11) PetscEnum EPS_BALANCE_NONE PetscEnum EPS_BALANCE_ONESIDE PetscEnum EPS_BALANCE_TWOSIDE PetscEnum EPS_BALANCE_USER parameter (EPS_BALANCE_NONE = 0) parameter (EPS_BALANCE_ONESIDE = 1) parameter (EPS_BALANCE_TWOSIDE = 2) parameter (EPS_BALANCE_USER = 3) PetscEnum EPS_RITZ PetscEnum EPS_HARMONIC PetscEnum EPS_HARMONIC_RELATIVE PetscEnum EPS_HARMONIC_RIGHT PetscEnum EPS_HARMONIC_LARGEST PetscEnum EPS_REFINED PetscEnum EPS_REFINED_HARMONIC parameter (EPS_RITZ = 0) parameter (EPS_HARMONIC = 1) parameter (EPS_HARMONIC_RELATIVE = 2) parameter (EPS_HARMONIC_RIGHT = 3) parameter (EPS_HARMONIC_LARGEST = 4) parameter (EPS_REFINED = 5) parameter (EPS_REFINED_HARMONIC = 6) PetscEnum EPS_ERROR_ABSOLUTE PetscEnum EPS_ERROR_RELATIVE PetscEnum EPS_ERROR_BACKWARD parameter (EPS_ERROR_ABSOLUTE = 0) parameter (EPS_ERROR_RELATIVE = 1) parameter (EPS_ERROR_BACKWARD = 2) PetscEnum EPS_CONV_ABS PetscEnum EPS_CONV_REL PetscEnum EPS_CONV_NORM PetscEnum EPS_CONV_USER parameter (EPS_CONV_ABS = 0) parameter (EPS_CONV_REL = 1) parameter (EPS_CONV_NORM = 2) parameter (EPS_CONV_USER = 3) PetscEnum EPS_STOP_BASIC PetscEnum EPS_STOP_USER parameter (EPS_STOP_BASIC = 0) parameter (EPS_STOP_USER = 1) PetscEnum EPS_POWER_SHIFT_CONSTANT PetscEnum EPS_POWER_SHIFT_RAYLEIGH PetscEnum EPS_POWER_SHIFT_WILKINSON parameter (EPS_POWER_SHIFT_CONSTANT = 0) parameter (EPS_POWER_SHIFT_RAYLEIGH = 1) parameter (EPS_POWER_SHIFT_WILKINSON = 2) PetscEnum EPS_LANCZOS_REORTHOG_LOCAL PetscEnum EPS_LANCZOS_REORTHOG_FULL PetscEnum EPS_LANCZOS_REORTHOG_SELECTIVE PetscEnum EPS_LANCZOS_REORTHOG_PERIODIC PetscEnum EPS_LANCZOS_REORTHOG_PARTIAL PetscEnum EPS_LANCZOS_REORTHOG_DELAYED parameter (EPS_LANCZOS_REORTHOG_LOCAL = 0) parameter (EPS_LANCZOS_REORTHOG_FULL = 1) parameter (EPS_LANCZOS_REORTHOG_SELECTIVE = 2) parameter (EPS_LANCZOS_REORTHOG_PERIODIC = 3) parameter (EPS_LANCZOS_REORTHOG_PARTIAL = 4) parameter (EPS_LANCZOS_REORTHOG_DELAYED = 5) PetscEnum EPS_PRIMME_DYNAMIC PetscEnum EPS_PRIMME_DEFAULT_MIN_TIME PetscEnum EPS_PRIMME_DEFAULT_MIN_MATVECS PetscEnum EPS_PRIMME_ARNOLDI PetscEnum EPS_PRIMME_GD PetscEnum EPS_PRIMME_GD_PLUSK PetscEnum EPS_PRIMME_GD_OLSEN_PLUSK PetscEnum EPS_PRIMME_JD_OLSEN_PLUSK PetscEnum EPS_PRIMME_RQI PetscEnum EPS_PRIMME_JDQR PetscEnum EPS_PRIMME_JDQMR PetscEnum EPS_PRIMME_JDQMR_ETOL PetscEnum EPS_PRIMME_SUBSPACE_ITERATION PetscEnum EPS_PRIMME_LOBPCG_ORTHOBASIS PetscEnum EPS_PRIMME_LOBPCG_ORTHOBASISW parameter (EPS_PRIMME_DYNAMIC = 0) parameter (EPS_PRIMME_DEFAULT_MIN_TIME = 1) parameter (EPS_PRIMME_DEFAULT_MIN_MATVECS = 2) parameter (EPS_PRIMME_ARNOLDI = 3) parameter (EPS_PRIMME_GD = 4) parameter (EPS_PRIMME_GD_PLUSK = 5) parameter (EPS_PRIMME_GD_OLSEN_PLUSK = 7) parameter (EPS_PRIMME_JD_OLSEN_PLUSK = 8) parameter (EPS_PRIMME_RQI = 9) parameter (EPS_PRIMME_JDQR = 10) parameter (EPS_PRIMME_JDQMR = 11) parameter (EPS_PRIMME_JDQMR_ETOL = 12) parameter (EPS_PRIMME_SUBSPACE_ITERATION = 13) parameter (EPS_PRIMME_LOBPCG_ORTHOBASIS = 14) parameter (EPS_PRIMME_LOBPCG_ORTHOBASISW = 15) PetscEnum EPS_CISS_QUADRULE_TRAPEZOIDAL PetscEnum EPS_CISS_QUADRULE_CHEBYSHEV parameter (EPS_CISS_QUADRULE_TRAPEZOIDAL = 1) parameter (EPS_CISS_QUADRULE_CHEBYSHEV = 2) PetscEnum EPS_CISS_EXTRACTION_RITZ PetscEnum EPS_CISS_EXTRACTION_HANKEL parameter (EPS_CISS_EXTRACTION_RITZ = 0) parameter (EPS_CISS_EXTRACTION_HANKEL = 1) ! ! Possible arguments to EPSMonitorSet() ! external EPSMONITORALL external EPSMONITORLG external EPSMONITORLGALL external EPSMONITORCONVERGED external EPSMONITORFIRST ! ! End of Fortran include file for the EPS package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcpepdef.h.html0000644000175000017500000001401713107004621022116 0ustar jromanjroman
Actual source code: slepcpepdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the PEP object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26:  #include slepc/finclude/slepcbvdef.h
 27:  #include slepc/finclude/slepcstdef.h
 28:  #include slepc/finclude/slepcdsdef.h
 29:  #include slepc/finclude/slepcrgdef.h
 30:  #include slepc/finclude/slepcepsdef.h

 32: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 33: #define PEP PetscFortranAddr
 34: #endif

 36: #define PEPType            character*(80)
 37: #define PEPProblemType     PetscEnum
 38: #define PEPWhich           PetscEnum
 39: #define PEPBasis           PetscEnum
 40: #define PEPScale           PetscEnum
 41: #define PEPRefine          PetscEnum
 42: #define PEPRefineScheme    PetscEnum
 43: #define PEPExtract         PetscEnum
 44: #define PEPConv            PetscEnum
 45: #define PEPStop            PetscEnum
 46: #define PEPErrorType       PetscEnum
 47: #define PEPConvergedReason PetscEnum

 49: #define PEPLINEAR    'linear'
 50: #define PEPQARNOLDI  'qarnoldi'
 51: #define PEPTOAR      'toar'
 52: #define PEPSTOAR     'stoar'
 53: #define PEPJD        'jd'

 55: #endif
slepc-3.7.4/include/slepc/finclude/slepcnep.h90.html0000644000175000017500000000602213107004621021603 0ustar jromanjroman
Actual source code: slepcnep.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional NEP include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcnep.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcnep.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepc.h900000644000175000017500000000254613107004621020144 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Single Fortran 90 include file ! #include "slepc/finclude/slepcsys.h" #include "slepc/finclude/slepcbv.h90" #include "slepc/finclude/slepcfn.h90" #include "slepc/finclude/slepcds.h90" #include "slepc/finclude/slepcrg.h90" #include "slepc/finclude/slepcst.h90" #include "slepc/finclude/slepceps.h90" #include "slepc/finclude/slepcsvd.h90" #include "slepc/finclude/slepcpep.h90" #include "slepc/finclude/slepcnep.h90" #include "slepc/finclude/slepcmfn.h90" slepc-3.7.4/include/slepc/finclude/slepcsvddef.h0000644000175000017500000000313413107004621021161 0ustar jromanjroman! ! Include file for Fortran use of the SVD object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCSVDDEF_H) #define __SLEPCSVDDEF_H #include "slepc/finclude/slepcbvdef.h" #include "slepc/finclude/slepcdsdef.h" #include "slepc/finclude/slepcepsdef.h" #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define SVD PetscFortranAddr #endif #define SVDType character*(80) #define SVDConvergedReason PetscEnum #define SVDErrorType PetscEnum #define SVDWhich PetscEnum #define SVDConv PetscEnum #define SVDStop PetscEnum #define SVDCROSS 'cross' #define SVDCYCLIC 'cyclic' #define SVDLAPACK 'lapack' #define SVDLANCZOS 'lanczos' #define SVDTRLANCZOS 'trlanczos' #endif slepc-3.7.4/include/slepc/finclude/slepcnep.h900000644000175000017500000000223713107004621020644 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional NEP include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcnep.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcnep.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepcmfndef.h0000644000175000017500000000256013107004621021147 0ustar jromanjroman! ! Include file for Fortran use of the MFN object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCMFNDEF_H) #define __SLEPCMFNDEF_H #include "petsc/finclude/petscmatdef.h" #include "slepc/finclude/slepcfndef.h" #include "slepc/finclude/slepcbvdef.h" #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define MFN PetscFortranAddr #endif #define MFNType character*(80) #define MFNConvergedReason PetscEnum #define MFNKRYLOV 'krylov' #define MFNEXPOKIT 'expokit' #endif slepc-3.7.4/include/slepc/finclude/slepcbv.h900000644000175000017500000000223413107004621020466 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional BV include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcbv.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcbv.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepcsvddef.h.html0000644000175000017500000001132713107004621022127 0ustar jromanjroman
Actual source code: slepcsvddef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the SVD object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26:  #include slepc/finclude/slepcbvdef.h
 27:  #include slepc/finclude/slepcdsdef.h
 28:  #include slepc/finclude/slepcepsdef.h

 30: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 31: #define SVD PetscFortranAddr
 32: #endif

 34: #define SVDType            character*(80)
 35: #define SVDConvergedReason PetscEnum
 36: #define SVDErrorType       PetscEnum
 37: #define SVDWhich           PetscEnum
 38: #define SVDConv            PetscEnum
 39: #define SVDStop            PetscEnum

 41: #define SVDCROSS     'cross'
 42: #define SVDCYCLIC    'cyclic'
 43: #define SVDLAPACK    'lapack'
 44: #define SVDLANCZOS   'lanczos'
 45: #define SVDTRLANCZOS 'trlanczos'

 47: #endif
slepc-3.7.4/include/slepc/finclude/slepcrgdef.h0000644000175000017500000000237613107004621021004 0ustar jromanjroman! ! Include file for Fortran use of the RG object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCRGDEF_H) #define __SLEPCRGDEF_H #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define RG PetscFortranAddr #endif #define RGType character*(80) #define RGINTERVAL 'interval' #define RGPOLYGON 'polygon' #define RGELLIPSE 'ellipse' #define RGRING 'ring' #endif slepc-3.7.4/include/slepc/finclude/makefile.html0000644000175000017500000000560713107004621021160 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#     
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

#requiresdefine   'PETSC_USING_F90'

CFLAGS    =
FFLAGS    =
SOURCEC   =
SOURCEF   =
SOURCEH   = slepc.h slepceps.h slepcst.h slepcsvd.h slepcpep.h \
            slepcnep.h slepcmfn.h slepcds.h slepcfn.h slepcrg.h slepcbv.h slepcsys.h \
            slepc.h90 slepceps.h90 slepcst.h90 slepcsvd.h90 \
            slepcpep.h90 slepcnep.h90 slepcmfn.h90 slepcds.h90 \
            slepcfn.h90 slepcrg.h90 slepcbv.h90 slepcdef.h slepcepsdef.h slepcstdef.h \
            slepcsvddef.h slepcpepdef.h slepcnepdef.h slepcmfndef.h \
            slepcdsdef.h slepcfndef.h slepcrgdef.h slepcbvdef.h slepcsysdef.h
LIBBASE   = libslepcsys
DIRS      = 
MANSEC    = 
LOCDIR    = include/slepc/finclude/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/include/slepc/finclude/slepcstdef.h0000644000175000017500000000253113107004621021013 0ustar jromanjroman! ! Include file for Fortran use of the ST object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCSTDEF_H) #define __SLEPCSTDEF_H #include "petsc/finclude/petsckspdef.h" #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define ST PetscFortranAddr #endif #define STType character*(80) #define STMatMode PetscEnum #define STSHELL 'shell' #define STSHIFT 'shift' #define STSINVERT 'sinvert' #define STCAYLEY 'cayley' #define STPRECOND 'precond' #endif slepc-3.7.4/include/slepc/finclude/slepcdef.h0000644000175000017500000000260213107004621020443 0ustar jromanjroman! ! Single Fortran include file for all of SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcsysdef.h" #include "slepc/finclude/slepcbvdef.h" #include "slepc/finclude/slepcfndef.h" #include "slepc/finclude/slepcdsdef.h" #include "slepc/finclude/slepcrgdef.h" #include "slepc/finclude/slepcstdef.h" #include "slepc/finclude/slepcepsdef.h" #include "slepc/finclude/slepcsvddef.h" #include "slepc/finclude/slepcpepdef.h" #include "slepc/finclude/slepcnepdef.h" #include "slepc/finclude/slepcmfndef.h" slepc-3.7.4/include/slepc/finclude/slepcpepdef.h0000644000175000017500000000360013107004621021147 0ustar jromanjroman! ! Include file for Fortran use of the PEP object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCPEPDEF_H) #define __SLEPCPEPDEF_H #include "slepc/finclude/slepcbvdef.h" #include "slepc/finclude/slepcstdef.h" #include "slepc/finclude/slepcdsdef.h" #include "slepc/finclude/slepcrgdef.h" #include "slepc/finclude/slepcepsdef.h" #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define PEP PetscFortranAddr #endif #define PEPType character*(80) #define PEPProblemType PetscEnum #define PEPWhich PetscEnum #define PEPBasis PetscEnum #define PEPScale PetscEnum #define PEPRefine PetscEnum #define PEPRefineScheme PetscEnum #define PEPExtract PetscEnum #define PEPConv PetscEnum #define PEPStop PetscEnum #define PEPErrorType PetscEnum #define PEPConvergedReason PetscEnum #define PEPLINEAR 'linear' #define PEPQARNOLDI 'qarnoldi' #define PEPTOAR 'toar' #define PEPSTOAR 'stoar' #define PEPJD 'jd' #endif slepc-3.7.4/include/slepc/finclude/slepceps.h900000644000175000017500000000223713107004621020651 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional EPS include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepceps.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepceps.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepceps.h90.html0000644000175000017500000000602213107004621021610 0ustar jromanjroman
Actual source code: slepceps.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional EPS include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepceps.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepceps.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcmfn.h0000644000175000017500000000321113107004621020462 0ustar jromanjroman! ! Include file for Fortran use of the MFN object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcsysdef.h" #include "slepc/finclude/slepcmfndef.h" PetscEnum MFN_CONVERGED_TOL PetscEnum MFN_CONVERGED_ITS PetscEnum MFN_DIVERGED_ITS PetscEnum MFN_DIVERGED_BREAKDOWN PetscEnum MFN_CONVERGED_ITERATING parameter (MFN_CONVERGED_TOL = 2) parameter (MFN_CONVERGED_ITS = 3) parameter (MFN_DIVERGED_ITS = -3) parameter (MFN_DIVERGED_BREAKDOWN = -4) parameter (MFN_CONVERGED_ITERATING = 0) ! ! Possible arguments to MFNMonitorSet() ! external MFNMONITORDEFAULT external MFNMONITORLG ! ! End of Fortran include file for the MFN package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcst.h.html0000644000175000017500000000617013107004621021302 0ustar jromanjroman
Actual source code: slepcst.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the ST object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !
 23:  #include slepc/finclude/slepcstdef.h

 25:       PetscEnum ST_MATMODE_COPY
 26:       PetscEnum ST_MATMODE_INPLACE
 27:       PetscEnum ST_MATMODE_SHELL

 29:       parameter (ST_MATMODE_COPY          =  0)
 30:       parameter (ST_MATMODE_INPLACE       =  1)
 31:       parameter (ST_MATMODE_SHELL         =  2)

 33: !
 34: !  End of Fortran include file for the ST package in SLEPc
 35: !
slepc-3.7.4/include/slepc/finclude/slepcbv.h0000644000175000017500000000362213107004621020317 0ustar jromanjroman! ! Include file for Fortran use of the BV object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcbvdef.h" PetscEnum BV_ORTHOG_CGS PetscEnum BV_ORTHOG_MGS parameter (BV_ORTHOG_CGS = 0) parameter (BV_ORTHOG_MGS = 1) PetscEnum BV_ORTHOG_REFINE_IFNEEDED PetscEnum BV_ORTHOG_REFINE_NEVER PetscEnum BV_ORTHOG_REFINE_ALWAYS parameter (BV_ORTHOG_REFINE_IFNEEDED = 0) parameter (BV_ORTHOG_REFINE_NEVER = 1) parameter (BV_ORTHOG_REFINE_ALWAYS = 2) PetscEnum BV_ORTHOG_BLOCK_GS PetscEnum BV_ORTHOG_BLOCK_CHOL parameter (BV_ORTHOG_BLOCK_GS = 0) parameter (BV_ORTHOG_BLOCK_CHOL = 1) PetscEnum BV_MATMULT_VECS PetscEnum BV_MATMULT_MAT PetscEnum BV_MATMULT_MAT_SAVE parameter (BV_MATMULT_VECS = 0) parameter (BV_MATMULT_MAT = 1) parameter (BV_MATMULT_MAT_SAVE = 2) ! ! End of Fortran include file for the BV package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcepsdef.h.html0000644000175000017500000001714513107004621022126 0ustar jromanjroman
Actual source code: slepcepsdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the EPS object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26:  #include slepc/finclude/slepcstdef.h
 27:  #include slepc/finclude/slepcbvdef.h
 28:  #include slepc/finclude/slepcdsdef.h
 29:  #include slepc/finclude/slepcrgdef.h

 31: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 32: #define EPS PetscFortranAddr
 33: #endif

 35: #define EPSType                character*(80)
 36: #define EPSConvergedReason     PetscEnum
 37: #define EPSErrorType           PetscEnum
 38: #define EPSProblemType         PetscEnum
 39: #define EPSWhich               PetscEnum
 40: #define EPSExtraction          PetscEnum
 41: #define EPSBalance             PetscEnum
 42: #define EPSConv                PetscEnum
 43: #define EPSStop                PetscEnum
 44: #define EPSPowerShiftType      PetscEnum
 45: #define EPSLanczosReorthogType PetscEnum
 46: #define EPSPRIMMEMethod        PetscEnum
 47: #define EPSCISSQuadRule        PetscEnum
 48: #define EPSCISSExtraction      PetscEnum

 50: #define EPSPOWER       'power'
 51: #define EPSSUBSPACE    'subspace'
 52: #define EPSARNOLDI     'arnoldi'
 53: #define EPSLANCZOS     'lanczos'
 54: #define EPSKRYLOVSCHUR 'krylovschur'
 55: #define EPSGD          'gd'
 56: #define EPSJD          'jd'
 57: #define EPSRQCG        'rqcg'
 58: #define EPSLOBPCG      'lobpcg'
 59: #define EPSCISS        'ciss'
 60: #define EPSLAPACK      'lapack'
 61: #define EPSARPACK      'arpack'
 62: #define EPSBLZPACK     'blzpack'
 63: #define EPSTRLAN       'trlan'
 64: #define EPSBLOPEX      'blopex'
 65: #define EPSPRIMME      'primme'
 66: #define EPSFEAST       'feast'

 68: #endif
slepc-3.7.4/include/slepc/finclude/slepcds.h900000644000175000017500000000223413107004621020465 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional DS include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcds.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcds.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepceps.h.html0000644000175000017500000003202413107004621021440 0ustar jromanjroman
Actual source code: slepceps.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the EPS object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcepsdef.h

 26:       PetscEnum EPS_CONVERGED_TOL
 27:       PetscEnum EPS_CONVERGED_USER
 28:       PetscEnum EPS_DIVERGED_ITS
 29:       PetscEnum EPS_DIVERGED_BREAKDOWN
 30:       PetscEnum EPS_DIVERGED_SYMMETRY_LOST
 31:       PetscEnum EPS_CONVERGED_ITERATING

 33:       parameter (EPS_CONVERGED_TOL          =  1)
 34:       parameter (EPS_CONVERGED_USER         =  2)
 35:       parameter (EPS_DIVERGED_ITS           = -1)
 36:       parameter (EPS_DIVERGED_BREAKDOWN     = -2)
 37:       parameter (EPS_DIVERGED_SYMMETRY_LOST = -3)
 38:       parameter (EPS_CONVERGED_ITERATING    =  0)

 40:       PetscEnum EPS_HEP
 41:       PetscEnum EPS_GHEP
 42:       PetscEnum EPS_NHEP
 43:       PetscEnum EPS_GNHEP
 44:       PetscEnum EPS_PGNHEP
 45:       PetscEnum EPS_GHIEP

 47:       parameter (EPS_HEP                    =  1)
 48:       parameter (EPS_GHEP                   =  2)
 49:       parameter (EPS_NHEP                   =  3)
 50:       parameter (EPS_GNHEP                  =  4)
 51:       parameter (EPS_PGNHEP                 =  5)
 52:       parameter (EPS_GHIEP                  =  6)

 54:       PetscEnum EPS_LARGEST_MAGNITUDE
 55:       PetscEnum EPS_SMALLEST_MAGNITUDE
 56:       PetscEnum EPS_LARGEST_REAL
 57:       PetscEnum EPS_SMALLEST_REAL
 58:       PetscEnum EPS_LARGEST_IMAGINARY
 59:       PetscEnum EPS_SMALLEST_IMAGINARY
 60:       PetscEnum EPS_TARGET_MAGNITUDE
 61:       PetscEnum EPS_TARGET_REAL
 62:       PetscEnum EPS_TARGET_IMAGINARY
 63:       PetscEnum EPS_ALL
 64:       PetscEnum EPS_WHICH_USER

 66:       parameter (EPS_LARGEST_MAGNITUDE      =  1)
 67:       parameter (EPS_SMALLEST_MAGNITUDE     =  2)
 68:       parameter (EPS_LARGEST_REAL           =  3)
 69:       parameter (EPS_SMALLEST_REAL          =  4)
 70:       parameter (EPS_LARGEST_IMAGINARY      =  5)
 71:       parameter (EPS_SMALLEST_IMAGINARY     =  6)
 72:       parameter (EPS_TARGET_MAGNITUDE       =  7)
 73:       parameter (EPS_TARGET_REAL            =  8)
 74:       parameter (EPS_TARGET_IMAGINARY       =  9)
 75:       parameter (EPS_ALL                    = 10)
 76:       parameter (EPS_WHICH_USER             = 11)

 78:       PetscEnum EPS_BALANCE_NONE
 79:       PetscEnum EPS_BALANCE_ONESIDE
 80:       PetscEnum EPS_BALANCE_TWOSIDE
 81:       PetscEnum EPS_BALANCE_USER

 83:       parameter (EPS_BALANCE_NONE           =  0)
 84:       parameter (EPS_BALANCE_ONESIDE        =  1)
 85:       parameter (EPS_BALANCE_TWOSIDE        =  2)
 86:       parameter (EPS_BALANCE_USER           =  3)

 88:       PetscEnum EPS_RITZ
 89:       PetscEnum EPS_HARMONIC
 90:       PetscEnum EPS_HARMONIC_RELATIVE
 91:       PetscEnum EPS_HARMONIC_RIGHT
 92:       PetscEnum EPS_HARMONIC_LARGEST
 93:       PetscEnum EPS_REFINED
 94:       PetscEnum EPS_REFINED_HARMONIC

 96:       parameter (EPS_RITZ                   =  0)
 97:       parameter (EPS_HARMONIC               =  1)
 98:       parameter (EPS_HARMONIC_RELATIVE      =  2)
 99:       parameter (EPS_HARMONIC_RIGHT         =  3)
100:       parameter (EPS_HARMONIC_LARGEST       =  4)
101:       parameter (EPS_REFINED                =  5)
102:       parameter (EPS_REFINED_HARMONIC       =  6)

104:       PetscEnum EPS_ERROR_ABSOLUTE
105:       PetscEnum EPS_ERROR_RELATIVE
106:       PetscEnum EPS_ERROR_BACKWARD

108:       parameter (EPS_ERROR_ABSOLUTE         =  0)
109:       parameter (EPS_ERROR_RELATIVE         =  1)
110:       parameter (EPS_ERROR_BACKWARD         =  2)

112:       PetscEnum EPS_CONV_ABS
113:       PetscEnum EPS_CONV_REL
114:       PetscEnum EPS_CONV_NORM
115:       PetscEnum EPS_CONV_USER

117:       parameter (EPS_CONV_ABS               =  0)
118:       parameter (EPS_CONV_REL               =  1)
119:       parameter (EPS_CONV_NORM              =  2)
120:       parameter (EPS_CONV_USER              =  3)

122:       PetscEnum EPS_STOP_BASIC
123:       PetscEnum EPS_STOP_USER

125:       parameter (EPS_STOP_BASIC             =  0)
126:       parameter (EPS_STOP_USER              =  1)

128:       PetscEnum EPS_POWER_SHIFT_CONSTANT
129:       PetscEnum EPS_POWER_SHIFT_RAYLEIGH
130:       PetscEnum EPS_POWER_SHIFT_WILKINSON

132:       parameter (EPS_POWER_SHIFT_CONSTANT   =  0)
133:       parameter (EPS_POWER_SHIFT_RAYLEIGH   =  1)
134:       parameter (EPS_POWER_SHIFT_WILKINSON  =  2)

136:       PetscEnum EPS_LANCZOS_REORTHOG_LOCAL
137:       PetscEnum EPS_LANCZOS_REORTHOG_FULL
138:       PetscEnum EPS_LANCZOS_REORTHOG_SELECTIVE
139:       PetscEnum EPS_LANCZOS_REORTHOG_PERIODIC
140:       PetscEnum EPS_LANCZOS_REORTHOG_PARTIAL
141:       PetscEnum EPS_LANCZOS_REORTHOG_DELAYED

143:       parameter (EPS_LANCZOS_REORTHOG_LOCAL     =  0)
144:       parameter (EPS_LANCZOS_REORTHOG_FULL      =  1)
145:       parameter (EPS_LANCZOS_REORTHOG_SELECTIVE =  2)
146:       parameter (EPS_LANCZOS_REORTHOG_PERIODIC  =  3)
147:       parameter (EPS_LANCZOS_REORTHOG_PARTIAL   =  4)
148:       parameter (EPS_LANCZOS_REORTHOG_DELAYED   =  5)

150:       PetscEnum EPS_PRIMME_DYNAMIC
151:       PetscEnum EPS_PRIMME_DEFAULT_MIN_TIME
152:       PetscEnum EPS_PRIMME_DEFAULT_MIN_MATVECS
153:       PetscEnum EPS_PRIMME_ARNOLDI
154:       PetscEnum EPS_PRIMME_GD
155:       PetscEnum EPS_PRIMME_GD_PLUSK
156:       PetscEnum EPS_PRIMME_GD_OLSEN_PLUSK
157:       PetscEnum EPS_PRIMME_JD_OLSEN_PLUSK
158:       PetscEnum EPS_PRIMME_RQI
159:       PetscEnum EPS_PRIMME_JDQR
160:       PetscEnum EPS_PRIMME_JDQMR
161:       PetscEnum EPS_PRIMME_JDQMR_ETOL
162:       PetscEnum EPS_PRIMME_SUBSPACE_ITERATION
163:       PetscEnum EPS_PRIMME_LOBPCG_ORTHOBASIS
164:       PetscEnum EPS_PRIMME_LOBPCG_ORTHOBASISW

166:       parameter (EPS_PRIMME_DYNAMIC             =  0)
167:       parameter (EPS_PRIMME_DEFAULT_MIN_TIME    =  1)
168:       parameter (EPS_PRIMME_DEFAULT_MIN_MATVECS =  2)
169:       parameter (EPS_PRIMME_ARNOLDI             =  3)
170:       parameter (EPS_PRIMME_GD                  =  4)
171:       parameter (EPS_PRIMME_GD_PLUSK            =  5)
172:       parameter (EPS_PRIMME_GD_OLSEN_PLUSK      =  7)
173:       parameter (EPS_PRIMME_JD_OLSEN_PLUSK      =  8)
174:       parameter (EPS_PRIMME_RQI                 =  9)
175:       parameter (EPS_PRIMME_JDQR                = 10)
176:       parameter (EPS_PRIMME_JDQMR               = 11)
177:       parameter (EPS_PRIMME_JDQMR_ETOL          = 12)
178:       parameter (EPS_PRIMME_SUBSPACE_ITERATION  = 13)
179:       parameter (EPS_PRIMME_LOBPCG_ORTHOBASIS   = 14)
180:       parameter (EPS_PRIMME_LOBPCG_ORTHOBASISW  = 15)

182:       PetscEnum EPS_CISS_QUADRULE_TRAPEZOIDAL
183:       PetscEnum EPS_CISS_QUADRULE_CHEBYSHEV

185:       parameter (EPS_CISS_QUADRULE_TRAPEZOIDAL  =  1)
186:       parameter (EPS_CISS_QUADRULE_CHEBYSHEV    =  2)

188:       PetscEnum EPS_CISS_EXTRACTION_RITZ
189:       PetscEnum EPS_CISS_EXTRACTION_HANKEL

191:       parameter (EPS_CISS_EXTRACTION_RITZ       =  0)
192:       parameter (EPS_CISS_EXTRACTION_HANKEL     =  1)

194: !
195: !   Possible arguments to EPSMonitorSet()
196: !
197:       external EPSMONITORALL
198:       external EPSMONITORLG
199:       external EPSMONITORLGALL
200:       external EPSMONITORCONVERGED
201:       external EPSMONITORFIRST

203: !
204: !  End of Fortran include file for the EPS package in SLEPc
205: !
slepc-3.7.4/include/slepc/finclude/slepcfn.h90.html0000644000175000017500000000601013107004621021421 0ustar jromanjroman
Actual source code: slepcfn.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional FN include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcfn.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcfn.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcfn.h.html0000644000175000017500000000643413107004621021262 0ustar jromanjroman
Actual source code: slepcfn.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the FN object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcfndef.h

 26:       PetscEnum FN_COMBINE_ADD
 27:       PetscEnum FN_COMBINE_MULTIPLY
 28:       PetscEnum FN_COMBINE_DIVIDE
 29:       PetscEnum FN_COMBINE_COMPOSE

 31:       parameter (FN_COMBINE_ADD           =  0)
 32:       parameter (FN_COMBINE_MULTIPLY      =  1)
 33:       parameter (FN_COMBINE_DIVIDE        =  2)
 34:       parameter (FN_COMBINE_COMPOSE       =  3)

 36: !
 37: !  End of Fortran include file for the FN package in SLEPc
 38: !
slepc-3.7.4/include/slepc/finclude/slepcrg.h90.html0000644000175000017500000000601013107004621021426 0ustar jromanjroman
Actual source code: slepcrg.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional RG include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcrg.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcrg.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcfndef.h.html0000644000175000017500000000744013107004621021737 0ustar jromanjroman
Actual source code: slepcfndef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the FN object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 27: #define FN PetscFortranAddr
 28: #endif

 30: #define FNType        character*(80)
 31: #define FNCombineType PetscEnum

 33: #define FNCOMBINE  'combine'
 34: #define FNRATIONAL 'rational'
 35: #define FNEXP      'exp'
 36: #define FNLOG      'log'
 37: #define FNPHI      'phi'
 38: #define FNSQRT     'sqrt'
 39: #define FNINVSQRT  'invsqrt'

 41: #endif
slepc-3.7.4/include/slepc/finclude/slepcmfn.h900000644000175000017500000000223713107004621020642 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional MFN include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcmfn.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcmfn.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepcbvdef.h0000644000175000017500000000263013107004621020774 0ustar jromanjroman! ! Include file for Fortran use of the BV object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCBVDEF_H) #define __SLEPCBVDEF_H #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define BV PetscFortranAddr #endif #define BVType character*(80) #define BVOrthogType PetscEnum #define BVOrthogRefineType PetscEnum #define BVOrthogBlockType PetscEnum #define BVMatMultType PetscEnum #define BVMAT 'mat' #define BVSVEC 'svec' #define BVVECS 'vecs' #define BVCONTIGUOUS 'contiguous' #endif slepc-3.7.4/include/slepc/finclude/slepcnep.h.html0000644000175000017500000001730313107004621021436 0ustar jromanjroman
Actual source code: slepcnep.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the NEP object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcnepdef.h

 26: !  Convergence flags.
 27: !  They should match the flags in $SLEPC_DIR/include/slepcnep.h

 29:       PetscEnum NEP_REFINE_NONE
 30:       PetscEnum NEP_REFINE_SIMPLE
 31:       PetscEnum NEP_REFINE_MULTIPLE

 33:       parameter (NEP_REFINE_NONE            =  0)
 34:       parameter (NEP_REFINE_SIMPLE          =  1)
 35:       parameter (NEP_REFINE_MULTIPLE        =  2)

 37:       PetscEnum NEP_REFINE_SCHEME_SCHUR
 38:       PetscEnum NEP_REFINE_SCHEME_MBE
 39:       PetscEnum NEP_REFINE_SCHEME_EXPLICIT

 41:       parameter (NEP_REFINE_SCHEME_SCHUR    =  1)
 42:       parameter (NEP_REFINE_SCHEME_MBE      =  2)
 43:       parameter (NEP_REFINE_SCHEME_EXPLICIT =  3)

 45:       PetscEnum NEP_CONV_ABS
 46:       PetscEnum NEP_CONV_REL
 47:       PetscEnum NEP_CONV_NORM
 48:       PetscEnum NEP_CONV_USER

 50:       parameter (NEP_CONV_ABS               =  0)
 51:       parameter (NEP_CONV_REL               =  1)
 52:       parameter (NEP_CONV_NORM              =  2)
 53:       parameter (NEP_CONV_USER              =  3)

 55:       PetscEnum NEP_STOP_BASIC
 56:       PetscEnum NEP_STOP_USER

 58:       parameter (NEP_STOP_BASIC             =  0)
 59:       parameter (NEP_STOP_USER              =  1)

 61:       PetscEnum NEP_CONVERGED_TOL
 62:       PetscEnum NEP_CONVERGED_USER
 63:       PetscEnum NEP_DIVERGED_ITS
 64:       PetscEnum NEP_DIVERGED_BREAKDOWN
 65:       PetscEnum NEP_DIVERGED_LINEAR_SOLVE
 66:       PetscEnum NEP_CONVERGED_ITERATING

 68:       parameter (NEP_CONVERGED_TOL            =  1)
 69:       parameter (NEP_CONVERGED_USER           =  2)
 70:       parameter (NEP_DIVERGED_ITS             = -1)
 71:       parameter (NEP_DIVERGED_BREAKDOWN       = -2)
 72:       parameter (NEP_DIVERGED_LINEAR_SOLVE    = -4)
 73:       parameter (NEP_CONVERGED_ITERATING      =  0)

 75:       PetscEnum NEP_LARGEST_MAGNITUDE
 76:       PetscEnum NEP_SMALLEST_MAGNITUDE
 77:       PetscEnum NEP_LARGEST_REAL
 78:       PetscEnum NEP_SMALLEST_REAL
 79:       PetscEnum NEP_LARGEST_IMAGINARY
 80:       PetscEnum NEP_SMALLEST_IMAGINARY
 81:       PetscEnum NEP_TARGET_MAGNITUDE
 82:       PetscEnum NEP_TARGET_REAL
 83:       PetscEnum NEP_TARGET_IMAGINARY
 84:       PetscEnum NEP_ALL
 85:       PetscEnum NEP_WHICH_USER

 87:       parameter (NEP_LARGEST_MAGNITUDE      =  1)
 88:       parameter (NEP_SMALLEST_MAGNITUDE     =  2)
 89:       parameter (NEP_LARGEST_REAL           =  3)
 90:       parameter (NEP_SMALLEST_REAL          =  4)
 91:       parameter (NEP_LARGEST_IMAGINARY      =  5)
 92:       parameter (NEP_SMALLEST_IMAGINARY     =  6)
 93:       parameter (NEP_TARGET_MAGNITUDE       =  7)
 94:       parameter (NEP_TARGET_REAL            =  8)
 95:       parameter (NEP_TARGET_IMAGINARY       =  9)
 96:       parameter (NEP_ALL                    = 10)
 97:       parameter (NEP_WHICH_USER             = 11)

 99:       PetscEnum NEP_ERROR_ABSOLUTE
100:       PetscEnum NEP_ERROR_RELATIVE
101:       PetscEnum NEP_ERROR_BACKWARD

103:       parameter (NEP_ERROR_ABSOLUTE         =  0)
104:       parameter (NEP_ERROR_RELATIVE         =  1)
105:       parameter (NEP_ERROR_BACKWARD         =  2)

107: !
108: !   Possible arguments to NEPMonitorSet()
109: !
110:       external NEPMONITORALL
111:       external NEPMONITORLG
112:       external NEPMONITORLGALL
113:       external NEPMONITORCONVERGED
114:       external NEPMONITORFIRST

116: !
117: !  End of Fortran include file for the NEP package in SLEPc
118: !
slepc-3.7.4/include/slepc/finclude/slepcst.h90.html0000644000175000017500000000601013107004621021444 0ustar jromanjroman
Actual source code: slepcst.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional ST include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcst.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcst.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcsvd.h900000644000175000017500000000223713107004621020656 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional SVD include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcsvd.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcsvd.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepcsys.h0000644000175000017500000000313313107004621020523 0ustar jromanjroman! ! Basic include file for Fortran use of the SLEPc package ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "petscconf.h" #include "petsc/finclude/petscdef.h" #include "slepcversion.h" #include "slepc/finclude/slepcsysdef.h" #if !defined(PETSC_USE_FORTRAN_DATATYPES) external SlepcConvMonitorDestroy #endif ! Default tolerance for the different solvers, depending on the precision PetscReal SLEPC_DEFAULT_TOL #if defined(PETSC_USE_REAL_SINGLE) parameter(SLEPC_DEFAULT_TOL = 1e-6) #elif defined(PETSC_USE_REAL_DOUBLE) parameter(SLEPC_DEFAULT_TOL = 1e-8) #elif defined(PETSC_USE_REAL___FLOAT128) parameter(SLEPC_DEFAULT_TOL = 1e-16) #else parameter(SLEPC_DEFAULT_TOL = 1e-7) #endif slepc-3.7.4/include/slepc/finclude/slepcdsdef.h0000644000175000017500000000263213107004621020775 0ustar jromanjroman! ! Include file for Fortran use of the DS object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCDSDEF_H) #define __SLEPCDSDEF_H #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define DS PetscFortranAddr #endif #define DSType character*(80) #define DSStateType PetscEnum #define DSMatType PetscEnum #define DSHEP 'hep' #define DSNHEP 'nhep' #define DSGHEP 'ghep' #define DSGHIEP 'ghiep' #define DSGNHEP 'gnhep' #define DSSVD 'svd' #define DSPEP 'pep' #define DSNEP 'nep' #endif slepc-3.7.4/include/slepc/finclude/slepcsvd.h90.html0000644000175000017500000000602213107004621021615 0ustar jromanjroman
Actual source code: slepcsvd.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional SVD include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcsvd.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcsvd.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcds.h0000644000175000017500000000570013107004621020315 0ustar jromanjroman! ! Include file for Fortran use of the DS object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcdsdef.h" PetscEnum DS_STATE_RAW PetscEnum DS_STATE_INTERMEDIATE PetscEnum DS_STATE_CONDENSED PetscEnum DS_STATE_TRUNCATED parameter (DS_STATE_RAW = 0) parameter (DS_STATE_INTERMEDIATE = 1) parameter (DS_STATE_CONDENSED = 2) parameter (DS_STATE_TRUNCATED = 3) PetscEnum DS_MAT_A PetscEnum DS_MAT_B PetscEnum DS_MAT_C PetscEnum DS_MAT_T PetscEnum DS_MAT_D PetscEnum DS_MAT_F PetscEnum DS_MAT_Q PetscEnum DS_MAT_Z PetscEnum DS_MAT_X PetscEnum DS_MAT_Y PetscEnum DS_MAT_U PetscEnum DS_MAT_VT PetscEnum DS_MAT_W PetscEnum DS_MAT_E0 PetscEnum DS_MAT_E1 PetscEnum DS_MAT_E2 PetscEnum DS_MAT_E3 PetscEnum DS_MAT_E4 PetscEnum DS_MAT_E5 PetscEnum DS_MAT_E6 PetscEnum DS_MAT_E7 PetscEnum DS_MAT_E8 PetscEnum DS_MAT_E9 PetscEnum DS_NUM_MAT parameter (DS_MAT_A = 0) parameter (DS_MAT_B = 1) parameter (DS_MAT_C = 2) parameter (DS_MAT_T = 3) parameter (DS_MAT_D = 4) parameter (DS_MAT_F = 5) parameter (DS_MAT_Q = 6) parameter (DS_MAT_Z = 7) parameter (DS_MAT_X = 8) parameter (DS_MAT_Y = 9) parameter (DS_MAT_U = 10) parameter (DS_MAT_VT = 11) parameter (DS_MAT_W = 12) parameter (DS_MAT_E0 = 13) parameter (DS_MAT_E1 = 14) parameter (DS_MAT_E2 = 15) parameter (DS_MAT_E3 = 16) parameter (DS_MAT_E4 = 17) parameter (DS_MAT_E5 = 18) parameter (DS_MAT_E6 = 19) parameter (DS_MAT_E7 = 20) parameter (DS_MAT_E8 = 21) parameter (DS_MAT_E9 = 22) parameter (DS_NUM_MAT = 23) ! ! End of Fortran include file for the DS package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcbv.h90.html0000644000175000017500000000601013107004621021425 0ustar jromanjroman
Actual source code: slepcbv.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional BV include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcbv.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcbv.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcst.h900000644000175000017500000000223413107004621020505 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional ST include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcst.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcst.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepcpep.h0000644000175000017500000001253213107004621020474 0ustar jromanjroman! ! Include file for Fortran use of the PEP object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcpepdef.h" ! Convergence flags. ! They should match the flags in $SLEPC_DIR/include/slepcpep.h PetscEnum PEP_CONVERGED_TOL PetscEnum PEP_CONVERGED_USER PetscEnum PEP_DIVERGED_ITS PetscEnum PEP_DIVERGED_BREAKDOWN PetscEnum PEP_DIVERGED_SYMMETRY_LOST PetscEnum PEP_CONVERGED_ITERATING parameter (PEP_CONVERGED_TOL = 1) parameter (PEP_CONVERGED_USER = 2) parameter (PEP_DIVERGED_ITS = -1) parameter (PEP_DIVERGED_BREAKDOWN = -2) parameter (PEP_DIVERGED_SYMMETRY_LOST = -3) parameter (PEP_CONVERGED_ITERATING = 0) PetscEnum PEP_GENERAL PetscEnum PEP_HERMITIAN PetscEnum PEP_GYROSCOPIC parameter (PEP_GENERAL = 1) parameter (PEP_HERMITIAN = 2) parameter (PEP_GYROSCOPIC = 3) PetscEnum PEP_LARGEST_MAGNITUDE PetscEnum PEP_SMALLEST_MAGNITUDE PetscEnum PEP_LARGEST_REAL PetscEnum PEP_SMALLEST_REAL PetscEnum PEP_LARGEST_IMAGINARY PetscEnum PEP_SMALLEST_IMAGINARY PetscEnum PEP_TARGET_MAGNITUDE PetscEnum PEP_TARGET_REAL PetscEnum PEP_TARGET_IMAGINARY PetscEnum PEP_WHICH_USER parameter (PEP_LARGEST_MAGNITUDE = 1) parameter (PEP_SMALLEST_MAGNITUDE = 2) parameter (PEP_LARGEST_REAL = 3) parameter (PEP_SMALLEST_REAL = 4) parameter (PEP_LARGEST_IMAGINARY = 5) parameter (PEP_SMALLEST_IMAGINARY = 6) parameter (PEP_TARGET_MAGNITUDE = 7) parameter (PEP_TARGET_REAL = 8) parameter (PEP_TARGET_IMAGINARY = 9) parameter (PEP_WHICH_USER = 10) PetscEnum PEP_BASIS_MONOMIAL PetscEnum PEP_BASIS_CHEBYSHEV1 PetscEnum PEP_BASIS_CHEBYSHEV2 PetscEnum PEP_BASIS_LEGENDRE PetscEnum PEP_BASIS_LAGUERRE PetscEnum PEP_BASIS_HERMITE parameter (PEP_BASIS_MONOMIAL = 0) parameter (PEP_BASIS_CHEBYSHEV1 = 1) parameter (PEP_BASIS_CHEBYSHEV2 = 2) parameter (PEP_BASIS_LEGENDRE = 3) parameter (PEP_BASIS_LAGUERRE = 4) parameter (PEP_BASIS_HERMITE = 5) PetscEnum PEP_SCALE_NONE PetscEnum PEP_SCALE_SCALAR PetscEnum PEP_SCALE_DIAGONAL PetscEnum PEP_SCALE_BOTH parameter (PEP_SCALE_NONE = 0) parameter (PEP_SCALE_SCALAR = 1) parameter (PEP_SCALE_DIAGONAL = 2) parameter (PEP_SCALE_BOTH = 3) PetscEnum PEP_REFINE_NONE PetscEnum PEP_REFINE_SIMPLE PetscEnum PEP_REFINE_MULTIPLE parameter (PEP_REFINE_NONE = 0) parameter (PEP_REFINE_SIMPLE = 1) parameter (PEP_REFINE_MULTIPLE = 2) PetscEnum PEP_REFINE_SCHEME_SCHUR PetscEnum PEP_REFINE_SCHEME_MBE PetscEnum PEP_REFINE_SCHEME_EXPLICIT parameter (PEP_REFINE_SCHEME_SCHUR = 1) parameter (PEP_REFINE_SCHEME_MBE = 2) parameter (PEP_REFINE_SCHEME_EXPLICIT = 3) PetscEnum PEP_EXTRACT_NONE PetscEnum PEP_EXTRACT_NORM PetscEnum PEP_EXTRACT_RESIDUAL PetscEnum PEP_EXTRACT_STRUCTURED parameter (PEP_EXTRACT_NONE = 1) parameter (PEP_EXTRACT_NORM = 2) parameter (PEP_EXTRACT_RESIDUAL = 3) parameter (PEP_EXTRACT_STRUCTURED = 4) PetscEnum PEP_ERROR_ABSOLUTE PetscEnum PEP_ERROR_RELATIVE PetscEnum PEP_ERROR_BACKWARD parameter (PEP_ERROR_ABSOLUTE = 0) parameter (PEP_ERROR_RELATIVE = 1) parameter (PEP_ERROR_BACKWARD = 2) PetscEnum PEP_CONV_ABS PetscEnum PEP_CONV_REL PetscEnum PEP_CONV_NORM PetscEnum PEP_CONV_USER parameter (PEP_CONV_ABS = 0) parameter (PEP_CONV_REL = 1) parameter (PEP_CONV_NORM = 2) parameter (PEP_CONV_USER = 3) PetscEnum PEP_STOP_BASIC PetscEnum PEP_STOP_USER parameter (PEP_STOP_BASIC = 0) parameter (PEP_STOP_USER = 1) ! ! Possible arguments to PEPMonitorSet() ! external PEPMONITORALL external PEPMONITORLG external PEPMONITORLGALL external PEPMONITORCONVERGED external PEPMONITORFIRST ! ! End of Fortran include file for the PEP package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcpep.h900000644000175000017500000000223713107004621020646 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional PEP include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcpep.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcpep.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepcds.h90.html0000644000175000017500000000601013107004621021424 0ustar jromanjroman
Actual source code: slepcds.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional DS include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcds.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcds.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcrgdef.h.html0000644000175000017500000000651313107004621021744 0ustar jromanjroman
Actual source code: slepcrgdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the RG object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 27: #define RG PetscFortranAddr
 28: #endif

 30: #define RGType      character*(80)

 32: #define RGINTERVAL  'interval'
 33: #define RGPOLYGON   'polygon'
 34: #define RGELLIPSE   'ellipse'
 35: #define RGRING      'ring'

 37: #endif
slepc-3.7.4/include/slepc/finclude/slepcnep.h0000644000175000017500000001002713107004621020467 0ustar jromanjroman! ! Include file for Fortran use of the NEP object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcnepdef.h" ! Convergence flags. ! They should match the flags in $SLEPC_DIR/include/slepcnep.h PetscEnum NEP_REFINE_NONE PetscEnum NEP_REFINE_SIMPLE PetscEnum NEP_REFINE_MULTIPLE parameter (NEP_REFINE_NONE = 0) parameter (NEP_REFINE_SIMPLE = 1) parameter (NEP_REFINE_MULTIPLE = 2) PetscEnum NEP_REFINE_SCHEME_SCHUR PetscEnum NEP_REFINE_SCHEME_MBE PetscEnum NEP_REFINE_SCHEME_EXPLICIT parameter (NEP_REFINE_SCHEME_SCHUR = 1) parameter (NEP_REFINE_SCHEME_MBE = 2) parameter (NEP_REFINE_SCHEME_EXPLICIT = 3) PetscEnum NEP_CONV_ABS PetscEnum NEP_CONV_REL PetscEnum NEP_CONV_NORM PetscEnum NEP_CONV_USER parameter (NEP_CONV_ABS = 0) parameter (NEP_CONV_REL = 1) parameter (NEP_CONV_NORM = 2) parameter (NEP_CONV_USER = 3) PetscEnum NEP_STOP_BASIC PetscEnum NEP_STOP_USER parameter (NEP_STOP_BASIC = 0) parameter (NEP_STOP_USER = 1) PetscEnum NEP_CONVERGED_TOL PetscEnum NEP_CONVERGED_USER PetscEnum NEP_DIVERGED_ITS PetscEnum NEP_DIVERGED_BREAKDOWN PetscEnum NEP_DIVERGED_LINEAR_SOLVE PetscEnum NEP_CONVERGED_ITERATING parameter (NEP_CONVERGED_TOL = 1) parameter (NEP_CONVERGED_USER = 2) parameter (NEP_DIVERGED_ITS = -1) parameter (NEP_DIVERGED_BREAKDOWN = -2) parameter (NEP_DIVERGED_LINEAR_SOLVE = -4) parameter (NEP_CONVERGED_ITERATING = 0) PetscEnum NEP_LARGEST_MAGNITUDE PetscEnum NEP_SMALLEST_MAGNITUDE PetscEnum NEP_LARGEST_REAL PetscEnum NEP_SMALLEST_REAL PetscEnum NEP_LARGEST_IMAGINARY PetscEnum NEP_SMALLEST_IMAGINARY PetscEnum NEP_TARGET_MAGNITUDE PetscEnum NEP_TARGET_REAL PetscEnum NEP_TARGET_IMAGINARY PetscEnum NEP_ALL PetscEnum NEP_WHICH_USER parameter (NEP_LARGEST_MAGNITUDE = 1) parameter (NEP_SMALLEST_MAGNITUDE = 2) parameter (NEP_LARGEST_REAL = 3) parameter (NEP_SMALLEST_REAL = 4) parameter (NEP_LARGEST_IMAGINARY = 5) parameter (NEP_SMALLEST_IMAGINARY = 6) parameter (NEP_TARGET_MAGNITUDE = 7) parameter (NEP_TARGET_REAL = 8) parameter (NEP_TARGET_IMAGINARY = 9) parameter (NEP_ALL = 10) parameter (NEP_WHICH_USER = 11) PetscEnum NEP_ERROR_ABSOLUTE PetscEnum NEP_ERROR_RELATIVE PetscEnum NEP_ERROR_BACKWARD parameter (NEP_ERROR_ABSOLUTE = 0) parameter (NEP_ERROR_RELATIVE = 1) parameter (NEP_ERROR_BACKWARD = 2) ! ! Possible arguments to NEPMonitorSet() ! external NEPMONITORALL external NEPMONITORLG external NEPMONITORLGALL external NEPMONITORCONVERGED external NEPMONITORFIRST ! ! End of Fortran include file for the NEP package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcnepdef.h.html0000644000175000017500000001305013107004621022110 0ustar jromanjroman
Actual source code: slepcnepdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the NEP object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26:  #include slepc/finclude/slepcbvdef.h
 27:  #include slepc/finclude/slepcdsdef.h
 28:  #include slepc/finclude/slepcrgdef.h
 29:  #include slepc/finclude/slepcfndef.h
 30:  #include slepc/finclude/slepcepsdef.h
 31:  #include slepc/finclude/slepcpepdef.h

 33: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 34: #define NEP PetscFortranAddr
 35: #endif

 37: #define NEPType            character*(80)
 38: #define NEPConvergedReason PetscEnum
 39: #define NEPErrorType       PetscEnum
 40: #define NEPWhich           PetscEnum
 41: #define NEPConv            PetscEnum
 42: #define NEPStop            PetscEnum
 43: #define NEPRefine          PetscEnum
 44: #define NEPRefineScheme    PetscEnum

 46: #define NEPRII       'rii'
 47: #define NEPSLP       'slp'
 48: #define NEPNARNOLDI  'narnoldi'
 49: #define NEPCISS      'ciss'
 50: #define NEPINTERPOL  'interpol'
 51: #define NEPNLEIGS    'nleigs'

 53: #endif
slepc-3.7.4/include/slepc/finclude/index.html0000644000175000017500000000434113107004621020504 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

slepc.h
slepceps.h
slepcst.h
slepcsvd.h
slepcpep.h
slepcnep.h
slepcmfn.h
slepcds.h
slepcfn.h
slepcrg.h
slepcbv.h
slepcsys.h
slepc.h90
slepceps.h90
slepcst.h90
slepcsvd.h90
slepcpep.h90
slepcnep.h90
slepcmfn.h90
slepcds.h90
slepcfn.h90
slepcrg.h90
slepcbv.h90
slepcdef.h
slepcepsdef.h
slepcstdef.h
slepcsvddef.h
slepcpepdef.h
slepcnepdef.h
slepcmfndef.h
slepcdsdef.h
slepcfndef.h
slepcrgdef.h
slepcbvdef.h
slepcsysdef.h
makefile
slepc-3.7.4/include/slepc/finclude/ftn-auto/0000755000175000017500000000000013107004621020242 5ustar jromanjromanslepc-3.7.4/include/slepc/finclude/ftn-auto/makefile0000644000175000017500000000056513107004621021750 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = SOURCEF = SOURCEH = slepcnep.h90 slepcbv.h90 slepceps.h90 slepcds.h90 slepcmfn.h90 slepcsvd.h90 slepcst.h90 slepcpep.h90 slepcsys.h90 slepcrg.h90 slepcfn.h90 DIRS = LIBBASE = libslepcsys LOCDIR = include/slepc/finclude/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcnep.h900000644000175000017500000002673713107004621022414 0ustar jromanjroman subroutine NEPCreate(a,b,z) integer a ! MPI_Comm NEP b ! NEP integer z end subroutine subroutine NEPReset(a,z) NEP a ! NEP integer z end subroutine subroutine NEPDestroy(a,z) NEP a ! NEP integer z end subroutine subroutine NEPSetBV(a,b,z) NEP a ! NEP BV b ! BV integer z end subroutine subroutine NEPGetBV(a,b,z) NEP a ! NEP BV b ! BV integer z end subroutine subroutine NEPSetRG(a,b,z) NEP a ! NEP RG b ! RG integer z end subroutine subroutine NEPGetRG(a,b,z) NEP a ! NEP RG b ! RG integer z end subroutine subroutine NEPSetDS(a,b,z) NEP a ! NEP DS b ! DS integer z end subroutine subroutine NEPGetDS(a,b,z) NEP a ! NEP DS b ! DS integer z end subroutine subroutine NEPRefineGetKSP(a,b,z) NEP a ! NEP KSP b ! KSP integer z end subroutine subroutine NEPSetTarget(a,b,z) NEP a ! NEP PetscScalar b ! PetscScalar integer z end subroutine subroutine NEPGetTarget(a,b,z) NEP a ! NEP PetscScalar b ! PetscScalar integer z end subroutine subroutine NEPSetSplitOperator(a,b,c,d,e,z) NEP a ! NEP PetscInt b ! PetscInt Mat c (*) ! Mat FN d (*) ! FN MatStructure e ! MatStructure integer z end subroutine subroutine NEPGetSplitOperatorTerm(a,b,c,d,z) NEP a ! NEP PetscInt b ! PetscInt Mat c ! Mat FN d ! FN integer z end subroutine subroutine NEPGetSplitOperatorInfo(a,b,c,z) NEP a ! NEP PetscInt b ! PetscInt MatStructure c ! MatStructure integer z end subroutine subroutine NEPSolve(a,z) NEP a ! NEP integer z end subroutine subroutine NEPProjectOperator(a,b,c,z) NEP a ! NEP PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine NEPApplyFunction(a,b,c,d,e,f,g,z) NEP a ! NEP PetscScalar b ! PetscScalar Vec c ! Vec Vec d ! Vec Vec e ! Vec Mat f ! Mat Mat g ! Mat integer z end subroutine subroutine NEPApplyJacobian(a,b,c,d,e,f,z) NEP a ! NEP PetscScalar b ! PetscScalar Vec c ! Vec Vec d ! Vec Vec e ! Vec Mat f ! Mat integer z end subroutine subroutine NEPGetIterationNumber(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPGetConverged(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPGetConvergedReason(a,b,z) NEP a ! NEP NEPConvergedReason b ! NEPConvergedReason integer z end subroutine subroutine NEPGetEigenpair(a,b,c,d,e,f,z) NEP a ! NEP PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar Vec e ! Vec Vec f ! Vec integer z end subroutine subroutine NEPGetErrorEstimate(a,b,c,z) NEP a ! NEP PetscInt b ! PetscInt PetscReal c ! PetscReal integer z end subroutine subroutine NEPComputeError(a,b,c,d,z) NEP a ! NEP PetscInt b ! PetscInt NEPErrorType c ! NEPErrorType PetscReal d ! PetscReal integer z end subroutine subroutine NEPComputeFunction(a,b,c,d,z) NEP a ! NEP PetscScalar b ! PetscScalar Mat c ! Mat Mat d ! Mat integer z end subroutine subroutine NEPComputeJacobian(a,b,c,z) NEP a ! NEP PetscScalar b ! PetscScalar Mat c ! Mat integer z end subroutine subroutine NEPSetWorkVecs(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPSetFromOptions(a,z) NEP a ! NEP integer z end subroutine subroutine NEPGetTolerances(a,b,c,z) NEP a ! NEP PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine NEPSetTolerances(a,b,c,z) NEP a ! NEP PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine NEPGetDimensions(a,b,c,d,z) NEP a ! NEP PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine NEPSetDimensions(a,b,c,d,z) NEP a ! NEP PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine NEPSetWhichEigenpairs(a,b,z) NEP a ! NEP NEPWhich b ! NEPWhich integer z end subroutine subroutine NEPGetWhichEigenpairs(a,b,z) NEP a ! NEP NEPWhich b ! NEPWhich integer z end subroutine subroutine NEPSetConvergenceTest(a,b,z) NEP a ! NEP NEPConv b ! NEPConv integer z end subroutine subroutine NEPGetConvergenceTest(a,b,z) NEP a ! NEP NEPConv b ! NEPConv integer z end subroutine subroutine NEPSetStoppingTest(a,b,z) NEP a ! NEP NEPStop b ! NEPStop integer z end subroutine subroutine NEPGetStoppingTest(a,b,z) NEP a ! NEP NEPStop b ! NEPStop integer z end subroutine subroutine NEPSetTrackAll(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPGetTrackAll(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPSetRefine(a,b,c,d,e,f,z) NEP a ! NEP NEPRefine b ! NEPRefine PetscInt c ! PetscInt PetscReal d ! PetscReal PetscInt e ! PetscInt NEPRefineScheme f ! NEPRefineScheme integer z end subroutine subroutine NEPGetRefine(a,b,c,d,e,f,z) NEP a ! NEP NEPRefine b ! NEPRefine PetscInt c ! PetscInt PetscReal d ! PetscReal PetscInt e ! PetscInt NEPRefineScheme f ! NEPRefineScheme integer z end subroutine subroutine NEPSetUp(a,z) NEP a ! NEP integer z end subroutine subroutine NEPSetInitialSpace(a,b,c,z) NEP a ! NEP PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine NEPAllocateSolution(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPReasonViewFromOptions(a,z) NEP a ! NEP integer z end subroutine subroutine NEPErrorViewFromOptions(a,z) NEP a ! NEP integer z end subroutine subroutine NEPValuesViewFromOptions(a,z) NEP a ! NEP integer z end subroutine subroutine NEPVectorsViewFromOptions(a,z) NEP a ! NEP integer z end subroutine subroutine NEPMonitorCancel(a,z) NEP a ! NEP integer z end subroutine subroutine NEPNArnoldiSetKSP(a,b,z) NEP a ! NEP KSP b ! KSP integer z end subroutine subroutine NEPNArnoldiGetKSP(a,b,z) NEP a ! NEP KSP b ! KSP integer z end subroutine subroutine NEPRIISetMaximumIterations(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPRIIGetMaximumIterations(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPRIISetLagPreconditioner(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPRIIGetLagPreconditioner(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPRIISetConstCorrectionTol(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPRIIGetConstCorrectionTol(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPRIISetKSP(a,b,z) NEP a ! NEP KSP b ! KSP integer z end subroutine subroutine NEPRIIGetKSP(a,b,z) NEP a ! NEP KSP b ! KSP integer z end subroutine subroutine NEPInterpolSetDegree(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPInterpolGetDegree(a,b,z) NEP a ! NEP PetscInt b ! PetscInt integer z end subroutine subroutine NEPInterpolSetPEP(a,b,z) NEP a ! NEP PEP b ! PEP integer z end subroutine subroutine NEPInterpolGetPEP(a,b,z) NEP a ! NEP PEP b ! PEP integer z end subroutine subroutine NEPNLEIGSSetRestart(a,b,z) NEP a ! NEP PetscReal b ! PetscReal integer z end subroutine subroutine NEPNLEIGSGetRestart(a,b,z) NEP a ! NEP PetscReal b ! PetscReal integer z end subroutine subroutine NEPNLEIGSSetLocking(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPNLEIGSGetLocking(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPNLEIGSSetInterpolation(a,b,c,z) NEP a ! NEP PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine NEPNLEIGSGetInterpolation(a,b,c,z) NEP a ! NEP PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine NEPNLEIGSSetTrueResidual(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPNLEIGSGetTrueResidual(a,b,z) NEP a ! NEP PetscBool b ! PetscBool integer z end subroutine subroutine NEPCISSSetSizes(a,b,c,d,e,f,g,z) NEP a ! NEP PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt PetscInt e ! PetscInt PetscInt f ! PetscInt PetscBool g ! PetscBool integer z end subroutine subroutine NEPCISSGetSizes(a,b,c,d,e,f,g,z) NEP a ! NEP PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt PetscInt e ! PetscInt PetscInt f ! PetscInt PetscBool g ! PetscBool integer z end subroutine subroutine NEPCISSSetThreshold(a,b,c,z) NEP a ! NEP PetscReal b ! PetscReal PetscReal c ! PetscReal integer z end subroutine subroutine NEPCISSGetThreshold(a,b,c,z) NEP a ! NEP PetscReal b ! PetscReal PetscReal c ! PetscReal integer z end subroutine subroutine NEPCISSSetRefinement(a,b,c,z) NEP a ! NEP PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine NEPCISSGetRefinement(a,b,c,z) NEP a ! NEP PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine NEPSLPSetEPS(a,b,z) NEP a ! NEP EPS b ! EPS integer z end subroutine subroutine NEPSLPGetEPS(a,b,z) NEP a ! NEP EPS b ! EPS integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcbv.h900000644000175000017500000002403413107004621022225 0ustar jromanjroman subroutine BVSetSizes(a,b,c,d,z) BV a ! BV PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine BVSetSizesFromVec(a,b,c,z) BV a ! BV Vec b ! Vec PetscInt c ! PetscInt integer z end subroutine subroutine BVGetSizes(a,b,c,d,z) BV a ! BV PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine BVSetNumConstraints(a,b,z) BV a ! BV PetscInt b ! PetscInt integer z end subroutine subroutine BVGetNumConstraints(a,b,z) BV a ! BV PetscInt b ! PetscInt integer z end subroutine subroutine BVResize(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscBool c ! PetscBool integer z end subroutine subroutine BVSetActiveColumns(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine BVGetActiveColumns(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine BVSetMatrix(a,b,c,z) BV a ! BV Mat b ! Mat PetscBool c ! PetscBool integer z end subroutine subroutine BVGetMatrix(a,b,c,z) BV a ! BV Mat b ! Mat PetscBool c ! PetscBool integer z end subroutine subroutine BVApplyMatrix(a,b,c,z) BV a ! BV Vec b ! Vec Vec c ! Vec integer z end subroutine subroutine BVApplyMatrixBV(a,b,z) BV a ! BV BV b ! BV integer z end subroutine subroutine BVGetCachedBV(a,b,z) BV a ! BV BV b ! BV integer z end subroutine subroutine BVSetSignature(a,b,z) BV a ! BV Vec b ! Vec integer z end subroutine subroutine BVGetSignature(a,b,z) BV a ! BV Vec b ! Vec integer z end subroutine subroutine BVSetRandomContext(a,b,z) BV a ! BV PetscRandom b ! PetscRandom integer z end subroutine subroutine BVGetRandomContext(a,b,z) BV a ! BV PetscRandom b ! PetscRandom integer z end subroutine subroutine BVSetFromOptions(a,z) BV a ! BV integer z end subroutine subroutine BVSetOrthogonalization(a,b,c,d,e,z) BV a ! BV BVOrthogType b ! BVOrthogType BVOrthogRefineType c ! BVOrthogRefineType PetscReal d ! PetscReal BVOrthogBlockType e ! BVOrthogBlockType integer z end subroutine subroutine BVGetOrthogonalization(a,b,c,d,e,z) BV a ! BV BVOrthogType b ! BVOrthogType BVOrthogRefineType c ! BVOrthogRefineType PetscReal d ! PetscReal BVOrthogBlockType e ! BVOrthogBlockType integer z end subroutine subroutine BVSetMatMultMethod(a,b,z) BV a ! BV BVMatMultType b ! BVMatMultType integer z end subroutine subroutine BVGetMatMultMethod(a,b,z) BV a ! BV BVMatMultType b ! BVMatMultType integer z end subroutine subroutine BVGetColumn(a,b,c,z) BV a ! BV PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine BVRestoreColumn(a,b,c,z) BV a ! BV PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine BVCreateVec(a,b,z) BV a ! BV Vec b ! Vec integer z end subroutine subroutine BVDuplicate(a,b,z) BV a ! BV BV b ! BV integer z end subroutine subroutine BVDuplicateResize(a,b,c,z) BV a ! BV PetscInt b ! PetscInt BV c ! BV integer z end subroutine subroutine BVCopy(a,b,z) BV a ! BV BV b ! BV integer z end subroutine subroutine BVCopyVec(a,b,c,z) BV a ! BV PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine BVCopyColumn(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine BVDestroy(a,z) BV a ! BV integer z end subroutine subroutine BVCreate(a,b,z) integer a ! MPI_Comm BV b ! BV integer z end subroutine subroutine BVInsertVec(a,b,c,z) BV a ! BV PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine BVInsertVecs(a,b,c,d,e,z) BV a ! BV PetscInt b ! PetscInt PetscInt c ! PetscInt Vec d ! Vec PetscBool e ! PetscBool integer z end subroutine subroutine BVInsertConstraints(a,b,c,z) BV a ! BV PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine BVMult(a,b,c,d,e,z) BV a ! BV PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar BV d ! BV Mat e ! Mat integer z end subroutine subroutine BVMultVec(a,b,c,d,e,z) BV a ! BV PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar Vec d ! Vec PetscScalar e ! PetscScalar integer z end subroutine subroutine BVMultColumn(a,b,c,d,e,z) BV a ! BV PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar PetscInt d ! PetscInt PetscScalar e ! PetscScalar integer z end subroutine subroutine BVMultInPlace(a,b,c,d,z) BV a ! BV Mat b ! Mat PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine BVMultInPlaceTranspose(a,b,c,d,z) BV a ! BV Mat b ! Mat PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine BVScale(a,b,z) BV a ! BV PetscScalar b ! PetscScalar integer z end subroutine subroutine BVScaleColumn(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscScalar c ! PetscScalar integer z end subroutine subroutine BVSetRandom(a,z) BV a ! BV integer z end subroutine subroutine BVSetRandomColumn(a,b,z) BV a ! BV PetscInt b ! PetscInt integer z end subroutine subroutine BVMatMult(a,b,c,z) BV a ! BV Mat b ! Mat BV c ! BV integer z end subroutine subroutine BVMatMultHermitianTranspose(a,b,c,z) BV a ! BV Mat b ! Mat BV c ! BV integer z end subroutine subroutine BVMatMultColumn(a,b,c,z) BV a ! BV Mat b ! Mat PetscInt c ! PetscInt integer z end subroutine subroutine BVOrthogonalizeVec(a,b,c,d,e,z) BV a ! BV Vec b ! Vec PetscScalar c ! PetscScalar PetscReal d ! PetscReal PetscBool e ! PetscBool integer z end subroutine subroutine BVOrthogonalizeColumn(a,b,c,d,e,z) BV a ! BV PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscReal d ! PetscReal PetscBool e ! PetscBool integer z end subroutine subroutine BVOrthogonalizeSomeColumn(a,b,c,d,e,f,z) BV a ! BV PetscInt b ! PetscInt PetscBool c ! PetscBool PetscScalar d ! PetscScalar PetscReal e ! PetscReal PetscBool f ! PetscBool integer z end subroutine subroutine BVOrthogonalize(a,b,z) BV a ! BV Mat b ! Mat integer z end subroutine subroutine BVDot(a,b,c,z) BV a ! BV BV b ! BV Mat c ! Mat integer z end subroutine subroutine BVDotVec(a,b,c,z) BV a ! BV Vec b ! Vec PetscScalar c ! PetscScalar integer z end subroutine subroutine BVDotVecBegin(a,b,c,z) BV a ! BV Vec b ! Vec PetscScalar c ! PetscScalar integer z end subroutine subroutine BVDotVecEnd(a,b,c,z) BV a ! BV Vec b ! Vec PetscScalar c ! PetscScalar integer z end subroutine subroutine BVDotColumn(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscScalar c ! PetscScalar integer z end subroutine subroutine BVDotColumnBegin(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscScalar c ! PetscScalar integer z end subroutine subroutine BVDotColumnEnd(a,b,c,z) BV a ! BV PetscInt b ! PetscInt PetscScalar c ! PetscScalar integer z end subroutine subroutine BVNorm(a,b,c,z) BV a ! BV NormType b ! NormType PetscReal c ! PetscReal integer z end subroutine subroutine BVNormVec(a,b,c,d,z) BV a ! BV Vec b ! Vec NormType c ! NormType PetscReal d ! PetscReal integer z end subroutine subroutine BVNormVecBegin(a,b,c,d,z) BV a ! BV Vec b ! Vec NormType c ! NormType PetscReal d ! PetscReal integer z end subroutine subroutine BVNormVecEnd(a,b,c,d,z) BV a ! BV Vec b ! Vec NormType c ! NormType PetscReal d ! PetscReal integer z end subroutine subroutine BVNormColumn(a,b,c,d,z) BV a ! BV PetscInt b ! PetscInt NormType c ! NormType PetscReal d ! PetscReal integer z end subroutine subroutine BVNormColumnBegin(a,b,c,d,z) BV a ! BV PetscInt b ! PetscInt NormType c ! NormType PetscReal d ! PetscReal integer z end subroutine subroutine BVNormColumnEnd(a,b,c,d,z) BV a ! BV PetscInt b ! PetscInt NormType c ! NormType PetscReal d ! PetscReal integer z end subroutine subroutine BVMatProject(a,b,c,d,z) BV a ! BV Mat b ! Mat BV c ! BV Mat d ! Mat integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepceps.h900000644000175000017500000004610313107004621022406 0ustar jromanjroman subroutine EPSKrylovSchurSetRestart(a,b,z) EPS a ! EPS PetscReal b ! PetscReal integer z end subroutine subroutine EPSKrylovSchurGetRestart(a,b,z) EPS a ! EPS PetscReal b ! PetscReal integer z end subroutine subroutine EPSKrylovSchurSetLocking(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSKrylovSchurGetLocking(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSKrylovSchurSetPartitions(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSKrylovSchurGetPartitions(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSKrylovSchurSetDetectZeros(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSKrylovSchurGetDetectZeros(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSKrylovSchurSetDimensions(a,b,c,d,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine EPSKrylovSchurGetDimensions(a,b,c,d,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine EPSSolve(a,z) EPS a ! EPS integer z end subroutine subroutine EPSGetIterationNumber(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSGetConverged(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSGetConvergedReason(a,b,z) EPS a ! EPS EPSConvergedReason b ! EPSConvergedReason integer z end subroutine subroutine EPSGetInvariantSubspace(a,b,z) EPS a ! EPS Vec b ! Vec integer z end subroutine subroutine EPSGetEigenpair(a,b,c,d,e,f,z) EPS a ! EPS PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar Vec e ! Vec Vec f ! Vec integer z end subroutine subroutine EPSGetEigenvalue(a,b,c,d,z) EPS a ! EPS PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar integer z end subroutine subroutine EPSGetEigenvector(a,b,c,d,z) EPS a ! EPS PetscInt b ! PetscInt Vec c ! Vec Vec d ! Vec integer z end subroutine subroutine EPSGetErrorEstimate(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscReal c ! PetscReal integer z end subroutine subroutine EPSComputeError(a,b,c,d,z) EPS a ! EPS PetscInt b ! PetscInt EPSErrorType c ! EPSErrorType PetscReal d ! PetscReal integer z end subroutine subroutine EPSSetUp(a,z) EPS a ! EPS integer z end subroutine subroutine EPSSetOperators(a,b,c,z) EPS a ! EPS Mat b ! Mat Mat c ! Mat integer z end subroutine subroutine EPSGetOperators(a,b,c,z) EPS a ! EPS Mat b ! Mat Mat c ! Mat integer z end subroutine subroutine EPSSetDeflationSpace(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine EPSSetInitialSpace(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine EPSAllocateSolution(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSReasonViewFromOptions(a,z) EPS a ! EPS integer z end subroutine subroutine EPSErrorViewFromOptions(a,z) EPS a ! EPS integer z end subroutine subroutine EPSValuesViewFromOptions(a,z) EPS a ! EPS integer z end subroutine subroutine EPSVectorsViewFromOptions(a,z) EPS a ! EPS integer z end subroutine subroutine EPSSetWorkVecs(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSMonitorCancel(a,z) EPS a ! EPS integer z end subroutine subroutine EPSCreate(a,b,z) integer a ! MPI_Comm EPS b ! EPS integer z end subroutine subroutine EPSReset(a,z) EPS a ! EPS integer z end subroutine subroutine EPSDestroy(a,z) EPS a ! EPS integer z end subroutine subroutine EPSSetTarget(a,b,z) EPS a ! EPS PetscScalar b ! PetscScalar integer z end subroutine subroutine EPSGetTarget(a,b,z) EPS a ! EPS PetscScalar b ! PetscScalar integer z end subroutine subroutine EPSSetInterval(a,b,c,z) EPS a ! EPS PetscReal b ! PetscReal PetscReal c ! PetscReal integer z end subroutine subroutine EPSGetInterval(a,b,c,z) EPS a ! EPS PetscReal b ! PetscReal PetscReal c ! PetscReal integer z end subroutine subroutine EPSSetST(a,b,z) EPS a ! EPS ST b ! ST integer z end subroutine subroutine EPSGetST(a,b,z) EPS a ! EPS ST b ! ST integer z end subroutine subroutine EPSSetBV(a,b,z) EPS a ! EPS BV b ! BV integer z end subroutine subroutine EPSGetBV(a,b,z) EPS a ! EPS BV b ! BV integer z end subroutine subroutine EPSSetRG(a,b,z) EPS a ! EPS RG b ! RG integer z end subroutine subroutine EPSGetRG(a,b,z) EPS a ! EPS RG b ! RG integer z end subroutine subroutine EPSSetDS(a,b,z) EPS a ! EPS DS b ! DS integer z end subroutine subroutine EPSGetDS(a,b,z) EPS a ! EPS DS b ! DS integer z end subroutine subroutine EPSIsGeneralized(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSIsHermitian(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSIsPositive(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSSetFromOptions(a,z) EPS a ! EPS integer z end subroutine subroutine EPSGetTolerances(a,b,c,z) EPS a ! EPS PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine EPSSetTolerances(a,b,c,z) EPS a ! EPS PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine EPSGetDimensions(a,b,c,d,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine EPSSetDimensions(a,b,c,d,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine EPSSetWhichEigenpairs(a,b,z) EPS a ! EPS EPSWhich b ! EPSWhich integer z end subroutine subroutine EPSGetWhichEigenpairs(a,b,z) EPS a ! EPS EPSWhich b ! EPSWhich integer z end subroutine subroutine EPSSetConvergenceTest(a,b,z) EPS a ! EPS EPSConv b ! EPSConv integer z end subroutine subroutine EPSGetConvergenceTest(a,b,z) EPS a ! EPS EPSConv b ! EPSConv integer z end subroutine subroutine EPSSetStoppingTest(a,b,z) EPS a ! EPS EPSStop b ! EPSStop integer z end subroutine subroutine EPSGetStoppingTest(a,b,z) EPS a ! EPS EPSStop b ! EPSStop integer z end subroutine subroutine EPSSetProblemType(a,b,z) EPS a ! EPS EPSProblemType b ! EPSProblemType integer z end subroutine subroutine EPSGetProblemType(a,b,z) EPS a ! EPS EPSProblemType b ! EPSProblemType integer z end subroutine subroutine EPSSetExtraction(a,b,z) EPS a ! EPS EPSExtraction b ! EPSExtraction integer z end subroutine subroutine EPSGetExtraction(a,b,z) EPS a ! EPS EPSExtraction b ! EPSExtraction integer z end subroutine subroutine EPSSetBalance(a,b,c,d,z) EPS a ! EPS EPSBalance b ! EPSBalance PetscInt c ! PetscInt PetscReal d ! PetscReal integer z end subroutine subroutine EPSGetBalance(a,b,c,d,z) EPS a ! EPS EPSBalance b ! EPSBalance PetscInt c ! PetscInt PetscReal d ! PetscReal integer z end subroutine subroutine EPSSetTrueResidual(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGetTrueResidual(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSSetTrackAll(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGetTrackAll(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSSetPurify(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGetPurify(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSCISSSetSizes(a,b,c,d,e,f,g,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt PetscInt e ! PetscInt PetscInt f ! PetscInt PetscBool g ! PetscBool integer z end subroutine subroutine EPSCISSGetSizes(a,b,c,d,e,f,g,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt PetscInt e ! PetscInt PetscInt f ! PetscInt PetscBool g ! PetscBool integer z end subroutine subroutine EPSCISSSetThreshold(a,b,c,z) EPS a ! EPS PetscReal b ! PetscReal PetscReal c ! PetscReal integer z end subroutine subroutine EPSCISSGetThreshold(a,b,c,z) EPS a ! EPS PetscReal b ! PetscReal PetscReal c ! PetscReal integer z end subroutine subroutine EPSCISSSetRefinement(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSCISSGetRefinement(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSCISSSetUseST(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSCISSGetUseST(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSCISSSetQuadRule(a,b,z) EPS a ! EPS EPSCISSQuadRule b ! EPSCISSQuadRule integer z end subroutine subroutine EPSCISSGetQuadRule(a,b,z) EPS a ! EPS EPSCISSQuadRule b ! EPSCISSQuadRule integer z end subroutine subroutine EPSCISSSetExtraction(a,b,z) EPS a ! EPS EPSCISSExtraction b ! EPSCISSExtraction integer z end subroutine subroutine EPSCISSGetExtraction(a,b,z) EPS a ! EPS EPSCISSExtraction b ! EPSCISSExtraction integer z end subroutine subroutine EPSBLOPEXSetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSBLOPEXGetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSJDSetKrylovStart(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSJDGetKrylovStart(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSJDSetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSJDGetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSJDGetRestart(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSJDSetRestart(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSJDGetInitialSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSJDSetInitialSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSJDGetFix(a,b,z) EPS a ! EPS PetscReal b ! PetscReal integer z end subroutine subroutine EPSJDSetFix(a,b,z) EPS a ! EPS PetscReal b ! PetscReal integer z end subroutine subroutine EPSJDSetConstCorrectionTol(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSJDGetConstCorrectionTol(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSJDGetWindowSizes(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSJDSetWindowSizes(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSJDSetBOrth(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSJDGetBOrth(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSRQCGSetReset(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSRQCGGetReset(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSLOBPCGSetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSLOBPCGGetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSLOBPCGSetRestart(a,b,z) EPS a ! EPS PetscReal b ! PetscReal integer z end subroutine subroutine EPSLOBPCGGetRestart(a,b,z) EPS a ! EPS PetscReal b ! PetscReal integer z end subroutine subroutine EPSLOBPCGSetLocking(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSLOBPCGGetLocking(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSFEASTSetNumPoints(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSFEASTGetNumPoints(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSGDSetKrylovStart(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGDGetKrylovStart(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGDSetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSGDGetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSGDGetRestart(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSGDSetRestart(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSGDGetInitialSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSGDSetInitialSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSGDSetBOrth(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGDGetBOrth(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGDGetWindowSizes(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSGDSetWindowSizes(a,b,c,z) EPS a ! EPS PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine EPSGDGetDoubleExpansion(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSGDSetDoubleExpansion(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSArnoldiSetDelayed(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSArnoldiGetDelayed(a,b,z) EPS a ! EPS PetscBool b ! PetscBool integer z end subroutine subroutine EPSPowerSetShiftType(a,b,z) EPS a ! EPS EPSPowerShiftType b ! EPSPowerShiftType integer z end subroutine subroutine EPSPowerGetShiftType(a,b,z) EPS a ! EPS EPSPowerShiftType b ! EPSPowerShiftType integer z end subroutine subroutine EPSBlzpackSetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSBlzpackSetNSteps(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSLanczosSetReorthog(a,b,z) EPS a ! EPS EPSLanczosReorthogType b ! EPSLanczosReorthogType integer z end subroutine subroutine EPSLanczosGetReorthog(a,b,z) EPS a ! EPS EPSLanczosReorthogType b ! EPSLanczosReorthogType integer z end subroutine subroutine EPSPRIMMESetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSPRIMMEGetBlockSize(a,b,z) EPS a ! EPS PetscInt b ! PetscInt integer z end subroutine subroutine EPSPRIMMESetMethod(a,b,z) EPS a ! EPS EPSPRIMMEMethod b ! EPSPRIMMEMethod integer z end subroutine subroutine EPSPRIMMEGetMethod(a,b,z) EPS a ! EPS EPSPRIMMEMethod b ! EPSPRIMMEMethod integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcds.h900000644000175000017500000001127213107004621022224 0ustar jromanjroman subroutine DSNEPSetFN(a,b,c,z) DS a ! DS PetscInt b ! PetscInt FN c (*) ! FN integer z end subroutine subroutine DSNEPGetFN(a,b,c,z) DS a ! DS PetscInt b ! PetscInt FN c ! FN integer z end subroutine subroutine DSNEPGetNumFN(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSPEPSetDegree(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSPEPGetDegree(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSCreate(a,b,z) integer a ! MPI_Comm DS b ! DS integer z end subroutine subroutine DSSetMethod(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSGetMethod(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSSetCompact(a,b,z) DS a ! DS PetscBool b ! PetscBool integer z end subroutine subroutine DSGetCompact(a,b,z) DS a ! DS PetscBool b ! PetscBool integer z end subroutine subroutine DSSetExtraRow(a,b,z) DS a ! DS PetscBool b ! PetscBool integer z end subroutine subroutine DSGetExtraRow(a,b,z) DS a ! DS PetscBool b ! PetscBool integer z end subroutine subroutine DSSetRefined(a,b,z) DS a ! DS PetscBool b ! PetscBool integer z end subroutine subroutine DSGetRefined(a,b,z) DS a ! DS PetscBool b ! PetscBool integer z end subroutine subroutine DSSetBlockSize(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSGetBlockSize(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSSetFromOptions(a,z) DS a ! DS integer z end subroutine subroutine DSAllocate(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSReset(a,z) DS a ! DS integer z end subroutine subroutine DSDestroy(a,z) DS a ! DS integer z end subroutine subroutine DSSetIdentity(a,b,z) DS a ! DS DSMatType b ! DSMatType integer z end subroutine subroutine DSGetLeadingDimension(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSSetState(a,b,z) DS a ! DS DSStateType b ! DSStateType integer z end subroutine subroutine DSGetState(a,b,z) DS a ! DS DSStateType b ! DSStateType integer z end subroutine subroutine DSSetDimensions(a,b,c,d,e,z) DS a ! DS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt PetscInt e ! PetscInt integer z end subroutine subroutine DSGetDimensions(a,b,c,d,e,f,z) DS a ! DS PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt PetscInt e ! PetscInt PetscInt f ! PetscInt integer z end subroutine subroutine DSTruncate(a,b,z) DS a ! DS PetscInt b ! PetscInt integer z end subroutine subroutine DSGetMat(a,b,c,z) DS a ! DS DSMatType b ! DSMatType Mat c ! Mat integer z end subroutine subroutine DSRestoreMat(a,b,c,z) DS a ! DS DSMatType b ! DSMatType Mat c ! Mat integer z end subroutine subroutine DSSolve(a,b,c,z) DS a ! DS PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar integer z end subroutine subroutine DSNormalize(a,b,c,z) DS a ! DS DSMatType b ! DSMatType PetscInt c ! PetscInt integer z end subroutine subroutine DSUpdateExtraRow(a,z) DS a ! DS integer z end subroutine subroutine DSCond(a,b,z) DS a ! DS PetscReal b ! PetscReal integer z end subroutine subroutine DSTranslateRKS(a,b,z) DS a ! DS PetscScalar b ! PetscScalar integer z end subroutine subroutine DSCopyMat(a,b,c,d,e,f,g,h,i,j,z) DS a ! DS DSMatType b ! DSMatType PetscInt c ! PetscInt PetscInt d ! PetscInt Mat e ! Mat PetscInt f ! PetscInt PetscInt g ! PetscInt PetscInt h ! PetscInt PetscInt i ! PetscInt PetscBool j ! PetscBool integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcmfn.h900000644000175000017500000000530513107004621022376 0ustar jromanjroman subroutine MFNMonitorCancel(a,z) MFN a ! MFN integer z end subroutine subroutine MFNSetFromOptions(a,z) MFN a ! MFN integer z end subroutine subroutine MFNGetTolerances(a,b,c,z) MFN a ! MFN PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine MFNSetTolerances(a,b,c,z) MFN a ! MFN PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine MFNGetDimensions(a,b,z) MFN a ! MFN PetscInt b ! PetscInt integer z end subroutine subroutine MFNSetDimensions(a,b,z) MFN a ! MFN PetscInt b ! PetscInt integer z end subroutine subroutine MFNSetErrorIfNotConverged(a,b,z) MFN a ! MFN PetscBool b ! PetscBool integer z end subroutine subroutine MFNGetErrorIfNotConverged(a,b,z) MFN a ! MFN PetscBool b ! PetscBool integer z end subroutine subroutine MFNSetUp(a,z) MFN a ! MFN integer z end subroutine subroutine MFNSetOperator(a,b,z) MFN a ! MFN Mat b ! Mat integer z end subroutine subroutine MFNGetOperator(a,b,z) MFN a ! MFN Mat b ! Mat integer z end subroutine subroutine MFNAllocateSolution(a,b,z) MFN a ! MFN PetscInt b ! PetscInt integer z end subroutine subroutine MFNReasonViewFromOptions(a,z) MFN a ! MFN integer z end subroutine subroutine MFNCreate(a,b,z) integer a ! MPI_Comm MFN b ! MFN integer z end subroutine subroutine MFNReset(a,z) MFN a ! MFN integer z end subroutine subroutine MFNDestroy(a,z) MFN a ! MFN integer z end subroutine subroutine MFNSetBV(a,b,z) MFN a ! MFN BV b ! BV integer z end subroutine subroutine MFNGetBV(a,b,z) MFN a ! MFN BV b ! BV integer z end subroutine subroutine MFNSetFN(a,b,z) MFN a ! MFN FN b ! FN integer z end subroutine subroutine MFNGetFN(a,b,z) MFN a ! MFN FN b ! FN integer z end subroutine subroutine MFNSolve(a,b,c,z) MFN a ! MFN Vec b ! Vec Vec c ! Vec integer z end subroutine subroutine MFNGetIterationNumber(a,b,z) MFN a ! MFN PetscInt b ! PetscInt integer z end subroutine subroutine MFNGetConvergedReason(a,b,z) MFN a ! MFN MFNConvergedReason b ! MFNConvergedReason integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcsvd.h900000644000175000017500000001433613107004621022416 0ustar jromanjroman subroutine SVDTRLanczosSetOneSide(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDTRLanczosGetOneSide(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDCyclicSetExplicitMatrix(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDCyclicGetExplicitMatrix(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDCyclicSetEPS(a,b,z) SVD a ! SVD EPS b ! EPS integer z end subroutine subroutine SVDCyclicGetEPS(a,b,z) SVD a ! SVD EPS b ! EPS integer z end subroutine subroutine SVDMonitorCancel(a,z) SVD a ! SVD integer z end subroutine subroutine SVDSetOperator(a,b,z) SVD a ! SVD Mat b ! Mat integer z end subroutine subroutine SVDGetOperator(a,b,z) SVD a ! SVD Mat b ! Mat integer z end subroutine subroutine SVDSetUp(a,z) SVD a ! SVD integer z end subroutine subroutine SVDSetInitialSpace(a,b,c,z) SVD a ! SVD PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine SVDSetInitialSpaceLeft(a,b,c,z) SVD a ! SVD PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine SVDAllocateSolution(a,b,z) SVD a ! SVD PetscInt b ! PetscInt integer z end subroutine subroutine SVDCreate(a,b,z) integer a ! MPI_Comm SVD b ! SVD integer z end subroutine subroutine SVDReset(a,z) SVD a ! SVD integer z end subroutine subroutine SVDDestroy(a,z) SVD a ! SVD integer z end subroutine subroutine SVDSetBV(a,b,c,z) SVD a ! SVD BV b ! BV BV c ! BV integer z end subroutine subroutine SVDGetBV(a,b,c,z) SVD a ! SVD BV b ! BV BV c ! BV integer z end subroutine subroutine SVDSetDS(a,b,z) SVD a ! SVD DS b ! DS integer z end subroutine subroutine SVDGetDS(a,b,z) SVD a ! SVD DS b ! DS integer z end subroutine subroutine SVDSetImplicitTranspose(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDGetImplicitTranspose(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDSetTolerances(a,b,c,z) SVD a ! SVD PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine SVDGetTolerances(a,b,c,z) SVD a ! SVD PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine SVDSetDimensions(a,b,c,d,z) SVD a ! SVD PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine SVDGetDimensions(a,b,c,d,z) SVD a ! SVD PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine SVDSetWhichSingularTriplets(a,b,z) SVD a ! SVD SVDWhich b ! SVDWhich integer z end subroutine subroutine SVDGetWhichSingularTriplets(a,b,z) SVD a ! SVD SVDWhich b ! SVDWhich integer z end subroutine subroutine SVDSetConvergenceTest(a,b,z) SVD a ! SVD SVDConv b ! SVDConv integer z end subroutine subroutine SVDGetConvergenceTest(a,b,z) SVD a ! SVD SVDConv b ! SVDConv integer z end subroutine subroutine SVDSetStoppingTest(a,b,z) SVD a ! SVD SVDStop b ! SVDStop integer z end subroutine subroutine SVDGetStoppingTest(a,b,z) SVD a ! SVD SVDStop b ! SVDStop integer z end subroutine subroutine SVDSetFromOptions(a,z) SVD a ! SVD integer z end subroutine subroutine SVDSetTrackAll(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDGetTrackAll(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDReasonViewFromOptions(a,z) SVD a ! SVD integer z end subroutine subroutine SVDErrorViewFromOptions(a,z) SVD a ! SVD integer z end subroutine subroutine SVDValuesViewFromOptions(a,z) SVD a ! SVD integer z end subroutine subroutine SVDVectorsViewFromOptions(a,z) SVD a ! SVD integer z end subroutine subroutine SVDSolve(a,z) SVD a ! SVD integer z end subroutine subroutine SVDGetIterationNumber(a,b,z) SVD a ! SVD PetscInt b ! PetscInt integer z end subroutine subroutine SVDGetConvergedReason(a,b,z) SVD a ! SVD SVDConvergedReason b ! SVDConvergedReason integer z end subroutine subroutine SVDGetConverged(a,b,z) SVD a ! SVD PetscInt b ! PetscInt integer z end subroutine subroutine SVDGetSingularTriplet(a,b,c,d,e,z) SVD a ! SVD PetscInt b ! PetscInt PetscReal c ! PetscReal Vec d ! Vec Vec e ! Vec integer z end subroutine subroutine SVDComputeError(a,b,c,d,z) SVD a ! SVD PetscInt b ! PetscInt SVDErrorType c ! SVDErrorType PetscReal d ! PetscReal integer z end subroutine subroutine SVDLanczosSetOneSide(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDLanczosGetOneSide(a,b,z) SVD a ! SVD PetscBool b ! PetscBool integer z end subroutine subroutine SVDCrossSetEPS(a,b,z) SVD a ! SVD EPS b ! EPS integer z end subroutine subroutine SVDCrossGetEPS(a,b,z) SVD a ! SVD EPS b ! EPS integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcst.h900000644000175000017500000001264113107004621022245 0ustar jromanjroman subroutine STCayleySetAntishift(a,b,z) ST a ! ST PetscScalar b ! PetscScalar integer z end subroutine subroutine STCayleyGetAntishift(a,b,z) ST a ! ST PetscScalar b ! PetscScalar integer z end subroutine subroutine STApply(a,b,c,z) ST a ! ST Vec b ! Vec Vec c ! Vec integer z end subroutine subroutine STApplyTranspose(a,b,c,z) ST a ! ST Vec b ! Vec Vec c ! Vec integer z end subroutine subroutine STGetBilinearForm(a,b,z) ST a ! ST Mat b ! Mat integer z end subroutine subroutine STComputeExplicitOperator(a,b,z) ST a ! ST Mat b ! Mat integer z end subroutine subroutine STSetUp(a,z) ST a ! ST integer z end subroutine subroutine STPostSolve(a,z) ST a ! ST integer z end subroutine subroutine STBackTransform(a,b,c,d,z) ST a ! ST PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar integer z end subroutine subroutine STMatSetUp(a,b,c,z) ST a ! ST PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar integer z end subroutine subroutine STSetFromOptions(a,z) ST a ! ST integer z end subroutine subroutine STSetMatStructure(a,b,z) ST a ! ST MatStructure b ! MatStructure integer z end subroutine subroutine STGetMatStructure(a,b,z) ST a ! ST MatStructure b ! MatStructure integer z end subroutine subroutine STSetMatMode(a,b,z) ST a ! ST STMatMode b ! STMatMode integer z end subroutine subroutine STGetMatMode(a,b,z) ST a ! ST STMatMode b ! STMatMode integer z end subroutine subroutine STSetTransform(a,b,z) ST a ! ST PetscBool b ! PetscBool integer z end subroutine subroutine STGetTransform(a,b,z) ST a ! ST PetscBool b ! PetscBool integer z end subroutine subroutine STMatMult(a,b,c,d,z) ST a ! ST PetscInt b ! PetscInt Vec c ! Vec Vec d ! Vec integer z end subroutine subroutine STMatMultTranspose(a,b,c,d,z) ST a ! ST PetscInt b ! PetscInt Vec c ! Vec Vec d ! Vec integer z end subroutine subroutine STMatSolve(a,b,c,z) ST a ! ST Vec b ! Vec Vec c ! Vec integer z end subroutine subroutine STMatSolveTranspose(a,b,c,z) ST a ! ST Vec b ! Vec Vec c ! Vec integer z end subroutine subroutine STSetKSP(a,b,z) ST a ! ST KSP b ! KSP integer z end subroutine subroutine STGetKSP(a,b,z) ST a ! ST KSP b ! KSP integer z end subroutine subroutine STCheckNullSpace(a,b,z) ST a ! ST BV b ! BV integer z end subroutine subroutine STReset(a,z) ST a ! ST integer z end subroutine subroutine STDestroy(a,z) ST a ! ST integer z end subroutine subroutine STCreate(a,b,z) integer a ! MPI_Comm ST b ! ST integer z end subroutine subroutine STSetOperators(a,b,c,z) ST a ! ST PetscInt b ! PetscInt Mat c (*) ! Mat integer z end subroutine subroutine STGetOperators(a,b,c,z) ST a ! ST PetscInt b ! PetscInt Mat c ! Mat integer z end subroutine subroutine STGetTOperators(a,b,c,z) ST a ! ST PetscInt b ! PetscInt Mat c ! Mat integer z end subroutine subroutine STGetNumMatrices(a,b,z) ST a ! ST PetscInt b ! PetscInt integer z end subroutine subroutine STSetShift(a,b,z) ST a ! ST PetscScalar b ! PetscScalar integer z end subroutine subroutine STGetShift(a,b,z) ST a ! ST PetscScalar b ! PetscScalar integer z end subroutine subroutine STSetDefaultShift(a,b,z) ST a ! ST PetscScalar b ! PetscScalar integer z end subroutine subroutine STScaleShift(a,b,z) ST a ! ST PetscScalar b ! PetscScalar integer z end subroutine subroutine STSetBalanceMatrix(a,b,z) ST a ! ST Vec b ! Vec integer z end subroutine subroutine STGetBalanceMatrix(a,b,z) ST a ! ST Vec b ! Vec integer z end subroutine subroutine STMatGetSize(a,b,c,z) ST a ! ST PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine STMatGetLocalSize(a,b,c,z) ST a ! ST PetscInt b ! PetscInt PetscInt c ! PetscInt integer z end subroutine subroutine STPrecondGetMatForPC(a,b,z) ST a ! ST Mat b ! Mat integer z end subroutine subroutine STPrecondSetMatForPC(a,b,z) ST a ! ST Mat b ! Mat integer z end subroutine subroutine STPrecondSetKSPHasMat(a,b,z) ST a ! ST PetscBool b ! PetscBool integer z end subroutine subroutine STPrecondGetKSPHasMat(a,b,z) ST a ! ST PetscBool b ! PetscBool integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcpep.h900000644000175000017500000002364413107004621022410 0ustar jromanjroman subroutine PEPCreate(a,b,z) integer a ! MPI_Comm PEP b ! PEP integer z end subroutine subroutine PEPReset(a,z) PEP a ! PEP integer z end subroutine subroutine PEPDestroy(a,z) PEP a ! PEP integer z end subroutine subroutine PEPSetBV(a,b,z) PEP a ! PEP BV b ! BV integer z end subroutine subroutine PEPGetBV(a,b,z) PEP a ! PEP BV b ! BV integer z end subroutine subroutine PEPSetRG(a,b,z) PEP a ! PEP RG b ! RG integer z end subroutine subroutine PEPGetRG(a,b,z) PEP a ! PEP RG b ! RG integer z end subroutine subroutine PEPSetDS(a,b,z) PEP a ! PEP DS b ! DS integer z end subroutine subroutine PEPGetDS(a,b,z) PEP a ! PEP DS b ! DS integer z end subroutine subroutine PEPSetST(a,b,z) PEP a ! PEP ST b ! ST integer z end subroutine subroutine PEPGetST(a,b,z) PEP a ! PEP ST b ! ST integer z end subroutine subroutine PEPRefineGetKSP(a,b,z) PEP a ! PEP KSP b ! KSP integer z end subroutine subroutine PEPSetTarget(a,b,z) PEP a ! PEP PetscScalar b ! PetscScalar integer z end subroutine subroutine PEPGetTarget(a,b,z) PEP a ! PEP PetscScalar b ! PetscScalar integer z end subroutine subroutine PEPSetUp(a,z) PEP a ! PEP integer z end subroutine subroutine PEPSetOperators(a,b,c,z) PEP a ! PEP PetscInt b ! PetscInt Mat c (*) ! Mat integer z end subroutine subroutine PEPGetOperators(a,b,c,z) PEP a ! PEP PetscInt b ! PetscInt Mat c ! Mat integer z end subroutine subroutine PEPGetNumMatrices(a,b,z) PEP a ! PEP PetscInt b ! PetscInt integer z end subroutine subroutine PEPSetInitialSpace(a,b,c,z) PEP a ! PEP PetscInt b ! PetscInt Vec c ! Vec integer z end subroutine subroutine PEPAllocateSolution(a,b,z) PEP a ! PEP PetscInt b ! PetscInt integer z end subroutine subroutine PEPSolve(a,z) PEP a ! PEP integer z end subroutine subroutine PEPGetIterationNumber(a,b,z) PEP a ! PEP PetscInt b ! PetscInt integer z end subroutine subroutine PEPGetConverged(a,b,z) PEP a ! PEP PetscInt b ! PetscInt integer z end subroutine subroutine PEPGetConvergedReason(a,b,z) PEP a ! PEP PEPConvergedReason b ! PEPConvergedReason integer z end subroutine subroutine PEPGetEigenpair(a,b,c,d,e,f,z) PEP a ! PEP PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar Vec e ! Vec Vec f ! Vec integer z end subroutine subroutine PEPGetErrorEstimate(a,b,c,z) PEP a ! PEP PetscInt b ! PetscInt PetscReal c ! PetscReal integer z end subroutine subroutine PEPComputeError(a,b,c,d,z) PEP a ! PEP PetscInt b ! PetscInt PEPErrorType c ! PEPErrorType PetscReal d ! PetscReal integer z end subroutine subroutine PEPSetWorkVecs(a,b,z) PEP a ! PEP PetscInt b ! PetscInt integer z end subroutine subroutine PEPMonitorCancel(a,z) PEP a ! PEP integer z end subroutine subroutine PEPSetFromOptions(a,z) PEP a ! PEP integer z end subroutine subroutine PEPGetTolerances(a,b,c,z) PEP a ! PEP PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine PEPSetTolerances(a,b,c,z) PEP a ! PEP PetscReal b ! PetscReal PetscInt c ! PetscInt integer z end subroutine subroutine PEPGetDimensions(a,b,c,d,z) PEP a ! PEP PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine PEPSetDimensions(a,b,c,d,z) PEP a ! PEP PetscInt b ! PetscInt PetscInt c ! PetscInt PetscInt d ! PetscInt integer z end subroutine subroutine PEPSetWhichEigenpairs(a,b,z) PEP a ! PEP PEPWhich b ! PEPWhich integer z end subroutine subroutine PEPGetWhichEigenpairs(a,b,z) PEP a ! PEP PEPWhich b ! PEPWhich integer z end subroutine subroutine PEPSetProblemType(a,b,z) PEP a ! PEP PEPProblemType b ! PEPProblemType integer z end subroutine subroutine PEPGetProblemType(a,b,z) PEP a ! PEP PEPProblemType b ! PEPProblemType integer z end subroutine subroutine PEPSetBasis(a,b,z) PEP a ! PEP PEPBasis b ! PEPBasis integer z end subroutine subroutine PEPGetBasis(a,b,z) PEP a ! PEP PEPBasis b ! PEPBasis integer z end subroutine subroutine PEPSetTrackAll(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPGetTrackAll(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPSetConvergenceTest(a,b,z) PEP a ! PEP PEPConv b ! PEPConv integer z end subroutine subroutine PEPGetConvergenceTest(a,b,z) PEP a ! PEP PEPConv b ! PEPConv integer z end subroutine subroutine PEPSetStoppingTest(a,b,z) PEP a ! PEP PEPStop b ! PEPStop integer z end subroutine subroutine PEPGetStoppingTest(a,b,z) PEP a ! PEP PEPStop b ! PEPStop integer z end subroutine subroutine PEPSetScale(a,b,c,d,e,f,g,z) PEP a ! PEP PEPScale b ! PEPScale PetscReal c ! PetscReal Vec d ! Vec Vec e ! Vec PetscInt f ! PetscInt PetscReal g ! PetscReal integer z end subroutine subroutine PEPGetScale(a,b,c,d,e,f,g,z) PEP a ! PEP PEPScale b ! PEPScale PetscReal c ! PetscReal Vec d ! Vec Vec e ! Vec PetscInt f ! PetscInt PetscReal g ! PetscReal integer z end subroutine subroutine PEPSetExtract(a,b,z) PEP a ! PEP PEPExtract b ! PEPExtract integer z end subroutine subroutine PEPGetExtract(a,b,z) PEP a ! PEP PEPExtract b ! PEPExtract integer z end subroutine subroutine PEPSetRefine(a,b,c,d,e,f,z) PEP a ! PEP PEPRefine b ! PEPRefine PetscInt c ! PetscInt PetscReal d ! PetscReal PetscInt e ! PetscInt PEPRefineScheme f ! PEPRefineScheme integer z end subroutine subroutine PEPGetRefine(a,b,c,d,e,f,z) PEP a ! PEP PEPRefine b ! PEPRefine PetscInt c ! PetscInt PetscReal d ! PetscReal PetscInt e ! PetscInt PEPRefineScheme f ! PEPRefineScheme integer z end subroutine subroutine PEPReasonViewFromOptions(a,z) PEP a ! PEP integer z end subroutine subroutine PEPErrorViewFromOptions(a,z) PEP a ! PEP integer z end subroutine subroutine PEPValuesViewFromOptions(a,z) PEP a ! PEP integer z end subroutine subroutine PEPVectorsViewFromOptions(a,z) PEP a ! PEP integer z end subroutine subroutine PEPTOARSetRestart(a,b,z) PEP a ! PEP PetscReal b ! PetscReal integer z end subroutine subroutine PEPTOARGetRestart(a,b,z) PEP a ! PEP PetscReal b ! PetscReal integer z end subroutine subroutine PEPTOARSetLocking(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPTOARGetLocking(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPJDSetRestart(a,b,z) PEP a ! PEP PetscReal b ! PetscReal integer z end subroutine subroutine PEPJDGetRestart(a,b,z) PEP a ! PEP PetscReal b ! PetscReal integer z end subroutine subroutine PEPQArnoldiSetRestart(a,b,z) PEP a ! PEP PetscReal b ! PetscReal integer z end subroutine subroutine PEPQArnoldiGetRestart(a,b,z) PEP a ! PEP PetscReal b ! PetscReal integer z end subroutine subroutine PEPQArnoldiSetLocking(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPQArnoldiGetLocking(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPSTOARSetLocking(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPSTOARGetLocking(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPLinearSetCompanionForm(a,b,z) PEP a ! PEP PetscInt b ! PetscInt integer z end subroutine subroutine PEPLinearGetCompanionForm(a,b,z) PEP a ! PEP PetscInt b ! PetscInt integer z end subroutine subroutine PEPLinearSetExplicitMatrix(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPLinearGetExplicitMatrix(a,b,z) PEP a ! PEP PetscBool b ! PetscBool integer z end subroutine subroutine PEPLinearSetEPS(a,b,z) PEP a ! PEP EPS b ! EPS integer z end subroutine subroutine PEPLinearGetEPS(a,b,z) PEP a ! PEP EPS b ! EPS integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcsys.h900000644000175000017500000000201213107004621022424 0ustar jromanjroman subroutine SlepcMatTile(a,b,c,d,e,f,g,h,i,z) PetscScalar a ! PetscScalar Mat b ! Mat PetscScalar c ! PetscScalar Mat d ! Mat PetscScalar e ! PetscScalar Mat f ! Mat PetscScalar g ! PetscScalar Mat h ! Mat Mat i ! Mat integer z end subroutine subroutine SlepcFinalize(z) integer z end subroutine subroutine SlepcInitialized(a,z) PetscBool a ! PetscBool integer z end subroutine subroutine SlepcSCCompare(a,b,c,d,e,f,z) SlepcSC a ! SlepcSC PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar PetscScalar e ! PetscScalar PetscInt f ! PetscInt integer z end subroutine subroutine SlepcSortEigenvalues(a,b,c,d,e,z) SlepcSC a ! SlepcSC PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar PetscInt e ! PetscInt integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcrg.h900000644000175000017500000000656313107004621022235 0ustar jromanjroman subroutine RGEllipseSetParameters(a,b,c,d,z) RG a ! RG PetscScalar b ! PetscScalar PetscReal c ! PetscReal PetscReal d ! PetscReal integer z end subroutine subroutine RGEllipseGetParameters(a,b,c,d,z) RG a ! RG PetscScalar b ! PetscScalar PetscReal c ! PetscReal PetscReal d ! PetscReal integer z end subroutine subroutine RGIntervalSetEndpoints(a,b,c,d,e,z) RG a ! RG PetscReal b ! PetscReal PetscReal c ! PetscReal PetscReal d ! PetscReal PetscReal e ! PetscReal integer z end subroutine subroutine RGIntervalGetEndpoints(a,b,c,d,e,z) RG a ! RG PetscReal b ! PetscReal PetscReal c ! PetscReal PetscReal d ! PetscReal PetscReal e ! PetscReal integer z end subroutine subroutine RGRingSetParameters(a,b,c,d,e,f,g,z) RG a ! RG PetscScalar b ! PetscScalar PetscReal c ! PetscReal PetscReal d ! PetscReal PetscReal e ! PetscReal PetscReal f ! PetscReal PetscReal g ! PetscReal integer z end subroutine subroutine RGRingGetParameters(a,b,c,d,e,f,g,z) RG a ! RG PetscScalar b ! PetscScalar PetscReal c ! PetscReal PetscReal d ! PetscReal PetscReal e ! PetscReal PetscReal f ! PetscReal PetscReal g ! PetscReal integer z end subroutine subroutine RGCreate(a,b,z) integer a ! MPI_Comm RG b ! RG integer z end subroutine subroutine RGSetFromOptions(a,z) RG a ! RG integer z end subroutine subroutine RGIsTrivial(a,b,z) RG a ! RG PetscBool b ! PetscBool integer z end subroutine subroutine RGCheckInside(a,b,c,d,e,z) RG a ! RG PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar PetscInt e ! PetscInt integer z end subroutine subroutine RGComputeContour(a,b,c,d,z) RG a ! RG PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar integer z end subroutine subroutine RGSetComplement(a,b,z) RG a ! RG PetscBool b ! PetscBool integer z end subroutine subroutine RGGetComplement(a,b,z) RG a ! RG PetscBool b ! PetscBool integer z end subroutine subroutine RGSetScale(a,b,z) RG a ! RG PetscReal b ! PetscReal integer z end subroutine subroutine RGGetScale(a,b,z) RG a ! RG PetscReal b ! PetscReal integer z end subroutine subroutine RGPushScale(a,b,z) RG a ! RG PetscReal b ! PetscReal integer z end subroutine subroutine RGPopScale(a,z) RG a ! RG integer z end subroutine subroutine RGDestroy(a,z) RG a ! RG integer z end subroutine subroutine RGPolygonSetVertices(a,b,c,d,z) RG a ! RG PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar integer z end subroutine subroutine RGPolygonGetVertices(a,b,c,d,z) RG a ! RG PetscInt b ! PetscInt PetscScalar c ! PetscScalar PetscScalar d ! PetscScalar integer z end subroutine slepc-3.7.4/include/slepc/finclude/ftn-auto/slepcfn.h900000644000175000017500000000517613107004621022227 0ustar jromanjroman subroutine FNCombineSetChildren(a,b,c,d,z) FN a ! FN FNCombineType b ! FNCombineType FN c ! FN FN d ! FN integer z end subroutine subroutine FNCombineGetChildren(a,b,c,d,z) FN a ! FN FNCombineType b ! FNCombineType FN c ! FN FN d ! FN integer z end subroutine subroutine FNPhiSetIndex(a,b,z) FN a ! FN PetscInt b ! PetscInt integer z end subroutine subroutine FNPhiGetIndex(a,b,z) FN a ! FN PetscInt b ! PetscInt integer z end subroutine subroutine FNRationalSetNumerator(a,b,c,z) FN a ! FN PetscInt b ! PetscInt PetscScalar c ! PetscScalar integer z end subroutine subroutine FNRationalGetNumerator(a,b,c,z) FN a ! FN PetscInt b ! PetscInt PetscScalar c (*) ! PetscScalar integer z end subroutine subroutine FNRationalSetDenominator(a,b,c,z) FN a ! FN PetscInt b ! PetscInt PetscScalar c ! PetscScalar integer z end subroutine subroutine FNRationalGetDenominator(a,b,c,z) FN a ! FN PetscInt b ! PetscInt PetscScalar c (*) ! PetscScalar integer z end subroutine subroutine FNCreate(a,b,z) integer a ! MPI_Comm FN b ! FN integer z end subroutine subroutine FNSetScale(a,b,c,z) FN a ! FN PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar integer z end subroutine subroutine FNGetScale(a,b,c,z) FN a ! FN PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar integer z end subroutine subroutine FNEvaluateFunction(a,b,c,z) FN a ! FN PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar integer z end subroutine subroutine FNEvaluateDerivative(a,b,c,z) FN a ! FN PetscScalar b ! PetscScalar PetscScalar c ! PetscScalar integer z end subroutine subroutine FNEvaluateFunctionMat(a,b,c,z) FN a ! FN Mat b ! Mat Mat c ! Mat integer z end subroutine subroutine FNEvaluateFunctionMatVec(a,b,c,z) FN a ! FN Mat b ! Mat Vec c ! Vec integer z end subroutine subroutine FNSetFromOptions(a,z) FN a ! FN integer z end subroutine subroutine FNDuplicate(a,b,c,z) FN a ! FN integer b ! MPI_Comm FN c ! FN integer z end subroutine subroutine FNDestroy(a,z) FN a ! FN integer z end subroutine slepc-3.7.4/include/slepc/finclude/slepcsys.h.html0000644000175000017500000001002213107004621021461 0ustar jromanjroman

Actual source code: slepcsys.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Basic include file for Fortran use of the SLEPc package
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 24: #include "petscconf.h"
 25: #include "petsc/finclude/petscdef.h"
 26:  #include slepcversion.h
 27:  #include slepc/finclude/slepcsysdef.h

 29: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 30:       external SlepcConvMonitorDestroy
 31: #endif

 33: ! Default tolerance for the different solvers, depending on the precision

 35:       PetscReal SLEPC_DEFAULT_TOL
 36: #if defined(PETSC_USE_REAL_SINGLE)
 37:       parameter(SLEPC_DEFAULT_TOL     =  1e-6)
 38: #elif defined(PETSC_USE_REAL_DOUBLE)
 39:       parameter(SLEPC_DEFAULT_TOL     =  1e-8)
 40: #elif defined(PETSC_USE_REAL___FLOAT128)
 41:       parameter(SLEPC_DEFAULT_TOL     = 1e-16)
 42: #else
 43:       parameter(SLEPC_DEFAULT_TOL     =  1e-7)
 44: #endif

slepc-3.7.4/include/slepc/finclude/slepc.h.html0000644000175000017500000000715413107004621020736 0ustar jromanjroman
Actual source code: slepc.h

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Single Fortran include file for all of SLEPc
 21: !

 23:  #include slepc/finclude/slepcsys.h
 24:  #include slepc/finclude/slepcbv.h
 25:  #include slepc/finclude/slepcfn.h
 26:  #include slepc/finclude/slepcds.h
 27:  #include slepc/finclude/slepcrg.h
 28:  #include slepc/finclude/slepcst.h
 29:  #include slepc/finclude/slepceps.h
 30:  #include slepc/finclude/slepcsvd.h
 31:  #include slepc/finclude/slepcpep.h
 32:  #include slepc/finclude/slepcnep.h
 33:  #include slepc/finclude/slepcmfn.h
slepc-3.7.4/include/slepc/finclude/slepcpep.h90.html0000644000175000017500000000602213107004621021605 0ustar jromanjroman
Actual source code: slepcpep.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional PEP include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcpep.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcpep.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcdef.h.html0000644000175000017500000000732513107004621021415 0ustar jromanjroman
Actual source code: slepcdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Single Fortran include file for all of SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !
 23:  #include slepc/finclude/slepcsysdef.h
 24:  #include slepc/finclude/slepcbvdef.h
 25:  #include slepc/finclude/slepcfndef.h
 26:  #include slepc/finclude/slepcdsdef.h
 27:  #include slepc/finclude/slepcrgdef.h
 28:  #include slepc/finclude/slepcstdef.h
 29:  #include slepc/finclude/slepcepsdef.h
 30:  #include slepc/finclude/slepcsvddef.h
 31:  #include slepc/finclude/slepcpepdef.h
 32:  #include slepc/finclude/slepcnepdef.h
 33:  #include slepc/finclude/slepcmfndef.h
slepc-3.7.4/include/slepc/finclude/slepcst.h0000644000175000017500000000246613107004621020343 0ustar jromanjroman! ! Include file for Fortran use of the ST object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcstdef.h" PetscEnum ST_MATMODE_COPY PetscEnum ST_MATMODE_INPLACE PetscEnum ST_MATMODE_SHELL parameter (ST_MATMODE_COPY = 0) parameter (ST_MATMODE_INPLACE = 1) parameter (ST_MATMODE_SHELL = 2) ! ! End of Fortran include file for the ST package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcsvd.h.html0000644000175000017500000001213113107004621021442 0ustar jromanjroman
Actual source code: slepcsvd.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the SVD object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcsvddef.h

 26:       PetscEnum SVD_CONVERGED_TOL
 27:       PetscEnum SVD_CONVERGED_USER
 28:       PetscEnum SVD_DIVERGED_ITS
 29:       PetscEnum SVD_DIVERGED_BREAKDOWN
 30:       PetscEnum SVD_CONVERGED_ITERATING

 32:       parameter (SVD_CONVERGED_TOL          =  1)
 33:       parameter (SVD_CONVERGED_USER         =  2)
 34:       parameter (SVD_DIVERGED_ITS           = -1)
 35:       parameter (SVD_DIVERGED_BREAKDOWN     = -2)
 36:       parameter (SVD_CONVERGED_ITERATING    =  0)

 38:       integer SVD_LARGEST
 39:       integer SVD_SMALLEST

 41:       parameter (SVD_LARGEST                =  0)
 42:       parameter (SVD_SMALLEST               =  1)

 44:       PetscEnum SVD_ERROR_ABSOLUTE
 45:       PetscEnum SVD_ERROR_RELATIVE

 47:       parameter (SVD_ERROR_ABSOLUTE         =  0)
 48:       parameter (SVD_ERROR_RELATIVE         =  1)

 50:       PetscEnum SVD_CONV_ABS
 51:       PetscEnum SVD_CONV_REL
 52:       PetscEnum SVD_CONV_USER

 54:       parameter (SVD_CONV_ABS               =  0)
 55:       parameter (SVD_CONV_REL               =  1)
 56:       parameter (SVD_CONV_USER              =  2)

 58:       PetscEnum SVD_STOP_BASIC
 59:       PetscEnum SVD_STOP_USER

 61:       parameter (SVD_STOP_BASIC             =  0)
 62:       parameter (SVD_STOP_USER              =  1)

 64: !
 65: !   Possible arguments to SVDMonitorSet()
 66: !
 67:       external SVDMONITORALL
 68:       external SVDMONITORLG
 69:       external SVDMONITORLGALL
 70:       external SVDMONITORCONVERGED
 71:       external SVDMONITORFIRST

 73: !
 74: !  End of Fortran include file for the SVD package in SLEPc
 75: !
slepc-3.7.4/include/slepc/finclude/slepcds.h.html0000644000175000017500000001406013107004621021257 0ustar jromanjroman
Actual source code: slepcds.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the DS object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcdsdef.h

 26:       PetscEnum DS_STATE_RAW
 27:       PetscEnum DS_STATE_INTERMEDIATE
 28:       PetscEnum DS_STATE_CONDENSED
 29:       PetscEnum DS_STATE_TRUNCATED

 31:       parameter (DS_STATE_RAW                =  0)
 32:       parameter (DS_STATE_INTERMEDIATE       =  1)
 33:       parameter (DS_STATE_CONDENSED          =  2)
 34:       parameter (DS_STATE_TRUNCATED          =  3)

 36:       PetscEnum DS_MAT_A
 37:       PetscEnum DS_MAT_B
 38:       PetscEnum DS_MAT_C
 39:       PetscEnum DS_MAT_T
 40:       PetscEnum DS_MAT_D
 41:       PetscEnum DS_MAT_F
 42:       PetscEnum DS_MAT_Q
 43:       PetscEnum DS_MAT_Z
 44:       PetscEnum DS_MAT_X
 45:       PetscEnum DS_MAT_Y
 46:       PetscEnum DS_MAT_U
 47:       PetscEnum DS_MAT_VT
 48:       PetscEnum DS_MAT_W
 49:       PetscEnum DS_MAT_E0
 50:       PetscEnum DS_MAT_E1
 51:       PetscEnum DS_MAT_E2
 52:       PetscEnum DS_MAT_E3
 53:       PetscEnum DS_MAT_E4
 54:       PetscEnum DS_MAT_E5
 55:       PetscEnum DS_MAT_E6
 56:       PetscEnum DS_MAT_E7
 57:       PetscEnum DS_MAT_E8
 58:       PetscEnum DS_MAT_E9
 59:       PetscEnum DS_NUM_MAT

 61:       parameter (DS_MAT_A         =  0)
 62:       parameter (DS_MAT_B         =  1)
 63:       parameter (DS_MAT_C         =  2)
 64:       parameter (DS_MAT_T         =  3)
 65:       parameter (DS_MAT_D         =  4)
 66:       parameter (DS_MAT_F         =  5)
 67:       parameter (DS_MAT_Q         =  6)
 68:       parameter (DS_MAT_Z         =  7)
 69:       parameter (DS_MAT_X         =  8)
 70:       parameter (DS_MAT_Y         =  9)
 71:       parameter (DS_MAT_U         = 10)
 72:       parameter (DS_MAT_VT        = 11)
 73:       parameter (DS_MAT_W         = 12)
 74:       parameter (DS_MAT_E0        = 13)
 75:       parameter (DS_MAT_E1        = 14)
 76:       parameter (DS_MAT_E2        = 15)
 77:       parameter (DS_MAT_E3        = 16)
 78:       parameter (DS_MAT_E4        = 17)
 79:       parameter (DS_MAT_E5        = 18)
 80:       parameter (DS_MAT_E6        = 19)
 81:       parameter (DS_MAT_E7        = 20)
 82:       parameter (DS_MAT_E8        = 21)
 83:       parameter (DS_MAT_E9        = 22)
 84:       parameter (DS_NUM_MAT       = 23)

 86: !
 87: !  End of Fortran include file for the DS package in SLEPc
 88: !
slepc-3.7.4/include/slepc/finclude/slepcsysdef.h.html0000644000175000017500000000502413107004621022146 0ustar jromanjroman
Actual source code: slepcsysdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Basic include file for Fortran use of the SLEPc package
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !


 27: #define SlepcConvMonitor PetscFortranAddr

 29: #endif

slepc-3.7.4/include/slepc/finclude/slepcbvdef.h.html0000644000175000017500000001010513107004621021733 0ustar jromanjroman
Actual source code: slepcbvdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the BV object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 27: #define BV PetscFortranAddr
 28: #endif

 30: #define BVType             character*(80)
 31: #define BVOrthogType       PetscEnum
 32: #define BVOrthogRefineType PetscEnum
 33: #define BVOrthogBlockType  PetscEnum
 34: #define BVMatMultType      PetscEnum

 36: #define BVMAT        'mat'
 37: #define BVSVEC       'svec'
 38: #define BVVECS       'vecs'
 39: #define BVCONTIGUOUS 'contiguous'

 41: #endif
slepc-3.7.4/include/slepc/finclude/slepcmfn.h90.html0000644000175000017500000000602213107004621021601 0ustar jromanjroman
Actual source code: slepcmfn.h90

slepc-3.7.4 2017-05-17
  1: !
  2: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  4: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  5: !
  6: !  This file is part of SLEPc.
  7: !
  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.
 11: !
 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.
 16: !
 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: !
 21: !
 22: !
 23: !  Additional MFN include file for use of SLEPc with Fortran 90/HPF
 24: !
 25: #include "slepc/finclude/ftn-custom/slepcmfn.h90"
 26: #if defined(PETSC_USE_FORTRAN_INTERFACES)
 27:       interface
 28: #include "slepc/finclude/ftn-auto/slepcmfn.h90"
 29:       end interface
 30: #endif

slepc-3.7.4/include/slepc/finclude/slepcfn.h0000644000175000017500000000261413107004621020313 0ustar jromanjroman! ! Include file for Fortran use of the FN object in SLEPc ! ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #include "slepc/finclude/slepcfndef.h" PetscEnum FN_COMBINE_ADD PetscEnum FN_COMBINE_MULTIPLY PetscEnum FN_COMBINE_DIVIDE PetscEnum FN_COMBINE_COMPOSE parameter (FN_COMBINE_ADD = 0) parameter (FN_COMBINE_MULTIPLY = 1) parameter (FN_COMBINE_DIVIDE = 2) parameter (FN_COMBINE_COMPOSE = 3) ! ! End of Fortran include file for the FN package in SLEPc ! slepc-3.7.4/include/slepc/finclude/slepcrg.h.html0000644000175000017500000000540213107004621021261 0ustar jromanjroman
Actual source code: slepcrg.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the RG object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcrgdef.h

 26: !
 27: !  End of Fortran include file for the RG package in SLEPc
 28: !
slepc-3.7.4/include/slepc/finclude/slepcrg.h900000644000175000017500000000223413107004621020467 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional RG include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcrg.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcrg.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/0000755000175000017500000000000013107004621020604 5ustar jromanjromanslepc-3.7.4/include/slepc/finclude/ftn-custom/makefile0000644000175000017500000000200613107004621022302 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # LOCDIR = include/slepc/finclude/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcbvdef.h900000644000175000017500000000211413107004621023241 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCBVDEF_H90) #define __SLEPCBVDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type BV PetscFortranAddr:: v end type BV #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcdsdef.h900000644000175000017500000000211413107004621023240 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCDSDEF_H90) #define __SLEPCDSDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type DS PetscFortranAddr:: v end type DS #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcsvddef.h900000644000175000017500000000212013107004621023423 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCSVDDEF_H90) #define __SLEPCSVDDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type SVD PetscFortranAddr:: v end type SVD #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcnep.h900000644000175000017500000000222213107004621022735 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcnepdef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(NEP_HIDE) #define NEP_HIDE type(NEP) #elif !defined(NEP_HIDE) #define NEP_HIDE NEP #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcbv.h900000644000175000017500000000221313107004621022562 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcbvdef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(BV_HIDE) #define BV_HIDE type(BV) #elif !defined(BV_HIDE) #define BV_HIDE BV #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepceps.h900000644000175000017500000000222213107004621022742 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcepsdef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(EPS_HIDE) #define EPS_HIDE type(EPS) #elif !defined(EPS_HIDE) #define EPS_HIDE EPS #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcds.h900000644000175000017500000000221313107004621022561 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcdsdef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(DS_HIDE) #define DS_HIDE type(DS) #elif !defined(DS_HIDE) #define DS_HIDE DS #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcmfn.h900000644000175000017500000000222213107004621022733 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcmfndef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(MFN_HIDE) #define MFN_HIDE type(MFN) #elif !defined(MFN_HIDE) #define MFN_HIDE MFN #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcmfndef.h900000644000175000017500000000212013107004621023407 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCMFNDEF_H90) #define __SLEPCMFNDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type MFN PetscFortranAddr:: v end type MFN #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcsvd.h900000644000175000017500000000222213107004621022747 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcsvddef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(SVD_HIDE) #define SVD_HIDE type(SVD) #elif !defined(SVD_HIDE) #define SVD_HIDE SVD #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcnepdef.h900000644000175000017500000000212013107004621023411 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCNEPDEF_H90) #define __SLEPCNEPDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type NEP PetscFortranAddr:: v end type NEP #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcst.h900000644000175000017500000000221313107004621022601 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcstdef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(ST_HIDE) #define ST_HIDE type(ST) #elif !defined(ST_HIDE) #define ST_HIDE ST #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcpepdef.h900000644000175000017500000000212013107004621023413 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCPEPDEF_H90) #define __SLEPCPEPDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type PEP PetscFortranAddr:: v end type PEP #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcpep.h900000644000175000017500000000222213107004621022737 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcpepdef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(PEP_HIDE) #define PEP_HIDE type(PEP) #elif !defined(PEP_HIDE) #define PEP_HIDE PEP #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcfndef.h900000644000175000017500000000211413107004621023235 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCFNDEF_H90) #define __SLEPCFNDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type FN PetscFortranAddr:: v end type FN #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcrgdef.h900000644000175000017500000000211413107004621023242 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCRGDEF_H90) #define __SLEPCRGDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type RG PetscFortranAddr:: v end type RG #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcstdef.h900000644000175000017500000000211413107004621023260 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCSTDEF_H90) #define __SLEPCSTDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type ST PetscFortranAddr:: v end type ST #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcepsdef.h900000644000175000017500000000212013107004621023416 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCEPSDEF_H90) #define __SLEPCEPSDEF_H90 #if defined(PETSC_USE_FORTRAN_DATATYPES) type EPS PetscFortranAddr:: v end type EPS #endif #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcrg.h900000644000175000017500000000221313107004621022563 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcrgdef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(RG_HIDE) #define RG_HIDE type(RG) #elif !defined(RG_HIDE) #define RG_HIDE RG #endif slepc-3.7.4/include/slepc/finclude/ftn-custom/slepcfn.h900000644000175000017500000000221313107004621022556 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(PETSC_USE_FORTRAN_MODULES) #include "slepc/finclude/ftn-custom/slepcfndef.h90" #endif #if defined(PETSC_USE_FORTRAN_DATATYPES) && !defined(FN_HIDE) #define FN_HIDE type(FN) #elif !defined(FN_HIDE) #define FN_HIDE FN #endif slepc-3.7.4/include/slepc/finclude/slepcstdef.h.html0000644000175000017500000000745313107004621021766 0ustar jromanjroman
Actual source code: slepcstdef.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the ST object in SLEPc
  3: !
  4: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  6: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  7: !
  8: !  This file is part of SLEPc.
  9: !
 10: !  SLEPc is free software: you can redistribute it and/or modify it under  the
 11: !  terms of version 3 of the GNU Lesser General Public License as published by
 12: !  the Free Software Foundation.
 13: !
 14: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
 15: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
 16: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
 17: !  more details.
 18: !
 19: !  You  should have received a copy of the GNU Lesser General  Public  License
 20: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 21: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22: !

 26: #include "petsc/finclude/petsckspdef.h"

 28: #if !defined(PETSC_USE_FORTRAN_DATATYPES)
 29: #define ST PetscFortranAddr
 30: #endif

 32: #define STType     character*(80)
 33: #define STMatMode  PetscEnum

 35: #define STSHELL    'shell'
 36: #define STSHIFT    'shift'
 37: #define STSINVERT  'sinvert'
 38: #define STCAYLEY   'cayley'
 39: #define STPRECOND  'precond'

 41: #endif
slepc-3.7.4/include/slepc/finclude/slepcmfn.h.html0000644000175000017500000000760113107004621021434 0ustar jromanjroman
Actual source code: slepcmfn.h

slepc-3.7.4 2017-05-17
  1: !
  2: !  Include file for Fortran use of the MFN object in SLEPc
  3: !
  4: !
  5: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  7: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  8: !
  9: !  This file is part of SLEPc.
 10: !
 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.
 14: !
 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.
 19: !
 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: !
 24:  #include slepc/finclude/slepcsysdef.h
 25:  #include slepc/finclude/slepcmfndef.h

 27:       PetscEnum MFN_CONVERGED_TOL
 28:       PetscEnum MFN_CONVERGED_ITS
 29:       PetscEnum MFN_DIVERGED_ITS
 30:       PetscEnum MFN_DIVERGED_BREAKDOWN
 31:       PetscEnum MFN_CONVERGED_ITERATING

 33:       parameter (MFN_CONVERGED_TOL          =  2)
 34:       parameter (MFN_CONVERGED_ITS          =  3)
 35:       parameter (MFN_DIVERGED_ITS           = -3)
 36:       parameter (MFN_DIVERGED_BREAKDOWN     = -4)
 37:       parameter (MFN_CONVERGED_ITERATING    =  0)

 39: !
 40: !   Possible arguments to MFNMonitorSet()
 41: !
 42:       external MFNMONITORDEFAULT
 43:       external MFNMONITORLG

 45: !
 46: !  End of Fortran include file for the MFN package in SLEPc
 47: !
slepc-3.7.4/include/slepc/finclude/slepcepsdef.h0000644000175000017500000000454413107004621021162 0ustar jromanjroman! ! Include file for Fortran use of the EPS object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCEPSDEF_H) #define __SLEPCEPSDEF_H #include "slepc/finclude/slepcstdef.h" #include "slepc/finclude/slepcbvdef.h" #include "slepc/finclude/slepcdsdef.h" #include "slepc/finclude/slepcrgdef.h" #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define EPS PetscFortranAddr #endif #define EPSType character*(80) #define EPSConvergedReason PetscEnum #define EPSErrorType PetscEnum #define EPSProblemType PetscEnum #define EPSWhich PetscEnum #define EPSExtraction PetscEnum #define EPSBalance PetscEnum #define EPSConv PetscEnum #define EPSStop PetscEnum #define EPSPowerShiftType PetscEnum #define EPSLanczosReorthogType PetscEnum #define EPSPRIMMEMethod PetscEnum #define EPSCISSQuadRule PetscEnum #define EPSCISSExtraction PetscEnum #define EPSPOWER 'power' #define EPSSUBSPACE 'subspace' #define EPSARNOLDI 'arnoldi' #define EPSLANCZOS 'lanczos' #define EPSKRYLOVSCHUR 'krylovschur' #define EPSGD 'gd' #define EPSJD 'jd' #define EPSRQCG 'rqcg' #define EPSLOBPCG 'lobpcg' #define EPSCISS 'ciss' #define EPSLAPACK 'lapack' #define EPSARPACK 'arpack' #define EPSBLZPACK 'blzpack' #define EPSTRLAN 'trlan' #define EPSBLOPEX 'blopex' #define EPSPRIMME 'primme' #define EPSFEAST 'feast' #endif slepc-3.7.4/include/slepc/finclude/slepcfn.h900000644000175000017500000000223413107004621020462 0ustar jromanjroman! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! ! ! Additional FN include file for use of SLEPc with Fortran 90/HPF ! #include "slepc/finclude/ftn-custom/slepcfn.h90" #if defined(PETSC_USE_FORTRAN_INTERFACES) interface #include "slepc/finclude/ftn-auto/slepcfn.h90" end interface #endif slepc-3.7.4/include/slepc/finclude/slepcfndef.h0000644000175000017500000000254713107004621020777 0ustar jromanjroman! ! Include file for Fortran use of the FN object in SLEPc ! ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! #if !defined(__SLEPCFNDEF_H) #define __SLEPCFNDEF_H #if !defined(PETSC_USE_FORTRAN_DATATYPES) #define FN PetscFortranAddr #endif #define FNType character*(80) #define FNCombineType PetscEnum #define FNCOMBINE 'combine' #define FNRATIONAL 'rational' #define FNEXP 'exp' #define FNLOG 'log' #define FNPHI 'phi' #define FNSQRT 'sqrt' #define FNINVSQRT 'invsqrt' #endif slepc-3.7.4/include/slepcrg.h0000644000175000017500000000654713107004621015432 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCRG_H) #define __SLEPCRG_H #include #include PETSC_EXTERN PetscErrorCode RGInitializePackage(void); /*J RGType - String with the name of the region. Level: beginner .seealso: RGSetType(), RG J*/ typedef const char* RGType; #define RGINTERVAL "interval" #define RGPOLYGON "polygon" #define RGELLIPSE "ellipse" #define RGRING "ring" /* Logging support */ PETSC_EXTERN PetscClassId RG_CLASSID; PETSC_EXTERN PetscErrorCode RGCreate(MPI_Comm,RG*); PETSC_EXTERN PetscErrorCode RGSetType(RG,RGType); PETSC_EXTERN PetscErrorCode RGGetType(RG,RGType*); PETSC_EXTERN PetscErrorCode RGSetOptionsPrefix(RG,const char *); PETSC_EXTERN PetscErrorCode RGAppendOptionsPrefix(RG,const char *); PETSC_EXTERN PetscErrorCode RGGetOptionsPrefix(RG,const char *[]); PETSC_EXTERN PetscErrorCode RGSetFromOptions(RG); PETSC_EXTERN PetscErrorCode RGView(RG,PetscViewer); PETSC_EXTERN PetscErrorCode RGDestroy(RG*); PETSC_EXTERN PetscErrorCode RGIsTrivial(RG,PetscBool*); PETSC_EXTERN PetscErrorCode RGSetComplement(RG,PetscBool); PETSC_EXTERN PetscErrorCode RGGetComplement(RG,PetscBool*); PETSC_EXTERN PetscErrorCode RGSetScale(RG,PetscReal); PETSC_EXTERN PetscErrorCode RGGetScale(RG,PetscReal*); PETSC_EXTERN PetscErrorCode RGPushScale(RG,PetscReal); PETSC_EXTERN PetscErrorCode RGPopScale(RG); PETSC_EXTERN PetscErrorCode RGCheckInside(RG,PetscInt,PetscScalar*,PetscScalar*,PetscInt*); PETSC_EXTERN PetscErrorCode RGComputeContour(RG,PetscInt,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscFunctionList RGList; PETSC_EXTERN PetscErrorCode RGRegister(const char[],PetscErrorCode(*)(RG)); /* --------- options specific to particular regions -------- */ PETSC_EXTERN PetscErrorCode RGEllipseSetParameters(RG,PetscScalar,PetscReal,PetscReal); PETSC_EXTERN PetscErrorCode RGEllipseGetParameters(RG,PetscScalar*,PetscReal*,PetscReal*); PETSC_EXTERN PetscErrorCode RGIntervalSetEndpoints(RG,PetscReal,PetscReal,PetscReal,PetscReal); PETSC_EXTERN PetscErrorCode RGIntervalGetEndpoints(RG,PetscReal*,PetscReal*,PetscReal*,PetscReal*); PETSC_EXTERN PetscErrorCode RGPolygonSetVertices(RG,PetscInt,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscErrorCode RGPolygonGetVertices(RG,PetscInt*,PetscScalar**,PetscScalar**); PETSC_EXTERN PetscErrorCode RGRingSetParameters(RG,PetscScalar,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal); PETSC_EXTERN PetscErrorCode RGRingGetParameters(RG,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); #endif slepc-3.7.4/include/slepc.h0000644000175000017500000000204413107004621015065 0ustar jromanjroman/* Include all top-level SLEPc functionality. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #include slepc-3.7.4/include/slepcbv.h.html0000644000175000017500000007603213107004621016370 0ustar jromanjroman
Actual source code: slepcbv.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */

 24: #include <slepcsys.h>

 26: PETSC_EXTERN PetscErrorCode BVInitializePackage(void);

 28: /*S
 29:     BV - Basis vectors, SLEPc object representing a collection of vectors
 30:     that typically constitute a basis of a subspace.

 32:     Level: beginner

 34: .seealso:  BVCreate()
 35: S*/
 36: typedef struct _p_BV* BV;

 38: /*J
 39:     BVType - String with the name of the type of BV. Each type differs in
 40:     the way data is stored internally.

 42:     Level: beginner

 44: .seealso: BVSetType(), BV
 45: J*/
 46: typedef const char* BVType;
 47: #define BVMAT        "mat"
 48: #define BVSVEC       "svec"
 49: #define BVVECS       "vecs"
 50: #define BVCONTIGUOUS "contiguous"

 52: /* Logging support */
 53: PETSC_EXTERN PetscClassId BV_CLASSID;

 55: /*E
 56:     BVOrthogType - Determines the method used in the orthogonalization
 57:     of vectors

 59:     Level: advanced

 61: .seealso: BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalizeColumn(), BVOrthogRefineType
 62: E*/
 63: typedef enum { BV_ORTHOG_CGS,
 64:                BV_ORTHOG_MGS } BVOrthogType;
 65: PETSC_EXTERN const char *BVOrthogTypes[];

 67: /*E
 68:     BVOrthogRefineType - Determines what type of refinement to use
 69:     during orthogonalization of vectors

 71:     Level: advanced

 73: .seealso: BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalizeColumn()
 74: E*/
 75: typedef enum { BV_ORTHOG_REFINE_IFNEEDED,
 76:                BV_ORTHOG_REFINE_NEVER,
 77:                BV_ORTHOG_REFINE_ALWAYS } BVOrthogRefineType;
 78: PETSC_EXTERN const char *BVOrthogRefineTypes[];

 80: /*E
 81:     BVOrthogBlockType - Determines the method used in block
 82:     orthogonalization (simultaneous orthogonalization of a set of vectors)

 84:     Level: advanced

 86: .seealso: BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalize()
 87: E*/
 88: typedef enum { BV_ORTHOG_BLOCK_GS,
 89:                BV_ORTHOG_BLOCK_CHOL } BVOrthogBlockType;
 90: PETSC_EXTERN const char *BVOrthogBlockTypes[];

 92: /*E
 93:     BVMatMultType - Determines how to perform the BVMatMult() operation:
 94:        BV_MATMULT_VECS: perform a matrix-vector multiply per each column;
 95:        BV_MATMULT_MAT: carry out a MatMatMult() product with a dense matrix (default);
 96:        BV_MATMULT_MAT_SAVE: call MatMatMult() and keep auxiliary matrices
 97:          (more efficient but needs more memory)

 99:     Level: advanced

101: .seealso: BVMatMult()
102: E*/
103: typedef enum { BV_MATMULT_VECS,
104:                BV_MATMULT_MAT,
105:                BV_MATMULT_MAT_SAVE } BVMatMultType;
106: PETSC_EXTERN const char *BVMatMultTypes[];

108: PETSC_EXTERN PetscErrorCode BVCreate(MPI_Comm,BV*);
109: PETSC_EXTERN PetscErrorCode BVDestroy(BV*);
110: PETSC_EXTERN PetscErrorCode BVSetType(BV,BVType);
111: PETSC_EXTERN PetscErrorCode BVGetType(BV,BVType*);
112: PETSC_EXTERN PetscErrorCode BVSetSizes(BV,PetscInt,PetscInt,PetscInt);
113: PETSC_EXTERN PetscErrorCode BVSetSizesFromVec(BV,Vec,PetscInt);
114: PETSC_EXTERN PetscErrorCode BVGetSizes(BV,PetscInt*,PetscInt*,PetscInt*);
115: PETSC_EXTERN PetscErrorCode BVResize(BV,PetscInt,PetscBool);
116: PETSC_EXTERN PetscErrorCode BVSetFromOptions(BV);
117: PETSC_EXTERN PetscErrorCode BVView(BV,PetscViewer);

119: PETSC_EXTERN PetscErrorCode BVGetColumn(BV,PetscInt,Vec*);
120: PETSC_EXTERN PetscErrorCode BVRestoreColumn(BV,PetscInt,Vec*);
121: PETSC_EXTERN PetscErrorCode BVGetArray(BV,PetscScalar**);
122: PETSC_EXTERN PetscErrorCode BVRestoreArray(BV,PetscScalar**);
123: PETSC_EXTERN PetscErrorCode BVGetArrayRead(BV,const PetscScalar**);
124: PETSC_EXTERN PetscErrorCode BVRestoreArrayRead(BV,const PetscScalar**);
125: PETSC_EXTERN PetscErrorCode BVCreateVec(BV,Vec*);
126: PETSC_EXTERN PetscErrorCode BVSetActiveColumns(BV,PetscInt,PetscInt);
127: PETSC_EXTERN PetscErrorCode BVGetActiveColumns(BV,PetscInt*,PetscInt*);
128: PETSC_EXTERN PetscErrorCode BVInsertVec(BV,PetscInt,Vec);
129: PETSC_EXTERN PetscErrorCode BVInsertVecs(BV,PetscInt,PetscInt*,Vec*,PetscBool);
130: PETSC_EXTERN PetscErrorCode BVInsertConstraints(BV,PetscInt*,Vec*);
131: PETSC_EXTERN PetscErrorCode BVSetNumConstraints(BV,PetscInt);
132: PETSC_EXTERN PetscErrorCode BVGetNumConstraints(BV,PetscInt*);
133: PETSC_EXTERN PetscErrorCode BVDuplicate(BV,BV*);
134: PETSC_EXTERN PetscErrorCode BVDuplicateResize(BV,PetscInt,BV*);
135: PETSC_EXTERN PetscErrorCode BVCopy(BV,BV);
136: PETSC_EXTERN PetscErrorCode BVCopyVec(BV,PetscInt,Vec);
137: PETSC_EXTERN PetscErrorCode BVCopyColumn(BV,PetscInt,PetscInt);
138: PETSC_EXTERN PetscErrorCode BVSetMatrix(BV,Mat,PetscBool);
139: PETSC_EXTERN PetscErrorCode BVGetMatrix(BV,Mat*,PetscBool*);
140: PETSC_EXTERN PetscErrorCode BVApplyMatrix(BV,Vec,Vec);
141: PETSC_EXTERN PetscErrorCode BVApplyMatrixBV(BV,BV);
142: PETSC_EXTERN PetscErrorCode BVGetCachedBV(BV,BV*);
143: PETSC_EXTERN PetscErrorCode BVSetSignature(BV,Vec);
144: PETSC_EXTERN PetscErrorCode BVGetSignature(BV,Vec);

146: PETSC_EXTERN PetscErrorCode BVMult(BV,PetscScalar,PetscScalar,BV,Mat);
147: PETSC_EXTERN PetscErrorCode BVMultVec(BV,PetscScalar,PetscScalar,Vec,PetscScalar*);
148: PETSC_EXTERN PetscErrorCode BVMultColumn(BV,PetscScalar,PetscScalar,PetscInt,PetscScalar*);
149: PETSC_EXTERN PetscErrorCode BVMultInPlace(BV,Mat,PetscInt,PetscInt);
150: PETSC_EXTERN PetscErrorCode BVMultInPlaceTranspose(BV,Mat,PetscInt,PetscInt);
151: PETSC_EXTERN PetscErrorCode BVMatMult(BV,Mat,BV);
152: PETSC_EXTERN PetscErrorCode BVMatMultHermitianTranspose(BV,Mat,BV);
153: PETSC_EXTERN PetscErrorCode BVMatMultColumn(BV,Mat,PetscInt);
154: PETSC_EXTERN PetscErrorCode BVMatProject(BV,Mat,BV,Mat);
155: PETSC_EXTERN PetscErrorCode BVDot(BV,BV,Mat);
156: PETSC_EXTERN PetscErrorCode BVDotVec(BV,Vec,PetscScalar*);
157: PETSC_EXTERN PetscErrorCode BVDotVecBegin(BV,Vec,PetscScalar*);
158: PETSC_EXTERN PetscErrorCode BVDotVecEnd(BV,Vec,PetscScalar*);
159: PETSC_EXTERN PetscErrorCode BVDotColumn(BV,PetscInt,PetscScalar*);
160: PETSC_EXTERN PetscErrorCode BVDotColumnBegin(BV,PetscInt,PetscScalar*);
161: PETSC_EXTERN PetscErrorCode BVDotColumnEnd(BV,PetscInt,PetscScalar*);
162: PETSC_EXTERN PetscErrorCode BVScale(BV,PetscScalar);
163: PETSC_EXTERN PetscErrorCode BVScaleColumn(BV,PetscInt,PetscScalar);
164: PETSC_EXTERN PetscErrorCode BVNorm(BV,NormType,PetscReal*);
165: PETSC_EXTERN PetscErrorCode BVNormVec(BV,Vec,NormType,PetscReal*);
166: PETSC_EXTERN PetscErrorCode BVNormVecBegin(BV,Vec,NormType,PetscReal*);
167: PETSC_EXTERN PetscErrorCode BVNormVecEnd(BV,Vec,NormType,PetscReal*);
168: PETSC_EXTERN PetscErrorCode BVNormColumn(BV,PetscInt,NormType,PetscReal*);
169: PETSC_EXTERN PetscErrorCode BVNormColumnBegin(BV,PetscInt,NormType,PetscReal*);
170: PETSC_EXTERN PetscErrorCode BVNormColumnEnd(BV,PetscInt,NormType,PetscReal*);
171: PETSC_EXTERN PetscErrorCode BVSetRandom(BV);
172: PETSC_EXTERN PetscErrorCode BVSetRandomColumn(BV,PetscInt);
173: PETSC_EXTERN PetscErrorCode BVSetRandomContext(BV,PetscRandom);
174: PETSC_EXTERN PetscErrorCode BVGetRandomContext(BV,PetscRandom*);

176: PETSC_EXTERN PetscErrorCode BVSetOrthogonalization(BV,BVOrthogType,BVOrthogRefineType,PetscReal,BVOrthogBlockType);
177: PETSC_EXTERN PetscErrorCode BVGetOrthogonalization(BV,BVOrthogType*,BVOrthogRefineType*,PetscReal*,BVOrthogBlockType*);
178: PETSC_EXTERN PetscErrorCode BVOrthogonalize(BV,Mat);
179: PETSC_EXTERN PetscErrorCode BVOrthogonalizeVec(BV,Vec,PetscScalar*,PetscReal*,PetscBool*);
180: PETSC_EXTERN PetscErrorCode BVOrthogonalizeColumn(BV,PetscInt,PetscScalar*,PetscReal*,PetscBool*);
181: PETSC_EXTERN PetscErrorCode BVOrthogonalizeSomeColumn(BV,PetscInt,PetscBool*,PetscScalar*,PetscReal*,PetscBool*);
182: PETSC_EXTERN PetscErrorCode BVSetMatMultMethod(BV,BVMatMultType);
183: PETSC_EXTERN PetscErrorCode BVGetMatMultMethod(BV,BVMatMultType*);

185: PETSC_EXTERN PetscErrorCode BVSetOptionsPrefix(BV,const char*);
186: PETSC_EXTERN PetscErrorCode BVAppendOptionsPrefix(BV,const char*);
187: PETSC_EXTERN PetscErrorCode BVGetOptionsPrefix(BV,const char*[]);

189: PETSC_EXTERN PetscFunctionList BVList;
190: PETSC_EXTERN PetscErrorCode BVRegister(const char[],PetscErrorCode(*)(BV));

192: #endif

slepc-3.7.4/include/slepceps.h0000644000175000017500000005210113107004621015574 0ustar jromanjroman/* User interface for the SLEPC eigenproblem solvers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCEPS_H) #define __SLEPCEPS_H #include #include #include #include PETSC_EXTERN PetscErrorCode EPSInitializePackage(void); /*S EPS - Abstract SLEPc object that manages all the eigenvalue problem solvers. Level: beginner .seealso: EPSCreate(), ST S*/ typedef struct _p_EPS* EPS; /*J EPSType - String with the name of a SLEPc eigensolver Level: beginner .seealso: EPSSetType(), EPS J*/ typedef const char* EPSType; #define EPSPOWER "power" #define EPSSUBSPACE "subspace" #define EPSARNOLDI "arnoldi" #define EPSLANCZOS "lanczos" #define EPSKRYLOVSCHUR "krylovschur" #define EPSGD "gd" #define EPSJD "jd" #define EPSRQCG "rqcg" #define EPSLOBPCG "lobpcg" #define EPSCISS "ciss" #define EPSLAPACK "lapack" #define EPSARPACK "arpack" #define EPSBLZPACK "blzpack" #define EPSTRLAN "trlan" #define EPSBLOPEX "blopex" #define EPSPRIMME "primme" #define EPSFEAST "feast" /* Logging support */ PETSC_EXTERN PetscClassId EPS_CLASSID; /*E EPSProblemType - Determines the type of eigenvalue problem Level: beginner .seealso: EPSSetProblemType(), EPSGetProblemType() E*/ typedef enum { EPS_HEP=1, EPS_GHEP, EPS_NHEP, EPS_GNHEP, EPS_PGNHEP, EPS_GHIEP } EPSProblemType; /*E EPSExtraction - Determines the type of extraction technique employed by the eigensolver Level: advanced .seealso: EPSSetExtraction(), EPSGetExtraction() E*/ typedef enum { EPS_RITZ, EPS_HARMONIC, EPS_HARMONIC_RELATIVE, EPS_HARMONIC_RIGHT, EPS_HARMONIC_LARGEST, EPS_REFINED, EPS_REFINED_HARMONIC } EPSExtraction; /*E EPSWhich - Determines which part of the spectrum is requested Level: intermediate .seealso: EPSSetWhichEigenpairs(), EPSGetWhichEigenpairs() E*/ typedef enum { EPS_LARGEST_MAGNITUDE=1, EPS_SMALLEST_MAGNITUDE, EPS_LARGEST_REAL, EPS_SMALLEST_REAL, EPS_LARGEST_IMAGINARY, EPS_SMALLEST_IMAGINARY, EPS_TARGET_MAGNITUDE, EPS_TARGET_REAL, EPS_TARGET_IMAGINARY, EPS_ALL, EPS_WHICH_USER } EPSWhich; /*E EPSBalance - The type of balancing used for non-Hermitian problems Level: intermediate .seealso: EPSSetBalance() E*/ typedef enum { EPS_BALANCE_NONE, EPS_BALANCE_ONESIDE, EPS_BALANCE_TWOSIDE, EPS_BALANCE_USER } EPSBalance; PETSC_EXTERN const char *EPSBalanceTypes[]; /*E EPSErrorType - The error type used to assess accuracy of computed solutions Level: intermediate .seealso: EPSComputeError() E*/ typedef enum { EPS_ERROR_ABSOLUTE, EPS_ERROR_RELATIVE, EPS_ERROR_BACKWARD } EPSErrorType; PETSC_EXTERN const char *EPSErrorTypes[]; /*E EPSConv - Determines the convergence test Level: intermediate .seealso: EPSSetConvergenceTest(), EPSSetConvergenceTestFunction() E*/ typedef enum { EPS_CONV_ABS, EPS_CONV_REL, EPS_CONV_NORM, EPS_CONV_USER } EPSConv; /*E EPSStop - Determines the stopping test Level: advanced .seealso: EPSSetStoppingTest(), EPSSetStoppingTestFunction() E*/ typedef enum { EPS_STOP_BASIC, EPS_STOP_USER } EPSStop; /*E EPSConvergedReason - Reason an eigensolver was said to have converged or diverged Level: intermediate .seealso: EPSSolve(), EPSGetConvergedReason(), EPSSetTolerances() E*/ typedef enum {/* converged */ EPS_CONVERGED_TOL = 1, EPS_CONVERGED_USER = 2, /* diverged */ EPS_DIVERGED_ITS = -1, EPS_DIVERGED_BREAKDOWN = -2, EPS_DIVERGED_SYMMETRY_LOST = -3, EPS_CONVERGED_ITERATING = 0} EPSConvergedReason; PETSC_EXTERN const char *const*EPSConvergedReasons; PETSC_EXTERN PetscErrorCode EPSCreate(MPI_Comm,EPS*); PETSC_EXTERN PetscErrorCode EPSDestroy(EPS*); PETSC_EXTERN PetscErrorCode EPSReset(EPS); PETSC_EXTERN PetscErrorCode EPSSetType(EPS,EPSType); PETSC_EXTERN PetscErrorCode EPSGetType(EPS,EPSType*); PETSC_EXTERN PetscErrorCode EPSSetProblemType(EPS,EPSProblemType); PETSC_EXTERN PetscErrorCode EPSGetProblemType(EPS,EPSProblemType*); PETSC_EXTERN PetscErrorCode EPSSetExtraction(EPS,EPSExtraction); PETSC_EXTERN PetscErrorCode EPSGetExtraction(EPS,EPSExtraction*); PETSC_EXTERN PetscErrorCode EPSSetBalance(EPS,EPSBalance,PetscInt,PetscReal); PETSC_EXTERN PetscErrorCode EPSGetBalance(EPS,EPSBalance*,PetscInt*,PetscReal*); PETSC_EXTERN PetscErrorCode EPSSetOperators(EPS,Mat,Mat); PETSC_EXTERN PetscErrorCode EPSGetOperators(EPS,Mat*,Mat*); PETSC_EXTERN PetscErrorCode EPSSetFromOptions(EPS); PETSC_EXTERN PetscErrorCode EPSSetUp(EPS); PETSC_EXTERN PetscErrorCode EPSSolve(EPS); PETSC_EXTERN PetscErrorCode EPSView(EPS,PetscViewer); PETSC_STATIC_INLINE PetscErrorCode EPSViewFromOptions(EPS eps,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)eps,obj,name);} PETSC_EXTERN PetscErrorCode EPSErrorView(EPS,EPSErrorType,PetscViewer); PETSC_DEPRECATED("Use EPSErrorView()") PETSC_STATIC_INLINE PetscErrorCode EPSPrintSolution(EPS eps,PetscViewer v) {return EPSErrorView(eps,EPS_ERROR_RELATIVE,v);} PETSC_EXTERN PetscErrorCode EPSErrorViewFromOptions(EPS); PETSC_EXTERN PetscErrorCode EPSReasonView(EPS,PetscViewer); PETSC_EXTERN PetscErrorCode EPSReasonViewFromOptions(EPS); PETSC_EXTERN PetscErrorCode EPSValuesView(EPS,PetscViewer); PETSC_EXTERN PetscErrorCode EPSValuesViewFromOptions(EPS); PETSC_EXTERN PetscErrorCode EPSVectorsView(EPS,PetscViewer); PETSC_EXTERN PetscErrorCode EPSVectorsViewFromOptions(EPS); PETSC_EXTERN PetscErrorCode EPSSetTarget(EPS,PetscScalar); PETSC_EXTERN PetscErrorCode EPSGetTarget(EPS,PetscScalar*); PETSC_EXTERN PetscErrorCode EPSSetInterval(EPS,PetscReal,PetscReal); PETSC_EXTERN PetscErrorCode EPSGetInterval(EPS,PetscReal*,PetscReal*); PETSC_EXTERN PetscErrorCode EPSSetST(EPS,ST); PETSC_EXTERN PetscErrorCode EPSGetST(EPS,ST*); PETSC_EXTERN PetscErrorCode EPSSetBV(EPS,BV); PETSC_EXTERN PetscErrorCode EPSGetBV(EPS,BV*); PETSC_EXTERN PetscErrorCode EPSSetRG(EPS,RG); PETSC_EXTERN PetscErrorCode EPSGetRG(EPS,RG*); PETSC_EXTERN PetscErrorCode EPSSetDS(EPS,DS); PETSC_EXTERN PetscErrorCode EPSGetDS(EPS,DS*); PETSC_EXTERN PetscErrorCode EPSSetTolerances(EPS,PetscReal,PetscInt); PETSC_EXTERN PetscErrorCode EPSGetTolerances(EPS,PetscReal*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSSetConvergenceTestFunction(EPS,PetscErrorCode (*)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode EPSSetConvergenceTest(EPS,EPSConv); PETSC_EXTERN PetscErrorCode EPSGetConvergenceTest(EPS,EPSConv*); PETSC_EXTERN PetscErrorCode EPSConvergedAbsolute(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode EPSConvergedRelative(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode EPSConvergedNorm(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode EPSSetStoppingTestFunction(EPS,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode EPSSetStoppingTest(EPS,EPSStop); PETSC_EXTERN PetscErrorCode EPSGetStoppingTest(EPS,EPSStop*); PETSC_EXTERN PetscErrorCode EPSStoppingBasic(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*); PETSC_EXTERN PetscErrorCode EPSGetConvergedReason(EPS,EPSConvergedReason*); PETSC_EXTERN PetscErrorCode EPSSetDimensions(EPS,PetscInt,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode EPSGetDimensions(EPS,PetscInt*,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSGetConverged(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSGetEigenpair(EPS,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec); PETSC_EXTERN PetscErrorCode EPSGetEigenvalue(EPS,PetscInt,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscErrorCode EPSGetEigenvector(EPS,PetscInt,Vec,Vec); PETSC_EXTERN PetscErrorCode EPSComputeError(EPS,PetscInt,EPSErrorType,PetscReal*); PETSC_DEPRECATED("Use EPSComputeError()") PETSC_STATIC_INLINE PetscErrorCode EPSComputeRelativeError(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_RELATIVE,r);} PETSC_DEPRECATED("Use EPSComputeError() with EPS_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode EPSComputeResidualNorm(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_ABSOLUTE,r);} PETSC_EXTERN PetscErrorCode EPSGetInvariantSubspace(EPS,Vec*); PETSC_EXTERN PetscErrorCode EPSGetErrorEstimate(EPS,PetscInt,PetscReal*); PETSC_EXTERN PetscErrorCode EPSMonitor(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt); PETSC_EXTERN PetscErrorCode EPSMonitorSet(EPS,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**)); PETSC_EXTERN PetscErrorCode EPSMonitorSetFromOptions(EPS,const char*,const char*,const char*,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool); PETSC_EXTERN PetscErrorCode EPSConvMonitorSetFromOptions(EPS,const char*,const char*,const char*,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor)); PETSC_EXTERN PetscErrorCode EPSMonitorCancel(EPS); PETSC_EXTERN PetscErrorCode EPSGetMonitorContext(EPS,void**); PETSC_EXTERN PetscErrorCode EPSGetIterationNumber(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSSetWhichEigenpairs(EPS,EPSWhich); PETSC_EXTERN PetscErrorCode EPSGetWhichEigenpairs(EPS,EPSWhich*); PETSC_EXTERN PetscErrorCode EPSSetTrueResidual(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSGetTrueResidual(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSSetPurify(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSGetPurify(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSSetEigenvalueComparison(EPS,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*); PETSC_EXTERN PetscErrorCode EPSSetArbitrarySelection(EPS,PetscErrorCode (*func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*),void*); PETSC_EXTERN PetscErrorCode EPSIsGeneralized(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSIsHermitian(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSIsPositive(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSMonitorFirst(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode EPSMonitorAll(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode EPSMonitorConverged(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor); PETSC_EXTERN PetscErrorCode EPSMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*); PETSC_EXTERN PetscErrorCode EPSMonitorLG(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode EPSMonitorLGAll(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode EPSSetTrackAll(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSGetTrackAll(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSSetDeflationSpace(EPS,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode EPSSetInitialSpace(EPS,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode EPSSetOptionsPrefix(EPS,const char*); PETSC_EXTERN PetscErrorCode EPSAppendOptionsPrefix(EPS,const char*); PETSC_EXTERN PetscErrorCode EPSGetOptionsPrefix(EPS,const char*[]); PETSC_EXTERN PetscFunctionList EPSList; PETSC_EXTERN PetscErrorCode EPSRegister(const char[],PetscErrorCode(*)(EPS)); PETSC_EXTERN PetscErrorCode EPSSetWorkVecs(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSAllocateSolution(EPS,PetscInt); /* --------- options specific to particular eigensolvers -------- */ /*E EPSPowerShiftType - determines the type of shift used in the Power iteration Level: advanced .seealso: EPSPowerSetShiftType(), EPSPowerGetShiftType() E*/ typedef enum { EPS_POWER_SHIFT_CONSTANT, EPS_POWER_SHIFT_RAYLEIGH, EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType; PETSC_EXTERN const char *EPSPowerShiftTypes[]; PETSC_EXTERN PetscErrorCode EPSPowerSetShiftType(EPS,EPSPowerShiftType); PETSC_EXTERN PetscErrorCode EPSPowerGetShiftType(EPS,EPSPowerShiftType*); PETSC_EXTERN PetscErrorCode EPSArnoldiSetDelayed(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSArnoldiGetDelayed(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetRestart(EPS,PetscReal); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetRestart(EPS,PetscReal*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetLocking(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetLocking(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetPartitions(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetPartitions(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetDetectZeros(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetDetectZeros(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetDimensions(EPS,PetscInt,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetDimensions(EPS,PetscInt*,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetSubintervals(EPS,PetscReal*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubintervals(EPS,PetscReal**); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetInertias(EPS,PetscInt*,PetscReal**,PetscInt**); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubcommInfo(EPS,PetscInt*,PetscInt*,Vec*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubcommPairs(EPS,PetscInt,PetscScalar*,Vec); PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubcommMats(EPS,Mat*,Mat*); PETSC_EXTERN PetscErrorCode EPSKrylovSchurUpdateSubcommMats(EPS,PetscScalar,PetscScalar,Mat,PetscScalar,PetscScalar, Mat,MatStructure,PetscBool); /*E EPSLanczosReorthogType - determines the type of reorthogonalization used in the Lanczos method Level: advanced .seealso: EPSLanczosSetReorthog(), EPSLanczosGetReorthog() E*/ typedef enum { EPS_LANCZOS_REORTHOG_LOCAL, EPS_LANCZOS_REORTHOG_FULL, EPS_LANCZOS_REORTHOG_SELECTIVE, EPS_LANCZOS_REORTHOG_PERIODIC, EPS_LANCZOS_REORTHOG_PARTIAL, EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType; PETSC_EXTERN const char *EPSLanczosReorthogTypes[]; PETSC_EXTERN PetscErrorCode EPSLanczosSetReorthog(EPS,EPSLanczosReorthogType); PETSC_EXTERN PetscErrorCode EPSLanczosGetReorthog(EPS,EPSLanczosReorthogType*); PETSC_EXTERN PetscErrorCode EPSBlzpackSetBlockSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSBlzpackSetNSteps(EPS,PetscInt); /*E EPSPRIMMEMethod - determines the method selected in the PRIMME library Level: advanced .seealso: EPSPRIMMESetMethod(), EPSPRIMMEGetMethod() E*/ typedef enum { EPS_PRIMME_DYNAMIC, EPS_PRIMME_DEFAULT_MIN_TIME, EPS_PRIMME_DEFAULT_MIN_MATVECS, EPS_PRIMME_ARNOLDI, EPS_PRIMME_GD, EPS_PRIMME_GD_PLUSK, EPS_PRIMME_GD_OLSEN_PLUSK, EPS_PRIMME_JD_OLSEN_PLUSK, EPS_PRIMME_RQI, EPS_PRIMME_JDQR, EPS_PRIMME_JDQMR, EPS_PRIMME_JDQMR_ETOL, EPS_PRIMME_SUBSPACE_ITERATION, EPS_PRIMME_LOBPCG_ORTHOBASIS, EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod; PETSC_EXTERN const char *EPSPRIMMEMethods[]; PETSC_EXTERN PetscErrorCode EPSPRIMMESetBlockSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSPRIMMESetMethod(EPS,EPSPRIMMEMethod); PETSC_EXTERN PetscErrorCode EPSPRIMMEGetBlockSize(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSPRIMMEGetMethod(EPS,EPSPRIMMEMethod*); PETSC_EXTERN PetscErrorCode EPSGDSetKrylovStart(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSGDGetKrylovStart(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSGDSetBlockSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSGDGetBlockSize(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSGDSetRestart(EPS,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode EPSGDGetRestart(EPS,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSGDSetInitialSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSGDGetInitialSize(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSGDSetBOrth(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSGDGetBOrth(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSGDGetWindowSizes(EPS,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSGDSetWindowSizes(EPS,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode EPSGDSetDoubleExpansion(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSGDGetDoubleExpansion(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSJDSetKrylovStart(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSJDGetKrylovStart(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSJDSetBlockSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSJDGetBlockSize(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSJDSetRestart(EPS,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode EPSJDGetRestart(EPS,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSJDSetInitialSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSJDGetInitialSize(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSJDSetFix(EPS,PetscReal); PETSC_EXTERN PetscErrorCode EPSJDGetFix(EPS,PetscReal*); PETSC_EXTERN PetscErrorCode EPSJDSetConstCorrectionTol(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSJDGetConstCorrectionTol(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSJDSetBOrth(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSJDGetBOrth(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSJDGetWindowSizes(EPS,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSJDSetWindowSizes(EPS,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode EPSRQCGSetReset(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSRQCGGetReset(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSLOBPCGSetBlockSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSLOBPCGGetBlockSize(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSLOBPCGSetRestart(EPS,PetscReal); PETSC_EXTERN PetscErrorCode EPSLOBPCGGetRestart(EPS,PetscReal*); PETSC_EXTERN PetscErrorCode EPSLOBPCGSetLocking(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSLOBPCGGetLocking(EPS,PetscBool*); /*E EPSCISSQuadRule - determines the quadrature rule in the CISS solver Level: advanced .seealso: EPSCISSSetQuadRule(), EPSCISSGetQuadRule() E*/ typedef enum { EPS_CISS_QUADRULE_TRAPEZOIDAL=1, EPS_CISS_QUADRULE_CHEBYSHEV } EPSCISSQuadRule; PETSC_EXTERN const char *EPSCISSQuadRules[]; /*E EPSCISSExtraction - determines the extraction technique in the CISS solver Level: advanced .seealso: EPSCISSSetExtraction(), EPSCISSGetExtraction() E*/ typedef enum { EPS_CISS_EXTRACTION_RITZ, EPS_CISS_EXTRACTION_HANKEL } EPSCISSExtraction; PETSC_EXTERN const char *EPSCISSExtractions[]; PETSC_EXTERN PetscErrorCode EPSCISSSetExtraction(EPS,EPSCISSExtraction); PETSC_EXTERN PetscErrorCode EPSCISSGetExtraction(EPS,EPSCISSExtraction*); PETSC_EXTERN PetscErrorCode EPSCISSSetQuadRule(EPS,EPSCISSQuadRule); PETSC_EXTERN PetscErrorCode EPSCISSGetQuadRule(EPS,EPSCISSQuadRule*); PETSC_EXTERN PetscErrorCode EPSCISSSetRegion(EPS,PetscScalar,PetscReal,PetscReal); PETSC_EXTERN PetscErrorCode EPSCISSGetRegion(EPS,PetscScalar*,PetscReal*,PetscReal*); PETSC_EXTERN PetscErrorCode EPSCISSSetSizes(EPS,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool); PETSC_EXTERN PetscErrorCode EPSCISSGetSizes(EPS,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*); PETSC_EXTERN PetscErrorCode EPSCISSSetThreshold(EPS,PetscReal,PetscReal); PETSC_EXTERN PetscErrorCode EPSCISSGetThreshold(EPS,PetscReal*,PetscReal*); PETSC_EXTERN PetscErrorCode EPSCISSSetRefinement(EPS,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode EPSCISSGetRefinement(EPS,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode EPSCISSSetUseST(EPS,PetscBool); PETSC_EXTERN PetscErrorCode EPSCISSGetUseST(EPS,PetscBool*); PETSC_EXTERN PetscErrorCode EPSBLOPEXSetBlockSize(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSBLOPEXGetBlockSize(EPS,PetscInt*); PETSC_EXTERN PetscErrorCode EPSFEASTSetNumPoints(EPS,PetscInt); PETSC_EXTERN PetscErrorCode EPSFEASTGetNumPoints(EPS,PetscInt*); #endif slepc-3.7.4/include/slepcrgtypes.h.html0000644000175000017500000000617613107004621017460 0ustar jromanjroman
Actual source code: slepcrgtypes.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */


 25: /*S
 26:    RG - Region of the complex plane.

 28:    Level: beginner

 30: .seealso: RGCreate()
 31: S*/
 32: typedef struct _p_RG* RG;

 34: #endif
slepc-3.7.4/include/makefile.html0000644000175000017500000000500113107004621016245 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#     
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS   =
FFLAGS   =
SOURCEC  =
SOURCEF  =
SOURCEH  = slepc.h slepcsys.h slepcmath.h slepcversion.h slepcblaslapack.h \
           slepceps.h slepcpep.h slepcnep.h slepcmfn.h slepcsvd.h \
           slepcst.h slepcds.h slepcfn.h slepcrg.h slepcbv.h slepcvec.h
LIBBASE  = libslepcsys
DIRS     = slepc/finclude slepc/private
LOCDIR   = include/
MANSEC   = 

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/include/slepcmfn.h0000644000175000017500000001144313107004621015571 0ustar jromanjroman/* User interface for the SLEPC matrix function object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCMFN_H) #define __SLEPCMFN_H #include #include PETSC_EXTERN PetscErrorCode MFNInitializePackage(void); /*S MFN - SLEPc object that encapsulates functionality for matrix functions. Level: beginner .seealso: MFNCreate() S*/ typedef struct _p_MFN* MFN; /*J MFNType - String with the name of a method for computing matrix functions. Level: beginner .seealso: MFNSetType(), MFN J*/ typedef const char* MFNType; #define MFNKRYLOV "krylov" #define MFNEXPOKIT "expokit" /* Logging support */ PETSC_EXTERN PetscClassId MFN_CLASSID; PETSC_EXTERN PetscErrorCode MFNCreate(MPI_Comm,MFN *); PETSC_EXTERN PetscErrorCode MFNDestroy(MFN*); PETSC_EXTERN PetscErrorCode MFNReset(MFN); PETSC_EXTERN PetscErrorCode MFNSetType(MFN,MFNType); PETSC_EXTERN PetscErrorCode MFNGetType(MFN,MFNType*); PETSC_EXTERN PetscErrorCode MFNSetOperator(MFN,Mat); PETSC_EXTERN PetscErrorCode MFNGetOperator(MFN,Mat*); PETSC_EXTERN PetscErrorCode MFNSetFromOptions(MFN); PETSC_EXTERN PetscErrorCode MFNSetUp(MFN); PETSC_EXTERN PetscErrorCode MFNSolve(MFN,Vec,Vec); PETSC_EXTERN PetscErrorCode MFNView(MFN,PetscViewer); PETSC_STATIC_INLINE PetscErrorCode MFNViewFromOptions(MFN mfn,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)mfn,obj,name);} PETSC_EXTERN PetscErrorCode MFNReasonView(MFN,PetscViewer); PETSC_EXTERN PetscErrorCode MFNReasonViewFromOptions(MFN); PETSC_EXTERN PetscErrorCode MFNSetBV(MFN,BV); PETSC_EXTERN PetscErrorCode MFNGetBV(MFN,BV*); PETSC_EXTERN PetscErrorCode MFNSetFN(MFN,FN); PETSC_EXTERN PetscErrorCode MFNGetFN(MFN,FN*); PETSC_EXTERN PetscErrorCode MFNSetTolerances(MFN,PetscReal,PetscInt); PETSC_EXTERN PetscErrorCode MFNGetTolerances(MFN,PetscReal*,PetscInt*); PETSC_EXTERN PetscErrorCode MFNSetDimensions(MFN,PetscInt); PETSC_EXTERN PetscErrorCode MFNGetDimensions(MFN,PetscInt*); PETSC_EXTERN PetscErrorCode MFNMonitor(MFN,PetscInt,PetscReal); PETSC_EXTERN PetscErrorCode MFNMonitorSet(MFN,PetscErrorCode (*)(MFN,PetscInt,PetscReal,void*),void*,PetscErrorCode (*)(void**)); PETSC_EXTERN PetscErrorCode MFNMonitorSetFromOptions(MFN,const char*,const char*,const char*,PetscErrorCode (*)(MFN,PetscInt,PetscReal,PetscViewerAndFormat*)); PETSC_EXTERN PetscErrorCode MFNMonitorCancel(MFN); PETSC_EXTERN PetscErrorCode MFNGetMonitorContext(MFN,void **); PETSC_EXTERN PetscErrorCode MFNGetIterationNumber(MFN,PetscInt*); PETSC_EXTERN PetscErrorCode MFNSetErrorIfNotConverged(MFN,PetscBool); PETSC_EXTERN PetscErrorCode MFNGetErrorIfNotConverged(MFN,PetscBool*); PETSC_EXTERN PetscErrorCode MFNMonitorDefault(MFN,PetscInt,PetscReal,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode MFNMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*); PETSC_EXTERN PetscErrorCode MFNMonitorLG(MFN,PetscInt,PetscReal,void*); PETSC_EXTERN PetscErrorCode MFNSetOptionsPrefix(MFN,const char*); PETSC_EXTERN PetscErrorCode MFNAppendOptionsPrefix(MFN,const char*); PETSC_EXTERN PetscErrorCode MFNGetOptionsPrefix(MFN,const char*[]); /*E MFNConvergedReason - reason a matrix function iteration was said to have converged or diverged Level: intermediate .seealso: MFNSolve(), MFNGetConvergedReason(), MFNSetTolerances() E*/ typedef enum {/* converged */ MFN_CONVERGED_TOL = 2, MFN_CONVERGED_ITS = 3, /* diverged */ MFN_DIVERGED_ITS = -3, MFN_DIVERGED_BREAKDOWN = -4, MFN_CONVERGED_ITERATING = 0} MFNConvergedReason; PETSC_EXTERN const char *const*MFNConvergedReasons; PETSC_EXTERN PetscErrorCode MFNGetConvergedReason(MFN,MFNConvergedReason *); PETSC_EXTERN PetscFunctionList MFNList; PETSC_EXTERN PetscErrorCode MFNRegister(const char[],PetscErrorCode(*)(MFN)); PETSC_EXTERN PetscErrorCode MFNAllocateSolution(MFN,PetscInt); #endif slepc-3.7.4/include/slepcst.h.html0000644000175000017500000005236513107004621016412 0ustar jromanjroman
Actual source code: slepcst.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Spectral transformation module for eigenvalue problems.

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <slepcsys.h>
 27: #include <slepcbv.h>
 28: #include <petscksp.h>

 30: PETSC_EXTERN PetscErrorCode STInitializePackage(void);

 32: /*S
 33:     ST - Abstract SLEPc object that manages spectral transformations.
 34:     This object is accessed only in advanced applications.

 36:     Level: beginner

 38: .seealso:  STCreate(), EPS
 39: S*/
 40: typedef struct _p_ST* ST;

 42: /*J
 43:     STType - String with the name of a SLEPc spectral transformation

 45:     Level: beginner

 47: .seealso: STSetType(), ST
 48: J*/
 49: typedef const char* STType;
 50: #define STSHELL     "shell"
 51: #define STSHIFT     "shift"
 52: #define STSINVERT   "sinvert"
 53: #define STCAYLEY    "cayley"
 54: #define STPRECOND   "precond"

 56: /* Logging support */
 57: PETSC_EXTERN PetscClassId ST_CLASSID;

 59: PETSC_EXTERN PetscErrorCode STCreate(MPI_Comm,ST*);
 60: PETSC_EXTERN PetscErrorCode STDestroy(ST*);
 61: PETSC_EXTERN PetscErrorCode STReset(ST);
 62: PETSC_EXTERN PetscErrorCode STSetType(ST,STType);
 63: PETSC_EXTERN PetscErrorCode STGetType(ST,STType*);
 64: PETSC_EXTERN PetscErrorCode STSetOperators(ST,PetscInt,Mat*);
 65: PETSC_EXTERN PetscErrorCode STGetOperators(ST,PetscInt,Mat*);
 66: PETSC_EXTERN PetscErrorCode STGetTOperators(ST,PetscInt,Mat*);
 67: PETSC_EXTERN PetscErrorCode STGetNumMatrices(ST,PetscInt*);
 68: PETSC_EXTERN PetscErrorCode STSetUp(ST);
 69: PETSC_EXTERN PetscErrorCode STSetFromOptions(ST);
 70: PETSC_EXTERN PetscErrorCode STView(ST,PetscViewer);

 72: PETSC_EXTERN PetscErrorCode STApply(ST,Vec,Vec);
 73: PETSC_EXTERN PetscErrorCode STMatMult(ST,PetscInt,Vec,Vec);
 74: PETSC_EXTERN PetscErrorCode STMatMultTranspose(ST,PetscInt,Vec,Vec);
 75: PETSC_EXTERN PetscErrorCode STMatSolve(ST,Vec,Vec);
 76: PETSC_EXTERN PetscErrorCode STMatSolveTranspose(ST,Vec,Vec);
 77: PETSC_EXTERN PetscErrorCode STGetBilinearForm(ST,Mat*);
 78: PETSC_EXTERN PetscErrorCode STApplyTranspose(ST,Vec,Vec);
 79: PETSC_EXTERN PetscErrorCode STComputeExplicitOperator(ST,Mat*);
 80: PETSC_EXTERN PetscErrorCode STMatSetUp(ST,PetscScalar,PetscScalar*);
 81: PETSC_EXTERN PetscErrorCode STPostSolve(ST);

 83: PETSC_EXTERN PetscErrorCode STSetKSP(ST,KSP);
 84: PETSC_EXTERN PetscErrorCode STGetKSP(ST,KSP*);
 85: PETSC_EXTERN PetscErrorCode STSetShift(ST,PetscScalar);
 86: PETSC_EXTERN PetscErrorCode STGetShift(ST,PetscScalar*);
 87: PETSC_EXTERN PetscErrorCode STSetDefaultShift(ST,PetscScalar);
 88: PETSC_EXTERN PetscErrorCode STScaleShift(ST,PetscScalar);
 89: PETSC_EXTERN PetscErrorCode STSetBalanceMatrix(ST,Vec);
 90: PETSC_EXTERN PetscErrorCode STGetBalanceMatrix(ST,Vec*);
 91: PETSC_EXTERN PetscErrorCode STSetTransform(ST,PetscBool);
 92: PETSC_EXTERN PetscErrorCode STGetTransform(ST,PetscBool*);

 94: PETSC_EXTERN PetscErrorCode STSetOptionsPrefix(ST,const char*);
 95: PETSC_EXTERN PetscErrorCode STAppendOptionsPrefix(ST,const char*);
 96: PETSC_EXTERN PetscErrorCode STGetOptionsPrefix(ST,const char*[]);

 98: PETSC_EXTERN PetscErrorCode STBackTransform(ST,PetscInt,PetscScalar*,PetscScalar*);

100: PETSC_EXTERN PetscErrorCode STCheckNullSpace(ST,BV);

102: PETSC_EXTERN PetscErrorCode STMatCreateVecs(ST,Vec*,Vec*);
103: PETSC_EXTERN PetscErrorCode STMatGetSize(ST,PetscInt*,PetscInt*);
104: PETSC_EXTERN PetscErrorCode STMatGetLocalSize(ST,PetscInt*,PetscInt*);

106: /*E
107:     STMatMode - Determines how to handle the coefficient matrix associated
108:     to the spectral transformation

110:     Level: intermediate

112: .seealso: STSetMatMode(), STGetMatMode()
113: E*/
114: typedef enum { ST_MATMODE_COPY,
115:                ST_MATMODE_INPLACE,
116:                ST_MATMODE_SHELL } STMatMode;
117: PETSC_EXTERN PetscErrorCode STSetMatMode(ST,STMatMode);
118: PETSC_EXTERN PetscErrorCode STGetMatMode(ST,STMatMode*);
119: PETSC_EXTERN PetscErrorCode STSetMatStructure(ST,MatStructure);
120: PETSC_EXTERN PetscErrorCode STGetMatStructure(ST,MatStructure*);

122: PETSC_EXTERN PetscFunctionList STList;
123: PETSC_EXTERN PetscErrorCode STRegister(const char[],PetscErrorCode(*)(ST));

125: /* --------- options specific to particular spectral transformations-------- */

127: PETSC_EXTERN PetscErrorCode STShellGetContext(ST st,void **ctx);
128: PETSC_EXTERN PetscErrorCode STShellSetContext(ST st,void *ctx);
129: PETSC_EXTERN PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec));
130: PETSC_EXTERN PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec));
131: PETSC_EXTERN PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*));

133: PETSC_EXTERN PetscErrorCode STCayleyGetAntishift(ST,PetscScalar*);
134: PETSC_EXTERN PetscErrorCode STCayleySetAntishift(ST,PetscScalar);

136: PETSC_EXTERN PetscErrorCode STPrecondGetMatForPC(ST,Mat*);
137: PETSC_EXTERN PetscErrorCode STPrecondSetMatForPC(ST,Mat);
138: PETSC_EXTERN PetscErrorCode STPrecondGetKSPHasMat(ST,PetscBool*);
139: PETSC_EXTERN PetscErrorCode STPrecondSetKSPHasMat(ST,PetscBool);

141: #endif

slepc-3.7.4/include/slepcbv.h0000644000175000017500000002040113107004621015412 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCBV_H) #define __SLEPCBV_H #include PETSC_EXTERN PetscErrorCode BVInitializePackage(void); /*S BV - Basis vectors, SLEPc object representing a collection of vectors that typically constitute a basis of a subspace. Level: beginner .seealso: BVCreate() S*/ typedef struct _p_BV* BV; /*J BVType - String with the name of the type of BV. Each type differs in the way data is stored internally. Level: beginner .seealso: BVSetType(), BV J*/ typedef const char* BVType; #define BVMAT "mat" #define BVSVEC "svec" #define BVVECS "vecs" #define BVCONTIGUOUS "contiguous" /* Logging support */ PETSC_EXTERN PetscClassId BV_CLASSID; /*E BVOrthogType - Determines the method used in the orthogonalization of vectors Level: advanced .seealso: BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalizeColumn(), BVOrthogRefineType E*/ typedef enum { BV_ORTHOG_CGS, BV_ORTHOG_MGS } BVOrthogType; PETSC_EXTERN const char *BVOrthogTypes[]; /*E BVOrthogRefineType - Determines what type of refinement to use during orthogonalization of vectors Level: advanced .seealso: BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalizeColumn() E*/ typedef enum { BV_ORTHOG_REFINE_IFNEEDED, BV_ORTHOG_REFINE_NEVER, BV_ORTHOG_REFINE_ALWAYS } BVOrthogRefineType; PETSC_EXTERN const char *BVOrthogRefineTypes[]; /*E BVOrthogBlockType - Determines the method used in block orthogonalization (simultaneous orthogonalization of a set of vectors) Level: advanced .seealso: BVSetOrthogonalization(), BVGetOrthogonalization(), BVOrthogonalize() E*/ typedef enum { BV_ORTHOG_BLOCK_GS, BV_ORTHOG_BLOCK_CHOL } BVOrthogBlockType; PETSC_EXTERN const char *BVOrthogBlockTypes[]; /*E BVMatMultType - Determines how to perform the BVMatMult() operation: BV_MATMULT_VECS: perform a matrix-vector multiply per each column; BV_MATMULT_MAT: carry out a MatMatMult() product with a dense matrix (default); BV_MATMULT_MAT_SAVE: call MatMatMult() and keep auxiliary matrices (more efficient but needs more memory) Level: advanced .seealso: BVMatMult() E*/ typedef enum { BV_MATMULT_VECS, BV_MATMULT_MAT, BV_MATMULT_MAT_SAVE } BVMatMultType; PETSC_EXTERN const char *BVMatMultTypes[]; PETSC_EXTERN PetscErrorCode BVCreate(MPI_Comm,BV*); PETSC_EXTERN PetscErrorCode BVDestroy(BV*); PETSC_EXTERN PetscErrorCode BVSetType(BV,BVType); PETSC_EXTERN PetscErrorCode BVGetType(BV,BVType*); PETSC_EXTERN PetscErrorCode BVSetSizes(BV,PetscInt,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode BVSetSizesFromVec(BV,Vec,PetscInt); PETSC_EXTERN PetscErrorCode BVGetSizes(BV,PetscInt*,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode BVResize(BV,PetscInt,PetscBool); PETSC_EXTERN PetscErrorCode BVSetFromOptions(BV); PETSC_EXTERN PetscErrorCode BVView(BV,PetscViewer); PETSC_EXTERN PetscErrorCode BVGetColumn(BV,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode BVRestoreColumn(BV,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode BVGetArray(BV,PetscScalar**); PETSC_EXTERN PetscErrorCode BVRestoreArray(BV,PetscScalar**); PETSC_EXTERN PetscErrorCode BVGetArrayRead(BV,const PetscScalar**); PETSC_EXTERN PetscErrorCode BVRestoreArrayRead(BV,const PetscScalar**); PETSC_EXTERN PetscErrorCode BVCreateVec(BV,Vec*); PETSC_EXTERN PetscErrorCode BVSetActiveColumns(BV,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode BVGetActiveColumns(BV,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode BVInsertVec(BV,PetscInt,Vec); PETSC_EXTERN PetscErrorCode BVInsertVecs(BV,PetscInt,PetscInt*,Vec*,PetscBool); PETSC_EXTERN PetscErrorCode BVInsertConstraints(BV,PetscInt*,Vec*); PETSC_EXTERN PetscErrorCode BVSetNumConstraints(BV,PetscInt); PETSC_EXTERN PetscErrorCode BVGetNumConstraints(BV,PetscInt*); PETSC_EXTERN PetscErrorCode BVDuplicate(BV,BV*); PETSC_EXTERN PetscErrorCode BVDuplicateResize(BV,PetscInt,BV*); PETSC_EXTERN PetscErrorCode BVCopy(BV,BV); PETSC_EXTERN PetscErrorCode BVCopyVec(BV,PetscInt,Vec); PETSC_EXTERN PetscErrorCode BVCopyColumn(BV,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode BVSetMatrix(BV,Mat,PetscBool); PETSC_EXTERN PetscErrorCode BVGetMatrix(BV,Mat*,PetscBool*); PETSC_EXTERN PetscErrorCode BVApplyMatrix(BV,Vec,Vec); PETSC_EXTERN PetscErrorCode BVApplyMatrixBV(BV,BV); PETSC_EXTERN PetscErrorCode BVGetCachedBV(BV,BV*); PETSC_EXTERN PetscErrorCode BVSetSignature(BV,Vec); PETSC_EXTERN PetscErrorCode BVGetSignature(BV,Vec); PETSC_EXTERN PetscErrorCode BVMult(BV,PetscScalar,PetscScalar,BV,Mat); PETSC_EXTERN PetscErrorCode BVMultVec(BV,PetscScalar,PetscScalar,Vec,PetscScalar*); PETSC_EXTERN PetscErrorCode BVMultColumn(BV,PetscScalar,PetscScalar,PetscInt,PetscScalar*); PETSC_EXTERN PetscErrorCode BVMultInPlace(BV,Mat,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode BVMultInPlaceTranspose(BV,Mat,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode BVMatMult(BV,Mat,BV); PETSC_EXTERN PetscErrorCode BVMatMultHermitianTranspose(BV,Mat,BV); PETSC_EXTERN PetscErrorCode BVMatMultColumn(BV,Mat,PetscInt); PETSC_EXTERN PetscErrorCode BVMatProject(BV,Mat,BV,Mat); PETSC_EXTERN PetscErrorCode BVDot(BV,BV,Mat); PETSC_EXTERN PetscErrorCode BVDotVec(BV,Vec,PetscScalar*); PETSC_EXTERN PetscErrorCode BVDotVecBegin(BV,Vec,PetscScalar*); PETSC_EXTERN PetscErrorCode BVDotVecEnd(BV,Vec,PetscScalar*); PETSC_EXTERN PetscErrorCode BVDotColumn(BV,PetscInt,PetscScalar*); PETSC_EXTERN PetscErrorCode BVDotColumnBegin(BV,PetscInt,PetscScalar*); PETSC_EXTERN PetscErrorCode BVDotColumnEnd(BV,PetscInt,PetscScalar*); PETSC_EXTERN PetscErrorCode BVScale(BV,PetscScalar); PETSC_EXTERN PetscErrorCode BVScaleColumn(BV,PetscInt,PetscScalar); PETSC_EXTERN PetscErrorCode BVNorm(BV,NormType,PetscReal*); PETSC_EXTERN PetscErrorCode BVNormVec(BV,Vec,NormType,PetscReal*); PETSC_EXTERN PetscErrorCode BVNormVecBegin(BV,Vec,NormType,PetscReal*); PETSC_EXTERN PetscErrorCode BVNormVecEnd(BV,Vec,NormType,PetscReal*); PETSC_EXTERN PetscErrorCode BVNormColumn(BV,PetscInt,NormType,PetscReal*); PETSC_EXTERN PetscErrorCode BVNormColumnBegin(BV,PetscInt,NormType,PetscReal*); PETSC_EXTERN PetscErrorCode BVNormColumnEnd(BV,PetscInt,NormType,PetscReal*); PETSC_EXTERN PetscErrorCode BVSetRandom(BV); PETSC_EXTERN PetscErrorCode BVSetRandomColumn(BV,PetscInt); PETSC_EXTERN PetscErrorCode BVSetRandomContext(BV,PetscRandom); PETSC_EXTERN PetscErrorCode BVGetRandomContext(BV,PetscRandom*); PETSC_EXTERN PetscErrorCode BVSetOrthogonalization(BV,BVOrthogType,BVOrthogRefineType,PetscReal,BVOrthogBlockType); PETSC_EXTERN PetscErrorCode BVGetOrthogonalization(BV,BVOrthogType*,BVOrthogRefineType*,PetscReal*,BVOrthogBlockType*); PETSC_EXTERN PetscErrorCode BVOrthogonalize(BV,Mat); PETSC_EXTERN PetscErrorCode BVOrthogonalizeVec(BV,Vec,PetscScalar*,PetscReal*,PetscBool*); PETSC_EXTERN PetscErrorCode BVOrthogonalizeColumn(BV,PetscInt,PetscScalar*,PetscReal*,PetscBool*); PETSC_EXTERN PetscErrorCode BVOrthogonalizeSomeColumn(BV,PetscInt,PetscBool*,PetscScalar*,PetscReal*,PetscBool*); PETSC_EXTERN PetscErrorCode BVSetMatMultMethod(BV,BVMatMultType); PETSC_EXTERN PetscErrorCode BVGetMatMultMethod(BV,BVMatMultType*); PETSC_EXTERN PetscErrorCode BVSetOptionsPrefix(BV,const char*); PETSC_EXTERN PetscErrorCode BVAppendOptionsPrefix(BV,const char*); PETSC_EXTERN PetscErrorCode BVGetOptionsPrefix(BV,const char*[]); PETSC_EXTERN PetscFunctionList BVList; PETSC_EXTERN PetscErrorCode BVRegister(const char[],PetscErrorCode(*)(BV)); #endif slepc-3.7.4/include/slepceps.h.html0000644000175000017500000022741113107004621016547 0ustar jromanjroman
Actual source code: slepceps.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    User interface for the SLEPC eigenproblem solvers.

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <slepcst.h>
 27: #include <slepcbv.h>
 28: #include <slepcds.h>
 29: #include <slepcrg.h>

 31: PETSC_EXTERN PetscErrorCode EPSInitializePackage(void);

 33: /*S
 34:     EPS - Abstract SLEPc object that manages all the eigenvalue
 35:     problem solvers.

 37:     Level: beginner

 39: .seealso:  EPSCreate(), ST
 40: S*/
 41: typedef struct _p_EPS* EPS;

 43: /*J
 44:     EPSType - String with the name of a SLEPc eigensolver

 46:     Level: beginner

 48: .seealso: EPSSetType(), EPS
 49: J*/
 50: typedef const char* EPSType;
 51: #define EPSPOWER       "power"
 52: #define EPSSUBSPACE    "subspace"
 53: #define EPSARNOLDI     "arnoldi"
 54: #define EPSLANCZOS     "lanczos"
 55: #define EPSKRYLOVSCHUR "krylovschur"
 56: #define EPSGD          "gd"
 57: #define EPSJD          "jd"
 58: #define EPSRQCG        "rqcg"
 59: #define EPSLOBPCG      "lobpcg"
 60: #define EPSCISS        "ciss"
 61: #define EPSLAPACK      "lapack"
 62: #define EPSARPACK      "arpack"
 63: #define EPSBLZPACK     "blzpack"
 64: #define EPSTRLAN       "trlan"
 65: #define EPSBLOPEX      "blopex"
 66: #define EPSPRIMME      "primme"
 67: #define EPSFEAST       "feast"

 69: /* Logging support */
 70: PETSC_EXTERN PetscClassId EPS_CLASSID;

 72: /*E
 73:     EPSProblemType - Determines the type of eigenvalue problem

 75:     Level: beginner

 77: .seealso: EPSSetProblemType(), EPSGetProblemType()
 78: E*/
 79: typedef enum { EPS_HEP=1,
 80:                EPS_GHEP,
 81:                EPS_NHEP,
 82:                EPS_GNHEP,
 83:                EPS_PGNHEP,
 84:                EPS_GHIEP } EPSProblemType;

 86: /*E
 87:     EPSExtraction - Determines the type of extraction technique employed
 88:     by the eigensolver

 90:     Level: advanced

 92: .seealso: EPSSetExtraction(), EPSGetExtraction()
 93: E*/
 94: typedef enum { EPS_RITZ,
 95:                EPS_HARMONIC,
 96:                EPS_HARMONIC_RELATIVE,
 97:                EPS_HARMONIC_RIGHT,
 98:                EPS_HARMONIC_LARGEST,
 99:                EPS_REFINED,
100:                EPS_REFINED_HARMONIC } EPSExtraction;

102: /*E
103:     EPSWhich - Determines which part of the spectrum is requested

105:     Level: intermediate

107: .seealso: EPSSetWhichEigenpairs(), EPSGetWhichEigenpairs()
108: E*/
109: typedef enum { EPS_LARGEST_MAGNITUDE=1,
110:                EPS_SMALLEST_MAGNITUDE,
111:                EPS_LARGEST_REAL,
112:                EPS_SMALLEST_REAL,
113:                EPS_LARGEST_IMAGINARY,
114:                EPS_SMALLEST_IMAGINARY,
115:                EPS_TARGET_MAGNITUDE,
116:                EPS_TARGET_REAL,
117:                EPS_TARGET_IMAGINARY,
118:                EPS_ALL,
119:                EPS_WHICH_USER } EPSWhich;

121: /*E
122:     EPSBalance - The type of balancing used for non-Hermitian problems

124:     Level: intermediate

126: .seealso: EPSSetBalance()
127: E*/
128: typedef enum { EPS_BALANCE_NONE,
129:                EPS_BALANCE_ONESIDE,
130:                EPS_BALANCE_TWOSIDE,
131:                EPS_BALANCE_USER } EPSBalance;
132: PETSC_EXTERN const char *EPSBalanceTypes[];

134: /*E
135:     EPSErrorType - The error type used to assess accuracy of computed solutions

137:     Level: intermediate

139: .seealso: EPSComputeError()
140: E*/
141: typedef enum { EPS_ERROR_ABSOLUTE,
142:                EPS_ERROR_RELATIVE,
143:                EPS_ERROR_BACKWARD } EPSErrorType;
144: PETSC_EXTERN const char *EPSErrorTypes[];

146: /*E
147:     EPSConv - Determines the convergence test

149:     Level: intermediate

151: .seealso: EPSSetConvergenceTest(), EPSSetConvergenceTestFunction()
152: E*/
153: typedef enum { EPS_CONV_ABS,
154:                EPS_CONV_REL,
155:                EPS_CONV_NORM,
156:                EPS_CONV_USER } EPSConv;

158: /*E
159:     EPSStop - Determines the stopping test

161:     Level: advanced

163: .seealso: EPSSetStoppingTest(), EPSSetStoppingTestFunction()
164: E*/
165: typedef enum { EPS_STOP_BASIC,
166:                EPS_STOP_USER } EPSStop;

168: /*E
169:     EPSConvergedReason - Reason an eigensolver was said to
170:          have converged or diverged

172:     Level: intermediate

174: .seealso: EPSSolve(), EPSGetConvergedReason(), EPSSetTolerances()
175: E*/
176: typedef enum {/* converged */
177:               EPS_CONVERGED_TOL                =  1,
178:               EPS_CONVERGED_USER               =  2,
179:               /* diverged */
180:               EPS_DIVERGED_ITS                 = -1,
181:               EPS_DIVERGED_BREAKDOWN           = -2,
182:               EPS_DIVERGED_SYMMETRY_LOST       = -3,
183:               EPS_CONVERGED_ITERATING          =  0} EPSConvergedReason;
184: PETSC_EXTERN const char *const*EPSConvergedReasons;

186: PETSC_EXTERN PetscErrorCode EPSCreate(MPI_Comm,EPS*);
187: PETSC_EXTERN PetscErrorCode EPSDestroy(EPS*);
188: PETSC_EXTERN PetscErrorCode EPSReset(EPS);
189: PETSC_EXTERN PetscErrorCode EPSSetType(EPS,EPSType);
190: PETSC_EXTERN PetscErrorCode EPSGetType(EPS,EPSType*);
191: PETSC_EXTERN PetscErrorCode EPSSetProblemType(EPS,EPSProblemType);
192: PETSC_EXTERN PetscErrorCode EPSGetProblemType(EPS,EPSProblemType*);
193: PETSC_EXTERN PetscErrorCode EPSSetExtraction(EPS,EPSExtraction);
194: PETSC_EXTERN PetscErrorCode EPSGetExtraction(EPS,EPSExtraction*);
195: PETSC_EXTERN PetscErrorCode EPSSetBalance(EPS,EPSBalance,PetscInt,PetscReal);
196: PETSC_EXTERN PetscErrorCode EPSGetBalance(EPS,EPSBalance*,PetscInt*,PetscReal*);
197: PETSC_EXTERN PetscErrorCode EPSSetOperators(EPS,Mat,Mat);
198: PETSC_EXTERN PetscErrorCode EPSGetOperators(EPS,Mat*,Mat*);
199: PETSC_EXTERN PetscErrorCode EPSSetFromOptions(EPS);
200: PETSC_EXTERN PetscErrorCode EPSSetUp(EPS);
201: PETSC_EXTERN PetscErrorCode EPSSolve(EPS);
202: PETSC_EXTERN PetscErrorCode EPSView(EPS,PetscViewer);
203: PETSC_STATIC_INLINE PetscErrorCode EPSViewFromOptions(EPS eps,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)eps,obj,name);}
204: PETSC_EXTERN PetscErrorCode EPSErrorView(EPS,EPSErrorType,PetscViewer);
205: PETSC_DEPRECATED("Use EPSErrorView()") PETSC_STATIC_INLINE PetscErrorCode EPSPrintSolution(EPS eps,PetscViewer v) {return EPSErrorView(eps,EPS_ERROR_RELATIVE,v);}
206: PETSC_EXTERN PetscErrorCode EPSErrorViewFromOptions(EPS);
207: PETSC_EXTERN PetscErrorCode EPSReasonView(EPS,PetscViewer);
208: PETSC_EXTERN PetscErrorCode EPSReasonViewFromOptions(EPS);
209: PETSC_EXTERN PetscErrorCode EPSValuesView(EPS,PetscViewer);
210: PETSC_EXTERN PetscErrorCode EPSValuesViewFromOptions(EPS);
211: PETSC_EXTERN PetscErrorCode EPSVectorsView(EPS,PetscViewer);
212: PETSC_EXTERN PetscErrorCode EPSVectorsViewFromOptions(EPS);

214: PETSC_EXTERN PetscErrorCode EPSSetTarget(EPS,PetscScalar);
215: PETSC_EXTERN PetscErrorCode EPSGetTarget(EPS,PetscScalar*);
216: PETSC_EXTERN PetscErrorCode EPSSetInterval(EPS,PetscReal,PetscReal);
217: PETSC_EXTERN PetscErrorCode EPSGetInterval(EPS,PetscReal*,PetscReal*);
218: PETSC_EXTERN PetscErrorCode EPSSetST(EPS,ST);
219: PETSC_EXTERN PetscErrorCode EPSGetST(EPS,ST*);
220: PETSC_EXTERN PetscErrorCode EPSSetBV(EPS,BV);
221: PETSC_EXTERN PetscErrorCode EPSGetBV(EPS,BV*);
222: PETSC_EXTERN PetscErrorCode EPSSetRG(EPS,RG);
223: PETSC_EXTERN PetscErrorCode EPSGetRG(EPS,RG*);
224: PETSC_EXTERN PetscErrorCode EPSSetDS(EPS,DS);
225: PETSC_EXTERN PetscErrorCode EPSGetDS(EPS,DS*);
226: PETSC_EXTERN PetscErrorCode EPSSetTolerances(EPS,PetscReal,PetscInt);
227: PETSC_EXTERN PetscErrorCode EPSGetTolerances(EPS,PetscReal*,PetscInt*);
228: PETSC_EXTERN PetscErrorCode EPSSetConvergenceTestFunction(EPS,PetscErrorCode (*)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*));
229: PETSC_EXTERN PetscErrorCode EPSSetConvergenceTest(EPS,EPSConv);
230: PETSC_EXTERN PetscErrorCode EPSGetConvergenceTest(EPS,EPSConv*);
231: PETSC_EXTERN PetscErrorCode EPSConvergedAbsolute(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
232: PETSC_EXTERN PetscErrorCode EPSConvergedRelative(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
233: PETSC_EXTERN PetscErrorCode EPSConvergedNorm(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
234: PETSC_EXTERN PetscErrorCode EPSSetStoppingTestFunction(EPS,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*),void*,PetscErrorCode (*)(void*));
235: PETSC_EXTERN PetscErrorCode EPSSetStoppingTest(EPS,EPSStop);
236: PETSC_EXTERN PetscErrorCode EPSGetStoppingTest(EPS,EPSStop*);
237: PETSC_EXTERN PetscErrorCode EPSStoppingBasic(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*);
238: PETSC_EXTERN PetscErrorCode EPSGetConvergedReason(EPS,EPSConvergedReason*);

240: PETSC_EXTERN PetscErrorCode EPSSetDimensions(EPS,PetscInt,PetscInt,PetscInt);
241: PETSC_EXTERN PetscErrorCode EPSGetDimensions(EPS,PetscInt*,PetscInt*,PetscInt*);

243: PETSC_EXTERN PetscErrorCode EPSGetConverged(EPS,PetscInt*);
244: PETSC_EXTERN PetscErrorCode EPSGetEigenpair(EPS,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec);
245: PETSC_EXTERN PetscErrorCode EPSGetEigenvalue(EPS,PetscInt,PetscScalar*,PetscScalar*);
246: PETSC_EXTERN PetscErrorCode EPSGetEigenvector(EPS,PetscInt,Vec,Vec);

248: PETSC_EXTERN PetscErrorCode EPSComputeError(EPS,PetscInt,EPSErrorType,PetscReal*);
249: PETSC_DEPRECATED("Use EPSComputeError()") PETSC_STATIC_INLINE PetscErrorCode EPSComputeRelativeError(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_RELATIVE,r);}
250: PETSC_DEPRECATED("Use EPSComputeError() with EPS_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode EPSComputeResidualNorm(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_ABSOLUTE,r);}
251: PETSC_EXTERN PetscErrorCode EPSGetInvariantSubspace(EPS,Vec*);
252: PETSC_EXTERN PetscErrorCode EPSGetErrorEstimate(EPS,PetscInt,PetscReal*);

254: PETSC_EXTERN PetscErrorCode EPSMonitor(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt);
255: PETSC_EXTERN PetscErrorCode EPSMonitorSet(EPS,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**));
256: PETSC_EXTERN PetscErrorCode EPSMonitorSetFromOptions(EPS,const char*,const char*,const char*,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool);
257: PETSC_EXTERN PetscErrorCode EPSConvMonitorSetFromOptions(EPS,const char*,const char*,const char*,PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor));
258: PETSC_EXTERN PetscErrorCode EPSMonitorCancel(EPS);
259: PETSC_EXTERN PetscErrorCode EPSGetMonitorContext(EPS,void**);
260: PETSC_EXTERN PetscErrorCode EPSGetIterationNumber(EPS,PetscInt*);

262: PETSC_EXTERN PetscErrorCode EPSSetWhichEigenpairs(EPS,EPSWhich);
263: PETSC_EXTERN PetscErrorCode EPSGetWhichEigenpairs(EPS,EPSWhich*);
264: PETSC_EXTERN PetscErrorCode EPSSetTrueResidual(EPS,PetscBool);
265: PETSC_EXTERN PetscErrorCode EPSGetTrueResidual(EPS,PetscBool*);
266: PETSC_EXTERN PetscErrorCode EPSSetPurify(EPS,PetscBool);
267: PETSC_EXTERN PetscErrorCode EPSGetPurify(EPS,PetscBool*);
268: PETSC_EXTERN PetscErrorCode EPSSetEigenvalueComparison(EPS,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*);
269: PETSC_EXTERN PetscErrorCode EPSSetArbitrarySelection(EPS,PetscErrorCode (*func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*),void*);
270: PETSC_EXTERN PetscErrorCode EPSIsGeneralized(EPS,PetscBool*);
271: PETSC_EXTERN PetscErrorCode EPSIsHermitian(EPS,PetscBool*);
272: PETSC_EXTERN PetscErrorCode EPSIsPositive(EPS,PetscBool*);

274: PETSC_EXTERN PetscErrorCode EPSMonitorFirst(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*);
275: PETSC_EXTERN PetscErrorCode EPSMonitorAll(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*);
276: PETSC_EXTERN PetscErrorCode EPSMonitorConverged(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor);
277: PETSC_EXTERN PetscErrorCode EPSMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*);
278: PETSC_EXTERN PetscErrorCode EPSMonitorLG(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
279: PETSC_EXTERN PetscErrorCode EPSMonitorLGAll(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);

281: PETSC_EXTERN PetscErrorCode EPSSetTrackAll(EPS,PetscBool);
282: PETSC_EXTERN PetscErrorCode EPSGetTrackAll(EPS,PetscBool*);

284: PETSC_EXTERN PetscErrorCode EPSSetDeflationSpace(EPS,PetscInt,Vec*);
285: PETSC_EXTERN PetscErrorCode EPSSetInitialSpace(EPS,PetscInt,Vec*);

287: PETSC_EXTERN PetscErrorCode EPSSetOptionsPrefix(EPS,const char*);
288: PETSC_EXTERN PetscErrorCode EPSAppendOptionsPrefix(EPS,const char*);
289: PETSC_EXTERN PetscErrorCode EPSGetOptionsPrefix(EPS,const char*[]);

291: PETSC_EXTERN PetscFunctionList EPSList;
292: PETSC_EXTERN PetscErrorCode EPSRegister(const char[],PetscErrorCode(*)(EPS));

294: PETSC_EXTERN PetscErrorCode EPSSetWorkVecs(EPS,PetscInt);
295: PETSC_EXTERN PetscErrorCode EPSAllocateSolution(EPS,PetscInt);

297: /* --------- options specific to particular eigensolvers -------- */

299: /*E
300:     EPSPowerShiftType - determines the type of shift used in the Power iteration

302:     Level: advanced

304: .seealso: EPSPowerSetShiftType(), EPSPowerGetShiftType()
305: E*/
306: typedef enum { EPS_POWER_SHIFT_CONSTANT,
307:                EPS_POWER_SHIFT_RAYLEIGH,
308:                EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType;
309: PETSC_EXTERN const char *EPSPowerShiftTypes[];

311: PETSC_EXTERN PetscErrorCode EPSPowerSetShiftType(EPS,EPSPowerShiftType);
312: PETSC_EXTERN PetscErrorCode EPSPowerGetShiftType(EPS,EPSPowerShiftType*);

314: PETSC_EXTERN PetscErrorCode EPSArnoldiSetDelayed(EPS,PetscBool);
315: PETSC_EXTERN PetscErrorCode EPSArnoldiGetDelayed(EPS,PetscBool*);

317: PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetRestart(EPS,PetscReal);
318: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetRestart(EPS,PetscReal*);
319: PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetLocking(EPS,PetscBool);
320: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetLocking(EPS,PetscBool*);
321: PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetPartitions(EPS,PetscInt);
322: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetPartitions(EPS,PetscInt*);
323: PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetDetectZeros(EPS,PetscBool);
324: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetDetectZeros(EPS,PetscBool*);
325: PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetDimensions(EPS,PetscInt,PetscInt,PetscInt);
326: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetDimensions(EPS,PetscInt*,PetscInt*,PetscInt*);
327: PETSC_EXTERN PetscErrorCode EPSKrylovSchurSetSubintervals(EPS,PetscReal*);
328: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubintervals(EPS,PetscReal**);
329: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetInertias(EPS,PetscInt*,PetscReal**,PetscInt**);
330: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubcommInfo(EPS,PetscInt*,PetscInt*,Vec*);
331: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubcommPairs(EPS,PetscInt,PetscScalar*,Vec);
332: PETSC_EXTERN PetscErrorCode EPSKrylovSchurGetSubcommMats(EPS,Mat*,Mat*);
333: PETSC_EXTERN PetscErrorCode EPSKrylovSchurUpdateSubcommMats(EPS,PetscScalar,PetscScalar,Mat,PetscScalar,PetscScalar, Mat,MatStructure,PetscBool);

335: /*E
336:     EPSLanczosReorthogType - determines the type of reorthogonalization
337:     used in the Lanczos method

339:     Level: advanced

341: .seealso: EPSLanczosSetReorthog(), EPSLanczosGetReorthog()
342: E*/
343: typedef enum { EPS_LANCZOS_REORTHOG_LOCAL,
344:                EPS_LANCZOS_REORTHOG_FULL,
345:                EPS_LANCZOS_REORTHOG_SELECTIVE,
346:                EPS_LANCZOS_REORTHOG_PERIODIC,
347:                EPS_LANCZOS_REORTHOG_PARTIAL,
348:                EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType;
349: PETSC_EXTERN const char *EPSLanczosReorthogTypes[];

351: PETSC_EXTERN PetscErrorCode EPSLanczosSetReorthog(EPS,EPSLanczosReorthogType);
352: PETSC_EXTERN PetscErrorCode EPSLanczosGetReorthog(EPS,EPSLanczosReorthogType*);

354: PETSC_EXTERN PetscErrorCode EPSBlzpackSetBlockSize(EPS,PetscInt);
355: PETSC_EXTERN PetscErrorCode EPSBlzpackSetNSteps(EPS,PetscInt);

357: /*E
358:     EPSPRIMMEMethod - determines the method selected in the PRIMME library

360:     Level: advanced

362: .seealso: EPSPRIMMESetMethod(), EPSPRIMMEGetMethod()
363: E*/
364: typedef enum { EPS_PRIMME_DYNAMIC,
365:                EPS_PRIMME_DEFAULT_MIN_TIME,
366:                EPS_PRIMME_DEFAULT_MIN_MATVECS,
367:                EPS_PRIMME_ARNOLDI,
368:                EPS_PRIMME_GD,
369:                EPS_PRIMME_GD_PLUSK,
370:                EPS_PRIMME_GD_OLSEN_PLUSK,
371:                EPS_PRIMME_JD_OLSEN_PLUSK,
372:                EPS_PRIMME_RQI,
373:                EPS_PRIMME_JDQR,
374:                EPS_PRIMME_JDQMR,
375:                EPS_PRIMME_JDQMR_ETOL,
376:                EPS_PRIMME_SUBSPACE_ITERATION,
377:                EPS_PRIMME_LOBPCG_ORTHOBASIS,
378:                EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod;
379: PETSC_EXTERN const char *EPSPRIMMEMethods[];

381: PETSC_EXTERN PetscErrorCode EPSPRIMMESetBlockSize(EPS,PetscInt);
382: PETSC_EXTERN PetscErrorCode EPSPRIMMESetMethod(EPS,EPSPRIMMEMethod);
383: PETSC_EXTERN PetscErrorCode EPSPRIMMEGetBlockSize(EPS,PetscInt*);
384: PETSC_EXTERN PetscErrorCode EPSPRIMMEGetMethod(EPS,EPSPRIMMEMethod*);

386: PETSC_EXTERN PetscErrorCode EPSGDSetKrylovStart(EPS,PetscBool);
387: PETSC_EXTERN PetscErrorCode EPSGDGetKrylovStart(EPS,PetscBool*);
388: PETSC_EXTERN PetscErrorCode EPSGDSetBlockSize(EPS,PetscInt);
389: PETSC_EXTERN PetscErrorCode EPSGDGetBlockSize(EPS,PetscInt*);
390: PETSC_EXTERN PetscErrorCode EPSGDSetRestart(EPS,PetscInt,PetscInt);
391: PETSC_EXTERN PetscErrorCode EPSGDGetRestart(EPS,PetscInt*,PetscInt*);
392: PETSC_EXTERN PetscErrorCode EPSGDSetInitialSize(EPS,PetscInt);
393: PETSC_EXTERN PetscErrorCode EPSGDGetInitialSize(EPS,PetscInt*);
394: PETSC_EXTERN PetscErrorCode EPSGDSetBOrth(EPS,PetscBool);
395: PETSC_EXTERN PetscErrorCode EPSGDGetBOrth(EPS,PetscBool*);
396: PETSC_EXTERN PetscErrorCode EPSGDGetWindowSizes(EPS,PetscInt*,PetscInt*);
397: PETSC_EXTERN PetscErrorCode EPSGDSetWindowSizes(EPS,PetscInt,PetscInt);
398: PETSC_EXTERN PetscErrorCode EPSGDSetDoubleExpansion(EPS,PetscBool);
399: PETSC_EXTERN PetscErrorCode EPSGDGetDoubleExpansion(EPS,PetscBool*);

401: PETSC_EXTERN PetscErrorCode EPSJDSetKrylovStart(EPS,PetscBool);
402: PETSC_EXTERN PetscErrorCode EPSJDGetKrylovStart(EPS,PetscBool*);
403: PETSC_EXTERN PetscErrorCode EPSJDSetBlockSize(EPS,PetscInt);
404: PETSC_EXTERN PetscErrorCode EPSJDGetBlockSize(EPS,PetscInt*);
405: PETSC_EXTERN PetscErrorCode EPSJDSetRestart(EPS,PetscInt,PetscInt);
406: PETSC_EXTERN PetscErrorCode EPSJDGetRestart(EPS,PetscInt*,PetscInt*);
407: PETSC_EXTERN PetscErrorCode EPSJDSetInitialSize(EPS,PetscInt);
408: PETSC_EXTERN PetscErrorCode EPSJDGetInitialSize(EPS,PetscInt*);
409: PETSC_EXTERN PetscErrorCode EPSJDSetFix(EPS,PetscReal);
410: PETSC_EXTERN PetscErrorCode EPSJDGetFix(EPS,PetscReal*);
411: PETSC_EXTERN PetscErrorCode EPSJDSetConstCorrectionTol(EPS,PetscBool);
412: PETSC_EXTERN PetscErrorCode EPSJDGetConstCorrectionTol(EPS,PetscBool*);
413: PETSC_EXTERN PetscErrorCode EPSJDSetBOrth(EPS,PetscBool);
414: PETSC_EXTERN PetscErrorCode EPSJDGetBOrth(EPS,PetscBool*);
415: PETSC_EXTERN PetscErrorCode EPSJDGetWindowSizes(EPS,PetscInt*,PetscInt*);
416: PETSC_EXTERN PetscErrorCode EPSJDSetWindowSizes(EPS,PetscInt,PetscInt);

418: PETSC_EXTERN PetscErrorCode EPSRQCGSetReset(EPS,PetscInt);
419: PETSC_EXTERN PetscErrorCode EPSRQCGGetReset(EPS,PetscInt*);

421: PETSC_EXTERN PetscErrorCode EPSLOBPCGSetBlockSize(EPS,PetscInt);
422: PETSC_EXTERN PetscErrorCode EPSLOBPCGGetBlockSize(EPS,PetscInt*);
423: PETSC_EXTERN PetscErrorCode EPSLOBPCGSetRestart(EPS,PetscReal);
424: PETSC_EXTERN PetscErrorCode EPSLOBPCGGetRestart(EPS,PetscReal*);
425: PETSC_EXTERN PetscErrorCode EPSLOBPCGSetLocking(EPS,PetscBool);
426: PETSC_EXTERN PetscErrorCode EPSLOBPCGGetLocking(EPS,PetscBool*);

428: /*E
429:     EPSCISSQuadRule - determines the quadrature rule in the CISS solver

431:     Level: advanced

433: .seealso: EPSCISSSetQuadRule(), EPSCISSGetQuadRule()
434: E*/
435: typedef enum { EPS_CISS_QUADRULE_TRAPEZOIDAL=1,
436:                EPS_CISS_QUADRULE_CHEBYSHEV } EPSCISSQuadRule;
437: PETSC_EXTERN const char *EPSCISSQuadRules[];

439: /*E
440:     EPSCISSExtraction - determines the extraction technique in the CISS solver

442:     Level: advanced

444: .seealso: EPSCISSSetExtraction(), EPSCISSGetExtraction()
445: E*/
446: typedef enum { EPS_CISS_EXTRACTION_RITZ,
447:                EPS_CISS_EXTRACTION_HANKEL } EPSCISSExtraction;
448: PETSC_EXTERN const char *EPSCISSExtractions[];

450: PETSC_EXTERN PetscErrorCode EPSCISSSetExtraction(EPS,EPSCISSExtraction);
451: PETSC_EXTERN PetscErrorCode EPSCISSGetExtraction(EPS,EPSCISSExtraction*);
452: PETSC_EXTERN PetscErrorCode EPSCISSSetQuadRule(EPS,EPSCISSQuadRule);
453: PETSC_EXTERN PetscErrorCode EPSCISSGetQuadRule(EPS,EPSCISSQuadRule*);
454: PETSC_EXTERN PetscErrorCode EPSCISSSetRegion(EPS,PetscScalar,PetscReal,PetscReal);
455: PETSC_EXTERN PetscErrorCode EPSCISSGetRegion(EPS,PetscScalar*,PetscReal*,PetscReal*);
456: PETSC_EXTERN PetscErrorCode EPSCISSSetSizes(EPS,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool);
457: PETSC_EXTERN PetscErrorCode EPSCISSGetSizes(EPS,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*);
458: PETSC_EXTERN PetscErrorCode EPSCISSSetThreshold(EPS,PetscReal,PetscReal);
459: PETSC_EXTERN PetscErrorCode EPSCISSGetThreshold(EPS,PetscReal*,PetscReal*);
460: PETSC_EXTERN PetscErrorCode EPSCISSSetRefinement(EPS,PetscInt,PetscInt);
461: PETSC_EXTERN PetscErrorCode EPSCISSGetRefinement(EPS,PetscInt*,PetscInt*);
462: PETSC_EXTERN PetscErrorCode EPSCISSSetUseST(EPS,PetscBool);
463: PETSC_EXTERN PetscErrorCode EPSCISSGetUseST(EPS,PetscBool*);

465: PETSC_EXTERN PetscErrorCode EPSBLOPEXSetBlockSize(EPS,PetscInt);
466: PETSC_EXTERN PetscErrorCode EPSBLOPEXGetBlockSize(EPS,PetscInt*);

468: PETSC_EXTERN PetscErrorCode EPSFEASTSetNumPoints(EPS,PetscInt);
469: PETSC_EXTERN PetscErrorCode EPSFEASTGetNumPoints(EPS,PetscInt*);

471: #endif

slepc-3.7.4/include/slepcfn.h.html0000644000175000017500000003244513107004621016364 0ustar jromanjroman
Actual source code: slepcfn.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */

 24: #include <slepcsys.h>

 26: PETSC_EXTERN PetscErrorCode FNInitializePackage(void);
 27: /*S
 28:    FN - Abstraction of a mathematical function.

 30:    Level: beginner

 32: .seealso: FNCreate()
 33: S*/
 34: typedef struct _p_FN* FN;

 36: /*J
 37:    FNType - String with the name of the mathematical function.

 39:    Level: beginner

 41: .seealso: FNSetType(), FN
 42: J*/
 43: typedef const char* FNType;
 44: #define FNCOMBINE  "combine"
 45: #define FNRATIONAL "rational"
 46: #define FNEXP      "exp"
 47: #define FNLOG      "log"
 48: #define FNPHI      "phi"
 49: #define FNSQRT     "sqrt"
 50: #define FNINVSQRT  "invsqrt"

 52: /* Logging support */
 53: PETSC_EXTERN PetscClassId FN_CLASSID;

 55: /*E
 56:     FNCombineType - Determines how two functions are combined

 58:     Level: advanced

 60: .seealso: FNCombineSetChildren()
 61: E*/
 62: typedef enum { FN_COMBINE_ADD,
 63:                FN_COMBINE_MULTIPLY,
 64:                FN_COMBINE_DIVIDE,
 65:                FN_COMBINE_COMPOSE } FNCombineType;

 67: PETSC_EXTERN PetscErrorCode FNCreate(MPI_Comm,FN*);
 68: PETSC_EXTERN PetscErrorCode FNSetType(FN,FNType);
 69: PETSC_EXTERN PetscErrorCode FNGetType(FN,FNType*);
 70: PETSC_EXTERN PetscErrorCode FNSetOptionsPrefix(FN,const char *);
 71: PETSC_EXTERN PetscErrorCode FNAppendOptionsPrefix(FN,const char *);
 72: PETSC_EXTERN PetscErrorCode FNGetOptionsPrefix(FN,const char *[]);
 73: PETSC_EXTERN PetscErrorCode FNSetFromOptions(FN);
 74: PETSC_EXTERN PetscErrorCode FNView(FN,PetscViewer);
 75: PETSC_EXTERN PetscErrorCode FNDestroy(FN*);
 76: PETSC_EXTERN PetscErrorCode FNDuplicate(FN,MPI_Comm,FN*);

 78: PETSC_EXTERN PetscErrorCode FNSetScale(FN,PetscScalar,PetscScalar);
 79: PETSC_EXTERN PetscErrorCode FNGetScale(FN,PetscScalar*,PetscScalar*);

 81: PETSC_EXTERN PetscErrorCode FNEvaluateFunction(FN,PetscScalar,PetscScalar*);
 82: PETSC_EXTERN PetscErrorCode FNEvaluateDerivative(FN,PetscScalar,PetscScalar*);
 83: PETSC_EXTERN PetscErrorCode FNEvaluateFunctionMat(FN,Mat,Mat);
 84: PETSC_EXTERN PetscErrorCode FNEvaluateFunctionMatVec(FN,Mat,Vec);

 86: PETSC_EXTERN PetscFunctionList FNList;
 87: PETSC_EXTERN PetscErrorCode FNRegister(const char[],PetscErrorCode(*)(FN));

 89: /* --------- options specific to particular functions -------- */

 91: PETSC_EXTERN PetscErrorCode FNRationalSetNumerator(FN,PetscInt,PetscScalar*);
 92: PETSC_EXTERN PetscErrorCode FNRationalGetNumerator(FN,PetscInt*,PetscScalar**);
 93: PETSC_EXTERN PetscErrorCode FNRationalSetDenominator(FN,PetscInt,PetscScalar*);
 94: PETSC_EXTERN PetscErrorCode FNRationalGetDenominator(FN,PetscInt*,PetscScalar**);

 96: PETSC_EXTERN PetscErrorCode FNCombineSetChildren(FN,FNCombineType,FN,FN);
 97: PETSC_EXTERN PetscErrorCode FNCombineGetChildren(FN,FNCombineType*,FN*,FN*);

 99: PETSC_EXTERN PetscErrorCode FNPhiSetIndex(FN,PetscInt);
100: PETSC_EXTERN PetscErrorCode FNPhiGetIndex(FN,PetscInt*);

102: #endif
slepc-3.7.4/include/slepcblaslapack.h.html0000644000175000017500000022467613107004621020067 0ustar jromanjroman
Actual source code: slepcblaslapack.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Necessary routines in BLAS and LAPACK not included in petscblaslapack.f

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <petscblaslapack.h>

 28: /* Macros for building LAPACK names */
 29: #if defined(PETSC_BLASLAPACK_UNDERSCORE)
 30: #if defined(PETSC_USE_REAL_SINGLE)
 31: #define SLEPC_BLASLAPACKREAL(lcase,ucase) s##lcase##_
 32: #if defined(PETSC_USE_COMPLEX)
 33: #define SLEPC_BLASLAPACK(lcase,ucase) c##lcase##_
 34: #else
 35: #define SLEPC_BLASLAPACK(lcase,ucase) s##lcase##_
 36: #endif
 37: #elif defined(PETSC_USE_REAL___FLOAT128)
 38: #define SLEPC_BLASLAPACKREAL(lcase,ucase) q##lcase##_
 39: #if defined(PETSC_USE_COMPLEX)
 40: #define SLEPC_BLASLAPACK(lcase,ucase) w##lcase##_
 41: #else
 42: #define SLEPC_BLASLAPACK(lcase,ucase) q##lcase##_
 43: #endif
 44: #else
 45: #define SLEPC_BLASLAPACKREAL(lcase,ucase) d##lcase##_
 46: #if defined(PETSC_USE_COMPLEX)
 47: #define SLEPC_BLASLAPACK(lcase,ucase) z##lcase##_
 48: #else
 49: #define SLEPC_BLASLAPACK(lcase,ucase) d##lcase##_
 50: #endif
 51: #endif

 53: #elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL)
 54: #if defined(PETSC_USE_REAL_SINGLE)
 55: #define SLEPC_BLASLAPACKREAL(lcase,ucase) S##ucase
 56: #if defined(PETSC_USE_COMPLEX)
 57: #define SLEPC_BLASLAPACK(lcase,ucase) C##ucase
 58: #else
 59: #define SLEPC_BLASLAPACK(lcase,ucase) S##ucase
 60: #endif
 61: #elif defined(PETSC_USE_REAL___FLOAT128)
 62: #define SLEPC_BLASLAPACKREAL(lcase,ucase) Q##ucase
 63: #if defined(PETSC_USE_COMPLEX)
 64: #define SLEPC_BLASLAPACK(lcase,ucase) W##ucase
 65: #else
 66: #define SLEPC_BLASLAPACK(lcase,ucase) Q##ucase
 67: #endif
 68: #else
 69: #define SLEPC_BLASLAPACKREAL(lcase,ucase) D##ucase
 70: #if defined(PETSC_USE_COMPLEX)
 71: #define SLEPC_BLASLAPACK(lcase,ucase) Z##ucase
 72: #else
 73: #define SLEPC_BLASLAPACK(lcase,ucase) D##ucase
 74: #endif
 75: #endif

 77: #else
 78: #if defined(PETSC_USE_REAL_SINGLE)
 79: #define SLEPC_BLASLAPACKREAL(lcase,ucase) s##lcase
 80: #if defined(PETSC_USE_COMPLEX)
 81: #define SLEPC_BLASLAPACK(lcase,ucase) c##lcase
 82: #else
 83: #define SLEPC_BLASLAPACK(lcase,ucase) s##lcase
 84: #endif
 85: #elif defined(PETSC_USE_REAL___FLOAT128)
 86: #define SLEPC_BLASLAPACKREAL(lcase,ucase) q##lcase
 87: #if defined(PETSC_USE_COMPLEX)
 88: #define SLEPC_BLASLAPACK(lcase,ucase) w##lcase
 89: #else
 90: #define SLEPC_BLASLAPACK(lcase,ucase) q##lcase
 91: #endif
 92: #else
 93: #define SLEPC_BLASLAPACKREAL(lcase,ucase) d##lcase
 94: #if defined(PETSC_USE_COMPLEX)
 95: #define SLEPC_BLASLAPACK(lcase,ucase) z##lcase
 96: #else
 97: #define SLEPC_BLASLAPACK(lcase,ucase) d##lcase
 98: #endif
 99: #endif

101: #endif

103: /* LAPACK return type: we assume slange, etc. behave in the same way as snrm2 */
104: #if defined(PETSC_USE_REAL_SINGLE) && defined(PETSC_BLASLAPACK_SNRM2_RETURNS_DOUBLE)
105: #define SlepcLRT double
106: #else
107: #define SlepcLRT PetscReal
108: #endif

110: /* LAPACK functions without string parameters */
111: #define LAPACKlaev2_ SLEPC_BLASLAPACK(laev2,LAEV2)
112: #define LAPACKgehrd_ SLEPC_BLASLAPACK(gehrd,GEHRD)
113: #define LAPACKgelqf_ SLEPC_BLASLAPACK(gelqf,GELQF)
114: #define LAPACKgeqp3_ SLEPC_BLASLAPACK(geqp3,GEQP3)
115: #define LAPACKtgexc_ SLEPC_BLASLAPACK(tgexc,TGEXC)
116: #define LAPACKlarfg_ SLEPC_BLASLAPACK(larfg,LARFG)
117: #define LAPACKlag2_  SLEPC_BLASLAPACKREAL(lag2,LAG2)
118: #define LAPACKlasv2_ SLEPC_BLASLAPACKREAL(lasv2,LASV2)
119: #define LAPACKlartg_ SLEPC_BLASLAPACKREAL(lartg,LARTG)
120: #define LAPACKlaln2_ SLEPC_BLASLAPACKREAL(laln2,LALN2)
121: #define LAPACKlaed4_ SLEPC_BLASLAPACKREAL(laed4,LAED4)
122: #define LAPACKlamrg_ SLEPC_BLASLAPACKREAL(lamrg,LAMRG)
123: #define LAPACKlapy2_ SLEPC_BLASLAPACKREAL(lapy2,LAPY2)
124: #if !defined(PETSC_USE_COMPLEX)
125: #define LAPACKorghr_ SLEPC_BLASLAPACK(orghr,ORGHR)
126: #else
127: #define LAPACKorghr_ SLEPC_BLASLAPACK(unghr,UNGHR)
128: #endif
129: /* the next one needs a special treatment due to the special names:
130:    srot, drot, csrot, zdrot */
131: #if !defined(PETSC_USE_COMPLEX)
132: #define BLASrot_     SLEPC_BLASLAPACK(rot,ROT)
133: #else
134: #if defined(PETSC_USE_REAL_SINGLE)
135: #define BLASrot_     SLEPC_BLASLAPACK(srot,SROT)
136: #elif defined(PETSC_USE_REAL___FLOAT128)
137: #define BLASrot_     SLEPC_BLASLAPACK(qrot,QROT)
138: #else
139: #define BLASrot_     SLEPC_BLASLAPACK(drot,DROT)
140: #endif
141: #endif

143: /* LAPACK functions with string parameters */
144: #if !defined(PETSC_BLASLAPACK_STDCALL)

146: /* same name for real and complex */
147: #define LAPACKlanhs_(a,b,c,d,e) SLEPC_BLASLAPACK(lanhs,LANHS) ((a),(b),(c),(d),(e),1)
148: #define LAPACKlange_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lange,LANGE) ((a),(b),(c),(d),(e),(f),1)
149: #define LAPACKggevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac) SLEPC_BLASLAPACK(ggevx,GGEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),(z),(aa),(ab),(ac),1,1,1,1)
150: #define LAPACKggev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(ggev,GGEV) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,1)
151: #define LAPACKpbtrf_(a,b,c,d,e,f) SLEPC_BLASLAPACK(pbtrf,PBTRF) ((a),(b),(c),(d),(e),(f),1)
152: #define LAPACKlarf_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(larf,LARF) ((a),(b),(c),(d),(e),(f),(g),(h),(i),1)
153: #define BLAStrmm_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(trmm,TRMM) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),1,1,1,1)
154: #define LAPACKlacpy_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(lacpy,LACPY) ((a),(b),(c),(d),(e),(f),(g),1)
155: #define LAPACKlascl_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(lascl,LASCL) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1)
156: #define LAPACKlansy_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lansy,LANSY) ((a),(b),(c),(d),(e),(f),1,1)
157: #define LAPACKlaset_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(laset,LASET) ((a),(b),(c),(d),(e),(f),(g),1)
158: #define LAPACKtrsyl_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(trsyl,TRSYL) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1)
159: #define LAPACKtrtri_(a,b,c,d,e,f) SLEPC_BLASLAPACK(trtri,TRTRI) ((a),(b),(c),(d),(e),(f),1,1)
160: /* subroutines in which we use only the real version, do not care whether they have different name */
161: #define LAPACKstevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) SLEPC_BLASLAPACKREAL(stevr,STEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),1,1)
162: #define LAPACKbdsdc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1)
163: #define LAPACKlamch_(a) SLEPC_BLASLAPACKREAL(lamch,LAMCH) ((a),1)
164: #define LAPACKlamc3_(a,b) SLEPC_BLASLAPACKREAL(lamc3,LAMC3) ((a),(b))

166: #if !defined(PETSC_USE_COMPLEX)
167: /* different name or signature, real */
168: #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) SLEPC_BLASLAPACK(syevr,SYEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),1,1,1)
169: #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(syevd,SYEVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),1,1)
170: #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n)  SLEPC_BLASLAPACK(sygvd,SYGVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1)
171: #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(ormlq,ORMLQ) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1)
172: #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(orgtr,ORGTR) ((a),(b),(c),(d),(e),(f),(g),(h),1)
173: #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(sytrd,SYTRD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1)
174: #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(trevc,TREVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1)
175: #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,1,1)
176: #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1,1)
177: #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(trexc,TREXC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1)
178: #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1)
179: #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,1)
180: #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),1,1,1)
181: #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(stedc,STEDC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),1)
182: #else
183: /* different name or signature, complex */
184: #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(heevr,HEEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,1)
185: #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(heevd,HEEVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1)
186: #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(hegvd,HEGVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,1)
187: #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(unmlq,UNMLQ) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1)
188: #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(ungtr,UNGTR) ((a),(b),(c),(d),(e),(f),(g),(h),1)
189: #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(hetrd,HETRD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1)
190: #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(trevc,TREVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1,1)
191: #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),1,1,1,1)
192: #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1,1)
193: #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(trexc,TREXC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),1)
194: #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1)
195: #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,1)
196: #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),1,1,1)
197: #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(stedc,STEDC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1)
198: #endif

200: #else /* PETSC_BLASLAPACK_STDCALL */

202: /* same name for real and complex */
203: #define LAPACKlanhs_(a,b,c,d,e) SLEPC_BLASLAPACK(lanhs,LANHS) ((a),1,(b),(c),(d),(e))
204: #define LAPACKlange_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lange,LANGE) ((a),1,(b),(c),(d),(e),(f))
205: #define LAPACKggevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac) SLEPC_BLASLAPACK(ggevx,GGEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),(z),(aa),(ab),(ac))
206: #define LAPACKggev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(ggev,GGEV) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q))
207: #define LAPACKpbtrf_(a,b,c,d,e,f) SLEPC_BLASLAPACK(pbtrf,PBTRF) ((a),1,(b),(c),(d),(e),(f))
208: #define LAPACKlarf_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(larf,LARF) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i))
209: #define BLAStrmm_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(trmm,TRMM) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k))
210: #define LAPACKlacpy_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(lacpy,LACPY) ((a),1,(b),(c),(d),(e),(f),(g))
211: #define LAPACKlascl_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(lascl,LASCL) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j))
212: #define LAPACKlansy_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lansy,LANSY) ((a),1,(b),1,(c),(d),(e),(f))
213: #define LAPACKlaset_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(laset,LASET) ((a),1,(b),(c),(d),(e),(f),(g))
214: #define LAPACKtrsyl_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(trsyl,TRSYL) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
215: #define LAPACKtrtri_(a,b,c,d,e,f) SLEPC_BLASLAPACK(trtri,TRTRI) ((a),1,(b),1,(c),(d),(e),(f))
216: /* subroutines in which we use only the real version, do not care whether they have different name */
217: #define LAPACKstevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) SLEPC_BLASLAPACKREAL(stevr,STEVR) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t))
218: #define LAPACKbdsdc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n))
219: #define LAPACKlamch_(a) SLEPC_BLASLAPACKREAL(lamch,LAMCH) ((a),1)
220: #define LAPACKlamc3_(a,b) SLEPC_BLASLAPACKREAL(lamc3,LAMC3) ((a),(b))

222: #if !defined(PETSC_USE_COMPLEX)
223: /* different name or signature, real */
224: #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) SLEPC_BLASLAPACK(syevr,SYEVR) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u))
225: #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(syevd,SYEVD) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k))
226: #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n)  SLEPC_BLASLAPACK(sygvd,SYGVD) ((a),(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n))
227: #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(ormlq,ORMLQ) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
228: #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(orgtr,ORGTR) ((a),1,(b),(c),(d),(e),(f),(g),(h))
229: #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(sytrd,SYTRD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j))
230: #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(trevc,TREVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n))
231: #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w))
232: #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o))
233: #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(trexc,TREXC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j))
234: #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n))
235: #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p))
236: #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s))
237: #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(stedc,STEDC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k))
238: #else
239: /* different name or signature, complex */
240: #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(heevr,HEEVR) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w))
241: #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(heevd,HEEVD) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
242: #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(hegvd,HEGVD) ((a),(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p))
243: #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(unmlq,UNMLQ) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
244: #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(ungtr,UNGTR) ((a),1,(b),(c),(d),(e),(f),(g),(h))
245: #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(hetrd,HETRD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j))
246: #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(trevc,TREVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o))
247: #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v))
248: #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o))
249: #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(trexc,TREXC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i))
250: #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o))
251: #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q))
252: #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s))
253: #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(stedc,STEDC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m))
254: #endif

256: #endif

258: #if !defined(PETSC_BLASLAPACK_STDCALL)

260: /* LAPACK functions without string parameters */
261: PETSC_EXTERN void      SLEPC_BLASLAPACK(laev2,LAEV2) (PetscScalar*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*);
262: PETSC_EXTERN void      SLEPC_BLASLAPACK(gehrd,GEHRD) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
263: PETSC_EXTERN void      SLEPC_BLASLAPACK(gelqf,GELQF) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
264: PETSC_EXTERN void      SLEPC_BLASLAPACK(larfg,LARFG) (PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*);
265: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(lag2,LAG2) (PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
266: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(lasv2,LASV2) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
267: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(lartg,LARTG) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
268: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(laln2,LALN2) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*);
269: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(laed4,LAED4) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*);
270: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(lamrg,LAMRG) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
271: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACKREAL(lapy2,LAPY2) (PetscReal*,PetscReal*);
272: PETSC_EXTERN void      BLASrot_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*);
273: #if !defined(PETSC_USE_COMPLEX)
274: PETSC_EXTERN void      SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
275: PETSC_EXTERN void      SLEPC_BLASLAPACK(orghr,ORGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
276: PETSC_EXTERN void      SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
277: #else
278: PETSC_EXTERN void      SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
279: PETSC_EXTERN void      SLEPC_BLASLAPACK(unghr,UNGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
280: PETSC_EXTERN void      SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
281: #endif

283: /* LAPACK functions with string parameters */
284: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACK(lanhs,LANHS) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt);
285: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACK(lange,LANGE) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt);
286: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACK(pbtrf,PBTRF) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
287: PETSC_EXTERN void      SLEPC_BLASLAPACK(larf,LARF) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt);
288: PETSC_EXTERN void      SLEPC_BLASLAPACK(trmm,TRMM) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt);
289: PETSC_EXTERN void      SLEPC_BLASLAPACK(lacpy,LACPY) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt);
290: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACK(lansy,LANSY) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt,PetscBLASInt);
291: PETSC_EXTERN void      SLEPC_BLASLAPACK(laset,LASET) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt);
292: PETSC_EXTERN void      SLEPC_BLASLAPACK(trsyl,TRSYL) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
293: PETSC_EXTERN void      SLEPC_BLASLAPACK(trtri,TRTRI) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);

295: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(stevr,STEVR) (const char*,const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
296: PETSC_EXTERN void      SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) (const char*,const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
297: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACKREAL(lamch,LAMCH) (const char*,PetscBLASInt);
298: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACKREAL(lamc3,LAMC3) (PetscReal*,PetscReal*);

300: #if !defined(PETSC_USE_COMPLEX)
301: PETSC_EXTERN void      SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt);
302: PETSC_EXTERN void      SLEPC_BLASLAPACK(ggev,GGEV) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
303: PETSC_EXTERN void      SLEPC_BLASLAPACK(syevr,SYEVR) (const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt);
304: PETSC_EXTERN void      SLEPC_BLASLAPACK(syevd,SYEVD) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
305: PETSC_EXTERN void      SLEPC_BLASLAPACK(sygvd,SYGVD) (PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
306: PETSC_EXTERN void      SLEPC_BLASLAPACK(ormlq,ORMLQ) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
307: PETSC_EXTERN void      SLEPC_BLASLAPACK(orgtr,ORGTR) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
308: PETSC_EXTERN void      SLEPC_BLASLAPACK(sytrd,SYTRD) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
309: PETSC_EXTERN void      SLEPC_BLASLAPACK(trevc,TREVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
310: PETSC_EXTERN void      SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt);
311: PETSC_EXTERN void      SLEPC_BLASLAPACK(gees,GEES) (const char*,const char*,PetscBLASInt(*)(PetscReal,PetscReal),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
312: PETSC_EXTERN void      SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt);
313: PETSC_EXTERN void      SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
314: PETSC_EXTERN void      SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
315: PETSC_EXTERN void      SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt);
316: PETSC_EXTERN void      SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
317: PETSC_EXTERN void      SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
318: #else
319: PETSC_EXTERN void      SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*, PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt);
320: PETSC_EXTERN void      SLEPC_BLASLAPACK(ggev,GGEV) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
321: PETSC_EXTERN void      SLEPC_BLASLAPACK(heevr,HEEVR) (const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt);
322: PETSC_EXTERN void      SLEPC_BLASLAPACK(heevd,HEEVD) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
323: PETSC_EXTERN void      SLEPC_BLASLAPACK(hegvd,HEGVD) (PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
324: PETSC_EXTERN void      SLEPC_BLASLAPACK(unmlq,UNMLQ) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
325: PETSC_EXTERN void      SLEPC_BLASLAPACK(ungtr,UNGTR) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
326: PETSC_EXTERN void      SLEPC_BLASLAPACK(hetrd,HETRD) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
327: PETSC_EXTERN void      SLEPC_BLASLAPACK(trevc,TREVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
328: PETSC_EXTERN void      SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt);
329: PETSC_EXTERN void      SLEPC_BLASLAPACK(gees,GEES) (const char*,const char*,PetscBLASInt(*)(PetscScalar),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
330: PETSC_EXTERN void      SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
331: PETSC_EXTERN void      SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
332: PETSC_EXTERN void      SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt);
333: PETSC_EXTERN void      SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt);
334: PETSC_EXTERN void      SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
335: PETSC_EXTERN void      SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt);
336: #endif

338: #else /* PETSC_BLASLAPACK_STDCALL */

340: /* LAPACK functions without string parameters */
341: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(laev2,LAEV2) (PetscScalar*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*);
342: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gehrd,GEHRD) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
343: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gelqf,GELQF) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
344: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(larfg,LARFG) (PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*);
345: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lag2,LAG2) (PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
346: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lasv2,LASV2) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
347: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lartg,LARTG) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);
348: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(laln2,LALN2) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*);
349: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(laed4,LAED4) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*);
350: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lamrg,LAMRG) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
351: PETSC_EXTERN SlepcLRT  PETSC_STDCALL SLEPC_BLASLAPACKREAL(lapy2,LAPY2) (PetscReal*,PetscReal*);
352: PETSC_EXTERN void PETSC_STDCALL BLASrot_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*);
353: #if !defined(PETSC_USE_COMPLEX)
354: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
355: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(orghr,ORGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
356: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
357: #else
358: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
359: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(unghr,UNGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
360: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
361: #endif

363: /* LAPACK functions with string parameters */
364: PETSC_EXTERN SlepcLRT  PETSC_STDCALL SLEPC_BLASLAPACK(lanhs,LANHS) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*);
365: PETSC_EXTERN SlepcLRT  PETSC_STDCALL SLEPC_BLASLAPACK(lange,LANGE) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*);
366: PETSC_EXTERN SlepcLRT  PETSC_STDCALL SLEPC_BLASLAPACK(pbtrf,PBTRF) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
367: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(larf,LARF) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*);
368: PETSC_EXTERN void      SLEPC_BLASLAPACK(trmm,TRMM) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*);
369: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(lacpy,LACPY) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*);
370: PETSC_EXTERN SlepcLRT  PETSC_STDCALL SLEPC_BLASLAPACK(lansy,LANSY) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*);
371: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(laset,LASET) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*);
372: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trsyl,TRSYL) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
373: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trtri,TRTRI) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);

375: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(stevr,STEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
376: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*);
377: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACKREAL(lamch,LAMCH) (const char*,PetscBLASInt);
378: PETSC_EXTERN SlepcLRT  SLEPC_BLASLAPACKREAL(lamc3,LAMC3) (PetscReal*,PetscReal*);

380: #if !defined(PETSC_USE_COMPLEX)
381: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
382: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggev,GGEV) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
383: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(syevr,SYEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
384: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(syevd,SYEVD) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
385: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(sygvd,SYGVD) (PetscBLASInt*,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
386: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ormlq,ORMLQ) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
387: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(orgtr,ORGTR) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
388: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(sytrd,SYTRD) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
389: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trevc,TREVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*);
390: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
391: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gees,GEES) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt(*)(PetscReal,PetscReal),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
392: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*);
393: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
394: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*);
395: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
396: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
397: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
398: #else
399: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*, PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
400: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggev,GGEV) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
401: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(heevr,HEEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
402: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(heevd,HEEVD) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
403: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hegvd,HEGVD) (PetscBLASInt*,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
404: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(unmlq,UNMLQ) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
405: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ungtr,UNGTR) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
406: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hetrd,HETRD) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
407: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trevc,TREVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*);
408: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);
409: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gees,GEES) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt(*)(PetscScalar),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*);
410: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
411: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*);
412: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*);
413: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
414: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*);
415: PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*);
416: #endif

418: #endif

420: #endif
slepc-3.7.4/include/slepcversion.h0000644000175000017500000000270613107004621016500 0ustar jromanjroman#if !defined(__SLEPCVERSION_H) #define __SLEPCVERSION_H #define SLEPC_VERSION_RELEASE 1 #define SLEPC_VERSION_MAJOR 3 #define SLEPC_VERSION_MINOR 7 #define SLEPC_VERSION_SUBMINOR 4 #define SLEPC_VERSION_PATCH 0 #define SLEPC_RELEASE_DATE "May 16, 2016" #define SLEPC_VERSION_DATE "May 17, 2017" #if !defined (SLEPC_VERSION_GIT) #define SLEPC_VERSION_GIT "v3.7.4" #endif #if !defined(SLEPC_VERSION_DATE_GIT) #define SLEPC_VERSION_DATE_GIT "2017-05-17 10:18:48 +0200" #endif #define SLEPC_VERSION_(MAJOR,MINOR,SUBMINOR) \ ((SLEPC_VERSION_MAJOR == (MAJOR)) && \ (SLEPC_VERSION_MINOR == (MINOR)) && \ (SLEPC_VERSION_SUBMINOR == (SUBMINOR)) && \ (SLEPC_VERSION_RELEASE == 1)) #define SLEPC_VERSION_LT(MAJOR,MINOR,SUBMINOR) \ (SLEPC_VERSION_RELEASE == 1 && \ (SLEPC_VERSION_MAJOR < (MAJOR) || \ (SLEPC_VERSION_MAJOR == (MAJOR) && \ (SLEPC_VERSION_MINOR < (MINOR) || \ (SLEPC_VERSION_MINOR == (MINOR) && \ (SLEPC_VERSION_SUBMINOR < (SUBMINOR))))))) #define SLEPC_VERSION_LE(MAJOR,MINOR,SUBMINOR) \ (SLEPC_VERSION_LT(MAJOR,MINOR,SUBMINOR) || \ SLEPC_VERSION_(MAJOR,MINOR,SUBMINOR)) #define SLEPC_VERSION_GT(MAJOR,MINOR,SUBMINOR) \ (0 == SLEPC_VERSION_LE(MAJOR,MINOR,SUBMINOR)) #define SLEPC_VERSION_GE(MAJOR,MINOR,SUBMINOR) \ (0 == SLEPC_VERSION_LT(MAJOR,MINOR,SUBMINOR)) #endif slepc-3.7.4/include/slepcnep.h.html0000644000175000017500000014473713107004621016553 0ustar jromanjroman
Actual source code: slepcnep.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    User interface for SLEPc's nonlinear eigenvalue solvers.

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <slepceps.h>
 27: #include <slepcpep.h>
 28: #include <slepcfn.h>

 30: PETSC_EXTERN PetscErrorCode NEPInitializePackage(void);

 32: /*S
 33:      NEP - Abstract SLEPc object that manages all solvers for
 34:      nonlinear eigenvalue problems.

 36:    Level: beginner

 38: .seealso:  NEPCreate()
 39: S*/
 40: typedef struct _p_NEP* NEP;

 42: /*J
 43:     NEPType - String with the name of a nonlinear eigensolver

 45:    Level: beginner

 47: .seealso: NEPSetType(), NEP
 48: J*/
 49: typedef const char* NEPType;
 50: #define NEPRII       "rii"
 51: #define NEPSLP       "slp"
 52: #define NEPNARNOLDI  "narnoldi"
 53: #define NEPCISS      "ciss"
 54: #define NEPINTERPOL  "interpol"
 55: #define NEPNLEIGS    "nleigs"

 57: /* Logging support */
 58: PETSC_EXTERN PetscClassId NEP_CLASSID;

 60: /*E
 61:     NEPWhich - Determines which part of the spectrum is requested

 63:     Level: intermediate

 65: .seealso: NEPSetWhichEigenpairs(), NEPGetWhichEigenpairs()
 66: E*/
 67: typedef enum { NEP_LARGEST_MAGNITUDE=1,
 68:                NEP_SMALLEST_MAGNITUDE,
 69:                NEP_LARGEST_REAL,
 70:                NEP_SMALLEST_REAL,
 71:                NEP_LARGEST_IMAGINARY,
 72:                NEP_SMALLEST_IMAGINARY,
 73:                NEP_TARGET_MAGNITUDE,
 74:                NEP_TARGET_REAL,
 75:                NEP_TARGET_IMAGINARY,
 76:                NEP_ALL,
 77:                NEP_WHICH_USER } NEPWhich;

 79: /*E
 80:     NEPErrorType - The error type used to assess accuracy of computed solutions

 82:     Level: intermediate

 84: .seealso: NEPComputeError()
 85: E*/
 86: typedef enum { NEP_ERROR_ABSOLUTE,
 87:                NEP_ERROR_RELATIVE,
 88:                NEP_ERROR_BACKWARD } NEPErrorType;
 89: PETSC_EXTERN const char *NEPErrorTypes[];

 91: /*E
 92:     NEPRefine - The refinement type

 94:     Level: intermediate

 96: .seealso: NEPSetRefine()
 97: E*/
 98: typedef enum { NEP_REFINE_NONE,
 99:                NEP_REFINE_SIMPLE,
100:                NEP_REFINE_MULTIPLE } NEPRefine;
101: PETSC_EXTERN const char *NEPRefineTypes[];

103: /*E
104:     NEPRefineScheme - The scheme used for solving linear systems during iterative refinement

106:     Level: intermediate

108: .seealso: NEPSetRefine()
109: E*/
110: typedef enum { NEP_REFINE_SCHEME_SCHUR=1,
111:                NEP_REFINE_SCHEME_MBE,
112:                NEP_REFINE_SCHEME_EXPLICIT } NEPRefineScheme;
113: PETSC_EXTERN const char *NEPRefineSchemes[];

115: /*E
116:     NEPConv - Determines the convergence test

118:     Level: intermediate

120: .seealso: NEPSetConvergenceTest(), NEPSetConvergenceTestFunction()
121: E*/
122: typedef enum { NEP_CONV_ABS,
123:                NEP_CONV_REL,
124:                NEP_CONV_NORM,
125:                NEP_CONV_USER } NEPConv;

127: /*E
128:     NEPStop - Determines the stopping test

130:     Level: advanced

132: .seealso: NEPSetStoppingTest(), NEPSetStoppingTestFunction()
133: E*/
134: typedef enum { NEP_STOP_BASIC,
135:                NEP_STOP_USER } NEPStop;

137: /*E
138:     NEPConvergedReason - Reason a nonlinear eigensolver was said to
139:          have converged or diverged

141:     Level: intermediate

143: .seealso: NEPSolve(), NEPGetConvergedReason(), NEPSetTolerances()
144: E*/
145: typedef enum {/* converged */
146:               NEP_CONVERGED_TOL                =  1,
147:               NEP_CONVERGED_USER               =  2,
148:               /* diverged */
149:               NEP_DIVERGED_ITS                 = -1,
150:               NEP_DIVERGED_BREAKDOWN           = -2,
151:                     /* unused                  = -3 */
152:               NEP_DIVERGED_LINEAR_SOLVE        = -4,
153:               NEP_CONVERGED_ITERATING          =  0} NEPConvergedReason;
154: PETSC_EXTERN const char *const*NEPConvergedReasons;

156: PETSC_EXTERN PetscErrorCode NEPCreate(MPI_Comm,NEP*);
157: PETSC_EXTERN PetscErrorCode NEPDestroy(NEP*);
158: PETSC_EXTERN PetscErrorCode NEPReset(NEP);
159: PETSC_EXTERN PetscErrorCode NEPSetType(NEP,NEPType);
160: PETSC_EXTERN PetscErrorCode NEPGetType(NEP,NEPType*);
161: PETSC_EXTERN PetscErrorCode NEPSetTarget(NEP,PetscScalar);
162: PETSC_EXTERN PetscErrorCode NEPGetTarget(NEP,PetscScalar*);
163: PETSC_EXTERN PetscErrorCode NEPSetFromOptions(NEP);
164: PETSC_EXTERN PetscErrorCode NEPSetUp(NEP);
165: PETSC_EXTERN PetscErrorCode NEPSolve(NEP);
166: PETSC_EXTERN PetscErrorCode NEPView(NEP,PetscViewer);
167: PETSC_STATIC_INLINE PetscErrorCode NEPViewFromOptions(NEP nep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)nep,obj,name);}
168: PETSC_EXTERN PetscErrorCode NEPErrorView(NEP,NEPErrorType,PetscViewer);
169: PETSC_EXTERN PetscErrorCode NEPErrorViewFromOptions(NEP);
170: PETSC_EXTERN PetscErrorCode NEPReasonView(NEP,PetscViewer);
171: PETSC_EXTERN PetscErrorCode NEPReasonViewFromOptions(NEP);
172: PETSC_EXTERN PetscErrorCode NEPValuesView(NEP,PetscViewer);
173: PETSC_EXTERN PetscErrorCode NEPValuesViewFromOptions(NEP);
174: PETSC_EXTERN PetscErrorCode NEPVectorsView(NEP,PetscViewer);
175: PETSC_EXTERN PetscErrorCode NEPVectorsViewFromOptions(NEP);

177: PETSC_EXTERN PetscErrorCode NEPSetFunction(NEP,Mat,Mat,PetscErrorCode (*)(NEP,PetscScalar,Mat,Mat,void*),void*);
178: PETSC_EXTERN PetscErrorCode NEPGetFunction(NEP,Mat*,Mat*,PetscErrorCode (**)(NEP,PetscScalar,Mat,Mat,void*),void**);
179: PETSC_EXTERN PetscErrorCode NEPSetJacobian(NEP,Mat,PetscErrorCode (*)(NEP,PetscScalar,Mat,void*),void*);
180: PETSC_EXTERN PetscErrorCode NEPGetJacobian(NEP,Mat*,PetscErrorCode (**)(NEP,PetscScalar,Mat,void*),void**);
181: PETSC_EXTERN PetscErrorCode NEPSetDerivatives(NEP,Mat,PetscErrorCode (*)(NEP,PetscScalar,PetscInt,Mat,void*),void*);
182: PETSC_EXTERN PetscErrorCode NEPGetDerivatives(NEP,Mat*,PetscErrorCode (**)(NEP,PetscScalar,PetscInt,Mat,void*),void**);
183: PETSC_EXTERN PetscErrorCode NEPSetSplitOperator(NEP,PetscInt,Mat*,FN*,MatStructure);
184: PETSC_EXTERN PetscErrorCode NEPGetSplitOperatorTerm(NEP,PetscInt,Mat*,FN*);
185: PETSC_EXTERN PetscErrorCode NEPGetSplitOperatorInfo(NEP,PetscInt*,MatStructure*);

187: PETSC_EXTERN PetscErrorCode NEPSetBV(NEP,BV);
188: PETSC_EXTERN PetscErrorCode NEPGetBV(NEP,BV*);
189: PETSC_EXTERN PetscErrorCode NEPSetRG(NEP,RG);
190: PETSC_EXTERN PetscErrorCode NEPGetRG(NEP,RG*);
191: PETSC_EXTERN PetscErrorCode NEPSetDS(NEP,DS);
192: PETSC_EXTERN PetscErrorCode NEPGetDS(NEP,DS*);
193: PETSC_EXTERN PetscErrorCode NEPRefineGetKSP(NEP,KSP*);
194: PETSC_EXTERN PetscErrorCode NEPSetTolerances(NEP,PetscReal,PetscInt);
195: PETSC_EXTERN PetscErrorCode NEPGetTolerances(NEP,PetscReal*,PetscInt*);
196: PETSC_EXTERN PetscErrorCode NEPSetConvergenceTestFunction(NEP,PetscErrorCode (*)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*));
197: PETSC_EXTERN PetscErrorCode NEPSetConvergenceTest(NEP,NEPConv);
198: PETSC_EXTERN PetscErrorCode NEPGetConvergenceTest(NEP,NEPConv*);
199: PETSC_EXTERN PetscErrorCode NEPConvergedAbsolute(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
200: PETSC_EXTERN PetscErrorCode NEPConvergedRelative(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
201: PETSC_EXTERN PetscErrorCode NEPConvergedNorm(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
202: PETSC_EXTERN PetscErrorCode NEPSetStoppingTestFunction(NEP,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void*,PetscErrorCode (*)(void*));
203: PETSC_EXTERN PetscErrorCode NEPSetStoppingTest(NEP,NEPStop);
204: PETSC_EXTERN PetscErrorCode NEPGetStoppingTest(NEP,NEPStop*);
205: PETSC_EXTERN PetscErrorCode NEPStoppingBasic(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*);
206: PETSC_EXTERN PetscErrorCode NEPSetDimensions(NEP,PetscInt,PetscInt,PetscInt);
207: PETSC_EXTERN PetscErrorCode NEPGetDimensions(NEP,PetscInt*,PetscInt*,PetscInt*);
208: PETSC_EXTERN PetscErrorCode NEPSetRefine(NEP,NEPRefine,PetscInt,PetscReal,PetscInt,NEPRefineScheme);
209: PETSC_EXTERN PetscErrorCode NEPGetRefine(NEP,NEPRefine*,PetscInt*,PetscReal*,PetscInt*,NEPRefineScheme*);

211: PETSC_EXTERN PetscErrorCode NEPGetConverged(NEP,PetscInt*);
212: PETSC_EXTERN PetscErrorCode NEPGetEigenpair(NEP,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec);

214: PETSC_EXTERN PetscErrorCode NEPComputeError(NEP,PetscInt,NEPErrorType,PetscReal*);
215: PETSC_DEPRECATED("Use NEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode NEPComputeRelativeError(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_RELATIVE,r);}
216: PETSC_DEPRECATED("Use NEPComputeError() with NEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode NEPComputeResidualNorm(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_ABSOLUTE,r);}
217: PETSC_EXTERN PetscErrorCode NEPGetErrorEstimate(NEP,PetscInt,PetscReal*);

219: PETSC_EXTERN PetscErrorCode NEPComputeFunction(NEP,PetscScalar,Mat,Mat);
220: PETSC_EXTERN PetscErrorCode NEPComputeJacobian(NEP,PetscScalar,Mat);
221: PETSC_EXTERN PetscErrorCode NEPApplyFunction(NEP,PetscScalar,Vec,Vec,Vec,Mat,Mat);
222: PETSC_EXTERN PetscErrorCode NEPApplyJacobian(NEP,PetscScalar,Vec,Vec,Vec,Mat);
223: PETSC_EXTERN PetscErrorCode NEPProjectOperator(NEP,PetscInt,PetscInt);

225: PETSC_EXTERN PetscErrorCode NEPMonitor(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt);
226: PETSC_EXTERN PetscErrorCode NEPMonitorSet(NEP,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**));
227: PETSC_EXTERN PetscErrorCode NEPMonitorSetFromOptions(NEP,const char*,const char*,const char*,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool);
228: PETSC_EXTERN PetscErrorCode NEPConvMonitorSetFromOptions(NEP,const char*,const char*,const char*,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor));
229: PETSC_EXTERN PetscErrorCode NEPMonitorCancel(NEP);
230: PETSC_EXTERN PetscErrorCode NEPGetMonitorContext(NEP,void **);
231: PETSC_EXTERN PetscErrorCode NEPGetIterationNumber(NEP,PetscInt*);

233: PETSC_EXTERN PetscErrorCode NEPSetInitialSpace(NEP,PetscInt,Vec*);
234: PETSC_EXTERN PetscErrorCode NEPSetWhichEigenpairs(NEP,NEPWhich);
235: PETSC_EXTERN PetscErrorCode NEPGetWhichEigenpairs(NEP,NEPWhich*);
236: PETSC_EXTERN PetscErrorCode NEPSetEigenvalueComparison(NEP,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*);

238: PETSC_EXTERN PetscErrorCode NEPMonitorAll(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*);
239: PETSC_EXTERN PetscErrorCode NEPMonitorFirst(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*);
240: PETSC_EXTERN PetscErrorCode NEPMonitorConverged(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor);
241: PETSC_EXTERN PetscErrorCode NEPMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*);
242: PETSC_EXTERN PetscErrorCode NEPMonitorLG(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
243: PETSC_EXTERN PetscErrorCode NEPMonitorLGAll(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);

245: PETSC_EXTERN PetscErrorCode NEPSetTrackAll(NEP,PetscBool);
246: PETSC_EXTERN PetscErrorCode NEPGetTrackAll(NEP,PetscBool*);

248: PETSC_EXTERN PetscErrorCode NEPSetOptionsPrefix(NEP,const char*);
249: PETSC_EXTERN PetscErrorCode NEPAppendOptionsPrefix(NEP,const char*);
250: PETSC_EXTERN PetscErrorCode NEPGetOptionsPrefix(NEP,const char*[]);

252: PETSC_EXTERN PetscErrorCode NEPGetConvergedReason(NEP,NEPConvergedReason *);

254: PETSC_EXTERN PetscFunctionList NEPList;
255: PETSC_EXTERN PetscErrorCode NEPRegister(const char[],PetscErrorCode(*)(NEP));

257: PETSC_EXTERN PetscErrorCode NEPSetWorkVecs(NEP,PetscInt);
258: PETSC_EXTERN PetscErrorCode NEPAllocateSolution(NEP,PetscInt);

260: /* --------- options specific to particular eigensolvers -------- */

262: PETSC_EXTERN PetscErrorCode NEPRIISetMaximumIterations(NEP,PetscInt);
263: PETSC_EXTERN PetscErrorCode NEPRIIGetMaximumIterations(NEP,PetscInt*);
264: PETSC_EXTERN PetscErrorCode NEPRIISetLagPreconditioner(NEP,PetscInt);
265: PETSC_EXTERN PetscErrorCode NEPRIIGetLagPreconditioner(NEP,PetscInt*);
266: PETSC_EXTERN PetscErrorCode NEPRIISetConstCorrectionTol(NEP,PetscBool);
267: PETSC_EXTERN PetscErrorCode NEPRIIGetConstCorrectionTol(NEP,PetscBool*);
268: PETSC_EXTERN PetscErrorCode NEPRIISetKSP(NEP,KSP);
269: PETSC_EXTERN PetscErrorCode NEPRIIGetKSP(NEP,KSP*);

271: PETSC_EXTERN PetscErrorCode NEPSLPSetEPS(NEP,EPS);
272: PETSC_EXTERN PetscErrorCode NEPSLPGetEPS(NEP,EPS*);

274: PETSC_EXTERN PetscErrorCode NEPNArnoldiSetKSP(NEP,KSP);
275: PETSC_EXTERN PetscErrorCode NEPNArnoldiGetKSP(NEP,KSP*);

277: PETSC_EXTERN PetscErrorCode NEPCISSSetSizes(NEP,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool);
278: PETSC_EXTERN PetscErrorCode NEPCISSGetSizes(NEP,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*);
279: PETSC_EXTERN PetscErrorCode NEPCISSSetThreshold(NEP,PetscReal,PetscReal);
280: PETSC_EXTERN PetscErrorCode NEPCISSGetThreshold(NEP,PetscReal*,PetscReal*);
281: PETSC_EXTERN PetscErrorCode NEPCISSSetRefinement(NEP,PetscInt,PetscInt);
282: PETSC_EXTERN PetscErrorCode NEPCISSGetRefinement(NEP,PetscInt*,PetscInt*);

284: PETSC_EXTERN PetscErrorCode NEPInterpolSetPEP(NEP,PEP);
285: PETSC_EXTERN PetscErrorCode NEPInterpolGetPEP(NEP,PEP*);
286: PETSC_EXTERN PetscErrorCode NEPInterpolSetDegree(NEP,PetscInt);
287: PETSC_EXTERN PetscErrorCode NEPInterpolGetDegree(NEP,PetscInt*);

289: PETSC_EXTERN PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP,PetscErrorCode (*)(NEP,PetscInt*,PetscScalar*,void*),void*);
290: PETSC_EXTERN PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP,PetscErrorCode (**)(NEP,PetscInt*,PetscScalar*,void*),void **);
291: PETSC_EXTERN PetscErrorCode NEPNLEIGSSetRestart(NEP,PetscReal);
292: PETSC_EXTERN PetscErrorCode NEPNLEIGSGetRestart(NEP,PetscReal*);
293: PETSC_EXTERN PetscErrorCode NEPNLEIGSSetLocking(NEP,PetscBool);
294: PETSC_EXTERN PetscErrorCode NEPNLEIGSGetLocking(NEP,PetscBool*);
295: PETSC_EXTERN PetscErrorCode NEPNLEIGSSetInterpolation(NEP,PetscReal,PetscInt);
296: PETSC_EXTERN PetscErrorCode NEPNLEIGSGetInterpolation(NEP,PetscReal*,PetscInt*);
297: PETSC_EXTERN PetscErrorCode NEPNLEIGSSetTrueResidual(NEP,PetscBool);
298: PETSC_EXTERN PetscErrorCode NEPNLEIGSGetTrueResidual(NEP,PetscBool*);
299: PETSC_EXTERN PetscErrorCode NEPNLEIGSSetRKShifts(NEP,PetscInt,PetscScalar*);
300: PETSC_EXTERN PetscErrorCode NEPNLEIGSGetRKShifts(NEP,PetscInt*,PetscScalar**);
301: PETSC_EXTERN PetscErrorCode NEPNLEIGSGetKSPs(NEP,KSP**);

303: #endif

slepc-3.7.4/include/slepcsys.h0000644000175000017500000000613613107004621015632 0ustar jromanjroman/* This include file contains definitions of system functions. It is included by all other SLEPc include files. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCSYS_H) #define __SLEPCSYS_H /* ========================================================================== */ /* slepcconf.h is created by the configure script and placed in ${PETSC_ARCH}/include. It contains macro definitions set at configure time. */ #include /* slepcversion.h contains version info */ #include #define SLEPC_AUTHOR_INFO " The SLEPc Team\n slepc-maint@upv.es\n http://slepc.upv.es\n" /* ========================================================================== */ /* The PETSc include files. */ #include /* slepcmath.h contains definition of basic math functions */ #include /* slepcsc.h contains definition of sorting criterion */ #include /* Creation and destruction of context for monitors of type XXXMonitorConverged */ typedef struct _n_SlepcConvMonitor* SlepcConvMonitor; PETSC_EXTERN PetscErrorCode SlepcConvMonitorCreate(PetscViewer,PetscViewerFormat,SlepcConvMonitor*); PETSC_EXTERN PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor*); /* Initialization of SLEPc and other system routines */ PETSC_EXTERN PetscErrorCode SlepcInitialize(int*,char***,const char[],const char[]); PETSC_EXTERN PetscErrorCode SlepcInitializeNoPointers(int,char**,const char[],const char[]); PETSC_EXTERN PetscErrorCode SlepcInitializeNoArguments(void); PETSC_EXTERN PetscErrorCode SlepcFinalize(void); PETSC_EXTERN PetscErrorCode SlepcInitializeFortran(void); PETSC_EXTERN PetscErrorCode SlepcInitialized(PetscBool*); PETSC_EXTERN PetscErrorCode SlepcGetVersion(char[],size_t); PETSC_EXTERN PetscErrorCode SlepcMatConvertSeqDense(Mat,Mat*); PETSC_EXTERN PetscErrorCode SlepcMatTile(PetscScalar,Mat,PetscScalar,Mat,PetscScalar,Mat,PetscScalar,Mat,Mat*); PETSC_EXTERN PetscErrorCode SlepcCheckOrthogonality(Vec*,PetscInt,Vec*,PetscInt,Mat,PetscViewer,PetscReal*); PETSC_EXTERN PetscErrorCode SlepcSNPrintfScalar(char*,size_t,PetscScalar,PetscBool); PETSC_EXTERN PetscErrorCode SlepcVecNormalize(Vec,Vec,PetscBool,PetscReal*); PETSC_EXTERN PetscBool SlepcInitializeCalled; #endif slepc-3.7.4/include/slepcds.h0000644000175000017500000001673313107004621015426 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCDS_H) #define __SLEPCDS_H #include #include #define DS_MAX_SOLVE 6 PETSC_EXTERN PetscErrorCode DSInitializePackage(void); /*S DS - Direct solver (or dense system), to represent low-dimensional eigenproblems that must be solved within iterative solvers. This is an auxiliary object and is not normally needed by application programmers. Level: beginner .seealso: DSCreate() S*/ typedef struct _p_DS* DS; /*J DSType - String with the name of the type of direct solver. Roughly, there are as many types as problem types are available within SLEPc. Level: advanced .seealso: DSSetType(), DS J*/ typedef const char* DSType; #define DSHEP "hep" #define DSNHEP "nhep" #define DSGHEP "ghep" #define DSGHIEP "ghiep" #define DSGNHEP "gnhep" #define DSSVD "svd" #define DSPEP "pep" #define DSNEP "nep" /* Logging support */ PETSC_EXTERN PetscClassId DS_CLASSID; /*E DSStateType - Indicates in which state the direct solver is Level: advanced .seealso: DSSetState() E*/ typedef enum { DS_STATE_RAW, DS_STATE_INTERMEDIATE, DS_STATE_CONDENSED, DS_STATE_TRUNCATED } DSStateType; /*E DSMatType - Used to refer to one of the matrices stored internally in DS Notes: The matrices preferently refer to + DS_MAT_A - first matrix of eigenproblem/singular value problem . DS_MAT_B - second matrix of a generalized eigenproblem . DS_MAT_C - third matrix of a quadratic eigenproblem . DS_MAT_T - tridiagonal matrix . DS_MAT_D - diagonal matrix . DS_MAT_Q - orthogonal matrix of (right) Schur vectors . DS_MAT_Z - orthogonal matrix of left Schur vectors . DS_MAT_X - right eigenvectors . DS_MAT_Y - left eigenvectors . DS_MAT_U - left singular vectors . DS_MAT_VT - right singular vectors . DS_MAT_W - workspace matrix - DS_MAT_Ex - extra matrices (x=0,..,9) All matrices can have space to hold ld x ld elements, except for DS_MAT_T that has space for 3 x ld elements (ld = leading dimension) and DS_MAT_D that has space for just ld elements. In DSPEP problems, matrices A, B, W can have space for d*ld x d*ld, where d is the polynomial degree, and X can have ld x d*ld. Level: advanced .seealso: DSAllocate(), DSGetArray(), DSGetArrayReal(), DSVectors() E*/ typedef enum { DS_MAT_A, DS_MAT_B, DS_MAT_C, DS_MAT_T, DS_MAT_D, DS_MAT_Q, DS_MAT_Z, DS_MAT_X, DS_MAT_Y, DS_MAT_U, DS_MAT_VT, DS_MAT_W, DS_MAT_E0, DS_MAT_E1, DS_MAT_E2, DS_MAT_E3, DS_MAT_E4, DS_MAT_E5, DS_MAT_E6, DS_MAT_E7, DS_MAT_E8, DS_MAT_E9, DS_NUM_MAT } DSMatType; /* Convenience for indexing extra matrices */ PETSC_EXTERN DSMatType DSMatExtra[]; #define DS_NUM_EXTRA 10 PETSC_EXTERN PetscErrorCode DSCreate(MPI_Comm,DS*); PETSC_EXTERN PetscErrorCode DSSetType(DS,DSType); PETSC_EXTERN PetscErrorCode DSGetType(DS,DSType*); PETSC_EXTERN PetscErrorCode DSSetOptionsPrefix(DS,const char *); PETSC_EXTERN PetscErrorCode DSAppendOptionsPrefix(DS,const char *); PETSC_EXTERN PetscErrorCode DSGetOptionsPrefix(DS,const char *[]); PETSC_EXTERN PetscErrorCode DSSetFromOptions(DS); PETSC_EXTERN PetscErrorCode DSView(DS,PetscViewer); PETSC_EXTERN PetscErrorCode DSViewMat(DS,PetscViewer,DSMatType); PETSC_EXTERN PetscErrorCode DSDestroy(DS*); PETSC_EXTERN PetscErrorCode DSReset(DS); PETSC_EXTERN PetscErrorCode DSAllocate(DS,PetscInt); PETSC_EXTERN PetscErrorCode DSGetLeadingDimension(DS,PetscInt*); PETSC_EXTERN PetscErrorCode DSSetState(DS,DSStateType); PETSC_EXTERN PetscErrorCode DSGetState(DS,DSStateType*); PETSC_EXTERN PetscErrorCode DSSetDimensions(DS,PetscInt,PetscInt,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode DSGetDimensions(DS,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode DSSetBlockSize(DS,PetscInt); PETSC_EXTERN PetscErrorCode DSGetBlockSize(DS,PetscInt*); PETSC_EXTERN PetscErrorCode DSTruncate(DS,PetscInt); PETSC_EXTERN PetscErrorCode DSSetIdentity(DS,DSMatType); PETSC_EXTERN PetscErrorCode DSSetMethod(DS,PetscInt); PETSC_EXTERN PetscErrorCode DSGetMethod(DS,PetscInt*); PETSC_EXTERN PetscErrorCode DSSetCompact(DS,PetscBool); PETSC_EXTERN PetscErrorCode DSGetCompact(DS,PetscBool*); PETSC_EXTERN PetscErrorCode DSSetExtraRow(DS,PetscBool); PETSC_EXTERN PetscErrorCode DSGetExtraRow(DS,PetscBool*); PETSC_EXTERN PetscErrorCode DSSetRefined(DS,PetscBool); PETSC_EXTERN PetscErrorCode DSGetRefined(DS,PetscBool*); PETSC_EXTERN PetscErrorCode DSGetMat(DS,DSMatType,Mat*); PETSC_EXTERN PetscErrorCode DSRestoreMat(DS,DSMatType,Mat*); PETSC_EXTERN PetscErrorCode DSGetArray(DS,DSMatType,PetscScalar*[]); PETSC_EXTERN PetscErrorCode DSRestoreArray(DS,DSMatType,PetscScalar*[]); PETSC_EXTERN PetscErrorCode DSGetArrayReal(DS,DSMatType,PetscReal*[]); PETSC_EXTERN PetscErrorCode DSRestoreArrayReal(DS,DSMatType,PetscReal*[]); PETSC_EXTERN PetscErrorCode DSVectors(DS,DSMatType,PetscInt*,PetscReal*); PETSC_EXTERN PetscErrorCode DSSolve(DS,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscErrorCode DSSort(DS,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*); PETSC_EXTERN PetscErrorCode DSCopyMat(DS,DSMatType,PetscInt,PetscInt,Mat,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool); PETSC_EXTERN PetscErrorCode DSSetSlepcSC(DS,SlepcSC); PETSC_EXTERN PetscErrorCode DSGetSlepcSC(DS,SlepcSC*); PETSC_EXTERN PetscErrorCode DSUpdateExtraRow(DS); PETSC_EXTERN PetscErrorCode DSCond(DS,PetscReal*); PETSC_EXTERN PetscErrorCode DSTranslateHarmonic(DS,PetscScalar,PetscReal,PetscBool,PetscScalar*,PetscReal*); PETSC_EXTERN PetscErrorCode DSTranslateRKS(DS,PetscScalar); PETSC_EXTERN PetscErrorCode DSNormalize(DS,DSMatType,PetscInt); PETSC_EXTERN PetscErrorCode DSOrthogonalize(DS,DSMatType,PetscInt,PetscInt*); PETSC_EXTERN PetscErrorCode DSPseudoOrthogonalize(DS,DSMatType,PetscInt,PetscReal*,PetscInt*,PetscReal*); /* --------- options specific to particular solvers -------- */ PETSC_EXTERN PetscErrorCode DSPEPSetDegree(DS,PetscInt); PETSC_EXTERN PetscErrorCode DSPEPGetDegree(DS,PetscInt*); PETSC_EXTERN PetscErrorCode DSNEPSetFN(DS,PetscInt,FN*); PETSC_EXTERN PetscErrorCode DSNEPGetFN(DS,PetscInt,FN*); PETSC_EXTERN PetscErrorCode DSNEPGetNumFN(DS,PetscInt*); PETSC_EXTERN PetscFunctionList DSList; PETSC_EXTERN PetscErrorCode DSRegister(const char[],PetscErrorCode(*)(DS)); #endif slepc-3.7.4/include/slepcpep.h0000644000175000017500000003363213107004621015601 0ustar jromanjroman/* User interface for SLEPc's polynomial eigenvalue solvers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCPEP_H) #define __SLEPCPEP_H #include PETSC_EXTERN PetscErrorCode PEPInitializePackage(void); /*S PEP - Abstract SLEPc object that manages all the polynomial eigenvalue problem solvers. Level: beginner .seealso: PEPCreate() S*/ typedef struct _p_PEP* PEP; /*J PEPType - String with the name of a polynomial eigensolver Level: beginner .seealso: PEPSetType(), PEP J*/ typedef const char* PEPType; #define PEPLINEAR "linear" #define PEPQARNOLDI "qarnoldi" #define PEPTOAR "toar" #define PEPSTOAR "stoar" #define PEPJD "jd" /* Logging support */ PETSC_EXTERN PetscClassId PEP_CLASSID; /*E PEPProblemType - Determines the type of the polynomial eigenproblem Level: intermediate .seealso: PEPSetProblemType(), PEPGetProblemType() E*/ typedef enum { PEP_GENERAL=1, PEP_HERMITIAN, /* All A_i Hermitian */ PEP_GYROSCOPIC /* QEP with M, K Hermitian, M>0, C skew-Hermitian */ } PEPProblemType; /*E PEPWhich - Determines which part of the spectrum is requested Level: intermediate .seealso: PEPSetWhichEigenpairs(), PEPGetWhichEigenpairs() E*/ typedef enum { PEP_LARGEST_MAGNITUDE=1, PEP_SMALLEST_MAGNITUDE, PEP_LARGEST_REAL, PEP_SMALLEST_REAL, PEP_LARGEST_IMAGINARY, PEP_SMALLEST_IMAGINARY, PEP_TARGET_MAGNITUDE, PEP_TARGET_REAL, PEP_TARGET_IMAGINARY, PEP_WHICH_USER } PEPWhich; /*E PEPBasis - The type of polynomial basis used to represent the polynomial eigenproblem Level: intermediate .seealso: PEPSetBasis() E*/ typedef enum { PEP_BASIS_MONOMIAL, PEP_BASIS_CHEBYSHEV1, PEP_BASIS_CHEBYSHEV2, PEP_BASIS_LEGENDRE, PEP_BASIS_LAGUERRE, PEP_BASIS_HERMITE } PEPBasis; PETSC_EXTERN const char *PEPBasisTypes[]; /*E PEPScale - The scaling strategy Level: intermediate .seealso: PEPSetScale() E*/ typedef enum { PEP_SCALE_NONE, PEP_SCALE_SCALAR, PEP_SCALE_DIAGONAL, PEP_SCALE_BOTH } PEPScale; PETSC_EXTERN const char *PEPScaleTypes[]; /*E PEPRefine - The refinement type Level: intermediate .seealso: PEPSetRefine() E*/ typedef enum { PEP_REFINE_NONE, PEP_REFINE_SIMPLE, PEP_REFINE_MULTIPLE } PEPRefine; PETSC_EXTERN const char *PEPRefineTypes[]; /*E PEPRefineScheme - The scheme used for solving linear systems during iterative refinement Level: intermediate .seealso: PEPSetRefine() E*/ typedef enum { PEP_REFINE_SCHEME_SCHUR=1, PEP_REFINE_SCHEME_MBE, PEP_REFINE_SCHEME_EXPLICIT } PEPRefineScheme; PETSC_EXTERN const char *PEPRefineSchemes[]; /*E PEPExtract - The extraction type Level: intermediate .seealso: PEPSetExtract() E*/ typedef enum { PEP_EXTRACT_NONE=1, PEP_EXTRACT_NORM, PEP_EXTRACT_RESIDUAL, PEP_EXTRACT_STRUCTURED } PEPExtract; PETSC_EXTERN const char *PEPExtractTypes[]; /*E PEPErrorType - The error type used to assess accuracy of computed solutions Level: intermediate .seealso: PEPComputeError() E*/ typedef enum { PEP_ERROR_ABSOLUTE, PEP_ERROR_RELATIVE, PEP_ERROR_BACKWARD } PEPErrorType; PETSC_EXTERN const char *PEPErrorTypes[]; /*E PEPConv - Determines the convergence test Level: intermediate .seealso: PEPSetConvergenceTest(), PEPSetConvergenceTestFunction() E*/ typedef enum { PEP_CONV_ABS, PEP_CONV_REL, PEP_CONV_NORM, PEP_CONV_USER } PEPConv; /*E PEPStop - Determines the stopping test Level: advanced .seealso: PEPSetStoppingTest(), PEPSetStoppingTestFunction() E*/ typedef enum { PEP_STOP_BASIC, PEP_STOP_USER } PEPStop; /*E PEPConvergedReason - Reason an eigensolver was said to have converged or diverged Level: intermediate .seealso: PEPSolve(), PEPGetConvergedReason(), PEPSetTolerances() E*/ typedef enum {/* converged */ PEP_CONVERGED_TOL = 1, PEP_CONVERGED_USER = 2, /* diverged */ PEP_DIVERGED_ITS = -1, PEP_DIVERGED_BREAKDOWN = -2, PEP_DIVERGED_SYMMETRY_LOST = -3, PEP_CONVERGED_ITERATING = 0} PEPConvergedReason; PETSC_EXTERN const char *const*PEPConvergedReasons; PETSC_EXTERN PetscErrorCode PEPCreate(MPI_Comm,PEP*); PETSC_EXTERN PetscErrorCode PEPDestroy(PEP*); PETSC_EXTERN PetscErrorCode PEPReset(PEP); PETSC_EXTERN PetscErrorCode PEPSetType(PEP,PEPType); PETSC_EXTERN PetscErrorCode PEPGetType(PEP,PEPType*); PETSC_EXTERN PetscErrorCode PEPSetProblemType(PEP,PEPProblemType); PETSC_EXTERN PetscErrorCode PEPGetProblemType(PEP,PEPProblemType*); PETSC_EXTERN PetscErrorCode PEPSetOperators(PEP,PetscInt,Mat[]); PETSC_EXTERN PetscErrorCode PEPGetOperators(PEP,PetscInt,Mat*); PETSC_EXTERN PetscErrorCode PEPGetNumMatrices(PEP,PetscInt*); PETSC_EXTERN PetscErrorCode PEPSetTarget(PEP,PetscScalar); PETSC_EXTERN PetscErrorCode PEPGetTarget(PEP,PetscScalar*); PETSC_EXTERN PetscErrorCode PEPSetFromOptions(PEP); PETSC_EXTERN PetscErrorCode PEPSetUp(PEP); PETSC_EXTERN PetscErrorCode PEPSolve(PEP); PETSC_EXTERN PetscErrorCode PEPView(PEP,PetscViewer); PETSC_STATIC_INLINE PetscErrorCode PEPViewFromOptions(PEP pep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)pep,obj,name);} PETSC_EXTERN PetscErrorCode PEPErrorView(PEP,PEPErrorType,PetscViewer); PETSC_DEPRECATED("Use PEPErrorView()") PETSC_STATIC_INLINE PetscErrorCode PEPPrintSolution(PEP pep,PetscViewer v) {return PEPErrorView(pep,PEP_ERROR_BACKWARD,v);} PETSC_EXTERN PetscErrorCode PEPErrorViewFromOptions(PEP); PETSC_EXTERN PetscErrorCode PEPReasonView(PEP,PetscViewer); PETSC_EXTERN PetscErrorCode PEPReasonViewFromOptions(PEP); PETSC_EXTERN PetscErrorCode PEPValuesView(PEP,PetscViewer); PETSC_EXTERN PetscErrorCode PEPValuesViewFromOptions(PEP); PETSC_EXTERN PetscErrorCode PEPVectorsView(PEP,PetscViewer); PETSC_EXTERN PetscErrorCode PEPVectorsViewFromOptions(PEP); PETSC_EXTERN PetscErrorCode PEPSetBV(PEP,BV); PETSC_EXTERN PetscErrorCode PEPGetBV(PEP,BV*); PETSC_EXTERN PetscErrorCode PEPSetRG(PEP,RG); PETSC_EXTERN PetscErrorCode PEPGetRG(PEP,RG*); PETSC_EXTERN PetscErrorCode PEPSetDS(PEP,DS); PETSC_EXTERN PetscErrorCode PEPGetDS(PEP,DS*); PETSC_EXTERN PetscErrorCode PEPSetST(PEP,ST); PETSC_EXTERN PetscErrorCode PEPGetST(PEP,ST*); PETSC_EXTERN PetscErrorCode PEPRefineGetKSP(PEP,KSP*); PETSC_EXTERN PetscErrorCode PEPSetTolerances(PEP,PetscReal,PetscInt); PETSC_EXTERN PetscErrorCode PEPGetTolerances(PEP,PetscReal*,PetscInt*); PETSC_EXTERN PetscErrorCode PEPSetConvergenceTestFunction(PEP,PetscErrorCode (*)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode PEPSetConvergenceTest(PEP,PEPConv); PETSC_EXTERN PetscErrorCode PEPGetConvergenceTest(PEP,PEPConv*); PETSC_EXTERN PetscErrorCode PEPConvergedAbsolute(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode PEPConvergedRelative(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode PEPConvergedNorm(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode PEPSetStoppingTestFunction(PEP,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode PEPSetStoppingTest(PEP,PEPStop); PETSC_EXTERN PetscErrorCode PEPGetStoppingTest(PEP,PEPStop*); PETSC_EXTERN PetscErrorCode PEPStoppingBasic(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*); PETSC_EXTERN PetscErrorCode PEPGetConvergedReason(PEP,PEPConvergedReason *); PETSC_EXTERN PetscErrorCode PEPSetDimensions(PEP,PetscInt,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode PEPGetDimensions(PEP,PetscInt*,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode PEPSetScale(PEP,PEPScale,PetscReal,Vec,Vec,PetscInt,PetscReal); PETSC_EXTERN PetscErrorCode PEPGetScale(PEP,PEPScale*,PetscReal*,Vec*,Vec*,PetscInt*,PetscReal*); PETSC_EXTERN PetscErrorCode PEPSetRefine(PEP,PEPRefine,PetscInt,PetscReal,PetscInt,PEPRefineScheme); PETSC_EXTERN PetscErrorCode PEPGetRefine(PEP,PEPRefine*,PetscInt*,PetscReal*,PetscInt*,PEPRefineScheme*); PETSC_EXTERN PetscErrorCode PEPSetExtract(PEP,PEPExtract); PETSC_EXTERN PetscErrorCode PEPGetExtract(PEP,PEPExtract*); PETSC_EXTERN PetscErrorCode PEPSetBasis(PEP,PEPBasis); PETSC_EXTERN PetscErrorCode PEPGetBasis(PEP,PEPBasis*); PETSC_EXTERN PetscErrorCode PEPGetConverged(PEP,PetscInt*); PETSC_EXTERN PetscErrorCode PEPGetEigenpair(PEP,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec); PETSC_EXTERN PetscErrorCode PEPComputeError(PEP,PetscInt,PEPErrorType,PetscReal*); PETSC_DEPRECATED("Use PEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode PEPComputeRelativeError(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_BACKWARD,r);} PETSC_DEPRECATED("Use PEPComputeError() with PEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode PEPComputeResidualNorm(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_ABSOLUTE,r);} PETSC_EXTERN PetscErrorCode PEPGetErrorEstimate(PEP,PetscInt,PetscReal*); PETSC_EXTERN PetscErrorCode PEPMonitor(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt); PETSC_EXTERN PetscErrorCode PEPMonitorSet(PEP,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**)); PETSC_EXTERN PetscErrorCode PEPMonitorSetFromOptions(PEP,const char*,const char*,const char*,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool); PETSC_EXTERN PetscErrorCode PEPConvMonitorSetFromOptions(PEP,const char*,const char*,const char*,PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor)); PETSC_EXTERN PetscErrorCode PEPMonitorCancel(PEP); PETSC_EXTERN PetscErrorCode PEPGetMonitorContext(PEP,void **); PETSC_EXTERN PetscErrorCode PEPGetIterationNumber(PEP,PetscInt*); PETSC_EXTERN PetscErrorCode PEPSetInitialSpace(PEP,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode PEPSetWhichEigenpairs(PEP,PEPWhich); PETSC_EXTERN PetscErrorCode PEPGetWhichEigenpairs(PEP,PEPWhich*); PETSC_EXTERN PetscErrorCode PEPSetEigenvalueComparison(PEP,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*); PETSC_EXTERN PetscErrorCode PEPMonitorAll(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode PEPMonitorFirst(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode PEPMonitorConverged(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor); PETSC_EXTERN PetscErrorCode PEPMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*); PETSC_EXTERN PetscErrorCode PEPMonitorLG(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode PEPMonitorLGAll(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode PEPSetTrackAll(PEP,PetscBool); PETSC_EXTERN PetscErrorCode PEPGetTrackAll(PEP,PetscBool*); PETSC_EXTERN PetscErrorCode PEPSetOptionsPrefix(PEP,const char*); PETSC_EXTERN PetscErrorCode PEPAppendOptionsPrefix(PEP,const char*); PETSC_EXTERN PetscErrorCode PEPGetOptionsPrefix(PEP,const char*[]); PETSC_EXTERN PetscFunctionList PEPList; PETSC_EXTERN PetscErrorCode PEPRegister(const char[],PetscErrorCode(*)(PEP)); PETSC_EXTERN PetscErrorCode PEPSetWorkVecs(PEP,PetscInt); PETSC_EXTERN PetscErrorCode PEPAllocateSolution(PEP,PetscInt); /* --------- options specific to particular eigensolvers -------- */ PETSC_EXTERN PetscErrorCode PEPLinearSetCompanionForm(PEP,PetscInt); PETSC_EXTERN PetscErrorCode PEPLinearGetCompanionForm(PEP,PetscInt*); PETSC_EXTERN PetscErrorCode PEPLinearSetExplicitMatrix(PEP,PetscBool); PETSC_EXTERN PetscErrorCode PEPLinearGetExplicitMatrix(PEP,PetscBool*); PETSC_EXTERN PetscErrorCode PEPLinearSetEPS(PEP,EPS); PETSC_EXTERN PetscErrorCode PEPLinearGetEPS(PEP,EPS*); PETSC_EXTERN PetscErrorCode PEPQArnoldiSetRestart(PEP,PetscReal); PETSC_EXTERN PetscErrorCode PEPQArnoldiGetRestart(PEP,PetscReal*); PETSC_EXTERN PetscErrorCode PEPQArnoldiSetLocking(PEP,PetscBool); PETSC_EXTERN PetscErrorCode PEPQArnoldiGetLocking(PEP,PetscBool*); PETSC_EXTERN PetscErrorCode PEPTOARSetRestart(PEP,PetscReal); PETSC_EXTERN PetscErrorCode PEPTOARGetRestart(PEP,PetscReal*); PETSC_EXTERN PetscErrorCode PEPTOARSetLocking(PEP,PetscBool); PETSC_EXTERN PetscErrorCode PEPTOARGetLocking(PEP,PetscBool*); PETSC_EXTERN PetscErrorCode PEPSTOARSetLocking(PEP,PetscBool); PETSC_EXTERN PetscErrorCode PEPSTOARGetLocking(PEP,PetscBool*); PETSC_EXTERN PetscErrorCode PEPJDSetRestart(PEP,PetscReal); PETSC_EXTERN PetscErrorCode PEPJDGetRestart(PEP,PetscReal*); #endif slepc-3.7.4/include/slepcrgtypes.h0000644000175000017500000000211613107004621016503 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCRGTYPES_H) #define __SLEPCRGTYPES_H /*S RG - Region of the complex plane. Level: beginner .seealso: RGCreate() S*/ typedef struct _p_RG* RG; #endif slepc-3.7.4/include/slepcnep.h0000644000175000017500000003456613107004621015606 0ustar jromanjroman/* User interface for SLEPc's nonlinear eigenvalue solvers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCNEP_H) #define __SLEPCNEP_H #include #include #include PETSC_EXTERN PetscErrorCode NEPInitializePackage(void); /*S NEP - Abstract SLEPc object that manages all solvers for nonlinear eigenvalue problems. Level: beginner .seealso: NEPCreate() S*/ typedef struct _p_NEP* NEP; /*J NEPType - String with the name of a nonlinear eigensolver Level: beginner .seealso: NEPSetType(), NEP J*/ typedef const char* NEPType; #define NEPRII "rii" #define NEPSLP "slp" #define NEPNARNOLDI "narnoldi" #define NEPCISS "ciss" #define NEPINTERPOL "interpol" #define NEPNLEIGS "nleigs" /* Logging support */ PETSC_EXTERN PetscClassId NEP_CLASSID; /*E NEPWhich - Determines which part of the spectrum is requested Level: intermediate .seealso: NEPSetWhichEigenpairs(), NEPGetWhichEigenpairs() E*/ typedef enum { NEP_LARGEST_MAGNITUDE=1, NEP_SMALLEST_MAGNITUDE, NEP_LARGEST_REAL, NEP_SMALLEST_REAL, NEP_LARGEST_IMAGINARY, NEP_SMALLEST_IMAGINARY, NEP_TARGET_MAGNITUDE, NEP_TARGET_REAL, NEP_TARGET_IMAGINARY, NEP_ALL, NEP_WHICH_USER } NEPWhich; /*E NEPErrorType - The error type used to assess accuracy of computed solutions Level: intermediate .seealso: NEPComputeError() E*/ typedef enum { NEP_ERROR_ABSOLUTE, NEP_ERROR_RELATIVE, NEP_ERROR_BACKWARD } NEPErrorType; PETSC_EXTERN const char *NEPErrorTypes[]; /*E NEPRefine - The refinement type Level: intermediate .seealso: NEPSetRefine() E*/ typedef enum { NEP_REFINE_NONE, NEP_REFINE_SIMPLE, NEP_REFINE_MULTIPLE } NEPRefine; PETSC_EXTERN const char *NEPRefineTypes[]; /*E NEPRefineScheme - The scheme used for solving linear systems during iterative refinement Level: intermediate .seealso: NEPSetRefine() E*/ typedef enum { NEP_REFINE_SCHEME_SCHUR=1, NEP_REFINE_SCHEME_MBE, NEP_REFINE_SCHEME_EXPLICIT } NEPRefineScheme; PETSC_EXTERN const char *NEPRefineSchemes[]; /*E NEPConv - Determines the convergence test Level: intermediate .seealso: NEPSetConvergenceTest(), NEPSetConvergenceTestFunction() E*/ typedef enum { NEP_CONV_ABS, NEP_CONV_REL, NEP_CONV_NORM, NEP_CONV_USER } NEPConv; /*E NEPStop - Determines the stopping test Level: advanced .seealso: NEPSetStoppingTest(), NEPSetStoppingTestFunction() E*/ typedef enum { NEP_STOP_BASIC, NEP_STOP_USER } NEPStop; /*E NEPConvergedReason - Reason a nonlinear eigensolver was said to have converged or diverged Level: intermediate .seealso: NEPSolve(), NEPGetConvergedReason(), NEPSetTolerances() E*/ typedef enum {/* converged */ NEP_CONVERGED_TOL = 1, NEP_CONVERGED_USER = 2, /* diverged */ NEP_DIVERGED_ITS = -1, NEP_DIVERGED_BREAKDOWN = -2, /* unused = -3 */ NEP_DIVERGED_LINEAR_SOLVE = -4, NEP_CONVERGED_ITERATING = 0} NEPConvergedReason; PETSC_EXTERN const char *const*NEPConvergedReasons; PETSC_EXTERN PetscErrorCode NEPCreate(MPI_Comm,NEP*); PETSC_EXTERN PetscErrorCode NEPDestroy(NEP*); PETSC_EXTERN PetscErrorCode NEPReset(NEP); PETSC_EXTERN PetscErrorCode NEPSetType(NEP,NEPType); PETSC_EXTERN PetscErrorCode NEPGetType(NEP,NEPType*); PETSC_EXTERN PetscErrorCode NEPSetTarget(NEP,PetscScalar); PETSC_EXTERN PetscErrorCode NEPGetTarget(NEP,PetscScalar*); PETSC_EXTERN PetscErrorCode NEPSetFromOptions(NEP); PETSC_EXTERN PetscErrorCode NEPSetUp(NEP); PETSC_EXTERN PetscErrorCode NEPSolve(NEP); PETSC_EXTERN PetscErrorCode NEPView(NEP,PetscViewer); PETSC_STATIC_INLINE PetscErrorCode NEPViewFromOptions(NEP nep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)nep,obj,name);} PETSC_EXTERN PetscErrorCode NEPErrorView(NEP,NEPErrorType,PetscViewer); PETSC_EXTERN PetscErrorCode NEPErrorViewFromOptions(NEP); PETSC_EXTERN PetscErrorCode NEPReasonView(NEP,PetscViewer); PETSC_EXTERN PetscErrorCode NEPReasonViewFromOptions(NEP); PETSC_EXTERN PetscErrorCode NEPValuesView(NEP,PetscViewer); PETSC_EXTERN PetscErrorCode NEPValuesViewFromOptions(NEP); PETSC_EXTERN PetscErrorCode NEPVectorsView(NEP,PetscViewer); PETSC_EXTERN PetscErrorCode NEPVectorsViewFromOptions(NEP); PETSC_EXTERN PetscErrorCode NEPSetFunction(NEP,Mat,Mat,PetscErrorCode (*)(NEP,PetscScalar,Mat,Mat,void*),void*); PETSC_EXTERN PetscErrorCode NEPGetFunction(NEP,Mat*,Mat*,PetscErrorCode (**)(NEP,PetscScalar,Mat,Mat,void*),void**); PETSC_EXTERN PetscErrorCode NEPSetJacobian(NEP,Mat,PetscErrorCode (*)(NEP,PetscScalar,Mat,void*),void*); PETSC_EXTERN PetscErrorCode NEPGetJacobian(NEP,Mat*,PetscErrorCode (**)(NEP,PetscScalar,Mat,void*),void**); PETSC_EXTERN PetscErrorCode NEPSetDerivatives(NEP,Mat,PetscErrorCode (*)(NEP,PetscScalar,PetscInt,Mat,void*),void*); PETSC_EXTERN PetscErrorCode NEPGetDerivatives(NEP,Mat*,PetscErrorCode (**)(NEP,PetscScalar,PetscInt,Mat,void*),void**); PETSC_EXTERN PetscErrorCode NEPSetSplitOperator(NEP,PetscInt,Mat*,FN*,MatStructure); PETSC_EXTERN PetscErrorCode NEPGetSplitOperatorTerm(NEP,PetscInt,Mat*,FN*); PETSC_EXTERN PetscErrorCode NEPGetSplitOperatorInfo(NEP,PetscInt*,MatStructure*); PETSC_EXTERN PetscErrorCode NEPSetBV(NEP,BV); PETSC_EXTERN PetscErrorCode NEPGetBV(NEP,BV*); PETSC_EXTERN PetscErrorCode NEPSetRG(NEP,RG); PETSC_EXTERN PetscErrorCode NEPGetRG(NEP,RG*); PETSC_EXTERN PetscErrorCode NEPSetDS(NEP,DS); PETSC_EXTERN PetscErrorCode NEPGetDS(NEP,DS*); PETSC_EXTERN PetscErrorCode NEPRefineGetKSP(NEP,KSP*); PETSC_EXTERN PetscErrorCode NEPSetTolerances(NEP,PetscReal,PetscInt); PETSC_EXTERN PetscErrorCode NEPGetTolerances(NEP,PetscReal*,PetscInt*); PETSC_EXTERN PetscErrorCode NEPSetConvergenceTestFunction(NEP,PetscErrorCode (*)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode NEPSetConvergenceTest(NEP,NEPConv); PETSC_EXTERN PetscErrorCode NEPGetConvergenceTest(NEP,NEPConv*); PETSC_EXTERN PetscErrorCode NEPConvergedAbsolute(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode NEPConvergedRelative(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode NEPConvergedNorm(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*); PETSC_EXTERN PetscErrorCode NEPSetStoppingTestFunction(NEP,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void*,PetscErrorCode (*)(void*)); PETSC_EXTERN PetscErrorCode NEPSetStoppingTest(NEP,NEPStop); PETSC_EXTERN PetscErrorCode NEPGetStoppingTest(NEP,NEPStop*); PETSC_EXTERN PetscErrorCode NEPStoppingBasic(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*); PETSC_EXTERN PetscErrorCode NEPSetDimensions(NEP,PetscInt,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode NEPGetDimensions(NEP,PetscInt*,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode NEPSetRefine(NEP,NEPRefine,PetscInt,PetscReal,PetscInt,NEPRefineScheme); PETSC_EXTERN PetscErrorCode NEPGetRefine(NEP,NEPRefine*,PetscInt*,PetscReal*,PetscInt*,NEPRefineScheme*); PETSC_EXTERN PetscErrorCode NEPGetConverged(NEP,PetscInt*); PETSC_EXTERN PetscErrorCode NEPGetEigenpair(NEP,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec); PETSC_EXTERN PetscErrorCode NEPComputeError(NEP,PetscInt,NEPErrorType,PetscReal*); PETSC_DEPRECATED("Use NEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode NEPComputeRelativeError(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_RELATIVE,r);} PETSC_DEPRECATED("Use NEPComputeError() with NEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode NEPComputeResidualNorm(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_ABSOLUTE,r);} PETSC_EXTERN PetscErrorCode NEPGetErrorEstimate(NEP,PetscInt,PetscReal*); PETSC_EXTERN PetscErrorCode NEPComputeFunction(NEP,PetscScalar,Mat,Mat); PETSC_EXTERN PetscErrorCode NEPComputeJacobian(NEP,PetscScalar,Mat); PETSC_EXTERN PetscErrorCode NEPApplyFunction(NEP,PetscScalar,Vec,Vec,Vec,Mat,Mat); PETSC_EXTERN PetscErrorCode NEPApplyJacobian(NEP,PetscScalar,Vec,Vec,Vec,Mat); PETSC_EXTERN PetscErrorCode NEPProjectOperator(NEP,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode NEPMonitor(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt); PETSC_EXTERN PetscErrorCode NEPMonitorSet(NEP,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**)); PETSC_EXTERN PetscErrorCode NEPMonitorSetFromOptions(NEP,const char*,const char*,const char*,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool); PETSC_EXTERN PetscErrorCode NEPConvMonitorSetFromOptions(NEP,const char*,const char*,const char*,PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor)); PETSC_EXTERN PetscErrorCode NEPMonitorCancel(NEP); PETSC_EXTERN PetscErrorCode NEPGetMonitorContext(NEP,void **); PETSC_EXTERN PetscErrorCode NEPGetIterationNumber(NEP,PetscInt*); PETSC_EXTERN PetscErrorCode NEPSetInitialSpace(NEP,PetscInt,Vec*); PETSC_EXTERN PetscErrorCode NEPSetWhichEigenpairs(NEP,NEPWhich); PETSC_EXTERN PetscErrorCode NEPGetWhichEigenpairs(NEP,NEPWhich*); PETSC_EXTERN PetscErrorCode NEPSetEigenvalueComparison(NEP,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void*); PETSC_EXTERN PetscErrorCode NEPMonitorAll(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode NEPMonitorFirst(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*); PETSC_EXTERN PetscErrorCode NEPMonitorConverged(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor); PETSC_EXTERN PetscErrorCode NEPMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*); PETSC_EXTERN PetscErrorCode NEPMonitorLG(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode NEPMonitorLGAll(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*); PETSC_EXTERN PetscErrorCode NEPSetTrackAll(NEP,PetscBool); PETSC_EXTERN PetscErrorCode NEPGetTrackAll(NEP,PetscBool*); PETSC_EXTERN PetscErrorCode NEPSetOptionsPrefix(NEP,const char*); PETSC_EXTERN PetscErrorCode NEPAppendOptionsPrefix(NEP,const char*); PETSC_EXTERN PetscErrorCode NEPGetOptionsPrefix(NEP,const char*[]); PETSC_EXTERN PetscErrorCode NEPGetConvergedReason(NEP,NEPConvergedReason *); PETSC_EXTERN PetscFunctionList NEPList; PETSC_EXTERN PetscErrorCode NEPRegister(const char[],PetscErrorCode(*)(NEP)); PETSC_EXTERN PetscErrorCode NEPSetWorkVecs(NEP,PetscInt); PETSC_EXTERN PetscErrorCode NEPAllocateSolution(NEP,PetscInt); /* --------- options specific to particular eigensolvers -------- */ PETSC_EXTERN PetscErrorCode NEPRIISetMaximumIterations(NEP,PetscInt); PETSC_EXTERN PetscErrorCode NEPRIIGetMaximumIterations(NEP,PetscInt*); PETSC_EXTERN PetscErrorCode NEPRIISetLagPreconditioner(NEP,PetscInt); PETSC_EXTERN PetscErrorCode NEPRIIGetLagPreconditioner(NEP,PetscInt*); PETSC_EXTERN PetscErrorCode NEPRIISetConstCorrectionTol(NEP,PetscBool); PETSC_EXTERN PetscErrorCode NEPRIIGetConstCorrectionTol(NEP,PetscBool*); PETSC_EXTERN PetscErrorCode NEPRIISetKSP(NEP,KSP); PETSC_EXTERN PetscErrorCode NEPRIIGetKSP(NEP,KSP*); PETSC_EXTERN PetscErrorCode NEPSLPSetEPS(NEP,EPS); PETSC_EXTERN PetscErrorCode NEPSLPGetEPS(NEP,EPS*); PETSC_EXTERN PetscErrorCode NEPNArnoldiSetKSP(NEP,KSP); PETSC_EXTERN PetscErrorCode NEPNArnoldiGetKSP(NEP,KSP*); PETSC_EXTERN PetscErrorCode NEPCISSSetSizes(NEP,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool); PETSC_EXTERN PetscErrorCode NEPCISSGetSizes(NEP,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*); PETSC_EXTERN PetscErrorCode NEPCISSSetThreshold(NEP,PetscReal,PetscReal); PETSC_EXTERN PetscErrorCode NEPCISSGetThreshold(NEP,PetscReal*,PetscReal*); PETSC_EXTERN PetscErrorCode NEPCISSSetRefinement(NEP,PetscInt,PetscInt); PETSC_EXTERN PetscErrorCode NEPCISSGetRefinement(NEP,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode NEPInterpolSetPEP(NEP,PEP); PETSC_EXTERN PetscErrorCode NEPInterpolGetPEP(NEP,PEP*); PETSC_EXTERN PetscErrorCode NEPInterpolSetDegree(NEP,PetscInt); PETSC_EXTERN PetscErrorCode NEPInterpolGetDegree(NEP,PetscInt*); PETSC_EXTERN PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP,PetscErrorCode (*)(NEP,PetscInt*,PetscScalar*,void*),void*); PETSC_EXTERN PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP,PetscErrorCode (**)(NEP,PetscInt*,PetscScalar*,void*),void **); PETSC_EXTERN PetscErrorCode NEPNLEIGSSetRestart(NEP,PetscReal); PETSC_EXTERN PetscErrorCode NEPNLEIGSGetRestart(NEP,PetscReal*); PETSC_EXTERN PetscErrorCode NEPNLEIGSSetLocking(NEP,PetscBool); PETSC_EXTERN PetscErrorCode NEPNLEIGSGetLocking(NEP,PetscBool*); PETSC_EXTERN PetscErrorCode NEPNLEIGSSetInterpolation(NEP,PetscReal,PetscInt); PETSC_EXTERN PetscErrorCode NEPNLEIGSGetInterpolation(NEP,PetscReal*,PetscInt*); PETSC_EXTERN PetscErrorCode NEPNLEIGSSetTrueResidual(NEP,PetscBool); PETSC_EXTERN PetscErrorCode NEPNLEIGSGetTrueResidual(NEP,PetscBool*); PETSC_EXTERN PetscErrorCode NEPNLEIGSSetRKShifts(NEP,PetscInt,PetscScalar*); PETSC_EXTERN PetscErrorCode NEPNLEIGSGetRKShifts(NEP,PetscInt*,PetscScalar**); PETSC_EXTERN PetscErrorCode NEPNLEIGSGetKSPs(NEP,KSP**); #endif slepc-3.7.4/include/index.html0000644000175000017500000000262213107004621015605 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

slepc/finclude/
slepc/private/
slepc.h
slepcsys.h
slepcmath.h
slepcversion.h
slepcblaslapack.h
slepceps.h
slepcpep.h
slepcnep.h
slepcmfn.h
slepcsvd.h
slepcst.h
slepcds.h
slepcfn.h
slepcrg.h
slepcbv.h
slepcvec.h
makefile
slepc-3.7.4/include/slepcblaslapack.h0000644000175000017500000014012413107004621017105 0ustar jromanjroman/* Necessary routines in BLAS and LAPACK not included in petscblaslapack.f - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCBLASLAPACK_H) #define __SLEPCBLASLAPACK_H #include /* Macros for building LAPACK names */ #if defined(PETSC_BLASLAPACK_UNDERSCORE) #if defined(PETSC_USE_REAL_SINGLE) #define SLEPC_BLASLAPACKREAL(lcase,ucase) s##lcase##_ #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) c##lcase##_ #else #define SLEPC_BLASLAPACK(lcase,ucase) s##lcase##_ #endif #elif defined(PETSC_USE_REAL___FLOAT128) #define SLEPC_BLASLAPACKREAL(lcase,ucase) q##lcase##_ #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) w##lcase##_ #else #define SLEPC_BLASLAPACK(lcase,ucase) q##lcase##_ #endif #else #define SLEPC_BLASLAPACKREAL(lcase,ucase) d##lcase##_ #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) z##lcase##_ #else #define SLEPC_BLASLAPACK(lcase,ucase) d##lcase##_ #endif #endif #elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL) #if defined(PETSC_USE_REAL_SINGLE) #define SLEPC_BLASLAPACKREAL(lcase,ucase) S##ucase #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) C##ucase #else #define SLEPC_BLASLAPACK(lcase,ucase) S##ucase #endif #elif defined(PETSC_USE_REAL___FLOAT128) #define SLEPC_BLASLAPACKREAL(lcase,ucase) Q##ucase #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) W##ucase #else #define SLEPC_BLASLAPACK(lcase,ucase) Q##ucase #endif #else #define SLEPC_BLASLAPACKREAL(lcase,ucase) D##ucase #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) Z##ucase #else #define SLEPC_BLASLAPACK(lcase,ucase) D##ucase #endif #endif #else #if defined(PETSC_USE_REAL_SINGLE) #define SLEPC_BLASLAPACKREAL(lcase,ucase) s##lcase #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) c##lcase #else #define SLEPC_BLASLAPACK(lcase,ucase) s##lcase #endif #elif defined(PETSC_USE_REAL___FLOAT128) #define SLEPC_BLASLAPACKREAL(lcase,ucase) q##lcase #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) w##lcase #else #define SLEPC_BLASLAPACK(lcase,ucase) q##lcase #endif #else #define SLEPC_BLASLAPACKREAL(lcase,ucase) d##lcase #if defined(PETSC_USE_COMPLEX) #define SLEPC_BLASLAPACK(lcase,ucase) z##lcase #else #define SLEPC_BLASLAPACK(lcase,ucase) d##lcase #endif #endif #endif /* LAPACK return type: we assume slange, etc. behave in the same way as snrm2 */ #if defined(PETSC_USE_REAL_SINGLE) && defined(PETSC_BLASLAPACK_SNRM2_RETURNS_DOUBLE) #define SlepcLRT double #else #define SlepcLRT PetscReal #endif /* LAPACK functions without string parameters */ #define LAPACKlaev2_ SLEPC_BLASLAPACK(laev2,LAEV2) #define LAPACKgehrd_ SLEPC_BLASLAPACK(gehrd,GEHRD) #define LAPACKgelqf_ SLEPC_BLASLAPACK(gelqf,GELQF) #define LAPACKgeqp3_ SLEPC_BLASLAPACK(geqp3,GEQP3) #define LAPACKtgexc_ SLEPC_BLASLAPACK(tgexc,TGEXC) #define LAPACKlarfg_ SLEPC_BLASLAPACK(larfg,LARFG) #define LAPACKlag2_ SLEPC_BLASLAPACKREAL(lag2,LAG2) #define LAPACKlasv2_ SLEPC_BLASLAPACKREAL(lasv2,LASV2) #define LAPACKlartg_ SLEPC_BLASLAPACKREAL(lartg,LARTG) #define LAPACKlaln2_ SLEPC_BLASLAPACKREAL(laln2,LALN2) #define LAPACKlaed4_ SLEPC_BLASLAPACKREAL(laed4,LAED4) #define LAPACKlamrg_ SLEPC_BLASLAPACKREAL(lamrg,LAMRG) #define LAPACKlapy2_ SLEPC_BLASLAPACKREAL(lapy2,LAPY2) #if !defined(PETSC_USE_COMPLEX) #define LAPACKorghr_ SLEPC_BLASLAPACK(orghr,ORGHR) #else #define LAPACKorghr_ SLEPC_BLASLAPACK(unghr,UNGHR) #endif /* the next one needs a special treatment due to the special names: srot, drot, csrot, zdrot */ #if !defined(PETSC_USE_COMPLEX) #define BLASrot_ SLEPC_BLASLAPACK(rot,ROT) #else #if defined(PETSC_USE_REAL_SINGLE) #define BLASrot_ SLEPC_BLASLAPACK(srot,SROT) #elif defined(PETSC_USE_REAL___FLOAT128) #define BLASrot_ SLEPC_BLASLAPACK(qrot,QROT) #else #define BLASrot_ SLEPC_BLASLAPACK(drot,DROT) #endif #endif /* LAPACK functions with string parameters */ #if !defined(PETSC_BLASLAPACK_STDCALL) /* same name for real and complex */ #define LAPACKlanhs_(a,b,c,d,e) SLEPC_BLASLAPACK(lanhs,LANHS) ((a),(b),(c),(d),(e),1) #define LAPACKlange_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lange,LANGE) ((a),(b),(c),(d),(e),(f),1) #define LAPACKggevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac) SLEPC_BLASLAPACK(ggevx,GGEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),(z),(aa),(ab),(ac),1,1,1,1) #define LAPACKggev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(ggev,GGEV) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,1) #define LAPACKpbtrf_(a,b,c,d,e,f) SLEPC_BLASLAPACK(pbtrf,PBTRF) ((a),(b),(c),(d),(e),(f),1) #define LAPACKlarf_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(larf,LARF) ((a),(b),(c),(d),(e),(f),(g),(h),(i),1) #define BLAStrmm_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(trmm,TRMM) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),1,1,1,1) #define LAPACKlacpy_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(lacpy,LACPY) ((a),(b),(c),(d),(e),(f),(g),1) #define LAPACKlascl_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(lascl,LASCL) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1) #define LAPACKlansy_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lansy,LANSY) ((a),(b),(c),(d),(e),(f),1,1) #define LAPACKlaset_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(laset,LASET) ((a),(b),(c),(d),(e),(f),(g),1) #define LAPACKtrsyl_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(trsyl,TRSYL) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1) #define LAPACKtrtri_(a,b,c,d,e,f) SLEPC_BLASLAPACK(trtri,TRTRI) ((a),(b),(c),(d),(e),(f),1,1) /* subroutines in which we use only the real version, do not care whether they have different name */ #define LAPACKstevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) SLEPC_BLASLAPACKREAL(stevr,STEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),1,1) #define LAPACKbdsdc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1) #define LAPACKlamch_(a) SLEPC_BLASLAPACKREAL(lamch,LAMCH) ((a),1) #define LAPACKlamc3_(a,b) SLEPC_BLASLAPACKREAL(lamc3,LAMC3) ((a),(b)) #if !defined(PETSC_USE_COMPLEX) /* different name or signature, real */ #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) SLEPC_BLASLAPACK(syevr,SYEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),1,1,1) #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(syevd,SYEVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),1,1) #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(sygvd,SYGVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1) #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(ormlq,ORMLQ) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1) #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(orgtr,ORGTR) ((a),(b),(c),(d),(e),(f),(g),(h),1) #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(sytrd,SYTRD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1) #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(trevc,TREVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1,1) #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,1,1) #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1,1) #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(trexc,TREXC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1) #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),1) #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,1) #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),1,1,1) #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(stedc,STEDC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),1) #else /* different name or signature, complex */ #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(heevr,HEEVR) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,1) #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(heevd,HEEVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1) #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(hegvd,HEGVD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,1) #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(unmlq,UNMLQ) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1,1) #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(ungtr,UNGTR) ((a),(b),(c),(d),(e),(f),(g),(h),1) #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(hetrd,HETRD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),1) #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(trevc,TREVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1,1) #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),1,1,1,1) #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1,1) #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(trexc,TREXC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),1) #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),1) #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,1) #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),1,1,1) #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(stedc,STEDC) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),1) #endif #else /* PETSC_BLASLAPACK_STDCALL */ /* same name for real and complex */ #define LAPACKlanhs_(a,b,c,d,e) SLEPC_BLASLAPACK(lanhs,LANHS) ((a),1,(b),(c),(d),(e)) #define LAPACKlange_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lange,LANGE) ((a),1,(b),(c),(d),(e),(f)) #define LAPACKggevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,ab,ac) SLEPC_BLASLAPACK(ggevx,GGEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),(z),(aa),(ab),(ac)) #define LAPACKggev_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(ggev,GGEV) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q)) #define LAPACKpbtrf_(a,b,c,d,e,f) SLEPC_BLASLAPACK(pbtrf,PBTRF) ((a),1,(b),(c),(d),(e),(f)) #define LAPACKlarf_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(larf,LARF) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i)) #define BLAStrmm_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(trmm,TRMM) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k)) #define LAPACKlacpy_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(lacpy,LACPY) ((a),1,(b),(c),(d),(e),(f),(g)) #define LAPACKlascl_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(lascl,LASCL) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j)) #define LAPACKlansy_(a,b,c,d,e,f) SLEPC_BLASLAPACK(lansy,LANSY) ((a),1,(b),1,(c),(d),(e),(f)) #define LAPACKlaset_(a,b,c,d,e,f,g) SLEPC_BLASLAPACK(laset,LASET) ((a),1,(b),(c),(d),(e),(f),(g)) #define LAPACKtrsyl_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(trsyl,TRSYL) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m)) #define LAPACKtrtri_(a,b,c,d,e,f) SLEPC_BLASLAPACK(trtri,TRTRI) ((a),1,(b),1,(c),(d),(e),(f)) /* subroutines in which we use only the real version, do not care whether they have different name */ #define LAPACKstevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) SLEPC_BLASLAPACKREAL(stevr,STEVR) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t)) #define LAPACKbdsdc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) #define LAPACKlamch_(a) SLEPC_BLASLAPACKREAL(lamch,LAMCH) ((a),1) #define LAPACKlamc3_(a,b) SLEPC_BLASLAPACKREAL(lamc3,LAMC3) ((a),(b)) #if !defined(PETSC_USE_COMPLEX) /* different name or signature, real */ #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) SLEPC_BLASLAPACK(syevr,SYEVR) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u)) #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(syevd,SYEVD) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k)) #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(sygvd,SYGVD) ((a),(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(ormlq,ORMLQ) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m)) #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(orgtr,ORGTR) ((a),1,(b),(c),(d),(e),(f),(g),(h)) #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(sytrd,SYTRD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j)) #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(trevc,TREVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w)) #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o)) #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(trexc,TREXC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j)) #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n)) #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p)) #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s)) #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k) SLEPC_BLASLAPACK(stedc,STEDC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k)) #else /* different name or signature, complex */ #define LAPACKsyevr_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) SLEPC_BLASLAPACK(heevr,HEEVR) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w)) #define LAPACKsyevd_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(heevd,HEEVD) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m)) #define LAPACKsygvd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_BLASLAPACK(hegvd,HEGVD) ((a),(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p)) #define LAPACKormlq_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(unmlq,UNMLQ) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m)) #define LAPACKorgtr_(a,b,c,d,e,f,g,h) SLEPC_BLASLAPACK(ungtr,UNGTR) ((a),1,(b),(c),(d),(e),(f),(g),(h)) #define LAPACKsytrd_(a,b,c,d,e,f,g,h,i,j) SLEPC_BLASLAPACK(hetrd,HETRD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j)) #define LAPACKtrevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(trevc,TREVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o)) #define LAPACKgeevx_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) SLEPC_BLASLAPACK(geevx,GEEVX) ((a),1,(b),1,(c),1,(d),1,(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v)) #define LAPACKgees_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gees,GEES) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o)) #define LAPACKtrexc_(a,b,c,d,e,f,g,h,i) SLEPC_BLASLAPACK(trexc,TREXC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i)) #define LAPACKgesdd_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) SLEPC_BLASLAPACK(gesdd,GESDD) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o)) #define LAPACKtgevc_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_BLASLAPACK(tgevc,TGEVC) ((a),1,(b),1,(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q)) #define LAPACKhsein_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) SLEPC_BLASLAPACK(hsein,HSEIN) ((a),1,(b),1,(c),1,(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s)) #define LAPACKstedc_(a,b,c,d,e,f,g,h,i,j,k,l,m) SLEPC_BLASLAPACK(stedc,STEDC) ((a),1,(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m)) #endif #endif #if !defined(PETSC_BLASLAPACK_STDCALL) /* LAPACK functions without string parameters */ PETSC_EXTERN void SLEPC_BLASLAPACK(laev2,LAEV2) (PetscScalar*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*); PETSC_EXTERN void SLEPC_BLASLAPACK(gehrd,GEHRD) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACK(gelqf,GELQF) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACK(larfg,LARFG) (PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(lag2,LAG2) (PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(lasv2,LASV2) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(lartg,LARTG) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(laln2,LALN2) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(laed4,LAED4) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(lamrg,LAMRG) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACKREAL(lapy2,LAPY2) (PetscReal*,PetscReal*); PETSC_EXTERN void BLASrot_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*); #if !defined(PETSC_USE_COMPLEX) PETSC_EXTERN void SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACK(orghr,ORGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); #else PETSC_EXTERN void SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACK(unghr,UNGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); #endif /* LAPACK functions with string parameters */ PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACK(lanhs,LANHS) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACK(lange,LANGE) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACK(pbtrf,PBTRF) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(larf,LARF) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(trmm,TRMM) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(lacpy,LACPY) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACK(lansy,LANSY) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(laset,LASET) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(trsyl,TRSYL) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(trtri,TRTRI) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(stevr,STEVR) (const char*,const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) (const char*,const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACKREAL(lamch,LAMCH) (const char*,PetscBLASInt); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACKREAL(lamc3,LAMC3) (PetscReal*,PetscReal*); #if !defined(PETSC_USE_COMPLEX) PETSC_EXTERN void SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(ggev,GGEV) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(syevr,SYEVR) (const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(syevd,SYEVD) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(sygvd,SYGVD) (PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(ormlq,ORMLQ) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(orgtr,ORGTR) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(sytrd,SYTRD) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(trevc,TREVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(gees,GEES) (const char*,const char*,PetscBLASInt(*)(PetscReal,PetscReal),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); #else PETSC_EXTERN void SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*, PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(ggev,GGEV) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(heevr,HEEVR) (const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(heevd,HEEVD) (const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(hegvd,HEGVD) (PetscBLASInt*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(unmlq,UNMLQ) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(ungtr,UNGTR) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(hetrd,HETRD) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(trevc,TREVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,const char*,const char*,const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(gees,GEES) (const char*,const char*,PetscBLASInt(*)(PetscScalar),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,const char*,const char*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt,PetscBLASInt,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); PETSC_EXTERN void SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt); #endif #else /* PETSC_BLASLAPACK_STDCALL */ /* LAPACK functions without string parameters */ PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(laev2,LAEV2) (PetscScalar*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gehrd,GEHRD) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gelqf,GELQF) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(larfg,LARFG) (PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lag2,LAG2) (PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lasv2,LASV2) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lartg,LARTG) (PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(laln2,LALN2) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(laed4,LAED4) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(lamrg,LAMRG) (PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN SlepcLRT PETSC_STDCALL SLEPC_BLASLAPACKREAL(lapy2,LAPY2) (PetscReal*,PetscReal*); PETSC_EXTERN void PETSC_STDCALL BLASrot_(PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*); #if !defined(PETSC_USE_COMPLEX) PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(orghr,ORGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); #else PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgexc,TGEXC) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(unghr,UNGHR) (PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geqp3,GEQP3) (PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); #endif /* LAPACK functions with string parameters */ PETSC_EXTERN SlepcLRT PETSC_STDCALL SLEPC_BLASLAPACK(lanhs,LANHS) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*); PETSC_EXTERN SlepcLRT PETSC_STDCALL SLEPC_BLASLAPACK(lange,LANGE) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*); PETSC_EXTERN SlepcLRT PETSC_STDCALL SLEPC_BLASLAPACK(pbtrf,PBTRF) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(larf,LARF) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*); PETSC_EXTERN void SLEPC_BLASLAPACK(trmm,TRMM) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(lacpy,LACPY) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); PETSC_EXTERN SlepcLRT PETSC_STDCALL SLEPC_BLASLAPACK(lansy,LANSY) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(laset,LASET) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trsyl,TRSYL) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trtri,TRTRI) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(stevr,STEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACKREAL(bdsdc,BDSDC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACKREAL(lamch,LAMCH) (const char*,PetscBLASInt); PETSC_EXTERN SlepcLRT SLEPC_BLASLAPACKREAL(lamc3,LAMC3) (PetscReal*,PetscReal*); #if !defined(PETSC_USE_COMPLEX) PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggev,GGEV) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(syevr,SYEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(syevd,SYEVD) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(sygvd,SYGVD) (PetscBLASInt*,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ormlq,ORMLQ) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(orgtr,ORGTR) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(sytrd,SYTRD) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trevc,TREVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gees,GEES) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt(*)(PetscReal,PetscReal),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); #else PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggevx,GGEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*, PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ggev,GGEV) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(heevr,HEEVR) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscBLASInt*, PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(heevd,HEEVD) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hegvd,HEGVD) (PetscBLASInt*,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(unmlq,UNMLQ) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(ungtr,UNGTR) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hetrd,HETRD) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trevc,TREVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(geevx,GEEVX) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gees,GEES) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt(*)(PetscScalar),PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(trexc,TREXC) (const char*,PetscBLASInt,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(gesdd,GESDD) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(tgevc,TGEVC) (const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(hsein,HSEIN) (const char*,PetscBLASInt,const char*,PetscBLASInt,const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(stedc,STEDC) (const char*,PetscBLASInt,PetscBLASInt*,PetscReal*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*); PETSC_EXTERN void PETSC_STDCALL SLEPC_BLASLAPACK(lascl,LASCL) (const char*,PetscBLASInt,PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*); #endif #endif #endif slepc-3.7.4/include/slepcsys.h.html0000644000175000017500000002113713107004621016573 0ustar jromanjroman

Actual source code: slepcsys.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    This include file contains definitions of system functions. It is included
  3:    by all other SLEPc include files.

  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: /*
 30:    slepcconf.h is created by the configure script and placed in ${PETSC_ARCH}/include.
 31:    It contains macro definitions set at configure time.
 32: */
 33: #include <slepcconf.h>
 34: /*
 35:     slepcversion.h contains version info
 36: */
 37: #include <slepcversion.h>
 38: #define SLEPC_AUTHOR_INFO "       The SLEPc Team\n    slepc-maint@upv.es\n http://slepc.upv.es\n"

 40: /* ========================================================================== */
 41: /*
 42:    The PETSc include files.
 43: */
 44: #include <petscmat.h>
 45: /*
 46:     slepcmath.h contains definition of basic math functions
 47: */
 48: #include <slepcmath.h>
 49: /*
 50:     slepcsc.h contains definition of sorting criterion
 51: */
 52: #include <slepcsc.h>

 54: /*
 55:     Creation and destruction of context for monitors of type XXXMonitorConverged
 56: */
 57: typedef struct _n_SlepcConvMonitor* SlepcConvMonitor;
 58: PETSC_EXTERN PetscErrorCode SlepcConvMonitorCreate(PetscViewer,PetscViewerFormat,SlepcConvMonitor*);
 59: PETSC_EXTERN PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor*);

 61: /*
 62:     Initialization of SLEPc and other system routines
 63: */
 64: PETSC_EXTERN PetscErrorCode SlepcInitialize(int*,char***,const char[],const char[]);
 65: PETSC_EXTERN PetscErrorCode SlepcInitializeNoPointers(int,char**,const char[],const char[]);
 66: PETSC_EXTERN PetscErrorCode SlepcInitializeNoArguments(void);
 67: PETSC_EXTERN PetscErrorCode SlepcFinalize(void);
 68: PETSC_EXTERN PetscErrorCode SlepcInitializeFortran(void);
 69: PETSC_EXTERN PetscErrorCode SlepcInitialized(PetscBool*);
 70: PETSC_EXTERN PetscErrorCode SlepcGetVersion(char[],size_t);

 72: PETSC_EXTERN PetscErrorCode SlepcMatConvertSeqDense(Mat,Mat*);
 73: PETSC_EXTERN PetscErrorCode SlepcMatTile(PetscScalar,Mat,PetscScalar,Mat,PetscScalar,Mat,PetscScalar,Mat,Mat*);
 74: PETSC_EXTERN PetscErrorCode SlepcCheckOrthogonality(Vec*,PetscInt,Vec*,PetscInt,Mat,PetscViewer,PetscReal*);
 75: PETSC_EXTERN PetscErrorCode SlepcSNPrintfScalar(char*,size_t,PetscScalar,PetscBool);
 76: PETSC_EXTERN PetscErrorCode SlepcVecNormalize(Vec,Vec,PetscBool,PetscReal*);

 78: PETSC_EXTERN PetscBool SlepcInitializeCalled;

 80: #endif

slepc-3.7.4/include/slepc.h.html0000644000175000017500000000557713107004621016046 0ustar jromanjroman
Actual source code: slepc.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Include all top-level SLEPc functionality.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepcsvd.h>
 25: #include <slepcpep.h>
 26: #include <slepcnep.h>
 27: #include <slepcmfn.h>

slepc-3.7.4/include/slepcsc.h0000644000175000017500000001006413107004621015414 0ustar jromanjroman/* Sorting criterion for various solvers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCSC_H) #define __SLEPCSC_H #include #include /*S SlepcSC - Data structure (C struct) for storing information about the sorting criterion used by different eigensolver objects. The SlepcSC structure contains a mapping function and a comparison function (with associated contexts). The mapping function usually calls ST's backtransform. The comparison function must have the following calling sequence: $ comparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx) + ar - real part of the 1st eigenvalue . ai - imaginary part of the 1st eigenvalue . br - real part of the 2nd eigenvalue . bi - imaginary part of the 2nd eigenvalue . res - result of comparison - ctx - optional context, stored in comparisonctx Note: The returning parameter 'res' can be + negative - if the 1st value is preferred to the 2st one . zero - if both values are equally preferred - positive - if the 2st value is preferred to the 1st one Fortran usage is not supported. Level: developer .seealso: SlepcSCCompare() S*/ struct _n_SlepcSC { /* map values before sorting, typically a call to STBackTransform (mapctx=ST) */ PetscErrorCode (*map)(PetscObject,PetscInt,PetscScalar*,PetscScalar*); PetscObject mapobj; /* comparison function such as SlepcCompareLargestMagnitude */ PetscErrorCode (*comparison)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); void *comparisonctx; /* optional region for filtering */ RG rg; }; typedef struct _n_SlepcSC* SlepcSC; PETSC_EXTERN PetscErrorCode SlepcSCCompare(SlepcSC,PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*); PETSC_EXTERN PetscErrorCode SlepcSortEigenvalues(SlepcSC,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm); PETSC_EXTERN PetscErrorCode SlepcMap_ST(PetscObject,PetscInt,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscErrorCode SlepcCompareLargestMagnitude(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareSmallestMagnitude(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareLargestReal(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareSmallestReal(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareLargestImaginary(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareSmallestImaginary(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareTargetMagnitude(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareTargetReal(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareTargetImaginary(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); PETSC_EXTERN PetscErrorCode SlepcCompareSmallestPosReal(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*); #endif slepc-3.7.4/include/slepcmath.h0000644000175000017500000000524713107004621015747 0ustar jromanjroman/* SLEPc mathematics include file. Defines basic operations and functions. This file is included by slepcsys.h and should not be used directly. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCMATH_H) #define __SLEPCMATH_H /* Default tolerance for the different solvers, depending on the precision */ #if defined(PETSC_USE_REAL_SINGLE) # define SLEPC_DEFAULT_TOL 1e-6 #elif defined(PETSC_USE_REAL_DOUBLE) # define SLEPC_DEFAULT_TOL 1e-8 #elif defined(PETSC_USE_REAL___FLOAT128) # define SLEPC_DEFAULT_TOL 1e-16 #else # define SLEPC_DEFAULT_TOL 1e-7 #endif /*@C SlepcAbs - Returns sqrt(x**2+y**2), taking care not to cause unnecessary overflow. It is based on LAPACK's DLAPY2. Not Collective Input parameters: . x,y - the real numbers Output parameter: . return - the result Note: This function is not available from Fortran. Level: developer @*/ PETSC_STATIC_INLINE PetscReal SlepcAbs(PetscReal x,PetscReal y) { PetscReal w,z,t,xabs=PetscAbs(x),yabs=PetscAbs(y); w = PetscMax(xabs,yabs); z = PetscMin(xabs,yabs); if (z == 0.0) return w; t = z/w; return w*PetscSqrtReal(1.0+t*t); } /*MC SlepcAbsEigenvalue - Returns the absolute value of a complex number given its real and imaginary parts. Synopsis: PetscReal SlepcAbsEigenvalue(PetscScalar x,PetscScalar y) Not Collective Input parameters: + x - the real part of the complex number - y - the imaginary part of the complex number Notes: This function computes sqrt(x**2+y**2), taking care not to cause unnecessary overflow. It is based on LAPACK's DLAPY2. This function is not available from Fortran. Level: developer M*/ #if !defined(PETSC_USE_COMPLEX) #define SlepcAbsEigenvalue(x,y) SlepcAbs(x,y) #else #define SlepcAbsEigenvalue(x,y) PetscAbsScalar(x) #endif #endif slepc-3.7.4/include/slepcst.h0000644000175000017500000001274213107004621015442 0ustar jromanjroman/* Spectral transformation module for eigenvalue problems. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCST_H) #define __SLEPCST_H #include #include #include PETSC_EXTERN PetscErrorCode STInitializePackage(void); /*S ST - Abstract SLEPc object that manages spectral transformations. This object is accessed only in advanced applications. Level: beginner .seealso: STCreate(), EPS S*/ typedef struct _p_ST* ST; /*J STType - String with the name of a SLEPc spectral transformation Level: beginner .seealso: STSetType(), ST J*/ typedef const char* STType; #define STSHELL "shell" #define STSHIFT "shift" #define STSINVERT "sinvert" #define STCAYLEY "cayley" #define STPRECOND "precond" /* Logging support */ PETSC_EXTERN PetscClassId ST_CLASSID; PETSC_EXTERN PetscErrorCode STCreate(MPI_Comm,ST*); PETSC_EXTERN PetscErrorCode STDestroy(ST*); PETSC_EXTERN PetscErrorCode STReset(ST); PETSC_EXTERN PetscErrorCode STSetType(ST,STType); PETSC_EXTERN PetscErrorCode STGetType(ST,STType*); PETSC_EXTERN PetscErrorCode STSetOperators(ST,PetscInt,Mat*); PETSC_EXTERN PetscErrorCode STGetOperators(ST,PetscInt,Mat*); PETSC_EXTERN PetscErrorCode STGetTOperators(ST,PetscInt,Mat*); PETSC_EXTERN PetscErrorCode STGetNumMatrices(ST,PetscInt*); PETSC_EXTERN PetscErrorCode STSetUp(ST); PETSC_EXTERN PetscErrorCode STSetFromOptions(ST); PETSC_EXTERN PetscErrorCode STView(ST,PetscViewer); PETSC_EXTERN PetscErrorCode STApply(ST,Vec,Vec); PETSC_EXTERN PetscErrorCode STMatMult(ST,PetscInt,Vec,Vec); PETSC_EXTERN PetscErrorCode STMatMultTranspose(ST,PetscInt,Vec,Vec); PETSC_EXTERN PetscErrorCode STMatSolve(ST,Vec,Vec); PETSC_EXTERN PetscErrorCode STMatSolveTranspose(ST,Vec,Vec); PETSC_EXTERN PetscErrorCode STGetBilinearForm(ST,Mat*); PETSC_EXTERN PetscErrorCode STApplyTranspose(ST,Vec,Vec); PETSC_EXTERN PetscErrorCode STComputeExplicitOperator(ST,Mat*); PETSC_EXTERN PetscErrorCode STMatSetUp(ST,PetscScalar,PetscScalar*); PETSC_EXTERN PetscErrorCode STPostSolve(ST); PETSC_EXTERN PetscErrorCode STSetKSP(ST,KSP); PETSC_EXTERN PetscErrorCode STGetKSP(ST,KSP*); PETSC_EXTERN PetscErrorCode STSetShift(ST,PetscScalar); PETSC_EXTERN PetscErrorCode STGetShift(ST,PetscScalar*); PETSC_EXTERN PetscErrorCode STSetDefaultShift(ST,PetscScalar); PETSC_EXTERN PetscErrorCode STScaleShift(ST,PetscScalar); PETSC_EXTERN PetscErrorCode STSetBalanceMatrix(ST,Vec); PETSC_EXTERN PetscErrorCode STGetBalanceMatrix(ST,Vec*); PETSC_EXTERN PetscErrorCode STSetTransform(ST,PetscBool); PETSC_EXTERN PetscErrorCode STGetTransform(ST,PetscBool*); PETSC_EXTERN PetscErrorCode STSetOptionsPrefix(ST,const char*); PETSC_EXTERN PetscErrorCode STAppendOptionsPrefix(ST,const char*); PETSC_EXTERN PetscErrorCode STGetOptionsPrefix(ST,const char*[]); PETSC_EXTERN PetscErrorCode STBackTransform(ST,PetscInt,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscErrorCode STCheckNullSpace(ST,BV); PETSC_EXTERN PetscErrorCode STMatCreateVecs(ST,Vec*,Vec*); PETSC_EXTERN PetscErrorCode STMatGetSize(ST,PetscInt*,PetscInt*); PETSC_EXTERN PetscErrorCode STMatGetLocalSize(ST,PetscInt*,PetscInt*); /*E STMatMode - Determines how to handle the coefficient matrix associated to the spectral transformation Level: intermediate .seealso: STSetMatMode(), STGetMatMode() E*/ typedef enum { ST_MATMODE_COPY, ST_MATMODE_INPLACE, ST_MATMODE_SHELL } STMatMode; PETSC_EXTERN PetscErrorCode STSetMatMode(ST,STMatMode); PETSC_EXTERN PetscErrorCode STGetMatMode(ST,STMatMode*); PETSC_EXTERN PetscErrorCode STSetMatStructure(ST,MatStructure); PETSC_EXTERN PetscErrorCode STGetMatStructure(ST,MatStructure*); PETSC_EXTERN PetscFunctionList STList; PETSC_EXTERN PetscErrorCode STRegister(const char[],PetscErrorCode(*)(ST)); /* --------- options specific to particular spectral transformations-------- */ PETSC_EXTERN PetscErrorCode STShellGetContext(ST st,void **ctx); PETSC_EXTERN PetscErrorCode STShellSetContext(ST st,void *ctx); PETSC_EXTERN PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec)); PETSC_EXTERN PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec)); PETSC_EXTERN PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*)); PETSC_EXTERN PetscErrorCode STCayleyGetAntishift(ST,PetscScalar*); PETSC_EXTERN PetscErrorCode STCayleySetAntishift(ST,PetscScalar); PETSC_EXTERN PetscErrorCode STPrecondGetMatForPC(ST,Mat*); PETSC_EXTERN PetscErrorCode STPrecondSetMatForPC(ST,Mat); PETSC_EXTERN PetscErrorCode STPrecondGetKSPHasMat(ST,PetscBool*); PETSC_EXTERN PetscErrorCode STPrecondSetKSPHasMat(ST,PetscBool); #endif slepc-3.7.4/include/slepcsvd.h.html0000644000175000017500000010504613107004621016553 0ustar jromanjroman
Actual source code: slepcsvd.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    User interface for SLEPc's singular value solvers.

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <slepceps.h>
 27: #include <slepcbv.h>
 28: #include <slepcds.h>

 30: PETSC_EXTERN PetscErrorCode SVDInitializePackage(void);

 32: /*S
 33:      SVD - Abstract SLEPc object that manages all the singular value
 34:      problem solvers.

 36:    Level: beginner

 38: .seealso:  SVDCreate()
 39: S*/
 40: typedef struct _p_SVD* SVD;

 42: /*J
 43:     SVDType - String with the name of a SLEPc singular value solver

 45:    Level: beginner

 47: .seealso: SVDSetType(), SVD
 48: J*/
 49: typedef const char* SVDType;
 50: #define SVDCROSS       "cross"
 51: #define SVDCYCLIC      "cyclic"
 52: #define SVDLAPACK      "lapack"
 53: #define SVDLANCZOS     "lanczos"
 54: #define SVDTRLANCZOS   "trlanczos"

 56: /* Logging support */
 57: PETSC_EXTERN PetscClassId SVD_CLASSID;

 59: /*E
 60:     SVDWhich - Determines whether largest or smallest singular triplets
 61:     are to be computed

 63:     Level: intermediate

 65: .seealso: SVDSetWhichSingularTriplets(), SVDGetWhichSingularTriplets()
 66: E*/
 67: typedef enum { SVD_LARGEST,
 68:                SVD_SMALLEST } SVDWhich;

 70: /*E
 71:     SVDErrorType - The error type used to assess accuracy of computed solutions

 73:     Level: intermediate

 75: .seealso: SVDComputeError()
 76: E*/
 77: typedef enum { SVD_ERROR_ABSOLUTE,
 78:                SVD_ERROR_RELATIVE } SVDErrorType;
 79: PETSC_EXTERN const char *SVDErrorTypes[];

 81: /*E
 82:     SVDConv - Determines the convergence test

 84:     Level: intermediate

 86: .seealso: SVDSetConvergenceTest(), SVDSetConvergenceTestFunction()
 87: E*/
 88: typedef enum { SVD_CONV_ABS,
 89:                SVD_CONV_REL,
 90:                SVD_CONV_USER } SVDConv;

 92: /*E
 93:     SVDStop - Determines the stopping test

 95:     Level: advanced

 97: .seealso: SVDSetStoppingTest(), SVDSetStoppingTestFunction()
 98: E*/
 99: typedef enum { SVD_STOP_BASIC,
100:                SVD_STOP_USER } SVDStop;

102: /*E
103:     SVDConvergedReason - Reason a singular value solver was said to
104:          have converged or diverged

106:    Level: intermediate

108: .seealso: SVDSolve(), SVDGetConvergedReason(), SVDSetTolerances()
109: E*/
110: typedef enum {/* converged */
111:               SVD_CONVERGED_TOL                =  1,
112:               SVD_CONVERGED_USER               =  2,
113:               /* diverged */
114:               SVD_DIVERGED_ITS                 = -1,
115:               SVD_DIVERGED_BREAKDOWN           = -2,
116:               SVD_CONVERGED_ITERATING          =  0 } SVDConvergedReason;
117: PETSC_EXTERN const char *const*SVDConvergedReasons;

119: PETSC_EXTERN PetscErrorCode SVDCreate(MPI_Comm,SVD*);
120: PETSC_EXTERN PetscErrorCode SVDSetBV(SVD,BV,BV);
121: PETSC_EXTERN PetscErrorCode SVDGetBV(SVD,BV*,BV*);
122: PETSC_EXTERN PetscErrorCode SVDSetDS(SVD,DS);
123: PETSC_EXTERN PetscErrorCode SVDGetDS(SVD,DS*);
124: PETSC_EXTERN PetscErrorCode SVDSetType(SVD,SVDType);
125: PETSC_EXTERN PetscErrorCode SVDGetType(SVD,SVDType*);
126: PETSC_EXTERN PetscErrorCode SVDSetOperator(SVD,Mat);
127: PETSC_EXTERN PetscErrorCode SVDGetOperator(SVD,Mat*);
128: PETSC_EXTERN PetscErrorCode SVDSetInitialSpace(SVD,PetscInt,Vec*);
129: PETSC_EXTERN PetscErrorCode SVDSetInitialSpaceLeft(SVD,PetscInt,Vec*);
130: PETSC_EXTERN PetscErrorCode SVDSetImplicitTranspose(SVD,PetscBool);
131: PETSC_EXTERN PetscErrorCode SVDGetImplicitTranspose(SVD,PetscBool*);
132: PETSC_EXTERN PetscErrorCode SVDSetDimensions(SVD,PetscInt,PetscInt,PetscInt);
133: PETSC_EXTERN PetscErrorCode SVDGetDimensions(SVD,PetscInt*,PetscInt*,PetscInt*);
134: PETSC_EXTERN PetscErrorCode SVDSetTolerances(SVD,PetscReal,PetscInt);
135: PETSC_EXTERN PetscErrorCode SVDGetTolerances(SVD,PetscReal*,PetscInt*);
136: PETSC_EXTERN PetscErrorCode SVDSetWhichSingularTriplets(SVD,SVDWhich);
137: PETSC_EXTERN PetscErrorCode SVDGetWhichSingularTriplets(SVD,SVDWhich*);
138: PETSC_EXTERN PetscErrorCode SVDSetFromOptions(SVD);
139: PETSC_EXTERN PetscErrorCode SVDSetOptionsPrefix(SVD,const char*);
140: PETSC_EXTERN PetscErrorCode SVDAppendOptionsPrefix(SVD,const char*);
141: PETSC_EXTERN PetscErrorCode SVDGetOptionsPrefix(SVD,const char*[]);
142: PETSC_EXTERN PetscErrorCode SVDSetUp(SVD);
143: PETSC_EXTERN PetscErrorCode SVDSolve(SVD);
144: PETSC_EXTERN PetscErrorCode SVDGetIterationNumber(SVD,PetscInt*);
145: PETSC_EXTERN PetscErrorCode SVDSetConvergenceTestFunction(SVD,PetscErrorCode (*)(SVD,PetscReal,PetscReal,PetscReal*,void*),void*,PetscErrorCode (*)(void*));
146: PETSC_EXTERN PetscErrorCode SVDSetConvergenceTest(SVD,SVDConv);
147: PETSC_EXTERN PetscErrorCode SVDGetConvergenceTest(SVD,SVDConv*);
148: PETSC_EXTERN PetscErrorCode SVDConvergedAbsolute(SVD,PetscReal,PetscReal,PetscReal*,void*);
149: PETSC_EXTERN PetscErrorCode SVDConvergedRelative(SVD,PetscReal,PetscReal,PetscReal*,void*);
150: PETSC_EXTERN PetscErrorCode SVDSetStoppingTestFunction(SVD,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*),void*,PetscErrorCode (*)(void*));
151: PETSC_EXTERN PetscErrorCode SVDSetStoppingTest(SVD,SVDStop);
152: PETSC_EXTERN PetscErrorCode SVDGetStoppingTest(SVD,SVDStop*);
153: PETSC_EXTERN PetscErrorCode SVDStoppingBasic(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*);
154: PETSC_EXTERN PetscErrorCode SVDGetConvergedReason(SVD,SVDConvergedReason*);
155: PETSC_EXTERN PetscErrorCode SVDGetConverged(SVD,PetscInt*);
156: PETSC_EXTERN PetscErrorCode SVDGetSingularTriplet(SVD,PetscInt,PetscReal*,Vec,Vec);
157: PETSC_EXTERN PetscErrorCode SVDComputeError(SVD,PetscInt,SVDErrorType,PetscReal*);
158: PETSC_DEPRECATED("Use SVDComputeError()") PETSC_STATIC_INLINE PetscErrorCode SVDComputeRelativeError(SVD svd,PetscInt i,PetscReal *r) {return SVDComputeError(svd,i,SVD_ERROR_RELATIVE,r);}
159: PETSC_DEPRECATED("Use SVDComputeError() with SVD_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode SVDComputeResidualNorms(SVD svd,PetscInt i,PetscReal *r1,PETSC_UNUSED PetscReal *r2) {return SVDComputeError(svd,i,SVD_ERROR_ABSOLUTE,r1);}
160: PETSC_EXTERN PetscErrorCode SVDView(SVD,PetscViewer);
161: PETSC_STATIC_INLINE PetscErrorCode SVDViewFromOptions(SVD svd,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)svd,obj,name);}
162: PETSC_EXTERN PetscErrorCode SVDErrorView(SVD,SVDErrorType,PetscViewer);
163: PETSC_DEPRECATED("Use SVDErrorView()") PETSC_STATIC_INLINE PetscErrorCode SVDPrintSolution(SVD svd,PetscViewer v) {return SVDErrorView(svd,SVD_ERROR_RELATIVE,v);}
164: PETSC_EXTERN PetscErrorCode SVDErrorViewFromOptions(SVD);
165: PETSC_EXTERN PetscErrorCode SVDReasonView(SVD,PetscViewer);
166: PETSC_EXTERN PetscErrorCode SVDReasonViewFromOptions(SVD);
167: PETSC_EXTERN PetscErrorCode SVDValuesView(SVD,PetscViewer);
168: PETSC_EXTERN PetscErrorCode SVDValuesViewFromOptions(SVD);
169: PETSC_EXTERN PetscErrorCode SVDVectorsView(SVD,PetscViewer);
170: PETSC_EXTERN PetscErrorCode SVDVectorsViewFromOptions(SVD);
171: PETSC_EXTERN PetscErrorCode SVDDestroy(SVD*);
172: PETSC_EXTERN PetscErrorCode SVDReset(SVD);

174: PETSC_EXTERN PetscErrorCode SVDMonitor(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt);
175: PETSC_EXTERN PetscErrorCode SVDMonitorSet(SVD,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void*,PetscErrorCode (*)(void**));
176: PETSC_EXTERN PetscErrorCode SVDMonitorSetFromOptions(SVD,const char*,const char*,const char*,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool);
177: PETSC_EXTERN PetscErrorCode SVDConvMonitorSetFromOptions(SVD,const char*,const char*,const char*,PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor));
178: PETSC_EXTERN PetscErrorCode SVDMonitorCancel(SVD);
179: PETSC_EXTERN PetscErrorCode SVDGetMonitorContext(SVD,void **);
180: PETSC_EXTERN PetscErrorCode SVDMonitorAll(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*);
181: PETSC_EXTERN PetscErrorCode SVDMonitorFirst(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*);
182: PETSC_EXTERN PetscErrorCode SVDMonitorConverged(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor);
183: PETSC_EXTERN PetscErrorCode SVDMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*);
184: PETSC_EXTERN PetscErrorCode SVDMonitorLG(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*);
185: PETSC_EXTERN PetscErrorCode SVDMonitorLGAll(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*);

187: PETSC_EXTERN PetscErrorCode SVDSetTrackAll(SVD,PetscBool);
188: PETSC_EXTERN PetscErrorCode SVDGetTrackAll(SVD,PetscBool*);

190: PETSC_EXTERN PetscErrorCode SVDCrossSetEPS(SVD,EPS);
191: PETSC_EXTERN PetscErrorCode SVDCrossGetEPS(SVD,EPS*);

193: PETSC_EXTERN PetscErrorCode SVDCyclicSetExplicitMatrix(SVD,PetscBool);
194: PETSC_EXTERN PetscErrorCode SVDCyclicGetExplicitMatrix(SVD,PetscBool*);
195: PETSC_EXTERN PetscErrorCode SVDCyclicSetEPS(SVD,EPS);
196: PETSC_EXTERN PetscErrorCode SVDCyclicGetEPS(SVD,EPS*);

198: PETSC_EXTERN PetscErrorCode SVDLanczosSetOneSide(SVD,PetscBool);
199: PETSC_EXTERN PetscErrorCode SVDLanczosGetOneSide(SVD,PetscBool*);

201: PETSC_EXTERN PetscErrorCode SVDTRLanczosSetOneSide(SVD,PetscBool);
202: PETSC_EXTERN PetscErrorCode SVDTRLanczosGetOneSide(SVD,PetscBool*);

204: PETSC_EXTERN PetscFunctionList SVDList;
205: PETSC_EXTERN PetscErrorCode SVDRegister(const char[],PetscErrorCode(*)(SVD));

207: PETSC_EXTERN PetscErrorCode SVDAllocateSolution(SVD,PetscInt);

209: #endif
slepc-3.7.4/include/slepcvec.h0000644000175000017500000000270013107004621015562 0ustar jromanjroman/* User interface for various vector operations added in SLEPc. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCVEC_H) #define __SLEPCVEC_H #include #include /* VecComp: Vec composed of several smaller Vecs */ #define VECCOMP "comp" PETSC_EXTERN PetscErrorCode VecCreateComp(MPI_Comm,PetscInt*,PetscInt,VecType,Vec,Vec*); PETSC_EXTERN PetscErrorCode VecCreateCompWithVecs(Vec*,PetscInt,Vec,Vec*); PETSC_EXTERN PetscErrorCode VecCompGetSubVecs(Vec,PetscInt*,const Vec**); PETSC_EXTERN PetscErrorCode VecCompSetSubVecs(Vec,PetscInt,Vec*); #endif slepc-3.7.4/include/slepcvec.h.html0000644000175000017500000000771113107004621016534 0ustar jromanjroman
Actual source code: slepcvec.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    User interface for various vector operations added in SLEPc.

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <slepcsys.h>
 27: #include <petscmat.h>

 29: /* VecComp: Vec composed of several smaller Vecs */
 30: #define VECCOMP  "comp"

 32: PETSC_EXTERN PetscErrorCode VecCreateComp(MPI_Comm,PetscInt*,PetscInt,VecType,Vec,Vec*);
 33: PETSC_EXTERN PetscErrorCode VecCreateCompWithVecs(Vec*,PetscInt,Vec,Vec*);
 34: PETSC_EXTERN PetscErrorCode VecCompGetSubVecs(Vec,PetscInt*,const Vec**);
 35: PETSC_EXTERN PetscErrorCode VecCompSetSubVecs(Vec,PetscInt,Vec*);

 37: #endif

slepc-3.7.4/include/slepcds.h.html0000644000175000017500000006417213107004621016371 0ustar jromanjroman
Actual source code: slepcds.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */

 24: #include <slepcsc.h>
 25: #include <slepcfn.h>

 27: #define DS_MAX_SOLVE 6

 29: PETSC_EXTERN PetscErrorCode DSInitializePackage(void);
 30: /*S
 31:     DS - Direct solver (or dense system), to represent low-dimensional
 32:     eigenproblems that must be solved within iterative solvers. This is an
 33:     auxiliary object and is not normally needed by application programmers.

 35:     Level: beginner

 37: .seealso:  DSCreate()
 38: S*/
 39: typedef struct _p_DS* DS;

 41: /*J
 42:     DSType - String with the name of the type of direct solver. Roughly,
 43:     there are as many types as problem types are available within SLEPc.

 45:     Level: advanced

 47: .seealso: DSSetType(), DS
 48: J*/
 49: typedef const char* DSType;
 50: #define DSHEP             "hep"
 51: #define DSNHEP            "nhep"
 52: #define DSGHEP            "ghep"
 53: #define DSGHIEP           "ghiep"
 54: #define DSGNHEP           "gnhep"
 55: #define DSSVD             "svd"
 56: #define DSPEP             "pep"
 57: #define DSNEP             "nep"

 59: /* Logging support */
 60: PETSC_EXTERN PetscClassId DS_CLASSID;

 62: /*E
 63:     DSStateType - Indicates in which state the direct solver is

 65:     Level: advanced

 67: .seealso: DSSetState()
 68: E*/
 69: typedef enum { DS_STATE_RAW,
 70:                DS_STATE_INTERMEDIATE,
 71:                DS_STATE_CONDENSED,
 72:                DS_STATE_TRUNCATED } DSStateType;

 74: /*E
 75:     DSMatType - Used to refer to one of the matrices stored internally in DS

 77:     Notes:
 78:     The matrices preferently refer to
 79: +   DS_MAT_A  - first matrix of eigenproblem/singular value problem
 80: .   DS_MAT_B  - second matrix of a generalized eigenproblem
 81: .   DS_MAT_C  - third matrix of a quadratic eigenproblem
 82: .   DS_MAT_T  - tridiagonal matrix
 83: .   DS_MAT_D  - diagonal matrix
 84: .   DS_MAT_Q  - orthogonal matrix of (right) Schur vectors
 85: .   DS_MAT_Z  - orthogonal matrix of left Schur vectors
 86: .   DS_MAT_X  - right eigenvectors
 87: .   DS_MAT_Y  - left eigenvectors
 88: .   DS_MAT_U  - left singular vectors
 89: .   DS_MAT_VT - right singular vectors
 90: .   DS_MAT_W  - workspace matrix
 91: -   DS_MAT_Ex - extra matrices (x=0,..,9)

 93:     All matrices can have space to hold ld x ld elements, except for
 94:     DS_MAT_T that has space for 3 x ld elements (ld = leading dimension)
 95:     and DS_MAT_D that has space for just ld elements.

 97:     In DSPEP problems, matrices A, B, W can have space for d*ld x d*ld,
 98:     where d is the polynomial degree, and X can have ld x d*ld.

100:     Level: advanced

102: .seealso: DSAllocate(), DSGetArray(), DSGetArrayReal(), DSVectors()
103: E*/
104: typedef enum { DS_MAT_A,
105:                DS_MAT_B,
106:                DS_MAT_C,
107:                DS_MAT_T,
108:                DS_MAT_D,
109:                DS_MAT_Q,
110:                DS_MAT_Z,
111:                DS_MAT_X,
112:                DS_MAT_Y,
113:                DS_MAT_U,
114:                DS_MAT_VT,
115:                DS_MAT_W,
116:                DS_MAT_E0,
117:                DS_MAT_E1,
118:                DS_MAT_E2,
119:                DS_MAT_E3,
120:                DS_MAT_E4,
121:                DS_MAT_E5,
122:                DS_MAT_E6,
123:                DS_MAT_E7,
124:                DS_MAT_E8,
125:                DS_MAT_E9,
126:                DS_NUM_MAT } DSMatType;

128: /* Convenience for indexing extra matrices */
129: PETSC_EXTERN DSMatType DSMatExtra[];
130: #define DS_NUM_EXTRA  10

132: PETSC_EXTERN PetscErrorCode DSCreate(MPI_Comm,DS*);
133: PETSC_EXTERN PetscErrorCode DSSetType(DS,DSType);
134: PETSC_EXTERN PetscErrorCode DSGetType(DS,DSType*);
135: PETSC_EXTERN PetscErrorCode DSSetOptionsPrefix(DS,const char *);
136: PETSC_EXTERN PetscErrorCode DSAppendOptionsPrefix(DS,const char *);
137: PETSC_EXTERN PetscErrorCode DSGetOptionsPrefix(DS,const char *[]);
138: PETSC_EXTERN PetscErrorCode DSSetFromOptions(DS);
139: PETSC_EXTERN PetscErrorCode DSView(DS,PetscViewer);
140: PETSC_EXTERN PetscErrorCode DSViewMat(DS,PetscViewer,DSMatType);
141: PETSC_EXTERN PetscErrorCode DSDestroy(DS*);
142: PETSC_EXTERN PetscErrorCode DSReset(DS);

144: PETSC_EXTERN PetscErrorCode DSAllocate(DS,PetscInt);
145: PETSC_EXTERN PetscErrorCode DSGetLeadingDimension(DS,PetscInt*);
146: PETSC_EXTERN PetscErrorCode DSSetState(DS,DSStateType);
147: PETSC_EXTERN PetscErrorCode DSGetState(DS,DSStateType*);
148: PETSC_EXTERN PetscErrorCode DSSetDimensions(DS,PetscInt,PetscInt,PetscInt,PetscInt);
149: PETSC_EXTERN PetscErrorCode DSGetDimensions(DS,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
150: PETSC_EXTERN PetscErrorCode DSSetBlockSize(DS,PetscInt);
151: PETSC_EXTERN PetscErrorCode DSGetBlockSize(DS,PetscInt*);
152: PETSC_EXTERN PetscErrorCode DSTruncate(DS,PetscInt);
153: PETSC_EXTERN PetscErrorCode DSSetIdentity(DS,DSMatType);
154: PETSC_EXTERN PetscErrorCode DSSetMethod(DS,PetscInt);
155: PETSC_EXTERN PetscErrorCode DSGetMethod(DS,PetscInt*);
156: PETSC_EXTERN PetscErrorCode DSSetCompact(DS,PetscBool);
157: PETSC_EXTERN PetscErrorCode DSGetCompact(DS,PetscBool*);
158: PETSC_EXTERN PetscErrorCode DSSetExtraRow(DS,PetscBool);
159: PETSC_EXTERN PetscErrorCode DSGetExtraRow(DS,PetscBool*);
160: PETSC_EXTERN PetscErrorCode DSSetRefined(DS,PetscBool);
161: PETSC_EXTERN PetscErrorCode DSGetRefined(DS,PetscBool*);
162: PETSC_EXTERN PetscErrorCode DSGetMat(DS,DSMatType,Mat*);
163: PETSC_EXTERN PetscErrorCode DSRestoreMat(DS,DSMatType,Mat*);
164: PETSC_EXTERN PetscErrorCode DSGetArray(DS,DSMatType,PetscScalar*[]);
165: PETSC_EXTERN PetscErrorCode DSRestoreArray(DS,DSMatType,PetscScalar*[]);
166: PETSC_EXTERN PetscErrorCode DSGetArrayReal(DS,DSMatType,PetscReal*[]);
167: PETSC_EXTERN PetscErrorCode DSRestoreArrayReal(DS,DSMatType,PetscReal*[]);
168: PETSC_EXTERN PetscErrorCode DSVectors(DS,DSMatType,PetscInt*,PetscReal*);
169: PETSC_EXTERN PetscErrorCode DSSolve(DS,PetscScalar*,PetscScalar*);
170: PETSC_EXTERN PetscErrorCode DSSort(DS,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*);
171: PETSC_EXTERN PetscErrorCode DSCopyMat(DS,DSMatType,PetscInt,PetscInt,Mat,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool);
172: PETSC_EXTERN PetscErrorCode DSSetSlepcSC(DS,SlepcSC);
173: PETSC_EXTERN PetscErrorCode DSGetSlepcSC(DS,SlepcSC*);
174: PETSC_EXTERN PetscErrorCode DSUpdateExtraRow(DS);
175: PETSC_EXTERN PetscErrorCode DSCond(DS,PetscReal*);
176: PETSC_EXTERN PetscErrorCode DSTranslateHarmonic(DS,PetscScalar,PetscReal,PetscBool,PetscScalar*,PetscReal*);
177: PETSC_EXTERN PetscErrorCode DSTranslateRKS(DS,PetscScalar);
178: PETSC_EXTERN PetscErrorCode DSNormalize(DS,DSMatType,PetscInt);
179: PETSC_EXTERN PetscErrorCode DSOrthogonalize(DS,DSMatType,PetscInt,PetscInt*);
180: PETSC_EXTERN PetscErrorCode DSPseudoOrthogonalize(DS,DSMatType,PetscInt,PetscReal*,PetscInt*,PetscReal*);

182: /* --------- options specific to particular solvers -------- */

184: PETSC_EXTERN PetscErrorCode DSPEPSetDegree(DS,PetscInt);
185: PETSC_EXTERN PetscErrorCode DSPEPGetDegree(DS,PetscInt*);

187: PETSC_EXTERN PetscErrorCode DSNEPSetFN(DS,PetscInt,FN*);
188: PETSC_EXTERN PetscErrorCode DSNEPGetFN(DS,PetscInt,FN*);
189: PETSC_EXTERN PetscErrorCode DSNEPGetNumFN(DS,PetscInt*);

191: PETSC_EXTERN PetscFunctionList DSList;
192: PETSC_EXTERN PetscErrorCode DSRegister(const char[],PetscErrorCode(*)(DS));

194: #endif
slepc-3.7.4/include/slepcversion.h.html0000644000175000017500000001112213107004621017433 0ustar jromanjroman
Actual source code: slepcversion.h

slepc-3.7.4 2017-05-17
4: #define SLEPC_VERSION_RELEASE 1 5: #define SLEPC_VERSION_MAJOR 3 6: #define SLEPC_VERSION_MINOR 7 7: #define SLEPC_VERSION_SUBMINOR 4 8: #define SLEPC_VERSION_PATCH 0 9: #define SLEPC_RELEASE_DATE "May 16, 2016" 10: #define SLEPC_VERSION_DATE "unknown" 12: #if !defined (SLEPC_VERSION_GIT) 13: #define SLEPC_VERSION_GIT "unknown" 14: #endif 16: #if !defined(SLEPC_VERSION_DATE_GIT) 17: #define SLEPC_VERSION_DATE_GIT "unknown" 18: #endif 20: #define SLEPC_VERSION_(MAJOR,MINOR,SUBMINOR) \ 21: ((SLEPC_VERSION_MAJOR == (MAJOR)) && \ 22: (SLEPC_VERSION_MINOR == (MINOR)) && \ 23: (SLEPC_VERSION_SUBMINOR == (SUBMINOR)) && \ 24: (SLEPC_VERSION_RELEASE == 1)) 26: #define SLEPC_VERSION_LT(MAJOR,MINOR,SUBMINOR) \ 27: (SLEPC_VERSION_RELEASE == 1 && \ 28: (SLEPC_VERSION_MAJOR < (MAJOR) || \ 29: (SLEPC_VERSION_MAJOR == (MAJOR) && \ 30: (SLEPC_VERSION_MINOR < (MINOR) || \ 31: (SLEPC_VERSION_MINOR == (MINOR) && \ 32: (SLEPC_VERSION_SUBMINOR < (SUBMINOR))))))) 34: #define SLEPC_VERSION_LE(MAJOR,MINOR,SUBMINOR) \ 35: (SLEPC_VERSION_LT(MAJOR,MINOR,SUBMINOR) || \ 36: SLEPC_VERSION_(MAJOR,MINOR,SUBMINOR)) 38: #define SLEPC_VERSION_GT(MAJOR,MINOR,SUBMINOR) \ 39: (0 == SLEPC_VERSION_LE(MAJOR,MINOR,SUBMINOR)) 41: #define SLEPC_VERSION_GE(MAJOR,MINOR,SUBMINOR) \ 42: (0 == SLEPC_VERSION_LT(MAJOR,MINOR,SUBMINOR)) 44: #endif slepc-3.7.4/include/slepcfn.h0000644000175000017500000000703013107004621015411 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__SLEPCFN_H) #define __SLEPCFN_H #include PETSC_EXTERN PetscErrorCode FNInitializePackage(void); /*S FN - Abstraction of a mathematical function. Level: beginner .seealso: FNCreate() S*/ typedef struct _p_FN* FN; /*J FNType - String with the name of the mathematical function. Level: beginner .seealso: FNSetType(), FN J*/ typedef const char* FNType; #define FNCOMBINE "combine" #define FNRATIONAL "rational" #define FNEXP "exp" #define FNLOG "log" #define FNPHI "phi" #define FNSQRT "sqrt" #define FNINVSQRT "invsqrt" /* Logging support */ PETSC_EXTERN PetscClassId FN_CLASSID; /*E FNCombineType - Determines how two functions are combined Level: advanced .seealso: FNCombineSetChildren() E*/ typedef enum { FN_COMBINE_ADD, FN_COMBINE_MULTIPLY, FN_COMBINE_DIVIDE, FN_COMBINE_COMPOSE } FNCombineType; PETSC_EXTERN PetscErrorCode FNCreate(MPI_Comm,FN*); PETSC_EXTERN PetscErrorCode FNSetType(FN,FNType); PETSC_EXTERN PetscErrorCode FNGetType(FN,FNType*); PETSC_EXTERN PetscErrorCode FNSetOptionsPrefix(FN,const char *); PETSC_EXTERN PetscErrorCode FNAppendOptionsPrefix(FN,const char *); PETSC_EXTERN PetscErrorCode FNGetOptionsPrefix(FN,const char *[]); PETSC_EXTERN PetscErrorCode FNSetFromOptions(FN); PETSC_EXTERN PetscErrorCode FNView(FN,PetscViewer); PETSC_EXTERN PetscErrorCode FNDestroy(FN*); PETSC_EXTERN PetscErrorCode FNDuplicate(FN,MPI_Comm,FN*); PETSC_EXTERN PetscErrorCode FNSetScale(FN,PetscScalar,PetscScalar); PETSC_EXTERN PetscErrorCode FNGetScale(FN,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscErrorCode FNEvaluateFunction(FN,PetscScalar,PetscScalar*); PETSC_EXTERN PetscErrorCode FNEvaluateDerivative(FN,PetscScalar,PetscScalar*); PETSC_EXTERN PetscErrorCode FNEvaluateFunctionMat(FN,Mat,Mat); PETSC_EXTERN PetscErrorCode FNEvaluateFunctionMatVec(FN,Mat,Vec); PETSC_EXTERN PetscFunctionList FNList; PETSC_EXTERN PetscErrorCode FNRegister(const char[],PetscErrorCode(*)(FN)); /* --------- options specific to particular functions -------- */ PETSC_EXTERN PetscErrorCode FNRationalSetNumerator(FN,PetscInt,PetscScalar*); PETSC_EXTERN PetscErrorCode FNRationalGetNumerator(FN,PetscInt*,PetscScalar**); PETSC_EXTERN PetscErrorCode FNRationalSetDenominator(FN,PetscInt,PetscScalar*); PETSC_EXTERN PetscErrorCode FNRationalGetDenominator(FN,PetscInt*,PetscScalar**); PETSC_EXTERN PetscErrorCode FNCombineSetChildren(FN,FNCombineType,FN,FN); PETSC_EXTERN PetscErrorCode FNCombineGetChildren(FN,FNCombineType*,FN*,FN*); PETSC_EXTERN PetscErrorCode FNPhiSetIndex(FN,PetscInt); PETSC_EXTERN PetscErrorCode FNPhiGetIndex(FN,PetscInt*); #endif slepc-3.7.4/include/slepcrg.h.html0000644000175000017500000002720413107004621016366 0ustar jromanjroman
Actual source code: slepcrg.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */

 24: #include <slepcsys.h>
 25: #include <slepcrgtypes.h>

 27: PETSC_EXTERN PetscErrorCode RGInitializePackage(void);

 29: /*J
 30:    RGType - String with the name of the region.

 32:    Level: beginner

 34: .seealso: RGSetType(), RG
 35: J*/
 36: typedef const char* RGType;
 37: #define RGINTERVAL  "interval"
 38: #define RGPOLYGON   "polygon"
 39: #define RGELLIPSE   "ellipse"
 40: #define RGRING      "ring"

 42: /* Logging support */
 43: PETSC_EXTERN PetscClassId RG_CLASSID;

 45: PETSC_EXTERN PetscErrorCode RGCreate(MPI_Comm,RG*);
 46: PETSC_EXTERN PetscErrorCode RGSetType(RG,RGType);
 47: PETSC_EXTERN PetscErrorCode RGGetType(RG,RGType*);
 48: PETSC_EXTERN PetscErrorCode RGSetOptionsPrefix(RG,const char *);
 49: PETSC_EXTERN PetscErrorCode RGAppendOptionsPrefix(RG,const char *);
 50: PETSC_EXTERN PetscErrorCode RGGetOptionsPrefix(RG,const char *[]);
 51: PETSC_EXTERN PetscErrorCode RGSetFromOptions(RG);
 52: PETSC_EXTERN PetscErrorCode RGView(RG,PetscViewer);
 53: PETSC_EXTERN PetscErrorCode RGDestroy(RG*);

 55: PETSC_EXTERN PetscErrorCode RGIsTrivial(RG,PetscBool*);
 56: PETSC_EXTERN PetscErrorCode RGSetComplement(RG,PetscBool);
 57: PETSC_EXTERN PetscErrorCode RGGetComplement(RG,PetscBool*);
 58: PETSC_EXTERN PetscErrorCode RGSetScale(RG,PetscReal);
 59: PETSC_EXTERN PetscErrorCode RGGetScale(RG,PetscReal*);
 60: PETSC_EXTERN PetscErrorCode RGPushScale(RG,PetscReal);
 61: PETSC_EXTERN PetscErrorCode RGPopScale(RG);
 62: PETSC_EXTERN PetscErrorCode RGCheckInside(RG,PetscInt,PetscScalar*,PetscScalar*,PetscInt*);
 63: PETSC_EXTERN PetscErrorCode RGComputeContour(RG,PetscInt,PetscScalar*,PetscScalar*);

 65: PETSC_EXTERN PetscFunctionList RGList;
 66: PETSC_EXTERN PetscErrorCode RGRegister(const char[],PetscErrorCode(*)(RG));

 68: /* --------- options specific to particular regions -------- */

 70: PETSC_EXTERN PetscErrorCode RGEllipseSetParameters(RG,PetscScalar,PetscReal,PetscReal);
 71: PETSC_EXTERN PetscErrorCode RGEllipseGetParameters(RG,PetscScalar*,PetscReal*,PetscReal*);

 73: PETSC_EXTERN PetscErrorCode RGIntervalSetEndpoints(RG,PetscReal,PetscReal,PetscReal,PetscReal);
 74: PETSC_EXTERN PetscErrorCode RGIntervalGetEndpoints(RG,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

 76: PETSC_EXTERN PetscErrorCode RGPolygonSetVertices(RG,PetscInt,PetscScalar*,PetscScalar*);
 77: PETSC_EXTERN PetscErrorCode RGPolygonGetVertices(RG,PetscInt*,PetscScalar**,PetscScalar**);

 79: PETSC_EXTERN PetscErrorCode RGRingSetParameters(RG,PetscScalar,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal);
 80: PETSC_EXTERN PetscErrorCode RGRingGetParameters(RG,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*);

 82: #endif
slepc-3.7.4/include/slepcmath.h.html0000644000175000017500000001616513107004621016713 0ustar jromanjroman
Actual source code: slepcmath.h

slepc-3.7.4 2017-05-17
  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

slepc-3.7.4/include/slepcmfn.h.html0000644000175000017500000004200113107004621016526 0ustar jromanjroman
Actual source code: slepcmfn.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    User interface for the SLEPC matrix function object.

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

  8:    This file is part of SLEPc.

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

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

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

 26: #include <slepcbv.h>
 27: #include <slepcfn.h>

 29: PETSC_EXTERN PetscErrorCode MFNInitializePackage(void);

 31: /*S
 32:     MFN - SLEPc object that encapsulates functionality for matrix functions.

 34:     Level: beginner

 36: .seealso:  MFNCreate()
 37: S*/
 38: typedef struct _p_MFN* MFN;

 40: /*J
 41:     MFNType - String with the name of a method for computing matrix functions.

 43:     Level: beginner

 45: .seealso: MFNSetType(), MFN
 46: J*/
 47: typedef const char* MFNType;
 48: #define MFNKRYLOV   "krylov"
 49: #define MFNEXPOKIT  "expokit"

 51: /* Logging support */
 52: PETSC_EXTERN PetscClassId MFN_CLASSID;

 54: PETSC_EXTERN PetscErrorCode MFNCreate(MPI_Comm,MFN *);
 55: PETSC_EXTERN PetscErrorCode MFNDestroy(MFN*);
 56: PETSC_EXTERN PetscErrorCode MFNReset(MFN);
 57: PETSC_EXTERN PetscErrorCode MFNSetType(MFN,MFNType);
 58: PETSC_EXTERN PetscErrorCode MFNGetType(MFN,MFNType*);
 59: PETSC_EXTERN PetscErrorCode MFNSetOperator(MFN,Mat);
 60: PETSC_EXTERN PetscErrorCode MFNGetOperator(MFN,Mat*);
 61: PETSC_EXTERN PetscErrorCode MFNSetFromOptions(MFN);
 62: PETSC_EXTERN PetscErrorCode MFNSetUp(MFN);
 63: PETSC_EXTERN PetscErrorCode MFNSolve(MFN,Vec,Vec);
 64: PETSC_EXTERN PetscErrorCode MFNView(MFN,PetscViewer);
 65: PETSC_STATIC_INLINE PetscErrorCode MFNViewFromOptions(MFN mfn,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)mfn,obj,name);}
 66: PETSC_EXTERN PetscErrorCode MFNReasonView(MFN,PetscViewer);
 67: PETSC_EXTERN PetscErrorCode MFNReasonViewFromOptions(MFN);

 69: PETSC_EXTERN PetscErrorCode MFNSetBV(MFN,BV);
 70: PETSC_EXTERN PetscErrorCode MFNGetBV(MFN,BV*);
 71: PETSC_EXTERN PetscErrorCode MFNSetFN(MFN,FN);
 72: PETSC_EXTERN PetscErrorCode MFNGetFN(MFN,FN*);
 73: PETSC_EXTERN PetscErrorCode MFNSetTolerances(MFN,PetscReal,PetscInt);
 74: PETSC_EXTERN PetscErrorCode MFNGetTolerances(MFN,PetscReal*,PetscInt*);
 75: PETSC_EXTERN PetscErrorCode MFNSetDimensions(MFN,PetscInt);
 76: PETSC_EXTERN PetscErrorCode MFNGetDimensions(MFN,PetscInt*);

 78: PETSC_EXTERN PetscErrorCode MFNMonitor(MFN,PetscInt,PetscReal);
 79: PETSC_EXTERN PetscErrorCode MFNMonitorSet(MFN,PetscErrorCode (*)(MFN,PetscInt,PetscReal,void*),void*,PetscErrorCode (*)(void**));
 80: PETSC_EXTERN PetscErrorCode MFNMonitorSetFromOptions(MFN,const char*,const char*,const char*,PetscErrorCode (*)(MFN,PetscInt,PetscReal,PetscViewerAndFormat*));
 81: PETSC_EXTERN PetscErrorCode MFNMonitorCancel(MFN);
 82: PETSC_EXTERN PetscErrorCode MFNGetMonitorContext(MFN,void **);
 83: PETSC_EXTERN PetscErrorCode MFNGetIterationNumber(MFN,PetscInt*);

 85: PETSC_EXTERN PetscErrorCode MFNSetErrorIfNotConverged(MFN,PetscBool);
 86: PETSC_EXTERN PetscErrorCode MFNGetErrorIfNotConverged(MFN,PetscBool*);

 88: PETSC_EXTERN PetscErrorCode MFNMonitorDefault(MFN,PetscInt,PetscReal,PetscViewerAndFormat*);
 89: PETSC_EXTERN PetscErrorCode MFNMonitorLGCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscDrawLG*);
 90: PETSC_EXTERN PetscErrorCode MFNMonitorLG(MFN,PetscInt,PetscReal,void*);

 92: PETSC_EXTERN PetscErrorCode MFNSetOptionsPrefix(MFN,const char*);
 93: PETSC_EXTERN PetscErrorCode MFNAppendOptionsPrefix(MFN,const char*);
 94: PETSC_EXTERN PetscErrorCode MFNGetOptionsPrefix(MFN,const char*[]);

 96: /*E
 97:     MFNConvergedReason - reason a matrix function iteration was said to
 98:          have converged or diverged

100:     Level: intermediate

102: .seealso: MFNSolve(), MFNGetConvergedReason(), MFNSetTolerances()
103: E*/
104: typedef enum {/* converged */
105:               MFN_CONVERGED_TOL                =  2,
106:               MFN_CONVERGED_ITS                =  3,
107:               /* diverged */
108:               MFN_DIVERGED_ITS                 = -3,
109:               MFN_DIVERGED_BREAKDOWN           = -4,
110:               MFN_CONVERGED_ITERATING          =  0} MFNConvergedReason;
111: PETSC_EXTERN const char *const*MFNConvergedReasons;

113: PETSC_EXTERN PetscErrorCode MFNGetConvergedReason(MFN,MFNConvergedReason *);

115: PETSC_EXTERN PetscFunctionList MFNList;
116: PETSC_EXTERN PetscErrorCode MFNRegister(const char[],PetscErrorCode(*)(MFN));

118: PETSC_EXTERN PetscErrorCode MFNAllocateSolution(MFN,PetscInt);

120: #endif

slepc-3.7.4/src/0000755000175000017500000000000013107004621012752 5ustar jromanjromanslepc-3.7.4/src/makefile0000644000175000017500000000200413107004621014446 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # DIRS = sys eps svd pep nep mfn LOCDIR = src/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/0000755000175000017500000000000013107004621013532 5ustar jromanjromanslepc-3.7.4/src/mfn/makefile0000644000175000017500000000216513107004621015236 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../include/slepc/private/mfnimpl.h ../../include/slepcmfn.h DIRS = interface impls examples f90-mod LOCDIR = src/mfn/ MANSEC = MFN include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/interface/0000755000175000017500000000000013107004621015472 5ustar jromanjromanslepc-3.7.4/src/mfn/interface/makefile0000644000175000017500000000225613107004621017177 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = mfnmon.c mfnbasic.c mfnregis.c mfnopts.c mfnsetup.c mfnsolve.c dlregismfn.c SOURCEF = SOURCEH = LIBBASE = libslepcmfn DIRS = MANSEC = MFN LOCDIR = src/mfn/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/interface/mfnsetup.c.html0000644000175000017500000003513013107004621020444 0ustar jromanjroman
Actual source code: mfnsetup.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       MFN routines related to problem setup.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/mfnimpl.h>       /*I "slepcmfn.h" I*/

 28: /*@
 29:    MFNSetUp - Sets up all the internal data structures necessary for the
 30:    execution of the matrix function solver.

 32:    Collective on MFN

 34:    Input Parameter:
 35: .  mfn   - matrix function context

 37:    Notes:
 38:    This function need not be called explicitly in most cases, since MFNSolve()
 39:    calls it. It can be useful when one wants to measure the set-up time
 40:    separately from the solve time.

 42:    Level: developer

 44: .seealso: MFNCreate(), MFNSolve(), MFNDestroy()
 45: @*/
 46: PetscErrorCode MFNSetUp(MFN mfn)
 47: {
 49:   PetscInt       N;


 54:   /* reset the convergence flag from the previous solves */
 55:   mfn->reason = MFN_CONVERGED_ITERATING;

 57:   if (mfn->setupcalled) return(0);
 58:   PetscLogEventBegin(MFN_SetUp,mfn,0,0,0);

 60:   /* Set default solver type (MFNSetFromOptions was not called) */
 61:   if (!((PetscObject)mfn)->type_name) {
 62:     MFNSetType(mfn,MFNKRYLOV);
 63:   }
 64:   if (!mfn->fn) { MFNGetFN(mfn,&mfn->fn); }
 65:   if (!((PetscObject)mfn->fn)->type_name) {
 66:     FNSetFromOptions(mfn->fn);
 67:   }

 69:   /* Check problem dimensions */
 70:   if (!mfn->A) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_WRONGSTATE,"MFNSetOperator must be called first");
 71:   MatGetSize(mfn->A,&N,NULL);
 72:   if (mfn->ncv > N) mfn->ncv = N;

 74:   /* call specific solver setup */
 75:   (*mfn->ops->setup)(mfn);

 77:   /* set tolerance if not yet set */
 78:   if (mfn->tol==PETSC_DEFAULT) mfn->tol = SLEPC_DEFAULT_TOL;

 80:   PetscLogEventEnd(MFN_SetUp,mfn,0,0,0);
 81:   mfn->setupcalled = 1;
 82:   return(0);
 83: }

 87: /*@
 88:    MFNSetOperator - Sets the matrix for which the matrix function is to be computed.

 90:    Collective on MFN and Mat

 92:    Input Parameters:
 93: +  mfn - the matrix function context
 94: -  A   - the problem matrix

 96:    Notes:
 97:    It must be called before MFNSetUp(). If it is called again after MFNSetUp() then
 98:    the MFN object is reset.

100:    Level: beginner

102: .seealso: MFNSolve(), MFNSetUp(), MFNReset()
103: @*/
104: PetscErrorCode MFNSetOperator(MFN mfn,Mat A)
105: {
107:   PetscInt       m,n;


114:   MatGetSize(A,&m,&n);
115:   if (m!=n) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_WRONG,"A is a non-square matrix");
116:   if (mfn->setupcalled) { MFNReset(mfn); }
117:   PetscObjectReference((PetscObject)A);
118:   MatDestroy(&mfn->A);
119:   mfn->A = A;
120:   return(0);
121: }

125: /*@
126:    MFNGetOperator - Gets the matrix associated with the MFN object.

128:    Collective on MFN and Mat

130:    Input Parameter:
131: .  mfn - the MFN context

133:    Output Parameters:
134: .  A  - the matrix for which the matrix function is to be computed

136:    Level: intermediate

138: .seealso: MFNSolve(), MFNSetOperator()
139: @*/
140: PetscErrorCode MFNGetOperator(MFN mfn,Mat *A)
141: {
145:   *A = mfn->A;
146:   return(0);
147: }

151: /*@
152:    MFNAllocateSolution - Allocate memory storage for common variables such
153:    as the basis vectors.

155:    Collective on MFN

157:    Input Parameters:
158: +  mfn   - eigensolver context
159: -  extra - number of additional positions, used for methods that require a
160:            working basis slightly larger than ncv

162:    Developers Note:
163:    This is PETSC_EXTERN because it may be required by user plugin MFN
164:    implementations.

166:    Level: developer
167: @*/
168: PetscErrorCode MFNAllocateSolution(MFN mfn,PetscInt extra)
169: {
171:   PetscInt       oldsize,requested;
172:   Vec            t;

175:   requested = mfn->ncv + extra;

177:   /* oldsize is zero if this is the first time setup is called */
178:   BVGetSizes(mfn->V,NULL,NULL,&oldsize);

180:   /* allocate basis vectors */
181:   if (!mfn->V) { MFNGetBV(mfn,&mfn->V); }
182:   if (!oldsize) {
183:     if (!((PetscObject)(mfn->V))->type_name) {
184:       BVSetType(mfn->V,BVSVEC);
185:     }
186:     MatCreateVecs(mfn->A,&t,NULL);
187:     BVSetSizesFromVec(mfn->V,t,requested);
188:     VecDestroy(&t);
189:   } else {
190:     BVResize(mfn->V,requested,PETSC_FALSE);
191:   }
192:   return(0);
193: }

slepc-3.7.4/src/mfn/interface/mfnmon.c0000644000175000017500000002020213107004621017124 0ustar jromanjroman/* MFN routines related to monitors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcmfn.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "MFNMonitor" /* Runs the user provided monitor routines, if any. */ PetscErrorCode MFNMonitor(MFN mfn,PetscInt it,PetscReal errest) { PetscErrorCode ierr; PetscInt i,n = mfn->numbermonitors; PetscFunctionBegin; for (i=0;imonitor[i])(mfn,it,errest,mfn->monitorcontext[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNMonitorSet" /*@C MFNMonitorSet - Sets an ADDITIONAL function to be called at every iteration to monitor convergence. Logically Collective on MFN Input Parameters: + mfn - matrix function context obtained from MFNCreate() . monitor - pointer to function (if this is NULL, it turns off monitoring) . mctx - [optional] context for private data for the monitor routine (use NULL if no context is desired) - monitordestroy - [optional] routine that frees monitor context (may be NULL) Calling Sequence of monitor: $ monitor(MFN mfn,int its,PetscReal errest,void *mctx) + mfn - matrix function context obtained from MFNCreate() . its - iteration number . errest - error estimate - mctx - optional monitoring context, as set by MFNMonitorSet() Options Database Keys: + -mfn_monitor - print the error estimate . -mfn_monitor_lg - sets line graph monitor for the error estimate - -mfn_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to MFNMonitorSet(), but does not cancel those set via the options database. Notes: Several different monitoring routines may be set by calling MFNMonitorSet() multiple times; all will be called in the order in which they were set. Level: intermediate .seealso: MFNMonitorFirst(), MFNMonitorAll(), MFNMonitorCancel() @*/ PetscErrorCode MFNMonitorSet(MFN mfn,PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**)) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); if (mfn->numbermonitors >= MAXMFNMONITORS) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Too many MFN monitors set"); mfn->monitor[mfn->numbermonitors] = monitor; mfn->monitorcontext[mfn->numbermonitors] = (void*)mctx; mfn->monitordestroy[mfn->numbermonitors++] = monitordestroy; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNMonitorCancel" /*@ MFNMonitorCancel - Clears all monitors for an MFN object. Logically Collective on MFN Input Parameters: . mfn - matrix function context obtained from MFNCreate() Options Database Key: . -mfn_monitor_cancel - Cancels all monitors that have been hardwired into a code by calls to MFNMonitorSet(), but does not cancel those set via the options database. Level: intermediate .seealso: MFNMonitorSet() @*/ PetscErrorCode MFNMonitorCancel(MFN mfn) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); for (i=0; inumbermonitors; i++) { if (mfn->monitordestroy[i]) { ierr = (*mfn->monitordestroy[i])(&mfn->monitorcontext[i]);CHKERRQ(ierr); } } mfn->numbermonitors = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetMonitorContext" /*@C MFNGetMonitorContext - Gets the monitor context, as set by MFNMonitorSet() for the FIRST monitor only. Not Collective Input Parameter: . mfn - matrix function context obtained from MFNCreate() Output Parameter: . ctx - monitor context Level: intermediate .seealso: MFNMonitorSet() @*/ PetscErrorCode MFNGetMonitorContext(MFN mfn,void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); *ctx = mfn->monitorcontext[0]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNMonitorDefault" /*@C MFNMonitorDefault - Print the error estimate of the current approximation at each iteration of the matrix function solver. Collective on MFN Input Parameters: + mfn - matrix function context . its - iteration number . errest - error estimate - vf - viewer and format for monitoring Level: intermediate .seealso: MFNMonitorSet() @*/ PetscErrorCode MFNMonitorDefault(MFN mfn,PetscInt its,PetscReal errest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(vf,4); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,4); ierr = PetscViewerPushFormat(viewer,vf->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)mfn)->tablevel);CHKERRQ(ierr); if (its == 1 && ((PetscObject)mfn)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Error estimates for %s solve.\n",((PetscObject)mfn)->prefix);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"%3D MFN Error estimate %14.12e\n",its,(double)errest);CHKERRQ(ierr); ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)mfn)->tablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNMonitorLGCreate" /*@C MFNMonitorLGCreate - Creates a line graph context for use with MFN to monitor convergence. Collective on MPI_Comm Input Parameters: + comm - communicator context . host - the X display to open, or null for the local machine . label - the title to put in the title bar . x, y - the screen coordinates of the upper left coordinate of the window - m, n - the screen width and height in pixels Output Parameter: . lgctx - the drawing context Options Database Keys: . -mfn_monitor_lg - Sets line graph monitor Notes: Use PetscDrawLGDestroy() to destroy this line graph. Level: intermediate .seealso: MFNMonitorSet() @*/ PetscErrorCode MFNMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx) { PetscDraw draw; PetscDrawLG lg; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscDrawCreate(comm,host,label,x,y,m,n,&draw);CHKERRQ(ierr); ierr = PetscDrawSetFromOptions(draw);CHKERRQ(ierr); ierr = PetscDrawLGCreate(draw,1,&lg);CHKERRQ(ierr); ierr = PetscDrawLGSetFromOptions(lg);CHKERRQ(ierr); ierr = PetscDrawDestroy(&draw);CHKERRQ(ierr); *lgctx = lg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNMonitorLG" PetscErrorCode MFNMonitorLG(MFN mfn,PetscInt its,PetscReal errest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscReal x,y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,1);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(mfn->tol)-2,0.0);CHKERRQ(ierr); } x = (PetscReal)its; if (errest > 0.0) y = PetscLog10Real(errest); else y = 0.0; ierr = PetscDrawLGAddPoint(lg,&x,&y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || mfn->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/interface/mfnsolve.c.html0000644000175000017500000003536213107004621020443 0ustar jromanjroman
Actual source code: mfnsolve.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       MFN routines related to the solution process.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/mfnimpl.h>   /*I "slepcmfn.h" I*/

 28: /*@
 29:    MFNSolve - Solves the matrix function problem. Given a vector b, the
 30:    vector x = f(A)*b is returned.

 32:    Collective on MFN

 34:    Input Parameters:
 35: +  mfn - matrix function context obtained from MFNCreate()
 36: -  b   - the right hand side vector

 38:    Output Parameter:
 39: .  x   - the solution (this may be the same vector as b, then b will be
 40:          overwritten with the answer)

 42:    Options Database Keys:
 43: +  -mfn_view - print information about the solver used
 44: .  -mfn_view_mat binary - save the matrix to the default binary viewer
 45: .  -mfn_view_rhs binary - save right hand side vector to the default binary viewer
 46: .  -mfn_view_solution binary - save computed solution vector to the default binary viewer
 47: -  -mfn_converged_reason - print reason for convergence, and number of iterations

 49:    Notes:
 50:    The matrix A is specified with MFNSetOperator().
 51:    The function f is specified with MFNSetFN().

 53:    Level: beginner

 55: .seealso: MFNCreate(), MFNSetUp(), MFNDestroy(), MFNSetTolerances(),
 56:           MFNSetOperator(), MFNSetFN()
 57: @*/
 58: PetscErrorCode MFNSolve(MFN mfn,Vec b,Vec x)
 59: {

 68:   VecLocked(x,3);

 70:   /* call setup */
 71:   MFNSetUp(mfn);
 72:   mfn->its = 0;

 74:   MFNViewFromOptions(mfn,NULL,"-mfn_view_pre");

 76:   /* check nonzero right-hand side */
 77:   VecNorm(b,NORM_2,&mfn->bnorm);
 78:   if (!mfn->bnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Cannot pass a zero b vector to MFNSolve()");

 80:   /* call solver */
 81:   PetscLogEventBegin(MFN_Solve,mfn,b,x,0);
 82:   if (b!=x) { VecLockPush(b); }
 83:   (*mfn->ops->solve)(mfn,b,x);
 84:   if (b!=x) { VecLockPop(b); }
 85:   PetscLogEventEnd(MFN_Solve,mfn,b,x,0);

 87:   if (!mfn->reason) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason");

 89:   if (mfn->errorifnotconverged && mfn->reason < 0) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_NOT_CONVERGED,"MFNSolve has not converged");

 91:   /* various viewers */
 92:   MFNViewFromOptions(mfn,NULL,"-mfn_view");
 93:   MFNReasonViewFromOptions(mfn);
 94:   MatViewFromOptions(mfn->A,(PetscObject)mfn,"-mfn_view_mat");
 95:   VecViewFromOptions(b,(PetscObject)mfn,"-mfn_view_rhs");
 96:   VecViewFromOptions(x,(PetscObject)mfn,"-mfn_view_solution");
 97:   return(0);
 98: }

102: /*@
103:    MFNGetIterationNumber - Gets the current iteration number. If the
104:    call to MFNSolve() is complete, then it returns the number of iterations
105:    carried out by the solution method.

107:    Not Collective

109:    Input Parameter:
110: .  mfn - the matrix function context

112:    Output Parameter:
113: .  its - number of iterations

115:    Level: intermediate

117:    Note:
118:    During the i-th iteration this call returns i-1. If MFNSolve() is
119:    complete, then parameter "its" contains either the iteration number at
120:    which convergence was successfully reached, or failure was detected.
121:    Call MFNGetConvergedReason() to determine if the solver converged or
122:    failed and why.

124: .seealso: MFNGetConvergedReason(), MFNSetTolerances()
125: @*/
126: PetscErrorCode MFNGetIterationNumber(MFN mfn,PetscInt *its)
127: {
131:   *its = mfn->its;
132:   return(0);
133: }

137: /*@
138:    MFNGetConvergedReason - Gets the reason why the MFNSolve() iteration was
139:    stopped.

141:    Not Collective

143:    Input Parameter:
144: .  mfn - the matrix function context

146:    Output Parameter:
147: .  reason - negative value indicates diverged, positive value converged

149:    Notes:

151:    Possible values for reason are
152: +  MFN_CONVERGED_TOL - converged up to tolerance
153: .  MFN_CONVERGED_ITS - solver completed the requested number of steps
154: .  MFN_DIVERGED_ITS - required more than max_it iterations to reach convergence
155: -  MFN_DIVERGED_BREAKDOWN - generic breakdown in method

157:    Can only be called after the call to MFNSolve() is complete.

159:    Basic solvers (e.g. unrestarted Krylov iterations) cannot determine if the
160:    computation is accurate up to the requested tolerance. In that case, the
161:    converged reason is set to MFN_CONVERGED_ITS if the requested number of steps
162:    (for instance, the ncv value in unrestarted Krylov methods) have been
163:    completed successfully.

165:    Level: intermediate

167: .seealso: MFNSetTolerances(), MFNSolve(), MFNConvergedReason, MFNSetErrorIfNotConverged()
168: @*/
169: PetscErrorCode MFNGetConvergedReason(MFN mfn,MFNConvergedReason *reason)
170: {
174:   *reason = mfn->reason;
175:   return(0);
176: }

slepc-3.7.4/src/mfn/interface/mfnopts.c.html0000644000175000017500000011246113107004621020274 0ustar jromanjroman
Actual source code: mfnopts.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       MFN routines related to options that can be set via the command-line
  3:       or procedurally.

  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: */

 25: #include <slepc/private/mfnimpl.h>   /*I "slepcmfn.h" I*/
 26: #include <petscdraw.h>

 30: /*@C
 31:    MFNMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 32:    indicated by the user.

 34:    Collective on MFN

 36:    Input Parameters:
 37: +  mfn      - the eigensolver context
 38: .  name     - the monitor option name
 39: .  help     - message indicating what monitoring is done
 40: .  manual   - manual page for the monitor
 41: .  monitor  - the monitor function, whose context is a PetscViewerAndFormat
 42: -  trackall - whether this monitor tracks all eigenvalues or not

 44:    Level: developer

 46: .seealso: MFNMonitorSet(), MFNSetTrackAll(), MFNConvMonitorSetFromOptions()
 47: @*/
 48: PetscErrorCode MFNMonitorSetFromOptions(MFN mfn,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,PetscViewerAndFormat*))
 49: {
 50:   PetscErrorCode       ierr;
 51:   PetscBool            flg;
 52:   PetscViewer          viewer;
 53:   PetscViewerFormat    format;
 54:   PetscViewerAndFormat *vf;

 57:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)mfn),((PetscObject)mfn)->prefix,name,&viewer,&format,&flg);
 58:   if (flg) {
 59:     PetscViewerAndFormatCreate(viewer,format,&vf);
 60:     PetscObjectDereference((PetscObject)viewer);
 61:     MFNMonitorSet(mfn,(PetscErrorCode (*)(MFN,PetscInt,PetscReal,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
 62:   }
 63:   return(0);
 64: }

 68: /*@
 69:    MFNSetFromOptions - Sets MFN options from the options database.
 70:    This routine must be called before MFNSetUp() if the user is to be
 71:    allowed to set the solver type.

 73:    Collective on MFN

 75:    Input Parameters:
 76: .  mfn - the matrix function context

 78:    Notes:
 79:    To see all options, run your program with the -help option.

 81:    Level: beginner
 82: @*/
 83: PetscErrorCode MFNSetFromOptions(MFN mfn)
 84: {
 86:   char           type[256];
 87:   PetscBool      set,flg,flg1,flg2;
 88:   PetscReal      r;
 89:   PetscInt       i;
 90:   PetscDrawLG    lg;

 94:   MFNRegisterAll();
 95:   PetscObjectOptionsBegin((PetscObject)mfn);
 96:     PetscOptionsFList("-mfn_type","Matrix Function method","MFNSetType",MFNList,(char*)(((PetscObject)mfn)->type_name?((PetscObject)mfn)->type_name:MFNKRYLOV),type,256,&flg);
 97:     if (flg) {
 98:       MFNSetType(mfn,type);
 99:     }
100:     /*
101:       Set the type if it was never set.
102:     */
103:     if (!((PetscObject)mfn)->type_name) {
104:       MFNSetType(mfn,MFNKRYLOV);
105:     }

107:     i = mfn->max_it;
108:     PetscOptionsInt("-mfn_max_it","Maximum number of iterations","MFNSetTolerances",mfn->max_it,&i,&flg1);
109:     if (!flg1) i = PETSC_DEFAULT;
110:     r = mfn->tol;
111:     PetscOptionsReal("-mfn_tol","Tolerance","MFNSetTolerances",mfn->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:mfn->tol,&r,&flg2);
112:     if (flg1 || flg2) {
113:       MFNSetTolerances(mfn,r,i);
114:     }

116:     PetscOptionsInt("-mfn_ncv","Number of basis vectors","MFNSetDimensions",mfn->ncv,&i,&flg);
117:     if (flg) {
118:       MFNSetDimensions(mfn,i);
119:     }

121:     PetscOptionsBool("-mfn_error_if_not_converged","Generate error if solver does not converge","MFNSetErrorIfNotConverged",mfn->errorifnotconverged,&mfn->errorifnotconverged,NULL);

123:     /* -----------------------------------------------------------------------*/
124:     /*
125:       Cancels all monitors hardwired into code before call to MFNSetFromOptions()
126:     */
127:     PetscOptionsBool("-mfn_monitor_cancel","Remove any hardwired monitor routines","MFNMonitorCancel",PETSC_FALSE,&flg,&set);
128:     if (set && flg) {
129:       MFNMonitorCancel(mfn);
130:     }
131:     /*
132:       Text monitors
133:     */
134:     MFNMonitorSetFromOptions(mfn,"-mfn_monitor","Monitor error estimate","MFNMonitorDefault",MFNMonitorDefault);
135:     /*
136:       Line graph monitors
137:     */
138:     PetscOptionsBool("-mfn_monitor_lg","Monitor error estimate graphically","MFNMonitorSet",PETSC_FALSE,&flg,&set);
139:     if (set && flg) {
140:       MFNMonitorLGCreate(PetscObjectComm((PetscObject)mfn),NULL,"Error estimate",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
141:       MFNMonitorSet(mfn,MFNMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
142:     }
143:   /* -----------------------------------------------------------------------*/

145:     PetscOptionsName("-mfn_view","Print detailed information on solver used","MFNView",NULL);

147:     if (mfn->ops->setfromoptions) {
148:       (*mfn->ops->setfromoptions)(PetscOptionsObject,mfn);
149:     }
150:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)mfn);
151:   PetscOptionsEnd();

153:   if (!mfn->V) { MFNGetBV(mfn,&mfn->V); }
154:   BVSetFromOptions(mfn->V);
155:   if (!mfn->fn) { MFNGetFN(mfn,&mfn->fn); }
156:   FNSetFromOptions(mfn->fn);
157:   return(0);
158: }

162: /*@
163:    MFNGetTolerances - Gets the tolerance and maximum iteration count used
164:    by the MFN convergence tests.

166:    Not Collective

168:    Input Parameter:
169: .  mfn - the matrix function context

171:    Output Parameters:
172: +  tol - the convergence tolerance
173: -  maxits - maximum number of iterations

175:    Notes:
176:    The user can specify NULL for any parameter that is not needed.

178:    Level: intermediate

180: .seealso: MFNSetTolerances()
181: @*/
182: PetscErrorCode MFNGetTolerances(MFN mfn,PetscReal *tol,PetscInt *maxits)
183: {
186:   if (tol)    *tol    = mfn->tol;
187:   if (maxits) *maxits = mfn->max_it;
188:   return(0);
189: }

193: /*@
194:    MFNSetTolerances - Sets the tolerance and maximum iteration count used
195:    by the MFN convergence tests.

197:    Logically Collective on MFN

199:    Input Parameters:
200: +  mfn - the matrix function context
201: .  tol - the convergence tolerance
202: -  maxits - maximum number of iterations to use

204:    Options Database Keys:
205: +  -mfn_tol <tol> - Sets the convergence tolerance
206: -  -mfn_max_it <maxits> - Sets the maximum number of iterations allowed

208:    Notes:
209:    Use PETSC_DEFAULT for either argument to assign a reasonably good value.

211:    Level: intermediate

213: .seealso: MFNGetTolerances()
214: @*/
215: PetscErrorCode MFNSetTolerances(MFN mfn,PetscReal tol,PetscInt maxits)
216: {
221:   if (tol == PETSC_DEFAULT) {
222:     mfn->tol = PETSC_DEFAULT;
223:     mfn->setupcalled = 0;
224:   } else {
225:     if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
226:     mfn->tol = tol;
227:   }
228:   if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
229:     mfn->max_it = 0;
230:     mfn->setupcalled = 0;
231:   } else {
232:     if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
233:     mfn->max_it = maxits;
234:   }
235:   return(0);
236: }

240: /*@
241:    MFNGetDimensions - Gets the dimension of the subspace used by the solver.

243:    Not Collective

245:    Input Parameter:
246: .  mfn - the matrix function context

248:    Output Parameter:
249: .  ncv - the maximum dimension of the subspace to be used by the solver

251:    Level: intermediate

253: .seealso: MFNSetDimensions()
254: @*/
255: PetscErrorCode MFNGetDimensions(MFN mfn,PetscInt *ncv)
256: {
260:   *ncv = mfn->ncv;
261:   return(0);
262: }

266: /*@
267:    MFNSetDimensions - Sets the dimension of the subspace to be used by the solver.

269:    Logically Collective on MFN

271:    Input Parameters:
272: +  mfn - the matrix function context
273: -  ncv - the maximum dimension of the subspace to be used by the solver

275:    Options Database Keys:
276: .  -mfn_ncv <ncv> - Sets the dimension of the subspace

278:    Notes:
279:    Use PETSC_DEFAULT for ncv to assign a reasonably good value, which is
280:    dependent on the solution method.

282:    Level: intermediate

284: .seealso: MFNGetDimensions()
285: @*/
286: PetscErrorCode MFNSetDimensions(MFN mfn,PetscInt ncv)
287: {
291:   if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) {
292:     mfn->ncv = 0;
293:   } else {
294:     if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
295:     mfn->ncv = ncv;
296:   }
297:   mfn->setupcalled = 0;
298:   return(0);
299: }

303: /*@
304:    MFNSetErrorIfNotConverged - Causes MFNSolve() to generate an error if the
305:    solver has not converged.

307:    Logically Collective on MFN

309:    Input Parameters:
310: +  mfn - the matrix function context
311: -  flg - PETSC_TRUE indicates you want the error generated

313:    Options Database Keys:
314: .  -mfn_error_if_not_converged - this takes an optional truth value (0/1/no/yes/true/false)

316:    Level: intermediate

318:    Note:
319:    Normally SLEPc continues if the solver fails to converge, you can call
320:    MFNGetConvergedReason() after a MFNSolve() to determine if it has converged.

322: .seealso: MFNGetErrorIfNotConverged()
323: @*/
324: PetscErrorCode MFNSetErrorIfNotConverged(MFN mfn,PetscBool flg)
325: {
329:   mfn->errorifnotconverged = flg;
330:   return(0);
331: }

335: /*@
336:    MFNGetErrorIfNotConverged - Return a flag indicating whether MFNSolve() will
337:    generate an error if the solver does not converge.

339:    Not Collective

341:    Input Parameter:
342: .  mfn - the matrix function context

344:    Output Parameter:
345: .  flag - PETSC_TRUE if it will generate an error, else PETSC_FALSE

347:    Level: intermediate

349: .seealso:  MFNSetErrorIfNotConverged()
350: @*/
351: PetscErrorCode MFNGetErrorIfNotConverged(MFN mfn,PetscBool *flag)
352: {
356:   *flag = mfn->errorifnotconverged;
357:   return(0);
358: }

362: /*@C
363:    MFNSetOptionsPrefix - Sets the prefix used for searching for all
364:    MFN options in the database.

366:    Logically Collective on MFN

368:    Input Parameters:
369: +  mfn - the matrix function context
370: -  prefix - the prefix string to prepend to all MFN option requests

372:    Notes:
373:    A hyphen (-) must NOT be given at the beginning of the prefix name.
374:    The first character of all runtime options is AUTOMATICALLY the
375:    hyphen.

377:    For example, to distinguish between the runtime options for two
378:    different MFN contexts, one could call
379: .vb
380:       MFNSetOptionsPrefix(mfn1,"fun1_")
381:       MFNSetOptionsPrefix(mfn2,"fun2_")
382: .ve

384:    Level: advanced

386: .seealso: MFNAppendOptionsPrefix(), MFNGetOptionsPrefix()
387: @*/
388: PetscErrorCode MFNSetOptionsPrefix(MFN mfn,const char *prefix)
389: {

394:   if (!mfn->V) { MFNGetBV(mfn,&mfn->V); }
395:   BVSetOptionsPrefix(mfn->V,prefix);
396:   if (!mfn->fn) { MFNGetFN(mfn,&mfn->fn); }
397:   FNSetOptionsPrefix(mfn->fn,prefix);
398:   PetscObjectSetOptionsPrefix((PetscObject)mfn,prefix);
399:   return(0);
400: }

404: /*@C
405:    MFNAppendOptionsPrefix - Appends to the prefix used for searching for all
406:    MFN options in the database.

408:    Logically Collective on MFN

410:    Input Parameters:
411: +  mfn - the matrix function context
412: -  prefix - the prefix string to prepend to all MFN option requests

414:    Notes:
415:    A hyphen (-) must NOT be given at the beginning of the prefix name.
416:    The first character of all runtime options is AUTOMATICALLY the hyphen.

418:    Level: advanced

420: .seealso: MFNSetOptionsPrefix(), MFNGetOptionsPrefix()
421: @*/
422: PetscErrorCode MFNAppendOptionsPrefix(MFN mfn,const char *prefix)
423: {

428:   if (!mfn->V) { MFNGetBV(mfn,&mfn->V); }
429:   BVSetOptionsPrefix(mfn->V,prefix);
430:   if (!mfn->fn) { MFNGetFN(mfn,&mfn->fn); }
431:   FNSetOptionsPrefix(mfn->fn,prefix);
432:   PetscObjectAppendOptionsPrefix((PetscObject)mfn,prefix);
433:   return(0);
434: }

438: /*@C
439:    MFNGetOptionsPrefix - Gets the prefix used for searching for all
440:    MFN options in the database.

442:    Not Collective

444:    Input Parameters:
445: .  mfn - the matrix function context

447:    Output Parameters:
448: .  prefix - pointer to the prefix string used is returned

450:    Note:
451:    On the Fortran side, the user should pass in a string 'prefix' of
452:    sufficient length to hold the prefix.

454:    Level: advanced

456: .seealso: MFNSetOptionsPrefix(), MFNAppendOptionsPrefix()
457: @*/
458: PetscErrorCode MFNGetOptionsPrefix(MFN mfn,const char *prefix[])
459: {

465:   PetscObjectGetOptionsPrefix((PetscObject)mfn,prefix);
466:   return(0);
467: }
slepc-3.7.4/src/mfn/interface/mfnbasic.c.html0000644000175000017500000011202413107004621020363 0ustar jromanjroman
Actual source code: mfnbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      The basic MFN routines, Create, View, etc. are here.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/mfnimpl.h>      /*I "slepcmfn.h" I*/

 26: PetscFunctionList MFNList = 0;
 27: PetscBool         MFNRegisterAllCalled = PETSC_FALSE;
 28: PetscClassId      MFN_CLASSID = 0;
 29: PetscLogEvent     MFN_SetUp = 0,MFN_Solve = 0;

 33: /*@C
 34:    MFNView - Prints the MFN data structure.

 36:    Collective on MFN

 38:    Input Parameters:
 39: +  mfn - the matrix function solver context
 40: -  viewer - optional visualization context

 42:    Options Database Key:
 43: .  -mfn_view -  Calls MFNView() at end of MFNSolve()

 45:    Note:
 46:    The available visualization contexts include
 47: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
 48: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
 49:          output where only the first processor opens
 50:          the file.  All other processors send their
 51:          data to the first processor to print.

 53:    The user can open an alternative visualization context with
 54:    PetscViewerASCIIOpen() - output to a specified file.

 56:    Level: beginner

 58: .seealso: PetscViewerASCIIOpen()
 59: @*/
 60: PetscErrorCode MFNView(MFN mfn,PetscViewer viewer)
 61: {
 63:   PetscBool      isascii;

 67:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)mfn));

 71:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
 72:   if (isascii) {
 73:     PetscObjectPrintClassNamePrefixType((PetscObject)mfn,viewer);
 74:     if (mfn->ops->view) {
 75:       PetscViewerASCIIPushTab(viewer);
 76:       (*mfn->ops->view)(mfn,viewer);
 77:       PetscViewerASCIIPopTab(viewer);
 78:     }
 79:     PetscViewerASCIIPrintf(viewer,"  number of column vectors (ncv): %D\n",mfn->ncv);
 80:     PetscViewerASCIIPrintf(viewer,"  maximum number of iterations: %D\n",mfn->max_it);
 81:     PetscViewerASCIIPrintf(viewer,"  tolerance: %g\n",(double)mfn->tol);
 82:   } else {
 83:     if (mfn->ops->view) {
 84:       (*mfn->ops->view)(mfn,viewer);
 85:     }
 86:   }
 87:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);
 88:   if (!mfn->V) { MFNGetFN(mfn,&mfn->fn); }
 89:   FNView(mfn->fn,viewer);
 90:   if (!mfn->V) { MFNGetBV(mfn,&mfn->V); }
 91:   BVView(mfn->V,viewer);
 92:   PetscViewerPopFormat(viewer);
 93:   return(0);
 94: }

 98: /*@C
 99:    MFNReasonView - Displays the reason an MFN solve converged or diverged.

101:    Collective on MFN

103:    Parameter:
104: +  mfn - the matrix function context
105: -  viewer - the viewer to display the reason

107:    Options Database Keys:
108: .  -mfn_converged_reason - print reason for convergence, and number of iterations

110:    Level: intermediate

112: .seealso: MFNSetTolerances(), MFNGetIterationNumber()
113: @*/
114: PetscErrorCode MFNReasonView(MFN mfn,PetscViewer viewer)
115: {
117:   PetscBool      isAscii;

120:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);
121:   if (isAscii) {
122:     PetscViewerASCIIAddTab(viewer,((PetscObject)mfn)->tablevel);
123:     if (mfn->reason > 0) {
124:       PetscViewerASCIIPrintf(viewer,"%s Matrix function solve converged due to %s; iterations %D\n",((PetscObject)mfn)->prefix?((PetscObject)mfn)->prefix:"",MFNConvergedReasons[mfn->reason],mfn->its);
125:     } else {
126:       PetscViewerASCIIPrintf(viewer,"%s Matrix function solve did not converge due to %s; iterations %D\n",((PetscObject)mfn)->prefix?((PetscObject)mfn)->prefix:"",MFNConvergedReasons[mfn->reason],mfn->its);
127:     }
128:     PetscViewerASCIISubtractTab(viewer,((PetscObject)mfn)->tablevel);
129:   }
130:   return(0);
131: }

135: /*@
136:    MFNReasonViewFromOptions - Processes command line options to determine if/how
137:    the MFN converged reason is to be viewed. 

139:    Collective on MFN

141:    Input Parameters:
142: .  mfn - the matrix function context

144:    Level: developer
145: @*/
146: PetscErrorCode MFNReasonViewFromOptions(MFN mfn)
147: {
148:   PetscErrorCode    ierr;
149:   PetscViewer       viewer;
150:   PetscBool         flg;
151:   static PetscBool  incall = PETSC_FALSE;
152:   PetscViewerFormat format;

155:   if (incall) return(0);
156:   incall = PETSC_TRUE;
157:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)mfn),((PetscObject)mfn)->prefix,"-mfn_converged_reason",&viewer,&format,&flg);
158:   if (flg) {
159:     PetscViewerPushFormat(viewer,format);
160:     MFNReasonView(mfn,viewer);
161:     PetscViewerPopFormat(viewer);
162:     PetscViewerDestroy(&viewer);
163:   }
164:   incall = PETSC_FALSE;
165:   return(0);
166: }

170: /*@
171:    MFNCreate - Creates the default MFN context.

173:    Collective on MPI_Comm

175:    Input Parameter:
176: .  comm - MPI communicator

178:    Output Parameter:
179: .  mfn - location to put the MFN context

181:    Note:
182:    The default MFN type is MFNKRYLOV

184:    Level: beginner

186: .seealso: MFNSetUp(), MFNSolve(), MFNDestroy(), MFN
187: @*/
188: PetscErrorCode MFNCreate(MPI_Comm comm,MFN *outmfn)
189: {
191:   MFN            mfn;

195:   *outmfn = 0;
196:   MFNInitializePackage();
197:   SlepcHeaderCreate(mfn,MFN_CLASSID,"MFN","Matrix Function","MFN",comm,MFNDestroy,MFNView);

199:   mfn->A               = NULL;
200:   mfn->fn              = NULL;
201:   mfn->max_it          = 0;
202:   mfn->ncv             = 0;
203:   mfn->tol             = PETSC_DEFAULT;
204:   mfn->errorifnotconverged = PETSC_FALSE;

206:   mfn->numbermonitors  = 0;

208:   mfn->V               = NULL;
209:   mfn->nwork           = 0;
210:   mfn->work            = NULL;
211:   mfn->data            = NULL;

213:   mfn->its             = 0;
214:   mfn->nv              = 0;
215:   mfn->errest          = 0;
216:   mfn->setupcalled     = 0;
217:   mfn->reason          = MFN_CONVERGED_ITERATING;

219:   *outmfn = mfn;
220:   return(0);
221: }

225: /*@C
226:    MFNSetType - Selects the particular solver to be used in the MFN object.

228:    Logically Collective on MFN

230:    Input Parameters:
231: +  mfn  - the matrix function context
232: -  type - a known method

234:    Options Database Key:
235: .  -mfn_type <method> - Sets the method; use -help for a list
236:     of available methods

238:    Notes:
239:    See "slepc/include/slepcmfn.h" for available methods. The default
240:    is MFNKRYLOV

242:    Normally, it is best to use the MFNSetFromOptions() command and
243:    then set the MFN type from the options database rather than by using
244:    this routine.  Using the options database provides the user with
245:    maximum flexibility in evaluating the different available methods.
246:    The MFNSetType() routine is provided for those situations where it
247:    is necessary to set the iterative solver independently of the command
248:    line or options database.

250:    Level: intermediate

252: .seealso: MFNType
253: @*/
254: PetscErrorCode MFNSetType(MFN mfn,MFNType type)
255: {
256:   PetscErrorCode ierr,(*r)(MFN);
257:   PetscBool      match;


263:   PetscObjectTypeCompare((PetscObject)mfn,type,&match);
264:   if (match) return(0);

266:   PetscFunctionListFind(MFNList,type,&r);
267:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown MFN type given: %s",type);

269:   if (mfn->ops->destroy) { (*mfn->ops->destroy)(mfn); }
270:   PetscMemzero(mfn->ops,sizeof(struct _MFNOps));

272:   mfn->setupcalled = 0;
273:   PetscObjectChangeTypeName((PetscObject)mfn,type);
274:   (*r)(mfn);
275:   return(0);
276: }

280: /*@C
281:    MFNGetType - Gets the MFN type as a string from the MFN object.

283:    Not Collective

285:    Input Parameter:
286: .  mfn - the matrix function context

288:    Output Parameter:
289: .  name - name of MFN method

291:    Level: intermediate

293: .seealso: MFNSetType()
294: @*/
295: PetscErrorCode MFNGetType(MFN mfn,MFNType *type)
296: {
300:   *type = ((PetscObject)mfn)->type_name;
301:   return(0);
302: }

306: /*@C
307:    MFNRegister - Adds a method to the matrix function solver package.

309:    Not Collective

311:    Input Parameters:
312: +  name - name of a new user-defined solver
313: -  function - routine to create the solver context

315:    Notes:
316:    MFNRegister() may be called multiple times to add several user-defined solvers.

318:    Sample usage:
319: .vb
320:     MFNRegister("my_solver",MySolverCreate);
321: .ve

323:    Then, your solver can be chosen with the procedural interface via
324: $     MFNSetType(mfn,"my_solver")
325:    or at runtime via the option
326: $     -mfn_type my_solver

328:    Level: advanced

330: .seealso: MFNRegisterAll()
331: @*/
332: PetscErrorCode MFNRegister(const char *name,PetscErrorCode (*function)(MFN))
333: {

337:   PetscFunctionListAdd(&MFNList,name,function);
338:   return(0);
339: }

343: /*@
344:    MFNReset - Resets the MFN context to the setupcalled=0 state and removes any
345:    allocated objects.

347:    Collective on MFN

349:    Input Parameter:
350: .  mfn - matrix function context obtained from MFNCreate()

352:    Level: advanced

354: .seealso: MFNDestroy()
355: @*/
356: PetscErrorCode MFNReset(MFN mfn)
357: {

362:   if (mfn->ops->reset) { (mfn->ops->reset)(mfn); }
363:   mfn->setupcalled = 0;
364:   return(0);
365: }

369: /*@
370:    MFNDestroy - Destroys the MFN context.

372:    Collective on MFN

374:    Input Parameter:
375: .  mfn - matrix function context obtained from MFNCreate()

377:    Level: beginner

379: .seealso: MFNCreate(), MFNSetUp(), MFNSolve()
380: @*/
381: PetscErrorCode MFNDestroy(MFN *mfn)
382: {

386:   if (!*mfn) return(0);
388:   if (--((PetscObject)(*mfn))->refct > 0) { *mfn = 0; return(0); }
389:   MFNReset(*mfn);
390:   if ((*mfn)->ops->destroy) { (*(*mfn)->ops->destroy)(*mfn); }
391:   MatDestroy(&(*mfn)->A);
392:   BVDestroy(&(*mfn)->V);
393:   FNDestroy(&(*mfn)->fn);
394:   MFNMonitorCancel(*mfn);
395:   PetscHeaderDestroy(mfn);
396:   return(0);
397: }

401: /*@
402:    MFNSetBV - Associates a basis vectors object to the matrix function solver.

404:    Collective on MFN

406:    Input Parameters:
407: +  mfn - matrix function context obtained from MFNCreate()
408: -  bv  - the basis vectors object

410:    Note:
411:    Use MFNGetBV() to retrieve the basis vectors context (for example,
412:    to free it at the end of the computations).

414:    Level: advanced

416: .seealso: MFNGetBV()
417: @*/
418: PetscErrorCode MFNSetBV(MFN mfn,BV bv)
419: {

426:   PetscObjectReference((PetscObject)bv);
427:   BVDestroy(&mfn->V);
428:   mfn->V = bv;
429:   PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->V);
430:   return(0);
431: }

435: /*@
436:    MFNGetBV - Obtain the basis vectors object associated to the matrix
437:    function solver.

439:    Not Collective

441:    Input Parameters:
442: .  mfn - matrix function context obtained from MFNCreate()

444:    Output Parameter:
445: .  bv - basis vectors context

447:    Level: advanced

449: .seealso: MFNSetBV()
450: @*/
451: PetscErrorCode MFNGetBV(MFN mfn,BV *bv)
452: {

458:   if (!mfn->V) {
459:     BVCreate(PetscObjectComm((PetscObject)mfn),&mfn->V);
460:     PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->V);
461:   }
462:   *bv = mfn->V;
463:   return(0);
464: }

468: /*@
469:    MFNSetFN - Specifies the function to be computed.

471:    Collective on MFN

473:    Input Parameters:
474: +  mfn - matrix function context obtained from MFNCreate()
475: -  fn  - the math function object

477:    Note:
478:    Use MFNGetFN() to retrieve the math function context (for example,
479:    to free it at the end of the computations).

481:    Level: beginner

483: .seealso: MFNGetFN()
484: @*/
485: PetscErrorCode MFNSetFN(MFN mfn,FN fn)
486: {

493:   PetscObjectReference((PetscObject)fn);
494:   FNDestroy(&mfn->fn);
495:   mfn->fn = fn;
496:   PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->fn);
497:   return(0);
498: }

502: /*@
503:    MFNGetFN - Obtain the math function object associated to the MFN object.

505:    Not Collective

507:    Input Parameters:
508: .  mfn - matrix function context obtained from MFNCreate()

510:    Output Parameter:
511: .  fn - math function context

513:    Level: beginner

515: .seealso: MFNSetFN()
516: @*/
517: PetscErrorCode MFNGetFN(MFN mfn,FN *fn)
518: {

524:   if (!mfn->fn) {
525:     FNCreate(PetscObjectComm((PetscObject)mfn),&mfn->fn);
526:     PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->fn);
527:   }
528:   *fn = mfn->fn;
529:   return(0);
530: }

slepc-3.7.4/src/mfn/interface/mfnregis.c.html0000644000175000017500000001074113107004621020416 0ustar jromanjroman
Actual source code: mfnregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/mfnimpl.h>  /*I "slepcmfn.h" I*/

 24: PETSC_EXTERN PetscErrorCode MFNCreate_Krylov(MFN);
 25: PETSC_EXTERN PetscErrorCode MFNCreate_Expokit(MFN);

 29: /*@C
 30:   MFNRegisterAll - Registers all the matrix functions in the MFN package.

 32:   Not Collective

 34:   Level: advanced

 36: .seealso:  MFNRegister()
 37: @*/
 38: PetscErrorCode MFNRegisterAll(void)
 39: {

 43:   if (MFNRegisterAllCalled) return(0);
 44:   MFNRegisterAllCalled = PETSC_TRUE;
 45:   MFNRegister(MFNKRYLOV,MFNCreate_Krylov);
 46:   MFNRegister(MFNEXPOKIT,MFNCreate_Expokit);
 47:   return(0);
 48: }

slepc-3.7.4/src/mfn/interface/makefile.html0000644000175000017500000000475213107004621020145 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = mfnmon.c mfnbasic.c mfnregis.c mfnopts.c mfnsetup.c mfnsolve.c dlregismfn.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcmfn
DIRS     =
MANSEC   = MFN
LOCDIR   = src/mfn/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/mfn/interface/mfnmon.c.html0000644000175000017500000004624213107004621020103 0ustar jromanjroman
Actual source code: mfnmon.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       MFN routines related to monitors.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/mfnimpl.h>   /*I "slepcmfn.h" I*/
 25: #include <petscdraw.h>

 29: /*
 30:    Runs the user provided monitor routines, if any.
 31: */
 32: PetscErrorCode MFNMonitor(MFN mfn,PetscInt it,PetscReal errest)
 33: {
 35:   PetscInt       i,n = mfn->numbermonitors;

 38:   for (i=0;i<n;i++) {
 39:     (*mfn->monitor[i])(mfn,it,errest,mfn->monitorcontext[i]);
 40:   }
 41:   return(0);
 42: }

 46: /*@C
 47:    MFNMonitorSet - Sets an ADDITIONAL function to be called at every
 48:    iteration to monitor convergence.

 50:    Logically Collective on MFN

 52:    Input Parameters:
 53: +  mfn     - matrix function context obtained from MFNCreate()
 54: .  monitor - pointer to function (if this is NULL, it turns off monitoring)
 55: .  mctx    - [optional] context for private data for the
 56:              monitor routine (use NULL if no context is desired)
 57: -  monitordestroy - [optional] routine that frees monitor context (may be NULL)

 59:    Calling Sequence of monitor:
 60: $   monitor(MFN mfn,int its,PetscReal errest,void *mctx)

 62: +  mfn    - matrix function context obtained from MFNCreate()
 63: .  its    - iteration number
 64: .  errest - error estimate
 65: -  mctx   - optional monitoring context, as set by MFNMonitorSet()

 67:    Options Database Keys:
 68: +    -mfn_monitor        - print the error estimate
 69: .    -mfn_monitor_lg     - sets line graph monitor for the error estimate
 70: -    -mfn_monitor_cancel - cancels all monitors that have been hardwired into
 71:       a code by calls to MFNMonitorSet(), but does not cancel those set via
 72:       the options database.

 74:    Notes:
 75:    Several different monitoring routines may be set by calling
 76:    MFNMonitorSet() multiple times; all will be called in the
 77:    order in which they were set.

 79:    Level: intermediate

 81: .seealso: MFNMonitorFirst(), MFNMonitorAll(), MFNMonitorCancel()
 82: @*/
 83: PetscErrorCode MFNMonitorSet(MFN mfn,PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
 84: {
 87:   if (mfn->numbermonitors >= MAXMFNMONITORS) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Too many MFN monitors set");
 88:   mfn->monitor[mfn->numbermonitors]           = monitor;
 89:   mfn->monitorcontext[mfn->numbermonitors]    = (void*)mctx;
 90:   mfn->monitordestroy[mfn->numbermonitors++]  = monitordestroy;
 91:   return(0);
 92: }

 96: /*@
 97:    MFNMonitorCancel - Clears all monitors for an MFN object.

 99:    Logically Collective on MFN

101:    Input Parameters:
102: .  mfn - matrix function context obtained from MFNCreate()

104:    Options Database Key:
105: .    -mfn_monitor_cancel - Cancels all monitors that have been hardwired
106:       into a code by calls to MFNMonitorSet(),
107:       but does not cancel those set via the options database.

109:    Level: intermediate

111: .seealso: MFNMonitorSet()
112: @*/
113: PetscErrorCode MFNMonitorCancel(MFN mfn)
114: {
116:   PetscInt       i;

120:   for (i=0; i<mfn->numbermonitors; i++) {
121:     if (mfn->monitordestroy[i]) {
122:       (*mfn->monitordestroy[i])(&mfn->monitorcontext[i]);
123:     }
124:   }
125:   mfn->numbermonitors = 0;
126:   return(0);
127: }

131: /*@C
132:    MFNGetMonitorContext - Gets the monitor context, as set by
133:    MFNMonitorSet() for the FIRST monitor only.

135:    Not Collective

137:    Input Parameter:
138: .  mfn - matrix function context obtained from MFNCreate()

140:    Output Parameter:
141: .  ctx - monitor context

143:    Level: intermediate

145: .seealso: MFNMonitorSet()
146: @*/
147: PetscErrorCode MFNGetMonitorContext(MFN mfn,void **ctx)
148: {
151:   *ctx = mfn->monitorcontext[0];
152:   return(0);
153: }

157: /*@C
158:    MFNMonitorDefault - Print the error estimate of the current approximation at each
159:    iteration of the matrix function solver.

161:    Collective on MFN

163:    Input Parameters:
164: +  mfn    - matrix function context
165: .  its    - iteration number
166: .  errest - error estimate
167: -  vf     - viewer and format for monitoring

169:    Level: intermediate

171: .seealso: MFNMonitorSet()
172: @*/
173: PetscErrorCode MFNMonitorDefault(MFN mfn,PetscInt its,PetscReal errest,PetscViewerAndFormat *vf)
174: {
176:   PetscViewer    viewer;

181:   viewer = vf->viewer;
183:   PetscViewerPushFormat(viewer,vf->format);
184:   PetscViewerASCIIAddTab(viewer,((PetscObject)mfn)->tablevel);
185:   if (its == 1 && ((PetscObject)mfn)->prefix) {
186:     PetscViewerASCIIPrintf(viewer,"  Error estimates for %s solve.\n",((PetscObject)mfn)->prefix);
187:   }
188:   PetscViewerASCIIPrintf(viewer,"%3D MFN Error estimate %14.12e\n",its,(double)errest);
189:   PetscViewerASCIISubtractTab(viewer,((PetscObject)mfn)->tablevel);
190:   PetscViewerPopFormat(viewer);
191:   return(0);
192: }

196: /*@C
197:    MFNMonitorLGCreate - Creates a line graph context for use with
198:    MFN to monitor convergence.

200:    Collective on MPI_Comm

202:    Input Parameters:
203: +  comm - communicator context
204: .  host - the X display to open, or null for the local machine
205: .  label - the title to put in the title bar
206: .  x, y - the screen coordinates of the upper left coordinate of
207:           the window
208: -  m, n - the screen width and height in pixels

210:    Output Parameter:
211: .  lgctx - the drawing context

213:    Options Database Keys:
214: .  -mfn_monitor_lg - Sets line graph monitor

216:    Notes:
217:    Use PetscDrawLGDestroy() to destroy this line graph.

219:    Level: intermediate

221: .seealso: MFNMonitorSet()
222: @*/
223: PetscErrorCode MFNMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
224: {
225:   PetscDraw      draw;
226:   PetscDrawLG    lg;

230:   PetscDrawCreate(comm,host,label,x,y,m,n,&draw);
231:   PetscDrawSetFromOptions(draw);
232:   PetscDrawLGCreate(draw,1,&lg);
233:   PetscDrawLGSetFromOptions(lg);
234:   PetscDrawDestroy(&draw);
235:   *lgctx = lg;
236:   return(0);
237: }

241: PetscErrorCode MFNMonitorLG(MFN mfn,PetscInt its,PetscReal errest,void *ctx)
242: {
243:   PetscDrawLG    lg = (PetscDrawLG)ctx;
244:   PetscReal      x,y;

249:   if (its==1) {
250:     PetscDrawLGReset(lg);
251:     PetscDrawLGSetDimension(lg,1);
252:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(mfn->tol)-2,0.0);
253:   }
254:   x = (PetscReal)its;
255:   if (errest > 0.0) y = PetscLog10Real(errest);
256:   else y = 0.0;
257:   PetscDrawLGAddPoint(lg,&x,&y);
258:   if (its <= 20 || !(its % 5) || mfn->reason) {
259:     PetscDrawLGDraw(lg);
260:     PetscDrawLGSave(lg);
261:   }
262:   return(0);
263: }

slepc-3.7.4/src/mfn/interface/mfnopts.c0000644000175000017500000003476213107004621017340 0ustar jromanjroman/* MFN routines related to options that can be set via the command-line or procedurally. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcmfn.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "MFNMonitorSetFromOptions" /*@C MFNMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user. Collective on MFN Input Parameters: + mfn - the eigensolver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor . monitor - the monitor function, whose context is a PetscViewerAndFormat - trackall - whether this monitor tracks all eigenvalues or not Level: developer .seealso: MFNMonitorSet(), MFNSetTrackAll(), MFNConvMonitorSetFromOptions() @*/ PetscErrorCode MFNMonitorSetFromOptions(MFN mfn,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,PetscViewerAndFormat*)) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; PetscViewerAndFormat *vf; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)mfn),((PetscObject)mfn)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerAndFormatCreate(viewer,format,&vf);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = MFNMonitorSet(mfn,(PetscErrorCode (*)(MFN,PetscInt,PetscReal,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetFromOptions" /*@ MFNSetFromOptions - Sets MFN options from the options database. This routine must be called before MFNSetUp() if the user is to be allowed to set the solver type. Collective on MFN Input Parameters: . mfn - the matrix function context Notes: To see all options, run your program with the -help option. Level: beginner @*/ PetscErrorCode MFNSetFromOptions(MFN mfn) { PetscErrorCode ierr; char type[256]; PetscBool set,flg,flg1,flg2; PetscReal r; PetscInt i; PetscDrawLG lg; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); ierr = MFNRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)mfn);CHKERRQ(ierr); ierr = PetscOptionsFList("-mfn_type","Matrix Function method","MFNSetType",MFNList,(char*)(((PetscObject)mfn)->type_name?((PetscObject)mfn)->type_name:MFNKRYLOV),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = MFNSetType(mfn,type);CHKERRQ(ierr); } /* Set the type if it was never set. */ if (!((PetscObject)mfn)->type_name) { ierr = MFNSetType(mfn,MFNKRYLOV);CHKERRQ(ierr); } i = mfn->max_it; ierr = PetscOptionsInt("-mfn_max_it","Maximum number of iterations","MFNSetTolerances",mfn->max_it,&i,&flg1);CHKERRQ(ierr); if (!flg1) i = PETSC_DEFAULT; r = mfn->tol; ierr = PetscOptionsReal("-mfn_tol","Tolerance","MFNSetTolerances",mfn->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:mfn->tol,&r,&flg2);CHKERRQ(ierr); if (flg1 || flg2) { ierr = MFNSetTolerances(mfn,r,i);CHKERRQ(ierr); } ierr = PetscOptionsInt("-mfn_ncv","Number of basis vectors","MFNSetDimensions",mfn->ncv,&i,&flg);CHKERRQ(ierr); if (flg) { ierr = MFNSetDimensions(mfn,i);CHKERRQ(ierr); } ierr = PetscOptionsBool("-mfn_error_if_not_converged","Generate error if solver does not converge","MFNSetErrorIfNotConverged",mfn->errorifnotconverged,&mfn->errorifnotconverged,NULL);CHKERRQ(ierr); /* -----------------------------------------------------------------------*/ /* Cancels all monitors hardwired into code before call to MFNSetFromOptions() */ ierr = PetscOptionsBool("-mfn_monitor_cancel","Remove any hardwired monitor routines","MFNMonitorCancel",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = MFNMonitorCancel(mfn);CHKERRQ(ierr); } /* Text monitors */ ierr = MFNMonitorSetFromOptions(mfn,"-mfn_monitor","Monitor error estimate","MFNMonitorDefault",MFNMonitorDefault);CHKERRQ(ierr); /* Line graph monitors */ ierr = PetscOptionsBool("-mfn_monitor_lg","Monitor error estimate graphically","MFNMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = MFNMonitorLGCreate(PetscObjectComm((PetscObject)mfn),NULL,"Error estimate",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = MFNMonitorSet(mfn,MFNMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); } /* -----------------------------------------------------------------------*/ ierr = PetscOptionsName("-mfn_view","Print detailed information on solver used","MFNView",NULL);CHKERRQ(ierr); if (mfn->ops->setfromoptions) { ierr = (*mfn->ops->setfromoptions)(PetscOptionsObject,mfn);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)mfn);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (!mfn->V) { ierr = MFNGetBV(mfn,&mfn->V);CHKERRQ(ierr); } ierr = BVSetFromOptions(mfn->V);CHKERRQ(ierr); if (!mfn->fn) { ierr = MFNGetFN(mfn,&mfn->fn);CHKERRQ(ierr); } ierr = FNSetFromOptions(mfn->fn);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetTolerances" /*@ MFNGetTolerances - Gets the tolerance and maximum iteration count used by the MFN convergence tests. Not Collective Input Parameter: . mfn - the matrix function context Output Parameters: + tol - the convergence tolerance - maxits - maximum number of iterations Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: MFNSetTolerances() @*/ PetscErrorCode MFNGetTolerances(MFN mfn,PetscReal *tol,PetscInt *maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); if (tol) *tol = mfn->tol; if (maxits) *maxits = mfn->max_it; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetTolerances" /*@ MFNSetTolerances - Sets the tolerance and maximum iteration count used by the MFN convergence tests. Logically Collective on MFN Input Parameters: + mfn - the matrix function context . tol - the convergence tolerance - maxits - maximum number of iterations to use Options Database Keys: + -mfn_tol - Sets the convergence tolerance - -mfn_max_it - Sets the maximum number of iterations allowed Notes: Use PETSC_DEFAULT for either argument to assign a reasonably good value. Level: intermediate .seealso: MFNGetTolerances() @*/ PetscErrorCode MFNSetTolerances(MFN mfn,PetscReal tol,PetscInt maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidLogicalCollectiveReal(mfn,tol,2); PetscValidLogicalCollectiveInt(mfn,maxits,3); if (tol == PETSC_DEFAULT) { mfn->tol = PETSC_DEFAULT; mfn->setupcalled = 0; } else { if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); mfn->tol = tol; } if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) { mfn->max_it = 0; mfn->setupcalled = 0; } else { if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0"); mfn->max_it = maxits; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetDimensions" /*@ MFNGetDimensions - Gets the dimension of the subspace used by the solver. Not Collective Input Parameter: . mfn - the matrix function context Output Parameter: . ncv - the maximum dimension of the subspace to be used by the solver Level: intermediate .seealso: MFNSetDimensions() @*/ PetscErrorCode MFNGetDimensions(MFN mfn,PetscInt *ncv) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(ncv,2); *ncv = mfn->ncv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetDimensions" /*@ MFNSetDimensions - Sets the dimension of the subspace to be used by the solver. Logically Collective on MFN Input Parameters: + mfn - the matrix function context - ncv - the maximum dimension of the subspace to be used by the solver Options Database Keys: . -mfn_ncv - Sets the dimension of the subspace Notes: Use PETSC_DEFAULT for ncv to assign a reasonably good value, which is dependent on the solution method. Level: intermediate .seealso: MFNGetDimensions() @*/ PetscErrorCode MFNSetDimensions(MFN mfn,PetscInt ncv) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidLogicalCollectiveInt(mfn,ncv,2); if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) { mfn->ncv = 0; } else { if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0"); mfn->ncv = ncv; } mfn->setupcalled = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetErrorIfNotConverged" /*@ MFNSetErrorIfNotConverged - Causes MFNSolve() to generate an error if the solver has not converged. Logically Collective on MFN Input Parameters: + mfn - the matrix function context - flg - PETSC_TRUE indicates you want the error generated Options Database Keys: . -mfn_error_if_not_converged - this takes an optional truth value (0/1/no/yes/true/false) Level: intermediate Note: Normally SLEPc continues if the solver fails to converge, you can call MFNGetConvergedReason() after a MFNSolve() to determine if it has converged. .seealso: MFNGetErrorIfNotConverged() @*/ PetscErrorCode MFNSetErrorIfNotConverged(MFN mfn,PetscBool flg) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidLogicalCollectiveBool(mfn,flg,2); mfn->errorifnotconverged = flg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetErrorIfNotConverged" /*@ MFNGetErrorIfNotConverged - Return a flag indicating whether MFNSolve() will generate an error if the solver does not converge. Not Collective Input Parameter: . mfn - the matrix function context Output Parameter: . flag - PETSC_TRUE if it will generate an error, else PETSC_FALSE Level: intermediate .seealso: MFNSetErrorIfNotConverged() @*/ PetscErrorCode MFNGetErrorIfNotConverged(MFN mfn,PetscBool *flag) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(flag,2); *flag = mfn->errorifnotconverged; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetOptionsPrefix" /*@C MFNSetOptionsPrefix - Sets the prefix used for searching for all MFN options in the database. Logically Collective on MFN Input Parameters: + mfn - the matrix function context - prefix - the prefix string to prepend to all MFN option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. For example, to distinguish between the runtime options for two different MFN contexts, one could call .vb MFNSetOptionsPrefix(mfn1,"fun1_") MFNSetOptionsPrefix(mfn2,"fun2_") .ve Level: advanced .seealso: MFNAppendOptionsPrefix(), MFNGetOptionsPrefix() @*/ PetscErrorCode MFNSetOptionsPrefix(MFN mfn,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); if (!mfn->V) { ierr = MFNGetBV(mfn,&mfn->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(mfn->V,prefix);CHKERRQ(ierr); if (!mfn->fn) { ierr = MFNGetFN(mfn,&mfn->fn);CHKERRQ(ierr); } ierr = FNSetOptionsPrefix(mfn->fn,prefix);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)mfn,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNAppendOptionsPrefix" /*@C MFNAppendOptionsPrefix - Appends to the prefix used for searching for all MFN options in the database. Logically Collective on MFN Input Parameters: + mfn - the matrix function context - prefix - the prefix string to prepend to all MFN option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: MFNSetOptionsPrefix(), MFNGetOptionsPrefix() @*/ PetscErrorCode MFNAppendOptionsPrefix(MFN mfn,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); if (!mfn->V) { ierr = MFNGetBV(mfn,&mfn->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(mfn->V,prefix);CHKERRQ(ierr); if (!mfn->fn) { ierr = MFNGetFN(mfn,&mfn->fn);CHKERRQ(ierr); } ierr = FNSetOptionsPrefix(mfn->fn,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)mfn,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetOptionsPrefix" /*@C MFNGetOptionsPrefix - Gets the prefix used for searching for all MFN options in the database. Not Collective Input Parameters: . mfn - the matrix function context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: MFNSetOptionsPrefix(), MFNAppendOptionsPrefix() @*/ PetscErrorCode MFNGetOptionsPrefix(MFN mfn,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)mfn,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/interface/dlregismfn.c.html0000644000175000017500000002336613107004621020745 0ustar jromanjroman
Actual source code: dlregismfn.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/mfnimpl.h>

 24: static PetscBool MFNPackageInitialized = PETSC_FALSE;

 26: const char *const MFNConvergedReasons_Shifted[] = {"DIVERGED_BREAKDOWN","DIVERGED_ITS","","","CONVERGED_ITERATING","","CONVERGED_TOL","CONVERGED_ITS","MFNConvergedReason","MFN_",0};
 27: const char *const*MFNConvergedReasons = MFNConvergedReasons_Shifted + 4;

 31: /*@C
 32:   MFNFinalizePackage - This function destroys everything in the SLEPc interface
 33:   to the MFN package. It is called from SlepcFinalize().

 35:   Level: developer

 37: .seealso: SlepcFinalize()
 38: @*/
 39: PetscErrorCode MFNFinalizePackage(void)
 40: {

 44:   PetscFunctionListDestroy(&MFNList);
 45:   MFNPackageInitialized = PETSC_FALSE;
 46:   MFNRegisterAllCalled  = PETSC_FALSE;
 47:   return(0);
 48: }

 52: /*@C
 53:   MFNInitializePackage - This function initializes everything in the MFN package.
 54:   It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 55:   on the first call to MFNCreate() when using static libraries.

 57:   Level: developer

 59: .seealso: SlepcInitialize()
 60: @*/
 61: PetscErrorCode MFNInitializePackage(void)
 62: {
 63:   char           logList[256];
 64:   char           *className;
 65:   PetscBool      opt;

 69:   if (MFNPackageInitialized) return(0);
 70:   MFNPackageInitialized = PETSC_TRUE;
 71:   /* Register Classes */
 72:   PetscClassIdRegister("Matrix Function",&MFN_CLASSID);
 73:   /* Register Constructors */
 74:   MFNRegisterAll();
 75:   /* Register Events */
 76:   PetscLogEventRegister("MFNSetUp",MFN_CLASSID,&MFN_SetUp);
 77:   PetscLogEventRegister("MFNSolve",MFN_CLASSID,&MFN_Solve);
 78:   /* Process info exclusions */
 79:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 80:   if (opt) {
 81:     PetscStrstr(logList,"mfn",&className);
 82:     if (className) {
 83:       PetscInfoDeactivateClass(MFN_CLASSID);
 84:     }
 85:   }
 86:   /* Process summary exclusions */
 87:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 88:   if (opt) {
 89:     PetscStrstr(logList,"mfn",&className);
 90:     if (className) {
 91:       PetscLogEventDeactivateClass(MFN_CLASSID);
 92:     }
 93:   }
 94:   PetscRegisterFinalize(MFNFinalizePackage);
 95:   return(0);
 96: }

 98: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

102: /*
103:   PetscDLLibraryRegister - This function is called when the dynamic library
104:   it is in is opened.

106:   This one registers all the MFN methods that are in the basic SLEPc libslepcmfn
107:   library.
108:  */
109: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn()
110: {

114:   MFNInitializePackage();
115:   return(0);
116: }
117: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */

slepc-3.7.4/src/mfn/interface/index.html0000644000175000017500000000250313107004621017467 0ustar jromanjroman Matrix Function - MFN
slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

mfnmon.c
mfnbasic.c
mfnregis.c
mfnopts.c
mfnsetup.c
mfnsolve.c
dlregismfn.c
makefile
slepc-3.7.4/src/mfn/interface/ftn-auto/0000755000175000017500000000000013107004621017227 5ustar jromanjromanslepc-3.7.4/src/mfn/interface/ftn-auto/makefile0000644000175000017500000000043513107004621020731 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = mfnbasicf.c mfnsolvef.c mfnoptsf.c mfnsetupf.c mfnmonf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcmfn LOCDIR = src/mfn/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/interface/ftn-auto/mfnbasicf.c0000644000175000017500000000633613107004621021333 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* mfnbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcmfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnreasonviewfromoptions_ MFNREASONVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnreasonviewfromoptions_ mfnreasonviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfncreate_ MFNCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfncreate_ mfncreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnreset_ MFNRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnreset_ mfnreset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfndestroy_ MFNDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfndestroy_ mfndestroy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsetbv_ MFNSETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsetbv_ mfnsetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngetbv_ MFNGETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngetbv_ mfngetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsetfn_ MFNSETFN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsetfn_ mfnsetfn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngetfn_ MFNGETFN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngetfn_ mfngetfn #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL mfnreasonviewfromoptions_(MFN mfn, int *__ierr ){ *__ierr = MFNReasonViewFromOptions( (MFN)PetscToPointer((mfn) )); } PETSC_EXTERN void PETSC_STDCALL mfncreate_(MPI_Fint * comm,MFN *outmfn, int *__ierr ){ *__ierr = MFNCreate( MPI_Comm_f2c(*(comm)),outmfn); } PETSC_EXTERN void PETSC_STDCALL mfnreset_(MFN mfn, int *__ierr ){ *__ierr = MFNReset( (MFN)PetscToPointer((mfn) )); } PETSC_EXTERN void PETSC_STDCALL mfndestroy_(MFN *mfn, int *__ierr ){ *__ierr = MFNDestroy(mfn); } PETSC_EXTERN void PETSC_STDCALL mfnsetbv_(MFN mfn,BV bv, int *__ierr ){ *__ierr = MFNSetBV( (MFN)PetscToPointer((mfn) ), (BV)PetscToPointer((bv) )); } PETSC_EXTERN void PETSC_STDCALL mfngetbv_(MFN mfn,BV *bv, int *__ierr ){ *__ierr = MFNGetBV( (MFN)PetscToPointer((mfn) ),bv); } PETSC_EXTERN void PETSC_STDCALL mfnsetfn_(MFN mfn,FN fn, int *__ierr ){ *__ierr = MFNSetFN( (MFN)PetscToPointer((mfn) ), (FN)PetscToPointer((fn) )); } PETSC_EXTERN void PETSC_STDCALL mfngetfn_(MFN mfn,FN *fn, int *__ierr ){ *__ierr = MFNGetFN( (MFN)PetscToPointer((mfn) ),fn); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/mfn/interface/ftn-auto/mfnsolvef.c0000644000175000017500000000355113107004621021376 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* mfnsolve.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcmfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsolve_ MFNSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsolve_ mfnsolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngetiterationnumber_ MFNGETITERATIONNUMBER #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngetiterationnumber_ mfngetiterationnumber #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngetconvergedreason_ MFNGETCONVERGEDREASON #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngetconvergedreason_ mfngetconvergedreason #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL mfnsolve_(MFN mfn,Vec b,Vec x, int *__ierr ){ *__ierr = MFNSolve( (MFN)PetscToPointer((mfn) ), (Vec)PetscToPointer((b) ), (Vec)PetscToPointer((x) )); } PETSC_EXTERN void PETSC_STDCALL mfngetiterationnumber_(MFN mfn,PetscInt *its, int *__ierr ){ *__ierr = MFNGetIterationNumber( (MFN)PetscToPointer((mfn) ),its); } PETSC_EXTERN void PETSC_STDCALL mfngetconvergedreason_(MFN mfn,MFNConvergedReason *reason, int *__ierr ){ *__ierr = MFNGetConvergedReason( (MFN)PetscToPointer((mfn) ),reason); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/mfn/interface/ftn-auto/mfnoptsf.c0000644000175000017500000000653013107004621021233 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* mfnopts.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcmfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsetfromoptions_ MFNSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsetfromoptions_ mfnsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngettolerances_ MFNGETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngettolerances_ mfngettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsettolerances_ MFNSETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsettolerances_ mfnsettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngetdimensions_ MFNGETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngetdimensions_ mfngetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsetdimensions_ MFNSETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsetdimensions_ mfnsetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnseterrorifnotconverged_ MFNSETERRORIFNOTCONVERGED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnseterrorifnotconverged_ mfnseterrorifnotconverged #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngeterrorifnotconverged_ MFNGETERRORIFNOTCONVERGED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngeterrorifnotconverged_ mfngeterrorifnotconverged #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL mfnsetfromoptions_(MFN mfn, int *__ierr ){ *__ierr = MFNSetFromOptions( (MFN)PetscToPointer((mfn) )); } PETSC_EXTERN void PETSC_STDCALL mfngettolerances_(MFN mfn,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = MFNGetTolerances( (MFN)PetscToPointer((mfn) ),tol,maxits); } PETSC_EXTERN void PETSC_STDCALL mfnsettolerances_(MFN mfn,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = MFNSetTolerances( (MFN)PetscToPointer((mfn) ),*tol,*maxits); } PETSC_EXTERN void PETSC_STDCALL mfngetdimensions_(MFN mfn,PetscInt *ncv, int *__ierr ){ *__ierr = MFNGetDimensions( (MFN)PetscToPointer((mfn) ),ncv); } PETSC_EXTERN void PETSC_STDCALL mfnsetdimensions_(MFN mfn,PetscInt *ncv, int *__ierr ){ *__ierr = MFNSetDimensions( (MFN)PetscToPointer((mfn) ),*ncv); } PETSC_EXTERN void PETSC_STDCALL mfnseterrorifnotconverged_(MFN mfn,PetscBool *flg, int *__ierr ){ *__ierr = MFNSetErrorIfNotConverged( (MFN)PetscToPointer((mfn) ),*flg); } PETSC_EXTERN void PETSC_STDCALL mfngeterrorifnotconverged_(MFN mfn,PetscBool *flag, int *__ierr ){ *__ierr = MFNGetErrorIfNotConverged( (MFN)PetscToPointer((mfn) ),flag); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/mfn/interface/ftn-auto/mfnsetupf.c0000644000175000017500000000411013107004621021376 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* mfnsetup.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcmfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsetup_ MFNSETUP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsetup_ mfnsetup #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnsetoperator_ MFNSETOPERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnsetoperator_ mfnsetoperator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfngetoperator_ MFNGETOPERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfngetoperator_ mfngetoperator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnallocatesolution_ MFNALLOCATESOLUTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnallocatesolution_ mfnallocatesolution #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL mfnsetup_(MFN mfn, int *__ierr ){ *__ierr = MFNSetUp( (MFN)PetscToPointer((mfn) )); } PETSC_EXTERN void PETSC_STDCALL mfnsetoperator_(MFN mfn,Mat A, int *__ierr ){ *__ierr = MFNSetOperator( (MFN)PetscToPointer((mfn) ), (Mat)PetscToPointer((A) )); } PETSC_EXTERN void PETSC_STDCALL mfngetoperator_(MFN mfn,Mat *A, int *__ierr ){ *__ierr = MFNGetOperator( (MFN)PetscToPointer((mfn) ),A); } PETSC_EXTERN void PETSC_STDCALL mfnallocatesolution_(MFN mfn,PetscInt *extra, int *__ierr ){ *__ierr = MFNAllocateSolution( (MFN)PetscToPointer((mfn) ),*extra); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/mfn/interface/ftn-auto/mfnmonf.c0000644000175000017500000000206513107004621021036 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* mfnmon.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcmfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define mfnmonitorcancel_ MFNMONITORCANCEL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define mfnmonitorcancel_ mfnmonitorcancel #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL mfnmonitorcancel_(MFN mfn, int *__ierr ){ *__ierr = MFNMonitorCancel( (MFN)PetscToPointer((mfn) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/mfn/interface/dlregismfn.c0000644000175000017500000000760013107004621017773 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include static PetscBool MFNPackageInitialized = PETSC_FALSE; const char *const MFNConvergedReasons_Shifted[] = {"DIVERGED_BREAKDOWN","DIVERGED_ITS","","","CONVERGED_ITERATING","","CONVERGED_TOL","CONVERGED_ITS","MFNConvergedReason","MFN_",0}; const char *const*MFNConvergedReasons = MFNConvergedReasons_Shifted + 4; #undef __FUNCT__ #define __FUNCT__ "MFNFinalizePackage" /*@C MFNFinalizePackage - This function destroys everything in the SLEPc interface to the MFN package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode MFNFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&MFNList);CHKERRQ(ierr); MFNPackageInitialized = PETSC_FALSE; MFNRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNInitializePackage" /*@C MFNInitializePackage - This function initializes everything in the MFN package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to MFNCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode MFNInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (MFNPackageInitialized) PetscFunctionReturn(0); MFNPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("Matrix Function",&MFN_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = MFNRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("MFNSetUp",MFN_CLASSID,&MFN_SetUp);CHKERRQ(ierr); ierr = PetscLogEventRegister("MFNSolve",MFN_CLASSID,&MFN_Solve);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"mfn",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(MFN_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"mfn",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(MFN_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(MFNFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) #undef __FUNCT__ #define __FUNCT__ "PetscDLLibraryRegister_slepcmfn" /* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the MFN methods that are in the basic SLEPc libslepcmfn library. */ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn() { PetscErrorCode ierr; PetscFunctionBegin; ierr = MFNInitializePackage();CHKERRQ(ierr); PetscFunctionReturn(0); } #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ slepc-3.7.4/src/mfn/interface/mfnsetup.c0000644000175000017500000001306713107004621017506 0ustar jromanjroman/* MFN routines related to problem setup. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcmfn.h" I*/ #undef __FUNCT__ #define __FUNCT__ "MFNSetUp" /*@ MFNSetUp - Sets up all the internal data structures necessary for the execution of the matrix function solver. Collective on MFN Input Parameter: . mfn - matrix function context Notes: This function need not be called explicitly in most cases, since MFNSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time. Level: developer .seealso: MFNCreate(), MFNSolve(), MFNDestroy() @*/ PetscErrorCode MFNSetUp(MFN mfn) { PetscErrorCode ierr; PetscInt N; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); /* reset the convergence flag from the previous solves */ mfn->reason = MFN_CONVERGED_ITERATING; if (mfn->setupcalled) PetscFunctionReturn(0); ierr = PetscLogEventBegin(MFN_SetUp,mfn,0,0,0);CHKERRQ(ierr); /* Set default solver type (MFNSetFromOptions was not called) */ if (!((PetscObject)mfn)->type_name) { ierr = MFNSetType(mfn,MFNKRYLOV);CHKERRQ(ierr); } if (!mfn->fn) { ierr = MFNGetFN(mfn,&mfn->fn);CHKERRQ(ierr); } if (!((PetscObject)mfn->fn)->type_name) { ierr = FNSetFromOptions(mfn->fn);CHKERRQ(ierr); } /* Check problem dimensions */ if (!mfn->A) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_WRONGSTATE,"MFNSetOperator must be called first"); ierr = MatGetSize(mfn->A,&N,NULL);CHKERRQ(ierr); if (mfn->ncv > N) mfn->ncv = N; /* call specific solver setup */ ierr = (*mfn->ops->setup)(mfn);CHKERRQ(ierr); /* set tolerance if not yet set */ if (mfn->tol==PETSC_DEFAULT) mfn->tol = SLEPC_DEFAULT_TOL; ierr = PetscLogEventEnd(MFN_SetUp,mfn,0,0,0);CHKERRQ(ierr); mfn->setupcalled = 1; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetOperator" /*@ MFNSetOperator - Sets the matrix for which the matrix function is to be computed. Collective on MFN and Mat Input Parameters: + mfn - the matrix function context - A - the problem matrix Notes: It must be called before MFNSetUp(). If it is called again after MFNSetUp() then the MFN object is reset. Level: beginner .seealso: MFNSolve(), MFNSetUp(), MFNReset() @*/ PetscErrorCode MFNSetOperator(MFN mfn,Mat A) { PetscErrorCode ierr; PetscInt m,n; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidHeaderSpecific(A,MAT_CLASSID,2); PetscCheckSameComm(mfn,1,A,2); ierr = MatGetSize(A,&m,&n);CHKERRQ(ierr); if (m!=n) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_WRONG,"A is a non-square matrix"); if (mfn->setupcalled) { ierr = MFNReset(mfn);CHKERRQ(ierr); } ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr); ierr = MatDestroy(&mfn->A);CHKERRQ(ierr); mfn->A = A; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetOperator" /*@ MFNGetOperator - Gets the matrix associated with the MFN object. Collective on MFN and Mat Input Parameter: . mfn - the MFN context Output Parameters: . A - the matrix for which the matrix function is to be computed Level: intermediate .seealso: MFNSolve(), MFNSetOperator() @*/ PetscErrorCode MFNGetOperator(MFN mfn,Mat *A) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(A,2); *A = mfn->A; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNAllocateSolution" /*@ MFNAllocateSolution - Allocate memory storage for common variables such as the basis vectors. Collective on MFN Input Parameters: + mfn - eigensolver context - extra - number of additional positions, used for methods that require a working basis slightly larger than ncv Developers Note: This is PETSC_EXTERN because it may be required by user plugin MFN implementations. Level: developer @*/ PetscErrorCode MFNAllocateSolution(MFN mfn,PetscInt extra) { PetscErrorCode ierr; PetscInt oldsize,requested; Vec t; PetscFunctionBegin; requested = mfn->ncv + extra; /* oldsize is zero if this is the first time setup is called */ ierr = BVGetSizes(mfn->V,NULL,NULL,&oldsize);CHKERRQ(ierr); /* allocate basis vectors */ if (!mfn->V) { ierr = MFNGetBV(mfn,&mfn->V);CHKERRQ(ierr); } if (!oldsize) { if (!((PetscObject)(mfn->V))->type_name) { ierr = BVSetType(mfn->V,BVSVEC);CHKERRQ(ierr); } ierr = MatCreateVecs(mfn->A,&t,NULL);CHKERRQ(ierr); ierr = BVSetSizesFromVec(mfn->V,t,requested);CHKERRQ(ierr); ierr = VecDestroy(&t);CHKERRQ(ierr); } else { ierr = BVResize(mfn->V,requested,PETSC_FALSE);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/interface/mfnregis.c0000644000175000017500000000312013107004621017444 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcmfn.h" I*/ PETSC_EXTERN PetscErrorCode MFNCreate_Krylov(MFN); PETSC_EXTERN PetscErrorCode MFNCreate_Expokit(MFN); #undef __FUNCT__ #define __FUNCT__ "MFNRegisterAll" /*@C MFNRegisterAll - Registers all the matrix functions in the MFN package. Not Collective Level: advanced .seealso: MFNRegister() @*/ PetscErrorCode MFNRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (MFNRegisterAllCalled) PetscFunctionReturn(0); MFNRegisterAllCalled = PETSC_TRUE; ierr = MFNRegister(MFNKRYLOV,MFNCreate_Krylov);CHKERRQ(ierr); ierr = MFNRegister(MFNEXPOKIT,MFNCreate_Expokit);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/interface/ftn-custom/0000755000175000017500000000000013107004621017571 5ustar jromanjromanslepc-3.7.4/src/mfn/interface/ftn-custom/makefile0000644000175000017500000000221113107004621021265 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zmfnf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcmfn LOCDIR = src/mfn/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/interface/ftn-custom/zmfnf.c0000644000175000017500000001376013107004621021064 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define mfnview_ MFNVIEW #define mfnreasonview_ MFNREASONVIEW #define mfnsetoptionsprefix_ MFNSETOPTIONSPREFIX #define mfnappendoptionsprefix_ MFNAPPENDOPTIONSPREFIX #define mfngetoptionsprefix_ MFNGETOPTIONSPREFIX #define mfnsettype_ MFNSETTYPE #define mfngettype_ MFNGETTYPE #define mfnmonitordefault_ MFNMONITORDEFAULT #define mfnmonitorlg_ MFNMONITORLG #define mfnmonitorset_ MFNMONITORSET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define mfnview_ mfnview #define mfnreasonview_ mfnreasonview #define mfnsetoptionsprefix_ mfnsetoptionsprefix #define mfnappendoptionsprefix_ mfnappendoptionsprefix #define mfngetoptionsprefix_ mfngetoptionsprefix #define mfnsettype_ mfnsettype #define mfngettype_ mfngettype #define mfnmonitordefault_ mfnmonitordefault #define mfnmonitorlg_ mfnmonitorlg #define mfnmonitorset_ mfnmonitorset #endif /* These are not usually called from Fortran but allow Fortran users to transparently set these monitors from .F code, hence no STDCALL */ PETSC_EXTERN void mfnmonitordefault_(MFN *mfn,PetscInt *it,PetscReal *errest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = MFNMonitorDefault(*mfn,*it,*errest,*ctx); } PETSC_EXTERN void mfnmonitorlg_(MFN *mfn,PetscInt *it,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = MFNMonitorLG(*mfn,*it,*errest,ctx); } static struct { PetscFortranCallbackId monitor; PetscFortranCallbackId monitordestroy; } _cb; /* These are not extern C because they are passed into non-extern C user level functions */ #undef __FUNCT__ #define __FUNCT__ "ourmonitor" static PetscErrorCode ourmonitor(MFN mfn,PetscInt i,PetscReal d,void* ctx) { PetscObjectUseFortranCallback(mfn,_cb.monitor,(MFN*,PetscInt*,PetscReal*,void*,PetscErrorCode*),(&mfn,&i,&d,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourdestroy" static PetscErrorCode ourdestroy(void** ctx) { MFN mfn = (MFN)*ctx; PetscObjectUseFortranCallback(mfn,_cb.monitordestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } PETSC_EXTERN void PETSC_STDCALL mfnview_(MFN *mfn,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = MFNView(*mfn,v); } PETSC_EXTERN void PETSC_STDCALL mfnreasonview_(MFN *mfn,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = MFNReasonView(*mfn,v); } PETSC_EXTERN void PETSC_STDCALL mfnsettype_(MFN *mfn,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = MFNSetType(*mfn,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL mfngettype_(MFN *mfn,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { MFNType tname; *ierr = MFNGetType(*mfn,&tname);if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL mfnsetoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = MFNSetOptionsPrefix(*mfn,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL mfnappendoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = MFNAppendOptionsPrefix(*mfn,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL mfngetoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = MFNGetOptionsPrefix(*mfn,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL mfnmonitorset_(MFN *mfn,void (PETSC_STDCALL *monitor)(MFN*,PetscInt*,PetscReal*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(mctx); CHKFORTRANNULLFUNCTION(monitordestroy); if ((PetscVoidFunction)monitor == (PetscVoidFunction)mfnmonitordefault_) { *ierr = MFNMonitorSet(*mfn,(PetscErrorCode (*)(MFN,PetscInt,PetscReal,void*))MFNMonitorDefault,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)mfnmonitorlg_) { *ierr = MFNMonitorSet(*mfn,MFNMonitorLG,0,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*mfn,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitor,(PetscVoidFunction)monitor,mctx); if (*ierr) return; if (!monitordestroy) { *ierr = MFNMonitorSet(*mfn,ourmonitor,*mfn,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*mfn,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitordestroy,(PetscVoidFunction)monitordestroy,mctx); if (*ierr) return; *ierr = MFNMonitorSet(*mfn,ourmonitor,*mfn,ourdestroy); } } } slepc-3.7.4/src/mfn/interface/mfnbasic.c0000644000175000017500000003530313107004621017424 0ustar jromanjroman/* The basic MFN routines, Create, View, etc. are here. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcmfn.h" I*/ PetscFunctionList MFNList = 0; PetscBool MFNRegisterAllCalled = PETSC_FALSE; PetscClassId MFN_CLASSID = 0; PetscLogEvent MFN_SetUp = 0,MFN_Solve = 0; #undef __FUNCT__ #define __FUNCT__ "MFNView" /*@C MFNView - Prints the MFN data structure. Collective on MFN Input Parameters: + mfn - the matrix function solver context - viewer - optional visualization context Options Database Key: . -mfn_view - Calls MFNView() at end of MFNSolve() Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner .seealso: PetscViewerASCIIOpen() @*/ PetscErrorCode MFNView(MFN mfn,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)mfn)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(mfn,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)mfn,viewer);CHKERRQ(ierr); if (mfn->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*mfn->ops->view)(mfn,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," number of column vectors (ncv): %D\n",mfn->ncv);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum number of iterations: %D\n",mfn->max_it);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," tolerance: %g\n",(double)mfn->tol);CHKERRQ(ierr); } else { if (mfn->ops->view) { ierr = (*mfn->ops->view)(mfn,viewer);CHKERRQ(ierr); } } ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);CHKERRQ(ierr); if (!mfn->V) { ierr = MFNGetFN(mfn,&mfn->fn);CHKERRQ(ierr); } ierr = FNView(mfn->fn,viewer);CHKERRQ(ierr); if (!mfn->V) { ierr = MFNGetBV(mfn,&mfn->V);CHKERRQ(ierr); } ierr = BVView(mfn->V,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNReasonView" /*@C MFNReasonView - Displays the reason an MFN solve converged or diverged. Collective on MFN Parameter: + mfn - the matrix function context - viewer - the viewer to display the reason Options Database Keys: . -mfn_converged_reason - print reason for convergence, and number of iterations Level: intermediate .seealso: MFNSetTolerances(), MFNGetIterationNumber() @*/ PetscErrorCode MFNReasonView(MFN mfn,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isAscii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);CHKERRQ(ierr); if (isAscii) { ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)mfn)->tablevel);CHKERRQ(ierr); if (mfn->reason > 0) { ierr = PetscViewerASCIIPrintf(viewer,"%s Matrix function solve converged due to %s; iterations %D\n",((PetscObject)mfn)->prefix?((PetscObject)mfn)->prefix:"",MFNConvergedReasons[mfn->reason],mfn->its);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%s Matrix function solve did not converge due to %s; iterations %D\n",((PetscObject)mfn)->prefix?((PetscObject)mfn)->prefix:"",MFNConvergedReasons[mfn->reason],mfn->its);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)mfn)->tablevel);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNReasonViewFromOptions" /*@ MFNReasonViewFromOptions - Processes command line options to determine if/how the MFN converged reason is to be viewed. Collective on MFN Input Parameters: . mfn - the matrix function context Level: developer @*/ PetscErrorCode MFNReasonViewFromOptions(MFN mfn) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)mfn),((PetscObject)mfn)->prefix,"-mfn_converged_reason",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = MFNReasonView(mfn,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNCreate" /*@ MFNCreate - Creates the default MFN context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . mfn - location to put the MFN context Note: The default MFN type is MFNKRYLOV Level: beginner .seealso: MFNSetUp(), MFNSolve(), MFNDestroy(), MFN @*/ PetscErrorCode MFNCreate(MPI_Comm comm,MFN *outmfn) { PetscErrorCode ierr; MFN mfn; PetscFunctionBegin; PetscValidPointer(outmfn,2); *outmfn = 0; ierr = MFNInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(mfn,MFN_CLASSID,"MFN","Matrix Function","MFN",comm,MFNDestroy,MFNView);CHKERRQ(ierr); mfn->A = NULL; mfn->fn = NULL; mfn->max_it = 0; mfn->ncv = 0; mfn->tol = PETSC_DEFAULT; mfn->errorifnotconverged = PETSC_FALSE; mfn->numbermonitors = 0; mfn->V = NULL; mfn->nwork = 0; mfn->work = NULL; mfn->data = NULL; mfn->its = 0; mfn->nv = 0; mfn->errest = 0; mfn->setupcalled = 0; mfn->reason = MFN_CONVERGED_ITERATING; *outmfn = mfn; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetType" /*@C MFNSetType - Selects the particular solver to be used in the MFN object. Logically Collective on MFN Input Parameters: + mfn - the matrix function context - type - a known method Options Database Key: . -mfn_type - Sets the method; use -help for a list of available methods Notes: See "slepc/include/slepcmfn.h" for available methods. The default is MFNKRYLOV Normally, it is best to use the MFNSetFromOptions() command and then set the MFN type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The MFNSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database. Level: intermediate .seealso: MFNType @*/ PetscErrorCode MFNSetType(MFN mfn,MFNType type) { PetscErrorCode ierr,(*r)(MFN); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)mfn,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(MFNList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)mfn),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown MFN type given: %s",type); if (mfn->ops->destroy) { ierr = (*mfn->ops->destroy)(mfn);CHKERRQ(ierr); } ierr = PetscMemzero(mfn->ops,sizeof(struct _MFNOps));CHKERRQ(ierr); mfn->setupcalled = 0; ierr = PetscObjectChangeTypeName((PetscObject)mfn,type);CHKERRQ(ierr); ierr = (*r)(mfn);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetType" /*@C MFNGetType - Gets the MFN type as a string from the MFN object. Not Collective Input Parameter: . mfn - the matrix function context Output Parameter: . name - name of MFN method Level: intermediate .seealso: MFNSetType() @*/ PetscErrorCode MFNGetType(MFN mfn,MFNType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)mfn)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNRegister" /*@C MFNRegister - Adds a method to the matrix function solver package. Not Collective Input Parameters: + name - name of a new user-defined solver - function - routine to create the solver context Notes: MFNRegister() may be called multiple times to add several user-defined solvers. Sample usage: .vb MFNRegister("my_solver",MySolverCreate); .ve Then, your solver can be chosen with the procedural interface via $ MFNSetType(mfn,"my_solver") or at runtime via the option $ -mfn_type my_solver Level: advanced .seealso: MFNRegisterAll() @*/ PetscErrorCode MFNRegister(const char *name,PetscErrorCode (*function)(MFN)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&MFNList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNReset" /*@ MFNReset - Resets the MFN context to the setupcalled=0 state and removes any allocated objects. Collective on MFN Input Parameter: . mfn - matrix function context obtained from MFNCreate() Level: advanced .seealso: MFNDestroy() @*/ PetscErrorCode MFNReset(MFN mfn) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); if (mfn->ops->reset) { ierr = (mfn->ops->reset)(mfn);CHKERRQ(ierr); } mfn->setupcalled = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNDestroy" /*@ MFNDestroy - Destroys the MFN context. Collective on MFN Input Parameter: . mfn - matrix function context obtained from MFNCreate() Level: beginner .seealso: MFNCreate(), MFNSetUp(), MFNSolve() @*/ PetscErrorCode MFNDestroy(MFN *mfn) { PetscErrorCode ierr; PetscFunctionBegin; if (!*mfn) PetscFunctionReturn(0); PetscValidHeaderSpecific(*mfn,MFN_CLASSID,1); if (--((PetscObject)(*mfn))->refct > 0) { *mfn = 0; PetscFunctionReturn(0); } ierr = MFNReset(*mfn);CHKERRQ(ierr); if ((*mfn)->ops->destroy) { ierr = (*(*mfn)->ops->destroy)(*mfn);CHKERRQ(ierr); } ierr = MatDestroy(&(*mfn)->A);CHKERRQ(ierr); ierr = BVDestroy(&(*mfn)->V);CHKERRQ(ierr); ierr = FNDestroy(&(*mfn)->fn);CHKERRQ(ierr); ierr = MFNMonitorCancel(*mfn);CHKERRQ(ierr); ierr = PetscHeaderDestroy(mfn);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetBV" /*@ MFNSetBV - Associates a basis vectors object to the matrix function solver. Collective on MFN Input Parameters: + mfn - matrix function context obtained from MFNCreate() - bv - the basis vectors object Note: Use MFNGetBV() to retrieve the basis vectors context (for example, to free it at the end of the computations). Level: advanced .seealso: MFNGetBV() @*/ PetscErrorCode MFNSetBV(MFN mfn,BV bv) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidHeaderSpecific(bv,BV_CLASSID,2); PetscCheckSameComm(mfn,1,bv,2); ierr = PetscObjectReference((PetscObject)bv);CHKERRQ(ierr); ierr = BVDestroy(&mfn->V);CHKERRQ(ierr); mfn->V = bv; ierr = PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetBV" /*@ MFNGetBV - Obtain the basis vectors object associated to the matrix function solver. Not Collective Input Parameters: . mfn - matrix function context obtained from MFNCreate() Output Parameter: . bv - basis vectors context Level: advanced .seealso: MFNSetBV() @*/ PetscErrorCode MFNGetBV(MFN mfn,BV *bv) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(bv,2); if (!mfn->V) { ierr = BVCreate(PetscObjectComm((PetscObject)mfn),&mfn->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->V);CHKERRQ(ierr); } *bv = mfn->V; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSetFN" /*@ MFNSetFN - Specifies the function to be computed. Collective on MFN Input Parameters: + mfn - matrix function context obtained from MFNCreate() - fn - the math function object Note: Use MFNGetFN() to retrieve the math function context (for example, to free it at the end of the computations). Level: beginner .seealso: MFNGetFN() @*/ PetscErrorCode MFNSetFN(MFN mfn,FN fn) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidHeaderSpecific(fn,FN_CLASSID,2); PetscCheckSameComm(mfn,1,fn,2); ierr = PetscObjectReference((PetscObject)fn);CHKERRQ(ierr); ierr = FNDestroy(&mfn->fn);CHKERRQ(ierr); mfn->fn = fn; ierr = PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->fn);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetFN" /*@ MFNGetFN - Obtain the math function object associated to the MFN object. Not Collective Input Parameters: . mfn - matrix function context obtained from MFNCreate() Output Parameter: . fn - math function context Level: beginner .seealso: MFNSetFN() @*/ PetscErrorCode MFNGetFN(MFN mfn,FN *fn) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidPointer(fn,2); if (!mfn->fn) { ierr = FNCreate(PetscObjectComm((PetscObject)mfn),&mfn->fn);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)mfn,(PetscObject)mfn->fn);CHKERRQ(ierr); } *fn = mfn->fn; PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/interface/mfnsolve.c0000644000175000017500000001403713107004621017474 0ustar jromanjroman/* MFN routines related to the solution process. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcmfn.h" I*/ #undef __FUNCT__ #define __FUNCT__ "MFNSolve" /*@ MFNSolve - Solves the matrix function problem. Given a vector b, the vector x = f(A)*b is returned. Collective on MFN Input Parameters: + mfn - matrix function context obtained from MFNCreate() - b - the right hand side vector Output Parameter: . x - the solution (this may be the same vector as b, then b will be overwritten with the answer) Options Database Keys: + -mfn_view - print information about the solver used . -mfn_view_mat binary - save the matrix to the default binary viewer . -mfn_view_rhs binary - save right hand side vector to the default binary viewer . -mfn_view_solution binary - save computed solution vector to the default binary viewer - -mfn_converged_reason - print reason for convergence, and number of iterations Notes: The matrix A is specified with MFNSetOperator(). The function f is specified with MFNSetFN(). Level: beginner .seealso: MFNCreate(), MFNSetUp(), MFNDestroy(), MFNSetTolerances(), MFNSetOperator(), MFNSetFN() @*/ PetscErrorCode MFNSolve(MFN mfn,Vec b,Vec x) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidHeaderSpecific(b,VEC_CLASSID,2); PetscCheckSameComm(mfn,1,b,2); if (b!=x) PetscValidHeaderSpecific(x,VEC_CLASSID,3); if (b!=x) PetscCheckSameComm(mfn,1,x,3); VecLocked(x,3); /* call setup */ ierr = MFNSetUp(mfn);CHKERRQ(ierr); mfn->its = 0; ierr = MFNViewFromOptions(mfn,NULL,"-mfn_view_pre");CHKERRQ(ierr); /* check nonzero right-hand side */ ierr = VecNorm(b,NORM_2,&mfn->bnorm);CHKERRQ(ierr); if (!mfn->bnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Cannot pass a zero b vector to MFNSolve()"); /* call solver */ ierr = PetscLogEventBegin(MFN_Solve,mfn,b,x,0);CHKERRQ(ierr); if (b!=x) { ierr = VecLockPush(b);CHKERRQ(ierr); } ierr = (*mfn->ops->solve)(mfn,b,x);CHKERRQ(ierr); if (b!=x) { ierr = VecLockPop(b);CHKERRQ(ierr); } ierr = PetscLogEventEnd(MFN_Solve,mfn,b,x,0);CHKERRQ(ierr); if (!mfn->reason) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason"); if (mfn->errorifnotconverged && mfn->reason < 0) SETERRQ(PetscObjectComm((PetscObject)mfn),PETSC_ERR_NOT_CONVERGED,"MFNSolve has not converged"); /* various viewers */ ierr = MFNViewFromOptions(mfn,NULL,"-mfn_view");CHKERRQ(ierr); ierr = MFNReasonViewFromOptions(mfn);CHKERRQ(ierr); ierr = MatViewFromOptions(mfn->A,(PetscObject)mfn,"-mfn_view_mat");CHKERRQ(ierr); ierr = VecViewFromOptions(b,(PetscObject)mfn,"-mfn_view_rhs");CHKERRQ(ierr); ierr = VecViewFromOptions(x,(PetscObject)mfn,"-mfn_view_solution");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetIterationNumber" /*@ MFNGetIterationNumber - Gets the current iteration number. If the call to MFNSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . mfn - the matrix function context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If MFNSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call MFNGetConvergedReason() to determine if the solver converged or failed and why. .seealso: MFNGetConvergedReason(), MFNSetTolerances() @*/ PetscErrorCode MFNGetIterationNumber(MFN mfn,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidIntPointer(its,2); *its = mfn->its; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNGetConvergedReason" /*@ MFNGetConvergedReason - Gets the reason why the MFNSolve() iteration was stopped. Not Collective Input Parameter: . mfn - the matrix function context Output Parameter: . reason - negative value indicates diverged, positive value converged Notes: Possible values for reason are + MFN_CONVERGED_TOL - converged up to tolerance . MFN_CONVERGED_ITS - solver completed the requested number of steps . MFN_DIVERGED_ITS - required more than max_it iterations to reach convergence - MFN_DIVERGED_BREAKDOWN - generic breakdown in method Can only be called after the call to MFNSolve() is complete. Basic solvers (e.g. unrestarted Krylov iterations) cannot determine if the computation is accurate up to the requested tolerance. In that case, the converged reason is set to MFN_CONVERGED_ITS if the requested number of steps (for instance, the ncv value in unrestarted Krylov methods) have been completed successfully. Level: intermediate .seealso: MFNSetTolerances(), MFNSolve(), MFNConvergedReason, MFNSetErrorIfNotConverged() @*/ PetscErrorCode MFNGetConvergedReason(MFN mfn,MFNConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); PetscValidIntPointer(reason,2); *reason = mfn->reason; PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/examples/0000755000175000017500000000000013107004621015350 5ustar jromanjromanslepc-3.7.4/src/mfn/examples/makefile0000644000175000017500000000201713107004621017050 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/mfn/examples/ DIRS = tests tutorials include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/examples/makefile.html0000644000175000017500000000442413107004621020017 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/mfn/examples/
DIRS     = tests tutorials

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/mfn/examples/tutorials/0000755000175000017500000000000013107004621017376 5ustar jromanjromanslepc-3.7.4/src/mfn/examples/tutorials/makefile0000644000175000017500000000351213107004621021077 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/mfn/examples/tutorials/ EXAMPLESC = ex23.c ex26.c EXAMPLESF = MANSEC = MFN TESTEXAMPLES_C = ex23.PETSc runex23_1 ex23.rm ex26.PETSc runex26_1 ex26.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common ex23: ex23.o chkopts -${CLINKER} -o ex23 ex23.o ${SLEPC_MFN_LIB} ${RM} ex23.o ex26: ex26.o chkopts -${CLINKER} -o ex26 ex26.o ${SLEPC_MFN_LIB} ${RM} ex26.o #------------------------------------------------------------------------------------ runex23_1: -@${MPIEXEC} -n 1 ./ex23 > ex23_1.tmp 2>&1; \ if (${DIFF} output/ex23_1.out ex23_1.tmp) then true; \ else echo "Possible problem with ex23_1, diffs above"; fi; \ ${RM} -f ex23_1.tmp runex26_1: -@${MPIEXEC} -n 1 ./ex26 > ex26_1.tmp 2>&1; \ if (${DIFF} output/ex26_1.out ex26_1.tmp) then true; \ else echo "Possible problem with ex26_1, diffs above"; fi; \ ${RM} -f ex26_1.tmp slepc-3.7.4/src/mfn/examples/tutorials/ex23.c.html0000644000175000017500000003477713107004621021310 0ustar jromanjroman
Actual source code: ex23.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Computes exp(t*A)*v for a matrix associated with a Markov model.\n\n"
 23:   "The command line options are:\n"
 24:   "  -t <t>, where <t> = time parameter (multiplies the matrix).\n\n"
 25:   "  -m <m>, where <m> = number of grid subdivisions in each dimension.\n\n";

 27: #include <slepcmfn.h>

 29: /*
 30:    User-defined routines
 31: */
 32: PetscErrorCode MatMarkovModel(PetscInt m,Mat A);

 36: int main(int argc,char **argv)
 37: {
 38:   Mat                A;           /* problem matrix */
 39:   MFN                mfn;
 40:   FN                 f;
 41:   PetscReal          tol,norm;
 42:   PetscScalar        t=2.0;
 43:   Vec                v,y;
 44:   PetscInt           N,m=15,ncv,maxit,its;
 45:   PetscErrorCode     ierr;
 46:   PetscBool          draw_sol;
 47:   MFNConvergedReason reason;

 49:   SlepcInitialize(&argc,&argv,(char*)0,help);

 51:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 52:   PetscOptionsGetScalar(NULL,NULL,"-t",&t,NULL);
 53:   N = m*(m+1)/2;
 54:   PetscPrintf(PETSC_COMM_WORLD,"\nMarkov y=exp(t*A)*e_1, N=%D (m=%D)\n\n",N,m);

 56:   PetscOptionsHasName(NULL,NULL,"-draw_sol",&draw_sol);

 58:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 59:             Compute the transition probability matrix, A
 60:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 62:   MatCreate(PETSC_COMM_WORLD,&A);
 63:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 64:   MatSetFromOptions(A);
 65:   MatSetUp(A);
 66:   MatMarkovModel(m,A);

 68:   /* set v = e_1 */
 69:   MatCreateVecs(A,NULL,&y);
 70:   MatCreateVecs(A,NULL,&v);
 71:   VecSetValue(v,0,1.0,INSERT_VALUES);
 72:   VecAssemblyBegin(v);
 73:   VecAssemblyEnd(v);

 75:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 76:                 Create the solver and set various options
 77:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 78:   /* 
 79:      Create matrix function solver context
 80:   */
 81:   MFNCreate(PETSC_COMM_WORLD,&mfn);

 83:   /* 
 84:      Set operator matrix, the function to compute, and other options
 85:   */
 86:   MFNSetOperator(mfn,A);
 87:   MFNGetFN(mfn,&f);
 88:   FNSetType(f,FNEXP);
 89:   FNSetScale(f,t,1.0);  
 90:   MFNSetTolerances(mfn,1e-07,PETSC_DEFAULT);

 92:   /*
 93:      Set solver parameters at runtime
 94:   */
 95:   MFNSetFromOptions(mfn);

 97:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 98:                       Solve the problem, y=exp(t*A)*v
 99:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

101:   MFNSolve(mfn,v,y);
102:   MFNGetConvergedReason(mfn,&reason);
103:   if (reason<0) SETERRQ(PETSC_COMM_WORLD,1,"Solver did not converge");
104:   VecNorm(y,NORM_2,&norm);
105:   
106:   /*
107:      Optional: Get some information from the solver and display it
108:   */
109:   MFNGetIterationNumber(mfn,&its);
110:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);
111:   MFNGetDimensions(mfn,&ncv);
112:   PetscPrintf(PETSC_COMM_WORLD," Subspace dimension: %D\n",ncv);
113:   MFNGetTolerances(mfn,&tol,&maxit);
114:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

116:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
117:                     Display solution and clean up
118:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
119:   PetscPrintf(PETSC_COMM_WORLD," Computed vector at time t=%.4g has norm %g\n\n",(double)PetscRealPart(t),(double)norm);
120:   if (draw_sol) {
121:     PetscViewerDrawSetPause(PETSC_VIEWER_DRAW_WORLD,-1);
122:     VecView(y,PETSC_VIEWER_DRAW_WORLD);
123:   }

125:   /* 
126:      Free work space
127:   */
128:   MFNDestroy(&mfn);
129:   MatDestroy(&A);
130:   VecDestroy(&v);
131:   VecDestroy(&y);
132:   SlepcFinalize();
133:   return ierr;
134: }

138: /*
139:     Matrix generator for a Markov model of a random walk on a triangular grid.
140:     See ex5.c for additional details.
141: */
142: PetscErrorCode MatMarkovModel(PetscInt m,Mat A)
143: {
144:   const PetscReal cst = 0.5/(PetscReal)(m-1);
145:   PetscReal       pd,pu;
146:   PetscInt        Istart,Iend,i,j,jmax,ix=0;
147:   PetscErrorCode  ierr;

150:   MatGetOwnershipRange(A,&Istart,&Iend);
151:   for (i=1;i<=m;i++) {
152:     jmax = m-i+1;
153:     for (j=1;j<=jmax;j++) {
154:       ix = ix + 1;
155:       if (ix-1<Istart || ix>Iend) continue;  /* compute only owned rows */
156:       if (j!=jmax) {
157:         pd = cst*(PetscReal)(i+j-1);
158:         /* north */
159:         if (i==1) {
160:           MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);
161:         } else {
162:           MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);
163:         }
164:         /* east */
165:         if (j==1) {
166:           MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);
167:         } else {
168:           MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);
169:         }
170:       }
171:       /* south */
172:       pu = 0.5 - cst*(PetscReal)(i+j-3);
173:       if (j>1) {
174:         MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);
175:       }
176:       /* west */
177:       if (i>1) {
178:         MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);
179:       }
180:     }
181:   }
182:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
183:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
184:   return(0);
185: }

slepc-3.7.4/src/mfn/examples/tutorials/makefile.html0000644000175000017500000000700113107004621022037 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/mfn/examples/tutorials/
EXAMPLESC  = ex23.c ex26.c
EXAMPLESF  =
MANSEC     = MFN

TESTEXAMPLES_C = ex23.PETSc runex23_1 ex23.rm ex26.PETSc runex26_1 ex26.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

ex23: ex23.o chkopts
	-${CLINKER} -o ex23 ex23.o ${SLEPC_MFN_LIB}
	${RM} ex23.o

ex26: ex26.o chkopts
	-${CLINKER} -o ex26 ex26.o ${SLEPC_MFN_LIB}
	${RM} ex26.o

#------------------------------------------------------------------------------------

runex23_1:
	-@${MPIEXEC} -n 1 ./ex23 > ex23_1.tmp 2>&1; \
	   if (${DIFF} output/ex23_1.out ex23_1.tmp) then true; \
	   else echo "Possible problem with ex23_1, diffs above"; fi; \
	   ${RM} -f ex23_1.tmp

runex26_1:
	-@${MPIEXEC} -n 1 ./ex26 > ex26_1.tmp 2>&1; \
	   if (${DIFF} output/ex26_1.out ex26_1.tmp) then true; \
	   else echo "Possible problem with ex26_1, diffs above"; fi; \
	   ${RM} -f ex26_1.tmp

slepc-3.7.4/src/mfn/examples/tutorials/ex23.c0000644000175000017500000001524013107004621020325 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Computes exp(t*A)*v for a matrix associated with a Markov model.\n\n" "The command line options are:\n" " -t , where = time parameter (multiplies the matrix).\n\n" " -m , where = number of grid subdivisions in each dimension.\n\n"; #include /* User-defined routines */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ MFN mfn; FN f; PetscReal tol,norm; PetscScalar t=2.0; Vec v,y; PetscInt N,m=15,ncv,maxit,its; PetscErrorCode ierr; PetscBool draw_sol; MFNConvergedReason reason; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-t",&t,NULL);CHKERRQ(ierr); N = m*(m+1)/2; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nMarkov y=exp(t*A)*e_1, N=%D (m=%D)\n\n",N,m);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-draw_sol",&draw_sol);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the transition probability matrix, A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatMarkovModel(m,A);CHKERRQ(ierr); /* set v = e_1 */ ierr = MatCreateVecs(A,NULL,&y);CHKERRQ(ierr); ierr = MatCreateVecs(A,NULL,&v);CHKERRQ(ierr); ierr = VecSetValue(v,0,1.0,INSERT_VALUES);CHKERRQ(ierr); ierr = VecAssemblyBegin(v);CHKERRQ(ierr); ierr = VecAssemblyEnd(v);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the solver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create matrix function solver context */ ierr = MFNCreate(PETSC_COMM_WORLD,&mfn);CHKERRQ(ierr); /* Set operator matrix, the function to compute, and other options */ ierr = MFNSetOperator(mfn,A);CHKERRQ(ierr); ierr = MFNGetFN(mfn,&f);CHKERRQ(ierr); ierr = FNSetType(f,FNEXP);CHKERRQ(ierr); ierr = FNSetScale(f,t,1.0);CHKERRQ(ierr); ierr = MFNSetTolerances(mfn,1e-07,PETSC_DEFAULT);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = MFNSetFromOptions(mfn);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the problem, y=exp(t*A)*v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MFNSolve(mfn,v,y);CHKERRQ(ierr); ierr = MFNGetConvergedReason(mfn,&reason);CHKERRQ(ierr); if (reason<0) SETERRQ(PETSC_COMM_WORLD,1,"Solver did not converge"); ierr = VecNorm(y,NORM_2,&norm);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = MFNGetIterationNumber(mfn,&its);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);CHKERRQ(ierr); ierr = MFNGetDimensions(mfn,&ncv);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Subspace dimension: %D\n",ncv);CHKERRQ(ierr); ierr = MFNGetTolerances(mfn,&tol,&maxit);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscPrintf(PETSC_COMM_WORLD," Computed vector at time t=%.4g has norm %g\n\n",(double)PetscRealPart(t),(double)norm);CHKERRQ(ierr); if (draw_sol) { ierr = PetscViewerDrawSetPause(PETSC_VIEWER_DRAW_WORLD,-1);CHKERRQ(ierr); ierr = VecView(y,PETSC_VIEWER_DRAW_WORLD);CHKERRQ(ierr); } /* Free work space */ ierr = MFNDestroy(&mfn);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMarkovModel" /* Matrix generator for a Markov model of a random walk on a triangular grid. See ex5.c for additional details. */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A) { const PetscReal cst = 0.5/(PetscReal)(m-1); PetscReal pd,pu; PetscInt Istart,Iend,i,j,jmax,ix=0; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=1;i<=m;i++) { jmax = m-i+1; for (j=1;j<=jmax;j++) { ix = ix + 1; if (ix-1Iend) continue; /* compute only owned rows */ if (j!=jmax) { pd = cst*(PetscReal)(i+j-1); /* north */ if (i==1) { ierr = MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);CHKERRQ(ierr); } /* east */ if (j==1) { ierr = MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);CHKERRQ(ierr); } } /* south */ pu = 0.5 - cst*(PetscReal)(i+j-3); if (j>1) { ierr = MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);CHKERRQ(ierr); } /* west */ if (i>1) { ierr = MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);CHKERRQ(ierr); } } } ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/examples/tutorials/output/0000755000175000017500000000000013107004621020736 5ustar jromanjromanslepc-3.7.4/src/mfn/examples/tutorials/output/ex26_1.out0000644000175000017500000000020413107004621022467 0ustar jromanjroman Square root of Laplacian y=sqrt(A)*e_1, N=100 (10x10 grid) Intermediate vector has norm 2. Error norm is less than 100*epsilon slepc-3.7.4/src/mfn/examples/tutorials/output/ex23_1.out0000644000175000017500000000027613107004621022475 0ustar jromanjroman Markov y=exp(t*A)*e_1, N=120 (m=15) Number of iterations of the method: 2 Subspace dimension: 30 Stopping condition: tol=1e-07, maxit=100 Computed vector at time t=2 has norm 2.47328 slepc-3.7.4/src/mfn/examples/tutorials/index.html0000644000175000017500000000234213107004621021374 0ustar jromanjroman Matrix Function - MFN
slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

ex23.c: Computes exp(t*A)*v for a matrix associated with a Markov model
ex26.c: Computes the action of the square root of the 2-D Laplacian
makefile
slepc-3.7.4/src/mfn/examples/tutorials/ex26.c0000644000175000017500000001333213107004621020330 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Computes the action of the square root of the 2-D Laplacian.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ MFN mfn; FN f; PetscReal norm; Vec v,y,z; PetscInt N,n=10,m,Istart,Iend,i,j,II; PetscErrorCode ierr; PetscBool flag,draw_sol; MFNConvergedReason reason; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSquare root of Laplacian y=sqrt(A)*e_1, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-draw_sol",&draw_sol);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the discrete 2-D Laplacian, A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (jActual source code: ex26.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Computes the action of the square root of the 2-D Laplacian.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 25:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n\n";

 27: #include <slepcmfn.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat                A;           /* problem matrix */
 34:   MFN                mfn;
 35:   FN                 f;
 36:   PetscReal          norm;
 37:   Vec                v,y,z;
 38:   PetscInt           N,n=10,m,Istart,Iend,i,j,II;
 39:   PetscErrorCode     ierr;
 40:   PetscBool          flag,draw_sol;
 41:   MFNConvergedReason reason;

 43:   SlepcInitialize(&argc,&argv,(char*)0,help);

 45:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 46:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 47:   if (!flag) m=n;
 48:   N = n*m;
 49:   PetscPrintf(PETSC_COMM_WORLD,"\nSquare root of Laplacian y=sqrt(A)*e_1, N=%D (%Dx%D grid)\n\n",N,n,m);

 51:   PetscOptionsHasName(NULL,NULL,"-draw_sol",&draw_sol);

 53:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 54:                  Compute the discrete 2-D Laplacian, A
 55:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 57:   MatCreate(PETSC_COMM_WORLD,&A);
 58:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 59:   MatSetFromOptions(A);
 60:   MatSetUp(A);

 62:   MatGetOwnershipRange(A,&Istart,&Iend);
 63:   for (II=Istart;II<Iend;II++) {
 64:     i = II/n; j = II-i*n;
 65:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); }
 66:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); }
 67:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); }
 68:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); }
 69:     MatSetValue(A,II,II,4.0,INSERT_VALUES);
 70:   }

 72:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 73:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 75:   /* set symmetry flag so that solver can exploit it */
 76:   MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);

 78:   /* set v = e_1 */
 79:   MatCreateVecs(A,NULL,&v);
 80:   VecSetValue(v,0,1.0,INSERT_VALUES);
 81:   VecAssemblyBegin(v);
 82:   VecAssemblyEnd(v);
 83:   VecDuplicate(v,&y);
 84:   VecDuplicate(v,&z);

 86:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 87:              Create the solver, set the matrix and the function
 88:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 89:   MFNCreate(PETSC_COMM_WORLD,&mfn);
 90:   MFNSetOperator(mfn,A);
 91:   MFNGetFN(mfn,&f);
 92:   FNSetType(f,FNSQRT);
 93:   MFNSetFromOptions(mfn);

 95:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 96:                       First solve: y=sqrt(A)*v
 97:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 99:   MFNSolve(mfn,v,y);
100:   MFNGetConvergedReason(mfn,&reason);
101:   if (reason<0) SETERRQ(PETSC_COMM_WORLD,1,"Solver did not converge");
102:   VecNorm(y,NORM_2,&norm);
103:   
104:   PetscPrintf(PETSC_COMM_WORLD," Intermediate vector has norm %g\n",(double)norm);
105:   if (draw_sol) {
106:     PetscViewerDrawSetPause(PETSC_VIEWER_DRAW_WORLD,-1);
107:     VecView(y,PETSC_VIEWER_DRAW_WORLD);
108:   }

110:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
111:              Second solve: z=sqrt(A)*y and compare against A*v
112:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

114:   MFNSolve(mfn,y,z);
115:   MFNGetConvergedReason(mfn,&reason);
116:   if (reason<0) SETERRQ(PETSC_COMM_WORLD,1,"Solver did not converge");

118:   MatMult(A,v,y);   /* overwrite y */
119:   VecAXPY(y,-1.0,z);
120:   VecNorm(y,NORM_2,&norm);
121:   
122:   if (norm<100*PETSC_MACHINE_EPSILON) {
123:     PetscPrintf(PETSC_COMM_WORLD," Error norm is less than 100*epsilon\n\n");
124:   } else {
125:     PetscPrintf(PETSC_COMM_WORLD," Error norm %3.1e\n\n",(double)norm);
126:   }
127:   if (draw_sol) {
128:     PetscViewerDrawSetPause(PETSC_VIEWER_DRAW_WORLD,-1);
129:     VecView(z,PETSC_VIEWER_DRAW_WORLD);
130:   }

132:   /* 
133:      Free work space
134:   */
135:   MFNDestroy(&mfn);
136:   MatDestroy(&A);
137:   VecDestroy(&v);
138:   VecDestroy(&y);
139:   VecDestroy(&z);
140:   SlepcFinalize();
141:   return ierr;
142: }

slepc-3.7.4/src/mfn/examples/index.html0000644000175000017500000000126213107004621017346 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
tutorials/
makefile
slepc-3.7.4/src/mfn/examples/tests/0000755000175000017500000000000013107004621016512 5ustar jromanjromanslepc-3.7.4/src/mfn/examples/tests/makefile0000644000175000017500000000443313107004621020216 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/mfn/examples/tests/ EXAMPLESC = test1.c EXAMPLESF = MANSEC = MFN TESTS = TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_1 runtest1_2 test1.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_MFN_LIB} ${RM} test1.o #------------------------------------------------------------------------------------ DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices runtest1_1: -@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ echo "Skipping test1_1 test"; \ else \ ${MPIEXEC} -n 1 ./test1 -file ${DATAPATH}/bfw62b.petsc > test1_1.tmp 2>&1; \ if (${DIFF} output/test1.out test1_1.tmp) then true; \ else echo "Possible problem with test1_1, diffs above"; fi; \ ${RM} -f test1_1.tmp; \ fi runtest1_2: -@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ echo "Skipping test1_2 test"; \ else \ ${MPIEXEC} -n 1 ./test1 -file ${DATAPATH}/bfw62b.petsc -mfn_type expokit > test1_2.tmp 2>&1; \ if (${DIFF} output/test1.out test1_2.tmp) then true; \ else echo "Possible problem with test1_2, diffs above"; fi; \ ${RM} -f test1_2.tmp; \ fi slepc-3.7.4/src/mfn/examples/tests/test1.c.html0000644000175000017500000002156013107004621020665 0ustar jromanjroman

Actual source code: test1.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Computes exp(A)*v for a matrix loaded from file.\n\n"
 23:   "The command line options are:\n"
 24:   "  -file <filename>, where <filename> = matrix file in PETSc binary form.\n\n";

 26: #include <slepcmfn.h>

 30: int main(int argc,char **argv)
 31: {
 32:   Mat                A;           /* problem matrix */
 33:   MFN                mfn;
 34:   FN                 f;
 35:   PetscReal          norm;
 36:   PetscScalar        t=2.0;
 37:   Vec                v,y;
 38:   PetscErrorCode     ierr;
 39:   PetscViewer        viewer;
 40:   PetscBool          flg;
 41:   char               filename[PETSC_MAX_PATH_LEN];
 42:   MFNConvergedReason reason;

 44:   SlepcInitialize(&argc,&argv,(char*)0,help);

 46:   PetscOptionsGetScalar(NULL,NULL,"-t",&t,NULL);
 47:   PetscPrintf(PETSC_COMM_WORLD,"\nMatrix exponential y=exp(t*A)*e, loaded from file\n\n");

 49:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 50:                 Load matrix A from binary file
 51:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 53:   PetscOptionsGetString(NULL,NULL,"-file",filename,PETSC_MAX_PATH_LEN,&flg);
 54:   if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name with the -file option");

 56: #if defined(PETSC_USE_COMPLEX)
 57:   PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrix from a binary file...\n");
 58: #else
 59:   PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrix from a binary file...\n");
 60: #endif
 61:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 62:   MatCreate(PETSC_COMM_WORLD,&A);
 63:   MatSetFromOptions(A);
 64:   MatLoad(A,viewer);
 65:   PetscViewerDestroy(&viewer);

 67:   /* set v = ones(n,1) */
 68:   MatCreateVecs(A,NULL,&y);
 69:   MatCreateVecs(A,NULL,&v);
 70:   VecSet(v,1.0);

 72:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 73:                 Create the solver and set various options
 74:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 76:   MFNCreate(PETSC_COMM_WORLD,&mfn);
 77:   MFNSetOperator(mfn,A);
 78:   MFNGetFN(mfn,&f);
 79:   FNSetType(f,FNEXP);
 80:   FNSetScale(f,t,1.0);  
 81:   MFNSetFromOptions(mfn);

 83:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 84:                       Solve the problem, y=exp(t*A)*v
 85:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 87:   MFNSolve(mfn,v,y);
 88:   MFNGetConvergedReason(mfn,&reason);
 89:   if (reason<0) SETERRQ(PETSC_COMM_WORLD,1,"Solver did not converge");
 90:   VecNorm(y,NORM_2,&norm);
 91:   PetscPrintf(PETSC_COMM_WORLD," Computed vector at time t=%.4g has norm %g\n\n",(double)PetscRealPart(t),(double)norm);
 92:   
 93:   /* 
 94:      Free work space
 95:   */
 96:   MFNDestroy(&mfn);
 97:   MatDestroy(&A);
 98:   VecDestroy(&v);
 99:   VecDestroy(&y);
100:   SlepcFinalize();
101:   return ierr;
102: }

slepc-3.7.4/src/mfn/examples/tests/makefile.html0000644000175000017500000001032213107004621021153 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/mfn/examples/tests/
EXAMPLESC  = test1.c
EXAMPLESF  =
MANSEC     = MFN
TESTS      =

TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_1 runtest1_2 test1.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_MFN_LIB}
	${RM} test1.o

#------------------------------------------------------------------------------------
DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices

runtest1_1:
	-@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
	   echo "Skipping test1_1 test"; \
	 else \
	   ${MPIEXEC} -n 1 ./test1 -file ${DATAPATH}/bfw62b.petsc > test1_1.tmp 2>&1; \
	   if (${DIFF} output/test1.out test1_1.tmp) then true; \
	   else echo "Possible problem with test1_1, diffs above"; fi; \
	   ${RM} -f test1_1.tmp; \
	 fi

runtest1_2:
	-@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
	   echo "Skipping test1_2 test"; \
	 else \
	   ${MPIEXEC} -n 1 ./test1 -file ${DATAPATH}/bfw62b.petsc -mfn_type expokit > test1_2.tmp 2>&1; \
	   if (${DIFF} output/test1.out test1_2.tmp) then true; \
	   else echo "Possible problem with test1_2, diffs above"; fi; \
	   ${RM} -f test1_2.tmp; \
	 fi

slepc-3.7.4/src/mfn/examples/tests/test1.c0000644000175000017500000001012513107004621017715 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Computes exp(A)*v for a matrix loaded from file.\n\n" "The command line options are:\n" " -file , where = matrix file in PETSc binary form.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ MFN mfn; FN f; PetscReal norm; PetscScalar t=2.0; Vec v,y; PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; char filename[PETSC_MAX_PATH_LEN]; MFNConvergedReason reason; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetScalar(NULL,NULL,"-t",&t,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nMatrix exponential y=exp(t*A)*e, loaded from file\n\n");CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load matrix A from binary file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscOptionsGetString(NULL,NULL,"-file",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name with the -file option"); #if defined(PETSC_USE_COMPLEX) ierr = PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrix from a binary file...\n");CHKERRQ(ierr); #else ierr = PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrix from a binary file...\n");CHKERRQ(ierr); #endif ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatLoad(A,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); /* set v = ones(n,1) */ ierr = MatCreateVecs(A,NULL,&y);CHKERRQ(ierr); ierr = MatCreateVecs(A,NULL,&v);CHKERRQ(ierr); ierr = VecSet(v,1.0);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the solver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MFNCreate(PETSC_COMM_WORLD,&mfn);CHKERRQ(ierr); ierr = MFNSetOperator(mfn,A);CHKERRQ(ierr); ierr = MFNGetFN(mfn,&f);CHKERRQ(ierr); ierr = FNSetType(f,FNEXP);CHKERRQ(ierr); ierr = FNSetScale(f,t,1.0);CHKERRQ(ierr); ierr = MFNSetFromOptions(mfn);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the problem, y=exp(t*A)*v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MFNSolve(mfn,v,y);CHKERRQ(ierr); ierr = MFNGetConvergedReason(mfn,&reason);CHKERRQ(ierr); if (reason<0) SETERRQ(PETSC_COMM_WORLD,1,"Solver did not converge"); ierr = VecNorm(y,NORM_2,&norm);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Computed vector at time t=%.4g has norm %g\n\n",(double)PetscRealPart(t),(double)norm);CHKERRQ(ierr); /* Free work space */ ierr = MFNDestroy(&mfn);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/mfn/examples/tests/output/0000755000175000017500000000000013107004621020052 5ustar jromanjromanslepc-3.7.4/src/mfn/examples/tests/output/test1.out0000644000175000017500000000021613107004621021642 0ustar jromanjroman Matrix exponential y=exp(t*A)*e, loaded from file Reading REAL matrix from a binary file... Computed vector at time t=2 has norm 7.87264 slepc-3.7.4/src/mfn/examples/tests/index.html0000644000175000017500000000215213107004621020507 0ustar jromanjroman Matrix Function - MFN
slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

test1.c: Computes exp(A)*v for a matrix loaded from file
makefile
slepc-3.7.4/src/mfn/makefile.html0000644000175000017500000000463513107004621016205 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../include/slepc/private/mfnimpl.h ../../include/slepcmfn.h
DIRS     = interface impls examples f90-mod
LOCDIR   = src/mfn/
MANSEC   = MFN

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/mfn/index.html0000644000175000017500000000246413107004621015535 0ustar jromanjroman Matrix Function - MFN
slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

interface/
impls/
examples/
f90-mod/
../../include/slepc/private/mfnimpl.h
../../include/slepcmfn.h
makefile
slepc-3.7.4/src/mfn/f90-mod/0000755000175000017500000000000013107004621014705 5ustar jromanjromanslepc-3.7.4/src/mfn/f90-mod/makefile0000644000175000017500000000255113107004621016410 0ustar jromanjroman # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_USING_F90' # # Makes Fortran module functions from *.h90 files in include/slepc/finclude # ALL: buildmod_slepc speciallib: buildmod_slepc specialfastlib: buildmod_slepc SPECIALLIB = yes SPECIALFASTLIB = yes CFLAGS = FFLAGS = SOURCEC = SOURCEF = slepcmfnmod.F SOURCEH = LIBBASE = libslepcmfn MANSEC = MFN LOCDIR = src/mfn/f90-mod/ CLEANFILES = *.mod include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/f90-mod/slepcmfnmod.F.html0000644000175000017500000000567013107004621020276 0ustar jromanjroman

Actual source code: slepcmfnmod.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 20: #define PETSC_USE_FORTRAN_MODULES

 22:         module slepcmfndef
 23:         use slepcsys
 24:         use slepcbv
 25:         use slepcfn
 26: #include <slepc/finclude/slepcmfn.h>
 27: #include <slepc/finclude/ftn-custom/slepcmfndef.h90>
 28:         end module

 30:         module slepcmfn
 31:         use slepcmfndef
 32: #include <slepc/finclude/slepcmfn.h90>
 33:         end module

slepc-3.7.4/src/mfn/f90-mod/makefile.html0000644000175000017500000000552413107004621017356 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#requiresdefine   'PETSC_USING_F90'
#
#   Makes Fortran module functions from *.h90 files in include/slepc/finclude
#
ALL: buildmod_slepc
speciallib: buildmod_slepc
specialfastlib: buildmod_slepc
SPECIALLIB     = yes
SPECIALFASTLIB = yes


CFLAGS     =
FFLAGS     =
SOURCEC    =
SOURCEF    = slepcmfnmod.F
SOURCEH    =
LIBBASE    = libslepcmfn
MANSEC     = MFN
LOCDIR     = src/mfn/f90-mod/
CLEANFILES = *.mod

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/mfn/f90-mod/slepcmfnmod.F0000644000175000017500000000236613107004621017332 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define PETSC_USE_FORTRAN_MODULES module slepcmfndef use slepcsys use slepcbv use slepcfn #include #include end module module slepcmfn use slepcmfndef #include end module slepc-3.7.4/src/mfn/f90-mod/index.html0000644000175000017500000000207113107004621016702 0ustar jromanjroman Matrix Function - MFN
slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

slepcmfnmod.F
makefile
slepc-3.7.4/src/mfn/impls/0000755000175000017500000000000013107004621014656 5ustar jromanjromanslepc-3.7.4/src/mfn/impls/makefile0000644000175000017500000000206613107004621016362 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcmfn DIRS = krylov expokit LOCDIR = src/mfn/impls/ MANSEC = MFN include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/impls/makefile.html0000644000175000017500000000455213107004621017327 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcmfn
DIRS     = krylov expokit
LOCDIR   = src/mfn/impls/
MANSEC   = MFN

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/mfn/impls/expokit/0000755000175000017500000000000013107004621016341 5ustar jromanjromanslepc-3.7.4/src/mfn/impls/expokit/makefile0000644000175000017500000000216313107004621020043 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = mfnexpokit.c SOURCEF = SOURCEH = LIBBASE = libslepcmfn DIRS = MANSEC = MFN LOCDIR = src/mfn/impls/expokit/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/impls/expokit/makefile.html0000644000175000017500000000466713107004621021021 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = mfnexpokit.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcmfn
DIRS     =
MANSEC   = MFN
LOCDIR   = src/mfn/impls/expokit/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/mfn/impls/expokit/mfnexpokit.c.html0000644000175000017500000003437413107004621021647 0ustar jromanjroman
Actual source code: mfnexpokit.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc matrix function solver: "expokit"

  5:    Method: Arnoldi method tailored for the matrix exponential

  7:    Algorithm:

  9:        Uses Arnoldi relations to compute exp(t_step*A)*v_last for
 10:        several time steps.

 12:    References:

 14:        [1] R. Sidje, "Expokit: a software package for computing matrix
 15:            exponentials", ACM Trans. Math. Softw. 24(1):130-156, 1998.

 17:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 19:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 21:    This file is part of SLEPc.

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

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

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

 37: #include <slepc/private/mfnimpl.h>

 41: PetscErrorCode MFNSetUp_Expokit(MFN mfn)
 42: {
 44:   PetscInt       N;
 45:   PetscBool      isexp;

 48:   MatGetSize(mfn->A,&N,NULL);
 49:   if (!mfn->ncv) mfn->ncv = PetscMin(30,N);
 50:   if (!mfn->max_it) mfn->max_it = 100;
 51:   MFNAllocateSolution(mfn,2);

 53:   PetscObjectTypeCompare((PetscObject)mfn->fn,FNEXP,&isexp);
 54:   if (!isexp) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This solver only supports the exponential function");
 55:   return(0);
 56: }

 60: PetscErrorCode MFNSolve_Expokit(MFN mfn,Vec b,Vec x)
 61: {
 63:   PetscInt       mxstep,mxrej,m,mb,ld,i,j,ireject,mx,k1;
 64:   Vec            v,r;
 65:   Mat            M=NULL,K=NULL;
 66:   FN             fn;
 67:   PetscScalar    *H,*B,*F,*betaF,t,sgn,sfactor;
 68:   PetscReal      anorm,avnorm,tol,err_loc,rndoff;
 69:   PetscReal      t_out,t_new,t_now,t_step;
 70:   PetscReal      xm,fact,s,p1,p2;
 71:   PetscReal      beta,beta2,gamma,delta;
 72:   PetscBool      breakdown;

 75:   m   = mfn->ncv;
 76:   tol = mfn->tol;
 77:   mxstep = mfn->max_it;
 78:   mxrej = 10;
 79:   gamma = 0.9;
 80:   delta = 1.2;
 81:   mb    = m;
 82:   FNGetScale(mfn->fn,&t,&sfactor);
 83:   FNDuplicate(mfn->fn,PetscObjectComm((PetscObject)mfn->fn),&fn);
 84:   FNSetScale(fn,1.0,1.0);
 85:   t_out = PetscAbsScalar(t);
 86:   t_now = 0.0;
 87:   MatNorm(mfn->A,NORM_INFINITY,&anorm);
 88:   rndoff = anorm*PETSC_MACHINE_EPSILON;

 90:   k1 = 2;
 91:   xm = 1.0/(PetscReal)m;
 92:   beta = mfn->bnorm;
 93:   fact = PetscPowRealInt((m+1)/2.72,m+1)*PetscSqrtReal(2*PETSC_PI*(m+1));
 94:   t_new = (1.0/anorm)*PetscPowReal((fact*tol)/(4.0*beta*anorm),xm);
 95:   s = PetscPowReal(10.0,PetscFloorReal(PetscLog10Real(t_new))-1);
 96:   t_new = PetscCeilReal(t_new/s)*s;
 97:   sgn = t/PetscAbsScalar(t);

 99:   VecCopy(b,x);
100:   ld = m+2;
101:   PetscCalloc3(m+1,&betaF,ld*ld,&H,ld*ld,&B);

103:   while (mfn->reason == MFN_CONVERGED_ITERATING) {
104:     mfn->its++;
105:     if (PetscIsInfOrNanReal(t_new)) t_new = PETSC_MAX_REAL;
106:     t_step = PetscMin(t_out-t_now,t_new);
107:     BVInsertVec(mfn->V,0,x);
108:     BVScaleColumn(mfn->V,0,1.0/beta);
109:     MFNBasicArnoldi(mfn,H,ld,0,&mb,&beta2,&breakdown);
110:     if (breakdown) {
111:       k1 = 0;
112:       t_step = t_out-t_now;
113:     }
114:     if (k1!=0) {
115:       H[m+1+ld*m] = 1.0;
116:       BVGetColumn(mfn->V,m,&v);
117:       BVGetColumn(mfn->V,m+1,&r);
118:       MatMult(mfn->A,v,r);
119:       BVRestoreColumn(mfn->V,m,&v);
120:       BVRestoreColumn(mfn->V,m+1,&r);
121:       BVNormColumn(mfn->V,m+1,NORM_2,&avnorm);
122:     }
123:     PetscMemcpy(B,H,ld*ld*sizeof(PetscScalar));

125:     ireject = 0;
126:     while (ireject <= mxrej) {
127:       mx = mb + k1;
128:       for (i=0;i<mx;i++) {
129:         for (j=0;j<mx;j++) {
130:           H[i+j*ld] = sgn*B[i+j*ld]*t_step;
131:         }
132:       }
133:       MFN_CreateDenseMat(mx,&M);
134:       MFN_CreateDenseMat(mx,&K);
135:       MatDenseGetArray(M,&F);
136:       for (j=0;j<mx;j++) {
137:         PetscMemcpy(F+j*mx,H+j*ld,mx*sizeof(PetscScalar));
138:       }
139:       MatDenseRestoreArray(M,&F);
140:       FNEvaluateFunctionMat(fn,M,K);

142:       if (k1==0) {
143:         err_loc = tol;
144:         break;
145:       } else {
146:         MatDenseGetArray(K,&F);
147:         p1 = PetscAbsScalar(beta*F[m]);
148:         p2 = PetscAbsScalar(beta*F[m+1]*avnorm);
149:         MatDenseRestoreArray(K,&F);
150:         if (p1 > 10*p2) {
151:           err_loc = p2;
152:           xm = 1.0/(PetscReal)m;
153:         } else if (p1 > p2) {
154:           err_loc = (p1*p2)/(p1-p2);
155:           xm = 1.0/(PetscReal)m;
156:         } else {
157:           err_loc = p1;
158:           xm = 1.0/(PetscReal)(m-1);
159:         }
160:       }
161:       if (err_loc <= delta*t_step*tol) break;
162:       else {
163:         t_step = gamma*t_step*PetscPowReal(t_step*tol/err_loc,xm);
164:         s = PetscPowReal(10.0,PetscFloorReal(PetscLog10Real(t_step))-1);
165:         t_step = PetscCeilReal(t_step/s)*s;
166:         ireject = ireject+1;
167:       }
168:     }

170:     mx = mb + PetscMax(0,k1-1);
171:     MatDenseGetArray(K,&F);
172:     for (j=0;j<mx;j++) betaF[j] = beta*F[j];
173:     MatDenseRestoreArray(K,&F);
174:     BVSetActiveColumns(mfn->V,0,mx);
175:     BVMultVec(mfn->V,1.0,0.0,x,betaF);
176:     VecNorm(x,NORM_2,&beta);

178:     t_now = t_now+t_step;
179:     if (t_now>=t_out) mfn->reason = MFN_CONVERGED_TOL;
180:     else {
181:       t_new = gamma*t_step*PetscPowReal((t_step*tol)/err_loc,xm);
182:       s = PetscPowReal(10.0,PetscFloorReal(PetscLog10Real(t_new))-1);
183:       t_new = PetscCeilReal(t_new/s)*s;
184:     }
185:     err_loc = PetscMax(err_loc,rndoff);
186:     if (mfn->its==mxstep) mfn->reason = MFN_DIVERGED_ITS;
187:     MFNMonitor(mfn,mfn->its,err_loc);
188:   }
189:   VecScale(x,sfactor);

191:   MatDestroy(&M);
192:   MatDestroy(&K);
193:   FNDestroy(&fn);
194:   PetscFree3(betaF,H,B);
195:   return(0);
196: }

200: PETSC_EXTERN PetscErrorCode MFNCreate_Expokit(MFN mfn)
201: {
203:   mfn->ops->solve          = MFNSolve_Expokit;
204:   mfn->ops->setup          = MFNSetUp_Expokit;
205:   return(0);
206: }
slepc-3.7.4/src/mfn/impls/expokit/mfnexpokit.c0000644000175000017500000001541613107004621020700 0ustar jromanjroman/* SLEPc matrix function solver: "expokit" Method: Arnoldi method tailored for the matrix exponential Algorithm: Uses Arnoldi relations to compute exp(t_step*A)*v_last for several time steps. References: [1] R. Sidje, "Expokit: a software package for computing matrix exponentials", ACM Trans. Math. Softw. 24(1):130-156, 1998. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #undef __FUNCT__ #define __FUNCT__ "MFNSetUp_Expokit" PetscErrorCode MFNSetUp_Expokit(MFN mfn) { PetscErrorCode ierr; PetscInt N; PetscBool isexp; PetscFunctionBegin; ierr = MatGetSize(mfn->A,&N,NULL);CHKERRQ(ierr); if (!mfn->ncv) mfn->ncv = PetscMin(30,N); if (!mfn->max_it) mfn->max_it = 100; ierr = MFNAllocateSolution(mfn,2);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)mfn->fn,FNEXP,&isexp);CHKERRQ(ierr); if (!isexp) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This solver only supports the exponential function"); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSolve_Expokit" PetscErrorCode MFNSolve_Expokit(MFN mfn,Vec b,Vec x) { PetscErrorCode ierr; PetscInt mxstep,mxrej,m,mb,ld,i,j,ireject,mx,k1; Vec v,r; Mat M=NULL,K=NULL; FN fn; PetscScalar *H,*B,*F,*betaF,t,sgn,sfactor; PetscReal anorm,avnorm,tol,err_loc,rndoff; PetscReal t_out,t_new,t_now,t_step; PetscReal xm,fact,s,p1,p2; PetscReal beta,beta2,gamma,delta; PetscBool breakdown; PetscFunctionBegin; m = mfn->ncv; tol = mfn->tol; mxstep = mfn->max_it; mxrej = 10; gamma = 0.9; delta = 1.2; mb = m; ierr = FNGetScale(mfn->fn,&t,&sfactor);CHKERRQ(ierr); ierr = FNDuplicate(mfn->fn,PetscObjectComm((PetscObject)mfn->fn),&fn);CHKERRQ(ierr); ierr = FNSetScale(fn,1.0,1.0);CHKERRQ(ierr); t_out = PetscAbsScalar(t); t_now = 0.0; ierr = MatNorm(mfn->A,NORM_INFINITY,&anorm);CHKERRQ(ierr); rndoff = anorm*PETSC_MACHINE_EPSILON; k1 = 2; xm = 1.0/(PetscReal)m; beta = mfn->bnorm; fact = PetscPowRealInt((m+1)/2.72,m+1)*PetscSqrtReal(2*PETSC_PI*(m+1)); t_new = (1.0/anorm)*PetscPowReal((fact*tol)/(4.0*beta*anorm),xm); s = PetscPowReal(10.0,PetscFloorReal(PetscLog10Real(t_new))-1); t_new = PetscCeilReal(t_new/s)*s; sgn = t/PetscAbsScalar(t); ierr = VecCopy(b,x);CHKERRQ(ierr); ld = m+2; ierr = PetscCalloc3(m+1,&betaF,ld*ld,&H,ld*ld,&B);CHKERRQ(ierr); while (mfn->reason == MFN_CONVERGED_ITERATING) { mfn->its++; if (PetscIsInfOrNanReal(t_new)) t_new = PETSC_MAX_REAL; t_step = PetscMin(t_out-t_now,t_new); ierr = BVInsertVec(mfn->V,0,x);CHKERRQ(ierr); ierr = BVScaleColumn(mfn->V,0,1.0/beta);CHKERRQ(ierr); ierr = MFNBasicArnoldi(mfn,H,ld,0,&mb,&beta2,&breakdown);CHKERRQ(ierr); if (breakdown) { k1 = 0; t_step = t_out-t_now; } if (k1!=0) { H[m+1+ld*m] = 1.0; ierr = BVGetColumn(mfn->V,m,&v);CHKERRQ(ierr); ierr = BVGetColumn(mfn->V,m+1,&r);CHKERRQ(ierr); ierr = MatMult(mfn->A,v,r);CHKERRQ(ierr); ierr = BVRestoreColumn(mfn->V,m,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(mfn->V,m+1,&r);CHKERRQ(ierr); ierr = BVNormColumn(mfn->V,m+1,NORM_2,&avnorm);CHKERRQ(ierr); } ierr = PetscMemcpy(B,H,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); ireject = 0; while (ireject <= mxrej) { mx = mb + k1; for (i=0;i 10*p2) { err_loc = p2; xm = 1.0/(PetscReal)m; } else if (p1 > p2) { err_loc = (p1*p2)/(p1-p2); xm = 1.0/(PetscReal)m; } else { err_loc = p1; xm = 1.0/(PetscReal)(m-1); } } if (err_loc <= delta*t_step*tol) break; else { t_step = gamma*t_step*PetscPowReal(t_step*tol/err_loc,xm); s = PetscPowReal(10.0,PetscFloorReal(PetscLog10Real(t_step))-1); t_step = PetscCeilReal(t_step/s)*s; ireject = ireject+1; } } mx = mb + PetscMax(0,k1-1); ierr = MatDenseGetArray(K,&F);CHKERRQ(ierr); for (j=0;jV,0,mx);CHKERRQ(ierr); ierr = BVMultVec(mfn->V,1.0,0.0,x,betaF);CHKERRQ(ierr); ierr = VecNorm(x,NORM_2,&beta);CHKERRQ(ierr); t_now = t_now+t_step; if (t_now>=t_out) mfn->reason = MFN_CONVERGED_TOL; else { t_new = gamma*t_step*PetscPowReal((t_step*tol)/err_loc,xm); s = PetscPowReal(10.0,PetscFloorReal(PetscLog10Real(t_new))-1); t_new = PetscCeilReal(t_new/s)*s; } err_loc = PetscMax(err_loc,rndoff); if (mfn->its==mxstep) mfn->reason = MFN_DIVERGED_ITS; ierr = MFNMonitor(mfn,mfn->its,err_loc);CHKERRQ(ierr); } ierr = VecScale(x,sfactor);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); ierr = MatDestroy(&K);CHKERRQ(ierr); ierr = FNDestroy(&fn);CHKERRQ(ierr); ierr = PetscFree3(betaF,H,B);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNCreate_Expokit" PETSC_EXTERN PetscErrorCode MFNCreate_Expokit(MFN mfn) { PetscFunctionBegin; mfn->ops->solve = MFNSolve_Expokit; mfn->ops->setup = MFNSetUp_Expokit; PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/impls/expokit/index.html0000644000175000017500000000210313107004621020332 0ustar jromanjroman Matrix Function - MFN
slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

mfnexpokit.c
makefile
slepc-3.7.4/src/mfn/impls/index.html0000644000175000017500000000211013107004621016645 0ustar jromanjroman Matrix Function - MFN

slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

krylov/
expokit/
makefile
slepc-3.7.4/src/mfn/impls/krylov/0000755000175000017500000000000013107004621016204 5ustar jromanjromanslepc-3.7.4/src/mfn/impls/krylov/makefile0000644000175000017500000000216113107004621017704 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = mfnkrylov.c SOURCEF = SOURCEH = LIBBASE = libslepcmfn DIRS = MANSEC = MFN LOCDIR = src/mfn/impls/krylov/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/mfn/impls/krylov/mfnkrylov.c0000644000175000017500000001410213107004621020375 0ustar jromanjroman/* SLEPc matrix function solver: "krylov" Method: Arnoldi with Eiermann-Ernst restart Algorithm: Build Arnoldi approximations using f(H) for the Hessenberg matrix H, restart by discarding the Krylov basis but keeping H. References: [1] M. Eiermann and O. Ernst, "A restarted Krylov subspace method for the evaluation of matrix functions", SIAM J. Numer. Anal. 44(6):2481-2504, 2006. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "MFNSetUp_Krylov" PetscErrorCode MFNSetUp_Krylov(MFN mfn) { PetscErrorCode ierr; PetscInt N; PetscFunctionBegin; ierr = MatGetSize(mfn->A,&N,NULL);CHKERRQ(ierr); if (!mfn->ncv) mfn->ncv = PetscMin(30,N); if (!mfn->max_it) mfn->max_it = 100; ierr = MFNAllocateSolution(mfn,1);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNBasicArnoldi" PetscErrorCode MFNBasicArnoldi(MFN mfn,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown) { PetscErrorCode ierr; PetscInt j,m = *M; Vec vj,vj1; PetscFunctionBegin; ierr = BVSetActiveColumns(mfn->V,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(mfn->V,j+1,&vj1);CHKERRQ(ierr); ierr = MatMult(mfn->A,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(mfn->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(mfn->V,j+1,&vj1);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(mfn->V,j+1,H+ldh*j,beta,breakdown);CHKERRQ(ierr); H[j+1+ldh*j] = *beta; if (*breakdown) { *M = j+1; break; } else { ierr = BVScaleColumn(mfn->V,j+1,1.0/(*beta));CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNSolve_Krylov" PetscErrorCode MFNSolve_Krylov(MFN mfn,Vec b,Vec x) { PetscErrorCode ierr; PetscInt n=0,m,ld,ldh,j; PetscBLASInt m_,inc=1; Mat G=NULL,H=NULL; Vec F=NULL; PetscScalar *array,*farray,*garray,*harray; PetscReal beta,betaold=0.0,nrm=1.0; PetscBool breakdown,set,flg,symm=PETSC_FALSE; PetscFunctionBegin; m = mfn->ncv; ld = m+1; ierr = PetscCalloc1(ld*ld,&array);CHKERRQ(ierr); /* set initial vector to b/||b|| */ ierr = BVInsertVec(mfn->V,0,b);CHKERRQ(ierr); ierr = BVScaleColumn(mfn->V,0,1.0/mfn->bnorm);CHKERRQ(ierr); ierr = VecSet(x,0.0);CHKERRQ(ierr); /* Restart loop */ while (mfn->reason == MFN_CONVERGED_ITERATING) { mfn->its++; /* compute Arnoldi factorization */ ierr = MFNBasicArnoldi(mfn,array,ld,0,&m,&beta,&breakdown);CHKERRQ(ierr); /* save previous Hessenberg matrix in G; allocate new storage for H and f(H) */ if (mfn->its>1) { G = H; H = NULL; } ldh = n+m; ierr = MFN_CreateVec(ldh,&F);CHKERRQ(ierr); ierr = MFN_CreateDenseMat(ldh,&H);CHKERRQ(ierr); /* glue together the previous H and the new H obtained with Arnoldi */ ierr = MatDenseGetArray(H,&harray);CHKERRQ(ierr); for (j=0;jits>1) { ierr = MatDenseGetArray(G,&garray);CHKERRQ(ierr); for (j=0;jits==1) { /* set symmetry flag of H from A */ ierr = MatIsHermitianKnown(mfn->A,&set,&flg);CHKERRQ(ierr); symm = set? flg: PETSC_FALSE; if (symm) { ierr = MatSetOption(H,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); } } /* evaluate f(H) */ ierr = FNEvaluateFunctionMatVec(mfn->fn,H,F);CHKERRQ(ierr); /* x += ||b||*V*f(H)*e_1 */ ierr = VecGetArray(F,&farray);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&m_);CHKERRQ(ierr); nrm = BLASnrm2_(&m_,farray+n,&inc); /* relative norm of the update ||u||/||b|| */ ierr = MFNMonitor(mfn,mfn->its,nrm);CHKERRQ(ierr); for (j=0;jbnorm; ierr = BVSetActiveColumns(mfn->V,0,m);CHKERRQ(ierr); ierr = BVMultVec(mfn->V,1.0,1.0,x,farray+n);CHKERRQ(ierr); ierr = VecRestoreArray(F,&farray);CHKERRQ(ierr); /* check convergence */ if (mfn->its>1) { if (mfn->its >= mfn->max_it) mfn->reason = MFN_DIVERGED_ITS; if (mncv || breakdown || beta==0.0 || nrmtol) mfn->reason = MFN_CONVERGED_TOL; } /* restart with vector v_{m+1} */ if (mfn->reason == MFN_CONVERGED_ITERATING) { ierr = BVCopyColumn(mfn->V,m,0);CHKERRQ(ierr); n += m; betaold = beta; } } ierr = MatDestroy(&H);CHKERRQ(ierr); ierr = MatDestroy(&G);CHKERRQ(ierr); ierr = VecDestroy(&F);CHKERRQ(ierr); ierr = PetscFree(array);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MFNCreate_Krylov" PETSC_EXTERN PetscErrorCode MFNCreate_Krylov(MFN mfn) { PetscFunctionBegin; mfn->ops->solve = MFNSolve_Krylov; mfn->ops->setup = MFNSetUp_Krylov; PetscFunctionReturn(0); } slepc-3.7.4/src/mfn/impls/krylov/makefile.html0000644000175000017500000000466313107004621020660 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = mfnkrylov.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcmfn
DIRS     =
MANSEC   = MFN
LOCDIR   = src/mfn/impls/krylov/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/mfn/impls/krylov/index.html0000644000175000017500000000207713107004621020207 0ustar jromanjroman Matrix Function - MFN
slepc-3.7.4 2017-05-17

Matrix Function - MFN: Examples

Matrix Function (MFN) is the object provided by SLEPc for computing the action of a matrix function on a vector. Given a matrix A and a vector b, the call MFNSolve(mfn,b,x) computes x=f(A)b, where f is a function such as the exponential.

mfnkrylov.c
makefile
slepc-3.7.4/src/mfn/impls/krylov/mfnkrylov.c.html0000644000175000017500000003173513107004621021353 0ustar jromanjroman

Actual source code: mfnkrylov.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc matrix function solver: "krylov"

  5:    Method: Arnoldi with Eiermann-Ernst restart

  7:    Algorithm:

  9:        Build Arnoldi approximations using f(H) for the Hessenberg matrix H,
 10:        restart by discarding the Krylov basis but keeping H.

 12:    References:

 14:        [1] M. Eiermann and O. Ernst, "A restarted Krylov subspace method
 15:            for the evaluation of matrix functions", SIAM J. Numer. Anal.
 16:            44(6):2481-2504, 2006.

 18:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 20:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 22:    This file is part of SLEPc.

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

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

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

 38: #include <slepc/private/mfnimpl.h>
 39: #include <slepcblaslapack.h>

 43: PetscErrorCode MFNSetUp_Krylov(MFN mfn)
 44: {
 46:   PetscInt       N;

 49:   MatGetSize(mfn->A,&N,NULL);
 50:   if (!mfn->ncv) mfn->ncv = PetscMin(30,N);
 51:   if (!mfn->max_it) mfn->max_it = 100;
 52:   MFNAllocateSolution(mfn,1);
 53:   return(0);
 54: }

 58: PetscErrorCode MFNBasicArnoldi(MFN mfn,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)
 59: {
 61:   PetscInt       j,m = *M;
 62:   Vec            vj,vj1;

 65:   BVSetActiveColumns(mfn->V,0,m);
 66:   for (j=k;j<m;j++) {
 67:     BVGetColumn(mfn->V,j,&vj);
 68:     BVGetColumn(mfn->V,j+1,&vj1);
 69:     MatMult(mfn->A,vj,vj1);
 70:     BVRestoreColumn(mfn->V,j,&vj);
 71:     BVRestoreColumn(mfn->V,j+1,&vj1);
 72:     BVOrthogonalizeColumn(mfn->V,j+1,H+ldh*j,beta,breakdown);
 73:     H[j+1+ldh*j] = *beta;
 74:     if (*breakdown) {
 75:       *M = j+1;
 76:       break;
 77:     } else {
 78:       BVScaleColumn(mfn->V,j+1,1.0/(*beta));
 79:     }
 80:   }
 81:   return(0);
 82: }

 86: PetscErrorCode MFNSolve_Krylov(MFN mfn,Vec b,Vec x)
 87: {
 89:   PetscInt       n=0,m,ld,ldh,j;
 90:   PetscBLASInt   m_,inc=1;
 91:   Mat            G=NULL,H=NULL;
 92:   Vec            F=NULL;
 93:   PetscScalar    *array,*farray,*garray,*harray;
 94:   PetscReal      beta,betaold=0.0,nrm=1.0;
 95:   PetscBool      breakdown,set,flg,symm=PETSC_FALSE;

 98:   m  = mfn->ncv;
 99:   ld = m+1;
100:   PetscCalloc1(ld*ld,&array);

102:   /* set initial vector to b/||b|| */
103:   BVInsertVec(mfn->V,0,b);
104:   BVScaleColumn(mfn->V,0,1.0/mfn->bnorm);
105:   VecSet(x,0.0);

107:   /* Restart loop */
108:   while (mfn->reason == MFN_CONVERGED_ITERATING) {
109:     mfn->its++;

111:     /* compute Arnoldi factorization */
112:     MFNBasicArnoldi(mfn,array,ld,0,&m,&beta,&breakdown);

114:     /* save previous Hessenberg matrix in G; allocate new storage for H and f(H) */
115:     if (mfn->its>1) { G = H; H = NULL; }
116:     ldh = n+m;
117:     MFN_CreateVec(ldh,&F);
118:     MFN_CreateDenseMat(ldh,&H);

120:     /* glue together the previous H and the new H obtained with Arnoldi */
121:     MatDenseGetArray(H,&harray);
122:     for (j=0;j<m;j++) {
123:       PetscMemcpy(harray+n+(j+n)*ldh,array+j*ld,m*sizeof(PetscScalar));
124:     }
125:     if (mfn->its>1) {
126:       MatDenseGetArray(G,&garray);
127:       for (j=0;j<n;j++) {
128:         PetscMemcpy(harray+j*ldh,garray+j*n,n*sizeof(PetscScalar));
129:       }
130:       MatDenseRestoreArray(G,&garray);
131:       MatDestroy(&G);
132:       harray[n+(n-1)*ldh] = betaold;
133:     }
134:     MatDenseRestoreArray(H,&harray);

136:     if (mfn->its==1) {
137:       /* set symmetry flag of H from A */
138:       MatIsHermitianKnown(mfn->A,&set,&flg);
139:       symm = set? flg: PETSC_FALSE;
140:       if (symm) {
141:         MatSetOption(H,MAT_HERMITIAN,PETSC_TRUE);
142:       }
143:     }

145:     /* evaluate f(H) */
146:     FNEvaluateFunctionMatVec(mfn->fn,H,F);

148:     /* x += ||b||*V*f(H)*e_1 */
149:     VecGetArray(F,&farray);
150:     PetscBLASIntCast(m,&m_);
151:     nrm = BLASnrm2_(&m_,farray+n,&inc);   /* relative norm of the update ||u||/||b|| */
152:     MFNMonitor(mfn,mfn->its,nrm);
153:     for (j=0;j<m;j++) farray[j+n] *= mfn->bnorm;
154:     BVSetActiveColumns(mfn->V,0,m);
155:     BVMultVec(mfn->V,1.0,1.0,x,farray+n);
156:     VecRestoreArray(F,&farray);

158:     /* check convergence */
159:     if (mfn->its>1) {
160:       if (mfn->its >= mfn->max_it) mfn->reason = MFN_DIVERGED_ITS;
161:       if (m<mfn->ncv || breakdown || beta==0.0 || nrm<mfn->tol) mfn->reason = MFN_CONVERGED_TOL;
162:     }

164:     /* restart with vector v_{m+1} */
165:     if (mfn->reason == MFN_CONVERGED_ITERATING) {
166:       BVCopyColumn(mfn->V,m,0);
167:       n += m;
168:       betaold = beta;
169:     }
170:   }

172:   MatDestroy(&H);
173:   MatDestroy(&G);
174:   VecDestroy(&F);
175:   PetscFree(array);
176:   return(0);
177: }

181: PETSC_EXTERN PetscErrorCode MFNCreate_Krylov(MFN mfn)
182: {
184:   mfn->ops->solve          = MFNSolve_Krylov;
185:   mfn->ops->setup          = MFNSetUp_Krylov;
186:   return(0);
187: }
slepc-3.7.4/src/svd/0000755000175000017500000000000013107004621013546 5ustar jromanjromanslepc-3.7.4/src/svd/makefile0000644000175000017500000000216513107004621015252 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../include/slepc/private/svdimpl.h ../../include/slepcsvd.h DIRS = interface impls examples f90-mod LOCDIR = src/svd/ MANSEC = SVD include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/interface/0000755000175000017500000000000013107004621015506 5ustar jromanjromanslepc-3.7.4/src/svd/interface/svdmon.c0000644000175000017500000003436713107004621017175 0ustar jromanjroman/* SVD routines related to monitors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "SVDMonitor" /* Runs the user provided monitor routines, if any. */ PetscErrorCode SVDMonitor(SVD svd,PetscInt it,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest) { PetscErrorCode ierr; PetscInt i,n = svd->numbermonitors; PetscFunctionBegin; for (i=0;imonitor[i])(svd,it,nconv,sigma,errest,nest,svd->monitorcontext[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorSet" /*@C SVDMonitorSet - Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested singular triplet. Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() . monitor - pointer to function (if this is NULL, it turns off monitoring) - mctx - [optional] context for private data for the monitor routine (use NULL if no context is desired) Calling Sequence of monitor: $ monitor(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *mctx) + svd - singular value solver context obtained from SVDCreate() . its - iteration number . nconv - number of converged singular triplets . sigma - singular values . errest - relative error estimates for each singular triplet . nest - number of error estimates - mctx - optional monitoring context, as set by SVDMonitorSet() Options Database Keys: + -svd_monitor - print only the first error estimate . -svd_monitor_all - print error estimates at each iteration . -svd_monitor_conv - print the singular value approximations only when convergence has been reached . -svd_monitor_lg - sets line graph monitor for the first unconverged approximate singular value . -svd_monitor_lg_all - sets line graph monitor for all unconverged approximate singular values - -svd_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to SVDMonitorSet(), but does not cancel those set via the options database. Notes: Several different monitoring routines may be set by calling SVDMonitorSet() multiple times; all will be called in the order in which they were set. Level: intermediate .seealso: SVDMonitorFirst(), SVDMonitorAll(), SVDMonitorCancel() @*/ PetscErrorCode SVDMonitorSet(SVD svd,PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**)) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (svd->numbermonitors >= MAXSVDMONITORS) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Too many SVD monitors set"); svd->monitor[svd->numbermonitors] = monitor; svd->monitorcontext[svd->numbermonitors] = (void*)mctx; svd->monitordestroy[svd->numbermonitors++] = monitordestroy; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorCancel" /*@ SVDMonitorCancel - Clears all monitors for an SVD object. Collective on SVD Input Parameters: . svd - singular value solver context obtained from SVDCreate() Options Database Key: . -svd_monitor_cancel - Cancels all monitors that have been hardwired into a code by calls to SVDMonitorSet(), but does not cancel those set via the options database. Level: intermediate .seealso: SVDMonitorSet() @*/ PetscErrorCode SVDMonitorCancel(SVD svd) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); for (i=0; inumbermonitors; i++) { if (svd->monitordestroy[i]) { ierr = (*svd->monitordestroy[i])(&svd->monitorcontext[i]);CHKERRQ(ierr); } } svd->numbermonitors = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetMonitorContext" /*@C SVDGetMonitorContext - Gets the monitor context, as set by SVDMonitorSet() for the FIRST monitor only. Not Collective Input Parameter: . svd - singular value solver context obtained from SVDCreate() Output Parameter: . ctx - monitor context Level: intermediate .seealso: SVDMonitorSet() @*/ PetscErrorCode SVDGetMonitorContext(SVD svd,void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); *ctx = svd->monitorcontext[0]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorAll" /*@C SVDMonitorAll - Print the current approximate values and error estimates at each iteration of the singular value solver. Collective on SVD Input Parameters: + svd - singular value solver context . its - iteration number . nconv - number of converged singular triplets so far . sigma - singular values . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: SVDMonitorSet(), SVDMonitorFirst(), SVDMonitorConverged() @*/ PetscErrorCode SVDMonitorAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscInt i; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(vf,7); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,7); ierr = PetscViewerPushFormat(viewer,vf->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);CHKERRQ(ierr); if (its==1 && ((PetscObject)svd)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Singular value approximations and residual norms for %s solve.\n",((PetscObject)svd)->prefix);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"%3D SVD nconv=%D Values (Errors)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;itablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorFirst" /*@C SVDMonitorFirst - Print the first unconverged approximate values and error estimates at each iteration of the singular value solver. Collective on SVD Input Parameters: + svd - singular value solver context . its - iteration number . nconv - number of converged singular triplets so far . sigma - singular values . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: SVDMonitorSet(), SVDMonitorAll(), SVDMonitorConverged() @*/ PetscErrorCode SVDMonitorFirst(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(vf,7); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,7); if (its==1 && ((PetscObject)svd)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Singular value approximations and residual norms for %s solve.\n",((PetscObject)svd)->prefix);CHKERRQ(ierr); } if (nconvformat);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%3D SVD nconv=%D first unconverged value (error)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," %g (%10.8e)\n",(double)sigma[nconv],(double)errest[nconv]);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)svd)->tablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorConverged" /*@C SVDMonitorConverged - Print the approximate values and error estimates as they converge. Collective on SVD Input Parameters: + svd - singular value solver context . its - iteration number . nconv - number of converged singular triplets so far . sigma - singular values . errest - error estimates . nest - number of error estimates to display - ctx - monitor context Level: intermediate .seealso: SVDMonitorSet(), SVDMonitorFirst(), SVDMonitorAll() @*/ PetscErrorCode SVDMonitorConverged(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx) { PetscErrorCode ierr; PetscInt i; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(ctx,7); viewer = ctx->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,7); if (its==1 && ((PetscObject)svd)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Convergence history for %s solve.\n",((PetscObject)svd)->prefix);CHKERRQ(ierr); } if (its==1) ctx->oldnconv = 0; if (ctx->oldnconv!=nconv) { ierr = PetscViewerPushFormat(viewer,ctx->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);CHKERRQ(ierr); for (i=ctx->oldnconv;itablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ctx->oldnconv = nconv; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorLGCreate" /*@C SVDMonitorLGCreate - Creates a line graph context for use with SVD to monitor convergence. Collective on MPI_Comm Input Parameters: + comm - communicator context . host - the X display to open, or null for the local machine . label - the title to put in the title bar . x, y - the screen coordinates of the upper left coordinate of the window - m, n - the screen width and height in pixels Output Parameter: . lgctx - the drawing context Options Database Keys: + -svd_monitor_lg - Sets line graph monitor for the first residual - -svd_monitor_lg_all - Sets line graph monitor for all residuals Notes: Use PetscDrawLGDestroy() to destroy this line graph. Level: intermediate .seealso: SVDMonitorSet() @*/ PetscErrorCode SVDMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx) { PetscDraw draw; PetscDrawLG lg; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscDrawCreate(comm,host,label,x,y,m,n,&draw);CHKERRQ(ierr); ierr = PetscDrawSetFromOptions(draw);CHKERRQ(ierr); ierr = PetscDrawLGCreate(draw,1,&lg);CHKERRQ(ierr); ierr = PetscDrawLGSetFromOptions(lg);CHKERRQ(ierr); ierr = PetscDrawDestroy(&draw);CHKERRQ(ierr); *lgctx = lg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorLG" PetscErrorCode SVDMonitorLG(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscReal x,y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,1);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(svd->tol)-2,0.0);CHKERRQ(ierr); } x = (PetscReal)its; if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]); else y = 0.0; ierr = PetscDrawLGAddPoint(lg,&x,&y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || svd->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorLGAll" PetscErrorCode SVDMonitorLGAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscInt i,n = PetscMin(svd->nsv,255); PetscReal *x,*y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,n);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(svd->tol)-2,0.0);CHKERRQ(ierr); } ierr = PetscMalloc2(n,&x,n,&y);CHKERRQ(ierr); for (i=0;i 0.0) y[i] = PetscLog10Real(errest[i]); else y[i] = 0.0; } ierr = PetscDrawLGAddPoint(lg,x,y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || svd->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } ierr = PetscFree2(x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/svd/interface/makefile0000644000175000017500000000230513107004621017206 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = svdregis.c svdbasic.c svddefault.c svdview.c svdopts.c svdsetup.c svdsolve.c svdmon.c dlregissvd.c SOURCEF = SOURCEH = LIBBASE = libslepcsvd DIRS = MANSEC = SVD LOCDIR = src/svd/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/interface/svdsolve.c.html0000644000175000017500000007302313107004621020467 0ustar jromanjroman
Actual source code: svdsolve.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       SVD routines related to the solution process.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>   /*I "slepcsvd.h" I*/

 28: PetscErrorCode SVDComputeVectors(SVD svd)
 29: {
 31:   Vec            tl,uj,vj;
 32:   PetscInt       j,oldsize;
 33:   PetscReal      norm;

 36:   SVDCheckSolved(svd,1);
 37:   switch (svd->state) {
 38:   case SVD_STATE_SOLVED:
 39:     /* generate left singular vectors on U */
 40:     if (!svd->U) { SVDGetBV(svd,NULL,&svd->U); }
 41:     BVGetSizes(svd->U,NULL,NULL,&oldsize);
 42:     if (!oldsize) {
 43:       if (!((PetscObject)(svd->U))->type_name) {
 44:         BVSetType(svd->U,BVSVEC);
 45:       }
 46:       SVDMatCreateVecs(svd,NULL,&tl);
 47:       BVSetSizesFromVec(svd->U,tl,svd->ncv);
 48:       VecDestroy(&tl);
 49:     }
 50:     for (j=0;j<svd->nconv;j++) {
 51:       BVGetColumn(svd->V,j,&vj);
 52:       BVGetColumn(svd->U,j,&uj);
 53:       SVDMatMult(svd,PETSC_FALSE,vj,uj);
 54:       BVRestoreColumn(svd->V,j,&vj);
 55:       BVRestoreColumn(svd->U,j,&uj);
 56:       BVOrthogonalizeColumn(svd->U,j,NULL,&norm,NULL);
 57:       BVScaleColumn(svd->U,j,1.0/norm);
 58:     }
 59:     break;
 60:   default:
 61:     break;
 62:   }
 63:   svd->state = SVD_STATE_VECTORS;
 64:   return(0);
 65: }

 69: /*@
 70:    SVDSolve - Solves the singular value problem.

 72:    Collective on SVD

 74:    Input Parameter:
 75: .  svd - singular value solver context obtained from SVDCreate()

 77:    Options Database Keys:
 78: +  -svd_view - print information about the solver used
 79: .  -svd_view_mat binary - save the matrix to the default binary viewer
 80: .  -svd_view_vectors binary - save the computed singular vectors to the default binary viewer
 81: .  -svd_view_values - print computed singular values
 82: .  -svd_converged_reason - print reason for convergence, and number of iterations
 83: .  -svd_error_absolute - print absolute errors of each singular triplet
 84: -  -svd_error_relative - print relative errors of each singular triplet

 86:    Level: beginner

 88: .seealso: SVDCreate(), SVDSetUp(), SVDDestroy()
 89: @*/
 90: PetscErrorCode SVDSolve(SVD svd)
 91: {
 93:   PetscInt       i,*workperm;

 97:   if (svd->state>=SVD_STATE_SOLVED) return(0);
 98:   PetscLogEventBegin(SVD_Solve,svd,0,0,0);

100:   /* call setup */
101:   SVDSetUp(svd);
102:   svd->its = 0;
103:   svd->nconv = 0;
104:   for (i=0;i<svd->ncv;i++) {
105:     svd->sigma[i]  = 0.0;
106:     svd->errest[i] = 0.0;
107:     svd->perm[i]   = i;
108:   }
109:   SVDViewFromOptions(svd,NULL,"-svd_view_pre");

111:   (*svd->ops->solve)(svd);
112:   svd->state = (svd->leftbasis)? SVD_STATE_VECTORS: SVD_STATE_SOLVED;

114:   /* sort singular triplets */
115:   if (svd->which == SVD_SMALLEST) {
116:     PetscSortRealWithPermutation(svd->nconv,svd->sigma,svd->perm);
117:   } else {
118:     PetscMalloc1(svd->nconv,&workperm);
119:     for (i=0;i<svd->nconv;i++) workperm[i] = i;
120:     PetscSortRealWithPermutation(svd->nconv,svd->sigma,workperm);
121:     for (i=0;i<svd->nconv;i++) svd->perm[i] = workperm[svd->nconv-i-1];
122:     PetscFree(workperm);
123:   }
124:   PetscLogEventEnd(SVD_Solve,svd,0,0,0);

126:   /* various viewers */
127:   SVDViewFromOptions(svd,NULL,"-svd_view");
128:   SVDReasonViewFromOptions(svd);
129:   SVDErrorViewFromOptions(svd);
130:   SVDValuesViewFromOptions(svd);
131:   SVDVectorsViewFromOptions(svd);
132:   MatViewFromOptions(svd->OP,(PetscObject)svd,"-svd_view_mat");

134:   /* Remove the initial subspaces */
135:   svd->nini = 0;
136:   svd->ninil = 0;
137:   return(0);
138: }

142: /*@
143:    SVDGetIterationNumber - Gets the current iteration number. If the
144:    call to SVDSolve() is complete, then it returns the number of iterations
145:    carried out by the solution method.

147:    Not Collective

149:    Input Parameter:
150: .  svd - the singular value solver context

152:    Output Parameter:
153: .  its - number of iterations

155:    Level: intermediate

157:    Note:
158:    During the i-th iteration this call returns i-1. If SVDSolve() is
159:    complete, then parameter "its" contains either the iteration number at
160:    which convergence was successfully reached, or failure was detected.
161:    Call SVDGetConvergedReason() to determine if the solver converged or
162:    failed and why.

164: .seealso: SVDGetConvergedReason(), SVDSetTolerances()
165: @*/
166: PetscErrorCode SVDGetIterationNumber(SVD svd,PetscInt *its)
167: {
171:   *its = svd->its;
172:   return(0);
173: }

177: /*@
178:    SVDGetConvergedReason - Gets the reason why the SVDSolve() iteration was
179:    stopped.

181:    Not Collective

183:    Input Parameter:
184: .  svd - the singular value solver context

186:    Output Parameter:
187: .  reason - negative value indicates diverged, positive value converged
188:    (see SVDConvergedReason)

190:    Notes:

192:    Possible values for reason are
193: +  SVD_CONVERGED_TOL - converged up to tolerance
194: .  SVD_CONVERGED_USER - converged due to a user-defined condition
195: .  SVD_DIVERGED_ITS - required more than max_it iterations to reach convergence
196: -  SVD_DIVERGED_BREAKDOWN - generic breakdown in method

198:    Can only be called after the call to SVDSolve() is complete.

200:    Level: intermediate

202: .seealso: SVDSetTolerances(), SVDSolve(), SVDConvergedReason
203: @*/
204: PetscErrorCode SVDGetConvergedReason(SVD svd,SVDConvergedReason *reason)
205: {
209:   SVDCheckSolved(svd,1);
210:   *reason = svd->reason;
211:   return(0);
212: }

216: /*@
217:    SVDGetConverged - Gets the number of converged singular values.

219:    Not Collective

221:    Input Parameter:
222: .  svd - the singular value solver context

224:    Output Parameter:
225: .  nconv - number of converged singular values

227:    Note:
228:    This function should be called after SVDSolve() has finished.

230:    Level: beginner

232: @*/
233: PetscErrorCode SVDGetConverged(SVD svd,PetscInt *nconv)
234: {
238:   SVDCheckSolved(svd,1);
239:   *nconv = svd->nconv;
240:   return(0);
241: }

245: /*@
246:    SVDGetSingularTriplet - Gets the i-th triplet of the singular value decomposition
247:    as computed by SVDSolve(). The solution consists in the singular value and its left
248:    and right singular vectors.

250:    Not Collective, but vectors are shared by all processors that share the SVD

252:    Input Parameters:
253: +  svd - singular value solver context
254: -  i   - index of the solution

256:    Output Parameters:
257: +  sigma - singular value
258: .  u     - left singular vector
259: -  v     - right singular vector

261:    Note:
262:    Both U or V can be NULL if singular vectors are not required.
263:    Otherwise, the caller must provide valid Vec objects, i.e.,
264:    they must be created by the calling program with e.g. MatCreateVecs().

266:    The index i should be a value between 0 and nconv-1 (see SVDGetConverged()).
267:    Singular triplets are indexed according to the ordering criterion established
268:    with SVDSetWhichSingularTriplets().

270:    Level: beginner

272: .seealso: SVDSolve(), SVDGetConverged(), SVDSetWhichSingularTriplets()
273: @*/
274: PetscErrorCode SVDGetSingularTriplet(SVD svd,PetscInt i,PetscReal *sigma,Vec u,Vec v)
275: {
277:   PetscInt       M,N;
278:   Vec            w;

283:   SVDCheckSolved(svd,1);
286:   if (i<0 || i>=svd->nconv) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
287:   *sigma = svd->sigma[svd->perm[i]];
288:   MatGetSize(svd->OP,&M,&N);
289:   if (M<N) { w = u; u = v; v = w; }
290:   if (u) {
291:     SVDComputeVectors(svd);
292:     BVCopyVec(svd->U,svd->perm[i],u);
293:   }
294:   if (v) {
295:     BVCopyVec(svd->V,svd->perm[i],v);
296:   }
297:   return(0);
298: }

302: /*
303:    SVDComputeResidualNorms_Private - Computes the norms of the left and
304:    right residuals associated with the i-th computed singular triplet.
305: @*/
306: static PetscErrorCode SVDComputeResidualNorms_Private(SVD svd,PetscInt i,PetscReal *norm1,PetscReal *norm2)
307: {
309:   Vec            u,v,x = NULL,y = NULL;
310:   PetscReal      sigma;
311:   PetscInt       M,N;

314:   MatCreateVecs(svd->OP,&v,&u);
315:   SVDGetSingularTriplet(svd,i,&sigma,u,v);
316:   /* norm1 = ||A*v-sigma*u||_2 */
317:   if (norm1) {
318:     VecDuplicate(u,&x);
319:     MatMult(svd->OP,v,x);
320:     VecAXPY(x,-sigma,u);
321:     VecNorm(x,NORM_2,norm1);
322:   }
323:   /* norm2 = ||A^T*u-sigma*v||_2 */
324:   if (norm2) {
325:     VecDuplicate(v,&y);
326:     if (svd->A && svd->AT) {
327:       MatGetSize(svd->OP,&M,&N);
328:       if (M<N) {
329:         MatMult(svd->A,u,y);
330:       } else {
331:         MatMult(svd->AT,u,y);
332:       }
333:     } else {
334: #if defined(PETSC_USE_COMPLEX)
335:       MatMultHermitianTranspose(svd->OP,u,y);
336: #else
337:       MatMultTranspose(svd->OP,u,y);
338: #endif
339:     }
340:     VecAXPY(y,-sigma,v);
341:     VecNorm(y,NORM_2,norm2);
342:   }

344:   VecDestroy(&v);
345:   VecDestroy(&u);
346:   VecDestroy(&x);
347:   VecDestroy(&y);
348:   return(0);
349: }

353: /*@
354:    SVDComputeError - Computes the error (based on the residual norm) associated
355:    with the i-th singular triplet.

357:    Collective on SVD

359:    Input Parameter:
360: +  svd  - the singular value solver context
361: .  i    - the solution index
362: -  type - the type of error to compute

364:    Output Parameter:
365: .  error - the error

367:    Notes:
368:    The error can be computed in various ways, all of them based on the residual
369:    norm obtained as sqrt(n1^2+n2^2) with n1 = ||A*v-sigma*u||_2 and
370:    n2 = ||A^T*u-sigma*v||_2, where sigma is the singular value, u is the left
371:    singular vector and v is the right singular vector.

373:    Level: beginner

375: .seealso: SVDErrorType, SVDSolve()
376: @*/
377: PetscErrorCode SVDComputeError(SVD svd,PetscInt i,SVDErrorType type,PetscReal *error)
378: {
380:   PetscReal      sigma,norm1,norm2;

387:   SVDCheckSolved(svd,1);
388:   SVDGetSingularTriplet(svd,i,&sigma,NULL,NULL);
389:   SVDComputeResidualNorms_Private(svd,i,&norm1,&norm2);
390:   *error = PetscSqrtReal(norm1*norm1+norm2*norm2);
391:   switch (type) {
392:     case SVD_ERROR_ABSOLUTE:
393:       break;
394:     case SVD_ERROR_RELATIVE:
395:       *error /= sigma;
396:       break;
397:     default:
398:       SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type");
399:   }
400:   return(0);
401: }

slepc-3.7.4/src/svd/interface/svddefault.c.html0000644000175000017500000002067413107004621020767 0ustar jromanjroman
Actual source code: svddefault.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      This file contains some simple default routines for common operations.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>      /*I "slepcsvd.h" I*/

 28: /*
 29:   SVDConvergedRelative - Checks convergence relative to the eigenvalue.
 30: */
 31: PetscErrorCode SVDConvergedRelative(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)
 32: {
 34:   *errest = res/sigma;
 35:   return(0);
 36: }

 40: /*
 41:   SVDConvergedAbsolute - Checks convergence absolutely.
 42: */
 43: PetscErrorCode SVDConvergedAbsolute(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)
 44: {
 46:   *errest = res;
 47:   return(0);
 48: }

 52: /*@C
 53:    SVDStoppingBasic - Default routine to determine whether the outer singular value
 54:    solver iteration must be stopped.

 56:    Collective on SVD

 58:    Input Parameters:
 59: +  svd    - singular value solver context obtained from SVDCreate()
 60: .  its    - current number of iterations
 61: .  max_it - maximum number of iterations
 62: .  nconv  - number of currently converged singular triplets
 63: .  nsv    - number of requested singular triplets
 64: -  ctx    - context (not used here)

 66:    Output Parameter:
 67: .  reason - result of the stopping test

 69:    Notes:
 70:    A positive value of reason indicates that the iteration has finished successfully
 71:    (converged), and a negative value indicates an error condition (diverged). If
 72:    the iteration needs to be continued, reason must be set to SVD_CONVERGED_ITERATING
 73:    (zero).

 75:    SVDStoppingBasic() will stop if all requested singular values are converged, or if
 76:    the maximum number of iterations has been reached.

 78:    Use SVDSetStoppingTest() to provide your own test instead of using this one.

 80:    Level: advanced

 82: .seealso: SVDSetStoppingTest(), SVDConvergedReason, SVDGetConvergedReason()
 83: @*/
 84: PetscErrorCode SVDStoppingBasic(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)
 85: {

 89:   *reason = SVD_CONVERGED_ITERATING;
 90:   if (nconv >= nsv) {
 91:     PetscInfo2(svd,"Singular value solver finished successfully: %D singular triplets converged at iteration %D\n",nconv,its);
 92:     *reason = SVD_CONVERGED_TOL;
 93:   } else if (its >= max_it) {
 94:     *reason = SVD_DIVERGED_ITS;
 95:     PetscInfo1(svd,"Singular value solver iteration reached maximum number of iterations (%D)\n",its);
 96:   }
 97:   return(0);
 98: }

slepc-3.7.4/src/svd/interface/makefile.html0000644000175000017500000000500113107004621020145 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = svdregis.c svdbasic.c svddefault.c svdview.c svdopts.c svdsetup.c svdsolve.c svdmon.c dlregissvd.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsvd
DIRS     =
MANSEC   = SVD
LOCDIR   = src/svd/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/svd/interface/svdsetup.c0000644000175000017500000003121013107004621017524 0ustar jromanjroman/* SVD routines for setting up the solver. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #undef __FUNCT__ #define __FUNCT__ "SVDSetOperator" /*@ SVDSetOperator - Set the matrix associated with the singular value problem. Collective on SVD and Mat Input Parameters: + svd - the singular value solver context - A - the matrix associated with the singular value problem Level: beginner .seealso: SVDSolve(), SVDGetOperator() @*/ PetscErrorCode SVDSetOperator(SVD svd,Mat mat) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidHeaderSpecific(mat,MAT_CLASSID,2); PetscCheckSameComm(svd,1,mat,2); if (svd->state) { ierr = SVDReset(svd);CHKERRQ(ierr); } ierr = PetscObjectReference((PetscObject)mat);CHKERRQ(ierr); ierr = MatDestroy(&svd->OP);CHKERRQ(ierr); svd->OP = mat; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetOperator" /*@ SVDGetOperator - Get the matrix associated with the singular value problem. Not collective, though parallel Mats are returned if the SVD is parallel Input Parameter: . svd - the singular value solver context Output Parameters: . A - the matrix associated with the singular value problem Level: advanced .seealso: SVDSolve(), SVDSetOperator() @*/ PetscErrorCode SVDGetOperator(SVD svd,Mat *A) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(A,2); *A = svd->OP; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetUp" /*@ SVDSetUp - Sets up all the internal data structures necessary for the execution of the singular value solver. Collective on SVD Input Parameter: . svd - singular value solver context Notes: This function need not be called explicitly in most cases, since SVDSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time. Level: developer .seealso: SVDCreate(), SVDSolve(), SVDDestroy() @*/ PetscErrorCode SVDSetUp(SVD svd) { PetscErrorCode ierr; PetscBool expltrans,flg; PetscInt M,N,k; SlepcSC sc; Vec *T; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (svd->state) PetscFunctionReturn(0); ierr = PetscLogEventBegin(SVD_SetUp,svd,0,0,0);CHKERRQ(ierr); /* reset the convergence flag from the previous solves */ svd->reason = SVD_CONVERGED_ITERATING; /* Set default solver type (SVDSetFromOptions was not called) */ if (!((PetscObject)svd)->type_name) { ierr = SVDSetType(svd,SVDCROSS);CHKERRQ(ierr); } if (!svd->ds) { ierr = SVDGetDS(svd,&svd->ds);CHKERRQ(ierr); } ierr = DSReset(svd->ds);CHKERRQ(ierr); /* check matrix */ if (!svd->OP) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_WRONGSTATE,"SVDSetOperator must be called first"); /* determine how to handle the transpose */ expltrans = PETSC_TRUE; if (svd->impltrans) expltrans = PETSC_FALSE; else { ierr = MatHasOperation(svd->OP,MATOP_TRANSPOSE,&flg);CHKERRQ(ierr); if (!flg) expltrans = PETSC_FALSE; else { ierr = PetscObjectTypeCompare((PetscObject)svd,SVDLAPACK,&flg);CHKERRQ(ierr); if (flg) expltrans = PETSC_FALSE; } } /* build transpose matrix */ ierr = MatDestroy(&svd->A);CHKERRQ(ierr); ierr = MatDestroy(&svd->AT);CHKERRQ(ierr); ierr = MatGetSize(svd->OP,&M,&N);CHKERRQ(ierr); ierr = PetscObjectReference((PetscObject)svd->OP);CHKERRQ(ierr); if (expltrans) { if (M>=N) { svd->A = svd->OP; ierr = MatTranspose(svd->OP,MAT_INITIAL_MATRIX,&svd->AT);CHKERRQ(ierr); ierr = MatConjugate(svd->AT);CHKERRQ(ierr); } else { ierr = MatTranspose(svd->OP,MAT_INITIAL_MATRIX,&svd->A);CHKERRQ(ierr); ierr = MatConjugate(svd->A);CHKERRQ(ierr); svd->AT = svd->OP; } } else { if (M>=N) { svd->A = svd->OP; svd->AT = NULL; } else { svd->A = NULL; svd->AT = svd->OP; } } /* swap initial vectors if necessary */ if (MISL; svd->ISL=svd->IS; svd->IS=T; k=svd->ninil; svd->ninil=svd->nini; svd->nini=k; } if (svd->ncv > PetscMin(M,N)) svd->ncv = PetscMin(M,N); if (svd->nsv > PetscMin(M,N)) svd->nsv = PetscMin(M,N); if (svd->ncv && svd->nsv > svd->ncv) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"nsv bigger than ncv"); /* call specific solver setup */ ierr = (*svd->ops->setup)(svd);CHKERRQ(ierr); /* set tolerance if not yet set */ if (svd->tol==PETSC_DEFAULT) svd->tol = SLEPC_DEFAULT_TOL; /* fill sorting criterion context */ ierr = DSGetSlepcSC(svd->ds,&sc);CHKERRQ(ierr); sc->comparison = (svd->which==SVD_LARGEST)? SlepcCompareLargestReal: SlepcCompareSmallestReal; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; /* process initial vectors */ if (svd->nini<0) { k = -svd->nini; if (k>svd->ncv) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The number of initial vectors is larger than ncv"); ierr = BVInsertVecs(svd->V,0,&k,svd->IS,PETSC_TRUE);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&svd->nini,&svd->IS);CHKERRQ(ierr); svd->nini = k; } if (svd->ninil<0) { k = 0; if (svd->leftbasis) { k = -svd->ninil; if (k>svd->ncv) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The number of left initial vectors is larger than ncv"); ierr = BVInsertVecs(svd->U,0,&k,svd->ISL,PETSC_TRUE);CHKERRQ(ierr); } else { ierr = PetscInfo(svd,"Ignoring initial left vectors\n");CHKERRQ(ierr); } ierr = SlepcBasisDestroy_Private(&svd->ninil,&svd->ISL);CHKERRQ(ierr); svd->ninil = k; } ierr = PetscLogEventEnd(SVD_SetUp,svd,0,0,0);CHKERRQ(ierr); svd->state = SVD_STATE_SETUP; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetInitialSpace" /*@ SVDSetInitialSpace - Specify a basis of vectors that constitute the initial (right) space, that is, a rough approximation to the right singular subspace from which the solver starts to iterate. Collective on SVD and Vec Input Parameter: + svd - the singular value solver context . n - number of vectors - is - set of basis vectors of the initial space Notes: Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored. These vectors do not persist from one SVDSolve() call to the other, so the initial space should be set every time. The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally. Common usage of this function is when the user can provide a rough approximation of the wanted singular space. Then, convergence may be faster. Level: intermediate .seealso: SVDSetInitialSpaceLeft() @*/ PetscErrorCode SVDSetInitialSpace(SVD svd,PetscInt n,Vec *is) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveInt(svd,n,2); if (n<0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative"); ierr = SlepcBasisReference_Private(n,is,&svd->nini,&svd->IS);CHKERRQ(ierr); if (n>0) svd->state = SVD_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetInitialSpaceLeft" /*@ SVDSetInitialSpaceLeft - Specify a basis of vectors that constitute the initial left space, that is, a rough approximation to the left singular subspace from which the solver starts to iterate. Collective on SVD and Vec Input Parameter: + svd - the singular value solver context . n - number of vectors - is - set of basis vectors of the initial space Notes: Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored. These vectors do not persist from one SVDSolve() call to the other, so the initial space should be set every time. The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally. Common usage of this function is when the user can provide a rough approximation of the wanted singular space. Then, convergence may be faster. Level: intermediate .seealso: SVDSetInitialSpace() @*/ PetscErrorCode SVDSetInitialSpaceLeft(SVD svd,PetscInt n,Vec *is) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveInt(svd,n,2); if (n<0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative"); ierr = SlepcBasisReference_Private(n,is,&svd->ninil,&svd->ISL);CHKERRQ(ierr); if (n>0) svd->state = SVD_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetDimensions_Default" /* SVDSetDimensions_Default - Set reasonable values for ncv, mpd if not set by the user. This is called at setup. */ PetscErrorCode SVDSetDimensions_Default(SVD svd) { PetscErrorCode ierr; PetscInt N; PetscFunctionBegin; ierr = SVDMatGetSize(svd,NULL,&N);CHKERRQ(ierr); if (svd->ncv) { /* ncv set */ if (svd->ncvnsv) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The value of ncv must be at least nsv"); } else if (svd->mpd) { /* mpd set */ svd->ncv = PetscMin(N,svd->nsv+svd->mpd); } else { /* neither set: defaults depend on nsv being small or large */ if (svd->nsv<500) svd->ncv = PetscMin(N,PetscMax(2*svd->nsv,10)); else { svd->mpd = 500; svd->ncv = PetscMin(N,svd->nsv+svd->mpd); } } if (!svd->mpd) svd->mpd = svd->ncv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDAllocateSolution" /*@ SVDAllocateSolution - Allocate memory storage for common variables such as the singular values and the basis vectors. Collective on SVD Input Parameters: + svd - eigensolver context - extra - number of additional positions, used for methods that require a working basis slightly larger than ncv Developers Notes: This is PETSC_EXTERN because it may be required by user plugin SVD implementations. This is called at setup after setting the value of ncv and the flag leftbasis. Level: developer @*/ PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra) { PetscErrorCode ierr; PetscInt oldsize,requested; Vec tr,tl; PetscFunctionBegin; requested = svd->ncv + extra; /* oldsize is zero if this is the first time setup is called */ ierr = BVGetSizes(svd->V,NULL,NULL,&oldsize);CHKERRQ(ierr); /* allocate sigma */ if (requested != oldsize || !svd->sigma) { if (oldsize) { ierr = PetscFree3(svd->sigma,svd->perm,svd->errest);CHKERRQ(ierr); } ierr = PetscMalloc3(requested,&svd->sigma,requested,&svd->perm,requested,&svd->errest);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)svd,PetscMax(0,requested-oldsize)*(2*sizeof(PetscReal)+sizeof(PetscInt)));CHKERRQ(ierr); } /* allocate V */ if (!svd->V) { ierr = SVDGetBV(svd,&svd->V,NULL);CHKERRQ(ierr); } if (!oldsize) { if (!((PetscObject)(svd->V))->type_name) { ierr = BVSetType(svd->V,BVSVEC);CHKERRQ(ierr); } ierr = SVDMatCreateVecs(svd,&tr,NULL);CHKERRQ(ierr); ierr = BVSetSizesFromVec(svd->V,tr,requested);CHKERRQ(ierr); ierr = VecDestroy(&tr);CHKERRQ(ierr); } else { ierr = BVResize(svd->V,requested,PETSC_FALSE);CHKERRQ(ierr); } /* allocate U */ if (svd->leftbasis) { if (!svd->U) { ierr = SVDGetBV(svd,NULL,&svd->U);CHKERRQ(ierr); } if (!oldsize) { if (!((PetscObject)(svd->U))->type_name) { ierr = BVSetType(svd->U,BVSVEC);CHKERRQ(ierr); } ierr = SVDMatCreateVecs(svd,NULL,&tl);CHKERRQ(ierr); ierr = BVSetSizesFromVec(svd->U,tl,requested);CHKERRQ(ierr); ierr = VecDestroy(&tl);CHKERRQ(ierr); } else { ierr = BVResize(svd->U,requested,PETSC_FALSE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } slepc-3.7.4/src/svd/interface/svddefault.c0000644000175000017500000000664413107004621020025 0ustar jromanjroman/* This file contains some simple default routines for common operations. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #undef __FUNCT__ #define __FUNCT__ "SVDConvergedRelative" /* SVDConvergedRelative - Checks convergence relative to the eigenvalue. */ PetscErrorCode SVDConvergedRelative(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx) { PetscFunctionBegin; *errest = res/sigma; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDConvergedAbsolute" /* SVDConvergedAbsolute - Checks convergence absolutely. */ PetscErrorCode SVDConvergedAbsolute(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx) { PetscFunctionBegin; *errest = res; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDStoppingBasic" /*@C SVDStoppingBasic - Default routine to determine whether the outer singular value solver iteration must be stopped. Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged singular triplets . nsv - number of requested singular triplets - ctx - context (not used here) Output Parameter: . reason - result of the stopping test Notes: A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to SVD_CONVERGED_ITERATING (zero). SVDStoppingBasic() will stop if all requested singular values are converged, or if the maximum number of iterations has been reached. Use SVDSetStoppingTest() to provide your own test instead of using this one. Level: advanced .seealso: SVDSetStoppingTest(), SVDConvergedReason, SVDGetConvergedReason() @*/ PetscErrorCode SVDStoppingBasic(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; *reason = SVD_CONVERGED_ITERATING; if (nconv >= nsv) { ierr = PetscInfo2(svd,"Singular value solver finished successfully: %D singular triplets converged at iteration %D\n",nconv,its);CHKERRQ(ierr); *reason = SVD_CONVERGED_TOL; } else if (its >= max_it) { *reason = SVD_DIVERGED_ITS; ierr = PetscInfo1(svd,"Singular value solver iteration reached maximum number of iterations (%D)\n",its);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/svd/interface/svdbasic.c0000644000175000017500000003035513107004621017456 0ustar jromanjroman/* The basic SVD routines, Create, Destroy, etc. are here. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ PetscFunctionList SVDList = 0; PetscBool SVDRegisterAllCalled = PETSC_FALSE; PetscClassId SVD_CLASSID = 0; PetscLogEvent SVD_SetUp = 0,SVD_Solve = 0; #undef __FUNCT__ #define __FUNCT__ "SVDCreate" /*@ SVDCreate - Creates the default SVD context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . svd - location to put the SVD context Note: The default SVD type is SVDCROSS Level: beginner .seealso: SVDSetUp(), SVDSolve(), SVDDestroy(), SVD @*/ PetscErrorCode SVDCreate(MPI_Comm comm,SVD *outsvd) { PetscErrorCode ierr; SVD svd; PetscFunctionBegin; PetscValidPointer(outsvd,2); *outsvd = 0; ierr = SVDInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(svd,SVD_CLASSID,"SVD","Singular Value Decomposition","SVD",comm,SVDDestroy,SVDView);CHKERRQ(ierr); svd->OP = NULL; svd->max_it = 0; svd->nsv = 1; svd->ncv = 0; svd->mpd = 0; svd->nini = 0; svd->ninil = 0; svd->tol = PETSC_DEFAULT; svd->conv = SVD_CONV_REL; svd->stop = SVD_STOP_BASIC; svd->which = SVD_LARGEST; svd->impltrans = PETSC_FALSE; svd->trackall = PETSC_FALSE; svd->converged = SVDConvergedRelative; svd->convergeddestroy = NULL; svd->stopping = SVDStoppingBasic; svd->stoppingdestroy = NULL; svd->convergedctx = NULL; svd->stoppingctx = NULL; svd->numbermonitors = 0; svd->ds = NULL; svd->U = NULL; svd->V = NULL; svd->A = NULL; svd->AT = NULL; svd->IS = NULL; svd->ISL = NULL; svd->sigma = NULL; svd->perm = NULL; svd->errest = NULL; svd->data = NULL; svd->state = SVD_STATE_INITIAL; svd->nconv = 0; svd->its = 0; svd->leftbasis = PETSC_FALSE; svd->reason = SVD_CONVERGED_ITERATING; ierr = PetscNewLog(svd,&svd->sc);CHKERRQ(ierr); *outsvd = svd; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDReset" /*@ SVDReset - Resets the SVD context to the initial state and removes any allocated objects. Collective on SVD Input Parameter: . svd - singular value solver context obtained from SVDCreate() Level: advanced .seealso: SVDDestroy() @*/ PetscErrorCode SVDReset(SVD svd) { PetscErrorCode ierr; PetscInt ncols; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (svd->ops->reset) { ierr = (svd->ops->reset)(svd);CHKERRQ(ierr); } if (svd->ds) { ierr = DSReset(svd->ds);CHKERRQ(ierr); } ierr = MatDestroy(&svd->OP);CHKERRQ(ierr); ierr = MatDestroy(&svd->A);CHKERRQ(ierr); ierr = MatDestroy(&svd->AT);CHKERRQ(ierr); ierr = BVGetSizes(svd->V,NULL,NULL,&ncols);CHKERRQ(ierr); if (ncols) { ierr = PetscFree3(svd->sigma,svd->perm,svd->errest);CHKERRQ(ierr); } ierr = BVDestroy(&svd->U);CHKERRQ(ierr); ierr = BVDestroy(&svd->V);CHKERRQ(ierr); svd->state = SVD_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDDestroy" /*@ SVDDestroy - Destroys the SVD context. Collective on SVD Input Parameter: . svd - singular value solver context obtained from SVDCreate() Level: beginner .seealso: SVDCreate(), SVDSetUp(), SVDSolve() @*/ PetscErrorCode SVDDestroy(SVD *svd) { PetscErrorCode ierr; PetscFunctionBegin; if (!*svd) PetscFunctionReturn(0); PetscValidHeaderSpecific(*svd,SVD_CLASSID,1); if (--((PetscObject)(*svd))->refct > 0) { *svd = 0; PetscFunctionReturn(0); } ierr = SVDReset(*svd);CHKERRQ(ierr); if ((*svd)->ops->destroy) { ierr = (*(*svd)->ops->destroy)(*svd);CHKERRQ(ierr); } ierr = DSDestroy(&(*svd)->ds);CHKERRQ(ierr); ierr = PetscFree((*svd)->sc);CHKERRQ(ierr); /* just in case the initial vectors have not been used */ ierr = SlepcBasisDestroy_Private(&(*svd)->nini,&(*svd)->IS);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&(*svd)->ninil,&(*svd)->ISL);CHKERRQ(ierr); ierr = SVDMonitorCancel(*svd);CHKERRQ(ierr); ierr = PetscHeaderDestroy(svd);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetType" /*@C SVDSetType - Selects the particular solver to be used in the SVD object. Logically Collective on SVD Input Parameters: + svd - the singular value solver context - type - a known method Options Database Key: . -svd_type - Sets the method; use -help for a list of available methods Notes: See "slepc/include/slepcsvd.h" for available methods. The default is SVDCROSS. Normally, it is best to use the SVDSetFromOptions() command and then set the SVD type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The SVDSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database. Level: intermediate .seealso: SVDType @*/ PetscErrorCode SVDSetType(SVD svd,SVDType type) { PetscErrorCode ierr,(*r)(SVD); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)svd,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(SVDList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown SVD type given: %s",type); if (svd->ops->destroy) { ierr = (*svd->ops->destroy)(svd);CHKERRQ(ierr); } ierr = PetscMemzero(svd->ops,sizeof(struct _SVDOps));CHKERRQ(ierr); svd->state = SVD_STATE_INITIAL; ierr = PetscObjectChangeTypeName((PetscObject)svd,type);CHKERRQ(ierr); ierr = (*r)(svd);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetType" /*@C SVDGetType - Gets the SVD type as a string from the SVD object. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . name - name of SVD method Level: intermediate .seealso: SVDSetType() @*/ PetscErrorCode SVDGetType(SVD svd,SVDType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)svd)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDRegister" /*@C SVDRegister - Adds a method to the singular value solver package. Not Collective Input Parameters: + name - name of a new user-defined solver - function - routine to create the solver context Notes: SVDRegister() may be called multiple times to add several user-defined solvers. Sample usage: .vb SVDRegister("my_solver",MySolverCreate); .ve Then, your solver can be chosen with the procedural interface via $ SVDSetType(svd,"my_solver") or at runtime via the option $ -svd_type my_solver Level: advanced .seealso: SVDRegisterAll() @*/ PetscErrorCode SVDRegister(const char *name,PetscErrorCode (*function)(SVD)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&SVDList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetBV" /*@ SVDSetBV - Associates basis vectors objects to the singular value solver. Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() . V - the basis vectors object for right singular vectors - U - the basis vectors object for left singular vectors Note: Use SVDGetBV() to retrieve the basis vectors contexts (for example, to free them at the end of the computations). Level: advanced .seealso: SVDGetBV() @*/ PetscErrorCode SVDSetBV(SVD svd,BV V,BV U) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (V) { PetscValidHeaderSpecific(V,BV_CLASSID,2); PetscCheckSameComm(svd,1,V,2); ierr = PetscObjectReference((PetscObject)V);CHKERRQ(ierr); ierr = BVDestroy(&svd->V);CHKERRQ(ierr); svd->V = V; ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->V);CHKERRQ(ierr); } if (U) { PetscValidHeaderSpecific(U,BV_CLASSID,3); PetscCheckSameComm(svd,1,U,3); ierr = PetscObjectReference((PetscObject)U);CHKERRQ(ierr); ierr = BVDestroy(&svd->U);CHKERRQ(ierr); svd->U = U; ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->U);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetBV" /*@ SVDGetBV - Obtain the basis vectors objects associated to the singular value solver object. Not Collective Input Parameters: . svd - singular value solver context obtained from SVDCreate() Output Parameter: + V - basis vectors context for right singular vectors - U - basis vectors context for left singular vectors Level: advanced .seealso: SVDSetBV() @*/ PetscErrorCode SVDGetBV(SVD svd,BV *V,BV *U) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (V) { if (!svd->V) { ierr = BVCreate(PetscObjectComm((PetscObject)svd),&svd->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->V);CHKERRQ(ierr); } *V = svd->V; } if (U) { if (!svd->U) { ierr = BVCreate(PetscObjectComm((PetscObject)svd),&svd->U);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->U);CHKERRQ(ierr); } *U = svd->U; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetDS" /*@ SVDSetDS - Associates a direct solver object to the singular value solver. Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() - ds - the direct solver object Note: Use SVDGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations). Level: advanced .seealso: SVDGetDS() @*/ PetscErrorCode SVDSetDS(SVD svd,DS ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidHeaderSpecific(ds,DS_CLASSID,2); PetscCheckSameComm(svd,1,ds,2); ierr = PetscObjectReference((PetscObject)ds);CHKERRQ(ierr); ierr = DSDestroy(&svd->ds);CHKERRQ(ierr); svd->ds = ds; ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetDS" /*@ SVDGetDS - Obtain the direct solver object associated to the singular value solver object. Not Collective Input Parameters: . svd - singular value solver context obtained from SVDCreate() Output Parameter: . ds - direct solver context Level: advanced .seealso: SVDSetDS() @*/ PetscErrorCode SVDGetDS(SVD svd,DS *ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(ds,2); if (!svd->ds) { ierr = DSCreate(PetscObjectComm((PetscObject)svd),&svd->ds);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->ds);CHKERRQ(ierr); } *ds = svd->ds; PetscFunctionReturn(0); } slepc-3.7.4/src/svd/interface/svdregis.c.html0000644000175000017500000001267313107004621020454 0ustar jromanjroman
Actual source code: svdregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/svdimpl.h>       /*I "slepcsvd.h" I*/

 24: PETSC_EXTERN PetscErrorCode SVDCreate_Cross(SVD);
 25: PETSC_EXTERN PetscErrorCode SVDCreate_Cyclic(SVD);
 26: PETSC_EXTERN PetscErrorCode SVDCreate_LAPACK(SVD);
 27: PETSC_EXTERN PetscErrorCode SVDCreate_Lanczos(SVD);
 28: PETSC_EXTERN PetscErrorCode SVDCreate_TRLanczos(SVD);

 32: /*@C
 33:    SVDRegisterAll - Registers all the singular value solvers in the SVD package.

 35:    Not Collective

 37:    Level: advanced

 39: .seealso:  SVDRegister()
 40: @*/
 41: PetscErrorCode SVDRegisterAll(void)
 42: {

 46:   if (SVDRegisterAllCalled) return(0);
 47:   SVDRegisterAllCalled = PETSC_TRUE;
 48:   SVDRegister(SVDCROSS,SVDCreate_Cross);
 49:   SVDRegister(SVDCYCLIC,SVDCreate_Cyclic);
 50:   SVDRegister(SVDLAPACK,SVDCreate_LAPACK);
 51:   SVDRegister(SVDLANCZOS,SVDCreate_Lanczos);
 52:   SVDRegister(SVDTRLANCZOS,SVDCreate_TRLanczos);
 53:   return(0);
 54: }

slepc-3.7.4/src/svd/interface/svdopts.c0000644000175000017500000010332213107004621017355 0ustar jromanjroman/* SVD routines for setting solver options. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "SVDSetImplicitTranspose" /*@ SVDSetImplicitTranspose - Indicates how to handle the transpose of the matrix associated with the singular value problem. Logically Collective on SVD Input Parameters: + svd - the singular value solver context - impl - how to handle the transpose (implicitly or not) Options Database Key: . -svd_implicittranspose - Activate the implicit transpose mode. Notes: By default, the transpose of the matrix is explicitly built (if the matrix has defined the MatTranspose operation). If this flag is set to true, the solver does not build the transpose, but handles it implicitly via MatMultTranspose() (or MatMultHermitianTranspose() in the complex case) operations. This is likely to be more inefficient than the default behaviour, both in sequential and in parallel, but requires less storage. Level: advanced .seealso: SVDGetImplicitTranspose(), SVDSolve(), SVDSetOperator() @*/ PetscErrorCode SVDSetImplicitTranspose(SVD svd,PetscBool impl) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveBool(svd,impl,2); if (svd->impltrans!=impl) { svd->impltrans = impl; svd->state = SVD_STATE_INITIAL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetImplicitTranspose" /*@ SVDGetImplicitTranspose - Gets the mode used to handle the transpose of the matrix associated with the singular value problem. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . impl - how to handle the transpose (implicitly or not) Level: advanced .seealso: SVDSetImplicitTranspose(), SVDSolve(), SVDSetOperator() @*/ PetscErrorCode SVDGetImplicitTranspose(SVD svd,PetscBool *impl) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(impl,2); *impl = svd->impltrans; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetTolerances" /*@ SVDSetTolerances - Sets the tolerance and maximum iteration count used by the default SVD convergence testers. Logically Collective on SVD Input Parameters: + svd - the singular value solver context . tol - the convergence tolerance - maxits - maximum number of iterations to use Options Database Keys: + -svd_tol - Sets the convergence tolerance - -svd_max_it - Sets the maximum number of iterations allowed (use PETSC_DECIDE to compute an educated guess based on basis and matrix sizes) Note: Use PETSC_DEFAULT for either argument to assign a reasonably good value. Level: intermediate .seealso: SVDGetTolerances() @*/ PetscErrorCode SVDSetTolerances(SVD svd,PetscReal tol,PetscInt maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveReal(svd,tol,2); PetscValidLogicalCollectiveInt(svd,maxits,3); if (tol == PETSC_DEFAULT) { svd->tol = PETSC_DEFAULT; svd->state = SVD_STATE_INITIAL; } else { if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); svd->tol = tol; } if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) { svd->max_it = 0; svd->state = SVD_STATE_INITIAL; } else { if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0"); svd->max_it = maxits; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetTolerances" /*@ SVDGetTolerances - Gets the tolerance and maximum iteration count used by the default SVD convergence tests. Not Collective Input Parameter: . svd - the singular value solver context Output Parameters: + tol - the convergence tolerance - maxits - maximum number of iterations Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: SVDSetTolerances() @*/ PetscErrorCode SVDGetTolerances(SVD svd,PetscReal *tol,PetscInt *maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (tol) *tol = svd->tol; if (maxits) *maxits = svd->max_it; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetDimensions" /*@ SVDSetDimensions - Sets the number of singular values to compute and the dimension of the subspace. Logically Collective on SVD Input Parameters: + svd - the singular value solver context . nsv - number of singular values to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Options Database Keys: + -svd_nsv - Sets the number of singular values . -svd_ncv - Sets the dimension of the subspace - -svd_mpd - Sets the maximum projected dimension Notes: Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method and the number of singular values required. The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nsv is small, the user sets ncv (a reasonable default is 2*nsv); and (b) in cases where nsv is large, the user sets mpd. The value of ncv should always be between nsv and (nsv+mpd), typically ncv=nsv+mpd. If nsv is not too large, mpd=nsv is a reasonable choice, otherwise a smaller value should be used. Level: intermediate .seealso: SVDGetDimensions() @*/ PetscErrorCode SVDSetDimensions(SVD svd,PetscInt nsv,PetscInt ncv,PetscInt mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveInt(svd,nsv,2); PetscValidLogicalCollectiveInt(svd,ncv,3); PetscValidLogicalCollectiveInt(svd,mpd,4); if (nsv<1) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nsv. Must be > 0"); svd->nsv = nsv; if (ncv == PETSC_DEFAULT || ncv == PETSC_DECIDE) { svd->ncv = 0; } else { if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0"); svd->ncv = ncv; } if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) { svd->mpd = 0; } else { if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0"); svd->mpd = mpd; } svd->state = SVD_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetDimensions" /*@ SVDGetDimensions - Gets the number of singular values to compute and the dimension of the subspace. Not Collective Input Parameter: . svd - the singular value context Output Parameters: + nsv - number of singular values to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: SVDSetDimensions() @*/ PetscErrorCode SVDGetDimensions(SVD svd,PetscInt *nsv,PetscInt *ncv,PetscInt *mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (nsv) *nsv = svd->nsv; if (ncv) *ncv = svd->ncv; if (mpd) *mpd = svd->mpd; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetWhichSingularTriplets" /*@ SVDSetWhichSingularTriplets - Specifies which singular triplets are to be sought. Logically Collective on SVD Input Parameter: . svd - singular value solver context obtained from SVDCreate() Output Parameter: . which - which singular triplets are to be sought Possible values: The parameter 'which' can have one of these values + SVD_LARGEST - largest singular values - SVD_SMALLEST - smallest singular values Options Database Keys: + -svd_largest - Sets largest singular values - -svd_smallest - Sets smallest singular values Level: intermediate .seealso: SVDGetWhichSingularTriplets(), SVDWhich @*/ PetscErrorCode SVDSetWhichSingularTriplets(SVD svd,SVDWhich which) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveEnum(svd,which,2); switch (which) { case SVD_LARGEST: case SVD_SMALLEST: if (svd->which != which) { svd->state = SVD_STATE_INITIAL; svd->which = which; } break; default: SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetWhichSingularTriplets" /*@ SVDGetWhichSingularTriplets - Returns which singular triplets are to be sought. Not Collective Input Parameter: . svd - singular value solver context obtained from SVDCreate() Output Parameter: . which - which singular triplets are to be sought Notes: See SVDSetWhichSingularTriplets() for possible values of which Level: intermediate .seealso: SVDSetWhichSingularTriplets(), SVDWhich @*/ PetscErrorCode SVDGetWhichSingularTriplets(SVD svd,SVDWhich *which) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(which,2); *which = svd->which; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetConvergenceTestFunction" /*@C SVDSetConvergenceTestFunction - Sets a function to compute the error estimate used in the convergence test. Logically Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() . func - a pointer to the convergence test function . ctx - context for private data for the convergence routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx) + svd - singular value solver context obtained from SVDCreate() . sigma - computed singular value . res - residual norm associated to the singular triplet . errest - (output) computed error estimate - ctx - optional context, as set by SVDSetConvergenceTestFunction() Note: If the error estimate returned by the convergence test function is less than the tolerance, then the singular value is accepted as converged. Level: advanced .seealso: SVDSetConvergenceTest(), SVDSetTolerances() @*/ PetscErrorCode SVDSetConvergenceTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscReal,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (svd->convergeddestroy) { ierr = (*svd->convergeddestroy)(svd->convergedctx);CHKERRQ(ierr); } svd->converged = func; svd->convergeddestroy = destroy; svd->convergedctx = ctx; if (func == SVDConvergedRelative) svd->conv = SVD_CONV_REL; else if (func == SVDConvergedAbsolute) svd->conv = SVD_CONV_ABS; else svd->conv = SVD_CONV_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetConvergenceTest" /*@ SVDSetConvergenceTest - Specifies how to compute the error estimate used in the convergence test. Logically Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() - conv - the type of convergence test Options Database Keys: + -svd_conv_abs - Sets the absolute convergence test . -svd_conv_rel - Sets the convergence test relative to the singular value - -svd_conv_user - Selects the user-defined convergence test Note: The parameter 'conv' can have one of these values + SVD_CONV_ABS - absolute error ||r|| . SVD_CONV_REL - error relative to the singular value l, ||r||/sigma - SVD_CONV_USER - function set by SVDSetConvergenceTestFunction() Level: intermediate .seealso: SVDGetConvergenceTest(), SVDSetConvergenceTestFunction(), SVDSetStoppingTest(), SVDConv @*/ PetscErrorCode SVDSetConvergenceTest(SVD svd,SVDConv conv) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveEnum(svd,conv,2); switch (conv) { case SVD_CONV_ABS: svd->converged = SVDConvergedAbsolute; break; case SVD_CONV_REL: svd->converged = SVDConvergedRelative; break; case SVD_CONV_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value"); } svd->conv = conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetConvergenceTest" /*@ SVDGetConvergenceTest - Gets the method used to compute the error estimate used in the convergence test. Not Collective Input Parameters: . svd - singular value solver context obtained from SVDCreate() Output Parameters: . conv - the type of convergence test Level: intermediate .seealso: SVDSetConvergenceTest(), SVDConv @*/ PetscErrorCode SVDGetConvergenceTest(SVD svd,SVDConv *conv) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(conv,2); *conv = svd->conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetStoppingTestFunction" /*@C SVDSetStoppingTestFunction - Sets a function to decide when to stop the outer iteration of the singular value solver. Logically Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() . func - pointer to the stopping test function . ctx - context for private data for the stopping routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx) + svd - singular value solver context obtained from SVDCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged singular triplets . nsv - number of requested singular triplets . reason - (output) result of the stopping test - ctx - optional context, as set by SVDSetStoppingTestFunction() Note: Normal usage is to first call the default routine SVDStoppingBasic() and then set reason to SVD_CONVERGED_USER if some user-defined conditions have been met. To let the singular value solver continue iterating, the result must be left as SVD_CONVERGED_ITERATING. Level: advanced .seealso: SVDSetStoppingTest(), SVDStoppingBasic() @*/ PetscErrorCode SVDSetStoppingTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (svd->stoppingdestroy) { ierr = (*svd->stoppingdestroy)(svd->stoppingctx);CHKERRQ(ierr); } svd->stopping = func; svd->stoppingdestroy = destroy; svd->stoppingctx = ctx; if (func == SVDStoppingBasic) svd->stop = SVD_STOP_BASIC; else svd->stop = SVD_STOP_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetStoppingTest" /*@ SVDSetStoppingTest - Specifies how to decide the termination of the outer loop of the singular value solver. Logically Collective on SVD Input Parameters: + svd - singular value solver context obtained from SVDCreate() - stop - the type of stopping test Options Database Keys: + -svd_stop_basic - Sets the default stopping test - -svd_stop_user - Selects the user-defined stopping test Note: The parameter 'stop' can have one of these values + SVD_STOP_BASIC - default stopping test - SVD_STOP_USER - function set by SVDSetStoppingTestFunction() Level: advanced .seealso: SVDGetStoppingTest(), SVDSetStoppingTestFunction(), SVDSetConvergenceTest(), SVDStop @*/ PetscErrorCode SVDSetStoppingTest(SVD svd,SVDStop stop) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveEnum(svd,stop,2); switch (stop) { case SVD_STOP_BASIC: svd->stopping = SVDStoppingBasic; break; case SVD_STOP_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value"); } svd->stop = stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetStoppingTest" /*@ SVDGetStoppingTest - Gets the method used to decide the termination of the outer loop of the singular value solver. Not Collective Input Parameters: . svd - singular value solver context obtained from SVDCreate() Output Parameters: . stop - the type of stopping test Level: advanced .seealso: SVDSetStoppingTest(), SVDStop @*/ PetscErrorCode SVDGetStoppingTest(SVD svd,SVDStop *stop) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(stop,2); *stop = svd->stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDMonitorSetFromOptions" /*@C SVDMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user. Collective on SVD Input Parameters: + svd - the singular value solver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor . monitor - the monitor function, whose context is a PetscViewerAndFormat - trackall - whether this monitor tracks all singular values or not Level: developer .seealso: SVDMonitorSet(), SVDSetTrackAll(), SVDConvMonitorSetFromOptions() @*/ PetscErrorCode SVDMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; PetscViewerAndFormat *vf; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerAndFormatCreate(viewer,format,&vf);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = SVDMonitorSet(svd,(PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);CHKERRQ(ierr); if (trackall) { ierr = SVDSetTrackAll(svd,PETSC_TRUE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDConvMonitorSetFromOptions" /*@C SVDConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence). Collective on SVD Input Parameters: + svd - the singular value solver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor - monitor - the monitor function, whose context is a SlepcConvMonitor Level: developer .seealso: SVDMonitorSet(), SVDMonitorSetFromOptions() @*/ PetscErrorCode SVDConvMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor)) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; SlepcConvMonitor ctx; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = SlepcConvMonitorCreate(viewer,format,&ctx);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = SVDMonitorSet(svd,(PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetFromOptions" /*@ SVDSetFromOptions - Sets SVD options from the options database. This routine must be called before SVDSetUp() if the user is to be allowed to set the solver type. Collective on SVD Input Parameters: . svd - the singular value solver context Notes: To see all options, run your program with the -help option. Level: beginner .seealso: @*/ PetscErrorCode SVDSetFromOptions(SVD svd) { PetscErrorCode ierr; char type[256]; PetscBool set,flg,val,flg1,flg2,flg3; PetscInt i,j,k; PetscReal r; PetscDrawLG lg; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); ierr = SVDRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)svd);CHKERRQ(ierr); ierr = PetscOptionsFList("-svd_type","Singular Value Solver method","SVDSetType",SVDList,(char*)(((PetscObject)svd)->type_name?((PetscObject)svd)->type_name:SVDCROSS),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetType(svd,type);CHKERRQ(ierr); } else if (!((PetscObject)svd)->type_name) { ierr = SVDSetType(svd,SVDCROSS);CHKERRQ(ierr); } ierr = PetscOptionsName("-svd_view","Print detailed information on solver used","SVDView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-svd_view_vectors","View computed singular vectors","SVDVectorsView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-svd_view_values","View computed singular values","SVDValuesView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-svd_converged_reason","Print reason for convergence, and number of iterations","SVDReasonView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-svd_error_absolute","Print absolute errors of each singular triplet","SVDErrorView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-svd_error_relative","Print relative errors of each singular triplet","SVDErrorView",NULL);CHKERRQ(ierr); ierr = PetscOptionsBool("-svd_implicittranspose","Handle matrix transpose implicitly","SVDSetImplicitTranspose",svd->impltrans,&val,&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetImplicitTranspose(svd,val);CHKERRQ(ierr); } i = svd->max_it? svd->max_it: PETSC_DEFAULT; ierr = PetscOptionsInt("-svd_max_it","Maximum number of iterations","SVDSetTolerances",svd->max_it,&i,&flg1);CHKERRQ(ierr); r = svd->tol; ierr = PetscOptionsReal("-svd_tol","Tolerance","SVDSetTolerances",svd->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:svd->tol,&r,&flg2);CHKERRQ(ierr); if (flg1 || flg2) { ierr = SVDSetTolerances(svd,r,i);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-svd_conv_rel","Relative error convergence test","SVDSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetConvergenceTest(svd,SVD_CONV_REL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-svd_conv_abs","Absolute error convergence test","SVDSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetConvergenceTest(svd,SVD_CONV_ABS);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-svd_conv_user","User-defined convergence test","SVDSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetConvergenceTest(svd,SVD_CONV_USER);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-svd_stop_basic","Stop iteration if all singular values converged or max_it reached","SVDSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetStoppingTest(svd,SVD_STOP_BASIC);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-svd_stop_user","User-defined stopping test","SVDSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetStoppingTest(svd,SVD_STOP_USER);CHKERRQ(ierr); } i = svd->nsv; ierr = PetscOptionsInt("-svd_nsv","Number of singular values to compute","SVDSetDimensions",svd->nsv,&i,&flg1);CHKERRQ(ierr); j = svd->ncv? svd->ncv: PETSC_DEFAULT; ierr = PetscOptionsInt("-svd_ncv","Number of basis vectors","SVDSetDimensions",svd->ncv,&j,&flg2);CHKERRQ(ierr); k = svd->mpd? svd->mpd: PETSC_DEFAULT; ierr = PetscOptionsInt("-svd_mpd","Maximum dimension of projected problem","SVDSetDimensions",svd->mpd,&k,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = SVDSetDimensions(svd,i,j,k);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-svd_largest","compute largest singular values","SVDSetWhichSingularTriplets",&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetWhichSingularTriplets(svd,SVD_LARGEST);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-svd_smallest","compute smallest singular values","SVDSetWhichSingularTriplets",&flg);CHKERRQ(ierr); if (flg) { ierr = SVDSetWhichSingularTriplets(svd,SVD_SMALLEST);CHKERRQ(ierr); } /* -----------------------------------------------------------------------*/ /* Cancels all monitors hardwired into code before call to SVDSetFromOptions() */ ierr = PetscOptionsBool("-svd_monitor_cancel","Remove any hardwired monitor routines","SVDMonitorCancel",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = SVDMonitorCancel(svd);CHKERRQ(ierr); } /* Text monitors */ ierr = SVDMonitorSetFromOptions(svd,"-svd_monitor","Monitor first unconverged approximate singular value and error estimate","SVDMonitorFirst",SVDMonitorFirst,PETSC_FALSE);CHKERRQ(ierr); ierr = SVDConvMonitorSetFromOptions(svd,"-svd_monitor_conv","Monitor approximate singular values and error estimates as they converge","SVDMonitorConverged",SVDMonitorConverged);CHKERRQ(ierr); ierr = SVDMonitorSetFromOptions(svd,"-svd_monitor_all","Monitor approximate singular values and error estimates","SVDMonitorAll",SVDMonitorAll,PETSC_TRUE);CHKERRQ(ierr); /* Line graph monitors */ ierr = PetscOptionsBool("-svd_monitor_lg","Monitor first unconverged approximate singular value and error estimate graphically","SVDMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = SVDMonitorLGCreate(PetscObjectComm((PetscObject)svd),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = SVDMonitorSet(svd,SVDMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); } ierr = PetscOptionsBool("-svd_monitor_lg_all","Monitor error estimates graphically","SVDMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = SVDMonitorLGCreate(PetscObjectComm((PetscObject)svd),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = SVDMonitorSet(svd,SVDMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); ierr = SVDSetTrackAll(svd,PETSC_TRUE);CHKERRQ(ierr); } if (svd->ops->setfromoptions) { ierr = (*svd->ops->setfromoptions)(PetscOptionsObject,svd);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)svd);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (!svd->V) { ierr = SVDGetBV(svd,&svd->V,&svd->U);CHKERRQ(ierr); } ierr = BVSetFromOptions(svd->V);CHKERRQ(ierr); ierr = BVSetFromOptions(svd->U);CHKERRQ(ierr); if (!svd->ds) { ierr = SVDGetDS(svd,&svd->ds);CHKERRQ(ierr); } ierr = DSSetFromOptions(svd->ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetTrackAll" /*@ SVDSetTrackAll - Specifies if the solver must compute the residual norm of all approximate singular value or not. Logically Collective on SVD Input Parameters: + svd - the singular value solver context - trackall - whether to compute all residuals or not Notes: If the user sets trackall=PETSC_TRUE then the solver computes (or estimates) the residual norm for each singular value approximation. Computing the residual is usually an expensive operation and solvers commonly compute only the residual associated to the first unconverged singular value. The options '-svd_monitor_all' and '-svd_monitor_lg_all' automatically activate this option. Level: developer .seealso: SVDGetTrackAll() @*/ PetscErrorCode SVDSetTrackAll(SVD svd,PetscBool trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveBool(svd,trackall,2); svd->trackall = trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetTrackAll" /*@ SVDGetTrackAll - Returns the flag indicating whether all residual norms must be computed or not. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . trackall - the returned flag Level: developer .seealso: SVDSetTrackAll() @*/ PetscErrorCode SVDGetTrackAll(SVD svd,PetscBool *trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(trackall,2); *trackall = svd->trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetOptionsPrefix" /*@C SVDSetOptionsPrefix - Sets the prefix used for searching for all SVD options in the database. Logically Collective on SVD Input Parameters: + svd - the singular value solver context - prefix - the prefix string to prepend to all SVD option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. For example, to distinguish between the runtime options for two different SVD contexts, one could call .vb SVDSetOptionsPrefix(svd1,"svd1_") SVDSetOptionsPrefix(svd2,"svd2_") .ve Level: advanced .seealso: SVDAppendOptionsPrefix(), SVDGetOptionsPrefix() @*/ PetscErrorCode SVDSetOptionsPrefix(SVD svd,const char *prefix) { PetscErrorCode ierr; PetscBool flg1,flg2; EPS eps; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (!svd->V) { ierr = SVDGetBV(svd,&svd->V,&svd->U);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(svd->V,prefix);CHKERRQ(ierr); ierr = BVSetOptionsPrefix(svd->U,prefix);CHKERRQ(ierr); if (!svd->ds) { ierr = SVDGetDS(svd,&svd->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(svd->ds,prefix);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)svd,prefix);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)svd,SVDCROSS,&flg1);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)svd,SVDCYCLIC,&flg2);CHKERRQ(ierr); if (flg1) { ierr = SVDCrossGetEPS(svd,&eps);CHKERRQ(ierr); } else if (flg2) { ierr = SVDCyclicGetEPS(svd,&eps);CHKERRQ(ierr); } if (flg1 || flg2) { ierr = EPSSetOptionsPrefix(eps,prefix);CHKERRQ(ierr); ierr = EPSAppendOptionsPrefix(eps,"svd_");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDAppendOptionsPrefix" /*@C SVDAppendOptionsPrefix - Appends to the prefix used for searching for all SVD options in the database. Logically Collective on SVD Input Parameters: + svd - the singular value solver context - prefix - the prefix string to prepend to all SVD option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: SVDSetOptionsPrefix(), SVDGetOptionsPrefix() @*/ PetscErrorCode SVDAppendOptionsPrefix(SVD svd,const char *prefix) { PetscErrorCode ierr; PetscBool flg1,flg2; EPS eps; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (!svd->V) { ierr = SVDGetBV(svd,&svd->V,&svd->U);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(svd->V,prefix);CHKERRQ(ierr); ierr = BVSetOptionsPrefix(svd->U,prefix);CHKERRQ(ierr); if (!svd->ds) { ierr = SVDGetDS(svd,&svd->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(svd->ds,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)svd,prefix);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)svd,SVDCROSS,&flg1);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)svd,SVDCYCLIC,&flg2);CHKERRQ(ierr); if (flg1) { ierr = SVDCrossGetEPS(svd,&eps);CHKERRQ(ierr); } else if (flg2) { ierr = SVDCyclicGetEPS(svd,&eps);CHKERRQ(ierr); } if (flg1 || flg2) { ierr = EPSSetOptionsPrefix(eps,((PetscObject)svd)->prefix);CHKERRQ(ierr); ierr = EPSAppendOptionsPrefix(eps,"svd_");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetOptionsPrefix" /*@C SVDGetOptionsPrefix - Gets the prefix used for searching for all SVD options in the database. Not Collective Input Parameters: . svd - the singular value solver context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: SVDSetOptionsPrefix(), SVDAppendOptionsPrefix() @*/ PetscErrorCode SVDGetOptionsPrefix(SVD svd,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)svd,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/svd/interface/svdsetup.c.html0000644000175000017500000007302613107004621020502 0ustar jromanjroman
Actual source code: svdsetup.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      SVD routines for setting up the solver.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>      /*I "slepcsvd.h" I*/

 28: /*@
 29:    SVDSetOperator - Set the matrix associated with the singular value problem.

 31:    Collective on SVD and Mat

 33:    Input Parameters:
 34: +  svd - the singular value solver context
 35: -  A  - the matrix associated with the singular value problem

 37:    Level: beginner

 39: .seealso: SVDSolve(), SVDGetOperator()
 40: @*/
 41: PetscErrorCode SVDSetOperator(SVD svd,Mat mat)
 42: {

 49:   if (svd->state) { SVDReset(svd); }
 50:   PetscObjectReference((PetscObject)mat);
 51:   MatDestroy(&svd->OP);
 52:   svd->OP = mat;
 53:   return(0);
 54: }

 58: /*@
 59:    SVDGetOperator - Get the matrix associated with the singular value problem.

 61:    Not collective, though parallel Mats are returned if the SVD is parallel

 63:    Input Parameter:
 64: .  svd - the singular value solver context

 66:    Output Parameters:
 67: .  A    - the matrix associated with the singular value problem

 69:    Level: advanced

 71: .seealso: SVDSolve(), SVDSetOperator()
 72: @*/
 73: PetscErrorCode SVDGetOperator(SVD svd,Mat *A)
 74: {
 78:   *A = svd->OP;
 79:   return(0);
 80: }

 84: /*@
 85:    SVDSetUp - Sets up all the internal data structures necessary for the
 86:    execution of the singular value solver.

 88:    Collective on SVD

 90:    Input Parameter:
 91: .  svd   - singular value solver context

 93:    Notes:
 94:    This function need not be called explicitly in most cases, since SVDSolve()
 95:    calls it. It can be useful when one wants to measure the set-up time
 96:    separately from the solve time.

 98:    Level: developer

100: .seealso: SVDCreate(), SVDSolve(), SVDDestroy()
101: @*/
102: PetscErrorCode SVDSetUp(SVD svd)
103: {
105:   PetscBool      expltrans,flg;
106:   PetscInt       M,N,k;
107:   SlepcSC        sc;
108:   Vec            *T;

112:   if (svd->state) return(0);
113:   PetscLogEventBegin(SVD_SetUp,svd,0,0,0);

115:   /* reset the convergence flag from the previous solves */
116:   svd->reason = SVD_CONVERGED_ITERATING;

118:   /* Set default solver type (SVDSetFromOptions was not called) */
119:   if (!((PetscObject)svd)->type_name) {
120:     SVDSetType(svd,SVDCROSS);
121:   }
122:   if (!svd->ds) { SVDGetDS(svd,&svd->ds); }
123:   DSReset(svd->ds);

125:   /* check matrix */
126:   if (!svd->OP) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_WRONGSTATE,"SVDSetOperator must be called first");

128:   /* determine how to handle the transpose */
129:   expltrans = PETSC_TRUE;
130:   if (svd->impltrans) expltrans = PETSC_FALSE;
131:   else {
132:     MatHasOperation(svd->OP,MATOP_TRANSPOSE,&flg);
133:     if (!flg) expltrans = PETSC_FALSE;
134:     else {
135:       PetscObjectTypeCompare((PetscObject)svd,SVDLAPACK,&flg);
136:       if (flg) expltrans = PETSC_FALSE;
137:     }
138:   }

140:   /* build transpose matrix */
141:   MatDestroy(&svd->A);
142:   MatDestroy(&svd->AT);
143:   MatGetSize(svd->OP,&M,&N);
144:   PetscObjectReference((PetscObject)svd->OP);
145:   if (expltrans) {
146:     if (M>=N) {
147:       svd->A = svd->OP;
148:       MatTranspose(svd->OP,MAT_INITIAL_MATRIX,&svd->AT);
149:       MatConjugate(svd->AT);
150:     } else {
151:       MatTranspose(svd->OP,MAT_INITIAL_MATRIX,&svd->A);
152:       MatConjugate(svd->A);
153:       svd->AT = svd->OP;
154:     }
155:   } else {
156:     if (M>=N) {
157:       svd->A = svd->OP;
158:       svd->AT = NULL;
159:     } else {
160:       svd->A = NULL;
161:       svd->AT = svd->OP;
162:     }
163:   }

165:   /* swap initial vectors if necessary */
166:   if (M<N) {
167:     T=svd->ISL; svd->ISL=svd->IS; svd->IS=T;
168:     k=svd->ninil; svd->ninil=svd->nini; svd->nini=k;
169:   }

171:   if (svd->ncv > PetscMin(M,N)) svd->ncv = PetscMin(M,N);
172:   if (svd->nsv > PetscMin(M,N)) svd->nsv = PetscMin(M,N);
173:   if (svd->ncv && svd->nsv > svd->ncv) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"nsv bigger than ncv");

175:   /* call specific solver setup */
176:   (*svd->ops->setup)(svd);

178:   /* set tolerance if not yet set */
179:   if (svd->tol==PETSC_DEFAULT) svd->tol = SLEPC_DEFAULT_TOL;

181:   /* fill sorting criterion context */
182:   DSGetSlepcSC(svd->ds,&sc);
183:   sc->comparison    = (svd->which==SVD_LARGEST)? SlepcCompareLargestReal: SlepcCompareSmallestReal;
184:   sc->comparisonctx = NULL;
185:   sc->map           = NULL;
186:   sc->mapobj        = NULL;

188:   /* process initial vectors */
189:   if (svd->nini<0) {
190:     k = -svd->nini;
191:     if (k>svd->ncv) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The number of initial vectors is larger than ncv");
192:     BVInsertVecs(svd->V,0,&k,svd->IS,PETSC_TRUE);
193:     SlepcBasisDestroy_Private(&svd->nini,&svd->IS);
194:     svd->nini = k;
195:   }
196:   if (svd->ninil<0) {
197:     k = 0;
198:     if (svd->leftbasis) {
199:       k = -svd->ninil;
200:       if (k>svd->ncv) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The number of left initial vectors is larger than ncv");
201:       BVInsertVecs(svd->U,0,&k,svd->ISL,PETSC_TRUE);
202:     } else {
203:       PetscInfo(svd,"Ignoring initial left vectors\n");
204:     }
205:     SlepcBasisDestroy_Private(&svd->ninil,&svd->ISL);
206:     svd->ninil = k;
207:   }

209:   PetscLogEventEnd(SVD_SetUp,svd,0,0,0);
210:   svd->state = SVD_STATE_SETUP;
211:   return(0);
212: }

216: /*@
217:    SVDSetInitialSpace - Specify a basis of vectors that constitute the initial
218:    (right) space, that is, a rough approximation to the right singular subspace
219:    from which the solver starts to iterate.

221:    Collective on SVD and Vec

223:    Input Parameter:
224: +  svd   - the singular value solver context
225: .  n     - number of vectors
226: -  is    - set of basis vectors of the initial space

228:    Notes:
229:    Some solvers start to iterate on a single vector (initial vector). In that case,
230:    the other vectors are ignored.

232:    These vectors do not persist from one SVDSolve() call to the other, so the
233:    initial space should be set every time.

235:    The vectors do not need to be mutually orthonormal, since they are explicitly
236:    orthonormalized internally.

238:    Common usage of this function is when the user can provide a rough approximation
239:    of the wanted singular space. Then, convergence may be faster.

241:    Level: intermediate

243: .seealso: SVDSetInitialSpaceLeft()
244: @*/
245: PetscErrorCode SVDSetInitialSpace(SVD svd,PetscInt n,Vec *is)
246: {

252:   if (n<0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative");
253:   SlepcBasisReference_Private(n,is,&svd->nini,&svd->IS);
254:   if (n>0) svd->state = SVD_STATE_INITIAL;
255:   return(0);
256: }

260: /*@
261:    SVDSetInitialSpaceLeft - Specify a basis of vectors that constitute the initial
262:    left space, that is, a rough approximation to the left singular subspace
263:    from which the solver starts to iterate.

265:    Collective on SVD and Vec

267:    Input Parameter:
268: +  svd   - the singular value solver context
269: .  n     - number of vectors
270: -  is    - set of basis vectors of the initial space

272:    Notes:
273:    Some solvers start to iterate on a single vector (initial vector). In that case,
274:    the other vectors are ignored.

276:    These vectors do not persist from one SVDSolve() call to the other, so the
277:    initial space should be set every time.

279:    The vectors do not need to be mutually orthonormal, since they are explicitly
280:    orthonormalized internally.

282:    Common usage of this function is when the user can provide a rough approximation
283:    of the wanted singular space. Then, convergence may be faster.

285:    Level: intermediate

287: .seealso: SVDSetInitialSpace()
288: @*/
289: PetscErrorCode SVDSetInitialSpaceLeft(SVD svd,PetscInt n,Vec *is)
290: {

296:   if (n<0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative");
297:   SlepcBasisReference_Private(n,is,&svd->ninil,&svd->ISL);
298:   if (n>0) svd->state = SVD_STATE_INITIAL;
299:   return(0);
300: }

304: /*
305:   SVDSetDimensions_Default - Set reasonable values for ncv, mpd if not set
306:   by the user. This is called at setup.
307:  */
308: PetscErrorCode SVDSetDimensions_Default(SVD svd)
309: {
311:   PetscInt       N;

314:   SVDMatGetSize(svd,NULL,&N);
315:   if (svd->ncv) { /* ncv set */
316:     if (svd->ncv<svd->nsv) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The value of ncv must be at least nsv");
317:   } else if (svd->mpd) { /* mpd set */
318:     svd->ncv = PetscMin(N,svd->nsv+svd->mpd);
319:   } else { /* neither set: defaults depend on nsv being small or large */
320:     if (svd->nsv<500) svd->ncv = PetscMin(N,PetscMax(2*svd->nsv,10));
321:     else {
322:       svd->mpd = 500;
323:       svd->ncv = PetscMin(N,svd->nsv+svd->mpd);
324:     }
325:   }
326:   if (!svd->mpd) svd->mpd = svd->ncv;
327:   return(0);
328: }

332: /*@
333:    SVDAllocateSolution - Allocate memory storage for common variables such
334:    as the singular values and the basis vectors.

336:    Collective on SVD

338:    Input Parameters:
339: +  svd   - eigensolver context
340: -  extra - number of additional positions, used for methods that require a
341:            working basis slightly larger than ncv

343:    Developers Notes:
344:    This is PETSC_EXTERN because it may be required by user plugin SVD
345:    implementations.

347:    This is called at setup after setting the value of ncv and the flag leftbasis.

349:    Level: developer
350: @*/
351: PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra)
352: {
354:   PetscInt       oldsize,requested;
355:   Vec            tr,tl;

358:   requested = svd->ncv + extra;

360:   /* oldsize is zero if this is the first time setup is called */
361:   BVGetSizes(svd->V,NULL,NULL,&oldsize);

363:   /* allocate sigma */
364:   if (requested != oldsize || !svd->sigma) {
365:     if (oldsize) {
366:       PetscFree3(svd->sigma,svd->perm,svd->errest);
367:     }
368:     PetscMalloc3(requested,&svd->sigma,requested,&svd->perm,requested,&svd->errest);
369:     PetscLogObjectMemory((PetscObject)svd,PetscMax(0,requested-oldsize)*(2*sizeof(PetscReal)+sizeof(PetscInt)));
370:   }
371:   /* allocate V */
372:   if (!svd->V) { SVDGetBV(svd,&svd->V,NULL); }
373:   if (!oldsize) {
374:     if (!((PetscObject)(svd->V))->type_name) {
375:       BVSetType(svd->V,BVSVEC);
376:     }
377:     SVDMatCreateVecs(svd,&tr,NULL);
378:     BVSetSizesFromVec(svd->V,tr,requested);
379:     VecDestroy(&tr);
380:   } else {
381:     BVResize(svd->V,requested,PETSC_FALSE);
382:   }
383:   /* allocate U */
384:   if (svd->leftbasis) {
385:     if (!svd->U) { SVDGetBV(svd,NULL,&svd->U); }
386:     if (!oldsize) {
387:       if (!((PetscObject)(svd->U))->type_name) {
388:         BVSetType(svd->U,BVSVEC);
389:       }
390:       SVDMatCreateVecs(svd,NULL,&tl);
391:       BVSetSizesFromVec(svd->U,tl,requested);
392:       VecDestroy(&tl);
393:     } else {
394:       BVResize(svd->U,requested,PETSC_FALSE);
395:     }
396:   }
397:   return(0);
398: }

slepc-3.7.4/src/svd/interface/svdmon.c.html0000644000175000017500000007527213107004621020140 0ustar jromanjroman
Actual source code: svdmon.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       SVD routines related to monitors.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>   /*I "slepcsvd.h" I*/
 25: #include <petscdraw.h>

 29: /*
 30:    Runs the user provided monitor routines, if any.
 31: */
 32: PetscErrorCode SVDMonitor(SVD svd,PetscInt it,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest)
 33: {
 35:   PetscInt       i,n = svd->numbermonitors;

 38:   for (i=0;i<n;i++) {
 39:     (*svd->monitor[i])(svd,it,nconv,sigma,errest,nest,svd->monitorcontext[i]);
 40:   }
 41:   return(0);
 42: }

 46: /*@C
 47:    SVDMonitorSet - Sets an ADDITIONAL function to be called at every
 48:    iteration to monitor the error estimates for each requested singular triplet.

 50:    Collective on SVD

 52:    Input Parameters:
 53: +  svd     - singular value solver context obtained from SVDCreate()
 54: .  monitor - pointer to function (if this is NULL, it turns off monitoring)
 55: -  mctx    - [optional] context for private data for the
 56:              monitor routine (use NULL if no context is desired)

 58:    Calling Sequence of monitor:
 59: $   monitor(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *mctx)

 61: +  svd    - singular value solver context obtained from SVDCreate()
 62: .  its    - iteration number
 63: .  nconv  - number of converged singular triplets
 64: .  sigma  - singular values
 65: .  errest - relative error estimates for each singular triplet
 66: .  nest   - number of error estimates
 67: -  mctx   - optional monitoring context, as set by SVDMonitorSet()

 69:    Options Database Keys:
 70: +    -svd_monitor        - print only the first error estimate
 71: .    -svd_monitor_all    - print error estimates at each iteration
 72: .    -svd_monitor_conv   - print the singular value approximations only when
 73:       convergence has been reached
 74: .    -svd_monitor_lg     - sets line graph monitor for the first unconverged
 75:       approximate singular value
 76: .    -svd_monitor_lg_all - sets line graph monitor for all unconverged
 77:       approximate singular values
 78: -    -svd_monitor_cancel - cancels all monitors that have been hardwired into
 79:       a code by calls to SVDMonitorSet(), but does not cancel those set via
 80:       the options database.

 82:    Notes:
 83:    Several different monitoring routines may be set by calling
 84:    SVDMonitorSet() multiple times; all will be called in the
 85:    order in which they were set.

 87:    Level: intermediate

 89: .seealso: SVDMonitorFirst(), SVDMonitorAll(), SVDMonitorCancel()
 90: @*/
 91: PetscErrorCode SVDMonitorSet(SVD svd,PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
 92: {
 95:   if (svd->numbermonitors >= MAXSVDMONITORS) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Too many SVD monitors set");
 96:   svd->monitor[svd->numbermonitors]           = monitor;
 97:   svd->monitorcontext[svd->numbermonitors]    = (void*)mctx;
 98:   svd->monitordestroy[svd->numbermonitors++]  = monitordestroy;
 99:   return(0);
100: }

104: /*@
105:    SVDMonitorCancel - Clears all monitors for an SVD object.

107:    Collective on SVD

109:    Input Parameters:
110: .  svd - singular value solver context obtained from SVDCreate()

112:    Options Database Key:
113: .    -svd_monitor_cancel - Cancels all monitors that have been hardwired
114:       into a code by calls to SVDMonitorSet(),
115:       but does not cancel those set via the options database.

117:    Level: intermediate

119: .seealso: SVDMonitorSet()
120: @*/
121: PetscErrorCode SVDMonitorCancel(SVD svd)
122: {
124:   PetscInt       i;

128:   for (i=0; i<svd->numbermonitors; i++) {
129:     if (svd->monitordestroy[i]) {
130:       (*svd->monitordestroy[i])(&svd->monitorcontext[i]);
131:     }
132:   }
133:   svd->numbermonitors = 0;
134:   return(0);
135: }

139: /*@C
140:    SVDGetMonitorContext - Gets the monitor context, as set by
141:    SVDMonitorSet() for the FIRST monitor only.

143:    Not Collective

145:    Input Parameter:
146: .  svd - singular value solver context obtained from SVDCreate()

148:    Output Parameter:
149: .  ctx - monitor context

151:    Level: intermediate

153: .seealso: SVDMonitorSet()
154: @*/
155: PetscErrorCode SVDGetMonitorContext(SVD svd,void **ctx)
156: {
159:   *ctx = svd->monitorcontext[0];
160:   return(0);
161: }

165: /*@C
166:    SVDMonitorAll - Print the current approximate values and
167:    error estimates at each iteration of the singular value solver.

169:    Collective on SVD

171:    Input Parameters:
172: +  svd    - singular value solver context
173: .  its    - iteration number
174: .  nconv  - number of converged singular triplets so far
175: .  sigma  - singular values
176: .  errest - error estimates
177: .  nest   - number of error estimates to display
178: -  vf     - viewer and format for monitoring

180:    Level: intermediate

182: .seealso: SVDMonitorSet(), SVDMonitorFirst(), SVDMonitorConverged()
183: @*/
184: PetscErrorCode SVDMonitorAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
185: {
187:   PetscInt       i;
188:   PetscViewer    viewer;

193:   viewer = vf->viewer;
195:   PetscViewerPushFormat(viewer,vf->format);
196:   PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);
197:   if (its==1 && ((PetscObject)svd)->prefix) {
198:     PetscViewerASCIIPrintf(viewer,"  Singular value approximations and residual norms for %s solve.\n",((PetscObject)svd)->prefix);
199:   }
200:   PetscViewerASCIIPrintf(viewer,"%3D SVD nconv=%D Values (Errors)",its,nconv);
201:   PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
202:   for (i=0;i<nest;i++) {
203:     PetscViewerASCIIPrintf(viewer," %g (%10.8e)",(double)sigma[i],(double)errest[i]);
204:   }
205:   PetscViewerASCIIPrintf(viewer,"\n");
206:   PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
207:   PetscViewerASCIISubtractTab(viewer,((PetscObject)svd)->tablevel);
208:   PetscViewerPopFormat(viewer);
209:   return(0);
210: }

214: /*@C
215:    SVDMonitorFirst - Print the first unconverged approximate values and
216:    error estimates at each iteration of the singular value solver.

218:    Collective on SVD

220:    Input Parameters:
221: +  svd    - singular value solver context
222: .  its    - iteration number
223: .  nconv  - number of converged singular triplets so far
224: .  sigma  - singular values
225: .  errest - error estimates
226: .  nest   - number of error estimates to display
227: -  vf     - viewer and format for monitoring

229:    Level: intermediate

231: .seealso: SVDMonitorSet(), SVDMonitorAll(), SVDMonitorConverged()
232: @*/
233: PetscErrorCode SVDMonitorFirst(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
234: {
236:   PetscViewer    viewer;

241:   viewer = vf->viewer;
243:   if (its==1 && ((PetscObject)svd)->prefix) {
244:     PetscViewerASCIIPrintf(viewer,"  Singular value approximations and residual norms for %s solve.\n",((PetscObject)svd)->prefix);
245:   }
246:   if (nconv<nest) {
247:     PetscViewerPushFormat(viewer,vf->format);
248:     PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);
249:     PetscViewerASCIIPrintf(viewer,"%3D SVD nconv=%D first unconverged value (error)",its,nconv);
250:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
251:     PetscViewerASCIIPrintf(viewer," %g (%10.8e)\n",(double)sigma[nconv],(double)errest[nconv]);
252:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
253:     PetscViewerASCIISubtractTab(viewer,((PetscObject)svd)->tablevel);
254:     PetscViewerPopFormat(viewer);
255:   }
256:   return(0);
257: }

261: /*@C
262:    SVDMonitorConverged - Print the approximate values and error estimates as they converge.

264:    Collective on SVD

266:    Input Parameters:
267: +  svd    - singular value solver context
268: .  its    - iteration number
269: .  nconv  - number of converged singular triplets so far
270: .  sigma  - singular values
271: .  errest - error estimates
272: .  nest   - number of error estimates to display
273: -  ctx    - monitor context

275:    Level: intermediate

277: .seealso: SVDMonitorSet(), SVDMonitorFirst(), SVDMonitorAll()
278: @*/
279: PetscErrorCode SVDMonitorConverged(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
280: {
282:   PetscInt       i;
283:   PetscViewer    viewer;

288:   viewer = ctx->viewer;
290:   if (its==1 && ((PetscObject)svd)->prefix) {
291:     PetscViewerASCIIPrintf(viewer,"  Convergence history for %s solve.\n",((PetscObject)svd)->prefix);
292:   }
293:   if (its==1) ctx->oldnconv = 0;
294:   if (ctx->oldnconv!=nconv) {
295:     PetscViewerPushFormat(viewer,ctx->format);
296:     PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);
297:     for (i=ctx->oldnconv;i<nconv;i++) {
298:       PetscViewerASCIIPrintf(viewer,"%3D SVD converged value (error) #%D",its,i);
299:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
300:       PetscViewerASCIIPrintf(viewer," %g (%10.8e)\n",(double)sigma[i],(double)errest[i]);
301:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
302:     }
303:     PetscViewerASCIISubtractTab(viewer,((PetscObject)svd)->tablevel);
304:     PetscViewerPopFormat(viewer);
305:     ctx->oldnconv = nconv;
306:   }
307:   return(0);
308: }

312: /*@C
313:    SVDMonitorLGCreate - Creates a line graph context for use with
314:    SVD to monitor convergence.

316:    Collective on MPI_Comm

318:    Input Parameters:
319: +  comm - communicator context
320: .  host - the X display to open, or null for the local machine
321: .  label - the title to put in the title bar
322: .  x, y - the screen coordinates of the upper left coordinate of
323:           the window
324: -  m, n - the screen width and height in pixels

326:    Output Parameter:
327: .  lgctx - the drawing context

329:    Options Database Keys:
330: +  -svd_monitor_lg - Sets line graph monitor for the first residual
331: -  -svd_monitor_lg_all - Sets line graph monitor for all residuals

333:    Notes:
334:    Use PetscDrawLGDestroy() to destroy this line graph.

336:    Level: intermediate

338: .seealso: SVDMonitorSet()
339: @*/
340: PetscErrorCode SVDMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
341: {
342:   PetscDraw      draw;
343:   PetscDrawLG    lg;

347:   PetscDrawCreate(comm,host,label,x,y,m,n,&draw);
348:   PetscDrawSetFromOptions(draw);
349:   PetscDrawLGCreate(draw,1,&lg);
350:   PetscDrawLGSetFromOptions(lg);
351:   PetscDrawDestroy(&draw);
352:   *lgctx = lg;
353:   return(0);
354: }

358: PetscErrorCode SVDMonitorLG(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx)
359: {
360:   PetscDrawLG    lg = (PetscDrawLG)ctx;
361:   PetscReal      x,y;

366:   if (its==1) {
367:     PetscDrawLGReset(lg);
368:     PetscDrawLGSetDimension(lg,1);
369:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(svd->tol)-2,0.0);
370:   }
371:   x = (PetscReal)its;
372:   if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]);
373:   else y = 0.0;
374:   PetscDrawLGAddPoint(lg,&x,&y);
375:   if (its <= 20 || !(its % 5) || svd->reason) {
376:     PetscDrawLGDraw(lg);
377:     PetscDrawLGSave(lg);
378:   }
379:   return(0);
380: }

384: PetscErrorCode SVDMonitorLGAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx)
385: {
386:   PetscDrawLG    lg = (PetscDrawLG)ctx;
387:   PetscInt       i,n = PetscMin(svd->nsv,255);
388:   PetscReal      *x,*y;

393:   if (its==1) {
394:     PetscDrawLGReset(lg);
395:     PetscDrawLGSetDimension(lg,n);
396:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(svd->tol)-2,0.0);
397:   }
398:   PetscMalloc2(n,&x,n,&y);
399:   for (i=0;i<n;i++) {
400:     x[i] = (PetscReal)its;
401:     if (i < nest && errest[i] > 0.0) y[i] = PetscLog10Real(errest[i]);
402:     else y[i] = 0.0;
403:   }
404:   PetscDrawLGAddPoint(lg,x,y);
405:   if (its <= 20 || !(its % 5) || svd->reason) {
406:     PetscDrawLGDraw(lg);
407:     PetscDrawLGSave(lg);
408:   }
409:   PetscFree2(x,y);
410:   return(0);
411: }

slepc-3.7.4/src/svd/interface/index.html0000644000175000017500000000351113107004621017503 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

svdregis.c
svdbasic.c
svddefault.c
svdview.c
svdopts.c
svdsetup.c
svdsolve.c
svdmon.c
dlregissvd.c
makefile
slepc-3.7.4/src/svd/interface/ftn-auto/0000755000175000017500000000000013107004621017243 5ustar jromanjromanslepc-3.7.4/src/svd/interface/ftn-auto/makefile0000644000175000017500000000045013107004621020742 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = svdmonf.c svdsetupf.c svdbasicf.c svdsolvef.c svdoptsf.c svdviewf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsvd LOCDIR = src/svd/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/interface/ftn-auto/svdmonf.c0000644000175000017500000000206513107004621021066 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* svdmon.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdmonitorcancel_ SVDMONITORCANCEL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdmonitorcancel_ svdmonitorcancel #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdmonitorcancel_(SVD svd, int *__ierr ){ *__ierr = SVDMonitorCancel( (SVD)PetscToPointer((svd) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/interface/ftn-auto/svdsetupf.c0000644000175000017500000000553613107004621021443 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* svdsetup.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetoperator_ SVDSETOPERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetoperator_ svdsetoperator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetoperator_ SVDGETOPERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetoperator_ svdgetoperator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetup_ SVDSETUP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetup_ svdsetup #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetinitialspace_ SVDSETINITIALSPACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetinitialspace_ svdsetinitialspace #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetinitialspaceleft_ SVDSETINITIALSPACELEFT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetinitialspaceleft_ svdsetinitialspaceleft #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdallocatesolution_ SVDALLOCATESOLUTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdallocatesolution_ svdallocatesolution #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdsetoperator_(SVD svd,Mat mat, int *__ierr ){ *__ierr = SVDSetOperator( (SVD)PetscToPointer((svd) ), (Mat)PetscToPointer((mat) )); } PETSC_EXTERN void PETSC_STDCALL svdgetoperator_(SVD svd,Mat *A, int *__ierr ){ *__ierr = SVDGetOperator( (SVD)PetscToPointer((svd) ),A); } PETSC_EXTERN void PETSC_STDCALL svdsetup_(SVD svd, int *__ierr ){ *__ierr = SVDSetUp( (SVD)PetscToPointer((svd) )); } PETSC_EXTERN void PETSC_STDCALL svdsetinitialspace_(SVD svd,PetscInt *n,Vec *is, int *__ierr ){ *__ierr = SVDSetInitialSpace( (SVD)PetscToPointer((svd) ),*n,is); } PETSC_EXTERN void PETSC_STDCALL svdsetinitialspaceleft_(SVD svd,PetscInt *n,Vec *is, int *__ierr ){ *__ierr = SVDSetInitialSpaceLeft( (SVD)PetscToPointer((svd) ),*n,is); } PETSC_EXTERN void PETSC_STDCALL svdallocatesolution_(SVD svd,PetscInt *extra, int *__ierr ){ *__ierr = SVDAllocateSolution( (SVD)PetscToPointer((svd) ),*extra); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/interface/ftn-auto/svdbasicf.c0000644000175000017500000000557313107004621021365 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* svdbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcreate_ SVDCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcreate_ svdcreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdreset_ SVDRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdreset_ svdreset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svddestroy_ SVDDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svddestroy_ svddestroy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetbv_ SVDSETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetbv_ svdsetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetbv_ SVDGETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetbv_ svdgetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetds_ SVDSETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetds_ svdsetds #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetds_ SVDGETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetds_ svdgetds #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdcreate_(MPI_Fint * comm,SVD *outsvd, int *__ierr ){ *__ierr = SVDCreate( MPI_Comm_f2c(*(comm)),outsvd); } PETSC_EXTERN void PETSC_STDCALL svdreset_(SVD svd, int *__ierr ){ *__ierr = SVDReset( (SVD)PetscToPointer((svd) )); } PETSC_EXTERN void PETSC_STDCALL svddestroy_(SVD *svd, int *__ierr ){ *__ierr = SVDDestroy(svd); } PETSC_EXTERN void PETSC_STDCALL svdsetbv_(SVD svd,BV V,BV U, int *__ierr ){ *__ierr = SVDSetBV( (SVD)PetscToPointer((svd) ), (BV)PetscToPointer((V) ), (BV)PetscToPointer((U) )); } PETSC_EXTERN void PETSC_STDCALL svdgetbv_(SVD svd,BV *V,BV *U, int *__ierr ){ *__ierr = SVDGetBV( (SVD)PetscToPointer((svd) ),V,U); } PETSC_EXTERN void PETSC_STDCALL svdsetds_(SVD svd,DS ds, int *__ierr ){ *__ierr = SVDSetDS( (SVD)PetscToPointer((svd) ), (DS)PetscToPointer((ds) )); } PETSC_EXTERN void PETSC_STDCALL svdgetds_(SVD svd,DS *ds, int *__ierr ){ *__ierr = SVDGetDS( (SVD)PetscToPointer((svd) ),ds); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/interface/ftn-auto/svdsolvef.c0000644000175000017500000000577313107004621021436 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* svdsolve.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsolve_ SVDSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsolve_ svdsolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetiterationnumber_ SVDGETITERATIONNUMBER #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetiterationnumber_ svdgetiterationnumber #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetconvergedreason_ SVDGETCONVERGEDREASON #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetconvergedreason_ svdgetconvergedreason #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetconverged_ SVDGETCONVERGED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetconverged_ svdgetconverged #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetsingulartriplet_ SVDGETSINGULARTRIPLET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetsingulartriplet_ svdgetsingulartriplet #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcomputeerror_ SVDCOMPUTEERROR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcomputeerror_ svdcomputeerror #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdsolve_(SVD svd, int *__ierr ){ *__ierr = SVDSolve( (SVD)PetscToPointer((svd) )); } PETSC_EXTERN void PETSC_STDCALL svdgetiterationnumber_(SVD svd,PetscInt *its, int *__ierr ){ *__ierr = SVDGetIterationNumber( (SVD)PetscToPointer((svd) ),its); } PETSC_EXTERN void PETSC_STDCALL svdgetconvergedreason_(SVD svd,SVDConvergedReason *reason, int *__ierr ){ *__ierr = SVDGetConvergedReason( (SVD)PetscToPointer((svd) ),reason); } PETSC_EXTERN void PETSC_STDCALL svdgetconverged_(SVD svd,PetscInt *nconv, int *__ierr ){ *__ierr = SVDGetConverged( (SVD)PetscToPointer((svd) ),nconv); } PETSC_EXTERN void PETSC_STDCALL svdgetsingulartriplet_(SVD svd,PetscInt *i,PetscReal *sigma,Vec u,Vec v, int *__ierr ){ *__ierr = SVDGetSingularTriplet( (SVD)PetscToPointer((svd) ),*i,sigma, (Vec)PetscToPointer((u) ), (Vec)PetscToPointer((v) )); } PETSC_EXTERN void PETSC_STDCALL svdcomputeerror_(SVD svd,PetscInt *i,SVDErrorType *type,PetscReal *error, int *__ierr ){ *__ierr = SVDComputeError( (SVD)PetscToPointer((svd) ),*i,*type,error); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/interface/ftn-auto/svdoptsf.c0000644000175000017500000001467213107004621021271 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* svdopts.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetimplicittranspose_ SVDSETIMPLICITTRANSPOSE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetimplicittranspose_ svdsetimplicittranspose #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetimplicittranspose_ SVDGETIMPLICITTRANSPOSE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetimplicittranspose_ svdgetimplicittranspose #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsettolerances_ SVDSETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsettolerances_ svdsettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgettolerances_ SVDGETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgettolerances_ svdgettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetdimensions_ SVDSETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetdimensions_ svdsetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetdimensions_ SVDGETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetdimensions_ svdgetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetwhichsingulartriplets_ SVDSETWHICHSINGULARTRIPLETS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetwhichsingulartriplets_ svdsetwhichsingulartriplets #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetwhichsingulartriplets_ SVDGETWHICHSINGULARTRIPLETS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetwhichsingulartriplets_ svdgetwhichsingulartriplets #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetconvergencetest_ SVDSETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetconvergencetest_ svdsetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetconvergencetest_ SVDGETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetconvergencetest_ svdgetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetstoppingtest_ SVDSETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetstoppingtest_ svdsetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgetstoppingtest_ SVDGETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgetstoppingtest_ svdgetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsetfromoptions_ SVDSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsetfromoptions_ svdsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdsettrackall_ SVDSETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdsettrackall_ svdsettrackall #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdgettrackall_ SVDGETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdgettrackall_ svdgettrackall #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdsetimplicittranspose_(SVD svd,PetscBool *impl, int *__ierr ){ *__ierr = SVDSetImplicitTranspose( (SVD)PetscToPointer((svd) ),*impl); } PETSC_EXTERN void PETSC_STDCALL svdgetimplicittranspose_(SVD svd,PetscBool *impl, int *__ierr ){ *__ierr = SVDGetImplicitTranspose( (SVD)PetscToPointer((svd) ),impl); } PETSC_EXTERN void PETSC_STDCALL svdsettolerances_(SVD svd,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = SVDSetTolerances( (SVD)PetscToPointer((svd) ),*tol,*maxits); } PETSC_EXTERN void PETSC_STDCALL svdgettolerances_(SVD svd,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = SVDGetTolerances( (SVD)PetscToPointer((svd) ),tol,maxits); } PETSC_EXTERN void PETSC_STDCALL svdsetdimensions_(SVD svd,PetscInt *nsv,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = SVDSetDimensions( (SVD)PetscToPointer((svd) ),*nsv,*ncv,*mpd); } PETSC_EXTERN void PETSC_STDCALL svdgetdimensions_(SVD svd,PetscInt *nsv,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = SVDGetDimensions( (SVD)PetscToPointer((svd) ),nsv,ncv,mpd); } PETSC_EXTERN void PETSC_STDCALL svdsetwhichsingulartriplets_(SVD svd,SVDWhich *which, int *__ierr ){ *__ierr = SVDSetWhichSingularTriplets( (SVD)PetscToPointer((svd) ),*which); } PETSC_EXTERN void PETSC_STDCALL svdgetwhichsingulartriplets_(SVD svd,SVDWhich *which, int *__ierr ){ *__ierr = SVDGetWhichSingularTriplets( (SVD)PetscToPointer((svd) ),which); } PETSC_EXTERN void PETSC_STDCALL svdsetconvergencetest_(SVD svd,SVDConv *conv, int *__ierr ){ *__ierr = SVDSetConvergenceTest( (SVD)PetscToPointer((svd) ),*conv); } PETSC_EXTERN void PETSC_STDCALL svdgetconvergencetest_(SVD svd,SVDConv *conv, int *__ierr ){ *__ierr = SVDGetConvergenceTest( (SVD)PetscToPointer((svd) ),conv); } PETSC_EXTERN void PETSC_STDCALL svdsetstoppingtest_(SVD svd,SVDStop *stop, int *__ierr ){ *__ierr = SVDSetStoppingTest( (SVD)PetscToPointer((svd) ),*stop); } PETSC_EXTERN void PETSC_STDCALL svdgetstoppingtest_(SVD svd,SVDStop *stop, int *__ierr ){ *__ierr = SVDGetStoppingTest( (SVD)PetscToPointer((svd) ),stop); } PETSC_EXTERN void PETSC_STDCALL svdsetfromoptions_(SVD svd, int *__ierr ){ *__ierr = SVDSetFromOptions( (SVD)PetscToPointer((svd) )); } PETSC_EXTERN void PETSC_STDCALL svdsettrackall_(SVD svd,PetscBool *trackall, int *__ierr ){ *__ierr = SVDSetTrackAll( (SVD)PetscToPointer((svd) ),*trackall); } PETSC_EXTERN void PETSC_STDCALL svdgettrackall_(SVD svd,PetscBool *trackall, int *__ierr ){ *__ierr = SVDGetTrackAll( (SVD)PetscToPointer((svd) ),trackall); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/interface/ftn-auto/svdviewf.c0000644000175000017500000000437313107004621021253 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* svdview.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdreasonviewfromoptions_ SVDREASONVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdreasonviewfromoptions_ svdreasonviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svderrorviewfromoptions_ SVDERRORVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svderrorviewfromoptions_ svderrorviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdvaluesviewfromoptions_ SVDVALUESVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdvaluesviewfromoptions_ svdvaluesviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdvectorsviewfromoptions_ SVDVECTORSVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdvectorsviewfromoptions_ svdvectorsviewfromoptions #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdreasonviewfromoptions_(SVD svd, int *__ierr ){ *__ierr = SVDReasonViewFromOptions( (SVD)PetscToPointer((svd) )); } PETSC_EXTERN void PETSC_STDCALL svderrorviewfromoptions_(SVD svd, int *__ierr ){ *__ierr = SVDErrorViewFromOptions( (SVD)PetscToPointer((svd) )); } PETSC_EXTERN void PETSC_STDCALL svdvaluesviewfromoptions_(SVD svd, int *__ierr ){ *__ierr = SVDValuesViewFromOptions( (SVD)PetscToPointer((svd) )); } PETSC_EXTERN void PETSC_STDCALL svdvectorsviewfromoptions_(SVD svd, int *__ierr ){ *__ierr = SVDVectorsViewFromOptions( (SVD)PetscToPointer((svd) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/interface/dlregissvd.c0000644000175000017500000000772513107004621020033 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include static PetscBool SVDPackageInitialized = PETSC_FALSE; const char *SVDErrorTypes[] = {"ABSOLUTE","RELATIVE","SVDErrorType","SVD_ERROR_",0}; const char *const SVDConvergedReasons_Shifted[] = {"","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","SVDConvergedReason","SVD_",0}; const char *const*SVDConvergedReasons = SVDConvergedReasons_Shifted + 4; #undef __FUNCT__ #define __FUNCT__ "SVDFinalizePackage" /*@C SVDFinalizePackage - This function destroys everything in the Slepc interface to the SVD package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode SVDFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&SVDList);CHKERRQ(ierr); SVDPackageInitialized = PETSC_FALSE; SVDRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDInitializePackage" /*@C SVDInitializePackage - This function initializes everything in the SVD package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to SVDCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode SVDInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (SVDPackageInitialized) PetscFunctionReturn(0); SVDPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("SVD Solver",&SVD_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = SVDRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("SVDSetUp",SVD_CLASSID,&SVD_SetUp);CHKERRQ(ierr); ierr = PetscLogEventRegister("SVDSolve",SVD_CLASSID,&SVD_Solve);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"svd",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(SVD_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"svd",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(SVD_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(SVDFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) #undef __FUNCT__ #define __FUNCT__ "PetscDLLibraryRegister_slepcsvd" /* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the SVD methods that are in the basic SLEPc libslepcsvd library. */ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsvd() { PetscErrorCode ierr; PetscFunctionBegin; ierr = SVDInitializePackage();CHKERRQ(ierr); PetscFunctionReturn(0); } #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ slepc-3.7.4/src/svd/interface/dlregissvd.c.html0000644000175000017500000002410013107004621020760 0ustar jromanjroman

Actual source code: dlregissvd.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/svdimpl.h>

 24: static PetscBool SVDPackageInitialized = PETSC_FALSE;

 26: const char *SVDErrorTypes[] = {"ABSOLUTE","RELATIVE","SVDErrorType","SVD_ERROR_",0};
 27: const char *const SVDConvergedReasons_Shifted[] = {"","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","SVDConvergedReason","SVD_",0};
 28: const char *const*SVDConvergedReasons = SVDConvergedReasons_Shifted + 4;

 32: /*@C
 33:    SVDFinalizePackage - This function destroys everything in the Slepc interface
 34:    to the SVD package. It is called from SlepcFinalize().

 36:    Level: developer

 38: .seealso: SlepcFinalize()
 39: @*/
 40: PetscErrorCode SVDFinalizePackage(void)
 41: {

 45:   PetscFunctionListDestroy(&SVDList);
 46:   SVDPackageInitialized = PETSC_FALSE;
 47:   SVDRegisterAllCalled  = PETSC_FALSE;
 48:   return(0);
 49: }

 53: /*@C
 54:    SVDInitializePackage - This function initializes everything in the SVD package.
 55:    It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 56:    on the first call to SVDCreate() when using static libraries.

 58:    Level: developer

 60: .seealso: SlepcInitialize()
 61: @*/
 62: PetscErrorCode SVDInitializePackage(void)
 63: {
 64:   char           logList[256];
 65:   char           *className;
 66:   PetscBool      opt;

 70:   if (SVDPackageInitialized) return(0);
 71:   SVDPackageInitialized = PETSC_TRUE;
 72:   /* Register Classes */
 73:   PetscClassIdRegister("SVD Solver",&SVD_CLASSID);
 74:   /* Register Constructors */
 75:   SVDRegisterAll();
 76:   /* Register Events */
 77:   PetscLogEventRegister("SVDSetUp",SVD_CLASSID,&SVD_SetUp);
 78:   PetscLogEventRegister("SVDSolve",SVD_CLASSID,&SVD_Solve);
 79:   /* Process info exclusions */
 80:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 81:   if (opt) {
 82:     PetscStrstr(logList,"svd",&className);
 83:     if (className) {
 84:       PetscInfoDeactivateClass(SVD_CLASSID);
 85:     }
 86:   }
 87:   /* Process summary exclusions */
 88:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 89:   if (opt) {
 90:     PetscStrstr(logList,"svd",&className);
 91:     if (className) {
 92:       PetscLogEventDeactivateClass(SVD_CLASSID);
 93:     }
 94:   }
 95:   PetscRegisterFinalize(SVDFinalizePackage);
 96:   return(0);
 97: }

 99: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

103: /*
104:   PetscDLLibraryRegister - This function is called when the dynamic library
105:   it is in is opened.

107:   This one registers all the SVD methods that are in the basic SLEPc libslepcsvd
108:   library.
109:  */
110: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsvd()
111: {

115:   SVDInitializePackage();
116:   return(0);
117: }
118: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */

slepc-3.7.4/src/svd/interface/svdopts.c.html0000644000175000017500000025311113107004621020322 0ustar jromanjroman
Actual source code: svdopts.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      SVD routines for setting solver options.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>      /*I "slepcsvd.h" I*/
 25: #include <petscdraw.h>

 29: /*@
 30:    SVDSetImplicitTranspose - Indicates how to handle the transpose of the matrix
 31:    associated with the singular value problem.

 33:    Logically Collective on SVD

 35:    Input Parameters:
 36: +  svd  - the singular value solver context
 37: -  impl - how to handle the transpose (implicitly or not)

 39:    Options Database Key:
 40: .  -svd_implicittranspose - Activate the implicit transpose mode.

 42:    Notes:
 43:    By default, the transpose of the matrix is explicitly built (if the matrix
 44:    has defined the MatTranspose operation).

 46:    If this flag is set to true, the solver does not build the transpose, but
 47:    handles it implicitly via MatMultTranspose() (or MatMultHermitianTranspose()
 48:    in the complex case) operations. This is likely to be more inefficient
 49:    than the default behaviour, both in sequential and in parallel, but
 50:    requires less storage.

 52:    Level: advanced

 54: .seealso: SVDGetImplicitTranspose(), SVDSolve(), SVDSetOperator()
 55: @*/
 56: PetscErrorCode SVDSetImplicitTranspose(SVD svd,PetscBool impl)
 57: {
 61:   if (svd->impltrans!=impl) {
 62:     svd->impltrans = impl;
 63:     svd->state     = SVD_STATE_INITIAL;
 64:   }
 65:   return(0);
 66: }

 70: /*@
 71:    SVDGetImplicitTranspose - Gets the mode used to handle the transpose
 72:    of the matrix associated with the singular value problem.

 74:    Not Collective

 76:    Input Parameter:
 77: .  svd  - the singular value solver context

 79:    Output Parameter:
 80: .  impl - how to handle the transpose (implicitly or not)

 82:    Level: advanced

 84: .seealso: SVDSetImplicitTranspose(), SVDSolve(), SVDSetOperator()
 85: @*/
 86: PetscErrorCode SVDGetImplicitTranspose(SVD svd,PetscBool *impl)
 87: {
 91:   *impl = svd->impltrans;
 92:   return(0);
 93: }

 97: /*@
 98:    SVDSetTolerances - Sets the tolerance and maximum
 99:    iteration count used by the default SVD convergence testers.

101:    Logically Collective on SVD

103:    Input Parameters:
104: +  svd - the singular value solver context
105: .  tol - the convergence tolerance
106: -  maxits - maximum number of iterations to use

108:    Options Database Keys:
109: +  -svd_tol <tol> - Sets the convergence tolerance
110: -  -svd_max_it <maxits> - Sets the maximum number of iterations allowed
111:    (use PETSC_DECIDE to compute an educated guess based on basis and matrix sizes)

113:    Note:
114:    Use PETSC_DEFAULT for either argument to assign a reasonably good value.

116:    Level: intermediate

118: .seealso: SVDGetTolerances()
119: @*/
120: PetscErrorCode SVDSetTolerances(SVD svd,PetscReal tol,PetscInt maxits)
121: {
126:   if (tol == PETSC_DEFAULT) {
127:     svd->tol   = PETSC_DEFAULT;
128:     svd->state = SVD_STATE_INITIAL;
129:   } else {
130:     if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
131:     svd->tol = tol;
132:   }
133:   if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
134:     svd->max_it = 0;
135:     svd->state  = SVD_STATE_INITIAL;
136:   } else {
137:     if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
138:     svd->max_it = maxits;
139:   }
140:   return(0);
141: }

145: /*@
146:    SVDGetTolerances - Gets the tolerance and maximum
147:    iteration count used by the default SVD convergence tests.

149:    Not Collective

151:    Input Parameter:
152: .  svd - the singular value solver context

154:    Output Parameters:
155: +  tol - the convergence tolerance
156: -  maxits - maximum number of iterations

158:    Notes:
159:    The user can specify NULL for any parameter that is not needed.

161:    Level: intermediate

163: .seealso: SVDSetTolerances()
164: @*/
165: PetscErrorCode SVDGetTolerances(SVD svd,PetscReal *tol,PetscInt *maxits)
166: {
169:   if (tol)    *tol    = svd->tol;
170:   if (maxits) *maxits = svd->max_it;
171:   return(0);
172: }

176: /*@
177:    SVDSetDimensions - Sets the number of singular values to compute
178:    and the dimension of the subspace.

180:    Logically Collective on SVD

182:    Input Parameters:
183: +  svd - the singular value solver context
184: .  nsv - number of singular values to compute
185: .  ncv - the maximum dimension of the subspace to be used by the solver
186: -  mpd - the maximum dimension allowed for the projected problem

188:    Options Database Keys:
189: +  -svd_nsv <nsv> - Sets the number of singular values
190: .  -svd_ncv <ncv> - Sets the dimension of the subspace
191: -  -svd_mpd <mpd> - Sets the maximum projected dimension

193:    Notes:
194:    Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is
195:    dependent on the solution method and the number of singular values required.

197:    The parameters ncv and mpd are intimately related, so that the user is advised
198:    to set one of them at most. Normal usage is that
199:    (a) in cases where nsv is small, the user sets ncv (a reasonable default is 2*nsv); and
200:    (b) in cases where nsv is large, the user sets mpd.

202:    The value of ncv should always be between nsv and (nsv+mpd), typically
203:    ncv=nsv+mpd. If nsv is not too large, mpd=nsv is a reasonable choice, otherwise
204:    a smaller value should be used.

206:    Level: intermediate

208: .seealso: SVDGetDimensions()
209: @*/
210: PetscErrorCode SVDSetDimensions(SVD svd,PetscInt nsv,PetscInt ncv,PetscInt mpd)
211: {
217:   if (nsv<1) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nsv. Must be > 0");
218:   svd->nsv = nsv;
219:   if (ncv == PETSC_DEFAULT || ncv == PETSC_DECIDE) {
220:     svd->ncv = 0;
221:   } else {
222:     if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
223:     svd->ncv = ncv;
224:   }
225:   if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) {
226:     svd->mpd = 0;
227:   } else {
228:     if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
229:     svd->mpd = mpd;
230:   }
231:   svd->state = SVD_STATE_INITIAL;
232:   return(0);
233: }

237: /*@
238:    SVDGetDimensions - Gets the number of singular values to compute
239:    and the dimension of the subspace.

241:    Not Collective

243:    Input Parameter:
244: .  svd - the singular value context

246:    Output Parameters:
247: +  nsv - number of singular values to compute
248: .  ncv - the maximum dimension of the subspace to be used by the solver
249: -  mpd - the maximum dimension allowed for the projected problem

251:    Notes:
252:    The user can specify NULL for any parameter that is not needed.

254:    Level: intermediate

256: .seealso: SVDSetDimensions()
257: @*/
258: PetscErrorCode SVDGetDimensions(SVD svd,PetscInt *nsv,PetscInt *ncv,PetscInt *mpd)
259: {
262:   if (nsv) *nsv = svd->nsv;
263:   if (ncv) *ncv = svd->ncv;
264:   if (mpd) *mpd = svd->mpd;
265:   return(0);
266: }

270: /*@
271:     SVDSetWhichSingularTriplets - Specifies which singular triplets are
272:     to be sought.

274:     Logically Collective on SVD

276:     Input Parameter:
277: .   svd - singular value solver context obtained from SVDCreate()

279:     Output Parameter:
280: .   which - which singular triplets are to be sought

282:     Possible values:
283:     The parameter 'which' can have one of these values

285: +     SVD_LARGEST  - largest singular values
286: -     SVD_SMALLEST - smallest singular values

288:     Options Database Keys:
289: +   -svd_largest  - Sets largest singular values
290: -   -svd_smallest - Sets smallest singular values

292:     Level: intermediate

294: .seealso: SVDGetWhichSingularTriplets(), SVDWhich
295: @*/
296: PetscErrorCode SVDSetWhichSingularTriplets(SVD svd,SVDWhich which)
297: {
301:   switch (which) {
302:     case SVD_LARGEST:
303:     case SVD_SMALLEST:
304:       if (svd->which != which) {
305:         svd->state = SVD_STATE_INITIAL;
306:         svd->which = which;
307:       }
308:       break;
309:   default:
310:     SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' parameter");
311:   }
312:   return(0);
313: }

317: /*@
318:     SVDGetWhichSingularTriplets - Returns which singular triplets are
319:     to be sought.

321:     Not Collective

323:     Input Parameter:
324: .   svd - singular value solver context obtained from SVDCreate()

326:     Output Parameter:
327: .   which - which singular triplets are to be sought

329:     Notes:
330:     See SVDSetWhichSingularTriplets() for possible values of which

332:     Level: intermediate

334: .seealso: SVDSetWhichSingularTriplets(), SVDWhich
335: @*/
336: PetscErrorCode SVDGetWhichSingularTriplets(SVD svd,SVDWhich *which)
337: {
341:   *which = svd->which;
342:   return(0);
343: }

347: /*@C
348:    SVDSetConvergenceTestFunction - Sets a function to compute the error estimate
349:    used in the convergence test.

351:    Logically Collective on SVD

353:    Input Parameters:
354: +  svd     - singular value solver context obtained from SVDCreate()
355: .  func    - a pointer to the convergence test function
356: .  ctx     - context for private data for the convergence routine (may be null)
357: -  destroy - a routine for destroying the context (may be null)

359:    Calling Sequence of func:
360: $   func(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)

362: +   svd    - singular value solver context obtained from SVDCreate()
363: .   sigma  - computed singular value
364: .   res    - residual norm associated to the singular triplet
365: .   errest - (output) computed error estimate
366: -   ctx    - optional context, as set by SVDSetConvergenceTestFunction()

368:    Note:
369:    If the error estimate returned by the convergence test function is less than
370:    the tolerance, then the singular value is accepted as converged.

372:    Level: advanced

374: .seealso: SVDSetConvergenceTest(), SVDSetTolerances()
375: @*/
376: PetscErrorCode SVDSetConvergenceTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscReal,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
377: {

382:   if (svd->convergeddestroy) {
383:     (*svd->convergeddestroy)(svd->convergedctx);
384:   }
385:   svd->converged        = func;
386:   svd->convergeddestroy = destroy;
387:   svd->convergedctx     = ctx;
388:   if (func == SVDConvergedRelative) svd->conv = SVD_CONV_REL;
389:   else if (func == SVDConvergedAbsolute) svd->conv = SVD_CONV_ABS;
390:   else svd->conv = SVD_CONV_USER;
391:   return(0);
392: }

396: /*@
397:    SVDSetConvergenceTest - Specifies how to compute the error estimate
398:    used in the convergence test.

400:    Logically Collective on SVD

402:    Input Parameters:
403: +  svd  - singular value solver context obtained from SVDCreate()
404: -  conv - the type of convergence test

406:    Options Database Keys:
407: +  -svd_conv_abs  - Sets the absolute convergence test
408: .  -svd_conv_rel  - Sets the convergence test relative to the singular value
409: -  -svd_conv_user - Selects the user-defined convergence test

411:    Note:
412:    The parameter 'conv' can have one of these values
413: +     SVD_CONV_ABS  - absolute error ||r||
414: .     SVD_CONV_REL  - error relative to the singular value l, ||r||/sigma
415: -     SVD_CONV_USER - function set by SVDSetConvergenceTestFunction()

417:    Level: intermediate

419: .seealso: SVDGetConvergenceTest(), SVDSetConvergenceTestFunction(), SVDSetStoppingTest(), SVDConv
420: @*/
421: PetscErrorCode SVDSetConvergenceTest(SVD svd,SVDConv conv)
422: {
426:   switch (conv) {
427:     case SVD_CONV_ABS:  svd->converged = SVDConvergedAbsolute; break;
428:     case SVD_CONV_REL:  svd->converged = SVDConvergedRelative; break;
429:     case SVD_CONV_USER: break;
430:     default:
431:       SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value");
432:   }
433:   svd->conv = conv;
434:   return(0);
435: }

439: /*@
440:    SVDGetConvergenceTest - Gets the method used to compute the error estimate
441:    used in the convergence test.

443:    Not Collective

445:    Input Parameters:
446: .  svd   - singular value solver context obtained from SVDCreate()

448:    Output Parameters:
449: .  conv  - the type of convergence test

451:    Level: intermediate

453: .seealso: SVDSetConvergenceTest(), SVDConv
454: @*/
455: PetscErrorCode SVDGetConvergenceTest(SVD svd,SVDConv *conv)
456: {
460:   *conv = svd->conv;
461:   return(0);
462: }

466: /*@C
467:    SVDSetStoppingTestFunction - Sets a function to decide when to stop the outer
468:    iteration of the singular value solver.

470:    Logically Collective on SVD

472:    Input Parameters:
473: +  svd     - singular value solver context obtained from SVDCreate()
474: .  func    - pointer to the stopping test function
475: .  ctx     - context for private data for the stopping routine (may be null)
476: -  destroy - a routine for destroying the context (may be null)

478:    Calling Sequence of func:
479: $   func(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)

481: +   svd    - singular value solver context obtained from SVDCreate()
482: .   its    - current number of iterations
483: .   max_it - maximum number of iterations
484: .   nconv  - number of currently converged singular triplets
485: .   nsv    - number of requested singular triplets
486: .   reason - (output) result of the stopping test
487: -   ctx    - optional context, as set by SVDSetStoppingTestFunction()

489:    Note:
490:    Normal usage is to first call the default routine SVDStoppingBasic() and then
491:    set reason to SVD_CONVERGED_USER if some user-defined conditions have been
492:    met. To let the singular value solver continue iterating, the result must be
493:    left as SVD_CONVERGED_ITERATING.

495:    Level: advanced

497: .seealso: SVDSetStoppingTest(), SVDStoppingBasic()
498: @*/
499: PetscErrorCode SVDSetStoppingTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
500: {

505:   if (svd->stoppingdestroy) {
506:     (*svd->stoppingdestroy)(svd->stoppingctx);
507:   }
508:   svd->stopping        = func;
509:   svd->stoppingdestroy = destroy;
510:   svd->stoppingctx     = ctx;
511:   if (func == SVDStoppingBasic) svd->stop = SVD_STOP_BASIC;
512:   else svd->stop = SVD_STOP_USER;
513:   return(0);
514: }

518: /*@
519:    SVDSetStoppingTest - Specifies how to decide the termination of the outer
520:    loop of the singular value solver.

522:    Logically Collective on SVD

524:    Input Parameters:
525: +  svd  - singular value solver context obtained from SVDCreate()
526: -  stop - the type of stopping test

528:    Options Database Keys:
529: +  -svd_stop_basic - Sets the default stopping test
530: -  -svd_stop_user  - Selects the user-defined stopping test

532:    Note:
533:    The parameter 'stop' can have one of these values
534: +     SVD_STOP_BASIC - default stopping test
535: -     SVD_STOP_USER  - function set by SVDSetStoppingTestFunction()

537:    Level: advanced

539: .seealso: SVDGetStoppingTest(), SVDSetStoppingTestFunction(), SVDSetConvergenceTest(), SVDStop
540: @*/
541: PetscErrorCode SVDSetStoppingTest(SVD svd,SVDStop stop)
542: {
546:   switch (stop) {
547:     case SVD_STOP_BASIC: svd->stopping = SVDStoppingBasic; break;
548:     case SVD_STOP_USER:  break;
549:     default:
550:       SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value");
551:   }
552:   svd->stop = stop;
553:   return(0);
554: }

558: /*@
559:    SVDGetStoppingTest - Gets the method used to decide the termination of the outer
560:    loop of the singular value solver.

562:    Not Collective

564:    Input Parameters:
565: .  svd   - singular value solver context obtained from SVDCreate()

567:    Output Parameters:
568: .  stop  - the type of stopping test

570:    Level: advanced

572: .seealso: SVDSetStoppingTest(), SVDStop
573: @*/
574: PetscErrorCode SVDGetStoppingTest(SVD svd,SVDStop *stop)
575: {
579:   *stop = svd->stop;
580:   return(0);
581: }

585: /*@C
586:    SVDMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
587:    indicated by the user.

589:    Collective on SVD

591:    Input Parameters:
592: +  svd      - the singular value solver context
593: .  name     - the monitor option name
594: .  help     - message indicating what monitoring is done
595: .  manual   - manual page for the monitor
596: .  monitor  - the monitor function, whose context is a PetscViewerAndFormat
597: -  trackall - whether this monitor tracks all singular values or not

599:    Level: developer

601: .seealso: SVDMonitorSet(), SVDSetTrackAll(), SVDConvMonitorSetFromOptions()
602: @*/
603: PetscErrorCode SVDMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
604: {
605:   PetscErrorCode       ierr;
606:   PetscBool            flg;
607:   PetscViewer          viewer;
608:   PetscViewerFormat    format;
609:   PetscViewerAndFormat *vf;

612:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,name,&viewer,&format,&flg);
613:   if (flg) {
614:     PetscViewerAndFormatCreate(viewer,format,&vf);
615:     PetscObjectDereference((PetscObject)viewer);
616:     SVDMonitorSet(svd,(PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
617:     if (trackall) {
618:       SVDSetTrackAll(svd,PETSC_TRUE);
619:     }
620:   }
621:   return(0);
622: }

626: /*@C
627:    SVDConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
628:    indicated by the user (for monitors that only show iteration numbers of convergence).

630:    Collective on SVD

632:    Input Parameters:
633: +  svd      - the singular value solver context
634: .  name     - the monitor option name
635: .  help     - message indicating what monitoring is done
636: .  manual   - manual page for the monitor
637: -  monitor  - the monitor function, whose context is a SlepcConvMonitor

639:    Level: developer

641: .seealso: SVDMonitorSet(), SVDMonitorSetFromOptions()
642: @*/
643: PetscErrorCode SVDConvMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor))
644: {
645:   PetscErrorCode    ierr;
646:   PetscBool         flg;
647:   PetscViewer       viewer;
648:   PetscViewerFormat format;
649:   SlepcConvMonitor  ctx;

652:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,name,&viewer,&format,&flg);
653:   if (flg) {
654:     SlepcConvMonitorCreate(viewer,format,&ctx);
655:     PetscObjectDereference((PetscObject)viewer);
656:     SVDMonitorSet(svd,(PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);
657:   }
658:   return(0);
659: }

663: /*@
664:    SVDSetFromOptions - Sets SVD options from the options database.
665:    This routine must be called before SVDSetUp() if the user is to be
666:    allowed to set the solver type.

668:    Collective on SVD

670:    Input Parameters:
671: .  svd - the singular value solver context

673:    Notes:
674:    To see all options, run your program with the -help option.

676:    Level: beginner

678: .seealso:
679: @*/
680: PetscErrorCode SVDSetFromOptions(SVD svd)
681: {
683:   char           type[256];
684:   PetscBool      set,flg,val,flg1,flg2,flg3;
685:   PetscInt       i,j,k;
686:   PetscReal      r;
687:   PetscDrawLG    lg;

691:   SVDRegisterAll();
692:   PetscObjectOptionsBegin((PetscObject)svd);
693:     PetscOptionsFList("-svd_type","Singular Value Solver method","SVDSetType",SVDList,(char*)(((PetscObject)svd)->type_name?((PetscObject)svd)->type_name:SVDCROSS),type,256,&flg);
694:     if (flg) {
695:       SVDSetType(svd,type);
696:     } else if (!((PetscObject)svd)->type_name) {
697:       SVDSetType(svd,SVDCROSS);
698:     }

700:     PetscOptionsName("-svd_view","Print detailed information on solver used","SVDView",NULL);
701:     PetscOptionsName("-svd_view_vectors","View computed singular vectors","SVDVectorsView",NULL);
702:     PetscOptionsName("-svd_view_values","View computed singular values","SVDValuesView",NULL);
703:     PetscOptionsName("-svd_converged_reason","Print reason for convergence, and number of iterations","SVDReasonView",NULL);
704:     PetscOptionsName("-svd_error_absolute","Print absolute errors of each singular triplet","SVDErrorView",NULL);
705:     PetscOptionsName("-svd_error_relative","Print relative errors of each singular triplet","SVDErrorView",NULL);

707:     PetscOptionsBool("-svd_implicittranspose","Handle matrix transpose implicitly","SVDSetImplicitTranspose",svd->impltrans,&val,&flg);
708:     if (flg) {
709:       SVDSetImplicitTranspose(svd,val);
710:     }

712:     i = svd->max_it? svd->max_it: PETSC_DEFAULT;
713:     PetscOptionsInt("-svd_max_it","Maximum number of iterations","SVDSetTolerances",svd->max_it,&i,&flg1);
714:     r = svd->tol;
715:     PetscOptionsReal("-svd_tol","Tolerance","SVDSetTolerances",svd->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:svd->tol,&r,&flg2);
716:     if (flg1 || flg2) {
717:       SVDSetTolerances(svd,r,i);
718:     }

720:     PetscOptionsBoolGroupBegin("-svd_conv_rel","Relative error convergence test","SVDSetConvergenceTest",&flg);
721:     if (flg) { SVDSetConvergenceTest(svd,SVD_CONV_REL); }
722:     PetscOptionsBoolGroup("-svd_conv_abs","Absolute error convergence test","SVDSetConvergenceTest",&flg);
723:     if (flg) { SVDSetConvergenceTest(svd,SVD_CONV_ABS); }
724:     PetscOptionsBoolGroupEnd("-svd_conv_user","User-defined convergence test","SVDSetConvergenceTest",&flg);
725:     if (flg) { SVDSetConvergenceTest(svd,SVD_CONV_USER); }

727:     PetscOptionsBoolGroupBegin("-svd_stop_basic","Stop iteration if all singular values converged or max_it reached","SVDSetStoppingTest",&flg);
728:     if (flg) { SVDSetStoppingTest(svd,SVD_STOP_BASIC); }
729:     PetscOptionsBoolGroupEnd("-svd_stop_user","User-defined stopping test","SVDSetStoppingTest",&flg);
730:     if (flg) { SVDSetStoppingTest(svd,SVD_STOP_USER); }

732:     i = svd->nsv;
733:     PetscOptionsInt("-svd_nsv","Number of singular values to compute","SVDSetDimensions",svd->nsv,&i,&flg1);
734:     j = svd->ncv? svd->ncv: PETSC_DEFAULT;
735:     PetscOptionsInt("-svd_ncv","Number of basis vectors","SVDSetDimensions",svd->ncv,&j,&flg2);
736:     k = svd->mpd? svd->mpd: PETSC_DEFAULT;
737:     PetscOptionsInt("-svd_mpd","Maximum dimension of projected problem","SVDSetDimensions",svd->mpd,&k,&flg3);
738:     if (flg1 || flg2 || flg3) {
739:       SVDSetDimensions(svd,i,j,k);
740:     }

742:     PetscOptionsBoolGroupBegin("-svd_largest","compute largest singular values","SVDSetWhichSingularTriplets",&flg);
743:     if (flg) { SVDSetWhichSingularTriplets(svd,SVD_LARGEST); }
744:     PetscOptionsBoolGroupEnd("-svd_smallest","compute smallest singular values","SVDSetWhichSingularTriplets",&flg);
745:     if (flg) { SVDSetWhichSingularTriplets(svd,SVD_SMALLEST); }

747:     /* -----------------------------------------------------------------------*/
748:     /*
749:       Cancels all monitors hardwired into code before call to SVDSetFromOptions()
750:     */
751:     PetscOptionsBool("-svd_monitor_cancel","Remove any hardwired monitor routines","SVDMonitorCancel",PETSC_FALSE,&flg,&set);
752:     if (set && flg) {
753:       SVDMonitorCancel(svd);
754:     }
755:     /*
756:       Text monitors
757:     */
758:     SVDMonitorSetFromOptions(svd,"-svd_monitor","Monitor first unconverged approximate singular value and error estimate","SVDMonitorFirst",SVDMonitorFirst,PETSC_FALSE);
759:     SVDConvMonitorSetFromOptions(svd,"-svd_monitor_conv","Monitor approximate singular values and error estimates as they converge","SVDMonitorConverged",SVDMonitorConverged);
760:     SVDMonitorSetFromOptions(svd,"-svd_monitor_all","Monitor approximate singular values and error estimates","SVDMonitorAll",SVDMonitorAll,PETSC_TRUE);
761:     /*
762:       Line graph monitors
763:     */
764:     PetscOptionsBool("-svd_monitor_lg","Monitor first unconverged approximate singular value and error estimate graphically","SVDMonitorSet",PETSC_FALSE,&flg,&set);
765:     if (set && flg) {
766:       SVDMonitorLGCreate(PetscObjectComm((PetscObject)svd),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
767:       SVDMonitorSet(svd,SVDMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
768:     }
769:     PetscOptionsBool("-svd_monitor_lg_all","Monitor error estimates graphically","SVDMonitorSet",PETSC_FALSE,&flg,&set);
770:     if (set && flg) {
771:       SVDMonitorLGCreate(PetscObjectComm((PetscObject)svd),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
772:       SVDMonitorSet(svd,SVDMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
773:       SVDSetTrackAll(svd,PETSC_TRUE);
774:     }

776:     if (svd->ops->setfromoptions) {
777:       (*svd->ops->setfromoptions)(PetscOptionsObject,svd);
778:     }
779:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)svd);
780:   PetscOptionsEnd();

782:   if (!svd->V) { SVDGetBV(svd,&svd->V,&svd->U); }
783:   BVSetFromOptions(svd->V);
784:   BVSetFromOptions(svd->U);
785:   if (!svd->ds) { SVDGetDS(svd,&svd->ds); }
786:   DSSetFromOptions(svd->ds);
787:   return(0);
788: }

792: /*@
793:    SVDSetTrackAll - Specifies if the solver must compute the residual norm of all
794:    approximate singular value or not.

796:    Logically Collective on SVD

798:    Input Parameters:
799: +  svd      - the singular value solver context
800: -  trackall - whether to compute all residuals or not

802:    Notes:
803:    If the user sets trackall=PETSC_TRUE then the solver computes (or estimates)
804:    the residual norm for each singular value approximation. Computing the residual is
805:    usually an expensive operation and solvers commonly compute only the residual
806:    associated to the first unconverged singular value.

808:    The options '-svd_monitor_all' and '-svd_monitor_lg_all' automatically
809:    activate this option.

811:    Level: developer

813: .seealso: SVDGetTrackAll()
814: @*/
815: PetscErrorCode SVDSetTrackAll(SVD svd,PetscBool trackall)
816: {
820:   svd->trackall = trackall;
821:   return(0);
822: }

826: /*@
827:    SVDGetTrackAll - Returns the flag indicating whether all residual norms must
828:    be computed or not.

830:    Not Collective

832:    Input Parameter:
833: .  svd - the singular value solver context

835:    Output Parameter:
836: .  trackall - the returned flag

838:    Level: developer

840: .seealso: SVDSetTrackAll()
841: @*/
842: PetscErrorCode SVDGetTrackAll(SVD svd,PetscBool *trackall)
843: {
847:   *trackall = svd->trackall;
848:   return(0);
849: }


854: /*@C
855:    SVDSetOptionsPrefix - Sets the prefix used for searching for all
856:    SVD options in the database.

858:    Logically Collective on SVD

860:    Input Parameters:
861: +  svd - the singular value solver context
862: -  prefix - the prefix string to prepend to all SVD option requests

864:    Notes:
865:    A hyphen (-) must NOT be given at the beginning of the prefix name.
866:    The first character of all runtime options is AUTOMATICALLY the
867:    hyphen.

869:    For example, to distinguish between the runtime options for two
870:    different SVD contexts, one could call
871: .vb
872:       SVDSetOptionsPrefix(svd1,"svd1_")
873:       SVDSetOptionsPrefix(svd2,"svd2_")
874: .ve

876:    Level: advanced

878: .seealso: SVDAppendOptionsPrefix(), SVDGetOptionsPrefix()
879: @*/
880: PetscErrorCode SVDSetOptionsPrefix(SVD svd,const char *prefix)
881: {
883:   PetscBool      flg1,flg2;
884:   EPS            eps;

888:   if (!svd->V) { SVDGetBV(svd,&svd->V,&svd->U); }
889:   BVSetOptionsPrefix(svd->V,prefix);
890:   BVSetOptionsPrefix(svd->U,prefix);
891:   if (!svd->ds) { SVDGetDS(svd,&svd->ds); }
892:   DSSetOptionsPrefix(svd->ds,prefix);
893:   PetscObjectSetOptionsPrefix((PetscObject)svd,prefix);
894:   PetscObjectTypeCompare((PetscObject)svd,SVDCROSS,&flg1);
895:   PetscObjectTypeCompare((PetscObject)svd,SVDCYCLIC,&flg2);
896:   if (flg1) {
897:     SVDCrossGetEPS(svd,&eps);
898:   } else if (flg2) {
899:       SVDCyclicGetEPS(svd,&eps);
900:   }
901:   if (flg1 || flg2) {
902:     EPSSetOptionsPrefix(eps,prefix);
903:     EPSAppendOptionsPrefix(eps,"svd_");
904:   }
905:   return(0);
906: }

910: /*@C
911:    SVDAppendOptionsPrefix - Appends to the prefix used for searching for all
912:    SVD options in the database.

914:    Logically Collective on SVD

916:    Input Parameters:
917: +  svd - the singular value solver context
918: -  prefix - the prefix string to prepend to all SVD option requests

920:    Notes:
921:    A hyphen (-) must NOT be given at the beginning of the prefix name.
922:    The first character of all runtime options is AUTOMATICALLY the hyphen.

924:    Level: advanced

926: .seealso: SVDSetOptionsPrefix(), SVDGetOptionsPrefix()
927: @*/
928: PetscErrorCode SVDAppendOptionsPrefix(SVD svd,const char *prefix)
929: {
931:   PetscBool      flg1,flg2;
932:   EPS            eps;

936:   if (!svd->V) { SVDGetBV(svd,&svd->V,&svd->U); }
937:   BVSetOptionsPrefix(svd->V,prefix);
938:   BVSetOptionsPrefix(svd->U,prefix);
939:   if (!svd->ds) { SVDGetDS(svd,&svd->ds); }
940:   DSSetOptionsPrefix(svd->ds,prefix);
941:   PetscObjectAppendOptionsPrefix((PetscObject)svd,prefix);
942:   PetscObjectTypeCompare((PetscObject)svd,SVDCROSS,&flg1);
943:   PetscObjectTypeCompare((PetscObject)svd,SVDCYCLIC,&flg2);
944:   if (flg1) {
945:     SVDCrossGetEPS(svd,&eps);
946:   } else if (flg2) {
947:     SVDCyclicGetEPS(svd,&eps);
948:   }
949:   if (flg1 || flg2) {
950:     EPSSetOptionsPrefix(eps,((PetscObject)svd)->prefix);
951:     EPSAppendOptionsPrefix(eps,"svd_");
952:   }
953:   return(0);
954: }

958: /*@C
959:    SVDGetOptionsPrefix - Gets the prefix used for searching for all
960:    SVD options in the database.

962:    Not Collective

964:    Input Parameters:
965: .  svd - the singular value solver context

967:    Output Parameters:
968: .  prefix - pointer to the prefix string used is returned

970:    Note:
971:    On the Fortran side, the user should pass in a string 'prefix' of
972:    sufficient length to hold the prefix.

974:    Level: advanced

976: .seealso: SVDSetOptionsPrefix(), SVDAppendOptionsPrefix()
977: @*/
978: PetscErrorCode SVDGetOptionsPrefix(SVD svd,const char *prefix[])
979: {

985:   PetscObjectGetOptionsPrefix((PetscObject)svd,prefix);
986:   return(0);
987: }

slepc-3.7.4/src/svd/interface/svdbasic.c.html0000644000175000017500000007621313107004621020424 0ustar jromanjroman
Actual source code: svdbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    The basic SVD routines, Create, Destroy, etc. are here.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>      /*I "slepcsvd.h" I*/

 26: PetscFunctionList SVDList = 0;
 27: PetscBool         SVDRegisterAllCalled = PETSC_FALSE;
 28: PetscClassId      SVD_CLASSID = 0;
 29: PetscLogEvent     SVD_SetUp = 0,SVD_Solve = 0;

 33: /*@
 34:    SVDCreate - Creates the default SVD context.

 36:    Collective on MPI_Comm

 38:    Input Parameter:
 39: .  comm - MPI communicator

 41:    Output Parameter:
 42: .  svd - location to put the SVD context

 44:    Note:
 45:    The default SVD type is SVDCROSS

 47:    Level: beginner

 49: .seealso: SVDSetUp(), SVDSolve(), SVDDestroy(), SVD
 50: @*/
 51: PetscErrorCode SVDCreate(MPI_Comm comm,SVD *outsvd)
 52: {
 54:   SVD            svd;

 58:   *outsvd = 0;
 59:   SVDInitializePackage();
 60:   SlepcHeaderCreate(svd,SVD_CLASSID,"SVD","Singular Value Decomposition","SVD",comm,SVDDestroy,SVDView);

 62:   svd->OP               = NULL;
 63:   svd->max_it           = 0;
 64:   svd->nsv              = 1;
 65:   svd->ncv              = 0;
 66:   svd->mpd              = 0;
 67:   svd->nini             = 0;
 68:   svd->ninil            = 0;
 69:   svd->tol              = PETSC_DEFAULT;
 70:   svd->conv             = SVD_CONV_REL;
 71:   svd->stop             = SVD_STOP_BASIC;
 72:   svd->which            = SVD_LARGEST;
 73:   svd->impltrans        = PETSC_FALSE;
 74:   svd->trackall         = PETSC_FALSE;

 76:   svd->converged        = SVDConvergedRelative;
 77:   svd->convergeddestroy = NULL;
 78:   svd->stopping         = SVDStoppingBasic;
 79:   svd->stoppingdestroy  = NULL;
 80:   svd->convergedctx     = NULL;
 81:   svd->stoppingctx      = NULL;
 82:   svd->numbermonitors   = 0;

 84:   svd->ds               = NULL;
 85:   svd->U                = NULL;
 86:   svd->V                = NULL;
 87:   svd->A                = NULL;
 88:   svd->AT               = NULL;
 89:   svd->IS               = NULL;
 90:   svd->ISL              = NULL;
 91:   svd->sigma            = NULL;
 92:   svd->perm             = NULL;
 93:   svd->errest           = NULL;
 94:   svd->data             = NULL;

 96:   svd->state            = SVD_STATE_INITIAL;
 97:   svd->nconv            = 0;
 98:   svd->its              = 0;
 99:   svd->leftbasis        = PETSC_FALSE;
100:   svd->reason           = SVD_CONVERGED_ITERATING;

102:   PetscNewLog(svd,&svd->sc);
103:   *outsvd = svd;
104:   return(0);
105: }

109: /*@
110:    SVDReset - Resets the SVD context to the initial state and removes any
111:    allocated objects.

113:    Collective on SVD

115:    Input Parameter:
116: .  svd - singular value solver context obtained from SVDCreate()

118:    Level: advanced

120: .seealso: SVDDestroy()
121: @*/
122: PetscErrorCode SVDReset(SVD svd)
123: {
125:   PetscInt       ncols;

129:   if (svd->ops->reset) { (svd->ops->reset)(svd); }
130:   if (svd->ds) { DSReset(svd->ds); }
131:   MatDestroy(&svd->OP);
132:   MatDestroy(&svd->A);
133:   MatDestroy(&svd->AT);
134:   BVGetSizes(svd->V,NULL,NULL,&ncols);
135:   if (ncols) {
136:     PetscFree3(svd->sigma,svd->perm,svd->errest);
137:   }
138:   BVDestroy(&svd->U);
139:   BVDestroy(&svd->V);
140:   svd->state = SVD_STATE_INITIAL;
141:   return(0);
142: }

146: /*@
147:    SVDDestroy - Destroys the SVD context.

149:    Collective on SVD

151:    Input Parameter:
152: .  svd - singular value solver context obtained from SVDCreate()

154:    Level: beginner

156: .seealso: SVDCreate(), SVDSetUp(), SVDSolve()
157: @*/
158: PetscErrorCode SVDDestroy(SVD *svd)
159: {

163:   if (!*svd) return(0);
165:   if (--((PetscObject)(*svd))->refct > 0) { *svd = 0; return(0); }
166:   SVDReset(*svd);
167:   if ((*svd)->ops->destroy) { (*(*svd)->ops->destroy)(*svd); }
168:   DSDestroy(&(*svd)->ds);
169:   PetscFree((*svd)->sc);
170:   /* just in case the initial vectors have not been used */
171:   SlepcBasisDestroy_Private(&(*svd)->nini,&(*svd)->IS);
172:   SlepcBasisDestroy_Private(&(*svd)->ninil,&(*svd)->ISL);
173:   SVDMonitorCancel(*svd);
174:   PetscHeaderDestroy(svd);
175:   return(0);
176: }

180: /*@C
181:    SVDSetType - Selects the particular solver to be used in the SVD object.

183:    Logically Collective on SVD

185:    Input Parameters:
186: +  svd      - the singular value solver context
187: -  type     - a known method

189:    Options Database Key:
190: .  -svd_type <method> - Sets the method; use -help for a list
191:     of available methods

193:    Notes:
194:    See "slepc/include/slepcsvd.h" for available methods. The default
195:    is SVDCROSS.

197:    Normally, it is best to use the SVDSetFromOptions() command and
198:    then set the SVD type from the options database rather than by using
199:    this routine.  Using the options database provides the user with
200:    maximum flexibility in evaluating the different available methods.
201:    The SVDSetType() routine is provided for those situations where it
202:    is necessary to set the iterative solver independently of the command
203:    line or options database.

205:    Level: intermediate

207: .seealso: SVDType
208: @*/
209: PetscErrorCode SVDSetType(SVD svd,SVDType type)
210: {
211:   PetscErrorCode ierr,(*r)(SVD);
212:   PetscBool      match;


218:   PetscObjectTypeCompare((PetscObject)svd,type,&match);
219:   if (match) return(0);

221:   PetscFunctionListFind(SVDList,type,&r);
222:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown SVD type given: %s",type);

224:   if (svd->ops->destroy) { (*svd->ops->destroy)(svd); }
225:   PetscMemzero(svd->ops,sizeof(struct _SVDOps));

227:   svd->state = SVD_STATE_INITIAL;
228:   PetscObjectChangeTypeName((PetscObject)svd,type);
229:   (*r)(svd);
230:   return(0);
231: }

235: /*@C
236:    SVDGetType - Gets the SVD type as a string from the SVD object.

238:    Not Collective

240:    Input Parameter:
241: .  svd - the singular value solver context

243:    Output Parameter:
244: .  name - name of SVD method

246:    Level: intermediate

248: .seealso: SVDSetType()
249: @*/
250: PetscErrorCode SVDGetType(SVD svd,SVDType *type)
251: {
255:   *type = ((PetscObject)svd)->type_name;
256:   return(0);
257: }

261: /*@C
262:    SVDRegister - Adds a method to the singular value solver package.

264:    Not Collective

266:    Input Parameters:
267: +  name - name of a new user-defined solver
268: -  function - routine to create the solver context

270:    Notes:
271:    SVDRegister() may be called multiple times to add several user-defined solvers.

273:    Sample usage:
274: .vb
275:     SVDRegister("my_solver",MySolverCreate);
276: .ve

278:    Then, your solver can be chosen with the procedural interface via
279: $     SVDSetType(svd,"my_solver")
280:    or at runtime via the option
281: $     -svd_type my_solver

283:    Level: advanced

285: .seealso: SVDRegisterAll()
286: @*/
287: PetscErrorCode SVDRegister(const char *name,PetscErrorCode (*function)(SVD))
288: {

292:   PetscFunctionListAdd(&SVDList,name,function);
293:   return(0);
294: }

298: /*@
299:    SVDSetBV - Associates basis vectors objects to the singular value solver.

301:    Collective on SVD

303:    Input Parameters:
304: +  svd - singular value solver context obtained from SVDCreate()
305: .  V   - the basis vectors object for right singular vectors
306: -  U   - the basis vectors object for left singular vectors

308:    Note:
309:    Use SVDGetBV() to retrieve the basis vectors contexts (for example,
310:    to free them at the end of the computations).

312:    Level: advanced

314: .seealso: SVDGetBV()
315: @*/
316: PetscErrorCode SVDSetBV(SVD svd,BV V,BV U)
317: {

322:   if (V) {
325:     PetscObjectReference((PetscObject)V);
326:     BVDestroy(&svd->V);
327:     svd->V = V;
328:     PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->V);
329:   }
330:   if (U) {
333:     PetscObjectReference((PetscObject)U);
334:     BVDestroy(&svd->U);
335:     svd->U = U;
336:     PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->U);
337:   }
338:   return(0);
339: }

343: /*@
344:    SVDGetBV - Obtain the basis vectors objects associated to the singular
345:    value solver object.

347:    Not Collective

349:    Input Parameters:
350: .  svd - singular value solver context obtained from SVDCreate()

352:    Output Parameter:
353: +  V - basis vectors context for right singular vectors
354: -  U - basis vectors context for left singular vectors

356:    Level: advanced

358: .seealso: SVDSetBV()
359: @*/
360: PetscErrorCode SVDGetBV(SVD svd,BV *V,BV *U)
361: {

366:   if (V) {
367:     if (!svd->V) {
368:       BVCreate(PetscObjectComm((PetscObject)svd),&svd->V);
369:       PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->V);
370:     }
371:     *V = svd->V;
372:   }
373:   if (U) {
374:     if (!svd->U) {
375:       BVCreate(PetscObjectComm((PetscObject)svd),&svd->U);
376:       PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->U);
377:     }
378:     *U = svd->U;
379:   }
380:   return(0);
381: }

385: /*@
386:    SVDSetDS - Associates a direct solver object to the singular value solver.

388:    Collective on SVD

390:    Input Parameters:
391: +  svd - singular value solver context obtained from SVDCreate()
392: -  ds  - the direct solver object

394:    Note:
395:    Use SVDGetDS() to retrieve the direct solver context (for example,
396:    to free it at the end of the computations).

398:    Level: advanced

400: .seealso: SVDGetDS()
401: @*/
402: PetscErrorCode SVDSetDS(SVD svd,DS ds)
403: {

410:   PetscObjectReference((PetscObject)ds);
411:   DSDestroy(&svd->ds);
412:   svd->ds = ds;
413:   PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->ds);
414:   return(0);
415: }

419: /*@
420:    SVDGetDS - Obtain the direct solver object associated to the singular value
421:    solver object.

423:    Not Collective

425:    Input Parameters:
426: .  svd - singular value solver context obtained from SVDCreate()

428:    Output Parameter:
429: .  ds - direct solver context

431:    Level: advanced

433: .seealso: SVDSetDS()
434: @*/
435: PetscErrorCode SVDGetDS(SVD svd,DS *ds)
436: {

442:   if (!svd->ds) {
443:     DSCreate(PetscObjectComm((PetscObject)svd),&svd->ds);
444:     PetscLogObjectParent((PetscObject)svd,(PetscObject)svd->ds);
445:   }
446:   *ds = svd->ds;
447:   return(0);
448: }

slepc-3.7.4/src/svd/interface/svdview.c.html0000644000175000017500000013206713107004621020315 0ustar jromanjroman
Actual source code: svdview.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    The SVD routines related to various viewers.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>      /*I "slepcsvd.h" I*/
 25: #include <petscdraw.h>

 29: /*@C
 30:    SVDView - Prints the SVD data structure.

 32:    Collective on SVD

 34:    Input Parameters:
 35: +  svd - the singular value solver context
 36: -  viewer - optional visualization context

 38:    Options Database Key:
 39: .  -svd_view -  Calls SVDView() at end of SVDSolve()

 41:    Note:
 42:    The available visualization contexts include
 43: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
 44: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
 45:          output where only the first processor opens
 46:          the file.  All other processors send their
 47:          data to the first processor to print.

 49:    The user can open an alternative visualization context with
 50:    PetscViewerASCIIOpen() - output to a specified file.

 52:    Level: beginner

 54: .seealso: STView(), PetscViewerASCIIOpen()
 55: @*/
 56: PetscErrorCode SVDView(SVD svd,PetscViewer viewer)
 57: {
 59:   PetscBool      isascii,isshell;

 63:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd));

 67:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
 68:   if (isascii) {
 69:     PetscObjectPrintClassNamePrefixType((PetscObject)svd,viewer);
 70:     if (svd->ops->view) {
 71:       PetscViewerASCIIPushTab(viewer);
 72:       (*svd->ops->view)(svd,viewer);
 73:       PetscViewerASCIIPopTab(viewer);
 74:     }
 75:     PetscViewerASCIIPrintf(viewer,"  transpose mode: %s\n",svd->impltrans?"implicit":"explicit");
 76:     if (svd->which == SVD_LARGEST) {
 77:       PetscViewerASCIIPrintf(viewer,"  selected portion of the spectrum: largest\n");
 78:     } else {
 79:       PetscViewerASCIIPrintf(viewer,"  selected portion of the spectrum: smallest\n");
 80:     }
 81:     PetscViewerASCIIPrintf(viewer,"  number of singular values (nsv): %D\n",svd->nsv);
 82:     PetscViewerASCIIPrintf(viewer,"  number of column vectors (ncv): %D\n",svd->ncv);
 83:     PetscViewerASCIIPrintf(viewer,"  maximum dimension of projected problem (mpd): %D\n",svd->mpd);
 84:     PetscViewerASCIIPrintf(viewer,"  maximum number of iterations: %D\n",svd->max_it);
 85:     PetscViewerASCIIPrintf(viewer,"  tolerance: %g\n",(double)svd->tol);
 86:     PetscViewerASCIIPrintf(viewer,"  convergence test: ");
 87:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
 88:     switch (svd->conv) {
 89:     case SVD_CONV_ABS:
 90:       PetscViewerASCIIPrintf(viewer,"absolute\n");break;
 91:     case SVD_CONV_REL:
 92:       PetscViewerASCIIPrintf(viewer,"relative to the singular value\n");break;
 93:     case SVD_CONV_USER:
 94:       PetscViewerASCIIPrintf(viewer,"user-defined\n");break;
 95:     }
 96:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
 97:     if (svd->nini) {
 98:       PetscViewerASCIIPrintf(viewer,"  dimension of user-provided initial space: %D\n",PetscAbs(svd->nini));
 99:     }
100:     if (svd->ninil) {
101:       PetscViewerASCIIPrintf(viewer,"  dimension of user-provided initial left space: %D\n",PetscAbs(svd->ninil));
102:     }
103:   } else {
104:     if (svd->ops->view) {
105:       (*svd->ops->view)(svd,viewer);
106:     }
107:   }
108:   PetscObjectTypeCompareAny((PetscObject)svd,&isshell,SVDCROSS,SVDCYCLIC,"");
109:   if (!isshell) {
110:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);
111:     if (!svd->V) { SVDGetBV(svd,&svd->V,NULL); }
112:     BVView(svd->V,viewer);
113:     if (!svd->ds) { SVDGetDS(svd,&svd->ds); }
114:     DSView(svd->ds,viewer);
115:     PetscViewerPopFormat(viewer);
116:   }
117:   return(0);
118: }

122: /*@C
123:    SVDReasonView - Displays the reason an SVD solve converged or diverged.

125:    Collective on SVD

127:    Parameter:
128: +  svd - the singular value solver context
129: -  viewer - the viewer to display the reason

131:    Options Database Keys:
132: .  -svd_converged_reason - print reason for convergence, and number of iterations

134:    Level: intermediate

136: .seealso: SVDSetTolerances(), SVDGetIterationNumber()
137: @*/
138: PetscErrorCode SVDReasonView(SVD svd,PetscViewer viewer)
139: {
141:   PetscBool      isAscii;

144:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);
145:   if (isAscii) {
146:     PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);
147:     if (svd->reason > 0) {
148:       PetscViewerASCIIPrintf(viewer,"%s SVD solve converged (%D singular triplet%s) due to %s; iterations %D\n",((PetscObject)svd)->prefix?((PetscObject)svd)->prefix:"",svd->nconv,(svd->nconv>1)?"s":"",SVDConvergedReasons[svd->reason],svd->its);
149:     } else {
150:       PetscViewerASCIIPrintf(viewer,"%s SVD solve did not converge due to %s; iterations %D\n",((PetscObject)svd)->prefix?((PetscObject)svd)->prefix:"",SVDConvergedReasons[svd->reason],svd->its);
151:     }
152:     PetscViewerASCIISubtractTab(viewer,((PetscObject)svd)->tablevel);
153:   }
154:   return(0);
155: }

159: /*@
160:    SVDReasonViewFromOptions - Processes command line options to determine if/how
161:    the SVD converged reason is to be viewed. 

163:    Collective on SVD

165:    Input Parameters:
166: .  svd - the singular value solver context

168:    Level: developer
169: @*/
170: PetscErrorCode SVDReasonViewFromOptions(SVD svd)
171: {
172:   PetscErrorCode    ierr;
173:   PetscViewer       viewer;
174:   PetscBool         flg;
175:   static PetscBool  incall = PETSC_FALSE;
176:   PetscViewerFormat format;

179:   if (incall) return(0);
180:   incall = PETSC_TRUE;
181:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_converged_reason",&viewer,&format,&flg);
182:   if (flg) {
183:     PetscViewerPushFormat(viewer,format);
184:     SVDReasonView(svd,viewer);
185:     PetscViewerPopFormat(viewer);
186:     PetscViewerDestroy(&viewer);
187:   }
188:   incall = PETSC_FALSE;
189:   return(0);
190: }

194: static PetscErrorCode SVDErrorView_ASCII(SVD svd,SVDErrorType etype,PetscViewer viewer)
195: {
196:   PetscBool      errok;
197:   PetscReal      error,sigma;
198:   PetscInt       i,j;

202:   if (svd->nconv<svd->nsv) {
203:     PetscViewerASCIIPrintf(viewer," Problem: less than %D singular values converged\n\n",svd->nsv);
204:     return(0);
205:   }
206:   errok = PETSC_TRUE;
207:   for (i=0;i<svd->nsv;i++) {
208:     SVDComputeError(svd,i,etype,&error);
209:     errok = (errok && error<5.0*svd->tol)? PETSC_TRUE: PETSC_FALSE;
210:   }
211:   if (!errok) {
212:     PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",svd->nsv);
213:     return(0);
214:   }
215:   PetscViewerASCIIPrintf(viewer," All requested singular values computed up to the required tolerance:");
216:   for (i=0;i<=(svd->nsv-1)/8;i++) {
217:     PetscViewerASCIIPrintf(viewer,"\n     ");
218:     for (j=0;j<PetscMin(8,svd->nsv-8*i);j++) {
219:       SVDGetSingularTriplet(svd,8*i+j,&sigma,NULL,NULL);
220:       PetscViewerASCIIPrintf(viewer,"%.5f",(double)sigma);
221:       if (8*i+j+1<svd->nsv) { PetscViewerASCIIPrintf(viewer,", "); }
222:     }
223:   }
224:   PetscViewerASCIIPrintf(viewer,"\n\n");
225:   return(0);
226: }

230: static PetscErrorCode SVDErrorView_DETAIL(SVD svd,SVDErrorType etype,PetscViewer viewer)
231: {
233:   PetscReal      error,sigma;
234:   PetscInt       i;
235: #define EXLEN 30
236:   char           ex[EXLEN],sep[]=" ---------------------- --------------------\n";

239:   if (!svd->nconv) return(0);
240:   switch (etype) {
241:     case SVD_ERROR_ABSOLUTE:
242:       PetscSNPrintf(ex,EXLEN," absolute error");
243:       break;
244:     case SVD_ERROR_RELATIVE:
245:       PetscSNPrintf(ex,EXLEN," relative error");
246:       break;
247:   }
248:   PetscViewerASCIIPrintf(viewer,"%s          sigma           %s\n%s",sep,ex,sep);
249:   for (i=0;i<svd->nconv;i++) {
250:     SVDGetSingularTriplet(svd,i,&sigma,NULL,NULL);
251:     SVDComputeError(svd,i,etype,&error);
252:     PetscViewerASCIIPrintf(viewer,"       % 6f          %12g\n",(double)sigma,(double)error);
253:   }
254:   PetscViewerASCIIPrintf(viewer,sep);
255:   return(0);
256: }

260: static PetscErrorCode SVDErrorView_MATLAB(SVD svd,SVDErrorType etype,PetscViewer viewer)
261: {
263:   PetscReal      error;
264:   PetscInt       i;
265:   const char     *name;

268:   PetscObjectGetName((PetscObject)svd,&name);
269:   PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);
270:   for (i=0;i<svd->nconv;i++) {
271:     SVDComputeError(svd,i,etype,&error);
272:     PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);
273:   }
274:   PetscViewerASCIIPrintf(viewer,"];\n");
275:   return(0);
276: }

280: /*@C
281:    SVDErrorView - Displays the errors associated with the computed solution
282:    (as well as the singular values).

284:    Collective on SVD

286:    Input Parameters:
287: +  svd    - the singular value solver context
288: .  etype  - error type
289: -  viewer - optional visualization context

291:    Options Database Key:
292: +  -svd_error_absolute - print absolute errors of each singular triplet
293: -  -svd_error_relative - print relative errors of each singular triplet

295:    Notes:
296:    By default, this function checks the error of all singular triplets and prints
297:    the singular values if all of them are below the requested tolerance.
298:    If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with
299:    singular values and corresponding errors is printed.

301:    Level: intermediate

303: .seealso: SVDSolve(), SVDValuesView(), SVDVectorsView()
304: @*/
305: PetscErrorCode SVDErrorView(SVD svd,SVDErrorType etype,PetscViewer viewer)
306: {
307:   PetscBool         isascii;
308:   PetscViewerFormat format;
309:   PetscErrorCode    ierr;

313:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd));
316:   SVDCheckSolved(svd,1);
317:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
318:   if (!isascii) return(0);

320:   PetscViewerGetFormat(viewer,&format);
321:   switch (format) {
322:     case PETSC_VIEWER_DEFAULT:
323:     case PETSC_VIEWER_ASCII_INFO:
324:       SVDErrorView_ASCII(svd,etype,viewer);
325:       break;
326:     case PETSC_VIEWER_ASCII_INFO_DETAIL:
327:       SVDErrorView_DETAIL(svd,etype,viewer);
328:       break;
329:     case PETSC_VIEWER_ASCII_MATLAB:
330:       SVDErrorView_MATLAB(svd,etype,viewer);
331:       break;
332:     default:
333:       PetscInfo1(svd,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
334:   }
335:   return(0);
336: }

340: /*@
341:    SVDErrorViewFromOptions - Processes command line options to determine if/how
342:    the errors of the computed solution are to be viewed. 

344:    Collective on SVD

346:    Input Parameters:
347: .  svd - the singular value solver context

349:    Level: developer
350: @*/
351: PetscErrorCode SVDErrorViewFromOptions(SVD svd)
352: {
353:   PetscErrorCode    ierr;
354:   PetscViewer       viewer;
355:   PetscBool         flg;
356:   static PetscBool  incall = PETSC_FALSE;
357:   PetscViewerFormat format;

360:   if (incall) return(0);
361:   incall = PETSC_TRUE;
362:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_error_absolute",&viewer,&format,&flg);
363:   if (flg) {
364:     PetscViewerPushFormat(viewer,format);
365:     SVDErrorView(svd,SVD_ERROR_ABSOLUTE,viewer);
366:     PetscViewerPopFormat(viewer);
367:     PetscViewerDestroy(&viewer);
368:   }
369:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_error_relative",&viewer,&format,&flg);
370:   if (flg) {
371:     PetscViewerPushFormat(viewer,format);
372:     SVDErrorView(svd,SVD_ERROR_RELATIVE,viewer);
373:     PetscViewerPopFormat(viewer);
374:     PetscViewerDestroy(&viewer);
375:   }
376:   incall = PETSC_FALSE;
377:   return(0);
378: }

382: static PetscErrorCode SVDValuesView_DRAW(SVD svd,PetscViewer viewer)
383: {
385:   PetscDraw      draw;
386:   PetscDrawSP    drawsp;
387:   PetscReal      re,im=0.0;
388:   PetscInt       i;

391:   if (!svd->nconv) return(0);
392:   PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed singular values",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);
393:   PetscViewerDrawGetDraw(viewer,0,&draw);
394:   PetscDrawSPCreate(draw,1,&drawsp);
395:   for (i=0;i<svd->nconv;i++) {
396:     re = svd->sigma[svd->perm[i]];
397:     PetscDrawSPAddPoint(drawsp,&re,&im);
398:   }
399:   PetscDrawSPDraw(drawsp,PETSC_TRUE);
400:   PetscDrawSPSave(drawsp);
401:   PetscDrawSPDestroy(&drawsp);
402:   PetscViewerDestroy(&viewer);
403:   return(0);
404: }

408: static PetscErrorCode SVDValuesView_ASCII(SVD svd,PetscViewer viewer)
409: {
410:   PetscInt       i;

414:   PetscViewerASCIIPrintf(viewer,"Singular values = \n");
415:   for (i=0;i<svd->nconv;i++) {
416:     PetscViewerASCIIPrintf(viewer,"   %.5f\n",(double)svd->sigma[svd->perm[i]]);
417:   }
418:   PetscViewerASCIIPrintf(viewer,"\n");
419:   return(0);
420: }

424: static PetscErrorCode SVDValuesView_MATLAB(SVD svd,PetscViewer viewer)
425: {
427:   PetscInt       i;
428:   const char     *name;

431:   PetscObjectGetName((PetscObject)svd,&name);
432:   PetscViewerASCIIPrintf(viewer,"Sigma_%s = [\n",name);
433:   for (i=0;i<svd->nconv;i++) {
434:     PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)svd->sigma[svd->perm[i]]);
435:   }
436:   PetscViewerASCIIPrintf(viewer,"];\n");
437:   return(0);
438: }

442: /*@C
443:    SVDValuesView - Displays the computed singular values in a viewer.

445:    Collective on SVD

447:    Input Parameters:
448: +  svd    - the singular value solver context
449: -  viewer - the viewer

451:    Options Database Key:
452: .  -svd_view_values - print computed singular values

454:    Level: intermediate

456: .seealso: SVDSolve(), SVDVectorsView(), SVDErrorView()
457: @*/
458: PetscErrorCode SVDValuesView(SVD svd,PetscViewer viewer)
459: {
460:   PetscBool         isascii,isdraw;
461:   PetscViewerFormat format;
462:   PetscErrorCode    ierr;

466:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd));
469:   SVDCheckSolved(svd,1);
470:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);
471:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
472:   if (isdraw) {
473:     SVDValuesView_DRAW(svd,viewer);
474:   } else if (isascii) {
475:     PetscViewerGetFormat(viewer,&format);
476:     switch (format) {
477:       case PETSC_VIEWER_DEFAULT:
478:       case PETSC_VIEWER_ASCII_INFO:
479:       case PETSC_VIEWER_ASCII_INFO_DETAIL:
480:         SVDValuesView_ASCII(svd,viewer);
481:         break;
482:       case PETSC_VIEWER_ASCII_MATLAB:
483:         SVDValuesView_MATLAB(svd,viewer);
484:         break;
485:       default:
486:         PetscInfo1(svd,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
487:     }
488:   }
489:   return(0);
490: }

494: /*@
495:    SVDValuesViewFromOptions - Processes command line options to determine if/how
496:    the computed singular values are to be viewed. 

498:    Collective on SVD

500:    Input Parameters:
501: .  svd - the singular value solver context

503:    Level: developer
504: @*/
505: PetscErrorCode SVDValuesViewFromOptions(SVD svd)
506: {
507:   PetscErrorCode    ierr;
508:   PetscViewer       viewer;
509:   PetscBool         flg;
510:   static PetscBool  incall = PETSC_FALSE;
511:   PetscViewerFormat format;

514:   if (incall) return(0);
515:   incall = PETSC_TRUE;
516:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_view_values",&viewer,&format,&flg);
517:   if (flg) {
518:     PetscViewerPushFormat(viewer,format);
519:     SVDValuesView(svd,viewer);
520:     PetscViewerPopFormat(viewer);
521:     PetscViewerDestroy(&viewer);
522:   }
523:   incall = PETSC_FALSE;
524:   return(0);
525: }

529: /*@C
530:    SVDVectorsView - Outputs computed singular vectors to a viewer.

532:    Collective on SVD

534:    Parameter:
535: +  svd    - the singular value solver context
536: -  viewer - the viewer

538:    Options Database Keys:
539: .  -svd_view_vectors - output singular vectors

541:    Level: intermediate

543: .seealso: SVDSolve(), SVDValuesView(), SVDErrorView()
544: @*/
545: PetscErrorCode SVDVectorsView(SVD svd,PetscViewer viewer)
546: {
548:   PetscInt       i,k;
549:   Vec            x;
550: #define NMLEN 30
551:   char           vname[NMLEN];
552:   const char     *ename;

556:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd));
559:   SVDCheckSolved(svd,1);
560:   if (svd->nconv) {
561:     PetscObjectGetName((PetscObject)svd,&ename);
562:     SVDComputeVectors(svd);
563:     for (i=0;i<svd->nconv;i++) {
564:       k = svd->perm[i];
565:       PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);
566:       BVGetColumn(svd->V,k,&x);
567:       PetscObjectSetName((PetscObject)x,vname);
568:       VecView(x,viewer);
569:       BVRestoreColumn(svd->V,k,&x);
570:       PetscSNPrintf(vname,NMLEN,"U%d_%s",(int)i,ename);
571:       BVGetColumn(svd->U,k,&x);
572:       PetscObjectSetName((PetscObject)x,vname);
573:       VecView(x,viewer);
574:       BVRestoreColumn(svd->U,k,&x);
575:     }
576:   }
577:   return(0);
578: }

582: /*@
583:    SVDVectorsViewFromOptions - Processes command line options to determine if/how
584:    the computed singular vectors are to be viewed. 

586:    Collective on SVD

588:    Input Parameters:
589: .  svd - the singular value solver context

591:    Level: developer
592: @*/
593: PetscErrorCode SVDVectorsViewFromOptions(SVD svd)
594: {
595:   PetscErrorCode    ierr;
596:   PetscViewer       viewer;
597:   PetscBool         flg = PETSC_FALSE;
598:   static PetscBool  incall = PETSC_FALSE;
599:   PetscViewerFormat format;

602:   if (incall) return(0);
603:   incall = PETSC_TRUE;
604:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_view_vectors",&viewer,&format,&flg);
605:   if (flg) {
606:     PetscViewerPushFormat(viewer,format);
607:     SVDVectorsView(svd,viewer);
608:     PetscViewerPopFormat(viewer);
609:     PetscViewerDestroy(&viewer);
610:   }
611:   incall = PETSC_FALSE;
612:   return(0);
613: }

slepc-3.7.4/src/svd/interface/svdview.c0000644000175000017500000005244413107004621017352 0ustar jromanjroman/* The SVD routines related to various viewers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "SVDView" /*@C SVDView - Prints the SVD data structure. Collective on SVD Input Parameters: + svd - the singular value solver context - viewer - optional visualization context Options Database Key: . -svd_view - Calls SVDView() at end of SVDSolve() Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner .seealso: STView(), PetscViewerASCIIOpen() @*/ PetscErrorCode SVDView(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii,isshell; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(svd,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)svd,viewer);CHKERRQ(ierr); if (svd->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*svd->ops->view)(svd,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," transpose mode: %s\n",svd->impltrans?"implicit":"explicit");CHKERRQ(ierr); if (svd->which == SVD_LARGEST) { ierr = PetscViewerASCIIPrintf(viewer," selected portion of the spectrum: largest\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," selected portion of the spectrum: smallest\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," number of singular values (nsv): %D\n",svd->nsv);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of column vectors (ncv): %D\n",svd->ncv);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum dimension of projected problem (mpd): %D\n",svd->mpd);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum number of iterations: %D\n",svd->max_it);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," tolerance: %g\n",(double)svd->tol);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," convergence test: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); switch (svd->conv) { case SVD_CONV_ABS: ierr = PetscViewerASCIIPrintf(viewer,"absolute\n");CHKERRQ(ierr);break; case SVD_CONV_REL: ierr = PetscViewerASCIIPrintf(viewer,"relative to the singular value\n");CHKERRQ(ierr);break; case SVD_CONV_USER: ierr = PetscViewerASCIIPrintf(viewer,"user-defined\n");CHKERRQ(ierr);break; } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); if (svd->nini) { ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided initial space: %D\n",PetscAbs(svd->nini));CHKERRQ(ierr); } if (svd->ninil) { ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided initial left space: %D\n",PetscAbs(svd->ninil));CHKERRQ(ierr); } } else { if (svd->ops->view) { ierr = (*svd->ops->view)(svd,viewer);CHKERRQ(ierr); } } ierr = PetscObjectTypeCompareAny((PetscObject)svd,&isshell,SVDCROSS,SVDCYCLIC,"");CHKERRQ(ierr); if (!isshell) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);CHKERRQ(ierr); if (!svd->V) { ierr = SVDGetBV(svd,&svd->V,NULL);CHKERRQ(ierr); } ierr = BVView(svd->V,viewer);CHKERRQ(ierr); if (!svd->ds) { ierr = SVDGetDS(svd,&svd->ds);CHKERRQ(ierr); } ierr = DSView(svd->ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDReasonView" /*@C SVDReasonView - Displays the reason an SVD solve converged or diverged. Collective on SVD Parameter: + svd - the singular value solver context - viewer - the viewer to display the reason Options Database Keys: . -svd_converged_reason - print reason for convergence, and number of iterations Level: intermediate .seealso: SVDSetTolerances(), SVDGetIterationNumber() @*/ PetscErrorCode SVDReasonView(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isAscii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);CHKERRQ(ierr); if (isAscii) { ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)svd)->tablevel);CHKERRQ(ierr); if (svd->reason > 0) { ierr = PetscViewerASCIIPrintf(viewer,"%s SVD solve converged (%D singular triplet%s) due to %s; iterations %D\n",((PetscObject)svd)->prefix?((PetscObject)svd)->prefix:"",svd->nconv,(svd->nconv>1)?"s":"",SVDConvergedReasons[svd->reason],svd->its);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%s SVD solve did not converge due to %s; iterations %D\n",((PetscObject)svd)->prefix?((PetscObject)svd)->prefix:"",SVDConvergedReasons[svd->reason],svd->its);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)svd)->tablevel);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDReasonViewFromOptions" /*@ SVDReasonViewFromOptions - Processes command line options to determine if/how the SVD converged reason is to be viewed. Collective on SVD Input Parameters: . svd - the singular value solver context Level: developer @*/ PetscErrorCode SVDReasonViewFromOptions(SVD svd) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_converged_reason",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = SVDReasonView(svd,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDErrorView_ASCII" static PetscErrorCode SVDErrorView_ASCII(SVD svd,SVDErrorType etype,PetscViewer viewer) { PetscBool errok; PetscReal error,sigma; PetscInt i,j; PetscErrorCode ierr; PetscFunctionBegin; if (svd->nconvnsv) { ierr = PetscViewerASCIIPrintf(viewer," Problem: less than %D singular values converged\n\n",svd->nsv);CHKERRQ(ierr); PetscFunctionReturn(0); } errok = PETSC_TRUE; for (i=0;insv;i++) { ierr = SVDComputeError(svd,i,etype,&error);CHKERRQ(ierr); errok = (errok && error<5.0*svd->tol)? PETSC_TRUE: PETSC_FALSE; } if (!errok) { ierr = PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",svd->nsv);CHKERRQ(ierr); PetscFunctionReturn(0); } ierr = PetscViewerASCIIPrintf(viewer," All requested singular values computed up to the required tolerance:");CHKERRQ(ierr); for (i=0;i<=(svd->nsv-1)/8;i++) { ierr = PetscViewerASCIIPrintf(viewer,"\n ");CHKERRQ(ierr); for (j=0;jnsv-8*i);j++) { ierr = SVDGetSingularTriplet(svd,8*i+j,&sigma,NULL,NULL);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%.5f",(double)sigma);CHKERRQ(ierr); if (8*i+j+1nsv) { ierr = PetscViewerASCIIPrintf(viewer,", ");CHKERRQ(ierr); } } } ierr = PetscViewerASCIIPrintf(viewer,"\n\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDErrorView_DETAIL" static PetscErrorCode SVDErrorView_DETAIL(SVD svd,SVDErrorType etype,PetscViewer viewer) { PetscErrorCode ierr; PetscReal error,sigma; PetscInt i; #define EXLEN 30 char ex[EXLEN],sep[]=" ---------------------- --------------------\n"; PetscFunctionBegin; if (!svd->nconv) PetscFunctionReturn(0); switch (etype) { case SVD_ERROR_ABSOLUTE: ierr = PetscSNPrintf(ex,EXLEN," absolute error");CHKERRQ(ierr); break; case SVD_ERROR_RELATIVE: ierr = PetscSNPrintf(ex,EXLEN," relative error");CHKERRQ(ierr); break; } ierr = PetscViewerASCIIPrintf(viewer,"%s sigma %s\n%s",sep,ex,sep);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = SVDGetSingularTriplet(svd,i,&sigma,NULL,NULL);CHKERRQ(ierr); ierr = SVDComputeError(svd,i,etype,&error);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," % 6f %12g\n",(double)sigma,(double)error);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,sep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDErrorView_MATLAB" static PetscErrorCode SVDErrorView_MATLAB(SVD svd,SVDErrorType etype,PetscViewer viewer) { PetscErrorCode ierr; PetscReal error; PetscInt i; const char *name; PetscFunctionBegin; ierr = PetscObjectGetName((PetscObject)svd,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = SVDComputeError(svd,i,etype,&error);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDErrorView" /*@C SVDErrorView - Displays the errors associated with the computed solution (as well as the singular values). Collective on SVD Input Parameters: + svd - the singular value solver context . etype - error type - viewer - optional visualization context Options Database Key: + -svd_error_absolute - print absolute errors of each singular triplet - -svd_error_relative - print relative errors of each singular triplet Notes: By default, this function checks the error of all singular triplets and prints the singular values if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with singular values and corresponding errors is printed. Level: intermediate .seealso: SVDSolve(), SVDValuesView(), SVDVectorsView() @*/ PetscErrorCode SVDErrorView(SVD svd,SVDErrorType etype,PetscViewer viewer) { PetscBool isascii; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(svd,1,viewer,2); SVDCheckSolved(svd,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (!isascii) PetscFunctionReturn(0); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: ierr = SVDErrorView_ASCII(svd,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = SVDErrorView_DETAIL(svd,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = SVDErrorView_MATLAB(svd,etype,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(svd,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDErrorViewFromOptions" /*@ SVDErrorViewFromOptions - Processes command line options to determine if/how the errors of the computed solution are to be viewed. Collective on SVD Input Parameters: . svd - the singular value solver context Level: developer @*/ PetscErrorCode SVDErrorViewFromOptions(SVD svd) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_error_absolute",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = SVDErrorView(svd,SVD_ERROR_ABSOLUTE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_error_relative",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = SVDErrorView(svd,SVD_ERROR_RELATIVE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDValuesView_DRAW" static PetscErrorCode SVDValuesView_DRAW(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; PetscDraw draw; PetscDrawSP drawsp; PetscReal re,im=0.0; PetscInt i; PetscFunctionBegin; if (!svd->nconv) PetscFunctionReturn(0); ierr = PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed singular values",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);CHKERRQ(ierr); ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); ierr = PetscDrawSPCreate(draw,1,&drawsp);CHKERRQ(ierr); for (i=0;inconv;i++) { re = svd->sigma[svd->perm[i]]; ierr = PetscDrawSPAddPoint(drawsp,&re,&im);CHKERRQ(ierr); } ierr = PetscDrawSPDraw(drawsp,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscDrawSPSave(drawsp);CHKERRQ(ierr); ierr = PetscDrawSPDestroy(&drawsp);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDValuesView_ASCII" static PetscErrorCode SVDValuesView_ASCII(SVD svd,PetscViewer viewer) { PetscInt i; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerASCIIPrintf(viewer,"Singular values = \n");CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = PetscViewerASCIIPrintf(viewer," %.5f\n",(double)svd->sigma[svd->perm[i]]);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDValuesView_MATLAB" static PetscErrorCode SVDValuesView_MATLAB(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; PetscInt i; const char *name; PetscFunctionBegin; ierr = PetscObjectGetName((PetscObject)svd,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"Sigma_%s = [\n",name);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)svd->sigma[svd->perm[i]]);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDValuesView" /*@C SVDValuesView - Displays the computed singular values in a viewer. Collective on SVD Input Parameters: + svd - the singular value solver context - viewer - the viewer Options Database Key: . -svd_view_values - print computed singular values Level: intermediate .seealso: SVDSolve(), SVDVectorsView(), SVDErrorView() @*/ PetscErrorCode SVDValuesView(SVD svd,PetscViewer viewer) { PetscBool isascii,isdraw; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(svd,1,viewer,2); SVDCheckSolved(svd,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isdraw) { ierr = SVDValuesView_DRAW(svd,viewer);CHKERRQ(ierr); } else if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = SVDValuesView_ASCII(svd,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = SVDValuesView_MATLAB(svd,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(svd,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDValuesViewFromOptions" /*@ SVDValuesViewFromOptions - Processes command line options to determine if/how the computed singular values are to be viewed. Collective on SVD Input Parameters: . svd - the singular value solver context Level: developer @*/ PetscErrorCode SVDValuesViewFromOptions(SVD svd) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_view_values",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = SVDValuesView(svd,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDVectorsView" /*@C SVDVectorsView - Outputs computed singular vectors to a viewer. Collective on SVD Parameter: + svd - the singular value solver context - viewer - the viewer Options Database Keys: . -svd_view_vectors - output singular vectors Level: intermediate .seealso: SVDSolve(), SVDValuesView(), SVDErrorView() @*/ PetscErrorCode SVDVectorsView(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; PetscInt i,k; Vec x; #define NMLEN 30 char vname[NMLEN]; const char *ename; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)svd)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(svd,1,viewer,2); SVDCheckSolved(svd,1); if (svd->nconv) { ierr = PetscObjectGetName((PetscObject)svd,&ename);CHKERRQ(ierr); ierr = SVDComputeVectors(svd);CHKERRQ(ierr); for (i=0;inconv;i++) { k = svd->perm[i]; ierr = PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);CHKERRQ(ierr); ierr = BVGetColumn(svd->V,k,&x);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)x,vname);CHKERRQ(ierr); ierr = VecView(x,viewer);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,k,&x);CHKERRQ(ierr); ierr = PetscSNPrintf(vname,NMLEN,"U%d_%s",(int)i,ename);CHKERRQ(ierr); ierr = BVGetColumn(svd->U,k,&x);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)x,vname);CHKERRQ(ierr); ierr = VecView(x,viewer);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->U,k,&x);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDVectorsViewFromOptions" /*@ SVDVectorsViewFromOptions - Processes command line options to determine if/how the computed singular vectors are to be viewed. Collective on SVD Input Parameters: . svd - the singular value solver context Level: developer @*/ PetscErrorCode SVDVectorsViewFromOptions(SVD svd) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg = PETSC_FALSE; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)svd),((PetscObject)svd)->prefix,"-svd_view_vectors",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = SVDVectorsView(svd,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } slepc-3.7.4/src/svd/interface/svdregis.c0000644000175000017500000000367513107004621017513 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ PETSC_EXTERN PetscErrorCode SVDCreate_Cross(SVD); PETSC_EXTERN PetscErrorCode SVDCreate_Cyclic(SVD); PETSC_EXTERN PetscErrorCode SVDCreate_LAPACK(SVD); PETSC_EXTERN PetscErrorCode SVDCreate_Lanczos(SVD); PETSC_EXTERN PetscErrorCode SVDCreate_TRLanczos(SVD); #undef __FUNCT__ #define __FUNCT__ "SVDRegisterAll" /*@C SVDRegisterAll - Registers all the singular value solvers in the SVD package. Not Collective Level: advanced .seealso: SVDRegister() @*/ PetscErrorCode SVDRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (SVDRegisterAllCalled) PetscFunctionReturn(0); SVDRegisterAllCalled = PETSC_TRUE; ierr = SVDRegister(SVDCROSS,SVDCreate_Cross);CHKERRQ(ierr); ierr = SVDRegister(SVDCYCLIC,SVDCreate_Cyclic);CHKERRQ(ierr); ierr = SVDRegister(SVDLAPACK,SVDCreate_LAPACK);CHKERRQ(ierr); ierr = SVDRegister(SVDLANCZOS,SVDCreate_Lanczos);CHKERRQ(ierr); ierr = SVDRegister(SVDTRLANCZOS,SVDCreate_TRLanczos);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/svd/interface/ftn-custom/0000755000175000017500000000000013107004621017605 5ustar jromanjromanslepc-3.7.4/src/svd/interface/ftn-custom/makefile0000644000175000017500000000221113107004621021301 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zsvdf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsvd LOCDIR = src/svd/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/interface/ftn-custom/zsvdf.c0000644000175000017500000003255113107004621021113 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define svdmonitorall_ SVDMONITORALL #define svdmonitorlg_ SVDMONITORLG #define svdmonitorlgall_ SVDMONITORLGALL #define svdmonitorconverged_ SVDMONITORCONVERGED #define svdmonitorfirst_ SVDMONITORFIRST #define svdview_ SVDVIEW #define svderrorview_ SVDERRORVIEW #define svdreasonview_ SVDREASONVIEW #define svdvaluesview_ SVDVALUESVIEW #define svdvectorsview_ SVDVECTORSVIEW #define svdsettype_ SVDSETTYPE #define svdgettype_ SVDGETTYPE #define svdmonitorset_ SVDMONITORSET #define svdsetoptionsprefix_ SVDSETOPTIONSPREFIX #define svdappendoptionsprefix_ SVDAPPENDOPTIONSPREFIX #define svdgetoptionsprefix_ SVDGETOPTIONSPREFIX #define svdconvergedabsolute_ SVDCONVERGEDABSOLUTE #define svdconvergedrelative_ SVDCONVERGEDRELATIVE #define svdsetconvergencetestfunction_ SVDSETCONVERGENCETESTFUNCTION #define svdsetstoppingtestfunction_ SVDSETSTOPPINGTESTFUNCTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define svdmonitorall_ svdmonitorall #define svdmonitorlg_ svdmonitorlg #define svdmonitorlgall_ svdmonitorlgall #define svdmonitorconverged_ svdmonitorconverged #define svdmonitorfirst_ svdmonitorfirst #define svdview_ svdview #define svderrorview_ svderrorview #define svdreasonview_ svdreasonview #define svdvaluesview_ svdvaluesview #define svdvectorsview_ svdvectorsview #define svdsettype_ svdsettype #define svdgettype_ svdgettype #define svdmonitorset_ svdmonitorset #define svdsetoptionsprefix_ svdsetoptionsprefix #define svdappendoptionsprefix_ svdappendoptionsprefix #define svdgetoptionsprefix_ svdgetoptionsprefix #define svdconvergedabsolute_ svdconvergedabsolute #define svdconvergedrelative_ svdconvergedrelative #define svdsetconvergencetestfunction_ svdsetconvergencetestfunction #define svdsetstoppingtestfunction_ svdsetstoppingtestfunction #endif /* These are not usually called from Fortran but allow Fortran users to transparently set these monitors from .F code, hence no STDCALL */ PETSC_EXTERN void svdmonitorall_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = SVDMonitorAll(*svd,*it,*nconv,sigma,errest,*nest,*ctx); } PETSC_EXTERN void svdmonitorconverged_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr) { *ierr = SVDMonitorConverged(*svd,*it,*nconv,sigma,errest,*nest,*ctx); } PETSC_EXTERN void svdmonitorfirst_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = SVDMonitorFirst(*svd,*it,*nconv,sigma,errest,*nest,*ctx); } PETSC_EXTERN void svdmonitorlg_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = SVDMonitorLG(*svd,*it,*nconv,sigma,errest,*nest,ctx); } PETSC_EXTERN void svdmonitorlgall_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = SVDMonitorLGAll(*svd,*it,*nconv,sigma,errest,*nest,ctx); } static struct { PetscFortranCallbackId monitor; PetscFortranCallbackId monitordestroy; PetscFortranCallbackId convergence; PetscFortranCallbackId convdestroy; PetscFortranCallbackId stopping; PetscFortranCallbackId stopdestroy; } _cb; /* These are not extern C because they are passed into non-extern C user level functions */ #undef __FUNCT__ #define __FUNCT__ "ourmonitor" static PetscErrorCode ourmonitor(SVD svd,PetscInt i,PetscInt nc,PetscReal *sigma,PetscReal *d,PetscInt l,void* ctx) { PetscObjectUseFortranCallback(svd,_cb.monitor,(SVD*,PetscInt*,PetscInt*,PetscReal*,PetscReal*,PetscInt*,void*,PetscErrorCode*),(&svd,&i,&nc,sigma,d,&l,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourdestroy" static PetscErrorCode ourdestroy(void** ctx) { SVD svd = (SVD)*ctx; PetscObjectUseFortranCallback(svd,_cb.monitordestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvergence" static PetscErrorCode ourconvergence(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx) { PetscObjectUseFortranCallback(svd,_cb.convergence,(SVD*,PetscReal*,PetscReal*,PetscReal*,void*,PetscErrorCode*),(&svd,&sigma,&res,errest,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvdestroy" static PetscErrorCode ourconvdestroy(void *ctx) { SVD svd = (SVD)ctx; PetscObjectUseFortranCallback(svd,_cb.convdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopping" static PetscErrorCode ourstopping(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx) { PetscObjectUseFortranCallback(svd,_cb.stopping,(SVD*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,SVDConvergedReason*,void*,PetscErrorCode*),(&svd,&its,&max_it,&nconv,&nsv,reason,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopdestroy" static PetscErrorCode ourstopdestroy(void *ctx) { SVD svd = (SVD)ctx; PetscObjectUseFortranCallback(svd,_cb.stopdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } PETSC_EXTERN void PETSC_STDCALL svdview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = SVDView(*svd,v); } PETSC_EXTERN void PETSC_STDCALL svdreasonview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = SVDReasonView(*svd,v); } PETSC_EXTERN void PETSC_STDCALL svderrorview_(SVD *svd,SVDErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = SVDErrorView(*svd,*etype,v); } PETSC_EXTERN void PETSC_STDCALL svdvaluesview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = SVDValuesView(*svd,v); } PETSC_EXTERN void PETSC_STDCALL svdvectorsview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = SVDVectorsView(*svd,v); } PETSC_EXTERN void PETSC_STDCALL svdsettype_(SVD *svd,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = SVDSetType(*svd,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL svdgettype_(SVD *svd,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { SVDType tname; *ierr = SVDGetType(*svd,&tname);if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL svdmonitorset_(SVD *svd,void (PETSC_STDCALL *monitor)(SVD*,PetscInt*,PetscInt*,PetscReal*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(mctx); CHKFORTRANNULLFUNCTION(monitordestroy); if ((PetscVoidFunction)monitor == (PetscVoidFunction)svdmonitorall_) { *ierr = SVDMonitorSet(*svd,(PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*))SVDMonitorAll,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)svdmonitorconverged_) { *ierr = SVDMonitorSet(*svd,(PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*))SVDMonitorConverged,*(SlepcConvMonitor*)mctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)svdmonitorfirst_) { *ierr = SVDMonitorSet(*svd,(PetscErrorCode (*)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*))SVDMonitorFirst,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)svdmonitorlg_) { *ierr = SVDMonitorSet(*svd,SVDMonitorLG,0,0); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)svdmonitorlgall_) { *ierr = SVDMonitorSet(*svd,SVDMonitorLGAll,0,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*svd,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitor,(PetscVoidFunction)monitor,mctx); if (*ierr) return; if (!monitordestroy) { *ierr = SVDMonitorSet(*svd,ourmonitor,*svd,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*svd,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitordestroy,(PetscVoidFunction)monitordestroy,mctx); if (*ierr) return; *ierr = SVDMonitorSet(*svd,ourmonitor,*svd,ourdestroy); } } } PETSC_EXTERN void PETSC_STDCALL svdsetoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = SVDSetOptionsPrefix(*svd,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL svdappendoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = SVDAppendOptionsPrefix(*svd,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL svdgetoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = SVDGetOptionsPrefix(*svd,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL svdconvergedabsolute_(SVD *svd,PetscReal *sigma,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = SVDConvergedAbsolute(*svd,*sigma,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL svdconvergedrelative_(SVD *svd,PetscReal *sigma,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = SVDConvergedRelative(*svd,*sigma,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL svdsetconvergencetestfunction_(SVD *svd,void (PETSC_STDCALL *func)(SVD*,PetscReal*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)svdconvergedabsolute_) { *ierr = SVDSetConvergenceTest(*svd,SVD_CONV_ABS); } else if ((PetscVoidFunction)func == (PetscVoidFunction)svdconvergedrelative_) { *ierr = SVDSetConvergenceTest(*svd,SVD_CONV_REL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*svd,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convergence,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = SVDSetConvergenceTestFunction(*svd,ourconvergence,*svd,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*svd,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = SVDSetConvergenceTestFunction(*svd,ourconvergence,*svd,ourconvdestroy); } } } PETSC_EXTERN void PETSC_STDCALL svdstoppingbasic_(SVD *svd,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nsv,SVDConvergedReason *reason,void *ctx,PetscErrorCode *ierr) { *ierr = SVDStoppingBasic(*svd,*its,*max_it,*nconv,*nsv,reason,ctx); } PETSC_EXTERN void PETSC_STDCALL svdsetstoppingtestfunction_(SVD *svd,void (PETSC_STDCALL *func)(SVD*,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)svdstoppingbasic_) { *ierr = SVDSetStoppingTest(*svd,SVD_STOP_BASIC); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*svd,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopping,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = SVDSetStoppingTestFunction(*svd,ourstopping,*svd,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*svd,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = SVDSetStoppingTestFunction(*svd,ourstopping,*svd,ourstopdestroy); } } } slepc-3.7.4/src/svd/interface/svdsolve.c0000644000175000017500000003067013107004621017525 0ustar jromanjroman/* SVD routines related to the solution process. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #undef __FUNCT__ #define __FUNCT__ "SVDComputeVectors" PetscErrorCode SVDComputeVectors(SVD svd) { PetscErrorCode ierr; Vec tl,uj,vj; PetscInt j,oldsize; PetscReal norm; PetscFunctionBegin; SVDCheckSolved(svd,1); switch (svd->state) { case SVD_STATE_SOLVED: /* generate left singular vectors on U */ if (!svd->U) { ierr = SVDGetBV(svd,NULL,&svd->U);CHKERRQ(ierr); } ierr = BVGetSizes(svd->U,NULL,NULL,&oldsize);CHKERRQ(ierr); if (!oldsize) { if (!((PetscObject)(svd->U))->type_name) { ierr = BVSetType(svd->U,BVSVEC);CHKERRQ(ierr); } ierr = SVDMatCreateVecs(svd,NULL,&tl);CHKERRQ(ierr); ierr = BVSetSizesFromVec(svd->U,tl,svd->ncv);CHKERRQ(ierr); ierr = VecDestroy(&tl);CHKERRQ(ierr); } for (j=0;jnconv;j++) { ierr = BVGetColumn(svd->V,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(svd->U,j,&uj);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_FALSE,vj,uj);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->U,j,&uj);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(svd->U,j,NULL,&norm,NULL);CHKERRQ(ierr); ierr = BVScaleColumn(svd->U,j,1.0/norm);CHKERRQ(ierr); } break; default: break; } svd->state = SVD_STATE_VECTORS; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSolve" /*@ SVDSolve - Solves the singular value problem. Collective on SVD Input Parameter: . svd - singular value solver context obtained from SVDCreate() Options Database Keys: + -svd_view - print information about the solver used . -svd_view_mat binary - save the matrix to the default binary viewer . -svd_view_vectors binary - save the computed singular vectors to the default binary viewer . -svd_view_values - print computed singular values . -svd_converged_reason - print reason for convergence, and number of iterations . -svd_error_absolute - print absolute errors of each singular triplet - -svd_error_relative - print relative errors of each singular triplet Level: beginner .seealso: SVDCreate(), SVDSetUp(), SVDDestroy() @*/ PetscErrorCode SVDSolve(SVD svd) { PetscErrorCode ierr; PetscInt i,*workperm; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); if (svd->state>=SVD_STATE_SOLVED) PetscFunctionReturn(0); ierr = PetscLogEventBegin(SVD_Solve,svd,0,0,0);CHKERRQ(ierr); /* call setup */ ierr = SVDSetUp(svd);CHKERRQ(ierr); svd->its = 0; svd->nconv = 0; for (i=0;incv;i++) { svd->sigma[i] = 0.0; svd->errest[i] = 0.0; svd->perm[i] = i; } ierr = SVDViewFromOptions(svd,NULL,"-svd_view_pre");CHKERRQ(ierr); ierr = (*svd->ops->solve)(svd);CHKERRQ(ierr); svd->state = (svd->leftbasis)? SVD_STATE_VECTORS: SVD_STATE_SOLVED; /* sort singular triplets */ if (svd->which == SVD_SMALLEST) { ierr = PetscSortRealWithPermutation(svd->nconv,svd->sigma,svd->perm);CHKERRQ(ierr); } else { ierr = PetscMalloc1(svd->nconv,&workperm);CHKERRQ(ierr); for (i=0;inconv;i++) workperm[i] = i; ierr = PetscSortRealWithPermutation(svd->nconv,svd->sigma,workperm);CHKERRQ(ierr); for (i=0;inconv;i++) svd->perm[i] = workperm[svd->nconv-i-1]; ierr = PetscFree(workperm);CHKERRQ(ierr); } ierr = PetscLogEventEnd(SVD_Solve,svd,0,0,0);CHKERRQ(ierr); /* various viewers */ ierr = SVDViewFromOptions(svd,NULL,"-svd_view");CHKERRQ(ierr); ierr = SVDReasonViewFromOptions(svd);CHKERRQ(ierr); ierr = SVDErrorViewFromOptions(svd);CHKERRQ(ierr); ierr = SVDValuesViewFromOptions(svd);CHKERRQ(ierr); ierr = SVDVectorsViewFromOptions(svd);CHKERRQ(ierr); ierr = MatViewFromOptions(svd->OP,(PetscObject)svd,"-svd_view_mat");CHKERRQ(ierr); /* Remove the initial subspaces */ svd->nini = 0; svd->ninil = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetIterationNumber" /*@ SVDGetIterationNumber - Gets the current iteration number. If the call to SVDSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If SVDSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call SVDGetConvergedReason() to determine if the solver converged or failed and why. .seealso: SVDGetConvergedReason(), SVDSetTolerances() @*/ PetscErrorCode SVDGetIterationNumber(SVD svd,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidIntPointer(its,2); *its = svd->its; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetConvergedReason" /*@ SVDGetConvergedReason - Gets the reason why the SVDSolve() iteration was stopped. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . reason - negative value indicates diverged, positive value converged (see SVDConvergedReason) Notes: Possible values for reason are + SVD_CONVERGED_TOL - converged up to tolerance . SVD_CONVERGED_USER - converged due to a user-defined condition . SVD_DIVERGED_ITS - required more than max_it iterations to reach convergence - SVD_DIVERGED_BREAKDOWN - generic breakdown in method Can only be called after the call to SVDSolve() is complete. Level: intermediate .seealso: SVDSetTolerances(), SVDSolve(), SVDConvergedReason @*/ PetscErrorCode SVDGetConvergedReason(SVD svd,SVDConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidIntPointer(reason,2); SVDCheckSolved(svd,1); *reason = svd->reason; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetConverged" /*@ SVDGetConverged - Gets the number of converged singular values. Not Collective Input Parameter: . svd - the singular value solver context Output Parameter: . nconv - number of converged singular values Note: This function should be called after SVDSolve() has finished. Level: beginner @*/ PetscErrorCode SVDGetConverged(SVD svd,PetscInt *nconv) { PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidIntPointer(nconv,2); SVDCheckSolved(svd,1); *nconv = svd->nconv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDGetSingularTriplet" /*@ SVDGetSingularTriplet - Gets the i-th triplet of the singular value decomposition as computed by SVDSolve(). The solution consists in the singular value and its left and right singular vectors. Not Collective, but vectors are shared by all processors that share the SVD Input Parameters: + svd - singular value solver context - i - index of the solution Output Parameters: + sigma - singular value . u - left singular vector - v - right singular vector Note: Both U or V can be NULL if singular vectors are not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs(). The index i should be a value between 0 and nconv-1 (see SVDGetConverged()). Singular triplets are indexed according to the ordering criterion established with SVDSetWhichSingularTriplets(). Level: beginner .seealso: SVDSolve(), SVDGetConverged(), SVDSetWhichSingularTriplets() @*/ PetscErrorCode SVDGetSingularTriplet(SVD svd,PetscInt i,PetscReal *sigma,Vec u,Vec v) { PetscErrorCode ierr; PetscInt M,N; Vec w; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveInt(svd,i,2); SVDCheckSolved(svd,1); if (u) { PetscValidHeaderSpecific(u,VEC_CLASSID,4); PetscCheckSameComm(svd,1,u,4); } if (v) { PetscValidHeaderSpecific(v,VEC_CLASSID,5); PetscCheckSameComm(svd,1,v,5); } if (i<0 || i>=svd->nconv) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); *sigma = svd->sigma[svd->perm[i]]; ierr = MatGetSize(svd->OP,&M,&N);CHKERRQ(ierr); if (MU,svd->perm[i],u);CHKERRQ(ierr); } if (v) { ierr = BVCopyVec(svd->V,svd->perm[i],v);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDComputeResidualNorms_Private" /* SVDComputeResidualNorms_Private - Computes the norms of the left and right residuals associated with the i-th computed singular triplet. @*/ static PetscErrorCode SVDComputeResidualNorms_Private(SVD svd,PetscInt i,PetscReal *norm1,PetscReal *norm2) { PetscErrorCode ierr; Vec u,v,x = NULL,y = NULL; PetscReal sigma; PetscInt M,N; PetscFunctionBegin; ierr = MatCreateVecs(svd->OP,&v,&u);CHKERRQ(ierr); ierr = SVDGetSingularTriplet(svd,i,&sigma,u,v);CHKERRQ(ierr); /* norm1 = ||A*v-sigma*u||_2 */ if (norm1) { ierr = VecDuplicate(u,&x);CHKERRQ(ierr); ierr = MatMult(svd->OP,v,x);CHKERRQ(ierr); ierr = VecAXPY(x,-sigma,u);CHKERRQ(ierr); ierr = VecNorm(x,NORM_2,norm1);CHKERRQ(ierr); } /* norm2 = ||A^T*u-sigma*v||_2 */ if (norm2) { ierr = VecDuplicate(v,&y);CHKERRQ(ierr); if (svd->A && svd->AT) { ierr = MatGetSize(svd->OP,&M,&N);CHKERRQ(ierr); if (MA,u,y);CHKERRQ(ierr); } else { ierr = MatMult(svd->AT,u,y);CHKERRQ(ierr); } } else { #if defined(PETSC_USE_COMPLEX) ierr = MatMultHermitianTranspose(svd->OP,u,y);CHKERRQ(ierr); #else ierr = MatMultTranspose(svd->OP,u,y);CHKERRQ(ierr); #endif } ierr = VecAXPY(y,-sigma,v);CHKERRQ(ierr); ierr = VecNorm(y,NORM_2,norm2);CHKERRQ(ierr); } ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&u);CHKERRQ(ierr); ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDComputeError" /*@ SVDComputeError - Computes the error (based on the residual norm) associated with the i-th singular triplet. Collective on SVD Input Parameter: + svd - the singular value solver context . i - the solution index - type - the type of error to compute Output Parameter: . error - the error Notes: The error can be computed in various ways, all of them based on the residual norm obtained as sqrt(n1^2+n2^2) with n1 = ||A*v-sigma*u||_2 and n2 = ||A^T*u-sigma*v||_2, where sigma is the singular value, u is the left singular vector and v is the right singular vector. Level: beginner .seealso: SVDErrorType, SVDSolve() @*/ PetscErrorCode SVDComputeError(SVD svd,PetscInt i,SVDErrorType type,PetscReal *error) { PetscErrorCode ierr; PetscReal sigma,norm1,norm2; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveInt(svd,i,2); PetscValidLogicalCollectiveEnum(svd,type,3); PetscValidPointer(error,4); SVDCheckSolved(svd,1); ierr = SVDGetSingularTriplet(svd,i,&sigma,NULL,NULL);CHKERRQ(ierr); ierr = SVDComputeResidualNorms_Private(svd,i,&norm1,&norm2);CHKERRQ(ierr); *error = PetscSqrtReal(norm1*norm1+norm2*norm2); switch (type) { case SVD_ERROR_ABSOLUTE: break; case SVD_ERROR_RELATIVE: *error /= sigma; break; default: SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type"); } PetscFunctionReturn(0); } slepc-3.7.4/src/svd/examples/0000755000175000017500000000000013107004621015364 5ustar jromanjromanslepc-3.7.4/src/svd/examples/makefile0000644000175000017500000000201713107004621017064 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/svd/examples/ DIRS = tests tutorials include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/examples/makefile.html0000644000175000017500000000442413107004621020033 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/svd/examples/
DIRS     = tests tutorials

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/svd/examples/tutorials/0000755000175000017500000000000013107004621017412 5ustar jromanjromanslepc-3.7.4/src/svd/examples/tutorials/makefile0000644000175000017500000000543013107004621021114 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/svd/examples/tutorials/ EXAMPLESC = ex8.c ex14.c ex15.c EXAMPLESF = ex15f.F MANSEC = SVD TESTEXAMPLES_C = ex8.PETSc runex8_1 ex8.rm TESTEXAMPLES_C_NOCOMPLEX = ex14.PETSc runex14_1 ex14.rm TESTEXAMPLES_FORTRAN = include ${SLEPC_DIR}/lib/slepc/conf/slepc_common ex8: ex8.o chkopts -${CLINKER} -o ex8 ex8.o ${SLEPC_SVD_LIB} ${RM} ex8.o ex14: ex14.o chkopts -${CLINKER} -o ex14 ex14.o ${SLEPC_SVD_LIB} ${RM} ex14.o ex15: ex15.o chkopts -${CLINKER} -o ex15 ex15.o ${SLEPC_SVD_LIB} ${RM} ex15.o ex15f: ex15f.o chkopts -${FLINKER} -o ex15f ex15f.o ${SLEPC_SVD_LIB} ${RM} ex15f.o #------------------------------------------------------------------------------------ DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices runex8_1: -@${MPIEXEC} -n 1 ./ex8 > ex8_1.tmp 2>&1; \ if (${DIFF} output/ex8_1.out ex8_1.tmp) then true; \ else echo "Possible problem with ex8_1, diffs above"; fi; \ ${RM} -f ex8_1.tmp runex14_1: -@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ echo "Skipping ex14 test"; \ else \ ${MPIEXEC} -n 1 ./ex14 -file ${DATAPATH}/rdb200.petsc -svd_nsv 4 -terse > ex14_1.tmp 2>&1; \ if (${DIFF} output/ex14_1.out ex14_1.tmp) then true; \ else echo "Possible problem with ex14_1, diffs above"; fi; \ ${RM} -f ex14_1.tmp; \ fi runex15_1: -@${MPIEXEC} -n 1 ./ex15 > ex15_1.tmp 2>&1; \ if (${DIFF} output/ex15_1.out ex15_1.tmp) then true; \ else echo "Possible problem with ex15_1, diffs above"; fi; \ ${RM} -f ex15_1.tmp runex15f_1: -@${MPIEXEC} -n 1 ./ex15f > ex15f_1.tmp 2>&1; \ if (${DIFF} output/ex15f_1.out ex15f_1.tmp) then true; \ else echo "Possible problem with ex15f_1, diffs above"; fi; \ ${RM} -f ex15f_1.tmp slepc-3.7.4/src/svd/examples/tutorials/ex15f.F0000644000175000017500000001461113107004621020454 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./ex15f [-help] [-n ] [-mu ] [all SLEPc options] ! ! Description: Singular value decomposition of the Lauchli matrix. ! ! The command line options are: ! -n , where = matrix dimension. ! -mu , where = subdiagonal value. ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! A operator matrix ! svd singular value solver context Mat A SVD svd SVDType tname PetscReal tol, error, sigma, mu PetscInt n, i, j, Istart, Iend PetscInt nsv, maxit, its, nconv PetscMPIInt rank PetscErrorCode ierr PetscBool flg PetscScalar one ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 100 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-n',n,flg,ierr) mu = PETSC_SQRT_MACHINE_EPSILON call PetscOptionsGetReal(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-mu',mu,flg,ierr) if (rank .eq. 0) then write(*,100) n, mu endif 100 format (/'Lauchli SVD, n =',I3,', mu=',E12.4,' (Fortran)') ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Build the Lauchli matrix ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call MatCreate(PETSC_COMM_WORLD,A,ierr) call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n+1,n,ierr) call MatSetFromOptions(A,ierr) call MatSetUp(A,ierr) call MatGetOwnershipRange(A,Istart,Iend,ierr) one = 1.0 do i=Istart,Iend-1 if (i .eq. 0) then do j=0,n-1 call MatSetValue(A,i,j,one,INSERT_VALUES,ierr) end do else call MatSetValue(A,i,i-1,mu,INSERT_VALUES,ierr) end if enddo call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create the singular value solver and display info ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Create singular value solver context call SVDCreate(PETSC_COMM_WORLD,svd,ierr) ! ** Set operator call SVDSetOperator(svd,A,ierr) ! ** Use thick-restart Lanczos as default solver call SVDSetType(svd,SVDTRLANCZOS,ierr) ! ** Set solver parameters at runtime call SVDSetFromOptions(svd,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the singular value system ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SVDSolve(svd,ierr) call SVDGetIterationNumber(svd,its,ierr) if (rank .eq. 0) then write(*,110) its endif 110 format (/' Number of iterations of the method:',I4) ! ** Optional: Get some information from the solver and display it call SVDGetType(svd,tname,ierr) if (rank .eq. 0) then write(*,120) tname endif 120 format (' Solution method: ',A) call SVDGetDimensions(svd,nsv,PETSC_NULL_INTEGER, & & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,130) nsv endif 130 format (' Number of requested singular values:',I2) call SVDGetTolerances(svd,tol,maxit,ierr) if (rank .eq. 0) then write(*,140) tol, maxit endif 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Get number of converged singular triplets call SVDGetConverged(svd,nconv,ierr) if (rank .eq. 0) then write(*,150) nconv endif 150 format (' Number of converged approximate singular triplets:',I2/) ! ** Display singular values and relative errors if (nconv.gt.0) then if (rank .eq. 0) then write(*,*) ' sigma relative error' write(*,*) ' ----------------- ------------------' endif do i=0,nconv-1 ! ** Get converged singular triplet: i-th singular value is stored in sigma call SVDGetSingularTriplet(svd,i,sigma,PETSC_NULL_OBJECT, & & PETSC_NULL_OBJECT,ierr) ! ** Compute the relative error associated to each eigenpair call SVDComputeError(svd,i,SVD_ERROR_RELATIVE,error,ierr) if (rank .eq. 0) then write(*,160) sigma, error endif 160 format (1P,' ',E12.4,' ',E12.4) enddo if (rank .eq. 0) then write(*,*) endif endif ! ** Free work space call SVDDestroy(svd,ierr) call MatDestroy(A,ierr) call SlepcFinalize(ierr) end slepc-3.7.4/src/svd/examples/tutorials/ex14.c0000644000175000017500000001173213107004621020343 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves a singular value problem with the matrix loaded from a file.\n" "This example works for both real and complex numbers.\n\n" "The command line options are:\n" " -file , where = matrix file in PETSc binary form.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ SVD svd; /* singular value problem solver context */ SVDType type; PetscReal tol; PetscInt nsv,maxit,its; char filename[PETSC_MAX_PATH_LEN]; PetscViewer viewer; PetscBool flg,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load the operator matrix that defines the singular value problem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSingular value problem stored in file.\n\n");CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-file",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name with the -file option"); #if defined(PETSC_USE_COMPLEX) ierr = PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrix from a binary file...\n");CHKERRQ(ierr); #else ierr = PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrix from a binary file...\n");CHKERRQ(ierr); #endif ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatLoad(A,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the singular value solver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create singular value solver context */ ierr = SVDCreate(PETSC_COMM_WORLD,&svd);CHKERRQ(ierr); /* Set operator */ ierr = SVDSetOperator(svd,A);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = SVDSetFromOptions(svd);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the singular value system - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = SVDSolve(svd);CHKERRQ(ierr); ierr = SVDGetIterationNumber(svd,&its);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = SVDGetType(svd,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = SVDGetDimensions(svd,&nsv,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested singular values: %D\n",nsv);CHKERRQ(ierr); ierr = SVDGetTolerances(svd,&tol,&maxit);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = SVDErrorView(svd,SVD_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = SVDReasonView(svd,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = SVDErrorView(svd,SVD_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); } ierr = SVDDestroy(&svd);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/svd/examples/tutorials/ex14.c.html0000644000175000017500000002527013107004621021310 0ustar jromanjroman
Actual source code: ex14.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves a singular value problem with the matrix loaded from a file.\n"
 23:   "This example works for both real and complex numbers.\n\n"
 24:   "The command line options are:\n"
 25:   "  -file <filename>, where <filename> = matrix file in PETSc binary form.\n\n";

 27: #include <slepcsvd.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A;               /* operator matrix */
 34:   SVD            svd;             /* singular value problem solver context */
 35:   SVDType        type;
 36:   PetscReal      tol;
 37:   PetscInt       nsv,maxit,its;
 38:   char           filename[PETSC_MAX_PATH_LEN];
 39:   PetscViewer    viewer;
 40:   PetscBool      flg,terse;

 43:   SlepcInitialize(&argc,&argv,(char*)0,help);

 45:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 46:         Load the operator matrix that defines the singular value problem
 47:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 49:   PetscPrintf(PETSC_COMM_WORLD,"\nSingular value problem stored in file.\n\n");
 50:   PetscOptionsGetString(NULL,NULL,"-file",filename,PETSC_MAX_PATH_LEN,&flg);
 51:   if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name with the -file option");

 53: #if defined(PETSC_USE_COMPLEX)
 54:   PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrix from a binary file...\n");
 55: #else
 56:   PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrix from a binary file...\n");
 57: #endif
 58:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 59:   MatCreate(PETSC_COMM_WORLD,&A);
 60:   MatSetFromOptions(A);
 61:   MatLoad(A,viewer);
 62:   PetscViewerDestroy(&viewer);

 64:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 65:                 Create the singular value solver and set various options
 66:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 68:   /*
 69:      Create singular value solver context
 70:   */
 71:   SVDCreate(PETSC_COMM_WORLD,&svd);

 73:   /*
 74:      Set operator
 75:   */
 76:   SVDSetOperator(svd,A);

 78:   /*
 79:      Set solver parameters at runtime
 80:   */
 81:   SVDSetFromOptions(svd);

 83:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 84:                       Solve the singular value system
 85:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 87:   SVDSolve(svd);
 88:   SVDGetIterationNumber(svd,&its);
 89:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);

 91:   /*
 92:      Optional: Get some information from the solver and display it
 93:   */
 94:   SVDGetType(svd,&type);
 95:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
 96:   SVDGetDimensions(svd,&nsv,NULL,NULL);
 97:   PetscPrintf(PETSC_COMM_WORLD," Number of requested singular values: %D\n",nsv);
 98:   SVDGetTolerances(svd,&tol,&maxit);
 99:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

101:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102:                     Display solution and clean up
103:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

105:   /* show detailed info unless -terse option is given by user */
106:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
107:   if (terse) {
108:     SVDErrorView(svd,SVD_ERROR_RELATIVE,NULL);
109:   } else {
110:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
111:     SVDReasonView(svd,PETSC_VIEWER_STDOUT_WORLD);
112:     SVDErrorView(svd,SVD_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
113:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
114:   }
115:   SVDDestroy(&svd);
116:   MatDestroy(&A);
117:   SlepcFinalize();
118:   return ierr;
119: }
slepc-3.7.4/src/svd/examples/tutorials/makefile.html0000644000175000017500000001174413107004621022064 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/svd/examples/tutorials/
EXAMPLESC  = ex8.c ex14.c ex15.c
EXAMPLESF  = ex15f.F
MANSEC     = SVD

TESTEXAMPLES_C           = ex8.PETSc runex8_1 ex8.rm
TESTEXAMPLES_C_NOCOMPLEX = ex14.PETSc runex14_1 ex14.rm
TESTEXAMPLES_FORTRAN     =

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

ex8: ex8.o chkopts
	-${CLINKER} -o ex8 ex8.o ${SLEPC_SVD_LIB}
	${RM} ex8.o

ex14: ex14.o chkopts
	-${CLINKER} -o ex14 ex14.o ${SLEPC_SVD_LIB}
	${RM} ex14.o

ex15: ex15.o chkopts
	-${CLINKER} -o ex15 ex15.o ${SLEPC_SVD_LIB}
	${RM} ex15.o

ex15f: ex15f.o chkopts
	-${FLINKER} -o ex15f ex15f.o ${SLEPC_SVD_LIB}
	${RM} ex15f.o

#------------------------------------------------------------------------------------
DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices

runex8_1:
	-@${MPIEXEC} -n 1 ./ex8 > ex8_1.tmp 2>&1; \
	   if (${DIFF} output/ex8_1.out ex8_1.tmp) then true; \
	   else echo "Possible problem with ex8_1, diffs above"; fi; \
	   ${RM} -f ex8_1.tmp

runex14_1:
	-@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
           echo "Skipping ex14 test"; \
         else \
	   ${MPIEXEC} -n 1 ./ex14 -file ${DATAPATH}/rdb200.petsc -svd_nsv 4 -terse > ex14_1.tmp 2>&1;	  \
	   if (${DIFF} output/ex14_1.out ex14_1.tmp) then true; \
	   else echo "Possible problem with ex14_1, diffs above"; fi; \
	   ${RM} -f ex14_1.tmp; \
         fi

runex15_1:
	-@${MPIEXEC} -n 1 ./ex15 > ex15_1.tmp 2>&1; \
	   if (${DIFF} output/ex15_1.out ex15_1.tmp) then true; \
	   else echo "Possible problem with ex15_1, diffs above"; fi; \
	   ${RM} -f ex15_1.tmp

runex15f_1:
	-@${MPIEXEC} -n 1 ./ex15f > ex15f_1.tmp 2>&1; \
	   if (${DIFF} output/ex15f_1.out ex15f_1.tmp) then true; \
	   else echo "Possible problem with ex15f_1, diffs above"; fi; \
	   ${RM} -f ex15f_1.tmp

slepc-3.7.4/src/svd/examples/tutorials/ex15f.F.html0000644000175000017500000003302713107004621021421 0ustar jromanjroman
Actual source code: ex15f.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./ex15f [-help] [-n <n>] [-mu <mu>] [all SLEPc options] 
 21: !
 22: !  Description: Singular value decomposition of the Lauchli matrix. 
 23: !
 24: !  The command line options are:
 25: !    -n <n>, where <n> = matrix dimension.
 26: !    -mu <mu>, where <mu> = subdiagonal value.
 27: !
 28: ! ---------------------------------------------------------------------- 
 29: !
 30:       program main
 31:       implicit none

 33: #include <petsc/finclude/petscsys.h>
 34: #include <petsc/finclude/petscvec.h>
 35: #include <petsc/finclude/petscmat.h>
 36: #include <slepc/finclude/slepcsys.h>
 37: #include <slepc/finclude/slepcsvd.h>

 39: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 40: !     Declarations
 41: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 42: !
 43: !  Variables:
 44: !     A     operator matrix
 45: !     svd   singular value solver context

 47:       Mat            A
 48:       SVD            svd
 49:       SVDType        tname
 50:       PetscReal      tol, error, sigma, mu
 51:       PetscInt       n, i, j, Istart, Iend
 52:       PetscInt       nsv, maxit, its, nconv
 53:       PetscMPIInt    rank
 54:       PetscErrorCode ierr
 55:       PetscBool      flg
 56:       PetscScalar    one

 58: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 59: !     Beginning of program
 60: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 62:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 63:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 64:       n = 100
 65:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 66:      &                        '-n',n,flg,ierr)
 67:       mu = PETSC_SQRT_MACHINE_EPSILON
 68:       call PetscOptionsGetReal(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 69:      &                        '-mu',mu,flg,ierr)

 71:       if (rank .eq. 0) then
 72:         write(*,100) n, mu
 73:       endif
 74:  100  format (/'Lauchli SVD, n =',I3,', mu=',E12.4,' (Fortran)')

 76: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 77: !     Build the Lauchli matrix
 78: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 80:       call MatCreate(PETSC_COMM_WORLD,A,ierr)
 81:       call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n+1,n,ierr)
 82:       call MatSetFromOptions(A,ierr)
 83:       call MatSetUp(A,ierr)

 85:       call MatGetOwnershipRange(A,Istart,Iend,ierr)
 86:       one = 1.0
 87:       do i=Istart,Iend-1
 88:         if (i .eq. 0) then
 89:           do j=0,n-1
 90:             call MatSetValue(A,i,j,one,INSERT_VALUES,ierr)
 91:           end do
 92:         else
 93:           call MatSetValue(A,i,i-1,mu,INSERT_VALUES,ierr)
 94:         end if
 95:       enddo

 97:       call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
 98:       call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)

100: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
101: !     Create the singular value solver and display info
102: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

104: !     ** Create singular value solver context
105:       call SVDCreate(PETSC_COMM_WORLD,svd,ierr)

107: !     ** Set operator
108:       call SVDSetOperator(svd,A,ierr)

110: !     ** Use thick-restart Lanczos as default solver
111:       call SVDSetType(svd,SVDTRLANCZOS,ierr)

113: !     ** Set solver parameters at runtime
114:       call SVDSetFromOptions(svd,ierr)

116: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
117: !     Solve the singular value system
118: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

120:       call SVDSolve(svd,ierr) 
121:       call SVDGetIterationNumber(svd,its,ierr)
122:       if (rank .eq. 0) then
123:         write(*,110) its
124:       endif
125:  110  format (/' Number of iterations of the method:',I4)

127: !     ** Optional: Get some information from the solver and display it
128:       call SVDGetType(svd,tname,ierr)
129:       if (rank .eq. 0) then
130:         write(*,120) tname
131:       endif
132:  120  format (' Solution method: ',A)
133:       call SVDGetDimensions(svd,nsv,PETSC_NULL_INTEGER,                 &
134:      &                      PETSC_NULL_INTEGER,ierr)
135:       if (rank .eq. 0) then
136:         write(*,130) nsv
137:       endif
138:  130  format (' Number of requested singular values:',I2)
139:       call SVDGetTolerances(svd,tol,maxit,ierr)
140:       if (rank .eq. 0) then
141:         write(*,140) tol, maxit
142:       endif
143:  140  format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)

145: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
146: !     Display solution and clean up
147: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

149: !     ** Get number of converged singular triplets
150:       call SVDGetConverged(svd,nconv,ierr)
151:       if (rank .eq. 0) then
152:         write(*,150) nconv
153:       endif
154:  150  format (' Number of converged approximate singular triplets:',I2/)

156: !     ** Display singular values and relative errors
157:       if (nconv.gt.0) then
158:         if (rank .eq. 0) then
159:           write(*,*) '       sigma          relative error'
160:           write(*,*) ' ----------------- ------------------'
161:         endif
162:         do i=0,nconv-1
163: !         ** Get converged singular triplet: i-th singular value is stored in sigma
164:           call SVDGetSingularTriplet(svd,i,sigma,PETSC_NULL_OBJECT,     &
165:      &         PETSC_NULL_OBJECT,ierr)

167: !         ** Compute the relative error associated to each eigenpair
168:           call SVDComputeError(svd,i,SVD_ERROR_RELATIVE,error,ierr)
169:           if (rank .eq. 0) then
170:             write(*,160) sigma, error
171:           endif
172:  160      format (1P,'   ',E12.4,'       ',E12.4)

174:         enddo
175:         if (rank .eq. 0) then
176:           write(*,*)
177:         endif
178:       endif

180: !     ** Free work space
181:       call SVDDestroy(svd,ierr)
182:       call MatDestroy(A,ierr)

184:       call SlepcFinalize(ierr)
185:       end

slepc-3.7.4/src/svd/examples/tutorials/ex8.c0000644000175000017500000001354413107004621020271 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Estimates the 2-norm condition number of a matrix A, that is, the ratio of the largest to the smallest singular values of A. " "The matrix is a Grcar matrix.\n\n" "The command line options are:\n" " -n , where = matrix dimension.\n\n"; #include /* This example computes the singular values of an nxn Grcar matrix, which is a nonsymmetric Toeplitz matrix: | 1 1 1 1 | | -1 1 1 1 1 | | -1 1 1 1 1 | | . . . . . | A = | . . . . . | | -1 1 1 1 1 | | -1 1 1 1 | | -1 1 1 | | -1 1 | */ #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* Grcar matrix */ SVD svd; /* singular value solver context */ PetscInt N=30,Istart,Iend,i,col[5],nconv1,nconv2; PetscScalar value[] = { -1, 1, 1, 1, 1 }; PetscReal sigma_1,sigma_n; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nEstimate the condition number of a Grcar matrix, n=%D\n\n",N);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Generate the matrix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i 0) { ierr = SVDGetSingularTriplet(svd,0,&sigma_1,NULL,NULL);CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD," Unable to compute large singular value!\n\n");CHKERRQ(ierr); } /* Request a singular value from the other end of the spectrum */ ierr = SVDSetWhichSingularTriplets(svd,SVD_SMALLEST);CHKERRQ(ierr); ierr = SVDSolve(svd);CHKERRQ(ierr); /* Get number of converged eigenpairs */ ierr = SVDGetConverged(svd,&nconv2);CHKERRQ(ierr); /* Get converged singular values: smallest singular value is stored in sigma_n. As before, we are not interested in the singular vectors */ if (nconv2 > 0) { ierr = SVDGetSingularTriplet(svd,0,&sigma_n,NULL,NULL);CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD," Unable to compute small singular value!\n\n");CHKERRQ(ierr); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (nconv1 > 0 && nconv2 > 0) { ierr = PetscPrintf(PETSC_COMM_WORLD," Computed singular values: sigma_1=%6f, sigma_n=%6f\n",(double)sigma_1,(double)sigma_n);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Estimated condition number: sigma_1/sigma_n=%6f\n\n",(double)(sigma_1/sigma_n));CHKERRQ(ierr); } /* Free work space */ ierr = SVDDestroy(&svd);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/svd/examples/tutorials/output/0000755000175000017500000000000013107004621020752 5ustar jromanjromanslepc-3.7.4/src/svd/examples/tutorials/output/ex15f_1.out0000644000175000017500000000137013107004621022654 0ustar jromanjroman Lauchli SVD, n =100, mu= 0.1000E-06 (Fortran) Number of iterations of the method: 1 Solution method: trlanczos Number of requested singular values: 1 Stopping condition: tol=1.0000E-08, maxit= 100 Number of converged approximate singular triplets:10 sigma relative error ----------------- ------------------ 1.0000E+01 1.7363E-15 1.0000E-07 6.1583E-09 1.0000E-07 8.6736E-10 1.0000E-07 2.9490E-09 1.0000E-07 3.4781E-09 1.0000E-07 1.6653E-09 1.0000E-07 5.5511E-10 1.0000E-07 9.7145E-10 1.0000E-07 3.4694E-10 1.0000E-07 1.3878E-08 slepc-3.7.4/src/svd/examples/tutorials/output/ex14_1.out0000644000175000017500000000053113107004621022503 0ustar jromanjroman Singular value problem stored in file. Reading REAL matrix from a binary file... Number of iterations of the method: 3 Solution method: cross Number of requested singular values: 4 Stopping condition: tol=1e-08, maxit=100 All requested singular values computed up to the required tolerance: 35.00752, 34.10419, 33.20131, 32.68111 slepc-3.7.4/src/svd/examples/tutorials/output/ex15_1.out0000644000175000017500000000131613107004621022506 0ustar jromanjroman Lauchli singular value decomposition, (101 x 100) mu=1.49012e-08 Number of iterations of the method: 1 Solution method: trlanczos Number of requested singular values: 1 Stopping condition: tol=1e-08, maxit=100 Number of converged approximate singular triplets: 10 sigma relative error --------------------- ------------------ 10.000000 1.5877e-15 0.000000 4.65661e-09 0.000000 2.6077e-08 0.000000 3.72529e-09 0.000000 1.11759e-08 0.000000 1.49012e-08 0.000000 2.34693e-07 0.000000 1.30385e-08 0.000000 5.58794e-09 0.000000 1.21072e-08 slepc-3.7.4/src/svd/examples/tutorials/output/ex8_1.out0000644000175000017500000000025513107004621022431 0ustar jromanjroman Estimate the condition number of a Grcar matrix, n=30 Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 slepc-3.7.4/src/svd/examples/tutorials/index.html0000644000175000017500000000344613107004621021416 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

ex8.c: Estimates the 2-norm condition number of a matrix A, that is, the ratio of the largest to the smallest singular values of A
ex14.c: Solves a singular value problem with the matrix loaded from a file
ex15.c: Singular value decomposition of the Lauchli matrix
makefile
slepc-3.7.4/src/svd/examples/tutorials/ex15.c0000644000175000017500000001337613107004621020352 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Singular value decomposition of the Lauchli matrix.\n" "The command line options are:\n" " -n , where = matrix dimension.\n" " -mu , where = subdiagonal value.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ Vec u,v; /* left and right singular vectors */ SVD svd; /* singular value problem solver context */ SVDType type; PetscReal error,tol,sigma,mu=PETSC_SQRT_MACHINE_EPSILON; PetscInt n=100,i,j,Istart,Iend,nsv,maxit,its,nconv; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-mu",&mu,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nLauchli singular value decomposition, (%D x %D) mu=%g\n\n",n+1,n,(double)mu);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Build the Lauchli matrix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n+1,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { /* Display singular values and relative errors */ ierr = PetscPrintf(PETSC_COMM_WORLD, " sigma relative error\n" " --------------------- ------------------\n");CHKERRQ(ierr); for (i=0;iActual source code: ex15.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Singular value decomposition of the Lauchli matrix.\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = matrix dimension.\n"
 25:   "  -mu <mu>, where <mu> = subdiagonal value.\n\n";

 27: #include <slepcsvd.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A;               /* operator matrix */
 34:   Vec            u,v;             /* left and right singular vectors */
 35:   SVD            svd;             /* singular value problem solver context */
 36:   SVDType        type;
 37:   PetscReal      error,tol,sigma,mu=PETSC_SQRT_MACHINE_EPSILON;
 38:   PetscInt       n=100,i,j,Istart,Iend,nsv,maxit,its,nconv;

 41:   SlepcInitialize(&argc,&argv,(char*)0,help);

 43:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 44:   PetscOptionsGetReal(NULL,NULL,"-mu",&mu,NULL);
 45:   PetscPrintf(PETSC_COMM_WORLD,"\nLauchli singular value decomposition, (%D x %D) mu=%g\n\n",n+1,n,(double)mu);

 47:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 48:                           Build the Lauchli matrix
 49:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 51:   MatCreate(PETSC_COMM_WORLD,&A);
 52:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n+1,n);
 53:   MatSetFromOptions(A);
 54:   MatSetUp(A);

 56:   MatGetOwnershipRange(A,&Istart,&Iend);
 57:   for (i=Istart;i<Iend;i++) {
 58:     if (i == 0) {
 59:       for (j=0;j<n;j++) {
 60:         MatSetValue(A,0,j,1.0,INSERT_VALUES);
 61:       }
 62:     } else {
 63:       MatSetValue(A,i,i-1,mu,INSERT_VALUES);
 64:     }
 65:   }

 67:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 68:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 69:   MatCreateVecs(A,&v,&u);

 71:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 72:           Create the singular value solver and set various options
 73:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 75:   /*
 76:      Create singular value solver context
 77:   */
 78:   SVDCreate(PETSC_COMM_WORLD,&svd);

 80:   /*
 81:      Set operator
 82:   */
 83:   SVDSetOperator(svd,A);

 85:   /*
 86:      Use thick-restart Lanczos as default solver
 87:   */
 88:   SVDSetType(svd,SVDTRLANCZOS);

 90:   /*
 91:      Set solver parameters at runtime
 92:   */
 93:   SVDSetFromOptions(svd);

 95:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 96:                       Solve the singular value system
 97:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 99:   SVDSolve(svd);
100:   SVDGetIterationNumber(svd,&its);
101:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);

103:   /*
104:      Optional: Get some information from the solver and display it
105:   */
106:   SVDGetType(svd,&type);
107:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
108:   SVDGetDimensions(svd,&nsv,NULL,NULL);
109:   PetscPrintf(PETSC_COMM_WORLD," Number of requested singular values: %D\n",nsv);
110:   SVDGetTolerances(svd,&tol,&maxit);
111:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

113:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114:                     Display solution and clean up
115:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

117:   /*
118:      Get number of converged singular triplets
119:   */
120:   SVDGetConverged(svd,&nconv);
121:   PetscPrintf(PETSC_COMM_WORLD," Number of converged approximate singular triplets: %D\n\n",nconv);

123:   if (nconv>0) {
124:     /*
125:        Display singular values and relative errors
126:     */
127:     PetscPrintf(PETSC_COMM_WORLD,
128:          "          sigma           relative error\n"
129:          "  --------------------- ------------------\n");
130:     for (i=0;i<nconv;i++) {
131:       /*
132:          Get converged singular triplets: i-th singular value is stored in sigma
133:       */
134:       SVDGetSingularTriplet(svd,i,&sigma,u,v);

136:       /*
137:          Compute the error associated to each singular triplet
138:       */
139:       SVDComputeError(svd,i,SVD_ERROR_RELATIVE,&error);

141:       PetscPrintf(PETSC_COMM_WORLD,"       % 6f      ",(double)sigma);
142:       PetscPrintf(PETSC_COMM_WORLD," % 12g\n",(double)error);
143:     }
144:     PetscPrintf(PETSC_COMM_WORLD,"\n");
145:   }

147:   /*
148:      Free work space
149:   */
150:   SVDDestroy(&svd);
151:   MatDestroy(&A);
152:   VecDestroy(&u);
153:   VecDestroy(&v);
154:   SlepcFinalize();
155:   return ierr;
156: }
slepc-3.7.4/src/svd/examples/tutorials/ex8.c.html0000644000175000017500000003273713107004621021241 0ustar jromanjroman
Actual source code: ex8.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Estimates the 2-norm condition number of a matrix A, that is, the ratio of the largest to the smallest singular values of A. "
 23:   "The matrix is a Grcar matrix.\n\n"
 24:   "The command line options are:\n"
 25:   "  -n <n>, where <n> = matrix dimension.\n\n";

 27: #include <slepcsvd.h>

 29: /*
 30:    This example computes the singular values of an nxn Grcar matrix,
 31:    which is a nonsymmetric Toeplitz matrix:

 33:               |  1  1  1  1               |
 34:               | -1  1  1  1  1            |
 35:               |    -1  1  1  1  1         |
 36:               |       .  .  .  .  .       |
 37:           A = |          .  .  .  .  .    |
 38:               |            -1  1  1  1  1 |
 39:               |               -1  1  1  1 |
 40:               |                  -1  1  1 |
 41:               |                     -1  1 |

 43:  */

 47: int main(int argc,char **argv)
 48: {
 49:   Mat            A;               /* Grcar matrix */
 50:   SVD            svd;             /* singular value solver context */
 51:   PetscInt       N=30,Istart,Iend,i,col[5],nconv1,nconv2;
 52:   PetscScalar    value[] = { -1, 1, 1, 1, 1 };
 53:   PetscReal      sigma_1,sigma_n;

 56:   SlepcInitialize(&argc,&argv,(char*)0,help);

 58:   PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);
 59:   PetscPrintf(PETSC_COMM_WORLD,"\nEstimate the condition number of a Grcar matrix, n=%D\n\n",N);

 61:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 62:         Generate the matrix
 63:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 65:   MatCreate(PETSC_COMM_WORLD,&A);
 66:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 67:   MatSetFromOptions(A);
 68:   MatSetUp(A);

 70:   MatGetOwnershipRange(A,&Istart,&Iend);
 71:   for (i=Istart;i<Iend;i++) {
 72:     col[0]=i-1; col[1]=i; col[2]=i+1; col[3]=i+2; col[4]=i+3;
 73:     if (i==0) {
 74:       MatSetValues(A,1,&i,PetscMin(4,N-i),col+1,value+1,INSERT_VALUES);
 75:     } else {
 76:       MatSetValues(A,1,&i,PetscMin(5,N-i+1),col,value,INSERT_VALUES);
 77:     }
 78:   }

 80:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 81:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 83:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 84:              Create the singular value solver and set the solution method
 85:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 87:   /*
 88:      Create singular value context
 89:   */
 90:   SVDCreate(PETSC_COMM_WORLD,&svd);

 92:   /*
 93:      Set operator
 94:   */
 95:   SVDSetOperator(svd,A);

 97:   /*
 98:      Set solver parameters at runtime
 99:   */
100:   SVDSetFromOptions(svd);
101:   SVDSetDimensions(svd,1,PETSC_DEFAULT,PETSC_DEFAULT);

103:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104:                       Solve the singular value problem
105:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

107:   /*
108:      First request a singular value from one end of the spectrum
109:   */
110:   SVDSetWhichSingularTriplets(svd,SVD_LARGEST);
111:   SVDSolve(svd);
112:   /*
113:      Get number of converged singular values
114:   */
115:   SVDGetConverged(svd,&nconv1);
116:   /*
117:      Get converged singular values: largest singular value is stored in sigma_1.
118:      In this example, we are not interested in the singular vectors
119:   */
120:   if (nconv1 > 0) {
121:     SVDGetSingularTriplet(svd,0,&sigma_1,NULL,NULL);
122:   } else {
123:     PetscPrintf(PETSC_COMM_WORLD," Unable to compute large singular value!\n\n");
124:   }

126:   /*
127:      Request a singular value from the other end of the spectrum
128:   */
129:   SVDSetWhichSingularTriplets(svd,SVD_SMALLEST);
130:   SVDSolve(svd);
131:   /*
132:      Get number of converged eigenpairs
133:   */
134:   SVDGetConverged(svd,&nconv2);
135:   /*
136:      Get converged singular values: smallest singular value is stored in sigma_n.
137:      As before, we are not interested in the singular vectors
138:   */
139:   if (nconv2 > 0) {
140:     SVDGetSingularTriplet(svd,0,&sigma_n,NULL,NULL);
141:   } else {
142:     PetscPrintf(PETSC_COMM_WORLD," Unable to compute small singular value!\n\n");
143:   }

145:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
146:                     Display solution and clean up
147:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
148:   if (nconv1 > 0 && nconv2 > 0) {
149:     PetscPrintf(PETSC_COMM_WORLD," Computed singular values: sigma_1=%6f, sigma_n=%6f\n",(double)sigma_1,(double)sigma_n);
150:     PetscPrintf(PETSC_COMM_WORLD," Estimated condition number: sigma_1/sigma_n=%6f\n\n",(double)(sigma_1/sigma_n));
151:   }

153:   /*
154:      Free work space
155:   */
156:   SVDDestroy(&svd);
157:   MatDestroy(&A);
158:   SlepcFinalize();
159:   return ierr;
160: }

slepc-3.7.4/src/svd/examples/index.html0000644000175000017500000000126213107004621017362 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
tutorials/
makefile
slepc-3.7.4/src/svd/examples/tests/0000755000175000017500000000000013107004621016526 5ustar jromanjromanslepc-3.7.4/src/svd/examples/tests/makefile0000644000175000017500000000721313107004621020231 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/svd/examples/tests/ EXAMPLESC = test1.c test2.c test3.c EXAMPLESF = MANSEC = SVD TESTS = test1 test2 test3 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \ test3.PETSc runtest3_1 test3.rm TESTEXAMPLES_C_NOF128= test2.PETSc runtest2_1 test2.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_SVD_LIB} ${RM} test1.o test2: test2.o chkopts -${CLINKER} -o test2 test2.o ${SLEPC_SVD_LIB} ${RM} test2.o test3: test3.o chkopts -${CLINKER} -o test3 test3.o ${SLEPC_SVD_LIB} ${RM} test3.o #------------------------------------------------------------------------------------ SVD = lanczos lapack trlanczos SVDEPS = cross cyclic EPS = krylovschur arnoldi lanczos gd jd runtest1_1: -@touch test1_1.tmp; \ for svd in ${SVDEPS} ${SVD}; do \ ${MPIEXEC} -n 1 ./test1 -type $$svd >> test1_1.tmp 2>&1; \ done; \ for svd in ${SVDEPS}; do \ for eps in ${EPS}; do \ ${MPIEXEC} -n 1 ./test1 -type $$svd -epstype $$eps >> test1_1.tmp 2>&1; \ done; \ done; \ if (${DIFF} output/test1_1.out test1_1.tmp) then true; \ else echo "Possible problem with test1_1, diffs above"; fi; \ ${RM} -f test1_1.tmp runtest2_1: -@touch test2_1.tmp; \ for svd in ${SVDEPS} ${SVD}; do \ echo "svd type $$svd" >> test2_1.tmp; \ ${MPIEXEC} -n 1 ./test2 -svd_type $$svd -svd_nsv 7 >> test2_1.tmp 2>&1; \ done; \ if (${GREP} USE_COMPLEX ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ [ x${SAVE_OUTPUT} = xyes ] && cp test2_1.tmp output/test2_1_complex.out; \ if (${DIFF} output/test2_1_complex.out test2_1.tmp) then true; \ else echo "Possible problem with test2_1, diffs above"; fi; \ else \ [ x${SAVE_OUTPUT} = xyes ] && cp test2_1.tmp output/test2_1.out; \ if (${DIFF} output/test2_1.out test2_1.tmp) then true; \ else echo "Possible problem with test2_1, diffs above"; fi; \ fi; \ ${RM} -f test2_1.tmp; runtest3_1: -@touch test3_1.tmp; \ for svd in ${SVDEPS} ${SVD}; do \ echo "svd type $$svd" >> test3_1.tmp; \ ${MPIEXEC} -n 1 ./test3 -svd_type $$svd -svd_nsv 4 >> test3_1.tmp 2>&1; \ done; \ echo "svd type lanczos one-sided" >> test3_1.tmp; \ ${MPIEXEC} -n 1 ./test3 -svd_type $$svd -svd_nsv 4 -svd_type lanczos -svd_lanczos_oneside >> test3_1.tmp 2>&1; \ echo "svd type trlanczos one-sided" >> test3_1.tmp; \ ${MPIEXEC} -n 1 ./test3 -svd_type $$svd -svd_nsv 4 -svd_type trlanczos -svd_trlanczos_oneside >> test3_1.tmp 2>&1; \ [ x${SAVE_OUTPUT} = xyes ] && cp test3_1.tmp output/test3_1.out; \ if (${DIFF} output/test3_1.out test3_1.tmp) then true; \ else echo "Possible problem with test3_1, diffs above"; fi; \ ${RM} -f test3_1.tmp slepc-3.7.4/src/svd/examples/tests/test1.c.html0000644000175000017500000003722413107004621020705 0ustar jromanjroman

Actual source code: test1.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test the solution of a SVD without calling SVDSetFromOptions (based on ex8.c).\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = matrix dimension.\n"
 25:   "  -type <svd_type> = svd type to test.\n\n";

 27: #include <slepcsvd.h>

 29: /*
 30:    This example computes the singular values of an nxn Grcar matrix,
 31:    which is a nonsymmetric Toeplitz matrix:

 33:               |  1  1  1  1               |
 34:               | -1  1  1  1  1            |
 35:               |    -1  1  1  1  1         |
 36:               |       .  .  .  .  .       |
 37:           A = |          .  .  .  .  .    |
 38:               |            -1  1  1  1  1 |
 39:               |               -1  1  1  1 |
 40:               |                  -1  1  1 |
 41:               |                     -1  1 |

 43:  */

 47: int main(int argc,char **argv)
 48: {
 49:   Mat            A;               /* Grcar matrix */
 50:   SVD            svd;             /* singular value solver context */
 51:   PetscInt       N=30,Istart,Iend,i,col[5],nconv1,nconv2;
 52:   PetscScalar    value[] = { -1, 1, 1, 1, 1 };
 53:   PetscReal      sigma_1,sigma_n;
 54:   char           svdtype[30] = "cross",epstype[30] = "";
 55:   PetscBool      flg;
 56:   EPS            eps;

 59:   SlepcInitialize(&argc,&argv,(char*)0,help);

 61:   PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);
 62:   PetscOptionsGetString(NULL,NULL,"-type",svdtype,30,NULL);
 63:   PetscOptionsGetString(NULL,NULL,"-epstype",epstype,30,&flg);
 64:   PetscPrintf(PETSC_COMM_WORLD,"\nEstimate the condition number of a Grcar matrix, n=%D",N);
 65:   PetscPrintf(PETSC_COMM_WORLD,"\nSVD type: %s",svdtype);
 66:   if (flg) {
 67:     PetscPrintf(PETSC_COMM_WORLD,"\nEPS type: %s",epstype);
 68:   }
 69:   PetscPrintf(PETSC_COMM_WORLD,"\n\n");

 71:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 72:         Generate the matrix
 73:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 75:   MatCreate(PETSC_COMM_WORLD,&A);
 76:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 77:   MatSetFromOptions(A);
 78:   MatSetUp(A);

 80:   MatGetOwnershipRange(A,&Istart,&Iend);
 81:   for (i=Istart;i<Iend;i++) {
 82:     col[0]=i-1; col[1]=i; col[2]=i+1; col[3]=i+2; col[4]=i+3;
 83:     if (i==0) {
 84:       MatSetValues(A,1,&i,4,col+1,value+1,INSERT_VALUES);
 85:     } else {
 86:       MatSetValues(A,1,&i,PetscMin(5,N-i+1),col,value,INSERT_VALUES);
 87:     }
 88:   }

 90:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 91:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 93:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 94:              Create the singular value solver and set the solution method
 95:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 97:   /*
 98:      Create singular value context
 99:   */
100:   SVDCreate(PETSC_COMM_WORLD,&svd);

102:   /*
103:      Set operator
104:   */
105:   SVDSetOperator(svd,A);

107:   /*
108:      Set solver parameters at runtime
109:   */
110:   SVDSetType(svd,svdtype);
111:   if (flg) {
112:     PetscObjectTypeCompare((PetscObject)svd,SVDCROSS,&flg);
113:     if (flg) {
114:       SVDCrossGetEPS(svd,&eps);
115:       EPSSetType(eps,epstype);
116:     }
117:     PetscObjectTypeCompare((PetscObject)svd,SVDCYCLIC,&flg);
118:     if (flg) {
119:       SVDCyclicGetEPS(svd,&eps);
120:       EPSSetType(eps,epstype);
121:     }
122:   }
123:   SVDSetDimensions(svd,1,PETSC_DEFAULT,PETSC_DEFAULT);
124:   SVDSetTolerances(svd,1e-6,1000);

126:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
127:                       Solve the eigensystem
128:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

130:   /*
131:      First request an eigenvalue from one end of the spectrum
132:   */
133:   SVDSetWhichSingularTriplets(svd,SVD_LARGEST);
134:   SVDSolve(svd);
135:   /*
136:      Get number of converged singular values
137:   */
138:   SVDGetConverged(svd,&nconv1);
139:   /*
140:      Get converged singular values: largest singular value is stored in sigma_1.
141:      In this example, we are not interested in the singular vectors
142:   */
143:   if (nconv1 > 0) {
144:     SVDGetSingularTriplet(svd,0,&sigma_1,NULL,NULL);
145:   } else {
146:     PetscPrintf(PETSC_COMM_WORLD," Unable to compute large singular value!\n\n");
147:   }

149:   /*
150:      Request an eigenvalue from the other end of the spectrum
151:   */
152:   SVDSetWhichSingularTriplets(svd,SVD_SMALLEST);
153:   SVDSolve(svd);
154:   /*
155:      Get number of converged eigenpairs
156:   */
157:   SVDGetConverged(svd,&nconv2);
158:   /*
159:      Get converged singular values: smallest singular value is stored in sigma_n.
160:      As before, we are not interested in the singular vectors
161:   */
162:   if (nconv2 > 0) {
163:     SVDGetSingularTriplet(svd,0,&sigma_n,NULL,NULL);
164:   } else {
165:     PetscPrintf(PETSC_COMM_WORLD," Unable to compute small singular value!\n\n");
166:   }

168:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
169:                     Display solution and clean up
170:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
171:   if (nconv1 > 0 && nconv2 > 0) {
172:     PetscPrintf(PETSC_COMM_WORLD," Computed singular values: sigma_1=%6f, sigma_n=%6f\n",(double)sigma_1,(double)sigma_n);
173:     PetscPrintf(PETSC_COMM_WORLD," Estimated condition number: sigma_1/sigma_n=%6f\n\n",(double)(sigma_1/sigma_n));
174:   }

176:   /*
177:      Free work space
178:   */
179:   SVDDestroy(&svd);
180:   MatDestroy(&A);
181:   SlepcFinalize();
182:   return ierr;
183: }

slepc-3.7.4/src/svd/examples/tests/makefile.html0000644000175000017500000001470613107004621021201 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/svd/examples/tests/
EXAMPLESC  = test1.c test2.c test3.c
EXAMPLESF  =
MANSEC     = SVD
TESTS      = test1 test2 test3

TESTEXAMPLES_C       = test1.PETSc runtest1_1 test1.rm \
                       test3.PETSc runtest3_1 test3.rm
TESTEXAMPLES_C_NOF128= test2.PETSc runtest2_1 test2.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_SVD_LIB}
	${RM} test1.o

test2: test2.o chkopts
	-${CLINKER} -o test2 test2.o ${SLEPC_SVD_LIB}
	${RM} test2.o

test3: test3.o chkopts
	-${CLINKER} -o test3 test3.o ${SLEPC_SVD_LIB}
	${RM} test3.o

#------------------------------------------------------------------------------------
SVD = lanczos lapack trlanczos
SVDEPS = cross cyclic
EPS = krylovschur arnoldi lanczos gd jd

runtest1_1:
	-@touch test1_1.tmp; \
	for svd in ${SVDEPS} ${SVD}; do \
	   ${MPIEXEC} -n 1 ./test1 -type $$svd >> test1_1.tmp 2>&1; \
	done; \
	for svd in ${SVDEPS}; do \
	   for eps in ${EPS}; do \
	      ${MPIEXEC} -n 1 ./test1 -type $$svd -epstype $$eps >> test1_1.tmp 2>&1; \
           done; \
	done; \
	if (${DIFF} output/test1_1.out test1_1.tmp) then true; \
	else echo "Possible problem with test1_1, diffs above"; fi; \
	${RM} -f test1_1.tmp

runtest2_1:
	-@touch test2_1.tmp; \
	for svd in ${SVDEPS} ${SVD}; do \
	   echo "svd type $$svd" >> test2_1.tmp; \
	   ${MPIEXEC} -n 1 ./test2 -svd_type $$svd -svd_nsv 7 >> test2_1.tmp 2>&1;    \
	done; \
	if (${GREP} USE_COMPLEX ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
	  [ x${SAVE_OUTPUT} = xyes ] && cp test2_1.tmp output/test2_1_complex.out; \
	  if (${DIFF} output/test2_1_complex.out test2_1.tmp) then true; \
	  else echo "Possible problem with test2_1, diffs above"; fi; \
	else \
	  [ x${SAVE_OUTPUT} = xyes ] && cp test2_1.tmp output/test2_1.out; \
	  if (${DIFF} output/test2_1.out test2_1.tmp) then true; \
	  else echo "Possible problem with test2_1, diffs above"; fi; \
	fi; \
	${RM} -f test2_1.tmp;

runtest3_1:
	-@touch test3_1.tmp; \
	for svd in ${SVDEPS} ${SVD}; do \
	   echo "svd type $$svd" >> test3_1.tmp; \
	   ${MPIEXEC} -n 1 ./test3 -svd_type $$svd -svd_nsv 4 >> test3_1.tmp 2>&1; \
	done; \
	echo "svd type lanczos one-sided" >> test3_1.tmp; \
	${MPIEXEC} -n 1 ./test3 -svd_type $$svd -svd_nsv 4 -svd_type lanczos -svd_lanczos_oneside >> test3_1.tmp 2>&1; \
	echo "svd type trlanczos one-sided" >> test3_1.tmp; \
	${MPIEXEC} -n 1 ./test3 -svd_type $$svd -svd_nsv 4 -svd_type trlanczos -svd_trlanczos_oneside >> test3_1.tmp 2>&1; \
	[ x${SAVE_OUTPUT} = xyes ] && cp test3_1.tmp output/test3_1.out; \
	if (${DIFF} output/test3_1.out test3_1.tmp) then true; \
	else echo "Possible problem with test3_1, diffs above"; fi; \
	${RM} -f test3_1.tmp

slepc-3.7.4/src/svd/examples/tests/test1.c0000644000175000017500000001537713107004621017747 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test the solution of a SVD without calling SVDSetFromOptions (based on ex8.c).\n\n" "The command line options are:\n" " -n , where = matrix dimension.\n" " -type = svd type to test.\n\n"; #include /* This example computes the singular values of an nxn Grcar matrix, which is a nonsymmetric Toeplitz matrix: | 1 1 1 1 | | -1 1 1 1 1 | | -1 1 1 1 1 | | . . . . . | A = | . . . . . | | -1 1 1 1 1 | | -1 1 1 1 | | -1 1 1 | | -1 1 | */ #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* Grcar matrix */ SVD svd; /* singular value solver context */ PetscInt N=30,Istart,Iend,i,col[5],nconv1,nconv2; PetscScalar value[] = { -1, 1, 1, 1, 1 }; PetscReal sigma_1,sigma_n; char svdtype[30] = "cross",epstype[30] = ""; PetscBool flg; EPS eps; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-type",svdtype,30,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-epstype",epstype,30,&flg);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nEstimate the condition number of a Grcar matrix, n=%D",N);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSVD type: %s",svdtype);CHKERRQ(ierr); if (flg) { ierr = PetscPrintf(PETSC_COMM_WORLD,"\nEPS type: %s",epstype);CHKERRQ(ierr); } ierr = PetscPrintf(PETSC_COMM_WORLD,"\n\n");CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Generate the matrix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i 0) { ierr = SVDGetSingularTriplet(svd,0,&sigma_1,NULL,NULL);CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD," Unable to compute large singular value!\n\n");CHKERRQ(ierr); } /* Request an eigenvalue from the other end of the spectrum */ ierr = SVDSetWhichSingularTriplets(svd,SVD_SMALLEST);CHKERRQ(ierr); ierr = SVDSolve(svd);CHKERRQ(ierr); /* Get number of converged eigenpairs */ ierr = SVDGetConverged(svd,&nconv2);CHKERRQ(ierr); /* Get converged singular values: smallest singular value is stored in sigma_n. As before, we are not interested in the singular vectors */ if (nconv2 > 0) { ierr = SVDGetSingularTriplet(svd,0,&sigma_n,NULL,NULL);CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD," Unable to compute small singular value!\n\n");CHKERRQ(ierr); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (nconv1 > 0 && nconv2 > 0) { ierr = PetscPrintf(PETSC_COMM_WORLD," Computed singular values: sigma_1=%6f, sigma_n=%6f\n",(double)sigma_1,(double)sigma_n);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Estimated condition number: sigma_1/sigma_n=%6f\n\n",(double)(sigma_1/sigma_n));CHKERRQ(ierr); } /* Free work space */ ierr = SVDDestroy(&svd);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/svd/examples/tests/test3.c0000644000175000017500000001013313107004621017732 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test SVD with user-provided initial vectors.\n\n" "The command line options are:\n" " -n , where = row dimension.\n" " -m , where = column dimension.\n\n"; #include /* This example computes the singular values of a rectangular nxm Grcar matrix: | 1 1 1 1 | | -1 1 1 1 1 | | -1 1 1 1 1 | A = | . . . . . | | . . . . . | | -1 1 1 1 1 | | -1 1 1 1 | */ #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* Grcar matrix */ SVD svd; /* singular value solver context */ Vec v0,w0; /* initial vectors */ PetscInt N=35,M=30,Istart,Iend,i,col[5]; PetscScalar value[] = { -1, 1, 1, 1, 1 }; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&M,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSVD of a rectangular Grcar matrix, %Dx%D\n\n",N,M);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Generate the matrix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,M);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;iActual source code: test2.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test SVD with different builds with a matrix loaded from a file"
 23:   " (matrices available in PETSc's distribution).\n\n";

 25: #include <slepcsvd.h>

 29: int main(int argc,char **argv)
 30: {
 31:   Mat            A;               /* operator matrix */
 32:   SVD            svd;             /* singular value problem solver context */
 33:   char           filename[PETSC_MAX_PATH_LEN];
 34:   const char     *prefix,*scalar,*ints,*floats;
 35:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 36:   PetscViewer    viewer;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);

 41:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 42:         Load the matrix for which the SVD must be computed
 43:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 44: #if defined(PETSC_USE_COMPLEX)
 45:   prefix = "nh";
 46:   scalar = "complex";
 47: #else
 48:   prefix = "ns";
 49:   scalar = "real";
 50: #endif
 51: #if defined(PETSC_USE_64BIT_INDICES)
 52:   ints   = "int64";
 53: #else
 54:   ints   = "int32";
 55: #endif
 56: #if defined(PETSC_USE_REAL_DOUBLE)
 57:   floats = "float64";
 58: #elif defined(PETSC_USE_REAL_SINGLE)
 59:   floats = "float32";
 60: #endif

 62:   PetscSNPrintf(filename,PETSC_MAX_PATH_LEN,"%s/share/petsc/datafiles/matrices/%s-%s-%s-%s",PETSC_DIR,prefix,scalar,ints,floats);
 63:   PetscPrintf(PETSC_COMM_WORLD,"\nReading matrix from binary file...\n\n");
 64:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 65:   MatCreate(PETSC_COMM_WORLD,&A);
 66:   MatSetFromOptions(A);
 67:   MatLoad(A,viewer);
 68:   PetscViewerDestroy(&viewer);

 70:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 71:                      Create the SVD solver
 72:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 73:   SVDCreate(PETSC_COMM_WORLD,&svd);
 74:   SVDSetOperator(svd,A);
 75:   SVDSetTolerances(svd,tol,PETSC_DEFAULT);
 76:   SVDSetFromOptions(svd);

 78:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 79:                 Solve the eigensystem and display solution
 80:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 81:   SVDSolve(svd);
 82:   SVDErrorView(svd,SVD_ERROR_RELATIVE,NULL);
 83:   SVDDestroy(&svd);
 84:   MatDestroy(&A);
 85:   SlepcFinalize();
 86:   return ierr;
 87: }

slepc-3.7.4/src/svd/examples/tests/output/0000755000175000017500000000000013107004621020066 5ustar jromanjromanslepc-3.7.4/src/svd/examples/tests/output/test2_1.out0000644000175000017500000000167613107004621022112 0ustar jromanjromansvd type cross Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04105, 6.37355, 5.47846, 5.30799, 4.47061, 4.06786, 3.92213 svd type cyclic Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04105, 6.37355, 5.47846, 5.30799, 4.47061, 4.06786, 3.92213 svd type lanczos Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04105, 6.37355, 5.47846, 5.30799, 4.47061, 4.06786, 3.92213 svd type lapack Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04105, 6.37355, 5.47846, 5.30799, 4.47061, 4.06786, 3.92213 svd type trlanczos Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04105, 6.37355, 5.47846, 5.30799, 4.47061, 4.06786, 3.92213 slepc-3.7.4/src/svd/examples/tests/output/test3_1.out0000644000175000017500000000230113107004621022075 0ustar jromanjromansvd type cross SVD of a rectangular Grcar matrix, 35x30 All requested singular values computed up to the required tolerance: 3.22175, 3.21797, 3.16825, 3.15128 svd type cyclic SVD of a rectangular Grcar matrix, 35x30 All requested singular values computed up to the required tolerance: 3.22175, 3.21797, 3.16825, 3.15128 svd type lanczos SVD of a rectangular Grcar matrix, 35x30 All requested singular values computed up to the required tolerance: 3.22175, 3.21797, 3.16825, 3.15128 svd type lapack SVD of a rectangular Grcar matrix, 35x30 All requested singular values computed up to the required tolerance: 3.22175, 3.21797, 3.16825, 3.15128 svd type trlanczos SVD of a rectangular Grcar matrix, 35x30 All requested singular values computed up to the required tolerance: 3.22175, 3.21797, 3.16825, 3.15128 svd type lanczos one-sided SVD of a rectangular Grcar matrix, 35x30 All requested singular values computed up to the required tolerance: 3.22175, 3.21797, 3.16825, 3.15128 svd type trlanczos one-sided SVD of a rectangular Grcar matrix, 35x30 All requested singular values computed up to the required tolerance: 3.22175, 3.21797, 3.16825, 3.15128 slepc-3.7.4/src/svd/examples/tests/output/test1_1.out0000644000175000017500000000571013107004621022102 0ustar jromanjroman Estimate the condition number of a Grcar matrix, n=30 SVD type: cross Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cyclic Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: lanczos Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: lapack Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: trlanczos Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cross EPS type: krylovschur Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cross EPS type: arnoldi Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cross EPS type: lanczos Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cross EPS type: gd Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cross EPS type: jd Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cyclic EPS type: krylovschur Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cyclic EPS type: arnoldi Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cyclic EPS type: lanczos Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cyclic EPS type: gd Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 Estimate the condition number of a Grcar matrix, n=30 SVD type: cyclic EPS type: jd Computed singular values: sigma_1=3.221487, sigma_n=0.955065 Estimated condition number: sigma_1/sigma_n=3.373056 slepc-3.7.4/src/svd/examples/tests/output/test2_1_complex.out0000644000175000017500000000167613107004621023641 0ustar jromanjromansvd type cross Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04428, 6.37662, 5.48234, 5.31000, 4.47278, 4.07783, 3.92481 svd type cyclic Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04428, 6.37662, 5.48234, 5.31000, 4.47278, 4.07783, 3.92481 svd type lanczos Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04428, 6.37662, 5.48234, 5.31000, 4.47278, 4.07783, 3.92481 svd type lapack Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04428, 6.37662, 5.48234, 5.31000, 4.47278, 4.07783, 3.92481 svd type trlanczos Reading matrix from binary file... All requested singular values computed up to the required tolerance: 7.04428, 6.37662, 5.48234, 5.31000, 4.47278, 4.07783, 3.92481 slepc-3.7.4/src/svd/examples/tests/index.html0000644000175000017500000000335313107004621020527 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

test1.c: Test the solution of a SVD without calling SVDSetFromOptions (based on ex8
test2.c: Test SVD with different builds with a matrix loaded from a file
test3.c: Test SVD with user-provided initial vectors
makefile
slepc-3.7.4/src/svd/examples/tests/test3.c.html0000644000175000017500000002240113107004621020676 0ustar jromanjroman

Actual source code: test3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test SVD with user-provided initial vectors.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = row dimension.\n"
 25:   "  -m <m>, where <m> = column dimension.\n\n";

 27: #include <slepcsvd.h>

 29: /*
 30:    This example computes the singular values of a rectangular nxm Grcar matrix:

 32:               |  1  1  1  1               |
 33:               | -1  1  1  1  1            |
 34:               |    -1  1  1  1  1         |
 35:           A = |       .  .  .  .  .       |
 36:               |          .  .  .  .  .    |
 37:               |            -1  1  1  1  1 |
 38:               |               -1  1  1  1 |

 40:  */

 44: int main(int argc,char **argv)
 45: {
 46:   Mat            A;               /* Grcar matrix */
 47:   SVD            svd;             /* singular value solver context */
 48:   Vec            v0,w0;           /* initial vectors */
 49:   PetscInt       N=35,M=30,Istart,Iend,i,col[5];
 50:   PetscScalar    value[] = { -1, 1, 1, 1, 1 };

 53:   SlepcInitialize(&argc,&argv,(char*)0,help);
 54:   PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);
 55:   PetscOptionsGetInt(NULL,NULL,"-m",&M,NULL);
 56:   PetscPrintf(PETSC_COMM_WORLD,"\nSVD of a rectangular Grcar matrix, %Dx%D\n\n",N,M);

 58:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 59:         Generate the matrix
 60:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 62:   MatCreate(PETSC_COMM_WORLD,&A);
 63:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,M);
 64:   MatSetFromOptions(A);
 65:   MatSetUp(A);

 67:   MatGetOwnershipRange(A,&Istart,&Iend);
 68:   for (i=Istart;i<Iend;i++) {
 69:     col[0]=i-1; col[1]=i; col[2]=i+1; col[3]=i+2; col[4]=i+3;
 70:     if (i==0) {
 71:       MatSetValues(A,1,&i,PetscMin(4,M-i+1),col+1,value+1,INSERT_VALUES);
 72:     } else {
 73:       MatSetValues(A,1,&i,PetscMin(5,M-i+1),col,value,INSERT_VALUES);
 74:     }
 75:   }
 76:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 77:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 79:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 80:              Create the SVD context and solve the problem
 81:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 83:   SVDCreate(PETSC_COMM_WORLD,&svd);
 84:   SVDSetOperator(svd,A);
 85:   SVDSetFromOptions(svd);

 87:   /*
 88:      Set the initial vectors. This is optional, if not done the initial
 89:      vectors are set to random values
 90:   */
 91:   MatCreateVecs(A,&v0,&w0);
 92:   VecSet(v0,1.0);
 93:   VecSet(w0,1.0);
 94:   SVDSetInitialSpace(svd,1,&v0);
 95:   SVDSetInitialSpaceLeft(svd,1,&w0);

 97:   /*
 98:      Compute solution
 99:   */
100:   SVDSolve(svd);
101:   SVDErrorView(svd,SVD_ERROR_RELATIVE,NULL);

103:   /*
104:      Free work space
105:   */
106:   VecDestroy(&v0);
107:   VecDestroy(&w0);
108:   SVDDestroy(&svd);
109:   MatDestroy(&A);
110:   SlepcFinalize();
111:   return ierr;
112: }

slepc-3.7.4/src/svd/examples/tests/test2.c0000644000175000017500000000660713107004621017744 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test SVD with different builds with a matrix loaded from a file" " (matrices available in PETSc's distribution).\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ SVD svd; /* singular value problem solver context */ char filename[PETSC_MAX_PATH_LEN]; const char *prefix,*scalar,*ints,*floats; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscViewer viewer; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load the matrix for which the SVD must be computed - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if defined(PETSC_USE_COMPLEX) prefix = "nh"; scalar = "complex"; #else prefix = "ns"; scalar = "real"; #endif #if defined(PETSC_USE_64BIT_INDICES) ints = "int64"; #else ints = "int32"; #endif #if defined(PETSC_USE_REAL_DOUBLE) floats = "float64"; #elif defined(PETSC_USE_REAL_SINGLE) floats = "float32"; #endif ierr = PetscSNPrintf(filename,PETSC_MAX_PATH_LEN,"%s/share/petsc/datafiles/matrices/%s-%s-%s-%s",PETSC_DIR,prefix,scalar,ints,floats);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nReading matrix from binary file...\n\n");CHKERRQ(ierr); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatLoad(A,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the SVD solver - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = SVDCreate(PETSC_COMM_WORLD,&svd);CHKERRQ(ierr); ierr = SVDSetOperator(svd,A);CHKERRQ(ierr); ierr = SVDSetTolerances(svd,tol,PETSC_DEFAULT);CHKERRQ(ierr); ierr = SVDSetFromOptions(svd);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem and display solution - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = SVDSolve(svd);CHKERRQ(ierr); ierr = SVDErrorView(svd,SVD_ERROR_RELATIVE,NULL);CHKERRQ(ierr); ierr = SVDDestroy(&svd);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/svd/makefile.html0000644000175000017500000000463513107004621016221 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../include/slepc/private/svdimpl.h ../../include/slepcsvd.h
DIRS     = interface impls examples f90-mod
LOCDIR   = src/svd/
MANSEC   = SVD

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/svd/index.html0000644000175000017500000000333613107004621015550 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

interface/
impls/
examples/
f90-mod/
../../include/slepc/private/svdimpl.h
../../include/slepcsvd.h
makefile
slepc-3.7.4/src/svd/f90-mod/0000755000175000017500000000000013107004621014721 5ustar jromanjromanslepc-3.7.4/src/svd/f90-mod/makefile0000644000175000017500000000255113107004621016424 0ustar jromanjroman # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_USING_F90' # # Makes Fortran module functions from *.h90 files in include/slepc/finclude # ALL: buildmod_slepc speciallib: buildmod_slepc specialfastlib: buildmod_slepc SPECIALLIB = yes SPECIALFASTLIB = yes CFLAGS = FFLAGS = SOURCEC = SOURCEF = slepcsvdmod.F SOURCEH = LIBBASE = libslepcsvd MANSEC = SVD LOCDIR = src/svd/f90-mod/ CLEANFILES = *.mod include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/f90-mod/makefile.html0000644000175000017500000000552413107004621017372 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#requiresdefine   'PETSC_USING_F90'
#
#   Makes Fortran module functions from *.h90 files in include/slepc/finclude
#
ALL: buildmod_slepc
speciallib: buildmod_slepc
specialfastlib: buildmod_slepc
SPECIALLIB     = yes
SPECIALFASTLIB = yes


CFLAGS     =
FFLAGS     =
SOURCEC    =
SOURCEF    = slepcsvdmod.F
SOURCEH    =
LIBBASE    = libslepcsvd
MANSEC     = SVD
LOCDIR     = src/svd/f90-mod/
CLEANFILES = *.mod

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/svd/f90-mod/slepcsvdmod.F0000644000175000017500000000234213107004621017354 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define PETSC_USE_FORTRAN_MODULES module slepcsvddef use slepcbv use slepceps #include #include end module module slepcsvd use slepcsvddef #include end module slepc-3.7.4/src/svd/f90-mod/index.html0000644000175000017500000000274313107004621016724 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

slepcsvdmod.F
makefile
slepc-3.7.4/src/svd/f90-mod/slepcsvdmod.F.html0000644000175000017500000000561213107004621020322 0ustar jromanjroman

Actual source code: slepcsvdmod.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 20: #define PETSC_USE_FORTRAN_MODULES

 22:         module slepcsvddef
 23:         use slepcbv
 24:         use slepceps
 25: #include <slepc/finclude/slepcsvd.h>
 26: #include <slepc/finclude/ftn-custom/slepcsvddef.h90>
 27:         end module

 29:         module slepcsvd
 30:         use slepcsvddef
 31: #include <slepc/finclude/slepcsvd.h90>
 32:         end module

slepc-3.7.4/src/svd/impls/0000755000175000017500000000000013107004621014672 5ustar jromanjromanslepc-3.7.4/src/svd/impls/makefile0000644000175000017500000000211513107004621016371 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcsvd DIRS = cross cyclic lapack lanczos trlanczos LOCDIR = src/svd/impls/ MANSEC = SVD include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/cyclic/0000755000175000017500000000000013107004621016140 5ustar jromanjromanslepc-3.7.4/src/svd/impls/cyclic/makefile0000644000175000017500000000215413107004621017642 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = cyclic.c SOURCEF = SOURCEH = LIBBASE = libslepcsvd DIRS = MANSEC = SVD LOCDIR = src/svd/impls/cyclic/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/cyclic/cyclic.c0000644000175000017500000005242013107004621017555 0ustar jromanjroman/* SLEPc singular value solver: "cyclic" Method: Uses a Hermitian eigensolver for H(A) = [ 0 A ; A^T 0 ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #include /*I "slepceps.h" I*/ typedef struct { PetscBool explicitmatrix; EPS eps; Mat mat; Vec x1,x2,y1,y2; } SVD_CYCLIC; #undef __FUNCT__ #define __FUNCT__ "MatMult_Cyclic" static PetscErrorCode MatMult_Cyclic(Mat B,Vec x,Vec y) { PetscErrorCode ierr; SVD svd; SVD_CYCLIC *cyclic; const PetscScalar *px; PetscScalar *py; PetscInt m; PetscFunctionBegin; ierr = MatShellGetContext(B,(void**)&svd);CHKERRQ(ierr); cyclic = (SVD_CYCLIC*)svd->data; ierr = SVDMatGetLocalSize(svd,&m,NULL);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = VecPlaceArray(cyclic->x1,px);CHKERRQ(ierr); ierr = VecPlaceArray(cyclic->x2,px+m);CHKERRQ(ierr); ierr = VecPlaceArray(cyclic->y1,py);CHKERRQ(ierr); ierr = VecPlaceArray(cyclic->y2,py+m);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_FALSE,cyclic->x2,cyclic->y1);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_TRUE,cyclic->x1,cyclic->y2);CHKERRQ(ierr); ierr = VecResetArray(cyclic->x1);CHKERRQ(ierr); ierr = VecResetArray(cyclic->x2);CHKERRQ(ierr); ierr = VecResetArray(cyclic->y1);CHKERRQ(ierr); ierr = VecResetArray(cyclic->y2);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatGetDiagonal_Cyclic" static PetscErrorCode MatGetDiagonal_Cyclic(Mat B,Vec diag) { PetscErrorCode ierr; PetscFunctionBegin; ierr = VecSet(diag,0.0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetUp_Cyclic" PetscErrorCode SVDSetUp_Cyclic(SVD svd) { PetscErrorCode ierr; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscInt M,N,m,n,i,isl,Istart,Iend; const PetscScalar *isa; PetscScalar *va; PetscBool trackall,gpu,issinv; Vec v; Mat Zm,Zn; ST st; PetscFunctionBegin; ierr = PetscObjectTypeCompareAny((PetscObject)svd->A,&gpu,MATSEQAIJCUSP,MATMPIAIJCUSP,MATSEQAIJCUSPARSE,MATMPIAIJCUSPARSE,"");CHKERRQ(ierr); if (gpu) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Solver not implemented for GPU matrices"); ierr = SVDMatGetSize(svd,&M,&N);CHKERRQ(ierr); ierr = SVDMatGetLocalSize(svd,&m,&n);CHKERRQ(ierr); if (!cyclic->mat) { if (cyclic->explicitmatrix) { if (!svd->AT) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Cannot use explicit cyclic matrix with implicit transpose"); ierr = MatCreate(PetscObjectComm((PetscObject)svd),&Zm);CHKERRQ(ierr); ierr = MatSetSizes(Zm,m,m,M,M);CHKERRQ(ierr); ierr = MatSetFromOptions(Zm);CHKERRQ(ierr); ierr = MatSetUp(Zm);CHKERRQ(ierr); ierr = MatGetOwnershipRange(Zm,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;iA,1.0,svd->AT,1.0,Zn,&cyclic->mat);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->mat);CHKERRQ(ierr); ierr = MatDestroy(&Zm);CHKERRQ(ierr); ierr = MatDestroy(&Zn);CHKERRQ(ierr); } else { ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,m,M,NULL,&cyclic->x1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,n,N,NULL,&cyclic->x2);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,m,M,NULL,&cyclic->y1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,n,N,NULL,&cyclic->y2);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->x1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->x2);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->y1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->y2);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)svd),m+n,m+n,M+N,M+N,svd,&cyclic->mat);CHKERRQ(ierr); ierr = MatShellSetOperation(cyclic->mat,MATOP_MULT,(void(*)(void))MatMult_Cyclic);CHKERRQ(ierr); ierr = MatShellSetOperation(cyclic->mat,MATOP_GET_DIAGONAL,(void(*)(void))MatGetDiagonal_Cyclic);CHKERRQ(ierr); } ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->mat);CHKERRQ(ierr); } if (!cyclic->eps) { ierr = SVDCyclicGetEPS(svd,&cyclic->eps);CHKERRQ(ierr); } ierr = EPSSetOperators(cyclic->eps,cyclic->mat,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(cyclic->eps,EPS_HEP);CHKERRQ(ierr); if (svd->which == SVD_LARGEST) { ierr = EPSGetST(cyclic->eps,&st);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)st,STSINVERT,&issinv);CHKERRQ(ierr); if (issinv) { ierr = EPSSetWhichEigenpairs(cyclic->eps,EPS_TARGET_MAGNITUDE);CHKERRQ(ierr); } else { ierr = EPSSetWhichEigenpairs(cyclic->eps,EPS_LARGEST_REAL);CHKERRQ(ierr); } } else { ierr = EPSSetEigenvalueComparison(cyclic->eps,SlepcCompareSmallestPosReal,NULL);CHKERRQ(ierr); ierr = EPSSetTarget(cyclic->eps,0.0);CHKERRQ(ierr); } ierr = EPSSetDimensions(cyclic->eps,svd->nsv,svd->ncv?svd->ncv:PETSC_DEFAULT,svd->mpd?svd->mpd:PETSC_DEFAULT);CHKERRQ(ierr); ierr = EPSSetTolerances(cyclic->eps,svd->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/10.0:svd->tol,svd->max_it?svd->max_it:PETSC_DEFAULT);CHKERRQ(ierr); switch (svd->conv) { case SVD_CONV_ABS: ierr = EPSSetConvergenceTest(cyclic->eps,EPS_CONV_ABS);CHKERRQ(ierr);break; case SVD_CONV_REL: ierr = EPSSetConvergenceTest(cyclic->eps,EPS_CONV_REL);CHKERRQ(ierr);break; case SVD_CONV_USER: SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined convergence test not supported in this solver"); } if (svd->stop!=SVD_STOP_BASIC) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined stopping test not supported in this solver"); /* Transfer the trackall option from svd to eps */ ierr = SVDGetTrackAll(svd,&trackall);CHKERRQ(ierr); ierr = EPSSetTrackAll(cyclic->eps,trackall);CHKERRQ(ierr); /* Transfer the initial subspace from svd to eps */ if (svd->nini<0 || svd->ninil<0) { for (i=0;i<-PetscMin(svd->nini,svd->ninil);i++) { ierr = MatCreateVecs(cyclic->mat,&v,NULL);CHKERRQ(ierr); ierr = VecGetArray(v,&va);CHKERRQ(ierr); if (i<-svd->ninil) { ierr = VecGetSize(svd->ISL[i],&isl);CHKERRQ(ierr); if (isl!=m) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Size mismatch for left initial vector"); ierr = VecGetArrayRead(svd->ISL[i],&isa);CHKERRQ(ierr); ierr = PetscMemcpy(va,isa,sizeof(PetscScalar)*m);CHKERRQ(ierr); ierr = VecRestoreArrayRead(svd->IS[i],&isa);CHKERRQ(ierr); } else { ierr = PetscMemzero(&va,sizeof(PetscScalar)*m);CHKERRQ(ierr); } if (i<-svd->nini) { ierr = VecGetSize(svd->IS[i],&isl);CHKERRQ(ierr); if (isl!=n) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Size mismatch for right initial vector"); ierr = VecGetArrayRead(svd->IS[i],&isa);CHKERRQ(ierr); ierr = PetscMemcpy(va+m,isa,sizeof(PetscScalar)*n);CHKERRQ(ierr); ierr = VecRestoreArrayRead(svd->IS[i],&isa);CHKERRQ(ierr); } else { ierr = PetscMemzero(va+m,sizeof(PetscScalar)*n);CHKERRQ(ierr); } ierr = VecRestoreArray(v,&va);CHKERRQ(ierr); ierr = VecDestroy(&svd->IS[i]);CHKERRQ(ierr); svd->IS[i] = v; } svd->nini = PetscMin(svd->nini,svd->ninil); ierr = EPSSetInitialSpace(cyclic->eps,-svd->nini,svd->IS);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&svd->nini,&svd->IS);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&svd->ninil,&svd->ISL);CHKERRQ(ierr); } ierr = EPSSetUp(cyclic->eps);CHKERRQ(ierr); ierr = EPSGetDimensions(cyclic->eps,NULL,&svd->ncv,&svd->mpd);CHKERRQ(ierr); svd->ncv = PetscMin(svd->ncv,PetscMin(M,N)); ierr = EPSGetTolerances(cyclic->eps,NULL,&svd->max_it);CHKERRQ(ierr); if (svd->tol==PETSC_DEFAULT) svd->tol = SLEPC_DEFAULT_TOL; svd->leftbasis = PETSC_TRUE; ierr = SVDAllocateSolution(svd,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSolve_Cyclic" PetscErrorCode SVDSolve_Cyclic(SVD svd) { PetscErrorCode ierr; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscInt i,j,M,N,m,n; PetscScalar sigma; const PetscScalar *px; Vec x,x1,x2; PetscFunctionBegin; ierr = EPSSolve(cyclic->eps);CHKERRQ(ierr); ierr = EPSGetConverged(cyclic->eps,&svd->nconv);CHKERRQ(ierr); ierr = EPSGetIterationNumber(cyclic->eps,&svd->its);CHKERRQ(ierr); ierr = EPSGetConvergedReason(cyclic->eps,(EPSConvergedReason*)&svd->reason);CHKERRQ(ierr); ierr = MatCreateVecs(cyclic->mat,&x,NULL);CHKERRQ(ierr); ierr = SVDMatGetSize(svd,&M,&N);CHKERRQ(ierr); ierr = SVDMatGetLocalSize(svd,&m,&n);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,m,M,NULL,&x1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,n,N,NULL,&x2);CHKERRQ(ierr); for (i=0,j=0;inconv;i++) { ierr = EPSGetEigenpair(cyclic->eps,i,&sigma,NULL,x,NULL);CHKERRQ(ierr); if (PetscRealPart(sigma) > 0.0) { svd->sigma[j] = PetscRealPart(sigma); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecPlaceArray(x1,px);CHKERRQ(ierr); ierr = VecPlaceArray(x2,px+m);CHKERRQ(ierr); ierr = BVInsertVec(svd->U,j,x1);CHKERRQ(ierr); ierr = BVScaleColumn(svd->U,j,1.0/PetscSqrtReal(2.0));CHKERRQ(ierr); ierr = BVInsertVec(svd->V,j,x2);CHKERRQ(ierr); ierr = BVScaleColumn(svd->V,j,1.0/PetscSqrtReal(2.0));CHKERRQ(ierr); ierr = VecResetArray(x1);CHKERRQ(ierr); ierr = VecResetArray(x2);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); j++; } } svd->nconv = j; ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&x1);CHKERRQ(ierr); ierr = VecDestroy(&x2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitor_Cyclic" static PetscErrorCode EPSMonitor_Cyclic(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscInt i,j; SVD svd = (SVD)ctx; PetscScalar er,ei; PetscErrorCode ierr; PetscFunctionBegin; nconv = 0; for (i=0,j=0;incv);i++) { er = eigr[i]; ei = eigi[i]; ierr = STBackTransform(eps->st,1,&er,&ei);CHKERRQ(ierr); if (PetscRealPart(er) > 0.0) { svd->sigma[j] = PetscRealPart(er); svd->errest[j] = errest[i]; if (errest[i] && errest[i] < svd->tol) nconv++; j++; } } nest = j; ierr = SVDMonitor(svd,its,nconv,svd->sigma,svd->errest,nest);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetFromOptions_Cyclic" PetscErrorCode SVDSetFromOptions_Cyclic(PetscOptionItems *PetscOptionsObject,SVD svd) { PetscErrorCode ierr; PetscBool set,val; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; ST st; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"SVD Cyclic Options");CHKERRQ(ierr); ierr = PetscOptionsBool("-svd_cyclic_explicitmatrix","Use cyclic explicit matrix","SVDCyclicSetExplicitMatrix",cyclic->explicitmatrix,&val,&set);CHKERRQ(ierr); if (set) { ierr = SVDCyclicSetExplicitMatrix(svd,val);CHKERRQ(ierr); } if (!cyclic->eps) { ierr = SVDCyclicGetEPS(svd,&cyclic->eps);CHKERRQ(ierr); } ierr = EPSSetFromOptions(cyclic->eps);CHKERRQ(ierr); if (!cyclic->explicitmatrix) { /* use as default an ST with shell matrix and Jacobi */ ierr = EPSGetST(cyclic->eps,&st);CHKERRQ(ierr); ierr = STSetMatMode(st,ST_MATMODE_SHELL);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicSetExplicitMatrix_Cyclic" static PetscErrorCode SVDCyclicSetExplicitMatrix_Cyclic(SVD svd,PetscBool explicitmatrix) { SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscFunctionBegin; cyclic->explicitmatrix = explicitmatrix; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicSetExplicitMatrix" /*@ SVDCyclicSetExplicitMatrix - Indicate if the eigensolver operator H(A) = [ 0 A ; A^T 0 ] must be computed explicitly. Logically Collective on SVD Input Parameters: + svd - singular value solver - explicit - boolean flag indicating if H(A) is built explicitly Options Database Key: . -svd_cyclic_explicitmatrix - Indicates the boolean flag Level: advanced .seealso: SVDCyclicGetExplicitMatrix() @*/ PetscErrorCode SVDCyclicSetExplicitMatrix(SVD svd,PetscBool explicitmatrix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveBool(svd,explicitmatrix,2); ierr = PetscTryMethod(svd,"SVDCyclicSetExplicitMatrix_C",(SVD,PetscBool),(svd,explicitmatrix));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicGetExplicitMatrix_Cyclic" static PetscErrorCode SVDCyclicGetExplicitMatrix_Cyclic(SVD svd,PetscBool *explicitmatrix) { SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscFunctionBegin; *explicitmatrix = cyclic->explicitmatrix; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicGetExplicitMatrix" /*@ SVDCyclicGetExplicitMatrix - Returns the flag indicating if H(A) is built explicitly Not Collective Input Parameter: . svd - singular value solver Output Parameter: . explicit - the mode flag Level: advanced .seealso: SVDCyclicSetExplicitMatrix() @*/ PetscErrorCode SVDCyclicGetExplicitMatrix(SVD svd,PetscBool *explicitmatrix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(explicitmatrix,2); ierr = PetscUseMethod(svd,"SVDCyclicGetExplicitMatrix_C",(SVD,PetscBool*),(svd,explicitmatrix));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicSetEPS_Cyclic" static PetscErrorCode SVDCyclicSetEPS_Cyclic(SVD svd,EPS eps) { PetscErrorCode ierr; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscFunctionBegin; ierr = PetscObjectReference((PetscObject)eps);CHKERRQ(ierr); ierr = EPSDestroy(&cyclic->eps);CHKERRQ(ierr); cyclic->eps = eps; ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->eps);CHKERRQ(ierr); svd->state = SVD_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicSetEPS" /*@ SVDCyclicSetEPS - Associate an eigensolver object (EPS) to the singular value solver. Collective on SVD Input Parameters: + svd - singular value solver - eps - the eigensolver object Level: advanced .seealso: SVDCyclicGetEPS() @*/ PetscErrorCode SVDCyclicSetEPS(SVD svd,EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidHeaderSpecific(eps,EPS_CLASSID,2); PetscCheckSameComm(svd,1,eps,2); ierr = PetscTryMethod(svd,"SVDCyclicSetEPS_C",(SVD,EPS),(svd,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicGetEPS_Cyclic" static PetscErrorCode SVDCyclicGetEPS_Cyclic(SVD svd,EPS *eps) { PetscErrorCode ierr; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscFunctionBegin; if (!cyclic->eps) { ierr = EPSCreate(PetscObjectComm((PetscObject)svd),&cyclic->eps);CHKERRQ(ierr); ierr = EPSSetOptionsPrefix(cyclic->eps,((PetscObject)svd)->prefix);CHKERRQ(ierr); ierr = EPSAppendOptionsPrefix(cyclic->eps,"svd_cyclic_");CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)cyclic->eps,(PetscObject)svd,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->eps);CHKERRQ(ierr); ierr = EPSSetWhichEigenpairs(cyclic->eps,EPS_LARGEST_REAL);CHKERRQ(ierr); ierr = EPSMonitorSet(cyclic->eps,EPSMonitor_Cyclic,svd,NULL);CHKERRQ(ierr); } *eps = cyclic->eps; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCyclicGetEPS" /*@ SVDCyclicGetEPS - Retrieve the eigensolver object (EPS) associated to the singular value solver. Not Collective Input Parameter: . svd - singular value solver Output Parameter: . eps - the eigensolver object Level: advanced .seealso: SVDCyclicSetEPS() @*/ PetscErrorCode SVDCyclicGetEPS(SVD svd,EPS *eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(eps,2); ierr = PetscUseMethod(svd,"SVDCyclicGetEPS_C",(SVD,EPS*),(svd,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDView_Cyclic" PetscErrorCode SVDView_Cyclic(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (!cyclic->eps) { ierr = SVDCyclicGetEPS(svd,&cyclic->eps);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," Cyclic: %s matrix\n",cyclic->explicitmatrix?"explicit":"implicit");CHKERRQ(ierr); ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = EPSView(cyclic->eps,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDReset_Cyclic" PetscErrorCode SVDReset_Cyclic(SVD svd) { PetscErrorCode ierr; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscFunctionBegin; if (!cyclic->eps) { ierr = EPSReset(cyclic->eps);CHKERRQ(ierr); } ierr = MatDestroy(&cyclic->mat);CHKERRQ(ierr); ierr = VecDestroy(&cyclic->x1);CHKERRQ(ierr); ierr = VecDestroy(&cyclic->x2);CHKERRQ(ierr); ierr = VecDestroy(&cyclic->y1);CHKERRQ(ierr); ierr = VecDestroy(&cyclic->y2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDDestroy_Cyclic" PetscErrorCode SVDDestroy_Cyclic(SVD svd) { PetscErrorCode ierr; SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data; PetscFunctionBegin; ierr = EPSDestroy(&cyclic->eps);CHKERRQ(ierr); ierr = PetscFree(svd->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetEPS_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetEPS_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetExplicitMatrix_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetExplicitMatrix_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCreate_Cyclic" PETSC_EXTERN PetscErrorCode SVDCreate_Cyclic(SVD svd) { PetscErrorCode ierr; SVD_CYCLIC *cyclic; PetscFunctionBegin; ierr = PetscNewLog(svd,&cyclic);CHKERRQ(ierr); svd->data = (void*)cyclic; svd->ops->solve = SVDSolve_Cyclic; svd->ops->setup = SVDSetUp_Cyclic; svd->ops->setfromoptions = SVDSetFromOptions_Cyclic; svd->ops->destroy = SVDDestroy_Cyclic; svd->ops->reset = SVDReset_Cyclic; svd->ops->view = SVDView_Cyclic; ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetEPS_C",SVDCyclicSetEPS_Cyclic);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetEPS_C",SVDCyclicGetEPS_Cyclic);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetExplicitMatrix_C",SVDCyclicSetExplicitMatrix_Cyclic);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetExplicitMatrix_C",SVDCyclicGetExplicitMatrix_Cyclic);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/svd/impls/cyclic/makefile.html0000644000175000017500000000465613107004621020616 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = cyclic.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsvd
DIRS     =
MANSEC   = SVD
LOCDIR   = src/svd/impls/cyclic/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/svd/impls/cyclic/index.html0000644000175000017500000000274313107004621020143 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

cyclic.c
makefile
slepc-3.7.4/src/svd/impls/cyclic/ftn-auto/0000755000175000017500000000000013107004621017675 5ustar jromanjromanslepc-3.7.4/src/svd/impls/cyclic/ftn-auto/makefile0000644000175000017500000000036113107004621021375 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = cyclicf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsvd LOCDIR = src/svd/impls/cyclic/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/cyclic/ftn-auto/cyclicf.c0000644000175000017500000000450213107004621021456 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* cyclic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcyclicsetexplicitmatrix_ SVDCYCLICSETEXPLICITMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcyclicsetexplicitmatrix_ svdcyclicsetexplicitmatrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcyclicgetexplicitmatrix_ SVDCYCLICGETEXPLICITMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcyclicgetexplicitmatrix_ svdcyclicgetexplicitmatrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcyclicseteps_ SVDCYCLICSETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcyclicseteps_ svdcyclicseteps #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcyclicgeteps_ SVDCYCLICGETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcyclicgeteps_ svdcyclicgeteps #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdcyclicsetexplicitmatrix_(SVD svd,PetscBool *explicitmatrix, int *__ierr ){ *__ierr = SVDCyclicSetExplicitMatrix( (SVD)PetscToPointer((svd) ),*explicitmatrix); } PETSC_EXTERN void PETSC_STDCALL svdcyclicgetexplicitmatrix_(SVD svd,PetscBool *explicitmatrix, int *__ierr ){ *__ierr = SVDCyclicGetExplicitMatrix( (SVD)PetscToPointer((svd) ),explicitmatrix); } PETSC_EXTERN void PETSC_STDCALL svdcyclicseteps_(SVD svd,EPS eps, int *__ierr ){ *__ierr = SVDCyclicSetEPS( (SVD)PetscToPointer((svd) ), (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL svdcyclicgeteps_(SVD svd,EPS *eps, int *__ierr ){ *__ierr = SVDCyclicGetEPS( (SVD)PetscToPointer((svd) ),eps); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/impls/cyclic/cyclic.c.html0000644000175000017500000012303013107004621020514 0ustar jromanjroman

Actual source code: cyclic.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc singular value solver: "cyclic"

  5:    Method: Uses a Hermitian eigensolver for H(A) = [ 0  A ; A^T 0 ]

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

 11:    This file is part of SLEPc.

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

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

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

 27: #include <slepc/private/svdimpl.h>                /*I "slepcsvd.h" I*/
 28: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/

 30: typedef struct {
 31:   PetscBool explicitmatrix;
 32:   EPS       eps;
 33:   Mat       mat;
 34:   Vec       x1,x2,y1,y2;
 35: } SVD_CYCLIC;

 39: static PetscErrorCode MatMult_Cyclic(Mat B,Vec x,Vec y)
 40: {
 41:   PetscErrorCode    ierr;
 42:   SVD               svd;
 43:   SVD_CYCLIC        *cyclic;
 44:   const PetscScalar *px;
 45:   PetscScalar       *py;
 46:   PetscInt          m;

 49:   MatShellGetContext(B,(void**)&svd);
 50:   cyclic = (SVD_CYCLIC*)svd->data;
 51:   SVDMatGetLocalSize(svd,&m,NULL);
 52:   VecGetArrayRead(x,&px);
 53:   VecGetArray(y,&py);
 54:   VecPlaceArray(cyclic->x1,px);
 55:   VecPlaceArray(cyclic->x2,px+m);
 56:   VecPlaceArray(cyclic->y1,py);
 57:   VecPlaceArray(cyclic->y2,py+m);
 58:   SVDMatMult(svd,PETSC_FALSE,cyclic->x2,cyclic->y1);
 59:   SVDMatMult(svd,PETSC_TRUE,cyclic->x1,cyclic->y2);
 60:   VecResetArray(cyclic->x1);
 61:   VecResetArray(cyclic->x2);
 62:   VecResetArray(cyclic->y1);
 63:   VecResetArray(cyclic->y2);
 64:   VecRestoreArrayRead(x,&px);
 65:   VecRestoreArray(y,&py);
 66:   return(0);
 67: }

 71: static PetscErrorCode MatGetDiagonal_Cyclic(Mat B,Vec diag)
 72: {

 76:   VecSet(diag,0.0);
 77:   return(0);
 78: }

 82: PetscErrorCode SVDSetUp_Cyclic(SVD svd)
 83: {
 84:   PetscErrorCode    ierr;
 85:   SVD_CYCLIC        *cyclic = (SVD_CYCLIC*)svd->data;
 86:   PetscInt          M,N,m,n,i,isl,Istart,Iend;
 87:   const PetscScalar *isa;
 88:   PetscScalar       *va;
 89:   PetscBool         trackall,gpu,issinv;
 90:   Vec               v;
 91:   Mat               Zm,Zn;
 92:   ST                st;

 95:   PetscObjectTypeCompareAny((PetscObject)svd->A,&gpu,MATSEQAIJCUSP,MATMPIAIJCUSP,MATSEQAIJCUSPARSE,MATMPIAIJCUSPARSE,"");
 96:   if (gpu) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Solver not implemented for GPU matrices");
 97:   SVDMatGetSize(svd,&M,&N);
 98:   SVDMatGetLocalSize(svd,&m,&n);
 99:   if (!cyclic->mat) {
100:     if (cyclic->explicitmatrix) {
101:       if (!svd->AT) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Cannot use explicit cyclic matrix with implicit transpose");
102:       MatCreate(PetscObjectComm((PetscObject)svd),&Zm);
103:       MatSetSizes(Zm,m,m,M,M);
104:       MatSetFromOptions(Zm);
105:       MatSetUp(Zm);
106:       MatGetOwnershipRange(Zm,&Istart,&Iend);
107:       for (i=Istart;i<Iend;i++) {
108:         MatSetValue(Zm,i,i,0.0,INSERT_VALUES);
109:       }
110:       MatAssemblyBegin(Zm,MAT_FINAL_ASSEMBLY);
111:       MatAssemblyEnd(Zm,MAT_FINAL_ASSEMBLY);
112:       MatCreate(PetscObjectComm((PetscObject)svd),&Zn);
113:       MatSetSizes(Zn,n,n,N,N);
114:       MatSetFromOptions(Zn);
115:       MatSetUp(Zn);
116:       MatGetOwnershipRange(Zn,&Istart,&Iend);
117:       for (i=Istart;i<Iend;i++) {
118:         MatSetValue(Zn,i,i,0.0,INSERT_VALUES);
119:       }
120:       MatAssemblyBegin(Zn,MAT_FINAL_ASSEMBLY);
121:       MatAssemblyEnd(Zn,MAT_FINAL_ASSEMBLY);
122:       SlepcMatTile(1.0,Zm,1.0,svd->A,1.0,svd->AT,1.0,Zn,&cyclic->mat);
123:       PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->mat);
124:       MatDestroy(&Zm);
125:       MatDestroy(&Zn);
126:     } else {
127:       VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,m,M,NULL,&cyclic->x1);
128:       VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,n,N,NULL,&cyclic->x2);
129:       VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,m,M,NULL,&cyclic->y1);
130:       VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,n,N,NULL,&cyclic->y2);
131:       PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->x1);
132:       PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->x2);
133:       PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->y1);
134:       PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->y2);
135:       MatCreateShell(PetscObjectComm((PetscObject)svd),m+n,m+n,M+N,M+N,svd,&cyclic->mat);
136:       MatShellSetOperation(cyclic->mat,MATOP_MULT,(void(*)(void))MatMult_Cyclic);
137:       MatShellSetOperation(cyclic->mat,MATOP_GET_DIAGONAL,(void(*)(void))MatGetDiagonal_Cyclic);
138:     }
139:     PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->mat);
140:   }

142:   if (!cyclic->eps) { SVDCyclicGetEPS(svd,&cyclic->eps); }
143:   EPSSetOperators(cyclic->eps,cyclic->mat,NULL);
144:   EPSSetProblemType(cyclic->eps,EPS_HEP);
145:   if (svd->which == SVD_LARGEST) {
146:     EPSGetST(cyclic->eps,&st);
147:     PetscObjectTypeCompare((PetscObject)st,STSINVERT,&issinv);
148:     if (issinv) {
149:       EPSSetWhichEigenpairs(cyclic->eps,EPS_TARGET_MAGNITUDE);
150:     } else {
151:       EPSSetWhichEigenpairs(cyclic->eps,EPS_LARGEST_REAL);
152:     }
153:   } else {
154:     EPSSetEigenvalueComparison(cyclic->eps,SlepcCompareSmallestPosReal,NULL);
155:     EPSSetTarget(cyclic->eps,0.0);
156:   }
157:   EPSSetDimensions(cyclic->eps,svd->nsv,svd->ncv?svd->ncv:PETSC_DEFAULT,svd->mpd?svd->mpd:PETSC_DEFAULT);
158:   EPSSetTolerances(cyclic->eps,svd->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/10.0:svd->tol,svd->max_it?svd->max_it:PETSC_DEFAULT);
159:   switch (svd->conv) {
160:   case SVD_CONV_ABS:
161:     EPSSetConvergenceTest(cyclic->eps,EPS_CONV_ABS);break;
162:   case SVD_CONV_REL:
163:     EPSSetConvergenceTest(cyclic->eps,EPS_CONV_REL);break;
164:   case SVD_CONV_USER:
165:     SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined convergence test not supported in this solver");
166:   }
167:   if (svd->stop!=SVD_STOP_BASIC) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined stopping test not supported in this solver");
168:   /* Transfer the trackall option from svd to eps */
169:   SVDGetTrackAll(svd,&trackall);
170:   EPSSetTrackAll(cyclic->eps,trackall);
171:   /* Transfer the initial subspace from svd to eps */
172:   if (svd->nini<0 || svd->ninil<0) {
173:     for (i=0;i<-PetscMin(svd->nini,svd->ninil);i++) {
174:       MatCreateVecs(cyclic->mat,&v,NULL);
175:       VecGetArray(v,&va);
176:       if (i<-svd->ninil) {
177:         VecGetSize(svd->ISL[i],&isl);
178:         if (isl!=m) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Size mismatch for left initial vector");
179:         VecGetArrayRead(svd->ISL[i],&isa);
180:         PetscMemcpy(va,isa,sizeof(PetscScalar)*m);
181:         VecRestoreArrayRead(svd->IS[i],&isa);
182:       } else {
183:         PetscMemzero(&va,sizeof(PetscScalar)*m);
184:       }
185:       if (i<-svd->nini) {
186:         VecGetSize(svd->IS[i],&isl);
187:         if (isl!=n) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"Size mismatch for right initial vector");
188:         VecGetArrayRead(svd->IS[i],&isa);
189:         PetscMemcpy(va+m,isa,sizeof(PetscScalar)*n);
190:         VecRestoreArrayRead(svd->IS[i],&isa);
191:       } else {
192:         PetscMemzero(va+m,sizeof(PetscScalar)*n);
193:       }
194:       VecRestoreArray(v,&va);
195:       VecDestroy(&svd->IS[i]);
196:       svd->IS[i] = v;
197:     }
198:     svd->nini = PetscMin(svd->nini,svd->ninil);
199:     EPSSetInitialSpace(cyclic->eps,-svd->nini,svd->IS);
200:     SlepcBasisDestroy_Private(&svd->nini,&svd->IS);
201:     SlepcBasisDestroy_Private(&svd->ninil,&svd->ISL);
202:   }
203:   EPSSetUp(cyclic->eps);
204:   EPSGetDimensions(cyclic->eps,NULL,&svd->ncv,&svd->mpd);
205:   svd->ncv = PetscMin(svd->ncv,PetscMin(M,N));
206:   EPSGetTolerances(cyclic->eps,NULL,&svd->max_it);
207:   if (svd->tol==PETSC_DEFAULT) svd->tol = SLEPC_DEFAULT_TOL;

209:   svd->leftbasis = PETSC_TRUE;
210:   SVDAllocateSolution(svd,0);
211:   return(0);
212: }

216: PetscErrorCode SVDSolve_Cyclic(SVD svd)
217: {
218:   PetscErrorCode    ierr;
219:   SVD_CYCLIC        *cyclic = (SVD_CYCLIC*)svd->data;
220:   PetscInt          i,j,M,N,m,n;
221:   PetscScalar       sigma;
222:   const PetscScalar *px;
223:   Vec               x,x1,x2;

226:   EPSSolve(cyclic->eps);
227:   EPSGetConverged(cyclic->eps,&svd->nconv);
228:   EPSGetIterationNumber(cyclic->eps,&svd->its);
229:   EPSGetConvergedReason(cyclic->eps,(EPSConvergedReason*)&svd->reason);

231:   MatCreateVecs(cyclic->mat,&x,NULL);
232:   SVDMatGetSize(svd,&M,&N);
233:   SVDMatGetLocalSize(svd,&m,&n);
234:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,m,M,NULL,&x1);
235:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)svd),1,n,N,NULL,&x2);
236:   for (i=0,j=0;i<svd->nconv;i++) {
237:     EPSGetEigenpair(cyclic->eps,i,&sigma,NULL,x,NULL);
238:     if (PetscRealPart(sigma) > 0.0) {
239:       svd->sigma[j] = PetscRealPart(sigma);
240:       VecGetArrayRead(x,&px);
241:       VecPlaceArray(x1,px);
242:       VecPlaceArray(x2,px+m);
243:       BVInsertVec(svd->U,j,x1);
244:       BVScaleColumn(svd->U,j,1.0/PetscSqrtReal(2.0));
245:       BVInsertVec(svd->V,j,x2);
246:       BVScaleColumn(svd->V,j,1.0/PetscSqrtReal(2.0));
247:       VecResetArray(x1);
248:       VecResetArray(x2);
249:       VecRestoreArrayRead(x,&px);
250:       j++;
251:     }
252:   }
253:   svd->nconv = j;

255:   VecDestroy(&x);
256:   VecDestroy(&x1);
257:   VecDestroy(&x2);
258:   return(0);
259: }

263: static PetscErrorCode EPSMonitor_Cyclic(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
264: {
265:   PetscInt       i,j;
266:   SVD            svd = (SVD)ctx;
267:   PetscScalar    er,ei;

271:   nconv = 0;
272:   for (i=0,j=0;i<PetscMin(nest,svd->ncv);i++) {
273:     er = eigr[i]; ei = eigi[i];
274:     STBackTransform(eps->st,1,&er,&ei);
275:     if (PetscRealPart(er) > 0.0) {
276:       svd->sigma[j] = PetscRealPart(er);
277:       svd->errest[j] = errest[i];
278:       if (errest[i] && errest[i] < svd->tol) nconv++;
279:       j++;
280:     }
281:   }
282:   nest = j;
283:   SVDMonitor(svd,its,nconv,svd->sigma,svd->errest,nest);
284:   return(0);
285: }

289: PetscErrorCode SVDSetFromOptions_Cyclic(PetscOptionItems *PetscOptionsObject,SVD svd)
290: {
292:   PetscBool      set,val;
293:   SVD_CYCLIC     *cyclic = (SVD_CYCLIC*)svd->data;
294:   ST             st;

297:   PetscOptionsHead(PetscOptionsObject,"SVD Cyclic Options");
298:   PetscOptionsBool("-svd_cyclic_explicitmatrix","Use cyclic explicit matrix","SVDCyclicSetExplicitMatrix",cyclic->explicitmatrix,&val,&set);
299:   if (set) {
300:     SVDCyclicSetExplicitMatrix(svd,val);
301:   }
302:   if (!cyclic->eps) { SVDCyclicGetEPS(svd,&cyclic->eps); }
303:   EPSSetFromOptions(cyclic->eps);
304:   if (!cyclic->explicitmatrix) {
305:     /* use as default an ST with shell matrix and Jacobi */
306:     EPSGetST(cyclic->eps,&st);
307:     STSetMatMode(st,ST_MATMODE_SHELL);
308:   }
309:   PetscOptionsTail();
310:   return(0);
311: }

315: static PetscErrorCode SVDCyclicSetExplicitMatrix_Cyclic(SVD svd,PetscBool explicitmatrix)
316: {
317:   SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data;

320:   cyclic->explicitmatrix = explicitmatrix;
321:   return(0);
322: }

326: /*@
327:    SVDCyclicSetExplicitMatrix - Indicate if the eigensolver operator
328:    H(A) = [ 0  A ; A^T 0 ] must be computed explicitly.

330:    Logically Collective on SVD

332:    Input Parameters:
333: +  svd      - singular value solver
334: -  explicit - boolean flag indicating if H(A) is built explicitly

336:    Options Database Key:
337: .  -svd_cyclic_explicitmatrix <boolean> - Indicates the boolean flag

339:    Level: advanced

341: .seealso: SVDCyclicGetExplicitMatrix()
342: @*/
343: PetscErrorCode SVDCyclicSetExplicitMatrix(SVD svd,PetscBool explicitmatrix)
344: {

350:   PetscTryMethod(svd,"SVDCyclicSetExplicitMatrix_C",(SVD,PetscBool),(svd,explicitmatrix));
351:   return(0);
352: }

356: static PetscErrorCode SVDCyclicGetExplicitMatrix_Cyclic(SVD svd,PetscBool *explicitmatrix)
357: {
358:   SVD_CYCLIC *cyclic = (SVD_CYCLIC*)svd->data;

361:   *explicitmatrix = cyclic->explicitmatrix;
362:   return(0);
363: }

367: /*@
368:    SVDCyclicGetExplicitMatrix - Returns the flag indicating if H(A) is built explicitly

370:    Not Collective

372:    Input Parameter:
373: .  svd  - singular value solver

375:    Output Parameter:
376: .  explicit - the mode flag

378:    Level: advanced

380: .seealso: SVDCyclicSetExplicitMatrix()
381: @*/
382: PetscErrorCode SVDCyclicGetExplicitMatrix(SVD svd,PetscBool *explicitmatrix)
383: {

389:   PetscUseMethod(svd,"SVDCyclicGetExplicitMatrix_C",(SVD,PetscBool*),(svd,explicitmatrix));
390:   return(0);
391: }

395: static PetscErrorCode SVDCyclicSetEPS_Cyclic(SVD svd,EPS eps)
396: {
397:   PetscErrorCode  ierr;
398:   SVD_CYCLIC      *cyclic = (SVD_CYCLIC*)svd->data;

401:   PetscObjectReference((PetscObject)eps);
402:   EPSDestroy(&cyclic->eps);
403:   cyclic->eps = eps;
404:   PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->eps);
405:   svd->state = SVD_STATE_INITIAL;
406:   return(0);
407: }

411: /*@
412:    SVDCyclicSetEPS - Associate an eigensolver object (EPS) to the
413:    singular value solver.

415:    Collective on SVD

417:    Input Parameters:
418: +  svd - singular value solver
419: -  eps - the eigensolver object

421:    Level: advanced

423: .seealso: SVDCyclicGetEPS()
424: @*/
425: PetscErrorCode SVDCyclicSetEPS(SVD svd,EPS eps)
426: {

433:   PetscTryMethod(svd,"SVDCyclicSetEPS_C",(SVD,EPS),(svd,eps));
434:   return(0);
435: }

439: static PetscErrorCode SVDCyclicGetEPS_Cyclic(SVD svd,EPS *eps)
440: {
442:   SVD_CYCLIC     *cyclic = (SVD_CYCLIC*)svd->data;

445:   if (!cyclic->eps) {
446:     EPSCreate(PetscObjectComm((PetscObject)svd),&cyclic->eps);
447:     EPSSetOptionsPrefix(cyclic->eps,((PetscObject)svd)->prefix);
448:     EPSAppendOptionsPrefix(cyclic->eps,"svd_cyclic_");
449:     PetscObjectIncrementTabLevel((PetscObject)cyclic->eps,(PetscObject)svd,1);
450:     PetscLogObjectParent((PetscObject)svd,(PetscObject)cyclic->eps);
451:     EPSSetWhichEigenpairs(cyclic->eps,EPS_LARGEST_REAL);
452:     EPSMonitorSet(cyclic->eps,EPSMonitor_Cyclic,svd,NULL);
453:   }
454:   *eps = cyclic->eps;
455:   return(0);
456: }

460: /*@
461:    SVDCyclicGetEPS - Retrieve the eigensolver object (EPS) associated
462:    to the singular value solver.

464:    Not Collective

466:    Input Parameter:
467: .  svd - singular value solver

469:    Output Parameter:
470: .  eps - the eigensolver object

472:    Level: advanced

474: .seealso: SVDCyclicSetEPS()
475: @*/
476: PetscErrorCode SVDCyclicGetEPS(SVD svd,EPS *eps)
477: {

483:   PetscUseMethod(svd,"SVDCyclicGetEPS_C",(SVD,EPS*),(svd,eps));
484:   return(0);
485: }

489: PetscErrorCode SVDView_Cyclic(SVD svd,PetscViewer viewer)
490: {
492:   SVD_CYCLIC     *cyclic = (SVD_CYCLIC*)svd->data;
493:   PetscBool      isascii;

496:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
497:   if (isascii) {
498:     if (!cyclic->eps) { SVDCyclicGetEPS(svd,&cyclic->eps); }
499:     PetscViewerASCIIPrintf(viewer,"  Cyclic: %s matrix\n",cyclic->explicitmatrix?"explicit":"implicit");
500:     PetscViewerASCIIPushTab(viewer);
501:     EPSView(cyclic->eps,viewer);
502:     PetscViewerASCIIPopTab(viewer);
503:   }
504:   return(0);
505: }

509: PetscErrorCode SVDReset_Cyclic(SVD svd)
510: {
512:   SVD_CYCLIC     *cyclic = (SVD_CYCLIC*)svd->data;

515:   if (!cyclic->eps) { EPSReset(cyclic->eps); }
516:   MatDestroy(&cyclic->mat);
517:   VecDestroy(&cyclic->x1);
518:   VecDestroy(&cyclic->x2);
519:   VecDestroy(&cyclic->y1);
520:   VecDestroy(&cyclic->y2);
521:   return(0);
522: }

526: PetscErrorCode SVDDestroy_Cyclic(SVD svd)
527: {
529:   SVD_CYCLIC     *cyclic = (SVD_CYCLIC*)svd->data;

532:   EPSDestroy(&cyclic->eps);
533:   PetscFree(svd->data);
534:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetEPS_C",NULL);
535:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetEPS_C",NULL);
536:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetExplicitMatrix_C",NULL);
537:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetExplicitMatrix_C",NULL);
538:   return(0);
539: }

543: PETSC_EXTERN PetscErrorCode SVDCreate_Cyclic(SVD svd)
544: {
546:   SVD_CYCLIC     *cyclic;

549:   PetscNewLog(svd,&cyclic);
550:   svd->data                      = (void*)cyclic;
551:   svd->ops->solve                = SVDSolve_Cyclic;
552:   svd->ops->setup                = SVDSetUp_Cyclic;
553:   svd->ops->setfromoptions       = SVDSetFromOptions_Cyclic;
554:   svd->ops->destroy              = SVDDestroy_Cyclic;
555:   svd->ops->reset                = SVDReset_Cyclic;
556:   svd->ops->view                 = SVDView_Cyclic;
557:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetEPS_C",SVDCyclicSetEPS_Cyclic);
558:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetEPS_C",SVDCyclicGetEPS_Cyclic);
559:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicSetExplicitMatrix_C",SVDCyclicSetExplicitMatrix_Cyclic);
560:   PetscObjectComposeFunction((PetscObject)svd,"SVDCyclicGetExplicitMatrix_C",SVDCyclicGetExplicitMatrix_Cyclic);
561:   return(0);
562: }

slepc-3.7.4/src/svd/impls/makefile.html0000644000175000017500000000460113107004621017336 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcsvd
DIRS     = cross cyclic lapack lanczos trlanczos
LOCDIR   = src/svd/impls/
MANSEC   = SVD

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/svd/impls/lapack/0000755000175000017500000000000013107004621016125 5ustar jromanjromanslepc-3.7.4/src/svd/impls/lapack/makefile0000644000175000017500000000216113107004621017625 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = svdlapack.c SOURCEF = SOURCEH = LIBBASE = libslepcsvd DIRS = MANSEC = SVD LOCDIR = src/svd/impls/lapack/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/lapack/makefile.html0000644000175000017500000000466313107004621020601 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = svdlapack.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsvd
DIRS     =
MANSEC   = SVD
LOCDIR   = src/svd/impls/lapack/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/svd/impls/lapack/index.html0000644000175000017500000000275113107004621020127 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

svdlapack.c
makefile
slepc-3.7.4/src/svd/impls/lapack/svdlapack.c0000644000175000017500000001016113107004621020240 0ustar jromanjroman/* This file implements a wrapper to the LAPACK SVD subroutines. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #undef __FUNCT__ #define __FUNCT__ "SVDSetUp_LAPACK" PetscErrorCode SVDSetUp_LAPACK(SVD svd) { PetscErrorCode ierr; PetscInt M,N; PetscFunctionBegin; ierr = SVDMatGetSize(svd,&M,&N);CHKERRQ(ierr); svd->ncv = N; if (svd->mpd) { ierr = PetscInfo(svd,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (svd->stop!=SVD_STOP_BASIC) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined stopping test not supported in this solver"); svd->max_it = 1; svd->leftbasis = PETSC_TRUE; ierr = SVDAllocateSolution(svd,0);CHKERRQ(ierr); ierr = DSSetType(svd->ds,DSSVD);CHKERRQ(ierr); ierr = DSAllocate(svd->ds,PetscMax(M,N));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSolve_LAPACK" PetscErrorCode SVDSolve_LAPACK(SVD svd) { PetscErrorCode ierr; PetscInt M,N,n,i,j,k,ld; Mat mat; Vec u,v; PetscScalar *pU,*pVT,*pmat,*pu,*pv,*A,*w; PetscFunctionBegin; ierr = DSGetLeadingDimension(svd->ds,&ld);CHKERRQ(ierr); ierr = MatConvert(svd->OP,MATSEQDENSE,MAT_INITIAL_MATRIX,&mat);CHKERRQ(ierr); ierr = MatGetSize(mat,&M,&N);CHKERRQ(ierr); ierr = DSSetDimensions(svd->ds,M,N,0,0);CHKERRQ(ierr); ierr = MatDenseGetArray(mat,&pmat);CHKERRQ(ierr); ierr = DSGetArray(svd->ds,DS_MAT_A,&A);CHKERRQ(ierr); for (i=0;ids,DS_MAT_A,&A);CHKERRQ(ierr); ierr = MatDenseRestoreArray(mat,&pmat);CHKERRQ(ierr); ierr = DSSetState(svd->ds,DS_STATE_RAW);CHKERRQ(ierr); n = PetscMin(M,N); ierr = PetscMalloc1(n,&w);CHKERRQ(ierr); ierr = DSSolve(svd->ds,w,NULL);CHKERRQ(ierr); ierr = DSSort(svd->ds,w,NULL,NULL,NULL,NULL);CHKERRQ(ierr); /* copy singular vectors */ ierr = DSGetArray(svd->ds,DS_MAT_U,&pU);CHKERRQ(ierr); ierr = DSGetArray(svd->ds,DS_MAT_VT,&pVT);CHKERRQ(ierr); for (i=0;iwhich == SVD_SMALLEST) k = n - i - 1; else k = i; svd->sigma[k] = PetscRealPart(w[i]); ierr = BVGetColumn(svd->U,k,&u);CHKERRQ(ierr); ierr = BVGetColumn(svd->V,k,&v);CHKERRQ(ierr); ierr = VecGetArray(u,&pu);CHKERRQ(ierr); ierr = VecGetArray(v,&pv);CHKERRQ(ierr); if (M>=N) { for (j=0;jU,k,&u);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,k,&v);CHKERRQ(ierr); } ierr = DSRestoreArray(svd->ds,DS_MAT_U,&pU);CHKERRQ(ierr); ierr = DSRestoreArray(svd->ds,DS_MAT_VT,&pVT);CHKERRQ(ierr); svd->nconv = n; svd->reason = SVD_CONVERGED_TOL; ierr = MatDestroy(&mat);CHKERRQ(ierr); ierr = PetscFree(w);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCreate_LAPACK" PETSC_EXTERN PetscErrorCode SVDCreate_LAPACK(SVD svd) { PetscFunctionBegin; svd->ops->setup = SVDSetUp_LAPACK; svd->ops->solve = SVDSolve_LAPACK; PetscFunctionReturn(0); } slepc-3.7.4/src/svd/impls/lapack/svdlapack.c.html0000644000175000017500000002247113107004621021212 0ustar jromanjroman

Actual source code: svdlapack.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the LAPACK SVD subroutines.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/svdimpl.h>

 28: PetscErrorCode SVDSetUp_LAPACK(SVD svd)
 29: {
 31:   PetscInt       M,N;

 34:   SVDMatGetSize(svd,&M,&N);
 35:   svd->ncv = N;
 36:   if (svd->mpd) { PetscInfo(svd,"Warning: parameter mpd ignored\n"); }
 37:   if (svd->stop!=SVD_STOP_BASIC) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined stopping test not supported in this solver");
 38:   svd->max_it = 1;
 39:   svd->leftbasis = PETSC_TRUE;
 40:   SVDAllocateSolution(svd,0);
 41:   DSSetType(svd->ds,DSSVD);
 42:   DSAllocate(svd->ds,PetscMax(M,N));
 43:   return(0);
 44: }

 48: PetscErrorCode SVDSolve_LAPACK(SVD svd)
 49: {
 51:   PetscInt       M,N,n,i,j,k,ld;
 52:   Mat            mat;
 53:   Vec            u,v;
 54:   PetscScalar    *pU,*pVT,*pmat,*pu,*pv,*A,*w;

 57:   DSGetLeadingDimension(svd->ds,&ld);
 58:   MatConvert(svd->OP,MATSEQDENSE,MAT_INITIAL_MATRIX,&mat);
 59:   MatGetSize(mat,&M,&N);
 60:   DSSetDimensions(svd->ds,M,N,0,0);
 61:   MatDenseGetArray(mat,&pmat);
 62:   DSGetArray(svd->ds,DS_MAT_A,&A);
 63:   for (i=0;i<M;i++)
 64:     for (j=0;j<N;j++)
 65:       A[i+j*ld] = pmat[i+j*M];
 66:   DSRestoreArray(svd->ds,DS_MAT_A,&A);
 67:   MatDenseRestoreArray(mat,&pmat);
 68:   DSSetState(svd->ds,DS_STATE_RAW);

 70:   n = PetscMin(M,N);
 71:   PetscMalloc1(n,&w);
 72:   DSSolve(svd->ds,w,NULL);
 73:   DSSort(svd->ds,w,NULL,NULL,NULL,NULL);

 75:   /* copy singular vectors */
 76:   DSGetArray(svd->ds,DS_MAT_U,&pU);
 77:   DSGetArray(svd->ds,DS_MAT_VT,&pVT);
 78:   for (i=0;i<n;i++) {
 79:     if (svd->which == SVD_SMALLEST) k = n - i - 1;
 80:     else k = i;
 81:     svd->sigma[k] = PetscRealPart(w[i]);
 82:     BVGetColumn(svd->U,k,&u);
 83:     BVGetColumn(svd->V,k,&v);
 84:     VecGetArray(u,&pu);
 85:     VecGetArray(v,&pv);
 86:     if (M>=N) {
 87:       for (j=0;j<M;j++) pu[j] = pU[i*ld+j];
 88:       for (j=0;j<N;j++) pv[j] = PetscConj(pVT[j*ld+i]);
 89:     } else {
 90:       for (j=0;j<N;j++) pu[j] = PetscConj(pVT[j*ld+i]);
 91:       for (j=0;j<M;j++) pv[j] = pU[i*ld+j];
 92:     }
 93:     VecRestoreArray(u,&pu);
 94:     VecRestoreArray(v,&pv);
 95:     BVRestoreColumn(svd->U,k,&u);
 96:     BVRestoreColumn(svd->V,k,&v);
 97:   }
 98:   DSRestoreArray(svd->ds,DS_MAT_U,&pU);
 99:   DSRestoreArray(svd->ds,DS_MAT_VT,&pVT);

101:   svd->nconv = n;
102:   svd->reason = SVD_CONVERGED_TOL;

104:   MatDestroy(&mat);
105:   PetscFree(w);
106:   return(0);
107: }

111: PETSC_EXTERN PetscErrorCode SVDCreate_LAPACK(SVD svd)
112: {
114:   svd->ops->setup   = SVDSetUp_LAPACK;
115:   svd->ops->solve   = SVDSolve_LAPACK;
116:   return(0);
117: }

slepc-3.7.4/src/svd/impls/lanczos/0000755000175000017500000000000013107004621016343 5ustar jromanjromanslepc-3.7.4/src/svd/impls/lanczos/makefile0000644000175000017500000000216213107004621020044 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = gklanczos.c SOURCEF = SOURCEH = LIBBASE = libslepcsvd DIRS = MANSEC = SVD LOCDIR = src/svd/impls/lanczos/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/lanczos/gklanczos.c.html0000644000175000017500000010173713107004621021456 0ustar jromanjroman
Actual source code: gklanczos.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc singular value solver: "lanczos"

  5:    Method: Explicitly restarted Lanczos

  7:    Algorithm:

  9:        Golub-Kahan-Lanczos bidiagonalization with explicit restart.

 11:    References:

 13:        [1] G.H. Golub and W. Kahan, "Calculating the singular values
 14:            and pseudo-inverse of a matrix", SIAM J. Numer. Anal. Ser.
 15:            B 2:205-224, 1965.

 17:        [2] V. Hernandez, J.E. Roman, and A. Tomas, "A robust and
 18:            efficient parallel SVD solver based on restarted Lanczos
 19:            bidiagonalization", Elec. Trans. Numer. Anal. 31:68-85,
 20:            2008.

 22:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 23:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 24:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 26:    This file is part of SLEPc.

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

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

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

 42: #include <slepc/private/svdimpl.h>                /*I "slepcsvd.h" I*/

 44: typedef struct {
 45:   PetscBool oneside;
 46: } SVD_LANCZOS;

 50: PetscErrorCode SVDSetUp_Lanczos(SVD svd)
 51: {
 53:   SVD_LANCZOS    *lanczos = (SVD_LANCZOS*)svd->data;
 54:   PetscInt       N;

 57:   SVDMatGetSize(svd,NULL,&N);
 58:   SVDSetDimensions_Default(svd);
 59:   if (svd->ncv>svd->nsv+svd->mpd) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The value of ncv must not be larger than nev+mpd");
 60:   if (!svd->max_it) svd->max_it = PetscMax(N/svd->ncv,100);
 61:   svd->leftbasis = PetscNot(lanczos->oneside);
 62:   SVDAllocateSolution(svd,1);
 63:   DSSetType(svd->ds,DSSVD);
 64:   DSSetCompact(svd->ds,PETSC_TRUE);
 65:   DSAllocate(svd->ds,svd->ncv);
 66:   return(0);
 67: }

 71: PetscErrorCode SVDTwoSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt k,PetscInt n)
 72: {
 74:   PetscInt       i;
 75:   Vec            u,v;

 78:   BVGetColumn(svd->V,k,&v);
 79:   BVGetColumn(svd->U,k,&u);
 80:   SVDMatMult(svd,PETSC_FALSE,v,u);
 81:   BVRestoreColumn(svd->V,k,&v);
 82:   BVRestoreColumn(svd->U,k,&u);
 83:   BVOrthogonalizeColumn(svd->U,k,NULL,alpha+k,NULL);
 84:   BVScaleColumn(U,k,1.0/alpha[k]);

 86:   for (i=k+1;i<n;i++) {
 87:     BVGetColumn(svd->V,i,&v);
 88:     BVGetColumn(svd->U,i-1,&u);
 89:     SVDMatMult(svd,PETSC_TRUE,u,v);
 90:     BVRestoreColumn(svd->V,i,&v);
 91:     BVRestoreColumn(svd->U,i-1,&u);
 92:     BVOrthogonalizeColumn(svd->V,i,NULL,beta+i-1,NULL);
 93:     BVScaleColumn(V,i,1.0/beta[i-1]);

 95:     BVGetColumn(svd->V,i,&v);
 96:     BVGetColumn(svd->U,i,&u);
 97:     SVDMatMult(svd,PETSC_FALSE,v,u);
 98:     BVRestoreColumn(svd->V,i,&v);
 99:     BVRestoreColumn(svd->U,i,&u);
100:     BVOrthogonalizeColumn(svd->U,i,NULL,alpha+i,NULL);
101:     BVScaleColumn(U,i,1.0/alpha[i]);
102:   }

104:   BVGetColumn(svd->V,n,&v);
105:   BVGetColumn(svd->U,n-1,&u);
106:   SVDMatMult(svd,PETSC_TRUE,u,v);
107:   BVRestoreColumn(svd->V,n,&v);
108:   BVRestoreColumn(svd->U,n-1,&u);
109:   BVOrthogonalizeColumn(svd->V,n,NULL,beta+n-1,NULL);
110:   return(0);
111: }

115: static PetscErrorCode SVDOneSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,Vec u,Vec u_1,PetscInt k,PetscInt n,PetscScalar* work)
116: {
118:   PetscInt       i,bvl,bvk;
119:   PetscReal      a,b;
120:   Vec            z,temp;

123:   BVGetActiveColumns(V,&bvl,&bvk);
124:   BVGetColumn(V,k,&z);
125:   SVDMatMult(svd,PETSC_FALSE,z,u);
126:   BVRestoreColumn(V,k,&z);

128:   for (i=k+1;i<n;i++) {
129:     BVGetColumn(V,i,&z);
130:     SVDMatMult(svd,PETSC_TRUE,u,z);
131:     BVRestoreColumn(V,i,&z);
132:     VecNormBegin(u,NORM_2,&a);
133:     BVSetActiveColumns(V,0,i);
134:     BVDotColumnBegin(V,i,work);
135:     VecNormEnd(u,NORM_2,&a);
136:     BVDotColumnEnd(V,i,work);
137:     VecScale(u,1.0/a);
138:     BVMultColumn(V,-1.0/a,1.0/a,i,work);

140:     /* h = V^* z, z = z - V h  */
141:     BVDotColumn(V,i,work);
142:     BVMultColumn(V,-1.0,1.0,i,work);
143:     BVNormColumn(V,i,NORM_2,&b);
144:     if (PetscAbsReal(b)<10*PETSC_MACHINE_EPSILON) SETERRQ(PETSC_COMM_SELF,1,"Recurrence generated a zero vector; use a two-sided variant");
145:     BVScaleColumn(V,i,1.0/b);

147:     BVGetColumn(V,i,&z);
148:     SVDMatMult(svd,PETSC_FALSE,z,u_1);
149:     BVRestoreColumn(V,i,&z);
150:     VecAXPY(u_1,-b,u);
151:     alpha[i-1] = a;
152:     beta[i-1] = b;
153:     temp = u;
154:     u = u_1;
155:     u_1 = temp;
156:   }

158:   BVGetColumn(V,n,&z);
159:   SVDMatMult(svd,PETSC_TRUE,u,z);
160:   BVRestoreColumn(V,n,&z);
161:   VecNormBegin(u,NORM_2,&a);
162:   BVDotColumnBegin(V,n,work);
163:   VecNormEnd(u,NORM_2,&a);
164:   BVDotColumnEnd(V,n,work);
165:   VecScale(u,1.0/a);
166:   BVMultColumn(V,-1.0/a,1.0/a,n,work);

168:   /* h = V^* z, z = z - V h  */
169:   BVDotColumn(V,n,work);
170:   BVMultColumn(V,-1.0,1.0,n,work);
171:   BVNormColumn(V,i,NORM_2,&b);

173:   alpha[n-1] = a;
174:   beta[n-1] = b;
175:   BVSetActiveColumns(V,bvl,bvk);
176:   return(0);
177: }

181: PetscErrorCode SVDSolve_Lanczos(SVD svd)
182: {
184:   SVD_LANCZOS    *lanczos = (SVD_LANCZOS*)svd->data;
185:   PetscReal      *alpha,*beta,lastbeta,norm,resnorm;
186:   PetscScalar    *swork,*w,*Q,*PT;
187:   PetscInt       i,k,j,nv,ld;
188:   Vec            u=0,u_1=0;
189:   Mat            U,VT;
190:   PetscBool      conv;

193:   /* allocate working space */
194:   DSGetLeadingDimension(svd->ds,&ld);
195:   PetscMalloc2(ld,&w,svd->ncv,&swork);

197:   if (lanczos->oneside) {
198:     SVDMatCreateVecs(svd,NULL,&u);
199:     SVDMatCreateVecs(svd,NULL,&u_1);
200:   }

202:   /* normalize start vector */
203:   if (!svd->nini) {
204:     BVSetRandomColumn(svd->V,0);
205:     BVNormColumn(svd->V,0,NORM_2,&norm);
206:     BVScaleColumn(svd->V,0,1.0/norm);
207:   }

209:   while (svd->reason == SVD_CONVERGED_ITERATING) {
210:     svd->its++;

212:     /* inner loop */
213:     nv = PetscMin(svd->nconv+svd->mpd,svd->ncv);
214:     BVSetActiveColumns(svd->V,svd->nconv,nv);
215:     DSGetArrayReal(svd->ds,DS_MAT_T,&alpha);
216:     beta = alpha + ld;
217:     if (lanczos->oneside) {
218:       SVDOneSideLanczos(svd,alpha,beta,svd->V,u,u_1,svd->nconv,nv,swork);
219:     } else {
220:       BVSetActiveColumns(svd->U,svd->nconv,nv);
221:       SVDTwoSideLanczos(svd,alpha,beta,svd->V,svd->U,svd->nconv,nv);
222:     }
223:     lastbeta = beta[nv-1];
224:     DSRestoreArrayReal(svd->ds,DS_MAT_T,&alpha);

226:     /* compute SVD of bidiagonal matrix */
227:     DSSetDimensions(svd->ds,nv,nv,svd->nconv,0);
228:     DSSetState(svd->ds,DS_STATE_INTERMEDIATE);
229:     DSSolve(svd->ds,w,NULL);
230:     DSSort(svd->ds,w,NULL,NULL,NULL,NULL);

232:     /* compute error estimates */
233:     k = 0;
234:     conv = PETSC_TRUE;
235:     DSGetArray(svd->ds,DS_MAT_U,&Q);
236:     for (i=svd->nconv;i<nv;i++) {
237:       svd->sigma[i] = PetscRealPart(w[i]);
238:       resnorm = PetscAbsScalar(Q[nv-1+i*ld])*lastbeta;
239:       (*svd->converged)(svd,svd->sigma[i],resnorm,&svd->errest[i],svd->convergedctx);
240:       if (conv) {
241:         if (svd->errest[i] < svd->tol) k++;
242:         else conv = PETSC_FALSE;
243:       }
244:     }
245:     DSRestoreArray(svd->ds,DS_MAT_U,&Q);

247:     /* check convergence */
248:     (*svd->stopping)(svd,svd->its,svd->max_it,svd->nconv+k,svd->nsv,&svd->reason,svd->stoppingctx);

250:     /* compute restart vector */
251:     DSGetArray(svd->ds,DS_MAT_VT,&PT);
252:     if (svd->reason == SVD_CONVERGED_ITERATING) {
253:       for (j=svd->nconv;j<nv;j++) swork[j-svd->nconv] = PT[k+svd->nconv+j*ld];
254:       BVMultColumn(svd->V,1.0,0.0,nv,swork);
255:     }
256:     DSRestoreArray(svd->ds,DS_MAT_VT,&PT);

258:     /* compute converged singular vectors */
259:     DSGetMat(svd->ds,DS_MAT_VT,&VT);
260:     BVMultInPlaceTranspose(svd->V,VT,svd->nconv,svd->nconv+k);
261:     MatDestroy(&VT);
262:     if (!lanczos->oneside) {
263:       DSGetMat(svd->ds,DS_MAT_U,&U);
264:       BVMultInPlace(svd->U,U,svd->nconv,svd->nconv+k);
265:       MatDestroy(&U);
266:     }

268:     /* copy restart vector from the last column */
269:     if (svd->reason == SVD_CONVERGED_ITERATING) {
270:       BVCopyColumn(svd->V,nv,svd->nconv+k);
271:     }

273:     svd->nconv += k;
274:     SVDMonitor(svd,svd->its,svd->nconv,svd->sigma,svd->errest,nv);
275:   }

277:   /* free working space */
278:   VecDestroy(&u);
279:   VecDestroy(&u_1);
280:   PetscFree2(w,swork);
281:   return(0);
282: }

286: PetscErrorCode SVDSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,SVD svd)
287: {
289:   PetscBool      set,val;
290:   SVD_LANCZOS    *lanczos = (SVD_LANCZOS*)svd->data;

293:   PetscOptionsHead(PetscOptionsObject,"SVD Lanczos Options");
294:   PetscOptionsBool("-svd_lanczos_oneside","Lanczos one-side reorthogonalization","SVDLanczosSetOneSide",lanczos->oneside,&val,&set);
295:   if (set) {
296:     SVDLanczosSetOneSide(svd,val);
297:   }
298:   PetscOptionsTail();
299:   return(0);
300: }

304: static PetscErrorCode SVDLanczosSetOneSide_Lanczos(SVD svd,PetscBool oneside)
305: {
306:   SVD_LANCZOS *lanczos = (SVD_LANCZOS*)svd->data;

309:   if (lanczos->oneside != oneside) {
310:     lanczos->oneside = oneside;
311:     svd->state = SVD_STATE_INITIAL;
312:   }
313:   return(0);
314: }

318: /*@
319:    SVDLanczosSetOneSide - Indicate if the variant of the Lanczos method
320:    to be used is one-sided or two-sided.

322:    Logically Collective on SVD

324:    Input Parameters:
325: +  svd     - singular value solver
326: -  oneside - boolean flag indicating if the method is one-sided or not

328:    Options Database Key:
329: .  -svd_lanczos_oneside <boolean> - Indicates the boolean flag

331:    Note:
332:    By default, a two-sided variant is selected, which is sometimes slightly
333:    more robust. However, the one-sided variant is faster because it avoids
334:    the orthogonalization associated to left singular vectors. It also saves
335:    the memory required for storing such vectors.

337:    Level: advanced

339: .seealso: SVDTRLanczosSetOneSide()
340: @*/
341: PetscErrorCode SVDLanczosSetOneSide(SVD svd,PetscBool oneside)
342: {

348:   PetscTryMethod(svd,"SVDLanczosSetOneSide_C",(SVD,PetscBool),(svd,oneside));
349:   return(0);
350: }

354: static PetscErrorCode SVDLanczosGetOneSide_Lanczos(SVD svd,PetscBool *oneside)
355: {
356:   SVD_LANCZOS *lanczos = (SVD_LANCZOS*)svd->data;

359:   *oneside = lanczos->oneside;
360:   return(0);
361: }

365: /*@
366:    SVDLanczosGetOneSide - Gets if the variant of the Lanczos method
367:    to be used is one-sided or two-sided.

369:    Not Collective

371:    Input Parameters:
372: .  svd     - singular value solver

374:    Output Parameters:
375: .  oneside - boolean flag indicating if the method is one-sided or not

377:    Level: advanced

379: .seealso: SVDLanczosSetOneSide()
380: @*/
381: PetscErrorCode SVDLanczosGetOneSide(SVD svd,PetscBool *oneside)
382: {

388:   PetscUseMethod(svd,"SVDLanczosGetOneSide_C",(SVD,PetscBool*),(svd,oneside));
389:   return(0);
390: }

394: PetscErrorCode SVDDestroy_Lanczos(SVD svd)
395: {

399:   PetscFree(svd->data);
400:   PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosSetOneSide_C",NULL);
401:   PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosGetOneSide_C",NULL);
402:   return(0);
403: }

407: PetscErrorCode SVDView_Lanczos(SVD svd,PetscViewer viewer)
408: {
410:   SVD_LANCZOS    *lanczos = (SVD_LANCZOS*)svd->data;
411:   PetscBool      isascii;

414:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
415:   if (isascii) {
416:     PetscViewerASCIIPrintf(viewer,"  Lanczos: %s-sided reorthogonalization\n",lanczos->oneside? "one": "two");
417:   }
418:   return(0);
419: }

423: PETSC_EXTERN PetscErrorCode SVDCreate_Lanczos(SVD svd)
424: {
426:   SVD_LANCZOS    *ctx;

429:   PetscNewLog(svd,&ctx);
430:   svd->data = (void*)ctx;

432:   svd->ops->setup          = SVDSetUp_Lanczos;
433:   svd->ops->solve          = SVDSolve_Lanczos;
434:   svd->ops->destroy        = SVDDestroy_Lanczos;
435:   svd->ops->setfromoptions = SVDSetFromOptions_Lanczos;
436:   svd->ops->view           = SVDView_Lanczos;
437:   PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosSetOneSide_C",SVDLanczosSetOneSide_Lanczos);
438:   PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosGetOneSide_C",SVDLanczosGetOneSide_Lanczos);
439:   return(0);
440: }

slepc-3.7.4/src/svd/impls/lanczos/makefile.html0000644000175000017500000000466613107004621021022 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = gklanczos.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsvd
DIRS     =
MANSEC   = SVD
LOCDIR   = src/svd/impls/lanczos/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/svd/impls/lanczos/index.html0000644000175000017500000000275313107004621020347 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

gklanczos.c
makefile
slepc-3.7.4/src/svd/impls/lanczos/gklanczos.c0000644000175000017500000003613613107004621020513 0ustar jromanjroman/* SLEPc singular value solver: "lanczos" Method: Explicitly restarted Lanczos Algorithm: Golub-Kahan-Lanczos bidiagonalization with explicit restart. References: [1] G.H. Golub and W. Kahan, "Calculating the singular values and pseudo-inverse of a matrix", SIAM J. Numer. Anal. Ser. B 2:205-224, 1965. [2] V. Hernandez, J.E. Roman, and A. Tomas, "A robust and efficient parallel SVD solver based on restarted Lanczos bidiagonalization", Elec. Trans. Numer. Anal. 31:68-85, 2008. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ typedef struct { PetscBool oneside; } SVD_LANCZOS; #undef __FUNCT__ #define __FUNCT__ "SVDSetUp_Lanczos" PetscErrorCode SVDSetUp_Lanczos(SVD svd) { PetscErrorCode ierr; SVD_LANCZOS *lanczos = (SVD_LANCZOS*)svd->data; PetscInt N; PetscFunctionBegin; ierr = SVDMatGetSize(svd,NULL,&N);CHKERRQ(ierr); ierr = SVDSetDimensions_Default(svd);CHKERRQ(ierr); if (svd->ncv>svd->nsv+svd->mpd) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The value of ncv must not be larger than nev+mpd"); if (!svd->max_it) svd->max_it = PetscMax(N/svd->ncv,100); svd->leftbasis = PetscNot(lanczos->oneside); ierr = SVDAllocateSolution(svd,1);CHKERRQ(ierr); ierr = DSSetType(svd->ds,DSSVD);CHKERRQ(ierr); ierr = DSSetCompact(svd->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(svd->ds,svd->ncv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDTwoSideLanczos" PetscErrorCode SVDTwoSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt k,PetscInt n) { PetscErrorCode ierr; PetscInt i; Vec u,v; PetscFunctionBegin; ierr = BVGetColumn(svd->V,k,&v);CHKERRQ(ierr); ierr = BVGetColumn(svd->U,k,&u);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_FALSE,v,u);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,k,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->U,k,&u);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(svd->U,k,NULL,alpha+k,NULL);CHKERRQ(ierr); ierr = BVScaleColumn(U,k,1.0/alpha[k]);CHKERRQ(ierr); for (i=k+1;iV,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(svd->U,i-1,&u);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_TRUE,u,v);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->U,i-1,&u);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(svd->V,i,NULL,beta+i-1,NULL);CHKERRQ(ierr); ierr = BVScaleColumn(V,i,1.0/beta[i-1]);CHKERRQ(ierr); ierr = BVGetColumn(svd->V,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(svd->U,i,&u);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_FALSE,v,u);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->U,i,&u);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(svd->U,i,NULL,alpha+i,NULL);CHKERRQ(ierr); ierr = BVScaleColumn(U,i,1.0/alpha[i]);CHKERRQ(ierr); } ierr = BVGetColumn(svd->V,n,&v);CHKERRQ(ierr); ierr = BVGetColumn(svd->U,n-1,&u);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_TRUE,u,v);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,n,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->U,n-1,&u);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(svd->V,n,NULL,beta+n-1,NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDOneSideLanczos" static PetscErrorCode SVDOneSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,Vec u,Vec u_1,PetscInt k,PetscInt n,PetscScalar* work) { PetscErrorCode ierr; PetscInt i,bvl,bvk; PetscReal a,b; Vec z,temp; PetscFunctionBegin; ierr = BVGetActiveColumns(V,&bvl,&bvk);CHKERRQ(ierr); ierr = BVGetColumn(V,k,&z);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_FALSE,z,u);CHKERRQ(ierr); ierr = BVRestoreColumn(V,k,&z);CHKERRQ(ierr); for (i=k+1;idata; PetscReal *alpha,*beta,lastbeta,norm,resnorm; PetscScalar *swork,*w,*Q,*PT; PetscInt i,k,j,nv,ld; Vec u=0,u_1=0; Mat U,VT; PetscBool conv; PetscFunctionBegin; /* allocate working space */ ierr = DSGetLeadingDimension(svd->ds,&ld);CHKERRQ(ierr); ierr = PetscMalloc2(ld,&w,svd->ncv,&swork);CHKERRQ(ierr); if (lanczos->oneside) { ierr = SVDMatCreateVecs(svd,NULL,&u);CHKERRQ(ierr); ierr = SVDMatCreateVecs(svd,NULL,&u_1);CHKERRQ(ierr); } /* normalize start vector */ if (!svd->nini) { ierr = BVSetRandomColumn(svd->V,0);CHKERRQ(ierr); ierr = BVNormColumn(svd->V,0,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(svd->V,0,1.0/norm);CHKERRQ(ierr); } while (svd->reason == SVD_CONVERGED_ITERATING) { svd->its++; /* inner loop */ nv = PetscMin(svd->nconv+svd->mpd,svd->ncv); ierr = BVSetActiveColumns(svd->V,svd->nconv,nv);CHKERRQ(ierr); ierr = DSGetArrayReal(svd->ds,DS_MAT_T,&alpha);CHKERRQ(ierr); beta = alpha + ld; if (lanczos->oneside) { ierr = SVDOneSideLanczos(svd,alpha,beta,svd->V,u,u_1,svd->nconv,nv,swork);CHKERRQ(ierr); } else { ierr = BVSetActiveColumns(svd->U,svd->nconv,nv);CHKERRQ(ierr); ierr = SVDTwoSideLanczos(svd,alpha,beta,svd->V,svd->U,svd->nconv,nv);CHKERRQ(ierr); } lastbeta = beta[nv-1]; ierr = DSRestoreArrayReal(svd->ds,DS_MAT_T,&alpha);CHKERRQ(ierr); /* compute SVD of bidiagonal matrix */ ierr = DSSetDimensions(svd->ds,nv,nv,svd->nconv,0);CHKERRQ(ierr); ierr = DSSetState(svd->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); ierr = DSSolve(svd->ds,w,NULL);CHKERRQ(ierr); ierr = DSSort(svd->ds,w,NULL,NULL,NULL,NULL);CHKERRQ(ierr); /* compute error estimates */ k = 0; conv = PETSC_TRUE; ierr = DSGetArray(svd->ds,DS_MAT_U,&Q);CHKERRQ(ierr); for (i=svd->nconv;isigma[i] = PetscRealPart(w[i]); resnorm = PetscAbsScalar(Q[nv-1+i*ld])*lastbeta; ierr = (*svd->converged)(svd,svd->sigma[i],resnorm,&svd->errest[i],svd->convergedctx);CHKERRQ(ierr); if (conv) { if (svd->errest[i] < svd->tol) k++; else conv = PETSC_FALSE; } } ierr = DSRestoreArray(svd->ds,DS_MAT_U,&Q);CHKERRQ(ierr); /* check convergence */ ierr = (*svd->stopping)(svd,svd->its,svd->max_it,svd->nconv+k,svd->nsv,&svd->reason,svd->stoppingctx);CHKERRQ(ierr); /* compute restart vector */ ierr = DSGetArray(svd->ds,DS_MAT_VT,&PT);CHKERRQ(ierr); if (svd->reason == SVD_CONVERGED_ITERATING) { for (j=svd->nconv;jnconv] = PT[k+svd->nconv+j*ld]; ierr = BVMultColumn(svd->V,1.0,0.0,nv,swork);CHKERRQ(ierr); } ierr = DSRestoreArray(svd->ds,DS_MAT_VT,&PT);CHKERRQ(ierr); /* compute converged singular vectors */ ierr = DSGetMat(svd->ds,DS_MAT_VT,&VT);CHKERRQ(ierr); ierr = BVMultInPlaceTranspose(svd->V,VT,svd->nconv,svd->nconv+k);CHKERRQ(ierr); ierr = MatDestroy(&VT);CHKERRQ(ierr); if (!lanczos->oneside) { ierr = DSGetMat(svd->ds,DS_MAT_U,&U);CHKERRQ(ierr); ierr = BVMultInPlace(svd->U,U,svd->nconv,svd->nconv+k);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); } /* copy restart vector from the last column */ if (svd->reason == SVD_CONVERGED_ITERATING) { ierr = BVCopyColumn(svd->V,nv,svd->nconv+k);CHKERRQ(ierr); } svd->nconv += k; ierr = SVDMonitor(svd,svd->its,svd->nconv,svd->sigma,svd->errest,nv);CHKERRQ(ierr); } /* free working space */ ierr = VecDestroy(&u);CHKERRQ(ierr); ierr = VecDestroy(&u_1);CHKERRQ(ierr); ierr = PetscFree2(w,swork);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetFromOptions_Lanczos" PetscErrorCode SVDSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,SVD svd) { PetscErrorCode ierr; PetscBool set,val; SVD_LANCZOS *lanczos = (SVD_LANCZOS*)svd->data; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"SVD Lanczos Options");CHKERRQ(ierr); ierr = PetscOptionsBool("-svd_lanczos_oneside","Lanczos one-side reorthogonalization","SVDLanczosSetOneSide",lanczos->oneside,&val,&set);CHKERRQ(ierr); if (set) { ierr = SVDLanczosSetOneSide(svd,val);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDLanczosSetOneSide_Lanczos" static PetscErrorCode SVDLanczosSetOneSide_Lanczos(SVD svd,PetscBool oneside) { SVD_LANCZOS *lanczos = (SVD_LANCZOS*)svd->data; PetscFunctionBegin; if (lanczos->oneside != oneside) { lanczos->oneside = oneside; svd->state = SVD_STATE_INITIAL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDLanczosSetOneSide" /*@ SVDLanczosSetOneSide - Indicate if the variant of the Lanczos method to be used is one-sided or two-sided. Logically Collective on SVD Input Parameters: + svd - singular value solver - oneside - boolean flag indicating if the method is one-sided or not Options Database Key: . -svd_lanczos_oneside - Indicates the boolean flag Note: By default, a two-sided variant is selected, which is sometimes slightly more robust. However, the one-sided variant is faster because it avoids the orthogonalization associated to left singular vectors. It also saves the memory required for storing such vectors. Level: advanced .seealso: SVDTRLanczosSetOneSide() @*/ PetscErrorCode SVDLanczosSetOneSide(SVD svd,PetscBool oneside) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveBool(svd,oneside,2); ierr = PetscTryMethod(svd,"SVDLanczosSetOneSide_C",(SVD,PetscBool),(svd,oneside));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDLanczosGetOneSide_Lanczos" static PetscErrorCode SVDLanczosGetOneSide_Lanczos(SVD svd,PetscBool *oneside) { SVD_LANCZOS *lanczos = (SVD_LANCZOS*)svd->data; PetscFunctionBegin; *oneside = lanczos->oneside; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDLanczosGetOneSide" /*@ SVDLanczosGetOneSide - Gets if the variant of the Lanczos method to be used is one-sided or two-sided. Not Collective Input Parameters: . svd - singular value solver Output Parameters: . oneside - boolean flag indicating if the method is one-sided or not Level: advanced .seealso: SVDLanczosSetOneSide() @*/ PetscErrorCode SVDLanczosGetOneSide(SVD svd,PetscBool *oneside) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(oneside,2); ierr = PetscUseMethod(svd,"SVDLanczosGetOneSide_C",(SVD,PetscBool*),(svd,oneside));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDDestroy_Lanczos" PetscErrorCode SVDDestroy_Lanczos(SVD svd) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(svd->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosSetOneSide_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosGetOneSide_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDView_Lanczos" PetscErrorCode SVDView_Lanczos(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; SVD_LANCZOS *lanczos = (SVD_LANCZOS*)svd->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," Lanczos: %s-sided reorthogonalization\n",lanczos->oneside? "one": "two");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCreate_Lanczos" PETSC_EXTERN PetscErrorCode SVDCreate_Lanczos(SVD svd) { PetscErrorCode ierr; SVD_LANCZOS *ctx; PetscFunctionBegin; ierr = PetscNewLog(svd,&ctx);CHKERRQ(ierr); svd->data = (void*)ctx; svd->ops->setup = SVDSetUp_Lanczos; svd->ops->solve = SVDSolve_Lanczos; svd->ops->destroy = SVDDestroy_Lanczos; svd->ops->setfromoptions = SVDSetFromOptions_Lanczos; svd->ops->view = SVDView_Lanczos; ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosSetOneSide_C",SVDLanczosSetOneSide_Lanczos);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDLanczosGetOneSide_C",SVDLanczosGetOneSide_Lanczos);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/svd/impls/lanczos/ftn-auto/0000755000175000017500000000000013107004621020100 5ustar jromanjromanslepc-3.7.4/src/svd/impls/lanczos/ftn-auto/makefile0000644000175000017500000000036513107004621021604 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = gklanczosf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsvd LOCDIR = src/svd/impls/lanczos/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/lanczos/ftn-auto/gklanczosf.c0000644000175000017500000000276613107004621022420 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* gklanczos.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdlanczossetoneside_ SVDLANCZOSSETONESIDE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdlanczossetoneside_ svdlanczossetoneside #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdlanczosgetoneside_ SVDLANCZOSGETONESIDE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdlanczosgetoneside_ svdlanczosgetoneside #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdlanczossetoneside_(SVD svd,PetscBool *oneside, int *__ierr ){ *__ierr = SVDLanczosSetOneSide( (SVD)PetscToPointer((svd) ),*oneside); } PETSC_EXTERN void PETSC_STDCALL svdlanczosgetoneside_(SVD svd,PetscBool *oneside, int *__ierr ){ *__ierr = SVDLanczosGetOneSide( (SVD)PetscToPointer((svd) ),oneside); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/impls/cross/0000755000175000017500000000000013107004621016023 5ustar jromanjromanslepc-3.7.4/src/svd/impls/cross/makefile0000644000175000017500000000215213107004621017523 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = cross.c SOURCEF = SOURCEH = LIBBASE = libslepcsvd DIRS = MANSEC = SVD LOCDIR = src/svd/impls/cross/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/cross/makefile.html0000644000175000017500000000465213107004621020475 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = cross.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsvd
DIRS     =
MANSEC   = SVD
LOCDIR   = src/svd/impls/cross/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/svd/impls/cross/index.html0000644000175000017500000000273713107004621020031 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

cross.c
makefile
slepc-3.7.4/src/svd/impls/cross/cross.c0000644000175000017500000003403613107004621017326 0ustar jromanjroman/* SLEPc singular value solver: "cross" Method: Uses a Hermitian eigensolver for A^T*A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ #include /*I "slepceps.h" I*/ typedef struct { EPS eps; Mat mat; Vec w,diag; } SVD_CROSS; #undef __FUNCT__ #define __FUNCT__ "MatMult_Cross" static PetscErrorCode MatMult_Cross(Mat B,Vec x,Vec y) { PetscErrorCode ierr; SVD svd; SVD_CROSS *cross; PetscFunctionBegin; ierr = MatShellGetContext(B,(void**)&svd);CHKERRQ(ierr); cross = (SVD_CROSS*)svd->data; ierr = SVDMatMult(svd,PETSC_FALSE,x,cross->w);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_TRUE,cross->w,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateVecs_Cross" static PetscErrorCode MatCreateVecs_Cross(Mat B,Vec *right,Vec *left) { PetscErrorCode ierr; SVD svd; PetscFunctionBegin; ierr = MatShellGetContext(B,(void**)&svd);CHKERRQ(ierr); if (right) { ierr = SVDMatCreateVecs(svd,right,NULL);CHKERRQ(ierr); if (left) { ierr = VecDuplicate(*right,left);CHKERRQ(ierr); } } else { ierr = SVDMatCreateVecs(svd,left,NULL);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatGetDiagonal_Cross" static PetscErrorCode MatGetDiagonal_Cross(Mat B,Vec d) { PetscErrorCode ierr; SVD svd; SVD_CROSS *cross; PetscMPIInt len; PetscInt N,n,i,j,start,end,ncols; PetscScalar *work1,*work2,*diag; const PetscInt *cols; const PetscScalar *vals; PetscFunctionBegin; ierr = MatShellGetContext(B,(void**)&svd);CHKERRQ(ierr); cross = (SVD_CROSS*)svd->data; if (!cross->diag) { /* compute diagonal from rows and store in cross->diag */ ierr = VecDuplicate(d,&cross->diag);CHKERRQ(ierr); ierr = SVDMatGetSize(svd,NULL,&N);CHKERRQ(ierr); ierr = SVDMatGetLocalSize(svd,NULL,&n);CHKERRQ(ierr); ierr = PetscMalloc2(N,&work1,N,&work2);CHKERRQ(ierr); for (i=0;iAT) { ierr = MatGetOwnershipRange(svd->AT,&start,&end);CHKERRQ(ierr); for (i=start;iAT,i,&ncols,NULL,&vals);CHKERRQ(ierr); for (j=0;jAT,i,&ncols,NULL,&vals);CHKERRQ(ierr); } } else { ierr = MatGetOwnershipRange(svd->A,&start,&end);CHKERRQ(ierr); for (i=start;iA,i,&ncols,&cols,&vals);CHKERRQ(ierr); for (j=0;jA,i,&ncols,&cols,&vals);CHKERRQ(ierr); } } ierr = PetscMPIIntCast(N,&len);CHKERRQ(ierr); ierr = MPI_Allreduce(work1,work2,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)svd));CHKERRQ(ierr); ierr = VecGetOwnershipRange(cross->diag,&start,&end);CHKERRQ(ierr); ierr = VecGetArray(cross->diag,&diag);CHKERRQ(ierr); for (i=start;idiag,&diag);CHKERRQ(ierr); ierr = PetscFree2(work1,work2);CHKERRQ(ierr); } ierr = VecCopy(cross->diag,d);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetUp_Cross" PetscErrorCode SVDSetUp_Cross(SVD svd) { PetscErrorCode ierr; SVD_CROSS *cross = (SVD_CROSS*)svd->data; PetscInt n; PetscBool trackall; PetscFunctionBegin; if (!cross->mat) { ierr = SVDMatGetLocalSize(svd,NULL,&n);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)svd),n,n,PETSC_DETERMINE,PETSC_DETERMINE,svd,&cross->mat);CHKERRQ(ierr); ierr = MatShellSetOperation(cross->mat,MATOP_MULT,(void(*)(void))MatMult_Cross);CHKERRQ(ierr); ierr = MatShellSetOperation(cross->mat,MATOP_GET_VECS,(void(*)(void))MatCreateVecs_Cross);CHKERRQ(ierr); ierr = MatShellSetOperation(cross->mat,MATOP_GET_DIAGONAL,(void(*)(void))MatGetDiagonal_Cross);CHKERRQ(ierr); ierr = SVDMatCreateVecs(svd,NULL,&cross->w);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->mat);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->w);CHKERRQ(ierr); } if (!cross->eps) { ierr = SVDCrossGetEPS(svd,&cross->eps);CHKERRQ(ierr); } ierr = EPSSetOperators(cross->eps,cross->mat,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(cross->eps,EPS_HEP);CHKERRQ(ierr); ierr = EPSSetWhichEigenpairs(cross->eps,svd->which == SVD_LARGEST ? EPS_LARGEST_REAL : EPS_SMALLEST_REAL);CHKERRQ(ierr); ierr = EPSSetDimensions(cross->eps,svd->nsv,svd->ncv?svd->ncv:PETSC_DEFAULT,svd->mpd?svd->mpd:PETSC_DEFAULT);CHKERRQ(ierr); ierr = EPSSetTolerances(cross->eps,svd->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/10.0:svd->tol,svd->max_it?svd->max_it:PETSC_DEFAULT);CHKERRQ(ierr); switch (svd->conv) { case SVD_CONV_ABS: ierr = EPSSetConvergenceTest(cross->eps,EPS_CONV_ABS);CHKERRQ(ierr);break; case SVD_CONV_REL: ierr = EPSSetConvergenceTest(cross->eps,EPS_CONV_REL);CHKERRQ(ierr);break; case SVD_CONV_USER: SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined convergence test not supported in this solver"); } if (svd->stop!=SVD_STOP_BASIC) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined stopping test not supported in this solver"); /* Transfer the trackall option from svd to eps */ ierr = SVDGetTrackAll(svd,&trackall);CHKERRQ(ierr); ierr = EPSSetTrackAll(cross->eps,trackall);CHKERRQ(ierr); ierr = EPSSetUp(cross->eps);CHKERRQ(ierr); ierr = EPSGetDimensions(cross->eps,NULL,&svd->ncv,&svd->mpd);CHKERRQ(ierr); ierr = EPSGetTolerances(cross->eps,NULL,&svd->max_it);CHKERRQ(ierr); if (svd->tol==PETSC_DEFAULT) svd->tol = SLEPC_DEFAULT_TOL; /* Transfer the initial space from svd to eps */ if (svd->nini < 0) { ierr = EPSSetInitialSpace(cross->eps,-svd->nini,svd->IS);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&svd->nini,&svd->IS);CHKERRQ(ierr); } svd->leftbasis = PETSC_FALSE; ierr = SVDAllocateSolution(svd,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSolve_Cross" PetscErrorCode SVDSolve_Cross(SVD svd) { PetscErrorCode ierr; SVD_CROSS *cross = (SVD_CROSS*)svd->data; PetscInt i; PetscScalar sigma; Vec v; PetscFunctionBegin; ierr = EPSSolve(cross->eps);CHKERRQ(ierr); ierr = EPSGetConverged(cross->eps,&svd->nconv);CHKERRQ(ierr); ierr = EPSGetIterationNumber(cross->eps,&svd->its);CHKERRQ(ierr); ierr = EPSGetConvergedReason(cross->eps,(EPSConvergedReason*)&svd->reason);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = BVGetColumn(svd->V,i,&v);CHKERRQ(ierr); ierr = EPSGetEigenpair(cross->eps,i,&sigma,NULL,v,NULL);CHKERRQ(ierr); ierr = BVRestoreColumn(svd->V,i,&v);CHKERRQ(ierr); if (PetscRealPart(sigma)<0.0) SETERRQ(PetscObjectComm((PetscObject)svd),1,"Negative eigenvalue computed by EPS"); svd->sigma[i] = PetscSqrtReal(PetscRealPart(sigma)); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitor_Cross" static PetscErrorCode EPSMonitor_Cross(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscInt i; SVD svd = (SVD)ctx; PetscScalar er,ei; PetscErrorCode ierr; PetscFunctionBegin; for (i=0;incv);i++) { er = eigr[i]; ei = eigi[i]; ierr = STBackTransform(eps->st,1,&er,&ei);CHKERRQ(ierr); svd->sigma[i] = PetscSqrtReal(PetscRealPart(er)); svd->errest[i] = errest[i]; } ierr = SVDMonitor(svd,its,nconv,svd->sigma,svd->errest,nest);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetFromOptions_Cross" PetscErrorCode SVDSetFromOptions_Cross(PetscOptionItems *PetscOptionsObject,SVD svd) { PetscErrorCode ierr; SVD_CROSS *cross = (SVD_CROSS*)svd->data; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"SVD Cross Options");CHKERRQ(ierr); if (!cross->eps) { ierr = SVDCrossGetEPS(svd,&cross->eps);CHKERRQ(ierr); } ierr = EPSSetFromOptions(cross->eps);CHKERRQ(ierr); ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCrossSetEPS_Cross" static PetscErrorCode SVDCrossSetEPS_Cross(SVD svd,EPS eps) { PetscErrorCode ierr; SVD_CROSS *cross = (SVD_CROSS*)svd->data; PetscFunctionBegin; ierr = PetscObjectReference((PetscObject)eps);CHKERRQ(ierr); ierr = EPSDestroy(&cross->eps);CHKERRQ(ierr); cross->eps = eps; ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->eps);CHKERRQ(ierr); svd->state = SVD_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCrossSetEPS" /*@ SVDCrossSetEPS - Associate an eigensolver object (EPS) to the singular value solver. Collective on SVD Input Parameters: + svd - singular value solver - eps - the eigensolver object Level: advanced .seealso: SVDCrossGetEPS() @*/ PetscErrorCode SVDCrossSetEPS(SVD svd,EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidHeaderSpecific(eps,EPS_CLASSID,2); PetscCheckSameComm(svd,1,eps,2); ierr = PetscTryMethod(svd,"SVDCrossSetEPS_C",(SVD,EPS),(svd,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCrossGetEPS_Cross" static PetscErrorCode SVDCrossGetEPS_Cross(SVD svd,EPS *eps) { SVD_CROSS *cross = (SVD_CROSS*)svd->data; ST st; PetscErrorCode ierr; PetscFunctionBegin; if (!cross->eps) { ierr = EPSCreate(PetscObjectComm((PetscObject)svd),&cross->eps);CHKERRQ(ierr); ierr = EPSSetOptionsPrefix(cross->eps,((PetscObject)svd)->prefix);CHKERRQ(ierr); ierr = EPSAppendOptionsPrefix(cross->eps,"svd_cross_");CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)cross->eps,(PetscObject)svd,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->eps);CHKERRQ(ierr); ierr = EPSSetWhichEigenpairs(cross->eps,EPS_LARGEST_REAL);CHKERRQ(ierr); ierr = EPSMonitorSet(cross->eps,EPSMonitor_Cross,svd,NULL);CHKERRQ(ierr); ierr = EPSGetST(cross->eps,&st);CHKERRQ(ierr); ierr = STSetMatMode(st,ST_MATMODE_SHELL);CHKERRQ(ierr); } *eps = cross->eps; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCrossGetEPS" /*@ SVDCrossGetEPS - Retrieve the eigensolver object (EPS) associated to the singular value solver. Not Collective Input Parameter: . svd - singular value solver Output Parameter: . eps - the eigensolver object Level: advanced .seealso: SVDCrossSetEPS() @*/ PetscErrorCode SVDCrossGetEPS(SVD svd,EPS *eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(eps,2); ierr = PetscUseMethod(svd,"SVDCrossGetEPS_C",(SVD,EPS*),(svd,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDView_Cross" PetscErrorCode SVDView_Cross(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; SVD_CROSS *cross = (SVD_CROSS*)svd->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (!cross->eps) { ierr = SVDCrossGetEPS(svd,&cross->eps);CHKERRQ(ierr); } ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = EPSView(cross->eps,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDReset_Cross" PetscErrorCode SVDReset_Cross(SVD svd) { PetscErrorCode ierr; SVD_CROSS *cross = (SVD_CROSS*)svd->data; PetscFunctionBegin; if (cross->eps) { ierr = EPSReset(cross->eps);CHKERRQ(ierr); } ierr = MatDestroy(&cross->mat);CHKERRQ(ierr); ierr = VecDestroy(&cross->w);CHKERRQ(ierr); ierr = VecDestroy(&cross->diag);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDDestroy_Cross" PetscErrorCode SVDDestroy_Cross(SVD svd) { PetscErrorCode ierr; SVD_CROSS *cross = (SVD_CROSS*)svd->data; PetscFunctionBegin; ierr = EPSDestroy(&cross->eps);CHKERRQ(ierr); ierr = PetscFree(svd->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCrossSetEPS_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCrossGetEPS_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCreate_Cross" PETSC_EXTERN PetscErrorCode SVDCreate_Cross(SVD svd) { PetscErrorCode ierr; SVD_CROSS *cross; PetscFunctionBegin; ierr = PetscNewLog(svd,&cross);CHKERRQ(ierr); svd->data = (void*)cross; svd->ops->solve = SVDSolve_Cross; svd->ops->setup = SVDSetUp_Cross; svd->ops->setfromoptions = SVDSetFromOptions_Cross; svd->ops->destroy = SVDDestroy_Cross; svd->ops->reset = SVDReset_Cross; svd->ops->view = SVDView_Cross; ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCrossSetEPS_C",SVDCrossSetEPS_Cross);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDCrossGetEPS_C",SVDCrossGetEPS_Cross);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/svd/impls/cross/ftn-auto/0000755000175000017500000000000013107004621017560 5ustar jromanjromanslepc-3.7.4/src/svd/impls/cross/ftn-auto/makefile0000644000175000017500000000035713107004621021265 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = crossf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsvd LOCDIR = src/svd/impls/cross/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/cross/ftn-auto/crossf.c0000644000175000017500000000267413107004621021234 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* cross.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcrossseteps_ SVDCROSSSETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcrossseteps_ svdcrossseteps #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdcrossgeteps_ SVDCROSSGETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdcrossgeteps_ svdcrossgeteps #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdcrossseteps_(SVD svd,EPS eps, int *__ierr ){ *__ierr = SVDCrossSetEPS( (SVD)PetscToPointer((svd) ), (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL svdcrossgeteps_(SVD svd,EPS *eps, int *__ierr ){ *__ierr = SVDCrossGetEPS( (SVD)PetscToPointer((svd) ),eps); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/svd/impls/cross/cross.c.html0000644000175000017500000007161513107004621020275 0ustar jromanjroman

Actual source code: cross.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc singular value solver: "cross"

  5:    Method: Uses a Hermitian eigensolver for A^T*A

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

 11:    This file is part of SLEPc.

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

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

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

 27: #include <slepc/private/svdimpl.h>                /*I "slepcsvd.h" I*/
 28: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/

 30: typedef struct {
 31:   EPS       eps;
 32:   Mat       mat;
 33:   Vec       w,diag;
 34: } SVD_CROSS;

 38: static PetscErrorCode MatMult_Cross(Mat B,Vec x,Vec y)
 39: {
 41:   SVD            svd;
 42:   SVD_CROSS      *cross;

 45:   MatShellGetContext(B,(void**)&svd);
 46:   cross = (SVD_CROSS*)svd->data;
 47:   SVDMatMult(svd,PETSC_FALSE,x,cross->w);
 48:   SVDMatMult(svd,PETSC_TRUE,cross->w,y);
 49:   return(0);
 50: }

 54: static PetscErrorCode MatCreateVecs_Cross(Mat B,Vec *right,Vec *left)
 55: {
 57:   SVD            svd;

 60:   MatShellGetContext(B,(void**)&svd);
 61:   if (right) {
 62:     SVDMatCreateVecs(svd,right,NULL);
 63:     if (left) { VecDuplicate(*right,left); }
 64:   } else {
 65:     SVDMatCreateVecs(svd,left,NULL);
 66:   }
 67:   return(0);
 68: }

 72: static PetscErrorCode MatGetDiagonal_Cross(Mat B,Vec d)
 73: {
 74:   PetscErrorCode    ierr;
 75:   SVD               svd;
 76:   SVD_CROSS         *cross;
 77:   PetscMPIInt       len;
 78:   PetscInt          N,n,i,j,start,end,ncols;
 79:   PetscScalar       *work1,*work2,*diag;
 80:   const PetscInt    *cols;
 81:   const PetscScalar *vals;

 84:   MatShellGetContext(B,(void**)&svd);
 85:   cross = (SVD_CROSS*)svd->data;
 86:   if (!cross->diag) {
 87:     /* compute diagonal from rows and store in cross->diag */
 88:     VecDuplicate(d,&cross->diag);
 89:     SVDMatGetSize(svd,NULL,&N);
 90:     SVDMatGetLocalSize(svd,NULL,&n);
 91:     PetscMalloc2(N,&work1,N,&work2);
 92:     for (i=0;i<n;i++) work1[i] = work2[i] = 0.0;
 93:     if (svd->AT) {
 94:       MatGetOwnershipRange(svd->AT,&start,&end);
 95:       for (i=start;i<end;i++) {
 96:         MatGetRow(svd->AT,i,&ncols,NULL,&vals);
 97:         for (j=0;j<ncols;j++)
 98:           work1[i] += vals[j]*vals[j];
 99:         MatRestoreRow(svd->AT,i,&ncols,NULL,&vals);
100:       }
101:     } else {
102:       MatGetOwnershipRange(svd->A,&start,&end);
103:       for (i=start;i<end;i++) {
104:         MatGetRow(svd->A,i,&ncols,&cols,&vals);
105:         for (j=0;j<ncols;j++)
106:           work1[cols[j]] += vals[j]*vals[j];
107:         MatRestoreRow(svd->A,i,&ncols,&cols,&vals);
108:       }
109:     }
110:     PetscMPIIntCast(N,&len);
111:     MPI_Allreduce(work1,work2,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)svd));
112:     VecGetOwnershipRange(cross->diag,&start,&end);
113:     VecGetArray(cross->diag,&diag);
114:     for (i=start;i<end;i++) diag[i-start] = work2[i];
115:     VecRestoreArray(cross->diag,&diag);
116:     PetscFree2(work1,work2);
117:   }
118:   VecCopy(cross->diag,d);
119:   return(0);
120: }

124: PetscErrorCode SVDSetUp_Cross(SVD svd)
125: {
127:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;
128:   PetscInt       n;
129:   PetscBool      trackall;

132:   if (!cross->mat) {
133:     SVDMatGetLocalSize(svd,NULL,&n);
134:     MatCreateShell(PetscObjectComm((PetscObject)svd),n,n,PETSC_DETERMINE,PETSC_DETERMINE,svd,&cross->mat);
135:     MatShellSetOperation(cross->mat,MATOP_MULT,(void(*)(void))MatMult_Cross);
136:     MatShellSetOperation(cross->mat,MATOP_GET_VECS,(void(*)(void))MatCreateVecs_Cross);
137:     MatShellSetOperation(cross->mat,MATOP_GET_DIAGONAL,(void(*)(void))MatGetDiagonal_Cross);
138:     SVDMatCreateVecs(svd,NULL,&cross->w);
139:     PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->mat);
140:     PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->w);
141:   }

143:   if (!cross->eps) { SVDCrossGetEPS(svd,&cross->eps); }
144:   EPSSetOperators(cross->eps,cross->mat,NULL);
145:   EPSSetProblemType(cross->eps,EPS_HEP);
146:   EPSSetWhichEigenpairs(cross->eps,svd->which == SVD_LARGEST ? EPS_LARGEST_REAL : EPS_SMALLEST_REAL);
147:   EPSSetDimensions(cross->eps,svd->nsv,svd->ncv?svd->ncv:PETSC_DEFAULT,svd->mpd?svd->mpd:PETSC_DEFAULT);
148:   EPSSetTolerances(cross->eps,svd->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/10.0:svd->tol,svd->max_it?svd->max_it:PETSC_DEFAULT);
149:   switch (svd->conv) {
150:   case SVD_CONV_ABS:
151:     EPSSetConvergenceTest(cross->eps,EPS_CONV_ABS);break;
152:   case SVD_CONV_REL:
153:     EPSSetConvergenceTest(cross->eps,EPS_CONV_REL);break;
154:   case SVD_CONV_USER:
155:     SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined convergence test not supported in this solver");
156:   }
157:   if (svd->stop!=SVD_STOP_BASIC) SETERRQ(PetscObjectComm((PetscObject)svd),PETSC_ERR_SUP,"User-defined stopping test not supported in this solver");
158:   /* Transfer the trackall option from svd to eps */
159:   SVDGetTrackAll(svd,&trackall);
160:   EPSSetTrackAll(cross->eps,trackall);
161:   EPSSetUp(cross->eps);
162:   EPSGetDimensions(cross->eps,NULL,&svd->ncv,&svd->mpd);
163:   EPSGetTolerances(cross->eps,NULL,&svd->max_it);
164:   if (svd->tol==PETSC_DEFAULT) svd->tol = SLEPC_DEFAULT_TOL;
165:   /* Transfer the initial space from svd to eps */
166:   if (svd->nini < 0) {
167:     EPSSetInitialSpace(cross->eps,-svd->nini,svd->IS);
168:     SlepcBasisDestroy_Private(&svd->nini,&svd->IS);
169:   }
170:   svd->leftbasis = PETSC_FALSE;
171:   SVDAllocateSolution(svd,0);
172:   return(0);
173: }

177: PetscErrorCode SVDSolve_Cross(SVD svd)
178: {
180:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;
181:   PetscInt       i;
182:   PetscScalar    sigma;
183:   Vec            v;

186:   EPSSolve(cross->eps);
187:   EPSGetConverged(cross->eps,&svd->nconv);
188:   EPSGetIterationNumber(cross->eps,&svd->its);
189:   EPSGetConvergedReason(cross->eps,(EPSConvergedReason*)&svd->reason);
190:   for (i=0;i<svd->nconv;i++) {
191:     BVGetColumn(svd->V,i,&v);
192:     EPSGetEigenpair(cross->eps,i,&sigma,NULL,v,NULL);
193:     BVRestoreColumn(svd->V,i,&v);
194:     if (PetscRealPart(sigma)<0.0) SETERRQ(PetscObjectComm((PetscObject)svd),1,"Negative eigenvalue computed by EPS");
195:     svd->sigma[i] = PetscSqrtReal(PetscRealPart(sigma));
196:   }
197:   return(0);
198: }

202: static PetscErrorCode EPSMonitor_Cross(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
203: {
204:   PetscInt       i;
205:   SVD            svd = (SVD)ctx;
206:   PetscScalar    er,ei;

210:   for (i=0;i<PetscMin(nest,svd->ncv);i++) {
211:     er = eigr[i]; ei = eigi[i];
212:     STBackTransform(eps->st,1,&er,&ei);
213:     svd->sigma[i] = PetscSqrtReal(PetscRealPart(er));
214:     svd->errest[i] = errest[i];
215:   }
216:   SVDMonitor(svd,its,nconv,svd->sigma,svd->errest,nest);
217:   return(0);
218: }

222: PetscErrorCode SVDSetFromOptions_Cross(PetscOptionItems *PetscOptionsObject,SVD svd)
223: {
225:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;

228:   PetscOptionsHead(PetscOptionsObject,"SVD Cross Options");
229:   if (!cross->eps) { SVDCrossGetEPS(svd,&cross->eps); }
230:   EPSSetFromOptions(cross->eps);
231:   PetscOptionsTail();
232:   return(0);
233: }

237: static PetscErrorCode SVDCrossSetEPS_Cross(SVD svd,EPS eps)
238: {
240:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;

243:   PetscObjectReference((PetscObject)eps);
244:   EPSDestroy(&cross->eps);
245:   cross->eps = eps;
246:   PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->eps);
247:   svd->state = SVD_STATE_INITIAL;
248:   return(0);
249: }

253: /*@
254:    SVDCrossSetEPS - Associate an eigensolver object (EPS) to the
255:    singular value solver.

257:    Collective on SVD

259:    Input Parameters:
260: +  svd - singular value solver
261: -  eps - the eigensolver object

263:    Level: advanced

265: .seealso: SVDCrossGetEPS()
266: @*/
267: PetscErrorCode SVDCrossSetEPS(SVD svd,EPS eps)
268: {

275:   PetscTryMethod(svd,"SVDCrossSetEPS_C",(SVD,EPS),(svd,eps));
276:   return(0);
277: }

281: static PetscErrorCode SVDCrossGetEPS_Cross(SVD svd,EPS *eps)
282: {
283:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;
284:   ST             st;

288:   if (!cross->eps) {
289:     EPSCreate(PetscObjectComm((PetscObject)svd),&cross->eps);
290:     EPSSetOptionsPrefix(cross->eps,((PetscObject)svd)->prefix);
291:     EPSAppendOptionsPrefix(cross->eps,"svd_cross_");
292:     PetscObjectIncrementTabLevel((PetscObject)cross->eps,(PetscObject)svd,1);
293:     PetscLogObjectParent((PetscObject)svd,(PetscObject)cross->eps);
294:     EPSSetWhichEigenpairs(cross->eps,EPS_LARGEST_REAL);
295:     EPSMonitorSet(cross->eps,EPSMonitor_Cross,svd,NULL);
296:     EPSGetST(cross->eps,&st);
297:     STSetMatMode(st,ST_MATMODE_SHELL);
298:   }
299:   *eps = cross->eps;
300:   return(0);
301: }

305: /*@
306:    SVDCrossGetEPS - Retrieve the eigensolver object (EPS) associated
307:    to the singular value solver.

309:    Not Collective

311:    Input Parameter:
312: .  svd - singular value solver

314:    Output Parameter:
315: .  eps - the eigensolver object

317:    Level: advanced

319: .seealso: SVDCrossSetEPS()
320: @*/
321: PetscErrorCode SVDCrossGetEPS(SVD svd,EPS *eps)
322: {

328:   PetscUseMethod(svd,"SVDCrossGetEPS_C",(SVD,EPS*),(svd,eps));
329:   return(0);
330: }

334: PetscErrorCode SVDView_Cross(SVD svd,PetscViewer viewer)
335: {
337:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;
338:   PetscBool      isascii;

341:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
342:   if (isascii) {
343:     if (!cross->eps) { SVDCrossGetEPS(svd,&cross->eps); }
344:     PetscViewerASCIIPushTab(viewer);
345:     EPSView(cross->eps,viewer);
346:     PetscViewerASCIIPopTab(viewer);
347:   }
348:   return(0);
349: }

353: PetscErrorCode SVDReset_Cross(SVD svd)
354: {
356:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;

359:   if (cross->eps) { EPSReset(cross->eps); }
360:   MatDestroy(&cross->mat);
361:   VecDestroy(&cross->w);
362:   VecDestroy(&cross->diag);
363:   return(0);
364: }

368: PetscErrorCode SVDDestroy_Cross(SVD svd)
369: {
371:   SVD_CROSS      *cross = (SVD_CROSS*)svd->data;

374:   EPSDestroy(&cross->eps);
375:   PetscFree(svd->data);
376:   PetscObjectComposeFunction((PetscObject)svd,"SVDCrossSetEPS_C",NULL);
377:   PetscObjectComposeFunction((PetscObject)svd,"SVDCrossGetEPS_C",NULL);
378:   return(0);
379: }

383: PETSC_EXTERN PetscErrorCode SVDCreate_Cross(SVD svd)
384: {
386:   SVD_CROSS      *cross;

389:   PetscNewLog(svd,&cross);
390:   svd->data = (void*)cross;

392:   svd->ops->solve          = SVDSolve_Cross;
393:   svd->ops->setup          = SVDSetUp_Cross;
394:   svd->ops->setfromoptions = SVDSetFromOptions_Cross;
395:   svd->ops->destroy        = SVDDestroy_Cross;
396:   svd->ops->reset          = SVDReset_Cross;
397:   svd->ops->view           = SVDView_Cross;
398:   PetscObjectComposeFunction((PetscObject)svd,"SVDCrossSetEPS_C",SVDCrossSetEPS_Cross);
399:   PetscObjectComposeFunction((PetscObject)svd,"SVDCrossGetEPS_C",SVDCrossGetEPS_Cross);
400:   return(0);
401: }

slepc-3.7.4/src/svd/impls/index.html0000644000175000017500000000313413107004621016670 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

cross/
cyclic/
lapack/
lanczos/
trlanczos/
makefile
slepc-3.7.4/src/svd/impls/trlanczos/0000755000175000017500000000000013107004621016711 5ustar jromanjromanslepc-3.7.4/src/svd/impls/trlanczos/makefile0000644000175000017500000000216413107004621020414 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = trlanczos.c SOURCEF = SOURCEH = LIBBASE = libslepcsvd DIRS = MANSEC = SVD LOCDIR = src/svd/impls/trlanczos/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/trlanczos/trlanczos.c0000644000175000017500000004615013107004621021102 0ustar jromanjroman/* SLEPc singular value solver: "trlanczos" Method: Thick-restart Lanczos Algorithm: Golub-Kahan-Lanczos bidiagonalization with thick-restart. References: [1] G.H. Golub and W. Kahan, "Calculating the singular values and pseudo-inverse of a matrix", SIAM J. Numer. Anal. Ser. B 2:205-224, 1965. [2] V. Hernandez, J.E. Roman, and A. Tomas, "A robust and efficient parallel SVD solver based on restarted Lanczos bidiagonalization", Elec. Trans. Numer. Anal. 31:68-85, 2008. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsvd.h" I*/ static PetscBool cited = PETSC_FALSE; static const char citation[] = "@Article{slepc-svd,\n" " author = \"V. Hern{\\'a}ndez and J. E. Rom{\\'a}n and A. Tom{\\'a}s\",\n" " title = \"A robust and efficient parallel {SVD} solver based on restarted {Lanczos} bidiagonalization\",\n" " journal = \"Electron. Trans. Numer. Anal.\",\n" " volume = \"31\",\n" " pages = \"68--85\",\n" " year = \"2008\"\n" "}\n"; typedef struct { PetscBool oneside; } SVD_TRLANCZOS; #undef __FUNCT__ #define __FUNCT__ "SVDSetUp_TRLanczos" PetscErrorCode SVDSetUp_TRLanczos(SVD svd) { PetscErrorCode ierr; PetscInt N; PetscFunctionBegin; ierr = SVDMatGetSize(svd,NULL,&N);CHKERRQ(ierr); ierr = SVDSetDimensions_Default(svd);CHKERRQ(ierr); if (svd->ncv>svd->nsv+svd->mpd) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The value of ncv must not be larger than nev+mpd"); if (!svd->max_it) svd->max_it = PetscMax(N/svd->ncv,100); svd->leftbasis = PETSC_TRUE; ierr = SVDAllocateSolution(svd,1);CHKERRQ(ierr); ierr = DSSetType(svd->ds,DSSVD);CHKERRQ(ierr); ierr = DSSetCompact(svd->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(svd->ds,svd->ncv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDOneSideTRLanczosMGS" static PetscErrorCode SVDOneSideTRLanczosMGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work) { PetscErrorCode ierr; PetscReal a,b; PetscInt i,k=nconv+l; Vec ui,ui1,vi; PetscFunctionBegin; ierr = BVGetColumn(V,k,&vi);CHKERRQ(ierr); ierr = BVGetColumn(U,k,&ui);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_FALSE,vi,ui);CHKERRQ(ierr); ierr = BVRestoreColumn(V,k,&vi);CHKERRQ(ierr); ierr = BVRestoreColumn(U,k,&ui);CHKERRQ(ierr); if (l>0) { for (i=0;i0.0) *norm = PetscSqrtReal(*norm); else { ierr = BVNormColumn(V,i,NORM_2,norm);CHKERRQ(ierr); } if (*norm < eta*onorm) { ierr = BVSetActiveColumns(V,0,i);CHKERRQ(ierr); ierr = BVDotColumn(V,i,h);CHKERRQ(ierr); ierr = BVMultColumn(V,-1.0,1.0,i,h);CHKERRQ(ierr); ierr = BVNormColumn(V,i,NORM_2,norm);CHKERRQ(ierr); } break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDOneSideTRLanczosCGS" static PetscErrorCode SVDOneSideTRLanczosCGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work) { PetscErrorCode ierr; PetscReal a,b,eta; PetscInt i,j,k=nconv+l; Vec ui,ui1,vi; BVOrthogRefineType refine; PetscFunctionBegin; ierr = BVGetColumn(V,k,&vi);CHKERRQ(ierr); ierr = BVGetColumn(U,k,&ui);CHKERRQ(ierr); ierr = SVDMatMult(svd,PETSC_FALSE,vi,ui);CHKERRQ(ierr); ierr = BVRestoreColumn(V,k,&vi);CHKERRQ(ierr); ierr = BVRestoreColumn(U,k,&ui);CHKERRQ(ierr); if (l>0) { for (i=0;iU,n-1,NORM_2,&a);CHKERRQ(ierr); if (refine == BV_ORTHOG_REFINE_IFNEEDED) { ierr = BVSetActiveColumns(V,0,n+1);CHKERRQ(ierr); ierr = BVGetColumn(V,n,&vi);CHKERRQ(ierr); ierr = BVDotVecBegin(V,vi,work);CHKERRQ(ierr); } else { ierr = BVSetActiveColumns(V,0,n);CHKERRQ(ierr); ierr = BVDotColumnBegin(V,n,work);CHKERRQ(ierr); } ierr = BVNormColumnEnd(svd->U,n-1,NORM_2,&a);CHKERRQ(ierr); if (refine == BV_ORTHOG_REFINE_IFNEEDED) { ierr = BVDotVecEnd(V,vi,work);CHKERRQ(ierr); ierr = BVRestoreColumn(V,n,&vi);CHKERRQ(ierr); } else { ierr = BVDotColumnEnd(V,n,work);CHKERRQ(ierr); } ierr = BVScaleColumn(U,n-1,1.0/a);CHKERRQ(ierr); for (j=0;jdata; PetscReal *alpha,*beta,lastbeta,norm,resnorm; PetscScalar *Q,*swork=NULL,*w; PetscInt i,k,l,nv,ld; Mat U,VT; PetscBool conv; BVOrthogType orthog; PetscFunctionBegin; ierr = PetscCitationsRegister(citation,&cited);CHKERRQ(ierr); /* allocate working space */ ierr = DSGetLeadingDimension(svd->ds,&ld);CHKERRQ(ierr); ierr = BVGetOrthogonalization(svd->V,&orthog,NULL,NULL,NULL);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&w);CHKERRQ(ierr); if (lanczos->oneside) { ierr = PetscMalloc1(svd->ncv+1,&swork);CHKERRQ(ierr); } /* normalize start vector */ if (!svd->nini) { ierr = BVSetRandomColumn(svd->V,0);CHKERRQ(ierr); ierr = BVNormColumn(svd->V,0,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(svd->V,0,1.0/norm);CHKERRQ(ierr); } l = 0; while (svd->reason == SVD_CONVERGED_ITERATING) { svd->its++; /* inner loop */ nv = PetscMin(svd->nconv+svd->mpd,svd->ncv); ierr = BVSetActiveColumns(svd->V,svd->nconv,nv);CHKERRQ(ierr); ierr = BVSetActiveColumns(svd->U,svd->nconv,nv);CHKERRQ(ierr); ierr = DSGetArrayReal(svd->ds,DS_MAT_T,&alpha);CHKERRQ(ierr); beta = alpha + ld; if (lanczos->oneside) { if (orthog == BV_ORTHOG_MGS) { ierr = SVDOneSideTRLanczosMGS(svd,alpha,beta,svd->V,svd->U,svd->nconv,l,nv,swork);CHKERRQ(ierr); } else { ierr = SVDOneSideTRLanczosCGS(svd,alpha,beta,svd->V,svd->U,svd->nconv,l,nv,swork);CHKERRQ(ierr); } } else { ierr = SVDTwoSideLanczos(svd,alpha,beta,svd->V,svd->U,svd->nconv+l,nv);CHKERRQ(ierr); } lastbeta = beta[nv-1]; ierr = DSRestoreArrayReal(svd->ds,DS_MAT_T,&alpha);CHKERRQ(ierr); ierr = BVScaleColumn(svd->V,nv,1.0/lastbeta);CHKERRQ(ierr); /* compute SVD of general matrix */ ierr = DSSetDimensions(svd->ds,nv,nv,svd->nconv,svd->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(svd->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(svd->ds,DS_STATE_RAW);CHKERRQ(ierr); } ierr = DSSolve(svd->ds,w,NULL);CHKERRQ(ierr); ierr = DSSort(svd->ds,w,NULL,NULL,NULL,NULL);CHKERRQ(ierr); /* compute error estimates */ k = 0; conv = PETSC_TRUE; ierr = DSGetArray(svd->ds,DS_MAT_U,&Q);CHKERRQ(ierr); ierr = DSGetArrayReal(svd->ds,DS_MAT_T,&alpha);CHKERRQ(ierr); beta = alpha + ld; for (i=svd->nconv;isigma[i] = PetscRealPart(w[i]); beta[i] = PetscRealPart(Q[nv-1+i*ld])*lastbeta; resnorm = PetscAbsReal(beta[i]); ierr = (*svd->converged)(svd,svd->sigma[i],resnorm,&svd->errest[i],svd->convergedctx);CHKERRQ(ierr); if (conv) { if (svd->errest[i] < svd->tol) k++; else conv = PETSC_FALSE; } } ierr = DSRestoreArrayReal(svd->ds,DS_MAT_T,&alpha);CHKERRQ(ierr); ierr = DSRestoreArray(svd->ds,DS_MAT_U,&Q);CHKERRQ(ierr); /* check convergence and update l */ ierr = (*svd->stopping)(svd,svd->its,svd->max_it,svd->nconv+k,svd->nsv,&svd->reason,svd->stoppingctx);CHKERRQ(ierr); if (svd->reason != SVD_CONVERGED_ITERATING) l = 0; else l = PetscMax((nv-svd->nconv-k)/2,0); /* compute converged singular vectors and restart vectors */ ierr = DSGetMat(svd->ds,DS_MAT_VT,&VT);CHKERRQ(ierr); ierr = BVMultInPlaceTranspose(svd->V,VT,svd->nconv,svd->nconv+k+l);CHKERRQ(ierr); ierr = MatDestroy(&VT);CHKERRQ(ierr); ierr = DSGetMat(svd->ds,DS_MAT_U,&U);CHKERRQ(ierr); ierr = BVMultInPlace(svd->U,U,svd->nconv,svd->nconv+k+l);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); /* copy the last vector to be the next initial vector */ if (svd->reason == SVD_CONVERGED_ITERATING) { ierr = BVCopyColumn(svd->V,nv,svd->nconv+k+l);CHKERRQ(ierr); } svd->nconv += k; ierr = SVDMonitor(svd,svd->its,svd->nconv,svd->sigma,svd->errest,nv);CHKERRQ(ierr); } /* orthonormalize U columns in one side method */ if (lanczos->oneside) { for (i=0;inconv;i++) { ierr = BVOrthogonalizeColumn(svd->U,i,NULL,&norm,NULL);CHKERRQ(ierr); ierr = BVScaleColumn(svd->U,i,1.0/norm);CHKERRQ(ierr); } } /* free working space */ ierr = PetscFree(w);CHKERRQ(ierr); if (swork) { ierr = PetscFree(swork);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDSetFromOptions_TRLanczos" PetscErrorCode SVDSetFromOptions_TRLanczos(PetscOptionItems *PetscOptionsObject,SVD svd) { PetscErrorCode ierr; PetscBool set,val; SVD_TRLANCZOS *lanczos = (SVD_TRLANCZOS*)svd->data; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"SVD TRLanczos Options");CHKERRQ(ierr); ierr = PetscOptionsBool("-svd_trlanczos_oneside","Lanczos one-side reorthogonalization","SVDTRLanczosSetOneSide",lanczos->oneside,&val,&set);CHKERRQ(ierr); if (set) { ierr = SVDTRLanczosSetOneSide(svd,val);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDTRLanczosSetOneSide_TRLanczos" static PetscErrorCode SVDTRLanczosSetOneSide_TRLanczos(SVD svd,PetscBool oneside) { SVD_TRLANCZOS *lanczos = (SVD_TRLANCZOS*)svd->data; PetscFunctionBegin; lanczos->oneside = oneside; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDTRLanczosSetOneSide" /*@ SVDTRLanczosSetOneSide - Indicate if the variant of the Lanczos method to be used is one-sided or two-sided. Logically Collective on SVD Input Parameters: + svd - singular value solver - oneside - boolean flag indicating if the method is one-sided or not Options Database Key: . -svd_trlanczos_oneside - Indicates the boolean flag Note: By default, a two-sided variant is selected, which is sometimes slightly more robust. However, the one-sided variant is faster because it avoids the orthogonalization associated to left singular vectors. Level: advanced .seealso: SVDLanczosSetOneSide() @*/ PetscErrorCode SVDTRLanczosSetOneSide(SVD svd,PetscBool oneside) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidLogicalCollectiveBool(svd,oneside,2); ierr = PetscTryMethod(svd,"SVDTRLanczosSetOneSide_C",(SVD,PetscBool),(svd,oneside));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDTRLanczosGetOneSide_TRLanczos" static PetscErrorCode SVDTRLanczosGetOneSide_TRLanczos(SVD svd,PetscBool *oneside) { SVD_TRLANCZOS *lanczos = (SVD_TRLANCZOS*)svd->data; PetscFunctionBegin; *oneside = lanczos->oneside; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDTRLanczosGetOneSide" /*@ SVDTRLanczosGetOneSide - Gets if the variant of the Lanczos method to be used is one-sided or two-sided. Not Collective Input Parameters: . svd - singular value solver Output Parameters: . oneside - boolean flag indicating if the method is one-sided or not Level: advanced .seealso: SVDTRLanczosSetOneSide() @*/ PetscErrorCode SVDTRLanczosGetOneSide(SVD svd,PetscBool *oneside) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(svd,SVD_CLASSID,1); PetscValidPointer(oneside,2); ierr = PetscUseMethod(svd,"SVDTRLanczosGetOneSide_C",(SVD,PetscBool*),(svd,oneside));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDDestroy_TRLanczos" PetscErrorCode SVDDestroy_TRLanczos(SVD svd) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(svd->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosSetOneSide_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosGetOneSide_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDView_TRLanczos" PetscErrorCode SVDView_TRLanczos(SVD svd,PetscViewer viewer) { PetscErrorCode ierr; SVD_TRLANCZOS *lanczos = (SVD_TRLANCZOS*)svd->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," TRLanczos: %s-sided reorthogonalization\n",lanczos->oneside? "one": "two");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVDCreate_TRLanczos" PETSC_EXTERN PetscErrorCode SVDCreate_TRLanczos(SVD svd) { PetscErrorCode ierr; SVD_TRLANCZOS *ctx; PetscFunctionBegin; ierr = PetscNewLog(svd,&ctx);CHKERRQ(ierr); svd->data = (void*)ctx; svd->ops->setup = SVDSetUp_TRLanczos; svd->ops->solve = SVDSolve_TRLanczos; svd->ops->destroy = SVDDestroy_TRLanczos; svd->ops->setfromoptions = SVDSetFromOptions_TRLanczos; svd->ops->view = SVDView_TRLanczos; ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosSetOneSide_C",SVDTRLanczosSetOneSide_TRLanczos);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosGetOneSide_C",SVDTRLanczosGetOneSide_TRLanczos);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/svd/impls/trlanczos/makefile.html0000644000175000017500000000467413107004621021367 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = trlanczos.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsvd
DIRS     =
MANSEC   = SVD
LOCDIR   = src/svd/impls/trlanczos/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/svd/impls/trlanczos/trlanczos.c.html0000644000175000017500000012735213107004621022051 0ustar jromanjroman
Actual source code: trlanczos.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc singular value solver: "trlanczos"

  5:    Method: Thick-restart Lanczos

  7:    Algorithm:

  9:        Golub-Kahan-Lanczos bidiagonalization with thick-restart.

 11:    References:

 13:        [1] G.H. Golub and W. Kahan, "Calculating the singular values
 14:            and pseudo-inverse of a matrix", SIAM J. Numer. Anal. Ser.
 15:            B 2:205-224, 1965.

 17:        [2] V. Hernandez, J.E. Roman, and A. Tomas, "A robust and
 18:            efficient parallel SVD solver based on restarted Lanczos
 19:            bidiagonalization", Elec. Trans. Numer. Anal. 31:68-85,
 20:            2008.

 22:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 23:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 24:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 26:    This file is part of SLEPc.

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

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

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

 42: #include <slepc/private/svdimpl.h>          /*I "slepcsvd.h" I*/

 44: static PetscBool  cited = PETSC_FALSE;
 45: static const char citation[] =
 46:   "@Article{slepc-svd,\n"
 47:   "   author = \"V. Hern{\\'a}ndez and J. E. Rom{\\'a}n and A. Tom{\\'a}s\",\n"
 48:   "   title = \"A robust and efficient parallel {SVD} solver based on restarted {Lanczos} bidiagonalization\",\n"
 49:   "   journal = \"Electron. Trans. Numer. Anal.\",\n"
 50:   "   volume = \"31\",\n"
 51:   "   pages = \"68--85\",\n"
 52:   "   year = \"2008\"\n"
 53:   "}\n";

 55: typedef struct {
 56:   PetscBool oneside;
 57: } SVD_TRLANCZOS;

 61: PetscErrorCode SVDSetUp_TRLanczos(SVD svd)
 62: {
 64:   PetscInt       N;

 67:   SVDMatGetSize(svd,NULL,&N);
 68:   SVDSetDimensions_Default(svd);
 69:   if (svd->ncv>svd->nsv+svd->mpd) SETERRQ(PetscObjectComm((PetscObject)svd),1,"The value of ncv must not be larger than nev+mpd");
 70:   if (!svd->max_it) svd->max_it = PetscMax(N/svd->ncv,100);
 71:   svd->leftbasis = PETSC_TRUE;
 72:   SVDAllocateSolution(svd,1);
 73:   DSSetType(svd->ds,DSSVD);
 74:   DSSetCompact(svd->ds,PETSC_TRUE);
 75:   DSAllocate(svd->ds,svd->ncv);
 76:   return(0);
 77: }

 81: static PetscErrorCode SVDOneSideTRLanczosMGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work)
 82: {
 84:   PetscReal      a,b;
 85:   PetscInt       i,k=nconv+l;
 86:   Vec            ui,ui1,vi;

 89:   BVGetColumn(V,k,&vi);
 90:   BVGetColumn(U,k,&ui);
 91:   SVDMatMult(svd,PETSC_FALSE,vi,ui);
 92:   BVRestoreColumn(V,k,&vi);
 93:   BVRestoreColumn(U,k,&ui);
 94:   if (l>0) {
 95:     for (i=0;i<l;i++) work[i]=beta[i+nconv];
 96:     BVMultColumn(U,-1.0,1.0,k,work);
 97:   }
 98:   BVNormColumn(U,k,NORM_2,&a);
 99:   BVScaleColumn(U,k,1.0/a);
100:   alpha[k] = a;

102:   for (i=k+1;i<n;i++) {
103:     BVGetColumn(V,i,&vi);
104:     BVGetColumn(U,i-1,&ui1);
105:     SVDMatMult(svd,PETSC_TRUE,ui1,vi);
106:     BVRestoreColumn(V,i,&vi);
107:     BVRestoreColumn(U,i-1,&ui1);
108:     BVOrthogonalizeColumn(V,i,NULL,&b,NULL);
109:     BVScaleColumn(V,i,1.0/b);
110:     beta[i-1] = b;

112:     BVGetColumn(V,i,&vi);
113:     BVGetColumn(U,i,&ui);
114:     SVDMatMult(svd,PETSC_FALSE,vi,ui);
115:     BVRestoreColumn(V,i,&vi);
116:     BVGetColumn(U,i-1,&ui1);
117:     VecAXPY(ui,-b,ui1);
118:     BVRestoreColumn(U,i-1,&ui1);
119:     BVRestoreColumn(U,i,&ui);
120:     BVNormColumn(U,i,NORM_2,&a);
121:     BVScaleColumn(U,i,1.0/a);
122:     alpha[i] = a;
123:   }

125:   BVGetColumn(V,n,&vi);
126:   BVGetColumn(U,n-1,&ui1);
127:   SVDMatMult(svd,PETSC_TRUE,ui1,vi);
128:   BVRestoreColumn(V,n,&vi);
129:   BVRestoreColumn(U,n-1,&ui1);
130:   BVOrthogonalizeColumn(V,n,NULL,&b,NULL);
131:   beta[n-1] = b;
132:   return(0);
133: }

137: /*
138:   Custom CGS orthogonalization, preprocess after first orthogonalization
139: */
140: static PetscErrorCode SVDOrthogonalizeCGS(BV V,PetscInt i,PetscScalar* h,PetscReal a,BVOrthogRefineType refine,PetscReal eta,PetscReal *norm)
141: {
143:   PetscReal      sum,onorm;
144:   PetscScalar    dot;
145:   PetscInt       j;

148:   switch (refine) {
149:   case BV_ORTHOG_REFINE_NEVER:
150:     BVNormColumn(V,i,NORM_2,norm);
151:     break;
152:   case BV_ORTHOG_REFINE_ALWAYS:
153:     BVSetActiveColumns(V,0,i);
154:     BVDotColumn(V,i,h);
155:     BVMultColumn(V,-1.0,1.0,i,h);
156:     BVNormColumn(V,i,NORM_2,norm);
157:     break;
158:   case BV_ORTHOG_REFINE_IFNEEDED:
159:     dot = h[i];
160:     onorm = PetscSqrtReal(PetscRealPart(dot)) / a;
161:     sum = 0.0;
162:     for (j=0;j<i;j++) {
163:       sum += PetscRealPart(h[j] * PetscConj(h[j]));
164:     }
165:     *norm = PetscRealPart(dot)/(a*a) - sum;
166:     if (*norm>0.0) *norm = PetscSqrtReal(*norm);
167:     else {
168:       BVNormColumn(V,i,NORM_2,norm);
169:     }
170:     if (*norm < eta*onorm) {
171:       BVSetActiveColumns(V,0,i);
172:       BVDotColumn(V,i,h);
173:       BVMultColumn(V,-1.0,1.0,i,h);
174:       BVNormColumn(V,i,NORM_2,norm);
175:     }
176:     break;
177:   }
178:   return(0);
179: }

183: static PetscErrorCode SVDOneSideTRLanczosCGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work)
184: {
185:   PetscErrorCode     ierr;
186:   PetscReal          a,b,eta;
187:   PetscInt           i,j,k=nconv+l;
188:   Vec                ui,ui1,vi;
189:   BVOrthogRefineType refine;

192:   BVGetColumn(V,k,&vi);
193:   BVGetColumn(U,k,&ui);
194:   SVDMatMult(svd,PETSC_FALSE,vi,ui);
195:   BVRestoreColumn(V,k,&vi);
196:   BVRestoreColumn(U,k,&ui);
197:   if (l>0) {
198:     for (i=0;i<l;i++) work[i]=beta[i+nconv];
199:     BVMultColumn(U,-1.0,1.0,k,work);
200:   }
201:   BVGetOrthogonalization(V,NULL,&refine,&eta,NULL);

203:   for (i=k+1;i<n;i++) {
204:     BVGetColumn(V,i,&vi);
205:     BVGetColumn(U,i-1,&ui1);
206:     SVDMatMult(svd,PETSC_TRUE,ui1,vi);
207:     BVRestoreColumn(V,i,&vi);
208:     BVRestoreColumn(U,i-1,&ui1);
209:     BVNormColumnBegin(U,i-1,NORM_2,&a);
210:     if (refine == BV_ORTHOG_REFINE_IFNEEDED) {
211:       BVSetActiveColumns(V,0,i+1);
212:       BVGetColumn(V,i,&vi);
213:       BVDotVecBegin(V,vi,work);
214:     } else {
215:       BVSetActiveColumns(V,0,i);
216:       BVDotColumnBegin(V,i,work);
217:     }
218:     BVNormColumnEnd(U,i-1,NORM_2,&a);
219:     if (refine == BV_ORTHOG_REFINE_IFNEEDED) {
220:       BVDotVecEnd(V,vi,work);
221:       BVRestoreColumn(V,i,&vi);
222:       BVSetActiveColumns(V,0,i);
223:     } else {
224:       BVDotColumnEnd(V,i,work);
225:     }

227:     BVScaleColumn(U,i-1,1.0/a);
228:     for (j=0;j<i;j++) work[j] = work[j] / a;
229:     BVMultColumn(V,-1.0,1.0/a,i,work);
230:     SVDOrthogonalizeCGS(V,i,work,a,refine,eta,&b);
231:     BVScaleColumn(V,i,1.0/b);
232:     if (PetscAbsReal(b)<10*PETSC_MACHINE_EPSILON) SETERRQ(PETSC_COMM_SELF,1,"Recurrence generated a zero vector; use a two-sided variant");

234:     BVGetColumn(V,i,&vi);
235:     BVGetColumn(U,i,&ui);
236:     BVGetColumn(U,i-1,&ui1);
237:     SVDMatMult(svd,PETSC_FALSE,vi,ui);
238:     VecAXPY(ui,-b,ui1);
239:     BVRestoreColumn(V,i,&vi);
240:     BVRestoreColumn(U,i,&ui);
241:     BVRestoreColumn(U,i-1,&ui1);

243:     alpha[i-1] = a;
244:     beta[i-1] = b;
245:   }

247:   BVGetColumn(V,n,&vi);
248:   BVGetColumn(U,n-1,&ui1);
249:   SVDMatMult(svd,PETSC_TRUE,ui1,vi);
250:   BVRestoreColumn(V,n,&vi);
251:   BVRestoreColumn(U,n-1,&ui1);

253:   BVNormColumnBegin(svd->U,n-1,NORM_2,&a);
254:   if (refine == BV_ORTHOG_REFINE_IFNEEDED) {
255:     BVSetActiveColumns(V,0,n+1);
256:     BVGetColumn(V,n,&vi);
257:     BVDotVecBegin(V,vi,work);
258:   } else {
259:     BVSetActiveColumns(V,0,n);
260:     BVDotColumnBegin(V,n,work);
261:   }
262:   BVNormColumnEnd(svd->U,n-1,NORM_2,&a);
263:   if (refine == BV_ORTHOG_REFINE_IFNEEDED) {
264:     BVDotVecEnd(V,vi,work);
265:     BVRestoreColumn(V,n,&vi);
266:   } else {
267:     BVDotColumnEnd(V,n,work);
268:   }

270:   BVScaleColumn(U,n-1,1.0/a);
271:   for (j=0;j<n;j++) work[j] = work[j] / a;
272:   BVMultColumn(V,-1.0,1.0/a,n,work);
273:   SVDOrthogonalizeCGS(V,n,work,a,refine,eta,&b);
274:   BVSetActiveColumns(V,nconv,n);
275:   alpha[n-1] = a;
276:   beta[n-1] = b;
277:   return(0);
278: }

282: PetscErrorCode SVDSolve_TRLanczos(SVD svd)
283: {
285:   SVD_TRLANCZOS  *lanczos = (SVD_TRLANCZOS*)svd->data;
286:   PetscReal      *alpha,*beta,lastbeta,norm,resnorm;
287:   PetscScalar    *Q,*swork=NULL,*w;
288:   PetscInt       i,k,l,nv,ld;
289:   Mat            U,VT;
290:   PetscBool      conv;
291:   BVOrthogType   orthog;

294:   PetscCitationsRegister(citation,&cited);
295:   /* allocate working space */
296:   DSGetLeadingDimension(svd->ds,&ld);
297:   BVGetOrthogonalization(svd->V,&orthog,NULL,NULL,NULL);
298:   PetscMalloc1(ld,&w);
299:   if (lanczos->oneside) {
300:     PetscMalloc1(svd->ncv+1,&swork);
301:   }

303:   /* normalize start vector */
304:   if (!svd->nini) {
305:     BVSetRandomColumn(svd->V,0);
306:     BVNormColumn(svd->V,0,NORM_2,&norm);
307:     BVScaleColumn(svd->V,0,1.0/norm);
308:   }

310:   l = 0;
311:   while (svd->reason == SVD_CONVERGED_ITERATING) {
312:     svd->its++;

314:     /* inner loop */
315:     nv = PetscMin(svd->nconv+svd->mpd,svd->ncv);
316:     BVSetActiveColumns(svd->V,svd->nconv,nv);
317:     BVSetActiveColumns(svd->U,svd->nconv,nv);
318:     DSGetArrayReal(svd->ds,DS_MAT_T,&alpha);
319:     beta = alpha + ld;
320:     if (lanczos->oneside) {
321:       if (orthog == BV_ORTHOG_MGS) {
322:         SVDOneSideTRLanczosMGS(svd,alpha,beta,svd->V,svd->U,svd->nconv,l,nv,swork);
323:       } else {
324:         SVDOneSideTRLanczosCGS(svd,alpha,beta,svd->V,svd->U,svd->nconv,l,nv,swork);
325:       }
326:     } else {
327:       SVDTwoSideLanczos(svd,alpha,beta,svd->V,svd->U,svd->nconv+l,nv);
328:     }
329:     lastbeta = beta[nv-1];
330:     DSRestoreArrayReal(svd->ds,DS_MAT_T,&alpha);
331:     BVScaleColumn(svd->V,nv,1.0/lastbeta);

333:     /* compute SVD of general matrix */
334:     DSSetDimensions(svd->ds,nv,nv,svd->nconv,svd->nconv+l);
335:     if (l==0) {
336:       DSSetState(svd->ds,DS_STATE_INTERMEDIATE);
337:     } else {
338:       DSSetState(svd->ds,DS_STATE_RAW);
339:     }
340:     DSSolve(svd->ds,w,NULL);
341:     DSSort(svd->ds,w,NULL,NULL,NULL,NULL);

343:     /* compute error estimates */
344:     k = 0;
345:     conv = PETSC_TRUE;
346:     DSGetArray(svd->ds,DS_MAT_U,&Q);
347:     DSGetArrayReal(svd->ds,DS_MAT_T,&alpha);
348:     beta = alpha + ld;
349:     for (i=svd->nconv;i<nv;i++) {
350:       svd->sigma[i] = PetscRealPart(w[i]);
351:       beta[i] = PetscRealPart(Q[nv-1+i*ld])*lastbeta;
352:       resnorm = PetscAbsReal(beta[i]);
353:       (*svd->converged)(svd,svd->sigma[i],resnorm,&svd->errest[i],svd->convergedctx);
354:       if (conv) {
355:         if (svd->errest[i] < svd->tol) k++;
356:         else conv = PETSC_FALSE;
357:       }
358:     }
359:     DSRestoreArrayReal(svd->ds,DS_MAT_T,&alpha);
360:     DSRestoreArray(svd->ds,DS_MAT_U,&Q);

362:     /* check convergence and update l */
363:     (*svd->stopping)(svd,svd->its,svd->max_it,svd->nconv+k,svd->nsv,&svd->reason,svd->stoppingctx);
364:     if (svd->reason != SVD_CONVERGED_ITERATING) l = 0;
365:     else l = PetscMax((nv-svd->nconv-k)/2,0);

367:     /* compute converged singular vectors and restart vectors */
368:     DSGetMat(svd->ds,DS_MAT_VT,&VT);
369:     BVMultInPlaceTranspose(svd->V,VT,svd->nconv,svd->nconv+k+l);
370:     MatDestroy(&VT);
371:     DSGetMat(svd->ds,DS_MAT_U,&U);
372:     BVMultInPlace(svd->U,U,svd->nconv,svd->nconv+k+l);
373:     MatDestroy(&U);

375:     /* copy the last vector to be the next initial vector */
376:     if (svd->reason == SVD_CONVERGED_ITERATING) {
377:       BVCopyColumn(svd->V,nv,svd->nconv+k+l);
378:     }

380:     svd->nconv += k;
381:     SVDMonitor(svd,svd->its,svd->nconv,svd->sigma,svd->errest,nv);
382:   }

384:   /* orthonormalize U columns in one side method */
385:   if (lanczos->oneside) {
386:     for (i=0;i<svd->nconv;i++) {
387:       BVOrthogonalizeColumn(svd->U,i,NULL,&norm,NULL);
388:       BVScaleColumn(svd->U,i,1.0/norm);
389:     }
390:   }

392:   /* free working space */
393:   PetscFree(w);
394:   if (swork) { PetscFree(swork); }
395:   return(0);
396: }

400: PetscErrorCode SVDSetFromOptions_TRLanczos(PetscOptionItems *PetscOptionsObject,SVD svd)
401: {
403:   PetscBool      set,val;
404:   SVD_TRLANCZOS  *lanczos = (SVD_TRLANCZOS*)svd->data;

407:   PetscOptionsHead(PetscOptionsObject,"SVD TRLanczos Options");
408:   PetscOptionsBool("-svd_trlanczos_oneside","Lanczos one-side reorthogonalization","SVDTRLanczosSetOneSide",lanczos->oneside,&val,&set);
409:   if (set) {
410:     SVDTRLanczosSetOneSide(svd,val);
411:   }
412:   PetscOptionsTail();
413:   return(0);
414: }

418: static PetscErrorCode SVDTRLanczosSetOneSide_TRLanczos(SVD svd,PetscBool oneside)
419: {
420:   SVD_TRLANCZOS *lanczos = (SVD_TRLANCZOS*)svd->data;

423:   lanczos->oneside = oneside;
424:   return(0);
425: }

429: /*@
430:    SVDTRLanczosSetOneSide - Indicate if the variant of the Lanczos method
431:    to be used is one-sided or two-sided.

433:    Logically Collective on SVD

435:    Input Parameters:
436: +  svd     - singular value solver
437: -  oneside - boolean flag indicating if the method is one-sided or not

439:    Options Database Key:
440: .  -svd_trlanczos_oneside <boolean> - Indicates the boolean flag

442:    Note:
443:    By default, a two-sided variant is selected, which is sometimes slightly
444:    more robust. However, the one-sided variant is faster because it avoids
445:    the orthogonalization associated to left singular vectors.

447:    Level: advanced

449: .seealso: SVDLanczosSetOneSide()
450: @*/
451: PetscErrorCode SVDTRLanczosSetOneSide(SVD svd,PetscBool oneside)
452: {

458:   PetscTryMethod(svd,"SVDTRLanczosSetOneSide_C",(SVD,PetscBool),(svd,oneside));
459:   return(0);
460: }

464: static PetscErrorCode SVDTRLanczosGetOneSide_TRLanczos(SVD svd,PetscBool *oneside)
465: {
466:   SVD_TRLANCZOS *lanczos = (SVD_TRLANCZOS*)svd->data;

469:   *oneside = lanczos->oneside;
470:   return(0);
471: }

475: /*@
476:    SVDTRLanczosGetOneSide - Gets if the variant of the Lanczos method
477:    to be used is one-sided or two-sided.

479:    Not Collective

481:    Input Parameters:
482: .  svd     - singular value solver

484:    Output Parameters:
485: .  oneside - boolean flag indicating if the method is one-sided or not

487:    Level: advanced

489: .seealso: SVDTRLanczosSetOneSide()
490: @*/
491: PetscErrorCode SVDTRLanczosGetOneSide(SVD svd,PetscBool *oneside)
492: {

498:   PetscUseMethod(svd,"SVDTRLanczosGetOneSide_C",(SVD,PetscBool*),(svd,oneside));
499:   return(0);
500: }

504: PetscErrorCode SVDDestroy_TRLanczos(SVD svd)
505: {

509:   PetscFree(svd->data);
510:   PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosSetOneSide_C",NULL);
511:   PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosGetOneSide_C",NULL);
512:   return(0);
513: }

517: PetscErrorCode SVDView_TRLanczos(SVD svd,PetscViewer viewer)
518: {
520:   SVD_TRLANCZOS  *lanczos = (SVD_TRLANCZOS*)svd->data;
521:   PetscBool      isascii;

524:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
525:   if (isascii) {
526:     PetscViewerASCIIPrintf(viewer,"  TRLanczos: %s-sided reorthogonalization\n",lanczos->oneside? "one": "two");
527:   }
528:   return(0);
529: }

533: PETSC_EXTERN PetscErrorCode SVDCreate_TRLanczos(SVD svd)
534: {
536:   SVD_TRLANCZOS  *ctx;

539:   PetscNewLog(svd,&ctx);
540:   svd->data = (void*)ctx;

542:   svd->ops->setup          = SVDSetUp_TRLanczos;
543:   svd->ops->solve          = SVDSolve_TRLanczos;
544:   svd->ops->destroy        = SVDDestroy_TRLanczos;
545:   svd->ops->setfromoptions = SVDSetFromOptions_TRLanczos;
546:   svd->ops->view           = SVDView_TRLanczos;
547:   PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosSetOneSide_C",SVDTRLanczosSetOneSide_TRLanczos);
548:   PetscObjectComposeFunction((PetscObject)svd,"SVDTRLanczosGetOneSide_C",SVDTRLanczosGetOneSide_TRLanczos);
549:   return(0);
550: }

slepc-3.7.4/src/svd/impls/trlanczos/index.html0000644000175000017500000000275713107004621020721 0ustar jromanjroman Singular Value Decomposition Solvers - SVD
slepc-3.7.4 2017-05-17

Singular Value Decomposition Solvers - SVD: Examples

The Singular Value Decomposition Solver (SVD) is very similar to the EPS object, but intended for the computation of the partial SVD of a rectangular matrix. With this type of object, the user can specify an SVD problem and solve it with any of the different solvers encapsulated by the package. Some of these solvers are actually implemented through calls to EPS eigensolvers.

The user interface is very similar to that of EPS, both for the options database (e.g., -svd_nsv 4 -svd_type lanczos), and for the programmatic interface (e.g., SVDSetDimensions() / SVDSetType()).

trlanczos.c
makefile
slepc-3.7.4/src/svd/impls/trlanczos/ftn-auto/0000755000175000017500000000000013107004621020446 5ustar jromanjromanslepc-3.7.4/src/svd/impls/trlanczos/ftn-auto/makefile0000644000175000017500000000036713107004621022154 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = trlanczosf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsvd LOCDIR = src/svd/impls/trlanczos/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/svd/impls/trlanczos/ftn-auto/trlanczosf.c0000644000175000017500000000301613107004621022777 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* trlanczos.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsvd.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdtrlanczossetoneside_ SVDTRLANCZOSSETONESIDE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdtrlanczossetoneside_ svdtrlanczossetoneside #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define svdtrlanczosgetoneside_ SVDTRLANCZOSGETONESIDE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define svdtrlanczosgetoneside_ svdtrlanczosgetoneside #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL svdtrlanczossetoneside_(SVD svd,PetscBool *oneside, int *__ierr ){ *__ierr = SVDTRLanczosSetOneSide( (SVD)PetscToPointer((svd) ),*oneside); } PETSC_EXTERN void PETSC_STDCALL svdtrlanczosgetoneside_(SVD svd,PetscBool *oneside, int *__ierr ){ *__ierr = SVDTRLanczosGetOneSide( (SVD)PetscToPointer((svd) ),oneside); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/0000755000175000017500000000000013107004621013534 5ustar jromanjromanslepc-3.7.4/src/nep/makefile0000644000175000017500000000216513107004621015240 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../include/slepc/private/nepimpl.h ../../include/slepcnep.h DIRS = interface impls examples f90-mod LOCDIR = src/nep/ MANSEC = NEP include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/interface/0000755000175000017500000000000013107004621015474 5ustar jromanjromanslepc-3.7.4/src/nep/interface/nepopts.c.html0000644000175000017500000032034613107004621020303 0ustar jromanjroman

Actual source code: nepopts.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       NEP routines related to options that can be set via the command-line
  3:       or procedurally.

  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: */

 25: #include <slepc/private/nepimpl.h>       /*I "slepcnep.h" I*/
 26: #include <petscdraw.h>

 30: /*@C
 31:    NEPMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 32:    indicated by the user.

 34:    Collective on NEP

 36:    Input Parameters:
 37: +  nep      - the nonlinear eigensolver context
 38: .  name     - the monitor option name
 39: .  help     - message indicating what monitoring is done
 40: .  manual   - manual page for the monitor
 41: .  monitor  - the monitor function, whose context is a PetscViewerAndFormat
 42: -  trackall - whether this monitor tracks all eigenvalues or not

 44:    Level: developer

 46: .seealso: NEPMonitorSet(), NEPSetTrackAll(), NEPConvMonitorSetFromOptions()
 47: @*/
 48: PetscErrorCode NEPMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
 49: {
 50:   PetscErrorCode       ierr;
 51:   PetscBool            flg;
 52:   PetscViewer          viewer;
 53:   PetscViewerFormat    format;
 54:   PetscViewerAndFormat *vf;

 57:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,name,&viewer,&format,&flg);
 58:   if (flg) {
 59:     PetscViewerAndFormatCreate(viewer,format,&vf);
 60:     PetscObjectDereference((PetscObject)viewer);
 61:     NEPMonitorSet(nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
 62:     if (trackall) {
 63:       NEPSetTrackAll(nep,PETSC_TRUE);
 64:     }
 65:   }
 66:   return(0);
 67: }

 71: /*@C
 72:    NEPConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 73:    indicated by the user (for monitors that only show iteration numbers of convergence).

 75:    Collective on NEP

 77:    Input Parameters:
 78: +  nep      - the nonlinear eigensolver context
 79: .  name     - the monitor option name
 80: .  help     - message indicating what monitoring is done
 81: .  manual   - manual page for the monitor
 82: -  monitor  - the monitor function, whose context is a SlepcConvMonitor

 84:    Level: developer

 86: .seealso: NEPMonitorSet(), NEPMonitorSetFromOptions()
 87: @*/
 88: PetscErrorCode NEPConvMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))
 89: {
 90:   PetscErrorCode    ierr;
 91:   PetscBool         flg;
 92:   PetscViewer       viewer;
 93:   PetscViewerFormat format;
 94:   SlepcConvMonitor  ctx;

 97:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,name,&viewer,&format,&flg);
 98:   if (flg) {
 99:     SlepcConvMonitorCreate(viewer,format,&ctx);
100:     PetscObjectDereference((PetscObject)viewer);
101:     NEPMonitorSet(nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);
102:   }
103:   return(0);
104: }

108: /*@
109:    NEPSetFromOptions - Sets NEP options from the options database.
110:    This routine must be called before NEPSetUp() if the user is to be
111:    allowed to set the solver type.

113:    Collective on NEP

115:    Input Parameters:
116: .  nep - the nonlinear eigensolver context

118:    Notes:
119:    To see all options, run your program with the -help option.

121:    Level: beginner
122: @*/
123: PetscErrorCode NEPSetFromOptions(NEP nep)
124: {
126:   char           type[256];
127:   PetscBool      set,flg,flg1,flg2,flg3;
128:   PetscReal      r;
129:   PetscScalar    s;
130:   PetscInt       i,j,k;
131:   PetscDrawLG    lg;

135:   NEPRegisterAll();
136:   PetscObjectOptionsBegin((PetscObject)nep);
137:     PetscOptionsFList("-nep_type","Nonlinear Eigenvalue Problem method","NEPSetType",NEPList,(char*)(((PetscObject)nep)->type_name?((PetscObject)nep)->type_name:NEPRII),type,256,&flg);
138:     if (flg) {
139:       NEPSetType(nep,type);
140:     } else if (!((PetscObject)nep)->type_name) {
141:       NEPSetType(nep,NEPRII);
142:     }

144:     PetscOptionsEnum("-nep_refine","Iterative refinement method","NEPSetRefine",NEPRefineTypes,(PetscEnum)nep->refine,(PetscEnum*)&nep->refine,NULL);

146:     i = nep->npart;
147:     PetscOptionsInt("-nep_refine_partitions","Number of partitions of the communicator for iterative refinement","NEPSetRefine",nep->npart,&i,&flg1);
148:     r = nep->rtol;
149:     PetscOptionsReal("-nep_refine_tol","Tolerance for iterative refinement","NEPSetRefine",nep->rtol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/1000:nep->rtol,&r,&flg2);
150:     j = nep->rits;
151:     PetscOptionsInt("-nep_refine_its","Maximum number of iterations for iterative refinement","NEPSetRefine",nep->rits,&j,&flg3);
152:     if (flg1 || flg2 || flg3) {
153:       NEPSetRefine(nep,nep->refine,i,r,j,nep->scheme);
154:     }

156:     PetscOptionsEnum("-nep_refine_scheme","Scheme used for linear systems within iterative refinement","NEPSetRefine",NEPRefineSchemes,(PetscEnum)nep->scheme,(PetscEnum*)&nep->scheme,NULL);

158:     i = nep->max_it? nep->max_it: PETSC_DEFAULT;
159:     PetscOptionsInt("-nep_max_it","Maximum number of iterations","NEPSetTolerances",nep->max_it,&i,&flg1);
160:     r = nep->tol;
161:     PetscOptionsReal("-nep_tol","Tolerance","NEPSetTolerances",nep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:nep->tol,&r,&flg2);
162:     if (flg1 || flg2) {
163:       NEPSetTolerances(nep,r,i);
164:     }

166:     PetscOptionsBoolGroupBegin("-nep_conv_rel","Relative error convergence test","NEPSetConvergenceTest",&flg);
167:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_REL); }
168:     PetscOptionsBoolGroup("-nep_conv_norm","Convergence test relative to the matrix norms","NEPSetConvergenceTest",&flg);
169:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_NORM); }
170:     PetscOptionsBoolGroup("-nep_conv_abs","Absolute error convergence test","NEPSetConvergenceTest",&flg);
171:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_ABS); }
172:     PetscOptionsBoolGroupEnd("-nep_conv_user","User-defined convergence test","NEPSetConvergenceTest",&flg);
173:     if (flg) { NEPSetConvergenceTest(nep,NEP_CONV_USER); }

175:     PetscOptionsBoolGroupBegin("-nep_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","NEPSetStoppingTest",&flg);
176:     if (flg) { NEPSetStoppingTest(nep,NEP_STOP_BASIC); }
177:     PetscOptionsBoolGroupEnd("-nep_stop_user","User-defined stopping test","NEPSetStoppingTest",&flg);
178:     if (flg) { NEPSetStoppingTest(nep,NEP_STOP_USER); }

180:     i = nep->nev;
181:     PetscOptionsInt("-nep_nev","Number of eigenvalues to compute","NEPSetDimensions",nep->nev,&i,&flg1);
182:     j = nep->ncv? nep->ncv: PETSC_DEFAULT;
183:     PetscOptionsInt("-nep_ncv","Number of basis vectors","NEPSetDimensions",nep->ncv,&j,&flg2);
184:     k = nep->mpd? nep->mpd: PETSC_DEFAULT;
185:     PetscOptionsInt("-nep_mpd","Maximum dimension of projected problem","NEPSetDimensions",nep->mpd,&k,&flg3);
186:     if (flg1 || flg2 || flg3) {
187:       NEPSetDimensions(nep,i,j,k);
188:     }

190:     PetscOptionsScalar("-nep_target","Value of the target","NEPSetTarget",nep->target,&s,&flg);
191:     if (flg) {
192:       NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE);
193:       NEPSetTarget(nep,s);
194:     }

196:     /* -----------------------------------------------------------------------*/
197:     /*
198:       Cancels all monitors hardwired into code before call to NEPSetFromOptions()
199:     */
200:     PetscOptionsBool("-nep_monitor_cancel","Remove any hardwired monitor routines","NEPMonitorCancel",PETSC_FALSE,&flg,&set);
201:     if (set && flg) {
202:       NEPMonitorCancel(nep);
203:     }
204:     /*
205:       Text monitors
206:     */
207:     NEPMonitorSetFromOptions(nep,"-nep_monitor","Monitor first unconverged approximate eigenvalue and error estimate","NEPMonitorFirst",NEPMonitorFirst,PETSC_FALSE);
208:     NEPConvMonitorSetFromOptions(nep,"-nep_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","NEPMonitorConverged",NEPMonitorConverged);
209:     NEPMonitorSetFromOptions(nep,"-nep_monitor_all","Monitor approximate eigenvalues and error estimates","NEPMonitorAll",NEPMonitorAll,PETSC_TRUE);
210:     /*
211:       Line graph monitors
212:     */
213:     PetscOptionsBool("-nep_monitor_lg","Monitor first unconverged approximate error estimate graphically","NEPMonitorSet",PETSC_FALSE,&flg,&set);
214:     if (set && flg) {
215:       NEPMonitorLGCreate(PetscObjectComm((PetscObject)nep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
216:       NEPMonitorSet(nep,NEPMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
217:     }
218:     PetscOptionsBool("-nep_monitor_lg_all","Monitor error estimates graphically","NEPMonitorSet",PETSC_FALSE,&flg,&set);
219:     if (set && flg) {
220:       NEPMonitorLGCreate(PetscObjectComm((PetscObject)nep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
221:       NEPMonitorSet(nep,NEPMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
222:       NEPSetTrackAll(nep,PETSC_TRUE);
223:     }
224:   /* -----------------------------------------------------------------------*/

226:     PetscOptionsBoolGroupBegin("-nep_largest_magnitude","compute largest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg);
227:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_LARGEST_MAGNITUDE); }
228:     PetscOptionsBoolGroup("-nep_smallest_magnitude","compute smallest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg);
229:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_SMALLEST_MAGNITUDE); }
230:     PetscOptionsBoolGroup("-nep_largest_real","compute largest real parts","NEPSetWhichEigenpairs",&flg);
231:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_LARGEST_REAL); }
232:     PetscOptionsBoolGroup("-nep_smallest_real","compute smallest real parts","NEPSetWhichEigenpairs",&flg);
233:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_SMALLEST_REAL); }
234:     PetscOptionsBoolGroup("-nep_largest_imaginary","compute largest imaginary parts","NEPSetWhichEigenpairs",&flg);
235:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_LARGEST_IMAGINARY); }
236:     PetscOptionsBoolGroup("-nep_smallest_imaginary","compute smallest imaginary parts","NEPSetWhichEigenpairs",&flg);
237:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_SMALLEST_IMAGINARY); }
238:     PetscOptionsBoolGroup("-nep_target_magnitude","compute nearest eigenvalues to target","NEPSetWhichEigenpairs",&flg);
239:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE); }
240:     PetscOptionsBoolGroup("-nep_target_real","compute eigenvalues with real parts close to target","NEPSetWhichEigenpairs",&flg);
241:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_TARGET_REAL); }
242:     PetscOptionsBoolGroup("-nep_target_imaginary","compute eigenvalues with imaginary parts close to target","NEPSetWhichEigenpairs",&flg);
243:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_TARGET_IMAGINARY); }
244:     PetscOptionsBoolGroupEnd("-nep_all","compute all eigenvalues in a region","NEPSetWhichEigenpairs",&flg);
245:     if (flg) { NEPSetWhichEigenpairs(nep,NEP_ALL); }

247:     PetscOptionsName("-nep_view","Print detailed information on solver used","NEPView",NULL);
248:     PetscOptionsName("-nep_view_vectors","View computed eigenvectors","NEPVectorsView",NULL);
249:     PetscOptionsName("-nep_view_values","View computed eigenvalues","NEPValuesView",NULL);
250:     PetscOptionsName("-nep_converged_reason","Print reason for convergence, and number of iterations","NEPReasonView",NULL);
251:     PetscOptionsName("-nep_error_absolute","Print absolute errors of each eigenpair","NEPErrorView",NULL);
252:     PetscOptionsName("-nep_error_relative","Print relative errors of each eigenpair","NEPErrorView",NULL);

254:     if (nep->ops->setfromoptions) {
255:       (*nep->ops->setfromoptions)(PetscOptionsObject,nep);
256:     }
257:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)nep);
258:   PetscOptionsEnd();

260:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
261:   BVSetFromOptions(nep->V);
262:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
263:   RGSetFromOptions(nep->rg);
264:   if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
265:   DSSetFromOptions(nep->ds);
266:   if (!nep->refineksp) { NEPRefineGetKSP(nep,&nep->refineksp); }
267:   KSPSetFromOptions(nep->refineksp);
268:   return(0);
269: }

273: /*@
274:    NEPGetTolerances - Gets the tolerance and maximum iteration count used
275:    by the NEP convergence tests.

277:    Not Collective

279:    Input Parameter:
280: .  nep - the nonlinear eigensolver context

282:    Output Parameters:
283: +  tol - the convergence tolerance
284: -  maxits - maximum number of iterations

286:    Notes:
287:    The user can specify NULL for any parameter that is not needed.

289:    Level: intermediate

291: .seealso: NEPSetTolerances()
292: @*/
293: PetscErrorCode NEPGetTolerances(NEP nep,PetscReal *tol,PetscInt *maxits)
294: {
297:   if (tol)    *tol    = nep->tol;
298:   if (maxits) *maxits = nep->max_it;
299:   return(0);
300: }

304: /*@
305:    NEPSetTolerances - Sets the tolerance and maximum iteration count used
306:    by the NEP convergence tests.

308:    Logically Collective on NEP

310:    Input Parameters:
311: +  nep    - the nonlinear eigensolver context
312: .  tol    - the convergence tolerance
313: -  maxits - maximum number of iterations to use

315:    Options Database Keys:
316: +  -nep_tol <tol> - Sets the convergence tolerance
317: -  -nep_max_it <maxits> - Sets the maximum number of iterations allowed

319:    Notes:
320:    Use PETSC_DEFAULT for either argument to assign a reasonably good value.

322:    Level: intermediate

324: .seealso: NEPGetTolerances()
325: @*/
326: PetscErrorCode NEPSetTolerances(NEP nep,PetscReal tol,PetscInt maxits)
327: {
332:   if (tol == PETSC_DEFAULT) {
333:     nep->tol   = PETSC_DEFAULT;
334:     nep->state = NEP_STATE_INITIAL;
335:   } else {
336:     if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
337:     nep->tol = tol;
338:   }
339:   if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
340:     nep->max_it = 0;
341:     nep->state  = NEP_STATE_INITIAL;
342:   } else {
343:     if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
344:     nep->max_it = maxits;
345:   }
346:   return(0);
347: }

351: /*@
352:    NEPGetDimensions - Gets the number of eigenvalues to compute
353:    and the dimension of the subspace.

355:    Not Collective

357:    Input Parameter:
358: .  nep - the nonlinear eigensolver context

360:    Output Parameters:
361: +  nev - number of eigenvalues to compute
362: .  ncv - the maximum dimension of the subspace to be used by the solver
363: -  mpd - the maximum dimension allowed for the projected problem

365:    Notes:
366:    The user can specify NULL for any parameter that is not needed.

368:    Level: intermediate

370: .seealso: NEPSetDimensions()
371: @*/
372: PetscErrorCode NEPGetDimensions(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
373: {
376:   if (nev) *nev = nep->nev;
377:   if (ncv) *ncv = nep->ncv;
378:   if (mpd) *mpd = nep->mpd;
379:   return(0);
380: }

384: /*@
385:    NEPSetDimensions - Sets the number of eigenvalues to compute
386:    and the dimension of the subspace.

388:    Logically Collective on NEP

390:    Input Parameters:
391: +  nep - the nonlinear eigensolver context
392: .  nev - number of eigenvalues to compute
393: .  ncv - the maximum dimension of the subspace to be used by the solver
394: -  mpd - the maximum dimension allowed for the projected problem

396:    Options Database Keys:
397: +  -nep_nev <nev> - Sets the number of eigenvalues
398: .  -nep_ncv <ncv> - Sets the dimension of the subspace
399: -  -nep_mpd <mpd> - Sets the maximum projected dimension

401:    Notes:
402:    Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is
403:    dependent on the solution method.

405:    The parameters ncv and mpd are intimately related, so that the user is advised
406:    to set one of them at most. Normal usage is that
407:    (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and
408:    (b) in cases where nev is large, the user sets mpd.

410:    The value of ncv should always be between nev and (nev+mpd), typically
411:    ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise
412:    a smaller value should be used.

414:    Level: intermediate

416: .seealso: NEPGetDimensions()
417: @*/
418: PetscErrorCode NEPSetDimensions(NEP nep,PetscInt nev,PetscInt ncv,PetscInt mpd)
419: {
425:   if (nev<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
426:   nep->nev = nev;
427:   if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) {
428:     nep->ncv = 0;
429:   } else {
430:     if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
431:     nep->ncv = ncv;
432:   }
433:   if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) {
434:     nep->mpd = 0;
435:   } else {
436:     if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
437:     nep->mpd = mpd;
438:   }
439:   nep->state = NEP_STATE_INITIAL;
440:   return(0);
441: }

445: /*@
446:     NEPSetWhichEigenpairs - Specifies which portion of the spectrum is
447:     to be sought.

449:     Logically Collective on NEP

451:     Input Parameters:
452: +   nep   - eigensolver context obtained from NEPCreate()
453: -   which - the portion of the spectrum to be sought

455:     Possible values:
456:     The parameter 'which' can have one of these values

458: +     NEP_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default)
459: .     NEP_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude
460: .     NEP_LARGEST_REAL - largest real parts
461: .     NEP_SMALLEST_REAL - smallest real parts
462: .     NEP_LARGEST_IMAGINARY - largest imaginary parts
463: .     NEP_SMALLEST_IMAGINARY - smallest imaginary parts
464: .     NEP_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude)
465: .     NEP_TARGET_REAL - eigenvalues with real part closest to target
466: .     NEP_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target
467: .     NEP_ALL - all eigenvalues contained in a given region
468: -     NEP_WHICH_USER - user defined ordering set with NEPSetEigenvalueComparison()

470:     Options Database Keys:
471: +   -nep_largest_magnitude - Sets largest eigenvalues in magnitude
472: .   -nep_smallest_magnitude - Sets smallest eigenvalues in magnitude
473: .   -nep_largest_real - Sets largest real parts
474: .   -nep_smallest_real - Sets smallest real parts
475: .   -nep_largest_imaginary - Sets largest imaginary parts
476: .   -nep_smallest_imaginary - Sets smallest imaginary parts
477: .   -nep_target_magnitude - Sets eigenvalues closest to target
478: .   -nep_target_real - Sets real parts closest to target
479: .   -nep_target_imaginary - Sets imaginary parts closest to target
480: -   -nep_all - Sets all eigenvalues in a region

482:     Notes:
483:     Not all eigensolvers implemented in NEP account for all the possible values
484:     stated above. If SLEPc is compiled for real numbers NEP_LARGEST_IMAGINARY
485:     and NEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part
486:     for eigenvalue selection.

488:     The target is a scalar value provided with NEPSetTarget().

490:     NEP_ALL is intended for use in the context of the CISS solver for
491:     computing all eigenvalues in a region.

493:     Level: intermediate

495: .seealso: NEPGetWhichEigenpairs(), NEPSetTarget(), NEPSetEigenvalueComparison(), NEPWhich
496: @*/
497: PetscErrorCode NEPSetWhichEigenpairs(NEP nep,NEPWhich which)
498: {
502:   switch (which) {
503:     case NEP_LARGEST_MAGNITUDE:
504:     case NEP_SMALLEST_MAGNITUDE:
505:     case NEP_LARGEST_REAL:
506:     case NEP_SMALLEST_REAL:
507:     case NEP_LARGEST_IMAGINARY:
508:     case NEP_SMALLEST_IMAGINARY:
509:     case NEP_TARGET_MAGNITUDE:
510:     case NEP_TARGET_REAL:
511: #if defined(PETSC_USE_COMPLEX)
512:     case NEP_TARGET_IMAGINARY:
513: #endif
514:     case EPS_ALL:
515:     case NEP_WHICH_USER:
516:       if (nep->which != which) {
517:         nep->state = NEP_STATE_INITIAL;
518:         nep->which = which;
519:       }
520:       break;
521:     default:
522:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
523:   }
524:   return(0);
525: }

529: /*@
530:     NEPGetWhichEigenpairs - Returns which portion of the spectrum is to be
531:     sought.

533:     Not Collective

535:     Input Parameter:
536: .   nep - eigensolver context obtained from NEPCreate()

538:     Output Parameter:
539: .   which - the portion of the spectrum to be sought

541:     Notes:
542:     See NEPSetWhichEigenpairs() for possible values of 'which'.

544:     Level: intermediate

546: .seealso: NEPSetWhichEigenpairs(), NEPWhich
547: @*/
548: PetscErrorCode NEPGetWhichEigenpairs(NEP nep,NEPWhich *which)
549: {
553:   *which = nep->which;
554:   return(0);
555: }

559: /*@C
560:    NEPSetEigenvalueComparison - Specifies the eigenvalue comparison function
561:    when NEPSetWhichEigenpairs() is set to NEP_WHICH_USER.

563:    Logically Collective on NEP

565:    Input Parameters:
566: +  pep  - eigensolver context obtained from NEPCreate()
567: .  func - a pointer to the comparison function
568: -  ctx  - a context pointer (the last parameter to the comparison function)

570:    Calling Sequence of func:
571: $   func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx)

573: +   ar     - real part of the 1st eigenvalue
574: .   ai     - imaginary part of the 1st eigenvalue
575: .   br     - real part of the 2nd eigenvalue
576: .   bi     - imaginary part of the 2nd eigenvalue
577: .   res    - result of comparison
578: -   ctx    - optional context, as set by NEPSetEigenvalueComparison()

580:    Note:
581:    The returning parameter 'res' can be
582: +  negative - if the 1st eigenvalue is preferred to the 2st one
583: .  zero     - if both eigenvalues are equally preferred
584: -  positive - if the 2st eigenvalue is preferred to the 1st one

586:    Level: advanced

588: .seealso: NEPSetWhichEigenpairs(), NEPWhich
589: @*/
590: PetscErrorCode NEPSetEigenvalueComparison(NEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)
591: {
594:   pep->sc->comparison    = func;
595:   pep->sc->comparisonctx = ctx;
596:   pep->which             = NEP_WHICH_USER;
597:   return(0);
598: }

602: /*@C
603:    NEPSetConvergenceTestFunction - Sets a function to compute the error estimate
604:    used in the convergence test.

606:    Logically Collective on NEP

608:    Input Parameters:
609: +  nep     - nonlinear eigensolver context obtained from NEPCreate()
610: .  func    - a pointer to the convergence test function
611: .  ctx     - context for private data for the convergence routine (may be null)
612: -  destroy - a routine for destroying the context (may be null)

614:    Calling Sequence of func:
615: $   func(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)

617: +   nep    - nonlinear eigensolver context obtained from NEPCreate()
618: .   eigr   - real part of the eigenvalue
619: .   eigi   - imaginary part of the eigenvalue
620: .   res    - residual norm associated to the eigenpair
621: .   errest - (output) computed error estimate
622: -   ctx    - optional context, as set by NEPSetConvergenceTestFunction()

624:    Note:
625:    If the error estimate returned by the convergence test function is less than
626:    the tolerance, then the eigenvalue is accepted as converged.

628:    Level: advanced

630: .seealso: NEPSetConvergenceTest(), NEPSetTolerances()
631: @*/
632: PetscErrorCode NEPSetConvergenceTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
633: {

638:   if (nep->convergeddestroy) {
639:     (*nep->convergeddestroy)(nep->convergedctx);
640:   }
641:   nep->converged        = func;
642:   nep->convergeddestroy = destroy;
643:   nep->convergedctx     = ctx;
644:   if (func == NEPConvergedRelative) nep->conv = NEP_CONV_REL;
645:   else if (func == NEPConvergedNorm) nep->conv = NEP_CONV_NORM;
646:   else if (func == NEPConvergedAbsolute) nep->conv = NEP_CONV_ABS;
647:   else nep->conv = NEP_CONV_USER;
648:   return(0);
649: }

653: /*@
654:    NEPSetConvergenceTest - Specifies how to compute the error estimate
655:    used in the convergence test.

657:    Logically Collective on NEP

659:    Input Parameters:
660: +  nep  - nonlinear eigensolver context obtained from NEPCreate()
661: -  conv - the type of convergence test

663:    Options Database Keys:
664: +  -nep_conv_abs  - Sets the absolute convergence test
665: .  -nep_conv_rel  - Sets the convergence test relative to the eigenvalue
666: -  -nep_conv_user - Selects the user-defined convergence test

668:    Note:
669:    The parameter 'conv' can have one of these values
670: +     NEP_CONV_ABS  - absolute error ||r||
671: .     NEP_CONV_REL  - error relative to the eigenvalue l, ||r||/|l|
672: .     NEP_CONV_NORM - error relative matrix norms, ||r||/sum_i(|f_i(l)|*||A_i||)
673: -     NEP_CONV_USER - function set by NEPSetConvergenceTestFunction()

675:    Level: intermediate

677: .seealso: NEPGetConvergenceTest(), NEPSetConvergenceTestFunction(), NEPSetStoppingTest(), NEPConv
678: @*/
679: PetscErrorCode NEPSetConvergenceTest(NEP nep,NEPConv conv)
680: {
684:   switch (conv) {
685:     case NEP_CONV_ABS:  nep->converged = NEPConvergedAbsolute; break;
686:     case NEP_CONV_REL:  nep->converged = NEPConvergedRelative; break;
687:     case NEP_CONV_NORM: nep->converged = NEPConvergedNorm; break;
688:     case NEP_CONV_USER: break;
689:     default:
690:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value");
691:   }
692:   nep->conv = conv;
693:   return(0);
694: }

698: /*@
699:    NEPGetConvergenceTest - Gets the method used to compute the error estimate
700:    used in the convergence test.

702:    Not Collective

704:    Input Parameters:
705: .  nep   - nonlinear eigensolver context obtained from NEPCreate()

707:    Output Parameters:
708: .  conv  - the type of convergence test

710:    Level: intermediate

712: .seealso: NEPSetConvergenceTest(), NEPConv
713: @*/
714: PetscErrorCode NEPGetConvergenceTest(NEP nep,NEPConv *conv)
715: {
719:   *conv = nep->conv;
720:   return(0);
721: }

725: /*@C
726:    NEPSetStoppingTestFunction - Sets a function to decide when to stop the outer
727:    iteration of the eigensolver.

729:    Logically Collective on NEP

731:    Input Parameters:
732: +  nep     - nonlinear eigensolver context obtained from NEPCreate()
733: .  func    - pointer to the stopping test function
734: .  ctx     - context for private data for the stopping routine (may be null)
735: -  destroy - a routine for destroying the context (may be null)

737:    Calling Sequence of func:
738: $   func(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)

740: +   nep    - nonlinear eigensolver context obtained from NEPCreate()
741: .   its    - current number of iterations
742: .   max_it - maximum number of iterations
743: .   nconv  - number of currently converged eigenpairs
744: .   nev    - number of requested eigenpairs
745: .   reason - (output) result of the stopping test
746: -   ctx    - optional context, as set by NEPSetStoppingTestFunction()

748:    Note:
749:    Normal usage is to first call the default routine NEPStoppingBasic() and then
750:    set reason to NEP_CONVERGED_USER if some user-defined conditions have been
751:    met. To let the eigensolver continue iterating, the result must be left as
752:    NEP_CONVERGED_ITERATING.

754:    Level: advanced

756: .seealso: NEPSetStoppingTest(), NEPStoppingBasic()
757: @*/
758: PetscErrorCode NEPSetStoppingTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
759: {

764:   if (nep->stoppingdestroy) {
765:     (*nep->stoppingdestroy)(nep->stoppingctx);
766:   }
767:   nep->stopping        = func;
768:   nep->stoppingdestroy = destroy;
769:   nep->stoppingctx     = ctx;
770:   if (func == NEPStoppingBasic) nep->stop = NEP_STOP_BASIC;
771:   else nep->stop = NEP_STOP_USER;
772:   return(0);
773: }

777: /*@
778:    NEPSetStoppingTest - Specifies how to decide the termination of the outer
779:    loop of the eigensolver.

781:    Logically Collective on NEP

783:    Input Parameters:
784: +  nep  - nonlinear eigensolver context obtained from NEPCreate()
785: -  stop - the type of stopping test

787:    Options Database Keys:
788: +  -nep_stop_basic - Sets the default stopping test
789: -  -nep_stop_user  - Selects the user-defined stopping test

791:    Note:
792:    The parameter 'stop' can have one of these values
793: +     NEP_STOP_BASIC - default stopping test
794: -     NEP_STOP_USER  - function set by NEPSetStoppingTestFunction()

796:    Level: advanced

798: .seealso: NEPGetStoppingTest(), NEPSetStoppingTestFunction(), NEPSetConvergenceTest(), NEPStop
799: @*/
800: PetscErrorCode NEPSetStoppingTest(NEP nep,NEPStop stop)
801: {
805:   switch (stop) {
806:     case NEP_STOP_BASIC: nep->stopping = NEPStoppingBasic; break;
807:     case NEP_STOP_USER:  break;
808:     default:
809:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value");
810:   }
811:   nep->stop = stop;
812:   return(0);
813: }

817: /*@
818:    NEPGetStoppingTest - Gets the method used to decide the termination of the outer
819:    loop of the eigensolver.

821:    Not Collective

823:    Input Parameters:
824: .  nep   - nonlinear eigensolver context obtained from NEPCreate()

826:    Output Parameters:
827: .  stop  - the type of stopping test

829:    Level: advanced

831: .seealso: NEPSetStoppingTest(), NEPStop
832: @*/
833: PetscErrorCode NEPGetStoppingTest(NEP nep,NEPStop *stop)
834: {
838:   *stop = nep->stop;
839:   return(0);
840: }

844: /*@
845:    NEPSetTrackAll - Specifies if the solver must compute the residual of all
846:    approximate eigenpairs or not.

848:    Logically Collective on NEP

850:    Input Parameters:
851: +  nep      - the eigensolver context
852: -  trackall - whether compute all residuals or not

854:    Notes:
855:    If the user sets trackall=PETSC_TRUE then the solver explicitly computes
856:    the residual for each eigenpair approximation. Computing the residual is
857:    usually an expensive operation and solvers commonly compute the associated
858:    residual to the first unconverged eigenpair.
859:    The options '-nep_monitor_all' and '-nep_monitor_lg_all' automatically
860:    activate this option.

862:    Level: developer

864: .seealso: NEPGetTrackAll()
865: @*/
866: PetscErrorCode NEPSetTrackAll(NEP nep,PetscBool trackall)
867: {
871:   nep->trackall = trackall;
872:   return(0);
873: }

877: /*@
878:    NEPGetTrackAll - Returns the flag indicating whether all residual norms must
879:    be computed or not.

881:    Not Collective

883:    Input Parameter:
884: .  nep - the eigensolver context

886:    Output Parameter:
887: .  trackall - the returned flag

889:    Level: developer

891: .seealso: NEPSetTrackAll()
892: @*/
893: PetscErrorCode NEPGetTrackAll(NEP nep,PetscBool *trackall)
894: {
898:   *trackall = nep->trackall;
899:   return(0);
900: }

904: /*@
905:    NEPSetRefine - Specifies the refinement type (and options) to be used
906:    after the solve.

908:    Logically Collective on NEP

910:    Input Parameters:
911: +  nep    - the nonlinear eigensolver context
912: .  refine - refinement type
913: .  npart  - number of partitions of the communicator
914: .  tol    - the convergence tolerance
915: .  its    - maximum number of refinement iterations
916: -  scheme - which scheme to be used for solving the involved linear systems

918:    Options Database Keys:
919: +  -nep_refine <type> - refinement type, one of <none,simple,multiple>
920: .  -nep_refine_partitions <n> - the number of partitions
921: .  -nep_refine_tol <tol> - the tolerance
922: .  -nep_refine_its <its> - number of iterations
923: -  -nep_refine_scheme - to set the scheme for the linear solves

925:    Notes:
926:    By default, iterative refinement is disabled, since it may be very
927:    costly. There are two possible refinement strategies: simple and multiple.
928:    The simple approach performs iterative refinement on each of the
929:    converged eigenpairs individually, whereas the multiple strategy works
930:    with the invariant pair as a whole, refining all eigenpairs simultaneously.
931:    The latter may be required for the case of multiple eigenvalues.

933:    In some cases, especially when using direct solvers within the
934:    iterative refinement method, it may be helpful for improved scalability
935:    to split the communicator in several partitions. The npart parameter
936:    indicates how many partitions to use (defaults to 1).

938:    The tol and its parameters specify the stopping criterion. In the simple
939:    method, refinement continues until the residual of each eigenpair is
940:    below the tolerance (tol defaults to the NEP tol, but may be set to a
941:    different value). In contrast, the multiple method simply performs its
942:    refinement iterations (just one by default).

944:    The scheme argument is used to change the way in which linear systems are
945:    solved. Possible choices are: explicit, mixed block elimination (MBE), 
946:    and Schur complement.

948:    Level: intermediate

950: .seealso: NEPGetRefine()
951: @*/
952: PetscErrorCode NEPSetRefine(NEP nep,NEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,NEPRefineScheme scheme)
953: {
955:   PetscMPIInt    size;

964:   nep->refine = refine;
965:   if (refine) {  /* process parameters only if not REFINE_NONE */
966:     if (npart == PETSC_DEFAULT || npart == PETSC_DECIDE) {
967:       nep->npart = 1;
968:     } else {
969:       MPI_Comm_size(PetscObjectComm((PetscObject)nep),&size);
970:       if (npart<1 || npart>size) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart");
971:       nep->npart = npart;
972:     }
973:     if (tol == PETSC_DEFAULT || tol == PETSC_DECIDE) {
974:       nep->rtol = PetscMax(nep->tol/1000,PETSC_MACHINE_EPSILON);
975:     } else {
976:       if (tol<=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
977:       nep->rtol = tol;
978:     }
979:     if (its==PETSC_DECIDE || its==PETSC_DEFAULT) {
980:       nep->rits = PETSC_DEFAULT;
981:     } else {
982:       if (its<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be >= 0");
983:       nep->rits = its;
984:     }
985:     nep->scheme = scheme;
986:   }
987:   nep->state = NEP_STATE_INITIAL;
988:   return(0);
989: }

993: /*@
994:    NEPGetRefine - Gets the refinement strategy used by the NEP object, and the
995:    associated parameters.

997:    Not Collective

999:    Input Parameter:
1000: .  nep - the nonlinear eigensolver context

1002:    Output Parameters:
1003: +  refine - refinement type
1004: .  npart  - number of partitions of the communicator
1005: .  tol    - the convergence tolerance
1006: -  its    - maximum number of refinement iterations
1007: -  scheme - the scheme used for solving linear systems

1009:    Level: intermediate

1011:    Note:
1012:    The user can specify NULL for any parameter that is not needed.

1014: .seealso: NEPSetRefine()
1015: @*/
1016: PetscErrorCode NEPGetRefine(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme)
1017: {
1020:   if (refine) *refine = nep->refine;
1021:   if (npart)  *npart  = nep->npart;
1022:   if (tol)    *tol    = nep->rtol;
1023:   if (its)    *its    = nep->rits;
1024:   if (scheme) *scheme = nep->scheme;
1025:   return(0);
1026: }

1030: /*@C
1031:    NEPSetOptionsPrefix - Sets the prefix used for searching for all
1032:    NEP options in the database.

1034:    Logically Collective on NEP

1036:    Input Parameters:
1037: +  nep - the nonlinear eigensolver context
1038: -  prefix - the prefix string to prepend to all NEP option requests

1040:    Notes:
1041:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1042:    The first character of all runtime options is AUTOMATICALLY the
1043:    hyphen.

1045:    For example, to distinguish between the runtime options for two
1046:    different NEP contexts, one could call
1047: .vb
1048:       NEPSetOptionsPrefix(nep1,"neig1_")
1049:       NEPSetOptionsPrefix(nep2,"neig2_")
1050: .ve

1052:    Level: advanced

1054: .seealso: NEPAppendOptionsPrefix(), NEPGetOptionsPrefix()
1055: @*/
1056: PetscErrorCode NEPSetOptionsPrefix(NEP nep,const char *prefix)
1057: {

1062:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
1063:   BVSetOptionsPrefix(nep->V,prefix);
1064:   if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
1065:   DSSetOptionsPrefix(nep->ds,prefix);
1066:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
1067:   RGSetOptionsPrefix(nep->rg,prefix);
1068:   PetscObjectSetOptionsPrefix((PetscObject)nep,prefix);
1069:   return(0);
1070: }

1074: /*@C
1075:    NEPAppendOptionsPrefix - Appends to the prefix used for searching for all
1076:    NEP options in the database.

1078:    Logically Collective on NEP

1080:    Input Parameters:
1081: +  nep - the nonlinear eigensolver context
1082: -  prefix - the prefix string to prepend to all NEP option requests

1084:    Notes:
1085:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1086:    The first character of all runtime options is AUTOMATICALLY the hyphen.

1088:    Level: advanced

1090: .seealso: NEPSetOptionsPrefix(), NEPGetOptionsPrefix()
1091: @*/
1092: PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char *prefix)
1093: {

1098:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
1099:   BVSetOptionsPrefix(nep->V,prefix);
1100:   if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
1101:   DSSetOptionsPrefix(nep->ds,prefix);
1102:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
1103:   RGSetOptionsPrefix(nep->rg,prefix);
1104:   PetscObjectAppendOptionsPrefix((PetscObject)nep,prefix);
1105:   return(0);
1106: }

1110: /*@C
1111:    NEPGetOptionsPrefix - Gets the prefix used for searching for all
1112:    NEP options in the database.

1114:    Not Collective

1116:    Input Parameters:
1117: .  nep - the nonlinear eigensolver context

1119:    Output Parameters:
1120: .  prefix - pointer to the prefix string used is returned

1122:    Note:
1123:    On the Fortran side, the user should pass in a string 'prefix' of
1124:    sufficient length to hold the prefix.

1126:    Level: advanced

1128: .seealso: NEPSetOptionsPrefix(), NEPAppendOptionsPrefix()
1129: @*/
1130: PetscErrorCode NEPGetOptionsPrefix(NEP nep,const char *prefix[])
1131: {

1137:   PetscObjectGetOptionsPrefix((PetscObject)nep,prefix);
1138:   return(0);
1139: }

slepc-3.7.4/src/nep/interface/makefile0000644000175000017500000000232113107004621017172 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = nepmon.c nepbasic.c nepview.c nepdefault.c nepregis.c nepopts.c nepsetup.c nepsolve.c neprefine.c dlregisnep.c SOURCEF = SOURCEH = LIBBASE = libslepcnep DIRS = MANSEC = NEP LOCDIR = src/nep/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/interface/nepsolve.c.html0000644000175000017500000015430513107004621020446 0ustar jromanjroman
Actual source code: nepsolve.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       NEP routines related to the solution process.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/nepimpl.h>       /*I "slepcnep.h" I*/
 25: #include <petscdraw.h>

 29: PetscErrorCode NEPComputeVectors(NEP nep)
 30: {

 34:   NEPCheckSolved(nep,1);
 35:   switch (nep->state) {
 36:   case NEP_STATE_SOLVED:
 37:     if (nep->ops->computevectors) {
 38:       (*nep->ops->computevectors)(nep);
 39:     }
 40:     break;
 41:   default:
 42:     break;
 43:   }
 44:   nep->state = NEP_STATE_EIGENVECTORS;
 45:   return(0);
 46: }

 50: /*@
 51:    NEPSolve - Solves the nonlinear eigensystem.

 53:    Collective on NEP

 55:    Input Parameter:
 56: .  nep - eigensolver context obtained from NEPCreate()

 58:    Options Database Keys:
 59: +  -nep_view - print information about the solver used
 60: .  -nep_view_vectors binary - save the computed eigenvectors to the default binary viewer
 61: .  -nep_view_values - print computed eigenvalues
 62: .  -nep_converged_reason - print reason for convergence, and number of iterations
 63: .  -nep_error_absolute - print absolute errors of each eigenpair
 64: -  -nep_error_relative - print relative errors of each eigenpair

 66:    Level: beginner

 68: .seealso: NEPCreate(), NEPSetUp(), NEPDestroy(), NEPSetTolerances()
 69: @*/
 70: PetscErrorCode NEPSolve(NEP nep)
 71: {
 73:   PetscInt       i;

 77:   if (nep->state>=NEP_STATE_SOLVED) return(0);
 78:   PetscLogEventBegin(NEP_Solve,nep,0,0,0);

 80:   /* call setup */
 81:   NEPSetUp(nep);
 82:   nep->nconv = 0;
 83:   nep->its = 0;
 84:   for (i=0;i<nep->ncv;i++) {
 85:     nep->eigr[i]   = 0.0;
 86:     nep->eigi[i]   = 0.0;
 87:     nep->errest[i] = 0.0;
 88:     nep->perm[i]   = i;
 89:   }
 90:   NEPViewFromOptions(nep,NULL,"-nep_view_pre");

 92:   (*nep->ops->solve)(nep);
 93:   nep->state = NEP_STATE_SOLVED;

 95:   if (!nep->reason) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason");

 97:   if (nep->refine==NEP_REFINE_SIMPLE && nep->rits>0 && nep->nconv>0) {
 98:     NEPComputeVectors(nep);
 99:     NEPNewtonRefinementSimple(nep,&nep->rits,nep->rtol,nep->nconv);
100:     nep->state = NEP_STATE_EIGENVECTORS;
101:   }

103:   /* sort eigenvalues according to nep->which parameter */
104:   SlepcSortEigenvalues(nep->sc,nep->nconv,nep->eigr,nep->eigi,nep->perm);
105:   PetscLogEventEnd(NEP_Solve,nep,0,0,0);

107:   /* various viewers */
108:   NEPViewFromOptions(nep,NULL,"-nep_view");
109:   NEPReasonViewFromOptions(nep);
110:   NEPErrorViewFromOptions(nep);
111:   NEPValuesViewFromOptions(nep);
112:   NEPVectorsViewFromOptions(nep);

114:   /* Remove the initial subspace */
115:   nep->nini = 0;
116:   return(0);
117: }

121: /*@
122:    NEPProjectOperator - Computes the projection of the nonlinear operator.

124:    Collective on NEP

126:    Input Parameters:
127: +  nep - the nonlinear eigensolver context
128: .  j0  - initial index
129: -  j1  - final index

131:    Notes:
132:    This is available for split operator only.

134:    The nonlinear operator T(lambda) is projected onto span(V), where V is
135:    an orthonormal basis built internally by the solver. The projected
136:    operator is equal to sum_i V'*A_i*V*f_i(lambda), so this function
137:    computes all matrices Ei = V'*A_i*V, and stores them in the extra
138:    matrices inside DS. Only rows/columns in the range [j0,j1-1] are computed,
139:    the previous ones are assumed to be available already.

141:    Level: developer

143: .seealso: NEPSetSplitOperator()
144: @*/
145: PetscErrorCode NEPProjectOperator(NEP nep,PetscInt j0,PetscInt j1)
146: {
148:   PetscInt       k;
149:   Mat            G;

155:   NEPCheckProblem(nep,1);
156:   NEPCheckSplit(nep,1);
157:   BVSetActiveColumns(nep->V,j0,j1);
158:   for (k=0;k<nep->nt;k++) {
159:     DSGetMat(nep->ds,DSMatExtra[k],&G);
160:     BVMatProject(nep->V,nep->A[k],nep->V,G);
161:     DSRestoreMat(nep->ds,DSMatExtra[k],&G);
162:   }
163:   return(0);
164: }

168: /*@
169:    NEPApplyFunction - Applies the nonlinear function T(lambda) to a given vector.

171:    Collective on NEP

173:    Input Parameters:
174: +  nep    - the nonlinear eigensolver context
175: .  lambda - scalar argument
176: .  x      - vector to be multiplied against
177: -  v      - workspace vector (used only in the case of split form)

179:    Output Parameters:
180: +  y   - result vector
181: .  A   - Function matrix
182: -  B   - optional preconditioning matrix

184:    Note:
185:    If the nonlinear operator is represented in split form, the result 
186:    y = T(lambda)*x is computed without building T(lambda) explicitly. In
187:    that case, parameters A and B are not used. Otherwise, the matrix
188:    T(lambda) is built and the effect is the same as a call to
189:    NEPComputeFunction() followed by a MatMult().

191:    Level: developer

193: .seealso: NEPSetSplitOperator(), NEPComputeFunction()
194: @*/
195: PetscErrorCode NEPApplyFunction(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A,Mat B)
196: {
198:   PetscInt       i;
199:   PetscScalar    alpha;


210:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) {
211:     VecSet(y,0.0);
212:     for (i=0;i<nep->nt;i++) {
213:       FNEvaluateFunction(nep->f[i],lambda,&alpha);
214:       MatMult(nep->A[i],x,v);
215:       VecAXPY(y,alpha,v);
216:     }
217:   } else {
218:     NEPComputeFunction(nep,lambda,A,B);
219:     MatMult(A,x,y);
220:   }
221:   return(0);
222: }

226: /*@
227:    NEPApplyJacobian - Applies the nonlinear Jacobian T'(lambda) to a given vector.

229:    Collective on NEP

231:    Input Parameters:
232: +  nep    - the nonlinear eigensolver context
233: .  lambda - scalar argument
234: .  x      - vector to be multiplied against
235: -  v      - workspace vector (used only in the case of split form)

237:    Output Parameters:
238: +  y   - result vector
239: -  A   - Jacobian matrix

241:    Note:
242:    If the nonlinear operator is represented in split form, the result 
243:    y = T'(lambda)*x is computed without building T'(lambda) explicitly. In
244:    that case, parameter A is not used. Otherwise, the matrix
245:    T'(lambda) is built and the effect is the same as a call to
246:    NEPComputeJacobian() followed by a MatMult().

248:    Level: developer

250: .seealso: NEPSetSplitOperator(), NEPComputeJacobian()
251: @*/
252: PetscErrorCode NEPApplyJacobian(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A)
253: {
255:   PetscInt       i;
256:   PetscScalar    alpha;


266:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) {
267:     VecSet(y,0.0);
268:     for (i=0;i<nep->nt;i++) {
269:       FNEvaluateDerivative(nep->f[i],lambda,&alpha);
270:       MatMult(nep->A[i],x,v);
271:       VecAXPY(y,alpha,v);
272:     }
273:   } else {
274:     NEPComputeJacobian(nep,lambda,A);
275:     MatMult(A,x,y);
276:   }
277:   return(0);
278: }

282: /*@
283:    NEPGetIterationNumber - Gets the current iteration number. If the
284:    call to NEPSolve() is complete, then it returns the number of iterations
285:    carried out by the solution method.

287:    Not Collective

289:    Input Parameter:
290: .  nep - the nonlinear eigensolver context

292:    Output Parameter:
293: .  its - number of iterations

295:    Level: intermediate

297:    Note:
298:    During the i-th iteration this call returns i-1. If NEPSolve() is
299:    complete, then parameter "its" contains either the iteration number at
300:    which convergence was successfully reached, or failure was detected.
301:    Call NEPGetConvergedReason() to determine if the solver converged or
302:    failed and why.

304: .seealso: NEPGetConvergedReason(), NEPSetTolerances()
305: @*/
306: PetscErrorCode NEPGetIterationNumber(NEP nep,PetscInt *its)
307: {
311:   *its = nep->its;
312:   return(0);
313: }

317: /*@
318:    NEPGetConverged - Gets the number of converged eigenpairs.

320:    Not Collective

322:    Input Parameter:
323: .  nep - the nonlinear eigensolver context

325:    Output Parameter:
326: .  nconv - number of converged eigenpairs

328:    Note:
329:    This function should be called after NEPSolve() has finished.

331:    Level: beginner

333: .seealso: NEPSetDimensions(), NEPSolve()
334: @*/
335: PetscErrorCode NEPGetConverged(NEP nep,PetscInt *nconv)
336: {
340:   NEPCheckSolved(nep,1);
341:   *nconv = nep->nconv;
342:   return(0);
343: }

347: /*@
348:    NEPGetConvergedReason - Gets the reason why the NEPSolve() iteration was
349:    stopped.

351:    Not Collective

353:    Input Parameter:
354: .  nep - the nonlinear eigensolver context

356:    Output Parameter:
357: .  reason - negative value indicates diverged, positive value converged

359:    Notes:

361:    Possible values for reason are
362: +  NEP_CONVERGED_TOL - converged up to tolerance
363: .  NEP_CONVERGED_USER - converged due to a user-defined condition
364: .  NEP_DIVERGED_ITS - required more than max_it iterations to reach convergence
365: .  NEP_DIVERGED_BREAKDOWN - generic breakdown in method
366: -  NEP_DIVERGED_LINEAR_SOLVE - inner linear solve failed

368:    Can only be called after the call to NEPSolve() is complete.

370:    Level: intermediate

372: .seealso: NEPSetTolerances(), NEPSolve(), NEPConvergedReason
373: @*/
374: PetscErrorCode NEPGetConvergedReason(NEP nep,NEPConvergedReason *reason)
375: {
379:   NEPCheckSolved(nep,1);
380:   *reason = nep->reason;
381:   return(0);
382: }

386: /*@
387:    NEPGetEigenpair - Gets the i-th solution of the eigenproblem as computed by
388:    NEPSolve(). The solution consists in both the eigenvalue and the eigenvector.

390:    Logically Collective on NEP

392:    Input Parameters:
393: +  nep - nonlinear eigensolver context
394: -  i   - index of the solution

396:    Output Parameters:
397: +  eigr - real part of eigenvalue
398: .  eigi - imaginary part of eigenvalue
399: .  Vr   - real part of eigenvector
400: -  Vi   - imaginary part of eigenvector

402:    Notes:
403:    It is allowed to pass NULL for Vr and Vi, if the eigenvector is not
404:    required. Otherwise, the caller must provide valid Vec objects, i.e.,
405:    they must be created by the calling program with e.g. MatCreateVecs().

407:    If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is
408:    configured with complex scalars the eigenvalue is stored
409:    directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is
410:    set to zero). In both cases, the user can pass NULL in eigi and Vi.

412:    The index i should be a value between 0 and nconv-1 (see NEPGetConverged()).
413:    Eigenpairs are indexed according to the ordering criterion established
414:    with NEPSetWhichEigenpairs().

416:    Level: beginner

418: .seealso: NEPSolve(), NEPGetConverged(), NEPSetWhichEigenpairs()
419: @*/
420: PetscErrorCode NEPGetEigenpair(NEP nep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)
421: {
422:   PetscInt       k;

430:   NEPCheckSolved(nep,1);
431:   if (i<0 || i>=nep->nconv) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");

433:   NEPComputeVectors(nep);
434:   k = nep->perm[i];

436:   /* eigenvalue */
437: #if defined(PETSC_USE_COMPLEX)
438:   if (eigr) *eigr = nep->eigr[k];
439:   if (eigi) *eigi = 0;
440: #else
441:   if (eigr) *eigr = nep->eigr[k];
442:   if (eigi) *eigi = nep->eigi[k];
443: #endif

445:   /* eigenvector */
446: #if defined(PETSC_USE_COMPLEX)
447:   if (Vr) { BVCopyVec(nep->V,k,Vr); }
448:   if (Vi) { VecSet(Vi,0.0); }
449: #else
450:   if (nep->eigi[k]>0) { /* first value of conjugate pair */
451:     if (Vr) { BVCopyVec(nep->V,k,Vr); }
452:     if (Vi) { BVCopyVec(nep->V,k+1,Vi); }
453:   } else if (nep->eigi[k]<0) { /* second value of conjugate pair */
454:     if (Vr) { BVCopyVec(nep->V,k-1,Vr); }
455:     if (Vi) {
456:       BVCopyVec(nep->V,k,Vi);
457:       VecScale(Vi,-1.0);
458:     }
459:   } else { /* real eigenvalue */
460:     if (Vr) { BVCopyVec(nep->V,k,Vr); }
461:     if (Vi) { VecSet(Vi,0.0); }
462:   }
463: #endif
464:   return(0);
465: }

469: /*@
470:    NEPGetErrorEstimate - Returns the error estimate associated to the i-th
471:    computed eigenpair.

473:    Not Collective

475:    Input Parameter:
476: +  nep - nonlinear eigensolver context
477: -  i   - index of eigenpair

479:    Output Parameter:
480: .  errest - the error estimate

482:    Notes:
483:    This is the error estimate used internally by the eigensolver. The actual
484:    error bound can be computed with NEPComputeRelativeError().

486:    Level: advanced

488: .seealso: NEPComputeRelativeError()
489: @*/
490: PetscErrorCode NEPGetErrorEstimate(NEP nep,PetscInt i,PetscReal *errest)
491: {
495:   NEPCheckSolved(nep,1);
496:   if (i<0 || i>=nep->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
497:   if (errest) *errest = nep->errest[nep->perm[i]];
498:   return(0);
499: }

503: /*
504:    NEPComputeResidualNorm_Private - Computes the norm of the residual vector
505:    associated with an eigenpair.

507:    Input Parameters:
508:      lambda - eigenvalue
509:      x      - eigenvector
510:      w      - array of work vectors (two vectors in split form, one vector otherwise)
511: */
512: PetscErrorCode NEPComputeResidualNorm_Private(NEP nep,PetscScalar lambda,Vec x,Vec *w,PetscReal *norm)
513: {
515:   Vec            y,z=NULL;

518:   y = w[0];
519:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) z = w[1];
520:   NEPApplyFunction(nep,lambda,x,z,y,nep->function,nep->function_pre);
521:   VecNorm(y,NORM_2,norm);
522:   return(0);
523: }

527: /*@
528:    NEPComputeError - Computes the error (based on the residual norm) associated
529:    with the i-th computed eigenpair.

531:    Collective on NEP

533:    Input Parameter:
534: +  nep  - the nonlinear eigensolver context
535: .  i    - the solution index
536: -  type - the type of error to compute

538:    Output Parameter:
539: .  error - the error

541:    Notes:
542:    The error can be computed in various ways, all of them based on the residual
543:    norm computed as ||T(lambda)x||_2 where lambda is the eigenvalue and x is the
544:    eigenvector.

546:    Level: beginner

548: .seealso: NEPErrorType, NEPSolve(), NEPGetErrorEstimate()
549: @*/
550: PetscErrorCode NEPComputeError(NEP nep,PetscInt i,NEPErrorType type,PetscReal *error)
551: {
553:   Vec            xr,xi=NULL;
554:   PetscInt       j,nwork,issplit=0;
555:   PetscScalar    kr,ki,s;
556:   PetscReal      er,z=0.0;
557:   PetscBool      flg;

564:   NEPCheckSolved(nep,1);

566:   /* allocate work vectors */
567: #if defined(PETSC_USE_COMPLEX)
568:   nwork = 2;
569: #else
570:   nwork = 3;
571: #endif
572:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) {
573:     issplit = 1;
574:     nwork++;  /* need an extra work vector for NEPComputeResidualNorm_Private */
575:   }
576:   NEPSetWorkVecs(nep,nwork);
577:   xr = nep->work[issplit+1];
578: #if !defined(PETSC_USE_COMPLEX)
579:   xi = nep->work[issplit+2];
580: #endif

582:   /* compute residual norms */
583:   NEPGetEigenpair(nep,i,&kr,&ki,xr,xi);
584: #if !defined(PETSC_USE_COMPLEX)
585:   if (ki) SETERRQ(PETSC_COMM_SELF,1,"Not implemented for complex eigenvalues with real scalars");
586: #endif
587:   NEPComputeResidualNorm_Private(nep,kr,xr,nep->work,error);
588:   VecNorm(xr,NORM_2,&er);

590:   /* compute error */
591:   switch (type) {
592:     case NEP_ERROR_ABSOLUTE:
593:       break;
594:     case NEP_ERROR_RELATIVE:
595:       *error /= PetscAbsScalar(kr)*er;
596:       break;
597:     case NEP_ERROR_BACKWARD:
598:       if (nep->fui!=NEP_USER_INTERFACE_SPLIT) {
599:         *error = 0.0;
600:         PetscInfo(nep,"Backward error only available in split form\n");
601:         break;
602:       }
603:       /* initialization of matrix norms */
604:       if (!nep->nrma[0]) {
605:         for (j=0;j<nep->nt;j++) {
606:           MatHasOperation(nep->A[j],MATOP_NORM,&flg);
607:           if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation");
608:           MatNorm(nep->A[j],NORM_INFINITY,&nep->nrma[j]);
609:         }
610:       }
611:       for (j=0;j<nep->nt;j++) {
612:         FNEvaluateFunction(nep->f[j],kr,&s);
613:         z = z + nep->nrma[j]*PetscAbsScalar(s);
614:       }
615:       *error /= z;
616:       break;
617:     default:
618:       SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type");
619:   }
620:   return(0);
621: }

625: /*@
626:    NEPComputeFunction - Computes the function matrix T(lambda) that has been
627:    set with NEPSetFunction().

629:    Collective on NEP and Mat

631:    Input Parameters:
632: +  nep    - the NEP context
633: -  lambda - the scalar argument

635:    Output Parameters:
636: +  A   - Function matrix
637: -  B   - optional preconditioning matrix

639:    Notes:
640:    NEPComputeFunction() is typically used within nonlinear eigensolvers
641:    implementations, so most users would not generally call this routine
642:    themselves.

644:    Level: developer

646: .seealso: NEPSetFunction(), NEPGetFunction()
647: @*/
648: PetscErrorCode NEPComputeFunction(NEP nep,PetscScalar lambda,Mat A,Mat B)
649: {
651:   PetscInt       i;
652:   PetscScalar    alpha;

656:   NEPCheckProblem(nep,1);
657:   switch (nep->fui) {
658:   case NEP_USER_INTERFACE_CALLBACK:
659:     if (!nep->computefunction) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_USER,"Must call NEPSetFunction() first");
660:     PetscLogEventBegin(NEP_FunctionEval,nep,A,B,0);
661:     PetscStackPush("NEP user Function function");
662:     (*nep->computefunction)(nep,lambda,A,B,nep->functionctx);
663:     PetscStackPop;
664:     PetscLogEventEnd(NEP_FunctionEval,nep,A,B,0);
665:     break;
666:   case NEP_USER_INTERFACE_SPLIT:
667:     MatZeroEntries(A);
668:     for (i=0;i<nep->nt;i++) {
669:       FNEvaluateFunction(nep->f[i],lambda,&alpha);
670:       MatAXPY(A,alpha,nep->A[i],nep->mstr);
671:     }
672:     if (A != B) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Not implemented");
673:     break;
674:   case NEP_USER_INTERFACE_DERIVATIVES:
675:     PetscLogEventBegin(NEP_DerivativesEval,nep,A,B,0);
676:     PetscStackPush("NEP user Derivatives function");
677:     (*nep->computederivatives)(nep,lambda,0,A,nep->derivativesctx);
678:     PetscStackPop;
679:     PetscLogEventEnd(NEP_DerivativesEval,nep,A,B,0);
680:     break;
681:   }
682:   return(0);
683: }

687: /*@
688:    NEPComputeJacobian - Computes the Jacobian matrix T'(lambda) that has been
689:    set with NEPSetJacobian().

691:    Collective on NEP and Mat

693:    Input Parameters:
694: +  nep    - the NEP context
695: -  lambda - the scalar argument

697:    Output Parameters:
698: .  A   - Jacobian matrix

700:    Notes:
701:    Most users should not need to explicitly call this routine, as it
702:    is used internally within the nonlinear eigensolvers.

704:    Level: developer

706: .seealso: NEPSetJacobian(), NEPGetJacobian()
707: @*/
708: PetscErrorCode NEPComputeJacobian(NEP nep,PetscScalar lambda,Mat A)
709: {
711:   PetscInt       i;
712:   PetscScalar    alpha;

716:   NEPCheckProblem(nep,1);
717:   switch (nep->fui) {
718:   case NEP_USER_INTERFACE_CALLBACK:
719:     if (!nep->computejacobian) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_USER,"Must call NEPSetJacobian() first");
720:     PetscLogEventBegin(NEP_JacobianEval,nep,A,0,0);
721:     PetscStackPush("NEP user Jacobian function");
722:     (*nep->computejacobian)(nep,lambda,A,nep->jacobianctx);
723:     PetscStackPop;
724:     PetscLogEventEnd(NEP_JacobianEval,nep,A,0,0);
725:     break;
726:   case NEP_USER_INTERFACE_SPLIT:
727:     MatZeroEntries(A);
728:     for (i=0;i<nep->nt;i++) {
729:       FNEvaluateDerivative(nep->f[i],lambda,&alpha);
730:       MatAXPY(A,alpha,nep->A[i],nep->mstr);
731:     }
732:     break;
733:   case NEP_USER_INTERFACE_DERIVATIVES:
734:     PetscLogEventBegin(NEP_DerivativesEval,nep,A,0,0);
735:     PetscStackPush("NEP user Derivatives function");
736:     (*nep->computederivatives)(nep,lambda,1,A,nep->derivativesctx);
737:     PetscStackPop;
738:     PetscLogEventEnd(NEP_DerivativesEval,nep,A,0,0);
739:     break;
740:   }
741:   return(0);
742: }

slepc-3.7.4/src/nep/interface/nepmon.c.html0000644000175000017500000010256413107004621020107 0ustar jromanjroman
Actual source code: nepmon.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       NEP routines related to monitors.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/nepimpl.h>      /*I "slepcnep.h" I*/
 25: #include <petscdraw.h>

 29: /*
 30:    Runs the user provided monitor routines, if any.
 31: */
 32: PetscErrorCode NEPMonitor(NEP nep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)
 33: {
 35:   PetscInt       i,n = nep->numbermonitors;

 38:   for (i=0;i<n;i++) {
 39:     (*nep->monitor[i])(nep,it,nconv,eigr,eigi,errest,nest,nep->monitorcontext[i]);
 40:   }
 41:   return(0);
 42: }

 46: /*@C
 47:    NEPMonitorSet - Sets an ADDITIONAL function to be called at every
 48:    iteration to monitor the error estimates for each requested eigenpair.

 50:    Logically Collective on NEP

 52:    Input Parameters:
 53: +  nep     - eigensolver context obtained from NEPCreate()
 54: .  monitor - pointer to function (if this is NULL, it turns off monitoring)
 55: .  mctx    - [optional] context for private data for the
 56:              monitor routine (use NULL if no context is desired)
 57: -  monitordestroy - [optional] routine that frees monitor context
 58:              (may be NULL)

 60:    Calling Sequence of monitor:
 61: $   monitor(NEP nep,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx)

 63: +  nep    - nonlinear eigensolver context obtained from NEPCreate()
 64: .  its    - iteration number
 65: .  nconv  - number of converged eigenpairs
 66: .  eigr   - real part of the eigenvalues
 67: .  eigi   - imaginary part of the eigenvalues
 68: .  errest - error estimates for each eigenpair
 69: .  nest   - number of error estimates
 70: -  mctx   - optional monitoring context, as set by NEPMonitorSet()

 72:    Options Database Keys:
 73: +    -nep_monitor        - print only the first error estimate
 74: .    -nep_monitor_all    - print error estimates at each iteration
 75: .    -nep_monitor_conv   - print the eigenvalue approximations only when
 76:       convergence has been reached
 77: .    -nep_monitor_lg     - sets line graph monitor for the first unconverged
 78:       approximate eigenvalue
 79: .    -nep_monitor_lg_all - sets line graph monitor for all unconverged
 80:       approximate eigenvalues
 81: -    -nep_monitor_cancel - cancels all monitors that have been hardwired into
 82:       a code by calls to NEPMonitorSet(), but does not cancel those set via
 83:       the options database.

 85:    Notes:
 86:    Several different monitoring routines may be set by calling
 87:    NEPMonitorSet() multiple times; all will be called in the
 88:    order in which they were set.

 90:    Level: intermediate

 92: .seealso: NEPMonitorFirst(), NEPMonitorAll(), NEPMonitorCancel()
 93: @*/
 94: PetscErrorCode NEPMonitorSet(NEP nep,PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
 95: {
 98:   if (nep->numbermonitors >= MAXNEPMONITORS) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Too many NEP monitors set");
 99:   nep->monitor[nep->numbermonitors]           = monitor;
100:   nep->monitorcontext[nep->numbermonitors]    = (void*)mctx;
101:   nep->monitordestroy[nep->numbermonitors++]  = monitordestroy;
102:   return(0);
103: }

107: /*@
108:    NEPMonitorCancel - Clears all monitors for a NEP object.

110:    Logically Collective on NEP

112:    Input Parameters:
113: .  nep - eigensolver context obtained from NEPCreate()

115:    Options Database Key:
116: .    -nep_monitor_cancel - Cancels all monitors that have been hardwired
117:       into a code by calls to NEPMonitorSet(),
118:       but does not cancel those set via the options database.

120:    Level: intermediate

122: .seealso: NEPMonitorSet()
123: @*/
124: PetscErrorCode NEPMonitorCancel(NEP nep)
125: {
127:   PetscInt       i;

131:   for (i=0; i<nep->numbermonitors; i++) {
132:     if (nep->monitordestroy[i]) {
133:       (*nep->monitordestroy[i])(&nep->monitorcontext[i]);
134:     }
135:   }
136:   nep->numbermonitors = 0;
137:   return(0);
138: }

142: /*@C
143:    NEPGetMonitorContext - Gets the monitor context, as set by
144:    NEPMonitorSet() for the FIRST monitor only.

146:    Not Collective

148:    Input Parameter:
149: .  nep - eigensolver context obtained from NEPCreate()

151:    Output Parameter:
152: .  ctx - monitor context

154:    Level: intermediate

156: .seealso: NEPMonitorSet(), NEPDefaultMonitor()
157: @*/
158: PetscErrorCode NEPGetMonitorContext(NEP nep,void **ctx)
159: {
162:   *ctx = nep->monitorcontext[0];
163:   return(0);
164: }

168: /*@C
169:    NEPMonitorAll - Print the current approximate values and
170:    error estimates at each iteration of the nonlinear eigensolver.

172:    Collective on NEP

174:    Input Parameters:
175: +  nep    - nonlinear eigensolver context
176: .  its    - iteration number
177: .  nconv  - number of converged eigenpairs so far
178: .  eigr   - real part of the eigenvalues
179: .  eigi   - imaginary part of the eigenvalues
180: .  errest - error estimates
181: .  nest   - number of error estimates to display
182: -  vf     - viewer and format for monitoring

184:    Level: intermediate

186: .seealso: NEPMonitorSet(), NEPMonitorFirst(), NEPMonitorConverged()
187: @*/
188: PetscErrorCode NEPMonitorAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
189: {
191:   PetscInt       i;
192:   PetscViewer    viewer;

197:   viewer = vf->viewer;
199:   PetscViewerPushFormat(viewer,vf->format);
200:   PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);
201:   if (its==1 && ((PetscObject)nep)->prefix) {
202:     PetscViewerASCIIPrintf(viewer,"  Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)nep)->prefix);
203:   }
204:   PetscViewerASCIIPrintf(viewer,"%3D NEP nconv=%D Values (Errors)",its,nconv);
205:   PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
206:   for (i=0;i<nest;i++) {
207: #if defined(PETSC_USE_COMPLEX)
208:     PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(eigr[i]),(double)PetscImaginaryPart(eigr[i]));
209: #else
210:     PetscViewerASCIIPrintf(viewer," %g",(double)eigr[i]);
211:     if (eigi[i]!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)eigi[i]); }
212: #endif
213:     PetscViewerASCIIPrintf(viewer," (%10.8e)",(double)errest[i]);
214:   }
215:   PetscViewerASCIIPrintf(viewer,"\n");
216:   PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
217:   PetscViewerASCIISubtractTab(viewer,((PetscObject)nep)->tablevel);
218:   PetscViewerPopFormat(viewer);
219:   return(0);
220: }

224: /*@C
225:    NEPMonitorFirst - Print the first unconverged approximate value and
226:    error estimate at each iteration of the nonlinear eigensolver.

228:    Collective on NEP

230:    Input Parameters:
231: +  nep    - nonlinear eigensolver context
232: .  its    - iteration number
233: .  nconv  - number of converged eigenpairs so far
234: .  eigr   - real part of the eigenvalues
235: .  eigi   - imaginary part of the eigenvalues
236: .  errest - error estimates
237: .  nest   - number of error estimates to display
238: -  vf     - viewer and format for monitoring

240:    Level: intermediate

242: .seealso: NEPMonitorSet(), NEPMonitorAll(), NEPMonitorConverged()
243: @*/
244: PetscErrorCode NEPMonitorFirst(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
245: {
247:   PetscViewer    viewer;

252:   viewer = vf->viewer;
254:   if (its==1 && ((PetscObject)nep)->prefix) {
255:     PetscViewerASCIIPrintf(viewer,"  Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)nep)->prefix);
256:   }
257:   if (nconv<nest) {
258:     PetscViewerPushFormat(viewer,vf->format);
259:     PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);
260:     PetscViewerASCIIPrintf(viewer,"%3D NEP nconv=%D first unconverged value (error)",its,nconv);
261:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
262: #if defined(PETSC_USE_COMPLEX)
263:     PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(eigr[nconv]),(double)PetscImaginaryPart(eigr[nconv]));
264: #else
265:     PetscViewerASCIIPrintf(viewer," %g",(double)eigr[nconv]);
266:     if (eigi[nconv]!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)eigi[nconv]); }
267: #endif
268:     PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);
269:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
270:     PetscViewerASCIISubtractTab(viewer,((PetscObject)nep)->tablevel);
271:     PetscViewerPopFormat(viewer);
272:   }
273:   return(0);
274: }

278: /*@C
279:    NEPMonitorConverged - Print the approximate values and
280:    error estimates as they converge.

282:    Collective on NEP

284:    Input Parameters:
285: +  nep    - nonlinear eigensolver context
286: .  its    - iteration number
287: .  nconv  - number of converged eigenpairs so far
288: .  eigr   - real part of the eigenvalues
289: .  eigi   - imaginary part of the eigenvalues
290: .  errest - error estimates
291: .  nest   - number of error estimates to display
292: -  ctx    - monitor context

294:    Level: intermediate

296: .seealso: NEPMonitorSet(), NEPMonitorFirst(), NEPMonitorAll()
297: @*/
298: PetscErrorCode NEPMonitorConverged(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
299: {
301:   PetscInt       i;
302:   PetscViewer    viewer;

307:   viewer = ctx->viewer;
309:   if (its==1 && ((PetscObject)nep)->prefix) {
310:     PetscViewerASCIIPrintf(viewer,"  Convergence history for %s solve.\n",((PetscObject)nep)->prefix);
311:   }
312:   if (its==1) ctx->oldnconv = 0;
313:   if (ctx->oldnconv!=nconv) {
314:     PetscViewerPushFormat(viewer,ctx->format);
315:     PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);
316:     for (i=ctx->oldnconv;i<nconv;i++) {
317:       PetscViewerASCIIPrintf(viewer,"%3D NEP converged value (error) #%D",its,i);
318:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
319: #if defined(PETSC_USE_COMPLEX)
320:       PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(eigr[i]),(double)PetscImaginaryPart(eigr[i]));
321: #else
322:       PetscViewerASCIIPrintf(viewer," %g",(double)eigr[i]);
323:       if (eigi[i]!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)eigi[i]); }
324: #endif
325:       PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[i]);
326:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
327:     }
328:     PetscViewerASCIISubtractTab(viewer,((PetscObject)nep)->tablevel);
329:     PetscViewerPopFormat(viewer);
330:     ctx->oldnconv = nconv;
331:   }
332:   return(0);
333: }

337: /*@C
338:    NEPMonitorLGCreate - Creates a line graph context for use with
339:    NEP to monitor convergence.

341:    Collective on MPI_Comm

343:    Input Parameters:
344: +  comm - communicator context
345: .  host - the X display to open, or null for the local machine
346: .  label - the title to put in the title bar
347: .  x, y - the screen coordinates of the upper left coordinate of
348:           the window
349: -  m, n - the screen width and height in pixels

351:    Output Parameter:
352: .  lgctx - the drawing context

354:    Options Database Keys:
355: +  -nep_monitor_lg - Sets line graph monitor for the first residual
356: -  -nep_monitor_lg_all - Sets line graph monitor for all residuals

358:    Notes:
359:    Use PetscDrawLGDestroy() to destroy this line graph.

361:    Level: intermediate

363: .seealso: NEPMonitorSet()
364: @*/
365: PetscErrorCode NEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
366: {
367:   PetscDraw      draw;
368:   PetscDrawLG    lg;

372:   PetscDrawCreate(comm,host,label,x,y,m,n,&draw);
373:   PetscDrawSetFromOptions(draw);
374:   PetscDrawLGCreate(draw,1,&lg);
375:   PetscDrawLGSetFromOptions(lg);
376:   PetscDrawDestroy(&draw);
377:   *lgctx = lg;
378:   return(0);
379: }

383: PetscErrorCode NEPMonitorLG(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
384: {
385:   PetscDrawLG    lg = (PetscDrawLG)ctx;
386:   PetscReal      x,y;

391:   if (its==1) {
392:     PetscDrawLGReset(lg);
393:     PetscDrawLGSetDimension(lg,1);
394:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(nep->tol)-2,0.0);
395:   }
396:   x = (PetscReal)its;
397:   if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]);
398:   else y = 0.0;
399:   PetscDrawLGAddPoint(lg,&x,&y);
400:   if (its <= 20 || !(its % 5) || nep->reason) {
401:     PetscDrawLGDraw(lg);
402:     PetscDrawLGSave(lg);
403:   }
404:   return(0);
405: }

409: PetscErrorCode NEPMonitorLGAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
410: {
411:   PetscDrawLG    lg = (PetscDrawLG)ctx;
412:   PetscInt       i,n = PetscMin(nep->nev,255);
413:   PetscReal      *x,*y;

418:   if (its==1) {
419:     PetscDrawLGReset(lg);
420:     PetscDrawLGSetDimension(lg,n);
421:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(nep->tol)-2,0.0);
422:   }
423:   PetscMalloc2(n,&x,n,&y);
424:   for (i=0;i<n;i++) {
425:     x[i] = (PetscReal)its;
426:     if (i < nest && errest[i] > 0.0) y[i] = PetscLog10Real(errest[i]);
427:     else y[i] = 0.0;
428:   }
429:   PetscDrawLGAddPoint(lg,x,y);
430:   if (its <= 20 || !(its % 5) || nep->reason) {
431:     PetscDrawLGDraw(lg);
432:     PetscDrawLGSave(lg);
433:   }
434:   PetscFree2(x,y);
435:   return(0);
436: }

slepc-3.7.4/src/nep/interface/nepbasic.c0000644000175000017500000007320213107004621017430 0ustar jromanjroman/* Basic NEP routines, Create, View, etc. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ PetscFunctionList NEPList = 0; PetscBool NEPRegisterAllCalled = PETSC_FALSE; PetscClassId NEP_CLASSID = 0; PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0; #undef __FUNCT__ #define __FUNCT__ "NEPCreate" /*@ NEPCreate - Creates the default NEP context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . nep - location to put the NEP context Level: beginner .seealso: NEPSetUp(), NEPSolve(), NEPDestroy(), NEP @*/ PetscErrorCode NEPCreate(MPI_Comm comm,NEP *outnep) { PetscErrorCode ierr; NEP nep; PetscFunctionBegin; PetscValidPointer(outnep,2); *outnep = 0; ierr = NEPInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(nep,NEP_CLASSID,"NEP","Nonlinear Eigenvalue Problem","NEP",comm,NEPDestroy,NEPView);CHKERRQ(ierr); nep->max_it = 0; nep->nev = 1; nep->ncv = 0; nep->mpd = 0; nep->nini = 0; nep->target = 0.0; nep->tol = PETSC_DEFAULT; nep->conv = NEP_CONV_REL; nep->stop = NEP_STOP_BASIC; nep->which = (NEPWhich)0; nep->refine = NEP_REFINE_NONE; nep->npart = 1; nep->rtol = PETSC_DEFAULT; nep->rits = PETSC_DEFAULT; nep->scheme = (NEPRefineScheme)0; nep->trackall = PETSC_FALSE; nep->computefunction = NULL; nep->computejacobian = NULL; nep->functionctx = NULL; nep->jacobianctx = NULL; nep->computederivatives = NULL; nep->derivativesctx = NULL; nep->converged = NEPConvergedRelative; nep->convergeddestroy= NULL; nep->stopping = NEPStoppingBasic; nep->stoppingdestroy = NULL; nep->convergedctx = NULL; nep->stoppingctx = NULL; nep->numbermonitors = 0; nep->ds = NULL; nep->V = NULL; nep->rg = NULL; nep->function = NULL; nep->function_pre = NULL; nep->jacobian = NULL; nep->derivatives = NULL; nep->A = NULL; nep->f = NULL; nep->nt = 0; nep->mstr = DIFFERENT_NONZERO_PATTERN; nep->IS = NULL; nep->eigr = NULL; nep->eigi = NULL; nep->errest = NULL; nep->perm = NULL; nep->nwork = 0; nep->work = NULL; nep->data = NULL; nep->state = NEP_STATE_INITIAL; nep->nconv = 0; nep->its = 0; nep->n = 0; nep->nloc = 0; nep->nrma = NULL; nep->fui = (NEPUserInterface)0; nep->reason = NEP_CONVERGED_ITERATING; ierr = PetscNewLog(nep,&nep->sc);CHKERRQ(ierr); *outnep = nep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetType" /*@C NEPSetType - Selects the particular solver to be used in the NEP object. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - type - a known method Options Database Key: . -nep_type - Sets the method; use -help for a list of available methods Notes: See "slepc/include/slepcnep.h" for available methods. Normally, it is best to use the NEPSetFromOptions() command and then set the NEP type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The NEPSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database. Level: intermediate .seealso: NEPType @*/ PetscErrorCode NEPSetType(NEP nep,NEPType type) { PetscErrorCode ierr,(*r)(NEP); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)nep,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(NEPList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown NEP type given: %s",type); if (nep->ops->destroy) { ierr = (*nep->ops->destroy)(nep);CHKERRQ(ierr); } ierr = PetscMemzero(nep->ops,sizeof(struct _NEPOps));CHKERRQ(ierr); nep->state = NEP_STATE_INITIAL; ierr = PetscObjectChangeTypeName((PetscObject)nep,type);CHKERRQ(ierr); ierr = (*r)(nep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetType" /*@C NEPGetType - Gets the NEP type as a string from the NEP object. Not Collective Input Parameter: . nep - the eigensolver context Output Parameter: . name - name of NEP method Level: intermediate .seealso: NEPSetType() @*/ PetscErrorCode NEPGetType(NEP nep,NEPType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)nep)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRegister" /*@C NEPRegister - Adds a method to the nonlinear eigenproblem solver package. Not Collective Input Parameters: + name - name of a new user-defined solver - function - routine to create the solver context Notes: NEPRegister() may be called multiple times to add several user-defined solvers. Sample usage: .vb NEPRegister("my_solver",MySolverCreate); .ve Then, your solver can be chosen with the procedural interface via $ NEPSetType(nep,"my_solver") or at runtime via the option $ -nep_type my_solver Level: advanced .seealso: NEPRegisterAll() @*/ PetscErrorCode NEPRegister(const char *name,PetscErrorCode (*function)(NEP)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&NEPList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReset_Problem" /* NEPReset_Problem - Destroys the problem matrices. @*/ PetscErrorCode NEPReset_Problem(NEP nep) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = MatDestroy(&nep->function);CHKERRQ(ierr); ierr = MatDestroy(&nep->function_pre);CHKERRQ(ierr); ierr = MatDestroy(&nep->jacobian);CHKERRQ(ierr); ierr = MatDestroy(&nep->derivatives);CHKERRQ(ierr); if (nep->fui==NEP_USER_INTERFACE_SPLIT) { ierr = MatDestroyMatrices(nep->nt,&nep->A);CHKERRQ(ierr); for (i=0;int;i++) { ierr = FNDestroy(&nep->f[i]);CHKERRQ(ierr); } ierr = PetscFree(nep->f);CHKERRQ(ierr); ierr = PetscFree(nep->nrma);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReset" /*@ NEPReset - Resets the NEP context to the initial state and removes any allocated objects. Collective on NEP Input Parameter: . nep - eigensolver context obtained from NEPCreate() Level: advanced .seealso: NEPDestroy() @*/ PetscErrorCode NEPReset(NEP nep) { PetscErrorCode ierr; PetscInt ncols; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (nep->ops->reset) { ierr = (nep->ops->reset)(nep);CHKERRQ(ierr); } if (nep->ds) { ierr = DSReset(nep->ds);CHKERRQ(ierr); } ierr = NEPReset_Problem(nep);CHKERRQ(ierr); ierr = BVGetSizes(nep->V,NULL,NULL,&ncols);CHKERRQ(ierr); if (ncols) { ierr = PetscFree4(nep->eigr,nep->eigi,nep->errest,nep->perm);CHKERRQ(ierr); } ierr = BVDestroy(&nep->V);CHKERRQ(ierr); ierr = VecDestroyVecs(nep->nwork,&nep->work);CHKERRQ(ierr); ierr = KSPDestroy(&nep->refineksp);CHKERRQ(ierr); ierr = PetscSubcommDestroy(&nep->refinesubc);CHKERRQ(ierr); nep->nwork = 0; nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPDestroy" /*@ NEPDestroy - Destroys the NEP context. Collective on NEP Input Parameter: . nep - eigensolver context obtained from NEPCreate() Level: beginner .seealso: NEPCreate(), NEPSetUp(), NEPSolve() @*/ PetscErrorCode NEPDestroy(NEP *nep) { PetscErrorCode ierr; PetscFunctionBegin; if (!*nep) PetscFunctionReturn(0); PetscValidHeaderSpecific(*nep,NEP_CLASSID,1); if (--((PetscObject)(*nep))->refct > 0) { *nep = 0; PetscFunctionReturn(0); } ierr = NEPReset(*nep);CHKERRQ(ierr); if ((*nep)->ops->destroy) { ierr = (*(*nep)->ops->destroy)(*nep);CHKERRQ(ierr); } ierr = RGDestroy(&(*nep)->rg);CHKERRQ(ierr); ierr = DSDestroy(&(*nep)->ds);CHKERRQ(ierr); ierr = PetscFree((*nep)->sc);CHKERRQ(ierr); /* just in case the initial vectors have not been used */ ierr = SlepcBasisDestroy_Private(&(*nep)->nini,&(*nep)->IS);CHKERRQ(ierr); if ((*nep)->convergeddestroy) { ierr = (*(*nep)->convergeddestroy)((*nep)->convergedctx);CHKERRQ(ierr); } ierr = NEPMonitorCancel(*nep);CHKERRQ(ierr); ierr = PetscHeaderDestroy(nep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetBV" /*@ NEPSetBV - Associates a basis vectors object to the nonlinear eigensolver. Collective on NEP Input Parameters: + nep - eigensolver context obtained from NEPCreate() - bv - the basis vectors object Note: Use NEPGetBV() to retrieve the basis vectors context (for example, to free it at the end of the computations). Level: advanced .seealso: NEPGetBV() @*/ PetscErrorCode NEPSetBV(NEP nep,BV bv) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidHeaderSpecific(bv,BV_CLASSID,2); PetscCheckSameComm(nep,1,bv,2); ierr = PetscObjectReference((PetscObject)bv);CHKERRQ(ierr); ierr = BVDestroy(&nep->V);CHKERRQ(ierr); nep->V = bv; ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetBV" /*@ NEPGetBV - Obtain the basis vectors object associated to the nonlinear eigensolver object. Not Collective Input Parameters: . nep - eigensolver context obtained from NEPCreate() Output Parameter: . bv - basis vectors context Level: advanced .seealso: NEPSetBV() @*/ PetscErrorCode NEPGetBV(NEP nep,BV *bv) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(bv,2); if (!nep->V) { ierr = BVCreate(PetscObjectComm((PetscObject)nep),&nep->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->V);CHKERRQ(ierr); } *bv = nep->V; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetRG" /*@ NEPSetRG - Associates a region object to the nonlinear eigensolver. Collective on NEP Input Parameters: + nep - eigensolver context obtained from NEPCreate() - rg - the region object Note: Use NEPGetRG() to retrieve the region context (for example, to free it at the end of the computations). Level: advanced .seealso: NEPGetRG() @*/ PetscErrorCode NEPSetRG(NEP nep,RG rg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidHeaderSpecific(rg,RG_CLASSID,2); PetscCheckSameComm(nep,1,rg,2); ierr = PetscObjectReference((PetscObject)rg);CHKERRQ(ierr); ierr = RGDestroy(&nep->rg);CHKERRQ(ierr); nep->rg = rg; ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->rg);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetRG" /*@ NEPGetRG - Obtain the region object associated to the nonlinear eigensolver object. Not Collective Input Parameters: . nep - eigensolver context obtained from NEPCreate() Output Parameter: . rg - region context Level: advanced .seealso: NEPSetRG() @*/ PetscErrorCode NEPGetRG(NEP nep,RG *rg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(rg,2); if (!nep->rg) { ierr = RGCreate(PetscObjectComm((PetscObject)nep),&nep->rg);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->rg);CHKERRQ(ierr); } *rg = nep->rg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetDS" /*@ NEPSetDS - Associates a direct solver object to the nonlinear eigensolver. Collective on NEP Input Parameters: + nep - eigensolver context obtained from NEPCreate() - ds - the direct solver object Note: Use NEPGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations). Level: advanced .seealso: NEPGetDS() @*/ PetscErrorCode NEPSetDS(NEP nep,DS ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidHeaderSpecific(ds,DS_CLASSID,2); PetscCheckSameComm(nep,1,ds,2); ierr = PetscObjectReference((PetscObject)ds);CHKERRQ(ierr); ierr = DSDestroy(&nep->ds);CHKERRQ(ierr); nep->ds = ds; ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetDS" /*@ NEPGetDS - Obtain the direct solver object associated to the nonlinear eigensolver object. Not Collective Input Parameters: . nep - eigensolver context obtained from NEPCreate() Output Parameter: . ds - direct solver context Level: advanced .seealso: NEPSetDS() @*/ PetscErrorCode NEPGetDS(NEP nep,DS *ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(ds,2); if (!nep->ds) { ierr = DSCreate(PetscObjectComm((PetscObject)nep),&nep->ds);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->ds);CHKERRQ(ierr); } *ds = nep->ds; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRefineGetKSP" /*@ NEPRefineGetKSP - Obtain the ksp object used by the eigensolver object in the refinement phase. Not Collective Input Parameters: . nep - eigensolver context obtained from NEPCreate() Output Parameter: . ksp - ksp context Level: advanced .seealso: NEPSetRefine() @*/ PetscErrorCode NEPRefineGetKSP(NEP nep,KSP *ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(ksp,2); if (!nep->refineksp) { if (nep->npart>1) { /* Split in subcomunicators */ ierr = PetscSubcommCreate(PetscObjectComm((PetscObject)nep),&nep->refinesubc);CHKERRQ(ierr); ierr = PetscSubcommSetNumber(nep->refinesubc,nep->npart);CHKERRQ(ierr);CHKERRQ(ierr); ierr = PetscSubcommSetType(nep->refinesubc,PETSC_SUBCOMM_CONTIGUOUS);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)nep,sizeof(PetscSubcomm));CHKERRQ(ierr); } ierr = KSPCreate((nep->npart==1)?PetscObjectComm((PetscObject)nep):PetscSubcommChild(nep->refinesubc),&nep->refineksp);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->refineksp);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(*ksp,((PetscObject)nep)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(*ksp,"nep_refine_");CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(*ksp,PETSC_TRUE);CHKERRQ(ierr); } *ksp = nep->refineksp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetTarget" /*@ NEPSetTarget - Sets the value of the target. Logically Collective on NEP Input Parameters: + nep - eigensolver context - target - the value of the target Options Database Key: . -nep_target - the value of the target Notes: The target is a scalar value used to determine the portion of the spectrum of interest. It is used in combination with NEPSetWhichEigenpairs(). In the case of complex scalars, a complex value can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -nep_target 1.0+2.0i Level: intermediate .seealso: NEPGetTarget(), NEPSetWhichEigenpairs() @*/ PetscErrorCode NEPSetTarget(NEP nep,PetscScalar target) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveScalar(nep,target,2); nep->target = target; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetTarget" /*@ NEPGetTarget - Gets the value of the target. Not Collective Input Parameter: . nep - eigensolver context Output Parameter: . target - the value of the target Note: If the target was not set by the user, then zero is returned. Level: intermediate .seealso: NEPSetTarget() @*/ PetscErrorCode NEPGetTarget(NEP nep,PetscScalar* target) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidScalarPointer(target,2); *target = nep->target; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetFunction" /*@C NEPSetFunction - Sets the function to compute the nonlinear Function T(lambda) as well as the location to store the matrix. Logically Collective on NEP and Mat Input Parameters: + nep - the NEP context . A - Function matrix . B - preconditioner matrix (usually same as the Function) . fun - Function evaluation routine (if NULL then NEP retains any previously set value) - ctx - [optional] user-defined context for private data for the Function evaluation routine (may be NULL) (if NULL then NEP retains any previously set value) Calling Sequence of fun: $ fun(NEP nep,PetscScalar lambda,Mat F,Mat P,void *ctx) + nep - the NEP context . lambda - the scalar argument where T(.) must be evaluated . T - matrix that will contain T(lambda) . P - (optional) different matrix to build the preconditioner - ctx - (optional) user-defined context, as set by NEPSetFunction() Level: beginner .seealso: NEPGetFunction(), NEPSetJacobian() @*/ PetscErrorCode NEPSetFunction(NEP nep,Mat A,Mat B,PetscErrorCode (*fun)(NEP,PetscScalar,Mat,Mat,void*),void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (A) PetscValidHeaderSpecific(A,MAT_CLASSID,2); if (B) PetscValidHeaderSpecific(B,MAT_CLASSID,3); if (A) PetscCheckSameComm(nep,1,A,2); if (B) PetscCheckSameComm(nep,1,B,3); if (nep->fui && nep->fui!=NEP_USER_INTERFACE_CALLBACK) { /* clean previous user info */ ierr = NEPReset_Problem(nep);CHKERRQ(ierr); } if (fun) nep->computefunction = fun; if (ctx) nep->functionctx = ctx; if (A) { ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr); ierr = MatDestroy(&nep->function);CHKERRQ(ierr); nep->function = A; } if (B) { ierr = PetscObjectReference((PetscObject)B);CHKERRQ(ierr); ierr = MatDestroy(&nep->function_pre);CHKERRQ(ierr); nep->function_pre = B; } nep->fui = NEP_USER_INTERFACE_CALLBACK; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetFunction" /*@C NEPGetFunction - Returns the Function matrix and optionally the user provided context for evaluating the Function. Not Collective, but Mat object will be parallel if NEP object is Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + A - location to stash Function matrix (or NULL) . B - location to stash preconditioner matrix (or NULL) . fun - location to put Function function (or NULL) - ctx - location to stash Function context (or NULL) Level: advanced .seealso: NEPSetFunction() @*/ PetscErrorCode NEPGetFunction(NEP nep,Mat *A,Mat *B,PetscErrorCode (**fun)(NEP,PetscScalar,Mat,Mat,void*),void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckCallback(nep,1); if (A) *A = nep->function; if (B) *B = nep->function_pre; if (fun) *fun = nep->computefunction; if (ctx) *ctx = nep->functionctx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetJacobian" /*@C NEPSetJacobian - Sets the function to compute Jacobian T'(lambda) as well as the location to store the matrix. Logically Collective on NEP and Mat Input Parameters: + nep - the NEP context . A - Jacobian matrix . jac - Jacobian evaluation routine (if NULL then NEP retains any previously set value) - ctx - [optional] user-defined context for private data for the Jacobian evaluation routine (may be NULL) (if NULL then NEP retains any previously set value) Calling Sequence of jac: $ jac(NEP nep,PetscScalar lambda,Mat J,void *ctx) + nep - the NEP context . lambda - the scalar argument where T'(.) must be evaluated . J - matrix that will contain T'(lambda) - ctx - (optional) user-defined context, as set by NEPSetJacobian() Level: beginner .seealso: NEPSetFunction(), NEPGetJacobian() @*/ PetscErrorCode NEPSetJacobian(NEP nep,Mat A,PetscErrorCode (*jac)(NEP,PetscScalar,Mat,void*),void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (A) PetscValidHeaderSpecific(A,MAT_CLASSID,2); if (A) PetscCheckSameComm(nep,1,A,2); if (nep->fui && nep->fui!=NEP_USER_INTERFACE_CALLBACK) { /* clean previous user info */ ierr = NEPReset_Problem(nep);CHKERRQ(ierr); } if (jac) nep->computejacobian = jac; if (ctx) nep->jacobianctx = ctx; if (A) { ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr); ierr = MatDestroy(&nep->jacobian);CHKERRQ(ierr); nep->jacobian = A; } nep->fui = NEP_USER_INTERFACE_CALLBACK; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetJacobian" /*@C NEPGetJacobian - Returns the Jacobian matrix and optionally the user provided routine and context for evaluating the Jacobian. Not Collective, but Mat object will be parallel if NEP object is Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + A - location to stash Jacobian matrix (or NULL) . jac - location to put Jacobian function (or NULL) - ctx - location to stash Jacobian context (or NULL) Level: advanced .seealso: NEPSetJacobian() @*/ PetscErrorCode NEPGetJacobian(NEP nep,Mat *A,PetscErrorCode (**jac)(NEP,PetscScalar,Mat,void*),void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckCallback(nep,1); if (A) *A = nep->jacobian; if (jac) *jac = nep->computejacobian; if (ctx) *ctx = nep->jacobianctx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetSplitOperator" /*@ NEPSetSplitOperator - Sets the operator of the nonlinear eigenvalue problem in split form. Collective on NEP, Mat and FN Input Parameters: + nep - the nonlinear eigensolver context . n - number of terms in the split form . A - array of matrices . f - array of functions - str - structure flag for matrices Notes: The nonlinear operator is written as T(lambda) = sum_i A_i*f_i(lambda), for i=1,...,n. The derivative T'(lambda) can be obtained using the derivatives of f_i. The structure flag provides information about A_i's nonzero pattern (see MatStructure enum). If all matrices have the same pattern, then use SAME_NONZERO_PATTERN. If the patterns are different but contained in the pattern of the first one, then use SUBSET_NONZERO_PATTERN. Otherwise use DIFFERENT_NONZERO_PATTERN. This function must be called before NEPSetUp(). If it is called again after NEPSetUp() then the NEP object is reset. Level: beginner .seealso: NEPGetSplitOperatorTerm(), NEPGetSplitOperatorInfo() @*/ PetscErrorCode NEPSetSplitOperator(NEP nep,PetscInt n,Mat A[],FN f[],MatStructure str) { PetscInt i; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,n,2); if (n <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Must have one or more terms, you have %D",n); PetscValidPointer(A,3); PetscCheckSameComm(nep,1,*A,3); PetscValidPointer(f,4); PetscCheckSameComm(nep,1,*f,4); if (nep->state) { ierr = NEPReset(nep);CHKERRQ(ierr); } /* clean previously stored information */ ierr = NEPReset_Problem(nep);CHKERRQ(ierr); /* allocate space and copy matrices and functions */ ierr = PetscMalloc1(n,&nep->A);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)nep,n*sizeof(Mat));CHKERRQ(ierr); for (i=0;iA[i] = A[i]; } ierr = PetscMalloc1(n,&nep->f);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)nep,n*sizeof(FN));CHKERRQ(ierr); for (i=0;if[i] = f[i]; } ierr = PetscCalloc1(n,&nep->nrma);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)nep,n*sizeof(PetscReal));CHKERRQ(ierr); nep->nt = n; nep->mstr = str; nep->fui = NEP_USER_INTERFACE_SPLIT; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetSplitOperatorTerm" /*@ NEPGetSplitOperatorTerm - Gets the matrices and functions associated with the nonlinear operator in split form. Not collective, though parallel Mats and FNs are returned if the NEP is parallel Input Parameter: + nep - the nonlinear eigensolver context - k - the index of the requested term (starting in 0) Output Parameters: + A - the matrix of the requested term - f - the function of the requested term Level: intermediate .seealso: NEPSetSplitOperator(), NEPGetSplitOperatorInfo() @*/ PetscErrorCode NEPGetSplitOperatorTerm(NEP nep,PetscInt k,Mat *A,FN *f) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckSplit(nep,1); if (k<0 || k>=nep->nt) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",nep->nt-1); if (A) *A = nep->A[k]; if (f) *f = nep->f[k]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetSplitOperatorInfo" /*@ NEPGetSplitOperatorInfo - Returns the number of terms of the split form of the nonlinear operator, as well as the structure flag for matrices. Not collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + n - the number of terms passed in NEPSetSplitOperator() - str - the matrix structure flag passed in NEPSetSplitOperator() Level: intermediate .seealso: NEPSetSplitOperator(), NEPGetSplitOperatorTerm() @*/ PetscErrorCode NEPGetSplitOperatorInfo(NEP nep,PetscInt *n,MatStructure *str) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckSplit(nep,1); if (n) *n = nep->nt; if (str) *str = nep->mstr; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetDerivatives" /*@C NEPSetDerivatives - Sets the function to compute the k-th derivative T^(k)(lambda) for any value of k (including 0), as well as the location to store the matrix. Logically Collective on NEP and Mat Input Parameters: + nep - the NEP context . A - the matrix to store the computed derivative . der - routing to evaluate the k-th derivative (if NULL then NEP retains any previously set value) - ctx - [optional] user-defined context for private data for the derivatives evaluation routine (may be NULL) (if NULL then NEP retains any previously set value) Level: beginner .seealso: NEPSetFunction(), NEPGetDerivatives() @*/ PetscErrorCode NEPSetDerivatives(NEP nep,Mat A,PetscErrorCode (*der)(NEP,PetscScalar,PetscInt,Mat,void*),void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (A) PetscValidHeaderSpecific(A,MAT_CLASSID,2); if (A) PetscCheckSameComm(nep,1,A,2); if (nep->fui && nep->fui!=NEP_USER_INTERFACE_DERIVATIVES) { /* clean previous user info */ ierr = NEPReset_Problem(nep);CHKERRQ(ierr); } if (der) nep->computederivatives = der; if (ctx) nep->derivativesctx = ctx; if (A) { ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr); ierr = MatDestroy(&nep->derivatives);CHKERRQ(ierr); nep->derivatives = A; } nep->fui = NEP_USER_INTERFACE_DERIVATIVES; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetDerivatives" /*@C NEPGetDerivatives - Returns the derivatives matrix and optionally the user provided routine and context for evaluating the derivatives. Not Collective, but Mat object will be parallel if NEP object is Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + A - location to stash the derivatives matrix (or NULL) . der - location to put derivatives function (or NULL) - ctx - location to stash derivatives context (or NULL) Level: advanced .seealso: NEPSetDerivatives() @*/ PetscErrorCode NEPGetDerivatives(NEP nep,Mat *A,PetscErrorCode (**der)(NEP,PetscScalar,PetscInt,Mat,void*),void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckDerivatives(nep,1); if (A) *A = nep->derivatives; if (der) *der = nep->computederivatives; if (ctx) *ctx = nep->derivativesctx; PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/nepsolve.c0000644000175000017500000005531613107004621017505 0ustar jromanjroman/* NEP routines related to the solution process. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "NEPComputeVectors" PetscErrorCode NEPComputeVectors(NEP nep) { PetscErrorCode ierr; PetscFunctionBegin; NEPCheckSolved(nep,1); switch (nep->state) { case NEP_STATE_SOLVED: if (nep->ops->computevectors) { ierr = (*nep->ops->computevectors)(nep);CHKERRQ(ierr); } break; default: break; } nep->state = NEP_STATE_EIGENVECTORS; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSolve" /*@ NEPSolve - Solves the nonlinear eigensystem. Collective on NEP Input Parameter: . nep - eigensolver context obtained from NEPCreate() Options Database Keys: + -nep_view - print information about the solver used . -nep_view_vectors binary - save the computed eigenvectors to the default binary viewer . -nep_view_values - print computed eigenvalues . -nep_converged_reason - print reason for convergence, and number of iterations . -nep_error_absolute - print absolute errors of each eigenpair - -nep_error_relative - print relative errors of each eigenpair Level: beginner .seealso: NEPCreate(), NEPSetUp(), NEPDestroy(), NEPSetTolerances() @*/ PetscErrorCode NEPSolve(NEP nep) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (nep->state>=NEP_STATE_SOLVED) PetscFunctionReturn(0); ierr = PetscLogEventBegin(NEP_Solve,nep,0,0,0);CHKERRQ(ierr); /* call setup */ ierr = NEPSetUp(nep);CHKERRQ(ierr); nep->nconv = 0; nep->its = 0; for (i=0;incv;i++) { nep->eigr[i] = 0.0; nep->eigi[i] = 0.0; nep->errest[i] = 0.0; nep->perm[i] = i; } ierr = NEPViewFromOptions(nep,NULL,"-nep_view_pre");CHKERRQ(ierr); ierr = (*nep->ops->solve)(nep);CHKERRQ(ierr); nep->state = NEP_STATE_SOLVED; if (!nep->reason) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason"); if (nep->refine==NEP_REFINE_SIMPLE && nep->rits>0 && nep->nconv>0) { ierr = NEPComputeVectors(nep);CHKERRQ(ierr); ierr = NEPNewtonRefinementSimple(nep,&nep->rits,nep->rtol,nep->nconv);CHKERRQ(ierr); nep->state = NEP_STATE_EIGENVECTORS; } /* sort eigenvalues according to nep->which parameter */ ierr = SlepcSortEigenvalues(nep->sc,nep->nconv,nep->eigr,nep->eigi,nep->perm);CHKERRQ(ierr); ierr = PetscLogEventEnd(NEP_Solve,nep,0,0,0);CHKERRQ(ierr); /* various viewers */ ierr = NEPViewFromOptions(nep,NULL,"-nep_view");CHKERRQ(ierr); ierr = NEPReasonViewFromOptions(nep);CHKERRQ(ierr); ierr = NEPErrorViewFromOptions(nep);CHKERRQ(ierr); ierr = NEPValuesViewFromOptions(nep);CHKERRQ(ierr); ierr = NEPVectorsViewFromOptions(nep);CHKERRQ(ierr); /* Remove the initial subspace */ nep->nini = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPProjectOperator" /*@ NEPProjectOperator - Computes the projection of the nonlinear operator. Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . j0 - initial index - j1 - final index Notes: This is available for split operator only. The nonlinear operator T(lambda) is projected onto span(V), where V is an orthonormal basis built internally by the solver. The projected operator is equal to sum_i V'*A_i*V*f_i(lambda), so this function computes all matrices Ei = V'*A_i*V, and stores them in the extra matrices inside DS. Only rows/columns in the range [j0,j1-1] are computed, the previous ones are assumed to be available already. Level: developer .seealso: NEPSetSplitOperator() @*/ PetscErrorCode NEPProjectOperator(NEP nep,PetscInt j0,PetscInt j1) { PetscErrorCode ierr; PetscInt k; Mat G; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,j0,2); PetscValidLogicalCollectiveInt(nep,j1,3); NEPCheckProblem(nep,1); NEPCheckSplit(nep,1); ierr = BVSetActiveColumns(nep->V,j0,j1);CHKERRQ(ierr); for (k=0;knt;k++) { ierr = DSGetMat(nep->ds,DSMatExtra[k],&G);CHKERRQ(ierr); ierr = BVMatProject(nep->V,nep->A[k],nep->V,G);CHKERRQ(ierr); ierr = DSRestoreMat(nep->ds,DSMatExtra[k],&G);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPApplyFunction" /*@ NEPApplyFunction - Applies the nonlinear function T(lambda) to a given vector. Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . lambda - scalar argument . x - vector to be multiplied against - v - workspace vector (used only in the case of split form) Output Parameters: + y - result vector . A - Function matrix - B - optional preconditioning matrix Note: If the nonlinear operator is represented in split form, the result y = T(lambda)*x is computed without building T(lambda) explicitly. In that case, parameters A and B are not used. Otherwise, the matrix T(lambda) is built and the effect is the same as a call to NEPComputeFunction() followed by a MatMult(). Level: developer .seealso: NEPSetSplitOperator(), NEPComputeFunction() @*/ PetscErrorCode NEPApplyFunction(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A,Mat B) { PetscErrorCode ierr; PetscInt i; PetscScalar alpha; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveScalar(nep,lambda,2); PetscValidHeaderSpecific(x,VEC_CLASSID,3); if (v) PetscValidHeaderSpecific(v,VEC_CLASSID,4); PetscValidHeaderSpecific(y,VEC_CLASSID,5); if (A) PetscValidHeaderSpecific(A,MAT_CLASSID,6); if (B) PetscValidHeaderSpecific(B,MAT_CLASSID,7); if (nep->fui==NEP_USER_INTERFACE_SPLIT) { ierr = VecSet(y,0.0);CHKERRQ(ierr); for (i=0;int;i++) { ierr = FNEvaluateFunction(nep->f[i],lambda,&alpha);CHKERRQ(ierr); ierr = MatMult(nep->A[i],x,v);CHKERRQ(ierr); ierr = VecAXPY(y,alpha,v);CHKERRQ(ierr); } } else { ierr = NEPComputeFunction(nep,lambda,A,B);CHKERRQ(ierr); ierr = MatMult(A,x,y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPApplyJacobian" /*@ NEPApplyJacobian - Applies the nonlinear Jacobian T'(lambda) to a given vector. Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . lambda - scalar argument . x - vector to be multiplied against - v - workspace vector (used only in the case of split form) Output Parameters: + y - result vector - A - Jacobian matrix Note: If the nonlinear operator is represented in split form, the result y = T'(lambda)*x is computed without building T'(lambda) explicitly. In that case, parameter A is not used. Otherwise, the matrix T'(lambda) is built and the effect is the same as a call to NEPComputeJacobian() followed by a MatMult(). Level: developer .seealso: NEPSetSplitOperator(), NEPComputeJacobian() @*/ PetscErrorCode NEPApplyJacobian(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A) { PetscErrorCode ierr; PetscInt i; PetscScalar alpha; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveScalar(nep,lambda,2); PetscValidHeaderSpecific(x,VEC_CLASSID,3); if (v) PetscValidHeaderSpecific(v,VEC_CLASSID,4); PetscValidHeaderSpecific(y,VEC_CLASSID,5); if (A) PetscValidHeaderSpecific(A,MAT_CLASSID,6); if (nep->fui==NEP_USER_INTERFACE_SPLIT) { ierr = VecSet(y,0.0);CHKERRQ(ierr); for (i=0;int;i++) { ierr = FNEvaluateDerivative(nep->f[i],lambda,&alpha);CHKERRQ(ierr); ierr = MatMult(nep->A[i],x,v);CHKERRQ(ierr); ierr = VecAXPY(y,alpha,v);CHKERRQ(ierr); } } else { ierr = NEPComputeJacobian(nep,lambda,A);CHKERRQ(ierr); ierr = MatMult(A,x,y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetIterationNumber" /*@ NEPGetIterationNumber - Gets the current iteration number. If the call to NEPSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If NEPSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call NEPGetConvergedReason() to determine if the solver converged or failed and why. .seealso: NEPGetConvergedReason(), NEPSetTolerances() @*/ PetscErrorCode NEPGetIterationNumber(NEP nep,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidIntPointer(its,2); *its = nep->its; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetConverged" /*@ NEPGetConverged - Gets the number of converged eigenpairs. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: . nconv - number of converged eigenpairs Note: This function should be called after NEPSolve() has finished. Level: beginner .seealso: NEPSetDimensions(), NEPSolve() @*/ PetscErrorCode NEPGetConverged(NEP nep,PetscInt *nconv) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidIntPointer(nconv,2); NEPCheckSolved(nep,1); *nconv = nep->nconv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetConvergedReason" /*@ NEPGetConvergedReason - Gets the reason why the NEPSolve() iteration was stopped. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: . reason - negative value indicates diverged, positive value converged Notes: Possible values for reason are + NEP_CONVERGED_TOL - converged up to tolerance . NEP_CONVERGED_USER - converged due to a user-defined condition . NEP_DIVERGED_ITS - required more than max_it iterations to reach convergence . NEP_DIVERGED_BREAKDOWN - generic breakdown in method - NEP_DIVERGED_LINEAR_SOLVE - inner linear solve failed Can only be called after the call to NEPSolve() is complete. Level: intermediate .seealso: NEPSetTolerances(), NEPSolve(), NEPConvergedReason @*/ PetscErrorCode NEPGetConvergedReason(NEP nep,NEPConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(reason,2); NEPCheckSolved(nep,1); *reason = nep->reason; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetEigenpair" /*@ NEPGetEigenpair - Gets the i-th solution of the eigenproblem as computed by NEPSolve(). The solution consists in both the eigenvalue and the eigenvector. Logically Collective on NEP Input Parameters: + nep - nonlinear eigensolver context - i - index of the solution Output Parameters: + eigr - real part of eigenvalue . eigi - imaginary part of eigenvalue . Vr - real part of eigenvector - Vi - imaginary part of eigenvector Notes: It is allowed to pass NULL for Vr and Vi, if the eigenvector is not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs(). If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is set to zero). In both cases, the user can pass NULL in eigi and Vi. The index i should be a value between 0 and nconv-1 (see NEPGetConverged()). Eigenpairs are indexed according to the ordering criterion established with NEPSetWhichEigenpairs(). Level: beginner .seealso: NEPSolve(), NEPGetConverged(), NEPSetWhichEigenpairs() @*/ PetscErrorCode NEPGetEigenpair(NEP nep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi) { PetscInt k; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,i,2); if (Vr) { PetscValidHeaderSpecific(Vr,VEC_CLASSID,5); PetscCheckSameComm(nep,1,Vr,5); } if (Vi) { PetscValidHeaderSpecific(Vi,VEC_CLASSID,6); PetscCheckSameComm(nep,1,Vi,6); } NEPCheckSolved(nep,1); if (i<0 || i>=nep->nconv) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); ierr = NEPComputeVectors(nep);CHKERRQ(ierr); k = nep->perm[i]; /* eigenvalue */ #if defined(PETSC_USE_COMPLEX) if (eigr) *eigr = nep->eigr[k]; if (eigi) *eigi = 0; #else if (eigr) *eigr = nep->eigr[k]; if (eigi) *eigi = nep->eigi[k]; #endif /* eigenvector */ #if defined(PETSC_USE_COMPLEX) if (Vr) { ierr = BVCopyVec(nep->V,k,Vr);CHKERRQ(ierr); } if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } #else if (nep->eigi[k]>0) { /* first value of conjugate pair */ if (Vr) { ierr = BVCopyVec(nep->V,k,Vr);CHKERRQ(ierr); } if (Vi) { ierr = BVCopyVec(nep->V,k+1,Vi);CHKERRQ(ierr); } } else if (nep->eigi[k]<0) { /* second value of conjugate pair */ if (Vr) { ierr = BVCopyVec(nep->V,k-1,Vr);CHKERRQ(ierr); } if (Vi) { ierr = BVCopyVec(nep->V,k,Vi);CHKERRQ(ierr); ierr = VecScale(Vi,-1.0);CHKERRQ(ierr); } } else { /* real eigenvalue */ if (Vr) { ierr = BVCopyVec(nep->V,k,Vr);CHKERRQ(ierr); } if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetErrorEstimate" /*@ NEPGetErrorEstimate - Returns the error estimate associated to the i-th computed eigenpair. Not Collective Input Parameter: + nep - nonlinear eigensolver context - i - index of eigenpair Output Parameter: . errest - the error estimate Notes: This is the error estimate used internally by the eigensolver. The actual error bound can be computed with NEPComputeRelativeError(). Level: advanced .seealso: NEPComputeRelativeError() @*/ PetscErrorCode NEPGetErrorEstimate(NEP nep,PetscInt i,PetscReal *errest) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(errest,3); NEPCheckSolved(nep,1); if (i<0 || i>=nep->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); if (errest) *errest = nep->errest[nep->perm[i]]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPComputeResidualNorm_Private" /* NEPComputeResidualNorm_Private - Computes the norm of the residual vector associated with an eigenpair. Input Parameters: lambda - eigenvalue x - eigenvector w - array of work vectors (two vectors in split form, one vector otherwise) */ PetscErrorCode NEPComputeResidualNorm_Private(NEP nep,PetscScalar lambda,Vec x,Vec *w,PetscReal *norm) { PetscErrorCode ierr; Vec y,z=NULL; PetscFunctionBegin; y = w[0]; if (nep->fui==NEP_USER_INTERFACE_SPLIT) z = w[1]; ierr = NEPApplyFunction(nep,lambda,x,z,y,nep->function,nep->function_pre);CHKERRQ(ierr); ierr = VecNorm(y,NORM_2,norm);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPComputeError" /*@ NEPComputeError - Computes the error (based on the residual norm) associated with the i-th computed eigenpair. Collective on NEP Input Parameter: + nep - the nonlinear eigensolver context . i - the solution index - type - the type of error to compute Output Parameter: . error - the error Notes: The error can be computed in various ways, all of them based on the residual norm computed as ||T(lambda)x||_2 where lambda is the eigenvalue and x is the eigenvector. Level: beginner .seealso: NEPErrorType, NEPSolve(), NEPGetErrorEstimate() @*/ PetscErrorCode NEPComputeError(NEP nep,PetscInt i,NEPErrorType type,PetscReal *error) { PetscErrorCode ierr; Vec xr,xi=NULL; PetscInt j,nwork,issplit=0; PetscScalar kr,ki,s; PetscReal er,z=0.0; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,i,2); PetscValidLogicalCollectiveEnum(nep,type,3); PetscValidPointer(error,4); NEPCheckSolved(nep,1); /* allocate work vectors */ #if defined(PETSC_USE_COMPLEX) nwork = 2; #else nwork = 3; #endif if (nep->fui==NEP_USER_INTERFACE_SPLIT) { issplit = 1; nwork++; /* need an extra work vector for NEPComputeResidualNorm_Private */ } ierr = NEPSetWorkVecs(nep,nwork);CHKERRQ(ierr); xr = nep->work[issplit+1]; #if !defined(PETSC_USE_COMPLEX) xi = nep->work[issplit+2]; #endif /* compute residual norms */ ierr = NEPGetEigenpair(nep,i,&kr,&ki,xr,xi);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) if (ki) SETERRQ(PETSC_COMM_SELF,1,"Not implemented for complex eigenvalues with real scalars"); #endif ierr = NEPComputeResidualNorm_Private(nep,kr,xr,nep->work,error);CHKERRQ(ierr); ierr = VecNorm(xr,NORM_2,&er);CHKERRQ(ierr); /* compute error */ switch (type) { case NEP_ERROR_ABSOLUTE: break; case NEP_ERROR_RELATIVE: *error /= PetscAbsScalar(kr)*er; break; case NEP_ERROR_BACKWARD: if (nep->fui!=NEP_USER_INTERFACE_SPLIT) { *error = 0.0; ierr = PetscInfo(nep,"Backward error only available in split form\n");CHKERRQ(ierr); break; } /* initialization of matrix norms */ if (!nep->nrma[0]) { for (j=0;jnt;j++) { ierr = MatHasOperation(nep->A[j],MATOP_NORM,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation"); ierr = MatNorm(nep->A[j],NORM_INFINITY,&nep->nrma[j]);CHKERRQ(ierr); } } for (j=0;jnt;j++) { ierr = FNEvaluateFunction(nep->f[j],kr,&s);CHKERRQ(ierr); z = z + nep->nrma[j]*PetscAbsScalar(s); } *error /= z; break; default: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPComputeFunction" /*@ NEPComputeFunction - Computes the function matrix T(lambda) that has been set with NEPSetFunction(). Collective on NEP and Mat Input Parameters: + nep - the NEP context - lambda - the scalar argument Output Parameters: + A - Function matrix - B - optional preconditioning matrix Notes: NEPComputeFunction() is typically used within nonlinear eigensolvers implementations, so most users would not generally call this routine themselves. Level: developer .seealso: NEPSetFunction(), NEPGetFunction() @*/ PetscErrorCode NEPComputeFunction(NEP nep,PetscScalar lambda,Mat A,Mat B) { PetscErrorCode ierr; PetscInt i; PetscScalar alpha; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckProblem(nep,1); switch (nep->fui) { case NEP_USER_INTERFACE_CALLBACK: if (!nep->computefunction) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_USER,"Must call NEPSetFunction() first"); ierr = PetscLogEventBegin(NEP_FunctionEval,nep,A,B,0);CHKERRQ(ierr); PetscStackPush("NEP user Function function"); ierr = (*nep->computefunction)(nep,lambda,A,B,nep->functionctx);CHKERRQ(ierr); PetscStackPop; ierr = PetscLogEventEnd(NEP_FunctionEval,nep,A,B,0);CHKERRQ(ierr); break; case NEP_USER_INTERFACE_SPLIT: ierr = MatZeroEntries(A);CHKERRQ(ierr); for (i=0;int;i++) { ierr = FNEvaluateFunction(nep->f[i],lambda,&alpha);CHKERRQ(ierr); ierr = MatAXPY(A,alpha,nep->A[i],nep->mstr);CHKERRQ(ierr); } if (A != B) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Not implemented"); break; case NEP_USER_INTERFACE_DERIVATIVES: ierr = PetscLogEventBegin(NEP_DerivativesEval,nep,A,B,0);CHKERRQ(ierr); PetscStackPush("NEP user Derivatives function"); ierr = (*nep->computederivatives)(nep,lambda,0,A,nep->derivativesctx);CHKERRQ(ierr); PetscStackPop; ierr = PetscLogEventEnd(NEP_DerivativesEval,nep,A,B,0);CHKERRQ(ierr); break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPComputeJacobian" /*@ NEPComputeJacobian - Computes the Jacobian matrix T'(lambda) that has been set with NEPSetJacobian(). Collective on NEP and Mat Input Parameters: + nep - the NEP context - lambda - the scalar argument Output Parameters: . A - Jacobian matrix Notes: Most users should not need to explicitly call this routine, as it is used internally within the nonlinear eigensolvers. Level: developer .seealso: NEPSetJacobian(), NEPGetJacobian() @*/ PetscErrorCode NEPComputeJacobian(NEP nep,PetscScalar lambda,Mat A) { PetscErrorCode ierr; PetscInt i; PetscScalar alpha; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckProblem(nep,1); switch (nep->fui) { case NEP_USER_INTERFACE_CALLBACK: if (!nep->computejacobian) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_USER,"Must call NEPSetJacobian() first"); ierr = PetscLogEventBegin(NEP_JacobianEval,nep,A,0,0);CHKERRQ(ierr); PetscStackPush("NEP user Jacobian function"); ierr = (*nep->computejacobian)(nep,lambda,A,nep->jacobianctx);CHKERRQ(ierr); PetscStackPop; ierr = PetscLogEventEnd(NEP_JacobianEval,nep,A,0,0);CHKERRQ(ierr); break; case NEP_USER_INTERFACE_SPLIT: ierr = MatZeroEntries(A);CHKERRQ(ierr); for (i=0;int;i++) { ierr = FNEvaluateDerivative(nep->f[i],lambda,&alpha);CHKERRQ(ierr); ierr = MatAXPY(A,alpha,nep->A[i],nep->mstr);CHKERRQ(ierr); } break; case NEP_USER_INTERFACE_DERIVATIVES: ierr = PetscLogEventBegin(NEP_DerivativesEval,nep,A,0,0);CHKERRQ(ierr); PetscStackPush("NEP user Derivatives function"); ierr = (*nep->computederivatives)(nep,lambda,1,A,nep->derivativesctx);CHKERRQ(ierr); PetscStackPop; ierr = PetscLogEventEnd(NEP_DerivativesEval,nep,A,0,0);CHKERRQ(ierr); break; } PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/makefile.html0000644000175000017500000000501513107004621020140 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = nepmon.c nepbasic.c nepview.c nepdefault.c nepregis.c nepopts.c nepsetup.c nepsolve.c neprefine.c dlregisnep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcnep
DIRS     =
MANSEC   = NEP
LOCDIR   = src/nep/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/interface/dlregisnep.c0000644000175000017500000001104213107004621017772 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include static PetscBool NEPPackageInitialized = PETSC_FALSE; const char *NEPErrorTypes[] = {"ABSOLUTE","RELATIVE","NEPErrorType","NEP_ERROR_",0}; const char *NEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","NEPRefine","NEP_REFINE_",0}; const char *NEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","NEPRefineScheme","NEP_REFINE_SCHEME_",0}; const char *const NEPConvergedReasons_Shifted[] = {"DIVERGED_LINEAR_SOLVE","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","NEPConvergedReason","NEP_",0}; const char *const*NEPConvergedReasons = NEPConvergedReasons_Shifted + 4; #undef __FUNCT__ #define __FUNCT__ "NEPFinalizePackage" /*@C NEPFinalizePackage - This function destroys everything in the Slepc interface to the NEP package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode NEPFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&NEPList);CHKERRQ(ierr); NEPPackageInitialized = PETSC_FALSE; NEPRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInitializePackage" /*@C NEPInitializePackage - This function initializes everything in the NEP package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to NEPCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode NEPInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (NEPPackageInitialized) PetscFunctionReturn(0); NEPPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("NEP Solver",&NEP_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = NEPRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("NEPSetUp",NEP_CLASSID,&NEP_SetUp);CHKERRQ(ierr); ierr = PetscLogEventRegister("NEPSolve",NEP_CLASSID,&NEP_Solve);CHKERRQ(ierr); ierr = PetscLogEventRegister("NEPRefine",NEP_CLASSID,&NEP_Refine);CHKERRQ(ierr); ierr = PetscLogEventRegister("NEPFunctionEval",NEP_CLASSID,&NEP_FunctionEval);CHKERRQ(ierr); ierr = PetscLogEventRegister("NEPJacobianEval",NEP_CLASSID,&NEP_JacobianEval);CHKERRQ(ierr); ierr = PetscLogEventRegister("NEPDerivativesEval",NEP_CLASSID,&NEP_DerivativesEval);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"nep",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(NEP_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"nep",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(NEP_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(NEPFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) #undef __FUNCT__ #define __FUNCT__ "PetscDLLibraryRegister_slepcnep" /* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the NEP methods that are in the basic SLEPc libslepcnep library. */ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcnep() { PetscErrorCode ierr; PetscFunctionBegin; ierr = NEPInitializePackage();CHKERRQ(ierr); PetscFunctionReturn(0); } #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ slepc-3.7.4/src/nep/interface/neprefine.c.html0000644000175000017500000012500213107004621020556 0ustar jromanjroman
Actual source code: neprefine.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Newton refinement for NEP, simple version.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/nepimpl.h>
 25: #include <slepcblaslapack.h>

 27: #define NREF_MAXIT 10

 29: typedef struct {
 30:   PetscSubcomm  subc;
 31:   VecScatter    *scatter_id,nst;
 32:   Mat           *A;
 33:   Vec           nv,vg,v,w;
 34:   FN            *fn;
 35: } NEPSimpNRefctx;

 37: typedef struct {
 38:   Mat          M1;
 39:   Vec          M2,M3;
 40:   PetscScalar  M4,m3;
 41: } FSubctx;

 45: static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)
 46: {
 48:   FSubctx        *ctx;
 49:   PetscScalar    t;
 50:   
 52:   MatShellGetContext(M,&ctx);
 53:   VecDot(x,ctx->M3,&t);
 54:   t *= ctx->m3/ctx->M4;
 55:   MatMult(ctx->M1,x,y);
 56:   VecAXPY(y,-t,ctx->M2);
 57:   return(0);
 58: }

 62: static PetscErrorCode NEPSimpleNRefSetUp(NEP nep,NEPSimpNRefctx **ctx_)
 63: {
 65:   PetscInt       i,si,j,n0,m0,nloc,*idx1,*idx2,ne;
 66:   IS             is1,is2;
 67:   NEPSimpNRefctx *ctx;
 68:   Vec            v;
 69:   PetscMPIInt    rank,size;

 72:   PetscCalloc1(1,ctx_);
 73:   ctx = *ctx_;
 74:   if (nep->npart==1) {
 75:     ctx->A  = nep->A;
 76:     ctx->fn = nep->f;
 77:   } else {
 78:     PetscMalloc2(nep->nt,&ctx->A,nep->npart,&ctx->scatter_id);

 80:     /* Duplicate matrices */
 81:     for (i=0;i<nep->nt;i++) {
 82:       MatCreateRedundantMatrix(nep->A[i],0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&ctx->A[i]);
 83:     }
 84:     MatCreateVecs(ctx->A[0],&ctx->v,NULL);

 86:     /* Duplicate FNs */
 87:     PetscMalloc1(nep->nt,&ctx->fn);
 88:     for (i=0;i<nep->nt;i++) {
 89:       FNDuplicate(nep->f[i],PetscSubcommChild(ctx->subc),&ctx->fn[i]);
 90:     }

 92:     /* Create scatters for sending vectors to each subcommucator */
 93:     BVGetColumn(nep->V,0,&v);
 94:     VecGetOwnershipRange(v,&n0,&m0);
 95:     BVRestoreColumn(nep->V,0,&v);
 96:     VecGetLocalSize(ctx->v,&nloc);
 97:     PetscMalloc2(m0-n0,&idx1,m0-n0,&idx2);
 98:     VecCreateMPI(PetscObjectComm((PetscObject)nep),nloc,PETSC_DECIDE,&ctx->vg);
 99:     for (si=0;si<nep->npart;si++) {
100:       j = 0;
101:       for (i=n0;i<m0;i++) {
102:         idx1[j]   = i;
103:         idx2[j++] = i+nep->n*si;
104:       }
105:       ISCreateGeneral(PetscObjectComm((PetscObject)nep),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);
106:       ISCreateGeneral(PetscObjectComm((PetscObject)nep),(m0-n0),idx2,PETSC_COPY_VALUES,&is2);
107:       BVGetColumn(nep->V,0,&v);
108:       VecScatterCreate(v,is1,ctx->vg,is2,&ctx->scatter_id[si]);
109:       BVRestoreColumn(nep->V,0,&v);
110:       ISDestroy(&is1);
111:       ISDestroy(&is2);
112:     }
113:     PetscFree2(idx1,idx2);
114:   }
115:   if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT) {
116:     MPI_Comm_rank(PetscObjectComm((PetscObject)ctx->A[0]),&rank);
117:     MPI_Comm_size(PetscObjectComm((PetscObject)ctx->A[0]),&size);
118:     if (size>1) {
119:       if (nep->npart==1) {
120:         BVGetColumn(nep->V,0,&v);
121:       } else v = ctx->v;
122:       VecGetOwnershipRange(v,&n0,&m0);
123:       ne = (rank == size-1)?nep->n:0;
124:       VecCreateMPI(PetscObjectComm((PetscObject)ctx->A[0]),ne,PETSC_DECIDE,&ctx->nv);
125:       PetscMalloc1(m0-n0,&idx1);
126:       for (i=n0;i<m0;i++) {
127:         idx1[i-n0] = i;
128:       }
129:       ISCreateGeneral(PetscObjectComm((PetscObject)nep),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);
130:       VecScatterCreate(v,is1,ctx->nv,is1,&ctx->nst);
131:       if (nep->npart==1) {
132:         BVRestoreColumn(nep->V,0,&v);
133:       }
134:       PetscFree(idx1);
135:       ISDestroy(&is1);
136:     }
137:   }  return(0);  
138: }

140: /*
141:   Gather Eigenpair idx from subcommunicator with color sc
142: */
145: static PetscErrorCode NEPSimpleNRefGatherEigenpair(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail)
146: {
148:   PetscMPIInt    nproc,p;
149:   MPI_Comm       comm=((PetscObject)nep)->comm;
150:   Vec            v;
151:   PetscScalar    *array;

154:   if (nep->npart>1) {
155:     MPI_Comm_size(comm,&nproc);
156:     p = (nproc/nep->npart)*sc+PetscMin(sc,nproc%nep->npart);
157:     /* Communicate convergence successful */
158:     MPI_Bcast(fail,1,MPIU_INT,p,comm);
159:     if (!(*fail)) {
160:       /* Process 0 of subcommunicator sc broadcasts the eigenvalue */ 
161:       MPI_Bcast(&nep->eigr[idx],1,MPIU_SCALAR,p,comm);
162:       /* Gather nep->V[idx] from the subcommuniator sc */
163:       BVGetColumn(nep->V,idx,&v);
164:       if (ctx->subc->color==sc) {
165:         VecGetArray(ctx->v,&array);
166:         VecPlaceArray(ctx->vg,array);
167:       }
168:       VecScatterBegin(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);
169:       VecScatterEnd(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);
170:       if (ctx->subc->color==sc) {
171:         VecResetArray(ctx->vg);
172:         VecRestoreArray(ctx->v,&array);
173:       }
174:       BVRestoreColumn(nep->V,idx,&v);
175:     }
176:   } else {
177:     if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT && !(*fail)) {
178:       MPI_Comm_size(comm,&nproc);
179:       p = (nproc/nep->npart)*sc+PetscMin(sc,nproc%nep->npart);
180:       MPI_Bcast(&nep->eigr[idx],1,MPIU_SCALAR,p,comm);
181:     }
182:   }
183:   return(0);
184: }

188: static PetscErrorCode NEPSimpleNRefScatterEigenvector(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx)
189: {
191:   Vec            v;
192:   PetscScalar    *array;
193:   
195:   if (nep->npart>1) {
196:     BVGetColumn(nep->V,idx,&v);
197:     if (ctx->subc->color==sc) {
198:       VecGetArray(ctx->v,&array);
199:       VecPlaceArray(ctx->vg,array);
200:     }
201:     VecScatterBegin(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);
202:     VecScatterEnd(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);
203:     if (ctx->subc->color==sc) {
204:       VecResetArray(ctx->vg);
205:       VecRestoreArray(ctx->v,&array);
206:     }
207:     BVRestoreColumn(nep->V,idx,&v);
208:   }
209:   return(0);
210: }

214: static PetscErrorCode NEPSimpleNRefSetUpSystem(NEP nep,NEPSimpNRefctx *ctx,Mat *A,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v)
215: {
216:   PetscErrorCode    ierr;
217:   PetscInt          i,st,ml,m0,n0,m1,mg;
218:   PetscInt          *dnz,*onz,ncols,*cols2,*nnz,nt=nep->nt;
219:   PetscScalar       zero=0.0,*coeffs,*coeffs2;
220:   PetscMPIInt       rank,size;
221:   MPI_Comm          comm;
222:   const PetscInt    *cols;
223:   const PetscScalar *vals,*array;
224:   FSubctx           *fctx;
225:   Vec               w=ctx->w;
226:   Mat               M;

229:   PetscMalloc2(nt,&coeffs,nt,&coeffs2);
230:   switch (nep->scheme) {
231:   case NEP_REFINE_SCHEME_SCHUR:
232:     if (ini) {
233:       PetscCalloc1(1,&fctx);
234:       MatGetSize(A[0],&m0,&n0);
235:       MatCreateShell(PetscObjectComm((PetscObject)A[0]),PETSC_DECIDE,PETSC_DECIDE,m0,n0,fctx,T);
236:       MatShellSetOperation(*T,MATOP_MULT,(void(*)(void))MatFSMult);
237:     } else {
238:       MatShellGetContext(*T,&fctx);
239:     }    
240:     M=fctx->M1;
241:     break;
242:   case NEP_REFINE_SCHEME_MBE:
243:     M=*T;
244:     break;
245:   case NEP_REFINE_SCHEME_EXPLICIT:
246:     M=*Mt;
247:     break;
248:   }
249:   if (ini) {
250:     MatDuplicate(A[0],MAT_COPY_VALUES,&M);
251:   } else {
252:     MatCopy(A[0],M,DIFFERENT_NONZERO_PATTERN);
253:   }
254:   for (i=0;i<nt;i++) {
255:     FNEvaluateFunction(ctx->fn[i],nep->eigr[idx],coeffs+i);
256:   }
257:   if (coeffs[0]!=1.0) {
258:     MatScale(M,coeffs[0]);
259:   }
260:   for (i=1;i<nt;i++) {
261:     MatAXPY(M,coeffs[i],A[i],(ini)?nep->mstr:SUBSET_NONZERO_PATTERN);
262:   }
263:   for (i=0;i<nt;i++) {
264:     FNEvaluateDerivative(ctx->fn[i],nep->eigr[idx],coeffs2+i);
265:   }
266:   st = 0;
267:   for (i=0;i<nt && PetscAbsScalar(coeffs2[i])==0.0;i++) st++;
268:   MatMult(A[st],v,w);
269:   if (coeffs2[st]!=1.0) {
270:     VecScale(w,coeffs2[st]);
271:   }
272:   for (i=st+1;i<nt;i++) {
273:     MatMult(A[i],v,t);
274:     VecAXPY(w,coeffs2[i],t);
275:   }

277:   switch (nep->scheme) {
278:   case NEP_REFINE_SCHEME_EXPLICIT:
279:     comm = PetscObjectComm((PetscObject)A[0]);
280:     MPI_Comm_rank(comm,&rank);
281:     MPI_Comm_size(comm,&size);
282:     MatGetSize(M,&mg,NULL);
283:     MatGetOwnershipRange(M,&m0,&m1);
284:     if (ini) {
285:       MatCreate(comm,T);
286:       MatGetLocalSize(M,&ml,NULL);
287:       if (rank==size-1) ml++;
288:       MatSetSizes(*T,ml,ml,mg+1,mg+1);
289:       MatSetFromOptions(*T);
290:       MatSetUp(*T);
291:       /* Preallocate M */
292:       if (size>1) {
293:         MatPreallocateInitialize(comm,ml,ml,dnz,onz);
294:         for (i=m0;i<m1;i++) {
295:           MatGetRow(M,i,&ncols,&cols,NULL);
296:           MatPreallocateSet(i,ncols,cols,dnz,onz);
297:           MatPreallocateSet(i,1,&mg,dnz,onz);
298:           MatRestoreRow(M,i,&ncols,&cols,NULL);
299:         }
300:         if (rank==size-1) {
301:           PetscCalloc1(mg+1,&cols2);
302:           for (i=0;i<mg+1;i++) cols2[i]=i;
303:           MatPreallocateSet(m1,mg+1,cols2,dnz,onz);
304:           PetscFree(cols2);
305:         }
306:         MatMPIAIJSetPreallocation(*T,0,dnz,0,onz);
307:         MatPreallocateFinalize(dnz,onz);
308:       } else {
309:         PetscCalloc1(mg+1,&nnz);
310:         for (i=0;i<mg;i++) {
311:           MatGetRow(M,i,&ncols,NULL,NULL);
312:           nnz[i] = ncols+1;
313:           MatRestoreRow(M,i,&ncols,NULL,NULL);
314:         }
315:         nnz[mg] = mg+1;
316:         MatSeqAIJSetPreallocation(*T,0,nnz);
317:         PetscFree(nnz);
318:       }
319:       *Mt = M;
320:       *P  = *T;
321:     }
322:   
323:     /* Set values */
324:     VecGetArrayRead(w,&array);
325:     for (i=m0;i<m1;i++) {
326:       MatGetRow(M,i,&ncols,&cols,&vals);
327:       MatSetValues(*T,1,&i,ncols,cols,vals,INSERT_VALUES);
328:       MatRestoreRow(M,i,&ncols,&cols,&vals);
329:       MatSetValues(*T,1,&i,1,&mg,array+i-m0,INSERT_VALUES);
330:     }
331:     VecRestoreArrayRead(w,&array);
332:     VecConjugate(v);
333:     MPI_Comm_size(PetscObjectComm((PetscObject)A[0]),&size);
334:     MPI_Comm_rank(PetscObjectComm((PetscObject)A[0]),&rank);
335:     if (size>1) {
336:       if (rank==size-1) {
337:         PetscMalloc1(nep->n,&cols2);
338:         for (i=0;i<nep->n;i++) cols2[i]=i;
339:       }
340:       VecScatterBegin(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);
341:       VecScatterEnd(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);
342:       VecGetArrayRead(ctx->nv,&array);
343:       if (rank==size-1) {
344:         MatSetValues(*T,1,&mg,nep->n,cols2,array,INSERT_VALUES);
345:         MatSetValues(*T,1,&mg,1,&mg,&zero,INSERT_VALUES);
346:       }
347:       VecRestoreArrayRead(ctx->nv,&array);
348:     } else {  
349:       PetscMalloc1(m1-m0,&cols2);
350:       for (i=0;i<m1-m0;i++) cols2[i]=m0+i;
351:       VecGetArrayRead(v,&array);
352:       MatSetValues(*T,1,&mg,m1-m0,cols2,array,INSERT_VALUES);
353:       MatSetValues(*T,1,&mg,1,&mg,&zero,INSERT_VALUES);
354:       VecRestoreArrayRead(v,&array);
355:     }
356:     VecConjugate(v);
357:     MatAssemblyBegin(*T,MAT_FINAL_ASSEMBLY);
358:     MatAssemblyEnd(*T,MAT_FINAL_ASSEMBLY);  
359:     PetscFree(cols2);
360:     break; 
361:   case NEP_REFINE_SCHEME_SCHUR:
362:     fctx->M2 = ctx->w;
363:     fctx->M3 = v;
364:     fctx->m3 = 0.0;
365:     for (i=1;i<nt-1;i++) fctx->m3 += PetscConj(coeffs[i])*coeffs[i];
366:     fctx->M4 = 0.0;
367:     for (i=1;i<nt-1;i++) fctx->M4 += PetscConj(coeffs[i])*coeffs2[i];
368:     fctx->M1 = M;
369:     if (ini) {
370:       MatDuplicate(M,MAT_COPY_VALUES,P);
371:     } else {
372:       MatCopy(M,*P,SAME_NONZERO_PATTERN);
373:     }
374:     VecConjugate(v);
375:     VecPointwiseMult(t,v,w);
376:     VecConjugate(v);
377:     VecScale(t,-fctx->m3/fctx->M4);
378:     MatDiagonalSet(*P,t,ADD_VALUES);
379:     break;
380:   case NEP_REFINE_SCHEME_MBE:
381:     *T = M;
382:     *P = M;
383:     break;
384:   }
385:   PetscFree2(coeffs,coeffs2);
386:   return(0);
387: }

391: PetscErrorCode NEPNewtonRefinementSimple(NEP nep,PetscInt *maxits,PetscReal tol,PetscInt k)
392: {
393:   PetscErrorCode    ierr;
394:   PetscInt          i,n,its,idx=0,*idx_sc,*its_sc,color,*fail_sc;
395:   PetscMPIInt       rank,size;
396:   Mat               Mt=NULL,T=NULL,P=NULL;
397:   MPI_Comm          comm;
398:   Vec               r,v,dv,rr=NULL,dvv=NULL,t[2];
399:   const PetscScalar *array;
400:   PetscScalar       *array2,deig=0.0,tt[2],ttt;
401:   PetscReal         norm,error;
402:   PetscBool         ini=PETSC_TRUE,sc_pend,solved=PETSC_FALSE;
403:   NEPSimpNRefctx    *ctx;
404:   FSubctx            *fctx=NULL;
405:   KSPConvergedReason reason;

408:   PetscLogEventBegin(NEP_Refine,nep,0,0,0);
409:   NEPSimpleNRefSetUp(nep,&ctx);
410:   its = (maxits)?*maxits:NREF_MAXIT;
411:   comm = (nep->npart==1)?PetscObjectComm((PetscObject)nep):PetscSubcommChild(ctx->subc);
412:   if (!nep->refineksp) { NEPRefineGetKSP(nep,&nep->refineksp); }
413:   if (nep->npart==1) {
414:     BVGetColumn(nep->V,0,&v);
415:   } else v = ctx->v;
416:   VecDuplicate(v,&ctx->w);
417:   VecDuplicate(v,&r);
418:   VecDuplicate(v,&dv);
419:   VecDuplicate(v,&t[0]);
420:   VecDuplicate(v,&t[1]);
421:   if (nep->npart==1) { BVRestoreColumn(nep->V,0,&v); }
422:   MPI_Comm_size(comm,&size);
423:   MPI_Comm_rank(comm,&rank);
424:   VecGetLocalSize(r,&n);
425:   PetscMalloc3(nep->npart,&idx_sc,nep->npart,&its_sc,nep->npart,&fail_sc);
426:   for (i=0;i<nep->npart;i++) fail_sc[i] = 0;
427:   for (i=0;i<nep->npart;i++) its_sc[i] = 0;
428:   color = (nep->npart==1)?0:ctx->subc->color;
429:    
430:   /* Loop performing iterative refinements */
431:   while (!solved) {
432:     for (i=0;i<nep->npart;i++) {
433:       sc_pend = PETSC_TRUE;
434:       if (its_sc[i]==0) {
435:         idx_sc[i] = idx++;
436:         if (idx_sc[i]>=k) {
437:           sc_pend = PETSC_FALSE;
438:         } else {
439:           NEPSimpleNRefScatterEigenvector(nep,ctx,i,idx_sc[i]);
440:         }
441:       }  else { /* Gather Eigenpair from subcommunicator i */
442:         NEPSimpleNRefGatherEigenpair(nep,ctx,i,idx_sc[i],&fail_sc[i]);
443:       }
444:       while (sc_pend) {
445:         if (!fail_sc[i]) {
446:           NEPComputeError(nep,idx_sc[i],NEP_ERROR_RELATIVE,&error);
447:         }
448:         if (error<=tol || its_sc[i]>=its || fail_sc[i]) {
449:           idx_sc[i] = idx++;
450:           its_sc[i] = 0;
451:           if (idx_sc[i]<k) { NEPSimpleNRefScatterEigenvector(nep,ctx,i,idx_sc[i]); }
452:         } else {
453:           sc_pend = PETSC_FALSE;
454:           its_sc[i]++;
455:         }
456:         if (idx_sc[i]>=k) sc_pend = PETSC_FALSE;
457:       }
458:     }
459:     solved = PETSC_TRUE;
460:     for (i=0;i<nep->npart&&solved;i++) solved = PetscNot(idx_sc[i]<k);
461:     if (idx_sc[color]<k) {
462: #if !defined(PETSC_USE_COMPLEX)
463:       if (nep->eigi[idx_sc[color]]!=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Simple Refinement not implemented in real scalar for complex eigenvalues");
464: #endif
465:       if (nep->npart==1) {
466:         BVGetColumn(nep->V,idx_sc[color],&v);
467:       } else v = ctx->v; 
468:       NEPSimpleNRefSetUpSystem(nep,ctx,ctx->A,idx_sc[color],&Mt,&T,&P,ini,t[0],v);
469:       KSPSetOperators(nep->refineksp,T,P);
470:       if (ini) {
471:         KSPSetFromOptions(nep->refineksp);
472:         if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT) {
473:           MatCreateVecs(T,&dvv,NULL);
474:           VecDuplicate(dvv,&rr);
475:         }
476:         ini = PETSC_FALSE;
477:       }
478:       switch (nep->scheme) {
479:       case NEP_REFINE_SCHEME_EXPLICIT:
480:         MatMult(Mt,v,r);
481:         VecGetArrayRead(r,&array);
482:         if (rank==size-1) {
483:           VecGetArray(rr,&array2);
484:           PetscMemcpy(array2,array,n*sizeof(PetscScalar));
485:           array2[n] = 0.0;
486:           VecRestoreArray(rr,&array2);
487:         } else {
488:           VecPlaceArray(rr,array);
489:         }
490:         KSPSolve(nep->refineksp,rr,dvv);
491:         KSPGetConvergedReason(nep->refineksp,&reason);
492:         if (reason>0) {
493:           if (rank != size-1) {
494:             VecResetArray(rr);
495:           }
496:           VecRestoreArrayRead(r,&array);
497:           VecGetArrayRead(dvv,&array);
498:           VecPlaceArray(dv,array);
499:           VecAXPY(v,-1.0,dv);
500:           VecNorm(v,NORM_2,&norm);
501:           VecScale(v,1.0/norm);
502:           VecResetArray(dv);
503:           if (rank==size-1) nep->eigr[idx_sc[color]] -= array[n];
504:           VecRestoreArrayRead(dvv,&array);
505:         } else fail_sc[color] = 1;
506:         break;
507:       case NEP_REFINE_SCHEME_MBE:
508:         MatMult(T,v,r);
509:         /* Mixed block elimination */
510:         VecConjugate(v);
511:         KSPSolveTranspose(nep->refineksp,v,t[0]);
512:         KSPGetConvergedReason(nep->refineksp,&reason);
513:         if (reason>0) {
514:           VecConjugate(t[0]);
515:           VecDot(ctx->w,t[0],&tt[0]);
516:           KSPSolve(nep->refineksp,ctx->w,t[1]);
517:           KSPGetConvergedReason(nep->refineksp,&reason);
518:           if (reason>0) {
519:             VecDot(t[1],v,&tt[1]);
520:             VecDot(r,t[0],&ttt);
521:             tt[0] = ttt/tt[0];
522:             VecAXPY(r,-tt[0],ctx->w);
523:             KSPSolve(nep->refineksp,r,dv);
524:             KSPGetConvergedReason(nep->refineksp,&reason);
525:             if (reason>0) {
526:               VecDot(dv,v,&ttt);
527:               tt[1] = ttt/tt[1];
528:               VecAXPY(dv,-tt[1],t[1]);
529:               deig = tt[0]+tt[1];
530:             }
531:           }
532:           VecConjugate(v);
533:           VecAXPY(v,-1.0,dv);
534:           VecNorm(v,NORM_2,&norm);
535:           VecScale(v,1.0/norm);
536:           nep->eigr[idx_sc[color]] -= deig;
537:           fail_sc[color] = 0;
538:         } else {
539:           VecConjugate(v);
540:           fail_sc[color] = 1;
541:         }
542:         break;
543:       case NEP_REFINE_SCHEME_SCHUR:
544:         MatShellGetContext(T,&fctx);
545:         MatMult(fctx->M1,v,r);
546:         KSPSolve(nep->refineksp,r,dv);
547:         KSPGetConvergedReason(nep->refineksp,&reason);
548:         if (reason>0) {
549:           VecDot(dv,v,&deig);
550:           deig *= -fctx->m3/fctx->M4;
551:           VecAXPY(v,-1.0,dv);
552:           VecNorm(v,NORM_2,&norm);
553:           VecScale(v,1.0/norm);
554:           nep->eigr[idx_sc[color]] -= deig;
555:           fail_sc[color] = 0;
556:         } else fail_sc[color] = 1;
557:         break;
558:       }
559:       if (nep->npart==1) { BVRestoreColumn(nep->V,idx_sc[color],&v); }
560:     }
561:   }
562:   VecDestroy(&t[0]);
563:   VecDestroy(&t[1]);
564:   VecDestroy(&dv);
565:   VecDestroy(&ctx->w);
566:   VecDestroy(&r);
567:   PetscFree3(idx_sc,its_sc,fail_sc);
568:   VecScatterDestroy(&ctx->nst);
569:   if (nep->npart>1) {
570:     VecDestroy(&ctx->vg);
571:     VecDestroy(&ctx->v);
572:     for (i=0;i<nep->nt;i++) {
573:       MatDestroy(&ctx->A[i]);
574:     }
575:     for (i=0;i<nep->npart;i++) {
576:       VecScatterDestroy(&ctx->scatter_id[i]);
577:     }
578:     PetscFree2(ctx->A,ctx->scatter_id);
579:   }
580:   if (fctx && nep->scheme==NEP_REFINE_SCHEME_SCHUR) {
581:     MatDestroy(&P);
582:     MatDestroy(&fctx->M1);
583:     PetscFree(fctx);
584:   }
585:   if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT) {
586:     MatDestroy(&Mt);
587:     VecDestroy(&dvv);
588:     VecDestroy(&rr);
589:     VecDestroy(&ctx->nv);
590:     if (nep->npart>1) {
591:       for (i=0;i<nep->nt;i++) { FNDestroy(&ctx->fn[i]); }
592:       PetscFree(ctx->fn);
593:     }
594:   }
595:   MatDestroy(&T);
596:   PetscFree(ctx);
597:   PetscLogEventEnd(NEP_Refine,nep,0,0,0);
598:   return(0);
599: }

slepc-3.7.4/src/nep/interface/nepdefault.c.html0000644000175000017500000004212613107004621020737 0ustar jromanjroman
Actual source code: nepdefault.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      This file contains some simple default routines for common NEP operations.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/nepimpl.h>     /*I "slepcnep.h" I*/

 28: /*@
 29:    NEPSetWorkVecs - Sets a number of work vectors into a NEP object

 31:    Collective on NEP

 33:    Input Parameters:
 34: +  nep - nonlinear eigensolver context
 35: -  nw  - number of work vectors to allocate

 37:    Developers Note:
 38:    This is PETSC_EXTERN because it may be required by user plugin NEP
 39:    implementations.

 41:    Level: developer
 42: @*/
 43: PetscErrorCode NEPSetWorkVecs(NEP nep,PetscInt nw)
 44: {
 46:   Vec            t;

 49:   if (nep->nwork < nw) {
 50:     VecDestroyVecs(nep->nwork,&nep->work);
 51:     nep->nwork = nw;
 52:     BVGetColumn(nep->V,0,&t);
 53:     VecDuplicateVecs(t,nw,&nep->work);
 54:     BVRestoreColumn(nep->V,0,&t);
 55:     PetscLogObjectParents(nep,nw,nep->work);
 56:   }
 57:   return(0);
 58: }

 62: /*
 63:   NEPGetDefaultShift - Return the value of sigma to start the nonlinear iteration.
 64:  */
 65: PetscErrorCode NEPGetDefaultShift(NEP nep,PetscScalar *sigma)
 66: {
 69:   switch (nep->which) {
 70:     case NEP_LARGEST_MAGNITUDE:
 71:     case NEP_LARGEST_IMAGINARY:
 72:     case NEP_ALL:
 73:     case NEP_WHICH_USER:
 74:       *sigma = 1.0;   /* arbitrary value */
 75:       break;
 76:     case NEP_SMALLEST_MAGNITUDE:
 77:     case NEP_SMALLEST_IMAGINARY:
 78:       *sigma = 0.0;
 79:       break;
 80:     case NEP_LARGEST_REAL:
 81:       *sigma = PETSC_MAX_REAL;
 82:       break;
 83:     case NEP_SMALLEST_REAL:
 84:       *sigma = PETSC_MIN_REAL;
 85:       break;
 86:     case NEP_TARGET_MAGNITUDE:
 87:     case NEP_TARGET_REAL:
 88:     case NEP_TARGET_IMAGINARY:
 89:       *sigma = nep->target;
 90:       break;
 91:   }
 92:   return(0);
 93: }

 97: /*
 98:   NEPConvergedRelative - Checks convergence relative to the eigenvalue.
 99: */
100: PetscErrorCode NEPConvergedRelative(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
101: {
102:   PetscReal w;

105:   w = SlepcAbsEigenvalue(eigr,eigi);
106:   *errest = res/w;
107:   return(0);
108: }

112: /*
113:   NEPConvergedAbsolute - Checks convergence absolutely.
114: */
115: PetscErrorCode NEPConvergedAbsolute(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
116: {
118:   *errest = res;
119:   return(0);
120: }

124: /*
125:   NEPConvergedNorm - Checks convergence relative to the matrix norms.
126: */
127: PetscErrorCode NEPConvergedNorm(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
128: {
129:   PetscScalar    s;
130:   PetscReal      w=0.0;
131:   PetscInt       j;
132:   PetscBool      flg;

136:   if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Backward error only available in split form");
137:   /* initialization of matrix norms */
138:   if (!nep->nrma[0]) {
139:     for (j=0;j<nep->nt;j++) {
140:       MatHasOperation(nep->A[j],MATOP_NORM,&flg);
141:       if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"The convergence test related to the matrix norms requires a matrix norm operation");
142:       MatNorm(nep->A[j],NORM_INFINITY,&nep->nrma[j]);
143:     }
144:   }
145:   for (j=0;j<nep->nt;j++) {
146:     FNEvaluateFunction(nep->f[j],eigr,&s);
147:     w = w + nep->nrma[j]*PetscAbsScalar(s);
148:   }
149:   *errest = res/w;
150:   return(0);
151: }

155: /*@C
156:    NEPStoppingBasic - Default routine to determine whether the outer eigensolver
157:    iteration must be stopped.

159:    Collective on NEP

161:    Input Parameters:
162: +  nep    - nonlinear eigensolver context obtained from NEPCreate()
163: .  its    - current number of iterations
164: .  max_it - maximum number of iterations
165: .  nconv  - number of currently converged eigenpairs
166: .  nev    - number of requested eigenpairs
167: -  ctx    - context (not used here)

169:    Output Parameter:
170: .  reason - result of the stopping test

172:    Notes:
173:    A positive value of reason indicates that the iteration has finished successfully
174:    (converged), and a negative value indicates an error condition (diverged). If
175:    the iteration needs to be continued, reason must be set to NEP_CONVERGED_ITERATING
176:    (zero).

178:    NEPStoppingBasic() will stop if all requested eigenvalues are converged, or if
179:    the maximum number of iterations has been reached.

181:    Use NEPSetStoppingTest() to provide your own test instead of using this one.

183:    Level: advanced

185: .seealso: NEPSetStoppingTest(), NEPConvergedReason, NEPGetConvergedReason()
186: @*/
187: PetscErrorCode NEPStoppingBasic(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)
188: {

192:   *reason = NEP_CONVERGED_ITERATING;
193:   if (nconv >= nev) {
194:     PetscInfo2(nep,"Nonlinear eigensolver finished successfully: %D eigenpairs converged at iteration %D\n",nconv,its);
195:     *reason = NEP_CONVERGED_TOL;
196:   } else if (its >= max_it) {
197:     *reason = NEP_DIVERGED_ITS;
198:     PetscInfo1(nep,"Nonlinear eigensolver iteration reached maximum number of iterations (%D)\n",its);
199:   }
200:   return(0);
201: }

205: PetscErrorCode NEPComputeVectors_Schur(NEP nep)
206: {
208:   PetscInt       n,i;
209:   Mat            Z;
210:   Vec            v;

213:   DSGetDimensions(nep->ds,&n,NULL,NULL,NULL,NULL);
214:   DSVectors(nep->ds,DS_MAT_X,NULL,NULL);
215:   DSGetMat(nep->ds,DS_MAT_X,&Z);
216:   BVSetActiveColumns(nep->V,0,n);
217:   BVMultInPlace(nep->V,Z,0,n);
218:   MatDestroy(&Z);

220:   /* normalization */
221:   for (i=0;i<n;i++) {
222:     BVGetColumn(nep->V,i,&v);
223:     VecNormalize(v,NULL);
224:     BVRestoreColumn(nep->V,i,&v);
225:   }
226:   return(0);
227: }

slepc-3.7.4/src/nep/interface/dlregisnep.c.html0000644000175000017500000002657013107004621020751 0ustar jromanjroman
Actual source code: dlregisnep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/nepimpl.h>

 24: static PetscBool NEPPackageInitialized = PETSC_FALSE;

 26: const char *NEPErrorTypes[] = {"ABSOLUTE","RELATIVE","NEPErrorType","NEP_ERROR_",0};
 27: const char *NEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","NEPRefine","NEP_REFINE_",0};
 28: const char *NEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","NEPRefineScheme","NEP_REFINE_SCHEME_",0};
 29: const char *const NEPConvergedReasons_Shifted[] = {"DIVERGED_LINEAR_SOLVE","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","NEPConvergedReason","NEP_",0};
 30: const char *const*NEPConvergedReasons = NEPConvergedReasons_Shifted + 4;

 34: /*@C
 35:    NEPFinalizePackage - This function destroys everything in the Slepc interface
 36:    to the NEP package. It is called from SlepcFinalize().

 38:    Level: developer

 40: .seealso: SlepcFinalize()
 41: @*/
 42: PetscErrorCode NEPFinalizePackage(void)
 43: {

 47:   PetscFunctionListDestroy(&NEPList);
 48:   NEPPackageInitialized = PETSC_FALSE;
 49:   NEPRegisterAllCalled  = PETSC_FALSE;
 50:   return(0);
 51: }

 55: /*@C
 56:    NEPInitializePackage - This function initializes everything in the NEP package.
 57:    It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 58:    on the first call to NEPCreate() when using static libraries.

 60:    Level: developer

 62: .seealso: SlepcInitialize()
 63: @*/
 64: PetscErrorCode NEPInitializePackage(void)
 65: {
 66:   char           logList[256];
 67:   char           *className;
 68:   PetscBool      opt;

 72:   if (NEPPackageInitialized) return(0);
 73:   NEPPackageInitialized = PETSC_TRUE;
 74:   /* Register Classes */
 75:   PetscClassIdRegister("NEP Solver",&NEP_CLASSID);
 76:   /* Register Constructors */
 77:   NEPRegisterAll();
 78:   /* Register Events */
 79:   PetscLogEventRegister("NEPSetUp",NEP_CLASSID,&NEP_SetUp);
 80:   PetscLogEventRegister("NEPSolve",NEP_CLASSID,&NEP_Solve);
 81:   PetscLogEventRegister("NEPRefine",NEP_CLASSID,&NEP_Refine);
 82:   PetscLogEventRegister("NEPFunctionEval",NEP_CLASSID,&NEP_FunctionEval);
 83:   PetscLogEventRegister("NEPJacobianEval",NEP_CLASSID,&NEP_JacobianEval);
 84:   PetscLogEventRegister("NEPDerivativesEval",NEP_CLASSID,&NEP_DerivativesEval);
 85:   /* Process info exclusions */
 86:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 87:   if (opt) {
 88:     PetscStrstr(logList,"nep",&className);
 89:     if (className) {
 90:       PetscInfoDeactivateClass(NEP_CLASSID);
 91:     }
 92:   }
 93:   /* Process summary exclusions */
 94:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 95:   if (opt) {
 96:     PetscStrstr(logList,"nep",&className);
 97:     if (className) {
 98:       PetscLogEventDeactivateClass(NEP_CLASSID);
 99:     }
100:   }
101:   PetscRegisterFinalize(NEPFinalizePackage);
102:   return(0);
103: }

105: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

109: /*
110:   PetscDLLibraryRegister - This function is called when the dynamic library
111:   it is in is opened.

113:   This one registers all the NEP methods that are in the basic SLEPc libslepcnep
114:   library.
115:  */
116: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcnep()
117: {

121:   NEPInitializePackage();
122:   return(0);
123: }
124: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */

slepc-3.7.4/src/nep/interface/nepbasic.c.html0000644000175000017500000022013113107004621020366 0ustar jromanjroman
Actual source code: nepbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Basic NEP routines, Create, View, etc.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/nepimpl.h>      /*I "slepcnep.h" I*/

 26: PetscFunctionList NEPList = 0;
 27: PetscBool         NEPRegisterAllCalled = PETSC_FALSE;
 28: PetscClassId      NEP_CLASSID = 0;
 29: PetscLogEvent     NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;

 33: /*@
 34:    NEPCreate - Creates the default NEP context.

 36:    Collective on MPI_Comm

 38:    Input Parameter:
 39: .  comm - MPI communicator

 41:    Output Parameter:
 42: .  nep - location to put the NEP context

 44:    Level: beginner

 46: .seealso: NEPSetUp(), NEPSolve(), NEPDestroy(), NEP
 47: @*/
 48: PetscErrorCode NEPCreate(MPI_Comm comm,NEP *outnep)
 49: {
 51:   NEP            nep;

 55:   *outnep = 0;
 56:   NEPInitializePackage();
 57:   SlepcHeaderCreate(nep,NEP_CLASSID,"NEP","Nonlinear Eigenvalue Problem","NEP",comm,NEPDestroy,NEPView);

 59:   nep->max_it          = 0;
 60:   nep->nev             = 1;
 61:   nep->ncv             = 0;
 62:   nep->mpd             = 0;
 63:   nep->nini            = 0;
 64:   nep->target          = 0.0;
 65:   nep->tol             = PETSC_DEFAULT;
 66:   nep->conv            = NEP_CONV_REL;
 67:   nep->stop            = NEP_STOP_BASIC;
 68:   nep->which           = (NEPWhich)0;
 69:   nep->refine          = NEP_REFINE_NONE;
 70:   nep->npart           = 1;
 71:   nep->rtol            = PETSC_DEFAULT;
 72:   nep->rits            = PETSC_DEFAULT;
 73:   nep->scheme          = (NEPRefineScheme)0;
 74:   nep->trackall        = PETSC_FALSE;

 76:   nep->computefunction = NULL;
 77:   nep->computejacobian = NULL;
 78:   nep->functionctx     = NULL;
 79:   nep->jacobianctx     = NULL;
 80:   nep->computederivatives = NULL;
 81:   nep->derivativesctx  = NULL;
 82:   nep->converged       = NEPConvergedRelative;
 83:   nep->convergeddestroy= NULL;
 84:   nep->stopping        = NEPStoppingBasic;
 85:   nep->stoppingdestroy = NULL;
 86:   nep->convergedctx    = NULL;
 87:   nep->stoppingctx     = NULL;
 88:   nep->numbermonitors  = 0;

 90:   nep->ds              = NULL;
 91:   nep->V               = NULL;
 92:   nep->rg              = NULL;
 93:   nep->function        = NULL;
 94:   nep->function_pre    = NULL;
 95:   nep->jacobian        = NULL;
 96:   nep->derivatives     = NULL;
 97:   nep->A               = NULL;
 98:   nep->f               = NULL;
 99:   nep->nt              = 0;
100:   nep->mstr            = DIFFERENT_NONZERO_PATTERN;
101:   nep->IS              = NULL;
102:   nep->eigr            = NULL;
103:   nep->eigi            = NULL;
104:   nep->errest          = NULL;
105:   nep->perm            = NULL;
106:   nep->nwork           = 0;
107:   nep->work            = NULL;
108:   nep->data            = NULL;

110:   nep->state           = NEP_STATE_INITIAL;
111:   nep->nconv           = 0;
112:   nep->its             = 0;
113:   nep->n               = 0;
114:   nep->nloc            = 0;
115:   nep->nrma            = NULL;
116:   nep->fui             = (NEPUserInterface)0;
117:   nep->reason          = NEP_CONVERGED_ITERATING;

119:   PetscNewLog(nep,&nep->sc);
120:   *outnep = nep;
121:   return(0);
122: }

126: /*@C
127:    NEPSetType - Selects the particular solver to be used in the NEP object.

129:    Logically Collective on NEP

131:    Input Parameters:
132: +  nep      - the nonlinear eigensolver context
133: -  type     - a known method

135:    Options Database Key:
136: .  -nep_type <method> - Sets the method; use -help for a list
137:     of available methods

139:    Notes:
140:    See "slepc/include/slepcnep.h" for available methods.

142:    Normally, it is best to use the NEPSetFromOptions() command and
143:    then set the NEP type from the options database rather than by using
144:    this routine.  Using the options database provides the user with
145:    maximum flexibility in evaluating the different available methods.
146:    The NEPSetType() routine is provided for those situations where it
147:    is necessary to set the iterative solver independently of the command
148:    line or options database.

150:    Level: intermediate

152: .seealso: NEPType
153: @*/
154: PetscErrorCode NEPSetType(NEP nep,NEPType type)
155: {
156:   PetscErrorCode ierr,(*r)(NEP);
157:   PetscBool      match;


163:   PetscObjectTypeCompare((PetscObject)nep,type,&match);
164:   if (match) return(0);

166:   PetscFunctionListFind(NEPList,type,&r);
167:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown NEP type given: %s",type);

169:   if (nep->ops->destroy) { (*nep->ops->destroy)(nep); }
170:   PetscMemzero(nep->ops,sizeof(struct _NEPOps));

172:   nep->state = NEP_STATE_INITIAL;
173:   PetscObjectChangeTypeName((PetscObject)nep,type);
174:   (*r)(nep);
175:   return(0);
176: }

180: /*@C
181:    NEPGetType - Gets the NEP type as a string from the NEP object.

183:    Not Collective

185:    Input Parameter:
186: .  nep - the eigensolver context

188:    Output Parameter:
189: .  name - name of NEP method

191:    Level: intermediate

193: .seealso: NEPSetType()
194: @*/
195: PetscErrorCode NEPGetType(NEP nep,NEPType *type)
196: {
200:   *type = ((PetscObject)nep)->type_name;
201:   return(0);
202: }

206: /*@C
207:    NEPRegister - Adds a method to the nonlinear eigenproblem solver package.

209:    Not Collective

211:    Input Parameters:
212: +  name - name of a new user-defined solver
213: -  function - routine to create the solver context

215:    Notes:
216:    NEPRegister() may be called multiple times to add several user-defined solvers.

218:    Sample usage:
219: .vb
220:     NEPRegister("my_solver",MySolverCreate);
221: .ve

223:    Then, your solver can be chosen with the procedural interface via
224: $     NEPSetType(nep,"my_solver")
225:    or at runtime via the option
226: $     -nep_type my_solver

228:    Level: advanced

230: .seealso: NEPRegisterAll()
231: @*/
232: PetscErrorCode NEPRegister(const char *name,PetscErrorCode (*function)(NEP))
233: {

237:   PetscFunctionListAdd(&NEPList,name,function);
238:   return(0);
239: }

243: /*
244:    NEPReset_Problem - Destroys the problem matrices.
245: @*/
246: PetscErrorCode NEPReset_Problem(NEP nep)
247: {
249:   PetscInt       i;

253:   MatDestroy(&nep->function);
254:   MatDestroy(&nep->function_pre);
255:   MatDestroy(&nep->jacobian);
256:   MatDestroy(&nep->derivatives);
257:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) {
258:     MatDestroyMatrices(nep->nt,&nep->A);
259:     for (i=0;i<nep->nt;i++) {
260:       FNDestroy(&nep->f[i]);
261:     }
262:     PetscFree(nep->f);
263:     PetscFree(nep->nrma);
264:   }
265:   return(0);
266: }
269: /*@
270:    NEPReset - Resets the NEP context to the initial state and removes any
271:    allocated objects.

273:    Collective on NEP

275:    Input Parameter:
276: .  nep - eigensolver context obtained from NEPCreate()

278:    Level: advanced

280: .seealso: NEPDestroy()
281: @*/
282: PetscErrorCode NEPReset(NEP nep)
283: {
285:   PetscInt       ncols;

289:   if (nep->ops->reset) { (nep->ops->reset)(nep); }
290:   if (nep->ds) { DSReset(nep->ds); }
291:   NEPReset_Problem(nep);
292:   BVGetSizes(nep->V,NULL,NULL,&ncols);
293:   if (ncols) {
294:     PetscFree4(nep->eigr,nep->eigi,nep->errest,nep->perm);
295:   }
296:   BVDestroy(&nep->V);
297:   VecDestroyVecs(nep->nwork,&nep->work);
298:   KSPDestroy(&nep->refineksp);
299:   PetscSubcommDestroy(&nep->refinesubc);
300:   nep->nwork = 0;
301:   nep->state = NEP_STATE_INITIAL;
302:   return(0);
303: }

307: /*@
308:    NEPDestroy - Destroys the NEP context.

310:    Collective on NEP

312:    Input Parameter:
313: .  nep - eigensolver context obtained from NEPCreate()

315:    Level: beginner

317: .seealso: NEPCreate(), NEPSetUp(), NEPSolve()
318: @*/
319: PetscErrorCode NEPDestroy(NEP *nep)
320: {

324:   if (!*nep) return(0);
326:   if (--((PetscObject)(*nep))->refct > 0) { *nep = 0; return(0); }
327:   NEPReset(*nep);
328:   if ((*nep)->ops->destroy) { (*(*nep)->ops->destroy)(*nep); }
329:   RGDestroy(&(*nep)->rg);
330:   DSDestroy(&(*nep)->ds);
331:   PetscFree((*nep)->sc);
332:   /* just in case the initial vectors have not been used */
333:   SlepcBasisDestroy_Private(&(*nep)->nini,&(*nep)->IS);
334:   if ((*nep)->convergeddestroy) {
335:     (*(*nep)->convergeddestroy)((*nep)->convergedctx);
336:   }
337:   NEPMonitorCancel(*nep);
338:   PetscHeaderDestroy(nep);
339:   return(0);
340: }

344: /*@
345:    NEPSetBV - Associates a basis vectors object to the nonlinear eigensolver.

347:    Collective on NEP

349:    Input Parameters:
350: +  nep - eigensolver context obtained from NEPCreate()
351: -  bv  - the basis vectors object

353:    Note:
354:    Use NEPGetBV() to retrieve the basis vectors context (for example,
355:    to free it at the end of the computations).

357:    Level: advanced

359: .seealso: NEPGetBV()
360: @*/
361: PetscErrorCode NEPSetBV(NEP nep,BV bv)
362: {

369:   PetscObjectReference((PetscObject)bv);
370:   BVDestroy(&nep->V);
371:   nep->V = bv;
372:   PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->V);
373:   return(0);
374: }

378: /*@
379:    NEPGetBV - Obtain the basis vectors object associated to the nonlinear
380:    eigensolver object.

382:    Not Collective

384:    Input Parameters:
385: .  nep - eigensolver context obtained from NEPCreate()

387:    Output Parameter:
388: .  bv - basis vectors context

390:    Level: advanced

392: .seealso: NEPSetBV()
393: @*/
394: PetscErrorCode NEPGetBV(NEP nep,BV *bv)
395: {

401:   if (!nep->V) {
402:     BVCreate(PetscObjectComm((PetscObject)nep),&nep->V);
403:     PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->V);
404:   }
405:   *bv = nep->V;
406:   return(0);
407: }

411: /*@
412:    NEPSetRG - Associates a region object to the nonlinear eigensolver.

414:    Collective on NEP

416:    Input Parameters:
417: +  nep - eigensolver context obtained from NEPCreate()
418: -  rg  - the region object

420:    Note:
421:    Use NEPGetRG() to retrieve the region context (for example,
422:    to free it at the end of the computations).

424:    Level: advanced

426: .seealso: NEPGetRG()
427: @*/
428: PetscErrorCode NEPSetRG(NEP nep,RG rg)
429: {

436:   PetscObjectReference((PetscObject)rg);
437:   RGDestroy(&nep->rg);
438:   nep->rg = rg;
439:   PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->rg);
440:   return(0);
441: }

445: /*@
446:    NEPGetRG - Obtain the region object associated to the
447:    nonlinear eigensolver object.

449:    Not Collective

451:    Input Parameters:
452: .  nep - eigensolver context obtained from NEPCreate()

454:    Output Parameter:
455: .  rg - region context

457:    Level: advanced

459: .seealso: NEPSetRG()
460: @*/
461: PetscErrorCode NEPGetRG(NEP nep,RG *rg)
462: {

468:   if (!nep->rg) {
469:     RGCreate(PetscObjectComm((PetscObject)nep),&nep->rg);
470:     PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->rg);
471:   }
472:   *rg = nep->rg;
473:   return(0);
474: }

478: /*@
479:    NEPSetDS - Associates a direct solver object to the nonlinear eigensolver.

481:    Collective on NEP

483:    Input Parameters:
484: +  nep - eigensolver context obtained from NEPCreate()
485: -  ds  - the direct solver object

487:    Note:
488:    Use NEPGetDS() to retrieve the direct solver context (for example,
489:    to free it at the end of the computations).

491:    Level: advanced

493: .seealso: NEPGetDS()
494: @*/
495: PetscErrorCode NEPSetDS(NEP nep,DS ds)
496: {

503:   PetscObjectReference((PetscObject)ds);
504:   DSDestroy(&nep->ds);
505:   nep->ds = ds;
506:   PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->ds);
507:   return(0);
508: }

512: /*@
513:    NEPGetDS - Obtain the direct solver object associated to the
514:    nonlinear eigensolver object.

516:    Not Collective

518:    Input Parameters:
519: .  nep - eigensolver context obtained from NEPCreate()

521:    Output Parameter:
522: .  ds - direct solver context

524:    Level: advanced

526: .seealso: NEPSetDS()
527: @*/
528: PetscErrorCode NEPGetDS(NEP nep,DS *ds)
529: {

535:   if (!nep->ds) {
536:     DSCreate(PetscObjectComm((PetscObject)nep),&nep->ds);
537:     PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->ds);
538:   }
539:   *ds = nep->ds;
540:   return(0);
541: }

545: /*@
546:    NEPRefineGetKSP - Obtain the ksp object used by the eigensolver
547:    object in the refinement phase.

549:    Not Collective

551:    Input Parameters:
552: .  nep - eigensolver context obtained from NEPCreate()

554:    Output Parameter:
555: .  ksp - ksp context

557:    Level: advanced

559: .seealso: NEPSetRefine()
560: @*/
561: PetscErrorCode NEPRefineGetKSP(NEP nep,KSP *ksp)
562: {

568:   if (!nep->refineksp) {
569:     if (nep->npart>1) {
570:       /* Split in subcomunicators */
571:       PetscSubcommCreate(PetscObjectComm((PetscObject)nep),&nep->refinesubc);
572:       PetscSubcommSetNumber(nep->refinesubc,nep->npart);
573:       PetscSubcommSetType(nep->refinesubc,PETSC_SUBCOMM_CONTIGUOUS);
574:       PetscLogObjectMemory((PetscObject)nep,sizeof(PetscSubcomm));
575:     }
576:     KSPCreate((nep->npart==1)?PetscObjectComm((PetscObject)nep):PetscSubcommChild(nep->refinesubc),&nep->refineksp);
577:     PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->refineksp);
578:     KSPSetOptionsPrefix(*ksp,((PetscObject)nep)->prefix);
579:     KSPAppendOptionsPrefix(*ksp,"nep_refine_");
580:     KSPSetErrorIfNotConverged(*ksp,PETSC_TRUE);
581:   }
582:   *ksp = nep->refineksp;
583:   return(0);
584: }

588: /*@
589:    NEPSetTarget - Sets the value of the target.

591:    Logically Collective on NEP

593:    Input Parameters:
594: +  nep    - eigensolver context
595: -  target - the value of the target

597:    Options Database Key:
598: .  -nep_target <scalar> - the value of the target

600:    Notes:
601:    The target is a scalar value used to determine the portion of the spectrum
602:    of interest. It is used in combination with NEPSetWhichEigenpairs().

604:    In the case of complex scalars, a complex value can be provided in the
605:    command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g.
606:    -nep_target 1.0+2.0i

608:    Level: intermediate

610: .seealso: NEPGetTarget(), NEPSetWhichEigenpairs()
611: @*/
612: PetscErrorCode NEPSetTarget(NEP nep,PetscScalar target)
613: {
617:   nep->target = target;
618:   return(0);
619: }

623: /*@
624:    NEPGetTarget - Gets the value of the target.

626:    Not Collective

628:    Input Parameter:
629: .  nep - eigensolver context

631:    Output Parameter:
632: .  target - the value of the target

634:    Note:
635:    If the target was not set by the user, then zero is returned.

637:    Level: intermediate

639: .seealso: NEPSetTarget()
640: @*/
641: PetscErrorCode NEPGetTarget(NEP nep,PetscScalar* target)
642: {
646:   *target = nep->target;
647:   return(0);
648: }

652: /*@C
653:    NEPSetFunction - Sets the function to compute the nonlinear Function T(lambda)
654:    as well as the location to store the matrix.

656:    Logically Collective on NEP and Mat

658:    Input Parameters:
659: +  nep - the NEP context
660: .  A   - Function matrix
661: .  B   - preconditioner matrix (usually same as the Function)
662: .  fun - Function evaluation routine (if NULL then NEP retains any
663:          previously set value)
664: -  ctx - [optional] user-defined context for private data for the Function
665:          evaluation routine (may be NULL) (if NULL then NEP retains any
666:          previously set value)

668:    Calling Sequence of fun:
669: $   fun(NEP nep,PetscScalar lambda,Mat F,Mat P,void *ctx)

671: +  nep    - the NEP context
672: .  lambda - the scalar argument where T(.) must be evaluated
673: .  T      - matrix that will contain T(lambda)
674: .  P      - (optional) different matrix to build the preconditioner
675: -  ctx    - (optional) user-defined context, as set by NEPSetFunction()

677:    Level: beginner

679: .seealso: NEPGetFunction(), NEPSetJacobian()
680: @*/
681: PetscErrorCode NEPSetFunction(NEP nep,Mat A,Mat B,PetscErrorCode (*fun)(NEP,PetscScalar,Mat,Mat,void*),void *ctx)
682: {


692:   if (nep->fui && nep->fui!=NEP_USER_INTERFACE_CALLBACK) {  /* clean previous user info */
693:     NEPReset_Problem(nep);
694:   }

696:   if (fun) nep->computefunction = fun;
697:   if (ctx) nep->functionctx     = ctx;
698:   if (A) {
699:     PetscObjectReference((PetscObject)A);
700:     MatDestroy(&nep->function);
701:     nep->function = A;
702:   }
703:   if (B) {
704:     PetscObjectReference((PetscObject)B);
705:     MatDestroy(&nep->function_pre);
706:     nep->function_pre = B;
707:   }
708:   nep->fui = NEP_USER_INTERFACE_CALLBACK;
709:   return(0);
710: }

714: /*@C
715:    NEPGetFunction - Returns the Function matrix and optionally the user
716:    provided context for evaluating the Function.

718:    Not Collective, but Mat object will be parallel if NEP object is

720:    Input Parameter:
721: .  nep - the nonlinear eigensolver context

723:    Output Parameters:
724: +  A   - location to stash Function matrix (or NULL)
725: .  B   - location to stash preconditioner matrix (or NULL)
726: .  fun - location to put Function function (or NULL)
727: -  ctx - location to stash Function context (or NULL)

729:    Level: advanced

731: .seealso: NEPSetFunction()
732: @*/
733: PetscErrorCode NEPGetFunction(NEP nep,Mat *A,Mat *B,PetscErrorCode (**fun)(NEP,PetscScalar,Mat,Mat,void*),void **ctx)
734: {
737:   NEPCheckCallback(nep,1);
738:   if (A)   *A   = nep->function;
739:   if (B)   *B   = nep->function_pre;
740:   if (fun) *fun = nep->computefunction;
741:   if (ctx) *ctx = nep->functionctx;
742:   return(0);
743: }

747: /*@C
748:    NEPSetJacobian - Sets the function to compute Jacobian T'(lambda) as well
749:    as the location to store the matrix.

751:    Logically Collective on NEP and Mat

753:    Input Parameters:
754: +  nep - the NEP context
755: .  A   - Jacobian matrix
756: .  jac - Jacobian evaluation routine (if NULL then NEP retains any
757:          previously set value)
758: -  ctx - [optional] user-defined context for private data for the Jacobian
759:          evaluation routine (may be NULL) (if NULL then NEP retains any
760:          previously set value)

762:    Calling Sequence of jac:
763: $   jac(NEP nep,PetscScalar lambda,Mat J,void *ctx)

765: +  nep    - the NEP context
766: .  lambda - the scalar argument where T'(.) must be evaluated
767: .  J      - matrix that will contain T'(lambda)
768: -  ctx    - (optional) user-defined context, as set by NEPSetJacobian()

770:    Level: beginner

772: .seealso: NEPSetFunction(), NEPGetJacobian()
773: @*/
774: PetscErrorCode NEPSetJacobian(NEP nep,Mat A,PetscErrorCode (*jac)(NEP,PetscScalar,Mat,void*),void *ctx)
775: {


783:   if (nep->fui && nep->fui!=NEP_USER_INTERFACE_CALLBACK) {  /* clean previous user info */
784:     NEPReset_Problem(nep);
785:   }

787:   if (jac) nep->computejacobian = jac;
788:   if (ctx) nep->jacobianctx     = ctx;
789:   if (A) {
790:     PetscObjectReference((PetscObject)A);
791:     MatDestroy(&nep->jacobian);
792:     nep->jacobian = A;
793:   }
794:   nep->fui = NEP_USER_INTERFACE_CALLBACK;
795:   return(0);
796: }

800: /*@C
801:    NEPGetJacobian - Returns the Jacobian matrix and optionally the user
802:    provided routine and context for evaluating the Jacobian.

804:    Not Collective, but Mat object will be parallel if NEP object is

806:    Input Parameter:
807: .  nep - the nonlinear eigensolver context

809:    Output Parameters:
810: +  A   - location to stash Jacobian matrix (or NULL)
811: .  jac - location to put Jacobian function (or NULL)
812: -  ctx - location to stash Jacobian context (or NULL)

814:    Level: advanced

816: .seealso: NEPSetJacobian()
817: @*/
818: PetscErrorCode NEPGetJacobian(NEP nep,Mat *A,PetscErrorCode (**jac)(NEP,PetscScalar,Mat,void*),void **ctx)
819: {
822:   NEPCheckCallback(nep,1);
823:   if (A)   *A   = nep->jacobian;
824:   if (jac) *jac = nep->computejacobian;
825:   if (ctx) *ctx = nep->jacobianctx;
826:   return(0);
827: }

831: /*@
832:    NEPSetSplitOperator - Sets the operator of the nonlinear eigenvalue problem
833:    in split form.

835:    Collective on NEP, Mat and FN

837:    Input Parameters:
838: +  nep - the nonlinear eigensolver context
839: .  n   - number of terms in the split form
840: .  A   - array of matrices
841: .  f   - array of functions
842: -  str - structure flag for matrices

844:    Notes:
845:    The nonlinear operator is written as T(lambda) = sum_i A_i*f_i(lambda),
846:    for i=1,...,n. The derivative T'(lambda) can be obtained using the
847:    derivatives of f_i.

849:    The structure flag provides information about A_i's nonzero pattern
850:    (see MatStructure enum). If all matrices have the same pattern, then
851:    use SAME_NONZERO_PATTERN. If the patterns are different but contained
852:    in the pattern of the first one, then use SUBSET_NONZERO_PATTERN.
853:    Otherwise use DIFFERENT_NONZERO_PATTERN.

855:    This function must be called before NEPSetUp(). If it is called again
856:    after NEPSetUp() then the NEP object is reset.

858:    Level: beginner

860: .seealso: NEPGetSplitOperatorTerm(), NEPGetSplitOperatorInfo()
861:  @*/
862: PetscErrorCode NEPSetSplitOperator(NEP nep,PetscInt n,Mat A[],FN f[],MatStructure str)
863: {
864:   PetscInt       i;

870:   if (n <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Must have one or more terms, you have %D",n);
875:   if (nep->state) { NEPReset(nep); }
876:   /* clean previously stored information */
877:   NEPReset_Problem(nep);
878:   /* allocate space and copy matrices and functions */
879:   PetscMalloc1(n,&nep->A);
880:   PetscLogObjectMemory((PetscObject)nep,n*sizeof(Mat));
881:   for (i=0;i<n;i++) {
883:     PetscObjectReference((PetscObject)A[i]);
884:     nep->A[i] = A[i];
885:   }
886:   PetscMalloc1(n,&nep->f);
887:   PetscLogObjectMemory((PetscObject)nep,n*sizeof(FN));
888:   for (i=0;i<n;i++) {
890:     PetscObjectReference((PetscObject)f[i]);
891:     nep->f[i] = f[i];
892:   }
893:   PetscCalloc1(n,&nep->nrma);
894:   PetscLogObjectMemory((PetscObject)nep,n*sizeof(PetscReal));
895:   nep->nt   = n;
896:   nep->mstr = str;
897:   nep->fui  = NEP_USER_INTERFACE_SPLIT;
898:   return(0);
899: }

903: /*@
904:    NEPGetSplitOperatorTerm - Gets the matrices and functions associated with
905:    the nonlinear operator in split form.

907:    Not collective, though parallel Mats and FNs are returned if the NEP is parallel

909:    Input Parameter:
910: +  nep - the nonlinear eigensolver context
911: -  k   - the index of the requested term (starting in 0)

913:    Output Parameters:
914: +  A - the matrix of the requested term
915: -  f - the function of the requested term

917:    Level: intermediate

919: .seealso: NEPSetSplitOperator(), NEPGetSplitOperatorInfo()
920: @*/
921: PetscErrorCode NEPGetSplitOperatorTerm(NEP nep,PetscInt k,Mat *A,FN *f)
922: {
925:   NEPCheckSplit(nep,1);
926:   if (k<0 || k>=nep->nt) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",nep->nt-1);
927:   if (A) *A = nep->A[k];
928:   if (f) *f = nep->f[k];
929:   return(0);
930: }

934: /*@
935:    NEPGetSplitOperatorInfo - Returns the number of terms of the split form of
936:    the nonlinear operator, as well as the structure flag for matrices.

938:    Not collective

940:    Input Parameter:
941: .  nep - the nonlinear eigensolver context

943:    Output Parameters:
944: +  n   - the number of terms passed in NEPSetSplitOperator()
945: -  str - the matrix structure flag passed in NEPSetSplitOperator()

947:    Level: intermediate

949: .seealso: NEPSetSplitOperator(), NEPGetSplitOperatorTerm()
950: @*/
951: PetscErrorCode NEPGetSplitOperatorInfo(NEP nep,PetscInt *n,MatStructure *str)
952: {
955:   NEPCheckSplit(nep,1);
956:   if (n)   *n = nep->nt;
957:   if (str) *str = nep->mstr;
958:   return(0);
959: }

963: /*@C
964:    NEPSetDerivatives - Sets the function to compute the k-th derivative T^(k)(lambda)
965:    for any value of k (including 0), as well as the location to store the matrix.

967:    Logically Collective on NEP and Mat

969:    Input Parameters:
970: +  nep - the NEP context
971: .  A   - the matrix to store the computed derivative
972: .  der - routing to evaluate the k-th derivative (if NULL then NEP retains any
973:          previously set value)
974: -  ctx - [optional] user-defined context for private data for the derivatives
975:          evaluation routine (may be NULL) (if NULL then NEP retains any
976:          previously set value)

978:    Level: beginner

980: .seealso: NEPSetFunction(), NEPGetDerivatives()
981: @*/
982: PetscErrorCode NEPSetDerivatives(NEP nep,Mat A,PetscErrorCode (*der)(NEP,PetscScalar,PetscInt,Mat,void*),void *ctx)
983: {


991:   if (nep->fui && nep->fui!=NEP_USER_INTERFACE_DERIVATIVES) {  /* clean previous user info */
992:     NEPReset_Problem(nep);
993:   }

995:   if (der) nep->computederivatives = der;
996:   if (ctx) nep->derivativesctx     = ctx;
997:   if (A) {
998:     PetscObjectReference((PetscObject)A);
999:     MatDestroy(&nep->derivatives);
1000:     nep->derivatives = A;
1001:   }
1002:   nep->fui = NEP_USER_INTERFACE_DERIVATIVES;
1003:   return(0);
1004: }

1008: /*@C
1009:    NEPGetDerivatives - Returns the derivatives matrix and optionally the user
1010:    provided routine and context for evaluating the derivatives.

1012:    Not Collective, but Mat object will be parallel if NEP object is

1014:    Input Parameter:
1015: .  nep - the nonlinear eigensolver context

1017:    Output Parameters:
1018: +  A   - location to stash the derivatives matrix (or NULL)
1019: .  der - location to put derivatives function (or NULL)
1020: -  ctx - location to stash derivatives context (or NULL)

1022:    Level: advanced

1024: .seealso: NEPSetDerivatives()
1025: @*/
1026: PetscErrorCode NEPGetDerivatives(NEP nep,Mat *A,PetscErrorCode (**der)(NEP,PetscScalar,PetscInt,Mat,void*),void **ctx)
1027: {
1030:   NEPCheckDerivatives(nep,1);
1031:   if (A)   *A   = nep->derivatives;
1032:   if (der) *der = nep->computederivatives;
1033:   if (ctx) *ctx = nep->derivativesctx;
1034:   return(0);
1035: }

slepc-3.7.4/src/nep/interface/nepregis.c.html0000644000175000017500000001355413107004621020427 0ustar jromanjroman
Actual source code: nepregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/nepimpl.h>      /*I "slepcnep.h" I*/

 24: PETSC_EXTERN PetscErrorCode NEPCreate_RII(NEP);
 25: PETSC_EXTERN PetscErrorCode NEPCreate_SLP(NEP);
 26: PETSC_EXTERN PetscErrorCode NEPCreate_NArnoldi(NEP);
 27: PETSC_EXTERN PetscErrorCode NEPCreate_CISS(NEP);
 28: PETSC_EXTERN PetscErrorCode NEPCreate_Interpol(NEP);
 29: PETSC_EXTERN PetscErrorCode NEPCreate_NLEIGS(NEP);

 33: /*@C
 34:    NEPRegisterAll - Registers all the solvers in the NEP package.

 36:    Not Collective

 38:    Level: advanced

 40: .seealso:  NEPRegister()
 41: @*/
 42: PetscErrorCode NEPRegisterAll(void)
 43: {

 47:   if (NEPRegisterAllCalled) return(0);
 48:   NEPRegisterAllCalled = PETSC_TRUE;
 49:   NEPRegister(NEPRII,NEPCreate_RII);
 50:   NEPRegister(NEPSLP,NEPCreate_SLP);
 51:   NEPRegister(NEPNARNOLDI,NEPCreate_NArnoldi);
 52:   NEPRegister(NEPINTERPOL,NEPCreate_Interpol);
 53: #if defined(PETSC_USE_COMPLEX)
 54:   NEPRegister(NEPCISS,NEPCreate_CISS);
 55: #endif
 56:   NEPRegister(NEPNLEIGS,NEPCreate_NLEIGS);
 57:   return(0);
 58: }

slepc-3.7.4/src/nep/interface/nepdefault.c0000644000175000017500000001602713107004621017775 0ustar jromanjroman/* This file contains some simple default routines for common NEP operations. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #undef __FUNCT__ #define __FUNCT__ "NEPSetWorkVecs" /*@ NEPSetWorkVecs - Sets a number of work vectors into a NEP object Collective on NEP Input Parameters: + nep - nonlinear eigensolver context - nw - number of work vectors to allocate Developers Note: This is PETSC_EXTERN because it may be required by user plugin NEP implementations. Level: developer @*/ PetscErrorCode NEPSetWorkVecs(NEP nep,PetscInt nw) { PetscErrorCode ierr; Vec t; PetscFunctionBegin; if (nep->nwork < nw) { ierr = VecDestroyVecs(nep->nwork,&nep->work);CHKERRQ(ierr); nep->nwork = nw; ierr = BVGetColumn(nep->V,0,&t);CHKERRQ(ierr); ierr = VecDuplicateVecs(t,nw,&nep->work);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,0,&t);CHKERRQ(ierr); ierr = PetscLogObjectParents(nep,nw,nep->work);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetDefaultShift" /* NEPGetDefaultShift - Return the value of sigma to start the nonlinear iteration. */ PetscErrorCode NEPGetDefaultShift(NEP nep,PetscScalar *sigma) { PetscFunctionBegin; PetscValidPointer(sigma,2); switch (nep->which) { case NEP_LARGEST_MAGNITUDE: case NEP_LARGEST_IMAGINARY: case NEP_ALL: case NEP_WHICH_USER: *sigma = 1.0; /* arbitrary value */ break; case NEP_SMALLEST_MAGNITUDE: case NEP_SMALLEST_IMAGINARY: *sigma = 0.0; break; case NEP_LARGEST_REAL: *sigma = PETSC_MAX_REAL; break; case NEP_SMALLEST_REAL: *sigma = PETSC_MIN_REAL; break; case NEP_TARGET_MAGNITUDE: case NEP_TARGET_REAL: case NEP_TARGET_IMAGINARY: *sigma = nep->target; break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPConvergedRelative" /* NEPConvergedRelative - Checks convergence relative to the eigenvalue. */ PetscErrorCode NEPConvergedRelative(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscReal w; PetscFunctionBegin; w = SlepcAbsEigenvalue(eigr,eigi); *errest = res/w; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPConvergedAbsolute" /* NEPConvergedAbsolute - Checks convergence absolutely. */ PetscErrorCode NEPConvergedAbsolute(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscFunctionBegin; *errest = res; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPConvergedNorm" /* NEPConvergedNorm - Checks convergence relative to the matrix norms. */ PetscErrorCode NEPConvergedNorm(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscScalar s; PetscReal w=0.0; PetscInt j; PetscBool flg; PetscErrorCode ierr; PetscFunctionBegin; if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Backward error only available in split form"); /* initialization of matrix norms */ if (!nep->nrma[0]) { for (j=0;jnt;j++) { ierr = MatHasOperation(nep->A[j],MATOP_NORM,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"The convergence test related to the matrix norms requires a matrix norm operation"); ierr = MatNorm(nep->A[j],NORM_INFINITY,&nep->nrma[j]);CHKERRQ(ierr); } } for (j=0;jnt;j++) { ierr = FNEvaluateFunction(nep->f[j],eigr,&s);CHKERRQ(ierr); w = w + nep->nrma[j]*PetscAbsScalar(s); } *errest = res/w; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPStoppingBasic" /*@C NEPStoppingBasic - Default routine to determine whether the outer eigensolver iteration must be stopped. Collective on NEP Input Parameters: + nep - nonlinear eigensolver context obtained from NEPCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged eigenpairs . nev - number of requested eigenpairs - ctx - context (not used here) Output Parameter: . reason - result of the stopping test Notes: A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to NEP_CONVERGED_ITERATING (zero). NEPStoppingBasic() will stop if all requested eigenvalues are converged, or if the maximum number of iterations has been reached. Use NEPSetStoppingTest() to provide your own test instead of using this one. Level: advanced .seealso: NEPSetStoppingTest(), NEPConvergedReason, NEPGetConvergedReason() @*/ PetscErrorCode NEPStoppingBasic(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; *reason = NEP_CONVERGED_ITERATING; if (nconv >= nev) { ierr = PetscInfo2(nep,"Nonlinear eigensolver finished successfully: %D eigenpairs converged at iteration %D\n",nconv,its);CHKERRQ(ierr); *reason = NEP_CONVERGED_TOL; } else if (its >= max_it) { *reason = NEP_DIVERGED_ITS; ierr = PetscInfo1(nep,"Nonlinear eigensolver iteration reached maximum number of iterations (%D)\n",its);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPComputeVectors_Schur" PetscErrorCode NEPComputeVectors_Schur(NEP nep) { PetscErrorCode ierr; PetscInt n,i; Mat Z; Vec v; PetscFunctionBegin; ierr = DSGetDimensions(nep->ds,&n,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSVectors(nep->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetMat(nep->ds,DS_MAT_X,&Z);CHKERRQ(ierr); ierr = BVSetActiveColumns(nep->V,0,n);CHKERRQ(ierr); ierr = BVMultInPlace(nep->V,Z,0,n);CHKERRQ(ierr); ierr = MatDestroy(&Z);CHKERRQ(ierr); /* normalization */ for (i=0;iV,i,&v);CHKERRQ(ierr); ierr = VecNormalize(v,NULL);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,i,&v);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/index.html0000644000175000017500000000370013107004621017471 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

nepmon.c
nepbasic.c
nepview.c
nepdefault.c
nepregis.c
nepopts.c
nepsetup.c
nepsolve.c
neprefine.c
dlregisnep.c
makefile
slepc-3.7.4/src/nep/interface/nepopts.c0000644000175000017500000012414613107004621017340 0ustar jromanjroman/* NEP routines related to options that can be set via the command-line or procedurally. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "NEPMonitorSetFromOptions" /*@C NEPMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user. Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor . monitor - the monitor function, whose context is a PetscViewerAndFormat - trackall - whether this monitor tracks all eigenvalues or not Level: developer .seealso: NEPMonitorSet(), NEPSetTrackAll(), NEPConvMonitorSetFromOptions() @*/ PetscErrorCode NEPMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; PetscViewerAndFormat *vf; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerAndFormatCreate(viewer,format,&vf);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = NEPMonitorSet(nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);CHKERRQ(ierr); if (trackall) { ierr = NEPSetTrackAll(nep,PETSC_TRUE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPConvMonitorSetFromOptions" /*@C NEPConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence). Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor - monitor - the monitor function, whose context is a SlepcConvMonitor Level: developer .seealso: NEPMonitorSet(), NEPMonitorSetFromOptions() @*/ PetscErrorCode NEPConvMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor)) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; SlepcConvMonitor ctx; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = SlepcConvMonitorCreate(viewer,format,&ctx);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = NEPMonitorSet(nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetFromOptions" /*@ NEPSetFromOptions - Sets NEP options from the options database. This routine must be called before NEPSetUp() if the user is to be allowed to set the solver type. Collective on NEP Input Parameters: . nep - the nonlinear eigensolver context Notes: To see all options, run your program with the -help option. Level: beginner @*/ PetscErrorCode NEPSetFromOptions(NEP nep) { PetscErrorCode ierr; char type[256]; PetscBool set,flg,flg1,flg2,flg3; PetscReal r; PetscScalar s; PetscInt i,j,k; PetscDrawLG lg; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = NEPRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)nep);CHKERRQ(ierr); ierr = PetscOptionsFList("-nep_type","Nonlinear Eigenvalue Problem method","NEPSetType",NEPList,(char*)(((PetscObject)nep)->type_name?((PetscObject)nep)->type_name:NEPRII),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetType(nep,type);CHKERRQ(ierr); } else if (!((PetscObject)nep)->type_name) { ierr = NEPSetType(nep,NEPRII);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-nep_refine","Iterative refinement method","NEPSetRefine",NEPRefineTypes,(PetscEnum)nep->refine,(PetscEnum*)&nep->refine,NULL);CHKERRQ(ierr); i = nep->npart; ierr = PetscOptionsInt("-nep_refine_partitions","Number of partitions of the communicator for iterative refinement","NEPSetRefine",nep->npart,&i,&flg1);CHKERRQ(ierr); r = nep->rtol; ierr = PetscOptionsReal("-nep_refine_tol","Tolerance for iterative refinement","NEPSetRefine",nep->rtol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/1000:nep->rtol,&r,&flg2);CHKERRQ(ierr); j = nep->rits; ierr = PetscOptionsInt("-nep_refine_its","Maximum number of iterations for iterative refinement","NEPSetRefine",nep->rits,&j,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = NEPSetRefine(nep,nep->refine,i,r,j,nep->scheme);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-nep_refine_scheme","Scheme used for linear systems within iterative refinement","NEPSetRefine",NEPRefineSchemes,(PetscEnum)nep->scheme,(PetscEnum*)&nep->scheme,NULL);CHKERRQ(ierr); i = nep->max_it? nep->max_it: PETSC_DEFAULT; ierr = PetscOptionsInt("-nep_max_it","Maximum number of iterations","NEPSetTolerances",nep->max_it,&i,&flg1);CHKERRQ(ierr); r = nep->tol; ierr = PetscOptionsReal("-nep_tol","Tolerance","NEPSetTolerances",nep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:nep->tol,&r,&flg2);CHKERRQ(ierr); if (flg1 || flg2) { ierr = NEPSetTolerances(nep,r,i);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-nep_conv_rel","Relative error convergence test","NEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetConvergenceTest(nep,NEP_CONV_REL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_conv_norm","Convergence test relative to the matrix norms","NEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetConvergenceTest(nep,NEP_CONV_NORM);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_conv_abs","Absolute error convergence test","NEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetConvergenceTest(nep,NEP_CONV_ABS);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-nep_conv_user","User-defined convergence test","NEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetConvergenceTest(nep,NEP_CONV_USER);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-nep_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","NEPSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetStoppingTest(nep,NEP_STOP_BASIC);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-nep_stop_user","User-defined stopping test","NEPSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetStoppingTest(nep,NEP_STOP_USER);CHKERRQ(ierr); } i = nep->nev; ierr = PetscOptionsInt("-nep_nev","Number of eigenvalues to compute","NEPSetDimensions",nep->nev,&i,&flg1);CHKERRQ(ierr); j = nep->ncv? nep->ncv: PETSC_DEFAULT; ierr = PetscOptionsInt("-nep_ncv","Number of basis vectors","NEPSetDimensions",nep->ncv,&j,&flg2);CHKERRQ(ierr); k = nep->mpd? nep->mpd: PETSC_DEFAULT; ierr = PetscOptionsInt("-nep_mpd","Maximum dimension of projected problem","NEPSetDimensions",nep->mpd,&k,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = NEPSetDimensions(nep,i,j,k);CHKERRQ(ierr); } ierr = PetscOptionsScalar("-nep_target","Value of the target","NEPSetTarget",nep->target,&s,&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE);CHKERRQ(ierr); ierr = NEPSetTarget(nep,s);CHKERRQ(ierr); } /* -----------------------------------------------------------------------*/ /* Cancels all monitors hardwired into code before call to NEPSetFromOptions() */ ierr = PetscOptionsBool("-nep_monitor_cancel","Remove any hardwired monitor routines","NEPMonitorCancel",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = NEPMonitorCancel(nep);CHKERRQ(ierr); } /* Text monitors */ ierr = NEPMonitorSetFromOptions(nep,"-nep_monitor","Monitor first unconverged approximate eigenvalue and error estimate","NEPMonitorFirst",NEPMonitorFirst,PETSC_FALSE);CHKERRQ(ierr); ierr = NEPConvMonitorSetFromOptions(nep,"-nep_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","NEPMonitorConverged",NEPMonitorConverged);CHKERRQ(ierr); ierr = NEPMonitorSetFromOptions(nep,"-nep_monitor_all","Monitor approximate eigenvalues and error estimates","NEPMonitorAll",NEPMonitorAll,PETSC_TRUE);CHKERRQ(ierr); /* Line graph monitors */ ierr = PetscOptionsBool("-nep_monitor_lg","Monitor first unconverged approximate error estimate graphically","NEPMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = NEPMonitorLGCreate(PetscObjectComm((PetscObject)nep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = NEPMonitorSet(nep,NEPMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); } ierr = PetscOptionsBool("-nep_monitor_lg_all","Monitor error estimates graphically","NEPMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = NEPMonitorLGCreate(PetscObjectComm((PetscObject)nep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = NEPMonitorSet(nep,NEPMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); ierr = NEPSetTrackAll(nep,PETSC_TRUE);CHKERRQ(ierr); } /* -----------------------------------------------------------------------*/ ierr = PetscOptionsBoolGroupBegin("-nep_largest_magnitude","compute largest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_LARGEST_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_smallest_magnitude","compute smallest eigenvalues in magnitude","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_SMALLEST_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_largest_real","compute largest real parts","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_LARGEST_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_smallest_real","compute smallest real parts","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_SMALLEST_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_largest_imaginary","compute largest imaginary parts","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_LARGEST_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_smallest_imaginary","compute smallest imaginary parts","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_SMALLEST_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_target_magnitude","compute nearest eigenvalues to target","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_TARGET_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_target_real","compute eigenvalues with real parts close to target","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_TARGET_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-nep_target_imaginary","compute eigenvalues with imaginary parts close to target","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_TARGET_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-nep_all","compute all eigenvalues in a region","NEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = NEPSetWhichEigenpairs(nep,NEP_ALL);CHKERRQ(ierr); } ierr = PetscOptionsName("-nep_view","Print detailed information on solver used","NEPView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-nep_view_vectors","View computed eigenvectors","NEPVectorsView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-nep_view_values","View computed eigenvalues","NEPValuesView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-nep_converged_reason","Print reason for convergence, and number of iterations","NEPReasonView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-nep_error_absolute","Print absolute errors of each eigenpair","NEPErrorView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-nep_error_relative","Print relative errors of each eigenpair","NEPErrorView",NULL);CHKERRQ(ierr); if (nep->ops->setfromoptions) { ierr = (*nep->ops->setfromoptions)(PetscOptionsObject,nep);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)nep);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (!nep->V) { ierr = NEPGetBV(nep,&nep->V);CHKERRQ(ierr); } ierr = BVSetFromOptions(nep->V);CHKERRQ(ierr); if (!nep->rg) { ierr = NEPGetRG(nep,&nep->rg);CHKERRQ(ierr); } ierr = RGSetFromOptions(nep->rg);CHKERRQ(ierr); if (!nep->ds) { ierr = NEPGetDS(nep,&nep->ds);CHKERRQ(ierr); } ierr = DSSetFromOptions(nep->ds);CHKERRQ(ierr); if (!nep->refineksp) { ierr = NEPRefineGetKSP(nep,&nep->refineksp);CHKERRQ(ierr); } ierr = KSPSetFromOptions(nep->refineksp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetTolerances" /*@ NEPGetTolerances - Gets the tolerance and maximum iteration count used by the NEP convergence tests. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + tol - the convergence tolerance - maxits - maximum number of iterations Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: NEPSetTolerances() @*/ PetscErrorCode NEPGetTolerances(NEP nep,PetscReal *tol,PetscInt *maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (tol) *tol = nep->tol; if (maxits) *maxits = nep->max_it; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetTolerances" /*@ NEPSetTolerances - Sets the tolerance and maximum iteration count used by the NEP convergence tests. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . tol - the convergence tolerance - maxits - maximum number of iterations to use Options Database Keys: + -nep_tol - Sets the convergence tolerance - -nep_max_it - Sets the maximum number of iterations allowed Notes: Use PETSC_DEFAULT for either argument to assign a reasonably good value. Level: intermediate .seealso: NEPGetTolerances() @*/ PetscErrorCode NEPSetTolerances(NEP nep,PetscReal tol,PetscInt maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveReal(nep,tol,2); PetscValidLogicalCollectiveInt(nep,maxits,3); if (tol == PETSC_DEFAULT) { nep->tol = PETSC_DEFAULT; nep->state = NEP_STATE_INITIAL; } else { if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); nep->tol = tol; } if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) { nep->max_it = 0; nep->state = NEP_STATE_INITIAL; } else { if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0"); nep->max_it = maxits; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetDimensions" /*@ NEPGetDimensions - Gets the number of eigenvalues to compute and the dimension of the subspace. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: NEPSetDimensions() @*/ PetscErrorCode NEPGetDimensions(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (nev) *nev = nep->nev; if (ncv) *ncv = nep->ncv; if (mpd) *mpd = nep->mpd; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetDimensions" /*@ NEPSetDimensions - Sets the number of eigenvalues to compute and the dimension of the subspace. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Options Database Keys: + -nep_nev - Sets the number of eigenvalues . -nep_ncv - Sets the dimension of the subspace - -nep_mpd - Sets the maximum projected dimension Notes: Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method. The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and (b) in cases where nev is large, the user sets mpd. The value of ncv should always be between nev and (nev+mpd), typically ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise a smaller value should be used. Level: intermediate .seealso: NEPGetDimensions() @*/ PetscErrorCode NEPSetDimensions(NEP nep,PetscInt nev,PetscInt ncv,PetscInt mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,nev,2); PetscValidLogicalCollectiveInt(nep,ncv,3); PetscValidLogicalCollectiveInt(nep,mpd,4); if (nev<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0"); nep->nev = nev; if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) { nep->ncv = 0; } else { if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0"); nep->ncv = ncv; } if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) { nep->mpd = 0; } else { if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0"); nep->mpd = mpd; } nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetWhichEigenpairs" /*@ NEPSetWhichEigenpairs - Specifies which portion of the spectrum is to be sought. Logically Collective on NEP Input Parameters: + nep - eigensolver context obtained from NEPCreate() - which - the portion of the spectrum to be sought Possible values: The parameter 'which' can have one of these values + NEP_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default) . NEP_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude . NEP_LARGEST_REAL - largest real parts . NEP_SMALLEST_REAL - smallest real parts . NEP_LARGEST_IMAGINARY - largest imaginary parts . NEP_SMALLEST_IMAGINARY - smallest imaginary parts . NEP_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude) . NEP_TARGET_REAL - eigenvalues with real part closest to target . NEP_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target . NEP_ALL - all eigenvalues contained in a given region - NEP_WHICH_USER - user defined ordering set with NEPSetEigenvalueComparison() Options Database Keys: + -nep_largest_magnitude - Sets largest eigenvalues in magnitude . -nep_smallest_magnitude - Sets smallest eigenvalues in magnitude . -nep_largest_real - Sets largest real parts . -nep_smallest_real - Sets smallest real parts . -nep_largest_imaginary - Sets largest imaginary parts . -nep_smallest_imaginary - Sets smallest imaginary parts . -nep_target_magnitude - Sets eigenvalues closest to target . -nep_target_real - Sets real parts closest to target . -nep_target_imaginary - Sets imaginary parts closest to target - -nep_all - Sets all eigenvalues in a region Notes: Not all eigensolvers implemented in NEP account for all the possible values stated above. If SLEPc is compiled for real numbers NEP_LARGEST_IMAGINARY and NEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part for eigenvalue selection. The target is a scalar value provided with NEPSetTarget(). NEP_ALL is intended for use in the context of the CISS solver for computing all eigenvalues in a region. Level: intermediate .seealso: NEPGetWhichEigenpairs(), NEPSetTarget(), NEPSetEigenvalueComparison(), NEPWhich @*/ PetscErrorCode NEPSetWhichEigenpairs(NEP nep,NEPWhich which) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveEnum(nep,which,2); switch (which) { case NEP_LARGEST_MAGNITUDE: case NEP_SMALLEST_MAGNITUDE: case NEP_LARGEST_REAL: case NEP_SMALLEST_REAL: case NEP_LARGEST_IMAGINARY: case NEP_SMALLEST_IMAGINARY: case NEP_TARGET_MAGNITUDE: case NEP_TARGET_REAL: #if defined(PETSC_USE_COMPLEX) case NEP_TARGET_IMAGINARY: #endif case EPS_ALL: case NEP_WHICH_USER: if (nep->which != which) { nep->state = NEP_STATE_INITIAL; nep->which = which; } break; default: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetWhichEigenpairs" /*@ NEPGetWhichEigenpairs - Returns which portion of the spectrum is to be sought. Not Collective Input Parameter: . nep - eigensolver context obtained from NEPCreate() Output Parameter: . which - the portion of the spectrum to be sought Notes: See NEPSetWhichEigenpairs() for possible values of 'which'. Level: intermediate .seealso: NEPSetWhichEigenpairs(), NEPWhich @*/ PetscErrorCode NEPGetWhichEigenpairs(NEP nep,NEPWhich *which) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(which,2); *which = nep->which; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetEigenvalueComparison" /*@C NEPSetEigenvalueComparison - Specifies the eigenvalue comparison function when NEPSetWhichEigenpairs() is set to NEP_WHICH_USER. Logically Collective on NEP Input Parameters: + pep - eigensolver context obtained from NEPCreate() . func - a pointer to the comparison function - ctx - a context pointer (the last parameter to the comparison function) Calling Sequence of func: $ func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx) + ar - real part of the 1st eigenvalue . ai - imaginary part of the 1st eigenvalue . br - real part of the 2nd eigenvalue . bi - imaginary part of the 2nd eigenvalue . res - result of comparison - ctx - optional context, as set by NEPSetEigenvalueComparison() Note: The returning parameter 'res' can be + negative - if the 1st eigenvalue is preferred to the 2st one . zero - if both eigenvalues are equally preferred - positive - if the 2st eigenvalue is preferred to the 1st one Level: advanced .seealso: NEPSetWhichEigenpairs(), NEPWhich @*/ PetscErrorCode NEPSetEigenvalueComparison(NEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,NEP_CLASSID,1); pep->sc->comparison = func; pep->sc->comparisonctx = ctx; pep->which = NEP_WHICH_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetConvergenceTestFunction" /*@C NEPSetConvergenceTestFunction - Sets a function to compute the error estimate used in the convergence test. Logically Collective on NEP Input Parameters: + nep - nonlinear eigensolver context obtained from NEPCreate() . func - a pointer to the convergence test function . ctx - context for private data for the convergence routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) + nep - nonlinear eigensolver context obtained from NEPCreate() . eigr - real part of the eigenvalue . eigi - imaginary part of the eigenvalue . res - residual norm associated to the eigenpair . errest - (output) computed error estimate - ctx - optional context, as set by NEPSetConvergenceTestFunction() Note: If the error estimate returned by the convergence test function is less than the tolerance, then the eigenvalue is accepted as converged. Level: advanced .seealso: NEPSetConvergenceTest(), NEPSetTolerances() @*/ PetscErrorCode NEPSetConvergenceTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (nep->convergeddestroy) { ierr = (*nep->convergeddestroy)(nep->convergedctx);CHKERRQ(ierr); } nep->converged = func; nep->convergeddestroy = destroy; nep->convergedctx = ctx; if (func == NEPConvergedRelative) nep->conv = NEP_CONV_REL; else if (func == NEPConvergedNorm) nep->conv = NEP_CONV_NORM; else if (func == NEPConvergedAbsolute) nep->conv = NEP_CONV_ABS; else nep->conv = NEP_CONV_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetConvergenceTest" /*@ NEPSetConvergenceTest - Specifies how to compute the error estimate used in the convergence test. Logically Collective on NEP Input Parameters: + nep - nonlinear eigensolver context obtained from NEPCreate() - conv - the type of convergence test Options Database Keys: + -nep_conv_abs - Sets the absolute convergence test . -nep_conv_rel - Sets the convergence test relative to the eigenvalue - -nep_conv_user - Selects the user-defined convergence test Note: The parameter 'conv' can have one of these values + NEP_CONV_ABS - absolute error ||r|| . NEP_CONV_REL - error relative to the eigenvalue l, ||r||/|l| . NEP_CONV_NORM - error relative matrix norms, ||r||/sum_i(|f_i(l)|*||A_i||) - NEP_CONV_USER - function set by NEPSetConvergenceTestFunction() Level: intermediate .seealso: NEPGetConvergenceTest(), NEPSetConvergenceTestFunction(), NEPSetStoppingTest(), NEPConv @*/ PetscErrorCode NEPSetConvergenceTest(NEP nep,NEPConv conv) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveEnum(nep,conv,2); switch (conv) { case NEP_CONV_ABS: nep->converged = NEPConvergedAbsolute; break; case NEP_CONV_REL: nep->converged = NEPConvergedRelative; break; case NEP_CONV_NORM: nep->converged = NEPConvergedNorm; break; case NEP_CONV_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value"); } nep->conv = conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetConvergenceTest" /*@ NEPGetConvergenceTest - Gets the method used to compute the error estimate used in the convergence test. Not Collective Input Parameters: . nep - nonlinear eigensolver context obtained from NEPCreate() Output Parameters: . conv - the type of convergence test Level: intermediate .seealso: NEPSetConvergenceTest(), NEPConv @*/ PetscErrorCode NEPGetConvergenceTest(NEP nep,NEPConv *conv) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(conv,2); *conv = nep->conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetStoppingTestFunction" /*@C NEPSetStoppingTestFunction - Sets a function to decide when to stop the outer iteration of the eigensolver. Logically Collective on NEP Input Parameters: + nep - nonlinear eigensolver context obtained from NEPCreate() . func - pointer to the stopping test function . ctx - context for private data for the stopping routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx) + nep - nonlinear eigensolver context obtained from NEPCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged eigenpairs . nev - number of requested eigenpairs . reason - (output) result of the stopping test - ctx - optional context, as set by NEPSetStoppingTestFunction() Note: Normal usage is to first call the default routine NEPStoppingBasic() and then set reason to NEP_CONVERGED_USER if some user-defined conditions have been met. To let the eigensolver continue iterating, the result must be left as NEP_CONVERGED_ITERATING. Level: advanced .seealso: NEPSetStoppingTest(), NEPStoppingBasic() @*/ PetscErrorCode NEPSetStoppingTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (nep->stoppingdestroy) { ierr = (*nep->stoppingdestroy)(nep->stoppingctx);CHKERRQ(ierr); } nep->stopping = func; nep->stoppingdestroy = destroy; nep->stoppingctx = ctx; if (func == NEPStoppingBasic) nep->stop = NEP_STOP_BASIC; else nep->stop = NEP_STOP_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetStoppingTest" /*@ NEPSetStoppingTest - Specifies how to decide the termination of the outer loop of the eigensolver. Logically Collective on NEP Input Parameters: + nep - nonlinear eigensolver context obtained from NEPCreate() - stop - the type of stopping test Options Database Keys: + -nep_stop_basic - Sets the default stopping test - -nep_stop_user - Selects the user-defined stopping test Note: The parameter 'stop' can have one of these values + NEP_STOP_BASIC - default stopping test - NEP_STOP_USER - function set by NEPSetStoppingTestFunction() Level: advanced .seealso: NEPGetStoppingTest(), NEPSetStoppingTestFunction(), NEPSetConvergenceTest(), NEPStop @*/ PetscErrorCode NEPSetStoppingTest(NEP nep,NEPStop stop) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveEnum(nep,stop,2); switch (stop) { case NEP_STOP_BASIC: nep->stopping = NEPStoppingBasic; break; case NEP_STOP_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value"); } nep->stop = stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetStoppingTest" /*@ NEPGetStoppingTest - Gets the method used to decide the termination of the outer loop of the eigensolver. Not Collective Input Parameters: . nep - nonlinear eigensolver context obtained from NEPCreate() Output Parameters: . stop - the type of stopping test Level: advanced .seealso: NEPSetStoppingTest(), NEPStop @*/ PetscErrorCode NEPGetStoppingTest(NEP nep,NEPStop *stop) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(stop,2); *stop = nep->stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetTrackAll" /*@ NEPSetTrackAll - Specifies if the solver must compute the residual of all approximate eigenpairs or not. Logically Collective on NEP Input Parameters: + nep - the eigensolver context - trackall - whether compute all residuals or not Notes: If the user sets trackall=PETSC_TRUE then the solver explicitly computes the residual for each eigenpair approximation. Computing the residual is usually an expensive operation and solvers commonly compute the associated residual to the first unconverged eigenpair. The options '-nep_monitor_all' and '-nep_monitor_lg_all' automatically activate this option. Level: developer .seealso: NEPGetTrackAll() @*/ PetscErrorCode NEPSetTrackAll(NEP nep,PetscBool trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveBool(nep,trackall,2); nep->trackall = trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetTrackAll" /*@ NEPGetTrackAll - Returns the flag indicating whether all residual norms must be computed or not. Not Collective Input Parameter: . nep - the eigensolver context Output Parameter: . trackall - the returned flag Level: developer .seealso: NEPSetTrackAll() @*/ PetscErrorCode NEPGetTrackAll(NEP nep,PetscBool *trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(trackall,2); *trackall = nep->trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetRefine" /*@ NEPSetRefine - Specifies the refinement type (and options) to be used after the solve. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . refine - refinement type . npart - number of partitions of the communicator . tol - the convergence tolerance . its - maximum number of refinement iterations - scheme - which scheme to be used for solving the involved linear systems Options Database Keys: + -nep_refine - refinement type, one of . -nep_refine_partitions - the number of partitions . -nep_refine_tol - the tolerance . -nep_refine_its - number of iterations - -nep_refine_scheme - to set the scheme for the linear solves Notes: By default, iterative refinement is disabled, since it may be very costly. There are two possible refinement strategies: simple and multiple. The simple approach performs iterative refinement on each of the converged eigenpairs individually, whereas the multiple strategy works with the invariant pair as a whole, refining all eigenpairs simultaneously. The latter may be required for the case of multiple eigenvalues. In some cases, especially when using direct solvers within the iterative refinement method, it may be helpful for improved scalability to split the communicator in several partitions. The npart parameter indicates how many partitions to use (defaults to 1). The tol and its parameters specify the stopping criterion. In the simple method, refinement continues until the residual of each eigenpair is below the tolerance (tol defaults to the NEP tol, but may be set to a different value). In contrast, the multiple method simply performs its refinement iterations (just one by default). The scheme argument is used to change the way in which linear systems are solved. Possible choices are: explicit, mixed block elimination (MBE), and Schur complement. Level: intermediate .seealso: NEPGetRefine() @*/ PetscErrorCode NEPSetRefine(NEP nep,NEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,NEPRefineScheme scheme) { PetscErrorCode ierr; PetscMPIInt size; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveEnum(nep,refine,2); PetscValidLogicalCollectiveInt(nep,npart,3); PetscValidLogicalCollectiveReal(nep,tol,4); PetscValidLogicalCollectiveInt(nep,its,5); PetscValidLogicalCollectiveEnum(nep,scheme,6); nep->refine = refine; if (refine) { /* process parameters only if not REFINE_NONE */ if (npart == PETSC_DEFAULT || npart == PETSC_DECIDE) { nep->npart = 1; } else { ierr = MPI_Comm_size(PetscObjectComm((PetscObject)nep),&size);CHKERRQ(ierr); if (npart<1 || npart>size) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart"); nep->npart = npart; } if (tol == PETSC_DEFAULT || tol == PETSC_DECIDE) { nep->rtol = PetscMax(nep->tol/1000,PETSC_MACHINE_EPSILON); } else { if (tol<=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); nep->rtol = tol; } if (its==PETSC_DECIDE || its==PETSC_DEFAULT) { nep->rits = PETSC_DEFAULT; } else { if (its<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be >= 0"); nep->rits = its; } nep->scheme = scheme; } nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetRefine" /*@ NEPGetRefine - Gets the refinement strategy used by the NEP object, and the associated parameters. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + refine - refinement type . npart - number of partitions of the communicator . tol - the convergence tolerance - its - maximum number of refinement iterations - scheme - the scheme used for solving linear systems Level: intermediate Note: The user can specify NULL for any parameter that is not needed. .seealso: NEPSetRefine() @*/ PetscErrorCode NEPGetRefine(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (refine) *refine = nep->refine; if (npart) *npart = nep->npart; if (tol) *tol = nep->rtol; if (its) *its = nep->rits; if (scheme) *scheme = nep->scheme; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetOptionsPrefix" /*@C NEPSetOptionsPrefix - Sets the prefix used for searching for all NEP options in the database. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - prefix - the prefix string to prepend to all NEP option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. For example, to distinguish between the runtime options for two different NEP contexts, one could call .vb NEPSetOptionsPrefix(nep1,"neig1_") NEPSetOptionsPrefix(nep2,"neig2_") .ve Level: advanced .seealso: NEPAppendOptionsPrefix(), NEPGetOptionsPrefix() @*/ PetscErrorCode NEPSetOptionsPrefix(NEP nep,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (!nep->V) { ierr = NEPGetBV(nep,&nep->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(nep->V,prefix);CHKERRQ(ierr); if (!nep->ds) { ierr = NEPGetDS(nep,&nep->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(nep->ds,prefix);CHKERRQ(ierr); if (!nep->rg) { ierr = NEPGetRG(nep,&nep->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(nep->rg,prefix);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)nep,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPAppendOptionsPrefix" /*@C NEPAppendOptionsPrefix - Appends to the prefix used for searching for all NEP options in the database. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - prefix - the prefix string to prepend to all NEP option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: NEPSetOptionsPrefix(), NEPGetOptionsPrefix() @*/ PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (!nep->V) { ierr = NEPGetBV(nep,&nep->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(nep->V,prefix);CHKERRQ(ierr); if (!nep->ds) { ierr = NEPGetDS(nep,&nep->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(nep->ds,prefix);CHKERRQ(ierr); if (!nep->rg) { ierr = NEPGetRG(nep,&nep->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(nep->rg,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)nep,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetOptionsPrefix" /*@C NEPGetOptionsPrefix - Gets the prefix used for searching for all NEP options in the database. Not Collective Input Parameters: . nep - the nonlinear eigensolver context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: NEPSetOptionsPrefix(), NEPAppendOptionsPrefix() @*/ PetscErrorCode NEPGetOptionsPrefix(NEP nep,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)nep,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/nepsetup.c0000644000175000017500000003127613107004621017514 0ustar jromanjroman/* NEP routines related to problem setup. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #undef __FUNCT__ #define __FUNCT__ "NEPSetUp" /*@ NEPSetUp - Sets up all the internal data structures necessary for the execution of the NEP solver. Collective on NEP Input Parameter: . nep - solver context Notes: This function need not be called explicitly in most cases, since NEPSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time. Level: developer .seealso: NEPCreate(), NEPSolve(), NEPDestroy() @*/ PetscErrorCode NEPSetUp(NEP nep) { PetscErrorCode ierr; PetscInt k; SlepcSC sc; Mat T; PetscBool flg; KSP ksp; PC pc; PetscMPIInt size; const MatSolverPackage stype; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); NEPCheckProblem(nep,1); if (nep->state) PetscFunctionReturn(0); ierr = PetscLogEventBegin(NEP_SetUp,nep,0,0,0);CHKERRQ(ierr); /* reset the convergence flag from the previous solves */ nep->reason = NEP_CONVERGED_ITERATING; /* set default solver type (NEPSetFromOptions was not called) */ if (!((PetscObject)nep)->type_name) { ierr = NEPSetType(nep,NEPRII);CHKERRQ(ierr); } if (!nep->ds) { ierr = NEPGetDS(nep,&nep->ds);CHKERRQ(ierr); } ierr = DSReset(nep->ds);CHKERRQ(ierr); if (!nep->rg) { ierr = NEPGetRG(nep,&nep->rg);CHKERRQ(ierr); } if (!((PetscObject)nep->rg)->type_name) { ierr = RGSetType(nep->rg,RGINTERVAL);CHKERRQ(ierr); } /* set problem dimensions */ switch (nep->fui) { case NEP_USER_INTERFACE_CALLBACK: ierr = NEPGetFunction(nep,&T,NULL,NULL,NULL);CHKERRQ(ierr); ierr = MatGetSize(T,&nep->n,NULL);CHKERRQ(ierr); ierr = MatGetLocalSize(T,&nep->nloc,NULL);CHKERRQ(ierr); break; case NEP_USER_INTERFACE_SPLIT: ierr = MatDuplicate(nep->A[0],MAT_DO_NOT_COPY_VALUES,&nep->function);CHKERRQ(ierr); ierr = MatDuplicate(nep->A[0],MAT_DO_NOT_COPY_VALUES,&nep->jacobian);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->function);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->jacobian);CHKERRQ(ierr); ierr = MatGetSize(nep->A[0],&nep->n,NULL);CHKERRQ(ierr); ierr = MatGetLocalSize(nep->A[0],&nep->nloc,NULL);CHKERRQ(ierr); break; case NEP_USER_INTERFACE_DERIVATIVES: ierr = NEPGetDerivatives(nep,&T,NULL,NULL);CHKERRQ(ierr); ierr = MatGetSize(T,&nep->n,NULL);CHKERRQ(ierr); ierr = MatGetLocalSize(T,&nep->nloc,NULL);CHKERRQ(ierr); break; } /* check consistency of refinement options */ if (nep->refine) { if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Iterative refinement only implemented in split form"); if (!nep->scheme) { /* set default scheme */ ierr = NEPRefineGetKSP(nep,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");CHKERRQ(ierr); } nep->scheme = flg? NEP_REFINE_SCHEME_MBE: NEP_REFINE_SCHEME_SCHUR; } if (nep->scheme==NEP_REFINE_SCHEME_MBE) { ierr = NEPRefineGetKSP(nep,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");CHKERRQ(ierr); } if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The MBE scheme for refinement requires a direct solver in KSP"); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pc),&size);CHKERRQ(ierr); if (size>1) { /* currently selected PC is a factorization */ ierr = PCFactorGetMatSolverPackage(pc,&stype);CHKERRQ(ierr); ierr = PetscStrcmp(stype,MATSOLVERPETSC,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"For Newton refinement, you chose to solve linear systems with a factorization, but in parallel runs you need to select an external package"); } } if (nep->scheme==NEP_REFINE_SCHEME_SCHUR) { if (nep->nt<=2) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The Schur scheme for refinement is only available for problems defined with more than 2 matrices"); if (nep->npart>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The Schur scheme for refinement does not support subcommunicators"); } } /* call specific solver setup */ ierr = (*nep->ops->setup)(nep);CHKERRQ(ierr); /* by default, compute eigenvalues close to target */ /* nep->target should contain the initial guess for the eigenvalue */ if (!nep->which) nep->which = NEP_TARGET_MAGNITUDE; /* set tolerance if not yet set */ if (nep->tol==PETSC_DEFAULT) nep->tol = SLEPC_DEFAULT_TOL; if (nep->refine) { if (nep->rtol==PETSC_DEFAULT) nep->rtol = PetscMax(nep->tol/1000,PETSC_MACHINE_EPSILON); if (nep->rits==PETSC_DEFAULT) nep->rits = (nep->refine==NEP_REFINE_SIMPLE)? 10: 1; } /* fill sorting criterion context */ switch (nep->which) { case NEP_LARGEST_MAGNITUDE: nep->sc->comparison = SlepcCompareLargestMagnitude; nep->sc->comparisonctx = NULL; break; case NEP_SMALLEST_MAGNITUDE: nep->sc->comparison = SlepcCompareSmallestMagnitude; nep->sc->comparisonctx = NULL; break; case NEP_LARGEST_REAL: nep->sc->comparison = SlepcCompareLargestReal; nep->sc->comparisonctx = NULL; break; case NEP_SMALLEST_REAL: nep->sc->comparison = SlepcCompareSmallestReal; nep->sc->comparisonctx = NULL; break; case NEP_LARGEST_IMAGINARY: nep->sc->comparison = SlepcCompareLargestImaginary; nep->sc->comparisonctx = NULL; break; case NEP_SMALLEST_IMAGINARY: nep->sc->comparison = SlepcCompareSmallestImaginary; nep->sc->comparisonctx = NULL; break; case NEP_TARGET_MAGNITUDE: nep->sc->comparison = SlepcCompareTargetMagnitude; nep->sc->comparisonctx = &nep->target; break; case NEP_TARGET_REAL: nep->sc->comparison = SlepcCompareTargetReal; nep->sc->comparisonctx = &nep->target; break; case NEP_TARGET_IMAGINARY: nep->sc->comparison = SlepcCompareTargetImaginary; nep->sc->comparisonctx = &nep->target; break; case NEP_ALL: nep->sc->comparison = SlepcCompareSmallestReal; nep->sc->comparisonctx = NULL; break; case NEP_WHICH_USER: break; } nep->sc->map = NULL; nep->sc->mapobj = NULL; /* fill sorting criterion for DS */ ierr = DSGetSlepcSC(nep->ds,&sc);CHKERRQ(ierr); sc->comparison = nep->sc->comparison; sc->comparisonctx = nep->sc->comparisonctx; ierr = PetscObjectTypeCompare((PetscObject)nep,NEPNLEIGS,&flg);CHKERRQ(ierr); if (!flg) { sc->map = NULL; sc->mapobj = NULL; } if (nep->ncv > nep->n) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"ncv must be the problem size at most"); if (nep->nev > nep->ncv) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"nev bigger than ncv"); /* process initial vectors */ if (nep->nini<0) { k = -nep->nini; if (k>nep->ncv) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The number of initial vectors is larger than ncv"); ierr = BVInsertVecs(nep->V,0,&k,nep->IS,PETSC_TRUE);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&nep->nini,&nep->IS);CHKERRQ(ierr); nep->nini = k; } ierr = PetscLogEventEnd(NEP_SetUp,nep,0,0,0);CHKERRQ(ierr); nep->state = NEP_STATE_SETUP; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetInitialSpace" /*@ NEPSetInitialSpace - Specify a basis of vectors that constitute the initial space, that is, the subspace from which the solver starts to iterate. Collective on NEP and Vec Input Parameter: + nep - the nonlinear eigensolver context . n - number of vectors - is - set of basis vectors of the initial space Notes: Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored. These vectors do not persist from one NEPSolve() call to the other, so the initial space should be set every time. The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally. Common usage of this function is when the user can provide a rough approximation of the wanted eigenspace. Then, convergence may be faster. Level: intermediate @*/ PetscErrorCode NEPSetInitialSpace(NEP nep,PetscInt n,Vec *is) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,n,2); if (n<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative"); ierr = SlepcBasisReference_Private(n,is,&nep->nini,&nep->IS);CHKERRQ(ierr); if (n>0) nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetDimensions_Default" /* NEPSetDimensions_Default - Set reasonable values for ncv, mpd if not set by the user. This is called at setup. */ PetscErrorCode NEPSetDimensions_Default(NEP nep,PetscInt nev,PetscInt *ncv,PetscInt *mpd) { PetscFunctionBegin; if (*ncv) { /* ncv set */ if (*ncvn,nev+(*mpd)); } else { /* neither set: defaults depend on nev being small or large */ if (nev<500) *ncv = PetscMin(nep->n,PetscMax(2*nev,nev+15)); else { *mpd = 500; *ncv = PetscMin(nep->n,nev+(*mpd)); } } if (!*mpd) *mpd = *ncv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPAllocateSolution" /*@ NEPAllocateSolution - Allocate memory storage for common variables such as eigenvalues and eigenvectors. Collective on NEP Input Parameters: + nep - eigensolver context - extra - number of additional positions, used for methods that require a working basis slightly larger than ncv Developers Note: This is PETSC_EXTERN because it may be required by user plugin NEP implementations. Level: developer @*/ PetscErrorCode NEPAllocateSolution(NEP nep,PetscInt extra) { PetscErrorCode ierr; PetscInt oldsize,newc,requested; PetscLogDouble cnt; Mat T; Vec t; PetscFunctionBegin; requested = nep->ncv + extra; /* oldsize is zero if this is the first time setup is called */ ierr = BVGetSizes(nep->V,NULL,NULL,&oldsize);CHKERRQ(ierr); newc = PetscMax(0,requested-oldsize); /* allocate space for eigenvalues and friends */ if (requested != oldsize || !nep->eigr) { if (oldsize) { ierr = PetscFree4(nep->eigr,nep->eigi,nep->errest,nep->perm);CHKERRQ(ierr); } ierr = PetscMalloc4(requested,&nep->eigr,requested,&nep->eigi,requested,&nep->errest,requested,&nep->perm);CHKERRQ(ierr); cnt = newc*sizeof(PetscScalar) + newc*sizeof(PetscReal) + newc*sizeof(PetscInt); ierr = PetscLogObjectMemory((PetscObject)nep,cnt);CHKERRQ(ierr); } /* allocate V */ if (!nep->V) { ierr = NEPGetBV(nep,&nep->V);CHKERRQ(ierr); } if (!oldsize) { if (!((PetscObject)(nep->V))->type_name) { ierr = BVSetType(nep->V,BVSVEC);CHKERRQ(ierr); } if (nep->fui==NEP_USER_INTERFACE_SPLIT) T = nep->A[0]; else { ierr = NEPGetFunction(nep,&T,NULL,NULL,NULL);CHKERRQ(ierr); } ierr = MatCreateVecs(T,&t,NULL);CHKERRQ(ierr); ierr = BVSetSizesFromVec(nep->V,t,requested);CHKERRQ(ierr); ierr = VecDestroy(&t);CHKERRQ(ierr); } else { ierr = BVResize(nep->V,requested,PETSC_FALSE);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/ftn-auto/0000755000175000017500000000000013107004621017231 5ustar jromanjromanslepc-3.7.4/src/nep/interface/ftn-auto/nepoptsf.c0000644000175000017500000001465613107004621021247 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nepopts.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetfromoptions_ NEPSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetfromoptions_ nepsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgettolerances_ NEPGETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgettolerances_ nepgettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsettolerances_ NEPSETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsettolerances_ nepsettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetdimensions_ NEPGETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetdimensions_ nepgetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetdimensions_ NEPSETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetdimensions_ nepsetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetwhicheigenpairs_ NEPSETWHICHEIGENPAIRS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetwhicheigenpairs_ nepsetwhicheigenpairs #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetwhicheigenpairs_ NEPGETWHICHEIGENPAIRS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetwhicheigenpairs_ nepgetwhicheigenpairs #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetconvergencetest_ NEPSETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetconvergencetest_ nepsetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetconvergencetest_ NEPGETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetconvergencetest_ nepgetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetstoppingtest_ NEPSETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetstoppingtest_ nepsetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetstoppingtest_ NEPGETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetstoppingtest_ nepgetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsettrackall_ NEPSETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsettrackall_ nepsettrackall #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgettrackall_ NEPGETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgettrackall_ nepgettrackall #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetrefine_ NEPSETREFINE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetrefine_ nepsetrefine #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetrefine_ NEPGETREFINE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetrefine_ nepgetrefine #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepsetfromoptions_(NEP nep, int *__ierr ){ *__ierr = NEPSetFromOptions( (NEP)PetscToPointer((nep) )); } PETSC_EXTERN void PETSC_STDCALL nepgettolerances_(NEP nep,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = NEPGetTolerances( (NEP)PetscToPointer((nep) ),tol,maxits); } PETSC_EXTERN void PETSC_STDCALL nepsettolerances_(NEP nep,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = NEPSetTolerances( (NEP)PetscToPointer((nep) ),*tol,*maxits); } PETSC_EXTERN void PETSC_STDCALL nepgetdimensions_(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = NEPGetDimensions( (NEP)PetscToPointer((nep) ),nev,ncv,mpd); } PETSC_EXTERN void PETSC_STDCALL nepsetdimensions_(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = NEPSetDimensions( (NEP)PetscToPointer((nep) ),*nev,*ncv,*mpd); } PETSC_EXTERN void PETSC_STDCALL nepsetwhicheigenpairs_(NEP nep,NEPWhich *which, int *__ierr ){ *__ierr = NEPSetWhichEigenpairs( (NEP)PetscToPointer((nep) ),*which); } PETSC_EXTERN void PETSC_STDCALL nepgetwhicheigenpairs_(NEP nep,NEPWhich *which, int *__ierr ){ *__ierr = NEPGetWhichEigenpairs( (NEP)PetscToPointer((nep) ),which); } PETSC_EXTERN void PETSC_STDCALL nepsetconvergencetest_(NEP nep,NEPConv *conv, int *__ierr ){ *__ierr = NEPSetConvergenceTest( (NEP)PetscToPointer((nep) ),*conv); } PETSC_EXTERN void PETSC_STDCALL nepgetconvergencetest_(NEP nep,NEPConv *conv, int *__ierr ){ *__ierr = NEPGetConvergenceTest( (NEP)PetscToPointer((nep) ),conv); } PETSC_EXTERN void PETSC_STDCALL nepsetstoppingtest_(NEP nep,NEPStop *stop, int *__ierr ){ *__ierr = NEPSetStoppingTest( (NEP)PetscToPointer((nep) ),*stop); } PETSC_EXTERN void PETSC_STDCALL nepgetstoppingtest_(NEP nep,NEPStop *stop, int *__ierr ){ *__ierr = NEPGetStoppingTest( (NEP)PetscToPointer((nep) ),stop); } PETSC_EXTERN void PETSC_STDCALL nepsettrackall_(NEP nep,PetscBool *trackall, int *__ierr ){ *__ierr = NEPSetTrackAll( (NEP)PetscToPointer((nep) ),*trackall); } PETSC_EXTERN void PETSC_STDCALL nepgettrackall_(NEP nep,PetscBool *trackall, int *__ierr ){ *__ierr = NEPGetTrackAll( (NEP)PetscToPointer((nep) ),trackall); } PETSC_EXTERN void PETSC_STDCALL nepsetrefine_(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme, int *__ierr ){ *__ierr = NEPSetRefine( (NEP)PetscToPointer((nep) ),*refine,*npart,*tol,*its,*scheme); } PETSC_EXTERN void PETSC_STDCALL nepgetrefine_(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme, int *__ierr ){ *__ierr = NEPGetRefine( (NEP)PetscToPointer((nep) ),refine,npart,tol,its,scheme); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/interface/ftn-auto/makefile0000644000175000017500000000046613107004621020737 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = nepoptsf.c nepviewf.c nepmonf.c nepsolvef.c nepbasicf.c nepsetupf.c nepdefaultf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcnep LOCDIR = src/nep/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/interface/ftn-auto/nepviewf.c0000644000175000017500000000437313107004621021227 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nepview.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepreasonviewfromoptions_ NEPREASONVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepreasonviewfromoptions_ nepreasonviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define neperrorviewfromoptions_ NEPERRORVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define neperrorviewfromoptions_ neperrorviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepvaluesviewfromoptions_ NEPVALUESVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepvaluesviewfromoptions_ nepvaluesviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepvectorsviewfromoptions_ NEPVECTORSVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepvectorsviewfromoptions_ nepvectorsviewfromoptions #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepreasonviewfromoptions_(NEP nep, int *__ierr ){ *__ierr = NEPReasonViewFromOptions( (NEP)PetscToPointer((nep) )); } PETSC_EXTERN void PETSC_STDCALL neperrorviewfromoptions_(NEP nep, int *__ierr ){ *__ierr = NEPErrorViewFromOptions( (NEP)PetscToPointer((nep) )); } PETSC_EXTERN void PETSC_STDCALL nepvaluesviewfromoptions_(NEP nep, int *__ierr ){ *__ierr = NEPValuesViewFromOptions( (NEP)PetscToPointer((nep) )); } PETSC_EXTERN void PETSC_STDCALL nepvectorsviewfromoptions_(NEP nep, int *__ierr ){ *__ierr = NEPVectorsViewFromOptions( (NEP)PetscToPointer((nep) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/interface/ftn-auto/nepmonf.c0000644000175000017500000000206513107004621021042 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nepmon.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepmonitorcancel_ NEPMONITORCANCEL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepmonitorcancel_ nepmonitorcancel #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepmonitorcancel_(NEP nep, int *__ierr ){ *__ierr = NEPMonitorCancel( (NEP)PetscToPointer((nep) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/interface/ftn-auto/nepsolvef.c0000644000175000017500000001320413107004621021376 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nepsolve.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsolve_ NEPSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsolve_ nepsolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepprojectoperator_ NEPPROJECTOPERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepprojectoperator_ nepprojectoperator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepapplyfunction_ NEPAPPLYFUNCTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepapplyfunction_ nepapplyfunction #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepapplyjacobian_ NEPAPPLYJACOBIAN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepapplyjacobian_ nepapplyjacobian #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetiterationnumber_ NEPGETITERATIONNUMBER #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetiterationnumber_ nepgetiterationnumber #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetconverged_ NEPGETCONVERGED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetconverged_ nepgetconverged #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetconvergedreason_ NEPGETCONVERGEDREASON #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetconvergedreason_ nepgetconvergedreason #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgeteigenpair_ NEPGETEIGENPAIR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgeteigenpair_ nepgeteigenpair #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgeterrorestimate_ NEPGETERRORESTIMATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgeterrorestimate_ nepgeterrorestimate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcomputeerror_ NEPCOMPUTEERROR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcomputeerror_ nepcomputeerror #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcomputefunction_ NEPCOMPUTEFUNCTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcomputefunction_ nepcomputefunction #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcomputejacobian_ NEPCOMPUTEJACOBIAN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcomputejacobian_ nepcomputejacobian #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepsolve_(NEP nep, int *__ierr ){ *__ierr = NEPSolve( (NEP)PetscToPointer((nep) )); } PETSC_EXTERN void PETSC_STDCALL nepprojectoperator_(NEP nep,PetscInt *j0,PetscInt *j1, int *__ierr ){ *__ierr = NEPProjectOperator( (NEP)PetscToPointer((nep) ),*j0,*j1); } PETSC_EXTERN void PETSC_STDCALL nepapplyfunction_(NEP nep,PetscScalar *lambda,Vec x,Vec v,Vec y,Mat A,Mat B, int *__ierr ){ *__ierr = NEPApplyFunction( (NEP)PetscToPointer((nep) ),*lambda, (Vec)PetscToPointer((x) ), (Vec)PetscToPointer((v) ), (Vec)PetscToPointer((y) ), (Mat)PetscToPointer((A) ), (Mat)PetscToPointer((B) )); } PETSC_EXTERN void PETSC_STDCALL nepapplyjacobian_(NEP nep,PetscScalar *lambda,Vec x,Vec v,Vec y,Mat A, int *__ierr ){ *__ierr = NEPApplyJacobian( (NEP)PetscToPointer((nep) ),*lambda, (Vec)PetscToPointer((x) ), (Vec)PetscToPointer((v) ), (Vec)PetscToPointer((y) ), (Mat)PetscToPointer((A) )); } PETSC_EXTERN void PETSC_STDCALL nepgetiterationnumber_(NEP nep,PetscInt *its, int *__ierr ){ *__ierr = NEPGetIterationNumber( (NEP)PetscToPointer((nep) ),its); } PETSC_EXTERN void PETSC_STDCALL nepgetconverged_(NEP nep,PetscInt *nconv, int *__ierr ){ *__ierr = NEPGetConverged( (NEP)PetscToPointer((nep) ),nconv); } PETSC_EXTERN void PETSC_STDCALL nepgetconvergedreason_(NEP nep,NEPConvergedReason *reason, int *__ierr ){ *__ierr = NEPGetConvergedReason( (NEP)PetscToPointer((nep) ),reason); } PETSC_EXTERN void PETSC_STDCALL nepgeteigenpair_(NEP nep,PetscInt *i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi, int *__ierr ){ *__ierr = NEPGetEigenpair( (NEP)PetscToPointer((nep) ),*i,eigr,eigi, (Vec)PetscToPointer((Vr) ), (Vec)PetscToPointer((Vi) )); } PETSC_EXTERN void PETSC_STDCALL nepgeterrorestimate_(NEP nep,PetscInt *i,PetscReal *errest, int *__ierr ){ *__ierr = NEPGetErrorEstimate( (NEP)PetscToPointer((nep) ),*i,errest); } PETSC_EXTERN void PETSC_STDCALL nepcomputeerror_(NEP nep,PetscInt *i,NEPErrorType *type,PetscReal *error, int *__ierr ){ *__ierr = NEPComputeError( (NEP)PetscToPointer((nep) ),*i,*type,error); } PETSC_EXTERN void PETSC_STDCALL nepcomputefunction_(NEP nep,PetscScalar *lambda,Mat A,Mat B, int *__ierr ){ *__ierr = NEPComputeFunction( (NEP)PetscToPointer((nep) ),*lambda, (Mat)PetscToPointer((A) ), (Mat)PetscToPointer((B) )); } PETSC_EXTERN void PETSC_STDCALL nepcomputejacobian_(NEP nep,PetscScalar *lambda,Mat A, int *__ierr ){ *__ierr = NEPComputeJacobian( (NEP)PetscToPointer((nep) ),*lambda, (Mat)PetscToPointer((A) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/interface/ftn-auto/nepbasicf.c0000644000175000017500000001331413107004621021331 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nepbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcreate_ NEPCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcreate_ nepcreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepreset_ NEPRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepreset_ nepreset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepdestroy_ NEPDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepdestroy_ nepdestroy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetbv_ NEPSETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetbv_ nepsetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetbv_ NEPGETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetbv_ nepgetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetrg_ NEPSETRG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetrg_ nepsetrg #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetrg_ NEPGETRG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetrg_ nepgetrg #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetds_ NEPSETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetds_ nepsetds #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetds_ NEPGETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetds_ nepgetds #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define neprefinegetksp_ NEPREFINEGETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define neprefinegetksp_ neprefinegetksp #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsettarget_ NEPSETTARGET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsettarget_ nepsettarget #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgettarget_ NEPGETTARGET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgettarget_ nepgettarget #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetsplitoperator_ NEPSETSPLITOPERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetsplitoperator_ nepsetsplitoperator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetsplitoperatorterm_ NEPGETSPLITOPERATORTERM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetsplitoperatorterm_ nepgetsplitoperatorterm #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepgetsplitoperatorinfo_ NEPGETSPLITOPERATORINFO #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepgetsplitoperatorinfo_ nepgetsplitoperatorinfo #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepcreate_(MPI_Fint * comm,NEP *outnep, int *__ierr ){ *__ierr = NEPCreate( MPI_Comm_f2c(*(comm)),outnep); } PETSC_EXTERN void PETSC_STDCALL nepreset_(NEP nep, int *__ierr ){ *__ierr = NEPReset( (NEP)PetscToPointer((nep) )); } PETSC_EXTERN void PETSC_STDCALL nepdestroy_(NEP *nep, int *__ierr ){ *__ierr = NEPDestroy(nep); } PETSC_EXTERN void PETSC_STDCALL nepsetbv_(NEP nep,BV bv, int *__ierr ){ *__ierr = NEPSetBV( (NEP)PetscToPointer((nep) ), (BV)PetscToPointer((bv) )); } PETSC_EXTERN void PETSC_STDCALL nepgetbv_(NEP nep,BV *bv, int *__ierr ){ *__ierr = NEPGetBV( (NEP)PetscToPointer((nep) ),bv); } PETSC_EXTERN void PETSC_STDCALL nepsetrg_(NEP nep,RG rg, int *__ierr ){ *__ierr = NEPSetRG( (NEP)PetscToPointer((nep) ), (RG)PetscToPointer((rg) )); } PETSC_EXTERN void PETSC_STDCALL nepgetrg_(NEP nep,RG *rg, int *__ierr ){ *__ierr = NEPGetRG( (NEP)PetscToPointer((nep) ),rg); } PETSC_EXTERN void PETSC_STDCALL nepsetds_(NEP nep,DS ds, int *__ierr ){ *__ierr = NEPSetDS( (NEP)PetscToPointer((nep) ), (DS)PetscToPointer((ds) )); } PETSC_EXTERN void PETSC_STDCALL nepgetds_(NEP nep,DS *ds, int *__ierr ){ *__ierr = NEPGetDS( (NEP)PetscToPointer((nep) ),ds); } PETSC_EXTERN void PETSC_STDCALL neprefinegetksp_(NEP nep,KSP *ksp, int *__ierr ){ *__ierr = NEPRefineGetKSP( (NEP)PetscToPointer((nep) ),ksp); } PETSC_EXTERN void PETSC_STDCALL nepsettarget_(NEP nep,PetscScalar *target, int *__ierr ){ *__ierr = NEPSetTarget( (NEP)PetscToPointer((nep) ),*target); } PETSC_EXTERN void PETSC_STDCALL nepgettarget_(NEP nep,PetscScalar* target, int *__ierr ){ *__ierr = NEPGetTarget( (NEP)PetscToPointer((nep) ),target); } PETSC_EXTERN void PETSC_STDCALL nepsetsplitoperator_(NEP nep,PetscInt *n,Mat A[],FN f[],MatStructure *str, int *__ierr ){ *__ierr = NEPSetSplitOperator( (NEP)PetscToPointer((nep) ),*n,A,f,*str); } PETSC_EXTERN void PETSC_STDCALL nepgetsplitoperatorterm_(NEP nep,PetscInt *k,Mat *A,FN *f, int *__ierr ){ *__ierr = NEPGetSplitOperatorTerm( (NEP)PetscToPointer((nep) ),*k,A,f); } PETSC_EXTERN void PETSC_STDCALL nepgetsplitoperatorinfo_(NEP nep,PetscInt *n,MatStructure *str, int *__ierr ){ *__ierr = NEPGetSplitOperatorInfo( (NEP)PetscToPointer((nep) ),n,str); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/interface/ftn-auto/nepsetupf.c0000644000175000017500000000340413107004621021407 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nepsetup.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetup_ NEPSETUP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetup_ nepsetup #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetinitialspace_ NEPSETINITIALSPACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetinitialspace_ nepsetinitialspace #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepallocatesolution_ NEPALLOCATESOLUTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepallocatesolution_ nepallocatesolution #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepsetup_(NEP nep, int *__ierr ){ *__ierr = NEPSetUp( (NEP)PetscToPointer((nep) )); } PETSC_EXTERN void PETSC_STDCALL nepsetinitialspace_(NEP nep,PetscInt *n,Vec *is, int *__ierr ){ *__ierr = NEPSetInitialSpace( (NEP)PetscToPointer((nep) ),*n,is); } PETSC_EXTERN void PETSC_STDCALL nepallocatesolution_(NEP nep,PetscInt *extra, int *__ierr ){ *__ierr = NEPAllocateSolution( (NEP)PetscToPointer((nep) ),*extra); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/interface/ftn-auto/nepdefaultf.c0000644000175000017500000000207613107004621021677 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nepdefault.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepsetworkvecs_ NEPSETWORKVECS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepsetworkvecs_ nepsetworkvecs #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepsetworkvecs_(NEP nep,PetscInt *nw, int *__ierr ){ *__ierr = NEPSetWorkVecs( (NEP)PetscToPointer((nep) ),*nw); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/interface/nepview.c0000644000175000017500000006571613107004621017334 0ustar jromanjroman/* The NEP routines related to various viewers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "NEPView" /*@C NEPView - Prints the NEP data structure. Collective on NEP Input Parameters: + nep - the nonlinear eigenproblem solver context - viewer - optional visualization context Options Database Key: . -nep_view - Calls NEPView() at end of NEPSolve() Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner .seealso: PetscViewerASCIIOpen() @*/ PetscErrorCode NEPView(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; char str[50]; PetscInt i; PetscBool isascii,istrivial,nods; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(nep,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)nep,viewer);CHKERRQ(ierr); if (nep->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*nep->ops->view)(nep,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } if (nep->fui) { switch (nep->fui) { case NEP_USER_INTERFACE_CALLBACK: ierr = PetscViewerASCIIPrintf(viewer," nonlinear operator from user callbacks\n");CHKERRQ(ierr); break; case NEP_USER_INTERFACE_SPLIT: ierr = PetscViewerASCIIPrintf(viewer," nonlinear operator in split form\n");CHKERRQ(ierr); break; case NEP_USER_INTERFACE_DERIVATIVES: ierr = PetscViewerASCIIPrintf(viewer," nonlinear operator from user callbacks for the successive derivatives\n");CHKERRQ(ierr); break; } } else { ierr = PetscViewerASCIIPrintf(viewer," nonlinear operator not specified yet\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," selected portion of the spectrum: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,nep->target,PETSC_FALSE);CHKERRQ(ierr); if (!nep->which) { ierr = PetscViewerASCIIPrintf(viewer,"not yet set\n");CHKERRQ(ierr); } else switch (nep->which) { case NEP_WHICH_USER: ierr = PetscViewerASCIIPrintf(viewer,"user defined\n");CHKERRQ(ierr); break; case NEP_TARGET_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (in magnitude)\n",str);CHKERRQ(ierr); break; case NEP_TARGET_REAL: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the real axis)\n",str);CHKERRQ(ierr); break; case NEP_TARGET_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the imaginary axis)\n",str);CHKERRQ(ierr); break; case NEP_LARGEST_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");CHKERRQ(ierr); break; case NEP_SMALLEST_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");CHKERRQ(ierr); break; case NEP_LARGEST_REAL: ierr = PetscViewerASCIIPrintf(viewer,"largest real parts\n");CHKERRQ(ierr); break; case NEP_SMALLEST_REAL: ierr = PetscViewerASCIIPrintf(viewer,"smallest real parts\n");CHKERRQ(ierr); break; case NEP_LARGEST_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");CHKERRQ(ierr); break; case NEP_SMALLEST_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");CHKERRQ(ierr); break; case NEP_ALL: ierr = PetscViewerASCIIPrintf(viewer,"all eigenvalues in the region\n");CHKERRQ(ierr); break; default: SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of nep->which"); } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of eigenvalues (nev): %D\n",nep->nev);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of column vectors (ncv): %D\n",nep->ncv);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum dimension of projected problem (mpd): %D\n",nep->mpd);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum number of iterations: %D\n",nep->max_it);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," tolerance: %g\n",(double)nep->tol);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," convergence test: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); switch (nep->conv) { case NEP_CONV_ABS: ierr = PetscViewerASCIIPrintf(viewer,"absolute\n");CHKERRQ(ierr);break; case NEP_CONV_REL: ierr = PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue\n");CHKERRQ(ierr);break; case NEP_CONV_NORM: ierr = PetscViewerASCIIPrintf(viewer,"relative to the matrix norms\n");CHKERRQ(ierr); if (nep->nrma) { ierr = PetscViewerASCIIPrintf(viewer," computed matrix norms: %g",(double)nep->nrma[0]);CHKERRQ(ierr); for (i=1;int;i++) { ierr = PetscViewerASCIIPrintf(viewer,", %g",(double)nep->nrma[i]);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } break; case NEP_CONV_USER: ierr = PetscViewerASCIIPrintf(viewer,"user-defined\n");CHKERRQ(ierr);break; } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); if (nep->refine) { ierr = PetscViewerASCIIPrintf(viewer," iterative refinement: %s, with %s scheme\n",NEPRefineTypes[nep->refine],NEPRefineSchemes[nep->scheme]);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," refinement stopping criterion: tol=%g, its=%D\n",(double)nep->rtol,nep->rits);CHKERRQ(ierr); if (nep->npart>1) { ierr = PetscViewerASCIIPrintf(viewer," splitting communicator in %D partitions for refinement\n",nep->npart);CHKERRQ(ierr); } } if (nep->nini) { ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided initial space: %D\n",PetscAbs(nep->nini));CHKERRQ(ierr); } } else { if (nep->ops->view) { ierr = (*nep->ops->view)(nep,viewer);CHKERRQ(ierr); } } ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);CHKERRQ(ierr); if (!nep->V) { ierr = NEPGetBV(nep,&nep->V);CHKERRQ(ierr); } ierr = BVView(nep->V,viewer);CHKERRQ(ierr); if (!nep->rg) { ierr = NEPGetRG(nep,&nep->rg);CHKERRQ(ierr); } ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) { ierr = RGView(nep->rg,viewer);CHKERRQ(ierr); } ierr = PetscObjectTypeCompareAny((PetscObject)nep,&nods,NEPRII,NEPSLP,NEPINTERPOL,"");CHKERRQ(ierr); if (!nods) { if (!nep->ds) { ierr = NEPGetDS(nep,&nep->ds);CHKERRQ(ierr); } ierr = DSView(nep->ds,viewer);CHKERRQ(ierr); } ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReasonView" /*@C NEPReasonView - Displays the reason a NEP solve converged or diverged. Collective on NEP Parameter: + nep - the nonlinear eigensolver context - viewer - the viewer to display the reason Options Database Keys: . -nep_converged_reason - print reason for convergence, and number of iterations Level: intermediate .seealso: NEPSetConvergenceTest(), NEPSetTolerances(), NEPGetIterationNumber() @*/ PetscErrorCode NEPReasonView(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isAscii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);CHKERRQ(ierr); if (isAscii) { ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);CHKERRQ(ierr); if (nep->reason > 0) { ierr = PetscViewerASCIIPrintf(viewer,"%s Nonlinear eigensolve converged (%D eigenpair%s) due to %s; iterations %D\n",((PetscObject)nep)->prefix?((PetscObject)nep)->prefix:"",nep->nconv,(nep->nconv>1)?"s":"",NEPConvergedReasons[nep->reason],nep->its);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%s Nonlinear eigensolve did not converge due to %s; iterations %D\n",((PetscObject)nep)->prefix?((PetscObject)nep)->prefix:"",NEPConvergedReasons[nep->reason],nep->its);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)nep)->tablevel);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReasonViewFromOptions" /*@ NEPReasonViewFromOptions - Processes command line options to determine if/how the NEP converged reason is to be viewed. Collective on NEP Input Parameters: . nep - the nonlinear eigensolver context Level: developer @*/ PetscErrorCode NEPReasonViewFromOptions(NEP nep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_converged_reason",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = NEPReasonView(nep,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPErrorView_ASCII" static PetscErrorCode NEPErrorView_ASCII(NEP nep,NEPErrorType etype,PetscViewer viewer) { PetscBool errok; PetscReal error,re,im; PetscScalar kr,ki; PetscInt i,j,nvals; PetscErrorCode ierr; PetscFunctionBegin; if (nep->which!=NEP_ALL && nep->nconvnev) { ierr = PetscViewerASCIIPrintf(viewer," Problem: less than %D eigenvalues converged\n\n",nep->nev);CHKERRQ(ierr); PetscFunctionReturn(0); } errok = PETSC_TRUE; nvals = (nep->which==NEP_ALL)? nep->nconv: nep->nev; for (i=0;itol)? PETSC_TRUE: PETSC_FALSE; } if (!errok) { ierr = PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",nvals);CHKERRQ(ierr); PetscFunctionReturn(0); } if (nep->which==NEP_ALL) { ierr = PetscViewerASCIIPrintf(viewer," Found %D eigenvalues, all of them computed up to the required tolerance:",nvals);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," All requested eigenvalues computed up to the required tolerance:");CHKERRQ(ierr); } for (i=0;i<=(nvals-1)/8;i++) { ierr = PetscViewerASCIIPrintf(viewer,"\n ");CHKERRQ(ierr); for (j=0;jnconv) PetscFunctionReturn(0); switch (etype) { case NEP_ERROR_ABSOLUTE: ierr = PetscSNPrintf(ex,EXLEN," ||T(k)x||");CHKERRQ(ierr); break; case NEP_ERROR_RELATIVE: ierr = PetscSNPrintf(ex,EXLEN," ||T(k)x||/||kx||");CHKERRQ(ierr); break; case NEP_ERROR_BACKWARD: ierr = PetscSNPrintf(ex,EXLEN," eta(x,k)");CHKERRQ(ierr); break; } ierr = PetscViewerASCIIPrintf(viewer,"%s k %s\n%s",sep,ex,sep);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = NEPGetEigenpair(nep,i,&kr,&ki,NULL,NULL);CHKERRQ(ierr); ierr = NEPComputeError(nep,i,etype,&error);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(kr); im = PetscImaginaryPart(kr); #else re = kr; im = ki; #endif if (im!=0.0) { ierr = PetscViewerASCIIPrintf(viewer," % 9f%+9fi %12g\n",(double)re,(double)im,(double)error);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," % 12f %12g\n",(double)re,(double)error);CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,sep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPErrorView_MATLAB" static PetscErrorCode NEPErrorView_MATLAB(NEP nep,NEPErrorType etype,PetscViewer viewer) { PetscErrorCode ierr; PetscReal error; PetscInt i; const char *name; PetscFunctionBegin; ierr = PetscObjectGetName((PetscObject)nep,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = NEPComputeError(nep,i,etype,&error);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPErrorView" /*@C NEPErrorView - Displays the errors associated with the computed solution (as well as the eigenvalues). Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . etype - error type - viewer - optional visualization context Options Database Key: + -nep_error_absolute - print absolute errors of each eigenpair . -nep_error_relative - print relative errors of each eigenpair - -nep_error_backward - print backward errors of each eigenpair Notes: By default, this function checks the error of all eigenpairs and prints the eigenvalues if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with eigenvalues and corresponding errors is printed. Level: intermediate .seealso: NEPSolve(), NEPValuesView(), NEPVectorsView() @*/ PetscErrorCode NEPErrorView(NEP nep,NEPErrorType etype,PetscViewer viewer) { PetscBool isascii; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(nep,1,viewer,2); NEPCheckSolved(nep,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (!isascii) PetscFunctionReturn(0); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: ierr = NEPErrorView_ASCII(nep,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = NEPErrorView_DETAIL(nep,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = NEPErrorView_MATLAB(nep,etype,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(nep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPErrorViewFromOptions" /*@ NEPErrorViewFromOptions - Processes command line options to determine if/how the errors of the computed solution are to be viewed. Collective on NEP Input Parameters: . nep - the nonlinear eigensolver context Level: developer @*/ PetscErrorCode NEPErrorViewFromOptions(NEP nep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_error_absolute",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = NEPErrorView(nep,NEP_ERROR_ABSOLUTE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_error_relative",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = NEPErrorView(nep,NEP_ERROR_RELATIVE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_error_backward",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = NEPErrorView(nep,NEP_ERROR_BACKWARD,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPValuesView_DRAW" static PetscErrorCode NEPValuesView_DRAW(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; PetscDraw draw; PetscDrawSP drawsp; PetscReal re,im; PetscInt i,k; PetscFunctionBegin; if (!nep->nconv) PetscFunctionReturn(0); ierr = PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed Eigenvalues",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);CHKERRQ(ierr); ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); ierr = PetscDrawSPCreate(draw,1,&drawsp);CHKERRQ(ierr); for (i=0;inconv;i++) { k = nep->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(nep->eigr[k]); im = PetscImaginaryPart(nep->eigr[k]); #else re = nep->eigr[k]; im = nep->eigi[k]; #endif ierr = PetscDrawSPAddPoint(drawsp,&re,&im);CHKERRQ(ierr); } ierr = PetscDrawSPDraw(drawsp,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscDrawSPSave(drawsp);CHKERRQ(ierr); ierr = PetscDrawSPDestroy(&drawsp);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPValuesView_ASCII" static PetscErrorCode NEPValuesView_ASCII(NEP nep,PetscViewer viewer) { PetscReal re,im; PetscInt i,k; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerASCIIPrintf(viewer,"Eigenvalues = \n");CHKERRQ(ierr); for (i=0;inconv;i++) { k = nep->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(nep->eigr[k]); im = PetscImaginaryPart(nep->eigr[k]); #else re = nep->eigr[k]; im = nep->eigi[k]; #endif if (PetscAbs(re)/PetscAbs(im)nconv;i++) { k = nep->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(nep->eigr[k]); im = PetscImaginaryPart(nep->eigr[k]); #else re = nep->eigr[k]; im = nep->eigi[k]; #endif if (im!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%18.16e%+18.16ei\n",(double)re,(double)im);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)re);CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPValuesView" /*@C NEPValuesView - Displays the computed eigenvalues in a viewer. Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - viewer - the viewer Options Database Key: . -nep_view_values - print computed eigenvalues Level: intermediate .seealso: NEPSolve(), NEPVectorsView(), NEPErrorView() @*/ PetscErrorCode NEPValuesView(NEP nep,PetscViewer viewer) { PetscBool isascii,isdraw; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(nep,1,viewer,2); NEPCheckSolved(nep,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isdraw) { ierr = NEPValuesView_DRAW(nep,viewer);CHKERRQ(ierr); } else if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = NEPValuesView_ASCII(nep,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = NEPValuesView_MATLAB(nep,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(nep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPValuesViewFromOptions" /*@ NEPValuesViewFromOptions - Processes command line options to determine if/how the computed eigenvalues are to be viewed. Collective on NEP Input Parameters: . nep - the nonlinear eigensolver context Level: developer @*/ PetscErrorCode NEPValuesViewFromOptions(NEP nep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_view_values",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = NEPValuesView(nep,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPVectorsView" /*@C NEPVectorsView - Outputs computed eigenvectors to a viewer. Collective on NEP Parameter: + nep - the nonlinear eigensolver context - viewer - the viewer Options Database Keys: . -nep_view_vectors - output eigenvectors. Note: If PETSc was configured with real scalars, complex conjugate eigenvectors will be viewed as two separate real vectors, one containing the real part and another one containing the imaginary part. Level: intermediate .seealso: NEPSolve(), NEPValuesView(), NEPErrorView() @*/ PetscErrorCode NEPVectorsView(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; PetscInt i,k; Vec x; #define NMLEN 30 char vname[NMLEN]; const char *ename; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(nep,1,viewer,2); NEPCheckSolved(nep,1); if (nep->nconv) { ierr = PetscObjectGetName((PetscObject)nep,&ename);CHKERRQ(ierr); ierr = NEPComputeVectors(nep);CHKERRQ(ierr); for (i=0;inconv;i++) { k = nep->perm[i]; ierr = PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);CHKERRQ(ierr); ierr = BVGetColumn(nep->V,k,&x);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)x,vname);CHKERRQ(ierr); ierr = VecView(x,viewer);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,k,&x);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPVectorsViewFromOptions" /*@ NEPVectorsViewFromOptions - Processes command line options to determine if/how the computed eigenvectors are to be viewed. Collective on NEP Input Parameters: . nep - the nonlinear eigensolver context Level: developer @*/ PetscErrorCode NEPVectorsViewFromOptions(NEP nep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg = PETSC_FALSE; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_view_vectors",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = NEPVectorsView(nep,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/nepsetup.c.html0000644000175000017500000007041013107004621020450 0ustar jromanjroman

Actual source code: nepsetup.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       NEP routines related to problem setup.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/nepimpl.h>       /*I "slepcnep.h" I*/

 28: /*@
 29:    NEPSetUp - Sets up all the internal data structures necessary for the
 30:    execution of the NEP solver.

 32:    Collective on NEP

 34:    Input Parameter:
 35: .  nep   - solver context

 37:    Notes:
 38:    This function need not be called explicitly in most cases, since NEPSolve()
 39:    calls it. It can be useful when one wants to measure the set-up time
 40:    separately from the solve time.

 42:    Level: developer

 44: .seealso: NEPCreate(), NEPSolve(), NEPDestroy()
 45: @*/
 46: PetscErrorCode NEPSetUp(NEP nep)
 47: {
 49:   PetscInt       k;
 50:   SlepcSC        sc;
 51:   Mat            T;
 52:   PetscBool      flg;
 53:   KSP            ksp;
 54:   PC             pc;
 55:   PetscMPIInt    size;
 56:   const MatSolverPackage stype;

 60:   NEPCheckProblem(nep,1);
 61:   if (nep->state) return(0);
 62:   PetscLogEventBegin(NEP_SetUp,nep,0,0,0);

 64:   /* reset the convergence flag from the previous solves */
 65:   nep->reason = NEP_CONVERGED_ITERATING;

 67:   /* set default solver type (NEPSetFromOptions was not called) */
 68:   if (!((PetscObject)nep)->type_name) {
 69:     NEPSetType(nep,NEPRII);
 70:   }
 71:   if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
 72:   DSReset(nep->ds);
 73:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
 74:   if (!((PetscObject)nep->rg)->type_name) {
 75:     RGSetType(nep->rg,RGINTERVAL);
 76:   }

 78:   /* set problem dimensions */
 79:   switch (nep->fui) {
 80:   case NEP_USER_INTERFACE_CALLBACK:
 81:     NEPGetFunction(nep,&T,NULL,NULL,NULL);
 82:     MatGetSize(T,&nep->n,NULL);
 83:     MatGetLocalSize(T,&nep->nloc,NULL);
 84:     break;
 85:   case NEP_USER_INTERFACE_SPLIT:
 86:     MatDuplicate(nep->A[0],MAT_DO_NOT_COPY_VALUES,&nep->function);
 87:     MatDuplicate(nep->A[0],MAT_DO_NOT_COPY_VALUES,&nep->jacobian);
 88:     PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->function);
 89:     PetscLogObjectParent((PetscObject)nep,(PetscObject)nep->jacobian);
 90:     MatGetSize(nep->A[0],&nep->n,NULL);
 91:     MatGetLocalSize(nep->A[0],&nep->nloc,NULL);
 92:     break;
 93:   case NEP_USER_INTERFACE_DERIVATIVES:
 94:     NEPGetDerivatives(nep,&T,NULL,NULL);
 95:     MatGetSize(T,&nep->n,NULL);
 96:     MatGetLocalSize(T,&nep->nloc,NULL);
 97:     break;
 98:   }

100:   /* check consistency of refinement options */
101:   if (nep->refine) {
102:     if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Iterative refinement only implemented in split form");
103:     if (!nep->scheme) {  /* set default scheme */
104:       NEPRefineGetKSP(nep,&ksp);
105:       KSPGetPC(ksp,&pc);
106:       PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);
107:       if (flg) {
108:         PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");
109:       }
110:       nep->scheme = flg? NEP_REFINE_SCHEME_MBE: NEP_REFINE_SCHEME_SCHUR;
111:     }
112:     if (nep->scheme==NEP_REFINE_SCHEME_MBE) {
113:       NEPRefineGetKSP(nep,&ksp);
114:       KSPGetPC(ksp,&pc);
115:       PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);
116:       if (flg) {
117:         PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");
118:       }
119:       if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The MBE scheme for refinement requires a direct solver in KSP");
120:       MPI_Comm_size(PetscObjectComm((PetscObject)pc),&size);
121:       if (size>1) {   /* currently selected PC is a factorization */
122:         PCFactorGetMatSolverPackage(pc,&stype);
123:         PetscStrcmp(stype,MATSOLVERPETSC,&flg);
124:         if (flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"For Newton refinement, you chose to solve linear systems with a factorization, but in parallel runs you need to select an external package");
125:       }
126:     }
127:     if (nep->scheme==NEP_REFINE_SCHEME_SCHUR) {
128:       if (nep->nt<=2) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The Schur scheme for refinement is only available for problems defined with more than 2 matrices");
129:       if (nep->npart>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The Schur scheme for refinement does not support subcommunicators"); 
130:     }
131:   }
132:   /* call specific solver setup */
133:   (*nep->ops->setup)(nep);

135:   /* by default, compute eigenvalues close to target */
136:   /* nep->target should contain the initial guess for the eigenvalue */
137:   if (!nep->which) nep->which = NEP_TARGET_MAGNITUDE;

139:   /* set tolerance if not yet set */
140:   if (nep->tol==PETSC_DEFAULT) nep->tol = SLEPC_DEFAULT_TOL;
141:   if (nep->refine) {
142:     if (nep->rtol==PETSC_DEFAULT) nep->rtol = PetscMax(nep->tol/1000,PETSC_MACHINE_EPSILON);
143:     if (nep->rits==PETSC_DEFAULT) nep->rits = (nep->refine==NEP_REFINE_SIMPLE)? 10: 1;
144:   }

146:   /* fill sorting criterion context */
147:   switch (nep->which) {
148:     case NEP_LARGEST_MAGNITUDE:
149:       nep->sc->comparison    = SlepcCompareLargestMagnitude;
150:       nep->sc->comparisonctx = NULL;
151:       break;
152:     case NEP_SMALLEST_MAGNITUDE:
153:       nep->sc->comparison    = SlepcCompareSmallestMagnitude;
154:       nep->sc->comparisonctx = NULL;
155:       break;
156:     case NEP_LARGEST_REAL:
157:       nep->sc->comparison    = SlepcCompareLargestReal;
158:       nep->sc->comparisonctx = NULL;
159:       break;
160:     case NEP_SMALLEST_REAL:
161:       nep->sc->comparison    = SlepcCompareSmallestReal;
162:       nep->sc->comparisonctx = NULL;
163:       break;
164:     case NEP_LARGEST_IMAGINARY:
165:       nep->sc->comparison    = SlepcCompareLargestImaginary;
166:       nep->sc->comparisonctx = NULL;
167:       break;
168:     case NEP_SMALLEST_IMAGINARY:
169:       nep->sc->comparison    = SlepcCompareSmallestImaginary;
170:       nep->sc->comparisonctx = NULL;
171:       break;
172:     case NEP_TARGET_MAGNITUDE:
173:       nep->sc->comparison    = SlepcCompareTargetMagnitude;
174:       nep->sc->comparisonctx = &nep->target;
175:       break;
176:     case NEP_TARGET_REAL:
177:       nep->sc->comparison    = SlepcCompareTargetReal;
178:       nep->sc->comparisonctx = &nep->target;
179:       break;
180:     case NEP_TARGET_IMAGINARY:
181:       nep->sc->comparison    = SlepcCompareTargetImaginary;
182:       nep->sc->comparisonctx = &nep->target;
183:       break;
184:     case NEP_ALL:
185:       nep->sc->comparison    = SlepcCompareSmallestReal;
186:       nep->sc->comparisonctx = NULL;
187:       break;
188:     case NEP_WHICH_USER:
189:       break;
190:   }

192:   nep->sc->map    = NULL;
193:   nep->sc->mapobj = NULL;

195:   /* fill sorting criterion for DS */
196:   DSGetSlepcSC(nep->ds,&sc);
197:   sc->comparison    = nep->sc->comparison;
198:   sc->comparisonctx = nep->sc->comparisonctx;
199:   PetscObjectTypeCompare((PetscObject)nep,NEPNLEIGS,&flg);
200:   if (!flg) {
201:     sc->map    = NULL;
202:     sc->mapobj = NULL;
203:   }
204:   if (nep->ncv > nep->n) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"ncv must be the problem size at most");
205:   if (nep->nev > nep->ncv) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"nev bigger than ncv");

207:   /* process initial vectors */
208:   if (nep->nini<0) {
209:     k = -nep->nini;
210:     if (k>nep->ncv) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The number of initial vectors is larger than ncv");
211:     BVInsertVecs(nep->V,0,&k,nep->IS,PETSC_TRUE);
212:     SlepcBasisDestroy_Private(&nep->nini,&nep->IS);
213:     nep->nini = k;
214:   }
215:   PetscLogEventEnd(NEP_SetUp,nep,0,0,0);
216:   nep->state = NEP_STATE_SETUP;
217:   return(0);
218: }

222: /*@
223:    NEPSetInitialSpace - Specify a basis of vectors that constitute the initial
224:    space, that is, the subspace from which the solver starts to iterate.

226:    Collective on NEP and Vec

228:    Input Parameter:
229: +  nep   - the nonlinear eigensolver context
230: .  n     - number of vectors
231: -  is    - set of basis vectors of the initial space

233:    Notes:
234:    Some solvers start to iterate on a single vector (initial vector). In that case,
235:    the other vectors are ignored.

237:    These vectors do not persist from one NEPSolve() call to the other, so the
238:    initial space should be set every time.

240:    The vectors do not need to be mutually orthonormal, since they are explicitly
241:    orthonormalized internally.

243:    Common usage of this function is when the user can provide a rough approximation
244:    of the wanted eigenspace. Then, convergence may be faster.

246:    Level: intermediate
247: @*/
248: PetscErrorCode NEPSetInitialSpace(NEP nep,PetscInt n,Vec *is)
249: {

255:   if (n<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative");
256:   SlepcBasisReference_Private(n,is,&nep->nini,&nep->IS);
257:   if (n>0) nep->state = NEP_STATE_INITIAL;
258:   return(0);
259: }

263: /*
264:   NEPSetDimensions_Default - Set reasonable values for ncv, mpd if not set
265:   by the user. This is called at setup.
266:  */
267: PetscErrorCode NEPSetDimensions_Default(NEP nep,PetscInt nev,PetscInt *ncv,PetscInt *mpd)
268: {
270:   if (*ncv) { /* ncv set */
271:     if (*ncv<nev) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must be at least nev");
272:   } else if (*mpd) { /* mpd set */
273:     *ncv = PetscMin(nep->n,nev+(*mpd));
274:   } else { /* neither set: defaults depend on nev being small or large */
275:     if (nev<500) *ncv = PetscMin(nep->n,PetscMax(2*nev,nev+15));
276:     else {
277:       *mpd = 500;
278:       *ncv = PetscMin(nep->n,nev+(*mpd));
279:     }
280:   }
281:   if (!*mpd) *mpd = *ncv;
282:   return(0);
283: }

287: /*@
288:    NEPAllocateSolution - Allocate memory storage for common variables such
289:    as eigenvalues and eigenvectors.

291:    Collective on NEP

293:    Input Parameters:
294: +  nep   - eigensolver context
295: -  extra - number of additional positions, used for methods that require a
296:            working basis slightly larger than ncv

298:    Developers Note:
299:    This is PETSC_EXTERN because it may be required by user plugin NEP
300:    implementations.

302:    Level: developer
303: @*/
304: PetscErrorCode NEPAllocateSolution(NEP nep,PetscInt extra)
305: {
307:   PetscInt       oldsize,newc,requested;
308:   PetscLogDouble cnt;
309:   Mat            T;
310:   Vec            t;

313:   requested = nep->ncv + extra;

315:   /* oldsize is zero if this is the first time setup is called */
316:   BVGetSizes(nep->V,NULL,NULL,&oldsize);
317:   newc = PetscMax(0,requested-oldsize);

319:   /* allocate space for eigenvalues and friends */
320:   if (requested != oldsize || !nep->eigr) {
321:     if (oldsize) {
322:       PetscFree4(nep->eigr,nep->eigi,nep->errest,nep->perm);
323:     }
324:     PetscMalloc4(requested,&nep->eigr,requested,&nep->eigi,requested,&nep->errest,requested,&nep->perm);
325:     cnt = newc*sizeof(PetscScalar) + newc*sizeof(PetscReal) + newc*sizeof(PetscInt);
326:     PetscLogObjectMemory((PetscObject)nep,cnt);
327:   }

329:   /* allocate V */
330:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
331:   if (!oldsize) {
332:     if (!((PetscObject)(nep->V))->type_name) {
333:       BVSetType(nep->V,BVSVEC);
334:     }
335:     if (nep->fui==NEP_USER_INTERFACE_SPLIT) T = nep->A[0];
336:     else {
337:       NEPGetFunction(nep,&T,NULL,NULL,NULL);
338:     }
339:     MatCreateVecs(T,&t,NULL);
340:     BVSetSizesFromVec(nep->V,t,requested);
341:     VecDestroy(&t);
342:   } else {
343:     BVResize(nep->V,requested,PETSC_FALSE);
344:   }
345:   return(0);
346: }

slepc-3.7.4/src/nep/interface/nepview.c.html0000644000175000017500000016205513107004621020271 0ustar jromanjroman
Actual source code: nepview.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    The NEP routines related to various viewers.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/nepimpl.h>      /*I "slepcnep.h" I*/
 25: #include <petscdraw.h>

 29: /*@C
 30:    NEPView - Prints the NEP data structure.

 32:    Collective on NEP

 34:    Input Parameters:
 35: +  nep - the nonlinear eigenproblem solver context
 36: -  viewer - optional visualization context

 38:    Options Database Key:
 39: .  -nep_view -  Calls NEPView() at end of NEPSolve()

 41:    Note:
 42:    The available visualization contexts include
 43: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
 44: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
 45:          output where only the first processor opens
 46:          the file.  All other processors send their
 47:          data to the first processor to print.

 49:    The user can open an alternative visualization context with
 50:    PetscViewerASCIIOpen() - output to a specified file.

 52:    Level: beginner

 54: .seealso: PetscViewerASCIIOpen()
 55: @*/
 56: PetscErrorCode NEPView(NEP nep,PetscViewer viewer)
 57: {
 59:   char           str[50];
 60:   PetscInt       i;
 61:   PetscBool      isascii,istrivial,nods;

 65:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep));

 69:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
 70:   if (isascii) {
 71:     PetscObjectPrintClassNamePrefixType((PetscObject)nep,viewer);
 72:     if (nep->ops->view) {
 73:       PetscViewerASCIIPushTab(viewer);
 74:       (*nep->ops->view)(nep,viewer);
 75:       PetscViewerASCIIPopTab(viewer);
 76:     }
 77:     if (nep->fui) {
 78:       switch (nep->fui) {
 79:       case NEP_USER_INTERFACE_CALLBACK:
 80:         PetscViewerASCIIPrintf(viewer,"  nonlinear operator from user callbacks\n");
 81:         break;
 82:       case NEP_USER_INTERFACE_SPLIT:
 83:         PetscViewerASCIIPrintf(viewer,"  nonlinear operator in split form\n");
 84:         break;
 85:       case NEP_USER_INTERFACE_DERIVATIVES:
 86:         PetscViewerASCIIPrintf(viewer,"  nonlinear operator from user callbacks for the successive derivatives\n");
 87:         break;
 88:       }
 89:     } else {
 90:       PetscViewerASCIIPrintf(viewer,"  nonlinear operator not specified yet\n");
 91:     }
 92:     PetscViewerASCIIPrintf(viewer,"  selected portion of the spectrum: ");
 93:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
 94:     SlepcSNPrintfScalar(str,50,nep->target,PETSC_FALSE);
 95:     if (!nep->which) {
 96:       PetscViewerASCIIPrintf(viewer,"not yet set\n");
 97:     } else switch (nep->which) {
 98:       case NEP_WHICH_USER:
 99:         PetscViewerASCIIPrintf(viewer,"user defined\n");
100:         break;
101:       case NEP_TARGET_MAGNITUDE:
102:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (in magnitude)\n",str);
103:         break;
104:       case NEP_TARGET_REAL:
105:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the real axis)\n",str);
106:         break;
107:       case NEP_TARGET_IMAGINARY:
108:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the imaginary axis)\n",str);
109:         break;
110:       case NEP_LARGEST_MAGNITUDE:
111:         PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");
112:         break;
113:       case NEP_SMALLEST_MAGNITUDE:
114:         PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");
115:         break;
116:       case NEP_LARGEST_REAL:
117:         PetscViewerASCIIPrintf(viewer,"largest real parts\n");
118:         break;
119:       case NEP_SMALLEST_REAL:
120:         PetscViewerASCIIPrintf(viewer,"smallest real parts\n");
121:         break;
122:       case NEP_LARGEST_IMAGINARY:
123:         PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");
124:         break;
125:       case NEP_SMALLEST_IMAGINARY:
126:         PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");
127:         break;
128:       case NEP_ALL:
129:         PetscViewerASCIIPrintf(viewer,"all eigenvalues in the region\n");
130:         break;
131:       default: SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of nep->which");
132:     }
133:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
134:     PetscViewerASCIIPrintf(viewer,"  number of eigenvalues (nev): %D\n",nep->nev);
135:     PetscViewerASCIIPrintf(viewer,"  number of column vectors (ncv): %D\n",nep->ncv);
136:     PetscViewerASCIIPrintf(viewer,"  maximum dimension of projected problem (mpd): %D\n",nep->mpd);
137:     PetscViewerASCIIPrintf(viewer,"  maximum number of iterations: %D\n",nep->max_it);
138:     PetscViewerASCIIPrintf(viewer,"  tolerance: %g\n",(double)nep->tol);
139:     PetscViewerASCIIPrintf(viewer,"  convergence test: ");
140:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
141:     switch (nep->conv) {
142:     case NEP_CONV_ABS:
143:       PetscViewerASCIIPrintf(viewer,"absolute\n");break;
144:     case NEP_CONV_REL:
145:       PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue\n");break;
146:     case NEP_CONV_NORM:
147:       PetscViewerASCIIPrintf(viewer,"relative to the matrix norms\n");
148:       if (nep->nrma) {
149:         PetscViewerASCIIPrintf(viewer,"  computed matrix norms: %g",(double)nep->nrma[0]);
150:         for (i=1;i<nep->nt;i++) {
151:           PetscViewerASCIIPrintf(viewer,", %g",(double)nep->nrma[i]);
152:         }
153:         PetscViewerASCIIPrintf(viewer,"\n");
154:       }
155:       break;
156:     case NEP_CONV_USER:
157:       PetscViewerASCIIPrintf(viewer,"user-defined\n");break;
158:     }
159:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
160:     if (nep->refine) {
161:       PetscViewerASCIIPrintf(viewer,"  iterative refinement: %s, with %s scheme\n",NEPRefineTypes[nep->refine],NEPRefineSchemes[nep->scheme]);
162:       PetscViewerASCIIPrintf(viewer,"  refinement stopping criterion: tol=%g, its=%D\n",(double)nep->rtol,nep->rits);
163:       if (nep->npart>1) {
164:         PetscViewerASCIIPrintf(viewer,"  splitting communicator in %D partitions for refinement\n",nep->npart);
165:       }
166:     }
167:     if (nep->nini) {
168:       PetscViewerASCIIPrintf(viewer,"  dimension of user-provided initial space: %D\n",PetscAbs(nep->nini));
169:     }
170:   } else {
171:     if (nep->ops->view) {
172:       (*nep->ops->view)(nep,viewer);
173:     }
174:   }
175:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);
176:   if (!nep->V) { NEPGetBV(nep,&nep->V); }
177:   BVView(nep->V,viewer);
178:   if (!nep->rg) { NEPGetRG(nep,&nep->rg); }
179:   RGIsTrivial(nep->rg,&istrivial);
180:   if (!istrivial) { RGView(nep->rg,viewer); }
181:   PetscObjectTypeCompareAny((PetscObject)nep,&nods,NEPRII,NEPSLP,NEPINTERPOL,"");
182:   if (!nods) {
183:     if (!nep->ds) { NEPGetDS(nep,&nep->ds); }
184:     DSView(nep->ds,viewer);
185:   }
186:   PetscViewerPopFormat(viewer);
187:   return(0);
188: }

192: /*@C
193:    NEPReasonView - Displays the reason a NEP solve converged or diverged.

195:    Collective on NEP

197:    Parameter:
198: +  nep - the nonlinear eigensolver context
199: -  viewer - the viewer to display the reason

201:    Options Database Keys:
202: .  -nep_converged_reason - print reason for convergence, and number of iterations

204:    Level: intermediate

206: .seealso: NEPSetConvergenceTest(), NEPSetTolerances(), NEPGetIterationNumber()
207: @*/
208: PetscErrorCode NEPReasonView(NEP nep,PetscViewer viewer)
209: {
211:   PetscBool      isAscii;

214:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);
215:   if (isAscii) {
216:     PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);
217:     if (nep->reason > 0) {
218:       PetscViewerASCIIPrintf(viewer,"%s Nonlinear eigensolve converged (%D eigenpair%s) due to %s; iterations %D\n",((PetscObject)nep)->prefix?((PetscObject)nep)->prefix:"",nep->nconv,(nep->nconv>1)?"s":"",NEPConvergedReasons[nep->reason],nep->its);
219:     } else {
220:       PetscViewerASCIIPrintf(viewer,"%s Nonlinear eigensolve did not converge due to %s; iterations %D\n",((PetscObject)nep)->prefix?((PetscObject)nep)->prefix:"",NEPConvergedReasons[nep->reason],nep->its);
221:     }
222:     PetscViewerASCIISubtractTab(viewer,((PetscObject)nep)->tablevel);
223:   }
224:   return(0);
225: }

229: /*@
230:    NEPReasonViewFromOptions - Processes command line options to determine if/how
231:    the NEP converged reason is to be viewed. 

233:    Collective on NEP

235:    Input Parameters:
236: .  nep - the nonlinear eigensolver context

238:    Level: developer
239: @*/
240: PetscErrorCode NEPReasonViewFromOptions(NEP nep)
241: {
242:   PetscErrorCode    ierr;
243:   PetscViewer       viewer;
244:   PetscBool         flg;
245:   static PetscBool  incall = PETSC_FALSE;
246:   PetscViewerFormat format;

249:   if (incall) return(0);
250:   incall = PETSC_TRUE;
251:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_converged_reason",&viewer,&format,&flg);
252:   if (flg) {
253:     PetscViewerPushFormat(viewer,format);
254:     NEPReasonView(nep,viewer);
255:     PetscViewerPopFormat(viewer);
256:     PetscViewerDestroy(&viewer);
257:   }
258:   incall = PETSC_FALSE;
259:   return(0);
260: }

264: static PetscErrorCode NEPErrorView_ASCII(NEP nep,NEPErrorType etype,PetscViewer viewer)
265: {
266:   PetscBool      errok;
267:   PetscReal      error,re,im;
268:   PetscScalar    kr,ki;
269:   PetscInt       i,j,nvals;

273:   if (nep->which!=NEP_ALL && nep->nconv<nep->nev) {
274:     PetscViewerASCIIPrintf(viewer," Problem: less than %D eigenvalues converged\n\n",nep->nev);
275:     return(0);
276:   }
277:   errok = PETSC_TRUE;
278:   nvals = (nep->which==NEP_ALL)? nep->nconv: nep->nev;
279:   for (i=0;i<nvals;i++) {
280:     NEPComputeError(nep,i,etype,&error);
281:     errok = (errok && error<5.0*nep->tol)? PETSC_TRUE: PETSC_FALSE;
282:   }
283:   if (!errok) {
284:     PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",nvals);
285:     return(0);
286:   }
287:   if (nep->which==NEP_ALL) {
288:     PetscViewerASCIIPrintf(viewer," Found %D eigenvalues, all of them computed up to the required tolerance:",nvals);
289:   } else {
290:     PetscViewerASCIIPrintf(viewer," All requested eigenvalues computed up to the required tolerance:");
291:   }
292:   for (i=0;i<=(nvals-1)/8;i++) {
293:     PetscViewerASCIIPrintf(viewer,"\n     ");
294:     for (j=0;j<PetscMin(8,nvals-8*i);j++) {
295:       NEPGetEigenpair(nep,8*i+j,&kr,&ki,NULL,NULL);
296: #if defined(PETSC_USE_COMPLEX)
297:       re = PetscRealPart(kr);
298:       im = PetscImaginaryPart(kr);
299: #else
300:       re = kr;
301:       im = ki;
302: #endif
303:       if (PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0;
304:       if (PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0;
305:       if (im!=0.0) {
306:         PetscViewerASCIIPrintf(viewer,"%.5f%+.5fi",(double)re,(double)im);
307:       } else {
308:         PetscViewerASCIIPrintf(viewer,"%.5f",(double)re);
309:       }
310:       if (8*i+j+1<nvals) { PetscViewerASCIIPrintf(viewer,", "); }
311:     }
312:   }
313:   PetscViewerASCIIPrintf(viewer,"\n\n");
314:   return(0);
315: }

319: static PetscErrorCode NEPErrorView_DETAIL(NEP nep,NEPErrorType etype,PetscViewer viewer)
320: {
322:   PetscReal      error,re,im;
323:   PetscScalar    kr,ki;
324:   PetscInt       i;
325: #define EXLEN 30
326:   char           ex[EXLEN],sep[]=" ---------------------- --------------------\n";

329:   if (!nep->nconv) return(0);
330:   switch (etype) {
331:     case NEP_ERROR_ABSOLUTE:
332:       PetscSNPrintf(ex,EXLEN,"    ||T(k)x||");
333:       break;
334:     case NEP_ERROR_RELATIVE:
335:       PetscSNPrintf(ex,EXLEN," ||T(k)x||/||kx||");
336:       break;
337:     case NEP_ERROR_BACKWARD:
338:       PetscSNPrintf(ex,EXLEN,"    eta(x,k)");
339:       break;
340:   }
341:   PetscViewerASCIIPrintf(viewer,"%s            k             %s\n%s",sep,ex,sep);
342:   for (i=0;i<nep->nconv;i++) {
343:     NEPGetEigenpair(nep,i,&kr,&ki,NULL,NULL);
344:     NEPComputeError(nep,i,etype,&error);
345: #if defined(PETSC_USE_COMPLEX)
346:     re = PetscRealPart(kr);
347:     im = PetscImaginaryPart(kr);
348: #else
349:     re = kr;
350:     im = ki;
351: #endif
352:     if (im!=0.0) {
353:       PetscViewerASCIIPrintf(viewer,"  % 9f%+9fi      %12g\n",(double)re,(double)im,(double)error);
354:     } else {
355:       PetscViewerASCIIPrintf(viewer,"    % 12f           %12g\n",(double)re,(double)error);
356:     }
357:   }
358:   PetscViewerASCIIPrintf(viewer,sep);
359:   return(0);
360: }

364: static PetscErrorCode NEPErrorView_MATLAB(NEP nep,NEPErrorType etype,PetscViewer viewer)
365: {
367:   PetscReal      error;
368:   PetscInt       i;
369:   const char     *name;

372:   PetscObjectGetName((PetscObject)nep,&name);
373:   PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);
374:   for (i=0;i<nep->nconv;i++) {
375:     NEPComputeError(nep,i,etype,&error);
376:     PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);
377:   }
378:   PetscViewerASCIIPrintf(viewer,"];\n");
379:   return(0);
380: }

384: /*@C
385:    NEPErrorView - Displays the errors associated with the computed solution
386:    (as well as the eigenvalues).

388:    Collective on NEP

390:    Input Parameters:
391: +  nep    - the nonlinear eigensolver context
392: .  etype  - error type
393: -  viewer - optional visualization context

395:    Options Database Key:
396: +  -nep_error_absolute - print absolute errors of each eigenpair
397: .  -nep_error_relative - print relative errors of each eigenpair
398: -  -nep_error_backward - print backward errors of each eigenpair

400:    Notes:
401:    By default, this function checks the error of all eigenpairs and prints
402:    the eigenvalues if all of them are below the requested tolerance.
403:    If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with
404:    eigenvalues and corresponding errors is printed.

406:    Level: intermediate

408: .seealso: NEPSolve(), NEPValuesView(), NEPVectorsView()
409: @*/
410: PetscErrorCode NEPErrorView(NEP nep,NEPErrorType etype,PetscViewer viewer)
411: {
412:   PetscBool         isascii;
413:   PetscViewerFormat format;
414:   PetscErrorCode    ierr;

418:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep));
421:   NEPCheckSolved(nep,1);
422:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
423:   if (!isascii) return(0);

425:   PetscViewerGetFormat(viewer,&format);
426:   switch (format) {
427:     case PETSC_VIEWER_DEFAULT:
428:     case PETSC_VIEWER_ASCII_INFO:
429:       NEPErrorView_ASCII(nep,etype,viewer);
430:       break;
431:     case PETSC_VIEWER_ASCII_INFO_DETAIL:
432:       NEPErrorView_DETAIL(nep,etype,viewer);
433:       break;
434:     case PETSC_VIEWER_ASCII_MATLAB:
435:       NEPErrorView_MATLAB(nep,etype,viewer);
436:       break;
437:     default:
438:       PetscInfo1(nep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
439:   }
440:   return(0);
441: }

445: /*@
446:    NEPErrorViewFromOptions - Processes command line options to determine if/how
447:    the errors of the computed solution are to be viewed. 

449:    Collective on NEP

451:    Input Parameters:
452: .  nep - the nonlinear eigensolver context

454:    Level: developer
455: @*/
456: PetscErrorCode NEPErrorViewFromOptions(NEP nep)
457: {
458:   PetscErrorCode    ierr;
459:   PetscViewer       viewer;
460:   PetscBool         flg;
461:   static PetscBool  incall = PETSC_FALSE;
462:   PetscViewerFormat format;

465:   if (incall) return(0);
466:   incall = PETSC_TRUE;
467:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_error_absolute",&viewer,&format,&flg);
468:   if (flg) {
469:     PetscViewerPushFormat(viewer,format);
470:     NEPErrorView(nep,NEP_ERROR_ABSOLUTE,viewer);
471:     PetscViewerPopFormat(viewer);
472:     PetscViewerDestroy(&viewer);
473:   }
474:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_error_relative",&viewer,&format,&flg);
475:   if (flg) {
476:     PetscViewerPushFormat(viewer,format);
477:     NEPErrorView(nep,NEP_ERROR_RELATIVE,viewer);
478:     PetscViewerPopFormat(viewer);
479:     PetscViewerDestroy(&viewer);
480:   }
481:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_error_backward",&viewer,&format,&flg);
482:   if (flg) {
483:     PetscViewerPushFormat(viewer,format);
484:     NEPErrorView(nep,NEP_ERROR_BACKWARD,viewer);
485:     PetscViewerPopFormat(viewer);
486:     PetscViewerDestroy(&viewer);
487:   }
488:   incall = PETSC_FALSE;
489:   return(0);
490: }

494: static PetscErrorCode NEPValuesView_DRAW(NEP nep,PetscViewer viewer)
495: {
497:   PetscDraw      draw;
498:   PetscDrawSP    drawsp;
499:   PetscReal      re,im;
500:   PetscInt       i,k;

503:   if (!nep->nconv) return(0);
504:   PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed Eigenvalues",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);
505:   PetscViewerDrawGetDraw(viewer,0,&draw);
506:   PetscDrawSPCreate(draw,1,&drawsp);
507:   for (i=0;i<nep->nconv;i++) {
508:     k = nep->perm[i];
509: #if defined(PETSC_USE_COMPLEX)
510:     re = PetscRealPart(nep->eigr[k]);
511:     im = PetscImaginaryPart(nep->eigr[k]);
512: #else
513:     re = nep->eigr[k];
514:     im = nep->eigi[k];
515: #endif
516:     PetscDrawSPAddPoint(drawsp,&re,&im);
517:   }
518:   PetscDrawSPDraw(drawsp,PETSC_TRUE);
519:   PetscDrawSPSave(drawsp);
520:   PetscDrawSPDestroy(&drawsp);
521:   PetscViewerDestroy(&viewer);
522:   return(0);
523: }

527: static PetscErrorCode NEPValuesView_ASCII(NEP nep,PetscViewer viewer)
528: {
529:   PetscReal      re,im;
530:   PetscInt       i,k;

534:   PetscViewerASCIIPrintf(viewer,"Eigenvalues = \n");
535:   for (i=0;i<nep->nconv;i++) {
536:     k = nep->perm[i];
537: #if defined(PETSC_USE_COMPLEX)
538:     re = PetscRealPart(nep->eigr[k]);
539:     im = PetscImaginaryPart(nep->eigr[k]);
540: #else
541:     re = nep->eigr[k];
542:     im = nep->eigi[k];
543: #endif
544:     if (PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0;
545:     if (PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0;
546:     if (im!=0.0) {
547:       PetscViewerASCIIPrintf(viewer,"   %.5f%+.5fi\n",(double)re,(double)im);
548:     } else {
549:       PetscViewerASCIIPrintf(viewer,"   %.5f\n",(double)re);
550:     }
551:   }
552:   PetscViewerASCIIPrintf(viewer,"\n");
553:   return(0);
554: }

558: static PetscErrorCode NEPValuesView_MATLAB(NEP nep,PetscViewer viewer)
559: {
561:   PetscInt       i,k;
562:   PetscReal      re,im;
563:   const char     *name;

566:   PetscObjectGetName((PetscObject)nep,&name);
567:   PetscViewerASCIIPrintf(viewer,"Lambda_%s = [\n",name);
568:   for (i=0;i<nep->nconv;i++) {
569:     k = nep->perm[i];
570: #if defined(PETSC_USE_COMPLEX)
571:     re = PetscRealPart(nep->eigr[k]);
572:     im = PetscImaginaryPart(nep->eigr[k]);
573: #else
574:     re = nep->eigr[k];
575:     im = nep->eigi[k];
576: #endif
577:     if (im!=0.0) {
578:       PetscViewerASCIIPrintf(viewer,"%18.16e%+18.16ei\n",(double)re,(double)im);
579:     } else {
580:       PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)re);
581:     }
582:   }
583:   PetscViewerASCIIPrintf(viewer,"];\n");
584:   return(0);
585: }

589: /*@C
590:    NEPValuesView - Displays the computed eigenvalues in a viewer.

592:    Collective on NEP

594:    Input Parameters:
595: +  nep    - the nonlinear eigensolver context
596: -  viewer - the viewer

598:    Options Database Key:
599: .  -nep_view_values - print computed eigenvalues

601:    Level: intermediate

603: .seealso: NEPSolve(), NEPVectorsView(), NEPErrorView()
604: @*/
605: PetscErrorCode NEPValuesView(NEP nep,PetscViewer viewer)
606: {
607:   PetscBool         isascii,isdraw;
608:   PetscViewerFormat format;
609:   PetscErrorCode    ierr;

613:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep));
616:   NEPCheckSolved(nep,1);
617:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);
618:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
619:   if (isdraw) {
620:     NEPValuesView_DRAW(nep,viewer);
621:   } else if (isascii) {
622:     PetscViewerGetFormat(viewer,&format);
623:     switch (format) {
624:       case PETSC_VIEWER_DEFAULT:
625:       case PETSC_VIEWER_ASCII_INFO:
626:       case PETSC_VIEWER_ASCII_INFO_DETAIL:
627:         NEPValuesView_ASCII(nep,viewer);
628:         break;
629:       case PETSC_VIEWER_ASCII_MATLAB:
630:         NEPValuesView_MATLAB(nep,viewer);
631:         break;
632:       default:
633:         PetscInfo1(nep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
634:     }
635:   }
636:   return(0);
637: }

641: /*@
642:    NEPValuesViewFromOptions - Processes command line options to determine if/how
643:    the computed eigenvalues are to be viewed. 

645:    Collective on NEP

647:    Input Parameters:
648: .  nep - the nonlinear eigensolver context

650:    Level: developer
651: @*/
652: PetscErrorCode NEPValuesViewFromOptions(NEP nep)
653: {
654:   PetscErrorCode    ierr;
655:   PetscViewer       viewer;
656:   PetscBool         flg;
657:   static PetscBool  incall = PETSC_FALSE;
658:   PetscViewerFormat format;

661:   if (incall) return(0);
662:   incall = PETSC_TRUE;
663:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_view_values",&viewer,&format,&flg);
664:   if (flg) {
665:     PetscViewerPushFormat(viewer,format);
666:     NEPValuesView(nep,viewer);
667:     PetscViewerPopFormat(viewer);
668:     PetscViewerDestroy(&viewer);
669:   }
670:   incall = PETSC_FALSE;
671:   return(0);
672: }

676: /*@C
677:    NEPVectorsView - Outputs computed eigenvectors to a viewer.

679:    Collective on NEP

681:    Parameter:
682: +  nep    - the nonlinear eigensolver context
683: -  viewer - the viewer

685:    Options Database Keys:
686: .  -nep_view_vectors - output eigenvectors.

688:    Note:
689:    If PETSc was configured with real scalars, complex conjugate eigenvectors
690:    will be viewed as two separate real vectors, one containing the real part
691:    and another one containing the imaginary part.

693:    Level: intermediate

695: .seealso: NEPSolve(), NEPValuesView(), NEPErrorView()
696: @*/
697: PetscErrorCode NEPVectorsView(NEP nep,PetscViewer viewer)
698: {
700:   PetscInt       i,k;
701:   Vec            x;
702: #define NMLEN 30
703:   char           vname[NMLEN];
704:   const char     *ename;

708:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)nep));
711:   NEPCheckSolved(nep,1);
712:   if (nep->nconv) {
713:     PetscObjectGetName((PetscObject)nep,&ename);
714:     NEPComputeVectors(nep);
715:     for (i=0;i<nep->nconv;i++) {
716:       k = nep->perm[i];
717:       PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);
718:       BVGetColumn(nep->V,k,&x);
719:       PetscObjectSetName((PetscObject)x,vname);
720:       VecView(x,viewer);
721:       BVRestoreColumn(nep->V,k,&x);
722:     }
723:   }
724:   return(0);
725: }

729: /*@
730:    NEPVectorsViewFromOptions - Processes command line options to determine if/how
731:    the computed eigenvectors are to be viewed. 

733:    Collective on NEP

735:    Input Parameters:
736: .  nep - the nonlinear eigensolver context

738:    Level: developer
739: @*/
740: PetscErrorCode NEPVectorsViewFromOptions(NEP nep)
741: {
742:   PetscErrorCode    ierr;
743:   PetscViewer       viewer;
744:   PetscBool         flg = PETSC_FALSE;
745:   static PetscBool  incall = PETSC_FALSE;
746:   PetscViewerFormat format;

749:   if (incall) return(0);
750:   incall = PETSC_TRUE;
751:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)nep),((PetscObject)nep)->prefix,"-nep_view_vectors",&viewer,&format,&flg);
752:   if (flg) {
753:     PetscViewerPushFormat(viewer,format);
754:     NEPVectorsView(nep,viewer);
755:     PetscViewerPopFormat(viewer);
756:     PetscViewerDestroy(&viewer);
757:   }
758:   incall = PETSC_FALSE;
759:   return(0);
760: }

slepc-3.7.4/src/nep/interface/neprefine.c0000644000175000017500000005566113107004621017630 0ustar jromanjroman/* Newton refinement for NEP, simple version. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #define NREF_MAXIT 10 typedef struct { PetscSubcomm subc; VecScatter *scatter_id,nst; Mat *A; Vec nv,vg,v,w; FN *fn; } NEPSimpNRefctx; typedef struct { Mat M1; Vec M2,M3; PetscScalar M4,m3; } FSubctx; #undef __FUNCT__ #define __FUNCT__ "MatFSMult" static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y) { PetscErrorCode ierr; FSubctx *ctx; PetscScalar t; PetscFunctionBegin; ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); ierr = VecDot(x,ctx->M3,&t);CHKERRQ(ierr); t *= ctx->m3/ctx->M4; ierr = MatMult(ctx->M1,x,y);CHKERRQ(ierr); ierr = VecAXPY(y,-t,ctx->M2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSimpleNRefSetUp" static PetscErrorCode NEPSimpleNRefSetUp(NEP nep,NEPSimpNRefctx **ctx_) { PetscErrorCode ierr; PetscInt i,si,j,n0,m0,nloc,*idx1,*idx2,ne; IS is1,is2; NEPSimpNRefctx *ctx; Vec v; PetscMPIInt rank,size; PetscFunctionBegin; ierr = PetscCalloc1(1,ctx_);CHKERRQ(ierr); ctx = *ctx_; if (nep->npart==1) { ctx->A = nep->A; ctx->fn = nep->f; } else { ierr = PetscMalloc2(nep->nt,&ctx->A,nep->npart,&ctx->scatter_id);CHKERRQ(ierr); /* Duplicate matrices */ for (i=0;int;i++) { ierr = MatCreateRedundantMatrix(nep->A[i],0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&ctx->A[i]);CHKERRQ(ierr); } ierr = MatCreateVecs(ctx->A[0],&ctx->v,NULL);CHKERRQ(ierr); /* Duplicate FNs */ ierr = PetscMalloc1(nep->nt,&ctx->fn);CHKERRQ(ierr); for (i=0;int;i++) { ierr = FNDuplicate(nep->f[i],PetscSubcommChild(ctx->subc),&ctx->fn[i]);CHKERRQ(ierr); } /* Create scatters for sending vectors to each subcommucator */ ierr = BVGetColumn(nep->V,0,&v);CHKERRQ(ierr); ierr = VecGetOwnershipRange(v,&n0,&m0);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,0,&v);CHKERRQ(ierr); ierr = VecGetLocalSize(ctx->v,&nloc);CHKERRQ(ierr); ierr = PetscMalloc2(m0-n0,&idx1,m0-n0,&idx2);CHKERRQ(ierr); ierr = VecCreateMPI(PetscObjectComm((PetscObject)nep),nloc,PETSC_DECIDE,&ctx->vg);CHKERRQ(ierr); for (si=0;sinpart;si++) { j = 0; for (i=n0;in*si; } ierr = ISCreateGeneral(PetscObjectComm((PetscObject)nep),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr); ierr = ISCreateGeneral(PetscObjectComm((PetscObject)nep),(m0-n0),idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr); ierr = BVGetColumn(nep->V,0,&v);CHKERRQ(ierr); ierr = VecScatterCreate(v,is1,ctx->vg,is2,&ctx->scatter_id[si]);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,0,&v);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); ierr = ISDestroy(&is2);CHKERRQ(ierr); } ierr = PetscFree2(idx1,idx2);CHKERRQ(ierr); } if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT) { ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)ctx->A[0]),&rank);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)ctx->A[0]),&size);CHKERRQ(ierr); if (size>1) { if (nep->npart==1) { ierr = BVGetColumn(nep->V,0,&v);CHKERRQ(ierr); } else v = ctx->v; ierr = VecGetOwnershipRange(v,&n0,&m0);CHKERRQ(ierr); ne = (rank == size-1)?nep->n:0; ierr = VecCreateMPI(PetscObjectComm((PetscObject)ctx->A[0]),ne,PETSC_DECIDE,&ctx->nv);CHKERRQ(ierr); ierr = PetscMalloc1(m0-n0,&idx1);CHKERRQ(ierr); for (i=n0;inv,is1,&ctx->nst);CHKERRQ(ierr); if (nep->npart==1) { ierr = BVRestoreColumn(nep->V,0,&v);CHKERRQ(ierr); } ierr = PetscFree(idx1);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); } } PetscFunctionReturn(0); } /* Gather Eigenpair idx from subcommunicator with color sc */ #undef __FUNCT__ #define __FUNCT__ "NEPSimpleNRefGatherEigenpair" static PetscErrorCode NEPSimpleNRefGatherEigenpair(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail) { PetscErrorCode ierr; PetscMPIInt nproc,p; MPI_Comm comm=((PetscObject)nep)->comm; Vec v; PetscScalar *array; PetscFunctionBegin; if (nep->npart>1) { ierr = MPI_Comm_size(comm,&nproc);CHKERRQ(ierr); p = (nproc/nep->npart)*sc+PetscMin(sc,nproc%nep->npart); /* Communicate convergence successful */ ierr = MPI_Bcast(fail,1,MPIU_INT,p,comm);CHKERRQ(ierr); if (!(*fail)) { /* Process 0 of subcommunicator sc broadcasts the eigenvalue */ ierr = MPI_Bcast(&nep->eigr[idx],1,MPIU_SCALAR,p,comm);CHKERRQ(ierr); /* Gather nep->V[idx] from the subcommuniator sc */ ierr = BVGetColumn(nep->V,idx,&v);CHKERRQ(ierr); if (ctx->subc->color==sc) { ierr = VecGetArray(ctx->v,&array);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->vg,array);CHKERRQ(ierr); } ierr = VecScatterBegin(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); if (ctx->subc->color==sc) { ierr = VecResetArray(ctx->vg);CHKERRQ(ierr); ierr = VecRestoreArray(ctx->v,&array);CHKERRQ(ierr); } ierr = BVRestoreColumn(nep->V,idx,&v);CHKERRQ(ierr); } } else { if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT && !(*fail)) { ierr = MPI_Comm_size(comm,&nproc);CHKERRQ(ierr); p = (nproc/nep->npart)*sc+PetscMin(sc,nproc%nep->npart); ierr = MPI_Bcast(&nep->eigr[idx],1,MPIU_SCALAR,p,comm);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSimpleNRefScatterEigenvector" static PetscErrorCode NEPSimpleNRefScatterEigenvector(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx) { PetscErrorCode ierr; Vec v; PetscScalar *array; PetscFunctionBegin; if (nep->npart>1) { ierr = BVGetColumn(nep->V,idx,&v);CHKERRQ(ierr); if (ctx->subc->color==sc) { ierr = VecGetArray(ctx->v,&array);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->vg,array);CHKERRQ(ierr); } ierr = VecScatterBegin(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); if (ctx->subc->color==sc) { ierr = VecResetArray(ctx->vg);CHKERRQ(ierr); ierr = VecRestoreArray(ctx->v,&array);CHKERRQ(ierr); } ierr = BVRestoreColumn(nep->V,idx,&v);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSimpleNRefSetUpSystem" static PetscErrorCode NEPSimpleNRefSetUpSystem(NEP nep,NEPSimpNRefctx *ctx,Mat *A,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v) { PetscErrorCode ierr; PetscInt i,st,ml,m0,n0,m1,mg; PetscInt *dnz,*onz,ncols,*cols2,*nnz,nt=nep->nt; PetscScalar zero=0.0,*coeffs,*coeffs2; PetscMPIInt rank,size; MPI_Comm comm; const PetscInt *cols; const PetscScalar *vals,*array; FSubctx *fctx; Vec w=ctx->w; Mat M; PetscFunctionBegin; ierr = PetscMalloc2(nt,&coeffs,nt,&coeffs2);CHKERRQ(ierr); switch (nep->scheme) { case NEP_REFINE_SCHEME_SCHUR: if (ini) { ierr = PetscCalloc1(1,&fctx);CHKERRQ(ierr); ierr = MatGetSize(A[0],&m0,&n0);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)A[0]),PETSC_DECIDE,PETSC_DECIDE,m0,n0,fctx,T);CHKERRQ(ierr); ierr = MatShellSetOperation(*T,MATOP_MULT,(void(*)(void))MatFSMult);CHKERRQ(ierr); } else { ierr = MatShellGetContext(*T,&fctx);CHKERRQ(ierr); } M=fctx->M1; break; case NEP_REFINE_SCHEME_MBE: M=*T; break; case NEP_REFINE_SCHEME_EXPLICIT: M=*Mt; break; } if (ini) { ierr = MatDuplicate(A[0],MAT_COPY_VALUES,&M);CHKERRQ(ierr); } else { ierr = MatCopy(A[0],M,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); } for (i=0;ifn[i],nep->eigr[idx],coeffs+i);CHKERRQ(ierr); } if (coeffs[0]!=1.0) { ierr = MatScale(M,coeffs[0]);CHKERRQ(ierr); } for (i=1;imstr:SUBSET_NONZERO_PATTERN);CHKERRQ(ierr); } for (i=0;ifn[i],nep->eigr[idx],coeffs2+i);CHKERRQ(ierr); } st = 0; for (i=0;ischeme) { case NEP_REFINE_SCHEME_EXPLICIT: comm = PetscObjectComm((PetscObject)A[0]); ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr); ierr = MatGetSize(M,&mg,NULL);CHKERRQ(ierr); ierr = MatGetOwnershipRange(M,&m0,&m1);CHKERRQ(ierr); if (ini) { ierr = MatCreate(comm,T);CHKERRQ(ierr); ierr = MatGetLocalSize(M,&ml,NULL);CHKERRQ(ierr); if (rank==size-1) ml++; ierr = MatSetSizes(*T,ml,ml,mg+1,mg+1);CHKERRQ(ierr); ierr = MatSetFromOptions(*T);CHKERRQ(ierr); ierr = MatSetUp(*T);CHKERRQ(ierr); /* Preallocate M */ if (size>1) { ierr = MatPreallocateInitialize(comm,ml,ml,dnz,onz);CHKERRQ(ierr); for (i=m0;i1) { if (rank==size-1) { ierr = PetscMalloc1(nep->n,&cols2);CHKERRQ(ierr); for (i=0;in;i++) cols2[i]=i; } ierr = VecScatterBegin(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecGetArrayRead(ctx->nv,&array);CHKERRQ(ierr); if (rank==size-1) { ierr = MatSetValues(*T,1,&mg,nep->n,cols2,array,INSERT_VALUES);CHKERRQ(ierr); ierr = MatSetValues(*T,1,&mg,1,&mg,&zero,INSERT_VALUES);CHKERRQ(ierr); } ierr = VecRestoreArrayRead(ctx->nv,&array);CHKERRQ(ierr); } else { ierr = PetscMalloc1(m1-m0,&cols2);CHKERRQ(ierr); for (i=0;iM2 = ctx->w; fctx->M3 = v; fctx->m3 = 0.0; for (i=1;im3 += PetscConj(coeffs[i])*coeffs[i]; fctx->M4 = 0.0; for (i=1;iM4 += PetscConj(coeffs[i])*coeffs2[i]; fctx->M1 = M; if (ini) { ierr = MatDuplicate(M,MAT_COPY_VALUES,P);CHKERRQ(ierr); } else { ierr = MatCopy(M,*P,SAME_NONZERO_PATTERN);CHKERRQ(ierr); } ierr = VecConjugate(v);CHKERRQ(ierr); ierr = VecPointwiseMult(t,v,w);CHKERRQ(ierr); ierr = VecConjugate(v);CHKERRQ(ierr); ierr = VecScale(t,-fctx->m3/fctx->M4);CHKERRQ(ierr); ierr = MatDiagonalSet(*P,t,ADD_VALUES);CHKERRQ(ierr); break; case NEP_REFINE_SCHEME_MBE: *T = M; *P = M; break; } ierr = PetscFree2(coeffs,coeffs2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNewtonRefinementSimple" PetscErrorCode NEPNewtonRefinementSimple(NEP nep,PetscInt *maxits,PetscReal tol,PetscInt k) { PetscErrorCode ierr; PetscInt i,n,its,idx=0,*idx_sc,*its_sc,color,*fail_sc; PetscMPIInt rank,size; Mat Mt=NULL,T=NULL,P=NULL; MPI_Comm comm; Vec r,v,dv,rr=NULL,dvv=NULL,t[2]; const PetscScalar *array; PetscScalar *array2,deig=0.0,tt[2],ttt; PetscReal norm,error; PetscBool ini=PETSC_TRUE,sc_pend,solved=PETSC_FALSE; NEPSimpNRefctx *ctx; FSubctx *fctx=NULL; KSPConvergedReason reason; PetscFunctionBegin; ierr = PetscLogEventBegin(NEP_Refine,nep,0,0,0);CHKERRQ(ierr); ierr = NEPSimpleNRefSetUp(nep,&ctx);CHKERRQ(ierr); its = (maxits)?*maxits:NREF_MAXIT; comm = (nep->npart==1)?PetscObjectComm((PetscObject)nep):PetscSubcommChild(ctx->subc); if (!nep->refineksp) { ierr = NEPRefineGetKSP(nep,&nep->refineksp);CHKERRQ(ierr); } if (nep->npart==1) { ierr = BVGetColumn(nep->V,0,&v);CHKERRQ(ierr); } else v = ctx->v; ierr = VecDuplicate(v,&ctx->w);CHKERRQ(ierr); ierr = VecDuplicate(v,&r);CHKERRQ(ierr); ierr = VecDuplicate(v,&dv);CHKERRQ(ierr); ierr = VecDuplicate(v,&t[0]);CHKERRQ(ierr); ierr = VecDuplicate(v,&t[1]);CHKERRQ(ierr); if (nep->npart==1) { ierr = BVRestoreColumn(nep->V,0,&v);CHKERRQ(ierr); } ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr); ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); ierr = VecGetLocalSize(r,&n);CHKERRQ(ierr); ierr = PetscMalloc3(nep->npart,&idx_sc,nep->npart,&its_sc,nep->npart,&fail_sc);CHKERRQ(ierr); for (i=0;inpart;i++) fail_sc[i] = 0; for (i=0;inpart;i++) its_sc[i] = 0; color = (nep->npart==1)?0:ctx->subc->color; /* Loop performing iterative refinements */ while (!solved) { for (i=0;inpart;i++) { sc_pend = PETSC_TRUE; if (its_sc[i]==0) { idx_sc[i] = idx++; if (idx_sc[i]>=k) { sc_pend = PETSC_FALSE; } else { ierr = NEPSimpleNRefScatterEigenvector(nep,ctx,i,idx_sc[i]);CHKERRQ(ierr); } } else { /* Gather Eigenpair from subcommunicator i */ ierr = NEPSimpleNRefGatherEigenpair(nep,ctx,i,idx_sc[i],&fail_sc[i]);CHKERRQ(ierr); } while (sc_pend) { if (!fail_sc[i]) { ierr = NEPComputeError(nep,idx_sc[i],NEP_ERROR_RELATIVE,&error);CHKERRQ(ierr); } if (error<=tol || its_sc[i]>=its || fail_sc[i]) { idx_sc[i] = idx++; its_sc[i] = 0; if (idx_sc[i]=k) sc_pend = PETSC_FALSE; } } solved = PETSC_TRUE; for (i=0;inpart&&solved;i++) solved = PetscNot(idx_sc[i]eigi[idx_sc[color]]!=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Simple Refinement not implemented in real scalar for complex eigenvalues"); #endif if (nep->npart==1) { ierr = BVGetColumn(nep->V,idx_sc[color],&v);CHKERRQ(ierr); } else v = ctx->v; ierr = NEPSimpleNRefSetUpSystem(nep,ctx,ctx->A,idx_sc[color],&Mt,&T,&P,ini,t[0],v);CHKERRQ(ierr); ierr = KSPSetOperators(nep->refineksp,T,P);CHKERRQ(ierr); if (ini) { ierr = KSPSetFromOptions(nep->refineksp);CHKERRQ(ierr); if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT) { ierr = MatCreateVecs(T,&dvv,NULL);CHKERRQ(ierr); ierr = VecDuplicate(dvv,&rr);CHKERRQ(ierr); } ini = PETSC_FALSE; } switch (nep->scheme) { case NEP_REFINE_SCHEME_EXPLICIT: ierr = MatMult(Mt,v,r);CHKERRQ(ierr); ierr = VecGetArrayRead(r,&array);CHKERRQ(ierr); if (rank==size-1) { ierr = VecGetArray(rr,&array2);CHKERRQ(ierr); ierr = PetscMemcpy(array2,array,n*sizeof(PetscScalar));CHKERRQ(ierr); array2[n] = 0.0; ierr = VecRestoreArray(rr,&array2);CHKERRQ(ierr); } else { ierr = VecPlaceArray(rr,array);CHKERRQ(ierr); } ierr = KSPSolve(nep->refineksp,rr,dvv);CHKERRQ(ierr); ierr = KSPGetConvergedReason(nep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { if (rank != size-1) { ierr = VecResetArray(rr);CHKERRQ(ierr); } ierr = VecRestoreArrayRead(r,&array);CHKERRQ(ierr); ierr = VecGetArrayRead(dvv,&array);CHKERRQ(ierr); ierr = VecPlaceArray(dv,array);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,dv);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); ierr = VecResetArray(dv);CHKERRQ(ierr); if (rank==size-1) nep->eigr[idx_sc[color]] -= array[n]; ierr = VecRestoreArrayRead(dvv,&array);CHKERRQ(ierr); } else fail_sc[color] = 1; break; case NEP_REFINE_SCHEME_MBE: ierr = MatMult(T,v,r);CHKERRQ(ierr); /* Mixed block elimination */ ierr = VecConjugate(v);CHKERRQ(ierr); ierr = KSPSolveTranspose(nep->refineksp,v,t[0]);CHKERRQ(ierr); ierr = KSPGetConvergedReason(nep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecConjugate(t[0]);CHKERRQ(ierr); ierr = VecDot(ctx->w,t[0],&tt[0]);CHKERRQ(ierr); ierr = KSPSolve(nep->refineksp,ctx->w,t[1]);CHKERRQ(ierr); ierr = KSPGetConvergedReason(nep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecDot(t[1],v,&tt[1]);CHKERRQ(ierr); ierr = VecDot(r,t[0],&ttt);CHKERRQ(ierr); tt[0] = ttt/tt[0]; ierr = VecAXPY(r,-tt[0],ctx->w);CHKERRQ(ierr); ierr = KSPSolve(nep->refineksp,r,dv);CHKERRQ(ierr); ierr = KSPGetConvergedReason(nep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecDot(dv,v,&ttt);CHKERRQ(ierr); tt[1] = ttt/tt[1]; ierr = VecAXPY(dv,-tt[1],t[1]);CHKERRQ(ierr); deig = tt[0]+tt[1]; } } ierr = VecConjugate(v);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,dv);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); nep->eigr[idx_sc[color]] -= deig; fail_sc[color] = 0; } else { ierr = VecConjugate(v);CHKERRQ(ierr); fail_sc[color] = 1; } break; case NEP_REFINE_SCHEME_SCHUR: ierr = MatShellGetContext(T,&fctx);CHKERRQ(ierr); ierr = MatMult(fctx->M1,v,r);CHKERRQ(ierr); ierr = KSPSolve(nep->refineksp,r,dv);CHKERRQ(ierr); ierr = KSPGetConvergedReason(nep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecDot(dv,v,&deig);CHKERRQ(ierr); deig *= -fctx->m3/fctx->M4; ierr = VecAXPY(v,-1.0,dv);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); nep->eigr[idx_sc[color]] -= deig; fail_sc[color] = 0; } else fail_sc[color] = 1; break; } if (nep->npart==1) { ierr = BVRestoreColumn(nep->V,idx_sc[color],&v);CHKERRQ(ierr); } } } ierr = VecDestroy(&t[0]);CHKERRQ(ierr); ierr = VecDestroy(&t[1]);CHKERRQ(ierr); ierr = VecDestroy(&dv);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w);CHKERRQ(ierr); ierr = VecDestroy(&r);CHKERRQ(ierr); ierr = PetscFree3(idx_sc,its_sc,fail_sc);CHKERRQ(ierr); ierr = VecScatterDestroy(&ctx->nst);CHKERRQ(ierr); if (nep->npart>1) { ierr = VecDestroy(&ctx->vg);CHKERRQ(ierr); ierr = VecDestroy(&ctx->v);CHKERRQ(ierr); for (i=0;int;i++) { ierr = MatDestroy(&ctx->A[i]);CHKERRQ(ierr); } for (i=0;inpart;i++) { ierr = VecScatterDestroy(&ctx->scatter_id[i]);CHKERRQ(ierr); } ierr = PetscFree2(ctx->A,ctx->scatter_id);CHKERRQ(ierr); } if (fctx && nep->scheme==NEP_REFINE_SCHEME_SCHUR) { ierr = MatDestroy(&P);CHKERRQ(ierr); ierr = MatDestroy(&fctx->M1);CHKERRQ(ierr); ierr = PetscFree(fctx);CHKERRQ(ierr); } if (nep->scheme==NEP_REFINE_SCHEME_EXPLICIT) { ierr = MatDestroy(&Mt);CHKERRQ(ierr); ierr = VecDestroy(&dvv);CHKERRQ(ierr); ierr = VecDestroy(&rr);CHKERRQ(ierr); ierr = VecDestroy(&ctx->nv);CHKERRQ(ierr); if (nep->npart>1) { for (i=0;int;i++) { ierr = FNDestroy(&ctx->fn[i]);CHKERRQ(ierr); } ierr = PetscFree(ctx->fn);CHKERRQ(ierr); } } ierr = MatDestroy(&T);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); ierr = PetscLogEventEnd(NEP_Refine,nep,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/nepmon.c0000644000175000017500000003723713107004621017150 0ustar jromanjroman/* NEP routines related to monitors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "NEPMonitor" /* Runs the user provided monitor routines, if any. */ PetscErrorCode NEPMonitor(NEP nep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest) { PetscErrorCode ierr; PetscInt i,n = nep->numbermonitors; PetscFunctionBegin; for (i=0;imonitor[i])(nep,it,nconv,eigr,eigi,errest,nest,nep->monitorcontext[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorSet" /*@C NEPMonitorSet - Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested eigenpair. Logically Collective on NEP Input Parameters: + nep - eigensolver context obtained from NEPCreate() . monitor - pointer to function (if this is NULL, it turns off monitoring) . mctx - [optional] context for private data for the monitor routine (use NULL if no context is desired) - monitordestroy - [optional] routine that frees monitor context (may be NULL) Calling Sequence of monitor: $ monitor(NEP nep,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx) + nep - nonlinear eigensolver context obtained from NEPCreate() . its - iteration number . nconv - number of converged eigenpairs . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates for each eigenpair . nest - number of error estimates - mctx - optional monitoring context, as set by NEPMonitorSet() Options Database Keys: + -nep_monitor - print only the first error estimate . -nep_monitor_all - print error estimates at each iteration . -nep_monitor_conv - print the eigenvalue approximations only when convergence has been reached . -nep_monitor_lg - sets line graph monitor for the first unconverged approximate eigenvalue . -nep_monitor_lg_all - sets line graph monitor for all unconverged approximate eigenvalues - -nep_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to NEPMonitorSet(), but does not cancel those set via the options database. Notes: Several different monitoring routines may be set by calling NEPMonitorSet() multiple times; all will be called in the order in which they were set. Level: intermediate .seealso: NEPMonitorFirst(), NEPMonitorAll(), NEPMonitorCancel() @*/ PetscErrorCode NEPMonitorSet(NEP nep,PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**)) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (nep->numbermonitors >= MAXNEPMONITORS) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Too many NEP monitors set"); nep->monitor[nep->numbermonitors] = monitor; nep->monitorcontext[nep->numbermonitors] = (void*)mctx; nep->monitordestroy[nep->numbermonitors++] = monitordestroy; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorCancel" /*@ NEPMonitorCancel - Clears all monitors for a NEP object. Logically Collective on NEP Input Parameters: . nep - eigensolver context obtained from NEPCreate() Options Database Key: . -nep_monitor_cancel - Cancels all monitors that have been hardwired into a code by calls to NEPMonitorSet(), but does not cancel those set via the options database. Level: intermediate .seealso: NEPMonitorSet() @*/ PetscErrorCode NEPMonitorCancel(NEP nep) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); for (i=0; inumbermonitors; i++) { if (nep->monitordestroy[i]) { ierr = (*nep->monitordestroy[i])(&nep->monitorcontext[i]);CHKERRQ(ierr); } } nep->numbermonitors = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPGetMonitorContext" /*@C NEPGetMonitorContext - Gets the monitor context, as set by NEPMonitorSet() for the FIRST monitor only. Not Collective Input Parameter: . nep - eigensolver context obtained from NEPCreate() Output Parameter: . ctx - monitor context Level: intermediate .seealso: NEPMonitorSet(), NEPDefaultMonitor() @*/ PetscErrorCode NEPGetMonitorContext(NEP nep,void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); *ctx = nep->monitorcontext[0]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorAll" /*@C NEPMonitorAll - Print the current approximate values and error estimates at each iteration of the nonlinear eigensolver. Collective on NEP Input Parameters: + nep - nonlinear eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: NEPMonitorSet(), NEPMonitorFirst(), NEPMonitorConverged() @*/ PetscErrorCode NEPMonitorAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscInt i; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(vf,8); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); ierr = PetscViewerPushFormat(viewer,vf->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);CHKERRQ(ierr); if (its==1 && ((PetscObject)nep)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)nep)->prefix);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"%3D NEP nconv=%D Values (Errors)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;itablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorFirst" /*@C NEPMonitorFirst - Print the first unconverged approximate value and error estimate at each iteration of the nonlinear eigensolver. Collective on NEP Input Parameters: + nep - nonlinear eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: NEPMonitorSet(), NEPMonitorAll(), NEPMonitorConverged() @*/ PetscErrorCode NEPMonitorFirst(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(vf,8); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); if (its==1 && ((PetscObject)nep)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)nep)->prefix);CHKERRQ(ierr); } if (nconvformat);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%3D NEP nconv=%D first unconverged value (error)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(eigr[nconv]),(double)PetscImaginaryPart(eigr[nconv]));CHKERRQ(ierr); #else ierr = PetscViewerASCIIPrintf(viewer," %g",(double)eigr[nconv]);CHKERRQ(ierr); if (eigi[nconv]!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+gi",(double)eigi[nconv]);CHKERRQ(ierr); } #endif ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)nep)->tablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorConverged" /*@C NEPMonitorConverged - Print the approximate values and error estimates as they converge. Collective on NEP Input Parameters: + nep - nonlinear eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - ctx - monitor context Level: intermediate .seealso: NEPMonitorSet(), NEPMonitorFirst(), NEPMonitorAll() @*/ PetscErrorCode NEPMonitorConverged(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx) { PetscErrorCode ierr; PetscInt i; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(ctx,8); viewer = ctx->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); if (its==1 && ((PetscObject)nep)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Convergence history for %s solve.\n",((PetscObject)nep)->prefix);CHKERRQ(ierr); } if (its==1) ctx->oldnconv = 0; if (ctx->oldnconv!=nconv) { ierr = PetscViewerPushFormat(viewer,ctx->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)nep)->tablevel);CHKERRQ(ierr); for (i=ctx->oldnconv;itablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ctx->oldnconv = nconv; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorLGCreate" /*@C NEPMonitorLGCreate - Creates a line graph context for use with NEP to monitor convergence. Collective on MPI_Comm Input Parameters: + comm - communicator context . host - the X display to open, or null for the local machine . label - the title to put in the title bar . x, y - the screen coordinates of the upper left coordinate of the window - m, n - the screen width and height in pixels Output Parameter: . lgctx - the drawing context Options Database Keys: + -nep_monitor_lg - Sets line graph monitor for the first residual - -nep_monitor_lg_all - Sets line graph monitor for all residuals Notes: Use PetscDrawLGDestroy() to destroy this line graph. Level: intermediate .seealso: NEPMonitorSet() @*/ PetscErrorCode NEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx) { PetscDraw draw; PetscDrawLG lg; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscDrawCreate(comm,host,label,x,y,m,n,&draw);CHKERRQ(ierr); ierr = PetscDrawSetFromOptions(draw);CHKERRQ(ierr); ierr = PetscDrawLGCreate(draw,1,&lg);CHKERRQ(ierr); ierr = PetscDrawLGSetFromOptions(lg);CHKERRQ(ierr); ierr = PetscDrawDestroy(&draw);CHKERRQ(ierr); *lgctx = lg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorLG" PetscErrorCode NEPMonitorLG(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscReal x,y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,1);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(nep->tol)-2,0.0);CHKERRQ(ierr); } x = (PetscReal)its; if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]); else y = 0.0; ierr = PetscDrawLGAddPoint(lg,&x,&y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || nep->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPMonitorLGAll" PetscErrorCode NEPMonitorLGAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscInt i,n = PetscMin(nep->nev,255); PetscReal *x,*y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,n);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(nep->tol)-2,0.0);CHKERRQ(ierr); } ierr = PetscMalloc2(n,&x,n,&y);CHKERRQ(ierr); for (i=0;i 0.0) y[i] = PetscLog10Real(errest[i]); else y[i] = 0.0; } ierr = PetscDrawLGAddPoint(lg,x,y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || nep->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } ierr = PetscFree2(x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/interface/ftn-custom/0000755000175000017500000000000013107004621017573 5ustar jromanjromanslepc-3.7.4/src/nep/interface/ftn-custom/makefile0000644000175000017500000000221113107004621021267 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = znepf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcnep LOCDIR = src/nep/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/interface/ftn-custom/znepf.c0000644000175000017500000003516013107004621021066 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define nepview_ NEPVIEW #define neperrorview_ NEPERRORVIEW #define nepreasonview_ NEPREASONVIEW #define nepvaluesview_ NEPVALUESVIEW #define nepvectorsview_ NEPVECTORSVIEW #define nepsetoptionsprefix_ NEPSETOPTIONSPREFIX #define nepappendoptionsprefix_ NEPAPPENDOPTIONSPREFIX #define nepgetoptionsprefix_ NEPGETOPTIONSPREFIX #define nepsettype_ NEPSETTYPE #define nepgettype_ NEPGETTYPE #define nepmonitorall_ NEPMONITORALL #define nepmonitorlg_ NEPMONITORLG #define nepmonitorlgall_ NEPMONITORLGALL #define nepmonitorset_ NEPMONITORSET #define nepmonitorconverged_ NEPMONITORCONVERGED #define nepmonitorfirst_ NEPMONITORFIRST #define nepconvergedabsolute_ NEPCONVERGEDABSOLUTE #define nepconvergedrelative_ NEPCONVERGEDRELATIVE #define nepsetconvergencetestfunction_ NEPSETCONVERGENCETESTFUNCTION #define nepsetstoppingtestfunction_ NEPSETSTOPPINGTESTFUNCTION #define nepseteigenvaluecomparison_ NEPSETEIGENVALUECOMPARISON #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define nepview_ nepview #define neperrorview_ neperrorview #define nepreasonview_ nepreasonview #define nepvaluesview_ nepvaluesview #define nepvectorsview_ nepvectorsview #define nepsetoptionsprefix_ nepsetoptionsprefix #define nepappendoptionsprefix_ nepappendoptionsprefix #define nepgetoptionsprefix_ nepgetoptionsprefix #define nepsettype_ nepsettype #define nepgettype_ nepgettype #define nepmonitorall_ nepmonitorall #define nepmonitorlg_ nepmonitorlg #define nepmonitorlgall_ nepmonitorlgall #define nepmonitorset_ nepmonitorset #define nepmonitorconverged_ nepmonitorconverged #define nepmonitorfirst_ nepmonitorfirst #define nepconvergedabsolute_ nepconvergedabsolute #define nepconvergedrelative_ nepconvergedrelative #define nepsetconvergencetestfunction_ nepsetconvergencetestfunction #define nepsetstoppingtestfunction_ nepsetstoppingtestfunction #define nepseteigenvaluecomparison_ nepseteigenvaluecomparison #endif /* These are not usually called from Fortran but allow Fortran users to transparently set these monitors from .F code, hence no STDCALL */ PETSC_EXTERN void nepmonitorall_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = NEPMonitorAll(*nep,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void nepmonitorconverged_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr) { *ierr = NEPMonitorConverged(*nep,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void nepmonitorfirst_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = NEPMonitorFirst(*nep,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void nepmonitorlg_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = NEPMonitorLG(*nep,*it,*nconv,eigr,eigi,errest,*nest,ctx); } PETSC_EXTERN void nepmonitorlgall_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = NEPMonitorLGAll(*nep,*it,*nconv,eigr,eigi,errest,*nest,ctx); } static struct { PetscFortranCallbackId monitor; PetscFortranCallbackId monitordestroy; PetscFortranCallbackId convergence; PetscFortranCallbackId convdestroy; PetscFortranCallbackId stopping; PetscFortranCallbackId stopdestroy; PetscFortranCallbackId comparison; } _cb; /* These are not extern C because they are passed into non-extern C user level functions */ #undef __FUNCT__ #define __FUNCT__ "ourmonitor" static PetscErrorCode ourmonitor(NEP nep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx) { PetscObjectUseFortranCallback(nep,_cb.monitor,(NEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),(&nep,&i,&nc,er,ei,d,&l,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourdestroy" static PetscErrorCode ourdestroy(void** ctx) { NEP nep = (NEP)*ctx; PetscObjectUseFortranCallback(nep,_cb.monitordestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvergence" static PetscErrorCode ourconvergence(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscObjectUseFortranCallback(nep,_cb.convergence,(NEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),(&nep,&eigr,&eigi,&res,errest,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvdestroy" static PetscErrorCode ourconvdestroy(void *ctx) { NEP nep = (NEP)ctx; PetscObjectUseFortranCallback(nep,_cb.convdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopping" static PetscErrorCode ourstopping(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx) { PetscObjectUseFortranCallback(nep,_cb.stopping,(NEP*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,NEPConvergedReason*,void*,PetscErrorCode*),(&nep,&its,&max_it,&nconv,&nev,reason,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopdestroy" static PetscErrorCode ourstopdestroy(void *ctx) { NEP nep = (NEP)ctx; PetscObjectUseFortranCallback(nep,_cb.stopdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "oureigenvaluecomparison" static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx) { NEP eps = (NEP)ctx; PetscObjectUseFortranCallback(eps,_cb.comparison,(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*,PetscErrorCode*),(&ar,&ai,&br,&bi,r,_ctx,&ierr)); } PETSC_EXTERN void PETSC_STDCALL nepview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = NEPView(*nep,v); } PETSC_EXTERN void PETSC_STDCALL nepreasonview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = NEPReasonView(*nep,v); } PETSC_EXTERN void PETSC_STDCALL neperrorview_(NEP *nep,NEPErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = NEPErrorView(*nep,*etype,v); } PETSC_EXTERN void PETSC_STDCALL nepvaluesview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = NEPValuesView(*nep,v); } PETSC_EXTERN void PETSC_STDCALL nepvectorsview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = NEPVectorsView(*nep,v); } PETSC_EXTERN void PETSC_STDCALL nepsettype_(NEP *nep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = NEPSetType(*nep,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL nepgettype_(NEP *nep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { NEPType tname; *ierr = NEPGetType(*nep,&tname);if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL nepsetoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = NEPSetOptionsPrefix(*nep,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL nepappendoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = NEPAppendOptionsPrefix(*nep,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL nepgetoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = NEPGetOptionsPrefix(*nep,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL nepmonitorset_(NEP *nep,void (PETSC_STDCALL *monitor)(NEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(mctx); CHKFORTRANNULLFUNCTION(monitordestroy); if ((PetscVoidFunction)monitor == (PetscVoidFunction)nepmonitorall_) { *ierr = NEPMonitorSet(*nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))NEPMonitorAll,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)nepmonitorconverged_) { *ierr = NEPMonitorSet(*nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))NEPMonitorConverged,*(SlepcConvMonitor*)mctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)nepmonitorfirst_) { *ierr = NEPMonitorSet(*nep,(PetscErrorCode (*)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))NEPMonitorFirst,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)nepmonitorlg_) { *ierr = NEPMonitorSet(*nep,NEPMonitorLG,0,0); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)nepmonitorlgall_) { *ierr = NEPMonitorSet(*nep,NEPMonitorLGAll,0,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*nep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitor,(PetscVoidFunction)monitor,mctx); if (*ierr) return; if (!monitordestroy) { *ierr = NEPMonitorSet(*nep,ourmonitor,*nep,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*nep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitordestroy,(PetscVoidFunction)monitordestroy,mctx); if (*ierr) return; *ierr = NEPMonitorSet(*nep,ourmonitor,*nep,ourdestroy); } } } PETSC_EXTERN void PETSC_STDCALL nepconvergedabsolute_(NEP *nep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = NEPConvergedAbsolute(*nep,*eigr,*eigi,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL nepconvergedrelative_(NEP *nep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = NEPConvergedRelative(*nep,*eigr,*eigi,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL nepsetconvergencetestfunction_(NEP *nep,void (PETSC_STDCALL *func)(NEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)nepconvergedabsolute_) { *ierr = NEPSetConvergenceTest(*nep,NEP_CONV_ABS); } else if ((PetscVoidFunction)func == (PetscVoidFunction)nepconvergedrelative_) { *ierr = NEPSetConvergenceTest(*nep,NEP_CONV_REL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*nep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convergence,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = NEPSetConvergenceTestFunction(*nep,ourconvergence,*nep,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*nep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = NEPSetConvergenceTestFunction(*nep,ourconvergence,*nep,ourconvdestroy); } } } PETSC_EXTERN void PETSC_STDCALL nepstoppingbasic_(NEP *nep,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,NEPConvergedReason *reason,void *ctx,PetscErrorCode *ierr) { *ierr = NEPStoppingBasic(*nep,*its,*max_it,*nconv,*nev,reason,ctx); } PETSC_EXTERN void PETSC_STDCALL nepsetstoppingtestfunction_(NEP *nep,void (PETSC_STDCALL *func)(NEP*,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)nepstoppingbasic_) { *ierr = NEPSetStoppingTest(*nep,NEP_STOP_BASIC); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*nep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopping,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = NEPSetStoppingTestFunction(*nep,ourstopping,*nep,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*nep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = NEPSetStoppingTestFunction(*nep,ourstopping,*nep,ourstopdestroy); } } } PETSC_EXTERN void PETSC_STDCALL nepseteigenvaluecomparison_(NEP *nep,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); *ierr = PetscObjectSetFortranCallback((PetscObject)*nep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.comparison,(PetscVoidFunction)func,ctx); if (*ierr) return; *ierr = NEPSetEigenvalueComparison(*nep,oureigenvaluecomparison,*nep); } slepc-3.7.4/src/nep/interface/nepregis.c0000644000175000017500000000406113107004621017455 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ PETSC_EXTERN PetscErrorCode NEPCreate_RII(NEP); PETSC_EXTERN PetscErrorCode NEPCreate_SLP(NEP); PETSC_EXTERN PetscErrorCode NEPCreate_NArnoldi(NEP); PETSC_EXTERN PetscErrorCode NEPCreate_CISS(NEP); PETSC_EXTERN PetscErrorCode NEPCreate_Interpol(NEP); PETSC_EXTERN PetscErrorCode NEPCreate_NLEIGS(NEP); #undef __FUNCT__ #define __FUNCT__ "NEPRegisterAll" /*@C NEPRegisterAll - Registers all the solvers in the NEP package. Not Collective Level: advanced .seealso: NEPRegister() @*/ PetscErrorCode NEPRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (NEPRegisterAllCalled) PetscFunctionReturn(0); NEPRegisterAllCalled = PETSC_TRUE; ierr = NEPRegister(NEPRII,NEPCreate_RII);CHKERRQ(ierr); ierr = NEPRegister(NEPSLP,NEPCreate_SLP);CHKERRQ(ierr); ierr = NEPRegister(NEPNARNOLDI,NEPCreate_NArnoldi);CHKERRQ(ierr); ierr = NEPRegister(NEPINTERPOL,NEPCreate_Interpol);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = NEPRegister(NEPCISS,NEPCreate_CISS);CHKERRQ(ierr); #endif ierr = NEPRegister(NEPNLEIGS,NEPCreate_NLEIGS);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/examples/0000755000175000017500000000000013107004621015352 5ustar jromanjromanslepc-3.7.4/src/nep/examples/makefile0000644000175000017500000000202513107004621017051 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/nep/examples/ DIRS = tests tutorials nlevp include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/examples/makefile.html0000644000175000017500000000443213107004621020020 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/nep/examples/
DIRS     = tests tutorials nlevp

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/nep/examples/nlevp/0000755000175000017500000000000013107004621016476 5ustar jromanjromanslepc-3.7.4/src/nep/examples/nlevp/makefile0000644000175000017500000000455213107004621020204 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/nep/examples/nlevp/ EXAMPLESC = loaded_string.c gun.c EXAMPLESF = MANSEC = NEP TESTS = loaded_string gun TESTEXAMPLES_C = loaded_string.PETSc runloaded_string loaded_string.rm TESTEXAMPLES_DATAFILESPATH_COMPLEX = gun.PETSc rungun gun.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common loaded_string: loaded_string.o chkopts -${CLINKER} -o loaded_string loaded_string.o ${SLEPC_NEP_LIB} ${RM} loaded_string.o gun: gun.o chkopts -${CLINKER} -o gun gun.o ${SLEPC_NEP_LIB} ${RM} gun.o #------------------------------------------------------------------------------------ runloaded_string: -@${MPIEXEC} -n 1 ./loaded_string -nep_type rii -n 100 -terse > loaded_string_1.tmp 2>&1; \ if (${DIFF} output/loaded_string_1.out loaded_string_1.tmp) then true; \ else echo "Possible problem with loaded_string_1, diffs above"; fi; \ ${RM} -f loaded_string_1.tmp rungun: -@${MPIEXEC} -n 1 ./gun -K $(DATAFILESPATH)/matrices/complex/gun_K.petsc -M $(DATAFILESPATH)/matrices/complex/gun_M.petsc -W1 $(DATAFILESPATH)/matrices/complex/gun_W1.petsc -W2 $(DATAFILESPATH)/matrices/complex/gun_W2.petsc -nep_type nleigs -rg_type interval -rg_interval_endpoints 12500,120500,-1,25000 -nep_target 65000 -nep_nev 4 -nep_tol 1e-12 -terse > gun_1.tmp 2>&1; \ if (${DIFF} output/gun_1.out gun_1.tmp) then true; \ else echo "Possible problem with gun_1, diffs above"; fi; \ ${RM} -f gun_1.tmp; slepc-3.7.4/src/nep/examples/nlevp/loaded_string.c0000644000175000017500000001445713107004621021473 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The loaded_string problem is a rational eigenvalue problem for the finite element model of a loaded vibrating string. */ static char help[] = "Finite element model of a loaded vibrating string.\n\n" "The command line options are:\n" " -n , dimension of the matrices.\n" " -kappa , stiffness of elastic spring.\n" " -mass , mass of the attached load.\n\n"; #include #define NMAT 3 #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A[NMAT]; /* problem matrices */ FN f[NMAT]; /* functions to define the nonlinear operator */ NEP nep; /* nonlinear eigensolver context */ PetscInt n=20,Istart,Iend,i; PetscReal kappa=1.0,m=1.0; PetscScalar sigma,numer[2],denom[2]; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-kappa",&kappa,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-mass",&m,NULL);CHKERRQ(ierr); sigma = kappa/m; ierr = PetscPrintf(PETSC_COMM_WORLD,"Loaded vibrating string, n=%D kappa=%g m=%g\n\n",n,(double)kappa,(double)m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Build the problem matrices - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* initialize matrices */ for (i=0;i0) { ierr = MatSetValue(A[0],i,i-1,-1.0*n,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[1],i,i-1,1.0/(6.0*n),INSERT_VALUES);CHKERRQ(ierr); } if (i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/nep/examples/nlevp/
EXAMPLESC  = loaded_string.c gun.c
EXAMPLESF  = 
MANSEC     = NEP
TESTS      = loaded_string gun

TESTEXAMPLES_C = loaded_string.PETSc runloaded_string loaded_string.rm
TESTEXAMPLES_DATAFILESPATH_COMPLEX = gun.PETSc rungun gun.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

loaded_string: loaded_string.o chkopts
	-${CLINKER} -o loaded_string loaded_string.o ${SLEPC_NEP_LIB}
	${RM} loaded_string.o

gun: gun.o chkopts
	-${CLINKER} -o gun gun.o ${SLEPC_NEP_LIB}
	${RM} gun.o

#------------------------------------------------------------------------------------
runloaded_string:
	-@${MPIEXEC} -n 1 ./loaded_string -nep_type rii -n 100 -terse > loaded_string_1.tmp 2>&1; \
	   if (${DIFF} output/loaded_string_1.out loaded_string_1.tmp) then true; \
	   else echo "Possible problem with loaded_string_1, diffs above"; fi; \
	   ${RM} -f loaded_string_1.tmp

rungun:
	-@${MPIEXEC} -n 1 ./gun -K $(DATAFILESPATH)/matrices/complex/gun_K.petsc -M $(DATAFILESPATH)/matrices/complex/gun_M.petsc -W1 $(DATAFILESPATH)/matrices/complex/gun_W1.petsc -W2 $(DATAFILESPATH)/matrices/complex/gun_W2.petsc -nep_type nleigs -rg_type interval -rg_interval_endpoints 12500,120500,-1,25000 -nep_target 65000 -nep_nev 4 -nep_tol 1e-12 -terse > gun_1.tmp 2>&1; \
	   if (${DIFF} output/gun_1.out gun_1.tmp) then true; \
	   else echo "Possible problem with gun_1, diffs above"; fi; \
	   ${RM} -f gun_1.tmp;

slepc-3.7.4/src/nep/examples/nlevp/loaded_string.c.html0000644000175000017500000003320013107004621022421 0ustar jromanjroman
Actual source code: loaded_string.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The loaded_string problem is a rational eigenvalue problem for the
 30:    finite element model of a loaded vibrating string.
 31: */

 33: static char help[] = "Finite element model of a loaded vibrating string.\n\n"
 34:   "The command line options are:\n"
 35:   "  -n <n>, dimension of the matrices.\n"
 36:   "  -kappa <kappa>, stiffness of elastic spring.\n"
 37:   "  -mass <m>, mass of the attached load.\n\n";

 39: #include <slepcnep.h>

 41: #define NMAT 3

 45: int main(int argc,char **argv)
 46: {
 47:   Mat            A[NMAT];         /* problem matrices */
 48:   FN             f[NMAT];         /* functions to define the nonlinear operator */
 49:   NEP            nep;             /* nonlinear eigensolver context */
 50:   PetscInt       n=20,Istart,Iend,i;
 51:   PetscReal      kappa=1.0,m=1.0;
 52:   PetscScalar    sigma,numer[2],denom[2];
 53:   PetscBool      terse;

 56:   SlepcInitialize(&argc,&argv,(char*)0,help);

 58:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 59:   PetscOptionsGetReal(NULL,NULL,"-kappa",&kappa,NULL);
 60:   PetscOptionsGetReal(NULL,NULL,"-mass",&m,NULL);
 61:   sigma = kappa/m;
 62:   PetscPrintf(PETSC_COMM_WORLD,"Loaded vibrating string, n=%D kappa=%g m=%g\n\n",n,(double)kappa,(double)m);

 64:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 65:                        Build the problem matrices 
 66:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 68:   /* initialize matrices */
 69:   for (i=0;i<NMAT;i++) {
 70:     MatCreate(PETSC_COMM_WORLD,&A[i]);
 71:     MatSetSizes(A[i],PETSC_DECIDE,PETSC_DECIDE,n,n);
 72:     MatSetFromOptions(A[i]);
 73:     MatSetUp(A[i]);
 74:   }
 75:   MatGetOwnershipRange(A[0],&Istart,&Iend);

 77:   /* A0 */
 78:   for (i=Istart;i<Iend;i++) {
 79:     MatSetValue(A[0],i,i,(i==n-1)?1.0*n:2.0*n,INSERT_VALUES);
 80:     if (i>0) { MatSetValue(A[0],i,i-1,-1.0*n,INSERT_VALUES); }
 81:     if (i<n-1) { MatSetValue(A[0],i,i+1,-1.0*n,INSERT_VALUES); }
 82:   }

 84:   /* A1 */

 86:   for (i=Istart;i<Iend;i++) {
 87:     MatSetValue(A[1],i,i,(i==n-1)?2.0/(6.0*n):4.0/(6.0*n),INSERT_VALUES);
 88:     if (i>0) { MatSetValue(A[1],i,i-1,1.0/(6.0*n),INSERT_VALUES); }
 89:     if (i<n-1) { MatSetValue(A[1],i,i+1,1.0/(6.0*n),INSERT_VALUES); }
 90:   }

 92:   /* A2 */
 93:   if (Istart<=n-1 && n-1<Iend) {
 94:     MatSetValue(A[2],n-1,n-1,kappa,INSERT_VALUES); 
 95:   }

 97:   /* assemble matrices */
 98:   for (i=0;i<NMAT;i++) {
 99:     MatAssemblyBegin(A[i],MAT_FINAL_ASSEMBLY);
100:   }
101:   for (i=0;i<NMAT;i++) {
102:     MatAssemblyEnd(A[i],MAT_FINAL_ASSEMBLY);
103:   }

105:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
106:                        Create the problem functions
107:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

109:   /* f1=1 */
110:   FNCreate(PETSC_COMM_WORLD,&f[0]);
111:   FNSetType(f[0],FNRATIONAL);
112:   numer[0] = 1.0;
113:   FNRationalSetNumerator(f[0],1,numer);

115:   /* f2=-lambda */
116:   FNCreate(PETSC_COMM_WORLD,&f[1]);
117:   FNSetType(f[1],FNRATIONAL);
118:   numer[0] = -1.0; numer[1] = 0.0;
119:   FNRationalSetNumerator(f[1],2,numer);

121:   /* f3=lambda/(lambda-sigma) */
122:   FNCreate(PETSC_COMM_WORLD,&f[2]);
123:   FNSetType(f[2],FNRATIONAL);
124:   numer[0] = 1.0; numer[1] = 0.0;
125:   denom[0] = 1.0; denom[1] = -sigma;
126:   FNRationalSetNumerator(f[2],2,numer);
127:   FNRationalSetDenominator(f[2],2,denom);

129:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
130:                 Create the eigensolver and solve the problem
131:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

133:   NEPCreate(PETSC_COMM_WORLD,&nep);
134:   NEPSetSplitOperator(nep,3,A,f,SUBSET_NONZERO_PATTERN);
135:   NEPSetFromOptions(nep);
136:   NEPSolve(nep);

138:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139:                     Display solution and clean up
140:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
141:   
142:   /* show detailed info unless -terse option is given by user */
143:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
144:   if (terse) {
145:     NEPErrorView(nep,NEP_ERROR_RELATIVE,NULL);
146:   } else {
147:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
148:     NEPReasonView(nep,PETSC_VIEWER_STDOUT_WORLD);
149:     NEPErrorView(nep,NEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
150:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
151:   }
152:   NEPDestroy(&nep);
153:   for (i=0;i<NMAT;i++) {
154:     MatDestroy(&A[i]);
155:     FNDestroy(&f[i]);
156:   }
157:   SlepcFinalize();
158:   return ierr;
159: }
slepc-3.7.4/src/nep/examples/nlevp/output/0000755000175000017500000000000013107004621020036 5ustar jromanjromanslepc-3.7.4/src/nep/examples/nlevp/output/gun_1.out0000644000175000017500000000026413107004621021602 0ustar jromanjromanGUN problem All requested eigenvalues computed up to the required tolerance: 54550.13915+459.51716i, 75402.85311+4948.34882i, 77240.79035+143.90139i, 80991.85642+32.38708i slepc-3.7.4/src/nep/examples/nlevp/output/loaded_string_1.out0000644000175000017500000000017613107004621023631 0ustar jromanjromanLoaded vibrating string, n=100 kappa=1. m=1. All requested eigenvalues computed up to the required tolerance: 4.48218 slepc-3.7.4/src/nep/examples/nlevp/index.html0000644000175000017500000000325513107004621020500 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

loaded_string.c: Finite element model of a loaded vibrating string
gun.c: Radio-frequency gun cavity
makefile
slepc-3.7.4/src/nep/examples/nlevp/gun.c.html0000644000175000017500000003753313107004621020411 0ustar jromanjroman

Actual source code: gun.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The gun problem arises from model of a radio-frequency gun cavity, with
 30:    the complex nonlinear function
 31:    T(lambda) = K-lambda*M+i*lambda^(1/2)*W1+i*(lambda-108.8774^2)^(1/2)*W2

 33:    Data files can be downloaded from http://slepc.upv.es/datafiles
 34: */

 36: static char help[] = "Radio-frequency gun cavity.\n\n"
 37:   "The command line options are:\n"
 38:   "-K <filename1> -M <filename2> -W1 <filename3> -W2 <filename4>, where filename1,..,filename4 are files containing the matrices in PETSc binary form defining the GUN problem.\n\n";

 40: #include <slepcnep.h>

 42: #define NMAT 4
 43: #define SIGMA 108.8774

 45: PetscErrorCode ComputeSingularities(NEP,PetscInt*,PetscScalar*,void*);

 49: int main(int argc,char **argv)
 50: {
 52:   Mat            A[NMAT];         /* problem matrices */
 53:   FN             f[NMAT];         /* functions to define the nonlinear operator */
 54:   FN             ff[2];           /* auxiliary functions to define the nonlinear operator */
 55:   NEP            nep;             /* nonlinear eigensolver context */
 56:   PetscBool      terse,flg;
 57:   const char*    string[NMAT]={"-K","-M","-W1","-W2"};
 58:   char           filename[PETSC_MAX_PATH_LEN];
 59:   PetscScalar    numer[2],sigma;
 60:   PetscInt       i;
 61:   PetscViewer    viewer;

 63:   SlepcInitialize(&argc,&argv,(char*)0,help);

 65:   PetscPrintf(PETSC_COMM_WORLD,"GUN problem\n\n");
 66: #if !defined(PETSC_USE_COMPLEX)
 67:   SETERRQ(PETSC_COMM_SELF,1,"This example requires complex scalars!");
 68: #endif

 70:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 71:                        Load the problem matrices 
 72:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 74:   for (i=0;i<NMAT;i++) {
 75:     PetscOptionsGetString(NULL,NULL,string[i],filename,PETSC_MAX_PATH_LEN,&flg);
 76:     if (!flg) SETERRQ1(PETSC_COMM_WORLD,1,"Must indicate a filename with the %s option",string[i]);
 77:     PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 78:     MatCreate(PETSC_COMM_WORLD,&A[i]);
 79:     MatSetFromOptions(A[i]);
 80:     MatLoad(A[i],viewer);
 81:     PetscViewerDestroy(&viewer);
 82:   }

 84:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 85:                        Create the problem functions
 86:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 88:   /* f1=1 */
 89:   FNCreate(PETSC_COMM_WORLD,&f[0]);
 90:   FNSetType(f[0],FNRATIONAL);
 91:   numer[0] = 1.0;
 92:   FNRationalSetNumerator(f[0],1,numer);

 94:   /* f2=-lambda */
 95:   FNCreate(PETSC_COMM_WORLD,&f[1]);
 96:   FNSetType(f[1],FNRATIONAL);
 97:   numer[0] = -1.0; numer[1] = 0.0;
 98:   FNRationalSetNumerator(f[1],2,numer);

100:   /* f3=i*sqrt(lambda) */
101:   FNCreate(PETSC_COMM_WORLD,&f[2]);
102:   FNSetType(f[2],FNSQRT);
103:   FNSetScale(f[2],1.0,PETSC_i);

105:   /* f4=i*sqrt(lambda-sigma^2) */
106:   sigma = SIGMA*SIGMA;
107:   FNCreate(PETSC_COMM_WORLD,&ff[0]);
108:   FNSetType(ff[0],FNSQRT);
109:   FNCreate(PETSC_COMM_WORLD,&ff[1]);
110:   FNSetType(ff[1],FNRATIONAL);
111:   numer[0] = 1.0; numer[1] = -sigma;
112:   FNRationalSetNumerator(ff[1],2,numer);
113:   FNCreate(PETSC_COMM_WORLD,&f[3]);
114:   FNSetType(f[3],FNCOMBINE);
115:   FNCombineSetChildren(f[3],FN_COMBINE_COMPOSE,ff[1],ff[0]);
116:   FNSetScale(f[3],1.0,PETSC_i);

118:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
119:                 Create the eigensolver and solve the problem
120:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

122:   NEPCreate(PETSC_COMM_WORLD,&nep);
123:   NEPSetSplitOperator(nep,4,A,f,DIFFERENT_NONZERO_PATTERN);
124:   NEPSetFromOptions(nep);

126:   PetscObjectTypeCompare((PetscObject)nep,NEPNLEIGS,&flg);
127:   if (flg) {
128:     NEPNLEIGSSetSingularitiesFunction(nep,ComputeSingularities,NULL);
129:   }

131:   NEPSolve(nep);

133:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134:                     Display solution and clean up
135:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
136:   
137:   /* show detailed info unless -terse option is given by user */
138:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
139:   if (terse) {
140:     NEPErrorView(nep,NEP_ERROR_RELATIVE,NULL);
141:   } else {
142:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
143:     NEPReasonView(nep,PETSC_VIEWER_STDOUT_WORLD);
144:     NEPErrorView(nep,NEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
145:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
146:   }
147:   NEPDestroy(&nep);
148:   for (i=0;i<NMAT;i++) {
149:     MatDestroy(&A[i]);
150:     FNDestroy(&f[i]);
151:   }
152:   for (i=0;i<2;i++) {
153:     FNDestroy(&ff[i]);
154:   }
155:   SlepcFinalize();
156:   return ierr;
157: }

161: /*
162:    ComputeSingularities - Computes maxnp points (at most) in the complex plane where
163:    the function T(.) is not analytic.

165:    In this case, we discretize the singularity region (-inf,108.8774^2)~(-10e+12,-10e-12+108.8774^2) 
166: */
167: PetscErrorCode ComputeSingularities(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *pt)
168: {
169:   PetscReal h;
170:   PetscInt  i;
171:   PetscReal   sigma,end;

174:   sigma = SIGMA*SIGMA;
175:   end = PetscLogReal(sigma);  
176:   h = (12.0+end)/(*maxnp-1);
177:   xi[0] = sigma;
178:   for (i=1;i<*maxnp;i++) xi[i] = -PetscPowReal(10,h*i)+sigma;
179:   return(0);
180: }
slepc-3.7.4/src/nep/examples/nlevp/gun.c0000644000175000017500000001615113107004621017437 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The gun problem arises from model of a radio-frequency gun cavity, with the complex nonlinear function T(lambda) = K-lambda*M+i*lambda^(1/2)*W1+i*(lambda-108.8774^2)^(1/2)*W2 Data files can be downloaded from http://slepc.upv.es/datafiles */ static char help[] = "Radio-frequency gun cavity.\n\n" "The command line options are:\n" "-K -M -W1 -W2 , where filename1,..,filename4 are files containing the matrices in PETSc binary form defining the GUN problem.\n\n"; #include #define NMAT 4 #define SIGMA 108.8774 PetscErrorCode ComputeSingularities(NEP,PetscInt*,PetscScalar*,void*); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Mat A[NMAT]; /* problem matrices */ FN f[NMAT]; /* functions to define the nonlinear operator */ FN ff[2]; /* auxiliary functions to define the nonlinear operator */ NEP nep; /* nonlinear eigensolver context */ PetscBool terse,flg; const char* string[NMAT]={"-K","-M","-W1","-W2"}; char filename[PETSC_MAX_PATH_LEN]; PetscScalar numer[2],sigma; PetscInt i; PetscViewer viewer; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscPrintf(PETSC_COMM_WORLD,"GUN problem\n\n");CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) SETERRQ(PETSC_COMM_SELF,1,"This example requires complex scalars!"); #endif /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load the problem matrices - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ for (i=0;i. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/nep/examples/tutorials/ EXAMPLESC = ex20.c ex21.c ex22.c ex27.c EXAMPLESF = MANSEC = NEP TESTEXAMPLES_C = ex21.PETSc runex21_1 ex21.rm \ ex22.PETSc runex22_1 ex22.rm \ ex27.PETSc runex27_1 runex27_2 ex27.rm TESTEXAMPLES_C_COMPLEX = ex22.PETSc runex22_ciss_1 ex22.rm TESTEXAMPLES_F90 = include ${SLEPC_DIR}/lib/slepc/conf/slepc_common ex20: ex20.o chkopts -${CLINKER} -o ex20 ex20.o ${SLEPC_NEP_LIB} ${RM} ex20.o ex21: ex21.o chkopts -${CLINKER} -o ex21 ex21.o ${SLEPC_NEP_LIB} ${RM} ex21.o ex22: ex22.o chkopts -${CLINKER} -o ex22 ex22.o ${SLEPC_NEP_LIB} ${RM} ex22.o ex27: ex27.o chkopts -${CLINKER} -o ex27 ex27.o ${SLEPC_NEP_LIB} ${RM} ex27.o #------------------------------------------------------------------------------------ runex20_1: -@${MPIEXEC} -n 1 ./ex20 > ex20_1.tmp 2>&1; \ if (${DIFF} output/ex20_1.out ex20_1.tmp) then true; \ else echo "Possible problem with ex20_1, diffs above"; fi; \ ${RM} -f ex20_1.tmp runex21_1: -@${MPIEXEC} -n 1 ./ex21 -terse > ex21_1.tmp 2>&1; \ if (${DIFF} output/ex21_1.out ex21_1.tmp) then true; \ else echo "Possible problem with ex21_1, diffs above"; fi; \ ${RM} -f ex21_1.tmp runex22_1: -@${MPIEXEC} -n 1 ./ex22 -terse > ex22_1.tmp 2>&1; \ if (${DIFF} output/ex22_1.out ex22_1.tmp) then true; \ else echo "Possible problem with ex22_1, diffs above"; fi; \ ${RM} -f ex22_1.tmp runex22_ciss_1: -@${MPIEXEC} -n 1 ./ex22 -nep_type ciss -rg_type ellipse -rg_ellipse_center 10 -rg_ellipse_radius 9.5 -nep_ncv 24 -terse > ex22_ciss_1.tmp 2>&1; \ if (${DIFF} output/ex22_ciss_1.out ex22_ciss_1.tmp) then true; \ else echo "Possible problem with ex22_ciss_1, diffs above"; fi; \ ${RM} -f ex22_ciss_1.tmp runex27_1: -@${MPIEXEC} -n 1 ./ex27 -nep_nev 3 -terse > ex27_1.tmp 2>&1; \ if (${DIFF} output/ex27_1.out ex27_1.tmp) then true; \ else echo "Possible problem with ex27_1, diffs above"; fi; \ ${RM} -f ex27_1.tmp runex27_2: -@${MPIEXEC} -n 1 ./ex27 -split 0 -nep_nev 3 -terse > ex27_2.tmp 2>&1; \ if (${DIFF} output/ex27_2.out ex27_2.tmp) then true; \ else echo "Possible problem with ex27_2, diffs above"; fi; \ ${RM} -f ex27_2.tmp slepc-3.7.4/src/nep/examples/tutorials/ex22.c0000644000175000017500000001736513107004621020340 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Delay differential equation.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions.\n" " -tau , where is the delay parameter.\n\n"; /* Solve parabolic partial differential equation with time delay tau u_t = u_xx + a*u(t) + b*u(t-tau) u(0,t) = u(pi,t) = 0 with a = 20 and b(x) = -4.1+x*(1-exp(x-pi)). Discretization leads to a DDE of dimension n -u' = A*u(t) + B*u(t-tau) which results in the nonlinear eigenproblem (-lambda*I + A + exp(-tau*lambda)*B)*u = 0 */ #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { NEP nep; /* nonlinear eigensolver context */ Mat Id,A,B; /* problem matrices */ FN f1,f2,f3; /* functions to define the nonlinear operator */ Mat mats[3]; FN funs[3]; NEPType type; PetscScalar coeffs[2],b; PetscInt n=128,nev,Istart,Iend,i; PetscReal tau=0.001,h,a=20,xi; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-tau",&tau,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Delay Eigenproblem, n=%D, tau=%g\n\n",n,(double)tau);CHKERRQ(ierr); h = PETSC_PI/(PetscReal)(n+1); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create nonlinear eigensolver context - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPCreate(PETSC_COMM_WORLD,&nep);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create problem matrices and coefficient functions. Pass them to NEP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Identity matrix */ ierr = MatCreate(PETSC_COMM_WORLD,&Id);CHKERRQ(ierr); ierr = MatSetSizes(Id,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(Id);CHKERRQ(ierr); ierr = MatSetUp(Id);CHKERRQ(ierr); ierr = MatGetOwnershipRange(Id,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES);CHKERRQ(ierr); } if (i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/nep/examples/tutorials/
EXAMPLESC  = ex20.c ex21.c ex22.c ex27.c
EXAMPLESF  =
MANSEC     = NEP

TESTEXAMPLES_C           = ex21.PETSc runex21_1 ex21.rm \
                           ex22.PETSc runex22_1 ex22.rm \
                           ex27.PETSc runex27_1 runex27_2 ex27.rm
TESTEXAMPLES_C_COMPLEX   = ex22.PETSc runex22_ciss_1 ex22.rm
TESTEXAMPLES_F90         =

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

ex20: ex20.o chkopts
	-${CLINKER} -o ex20 ex20.o ${SLEPC_NEP_LIB}
	${RM} ex20.o

ex21: ex21.o chkopts
	-${CLINKER} -o ex21 ex21.o ${SLEPC_NEP_LIB}
	${RM} ex21.o

ex22: ex22.o chkopts
	-${CLINKER} -o ex22 ex22.o ${SLEPC_NEP_LIB}
	${RM} ex22.o

ex27: ex27.o chkopts
	-${CLINKER} -o ex27 ex27.o ${SLEPC_NEP_LIB}
	${RM} ex27.o

#------------------------------------------------------------------------------------

runex20_1:
	-@${MPIEXEC} -n 1 ./ex20 > ex20_1.tmp 2>&1; \
	   if (${DIFF} output/ex20_1.out ex20_1.tmp) then true; \
	   else echo "Possible problem with ex20_1, diffs above"; fi; \
	   ${RM} -f ex20_1.tmp

runex21_1:
	-@${MPIEXEC} -n 1 ./ex21 -terse > ex21_1.tmp 2>&1; \
	   if (${DIFF} output/ex21_1.out ex21_1.tmp) then true; \
	   else echo "Possible problem with ex21_1, diffs above"; fi; \
	   ${RM} -f ex21_1.tmp

runex22_1:
	-@${MPIEXEC} -n 1 ./ex22 -terse > ex22_1.tmp 2>&1; \
	   if (${DIFF} output/ex22_1.out ex22_1.tmp) then true; \
	   else echo "Possible problem with ex22_1, diffs above"; fi; \
	   ${RM} -f ex22_1.tmp

runex22_ciss_1:
	-@${MPIEXEC} -n 1 ./ex22 -nep_type ciss -rg_type ellipse -rg_ellipse_center 10 -rg_ellipse_radius 9.5 -nep_ncv 24 -terse > ex22_ciss_1.tmp 2>&1; \
	   if (${DIFF} output/ex22_ciss_1.out ex22_ciss_1.tmp) then true; \
	   else echo "Possible problem with ex22_ciss_1, diffs above"; fi; \
	   ${RM} -f ex22_ciss_1.tmp

runex27_1:
	-@${MPIEXEC} -n 1 ./ex27 -nep_nev 3 -terse > ex27_1.tmp 2>&1; \
	   if (${DIFF} output/ex27_1.out ex27_1.tmp) then true; \
	   else echo "Possible problem with ex27_1, diffs above"; fi; \
	   ${RM} -f ex27_1.tmp

runex27_2:
	-@${MPIEXEC} -n 1 ./ex27 -split 0 -nep_nev 3 -terse > ex27_2.tmp 2>&1; \
	   if (${DIFF} output/ex27_2.out ex27_2.tmp) then true; \
	   else echo "Possible problem with ex27_2, diffs above"; fi; \
	   ${RM} -f ex27_2.tmp

slepc-3.7.4/src/nep/examples/tutorials/ex21.c.html0000644000175000017500000006451613107004621021302 0ustar jromanjroman
Actual source code: ex21.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Simple 1-D nonlinear eigenproblem (matrix-free version, sequential).\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions\n\n";

 26: /*
 27:    Solve 1-D PDE
 28:             -u'' = lambda*u
 29:    on [0,1] subject to
 30:             u(0)=0, u'(1)=u(1)*lambda*kappa/(kappa-lambda)
 31: */

 33: #include <slepcnep.h>

 35: /*
 36:    User-defined routines
 37: */
 38: PetscErrorCode FormInitialGuess(Vec);
 39: PetscErrorCode FormFunction(NEP,PetscScalar,Mat,Mat,void*);
 40: PetscErrorCode FormJacobian(NEP,PetscScalar,Mat,void*);

 42: /*
 43:    Matrix operations and context
 44: */
 45: PetscErrorCode MatMult_Fun(Mat,Vec,Vec);
 46: PetscErrorCode MatGetDiagonal_Fun(Mat,Vec);
 47: PetscErrorCode MatDestroy_Fun(Mat);
 48: PetscErrorCode MatDuplicate_Fun(Mat,MatDuplicateOption,Mat*);
 49: PetscErrorCode MatMult_Jac(Mat,Vec,Vec);
 50: PetscErrorCode MatDestroy_Jac(Mat);

 52: typedef struct {
 53:   PetscScalar lambda,kappa;
 54:   PetscReal   h;
 55: } MatCtx;

 57: /*
 58:    User-defined application context
 59: */
 60: typedef struct {
 61:   PetscScalar kappa;   /* ratio between stiffness of spring and attached mass */
 62:   PetscReal   h;       /* mesh spacing */
 63: } ApplicationCtx;

 67: int main(int argc,char **argv)
 68: {
 69:   NEP            nep;             /* nonlinear eigensolver context */
 70:   Mat            F,J;             /* Function and Jacobian matrices */
 71:   ApplicationCtx ctx;             /* user-defined context */
 72:   MatCtx         *ctxF,*ctxJ;     /* contexts for shell matrices */
 73:   NEPType        type;
 74:   PetscInt       n=128,nev;
 75:   KSP            ksp;
 76:   PC             pc;
 77:   PetscMPIInt    size;
 78:   PetscBool      terse;

 81:   SlepcInitialize(&argc,&argv,(char*)0,help);
 82:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 83:   if (size != 1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This is a uniprocessor example only!");
 84:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 85:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Nonlinear Eigenproblem, n=%D\n\n",n);
 86:   ctx.h = 1.0/(PetscReal)n;
 87:   ctx.kappa = 1.0;

 89:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 90:      Create nonlinear eigensolver context
 91:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 93:   NEPCreate(PETSC_COMM_WORLD,&nep);

 95:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 96:      Create matrix data structure; set Function evaluation routine
 97:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 99:   PetscNew(&ctxF);
100:   ctxF->h = ctx.h;
101:   ctxF->kappa = ctx.kappa;

103:   MatCreateShell(PETSC_COMM_WORLD,n,n,n,n,(void*)ctxF,&F);
104:   MatShellSetOperation(F,MATOP_MULT,(void(*)())MatMult_Fun);
105:   MatShellSetOperation(F,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Fun);
106:   MatShellSetOperation(F,MATOP_DESTROY,(void(*)())MatDestroy_Fun);
107:   MatShellSetOperation(F,MATOP_DUPLICATE,(void(*)())MatDuplicate_Fun);

109:   /*
110:      Set Function matrix data structure and default Function evaluation
111:      routine
112:   */
113:   NEPSetFunction(nep,F,F,FormFunction,NULL);

115:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
116:      Create matrix data structure; set Jacobian evaluation routine
117:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

119:   PetscNew(&ctxJ);
120:   ctxJ->h = ctx.h;
121:   ctxJ->kappa = ctx.kappa;

123:   MatCreateShell(PETSC_COMM_WORLD,n,n,n,n,(void*)ctxJ,&J);
124:   MatShellSetOperation(J,MATOP_MULT,(void(*)())MatMult_Jac);
125:   MatShellSetOperation(J,MATOP_DESTROY,(void(*)())MatDestroy_Jac);

127:   /*
128:      Set Jacobian matrix data structure and default Jacobian evaluation
129:      routine
130:   */
131:   NEPSetJacobian(nep,J,FormJacobian,NULL);

133:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134:      Customize nonlinear solver; set runtime options
135:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

137:   NEPSetType(nep,NEPRII);
138:   NEPRIISetLagPreconditioner(nep,0);
139:   NEPRIIGetKSP(nep,&ksp);
140:   KSPSetType(ksp,KSPBCGS);
141:   KSPGetPC(ksp,&pc);
142:   PCSetType(pc,PCJACOBI);

144:   /*
145:      Set solver parameters at runtime
146:   */
147:   NEPSetFromOptions(nep);

149:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
150:                       Solve the eigensystem
151:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

153:   NEPSolve(nep);
154:   NEPGetType(nep,&type);
155:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n",type);
156:   NEPGetDimensions(nep,&nev,NULL,NULL);
157:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

159:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
160:                     Display solution and clean up
161:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

163:   /* show detailed info unless -terse option is given by user */
164:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
165:   if (terse) {
166:     NEPErrorView(nep,NEP_ERROR_RELATIVE,NULL);
167:   } else {
168:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
169:     NEPReasonView(nep,PETSC_VIEWER_STDOUT_WORLD);
170:     NEPErrorView(nep,NEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
171:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
172:   }
173:   NEPDestroy(&nep);
174:   MatDestroy(&F);
175:   MatDestroy(&J);
176:   SlepcFinalize();
177:   return ierr;
178: }

180: /* ------------------------------------------------------------------- */
183: /*
184:    FormInitialGuess - Computes initial guess.

186:    Input/Output Parameter:
187: .  x - the solution vector
188: */
189: PetscErrorCode FormInitialGuess(Vec x)
190: {

194:   VecSet(x,1.0);
195:   return(0);
196: }

198: /* ------------------------------------------------------------------- */
201: /*
202:    FormFunction - Computes Function matrix  T(lambda)

204:    Input Parameters:
205: .  nep    - the NEP context
206: .  lambda - real part of the scalar argument
207: .  ctx    - optional user-defined context, as set by NEPSetFunction()

209:    Output Parameters:
210: .  fun - Function matrix
211: .  B   - optionally different preconditioning matrix
212: */
213: PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)
214: {
216:   MatCtx         *ctxF;

219:   MatShellGetContext(fun,(void**)&ctxF);
220:   ctxF->lambda = lambda;
221:   return(0);
222: }

224: /* ------------------------------------------------------------------- */
227: /*
228:    FormJacobian - Computes Jacobian matrix  T'(lambda)

230:    Input Parameters:
231: .  nep    - the NEP context
232: .  lambda - real part of the scalar argument
233: .  ctx    - optional user-defined context, as set by NEPSetJacobian()

235:    Output Parameters:
236: .  jac - Jacobian matrix
237: .  B   - optionally different preconditioning matrix
238: */
239: PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx)
240: {
242:   MatCtx         *ctxJ;

245:   MatShellGetContext(jac,(void**)&ctxJ);
246:   ctxJ->lambda = lambda;
247:   return(0);
248: }

250: /* ------------------------------------------------------------------- */
253: PetscErrorCode MatMult_Fun(Mat A,Vec x,Vec y)
254: {
255:   PetscErrorCode    ierr;
256:   MatCtx            *ctx;
257:   PetscInt          i,n;
258:   const PetscScalar *px;
259:   PetscScalar       *py,c,d,de,oe;
260:   PetscReal         h;

263:   MatShellGetContext(A,(void**)&ctx);
264:   VecGetArrayRead(x,&px);
265:   VecGetArray(y,&py);

267:   VecGetSize(x,&n);
268:   h = ctx->h;
269:   c = ctx->kappa/(ctx->lambda-ctx->kappa);
270:   d = n;
271:   de = 2.0*(d-ctx->lambda*h/3.0);   /* diagonal entry */
272:   oe = -d-ctx->lambda*h/6.0;        /* offdiagonal entry */
273:   py[0] = de*px[0] + oe*px[1];
274:   for (i=1;i<n-1;i++) py[i] = oe*px[i-1] +de*px[i] + oe*px[i+1];
275:   de = d-ctx->lambda*h/3.0+ctx->lambda*c;   /* diagonal entry of last row */
276:   py[n-1] = oe*px[n-2] + de*px[n-1];

278:   VecRestoreArrayRead(x,&px);
279:   VecRestoreArray(y,&py);
280:   return(0);
281: }

283: /* ------------------------------------------------------------------- */
286: PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag)
287: {
288:   PetscErrorCode    ierr;
289:   MatCtx            *ctx;
290:   PetscInt          n;
291:   PetscScalar       *pd,c,d;
292:   PetscReal         h;

295:   MatShellGetContext(A,(void**)&ctx);
296:   VecGetSize(diag,&n);
297:   h = ctx->h;
298:   c = ctx->kappa/(ctx->lambda-ctx->kappa);
299:   d = n;
300:   VecSet(diag,2.0*(d-ctx->lambda*h/3.0));
301:   VecGetArray(diag,&pd);
302:   pd[n-1] = d-ctx->lambda*h/3.0+ctx->lambda*c;
303:   VecRestoreArray(diag,&pd);
304:   return(0);
305: }

307: /* ------------------------------------------------------------------- */
310: PetscErrorCode MatDestroy_Fun(Mat A)
311: {
312:   MatCtx         *ctx;

316:   MatShellGetContext(A,(void**)&ctx);
317:   PetscFree(ctx);
318:   return(0);
319: }

321: /* ------------------------------------------------------------------- */
324: PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B)
325: {
326:   MatCtx         *actx,*bctx;
327:   PetscInt       n;
328:   MPI_Comm       comm;

332:   MatShellGetContext(A,(void**)&actx);
333:   MatGetSize(A,&n,NULL);

335:   PetscNew(&bctx);
336:   bctx->h      = actx->h;
337:   bctx->kappa  = actx->kappa;
338:   bctx->lambda = actx->lambda;

340:   PetscObjectGetComm((PetscObject)A,&comm);
341:   MatCreateShell(comm,n,n,n,n,(void*)bctx,B);
342:   MatShellSetOperation(*B,MATOP_MULT,(void(*)())MatMult_Fun);
343:   MatShellSetOperation(*B,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Fun);
344:   MatShellSetOperation(*B,MATOP_DESTROY,(void(*)())MatDestroy_Fun);
345:   MatShellSetOperation(*B,MATOP_DUPLICATE,(void(*)())MatDuplicate_Fun);
346:   return(0);
347: }

349: /* ------------------------------------------------------------------- */
352: PetscErrorCode MatMult_Jac(Mat A,Vec x,Vec y)
353: {
354:   PetscErrorCode    ierr;
355:   MatCtx            *ctx;
356:   PetscInt          i,n;
357:   const PetscScalar *px;
358:   PetscScalar       *py,c,de,oe;
359:   PetscReal         h;

362:   MatShellGetContext(A,(void**)&ctx);
363:   VecGetArrayRead(x,&px);
364:   VecGetArray(y,&py);

366:   VecGetSize(x,&n);
367:   h = ctx->h;
368:   c = ctx->kappa/(ctx->lambda-ctx->kappa);
369:   de = -2.0*h/3.0;    /* diagonal entry */
370:   oe = -h/6.0;        /* offdiagonal entry */
371:   py[0] = de*px[0] + oe*px[1];
372:   for (i=1;i<n-1;i++) py[i] = oe*px[i-1] +de*px[i] + oe*px[i+1];
373:   de = -h/3.0-c*c;    /* diagonal entry of last row */
374:   py[n-1] = oe*px[n-2] + de*px[n-1];

376:   VecRestoreArrayRead(x,&px);
377:   VecRestoreArray(y,&py);
378:   return(0);
379: }

381: /* ------------------------------------------------------------------- */
384: PetscErrorCode MatDestroy_Jac(Mat A)
385: {
386:   MatCtx         *ctx;

390:   MatShellGetContext(A,(void**)&ctx);
391:   PetscFree(ctx);
392:   return(0);
393: }

slepc-3.7.4/src/nep/examples/tutorials/ex20.c0000644000175000017500000003450413107004621020330 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Simple 1-D nonlinear eigenproblem.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions.\n" " -draw_sol, to draw the computed solution.\n\n"; /* Solve 1-D PDE -u'' = lambda*u on [0,1] subject to u(0)=0, u'(1)=u(1)*lambda*kappa/(kappa-lambda) */ #include /* User-defined routines */ PetscErrorCode FormInitialGuess(Vec); PetscErrorCode FormFunction(NEP,PetscScalar,Mat,Mat,void*); PetscErrorCode FormJacobian(NEP,PetscScalar,Mat,void*); PetscErrorCode CheckSolution(PetscScalar,Vec,PetscReal*,void*); PetscErrorCode FixSign(Vec); /* User-defined application context */ typedef struct { PetscScalar kappa; /* ratio between stiffness of spring and attached mass */ PetscReal h; /* mesh spacing */ } ApplicationCtx; #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { NEP nep; /* nonlinear eigensolver context */ Vec x; /* eigenvector */ PetscScalar lambda; /* eigenvalue */ Mat F,J; /* Function and Jacobian matrices */ ApplicationCtx ctx; /* user-defined context */ NEPType type; PetscInt n=128,nev,i,its,maxit,nconv; PetscReal re,im,tol,norm,error; PetscBool draw_sol; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Nonlinear Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); ctx.h = 1.0/(PetscReal)n; ctx.kappa = 1.0; ierr = PetscOptionsHasName(NULL,NULL,"-draw_sol",&draw_sol);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create nonlinear eigensolver context - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPCreate(PETSC_COMM_WORLD,&nep);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create matrix data structure; set Function evaluation routine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&F);CHKERRQ(ierr); ierr = MatSetSizes(F,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(F);CHKERRQ(ierr); ierr = MatSeqAIJSetPreallocation(F,3,NULL);CHKERRQ(ierr); ierr = MatMPIAIJSetPreallocation(F,3,NULL,1,NULL);CHKERRQ(ierr); ierr = MatSetUp(F);CHKERRQ(ierr); /* Set Function matrix data structure and default Function evaluation routine */ ierr = NEPSetFunction(nep,F,F,FormFunction,&ctx);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create matrix data structure; set Jacobian evaluation routine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&J);CHKERRQ(ierr); ierr = MatSetSizes(J,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(J);CHKERRQ(ierr); ierr = MatSeqAIJSetPreallocation(J,3,NULL);CHKERRQ(ierr); ierr = MatMPIAIJSetPreallocation(F,3,NULL,1,NULL);CHKERRQ(ierr); ierr = MatSetUp(J);CHKERRQ(ierr); /* Set Jacobian matrix data structure and default Jacobian evaluation routine */ ierr = NEPSetJacobian(nep,J,FormJacobian,&ctx);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Customize nonlinear solver; set runtime options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPSetTolerances(nep,1e-9,PETSC_DEFAULT);CHKERRQ(ierr); ierr = NEPSetDimensions(nep,1,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = NEPSetFromOptions(nep);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Initialize application - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Evaluate initial guess */ ierr = MatCreateVecs(F,&x,NULL);CHKERRQ(ierr); ierr = FormInitialGuess(x);CHKERRQ(ierr); ierr = NEPSetInitialSpace(nep,1,&x);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPSolve(nep);CHKERRQ(ierr); ierr = NEPGetIterationNumber(nep,&its);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of NEP iterations = %D\n\n",its);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = NEPGetType(nep,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n",type);CHKERRQ(ierr); ierr = NEPGetDimensions(nep,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); ierr = NEPGetTolerances(nep,&tol,&maxit);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%g, maxit=%D\n",(double)tol,maxit);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Get number of converged approximate eigenpairs */ ierr = NEPGetConverged(nep,&nconv);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of converged approximate eigenpairs: %D\n\n",nconv);CHKERRQ(ierr); if (nconv>0) { /* Display eigenvalues and relative errors */ ierr = PetscPrintf(PETSC_COMM_WORLD, " k ||T(k)x|| error\n" " ----------------- ------------------ ------------------\n");CHKERRQ(ierr); for (i=0;ih; c = user->kappa/(lambda-user->kappa); d = n; /* Interior grid points */ for (i=(FirstBlock? Istart+1: Istart);i<(LastBlock? Iend-1: Iend);i++) { j[0] = i-1; j[1] = i; j[2] = i+1; A[0] = A[2] = -d-lambda*h/6.0; A[1] = 2.0*(d-lambda*h/3.0); ierr = MatSetValues(fun,1,&i,3,j,A,INSERT_VALUES);CHKERRQ(ierr); } /* Boundary points */ if (FirstBlock) { i = 0; j[0] = 0; j[1] = 1; A[0] = 2.0*(d-lambda*h/3.0); A[1] = -d-lambda*h/6.0; ierr = MatSetValues(fun,1,&i,2,j,A,INSERT_VALUES);CHKERRQ(ierr); } if (LastBlock) { i = n-1; j[0] = n-2; j[1] = n-1; A[0] = -d-lambda*h/6.0; A[1] = d-lambda*h/3.0+lambda*c; ierr = MatSetValues(fun,1,&i,2,j,A,INSERT_VALUES);CHKERRQ(ierr); } /* Assemble matrix */ ierr = MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); if (fun != B) { ierr = MatAssemblyBegin(fun,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(fun,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); } PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "FormJacobian" /* FormJacobian - Computes Jacobian matrix T'(lambda) Input Parameters: . nep - the NEP context . lambda - the scalar argument . ctx - optional user-defined context, as set by NEPSetJacobian() Output Parameters: . jac - Jacobian matrix . B - optionally different preconditioning matrix */ PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx) { PetscErrorCode ierr; ApplicationCtx *user = (ApplicationCtx*)ctx; PetscScalar A[3],c; PetscReal h; PetscInt i,n,j[3],Istart,Iend; PetscBool FirstBlock=PETSC_FALSE,LastBlock=PETSC_FALSE; PetscFunctionBeginUser; /* Compute Jacobian entries and insert into matrix */ ierr = MatGetSize(jac,&n,NULL);CHKERRQ(ierr); ierr = MatGetOwnershipRange(jac,&Istart,&Iend);CHKERRQ(ierr); if (Istart==0) FirstBlock=PETSC_TRUE; if (Iend==n) LastBlock=PETSC_TRUE; h = user->h; c = user->kappa/(lambda-user->kappa); /* Interior grid points */ for (i=(FirstBlock? Istart+1: Istart);i<(LastBlock? Iend-1: Iend);i++) { j[0] = i-1; j[1] = i; j[2] = i+1; A[0] = A[2] = -h/6.0; A[1] = -2.0*h/3.0; ierr = MatSetValues(jac,1,&i,3,j,A,INSERT_VALUES);CHKERRQ(ierr); } /* Boundary points */ if (FirstBlock) { i = 0; j[0] = 0; j[1] = 1; A[0] = -2.0*h/3.0; A[1] = -h/6.0; ierr = MatSetValues(jac,1,&i,2,j,A,INSERT_VALUES);CHKERRQ(ierr); } if (LastBlock) { i = n-1; j[0] = n-2; j[1] = n-1; A[0] = -h/6.0; A[1] = -h/3.0-c*c; ierr = MatSetValues(jac,1,&i,2,j,A,INSERT_VALUES);CHKERRQ(ierr); } /* Assemble matrix */ ierr = MatAssemblyBegin(jac,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(jac,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "CheckSolution" /* CheckSolution - Given a computed solution (lambda,x) check if it satisfies the analytic solution. Input Parameters: + lambda - the computed eigenvalue - y - the computed eigenvector Output Parameter: . error - norm of difference between the computed and exact eigenvector */ PetscErrorCode CheckSolution(PetscScalar lambda,Vec y,PetscReal *error,void *ctx) { PetscErrorCode ierr; PetscScalar nu,*uu; PetscInt i,n,Istart,Iend; PetscReal x; Vec u; ApplicationCtx *user = (ApplicationCtx*)ctx; PetscFunctionBeginUser; nu = PetscSqrtScalar(lambda); ierr = VecDuplicate(y,&u);CHKERRQ(ierr); ierr = VecGetSize(u,&n);CHKERRQ(ierr); ierr = VecGetOwnershipRange(y,&Istart,&Iend);CHKERRQ(ierr); ierr = VecGetArray(u,&uu);CHKERRQ(ierr); for (i=Istart;ih; uu[i-Istart] = PetscSinReal(nu*x); } ierr = VecRestoreArray(u,&uu);CHKERRQ(ierr); ierr = VecNormalize(u,NULL);CHKERRQ(ierr); ierr = VecAXPY(u,-1.0,y);CHKERRQ(ierr); ierr = VecNorm(u,NORM_2,error);CHKERRQ(ierr); ierr = VecDestroy(&u);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "FixSign" /* FixSign - Force the eigenfunction to be real and positive, since some eigensolvers may return the eigenvector multiplied by a complex number of modulus one. Input/Output Parameter: . x - the computed vector */ PetscErrorCode FixSign(Vec x) { PetscErrorCode ierr; PetscMPIInt rank; PetscScalar sign; const PetscScalar *xx; PetscFunctionBeginUser; ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr); if (!rank) { ierr = VecGetArrayRead(x,&xx);CHKERRQ(ierr); sign = *xx/PetscAbsScalar(*xx); ierr = VecRestoreArrayRead(x,&xx);CHKERRQ(ierr); } ierr = MPI_Bcast(&sign,1,MPIU_SCALAR,0,PETSC_COMM_WORLD);CHKERRQ(ierr); ierr = VecScale(x,1.0/sign);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/examples/tutorials/ex21.c0000644000175000017500000003202413107004621020324 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Simple 1-D nonlinear eigenproblem (matrix-free version, sequential).\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions\n\n"; /* Solve 1-D PDE -u'' = lambda*u on [0,1] subject to u(0)=0, u'(1)=u(1)*lambda*kappa/(kappa-lambda) */ #include /* User-defined routines */ PetscErrorCode FormInitialGuess(Vec); PetscErrorCode FormFunction(NEP,PetscScalar,Mat,Mat,void*); PetscErrorCode FormJacobian(NEP,PetscScalar,Mat,void*); /* Matrix operations and context */ PetscErrorCode MatMult_Fun(Mat,Vec,Vec); PetscErrorCode MatGetDiagonal_Fun(Mat,Vec); PetscErrorCode MatDestroy_Fun(Mat); PetscErrorCode MatDuplicate_Fun(Mat,MatDuplicateOption,Mat*); PetscErrorCode MatMult_Jac(Mat,Vec,Vec); PetscErrorCode MatDestroy_Jac(Mat); typedef struct { PetscScalar lambda,kappa; PetscReal h; } MatCtx; /* User-defined application context */ typedef struct { PetscScalar kappa; /* ratio between stiffness of spring and attached mass */ PetscReal h; /* mesh spacing */ } ApplicationCtx; #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { NEP nep; /* nonlinear eigensolver context */ Mat F,J; /* Function and Jacobian matrices */ ApplicationCtx ctx; /* user-defined context */ MatCtx *ctxF,*ctxJ; /* contexts for shell matrices */ NEPType type; PetscInt n=128,nev; KSP ksp; PC pc; PetscMPIInt size; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); if (size != 1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This is a uniprocessor example only!"); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Nonlinear Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); ctx.h = 1.0/(PetscReal)n; ctx.kappa = 1.0; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create nonlinear eigensolver context - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPCreate(PETSC_COMM_WORLD,&nep);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create matrix data structure; set Function evaluation routine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscNew(&ctxF);CHKERRQ(ierr); ctxF->h = ctx.h; ctxF->kappa = ctx.kappa; ierr = MatCreateShell(PETSC_COMM_WORLD,n,n,n,n,(void*)ctxF,&F);CHKERRQ(ierr); ierr = MatShellSetOperation(F,MATOP_MULT,(void(*)())MatMult_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(F,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(F,MATOP_DESTROY,(void(*)())MatDestroy_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(F,MATOP_DUPLICATE,(void(*)())MatDuplicate_Fun);CHKERRQ(ierr); /* Set Function matrix data structure and default Function evaluation routine */ ierr = NEPSetFunction(nep,F,F,FormFunction,NULL);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create matrix data structure; set Jacobian evaluation routine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscNew(&ctxJ);CHKERRQ(ierr); ctxJ->h = ctx.h; ctxJ->kappa = ctx.kappa; ierr = MatCreateShell(PETSC_COMM_WORLD,n,n,n,n,(void*)ctxJ,&J);CHKERRQ(ierr); ierr = MatShellSetOperation(J,MATOP_MULT,(void(*)())MatMult_Jac);CHKERRQ(ierr); ierr = MatShellSetOperation(J,MATOP_DESTROY,(void(*)())MatDestroy_Jac);CHKERRQ(ierr); /* Set Jacobian matrix data structure and default Jacobian evaluation routine */ ierr = NEPSetJacobian(nep,J,FormJacobian,NULL);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Customize nonlinear solver; set runtime options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPSetType(nep,NEPRII);CHKERRQ(ierr); ierr = NEPRIISetLagPreconditioner(nep,0);CHKERRQ(ierr); ierr = NEPRIIGetKSP(nep,&ksp);CHKERRQ(ierr); ierr = KSPSetType(ksp,KSPBCGS);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = NEPSetFromOptions(nep);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPSolve(nep);CHKERRQ(ierr); ierr = NEPGetType(nep,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n",type);CHKERRQ(ierr); ierr = NEPGetDimensions(nep,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = NEPErrorView(nep,NEP_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = NEPReasonView(nep,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = NEPErrorView(nep,NEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); } ierr = NEPDestroy(&nep);CHKERRQ(ierr); ierr = MatDestroy(&F);CHKERRQ(ierr); ierr = MatDestroy(&J);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "FormInitialGuess" /* FormInitialGuess - Computes initial guess. Input/Output Parameter: . x - the solution vector */ PetscErrorCode FormInitialGuess(Vec x) { PetscErrorCode ierr; PetscFunctionBeginUser; ierr = VecSet(x,1.0);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "FormFunction" /* FormFunction - Computes Function matrix T(lambda) Input Parameters: . nep - the NEP context . lambda - real part of the scalar argument . ctx - optional user-defined context, as set by NEPSetFunction() Output Parameters: . fun - Function matrix . B - optionally different preconditioning matrix */ PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx) { PetscErrorCode ierr; MatCtx *ctxF; PetscFunctionBeginUser; ierr = MatShellGetContext(fun,(void**)&ctxF);CHKERRQ(ierr); ctxF->lambda = lambda; PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "FormJacobian" /* FormJacobian - Computes Jacobian matrix T'(lambda) Input Parameters: . nep - the NEP context . lambda - real part of the scalar argument . ctx - optional user-defined context, as set by NEPSetJacobian() Output Parameters: . jac - Jacobian matrix . B - optionally different preconditioning matrix */ PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx) { PetscErrorCode ierr; MatCtx *ctxJ; PetscFunctionBeginUser; ierr = MatShellGetContext(jac,(void**)&ctxJ);CHKERRQ(ierr); ctxJ->lambda = lambda; PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "MatMult_Fun" PetscErrorCode MatMult_Fun(Mat A,Vec x,Vec y) { PetscErrorCode ierr; MatCtx *ctx; PetscInt i,n; const PetscScalar *px; PetscScalar *py,c,d,de,oe; PetscReal h; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = VecGetSize(x,&n);CHKERRQ(ierr); h = ctx->h; c = ctx->kappa/(ctx->lambda-ctx->kappa); d = n; de = 2.0*(d-ctx->lambda*h/3.0); /* diagonal entry */ oe = -d-ctx->lambda*h/6.0; /* offdiagonal entry */ py[0] = de*px[0] + oe*px[1]; for (i=1;ilambda*h/3.0+ctx->lambda*c; /* diagonal entry of last row */ py[n-1] = oe*px[n-2] + de*px[n-1]; ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "MatGetDiagonal_Fun" PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag) { PetscErrorCode ierr; MatCtx *ctx; PetscInt n; PetscScalar *pd,c,d; PetscReal h; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = VecGetSize(diag,&n);CHKERRQ(ierr); h = ctx->h; c = ctx->kappa/(ctx->lambda-ctx->kappa); d = n; ierr = VecSet(diag,2.0*(d-ctx->lambda*h/3.0));CHKERRQ(ierr); ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); pd[n-1] = d-ctx->lambda*h/3.0+ctx->lambda*c; ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "MatDestroy_Fun" PetscErrorCode MatDestroy_Fun(Mat A) { MatCtx *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "MatDuplicate_Fun" PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B) { MatCtx *actx,*bctx; PetscInt n; MPI_Comm comm; PetscErrorCode ierr; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&actx);CHKERRQ(ierr); ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr); ierr = PetscNew(&bctx);CHKERRQ(ierr); bctx->h = actx->h; bctx->kappa = actx->kappa; bctx->lambda = actx->lambda; ierr = PetscObjectGetComm((PetscObject)A,&comm);CHKERRQ(ierr); ierr = MatCreateShell(comm,n,n,n,n,(void*)bctx,B);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_MULT,(void(*)())MatMult_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_DESTROY,(void(*)())MatDestroy_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_DUPLICATE,(void(*)())MatDuplicate_Fun);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "MatMult_Jac" PetscErrorCode MatMult_Jac(Mat A,Vec x,Vec y) { PetscErrorCode ierr; MatCtx *ctx; PetscInt i,n; const PetscScalar *px; PetscScalar *py,c,de,oe; PetscReal h; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = VecGetSize(x,&n);CHKERRQ(ierr); h = ctx->h; c = ctx->kappa/(ctx->lambda-ctx->kappa); de = -2.0*h/3.0; /* diagonal entry */ oe = -h/6.0; /* offdiagonal entry */ py[0] = de*px[0] + oe*px[1]; for (i=1;iActual source code: ex22.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Delay differential equation.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions.\n"
 25:   "  -tau <tau>, where <tau> is the delay parameter.\n\n";

 27: /*
 28:    Solve parabolic partial differential equation with time delay tau

 30:             u_t = u_xx + a*u(t) + b*u(t-tau)
 31:             u(0,t) = u(pi,t) = 0

 33:    with a = 20 and b(x) = -4.1+x*(1-exp(x-pi)).

 35:    Discretization leads to a DDE of dimension n

 37:             -u' = A*u(t) + B*u(t-tau)

 39:    which results in the nonlinear eigenproblem

 41:             (-lambda*I + A + exp(-tau*lambda)*B)*u = 0
 42: */

 44: #include <slepcnep.h>

 48: int main(int argc,char **argv)
 49: {
 50:   NEP            nep;             /* nonlinear eigensolver context */
 51:   Mat            Id,A,B;          /* problem matrices */
 52:   FN             f1,f2,f3;        /* functions to define the nonlinear operator */
 53:   Mat            mats[3];
 54:   FN             funs[3];
 55:   NEPType        type;
 56:   PetscScalar    coeffs[2],b;
 57:   PetscInt       n=128,nev,Istart,Iend,i;
 58:   PetscReal      tau=0.001,h,a=20,xi;
 59:   PetscBool      terse;

 62:   SlepcInitialize(&argc,&argv,(char*)0,help);
 63:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 64:   PetscOptionsGetReal(NULL,NULL,"-tau",&tau,NULL);
 65:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Delay Eigenproblem, n=%D, tau=%g\n\n",n,(double)tau);
 66:   h = PETSC_PI/(PetscReal)(n+1);

 68:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 69:      Create nonlinear eigensolver context
 70:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 72:   NEPCreate(PETSC_COMM_WORLD,&nep);

 74:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 75:      Create problem matrices and coefficient functions. Pass them to NEP
 76:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 78:   /*
 79:      Identity matrix
 80:   */
 81:   MatCreate(PETSC_COMM_WORLD,&Id);
 82:   MatSetSizes(Id,PETSC_DECIDE,PETSC_DECIDE,n,n);
 83:   MatSetFromOptions(Id);
 84:   MatSetUp(Id);
 85:   MatGetOwnershipRange(Id,&Istart,&Iend);
 86:   for (i=Istart;i<Iend;i++) {
 87:     MatSetValue(Id,i,i,1.0,INSERT_VALUES);
 88:   }
 89:   MatAssemblyBegin(Id,MAT_FINAL_ASSEMBLY);
 90:   MatAssemblyEnd(Id,MAT_FINAL_ASSEMBLY);
 91:   MatSetOption(Id,MAT_HERMITIAN,PETSC_TRUE);

 93:   /*
 94:      A = 1/h^2*tridiag(1,-2,1) + a*I
 95:   */
 96:   MatCreate(PETSC_COMM_WORLD,&A);
 97:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 98:   MatSetFromOptions(A);
 99:   MatSetUp(A);
100:   MatGetOwnershipRange(A,&Istart,&Iend);
101:   for (i=Istart;i<Iend;i++) {
102:     if (i>0) { MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES); }
103:     if (i<n-1) { MatSetValue(A,i,i+1,1.0/(h*h),INSERT_VALUES); }
104:     MatSetValue(A,i,i,-2.0/(h*h)+a,INSERT_VALUES);
105:   }
106:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
107:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
108:   MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);

110:   /*
111:      B = diag(b(xi))
112:   */
113:   MatCreate(PETSC_COMM_WORLD,&B);
114:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
115:   MatSetFromOptions(B);
116:   MatSetUp(B);
117:   MatGetOwnershipRange(B,&Istart,&Iend);
118:   for (i=Istart;i<Iend;i++) {
119:     xi = (i+1)*h;
120:     b = -4.1+xi*(1.0-PetscExpReal(xi-PETSC_PI));
121:     MatSetValues(B,1,&i,1,&i,&b,INSERT_VALUES);
122:   }
123:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
124:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
125:   MatSetOption(B,MAT_HERMITIAN,PETSC_TRUE);

127:   /*
128:      Functions: f1=-lambda, f2=1.0, f3=exp(-tau*lambda)
129:   */
130:   FNCreate(PETSC_COMM_WORLD,&f1);
131:   FNSetType(f1,FNRATIONAL);
132:   coeffs[0] = -1.0; coeffs[1] = 0.0;
133:   FNRationalSetNumerator(f1,2,coeffs);

135:   FNCreate(PETSC_COMM_WORLD,&f2);
136:   FNSetType(f2,FNRATIONAL);
137:   coeffs[0] = 1.0;
138:   FNRationalSetNumerator(f2,1,coeffs);

140:   FNCreate(PETSC_COMM_WORLD,&f3);
141:   FNSetType(f3,FNEXP);
142:   FNSetScale(f3,-tau,1.0);

144:   /*
145:      Set the split operator. Note that A is passed first so that
146:      SUBSET_NONZERO_PATTERN can be used
147:   */
148:   mats[0] = A;  funs[0] = f2;
149:   mats[1] = Id; funs[1] = f1;
150:   mats[2] = B;  funs[2] = f3;
151:   NEPSetSplitOperator(nep,3,mats,funs,SUBSET_NONZERO_PATTERN);

153:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
154:              Customize nonlinear solver; set runtime options
155:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

157:   NEPSetTolerances(nep,1e-9,PETSC_DEFAULT);
158:   NEPSetDimensions(nep,1,PETSC_DEFAULT,PETSC_DEFAULT);
159:   NEPRIISetLagPreconditioner(nep,0);

161:   /*
162:      Set solver parameters at runtime
163:   */
164:   NEPSetFromOptions(nep);

166:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
167:                       Solve the eigensystem
168:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

170:   NEPSolve(nep);
171:   NEPGetType(nep,&type);
172:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n",type);
173:   NEPGetDimensions(nep,&nev,NULL,NULL);
174:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

176:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
177:                     Display solution and clean up
178:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

180:   /* show detailed info unless -terse option is given by user */
181:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
182:   if (terse) {
183:     NEPErrorView(nep,NEP_ERROR_RELATIVE,NULL);
184:   } else {
185:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
186:     NEPReasonView(nep,PETSC_VIEWER_STDOUT_WORLD);
187:     NEPErrorView(nep,NEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
188:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
189:   }
190:   NEPDestroy(&nep);
191:   MatDestroy(&Id);
192:   MatDestroy(&A);
193:   MatDestroy(&B);
194:   FNDestroy(&f1);
195:   FNDestroy(&f2);
196:   FNDestroy(&f3);
197:   SlepcFinalize();
198:   return ierr;
199: }

slepc-3.7.4/src/nep/examples/tutorials/ex27.c0000644000175000017500000002231213107004621020331 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2013, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Simple nonlinear eigenproblem using the NLEIGS solver.\n\n" "The command line options are:\n" " -n , where = matrix dimension.\n" " -split <0/1>, to select the split form in the problem definition (enabled by default)\n"; /* Solve T(lambda)x=0 using NLEIGS solver with T(lambda) = -D+sqrt(lambda)*I where D is the Laplacian operator in 1 dimension and with the interpolation interval [.01,16] */ #include /* User-defined routines */ PetscErrorCode FormFunction(NEP,PetscScalar,Mat,Mat,void*); PetscErrorCode ComputeSingularities(NEP,PetscInt*,PetscScalar*,void*); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { NEP nep; /* nonlinear eigensolver context */ Mat F,A[2]; NEPType type; PetscInt n=100,nev,Istart,Iend,i; PetscErrorCode ierr; PetscBool split=PETSC_TRUE; RG rg; FN f[2]; PetscBool terse; PetscScalar coeffs; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetBool(NULL,NULL,"-split",&split,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSquare root eigenproblem, n=%D%s\n\n",n,split?" (in split form)":"");CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create nonlinear eigensolver context - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPCreate(PETSC_COMM_WORLD,&nep);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the NLEIGS solver and set required options for it - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = NEPSetType(nep,NEPNLEIGS);CHKERRQ(ierr); ierr = NEPNLEIGSSetSingularitiesFunction(nep,ComputeSingularities,NULL);CHKERRQ(ierr); ierr = NEPGetRG(nep,&rg);CHKERRQ(ierr); ierr = RGSetType(rg,RGINTERVAL);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = RGIntervalSetEndpoints(rg,0.01,16.0,-0.001,0.001);CHKERRQ(ierr); #else ierr = RGIntervalSetEndpoints(rg,0.01,16.0,0,0);CHKERRQ(ierr); #endif ierr = NEPSetTarget(nep,1.1);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Define the nonlinear problem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if (split) { /* Create matrices for the split form */ ierr = MatCreate(PETSC_COMM_WORLD,&A[0]);CHKERRQ(ierr); ierr = MatSetSizes(A[0],PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A[0]);CHKERRQ(ierr); ierr = MatSetUp(A[0]);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A[0],&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A[0],i,i-1,1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

ex20.c: Simple 1-D nonlinear eigenproblem
ex21.c: Simple 1-D nonlinear eigenproblem (matrix-free version, sequential)
ex22.c: Delay differential equation
ex27.c: Simple nonlinear eigenproblem using the NLEIGS solver
makefile
slepc-3.7.4/src/nep/examples/tutorials/ex20.c.html0000644000175000017500000007634213107004621021301 0ustar jromanjroman

Actual source code: ex20.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Simple 1-D nonlinear eigenproblem.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions.\n"
 25:   "  -draw_sol, to draw the computed solution.\n\n";

 27: /*
 28:    Solve 1-D PDE
 29:             -u'' = lambda*u
 30:    on [0,1] subject to
 31:             u(0)=0, u'(1)=u(1)*lambda*kappa/(kappa-lambda)
 32: */

 34: #include <slepcnep.h>

 36: /*
 37:    User-defined routines
 38: */
 39: PetscErrorCode FormInitialGuess(Vec);
 40: PetscErrorCode FormFunction(NEP,PetscScalar,Mat,Mat,void*);
 41: PetscErrorCode FormJacobian(NEP,PetscScalar,Mat,void*);
 42: PetscErrorCode CheckSolution(PetscScalar,Vec,PetscReal*,void*);
 43: PetscErrorCode FixSign(Vec);

 45: /*
 46:    User-defined application context
 47: */
 48: typedef struct {
 49:   PetscScalar kappa;   /* ratio between stiffness of spring and attached mass */
 50:   PetscReal   h;       /* mesh spacing */
 51: } ApplicationCtx;

 55: int main(int argc,char **argv)
 56: {
 57:   NEP            nep;             /* nonlinear eigensolver context */
 58:   Vec            x;               /* eigenvector */
 59:   PetscScalar    lambda;          /* eigenvalue */
 60:   Mat            F,J;             /* Function and Jacobian matrices */
 61:   ApplicationCtx ctx;             /* user-defined context */
 62:   NEPType        type;
 63:   PetscInt       n=128,nev,i,its,maxit,nconv;
 64:   PetscReal      re,im,tol,norm,error;
 65:   PetscBool      draw_sol;

 68:   SlepcInitialize(&argc,&argv,(char*)0,help);
 69:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 70:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Nonlinear Eigenproblem, n=%D\n\n",n);
 71:   ctx.h = 1.0/(PetscReal)n;
 72:   ctx.kappa = 1.0;
 73:   PetscOptionsHasName(NULL,NULL,"-draw_sol",&draw_sol);

 75:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 76:      Create nonlinear eigensolver context
 77:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 79:   NEPCreate(PETSC_COMM_WORLD,&nep);

 81:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 82:      Create matrix data structure; set Function evaluation routine
 83:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 85:   MatCreate(PETSC_COMM_WORLD,&F);
 86:   MatSetSizes(F,PETSC_DECIDE,PETSC_DECIDE,n,n);
 87:   MatSetFromOptions(F);
 88:   MatSeqAIJSetPreallocation(F,3,NULL);
 89:   MatMPIAIJSetPreallocation(F,3,NULL,1,NULL);
 90:   MatSetUp(F);

 92:   /*
 93:      Set Function matrix data structure and default Function evaluation
 94:      routine
 95:   */
 96:   NEPSetFunction(nep,F,F,FormFunction,&ctx);

 98:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 99:      Create matrix data structure; set Jacobian evaluation routine
100:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

102:   MatCreate(PETSC_COMM_WORLD,&J);
103:   MatSetSizes(J,PETSC_DECIDE,PETSC_DECIDE,n,n);
104:   MatSetFromOptions(J);
105:   MatSeqAIJSetPreallocation(J,3,NULL);
106:   MatMPIAIJSetPreallocation(F,3,NULL,1,NULL);
107:   MatSetUp(J);

109:   /*
110:      Set Jacobian matrix data structure and default Jacobian evaluation
111:      routine
112:   */
113:   NEPSetJacobian(nep,J,FormJacobian,&ctx);

115:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
116:      Customize nonlinear solver; set runtime options
117:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

119:   NEPSetTolerances(nep,1e-9,PETSC_DEFAULT);
120:   NEPSetDimensions(nep,1,PETSC_DEFAULT,PETSC_DEFAULT);

122:   /*
123:      Set solver parameters at runtime
124:   */
125:   NEPSetFromOptions(nep);

127:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
128:                       Initialize application
129:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

131:   /*
132:      Evaluate initial guess
133:   */
134:   MatCreateVecs(F,&x,NULL);
135:   FormInitialGuess(x);
136:   NEPSetInitialSpace(nep,1,&x);

138:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139:                       Solve the eigensystem
140:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

142:   NEPSolve(nep);
143:   NEPGetIterationNumber(nep,&its);
144:   PetscPrintf(PETSC_COMM_WORLD," Number of NEP iterations = %D\n\n",its);

146:   /*
147:      Optional: Get some information from the solver and display it
148:   */
149:   NEPGetType(nep,&type);
150:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n",type);
151:   NEPGetDimensions(nep,&nev,NULL,NULL);
152:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
153:   NEPGetTolerances(nep,&tol,&maxit);
154:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%g, maxit=%D\n",(double)tol,maxit);

156:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
157:                     Display solution and clean up
158:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

160:   /*
161:      Get number of converged approximate eigenpairs
162:   */
163:   NEPGetConverged(nep,&nconv);
164:   PetscPrintf(PETSC_COMM_WORLD," Number of converged approximate eigenpairs: %D\n\n",nconv);

166:   if (nconv>0) {
167:     /*
168:        Display eigenvalues and relative errors
169:     */
170:     PetscPrintf(PETSC_COMM_WORLD,
171:          "           k              ||T(k)x||           error\n"
172:          "   ----------------- ------------------ ------------------\n");
173:     for (i=0;i<nconv;i++) {
174:       /*
175:         Get converged eigenpairs (in this example they are always real)
176:       */
177:       NEPGetEigenpair(nep,i,&lambda,NULL,x,NULL);
178:       FixSign(x);
179:       /*
180:          Compute residual norm and error
181:       */
182:       NEPComputeError(nep,i,NEP_ERROR_RELATIVE,&norm);
183:       CheckSolution(lambda,x,&error,&ctx);

185: #if defined(PETSC_USE_COMPLEX)
186:       re = PetscRealPart(lambda);
187:       im = PetscImaginaryPart(lambda);
188: #else
189:       re = lambda;
190:       im = 0.0;
191: #endif
192:       if (im!=0.0) {
193:         PetscPrintf(PETSC_COMM_WORLD," %9f%+9fi %12g     %12g\n",(double)re,(double)im,(double)norm,(double)error);
194:       } else {
195:         PetscPrintf(PETSC_COMM_WORLD,"   %12f         %12g     %12g\n",(double)re,(double)norm,(double)error);
196:       }
197:       if (draw_sol) {
198:         PetscViewerDrawSetPause(PETSC_VIEWER_DRAW_WORLD,-1);
199:         VecView(x,PETSC_VIEWER_DRAW_WORLD);
200:       }
201:     }
202:     PetscPrintf(PETSC_COMM_WORLD,"\n");
203:   }

205:   NEPDestroy(&nep);
206:   MatDestroy(&F);
207:   MatDestroy(&J);
208:   VecDestroy(&x);
209:   SlepcFinalize();
210:   return ierr;
211: }

213: /* ------------------------------------------------------------------- */
216: /*
217:    FormInitialGuess - Computes initial guess.

219:    Input/Output Parameter:
220: .  x - the solution vector
221: */
222: PetscErrorCode FormInitialGuess(Vec x)
223: {

227:   VecSet(x,1.0);
228:   return(0);
229: }

231: /* ------------------------------------------------------------------- */
234: /*
235:    FormFunction - Computes Function matrix  T(lambda)

237:    Input Parameters:
238: .  nep    - the NEP context
239: .  lambda - the scalar argument
240: .  ctx    - optional user-defined context, as set by NEPSetFunction()

242:    Output Parameters:
243: .  fun - Function matrix
244: .  B   - optionally different preconditioning matrix
245: */
246: PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)
247: {
249:   ApplicationCtx *user = (ApplicationCtx*)ctx;
250:   PetscScalar    A[3],c,d;
251:   PetscReal      h;
252:   PetscInt       i,n,j[3],Istart,Iend;
253:   PetscBool      FirstBlock=PETSC_FALSE,LastBlock=PETSC_FALSE;

256:   /*
257:      Compute Function entries and insert into matrix
258:   */
259:   MatGetSize(fun,&n,NULL);
260:   MatGetOwnershipRange(fun,&Istart,&Iend);
261:   if (Istart==0) FirstBlock=PETSC_TRUE;
262:   if (Iend==n) LastBlock=PETSC_TRUE;
263:   h = user->h;
264:   c = user->kappa/(lambda-user->kappa);
265:   d = n;

267:   /*
268:      Interior grid points
269:   */
270:   for (i=(FirstBlock? Istart+1: Istart);i<(LastBlock? Iend-1: Iend);i++) {
271:     j[0] = i-1; j[1] = i; j[2] = i+1;
272:     A[0] = A[2] = -d-lambda*h/6.0; A[1] = 2.0*(d-lambda*h/3.0);
273:     MatSetValues(fun,1,&i,3,j,A,INSERT_VALUES);
274:   }

276:   /*
277:      Boundary points
278:   */
279:   if (FirstBlock) {
280:     i = 0;
281:     j[0] = 0; j[1] = 1;
282:     A[0] = 2.0*(d-lambda*h/3.0); A[1] = -d-lambda*h/6.0;
283:     MatSetValues(fun,1,&i,2,j,A,INSERT_VALUES);
284:   }

286:   if (LastBlock) {
287:     i = n-1;
288:     j[0] = n-2; j[1] = n-1;
289:     A[0] = -d-lambda*h/6.0; A[1] = d-lambda*h/3.0+lambda*c;
290:     MatSetValues(fun,1,&i,2,j,A,INSERT_VALUES);
291:   }

293:   /*
294:      Assemble matrix
295:   */
296:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
297:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
298:   if (fun != B) {
299:     MatAssemblyBegin(fun,MAT_FINAL_ASSEMBLY);
300:     MatAssemblyEnd(fun,MAT_FINAL_ASSEMBLY);
301:   }
302:   return(0);
303: }

305: /* ------------------------------------------------------------------- */
308: /*
309:    FormJacobian - Computes Jacobian matrix  T'(lambda)

311:    Input Parameters:
312: .  nep    - the NEP context
313: .  lambda - the scalar argument
314: .  ctx    - optional user-defined context, as set by NEPSetJacobian()

316:    Output Parameters:
317: .  jac - Jacobian matrix
318: .  B   - optionally different preconditioning matrix
319: */
320: PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx)
321: {
323:   ApplicationCtx *user = (ApplicationCtx*)ctx;
324:   PetscScalar    A[3],c;
325:   PetscReal      h;
326:   PetscInt       i,n,j[3],Istart,Iend;
327:   PetscBool      FirstBlock=PETSC_FALSE,LastBlock=PETSC_FALSE;

330:   /*
331:      Compute Jacobian entries and insert into matrix
332:   */
333:   MatGetSize(jac,&n,NULL);
334:   MatGetOwnershipRange(jac,&Istart,&Iend);
335:   if (Istart==0) FirstBlock=PETSC_TRUE;
336:   if (Iend==n) LastBlock=PETSC_TRUE;
337:   h = user->h;
338:   c = user->kappa/(lambda-user->kappa);

340:   /*
341:      Interior grid points
342:   */
343:   for (i=(FirstBlock? Istart+1: Istart);i<(LastBlock? Iend-1: Iend);i++) {
344:     j[0] = i-1; j[1] = i; j[2] = i+1;
345:     A[0] = A[2] = -h/6.0; A[1] = -2.0*h/3.0;
346:     MatSetValues(jac,1,&i,3,j,A,INSERT_VALUES);
347:   }

349:   /*
350:      Boundary points
351:   */
352:   if (FirstBlock) {
353:     i = 0;
354:     j[0] = 0; j[1] = 1;
355:     A[0] = -2.0*h/3.0; A[1] = -h/6.0;
356:     MatSetValues(jac,1,&i,2,j,A,INSERT_VALUES);
357:   }

359:   if (LastBlock) {
360:     i = n-1;
361:     j[0] = n-2; j[1] = n-1;
362:     A[0] = -h/6.0; A[1] = -h/3.0-c*c;
363:     MatSetValues(jac,1,&i,2,j,A,INSERT_VALUES);
364:   }

366:   /*
367:      Assemble matrix
368:   */
369:   MatAssemblyBegin(jac,MAT_FINAL_ASSEMBLY);
370:   MatAssemblyEnd(jac,MAT_FINAL_ASSEMBLY);
371:   return(0);
372: }

374: /* ------------------------------------------------------------------- */
377: /*
378:    CheckSolution - Given a computed solution (lambda,x) check if it
379:    satisfies the analytic solution.

381:    Input Parameters:
382: +  lambda - the computed eigenvalue
383: -  y      - the computed eigenvector

385:    Output Parameter:
386: .  error - norm of difference between the computed and exact eigenvector
387: */
388: PetscErrorCode CheckSolution(PetscScalar lambda,Vec y,PetscReal *error,void *ctx)
389: {
391:   PetscScalar    nu,*uu;
392:   PetscInt       i,n,Istart,Iend;
393:   PetscReal      x;
394:   Vec            u;
395:   ApplicationCtx *user = (ApplicationCtx*)ctx;

398:   nu = PetscSqrtScalar(lambda);
399:   VecDuplicate(y,&u);
400:   VecGetSize(u,&n);
401:   VecGetOwnershipRange(y,&Istart,&Iend);
402:   VecGetArray(u,&uu);
403:   for (i=Istart;i<Iend;i++) {
404:     x = (i+1)*user->h;
405:     uu[i-Istart] = PetscSinReal(nu*x);
406:   }
407:   VecRestoreArray(u,&uu);
408:   VecNormalize(u,NULL);
409:   VecAXPY(u,-1.0,y);
410:   VecNorm(u,NORM_2,error);
411:   VecDestroy(&u);
412:   return(0);
413: }

415: /* ------------------------------------------------------------------- */
418: /*
419:    FixSign - Force the eigenfunction to be real and positive, since
420:    some eigensolvers may return the eigenvector multiplied by a
421:    complex number of modulus one.

423:    Input/Output Parameter:
424: .  x - the computed vector
425: */
426: PetscErrorCode FixSign(Vec x)
427: {
428:   PetscErrorCode    ierr;
429:   PetscMPIInt       rank;
430:   PetscScalar       sign;
431:   const PetscScalar *xx;

434:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
435:   if (!rank) {
436:     VecGetArrayRead(x,&xx);
437:     sign = *xx/PetscAbsScalar(*xx);
438:     VecRestoreArrayRead(x,&xx);
439:   }
440:   MPI_Bcast(&sign,1,MPIU_SCALAR,0,PETSC_COMM_WORLD);
441:   VecScale(x,1.0/sign);
442:   return(0);
443: }

slepc-3.7.4/src/nep/examples/tutorials/ex27.c.html0000644000175000017500000004707513107004621021311 0ustar jromanjroman
Actual source code: ex27.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2013, 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: static char help[] = "Simple nonlinear eigenproblem using the NLEIGS solver.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = matrix dimension.\n"
 25:   "  -split <0/1>, to select the split form in the problem definition (enabled by default)\n";


 28: /*
 29:    Solve T(lambda)x=0 using NLEIGS solver
 30:       with T(lambda) = -D+sqrt(lambda)*I
 31:       where D is the Laplacian operator in 1 dimension
 32:       and with the interpolation interval [.01,16]   
 33: */

 35: #include <slepcnep.h>

 37: /*
 38:    User-defined routines
 39: */
 40: PetscErrorCode FormFunction(NEP,PetscScalar,Mat,Mat,void*);
 41: PetscErrorCode ComputeSingularities(NEP,PetscInt*,PetscScalar*,void*);

 45: int main(int argc,char **argv)
 46: {
 47:   NEP            nep;             /* nonlinear eigensolver context */
 48:   Mat            F,A[2];             
 49:   NEPType        type;
 50:   PetscInt       n=100,nev,Istart,Iend,i;
 52:   PetscBool      split=PETSC_TRUE;
 53:   RG             rg;
 54:   FN             f[2];
 55:   PetscBool      terse;
 56:   PetscScalar    coeffs;

 58:   SlepcInitialize(&argc,&argv,(char*)0,help);
 59:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 60:   PetscOptionsGetBool(NULL,NULL,"-split",&split,NULL);
 61:   PetscPrintf(PETSC_COMM_WORLD,"\nSquare root eigenproblem, n=%D%s\n\n",n,split?" (in split form)":"");

 63:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 64:      Create nonlinear eigensolver context
 65:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 67:   NEPCreate(PETSC_COMM_WORLD,&nep);

 69:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 70:      Select the NLEIGS solver and set required options for it
 71:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 73:   NEPSetType(nep,NEPNLEIGS);
 74:   NEPNLEIGSSetSingularitiesFunction(nep,ComputeSingularities,NULL);
 75:   NEPGetRG(nep,&rg);
 76:   RGSetType(rg,RGINTERVAL);
 77: #if defined(PETSC_USE_COMPLEX)
 78:   RGIntervalSetEndpoints(rg,0.01,16.0,-0.001,0.001);
 79: #else
 80:   RGIntervalSetEndpoints(rg,0.01,16.0,0,0);
 81: #endif
 82:   NEPSetTarget(nep,1.1);

 84:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 85:      Define the nonlinear problem
 86:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 87:   
 88:   if (split) {
 89:     /*
 90:        Create matrices for the split form 
 91:     */
 92:     MatCreate(PETSC_COMM_WORLD,&A[0]);
 93:     MatSetSizes(A[0],PETSC_DECIDE,PETSC_DECIDE,n,n);
 94:     MatSetFromOptions(A[0]);
 95:     MatSetUp(A[0]);
 96:     MatGetOwnershipRange(A[0],&Istart,&Iend);
 97:     for (i=Istart;i<Iend;i++) {
 98:       if (i>0) { MatSetValue(A[0],i,i-1,1.0,INSERT_VALUES); }
 99:       if (i<n-1) { MatSetValue(A[0],i,i+1,1.0,INSERT_VALUES); }
100:       MatSetValue(A[0],i,i,-2.0,INSERT_VALUES);
101:     }
102:     MatAssemblyBegin(A[0],MAT_FINAL_ASSEMBLY);
103:     MatAssemblyEnd(A[0],MAT_FINAL_ASSEMBLY);

105:     MatCreate(PETSC_COMM_WORLD,&A[1]);
106:     MatSetSizes(A[1],PETSC_DECIDE,PETSC_DECIDE,n,n);
107:     MatSetFromOptions(A[1]);
108:     MatSetUp(A[1]);
109:     MatAssemblyBegin(A[1],MAT_FINAL_ASSEMBLY);
110:     MatAssemblyEnd(A[1],MAT_FINAL_ASSEMBLY);
111:     MatShift(A[1],1.0);

113:     /*
114:        Define funcions for the split form 
115:      */
116:     FNCreate(PETSC_COMM_WORLD,&f[0]);
117:     FNSetType(f[0],FNRATIONAL);
118:     coeffs = 1.0;
119:     FNRationalSetNumerator(f[0],1,&coeffs);
120:     FNCreate(PETSC_COMM_WORLD,&f[1]);
121:     FNSetType(f[1],FNSQRT);
122:     NEPSetSplitOperator(nep,2,A,f,SUBSET_NONZERO_PATTERN);

124:   } else {
125:     /*
126:        Callback form: create matrix and set Function evaluation routine
127:      */
128:     MatCreate(PETSC_COMM_WORLD,&F);
129:     MatSetSizes(F,PETSC_DECIDE,PETSC_DECIDE,n,n);
130:     MatSetFromOptions(F);
131:     MatSeqAIJSetPreallocation(F,3,NULL);
132:     MatMPIAIJSetPreallocation(F,3,NULL,1,NULL);
133:     MatSetUp(F);
134:     NEPSetFunction(nep,F,F,FormFunction,NULL);
135:   }

137:   /*
138:      Set solver parameters at runtime
139:   */
140:   NEPSetFromOptions(nep);

142:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
143:                       Solve the eigensystem
144:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
145:   NEPSolve(nep);
146:   NEPGetType(nep,&type);
147:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n",type);
148:   NEPGetDimensions(nep,&nev,NULL,NULL);
149:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

151:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
152:                     Display solution and clean up
153:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

155:   /* show detailed info unless -terse option is given by user */
156:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
157:   if (terse) {
158:     NEPErrorView(nep,NEP_ERROR_RELATIVE,NULL);
159:   } else {
160:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
161:     NEPReasonView(nep,PETSC_VIEWER_STDOUT_WORLD);
162:     NEPErrorView(nep,NEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
163:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
164:   }
165:   NEPDestroy(&nep);
166:   if (split) {
167:     MatDestroy(&A[0]);
168:     MatDestroy(&A[1]);
169:     FNDestroy(&f[0]);
170:     FNDestroy(&f[1]);
171:   } else {
172:     MatDestroy(&F);
173:   }
174:   SlepcFinalize();
175:   return ierr;
176: }

178: /* ------------------------------------------------------------------- */
181: /*
182:    FormFunction - Computes Function matrix  T(lambda)
183: */
184: PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)
185: {
187:   PetscInt       i,n,col[3],Istart,Iend;
188:   PetscBool      FirstBlock=PETSC_FALSE,LastBlock=PETSC_FALSE;
189:   PetscScalar    value[3],t;

192:   /*
193:      Compute Function entries and insert into matrix
194:   */
195:   t = PetscSqrtScalar(lambda);
196:   MatGetSize(fun,&n,NULL);
197:   MatGetOwnershipRange(fun,&Istart,&Iend);
198:   if (Istart==0) FirstBlock=PETSC_TRUE;
199:   if (Iend==n) LastBlock=PETSC_TRUE;
200:   value[0]=1.0; value[1]=t-2.0; value[2]=1.0;
201:   for (i=(FirstBlock? Istart+1: Istart); i<(LastBlock? Iend-1: Iend); i++) {
202:     col[0]=i-1; col[1]=i; col[2]=i+1;
203:     MatSetValues(fun,1,&i,3,col,value,INSERT_VALUES);
204:   }
205:   if (LastBlock) {
206:     i=n-1; col[0]=n-2; col[1]=n-1;
207:     MatSetValues(fun,1,&i,2,col,value,INSERT_VALUES);
208:   }
209:   if (FirstBlock) {
210:     i=0; col[0]=0; col[1]=1; value[0]=t-2.0; value[1]=1.0;
211:     MatSetValues(fun,1,&i,2,col,value,INSERT_VALUES);
212:   }

214:   /*
215:      Assemble matrix
216:   */
217:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
218:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
219:   if (fun != B) {
220:     MatAssemblyBegin(fun,MAT_FINAL_ASSEMBLY);
221:     MatAssemblyEnd(fun,MAT_FINAL_ASSEMBLY);
222:   }
223:   return(0);
224: }

228: /*
229:    ComputeSingularities - Computes maxnp points (at most) in the complex plane where
230:    the function T(.) is not analytic.

232:    In this case, we discretize the singularity region (-inf,0)~(-10e+6,-10e-6) 
233: */
234: PetscErrorCode ComputeSingularities(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *pt)
235: {
236:   PetscReal h;
237:   PetscInt  i;

240:   h = 12.0/(*maxnp-1);
241:   xi[0] = -1e-6; xi[*maxnp-1] = -1e+6;
242:   for (i=1;i<*maxnp-1;i++) xi[i] = -PetscPowReal(10,-6+h*i);
243:   return(0);
244: }

slepc-3.7.4/src/nep/examples/index.html0000644000175000017500000000132213107004621017345 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
tutorials/
nlevp/
makefile
slepc-3.7.4/src/nep/examples/tests/0000755000175000017500000000000013107004621016514 5ustar jromanjromanslepc-3.7.4/src/nep/examples/tests/makefile0000644000175000017500000000232013107004621020211 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/nep/examples/tests/ EXAMPLESC = EXAMPLESF = MANSEC = NEP TESTS = TESTEXAMPLES_C = include ${SLEPC_DIR}/lib/slepc/conf/slepc_common #------------------------------------------------------------------------------------ slepc-3.7.4/src/nep/examples/tests/makefile.html0000644000175000017500000000500513107004621021157 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/nep/examples/tests/
EXAMPLESC  =
EXAMPLESF  =
MANSEC     = NEP
TESTS      =

TESTEXAMPLES_C       =

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

#------------------------------------------------------------------------------------
slepc-3.7.4/src/nep/examples/tests/index.html0000644000175000017500000000300613107004621020510 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

makefile
slepc-3.7.4/src/nep/makefile.html0000644000175000017500000000463513107004621016207 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../include/slepc/private/nepimpl.h ../../include/slepcnep.h
DIRS     = interface impls examples f90-mod
LOCDIR   = src/nep/
MANSEC   = NEP

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/index.html0000644000175000017500000000344613107004621015540 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

interface/
impls/
examples/
f90-mod/
../../include/slepc/private/nepimpl.h
../../include/slepcnep.h
makefile
slepc-3.7.4/src/nep/f90-mod/0000755000175000017500000000000013107004621014707 5ustar jromanjromanslepc-3.7.4/src/nep/f90-mod/makefile0000644000175000017500000000255113107004621016412 0ustar jromanjroman # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_USING_F90' # # Makes Fortran module functions from *.h90 files in include/slepc/finclude # ALL: buildmod_slepc speciallib: buildmod_slepc specialfastlib: buildmod_slepc SPECIALLIB = yes SPECIALFASTLIB = yes CFLAGS = FFLAGS = SOURCEC = SOURCEF = slepcnepmod.F SOURCEH = LIBBASE = libslepcnep MANSEC = NEP LOCDIR = src/nep/f90-mod/ CLEANFILES = *.mod include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/f90-mod/makefile.html0000644000175000017500000000552413107004621017360 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#requiresdefine   'PETSC_USING_F90'
#
#   Makes Fortran module functions from *.h90 files in include/slepc/finclude
#
ALL: buildmod_slepc
speciallib: buildmod_slepc
specialfastlib: buildmod_slepc
SPECIALLIB     = yes
SPECIALFASTLIB = yes


CFLAGS     =
FFLAGS     =
SOURCEC    =
SOURCEF    = slepcnepmod.F
SOURCEH    =
LIBBASE    = libslepcnep
MANSEC     = NEP
LOCDIR     = src/nep/f90-mod/
CLEANFILES = *.mod

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/nep/f90-mod/index.html0000644000175000017500000000305313107004621016705 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

slepcnepmod.F
makefile
slepc-3.7.4/src/nep/f90-mod/slepcnepmod.F.html0000644000175000017500000000610313107004621020272 0ustar jromanjroman

Actual source code: slepcnepmod.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 20: #define PETSC_USE_FORTRAN_MODULES

 22:         module slepcnepdef
 23:         use slepcbv
 24:         use slepcrg
 25:         use slepcds
 26:         use slepcfn
 27:         use slepceps
 28:         use slepcpep
 29: #include <slepc/finclude/slepcnep.h>
 30: #include <slepc/finclude/ftn-custom/slepcnepdef.h90>
 31:         end module

 33:         module slepcnep
 34:         use slepcnepdef
 35: #include <slepc/finclude/slepcnep.h90>
 36:         end module

slepc-3.7.4/src/nep/f90-mod/slepcnepmod.F0000644000175000017500000000246313107004621017334 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define PETSC_USE_FORTRAN_MODULES module slepcnepdef use slepcbv use slepcrg use slepcds use slepcfn use slepceps use slepcpep #include #include end module module slepcnep use slepcnepdef #include end module slepc-3.7.4/src/nep/impls/0000755000175000017500000000000013107004621014660 5ustar jromanjromanslepc-3.7.4/src/nep/impls/makefile0000644000175000017500000000211513107004621016357 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcnep DIRS = rii slp narnoldi interpol ciss nleigs LOCDIR = src/nep/impls/ MANSEC = NEP include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/rii/0000755000175000017500000000000013107004621015443 5ustar jromanjromanslepc-3.7.4/src/nep/impls/rii/makefile0000644000175000017500000000215013107004621017141 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = rii.c SOURCEF = SOURCEH = LIBBASE = libslepcnep DIRS = MANSEC = NEP LOCDIR = src/nep/impls/rii/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/rii/rii.c.html0000644000175000017500000012352413107004621017344 0ustar jromanjroman
Actual source code: rii.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc nonlinear eigensolver: "rii"

  5:    Method: Residual inverse iteration

  7:    Algorithm:

  9:        Simple residual inverse iteration with varying shift.

 11:    References:

 13:        [1] A. Neumaier, "Residual inverse iteration for the nonlinear
 14:            eigenvalue problem", SIAM J. Numer. Anal. 22(5):914-923, 1985.

 16:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 17:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 18:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 20:    This file is part of SLEPc.

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

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

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

 36: #include <slepc/private/nepimpl.h>         /*I "slepcnep.h" I*/

 38: typedef struct {
 39:   PetscInt  max_inner_it;     /* maximum number of Newton iterations */
 40:   PetscInt  lag;              /* interval to rebuild preconditioner */
 41:   PetscBool cctol;            /* constant correction tolerance */
 42:   KSP       ksp;              /* linear solver object */
 43: } NEP_RII;

 47: PETSC_STATIC_INLINE PetscErrorCode NEPRII_KSPSolve(NEP nep,Vec b,Vec x)
 48: {
 50:   PetscInt       lits;
 51:   NEP_RII        *ctx = (NEP_RII*)nep->data;

 54:   KSPSolve(ctx->ksp,b,x);
 55:   KSPGetIterationNumber(ctx->ksp,&lits);
 56:   PetscInfo2(nep,"iter=%D, linear solve iterations=%D\n",nep->its,lits);
 57:   return(0);
 58: }

 62: PetscErrorCode NEPSetUp_RII(NEP nep)
 63: {
 65:   PetscBool      istrivial;

 68:   if (nep->nev>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Requested several eigenpairs but this solver can compute only one");
 69:   if (nep->ncv) { PetscInfo(nep,"Setting ncv = 1, ignoring user-provided value\n"); }
 70:   nep->ncv = 1;
 71:   if (nep->mpd) { PetscInfo(nep,"Setting mpd = 1, ignoring user-provided value\n"); }
 72:   nep->mpd = 1;
 73:   if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv);
 74:   if (nep->which && nep->which!=NEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of which");

 76:   RGIsTrivial(nep->rg,&istrivial);
 77:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support region filtering");

 79:   NEPAllocateSolution(nep,0);
 80:   NEPSetWorkVecs(nep,2);
 81:   return(0);
 82: }

 86: PetscErrorCode NEPSolve_RII(NEP nep)
 87: {
 88:   PetscErrorCode     ierr;
 89:   NEP_RII            *ctx = (NEP_RII*)nep->data;
 90:   Mat                T=nep->function,Tp=nep->jacobian,Tsigma;
 91:   Vec                u,r=nep->work[0],delta=nep->work[1];
 92:   PetscScalar        lambda,a1,a2,corr;
 93:   PetscReal          resnorm=1.0,ktol=0.1;
 94:   PetscBool          hascopy;
 95:   PetscInt           inner_its;
 96:   KSPConvergedReason kspreason;

 99:   /* get initial approximation of eigenvalue and eigenvector */
100:   NEPGetDefaultShift(nep,&lambda);
101:   if (!nep->nini) {
102:     BVSetRandomColumn(nep->V,0);
103:   }
104:   BVGetColumn(nep->V,0,&u);
105:   NEPComputeFunction(nep,lambda,T,T);

107:   /* prepare linear solver */
108:   if (!ctx->ksp) { NEPRIIGetKSP(nep,&ctx->ksp); }
109:   MatDuplicate(T,MAT_COPY_VALUES,&Tsigma);
110:   KSPSetOperators(ctx->ksp,Tsigma,Tsigma);

112:   /* Restart loop */
113:   while (nep->reason == NEP_CONVERGED_ITERATING) {
114:     nep->its++;

116:     /* Use Newton's method to compute nonlinear Rayleigh functional. Current eigenvalue 
117:        estimate as starting value. */
118:     inner_its=0;
119:     do {
120:       NEPApplyFunction(nep,lambda,u,delta,r,T,T);
121:       VecDot(r,u,&a1);
122:       NEPApplyJacobian(nep,lambda,u,delta,r,Tp);
123:       VecDot(r,u,&a2);
124:       corr = a1/a2;
125:       lambda = lambda - corr;
126:       inner_its++;
127:     } while (PetscAbsScalar(corr)>PETSC_SQRT_MACHINE_EPSILON && inner_its<ctx->max_inner_it);

129:     /* update preconditioner and set adaptive tolerance */
130:     if (ctx->lag && !(nep->its%ctx->lag) && nep->its>2*ctx->lag && resnorm<1e-2) {
131:       MatHasOperation(T,MATOP_COPY,&hascopy);
132:       if (hascopy) {
133:         MatCopy(T,Tsigma,DIFFERENT_NONZERO_PATTERN);
134:       } else {
135:         MatDestroy(&Tsigma);
136:         MatDuplicate(T,MAT_COPY_VALUES,&Tsigma);
137:       }
138:       KSPSetOperators(ctx->ksp,Tsigma,Tsigma);
139:     }
140:     if (!ctx->cctol) {
141:       ktol = PetscMax(ktol/2.0,PETSC_MACHINE_EPSILON*10.0);
142:       KSPSetTolerances(ctx->ksp,ktol,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);
143:     }

145:     /* form residual,  r = T(lambda)*u */
146:     NEPApplyFunction(nep,lambda,u,delta,r,T,T);

148:     /* convergence test */
149:     VecNorm(r,NORM_2,&resnorm);
150:     (*nep->converged)(nep,lambda,0,resnorm,&nep->errest[nep->nconv],nep->convergedctx);
151:     nep->eigr[nep->nconv] = lambda;
152:     if (nep->errest[nep->nconv]<=nep->tol) {
153:       nep->nconv = nep->nconv + 1;
154:     }
155:     (*nep->stopping)(nep,nep->its,nep->max_it,nep->nconv,nep->nev,&nep->reason,nep->stoppingctx);
156:     NEPMonitor(nep,nep->its,nep->nconv,nep->eigr,nep->eigi,nep->errest,1);

158:     if (nep->reason == NEP_CONVERGED_ITERATING) {
159:       /* eigenvector correction: delta = T(sigma)\r */
160:       NEPRII_KSPSolve(nep,r,delta);
161:       KSPGetConvergedReason(ctx->ksp,&kspreason);
162:       if (kspreason<0) {
163:         PetscInfo1(nep,"iter=%D, linear solve failed, stopping solve\n",nep->its);
164:         nep->reason = NEP_DIVERGED_LINEAR_SOLVE;
165:         break;
166:       }

168:       /* update eigenvector: u = u - delta */
169:       VecAXPY(u,-1.0,delta);

171:       /* normalize eigenvector */
172:       VecNormalize(u,NULL);
173:     }
174:   }
175:   MatDestroy(&Tsigma);
176:   BVRestoreColumn(nep->V,0,&u);
177:   return(0);
178: }

182: PetscErrorCode NEPSetFromOptions_RII(PetscOptionItems *PetscOptionsObject,NEP nep)
183: {
185:   NEP_RII        *ctx = (NEP_RII*)nep->data;
186:   PetscBool      flg;
187:   PetscInt       i;

190:   if (!ctx->ksp) { NEPRIIGetKSP(nep,&ctx->ksp); }
191:   KSPSetOperators(ctx->ksp,nep->function,nep->function_pre);
192:   KSPSetFromOptions(ctx->ksp);
193:   PetscOptionsHead(PetscOptionsObject,"NEP RII Options");
194:     PetscOptionsInt("-nep_rii_max_it","Maximum number of Newton iterations for updating Rayleigh functional","NEPRIISetMaximumIterations",ctx->max_inner_it,&ctx->max_inner_it,NULL);
195:     PetscOptionsBool("-nep_rii_const_correction_tol","Constant correction tolerance for the linear solver","NEPRIISetConstCorrectionTol",ctx->cctol,&ctx->cctol,NULL);
196:     i = 0;
197:     PetscOptionsInt("-nep_rii_lag_preconditioner","Interval to rebuild preconditioner","NEPRIISetLagPreconditioner",ctx->lag,&i,&flg);
198:     if (flg) { NEPRIISetLagPreconditioner(nep,i); }
199:   PetscOptionsTail();
200:   return(0);
201: }

205: static PetscErrorCode NEPRIISetMaximumIterations_RII(NEP nep,PetscInt its)
206: {
207:   NEP_RII *ctx = (NEP_RII*)nep->data;

210:   ctx->max_inner_it = its;
211:   return(0);
212: }

216: /*@
217:    NEPRIISetMaximumIterations - Sets the maximum number of inner iterations to be
218:    used in the RII solver. These are the Newton iterations related to the computation
219:    of the nonlinear Rayleigh functional.

221:    Logically Collective on NEP

223:    Input Parameters:
224: +  nep - nonlinear eigenvalue solver
225: -  its - maximum inner iterations

227:    Level: advanced

229: .seealso: NEPRIIGetMaximumIterations()
230: @*/
231: PetscErrorCode NEPRIISetMaximumIterations(NEP nep,PetscInt its)
232: {

238:   PetscTryMethod(nep,"NEPRIISetMaximumIterations_C",(NEP,PetscInt),(nep,its));
239:   return(0);
240: }

244: static PetscErrorCode NEPRIIGetMaximumIterations_RII(NEP nep,PetscInt *its)
245: {
246:   NEP_RII *ctx = (NEP_RII*)nep->data;

249:   *its = ctx->max_inner_it;
250:   return(0);
251: }

255: /*@
256:    NEPRIIGetMaximumIterations - Gets the maximum number of inner iterations of RII.

258:    Not Collective

260:    Input Parameter:
261: .  nep - nonlinear eigenvalue solver

263:    Output Parameter:
264: .  its - maximum inner iterations

266:    Level: advanced

268: .seealso: NEPRIISetMaximumIterations()
269: @*/
270: PetscErrorCode NEPRIIGetMaximumIterations(NEP nep,PetscInt *its)
271: {

277:   PetscUseMethod(nep,"NEPRIIGetMaximumIterations_C",(NEP,PetscInt*),(nep,its));
278:   return(0);
279: }

283: static PetscErrorCode NEPRIISetLagPreconditioner_RII(NEP nep,PetscInt lag)
284: {
285:   NEP_RII *ctx = (NEP_RII*)nep->data;

288:   if (lag<0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Lag must be non-negative");
289:   ctx->lag = lag;
290:   return(0);
291: }

295: /*@
296:    NEPRIISetLagPreconditioner - Determines when the preconditioner is rebuilt in the
297:    nonlinear solve.

299:    Logically Collective on NEP

301:    Input Parameters:
302: +  nep - nonlinear eigenvalue solver
303: -   lag - 0 indicates NEVER rebuild, 1 means rebuild every time the Jacobian is
304:           computed within the nonlinear iteration, 2 means every second time
305:           the Jacobian is built, etc.

307:    Options Database Keys:
308: .  -nep_rii_lag_preconditioner <lag>

310:    Notes:
311:    The default is 1.
312:    The preconditioner is ALWAYS built in the first iteration of a nonlinear solve.

314:    Level: intermediate

316: .seealso: NEPRIIGetLagPreconditioner()
317: @*/
318: PetscErrorCode NEPRIISetLagPreconditioner(NEP nep,PetscInt lag)
319: {

325:   PetscTryMethod(nep,"NEPRIISetLagPreconditioner_C",(NEP,PetscInt),(nep,lag));
326:   return(0);
327: }

331: static PetscErrorCode NEPRIIGetLagPreconditioner_RII(NEP nep,PetscInt *lag)
332: {
333:   NEP_RII *ctx = (NEP_RII*)nep->data;

336:   *lag = ctx->lag;
337:   return(0);
338: }

342: /*@
343:    NEPRIIGetLagPreconditioner - Indicates how often the preconditioner is rebuilt.

345:    Not Collective

347:    Input Parameter:
348: .  nep - nonlinear eigenvalue solver

350:    Output Parameter:
351: .  lag - the lag parameter

353:    Level: intermediate

355: .seealso: NEPRIISetLagPreconditioner()
356: @*/
357: PetscErrorCode NEPRIIGetLagPreconditioner(NEP nep,PetscInt *lag)
358: {

364:   PetscUseMethod(nep,"NEPRIIGetLagPreconditioner_C",(NEP,PetscInt*),(nep,lag));
365:   return(0);
366: }

370: static PetscErrorCode NEPRIISetConstCorrectionTol_RII(NEP nep,PetscBool cct)
371: {
372:   NEP_RII *ctx = (NEP_RII*)nep->data;

375:   ctx->cctol = cct;
376:   return(0);
377: }

381: /*@
382:    NEPRIISetConstCorrectionTol - Sets a flag to keep the tolerance used
383:    in the linear solver constant.

385:    Logically Collective on NEP

387:    Input Parameters:
388: +  nep - nonlinear eigenvalue solver
389: -  cct - a boolean value

391:    Options Database Keys:
392: .  -nep_rii_const_correction_tol <bool> - set the boolean flag

394:    Notes:
395:    By default, an exponentially decreasing tolerance is set in the KSP used
396:    within the nonlinear iteration, so that each Newton iteration requests
397:    better accuracy than the previous one. The constant correction tolerance
398:    flag stops this behaviour.

400:    Level: intermediate

402: .seealso: NEPRIIGetConstCorrectionTol()
403: @*/
404: PetscErrorCode NEPRIISetConstCorrectionTol(NEP nep,PetscBool cct)
405: {

411:   PetscTryMethod(nep,"NEPRIISetConstCorrectionTol_C",(NEP,PetscBool),(nep,cct));
412:   return(0);
413: }

417: static PetscErrorCode NEPRIIGetConstCorrectionTol_RII(NEP nep,PetscBool *cct)
418: {
419:   NEP_RII *ctx = (NEP_RII*)nep->data;

422:   *cct = ctx->cctol;
423:   return(0);
424: }

428: /*@
429:    NEPRIIGetConstCorrectionTol - Returns the constant tolerance flag.

431:    Not Collective

433:    Input Parameter:
434: .  nep - nonlinear eigenvalue solver

436:    Output Parameter:
437: .  cct - the value of the constant tolerance flag

439:    Level: intermediate

441: .seealso: NEPRIISetConstCorrectionTol()
442: @*/
443: PetscErrorCode NEPRIIGetConstCorrectionTol(NEP nep,PetscBool *cct)
444: {

450:   PetscUseMethod(nep,"NEPRIIGetConstCorrectionTol_C",(NEP,PetscBool*),(nep,cct));
451:   return(0);
452: }

456: static PetscErrorCode NEPRIISetKSP_RII(NEP nep,KSP ksp)
457: {
459:   NEP_RII        *ctx = (NEP_RII*)nep->data;

462:   PetscObjectReference((PetscObject)ksp);
463:   KSPDestroy(&ctx->ksp);
464:   ctx->ksp = ksp;
465:   PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);
466:   nep->state = NEP_STATE_INITIAL;
467:   return(0);
468: }

472: /*@
473:    NEPRIISetKSP - Associate a linear solver object (KSP) to the nonlinear
474:    eigenvalue solver.

476:    Collective on NEP

478:    Input Parameters:
479: +  nep - eigenvalue solver
480: -  ksp - the linear solver object

482:    Level: advanced

484: .seealso: NEPRIIGetKSP()
485: @*/
486: PetscErrorCode NEPRIISetKSP(NEP nep,KSP ksp)
487: {

494:   PetscTryMethod(nep,"NEPRIISetKSP_C",(NEP,KSP),(nep,ksp));
495:   return(0);
496: }

500: static PetscErrorCode NEPRIIGetKSP_RII(NEP nep,KSP *ksp)
501: {
503:   NEP_RII        *ctx = (NEP_RII*)nep->data;

506:   if (!ctx->ksp) {
507:     KSPCreate(PetscObjectComm((PetscObject)nep),&ctx->ksp);
508:     KSPSetOptionsPrefix(ctx->ksp,((PetscObject)nep)->prefix);
509:     KSPAppendOptionsPrefix(ctx->ksp,"nep_rii_");
510:     PetscObjectIncrementTabLevel((PetscObject)ctx->ksp,(PetscObject)nep,1);
511:     PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);
512:     KSPSetErrorIfNotConverged(ctx->ksp,PETSC_TRUE);
513:   }
514:   *ksp = ctx->ksp;
515:   return(0);
516: }

520: /*@
521:    NEPRIIGetKSP - Retrieve the linear solver object (KSP) associated with
522:    the nonlinear eigenvalue solver.

524:    Not Collective

526:    Input Parameter:
527: .  nep - nonlinear eigenvalue solver

529:    Output Parameter:
530: .  ksp - the linear solver object

532:    Level: advanced

534: .seealso: NEPRIISetKSP()
535: @*/
536: PetscErrorCode NEPRIIGetKSP(NEP nep,KSP *ksp)
537: {

543:   PetscUseMethod(nep,"NEPRIIGetKSP_C",(NEP,KSP*),(nep,ksp));
544:   return(0);
545: }

549: PetscErrorCode NEPView_RII(NEP nep,PetscViewer viewer)
550: {
552:   NEP_RII        *ctx = (NEP_RII*)nep->data;
553:   PetscBool      isascii;

556:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
557:   if (isascii) {
558:     if (!ctx->ksp) { NEPRIIGetKSP(nep,&ctx->ksp); }
559:     PetscViewerASCIIPrintf(viewer,"  RII: maximum number of inner iterations: %D\n",ctx->max_inner_it);
560:     if (ctx->cctol) {
561:       PetscViewerASCIIPrintf(viewer,"  RII: using a constant tolerance for the linear solver\n");
562:     }
563:     if (ctx->lag) {
564:       PetscViewerASCIIPrintf(viewer,"  RII: updating the preconditioner every %D iterations\n",ctx->lag);
565:     }
566:     PetscViewerASCIIPushTab(viewer);
567:     KSPView(ctx->ksp,viewer);
568:     PetscViewerASCIIPopTab(viewer);
569:   }
570:   return(0);
571: }

575: PetscErrorCode NEPDestroy_RII(NEP nep)
576: {
578:   NEP_RII        *ctx = (NEP_RII*)nep->data;

581:   KSPDestroy(&ctx->ksp);
582:   PetscFree(nep->data);
583:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetMaximumIterations_C",NULL);
584:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetMaximumIterations_C",NULL);
585:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetLagPreconditioner_C",NULL);
586:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetLagPreconditioner_C",NULL);
587:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetConstCorrectionTol_C",NULL);
588:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetConstCorrectionTol_C",NULL);
589:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetKSP_C",NULL);
590:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetKSP_C",NULL);
591:   return(0);
592: }

596: PETSC_EXTERN PetscErrorCode NEPCreate_RII(NEP nep)
597: {
599:   NEP_RII        *ctx;

602:   PetscNewLog(nep,&ctx);
603:   ctx->max_inner_it = 10;
604:   ctx->lag          = 1;
605:   ctx->cctol        = PETSC_FALSE;
606:   nep->data = (void*)ctx;

608:   nep->ops->solve          = NEPSolve_RII;
609:   nep->ops->setup          = NEPSetUp_RII;
610:   nep->ops->setfromoptions = NEPSetFromOptions_RII;
611:   nep->ops->destroy        = NEPDestroy_RII;
612:   nep->ops->view           = NEPView_RII;
613:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetMaximumIterations_C",NEPRIISetMaximumIterations_RII);
614:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetMaximumIterations_C",NEPRIIGetMaximumIterations_RII);
615:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetLagPreconditioner_C",NEPRIISetLagPreconditioner_RII);
616:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetLagPreconditioner_C",NEPRIIGetLagPreconditioner_RII);
617:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetConstCorrectionTol_C",NEPRIISetConstCorrectionTol_RII);
618:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetConstCorrectionTol_C",NEPRIIGetConstCorrectionTol_RII);
619:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetKSP_C",NEPRIISetKSP_RII);
620:   PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetKSP_C",NEPRIIGetKSP_RII);
621:   return(0);
622: }

slepc-3.7.4/src/nep/impls/rii/makefile.html0000644000175000017500000000464413107004621020116 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = rii.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcnep
DIRS     =
MANSEC   = NEP
LOCDIR   = src/nep/impls/rii/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/impls/rii/rii.c0000644000175000017500000005070513107004621016401 0ustar jromanjroman/* SLEPc nonlinear eigensolver: "rii" Method: Residual inverse iteration Algorithm: Simple residual inverse iteration with varying shift. References: [1] A. Neumaier, "Residual inverse iteration for the nonlinear eigenvalue problem", SIAM J. Numer. Anal. 22(5):914-923, 1985. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ typedef struct { PetscInt max_inner_it; /* maximum number of Newton iterations */ PetscInt lag; /* interval to rebuild preconditioner */ PetscBool cctol; /* constant correction tolerance */ KSP ksp; /* linear solver object */ } NEP_RII; #undef __FUNCT__ #define __FUNCT__ "NEPRII_KSPSolve" PETSC_STATIC_INLINE PetscErrorCode NEPRII_KSPSolve(NEP nep,Vec b,Vec x) { PetscErrorCode ierr; PetscInt lits; NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; ierr = KSPSolve(ctx->ksp,b,x);CHKERRQ(ierr); ierr = KSPGetIterationNumber(ctx->ksp,&lits);CHKERRQ(ierr); ierr = PetscInfo2(nep,"iter=%D, linear solve iterations=%D\n",nep->its,lits);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetUp_RII" PetscErrorCode NEPSetUp_RII(NEP nep) { PetscErrorCode ierr; PetscBool istrivial; PetscFunctionBegin; if (nep->nev>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Requested several eigenpairs but this solver can compute only one"); if (nep->ncv) { ierr = PetscInfo(nep,"Setting ncv = 1, ignoring user-provided value\n");CHKERRQ(ierr); } nep->ncv = 1; if (nep->mpd) { ierr = PetscInfo(nep,"Setting mpd = 1, ignoring user-provided value\n");CHKERRQ(ierr); } nep->mpd = 1; if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv); if (nep->which && nep->which!=NEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of which"); ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support region filtering"); ierr = NEPAllocateSolution(nep,0);CHKERRQ(ierr); ierr = NEPSetWorkVecs(nep,2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSolve_RII" PetscErrorCode NEPSolve_RII(NEP nep) { PetscErrorCode ierr; NEP_RII *ctx = (NEP_RII*)nep->data; Mat T=nep->function,Tp=nep->jacobian,Tsigma; Vec u,r=nep->work[0],delta=nep->work[1]; PetscScalar lambda,a1,a2,corr; PetscReal resnorm=1.0,ktol=0.1; PetscBool hascopy; PetscInt inner_its; KSPConvergedReason kspreason; PetscFunctionBegin; /* get initial approximation of eigenvalue and eigenvector */ ierr = NEPGetDefaultShift(nep,&lambda);CHKERRQ(ierr); if (!nep->nini) { ierr = BVSetRandomColumn(nep->V,0);CHKERRQ(ierr); } ierr = BVGetColumn(nep->V,0,&u);CHKERRQ(ierr); ierr = NEPComputeFunction(nep,lambda,T,T);CHKERRQ(ierr); /* prepare linear solver */ if (!ctx->ksp) { ierr = NEPRIIGetKSP(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = MatDuplicate(T,MAT_COPY_VALUES,&Tsigma);CHKERRQ(ierr); ierr = KSPSetOperators(ctx->ksp,Tsigma,Tsigma);CHKERRQ(ierr); /* Restart loop */ while (nep->reason == NEP_CONVERGED_ITERATING) { nep->its++; /* Use Newton's method to compute nonlinear Rayleigh functional. Current eigenvalue estimate as starting value. */ inner_its=0; do { ierr = NEPApplyFunction(nep,lambda,u,delta,r,T,T);CHKERRQ(ierr); ierr = VecDot(r,u,&a1);CHKERRQ(ierr); ierr = NEPApplyJacobian(nep,lambda,u,delta,r,Tp);CHKERRQ(ierr); ierr = VecDot(r,u,&a2);CHKERRQ(ierr); corr = a1/a2; lambda = lambda - corr; inner_its++; } while (PetscAbsScalar(corr)>PETSC_SQRT_MACHINE_EPSILON && inner_itsmax_inner_it); /* update preconditioner and set adaptive tolerance */ if (ctx->lag && !(nep->its%ctx->lag) && nep->its>2*ctx->lag && resnorm<1e-2) { ierr = MatHasOperation(T,MATOP_COPY,&hascopy);CHKERRQ(ierr); if (hascopy) { ierr = MatCopy(T,Tsigma,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); } else { ierr = MatDestroy(&Tsigma);CHKERRQ(ierr); ierr = MatDuplicate(T,MAT_COPY_VALUES,&Tsigma);CHKERRQ(ierr); } ierr = KSPSetOperators(ctx->ksp,Tsigma,Tsigma);CHKERRQ(ierr); } if (!ctx->cctol) { ktol = PetscMax(ktol/2.0,PETSC_MACHINE_EPSILON*10.0); ierr = KSPSetTolerances(ctx->ksp,ktol,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr); } /* form residual, r = T(lambda)*u */ ierr = NEPApplyFunction(nep,lambda,u,delta,r,T,T);CHKERRQ(ierr); /* convergence test */ ierr = VecNorm(r,NORM_2,&resnorm);CHKERRQ(ierr); ierr = (*nep->converged)(nep,lambda,0,resnorm,&nep->errest[nep->nconv],nep->convergedctx);CHKERRQ(ierr); nep->eigr[nep->nconv] = lambda; if (nep->errest[nep->nconv]<=nep->tol) { nep->nconv = nep->nconv + 1; } ierr = (*nep->stopping)(nep,nep->its,nep->max_it,nep->nconv,nep->nev,&nep->reason,nep->stoppingctx);CHKERRQ(ierr); ierr = NEPMonitor(nep,nep->its,nep->nconv,nep->eigr,nep->eigi,nep->errest,1);CHKERRQ(ierr); if (nep->reason == NEP_CONVERGED_ITERATING) { /* eigenvector correction: delta = T(sigma)\r */ ierr = NEPRII_KSPSolve(nep,r,delta);CHKERRQ(ierr); ierr = KSPGetConvergedReason(ctx->ksp,&kspreason);CHKERRQ(ierr); if (kspreason<0) { ierr = PetscInfo1(nep,"iter=%D, linear solve failed, stopping solve\n",nep->its);CHKERRQ(ierr); nep->reason = NEP_DIVERGED_LINEAR_SOLVE; break; } /* update eigenvector: u = u - delta */ ierr = VecAXPY(u,-1.0,delta);CHKERRQ(ierr); /* normalize eigenvector */ ierr = VecNormalize(u,NULL);CHKERRQ(ierr); } } ierr = MatDestroy(&Tsigma);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,0,&u);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetFromOptions_RII" PetscErrorCode NEPSetFromOptions_RII(PetscOptionItems *PetscOptionsObject,NEP nep) { PetscErrorCode ierr; NEP_RII *ctx = (NEP_RII*)nep->data; PetscBool flg; PetscInt i; PetscFunctionBegin; if (!ctx->ksp) { ierr = NEPRIIGetKSP(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = KSPSetOperators(ctx->ksp,nep->function,nep->function_pre);CHKERRQ(ierr); ierr = KSPSetFromOptions(ctx->ksp);CHKERRQ(ierr); ierr = PetscOptionsHead(PetscOptionsObject,"NEP RII Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_rii_max_it","Maximum number of Newton iterations for updating Rayleigh functional","NEPRIISetMaximumIterations",ctx->max_inner_it,&ctx->max_inner_it,NULL);CHKERRQ(ierr); ierr = PetscOptionsBool("-nep_rii_const_correction_tol","Constant correction tolerance for the linear solver","NEPRIISetConstCorrectionTol",ctx->cctol,&ctx->cctol,NULL);CHKERRQ(ierr); i = 0; ierr = PetscOptionsInt("-nep_rii_lag_preconditioner","Interval to rebuild preconditioner","NEPRIISetLagPreconditioner",ctx->lag,&i,&flg);CHKERRQ(ierr); if (flg) { ierr = NEPRIISetLagPreconditioner(nep,i);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetMaximumIterations_RII" static PetscErrorCode NEPRIISetMaximumIterations_RII(NEP nep,PetscInt its) { NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; ctx->max_inner_it = its; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetMaximumIterations" /*@ NEPRIISetMaximumIterations - Sets the maximum number of inner iterations to be used in the RII solver. These are the Newton iterations related to the computation of the nonlinear Rayleigh functional. Logically Collective on NEP Input Parameters: + nep - nonlinear eigenvalue solver - its - maximum inner iterations Level: advanced .seealso: NEPRIIGetMaximumIterations() @*/ PetscErrorCode NEPRIISetMaximumIterations(NEP nep,PetscInt its) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,its,2); ierr = PetscTryMethod(nep,"NEPRIISetMaximumIterations_C",(NEP,PetscInt),(nep,its));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetMaximumIterations_RII" static PetscErrorCode NEPRIIGetMaximumIterations_RII(NEP nep,PetscInt *its) { NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; *its = ctx->max_inner_it; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetMaximumIterations" /*@ NEPRIIGetMaximumIterations - Gets the maximum number of inner iterations of RII. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . its - maximum inner iterations Level: advanced .seealso: NEPRIISetMaximumIterations() @*/ PetscErrorCode NEPRIIGetMaximumIterations(NEP nep,PetscInt *its) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(its,2); ierr = PetscUseMethod(nep,"NEPRIIGetMaximumIterations_C",(NEP,PetscInt*),(nep,its));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetLagPreconditioner_RII" static PetscErrorCode NEPRIISetLagPreconditioner_RII(NEP nep,PetscInt lag) { NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; if (lag<0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Lag must be non-negative"); ctx->lag = lag; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetLagPreconditioner" /*@ NEPRIISetLagPreconditioner - Determines when the preconditioner is rebuilt in the nonlinear solve. Logically Collective on NEP Input Parameters: + nep - nonlinear eigenvalue solver - lag - 0 indicates NEVER rebuild, 1 means rebuild every time the Jacobian is computed within the nonlinear iteration, 2 means every second time the Jacobian is built, etc. Options Database Keys: . -nep_rii_lag_preconditioner Notes: The default is 1. The preconditioner is ALWAYS built in the first iteration of a nonlinear solve. Level: intermediate .seealso: NEPRIIGetLagPreconditioner() @*/ PetscErrorCode NEPRIISetLagPreconditioner(NEP nep,PetscInt lag) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,lag,2); ierr = PetscTryMethod(nep,"NEPRIISetLagPreconditioner_C",(NEP,PetscInt),(nep,lag));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetLagPreconditioner_RII" static PetscErrorCode NEPRIIGetLagPreconditioner_RII(NEP nep,PetscInt *lag) { NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; *lag = ctx->lag; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetLagPreconditioner" /*@ NEPRIIGetLagPreconditioner - Indicates how often the preconditioner is rebuilt. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . lag - the lag parameter Level: intermediate .seealso: NEPRIISetLagPreconditioner() @*/ PetscErrorCode NEPRIIGetLagPreconditioner(NEP nep,PetscInt *lag) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(lag,2); ierr = PetscUseMethod(nep,"NEPRIIGetLagPreconditioner_C",(NEP,PetscInt*),(nep,lag));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetConstCorrectionTol_RII" static PetscErrorCode NEPRIISetConstCorrectionTol_RII(NEP nep,PetscBool cct) { NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; ctx->cctol = cct; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetConstCorrectionTol" /*@ NEPRIISetConstCorrectionTol - Sets a flag to keep the tolerance used in the linear solver constant. Logically Collective on NEP Input Parameters: + nep - nonlinear eigenvalue solver - cct - a boolean value Options Database Keys: . -nep_rii_const_correction_tol - set the boolean flag Notes: By default, an exponentially decreasing tolerance is set in the KSP used within the nonlinear iteration, so that each Newton iteration requests better accuracy than the previous one. The constant correction tolerance flag stops this behaviour. Level: intermediate .seealso: NEPRIIGetConstCorrectionTol() @*/ PetscErrorCode NEPRIISetConstCorrectionTol(NEP nep,PetscBool cct) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,cct,2); ierr = PetscTryMethod(nep,"NEPRIISetConstCorrectionTol_C",(NEP,PetscBool),(nep,cct));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetConstCorrectionTol_RII" static PetscErrorCode NEPRIIGetConstCorrectionTol_RII(NEP nep,PetscBool *cct) { NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; *cct = ctx->cctol; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetConstCorrectionTol" /*@ NEPRIIGetConstCorrectionTol - Returns the constant tolerance flag. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . cct - the value of the constant tolerance flag Level: intermediate .seealso: NEPRIISetConstCorrectionTol() @*/ PetscErrorCode NEPRIIGetConstCorrectionTol(NEP nep,PetscBool *cct) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(cct,2); ierr = PetscUseMethod(nep,"NEPRIIGetConstCorrectionTol_C",(NEP,PetscBool*),(nep,cct));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetKSP_RII" static PetscErrorCode NEPRIISetKSP_RII(NEP nep,KSP ksp) { PetscErrorCode ierr; NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; ierr = PetscObjectReference((PetscObject)ksp);CHKERRQ(ierr); ierr = KSPDestroy(&ctx->ksp);CHKERRQ(ierr); ctx->ksp = ksp; ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);CHKERRQ(ierr); nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIISetKSP" /*@ NEPRIISetKSP - Associate a linear solver object (KSP) to the nonlinear eigenvalue solver. Collective on NEP Input Parameters: + nep - eigenvalue solver - ksp - the linear solver object Level: advanced .seealso: NEPRIIGetKSP() @*/ PetscErrorCode NEPRIISetKSP(NEP nep,KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidHeaderSpecific(ksp,KSP_CLASSID,2); PetscCheckSameComm(nep,1,ksp,2); ierr = PetscTryMethod(nep,"NEPRIISetKSP_C",(NEP,KSP),(nep,ksp));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetKSP_RII" static PetscErrorCode NEPRIIGetKSP_RII(NEP nep,KSP *ksp) { PetscErrorCode ierr; NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; if (!ctx->ksp) { ierr = KSPCreate(PetscObjectComm((PetscObject)nep),&ctx->ksp);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(ctx->ksp,((PetscObject)nep)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(ctx->ksp,"nep_rii_");CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->ksp,(PetscObject)nep,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(ctx->ksp,PETSC_TRUE);CHKERRQ(ierr); } *ksp = ctx->ksp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPRIIGetKSP" /*@ NEPRIIGetKSP - Retrieve the linear solver object (KSP) associated with the nonlinear eigenvalue solver. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . ksp - the linear solver object Level: advanced .seealso: NEPRIISetKSP() @*/ PetscErrorCode NEPRIIGetKSP(NEP nep,KSP *ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(ksp,2); ierr = PetscUseMethod(nep,"NEPRIIGetKSP_C",(NEP,KSP*),(nep,ksp));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPView_RII" PetscErrorCode NEPView_RII(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; NEP_RII *ctx = (NEP_RII*)nep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (!ctx->ksp) { ierr = NEPRIIGetKSP(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," RII: maximum number of inner iterations: %D\n",ctx->max_inner_it);CHKERRQ(ierr); if (ctx->cctol) { ierr = PetscViewerASCIIPrintf(viewer," RII: using a constant tolerance for the linear solver\n");CHKERRQ(ierr); } if (ctx->lag) { ierr = PetscViewerASCIIPrintf(viewer," RII: updating the preconditioner every %D iterations\n",ctx->lag);CHKERRQ(ierr); } ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = KSPView(ctx->ksp,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPDestroy_RII" PetscErrorCode NEPDestroy_RII(NEP nep) { PetscErrorCode ierr; NEP_RII *ctx = (NEP_RII*)nep->data; PetscFunctionBegin; ierr = KSPDestroy(&ctx->ksp);CHKERRQ(ierr); ierr = PetscFree(nep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetMaximumIterations_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetMaximumIterations_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetLagPreconditioner_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetLagPreconditioner_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetConstCorrectionTol_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetConstCorrectionTol_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetKSP_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetKSP_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCreate_RII" PETSC_EXTERN PetscErrorCode NEPCreate_RII(NEP nep) { PetscErrorCode ierr; NEP_RII *ctx; PetscFunctionBegin; ierr = PetscNewLog(nep,&ctx);CHKERRQ(ierr); ctx->max_inner_it = 10; ctx->lag = 1; ctx->cctol = PETSC_FALSE; nep->data = (void*)ctx; nep->ops->solve = NEPSolve_RII; nep->ops->setup = NEPSetUp_RII; nep->ops->setfromoptions = NEPSetFromOptions_RII; nep->ops->destroy = NEPDestroy_RII; nep->ops->view = NEPView_RII; ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetMaximumIterations_C",NEPRIISetMaximumIterations_RII);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetMaximumIterations_C",NEPRIIGetMaximumIterations_RII);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetLagPreconditioner_C",NEPRIISetLagPreconditioner_RII);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetLagPreconditioner_C",NEPRIIGetLagPreconditioner_RII);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetConstCorrectionTol_C",NEPRIISetConstCorrectionTol_RII);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetConstCorrectionTol_C",NEPRIIGetConstCorrectionTol_RII);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIISetKSP_C",NEPRIISetKSP_RII);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPRIIGetKSP_C",NEPRIIGetKSP_RII);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/impls/rii/index.html0000644000175000017500000000303713107004621017443 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

rii.c
makefile
slepc-3.7.4/src/nep/impls/rii/ftn-auto/0000755000175000017500000000000013107004621017200 5ustar jromanjromanslepc-3.7.4/src/nep/impls/rii/ftn-auto/makefile0000644000175000017500000000035313107004621020701 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = riif.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcnep LOCDIR = src/nep/impls/rii/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/rii/ftn-auto/riif.c0000644000175000017500000000757313107004621020311 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* rii.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriisetmaximumiterations_ NEPRIISETMAXIMUMITERATIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriisetmaximumiterations_ nepriisetmaximumiterations #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriigetmaximumiterations_ NEPRIIGETMAXIMUMITERATIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriigetmaximumiterations_ nepriigetmaximumiterations #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriisetlagpreconditioner_ NEPRIISETLAGPRECONDITIONER #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriisetlagpreconditioner_ nepriisetlagpreconditioner #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriigetlagpreconditioner_ NEPRIIGETLAGPRECONDITIONER #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriigetlagpreconditioner_ nepriigetlagpreconditioner #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriisetconstcorrectiontol_ NEPRIISETCONSTCORRECTIONTOL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriisetconstcorrectiontol_ nepriisetconstcorrectiontol #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriigetconstcorrectiontol_ NEPRIIGETCONSTCORRECTIONTOL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriigetconstcorrectiontol_ nepriigetconstcorrectiontol #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriisetksp_ NEPRIISETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriisetksp_ nepriisetksp #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepriigetksp_ NEPRIIGETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepriigetksp_ nepriigetksp #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepriisetmaximumiterations_(NEP nep,PetscInt *its, int *__ierr ){ *__ierr = NEPRIISetMaximumIterations( (NEP)PetscToPointer((nep) ),*its); } PETSC_EXTERN void PETSC_STDCALL nepriigetmaximumiterations_(NEP nep,PetscInt *its, int *__ierr ){ *__ierr = NEPRIIGetMaximumIterations( (NEP)PetscToPointer((nep) ),its); } PETSC_EXTERN void PETSC_STDCALL nepriisetlagpreconditioner_(NEP nep,PetscInt *lag, int *__ierr ){ *__ierr = NEPRIISetLagPreconditioner( (NEP)PetscToPointer((nep) ),*lag); } PETSC_EXTERN void PETSC_STDCALL nepriigetlagpreconditioner_(NEP nep,PetscInt *lag, int *__ierr ){ *__ierr = NEPRIIGetLagPreconditioner( (NEP)PetscToPointer((nep) ),lag); } PETSC_EXTERN void PETSC_STDCALL nepriisetconstcorrectiontol_(NEP nep,PetscBool *cct, int *__ierr ){ *__ierr = NEPRIISetConstCorrectionTol( (NEP)PetscToPointer((nep) ),*cct); } PETSC_EXTERN void PETSC_STDCALL nepriigetconstcorrectiontol_(NEP nep,PetscBool *cct, int *__ierr ){ *__ierr = NEPRIIGetConstCorrectionTol( (NEP)PetscToPointer((nep) ),cct); } PETSC_EXTERN void PETSC_STDCALL nepriisetksp_(NEP nep,KSP ksp, int *__ierr ){ *__ierr = NEPRIISetKSP( (NEP)PetscToPointer((nep) ), (KSP)PetscToPointer((ksp) )); } PETSC_EXTERN void PETSC_STDCALL nepriigetksp_(NEP nep,KSP *ksp, int *__ierr ){ *__ierr = NEPRIIGetKSP( (NEP)PetscToPointer((nep) ),ksp); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/impls/interpol/0000755000175000017500000000000013107004621016514 5ustar jromanjromanslepc-3.7.4/src/nep/impls/interpol/makefile0000644000175000017500000000216213107004621020215 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = interpol.c SOURCEF = SOURCEH = LIBBASE = libslepcnep DIRS = MANSEC = NEP LOCDIR = src/nep/impls/interpol/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/interpol/interpol.c0000644000175000017500000003753013107004621020524 0ustar jromanjroman/* SLEPc nonlinear eigensolver: "interpol" Method: Polynomial interpolation Algorithm: Uses a PEP object to solve the interpolated NEP. Currently supports only Chebyshev interpolation on an interval. References: [1] C. Effenberger and D. Kresser, "Chebyshev interpolation for nonlinear eigenvalue problems", BIT 52:933-951, 2012. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #include /*I "slepcpep.h" I*/ typedef struct { PEP pep; PetscInt deg; } NEP_INTERPOL; #undef __FUNCT__ #define __FUNCT__ "NEPSetUp_Interpol" PetscErrorCode NEPSetUp_Interpol(NEP nep) { PetscErrorCode ierr; NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; ST st; RG rg; PetscReal a,b,c,d,s,tol; PetscScalar zero=0.0; PetscBool flg,istrivial,trackall; PetscInt its,in; PetscFunctionBegin; ierr = NEPSetDimensions_Default(nep,nep->nev,&nep->ncv,&nep->mpd);CHKERRQ(ierr); if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd"); if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv); if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEPINTERPOL only available for split operator"); if (nep->stopping!=NEPStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support user-defined stopping test"); /* transfer PEP options */ if (!ctx->pep) { ierr = NEPInterpolGetPEP(nep,&ctx->pep);CHKERRQ(ierr); } ierr = PEPSetBV(ctx->pep,nep->V);CHKERRQ(ierr); ierr = PEPSetBasis(ctx->pep,PEP_BASIS_CHEBYSHEV1);CHKERRQ(ierr); ierr = PEPSetWhichEigenpairs(ctx->pep,PEP_TARGET_MAGNITUDE);CHKERRQ(ierr); ierr = PEPGetST(ctx->pep,&st);CHKERRQ(ierr); ierr = STSetType(st,STSINVERT);CHKERRQ(ierr); ierr = PEPSetDimensions(ctx->pep,nep->nev,nep->ncv?nep->ncv:PETSC_DEFAULT,nep->mpd?nep->mpd:PETSC_DEFAULT);CHKERRQ(ierr); tol=ctx->pep->tol; if (tol==PETSC_DEFAULT) tol = (nep->tol==PETSC_DEFAULT)?SLEPC_DEFAULT_TOL/10.0:nep->tol/10.0; its=ctx->pep->max_it; if (!its) its = nep->max_it?nep->max_it:PETSC_DEFAULT; ierr = PEPSetTolerances(ctx->pep,tol,its);CHKERRQ(ierr); ierr = NEPGetTrackAll(nep,&trackall);CHKERRQ(ierr); ierr = PEPSetTrackAll(ctx->pep,trackall);CHKERRQ(ierr); /* transfer region options */ ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); if (istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEPINTERPOL requires a nontrivial region"); ierr = PetscObjectTypeCompare((PetscObject)nep->rg,RGINTERVAL,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Only implemented for interval regions"); ierr = RGIntervalGetEndpoints(nep->rg,&a,&b,&c,&d);CHKERRQ(ierr); if (a<=-PETSC_MAX_REAL || b>=PETSC_MAX_REAL) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Only implemented for bounded intervals"); ierr = PEPGetRG(ctx->pep,&rg);CHKERRQ(ierr); ierr = RGSetType(rg,RGINTERVAL);CHKERRQ(ierr); if (a==b) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Only implemented for intervals on the real axis"); s = 2.0/(b-a); c = c*s; d = d*s; ierr = RGIntervalSetEndpoints(rg,-1.0,1.0,c,d);CHKERRQ(ierr); ierr = RGCheckInside(nep->rg,1,&nep->target,&zero,&in);CHKERRQ(ierr); if (in<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The target is not inside the target set"); ierr = PEPSetTarget(ctx->pep,(nep->target-(a+b)/2)*s);CHKERRQ(ierr); ierr = NEPAllocateSolution(nep,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "ChebyshevNodes" /* Input: d, number of nodes to compute a,b, interval extrems Output: *x, array containing the d Chebyshev nodes of the interval [a,b] *dct2, coefficients to compute a discrete cosine transformation (DCT-II) */ static PetscErrorCode ChebyshevNodes(PetscInt d,PetscReal a,PetscReal b,PetscScalar *x,PetscReal *dct2) { PetscInt j,i; PetscReal t; PetscFunctionBegin; for (j=0;jdata; Mat *A; /*T=nep->function,Tp=nep->jacobian;*/ PetscScalar *x,*fx,t; PetscReal *cs,a,b,s; PetscInt i,j,k,deg=ctx->deg; PetscFunctionBegin; ierr = PetscMalloc4(deg+1,&A,(deg+1)*(deg+1),&cs,deg+1,&x,(deg+1)*nep->nt,&fx);CHKERRQ(ierr); ierr = RGIntervalGetEndpoints(nep->rg,&a,&b,NULL,NULL);CHKERRQ(ierr); ierr = ChebyshevNodes(deg,a,b,x,cs);CHKERRQ(ierr); for (j=0;jnt;j++) { for (i=0;i<=deg;i++) { ierr = FNEvaluateFunction(nep->f[j],x[i],&fx[i+j*(deg+1)]);CHKERRQ(ierr); } } /* Polynomial coefficients */ for (k=0;k<=deg;k++) { ierr = MatDuplicate(nep->A[0],MAT_COPY_VALUES,&A[k]);CHKERRQ(ierr); t = 0.0; for (i=0;int;j++) { t = 0.0; for (i=0;iA[j],nep->mstr);CHKERRQ(ierr); } } ierr = PEPSetOperators(ctx->pep,deg+1,A);CHKERRQ(ierr); for (k=0;k<=deg;k++) { ierr = MatDestroy(&A[k]);CHKERRQ(ierr); } ierr = PetscFree4(A,cs,x,fx);CHKERRQ(ierr); /* Solve polynomial eigenproblem */ ierr = PEPSolve(ctx->pep);CHKERRQ(ierr); ierr = PEPGetConverged(ctx->pep,&nep->nconv);CHKERRQ(ierr); ierr = PEPGetIterationNumber(ctx->pep,&nep->its);CHKERRQ(ierr); ierr = PEPGetConvergedReason(ctx->pep,(PEPConvergedReason*)&nep->reason);CHKERRQ(ierr); s = 2.0/(b-a); for (i=0;inconv;i++) { ierr = PEPGetEigenpair(ctx->pep,i,&nep->eigr[i],&nep->eigi[i],NULL,NULL);CHKERRQ(ierr); nep->eigr[i] /= s; nep->eigr[i] += (a+b)/2.0; nep->eigi[i] /= s; } nep->state = NEP_STATE_EIGENVECTORS; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitor_Interpol" static PetscErrorCode PEPMonitor_Interpol(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscInt i,n; NEP nep = (NEP)ctx; PetscReal a,b,s; PetscErrorCode ierr; PetscFunctionBegin; n = PetscMin(nest,nep->ncv); for (i=0;ieigr[i] = eigr[i]; nep->eigi[i] = eigi[i]; nep->errest[i] = errest[i]; } ierr = STBackTransform(pep->st,n,nep->eigr,nep->eigi);CHKERRQ(ierr); ierr = RGIntervalGetEndpoints(nep->rg,&a,&b,NULL,NULL);CHKERRQ(ierr); s = 2.0/(b-a); for (i=0;ieigr[i] /= s; nep->eigr[i] += (a+b)/2.0; nep->eigi[i] /= s; } ierr = NEPMonitor(nep,its,nconv,nep->eigr,nep->eigi,nep->errest,nest);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetFromOptions_Interpol" PetscErrorCode NEPSetFromOptions_Interpol(PetscOptionItems *PetscOptionsObject,NEP nep) { PetscErrorCode ierr; NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; PetscFunctionBegin; if (!ctx->pep) { ierr = NEPInterpolGetPEP(nep,&ctx->pep);CHKERRQ(ierr); } ierr = PEPSetFromOptions(ctx->pep);CHKERRQ(ierr); ierr = PetscOptionsHead(PetscOptionsObject,"NEP Interpol Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_interpol_degree","Degree of interpolation polynomial","NEPInterpolSetDegree",ctx->deg,&ctx->deg,NULL);CHKERRQ(ierr); ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolSetDegree_Interpol" static PetscErrorCode NEPInterpolSetDegree_Interpol(NEP nep,PetscInt deg) { NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; PetscFunctionBegin; ctx->deg = deg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolSetDegree" /*@ NEPInterpolSetDegree - Sets the degree of the interpolation polynomial. Collective on NEP Input Parameters: + nep - nonlinear eigenvalue solver - deg - polynomial degree Level: advanced .seealso: NEPInterpolGetDegree() @*/ PetscErrorCode NEPInterpolSetDegree(NEP nep,PetscInt deg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,deg,2); ierr = PetscTryMethod(nep,"NEPInterpolSetDegree_C",(NEP,PetscInt),(nep,deg));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolGetDegree_Interpol" static PetscErrorCode NEPInterpolGetDegree_Interpol(NEP nep,PetscInt *deg) { NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; PetscFunctionBegin; *deg = ctx->deg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolGetDegree" /*@ NEPInterpolGetDegree - Gets the degree of the interpolation polynomial. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . deg - the polynomial degree Level: advanced .seealso: NEPInterpolSetDegree() @*/ PetscErrorCode NEPInterpolGetDegree(NEP nep,PetscInt *deg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(deg,2); ierr = PetscUseMethod(nep,"NEPInterpolGetDegree_C",(NEP,PetscInt*),(nep,deg));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolSetPEP_Interpol" static PetscErrorCode NEPInterpolSetPEP_Interpol(NEP nep,PEP pep) { PetscErrorCode ierr; NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; PetscFunctionBegin; ierr = PetscObjectReference((PetscObject)pep);CHKERRQ(ierr); ierr = PEPDestroy(&ctx->pep);CHKERRQ(ierr); ctx->pep = pep; ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->pep);CHKERRQ(ierr); nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolSetPEP" /*@ NEPInterpolSetPEP - Associate a polynomial eigensolver object (PEP) to the nonlinear eigenvalue solver. Collective on NEP Input Parameters: + nep - nonlinear eigenvalue solver - pep - the polynomial eigensolver object Level: advanced .seealso: NEPInterpolGetPEP() @*/ PetscErrorCode NEPInterpolSetPEP(NEP nep,PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidHeaderSpecific(pep,PEP_CLASSID,2); PetscCheckSameComm(nep,1,pep,2); ierr = PetscTryMethod(nep,"NEPInterpolSetPEP_C",(NEP,PEP),(nep,pep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolGetPEP_Interpol" static PetscErrorCode NEPInterpolGetPEP_Interpol(NEP nep,PEP *pep) { PetscErrorCode ierr; NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; ST st; PetscFunctionBegin; if (!ctx->pep) { ierr = PEPCreate(PetscObjectComm((PetscObject)nep),&ctx->pep);CHKERRQ(ierr); ierr = PEPSetOptionsPrefix(ctx->pep,((PetscObject)nep)->prefix);CHKERRQ(ierr); ierr = PEPAppendOptionsPrefix(ctx->pep,"nep_interpol_");CHKERRQ(ierr); ierr = PEPGetST(ctx->pep,&st);CHKERRQ(ierr); ierr = STSetOptionsPrefix(st,((PetscObject)ctx->pep)->prefix);CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->pep,(PetscObject)nep,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->pep);CHKERRQ(ierr); ierr = PEPMonitorSet(ctx->pep,PEPMonitor_Interpol,nep,NULL);CHKERRQ(ierr); } *pep = ctx->pep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPInterpolGetPEP" /*@ NEPInterpolGetPEP - Retrieve the polynomial eigensolver object (PEP) associated with the nonlinear eigenvalue solver. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . pep - the polynomial eigensolver object Level: advanced .seealso: NEPInterpolSetPEP() @*/ PetscErrorCode NEPInterpolGetPEP(NEP nep,PEP *pep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(pep,2); ierr = PetscUseMethod(nep,"NEPInterpolGetPEP_C",(NEP,PEP*),(nep,pep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPView_Interpol" PetscErrorCode NEPView_Interpol(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (!ctx->pep) { ierr = NEPInterpolGetPEP(nep,&ctx->pep);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," Interpol: polynomial degree %D\n",ctx->deg);CHKERRQ(ierr); ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = PEPView(ctx->pep,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReset_Interpol" PetscErrorCode NEPReset_Interpol(NEP nep) { PetscErrorCode ierr; NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; PetscFunctionBegin; if (!ctx->pep) { ierr = PEPReset(ctx->pep);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPDestroy_Interpol" PetscErrorCode NEPDestroy_Interpol(NEP nep) { PetscErrorCode ierr; NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data; PetscFunctionBegin; ierr = PEPDestroy(&ctx->pep);CHKERRQ(ierr); ierr = PetscFree(nep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetDegree_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetDegree_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetPEP_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetPEP_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCreate_Interpol" PETSC_EXTERN PetscErrorCode NEPCreate_Interpol(NEP nep) { PetscErrorCode ierr; NEP_INTERPOL *ctx; PetscFunctionBegin; ierr = PetscNewLog(nep,&ctx);CHKERRQ(ierr); ctx->deg = 5; nep->data = (void*)ctx; nep->ops->solve = NEPSolve_Interpol; nep->ops->setup = NEPSetUp_Interpol; nep->ops->setfromoptions = NEPSetFromOptions_Interpol; nep->ops->reset = NEPReset_Interpol; nep->ops->destroy = NEPDestroy_Interpol; nep->ops->view = NEPView_Interpol; ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetDegree_C",NEPInterpolSetDegree_Interpol);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetDegree_C",NEPInterpolGetDegree_Interpol);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetPEP_C",NEPInterpolSetPEP_Interpol);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetPEP_C",NEPInterpolGetPEP_Interpol);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/impls/interpol/makefile.html0000644000175000017500000000467013107004621021166 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = interpol.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcnep
DIRS     =
MANSEC   = NEP
LOCDIR   = src/nep/impls/interpol/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/impls/interpol/interpol.c.html0000644000175000017500000010553213107004621021465 0ustar jromanjroman
Actual source code: interpol.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc nonlinear eigensolver: "interpol"

  5:    Method: Polynomial interpolation

  7:    Algorithm:

  9:        Uses a PEP object to solve the interpolated NEP. Currently supports
 10:        only Chebyshev interpolation on an interval.

 12:    References:

 14:        [1] C. Effenberger and D. Kresser, "Chebyshev interpolation for
 15:            nonlinear eigenvalue problems", BIT 52:933-951, 2012.

 17:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 19:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 21:    This file is part of SLEPc.

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

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

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

 37: #include <slepc/private/nepimpl.h>         /*I "slepcnep.h" I*/
 38: #include <slepc/private/pepimpl.h>         /*I "slepcpep.h" I*/

 40: typedef struct {
 41:   PEP       pep;
 42:   PetscInt  deg;
 43: } NEP_INTERPOL;

 47: PetscErrorCode NEPSetUp_Interpol(NEP nep)
 48: {
 50:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;
 51:   ST             st;
 52:   RG             rg;
 53:   PetscReal      a,b,c,d,s,tol;
 54:   PetscScalar    zero=0.0;
 55:   PetscBool      flg,istrivial,trackall;
 56:   PetscInt       its,in;

 59:   NEPSetDimensions_Default(nep,nep->nev,&nep->ncv,&nep->mpd);
 60:   if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd");
 61:   if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv);
 62:   if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEPINTERPOL only available for split operator");
 63:   if (nep->stopping!=NEPStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support user-defined stopping test");

 65:   /* transfer PEP options */
 66:   if (!ctx->pep) { NEPInterpolGetPEP(nep,&ctx->pep); }
 67:   PEPSetBV(ctx->pep,nep->V);
 68:   PEPSetBasis(ctx->pep,PEP_BASIS_CHEBYSHEV1);
 69:   PEPSetWhichEigenpairs(ctx->pep,PEP_TARGET_MAGNITUDE);
 70:   PEPGetST(ctx->pep,&st);
 71:   STSetType(st,STSINVERT);
 72:   PEPSetDimensions(ctx->pep,nep->nev,nep->ncv?nep->ncv:PETSC_DEFAULT,nep->mpd?nep->mpd:PETSC_DEFAULT);
 73:   tol=ctx->pep->tol;
 74:   if (tol==PETSC_DEFAULT) tol = (nep->tol==PETSC_DEFAULT)?SLEPC_DEFAULT_TOL/10.0:nep->tol/10.0;
 75:   its=ctx->pep->max_it;
 76:   if (!its) its = nep->max_it?nep->max_it:PETSC_DEFAULT;
 77:   PEPSetTolerances(ctx->pep,tol,its);
 78:   NEPGetTrackAll(nep,&trackall);
 79:   PEPSetTrackAll(ctx->pep,trackall);

 81:   /* transfer region options */
 82:   RGIsTrivial(nep->rg,&istrivial);
 83:   if (istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEPINTERPOL requires a nontrivial region");
 84:   PetscObjectTypeCompare((PetscObject)nep->rg,RGINTERVAL,&flg);
 85:   if (!flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Only implemented for interval regions");
 86:   RGIntervalGetEndpoints(nep->rg,&a,&b,&c,&d);
 87:   if (a<=-PETSC_MAX_REAL || b>=PETSC_MAX_REAL) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Only implemented for bounded intervals");
 88:   PEPGetRG(ctx->pep,&rg);
 89:   RGSetType(rg,RGINTERVAL);
 90:   if (a==b) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Only implemented for intervals on the real axis");
 91:   s = 2.0/(b-a);
 92:   c = c*s;
 93:   d = d*s;
 94:   RGIntervalSetEndpoints(rg,-1.0,1.0,c,d);
 95:   RGCheckInside(nep->rg,1,&nep->target,&zero,&in);
 96:   if (in<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The target is not inside the target set");
 97:   PEPSetTarget(ctx->pep,(nep->target-(a+b)/2)*s);

 99:   NEPAllocateSolution(nep,0);
100:   return(0);
101: }

105: /*
106:   Input: 
107:     d, number of nodes to compute
108:     a,b, interval extrems
109:   Output:
110:     *x, array containing the d Chebyshev nodes of the interval [a,b]
111:     *dct2, coefficients to compute a discrete cosine transformation (DCT-II)
112: */
113: static PetscErrorCode ChebyshevNodes(PetscInt d,PetscReal a,PetscReal b,PetscScalar *x,PetscReal *dct2)
114: {
115:   PetscInt  j,i;
116:   PetscReal t;

119:   for (j=0;j<d+1;j++) {
120:     t = ((2*j+1)*PETSC_PI)/(2*(d+1));
121:     x[j] = (a+b)/2.0+((b-a)/2.0)*PetscCosReal(t);
122:     for (i=0;i<d+1;i++) dct2[j*(d+1)+i] = PetscCosReal(i*t);
123:   }
124:   return(0);
125: }

129: PetscErrorCode NEPSolve_Interpol(NEP nep)
130: {
132:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;
133:   Mat            *A;   /*T=nep->function,Tp=nep->jacobian;*/
134:   PetscScalar    *x,*fx,t;
135:   PetscReal      *cs,a,b,s;
136:   PetscInt       i,j,k,deg=ctx->deg;

139:   PetscMalloc4(deg+1,&A,(deg+1)*(deg+1),&cs,deg+1,&x,(deg+1)*nep->nt,&fx);
140:   RGIntervalGetEndpoints(nep->rg,&a,&b,NULL,NULL);
141:   ChebyshevNodes(deg,a,b,x,cs);
142:   for (j=0;j<nep->nt;j++) {
143:     for (i=0;i<=deg;i++) {
144:       FNEvaluateFunction(nep->f[j],x[i],&fx[i+j*(deg+1)]);
145:     }
146:   }

148:   /* Polynomial coefficients */
149:   for (k=0;k<=deg;k++) {
150:     MatDuplicate(nep->A[0],MAT_COPY_VALUES,&A[k]);
151:     t = 0.0;
152:     for (i=0;i<deg+1;i++) t += fx[i]*cs[i*(deg+1)+k];
153:     t *= 2.0/(deg+1); 
154:     if (k==0) t /= 2.0;
155:     MatScale(A[k],t);
156:     for (j=1;j<nep->nt;j++) {
157:       t = 0.0;
158:       for (i=0;i<deg+1;i++) t += fx[i+j*(deg+1)]*cs[i*(deg+1)+k];
159:       t *= 2.0/(deg+1); 
160:       if (k==0) t /= 2.0;
161:       MatAXPY(A[k],t,nep->A[j],nep->mstr);
162:     }
163:   }

165:   PEPSetOperators(ctx->pep,deg+1,A);
166:   for (k=0;k<=deg;k++) {
167:     MatDestroy(&A[k]);
168:   }
169:   PetscFree4(A,cs,x,fx);

171:   /* Solve polynomial eigenproblem */
172:   PEPSolve(ctx->pep);
173:   PEPGetConverged(ctx->pep,&nep->nconv);
174:   PEPGetIterationNumber(ctx->pep,&nep->its);
175:   PEPGetConvergedReason(ctx->pep,(PEPConvergedReason*)&nep->reason);
176:   s = 2.0/(b-a);
177:   for (i=0;i<nep->nconv;i++) {
178:     PEPGetEigenpair(ctx->pep,i,&nep->eigr[i],&nep->eigi[i],NULL,NULL);
179:     nep->eigr[i] /= s;
180:     nep->eigr[i] += (a+b)/2.0;
181:     nep->eigi[i] /= s;
182:   }
183:   nep->state = NEP_STATE_EIGENVECTORS;
184:   return(0);
185: }

189: static PetscErrorCode PEPMonitor_Interpol(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
190: {
191:   PetscInt       i,n;
192:   NEP            nep = (NEP)ctx;
193:   PetscReal      a,b,s;

197:   n = PetscMin(nest,nep->ncv);
198:   for (i=0;i<n;i++) {
199:     nep->eigr[i]   = eigr[i];
200:     nep->eigi[i]   = eigi[i];
201:     nep->errest[i] = errest[i];
202:   }
203:   STBackTransform(pep->st,n,nep->eigr,nep->eigi);
204:   RGIntervalGetEndpoints(nep->rg,&a,&b,NULL,NULL);
205:   s = 2.0/(b-a);
206:   for (i=0;i<n;i++) {
207:     nep->eigr[i] /= s;
208:     nep->eigr[i] += (a+b)/2.0;
209:     nep->eigi[i] /= s;
210:   }  
211:   NEPMonitor(nep,its,nconv,nep->eigr,nep->eigi,nep->errest,nest);
212:   return(0);
213: }

217: PetscErrorCode NEPSetFromOptions_Interpol(PetscOptionItems *PetscOptionsObject,NEP nep)
218: {
220:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;

223:   if (!ctx->pep) { NEPInterpolGetPEP(nep,&ctx->pep); }
224:   PEPSetFromOptions(ctx->pep);
225:   PetscOptionsHead(PetscOptionsObject,"NEP Interpol Options");
226:   PetscOptionsInt("-nep_interpol_degree","Degree of interpolation polynomial","NEPInterpolSetDegree",ctx->deg,&ctx->deg,NULL);
227:   PetscOptionsTail();
228:   return(0);
229: }

233: static PetscErrorCode NEPInterpolSetDegree_Interpol(NEP nep,PetscInt deg)
234: {
235:   NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data;

238:   ctx->deg = deg;
239:   return(0);
240: }

244: /*@
245:    NEPInterpolSetDegree - Sets the degree of the interpolation polynomial.

247:    Collective on NEP

249:    Input Parameters:
250: +  nep - nonlinear eigenvalue solver
251: -  deg - polynomial degree

253:    Level: advanced

255: .seealso: NEPInterpolGetDegree()
256: @*/
257: PetscErrorCode NEPInterpolSetDegree(NEP nep,PetscInt deg)
258: {

264:   PetscTryMethod(nep,"NEPInterpolSetDegree_C",(NEP,PetscInt),(nep,deg));
265:   return(0);
266: }

270: static PetscErrorCode NEPInterpolGetDegree_Interpol(NEP nep,PetscInt *deg)
271: {
272:   NEP_INTERPOL *ctx = (NEP_INTERPOL*)nep->data;

275:   *deg = ctx->deg;
276:   return(0);
277: }

281: /*@
282:    NEPInterpolGetDegree - Gets the degree of the interpolation polynomial.

284:    Not Collective

286:    Input Parameter:
287: .  nep - nonlinear eigenvalue solver

289:    Output Parameter:
290: .  deg - the polynomial degree

292:    Level: advanced

294: .seealso: NEPInterpolSetDegree()
295: @*/
296: PetscErrorCode NEPInterpolGetDegree(NEP nep,PetscInt *deg)
297: {

303:   PetscUseMethod(nep,"NEPInterpolGetDegree_C",(NEP,PetscInt*),(nep,deg));
304:   return(0);
305: }

309: static PetscErrorCode NEPInterpolSetPEP_Interpol(NEP nep,PEP pep)
310: {
312:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;

315:   PetscObjectReference((PetscObject)pep);
316:   PEPDestroy(&ctx->pep);
317:   ctx->pep = pep;
318:   PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->pep);
319:   nep->state = NEP_STATE_INITIAL;
320:   return(0);
321: }

325: /*@
326:    NEPInterpolSetPEP - Associate a polynomial eigensolver object (PEP) to the
327:    nonlinear eigenvalue solver.

329:    Collective on NEP

331:    Input Parameters:
332: +  nep - nonlinear eigenvalue solver
333: -  pep - the polynomial eigensolver object

335:    Level: advanced

337: .seealso: NEPInterpolGetPEP()
338: @*/
339: PetscErrorCode NEPInterpolSetPEP(NEP nep,PEP pep)
340: {

347:   PetscTryMethod(nep,"NEPInterpolSetPEP_C",(NEP,PEP),(nep,pep));
348:   return(0);
349: }

353: static PetscErrorCode NEPInterpolGetPEP_Interpol(NEP nep,PEP *pep)
354: {
356:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;
357:   ST             st;

360:   if (!ctx->pep) {
361:     PEPCreate(PetscObjectComm((PetscObject)nep),&ctx->pep);
362:     PEPSetOptionsPrefix(ctx->pep,((PetscObject)nep)->prefix);
363:     PEPAppendOptionsPrefix(ctx->pep,"nep_interpol_");
364:     PEPGetST(ctx->pep,&st);
365:     STSetOptionsPrefix(st,((PetscObject)ctx->pep)->prefix);
366:     PetscObjectIncrementTabLevel((PetscObject)ctx->pep,(PetscObject)nep,1);
367:     PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->pep);
368:     PEPMonitorSet(ctx->pep,PEPMonitor_Interpol,nep,NULL);
369:   }
370:   *pep = ctx->pep;
371:   return(0);
372: }

376: /*@
377:    NEPInterpolGetPEP - Retrieve the polynomial eigensolver object (PEP)
378:    associated with the nonlinear eigenvalue solver.

380:    Not Collective

382:    Input Parameter:
383: .  nep - nonlinear eigenvalue solver

385:    Output Parameter:
386: .  pep - the polynomial eigensolver object

388:    Level: advanced

390: .seealso: NEPInterpolSetPEP()
391: @*/
392: PetscErrorCode NEPInterpolGetPEP(NEP nep,PEP *pep)
393: {

399:   PetscUseMethod(nep,"NEPInterpolGetPEP_C",(NEP,PEP*),(nep,pep));
400:   return(0);
401: }

405: PetscErrorCode NEPView_Interpol(NEP nep,PetscViewer viewer)
406: {
408:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;
409:   PetscBool      isascii;

412:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
413:   if (isascii) {
414:     if (!ctx->pep) { NEPInterpolGetPEP(nep,&ctx->pep); }
415:     PetscViewerASCIIPrintf(viewer,"  Interpol: polynomial degree %D\n",ctx->deg);
416:     PetscViewerASCIIPushTab(viewer);
417:     PEPView(ctx->pep,viewer);
418:     PetscViewerASCIIPopTab(viewer);
419:   }
420:   return(0);
421: }

425: PetscErrorCode NEPReset_Interpol(NEP nep)
426: {
428:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;

431:   if (!ctx->pep) { PEPReset(ctx->pep); }
432:   return(0);
433: }

437: PetscErrorCode NEPDestroy_Interpol(NEP nep)
438: {
440:   NEP_INTERPOL   *ctx = (NEP_INTERPOL*)nep->data;

443:   PEPDestroy(&ctx->pep);
444:   PetscFree(nep->data);
445:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetDegree_C",NULL);
446:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetDegree_C",NULL);
447:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetPEP_C",NULL);
448:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetPEP_C",NULL);
449:   return(0);
450: }

454: PETSC_EXTERN PetscErrorCode NEPCreate_Interpol(NEP nep)
455: {
457:   NEP_INTERPOL   *ctx;

460:   PetscNewLog(nep,&ctx);
461:   ctx->deg  = 5;
462:   nep->data = (void*)ctx;

464:   nep->ops->solve          = NEPSolve_Interpol;
465:   nep->ops->setup          = NEPSetUp_Interpol;
466:   nep->ops->setfromoptions = NEPSetFromOptions_Interpol;
467:   nep->ops->reset          = NEPReset_Interpol;
468:   nep->ops->destroy        = NEPDestroy_Interpol;
469:   nep->ops->view           = NEPView_Interpol;
470:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetDegree_C",NEPInterpolSetDegree_Interpol);
471:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetDegree_C",NEPInterpolGetDegree_Interpol);
472:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolSetPEP_C",NEPInterpolSetPEP_Interpol);
473:   PetscObjectComposeFunction((PetscObject)nep,"NEPInterpolGetPEP_C",NEPInterpolGetPEP_Interpol);
474:   return(0);
475: }

slepc-3.7.4/src/nep/impls/interpol/index.html0000644000175000017500000000306313107004621020513 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

interpol.c
makefile
slepc-3.7.4/src/nep/impls/interpol/ftn-auto/0000755000175000017500000000000013107004621020251 5ustar jromanjromanslepc-3.7.4/src/nep/impls/interpol/ftn-auto/makefile0000644000175000017500000000036513107004621021755 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = interpolf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcnep LOCDIR = src/nep/impls/interpol/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/interpol/ftn-auto/interpolf.c0000644000175000017500000000434613107004621022426 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* interpol.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepinterpolsetdegree_ NEPINTERPOLSETDEGREE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepinterpolsetdegree_ nepinterpolsetdegree #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepinterpolgetdegree_ NEPINTERPOLGETDEGREE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepinterpolgetdegree_ nepinterpolgetdegree #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepinterpolsetpep_ NEPINTERPOLSETPEP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepinterpolsetpep_ nepinterpolsetpep #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepinterpolgetpep_ NEPINTERPOLGETPEP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepinterpolgetpep_ nepinterpolgetpep #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepinterpolsetdegree_(NEP nep,PetscInt *deg, int *__ierr ){ *__ierr = NEPInterpolSetDegree( (NEP)PetscToPointer((nep) ),*deg); } PETSC_EXTERN void PETSC_STDCALL nepinterpolgetdegree_(NEP nep,PetscInt *deg, int *__ierr ){ *__ierr = NEPInterpolGetDegree( (NEP)PetscToPointer((nep) ),deg); } PETSC_EXTERN void PETSC_STDCALL nepinterpolsetpep_(NEP nep,PEP pep, int *__ierr ){ *__ierr = NEPInterpolSetPEP( (NEP)PetscToPointer((nep) ), (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL nepinterpolgetpep_(NEP nep,PEP *pep, int *__ierr ){ *__ierr = NEPInterpolGetPEP( (NEP)PetscToPointer((nep) ),pep); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/impls/slp/0000755000175000017500000000000013107004621015456 5ustar jromanjromanslepc-3.7.4/src/nep/impls/slp/makefile0000644000175000017500000000215013107004621017154 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = slp.c SOURCEF = SOURCEH = LIBBASE = libslepcnep DIRS = MANSEC = NEP LOCDIR = src/nep/impls/slp/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/slp/makefile.html0000644000175000017500000000464413107004621020131 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = slp.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcnep
DIRS     =
MANSEC   = NEP
LOCDIR   = src/nep/impls/slp/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/impls/slp/index.html0000644000175000017500000000303713107004621017456 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

slp.c
makefile
slepc-3.7.4/src/nep/impls/slp/ftn-auto/0000755000175000017500000000000013107004621017213 5ustar jromanjromanslepc-3.7.4/src/nep/impls/slp/ftn-auto/makefile0000644000175000017500000000035313107004621020714 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = slpf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcnep LOCDIR = src/nep/impls/slp/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/slp/ftn-auto/slpf.c0000644000175000017500000000261413107004621020326 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* slp.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepslpseteps_ NEPSLPSETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepslpseteps_ nepslpseteps #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepslpgeteps_ NEPSLPGETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepslpgeteps_ nepslpgeteps #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepslpseteps_(NEP nep,EPS eps, int *__ierr ){ *__ierr = NEPSLPSetEPS( (NEP)PetscToPointer((nep) ), (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL nepslpgeteps_(NEP nep,EPS *eps, int *__ierr ){ *__ierr = NEPSLPGetEPS( (NEP)PetscToPointer((nep) ),eps); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/impls/slp/slp.c.html0000644000175000017500000005544513107004621017400 0ustar jromanjroman

Actual source code: slp.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc nonlinear eigensolver: "slp"

  5:    Method: Succesive linear problems

  7:    Algorithm:

  9:        Newton-type iteration based on first order Taylor approximation.

 11:    References:

 13:        [1] A. Ruhe, "Algorithms for the nonlinear eigenvalue problem", SIAM J.
 14:            Numer. Anal. 10(4):674-689, 1973.

 16:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 17:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 18:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 20:    This file is part of SLEPc.

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

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

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

 36: #include <slepc/private/nepimpl.h>         /*I "slepcnep.h" I*/

 38: typedef struct {
 39:   EPS       eps;             /* linear eigensolver for T*z = mu*Tp*z */
 40: } NEP_SLP;

 44: PetscErrorCode NEPSetUp_SLP(NEP nep)
 45: {
 47:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;
 48:   ST             st;
 49:   PetscBool      istrivial;

 52:   if (nep->nev>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Requested several eigenpairs but this solver can compute only one");
 53:   if (nep->ncv) { PetscInfo(nep,"Setting ncv = 1, ignoring user-provided value\n"); }
 54:   nep->ncv = 1;
 55:   if (nep->mpd) { PetscInfo(nep,"Setting mpd = 1, ignoring user-provided value\n"); }
 56:   nep->mpd = 1;
 57:   if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd");
 58:   if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv);
 59:   if (nep->which && nep->which!=NEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of which");

 61:   RGIsTrivial(nep->rg,&istrivial);
 62:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support region filtering");

 64:   if (!ctx->eps) { NEPSLPGetEPS(nep,&ctx->eps); }
 65:   EPSSetWhichEigenpairs(ctx->eps,EPS_TARGET_MAGNITUDE);
 66:   EPSSetTarget(ctx->eps,0.0);
 67:   EPSGetST(ctx->eps,&st);
 68:   STSetType(st,STSINVERT);
 69:   EPSSetTolerances(ctx->eps,nep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/10.0:nep->tol/10.0,nep->max_it?nep->max_it:PETSC_DEFAULT);

 71:   NEPAllocateSolution(nep,0);
 72:   NEPSetWorkVecs(nep,1);
 73:   return(0);
 74: }

 78: PetscErrorCode NEPSolve_SLP(NEP nep)
 79: {
 81:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;
 82:   Mat            T=nep->function,Tp=nep->jacobian;
 83:   Vec            u,r=nep->work[0];
 84:   PetscScalar    lambda,mu,im;
 85:   PetscReal      resnorm;
 86:   PetscInt       nconv;

 89:   /* get initial approximation of eigenvalue and eigenvector */
 90:   NEPGetDefaultShift(nep,&lambda);
 91:   if (!nep->nini) {
 92:     BVSetRandomColumn(nep->V,0);
 93:   }
 94:   BVGetColumn(nep->V,0,&u);

 96:   /* Restart loop */
 97:   while (nep->reason == NEP_CONVERGED_ITERATING) {
 98:     nep->its++;

100:     /* evaluate T(lambda) and T'(lambda) */
101:     NEPComputeFunction(nep,lambda,T,T);
102:     NEPComputeJacobian(nep,lambda,Tp);

104:     /* form residual,  r = T(lambda)*u (used in convergence test only) */
105:     MatMult(T,u,r);

107:     /* convergence test */
108:     VecNorm(r,NORM_2,&resnorm);
109:     (*nep->converged)(nep,lambda,0,resnorm,&nep->errest[nep->nconv],nep->convergedctx);
110:     nep->eigr[nep->nconv] = lambda;
111:     if (nep->errest[nep->nconv]<=nep->tol) {
112:       nep->nconv = nep->nconv + 1;
113:     }
114:     (*nep->stopping)(nep,nep->its,nep->max_it,nep->nconv,nep->nev,&nep->reason,nep->stoppingctx);
115:     NEPMonitor(nep,nep->its,nep->nconv,nep->eigr,nep->eigi,nep->errest,1);

117:     if (nep->reason == NEP_CONVERGED_ITERATING) {
118:       /* compute eigenvalue correction mu and eigenvector approximation u */
119:       EPSSetOperators(ctx->eps,T,Tp);
120:       EPSSetInitialSpace(ctx->eps,1,&u);
121:       EPSSolve(ctx->eps);
122:       EPSGetConverged(ctx->eps,&nconv);
123:       if (!nconv) {
124:         PetscInfo1(nep,"iter=%D, inner iteration failed, stopping solve\n",nep->its);
125:         nep->reason = NEP_DIVERGED_LINEAR_SOLVE;
126:         break;
127:       }
128:       EPSGetEigenpair(ctx->eps,0,&mu,&im,u,NULL);
129:       if (PetscAbsScalar(im)>PETSC_MACHINE_EPSILON) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Complex eigenvalue approximation - not implemented in real scalars");

131:       /* correct eigenvalue */
132:       lambda = lambda - mu;
133:     }
134:   }
135:   BVRestoreColumn(nep->V,0,&u);
136:   return(0);
137: }

141: PetscErrorCode NEPSetFromOptions_SLP(PetscOptionItems *PetscOptionsObject,NEP nep)
142: {
144:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;

147:   PetscOptionsHead(PetscOptionsObject,"NEP SLP Options");
148:   if (!ctx->eps) { NEPSLPGetEPS(nep,&ctx->eps); }
149:   EPSSetFromOptions(ctx->eps);
150:   PetscOptionsTail();
151:   return(0);
152: }

156: static PetscErrorCode NEPSLPSetEPS_SLP(NEP nep,EPS eps)
157: {
159:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;

162:   PetscObjectReference((PetscObject)eps);
163:   EPSDestroy(&ctx->eps);
164:   ctx->eps = eps;
165:   PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->eps);
166:   nep->state = NEP_STATE_INITIAL;
167:   return(0);
168: }

172: /*@
173:    NEPSLPSetEPS - Associate a linear eigensolver object (EPS) to the
174:    nonlinear eigenvalue solver.

176:    Collective on NEP

178:    Input Parameters:
179: +  nep - nonlinear eigenvalue solver
180: -  eps - the eigensolver object

182:    Level: advanced

184: .seealso: NEPSLPGetEPS()
185: @*/
186: PetscErrorCode NEPSLPSetEPS(NEP nep,EPS eps)
187: {

194:   PetscTryMethod(nep,"NEPSLPSetEPS_C",(NEP,EPS),(nep,eps));
195:   return(0);
196: }

200: static PetscErrorCode NEPSLPGetEPS_SLP(NEP nep,EPS *eps)
201: {
203:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;
204:   ST             st;

207:   if (!ctx->eps) {
208:     EPSCreate(PetscObjectComm((PetscObject)nep),&ctx->eps);
209:     EPSSetOptionsPrefix(ctx->eps,((PetscObject)nep)->prefix);
210:     EPSAppendOptionsPrefix(ctx->eps,"nep_slp_");
211:     EPSGetST(ctx->eps,&st);
212:     STSetOptionsPrefix(st,((PetscObject)ctx->eps)->prefix);
213:     PetscObjectIncrementTabLevel((PetscObject)ctx->eps,(PetscObject)nep,1);
214:     PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->eps);
215:   }
216:   *eps = ctx->eps;
217:   return(0);
218: }

222: /*@
223:    NEPSLPGetEPS - Retrieve the linear eigensolver object (EPS) associated
224:    to the nonlinear eigenvalue solver.

226:    Not Collective

228:    Input Parameter:
229: .  nep - nonlinear eigenvalue solver

231:    Output Parameter:
232: .  eps - the eigensolver object

234:    Level: advanced

236: .seealso: NEPSLPSetEPS()
237: @*/
238: PetscErrorCode NEPSLPGetEPS(NEP nep,EPS *eps)
239: {

245:   PetscUseMethod(nep,"NEPSLPGetEPS_C",(NEP,EPS*),(nep,eps));
246:   return(0);
247: }

251: PetscErrorCode NEPView_SLP(NEP nep,PetscViewer viewer)
252: {
254:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;
255:   PetscBool      isascii;

258:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
259:   if (isascii) {
260:     if (!ctx->eps) { NEPSLPGetEPS(nep,&ctx->eps); }
261:     PetscViewerASCIIPushTab(viewer);
262:     EPSView(ctx->eps,viewer);
263:     PetscViewerASCIIPopTab(viewer);
264:   }
265:   return(0);
266: }

270: PetscErrorCode NEPReset_SLP(NEP nep)
271: {
273:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;

276:   if (!ctx->eps) { EPSReset(ctx->eps); }
277:   return(0);
278: }

282: PetscErrorCode NEPDestroy_SLP(NEP nep)
283: {
285:   NEP_SLP        *ctx = (NEP_SLP*)nep->data;

288:   EPSDestroy(&ctx->eps);
289:   PetscFree(nep->data);
290:   PetscObjectComposeFunction((PetscObject)nep,"NEPSLPSetEPS_C",NULL);
291:   PetscObjectComposeFunction((PetscObject)nep,"NEPSLPGetEPS_C",NULL);
292:   return(0);
293: }

297: PETSC_EXTERN PetscErrorCode NEPCreate_SLP(NEP nep)
298: {
300:   NEP_SLP        *ctx;

303:   PetscNewLog(nep,&ctx);
304:   nep->data = (void*)ctx;

306:   nep->ops->solve          = NEPSolve_SLP;
307:   nep->ops->setup          = NEPSetUp_SLP;
308:   nep->ops->setfromoptions = NEPSetFromOptions_SLP;
309:   nep->ops->reset          = NEPReset_SLP;
310:   nep->ops->destroy        = NEPDestroy_SLP;
311:   nep->ops->view           = NEPView_SLP;
312:   PetscObjectComposeFunction((PetscObject)nep,"NEPSLPSetEPS_C",NEPSLPSetEPS_SLP);
313:   PetscObjectComposeFunction((PetscObject)nep,"NEPSLPGetEPS_C",NEPSLPGetEPS_SLP);
314:   return(0);
315: }

slepc-3.7.4/src/nep/impls/slp/slp.c0000644000175000017500000002477613107004621016440 0ustar jromanjroman/* SLEPc nonlinear eigensolver: "slp" Method: Succesive linear problems Algorithm: Newton-type iteration based on first order Taylor approximation. References: [1] A. Ruhe, "Algorithms for the nonlinear eigenvalue problem", SIAM J. Numer. Anal. 10(4):674-689, 1973. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ typedef struct { EPS eps; /* linear eigensolver for T*z = mu*Tp*z */ } NEP_SLP; #undef __FUNCT__ #define __FUNCT__ "NEPSetUp_SLP" PetscErrorCode NEPSetUp_SLP(NEP nep) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; ST st; PetscBool istrivial; PetscFunctionBegin; if (nep->nev>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Requested several eigenpairs but this solver can compute only one"); if (nep->ncv) { ierr = PetscInfo(nep,"Setting ncv = 1, ignoring user-provided value\n");CHKERRQ(ierr); } nep->ncv = 1; if (nep->mpd) { ierr = PetscInfo(nep,"Setting mpd = 1, ignoring user-provided value\n");CHKERRQ(ierr); } nep->mpd = 1; if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd"); if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv); if (nep->which && nep->which!=NEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of which"); ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support region filtering"); if (!ctx->eps) { ierr = NEPSLPGetEPS(nep,&ctx->eps);CHKERRQ(ierr); } ierr = EPSSetWhichEigenpairs(ctx->eps,EPS_TARGET_MAGNITUDE);CHKERRQ(ierr); ierr = EPSSetTarget(ctx->eps,0.0);CHKERRQ(ierr); ierr = EPSGetST(ctx->eps,&st);CHKERRQ(ierr); ierr = STSetType(st,STSINVERT);CHKERRQ(ierr); ierr = EPSSetTolerances(ctx->eps,nep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/10.0:nep->tol/10.0,nep->max_it?nep->max_it:PETSC_DEFAULT);CHKERRQ(ierr); ierr = NEPAllocateSolution(nep,0);CHKERRQ(ierr); ierr = NEPSetWorkVecs(nep,1);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSolve_SLP" PetscErrorCode NEPSolve_SLP(NEP nep) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; Mat T=nep->function,Tp=nep->jacobian; Vec u,r=nep->work[0]; PetscScalar lambda,mu,im; PetscReal resnorm; PetscInt nconv; PetscFunctionBegin; /* get initial approximation of eigenvalue and eigenvector */ ierr = NEPGetDefaultShift(nep,&lambda);CHKERRQ(ierr); if (!nep->nini) { ierr = BVSetRandomColumn(nep->V,0);CHKERRQ(ierr); } ierr = BVGetColumn(nep->V,0,&u);CHKERRQ(ierr); /* Restart loop */ while (nep->reason == NEP_CONVERGED_ITERATING) { nep->its++; /* evaluate T(lambda) and T'(lambda) */ ierr = NEPComputeFunction(nep,lambda,T,T);CHKERRQ(ierr); ierr = NEPComputeJacobian(nep,lambda,Tp);CHKERRQ(ierr); /* form residual, r = T(lambda)*u (used in convergence test only) */ ierr = MatMult(T,u,r);CHKERRQ(ierr); /* convergence test */ ierr = VecNorm(r,NORM_2,&resnorm);CHKERRQ(ierr); ierr = (*nep->converged)(nep,lambda,0,resnorm,&nep->errest[nep->nconv],nep->convergedctx);CHKERRQ(ierr); nep->eigr[nep->nconv] = lambda; if (nep->errest[nep->nconv]<=nep->tol) { nep->nconv = nep->nconv + 1; } ierr = (*nep->stopping)(nep,nep->its,nep->max_it,nep->nconv,nep->nev,&nep->reason,nep->stoppingctx);CHKERRQ(ierr); ierr = NEPMonitor(nep,nep->its,nep->nconv,nep->eigr,nep->eigi,nep->errest,1);CHKERRQ(ierr); if (nep->reason == NEP_CONVERGED_ITERATING) { /* compute eigenvalue correction mu and eigenvector approximation u */ ierr = EPSSetOperators(ctx->eps,T,Tp);CHKERRQ(ierr); ierr = EPSSetInitialSpace(ctx->eps,1,&u);CHKERRQ(ierr); ierr = EPSSolve(ctx->eps);CHKERRQ(ierr); ierr = EPSGetConverged(ctx->eps,&nconv);CHKERRQ(ierr); if (!nconv) { ierr = PetscInfo1(nep,"iter=%D, inner iteration failed, stopping solve\n",nep->its);CHKERRQ(ierr); nep->reason = NEP_DIVERGED_LINEAR_SOLVE; break; } ierr = EPSGetEigenpair(ctx->eps,0,&mu,&im,u,NULL);CHKERRQ(ierr); if (PetscAbsScalar(im)>PETSC_MACHINE_EPSILON) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Complex eigenvalue approximation - not implemented in real scalars"); /* correct eigenvalue */ lambda = lambda - mu; } } ierr = BVRestoreColumn(nep->V,0,&u);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetFromOptions_SLP" PetscErrorCode NEPSetFromOptions_SLP(PetscOptionItems *PetscOptionsObject,NEP nep) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"NEP SLP Options");CHKERRQ(ierr); if (!ctx->eps) { ierr = NEPSLPGetEPS(nep,&ctx->eps);CHKERRQ(ierr); } ierr = EPSSetFromOptions(ctx->eps);CHKERRQ(ierr); ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSLPSetEPS_SLP" static PetscErrorCode NEPSLPSetEPS_SLP(NEP nep,EPS eps) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; PetscFunctionBegin; ierr = PetscObjectReference((PetscObject)eps);CHKERRQ(ierr); ierr = EPSDestroy(&ctx->eps);CHKERRQ(ierr); ctx->eps = eps; ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->eps);CHKERRQ(ierr); nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSLPSetEPS" /*@ NEPSLPSetEPS - Associate a linear eigensolver object (EPS) to the nonlinear eigenvalue solver. Collective on NEP Input Parameters: + nep - nonlinear eigenvalue solver - eps - the eigensolver object Level: advanced .seealso: NEPSLPGetEPS() @*/ PetscErrorCode NEPSLPSetEPS(NEP nep,EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidHeaderSpecific(eps,EPS_CLASSID,2); PetscCheckSameComm(nep,1,eps,2); ierr = PetscTryMethod(nep,"NEPSLPSetEPS_C",(NEP,EPS),(nep,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSLPGetEPS_SLP" static PetscErrorCode NEPSLPGetEPS_SLP(NEP nep,EPS *eps) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; ST st; PetscFunctionBegin; if (!ctx->eps) { ierr = EPSCreate(PetscObjectComm((PetscObject)nep),&ctx->eps);CHKERRQ(ierr); ierr = EPSSetOptionsPrefix(ctx->eps,((PetscObject)nep)->prefix);CHKERRQ(ierr); ierr = EPSAppendOptionsPrefix(ctx->eps,"nep_slp_");CHKERRQ(ierr); ierr = EPSGetST(ctx->eps,&st);CHKERRQ(ierr); ierr = STSetOptionsPrefix(st,((PetscObject)ctx->eps)->prefix);CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->eps,(PetscObject)nep,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->eps);CHKERRQ(ierr); } *eps = ctx->eps; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSLPGetEPS" /*@ NEPSLPGetEPS - Retrieve the linear eigensolver object (EPS) associated to the nonlinear eigenvalue solver. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . eps - the eigensolver object Level: advanced .seealso: NEPSLPSetEPS() @*/ PetscErrorCode NEPSLPGetEPS(NEP nep,EPS *eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(eps,2); ierr = PetscUseMethod(nep,"NEPSLPGetEPS_C",(NEP,EPS*),(nep,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPView_SLP" PetscErrorCode NEPView_SLP(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (!ctx->eps) { ierr = NEPSLPGetEPS(nep,&ctx->eps);CHKERRQ(ierr); } ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = EPSView(ctx->eps,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReset_SLP" PetscErrorCode NEPReset_SLP(NEP nep) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; PetscFunctionBegin; if (!ctx->eps) { ierr = EPSReset(ctx->eps);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPDestroy_SLP" PetscErrorCode NEPDestroy_SLP(NEP nep) { PetscErrorCode ierr; NEP_SLP *ctx = (NEP_SLP*)nep->data; PetscFunctionBegin; ierr = EPSDestroy(&ctx->eps);CHKERRQ(ierr); ierr = PetscFree(nep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPSLPSetEPS_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPSLPGetEPS_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCreate_SLP" PETSC_EXTERN PetscErrorCode NEPCreate_SLP(NEP nep) { PetscErrorCode ierr; NEP_SLP *ctx; PetscFunctionBegin; ierr = PetscNewLog(nep,&ctx);CHKERRQ(ierr); nep->data = (void*)ctx; nep->ops->solve = NEPSolve_SLP; nep->ops->setup = NEPSetUp_SLP; nep->ops->setfromoptions = NEPSetFromOptions_SLP; nep->ops->reset = NEPReset_SLP; nep->ops->destroy = NEPDestroy_SLP; nep->ops->view = NEPView_SLP; ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPSLPSetEPS_C",NEPSLPSetEPS_SLP);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPSLPGetEPS_C",NEPSLPGetEPS_SLP);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/impls/makefile.html0000644000175000017500000000460113107004621017324 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcnep
DIRS     = rii slp narnoldi interpol ciss nleigs
LOCDIR   = src/nep/impls/
MANSEC   = NEP

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/impls/ciss/0000755000175000017500000000000013107004621015621 5ustar jromanjromanslepc-3.7.4/src/nep/impls/ciss/makefile0000644000175000017500000000220613107004621017321 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresscalar complex CFLAGS = FFLAGS = SOURCEC = nciss.c SOURCEF = SOURCEH = LIBBASE = libslepcnep DIRS = MANSEC = NEP LOCDIR = src/nep/impls/ciss/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/ciss/nciss.c0000644000175000017500000012565013107004621017115 0ustar jromanjroman/* SLEPc eigensolver: "ciss" Method: Contour Integral Spectral Slicing Algorithm: Contour integral based on Sakurai-Sugiura method to construct a subspace, with various eigenpair extractions (Rayleigh-Ritz, explicit moment). Based on code contributed by Y. Maeda, T. Sakurai. References: [1] T. Sakurai and H. Sugiura, "A projection method for generalized eigenvalue problems", J. Comput. Appl. Math. 159:119-128, 2003. [2] T. Sakurai and H. Tadano, "CIRR: a Rayleigh-Ritz type method with contour integral for generalized eigenvalue problems", Hokkaido Math. J. 36:745-757, 2007. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #include typedef struct { /* parameters */ PetscInt N; /* number of integration points (32) */ PetscInt L; /* block size (16) */ PetscInt M; /* moment degree (N/4 = 4) */ PetscReal delta; /* threshold of singular value (1e-12) */ PetscInt L_max; /* maximum number of columns of the source matrix V */ PetscReal spurious_threshold; /* discard spurious eigenpairs */ PetscBool isreal; /* T(z) is real for real z */ PetscInt refine_inner; PetscInt refine_blocksize; /* private data */ PetscReal *sigma; /* threshold for numerical rank */ PetscInt num_subcomm; PetscInt subcomm_id; PetscInt num_solve_point; PetscScalar *weight; PetscScalar *omega; PetscScalar *pp; BV V; BV S; BV Y; KSP *ksp; Mat *kspMat; PetscBool useconj; PetscReal est_eig; PetscSubcomm subcomm; PetscBool usest; } NEP_CISS; #undef __FUNCT__ #define __FUNCT__ "SetSolverComm" static PetscErrorCode SetSolverComm(NEP nep) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscInt N = ctx->N; PetscFunctionBegin; if (ctx->useconj) N = N/2; if (!ctx->subcomm) { ierr = PetscSubcommCreate(PetscObjectComm((PetscObject)nep),&ctx->subcomm);CHKERRQ(ierr); ierr = PetscSubcommSetNumber(ctx->subcomm,ctx->num_subcomm);CHKERRQ(ierr);CHKERRQ(ierr); ierr = PetscSubcommSetType(ctx->subcomm,PETSC_SUBCOMM_INTERLACED);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)nep,sizeof(PetscSubcomm));CHKERRQ(ierr); ierr = PetscSubcommSetFromOptions(ctx->subcomm);CHKERRQ(ierr); } ctx->subcomm_id = ctx->subcomm->color; ctx->num_solve_point = N / ctx->num_subcomm; if ((N%ctx->num_subcomm) > ctx->subcomm_id) ctx->num_solve_point+=1; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SetPathParameter" static PetscErrorCode SetPathParameter(NEP nep) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscInt i; PetscScalar center; PetscReal theta,radius,vscale,rgscale; PetscBool isellipse=PETSC_FALSE; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)nep->rg,RGELLIPSE,&isellipse);CHKERRQ(ierr); ierr = RGGetScale(nep->rg,&rgscale);CHKERRQ(ierr); if (isellipse) { ierr = RGEllipseGetParameters(nep->rg,¢er,&radius,&vscale);CHKERRQ(ierr); } else SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Region must be Ellipse"); for (i=0;iN;i++) { theta = ((2*PETSC_PI)/ctx->N)*(i+0.5); ctx->pp[i] = PetscCosReal(theta) + PETSC_i*vscale*PetscSinReal(theta); ctx->weight[i] = radius*(vscale*PetscCosReal(theta) + PETSC_i*PetscSinReal(theta))/(PetscReal)ctx->N; ctx->omega[i] = rgscale*(center + radius*ctx->pp[i]); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "CISSVecSetRandom" static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1) { PetscErrorCode ierr; PetscInt i,j,nlocal; PetscScalar *vdata; Vec x; PetscFunctionBegin; ierr = BVGetSizes(V,&nlocal,NULL,NULL);CHKERRQ(ierr); for (i=i0;idata; PetscInt i,j,p_id; Mat Fz; PC pc; Vec Bvj,vj,yj; KSP ksp; PetscFunctionBegin; if (ctx->usest) { ierr = NEPComputeFunction(nep,0,T,T);CHKERRQ(ierr); ierr = MatDuplicate(T,MAT_DO_NOT_COPY_VALUES,&Fz);CHKERRQ(ierr); ierr = KSPCreate(PetscObjectComm((PetscObject)nep),&ksp);CHKERRQ(ierr); } ierr = BVCreateVec(V,&Bvj);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; ierr = NEPComputeFunction(nep,ctx->omega[p_id],T,T);CHKERRQ(ierr); ierr = NEPComputeJacobian(nep,ctx->omega[p_id],dT);CHKERRQ(ierr); if (!ctx->usest && initksp == PETSC_TRUE) { ierr = MatDuplicate(T,MAT_COPY_VALUES,&ctx->kspMat[i]);CHKERRQ(ierr); ierr = KSPSetOperators(ctx->ksp[i],ctx->kspMat[i],ctx->kspMat[i]);CHKERRQ(ierr); ierr = KSPSetType(ctx->ksp[i],KSPPREONLY);CHKERRQ(ierr); ierr = KSPGetPC(ctx->ksp[i],&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); ierr = KSPSetFromOptions(ctx->ksp[i]);CHKERRQ(ierr); } else if (ctx->usest) { ierr = MatCopy(T,Fz,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = KSPSetOperators(ksp,Fz,Fz);CHKERRQ(ierr); ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr); } for (j=L_start;jY,i*ctx->L_max+j,&yj);CHKERRQ(ierr); ierr = MatMult(dT,vj,Bvj);CHKERRQ(ierr); if (ctx->usest) { ierr = KSPSolve(ksp,Bvj,yj);CHKERRQ(ierr); } else { ierr = KSPSolve(ctx->ksp[i],Bvj,yj);CHKERRQ(ierr); } ierr = BVRestoreColumn(V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->Y,i*ctx->L_max+j,&yj);CHKERRQ(ierr); } if (ctx->usest && inum_solve_point-1) { ierr = KSPReset(ksp);CHKERRQ(ierr); } } if (ctx->usest) { ierr = MatDestroy(&Fz);CHKERRQ(ierr); ierr = KSPDestroy(&ksp);CHKERRQ(ierr); } ierr = VecDestroy(&Bvj);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EstimateNumberEigs" static PetscErrorCode EstimateNumberEigs(NEP nep,PetscInt *L_add) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscInt i,j,p_id; PetscScalar tmp,m = 1,sum = 0.0; PetscReal eta; Vec v,vtemp,vj,yj; PetscFunctionBegin; ierr = BVGetColumn(ctx->Y,0,&yj);CHKERRQ(ierr); ierr = VecDuplicate(yj,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->Y,0,&yj);CHKERRQ(ierr); ierr = BVCreateVec(ctx->V,&vtemp);CHKERRQ(ierr); for (j=0;jL;j++) { ierr = VecSet(v,0);CHKERRQ(ierr); for (i=0;inum_solve_point; i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; ierr = BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);CHKERRQ(ierr); ierr = BVMultVec(ctx->Y,ctx->weight[p_id],1,v,&m);CHKERRQ(ierr); } ierr = BVGetColumn(ctx->V,j,&vj);CHKERRQ(ierr); ierr = VecDot(vj,v,&tmp);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->V,j,&vj);CHKERRQ(ierr); if (ctx->useconj) sum += PetscRealPart(tmp)*2; else sum += tmp; } ctx->est_eig = PetscAbsScalar(sum/(PetscReal)ctx->L); eta = PetscPowReal(10,-PetscLog10Real(nep->tol)/ctx->N); ierr = PetscInfo1(nep,"Estimation_#Eig %f\n",(double)ctx->est_eig);CHKERRQ(ierr); *L_add = (PetscInt)PetscCeilReal((ctx->est_eig*eta)/ctx->M) - ctx->L; if (*L_add < 0) *L_add = 0; if (*L_add>ctx->L_max-ctx->L) { ierr = PetscInfo(nep,"Number of eigenvalues around the contour path may be too large\n");CHKERRQ(ierr); *L_add = ctx->L_max-ctx->L; } ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&vtemp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "CalcMu" static PetscErrorCode CalcMu(NEP nep, PetscScalar *Mu) { PetscErrorCode ierr; PetscMPIInt sub_size,len; PetscInt i,j,k,s; PetscScalar *m,*temp,*temp2,*ppk,alp; NEP_CISS *ctx = (NEP_CISS*)nep->data; Mat M; PetscFunctionBegin; ierr = MPI_Comm_size(PetscSubcommChild(ctx->subcomm),&sub_size);CHKERRQ(ierr); ierr = PetscMalloc3(ctx->num_solve_point*ctx->L*(ctx->L+1),&temp,2*ctx->M*ctx->L*ctx->L,&temp2,ctx->num_solve_point,&ppk);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,ctx->L,ctx->L_max*ctx->num_solve_point,NULL,&M);CHKERRQ(ierr); for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] = 0; ierr = BVSetActiveColumns(ctx->Y,0,ctx->L_max*ctx->num_solve_point);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->V,0,ctx->L);CHKERRQ(ierr); ierr = BVDot(ctx->Y,ctx->V,M);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&m);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) { for (j=0;jL;j++) { for (k=0;kL;k++) { temp[k+j*ctx->L+i*ctx->L*ctx->L]=m[k+j*ctx->L+i*ctx->L*ctx->L_max]; } } } ierr = MatDenseRestoreArray(M,&m);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) ppk[i] = 1; for (k=0;k<2*ctx->M;k++) { for (j=0;jL;j++) { for (i=0;inum_solve_point;i++) { alp = ppk[i]*ctx->weight[i*ctx->subcomm->n + ctx->subcomm_id]; for (s=0;sL;s++) { if (ctx->useconj) temp2[s+(j+k*ctx->L)*ctx->L] += PetscRealPart(alp*temp[s+(j+i*ctx->L)*ctx->L])*2; else temp2[s+(j+k*ctx->L)*ctx->L] += alp*temp[s+(j+i*ctx->L)*ctx->L]; } } } for (i=0;inum_solve_point;i++) ppk[i] *= ctx->pp[i*ctx->subcomm->n + ctx->subcomm_id]; } for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] /= sub_size; ierr = PetscMPIIntCast(2*ctx->M*ctx->L*ctx->L,&len);CHKERRQ(ierr); ierr = MPI_Allreduce(temp2,Mu,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)nep));CHKERRQ(ierr); ierr = PetscFree3(temp,temp2,ppk);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BlockHankel" static PetscErrorCode BlockHankel(NEP nep,PetscScalar *Mu,PetscInt s,PetscScalar *H) { NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscInt i,j,k,L=ctx->L,M=ctx->M; PetscFunctionBegin; for (k=0;kdata; PetscInt i,ml=ctx->L*ctx->M; PetscBLASInt m,n,lda,ldu,ldvt,lwork,info; PetscScalar *work; #if defined(PETSC_USE_COMPLEX) PetscReal *rwork; #endif PetscFunctionBegin; ierr = PetscMalloc1(5*ml,&work);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscMalloc1(5*ml,&rwork);CHKERRQ(ierr); #endif ierr = PetscBLASIntCast(ml,&m);CHKERRQ(ierr); n = m; lda = m; ldu = m; ldvt = m; lwork = 5*m; ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,rwork,&info)); #else PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info); ierr = PetscFPTrapPop();CHKERRQ(ierr); (*K) = 0; for (i=0;isigma[i]/PetscMax(ctx->sigma[0],1)>ctx->delta) (*K)++; } ierr = PetscFree(work);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscFree(rwork);CHKERRQ(ierr); #endif PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "ConstructS" static PetscErrorCode ConstructS(NEP nep) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscInt i,j,k,vec_local_size,p_id; Vec v,sj,yj; PetscScalar *ppk, *v_data, m = 1; PetscFunctionBegin; ierr = BVGetSizes(ctx->Y,&vec_local_size,NULL,NULL);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->num_solve_point,&ppk);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) ppk[i] = 1; ierr = BVGetColumn(ctx->Y,0,&yj);CHKERRQ(ierr); ierr = VecDuplicate(yj,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->Y,0,&yj);CHKERRQ(ierr); for (k=0;kM;k++) { for (j=0;jL;j++) { ierr = VecSet(v,0);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; ierr = BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);CHKERRQ(ierr); ierr = BVMultVec(ctx->Y,ppk[i]*ctx->weight[p_id],1,v,&m);CHKERRQ(ierr); } if (ctx->useconj) { ierr = VecGetArray(v,&v_data);CHKERRQ(ierr); for (i=0;iS,k*ctx->L+j,&sj);CHKERRQ(ierr); ierr = VecCopy(v,sj);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->S,k*ctx->L+j,&sj);CHKERRQ(ierr); } for (i=0;inum_solve_point;i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; ppk[i] *= ctx->pp[p_id]; } } ierr = PetscFree(ppk);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "isGhost" static PetscErrorCode isGhost(NEP nep,PetscInt ld,PetscInt nv,PetscBool *fl) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscInt i,j; PetscScalar *pX; PetscReal *tau,s1,s2,tau_max=0.0; PetscFunctionBegin; ierr = PetscMalloc1(nv,&tau);CHKERRQ(ierr); ierr = DSVectors(nep->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetArray(nep->ds,DS_MAT_X,&pX);CHKERRQ(ierr); for (i=0;isigma[j]; } tau[i] = s1/s2; tau_max = PetscMax(tau_max,tau[i]); } ierr = DSRestoreArray(nep->ds,DS_MAT_X,&pX);CHKERRQ(ierr); for (i=0;i=ctx->spurious_threshold) fl[i] = PETSC_TRUE; else fl[i] = PETSC_FALSE; } ierr = PetscFree(tau);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetUp_CISS" PetscErrorCode NEPSetUp_CISS(NEP nep) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscInt i,nwork; PetscBool istrivial,isellipse,flg; PetscScalar center; PetscFunctionBegin; if (!nep->ncv) nep->ncv = ctx->L_max*ctx->M; else { ctx->L_max = nep->ncv/ctx->M; if (ctx->L_max == 0) { ctx->L_max = 1; nep->ncv = ctx->L_max*ctx->M; } if (ctx->L > ctx->L_max) ctx->L = ctx->L_max; } if (!nep->max_it) nep->max_it = 1; if (!nep->mpd) nep->mpd = nep->ncv; if (!nep->which) nep->which = NEP_ALL; if (nep->stopping!=NEPStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support user-defined stopping test"); /* check region */ ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); if (istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"CISS requires a nontrivial region, e.g. -rg_type ellipse ..."); ierr = RGGetComplement(nep->rg,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"A region with complement flag set is not allowed"); ierr = PetscObjectTypeCompare((PetscObject)nep->rg,RGELLIPSE,&isellipse);CHKERRQ(ierr); if (!isellipse) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Currently only implemented for elliptic or arc regions"); ierr = RGEllipseGetParameters(nep->rg,¢er,NULL,NULL);CHKERRQ(ierr); if (ctx->isreal && PetscImaginaryPart(center) == 0.0) ctx->useconj = PETSC_TRUE; else ctx->useconj = PETSC_FALSE; /* create split comm */ ctx->num_subcomm = 1; ierr = SetSolverComm(nep);CHKERRQ(ierr); ierr = NEPAllocateSolution(nep,0);CHKERRQ(ierr); ierr = PetscMalloc4(ctx->N,&ctx->weight,ctx->N,&ctx->omega,ctx->N,&ctx->pp,ctx->L_max*ctx->M,&ctx->sigma);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)nep,3*ctx->N*sizeof(PetscScalar)+ctx->L_max*ctx->N*sizeof(PetscReal));CHKERRQ(ierr); /* allocate basis vectors */ ierr = BVDuplicateResize(nep->V,ctx->L_max*ctx->M,&ctx->S);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->S);CHKERRQ(ierr); ierr = BVDuplicateResize(nep->V,ctx->L_max,&ctx->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->V);CHKERRQ(ierr); if (!ctx->usest) { ierr = PetscMalloc2(ctx->num_solve_point,&ctx->ksp,ctx->num_solve_point,&ctx->kspMat);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)nep,ctx->num_solve_point*sizeof(KSP)+ctx->num_solve_point*sizeof(Mat));CHKERRQ(ierr); for (i=0;inum_solve_point;i++) { ierr = KSPCreate(PetscSubcommChild(ctx->subcomm),&ctx->ksp[i]);CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->ksp[i],(PetscObject)nep,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp[i]);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(ctx->ksp[i],((PetscObject)nep)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(ctx->ksp[i],"nep_ciss_");CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(ctx->ksp[i],PETSC_TRUE);CHKERRQ(ierr); } } ierr = BVDuplicateResize(nep->V,ctx->num_solve_point*ctx->L_max,&ctx->Y);CHKERRQ(ierr); ierr = DSSetType(nep->ds,DSGNHEP);CHKERRQ(ierr); ierr = DSAllocate(nep->ds,nep->ncv);CHKERRQ(ierr); nwork = (nep->fui==NEP_USER_INTERFACE_SPLIT)? 2: 1; ierr = NEPSetWorkVecs(nep,nwork);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSolve_CISS" PetscErrorCode NEPSolve_CISS(NEP nep) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; Mat X,M; PetscInt i,j,ld,L_add=0,nv=0,L_base=ctx->L,inner,*inside; PetscScalar *Mu,*H0,*H1,*rr,*temp,center; PetscReal error,max_error,radius,rgscale; PetscBool *fl1; Vec si; SlepcSC sc; PetscRandom rand; PetscFunctionBegin; ierr = DSGetSlepcSC(nep->ds,&sc);CHKERRQ(ierr); sc->comparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSGetLeadingDimension(nep->ds,&ld);CHKERRQ(ierr); ierr = SetPathParameter(nep);CHKERRQ(ierr); ierr = CISSVecSetRandom(ctx->V,0,ctx->L);CHKERRQ(ierr); ierr = BVGetRandomContext(ctx->V,&rand);CHKERRQ(ierr); ierr = SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,0,ctx->L,PETSC_TRUE);CHKERRQ(ierr); ierr = EstimateNumberEigs(nep,&L_add);CHKERRQ(ierr); if (L_add>0) { ierr = PetscInfo2(nep,"Changing L %D -> %D by Estimate #Eig\n",ctx->L,ctx->L+L_add);CHKERRQ(ierr); ierr = CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);CHKERRQ(ierr); ierr = SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);CHKERRQ(ierr); ctx->L += L_add; } ierr = PetscMalloc2(ctx->L*ctx->L*ctx->M*2,&Mu,ctx->L*ctx->M*ctx->L*ctx->M,&H0);CHKERRQ(ierr); for (i=0;irefine_blocksize;i++) { ierr = CalcMu(nep,Mu);CHKERRQ(ierr); ierr = BlockHankel(nep,Mu,0,H0);CHKERRQ(ierr); ierr = SVD_H0(nep,H0,&nv);CHKERRQ(ierr); if (ctx->sigma[0]<=ctx->delta || nv < ctx->L*ctx->M || ctx->L == ctx->L_max) break; L_add = L_base; if (ctx->L+L_add>ctx->L_max) L_add = ctx->L_max-ctx->L; ierr = PetscInfo2(nep,"Changing L %D -> %D by SVD(H0)\n",ctx->L,ctx->L+L_add);CHKERRQ(ierr); ierr = CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);CHKERRQ(ierr); ierr = SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);CHKERRQ(ierr); ctx->L += L_add; } ierr = PetscFree2(Mu,H0);CHKERRQ(ierr); ierr = RGGetScale(nep->rg,&rgscale);CHKERRQ(ierr); ierr = RGEllipseGetParameters(nep->rg,¢er,&radius,NULL);CHKERRQ(ierr); ierr = PetscMalloc3(ctx->L*ctx->L*ctx->M*2,&Mu,ctx->L*ctx->M*ctx->L*ctx->M,&H0,ctx->L*ctx->M*ctx->L*ctx->M,&H1);CHKERRQ(ierr); while (nep->reason == NEP_CONVERGED_ITERATING) { nep->its++; for (inner=0;inner<=ctx->refine_inner;inner++) { ierr = CalcMu(nep,Mu);CHKERRQ(ierr); ierr = BlockHankel(nep,Mu,0,H0);CHKERRQ(ierr); ierr = SVD_H0(nep,H0,&nv);CHKERRQ(ierr); if (ctx->sigma[0]>ctx->delta && nv==ctx->L*ctx->M && inner!=ctx->refine_inner) { ierr = ConstructS(nep);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,ctx->L);CHKERRQ(ierr); ierr = BVCopy(ctx->S,ctx->V);CHKERRQ(ierr); ierr = SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,0,ctx->L,PETSC_FALSE);CHKERRQ(ierr); } else break; } nep->nconv = 0; if (nv == 0) break; ierr = BlockHankel(nep,Mu,0,H0);CHKERRQ(ierr); ierr = BlockHankel(nep,Mu,1,H1);CHKERRQ(ierr); ierr = DSSetDimensions(nep->ds,nv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(nep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSGetArray(nep->ds,DS_MAT_A,&temp);CHKERRQ(ierr); for (j=0;jL*ctx->M]; ierr = DSRestoreArray(nep->ds,DS_MAT_A,&temp);CHKERRQ(ierr); ierr = DSGetArray(nep->ds,DS_MAT_B,&temp);CHKERRQ(ierr); for (j=0;jL*ctx->M]; ierr = DSRestoreArray(nep->ds,DS_MAT_B,&temp);CHKERRQ(ierr); ierr = DSSolve(nep->ds,nep->eigr,nep->eigi);CHKERRQ(ierr); ierr = DSVectors(nep->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); for (i=0;ieigr[i] = (nep->eigr[i]*radius+center)*rgscale; #if !defined(PETSC_USE_COMPLEX) nep->eigi[i] = nep->eigi[i]*radius*rgscale; #endif } ierr = PetscMalloc3(nv,&fl1,nv,&inside,nv,&rr);CHKERRQ(ierr); ierr = isGhost(nep,ld,nv,fl1);CHKERRQ(ierr); ierr = RGCheckInside(nep->rg,nv,nep->eigr,nep->eigi,inside);CHKERRQ(ierr); for (i=0;i0) { rr[i] = 1.0; nep->nconv++; } else rr[i] = 0.0; } ierr = DSSort(nep->ds,nep->eigr,nep->eigi,rr,NULL,&nep->nconv);CHKERRQ(ierr); for (i=0;ieigr[i] = (nep->eigr[i]*radius+center)*rgscale; #if !defined(PETSC_USE_COMPLEX) nep->eigi[i] = nep->eigi[i]*radius*rgscale; #endif } ierr = PetscFree3(fl1,inside,rr);CHKERRQ(ierr); ierr = BVSetActiveColumns(nep->V,0,nv);CHKERRQ(ierr); ierr = ConstructS(nep);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,nv);CHKERRQ(ierr); ierr = BVCopy(ctx->S,nep->V);CHKERRQ(ierr); ierr = DSVectors(nep->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetMat(nep->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVMultInPlace(ctx->S,X,0,nep->nconv);CHKERRQ(ierr); ierr = BVMultInPlace(nep->V,X,0,nep->nconv);CHKERRQ(ierr); ierr = MatDestroy(&X);CHKERRQ(ierr); max_error = 0.0; for (i=0;inconv;i++) { ierr = BVGetColumn(nep->V,i,&si);CHKERRQ(ierr); ierr = VecNormalize(si,NULL);CHKERRQ(ierr); ierr = NEPComputeResidualNorm_Private(nep,nep->eigr[i],si,nep->work,&error);CHKERRQ(ierr); ierr = (*nep->converged)(nep,nep->eigr[i],0,error,&error,nep->convergedctx);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,i,&si);CHKERRQ(ierr); max_error = PetscMax(max_error,error); } if (max_error <= nep->tol) nep->reason = NEP_CONVERGED_TOL; else if (nep->its > nep->max_it) nep->reason = NEP_DIVERGED_ITS; else { if (nep->nconv > ctx->L) nv = nep->nconv; else if (ctx->L > nv) nv = ctx->L; ierr = MatCreateSeqDense(PETSC_COMM_SELF,nv,ctx->L,NULL,&M);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&temp);CHKERRQ(ierr); for (i=0;iL*nv;i++) { ierr = PetscRandomGetValue(rand,&temp[i]);CHKERRQ(ierr); temp[i] = PetscRealPart(temp[i]); } ierr = MatDenseRestoreArray(M,&temp);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,nv);CHKERRQ(ierr); ierr = BVMultInPlace(ctx->S,M,0,ctx->L);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,ctx->L);CHKERRQ(ierr); ierr = BVCopy(ctx->S,ctx->V);CHKERRQ(ierr); ierr = SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,0,ctx->L,PETSC_FALSE);CHKERRQ(ierr); } } ierr = PetscFree3(Mu,H0,H1);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSSetSizes_CISS" static PetscErrorCode NEPCISSSetSizes_CISS(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats) { NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; if (ip == PETSC_DECIDE || ip == PETSC_DEFAULT) { if (ctx->N!=32) { ctx->N =32; ctx->M = ctx->N/4; } } else { if (ip<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be > 0"); if (ip%2) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be an even number"); if (ctx->N!=ip) { ctx->N = ip; ctx->M = ctx->N/4; } } if (bs == PETSC_DECIDE || bs == PETSC_DEFAULT) { ctx->L = 16; } else { if (bs<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be > 0"); if (bs>ctx->L_max) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be less than or equal to the maximum number of block size"); ctx->L = bs; } if (ms == PETSC_DECIDE || ms == PETSC_DEFAULT) { ctx->M = ctx->N/4; } else { if (ms<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be > 0"); if (ms>ctx->N) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be less than or equal to the number of integration points"); ctx->M = ms; } if (npart == PETSC_DECIDE || npart == PETSC_DEFAULT) { ctx->num_subcomm = 1; } else { if (npart<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The npart argument must be > 0"); ctx->num_subcomm = npart; } if (bsmax == PETSC_DECIDE || bsmax == PETSC_DEFAULT) { ctx->L = 256; } else { if (bsmax<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The bsmax argument must be > 0"); if (bsmaxL) ctx->L_max = ctx->L; else ctx->L_max = bsmax; } ctx->isreal = realmats; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSSetSizes" /*@ NEPCISSSetSizes - Sets the values of various size parameters in the CISS solver. Logically Collective on NEP Input Parameters: + nep - the eigenproblem solver context . ip - number of integration points . bs - block size . ms - moment size . npart - number of partitions when splitting the communicator . bsmax - max block size - realmats - T(z) is real for real z Options Database Keys: + -nep_ciss_integration_points - Sets the number of integration points . -nep_ciss_blocksize - Sets the block size . -nep_ciss_moments - Sets the moment size . -nep_ciss_partitions - Sets the number of partitions . -nep_ciss_maxblocksize - Sets the maximum block size - -nep_ciss_realmats - T(z) is real for real z Note: The default number of partitions is 1. This means the internal KSP object is shared among all processes of the NEP communicator. Otherwise, the communicator is split into npart communicators, so that npart KSP solves proceed simultaneously. The realmats flag can be set to true when T(.) is guaranteed to be real when the argument is a real value, for example, when all matrices in the split form are real. When set to true, the solver avoids some computations. Level: advanced .seealso: NEPCISSGetSizes() @*/ PetscErrorCode NEPCISSSetSizes(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,ip,2); PetscValidLogicalCollectiveInt(nep,bs,3); PetscValidLogicalCollectiveInt(nep,ms,4); PetscValidLogicalCollectiveInt(nep,npart,5); PetscValidLogicalCollectiveInt(nep,bsmax,6); PetscValidLogicalCollectiveBool(nep,realmats,7); ierr = PetscTryMethod(nep,"NEPCISSSetSizes_C",(NEP,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool),(nep,ip,bs,ms,npart,bsmax,realmats));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSGetSizes_CISS" static PetscErrorCode NEPCISSGetSizes_CISS(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats) { NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; if (ip) *ip = ctx->N; if (bs) *bs = ctx->L; if (ms) *ms = ctx->M; if (npart) *npart = ctx->num_subcomm; if (bsmax) *bsmax = ctx->L_max; if (realmats) *realmats = ctx->isreal; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSGetSizes" /*@ NEPCISSGetSizes - Gets the values of various size parameters in the CISS solver. Not Collective Input Parameter: . nep - the eigenproblem solver context Output Parameters: + ip - number of integration points . bs - block size . ms - moment size . npart - number of partitions when splitting the communicator . bsmax - max block size - realmats - T(z) is real for real z Level: advanced .seealso: NEPCISSSetSizes() @*/ PetscErrorCode NEPCISSGetSizes(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = PetscUseMethod(nep,"NEPCISSGetSizes_C",(NEP,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*),(nep,ip,bs,ms,npart,bsmax,realmats));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSSetThreshold_CISS" static PetscErrorCode NEPCISSSetThreshold_CISS(NEP nep,PetscReal delta,PetscReal spur) { NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; if (delta == PETSC_DEFAULT) { ctx->delta = 1e-12; } else { if (delta<=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The delta argument must be > 0.0"); ctx->delta = delta; } if (spur == PETSC_DEFAULT) { ctx->spurious_threshold = 1e-4; } else { if (spur<=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The spurious threshold argument must be > 0.0"); ctx->spurious_threshold = spur; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSSetThreshold" /*@ NEPCISSSetThreshold - Sets the values of various threshold parameters in the CISS solver. Logically Collective on NEP Input Parameters: + nep - the eigenproblem solver context . delta - threshold for numerical rank - spur - spurious threshold (to discard spurious eigenpairs) Options Database Keys: + -nep_ciss_delta - Sets the delta - -nep_ciss_spurious_threshold - Sets the spurious threshold Level: advanced .seealso: NEPCISSGetThreshold() @*/ PetscErrorCode NEPCISSSetThreshold(NEP nep,PetscReal delta,PetscReal spur) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveReal(nep,delta,2); PetscValidLogicalCollectiveReal(nep,spur,3); ierr = PetscTryMethod(nep,"NEPCISSSetThreshold_C",(NEP,PetscReal,PetscReal),(nep,delta,spur));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSGetThreshold_CISS" static PetscErrorCode NEPCISSGetThreshold_CISS(NEP nep,PetscReal *delta,PetscReal *spur) { NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; if (delta) *delta = ctx->delta; if (spur) *spur = ctx->spurious_threshold; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSGetThreshold" /*@ NEPCISSGetThreshold - Gets the values of various threshold parameters in the CISS solver. Not Collective Input Parameter: . nep - the eigenproblem solver context Output Parameters: + delta - threshold for numerical rank - spur - spurious threshold (to discard spurious eigenpairs) Level: advanced .seealso: NEPCISSSetThreshold() @*/ PetscErrorCode NEPCISSGetThreshold(NEP nep,PetscReal *delta,PetscReal *spur) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = PetscUseMethod(nep,"NEPCISSGetThreshold_C",(NEP,PetscReal*,PetscReal*),(nep,delta,spur));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSSetRefinement_CISS" static PetscErrorCode NEPCISSSetRefinement_CISS(NEP nep,PetscInt inner,PetscInt blsize) { NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; if (inner == PETSC_DEFAULT) { ctx->refine_inner = 0; } else { if (inner<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The refine inner argument must be >= 0"); ctx->refine_inner = inner; } if (blsize == PETSC_DEFAULT) { ctx->refine_blocksize = 0; } else { if (blsize<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The refine blocksize argument must be >= 0"); ctx->refine_blocksize = blsize; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSSetRefinement" /*@ NEPCISSSetRefinement - Sets the values of various refinement parameters in the CISS solver. Logically Collective on NEP Input Parameters: + nep - the eigenproblem solver context . inner - number of iterative refinement iterations (inner loop) - blsize - number of iterative refinement iterations (blocksize loop) Options Database Keys: + -nep_ciss_refine_inner - Sets number of inner iterations - -nep_ciss_refine_blocksize - Sets number of blocksize iterations Level: advanced .seealso: NEPCISSGetRefinement() @*/ PetscErrorCode NEPCISSSetRefinement(NEP nep,PetscInt inner,PetscInt blsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,inner,2); PetscValidLogicalCollectiveInt(nep,blsize,3); ierr = PetscTryMethod(nep,"NEPCISSSetRefinement_C",(NEP,PetscInt,PetscInt),(nep,inner,blsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSGetRefinement_CISS" static PetscErrorCode NEPCISSGetRefinement_CISS(NEP nep,PetscInt *inner,PetscInt *blsize) { NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; if (inner) *inner = ctx->refine_inner; if (blsize) *blsize = ctx->refine_blocksize; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCISSGetRefinement" /*@ NEPCISSGetRefinement - Gets the values of various refinement parameters in the CISS solver. Not Collective Input Parameter: . nep - the eigenproblem solver context Output Parameters: + inner - number of iterative refinement iterations (inner loop) - blsize - number of iterative refinement iterations (blocksize loop) Level: advanced .seealso: NEPCISSSetRefinement() @*/ PetscErrorCode NEPCISSGetRefinement(NEP nep, PetscInt *inner, PetscInt *blsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = PetscUseMethod(nep,"NEPCISSGetRefinement_C",(NEP,PetscInt*,PetscInt*),(nep,inner,blsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReset_CISS" PetscErrorCode NEPReset_CISS(NEP nep) { PetscErrorCode ierr; PetscInt i; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; ierr = PetscSubcommDestroy(&ctx->subcomm);CHKERRQ(ierr); ierr = PetscFree4(ctx->weight,ctx->omega,ctx->pp,ctx->sigma);CHKERRQ(ierr); ierr = BVDestroy(&ctx->S);CHKERRQ(ierr); ierr = BVDestroy(&ctx->V);CHKERRQ(ierr); ierr = BVDestroy(&ctx->Y);CHKERRQ(ierr); if (!ctx->usest) { for (i=0;inum_solve_point;i++) { ierr = KSPDestroy(&ctx->ksp[i]);CHKERRQ(ierr); } for (i=0;inum_solve_point;i++) { ierr = MatDestroy(&ctx->kspMat[i]);CHKERRQ(ierr); } ierr = PetscFree2(ctx->ksp,ctx->kspMat);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetFromOptions_CISS" PetscErrorCode NEPSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,NEP nep) { PetscErrorCode ierr; PetscReal r1,r2; PetscInt i1,i2,i3,i4,i5,i6,i7; PetscBool b1; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"NEP CISS Options");CHKERRQ(ierr); ierr = NEPCISSGetSizes(nep,&i1,&i2,&i3,&i4,&i5,&b1);CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_ciss_integration_points","CISS number of integration points","NEPCISSSetSizes",i1,&i1,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_ciss_blocksize","CISS block size","NEPCISSSetSizes",i2,&i2,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_ciss_moments","CISS moment size","NEPCISSSetSizes",i3,&i3,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_ciss_partitions","CISS number of partitions","NEPCISSSetSizes",i4,&i4,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_ciss_maxblocksize","CISS maximum block size","NEPCISSSetSizes",i5,&i5,NULL);CHKERRQ(ierr); ierr = PetscOptionsBool("-nep_ciss_realmats","CISS flag indicating that T(z) is real for real z","NEPCISSSetSizes",b1,&b1,NULL);CHKERRQ(ierr); ierr = NEPCISSSetSizes(nep,i1,i2,i3,i4,i5,b1);CHKERRQ(ierr); ierr = NEPCISSGetThreshold(nep,&r1,&r2);CHKERRQ(ierr); ierr = PetscOptionsReal("-nep_ciss_delta","CISS threshold for numerical rank","NEPCISSSetThreshold",r1,&r1,NULL);CHKERRQ(ierr); ierr = PetscOptionsReal("-nep_ciss_spurious_threshold","CISS threshold for the spurious eigenpairs","NEPCISSSetThreshold",r2,&r2,NULL);CHKERRQ(ierr); ierr = NEPCISSSetThreshold(nep,r1,r2);CHKERRQ(ierr); ierr = NEPCISSGetRefinement(nep,&i6,&i7);CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_ciss_refine_inner","CISS number of inner iterative refinement iterations","NEPCISSSetRefinement",i6,&i6,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-nep_ciss_refine_blocksize","CISS number of blocksize iterative refinement iterations","NEPCISSSetRefinement",i7,&i7,NULL);CHKERRQ(ierr); ierr = NEPCISSSetRefinement(nep,i6,i7);CHKERRQ(ierr); ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPDestroy_CISS" PetscErrorCode NEPDestroy_CISS(NEP nep) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(nep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetThreshold_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetThreshold_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetRefinement_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetRefinement_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPView_CISS" PetscErrorCode NEPView_CISS(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," CISS: sizes { integration points: %D, block size: %D, moment size: %D, partitions: %D, maximum block size: %D }\n",ctx->N,ctx->L,ctx->M,ctx->num_subcomm,ctx->L_max);CHKERRQ(ierr); if (ctx->isreal) { ierr = PetscViewerASCIIPrintf(viewer," CISS: exploiting symmetry of integration points\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," CISS: threshold { delta: %g, spurious threshold: %g }\n",(double)ctx->delta,(double)ctx->spurious_threshold);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," CISS: iterative refinement { inner: %D, blocksize: %D }\n",ctx->refine_inner, ctx->refine_blocksize);CHKERRQ(ierr); ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); if (!ctx->usest && ctx->ksp[0]) { ierr = KSPView(ctx->ksp[0],viewer);CHKERRQ(ierr); } ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCreate_CISS" PETSC_EXTERN PetscErrorCode NEPCreate_CISS(NEP nep) { PetscErrorCode ierr; NEP_CISS *ctx = (NEP_CISS*)nep->data; PetscFunctionBegin; ierr = PetscNewLog(nep,&ctx);CHKERRQ(ierr); nep->data = ctx; nep->ops->solve = NEPSolve_CISS; nep->ops->setup = NEPSetUp_CISS; nep->ops->setfromoptions = NEPSetFromOptions_CISS; nep->ops->reset = NEPReset_CISS; nep->ops->destroy = NEPDestroy_CISS; nep->ops->view = NEPView_CISS; ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetSizes_C",NEPCISSSetSizes_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetSizes_C",NEPCISSGetSizes_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetThreshold_C",NEPCISSSetThreshold_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetThreshold_C",NEPCISSGetThreshold_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetRefinement_C",NEPCISSSetRefinement_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetRefinement_C",NEPCISSGetRefinement_CISS);CHKERRQ(ierr); /* set default values of parameters */ ctx->N = 32; ctx->L = 16; ctx->M = ctx->N/4; ctx->delta = 1e-12; ctx->L_max = 64; ctx->spurious_threshold = 1e-4; ctx->usest = PETSC_FALSE; ctx->isreal = PETSC_FALSE; ctx->refine_inner = 0; ctx->refine_blocksize = 0; ctx->num_subcomm = 1; PetscFunctionReturn(0); } slepc-3.7.4/src/nep/impls/ciss/nciss.c.html0000644000175000017500000025636113107004621020064 0ustar jromanjroman
Actual source code: nciss.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "ciss"

  5:    Method: Contour Integral Spectral Slicing

  7:    Algorithm:

  9:        Contour integral based on Sakurai-Sugiura method to construct a
 10:        subspace, with various eigenpair extractions (Rayleigh-Ritz,
 11:        explicit moment).

 13:    Based on code contributed by Y. Maeda, T. Sakurai.

 15:    References:

 17:        [1] T. Sakurai and H. Sugiura, "A projection method for generalized
 18:            eigenvalue problems", J. Comput. Appl. Math. 159:119-128, 2003.

 20:        [2] T. Sakurai and H. Tadano, "CIRR: a Rayleigh-Ritz type method with
 21:            contour integral for generalized eigenvalue problems", Hokkaido
 22:            Math. J. 36:745-757, 2007.

 24:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 25:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 26:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 28:    This file is part of SLEPc.

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

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

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

 44: #include <slepc/private/nepimpl.h>         /*I "slepcnep.h" I*/
 45: #include <slepcblaslapack.h>

 47: typedef struct {
 48:   /* parameters */
 49:   PetscInt     N;          /* number of integration points (32) */
 50:   PetscInt     L;          /* block size (16) */
 51:   PetscInt     M;          /* moment degree (N/4 = 4) */
 52:   PetscReal    delta;      /* threshold of singular value (1e-12) */
 53:   PetscInt     L_max;      /* maximum number of columns of the source matrix V */
 54:   PetscReal    spurious_threshold; /* discard spurious eigenpairs */
 55:   PetscBool    isreal;     /* T(z) is real for real z */
 56:   PetscInt     refine_inner;
 57:   PetscInt     refine_blocksize;
 58:   /* private data */
 59:   PetscReal    *sigma;     /* threshold for numerical rank */
 60:   PetscInt     num_subcomm;
 61:   PetscInt     subcomm_id;
 62:   PetscInt     num_solve_point;
 63:   PetscScalar  *weight;
 64:   PetscScalar  *omega;
 65:   PetscScalar  *pp;
 66:   BV           V;
 67:   BV           S;
 68:   BV           Y;
 69:   KSP          *ksp;
 70:   Mat          *kspMat;
 71:   PetscBool    useconj;
 72:   PetscReal    est_eig;
 73:   PetscSubcomm subcomm;
 74:   PetscBool    usest;
 75: } NEP_CISS;

 79: static PetscErrorCode SetSolverComm(NEP nep)
 80: {
 82:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
 83:   PetscInt       N = ctx->N;

 86:   if (ctx->useconj) N = N/2;
 87:   if (!ctx->subcomm) {
 88:     PetscSubcommCreate(PetscObjectComm((PetscObject)nep),&ctx->subcomm);
 89:     PetscSubcommSetNumber(ctx->subcomm,ctx->num_subcomm);
 90:     PetscSubcommSetType(ctx->subcomm,PETSC_SUBCOMM_INTERLACED);
 91:     PetscLogObjectMemory((PetscObject)nep,sizeof(PetscSubcomm));
 92:     PetscSubcommSetFromOptions(ctx->subcomm);
 93:   }
 94:   ctx->subcomm_id = ctx->subcomm->color;
 95:   ctx->num_solve_point = N / ctx->num_subcomm;
 96:   if ((N%ctx->num_subcomm) > ctx->subcomm_id) ctx->num_solve_point+=1;
 97:   return(0);
 98: }

102: static PetscErrorCode SetPathParameter(NEP nep)
103: {
105:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
106:   PetscInt       i;
107:   PetscScalar    center;
108:   PetscReal      theta,radius,vscale,rgscale;
109:   PetscBool      isellipse=PETSC_FALSE;

112:   PetscObjectTypeCompare((PetscObject)nep->rg,RGELLIPSE,&isellipse);
113:   RGGetScale(nep->rg,&rgscale);
114:   if (isellipse) {
115:     RGEllipseGetParameters(nep->rg,&center,&radius,&vscale);
116:   } else SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Region must be Ellipse");
117:   for (i=0;i<ctx->N;i++) {
118:     theta = ((2*PETSC_PI)/ctx->N)*(i+0.5);
119:     ctx->pp[i] = PetscCosReal(theta) + PETSC_i*vscale*PetscSinReal(theta);
120:     ctx->weight[i] = radius*(vscale*PetscCosReal(theta) + PETSC_i*PetscSinReal(theta))/(PetscReal)ctx->N;
121:     ctx->omega[i] = rgscale*(center + radius*ctx->pp[i]);
122:   }
123:   return(0);
124: }

128: static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1)
129: {
131:   PetscInt       i,j,nlocal;
132:   PetscScalar    *vdata;
133:   Vec            x;

136:   BVGetSizes(V,&nlocal,NULL,NULL);
137:   for (i=i0;i<i1;i++) {
138:     BVSetRandomColumn(V,i);
139:     BVGetColumn(V,i,&x);
140:     VecGetArray(x,&vdata);
141:     for (j=0;j<nlocal;j++) {
142:       vdata[j] = PetscRealPart(vdata[j]);
143:       if (PetscRealPart(vdata[j]) < 0.5) vdata[j] = -1.0;
144:       else vdata[j] = 1.0;
145:     }
146:     VecRestoreArray(x,&vdata);
147:     BVRestoreColumn(V,i,&x);
148:   }
149:   return(0);
150: }

154: static PetscErrorCode SolveLinearSystem(NEP nep,Mat T,Mat dT,BV V,PetscInt L_start,PetscInt L_end,PetscBool initksp)
155: {
157:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
158:   PetscInt       i,j,p_id;
159:   Mat            Fz;
160:   PC             pc;
161:   Vec            Bvj,vj,yj;
162:   KSP            ksp;

165:   if (ctx->usest) {
166:     NEPComputeFunction(nep,0,T,T);
167:     MatDuplicate(T,MAT_DO_NOT_COPY_VALUES,&Fz);
168:     KSPCreate(PetscObjectComm((PetscObject)nep),&ksp);
169:   }
170:   BVCreateVec(V,&Bvj);
171:   for (i=0;i<ctx->num_solve_point;i++) {
172:     p_id = i*ctx->subcomm->n + ctx->subcomm_id;
173:     NEPComputeFunction(nep,ctx->omega[p_id],T,T);
174:     NEPComputeJacobian(nep,ctx->omega[p_id],dT);
175:     if (!ctx->usest && initksp == PETSC_TRUE) {
176:       MatDuplicate(T,MAT_COPY_VALUES,&ctx->kspMat[i]);
177:       KSPSetOperators(ctx->ksp[i],ctx->kspMat[i],ctx->kspMat[i]);
178:       KSPSetType(ctx->ksp[i],KSPPREONLY);
179:       KSPGetPC(ctx->ksp[i],&pc);
180:       PCSetType(pc,PCLU);
181:       KSPSetFromOptions(ctx->ksp[i]);
182:     } else if (ctx->usest) {
183:       MatCopy(T,Fz,DIFFERENT_NONZERO_PATTERN);
184:       KSPSetOperators(ksp,Fz,Fz);
185:       KSPSetType(ksp,KSPPREONLY);
186:       KSPGetPC(ksp,&pc);
187:       PCSetType(pc,PCLU);
188:       KSPSetFromOptions(ksp);
189:     }
190:     for (j=L_start;j<L_end;j++) {
191:       BVGetColumn(V,j,&vj);
192:       BVGetColumn(ctx->Y,i*ctx->L_max+j,&yj);
193:       MatMult(dT,vj,Bvj);
194:       if (ctx->usest) {
195:         KSPSolve(ksp,Bvj,yj);
196:       } else {
197:         KSPSolve(ctx->ksp[i],Bvj,yj);
198:       }
199:       BVRestoreColumn(V,j,&vj);
200:       BVRestoreColumn(ctx->Y,i*ctx->L_max+j,&yj);
201:     }
202:     if (ctx->usest && i<ctx->num_solve_point-1) {  KSPReset(ksp); }
203:   }
204:   if (ctx->usest) {
205:     MatDestroy(&Fz);
206:     KSPDestroy(&ksp);
207:   }
208:   VecDestroy(&Bvj);
209:   return(0);
210: }

214: static PetscErrorCode EstimateNumberEigs(NEP nep,PetscInt *L_add)
215: {
217:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
218:   PetscInt       i,j,p_id;
219:   PetscScalar    tmp,m = 1,sum = 0.0;
220:   PetscReal      eta;
221:   Vec            v,vtemp,vj,yj;

224:   BVGetColumn(ctx->Y,0,&yj);
225:   VecDuplicate(yj,&v);
226:   BVRestoreColumn(ctx->Y,0,&yj);
227:   BVCreateVec(ctx->V,&vtemp);
228:   for (j=0;j<ctx->L;j++) {
229:     VecSet(v,0);
230:     for (i=0;i<ctx->num_solve_point; i++) {
231:       p_id = i*ctx->subcomm->n + ctx->subcomm_id;
232:       BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);
233:       BVMultVec(ctx->Y,ctx->weight[p_id],1,v,&m);
234:     }
235:     BVGetColumn(ctx->V,j,&vj);
236:     VecDot(vj,v,&tmp);
237:     BVRestoreColumn(ctx->V,j,&vj);
238:     if (ctx->useconj) sum += PetscRealPart(tmp)*2;
239:     else sum += tmp;
240:   }
241:   ctx->est_eig = PetscAbsScalar(sum/(PetscReal)ctx->L);
242:   eta = PetscPowReal(10,-PetscLog10Real(nep->tol)/ctx->N);
243:   PetscInfo1(nep,"Estimation_#Eig %f\n",(double)ctx->est_eig);
244:   *L_add = (PetscInt)PetscCeilReal((ctx->est_eig*eta)/ctx->M) - ctx->L;
245:   if (*L_add < 0) *L_add = 0;
246:   if (*L_add>ctx->L_max-ctx->L) {
247:     PetscInfo(nep,"Number of eigenvalues around the contour path may be too large\n");
248:     *L_add = ctx->L_max-ctx->L;
249:   }
250:   VecDestroy(&v);
251:   VecDestroy(&vtemp);
252:   return(0);
253: }

257: static PetscErrorCode CalcMu(NEP nep, PetscScalar *Mu)
258: {
260:   PetscMPIInt    sub_size,len;
261:   PetscInt       i,j,k,s;
262:   PetscScalar    *m,*temp,*temp2,*ppk,alp;
263:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
264:   Mat            M;

267:   MPI_Comm_size(PetscSubcommChild(ctx->subcomm),&sub_size);
268:   PetscMalloc3(ctx->num_solve_point*ctx->L*(ctx->L+1),&temp,2*ctx->M*ctx->L*ctx->L,&temp2,ctx->num_solve_point,&ppk);
269:   MatCreateSeqDense(PETSC_COMM_SELF,ctx->L,ctx->L_max*ctx->num_solve_point,NULL,&M);
270:   for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] = 0;
271:   BVSetActiveColumns(ctx->Y,0,ctx->L_max*ctx->num_solve_point);
272:   BVSetActiveColumns(ctx->V,0,ctx->L);
273:   BVDot(ctx->Y,ctx->V,M);
274:   MatDenseGetArray(M,&m);
275:   for (i=0;i<ctx->num_solve_point;i++) {
276:     for (j=0;j<ctx->L;j++) {
277:       for (k=0;k<ctx->L;k++) {
278:         temp[k+j*ctx->L+i*ctx->L*ctx->L]=m[k+j*ctx->L+i*ctx->L*ctx->L_max];
279:       }
280:     }
281:   }
282:   MatDenseRestoreArray(M,&m);
283:   for (i=0;i<ctx->num_solve_point;i++) ppk[i] = 1;
284:   for (k=0;k<2*ctx->M;k++) {
285:     for (j=0;j<ctx->L;j++) {
286:       for (i=0;i<ctx->num_solve_point;i++) {
287:         alp = ppk[i]*ctx->weight[i*ctx->subcomm->n + ctx->subcomm_id];
288:         for (s=0;s<ctx->L;s++) {
289:           if (ctx->useconj) temp2[s+(j+k*ctx->L)*ctx->L] += PetscRealPart(alp*temp[s+(j+i*ctx->L)*ctx->L])*2;
290:           else temp2[s+(j+k*ctx->L)*ctx->L] += alp*temp[s+(j+i*ctx->L)*ctx->L];
291:         }
292:       }
293:     }
294:     for (i=0;i<ctx->num_solve_point;i++) 
295:       ppk[i] *= ctx->pp[i*ctx->subcomm->n + ctx->subcomm_id];
296:   }
297:   for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] /= sub_size;
298:   PetscMPIIntCast(2*ctx->M*ctx->L*ctx->L,&len);
299:   MPI_Allreduce(temp2,Mu,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)nep));
300:   PetscFree3(temp,temp2,ppk);
301:   MatDestroy(&M);
302:   return(0);
303: }

307: static PetscErrorCode BlockHankel(NEP nep,PetscScalar *Mu,PetscInt s,PetscScalar *H)
308: {
309:   NEP_CISS *ctx = (NEP_CISS*)nep->data;
310:   PetscInt  i,j,k,L=ctx->L,M=ctx->M;

313:   for (k=0;k<L*M;k++)
314:     for (j=0;j<M;j++) 
315:       for (i=0;i<L;i++) 
316:         H[j*L+i+k*L*M] = Mu[i+k*L+(j+s)*L*L];
317:   return(0);
318: }

322: static PetscErrorCode SVD_H0(NEP nep,PetscScalar *S,PetscInt *K)
323: {
324: #if defined(PETSC_MISSING_LAPACK_GESVD)
326:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable");
327: #else
329:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
330:   PetscInt       i,ml=ctx->L*ctx->M;
331:   PetscBLASInt   m,n,lda,ldu,ldvt,lwork,info;
332:   PetscScalar    *work;
333: #if defined(PETSC_USE_COMPLEX)
334:   PetscReal      *rwork;
335: #endif

338:   PetscMalloc1(5*ml,&work);
339: #if defined(PETSC_USE_COMPLEX)
340:   PetscMalloc1(5*ml,&rwork);
341: #endif
342:   PetscBLASIntCast(ml,&m);
343:   n = m; lda = m; ldu = m; ldvt = m; lwork = 5*m;
344:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
345: #if defined(PETSC_USE_COMPLEX)
346:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,rwork,&info));
347: #else
348:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,&info));
349: #endif
350:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);
351:   PetscFPTrapPop();
352:   (*K) = 0;
353:   for (i=0;i<ml;i++) {
354:     if (ctx->sigma[i]/PetscMax(ctx->sigma[0],1)>ctx->delta) (*K)++;
355:   }
356:   PetscFree(work);
357: #if defined(PETSC_USE_COMPLEX)
358:   PetscFree(rwork);
359: #endif
360:   return(0);
361: #endif
362: }

366: static PetscErrorCode ConstructS(NEP nep)
367: {
369:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
370:   PetscInt       i,j,k,vec_local_size,p_id;
371:   Vec            v,sj,yj;
372:   PetscScalar    *ppk, *v_data, m = 1;

375:   BVGetSizes(ctx->Y,&vec_local_size,NULL,NULL);
376:   PetscMalloc1(ctx->num_solve_point,&ppk);
377:   for (i=0;i<ctx->num_solve_point;i++) ppk[i] = 1;
378:   BVGetColumn(ctx->Y,0,&yj);
379:   VecDuplicate(yj,&v);
380:   BVRestoreColumn(ctx->Y,0,&yj);
381:   for (k=0;k<ctx->M;k++) {
382:     for (j=0;j<ctx->L;j++) {
383:       VecSet(v,0);
384:       for (i=0;i<ctx->num_solve_point;i++) {
385:         p_id = i*ctx->subcomm->n + ctx->subcomm_id;
386:         BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);
387:         BVMultVec(ctx->Y,ppk[i]*ctx->weight[p_id],1,v,&m);
388:       }
389:       if (ctx->useconj) {
390:         VecGetArray(v,&v_data);
391:         for (i=0;i<vec_local_size;i++) v_data[i] = PetscRealPart(v_data[i])*2;
392:         VecRestoreArray(v,&v_data);
393:       }
394:       BVGetColumn(ctx->S,k*ctx->L+j,&sj);
395:       VecCopy(v,sj);
396:       BVRestoreColumn(ctx->S,k*ctx->L+j,&sj);
397:     }
398:     for (i=0;i<ctx->num_solve_point;i++) {
399:       p_id = i*ctx->subcomm->n + ctx->subcomm_id;
400:       ppk[i] *= ctx->pp[p_id];
401:     }
402:   }
403:   PetscFree(ppk);
404:   VecDestroy(&v);
405:   return(0);
406: }

410: static PetscErrorCode isGhost(NEP nep,PetscInt ld,PetscInt nv,PetscBool *fl)
411: {
413:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
414:   PetscInt       i,j;
415:   PetscScalar    *pX;
416:   PetscReal      *tau,s1,s2,tau_max=0.0;

419:   PetscMalloc1(nv,&tau);
420:   DSVectors(nep->ds,DS_MAT_X,NULL,NULL);
421:   DSGetArray(nep->ds,DS_MAT_X,&pX);

423:   for (i=0;i<nv;i++) {
424:     s1 = 0;
425:     s2 = 0;
426:     for (j=0;j<nv;j++) {
427:       s1 += PetscAbsScalar(PetscPowScalar(pX[i*ld+j],2));
428:       s2 += PetscPowReal(PetscAbsScalar(pX[i*ld+j]),2)/ctx->sigma[j];
429:     }
430:     tau[i] = s1/s2;
431:     tau_max = PetscMax(tau_max,tau[i]);
432:   }
433:   DSRestoreArray(nep->ds,DS_MAT_X,&pX);
434:   for (i=0;i<nv;i++) {
435:     tau[i] /= tau_max;
436:   }
437:   for (i=0;i<nv;i++) {
438:     if (tau[i]>=ctx->spurious_threshold) fl[i] = PETSC_TRUE;
439:     else fl[i] = PETSC_FALSE;
440:   }
441:   PetscFree(tau);
442:   return(0);
443: }

447: PetscErrorCode NEPSetUp_CISS(NEP nep)
448: {
450:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
451:   PetscInt       i,nwork;
452:   PetscBool      istrivial,isellipse,flg;
453:   PetscScalar    center;

456:   if (!nep->ncv) nep->ncv = ctx->L_max*ctx->M;
457:   else {
458:     ctx->L_max = nep->ncv/ctx->M;
459:     if (ctx->L_max == 0) {
460:       ctx->L_max = 1;
461:       nep->ncv = ctx->L_max*ctx->M;
462:     }
463:     if (ctx->L > ctx->L_max) ctx->L = ctx->L_max;
464:   }
465:   if (!nep->max_it) nep->max_it = 1;
466:   if (!nep->mpd) nep->mpd = nep->ncv;
467:   if (!nep->which) nep->which = NEP_ALL;
468:   if (nep->stopping!=NEPStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support user-defined stopping test");

470:   /* check region */
471:   RGIsTrivial(nep->rg,&istrivial);
472:   if (istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"CISS requires a nontrivial region, e.g. -rg_type ellipse ...");
473:   RGGetComplement(nep->rg,&flg);
474:   if (flg) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"A region with complement flag set is not allowed");
475:   PetscObjectTypeCompare((PetscObject)nep->rg,RGELLIPSE,&isellipse);
476:   if (!isellipse) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Currently only implemented for elliptic or arc regions");
477:   RGEllipseGetParameters(nep->rg,&center,NULL,NULL);
478:   if (ctx->isreal && PetscImaginaryPart(center) == 0.0) ctx->useconj = PETSC_TRUE;
479:   else ctx->useconj = PETSC_FALSE;

481:   /* create split comm */
482:   ctx->num_subcomm = 1;
483:   SetSolverComm(nep);

485:   NEPAllocateSolution(nep,0);
486:   PetscMalloc4(ctx->N,&ctx->weight,ctx->N,&ctx->omega,ctx->N,&ctx->pp,ctx->L_max*ctx->M,&ctx->sigma);
487:   PetscLogObjectMemory((PetscObject)nep,3*ctx->N*sizeof(PetscScalar)+ctx->L_max*ctx->N*sizeof(PetscReal));

489:   /* allocate basis vectors */
490:   BVDuplicateResize(nep->V,ctx->L_max*ctx->M,&ctx->S);
491:   PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->S);
492:   BVDuplicateResize(nep->V,ctx->L_max,&ctx->V);
493:   PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->V);

495:   if (!ctx->usest) {
496:     PetscMalloc2(ctx->num_solve_point,&ctx->ksp,ctx->num_solve_point,&ctx->kspMat);
497:     PetscLogObjectMemory((PetscObject)nep,ctx->num_solve_point*sizeof(KSP)+ctx->num_solve_point*sizeof(Mat));
498:     for (i=0;i<ctx->num_solve_point;i++) {
499:       KSPCreate(PetscSubcommChild(ctx->subcomm),&ctx->ksp[i]);
500:       PetscObjectIncrementTabLevel((PetscObject)ctx->ksp[i],(PetscObject)nep,1);
501:       PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp[i]);
502:       KSPSetOptionsPrefix(ctx->ksp[i],((PetscObject)nep)->prefix);
503:       KSPAppendOptionsPrefix(ctx->ksp[i],"nep_ciss_");
504:       KSPSetErrorIfNotConverged(ctx->ksp[i],PETSC_TRUE);
505:     }
506:   }

508:   BVDuplicateResize(nep->V,ctx->num_solve_point*ctx->L_max,&ctx->Y);

510:   DSSetType(nep->ds,DSGNHEP);
511:   DSAllocate(nep->ds,nep->ncv);
512:   nwork = (nep->fui==NEP_USER_INTERFACE_SPLIT)? 2: 1;
513:   NEPSetWorkVecs(nep,nwork);
514:   return(0);
515: }

519: PetscErrorCode NEPSolve_CISS(NEP nep)
520: {
522:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
523:   Mat            X,M;
524:   PetscInt       i,j,ld,L_add=0,nv=0,L_base=ctx->L,inner,*inside;
525:   PetscScalar    *Mu,*H0,*H1,*rr,*temp,center;
526:   PetscReal      error,max_error,radius,rgscale;
527:   PetscBool      *fl1;
528:   Vec            si;
529:   SlepcSC        sc;
530:   PetscRandom    rand;

533:   DSGetSlepcSC(nep->ds,&sc);
534:   sc->comparison    = SlepcCompareLargestMagnitude;
535:   sc->comparisonctx = NULL;
536:   sc->map           = NULL;
537:   sc->mapobj        = NULL;
538:   DSGetLeadingDimension(nep->ds,&ld);
539:   SetPathParameter(nep);
540:   CISSVecSetRandom(ctx->V,0,ctx->L);
541:   BVGetRandomContext(ctx->V,&rand);

543:   SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,0,ctx->L,PETSC_TRUE);
544:   EstimateNumberEigs(nep,&L_add);
545:   if (L_add>0) {
546:     PetscInfo2(nep,"Changing L %D -> %D by Estimate #Eig\n",ctx->L,ctx->L+L_add);
547:     CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);
548:     SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);
549:     ctx->L += L_add;
550:   }
551:   PetscMalloc2(ctx->L*ctx->L*ctx->M*2,&Mu,ctx->L*ctx->M*ctx->L*ctx->M,&H0);
552:   for (i=0;i<ctx->refine_blocksize;i++) {
553:     CalcMu(nep,Mu);
554:     BlockHankel(nep,Mu,0,H0);
555:     SVD_H0(nep,H0,&nv);
556:     if (ctx->sigma[0]<=ctx->delta || nv < ctx->L*ctx->M || ctx->L == ctx->L_max) break;
557:     L_add = L_base;
558:     if (ctx->L+L_add>ctx->L_max) L_add = ctx->L_max-ctx->L;
559:     PetscInfo2(nep,"Changing L %D -> %D by SVD(H0)\n",ctx->L,ctx->L+L_add);
560:     CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);
561:     SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);
562:     ctx->L += L_add;
563:   }
564:   PetscFree2(Mu,H0);

566:   RGGetScale(nep->rg,&rgscale);
567:   RGEllipseGetParameters(nep->rg,&center,&radius,NULL);

569:   PetscMalloc3(ctx->L*ctx->L*ctx->M*2,&Mu,ctx->L*ctx->M*ctx->L*ctx->M,&H0,ctx->L*ctx->M*ctx->L*ctx->M,&H1);
570:   while (nep->reason == NEP_CONVERGED_ITERATING) {
571:     nep->its++;
572:     for (inner=0;inner<=ctx->refine_inner;inner++) {
573:       CalcMu(nep,Mu);
574:       BlockHankel(nep,Mu,0,H0);
575:       SVD_H0(nep,H0,&nv);
576:       if (ctx->sigma[0]>ctx->delta && nv==ctx->L*ctx->M && inner!=ctx->refine_inner) {
577:         ConstructS(nep);
578:         BVSetActiveColumns(ctx->S,0,ctx->L);
579:         BVCopy(ctx->S,ctx->V);
580:         SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,0,ctx->L,PETSC_FALSE);
581:       } else break;
582:     }

584:     nep->nconv = 0;
585:     if (nv == 0) break;
586:     BlockHankel(nep,Mu,0,H0);
587:     BlockHankel(nep,Mu,1,H1);
588:     DSSetDimensions(nep->ds,nv,0,0,0);
589:     DSSetState(nep->ds,DS_STATE_RAW);
590:     DSGetArray(nep->ds,DS_MAT_A,&temp);
591:     for (j=0;j<nv;j++)
592:       for (i=0;i<nv;i++)
593:         temp[i+j*ld] = H1[i+j*ctx->L*ctx->M];
594:     DSRestoreArray(nep->ds,DS_MAT_A,&temp);
595:     DSGetArray(nep->ds,DS_MAT_B,&temp);
596:     for (j=0;j<nv;j++) 
597:       for (i=0;i<nv;i++)
598:         temp[i+j*ld] = H0[i+j*ctx->L*ctx->M];
599:     DSRestoreArray(nep->ds,DS_MAT_B,&temp);
600:     DSSolve(nep->ds,nep->eigr,nep->eigi);
601:     DSVectors(nep->ds,DS_MAT_X,NULL,NULL);
602:     for (i=0;i<nv;i++){
603:       nep->eigr[i] = (nep->eigr[i]*radius+center)*rgscale;
604: #if !defined(PETSC_USE_COMPLEX)
605:       nep->eigi[i] = nep->eigi[i]*radius*rgscale;
606: #endif
607:     }
608:     PetscMalloc3(nv,&fl1,nv,&inside,nv,&rr);
609:     isGhost(nep,ld,nv,fl1);
610:     RGCheckInside(nep->rg,nv,nep->eigr,nep->eigi,inside);
611:     for (i=0;i<nv;i++) {
612:       if (fl1[i] && inside[i]>0) {
613:         rr[i] = 1.0;
614:         nep->nconv++;
615:       } else rr[i] = 0.0;
616:     }
617:     DSSort(nep->ds,nep->eigr,nep->eigi,rr,NULL,&nep->nconv);
618:     for (i=0;i<nv;i++){
619:       nep->eigr[i] = (nep->eigr[i]*radius+center)*rgscale;
620: #if !defined(PETSC_USE_COMPLEX)
621:       nep->eigi[i] = nep->eigi[i]*radius*rgscale;
622: #endif
623:     }
624:     PetscFree3(fl1,inside,rr);
625:     BVSetActiveColumns(nep->V,0,nv);
626:     ConstructS(nep);
627:     BVSetActiveColumns(ctx->S,0,nv);
628:     BVCopy(ctx->S,nep->V);

630:     DSVectors(nep->ds,DS_MAT_X,NULL,NULL);
631:     DSGetMat(nep->ds,DS_MAT_X,&X);
632:     BVMultInPlace(ctx->S,X,0,nep->nconv);
633:     BVMultInPlace(nep->V,X,0,nep->nconv);
634:     MatDestroy(&X);
635:     max_error = 0.0;
636:     for (i=0;i<nep->nconv;i++) {
637:       BVGetColumn(nep->V,i,&si);
638:       VecNormalize(si,NULL);
639:       NEPComputeResidualNorm_Private(nep,nep->eigr[i],si,nep->work,&error);
640:       (*nep->converged)(nep,nep->eigr[i],0,error,&error,nep->convergedctx);
641:       BVRestoreColumn(nep->V,i,&si);
642:       max_error = PetscMax(max_error,error);
643:     }
644:     if (max_error <= nep->tol) nep->reason = NEP_CONVERGED_TOL;
645:     else if (nep->its > nep->max_it) nep->reason = NEP_DIVERGED_ITS;
646:     else {
647:       if (nep->nconv > ctx->L) nv = nep->nconv;
648:       else if (ctx->L > nv) nv = ctx->L;
649:       MatCreateSeqDense(PETSC_COMM_SELF,nv,ctx->L,NULL,&M);
650:       MatDenseGetArray(M,&temp);
651:       for (i=0;i<ctx->L*nv;i++) {
652:         PetscRandomGetValue(rand,&temp[i]);
653:         temp[i] = PetscRealPart(temp[i]);
654:       }
655:       MatDenseRestoreArray(M,&temp);
656:       BVSetActiveColumns(ctx->S,0,nv);
657:       BVMultInPlace(ctx->S,M,0,ctx->L);
658:       MatDestroy(&M);
659:       BVSetActiveColumns(ctx->S,0,ctx->L);
660:       BVCopy(ctx->S,ctx->V);
661:       SolveLinearSystem(nep,nep->function,nep->jacobian,ctx->V,0,ctx->L,PETSC_FALSE);
662:     }
663:   }
664:   PetscFree3(Mu,H0,H1);  
665:   return(0);
666: }

670: static PetscErrorCode NEPCISSSetSizes_CISS(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)
671: {
672:   NEP_CISS *ctx = (NEP_CISS*)nep->data;

675:   if (ip == PETSC_DECIDE || ip == PETSC_DEFAULT) {
676:     if (ctx->N!=32) { ctx->N =32; ctx->M = ctx->N/4; }
677:   } else {
678:     if (ip<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be > 0");
679:     if (ip%2) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be an even number");
680:     if (ctx->N!=ip) { ctx->N = ip; ctx->M = ctx->N/4; }
681:   }
682:   if (bs == PETSC_DECIDE || bs == PETSC_DEFAULT) {
683:     ctx->L = 16;
684:   } else {
685:     if (bs<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be > 0");
686:     if (bs>ctx->L_max) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be less than or equal to the maximum number of block size");
687:     ctx->L = bs;
688:   }
689:   if (ms == PETSC_DECIDE || ms == PETSC_DEFAULT) {
690:     ctx->M = ctx->N/4;
691:   } else {
692:     if (ms<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be > 0");
693:     if (ms>ctx->N) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be less than or equal to the number of integration points");
694:     ctx->M = ms;
695:   }
696:   if (npart == PETSC_DECIDE || npart == PETSC_DEFAULT) {
697:     ctx->num_subcomm = 1;
698:   } else {
699:     if (npart<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The npart argument must be > 0");
700:     ctx->num_subcomm = npart;
701:   }
702:   if (bsmax == PETSC_DECIDE || bsmax == PETSC_DEFAULT) {
703:     ctx->L = 256;
704:   } else {
705:     if (bsmax<1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The bsmax argument must be > 0");
706:     if (bsmax<ctx->L) ctx->L_max = ctx->L;
707:     else ctx->L_max = bsmax;
708:   }
709:   ctx->isreal = realmats;
710:   return(0);
711: }

715: /*@
716:    NEPCISSSetSizes - Sets the values of various size parameters in the CISS solver.

718:    Logically Collective on NEP

720:    Input Parameters:
721: +  nep   - the eigenproblem solver context
722: .  ip    - number of integration points
723: .  bs    - block size
724: .  ms    - moment size
725: .  npart - number of partitions when splitting the communicator
726: .  bsmax - max block size
727: -  realmats - T(z) is real for real z

729:    Options Database Keys:
730: +  -nep_ciss_integration_points - Sets the number of integration points
731: .  -nep_ciss_blocksize - Sets the block size
732: .  -nep_ciss_moments - Sets the moment size
733: .  -nep_ciss_partitions - Sets the number of partitions
734: .  -nep_ciss_maxblocksize - Sets the maximum block size
735: -  -nep_ciss_realmats - T(z) is real for real z

737:    Note:
738:    The default number of partitions is 1. This means the internal KSP object is shared
739:    among all processes of the NEP communicator. Otherwise, the communicator is split
740:    into npart communicators, so that npart KSP solves proceed simultaneously.

742:    The realmats flag can be set to true when T(.) is guaranteed to be real
743:    when the argument is a real value, for example, when all matrices in
744:    the split form are real. When set to true, the solver avoids some computations.

746:    Level: advanced

748: .seealso: NEPCISSGetSizes()
749: @*/
750: PetscErrorCode NEPCISSSetSizes(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)
751: {

762:   PetscTryMethod(nep,"NEPCISSSetSizes_C",(NEP,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool),(nep,ip,bs,ms,npart,bsmax,realmats));
763:   return(0);
764: }

768: static PetscErrorCode NEPCISSGetSizes_CISS(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)
769: {
770:   NEP_CISS *ctx = (NEP_CISS*)nep->data;

773:   if (ip) *ip = ctx->N;
774:   if (bs) *bs = ctx->L;
775:   if (ms) *ms = ctx->M;
776:   if (npart) *npart = ctx->num_subcomm;
777:   if (bsmax) *bsmax = ctx->L_max;
778:   if (realmats) *realmats = ctx->isreal;
779:   return(0);
780: }

784: /*@
785:    NEPCISSGetSizes - Gets the values of various size parameters in the CISS solver.

787:    Not Collective

789:    Input Parameter:
790: .  nep - the eigenproblem solver context

792:    Output Parameters:
793: +  ip    - number of integration points
794: .  bs    - block size
795: .  ms    - moment size
796: .  npart - number of partitions when splitting the communicator
797: .  bsmax - max block size
798: -  realmats - T(z) is real for real z

800:    Level: advanced

802: .seealso: NEPCISSSetSizes()
803: @*/
804: PetscErrorCode NEPCISSGetSizes(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)
805: {

810:   PetscUseMethod(nep,"NEPCISSGetSizes_C",(NEP,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*),(nep,ip,bs,ms,npart,bsmax,realmats));
811:   return(0);
812: }

816: static PetscErrorCode NEPCISSSetThreshold_CISS(NEP nep,PetscReal delta,PetscReal spur)
817: {
818:   NEP_CISS *ctx = (NEP_CISS*)nep->data;

821:   if (delta == PETSC_DEFAULT) {
822:     ctx->delta = 1e-12;
823:   } else {
824:     if (delta<=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The delta argument must be > 0.0");
825:     ctx->delta = delta;
826:   }
827:   if (spur == PETSC_DEFAULT) {
828:     ctx->spurious_threshold = 1e-4;
829:   } else {
830:     if (spur<=0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The spurious threshold argument must be > 0.0");
831:     ctx->spurious_threshold = spur;
832:   }
833:   return(0);
834: }

838: /*@
839:    NEPCISSSetThreshold - Sets the values of various threshold parameters in
840:    the CISS solver.

842:    Logically Collective on NEP

844:    Input Parameters:
845: +  nep   - the eigenproblem solver context
846: .  delta - threshold for numerical rank
847: -  spur  - spurious threshold (to discard spurious eigenpairs)

849:    Options Database Keys:
850: +  -nep_ciss_delta - Sets the delta
851: -  -nep_ciss_spurious_threshold - Sets the spurious threshold

853:    Level: advanced

855: .seealso: NEPCISSGetThreshold()
856: @*/
857: PetscErrorCode NEPCISSSetThreshold(NEP nep,PetscReal delta,PetscReal spur)
858: {

865:   PetscTryMethod(nep,"NEPCISSSetThreshold_C",(NEP,PetscReal,PetscReal),(nep,delta,spur));
866:   return(0);
867: }

871: static PetscErrorCode NEPCISSGetThreshold_CISS(NEP nep,PetscReal *delta,PetscReal *spur)
872: {
873:   NEP_CISS *ctx = (NEP_CISS*)nep->data;

876:   if (delta) *delta = ctx->delta;
877:   if (spur)  *spur = ctx->spurious_threshold;
878:   return(0);
879: }

883: /*@
884:    NEPCISSGetThreshold - Gets the values of various threshold parameters in
885:    the CISS solver.

887:    Not Collective

889:    Input Parameter:
890: .  nep - the eigenproblem solver context

892:    Output Parameters:
893: +  delta - threshold for numerical rank
894: -  spur  - spurious threshold (to discard spurious eigenpairs)

896:    Level: advanced

898: .seealso: NEPCISSSetThreshold()
899: @*/
900: PetscErrorCode NEPCISSGetThreshold(NEP nep,PetscReal *delta,PetscReal *spur)
901: {

906:   PetscUseMethod(nep,"NEPCISSGetThreshold_C",(NEP,PetscReal*,PetscReal*),(nep,delta,spur));
907:   return(0);
908: }

912: static PetscErrorCode NEPCISSSetRefinement_CISS(NEP nep,PetscInt inner,PetscInt blsize)
913: {
914:   NEP_CISS *ctx = (NEP_CISS*)nep->data;

917:   if (inner == PETSC_DEFAULT) {
918:     ctx->refine_inner = 0;
919:   } else {
920:     if (inner<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The refine inner argument must be >= 0");
921:     ctx->refine_inner = inner;
922:   }
923:   if (blsize == PETSC_DEFAULT) {
924:     ctx->refine_blocksize = 0;
925:   } else {
926:     if (blsize<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The refine blocksize argument must be >= 0");
927:     ctx->refine_blocksize = blsize;
928:   }
929:   return(0);
930: }

934: /*@
935:    NEPCISSSetRefinement - Sets the values of various refinement parameters
936:    in the CISS solver.

938:    Logically Collective on NEP

940:    Input Parameters:
941: +  nep    - the eigenproblem solver context
942: .  inner  - number of iterative refinement iterations (inner loop)
943: -  blsize - number of iterative refinement iterations (blocksize loop)

945:    Options Database Keys:
946: +  -nep_ciss_refine_inner - Sets number of inner iterations
947: -  -nep_ciss_refine_blocksize - Sets number of blocksize iterations

949:    Level: advanced

951: .seealso: NEPCISSGetRefinement()
952: @*/
953: PetscErrorCode NEPCISSSetRefinement(NEP nep,PetscInt inner,PetscInt blsize)
954: {

961:   PetscTryMethod(nep,"NEPCISSSetRefinement_C",(NEP,PetscInt,PetscInt),(nep,inner,blsize));
962:   return(0);
963: }

967: static PetscErrorCode NEPCISSGetRefinement_CISS(NEP nep,PetscInt *inner,PetscInt *blsize)
968: {
969:   NEP_CISS *ctx = (NEP_CISS*)nep->data;

972:   if (inner)  *inner = ctx->refine_inner;
973:   if (blsize) *blsize = ctx->refine_blocksize;
974:   return(0);
975: }

979: /*@
980:    NEPCISSGetRefinement - Gets the values of various refinement parameters
981:    in the CISS solver.

983:    Not Collective

985:    Input Parameter:
986: .  nep - the eigenproblem solver context

988:    Output Parameters:
989: +  inner  - number of iterative refinement iterations (inner loop)
990: -  blsize - number of iterative refinement iterations (blocksize loop)

992:    Level: advanced

994: .seealso: NEPCISSSetRefinement()
995: @*/
996: PetscErrorCode NEPCISSGetRefinement(NEP nep, PetscInt *inner, PetscInt *blsize)
997: {

1002:   PetscUseMethod(nep,"NEPCISSGetRefinement_C",(NEP,PetscInt*,PetscInt*),(nep,inner,blsize));
1003:   return(0);
1004: }

1008: PetscErrorCode NEPReset_CISS(NEP nep)
1009: {
1011:   PetscInt       i;
1012:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;

1015:   PetscSubcommDestroy(&ctx->subcomm);
1016:   PetscFree4(ctx->weight,ctx->omega,ctx->pp,ctx->sigma);
1017:   BVDestroy(&ctx->S);
1018:   BVDestroy(&ctx->V);
1019:   BVDestroy(&ctx->Y);
1020:   if (!ctx->usest) {
1021:     for (i=0;i<ctx->num_solve_point;i++) {
1022:       KSPDestroy(&ctx->ksp[i]);
1023:     }
1024:     for (i=0;i<ctx->num_solve_point;i++) {
1025:       MatDestroy(&ctx->kspMat[i]);
1026:     }
1027:     PetscFree2(ctx->ksp,ctx->kspMat);
1028:   }
1029:   return(0);
1030: }

1034: PetscErrorCode NEPSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,NEP nep)
1035: {
1037:   PetscReal      r1,r2;
1038:   PetscInt       i1,i2,i3,i4,i5,i6,i7;
1039:   PetscBool      b1;

1042:   PetscOptionsHead(PetscOptionsObject,"NEP CISS Options");

1044:   NEPCISSGetSizes(nep,&i1,&i2,&i3,&i4,&i5,&b1);
1045:   PetscOptionsInt("-nep_ciss_integration_points","CISS number of integration points","NEPCISSSetSizes",i1,&i1,NULL);
1046:   PetscOptionsInt("-nep_ciss_blocksize","CISS block size","NEPCISSSetSizes",i2,&i2,NULL);
1047:   PetscOptionsInt("-nep_ciss_moments","CISS moment size","NEPCISSSetSizes",i3,&i3,NULL);
1048:   PetscOptionsInt("-nep_ciss_partitions","CISS number of partitions","NEPCISSSetSizes",i4,&i4,NULL);
1049:   PetscOptionsInt("-nep_ciss_maxblocksize","CISS maximum block size","NEPCISSSetSizes",i5,&i5,NULL);
1050:   PetscOptionsBool("-nep_ciss_realmats","CISS flag indicating that T(z) is real for real z","NEPCISSSetSizes",b1,&b1,NULL);
1051:   NEPCISSSetSizes(nep,i1,i2,i3,i4,i5,b1);

1053:   NEPCISSGetThreshold(nep,&r1,&r2);
1054:   PetscOptionsReal("-nep_ciss_delta","CISS threshold for numerical rank","NEPCISSSetThreshold",r1,&r1,NULL);
1055:   PetscOptionsReal("-nep_ciss_spurious_threshold","CISS threshold for the spurious eigenpairs","NEPCISSSetThreshold",r2,&r2,NULL);
1056:   NEPCISSSetThreshold(nep,r1,r2);

1058:   NEPCISSGetRefinement(nep,&i6,&i7);
1059:   PetscOptionsInt("-nep_ciss_refine_inner","CISS number of inner iterative refinement iterations","NEPCISSSetRefinement",i6,&i6,NULL);
1060:   PetscOptionsInt("-nep_ciss_refine_blocksize","CISS number of blocksize iterative refinement iterations","NEPCISSSetRefinement",i7,&i7,NULL);
1061:   NEPCISSSetRefinement(nep,i6,i7);

1063:   PetscOptionsTail();
1064:   return(0);
1065: }

1069: PetscErrorCode NEPDestroy_CISS(NEP nep)
1070: {

1074:   PetscFree(nep->data);
1075:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetSizes_C",NULL);
1076:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetSizes_C",NULL);
1077:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetThreshold_C",NULL);
1078:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetThreshold_C",NULL);
1079:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetRefinement_C",NULL);
1080:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetRefinement_C",NULL);
1081:   return(0);
1082: }

1086: PetscErrorCode NEPView_CISS(NEP nep,PetscViewer viewer)
1087: {
1089:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;
1090:   PetscBool      isascii;

1093:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
1094:   if (isascii) {
1095:     PetscViewerASCIIPrintf(viewer,"  CISS: sizes { integration points: %D, block size: %D, moment size: %D, partitions: %D, maximum block size: %D }\n",ctx->N,ctx->L,ctx->M,ctx->num_subcomm,ctx->L_max);
1096:     if (ctx->isreal) {
1097:       PetscViewerASCIIPrintf(viewer,"  CISS: exploiting symmetry of integration points\n");
1098:     }
1099:     PetscViewerASCIIPrintf(viewer,"  CISS: threshold { delta: %g, spurious threshold: %g }\n",(double)ctx->delta,(double)ctx->spurious_threshold);
1100:     PetscViewerASCIIPrintf(viewer,"  CISS: iterative refinement  { inner: %D, blocksize: %D }\n",ctx->refine_inner, ctx->refine_blocksize);
1101:     PetscViewerASCIIPushTab(viewer);
1102:     if (!ctx->usest && ctx->ksp[0]) { KSPView(ctx->ksp[0],viewer); }
1103:     PetscViewerASCIIPopTab(viewer);
1104:   }
1105:   return(0);
1106: }

1110: PETSC_EXTERN PetscErrorCode NEPCreate_CISS(NEP nep)
1111: {
1113:   NEP_CISS       *ctx = (NEP_CISS*)nep->data;

1116:   PetscNewLog(nep,&ctx);
1117:   nep->data = ctx;
1118:   nep->ops->solve          = NEPSolve_CISS;
1119:   nep->ops->setup          = NEPSetUp_CISS;
1120:   nep->ops->setfromoptions = NEPSetFromOptions_CISS;
1121:   nep->ops->reset          = NEPReset_CISS;
1122:   nep->ops->destroy        = NEPDestroy_CISS;
1123:   nep->ops->view           = NEPView_CISS;
1124:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetSizes_C",NEPCISSSetSizes_CISS);
1125:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetSizes_C",NEPCISSGetSizes_CISS);
1126:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetThreshold_C",NEPCISSSetThreshold_CISS);
1127:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetThreshold_C",NEPCISSGetThreshold_CISS);
1128:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSSetRefinement_C",NEPCISSSetRefinement_CISS);
1129:   PetscObjectComposeFunction((PetscObject)nep,"NEPCISSGetRefinement_C",NEPCISSGetRefinement_CISS);
1130:   /* set default values of parameters */
1131:   ctx->N       = 32;
1132:   ctx->L       = 16;
1133:   ctx->M       = ctx->N/4;
1134:   ctx->delta   = 1e-12;
1135:   ctx->L_max   = 64;
1136:   ctx->spurious_threshold = 1e-4;
1137:   ctx->usest   = PETSC_FALSE;
1138:   ctx->isreal  = PETSC_FALSE;
1139:   ctx->refine_inner = 0;
1140:   ctx->refine_blocksize = 0;
1141:   ctx->num_subcomm = 1;
1142:   return(0);
1143: }

slepc-3.7.4/src/nep/impls/ciss/makefile.html0000644000175000017500000000474113107004621020272 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresscalar    complex

CFLAGS   =
FFLAGS   =
SOURCEC  = nciss.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcnep
DIRS     =
MANSEC   = NEP
LOCDIR   = src/nep/impls/ciss/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/nep/impls/ciss/index.html0000644000175000017500000000304513107004621017620 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

nciss.c
makefile
slepc-3.7.4/src/nep/impls/ciss/ftn-auto/0000755000175000017500000000000013107004621017356 5ustar jromanjromanslepc-3.7.4/src/nep/impls/ciss/ftn-auto/makefile0000644000175000017500000000035613107004621021062 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = ncissf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcnep LOCDIR = src/nep/impls/ciss/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/ciss/ftn-auto/ncissf.c0000644000175000017500000000633713107004621021020 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nciss.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcisssetsizes_ NEPCISSSETSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcisssetsizes_ nepcisssetsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcissgetsizes_ NEPCISSGETSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcissgetsizes_ nepcissgetsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcisssetthreshold_ NEPCISSSETTHRESHOLD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcisssetthreshold_ nepcisssetthreshold #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcissgetthreshold_ NEPCISSGETTHRESHOLD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcissgetthreshold_ nepcissgetthreshold #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcisssetrefinement_ NEPCISSSETREFINEMENT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcisssetrefinement_ nepcisssetrefinement #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepcissgetrefinement_ NEPCISSGETREFINEMENT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepcissgetrefinement_ nepcissgetrefinement #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepcisssetsizes_(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats, int *__ierr ){ *__ierr = NEPCISSSetSizes( (NEP)PetscToPointer((nep) ),*ip,*bs,*ms,*npart,*bsmax,*realmats); } PETSC_EXTERN void PETSC_STDCALL nepcissgetsizes_(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats, int *__ierr ){ *__ierr = NEPCISSGetSizes( (NEP)PetscToPointer((nep) ),ip,bs,ms,npart,bsmax,realmats); } PETSC_EXTERN void PETSC_STDCALL nepcisssetthreshold_(NEP nep,PetscReal *delta,PetscReal *spur, int *__ierr ){ *__ierr = NEPCISSSetThreshold( (NEP)PetscToPointer((nep) ),*delta,*spur); } PETSC_EXTERN void PETSC_STDCALL nepcissgetthreshold_(NEP nep,PetscReal *delta,PetscReal *spur, int *__ierr ){ *__ierr = NEPCISSGetThreshold( (NEP)PetscToPointer((nep) ),delta,spur); } PETSC_EXTERN void PETSC_STDCALL nepcisssetrefinement_(NEP nep,PetscInt *inner,PetscInt *blsize, int *__ierr ){ *__ierr = NEPCISSSetRefinement( (NEP)PetscToPointer((nep) ),*inner,*blsize); } PETSC_EXTERN void PETSC_STDCALL nepcissgetrefinement_(NEP nep,PetscInt *inner,PetscInt *blsize, int *__ierr ){ *__ierr = NEPCISSGetRefinement( (NEP)PetscToPointer((nep) ),inner,blsize); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/impls/nleigs/0000755000175000017500000000000013107004621016141 5ustar jromanjromanslepc-3.7.4/src/nep/impls/nleigs/makefile0000644000175000017500000000216413107004621017644 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2013, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = nleigs.c SOURCEF = SOURCEH = LIBBASE = libslepc DIRS = MANSEC = NEP LOCDIR = src/nep/impls/nleigs/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/nleigs/makefile.html0000644000175000017500000000466613107004621020620 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2013, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#     
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = nleigs.c
SOURCEF  = 
SOURCEH  =
LIBBASE  = libslepc
DIRS     =
MANSEC   = NEP
LOCDIR   = src/nep/impls/nleigs/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/impls/nleigs/nleigs.c.html0000644000175000017500000044660413107004621020547 0ustar jromanjroman
Actual source code: nleigs.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc nonlinear eigensolver: "nleigs"

  5:    Method: NLEIGS

  7:    Algorithm:

  9:        Fully rational Krylov method for nonlinear eigenvalue problems.

 11:    References:

 13:        [1] S. Guttel et al., "NLEIGS: A class of robust fully rational Krylov
 14:            method for nonlinear eigenvalue problems", SIAM J. Sci. Comput.
 15:            36(6):A2842-A2864, 2014.

 17:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 19:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 21:    This file is part of SLEPc.

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

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

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

 37: #include <slepc/private/nepimpl.h>         /*I "slepcnep.h" I*/
 38: #include <slepcblaslapack.h>

 40: #define  MAX_LBPOINTS  100
 41: #define  NDPOINTS      1e4
 42: #define  MAX_NSHIFTS   100

 44: typedef struct {
 45:   PetscInt       nmat;      /* number of interpolation points */
 46:   PetscScalar    *s,*xi;    /* Leja-Bagby points */
 47:   PetscScalar    *beta;     /* scaling factors */
 48:   Mat            *D;        /* divided difference matrices */
 49:   PetscScalar    *coeffD;   /* coefficients for divided differences in split form */
 50:   PetscInt       nshifts;   /* provided number of shifts */
 51:   PetscScalar    *shifts;   /* user-provided shifts for the Rational Krylov variant */
 52:   PetscInt       nshiftsw;  /* actual number of shifts (1 if Krylov-Schur) */
 53:   PetscReal      ddtol;     /* tolerance for divided difference convergence */
 54:   PetscInt       ddmaxit;   /* maximum number of divided difference terms */
 55:   BV             W;         /* auxiliary BV object */
 56:   PetscReal      keep;      /* restart parameter */
 57:   PetscBool      lock;      /* locking/non-locking variant */
 58:   PetscBool      trueres;   /* whether the true residual norm must be computed */
 59:   PetscInt       idxrk;     /* index of next shift to use */
 60:   KSP            *ksp;      /* ksp array for storing shift factorizations */
 61:   Vec            vrn;       /* random vector with normally distributed value */
 62:   void           *singularitiesctx;
 63:   PetscErrorCode (*computesingularities)(NEP,PetscInt*,PetscScalar*,void*);
 64: } NEP_NLEIGS;

 66: typedef struct {
 67:   PetscInt    nmat;
 68:   PetscScalar coeff[MAX_NSHIFTS];
 69:   Mat         A[MAX_NSHIFTS];
 70:   Vec         t;
 71: } ShellMatCtx;

 75: PETSC_STATIC_INLINE PetscErrorCode NEPNLEIGSSetShifts(NEP nep)
 76: {
 77:   NEP_NLEIGS *ctx = (NEP_NLEIGS*)nep->data;

 80:   if (!ctx->nshifts) { 
 81:     ctx->shifts = &nep->target;
 82:     ctx->nshiftsw = 1;
 83:   } else ctx->nshiftsw = ctx->nshifts;
 84:   return(0);
 85: }

 89: static PetscErrorCode NEPNLEIGSBackTransform(PetscObject ob,PetscInt n,PetscScalar *valr,PetscScalar *vali)
 90: {
 91:   NEP         nep;
 92:   PetscInt    j;
 93: #if !defined(PETSC_USE_COMPLEX)
 94:   PetscScalar t;
 95: #endif

 98:   nep = (NEP)ob;
 99: #if !defined(PETSC_USE_COMPLEX)
100:   for (j=0;j<n;j++) {
101:     if (vali[j] == 0) valr[j] = 1.0 / valr[j] + nep->target;
102:     else {
103:       t = valr[j] * valr[j] + vali[j] * vali[j];
104:       valr[j] = valr[j] / t + nep->target;
105:       vali[j] = - vali[j] / t;
106:     }
107:   }
108: #else
109:   for (j=0;j<n;j++) {
110:     valr[j] = 1.0 / valr[j] + nep->target;
111:   }
112: #endif
113:   return(0);
114: }

118: static PetscErrorCode NEPNLEIGSLejaBagbyPoints(NEP nep)
119: {
121:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
122:   PetscInt       i,k,ndpt=NDPOINTS,ndptx=NDPOINTS;
123:   PetscScalar    *ds,*dsi,*dxi,*nrs,*nrxi,*s=ctx->s,*xi=ctx->xi,*beta=ctx->beta;
124:   PetscReal      maxnrs,minnrxi;

127:   PetscMalloc5(ndpt+1,&ds,ndpt+1,&dsi,ndpt,&dxi,ndpt+1,&nrs,ndpt,&nrxi);

129:   /* Discretize the target region boundary */
130:   RGComputeContour(nep->rg,ndpt,ds,dsi);
131: #if !defined(PETSC_USE_COMPLEX)
132:   for (i=0;i<ndpt;i++) if (dsi[i]!=0.0) break;
133:   if (i<ndpt) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NLEIGS with real arithmetic requires the target set to be included in the real axis");
134: #endif
135:   /* Discretize the singularity region */
136:   if (ctx->computesingularities) {
137:     (ctx->computesingularities)(nep,&ndptx,dxi,ctx->singularitiesctx);
138:   } else ndptx = 0;

140:   /* Look for Leja-Bagby points in the discretization sets */
141:   s[0]    = ds[0];
142:   xi[0]   = (ndptx>0)?dxi[0]:PETSC_INFINITY;
143:   beta[0] = 1.0; /* scaling factors are also computed here */
144:   maxnrs  = 0.0;
145:   minnrxi = PETSC_MAX_REAL; 
146:   for (i=0;i<ndpt;i++) {
147:     nrs[i] = (ds[i]-s[0])/(1.0-ds[i]/xi[0]);
148:     if (PetscAbsScalar(nrs[i])>=maxnrs) {maxnrs = PetscAbsScalar(nrs[i]); s[1] = ds[i];}
149:   }
150:   for (i=1;i<ndptx;i++) {
151:     nrxi[i] = (dxi[i]-s[0])/(1.0-dxi[i]/xi[0]);
152:     if (PetscAbsScalar(nrxi[i])<=minnrxi) {minnrxi = PetscAbsScalar(nrxi[i]); xi[1] = dxi[i];}
153:   }
154:   if (ndptx<2) xi[1] = PETSC_INFINITY;

156:   beta[1] = maxnrs;
157:   for (k=2;k<ctx->ddmaxit;k++) {
158:     maxnrs = 0.0;
159:     minnrxi = PETSC_MAX_REAL;
160:     for (i=0;i<ndpt;i++) {
161:       nrs[i] *= ((ds[i]-s[k-1])/(1.0-ds[i]/xi[k-1]))/beta[k-1];
162:       if (PetscAbsScalar(nrs[i])>maxnrs) {maxnrs = PetscAbsScalar(nrs[i]); s[k] = ds[i];}
163:     }
164:     if (ndptx>k) {
165:       for (i=1;i<ndptx;i++) {
166:         nrxi[i] *= ((dxi[i]-s[k-1])/(1.0-dxi[i]/xi[k-1]))/beta[k-1];
167:         if (PetscAbsScalar(nrxi[i])<minnrxi) {minnrxi = PetscAbsScalar(nrxi[i]); xi[k] = dxi[i];}
168:       }
169:     } else xi[k] = PETSC_INFINITY;
170:     beta[k] = maxnrs;
171:   }
172:   PetscFree5(ds,dsi,dxi,nrs,nrxi);
173:   return(0);
174: }

178: static PetscErrorCode NEPNLEIGSEvalNRTFunct(NEP nep,PetscInt k,PetscScalar sigma,PetscScalar *b)
179: {
180:   NEP_NLEIGS  *ctx=(NEP_NLEIGS*)nep->data;
181:   PetscInt    i;
182:   PetscScalar *beta=ctx->beta,*s=ctx->s,*xi=ctx->xi;

185:   b[0] = 1.0/beta[0];
186:   for (i=0;i<k;i++) {
187:     b[i+1] = ((sigma-s[i])*b[i])/(beta[i+1]*(1.0-sigma/xi[i]));
188:   }
189:   return(0);
190: }

194: static PetscErrorCode MatMult_Fun(Mat A,Vec x,Vec y)
195: {
197:   ShellMatCtx    *ctx;
198:   PetscInt       i;

201:   MatShellGetContext(A,(void**)&ctx);
202:   MatMult(ctx->A[0],x,y);
203:   if (ctx->coeff[0]!=1.0) { VecScale(y,ctx->coeff[0]); }
204:   for (i=1;i<ctx->nmat;i++) {
205:     MatMult(ctx->A[i],x,ctx->t);
206:     VecAXPY(y,ctx->coeff[i],ctx->t);
207:   }
208:   return(0);
209: }

213: static PetscErrorCode MatMultTranspose_Fun(Mat A,Vec x,Vec y)
214: {
216:   ShellMatCtx    *ctx;
217:   PetscInt       i;

220:   MatShellGetContext(A,(void**)&ctx);
221:   MatMultTranspose(ctx->A[0],x,y);
222:   if (ctx->coeff[0]!=1.0) { VecScale(y,ctx->coeff[0]); }
223:   for (i=1;i<ctx->nmat;i++) {
224:     MatMultTranspose(ctx->A[i],x,ctx->t);
225:     VecAXPY(y,ctx->coeff[i],ctx->t);
226:   }
227:   return(0);
228: }

232: static PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag)
233: {
235:   ShellMatCtx    *ctx;
236:   PetscInt       i;

239:   MatShellGetContext(A,(void**)&ctx);
240:   MatGetDiagonal(ctx->A[0],diag);
241:   if (ctx->coeff[0]!=1.0) { VecScale(diag,ctx->coeff[0]); }
242:   for (i=1;i<ctx->nmat;i++) {
243:     MatGetDiagonal(ctx->A[i],ctx->t);
244:     VecAXPY(diag,ctx->coeff[i],ctx->t);
245:   }
246:   return(0);
247: }

251: static PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B)
252: {
253:   PetscInt       n,i;
254:   ShellMatCtx    *ctxnew,*ctx;
255:   void           (*fun)();

259:   MatShellGetContext(A,(void**)&ctx);
260:   PetscNew(&ctxnew);
261:   ctxnew->nmat = ctx->nmat;
262:   for (i=0;i<ctx->nmat;i++) {
263:     PetscObjectReference((PetscObject)ctx->A[i]);
264:     ctxnew->A[i] = ctx->A[i];
265:     ctxnew->coeff[i] = ctx->coeff[i];
266:   }
267:   MatGetSize(ctx->A[0],&n,NULL);
268:   VecDuplicate(ctx->t,&ctxnew->t);
269:   MatCreateShell(PETSC_COMM_WORLD,n,n,n,n,(void*)ctxnew,B);
270:   MatShellGetOperation(A,MATOP_MULT,&fun);
271:   MatShellSetOperation(*B,MATOP_MULT,fun);
272:   MatShellGetOperation(A,MATOP_MULT_TRANSPOSE,&fun);
273:   MatShellSetOperation(*B,MATOP_MULT_TRANSPOSE,fun);
274:   MatShellGetOperation(A,MATOP_GET_DIAGONAL,&fun);
275:   MatShellSetOperation(*B,MATOP_GET_DIAGONAL,fun);
276:   MatShellGetOperation(A,MATOP_DUPLICATE,&fun);
277:   MatShellSetOperation(*B,MATOP_DUPLICATE,fun);
278:   MatShellGetOperation(A,MATOP_DESTROY,&fun);
279:   MatShellSetOperation(*B,MATOP_DESTROY,fun);
280:   MatShellGetOperation(A,MATOP_AXPY,&fun);
281:   MatShellSetOperation(*B,MATOP_AXPY,fun);
282:   return(0);
283: }

287: static PetscErrorCode MatDestroy_Fun(Mat A)
288: {
289:   ShellMatCtx    *ctx;
291:   PetscInt       i;

294:   if (A) {
295:     MatShellGetContext(A,(void**)&ctx);
296:     for (i=0;i<ctx->nmat;i++) {
297:       MatDestroy(&ctx->A[i]);
298:     }
299:     VecDestroy(&ctx->t);
300:     PetscFree(ctx);
301:   }
302:   return(0);
303: }

307: static PetscErrorCode MatAXPY_Fun(Mat Y,PetscScalar a,Mat X,MatStructure str)
308: {
309:   ShellMatCtx    *ctxY,*ctxX;
311:   PetscInt       i,j;
312:   PetscBool      found;

315:   MatShellGetContext(Y,(void**)&ctxY);
316:   MatShellGetContext(X,(void**)&ctxX);
317:   for (i=0;i<ctxX->nmat;i++) {
318:     found = PETSC_FALSE;
319:     for (j=0;!found&&j<ctxY->nmat;j++) {
320:       if (ctxX->A[i]==ctxY->A[j]) {
321:         found = PETSC_TRUE;
322:         ctxY->coeff[j] += a*ctxX->coeff[i];
323:       }
324:     }
325:     if (!found) {
326:       ctxY->coeff[ctxY->nmat] = a*ctxX->coeff[i];
327:       ctxY->A[ctxY->nmat++] = ctxX->A[i];
328:       PetscObjectReference((PetscObject)ctxX->A[i]);
329:     }
330:   }
331:   return(0);
332: }

336: static PetscErrorCode MatScale_Fun(Mat M,PetscScalar a)
337: {
338:   ShellMatCtx    *ctx;
340:   PetscInt       i;

343:   MatShellGetContext(M,(void**)&ctx);
344:   for (i=0;i<ctx->nmat;i++) ctx->coeff[i] *= a;
345:   return(0);
346: }

350: static PetscErrorCode NLEIGSMatToMatShellArray(Mat M,Mat *Ms)
351: {
353:   ShellMatCtx    *ctx;
354:   PetscInt       n;
355:   PetscBool      has;
356:   
358:   MatHasOperation(M,MATOP_DUPLICATE,&has);
359:   if (!has) SETERRQ(PetscObjectComm((PetscObject)M),1,"MatDuplicate operation required");
360:   PetscNew(&ctx);
361:   MatDuplicate(M,MAT_COPY_VALUES,&ctx->A[0]);
362:   ctx->nmat = 1;
363:   ctx->coeff[0] = 1.0;
364:   MatCreateVecs(M,&ctx->t,NULL);
365:   MatGetSize(M,&n,NULL);
366:   MatCreateShell(PetscObjectComm((PetscObject)M),n,n,n,n,(void*)ctx,Ms);
367:   MatShellSetOperation(*Ms,MATOP_MULT,(void(*)())MatMult_Fun);
368:   MatShellSetOperation(*Ms,MATOP_MULT_TRANSPOSE,(void(*)())MatMultTranspose_Fun);
369:   MatShellSetOperation(*Ms,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Fun);
370:   MatShellSetOperation(*Ms,MATOP_DUPLICATE,(void(*)())MatDuplicate_Fun);
371:   MatShellSetOperation(*Ms,MATOP_DESTROY,(void(*)())MatDestroy_Fun);
372:   MatShellSetOperation(*Ms,MATOP_AXPY,(void(*)())MatAXPY_Fun);
373:   MatShellSetOperation(*Ms,MATOP_SCALE,(void(*)())MatScale_Fun);
374:   return(0);
375: }

379: static PetscErrorCode NEPNLEIGSNormEstimation(NEP nep,Mat M,PetscReal *norm,Vec *w)
380: {
381:   PetscScalar    *z,*x,*y;
382:   PetscReal      tr;
383:   Vec            X=w[0],Y=w[1];
384:   PetscInt       n,i;
385:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
386:   PetscRandom    rand;
388:   
390:   if (!ctx->vrn) {
391:     /* generate a random vector with normally distributed entries with the Box-Muller transform */
392:     BVGetRandomContext(nep->V,&rand);
393:     MatCreateVecs(M,&ctx->vrn,NULL);
394:     VecSetRandom(X,rand);
395:     VecSetRandom(Y,rand);
396:     VecGetLocalSize(ctx->vrn,&n);
397:     VecGetArray(ctx->vrn,&z);
398:     VecGetArray(X,&x);
399:     VecGetArray(Y,&y);
400:     for (i=0;i<n;i++) {
401: #if defined(PETSC_USE_COMPLEX)
402:       z[i] = PetscSqrtReal(-2.0*PetscLogReal(PetscRealPart(x[i])))*PetscCosReal(2.0*PETSC_PI*PetscRealPart(y[i]));
403:       z[i] += PETSC_i*(PetscSqrtReal(-2.0*PetscLogReal(PetscImaginaryPart(x[i])))*PetscCosReal(2.0*PETSC_PI*PetscImaginaryPart(y[i])));
404: #else
405:       z[i] = PetscSqrtReal(-2.0*PetscLogReal(x[i]))*PetscCosReal(2.0*PETSC_PI*y[i]);
406: #endif
407:     }
408:     VecRestoreArray(ctx->vrn,&z);
409:     VecRestoreArray(X,&x);
410:     VecRestoreArray(Y,&y);
411:     VecNorm(ctx->vrn,NORM_2,&tr);
412:     VecScale(ctx->vrn,1/tr);
413:   }
414:   /* matrix-free norm estimator of Ipsen http://www4.ncsu.edu/~ipsen/ps/slides_ima.pdf */
415:   MatGetSize(M,&n,NULL);
416:   MatMult(M,ctx->vrn,X);
417:   VecNorm(X,NORM_2,norm);
418:   *norm *= PetscSqrtReal((PetscReal)n);
419:   return(0);
420: }

424: static PetscErrorCode NEPNLEIGSDividedDifferences_split(NEP nep)
425: {
427:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
428:   PetscInt       k,j,i;
429:   PetscReal      norm0,norm,max;
430:   PetscScalar    *s=ctx->s,*beta=ctx->beta,*b,alpha,*coeffs;
431:   Mat            T,Ts;
432:   PetscBool      shell;

435:   PetscMalloc1(nep->nt*ctx->ddmaxit,&ctx->coeffD);
436:   PetscMalloc2(ctx->ddmaxit+1,&b,ctx->ddmaxit+1,&coeffs);
437:   max = 0.0;
438:   for (j=0;j<nep->nt;j++) {
439:     FNEvaluateFunction(nep->f[j],s[0],ctx->coeffD+j);
440:     ctx->coeffD[j] /= beta[0];
441:     max = PetscMax(PetscAbsScalar(ctx->coeffD[j]),max);
442:   }
443:   norm0 = max;
444:   ctx->nmat = ctx->ddmaxit;
445:   for (k=1;k<ctx->ddmaxit;k++) {
446:     NEPNLEIGSEvalNRTFunct(nep,k,s[k],b);
447:     max = 0.0;
448:     for (i=0;i<nep->nt;i++) {
449:       FNEvaluateFunction(nep->f[i],s[k],ctx->coeffD+k*nep->nt+i);
450:       for (j=0;j<k;j++) {
451:         ctx->coeffD[k*nep->nt+i] -= b[j]*ctx->coeffD[i+nep->nt*j];
452:       }
453:       ctx->coeffD[k*nep->nt+i] /= b[k];
454:       max = PetscMax(PetscAbsScalar(ctx->coeffD[k*nep->nt+i]),max);
455:     }
456:     norm = max;
457:     if (norm/norm0 < ctx->ddtol) {
458:       ctx->nmat = k+1;
459:       break;
460:     } 
461:   }
462:   if (!ctx->ksp) { NEPNLEIGSGetKSPs(nep,&ctx->ksp); }
463:   PetscObjectTypeCompare((PetscObject)nep->A[0],MATSHELL,&shell);
464:   for (i=0;i<ctx->nshiftsw;i++) {
465:     NEPNLEIGSEvalNRTFunct(nep,ctx->nmat-1,ctx->shifts[i],coeffs);
466:     if (!shell) {
467:       MatDuplicate(nep->A[0],MAT_COPY_VALUES,&T);
468:     } else {
469:       NLEIGSMatToMatShellArray(nep->A[0],&T);
470:     }
471:     alpha = 0.0;
472:     for (j=0;j<ctx->nmat-1;j++) alpha += coeffs[j]*ctx->coeffD[j*nep->nt];
473:     MatScale(T,alpha);
474:     for (k=1;k<nep->nt;k++) {
475:       alpha = 0.0;
476:       for (j=0;j<ctx->nmat-1;j++) alpha += coeffs[j]*ctx->coeffD[j*nep->nt+k];
477:       if (shell) {
478:         NLEIGSMatToMatShellArray(nep->A[k],&Ts);
479:       }
480:       MatAXPY(T,alpha,shell?Ts:nep->A[k],nep->mstr);
481:       if (shell) {
482:         MatDestroy(&Ts);
483:       }
484:     }
485:     KSPSetOperators(ctx->ksp[i],T,T);
486:     KSPSetUp(ctx->ksp[i]);
487:     MatDestroy(&T);
488:   }
489:   PetscFree2(b,coeffs);
490:   return(0);
491: }

495: static PetscErrorCode NEPNLEIGSDividedDifferences_callback(NEP nep)
496: {
498:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
499:   PetscInt       k,j,i;
500:   PetscReal      norm0,norm;
501:   PetscScalar    *s=ctx->s,*beta=ctx->beta,*b,*coeffs;
502:   Mat            *D=ctx->D,T;
503:   PetscBool      shell,has,vec=PETSC_FALSE;
504:   Vec            w[2];

507:   PetscMalloc2(ctx->ddmaxit+1,&b,ctx->ddmaxit+1,&coeffs);
508:   T = nep->function;
509:   NEPComputeFunction(nep,s[0],T,T);
510:   PetscObjectTypeCompare((PetscObject)T,MATSHELL,&shell);
511:   if (!shell) {
512:     MatDuplicate(T,MAT_COPY_VALUES,&D[0]);
513:   } else {
514:     NLEIGSMatToMatShellArray(T,&D[0]);
515:   }
516:   if (beta[0]!=1.0) {
517:     MatScale(D[0],1.0/beta[0]);
518:   }
519:   MatHasOperation(D[0],MATOP_NORM,&has);
520:   if (has) {
521:     MatNorm(D[0],NORM_FROBENIUS,&norm0);
522:   } else {
523:     MatCreateVecs(D[0],NULL,&w[0]);
524:     VecDuplicate(w[0],&w[1]);
525:     vec = PETSC_TRUE;
526:     NEPNLEIGSNormEstimation(nep,D[0],&norm0,w);
527:   }
528:   ctx->nmat = ctx->ddmaxit;
529:   for (k=1;k<ctx->ddmaxit;k++) {
530:     NEPNLEIGSEvalNRTFunct(nep,k,s[k],b);
531:     NEPComputeFunction(nep,s[k],T,T);
532:     if (!shell) {
533:       MatDuplicate(T,MAT_COPY_VALUES,&D[k]);
534:     } else {
535:       NLEIGSMatToMatShellArray(T,&D[k]);
536:     }
537:     for (j=0;j<k;j++) {
538:       MatAXPY(D[k],-b[j],D[j],nep->mstr);
539:     }
540:     MatScale(D[k],1.0/b[k]);
541:     MatHasOperation(D[k],MATOP_NORM,&has);
542:     if (has) {
543:       MatNorm(D[k],NORM_FROBENIUS,&norm);
544:     } else {
545:       if(!vec) {
546:         MatCreateVecs(D[k],NULL,&w[0]);
547:         VecDuplicate(w[0],&w[1]);
548:         vec = PETSC_TRUE;
549:       }
550:       NEPNLEIGSNormEstimation(nep,D[k],&norm,w);
551:     }
552:     if (norm/norm0 < ctx->ddtol) {
553:       ctx->nmat = k+1; /* increment (the last matrix is not used) */
554:       MatDestroy(&D[k]);
555:       break;
556:     } 
557:   }
558:   if (!ctx->ksp) { NEPNLEIGSGetKSPs(nep,&ctx->ksp); }
559:   for (i=0;i<ctx->nshiftsw;i++) {
560:     NEPNLEIGSEvalNRTFunct(nep,ctx->nmat-1,ctx->shifts[i],coeffs);
561:     MatDuplicate(ctx->D[0],MAT_COPY_VALUES,&T);
562:     if (coeffs[0]!=1.0) { MatScale(T,coeffs[0]); }
563:     for (j=1;j<ctx->nmat-1;j++) {
564:       MatAXPY(T,coeffs[j],ctx->D[j],nep->mstr);
565:     }
566:     KSPSetOperators(ctx->ksp[i],T,T);
567:     KSPSetUp(ctx->ksp[i]);
568:     MatDestroy(&T);
569:   }
570:   PetscFree2(b,coeffs);
571:   if (vec) {
572:     VecDestroy(&w[0]);  
573:     VecDestroy(&w[1]);  
574:   }
575:   return(0);
576: }

580: static PetscErrorCode NEPNLEIGSRitzVector(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscInt k,Vec t)
581: {
583:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
584:   PetscInt       deg=ctx->nmat-1,ldds,n;
585:   PetscBLASInt   nq_,lds_,n_,one=1,ldds_;
586:   PetscScalar    sone=1.0,zero=0.0,*x,*y,*X;

589:   DSGetDimensions(nep->ds,&n,NULL,NULL,NULL,NULL);
590:   PetscMalloc1(n+nq,&y);
591:   x = y+nq;
592:   DSGetLeadingDimension(nep->ds,&ldds);
593:   PetscBLASIntCast(n,&n_);
594:   PetscBLASIntCast(nq,&nq_);
595:   PetscBLASIntCast(ldds,&ldds_);
596:   PetscBLASIntCast(deg*ld,&lds_);
597:   DSGetArray(nep->ds,DS_MAT_X,&X);
598:   if (ctx->nshifts) PetscStackCall("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,H,&ldds_,X+k*ldds,&one,&zero,x,&one));
599:   else x = X+k*ldds;
600:   PetscStackCall("BLASgemv",BLASgemv_("N",&nq_,&n_,&sone,S,&lds_,x,&one,&zero,y,&one));
601:   DSRestoreArray(nep->ds,DS_MAT_X,&X);
602:   BVSetActiveColumns(nep->V,0,nq);
603:   BVMultVec(nep->V,1.0,0.0,t,y);
604:   VecNormalize(t,NULL);
605:   PetscFree(y);
606:   return(0);
607: }

611: /*
612:    NEPKrylovConvergence - This is the analogue to EPSKrylovConvergence.
613: */
614: static PetscErrorCode NEPNLEIGSKrylovConvergence(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscBool getall,PetscInt kini,PetscInt nits,PetscScalar betak,PetscReal betah,PetscInt *kout,Vec *w)
615: {
617:   PetscInt       k,newk,marker,inside;
618:   PetscScalar    re,im;
619:   PetscReal      resnorm,tt;
620:   PetscBool      istrivial;
621:   Vec            t;
622:   NEP_NLEIGS     *ctx = (NEP_NLEIGS*)nep->data;

625:   t = w[0];
626:   RGIsTrivial(nep->rg,&istrivial);
627:   marker = -1;
628:   if (nep->trackall) getall = PETSC_TRUE;
629:   for (k=kini;k<kini+nits;k++) {
630:     /* eigenvalue */
631:     re = nep->eigr[k];
632:     im = nep->eigi[k];
633:     if (!istrivial) {
634:       if (!ctx->nshifts) {
635:         NEPNLEIGSBackTransform((PetscObject)nep,1,&re,&im);
636:       }
637:       RGCheckInside(nep->rg,1,&re,&im,&inside);
638:       if (marker==-1 && inside<0) marker = k;
639:     }
640:     newk = k;
641:     DSVectors(nep->ds,DS_MAT_X,&newk,&resnorm);
642:     tt = (ctx->nshifts)?SlepcAbsEigenvalue(betak-nep->eigr[k]*betah,nep->eigi[k]*betah):betah;
643:     resnorm *=  PetscAbsReal(tt);
644:     /* error estimate */
645:     (*nep->converged)(nep,nep->eigr[k],nep->eigi[k],resnorm,&nep->errest[k],nep->convergedctx);
646:     if (ctx->trueres && (nep->errest[k] < nep->tol) ) {
647:       /* check explicit residual */
648:       NEPNLEIGSRitzVector(nep,S,ld,nq,H,k,t);
649:       NEPComputeResidualNorm_Private(nep,re,t,w+1,&resnorm);
650:       (*nep->converged)(nep,re,im,resnorm,&nep->errest[k],nep->convergedctx);
651:     }
652:     if (marker==-1 && nep->errest[k] >= nep->tol) marker = k;
653:     if (newk==k+1) {
654:       nep->errest[k+1] = nep->errest[k];
655:       k++;
656:     }
657:     if (marker!=-1 && !getall) break;
658:   }
659:   if (marker!=-1) k = marker;
660:   *kout = k;
661:   return(0);
662: }

666: PetscErrorCode NEPSetUp_NLEIGS(NEP nep)
667: {
669:   PetscInt       k,in;
670:   PetscScalar    zero=0.0;
671:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
672:   SlepcSC        sc;
673:   PetscBool      istrivial;

676:   NEPSetDimensions_Default(nep,nep->nev,&nep->ncv,&nep->mpd);
677:   if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd");
678:   if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv);
679:   if (!ctx->ddmaxit) ctx->ddmaxit = MAX_LBPOINTS;
680:   RGIsTrivial(nep->rg,&istrivial);
681:   if (istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEPNLEIGS requires a nontrivial region defining the target set");
682:   RGCheckInside(nep->rg,1,&nep->target,&zero,&in);
683:   if (in<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The target is not inside the target set");
684:   if (!nep->which) nep->which = NEP_TARGET_MAGNITUDE;

686:   /* Initialize the NLEIGS context structure */
687:   k = ctx->ddmaxit;
688:   PetscMalloc4(k,&ctx->s,k,&ctx->xi,k,&ctx->beta,k,&ctx->D);
689:   nep->data = ctx;
690:   if (nep->tol==PETSC_DEFAULT) nep->tol = SLEPC_DEFAULT_TOL;
691:   if (ctx->ddtol==PETSC_DEFAULT) ctx->ddtol = nep->tol/10.0;
692:   if (!ctx->keep) ctx->keep = 0.5;

694:   /* Compute Leja-Bagby points and scaling values */
695:   NEPNLEIGSLejaBagbyPoints(nep);

697:   /* Compute the divided difference matrices */
698:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) {
699:     NEPNLEIGSDividedDifferences_split(nep);
700:   } else {
701:     NEPNLEIGSDividedDifferences_callback(nep);
702:   }
703:   NEPAllocateSolution(nep,ctx->nmat);
704:   NEPSetWorkVecs(nep,4);

706:   /* set-up DS and transfer split operator functions */
707:   DSSetType(nep->ds,ctx->nshifts?DSGNHEP:DSNHEP);
708:   DSAllocate(nep->ds,nep->ncv+1);
709:   DSGetSlepcSC(nep->ds,&sc);
710:   if (!ctx->nshifts) {
711:     sc->map = NEPNLEIGSBackTransform;
712:     DSSetExtraRow(nep->ds,PETSC_TRUE);
713:   }
714:   sc->mapobj        = (PetscObject)nep;
715:   sc->rg            = nep->rg;
716:   sc->comparison    = nep->sc->comparison;
717:   sc->comparisonctx = nep->sc->comparisonctx;
718:   return(0);
719: }

723: /*
724:   Norm of [sp;sq] 
725: */
726: static PetscErrorCode NEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm)
727: {
729:   PetscBLASInt   n_,one=1;

732:   PetscBLASIntCast(n,&n_);
733:   *norm = BLASnrm2_(&n_,S,&one);
734:   return(0);
735: }

739: /*
740:  Computes GS orthogonalization   [z;x] - [Sp;Sq]*y,
741:  where y = ([Sp;Sq]'*[z;x]).
742:    k: Column from S to be orthogonalized against previous columns.
743:    Sq = Sp+ld
744:    dim(work)=k;
745: */
746: static PetscErrorCode NEPTOAROrth2(NEP nep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work)
747: {
749:   PetscBLASInt   n_,lds_,k_,one=1;
750:   PetscScalar    sonem=-1.0,sone=1.0,szero=0.0,*x0,*x,*c;
751:   PetscInt       i,lds=deg*ld,n;
752:   PetscReal      eta,onorm;
753:   
755:   BVGetOrthogonalization(nep->V,NULL,NULL,&eta,NULL);
756:   n = k+deg-1;
757:   PetscBLASIntCast(n,&n_);
758:   PetscBLASIntCast(deg*ld,&lds_);
759:   PetscBLASIntCast(k,&k_); /* Number of vectors to orthogonalize against them */
760:   c = work;
761:   x0 = S+k*lds;
762:   PetscStackCall("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S,&lds_,x0,&one,&szero,y,&one));
763:   for (i=1;i<deg;i++) {
764:     x = S+i*ld+k*lds;
765:     PetscStackCall("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+i*ld,&lds_,x,&one,&sone,y,&one));
766:   }
767:   for (i=0;i<deg;i++) {
768:     x= S+i*ld+k*lds;
769:     PetscStackCall("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S+i*ld,&lds_,y,&one,&sone,x,&one));
770:   }
771:   NEPTOARSNorm2(lds,S+k*lds,&onorm);
772:   /* twice */
773:   PetscStackCall("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S,&lds_,x0,&one,&szero,c,&one));
774:   for (i=1;i<deg;i++) {
775:     x = S+i*ld+k*lds;
776:     PetscStackCall("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+i*ld,&lds_,x,&one,&sone,c,&one));
777:   }
778:   for (i=0;i<deg;i++) {
779:     x= S+i*ld+k*lds;
780:     PetscStackCall("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S+i*ld,&lds_,c,&one,&sone,x,&one));
781:   }
782:   for (i=0;i<k;i++) y[i] += c[i];
783:   if (norm) {
784:     NEPTOARSNorm2(lds,S+k*lds,norm);
785:     if (lindep) *lindep = (*norm < eta * onorm)?PETSC_TRUE:PETSC_FALSE;
786:   }
787:   return(0);
788: }

792: /*
793:   Extend the TOAR basis by applying the the matrix operator
794:   over a vector which is decomposed on the TOAR way
795:   Input:
796:     - S,V: define the latest Arnoldi vector (nv vectors in V)
797:   Output:
798:     - t: new vector extending the TOAR basis
799:     - r: temporally coefficients to compute the TOAR coefficients
800:          for the new Arnoldi vector
801:   Workspace: t_ (two vectors)
802: */
803: static PetscErrorCode NEPTOARExtendBasis(NEP nep,PetscInt idxrktg,PetscScalar *S,PetscInt ls,PetscInt nv,BV V,Vec t,PetscScalar *r,PetscInt lr,Vec *t_)
804: {
806:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
807:   PetscInt       deg=ctx->nmat-1,k,j;
808:   Vec            v=t_[0],q=t_[1],w;
809:   PetscScalar    *beta=ctx->beta,*s=ctx->s,*xi=ctx->xi,*coeffs,sigma;

812:   if (!ctx->ksp) { NEPNLEIGSGetKSPs(nep,&ctx->ksp); }
813:   sigma = ctx->shifts[idxrktg];
814:   BVSetActiveColumns(nep->V,0,nv);
815:   PetscMalloc1(ctx->nmat-1,&coeffs);
816:   if (PetscAbsScalar(s[deg-2]-sigma)<100*PETSC_MACHINE_EPSILON) SETERRQ(PETSC_COMM_SELF,1,"Breakdown in NLEIGS");
817:   /* i-part stored in (i-1) position */
818:   for (j=0;j<nv;j++) {
819:     r[(deg-2)*lr+j] = (S[(deg-2)*ls+j]+(beta[deg-1]/xi[deg-2])*S[(deg-1)*ls+j])/(s[deg-2]-sigma);
820:   }
821:   BVSetActiveColumns(ctx->W,0,deg-1);
822:   BVGetColumn(ctx->W,deg-2,&w);
823:   BVMultVec(V,1.0,0.0,w,r+(deg-2)*lr);
824:   BVRestoreColumn(ctx->W,deg-2,&w);
825:   for (k=deg-2;k>0;k--) {
826:     if (PetscAbsScalar(s[k-1]-sigma)<100*PETSC_MACHINE_EPSILON) SETERRQ(PETSC_COMM_SELF,1,"Breakdown in NLEIGS");
827:     for (j=0;j<nv;j++) r[(k-1)*lr+j] = (S[(k-1)*ls+j]+(beta[k]/xi[k-1])*S[k*ls+j]-beta[k]*(1.0-sigma/xi[k-1])*r[(k)*lr+j])/(s[k-1]-sigma);
828:     BVGetColumn(ctx->W,k-1,&w);
829:     BVMultVec(V,1.0,0.0,w,r+(k-1)*lr);
830:     BVRestoreColumn(ctx->W,k-1,&w);
831:   }
832:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) {
833:     for (j=0;j<ctx->nmat-1;j++) coeffs[j] = ctx->coeffD[nep->nt*j];
834:     BVMultVec(ctx->W,1.0,0.0,v,coeffs);
835:     MatMult(nep->A[0],v,q);
836:     for (k=1;k<nep->nt;k++) {
837:       for (j=0;j<ctx->nmat-1;j++) coeffs[j] = ctx->coeffD[nep->nt*j+k];
838:       BVMultVec(ctx->W,1.0,0,v,coeffs);
839:       MatMult(nep->A[k],v,t);
840:       VecAXPY(q,1.0,t);
841:     }
842:     KSPSolve(ctx->ksp[idxrktg],q,t);
843:     VecScale(t,-1.0);
844:   } else {
845:     for (k=0;k<deg-1;k++) {
846:       BVGetColumn(ctx->W,k,&w);
847:       MatMult(ctx->D[k],w,q);
848:       BVRestoreColumn(ctx->W,k,&w);
849:       BVInsertVec(ctx->W,k,q);
850:     }
851:     for (j=0;j<ctx->nmat-1;j++) coeffs[j] = 1.0;
852:     BVMultVec(ctx->W,1.0,0.0,q,coeffs);
853:     KSPSolve(ctx->ksp[idxrktg],q,t);
854:     VecScale(t,-1.0);
855:   }
856:   PetscFree(coeffs);
857:   return(0);
858: }

862: /*
863:   Compute TOAR coefficients of the blocks of the new Arnoldi vector computed
864: */
865: static PetscErrorCode NEPTOARCoefficients(NEP nep,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x,PetscScalar *work)
866: {
868:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
869:   PetscInt       k,j,d=ctx->nmat-1;
870:   PetscScalar    *t=work;

873:   NEPNLEIGSEvalNRTFunct(nep,d-1,sigma,t);
874:   for (k=0;k<d-1;k++) {
875:     for (j=0;j<=nv;j++) r[k*lr+j] += t[k]*x[j];
876:   }
877:   for (j=0;j<=nv;j++) r[(d-1)*lr+j] = t[d-1]*x[j];
878:   return(0);
879: }

883: /*
884:   Compute continuation vector coefficients for the Rational-Krylov run.
885:   dim(work) >= (end-ini)*(end-ini+1) + end+1 + 2*(end-ini+1), dim(t) = end. 
886: */
887: static PetscErrorCode NEPNLEIGS_RKcontinuation(NEP nep,PetscInt ini,PetscInt end,PetscScalar *K,PetscScalar *H,PetscInt ld,PetscScalar sigma,PetscScalar *S,PetscInt lds,PetscScalar *cont,PetscScalar *t,PetscScalar *work)
888: {
889: #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(SLEPC_MISSING_LAPACK_LARF)
891:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/LARF - Lapack routines are unavailable");
892: #else
894:   PetscScalar    *x,*W,*tau,sone=1.0,szero=0.0;
895:   PetscInt       i,j,n1,n,nwu=0;
896:   PetscBLASInt   info,n_,n1_,one=1,dim,lds_;
897:   NEP_NLEIGS     *ctx = (NEP_NLEIGS*)nep->data;

900:   if (!ctx->nshifts || !end) {
901:     t[0] = 1;
902:     PetscMemcpy(cont,S+end*lds,lds*sizeof(PetscScalar));
903:   } else {
904:     n   = end-ini;
905:     n1  = n+1;
906:     x   = work+nwu;
907:     nwu += end+1;
908:     tau = work+nwu;
909:     nwu += n;
910:     W   = work+nwu;
911:     nwu += n1*n;
912:     for (j=ini;j<end;j++) {
913:       for (i=ini;i<=end;i++) W[(j-ini)*n1+i-ini] = K[j*ld+i] -H[j*ld+i]*sigma;
914:     }
915:     PetscBLASIntCast(n,&n_);
916:     PetscBLASIntCast(n1,&n1_);
917:     PetscBLASIntCast(end+1,&dim);
918:     PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&n1_,&n_,W,&n1_,tau,work+nwu,&n1_,&info));
919:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);
920:     for (i=0;i<end;i++) t[i] = 0.0;
921:     t[end] = 1.0; 
922:     for (j=n-1;j>=0;j--) {
923:       for (i=0;i<ini+j;i++) x[i] = 0.0;
924:       x[ini+j] = 1.0;
925:       for (i=j+1;i<n1;i++) x[i+ini] = W[i+n1*j]; 
926:       tau[j] = PetscConj(tau[j]);
927:       PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&dim,&one,x,&one,tau+j,t,&dim,work+nwu));
928:     }
929:     PetscBLASIntCast(lds,&lds_);
930:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&lds_,&n1_,&sone,S,&lds_,t,&one,&szero,cont,&one));
931:   }
932:   return(0);
933: #endif
934: }

938: /*
939:   Compute a run of Arnoldi iterations
940: */
941: static PetscErrorCode NEPNLEIGSTOARrun(NEP nep,PetscInt *nq,PetscScalar *S,PetscInt ld,PetscScalar *K,PetscScalar *H,PetscInt ldh,BV V,PetscInt k,PetscInt *M,PetscBool *breakdown,Vec *t_)
942: {
944:   NEP_NLEIGS     *ctx = (NEP_NLEIGS*)nep->data;
945:   PetscInt       i,j,p,m=*M,lwa,deg=ctx->nmat-1,lds=ld*deg,nqt=*nq;
946:   Vec            t=t_[0];
947:   PetscReal      norm;
948:   PetscScalar    *x,*work,*tt,sigma,*cont;
949:   PetscBool      lindep;

952:   lwa = PetscMax(ld,deg)+(m+1)*(m+1)+4*(m+1);
953:   PetscMalloc4(ld,&x,lwa,&work,m+1,&tt,lds,&cont);
954:   for (j=k;j<m;j++) {
955:     sigma = ctx->shifts[(++(ctx->idxrk))%ctx->nshiftsw];

957:     /* Continuation vector */
958:     NEPNLEIGS_RKcontinuation(nep,0,j,K,H,ldh,sigma,S,lds,cont,tt,work);
959:     
960:     /* apply operator */
961:     BVGetColumn(nep->V,nqt,&t);
962:     NEPTOARExtendBasis(nep,(ctx->idxrk)%ctx->nshiftsw,cont,ld,nqt,V,t,S+(j+1)*lds,ld,t_+1);
963:     BVRestoreColumn(nep->V,nqt,&t);

965:     /* orthogonalize */
966:     BVOrthogonalizeColumn(nep->V,nqt,x,&norm,&lindep);
967:     if (!lindep) {
968:       x[nqt] = norm;
969:       BVScaleColumn(nep->V,nqt,1.0/norm);
970:       nqt++;
971:     } else x[nqt] = 0.0;

973:     NEPTOARCoefficients(nep,sigma,*nq,cont,ld,S+(j+1)*lds,ld,x,work);

975:     /* Level-2 orthogonalization */
976:     NEPTOAROrth2(nep,S,ld,deg,j+1,H+j*ldh,&norm,breakdown,work);
977:     H[j+1+ldh*j] = norm;
978:     if (ctx->nshifts) {
979:       for (i=0;i<=j;i++) K[i+ldh*j] = sigma*H[i+ldh*j] + tt[i];
980:       K[j+1+ldh*j] = sigma*H[j+1+ldh*j];
981:     }
982:     *nq = nqt;
983:     if (*breakdown) {
984:       *M = j+1;
985:       break;
986:     }
987:     for (p=0;p<deg;p++) {
988:       for (i=0;i<=j+deg;i++) {
989:         S[i+p*ld+(j+1)*lds] /= norm;
990:       }
991:     }
992:   } 
993:   PetscFree4(x,work,tt,cont);
994:   return(0);
995: }

999: /* dim(work)=5*ld*lds dim(rwork)=6*n */
1000: static PetscErrorCode NEPTOARTrunc(NEP nep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt *nq,PetscInt cs1,PetscScalar *work,PetscReal *rwork)
1001: {
1003:   PetscInt       lwa,nwu=0,nrwu=0;
1004:   PetscInt       j,i,n,lds=deg*ld,rk=0,rs1;
1005:   PetscScalar    *M,*V,*pU,t;
1006:   PetscReal      *sg,tol;
1007:   PetscBLASInt   cs1_,rs1_,cs1tdeg,n_,info,lw_;
1008:   Mat            U;

1011:   rs1 = *nq;
1012:   n = (rs1>deg*cs1)?deg*cs1:rs1;
1013:   lwa = 5*ld*lds;
1014:   M = work+nwu;
1015:   nwu += rs1*cs1*deg;
1016:   sg = rwork+nrwu;
1017:   nrwu += n;
1018:   pU = work+nwu;
1019:   nwu += rs1*n;
1020:   V = work+nwu;
1021:   nwu += deg*cs1*n;
1022:   for (i=0;i<cs1;i++) {
1023:     for (j=0;j<deg;j++) {
1024:       PetscMemcpy(M+(i+j*cs1)*rs1,S+i*lds+j*ld,rs1*sizeof(PetscScalar));
1025:     } 
1026:   }
1027:   PetscBLASIntCast(n,&n_);
1028:   PetscBLASIntCast(cs1,&cs1_);
1029:   PetscBLASIntCast(rs1,&rs1_);
1030:   PetscBLASIntCast(cs1*deg,&cs1tdeg);
1031:   PetscBLASIntCast(lwa-nwu,&lw_);
1032: #if !defined (PETSC_USE_COMPLEX)
1033:   PetscStackCall("LAPACKgesvd",LAPACKgesvd_("S","S",&rs1_,&cs1tdeg,M,&rs1_,sg,pU,&rs1_,V,&n_,work+nwu,&lw_,&info));
1034: #else
1035:   PetscStackCall("LAPACKgesvd",LAPACKgesvd_("S","S",&rs1_,&cs1tdeg,M,&rs1_,sg,pU,&rs1_,V,&n_,work+nwu,&lw_,rwork+nrwu,&info));  
1036: #endif
1037:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);
1038:   
1039:   /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */
1040:   MatCreateSeqDense(PETSC_COMM_SELF,rs1,cs1+deg-1,pU,&U);
1041:   BVSetActiveColumns(nep->V,0,rs1);
1042:   BVMultInPlace(nep->V,U,0,cs1+deg-1);
1043:   BVSetActiveColumns(nep->V,0,cs1+deg-1);
1044:   MatDestroy(&U);  
1045:   tol = PetscMax(rs1,deg*cs1)*PETSC_MACHINE_EPSILON*sg[0];
1046:   for (i=0;i<PetscMin(n_,cs1tdeg);i++) if (sg[i]>tol) rk++;
1047:   rk = PetscMin(cs1+deg-1,rk);
1048:   
1049:   /* Update S */
1050:   PetscMemzero(S,lds*ld*sizeof(PetscScalar));
1051:   for (i=0;i<rk;i++) {
1052:     t = sg[i];
1053:     PetscStackCall("BLASscal",BLASscal_(&cs1tdeg,&t,V+i,&n_));
1054:   }
1055:   for (j=0;j<cs1;j++) {
1056:     for (i=0;i<deg;i++) {
1057:       PetscMemcpy(S+j*lds+i*ld,V+(cs1*i+j)*n,rk*sizeof(PetscScalar));
1058:     }
1059:   }
1060:   *nq = rk;
1061:   return(0);
1062: }

1066: /*
1067:   S <- S*Q 
1068:   columns s-s+ncu of S
1069:   rows 0-sr of S
1070:   size(Q) qr x ncu
1071:   dim(work)=sr*ncu
1072: */
1073: static PetscErrorCode NEPTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)
1074: {
1076:   PetscScalar    a=1.0,b=0.0;
1077:   PetscBLASInt   sr_,ncu_,ldq_,lds_,qr_;
1078:   PetscInt       j,lds=deg*ld,i;

1081:   PetscBLASIntCast(sr,&sr_);
1082:   PetscBLASIntCast(qr,&qr_);
1083:   PetscBLASIntCast(ncu,&ncu_);
1084:   PetscBLASIntCast(lds,&lds_);
1085:   PetscBLASIntCast(ldq,&ldq_);
1086:   for (i=0;i<deg;i++) {
1087:     PetscStackCall("BLASgemm",BLASgemm_("N","N",&sr_,&ncu_,&qr_,&a,S+i*ld,&lds_,Q,&ldq_,&b,work,&sr_));
1088:     for (j=0;j<ncu;j++) {
1089:       PetscMemcpy(S+lds*(s+j)+i*ld,work+j*sr,sr*sizeof(PetscScalar));
1090:     }
1091:   }
1092:   return(0);
1093: }

1097: PetscErrorCode NEPSolve_NLEIGS(NEP nep)
1098: {
1100:   NEP_NLEIGS     *ctx = (NEP_NLEIGS*)nep->data;
1101:   PetscInt       i,j,k=0,l,nv=0,ld,lds,off,ldds,rs1,nq=0,newn;
1102:   PetscInt       lwa,lrwa,nwu=0,nrwu=0,deg=ctx->nmat-1,nconv=0;
1103:   PetscScalar    *S,*Q,*work,*H,*pU,*K,betak=0,*Hc,*eigr,*eigi;
1104:   PetscReal      betah,norm,*rwork;
1105:   PetscBool      breakdown=PETSC_FALSE,lindep;
1106:   Mat            U;

1109:   ld = nep->ncv+deg;
1110:   lds = deg*ld;
1111:   lwa = (deg+6)*ld*lds;
1112:   lrwa = 7*lds;
1113:   DSGetLeadingDimension(nep->ds,&ldds);
1114:   PetscMalloc4(lwa,&work,lrwa,&rwork,lds*ld,&S,ldds*ldds,&Hc);
1115:   PetscMemzero(S,lds*ld*sizeof(PetscScalar));
1116:   if (!ctx->nshifts) {
1117:     PetscMalloc2(nep->ncv,&eigr,nep->ncv,&eigi);
1118:   } else { eigr = nep->eigr; eigi = nep->eigi; }
1119:   BVDuplicateResize(nep->V,PetscMax(nep->nt-1,ctx->nmat-1),&ctx->W);

1121:   /* Get the starting vector */
1122:   for (i=0;i<deg;i++) {
1123:     BVSetRandomColumn(nep->V,i);
1124:     BVOrthogonalizeColumn(nep->V,i,S+i*ld,&norm,&lindep);
1125:     if (!lindep) {
1126:       BVScaleColumn(nep->V,i,1/norm);
1127:       S[i+i*ld] = norm;
1128:       nq++;
1129:     }
1130:   }
1131:   if (!nq) SETERRQ(PetscObjectComm((PetscObject)nep),1,"NEP: Problem with initial vector");
1132:   NEPTOARSNorm2(lds,S,&norm);
1133:   for (j=0;j<deg;j++) {
1134:     for (i=0;i<=j;i++) S[i+j*ld] /= norm;
1135:   }

1137:   /* Restart loop */
1138:   l = 0;
1139:   while (nep->reason == NEP_CONVERGED_ITERATING) {
1140:     nep->its++;
1141:     
1142:     /* Compute an nv-step Krylov relation */
1143:     nv = PetscMin(nep->nconv+nep->mpd,nep->ncv);
1144:     if (ctx->nshifts) { DSGetArray(nep->ds,DS_MAT_A,&K); }
1145:     DSGetArray(nep->ds,ctx->nshifts?DS_MAT_B:DS_MAT_A,&H);
1146:     NEPNLEIGSTOARrun(nep,&nq,S,ld,K,H,ldds,nep->V,nep->nconv+l,&nv,&breakdown,nep->work);
1147:     betah = PetscAbsScalar(H[(nv-1)*ldds+nv]);
1148:     DSRestoreArray(nep->ds,ctx->nshifts?DS_MAT_B:DS_MAT_A,&H);
1149:     if (ctx->nshifts) {
1150:       betak = K[(nv-1)*ldds+nv];
1151:       DSRestoreArray(nep->ds,DS_MAT_A,&K);
1152:     }
1153:     DSSetDimensions(nep->ds,nv,0,nep->nconv,nep->nconv+l);
1154:     if (l==0) {
1155:       DSSetState(nep->ds,DS_STATE_INTERMEDIATE);
1156:     } else {
1157:       DSSetState(nep->ds,DS_STATE_RAW);
1158:     }

1160:     /* Solve projected problem */
1161:     if (ctx->nshifts) {
1162:       DSGetArray(nep->ds,DS_MAT_B,&H);
1163:       PetscMemcpy(Hc,H,ldds*ldds*sizeof(PetscScalar));
1164:       DSRestoreArray(nep->ds,DS_MAT_B,&H);
1165:     }
1166:     DSSolve(nep->ds,nep->eigr,nep->eigi);
1167:     DSSort(nep->ds,nep->eigr,nep->eigi,NULL,NULL,NULL);
1168:     if (!ctx->nshifts) {
1169:       DSUpdateExtraRow(nep->ds);
1170:     }

1172:     /* Check convergence */
1173:     NEPNLEIGSKrylovConvergence(nep,S,ld,nq,Hc,PETSC_FALSE,nep->nconv,nv-nep->nconv,betak,betah,&k,nep->work);
1174:     (*nep->stopping)(nep,nep->its,nep->max_it,k,nep->nev,&nep->reason,nep->stoppingctx);
1175:     nconv = k;

1177:     /* Update l */
1178:     if (nep->reason != NEP_CONVERGED_ITERATING || breakdown) l = 0;
1179:     else {
1180:       l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep));
1181:       if (!breakdown) {
1182:         /* Prepare the Rayleigh quotient for restart */
1183:         if (!ctx->nshifts) {
1184:           DSTruncate(nep->ds,k+l);
1185:           DSGetDimensions(nep->ds,&newn,NULL,NULL,NULL,NULL);
1186:           l = newn-k;
1187:         } else {
1188:           DSGetArray(nep->ds,DS_MAT_Q,&Q);
1189:           DSGetArray(nep->ds,DS_MAT_B,&H);
1190:           DSGetArray(nep->ds,DS_MAT_A,&K);
1191:           for (i=ctx->lock?k:0;i<k+l;i++) {
1192:             H[k+l+i*ldds] = betah*Q[nv-1+i*ldds];
1193:             K[k+l+i*ldds] = betak*Q[nv-1+i*ldds];
1194:           }
1195:           DSRestoreArray(nep->ds,DS_MAT_B,&H);
1196:           DSRestoreArray(nep->ds,DS_MAT_A,&K);
1197:           DSRestoreArray(nep->ds,DS_MAT_Q,&Q);
1198:           DSSetDimensions(nep->ds,k+l,0,nep->nconv,0);
1199:         }
1200:       }
1201:     }
1202:     if (!ctx->lock && l>0) { l += k; k = 0; }

1204:     /* Update S */
1205:     off = nep->nconv*ldds;
1206:     DSGetArray(nep->ds,ctx->nshifts?DS_MAT_Z:DS_MAT_Q,&Q);
1207:     NEPTOARSupdate(S,ld,deg,nq,nep->nconv,k+l-nep->nconv,nv,Q+off,ldds,work+nwu);
1208:     DSRestoreArray(nep->ds,ctx->nshifts?DS_MAT_Z:DS_MAT_Q,&Q);

1210:     /* Copy last column of S */
1211:     PetscMemcpy(S+lds*(k+l),S+lds*nv,lds*sizeof(PetscScalar));
1212:     if (nep->reason == NEP_CONVERGED_ITERATING) {
1213:       if (breakdown) {

1215:         /* Stop if breakdown */
1216:         PetscInfo2(nep,"Breakdown (it=%D norm=%g)\n",nep->its,(double)betah);
1217:         nep->reason = NEP_DIVERGED_BREAKDOWN;
1218:       } else {
1219:         /* Truncate S */
1220:         NEPTOARTrunc(nep,S,ld,deg,&nq,k+l+1,work+nwu,rwork+nrwu);
1221:       }
1222:     }
1223:     nep->nconv = k;
1224:     if (!ctx->nshifts) {
1225:       for (i=0;i<nv;i++) { eigr[i] = nep->eigr[i]; eigi[i] = nep->eigi[i]; }
1226:       NEPNLEIGSBackTransform((PetscObject)nep,nv,eigr,eigi);
1227:     }
1228:     NEPMonitor(nep,nep->its,nconv,eigr,eigi,nep->errest,nv);
1229:   }
1230:   nep->nconv = nconv;
1231:   if (nep->nconv>0) {
1232:     /* Extract invariant pair */
1233:     NEPTOARTrunc(nep,S,ld,deg,&nq,nep->nconv,work+nwu,rwork+nrwu);
1234:     /* Update vectors V = V*S or V=V*S*H */    
1235:     rs1 = nep->nconv;
1236:     if (ctx->nshifts) {
1237:       DSGetArray(nep->ds,DS_MAT_B,&H);
1238:       NEPTOARSupdate(S,ld,deg,rs1,0,nep->nconv,nep->nconv,H,ldds,work+nwu);
1239:       DSRestoreArray(nep->ds,DS_MAT_B,&H);
1240:     }
1241:     PetscMalloc1(rs1*nep->nconv,&pU);
1242:     for (i=0;i<nep->nconv;i++) {
1243:       PetscMemcpy(pU+i*rs1,S+i*lds,rs1*sizeof(PetscScalar));
1244:     }
1245:     MatCreateSeqDense(PETSC_COMM_SELF,rs1,nep->nconv,pU,&U);
1246:     BVSetActiveColumns(nep->V,0,rs1);
1247:     BVMultInPlace(nep->V,U,0,nep->nconv);
1248:     BVSetActiveColumns(nep->V,0,nep->nconv);
1249:     MatDestroy(&U);
1250:     PetscFree(pU);
1251:   }
1252:   /* truncate Schur decomposition and change the state to raw so that
1253:      DSVectors() computes eigenvectors from scratch */
1254:   DSSetDimensions(nep->ds,nep->nconv,0,0,0);
1255:   DSSetState(nep->ds,DS_STATE_RAW);

1257:   PetscFree4(work,rwork,S,Hc);
1258:   /* Map eigenvalues back to the original problem */
1259:   if (!ctx->nshifts) {
1260:     NEPNLEIGSBackTransform((PetscObject)nep,nep->nconv,nep->eigr,nep->eigi);
1261:     PetscFree2(eigr,eigi);
1262:   }
1263:   BVDestroy(&ctx->W);
1264:   return(0);
1265: }

1269: static PetscErrorCode NEPNLEIGSSetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx)
1270: {
1271:   NEP_NLEIGS *nepctx=(NEP_NLEIGS*)nep->data;

1274:   if (fun) nepctx->computesingularities = fun;
1275:   if (ctx) nepctx->singularitiesctx     = ctx;
1276:   return(0);
1277: }

1281: /*@C
1282:    NEPNLEIGSSetSingularitiesFunction - Sets a user function to compute a discretization
1283:    of the singularity set (where T(.) is not analytic).

1285:    Logically Collective on NEP

1287:    Input Parameters:
1288: +  nep - the NEP context
1289: .  fun - user function (if NULL then NEP retains any previously set value)
1290: -  ctx - [optional] user-defined context for private data for the function
1291:          (may be NULL, in which case NEP retains any previously set value)

1293:    Calling Sequence of fun:
1294: $   fun(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *ctx)

1296: +   nep   - the NEP context
1297: .   maxnp - on input number of requested points in the discretization (can be set)
1298: .   xi    - computed values of the discretization
1299: -   ctx   - optional context, as set by NEPNLEIGSSetSingularitiesFunction()

1301:    Note:
1302:    The user-defined function can set a smaller value of maxnp if necessary.

1304:    Level: intermediate

1306: .seealso: NEPNLEIGSGetSingularitiesFunction()
1307: @*/
1308: PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx)
1309: {

1314:   PetscTryMethod(nep,"NEPNLEIGSSetSingularitiesFunction_C",(NEP,PetscErrorCode(*)(NEP,PetscInt*,PetscScalar*,void*),void*),(nep,fun,ctx));
1315:   return(0);
1316: }

1320: static PetscErrorCode NEPNLEIGSGetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx)
1321: {
1322:   NEP_NLEIGS *nepctx=(NEP_NLEIGS*)nep->data;

1325:   if (fun) *fun = nepctx->computesingularities;
1326:   if (ctx) *ctx = nepctx->singularitiesctx;
1327:   return(0);
1328: }

1332: /*@C
1333:    NEPNLEIGSGetSingularitiesFunction - Returns the Function and optionally the user
1334:    provided context for computing a discretization of the singularity set.

1336:    Not Collective

1338:    Input Parameter:
1339: .  nep - the nonlinear eigensolver context

1341:    Output Parameters:
1342: +  fun - location to put the function (or NULL)
1343: -  ctx - location to stash the function context (or NULL)

1345:    Level: advanced

1347: .seealso: NEPNLEIGSSetSingularitiesFunction()
1348: @*/
1349: PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx)
1350: {

1355:   PetscUseMethod(nep,"NEPNLEIGSGetSingularitiesFunction_C",(NEP,PetscErrorCode(**)(NEP,PetscInt*,PetscScalar*,void*),void**),(nep,fun,ctx));
1356:   return(0);
1357: }

1361: static PetscErrorCode NEPNLEIGSSetRestart_NLEIGS(NEP nep,PetscReal keep)
1362: {
1363:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1366:   if (keep==PETSC_DEFAULT) ctx->keep = 0.5;
1367:   else {
1368:     if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]");
1369:     ctx->keep = keep;
1370:   }
1371:   return(0);
1372: }

1376: /*@
1377:    NEPNLEIGSSetRestart - Sets the restart parameter for the NLEIGS
1378:    method, in particular the proportion of basis vectors that must be kept
1379:    after restart.

1381:    Logically Collective on NEP

1383:    Input Parameters:
1384: +  nep  - the nonlinear eigensolver context
1385: -  keep - the number of vectors to be kept at restart

1387:    Options Database Key:
1388: .  -nep_nleigs_restart - Sets the restart parameter

1390:    Notes:
1391:    Allowed values are in the range [0.1,0.9]. The default is 0.5.

1393:    Level: advanced

1395: .seealso: NEPNLEIGSGetRestart()
1396: @*/
1397: PetscErrorCode NEPNLEIGSSetRestart(NEP nep,PetscReal keep)
1398: {

1404:   PetscTryMethod(nep,"NEPNLEIGSSetRestart_C",(NEP,PetscReal),(nep,keep));
1405:   return(0);
1406: }

1410: static PetscErrorCode NEPNLEIGSGetRestart_NLEIGS(NEP nep,PetscReal *keep)
1411: {
1412:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1415:   *keep = ctx->keep;
1416:   return(0);
1417: }

1421: /*@
1422:    NEPNLEIGSGetRestart - Gets the restart parameter used in the NLEIGS method.

1424:    Not Collective

1426:    Input Parameter:
1427: .  nep - the nonlinear eigensolver context

1429:    Output Parameter:
1430: .  keep - the restart parameter

1432:    Level: advanced

1434: .seealso: NEPNLEIGSSetRestart()
1435: @*/
1436: PetscErrorCode NEPNLEIGSGetRestart(NEP nep,PetscReal *keep)
1437: {

1443:   PetscUseMethod(nep,"NEPNLEIGSGetRestart_C",(NEP,PetscReal*),(nep,keep));
1444:   return(0);
1445: }

1449: static PetscErrorCode NEPNLEIGSSetLocking_NLEIGS(NEP nep,PetscBool lock)
1450: {
1451:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1454:   ctx->lock = lock;
1455:   return(0);
1456: }

1460: /*@
1461:    NEPNLEIGSSetLocking - Choose between locking and non-locking variants of
1462:    the NLEIGS method.

1464:    Logically Collective on NEP

1466:    Input Parameters:
1467: +  nep  - the nonlinear eigensolver context
1468: -  lock - true if the locking variant must be selected

1470:    Options Database Key:
1471: .  -nep_nleigs_locking - Sets the locking flag

1473:    Notes:
1474:    The default is to lock converged eigenpairs when the method restarts.
1475:    This behaviour can be changed so that all directions are kept in the
1476:    working subspace even if already converged to working accuracy (the
1477:    non-locking variant).

1479:    Level: advanced

1481: .seealso: NEPNLEIGSGetLocking()
1482: @*/
1483: PetscErrorCode NEPNLEIGSSetLocking(NEP nep,PetscBool lock)
1484: {

1490:   PetscTryMethod(nep,"NEPNLEIGSSetLocking_C",(NEP,PetscBool),(nep,lock));
1491:   return(0);
1492: }

1496: static PetscErrorCode NEPNLEIGSGetLocking_NLEIGS(NEP nep,PetscBool *lock)
1497: {
1498:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1501:   *lock = ctx->lock;
1502:   return(0);
1503: }

1507: /*@
1508:    NEPNLEIGSGetLocking - Gets the locking flag used in the NLEIGS method.

1510:    Not Collective

1512:    Input Parameter:
1513: .  nep - the nonlinear eigensolver context

1515:    Output Parameter:
1516: .  lock - the locking flag

1518:    Level: advanced

1520: .seealso: NEPNLEIGSSetLocking()
1521: @*/
1522: PetscErrorCode NEPNLEIGSGetLocking(NEP nep,PetscBool *lock)
1523: {

1529:   PetscUseMethod(nep,"NEPNLEIGSGetLocking_C",(NEP,PetscBool*),(nep,lock));
1530:   return(0);
1531: }

1535: static PetscErrorCode NEPNLEIGSSetInterpolation_NLEIGS(NEP nep,PetscReal tol,PetscInt maxits)
1536: {
1537:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1540:   if (tol == PETSC_DEFAULT) {
1541:     ctx->ddtol = PETSC_DEFAULT;
1542:     nep->state = NEP_STATE_INITIAL;
1543:   } else {
1544:     if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
1545:     ctx->ddtol = tol;
1546:   }
1547:   if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
1548:     ctx->ddmaxit = 0;
1549:     nep->state   = NEP_STATE_INITIAL;
1550:   } else {
1551:     if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
1552:     ctx->ddmaxit = maxits;
1553:   }
1554:   return(0);
1555: }

1559: /*@
1560:    NEPNLEIGSSetInterpolation - Sets the tolerance and maximum iteration count used
1561:    by the NLEIGS method when building the interpolation via divided differences.

1563:    Logically Collective on NEP

1565:    Input Parameters:
1566: +  nep    - the nonlinear eigensolver context
1567: .  tol    - the convergence tolerance
1568: -  maxits - maximum number of iterations to use

1570:    Options Database Key:
1571: +  -nep_nleigs_interpolation_tol <tol> - Sets the convergence tolerance
1572: -  -nep_nleigs_interpolation_max_it <maxits> - Sets the maximum number of iterations

1574:    Notes:
1575:    Use PETSC_DEFAULT for either argument to assign a reasonably good value.

1577:    Level: advanced

1579: .seealso: NEPNLEIGSGetInterpolation()
1580: @*/
1581: PetscErrorCode NEPNLEIGSSetInterpolation(NEP nep,PetscReal tol,PetscInt maxits)
1582: {

1589:   PetscTryMethod(nep,"NEPNLEIGSSetInterpolation_C",(NEP,PetscReal,PetscInt),(nep,tol,maxits));
1590:   return(0);
1591: }

1595: static PetscErrorCode NEPNLEIGSGetInterpolation_NLEIGS(NEP nep,PetscReal *tol,PetscInt *maxits)
1596: {
1597:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1600:   if (tol)    *tol    = ctx->ddtol;
1601:   if (maxits) *maxits = ctx->ddmaxit;
1602:   return(0);
1603: }

1607: /*@
1608:    NEPNLEIGSGetInterpolation - Gets the tolerance and maximum iteration count used
1609:    by the NLEIGS method when building the interpolation via divided differences.

1611:    Not Collective

1613:    Input Parameter:
1614: .  nep - the nonlinear eigensolver context

1616:    Output Parameter:
1617: +  tol    - the convergence tolerance
1618: -  maxits - maximum number of iterations

1620:    Level: advanced

1622: .seealso: NEPNLEIGSSetInterpolation()
1623: @*/
1624: PetscErrorCode NEPNLEIGSGetInterpolation(NEP nep,PetscReal *tol,PetscInt *maxits)
1625: {

1630:   PetscTryMethod(nep,"NEPNLEIGSGetInterpolation_C",(NEP,PetscReal*,PetscInt*),(nep,tol,maxits));
1631:   return(0);
1632: }

1636: static PetscErrorCode NEPNLEIGSSetTrueResidual_NLEIGS(NEP nep,PetscBool trueres)
1637: {
1638:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1641:   ctx->trueres = trueres;
1642:   return(0);
1643: }

1647: /*@
1648:    NEPNLEIGSSetTrueResidual - Specifies if the solver must compute the true residual
1649:    explicitly or not.

1651:    Logically Collective on NEP

1653:    Input Parameters:
1654: +  nep - the nonlinear eigensolver context
1655: -  trueres - whether true residuals are required or not

1657:    Options Database Key:
1658: .  -nep_nleigs_true_residual <boolean> - Sets/resets the boolean flag 'trueres'

1660:    Notes:
1661:    If the user sets trueres=PETSC_TRUE then the solver explicitly computes
1662:    the true residual norm for each eigenpair approximation, and uses it for
1663:    convergence testing. The default is to use the cheaper approximation 
1664:    available from the (rational) Krylov iteration.

1666:    Level: advanced

1668: .seealso: NEPNLEIGSGetTrueResidual()
1669: @*/
1670: PetscErrorCode NEPNLEIGSSetTrueResidual(NEP nep,PetscBool trueres)
1671: {

1677:   PetscTryMethod(nep,"NEPNLEIGSSetTrueResidual_C",(NEP,PetscBool),(nep,trueres));
1678:   return(0);
1679: }

1683: static PetscErrorCode NEPNLEIGSGetTrueResidual_NLEIGS(NEP nep,PetscBool *trueres)
1684: {
1685:   NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data;

1688:   *trueres = ctx->trueres;
1689:   return(0);
1690: }

1694: /*@
1695:    NEPNLEIGSGetTrueResidual - Returns the flag indicating whether true
1696:    residuals must be computed explicitly or not.

1698:    Not Collective

1700:    Input Parameter:
1701: .  nep - the nonlinear eigensolver context

1703:    Output Parameter:
1704: .  trueres - the returned flag

1706:    Level: advanced

1708: .seealso: NEPNLEIGSSetTrueResidual()
1709: @*/
1710: PetscErrorCode NEPNLEIGSGetTrueResidual(NEP nep,PetscBool *trueres)
1711: {

1717:   PetscTryMethod(nep,"NEPNLEIGSGetTrueResidual_C",(NEP,PetscBool*),(nep,trueres));
1718:   return(0);
1719: }

1723: static PetscErrorCode NEPNLEIGSSetRKShifts_NLEIGS(NEP nep,PetscInt ns,PetscScalar *shifts)
1724: {
1726:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
1727:   PetscInt       i;

1730:   if (ns<=0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"Number of shifts must be positive");
1731:   if (ctx->nshifts) { PetscFree(ctx->shifts); }
1732:   for (i=0;i<ctx->nshiftsw;i++) { KSPDestroy(&ctx->ksp[i]); }
1733:   PetscFree(ctx->ksp);
1734:   ctx->ksp = NULL;
1735:   PetscMalloc1(ns,&ctx->shifts);
1736:   for (i=0;i<ns;i++) ctx->shifts[i] = shifts[i];
1737:   ctx->nshifts = ns;
1738:   nep->state   = NEP_STATE_INITIAL;
1739:   return(0);
1740: }

1744: /*@C
1745:    NEPNLEIGSSetRKShifts - Sets a list of shifts to be used in the Rational
1746:    Krylov method.

1748:    Logically Collective on NEP

1750:    Input Parameters:
1751: +  nep    - the nonlinear eigensolver context
1752: .  ns     - number of shifts
1753: -  shifts - array of scalar values specifying the shifts

1755:    Options Database Key:
1756: .  -nep_nleigs_rk_shifts - Sets the list of shifts

1758:    Notes:
1759:    If only one shift is provided, the subspace is built with the simpler
1760:    shift-and-invert Krylov-Schur.

1762:    In the case of real scalars, complex shifts are not allowed. In the
1763:    command line, a comma-separated list of complex values can be provided with
1764:    the format [+/-][realnumber][+/-]realnumberi with no spaces, e.g.
1765:    -nep_nleigs_rk_shifts 1.0+2.0i,1.5+2.0i,1.0+1.5i

1767:    Level: advanced

1769: .seealso: NEPNLEIGSGetRKShifts()
1770: @*/
1771: PetscErrorCode NEPNLEIGSSetRKShifts(NEP nep,PetscInt ns,PetscScalar *shifts)
1772: {

1779:   PetscTryMethod(nep,"NEPNLEIGSSetRKShifts_C",(NEP,PetscInt,PetscScalar*),(nep,ns,shifts));
1780:   return(0);
1781: }

1785: static PetscErrorCode NEPNLEIGSGetRKShifts_NLEIGS(NEP nep,PetscInt *ns,PetscScalar **shifts)
1786: {
1788:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
1789:   PetscInt       i;

1792:   *ns = ctx->nshifts;
1793:   if (ctx->nshifts) {
1794:     PetscMalloc1(ctx->nshifts,shifts);
1795:     for (i=0;i<ctx->nshifts;i++) (*shifts)[i] = ctx->shifts[i];
1796:   }
1797:   return(0);
1798: }

1802: /*@C
1803:    NEPNLEIGSGetRKShifts - Gets the list of shifts used in the Rational
1804:    Krylov method.

1806:    Not Collective

1808:    Input Parameter:
1809: .  nep - the nonlinear eigensolver context

1811:    Output Parameter:
1812: +  ns     - number of shifts
1813: -  shifts - array of shifts

1815:    Level: advanced

1817: .seealso: NEPNLEIGSSetRKShifts()
1818: @*/
1819: PetscErrorCode NEPNLEIGSGetRKShifts(NEP nep,PetscInt *ns,PetscScalar **shifts)
1820: {

1827:   PetscTryMethod(nep,"NEPNLEIGSGetRKShifts_C",(NEP,PetscInt*,PetscScalar**),(nep,ns,shifts));
1828:   return(0);
1829: }

1831: #define SHIFTMAX 30

1835: PetscErrorCode NEPSetFromOptions_NLEIGS(PetscOptionItems *PetscOptionsObject,NEP nep)
1836: {
1838:   NEP_NLEIGS     *ctx = (NEP_NLEIGS*)nep->data;
1839:   PetscInt       i,k;
1840:   PetscBool      flg1,flg2,b;
1841:   PetscReal      r;
1842:   PetscScalar    array[SHIFTMAX];
1843:   PC             pc;
1844:   PCType         pctype;
1845:   KSPType        ksptype;

1848:   PetscOptionsHead(PetscOptionsObject,"NEP NLEIGS Options");
1849:   PetscOptionsReal("-nep_nleigs_restart","Proportion of vectors kept after restart","NEPNLEIGSSetRestart",0.5,&r,&flg1);
1850:   if (flg1) {
1851:     NEPNLEIGSSetRestart(nep,r);
1852:   }
1853:   PetscOptionsBool("-nep_nleigs_locking","Choose between locking and non-locking variants","NEPNLEIGSSetLocking",PETSC_FALSE,&b,&flg1);
1854:   if (flg1) {
1855:     NEPNLEIGSSetLocking(nep,b);
1856:   }
1857:   PetscOptionsBool("-nep_nleigs_true_residual","Compute true residuals explicitly","NEPNLEIGSSetTrueResidual",PETSC_FALSE,&b,&flg1);
1858:   if (flg1) {
1859:     NEPNLEIGSSetTrueResidual(nep,b);
1860:   }
1861:   NEPNLEIGSGetInterpolation(nep,&r,&i);
1862:   if (!i) i = PETSC_DEFAULT;
1863:   PetscOptionsInt("-nep_nleigs_interpolation_max_it","Maximum number of terms for interpolation via divided differences","NEPNLEIGSSetInterpolation",i,&i,&flg1);
1864:   PetscOptionsReal("-nep_nleigs_interpolation_tol","Tolerance for interpolation via divided differences","NEPNLEIGSSetInterpolation",r,&r,&flg2);
1865:   if (flg1 || flg2) {
1866:     NEPNLEIGSSetInterpolation(nep,r,i);
1867:   }
1868:   k = SHIFTMAX;
1869:   for (i=0;i<k;i++) array[i] = 0;
1870:   PetscOptionsScalarArray("-nep_nleigs_rk_shifts","Shifts for Rational Krylov","NEPNLEIGSSetRKShifts",array,&k,&flg1);
1871:   if (flg1) {
1872:     NEPNLEIGSSetRKShifts(nep,k,array);
1873:   }

1875:   if (!ctx->ksp) { NEPNLEIGSGetKSPs(nep,&ctx->ksp); }
1876:   for (i=0;i<ctx->nshiftsw;i++) {
1877:     KSPGetPC(ctx->ksp[i],&pc);
1878:     KSPGetType(ctx->ksp[i],&ksptype);
1879:     PCGetType(pc,&pctype);
1880:     if (!pctype && !ksptype) {
1881:       KSPSetType(ctx->ksp[i],KSPPREONLY);
1882:       PCSetType(pc,PCLU);
1883:     }
1884:     KSPSetOperators(ctx->ksp[i],nep->function,nep->function_pre);
1885:     KSPSetFromOptions(ctx->ksp[i]);
1886:   }
1887:   PetscOptionsTail();
1888:   return(0);
1889: }

1893: static PetscErrorCode NEPNLEIGSGetKSPs_NLEIGS(NEP nep,KSP **ksp)
1894: {
1896:   NEP_NLEIGS     *ctx = (NEP_NLEIGS*)nep->data;
1897:   PetscInt       i;

1900:   if (!ctx->ksp) {
1901:     NEPNLEIGSSetShifts(nep);
1902:     PetscMalloc1(ctx->nshiftsw,&ctx->ksp);
1903:     for (i=0;i<ctx->nshiftsw;i++) {
1904:       KSPCreate(PetscObjectComm((PetscObject)nep),&ctx->ksp[i]);
1905:       KSPSetOptionsPrefix(ctx->ksp[i],((PetscObject)nep)->prefix);
1906:       KSPAppendOptionsPrefix(ctx->ksp[i],"nep_nleigs_");
1907:       PetscObjectIncrementTabLevel((PetscObject)ctx->ksp[i],(PetscObject)nep,1);
1908:       PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp[i]);
1909:       KSPSetErrorIfNotConverged(ctx->ksp[i],PETSC_TRUE);
1910:     }
1911:   }
1912:   *ksp = ctx->ksp;
1913:   return(0);
1914: }

1918: /*@C
1919:    NEPNLEIGSGetKSPs - Retrieve the array of linear solver objects associated with
1920:    the nonlinear eigenvalue solver.

1922:    Not Collective

1924:    Input Parameter:
1925: .  nep - nonlinear eigenvalue solver

1927:    Output Parameter:
1928: .  ksp - array of linear solver object

1930:    Level: advanced
1931: @*/
1932: PetscErrorCode NEPNLEIGSGetKSPs(NEP nep,KSP **ksp)
1933: {

1939:   PetscUseMethod(nep,"NEPNLEIGSGetKSPs_C",(NEP,KSP**),(nep,ksp));
1940:   return(0);
1941: }

1945: PetscErrorCode NEPView_NLEIGS(NEP nep,PetscViewer viewer)
1946: {
1948:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;
1949:   PetscBool      isascii;
1950:   PetscInt       i;
1951:   char           str[50];

1954:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
1955:   if (isascii) {
1956:     PetscViewerASCIIPrintf(viewer,"  NLEIGS: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));
1957:     PetscViewerASCIIPrintf(viewer,"  NLEIGS: using the %slocking variant\n",ctx->lock?"":"non-");
1958:     PetscViewerASCIIPrintf(viewer,"  NLEIGS: divided difference terms: used=%D, max=%D\n",ctx->nmat-1,ctx->ddmaxit);
1959:     PetscViewerASCIIPrintf(viewer,"  NLEIGS: tolerance for divided difference convergence: %g\n",(double)ctx->ddtol);
1960:     if (ctx->nshifts) {
1961:       PetscViewerASCIIPrintf(viewer,"  NLEIGS: RK shifts: ");
1962:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
1963:       for (i=0;i<ctx->nshifts;i++) {
1964:         SlepcSNPrintfScalar(str,50,ctx->shifts[i],PETSC_FALSE);
1965:         PetscViewerASCIIPrintf(viewer,"%s%s",str,(i<ctx->nshifts-1)?",":"");
1966:       }
1967:       PetscViewerASCIIPrintf(viewer,"\n");
1968:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
1969:     }
1970:     if (ctx->trueres) { PetscViewerASCIIPrintf(viewer,"  NLEIGS: computing true residuals for convergence check\n"); }
1971:     if (!ctx->ksp) { NEPNLEIGSGetKSPs(nep,&ctx->ksp); }
1972:     PetscViewerASCIIPushTab(viewer);
1973:     KSPView(ctx->ksp[0],viewer);
1974:     PetscViewerASCIIPopTab(viewer);
1975:   }
1976:   return(0);
1977: }

1981: PetscErrorCode NEPReset_NLEIGS(NEP nep)
1982: {
1984:   PetscInt       k;
1985:   NEP_NLEIGS     *ctx=(NEP_NLEIGS*)nep->data;

1988:   if (nep->fui==NEP_USER_INTERFACE_SPLIT) {
1989:     PetscFree(ctx->coeffD);
1990:   } else {
1991:     for (k=0;k<ctx->nmat;k++) { MatDestroy(&ctx->D[k]); }
1992:   }
1993:   if (ctx->vrn) {
1994:     VecDestroy(&ctx->vrn);
1995:   }
1996:   return(0);
1997: }

2001: PetscErrorCode NEPDestroy_NLEIGS(NEP nep)
2002: {
2004:   PetscInt       k;
2005:   NEP_NLEIGS     *ctx = (NEP_NLEIGS*)nep->data;

2008:   for (k=0;k<ctx->nshiftsw;k++) { KSPDestroy(&ctx->ksp[k]); }
2009:   PetscFree(ctx->ksp);
2010:   if (ctx->nshifts) { PetscFree(ctx->shifts); }
2011:   PetscFree4(ctx->s,ctx->xi,ctx->beta,ctx->D);
2012:   PetscFree(nep->data);
2013:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetSingularitiesFunction_C",NULL);
2014:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetSingularitiesFunction_C",NULL);
2015:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRestart_C",NULL);
2016:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRestart_C",NULL);
2017:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetLocking_C",NULL);
2018:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetLocking_C",NULL);
2019:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetInterpolation_C",NULL);
2020:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetInterpolation_C",NULL);
2021:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetTrueResidual_C",NULL);
2022:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetTrueResidual_C",NULL);
2023:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRKShifts_C",NULL);
2024:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRKShifts_C",NULL);
2025:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetKSPs_C",NULL);
2026:   return(0);
2027: }

2031: PETSC_EXTERN PetscErrorCode NEPCreate_NLEIGS(NEP nep)
2032: {
2034:   NEP_NLEIGS     *ctx;

2037:   PetscNewLog(nep,&ctx);
2038:   nep->data = (void*)ctx;
2039:   ctx->lock    = PETSC_TRUE;
2040:   ctx->ddtol   = PETSC_DEFAULT;
2041:   ctx->ddmaxit = 0;
2042:   ctx->trueres = PETSC_FALSE;
2043:   ctx->nshifts = 0;

2045:   nep->ops->solve          = NEPSolve_NLEIGS;
2046:   nep->ops->setup          = NEPSetUp_NLEIGS;
2047:   nep->ops->setfromoptions = NEPSetFromOptions_NLEIGS;
2048:   nep->ops->view           = NEPView_NLEIGS;
2049:   nep->ops->destroy        = NEPDestroy_NLEIGS;
2050:   nep->ops->reset          = NEPReset_NLEIGS;
2051:   nep->ops->computevectors = NEPComputeVectors_Schur;
2052:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetSingularitiesFunction_C",NEPNLEIGSSetSingularitiesFunction_NLEIGS);
2053:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetSingularitiesFunction_C",NEPNLEIGSGetSingularitiesFunction_NLEIGS);
2054:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRestart_C",NEPNLEIGSSetRestart_NLEIGS);
2055:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRestart_C",NEPNLEIGSGetRestart_NLEIGS);
2056:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetLocking_C",NEPNLEIGSSetLocking_NLEIGS);
2057:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetLocking_C",NEPNLEIGSGetLocking_NLEIGS);
2058:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetInterpolation_C",NEPNLEIGSSetInterpolation_NLEIGS);
2059:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetInterpolation_C",NEPNLEIGSGetInterpolation_NLEIGS);
2060:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetTrueResidual_C",NEPNLEIGSSetTrueResidual_NLEIGS);
2061:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetTrueResidual_C",NEPNLEIGSGetTrueResidual_NLEIGS);
2062:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRKShifts_C",NEPNLEIGSSetRKShifts_NLEIGS);
2063:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRKShifts_C",NEPNLEIGSGetRKShifts_NLEIGS);
2064:   PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetKSPs_C",NEPNLEIGSGetKSPs_NLEIGS);
2065:   return(0);
2066: }

slepc-3.7.4/src/nep/impls/nleigs/nleigs.c0000644000175000017500000022112013107004621017564 0ustar jromanjroman/* SLEPc nonlinear eigensolver: "nleigs" Method: NLEIGS Algorithm: Fully rational Krylov method for nonlinear eigenvalue problems. References: [1] S. Guttel et al., "NLEIGS: A class of robust fully rational Krylov method for nonlinear eigenvalue problems", SIAM J. Sci. Comput. 36(6):A2842-A2864, 2014. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ #include #define MAX_LBPOINTS 100 #define NDPOINTS 1e4 #define MAX_NSHIFTS 100 typedef struct { PetscInt nmat; /* number of interpolation points */ PetscScalar *s,*xi; /* Leja-Bagby points */ PetscScalar *beta; /* scaling factors */ Mat *D; /* divided difference matrices */ PetscScalar *coeffD; /* coefficients for divided differences in split form */ PetscInt nshifts; /* provided number of shifts */ PetscScalar *shifts; /* user-provided shifts for the Rational Krylov variant */ PetscInt nshiftsw; /* actual number of shifts (1 if Krylov-Schur) */ PetscReal ddtol; /* tolerance for divided difference convergence */ PetscInt ddmaxit; /* maximum number of divided difference terms */ BV W; /* auxiliary BV object */ PetscReal keep; /* restart parameter */ PetscBool lock; /* locking/non-locking variant */ PetscBool trueres; /* whether the true residual norm must be computed */ PetscInt idxrk; /* index of next shift to use */ KSP *ksp; /* ksp array for storing shift factorizations */ Vec vrn; /* random vector with normally distributed value */ void *singularitiesctx; PetscErrorCode (*computesingularities)(NEP,PetscInt*,PetscScalar*,void*); } NEP_NLEIGS; typedef struct { PetscInt nmat; PetscScalar coeff[MAX_NSHIFTS]; Mat A[MAX_NSHIFTS]; Vec t; } ShellMatCtx; #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetShifts" PETSC_STATIC_INLINE PetscErrorCode NEPNLEIGSSetShifts(NEP nep) { NEP_NLEIGS *ctx = (NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (!ctx->nshifts) { ctx->shifts = &nep->target; ctx->nshiftsw = 1; } else ctx->nshiftsw = ctx->nshifts; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSBackTransform" static PetscErrorCode NEPNLEIGSBackTransform(PetscObject ob,PetscInt n,PetscScalar *valr,PetscScalar *vali) { NEP nep; PetscInt j; #if !defined(PETSC_USE_COMPLEX) PetscScalar t; #endif PetscFunctionBegin; nep = (NEP)ob; #if !defined(PETSC_USE_COMPLEX) for (j=0;jtarget; else { t = valr[j] * valr[j] + vali[j] * vali[j]; valr[j] = valr[j] / t + nep->target; vali[j] = - vali[j] / t; } } #else for (j=0;jtarget; } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSLejaBagbyPoints" static PetscErrorCode NEPNLEIGSLejaBagbyPoints(NEP nep) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscInt i,k,ndpt=NDPOINTS,ndptx=NDPOINTS; PetscScalar *ds,*dsi,*dxi,*nrs,*nrxi,*s=ctx->s,*xi=ctx->xi,*beta=ctx->beta; PetscReal maxnrs,minnrxi; PetscFunctionBegin; ierr = PetscMalloc5(ndpt+1,&ds,ndpt+1,&dsi,ndpt,&dxi,ndpt+1,&nrs,ndpt,&nrxi);CHKERRQ(ierr); /* Discretize the target region boundary */ ierr = RGComputeContour(nep->rg,ndpt,ds,dsi);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) for (i=0;icomputesingularities) { ierr = (ctx->computesingularities)(nep,&ndptx,dxi,ctx->singularitiesctx);CHKERRQ(ierr); } else ndptx = 0; /* Look for Leja-Bagby points in the discretization sets */ s[0] = ds[0]; xi[0] = (ndptx>0)?dxi[0]:PETSC_INFINITY; beta[0] = 1.0; /* scaling factors are also computed here */ maxnrs = 0.0; minnrxi = PETSC_MAX_REAL; for (i=0;i=maxnrs) {maxnrs = PetscAbsScalar(nrs[i]); s[1] = ds[i];} } for (i=1;iddmaxit;k++) { maxnrs = 0.0; minnrxi = PETSC_MAX_REAL; for (i=0;imaxnrs) {maxnrs = PetscAbsScalar(nrs[i]); s[k] = ds[i];} } if (ndptx>k) { for (i=1;idata; PetscInt i; PetscScalar *beta=ctx->beta,*s=ctx->s,*xi=ctx->xi; PetscFunctionBegin; b[0] = 1.0/beta[0]; for (i=0;iA[0],x,y);CHKERRQ(ierr); if (ctx->coeff[0]!=1.0) { ierr = VecScale(y,ctx->coeff[0]);CHKERRQ(ierr); } for (i=1;inmat;i++) { ierr = MatMult(ctx->A[i],x,ctx->t);CHKERRQ(ierr); ierr = VecAXPY(y,ctx->coeff[i],ctx->t);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMultTranspose_Fun" static PetscErrorCode MatMultTranspose_Fun(Mat A,Vec x,Vec y) { PetscErrorCode ierr; ShellMatCtx *ctx; PetscInt i; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = MatMultTranspose(ctx->A[0],x,y);CHKERRQ(ierr); if (ctx->coeff[0]!=1.0) { ierr = VecScale(y,ctx->coeff[0]);CHKERRQ(ierr); } for (i=1;inmat;i++) { ierr = MatMultTranspose(ctx->A[i],x,ctx->t);CHKERRQ(ierr); ierr = VecAXPY(y,ctx->coeff[i],ctx->t);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatGetDiagonal_Fun" static PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag) { PetscErrorCode ierr; ShellMatCtx *ctx; PetscInt i; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = MatGetDiagonal(ctx->A[0],diag);CHKERRQ(ierr); if (ctx->coeff[0]!=1.0) { ierr = VecScale(diag,ctx->coeff[0]);CHKERRQ(ierr); } for (i=1;inmat;i++) { ierr = MatGetDiagonal(ctx->A[i],ctx->t);CHKERRQ(ierr); ierr = VecAXPY(diag,ctx->coeff[i],ctx->t);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatDuplicate_Fun" static PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B) { PetscInt n,i; ShellMatCtx *ctxnew,*ctx; void (*fun)(); PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = PetscNew(&ctxnew);CHKERRQ(ierr); ctxnew->nmat = ctx->nmat; for (i=0;inmat;i++) { ierr = PetscObjectReference((PetscObject)ctx->A[i]);CHKERRQ(ierr); ctxnew->A[i] = ctx->A[i]; ctxnew->coeff[i] = ctx->coeff[i]; } ierr = MatGetSize(ctx->A[0],&n,NULL);CHKERRQ(ierr); ierr = VecDuplicate(ctx->t,&ctxnew->t);CHKERRQ(ierr); ierr = MatCreateShell(PETSC_COMM_WORLD,n,n,n,n,(void*)ctxnew,B);CHKERRQ(ierr); ierr = MatShellGetOperation(A,MATOP_MULT,&fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_MULT,fun);CHKERRQ(ierr); ierr = MatShellGetOperation(A,MATOP_MULT_TRANSPOSE,&fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_MULT_TRANSPOSE,fun);CHKERRQ(ierr); ierr = MatShellGetOperation(A,MATOP_GET_DIAGONAL,&fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_GET_DIAGONAL,fun);CHKERRQ(ierr); ierr = MatShellGetOperation(A,MATOP_DUPLICATE,&fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_DUPLICATE,fun);CHKERRQ(ierr); ierr = MatShellGetOperation(A,MATOP_DESTROY,&fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_DESTROY,fun);CHKERRQ(ierr); ierr = MatShellGetOperation(A,MATOP_AXPY,&fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*B,MATOP_AXPY,fun);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatDestroy_Fun" static PetscErrorCode MatDestroy_Fun(Mat A) { ShellMatCtx *ctx; PetscErrorCode ierr; PetscInt i; PetscFunctionBeginUser; if (A) { ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = MatDestroy(&ctx->A[i]);CHKERRQ(ierr); } ierr = VecDestroy(&ctx->t);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatAXPY_Fun" static PetscErrorCode MatAXPY_Fun(Mat Y,PetscScalar a,Mat X,MatStructure str) { ShellMatCtx *ctxY,*ctxX; PetscErrorCode ierr; PetscInt i,j; PetscBool found; PetscFunctionBeginUser; ierr = MatShellGetContext(Y,(void**)&ctxY);CHKERRQ(ierr); ierr = MatShellGetContext(X,(void**)&ctxX);CHKERRQ(ierr); for (i=0;inmat;i++) { found = PETSC_FALSE; for (j=0;!found&&jnmat;j++) { if (ctxX->A[i]==ctxY->A[j]) { found = PETSC_TRUE; ctxY->coeff[j] += a*ctxX->coeff[i]; } } if (!found) { ctxY->coeff[ctxY->nmat] = a*ctxX->coeff[i]; ctxY->A[ctxY->nmat++] = ctxX->A[i]; ierr = PetscObjectReference((PetscObject)ctxX->A[i]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatScale_Fun" static PetscErrorCode MatScale_Fun(Mat M,PetscScalar a) { ShellMatCtx *ctx; PetscErrorCode ierr; PetscInt i; PetscFunctionBeginUser; ierr = MatShellGetContext(M,(void**)&ctx);CHKERRQ(ierr); for (i=0;inmat;i++) ctx->coeff[i] *= a; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NLEIGSMatToMatShellArray" static PetscErrorCode NLEIGSMatToMatShellArray(Mat M,Mat *Ms) { PetscErrorCode ierr; ShellMatCtx *ctx; PetscInt n; PetscBool has; PetscFunctionBegin; ierr = MatHasOperation(M,MATOP_DUPLICATE,&has);CHKERRQ(ierr); if (!has) SETERRQ(PetscObjectComm((PetscObject)M),1,"MatDuplicate operation required"); ierr = PetscNew(&ctx);CHKERRQ(ierr); ierr = MatDuplicate(M,MAT_COPY_VALUES,&ctx->A[0]);CHKERRQ(ierr); ctx->nmat = 1; ctx->coeff[0] = 1.0; ierr = MatCreateVecs(M,&ctx->t,NULL);CHKERRQ(ierr); ierr = MatGetSize(M,&n,NULL);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)M),n,n,n,n,(void*)ctx,Ms);CHKERRQ(ierr); ierr = MatShellSetOperation(*Ms,MATOP_MULT,(void(*)())MatMult_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*Ms,MATOP_MULT_TRANSPOSE,(void(*)())MatMultTranspose_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*Ms,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*Ms,MATOP_DUPLICATE,(void(*)())MatDuplicate_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*Ms,MATOP_DESTROY,(void(*)())MatDestroy_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*Ms,MATOP_AXPY,(void(*)())MatAXPY_Fun);CHKERRQ(ierr); ierr = MatShellSetOperation(*Ms,MATOP_SCALE,(void(*)())MatScale_Fun);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSNormEstimation" static PetscErrorCode NEPNLEIGSNormEstimation(NEP nep,Mat M,PetscReal *norm,Vec *w) { PetscScalar *z,*x,*y; PetscReal tr; Vec X=w[0],Y=w[1]; PetscInt n,i; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscRandom rand; PetscErrorCode ierr; PetscFunctionBegin; if (!ctx->vrn) { /* generate a random vector with normally distributed entries with the Box-Muller transform */ ierr = BVGetRandomContext(nep->V,&rand);CHKERRQ(ierr); ierr = MatCreateVecs(M,&ctx->vrn,NULL);CHKERRQ(ierr); ierr = VecSetRandom(X,rand);CHKERRQ(ierr); ierr = VecSetRandom(Y,rand);CHKERRQ(ierr); ierr = VecGetLocalSize(ctx->vrn,&n);CHKERRQ(ierr); ierr = VecGetArray(ctx->vrn,&z);CHKERRQ(ierr); ierr = VecGetArray(X,&x);CHKERRQ(ierr); ierr = VecGetArray(Y,&y);CHKERRQ(ierr); for (i=0;ivrn,&z);CHKERRQ(ierr); ierr = VecRestoreArray(X,&x);CHKERRQ(ierr); ierr = VecRestoreArray(Y,&y);CHKERRQ(ierr); ierr = VecNorm(ctx->vrn,NORM_2,&tr);CHKERRQ(ierr); ierr = VecScale(ctx->vrn,1/tr);CHKERRQ(ierr); } /* matrix-free norm estimator of Ipsen http://www4.ncsu.edu/~ipsen/ps/slides_ima.pdf */ ierr = MatGetSize(M,&n,NULL);CHKERRQ(ierr); ierr = MatMult(M,ctx->vrn,X);CHKERRQ(ierr); ierr = VecNorm(X,NORM_2,norm);CHKERRQ(ierr); *norm *= PetscSqrtReal((PetscReal)n); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSDividedDifferences_split" static PetscErrorCode NEPNLEIGSDividedDifferences_split(NEP nep) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscInt k,j,i; PetscReal norm0,norm,max; PetscScalar *s=ctx->s,*beta=ctx->beta,*b,alpha,*coeffs; Mat T,Ts; PetscBool shell; PetscFunctionBegin; ierr = PetscMalloc1(nep->nt*ctx->ddmaxit,&ctx->coeffD);CHKERRQ(ierr); ierr = PetscMalloc2(ctx->ddmaxit+1,&b,ctx->ddmaxit+1,&coeffs);CHKERRQ(ierr); max = 0.0; for (j=0;jnt;j++) { ierr = FNEvaluateFunction(nep->f[j],s[0],ctx->coeffD+j);CHKERRQ(ierr); ctx->coeffD[j] /= beta[0]; max = PetscMax(PetscAbsScalar(ctx->coeffD[j]),max); } norm0 = max; ctx->nmat = ctx->ddmaxit; for (k=1;kddmaxit;k++) { ierr = NEPNLEIGSEvalNRTFunct(nep,k,s[k],b);CHKERRQ(ierr); max = 0.0; for (i=0;int;i++) { ierr = FNEvaluateFunction(nep->f[i],s[k],ctx->coeffD+k*nep->nt+i);CHKERRQ(ierr); for (j=0;jcoeffD[k*nep->nt+i] -= b[j]*ctx->coeffD[i+nep->nt*j]; } ctx->coeffD[k*nep->nt+i] /= b[k]; max = PetscMax(PetscAbsScalar(ctx->coeffD[k*nep->nt+i]),max); } norm = max; if (norm/norm0 < ctx->ddtol) { ctx->nmat = k+1; break; } } if (!ctx->ksp) { ierr = NEPNLEIGSGetKSPs(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)nep->A[0],MATSHELL,&shell);CHKERRQ(ierr); for (i=0;inshiftsw;i++) { ierr = NEPNLEIGSEvalNRTFunct(nep,ctx->nmat-1,ctx->shifts[i],coeffs);CHKERRQ(ierr); if (!shell) { ierr = MatDuplicate(nep->A[0],MAT_COPY_VALUES,&T);CHKERRQ(ierr); } else { ierr = NLEIGSMatToMatShellArray(nep->A[0],&T);CHKERRQ(ierr); } alpha = 0.0; for (j=0;jnmat-1;j++) alpha += coeffs[j]*ctx->coeffD[j*nep->nt]; ierr = MatScale(T,alpha);CHKERRQ(ierr); for (k=1;knt;k++) { alpha = 0.0; for (j=0;jnmat-1;j++) alpha += coeffs[j]*ctx->coeffD[j*nep->nt+k]; if (shell) { ierr = NLEIGSMatToMatShellArray(nep->A[k],&Ts);CHKERRQ(ierr); } ierr = MatAXPY(T,alpha,shell?Ts:nep->A[k],nep->mstr);CHKERRQ(ierr); if (shell) { ierr = MatDestroy(&Ts);CHKERRQ(ierr); } } ierr = KSPSetOperators(ctx->ksp[i],T,T);CHKERRQ(ierr); ierr = KSPSetUp(ctx->ksp[i]);CHKERRQ(ierr); ierr = MatDestroy(&T);CHKERRQ(ierr); } ierr = PetscFree2(b,coeffs);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSDividedDifferences_callback" static PetscErrorCode NEPNLEIGSDividedDifferences_callback(NEP nep) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscInt k,j,i; PetscReal norm0,norm; PetscScalar *s=ctx->s,*beta=ctx->beta,*b,*coeffs; Mat *D=ctx->D,T; PetscBool shell,has,vec=PETSC_FALSE; Vec w[2]; PetscFunctionBegin; ierr = PetscMalloc2(ctx->ddmaxit+1,&b,ctx->ddmaxit+1,&coeffs);CHKERRQ(ierr); T = nep->function; ierr = NEPComputeFunction(nep,s[0],T,T);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)T,MATSHELL,&shell);CHKERRQ(ierr); if (!shell) { ierr = MatDuplicate(T,MAT_COPY_VALUES,&D[0]);CHKERRQ(ierr); } else { ierr = NLEIGSMatToMatShellArray(T,&D[0]);CHKERRQ(ierr); } if (beta[0]!=1.0) { ierr = MatScale(D[0],1.0/beta[0]);CHKERRQ(ierr); } ierr = MatHasOperation(D[0],MATOP_NORM,&has);CHKERRQ(ierr); if (has) { ierr = MatNorm(D[0],NORM_FROBENIUS,&norm0);CHKERRQ(ierr); } else { ierr = MatCreateVecs(D[0],NULL,&w[0]);CHKERRQ(ierr); ierr = VecDuplicate(w[0],&w[1]);CHKERRQ(ierr); vec = PETSC_TRUE; ierr = NEPNLEIGSNormEstimation(nep,D[0],&norm0,w);CHKERRQ(ierr); } ctx->nmat = ctx->ddmaxit; for (k=1;kddmaxit;k++) { ierr = NEPNLEIGSEvalNRTFunct(nep,k,s[k],b);CHKERRQ(ierr); ierr = NEPComputeFunction(nep,s[k],T,T);CHKERRQ(ierr); if (!shell) { ierr = MatDuplicate(T,MAT_COPY_VALUES,&D[k]);CHKERRQ(ierr); } else { ierr = NLEIGSMatToMatShellArray(T,&D[k]);CHKERRQ(ierr); } for (j=0;jmstr);CHKERRQ(ierr); } ierr = MatScale(D[k],1.0/b[k]);CHKERRQ(ierr); ierr = MatHasOperation(D[k],MATOP_NORM,&has);CHKERRQ(ierr); if (has) { ierr = MatNorm(D[k],NORM_FROBENIUS,&norm);CHKERRQ(ierr); } else { if(!vec) { ierr = MatCreateVecs(D[k],NULL,&w[0]);CHKERRQ(ierr); ierr = VecDuplicate(w[0],&w[1]);CHKERRQ(ierr); vec = PETSC_TRUE; } ierr = NEPNLEIGSNormEstimation(nep,D[k],&norm,w);CHKERRQ(ierr); } if (norm/norm0 < ctx->ddtol) { ctx->nmat = k+1; /* increment (the last matrix is not used) */ ierr = MatDestroy(&D[k]);CHKERRQ(ierr); break; } } if (!ctx->ksp) { ierr = NEPNLEIGSGetKSPs(nep,&ctx->ksp);CHKERRQ(ierr); } for (i=0;inshiftsw;i++) { ierr = NEPNLEIGSEvalNRTFunct(nep,ctx->nmat-1,ctx->shifts[i],coeffs);CHKERRQ(ierr); ierr = MatDuplicate(ctx->D[0],MAT_COPY_VALUES,&T);CHKERRQ(ierr); if (coeffs[0]!=1.0) { ierr = MatScale(T,coeffs[0]);CHKERRQ(ierr); } for (j=1;jnmat-1;j++) { ierr = MatAXPY(T,coeffs[j],ctx->D[j],nep->mstr);CHKERRQ(ierr); } ierr = KSPSetOperators(ctx->ksp[i],T,T);CHKERRQ(ierr); ierr = KSPSetUp(ctx->ksp[i]);CHKERRQ(ierr); ierr = MatDestroy(&T);CHKERRQ(ierr); } ierr = PetscFree2(b,coeffs);CHKERRQ(ierr); if (vec) { ierr = VecDestroy(&w[0]);CHKERRQ(ierr); ierr = VecDestroy(&w[1]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSRitzVector" static PetscErrorCode NEPNLEIGSRitzVector(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscInt k,Vec t) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscInt deg=ctx->nmat-1,ldds,n; PetscBLASInt nq_,lds_,n_,one=1,ldds_; PetscScalar sone=1.0,zero=0.0,*x,*y,*X; PetscFunctionBegin; ierr = DSGetDimensions(nep->ds,&n,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = PetscMalloc1(n+nq,&y);CHKERRQ(ierr); x = y+nq; ierr = DSGetLeadingDimension(nep->ds,&ldds);CHKERRQ(ierr); ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(nq,&nq_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldds,&ldds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(deg*ld,&lds_);CHKERRQ(ierr); ierr = DSGetArray(nep->ds,DS_MAT_X,&X);CHKERRQ(ierr); if (ctx->nshifts) PetscStackCall("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,H,&ldds_,X+k*ldds,&one,&zero,x,&one)); else x = X+k*ldds; PetscStackCall("BLASgemv",BLASgemv_("N",&nq_,&n_,&sone,S,&lds_,x,&one,&zero,y,&one)); ierr = DSRestoreArray(nep->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVSetActiveColumns(nep->V,0,nq);CHKERRQ(ierr); ierr = BVMultVec(nep->V,1.0,0.0,t,y);CHKERRQ(ierr); ierr = VecNormalize(t,NULL);CHKERRQ(ierr); ierr = PetscFree(y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSKrylovConvergence" /* NEPKrylovConvergence - This is the analogue to EPSKrylovConvergence. */ static PetscErrorCode NEPNLEIGSKrylovConvergence(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscBool getall,PetscInt kini,PetscInt nits,PetscScalar betak,PetscReal betah,PetscInt *kout,Vec *w) { PetscErrorCode ierr; PetscInt k,newk,marker,inside; PetscScalar re,im; PetscReal resnorm,tt; PetscBool istrivial; Vec t; NEP_NLEIGS *ctx = (NEP_NLEIGS*)nep->data; PetscFunctionBegin; t = w[0]; ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); marker = -1; if (nep->trackall) getall = PETSC_TRUE; for (k=kini;keigr[k]; im = nep->eigi[k]; if (!istrivial) { if (!ctx->nshifts) { ierr = NEPNLEIGSBackTransform((PetscObject)nep,1,&re,&im);CHKERRQ(ierr); } ierr = RGCheckInside(nep->rg,1,&re,&im,&inside);CHKERRQ(ierr); if (marker==-1 && inside<0) marker = k; } newk = k; ierr = DSVectors(nep->ds,DS_MAT_X,&newk,&resnorm);CHKERRQ(ierr); tt = (ctx->nshifts)?SlepcAbsEigenvalue(betak-nep->eigr[k]*betah,nep->eigi[k]*betah):betah; resnorm *= PetscAbsReal(tt); /* error estimate */ ierr = (*nep->converged)(nep,nep->eigr[k],nep->eigi[k],resnorm,&nep->errest[k],nep->convergedctx);CHKERRQ(ierr); if (ctx->trueres && (nep->errest[k] < nep->tol) ) { /* check explicit residual */ ierr = NEPNLEIGSRitzVector(nep,S,ld,nq,H,k,t);CHKERRQ(ierr); ierr = NEPComputeResidualNorm_Private(nep,re,t,w+1,&resnorm);CHKERRQ(ierr); ierr = (*nep->converged)(nep,re,im,resnorm,&nep->errest[k],nep->convergedctx);CHKERRQ(ierr); } if (marker==-1 && nep->errest[k] >= nep->tol) marker = k; if (newk==k+1) { nep->errest[k+1] = nep->errest[k]; k++; } if (marker!=-1 && !getall) break; } if (marker!=-1) k = marker; *kout = k; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetUp_NLEIGS" PetscErrorCode NEPSetUp_NLEIGS(NEP nep) { PetscErrorCode ierr; PetscInt k,in; PetscScalar zero=0.0; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; SlepcSC sc; PetscBool istrivial; PetscFunctionBegin; ierr = NEPSetDimensions_Default(nep,nep->nev,&nep->ncv,&nep->mpd);CHKERRQ(ierr); if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd"); if (!nep->max_it) nep->max_it = PetscMax(5000,2*nep->n/nep->ncv); if (!ctx->ddmaxit) ctx->ddmaxit = MAX_LBPOINTS; ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); if (istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NEPNLEIGS requires a nontrivial region defining the target set"); ierr = RGCheckInside(nep->rg,1,&nep->target,&zero,&in);CHKERRQ(ierr); if (in<0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"The target is not inside the target set"); if (!nep->which) nep->which = NEP_TARGET_MAGNITUDE; /* Initialize the NLEIGS context structure */ k = ctx->ddmaxit; ierr = PetscMalloc4(k,&ctx->s,k,&ctx->xi,k,&ctx->beta,k,&ctx->D);CHKERRQ(ierr); nep->data = ctx; if (nep->tol==PETSC_DEFAULT) nep->tol = SLEPC_DEFAULT_TOL; if (ctx->ddtol==PETSC_DEFAULT) ctx->ddtol = nep->tol/10.0; if (!ctx->keep) ctx->keep = 0.5; /* Compute Leja-Bagby points and scaling values */ ierr = NEPNLEIGSLejaBagbyPoints(nep);CHKERRQ(ierr); /* Compute the divided difference matrices */ if (nep->fui==NEP_USER_INTERFACE_SPLIT) { ierr = NEPNLEIGSDividedDifferences_split(nep);CHKERRQ(ierr); } else { ierr = NEPNLEIGSDividedDifferences_callback(nep);CHKERRQ(ierr); } ierr = NEPAllocateSolution(nep,ctx->nmat);CHKERRQ(ierr); ierr = NEPSetWorkVecs(nep,4);CHKERRQ(ierr); /* set-up DS and transfer split operator functions */ ierr = DSSetType(nep->ds,ctx->nshifts?DSGNHEP:DSNHEP);CHKERRQ(ierr); ierr = DSAllocate(nep->ds,nep->ncv+1);CHKERRQ(ierr); ierr = DSGetSlepcSC(nep->ds,&sc);CHKERRQ(ierr); if (!ctx->nshifts) { sc->map = NEPNLEIGSBackTransform; ierr = DSSetExtraRow(nep->ds,PETSC_TRUE);CHKERRQ(ierr); } sc->mapobj = (PetscObject)nep; sc->rg = nep->rg; sc->comparison = nep->sc->comparison; sc->comparisonctx = nep->sc->comparisonctx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPTOARSNorm2" /* Norm of [sp;sq] */ static PetscErrorCode NEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm) { PetscErrorCode ierr; PetscBLASInt n_,one=1; PetscFunctionBegin; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); *norm = BLASnrm2_(&n_,S,&one); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPTOAROrth2" /* Computes GS orthogonalization [z;x] - [Sp;Sq]*y, where y = ([Sp;Sq]'*[z;x]). k: Column from S to be orthogonalized against previous columns. Sq = Sp+ld dim(work)=k; */ static PetscErrorCode NEPTOAROrth2(NEP nep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work) { PetscErrorCode ierr; PetscBLASInt n_,lds_,k_,one=1; PetscScalar sonem=-1.0,sone=1.0,szero=0.0,*x0,*x,*c; PetscInt i,lds=deg*ld,n; PetscReal eta,onorm; PetscFunctionBegin; ierr = BVGetOrthogonalization(nep->V,NULL,NULL,&eta,NULL);CHKERRQ(ierr); n = k+deg-1; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(deg*ld,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); /* Number of vectors to orthogonalize against them */ c = work; x0 = S+k*lds; PetscStackCall("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S,&lds_,x0,&one,&szero,y,&one)); for (i=1;idata; PetscInt deg=ctx->nmat-1,k,j; Vec v=t_[0],q=t_[1],w; PetscScalar *beta=ctx->beta,*s=ctx->s,*xi=ctx->xi,*coeffs,sigma; PetscFunctionBegin; if (!ctx->ksp) { ierr = NEPNLEIGSGetKSPs(nep,&ctx->ksp);CHKERRQ(ierr); } sigma = ctx->shifts[idxrktg]; ierr = BVSetActiveColumns(nep->V,0,nv);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->nmat-1,&coeffs);CHKERRQ(ierr); if (PetscAbsScalar(s[deg-2]-sigma)<100*PETSC_MACHINE_EPSILON) SETERRQ(PETSC_COMM_SELF,1,"Breakdown in NLEIGS"); /* i-part stored in (i-1) position */ for (j=0;jW,0,deg-1);CHKERRQ(ierr); ierr = BVGetColumn(ctx->W,deg-2,&w);CHKERRQ(ierr); ierr = BVMultVec(V,1.0,0.0,w,r+(deg-2)*lr);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->W,deg-2,&w);CHKERRQ(ierr); for (k=deg-2;k>0;k--) { if (PetscAbsScalar(s[k-1]-sigma)<100*PETSC_MACHINE_EPSILON) SETERRQ(PETSC_COMM_SELF,1,"Breakdown in NLEIGS"); for (j=0;jW,k-1,&w);CHKERRQ(ierr); ierr = BVMultVec(V,1.0,0.0,w,r+(k-1)*lr);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->W,k-1,&w);CHKERRQ(ierr); } if (nep->fui==NEP_USER_INTERFACE_SPLIT) { for (j=0;jnmat-1;j++) coeffs[j] = ctx->coeffD[nep->nt*j]; ierr = BVMultVec(ctx->W,1.0,0.0,v,coeffs);CHKERRQ(ierr); ierr = MatMult(nep->A[0],v,q);CHKERRQ(ierr); for (k=1;knt;k++) { for (j=0;jnmat-1;j++) coeffs[j] = ctx->coeffD[nep->nt*j+k]; ierr = BVMultVec(ctx->W,1.0,0,v,coeffs);CHKERRQ(ierr); ierr = MatMult(nep->A[k],v,t);CHKERRQ(ierr); ierr = VecAXPY(q,1.0,t);CHKERRQ(ierr); } ierr = KSPSolve(ctx->ksp[idxrktg],q,t);CHKERRQ(ierr); ierr = VecScale(t,-1.0);CHKERRQ(ierr); } else { for (k=0;kW,k,&w);CHKERRQ(ierr); ierr = MatMult(ctx->D[k],w,q);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->W,k,&w);CHKERRQ(ierr); ierr = BVInsertVec(ctx->W,k,q);CHKERRQ(ierr); } for (j=0;jnmat-1;j++) coeffs[j] = 1.0; ierr = BVMultVec(ctx->W,1.0,0.0,q,coeffs);CHKERRQ(ierr); ierr = KSPSolve(ctx->ksp[idxrktg],q,t);CHKERRQ(ierr); ierr = VecScale(t,-1.0);CHKERRQ(ierr); } ierr = PetscFree(coeffs);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPTOARCoefficients" /* Compute TOAR coefficients of the blocks of the new Arnoldi vector computed */ static PetscErrorCode NEPTOARCoefficients(NEP nep,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x,PetscScalar *work) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscInt k,j,d=ctx->nmat-1; PetscScalar *t=work; PetscFunctionBegin; ierr = NEPNLEIGSEvalNRTFunct(nep,d-1,sigma,t);CHKERRQ(ierr); for (k=0;k= (end-ini)*(end-ini+1) + end+1 + 2*(end-ini+1), dim(t) = end. */ static PetscErrorCode NEPNLEIGS_RKcontinuation(NEP nep,PetscInt ini,PetscInt end,PetscScalar *K,PetscScalar *H,PetscInt ld,PetscScalar sigma,PetscScalar *S,PetscInt lds,PetscScalar *cont,PetscScalar *t,PetscScalar *work) { #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(SLEPC_MISSING_LAPACK_LARF) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/LARF - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscScalar *x,*W,*tau,sone=1.0,szero=0.0; PetscInt i,j,n1,n,nwu=0; PetscBLASInt info,n_,n1_,one=1,dim,lds_; NEP_NLEIGS *ctx = (NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (!ctx->nshifts || !end) { t[0] = 1; ierr = PetscMemcpy(cont,S+end*lds,lds*sizeof(PetscScalar));CHKERRQ(ierr); } else { n = end-ini; n1 = n+1; x = work+nwu; nwu += end+1; tau = work+nwu; nwu += n; W = work+nwu; nwu += n1*n; for (j=ini;j=0;j--) { for (i=0;idata; PetscInt i,j,p,m=*M,lwa,deg=ctx->nmat-1,lds=ld*deg,nqt=*nq; Vec t=t_[0]; PetscReal norm; PetscScalar *x,*work,*tt,sigma,*cont; PetscBool lindep; PetscFunctionBegin; lwa = PetscMax(ld,deg)+(m+1)*(m+1)+4*(m+1); ierr = PetscMalloc4(ld,&x,lwa,&work,m+1,&tt,lds,&cont);CHKERRQ(ierr); for (j=k;jshifts[(++(ctx->idxrk))%ctx->nshiftsw]; /* Continuation vector */ ierr = NEPNLEIGS_RKcontinuation(nep,0,j,K,H,ldh,sigma,S,lds,cont,tt,work);CHKERRQ(ierr); /* apply operator */ ierr = BVGetColumn(nep->V,nqt,&t);CHKERRQ(ierr); ierr = NEPTOARExtendBasis(nep,(ctx->idxrk)%ctx->nshiftsw,cont,ld,nqt,V,t,S+(j+1)*lds,ld,t_+1);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,nqt,&t);CHKERRQ(ierr); /* orthogonalize */ ierr = BVOrthogonalizeColumn(nep->V,nqt,x,&norm,&lindep);CHKERRQ(ierr); if (!lindep) { x[nqt] = norm; ierr = BVScaleColumn(nep->V,nqt,1.0/norm);CHKERRQ(ierr); nqt++; } else x[nqt] = 0.0; ierr = NEPTOARCoefficients(nep,sigma,*nq,cont,ld,S+(j+1)*lds,ld,x,work);CHKERRQ(ierr); /* Level-2 orthogonalization */ ierr = NEPTOAROrth2(nep,S,ld,deg,j+1,H+j*ldh,&norm,breakdown,work);CHKERRQ(ierr); H[j+1+ldh*j] = norm; if (ctx->nshifts) { for (i=0;i<=j;i++) K[i+ldh*j] = sigma*H[i+ldh*j] + tt[i]; K[j+1+ldh*j] = sigma*H[j+1+ldh*j]; } *nq = nqt; if (*breakdown) { *M = j+1; break; } for (p=0;pdeg*cs1)?deg*cs1:rs1; lwa = 5*ld*lds; M = work+nwu; nwu += rs1*cs1*deg; sg = rwork+nrwu; nrwu += n; pU = work+nwu; nwu += rs1*n; V = work+nwu; nwu += deg*cs1*n; for (i=0;iV,0,rs1);CHKERRQ(ierr); ierr = BVMultInPlace(nep->V,U,0,cs1+deg-1);CHKERRQ(ierr); ierr = BVSetActiveColumns(nep->V,0,cs1+deg-1);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); tol = PetscMax(rs1,deg*cs1)*PETSC_MACHINE_EPSILON*sg[0]; for (i=0;itol) rk++; rk = PetscMin(cs1+deg-1,rk); /* Update S */ ierr = PetscMemzero(S,lds*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;idata; PetscInt i,j,k=0,l,nv=0,ld,lds,off,ldds,rs1,nq=0,newn; PetscInt lwa,lrwa,nwu=0,nrwu=0,deg=ctx->nmat-1,nconv=0; PetscScalar *S,*Q,*work,*H,*pU,*K,betak=0,*Hc,*eigr,*eigi; PetscReal betah,norm,*rwork; PetscBool breakdown=PETSC_FALSE,lindep; Mat U; PetscFunctionBegin; ld = nep->ncv+deg; lds = deg*ld; lwa = (deg+6)*ld*lds; lrwa = 7*lds; ierr = DSGetLeadingDimension(nep->ds,&ldds);CHKERRQ(ierr); ierr = PetscMalloc4(lwa,&work,lrwa,&rwork,lds*ld,&S,ldds*ldds,&Hc);CHKERRQ(ierr); ierr = PetscMemzero(S,lds*ld*sizeof(PetscScalar));CHKERRQ(ierr); if (!ctx->nshifts) { ierr = PetscMalloc2(nep->ncv,&eigr,nep->ncv,&eigi);CHKERRQ(ierr); } else { eigr = nep->eigr; eigi = nep->eigi; } ierr = BVDuplicateResize(nep->V,PetscMax(nep->nt-1,ctx->nmat-1),&ctx->W);CHKERRQ(ierr); /* Get the starting vector */ for (i=0;iV,i);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(nep->V,i,S+i*ld,&norm,&lindep);CHKERRQ(ierr); if (!lindep) { ierr = BVScaleColumn(nep->V,i,1/norm);CHKERRQ(ierr); S[i+i*ld] = norm; nq++; } } if (!nq) SETERRQ(PetscObjectComm((PetscObject)nep),1,"NEP: Problem with initial vector"); ierr = NEPTOARSNorm2(lds,S,&norm);CHKERRQ(ierr); for (j=0;jreason == NEP_CONVERGED_ITERATING) { nep->its++; /* Compute an nv-step Krylov relation */ nv = PetscMin(nep->nconv+nep->mpd,nep->ncv); if (ctx->nshifts) { ierr = DSGetArray(nep->ds,DS_MAT_A,&K);CHKERRQ(ierr); } ierr = DSGetArray(nep->ds,ctx->nshifts?DS_MAT_B:DS_MAT_A,&H);CHKERRQ(ierr); ierr = NEPNLEIGSTOARrun(nep,&nq,S,ld,K,H,ldds,nep->V,nep->nconv+l,&nv,&breakdown,nep->work);CHKERRQ(ierr); betah = PetscAbsScalar(H[(nv-1)*ldds+nv]); ierr = DSRestoreArray(nep->ds,ctx->nshifts?DS_MAT_B:DS_MAT_A,&H);CHKERRQ(ierr); if (ctx->nshifts) { betak = K[(nv-1)*ldds+nv]; ierr = DSRestoreArray(nep->ds,DS_MAT_A,&K);CHKERRQ(ierr); } ierr = DSSetDimensions(nep->ds,nv,0,nep->nconv,nep->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(nep->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(nep->ds,DS_STATE_RAW);CHKERRQ(ierr); } /* Solve projected problem */ if (ctx->nshifts) { ierr = DSGetArray(nep->ds,DS_MAT_B,&H);CHKERRQ(ierr); ierr = PetscMemcpy(Hc,H,ldds*ldds*sizeof(PetscScalar));CHKERRQ(ierr); ierr = DSRestoreArray(nep->ds,DS_MAT_B,&H);CHKERRQ(ierr); } ierr = DSSolve(nep->ds,nep->eigr,nep->eigi);CHKERRQ(ierr); ierr = DSSort(nep->ds,nep->eigr,nep->eigi,NULL,NULL,NULL);CHKERRQ(ierr); if (!ctx->nshifts) { ierr = DSUpdateExtraRow(nep->ds);CHKERRQ(ierr); } /* Check convergence */ ierr = NEPNLEIGSKrylovConvergence(nep,S,ld,nq,Hc,PETSC_FALSE,nep->nconv,nv-nep->nconv,betak,betah,&k,nep->work);CHKERRQ(ierr); ierr = (*nep->stopping)(nep,nep->its,nep->max_it,k,nep->nev,&nep->reason,nep->stoppingctx);CHKERRQ(ierr); nconv = k; /* Update l */ if (nep->reason != NEP_CONVERGED_ITERATING || breakdown) l = 0; else { l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep)); if (!breakdown) { /* Prepare the Rayleigh quotient for restart */ if (!ctx->nshifts) { ierr = DSTruncate(nep->ds,k+l);CHKERRQ(ierr); ierr = DSGetDimensions(nep->ds,&newn,NULL,NULL,NULL,NULL);CHKERRQ(ierr); l = newn-k; } else { ierr = DSGetArray(nep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSGetArray(nep->ds,DS_MAT_B,&H);CHKERRQ(ierr); ierr = DSGetArray(nep->ds,DS_MAT_A,&K);CHKERRQ(ierr); for (i=ctx->lock?k:0;ids,DS_MAT_B,&H);CHKERRQ(ierr); ierr = DSRestoreArray(nep->ds,DS_MAT_A,&K);CHKERRQ(ierr); ierr = DSRestoreArray(nep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSSetDimensions(nep->ds,k+l,0,nep->nconv,0);CHKERRQ(ierr); } } } if (!ctx->lock && l>0) { l += k; k = 0; } /* Update S */ off = nep->nconv*ldds; ierr = DSGetArray(nep->ds,ctx->nshifts?DS_MAT_Z:DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = NEPTOARSupdate(S,ld,deg,nq,nep->nconv,k+l-nep->nconv,nv,Q+off,ldds,work+nwu);CHKERRQ(ierr); ierr = DSRestoreArray(nep->ds,ctx->nshifts?DS_MAT_Z:DS_MAT_Q,&Q);CHKERRQ(ierr); /* Copy last column of S */ ierr = PetscMemcpy(S+lds*(k+l),S+lds*nv,lds*sizeof(PetscScalar));CHKERRQ(ierr); if (nep->reason == NEP_CONVERGED_ITERATING) { if (breakdown) { /* Stop if breakdown */ ierr = PetscInfo2(nep,"Breakdown (it=%D norm=%g)\n",nep->its,(double)betah);CHKERRQ(ierr); nep->reason = NEP_DIVERGED_BREAKDOWN; } else { /* Truncate S */ ierr = NEPTOARTrunc(nep,S,ld,deg,&nq,k+l+1,work+nwu,rwork+nrwu);CHKERRQ(ierr); } } nep->nconv = k; if (!ctx->nshifts) { for (i=0;ieigr[i]; eigi[i] = nep->eigi[i]; } ierr = NEPNLEIGSBackTransform((PetscObject)nep,nv,eigr,eigi);CHKERRQ(ierr); } ierr = NEPMonitor(nep,nep->its,nconv,eigr,eigi,nep->errest,nv);CHKERRQ(ierr); } nep->nconv = nconv; if (nep->nconv>0) { /* Extract invariant pair */ ierr = NEPTOARTrunc(nep,S,ld,deg,&nq,nep->nconv,work+nwu,rwork+nrwu);CHKERRQ(ierr); /* Update vectors V = V*S or V=V*S*H */ rs1 = nep->nconv; if (ctx->nshifts) { ierr = DSGetArray(nep->ds,DS_MAT_B,&H);CHKERRQ(ierr); ierr = NEPTOARSupdate(S,ld,deg,rs1,0,nep->nconv,nep->nconv,H,ldds,work+nwu);CHKERRQ(ierr); ierr = DSRestoreArray(nep->ds,DS_MAT_B,&H);CHKERRQ(ierr); } ierr = PetscMalloc1(rs1*nep->nconv,&pU);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = PetscMemcpy(pU+i*rs1,S+i*lds,rs1*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = MatCreateSeqDense(PETSC_COMM_SELF,rs1,nep->nconv,pU,&U);CHKERRQ(ierr); ierr = BVSetActiveColumns(nep->V,0,rs1);CHKERRQ(ierr); ierr = BVMultInPlace(nep->V,U,0,nep->nconv);CHKERRQ(ierr); ierr = BVSetActiveColumns(nep->V,0,nep->nconv);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); ierr = PetscFree(pU);CHKERRQ(ierr); } /* truncate Schur decomposition and change the state to raw so that DSVectors() computes eigenvectors from scratch */ ierr = DSSetDimensions(nep->ds,nep->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(nep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = PetscFree4(work,rwork,S,Hc);CHKERRQ(ierr); /* Map eigenvalues back to the original problem */ if (!ctx->nshifts) { ierr = NEPNLEIGSBackTransform((PetscObject)nep,nep->nconv,nep->eigr,nep->eigi);CHKERRQ(ierr); ierr = PetscFree2(eigr,eigi);CHKERRQ(ierr); } ierr = BVDestroy(&ctx->W);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetSingularitiesFunction_NLEIGS" static PetscErrorCode NEPNLEIGSSetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx) { NEP_NLEIGS *nepctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (fun) nepctx->computesingularities = fun; if (ctx) nepctx->singularitiesctx = ctx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetSingularitiesFunction" /*@C NEPNLEIGSSetSingularitiesFunction - Sets a user function to compute a discretization of the singularity set (where T(.) is not analytic). Logically Collective on NEP Input Parameters: + nep - the NEP context . fun - user function (if NULL then NEP retains any previously set value) - ctx - [optional] user-defined context for private data for the function (may be NULL, in which case NEP retains any previously set value) Calling Sequence of fun: $ fun(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *ctx) + nep - the NEP context . maxnp - on input number of requested points in the discretization (can be set) . xi - computed values of the discretization - ctx - optional context, as set by NEPNLEIGSSetSingularitiesFunction() Note: The user-defined function can set a smaller value of maxnp if necessary. Level: intermediate .seealso: NEPNLEIGSGetSingularitiesFunction() @*/ PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = PetscTryMethod(nep,"NEPNLEIGSSetSingularitiesFunction_C",(NEP,PetscErrorCode(*)(NEP,PetscInt*,PetscScalar*,void*),void*),(nep,fun,ctx));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetSingularitiesFunction_NLEIGS" static PetscErrorCode NEPNLEIGSGetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx) { NEP_NLEIGS *nepctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (fun) *fun = nepctx->computesingularities; if (ctx) *ctx = nepctx->singularitiesctx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetSingularitiesFunction" /*@C NEPNLEIGSGetSingularitiesFunction - Returns the Function and optionally the user provided context for computing a discretization of the singularity set. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameters: + fun - location to put the function (or NULL) - ctx - location to stash the function context (or NULL) Level: advanced .seealso: NEPNLEIGSSetSingularitiesFunction() @*/ PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = PetscUseMethod(nep,"NEPNLEIGSGetSingularitiesFunction_C",(NEP,PetscErrorCode(**)(NEP,PetscInt*,PetscScalar*,void*),void**),(nep,fun,ctx));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetRestart_NLEIGS" static PetscErrorCode NEPNLEIGSSetRestart_NLEIGS(NEP nep,PetscReal keep) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (keep==PETSC_DEFAULT) ctx->keep = 0.5; else { if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]"); ctx->keep = keep; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetRestart" /*@ NEPNLEIGSSetRestart - Sets the restart parameter for the NLEIGS method, in particular the proportion of basis vectors that must be kept after restart. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - keep - the number of vectors to be kept at restart Options Database Key: . -nep_nleigs_restart - Sets the restart parameter Notes: Allowed values are in the range [0.1,0.9]. The default is 0.5. Level: advanced .seealso: NEPNLEIGSGetRestart() @*/ PetscErrorCode NEPNLEIGSSetRestart(NEP nep,PetscReal keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveReal(nep,keep,2); ierr = PetscTryMethod(nep,"NEPNLEIGSSetRestart_C",(NEP,PetscReal),(nep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetRestart_NLEIGS" static PetscErrorCode NEPNLEIGSGetRestart_NLEIGS(NEP nep,PetscReal *keep) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; *keep = ctx->keep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetRestart" /*@ NEPNLEIGSGetRestart - Gets the restart parameter used in the NLEIGS method. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: . keep - the restart parameter Level: advanced .seealso: NEPNLEIGSSetRestart() @*/ PetscErrorCode NEPNLEIGSGetRestart(NEP nep,PetscReal *keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(keep,2); ierr = PetscUseMethod(nep,"NEPNLEIGSGetRestart_C",(NEP,PetscReal*),(nep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetLocking_NLEIGS" static PetscErrorCode NEPNLEIGSSetLocking_NLEIGS(NEP nep,PetscBool lock) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; ctx->lock = lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetLocking" /*@ NEPNLEIGSSetLocking - Choose between locking and non-locking variants of the NLEIGS method. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - lock - true if the locking variant must be selected Options Database Key: . -nep_nleigs_locking - Sets the locking flag Notes: The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant). Level: advanced .seealso: NEPNLEIGSGetLocking() @*/ PetscErrorCode NEPNLEIGSSetLocking(NEP nep,PetscBool lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveBool(nep,lock,2); ierr = PetscTryMethod(nep,"NEPNLEIGSSetLocking_C",(NEP,PetscBool),(nep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetLocking_NLEIGS" static PetscErrorCode NEPNLEIGSGetLocking_NLEIGS(NEP nep,PetscBool *lock) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; *lock = ctx->lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetLocking" /*@ NEPNLEIGSGetLocking - Gets the locking flag used in the NLEIGS method. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: . lock - the locking flag Level: advanced .seealso: NEPNLEIGSSetLocking() @*/ PetscErrorCode NEPNLEIGSGetLocking(NEP nep,PetscBool *lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(lock,2); ierr = PetscUseMethod(nep,"NEPNLEIGSGetLocking_C",(NEP,PetscBool*),(nep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetInterpolation_NLEIGS" static PetscErrorCode NEPNLEIGSSetInterpolation_NLEIGS(NEP nep,PetscReal tol,PetscInt maxits) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (tol == PETSC_DEFAULT) { ctx->ddtol = PETSC_DEFAULT; nep->state = NEP_STATE_INITIAL; } else { if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); ctx->ddtol = tol; } if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) { ctx->ddmaxit = 0; nep->state = NEP_STATE_INITIAL; } else { if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0"); ctx->ddmaxit = maxits; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetInterpolation" /*@ NEPNLEIGSSetInterpolation - Sets the tolerance and maximum iteration count used by the NLEIGS method when building the interpolation via divided differences. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . tol - the convergence tolerance - maxits - maximum number of iterations to use Options Database Key: + -nep_nleigs_interpolation_tol - Sets the convergence tolerance - -nep_nleigs_interpolation_max_it - Sets the maximum number of iterations Notes: Use PETSC_DEFAULT for either argument to assign a reasonably good value. Level: advanced .seealso: NEPNLEIGSGetInterpolation() @*/ PetscErrorCode NEPNLEIGSSetInterpolation(NEP nep,PetscReal tol,PetscInt maxits) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveReal(nep,tol,2); PetscValidLogicalCollectiveInt(nep,maxits,3); ierr = PetscTryMethod(nep,"NEPNLEIGSSetInterpolation_C",(NEP,PetscReal,PetscInt),(nep,tol,maxits));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetInterpolation_NLEIGS" static PetscErrorCode NEPNLEIGSGetInterpolation_NLEIGS(NEP nep,PetscReal *tol,PetscInt *maxits) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (tol) *tol = ctx->ddtol; if (maxits) *maxits = ctx->ddmaxit; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetInterpolation" /*@ NEPNLEIGSGetInterpolation - Gets the tolerance and maximum iteration count used by the NLEIGS method when building the interpolation via divided differences. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: + tol - the convergence tolerance - maxits - maximum number of iterations Level: advanced .seealso: NEPNLEIGSSetInterpolation() @*/ PetscErrorCode NEPNLEIGSGetInterpolation(NEP nep,PetscReal *tol,PetscInt *maxits) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); ierr = PetscTryMethod(nep,"NEPNLEIGSGetInterpolation_C",(NEP,PetscReal*,PetscInt*),(nep,tol,maxits));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetTrueResidual_NLEIGS" static PetscErrorCode NEPNLEIGSSetTrueResidual_NLEIGS(NEP nep,PetscBool trueres) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; ctx->trueres = trueres; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetTrueResidual" /*@ NEPNLEIGSSetTrueResidual - Specifies if the solver must compute the true residual explicitly or not. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - trueres - whether true residuals are required or not Options Database Key: . -nep_nleigs_true_residual - Sets/resets the boolean flag 'trueres' Notes: If the user sets trueres=PETSC_TRUE then the solver explicitly computes the true residual norm for each eigenpair approximation, and uses it for convergence testing. The default is to use the cheaper approximation available from the (rational) Krylov iteration. Level: advanced .seealso: NEPNLEIGSGetTrueResidual() @*/ PetscErrorCode NEPNLEIGSSetTrueResidual(NEP nep,PetscBool trueres) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveBool(nep,trueres,2); ierr = PetscTryMethod(nep,"NEPNLEIGSSetTrueResidual_C",(NEP,PetscBool),(nep,trueres));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetTrueResidual_NLEIGS" static PetscErrorCode NEPNLEIGSGetTrueResidual_NLEIGS(NEP nep,PetscBool *trueres) { NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; *trueres = ctx->trueres; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetTrueResidual" /*@ NEPNLEIGSGetTrueResidual - Returns the flag indicating whether true residuals must be computed explicitly or not. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: . trueres - the returned flag Level: advanced .seealso: NEPNLEIGSSetTrueResidual() @*/ PetscErrorCode NEPNLEIGSGetTrueResidual(NEP nep,PetscBool *trueres) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(trueres,2); ierr = PetscTryMethod(nep,"NEPNLEIGSGetTrueResidual_C",(NEP,PetscBool*),(nep,trueres));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetRKShifts_NLEIGS" static PetscErrorCode NEPNLEIGSSetRKShifts_NLEIGS(NEP nep,PetscInt ns,PetscScalar *shifts) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscInt i; PetscFunctionBegin; if (ns<=0) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_ARG_WRONG,"Number of shifts must be positive"); if (ctx->nshifts) { ierr = PetscFree(ctx->shifts);CHKERRQ(ierr); } for (i=0;inshiftsw;i++) { ierr = KSPDestroy(&ctx->ksp[i]);CHKERRQ(ierr); } ierr = PetscFree(ctx->ksp);CHKERRQ(ierr); ctx->ksp = NULL; ierr = PetscMalloc1(ns,&ctx->shifts);CHKERRQ(ierr); for (i=0;ishifts[i] = shifts[i]; ctx->nshifts = ns; nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSSetRKShifts" /*@C NEPNLEIGSSetRKShifts - Sets a list of shifts to be used in the Rational Krylov method. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context . ns - number of shifts - shifts - array of scalar values specifying the shifts Options Database Key: . -nep_nleigs_rk_shifts - Sets the list of shifts Notes: If only one shift is provided, the subspace is built with the simpler shift-and-invert Krylov-Schur. In the case of real scalars, complex shifts are not allowed. In the command line, a comma-separated list of complex values can be provided with the format [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -nep_nleigs_rk_shifts 1.0+2.0i,1.5+2.0i,1.0+1.5i Level: advanced .seealso: NEPNLEIGSGetRKShifts() @*/ PetscErrorCode NEPNLEIGSSetRKShifts(NEP nep,PetscInt ns,PetscScalar *shifts) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidLogicalCollectiveInt(nep,ns,2); PetscValidPointer(nep,shifts); ierr = PetscTryMethod(nep,"NEPNLEIGSSetRKShifts_C",(NEP,PetscInt,PetscScalar*),(nep,ns,shifts));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetRKShifts_NLEIGS" static PetscErrorCode NEPNLEIGSGetRKShifts_NLEIGS(NEP nep,PetscInt *ns,PetscScalar **shifts) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscInt i; PetscFunctionBegin; *ns = ctx->nshifts; if (ctx->nshifts) { ierr = PetscMalloc1(ctx->nshifts,shifts);CHKERRQ(ierr); for (i=0;inshifts;i++) (*shifts)[i] = ctx->shifts[i]; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetRKShifts" /*@C NEPNLEIGSGetRKShifts - Gets the list of shifts used in the Rational Krylov method. Not Collective Input Parameter: . nep - the nonlinear eigensolver context Output Parameter: + ns - number of shifts - shifts - array of shifts Level: advanced .seealso: NEPNLEIGSSetRKShifts() @*/ PetscErrorCode NEPNLEIGSGetRKShifts(NEP nep,PetscInt *ns,PetscScalar **shifts) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(nep,ns); PetscValidPointer(nep,shifts); ierr = PetscTryMethod(nep,"NEPNLEIGSGetRKShifts_C",(NEP,PetscInt*,PetscScalar**),(nep,ns,shifts));CHKERRQ(ierr); PetscFunctionReturn(0); } #define SHIFTMAX 30 #undef __FUNCT__ #define __FUNCT__ "NEPSetFromOptions_NLEIGS" PetscErrorCode NEPSetFromOptions_NLEIGS(PetscOptionItems *PetscOptionsObject,NEP nep) { PetscErrorCode ierr; NEP_NLEIGS *ctx = (NEP_NLEIGS*)nep->data; PetscInt i,k; PetscBool flg1,flg2,b; PetscReal r; PetscScalar array[SHIFTMAX]; PC pc; PCType pctype; KSPType ksptype; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"NEP NLEIGS Options");CHKERRQ(ierr); ierr = PetscOptionsReal("-nep_nleigs_restart","Proportion of vectors kept after restart","NEPNLEIGSSetRestart",0.5,&r,&flg1);CHKERRQ(ierr); if (flg1) { ierr = NEPNLEIGSSetRestart(nep,r);CHKERRQ(ierr); } ierr = PetscOptionsBool("-nep_nleigs_locking","Choose between locking and non-locking variants","NEPNLEIGSSetLocking",PETSC_FALSE,&b,&flg1);CHKERRQ(ierr); if (flg1) { ierr = NEPNLEIGSSetLocking(nep,b);CHKERRQ(ierr); } ierr = PetscOptionsBool("-nep_nleigs_true_residual","Compute true residuals explicitly","NEPNLEIGSSetTrueResidual",PETSC_FALSE,&b,&flg1);CHKERRQ(ierr); if (flg1) { ierr = NEPNLEIGSSetTrueResidual(nep,b);CHKERRQ(ierr); } ierr = NEPNLEIGSGetInterpolation(nep,&r,&i);CHKERRQ(ierr); if (!i) i = PETSC_DEFAULT; ierr = PetscOptionsInt("-nep_nleigs_interpolation_max_it","Maximum number of terms for interpolation via divided differences","NEPNLEIGSSetInterpolation",i,&i,&flg1);CHKERRQ(ierr); ierr = PetscOptionsReal("-nep_nleigs_interpolation_tol","Tolerance for interpolation via divided differences","NEPNLEIGSSetInterpolation",r,&r,&flg2);CHKERRQ(ierr); if (flg1 || flg2) { ierr = NEPNLEIGSSetInterpolation(nep,r,i);CHKERRQ(ierr); } k = SHIFTMAX; for (i=0;iksp) { ierr = NEPNLEIGSGetKSPs(nep,&ctx->ksp);CHKERRQ(ierr); } for (i=0;inshiftsw;i++) { ierr = KSPGetPC(ctx->ksp[i],&pc);CHKERRQ(ierr); ierr = KSPGetType(ctx->ksp[i],&ksptype);CHKERRQ(ierr); ierr = PCGetType(pc,&pctype);CHKERRQ(ierr); if (!pctype && !ksptype) { ierr = KSPSetType(ctx->ksp[i],KSPPREONLY);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); } ierr = KSPSetOperators(ctx->ksp[i],nep->function,nep->function_pre);CHKERRQ(ierr); ierr = KSPSetFromOptions(ctx->ksp[i]);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetKSPs_NLEIGS" static PetscErrorCode NEPNLEIGSGetKSPs_NLEIGS(NEP nep,KSP **ksp) { PetscErrorCode ierr; NEP_NLEIGS *ctx = (NEP_NLEIGS*)nep->data; PetscInt i; PetscFunctionBegin; if (!ctx->ksp) { ierr = NEPNLEIGSSetShifts(nep);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->nshiftsw,&ctx->ksp);CHKERRQ(ierr); for (i=0;inshiftsw;i++) { ierr = KSPCreate(PetscObjectComm((PetscObject)nep),&ctx->ksp[i]);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(ctx->ksp[i],((PetscObject)nep)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(ctx->ksp[i],"nep_nleigs_");CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->ksp[i],(PetscObject)nep,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp[i]);CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(ctx->ksp[i],PETSC_TRUE);CHKERRQ(ierr); } } *ksp = ctx->ksp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNLEIGSGetKSPs" /*@C NEPNLEIGSGetKSPs - Retrieve the array of linear solver objects associated with the nonlinear eigenvalue solver. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . ksp - array of linear solver object Level: advanced @*/ PetscErrorCode NEPNLEIGSGetKSPs(NEP nep,KSP **ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(ksp,2); ierr = PetscUseMethod(nep,"NEPNLEIGSGetKSPs_C",(NEP,KSP**),(nep,ksp));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPView_NLEIGS" PetscErrorCode NEPView_NLEIGS(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscBool isascii; PetscInt i; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," NLEIGS: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," NLEIGS: using the %slocking variant\n",ctx->lock?"":"non-");CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," NLEIGS: divided difference terms: used=%D, max=%D\n",ctx->nmat-1,ctx->ddmaxit);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," NLEIGS: tolerance for divided difference convergence: %g\n",(double)ctx->ddtol);CHKERRQ(ierr); if (ctx->nshifts) { ierr = PetscViewerASCIIPrintf(viewer," NLEIGS: RK shifts: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;inshifts;i++) { ierr = SlepcSNPrintfScalar(str,50,ctx->shifts[i],PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s%s",str,(inshifts-1)?",":"");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } if (ctx->trueres) { ierr = PetscViewerASCIIPrintf(viewer," NLEIGS: computing true residuals for convergence check\n");CHKERRQ(ierr); } if (!ctx->ksp) { ierr = NEPNLEIGSGetKSPs(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = KSPView(ctx->ksp[0],viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPReset_NLEIGS" PetscErrorCode NEPReset_NLEIGS(NEP nep) { PetscErrorCode ierr; PetscInt k; NEP_NLEIGS *ctx=(NEP_NLEIGS*)nep->data; PetscFunctionBegin; if (nep->fui==NEP_USER_INTERFACE_SPLIT) { ierr = PetscFree(ctx->coeffD);CHKERRQ(ierr); } else { for (k=0;knmat;k++) { ierr = MatDestroy(&ctx->D[k]);CHKERRQ(ierr); } } if (ctx->vrn) { ierr = VecDestroy(&ctx->vrn);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPDestroy_NLEIGS" PetscErrorCode NEPDestroy_NLEIGS(NEP nep) { PetscErrorCode ierr; PetscInt k; NEP_NLEIGS *ctx = (NEP_NLEIGS*)nep->data; PetscFunctionBegin; for (k=0;knshiftsw;k++) { ierr = KSPDestroy(&ctx->ksp[k]);CHKERRQ(ierr); } ierr = PetscFree(ctx->ksp);CHKERRQ(ierr); if (ctx->nshifts) { ierr = PetscFree(ctx->shifts);CHKERRQ(ierr); } ierr = PetscFree4(ctx->s,ctx->xi,ctx->beta,ctx->D);CHKERRQ(ierr); ierr = PetscFree(nep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetSingularitiesFunction_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetSingularitiesFunction_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetInterpolation_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetInterpolation_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetTrueResidual_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetTrueResidual_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRKShifts_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRKShifts_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetKSPs_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCreate_NLEIGS" PETSC_EXTERN PetscErrorCode NEPCreate_NLEIGS(NEP nep) { PetscErrorCode ierr; NEP_NLEIGS *ctx; PetscFunctionBegin; ierr = PetscNewLog(nep,&ctx);CHKERRQ(ierr); nep->data = (void*)ctx; ctx->lock = PETSC_TRUE; ctx->ddtol = PETSC_DEFAULT; ctx->ddmaxit = 0; ctx->trueres = PETSC_FALSE; ctx->nshifts = 0; nep->ops->solve = NEPSolve_NLEIGS; nep->ops->setup = NEPSetUp_NLEIGS; nep->ops->setfromoptions = NEPSetFromOptions_NLEIGS; nep->ops->view = NEPView_NLEIGS; nep->ops->destroy = NEPDestroy_NLEIGS; nep->ops->reset = NEPReset_NLEIGS; nep->ops->computevectors = NEPComputeVectors_Schur; ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetSingularitiesFunction_C",NEPNLEIGSSetSingularitiesFunction_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetSingularitiesFunction_C",NEPNLEIGSGetSingularitiesFunction_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRestart_C",NEPNLEIGSSetRestart_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRestart_C",NEPNLEIGSGetRestart_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetLocking_C",NEPNLEIGSSetLocking_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetLocking_C",NEPNLEIGSGetLocking_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetInterpolation_C",NEPNLEIGSSetInterpolation_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetInterpolation_C",NEPNLEIGSGetInterpolation_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetTrueResidual_C",NEPNLEIGSSetTrueResidual_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetTrueResidual_C",NEPNLEIGSGetTrueResidual_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSSetRKShifts_C",NEPNLEIGSSetRKShifts_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetRKShifts_C",NEPNLEIGSGetRKShifts_NLEIGS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNLEIGSGetKSPs_C",NEPNLEIGSGetKSPs_NLEIGS);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/impls/nleigs/index.html0000644000175000017500000000305313107004621020137 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

nleigs.c
makefile
slepc-3.7.4/src/nep/impls/nleigs/ftn-auto/0000755000175000017500000000000013107004621017676 5ustar jromanjromanslepc-3.7.4/src/nep/impls/nleigs/ftn-auto/makefile0000644000175000017500000000035613107004621021402 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = nleigsf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepc LOCDIR = src/nep/impls/nleigs/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/nleigs/ftn-auto/nleigsf.c0000644000175000017500000000761713107004621021504 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* nleigs.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigssetrestart_ NEPNLEIGSSETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigssetrestart_ nepnleigssetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigsgetrestart_ NEPNLEIGSGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigsgetrestart_ nepnleigsgetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigssetlocking_ NEPNLEIGSSETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigssetlocking_ nepnleigssetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigsgetlocking_ NEPNLEIGSGETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigsgetlocking_ nepnleigsgetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigssetinterpolation_ NEPNLEIGSSETINTERPOLATION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigssetinterpolation_ nepnleigssetinterpolation #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigsgetinterpolation_ NEPNLEIGSGETINTERPOLATION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigsgetinterpolation_ nepnleigsgetinterpolation #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigssettrueresidual_ NEPNLEIGSSETTRUERESIDUAL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigssettrueresidual_ nepnleigssettrueresidual #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnleigsgettrueresidual_ NEPNLEIGSGETTRUERESIDUAL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnleigsgettrueresidual_ nepnleigsgettrueresidual #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepnleigssetrestart_(NEP nep,PetscReal *keep, int *__ierr ){ *__ierr = NEPNLEIGSSetRestart( (NEP)PetscToPointer((nep) ),*keep); } PETSC_EXTERN void PETSC_STDCALL nepnleigsgetrestart_(NEP nep,PetscReal *keep, int *__ierr ){ *__ierr = NEPNLEIGSGetRestart( (NEP)PetscToPointer((nep) ),keep); } PETSC_EXTERN void PETSC_STDCALL nepnleigssetlocking_(NEP nep,PetscBool *lock, int *__ierr ){ *__ierr = NEPNLEIGSSetLocking( (NEP)PetscToPointer((nep) ),*lock); } PETSC_EXTERN void PETSC_STDCALL nepnleigsgetlocking_(NEP nep,PetscBool *lock, int *__ierr ){ *__ierr = NEPNLEIGSGetLocking( (NEP)PetscToPointer((nep) ),lock); } PETSC_EXTERN void PETSC_STDCALL nepnleigssetinterpolation_(NEP nep,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = NEPNLEIGSSetInterpolation( (NEP)PetscToPointer((nep) ),*tol,*maxits); } PETSC_EXTERN void PETSC_STDCALL nepnleigsgetinterpolation_(NEP nep,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = NEPNLEIGSGetInterpolation( (NEP)PetscToPointer((nep) ),tol,maxits); } PETSC_EXTERN void PETSC_STDCALL nepnleigssettrueresidual_(NEP nep,PetscBool *trueres, int *__ierr ){ *__ierr = NEPNLEIGSSetTrueResidual( (NEP)PetscToPointer((nep) ),*trueres); } PETSC_EXTERN void PETSC_STDCALL nepnleigsgettrueresidual_(NEP nep,PetscBool *trueres, int *__ierr ){ *__ierr = NEPNLEIGSGetTrueResidual( (NEP)PetscToPointer((nep) ),trueres); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/nep/impls/index.html0000644000175000017500000000327013107004621016657 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP

slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

rii/
slp/
narnoldi/
interpol/
ciss/
nleigs/
makefile
slepc-3.7.4/src/nep/impls/narnoldi/0000755000175000017500000000000013107004621016466 5ustar jromanjromanslepc-3.7.4/src/nep/impls/narnoldi/makefile0000644000175000017500000000217313107004621020171 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = narnoldi.c SOURCEF = SOURCEH = LIBBASE = libslepcnep DIRS = MANSEC = NEP LOCDIR = src/nep/impls/narnoldi/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/narnoldi/narnoldi.c0000644000175000017500000002742413107004621020451 0ustar jromanjroman/* SLEPc nonlinear eigensolver: "narnoldi" Method: Nonlinear Arnoldi Algorithm: Arnoldi for nonlinear eigenproblems. References: [1] H. Voss, "An Arnoldi method for nonlinear eigenvalue problems", BIT 44:387-401, 2004. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcnep.h" I*/ typedef struct { KSP ksp; /* linear solver object */ } NEP_NARNOLDI; #undef __FUNCT__ #define __FUNCT__ "NEPNArnoldi_KSPSolve" PETSC_STATIC_INLINE PetscErrorCode NEPNArnoldi_KSPSolve(NEP nep,Vec b,Vec x) { PetscErrorCode ierr; PetscInt lits; NEP_NARNOLDI *ctx = (NEP_NARNOLDI*)nep->data; PetscFunctionBegin; ierr = KSPSolve(ctx->ksp,b,x);CHKERRQ(ierr); ierr = KSPGetIterationNumber(ctx->ksp,&lits);CHKERRQ(ierr); ierr = PetscInfo2(nep,"iter=%D, linear solve iterations=%D\n",nep->its,lits);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetUp_NArnoldi" PetscErrorCode NEPSetUp_NArnoldi(NEP nep) { PetscErrorCode ierr; PetscBool istrivial; PetscFunctionBegin; ierr = NEPSetDimensions_Default(nep,nep->nev,&nep->ncv,&nep->mpd);CHKERRQ(ierr); if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd"); if (nep->nev>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Requested several eigenpairs but this solver can compute only one"); if (!nep->max_it) nep->max_it = nep->ncv; if (nep->max_it < nep->ncv) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Current implementation is unrestarted, must set max_it >= ncv"); if (nep->which && nep->which!=NEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of which"); if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NARNOLDI only available for split operator"); ierr = RGIsTrivial(nep->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support region filtering"); ierr = NEPAllocateSolution(nep,0);CHKERRQ(ierr); ierr = NEPSetWorkVecs(nep,3);CHKERRQ(ierr); /* set-up DS and transfer split operator functions */ ierr = DSSetType(nep->ds,DSNEP);CHKERRQ(ierr); ierr = DSNEPSetFN(nep->ds,nep->nt,nep->f);CHKERRQ(ierr); ierr = DSAllocate(nep->ds,nep->ncv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSolve_NArnoldi" PetscErrorCode NEPSolve_NArnoldi(NEP nep) { PetscErrorCode ierr; NEP_NARNOLDI *ctx = (NEP_NARNOLDI*)nep->data; Mat T=nep->function,Tsigma; Vec f,r=nep->work[0],x=nep->work[1],w=nep->work[2]; PetscScalar *X,lambda; PetscReal beta,resnorm=0.0,nrm; PetscInt n; PetscBool breakdown; KSPConvergedReason kspreason; PetscFunctionBegin; /* get initial space and shift */ ierr = NEPGetDefaultShift(nep,&lambda);CHKERRQ(ierr); if (!nep->nini) { ierr = BVSetRandomColumn(nep->V,0);CHKERRQ(ierr); ierr = BVNormColumn(nep->V,0,NORM_2,&nrm);CHKERRQ(ierr); ierr = BVScaleColumn(nep->V,0,1.0/nrm);CHKERRQ(ierr); n = 1; } else n = nep->nini; /* build projected matrices for initial space */ ierr = DSSetDimensions(nep->ds,n,0,0,0);CHKERRQ(ierr); ierr = NEPProjectOperator(nep,0,n);CHKERRQ(ierr); /* prepare linear solver */ if (!ctx->ksp) { ierr = NEPNArnoldiGetKSP(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = NEPComputeFunction(nep,lambda,T,T);CHKERRQ(ierr); ierr = MatDuplicate(T,MAT_COPY_VALUES,&Tsigma);CHKERRQ(ierr); ierr = KSPSetOperators(ctx->ksp,Tsigma,Tsigma);CHKERRQ(ierr); /* Restart loop */ while (nep->reason == NEP_CONVERGED_ITERATING) { nep->its++; /* solve projected problem */ ierr = DSSetDimensions(nep->ds,n,0,0,0);CHKERRQ(ierr); ierr = DSSetState(nep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSSolve(nep->ds,nep->eigr,NULL);CHKERRQ(ierr); lambda = nep->eigr[0]; /* compute Ritz vector, x = V*s */ ierr = DSGetArray(nep->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVSetActiveColumns(nep->V,0,n);CHKERRQ(ierr); ierr = BVMultVec(nep->V,1.0,0.0,x,X);CHKERRQ(ierr); ierr = DSRestoreArray(nep->ds,DS_MAT_X,&X);CHKERRQ(ierr); /* compute the residual, r = T(lambda)*x */ ierr = NEPApplyFunction(nep,lambda,x,w,r,NULL,NULL);CHKERRQ(ierr); /* convergence test */ ierr = VecNorm(r,NORM_2,&resnorm);CHKERRQ(ierr); ierr = (*nep->converged)(nep,lambda,0,resnorm,&nep->errest[nep->nconv],nep->convergedctx);CHKERRQ(ierr); if (nep->errest[nep->nconv]<=nep->tol) { ierr = BVInsertVec(nep->V,nep->nconv,x);CHKERRQ(ierr); nep->nconv = nep->nconv + 1; } ierr = (*nep->stopping)(nep,nep->its,nep->max_it,nep->nconv,nep->nev,&nep->reason,nep->stoppingctx);CHKERRQ(ierr); ierr = NEPMonitor(nep,nep->its,nep->nconv,nep->eigr,nep->eigi,nep->errest,1);CHKERRQ(ierr); if (nep->reason == NEP_CONVERGED_ITERATING) { /* continuation vector: f = T(sigma)\r */ ierr = BVGetColumn(nep->V,n,&f);CHKERRQ(ierr); ierr = NEPNArnoldi_KSPSolve(nep,r,f);CHKERRQ(ierr); ierr = BVRestoreColumn(nep->V,n,&f);CHKERRQ(ierr); ierr = KSPGetConvergedReason(ctx->ksp,&kspreason);CHKERRQ(ierr); if (kspreason<0) { ierr = PetscInfo1(nep,"iter=%D, linear solve failed, stopping solve\n",nep->its);CHKERRQ(ierr); nep->reason = NEP_DIVERGED_LINEAR_SOLVE; break; } /* orthonormalize */ ierr = BVOrthogonalizeColumn(nep->V,n,NULL,&beta,&breakdown);CHKERRQ(ierr); if (breakdown || beta==0.0) { ierr = PetscInfo1(nep,"iter=%D, orthogonalization failed, stopping solve\n",nep->its);CHKERRQ(ierr); nep->reason = NEP_DIVERGED_BREAKDOWN; break; } ierr = BVScaleColumn(nep->V,n,1.0/beta);CHKERRQ(ierr); /* update projected matrices */ ierr = DSSetDimensions(nep->ds,n+1,0,0,0);CHKERRQ(ierr); ierr = NEPProjectOperator(nep,n,n+1);CHKERRQ(ierr); n++; } } ierr = MatDestroy(&Tsigma);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPSetFromOptions_NArnoldi" PetscErrorCode NEPSetFromOptions_NArnoldi(PetscOptionItems *PetscOptionsObject,NEP nep) { PetscErrorCode ierr; NEP_NARNOLDI *ctx = (NEP_NARNOLDI*)nep->data; PetscFunctionBegin; if (!ctx->ksp) { ierr = NEPNArnoldiGetKSP(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = KSPSetOperators(ctx->ksp,nep->function,nep->function_pre);CHKERRQ(ierr); ierr = KSPSetFromOptions(ctx->ksp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNArnoldiSetKSP_NArnoldi" static PetscErrorCode NEPNArnoldiSetKSP_NArnoldi(NEP nep,KSP ksp) { PetscErrorCode ierr; NEP_NARNOLDI *ctx = (NEP_NARNOLDI*)nep->data; PetscFunctionBegin; ierr = PetscObjectReference((PetscObject)ksp);CHKERRQ(ierr); ierr = KSPDestroy(&ctx->ksp);CHKERRQ(ierr); ctx->ksp = ksp; ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);CHKERRQ(ierr); nep->state = NEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNArnoldiSetKSP" /*@ NEPNArnoldiSetKSP - Associate a linear solver object (KSP) to the nonlinear eigenvalue solver. Collective on NEP Input Parameters: + nep - eigenvalue solver - ksp - the linear solver object Level: advanced .seealso: NEPNArnoldiGetKSP() @*/ PetscErrorCode NEPNArnoldiSetKSP(NEP nep,KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidHeaderSpecific(ksp,KSP_CLASSID,2); PetscCheckSameComm(nep,1,ksp,2); ierr = PetscTryMethod(nep,"NEPNArnoldiSetKSP_C",(NEP,KSP),(nep,ksp));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNArnoldiGetKSP_NArnoldi" static PetscErrorCode NEPNArnoldiGetKSP_NArnoldi(NEP nep,KSP *ksp) { PetscErrorCode ierr; NEP_NARNOLDI *ctx = (NEP_NARNOLDI*)nep->data; PetscFunctionBegin; if (!ctx->ksp) { ierr = KSPCreate(PetscObjectComm((PetscObject)nep),&ctx->ksp);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(ctx->ksp,((PetscObject)nep)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(ctx->ksp,"nep_narnoldi_");CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->ksp,(PetscObject)nep,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(ctx->ksp,PETSC_TRUE);CHKERRQ(ierr); } *ksp = ctx->ksp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPNArnoldiGetKSP" /*@ NEPNArnoldiGetKSP - Retrieve the linear solver object (KSP) associated with the nonlinear eigenvalue solver. Not Collective Input Parameter: . nep - nonlinear eigenvalue solver Output Parameter: . ksp - the linear solver object Level: advanced .seealso: NEPNArnoldiSetKSP() @*/ PetscErrorCode NEPNArnoldiGetKSP(NEP nep,KSP *ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); PetscValidPointer(ksp,2); ierr = PetscUseMethod(nep,"NEPNArnoldiGetKSP_C",(NEP,KSP*),(nep,ksp));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPView_NArnoldi" PetscErrorCode NEPView_NArnoldi(NEP nep,PetscViewer viewer) { PetscErrorCode ierr; NEP_NARNOLDI *ctx = (NEP_NARNOLDI*)nep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (!ctx->ksp) { ierr = NEPNArnoldiGetKSP(nep,&ctx->ksp);CHKERRQ(ierr); } ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = KSPView(ctx->ksp,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPDestroy_NArnoldi" PetscErrorCode NEPDestroy_NArnoldi(NEP nep) { PetscErrorCode ierr; NEP_NARNOLDI *ctx = (NEP_NARNOLDI*)nep->data; PetscFunctionBegin; ierr = KSPDestroy(&ctx->ksp);CHKERRQ(ierr); ierr = PetscFree(nep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiSetKSP_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiGetKSP_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NEPCreate_NArnoldi" PETSC_EXTERN PetscErrorCode NEPCreate_NArnoldi(NEP nep) { PetscErrorCode ierr; NEP_NARNOLDI *ctx; PetscFunctionBegin; ierr = PetscNewLog(nep,&ctx);CHKERRQ(ierr); nep->data = (void*)ctx; nep->ops->solve = NEPSolve_NArnoldi; nep->ops->setup = NEPSetUp_NArnoldi; nep->ops->setfromoptions = NEPSetFromOptions_NArnoldi; nep->ops->destroy = NEPDestroy_NArnoldi; nep->ops->view = NEPView_NArnoldi; ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiSetKSP_C",NEPNArnoldiSetKSP_NArnoldi);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiGetKSP_C",NEPNArnoldiGetKSP_NArnoldi);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/nep/impls/narnoldi/makefile.html0000644000175000017500000000470113107004621021133 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#     
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = narnoldi.c
SOURCEF  = 
SOURCEH  =
LIBBASE  = libslepcnep
DIRS     =
MANSEC   = NEP
LOCDIR   = src/nep/impls/narnoldi/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/nep/impls/narnoldi/narnoldi.c.html0000644000175000017500000006000313107004621021402 0ustar jromanjroman
Actual source code: narnoldi.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc nonlinear eigensolver: "narnoldi"

  5:    Method: Nonlinear Arnoldi

  7:    Algorithm:

  9:        Arnoldi for nonlinear eigenproblems.

 11:    References:

 13:        [1] H. Voss, "An Arnoldi method for nonlinear eigenvalue problems",
 14:            BIT 44:387-401, 2004.

 16:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 17:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 18:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 20:    This file is part of SLEPc.

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

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

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

 36: #include <slepc/private/nepimpl.h>         /*I "slepcnep.h" I*/

 38: typedef struct {
 39:   KSP      ksp;              /* linear solver object */
 40: } NEP_NARNOLDI;

 44: PETSC_STATIC_INLINE PetscErrorCode NEPNArnoldi_KSPSolve(NEP nep,Vec b,Vec x)
 45: {
 47:   PetscInt       lits;
 48:   NEP_NARNOLDI   *ctx = (NEP_NARNOLDI*)nep->data;

 51:   KSPSolve(ctx->ksp,b,x);
 52:   KSPGetIterationNumber(ctx->ksp,&lits);
 53:   PetscInfo2(nep,"iter=%D, linear solve iterations=%D\n",nep->its,lits);
 54:   return(0);
 55: }

 59: PetscErrorCode NEPSetUp_NArnoldi(NEP nep)
 60: {
 62:   PetscBool      istrivial;

 65:   NEPSetDimensions_Default(nep,nep->nev,&nep->ncv,&nep->mpd);
 66:   if (nep->ncv>nep->nev+nep->mpd) SETERRQ(PetscObjectComm((PetscObject)nep),1,"The value of ncv must not be larger than nev+mpd");
 67:   if (nep->nev>1) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Requested several eigenpairs but this solver can compute only one");
 68:   if (!nep->max_it) nep->max_it = nep->ncv;
 69:   if (nep->max_it < nep->ncv) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Current implementation is unrestarted, must set max_it >= ncv");
 70:   if (nep->which && nep->which!=NEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)nep),1,"Wrong value of which");
 71:   if (nep->fui!=NEP_USER_INTERFACE_SPLIT) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"NARNOLDI only available for split operator");

 73:   RGIsTrivial(nep->rg,&istrivial);
 74:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"This solver does not support region filtering");

 76:   NEPAllocateSolution(nep,0);
 77:   NEPSetWorkVecs(nep,3);

 79:   /* set-up DS and transfer split operator functions */
 80:   DSSetType(nep->ds,DSNEP);
 81:   DSNEPSetFN(nep->ds,nep->nt,nep->f);
 82:   DSAllocate(nep->ds,nep->ncv);
 83:   return(0);
 84: }

 88: PetscErrorCode NEPSolve_NArnoldi(NEP nep)
 89: {
 90:   PetscErrorCode     ierr;
 91:   NEP_NARNOLDI       *ctx = (NEP_NARNOLDI*)nep->data;
 92:   Mat                T=nep->function,Tsigma;
 93:   Vec                f,r=nep->work[0],x=nep->work[1],w=nep->work[2];
 94:   PetscScalar        *X,lambda;
 95:   PetscReal          beta,resnorm=0.0,nrm;
 96:   PetscInt           n;
 97:   PetscBool          breakdown;
 98:   KSPConvergedReason kspreason;

101:   /* get initial space and shift */
102:   NEPGetDefaultShift(nep,&lambda);
103:   if (!nep->nini) {
104:     BVSetRandomColumn(nep->V,0);
105:     BVNormColumn(nep->V,0,NORM_2,&nrm);
106:     BVScaleColumn(nep->V,0,1.0/nrm);
107:     n = 1;
108:   } else n = nep->nini;

110:   /* build projected matrices for initial space */
111:   DSSetDimensions(nep->ds,n,0,0,0);
112:   NEPProjectOperator(nep,0,n);

114:   /* prepare linear solver */
115:   if (!ctx->ksp) { NEPNArnoldiGetKSP(nep,&ctx->ksp); }
116:   NEPComputeFunction(nep,lambda,T,T);
117:   MatDuplicate(T,MAT_COPY_VALUES,&Tsigma);
118:   KSPSetOperators(ctx->ksp,Tsigma,Tsigma);

120:   /* Restart loop */
121:   while (nep->reason == NEP_CONVERGED_ITERATING) {
122:     nep->its++;

124:     /* solve projected problem */
125:     DSSetDimensions(nep->ds,n,0,0,0);
126:     DSSetState(nep->ds,DS_STATE_RAW);
127:     DSSolve(nep->ds,nep->eigr,NULL);
128:     lambda = nep->eigr[0];

130:     /* compute Ritz vector, x = V*s */
131:     DSGetArray(nep->ds,DS_MAT_X,&X);
132:     BVSetActiveColumns(nep->V,0,n);
133:     BVMultVec(nep->V,1.0,0.0,x,X);
134:     DSRestoreArray(nep->ds,DS_MAT_X,&X);

136:     /* compute the residual, r = T(lambda)*x */
137:     NEPApplyFunction(nep,lambda,x,w,r,NULL,NULL);

139:     /* convergence test */
140:     VecNorm(r,NORM_2,&resnorm);
141:     (*nep->converged)(nep,lambda,0,resnorm,&nep->errest[nep->nconv],nep->convergedctx);
142:     if (nep->errest[nep->nconv]<=nep->tol) {
143:       BVInsertVec(nep->V,nep->nconv,x);
144:       nep->nconv = nep->nconv + 1;
145:     }
146:     (*nep->stopping)(nep,nep->its,nep->max_it,nep->nconv,nep->nev,&nep->reason,nep->stoppingctx);
147:     NEPMonitor(nep,nep->its,nep->nconv,nep->eigr,nep->eigi,nep->errest,1);

149:     if (nep->reason == NEP_CONVERGED_ITERATING) {

151:       /* continuation vector: f = T(sigma)\r */
152:       BVGetColumn(nep->V,n,&f);
153:       NEPNArnoldi_KSPSolve(nep,r,f);
154:       BVRestoreColumn(nep->V,n,&f);
155:       KSPGetConvergedReason(ctx->ksp,&kspreason);
156:       if (kspreason<0) {
157:         PetscInfo1(nep,"iter=%D, linear solve failed, stopping solve\n",nep->its);
158:         nep->reason = NEP_DIVERGED_LINEAR_SOLVE;
159:         break;
160:       }

162:       /* orthonormalize */
163:       BVOrthogonalizeColumn(nep->V,n,NULL,&beta,&breakdown);
164:       if (breakdown || beta==0.0) {
165:         PetscInfo1(nep,"iter=%D, orthogonalization failed, stopping solve\n",nep->its);
166:         nep->reason = NEP_DIVERGED_BREAKDOWN;
167:         break;
168:       }
169:       BVScaleColumn(nep->V,n,1.0/beta);

171:       /* update projected matrices */
172:       DSSetDimensions(nep->ds,n+1,0,0,0);
173:       NEPProjectOperator(nep,n,n+1);
174:       n++;
175:     }
176:   }
177:   MatDestroy(&Tsigma);
178:   return(0);
179: }

183: PetscErrorCode NEPSetFromOptions_NArnoldi(PetscOptionItems *PetscOptionsObject,NEP nep)
184: {
186:   NEP_NARNOLDI   *ctx = (NEP_NARNOLDI*)nep->data;

189:   if (!ctx->ksp) { NEPNArnoldiGetKSP(nep,&ctx->ksp); }
190:   KSPSetOperators(ctx->ksp,nep->function,nep->function_pre);
191:   KSPSetFromOptions(ctx->ksp);
192:   return(0);
193: }

197: static PetscErrorCode NEPNArnoldiSetKSP_NArnoldi(NEP nep,KSP ksp)
198: {
200:   NEP_NARNOLDI   *ctx = (NEP_NARNOLDI*)nep->data;

203:   PetscObjectReference((PetscObject)ksp);
204:   KSPDestroy(&ctx->ksp);
205:   ctx->ksp = ksp;
206:   PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);
207:   nep->state = NEP_STATE_INITIAL;
208:   return(0);
209: }

213: /*@
214:    NEPNArnoldiSetKSP - Associate a linear solver object (KSP) to the nonlinear
215:    eigenvalue solver.

217:    Collective on NEP

219:    Input Parameters:
220: +  nep - eigenvalue solver
221: -  ksp - the linear solver object

223:    Level: advanced

225: .seealso: NEPNArnoldiGetKSP()
226: @*/
227: PetscErrorCode NEPNArnoldiSetKSP(NEP nep,KSP ksp)
228: {

235:   PetscTryMethod(nep,"NEPNArnoldiSetKSP_C",(NEP,KSP),(nep,ksp));
236:   return(0);
237: }

241: static PetscErrorCode NEPNArnoldiGetKSP_NArnoldi(NEP nep,KSP *ksp)
242: {
244:   NEP_NARNOLDI   *ctx = (NEP_NARNOLDI*)nep->data;

247:   if (!ctx->ksp) {
248:     KSPCreate(PetscObjectComm((PetscObject)nep),&ctx->ksp);
249:     KSPSetOptionsPrefix(ctx->ksp,((PetscObject)nep)->prefix);
250:     KSPAppendOptionsPrefix(ctx->ksp,"nep_narnoldi_");
251:     PetscObjectIncrementTabLevel((PetscObject)ctx->ksp,(PetscObject)nep,1);
252:     PetscLogObjectParent((PetscObject)nep,(PetscObject)ctx->ksp);
253:     KSPSetErrorIfNotConverged(ctx->ksp,PETSC_TRUE);
254:   }
255:   *ksp = ctx->ksp;
256:   return(0);
257: }

261: /*@
262:    NEPNArnoldiGetKSP - Retrieve the linear solver object (KSP) associated with
263:    the nonlinear eigenvalue solver.

265:    Not Collective

267:    Input Parameter:
268: .  nep - nonlinear eigenvalue solver

270:    Output Parameter:
271: .  ksp - the linear solver object

273:    Level: advanced

275: .seealso: NEPNArnoldiSetKSP()
276: @*/
277: PetscErrorCode NEPNArnoldiGetKSP(NEP nep,KSP *ksp)
278: {

284:   PetscUseMethod(nep,"NEPNArnoldiGetKSP_C",(NEP,KSP*),(nep,ksp));
285:   return(0);
286: }

290: PetscErrorCode NEPView_NArnoldi(NEP nep,PetscViewer viewer)
291: {
293:   NEP_NARNOLDI   *ctx = (NEP_NARNOLDI*)nep->data;
294:   PetscBool      isascii;

297:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
298:   if (isascii) {
299:     if (!ctx->ksp) { NEPNArnoldiGetKSP(nep,&ctx->ksp); }
300:     PetscViewerASCIIPushTab(viewer);
301:     KSPView(ctx->ksp,viewer);
302:     PetscViewerASCIIPopTab(viewer);
303:   }
304:   return(0);
305: }

309: PetscErrorCode NEPDestroy_NArnoldi(NEP nep)
310: {
312:   NEP_NARNOLDI   *ctx = (NEP_NARNOLDI*)nep->data;

315:   KSPDestroy(&ctx->ksp);
316:   PetscFree(nep->data);
317:   PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiSetKSP_C",NULL);
318:   PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiGetKSP_C",NULL);
319:   return(0);
320: }

324: PETSC_EXTERN PetscErrorCode NEPCreate_NArnoldi(NEP nep)
325: {
327:   NEP_NARNOLDI   *ctx;

330:   PetscNewLog(nep,&ctx);
331:   nep->data = (void*)ctx;

333:   nep->ops->solve          = NEPSolve_NArnoldi;
334:   nep->ops->setup          = NEPSetUp_NArnoldi;
335:   nep->ops->setfromoptions = NEPSetFromOptions_NArnoldi;
336:   nep->ops->destroy        = NEPDestroy_NArnoldi;
337:   nep->ops->view           = NEPView_NArnoldi;
338:   PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiSetKSP_C",NEPNArnoldiSetKSP_NArnoldi);
339:   PetscObjectComposeFunction((PetscObject)nep,"NEPNArnoldiGetKSP_C",NEPNArnoldiGetKSP_NArnoldi);
340:   return(0);
341: }

slepc-3.7.4/src/nep/impls/narnoldi/index.html0000644000175000017500000000306313107004621020465 0ustar jromanjroman Nonlinear Eigenvalue Problem Solvers - NEP
slepc-3.7.4 2017-05-17

Nonlinear Eigenvalue Problem Solvers - NEP: Examples NLEVP

The Nonlinear Eigenvalue Problem (NEP) solver is the object provided by SLEPc for specifying an eigenvalue problem that is nonlinear with respect to the eigenvalue (not the eigenvector). This is intended for general nonlinear problems (rather than polynomial eigenproblems) described as T(λ)x=0.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -nep_nev 4 -nep_type narnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., NEPSetDimensions() / NEPSetType()).

narnoldi.c
makefile
slepc-3.7.4/src/nep/impls/narnoldi/ftn-auto/0000755000175000017500000000000013107004621020223 5ustar jromanjromanslepc-3.7.4/src/nep/impls/narnoldi/ftn-auto/makefile0000644000175000017500000000036513107004621021727 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = narnoldif.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcnep LOCDIR = src/nep/impls/narnoldi/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/nep/impls/narnoldi/ftn-auto/narnoldif.c0000644000175000017500000000271513107004621022350 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* narnoldi.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcnep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnarnoldisetksp_ NEPNARNOLDISETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnarnoldisetksp_ nepnarnoldisetksp #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define nepnarnoldigetksp_ NEPNARNOLDIGETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define nepnarnoldigetksp_ nepnarnoldigetksp #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL nepnarnoldisetksp_(NEP nep,KSP ksp, int *__ierr ){ *__ierr = NEPNArnoldiSetKSP( (NEP)PetscToPointer((nep) ), (KSP)PetscToPointer((ksp) )); } PETSC_EXTERN void PETSC_STDCALL nepnarnoldigetksp_(NEP nep,KSP *ksp, int *__ierr ){ *__ierr = NEPNArnoldiGetKSP( (NEP)PetscToPointer((nep) ),ksp); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/0000755000175000017500000000000013107004621013541 5ustar jromanjromanslepc-3.7.4/src/eps/makefile0000644000175000017500000000216513107004621015245 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../include/slepc/private/epsimpl.h ../../include/slepceps.h DIRS = interface impls examples f90-mod LOCDIR = src/eps/ MANSEC = EPS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/interface/0000755000175000017500000000000013107004621015501 5ustar jromanjromanslepc-3.7.4/src/eps/interface/makefile0000644000175000017500000000230513107004621017201 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = epsmon.c epsbasic.c epsview.c epsdefault.c epsregis.c epsopts.c epssetup.c epssolve.c dlregiseps.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/interface/epssolve.c0000644000175000017500000006132013107004621017507 0ustar jromanjroman/* EPS routines related to the solution process. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "EPSComputeVectors" PetscErrorCode EPSComputeVectors(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; EPSCheckSolved(eps,1); switch (eps->state) { case EPS_STATE_SOLVED: if (eps->ops->computevectors) { ierr = (*eps->ops->computevectors)(eps);CHKERRQ(ierr); } break; default: break; } eps->state = EPS_STATE_EIGENVECTORS; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve" /*@ EPSSolve - Solves the eigensystem. Collective on EPS Input Parameter: . eps - eigensolver context obtained from EPSCreate() Options Database Keys: + -eps_view - print information about the solver used . -eps_view_mat0 binary - save the first matrix (A) to the default binary viewer . -eps_view_mat1 binary - save the second matrix (B) to the default binary viewer . -eps_view_vectors binary - save the computed eigenvectors to the default binary viewer . -eps_view_values - print computed eigenvalues . -eps_converged_reason - print reason for convergence, and number of iterations . -eps_error_absolute - print absolute errors of each eigenpair . -eps_error_relative - print relative errors of each eigenpair - -eps_error_backward - print backward errors of each eigenpair Level: beginner .seealso: EPSCreate(), EPSSetUp(), EPSDestroy(), EPSSetTolerances() @*/ PetscErrorCode EPSSolve(EPS eps) { PetscErrorCode ierr; PetscInt i,nmat; PetscScalar dot; PetscBool iscayley; STMatMode matmode; Mat A,B; Vec w,x; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (eps->state>=EPS_STATE_SOLVED) PetscFunctionReturn(0); ierr = PetscLogEventBegin(EPS_Solve,eps,0,0,0);CHKERRQ(ierr); /* call setup */ ierr = EPSSetUp(eps);CHKERRQ(ierr); eps->nconv = 0; eps->its = 0; for (i=0;incv;i++) { eps->eigr[i] = 0.0; eps->eigi[i] = 0.0; eps->errest[i] = 0.0; eps->perm[i] = i; } ierr = EPSViewFromOptions(eps,NULL,"-eps_view_pre");CHKERRQ(ierr); /* call solver */ ierr = (*eps->ops->solve)(eps);CHKERRQ(ierr); eps->state = EPS_STATE_SOLVED; ierr = STGetMatMode(eps->st,&matmode);CHKERRQ(ierr); if (matmode == ST_MATMODE_INPLACE && eps->ispositive) { /* Purify eigenvectors before reverting operator */ ierr = EPSComputeVectors(eps);CHKERRQ(ierr); } ierr = STPostSolve(eps->st);CHKERRQ(ierr); if (!eps->reason) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason"); /* Map eigenvalues back to the original problem, necessary in some * spectral transformations */ if (eps->ops->backtransform) { ierr = (*eps->ops->backtransform)(eps);CHKERRQ(ierr); } #if !defined(PETSC_USE_COMPLEX) /* reorder conjugate eigenvalues (positive imaginary first) */ for (i=0; inconv-1; i++) { if (eps->eigi[i] != 0) { if (eps->eigi[i] < 0) { eps->eigi[i] = -eps->eigi[i]; eps->eigi[i+1] = -eps->eigi[i+1]; /* the next correction only works with eigenvectors */ ierr = EPSComputeVectors(eps);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,i+1,-1.0);CHKERRQ(ierr); } i++; } } #endif ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } /* In the case of Cayley transform, eigenvectors need to be B-normalized */ ierr = PetscObjectTypeCompare((PetscObject)eps->st,STCAYLEY,&iscayley);CHKERRQ(ierr); if (iscayley && nmat>1 && eps->ishermitian) { ierr = MatCreateVecs(B,NULL,&w);CHKERRQ(ierr); ierr = EPSComputeVectors(eps);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = BVGetColumn(eps->V,i,&x);CHKERRQ(ierr); ierr = MatMult(B,x,w);CHKERRQ(ierr); ierr = VecDot(w,x,&dot);CHKERRQ(ierr); ierr = VecScale(x,1.0/PetscSqrtScalar(dot));CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&x);CHKERRQ(ierr); } ierr = VecDestroy(&w);CHKERRQ(ierr); } /* sort eigenvalues according to eps->which parameter */ ierr = SlepcSortEigenvalues(eps->sc,eps->nconv,eps->eigr,eps->eigi,eps->perm);CHKERRQ(ierr); ierr = PetscLogEventEnd(EPS_Solve,eps,0,0,0);CHKERRQ(ierr); /* various viewers */ ierr = EPSViewFromOptions(eps,NULL,"-eps_view");CHKERRQ(ierr); ierr = EPSReasonViewFromOptions(eps);CHKERRQ(ierr); ierr = EPSErrorViewFromOptions(eps);CHKERRQ(ierr); ierr = EPSValuesViewFromOptions(eps);CHKERRQ(ierr); ierr = EPSVectorsViewFromOptions(eps);CHKERRQ(ierr); ierr = MatViewFromOptions(A,(PetscObject)eps,"-eps_view_mat0");CHKERRQ(ierr); if (nmat>1) { ierr = MatViewFromOptions(B,(PetscObject)eps,"-eps_view_mat1");CHKERRQ(ierr); } /* Remove deflation and initial subspaces */ if (eps->nds) { ierr = BVSetNumConstraints(eps->V,0);CHKERRQ(ierr); eps->nds = 0; } eps->nini = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetIterationNumber" /*@ EPSGetIterationNumber - Gets the current iteration number. If the call to EPSSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If EPSSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call EPSGetConvergedReason() to determine if the solver converged or failed and why. .seealso: EPSGetConvergedReason(), EPSSetTolerances() @*/ PetscErrorCode EPSGetIterationNumber(EPS eps,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(its,2); *its = eps->its; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetConverged" /*@ EPSGetConverged - Gets the number of converged eigenpairs. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . nconv - number of converged eigenpairs Note: This function should be called after EPSSolve() has finished. Level: beginner .seealso: EPSSetDimensions(), EPSSolve() @*/ PetscErrorCode EPSGetConverged(EPS eps,PetscInt *nconv) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(nconv,2); EPSCheckSolved(eps,1); *nconv = eps->nconv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetConvergedReason" /*@ EPSGetConvergedReason - Gets the reason why the EPSSolve() iteration was stopped. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . reason - negative value indicates diverged, positive value converged Notes: Possible values for reason are + EPS_CONVERGED_TOL - converged up to tolerance . EPS_CONVERGED_USER - converged due to a user-defined condition . EPS_DIVERGED_ITS - required more than max_it iterations to reach convergence . EPS_DIVERGED_BREAKDOWN - generic breakdown in method - EPS_DIVERGED_SYMMETRY_LOST - pseudo-Lanczos was not able to keep symmetry Can only be called after the call to EPSSolve() is complete. Level: intermediate .seealso: EPSSetTolerances(), EPSSolve(), EPSConvergedReason @*/ PetscErrorCode EPSGetConvergedReason(EPS eps,EPSConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(reason,2); EPSCheckSolved(eps,1); *reason = eps->reason; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetInvariantSubspace" /*@ EPSGetInvariantSubspace - Gets an orthonormal basis of the computed invariant subspace. Not Collective, but vectors are shared by all processors that share the EPS Input Parameter: . eps - the eigensolver context Output Parameter: . v - an array of vectors Notes: This function should be called after EPSSolve() has finished. The user should provide in v an array of nconv vectors, where nconv is the value returned by EPSGetConverged(). The first k vectors returned in v span an invariant subspace associated with the first k computed eigenvalues (note that this is not true if the k-th eigenvalue is complex and matrix A is real; in this case the first k+1 vectors should be used). An invariant subspace X of A satisfies Ax in X for all x in X (a similar definition applies for generalized eigenproblems). Level: intermediate .seealso: EPSGetEigenpair(), EPSGetConverged(), EPSSolve() @*/ PetscErrorCode EPSGetInvariantSubspace(EPS eps,Vec *v) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(v,2); PetscValidHeaderSpecific(*v,VEC_CLASSID,2); EPSCheckSolved(eps,1); if (!eps->ishermitian && eps->state==EPS_STATE_EIGENVECTORS) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"EPSGetInvariantSubspace must be called before EPSGetEigenpair,EPSGetEigenvector or EPSComputeError"); for (i=0;inconv;i++) { ierr = BVCopyVec(eps->V,i,v[i]);CHKERRQ(ierr); if (eps->balance!=EPS_BALANCE_NONE && eps->D) { ierr = VecPointwiseDivide(v[i],v[i],eps->D);CHKERRQ(ierr); ierr = VecNormalize(v[i],NULL);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetEigenpair" /*@ EPSGetEigenpair - Gets the i-th solution of the eigenproblem as computed by EPSSolve(). The solution consists in both the eigenvalue and the eigenvector. Logically Collective on EPS Input Parameters: + eps - eigensolver context - i - index of the solution Output Parameters: + eigr - real part of eigenvalue . eigi - imaginary part of eigenvalue . Vr - real part of eigenvector - Vi - imaginary part of eigenvector Notes: It is allowed to pass NULL for Vr and Vi, if the eigenvector is not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs(). If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is set to zero). In both cases, the user can pass NULL in eigi and Vi. The index i should be a value between 0 and nconv-1 (see EPSGetConverged()). Eigenpairs are indexed according to the ordering criterion established with EPSSetWhichEigenpairs(). The 2-norm of the eigenvector is one unless the problem is generalized Hermitian. In this case the eigenvector is normalized with respect to the norm defined by the B matrix. Level: beginner .seealso: EPSGetEigenvalue(), EPSGetEigenvector(), EPSSolve(), EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetInvariantSubspace() @*/ PetscErrorCode EPSGetEigenpair(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,i,2); EPSCheckSolved(eps,1); if (i<0 || i>=eps->nconv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); ierr = EPSGetEigenvalue(eps,i,eigr,eigi);CHKERRQ(ierr); if (Vr || Vi) { ierr = EPSGetEigenvector(eps,i,Vr,Vi);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetEigenvalue" /*@ EPSGetEigenvalue - Gets the i-th eigenvalue as computed by EPSSolve(). Not Collective Input Parameters: + eps - eigensolver context - i - index of the solution Output Parameters: + eigr - real part of eigenvalue - eigi - imaginary part of eigenvalue Notes: If the eigenvalue is real, then eigi is set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero). The index i should be a value between 0 and nconv-1 (see EPSGetConverged()). Eigenpairs are indexed according to the ordering criterion established with EPSSetWhichEigenpairs(). Level: beginner .seealso: EPSSolve(), EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetEigenpair() @*/ PetscErrorCode EPSGetEigenvalue(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi) { PetscInt k; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); EPSCheckSolved(eps,1); if (i<0 || i>=eps->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); k = eps->perm[i]; #if defined(PETSC_USE_COMPLEX) if (eigr) *eigr = eps->eigr[k]; if (eigi) *eigi = 0; #else if (eigr) *eigr = eps->eigr[k]; if (eigi) *eigi = eps->eigi[k]; #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetEigenvector" /*@ EPSGetEigenvector - Gets the i-th right eigenvector as computed by EPSSolve(). Logically Collective on EPS Input Parameters: + eps - eigensolver context - i - index of the solution Output Parameters: + Vr - real part of eigenvector - Vi - imaginary part of eigenvector Notes: The caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs(). If the corresponding eigenvalue is real, then Vi is set to zero. If PETSc is configured with complex scalars the eigenvector is stored directly in Vr (Vi is set to zero). In both cases, the user can pass NULL in Vi. The index i should be a value between 0 and nconv-1 (see EPSGetConverged()). Eigenpairs are indexed according to the ordering criterion established with EPSSetWhichEigenpairs(). The 2-norm of the eigenvector is one unless the problem is generalized Hermitian. In this case the eigenvector is normalized with respect to the norm defined by the B matrix. Level: beginner .seealso: EPSSolve(), EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetEigenpair() @*/ PetscErrorCode EPSGetEigenvector(EPS eps,PetscInt i,Vec Vr,Vec Vi) { PetscErrorCode ierr; PetscInt k; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,i,2); PetscValidHeaderSpecific(Vr,VEC_CLASSID,3); PetscCheckSameComm(eps,1,Vr,3); if (Vi) { PetscValidHeaderSpecific(Vi,VEC_CLASSID,4); PetscCheckSameComm(eps,1,Vi,4); } EPSCheckSolved(eps,1); if (i<0 || i>=eps->nconv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); ierr = EPSComputeVectors(eps);CHKERRQ(ierr); k = eps->perm[i]; #if defined(PETSC_USE_COMPLEX) ierr = BVCopyVec(eps->V,k,Vr);CHKERRQ(ierr); if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } #else if (eps->eigi[k] > 0) { /* first value of conjugate pair */ ierr = BVCopyVec(eps->V,k,Vr);CHKERRQ(ierr); if (Vi) { ierr = BVCopyVec(eps->V,k+1,Vi);CHKERRQ(ierr); } } else if (eps->eigi[k] < 0) { /* second value of conjugate pair */ ierr = BVCopyVec(eps->V,k-1,Vr);CHKERRQ(ierr); if (Vi) { ierr = BVCopyVec(eps->V,k,Vi);CHKERRQ(ierr); ierr = VecScale(Vi,-1.0);CHKERRQ(ierr); } } else { /* real eigenvalue */ ierr = BVCopyVec(eps->V,k,Vr);CHKERRQ(ierr); if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetErrorEstimate" /*@ EPSGetErrorEstimate - Returns the error estimate associated to the i-th computed eigenpair. Not Collective Input Parameter: + eps - eigensolver context - i - index of eigenpair Output Parameter: . errest - the error estimate Notes: This is the error estimate used internally by the eigensolver. The actual error bound can be computed with EPSComputeError(). See also the users manual for details. Level: advanced .seealso: EPSComputeError() @*/ PetscErrorCode EPSGetErrorEstimate(EPS eps,PetscInt i,PetscReal *errest) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(errest,3); EPSCheckSolved(eps,1); if (i<0 || i>=eps->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); if (errest) *errest = eps->errest[eps->perm[i]]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeResidualNorm_Private" /* EPSComputeResidualNorm_Private - Computes the norm of the residual vector associated with an eigenpair. Input Parameters: kr,ki - eigenvalue xr,xi - eigenvector z - three work vectors (the second one not referenced in complex scalars) */ PetscErrorCode EPSComputeResidualNorm_Private(EPS eps,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm) { PetscErrorCode ierr; PetscInt nmat; Mat A,B; Vec u,w; #if !defined(PETSC_USE_COMPLEX) Vec v; PetscReal ni,nr; #endif PetscFunctionBegin; u = z[0]; w = z[2]; ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } #if !defined(PETSC_USE_COMPLEX) v = z[1]; if (ki == 0 || PetscAbsScalar(ki) < PetscAbsScalar(kr*PETSC_MACHINE_EPSILON)) { #endif ierr = MatMult(A,xr,u);CHKERRQ(ierr); /* u=A*x */ if (PetscAbsScalar(kr) > PETSC_MACHINE_EPSILON) { if (nmat>1) { ierr = MatMult(B,xr,w);CHKERRQ(ierr); } else { ierr = VecCopy(xr,w);CHKERRQ(ierr); } /* w=B*x */ ierr = VecAXPY(u,-kr,w);CHKERRQ(ierr); /* u=A*x-k*B*x */ } ierr = VecNorm(u,NORM_2,norm);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) } else { ierr = MatMult(A,xr,u);CHKERRQ(ierr); /* u=A*xr */ if (SlepcAbsEigenvalue(kr,ki) > PETSC_MACHINE_EPSILON) { if (nmat>1) { ierr = MatMult(B,xr,v);CHKERRQ(ierr); } else { ierr = VecCopy(xr,v);CHKERRQ(ierr); } /* v=B*xr */ ierr = VecAXPY(u,-kr,v);CHKERRQ(ierr); /* u=A*xr-kr*B*xr */ if (nmat>1) { ierr = MatMult(B,xi,w);CHKERRQ(ierr); } else { ierr = VecCopy(xi,w);CHKERRQ(ierr); } /* w=B*xi */ ierr = VecAXPY(u,ki,w);CHKERRQ(ierr); /* u=A*xr-kr*B*xr+ki*B*xi */ } ierr = VecNorm(u,NORM_2,&nr);CHKERRQ(ierr); ierr = MatMult(A,xi,u);CHKERRQ(ierr); /* u=A*xi */ if (SlepcAbsEigenvalue(kr,ki) > PETSC_MACHINE_EPSILON) { ierr = VecAXPY(u,-kr,w);CHKERRQ(ierr); /* u=A*xi-kr*B*xi */ ierr = VecAXPY(u,-ki,v);CHKERRQ(ierr); /* u=A*xi-kr*B*xi-ki*B*xr */ } ierr = VecNorm(u,NORM_2,&ni);CHKERRQ(ierr); *norm = SlepcAbsEigenvalue(nr,ni); } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeError" /*@ EPSComputeError - Computes the error (based on the residual norm) associated with the i-th computed eigenpair. Collective on EPS Input Parameter: + eps - the eigensolver context . i - the solution index - type - the type of error to compute Output Parameter: . error - the error Notes: The error can be computed in various ways, all of them based on the residual norm ||Ax-kBx||_2 where k is the eigenvalue and x is the eigenvector. Level: beginner .seealso: EPSErrorType, EPSSolve(), EPSGetErrorEstimate() @*/ PetscErrorCode EPSComputeError(EPS eps,PetscInt i,EPSErrorType type,PetscReal *error) { PetscErrorCode ierr; Mat A,B; Vec xr,xi,w[3]; PetscReal t; PetscScalar kr,ki; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,i,2); PetscValidLogicalCollectiveEnum(eps,type,3); PetscValidPointer(error,4); EPSCheckSolved(eps,1); /* allocate work vectors */ #if defined(PETSC_USE_COMPLEX) ierr = EPSSetWorkVecs(eps,3);CHKERRQ(ierr); xi = NULL; w[1] = NULL; #else ierr = EPSSetWorkVecs(eps,5);CHKERRQ(ierr); xi = eps->work[3]; w[1] = eps->work[4]; #endif xr = eps->work[0]; w[0] = eps->work[1]; w[2] = eps->work[2]; /* compute residual norms */ ierr = EPSGetEigenpair(eps,i,&kr,&ki,xr,xi);CHKERRQ(ierr); ierr = EPSComputeResidualNorm_Private(eps,kr,ki,xr,xi,w,error);CHKERRQ(ierr); /* compute error */ switch (type) { case EPS_ERROR_ABSOLUTE: break; case EPS_ERROR_RELATIVE: *error /= SlepcAbsEigenvalue(kr,ki); break; case EPS_ERROR_BACKWARD: /* initialization of matrix norms */ if (!eps->nrma) { ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); ierr = MatHasOperation(A,MATOP_NORM,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation"); ierr = MatNorm(A,NORM_INFINITY,&eps->nrma);CHKERRQ(ierr); } if (eps->isgeneralized) { if (!eps->nrmb) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); ierr = MatHasOperation(B,MATOP_NORM,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation"); ierr = MatNorm(B,NORM_INFINITY,&eps->nrmb);CHKERRQ(ierr); } } else eps->nrmb = 1.0; t = SlepcAbsEigenvalue(kr,ki); *error /= eps->nrma+t*eps->nrmb; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetStartVector" /* EPSGetStartVector - Generate a suitable vector to be used as the starting vector for the recurrence that builds the right subspace. Collective on EPS and Vec Input Parameters: + eps - the eigensolver context - i - iteration number Output Parameters: . breakdown - flag indicating that a breakdown has occurred Notes: The start vector is computed from another vector: for the first step (i=0), the first initial vector is used (see EPSSetInitialSpace()); otherwise a random vector is created. Then this vector is forced to be in the range of OP (only for generalized definite problems) and orthonormalized with respect to all V-vectors up to i-1. The resulting vector is placed in V[i]. The flag breakdown is set to true if either i=0 and the vector belongs to the deflation space, or i>0 and the vector is linearly dependent with respect to the V-vectors. */ PetscErrorCode EPSGetStartVector(EPS eps,PetscInt i,PetscBool *breakdown) { PetscErrorCode ierr; PetscReal norm; PetscBool lindep; Vec w,z; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,i,2); /* For the first step, use the first initial vector, otherwise a random one */ if (i>0 || eps->nini==0) { ierr = BVSetRandomColumn(eps->V,i);CHKERRQ(ierr); } /* Force the vector to be in the range of OP for definite generalized problems */ if (eps->ispositive || (eps->isgeneralized && eps->ishermitian)) { ierr = BVCreateVec(eps->V,&w);CHKERRQ(ierr); ierr = BVCopyVec(eps->V,i,w);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,i,&z);CHKERRQ(ierr); ierr = STApply(eps->st,w,z);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&z);CHKERRQ(ierr); ierr = VecDestroy(&w);CHKERRQ(ierr); } /* Orthonormalize the vector with respect to previous vectors */ ierr = BVOrthogonalizeColumn(eps->V,i,NULL,&norm,&lindep);CHKERRQ(ierr); if (breakdown) *breakdown = lindep; else if (lindep || norm == 0.0) { if (i==0) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Initial vector is zero or belongs to the deflation space"); else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unable to generate more start vectors"); } ierr = BVScaleColumn(eps->V,i,1.0/norm);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/interface/epsview.c.html0000644000175000017500000017642613107004621020312 0ustar jromanjroman

Actual source code: epsview.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    The EPS routines related to various viewers.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>      /*I "slepceps.h" I*/
 25: #include <petscdraw.h>

 29: /*@C
 30:    EPSView - Prints the EPS data structure.

 32:    Collective on EPS

 34:    Input Parameters:
 35: +  eps - the eigenproblem solver context
 36: -  viewer - optional visualization context

 38:    Options Database Key:
 39: .  -eps_view -  Calls EPSView() at end of EPSSolve()

 41:    Note:
 42:    The available visualization contexts include
 43: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
 44: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
 45:          output where only the first processor opens
 46:          the file.  All other processors send their
 47:          data to the first processor to print.

 49:    The user can open an alternative visualization context with
 50:    PetscViewerASCIIOpen() - output to a specified file.

 52:    Level: beginner

 54: .seealso: STView(), PetscViewerASCIIOpen()
 55: @*/
 56: PetscErrorCode EPSView(EPS eps,PetscViewer viewer)
 57: {
 59:   const char     *type,*extr,*bal;
 60:   char           str[50];
 61:   PetscBool      isascii,ispower,isexternal,istrivial;

 65:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps));

 69: #if defined(PETSC_USE_COMPLEX)
 70: #define HERM "hermitian"
 71: #else
 72: #define HERM "symmetric"
 73: #endif
 74:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
 75:   if (isascii) {
 76:     PetscObjectPrintClassNamePrefixType((PetscObject)eps,viewer);
 77:     if (eps->ops->view) {
 78:       PetscViewerASCIIPushTab(viewer);
 79:       (*eps->ops->view)(eps,viewer);
 80:       PetscViewerASCIIPopTab(viewer);
 81:     }
 82:     if (eps->problem_type) {
 83:       switch (eps->problem_type) {
 84:         case EPS_HEP:   type = HERM " eigenvalue problem"; break;
 85:         case EPS_GHEP:  type = "generalized " HERM " eigenvalue problem"; break;
 86:         case EPS_NHEP:  type = "non-" HERM " eigenvalue problem"; break;
 87:         case EPS_GNHEP: type = "generalized non-" HERM " eigenvalue problem"; break;
 88:         case EPS_PGNHEP: type = "generalized non-" HERM " eigenvalue problem with " HERM " positive definite B"; break;
 89:         case EPS_GHIEP: type = "generalized " HERM "-indefinite eigenvalue problem"; break;
 90:         default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->problem_type");
 91:       }
 92:     } else type = "not yet set";
 93:     PetscViewerASCIIPrintf(viewer,"  problem type: %s\n",type);
 94:     if (eps->extraction) {
 95:       switch (eps->extraction) {
 96:         case EPS_RITZ:             extr = "Rayleigh-Ritz"; break;
 97:         case EPS_HARMONIC:         extr = "harmonic Ritz"; break;
 98:         case EPS_HARMONIC_RELATIVE:extr = "relative harmonic Ritz"; break;
 99:         case EPS_HARMONIC_RIGHT:   extr = "right harmonic Ritz"; break;
100:         case EPS_HARMONIC_LARGEST: extr = "largest harmonic Ritz"; break;
101:         case EPS_REFINED:          extr = "refined Ritz"; break;
102:         case EPS_REFINED_HARMONIC: extr = "refined harmonic Ritz"; break;
103:         default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->extraction");
104:       }
105:       PetscViewerASCIIPrintf(viewer,"  extraction type: %s\n",extr);
106:     }
107:     if (!eps->ishermitian && eps->balance!=EPS_BALANCE_NONE) {
108:       switch (eps->balance) {
109:         case EPS_BALANCE_ONESIDE:   bal = "one-sided Krylov"; break;
110:         case EPS_BALANCE_TWOSIDE:   bal = "two-sided Krylov"; break;
111:         case EPS_BALANCE_USER:      bal = "user-defined matrix"; break;
112:         default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->balance");
113:       }
114:       PetscViewerASCIIPrintf(viewer,"  balancing enabled: %s",bal);
115:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
116:       if (eps->balance==EPS_BALANCE_ONESIDE || eps->balance==EPS_BALANCE_TWOSIDE) {
117:         PetscViewerASCIIPrintf(viewer,", with its=%D",eps->balance_its);
118:       }
119:       if (eps->balance==EPS_BALANCE_TWOSIDE && eps->balance_cutoff!=0.0) {
120:         PetscViewerASCIIPrintf(viewer," and cutoff=%g",(double)eps->balance_cutoff);
121:       }
122:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
123:       PetscViewerASCIIPrintf(viewer,"\n");
124:     }
125:     PetscViewerASCIIPrintf(viewer,"  selected portion of the spectrum: ");
126:     SlepcSNPrintfScalar(str,50,eps->target,PETSC_FALSE);
127:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
128:     if (!eps->which) {
129:       PetscViewerASCIIPrintf(viewer,"not yet set\n");
130:     } else switch (eps->which) {
131:       case EPS_WHICH_USER:
132:         PetscViewerASCIIPrintf(viewer,"user defined\n");
133:         break;
134:       case EPS_TARGET_MAGNITUDE:
135:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (in magnitude)\n",str);
136:         break;
137:       case EPS_TARGET_REAL:
138:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the real axis)\n",str);
139:         break;
140:       case EPS_TARGET_IMAGINARY:
141:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the imaginary axis)\n",str);
142:         break;
143:       case EPS_LARGEST_MAGNITUDE:
144:         PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");
145:         break;
146:       case EPS_SMALLEST_MAGNITUDE:
147:         PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");
148:         break;
149:       case EPS_LARGEST_REAL:
150:         PetscViewerASCIIPrintf(viewer,"largest real parts\n");
151:         break;
152:       case EPS_SMALLEST_REAL:
153:         PetscViewerASCIIPrintf(viewer,"smallest real parts\n");
154:         break;
155:       case EPS_LARGEST_IMAGINARY:
156:         PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");
157:         break;
158:       case EPS_SMALLEST_IMAGINARY:
159:         PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");
160:         break;
161:       case EPS_ALL:
162:         if (eps->inta || eps->intb) {
163:           PetscViewerASCIIPrintf(viewer,"all eigenvalues in interval [%g,%g]\n",(double)eps->inta,(double)eps->intb);
164:         } else {
165:           PetscViewerASCIIPrintf(viewer,"all eigenvalues in the region\n");
166:         }
167:         break;
168:       default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
169:     }
170:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
171:     if (eps->isgeneralized && eps->ishermitian && eps->purify) {
172:       PetscViewerASCIIPrintf(viewer,"  postprocessing eigenvectors with purification\n");
173:     }
174:     if (eps->trueres) {
175:       PetscViewerASCIIPrintf(viewer,"  computing true residuals explicitly\n");
176:     }
177:     if (eps->trackall) {
178:       PetscViewerASCIIPrintf(viewer,"  computing all residuals (for tracking convergence)\n");
179:     }
180:     PetscViewerASCIIPrintf(viewer,"  number of eigenvalues (nev): %D\n",eps->nev);
181:     PetscViewerASCIIPrintf(viewer,"  number of column vectors (ncv): %D\n",eps->ncv);
182:     PetscViewerASCIIPrintf(viewer,"  maximum dimension of projected problem (mpd): %D\n",eps->mpd);
183:     PetscViewerASCIIPrintf(viewer,"  maximum number of iterations: %D\n",eps->max_it);
184:     PetscViewerASCIIPrintf(viewer,"  tolerance: %g\n",(double)eps->tol);
185:     PetscViewerASCIIPrintf(viewer,"  convergence test: ");
186:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
187:     switch (eps->conv) {
188:     case EPS_CONV_ABS:
189:       PetscViewerASCIIPrintf(viewer,"absolute\n");break;
190:     case EPS_CONV_REL:
191:       PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue\n");break;
192:     case EPS_CONV_NORM:
193:       PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue and matrix norms\n");
194:       PetscViewerASCIIPrintf(viewer,"  computed matrix norms: norm(A)=%g",(double)eps->nrma);
195:       if (eps->isgeneralized) {
196:         PetscViewerASCIIPrintf(viewer,", norm(B)=%g",(double)eps->nrmb);
197:       }
198:       PetscViewerASCIIPrintf(viewer,"\n");
199:       break;
200:     case EPS_CONV_USER:
201:       PetscViewerASCIIPrintf(viewer,"user-defined\n");break;
202:     }
203:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
204:     if (eps->nini) {
205:       PetscViewerASCIIPrintf(viewer,"  dimension of user-provided initial space: %D\n",PetscAbs(eps->nini));
206:     }
207:     if (eps->nds) {
208:       PetscViewerASCIIPrintf(viewer,"  dimension of user-provided deflation space: %D\n",PetscAbs(eps->nds));
209:     }
210:   } else {
211:     if (eps->ops->view) {
212:       (*eps->ops->view)(eps,viewer);
213:     }
214:   }
215:   PetscObjectTypeCompareAny((PetscObject)eps,&isexternal,EPSARPACK,EPSBLZPACK,EPSTRLAN,EPSBLOPEX,EPSPRIMME,"");
216:   if (!isexternal) {
217:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);
218:     if (!eps->V) { EPSGetBV(eps,&eps->V); }
219:     BVView(eps->V,viewer);
220:     if (eps->rg) {
221:       RGIsTrivial(eps->rg,&istrivial);
222:       if (!istrivial) { RGView(eps->rg,viewer); }
223:     }
224:     PetscObjectTypeCompare((PetscObject)eps,EPSPOWER,&ispower);
225:     if (!ispower) {
226:       if (!eps->ds) { EPSGetDS(eps,&eps->ds); }
227:       DSView(eps->ds,viewer);
228:     }
229:     PetscViewerPopFormat(viewer);
230:   }
231:   if (!eps->st) { EPSGetST(eps,&eps->st); }
232:   STView(eps->st,viewer);
233:   return(0);
234: }

238: /*@C
239:    EPSReasonView - Displays the reason an EPS solve converged or diverged.

241:    Collective on EPS

243:    Parameter:
244: +  eps - the eigensolver context
245: -  viewer - the viewer to display the reason

247:    Options Database Keys:
248: .  -eps_converged_reason - print reason for convergence, and number of iterations

250:    Level: intermediate

252: .seealso: EPSSetConvergenceTest(), EPSSetTolerances(), EPSGetIterationNumber()
253: @*/
254: PetscErrorCode EPSReasonView(EPS eps,PetscViewer viewer)
255: {
257:   PetscBool      isAscii;

260:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);
261:   if (isAscii) {
262:     PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);
263:     if (eps->reason > 0) {
264:       PetscViewerASCIIPrintf(viewer,"%s Linear eigensolve converged (%D eigenpair%s) due to %s; iterations %D\n",((PetscObject)eps)->prefix?((PetscObject)eps)->prefix:"",eps->nconv,(eps->nconv>1)?"s":"",EPSConvergedReasons[eps->reason],eps->its);
265:     } else {
266:       PetscViewerASCIIPrintf(viewer,"%s Linear eigensolve did not converge due to %s; iterations %D\n",((PetscObject)eps)->prefix?((PetscObject)eps)->prefix:"",EPSConvergedReasons[eps->reason],eps->its);
267:     }
268:     PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);
269:   }
270:   return(0);
271: }

275: /*@
276:    EPSReasonViewFromOptions - Processes command line options to determine if/how
277:    the EPS converged reason is to be viewed. 

279:    Collective on EPS

281:    Input Parameters:
282: .  eps - the eigensolver context

284:    Level: developer
285: @*/
286: PetscErrorCode EPSReasonViewFromOptions(EPS eps)
287: {
288:   PetscErrorCode    ierr;
289:   PetscViewer       viewer;
290:   PetscBool         flg;
291:   static PetscBool  incall = PETSC_FALSE;
292:   PetscViewerFormat format;

295:   if (incall) return(0);
296:   incall = PETSC_TRUE;
297:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_converged_reason",&viewer,&format,&flg);
298:   if (flg) {
299:     PetscViewerPushFormat(viewer,format);
300:     EPSReasonView(eps,viewer);
301:     PetscViewerPopFormat(viewer);
302:     PetscViewerDestroy(&viewer);
303:   }
304:   incall = PETSC_FALSE;
305:   return(0);
306: }

310: static PetscErrorCode EPSErrorView_ASCII(EPS eps,EPSErrorType etype,PetscViewer viewer)
311: {
312:   PetscBool      errok;
313:   PetscReal      error,re,im;
314:   PetscScalar    kr,ki;
315:   PetscInt       i,j,nvals;

319:   if (eps->which!=EPS_ALL && eps->nconv<eps->nev) {
320:     PetscViewerASCIIPrintf(viewer," Problem: less than %D eigenvalues converged\n\n",eps->nev);
321:     return(0);
322:   }
323:   errok = PETSC_TRUE;
324:   nvals = (eps->which==EPS_ALL)? eps->nconv: eps->nev;
325:   for (i=0;i<nvals;i++) {
326:     EPSComputeError(eps,i,etype,&error);
327:     errok = (errok && error<5.0*eps->tol)? PETSC_TRUE: PETSC_FALSE;
328:   }
329:   if (!errok) {
330:     PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",nvals);
331:     return(0);
332:   }
333:   if (eps->which==EPS_ALL) {
334:     PetscViewerASCIIPrintf(viewer," Found %D eigenvalues, all of them computed up to the required tolerance:",nvals);
335:   } else {
336:     PetscViewerASCIIPrintf(viewer," All requested eigenvalues computed up to the required tolerance:");
337:   }
338:   for (i=0;i<=(nvals-1)/8;i++) {
339:     PetscViewerASCIIPrintf(viewer,"\n     ");
340:     for (j=0;j<PetscMin(8,nvals-8*i);j++) {
341:       EPSGetEigenpair(eps,8*i+j,&kr,&ki,NULL,NULL);
342: #if defined(PETSC_USE_COMPLEX)
343:       re = PetscRealPart(kr);
344:       im = PetscImaginaryPart(kr);
345: #else
346:       re = kr;
347:       im = ki;
348: #endif
349:       if (PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0;
350:       if (PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0;
351:       if (im!=0.0) {
352:         PetscViewerASCIIPrintf(viewer,"%.5f%+.5fi",(double)re,(double)im);
353:       } else {
354:         PetscViewerASCIIPrintf(viewer,"%.5f",(double)re);
355:       }
356:       if (8*i+j+1<nvals) { PetscViewerASCIIPrintf(viewer,", "); }
357:     }
358:   }
359:   PetscViewerASCIIPrintf(viewer,"\n\n");
360:   return(0);
361: }

365: static PetscErrorCode EPSErrorView_DETAIL(EPS eps,EPSErrorType etype,PetscViewer viewer)
366: {
368:   PetscReal      error,re,im;
369:   PetscScalar    kr,ki;
370:   PetscInt       i;
371: #define EXLEN 30
372:   char           ex[EXLEN],sep[]=" ---------------------- --------------------\n";

375:   if (!eps->nconv) return(0);
376:   switch (etype) {
377:     case EPS_ERROR_ABSOLUTE:
378:       PetscSNPrintf(ex,EXLEN,"   ||Ax-k%sx||",eps->isgeneralized?"B":"");
379:       break;
380:     case EPS_ERROR_RELATIVE:
381:       PetscSNPrintf(ex,EXLEN,"||Ax-k%sx||/||kx||",eps->isgeneralized?"B":"");
382:       break;
383:     case EPS_ERROR_BACKWARD:
384:       PetscSNPrintf(ex,EXLEN,"    eta(x,k)");
385:       break;
386:   }
387:   PetscViewerASCIIPrintf(viewer,"%s            k             %s\n%s",sep,ex,sep);
388:   for (i=0;i<eps->nconv;i++) {
389:     EPSGetEigenpair(eps,i,&kr,&ki,NULL,NULL);
390:     EPSComputeError(eps,i,etype,&error);
391: #if defined(PETSC_USE_COMPLEX)
392:     re = PetscRealPart(kr);
393:     im = PetscImaginaryPart(kr);
394: #else
395:     re = kr;
396:     im = ki;
397: #endif
398:     if (im!=0.0) {
399:       PetscViewerASCIIPrintf(viewer,"  % 9f%+9fi      %12g\n",(double)re,(double)im,(double)error);
400:     } else {
401:       PetscViewerASCIIPrintf(viewer,"    % 12f           %12g\n",(double)re,(double)error);
402:     }
403:   }
404:   PetscViewerASCIIPrintf(viewer,sep);
405:   return(0);
406: }

410: static PetscErrorCode EPSErrorView_MATLAB(EPS eps,EPSErrorType etype,PetscViewer viewer)
411: {
413:   PetscReal      error;
414:   PetscInt       i;
415:   const char     *name;

418:   PetscObjectGetName((PetscObject)eps,&name);
419:   PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);
420:   for (i=0;i<eps->nconv;i++) {
421:     EPSComputeError(eps,i,etype,&error);
422:     PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);
423:   }
424:   PetscViewerASCIIPrintf(viewer,"];\n");
425:   return(0);
426: }

430: /*@C
431:    EPSErrorView - Displays the errors associated with the computed solution
432:    (as well as the eigenvalues).

434:    Collective on EPS

436:    Input Parameters:
437: +  eps    - the eigensolver context
438: .  etype  - error type
439: -  viewer - optional visualization context

441:    Options Database Key:
442: +  -eps_error_absolute - print absolute errors of each eigenpair
443: .  -eps_error_relative - print relative errors of each eigenpair
444: -  -eps_error_backward - print backward errors of each eigenpair

446:    Notes:
447:    By default, this function checks the error of all eigenpairs and prints
448:    the eigenvalues if all of them are below the requested tolerance.
449:    If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with
450:    eigenvalues and corresponding errors is printed.

452:    Level: intermediate

454: .seealso: EPSSolve(), EPSValuesView(), EPSVectorsView()
455: @*/
456: PetscErrorCode EPSErrorView(EPS eps,EPSErrorType etype,PetscViewer viewer)
457: {
458:   PetscBool         isascii;
459:   PetscViewerFormat format;
460:   PetscErrorCode    ierr;

464:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps));
467:   EPSCheckSolved(eps,1);
468:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
469:   if (!isascii) return(0);

471:   PetscViewerGetFormat(viewer,&format);
472:   switch (format) {
473:     case PETSC_VIEWER_DEFAULT:
474:     case PETSC_VIEWER_ASCII_INFO:
475:       EPSErrorView_ASCII(eps,etype,viewer);
476:       break;
477:     case PETSC_VIEWER_ASCII_INFO_DETAIL:
478:       EPSErrorView_DETAIL(eps,etype,viewer);
479:       break;
480:     case PETSC_VIEWER_ASCII_MATLAB:
481:       EPSErrorView_MATLAB(eps,etype,viewer);
482:       break;
483:     default:
484:       PetscInfo1(eps,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
485:   }
486:   return(0);
487: }

491: /*@
492:    EPSErrorViewFromOptions - Processes command line options to determine if/how
493:    the errors of the computed solution are to be viewed. 

495:    Collective on EPS

497:    Input Parameters:
498: .  eps - the eigensolver context

500:    Level: developer
501: @*/
502: PetscErrorCode EPSErrorViewFromOptions(EPS eps)
503: {
504:   PetscErrorCode    ierr;
505:   PetscViewer       viewer;
506:   PetscBool         flg;
507:   static PetscBool  incall = PETSC_FALSE;
508:   PetscViewerFormat format;

511:   if (incall) return(0);
512:   incall = PETSC_TRUE;
513:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_error_absolute",&viewer,&format,&flg);
514:   if (flg) {
515:     PetscViewerPushFormat(viewer,format);
516:     EPSErrorView(eps,EPS_ERROR_ABSOLUTE,viewer);
517:     PetscViewerPopFormat(viewer);
518:     PetscViewerDestroy(&viewer);
519:   }
520:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_error_relative",&viewer,&format,&flg);
521:   if (flg) {
522:     PetscViewerPushFormat(viewer,format);
523:     EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);
524:     PetscViewerPopFormat(viewer);
525:     PetscViewerDestroy(&viewer);
526:   }
527:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_error_backward",&viewer,&format,&flg);
528:   if (flg) {
529:     PetscViewerPushFormat(viewer,format);
530:     EPSErrorView(eps,EPS_ERROR_BACKWARD,viewer);
531:     PetscViewerPopFormat(viewer);
532:     PetscViewerDestroy(&viewer);
533:   }
534:   incall = PETSC_FALSE;
535:   return(0);
536: }

540: static PetscErrorCode EPSValuesView_DRAW(EPS eps,PetscViewer viewer)
541: {
543:   PetscDraw      draw;
544:   PetscDrawSP    drawsp;
545:   PetscReal      re,im;
546:   PetscInt       i,k;

549:   if (!eps->nconv) return(0);
550:   PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed Eigenvalues",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);
551:   PetscViewerDrawGetDraw(viewer,0,&draw);
552:   PetscDrawSPCreate(draw,1,&drawsp);
553:   for (i=0;i<eps->nconv;i++) {
554:     k = eps->perm[i];
555: #if defined(PETSC_USE_COMPLEX)
556:     re = PetscRealPart(eps->eigr[k]);
557:     im = PetscImaginaryPart(eps->eigr[k]);
558: #else
559:     re = eps->eigr[k];
560:     im = eps->eigi[k];
561: #endif
562:     PetscDrawSPAddPoint(drawsp,&re,&im);
563:   }
564:   PetscDrawSPDraw(drawsp,PETSC_TRUE);
565:   PetscDrawSPSave(drawsp);
566:   PetscDrawSPDestroy(&drawsp);
567:   PetscViewerDestroy(&viewer);
568:   return(0);
569: }

573: static PetscErrorCode EPSValuesView_ASCII(EPS eps,PetscViewer viewer)
574: {
575:   PetscReal      re,im;
576:   PetscInt       i,k;

580:   PetscViewerASCIIPrintf(viewer,"Eigenvalues = \n");
581:   for (i=0;i<eps->nconv;i++) {
582:     k = eps->perm[i];
583: #if defined(PETSC_USE_COMPLEX)
584:     re = PetscRealPart(eps->eigr[k]);
585:     im = PetscImaginaryPart(eps->eigr[k]);
586: #else
587:     re = eps->eigr[k];
588:     im = eps->eigi[k];
589: #endif
590:     if (PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0;
591:     if (PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0;
592:     if (im!=0.0) {
593:       PetscViewerASCIIPrintf(viewer,"   %.5f%+.5fi\n",(double)re,(double)im);
594:     } else {
595:       PetscViewerASCIIPrintf(viewer,"   %.5f\n",(double)re);
596:     }
597:   }
598:   PetscViewerASCIIPrintf(viewer,"\n");
599:   return(0);
600: }

604: static PetscErrorCode EPSValuesView_MATLAB(EPS eps,PetscViewer viewer)
605: {
607:   PetscInt       i,k;
608:   PetscReal      re,im;
609:   const char     *name;

612:   PetscObjectGetName((PetscObject)eps,&name);
613:   PetscViewerASCIIPrintf(viewer,"Lambda_%s = [\n",name);
614:   for (i=0;i<eps->nconv;i++) {
615:     k = eps->perm[i];
616: #if defined(PETSC_USE_COMPLEX)
617:     re = PetscRealPart(eps->eigr[k]);
618:     im = PetscImaginaryPart(eps->eigr[k]);
619: #else
620:     re = eps->eigr[k];
621:     im = eps->eigi[k];
622: #endif
623:     if (im!=0.0) {
624:       PetscViewerASCIIPrintf(viewer,"%18.16e%+18.16ei\n",(double)re,(double)im);
625:     } else {
626:       PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)re);
627:     }
628:   }
629:   PetscViewerASCIIPrintf(viewer,"];\n");
630:   return(0);
631: }

635: /*@C
636:    EPSValuesView - Displays the computed eigenvalues in a viewer.

638:    Collective on EPS

640:    Input Parameters:
641: +  eps    - the eigensolver context
642: -  viewer - the viewer

644:    Options Database Key:
645: .  -eps_view_values - print computed eigenvalues

647:    Level: intermediate

649: .seealso: EPSSolve(), EPSVectorsView(), EPSErrorView()
650: @*/
651: PetscErrorCode EPSValuesView(EPS eps,PetscViewer viewer)
652: {
653:   PetscBool         isascii,isdraw;
654:   PetscViewerFormat format;
655:   PetscErrorCode    ierr;

659:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps));
662:   EPSCheckSolved(eps,1);
663:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);
664:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
665:   if (isdraw) {
666:     EPSValuesView_DRAW(eps,viewer);
667:   } else if (isascii) {
668:     PetscViewerGetFormat(viewer,&format);
669:     switch (format) {
670:       case PETSC_VIEWER_DEFAULT:
671:       case PETSC_VIEWER_ASCII_INFO:
672:       case PETSC_VIEWER_ASCII_INFO_DETAIL:
673:         EPSValuesView_ASCII(eps,viewer);
674:         break;
675:       case PETSC_VIEWER_ASCII_MATLAB:
676:         EPSValuesView_MATLAB(eps,viewer);
677:         break;
678:       default:
679:         PetscInfo1(eps,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
680:     }
681:   }
682:   return(0);
683: }

687: /*@
688:    EPSValuesViewFromOptions - Processes command line options to determine if/how
689:    the computed eigenvalues are to be viewed. 

691:    Collective on EPS

693:    Input Parameters:
694: .  eps - the eigensolver context

696:    Level: developer
697: @*/
698: PetscErrorCode EPSValuesViewFromOptions(EPS eps)
699: {
700:   PetscErrorCode    ierr;
701:   PetscViewer       viewer;
702:   PetscBool         flg;
703:   static PetscBool  incall = PETSC_FALSE;
704:   PetscViewerFormat format;

707:   if (incall) return(0);
708:   incall = PETSC_TRUE;
709:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_view_values",&viewer,&format,&flg);
710:   if (flg) {
711:     PetscViewerPushFormat(viewer,format);
712:     EPSValuesView(eps,viewer);
713:     PetscViewerPopFormat(viewer);
714:     PetscViewerDestroy(&viewer);
715:   }
716:   incall = PETSC_FALSE;
717:   return(0);
718: }

722: /*@C
723:    EPSVectorsView - Outputs computed eigenvectors to a viewer.

725:    Collective on EPS

727:    Parameter:
728: +  eps    - the eigensolver context
729: -  viewer - the viewer

731:    Options Database Keys:
732: .  -eps_view_vectors - output eigenvectors.

734:    Note:
735:    If PETSc was configured with real scalars, complex conjugate eigenvectors
736:    will be viewed as two separate real vectors, one containing the real part
737:    and another one containing the imaginary part.

739:    Level: intermediate

741: .seealso: EPSSolve(), EPSValuesView(), EPSErrorView()
742: @*/
743: PetscErrorCode EPSVectorsView(EPS eps,PetscViewer viewer)
744: {
746:   PetscInt       i,k;
747:   Vec            x;
748: #define NMLEN 30
749:   char           vname[NMLEN];
750:   const char     *ename;

754:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps));
757:   EPSCheckSolved(eps,1);
758:   if (eps->nconv) {
759:     PetscObjectGetName((PetscObject)eps,&ename);
760:     EPSComputeVectors(eps);
761:     for (i=0;i<eps->nconv;i++) {
762:       k = eps->perm[i];
763:       PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);
764:       BVGetColumn(eps->V,k,&x);
765:       PetscObjectSetName((PetscObject)x,vname);
766:       VecView(x,viewer);
767:       BVRestoreColumn(eps->V,k,&x);
768:     }
769:   }
770:   return(0);
771: }

775: /*@
776:    EPSVectorsViewFromOptions - Processes command line options to determine if/how
777:    the computed eigenvectors are to be viewed. 

779:    Collective on EPS

781:    Input Parameters:
782: .  eps - the eigensolver context

784:    Level: developer
785: @*/
786: PetscErrorCode EPSVectorsViewFromOptions(EPS eps)
787: {
788:   PetscErrorCode    ierr;
789:   PetscViewer       viewer;
790:   PetscBool         flg = PETSC_FALSE;
791:   static PetscBool  incall = PETSC_FALSE;
792:   PetscViewerFormat format;

795:   if (incall) return(0);
796:   incall = PETSC_TRUE;
797:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_view_vectors",&viewer,&format,&flg);
798:   if (flg) {
799:     PetscViewerPushFormat(viewer,format);
800:     EPSVectorsView(eps,viewer);
801:     PetscViewerPopFormat(viewer);
802:     PetscViewerDestroy(&viewer);
803:   }
804:   incall = PETSC_FALSE;
805:   return(0);
806: }

slepc-3.7.4/src/eps/interface/epssetup.c0000644000175000017500000004256513107004621017531 0ustar jromanjroman/* EPS routines related to problem setup. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #undef __FUNCT__ #define __FUNCT__ "EPSSetUp" /*@ EPSSetUp - Sets up all the internal data structures necessary for the execution of the eigensolver. Then calls STSetUp() for any set-up operations associated to the ST object. Collective on EPS Input Parameter: . eps - eigenproblem solver context Notes: This function need not be called explicitly in most cases, since EPSSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time. Level: developer .seealso: EPSCreate(), EPSSolve(), EPSDestroy(), STSetUp(), EPSSetInitialSpace() @*/ PetscErrorCode EPSSetUp(EPS eps) { PetscErrorCode ierr; Mat A,B; SlepcSC sc; PetscInt k,nmat; PetscBool flg,istrivial; #if defined(PETSC_USE_COMPLEX) PetscScalar sigma; #endif PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (eps->state) PetscFunctionReturn(0); ierr = PetscLogEventBegin(EPS_SetUp,eps,0,0,0);CHKERRQ(ierr); /* reset the convergence flag from the previous solves */ eps->reason = EPS_CONVERGED_ITERATING; /* Set default solver type (EPSSetFromOptions was not called) */ if (!((PetscObject)eps)->type_name) { ierr = EPSSetType(eps,EPSKRYLOVSCHUR);CHKERRQ(ierr); } if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } if (!((PetscObject)eps->st)->type_name) { ierr = PetscObjectTypeCompareAny((PetscObject)eps,&flg,EPSGD,EPSJD,EPSRQCG,EPSBLOPEX,EPSPRIMME,"");CHKERRQ(ierr); ierr = STSetType(eps->st,flg?STPRECOND:STSHIFT);CHKERRQ(ierr); } ierr = STSetTransform(eps->st,PETSC_TRUE);CHKERRQ(ierr); if (!eps->ds) { ierr = EPSGetDS(eps,&eps->ds);CHKERRQ(ierr); } ierr = DSReset(eps->ds);CHKERRQ(ierr); if (!eps->rg) { ierr = EPSGetRG(eps,&eps->rg);CHKERRQ(ierr); } if (!((PetscObject)eps->rg)->type_name) { ierr = RGSetType(eps->rg,RGINTERVAL);CHKERRQ(ierr); } /* Set problem dimensions */ ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); if (!nmat) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"EPSSetOperators must be called first"); ierr = STMatGetSize(eps->st,&eps->n,NULL);CHKERRQ(ierr); ierr = STMatGetLocalSize(eps->st,&eps->nloc,NULL);CHKERRQ(ierr); /* Set default problem type */ if (!eps->problem_type) { if (nmat==1) { ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); } else { ierr = EPSSetProblemType(eps,EPS_GNHEP);CHKERRQ(ierr); } } else if (nmat==1 && eps->isgeneralized) { ierr = PetscInfo(eps,"Eigenproblem set as generalized but no matrix B was provided; reverting to a standard eigenproblem\n");CHKERRQ(ierr); eps->isgeneralized = PETSC_FALSE; eps->problem_type = eps->ishermitian? EPS_HEP: EPS_NHEP; } else if (nmat>1 && !eps->isgeneralized) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_INCOMP,"Inconsistent EPS state"); if (eps->nev > eps->n) eps->nev = eps->n; if (eps->ncv > eps->n) eps->ncv = eps->n; /* initialization of matrix norms */ if (eps->conv==EPS_CONV_NORM) { if (!eps->nrma) { ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); ierr = MatNorm(A,NORM_INFINITY,&eps->nrma);CHKERRQ(ierr); } if (nmat>1 && !eps->nrmb) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); ierr = MatNorm(B,NORM_INFINITY,&eps->nrmb);CHKERRQ(ierr); } } /* call specific solver setup */ ierr = (*eps->ops->setup)(eps);CHKERRQ(ierr); /* check extraction */ ierr = PetscObjectTypeCompareAny((PetscObject)eps->st,&flg,STPRECOND,STSHIFT,"");CHKERRQ(ierr); if (!flg && eps->extraction && eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Cannot use a spectral transformation combined with harmonic extraction"); /* set tolerance if not yet set */ if (eps->tol==PETSC_DEFAULT) eps->tol = SLEPC_DEFAULT_TOL; /* fill sorting criterion context */ switch (eps->which) { case EPS_LARGEST_MAGNITUDE: eps->sc->comparison = SlepcCompareLargestMagnitude; eps->sc->comparisonctx = NULL; break; case EPS_SMALLEST_MAGNITUDE: eps->sc->comparison = SlepcCompareSmallestMagnitude; eps->sc->comparisonctx = NULL; break; case EPS_LARGEST_REAL: eps->sc->comparison = SlepcCompareLargestReal; eps->sc->comparisonctx = NULL; break; case EPS_SMALLEST_REAL: eps->sc->comparison = SlepcCompareSmallestReal; eps->sc->comparisonctx = NULL; break; case EPS_LARGEST_IMAGINARY: eps->sc->comparison = SlepcCompareLargestImaginary; eps->sc->comparisonctx = NULL; break; case EPS_SMALLEST_IMAGINARY: eps->sc->comparison = SlepcCompareSmallestImaginary; eps->sc->comparisonctx = NULL; break; case EPS_TARGET_MAGNITUDE: eps->sc->comparison = SlepcCompareTargetMagnitude; eps->sc->comparisonctx = &eps->target; break; case EPS_TARGET_REAL: eps->sc->comparison = SlepcCompareTargetReal; eps->sc->comparisonctx = &eps->target; break; case EPS_TARGET_IMAGINARY: eps->sc->comparison = SlepcCompareTargetImaginary; eps->sc->comparisonctx = &eps->target; break; case EPS_ALL: eps->sc->comparison = SlepcCompareSmallestReal; eps->sc->comparisonctx = NULL; break; case EPS_WHICH_USER: break; } eps->sc->map = NULL; eps->sc->mapobj = NULL; /* fill sorting criterion for DS */ ierr = DSGetSlepcSC(eps->ds,&sc);CHKERRQ(ierr); ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (eps->which==EPS_ALL) { sc->rg = NULL; sc->comparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; } else { sc->rg = istrivial? NULL: eps->rg; sc->comparison = eps->sc->comparison; sc->comparisonctx = eps->sc->comparisonctx; sc->map = SlepcMap_ST; sc->mapobj = (PetscObject)eps->st; } /* Build balancing matrix if required */ if (!eps->ishermitian && (eps->balance==EPS_BALANCE_ONESIDE || eps->balance==EPS_BALANCE_TWOSIDE)) { if (!eps->D) { ierr = BVCreateVec(eps->V,&eps->D);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->D);CHKERRQ(ierr); } else { ierr = VecSet(eps->D,1.0);CHKERRQ(ierr); } ierr = EPSBuildBalance_Krylov(eps);CHKERRQ(ierr); ierr = STSetBalanceMatrix(eps->st,eps->D);CHKERRQ(ierr); } /* Setup ST */ ierr = STSetUp(eps->st);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = STGetShift(eps->st,&sigma);CHKERRQ(ierr); if (eps->ishermitian && PetscImaginaryPart(sigma) != 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Hermitian problems are not compatible with complex shifts"); #endif ierr = PetscObjectTypeCompare((PetscObject)eps->st,STCAYLEY,&flg);CHKERRQ(ierr); if (flg && eps->problem_type == EPS_PGNHEP) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Cayley spectral transformation is not compatible with PGNHEP"); /* process deflation and initial vectors */ if (eps->nds<0) { k = -eps->nds; ierr = BVInsertConstraints(eps->V,&k,eps->defl);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&eps->nds,&eps->defl);CHKERRQ(ierr); eps->nds = k; ierr = STCheckNullSpace(eps->st,eps->V);CHKERRQ(ierr); } if (eps->nini<0) { k = -eps->nini; if (k>eps->ncv) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The number of initial vectors is larger than ncv"); ierr = BVInsertVecs(eps->V,0,&k,eps->IS,PETSC_TRUE);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&eps->nini,&eps->IS);CHKERRQ(ierr); eps->nini = k; } ierr = PetscLogEventEnd(EPS_SetUp,eps,0,0,0);CHKERRQ(ierr); eps->state = EPS_STATE_SETUP; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetOperators" /*@ EPSSetOperators - Sets the matrices associated with the eigenvalue problem. Collective on EPS and Mat Input Parameters: + eps - the eigenproblem solver context . A - the matrix associated with the eigensystem - B - the second matrix in the case of generalized eigenproblems Notes: To specify a standard eigenproblem, use NULL for parameter B. It must be called before EPSSetUp(). If it is called again after EPSSetUp() then the EPS object is reset. Level: beginner .seealso: EPSSolve(), EPSSetUp(), EPSReset(), EPSGetST(), STGetOperators() @*/ PetscErrorCode EPSSetOperators(EPS eps,Mat A,Mat B) { PetscErrorCode ierr; PetscInt m,n,m0,nmat; Mat mat[2]; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidHeaderSpecific(A,MAT_CLASSID,2); if (B) PetscValidHeaderSpecific(B,MAT_CLASSID,3); PetscCheckSameComm(eps,1,A,2); if (B) PetscCheckSameComm(eps,1,B,3); /* Check for square matrices */ ierr = MatGetSize(A,&m,&n);CHKERRQ(ierr); if (m!=n) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"A is a non-square matrix"); if (B) { ierr = MatGetSize(B,&m0,&n);CHKERRQ(ierr); if (m0!=n) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"B is a non-square matrix"); if (m!=m0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_INCOMP,"Dimensions of A and B do not match"); } if (eps->state && n!=eps->n) { ierr = EPSReset(eps);CHKERRQ(ierr); } eps->nrma = 0.0; eps->nrmb = 0.0; if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } mat[0] = A; if (B) { mat[1] = B; nmat = 2; } else nmat = 1; ierr = STSetOperators(eps->st,nmat,mat);CHKERRQ(ierr); eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetOperators" /*@ EPSGetOperators - Gets the matrices associated with the eigensystem. Collective on EPS and Mat Input Parameter: . eps - the EPS context Output Parameters: + A - the matrix associated with the eigensystem - B - the second matrix in the case of generalized eigenproblems Level: intermediate .seealso: EPSSolve(), EPSGetST(), STGetOperators(), STSetOperators() @*/ PetscErrorCode EPSGetOperators(EPS eps,Mat *A,Mat *B) { PetscErrorCode ierr; ST st; PetscInt k; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = EPSGetST(eps,&st);CHKERRQ(ierr); if (A) { ierr = STGetOperators(st,0,A);CHKERRQ(ierr); } if (B) { ierr = STGetNumMatrices(st,&k);CHKERRQ(ierr); if (k==1) B = NULL; else { ierr = STGetOperators(st,1,B);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetDeflationSpace" /*@ EPSSetDeflationSpace - Specify a basis of vectors that constitute the deflation space. Collective on EPS and Vec Input Parameter: + eps - the eigenproblem solver context . n - number of vectors - v - set of basis vectors of the deflation space Notes: When a deflation space is given, the eigensolver seeks the eigensolution in the restriction of the problem to the orthogonal complement of this space. This can be used for instance in the case that an invariant subspace is known beforehand (such as the nullspace of the matrix). These vectors do not persist from one EPSSolve() call to the other, so the deflation space should be set every time. The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally. Level: intermediate .seealso: EPSSetInitialSpace() @*/ PetscErrorCode EPSSetDeflationSpace(EPS eps,PetscInt n,Vec *v) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,n,2); if (n<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument n out of range"); ierr = SlepcBasisReference_Private(n,v,&eps->nds,&eps->defl);CHKERRQ(ierr); if (n>0) eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetInitialSpace" /*@ EPSSetInitialSpace - Specify a basis of vectors that constitute the initial space, that is, the subspace from which the solver starts to iterate. Collective on EPS and Vec Input Parameter: + eps - the eigenproblem solver context . n - number of vectors - is - set of basis vectors of the initial space Notes: Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored. These vectors do not persist from one EPSSolve() call to the other, so the initial space should be set every time. The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally. Common usage of this function is when the user can provide a rough approximation of the wanted eigenspace. Then, convergence may be faster. Level: intermediate .seealso: EPSSetDeflationSpace() @*/ PetscErrorCode EPSSetInitialSpace(EPS eps,PetscInt n,Vec *is) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,n,2); if (n<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative"); ierr = SlepcBasisReference_Private(n,is,&eps->nini,&eps->IS);CHKERRQ(ierr); if (n>0) eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetDimensions_Default" /* EPSSetDimensions_Default - Set reasonable values for ncv, mpd if not set by the user. This is called at setup. */ PetscErrorCode EPSSetDimensions_Default(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd) { PetscErrorCode ierr; PetscBool krylov; PetscFunctionBegin; if (*ncv) { /* ncv set */ ierr = PetscObjectTypeCompareAny((PetscObject)eps,&krylov,EPSKRYLOVSCHUR,EPSARNOLDI,EPSLANCZOS,"");CHKERRQ(ierr); if (krylov) { if (*ncvn)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must be at least nev+1"); } else { if (*ncvn,nev+(*mpd)); } else { /* neither set: defaults depend on nev being small or large */ if (nev<500) *ncv = PetscMin(eps->n,PetscMax(2*nev,nev+15)); else { *mpd = 500; *ncv = PetscMin(eps->n,nev+(*mpd)); } } if (!*mpd) *mpd = *ncv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSAllocateSolution" /*@ EPSAllocateSolution - Allocate memory storage for common variables such as eigenvalues and eigenvectors. Collective on EPS Input Parameters: + eps - eigensolver context - extra - number of additional positions, used for methods that require a working basis slightly larger than ncv Developers Note: This is PETSC_EXTERN because it may be required by user plugin EPS implementations. Level: developer @*/ PetscErrorCode EPSAllocateSolution(EPS eps,PetscInt extra) { PetscErrorCode ierr; PetscInt oldsize,newc,requested; PetscLogDouble cnt; Vec t; PetscFunctionBegin; requested = eps->ncv + extra; /* oldsize is zero if this is the first time setup is called */ ierr = BVGetSizes(eps->V,NULL,NULL,&oldsize);CHKERRQ(ierr); newc = PetscMax(0,requested-oldsize); /* allocate space for eigenvalues and friends */ if (requested != oldsize || !eps->eigr) { if (oldsize) { ierr = PetscFree4(eps->eigr,eps->eigi,eps->errest,eps->perm);CHKERRQ(ierr); } ierr = PetscMalloc4(requested,&eps->eigr,requested,&eps->eigi,requested,&eps->errest,requested,&eps->perm);CHKERRQ(ierr); cnt = 2*newc*sizeof(PetscScalar) + 2*newc*sizeof(PetscReal) + newc*sizeof(PetscInt); ierr = PetscLogObjectMemory((PetscObject)eps,cnt);CHKERRQ(ierr); } /* workspace for the case of arbitrary selection */ if (eps->arbitrary) { if (eps->rr) { ierr = PetscFree2(eps->rr,eps->ri);CHKERRQ(ierr); } ierr = PetscMalloc2(requested,&eps->rr,requested,&eps->ri);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,2*newc*sizeof(PetscScalar));CHKERRQ(ierr); } /* allocate V */ if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } if (!oldsize) { if (!((PetscObject)(eps->V))->type_name) { ierr = BVSetType(eps->V,BVSVEC);CHKERRQ(ierr); } ierr = STMatCreateVecs(eps->st,&t,NULL);CHKERRQ(ierr); ierr = BVSetSizesFromVec(eps->V,t,requested);CHKERRQ(ierr); ierr = VecDestroy(&t);CHKERRQ(ierr); } else { ierr = BVResize(eps->V,requested,PETSC_FALSE);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/interface/epssetup.c.html0000644000175000017500000012241713107004621020467 0ustar jromanjroman
Actual source code: epssetup.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       EPS routines related to problem setup.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>       /*I "slepceps.h" I*/

 28: /*@
 29:    EPSSetUp - Sets up all the internal data structures necessary for the
 30:    execution of the eigensolver. Then calls STSetUp() for any set-up
 31:    operations associated to the ST object.

 33:    Collective on EPS

 35:    Input Parameter:
 36: .  eps   - eigenproblem solver context

 38:    Notes:
 39:    This function need not be called explicitly in most cases, since EPSSolve()
 40:    calls it. It can be useful when one wants to measure the set-up time
 41:    separately from the solve time.

 43:    Level: developer

 45: .seealso: EPSCreate(), EPSSolve(), EPSDestroy(), STSetUp(), EPSSetInitialSpace()
 46: @*/
 47: PetscErrorCode EPSSetUp(EPS eps)
 48: {
 50:   Mat            A,B;
 51:   SlepcSC        sc;
 52:   PetscInt       k,nmat;
 53:   PetscBool      flg,istrivial;
 54: #if defined(PETSC_USE_COMPLEX)
 55:   PetscScalar    sigma;
 56: #endif

 60:   if (eps->state) return(0);
 61:   PetscLogEventBegin(EPS_SetUp,eps,0,0,0);

 63:   /* reset the convergence flag from the previous solves */
 64:   eps->reason = EPS_CONVERGED_ITERATING;

 66:   /* Set default solver type (EPSSetFromOptions was not called) */
 67:   if (!((PetscObject)eps)->type_name) {
 68:     EPSSetType(eps,EPSKRYLOVSCHUR);
 69:   }
 70:   if (!eps->st) { EPSGetST(eps,&eps->st); }
 71:   if (!((PetscObject)eps->st)->type_name) {
 72:     PetscObjectTypeCompareAny((PetscObject)eps,&flg,EPSGD,EPSJD,EPSRQCG,EPSBLOPEX,EPSPRIMME,"");
 73:     STSetType(eps->st,flg?STPRECOND:STSHIFT);
 74:   }
 75:   STSetTransform(eps->st,PETSC_TRUE);
 76:   if (!eps->ds) { EPSGetDS(eps,&eps->ds); }
 77:   DSReset(eps->ds);
 78:   if (!eps->rg) { EPSGetRG(eps,&eps->rg); }
 79:   if (!((PetscObject)eps->rg)->type_name) {
 80:     RGSetType(eps->rg,RGINTERVAL);
 81:   }

 83:   /* Set problem dimensions */
 84:   STGetNumMatrices(eps->st,&nmat);
 85:   if (!nmat) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"EPSSetOperators must be called first");
 86:   STMatGetSize(eps->st,&eps->n,NULL);
 87:   STMatGetLocalSize(eps->st,&eps->nloc,NULL);

 89:   /* Set default problem type */
 90:   if (!eps->problem_type) {
 91:     if (nmat==1) {
 92:       EPSSetProblemType(eps,EPS_NHEP);
 93:     } else {
 94:       EPSSetProblemType(eps,EPS_GNHEP);
 95:     }
 96:   } else if (nmat==1 && eps->isgeneralized) {
 97:     PetscInfo(eps,"Eigenproblem set as generalized but no matrix B was provided; reverting to a standard eigenproblem\n");
 98:     eps->isgeneralized = PETSC_FALSE;
 99:     eps->problem_type = eps->ishermitian? EPS_HEP: EPS_NHEP;
100:   } else if (nmat>1 && !eps->isgeneralized) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_INCOMP,"Inconsistent EPS state");

102:   if (eps->nev > eps->n) eps->nev = eps->n;
103:   if (eps->ncv > eps->n) eps->ncv = eps->n;

105:   /* initialization of matrix norms */
106:   if (eps->conv==EPS_CONV_NORM) {
107:     if (!eps->nrma) {
108:       STGetOperators(eps->st,0,&A);
109:       MatNorm(A,NORM_INFINITY,&eps->nrma);
110:     }
111:     if (nmat>1 && !eps->nrmb) {
112:       STGetOperators(eps->st,1,&B);
113:       MatNorm(B,NORM_INFINITY,&eps->nrmb);
114:     }
115:   }

117:   /* call specific solver setup */
118:   (*eps->ops->setup)(eps);

120:   /* check extraction */
121:   PetscObjectTypeCompareAny((PetscObject)eps->st,&flg,STPRECOND,STSHIFT,"");
122:   if (!flg && eps->extraction && eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Cannot use a spectral transformation combined with harmonic extraction");

124:   /* set tolerance if not yet set */
125:   if (eps->tol==PETSC_DEFAULT) eps->tol = SLEPC_DEFAULT_TOL;

127:   /* fill sorting criterion context */
128:   switch (eps->which) {
129:     case EPS_LARGEST_MAGNITUDE:
130:       eps->sc->comparison    = SlepcCompareLargestMagnitude;
131:       eps->sc->comparisonctx = NULL;
132:       break;
133:     case EPS_SMALLEST_MAGNITUDE:
134:       eps->sc->comparison    = SlepcCompareSmallestMagnitude;
135:       eps->sc->comparisonctx = NULL;
136:       break;
137:     case EPS_LARGEST_REAL:
138:       eps->sc->comparison    = SlepcCompareLargestReal;
139:       eps->sc->comparisonctx = NULL;
140:       break;
141:     case EPS_SMALLEST_REAL:
142:       eps->sc->comparison    = SlepcCompareSmallestReal;
143:       eps->sc->comparisonctx = NULL;
144:       break;
145:     case EPS_LARGEST_IMAGINARY:
146:       eps->sc->comparison    = SlepcCompareLargestImaginary;
147:       eps->sc->comparisonctx = NULL;
148:       break;
149:     case EPS_SMALLEST_IMAGINARY:
150:       eps->sc->comparison    = SlepcCompareSmallestImaginary;
151:       eps->sc->comparisonctx = NULL;
152:       break;
153:     case EPS_TARGET_MAGNITUDE:
154:       eps->sc->comparison    = SlepcCompareTargetMagnitude;
155:       eps->sc->comparisonctx = &eps->target;
156:       break;
157:     case EPS_TARGET_REAL:
158:       eps->sc->comparison    = SlepcCompareTargetReal;
159:       eps->sc->comparisonctx = &eps->target;
160:       break;
161:     case EPS_TARGET_IMAGINARY:
162:       eps->sc->comparison    = SlepcCompareTargetImaginary;
163:       eps->sc->comparisonctx = &eps->target;
164:       break;
165:     case EPS_ALL:
166:       eps->sc->comparison    = SlepcCompareSmallestReal;
167:       eps->sc->comparisonctx = NULL;
168:       break;
169:     case EPS_WHICH_USER:
170:       break;
171:   }
172:   eps->sc->map    = NULL;
173:   eps->sc->mapobj = NULL;

175:   /* fill sorting criterion for DS */
176:   DSGetSlepcSC(eps->ds,&sc);
177:   RGIsTrivial(eps->rg,&istrivial);
178:   if (eps->which==EPS_ALL) {
179:     sc->rg            = NULL;
180:     sc->comparison    = SlepcCompareLargestMagnitude;
181:     sc->comparisonctx = NULL;
182:     sc->map           = NULL;
183:     sc->mapobj        = NULL;
184:   } else {
185:     sc->rg            = istrivial? NULL: eps->rg;
186:     sc->comparison    = eps->sc->comparison;
187:     sc->comparisonctx = eps->sc->comparisonctx;
188:     sc->map           = SlepcMap_ST;
189:     sc->mapobj        = (PetscObject)eps->st;
190:   }

192:   /* Build balancing matrix if required */
193:   if (!eps->ishermitian && (eps->balance==EPS_BALANCE_ONESIDE || eps->balance==EPS_BALANCE_TWOSIDE)) {
194:     if (!eps->D) {
195:       BVCreateVec(eps->V,&eps->D);
196:       PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->D);
197:     } else {
198:       VecSet(eps->D,1.0);
199:     }
200:     EPSBuildBalance_Krylov(eps);
201:     STSetBalanceMatrix(eps->st,eps->D);
202:   }

204:   /* Setup ST */
205:   STSetUp(eps->st);

207: #if defined(PETSC_USE_COMPLEX)
208:   STGetShift(eps->st,&sigma);
209:   if (eps->ishermitian && PetscImaginaryPart(sigma) != 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Hermitian problems are not compatible with complex shifts");
210: #endif
211:   PetscObjectTypeCompare((PetscObject)eps->st,STCAYLEY,&flg);
212:   if (flg && eps->problem_type == EPS_PGNHEP) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Cayley spectral transformation is not compatible with PGNHEP");

214:   /* process deflation and initial vectors */
215:   if (eps->nds<0) {
216:     k = -eps->nds;
217:     BVInsertConstraints(eps->V,&k,eps->defl);
218:     SlepcBasisDestroy_Private(&eps->nds,&eps->defl);
219:     eps->nds = k;
220:     STCheckNullSpace(eps->st,eps->V);
221:   }
222:   if (eps->nini<0) {
223:     k = -eps->nini;
224:     if (k>eps->ncv) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The number of initial vectors is larger than ncv");
225:     BVInsertVecs(eps->V,0,&k,eps->IS,PETSC_TRUE);
226:     SlepcBasisDestroy_Private(&eps->nini,&eps->IS);
227:     eps->nini = k;
228:   }

230:   PetscLogEventEnd(EPS_SetUp,eps,0,0,0);
231:   eps->state = EPS_STATE_SETUP;
232:   return(0);
233: }

237: /*@
238:    EPSSetOperators - Sets the matrices associated with the eigenvalue problem.

240:    Collective on EPS and Mat

242:    Input Parameters:
243: +  eps - the eigenproblem solver context
244: .  A  - the matrix associated with the eigensystem
245: -  B  - the second matrix in the case of generalized eigenproblems

247:    Notes:
248:    To specify a standard eigenproblem, use NULL for parameter B.

250:    It must be called before EPSSetUp(). If it is called again after EPSSetUp() then
251:    the EPS object is reset.

253:    Level: beginner

255: .seealso: EPSSolve(), EPSSetUp(), EPSReset(), EPSGetST(), STGetOperators()
256: @*/
257: PetscErrorCode EPSSetOperators(EPS eps,Mat A,Mat B)
258: {
260:   PetscInt       m,n,m0,nmat;
261:   Mat            mat[2];


270:   /* Check for square matrices */
271:   MatGetSize(A,&m,&n);
272:   if (m!=n) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"A is a non-square matrix");
273:   if (B) {
274:     MatGetSize(B,&m0,&n);
275:     if (m0!=n) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"B is a non-square matrix");
276:     if (m!=m0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_INCOMP,"Dimensions of A and B do not match");
277:   }
278:   if (eps->state && n!=eps->n) { EPSReset(eps); }
279:   eps->nrma = 0.0;
280:   eps->nrmb = 0.0;
281:   if (!eps->st) { EPSGetST(eps,&eps->st); }
282:   mat[0] = A;
283:   if (B) {
284:     mat[1] = B;
285:     nmat = 2;
286:   } else nmat = 1;
287:   STSetOperators(eps->st,nmat,mat);
288:   eps->state = EPS_STATE_INITIAL;
289:   return(0);
290: }

294: /*@
295:    EPSGetOperators - Gets the matrices associated with the eigensystem.

297:    Collective on EPS and Mat

299:    Input Parameter:
300: .  eps - the EPS context

302:    Output Parameters:
303: +  A  - the matrix associated with the eigensystem
304: -  B  - the second matrix in the case of generalized eigenproblems

306:    Level: intermediate

308: .seealso: EPSSolve(), EPSGetST(), STGetOperators(), STSetOperators()
309: @*/
310: PetscErrorCode EPSGetOperators(EPS eps,Mat *A,Mat *B)
311: {
313:   ST             st;
314:   PetscInt       k;

318:   EPSGetST(eps,&st);
319:   if (A) { STGetOperators(st,0,A); }
320:   if (B) {
321:     STGetNumMatrices(st,&k);
322:     if (k==1) B = NULL;
323:     else {
324:       STGetOperators(st,1,B);
325:     }
326:   }
327:   return(0);
328: }

332: /*@
333:    EPSSetDeflationSpace - Specify a basis of vectors that constitute the deflation
334:    space.

336:    Collective on EPS and Vec

338:    Input Parameter:
339: +  eps - the eigenproblem solver context
340: .  n   - number of vectors
341: -  v   - set of basis vectors of the deflation space

343:    Notes:
344:    When a deflation space is given, the eigensolver seeks the eigensolution
345:    in the restriction of the problem to the orthogonal complement of this
346:    space. This can be used for instance in the case that an invariant
347:    subspace is known beforehand (such as the nullspace of the matrix).

349:    These vectors do not persist from one EPSSolve() call to the other, so the
350:    deflation space should be set every time.

352:    The vectors do not need to be mutually orthonormal, since they are explicitly
353:    orthonormalized internally.

355:    Level: intermediate

357: .seealso: EPSSetInitialSpace()
358: @*/
359: PetscErrorCode EPSSetDeflationSpace(EPS eps,PetscInt n,Vec *v)
360: {

366:   if (n<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument n out of range");
367:   SlepcBasisReference_Private(n,v,&eps->nds,&eps->defl);
368:   if (n>0) eps->state = EPS_STATE_INITIAL;
369:   return(0);
370: }

374: /*@
375:    EPSSetInitialSpace - Specify a basis of vectors that constitute the initial
376:    space, that is, the subspace from which the solver starts to iterate.

378:    Collective on EPS and Vec

380:    Input Parameter:
381: +  eps - the eigenproblem solver context
382: .  n   - number of vectors
383: -  is  - set of basis vectors of the initial space

385:    Notes:
386:    Some solvers start to iterate on a single vector (initial vector). In that case,
387:    the other vectors are ignored.

389:    These vectors do not persist from one EPSSolve() call to the other, so the
390:    initial space should be set every time.

392:    The vectors do not need to be mutually orthonormal, since they are explicitly
393:    orthonormalized internally.

395:    Common usage of this function is when the user can provide a rough approximation
396:    of the wanted eigenspace. Then, convergence may be faster.

398:    Level: intermediate

400: .seealso: EPSSetDeflationSpace()
401: @*/
402: PetscErrorCode EPSSetInitialSpace(EPS eps,PetscInt n,Vec *is)
403: {

409:   if (n<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative");
410:   SlepcBasisReference_Private(n,is,&eps->nini,&eps->IS);
411:   if (n>0) eps->state = EPS_STATE_INITIAL;
412:   return(0);
413: }

417: /*
418:   EPSSetDimensions_Default - Set reasonable values for ncv, mpd if not set
419:   by the user. This is called at setup.
420:  */
421: PetscErrorCode EPSSetDimensions_Default(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)
422: {
424:   PetscBool      krylov;

427:   if (*ncv) { /* ncv set */
428:     PetscObjectTypeCompareAny((PetscObject)eps,&krylov,EPSKRYLOVSCHUR,EPSARNOLDI,EPSLANCZOS,"");
429:     if (krylov) {
430:       if (*ncv<nev+1 && !(*ncv==nev && *ncv==eps->n)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must be at least nev+1");
431:     } else {
432:       if (*ncv<nev) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must be at least nev");
433:     }
434:   } else if (*mpd) { /* mpd set */
435:     *ncv = PetscMin(eps->n,nev+(*mpd));
436:   } else { /* neither set: defaults depend on nev being small or large */
437:     if (nev<500) *ncv = PetscMin(eps->n,PetscMax(2*nev,nev+15));
438:     else {
439:       *mpd = 500;
440:       *ncv = PetscMin(eps->n,nev+(*mpd));
441:     }
442:   }
443:   if (!*mpd) *mpd = *ncv;
444:   return(0);
445: }

449: /*@
450:    EPSAllocateSolution - Allocate memory storage for common variables such
451:    as eigenvalues and eigenvectors.

453:    Collective on EPS

455:    Input Parameters:
456: +  eps   - eigensolver context
457: -  extra - number of additional positions, used for methods that require a
458:            working basis slightly larger than ncv

460:    Developers Note:
461:    This is PETSC_EXTERN because it may be required by user plugin EPS
462:    implementations.

464:    Level: developer
465: @*/
466: PetscErrorCode EPSAllocateSolution(EPS eps,PetscInt extra)
467: {
469:   PetscInt       oldsize,newc,requested;
470:   PetscLogDouble cnt;
471:   Vec            t;

474:   requested = eps->ncv + extra;

476:   /* oldsize is zero if this is the first time setup is called */
477:   BVGetSizes(eps->V,NULL,NULL,&oldsize);
478:   newc = PetscMax(0,requested-oldsize);

480:   /* allocate space for eigenvalues and friends */
481:   if (requested != oldsize || !eps->eigr) {
482:     if (oldsize) {
483:       PetscFree4(eps->eigr,eps->eigi,eps->errest,eps->perm);
484:     }
485:     PetscMalloc4(requested,&eps->eigr,requested,&eps->eigi,requested,&eps->errest,requested,&eps->perm);
486:     cnt = 2*newc*sizeof(PetscScalar) + 2*newc*sizeof(PetscReal) + newc*sizeof(PetscInt);
487:     PetscLogObjectMemory((PetscObject)eps,cnt);
488:   }

490:   /* workspace for the case of arbitrary selection */
491:   if (eps->arbitrary) {
492:     if (eps->rr) {
493:       PetscFree2(eps->rr,eps->ri);
494:     }
495:     PetscMalloc2(requested,&eps->rr,requested,&eps->ri);
496:     PetscLogObjectMemory((PetscObject)eps,2*newc*sizeof(PetscScalar));
497:   }

499:   /* allocate V */
500:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
501:   if (!oldsize) {
502:     if (!((PetscObject)(eps->V))->type_name) {
503:       BVSetType(eps->V,BVSVEC);
504:     }
505:     STMatCreateVecs(eps->st,&t,NULL);
506:     BVSetSizesFromVec(eps->V,t,requested);
507:     VecDestroy(&t);
508:   } else {
509:     BVResize(eps->V,requested,PETSC_FALSE);
510:   }
511:   return(0);
512: }

slepc-3.7.4/src/eps/interface/epsview.c0000644000175000017500000007276013107004621017343 0ustar jromanjroman/* The EPS routines related to various viewers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "EPSView" /*@C EPSView - Prints the EPS data structure. Collective on EPS Input Parameters: + eps - the eigenproblem solver context - viewer - optional visualization context Options Database Key: . -eps_view - Calls EPSView() at end of EPSSolve() Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner .seealso: STView(), PetscViewerASCIIOpen() @*/ PetscErrorCode EPSView(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; const char *type,*extr,*bal; char str[50]; PetscBool isascii,ispower,isexternal,istrivial; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(eps,1,viewer,2); #if defined(PETSC_USE_COMPLEX) #define HERM "hermitian" #else #define HERM "symmetric" #endif ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)eps,viewer);CHKERRQ(ierr); if (eps->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*eps->ops->view)(eps,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } if (eps->problem_type) { switch (eps->problem_type) { case EPS_HEP: type = HERM " eigenvalue problem"; break; case EPS_GHEP: type = "generalized " HERM " eigenvalue problem"; break; case EPS_NHEP: type = "non-" HERM " eigenvalue problem"; break; case EPS_GNHEP: type = "generalized non-" HERM " eigenvalue problem"; break; case EPS_PGNHEP: type = "generalized non-" HERM " eigenvalue problem with " HERM " positive definite B"; break; case EPS_GHIEP: type = "generalized " HERM "-indefinite eigenvalue problem"; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->problem_type"); } } else type = "not yet set"; ierr = PetscViewerASCIIPrintf(viewer," problem type: %s\n",type);CHKERRQ(ierr); if (eps->extraction) { switch (eps->extraction) { case EPS_RITZ: extr = "Rayleigh-Ritz"; break; case EPS_HARMONIC: extr = "harmonic Ritz"; break; case EPS_HARMONIC_RELATIVE:extr = "relative harmonic Ritz"; break; case EPS_HARMONIC_RIGHT: extr = "right harmonic Ritz"; break; case EPS_HARMONIC_LARGEST: extr = "largest harmonic Ritz"; break; case EPS_REFINED: extr = "refined Ritz"; break; case EPS_REFINED_HARMONIC: extr = "refined harmonic Ritz"; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->extraction"); } ierr = PetscViewerASCIIPrintf(viewer," extraction type: %s\n",extr);CHKERRQ(ierr); } if (!eps->ishermitian && eps->balance!=EPS_BALANCE_NONE) { switch (eps->balance) { case EPS_BALANCE_ONESIDE: bal = "one-sided Krylov"; break; case EPS_BALANCE_TWOSIDE: bal = "two-sided Krylov"; break; case EPS_BALANCE_USER: bal = "user-defined matrix"; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->balance"); } ierr = PetscViewerASCIIPrintf(viewer," balancing enabled: %s",bal);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); if (eps->balance==EPS_BALANCE_ONESIDE || eps->balance==EPS_BALANCE_TWOSIDE) { ierr = PetscViewerASCIIPrintf(viewer,", with its=%D",eps->balance_its);CHKERRQ(ierr); } if (eps->balance==EPS_BALANCE_TWOSIDE && eps->balance_cutoff!=0.0) { ierr = PetscViewerASCIIPrintf(viewer," and cutoff=%g",(double)eps->balance_cutoff);CHKERRQ(ierr); } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," selected portion of the spectrum: ");CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,eps->target,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); if (!eps->which) { ierr = PetscViewerASCIIPrintf(viewer,"not yet set\n");CHKERRQ(ierr); } else switch (eps->which) { case EPS_WHICH_USER: ierr = PetscViewerASCIIPrintf(viewer,"user defined\n");CHKERRQ(ierr); break; case EPS_TARGET_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (in magnitude)\n",str);CHKERRQ(ierr); break; case EPS_TARGET_REAL: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the real axis)\n",str);CHKERRQ(ierr); break; case EPS_TARGET_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the imaginary axis)\n",str);CHKERRQ(ierr); break; case EPS_LARGEST_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");CHKERRQ(ierr); break; case EPS_SMALLEST_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");CHKERRQ(ierr); break; case EPS_LARGEST_REAL: ierr = PetscViewerASCIIPrintf(viewer,"largest real parts\n");CHKERRQ(ierr); break; case EPS_SMALLEST_REAL: ierr = PetscViewerASCIIPrintf(viewer,"smallest real parts\n");CHKERRQ(ierr); break; case EPS_LARGEST_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");CHKERRQ(ierr); break; case EPS_SMALLEST_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");CHKERRQ(ierr); break; case EPS_ALL: if (eps->inta || eps->intb) { ierr = PetscViewerASCIIPrintf(viewer,"all eigenvalues in interval [%g,%g]\n",(double)eps->inta,(double)eps->intb);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"all eigenvalues in the region\n");CHKERRQ(ierr); } break; default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); if (eps->isgeneralized && eps->ishermitian && eps->purify) { ierr = PetscViewerASCIIPrintf(viewer," postprocessing eigenvectors with purification\n");CHKERRQ(ierr); } if (eps->trueres) { ierr = PetscViewerASCIIPrintf(viewer," computing true residuals explicitly\n");CHKERRQ(ierr); } if (eps->trackall) { ierr = PetscViewerASCIIPrintf(viewer," computing all residuals (for tracking convergence)\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," number of eigenvalues (nev): %D\n",eps->nev);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of column vectors (ncv): %D\n",eps->ncv);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum dimension of projected problem (mpd): %D\n",eps->mpd);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum number of iterations: %D\n",eps->max_it);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," tolerance: %g\n",(double)eps->tol);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," convergence test: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); switch (eps->conv) { case EPS_CONV_ABS: ierr = PetscViewerASCIIPrintf(viewer,"absolute\n");CHKERRQ(ierr);break; case EPS_CONV_REL: ierr = PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue\n");CHKERRQ(ierr);break; case EPS_CONV_NORM: ierr = PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue and matrix norms\n");CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," computed matrix norms: norm(A)=%g",(double)eps->nrma);CHKERRQ(ierr); if (eps->isgeneralized) { ierr = PetscViewerASCIIPrintf(viewer,", norm(B)=%g",(double)eps->nrmb);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); break; case EPS_CONV_USER: ierr = PetscViewerASCIIPrintf(viewer,"user-defined\n");CHKERRQ(ierr);break; } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); if (eps->nini) { ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided initial space: %D\n",PetscAbs(eps->nini));CHKERRQ(ierr); } if (eps->nds) { ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided deflation space: %D\n",PetscAbs(eps->nds));CHKERRQ(ierr); } } else { if (eps->ops->view) { ierr = (*eps->ops->view)(eps,viewer);CHKERRQ(ierr); } } ierr = PetscObjectTypeCompareAny((PetscObject)eps,&isexternal,EPSARPACK,EPSBLZPACK,EPSTRLAN,EPSBLOPEX,EPSPRIMME,"");CHKERRQ(ierr); if (!isexternal) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);CHKERRQ(ierr); if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } ierr = BVView(eps->V,viewer);CHKERRQ(ierr); if (eps->rg) { ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) { ierr = RGView(eps->rg,viewer);CHKERRQ(ierr); } } ierr = PetscObjectTypeCompare((PetscObject)eps,EPSPOWER,&ispower);CHKERRQ(ierr); if (!ispower) { if (!eps->ds) { ierr = EPSGetDS(eps,&eps->ds);CHKERRQ(ierr); } ierr = DSView(eps->ds,viewer);CHKERRQ(ierr); } ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } ierr = STView(eps->st,viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReasonView" /*@C EPSReasonView - Displays the reason an EPS solve converged or diverged. Collective on EPS Parameter: + eps - the eigensolver context - viewer - the viewer to display the reason Options Database Keys: . -eps_converged_reason - print reason for convergence, and number of iterations Level: intermediate .seealso: EPSSetConvergenceTest(), EPSSetTolerances(), EPSGetIterationNumber() @*/ PetscErrorCode EPSReasonView(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isAscii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);CHKERRQ(ierr); if (isAscii) { ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); if (eps->reason > 0) { ierr = PetscViewerASCIIPrintf(viewer,"%s Linear eigensolve converged (%D eigenpair%s) due to %s; iterations %D\n",((PetscObject)eps)->prefix?((PetscObject)eps)->prefix:"",eps->nconv,(eps->nconv>1)?"s":"",EPSConvergedReasons[eps->reason],eps->its);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%s Linear eigensolve did not converge due to %s; iterations %D\n",((PetscObject)eps)->prefix?((PetscObject)eps)->prefix:"",EPSConvergedReasons[eps->reason],eps->its);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReasonViewFromOptions" /*@ EPSReasonViewFromOptions - Processes command line options to determine if/how the EPS converged reason is to be viewed. Collective on EPS Input Parameters: . eps - the eigensolver context Level: developer @*/ PetscErrorCode EPSReasonViewFromOptions(EPS eps) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_converged_reason",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = EPSReasonView(eps,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSErrorView_ASCII" static PetscErrorCode EPSErrorView_ASCII(EPS eps,EPSErrorType etype,PetscViewer viewer) { PetscBool errok; PetscReal error,re,im; PetscScalar kr,ki; PetscInt i,j,nvals; PetscErrorCode ierr; PetscFunctionBegin; if (eps->which!=EPS_ALL && eps->nconvnev) { ierr = PetscViewerASCIIPrintf(viewer," Problem: less than %D eigenvalues converged\n\n",eps->nev);CHKERRQ(ierr); PetscFunctionReturn(0); } errok = PETSC_TRUE; nvals = (eps->which==EPS_ALL)? eps->nconv: eps->nev; for (i=0;itol)? PETSC_TRUE: PETSC_FALSE; } if (!errok) { ierr = PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",nvals);CHKERRQ(ierr); PetscFunctionReturn(0); } if (eps->which==EPS_ALL) { ierr = PetscViewerASCIIPrintf(viewer," Found %D eigenvalues, all of them computed up to the required tolerance:",nvals);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," All requested eigenvalues computed up to the required tolerance:");CHKERRQ(ierr); } for (i=0;i<=(nvals-1)/8;i++) { ierr = PetscViewerASCIIPrintf(viewer,"\n ");CHKERRQ(ierr); for (j=0;jnconv) PetscFunctionReturn(0); switch (etype) { case EPS_ERROR_ABSOLUTE: ierr = PetscSNPrintf(ex,EXLEN," ||Ax-k%sx||",eps->isgeneralized?"B":"");CHKERRQ(ierr); break; case EPS_ERROR_RELATIVE: ierr = PetscSNPrintf(ex,EXLEN,"||Ax-k%sx||/||kx||",eps->isgeneralized?"B":"");CHKERRQ(ierr); break; case EPS_ERROR_BACKWARD: ierr = PetscSNPrintf(ex,EXLEN," eta(x,k)");CHKERRQ(ierr); break; } ierr = PetscViewerASCIIPrintf(viewer,"%s k %s\n%s",sep,ex,sep);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = EPSGetEigenpair(eps,i,&kr,&ki,NULL,NULL);CHKERRQ(ierr); ierr = EPSComputeError(eps,i,etype,&error);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(kr); im = PetscImaginaryPart(kr); #else re = kr; im = ki; #endif if (im!=0.0) { ierr = PetscViewerASCIIPrintf(viewer," % 9f%+9fi %12g\n",(double)re,(double)im,(double)error);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," % 12f %12g\n",(double)re,(double)error);CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,sep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSErrorView_MATLAB" static PetscErrorCode EPSErrorView_MATLAB(EPS eps,EPSErrorType etype,PetscViewer viewer) { PetscErrorCode ierr; PetscReal error; PetscInt i; const char *name; PetscFunctionBegin; ierr = PetscObjectGetName((PetscObject)eps,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = EPSComputeError(eps,i,etype,&error);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSErrorView" /*@C EPSErrorView - Displays the errors associated with the computed solution (as well as the eigenvalues). Collective on EPS Input Parameters: + eps - the eigensolver context . etype - error type - viewer - optional visualization context Options Database Key: + -eps_error_absolute - print absolute errors of each eigenpair . -eps_error_relative - print relative errors of each eigenpair - -eps_error_backward - print backward errors of each eigenpair Notes: By default, this function checks the error of all eigenpairs and prints the eigenvalues if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with eigenvalues and corresponding errors is printed. Level: intermediate .seealso: EPSSolve(), EPSValuesView(), EPSVectorsView() @*/ PetscErrorCode EPSErrorView(EPS eps,EPSErrorType etype,PetscViewer viewer) { PetscBool isascii; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(eps,1,viewer,2); EPSCheckSolved(eps,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (!isascii) PetscFunctionReturn(0); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: ierr = EPSErrorView_ASCII(eps,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = EPSErrorView_DETAIL(eps,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = EPSErrorView_MATLAB(eps,etype,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(eps,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSErrorViewFromOptions" /*@ EPSErrorViewFromOptions - Processes command line options to determine if/how the errors of the computed solution are to be viewed. Collective on EPS Input Parameters: . eps - the eigensolver context Level: developer @*/ PetscErrorCode EPSErrorViewFromOptions(EPS eps) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_error_absolute",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_ABSOLUTE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_error_relative",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_error_backward",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_BACKWARD,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSValuesView_DRAW" static PetscErrorCode EPSValuesView_DRAW(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; PetscDraw draw; PetscDrawSP drawsp; PetscReal re,im; PetscInt i,k; PetscFunctionBegin; if (!eps->nconv) PetscFunctionReturn(0); ierr = PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed Eigenvalues",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);CHKERRQ(ierr); ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); ierr = PetscDrawSPCreate(draw,1,&drawsp);CHKERRQ(ierr); for (i=0;inconv;i++) { k = eps->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(eps->eigr[k]); im = PetscImaginaryPart(eps->eigr[k]); #else re = eps->eigr[k]; im = eps->eigi[k]; #endif ierr = PetscDrawSPAddPoint(drawsp,&re,&im);CHKERRQ(ierr); } ierr = PetscDrawSPDraw(drawsp,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscDrawSPSave(drawsp);CHKERRQ(ierr); ierr = PetscDrawSPDestroy(&drawsp);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSValuesView_ASCII" static PetscErrorCode EPSValuesView_ASCII(EPS eps,PetscViewer viewer) { PetscReal re,im; PetscInt i,k; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerASCIIPrintf(viewer,"Eigenvalues = \n");CHKERRQ(ierr); for (i=0;inconv;i++) { k = eps->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(eps->eigr[k]); im = PetscImaginaryPart(eps->eigr[k]); #else re = eps->eigr[k]; im = eps->eigi[k]; #endif if (PetscAbs(re)/PetscAbs(im)nconv;i++) { k = eps->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(eps->eigr[k]); im = PetscImaginaryPart(eps->eigr[k]); #else re = eps->eigr[k]; im = eps->eigi[k]; #endif if (im!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%18.16e%+18.16ei\n",(double)re,(double)im);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)re);CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSValuesView" /*@C EPSValuesView - Displays the computed eigenvalues in a viewer. Collective on EPS Input Parameters: + eps - the eigensolver context - viewer - the viewer Options Database Key: . -eps_view_values - print computed eigenvalues Level: intermediate .seealso: EPSSolve(), EPSVectorsView(), EPSErrorView() @*/ PetscErrorCode EPSValuesView(EPS eps,PetscViewer viewer) { PetscBool isascii,isdraw; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(eps,1,viewer,2); EPSCheckSolved(eps,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isdraw) { ierr = EPSValuesView_DRAW(eps,viewer);CHKERRQ(ierr); } else if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = EPSValuesView_ASCII(eps,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = EPSValuesView_MATLAB(eps,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(eps,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSValuesViewFromOptions" /*@ EPSValuesViewFromOptions - Processes command line options to determine if/how the computed eigenvalues are to be viewed. Collective on EPS Input Parameters: . eps - the eigensolver context Level: developer @*/ PetscErrorCode EPSValuesViewFromOptions(EPS eps) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_view_values",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = EPSValuesView(eps,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSVectorsView" /*@C EPSVectorsView - Outputs computed eigenvectors to a viewer. Collective on EPS Parameter: + eps - the eigensolver context - viewer - the viewer Options Database Keys: . -eps_view_vectors - output eigenvectors. Note: If PETSc was configured with real scalars, complex conjugate eigenvectors will be viewed as two separate real vectors, one containing the real part and another one containing the imaginary part. Level: intermediate .seealso: EPSSolve(), EPSValuesView(), EPSErrorView() @*/ PetscErrorCode EPSVectorsView(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; PetscInt i,k; Vec x; #define NMLEN 30 char vname[NMLEN]; const char *ename; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)eps)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(eps,1,viewer,2); EPSCheckSolved(eps,1); if (eps->nconv) { ierr = PetscObjectGetName((PetscObject)eps,&ename);CHKERRQ(ierr); ierr = EPSComputeVectors(eps);CHKERRQ(ierr); for (i=0;inconv;i++) { k = eps->perm[i]; ierr = PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,k,&x);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)x,vname);CHKERRQ(ierr); ierr = VecView(x,viewer);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,k,&x);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSVectorsViewFromOptions" /*@ EPSVectorsViewFromOptions - Processes command line options to determine if/how the computed eigenvectors are to be viewed. Collective on EPS Input Parameters: . eps - the eigensolver context Level: developer @*/ PetscErrorCode EPSVectorsViewFromOptions(EPS eps) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg = PETSC_FALSE; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,"-eps_view_vectors",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = EPSVectorsView(eps,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } slepc-3.7.4/src/eps/interface/epsdefault.c0000644000175000017500000003661513107004621020014 0ustar jromanjroman/* This file contains some simple default routines for common operations. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "EPSBackTransform_Default" PetscErrorCode EPSBackTransform_Default(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = STBackTransform(eps->st,eps->nconv,eps->eigr,eps->eigi);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeVectors_Hermitian" /* EPSComputeVectors_Hermitian - Copies the Lanczos vectors as eigenvectors using purification for generalized eigenproblems. */ PetscErrorCode EPSComputeVectors_Hermitian(EPS eps) { PetscErrorCode ierr; PetscInt i; PetscReal norm; Vec w,z; PetscFunctionBegin; if (eps->isgeneralized && eps->purify) { /* Purify eigenvectors */ ierr = BVCreateVec(eps->V,&w);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = BVCopyVec(eps->V,i,w);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,i,&z);CHKERRQ(ierr); ierr = STApply(eps->st,w,z);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&z);CHKERRQ(ierr); ierr = BVNormColumn(eps->V,i,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,i,1.0/norm);CHKERRQ(ierr); } ierr = VecDestroy(&w);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeVectors_Indefinite" /* EPSComputeVectors_Indefinite - similar to the Schur version but for indefinite problems */ PetscErrorCode EPSComputeVectors_Indefinite(EPS eps) { PetscErrorCode ierr; PetscInt n,i; Mat X; Vec v,z; #if !defined(PETSC_USE_COMPLEX) Vec v1; PetscScalar tmp; PetscReal norm,normi; #endif PetscFunctionBegin; ierr = DSGetDimensions(eps->ds,&n,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,n);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,X,0,n);CHKERRQ(ierr); ierr = MatDestroy(&X);CHKERRQ(ierr); /* purification */ if (eps->purify) { ierr = BVCreateVec(eps->V,&v);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = BVCopyVec(eps->V,i,v);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,i,&z);CHKERRQ(ierr); ierr = STApply(eps->st,v,z);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&z);CHKERRQ(ierr); } ierr = VecDestroy(&v);CHKERRQ(ierr); } /* normalization */ for (i=0;ieigi[i] != 0.0) { ierr = BVGetColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,i+1,&v1);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecNorm(v1,NORM_2,&normi);CHKERRQ(ierr); tmp = 1.0 / SlepcAbsEigenvalue(norm,normi); ierr = VecScale(v,tmp);CHKERRQ(ierr); ierr = VecScale(v1,tmp);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i+1,&v1);CHKERRQ(ierr); i++; } else #endif { ierr = BVGetColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = VecNormalize(v,NULL);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeVectors_Schur" /* EPSComputeVectors_Schur - Compute eigenvectors from the vectors provided by the eigensolver. This version is intended for solvers that provide Schur vectors. Given the partial Schur decomposition OP*V=V*T, the following steps are performed: 1) compute eigenvectors of T: T*Z=Z*D 2) compute eigenvectors of OP: X=V*Z */ PetscErrorCode EPSComputeVectors_Schur(EPS eps) { PetscErrorCode ierr; PetscInt n,i; Mat Z; Vec w,z,v; #if !defined(PETSC_USE_COMPLEX) Vec v1; PetscScalar tmp; PetscReal norm,normi; #endif PetscFunctionBegin; if (eps->ishermitian) { if (eps->isgeneralized && !eps->ispositive) { ierr = EPSComputeVectors_Indefinite(eps);CHKERRQ(ierr); } else { ierr = EPSComputeVectors_Hermitian(eps);CHKERRQ(ierr); } PetscFunctionReturn(0); } ierr = DSGetDimensions(eps->ds,&n,NULL,NULL,NULL,NULL);CHKERRQ(ierr); /* right eigenvectors */ ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); /* V = V * Z */ ierr = DSGetMat(eps->ds,DS_MAT_X,&Z);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,n);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,Z,0,n);CHKERRQ(ierr); ierr = MatDestroy(&Z);CHKERRQ(ierr); /* Purify eigenvectors */ if (eps->ispositive && eps->purify) { ierr = BVCreateVec(eps->V,&w);CHKERRQ(ierr); for (i=0;iV,i,w);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,i,&z);CHKERRQ(ierr); ierr = STApply(eps->st,w,z);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&z);CHKERRQ(ierr); } ierr = VecDestroy(&w);CHKERRQ(ierr); } /* Fix eigenvectors if balancing was used */ if (eps->balance!=EPS_BALANCE_NONE && eps->D) { for (i=0;iV,i,&z);CHKERRQ(ierr); ierr = VecPointwiseDivide(z,z,eps->D);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&z);CHKERRQ(ierr); } } /* normalize eigenvectors (when using purification or balancing) */ if ((eps->ispositive && eps->purify) || (eps->balance!=EPS_BALANCE_NONE && eps->D)) { for (i=0;ieigi[i] != 0.0) { ierr = BVGetColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,i+1,&v1);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecNorm(v1,NORM_2,&normi);CHKERRQ(ierr); tmp = 1.0 / SlepcAbsEigenvalue(norm,normi); ierr = VecScale(v,tmp);CHKERRQ(ierr); ierr = VecScale(v1,tmp);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i+1,&v1);CHKERRQ(ierr); i++; } else #endif { ierr = BVGetColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = VecNormalize(v,NULL);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetWorkVecs" /*@ EPSSetWorkVecs - Sets a number of work vectors into an EPS object. Collective on EPS Input Parameters: + eps - eigensolver context - nw - number of work vectors to allocate Developers Note: This is PETSC_EXTERN because it may be required by user plugin EPS implementations. Level: developer @*/ PetscErrorCode EPSSetWorkVecs(EPS eps,PetscInt nw) { PetscErrorCode ierr; Vec t; PetscFunctionBegin; if (eps->nwork < nw) { ierr = VecDestroyVecs(eps->nwork,&eps->work);CHKERRQ(ierr); eps->nwork = nw; ierr = BVGetColumn(eps->V,0,&t);CHKERRQ(ierr); ierr = VecDuplicateVecs(t,nw,&eps->work);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&t);CHKERRQ(ierr); ierr = PetscLogObjectParents(eps,nw,eps->work);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetWhichEigenpairs_Default" /* EPSSetWhichEigenpairs_Default - Sets the default value for which, depending on the ST. */ PetscErrorCode EPSSetWhichEigenpairs_Default(EPS eps) { PetscBool target; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscObjectTypeCompareAny((PetscObject)eps->st,&target,STSINVERT,STCAYLEY,"");CHKERRQ(ierr); if (target) eps->which = EPS_TARGET_MAGNITUDE; else eps->which = EPS_LARGEST_MAGNITUDE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSConvergedRelative" /* EPSConvergedRelative - Checks convergence relative to the eigenvalue. */ PetscErrorCode EPSConvergedRelative(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscReal w; PetscFunctionBegin; w = SlepcAbsEigenvalue(eigr,eigi); *errest = res/w; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSConvergedAbsolute" /* EPSConvergedAbsolute - Checks convergence absolutely. */ PetscErrorCode EPSConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscFunctionBegin; *errest = res; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSConvergedNorm" /* EPSConvergedNorm - Checks convergence relative to the eigenvalue and the matrix norms. */ PetscErrorCode EPSConvergedNorm(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscReal w; PetscFunctionBegin; w = SlepcAbsEigenvalue(eigr,eigi); *errest = res / (eps->nrma + w*eps->nrmb); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSStoppingBasic" /*@C EPSStoppingBasic - Default routine to determine whether the outer eigensolver iteration must be stopped. Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged eigenpairs . nev - number of requested eigenpairs - ctx - context (not used here) Output Parameter: . reason - result of the stopping test Notes: A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to EPS_CONVERGED_ITERATING (zero). EPSStoppingBasic() will stop if all requested eigenvalues are converged, or if the maximum number of iterations has been reached. Use EPSSetStoppingTest() to provide your own test instead of using this one. Level: advanced .seealso: EPSSetStoppingTest(), EPSConvergedReason, EPSGetConvergedReason() @*/ PetscErrorCode EPSStoppingBasic(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; *reason = EPS_CONVERGED_ITERATING; if (nconv >= nev) { ierr = PetscInfo2(eps,"Linear eigensolver finished successfully: %D eigenpairs converged at iteration %D\n",nconv,its);CHKERRQ(ierr); *reason = EPS_CONVERGED_TOL; } else if (its >= max_it) { *reason = EPS_DIVERGED_ITS; ierr = PetscInfo1(eps,"Linear eigensolver iteration reached maximum number of iterations (%D)\n",its);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeRitzVector" /* EPSComputeRitzVector - Computes the current Ritz vector. Simple case (complex scalars or real scalars with Zi=NULL): x = V*Zr (V is a basis of nv vectors, Zr has length nv) Split case: x = V*Zr y = V*Zi (Zr and Zi have length nv) */ PetscErrorCode EPSComputeRitzVector(EPS eps,PetscScalar *Zr,PetscScalar *Zi,BV V,Vec x,Vec y) { PetscErrorCode ierr; PetscReal norm; #if !defined(PETSC_USE_COMPLEX) Vec z; #endif PetscFunctionBegin; /* compute eigenvector */ ierr = BVMultVec(V,1.0,0.0,x,Zr);CHKERRQ(ierr); /* purify eigenvector in positive generalized problems */ if (eps->ispositive && eps->purify) { ierr = STApply(eps->st,x,y);CHKERRQ(ierr); if (eps->ishermitian) { ierr = BVNormVec(eps->V,y,NORM_2,&norm);CHKERRQ(ierr); } else { ierr = VecNorm(y,NORM_2,&norm);CHKERRQ(ierr); } ierr = VecScale(y,1.0/norm);CHKERRQ(ierr); ierr = VecCopy(y,x);CHKERRQ(ierr); } /* fix eigenvector if balancing is used */ if (!eps->ishermitian && eps->balance!=EPS_BALANCE_NONE && eps->D) { ierr = VecPointwiseDivide(x,x,eps->D);CHKERRQ(ierr); ierr = VecNormalize(x,&norm);CHKERRQ(ierr); } #if !defined(PETSC_USE_COMPLEX) /* compute imaginary part of eigenvector */ if (Zi) { ierr = BVMultVec(V,1.0,0.0,y,Zi);CHKERRQ(ierr); if (eps->ispositive) { ierr = BVCreateVec(V,&z);CHKERRQ(ierr); ierr = STApply(eps->st,y,z);CHKERRQ(ierr); ierr = VecNorm(z,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(z,1.0/norm);CHKERRQ(ierr); ierr = VecCopy(z,y);CHKERRQ(ierr); ierr = VecDestroy(&z);CHKERRQ(ierr); } if (eps->balance!=EPS_BALANCE_NONE && eps->D) { ierr = VecPointwiseDivide(y,y,eps->D);CHKERRQ(ierr); ierr = VecNormalize(y,&norm);CHKERRQ(ierr); } } else #endif { ierr = VecSet(y,0.0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBuildBalance_Krylov" /* EPSBuildBalance_Krylov - uses a Krylov subspace method to compute the diagonal matrix to be applied for balancing in non-Hermitian problems. */ PetscErrorCode EPSBuildBalance_Krylov(EPS eps) { Vec z,p,r; PetscInt i,j; PetscReal norma; PetscScalar *pz,*pD; const PetscScalar *pr,*pp; PetscRandom rand; PetscErrorCode ierr; PetscFunctionBegin; ierr = EPSSetWorkVecs(eps,3);CHKERRQ(ierr); ierr = BVGetRandomContext(eps->V,&rand);CHKERRQ(ierr); r = eps->work[0]; p = eps->work[1]; z = eps->work[2]; ierr = VecSet(eps->D,1.0);CHKERRQ(ierr); for (j=0;jbalance_its;j++) { /* Build a random vector of +-1's */ ierr = VecSetRandom(z,rand);CHKERRQ(ierr); ierr = VecGetArray(z,&pz);CHKERRQ(ierr); for (i=0;inloc;i++) { if (PetscRealPart(pz[i])<0.5) pz[i]=-1.0; else pz[i]=1.0; } ierr = VecRestoreArray(z,&pz);CHKERRQ(ierr); /* Compute p=DA(D\z) */ ierr = VecPointwiseDivide(r,z,eps->D);CHKERRQ(ierr); ierr = STApply(eps->st,r,p);CHKERRQ(ierr); ierr = VecPointwiseMult(p,p,eps->D);CHKERRQ(ierr); if (j==0) { /* Estimate the matrix inf-norm */ ierr = VecAbs(p);CHKERRQ(ierr); ierr = VecMax(p,NULL,&norma);CHKERRQ(ierr); } if (eps->balance == EPS_BALANCE_TWOSIDE) { /* Compute r=D\(A'Dz) */ ierr = VecPointwiseMult(z,z,eps->D);CHKERRQ(ierr); ierr = STApplyTranspose(eps->st,z,r);CHKERRQ(ierr); ierr = VecPointwiseDivide(r,r,eps->D);CHKERRQ(ierr); } /* Adjust values of D */ ierr = VecGetArrayRead(r,&pr);CHKERRQ(ierr); ierr = VecGetArrayRead(p,&pp);CHKERRQ(ierr); ierr = VecGetArray(eps->D,&pD);CHKERRQ(ierr); for (i=0;inloc;i++) { if (eps->balance == EPS_BALANCE_TWOSIDE) { if (PetscAbsScalar(pp[i])>eps->balance_cutoff*norma && pr[i]!=0.0) pD[i] *= PetscSqrtReal(PetscAbsScalar(pr[i]/pp[i])); } else { if (pp[i]!=0.0) pD[i] *= 1.0/PetscAbsScalar(pp[i]); } } ierr = VecRestoreArrayRead(r,&pr);CHKERRQ(ierr); ierr = VecRestoreArrayRead(p,&pp);CHKERRQ(ierr); ierr = VecRestoreArray(eps->D,&pD);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/interface/epsopts.c.html0000644000175000017500000043071513107004621020317 0ustar jromanjroman
Actual source code: epsopts.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       EPS routines related to options that can be set via the command-line
  3:       or procedurally.

  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: */

 25: #include <slepc/private/epsimpl.h>   /*I "slepceps.h" I*/
 26: #include <petscdraw.h>

 30: /*@C
 31:    EPSMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 32:    indicated by the user.

 34:    Collective on EPS

 36:    Input Parameters:
 37: +  eps      - the eigensolver context
 38: .  name     - the monitor option name
 39: .  help     - message indicating what monitoring is done
 40: .  manual   - manual page for the monitor
 41: .  monitor  - the monitor function, whose context is a PetscViewerAndFormat
 42: -  trackall - whether this monitor tracks all eigenvalues or not

 44:    Level: developer

 46: .seealso: EPSMonitorSet(), EPSSetTrackAll(), EPSConvMonitorSetFromOptions()
 47: @*/
 48: PetscErrorCode EPSMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
 49: {
 50:   PetscErrorCode       ierr;
 51:   PetscBool            flg;
 52:   PetscViewer          viewer;
 53:   PetscViewerFormat    format;
 54:   PetscViewerAndFormat *vf;

 57:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,name,&viewer,&format,&flg);
 58:   if (flg) {
 59:     PetscViewerAndFormatCreate(viewer,format,&vf);
 60:     PetscObjectDereference((PetscObject)viewer);
 61:     EPSMonitorSet(eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
 62:     if (trackall) {
 63:       EPSSetTrackAll(eps,PETSC_TRUE);
 64:     }
 65:   }
 66:   return(0);
 67: }

 71: /*@C
 72:    EPSConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 73:    indicated by the user (for monitors that only show iteration numbers of convergence).

 75:    Collective on EPS

 77:    Input Parameters:
 78: +  eps      - the eigensolver context
 79: .  name     - the monitor option name
 80: .  help     - message indicating what monitoring is done
 81: .  manual   - manual page for the monitor
 82: -  monitor  - the monitor function, whose context is a SlepcConvMonitor

 84:    Level: developer

 86: .seealso: EPSMonitorSet(), EPSMonitorSetFromOptions()
 87: @*/
 88: PetscErrorCode EPSConvMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))
 89: {
 90:   PetscErrorCode    ierr;
 91:   PetscBool         flg;
 92:   PetscViewer       viewer;
 93:   PetscViewerFormat format;
 94:   SlepcConvMonitor  ctx;

 97:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,name,&viewer,&format,&flg);
 98:   if (flg) {
 99:     SlepcConvMonitorCreate(viewer,format,&ctx);
100:     PetscObjectDereference((PetscObject)viewer);
101:     EPSMonitorSet(eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);
102:   }
103:   return(0);
104: }

108: /*@
109:    EPSSetFromOptions - Sets EPS options from the options database.
110:    This routine must be called before EPSSetUp() if the user is to be
111:    allowed to set the solver type.

113:    Collective on EPS

115:    Input Parameters:
116: .  eps - the eigensolver context

118:    Notes:
119:    To see all options, run your program with the -help option.

121:    Level: beginner
122: @*/
123: PetscErrorCode EPSSetFromOptions(EPS eps)
124: {
126:   char           type[256];
127:   PetscBool      set,flg,flg1,flg2,flg3;
128:   PetscReal      r,array[2]={0,0};
129:   PetscScalar    s;
130:   PetscInt       i,j,k;
131:   PetscDrawLG    lg;

135:   EPSRegisterAll();
136:   PetscObjectOptionsBegin((PetscObject)eps);
137:     PetscOptionsFList("-eps_type","Eigenvalue Problem Solver method","EPSSetType",EPSList,(char*)(((PetscObject)eps)->type_name?((PetscObject)eps)->type_name:EPSKRYLOVSCHUR),type,256,&flg);
138:     if (flg) {
139:       EPSSetType(eps,type);
140:     }
141:     /*
142:       Set the type if it was never set.
143:     */
144:     if (!((PetscObject)eps)->type_name) {
145:       EPSSetType(eps,EPSKRYLOVSCHUR);
146:     }

148:     PetscOptionsBoolGroupBegin("-eps_hermitian","hermitian eigenvalue problem","EPSSetProblemType",&flg);
149:     if (flg) { EPSSetProblemType(eps,EPS_HEP); }
150:     PetscOptionsBoolGroup("-eps_gen_hermitian","generalized hermitian eigenvalue problem","EPSSetProblemType",&flg);
151:     if (flg) { EPSSetProblemType(eps,EPS_GHEP); }
152:     PetscOptionsBoolGroup("-eps_non_hermitian","non-hermitian eigenvalue problem","EPSSetProblemType",&flg);
153:     if (flg) { EPSSetProblemType(eps,EPS_NHEP); }
154:     PetscOptionsBoolGroup("-eps_gen_non_hermitian","generalized non-hermitian eigenvalue problem","EPSSetProblemType",&flg);
155:     if (flg) { EPSSetProblemType(eps,EPS_GNHEP); }
156:     PetscOptionsBoolGroup("-eps_pos_gen_non_hermitian","generalized non-hermitian eigenvalue problem with positive semi-definite B","EPSSetProblemType",&flg);
157:     if (flg) { EPSSetProblemType(eps,EPS_PGNHEP); }
158:     PetscOptionsBoolGroupEnd("-eps_gen_indefinite","generalized hermitian-indefinite eigenvalue problem","EPSSetProblemType",&flg);
159:     if (flg) { EPSSetProblemType(eps,EPS_GHIEP); }

161:     PetscOptionsBoolGroupBegin("-eps_ritz","Rayleigh-Ritz extraction","EPSSetExtraction",&flg);
162:     if (flg) { EPSSetExtraction(eps,EPS_RITZ); }
163:     PetscOptionsBoolGroup("-eps_harmonic","harmonic Ritz extraction","EPSSetExtraction",&flg);
164:     if (flg) { EPSSetExtraction(eps,EPS_HARMONIC); }
165:     PetscOptionsBoolGroup("-eps_harmonic_relative","relative harmonic Ritz extraction","EPSSetExtraction",&flg);
166:     if (flg) { EPSSetExtraction(eps,EPS_HARMONIC_RELATIVE); }
167:     PetscOptionsBoolGroup("-eps_harmonic_right","right harmonic Ritz extraction","EPSSetExtraction",&flg);
168:     if (flg) { EPSSetExtraction(eps,EPS_HARMONIC_RIGHT); }
169:     PetscOptionsBoolGroup("-eps_harmonic_largest","largest harmonic Ritz extraction","EPSSetExtraction",&flg);
170:     if (flg) { EPSSetExtraction(eps,EPS_HARMONIC_LARGEST); }
171:     PetscOptionsBoolGroup("-eps_refined","refined Ritz extraction","EPSSetExtraction",&flg);
172:     if (flg) { EPSSetExtraction(eps,EPS_REFINED); }
173:     PetscOptionsBoolGroupEnd("-eps_refined_harmonic","refined harmonic Ritz extraction","EPSSetExtraction",&flg);
174:     if (flg) { EPSSetExtraction(eps,EPS_REFINED_HARMONIC); }

176:     PetscOptionsEnum("-eps_balance","Balancing method","EPSSetBalance",EPSBalanceTypes,(PetscEnum)eps->balance,(PetscEnum*)&eps->balance,NULL);

178:     j = eps->balance_its;
179:     PetscOptionsInt("-eps_balance_its","Number of iterations in balancing","EPSSetBalance",eps->balance_its,&j,&flg1);
180:     r = eps->balance_cutoff;
181:     PetscOptionsReal("-eps_balance_cutoff","Cutoff value in balancing","EPSSetBalance",eps->balance_cutoff,&r,&flg2);
182:     if (flg1 || flg2) {
183:       EPSSetBalance(eps,eps->balance,j,r);
184:     }

186:     i = eps->max_it? eps->max_it: PETSC_DEFAULT;
187:     PetscOptionsInt("-eps_max_it","Maximum number of iterations","EPSSetTolerances",eps->max_it,&i,&flg1);
188:     r = eps->tol;
189:     PetscOptionsReal("-eps_tol","Tolerance","EPSSetTolerances",eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol,&r,&flg2);
190:     if (flg1 || flg2) {
191:       EPSSetTolerances(eps,r,i);
192:     }

194:     PetscOptionsBoolGroupBegin("-eps_conv_rel","Relative error convergence test","EPSSetConvergenceTest",&flg);
195:     if (flg) { EPSSetConvergenceTest(eps,EPS_CONV_REL); }
196:     PetscOptionsBoolGroup("-eps_conv_norm","Convergence test relative to the eigenvalue and the matrix norms","EPSSetConvergenceTest",&flg);
197:     if (flg) { EPSSetConvergenceTest(eps,EPS_CONV_NORM); }
198:     PetscOptionsBoolGroup("-eps_conv_abs","Absolute error convergence test","EPSSetConvergenceTest",&flg);
199:     if (flg) { EPSSetConvergenceTest(eps,EPS_CONV_ABS); }
200:     PetscOptionsBoolGroupEnd("-eps_conv_user","User-defined convergence test","EPSSetConvergenceTest",&flg);
201:     if (flg) { EPSSetConvergenceTest(eps,EPS_CONV_USER); }

203:     PetscOptionsBoolGroupBegin("-eps_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","EPSSetStoppingTest",&flg);
204:     if (flg) { EPSSetStoppingTest(eps,EPS_STOP_BASIC); }
205:     PetscOptionsBoolGroupEnd("-eps_stop_user","User-defined stopping test","EPSSetStoppingTest",&flg);
206:     if (flg) { EPSSetStoppingTest(eps,EPS_STOP_USER); }

208:     i = eps->nev;
209:     PetscOptionsInt("-eps_nev","Number of eigenvalues to compute","EPSSetDimensions",eps->nev,&i,&flg1);
210:     j = eps->ncv? eps->ncv: PETSC_DEFAULT;
211:     PetscOptionsInt("-eps_ncv","Number of basis vectors","EPSSetDimensions",eps->ncv,&j,&flg2);
212:     k = eps->mpd? eps->mpd: PETSC_DEFAULT;
213:     PetscOptionsInt("-eps_mpd","Maximum dimension of projected problem","EPSSetDimensions",eps->mpd,&k,&flg3);
214:     if (flg1 || flg2 || flg3) {
215:       EPSSetDimensions(eps,i,j,k);
216:     }

218:     /* -----------------------------------------------------------------------*/
219:     /*
220:       Cancels all monitors hardwired into code before call to EPSSetFromOptions()
221:     */
222:     PetscOptionsBool("-eps_monitor_cancel","Remove any hardwired monitor routines","EPSMonitorCancel",PETSC_FALSE,&flg,&set);
223:     if (set && flg) {
224:       EPSMonitorCancel(eps);
225:     }
226:     /*
227:       Text monitors
228:     */
229:     EPSMonitorSetFromOptions(eps,"-eps_monitor","Monitor first unconverged approximate eigenvalue and error estimate","EPSMonitorFirst",EPSMonitorFirst,PETSC_FALSE);
230:     EPSConvMonitorSetFromOptions(eps,"-eps_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","EPSMonitorConverged",EPSMonitorConverged);
231:     EPSMonitorSetFromOptions(eps,"-eps_monitor_all","Monitor approximate eigenvalues and error estimates","EPSMonitorAll",EPSMonitorAll,PETSC_TRUE);
232:     /*
233:       Line graph monitors
234:     */
235:     PetscOptionsBool("-eps_monitor_lg","Monitor first unconverged approximate eigenvalue and error estimate graphically","EPSMonitorSet",PETSC_FALSE,&flg,&set);
236:     if (set && flg) {
237:       EPSMonitorLGCreate(PetscObjectComm((PetscObject)eps),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
238:       EPSMonitorSet(eps,EPSMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
239:     }
240:     PetscOptionsBool("-eps_monitor_lg_all","Monitor error estimates graphically","EPSMonitorSet",PETSC_FALSE,&flg,&set);
241:     if (set && flg) {
242:       EPSMonitorLGCreate(PetscObjectComm((PetscObject)eps),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
243:       EPSMonitorSet(eps,EPSMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
244:       EPSSetTrackAll(eps,PETSC_TRUE);
245:     }
246:   /* -----------------------------------------------------------------------*/
247:     PetscOptionsBoolGroupBegin("-eps_largest_magnitude","compute largest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg);
248:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_LARGEST_MAGNITUDE); }
249:     PetscOptionsBoolGroup("-eps_smallest_magnitude","compute smallest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg);
250:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_SMALLEST_MAGNITUDE); }
251:     PetscOptionsBoolGroup("-eps_largest_real","compute largest real parts","EPSSetWhichEigenpairs",&flg);
252:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL); }
253:     PetscOptionsBoolGroup("-eps_smallest_real","compute smallest real parts","EPSSetWhichEigenpairs",&flg);
254:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL); }
255:     PetscOptionsBoolGroup("-eps_largest_imaginary","compute largest imaginary parts","EPSSetWhichEigenpairs",&flg);
256:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_LARGEST_IMAGINARY); }
257:     PetscOptionsBoolGroup("-eps_smallest_imaginary","compute smallest imaginary parts","EPSSetWhichEigenpairs",&flg);
258:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_SMALLEST_IMAGINARY); }
259:     PetscOptionsBoolGroup("-eps_target_magnitude","compute nearest eigenvalues to target","EPSSetWhichEigenpairs",&flg);
260:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE); }
261:     PetscOptionsBoolGroup("-eps_target_real","compute eigenvalues with real parts close to target","EPSSetWhichEigenpairs",&flg);
262:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_TARGET_REAL); }
263:     PetscOptionsBoolGroup("-eps_target_imaginary","compute eigenvalues with imaginary parts close to target","EPSSetWhichEigenpairs",&flg);
264:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_TARGET_IMAGINARY); }
265:     PetscOptionsBoolGroupEnd("-eps_all","compute all eigenvalues in an interval or a region","EPSSetWhichEigenpairs",&flg);
266:     if (flg) { EPSSetWhichEigenpairs(eps,EPS_ALL); }

268:     PetscOptionsScalar("-eps_target","Value of the target","EPSSetTarget",eps->target,&s,&flg);
269:     if (flg) {
270:       if (eps->which!=EPS_TARGET_REAL && eps->which!=EPS_TARGET_IMAGINARY) {
271:         EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);
272:       }
273:       EPSSetTarget(eps,s);
274:     }
275:     k = 2;
276:     PetscOptionsRealArray("-eps_interval","Computational interval (two real values separated with a comma without spaces)","EPSSetInterval",array,&k,&flg);
277:     if (flg) {
278:       if (k<2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_SIZ,"Must pass two values in -eps_interval (comma-separated without spaces)");
279:       EPSSetWhichEigenpairs(eps,EPS_ALL);
280:       EPSSetInterval(eps,array[0],array[1]);
281:     }

283:     PetscOptionsBool("-eps_true_residual","Compute true residuals explicitly","EPSSetTrueResidual",eps->trueres,&eps->trueres,NULL);
284:     PetscOptionsBool("-eps_purify","Postprocess eigenvectors for purification","EPSSetPurify",eps->purify,&eps->purify,NULL);

286:     PetscOptionsName("-eps_view","Print detailed information on solver used","EPSView",NULL);
287:     PetscOptionsName("-eps_view_vectors","View computed eigenvectors","EPSVectorsView",NULL);
288:     PetscOptionsName("-eps_view_values","View computed eigenvalues","EPSValuesView",NULL);
289:     PetscOptionsName("-eps_converged_reason","Print reason for convergence, and number of iterations","EPSReasonView",NULL);
290:     PetscOptionsName("-eps_error_absolute","Print absolute errors of each eigenpair","EPSErrorView",NULL);
291:     PetscOptionsName("-eps_error_relative","Print relative errors of each eigenpair","EPSErrorView",NULL);
292:     PetscOptionsName("-eps_error_backward","Print backward errors of each eigenpair","EPSErrorView",NULL);

294:     if (eps->ops->setfromoptions) {
295:       (*eps->ops->setfromoptions)(PetscOptionsObject,eps);
296:     }
297:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)eps);
298:   PetscOptionsEnd();

300:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
301:   BVSetFromOptions(eps->V);
302:   if (!eps->rg) { EPSGetRG(eps,&eps->rg); }
303:   RGSetFromOptions(eps->rg);
304:   if (!eps->ds) { EPSGetDS(eps,&eps->ds); }
305:   DSSetFromOptions(eps->ds);
306:   if (!eps->st) { EPSGetST(eps,&eps->st); }
307:   STSetFromOptions(eps->st);
308:   return(0);
309: }

313: /*@
314:    EPSGetTolerances - Gets the tolerance and maximum iteration count used
315:    by the EPS convergence tests.

317:    Not Collective

319:    Input Parameter:
320: .  eps - the eigensolver context

322:    Output Parameters:
323: +  tol - the convergence tolerance
324: -  maxits - maximum number of iterations

326:    Notes:
327:    The user can specify NULL for any parameter that is not needed.

329:    Level: intermediate

331: .seealso: EPSSetTolerances()
332: @*/
333: PetscErrorCode EPSGetTolerances(EPS eps,PetscReal *tol,PetscInt *maxits)
334: {
337:   if (tol)    *tol    = eps->tol;
338:   if (maxits) *maxits = eps->max_it;
339:   return(0);
340: }

344: /*@
345:    EPSSetTolerances - Sets the tolerance and maximum iteration count used
346:    by the EPS convergence tests.

348:    Logically Collective on EPS

350:    Input Parameters:
351: +  eps - the eigensolver context
352: .  tol - the convergence tolerance
353: -  maxits - maximum number of iterations to use

355:    Options Database Keys:
356: +  -eps_tol <tol> - Sets the convergence tolerance
357: -  -eps_max_it <maxits> - Sets the maximum number of iterations allowed

359:    Notes:
360:    Use PETSC_DEFAULT for either argument to assign a reasonably good value.

362:    Level: intermediate

364: .seealso: EPSGetTolerances()
365: @*/
366: PetscErrorCode EPSSetTolerances(EPS eps,PetscReal tol,PetscInt maxits)
367: {
372:   if (tol == PETSC_DEFAULT) {
373:     eps->tol   = PETSC_DEFAULT;
374:     eps->state = EPS_STATE_INITIAL;
375:   } else {
376:     if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
377:     eps->tol = tol;
378:   }
379:   if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
380:     eps->max_it = 0;
381:     eps->state  = EPS_STATE_INITIAL;
382:   } else {
383:     if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
384:     eps->max_it = maxits;
385:   }
386:   return(0);
387: }

391: /*@
392:    EPSGetDimensions - Gets the number of eigenvalues to compute
393:    and the dimension of the subspace.

395:    Not Collective

397:    Input Parameter:
398: .  eps - the eigensolver context

400:    Output Parameters:
401: +  nev - number of eigenvalues to compute
402: .  ncv - the maximum dimension of the subspace to be used by the solver
403: -  mpd - the maximum dimension allowed for the projected problem

405:    Level: intermediate

407: .seealso: EPSSetDimensions()
408: @*/
409: PetscErrorCode EPSGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
410: {
413:   if (nev) *nev = eps->nev;
414:   if (ncv) *ncv = eps->ncv;
415:   if (mpd) *mpd = eps->mpd;
416:   return(0);
417: }

421: /*@
422:    EPSSetDimensions - Sets the number of eigenvalues to compute
423:    and the dimension of the subspace.

425:    Logically Collective on EPS

427:    Input Parameters:
428: +  eps - the eigensolver context
429: .  nev - number of eigenvalues to compute
430: .  ncv - the maximum dimension of the subspace to be used by the solver
431: -  mpd - the maximum dimension allowed for the projected problem

433:    Options Database Keys:
434: +  -eps_nev <nev> - Sets the number of eigenvalues
435: .  -eps_ncv <ncv> - Sets the dimension of the subspace
436: -  -eps_mpd <mpd> - Sets the maximum projected dimension

438:    Notes:
439:    Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is
440:    dependent on the solution method.

442:    The parameters ncv and mpd are intimately related, so that the user is advised
443:    to set one of them at most. Normal usage is that
444:    (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and
445:    (b) in cases where nev is large, the user sets mpd.

447:    The value of ncv should always be between nev and (nev+mpd), typically
448:    ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise
449:    a smaller value should be used.

451:    When computing all eigenvalues in an interval, see EPSSetInterval(), these
452:    parameters lose relevance, and tuning must be done with
453:    EPSKrylovSchurSetDimensions().

455:    Level: intermediate

457: .seealso: EPSGetDimensions(), EPSSetInterval(), EPSKrylovSchurSetDimensions()
458: @*/
459: PetscErrorCode EPSSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)
460: {
466:   if (nev<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
467:   eps->nev = nev;
468:   if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) {
469:     eps->ncv = 0;
470:   } else {
471:     if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
472:     eps->ncv = ncv;
473:   }
474:   if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) {
475:     eps->mpd = 0;
476:   } else {
477:     if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
478:     eps->mpd = mpd;
479:   }
480:   eps->state = EPS_STATE_INITIAL;
481:   return(0);
482: }

486: /*@
487:    EPSSetWhichEigenpairs - Specifies which portion of the spectrum is
488:    to be sought.

490:    Logically Collective on EPS

492:    Input Parameters:
493: +  eps   - eigensolver context obtained from EPSCreate()
494: -  which - the portion of the spectrum to be sought

496:    Possible values:
497:    The parameter 'which' can have one of these values

499: +     EPS_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default)
500: .     EPS_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude
501: .     EPS_LARGEST_REAL - largest real parts
502: .     EPS_SMALLEST_REAL - smallest real parts
503: .     EPS_LARGEST_IMAGINARY - largest imaginary parts
504: .     EPS_SMALLEST_IMAGINARY - smallest imaginary parts
505: .     EPS_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude)
506: .     EPS_TARGET_REAL - eigenvalues with real part closest to target
507: .     EPS_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target
508: .     EPS_ALL - all eigenvalues contained in a given interval or region
509: -     EPS_WHICH_USER - user defined ordering set with EPSSetEigenvalueComparison()

511:    Options Database Keys:
512: +   -eps_largest_magnitude - Sets largest eigenvalues in magnitude
513: .   -eps_smallest_magnitude - Sets smallest eigenvalues in magnitude
514: .   -eps_largest_real - Sets largest real parts
515: .   -eps_smallest_real - Sets smallest real parts
516: .   -eps_largest_imaginary - Sets largest imaginary parts
517: .   -eps_smallest_imaginary - Sets smallest imaginary parts
518: .   -eps_target_magnitude - Sets eigenvalues closest to target
519: .   -eps_target_real - Sets real parts closest to target
520: .   -eps_target_imaginary - Sets imaginary parts closest to target
521: -   -eps_all - Sets all eigenvalues in an interval or region

523:    Notes:
524:    Not all eigensolvers implemented in EPS account for all the possible values
525:    stated above. Also, some values make sense only for certain types of
526:    problems. If SLEPc is compiled for real numbers EPS_LARGEST_IMAGINARY
527:    and EPS_SMALLEST_IMAGINARY use the absolute value of the imaginary part
528:    for eigenvalue selection.

530:    The target is a scalar value provided with EPSSetTarget().

532:    The criterion EPS_TARGET_IMAGINARY is available only in case PETSc and
533:    SLEPc have been built with complex scalars.

535:    EPS_ALL is intended for use in combination with an interval (see
536:    EPSSetInterval()), when all eigenvalues within the interval are requested,
537:    or in the context of the CISS solver for computing all eigenvalues in a region.
538:    In those cases, the number of eigenvalues is unknown, so the nev parameter
539:    has a different sense, see EPSSetDimensions().

541:    Level: intermediate

543: .seealso: EPSGetWhichEigenpairs(), EPSSetTarget(), EPSSetInterval(),
544:           EPSSetDimensions(), EPSSetEigenvalueComparison(), EPSWhich
545: @*/
546: PetscErrorCode EPSSetWhichEigenpairs(EPS eps,EPSWhich which)
547: {
551:   switch (which) {
552:     case EPS_LARGEST_MAGNITUDE:
553:     case EPS_SMALLEST_MAGNITUDE:
554:     case EPS_LARGEST_REAL:
555:     case EPS_SMALLEST_REAL:
556:     case EPS_LARGEST_IMAGINARY:
557:     case EPS_SMALLEST_IMAGINARY:
558:     case EPS_TARGET_MAGNITUDE:
559:     case EPS_TARGET_REAL:
560: #if defined(PETSC_USE_COMPLEX)
561:     case EPS_TARGET_IMAGINARY:
562: #endif
563:     case EPS_ALL:
564:     case EPS_WHICH_USER:
565:       if (eps->which != which) {
566:         eps->state = EPS_STATE_INITIAL;
567:         eps->which = which;
568:       }
569:       break;
570:     default:
571:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
572:   }
573:   return(0);
574: }

578: /*@
579:    EPSGetWhichEigenpairs - Returns which portion of the spectrum is to be
580:    sought.

582:    Not Collective

584:    Input Parameter:
585: .  eps - eigensolver context obtained from EPSCreate()

587:    Output Parameter:
588: .  which - the portion of the spectrum to be sought

590:    Notes:
591:    See EPSSetWhichEigenpairs() for possible values of 'which'.

593:    Level: intermediate

595: .seealso: EPSSetWhichEigenpairs(), EPSWhich
596: @*/
597: PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which)
598: {
602:   *which = eps->which;
603:   return(0);
604: }

608: /*@C
609:    EPSSetEigenvalueComparison - Specifies the eigenvalue comparison function
610:    when EPSSetWhichEigenpairs() is set to EPS_WHICH_USER.

612:    Logically Collective on EPS

614:    Input Parameters:
615: +  eps  - eigensolver context obtained from EPSCreate()
616: .  func - a pointer to the comparison function
617: -  ctx  - a context pointer (the last parameter to the comparison function)

619:    Calling Sequence of func:
620: $   func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx)

622: +   ar     - real part of the 1st eigenvalue
623: .   ai     - imaginary part of the 1st eigenvalue
624: .   br     - real part of the 2nd eigenvalue
625: .   bi     - imaginary part of the 2nd eigenvalue
626: .   res    - result of comparison
627: -   ctx    - optional context, as set by EPSSetEigenvalueComparison()

629:    Note:
630:    The returning parameter 'res' can be
631: +  negative - if the 1st eigenvalue is preferred to the 2st one
632: .  zero     - if both eigenvalues are equally preferred
633: -  positive - if the 2st eigenvalue is preferred to the 1st one

635:    Level: advanced

637: .seealso: EPSSetWhichEigenpairs(), EPSWhich
638: @*/
639: PetscErrorCode EPSSetEigenvalueComparison(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)
640: {
643:   eps->sc->comparison    = func;
644:   eps->sc->comparisonctx = ctx;
645:   eps->which             = EPS_WHICH_USER;
646:   return(0);
647: }

651: /*@C
652:    EPSSetArbitrarySelection - Specifies a function intended to look for
653:    eigenvalues according to an arbitrary selection criterion. This criterion
654:    can be based on a computation involving the current eigenvector approximation.

656:    Logically Collective on EPS

658:    Input Parameters:
659: +  eps  - eigensolver context obtained from EPSCreate()
660: .  func - a pointer to the evaluation function
661: -  ctx  - a context pointer (the last parameter to the evaluation function)

663:    Calling Sequence of func:
664: $   func(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)

666: +   er     - real part of the current eigenvalue approximation
667: .   ei     - imaginary part of the current eigenvalue approximation
668: .   xr     - real part of the current eigenvector approximation
669: .   xi     - imaginary part of the current eigenvector approximation
670: .   rr     - result of evaluation (real part)
671: .   ri     - result of evaluation (imaginary part)
672: -   ctx    - optional context, as set by EPSSetArbitrarySelection()

674:    Notes:
675:    This provides a mechanism to select eigenpairs by evaluating a user-defined
676:    function. When a function has been provided, the default selection based on
677:    sorting the eigenvalues is replaced by the sorting of the results of this
678:    function (with the same sorting criterion given in EPSSetWhichEigenpairs()).

680:    For instance, suppose you want to compute those eigenvectors that maximize
681:    a certain computable expression. Then implement the computation using
682:    the arguments xr and xi, and return the result in rr. Then set the standard
683:    sorting by magnitude so that the eigenpair with largest value of rr is
684:    selected.

686:    This evaluation function is collective, that is, all processes call it and
687:    it can use collective operations; furthermore, the computed result must
688:    be the same in all processes.

690:    The result of func is expressed as a complex number so that it is possible to
691:    use the standard eigenvalue sorting functions, but normally only rr is used.
692:    Set ri to zero unless it is meaningful in your application.

694:    Level: advanced

696: .seealso: EPSSetWhichEigenpairs()
697: @*/
698: PetscErrorCode EPSSetArbitrarySelection(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*),void* ctx)
699: {
702:   eps->arbitrary    = func;
703:   eps->arbitraryctx = ctx;
704:   eps->state        = EPS_STATE_INITIAL;
705:   return(0);
706: }

710: /*@C
711:    EPSSetConvergenceTestFunction - Sets a function to compute the error estimate
712:    used in the convergence test.

714:    Logically Collective on EPS

716:    Input Parameters:
717: +  eps     - eigensolver context obtained from EPSCreate()
718: .  func    - a pointer to the convergence test function
719: .  ctx     - context for private data for the convergence routine (may be null)
720: -  destroy - a routine for destroying the context (may be null)

722:    Calling Sequence of func:
723: $   func(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)

725: +   eps    - eigensolver context obtained from EPSCreate()
726: .   eigr   - real part of the eigenvalue
727: .   eigi   - imaginary part of the eigenvalue
728: .   res    - residual norm associated to the eigenpair
729: .   errest - (output) computed error estimate
730: -   ctx    - optional context, as set by EPSSetConvergenceTestFunction()

732:    Note:
733:    If the error estimate returned by the convergence test function is less than
734:    the tolerance, then the eigenvalue is accepted as converged.

736:    Level: advanced

738: .seealso: EPSSetConvergenceTest(), EPSSetTolerances()
739: @*/
740: PetscErrorCode EPSSetConvergenceTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
741: {

746:   if (eps->convergeddestroy) {
747:     (*eps->convergeddestroy)(eps->convergedctx);
748:   }
749:   eps->converged        = func;
750:   eps->convergeddestroy = destroy;
751:   eps->convergedctx     = ctx;
752:   if (func == EPSConvergedRelative) eps->conv = EPS_CONV_REL;
753:   else if (func == EPSConvergedNorm) eps->conv = EPS_CONV_NORM;
754:   else if (func == EPSConvergedAbsolute) eps->conv = EPS_CONV_ABS;
755:   else eps->conv = EPS_CONV_USER;
756:   return(0);
757: }

761: /*@
762:    EPSSetConvergenceTest - Specifies how to compute the error estimate
763:    used in the convergence test.

765:    Logically Collective on EPS

767:    Input Parameters:
768: +  eps  - eigensolver context obtained from EPSCreate()
769: -  conv - the type of convergence test

771:    Options Database Keys:
772: +  -eps_conv_abs  - Sets the absolute convergence test
773: .  -eps_conv_rel  - Sets the convergence test relative to the eigenvalue
774: .  -eps_conv_norm - Sets the convergence test relative to the matrix norms
775: -  -eps_conv_user - Selects the user-defined convergence test

777:    Note:
778:    The parameter 'conv' can have one of these values
779: +     EPS_CONV_ABS  - absolute error ||r||
780: .     EPS_CONV_REL  - error relative to the eigenvalue l, ||r||/|l|
781: .     EPS_CONV_NORM - error relative to the matrix norms, ||r||/(||A||+|l|*||B||)
782: -     EPS_CONV_USER - function set by EPSSetConvergenceTestFunction()

784:    Level: intermediate

786: .seealso: EPSGetConvergenceTest(), EPSSetConvergenceTestFunction(), EPSSetStoppingTest(), EPSConv
787: @*/
788: PetscErrorCode EPSSetConvergenceTest(EPS eps,EPSConv conv)
789: {
793:   switch (conv) {
794:     case EPS_CONV_ABS:  eps->converged = EPSConvergedAbsolute; break;
795:     case EPS_CONV_REL:  eps->converged = EPSConvergedRelative; break;
796:     case EPS_CONV_NORM: eps->converged = EPSConvergedNorm; break;
797:     case EPS_CONV_USER: break;
798:     default:
799:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value");
800:   }
801:   eps->conv = conv;
802:   return(0);
803: }

807: /*@
808:    EPSGetConvergenceTest - Gets the method used to compute the error estimate
809:    used in the convergence test.

811:    Not Collective

813:    Input Parameters:
814: .  eps   - eigensolver context obtained from EPSCreate()

816:    Output Parameters:
817: .  conv  - the type of convergence test

819:    Level: intermediate

821: .seealso: EPSSetConvergenceTest(), EPSConv
822: @*/
823: PetscErrorCode EPSGetConvergenceTest(EPS eps,EPSConv *conv)
824: {
828:   *conv = eps->conv;
829:   return(0);
830: }

834: /*@C
835:    EPSSetStoppingTestFunction - Sets a function to decide when to stop the outer
836:    iteration of the eigensolver.

838:    Logically Collective on EPS

840:    Input Parameters:
841: +  eps     - eigensolver context obtained from EPSCreate()
842: .  func    - pointer to the stopping test function
843: .  ctx     - context for private data for the stopping routine (may be null)
844: -  destroy - a routine for destroying the context (may be null)

846:    Calling Sequence of func:
847: $   func(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)

849: +   eps    - eigensolver context obtained from EPSCreate()
850: .   its    - current number of iterations
851: .   max_it - maximum number of iterations
852: .   nconv  - number of currently converged eigenpairs
853: .   nev    - number of requested eigenpairs
854: .   reason - (output) result of the stopping test
855: -   ctx    - optional context, as set by EPSSetStoppingTestFunction()

857:    Note:
858:    Normal usage is to first call the default routine EPSStoppingBasic() and then
859:    set reason to EPS_CONVERGED_USER if some user-defined conditions have been
860:    met. To let the eigensolver continue iterating, the result must be left as
861:    EPS_CONVERGED_ITERATING.

863:    Level: advanced

865: .seealso: EPSSetStoppingTest(), EPSStoppingBasic()
866: @*/
867: PetscErrorCode EPSSetStoppingTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
868: {

873:   if (eps->stoppingdestroy) {
874:     (*eps->stoppingdestroy)(eps->stoppingctx);
875:   }
876:   eps->stopping        = func;
877:   eps->stoppingdestroy = destroy;
878:   eps->stoppingctx     = ctx;
879:   if (func == EPSStoppingBasic) eps->stop = EPS_STOP_BASIC;
880:   else eps->stop = EPS_STOP_USER;
881:   return(0);
882: }

886: /*@
887:    EPSSetStoppingTest - Specifies how to decide the termination of the outer
888:    loop of the eigensolver.

890:    Logically Collective on EPS

892:    Input Parameters:
893: +  eps  - eigensolver context obtained from EPSCreate()
894: -  stop - the type of stopping test

896:    Options Database Keys:
897: +  -eps_stop_basic - Sets the default stopping test
898: -  -eps_stop_user  - Selects the user-defined stopping test

900:    Note:
901:    The parameter 'stop' can have one of these values
902: +     EPS_STOP_BASIC - default stopping test
903: -     EPS_STOP_USER  - function set by EPSSetStoppingTestFunction()

905:    Level: advanced

907: .seealso: EPSGetStoppingTest(), EPSSetStoppingTestFunction(), EPSSetConvergenceTest(), EPSStop
908: @*/
909: PetscErrorCode EPSSetStoppingTest(EPS eps,EPSStop stop)
910: {
914:   switch (stop) {
915:     case EPS_STOP_BASIC: eps->stopping = EPSStoppingBasic; break;
916:     case EPS_STOP_USER:  break;
917:     default:
918:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value");
919:   }
920:   eps->stop = stop;
921:   return(0);
922: }

926: /*@
927:    EPSGetStoppingTest - Gets the method used to decide the termination of the outer
928:    loop of the eigensolver.

930:    Not Collective

932:    Input Parameters:
933: .  eps   - eigensolver context obtained from EPSCreate()

935:    Output Parameters:
936: .  stop  - the type of stopping test

938:    Level: advanced

940: .seealso: EPSSetStoppingTest(), EPSStop
941: @*/
942: PetscErrorCode EPSGetStoppingTest(EPS eps,EPSStop *stop)
943: {
947:   *stop = eps->stop;
948:   return(0);
949: }

953: /*@
954:    EPSSetProblemType - Specifies the type of the eigenvalue problem.

956:    Logically Collective on EPS

958:    Input Parameters:
959: +  eps      - the eigensolver context
960: -  type     - a known type of eigenvalue problem

962:    Options Database Keys:
963: +  -eps_hermitian - Hermitian eigenvalue problem
964: .  -eps_gen_hermitian - generalized Hermitian eigenvalue problem
965: .  -eps_non_hermitian - non-Hermitian eigenvalue problem
966: .  -eps_gen_non_hermitian - generalized non-Hermitian eigenvalue problem
967: -  -eps_pos_gen_non_hermitian - generalized non-Hermitian eigenvalue problem
968:    with positive semi-definite B

970:    Notes:
971:    Allowed values for the problem type are: Hermitian (EPS_HEP), non-Hermitian
972:    (EPS_NHEP), generalized Hermitian (EPS_GHEP), generalized non-Hermitian
973:    (EPS_GNHEP), generalized non-Hermitian with positive semi-definite B
974:    (EPS_PGNHEP), and generalized Hermitian-indefinite (EPS_GHIEP).

976:    This function must be used to instruct SLEPc to exploit symmetry. If no
977:    problem type is specified, by default a non-Hermitian problem is assumed
978:    (either standard or generalized). If the user knows that the problem is
979:    Hermitian (i.e. A=A^H) or generalized Hermitian (i.e. A=A^H, B=B^H, and
980:    B positive definite) then it is recommended to set the problem type so
981:    that eigensolver can exploit these properties.

983:    Level: intermediate

985: .seealso: EPSSetOperators(), EPSSetType(), EPSGetProblemType(), EPSProblemType
986: @*/
987: PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type)
988: {
992:   if (type == eps->problem_type) return(0);
993:   switch (type) {
994:     case EPS_HEP:
995:       eps->isgeneralized = PETSC_FALSE;
996:       eps->ishermitian = PETSC_TRUE;
997:       eps->ispositive = PETSC_FALSE;
998:       break;
999:     case EPS_NHEP:
1000:       eps->isgeneralized = PETSC_FALSE;
1001:       eps->ishermitian = PETSC_FALSE;
1002:       eps->ispositive = PETSC_FALSE;
1003:       break;
1004:     case EPS_GHEP:
1005:       eps->isgeneralized = PETSC_TRUE;
1006:       eps->ishermitian = PETSC_TRUE;
1007:       eps->ispositive = PETSC_TRUE;
1008:       break;
1009:     case EPS_GNHEP:
1010:       eps->isgeneralized = PETSC_TRUE;
1011:       eps->ishermitian = PETSC_FALSE;
1012:       eps->ispositive = PETSC_FALSE;
1013:       break;
1014:     case EPS_PGNHEP:
1015:       eps->isgeneralized = PETSC_TRUE;
1016:       eps->ishermitian = PETSC_FALSE;
1017:       eps->ispositive = PETSC_TRUE;
1018:       break;
1019:     case EPS_GHIEP:
1020:       eps->isgeneralized = PETSC_TRUE;
1021:       eps->ishermitian = PETSC_TRUE;
1022:       eps->ispositive = PETSC_FALSE;
1023:       break;
1024:     default:
1025:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type");
1026:   }
1027:   eps->problem_type = type;
1028:   eps->state = EPS_STATE_INITIAL;
1029:   return(0);
1030: }

1034: /*@
1035:    EPSGetProblemType - Gets the problem type from the EPS object.

1037:    Not Collective

1039:    Input Parameter:
1040: .  eps - the eigensolver context

1042:    Output Parameter:
1043: .  type - name of EPS problem type

1045:    Level: intermediate

1047: .seealso: EPSSetProblemType(), EPSProblemType
1048: @*/
1049: PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type)
1050: {
1054:   *type = eps->problem_type;
1055:   return(0);
1056: }

1060: /*@
1061:    EPSSetExtraction - Specifies the type of extraction technique to be employed
1062:    by the eigensolver.

1064:    Logically Collective on EPS

1066:    Input Parameters:
1067: +  eps  - the eigensolver context
1068: -  extr - a known type of extraction

1070:    Options Database Keys:
1071: +  -eps_ritz - Rayleigh-Ritz extraction
1072: .  -eps_harmonic - harmonic Ritz extraction
1073: .  -eps_harmonic_relative - harmonic Ritz extraction relative to the eigenvalue
1074: .  -eps_harmonic_right - harmonic Ritz extraction for rightmost eigenvalues
1075: .  -eps_harmonic_largest - harmonic Ritz extraction for largest magnitude
1076:    (without target)
1077: .  -eps_refined - refined Ritz extraction
1078: -  -eps_refined_harmonic - refined harmonic Ritz extraction

1080:    Notes:
1081:    Not all eigensolvers support all types of extraction. See the SLEPc
1082:    Users Manual for details.

1084:    By default, a standard Rayleigh-Ritz extraction is used. Other extractions
1085:    may be useful when computing interior eigenvalues.

1087:    Harmonic-type extractions are used in combination with a 'target'.

1089:    Level: advanced

1091: .seealso: EPSSetTarget(), EPSGetExtraction(), EPSExtraction
1092: @*/
1093: PetscErrorCode EPSSetExtraction(EPS eps,EPSExtraction extr)
1094: {
1098:   eps->extraction = extr;
1099:   return(0);
1100: }

1104: /*@
1105:    EPSGetExtraction - Gets the extraction type used by the EPS object.

1107:    Not Collective

1109:    Input Parameter:
1110: .  eps - the eigensolver context

1112:    Output Parameter:
1113: .  extr - name of extraction type

1115:    Level: advanced

1117: .seealso: EPSSetExtraction(), EPSExtraction
1118: @*/
1119: PetscErrorCode EPSGetExtraction(EPS eps,EPSExtraction *extr)
1120: {
1124:   *extr = eps->extraction;
1125:   return(0);
1126: }

1130: /*@
1131:    EPSSetBalance - Specifies the balancing technique to be employed by the
1132:    eigensolver, and some parameters associated to it.

1134:    Logically Collective on EPS

1136:    Input Parameters:
1137: +  eps    - the eigensolver context
1138: .  bal    - the balancing method, one of EPS_BALANCE_NONE, EPS_BALANCE_ONESIDE,
1139:             EPS_BALANCE_TWOSIDE, or EPS_BALANCE_USER
1140: .  its    - number of iterations of the balancing algorithm
1141: -  cutoff - cutoff value

1143:    Options Database Keys:
1144: +  -eps_balance <method> - the balancing method, where <method> is one of
1145:                            'none', 'oneside', 'twoside', or 'user'
1146: .  -eps_balance_its <its> - number of iterations
1147: -  -eps_balance_cutoff <cutoff> - cutoff value

1149:    Notes:
1150:    When balancing is enabled, the solver works implicitly with matrix DAD^-1,
1151:    where D is an appropriate diagonal matrix. This improves the accuracy of
1152:    the computed results in some cases. See the SLEPc Users Manual for details.

1154:    Balancing makes sense only for non-Hermitian problems when the required
1155:    precision is high (i.e. a small tolerance such as 1e-15).

1157:    By default, balancing is disabled. The two-sided method is much more
1158:    effective than the one-sided counterpart, but it requires the system
1159:    matrices to have the MatMultTranspose operation defined.

1161:    The parameter 'its' is the number of iterations performed by the method. The
1162:    cutoff value is used only in the two-side variant. Use PETSC_DEFAULT to assign
1163:    a reasonably good value.

1165:    User-defined balancing is allowed provided that the corresponding matrix
1166:    is set via STSetBalanceMatrix.

1168:    Level: intermediate

1170: .seealso: EPSGetBalance(), EPSBalance, STSetBalanceMatrix()
1171: @*/
1172: PetscErrorCode EPSSetBalance(EPS eps,EPSBalance bal,PetscInt its,PetscReal cutoff)
1173: {
1179:   switch (bal) {
1180:     case EPS_BALANCE_NONE:
1181:     case EPS_BALANCE_ONESIDE:
1182:     case EPS_BALANCE_TWOSIDE:
1183:     case EPS_BALANCE_USER:
1184:       eps->balance = bal;
1185:       break;
1186:     default:
1187:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid value of argument 'bal'");
1188:   }
1189:   if (its==PETSC_DECIDE || its==PETSC_DEFAULT) eps->balance_its = 5;
1190:   else {
1191:     if (its <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be > 0");
1192:     eps->balance_its = its;
1193:   }
1194:   if (cutoff==PETSC_DECIDE || cutoff==PETSC_DEFAULT) eps->balance_cutoff = 1e-8;
1195:   else {
1196:     if (cutoff <= 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of cutoff. Must be > 0");
1197:     eps->balance_cutoff = cutoff;
1198:   }
1199:   return(0);
1200: }

1204: /*@
1205:    EPSGetBalance - Gets the balancing type used by the EPS object, and the
1206:    associated parameters.

1208:    Not Collective

1210:    Input Parameter:
1211: .  eps - the eigensolver context

1213:    Output Parameters:
1214: +  bal    - the balancing method
1215: .  its    - number of iterations of the balancing algorithm
1216: -  cutoff - cutoff value

1218:    Level: intermediate

1220:    Note:
1221:    The user can specify NULL for any parameter that is not needed.

1223: .seealso: EPSSetBalance(), EPSBalance
1224: @*/
1225: PetscErrorCode EPSGetBalance(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff)
1226: {
1229:   if (bal)    *bal = eps->balance;
1230:   if (its)    *its = eps->balance_its;
1231:   if (cutoff) *cutoff = eps->balance_cutoff;
1232:   return(0);
1233: }

1237: /*@
1238:    EPSSetTrueResidual - Specifies if the solver must compute the true residual
1239:    explicitly or not.

1241:    Logically Collective on EPS

1243:    Input Parameters:
1244: +  eps     - the eigensolver context
1245: -  trueres - whether true residuals are required or not

1247:    Options Database Keys:
1248: .  -eps_true_residual <boolean> - Sets/resets the boolean flag 'trueres'

1250:    Notes:
1251:    If the user sets trueres=PETSC_TRUE then the solver explicitly computes
1252:    the true residual for each eigenpair approximation, and uses it for
1253:    convergence testing. Computing the residual is usually an expensive
1254:    operation. Some solvers (e.g., Krylov solvers) can avoid this computation
1255:    by using a cheap estimate of the residual norm, but this may sometimes
1256:    give inaccurate results (especially if a spectral transform is being
1257:    used). On the contrary, preconditioned eigensolvers (e.g., Davidson solvers)
1258:    do rely on computing the true residual, so this option is irrelevant for them.

1260:    Level: advanced

1262: .seealso: EPSGetTrueResidual()
1263: @*/
1264: PetscErrorCode EPSSetTrueResidual(EPS eps,PetscBool trueres)
1265: {
1269:   eps->trueres = trueres;
1270:   return(0);
1271: }

1275: /*@
1276:    EPSGetTrueResidual - Returns the flag indicating whether true
1277:    residuals must be computed explicitly or not.

1279:    Not Collective

1281:    Input Parameter:
1282: .  eps - the eigensolver context

1284:    Output Parameter:
1285: .  trueres - the returned flag

1287:    Level: advanced

1289: .seealso: EPSSetTrueResidual()
1290: @*/
1291: PetscErrorCode EPSGetTrueResidual(EPS eps,PetscBool *trueres)
1292: {
1296:   *trueres = eps->trueres;
1297:   return(0);
1298: }

1302: /*@
1303:    EPSSetTrackAll - Specifies if the solver must compute the residual norm of all
1304:    approximate eigenpairs or not.

1306:    Logically Collective on EPS

1308:    Input Parameters:
1309: +  eps      - the eigensolver context
1310: -  trackall - whether to compute all residuals or not

1312:    Notes:
1313:    If the user sets trackall=PETSC_TRUE then the solver computes (or estimates)
1314:    the residual norm for each eigenpair approximation. Computing the residual is
1315:    usually an expensive operation and solvers commonly compute only the residual
1316:    associated to the first unconverged eigenpair.

1318:    The options '-eps_monitor_all' and '-eps_monitor_lg_all' automatically
1319:    activate this option.

1321:    Level: developer

1323: .seealso: EPSGetTrackAll()
1324: @*/
1325: PetscErrorCode EPSSetTrackAll(EPS eps,PetscBool trackall)
1326: {
1330:   eps->trackall = trackall;
1331:   return(0);
1332: }

1336: /*@
1337:    EPSGetTrackAll - Returns the flag indicating whether all residual norms must
1338:    be computed or not.

1340:    Not Collective

1342:    Input Parameter:
1343: .  eps - the eigensolver context

1345:    Output Parameter:
1346: .  trackall - the returned flag

1348:    Level: developer

1350: .seealso: EPSSetTrackAll()
1351: @*/
1352: PetscErrorCode EPSGetTrackAll(EPS eps,PetscBool *trackall)
1353: {
1357:   *trackall = eps->trackall;
1358:   return(0);
1359: }

1363: /*@
1364:    EPSSetPurify - Deactivate eigenvector purification (which is activated by default).

1366:    Logically Collective on EPS

1368:    Input Parameters:
1369: +  eps    - the eigensolver context
1370: -  purify - whether purification is required or not

1372:    Options Database Keys:
1373: .  -eps_purify <boolean> - Sets/resets the boolean flag 'purify'

1375:    Notes:
1376:    By default, eigenvectors of generalized symmetric eigenproblems are purified
1377:    in order to purge directions in the nullspace of matrix B. If the user knows
1378:    that B is non-singular, then purification can be safely deactivated and some
1379:    computational cost is avoided (this is particularly important in interval computations).

1381:    Level: intermediate

1383: .seealso: EPSGetPurify(), EPSSetInterval()
1384: @*/
1385: PetscErrorCode EPSSetPurify(EPS eps,PetscBool purify)
1386: {
1390:   eps->purify = purify;
1391:   return(0);
1392: }

1396: /*@
1397:    EPSGetPurify - Returns the flag indicating whether purification is activated
1398:    or not.

1400:    Not Collective

1402:    Input Parameter:
1403: .  eps - the eigensolver context

1405:    Output Parameter:
1406: .  purify - the returned flag

1408:    Level: intermediate

1410: .seealso: EPSSetPurify()
1411: @*/
1412: PetscErrorCode EPSGetPurify(EPS eps,PetscBool *purify)
1413: {
1417:   *purify = eps->purify;
1418:   return(0);
1419: }

1423: /*@C
1424:    EPSSetOptionsPrefix - Sets the prefix used for searching for all
1425:    EPS options in the database.

1427:    Logically Collective on EPS

1429:    Input Parameters:
1430: +  eps - the eigensolver context
1431: -  prefix - the prefix string to prepend to all EPS option requests

1433:    Notes:
1434:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1435:    The first character of all runtime options is AUTOMATICALLY the
1436:    hyphen.

1438:    For example, to distinguish between the runtime options for two
1439:    different EPS contexts, one could call
1440: .vb
1441:       EPSSetOptionsPrefix(eps1,"eig1_")
1442:       EPSSetOptionsPrefix(eps2,"eig2_")
1443: .ve

1445:    Level: advanced

1447: .seealso: EPSAppendOptionsPrefix(), EPSGetOptionsPrefix()
1448: @*/
1449: PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix)
1450: {

1455:   if (!eps->st) { EPSGetST(eps,&eps->st); }
1456:   STSetOptionsPrefix(eps->st,prefix);
1457:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
1458:   BVSetOptionsPrefix(eps->V,prefix);
1459:   if (!eps->ds) { EPSGetDS(eps,&eps->ds); }
1460:   DSSetOptionsPrefix(eps->ds,prefix);
1461:   if (!eps->rg) { EPSGetRG(eps,&eps->rg); }
1462:   RGSetOptionsPrefix(eps->rg,prefix);
1463:   PetscObjectSetOptionsPrefix((PetscObject)eps,prefix);
1464:   return(0);
1465: }

1469: /*@C
1470:    EPSAppendOptionsPrefix - Appends to the prefix used for searching for all
1471:    EPS options in the database.

1473:    Logically Collective on EPS

1475:    Input Parameters:
1476: +  eps - the eigensolver context
1477: -  prefix - the prefix string to prepend to all EPS option requests

1479:    Notes:
1480:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1481:    The first character of all runtime options is AUTOMATICALLY the hyphen.

1483:    Level: advanced

1485: .seealso: EPSSetOptionsPrefix(), EPSGetOptionsPrefix()
1486: @*/
1487: PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix)
1488: {

1493:   if (!eps->st) { EPSGetST(eps,&eps->st); }
1494:   STAppendOptionsPrefix(eps->st,prefix);
1495:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
1496:   BVSetOptionsPrefix(eps->V,prefix);
1497:   if (!eps->ds) { EPSGetDS(eps,&eps->ds); }
1498:   DSSetOptionsPrefix(eps->ds,prefix);
1499:   if (!eps->rg) { EPSGetRG(eps,&eps->rg); }
1500:   RGSetOptionsPrefix(eps->rg,prefix);
1501:   PetscObjectAppendOptionsPrefix((PetscObject)eps,prefix);
1502:   return(0);
1503: }

1507: /*@C
1508:    EPSGetOptionsPrefix - Gets the prefix used for searching for all
1509:    EPS options in the database.

1511:    Not Collective

1513:    Input Parameters:
1514: .  eps - the eigensolver context

1516:    Output Parameters:
1517: .  prefix - pointer to the prefix string used is returned

1519:    Note:
1520:    On the Fortran side, the user should pass in a string 'prefix' of
1521:    sufficient length to hold the prefix.

1523:    Level: advanced

1525: .seealso: EPSSetOptionsPrefix(), EPSAppendOptionsPrefix()
1526: @*/
1527: PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[])
1528: {

1534:   PetscObjectGetOptionsPrefix((PetscObject)eps,prefix);
1535:   return(0);
1536: }

slepc-3.7.4/src/eps/interface/makefile.html0000644000175000017500000000500113107004621020140 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = epsmon.c epsbasic.c epsview.c epsdefault.c epsregis.c epsopts.c epssetup.c epssolve.c dlregiseps.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/interface/epsregis.c0000644000175000017500000000733213107004621017473 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ PETSC_EXTERN PetscErrorCode EPSCreate_Power(EPS); PETSC_EXTERN PetscErrorCode EPSCreate_Subspace(EPS); PETSC_EXTERN PetscErrorCode EPSCreate_Arnoldi(EPS); PETSC_EXTERN PetscErrorCode EPSCreate_Lanczos(EPS); PETSC_EXTERN PetscErrorCode EPSCreate_KrylovSchur(EPS); #if defined(SLEPC_HAVE_ARPACK) PETSC_EXTERN PetscErrorCode EPSCreate_ARPACK(EPS); #endif PETSC_EXTERN PetscErrorCode EPSCreate_LAPACK(EPS); #if defined(SLEPC_HAVE_BLZPACK) PETSC_EXTERN PetscErrorCode EPSCreate_BLZPACK(EPS); #endif #if defined(SLEPC_HAVE_TRLAN) PETSC_EXTERN PetscErrorCode EPSCreate_TRLAN(EPS); #endif #if defined(SLEPC_HAVE_BLOPEX) PETSC_EXTERN PetscErrorCode EPSCreate_BLOPEX(EPS); #endif #if defined(SLEPC_HAVE_PRIMME) PETSC_EXTERN PetscErrorCode EPSCreate_PRIMME(EPS eps); #endif #if defined(SLEPC_HAVE_FEAST) PETSC_EXTERN PetscErrorCode EPSCreate_FEAST(EPS); #endif PETSC_EXTERN PetscErrorCode EPSCreate_GD(EPS eps); PETSC_EXTERN PetscErrorCode EPSCreate_JD(EPS eps); PETSC_EXTERN PetscErrorCode EPSCreate_RQCG(EPS eps); PETSC_EXTERN PetscErrorCode EPSCreate_LOBPCG(EPS eps); PETSC_EXTERN PetscErrorCode EPSCreate_CISS(EPS eps); #undef __FUNCT__ #define __FUNCT__ "EPSRegisterAll" /*@C EPSRegisterAll - Registers all the eigenvalue solvers in the EPS package. Not Collective Level: advanced .seealso: EPSRegister() @*/ PetscErrorCode EPSRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (EPSRegisterAllCalled) PetscFunctionReturn(0); EPSRegisterAllCalled = PETSC_TRUE; ierr = EPSRegister(EPSKRYLOVSCHUR,EPSCreate_KrylovSchur);CHKERRQ(ierr); ierr = EPSRegister(EPSPOWER,EPSCreate_Power);CHKERRQ(ierr); ierr = EPSRegister(EPSSUBSPACE,EPSCreate_Subspace);CHKERRQ(ierr); ierr = EPSRegister(EPSARNOLDI,EPSCreate_Arnoldi);CHKERRQ(ierr); ierr = EPSRegister(EPSLANCZOS,EPSCreate_Lanczos);CHKERRQ(ierr); ierr = EPSRegister(EPSGD,EPSCreate_GD);CHKERRQ(ierr); ierr = EPSRegister(EPSJD,EPSCreate_JD);CHKERRQ(ierr); ierr = EPSRegister(EPSRQCG,EPSCreate_RQCG);CHKERRQ(ierr); ierr = EPSRegister(EPSLOBPCG,EPSCreate_LOBPCG);CHKERRQ(ierr); ierr = EPSRegister(EPSCISS,EPSCreate_CISS);CHKERRQ(ierr); ierr = EPSRegister(EPSLAPACK,EPSCreate_LAPACK);CHKERRQ(ierr); #if defined(SLEPC_HAVE_ARPACK) ierr = EPSRegister(EPSARPACK,EPSCreate_ARPACK);CHKERRQ(ierr); #endif #if defined(SLEPC_HAVE_BLZPACK) ierr = EPSRegister(EPSBLZPACK,EPSCreate_BLZPACK);CHKERRQ(ierr); #endif #if defined(SLEPC_HAVE_TRLAN) ierr = EPSRegister(EPSTRLAN,EPSCreate_TRLAN);CHKERRQ(ierr); #endif #if defined(SLEPC_HAVE_BLOPEX) ierr = EPSRegister(EPSBLOPEX,EPSCreate_BLOPEX);CHKERRQ(ierr); #endif #if defined(SLEPC_HAVE_PRIMME) ierr = EPSRegister(EPSPRIMME,EPSCreate_PRIMME);CHKERRQ(ierr); #endif #if defined(SLEPC_HAVE_FEAST) ierr = EPSRegister(EPSFEAST,EPSCreate_FEAST);CHKERRQ(ierr); #endif PetscFunctionReturn(0); } slepc-3.7.4/src/eps/interface/epssolve.c.html0000644000175000017500000016600113107004621020454 0ustar jromanjroman
Actual source code: epssolve.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       EPS routines related to the solution process.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>   /*I "slepceps.h" I*/
 25: #include <petscdraw.h>

 29: PetscErrorCode EPSComputeVectors(EPS eps)
 30: {

 34:   EPSCheckSolved(eps,1);
 35:   switch (eps->state) {
 36:   case EPS_STATE_SOLVED:
 37:     if (eps->ops->computevectors) {
 38:       (*eps->ops->computevectors)(eps);
 39:     }
 40:     break;
 41:   default:
 42:     break;
 43:   }
 44:   eps->state = EPS_STATE_EIGENVECTORS;
 45:   return(0);
 46: }

 50: /*@
 51:    EPSSolve - Solves the eigensystem.

 53:    Collective on EPS

 55:    Input Parameter:
 56: .  eps - eigensolver context obtained from EPSCreate()

 58:    Options Database Keys:
 59: +  -eps_view - print information about the solver used
 60: .  -eps_view_mat0 binary - save the first matrix (A) to the default binary viewer
 61: .  -eps_view_mat1 binary - save the second matrix (B) to the default binary viewer
 62: .  -eps_view_vectors binary - save the computed eigenvectors to the default binary viewer
 63: .  -eps_view_values - print computed eigenvalues
 64: .  -eps_converged_reason - print reason for convergence, and number of iterations
 65: .  -eps_error_absolute - print absolute errors of each eigenpair
 66: .  -eps_error_relative - print relative errors of each eigenpair
 67: -  -eps_error_backward - print backward errors of each eigenpair

 69:    Level: beginner

 71: .seealso: EPSCreate(), EPSSetUp(), EPSDestroy(), EPSSetTolerances()
 72: @*/
 73: PetscErrorCode EPSSolve(EPS eps)
 74: {
 76:   PetscInt       i,nmat;
 77:   PetscScalar    dot;
 78:   PetscBool      iscayley;
 79:   STMatMode      matmode;
 80:   Mat            A,B;
 81:   Vec            w,x;

 85:   if (eps->state>=EPS_STATE_SOLVED) return(0);
 86:   PetscLogEventBegin(EPS_Solve,eps,0,0,0);

 88:   /* call setup */
 89:   EPSSetUp(eps);
 90:   eps->nconv = 0;
 91:   eps->its   = 0;
 92:   for (i=0;i<eps->ncv;i++) {
 93:     eps->eigr[i]   = 0.0;
 94:     eps->eigi[i]   = 0.0;
 95:     eps->errest[i] = 0.0;
 96:     eps->perm[i]   = i;
 97:   }
 98:   EPSViewFromOptions(eps,NULL,"-eps_view_pre");

100:   /* call solver */
101:   (*eps->ops->solve)(eps);
102:   eps->state = EPS_STATE_SOLVED;

104:   STGetMatMode(eps->st,&matmode);
105:   if (matmode == ST_MATMODE_INPLACE && eps->ispositive) {
106:     /* Purify eigenvectors before reverting operator */
107:     EPSComputeVectors(eps);
108:   }
109:   STPostSolve(eps->st);

111:   if (!eps->reason) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason");

113:   /* Map eigenvalues back to the original problem, necessary in some
114:   * spectral transformations */
115:   if (eps->ops->backtransform) {
116:     (*eps->ops->backtransform)(eps);
117:   }

119: #if !defined(PETSC_USE_COMPLEX)
120:   /* reorder conjugate eigenvalues (positive imaginary first) */
121:   for (i=0; i<eps->nconv-1; i++) {
122:     if (eps->eigi[i] != 0) {
123:       if (eps->eigi[i] < 0) {
124:         eps->eigi[i] = -eps->eigi[i];
125:         eps->eigi[i+1] = -eps->eigi[i+1];
126:         /* the next correction only works with eigenvectors */
127:         EPSComputeVectors(eps);
128:         BVScaleColumn(eps->V,i+1,-1.0);
129:       }
130:       i++;
131:     }
132:   }
133: #endif

135:   STGetNumMatrices(eps->st,&nmat);
136:   STGetOperators(eps->st,0,&A);
137:   if (nmat>1) { STGetOperators(eps->st,1,&B); }

139:   /* In the case of Cayley transform, eigenvectors need to be B-normalized */
140:   PetscObjectTypeCompare((PetscObject)eps->st,STCAYLEY,&iscayley);
141:   if (iscayley && nmat>1 && eps->ishermitian) {
142:     MatCreateVecs(B,NULL,&w);
143:     EPSComputeVectors(eps);
144:     for (i=0;i<eps->nconv;i++) {
145:       BVGetColumn(eps->V,i,&x);
146:       MatMult(B,x,w);
147:       VecDot(w,x,&dot);
148:       VecScale(x,1.0/PetscSqrtScalar(dot));
149:       BVRestoreColumn(eps->V,i,&x);
150:     }
151:     VecDestroy(&w);
152:   }

154:   /* sort eigenvalues according to eps->which parameter */
155:   SlepcSortEigenvalues(eps->sc,eps->nconv,eps->eigr,eps->eigi,eps->perm);
156:   PetscLogEventEnd(EPS_Solve,eps,0,0,0);

158:   /* various viewers */
159:   EPSViewFromOptions(eps,NULL,"-eps_view");
160:   EPSReasonViewFromOptions(eps);
161:   EPSErrorViewFromOptions(eps);
162:   EPSValuesViewFromOptions(eps);
163:   EPSVectorsViewFromOptions(eps);
164:   MatViewFromOptions(A,(PetscObject)eps,"-eps_view_mat0");
165:   if (nmat>1) { MatViewFromOptions(B,(PetscObject)eps,"-eps_view_mat1"); }

167:   /* Remove deflation and initial subspaces */
168:   if (eps->nds) {
169:     BVSetNumConstraints(eps->V,0);
170:     eps->nds = 0;
171:   }
172:   eps->nini = 0;
173:   return(0);
174: }

178: /*@
179:    EPSGetIterationNumber - Gets the current iteration number. If the
180:    call to EPSSolve() is complete, then it returns the number of iterations
181:    carried out by the solution method.

183:    Not Collective

185:    Input Parameter:
186: .  eps - the eigensolver context

188:    Output Parameter:
189: .  its - number of iterations

191:    Level: intermediate

193:    Note:
194:    During the i-th iteration this call returns i-1. If EPSSolve() is
195:    complete, then parameter "its" contains either the iteration number at
196:    which convergence was successfully reached, or failure was detected.
197:    Call EPSGetConvergedReason() to determine if the solver converged or
198:    failed and why.

200: .seealso: EPSGetConvergedReason(), EPSSetTolerances()
201: @*/
202: PetscErrorCode EPSGetIterationNumber(EPS eps,PetscInt *its)
203: {
207:   *its = eps->its;
208:   return(0);
209: }

213: /*@
214:    EPSGetConverged - Gets the number of converged eigenpairs.

216:    Not Collective

218:    Input Parameter:
219: .  eps - the eigensolver context

221:    Output Parameter:
222: .  nconv - number of converged eigenpairs

224:    Note:
225:    This function should be called after EPSSolve() has finished.

227:    Level: beginner

229: .seealso: EPSSetDimensions(), EPSSolve()
230: @*/
231: PetscErrorCode EPSGetConverged(EPS eps,PetscInt *nconv)
232: {
236:   EPSCheckSolved(eps,1);
237:   *nconv = eps->nconv;
238:   return(0);
239: }

243: /*@
244:    EPSGetConvergedReason - Gets the reason why the EPSSolve() iteration was
245:    stopped.

247:    Not Collective

249:    Input Parameter:
250: .  eps - the eigensolver context

252:    Output Parameter:
253: .  reason - negative value indicates diverged, positive value converged

255:    Notes:

257:    Possible values for reason are
258: +  EPS_CONVERGED_TOL - converged up to tolerance
259: .  EPS_CONVERGED_USER - converged due to a user-defined condition
260: .  EPS_DIVERGED_ITS - required more than max_it iterations to reach convergence
261: .  EPS_DIVERGED_BREAKDOWN - generic breakdown in method
262: -  EPS_DIVERGED_SYMMETRY_LOST - pseudo-Lanczos was not able to keep symmetry

264:    Can only be called after the call to EPSSolve() is complete.

266:    Level: intermediate

268: .seealso: EPSSetTolerances(), EPSSolve(), EPSConvergedReason
269: @*/
270: PetscErrorCode EPSGetConvergedReason(EPS eps,EPSConvergedReason *reason)
271: {
275:   EPSCheckSolved(eps,1);
276:   *reason = eps->reason;
277:   return(0);
278: }

282: /*@
283:    EPSGetInvariantSubspace - Gets an orthonormal basis of the computed invariant
284:    subspace.

286:    Not Collective, but vectors are shared by all processors that share the EPS

288:    Input Parameter:
289: .  eps - the eigensolver context

291:    Output Parameter:
292: .  v - an array of vectors

294:    Notes:
295:    This function should be called after EPSSolve() has finished.

297:    The user should provide in v an array of nconv vectors, where nconv is
298:    the value returned by EPSGetConverged().

300:    The first k vectors returned in v span an invariant subspace associated
301:    with the first k computed eigenvalues (note that this is not true if the
302:    k-th eigenvalue is complex and matrix A is real; in this case the first
303:    k+1 vectors should be used). An invariant subspace X of A satisfies Ax
304:    in X for all x in X (a similar definition applies for generalized
305:    eigenproblems).

307:    Level: intermediate

309: .seealso: EPSGetEigenpair(), EPSGetConverged(), EPSSolve()
310: @*/
311: PetscErrorCode EPSGetInvariantSubspace(EPS eps,Vec *v)
312: {
314:   PetscInt       i;

320:   EPSCheckSolved(eps,1);
321:   if (!eps->ishermitian && eps->state==EPS_STATE_EIGENVECTORS) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"EPSGetInvariantSubspace must be called before EPSGetEigenpair,EPSGetEigenvector or EPSComputeError");
322:   for (i=0;i<eps->nconv;i++) {
323:     BVCopyVec(eps->V,i,v[i]);
324:     if (eps->balance!=EPS_BALANCE_NONE && eps->D) {
325:       VecPointwiseDivide(v[i],v[i],eps->D);
326:       VecNormalize(v[i],NULL);
327:     }
328:   }
329:   return(0);
330: }

334: /*@
335:    EPSGetEigenpair - Gets the i-th solution of the eigenproblem as computed by
336:    EPSSolve(). The solution consists in both the eigenvalue and the eigenvector.

338:    Logically Collective on EPS

340:    Input Parameters:
341: +  eps - eigensolver context
342: -  i   - index of the solution

344:    Output Parameters:
345: +  eigr - real part of eigenvalue
346: .  eigi - imaginary part of eigenvalue
347: .  Vr   - real part of eigenvector
348: -  Vi   - imaginary part of eigenvector

350:    Notes:
351:    It is allowed to pass NULL for Vr and Vi, if the eigenvector is not
352:    required. Otherwise, the caller must provide valid Vec objects, i.e.,
353:    they must be created by the calling program with e.g. MatCreateVecs().

355:    If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is
356:    configured with complex scalars the eigenvalue is stored
357:    directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is
358:    set to zero). In both cases, the user can pass NULL in eigi and Vi.

360:    The index i should be a value between 0 and nconv-1 (see EPSGetConverged()).
361:    Eigenpairs are indexed according to the ordering criterion established
362:    with EPSSetWhichEigenpairs().

364:    The 2-norm of the eigenvector is one unless the problem is generalized
365:    Hermitian. In this case the eigenvector is normalized with respect to the
366:    norm defined by the B matrix.

368:    Level: beginner

370: .seealso: EPSGetEigenvalue(), EPSGetEigenvector(), EPSSolve(),
371:           EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetInvariantSubspace()
372: @*/
373: PetscErrorCode EPSGetEigenpair(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)
374: {

380:   EPSCheckSolved(eps,1);
381:   if (i<0 || i>=eps->nconv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
382:   EPSGetEigenvalue(eps,i,eigr,eigi);
383:   if (Vr || Vi) { EPSGetEigenvector(eps,i,Vr,Vi); }
384:   return(0);
385: }

389: /*@
390:    EPSGetEigenvalue - Gets the i-th eigenvalue as computed by EPSSolve().

392:    Not Collective

394:    Input Parameters:
395: +  eps - eigensolver context
396: -  i   - index of the solution

398:    Output Parameters:
399: +  eigr - real part of eigenvalue
400: -  eigi - imaginary part of eigenvalue

402:    Notes:
403:    If the eigenvalue is real, then eigi is set to zero. If PETSc is
404:    configured with complex scalars the eigenvalue is stored
405:    directly in eigr (eigi is set to zero).

407:    The index i should be a value between 0 and nconv-1 (see EPSGetConverged()).
408:    Eigenpairs are indexed according to the ordering criterion established
409:    with EPSSetWhichEigenpairs().

411:    Level: beginner

413: .seealso: EPSSolve(), EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetEigenpair()
414: @*/
415: PetscErrorCode EPSGetEigenvalue(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi)
416: {
417:   PetscInt k;

421:   EPSCheckSolved(eps,1);
422:   if (i<0 || i>=eps->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
423:   k = eps->perm[i];
424: #if defined(PETSC_USE_COMPLEX)
425:   if (eigr) *eigr = eps->eigr[k];
426:   if (eigi) *eigi = 0;
427: #else
428:   if (eigr) *eigr = eps->eigr[k];
429:   if (eigi) *eigi = eps->eigi[k];
430: #endif
431:   return(0);
432: }

436: /*@
437:    EPSGetEigenvector - Gets the i-th right eigenvector as computed by EPSSolve().

439:    Logically Collective on EPS

441:    Input Parameters:
442: +  eps - eigensolver context
443: -  i   - index of the solution

445:    Output Parameters:
446: +  Vr   - real part of eigenvector
447: -  Vi   - imaginary part of eigenvector

449:    Notes:
450:    The caller must provide valid Vec objects, i.e., they must be created
451:    by the calling program with e.g. MatCreateVecs().

453:    If the corresponding eigenvalue is real, then Vi is set to zero. If PETSc is
454:    configured with complex scalars the eigenvector is stored
455:    directly in Vr (Vi is set to zero). In both cases, the user can pass NULL in Vi.

457:    The index i should be a value between 0 and nconv-1 (see EPSGetConverged()).
458:    Eigenpairs are indexed according to the ordering criterion established
459:    with EPSSetWhichEigenpairs().

461:    The 2-norm of the eigenvector is one unless the problem is generalized
462:    Hermitian. In this case the eigenvector is normalized with respect to the
463:    norm defined by the B matrix.

465:    Level: beginner

467: .seealso: EPSSolve(), EPSGetConverged(), EPSSetWhichEigenpairs(), EPSGetEigenpair()
468: @*/
469: PetscErrorCode EPSGetEigenvector(EPS eps,PetscInt i,Vec Vr,Vec Vi)
470: {
472:   PetscInt       k;

480:   EPSCheckSolved(eps,1);
481:   if (i<0 || i>=eps->nconv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
482:   EPSComputeVectors(eps);
483:   k = eps->perm[i];
484: #if defined(PETSC_USE_COMPLEX)
485:   BVCopyVec(eps->V,k,Vr);
486:   if (Vi) { VecSet(Vi,0.0); }
487: #else
488:   if (eps->eigi[k] > 0) { /* first value of conjugate pair */
489:     BVCopyVec(eps->V,k,Vr);
490:     if (Vi) {
491:       BVCopyVec(eps->V,k+1,Vi);
492:     }
493:   } else if (eps->eigi[k] < 0) { /* second value of conjugate pair */
494:     BVCopyVec(eps->V,k-1,Vr);
495:     if (Vi) {
496:       BVCopyVec(eps->V,k,Vi);
497:       VecScale(Vi,-1.0);
498:     }
499:   } else { /* real eigenvalue */
500:     BVCopyVec(eps->V,k,Vr);
501:     if (Vi) { VecSet(Vi,0.0); }
502:   }
503: #endif
504:   return(0);
505: }

509: /*@
510:    EPSGetErrorEstimate - Returns the error estimate associated to the i-th
511:    computed eigenpair.

513:    Not Collective

515:    Input Parameter:
516: +  eps - eigensolver context
517: -  i   - index of eigenpair

519:    Output Parameter:
520: .  errest - the error estimate

522:    Notes:
523:    This is the error estimate used internally by the eigensolver. The actual
524:    error bound can be computed with EPSComputeError(). See also the users
525:    manual for details.

527:    Level: advanced

529: .seealso: EPSComputeError()
530: @*/
531: PetscErrorCode EPSGetErrorEstimate(EPS eps,PetscInt i,PetscReal *errest)
532: {
536:   EPSCheckSolved(eps,1);
537:   if (i<0 || i>=eps->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
538:   if (errest) *errest = eps->errest[eps->perm[i]];
539:   return(0);
540: }

544: /*
545:    EPSComputeResidualNorm_Private - Computes the norm of the residual vector
546:    associated with an eigenpair.

548:    Input Parameters:
549:      kr,ki - eigenvalue
550:      xr,xi - eigenvector
551:      z     - three work vectors (the second one not referenced in complex scalars)
552: */
553: PetscErrorCode EPSComputeResidualNorm_Private(EPS eps,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm)
554: {
556:   PetscInt       nmat;
557:   Mat            A,B;
558:   Vec            u,w;
559: #if !defined(PETSC_USE_COMPLEX)
560:   Vec            v;
561:   PetscReal      ni,nr;
562: #endif

565:   u = z[0]; w = z[2];
566:   STGetNumMatrices(eps->st,&nmat);
567:   STGetOperators(eps->st,0,&A);
568:   if (nmat>1) { STGetOperators(eps->st,1,&B); }

570: #if !defined(PETSC_USE_COMPLEX)
571:   v = z[1]; 
572:   if (ki == 0 || PetscAbsScalar(ki) < PetscAbsScalar(kr*PETSC_MACHINE_EPSILON)) {
573: #endif
574:     MatMult(A,xr,u);                             /* u=A*x */
575:     if (PetscAbsScalar(kr) > PETSC_MACHINE_EPSILON) {
576:       if (nmat>1) { MatMult(B,xr,w); }
577:       else { VecCopy(xr,w); }                    /* w=B*x */
578:       VecAXPY(u,-kr,w);                          /* u=A*x-k*B*x */
579:     }
580:     VecNorm(u,NORM_2,norm);
581: #if !defined(PETSC_USE_COMPLEX)
582:   } else {
583:     MatMult(A,xr,u);                             /* u=A*xr */
584:     if (SlepcAbsEigenvalue(kr,ki) > PETSC_MACHINE_EPSILON) {
585:       if (nmat>1) { MatMult(B,xr,v); }
586:       else { VecCopy(xr,v); }                    /* v=B*xr */
587:       VecAXPY(u,-kr,v);                          /* u=A*xr-kr*B*xr */
588:       if (nmat>1) { MatMult(B,xi,w); }
589:       else { VecCopy(xi,w); }                    /* w=B*xi */
590:       VecAXPY(u,ki,w);                           /* u=A*xr-kr*B*xr+ki*B*xi */
591:     }
592:     VecNorm(u,NORM_2,&nr);
593:     MatMult(A,xi,u);                             /* u=A*xi */
594:     if (SlepcAbsEigenvalue(kr,ki) > PETSC_MACHINE_EPSILON) {
595:       VecAXPY(u,-kr,w);                          /* u=A*xi-kr*B*xi */
596:       VecAXPY(u,-ki,v);                          /* u=A*xi-kr*B*xi-ki*B*xr */
597:     }
598:     VecNorm(u,NORM_2,&ni);
599:     *norm = SlepcAbsEigenvalue(nr,ni);
600:   }
601: #endif
602:   return(0);
603: }

607: /*@
608:    EPSComputeError - Computes the error (based on the residual norm) associated
609:    with the i-th computed eigenpair.

611:    Collective on EPS

613:    Input Parameter:
614: +  eps  - the eigensolver context
615: .  i    - the solution index
616: -  type - the type of error to compute

618:    Output Parameter:
619: .  error - the error

621:    Notes:
622:    The error can be computed in various ways, all of them based on the residual
623:    norm ||Ax-kBx||_2 where k is the eigenvalue and x is the eigenvector.

625:    Level: beginner

627: .seealso: EPSErrorType, EPSSolve(), EPSGetErrorEstimate()
628: @*/
629: PetscErrorCode EPSComputeError(EPS eps,PetscInt i,EPSErrorType type,PetscReal *error)
630: {
632:   Mat            A,B;
633:   Vec            xr,xi,w[3];
634:   PetscReal      t;
635:   PetscScalar    kr,ki;
636:   PetscBool      flg;

643:   EPSCheckSolved(eps,1);

645:   /* allocate work vectors */
646: #if defined(PETSC_USE_COMPLEX)
647:   EPSSetWorkVecs(eps,3);
648:   xi   = NULL;
649:   w[1] = NULL;
650: #else
651:   EPSSetWorkVecs(eps,5);
652:   xi   = eps->work[3];
653:   w[1] = eps->work[4];
654: #endif
655:   xr   = eps->work[0];
656:   w[0] = eps->work[1];
657:   w[2] = eps->work[2];

659:   /* compute residual norms */
660:   EPSGetEigenpair(eps,i,&kr,&ki,xr,xi);
661:   EPSComputeResidualNorm_Private(eps,kr,ki,xr,xi,w,error);

663:   /* compute error */
664:   switch (type) {
665:     case EPS_ERROR_ABSOLUTE:
666:       break;
667:     case EPS_ERROR_RELATIVE:
668:       *error /= SlepcAbsEigenvalue(kr,ki);
669:       break;
670:     case EPS_ERROR_BACKWARD:
671:       /* initialization of matrix norms */
672:       if (!eps->nrma) {
673:         STGetOperators(eps->st,0,&A);
674:         MatHasOperation(A,MATOP_NORM,&flg);
675:         if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation");
676:         MatNorm(A,NORM_INFINITY,&eps->nrma);
677:       }
678:       if (eps->isgeneralized) {
679:         if (!eps->nrmb) {
680:           STGetOperators(eps->st,1,&B);
681:           MatHasOperation(B,MATOP_NORM,&flg);
682:           if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation");
683:           MatNorm(B,NORM_INFINITY,&eps->nrmb);
684:         }
685:       } else eps->nrmb = 1.0;
686:       t = SlepcAbsEigenvalue(kr,ki);
687:       *error /= eps->nrma+t*eps->nrmb;
688:       break;
689:     default:
690:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type");
691:   }
692:   return(0);
693: }

697: /*
698:    EPSGetStartVector - Generate a suitable vector to be used as the starting vector
699:    for the recurrence that builds the right subspace.

701:    Collective on EPS and Vec

703:    Input Parameters:
704: +  eps - the eigensolver context
705: -  i   - iteration number

707:    Output Parameters:
708: .  breakdown - flag indicating that a breakdown has occurred

710:    Notes:
711:    The start vector is computed from another vector: for the first step (i=0),
712:    the first initial vector is used (see EPSSetInitialSpace()); otherwise a random
713:    vector is created. Then this vector is forced to be in the range of OP (only
714:    for generalized definite problems) and orthonormalized with respect to all
715:    V-vectors up to i-1. The resulting vector is placed in V[i].

717:    The flag breakdown is set to true if either i=0 and the vector belongs to the
718:    deflation space, or i>0 and the vector is linearly dependent with respect
719:    to the V-vectors.
720: */
721: PetscErrorCode EPSGetStartVector(EPS eps,PetscInt i,PetscBool *breakdown)
722: {
724:   PetscReal      norm;
725:   PetscBool      lindep;
726:   Vec            w,z;


732:   /* For the first step, use the first initial vector, otherwise a random one */
733:   if (i>0 || eps->nini==0) {
734:     BVSetRandomColumn(eps->V,i);
735:   }

737:   /* Force the vector to be in the range of OP for definite generalized problems */
738:   if (eps->ispositive || (eps->isgeneralized && eps->ishermitian)) {
739:     BVCreateVec(eps->V,&w);
740:     BVCopyVec(eps->V,i,w);
741:     BVGetColumn(eps->V,i,&z);
742:     STApply(eps->st,w,z);
743:     BVRestoreColumn(eps->V,i,&z);
744:     VecDestroy(&w);
745:   }

747:   /* Orthonormalize the vector with respect to previous vectors */
748:   BVOrthogonalizeColumn(eps->V,i,NULL,&norm,&lindep);
749:   if (breakdown) *breakdown = lindep;
750:   else if (lindep || norm == 0.0) {
751:     if (i==0) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Initial vector is zero or belongs to the deflation space");
752:     else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unable to generate more start vectors");
753:   }
754:   BVScaleColumn(eps->V,i,1.0/norm);
755:   return(0);
756: }

slepc-3.7.4/src/eps/interface/epsmon.c.html0000644000175000017500000010365213107004621020120 0ustar jromanjroman
Actual source code: epsmon.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       EPS routines related to monitors.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>   /*I "slepceps.h" I*/
 25: #include <petscdraw.h>

 29: /*
 30:    Runs the user provided monitor routines, if any.
 31: */
 32: PetscErrorCode EPSMonitor(EPS eps,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)
 33: {
 35:   PetscInt       i,n = eps->numbermonitors;

 38:   for (i=0;i<n;i++) {
 39:     (*eps->monitor[i])(eps,it,nconv,eigr,eigi,errest,nest,eps->monitorcontext[i]);
 40:   }
 41:   return(0);
 42: }

 46: /*@C
 47:    EPSMonitorSet - Sets an ADDITIONAL function to be called at every
 48:    iteration to monitor the error estimates for each requested eigenpair.

 50:    Logically Collective on EPS

 52:    Input Parameters:
 53: +  eps     - eigensolver context obtained from EPSCreate()
 54: .  monitor - pointer to function (if this is NULL, it turns off monitoring)
 55: .  mctx    - [optional] context for private data for the
 56:              monitor routine (use NULL if no context is desired)
 57: -  monitordestroy - [optional] routine that frees monitor context (may be NULL)

 59:    Calling Sequence of monitor:
 60: $   monitor(EPS eps,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx)

 62: +  eps    - eigensolver context obtained from EPSCreate()
 63: .  its    - iteration number
 64: .  nconv  - number of converged eigenpairs
 65: .  eigr   - real part of the eigenvalues
 66: .  eigi   - imaginary part of the eigenvalues
 67: .  errest - relative error estimates for each eigenpair
 68: .  nest   - number of error estimates
 69: -  mctx   - optional monitoring context, as set by EPSMonitorSet()

 71:    Options Database Keys:
 72: +    -eps_monitor        - print only the first error estimate
 73: .    -eps_monitor_all    - print error estimates at each iteration
 74: .    -eps_monitor_conv   - print the eigenvalue approximations only when
 75:       convergence has been reached
 76: .    -eps_monitor_lg     - sets line graph monitor for the first unconverged
 77:       approximate eigenvalue
 78: .    -eps_monitor_lg_all - sets line graph monitor for all unconverged
 79:       approximate eigenvalues
 80: -    -eps_monitor_cancel - cancels all monitors that have been hardwired into
 81:       a code by calls to EPSMonitorSet(), but does not cancel those set via
 82:       the options database.

 84:    Notes:
 85:    Several different monitoring routines may be set by calling
 86:    EPSMonitorSet() multiple times; all will be called in the
 87:    order in which they were set.

 89:    Level: intermediate

 91: .seealso: EPSMonitorFirst(), EPSMonitorAll(), EPSMonitorCancel()
 92: @*/
 93: PetscErrorCode EPSMonitorSet(EPS eps,PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
 94: {
 97:   if (eps->numbermonitors >= MAXEPSMONITORS) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Too many EPS monitors set");
 98:   eps->monitor[eps->numbermonitors]           = monitor;
 99:   eps->monitorcontext[eps->numbermonitors]    = (void*)mctx;
100:   eps->monitordestroy[eps->numbermonitors++]  = monitordestroy;
101:   return(0);
102: }

106: /*@
107:    EPSMonitorCancel - Clears all monitors for an EPS object.

109:    Logically Collective on EPS

111:    Input Parameters:
112: .  eps - eigensolver context obtained from EPSCreate()

114:    Options Database Key:
115: .    -eps_monitor_cancel - Cancels all monitors that have been hardwired
116:       into a code by calls to EPSMonitorSet(),
117:       but does not cancel those set via the options database.

119:    Level: intermediate

121: .seealso: EPSMonitorSet()
122: @*/
123: PetscErrorCode EPSMonitorCancel(EPS eps)
124: {
126:   PetscInt       i;

130:   for (i=0; i<eps->numbermonitors; i++) {
131:     if (eps->monitordestroy[i]) {
132:       (*eps->monitordestroy[i])(&eps->monitorcontext[i]);
133:     }
134:   }
135:   eps->numbermonitors = 0;
136:   return(0);
137: }

141: /*@C
142:    EPSGetMonitorContext - Gets the monitor context, as set by
143:    EPSMonitorSet() for the FIRST monitor only.

145:    Not Collective

147:    Input Parameter:
148: .  eps - eigensolver context obtained from EPSCreate()

150:    Output Parameter:
151: .  ctx - monitor context

153:    Level: intermediate

155: .seealso: EPSMonitorSet()
156: @*/
157: PetscErrorCode EPSGetMonitorContext(EPS eps,void **ctx)
158: {
161:   *ctx = eps->monitorcontext[0];
162:   return(0);
163: }

167: /*@C
168:    EPSMonitorAll - Print the current approximate values and
169:    error estimates at each iteration of the eigensolver.

171:    Collective on EPS

173:    Input Parameters:
174: +  eps    - eigensolver context
175: .  its    - iteration number
176: .  nconv  - number of converged eigenpairs so far
177: .  eigr   - real part of the eigenvalues
178: .  eigi   - imaginary part of the eigenvalues
179: .  errest - error estimates
180: .  nest   - number of error estimates to display
181: -  vf     - viewer and format for monitoring

183:    Level: intermediate

185: .seealso: EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorConverged()
186: @*/
187: PetscErrorCode EPSMonitorAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
188: {
190:   PetscInt       i;
191:   PetscScalar    er,ei;
192:   PetscViewer    viewer;

197:   viewer = vf->viewer;
199:   PetscViewerPushFormat(viewer,vf->format);
200:   PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);
201:   if (its==1 && ((PetscObject)eps)->prefix) {
202:     PetscViewerASCIIPrintf(viewer,"  Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)eps)->prefix);
203:   }
204:   PetscViewerASCIIPrintf(viewer,"%3D EPS nconv=%D Values (Errors)",its,nconv);
205:   PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
206:   for (i=0;i<nest;i++) {
207:     er = eigr[i]; ei = eigi[i];
208:     STBackTransform(eps->st,1,&er,&ei);
209: #if defined(PETSC_USE_COMPLEX)
210:     PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));
211: #else
212:     PetscViewerASCIIPrintf(viewer," %g",(double)er);
213:     if (ei!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei); }
214: #endif
215:     PetscViewerASCIIPrintf(viewer," (%10.8e)",(double)errest[i]);
216:   }
217:   PetscViewerASCIIPrintf(viewer,"\n");
218:   PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
219:   PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);
220:   PetscViewerPopFormat(viewer);
221:   return(0);
222: }

226: /*@C
227:    EPSMonitorFirst - Print the first approximate value and
228:    error estimate at each iteration of the eigensolver.

230:    Collective on EPS

232:    Input Parameters:
233: +  eps    - eigensolver context
234: .  its    - iteration number
235: .  nconv  - number of converged eigenpairs so far
236: .  eigr   - real part of the eigenvalues
237: .  eigi   - imaginary part of the eigenvalues
238: .  errest - error estimates
239: .  nest   - number of error estimates to display
240: -  vf     - viewer and format for monitoring

242:    Level: intermediate

244: .seealso: EPSMonitorSet(), EPSMonitorAll(), EPSMonitorConverged()
245: @*/
246: PetscErrorCode EPSMonitorFirst(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
247: {
249:   PetscScalar    er,ei;
250:   PetscViewer    viewer;

255:   viewer = vf->viewer;
257:   if (its==1 && ((PetscObject)eps)->prefix) {
258:     PetscViewerASCIIPrintf(viewer,"  Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)eps)->prefix);
259:   }
260:   if (nconv<nest) {
261:     PetscViewerPushFormat(viewer,vf->format);
262:     PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);
263:     PetscViewerASCIIPrintf(viewer,"%3D EPS nconv=%D first unconverged value (error)",its,nconv);
264:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
265:     er = eigr[nconv]; ei = eigi[nconv];
266:     STBackTransform(eps->st,1,&er,&ei);
267: #if defined(PETSC_USE_COMPLEX)
268:     PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));
269: #else
270:     PetscViewerASCIIPrintf(viewer," %g",(double)er);
271:     if (ei!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei); }
272: #endif
273:     PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);
274:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
275:     PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);
276:     PetscViewerPopFormat(viewer);
277:   }
278:   return(0);
279: }

283: /*@C
284:    EPSMonitorConverged - Print the approximate values and
285:    error estimates as they converge.

287:    Collective on EPS

289:    Input Parameters:
290: +  eps    - eigensolver context
291: .  its    - iteration number
292: .  nconv  - number of converged eigenpairs so far
293: .  eigr   - real part of the eigenvalues
294: .  eigi   - imaginary part of the eigenvalues
295: .  errest - error estimates
296: .  nest   - number of error estimates to display
297: -  ctx    - monitor context

299:    Level: intermediate

301: .seealso: EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorAll()
302: @*/
303: PetscErrorCode EPSMonitorConverged(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
304: {
306:   PetscInt       i;
307:   PetscScalar    er,ei;
308:   PetscViewer    viewer;

313:   viewer = ctx->viewer;
315:   if (its==1 && ((PetscObject)eps)->prefix) {
316:     PetscViewerASCIIPrintf(viewer,"  Convergence history for %s solve.\n",((PetscObject)eps)->prefix);
317:   }
318:   if (its==1) ctx->oldnconv = 0;
319:   if (ctx->oldnconv!=nconv) {
320:     PetscViewerPushFormat(viewer,ctx->format);
321:     PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);
322:     for (i=ctx->oldnconv;i<nconv;i++) {
323:       PetscViewerASCIIPrintf(viewer,"%3D EPS converged value (error) #%D",its,i);
324:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
325:       er = eigr[i]; ei = eigi[i];
326:       STBackTransform(eps->st,1,&er,&ei);
327: #if defined(PETSC_USE_COMPLEX)
328:       PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));
329: #else
330:       PetscViewerASCIIPrintf(viewer," %g",(double)er);
331:       if (ei!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei); }
332: #endif
333:       PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[i]);
334:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
335:     }
336:     PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);
337:     PetscViewerPopFormat(viewer);
338:     ctx->oldnconv = nconv;
339:   }
340:   return(0);
341: }

345: /*@C
346:    EPSMonitorLGCreate - Creates a line graph context for use with
347:    EPS to monitor convergence.

349:    Collective on MPI_Comm

351:    Input Parameters:
352: +  comm - communicator context
353: .  host - the X display to open, or null for the local machine
354: .  label - the title to put in the title bar
355: .  x, y - the screen coordinates of the upper left coordinate of
356:           the window
357: -  m, n - the screen width and height in pixels

359:    Output Parameter:
360: .  lgctx - the drawing context

362:    Options Database Keys:
363: +  -eps_monitor_lg - Sets line graph monitor for the first residual
364: -  -eps_monitor_lg_all - Sets line graph monitor for all residuals

366:    Notes:
367:    Use PetscDrawLGDestroy() to destroy this line graph.

369:    Level: intermediate

371: .seealso: EPSMonitorSet()
372: @*/
373: PetscErrorCode EPSMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
374: {
375:   PetscDraw      draw;
376:   PetscDrawLG    lg;

380:   PetscDrawCreate(comm,host,label,x,y,m,n,&draw);
381:   PetscDrawSetFromOptions(draw);
382:   PetscDrawLGCreate(draw,1,&lg);
383:   PetscDrawLGSetFromOptions(lg);
384:   PetscDrawDestroy(&draw);
385:   *lgctx = lg;
386:   return(0);
387: }

391: PetscErrorCode EPSMonitorLG(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
392: {
393:   PetscDrawLG    lg = (PetscDrawLG)ctx;
394:   PetscReal      x,y;

399:   if (its==1) {
400:     PetscDrawLGReset(lg);
401:     PetscDrawLGSetDimension(lg,1);
402:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(eps->tol)-2,0.0);
403:   }
404:   x = (PetscReal)its;
405:   if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]);
406:   else y = 0.0;
407:   PetscDrawLGAddPoint(lg,&x,&y);
408:   if (its <= 20 || !(its % 5) || eps->reason) {
409:     PetscDrawLGDraw(lg);
410:     PetscDrawLGSave(lg);
411:   }
412:   return(0);
413: }

417: PetscErrorCode EPSMonitorLGAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
418: {
419:   PetscDrawLG    lg = (PetscDrawLG)ctx;
420:   PetscInt       i,n = PetscMin(eps->nev,255);
421:   PetscReal      *x,*y;

426:   if (its==1) {
427:     PetscDrawLGReset(lg);
428:     PetscDrawLGSetDimension(lg,n);
429:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(eps->tol)-2,0.0);
430:   }
431:   PetscMalloc2(n,&x,n,&y);
432:   for (i=0;i<n;i++) {
433:     x[i] = (PetscReal)its;
434:     if (i < nest && errest[i] > 0.0) y[i] = PetscLog10Real(errest[i]);
435:     else y[i] = 0.0;
436:   }
437:   PetscDrawLGAddPoint(lg,x,y);
438:   if (its <= 20 || !(its % 5) || eps->reason) {
439:     PetscDrawLGDraw(lg);
440:     PetscDrawLGSave(lg);
441:   }
442:   PetscFree2(x,y);
443:   return(0);
444: }

slepc-3.7.4/src/eps/interface/index.html0000644000175000017500000000334613107004621017504 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

epsmon.c
epsbasic.c
epsview.c
epsdefault.c
epsregis.c
epsopts.c
epssetup.c
epssolve.c
dlregiseps.c
makefile
slepc-3.7.4/src/eps/interface/epsregis.c.html0000644000175000017500000002566713107004621020451 0ustar jromanjroman

Actual source code: epsregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/epsimpl.h>  /*I "slepceps.h" I*/

 24: PETSC_EXTERN PetscErrorCode EPSCreate_Power(EPS);
 25: PETSC_EXTERN PetscErrorCode EPSCreate_Subspace(EPS);
 26: PETSC_EXTERN PetscErrorCode EPSCreate_Arnoldi(EPS);
 27: PETSC_EXTERN PetscErrorCode EPSCreate_Lanczos(EPS);
 28: PETSC_EXTERN PetscErrorCode EPSCreate_KrylovSchur(EPS);
 29: #if defined(SLEPC_HAVE_ARPACK)
 30: PETSC_EXTERN PetscErrorCode EPSCreate_ARPACK(EPS);
 31: #endif
 32: PETSC_EXTERN PetscErrorCode EPSCreate_LAPACK(EPS);
 33: #if defined(SLEPC_HAVE_BLZPACK)
 34: PETSC_EXTERN PetscErrorCode EPSCreate_BLZPACK(EPS);
 35: #endif
 36: #if defined(SLEPC_HAVE_TRLAN)
 37: PETSC_EXTERN PetscErrorCode EPSCreate_TRLAN(EPS);
 38: #endif
 39: #if defined(SLEPC_HAVE_BLOPEX)
 40: PETSC_EXTERN PetscErrorCode EPSCreate_BLOPEX(EPS);
 41: #endif
 42: #if defined(SLEPC_HAVE_PRIMME)
 43: PETSC_EXTERN PetscErrorCode EPSCreate_PRIMME(EPS eps);
 44: #endif
 45: #if defined(SLEPC_HAVE_FEAST)
 46: PETSC_EXTERN PetscErrorCode EPSCreate_FEAST(EPS);
 47: #endif
 48: PETSC_EXTERN PetscErrorCode EPSCreate_GD(EPS eps);
 49: PETSC_EXTERN PetscErrorCode EPSCreate_JD(EPS eps);
 50: PETSC_EXTERN PetscErrorCode EPSCreate_RQCG(EPS eps);
 51: PETSC_EXTERN PetscErrorCode EPSCreate_LOBPCG(EPS eps);
 52: PETSC_EXTERN PetscErrorCode EPSCreate_CISS(EPS eps);

 56: /*@C
 57:   EPSRegisterAll - Registers all the eigenvalue solvers in the EPS package.

 59:   Not Collective

 61:   Level: advanced

 63: .seealso:  EPSRegister()
 64: @*/
 65: PetscErrorCode EPSRegisterAll(void)
 66: {

 70:   if (EPSRegisterAllCalled) return(0);
 71:   EPSRegisterAllCalled = PETSC_TRUE;
 72:   EPSRegister(EPSKRYLOVSCHUR,EPSCreate_KrylovSchur);
 73:   EPSRegister(EPSPOWER,EPSCreate_Power);
 74:   EPSRegister(EPSSUBSPACE,EPSCreate_Subspace);
 75:   EPSRegister(EPSARNOLDI,EPSCreate_Arnoldi);
 76:   EPSRegister(EPSLANCZOS,EPSCreate_Lanczos);
 77:   EPSRegister(EPSGD,EPSCreate_GD);
 78:   EPSRegister(EPSJD,EPSCreate_JD);
 79:   EPSRegister(EPSRQCG,EPSCreate_RQCG);
 80:   EPSRegister(EPSLOBPCG,EPSCreate_LOBPCG);
 81:   EPSRegister(EPSCISS,EPSCreate_CISS);
 82:   EPSRegister(EPSLAPACK,EPSCreate_LAPACK);
 83: #if defined(SLEPC_HAVE_ARPACK)
 84:   EPSRegister(EPSARPACK,EPSCreate_ARPACK);
 85: #endif
 86: #if defined(SLEPC_HAVE_BLZPACK)
 87:   EPSRegister(EPSBLZPACK,EPSCreate_BLZPACK);
 88: #endif
 89: #if defined(SLEPC_HAVE_TRLAN)
 90:   EPSRegister(EPSTRLAN,EPSCreate_TRLAN);
 91: #endif
 92: #if defined(SLEPC_HAVE_BLOPEX)
 93:   EPSRegister(EPSBLOPEX,EPSCreate_BLOPEX);
 94: #endif
 95: #if defined(SLEPC_HAVE_PRIMME)
 96:   EPSRegister(EPSPRIMME,EPSCreate_PRIMME);
 97: #endif
 98: #if defined(SLEPC_HAVE_FEAST)
 99:   EPSRegister(EPSFEAST,EPSCreate_FEAST);
100: #endif
101:   return(0);
102: }
slepc-3.7.4/src/eps/interface/epsmon.c0000644000175000017500000003751013107004621017154 0ustar jromanjroman/* EPS routines related to monitors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "EPSMonitor" /* Runs the user provided monitor routines, if any. */ PetscErrorCode EPSMonitor(EPS eps,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest) { PetscErrorCode ierr; PetscInt i,n = eps->numbermonitors; PetscFunctionBegin; for (i=0;imonitor[i])(eps,it,nconv,eigr,eigi,errest,nest,eps->monitorcontext[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorSet" /*@C EPSMonitorSet - Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested eigenpair. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() . monitor - pointer to function (if this is NULL, it turns off monitoring) . mctx - [optional] context for private data for the monitor routine (use NULL if no context is desired) - monitordestroy - [optional] routine that frees monitor context (may be NULL) Calling Sequence of monitor: $ monitor(EPS eps,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx) + eps - eigensolver context obtained from EPSCreate() . its - iteration number . nconv - number of converged eigenpairs . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - relative error estimates for each eigenpair . nest - number of error estimates - mctx - optional monitoring context, as set by EPSMonitorSet() Options Database Keys: + -eps_monitor - print only the first error estimate . -eps_monitor_all - print error estimates at each iteration . -eps_monitor_conv - print the eigenvalue approximations only when convergence has been reached . -eps_monitor_lg - sets line graph monitor for the first unconverged approximate eigenvalue . -eps_monitor_lg_all - sets line graph monitor for all unconverged approximate eigenvalues - -eps_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to EPSMonitorSet(), but does not cancel those set via the options database. Notes: Several different monitoring routines may be set by calling EPSMonitorSet() multiple times; all will be called in the order in which they were set. Level: intermediate .seealso: EPSMonitorFirst(), EPSMonitorAll(), EPSMonitorCancel() @*/ PetscErrorCode EPSMonitorSet(EPS eps,PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**)) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (eps->numbermonitors >= MAXEPSMONITORS) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Too many EPS monitors set"); eps->monitor[eps->numbermonitors] = monitor; eps->monitorcontext[eps->numbermonitors] = (void*)mctx; eps->monitordestroy[eps->numbermonitors++] = monitordestroy; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorCancel" /*@ EPSMonitorCancel - Clears all monitors for an EPS object. Logically Collective on EPS Input Parameters: . eps - eigensolver context obtained from EPSCreate() Options Database Key: . -eps_monitor_cancel - Cancels all monitors that have been hardwired into a code by calls to EPSMonitorSet(), but does not cancel those set via the options database. Level: intermediate .seealso: EPSMonitorSet() @*/ PetscErrorCode EPSMonitorCancel(EPS eps) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); for (i=0; inumbermonitors; i++) { if (eps->monitordestroy[i]) { ierr = (*eps->monitordestroy[i])(&eps->monitorcontext[i]);CHKERRQ(ierr); } } eps->numbermonitors = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetMonitorContext" /*@C EPSGetMonitorContext - Gets the monitor context, as set by EPSMonitorSet() for the FIRST monitor only. Not Collective Input Parameter: . eps - eigensolver context obtained from EPSCreate() Output Parameter: . ctx - monitor context Level: intermediate .seealso: EPSMonitorSet() @*/ PetscErrorCode EPSGetMonitorContext(EPS eps,void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); *ctx = eps->monitorcontext[0]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorAll" /*@C EPSMonitorAll - Print the current approximate values and error estimates at each iteration of the eigensolver. Collective on EPS Input Parameters: + eps - eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorConverged() @*/ PetscErrorCode EPSMonitorAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscInt i; PetscScalar er,ei; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(vf,8); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); ierr = PetscViewerPushFormat(viewer,vf->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); if (its==1 && ((PetscObject)eps)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)eps)->prefix);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"%3D EPS nconv=%D Values (Errors)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;ist,1,&er,&ei);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));CHKERRQ(ierr); #else ierr = PetscViewerASCIIPrintf(viewer," %g",(double)er);CHKERRQ(ierr); if (ei!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei);CHKERRQ(ierr); } #endif ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)",(double)errest[i]);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorFirst" /*@C EPSMonitorFirst - Print the first approximate value and error estimate at each iteration of the eigensolver. Collective on EPS Input Parameters: + eps - eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: EPSMonitorSet(), EPSMonitorAll(), EPSMonitorConverged() @*/ PetscErrorCode EPSMonitorFirst(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscScalar er,ei; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(vf,8); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); if (its==1 && ((PetscObject)eps)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)eps)->prefix);CHKERRQ(ierr); } if (nconvformat);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%3D EPS nconv=%D first unconverged value (error)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); er = eigr[nconv]; ei = eigi[nconv]; ierr = STBackTransform(eps->st,1,&er,&ei);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));CHKERRQ(ierr); #else ierr = PetscViewerASCIIPrintf(viewer," %g",(double)er);CHKERRQ(ierr); if (ei!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei);CHKERRQ(ierr); } #endif ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorConverged" /*@C EPSMonitorConverged - Print the approximate values and error estimates as they converge. Collective on EPS Input Parameters: + eps - eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - ctx - monitor context Level: intermediate .seealso: EPSMonitorSet(), EPSMonitorFirst(), EPSMonitorAll() @*/ PetscErrorCode EPSMonitorConverged(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx) { PetscErrorCode ierr; PetscInt i; PetscScalar er,ei; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(ctx,8); viewer = ctx->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); if (its==1 && ((PetscObject)eps)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Convergence history for %s solve.\n",((PetscObject)eps)->prefix);CHKERRQ(ierr); } if (its==1) ctx->oldnconv = 0; if (ctx->oldnconv!=nconv) { ierr = PetscViewerPushFormat(viewer,ctx->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); for (i=ctx->oldnconv;ist,1,&er,&ei);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));CHKERRQ(ierr); #else ierr = PetscViewerASCIIPrintf(viewer," %g",(double)er);CHKERRQ(ierr); if (ei!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei);CHKERRQ(ierr); } #endif ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[i]);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)eps)->tablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ctx->oldnconv = nconv; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorLGCreate" /*@C EPSMonitorLGCreate - Creates a line graph context for use with EPS to monitor convergence. Collective on MPI_Comm Input Parameters: + comm - communicator context . host - the X display to open, or null for the local machine . label - the title to put in the title bar . x, y - the screen coordinates of the upper left coordinate of the window - m, n - the screen width and height in pixels Output Parameter: . lgctx - the drawing context Options Database Keys: + -eps_monitor_lg - Sets line graph monitor for the first residual - -eps_monitor_lg_all - Sets line graph monitor for all residuals Notes: Use PetscDrawLGDestroy() to destroy this line graph. Level: intermediate .seealso: EPSMonitorSet() @*/ PetscErrorCode EPSMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx) { PetscDraw draw; PetscDrawLG lg; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscDrawCreate(comm,host,label,x,y,m,n,&draw);CHKERRQ(ierr); ierr = PetscDrawSetFromOptions(draw);CHKERRQ(ierr); ierr = PetscDrawLGCreate(draw,1,&lg);CHKERRQ(ierr); ierr = PetscDrawLGSetFromOptions(lg);CHKERRQ(ierr); ierr = PetscDrawDestroy(&draw);CHKERRQ(ierr); *lgctx = lg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorLG" PetscErrorCode EPSMonitorLG(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscReal x,y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,1);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(eps->tol)-2,0.0);CHKERRQ(ierr); } x = (PetscReal)its; if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]); else y = 0.0; ierr = PetscDrawLGAddPoint(lg,&x,&y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || eps->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitorLGAll" PetscErrorCode EPSMonitorLGAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscInt i,n = PetscMin(eps->nev,255); PetscReal *x,*y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,n);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(eps->tol)-2,0.0);CHKERRQ(ierr); } ierr = PetscMalloc2(n,&x,n,&y);CHKERRQ(ierr); for (i=0;i 0.0) y[i] = PetscLog10Real(errest[i]); else y[i] = 0.0; } ierr = PetscDrawLGAddPoint(lg,x,y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || eps->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } ierr = PetscFree2(x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/interface/dlregiseps.c.html0000644000175000017500000003157213107004621020761 0ustar jromanjroman
Actual source code: dlregiseps.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/epsimpl.h>

 24: static PetscBool EPSPackageInitialized = PETSC_FALSE;

 26: const char *EPSBalanceTypes[] = {"NONE","ONESIDE","TWOSIDE","USER","EPSBalance","EPS_BALANCE_",0};
 27: const char *EPSErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","EPSErrorType","EPS_ERROR_",0};
 28: const char *EPSPowerShiftTypes[] = {"CONSTANT","RAYLEIGH","WILKINSON","EPSPowerShiftType","EPS_POWER_SHIFT_",0};
 29: const char *EPSLanczosReorthogTypes[] = {"LOCAL","FULL","SELECTIVE","PERIODIC","PARTIAL","DELAYED","EPSLanczosReorthogType","EPS_LANCZOS_REORTHOG_",0};
 30: const char *EPSPRIMMEMethods[] = {"DYNAMIC","DEFAULT_MIN_TIME","DEFAULT_MIN_MATVECS","ARNOLDI","GD","GD_PLUSK","GD_OLSEN_PLUSK","JD_OLSEN_PLUSK","RQI","JDQR","JDQMR","JDQMR_ETOL","SUBSPACE_ITERATION","LOBPCG_ORTHOBASIS","LOBPCG_ORTHOBASISW","EPSPRIMMEMethod","EPS_PRIMME_",0};
 31: const char *EPSCISSQuadRules[] = {"(not set yet)","TRAPEZOIDAL","CHEBYSHEV","EPSCISSQuadRule","EPS_CISS_QUADRULE_",0};
 32: const char *EPSCISSExtractions[] = {"RITZ","HANKEL","EPSCISSExtraction","EPS_CISS_EXTRACTION_",0};
 33: const char *const EPSConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","EPSConvergedReason","EPS_",0};
 34: const char *const*EPSConvergedReasons = EPSConvergedReasons_Shifted + 4;

 38: /*@C
 39:   EPSFinalizePackage - This function destroys everything in the SLEPc interface
 40:   to the EPS package. It is called from SlepcFinalize().

 42:   Level: developer

 44: .seealso: SlepcFinalize()
 45: @*/
 46: PetscErrorCode EPSFinalizePackage(void)
 47: {

 51:   PetscFunctionListDestroy(&EPSList);
 52:   EPSPackageInitialized = PETSC_FALSE;
 53:   EPSRegisterAllCalled  = PETSC_FALSE;
 54:   return(0);
 55: }

 59: /*@C
 60:   EPSInitializePackage - This function initializes everything in the EPS package.
 61:   It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 62:   on the first call to EPSCreate() when using static libraries.

 64:   Level: developer

 66: .seealso: SlepcInitialize()
 67: @*/
 68: PetscErrorCode EPSInitializePackage()
 69: {
 70:   char           logList[256];
 71:   char           *className;
 72:   PetscBool      opt;

 76:   if (EPSPackageInitialized) return(0);
 77:   EPSPackageInitialized = PETSC_TRUE;
 78:   /* Register Classes */
 79:   PetscClassIdRegister("EPS Solver",&EPS_CLASSID);
 80:   /* Register Constructors */
 81:   EPSRegisterAll();
 82:   /* Register Events */
 83:   PetscLogEventRegister("EPSSetUp",EPS_CLASSID,&EPS_SetUp);
 84:   PetscLogEventRegister("EPSSolve",EPS_CLASSID,&EPS_Solve);
 85:   /* Process info exclusions */
 86:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 87:   if (opt) {
 88:     PetscStrstr(logList,"eps",&className);
 89:     if (className) {
 90:       PetscInfoDeactivateClass(EPS_CLASSID);
 91:     }
 92:   }
 93:   /* Process summary exclusions */
 94:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 95:   if (opt) {
 96:     PetscStrstr(logList,"eps",&className);
 97:     if (className) {
 98:       PetscLogEventDeactivateClass(EPS_CLASSID);
 99:     }
100:   }
101:   PetscRegisterFinalize(EPSFinalizePackage);
102:   return(0);
103: }

105: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

109: /*
110:   PetscDLLibraryRegister - This function is called when the dynamic library
111:   it is in is opened.

113:   This one registers all the EPS methods that are in the basic SLEPc libslepceps
114:   library.
115:  */
116: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepceps()
117: {

121:   EPSInitializePackage();
122:   return(0);
123: }
124: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */

slepc-3.7.4/src/eps/interface/dlregiseps.c0000644000175000017500000001150613107004621020011 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include static PetscBool EPSPackageInitialized = PETSC_FALSE; const char *EPSBalanceTypes[] = {"NONE","ONESIDE","TWOSIDE","USER","EPSBalance","EPS_BALANCE_",0}; const char *EPSErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","EPSErrorType","EPS_ERROR_",0}; const char *EPSPowerShiftTypes[] = {"CONSTANT","RAYLEIGH","WILKINSON","EPSPowerShiftType","EPS_POWER_SHIFT_",0}; const char *EPSLanczosReorthogTypes[] = {"LOCAL","FULL","SELECTIVE","PERIODIC","PARTIAL","DELAYED","EPSLanczosReorthogType","EPS_LANCZOS_REORTHOG_",0}; const char *EPSPRIMMEMethods[] = {"DYNAMIC","DEFAULT_MIN_TIME","DEFAULT_MIN_MATVECS","ARNOLDI","GD","GD_PLUSK","GD_OLSEN_PLUSK","JD_OLSEN_PLUSK","RQI","JDQR","JDQMR","JDQMR_ETOL","SUBSPACE_ITERATION","LOBPCG_ORTHOBASIS","LOBPCG_ORTHOBASISW","EPSPRIMMEMethod","EPS_PRIMME_",0}; const char *EPSCISSQuadRules[] = {"(not set yet)","TRAPEZOIDAL","CHEBYSHEV","EPSCISSQuadRule","EPS_CISS_QUADRULE_",0}; const char *EPSCISSExtractions[] = {"RITZ","HANKEL","EPSCISSExtraction","EPS_CISS_EXTRACTION_",0}; const char *const EPSConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","EPSConvergedReason","EPS_",0}; const char *const*EPSConvergedReasons = EPSConvergedReasons_Shifted + 4; #undef __FUNCT__ #define __FUNCT__ "EPSFinalizePackage" /*@C EPSFinalizePackage - This function destroys everything in the SLEPc interface to the EPS package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode EPSFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&EPSList);CHKERRQ(ierr); EPSPackageInitialized = PETSC_FALSE; EPSRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSInitializePackage" /*@C EPSInitializePackage - This function initializes everything in the EPS package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to EPSCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode EPSInitializePackage() { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (EPSPackageInitialized) PetscFunctionReturn(0); EPSPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("EPS Solver",&EPS_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = EPSRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("EPSSetUp",EPS_CLASSID,&EPS_SetUp);CHKERRQ(ierr); ierr = PetscLogEventRegister("EPSSolve",EPS_CLASSID,&EPS_Solve);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"eps",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(EPS_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"eps",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(EPS_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(EPSFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) #undef __FUNCT__ #define __FUNCT__ "PetscDLLibraryRegister_slepceps" /* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the EPS methods that are in the basic SLEPc libslepceps library. */ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepceps() { PetscErrorCode ierr; PetscFunctionBegin; ierr = EPSInitializePackage();CHKERRQ(ierr); PetscFunctionReturn(0); } #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ slepc-3.7.4/src/eps/interface/ftn-auto/0000755000175000017500000000000013107004621017236 5ustar jromanjromanslepc-3.7.4/src/eps/interface/ftn-auto/makefile0000644000175000017500000000046613107004621020744 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = epsdefaultf.c epssetupf.c epsviewf.c epsoptsf.c epsmonf.c epsbasicf.c epssolvef.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/interface/ftn-auto/epsdefaultf.c0000644000175000017500000000207613107004621021711 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* epsdefault.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetworkvecs_ EPSSETWORKVECS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetworkvecs_ epssetworkvecs #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epssetworkvecs_(EPS eps,PetscInt *nw, int *__ierr ){ *__ierr = EPSSetWorkVecs( (EPS)PetscToPointer((eps) ),*nw); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/interface/ftn-auto/epssetupf.c0000644000175000017500000000560313107004621021424 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* epssetup.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetup_ EPSSETUP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetup_ epssetup #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetoperators_ EPSSETOPERATORS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetoperators_ epssetoperators #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetoperators_ EPSGETOPERATORS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetoperators_ epsgetoperators #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetdeflationspace_ EPSSETDEFLATIONSPACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetdeflationspace_ epssetdeflationspace #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetinitialspace_ EPSSETINITIALSPACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetinitialspace_ epssetinitialspace #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsallocatesolution_ EPSALLOCATESOLUTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsallocatesolution_ epsallocatesolution #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epssetup_(EPS eps, int *__ierr ){ *__ierr = EPSSetUp( (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL epssetoperators_(EPS eps,Mat A,Mat B, int *__ierr ){ *__ierr = EPSSetOperators( (EPS)PetscToPointer((eps) ), (Mat)PetscToPointer((A) ), (Mat)PetscToPointer((B) )); } PETSC_EXTERN void PETSC_STDCALL epsgetoperators_(EPS eps,Mat *A,Mat *B, int *__ierr ){ *__ierr = EPSGetOperators( (EPS)PetscToPointer((eps) ),A,B); } PETSC_EXTERN void PETSC_STDCALL epssetdeflationspace_(EPS eps,PetscInt *n,Vec *v, int *__ierr ){ *__ierr = EPSSetDeflationSpace( (EPS)PetscToPointer((eps) ),*n,v); } PETSC_EXTERN void PETSC_STDCALL epssetinitialspace_(EPS eps,PetscInt *n,Vec *is, int *__ierr ){ *__ierr = EPSSetInitialSpace( (EPS)PetscToPointer((eps) ),*n,is); } PETSC_EXTERN void PETSC_STDCALL epsallocatesolution_(EPS eps,PetscInt *extra, int *__ierr ){ *__ierr = EPSAllocateSolution( (EPS)PetscToPointer((eps) ),*extra); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/interface/ftn-auto/epsviewf.c0000644000175000017500000000437313107004621021241 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* epsview.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsreasonviewfromoptions_ EPSREASONVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsreasonviewfromoptions_ epsreasonviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epserrorviewfromoptions_ EPSERRORVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epserrorviewfromoptions_ epserrorviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsvaluesviewfromoptions_ EPSVALUESVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsvaluesviewfromoptions_ epsvaluesviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsvectorsviewfromoptions_ EPSVECTORSVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsvectorsviewfromoptions_ epsvectorsviewfromoptions #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsreasonviewfromoptions_(EPS eps, int *__ierr ){ *__ierr = EPSReasonViewFromOptions( (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL epserrorviewfromoptions_(EPS eps, int *__ierr ){ *__ierr = EPSErrorViewFromOptions( (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL epsvaluesviewfromoptions_(EPS eps, int *__ierr ){ *__ierr = EPSValuesViewFromOptions( (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL epsvectorsviewfromoptions_(EPS eps, int *__ierr ){ *__ierr = EPSVectorsViewFromOptions( (EPS)PetscToPointer((eps) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/interface/ftn-auto/epsoptsf.c0000644000175000017500000002231613107004621021251 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* epsopts.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetfromoptions_ EPSSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetfromoptions_ epssetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgettolerances_ EPSGETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgettolerances_ epsgettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssettolerances_ EPSSETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssettolerances_ epssettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetdimensions_ EPSGETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetdimensions_ epsgetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetdimensions_ EPSSETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetdimensions_ epssetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetwhicheigenpairs_ EPSSETWHICHEIGENPAIRS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetwhicheigenpairs_ epssetwhicheigenpairs #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetwhicheigenpairs_ EPSGETWHICHEIGENPAIRS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetwhicheigenpairs_ epsgetwhicheigenpairs #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetconvergencetest_ EPSSETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetconvergencetest_ epssetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetconvergencetest_ EPSGETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetconvergencetest_ epsgetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetstoppingtest_ EPSSETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetstoppingtest_ epssetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetstoppingtest_ EPSGETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetstoppingtest_ epsgetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetproblemtype_ EPSSETPROBLEMTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetproblemtype_ epssetproblemtype #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetproblemtype_ EPSGETPROBLEMTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetproblemtype_ epsgetproblemtype #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetextraction_ EPSSETEXTRACTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetextraction_ epssetextraction #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetextraction_ EPSGETEXTRACTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetextraction_ epsgetextraction #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetbalance_ EPSSETBALANCE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetbalance_ epssetbalance #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetbalance_ EPSGETBALANCE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetbalance_ epsgetbalance #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssettrueresidual_ EPSSETTRUERESIDUAL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssettrueresidual_ epssettrueresidual #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgettrueresidual_ EPSGETTRUERESIDUAL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgettrueresidual_ epsgettrueresidual #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssettrackall_ EPSSETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssettrackall_ epssettrackall #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgettrackall_ EPSGETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgettrackall_ epsgettrackall #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetpurify_ EPSSETPURIFY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetpurify_ epssetpurify #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetpurify_ EPSGETPURIFY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetpurify_ epsgetpurify #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epssetfromoptions_(EPS eps, int *__ierr ){ *__ierr = EPSSetFromOptions( (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL epsgettolerances_(EPS eps,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = EPSGetTolerances( (EPS)PetscToPointer((eps) ),tol,maxits); } PETSC_EXTERN void PETSC_STDCALL epssettolerances_(EPS eps,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = EPSSetTolerances( (EPS)PetscToPointer((eps) ),*tol,*maxits); } PETSC_EXTERN void PETSC_STDCALL epsgetdimensions_(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = EPSGetDimensions( (EPS)PetscToPointer((eps) ),nev,ncv,mpd); } PETSC_EXTERN void PETSC_STDCALL epssetdimensions_(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = EPSSetDimensions( (EPS)PetscToPointer((eps) ),*nev,*ncv,*mpd); } PETSC_EXTERN void PETSC_STDCALL epssetwhicheigenpairs_(EPS eps,EPSWhich *which, int *__ierr ){ *__ierr = EPSSetWhichEigenpairs( (EPS)PetscToPointer((eps) ),*which); } PETSC_EXTERN void PETSC_STDCALL epsgetwhicheigenpairs_(EPS eps,EPSWhich *which, int *__ierr ){ *__ierr = EPSGetWhichEigenpairs( (EPS)PetscToPointer((eps) ),which); } PETSC_EXTERN void PETSC_STDCALL epssetconvergencetest_(EPS eps,EPSConv *conv, int *__ierr ){ *__ierr = EPSSetConvergenceTest( (EPS)PetscToPointer((eps) ),*conv); } PETSC_EXTERN void PETSC_STDCALL epsgetconvergencetest_(EPS eps,EPSConv *conv, int *__ierr ){ *__ierr = EPSGetConvergenceTest( (EPS)PetscToPointer((eps) ),conv); } PETSC_EXTERN void PETSC_STDCALL epssetstoppingtest_(EPS eps,EPSStop *stop, int *__ierr ){ *__ierr = EPSSetStoppingTest( (EPS)PetscToPointer((eps) ),*stop); } PETSC_EXTERN void PETSC_STDCALL epsgetstoppingtest_(EPS eps,EPSStop *stop, int *__ierr ){ *__ierr = EPSGetStoppingTest( (EPS)PetscToPointer((eps) ),stop); } PETSC_EXTERN void PETSC_STDCALL epssetproblemtype_(EPS eps,EPSProblemType *type, int *__ierr ){ *__ierr = EPSSetProblemType( (EPS)PetscToPointer((eps) ),*type); } PETSC_EXTERN void PETSC_STDCALL epsgetproblemtype_(EPS eps,EPSProblemType *type, int *__ierr ){ *__ierr = EPSGetProblemType( (EPS)PetscToPointer((eps) ),type); } PETSC_EXTERN void PETSC_STDCALL epssetextraction_(EPS eps,EPSExtraction *extr, int *__ierr ){ *__ierr = EPSSetExtraction( (EPS)PetscToPointer((eps) ),*extr); } PETSC_EXTERN void PETSC_STDCALL epsgetextraction_(EPS eps,EPSExtraction *extr, int *__ierr ){ *__ierr = EPSGetExtraction( (EPS)PetscToPointer((eps) ),extr); } PETSC_EXTERN void PETSC_STDCALL epssetbalance_(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff, int *__ierr ){ *__ierr = EPSSetBalance( (EPS)PetscToPointer((eps) ),*bal,*its,*cutoff); } PETSC_EXTERN void PETSC_STDCALL epsgetbalance_(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff, int *__ierr ){ *__ierr = EPSGetBalance( (EPS)PetscToPointer((eps) ),bal,its,cutoff); } PETSC_EXTERN void PETSC_STDCALL epssettrueresidual_(EPS eps,PetscBool *trueres, int *__ierr ){ *__ierr = EPSSetTrueResidual( (EPS)PetscToPointer((eps) ),*trueres); } PETSC_EXTERN void PETSC_STDCALL epsgettrueresidual_(EPS eps,PetscBool *trueres, int *__ierr ){ *__ierr = EPSGetTrueResidual( (EPS)PetscToPointer((eps) ),trueres); } PETSC_EXTERN void PETSC_STDCALL epssettrackall_(EPS eps,PetscBool *trackall, int *__ierr ){ *__ierr = EPSSetTrackAll( (EPS)PetscToPointer((eps) ),*trackall); } PETSC_EXTERN void PETSC_STDCALL epsgettrackall_(EPS eps,PetscBool *trackall, int *__ierr ){ *__ierr = EPSGetTrackAll( (EPS)PetscToPointer((eps) ),trackall); } PETSC_EXTERN void PETSC_STDCALL epssetpurify_(EPS eps,PetscBool *purify, int *__ierr ){ *__ierr = EPSSetPurify( (EPS)PetscToPointer((eps) ),*purify); } PETSC_EXTERN void PETSC_STDCALL epsgetpurify_(EPS eps,PetscBool *purify, int *__ierr ){ *__ierr = EPSGetPurify( (EPS)PetscToPointer((eps) ),purify); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/interface/ftn-auto/epsmonf.c0000644000175000017500000000206513107004621021054 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* epsmon.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsmonitorcancel_ EPSMONITORCANCEL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsmonitorcancel_ epsmonitorcancel #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsmonitorcancel_(EPS eps, int *__ierr ){ *__ierr = EPSMonitorCancel( (EPS)PetscToPointer((eps) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/interface/ftn-auto/epsbasicf.c0000644000175000017500000001500213107004621021337 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* epsbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscreate_ EPSCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscreate_ epscreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsreset_ EPSRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsreset_ epsreset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsdestroy_ EPSDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsdestroy_ epsdestroy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssettarget_ EPSSETTARGET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssettarget_ epssettarget #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgettarget_ EPSGETTARGET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgettarget_ epsgettarget #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetinterval_ EPSSETINTERVAL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetinterval_ epssetinterval #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetinterval_ EPSGETINTERVAL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetinterval_ epsgetinterval #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetst_ EPSSETST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetst_ epssetst #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetst_ EPSGETST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetst_ epsgetst #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetbv_ EPSSETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetbv_ epssetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetbv_ EPSGETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetbv_ epsgetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetrg_ EPSSETRG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetrg_ epssetrg #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetrg_ EPSGETRG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetrg_ epsgetrg #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssetds_ EPSSETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssetds_ epssetds #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetds_ EPSGETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetds_ epsgetds #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsisgeneralized_ EPSISGENERALIZED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsisgeneralized_ epsisgeneralized #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsishermitian_ EPSISHERMITIAN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsishermitian_ epsishermitian #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsispositive_ EPSISPOSITIVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsispositive_ epsispositive #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epscreate_(MPI_Fint * comm,EPS *outeps, int *__ierr ){ *__ierr = EPSCreate( MPI_Comm_f2c(*(comm)),outeps); } PETSC_EXTERN void PETSC_STDCALL epsreset_(EPS eps, int *__ierr ){ *__ierr = EPSReset( (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL epsdestroy_(EPS *eps, int *__ierr ){ *__ierr = EPSDestroy(eps); } PETSC_EXTERN void PETSC_STDCALL epssettarget_(EPS eps,PetscScalar *target, int *__ierr ){ *__ierr = EPSSetTarget( (EPS)PetscToPointer((eps) ),*target); } PETSC_EXTERN void PETSC_STDCALL epsgettarget_(EPS eps,PetscScalar* target, int *__ierr ){ *__ierr = EPSGetTarget( (EPS)PetscToPointer((eps) ),target); } PETSC_EXTERN void PETSC_STDCALL epssetinterval_(EPS eps,PetscReal *inta,PetscReal *intb, int *__ierr ){ *__ierr = EPSSetInterval( (EPS)PetscToPointer((eps) ),*inta,*intb); } PETSC_EXTERN void PETSC_STDCALL epsgetinterval_(EPS eps,PetscReal* inta,PetscReal* intb, int *__ierr ){ *__ierr = EPSGetInterval( (EPS)PetscToPointer((eps) ),inta,intb); } PETSC_EXTERN void PETSC_STDCALL epssetst_(EPS eps,ST st, int *__ierr ){ *__ierr = EPSSetST( (EPS)PetscToPointer((eps) ), (ST)PetscToPointer((st) )); } PETSC_EXTERN void PETSC_STDCALL epsgetst_(EPS eps,ST *st, int *__ierr ){ *__ierr = EPSGetST( (EPS)PetscToPointer((eps) ),st); } PETSC_EXTERN void PETSC_STDCALL epssetbv_(EPS eps,BV V, int *__ierr ){ *__ierr = EPSSetBV( (EPS)PetscToPointer((eps) ), (BV)PetscToPointer((V) )); } PETSC_EXTERN void PETSC_STDCALL epsgetbv_(EPS eps,BV *V, int *__ierr ){ *__ierr = EPSGetBV( (EPS)PetscToPointer((eps) ),V); } PETSC_EXTERN void PETSC_STDCALL epssetrg_(EPS eps,RG rg, int *__ierr ){ *__ierr = EPSSetRG( (EPS)PetscToPointer((eps) ), (RG)PetscToPointer((rg) )); } PETSC_EXTERN void PETSC_STDCALL epsgetrg_(EPS eps,RG *rg, int *__ierr ){ *__ierr = EPSGetRG( (EPS)PetscToPointer((eps) ),rg); } PETSC_EXTERN void PETSC_STDCALL epssetds_(EPS eps,DS ds, int *__ierr ){ *__ierr = EPSSetDS( (EPS)PetscToPointer((eps) ), (DS)PetscToPointer((ds) )); } PETSC_EXTERN void PETSC_STDCALL epsgetds_(EPS eps,DS *ds, int *__ierr ){ *__ierr = EPSGetDS( (EPS)PetscToPointer((eps) ),ds); } PETSC_EXTERN void PETSC_STDCALL epsisgeneralized_(EPS eps,PetscBool* is, int *__ierr ){ *__ierr = EPSIsGeneralized( (EPS)PetscToPointer((eps) ),is); } PETSC_EXTERN void PETSC_STDCALL epsishermitian_(EPS eps,PetscBool* is, int *__ierr ){ *__ierr = EPSIsHermitian( (EPS)PetscToPointer((eps) ),is); } PETSC_EXTERN void PETSC_STDCALL epsispositive_(EPS eps,PetscBool* is, int *__ierr ){ *__ierr = EPSIsPositive( (EPS)PetscToPointer((eps) ),is); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/interface/ftn-auto/epssolvef.c0000644000175000017500000001112513107004621021410 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* epssolve.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epssolve_ EPSSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epssolve_ epssolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetiterationnumber_ EPSGETITERATIONNUMBER #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetiterationnumber_ epsgetiterationnumber #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetconverged_ EPSGETCONVERGED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetconverged_ epsgetconverged #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetconvergedreason_ EPSGETCONVERGEDREASON #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetconvergedreason_ epsgetconvergedreason #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgetinvariantsubspace_ EPSGETINVARIANTSUBSPACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgetinvariantsubspace_ epsgetinvariantsubspace #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgeteigenpair_ EPSGETEIGENPAIR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgeteigenpair_ epsgeteigenpair #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgeteigenvalue_ EPSGETEIGENVALUE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgeteigenvalue_ epsgeteigenvalue #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgeteigenvector_ EPSGETEIGENVECTOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgeteigenvector_ epsgeteigenvector #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgeterrorestimate_ EPSGETERRORESTIMATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgeterrorestimate_ epsgeterrorestimate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscomputeerror_ EPSCOMPUTEERROR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscomputeerror_ epscomputeerror #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epssolve_(EPS eps, int *__ierr ){ *__ierr = EPSSolve( (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL epsgetiterationnumber_(EPS eps,PetscInt *its, int *__ierr ){ *__ierr = EPSGetIterationNumber( (EPS)PetscToPointer((eps) ),its); } PETSC_EXTERN void PETSC_STDCALL epsgetconverged_(EPS eps,PetscInt *nconv, int *__ierr ){ *__ierr = EPSGetConverged( (EPS)PetscToPointer((eps) ),nconv); } PETSC_EXTERN void PETSC_STDCALL epsgetconvergedreason_(EPS eps,EPSConvergedReason *reason, int *__ierr ){ *__ierr = EPSGetConvergedReason( (EPS)PetscToPointer((eps) ),reason); } PETSC_EXTERN void PETSC_STDCALL epsgetinvariantsubspace_(EPS eps,Vec *v, int *__ierr ){ *__ierr = EPSGetInvariantSubspace( (EPS)PetscToPointer((eps) ),v); } PETSC_EXTERN void PETSC_STDCALL epsgeteigenpair_(EPS eps,PetscInt *i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi, int *__ierr ){ *__ierr = EPSGetEigenpair( (EPS)PetscToPointer((eps) ),*i,eigr,eigi, (Vec)PetscToPointer((Vr) ), (Vec)PetscToPointer((Vi) )); } PETSC_EXTERN void PETSC_STDCALL epsgeteigenvalue_(EPS eps,PetscInt *i,PetscScalar *eigr,PetscScalar *eigi, int *__ierr ){ *__ierr = EPSGetEigenvalue( (EPS)PetscToPointer((eps) ),*i,eigr,eigi); } PETSC_EXTERN void PETSC_STDCALL epsgeteigenvector_(EPS eps,PetscInt *i,Vec Vr,Vec Vi, int *__ierr ){ *__ierr = EPSGetEigenvector( (EPS)PetscToPointer((eps) ),*i, (Vec)PetscToPointer((Vr) ), (Vec)PetscToPointer((Vi) )); } PETSC_EXTERN void PETSC_STDCALL epsgeterrorestimate_(EPS eps,PetscInt *i,PetscReal *errest, int *__ierr ){ *__ierr = EPSGetErrorEstimate( (EPS)PetscToPointer((eps) ),*i,errest); } PETSC_EXTERN void PETSC_STDCALL epscomputeerror_(EPS eps,PetscInt *i,EPSErrorType *type,PetscReal *error, int *__ierr ){ *__ierr = EPSComputeError( (EPS)PetscToPointer((eps) ),*i,*type,error); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/interface/epsdefault.c.html0000644000175000017500000010727713107004621020762 0ustar jromanjroman
Actual source code: epsdefault.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      This file contains some simple default routines for common operations.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>   /*I "slepceps.h" I*/
 25: #include <slepcvec.h>

 29: PetscErrorCode EPSBackTransform_Default(EPS eps)
 30: {

 34:   STBackTransform(eps->st,eps->nconv,eps->eigr,eps->eigi);
 35:   return(0);
 36: }

 40: /*
 41:   EPSComputeVectors_Hermitian - Copies the Lanczos vectors as eigenvectors
 42:   using purification for generalized eigenproblems.
 43:  */
 44: PetscErrorCode EPSComputeVectors_Hermitian(EPS eps)
 45: {
 47:   PetscInt       i;
 48:   PetscReal      norm;
 49:   Vec            w,z;

 52:   if (eps->isgeneralized && eps->purify) {
 53:     /* Purify eigenvectors */
 54:     BVCreateVec(eps->V,&w);
 55:     for (i=0;i<eps->nconv;i++) {
 56:       BVCopyVec(eps->V,i,w);
 57:       BVGetColumn(eps->V,i,&z);
 58:       STApply(eps->st,w,z);
 59:       BVRestoreColumn(eps->V,i,&z);
 60:       BVNormColumn(eps->V,i,NORM_2,&norm);
 61:       BVScaleColumn(eps->V,i,1.0/norm);
 62:     }
 63:     VecDestroy(&w);
 64:   }
 65:   return(0);
 66: }

 70: /*
 71:   EPSComputeVectors_Indefinite - similar to the Schur version but
 72:   for indefinite problems
 73:  */
 74: PetscErrorCode EPSComputeVectors_Indefinite(EPS eps)
 75: {
 77:   PetscInt       n,i;
 78:   Mat            X;
 79:   Vec            v,z;
 80: #if !defined(PETSC_USE_COMPLEX)
 81:   Vec            v1;
 82:   PetscScalar    tmp;
 83:   PetscReal      norm,normi;
 84: #endif

 87:   DSGetDimensions(eps->ds,&n,NULL,NULL,NULL,NULL);
 88:   DSVectors(eps->ds,DS_MAT_X,NULL,NULL);
 89:   DSGetMat(eps->ds,DS_MAT_X,&X);
 90:   BVSetActiveColumns(eps->V,0,n);
 91:   BVMultInPlace(eps->V,X,0,n);
 92:   MatDestroy(&X);

 94:   /* purification */
 95:   if (eps->purify) {
 96:     BVCreateVec(eps->V,&v);
 97:     for (i=0;i<eps->nconv;i++) {
 98:       BVCopyVec(eps->V,i,v);
 99:       BVGetColumn(eps->V,i,&z);
100:       STApply(eps->st,v,z);
101:       BVRestoreColumn(eps->V,i,&z);
102:     }
103:     VecDestroy(&v);
104:   }

106:   /* normalization */
107:   for (i=0;i<n;i++) {
108: #if !defined(PETSC_USE_COMPLEX)
109:     if (eps->eigi[i] != 0.0) {
110:       BVGetColumn(eps->V,i,&v);
111:       BVGetColumn(eps->V,i+1,&v1);
112:       VecNorm(v,NORM_2,&norm);
113:       VecNorm(v1,NORM_2,&normi);
114:       tmp = 1.0 / SlepcAbsEigenvalue(norm,normi);
115:       VecScale(v,tmp);
116:       VecScale(v1,tmp);
117:       BVRestoreColumn(eps->V,i,&v);
118:       BVRestoreColumn(eps->V,i+1,&v1);
119:       i++;
120:     } else
121: #endif
122:     {
123:       BVGetColumn(eps->V,i,&v);
124:       VecNormalize(v,NULL);
125:       BVRestoreColumn(eps->V,i,&v);
126:     }
127:   }
128:   return(0);
129: }

133: /*
134:   EPSComputeVectors_Schur - Compute eigenvectors from the vectors
135:   provided by the eigensolver. This version is intended for solvers
136:   that provide Schur vectors. Given the partial Schur decomposition
137:   OP*V=V*T, the following steps are performed:
138:       1) compute eigenvectors of T: T*Z=Z*D
139:       2) compute eigenvectors of OP: X=V*Z
140:  */
141: PetscErrorCode EPSComputeVectors_Schur(EPS eps)
142: {
144:   PetscInt       n,i;
145:   Mat            Z;
146:   Vec            w,z,v;
147: #if !defined(PETSC_USE_COMPLEX)
148:   Vec            v1;
149:   PetscScalar    tmp;
150:   PetscReal      norm,normi;
151: #endif

154:   if (eps->ishermitian) {
155:     if (eps->isgeneralized && !eps->ispositive) {
156:        EPSComputeVectors_Indefinite(eps);
157:     } else {
158:       EPSComputeVectors_Hermitian(eps);
159:     }
160:     return(0);
161:   }
162:   DSGetDimensions(eps->ds,&n,NULL,NULL,NULL,NULL);

164:   /* right eigenvectors */
165:   DSVectors(eps->ds,DS_MAT_X,NULL,NULL);

167:   /* V = V * Z */
168:   DSGetMat(eps->ds,DS_MAT_X,&Z);
169:   BVSetActiveColumns(eps->V,0,n);
170:   BVMultInPlace(eps->V,Z,0,n);
171:   MatDestroy(&Z);

173:   /* Purify eigenvectors */
174:   if (eps->ispositive && eps->purify) {
175:     BVCreateVec(eps->V,&w);
176:     for (i=0;i<n;i++) {
177:       BVCopyVec(eps->V,i,w);
178:       BVGetColumn(eps->V,i,&z);
179:       STApply(eps->st,w,z);
180:       BVRestoreColumn(eps->V,i,&z);
181:     }
182:     VecDestroy(&w);
183:   }

185:   /* Fix eigenvectors if balancing was used */
186:   if (eps->balance!=EPS_BALANCE_NONE && eps->D) {
187:     for (i=0;i<n;i++) {
188:       BVGetColumn(eps->V,i,&z);
189:       VecPointwiseDivide(z,z,eps->D);
190:       BVRestoreColumn(eps->V,i,&z);
191:     }
192:   }

194:   /* normalize eigenvectors (when using purification or balancing) */
195:   if ((eps->ispositive && eps->purify) || (eps->balance!=EPS_BALANCE_NONE && eps->D)) {
196:     for (i=0;i<n;i++) {
197: #if !defined(PETSC_USE_COMPLEX)
198:       if (eps->eigi[i] != 0.0) {
199:         BVGetColumn(eps->V,i,&v);
200:         BVGetColumn(eps->V,i+1,&v1);
201:         VecNorm(v,NORM_2,&norm);
202:         VecNorm(v1,NORM_2,&normi);
203:         tmp = 1.0 / SlepcAbsEigenvalue(norm,normi);
204:         VecScale(v,tmp);
205:         VecScale(v1,tmp);
206:         BVRestoreColumn(eps->V,i,&v);
207:         BVRestoreColumn(eps->V,i+1,&v1);
208:         i++;
209:       } else
210: #endif
211:       {
212:         BVGetColumn(eps->V,i,&v);
213:         VecNormalize(v,NULL);
214:         BVRestoreColumn(eps->V,i,&v);
215:       }
216:     }
217:   }
218:   return(0);
219: }

223: /*@
224:    EPSSetWorkVecs - Sets a number of work vectors into an EPS object.

226:    Collective on EPS

228:    Input Parameters:
229: +  eps - eigensolver context
230: -  nw  - number of work vectors to allocate

232:    Developers Note:
233:    This is PETSC_EXTERN because it may be required by user plugin EPS
234:    implementations.

236:    Level: developer
237: @*/
238: PetscErrorCode EPSSetWorkVecs(EPS eps,PetscInt nw)
239: {
241:   Vec            t;

244:   if (eps->nwork < nw) {
245:     VecDestroyVecs(eps->nwork,&eps->work);
246:     eps->nwork = nw;
247:     BVGetColumn(eps->V,0,&t);
248:     VecDuplicateVecs(t,nw,&eps->work);
249:     BVRestoreColumn(eps->V,0,&t);
250:     PetscLogObjectParents(eps,nw,eps->work);
251:   }
252:   return(0);
253: }

257: /*
258:   EPSSetWhichEigenpairs_Default - Sets the default value for which,
259:   depending on the ST.
260:  */
261: PetscErrorCode EPSSetWhichEigenpairs_Default(EPS eps)
262: {
263:   PetscBool      target;

267:   PetscObjectTypeCompareAny((PetscObject)eps->st,&target,STSINVERT,STCAYLEY,"");
268:   if (target) eps->which = EPS_TARGET_MAGNITUDE;
269:   else eps->which = EPS_LARGEST_MAGNITUDE;
270:   return(0);
271: }

275: /*
276:   EPSConvergedRelative - Checks convergence relative to the eigenvalue.
277: */
278: PetscErrorCode EPSConvergedRelative(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
279: {
280:   PetscReal w;

283:   w = SlepcAbsEigenvalue(eigr,eigi);
284:   *errest = res/w;
285:   return(0);
286: }

290: /*
291:   EPSConvergedAbsolute - Checks convergence absolutely.
292: */
293: PetscErrorCode EPSConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
294: {
296:   *errest = res;
297:   return(0);
298: }

302: /*
303:   EPSConvergedNorm - Checks convergence relative to the eigenvalue and
304:   the matrix norms.
305: */
306: PetscErrorCode EPSConvergedNorm(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
307: {
308:   PetscReal w;

311:   w = SlepcAbsEigenvalue(eigr,eigi);
312:   *errest = res / (eps->nrma + w*eps->nrmb);
313:   return(0);
314: }

318: /*@C
319:    EPSStoppingBasic - Default routine to determine whether the outer eigensolver
320:    iteration must be stopped.

322:    Collective on EPS

324:    Input Parameters:
325: +  eps    - eigensolver context obtained from EPSCreate()
326: .  its    - current number of iterations
327: .  max_it - maximum number of iterations
328: .  nconv  - number of currently converged eigenpairs
329: .  nev    - number of requested eigenpairs
330: -  ctx    - context (not used here)

332:    Output Parameter:
333: .  reason - result of the stopping test

335:    Notes:
336:    A positive value of reason indicates that the iteration has finished successfully
337:    (converged), and a negative value indicates an error condition (diverged). If
338:    the iteration needs to be continued, reason must be set to EPS_CONVERGED_ITERATING
339:    (zero).

341:    EPSStoppingBasic() will stop if all requested eigenvalues are converged, or if
342:    the maximum number of iterations has been reached.

344:    Use EPSSetStoppingTest() to provide your own test instead of using this one.

346:    Level: advanced

348: .seealso: EPSSetStoppingTest(), EPSConvergedReason, EPSGetConvergedReason()
349: @*/
350: PetscErrorCode EPSStoppingBasic(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)
351: {

355:   *reason = EPS_CONVERGED_ITERATING;
356:   if (nconv >= nev) {
357:     PetscInfo2(eps,"Linear eigensolver finished successfully: %D eigenpairs converged at iteration %D\n",nconv,its);
358:     *reason = EPS_CONVERGED_TOL;
359:   } else if (its >= max_it) {
360:     *reason = EPS_DIVERGED_ITS;
361:     PetscInfo1(eps,"Linear eigensolver iteration reached maximum number of iterations (%D)\n",its);
362:   }
363:   return(0);
364: }

368: /*
369:   EPSComputeRitzVector - Computes the current Ritz vector.

371:   Simple case (complex scalars or real scalars with Zi=NULL):
372:     x = V*Zr  (V is a basis of nv vectors, Zr has length nv)

374:   Split case:
375:     x = V*Zr  y = V*Zi  (Zr and Zi have length nv)
376: */
377: PetscErrorCode EPSComputeRitzVector(EPS eps,PetscScalar *Zr,PetscScalar *Zi,BV V,Vec x,Vec y)
378: {
380:   PetscReal      norm;
381: #if !defined(PETSC_USE_COMPLEX)
382:   Vec            z;
383: #endif

386:   /* compute eigenvector */
387:   BVMultVec(V,1.0,0.0,x,Zr);

389:   /* purify eigenvector in positive generalized problems */
390:   if (eps->ispositive && eps->purify) {
391:     STApply(eps->st,x,y);
392:     if (eps->ishermitian) {
393:       BVNormVec(eps->V,y,NORM_2,&norm);
394:     } else {
395:       VecNorm(y,NORM_2,&norm);
396:     }
397:     VecScale(y,1.0/norm);
398:     VecCopy(y,x);
399:   }
400:   /* fix eigenvector if balancing is used */
401:   if (!eps->ishermitian && eps->balance!=EPS_BALANCE_NONE && eps->D) {
402:     VecPointwiseDivide(x,x,eps->D);
403:     VecNormalize(x,&norm);
404:   }
405: #if !defined(PETSC_USE_COMPLEX)
406:   /* compute imaginary part of eigenvector */
407:   if (Zi) {
408:     BVMultVec(V,1.0,0.0,y,Zi);
409:     if (eps->ispositive) {
410:       BVCreateVec(V,&z);
411:       STApply(eps->st,y,z);
412:       VecNorm(z,NORM_2,&norm);
413:       VecScale(z,1.0/norm);
414:       VecCopy(z,y);
415:       VecDestroy(&z);
416:     }
417:     if (eps->balance!=EPS_BALANCE_NONE && eps->D) {
418:       VecPointwiseDivide(y,y,eps->D);
419:       VecNormalize(y,&norm);
420:     }
421:   } else
422: #endif
423:   { VecSet(y,0.0); }
424:   return(0);
425: }

429: /*
430:   EPSBuildBalance_Krylov - uses a Krylov subspace method to compute the
431:   diagonal matrix to be applied for balancing in non-Hermitian problems.
432: */
433: PetscErrorCode EPSBuildBalance_Krylov(EPS eps)
434: {
435:   Vec               z,p,r;
436:   PetscInt          i,j;
437:   PetscReal         norma;
438:   PetscScalar       *pz,*pD;
439:   const PetscScalar *pr,*pp;
440:   PetscRandom       rand;
441:   PetscErrorCode    ierr;

444:   EPSSetWorkVecs(eps,3);
445:   BVGetRandomContext(eps->V,&rand);
446:   r = eps->work[0];
447:   p = eps->work[1];
448:   z = eps->work[2];
449:   VecSet(eps->D,1.0);

451:   for (j=0;j<eps->balance_its;j++) {

453:     /* Build a random vector of +-1's */
454:     VecSetRandom(z,rand);
455:     VecGetArray(z,&pz);
456:     for (i=0;i<eps->nloc;i++) {
457:       if (PetscRealPart(pz[i])<0.5) pz[i]=-1.0;
458:       else pz[i]=1.0;
459:     }
460:     VecRestoreArray(z,&pz);

462:     /* Compute p=DA(D\z) */
463:     VecPointwiseDivide(r,z,eps->D);
464:     STApply(eps->st,r,p);
465:     VecPointwiseMult(p,p,eps->D);
466:     if (j==0) {
467:       /* Estimate the matrix inf-norm */
468:       VecAbs(p);
469:       VecMax(p,NULL,&norma);
470:     }
471:     if (eps->balance == EPS_BALANCE_TWOSIDE) {
472:       /* Compute r=D\(A'Dz) */
473:       VecPointwiseMult(z,z,eps->D);
474:       STApplyTranspose(eps->st,z,r);
475:       VecPointwiseDivide(r,r,eps->D);
476:     }

478:     /* Adjust values of D */
479:     VecGetArrayRead(r,&pr);
480:     VecGetArrayRead(p,&pp);
481:     VecGetArray(eps->D,&pD);
482:     for (i=0;i<eps->nloc;i++) {
483:       if (eps->balance == EPS_BALANCE_TWOSIDE) {
484:         if (PetscAbsScalar(pp[i])>eps->balance_cutoff*norma && pr[i]!=0.0)
485:           pD[i] *= PetscSqrtReal(PetscAbsScalar(pr[i]/pp[i]));
486:       } else {
487:         if (pp[i]!=0.0) pD[i] *= 1.0/PetscAbsScalar(pp[i]);
488:       }
489:     }
490:     VecRestoreArrayRead(r,&pr);
491:     VecRestoreArrayRead(p,&pp);
492:     VecRestoreArray(eps->D,&pD);
493:   }
494:   return(0);
495: }

slepc-3.7.4/src/eps/interface/epsbasic.c.html0000644000175000017500000015346413107004621020416 0ustar jromanjroman
Actual source code: epsbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    The basic EPS routines, Create, Destroy, etc. are here.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>      /*I "slepceps.h" I*/

 26: PetscFunctionList EPSList = 0;
 27: PetscBool         EPSRegisterAllCalled = PETSC_FALSE;
 28: PetscClassId      EPS_CLASSID = 0;
 29: PetscLogEvent     EPS_SetUp = 0,EPS_Solve = 0;

 33: /*@
 34:    EPSCreate - Creates the default EPS context.

 36:    Collective on MPI_Comm

 38:    Input Parameter:
 39: .  comm - MPI communicator

 41:    Output Parameter:
 42: .  eps - location to put the EPS context

 44:    Note:
 45:    The default EPS type is EPSKRYLOVSCHUR

 47:    Level: beginner

 49: .seealso: EPSSetUp(), EPSSolve(), EPSDestroy(), EPS
 50: @*/
 51: PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps)
 52: {
 54:   EPS            eps;

 58:   *outeps = 0;
 59:   EPSInitializePackage();
 60:   SlepcHeaderCreate(eps,EPS_CLASSID,"EPS","Eigenvalue Problem Solver","EPS",comm,EPSDestroy,EPSView);

 62:   eps->max_it          = 0;
 63:   eps->nev             = 1;
 64:   eps->ncv             = 0;
 65:   eps->mpd             = 0;
 66:   eps->nini            = 0;
 67:   eps->nds             = 0;
 68:   eps->target          = 0.0;
 69:   eps->tol             = PETSC_DEFAULT;
 70:   eps->conv            = EPS_CONV_REL;
 71:   eps->stop            = EPS_STOP_BASIC;
 72:   eps->which           = (EPSWhich)0;
 73:   eps->inta            = 0.0;
 74:   eps->intb            = 0.0;
 75:   eps->problem_type    = (EPSProblemType)0;
 76:   eps->extraction      = EPS_RITZ;
 77:   eps->balance         = EPS_BALANCE_NONE;
 78:   eps->balance_its     = 5;
 79:   eps->balance_cutoff  = 1e-8;
 80:   eps->trueres         = PETSC_FALSE;
 81:   eps->trackall        = PETSC_FALSE;
 82:   eps->purify          = PETSC_TRUE;

 84:   eps->converged       = EPSConvergedRelative;
 85:   eps->convergeddestroy= NULL;
 86:   eps->stopping        = EPSStoppingBasic;
 87:   eps->stoppingdestroy = NULL;
 88:   eps->arbitrary       = NULL;
 89:   eps->convergedctx    = NULL;
 90:   eps->stoppingctx     = NULL;
 91:   eps->arbitraryctx    = NULL;
 92:   eps->numbermonitors  = 0;

 94:   eps->st              = NULL;
 95:   eps->ds              = NULL;
 96:   eps->V               = NULL;
 97:   eps->rg              = NULL;
 98:   eps->D               = NULL;
 99:   eps->IS              = NULL;
100:   eps->defl            = NULL;
101:   eps->eigr            = NULL;
102:   eps->eigi            = NULL;
103:   eps->errest          = NULL;
104:   eps->rr              = NULL;
105:   eps->ri              = NULL;
106:   eps->perm            = NULL;
107:   eps->nwork           = 0;
108:   eps->work            = NULL;
109:   eps->data            = NULL;

111:   eps->state           = EPS_STATE_INITIAL;
112:   eps->nconv           = 0;
113:   eps->its             = 0;
114:   eps->nloc            = 0;
115:   eps->nrma            = 0.0;
116:   eps->nrmb            = 0.0;
117:   eps->isgeneralized   = PETSC_FALSE;
118:   eps->ispositive      = PETSC_FALSE;
119:   eps->ishermitian     = PETSC_FALSE;
120:   eps->reason          = EPS_CONVERGED_ITERATING;

122:   PetscNewLog(eps,&eps->sc);
123:   *outeps = eps;
124:   return(0);
125: }

129: /*@C
130:    EPSSetType - Selects the particular solver to be used in the EPS object.

132:    Logically Collective on EPS

134:    Input Parameters:
135: +  eps  - the eigensolver context
136: -  type - a known method

138:    Options Database Key:
139: .  -eps_type <method> - Sets the method; use -help for a list
140:     of available methods

142:    Notes:
143:    See "slepc/include/slepceps.h" for available methods. The default
144:    is EPSKRYLOVSCHUR.

146:    Normally, it is best to use the EPSSetFromOptions() command and
147:    then set the EPS type from the options database rather than by using
148:    this routine.  Using the options database provides the user with
149:    maximum flexibility in evaluating the different available methods.
150:    The EPSSetType() routine is provided for those situations where it
151:    is necessary to set the iterative solver independently of the command
152:    line or options database.

154:    Level: intermediate

156: .seealso: STSetType(), EPSType
157: @*/
158: PetscErrorCode EPSSetType(EPS eps,EPSType type)
159: {
160:   PetscErrorCode ierr,(*r)(EPS);
161:   PetscBool      match;


167:   PetscObjectTypeCompare((PetscObject)eps,type,&match);
168:   if (match) return(0);

170:   PetscFunctionListFind(EPSList,type,&r);
171:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown EPS type given: %s",type);

173:   if (eps->ops->destroy) { (*eps->ops->destroy)(eps); }
174:   PetscMemzero(eps->ops,sizeof(struct _EPSOps));

176:   eps->state = EPS_STATE_INITIAL;
177:   PetscObjectChangeTypeName((PetscObject)eps,type);
178:   (*r)(eps);
179:   return(0);
180: }

184: /*@C
185:    EPSGetType - Gets the EPS type as a string from the EPS object.

187:    Not Collective

189:    Input Parameter:
190: .  eps - the eigensolver context

192:    Output Parameter:
193: .  name - name of EPS method

195:    Level: intermediate

197: .seealso: EPSSetType()
198: @*/
199: PetscErrorCode EPSGetType(EPS eps,EPSType *type)
200: {
204:   *type = ((PetscObject)eps)->type_name;
205:   return(0);
206: }

210: /*@C
211:    EPSRegister - Adds a method to the eigenproblem solver package.

213:    Not Collective

215:    Input Parameters:
216: +  name - name of a new user-defined solver
217: -  function - routine to create the solver context

219:    Notes:
220:    EPSRegister() may be called multiple times to add several user-defined solvers.

222:    Sample usage:
223: .vb
224:     EPSRegister("my_solver",MySolverCreate);
225: .ve

227:    Then, your solver can be chosen with the procedural interface via
228: $     EPSSetType(eps,"my_solver")
229:    or at runtime via the option
230: $     -eps_type my_solver

232:    Level: advanced

234: .seealso: EPSRegisterAll()
235: @*/
236: PetscErrorCode EPSRegister(const char *name,PetscErrorCode (*function)(EPS))
237: {

241:   PetscFunctionListAdd(&EPSList,name,function);
242:   return(0);
243: }

247: /*@
248:    EPSReset - Resets the EPS context to the initial state and removes any
249:    allocated objects.

251:    Collective on EPS

253:    Input Parameter:
254: .  eps - eigensolver context obtained from EPSCreate()

256:    Level: advanced

258: .seealso: EPSDestroy()
259: @*/
260: PetscErrorCode EPSReset(EPS eps)
261: {
263:   PetscInt       ncols;

267:   if (eps->ops->reset) { (eps->ops->reset)(eps); }
268:   if (eps->st) { STReset(eps->st); }
269:   if (eps->ds) { DSReset(eps->ds); }
270:   VecDestroy(&eps->D);
271:   BVGetSizes(eps->V,NULL,NULL,&ncols);
272:   if (ncols) {
273:     PetscFree4(eps->eigr,eps->eigi,eps->errest,eps->perm);
274:     PetscFree2(eps->rr,eps->ri);
275:   }
276:   BVDestroy(&eps->V);
277:   VecDestroyVecs(eps->nwork,&eps->work);
278:   eps->nwork = 0;
279:   eps->state = EPS_STATE_INITIAL;
280:   return(0);
281: }

285: /*@
286:    EPSDestroy - Destroys the EPS context.

288:    Collective on EPS

290:    Input Parameter:
291: .  eps - eigensolver context obtained from EPSCreate()

293:    Level: beginner

295: .seealso: EPSCreate(), EPSSetUp(), EPSSolve()
296: @*/
297: PetscErrorCode EPSDestroy(EPS *eps)
298: {

302:   if (!*eps) return(0);
304:   if (--((PetscObject)(*eps))->refct > 0) { *eps = 0; return(0); }
305:   EPSReset(*eps);
306:   if ((*eps)->ops->destroy) { (*(*eps)->ops->destroy)(*eps); }
307:   STDestroy(&(*eps)->st);
308:   RGDestroy(&(*eps)->rg);
309:   DSDestroy(&(*eps)->ds);
310:   PetscFree((*eps)->sc);
311:   /* just in case the initial vectors have not been used */
312:   SlepcBasisDestroy_Private(&(*eps)->nds,&(*eps)->defl);
313:   SlepcBasisDestroy_Private(&(*eps)->nini,&(*eps)->IS);
314:   if ((*eps)->convergeddestroy) {
315:     (*(*eps)->convergeddestroy)((*eps)->convergedctx);
316:   }
317:   EPSMonitorCancel(*eps);
318:   PetscHeaderDestroy(eps);
319:   return(0);
320: }

324: /*@
325:    EPSSetTarget - Sets the value of the target.

327:    Logically Collective on EPS

329:    Input Parameters:
330: +  eps    - eigensolver context
331: -  target - the value of the target

333:    Options Database Key:
334: .  -eps_target <scalar> - the value of the target

336:    Notes:
337:    The target is a scalar value used to determine the portion of the spectrum
338:    of interest. It is used in combination with EPSSetWhichEigenpairs().

340:    In the case of complex scalars, a complex value can be provided in the
341:    command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g.
342:    -eps_target 1.0+2.0i

344:    Level: intermediate

346: .seealso: EPSGetTarget(), EPSSetWhichEigenpairs()
347: @*/
348: PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)
349: {

355:   eps->target = target;
356:   if (!eps->st) { EPSGetST(eps,&eps->st); }
357:   STSetDefaultShift(eps->st,target);
358:   return(0);
359: }

363: /*@
364:    EPSGetTarget - Gets the value of the target.

366:    Not Collective

368:    Input Parameter:
369: .  eps - eigensolver context

371:    Output Parameter:
372: .  target - the value of the target

374:    Note:
375:    If the target was not set by the user, then zero is returned.

377:    Level: intermediate

379: .seealso: EPSSetTarget()
380: @*/
381: PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)
382: {
386:   *target = eps->target;
387:   return(0);
388: }

392: /*@
393:    EPSSetInterval - Defines the computational interval for spectrum slicing.

395:    Logically Collective on EPS

397:    Input Parameters:
398: +  eps  - eigensolver context
399: .  inta - left end of the interval
400: -  intb - right end of the interval

402:    Options Database Key:
403: .  -eps_interval <a,b> - set [a,b] as the interval of interest

405:    Notes:
406:    Spectrum slicing is a technique employed for computing all eigenvalues of
407:    symmetric eigenproblems in a given interval. This function provides the
408:    interval to be considered. It must be used in combination with EPS_ALL, see
409:    EPSSetWhichEigenpairs().

411:    In the command-line option, two values must be provided. For an open interval,
412:    one can give an infinite, e.g., -eps_interval 1.0,inf or -eps_interval -inf,1.0.
413:    An open interval in the programmatic interface can be specified with
414:    PETSC_MAX_REAL and -PETSC_MAX_REAL.

416:    Level: intermediate

418: .seealso: EPSGetInterval(), EPSSetWhichEigenpairs()
419: @*/
420: PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb)
421: {
426:   if (inta>=intb) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Badly defined interval, must be inta<intb");
427:   eps->inta = inta;
428:   eps->intb = intb;
429:   eps->state = EPS_STATE_INITIAL;
430:   return(0);
431: }

435: /*@
436:    EPSGetInterval - Gets the computational interval for spectrum slicing.

438:    Not Collective

440:    Input Parameter:
441: .  eps - eigensolver context

443:    Output Parameters:
444: +  inta - left end of the interval
445: -  intb - right end of the interval

447:    Level: intermediate

449:    Note:
450:    If the interval was not set by the user, then zeros are returned.

452: .seealso: EPSSetInterval()
453: @*/
454: PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb)
455: {
460:   if (inta) *inta = eps->inta;
461:   if (intb) *intb = eps->intb;
462:   return(0);
463: }

467: /*@
468:    EPSSetST - Associates a spectral transformation object to the eigensolver.

470:    Collective on EPS

472:    Input Parameters:
473: +  eps - eigensolver context obtained from EPSCreate()
474: -  st   - the spectral transformation object

476:    Note:
477:    Use EPSGetST() to retrieve the spectral transformation context (for example,
478:    to free it at the end of the computations).

480:    Level: advanced

482: .seealso: EPSGetST()
483: @*/
484: PetscErrorCode EPSSetST(EPS eps,ST st)
485: {

492:   PetscObjectReference((PetscObject)st);
493:   STDestroy(&eps->st);
494:   eps->st = st;
495:   PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->st);
496:   return(0);
497: }

501: /*@
502:    EPSGetST - Obtain the spectral transformation (ST) object associated
503:    to the eigensolver object.

505:    Not Collective

507:    Input Parameters:
508: .  eps - eigensolver context obtained from EPSCreate()

510:    Output Parameter:
511: .  st - spectral transformation context

513:    Level: intermediate

515: .seealso: EPSSetST()
516: @*/
517: PetscErrorCode EPSGetST(EPS eps,ST *st)
518: {

524:   if (!eps->st) {
525:     STCreate(PetscObjectComm((PetscObject)eps),&eps->st);
526:     PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->st);
527:   }
528:   *st = eps->st;
529:   return(0);
530: }

534: /*@
535:    EPSSetBV - Associates a basis vectors object to the eigensolver.

537:    Collective on EPS

539:    Input Parameters:
540: +  eps - eigensolver context obtained from EPSCreate()
541: -  V   - the basis vectors object

543:    Note:
544:    Use EPSGetBV() to retrieve the basis vectors context (for example,
545:    to free them at the end of the computations).

547:    Level: advanced

549: .seealso: EPSGetBV()
550: @*/
551: PetscErrorCode EPSSetBV(EPS eps,BV V)
552: {

559:   PetscObjectReference((PetscObject)V);
560:   BVDestroy(&eps->V);
561:   eps->V = V;
562:   PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->V);
563:   return(0);
564: }

568: /*@
569:    EPSGetBV - Obtain the basis vectors object associated to the eigensolver object.

571:    Not Collective

573:    Input Parameters:
574: .  eps - eigensolver context obtained from EPSCreate()

576:    Output Parameter:
577: .  V - basis vectors context

579:    Level: advanced

581: .seealso: EPSSetBV()
582: @*/
583: PetscErrorCode EPSGetBV(EPS eps,BV *V)
584: {

590:   if (!eps->V) {
591:     BVCreate(PetscObjectComm((PetscObject)eps),&eps->V);
592:     PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->V);
593:   }
594:   *V = eps->V;
595:   return(0);
596: }

600: /*@
601:    EPSSetRG - Associates a region object to the eigensolver.

603:    Collective on EPS

605:    Input Parameters:
606: +  eps - eigensolver context obtained from EPSCreate()
607: -  rg  - the region object

609:    Note:
610:    Use EPSGetRG() to retrieve the region context (for example,
611:    to free it at the end of the computations).

613:    Level: advanced

615: .seealso: EPSGetRG()
616: @*/
617: PetscErrorCode EPSSetRG(EPS eps,RG rg)
618: {

625:   PetscObjectReference((PetscObject)rg);
626:   RGDestroy(&eps->rg);
627:   eps->rg = rg;
628:   PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->rg);
629:   return(0);
630: }

634: /*@
635:    EPSGetRG - Obtain the region object associated to the eigensolver.

637:    Not Collective

639:    Input Parameters:
640: .  eps - eigensolver context obtained from EPSCreate()

642:    Output Parameter:
643: .  rg - region context

645:    Level: advanced

647: .seealso: EPSSetRG()
648: @*/
649: PetscErrorCode EPSGetRG(EPS eps,RG *rg)
650: {

656:   if (!eps->rg) {
657:     RGCreate(PetscObjectComm((PetscObject)eps),&eps->rg);
658:     PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->rg);
659:   }
660:   *rg = eps->rg;
661:   return(0);
662: }

666: /*@
667:    EPSSetDS - Associates a direct solver object to the eigensolver.

669:    Collective on EPS

671:    Input Parameters:
672: +  eps - eigensolver context obtained from EPSCreate()
673: -  ds  - the direct solver object

675:    Note:
676:    Use EPSGetDS() to retrieve the direct solver context (for example,
677:    to free it at the end of the computations).

679:    Level: advanced

681: .seealso: EPSGetDS()
682: @*/
683: PetscErrorCode EPSSetDS(EPS eps,DS ds)
684: {

691:   PetscObjectReference((PetscObject)ds);
692:   DSDestroy(&eps->ds);
693:   eps->ds = ds;
694:   PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->ds);
695:   return(0);
696: }

700: /*@
701:    EPSGetDS - Obtain the direct solver object associated to the eigensolver object.

703:    Not Collective

705:    Input Parameters:
706: .  eps - eigensolver context obtained from EPSCreate()

708:    Output Parameter:
709: .  ds - direct solver context

711:    Level: advanced

713: .seealso: EPSSetDS()
714: @*/
715: PetscErrorCode EPSGetDS(EPS eps,DS *ds)
716: {

722:   if (!eps->ds) {
723:     DSCreate(PetscObjectComm((PetscObject)eps),&eps->ds);
724:     PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->ds);
725:   }
726:   *ds = eps->ds;
727:   return(0);
728: }

732: /*@
733:    EPSIsGeneralized - Ask if the EPS object corresponds to a generalized
734:    eigenvalue problem.

736:    Not collective

738:    Input Parameter:
739: .  eps - the eigenproblem solver context

741:    Output Parameter:
742: .  is - the answer

744:    Level: intermediate

746: .seealso: EPSIsHermitian(), EPSIsPositive()
747: @*/
748: PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is)
749: {
753:   *is = eps->isgeneralized;
754:   return(0);
755: }

759: /*@
760:    EPSIsHermitian - Ask if the EPS object corresponds to a Hermitian
761:    eigenvalue problem.

763:    Not collective

765:    Input Parameter:
766: .  eps - the eigenproblem solver context

768:    Output Parameter:
769: .  is - the answer

771:    Level: intermediate

773: .seealso: EPSIsGeneralized(), EPSIsPositive()
774: @*/
775: PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is)
776: {
780:   *is = eps->ishermitian;
781:   return(0);
782: }

786: /*@
787:    EPSIsPositive - Ask if the EPS object corresponds to an eigenvalue
788:    problem type that requires a positive (semi-) definite matrix B.

790:    Not collective

792:    Input Parameter:
793: .  eps - the eigenproblem solver context

795:    Output Parameter:
796: .  is - the answer

798:    Level: intermediate

800: .seealso: EPSIsGeneralized(), EPSIsHermitian()
801: @*/
802: PetscErrorCode EPSIsPositive(EPS eps,PetscBool* is)
803: {
807:   *is = eps->ispositive;
808:   return(0);
809: }

slepc-3.7.4/src/eps/interface/epsbasic.c0000644000175000017500000005153713107004621017451 0ustar jromanjroman/* The basic EPS routines, Create, Destroy, etc. are here. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ PetscFunctionList EPSList = 0; PetscBool EPSRegisterAllCalled = PETSC_FALSE; PetscClassId EPS_CLASSID = 0; PetscLogEvent EPS_SetUp = 0,EPS_Solve = 0; #undef __FUNCT__ #define __FUNCT__ "EPSCreate" /*@ EPSCreate - Creates the default EPS context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . eps - location to put the EPS context Note: The default EPS type is EPSKRYLOVSCHUR Level: beginner .seealso: EPSSetUp(), EPSSolve(), EPSDestroy(), EPS @*/ PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps) { PetscErrorCode ierr; EPS eps; PetscFunctionBegin; PetscValidPointer(outeps,2); *outeps = 0; ierr = EPSInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(eps,EPS_CLASSID,"EPS","Eigenvalue Problem Solver","EPS",comm,EPSDestroy,EPSView);CHKERRQ(ierr); eps->max_it = 0; eps->nev = 1; eps->ncv = 0; eps->mpd = 0; eps->nini = 0; eps->nds = 0; eps->target = 0.0; eps->tol = PETSC_DEFAULT; eps->conv = EPS_CONV_REL; eps->stop = EPS_STOP_BASIC; eps->which = (EPSWhich)0; eps->inta = 0.0; eps->intb = 0.0; eps->problem_type = (EPSProblemType)0; eps->extraction = EPS_RITZ; eps->balance = EPS_BALANCE_NONE; eps->balance_its = 5; eps->balance_cutoff = 1e-8; eps->trueres = PETSC_FALSE; eps->trackall = PETSC_FALSE; eps->purify = PETSC_TRUE; eps->converged = EPSConvergedRelative; eps->convergeddestroy= NULL; eps->stopping = EPSStoppingBasic; eps->stoppingdestroy = NULL; eps->arbitrary = NULL; eps->convergedctx = NULL; eps->stoppingctx = NULL; eps->arbitraryctx = NULL; eps->numbermonitors = 0; eps->st = NULL; eps->ds = NULL; eps->V = NULL; eps->rg = NULL; eps->D = NULL; eps->IS = NULL; eps->defl = NULL; eps->eigr = NULL; eps->eigi = NULL; eps->errest = NULL; eps->rr = NULL; eps->ri = NULL; eps->perm = NULL; eps->nwork = 0; eps->work = NULL; eps->data = NULL; eps->state = EPS_STATE_INITIAL; eps->nconv = 0; eps->its = 0; eps->nloc = 0; eps->nrma = 0.0; eps->nrmb = 0.0; eps->isgeneralized = PETSC_FALSE; eps->ispositive = PETSC_FALSE; eps->ishermitian = PETSC_FALSE; eps->reason = EPS_CONVERGED_ITERATING; ierr = PetscNewLog(eps,&eps->sc);CHKERRQ(ierr); *outeps = eps; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetType" /*@C EPSSetType - Selects the particular solver to be used in the EPS object. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - type - a known method Options Database Key: . -eps_type - Sets the method; use -help for a list of available methods Notes: See "slepc/include/slepceps.h" for available methods. The default is EPSKRYLOVSCHUR. Normally, it is best to use the EPSSetFromOptions() command and then set the EPS type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The EPSSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database. Level: intermediate .seealso: STSetType(), EPSType @*/ PetscErrorCode EPSSetType(EPS eps,EPSType type) { PetscErrorCode ierr,(*r)(EPS); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)eps,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(EPSList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown EPS type given: %s",type); if (eps->ops->destroy) { ierr = (*eps->ops->destroy)(eps);CHKERRQ(ierr); } ierr = PetscMemzero(eps->ops,sizeof(struct _EPSOps));CHKERRQ(ierr); eps->state = EPS_STATE_INITIAL; ierr = PetscObjectChangeTypeName((PetscObject)eps,type);CHKERRQ(ierr); ierr = (*r)(eps);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetType" /*@C EPSGetType - Gets the EPS type as a string from the EPS object. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . name - name of EPS method Level: intermediate .seealso: EPSSetType() @*/ PetscErrorCode EPSGetType(EPS eps,EPSType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)eps)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSRegister" /*@C EPSRegister - Adds a method to the eigenproblem solver package. Not Collective Input Parameters: + name - name of a new user-defined solver - function - routine to create the solver context Notes: EPSRegister() may be called multiple times to add several user-defined solvers. Sample usage: .vb EPSRegister("my_solver",MySolverCreate); .ve Then, your solver can be chosen with the procedural interface via $ EPSSetType(eps,"my_solver") or at runtime via the option $ -eps_type my_solver Level: advanced .seealso: EPSRegisterAll() @*/ PetscErrorCode EPSRegister(const char *name,PetscErrorCode (*function)(EPS)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&EPSList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset" /*@ EPSReset - Resets the EPS context to the initial state and removes any allocated objects. Collective on EPS Input Parameter: . eps - eigensolver context obtained from EPSCreate() Level: advanced .seealso: EPSDestroy() @*/ PetscErrorCode EPSReset(EPS eps) { PetscErrorCode ierr; PetscInt ncols; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (eps->ops->reset) { ierr = (eps->ops->reset)(eps);CHKERRQ(ierr); } if (eps->st) { ierr = STReset(eps->st);CHKERRQ(ierr); } if (eps->ds) { ierr = DSReset(eps->ds);CHKERRQ(ierr); } ierr = VecDestroy(&eps->D);CHKERRQ(ierr); ierr = BVGetSizes(eps->V,NULL,NULL,&ncols);CHKERRQ(ierr); if (ncols) { ierr = PetscFree4(eps->eigr,eps->eigi,eps->errest,eps->perm);CHKERRQ(ierr); ierr = PetscFree2(eps->rr,eps->ri);CHKERRQ(ierr); } ierr = BVDestroy(&eps->V);CHKERRQ(ierr); ierr = VecDestroyVecs(eps->nwork,&eps->work);CHKERRQ(ierr); eps->nwork = 0; eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy" /*@ EPSDestroy - Destroys the EPS context. Collective on EPS Input Parameter: . eps - eigensolver context obtained from EPSCreate() Level: beginner .seealso: EPSCreate(), EPSSetUp(), EPSSolve() @*/ PetscErrorCode EPSDestroy(EPS *eps) { PetscErrorCode ierr; PetscFunctionBegin; if (!*eps) PetscFunctionReturn(0); PetscValidHeaderSpecific(*eps,EPS_CLASSID,1); if (--((PetscObject)(*eps))->refct > 0) { *eps = 0; PetscFunctionReturn(0); } ierr = EPSReset(*eps);CHKERRQ(ierr); if ((*eps)->ops->destroy) { ierr = (*(*eps)->ops->destroy)(*eps);CHKERRQ(ierr); } ierr = STDestroy(&(*eps)->st);CHKERRQ(ierr); ierr = RGDestroy(&(*eps)->rg);CHKERRQ(ierr); ierr = DSDestroy(&(*eps)->ds);CHKERRQ(ierr); ierr = PetscFree((*eps)->sc);CHKERRQ(ierr); /* just in case the initial vectors have not been used */ ierr = SlepcBasisDestroy_Private(&(*eps)->nds,&(*eps)->defl);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&(*eps)->nini,&(*eps)->IS);CHKERRQ(ierr); if ((*eps)->convergeddestroy) { ierr = (*(*eps)->convergeddestroy)((*eps)->convergedctx);CHKERRQ(ierr); } ierr = EPSMonitorCancel(*eps);CHKERRQ(ierr); ierr = PetscHeaderDestroy(eps);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetTarget" /*@ EPSSetTarget - Sets the value of the target. Logically Collective on EPS Input Parameters: + eps - eigensolver context - target - the value of the target Options Database Key: . -eps_target - the value of the target Notes: The target is a scalar value used to determine the portion of the spectrum of interest. It is used in combination with EPSSetWhichEigenpairs(). In the case of complex scalars, a complex value can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -eps_target 1.0+2.0i Level: intermediate .seealso: EPSGetTarget(), EPSSetWhichEigenpairs() @*/ PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveScalar(eps,target,2); eps->target = target; if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } ierr = STSetDefaultShift(eps->st,target);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetTarget" /*@ EPSGetTarget - Gets the value of the target. Not Collective Input Parameter: . eps - eigensolver context Output Parameter: . target - the value of the target Note: If the target was not set by the user, then zero is returned. Level: intermediate .seealso: EPSSetTarget() @*/ PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidScalarPointer(target,2); *target = eps->target; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetInterval" /*@ EPSSetInterval - Defines the computational interval for spectrum slicing. Logically Collective on EPS Input Parameters: + eps - eigensolver context . inta - left end of the interval - intb - right end of the interval Options Database Key: . -eps_interval - set [a,b] as the interval of interest Notes: Spectrum slicing is a technique employed for computing all eigenvalues of symmetric eigenproblems in a given interval. This function provides the interval to be considered. It must be used in combination with EPS_ALL, see EPSSetWhichEigenpairs(). In the command-line option, two values must be provided. For an open interval, one can give an infinite, e.g., -eps_interval 1.0,inf or -eps_interval -inf,1.0. An open interval in the programmatic interface can be specified with PETSC_MAX_REAL and -PETSC_MAX_REAL. Level: intermediate .seealso: EPSGetInterval(), EPSSetWhichEigenpairs() @*/ PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveReal(eps,inta,2); PetscValidLogicalCollectiveReal(eps,intb,3); if (inta>=intb) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Badly defined interval, must be intainta = inta; eps->intb = intb; eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetInterval" /*@ EPSGetInterval - Gets the computational interval for spectrum slicing. Not Collective Input Parameter: . eps - eigensolver context Output Parameters: + inta - left end of the interval - intb - right end of the interval Level: intermediate Note: If the interval was not set by the user, then zeros are returned. .seealso: EPSSetInterval() @*/ PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(inta,2); PetscValidPointer(intb,3); if (inta) *inta = eps->inta; if (intb) *intb = eps->intb; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetST" /*@ EPSSetST - Associates a spectral transformation object to the eigensolver. Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() - st - the spectral transformation object Note: Use EPSGetST() to retrieve the spectral transformation context (for example, to free it at the end of the computations). Level: advanced .seealso: EPSGetST() @*/ PetscErrorCode EPSSetST(EPS eps,ST st) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidHeaderSpecific(st,ST_CLASSID,2); PetscCheckSameComm(eps,1,st,2); ierr = PetscObjectReference((PetscObject)st);CHKERRQ(ierr); ierr = STDestroy(&eps->st);CHKERRQ(ierr); eps->st = st; ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->st);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetST" /*@ EPSGetST - Obtain the spectral transformation (ST) object associated to the eigensolver object. Not Collective Input Parameters: . eps - eigensolver context obtained from EPSCreate() Output Parameter: . st - spectral transformation context Level: intermediate .seealso: EPSSetST() @*/ PetscErrorCode EPSGetST(EPS eps,ST *st) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(st,2); if (!eps->st) { ierr = STCreate(PetscObjectComm((PetscObject)eps),&eps->st);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->st);CHKERRQ(ierr); } *st = eps->st; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetBV" /*@ EPSSetBV - Associates a basis vectors object to the eigensolver. Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() - V - the basis vectors object Note: Use EPSGetBV() to retrieve the basis vectors context (for example, to free them at the end of the computations). Level: advanced .seealso: EPSGetBV() @*/ PetscErrorCode EPSSetBV(EPS eps,BV V) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidHeaderSpecific(V,BV_CLASSID,2); PetscCheckSameComm(eps,1,V,2); ierr = PetscObjectReference((PetscObject)V);CHKERRQ(ierr); ierr = BVDestroy(&eps->V);CHKERRQ(ierr); eps->V = V; ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetBV" /*@ EPSGetBV - Obtain the basis vectors object associated to the eigensolver object. Not Collective Input Parameters: . eps - eigensolver context obtained from EPSCreate() Output Parameter: . V - basis vectors context Level: advanced .seealso: EPSSetBV() @*/ PetscErrorCode EPSGetBV(EPS eps,BV *V) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(V,2); if (!eps->V) { ierr = BVCreate(PetscObjectComm((PetscObject)eps),&eps->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->V);CHKERRQ(ierr); } *V = eps->V; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetRG" /*@ EPSSetRG - Associates a region object to the eigensolver. Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() - rg - the region object Note: Use EPSGetRG() to retrieve the region context (for example, to free it at the end of the computations). Level: advanced .seealso: EPSGetRG() @*/ PetscErrorCode EPSSetRG(EPS eps,RG rg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidHeaderSpecific(rg,RG_CLASSID,2); PetscCheckSameComm(eps,1,rg,2); ierr = PetscObjectReference((PetscObject)rg);CHKERRQ(ierr); ierr = RGDestroy(&eps->rg);CHKERRQ(ierr); eps->rg = rg; ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->rg);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetRG" /*@ EPSGetRG - Obtain the region object associated to the eigensolver. Not Collective Input Parameters: . eps - eigensolver context obtained from EPSCreate() Output Parameter: . rg - region context Level: advanced .seealso: EPSSetRG() @*/ PetscErrorCode EPSGetRG(EPS eps,RG *rg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(rg,2); if (!eps->rg) { ierr = RGCreate(PetscObjectComm((PetscObject)eps),&eps->rg);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->rg);CHKERRQ(ierr); } *rg = eps->rg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetDS" /*@ EPSSetDS - Associates a direct solver object to the eigensolver. Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() - ds - the direct solver object Note: Use EPSGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations). Level: advanced .seealso: EPSGetDS() @*/ PetscErrorCode EPSSetDS(EPS eps,DS ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidHeaderSpecific(ds,DS_CLASSID,2); PetscCheckSameComm(eps,1,ds,2); ierr = PetscObjectReference((PetscObject)ds);CHKERRQ(ierr); ierr = DSDestroy(&eps->ds);CHKERRQ(ierr); eps->ds = ds; ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetDS" /*@ EPSGetDS - Obtain the direct solver object associated to the eigensolver object. Not Collective Input Parameters: . eps - eigensolver context obtained from EPSCreate() Output Parameter: . ds - direct solver context Level: advanced .seealso: EPSSetDS() @*/ PetscErrorCode EPSGetDS(EPS eps,DS *ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(ds,2); if (!eps->ds) { ierr = DSCreate(PetscObjectComm((PetscObject)eps),&eps->ds);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)eps->ds);CHKERRQ(ierr); } *ds = eps->ds; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSIsGeneralized" /*@ EPSIsGeneralized - Ask if the EPS object corresponds to a generalized eigenvalue problem. Not collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . is - the answer Level: intermediate .seealso: EPSIsHermitian(), EPSIsPositive() @*/ PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(is,2); *is = eps->isgeneralized; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSIsHermitian" /*@ EPSIsHermitian - Ask if the EPS object corresponds to a Hermitian eigenvalue problem. Not collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . is - the answer Level: intermediate .seealso: EPSIsGeneralized(), EPSIsPositive() @*/ PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(is,2); *is = eps->ishermitian; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSIsPositive" /*@ EPSIsPositive - Ask if the EPS object corresponds to an eigenvalue problem type that requires a positive (semi-) definite matrix B. Not collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . is - the answer Level: intermediate .seealso: EPSIsGeneralized(), EPSIsHermitian() @*/ PetscErrorCode EPSIsPositive(EPS eps,PetscBool* is) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(is,2); *is = eps->ispositive; PetscFunctionReturn(0); } slepc-3.7.4/src/eps/interface/ftn-custom/0000755000175000017500000000000013107004621017600 5ustar jromanjromanslepc-3.7.4/src/eps/interface/ftn-custom/makefile0000644000175000017500000000221113107004621021274 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zepsf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/interface/ftn-custom/zepsf.c0000644000175000017500000004350713107004621021104 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define epsview_ EPSVIEW #define epserrorview_ EPSERRORVIEW #define epsreasonview_ EPSREASONVIEW #define epsvaluesview_ EPSVALUESVIEW #define epsvectorsview_ EPSVECTORSVIEW #define epssetoptionsprefix_ EPSSETOPTIONSPREFIX #define epsappendoptionsprefix_ EPSAPPENDOPTIONSPREFIX #define epsgetoptionsprefix_ EPSGETOPTIONSPREFIX #define epssettype_ EPSSETTYPE #define epsgettype_ EPSGETTYPE #define epsmonitorall_ EPSMONITORALL #define epsmonitorlg_ EPSMONITORLG #define epsmonitorlgall_ EPSMONITORLGALL #define epsmonitorset_ EPSMONITORSET #define epsmonitorconverged_ EPSMONITORCONVERGED #define epsmonitorfirst_ EPSMONITORFIRST #define epsconvergedabsolute_ EPSCONVERGEDABSOLUTE #define epsconvergedrelative_ EPSCONVERGEDRELATIVE #define epsconvergednorm_ EPSCONVERGEDNORM #define epssetconvergencetestfunction_ EPSSETCONVERGENCETESTFUNCTION #define epssetstoppingtestfunction_ EPSSETSTOPPINGTESTFUNCTION #define epsseteigenvaluecomparison_ EPSSETEIGENVALUECOMPARISON #define epssetarbitraryselection_ EPSSETARBITRARYSELECTION #define epskrylovschursetsubintervals_ EPSKRYLOVSCHURSETSUBINTERVALs #define epskrylovschurgetsubintervals_ EPSKRYLOVSCHURGETSUBINTERVALs #define epskrylovschurgetinertias_ EPSKRYLOVSCHURGETINERTIAS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define epsview_ epsview #define epserrorview_ epserrorview #define epsreasonview_ epsreasonview #define epsvaluesview_ epsvaluesview #define epsvectorsview_ epsvectorsview #define epssetoptionsprefix_ epssetoptionsprefix #define epsappendoptionsprefix_ epsappendoptionsprefix #define epsgetoptionsprefix_ epsgetoptionsprefix #define epssettype_ epssettype #define epsgettype_ epsgettype #define epsmonitorall_ epsmonitorall #define epsmonitorlg_ epsmonitorlg #define epsmonitorlgall_ epsmonitorlgall #define epsmonitorset_ epsmonitorset #define epsmonitorconverged_ epsmonitorconverged #define epsmonitorfirst_ epsmonitorfirst #define epsconvergedabsolute_ epsconvergedabsolute #define epsconvergedrelative_ epsconvergedrelative #define epsconvergednorm_ epsconvergednorm #define epssetconvergencetestfunction_ epssetconvergencetestfunction #define epssetstoppingtestfunction_ epssetstoppingtestfunction #define epsseteigenvaluecomparison_ epsseteigenvaluecomparison #define epssetarbitraryselection_ epssetarbitraryselection #define epskrylovschursetsubintervals_ epskrylovschursetsubintervals #define epskrylovschurgetsubintervals_ epskrylovschurgetsubintervals #define epskrylovschurgetinertias_ epskrylovschurgetinertias #endif /* These are not usually called from Fortran but allow Fortran users to transparently set these monitors from .F code, hence no STDCALL */ PETSC_EXTERN void epsmonitorall_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = EPSMonitorAll(*eps,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void epsmonitorconverged_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr) { *ierr = EPSMonitorConverged(*eps,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void epsmonitorfirst_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = EPSMonitorFirst(*eps,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void epsmonitorlg_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = EPSMonitorLG(*eps,*it,*nconv,eigr,eigi,errest,*nest,ctx); } PETSC_EXTERN void epsmonitorlgall_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = EPSMonitorLGAll(*eps,*it,*nconv,eigr,eigi,errest,*nest,ctx); } static struct { PetscFortranCallbackId monitor; PetscFortranCallbackId monitordestroy; PetscFortranCallbackId convergence; PetscFortranCallbackId convdestroy; PetscFortranCallbackId stopping; PetscFortranCallbackId stopdestroy; PetscFortranCallbackId comparison; PetscFortranCallbackId arbitrary; } _cb; /* These are not extern C because they are passed into non-extern C user level functions */ #undef __FUNCT__ #define __FUNCT__ "ourmonitor" static PetscErrorCode ourmonitor(EPS eps,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx) { PetscObjectUseFortranCallback(eps,_cb.monitor,(EPS*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),(&eps,&i,&nc,er,ei,d,&l,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourdestroy" static PetscErrorCode ourdestroy(void** ctx) { EPS eps = (EPS)*ctx; PetscObjectUseFortranCallback(eps,_cb.monitordestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvergence" static PetscErrorCode ourconvergence(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscObjectUseFortranCallback(eps,_cb.convergence,(EPS*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),(&eps,&eigr,&eigi,&res,errest,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvdestroy" static PetscErrorCode ourconvdestroy(void *ctx) { EPS eps = (EPS)ctx; PetscObjectUseFortranCallback(eps,_cb.convdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopping" static PetscErrorCode ourstopping(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx) { PetscObjectUseFortranCallback(eps,_cb.stopping,(EPS*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,EPSConvergedReason*,void*,PetscErrorCode*),(&eps,&its,&max_it,&nconv,&nev,reason,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopdestroy" static PetscErrorCode ourstopdestroy(void *ctx) { EPS eps = (EPS)ctx; PetscObjectUseFortranCallback(eps,_cb.stopdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "oureigenvaluecomparison" static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx) { EPS eps = (EPS)ctx; PetscObjectUseFortranCallback(eps,_cb.comparison,(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*,PetscErrorCode*),(&ar,&ai,&br,&bi,r,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourarbitraryfunc" static PetscErrorCode ourarbitraryfunc(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx) { EPS eps = (EPS)ctx; PetscObjectUseFortranCallback(eps,_cb.arbitrary,(PetscScalar*,PetscScalar*,Vec*,Vec*,PetscScalar*,PetscScalar*,void*,PetscErrorCode*),(&er,&ei,&xr,&xi,rr,ri,_ctx,&ierr)); } PETSC_EXTERN void PETSC_STDCALL epsview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = EPSView(*eps,v); } PETSC_EXTERN void PETSC_STDCALL epsreasonview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = EPSReasonView(*eps,v); } PETSC_EXTERN void PETSC_STDCALL epserrorview_(EPS *eps,EPSErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = EPSErrorView(*eps,*etype,v); } PETSC_EXTERN void PETSC_STDCALL epsvaluesview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = EPSValuesView(*eps,v); } PETSC_EXTERN void PETSC_STDCALL epsvectorsview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = EPSVectorsView(*eps,v); } PETSC_EXTERN void PETSC_STDCALL epssettype_(EPS *eps,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = EPSSetType(*eps,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL epsgettype_(EPS *eps,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { EPSType tname; *ierr = EPSGetType(*eps,&tname);if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL epssetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = EPSSetOptionsPrefix(*eps,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL epsappendoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = EPSAppendOptionsPrefix(*eps,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL epsgetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = EPSGetOptionsPrefix(*eps,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL epsmonitorset_(EPS *eps,void (PETSC_STDCALL *monitor)(EPS*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(mctx); CHKFORTRANNULLFUNCTION(monitordestroy); if ((PetscVoidFunction)monitor == (PetscVoidFunction)epsmonitorall_) { *ierr = EPSMonitorSet(*eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))EPSMonitorAll,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)epsmonitorconverged_) { *ierr = EPSMonitorSet(*eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))EPSMonitorConverged,*(SlepcConvMonitor*)mctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)epsmonitorfirst_) { *ierr = EPSMonitorSet(*eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))EPSMonitorFirst,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)epsmonitorlg_) { *ierr = EPSMonitorSet(*eps,EPSMonitorLG,0,0); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)epsmonitorlgall_) { *ierr = EPSMonitorSet(*eps,EPSMonitorLGAll,0,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitor,(PetscVoidFunction)monitor,mctx); if (*ierr) return; if (!monitordestroy) { *ierr = EPSMonitorSet(*eps,ourmonitor,*eps,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitordestroy,(PetscVoidFunction)monitordestroy,mctx); if (*ierr) return; *ierr = EPSMonitorSet(*eps,ourmonitor,*eps,ourdestroy); } } } PETSC_EXTERN void PETSC_STDCALL epsconvergedabsolute_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = EPSConvergedAbsolute(*eps,*eigr,*eigi,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL epsconvergedrelative_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = EPSConvergedRelative(*eps,*eigr,*eigi,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL epsconvergednorm_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = EPSConvergedNorm(*eps,*eigr,*eigi,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL epssetconvergencetestfunction_(EPS *eps,void (PETSC_STDCALL *func)(EPS*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)epsconvergedabsolute_) { *ierr = EPSSetConvergenceTest(*eps,EPS_CONV_ABS); } else if ((PetscVoidFunction)func == (PetscVoidFunction)epsconvergedrelative_) { *ierr = EPSSetConvergenceTest(*eps,EPS_CONV_REL); } else if ((PetscVoidFunction)func == (PetscVoidFunction)epsconvergednorm_) { *ierr = EPSSetConvergenceTest(*eps,EPS_CONV_NORM); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convergence,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = EPSSetConvergenceTestFunction(*eps,ourconvergence,*eps,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = EPSSetConvergenceTestFunction(*eps,ourconvergence,*eps,ourconvdestroy); } } } PETSC_EXTERN void PETSC_STDCALL epsstoppingbasic_(EPS *eps,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,EPSConvergedReason *reason,void *ctx,PetscErrorCode *ierr) { *ierr = EPSStoppingBasic(*eps,*its,*max_it,*nconv,*nev,reason,ctx); } PETSC_EXTERN void PETSC_STDCALL epssetstoppingtestfunction_(EPS *eps,void (PETSC_STDCALL *func)(EPS*,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)epsstoppingbasic_) { *ierr = EPSSetStoppingTest(*eps,EPS_STOP_BASIC); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopping,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = EPSSetStoppingTestFunction(*eps,ourstopping,*eps,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = EPSSetStoppingTestFunction(*eps,ourstopping,*eps,ourstopdestroy); } } } PETSC_EXTERN void PETSC_STDCALL epsseteigenvaluecomparison_(EPS *eps,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.comparison,(PetscVoidFunction)func,ctx); if (*ierr) return; *ierr = EPSSetEigenvalueComparison(*eps,oureigenvaluecomparison,*eps); } PETSC_EXTERN void PETSC_STDCALL epssetarbitraryselection_(EPS *eps,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,Vec*,Vec*,PetscScalar*,PetscScalar*,void*,PetscErrorCode*),void *ctx,PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); *ierr = PetscObjectSetFortranCallback((PetscObject)*eps,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.arbitrary,(PetscVoidFunction)func,ctx); if (*ierr) return; *ierr = EPSSetArbitrarySelection(*eps,ourarbitraryfunc,*eps); } PETSC_EXTERN void PETSC_STDCALL epskrylovschursetsubintervals_(EPS *eps,PetscReal *subint,PetscErrorCode *ierr) { CHKFORTRANNULLREAL(subint); *ierr = EPSKrylovSchurSetSubintervals(*eps,subint); } PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetsubintervals_(EPS *eps,PetscReal *subint,PetscErrorCode *ierr) { PetscReal *osubint; PetscInt npart; CHKFORTRANNULLREAL(subint); *ierr = EPSKrylovSchurGetSubintervals(*eps,&osubint); if (*ierr) return; *ierr = EPSKrylovSchurGetPartitions(*eps,&npart); if (*ierr) return; *ierr = PetscMemcpy(subint,osubint,(npart+1)*sizeof(PetscReal)); if (*ierr) return; *ierr = PetscFree(osubint); } PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetinertias_(EPS *eps,PetscInt *nshift,PetscReal *shifts,PetscInt *inertias,PetscErrorCode *ierr) { PetscReal *oshifts; PetscInt *oinertias; PetscInt n; CHKFORTRANNULLREAL(shifts); CHKFORTRANNULLINTEGER(inertias); *ierr = EPSKrylovSchurGetInertias(*eps,&n,&oshifts,&oinertias); if (*ierr) return; if (shifts) { *ierr = PetscMemcpy(shifts,oshifts,n*sizeof(PetscReal)); if (*ierr) return; } if (inertias) { *ierr = PetscMemcpy(inertias,oinertias,n*sizeof(PetscInt)); if (*ierr) return; } *nshift = n; *ierr = PetscFree(oshifts); *ierr = PetscFree(oinertias); } slepc-3.7.4/src/eps/interface/epsopts.c0000644000175000017500000016033513107004621017352 0ustar jromanjroman/* EPS routines related to options that can be set via the command-line or procedurally. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "EPSMonitorSetFromOptions" /*@C EPSMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user. Collective on EPS Input Parameters: + eps - the eigensolver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor . monitor - the monitor function, whose context is a PetscViewerAndFormat - trackall - whether this monitor tracks all eigenvalues or not Level: developer .seealso: EPSMonitorSet(), EPSSetTrackAll(), EPSConvMonitorSetFromOptions() @*/ PetscErrorCode EPSMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; PetscViewerAndFormat *vf; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerAndFormatCreate(viewer,format,&vf);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = EPSMonitorSet(eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);CHKERRQ(ierr); if (trackall) { ierr = EPSSetTrackAll(eps,PETSC_TRUE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSConvMonitorSetFromOptions" /*@C EPSConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence). Collective on EPS Input Parameters: + eps - the eigensolver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor - monitor - the monitor function, whose context is a SlepcConvMonitor Level: developer .seealso: EPSMonitorSet(), EPSMonitorSetFromOptions() @*/ PetscErrorCode EPSConvMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor)) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; SlepcConvMonitor ctx; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = SlepcConvMonitorCreate(viewer,format,&ctx);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = EPSMonitorSet(eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions" /*@ EPSSetFromOptions - Sets EPS options from the options database. This routine must be called before EPSSetUp() if the user is to be allowed to set the solver type. Collective on EPS Input Parameters: . eps - the eigensolver context Notes: To see all options, run your program with the -help option. Level: beginner @*/ PetscErrorCode EPSSetFromOptions(EPS eps) { PetscErrorCode ierr; char type[256]; PetscBool set,flg,flg1,flg2,flg3; PetscReal r,array[2]={0,0}; PetscScalar s; PetscInt i,j,k; PetscDrawLG lg; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = EPSRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)eps);CHKERRQ(ierr); ierr = PetscOptionsFList("-eps_type","Eigenvalue Problem Solver method","EPSSetType",EPSList,(char*)(((PetscObject)eps)->type_name?((PetscObject)eps)->type_name:EPSKRYLOVSCHUR),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetType(eps,type);CHKERRQ(ierr); } /* Set the type if it was never set. */ if (!((PetscObject)eps)->type_name) { ierr = EPSSetType(eps,EPSKRYLOVSCHUR);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-eps_hermitian","hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_gen_hermitian","generalized hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetProblemType(eps,EPS_GHEP);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_non_hermitian","non-hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_gen_non_hermitian","generalized non-hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetProblemType(eps,EPS_GNHEP);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_pos_gen_non_hermitian","generalized non-hermitian eigenvalue problem with positive semi-definite B","EPSSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetProblemType(eps,EPS_PGNHEP);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-eps_gen_indefinite","generalized hermitian-indefinite eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetProblemType(eps,EPS_GHIEP);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-eps_ritz","Rayleigh-Ritz extraction","EPSSetExtraction",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetExtraction(eps,EPS_RITZ);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_harmonic","harmonic Ritz extraction","EPSSetExtraction",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetExtraction(eps,EPS_HARMONIC);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_harmonic_relative","relative harmonic Ritz extraction","EPSSetExtraction",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetExtraction(eps,EPS_HARMONIC_RELATIVE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_harmonic_right","right harmonic Ritz extraction","EPSSetExtraction",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetExtraction(eps,EPS_HARMONIC_RIGHT);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_harmonic_largest","largest harmonic Ritz extraction","EPSSetExtraction",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetExtraction(eps,EPS_HARMONIC_LARGEST);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_refined","refined Ritz extraction","EPSSetExtraction",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetExtraction(eps,EPS_REFINED);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-eps_refined_harmonic","refined harmonic Ritz extraction","EPSSetExtraction",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetExtraction(eps,EPS_REFINED_HARMONIC);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-eps_balance","Balancing method","EPSSetBalance",EPSBalanceTypes,(PetscEnum)eps->balance,(PetscEnum*)&eps->balance,NULL);CHKERRQ(ierr); j = eps->balance_its; ierr = PetscOptionsInt("-eps_balance_its","Number of iterations in balancing","EPSSetBalance",eps->balance_its,&j,&flg1);CHKERRQ(ierr); r = eps->balance_cutoff; ierr = PetscOptionsReal("-eps_balance_cutoff","Cutoff value in balancing","EPSSetBalance",eps->balance_cutoff,&r,&flg2);CHKERRQ(ierr); if (flg1 || flg2) { ierr = EPSSetBalance(eps,eps->balance,j,r);CHKERRQ(ierr); } i = eps->max_it? eps->max_it: PETSC_DEFAULT; ierr = PetscOptionsInt("-eps_max_it","Maximum number of iterations","EPSSetTolerances",eps->max_it,&i,&flg1);CHKERRQ(ierr); r = eps->tol; ierr = PetscOptionsReal("-eps_tol","Tolerance","EPSSetTolerances",eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol,&r,&flg2);CHKERRQ(ierr); if (flg1 || flg2) { ierr = EPSSetTolerances(eps,r,i);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-eps_conv_rel","Relative error convergence test","EPSSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetConvergenceTest(eps,EPS_CONV_REL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_conv_norm","Convergence test relative to the eigenvalue and the matrix norms","EPSSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetConvergenceTest(eps,EPS_CONV_NORM);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_conv_abs","Absolute error convergence test","EPSSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetConvergenceTest(eps,EPS_CONV_ABS);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-eps_conv_user","User-defined convergence test","EPSSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetConvergenceTest(eps,EPS_CONV_USER);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-eps_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","EPSSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetStoppingTest(eps,EPS_STOP_BASIC);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-eps_stop_user","User-defined stopping test","EPSSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetStoppingTest(eps,EPS_STOP_USER);CHKERRQ(ierr); } i = eps->nev; ierr = PetscOptionsInt("-eps_nev","Number of eigenvalues to compute","EPSSetDimensions",eps->nev,&i,&flg1);CHKERRQ(ierr); j = eps->ncv? eps->ncv: PETSC_DEFAULT; ierr = PetscOptionsInt("-eps_ncv","Number of basis vectors","EPSSetDimensions",eps->ncv,&j,&flg2);CHKERRQ(ierr); k = eps->mpd? eps->mpd: PETSC_DEFAULT; ierr = PetscOptionsInt("-eps_mpd","Maximum dimension of projected problem","EPSSetDimensions",eps->mpd,&k,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = EPSSetDimensions(eps,i,j,k);CHKERRQ(ierr); } /* -----------------------------------------------------------------------*/ /* Cancels all monitors hardwired into code before call to EPSSetFromOptions() */ ierr = PetscOptionsBool("-eps_monitor_cancel","Remove any hardwired monitor routines","EPSMonitorCancel",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = EPSMonitorCancel(eps);CHKERRQ(ierr); } /* Text monitors */ ierr = EPSMonitorSetFromOptions(eps,"-eps_monitor","Monitor first unconverged approximate eigenvalue and error estimate","EPSMonitorFirst",EPSMonitorFirst,PETSC_FALSE);CHKERRQ(ierr); ierr = EPSConvMonitorSetFromOptions(eps,"-eps_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","EPSMonitorConverged",EPSMonitorConverged);CHKERRQ(ierr); ierr = EPSMonitorSetFromOptions(eps,"-eps_monitor_all","Monitor approximate eigenvalues and error estimates","EPSMonitorAll",EPSMonitorAll,PETSC_TRUE);CHKERRQ(ierr); /* Line graph monitors */ ierr = PetscOptionsBool("-eps_monitor_lg","Monitor first unconverged approximate eigenvalue and error estimate graphically","EPSMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = EPSMonitorLGCreate(PetscObjectComm((PetscObject)eps),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = EPSMonitorSet(eps,EPSMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); } ierr = PetscOptionsBool("-eps_monitor_lg_all","Monitor error estimates graphically","EPSMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = EPSMonitorLGCreate(PetscObjectComm((PetscObject)eps),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = EPSMonitorSet(eps,EPSMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); ierr = EPSSetTrackAll(eps,PETSC_TRUE);CHKERRQ(ierr); } /* -----------------------------------------------------------------------*/ ierr = PetscOptionsBoolGroupBegin("-eps_largest_magnitude","compute largest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_smallest_magnitude","compute smallest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_largest_real","compute largest real parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_smallest_real","compute smallest real parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_largest_imaginary","compute largest imaginary parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_smallest_imaginary","compute smallest imaginary parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_target_magnitude","compute nearest eigenvalues to target","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_target_real","compute eigenvalues with real parts close to target","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_TARGET_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-eps_target_imaginary","compute eigenvalues with imaginary parts close to target","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_TARGET_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-eps_all","compute all eigenvalues in an interval or a region","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = EPSSetWhichEigenpairs(eps,EPS_ALL);CHKERRQ(ierr); } ierr = PetscOptionsScalar("-eps_target","Value of the target","EPSSetTarget",eps->target,&s,&flg);CHKERRQ(ierr); if (flg) { if (eps->which!=EPS_TARGET_REAL && eps->which!=EPS_TARGET_IMAGINARY) { ierr = EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);CHKERRQ(ierr); } ierr = EPSSetTarget(eps,s);CHKERRQ(ierr); } k = 2; ierr = PetscOptionsRealArray("-eps_interval","Computational interval (two real values separated with a comma without spaces)","EPSSetInterval",array,&k,&flg);CHKERRQ(ierr); if (flg) { if (k<2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_SIZ,"Must pass two values in -eps_interval (comma-separated without spaces)"); ierr = EPSSetWhichEigenpairs(eps,EPS_ALL);CHKERRQ(ierr); ierr = EPSSetInterval(eps,array[0],array[1]);CHKERRQ(ierr); } ierr = PetscOptionsBool("-eps_true_residual","Compute true residuals explicitly","EPSSetTrueResidual",eps->trueres,&eps->trueres,NULL);CHKERRQ(ierr); ierr = PetscOptionsBool("-eps_purify","Postprocess eigenvectors for purification","EPSSetPurify",eps->purify,&eps->purify,NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-eps_view","Print detailed information on solver used","EPSView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-eps_view_vectors","View computed eigenvectors","EPSVectorsView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-eps_view_values","View computed eigenvalues","EPSValuesView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-eps_converged_reason","Print reason for convergence, and number of iterations","EPSReasonView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-eps_error_absolute","Print absolute errors of each eigenpair","EPSErrorView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-eps_error_relative","Print relative errors of each eigenpair","EPSErrorView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-eps_error_backward","Print backward errors of each eigenpair","EPSErrorView",NULL);CHKERRQ(ierr); if (eps->ops->setfromoptions) { ierr = (*eps->ops->setfromoptions)(PetscOptionsObject,eps);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)eps);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } ierr = BVSetFromOptions(eps->V);CHKERRQ(ierr); if (!eps->rg) { ierr = EPSGetRG(eps,&eps->rg);CHKERRQ(ierr); } ierr = RGSetFromOptions(eps->rg);CHKERRQ(ierr); if (!eps->ds) { ierr = EPSGetDS(eps,&eps->ds);CHKERRQ(ierr); } ierr = DSSetFromOptions(eps->ds);CHKERRQ(ierr); if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } ierr = STSetFromOptions(eps->st);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetTolerances" /*@ EPSGetTolerances - Gets the tolerance and maximum iteration count used by the EPS convergence tests. Not Collective Input Parameter: . eps - the eigensolver context Output Parameters: + tol - the convergence tolerance - maxits - maximum number of iterations Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: EPSSetTolerances() @*/ PetscErrorCode EPSGetTolerances(EPS eps,PetscReal *tol,PetscInt *maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (tol) *tol = eps->tol; if (maxits) *maxits = eps->max_it; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetTolerances" /*@ EPSSetTolerances - Sets the tolerance and maximum iteration count used by the EPS convergence tests. Logically Collective on EPS Input Parameters: + eps - the eigensolver context . tol - the convergence tolerance - maxits - maximum number of iterations to use Options Database Keys: + -eps_tol - Sets the convergence tolerance - -eps_max_it - Sets the maximum number of iterations allowed Notes: Use PETSC_DEFAULT for either argument to assign a reasonably good value. Level: intermediate .seealso: EPSGetTolerances() @*/ PetscErrorCode EPSSetTolerances(EPS eps,PetscReal tol,PetscInt maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveReal(eps,tol,2); PetscValidLogicalCollectiveInt(eps,maxits,3); if (tol == PETSC_DEFAULT) { eps->tol = PETSC_DEFAULT; eps->state = EPS_STATE_INITIAL; } else { if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); eps->tol = tol; } if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) { eps->max_it = 0; eps->state = EPS_STATE_INITIAL; } else { if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0"); eps->max_it = maxits; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetDimensions" /*@ EPSGetDimensions - Gets the number of eigenvalues to compute and the dimension of the subspace. Not Collective Input Parameter: . eps - the eigensolver context Output Parameters: + nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Level: intermediate .seealso: EPSSetDimensions() @*/ PetscErrorCode EPSGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (nev) *nev = eps->nev; if (ncv) *ncv = eps->ncv; if (mpd) *mpd = eps->mpd; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetDimensions" /*@ EPSSetDimensions - Sets the number of eigenvalues to compute and the dimension of the subspace. Logically Collective on EPS Input Parameters: + eps - the eigensolver context . nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Options Database Keys: + -eps_nev - Sets the number of eigenvalues . -eps_ncv - Sets the dimension of the subspace - -eps_mpd - Sets the maximum projected dimension Notes: Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method. The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and (b) in cases where nev is large, the user sets mpd. The value of ncv should always be between nev and (nev+mpd), typically ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise a smaller value should be used. When computing all eigenvalues in an interval, see EPSSetInterval(), these parameters lose relevance, and tuning must be done with EPSKrylovSchurSetDimensions(). Level: intermediate .seealso: EPSGetDimensions(), EPSSetInterval(), EPSKrylovSchurSetDimensions() @*/ PetscErrorCode EPSSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,nev,2); PetscValidLogicalCollectiveInt(eps,ncv,3); PetscValidLogicalCollectiveInt(eps,mpd,4); if (nev<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0"); eps->nev = nev; if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) { eps->ncv = 0; } else { if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0"); eps->ncv = ncv; } if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) { eps->mpd = 0; } else { if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0"); eps->mpd = mpd; } eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetWhichEigenpairs" /*@ EPSSetWhichEigenpairs - Specifies which portion of the spectrum is to be sought. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() - which - the portion of the spectrum to be sought Possible values: The parameter 'which' can have one of these values + EPS_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default) . EPS_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude . EPS_LARGEST_REAL - largest real parts . EPS_SMALLEST_REAL - smallest real parts . EPS_LARGEST_IMAGINARY - largest imaginary parts . EPS_SMALLEST_IMAGINARY - smallest imaginary parts . EPS_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude) . EPS_TARGET_REAL - eigenvalues with real part closest to target . EPS_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target . EPS_ALL - all eigenvalues contained in a given interval or region - EPS_WHICH_USER - user defined ordering set with EPSSetEigenvalueComparison() Options Database Keys: + -eps_largest_magnitude - Sets largest eigenvalues in magnitude . -eps_smallest_magnitude - Sets smallest eigenvalues in magnitude . -eps_largest_real - Sets largest real parts . -eps_smallest_real - Sets smallest real parts . -eps_largest_imaginary - Sets largest imaginary parts . -eps_smallest_imaginary - Sets smallest imaginary parts . -eps_target_magnitude - Sets eigenvalues closest to target . -eps_target_real - Sets real parts closest to target . -eps_target_imaginary - Sets imaginary parts closest to target - -eps_all - Sets all eigenvalues in an interval or region Notes: Not all eigensolvers implemented in EPS account for all the possible values stated above. Also, some values make sense only for certain types of problems. If SLEPc is compiled for real numbers EPS_LARGEST_IMAGINARY and EPS_SMALLEST_IMAGINARY use the absolute value of the imaginary part for eigenvalue selection. The target is a scalar value provided with EPSSetTarget(). The criterion EPS_TARGET_IMAGINARY is available only in case PETSc and SLEPc have been built with complex scalars. EPS_ALL is intended for use in combination with an interval (see EPSSetInterval()), when all eigenvalues within the interval are requested, or in the context of the CISS solver for computing all eigenvalues in a region. In those cases, the number of eigenvalues is unknown, so the nev parameter has a different sense, see EPSSetDimensions(). Level: intermediate .seealso: EPSGetWhichEigenpairs(), EPSSetTarget(), EPSSetInterval(), EPSSetDimensions(), EPSSetEigenvalueComparison(), EPSWhich @*/ PetscErrorCode EPSSetWhichEigenpairs(EPS eps,EPSWhich which) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,which,2); switch (which) { case EPS_LARGEST_MAGNITUDE: case EPS_SMALLEST_MAGNITUDE: case EPS_LARGEST_REAL: case EPS_SMALLEST_REAL: case EPS_LARGEST_IMAGINARY: case EPS_SMALLEST_IMAGINARY: case EPS_TARGET_MAGNITUDE: case EPS_TARGET_REAL: #if defined(PETSC_USE_COMPLEX) case EPS_TARGET_IMAGINARY: #endif case EPS_ALL: case EPS_WHICH_USER: if (eps->which != which) { eps->state = EPS_STATE_INITIAL; eps->which = which; } break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetWhichEigenpairs" /*@ EPSGetWhichEigenpairs - Returns which portion of the spectrum is to be sought. Not Collective Input Parameter: . eps - eigensolver context obtained from EPSCreate() Output Parameter: . which - the portion of the spectrum to be sought Notes: See EPSSetWhichEigenpairs() for possible values of 'which'. Level: intermediate .seealso: EPSSetWhichEigenpairs(), EPSWhich @*/ PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(which,2); *which = eps->which; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetEigenvalueComparison" /*@C EPSSetEigenvalueComparison - Specifies the eigenvalue comparison function when EPSSetWhichEigenpairs() is set to EPS_WHICH_USER. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() . func - a pointer to the comparison function - ctx - a context pointer (the last parameter to the comparison function) Calling Sequence of func: $ func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx) + ar - real part of the 1st eigenvalue . ai - imaginary part of the 1st eigenvalue . br - real part of the 2nd eigenvalue . bi - imaginary part of the 2nd eigenvalue . res - result of comparison - ctx - optional context, as set by EPSSetEigenvalueComparison() Note: The returning parameter 'res' can be + negative - if the 1st eigenvalue is preferred to the 2st one . zero - if both eigenvalues are equally preferred - positive - if the 2st eigenvalue is preferred to the 1st one Level: advanced .seealso: EPSSetWhichEigenpairs(), EPSWhich @*/ PetscErrorCode EPSSetEigenvalueComparison(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); eps->sc->comparison = func; eps->sc->comparisonctx = ctx; eps->which = EPS_WHICH_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetArbitrarySelection" /*@C EPSSetArbitrarySelection - Specifies a function intended to look for eigenvalues according to an arbitrary selection criterion. This criterion can be based on a computation involving the current eigenvector approximation. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() . func - a pointer to the evaluation function - ctx - a context pointer (the last parameter to the evaluation function) Calling Sequence of func: $ func(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx) + er - real part of the current eigenvalue approximation . ei - imaginary part of the current eigenvalue approximation . xr - real part of the current eigenvector approximation . xi - imaginary part of the current eigenvector approximation . rr - result of evaluation (real part) . ri - result of evaluation (imaginary part) - ctx - optional context, as set by EPSSetArbitrarySelection() Notes: This provides a mechanism to select eigenpairs by evaluating a user-defined function. When a function has been provided, the default selection based on sorting the eigenvalues is replaced by the sorting of the results of this function (with the same sorting criterion given in EPSSetWhichEigenpairs()). For instance, suppose you want to compute those eigenvectors that maximize a certain computable expression. Then implement the computation using the arguments xr and xi, and return the result in rr. Then set the standard sorting by magnitude so that the eigenpair with largest value of rr is selected. This evaluation function is collective, that is, all processes call it and it can use collective operations; furthermore, the computed result must be the same in all processes. The result of func is expressed as a complex number so that it is possible to use the standard eigenvalue sorting functions, but normally only rr is used. Set ri to zero unless it is meaningful in your application. Level: advanced .seealso: EPSSetWhichEigenpairs() @*/ PetscErrorCode EPSSetArbitrarySelection(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*),void* ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); eps->arbitrary = func; eps->arbitraryctx = ctx; eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetConvergenceTestFunction" /*@C EPSSetConvergenceTestFunction - Sets a function to compute the error estimate used in the convergence test. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() . func - a pointer to the convergence test function . ctx - context for private data for the convergence routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) + eps - eigensolver context obtained from EPSCreate() . eigr - real part of the eigenvalue . eigi - imaginary part of the eigenvalue . res - residual norm associated to the eigenpair . errest - (output) computed error estimate - ctx - optional context, as set by EPSSetConvergenceTestFunction() Note: If the error estimate returned by the convergence test function is less than the tolerance, then the eigenvalue is accepted as converged. Level: advanced .seealso: EPSSetConvergenceTest(), EPSSetTolerances() @*/ PetscErrorCode EPSSetConvergenceTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (eps->convergeddestroy) { ierr = (*eps->convergeddestroy)(eps->convergedctx);CHKERRQ(ierr); } eps->converged = func; eps->convergeddestroy = destroy; eps->convergedctx = ctx; if (func == EPSConvergedRelative) eps->conv = EPS_CONV_REL; else if (func == EPSConvergedNorm) eps->conv = EPS_CONV_NORM; else if (func == EPSConvergedAbsolute) eps->conv = EPS_CONV_ABS; else eps->conv = EPS_CONV_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetConvergenceTest" /*@ EPSSetConvergenceTest - Specifies how to compute the error estimate used in the convergence test. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() - conv - the type of convergence test Options Database Keys: + -eps_conv_abs - Sets the absolute convergence test . -eps_conv_rel - Sets the convergence test relative to the eigenvalue . -eps_conv_norm - Sets the convergence test relative to the matrix norms - -eps_conv_user - Selects the user-defined convergence test Note: The parameter 'conv' can have one of these values + EPS_CONV_ABS - absolute error ||r|| . EPS_CONV_REL - error relative to the eigenvalue l, ||r||/|l| . EPS_CONV_NORM - error relative to the matrix norms, ||r||/(||A||+|l|*||B||) - EPS_CONV_USER - function set by EPSSetConvergenceTestFunction() Level: intermediate .seealso: EPSGetConvergenceTest(), EPSSetConvergenceTestFunction(), EPSSetStoppingTest(), EPSConv @*/ PetscErrorCode EPSSetConvergenceTest(EPS eps,EPSConv conv) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,conv,2); switch (conv) { case EPS_CONV_ABS: eps->converged = EPSConvergedAbsolute; break; case EPS_CONV_REL: eps->converged = EPSConvergedRelative; break; case EPS_CONV_NORM: eps->converged = EPSConvergedNorm; break; case EPS_CONV_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value"); } eps->conv = conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetConvergenceTest" /*@ EPSGetConvergenceTest - Gets the method used to compute the error estimate used in the convergence test. Not Collective Input Parameters: . eps - eigensolver context obtained from EPSCreate() Output Parameters: . conv - the type of convergence test Level: intermediate .seealso: EPSSetConvergenceTest(), EPSConv @*/ PetscErrorCode EPSGetConvergenceTest(EPS eps,EPSConv *conv) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(conv,2); *conv = eps->conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetStoppingTestFunction" /*@C EPSSetStoppingTestFunction - Sets a function to decide when to stop the outer iteration of the eigensolver. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() . func - pointer to the stopping test function . ctx - context for private data for the stopping routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx) + eps - eigensolver context obtained from EPSCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged eigenpairs . nev - number of requested eigenpairs . reason - (output) result of the stopping test - ctx - optional context, as set by EPSSetStoppingTestFunction() Note: Normal usage is to first call the default routine EPSStoppingBasic() and then set reason to EPS_CONVERGED_USER if some user-defined conditions have been met. To let the eigensolver continue iterating, the result must be left as EPS_CONVERGED_ITERATING. Level: advanced .seealso: EPSSetStoppingTest(), EPSStoppingBasic() @*/ PetscErrorCode EPSSetStoppingTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (eps->stoppingdestroy) { ierr = (*eps->stoppingdestroy)(eps->stoppingctx);CHKERRQ(ierr); } eps->stopping = func; eps->stoppingdestroy = destroy; eps->stoppingctx = ctx; if (func == EPSStoppingBasic) eps->stop = EPS_STOP_BASIC; else eps->stop = EPS_STOP_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetStoppingTest" /*@ EPSSetStoppingTest - Specifies how to decide the termination of the outer loop of the eigensolver. Logically Collective on EPS Input Parameters: + eps - eigensolver context obtained from EPSCreate() - stop - the type of stopping test Options Database Keys: + -eps_stop_basic - Sets the default stopping test - -eps_stop_user - Selects the user-defined stopping test Note: The parameter 'stop' can have one of these values + EPS_STOP_BASIC - default stopping test - EPS_STOP_USER - function set by EPSSetStoppingTestFunction() Level: advanced .seealso: EPSGetStoppingTest(), EPSSetStoppingTestFunction(), EPSSetConvergenceTest(), EPSStop @*/ PetscErrorCode EPSSetStoppingTest(EPS eps,EPSStop stop) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,stop,2); switch (stop) { case EPS_STOP_BASIC: eps->stopping = EPSStoppingBasic; break; case EPS_STOP_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value"); } eps->stop = stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetStoppingTest" /*@ EPSGetStoppingTest - Gets the method used to decide the termination of the outer loop of the eigensolver. Not Collective Input Parameters: . eps - eigensolver context obtained from EPSCreate() Output Parameters: . stop - the type of stopping test Level: advanced .seealso: EPSSetStoppingTest(), EPSStop @*/ PetscErrorCode EPSGetStoppingTest(EPS eps,EPSStop *stop) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(stop,2); *stop = eps->stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetProblemType" /*@ EPSSetProblemType - Specifies the type of the eigenvalue problem. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - type - a known type of eigenvalue problem Options Database Keys: + -eps_hermitian - Hermitian eigenvalue problem . -eps_gen_hermitian - generalized Hermitian eigenvalue problem . -eps_non_hermitian - non-Hermitian eigenvalue problem . -eps_gen_non_hermitian - generalized non-Hermitian eigenvalue problem - -eps_pos_gen_non_hermitian - generalized non-Hermitian eigenvalue problem with positive semi-definite B Notes: Allowed values for the problem type are: Hermitian (EPS_HEP), non-Hermitian (EPS_NHEP), generalized Hermitian (EPS_GHEP), generalized non-Hermitian (EPS_GNHEP), generalized non-Hermitian with positive semi-definite B (EPS_PGNHEP), and generalized Hermitian-indefinite (EPS_GHIEP). This function must be used to instruct SLEPc to exploit symmetry. If no problem type is specified, by default a non-Hermitian problem is assumed (either standard or generalized). If the user knows that the problem is Hermitian (i.e. A=A^H) or generalized Hermitian (i.e. A=A^H, B=B^H, and B positive definite) then it is recommended to set the problem type so that eigensolver can exploit these properties. Level: intermediate .seealso: EPSSetOperators(), EPSSetType(), EPSGetProblemType(), EPSProblemType @*/ PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,type,2); if (type == eps->problem_type) PetscFunctionReturn(0); switch (type) { case EPS_HEP: eps->isgeneralized = PETSC_FALSE; eps->ishermitian = PETSC_TRUE; eps->ispositive = PETSC_FALSE; break; case EPS_NHEP: eps->isgeneralized = PETSC_FALSE; eps->ishermitian = PETSC_FALSE; eps->ispositive = PETSC_FALSE; break; case EPS_GHEP: eps->isgeneralized = PETSC_TRUE; eps->ishermitian = PETSC_TRUE; eps->ispositive = PETSC_TRUE; break; case EPS_GNHEP: eps->isgeneralized = PETSC_TRUE; eps->ishermitian = PETSC_FALSE; eps->ispositive = PETSC_FALSE; break; case EPS_PGNHEP: eps->isgeneralized = PETSC_TRUE; eps->ishermitian = PETSC_FALSE; eps->ispositive = PETSC_TRUE; break; case EPS_GHIEP: eps->isgeneralized = PETSC_TRUE; eps->ishermitian = PETSC_TRUE; eps->ispositive = PETSC_FALSE; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type"); } eps->problem_type = type; eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetProblemType" /*@ EPSGetProblemType - Gets the problem type from the EPS object. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . type - name of EPS problem type Level: intermediate .seealso: EPSSetProblemType(), EPSProblemType @*/ PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(type,2); *type = eps->problem_type; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetExtraction" /*@ EPSSetExtraction - Specifies the type of extraction technique to be employed by the eigensolver. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - extr - a known type of extraction Options Database Keys: + -eps_ritz - Rayleigh-Ritz extraction . -eps_harmonic - harmonic Ritz extraction . -eps_harmonic_relative - harmonic Ritz extraction relative to the eigenvalue . -eps_harmonic_right - harmonic Ritz extraction for rightmost eigenvalues . -eps_harmonic_largest - harmonic Ritz extraction for largest magnitude (without target) . -eps_refined - refined Ritz extraction - -eps_refined_harmonic - refined harmonic Ritz extraction Notes: Not all eigensolvers support all types of extraction. See the SLEPc Users Manual for details. By default, a standard Rayleigh-Ritz extraction is used. Other extractions may be useful when computing interior eigenvalues. Harmonic-type extractions are used in combination with a 'target'. Level: advanced .seealso: EPSSetTarget(), EPSGetExtraction(), EPSExtraction @*/ PetscErrorCode EPSSetExtraction(EPS eps,EPSExtraction extr) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,extr,2); eps->extraction = extr; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetExtraction" /*@ EPSGetExtraction - Gets the extraction type used by the EPS object. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . extr - name of extraction type Level: advanced .seealso: EPSSetExtraction(), EPSExtraction @*/ PetscErrorCode EPSGetExtraction(EPS eps,EPSExtraction *extr) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(extr,2); *extr = eps->extraction; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetBalance" /*@ EPSSetBalance - Specifies the balancing technique to be employed by the eigensolver, and some parameters associated to it. Logically Collective on EPS Input Parameters: + eps - the eigensolver context . bal - the balancing method, one of EPS_BALANCE_NONE, EPS_BALANCE_ONESIDE, EPS_BALANCE_TWOSIDE, or EPS_BALANCE_USER . its - number of iterations of the balancing algorithm - cutoff - cutoff value Options Database Keys: + -eps_balance - the balancing method, where is one of 'none', 'oneside', 'twoside', or 'user' . -eps_balance_its - number of iterations - -eps_balance_cutoff - cutoff value Notes: When balancing is enabled, the solver works implicitly with matrix DAD^-1, where D is an appropriate diagonal matrix. This improves the accuracy of the computed results in some cases. See the SLEPc Users Manual for details. Balancing makes sense only for non-Hermitian problems when the required precision is high (i.e. a small tolerance such as 1e-15). By default, balancing is disabled. The two-sided method is much more effective than the one-sided counterpart, but it requires the system matrices to have the MatMultTranspose operation defined. The parameter 'its' is the number of iterations performed by the method. The cutoff value is used only in the two-side variant. Use PETSC_DEFAULT to assign a reasonably good value. User-defined balancing is allowed provided that the corresponding matrix is set via STSetBalanceMatrix. Level: intermediate .seealso: EPSGetBalance(), EPSBalance, STSetBalanceMatrix() @*/ PetscErrorCode EPSSetBalance(EPS eps,EPSBalance bal,PetscInt its,PetscReal cutoff) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,bal,2); PetscValidLogicalCollectiveInt(eps,its,3); PetscValidLogicalCollectiveReal(eps,cutoff,4); switch (bal) { case EPS_BALANCE_NONE: case EPS_BALANCE_ONESIDE: case EPS_BALANCE_TWOSIDE: case EPS_BALANCE_USER: eps->balance = bal; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid value of argument 'bal'"); } if (its==PETSC_DECIDE || its==PETSC_DEFAULT) eps->balance_its = 5; else { if (its <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be > 0"); eps->balance_its = its; } if (cutoff==PETSC_DECIDE || cutoff==PETSC_DEFAULT) eps->balance_cutoff = 1e-8; else { if (cutoff <= 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of cutoff. Must be > 0"); eps->balance_cutoff = cutoff; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetBalance" /*@ EPSGetBalance - Gets the balancing type used by the EPS object, and the associated parameters. Not Collective Input Parameter: . eps - the eigensolver context Output Parameters: + bal - the balancing method . its - number of iterations of the balancing algorithm - cutoff - cutoff value Level: intermediate Note: The user can specify NULL for any parameter that is not needed. .seealso: EPSSetBalance(), EPSBalance @*/ PetscErrorCode EPSGetBalance(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (bal) *bal = eps->balance; if (its) *its = eps->balance_its; if (cutoff) *cutoff = eps->balance_cutoff; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetTrueResidual" /*@ EPSSetTrueResidual - Specifies if the solver must compute the true residual explicitly or not. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - trueres - whether true residuals are required or not Options Database Keys: . -eps_true_residual - Sets/resets the boolean flag 'trueres' Notes: If the user sets trueres=PETSC_TRUE then the solver explicitly computes the true residual for each eigenpair approximation, and uses it for convergence testing. Computing the residual is usually an expensive operation. Some solvers (e.g., Krylov solvers) can avoid this computation by using a cheap estimate of the residual norm, but this may sometimes give inaccurate results (especially if a spectral transform is being used). On the contrary, preconditioned eigensolvers (e.g., Davidson solvers) do rely on computing the true residual, so this option is irrelevant for them. Level: advanced .seealso: EPSGetTrueResidual() @*/ PetscErrorCode EPSSetTrueResidual(EPS eps,PetscBool trueres) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,trueres,2); eps->trueres = trueres; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetTrueResidual" /*@ EPSGetTrueResidual - Returns the flag indicating whether true residuals must be computed explicitly or not. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . trueres - the returned flag Level: advanced .seealso: EPSSetTrueResidual() @*/ PetscErrorCode EPSGetTrueResidual(EPS eps,PetscBool *trueres) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(trueres,2); *trueres = eps->trueres; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetTrackAll" /*@ EPSSetTrackAll - Specifies if the solver must compute the residual norm of all approximate eigenpairs or not. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - trackall - whether to compute all residuals or not Notes: If the user sets trackall=PETSC_TRUE then the solver computes (or estimates) the residual norm for each eigenpair approximation. Computing the residual is usually an expensive operation and solvers commonly compute only the residual associated to the first unconverged eigenpair. The options '-eps_monitor_all' and '-eps_monitor_lg_all' automatically activate this option. Level: developer .seealso: EPSGetTrackAll() @*/ PetscErrorCode EPSSetTrackAll(EPS eps,PetscBool trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,trackall,2); eps->trackall = trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetTrackAll" /*@ EPSGetTrackAll - Returns the flag indicating whether all residual norms must be computed or not. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . trackall - the returned flag Level: developer .seealso: EPSSetTrackAll() @*/ PetscErrorCode EPSGetTrackAll(EPS eps,PetscBool *trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(trackall,2); *trackall = eps->trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetPurify" /*@ EPSSetPurify - Deactivate eigenvector purification (which is activated by default). Logically Collective on EPS Input Parameters: + eps - the eigensolver context - purify - whether purification is required or not Options Database Keys: . -eps_purify - Sets/resets the boolean flag 'purify' Notes: By default, eigenvectors of generalized symmetric eigenproblems are purified in order to purge directions in the nullspace of matrix B. If the user knows that B is non-singular, then purification can be safely deactivated and some computational cost is avoided (this is particularly important in interval computations). Level: intermediate .seealso: EPSGetPurify(), EPSSetInterval() @*/ PetscErrorCode EPSSetPurify(EPS eps,PetscBool purify) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,purify,2); eps->purify = purify; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetPurify" /*@ EPSGetPurify - Returns the flag indicating whether purification is activated or not. Not Collective Input Parameter: . eps - the eigensolver context Output Parameter: . purify - the returned flag Level: intermediate .seealso: EPSSetPurify() @*/ PetscErrorCode EPSGetPurify(EPS eps,PetscBool *purify) { PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(purify,2); *purify = eps->purify; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetOptionsPrefix" /*@C EPSSetOptionsPrefix - Sets the prefix used for searching for all EPS options in the database. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - prefix - the prefix string to prepend to all EPS option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. For example, to distinguish between the runtime options for two different EPS contexts, one could call .vb EPSSetOptionsPrefix(eps1,"eig1_") EPSSetOptionsPrefix(eps2,"eig2_") .ve Level: advanced .seealso: EPSAppendOptionsPrefix(), EPSGetOptionsPrefix() @*/ PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } ierr = STSetOptionsPrefix(eps->st,prefix);CHKERRQ(ierr); if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(eps->V,prefix);CHKERRQ(ierr); if (!eps->ds) { ierr = EPSGetDS(eps,&eps->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(eps->ds,prefix);CHKERRQ(ierr); if (!eps->rg) { ierr = EPSGetRG(eps,&eps->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(eps->rg,prefix);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)eps,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSAppendOptionsPrefix" /*@C EPSAppendOptionsPrefix - Appends to the prefix used for searching for all EPS options in the database. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - prefix - the prefix string to prepend to all EPS option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: EPSSetOptionsPrefix(), EPSGetOptionsPrefix() @*/ PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } ierr = STAppendOptionsPrefix(eps->st,prefix);CHKERRQ(ierr); if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(eps->V,prefix);CHKERRQ(ierr); if (!eps->ds) { ierr = EPSGetDS(eps,&eps->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(eps->ds,prefix);CHKERRQ(ierr); if (!eps->rg) { ierr = EPSGetRG(eps,&eps->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(eps->rg,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)eps,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGetOptionsPrefix" /*@C EPSGetOptionsPrefix - Gets the prefix used for searching for all EPS options in the database. Not Collective Input Parameters: . eps - the eigensolver context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: EPSSetOptionsPrefix(), EPSAppendOptionsPrefix() @*/ PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)eps,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/0000755000175000017500000000000013107004621015357 5ustar jromanjromanslepc-3.7.4/src/eps/examples/makefile0000644000175000017500000000201713107004621017057 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/eps/examples/ DIRS = tests tutorials include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/examples/makefile.html0000644000175000017500000000442413107004621020026 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/eps/examples/
DIRS     = tests tutorials

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/examples/tutorials/0000755000175000017500000000000013107004621017405 5ustar jromanjromanslepc-3.7.4/src/eps/examples/tutorials/makefile0000644000175000017500000002712313107004621021112 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/eps/examples/tutorials/ EXAMPLESC = ex1.c ex2.c ex3.c ex4.c ex5.c ex7.c ex9.c ex10.c ex11.c ex12.c ex13.c \ ex18.c ex19.c ex24.c ex25.c ex29.c ex30.c ex31.c EXAMPLESF = ex1f.F ex1f90.F90 ex6f.F MANSEC = EPS TESTEXAMPLES_C = ex2.PETSc runex2_1 runex2_ciss_1 runex2_ciss_2 ex2.rm \ ex3.PETSc runex3_1 ex3.rm \ ex5.PETSc runex5_1 ex5.rm \ ex9.PETSc runex9_1 runex9_2 ex9.rm \ ex10.PETSc runex10_1 ex10.rm \ ex11.PETSc runex11_1 ex11.rm \ ex12.PETSc runex12_1 ex12.rm \ ex13.PETSc runex13_1 ex13.rm \ ex18.PETSc runex18_1 ex18.rm \ ex24.PETSc runex24_1 ex24.rm \ ex29.PETSc runex29_1 ex29.rm \ ex30.PETSc runex30_1 ex30.rm TESTEXAMPLES_C_NOCOMPLEX = ex4.PETSc runex4_1 ex4.rm \ ex7.PETSc runex7_1 ex7.rm \ ex25.PETSc runex25_1 ex25.rm \ ex31.PETSc runex31_1 ex31.rm TESTEXAMPLES_FORTRAN_NOCOMPLEX = ex6f.PETSc runex6f_1 ex6f.rm TESTEXAMPLES_F90 = ex1f90.PETSc runex1f90_1 ex1f90.rm TESTEXAMPLES_DATAFILESPATH_COMPLEX = ex4.PETSc runex4_ciss_1 ex4.rm \ ex7.PETSc runex7_ciss_1 ex7.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common ex1: ex1.o chkopts -${CLINKER} -o ex1 ex1.o ${SLEPC_EPS_LIB} ${RM} ex1.o ex1f: ex1f.o chkopts -${FLINKER} -o ex1f ex1f.o ${SLEPC_EPS_LIB} ${RM} ex1f.o ex1f90: ex1f90.o chkopts -${FLINKER} -o ex1f90 ex1f90.o ${SLEPC_EPS_LIB} ${RM} ex1f90.o ex2: ex2.o chkopts -${CLINKER} -o ex2 ex2.o ${SLEPC_EPS_LIB} ${RM} ex2.o ex3: ex3.o chkopts -${CLINKER} -o ex3 ex3.o ${SLEPC_EPS_LIB} ${RM} ex3.o ex4: ex4.o chkopts -${CLINKER} -o ex4 ex4.o ${SLEPC_EPS_LIB} ${RM} ex4.o ex5: ex5.o chkopts -${CLINKER} -o ex5 ex5.o ${SLEPC_EPS_LIB} ${RM} ex5.o ex6f: ex6f.o chkopts -${FLINKER} -o ex6f ex6f.o ${SLEPC_EPS_LIB} ${RM} ex6f.o ex7: ex7.o chkopts -${CLINKER} -o ex7 ex7.o ${SLEPC_EPS_LIB} ${RM} ex7.o ex9: ex9.o chkopts -${CLINKER} -o ex9 ex9.o ${SLEPC_EPS_LIB} ${RM} ex9.o ex10: ex10.o chkopts -${CLINKER} -o ex10 ex10.o ${SLEPC_EPS_LIB} ${RM} ex10.o ex11: ex11.o chkopts -${CLINKER} -o ex11 ex11.o ${SLEPC_EPS_LIB} ${RM} ex11.o ex12: ex12.o chkopts -${CLINKER} -o ex12 ex12.o ${SLEPC_EPS_LIB} ${RM} ex12.o ex13: ex13.o chkopts -${CLINKER} -o ex13 ex13.o ${SLEPC_EPS_LIB} ${RM} ex13.o ex18: ex18.o chkopts -${CLINKER} -o ex18 ex18.o ${SLEPC_EPS_LIB} ${RM} ex18.o ex19: ex19.o chkopts -${CLINKER} -o ex19 ex19.o ${SLEPC_EPS_LIB} ${RM} ex19.o ex24: ex24.o chkopts -${CLINKER} -o ex24 ex24.o ${SLEPC_EPS_LIB} ${RM} ex24.o ex25: ex25.o chkopts -${CLINKER} -o ex25 ex25.o ${SLEPC_EPS_LIB} ${RM} ex25.o ex29: ex29.o chkopts -${CLINKER} -o ex29 ex29.o ${SLEPC_EPS_LIB} ${RM} ex29.o ex30: ex30.o chkopts -${CLINKER} -o ex30 ex30.o ${SLEPC_EPS_LIB} ${RM} ex30.o ex31: ex31.o chkopts -${CLINKER} -o ex31 ex31.o ${SLEPC_EPS_LIB} ${RM} ex31.o #------------------------------------------------------------------------------------ DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices runex1_1: -@${MPIEXEC} -n 1 ./ex1 > ex1_1.tmp 2>&1; \ if (${DIFF} output/ex1_1.out ex1_1.tmp) then true; \ else echo "Possible problem with ex1_1, diffs above"; fi; \ ${RM} -f ex1_1.tmp runex1f_1: -@${MPIEXEC} -n 1 ./ex1f > ex1f_1.tmp 2>&1; \ if (${DIFF} output/ex1f_1.out ex1f_1.tmp) then true; \ else echo "Possible problem with ex1f_1, diffs above"; fi; \ ${RM} -f ex1f_1.tmp runex1f90_1: -@${MPIEXEC} -n 1 ./ex1f90 -eps_nev 4 -terse > ex1f90_1.tmp 2>&1; \ if (${DIFF} output/ex1f90_1.out ex1f90_1.tmp) then true; \ else echo "Possible problem with ex1f90_1, diffs above"; fi; \ ${RM} -f ex1f90_1.tmp runex2_1: -@${MPIEXEC} -n 1 ./ex2 -eps_nev 4 -terse > ex2_1.tmp 2>&1; \ if (${DIFF} output/ex2_1.out ex2_1.tmp) then true; \ else echo "Possible problem with ex2_1, diffs above"; fi; \ ${RM} -f ex2_1.tmp runex2_ciss_1: -@if [ "${PETSC_PRECISION}" != "double" ]; then \ echo "Skipping ex2_ciss_1 test"; \ else \ ${MPIEXEC} -n 1 ./ex2 -n 30 -eps_type ciss -rg_type interval -rg_interval_endpoints 1.1,1.25 -terse > ex2_ciss.tmp 2>&1; \ if (${DIFF} output/ex2_ciss.out ex2_ciss.tmp) then true; \ else echo "Possible problem with ex2_ciss_1, diffs above"; fi; \ ${RM} -f ex2_ciss.tmp; \ fi runex2_ciss_2: -@if [ "${PETSC_PRECISION}" != "double" ]; then \ echo "Skipping ex2_ciss_2 test"; \ else \ ${MPIEXEC} -n 2 ./ex2 -n 30 -eps_type ciss -rg_type ellipse -rg_ellipse_center 1.175 -rg_ellipse_radius 0.075 -eps_ciss_partitions 2 -terse > ex2_ciss.tmp 2>&1; \ if (${DIFF} output/ex2_ciss.out ex2_ciss.tmp) then true; \ else echo "Possible problem with ex2_ciss_2, diffs above"; fi; \ ${RM} -f ex2_ciss.tmp; \ fi runex3_1: -@${MPIEXEC} -n 1 ./ex3 -eps_nev 4 -terse > ex3_1.tmp 2>&1; \ if (${DIFF} output/ex3_1.out ex3_1.tmp) then true; \ else echo "Possible problem with ex3_1, diffs above"; fi; \ ${RM} -f ex3_1.tmp runex4_1: -@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ echo "Skipping ex4 test"; \ else \ ${MPIEXEC} -n 1 ./ex4 -file ${DATAPATH}/rdb200.petsc -eps_nev 4 -terse > ex4_1.tmp 2>&1; \ if (${DIFF} output/ex4_1.out ex4_1.tmp) then true; \ else echo "Possible problem with ex4_1, diffs above"; fi; \ ${RM} -f ex4_1.tmp; \ fi runex4_ciss_1: -@${MPIEXEC} -n 1 ./ex4 -file $(DATAFILESPATH)/matrices/complex/qc324.petsc -eps_type ciss -rg_type ellipse -rg_ellipse_center -.012-.08i -rg_ellipse_radius .05 -terse > ex4_ciss_1.tmp 2>&1; \ if (${DIFF} output/ex4_ciss_1.out ex4_ciss_1.tmp) then true; \ else echo "Possible problem with ex4_ciss_1, diffs above"; fi; \ ${RM} -f ex4_ciss_1.tmp; runex5_1: -@${MPIEXEC} -n 1 ./ex5 -st_shift 1 -eps_nev 4 -terse > ex5_1.tmp 2>&1; \ if (${DIFF} output/ex5_1.out ex5_1.tmp) then true; \ else echo "Possible problem with ex5_1, diffs above"; fi; \ ${RM} -f ex5_1.tmp runex6f_1: -@${MPIEXEC} -n 1 ./ex6f -eps_max_it 1000 -eps_ncv 12 -eps_tol 1e-5 -eps_nev 4 -terse > ex6f_1.tmp 2>&1; \ if (${DIFF} output/ex6f_1.out ex6f_1.tmp) then true; \ else echo "Possible problem with ex6f_1, diffs above"; fi; \ ${RM} -f ex6f_1.tmp runex7_1: -@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ echo "Skipping ex7 test"; \ else \ ${MPIEXEC} -n 1 ./ex7 -f1 ${DATAPATH}/bfw62a.petsc -f2 ${DATAPATH}/bfw62b.petsc -eps_nev 4 -terse > ex7_1.tmp 2>&1; \ if (${DIFF} output/ex7_1.out ex7_1.tmp) then true; \ else echo "Possible problem with ex7_1, diffs above"; fi; \ ${RM} -f ex7_1.tmp; \ fi runex7_ciss_1: -@${MPIEXEC} -n 1 ./ex7 -f1 $(DATAFILESPATH)/matrices/complex/mhd1280a.petsc -f2 $(DATAFILESPATH)/matrices/complex/mhd1280b.petsc -eps_type ciss -eps_ciss_usest 0 -eps_ciss_quadrule chebyshev -rg_type ring -rg_ring_center 0 -rg_ring_radius .5 -rg_ring_width 0.2 -rg_ring_startangle .25 -rg_ring_endangle .5 -terse > ex7_ciss_1.tmp 2>&1; \ if (${DIFF} output/ex7_ciss_1.out ex7_ciss_1.tmp) then true; \ else echo "Possible problem with ex7_ciss_1, diffs above"; fi; \ ${RM} -f ex7_ciss_1.tmp; runex9_1: -@${MPIEXEC} -n 1 ./ex9 -eps_nev 4 -terse > ex9_1.tmp 2>&1; \ if (${DIFF} output/ex9_1.out ex9_1.tmp) then true; \ else echo "Possible problem with ex9_1, diffs above"; fi; \ ${RM} -f ex9_1.tmp runex9_2: -@${MPIEXEC} -n 1 ./ex9 -eps_nev 8 -eps_max_it 300 -eps_target -28 -rg_type interval -rg_interval_endpoints -40,-20,-.1,.1 -terse > ex9_2.tmp 2>&1; \ if (${DIFF} output/ex9_2.out ex9_2.tmp) then true; \ else echo "Possible problem with ex9_2, diffs above"; fi; \ ${RM} -f ex9_2.tmp runex10_1: -@${MPIEXEC} -n 1 ./ex10 -eps_nev 5 -st_type shell -terse > ex10_1.tmp 2>&1; \ if (${DIFF} output/ex10_1.out ex10_1.tmp) then true; \ else echo "Possible problem with ex10_1, diffs above"; fi; \ ${RM} -f ex10_1.tmp runex11_1: -@${MPIEXEC} -n 1 ./ex11 -eps_nev 4 -terse > ex11_1.tmp 2>&1; \ if (${DIFF} output/ex11_1.out ex11_1.tmp) then true; \ else echo "Possible problem with ex11_1, diffs above"; fi; \ ${RM} -f ex11_1.tmp runex12_1: -@${MPIEXEC} -n 1 ./ex12 -eps_krylovschur_nev 30 > ex12_1.tmp 2>&1; \ if (${DIFF} output/ex12_1.out ex12_1.tmp) then true; \ else echo "Possible problem with ex12_1, diffs above"; fi; \ ${RM} -f ex12_1.tmp runex13_1: -@${MPIEXEC} -n 1 ./ex13 -eps_nev 4 -terse > ex13_1.tmp 2>&1; \ if (${DIFF} output/ex13_1.out ex13_1.tmp) then true; \ else echo "Possible problem with ex13_1, diffs above"; fi; \ ${RM} -f ex13_1.tmp runex18_1: -@${MPIEXEC} -n 1 ./ex18 -eps_nev 4 -terse > ex18_1.tmp 2>&1; \ if (${DIFF} output/ex18_1.out ex18_1.tmp) then true; \ else echo "Possible problem with ex18_1, diffs above"; fi; \ ${RM} -f ex18_1.tmp runex19_1: -@${MPIEXEC} -n 1 ./ex19 -eps_nev 8 -eps_ncv 64 > ex19_1.tmp 2>&1; \ if (${DIFF} output/ex19_1.out ex19_1.tmp) then true; \ else echo "Possible problem with ex19_1, diffs above"; fi; \ ${RM} -f ex19_1.tmp runex24_1: -@${MPIEXEC} -n 1 ./ex24 -n 15 -eps_ncv 20 -terse > ex24_1.tmp 2>&1; \ if (${DIFF} output/ex24_1.out ex24_1.tmp) then true; \ else echo "Possible problem with ex24_1, diffs above"; fi; \ ${RM} -f ex24_1.tmp runex25_1: -@${MPIEXEC} -n 1 ./ex25 -terse > ex25_1.tmp 2>&1; \ if (${DIFF} output/ex25_1.out ex25_1.tmp) then true; \ else echo "Possible problem with ex25_1, diffs above"; fi; \ ${RM} -f ex25_1.tmp runex29_1: -@${MPIEXEC} -n 1 ./ex29 -m 350 > ex29_1.tmp 2>&1; \ if (${DIFF} output/ex29_1.out ex29_1.tmp) then true; \ else echo "Possible problem with ex29_1, diffs above"; fi; \ ${RM} -f ex29_1.tmp runex30_1: -@${MPIEXEC} -n 1 ./ex30 -n 100 -terse > ex30_1.tmp 2>&1; \ if (${DIFF} output/ex30_1.out ex30_1.tmp) then true; \ else echo "Possible problem with ex30_1, diffs above"; fi; \ ${RM} -f ex30_1.tmp runex31_1: -@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ echo "Skipping ex31 test"; \ else \ ${MPIEXEC} -n 1 ./ex31 -terse > ex31_1.tmp 2>&1; \ if (${DIFF} output/ex31_1.out ex31_1.tmp) then true; \ else echo "Possible problem with ex31_1, diffs above"; fi; \ ${RM} -f ex31_1.tmp; \ fi slepc-3.7.4/src/eps/examples/tutorials/ex30.c0000644000175000017500000002757613107004621020351 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Illustrates the use of a region for filtering; the number of wanted eigenvalues in not known a priori.\n\n" "The problem is the Brusselator wave model as in ex9.c.\n" "The command line options are:\n" " -n , where = block dimension of the 2x2 block matrix.\n" " -L , where = bifurcation parameter.\n" " -alpha , -beta , -delta1 , -delta2 ,\n" " where = model parameters.\n\n"; #include /* This example tries to compute all eigenvalues lying outside the real axis. This could be achieved by computing LARGEST_IMAGINARY eigenvalues, but here we take a different route: define a region of the complex plane where eigenvalues must be emphasized (eigenvalues outside the region are filtered out). In this case, we select the region as the complement of a thin stripe around the real axis. */ PetscErrorCode MatMult_Brussel(Mat,Vec,Vec); PetscErrorCode MatShift_Brussel(PetscScalar*,Mat); PetscErrorCode MatGetDiagonal_Brussel(Mat,Vec); PetscErrorCode MyStoppingTest(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*); typedef struct { Mat T; Vec x1,x2,y1,y2; PetscScalar alpha,beta,tau1,tau2,sigma; PetscInt lastnconv; /* last value of nconv; used in stopping test */ PetscInt nreps; /* number of repetitions of nconv; used in stopping test */ } CTX_BRUSSEL; #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* eigenvalue problem matrix */ EPS eps; /* eigenproblem solver context */ RG rg; /* region object */ PetscScalar delta1,delta2,L,h; PetscInt N=30,n,i,Istart,Iend,mpd; CTX_BRUSSEL *ctx; PetscBool terse; PetscViewer viewer; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nBrusselator wave model, n=%D\n\n",N);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Generate the matrix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create shell matrix context and set default parameters */ ierr = PetscNew(&ctx);CHKERRQ(ierr); ctx->alpha = 2.0; ctx->beta = 5.45; delta1 = 0.008; delta2 = 0.004; L = 0.51302; /* Look the command line for user-provided parameters */ ierr = PetscOptionsGetScalar(NULL,NULL,"-L",&L,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-alpha",&ctx->alpha,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-beta",&ctx->beta,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-delta1",&delta1,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-delta2",&delta2,NULL);CHKERRQ(ierr); /* Create matrix T */ ierr = MatCreate(PETSC_COMM_WORLD,&ctx->T);CHKERRQ(ierr); ierr = MatSetSizes(ctx->T,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(ctx->T);CHKERRQ(ierr); ierr = MatSetUp(ctx->T);CHKERRQ(ierr); ierr = MatGetOwnershipRange(ctx->T,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(ctx->T,i,i-1,1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iT,i,i+1,1.0,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(ctx->T,i,i,-2.0,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatAssemblyBegin(ctx->T,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(ctx->T,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->T,&n,NULL);CHKERRQ(ierr); /* Fill the remaining information in the shell matrix context and create auxiliary vectors */ h = 1.0 / (PetscReal)(N+1); ctx->tau1 = delta1 / ((h*L)*(h*L)); ctx->tau2 = delta2 / ((h*L)*(h*L)); ctx->sigma = 0.0; ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x2);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y2);CHKERRQ(ierr); /* Create the shell matrix */ ierr = MatCreateShell(PETSC_COMM_WORLD,2*n,2*n,2*N,2*N,(void*)ctx,&A);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Brussel);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_SHIFT,(void(*)())MatShift_Brussel);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Brussel);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and configure the region - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); /* Define the region containing the eigenvalues of interest */ ierr = EPSGetRG(eps,&rg);CHKERRQ(ierr); ierr = RGSetType(rg,RGINTERVAL);CHKERRQ(ierr); ierr = RGIntervalSetEndpoints(rg,-PETSC_INFINITY,PETSC_INFINITY,-0.01,0.01);CHKERRQ(ierr); ierr = RGSetComplement(rg,PETSC_TRUE);CHKERRQ(ierr); /* sort eigenvalue approximations wrt a target, otherwise convergence will be erratic */ ierr = EPSSetTarget(eps,0.0);CHKERRQ(ierr); ierr = EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);CHKERRQ(ierr); /* Set solver options. In particular, we must allocate sufficient storage for all eigenpairs that may converge (ncv). This is application-dependent. */ mpd = 40; ierr = EPSSetDimensions(eps,2*mpd,3*mpd,mpd);CHKERRQ(ierr); ierr = EPSSetTolerances(eps,1e-7,2000);CHKERRQ(ierr); ctx->lastnconv = 0; ctx->nreps = 0; ierr = EPSSetStoppingTestFunction(eps,MyStoppingTest,(void*)ctx,NULL);CHKERRQ(ierr); ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem and display solution - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* show detailed info unless -terse option is given by user */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSReasonView(eps,viewer);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (!terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);CHKERRQ(ierr); } ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = MatDestroy(&ctx->T);CHKERRQ(ierr); ierr = VecDestroy(&ctx->x1);CHKERRQ(ierr); ierr = VecDestroy(&ctx->x2);CHKERRQ(ierr); ierr = VecDestroy(&ctx->y1);CHKERRQ(ierr); ierr = VecDestroy(&ctx->y2);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMult_Brussel" PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y) { PetscInt n; const PetscScalar *px; PetscScalar *py; CTX_BRUSSEL *ctx; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->T,&n,NULL);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->x2,px+n);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->y2,py+n);CHKERRQ(ierr); ierr = MatMult(ctx->T,ctx->x1,ctx->y1);CHKERRQ(ierr); ierr = VecScale(ctx->y1,ctx->tau1);CHKERRQ(ierr); ierr = VecAXPY(ctx->y1,ctx->beta - 1.0 + ctx->sigma,ctx->x1);CHKERRQ(ierr); ierr = VecAXPY(ctx->y1,ctx->alpha * ctx->alpha,ctx->x2);CHKERRQ(ierr); ierr = MatMult(ctx->T,ctx->x2,ctx->y2);CHKERRQ(ierr); ierr = VecScale(ctx->y2,ctx->tau2);CHKERRQ(ierr); ierr = VecAXPY(ctx->y2,-ctx->beta,ctx->x1);CHKERRQ(ierr); ierr = VecAXPY(ctx->y2,-ctx->alpha * ctx->alpha + ctx->sigma,ctx->x2);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatShift_Brussel" PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y) { CTX_BRUSSEL *ctx; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(Y,(void**)&ctx);CHKERRQ(ierr); ctx->sigma += *a; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatGetDiagonal_Brussel" PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag) { Vec d1,d2; PetscInt n; PetscScalar *pd; MPI_Comm comm; CTX_BRUSSEL *ctx; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = PetscObjectGetComm((PetscObject)A,&comm);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->T,&n,NULL);CHKERRQ(ierr); ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd,&d1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd+n,&d2);CHKERRQ(ierr); ierr = VecSet(d1,-2.0*ctx->tau1 + ctx->beta - 1.0 + ctx->sigma);CHKERRQ(ierr); ierr = VecSet(d2,-2.0*ctx->tau2 - ctx->alpha*ctx->alpha + ctx->sigma);CHKERRQ(ierr); ierr = VecDestroy(&d1);CHKERRQ(ierr); ierr = VecDestroy(&d2);CHKERRQ(ierr); ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MyStoppingTest" /* Function for user-defined stopping test. Ignores the value of nev. It only takes into account the number of eigenpairs that have converged in recent outer iterations (restarts); if no new eigenvalus have converged in the last few restarts, we stop the iteration, assuming that no more eigenvalues are present inside the region. */ PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ptr) { PetscErrorCode ierr; CTX_BRUSSEL *ctx = (CTX_BRUSSEL*)ptr; PetscFunctionBeginUser; /* check usual termination conditions, but ignoring the case nconv>=nev */ ierr = EPSStoppingBasic(eps,its,max_it,nconv,PETSC_MAX_INT,reason,NULL);CHKERRQ(ierr); if (*reason==EPS_CONVERGED_ITERATING) { /* check if nconv is the same as before */ if (nconv==ctx->lastnconv) ctx->nreps++; else { ctx->lastnconv = nconv; ctx->nreps = 0; } /* check if no eigenvalues converged in last 10 restarts */ if (nconv && ctx->nreps>10) *reason = EPS_CONVERGED_USER; } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tutorials/ex11.c.html0000644000175000017500000003031413107004621021273 0ustar jromanjroman
Actual source code: ex11.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\n\n"
 23:   "This example illustrates EPSSetDeflationSpace(). The example graph corresponds to a "
 24:   "2-D regular mesh. The command line options are:\n"
 25:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n\n";

 28: #include <slepceps.h>

 32: int main (int argc,char **argv)
 33: {
 34:   EPS            eps;             /* eigenproblem solver context */
 35:   Mat            A;               /* operator matrix */
 36:   Vec            x;
 37:   EPSType        type;
 38:   PetscInt       N,n=10,m,i,j,II,Istart,Iend,nev;
 39:   PetscScalar    w;
 40:   PetscBool      flag,terse;

 43:   SlepcInitialize(&argc,&argv,(char*)0,help);

 45:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 46:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 47:   if (!flag) m=n;
 48:   N = n*m;
 49:   PetscPrintf(PETSC_COMM_WORLD,"\nFiedler vector of a 2-D regular mesh, N=%D (%Dx%D grid)\n\n",N,n,m);

 51:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 52:      Compute the operator matrix that defines the eigensystem, Ax=kx
 53:      In this example, A = L(G), where L is the Laplacian of graph G, i.e.
 54:      Lii = degree of node i, Lij = -1 if edge (i,j) exists in G
 55:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 57:   MatCreate(PETSC_COMM_WORLD,&A);
 58:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 59:   MatSetFromOptions(A);
 60:   MatSetUp(A);

 62:   MatGetOwnershipRange(A,&Istart,&Iend);
 63:   for (II=Istart;II<Iend;II++) {
 64:     i = II/n; j = II-i*n;
 65:     w = 0.0;
 66:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); w=w+1.0; }
 67:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); w=w+1.0; }
 68:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); w=w+1.0; }
 69:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); w=w+1.0; }
 70:     MatSetValue(A,II,II,w,INSERT_VALUES);
 71:   }

 73:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 74:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 76:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 77:                 Create the eigensolver and set various options
 78:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 80:   /*
 81:      Create eigensolver context
 82:   */
 83:   EPSCreate(PETSC_COMM_WORLD,&eps);

 85:   /*
 86:      Set operators. In this case, it is a standard eigenvalue problem
 87:   */
 88:   EPSSetOperators(eps,A,NULL);
 89:   EPSSetProblemType(eps,EPS_HEP);

 91:   /*
 92:      Select portion of spectrum
 93:   */
 94:   EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);

 96:   /*
 97:      Set solver parameters at runtime
 98:   */
 99:   EPSSetFromOptions(eps);

101:   /*
102:      Attach deflation space: in this case, the matrix has a constant
103:      nullspace, [1 1 ... 1]^T is the eigenvector of the zero eigenvalue
104:   */
105:   MatCreateVecs(A,&x,NULL);
106:   VecSet(x,1.0);
107:   EPSSetDeflationSpace(eps,1,&x);
108:   VecDestroy(&x);

110:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111:                       Solve the eigensystem
112:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

114:   EPSSolve(eps);

116:   /*
117:      Optional: Get some information from the solver and display it
118:   */
119:   EPSGetType(eps,&type);
120:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
121:   EPSGetDimensions(eps,&nev,NULL,NULL);
122:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

124:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
125:                     Display solution and clean up
126:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

128:   /* show detailed info unless -terse option is given by user */
129:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
130:   if (terse) {
131:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
132:   } else {
133:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
134:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
135:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
136:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
137:   }
138:   EPSDestroy(&eps);
139:   MatDestroy(&A);
140:   SlepcFinalize();
141:   return ierr;
142: }

slepc-3.7.4/src/eps/examples/tutorials/ex1f.F.html0000644000175000017500000003515413107004621021332 0ustar jromanjroman
Actual source code: ex1f.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./ex1f [-help] [-n <n>] [all SLEPc options] 
 21: !
 22: !  Description: Simple example that solves an eigensystem with the EPS object.
 23: !  The standard symmetric eigenvalue problem to be solved corresponds to the 
 24: !  Laplacian operator in 1 dimension. 
 25: !
 26: !  The command line options are:
 27: !    -n <n>, where <n> = number of grid points = matrix size
 28: !
 29: ! ---------------------------------------------------------------------- 
 30: !
 31:       program main
 32:       implicit none

 34: #include <petsc/finclude/petscsys.h>
 35: #include <petsc/finclude/petscvec.h>
 36: #include <petsc/finclude/petscmat.h>
 37: #include <slepc/finclude/slepcsys.h>
 38: #include <slepc/finclude/slepceps.h>

 40: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 41: !     Declarations
 42: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 43: !
 44: !  Variables:
 45: !     A     operator matrix
 46: !     eps   eigenproblem solver context

 48:       Mat            A
 49:       EPS            eps
 50:       EPSType        tname
 51:       PetscReal      tol, error
 52:       PetscScalar    kr, ki
 53:       Vec            xr, xi
 54:       PetscInt       n, i, Istart, Iend
 55:       PetscInt       nev, maxit, its, nconv
 56:       PetscInt       col(3)
 57:       PetscInt       i1,i2,i3
 58:       PetscMPIInt    rank
 59:       PetscErrorCode ierr
 60:       PetscBool      flg
 61:       PetscScalar    value(3)

 63: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 64: !     Beginning of program
 65: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 67:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 68:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 69:       n = 30
 70:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 71:      &                        '-n',n,flg,ierr)

 73:       if (rank .eq. 0) then
 74:         write(*,100) n
 75:       endif
 76:  100  format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')

 78: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 79: !     Compute the operator matrix that defines the eigensystem, Ax=kx
 80: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 82:       call MatCreate(PETSC_COMM_WORLD,A,ierr)
 83:       call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
 84:       call MatSetFromOptions(A,ierr)
 85:       call MatSetUp(A,ierr)

 87:       i1 = 1
 88:       i2 = 2
 89:       i3 = 3
 90:       call MatGetOwnershipRange(A,Istart,Iend,ierr)
 91:       if (Istart .eq. 0) then 
 92:         i = 0
 93:         col(1) = 0
 94:         col(2) = 1
 95:         value(1) =  2.0
 96:         value(2) = -1.0
 97:         call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr)
 98:         Istart = Istart+1
 99:       endif
100:       if (Iend .eq. n) then 
101:         i = n-1
102:         col(1) = n-2
103:         col(2) = n-1
104:         value(1) = -1.0
105:         value(2) =  2.0
106:         call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr)
107:         Iend = Iend-1
108:       endif
109:       value(1) = -1.0
110:       value(2) =  2.0
111:       value(3) = -1.0
112:       do i=Istart,Iend-1
113:         col(1) = i-1
114:         col(2) = i
115:         col(3) = i+1
116:         call MatSetValues(A,i1,i,i3,col,value,INSERT_VALUES,ierr)
117:       enddo

119:       call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
120:       call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)

122:       call MatCreateVecs(A,xr,xi,ierr)

124: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
125: !     Create the eigensolver and display info
126: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

128: !     ** Create eigensolver context
129:       call EPSCreate(PETSC_COMM_WORLD,eps,ierr)

131: !     ** Set operators. In this case, it is a standard eigenvalue problem
132:       call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr)
133:       call EPSSetProblemType(eps,EPS_HEP,ierr)

135: !     ** Set solver parameters at runtime
136:       call EPSSetFromOptions(eps,ierr)

138: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
139: !     Solve the eigensystem
140: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

142:       call EPSSolve(eps,ierr) 
143:       call EPSGetIterationNumber(eps,its,ierr)
144:       if (rank .eq. 0) then
145:         write(*,110) its
146:       endif
147:  110  format (/' Number of iterations of the method:',I4)

149: !     ** Optional: Get some information from the solver and display it
150:       call EPSGetType(eps,tname,ierr)
151:       if (rank .eq. 0) then
152:         write(*,120) tname
153:       endif
154:  120  format (' Solution method: ',A)
155:       call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER,                 &
156:      &                      PETSC_NULL_INTEGER,ierr)
157:       if (rank .eq. 0) then
158:         write(*,130) nev
159:       endif
160:  130  format (' Number of requested eigenvalues:',I2)
161:       call EPSGetTolerances(eps,tol,maxit,ierr)
162:       if (rank .eq. 0) then
163:         write(*,140) tol, maxit
164:       endif
165:  140  format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)

167: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
168: !     Display solution and clean up
169: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

171: !     ** Get number of converged eigenpairs
172:       call EPSGetConverged(eps,nconv,ierr)
173:       if (rank .eq. 0) then
174:         write(*,150) nconv
175:       endif
176:  150  format (' Number of converged eigenpairs:',I2/)

178: !     ** Display eigenvalues and relative errors
179:       if (nconv.gt.0) then
180:         if (rank .eq. 0) then
181:           write(*,*) '         k          ||Ax-kx||/||kx||'
182:           write(*,*) ' ----------------- ------------------'
183:         endif
184:         do i=0,nconv-1
185: !         ** Get converged eigenpairs: i-th eigenvalue is stored in kr 
186: !         ** (real part) and ki (imaginary part)
187:           call EPSGetEigenpair(eps,i,kr,ki,xr,xi,ierr)

189: !         ** Compute the relative error associated to each eigenpair
190:           call EPSComputeError(eps,i,EPS_ERROR_RELATIVE,error,ierr)
191:           if (rank .eq. 0) then
192:             write(*,160) PetscRealPart(kr), error
193:           endif
194:  160      format (1P,'   ',E12.4,'       ',E12.4)

196:         enddo
197:         if (rank .eq. 0) then
198:           write(*,*)
199:         endif
200:       endif

202: !     ** Free work space
203:       call EPSDestroy(eps,ierr)
204:       call MatDestroy(A,ierr)
205:       call VecDestroy(xr,ierr)
206:       call VecDestroy(xi,ierr)

208:       call SlepcFinalize(ierr)
209:       end

slepc-3.7.4/src/eps/examples/tutorials/ex12.c0000644000175000017500000001467713107004621020347 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Compute all eigenvalues in an interval of a symmetric-definite problem.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B; /* matrices */ EPS eps; /* eigenproblem solver context */ ST st; /* spectral transformation context */ KSP ksp; PC pc; PetscInt N,n=35,m,Istart,Iend,II,nev,i,j,k,*inertias; PetscBool flag; PetscReal int0,int1,*shifts; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSymmetric-definite problem with two intervals, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, Ax=kBx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. " "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n" "This example illustrates how the user can set the initial vector.\n\n" "The command line options are:\n" " -m , where = number of grid subdivisions in each dimension.\n\n"; #include /* User-defined routines */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Vec v0; /* initial vector */ Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscInt N,m=15,nev; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); N = m*(m+1)/2; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n\n",N,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatMarkovModel(m,A);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* Set the initial vector. This is optional, if not done the initial vector is set to random values */ ierr = MatCreateVecs(A,&v0,NULL);CHKERRQ(ierr); ierr = VecSet(v0,1.0);CHKERRQ(ierr); ierr = EPSSetInitialSpace(eps,1,&v0);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = VecDestroy(&v0);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMarkovModel" /* Matrix generator for a Markov model of a random walk on a triangular grid. This subroutine generates a test matrix that models a random walk on a triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a FORTRAN subroutine to calculate the dominant invariant subspaces of a real matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295 (1980) ]. These matrices provide reasonably easy test problems for eigenvalue algorithms. The transpose of the matrix is stochastic and so it is known that one is an exact eigenvalue. One seeks the eigenvector of the transpose associated with the eigenvalue unity. The problem is to calculate the steady state probability distribution of the system, which is the eigevector associated with the eigenvalue one and scaled in such a way that the sum all the components is equal to one. Note: the code will actually compute the transpose of the stochastic matrix that contains the transition probabilities. */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A) { const PetscReal cst = 0.5/(PetscReal)(m-1); PetscReal pd,pu; PetscInt Istart,Iend,i,j,jmax,ix=0; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=1;i<=m;i++) { jmax = m-i+1; for (j=1;j<=jmax;j++) { ix = ix + 1; if (ix-1Iend) continue; /* compute only owned rows */ if (j!=jmax) { pd = cst*(PetscReal)(i+j-1); /* north */ if (i==1) { ierr = MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);CHKERRQ(ierr); } /* east */ if (j==1) { ierr = MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);CHKERRQ(ierr); } } /* south */ pu = 0.5 - cst*(PetscReal)(i+j-3); if (j>1) { ierr = MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);CHKERRQ(ierr); } /* west */ if (i>1) { ierr = MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);CHKERRQ(ierr); } } } ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tutorials/ex2.c.html0000644000175000017500000002500213107004621021211 0ustar jromanjroman
Actual source code: ex2.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 2 dimensions.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 25:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n\n";

 27: #include <slepceps.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A;               /* operator matrix */
 34:   EPS            eps;             /* eigenproblem solver context */
 35:   EPSType        type;
 36:   PetscInt       N,n=10,m,Istart,Iend,II,nev,i,j;
 37:   PetscBool      flag,terse;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);

 42:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 44:   if (!flag) m=n;
 45:   N = n*m;
 46:   PetscPrintf(PETSC_COMM_WORLD,"\n2-D Laplacian Eigenproblem, N=%D (%Dx%D grid)\n\n",N,n,m);

 48:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 49:      Compute the operator matrix that defines the eigensystem, Ax=kx
 50:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 52:   MatCreate(PETSC_COMM_WORLD,&A);
 53:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 54:   MatSetFromOptions(A);
 55:   MatSetUp(A);

 57:   MatGetOwnershipRange(A,&Istart,&Iend);
 58:   for (II=Istart;II<Iend;II++) {
 59:     i = II/n; j = II-i*n;
 60:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); }
 61:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); }
 62:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); }
 63:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); }
 64:     MatSetValue(A,II,II,4.0,INSERT_VALUES);
 65:   }

 67:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 68:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 70:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 71:                 Create the eigensolver and set various options
 72:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 74:   /*
 75:      Create eigensolver context
 76:   */
 77:   EPSCreate(PETSC_COMM_WORLD,&eps);

 79:   /*
 80:      Set operators. In this case, it is a standard eigenvalue problem
 81:   */
 82:   EPSSetOperators(eps,A,NULL);
 83:   EPSSetProblemType(eps,EPS_HEP);

 85:   /*
 86:      Set solver parameters at runtime
 87:   */
 88:   EPSSetFromOptions(eps);

 90:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 91:                       Solve the eigensystem
 92:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 94:   EPSSolve(eps);

 96:   /*
 97:      Optional: Get some information from the solver and display it
 98:   */
 99:   EPSGetType(eps,&type);
100:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
101:   EPSGetDimensions(eps,&nev,NULL,NULL);
102:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

104:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
105:                     Display solution and clean up
106:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

108:   /* show detailed info unless -terse option is given by user */
109:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
110:   if (terse) {
111:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
112:   } else {
113:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
114:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
115:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
116:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
117:   }
118:   EPSDestroy(&eps);
119:   MatDestroy(&A);
120:   SlepcFinalize();
121:   return ierr;
122: }

slepc-3.7.4/src/eps/examples/tutorials/ex30.c.html0000644000175000017500000005535213107004621021305 0ustar jromanjroman
Actual source code: ex30.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Illustrates the use of a region for filtering; the number of wanted eigenvalues in not known a priori.\n\n"
 23:   "The problem is the Brusselator wave model as in ex9.c.\n"
 24:   "The command line options are:\n"
 25:   "  -n <n>, where <n> = block dimension of the 2x2 block matrix.\n"
 26:   "  -L <L>, where <L> = bifurcation parameter.\n"
 27:   "  -alpha <alpha>, -beta <beta>, -delta1 <delta1>,  -delta2 <delta2>,\n"
 28:   "       where <alpha> <beta> <delta1> <delta2> = model parameters.\n\n";

 30: #include <slepceps.h>

 32: /*
 33:    This example tries to compute all eigenvalues lying outside the real axis.
 34:    This could be achieved by computing LARGEST_IMAGINARY eigenvalues, but
 35:    here we take a different route: define a region of the complex plane where
 36:    eigenvalues must be emphasized (eigenvalues outside the region are filtered
 37:    out). In this case, we select the region as the complement of a thin stripe
 38:    around the real axis.
 39:  */

 41: PetscErrorCode MatMult_Brussel(Mat,Vec,Vec);
 42: PetscErrorCode MatShift_Brussel(PetscScalar*,Mat);
 43: PetscErrorCode MatGetDiagonal_Brussel(Mat,Vec);
 44: PetscErrorCode MyStoppingTest(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*);

 46: typedef struct {
 47:   Mat         T;
 48:   Vec         x1,x2,y1,y2;
 49:   PetscScalar alpha,beta,tau1,tau2,sigma;
 50:   PetscInt    lastnconv;      /* last value of nconv; used in stopping test */
 51:   PetscInt    nreps;          /* number of repetitions of nconv; used in stopping test */
 52: } CTX_BRUSSEL;

 56: int main(int argc,char **argv)
 57: {
 58:   Mat            A;               /* eigenvalue problem matrix */
 59:   EPS            eps;             /* eigenproblem solver context */
 60:   RG             rg;              /* region object */
 61:   PetscScalar    delta1,delta2,L,h;
 62:   PetscInt       N=30,n,i,Istart,Iend,mpd;
 63:   CTX_BRUSSEL    *ctx;
 64:   PetscBool      terse;
 65:   PetscViewer    viewer;

 68:   SlepcInitialize(&argc,&argv,(char*)0,help);

 70:   PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);
 71:   PetscPrintf(PETSC_COMM_WORLD,"\nBrusselator wave model, n=%D\n\n",N);

 73:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 74:         Generate the matrix
 75:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 77:   /*
 78:      Create shell matrix context and set default parameters
 79:   */
 80:   PetscNew(&ctx);
 81:   ctx->alpha = 2.0;
 82:   ctx->beta  = 5.45;
 83:   delta1     = 0.008;
 84:   delta2     = 0.004;
 85:   L          = 0.51302;

 87:   /*
 88:      Look the command line for user-provided parameters
 89:   */
 90:   PetscOptionsGetScalar(NULL,NULL,"-L",&L,NULL);
 91:   PetscOptionsGetScalar(NULL,NULL,"-alpha",&ctx->alpha,NULL);
 92:   PetscOptionsGetScalar(NULL,NULL,"-beta",&ctx->beta,NULL);
 93:   PetscOptionsGetScalar(NULL,NULL,"-delta1",&delta1,NULL);
 94:   PetscOptionsGetScalar(NULL,NULL,"-delta2",&delta2,NULL);

 96:   /*
 97:      Create matrix T
 98:   */
 99:   MatCreate(PETSC_COMM_WORLD,&ctx->T);
100:   MatSetSizes(ctx->T,PETSC_DECIDE,PETSC_DECIDE,N,N);
101:   MatSetFromOptions(ctx->T);
102:   MatSetUp(ctx->T);

104:   MatGetOwnershipRange(ctx->T,&Istart,&Iend);
105:   for (i=Istart;i<Iend;i++) {
106:     if (i>0) { MatSetValue(ctx->T,i,i-1,1.0,INSERT_VALUES); }
107:     if (i<N-1) { MatSetValue(ctx->T,i,i+1,1.0,INSERT_VALUES); }
108:     MatSetValue(ctx->T,i,i,-2.0,INSERT_VALUES);
109:   }
110:   MatAssemblyBegin(ctx->T,MAT_FINAL_ASSEMBLY);
111:   MatAssemblyEnd(ctx->T,MAT_FINAL_ASSEMBLY);
112:   MatGetLocalSize(ctx->T,&n,NULL);

114:   /*
115:      Fill the remaining information in the shell matrix context
116:      and create auxiliary vectors
117:   */
118:   h = 1.0 / (PetscReal)(N+1);
119:   ctx->tau1 = delta1 / ((h*L)*(h*L));
120:   ctx->tau2 = delta2 / ((h*L)*(h*L));
121:   ctx->sigma = 0.0;
122:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x1);
123:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x2);
124:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y1);
125:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y2);

127:   /*
128:      Create the shell matrix
129:   */
130:   MatCreateShell(PETSC_COMM_WORLD,2*n,2*n,2*N,2*N,(void*)ctx,&A);
131:   MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Brussel);
132:   MatShellSetOperation(A,MATOP_SHIFT,(void(*)())MatShift_Brussel);
133:   MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Brussel);

135:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
136:                 Create the eigensolver and configure the region
137:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

139:   EPSCreate(PETSC_COMM_WORLD,&eps);
140:   EPSSetOperators(eps,A,NULL);
141:   EPSSetProblemType(eps,EPS_NHEP);

143:   /*
144:      Define the region containing the eigenvalues of interest
145:   */
146:   EPSGetRG(eps,&rg);
147:   RGSetType(rg,RGINTERVAL);
148:   RGIntervalSetEndpoints(rg,-PETSC_INFINITY,PETSC_INFINITY,-0.01,0.01);
149:   RGSetComplement(rg,PETSC_TRUE);
150:   /* sort eigenvalue approximations wrt a target, otherwise convergence will be erratic */
151:   EPSSetTarget(eps,0.0);
152:   EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);

154:   /*
155:      Set solver options. In particular, we must allocate sufficient
156:      storage for all eigenpairs that may converge (ncv). This is
157:      application-dependent.
158:   */
159:   mpd = 40;
160:   EPSSetDimensions(eps,2*mpd,3*mpd,mpd);
161:   EPSSetTolerances(eps,1e-7,2000);
162:   ctx->lastnconv = 0;
163:   ctx->nreps     = 0;
164:   EPSSetStoppingTestFunction(eps,MyStoppingTest,(void*)ctx,NULL);
165:   EPSSetFromOptions(eps);

167:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
168:                 Solve the eigensystem and display solution
169:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

171:   EPSSolve(eps);

173:   /* show detailed info unless -terse option is given by user */
174:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
175:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
176:   EPSReasonView(eps,viewer);
177:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
178:   if (!terse) {
179:     EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);
180:   }
181:   PetscViewerPopFormat(viewer);

183:   EPSDestroy(&eps);
184:   MatDestroy(&A);
185:   MatDestroy(&ctx->T);
186:   VecDestroy(&ctx->x1);
187:   VecDestroy(&ctx->x2);
188:   VecDestroy(&ctx->y1);
189:   VecDestroy(&ctx->y2);
190:   PetscFree(ctx);
191:   SlepcFinalize();
192:   return ierr;
193: }

197: PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y)
198: {
199:   PetscInt          n;
200:   const PetscScalar *px;
201:   PetscScalar       *py;
202:   CTX_BRUSSEL       *ctx;
203:   PetscErrorCode    ierr;

206:   MatShellGetContext(A,(void**)&ctx);
207:   MatGetLocalSize(ctx->T,&n,NULL);
208:   VecGetArrayRead(x,&px);
209:   VecGetArray(y,&py);
210:   VecPlaceArray(ctx->x1,px);
211:   VecPlaceArray(ctx->x2,px+n);
212:   VecPlaceArray(ctx->y1,py);
213:   VecPlaceArray(ctx->y2,py+n);

215:   MatMult(ctx->T,ctx->x1,ctx->y1);
216:   VecScale(ctx->y1,ctx->tau1);
217:   VecAXPY(ctx->y1,ctx->beta - 1.0 + ctx->sigma,ctx->x1);
218:   VecAXPY(ctx->y1,ctx->alpha * ctx->alpha,ctx->x2);

220:   MatMult(ctx->T,ctx->x2,ctx->y2);
221:   VecScale(ctx->y2,ctx->tau2);
222:   VecAXPY(ctx->y2,-ctx->beta,ctx->x1);
223:   VecAXPY(ctx->y2,-ctx->alpha * ctx->alpha + ctx->sigma,ctx->x2);

225:   VecRestoreArrayRead(x,&px);
226:   VecRestoreArray(y,&py);
227:   VecResetArray(ctx->x1);
228:   VecResetArray(ctx->x2);
229:   VecResetArray(ctx->y1);
230:   VecResetArray(ctx->y2);
231:   return(0);
232: }

236: PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y)
237: {
238:   CTX_BRUSSEL    *ctx;

242:   MatShellGetContext(Y,(void**)&ctx);
243:   ctx->sigma += *a;
244:   return(0);
245: }

249: PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag)
250: {
251:   Vec            d1,d2;
252:   PetscInt       n;
253:   PetscScalar    *pd;
254:   MPI_Comm       comm;
255:   CTX_BRUSSEL    *ctx;

259:   MatShellGetContext(A,(void**)&ctx);
260:   PetscObjectGetComm((PetscObject)A,&comm);
261:   MatGetLocalSize(ctx->T,&n,NULL);
262:   VecGetArray(diag,&pd);
263:   VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd,&d1);
264:   VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd+n,&d2);

266:   VecSet(d1,-2.0*ctx->tau1 + ctx->beta - 1.0 + ctx->sigma);
267:   VecSet(d2,-2.0*ctx->tau2 - ctx->alpha*ctx->alpha + ctx->sigma);

269:   VecDestroy(&d1);
270:   VecDestroy(&d2);
271:   VecRestoreArray(diag,&pd);
272:   return(0);
273: }

277: /*
278:     Function for user-defined stopping test.

280:     Ignores the value of nev. It only takes into account the number of
281:     eigenpairs that have converged in recent outer iterations (restarts);
282:     if no new eigenvalus have converged in the last few restarts,
283:     we stop the iteration, assuming that no more eigenvalues are present
284:     inside the region.
285: */
286: PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ptr)
287: {
289:   CTX_BRUSSEL    *ctx = (CTX_BRUSSEL*)ptr;

292:   /* check usual termination conditions, but ignoring the case nconv>=nev */
293:   EPSStoppingBasic(eps,its,max_it,nconv,PETSC_MAX_INT,reason,NULL);
294:   if (*reason==EPS_CONVERGED_ITERATING) {
295:     /* check if nconv is the same as before */
296:     if (nconv==ctx->lastnconv) ctx->nreps++;
297:     else {
298:       ctx->lastnconv = nconv;
299:       ctx->nreps     = 0;
300:     }
301:     /* check if no eigenvalues converged in last 10 restarts */
302:     if (nconv && ctx->nreps>10) *reason = EPS_CONVERGED_USER;
303:   }
304:   return(0);
305: }

slepc-3.7.4/src/eps/examples/tutorials/ex5.c.html0000644000175000017500000003674313107004621021232 0ustar jromanjroman
Actual source code: ex5.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. "
 23:   "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n"
 24:   "This example illustrates how the user can set the initial vector.\n\n"
 25:   "The command line options are:\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in each dimension.\n\n";

 28: #include <slepceps.h>

 30: /*
 31:    User-defined routines
 32: */
 33: PetscErrorCode MatMarkovModel(PetscInt m,Mat A);

 37: int main(int argc,char **argv)
 38: {
 39:   Vec            v0;              /* initial vector */
 40:   Mat            A;               /* operator matrix */
 41:   EPS            eps;             /* eigenproblem solver context */
 42:   EPSType        type;
 43:   PetscInt       N,m=15,nev;
 44:   PetscBool      terse;

 47:   SlepcInitialize(&argc,&argv,(char*)0,help);

 49:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 50:   N = m*(m+1)/2;
 51:   PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n\n",N,m);

 53:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 54:      Compute the operator matrix that defines the eigensystem, Ax=kx
 55:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 57:   MatCreate(PETSC_COMM_WORLD,&A);
 58:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 59:   MatSetFromOptions(A);
 60:   MatSetUp(A);
 61:   MatMarkovModel(m,A);

 63:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 64:                 Create the eigensolver and set various options
 65:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 67:   /*
 68:      Create eigensolver context
 69:   */
 70:   EPSCreate(PETSC_COMM_WORLD,&eps);

 72:   /*
 73:      Set operators. In this case, it is a standard eigenvalue problem
 74:   */
 75:   EPSSetOperators(eps,A,NULL);
 76:   EPSSetProblemType(eps,EPS_NHEP);

 78:   /*
 79:      Set solver parameters at runtime
 80:   */
 81:   EPSSetFromOptions(eps);

 83:   /*
 84:      Set the initial vector. This is optional, if not done the initial
 85:      vector is set to random values
 86:   */
 87:   MatCreateVecs(A,&v0,NULL);
 88:   VecSet(v0,1.0);
 89:   EPSSetInitialSpace(eps,1,&v0);

 91:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 92:                       Solve the eigensystem
 93:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 95:   EPSSolve(eps);

 97:   /*
 98:      Optional: Get some information from the solver and display it
 99:   */
100:   EPSGetType(eps,&type);
101:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
102:   EPSGetDimensions(eps,&nev,NULL,NULL);
103:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

105:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106:                     Display solution and clean up
107:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

109:   /* show detailed info unless -terse option is given by user */
110:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
111:   if (terse) {
112:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
113:   } else {
114:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
115:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
116:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
117:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
118:   }
119:   EPSDestroy(&eps);
120:   MatDestroy(&A);
121:   VecDestroy(&v0);
122:   SlepcFinalize();
123:   return ierr;
124: }

128: /*
129:     Matrix generator for a Markov model of a random walk on a triangular grid.

131:     This subroutine generates a test matrix that models a random walk on a
132:     triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a
133:     FORTRAN subroutine to calculate the dominant invariant subspaces of a real
134:     matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few
135:     papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295
136:     (1980) ]. These matrices provide reasonably easy test problems for eigenvalue
137:     algorithms. The transpose of the matrix  is stochastic and so it is known
138:     that one is an exact eigenvalue. One seeks the eigenvector of the transpose
139:     associated with the eigenvalue unity. The problem is to calculate the steady
140:     state probability distribution of the system, which is the eigevector
141:     associated with the eigenvalue one and scaled in such a way that the sum all
142:     the components is equal to one.

144:     Note: the code will actually compute the transpose of the stochastic matrix
145:     that contains the transition probabilities.
146: */
147: PetscErrorCode MatMarkovModel(PetscInt m,Mat A)
148: {
149:   const PetscReal cst = 0.5/(PetscReal)(m-1);
150:   PetscReal       pd,pu;
151:   PetscInt        Istart,Iend,i,j,jmax,ix=0;
152:   PetscErrorCode  ierr;

155:   MatGetOwnershipRange(A,&Istart,&Iend);
156:   for (i=1;i<=m;i++) {
157:     jmax = m-i+1;
158:     for (j=1;j<=jmax;j++) {
159:       ix = ix + 1;
160:       if (ix-1<Istart || ix>Iend) continue;  /* compute only owned rows */
161:       if (j!=jmax) {
162:         pd = cst*(PetscReal)(i+j-1);
163:         /* north */
164:         if (i==1) {
165:           MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);
166:         } else {
167:           MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);
168:         }
169:         /* east */
170:         if (j==1) {
171:           MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);
172:         } else {
173:           MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);
174:         }
175:       }
176:       /* south */
177:       pu = 0.5 - cst*(PetscReal)(i+j-3);
178:       if (j>1) {
179:         MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);
180:       }
181:       /* west */
182:       if (i>1) {
183:         MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);
184:       }
185:     }
186:   }
187:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
188:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
189:   return(0);
190: }

slepc-3.7.4/src/eps/examples/tutorials/ex13.c0000644000175000017500000001463213107004621020337 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Generalized Symmetric eigenproblem.\n\n" "The problem is Ax = lambda Bx, with:\n" " A = Laplacian operator in 2-D\n" " B = diagonal matrix with all values equal to 4 except nulldim zeros\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n" " -nulldim , where = dimension of the nullspace of B.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B; /* matrices */ EPS eps; /* eigenproblem solver context */ ST st; /* spectral transformation context */ EPSType type; PetscInt N,n=10,m,Istart,Iend,II,nev,i,j,nulldim=0; PetscBool flag,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscOptionsGetInt(NULL,NULL,"-nulldim",&nulldim,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nGeneralized Symmetric Eigenproblem, N=%D (%Dx%D grid), null(B)=%D\n\n",N,n,m,nulldim);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, Ax=kBx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j=nulldim) { ierr = MatSetValue(B,II,II,4.0,INSERT_VALUES);CHKERRQ(ierr); } } ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a generalized eigenvalue problem */ ierr = EPSSetOperators(eps,A,B);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_GHEP);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); ierr = PetscObjectTypeCompareAny((PetscObject)eps,&flag,EPSBLOPEX,EPSRQCG,"");CHKERRQ(ierr); if (flag) { ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);CHKERRQ(ierr); } else { /* Select portion of spectrum */ ierr = EPSSetTarget(eps,0.0);CHKERRQ(ierr); ierr = EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);CHKERRQ(ierr); /* Use shift-and-invert to avoid solving linear systems with a singular B in case nulldim>0 */ ierr = PetscObjectTypeCompareAny((PetscObject)eps,&flag,EPSGD,EPSJD,"");CHKERRQ(ierr); if (!flag) { ierr = EPSGetST(eps,&st);CHKERRQ(ierr); ierr = STSetType(st,STSINVERT);CHKERRQ(ierr); } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = MatDestroy(&B);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/eps/examples/tutorials/ex1.c0000644000175000017500000001360113107004621020247 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions = matrix dimension.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscReal error,tol,re,im; PetscScalar kr,ki; Vec xr,xi; PetscInt n=30,i,Istart,Iend,nev,maxit,its,nconv; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { /* Display eigenvalues and relative errors */ ierr = PetscPrintf(PETSC_COMM_WORLD, " k ||Ax-kx||/||kx||\n" " ----------------- ------------------\n");CHKERRQ(ierr); for (i=0;iActual source code: ex7.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves a generalized eigensystem Ax=kBx with matrices loaded from a file.\n"
 23:   "The command line options are:\n"
 24:   "  -f1 <filename> -f2 <filename>, PETSc binary files containing A and B.\n"
 25:   "  -evecs <filename>, output file to save computed eigenvectors.\n"
 26:   "  -ninitial <nini>, number of user-provided initial guesses.\n"
 27:   "  -finitial <filename>, binary file containing <nini> vectors.\n"
 28:   "  -nconstr <ncon>, number of user-provided constraints.\n"
 29:   "  -fconstr <filename>, binary file containing <ncon> vectors.\n\n";

 31: #include <slepceps.h>

 35: int main(int argc,char **argv)
 36: {
 37:   Mat            A,B;             /* matrices */
 38:   EPS            eps;             /* eigenproblem solver context */
 39:   ST             st;
 40:   KSP            ksp;
 41:   EPSType        type;
 42:   PetscReal      tol;
 43:   Vec            xr,xi,*Iv,*Cv;
 44:   PetscInt       nev,maxit,i,its,lits,nconv,nini=0,ncon=0;
 45:   char           filename[PETSC_MAX_PATH_LEN];
 46:   PetscViewer    viewer;
 47:   PetscBool      flg,evecs,ishermitian,terse;

 50:   SlepcInitialize(&argc,&argv,(char*)0,help);

 52:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 53:         Load the matrices that define the eigensystem, Ax=kBx
 54:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 56:   PetscPrintf(PETSC_COMM_WORLD,"\nGeneralized eigenproblem stored in file.\n\n");
 57:   PetscOptionsGetString(NULL,NULL,"-f1",filename,PETSC_MAX_PATH_LEN,&flg);
 58:   if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name for matrix A with the -f1 option");

 60: #if defined(PETSC_USE_COMPLEX)
 61:   PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrices from binary files...\n");
 62: #else
 63:   PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrices from binary files...\n");
 64: #endif
 65:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 66:   MatCreate(PETSC_COMM_WORLD,&A);
 67:   MatSetFromOptions(A);
 68:   MatLoad(A,viewer);
 69:   PetscViewerDestroy(&viewer);

 71:   PetscOptionsGetString(NULL,NULL,"-f2",filename,PETSC_MAX_PATH_LEN,&flg);
 72:   if (flg) {
 73:     PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 74:     MatCreate(PETSC_COMM_WORLD,&B);
 75:     MatSetFromOptions(B);
 76:     MatLoad(B,viewer);
 77:     PetscViewerDestroy(&viewer);
 78:   } else {
 79:     PetscPrintf(PETSC_COMM_WORLD," Matrix B was not provided, setting B=I\n\n");
 80:     B = NULL;
 81:   }

 83:   MatCreateVecs(A,NULL,&xr);
 84:   MatCreateVecs(A,NULL,&xi);

 86:   /*
 87:      Read user constraints if available
 88:   */
 89:   PetscOptionsGetInt(NULL,NULL,"-nconstr",&ncon,&flg);
 90:   if (flg) {
 91:     if (ncon<=0) SETERRQ(PETSC_COMM_WORLD,1,"The number of constraints must be >0");
 92:     PetscOptionsGetString(NULL,NULL,"-fconstr",filename,PETSC_MAX_PATH_LEN,&flg);
 93:     if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must specify the name of the file storing the constraints");
 94:     PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 95:     VecDuplicateVecs(xr,ncon,&Cv);
 96:     for (i=0;i<ncon;i++) {
 97:       VecLoad(Cv[i],viewer);
 98:     }
 99:     PetscViewerDestroy(&viewer);
100:   }

102:   /*
103:      Read initial guesses if available
104:   */
105:   PetscOptionsGetInt(NULL,NULL,"-ninitial",&nini,&flg);
106:   if (flg) {
107:     if (nini<=0) SETERRQ(PETSC_COMM_WORLD,1,"The number of initial vectors must be >0");
108:     PetscOptionsGetString(NULL,NULL,"-finitial",filename,PETSC_MAX_PATH_LEN,&flg);
109:     if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must specify the name of the file containing the initial vectors");
110:     PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
111:     VecDuplicateVecs(xr,nini,&Iv);
112:     for (i=0;i<nini;i++) {
113:       VecLoad(Iv[i],viewer);
114:     }
115:     PetscViewerDestroy(&viewer);
116:   }

118:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
119:                 Create the eigensolver and set various options
120:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

122:   /*
123:      Create eigensolver context
124:   */
125:   EPSCreate(PETSC_COMM_WORLD,&eps);

127:   /*
128:      Set operators. In this case, it is a generalized eigenvalue problem
129:   */
130:   EPSSetOperators(eps,A,B);

132:   /*
133:      If the user provided initial guesses or constraints, pass them here
134:   */
135:   EPSSetInitialSpace(eps,nini,Iv);
136:   EPSSetDeflationSpace(eps,ncon,Cv);

138:   /*
139:      Set solver parameters at runtime
140:   */
141:   EPSSetFromOptions(eps);

143:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
144:                       Solve the eigensystem
145:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

147:   EPSSolve(eps);

149:   /*
150:      Optional: Get some information from the solver and display it
151:   */
152:   EPSGetIterationNumber(eps,&its);
153:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);
154:   EPSGetST(eps,&st);
155:   STGetKSP(st,&ksp);
156:   KSPGetTotalIterations(ksp,&lits);
157:   PetscPrintf(PETSC_COMM_WORLD," Number of linear iterations of the method: %D\n",lits);
158:   EPSGetType(eps,&type);
159:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
160:   EPSGetDimensions(eps,&nev,NULL,NULL);
161:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
162:   EPSGetTolerances(eps,&tol,&maxit);
163:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

165:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
166:                     Display solution and clean up
167:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

169:   /*
170:      Show detailed info unless -terse option is given by user
171:    */
172:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
173:   if (terse) {
174:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
175:   } else {
176:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
177:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
178:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
179:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
180:   }

182:   /*
183:      Save eigenvectors, if requested
184:   */
185:   PetscOptionsGetString(NULL,NULL,"-evecs",filename,PETSC_MAX_PATH_LEN,&evecs);
186:   EPSGetConverged(eps,&nconv);
187:   if (nconv>0 && evecs) {
188:     PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_WRITE,&viewer);
189:     EPSIsHermitian(eps,&ishermitian);
190:     for (i=0;i<nconv;i++) {
191:       EPSGetEigenvector(eps,i,xr,xi);
192:       VecView(xr,viewer);
193: #if !defined(PETSC_USE_COMPLEX)
194:       if (!ishermitian) { VecView(xi,viewer); }
195: #endif
196:     }
197:     PetscViewerDestroy(&viewer);
198:   }

200:   /*
201:      Free work space
202:   */
203:   EPSDestroy(&eps);
204:   MatDestroy(&A);
205:   MatDestroy(&B);
206:   VecDestroy(&xr);
207:   VecDestroy(&xi);
208:   if (nini > 0) {
209:     VecDestroyVecs(nini,&Iv);
210:   }
211:   if (ncon > 0) {
212:     VecDestroyVecs(ncon,&Cv);
213:   }
214:   SlepcFinalize();
215:   return ierr;
216: }

slepc-3.7.4/src/eps/examples/tutorials/ex9.c.html0000644000175000017500000004754513107004621021240 0ustar jromanjroman
Actual source code: ex9.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves a problem associated to the Brusselator wave model in chemical reactions, illustrating the use of shell matrices.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = block dimension of the 2x2 block matrix.\n"
 25:   "  -L <L>, where <L> = bifurcation parameter.\n"
 26:   "  -alpha <alpha>, -beta <beta>, -delta1 <delta1>,  -delta2 <delta2>,\n"
 27:   "       where <alpha> <beta> <delta1> <delta2> = model parameters.\n\n";

 29: #include <slepceps.h>

 31: /*
 32:    This example computes the eigenvalues with largest real part of the
 33:    following matrix

 35:         A = [ tau1*T+(beta-1)*I     alpha^2*I
 36:                   -beta*I        tau2*T-alpha^2*I ],

 38:    where

 40:         T = tridiag{1,-2,1}
 41:         h = 1/(n+1)
 42:         tau1 = delta1/(h*L)^2
 43:         tau2 = delta2/(h*L)^2
 44:  */


 47: /*
 48:    Matrix operations
 49: */
 50: PetscErrorCode MatMult_Brussel(Mat,Vec,Vec);
 51: PetscErrorCode MatShift_Brussel(PetscScalar*,Mat);
 52: PetscErrorCode MatGetDiagonal_Brussel(Mat,Vec);

 54: typedef struct {
 55:   Mat         T;
 56:   Vec         x1,x2,y1,y2;
 57:   PetscScalar alpha,beta,tau1,tau2,sigma;
 58: } CTX_BRUSSEL;

 62: int main(int argc,char **argv)
 63: {
 64:   Mat            A;               /* eigenvalue problem matrix */
 65:   EPS            eps;             /* eigenproblem solver context */
 66:   EPSType        type;
 67:   PetscScalar    delta1,delta2,L,h;
 68:   PetscInt       N=30,n,i,Istart,Iend,nev;
 69:   CTX_BRUSSEL    *ctx;
 70:   PetscBool      terse;
 71:   PetscViewer    viewer;

 74:   SlepcInitialize(&argc,&argv,(char*)0,help);

 76:   PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);
 77:   PetscPrintf(PETSC_COMM_WORLD,"\nBrusselator wave model, n=%D\n\n",N);

 79:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 80:         Generate the matrix
 81:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 83:   /*
 84:      Create shell matrix context and set default parameters
 85:   */
 86:   PetscNew(&ctx);
 87:   ctx->alpha = 2.0;
 88:   ctx->beta  = 5.45;
 89:   delta1     = 0.008;
 90:   delta2     = 0.004;
 91:   L          = 0.51302;

 93:   /*
 94:      Look the command line for user-provided parameters
 95:   */
 96:   PetscOptionsGetScalar(NULL,NULL,"-L",&L,NULL);
 97:   PetscOptionsGetScalar(NULL,NULL,"-alpha",&ctx->alpha,NULL);
 98:   PetscOptionsGetScalar(NULL,NULL,"-beta",&ctx->beta,NULL);
 99:   PetscOptionsGetScalar(NULL,NULL,"-delta1",&delta1,NULL);
100:   PetscOptionsGetScalar(NULL,NULL,"-delta2",&delta2,NULL);

102:   /*
103:      Create matrix T
104:   */
105:   MatCreate(PETSC_COMM_WORLD,&ctx->T);
106:   MatSetSizes(ctx->T,PETSC_DECIDE,PETSC_DECIDE,N,N);
107:   MatSetFromOptions(ctx->T);
108:   MatSetUp(ctx->T);

110:   MatGetOwnershipRange(ctx->T,&Istart,&Iend);
111:   for (i=Istart;i<Iend;i++) {
112:     if (i>0) { MatSetValue(ctx->T,i,i-1,1.0,INSERT_VALUES); }
113:     if (i<N-1) { MatSetValue(ctx->T,i,i+1,1.0,INSERT_VALUES); }
114:     MatSetValue(ctx->T,i,i,-2.0,INSERT_VALUES);
115:   }
116:   MatAssemblyBegin(ctx->T,MAT_FINAL_ASSEMBLY);
117:   MatAssemblyEnd(ctx->T,MAT_FINAL_ASSEMBLY);
118:   MatGetLocalSize(ctx->T,&n,NULL);

120:   /*
121:      Fill the remaining information in the shell matrix context
122:      and create auxiliary vectors
123:   */
124:   h = 1.0 / (PetscReal)(N+1);
125:   ctx->tau1 = delta1 / ((h*L)*(h*L));
126:   ctx->tau2 = delta2 / ((h*L)*(h*L));
127:   ctx->sigma = 0.0;
128:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x1);
129:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x2);
130:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y1);
131:   VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y2);

133:   /*
134:      Create the shell matrix
135:   */
136:   MatCreateShell(PETSC_COMM_WORLD,2*n,2*n,2*N,2*N,(void*)ctx,&A);
137:   MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Brussel);
138:   MatShellSetOperation(A,MATOP_SHIFT,(void(*)())MatShift_Brussel);
139:   MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Brussel);

141:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142:                 Create the eigensolver and set various options
143:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

145:   /*
146:      Create eigensolver context
147:   */
148:   EPSCreate(PETSC_COMM_WORLD,&eps);

150:   /*
151:      Set operators. In this case, it is a standard eigenvalue problem
152:   */
153:   EPSSetOperators(eps,A,NULL);
154:   EPSSetProblemType(eps,EPS_NHEP);

156:   /*
157:      Ask for the rightmost eigenvalues
158:   */
159:   EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL);

161:   /*
162:      Set other solver options at runtime
163:   */
164:   EPSSetFromOptions(eps);

166:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
167:                       Solve the eigensystem
168:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

170:   EPSSolve(eps);

172:   /*
173:      Optional: Get some information from the solver and display it
174:   */
175:   EPSGetType(eps,&type);
176:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
177:   EPSGetDimensions(eps,&nev,NULL,NULL);
178:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

180:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
181:                     Display solution and clean up
182:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

184:   /* show detailed info unless -terse option is given by user */
185:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
186:   if (terse) {
187:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
188:   } else {
189:     PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
190:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
191:     EPSReasonView(eps,viewer);
192:     EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);
193:     PetscViewerPopFormat(viewer);
194:   }
195:   EPSDestroy(&eps);
196:   MatDestroy(&A);
197:   MatDestroy(&ctx->T);
198:   VecDestroy(&ctx->x1);
199:   VecDestroy(&ctx->x2);
200:   VecDestroy(&ctx->y1);
201:   VecDestroy(&ctx->y2);
202:   PetscFree(ctx);
203:   SlepcFinalize();
204:   return ierr;
205: }

209: PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y)
210: {
211:   PetscInt          n;
212:   const PetscScalar *px;
213:   PetscScalar       *py;
214:   CTX_BRUSSEL       *ctx;
215:   PetscErrorCode    ierr;

218:   MatShellGetContext(A,(void**)&ctx);
219:   MatGetLocalSize(ctx->T,&n,NULL);
220:   VecGetArrayRead(x,&px);
221:   VecGetArray(y,&py);
222:   VecPlaceArray(ctx->x1,px);
223:   VecPlaceArray(ctx->x2,px+n);
224:   VecPlaceArray(ctx->y1,py);
225:   VecPlaceArray(ctx->y2,py+n);

227:   MatMult(ctx->T,ctx->x1,ctx->y1);
228:   VecScale(ctx->y1,ctx->tau1);
229:   VecAXPY(ctx->y1,ctx->beta - 1.0 + ctx->sigma,ctx->x1);
230:   VecAXPY(ctx->y1,ctx->alpha * ctx->alpha,ctx->x2);

232:   MatMult(ctx->T,ctx->x2,ctx->y2);
233:   VecScale(ctx->y2,ctx->tau2);
234:   VecAXPY(ctx->y2,-ctx->beta,ctx->x1);
235:   VecAXPY(ctx->y2,-ctx->alpha * ctx->alpha + ctx->sigma,ctx->x2);

237:   VecRestoreArrayRead(x,&px);
238:   VecRestoreArray(y,&py);
239:   VecResetArray(ctx->x1);
240:   VecResetArray(ctx->x2);
241:   VecResetArray(ctx->y1);
242:   VecResetArray(ctx->y2);
243:   return(0);
244: }

248: PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y)
249: {
250:   CTX_BRUSSEL    *ctx;

254:   MatShellGetContext(Y,(void**)&ctx);
255:   ctx->sigma += *a;
256:   return(0);
257: }

261: PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag)
262: {
263:   Vec            d1,d2;
264:   PetscInt       n;
265:   PetscScalar    *pd;
266:   MPI_Comm       comm;
267:   CTX_BRUSSEL    *ctx;

271:   MatShellGetContext(A,(void**)&ctx);
272:   PetscObjectGetComm((PetscObject)A,&comm);
273:   MatGetLocalSize(ctx->T,&n,NULL);
274:   VecGetArray(diag,&pd);
275:   VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd,&d1);
276:   VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd+n,&d2);

278:   VecSet(d1,-2.0*ctx->tau1 + ctx->beta - 1.0 + ctx->sigma);
279:   VecSet(d2,-2.0*ctx->tau2 - ctx->alpha*ctx->alpha + ctx->sigma);

281:   VecDestroy(&d1);
282:   VecDestroy(&d2);
283:   VecRestoreArray(diag,&pd);
284:   return(0);
285: }

slepc-3.7.4/src/eps/examples/tutorials/ex31.c.html0000644000175000017500000014277613107004621021315 0ustar jromanjroman
Actual source code: ex31.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Power grid small signal stability analysis of WECC 9 bus system.\n\
 23: This example is based on the 9-bus (node) example given in the book Power\n\
 24: Systems Dynamics and Stability (Chapter 8) by P. Sauer and M. A. Pai.\n\
 25: The power grid in this example consists of 9 buses (nodes), 3 generators,\n\
 26: 3 loads, and 9 transmission lines. The network equations are written\n\
 27: in current balance form using rectangular coordinates. It uses the SLEPc\n\
 28: package to calculate the eigenvalues for small signal stability analysis\n\n";

 30: /*
 31:    This example is based on PETSc's ex9bus example (under TS).

 33:    The equations for the stability analysis are described by the DAE

 35:    \dot{x} = f(x,y,t)
 36:      0     = g(x,y,t)

 38:    where the generators are described by differential equations, while the algebraic
 39:    constraints define the network equations.

 41:    The generators are modeled with a 4th order differential equation describing the electrical
 42:    and mechanical dynamics. Each generator also has an exciter system modeled by 3rd order
 43:    diff. eqns. describing the exciter, voltage regulator, and the feedback stabilizer
 44:    mechanism.

 46:    The network equations are described by nodal current balance equations.
 47:     I(x,y) - Y*V = 0

 49:    where:
 50:     I(x,y) is the current injected from generators and loads.
 51:       Y    is the admittance matrix, and
 52:       V    is the voltage vector

 54:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 55:  
 56:    The linearized equations for the eigenvalue analysis are

 58:      \dot{\delta{x}} = f_x*\delta{x} + f_y*\delta{y}
 59:              0       = g_x*\delta{x} + g_y*\delta{y}

 61:    This gives the linearized sensitivity matrix
 62:      A = | f_x  f_y |
 63:          | g_x  g_y |

 65:    We are interested in the eigenvalues of the Schur complement of A
 66:      \hat{A} = f_x - g_x*inv(g_y)*f_y


 69:    Example contributed by: Shrirang Abhyankar
 70: */

 72: #include <petscdm.h>
 73: #include <petscdmda.h>
 74: #include <petscdmcomposite.h>
 75: #include <slepceps.h>

 77: #define freq 60
 78: #define w_s (2*PETSC_PI*freq)

 80: /* Sizes and indices */
 81: const PetscInt nbus    = 9; /* Number of network buses */
 82: const PetscInt ngen    = 3; /* Number of generators */
 83: const PetscInt nload   = 3; /* Number of loads */
 84: const PetscInt gbus[3] = {0,1,2}; /* Buses at which generators are incident */
 85: const PetscInt lbus[3] = {4,5,7}; /* Buses at which loads are incident */

 87: /* Generator real and reactive powers (found via loadflow) */
 88: const PetscScalar PG[3] = {0.716786142395021,1.630000000000000,0.850000000000000};
 89: const PetscScalar QG[3] = {0.270702180178785,0.066120127797275,-0.108402221791588};
 90: /* Generator constants */
 91: const PetscScalar H[3]    = {23.64,6.4,3.01};   /* Inertia constant */
 92: const PetscScalar Rs[3]   = {0.0,0.0,0.0}; /* Stator Resistance */
 93: const PetscScalar Xd[3]   = {0.146,0.8958,1.3125};  /* d-axis reactance */
 94: const PetscScalar Xdp[3]  = {0.0608,0.1198,0.1813}; /* d-axis transient reactance */
 95: const PetscScalar Xq[3]   = {0.0969,0.8645,1.2578}; /* q-axis reactance Xq(1) set to 0.4360, value given in text 0.0969 */
 96: const PetscScalar Xqp[3]  = {0.0969,0.1969,0.25}; /* q-axis transient reactance */
 97: const PetscScalar Td0p[3] = {8.96,6.0,5.89}; /* d-axis open circuit time constant */
 98: const PetscScalar Tq0p[3] = {0.31,0.535,0.6}; /* q-axis open circuit time constant */
 99: PetscScalar M[3]; /* M = 2*H/w_s */
100: PetscScalar D[3]; /* D = 0.1*M */

102: PetscScalar TM[3]; /* Mechanical Torque */
103: /* Exciter system constants */
104: const PetscScalar KA[3] = {20.0,20.0,20.0};  /* Voltage regulartor gain constant */
105: const PetscScalar TA[3] = {0.2,0.2,0.2};     /* Voltage regulator time constant */
106: const PetscScalar KE[3] = {1.0,1.0,1.0};     /* Exciter gain constant */
107: const PetscScalar TE[3] = {0.314,0.314,0.314}; /* Exciter time constant */
108: const PetscScalar KF[3] = {0.063,0.063,0.063};  /* Feedback stabilizer gain constant */
109: const PetscScalar TF[3] = {0.35,0.35,0.35};    /* Feedback stabilizer time constant */
110: const PetscScalar k1[3] = {0.0039,0.0039,0.0039};
111: const PetscScalar k2[3] = {1.555,1.555,1.555};  /* k1 and k2 for calculating the saturation function SE = k1*exp(k2*Efd) */

113: PetscScalar Vref[3];
114: /* Load constants
115:   We use a composite load model that describes the load and reactive powers at each time instant as follows
116:   P(t) = \sum\limits_{i=0}^ld_nsegsp \ld_alphap_i*P_D0(\frac{V_m(t)}{V_m0})^\ld_betap_i
117:   Q(t) = \sum\limits_{i=0}^ld_nsegsq \ld_alphaq_i*Q_D0(\frac{V_m(t)}{V_m0})^\ld_betaq_i
118:   where
119:     ld_nsegsp,ld_nsegsq - Number of individual load models for real and reactive power loads
120:     ld_alphap,ld_alphap - Percentage contribution (weights) or loads
121:     P_D0                - Real power load
122:     Q_D0                - Reactive power load
123:     V_m(t)              - Voltage magnitude at time t
124:     V_m0                - Voltage magnitude at t = 0
125:     ld_betap, ld_betaq  - exponents describing the load model for real and reactive part

127:     Note: All loads have the same characteristic currently.
128: */
129: const PetscScalar PD0[3] = {1.25,0.9,1.0};
130: const PetscScalar QD0[3] = {0.5,0.3,0.35};
131: const PetscInt    ld_nsegsp[3] = {3,3,3};
132: const PetscScalar ld_alphap[3] = {0.0,0.0,1.0};
133: const PetscScalar ld_betap[3]  = {2.0,1.0,0.0};
134: const PetscInt    ld_nsegsq[3] = {3,3,3};
135: const PetscScalar ld_alphaq[3] = {0.0,0.0,1.0};
136: const PetscScalar ld_betaq[3]  = {2.0,1.0,0.0};

138: typedef struct {
139:   DM       dmgen, dmnet; /* DMs to manage generator and network subsystem */
140:   DM       dmpgrid;      /* Composite DM to manage the entire power grid */
141:   Mat      Ybus;         /* Network admittance matrix */
142:   Vec      V0;           /* Initial voltage vector (Power flow solution) */
143:   PetscInt neqs_gen,neqs_net,neqs_pgrid;
144:   IS       is_diff;      /* indices for differential equations */
145:   IS       is_alg;       /* indices for algebraic equations */
146: } Userctx;

148: /* Converts from machine frame (dq) to network (phase a real,imag) reference frame */
151: PetscErrorCode dq2ri(PetscScalar Fd,PetscScalar Fq,PetscScalar delta,PetscScalar *Fr,PetscScalar *Fi)
152: {
154:   *Fr =  Fd*PetscSinScalar(delta) + Fq*PetscCosScalar(delta);
155:   *Fi = -Fd*PetscCosScalar(delta) + Fq*PetscSinScalar(delta);
156:   return(0);
157: }

159: /* Converts from network frame ([phase a real,imag) to machine (dq) reference frame */
162: PetscErrorCode ri2dq(PetscScalar Fr,PetscScalar Fi,PetscScalar delta,PetscScalar *Fd,PetscScalar *Fq)
163: {
165:   *Fd =  Fr*PetscSinScalar(delta) - Fi*PetscCosScalar(delta);
166:   *Fq =  Fr*PetscCosScalar(delta) + Fi*PetscSinScalar(delta);
167:   return(0);
168: }

172: PetscErrorCode SetInitialGuess(Vec X,Userctx *user)
173: {
175:   Vec            Xgen,Xnet;
176:   PetscScalar    *xgen,*xnet;
177:   PetscInt       i,idx=0;
178:   PetscScalar    Vr,Vi,IGr,IGi,Vm,Vm2;
179:   PetscScalar    Eqp,Edp,delta;
180:   PetscScalar    Efd,RF,VR; /* Exciter variables */
181:   PetscScalar    Id,Iq;  /* Generator dq axis currents */
182:   PetscScalar    theta,Vd,Vq,SE;

185:   M[0] = 2*H[0]/w_s; M[1] = 2*H[1]/w_s; M[2] = 2*H[2]/w_s;
186:       /*      D[0] = 0.1*M[0]; D[1] = 0.1*M[1]; D[2] = 0.1*M[2];
187:        */
188:   D[0] = D[1] = D[2] = 0.0;
189:   DMCompositeGetLocalVectors(user->dmpgrid,&Xgen,&Xnet);

191:   /* Network subsystem initialization */
192:   VecCopy(user->V0,Xnet);

194:   /* Generator subsystem initialization */
195:   VecGetArray(Xgen,&xgen);
196:   VecGetArray(Xnet,&xnet);

198:   for (i=0; i < ngen; i++) {
199:     Vr  = xnet[2*gbus[i]]; /* Real part of generator terminal voltage */
200:     Vi  = xnet[2*gbus[i]+1]; /* Imaginary part of the generator terminal voltage */
201:     Vm  = PetscSqrtScalar(Vr*Vr + Vi*Vi); Vm2 = Vm*Vm;
202:     IGr = (Vr*PG[i] + Vi*QG[i])/Vm2;
203:     IGi = (Vi*PG[i] - Vr*QG[i])/Vm2;

205:     delta = atan2(Vi+Xq[i]*IGr,Vr-Xq[i]*IGi); /* Machine angle */

207:     theta = PETSC_PI/2.0 - delta;

209:     Id = IGr*PetscCosScalar(theta) - IGi*PetscSinScalar(theta); /* d-axis stator current */
210:     Iq = IGr*PetscSinScalar(theta) + IGi*PetscCosScalar(theta); /* q-axis stator current */

212:     Vd = Vr*PetscCosScalar(theta) - Vi*PetscSinScalar(theta);
213:     Vq = Vr*PetscSinScalar(theta) + Vi*PetscCosScalar(theta);

215:     Edp = Vd + Rs[i]*Id - Xqp[i]*Iq; /* d-axis transient EMF */
216:     Eqp = Vq + Rs[i]*Iq + Xdp[i]*Id; /* q-axis transient EMF */

218:     TM[i] = PG[i];

220:     /* The generator variables are ordered as [Eqp,Edp,delta,w,Id,Iq] */
221:     xgen[idx]   = Eqp;
222:     xgen[idx+1] = Edp;
223:     xgen[idx+2] = delta;
224:     xgen[idx+3] = w_s;

226:     idx = idx + 4;

228:     xgen[idx]   = Id;
229:     xgen[idx+1] = Iq;

231:     idx = idx + 2;

233:     /* Exciter */
234:     Efd = Eqp + (Xd[i] - Xdp[i])*Id;
235:     SE  = k1[i]*PetscExpScalar(k2[i]*Efd);
236:     VR  =  KE[i]*Efd + SE;
237:     RF  =  KF[i]*Efd/TF[i];

239:     xgen[idx]   = Efd;
240:     xgen[idx+1] = RF;
241:     xgen[idx+2] = VR;

243:     Vref[i] = Vm + (VR/KA[i]);

245:     idx = idx + 3;
246:   }

248:   VecRestoreArray(Xgen,&xgen);
249:   VecRestoreArray(Xnet,&xnet);

251:   /* VecView(Xgen,0); */
252:   DMCompositeGather(user->dmpgrid,X,INSERT_VALUES,Xgen,Xnet);
253:   DMCompositeRestoreLocalVectors(user->dmpgrid,&Xgen,&Xnet);
254:   return(0);
255: }

259: PetscErrorCode PreallocateJacobian(Mat J,Userctx *user)
260: {
262:   PetscInt       *d_nnz;
263:   PetscInt       i,idx=0,start=0;
264:   PetscInt       ncols;

267:   PetscMalloc1(user->neqs_pgrid,&d_nnz);
268:   for (i=0; i<user->neqs_pgrid; i++) d_nnz[i] = 0;
269:   /* Generator subsystem */
270:   for (i=0; i < ngen; i++) {

272:     d_nnz[idx]   += 3;
273:     d_nnz[idx+1] += 2;
274:     d_nnz[idx+2] += 2;
275:     d_nnz[idx+3] += 5;
276:     d_nnz[idx+4] += 6;
277:     d_nnz[idx+5] += 6;

279:     d_nnz[user->neqs_gen+2*gbus[i]]   += 3;
280:     d_nnz[user->neqs_gen+2*gbus[i]+1] += 3;

282:     d_nnz[idx+6] += 2;
283:     d_nnz[idx+7] += 2;
284:     d_nnz[idx+8] += 5;

286:     idx = idx + 9;
287:   }

289:   start = user->neqs_gen;

291:   for (i=0; i < nbus; i++) {
292:     MatGetRow(user->Ybus,2*i,&ncols,NULL,NULL);
293:     d_nnz[start+2*i]   += ncols;
294:     d_nnz[start+2*i+1] += ncols;
295:     MatRestoreRow(user->Ybus,2*i,&ncols,NULL,NULL);
296:   }

298:   MatSeqAIJSetPreallocation(J,0,d_nnz);

300:   PetscFree(d_nnz);
301:   return(0);
302: }

304: /*
305:    J = [-df_dx, -df_dy
306:         dg_dx, dg_dy]
307: */
310: PetscErrorCode ResidualJacobian(Vec X,Mat J,void *ctx)
311: {
313:   Userctx        *user=(Userctx*)ctx;
314:   Vec            Xgen,Xnet;
315:   PetscScalar    *xgen,*xnet;
316:   PetscInt       i,idx=0;
317:   PetscScalar    Vr,Vi,Vm,Vm2;
318:   PetscScalar    Eqp,Edp,delta; /* Generator variables */
319:   PetscScalar    Efd;
320:   PetscScalar    Id,Iq;  /* Generator dq axis currents */
321:   PetscScalar    Vd,Vq;
322:   PetscScalar    val[10];
323:   PetscInt       row[2],col[10];
324:   PetscInt       net_start=user->neqs_gen;
325:   PetscScalar    Zdq_inv[4],det;
326:   PetscScalar    dVd_dVr,dVd_dVi,dVq_dVr,dVq_dVi,dVd_ddelta,dVq_ddelta;
327:   PetscScalar    dIGr_ddelta,dIGi_ddelta,dIGr_dId,dIGr_dIq,dIGi_dId,dIGi_dIq;
328:   PetscScalar    dSE_dEfd;
329:   PetscScalar    dVm_dVd,dVm_dVq,dVm_dVr,dVm_dVi;
330:   PetscInt          ncols;
331:   const PetscInt    *cols;
332:   const PetscScalar *yvals;
333:   PetscInt          k;
334:   PetscScalar PD,QD,Vm0,*v0,Vm4;
335:   PetscScalar dPD_dVr,dPD_dVi,dQD_dVr,dQD_dVi;
336:   PetscScalar dIDr_dVr,dIDr_dVi,dIDi_dVr,dIDi_dVi;


340:   MatZeroEntries(J);
341:   DMCompositeGetLocalVectors(user->dmpgrid,&Xgen,&Xnet);
342:   DMCompositeScatter(user->dmpgrid,X,Xgen,Xnet);

344:   VecGetArray(Xgen,&xgen);
345:   VecGetArray(Xnet,&xnet);

347:   /* Generator subsystem */
348:   for (i=0; i < ngen; i++) {
349:     Eqp   = xgen[idx];
350:     Edp   = xgen[idx+1];
351:     delta = xgen[idx+2];
352:     Id    = xgen[idx+4];
353:     Iq    = xgen[idx+5];
354:     Efd   = xgen[idx+6];

356:     /*    fgen[idx]   = (Eqp + (Xd[i] - Xdp[i])*Id - Efd)/Td0p[i]; */
357:     row[0] = idx;
358:     col[0] = idx;           col[1] = idx+4;          col[2] = idx+6;
359:     val[0] = 1/ Td0p[i]; val[1] = (Xd[i] - Xdp[i])/ Td0p[i]; val[2] = -1/Td0p[i];

361:     MatSetValues(J,1,row,3,col,val,INSERT_VALUES);

363:     /*    fgen[idx+1] = (Edp - (Xq[i] - Xqp[i])*Iq)/Tq0p[i]; */
364:     row[0] = idx + 1;
365:     col[0] = idx + 1;       col[1] = idx+5;
366:     val[0] = 1/Tq0p[i]; val[1] = -(Xq[i] - Xqp[i])/Tq0p[i];
367:     MatSetValues(J,1,row,2,col,val,INSERT_VALUES);

369:     /*    fgen[idx+2] = - w + w_s; */
370:     row[0] = idx + 2;
371:     col[0] = idx + 2; col[1] = idx + 3;
372:     val[0] = 0;       val[1] = -1;
373:     MatSetValues(J,1,row,2,col,val,INSERT_VALUES);

375:     /*    fgen[idx+3] = (-TM[i] + Edp*Id + Eqp*Iq + (Xqp[i] - Xdp[i])*Id*Iq + D[i]*(w - w_s))/M[i]; */
376:     row[0] = idx + 3;
377:     col[0] = idx; col[1] = idx + 1; col[2] = idx + 3;       col[3] = idx + 4;                  col[4] = idx + 5;
378:     val[0] = Iq/M[i];  val[1] = Id/M[i];      val[2] = D[i]/M[i]; val[3] = (Edp + (Xqp[i]-Xdp[i])*Iq)/M[i]; val[4] = (Eqp + (Xqp[i] - Xdp[i])*Id)/M[i];
379:     MatSetValues(J,1,row,5,col,val,INSERT_VALUES);

381:     Vr   = xnet[2*gbus[i]]; /* Real part of generator terminal voltage */
382:     Vi   = xnet[2*gbus[i]+1]; /* Imaginary part of the generator terminal voltage */
383:     ri2dq(Vr,Vi,delta,&Vd,&Vq);

385:     det = Rs[i]*Rs[i] + Xdp[i]*Xqp[i];

387:     Zdq_inv[0] = Rs[i]/det;
388:     Zdq_inv[1] = Xqp[i]/det;
389:     Zdq_inv[2] = -Xdp[i]/det;
390:     Zdq_inv[3] = Rs[i]/det;

392:     dVd_dVr    = PetscSinScalar(delta); dVd_dVi = -PetscCosScalar(delta);
393:     dVq_dVr    = PetscCosScalar(delta); dVq_dVi = PetscSinScalar(delta);
394:     dVd_ddelta = Vr*PetscCosScalar(delta) + Vi*PetscSinScalar(delta);
395:     dVq_ddelta = -Vr*PetscSinScalar(delta) + Vi*PetscCosScalar(delta);

397:     /*    fgen[idx+4] = Zdq_inv[0]*(-Edp + Vd) + Zdq_inv[1]*(-Eqp + Vq) + Id; */
398:     row[0] = idx+4;
399:     col[0] = idx;         col[1] = idx+1;        col[2] = idx + 2;
400:     val[0] = -Zdq_inv[1]; val[1] = -Zdq_inv[0];  val[2] = Zdq_inv[0]*dVd_ddelta + Zdq_inv[1]*dVq_ddelta;
401:     col[3] = idx + 4; col[4] = net_start+2*gbus[i];                     col[5] = net_start + 2*gbus[i]+1;
402:     val[3] = 1;       val[4] = Zdq_inv[0]*dVd_dVr + Zdq_inv[1]*dVq_dVr; val[5] = Zdq_inv[0]*dVd_dVi + Zdq_inv[1]*dVq_dVi;
403:     MatSetValues(J,1,row,6,col,val,INSERT_VALUES);

405:     /*  fgen[idx+5] = Zdq_inv[2]*(-Edp + Vd) + Zdq_inv[3]*(-Eqp + Vq) + Iq; */
406:     row[0] = idx+5;
407:     col[0] = idx;         col[1] = idx+1;        col[2] = idx + 2;
408:     val[0] = -Zdq_inv[3]; val[1] = -Zdq_inv[2];  val[2] = Zdq_inv[2]*dVd_ddelta + Zdq_inv[3]*dVq_ddelta;
409:     col[3] = idx + 5; col[4] = net_start+2*gbus[i];                     col[5] = net_start + 2*gbus[i]+1;
410:     val[3] = 1;       val[4] = Zdq_inv[2]*dVd_dVr + Zdq_inv[3]*dVq_dVr; val[5] = Zdq_inv[2]*dVd_dVi + Zdq_inv[3]*dVq_dVi;
411:     MatSetValues(J,1,row,6,col,val,INSERT_VALUES);

413:     dIGr_ddelta = Id*PetscCosScalar(delta) - Iq*PetscSinScalar(delta);
414:     dIGi_ddelta = Id*PetscSinScalar(delta) + Iq*PetscCosScalar(delta);
415:     dIGr_dId    = PetscSinScalar(delta);  dIGr_dIq = PetscCosScalar(delta);
416:     dIGi_dId    = -PetscCosScalar(delta); dIGi_dIq = PetscSinScalar(delta);

418:     /* fnet[2*gbus[i]]   -= IGi; */
419:     row[0] = net_start + 2*gbus[i];
420:     col[0] = idx+2;        col[1] = idx + 4;   col[2] = idx + 5;
421:     val[0] = -dIGi_ddelta; val[1] = -dIGi_dId; val[2] = -dIGi_dIq;
422:     MatSetValues(J,1,row,3,col,val,INSERT_VALUES);

424:     /* fnet[2*gbus[i]+1]   -= IGr; */
425:     row[0] = net_start + 2*gbus[i]+1;
426:     col[0] = idx+2;        col[1] = idx + 4;   col[2] = idx + 5;
427:     val[0] = -dIGr_ddelta; val[1] = -dIGr_dId; val[2] = -dIGr_dIq;
428:     MatSetValues(J,1,row,3,col,val,INSERT_VALUES);

430:     Vm = PetscSqrtScalar(Vd*Vd + Vq*Vq); Vm2 = Vm*Vm;

432:     /*    fgen[idx+6] = (KE[i]*Efd + SE - VR)/TE[i]; */
433:     /*    SE  = k1[i]*PetscExpScalar(k2[i]*Efd); */

435:     dSE_dEfd = k1[i]*k2[i]*PetscExpScalar(k2[i]*Efd);

437:     row[0] = idx + 6;
438:     col[0] = idx + 6;                     col[1] = idx + 8;
439:     val[0] = (KE[i] + dSE_dEfd)/TE[i];  val[1] = -1/TE[i];
440:     MatSetValues(J,1,row,2,col,val,INSERT_VALUES);

442:     /* Exciter differential equations */

444:     /*    fgen[idx+7] = (RF - KF[i]*Efd/TF[i])/TF[i]; */
445:     row[0] = idx + 7;
446:     col[0] = idx + 6;       col[1] = idx + 7;
447:     val[0] = (-KF[i]/TF[i])/TF[i];  val[1] = 1/TF[i];
448:     MatSetValues(J,1,row,2,col,val,INSERT_VALUES);

450:     /*    fgen[idx+8] = (VR - KA[i]*RF + KA[i]*KF[i]*Efd/TF[i] - KA[i]*(Vref[i] - Vm))/TA[i]; */
451:     /* Vm = (Vd^2 + Vq^2)^0.5; */

453:     dVm_dVd = Vd/Vm; dVm_dVq = Vq/Vm;
454:     dVm_dVr = dVm_dVd*dVd_dVr + dVm_dVq*dVq_dVr;
455:     dVm_dVi = dVm_dVd*dVd_dVi + dVm_dVq*dVq_dVi;
456:     row[0]  = idx + 8;
457:     col[0]  = idx + 6;           col[1] = idx + 7; col[2] = idx + 8;
458:     val[0]  = (KA[i]*KF[i]/TF[i])/TA[i]; val[1] = -KA[i]/TA[i];  val[2] = 1/TA[i];
459:     col[3]  = net_start + 2*gbus[i]; col[4] = net_start + 2*gbus[i]+1;
460:     val[3]  = KA[i]*dVm_dVr/TA[i];         val[4] = KA[i]*dVm_dVi/TA[i];
461:     MatSetValues(J,1,row,5,col,val,INSERT_VALUES);
462:     idx     = idx + 9;
463:   }

465:   for (i=0; i<nbus; i++) {
466:     MatGetRow(user->Ybus,2*i,&ncols,&cols,&yvals);
467:     row[0] = net_start + 2*i;
468:     for (k=0; k<ncols; k++) {
469:       col[k] = net_start + cols[k];
470:       val[k] = yvals[k];
471:     }
472:     MatSetValues(J,1,row,ncols,col,val,INSERT_VALUES);
473:     MatRestoreRow(user->Ybus,2*i,&ncols,&cols,&yvals);

475:     MatGetRow(user->Ybus,2*i+1,&ncols,&cols,&yvals);
476:     row[0] = net_start + 2*i+1;
477:     for (k=0; k<ncols; k++) {
478:       col[k] = net_start + cols[k];
479:       val[k] = yvals[k];
480:     }
481:     MatSetValues(J,1,row,ncols,col,val,INSERT_VALUES);
482:     MatRestoreRow(user->Ybus,2*i+1,&ncols,&cols,&yvals);
483:   }

485:   MatAssemblyBegin(J,MAT_FLUSH_ASSEMBLY);
486:   MatAssemblyEnd(J,MAT_FLUSH_ASSEMBLY);

488:   VecGetArray(user->V0,&v0);
489:   for (i=0; i < nload; i++) {
490:     Vr      = xnet[2*lbus[i]]; /* Real part of load bus voltage */
491:     Vi      = xnet[2*lbus[i]+1]; /* Imaginary part of the load bus voltage */
492:     Vm      = PetscSqrtScalar(Vr*Vr + Vi*Vi); Vm2 = Vm*Vm; Vm4 = Vm2*Vm2;
493:     Vm0     = PetscSqrtScalar(v0[2*lbus[i]]*v0[2*lbus[i]] + v0[2*lbus[i]+1]*v0[2*lbus[i]+1]);
494:     PD      = QD = 0.0;
495:     dPD_dVr = dPD_dVi = dQD_dVr = dQD_dVi = 0.0;
496:     for (k=0; k < ld_nsegsp[i]; k++) {
497:       PD      += ld_alphap[k]*PD0[i]*PetscPowScalar((Vm/Vm0),ld_betap[k]);
498:       dPD_dVr += ld_alphap[k]*ld_betap[k]*PD0[i]*PetscPowScalar((1/Vm0),ld_betap[k])*Vr*PetscPowScalar(Vm,(ld_betap[k]-2));
499:       dPD_dVi += ld_alphap[k]*ld_betap[k]*PD0[i]*PetscPowScalar((1/Vm0),ld_betap[k])*Vi*PetscPowScalar(Vm,(ld_betap[k]-2));
500:     }
501:     for (k=0; k < ld_nsegsq[i]; k++) {
502:       QD      += ld_alphaq[k]*QD0[i]*PetscPowScalar((Vm/Vm0),ld_betaq[k]);
503:       dQD_dVr += ld_alphaq[k]*ld_betaq[k]*QD0[i]*PetscPowScalar((1/Vm0),ld_betaq[k])*Vr*PetscPowScalar(Vm,(ld_betaq[k]-2));
504:       dQD_dVi += ld_alphaq[k]*ld_betaq[k]*QD0[i]*PetscPowScalar((1/Vm0),ld_betaq[k])*Vi*PetscPowScalar(Vm,(ld_betaq[k]-2));
505:     }

507:     /*    IDr = (PD*Vr + QD*Vi)/Vm2; */
508:     /*    IDi = (-QD*Vr + PD*Vi)/Vm2; */

510:     dIDr_dVr = (dPD_dVr*Vr + dQD_dVr*Vi + PD)/Vm2 - ((PD*Vr + QD*Vi)*2*Vr)/Vm4;
511:     dIDr_dVi = (dPD_dVi*Vr + dQD_dVi*Vi + QD)/Vm2 - ((PD*Vr + QD*Vi)*2*Vi)/Vm4;

513:     dIDi_dVr = (-dQD_dVr*Vr + dPD_dVr*Vi - QD)/Vm2 - ((-QD*Vr + PD*Vi)*2*Vr)/Vm4;
514:     dIDi_dVi = (-dQD_dVi*Vr + dPD_dVi*Vi + PD)/Vm2 - ((-QD*Vr + PD*Vi)*2*Vi)/Vm4;


517:     /*    fnet[2*lbus[i]]   += IDi; */
518:     row[0] = net_start + 2*lbus[i];
519:     col[0] = net_start + 2*lbus[i];  col[1] = net_start + 2*lbus[i]+1;
520:     val[0] = dIDi_dVr;               val[1] = dIDi_dVi;
521:     MatSetValues(J,1,row,2,col,val,ADD_VALUES);
522:     /*    fnet[2*lbus[i]+1] += IDr; */
523:     row[0] = net_start + 2*lbus[i]+1;
524:     col[0] = net_start + 2*lbus[i];  col[1] = net_start + 2*lbus[i]+1;
525:     val[0] = dIDr_dVr;               val[1] = dIDr_dVi;
526:     MatSetValues(J,1,row,2,col,val,ADD_VALUES);
527:   }
528:   VecRestoreArray(user->V0,&v0);

530:   VecRestoreArray(Xgen,&xgen);
531:   VecRestoreArray(Xnet,&xnet);

533:   DMCompositeRestoreLocalVectors(user->dmpgrid,&Xgen,&Xnet);

535:   MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);
536:   MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);
537:   return(0);
538: }

542: int main(int argc,char **argv)
543: {
544:   EPS            eps;
545:   EPSType        type;
547:   PetscMPIInt    size;
548:   Userctx        user;
549:   PetscViewer    Xview,Ybusview;
550:   Vec            X,Xr,Xi;
551:   Mat            J,Jred=NULL;
552:   IS             is0,is1;
553:   PetscInt       i,*idx2,its,nev,nconv;
554:   PetscReal      error,re,im;
555:   PetscScalar    kr,ki;
556:   PetscBool      terse;

558:   SlepcInitialize(&argc,&argv,NULL,help);
559:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
560:   if (size > 1) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Only for sequential runs");
561:   /* show detailed info unless -terse option is given by user */
562:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);

564:   user.neqs_gen   = 9*ngen; /* # eqs. for generator subsystem */
565:   user.neqs_net   = 2*nbus; /* # eqs. for network subsystem   */
566:   user.neqs_pgrid = user.neqs_gen + user.neqs_net;
567:   PetscPrintf(PETSC_COMM_WORLD,"\nStability analysis in a network with %D buses and %D generators\n\n",nbus,ngen);

569:   /* Create indices for differential and algebraic equations */
570:   PetscMalloc1(7*ngen,&idx2);
571:   for (i=0; i<ngen; i++) {
572:     idx2[7*i]   = 9*i;   idx2[7*i+1] = 9*i+1; idx2[7*i+2] = 9*i+2; idx2[7*i+3] = 9*i+3;
573:     idx2[7*i+4] = 9*i+6; idx2[7*i+5] = 9*i+7; idx2[7*i+6] = 9*i+8;
574:   }
575:   ISCreateGeneral(PETSC_COMM_WORLD,7*ngen,idx2,PETSC_COPY_VALUES,&user.is_diff);
576:   ISComplement(user.is_diff,0,user.neqs_pgrid,&user.is_alg);
577:   PetscFree(idx2);

579:   /* Read initial voltage vector and Ybus */
580:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,"X.bin",FILE_MODE_READ,&Xview);
581:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,"Ybus.bin",FILE_MODE_READ,&Ybusview);

583:   VecCreate(PETSC_COMM_WORLD,&user.V0);
584:   VecSetSizes(user.V0,PETSC_DECIDE,user.neqs_net);
585:   VecLoad(user.V0,Xview);

587:   MatCreate(PETSC_COMM_WORLD,&user.Ybus);
588:   MatSetSizes(user.Ybus,PETSC_DECIDE,PETSC_DECIDE,user.neqs_net,user.neqs_net);
589:   MatSetType(user.Ybus,MATBAIJ);
590:   /*  MatSetBlockSize(user.Ybus,2); */
591:   MatLoad(user.Ybus,Ybusview);

593:   PetscViewerDestroy(&Xview);
594:   PetscViewerDestroy(&Ybusview);

596:   /* Create DMs for generator and network subsystems */
597:   DMDACreate1d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,user.neqs_gen,1,1,NULL,&user.dmgen);
598:   DMSetOptionsPrefix(user.dmgen,"dmgen_");
599:   DMDACreate1d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,user.neqs_net,1,1,NULL,&user.dmnet);
600:   DMSetOptionsPrefix(user.dmnet,"dmnet_");
601:   /* Create a composite DM packer and add the two DMs */
602:   DMCompositeCreate(PETSC_COMM_WORLD,&user.dmpgrid);
603:   DMSetOptionsPrefix(user.dmpgrid,"pgrid_");
604:   DMCompositeAddDM(user.dmpgrid,user.dmgen);
605:   DMCompositeAddDM(user.dmpgrid,user.dmnet);

607:   DMCreateGlobalVector(user.dmpgrid,&X);

609:   MatCreate(PETSC_COMM_WORLD,&J);
610:   MatSetSizes(J,PETSC_DECIDE,PETSC_DECIDE,user.neqs_pgrid,user.neqs_pgrid);
611:   MatSetFromOptions(J);
612:   PreallocateJacobian(J,&user);

614:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
615:      Set initial conditions
616:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
617:   SetInitialGuess(X,&user);

619:   /* Form Jacobian */
620:   ResidualJacobian(X,J,(void*)&user);
621:   MatScale(J,-1);
622:   is0 = user.is_diff;
623:   is1 = user.is_alg;

625:   MatGetSchurComplement(J,is1,is1,is0,is0,MAT_IGNORE_MATRIX,NULL,MAT_SCHUR_COMPLEMENT_AINV_DIAG,MAT_INITIAL_MATRIX,&Jred);

627:   if (!terse) {
628:     MatView(Jred,NULL);
629:   }

631:   MatCreateVecs(Jred,NULL,&Xr);
632:   MatCreateVecs(Jred,NULL,&Xi);

634:   /* Create the eigensolver and set the various options */
635:   EPSCreate(PETSC_COMM_WORLD,&eps);
636:   EPSSetOperators(eps,Jred,NULL);
637:   EPSSetProblemType(eps,EPS_NHEP);
638:   EPSSetFromOptions(eps);
639:   
640:   /* Solve the eigenvalue problem */
641:   EPSSolve(eps);

643:   EPSGetIterationNumber(eps,&its);
644:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the eigensolver: %D\n",its);
645:   EPSGetType(eps,&type);
646:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n", type);
647:   EPSGetDimensions(eps,&nev,NULL,NULL);
648:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

650:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
651:                     Display solution and clean up
652:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
653:   if (terse) {
654:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
655:   } else {
656:     /* Get number of converged approximate eigenpairs */
657:     EPSGetConverged(eps,&nconv);
658:     PetscPrintf(PETSC_COMM_WORLD," Number of converged eigenpairs: %D\n\n",nconv);
659:   
660:     if (nconv>0) {
661:       /* Display eigenvalues and relative errors */
662:       PetscPrintf(PETSC_COMM_WORLD,
663:            "           k          ||Ax-kx||/||kx||\n"
664:            "   ----------------- ------------------\n");
665:   
666:       for (i=0;i<nconv;i++) {
667:         /* Get converged eigenpairs: i-th eigenvalue is stored in kr (real part) and
668:           ki (imaginary part) */
669:         EPSGetEigenpair(eps,i,&kr,&ki,Xr,Xi);
670:         /* Compute the relative error associated to each eigenpair */
671:         EPSComputeError(eps,i,EPS_ERROR_RELATIVE,&error);

673: #if defined(PETSC_USE_COMPLEX)
674:         re = PetscRealPart(kr);
675:         im = PetscImaginaryPart(kr);
676: #else
677:         re = kr;
678:         im = ki;
679: #endif
680:         if (im!=0.0) {
681:           PetscPrintf(PETSC_COMM_WORLD," %9f%+9fi %12g\n",(double)re,(double)im,(double)error);
682:         } else {
683:           PetscPrintf(PETSC_COMM_WORLD,"   %12f       %12g\n",(double)re,(double)error);
684:         }
685:       }
686:       PetscPrintf(PETSC_COMM_WORLD,"\n");
687:     }
688:   }

690:   /* Free work space */
691:   EPSDestroy(&eps);
692:   MatDestroy(&J);
693:   MatDestroy(&Jred);
694:   MatDestroy(&user.Ybus);
695:   VecDestroy(&X);
696:   VecDestroy(&Xr);
697:   VecDestroy(&Xi);
698:   VecDestroy(&user.V0);
699:   DMDestroy(&user.dmgen);
700:   DMDestroy(&user.dmnet);
701:   DMDestroy(&user.dmpgrid);
702:   ISDestroy(&user.is_diff);
703:   ISDestroy(&user.is_alg);
704:   SlepcFinalize();
705:   return ierr;
706: }
slepc-3.7.4/src/eps/examples/tutorials/ex24.c.html0000644000175000017500000004651713107004621021313 0ustar jromanjroman
Actual source code: ex24.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Spectrum folding for a standard symmetric eigenproblem.\n\n"
 23:   "The problem matrix is the 2-D Laplacian.\n\n"
 24:   "The command line options are:\n"
 25:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n";

 28: #include <slepceps.h>

 30: /*
 31:    User context for spectrum folding
 32: */
 33: typedef struct {
 34:   Mat       A;
 35:   Vec       w;
 36:   PetscReal target;
 37: } CTX_FOLD;

 39: /*
 40:    Auxiliary routines
 41: */
 42: PetscErrorCode MatMult_Fold(Mat,Vec,Vec);
 43: PetscErrorCode RayleighQuotient(Mat,Vec,PetscScalar*);
 44: PetscErrorCode ComputeResidualNorm(Mat,PetscScalar,Vec,PetscReal*);

 48: int main(int argc,char **argv)
 49: {
 50:   Mat            A,M,P;       /* problem matrix, shell matrix and preconditioner */
 51:   Vec            x;           /* eigenvector */
 52:   EPS            eps;         /* eigenproblem solver context */
 53:   ST             st;          /* spectral transformation */
 54:   KSP            ksp;
 55:   PC             pc;
 56:   EPSType        type;
 57:   CTX_FOLD       *ctx;
 58:   PetscInt       nconv,N,n=10,m,Istart,Iend,II,i,j;
 59:   PetscReal      *error,*evals,target=2.1,tol;
 60:   PetscScalar    lambda;
 61:   PetscBool      flag,terse,errok;

 64:   SlepcInitialize(&argc,&argv,(char*)0,help);

 66:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 67:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 68:   if (!flag) m=n;
 69:   PetscOptionsGetReal(NULL,NULL,"-target",&target,NULL);
 70:   N = n*m;
 71:   PetscPrintf(PETSC_COMM_WORLD,"\nSpectrum Folding, N=%D (%Dx%D grid) target=%f\n\n",N,n,m,(double)target);

 73:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 74:      Compute the 5-point stencil Laplacian
 75:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 77:   MatCreate(PETSC_COMM_WORLD,&A);
 78:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 79:   MatSetFromOptions(A);
 80:   MatSetUp(A);

 82:   MatGetOwnershipRange(A,&Istart,&Iend);
 83:   for (II=Istart;II<Iend;II++) {
 84:     i = II/n; j = II-i*n;
 85:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); }
 86:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); }
 87:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); }
 88:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); }
 89:     MatSetValue(A,II,II,4.0,INSERT_VALUES);
 90:   }

 92:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 93:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 94:   MatCreateVecs(A,&x,NULL);

 96:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 97:                 Create shell matrix to perform spectrum folding
 98:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 99:   PetscNew(&ctx);
100:   ctx->A = A;
101:   ctx->target = target;
102:   VecDuplicate(x,&ctx->w);

104:   MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,ctx,&M);
105:   MatSetFromOptions(M);
106:   MatShellSetOperation(M,MATOP_MULT,(void(*)())MatMult_Fold);

108:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109:                 Create the eigensolver and set various options
110:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

112:   EPSCreate(PETSC_COMM_WORLD,&eps);
113:   EPSSetOperators(eps,M,NULL);
114:   EPSSetProblemType(eps,EPS_HEP);
115:   EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);
116:   EPSSetFromOptions(eps);

118:   PetscObjectTypeCompareAny((PetscObject)eps,&flag,EPSBLOPEX,EPSRQCG,"");
119:   if (flag) {
120:     /*
121:        Build preconditioner specific for this application (diagonal of A^2)
122:     */
123:     MatGetRowSum(A,x);
124:     VecScale(x,-1.0);
125:     VecShift(x,20.0);
126:     MatCreate(PETSC_COMM_WORLD,&P);
127:     MatSetSizes(P,PETSC_DECIDE,PETSC_DECIDE,N,N);
128:     MatSetFromOptions(P);
129:     MatSetUp(P);
130:     MatDiagonalSet(P,x,INSERT_VALUES);
131:     /*
132:        Set diagonal preconditioner
133:     */
134:     EPSGetST(eps,&st);
135:     STSetType(st,STPRECOND);
136:     STPrecondSetMatForPC(st,P);
137:     MatDestroy(&P);
138:     STGetKSP(st,&ksp);
139:     KSPGetPC(ksp,&pc);
140:     PCSetType(pc,PCJACOBI);
141:   }

143:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
144:                       Solve the eigensystem
145:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

147:   EPSSolve(eps);
148:   EPSGetType(eps,&type);
149:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
150:   EPSGetTolerances(eps,&tol,NULL);

152:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
153:                     Display solution and clean up
154:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

156:   EPSGetConverged(eps,&nconv);
157:   PetscPrintf(PETSC_COMM_WORLD," Number of converged eigenpairs: %D\n\n",nconv);
158:   if (nconv>0) {
159:     PetscMalloc2(nconv,&evals,nconv,&error);
160:     for (i=0;i<nconv;i++) {
161:       /*  Get i-th eigenvector, compute eigenvalue approximation from
162:           Rayleigh quotient and compute residual norm */
163:       EPSGetEigenpair(eps,i,NULL,NULL,x,NULL);
164:       RayleighQuotient(A,x,&lambda);
165:       ComputeResidualNorm(A,lambda,x,&error[i]);
166: #if defined(PETSC_USE_COMPLEX)
167:       evals[i] = PetscRealPart(lambda);
168: #else
169:       evals[i] = lambda;
170: #endif
171:     }
172:     PetscOptionsHasName(NULL,NULL,"-terse",&terse);
173:     if (!terse) {
174:       PetscPrintf(PETSC_COMM_WORLD,
175:            "           k              ||Ax-kx||\n"
176:            "   ----------------- ------------------\n");
177:       for (i=0;i<nconv;i++) {
178:         PetscPrintf(PETSC_COMM_WORLD,"   %12f       %12.2g\n",(double)evals[i],(double)error[i]);
179:       }
180:     } else {
181:       errok = PETSC_TRUE;
182:       for (i=0;i<nconv;i++) errok = (errok && error[i]<5.0*tol)? PETSC_TRUE: PETSC_FALSE;
183:       if (!errok) {
184:         PetscPrintf(PETSC_COMM_WORLD," Problem: some of the first %D relative errors are higher than the tolerance\n\n",nconv);
185:       } else {
186:         PetscPrintf(PETSC_COMM_WORLD," nconv=%D eigenvalues computed up to the required tolerance:",nconv);
187:         for (i=0;i<nconv;i++) {
188:           PetscPrintf(PETSC_COMM_WORLD," %.5f",(double)evals[i]);
189:         }
190:       }
191:     }
192:     PetscPrintf(PETSC_COMM_WORLD,"\n");
193:     PetscFree2(evals,error);
194:   }

196:   EPSDestroy(&eps);
197:   MatDestroy(&A);
198:   MatDestroy(&M);
199:   VecDestroy(&ctx->w);
200:   VecDestroy(&x);
201:   PetscFree(ctx);
202:   SlepcFinalize();
203:   return ierr;
204: }

208: /*
209:     Matrix-vector product subroutine for the spectrum folding.
210:        y <-- (A-t*I)^2*x
211:  */
212: PetscErrorCode MatMult_Fold(Mat M,Vec x,Vec y)
213: {
214:   CTX_FOLD       *ctx;
215:   PetscScalar    sigma;

219:   MatShellGetContext(M,&ctx);
220:   sigma = -ctx->target;
221:   MatMult(ctx->A,x,ctx->w);
222:   VecAXPY(ctx->w,sigma,x);
223:   MatMult(ctx->A,ctx->w,y);
224:   VecAXPY(y,sigma,ctx->w);
225:   return(0);
226: }

230: /*
231:     Computes the Rayleigh quotient of a vector x
232:        r <-- x^T*A*x       (assumes x has unit norm)
233:  */
234: PetscErrorCode RayleighQuotient(Mat A,Vec x,PetscScalar *r)
235: {
236:   Vec            Ax;

240:   VecDuplicate(x,&Ax);
241:   MatMult(A,x,Ax);
242:   VecDot(Ax,x,r);
243:   VecDestroy(&Ax);
244:   return(0);
245: }

249: /*
250:     Computes the residual norm of an approximate eigenvector x, |A*x-lambda*x|
251:  */
252: PetscErrorCode ComputeResidualNorm(Mat A,PetscScalar lambda,Vec x,PetscReal *r)
253: {
254:   Vec            Ax;

258:   VecDuplicate(x,&Ax);
259:   MatMult(A,x,Ax);
260:   VecAXPY(Ax,-lambda,x);
261:   VecNorm(Ax,NORM_2,r);
262:   VecDestroy(&Ax);
263:   return(0);
264: }

slepc-3.7.4/src/eps/examples/tutorials/ex10.c0000644000175000017500000002501113107004621020325 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Illustrates the use of shell spectral transformations. " "The problem to be solved is the same as ex1.c and" "corresponds to the Laplacian operator in 1 dimension.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions = matrix dimension.\n\n"; #include /* Define context for user-provided spectral transformation */ typedef struct { KSP ksp; } SampleShellST; /* Declare routines for user-provided spectral transformation */ PetscErrorCode STCreate_User(SampleShellST**); PetscErrorCode STSetUp_User(SampleShellST*,ST); PetscErrorCode STApply_User(ST,Vec,Vec); PetscErrorCode STBackTransform_User(ST,PetscInt,PetscScalar*,PetscScalar*); PetscErrorCode STDestroy_User(SampleShellST*); #undef __FUNCT__ #define __FUNCT__ "main" int main (int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ ST st; /* spectral transformation context */ SampleShellST *shell; /* user-defined spectral transform context */ EPSType type; PetscInt n=30,i,Istart,Iend,nev; PetscBool isShell,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem (shell-enabled), n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iksp);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(newctx->ksp,"st_");CHKERRQ(ierr); *shell = newctx; PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "STSetUp_User" /* STSetUp_User - This routine sets up a user-defined spectral transformation context. Input Parameters: . shell - user-defined spectral transformation context . st - spectral transformation context containing the operator matrices Output Parameter: . shell - fully set up user-defined transformation context Notes: In this example, the user-defined transformation is simply OP=A^-1. Therefore, the eigenpairs converge in reversed order. The KSP object used for the solution of linear systems with A is handled via the user-defined context SampleShellST. */ PetscErrorCode STSetUp_User(SampleShellST *shell,ST st) { Mat A; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = STGetOperators(st,0,&A);CHKERRQ(ierr); ierr = KSPSetOperators(shell->ksp,A,A);CHKERRQ(ierr); ierr = KSPSetFromOptions(shell->ksp);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "STApply_User" /* STApply_User - This routine demonstrates the use of a user-provided spectral transformation. Input Parameters: . ctx - optional user-defined context, as set by STShellSetContext() . x - input vector Output Parameter: . y - output vector Notes: The transformation implemented in this code is just OP=A^-1 and therefore it is of little use, merely as an example of working with a STSHELL. */ PetscErrorCode STApply_User(ST st,Vec x,Vec y) { SampleShellST *shell; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = STShellGetContext(st,(void**)&shell);CHKERRQ(ierr); ierr = KSPSolve(shell->ksp,x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "STBackTransform_User" /* STBackTransform_User - This routine demonstrates the use of a user-provided spectral transformation. Input Parameters: + ctx - optional user-defined context, as set by STShellSetContext() . eigr - pointer to real part of eigenvalues - eigi - pointer to imaginary part of eigenvalues Output Parameters: + eigr - modified real part of eigenvalues - eigi - modified imaginary part of eigenvalues Notes: This code implements the back transformation of eigenvalues in order to retrieve the eigenvalues of the original problem. In this example, simply set k_i = 1/k_i. */ PetscErrorCode STBackTransform_User(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) { PetscInt j; PetscFunctionBeginUser; for (j=0;jksp);CHKERRQ(ierr); ierr = PetscFree(shell);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tutorials/makefile.html0000644000175000017500000004431713107004621022061 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/eps/examples/tutorials/
EXAMPLESC  = ex1.c ex2.c ex3.c ex4.c ex5.c ex7.c ex9.c ex10.c ex11.c ex12.c ex13.c \
             ex18.c ex19.c ex24.c ex25.c ex29.c ex30.c ex31.c
EXAMPLESF  = ex1f.F ex1f90.F90 ex6f.F
MANSEC     = EPS

TESTEXAMPLES_C                 = ex2.PETSc runex2_1 runex2_ciss_1 runex2_ciss_2 ex2.rm \
                                 ex3.PETSc runex3_1 ex3.rm \
                                 ex5.PETSc runex5_1 ex5.rm \
                                 ex9.PETSc runex9_1 runex9_2 ex9.rm \
                                 ex10.PETSc runex10_1 ex10.rm \
                                 ex11.PETSc runex11_1 ex11.rm \
                                 ex12.PETSc runex12_1 ex12.rm \
                                 ex13.PETSc runex13_1 ex13.rm \
                                 ex18.PETSc runex18_1 ex18.rm \
                                 ex24.PETSc runex24_1 ex24.rm \
                                 ex29.PETSc runex29_1 ex29.rm \
                                 ex30.PETSc runex30_1 ex30.rm
TESTEXAMPLES_C_NOCOMPLEX       = ex4.PETSc runex4_1 ex4.rm \
                                 ex7.PETSc runex7_1 ex7.rm \
                                 ex25.PETSc runex25_1 ex25.rm \
                                 ex31.PETSc runex31_1 ex31.rm
TESTEXAMPLES_FORTRAN_NOCOMPLEX = ex6f.PETSc runex6f_1 ex6f.rm
TESTEXAMPLES_F90               = ex1f90.PETSc runex1f90_1 ex1f90.rm
TESTEXAMPLES_DATAFILESPATH_COMPLEX = ex4.PETSc runex4_ciss_1 ex4.rm \
                                 ex7.PETSc runex7_ciss_1 ex7.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

ex1: ex1.o chkopts
	-${CLINKER} -o ex1 ex1.o ${SLEPC_EPS_LIB}
	${RM} ex1.o

ex1f: ex1f.o chkopts
	-${FLINKER} -o ex1f ex1f.o ${SLEPC_EPS_LIB}
	${RM} ex1f.o

ex1f90: ex1f90.o chkopts
	-${FLINKER} -o ex1f90 ex1f90.o ${SLEPC_EPS_LIB}
	${RM} ex1f90.o

ex2: ex2.o chkopts
	-${CLINKER} -o ex2 ex2.o ${SLEPC_EPS_LIB}
	${RM} ex2.o

ex3: ex3.o chkopts
	-${CLINKER} -o ex3 ex3.o ${SLEPC_EPS_LIB}
	${RM} ex3.o

ex4: ex4.o chkopts
	-${CLINKER} -o ex4 ex4.o ${SLEPC_EPS_LIB}
	${RM} ex4.o

ex5: ex5.o chkopts
	-${CLINKER} -o ex5 ex5.o ${SLEPC_EPS_LIB}
	${RM} ex5.o

ex6f: ex6f.o chkopts
	-${FLINKER} -o ex6f ex6f.o ${SLEPC_EPS_LIB}
	${RM} ex6f.o

ex7: ex7.o chkopts
	-${CLINKER} -o ex7 ex7.o ${SLEPC_EPS_LIB}
	${RM} ex7.o

ex9: ex9.o chkopts
	-${CLINKER} -o ex9 ex9.o ${SLEPC_EPS_LIB}
	${RM} ex9.o

ex10: ex10.o chkopts
	-${CLINKER} -o ex10 ex10.o ${SLEPC_EPS_LIB}
	${RM} ex10.o

ex11: ex11.o chkopts
	-${CLINKER} -o ex11 ex11.o ${SLEPC_EPS_LIB}
	${RM} ex11.o

ex12: ex12.o chkopts
	-${CLINKER} -o ex12 ex12.o ${SLEPC_EPS_LIB}
	${RM} ex12.o

ex13: ex13.o chkopts
	-${CLINKER} -o ex13 ex13.o ${SLEPC_EPS_LIB}
	${RM} ex13.o

ex18: ex18.o chkopts
	-${CLINKER} -o ex18 ex18.o ${SLEPC_EPS_LIB}
	${RM} ex18.o

ex19: ex19.o chkopts
	-${CLINKER} -o ex19 ex19.o ${SLEPC_EPS_LIB}
	${RM} ex19.o

ex24: ex24.o chkopts
	-${CLINKER} -o ex24 ex24.o ${SLEPC_EPS_LIB}
	${RM} ex24.o

ex25: ex25.o chkopts
	-${CLINKER} -o ex25 ex25.o ${SLEPC_EPS_LIB}
	${RM} ex25.o

ex29: ex29.o chkopts
	-${CLINKER} -o ex29 ex29.o ${SLEPC_EPS_LIB}
	${RM} ex29.o

ex30: ex30.o chkopts
	-${CLINKER} -o ex30 ex30.o ${SLEPC_EPS_LIB}
	${RM} ex30.o

ex31: ex31.o chkopts
	-${CLINKER} -o ex31 ex31.o ${SLEPC_EPS_LIB}
	${RM} ex31.o

#------------------------------------------------------------------------------------
DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices

runex1_1:
	-@${MPIEXEC} -n 1 ./ex1 > ex1_1.tmp 2>&1; \
	   if (${DIFF} output/ex1_1.out ex1_1.tmp) then true; \
	   else echo "Possible problem with ex1_1, diffs above"; fi; \
	   ${RM} -f ex1_1.tmp

runex1f_1:
	-@${MPIEXEC} -n 1 ./ex1f > ex1f_1.tmp 2>&1; \
	   if (${DIFF} output/ex1f_1.out ex1f_1.tmp) then true; \
	   else echo "Possible problem with ex1f_1, diffs above"; fi; \
	   ${RM} -f ex1f_1.tmp

runex1f90_1:
	-@${MPIEXEC} -n 1 ./ex1f90 -eps_nev 4 -terse > ex1f90_1.tmp 2>&1; \
	   if (${DIFF} output/ex1f90_1.out ex1f90_1.tmp) then true; \
	   else echo "Possible problem with ex1f90_1, diffs above"; fi; \
	   ${RM} -f ex1f90_1.tmp

runex2_1:
	-@${MPIEXEC} -n 1 ./ex2 -eps_nev 4 -terse > ex2_1.tmp 2>&1; \
	   if (${DIFF} output/ex2_1.out ex2_1.tmp) then true; \
	   else echo "Possible problem with ex2_1, diffs above"; fi; \
	   ${RM} -f ex2_1.tmp

runex2_ciss_1:
	-@if [ "${PETSC_PRECISION}" != "double" ]; then \
	   echo "Skipping ex2_ciss_1 test"; \
	 else \
	   ${MPIEXEC} -n 1 ./ex2 -n 30 -eps_type ciss -rg_type interval -rg_interval_endpoints 1.1,1.25 -terse > ex2_ciss.tmp 2>&1; \
	   if (${DIFF} output/ex2_ciss.out ex2_ciss.tmp) then true; \
	   else echo "Possible problem with ex2_ciss_1, diffs above"; fi; \
	   ${RM} -f ex2_ciss.tmp; \
	 fi

runex2_ciss_2:
	-@if [ "${PETSC_PRECISION}" != "double" ]; then \
	   echo "Skipping ex2_ciss_2 test"; \
	 else \
	   ${MPIEXEC} -n 2 ./ex2 -n 30 -eps_type ciss -rg_type ellipse -rg_ellipse_center 1.175 -rg_ellipse_radius 0.075 -eps_ciss_partitions 2 -terse > ex2_ciss.tmp 2>&1; \
	   if (${DIFF} output/ex2_ciss.out ex2_ciss.tmp) then true; \
	   else echo "Possible problem with ex2_ciss_2, diffs above"; fi; \
	   ${RM} -f ex2_ciss.tmp; \
	 fi

runex3_1:
	-@${MPIEXEC} -n 1 ./ex3 -eps_nev 4 -terse > ex3_1.tmp 2>&1; \
	   if (${DIFF} output/ex3_1.out ex3_1.tmp) then true; \
	   else echo "Possible problem with ex3_1, diffs above"; fi; \
	   ${RM} -f ex3_1.tmp

runex4_1:
	-@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
	   echo "Skipping ex4 test"; \
	 else \
	   ${MPIEXEC} -n 1 ./ex4 -file ${DATAPATH}/rdb200.petsc -eps_nev 4 -terse > ex4_1.tmp 2>&1; \
	   if (${DIFF} output/ex4_1.out ex4_1.tmp) then true; \
	   else echo "Possible problem with ex4_1, diffs above"; fi; \
	   ${RM} -f ex4_1.tmp; \
	 fi

runex4_ciss_1:
	-@${MPIEXEC} -n 1 ./ex4 -file $(DATAFILESPATH)/matrices/complex/qc324.petsc -eps_type ciss -rg_type ellipse -rg_ellipse_center -.012-.08i -rg_ellipse_radius .05 -terse > ex4_ciss_1.tmp 2>&1; \
	   if (${DIFF} output/ex4_ciss_1.out ex4_ciss_1.tmp) then true; \
	   else echo "Possible problem with ex4_ciss_1, diffs above"; fi; \
	   ${RM} -f ex4_ciss_1.tmp;

runex5_1:
	-@${MPIEXEC} -n 1 ./ex5 -st_shift 1 -eps_nev 4 -terse > ex5_1.tmp 2>&1; \
	   if (${DIFF} output/ex5_1.out ex5_1.tmp) then true; \
	   else echo "Possible problem with ex5_1, diffs above"; fi; \
	   ${RM} -f ex5_1.tmp

runex6f_1:
	-@${MPIEXEC} -n 1 ./ex6f -eps_max_it 1000 -eps_ncv 12 -eps_tol 1e-5 -eps_nev 4 -terse > ex6f_1.tmp 2>&1; \
	   if (${DIFF} output/ex6f_1.out ex6f_1.tmp) then true; \
	   else echo "Possible problem with ex6f_1, diffs above"; fi; \
	   ${RM} -f ex6f_1.tmp

runex7_1:
	-@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
	   echo "Skipping ex7 test"; \
	 else \
           ${MPIEXEC} -n 1 ./ex7 -f1 ${DATAPATH}/bfw62a.petsc -f2 ${DATAPATH}/bfw62b.petsc -eps_nev 4 -terse > ex7_1.tmp 2>&1; \
	   if (${DIFF} output/ex7_1.out ex7_1.tmp) then true; \
	   else echo "Possible problem with ex7_1, diffs above"; fi; \
	   ${RM} -f ex7_1.tmp; \
	 fi

runex7_ciss_1:
	-@${MPIEXEC} -n 1 ./ex7 -f1 $(DATAFILESPATH)/matrices/complex/mhd1280a.petsc -f2 $(DATAFILESPATH)/matrices/complex/mhd1280b.petsc -eps_type ciss -eps_ciss_usest 0 -eps_ciss_quadrule chebyshev -rg_type ring -rg_ring_center 0 -rg_ring_radius .5 -rg_ring_width 0.2 -rg_ring_startangle .25 -rg_ring_endangle .5 -terse > ex7_ciss_1.tmp 2>&1; \
	   if (${DIFF} output/ex7_ciss_1.out ex7_ciss_1.tmp) then true; \
	   else echo "Possible problem with ex7_ciss_1, diffs above"; fi; \
	   ${RM} -f ex7_ciss_1.tmp;

runex9_1:
	-@${MPIEXEC} -n 1 ./ex9 -eps_nev 4 -terse > ex9_1.tmp 2>&1; \
	   if (${DIFF} output/ex9_1.out ex9_1.tmp) then true; \
	   else echo "Possible problem with ex9_1, diffs above"; fi; \
	   ${RM} -f ex9_1.tmp

runex9_2:
	-@${MPIEXEC} -n 1 ./ex9 -eps_nev 8 -eps_max_it 300 -eps_target -28 -rg_type interval -rg_interval_endpoints -40,-20,-.1,.1 -terse > ex9_2.tmp 2>&1; \
	   if (${DIFF} output/ex9_2.out ex9_2.tmp) then true; \
	   else echo "Possible problem with ex9_2, diffs above"; fi; \
	   ${RM} -f ex9_2.tmp

runex10_1:
	-@${MPIEXEC} -n 1 ./ex10 -eps_nev 5 -st_type shell -terse > ex10_1.tmp 2>&1; \
	   if (${DIFF} output/ex10_1.out ex10_1.tmp) then true; \
	   else echo "Possible problem with ex10_1, diffs above"; fi; \
	   ${RM} -f ex10_1.tmp
runex11_1:
	-@${MPIEXEC} -n 1 ./ex11 -eps_nev 4 -terse > ex11_1.tmp 2>&1; \
	   if (${DIFF} output/ex11_1.out ex11_1.tmp) then true; \
	   else echo "Possible problem with ex11_1, diffs above"; fi; \
	   ${RM} -f ex11_1.tmp

runex12_1:
	-@${MPIEXEC} -n 1 ./ex12 -eps_krylovschur_nev 30 > ex12_1.tmp 2>&1; \
	   if (${DIFF} output/ex12_1.out ex12_1.tmp) then true; \
	   else echo "Possible problem with ex12_1, diffs above"; fi; \
	   ${RM} -f ex12_1.tmp

runex13_1:
	-@${MPIEXEC} -n 1 ./ex13 -eps_nev 4 -terse > ex13_1.tmp 2>&1; \
	   if (${DIFF} output/ex13_1.out ex13_1.tmp) then true; \
	   else echo "Possible problem with ex13_1, diffs above"; fi; \
	   ${RM} -f ex13_1.tmp

runex18_1:
	-@${MPIEXEC} -n 1 ./ex18 -eps_nev 4 -terse > ex18_1.tmp 2>&1; \
	   if (${DIFF} output/ex18_1.out ex18_1.tmp) then true; \
	   else echo "Possible problem with ex18_1, diffs above"; fi; \
	   ${RM} -f ex18_1.tmp

runex19_1:
	-@${MPIEXEC} -n 1 ./ex19 -eps_nev 8 -eps_ncv 64 > ex19_1.tmp 2>&1; \
	   if (${DIFF} output/ex19_1.out ex19_1.tmp) then true; \
	   else echo "Possible problem with ex19_1, diffs above"; fi; \
	   ${RM} -f ex19_1.tmp

runex24_1:
	-@${MPIEXEC} -n 1 ./ex24 -n 15 -eps_ncv 20 -terse > ex24_1.tmp 2>&1; \
	   if (${DIFF} output/ex24_1.out ex24_1.tmp) then true; \
	   else echo "Possible problem with ex24_1, diffs above"; fi; \
	   ${RM} -f ex24_1.tmp

runex25_1:
	-@${MPIEXEC} -n 1 ./ex25 -terse > ex25_1.tmp 2>&1; \
	   if (${DIFF} output/ex25_1.out ex25_1.tmp) then true; \
	   else echo "Possible problem with ex25_1, diffs above"; fi; \
	   ${RM} -f ex25_1.tmp

runex29_1:
	-@${MPIEXEC} -n 1 ./ex29 -m 350 > ex29_1.tmp 2>&1; \
	   if (${DIFF} output/ex29_1.out ex29_1.tmp) then true; \
	   else echo "Possible problem with ex29_1, diffs above"; fi; \
	   ${RM} -f ex29_1.tmp

runex30_1:
	-@${MPIEXEC} -n 1 ./ex30 -n 100 -terse > ex30_1.tmp 2>&1; \
	   if (${DIFF} output/ex30_1.out ex30_1.tmp) then true; \
	   else echo "Possible problem with ex30_1, diffs above"; fi; \
	   ${RM} -f ex30_1.tmp

runex31_1:
	-@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
           echo "Skipping ex31 test"; \
         else \
	   ${MPIEXEC} -n 1 ./ex31 -terse > ex31_1.tmp 2>&1; \
	   if (${DIFF} output/ex31_1.out ex31_1.tmp) then true; \
	   else echo "Possible problem with ex31_1, diffs above"; fi; \
	   ${RM} -f ex31_1.tmp; \
         fi

slepc-3.7.4/src/eps/examples/tutorials/ex29.c.html0000644000175000017500000004213513107004621021310 0ustar jromanjroman
Actual source code: ex29.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves the same problem as in ex5, with a user-defined stopping test."
 23:   "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n"
 24:   "This example illustrates how the user can set a custom stopping test function.\n\n"
 25:   "The command line options are:\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in each dimension.\n"
 27:   "  -seconds <s>, where <s> = maximum time in seconds allowed for computation.\n\n";

 29: #include <slepceps.h>
 30: #include <petsctime.h>

 32: /*
 33:    User-defined routines
 34: */

 36: PetscErrorCode MyStoppingTest(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*);
 37: PetscErrorCode MatMarkovModel(PetscInt,Mat);

 41: int main(int argc,char **argv)
 42: {
 43:   Mat                A;               /* operator matrix */
 44:   EPS                eps;             /* eigenproblem solver context */
 45:   PetscReal          seconds=2.5;     /* maximum time allowed for computation */
 46:   PetscLogDouble     deadline;        /* time to abort computation */
 47:   PetscInt           N,m=15,nconv;
 48:   PetscBool          terse;
 49:   PetscViewer        viewer;
 50:   EPSConvergedReason reason;
 51:   PetscErrorCode     ierr;

 53:   SlepcInitialize(&argc,&argv,(char*)0,help);

 55:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 56:   N = m*(m+1)/2;
 57:   PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n",N,m);
 58:   PetscOptionsGetReal(NULL,NULL,"-seconds",&seconds,NULL);
 59:   PetscPrintf(PETSC_COMM_WORLD,"Maximum time for computation is set to %g seconds.\n\n",(double)seconds);
 60:   deadline = seconds;
 61:   PetscTimeAdd(&deadline);

 63:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 64:      Compute the operator matrix that defines the eigensystem, Ax=kx
 65:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 67:   MatCreate(PETSC_COMM_WORLD,&A);
 68:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 69:   MatSetFromOptions(A);
 70:   MatSetUp(A);
 71:   MatMarkovModel(m,A);

 73:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 74:                 Create the eigensolver and set various options
 75:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 77:   EPSCreate(PETSC_COMM_WORLD,&eps);
 78:   EPSSetOperators(eps,A,NULL);
 79:   EPSSetProblemType(eps,EPS_NHEP);
 80:   EPSSetStoppingTestFunction(eps,MyStoppingTest,&deadline,NULL);
 81:   EPSSetFromOptions(eps);

 83:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 84:                       Solve the eigensystem
 85:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 87:   EPSSolve(eps);

 89:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 90:                     Display solution and clean up
 91:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 93:   /* show detailed info unless -terse option is given by user */
 94:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
 95:   if (terse) {
 96:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
 97:   } else {
 98:     PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 99:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
100:     EPSGetConvergedReason(eps,&reason);
101:     if (reason!=EPS_CONVERGED_USER) {
102:       EPSReasonView(eps,viewer);
103:       EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);
104:     } else {
105:       EPSGetConverged(eps,&nconv);
106:       PetscViewerASCIIPrintf(viewer,"Eigensolve finished with %D converged eigenpairs; reason=%s\n",nconv,EPSConvergedReasons[reason]);
107:     }
108:     PetscViewerPopFormat(viewer);
109:   }
110:   EPSDestroy(&eps);
111:   MatDestroy(&A);
112:   SlepcFinalize();
113:   return ierr;
114: }

118: /*
119:     Matrix generator for a Markov model of a random walk on a triangular grid.

121:     This subroutine generates a test matrix that models a random walk on a
122:     triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a
123:     FORTRAN subroutine to calculate the dominant invariant subspaces of a real
124:     matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few
125:     papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295
126:     (1980) ]. These matrices provide reasonably easy test problems for eigenvalue
127:     algorithms. The transpose of the matrix  is stochastic and so it is known
128:     that one is an exact eigenvalue. One seeks the eigenvector of the transpose
129:     associated with the eigenvalue unity. The problem is to calculate the steady
130:     state probability distribution of the system, which is the eigevector
131:     associated with the eigenvalue one and scaled in such a way that the sum all
132:     the components is equal to one.

134:     Note: the code will actually compute the transpose of the stochastic matrix
135:     that contains the transition probabilities.
136: */
137: PetscErrorCode MatMarkovModel(PetscInt m,Mat A)
138: {
139:   const PetscReal cst = 0.5/(PetscReal)(m-1);
140:   PetscReal       pd,pu;
141:   PetscInt        Istart,Iend,i,j,jmax,ix=0;
142:   PetscErrorCode  ierr;

145:   MatGetOwnershipRange(A,&Istart,&Iend);
146:   for (i=1;i<=m;i++) {
147:     jmax = m-i+1;
148:     for (j=1;j<=jmax;j++) {
149:       ix = ix + 1;
150:       if (ix-1<Istart || ix>Iend) continue;  /* compute only owned rows */
151:       if (j!=jmax) {
152:         pd = cst*(PetscReal)(i+j-1);
153:         /* north */
154:         if (i==1) {
155:           MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);
156:         } else {
157:           MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);
158:         }
159:         /* east */
160:         if (j==1) {
161:           MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);
162:         } else {
163:           MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);
164:         }
165:       }
166:       /* south */
167:       pu = 0.5 - cst*(PetscReal)(i+j-3);
168:       if (j>1) {
169:         MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);
170:       }
171:       /* west */
172:       if (i>1) {
173:         MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);
174:       }
175:     }
176:   }
177:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
178:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
179:   return(0);
180: }

184: /*
185:     Function for user-defined stopping test.

187:     Checks that the computing time has not exceeded the deadline.
188: */
189: PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)
190: {
192:   PetscLogDouble now,deadline = *(PetscLogDouble*)ctx;

195:   /* check if usual termination conditions are met */
196:   EPSStoppingBasic(eps,its,max_it,nconv,nev,reason,NULL);
197:   if (*reason==EPS_CONVERGED_ITERATING) {
198:     /* check if deadline has expired */
199:     PetscTime(&now);
200:     if (now>deadline) *reason = EPS_CONVERGED_USER;
201:   }
202:   return(0);
203: }

slepc-3.7.4/src/eps/examples/tutorials/ex6f.F.html0000644000175000017500000005264513107004621021343 0ustar jromanjroman
Actual source code: ex6f.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./ex6f [-help] [-m <m>] [all SLEPc options] 
 21: !
 22: !  Description: This example solves the eigensystem arising in the Ising
 23: !  model for ferromagnetic materials. The file mvmisg.f must be linked
 24: !  together. Information about the model can be found at the following 
 25: !  site http://math.nist.gov/MatrixMarket/data/NEP
 26: !
 27: !  The command line options are:
 28: !    -m <m>, where <m> is the number of 2x2 blocks, i.e. matrix size N=2*m
 29: !
 30: ! ---------------------------------------------------------------------- 
 31: !
 32:       program main
 33:       implicit none

 35: #include <petsc/finclude/petscsys.h>
 36: #include <petsc/finclude/petscvec.h>
 37: #include <petsc/finclude/petscmat.h>
 38: #include <petsc/finclude/petscviewer.h>
 39: #include <slepc/finclude/slepcsys.h>
 40: #include <slepc/finclude/slepceps.h>

 42: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 43: !     Declarations
 44: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 45: !
 46: !  Variables:
 47: !     A     operator matrix
 48: !     eps   eigenproblem solver context

 50:       Mat            A
 51:       EPS            eps
 52:       EPSType        tname
 53:       PetscReal      tol
 54:       PetscInt       N, m
 55:       PetscInt       nev, maxit, its
 56:       PetscMPIInt    sz, rank
 57:       PetscErrorCode ierr
 58:       PetscBool      flg, terse

 60: !     This is the routine to use for matrix-free approach
 61: !
 62:       external MatIsing_Mult

 64: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 65: !     Beginning of program
 66: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 68:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 69: #if defined(PETSC_USE_COMPLEX)
 70:       write(*,*) 'This example requires real numbers.'
 71:       goto 999
 72: #endif
 73:       call MPI_Comm_size(PETSC_COMM_WORLD,sz,ierr)
 74:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 75:       if (sz .ne. 1) then
 76:          if (rank .eq. 0) then
 77:             write(*,*) 'This is a uniprocessor example only!'
 78:          endif
 79:          SETERRQ(PETSC_COMM_WORLD,1,' ',ierr)
 80:       endif
 81:       m = 30
 82:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 83:      &                        '-m',m,flg,ierr)
 84:       N = 2*m

 86:       if (rank .eq. 0) then
 87:         write(*,*)
 88:         write(*,'(A,I6,A)') 'Ising Model Eigenproblem, m=',m,', (N=2*m)'
 89:         write(*,*)
 90:       endif

 92: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 93: !     Register the matrix-vector subroutine for the operator that defines
 94: !     the eigensystem, Ax=kx
 95: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 97:       call MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,PETSC_NULL_OBJECT,   &
 98:      &                    A,ierr)
 99:       call MatShellSetOperation(A,MATOP_MULT,MatIsing_Mult,ierr)

101: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
102: !     Create the eigensolver and display info
103: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

105: !     ** Create eigensolver context
106:       call EPSCreate(PETSC_COMM_WORLD,eps,ierr)

108: !     ** Set operators. In this case, it is a standard eigenvalue problem
109:       call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr)
110:       call EPSSetProblemType(eps,EPS_NHEP,ierr)

112: !     ** Set solver parameters at runtime
113:       call EPSSetFromOptions(eps,ierr)

115: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
116: !     Solve the eigensystem
117: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

119:       call EPSSolve(eps,ierr) 
120:       call EPSGetIterationNumber(eps,its,ierr)
121:       if (rank .eq. 0) then
122:         write(*,'(A,I4)') ' Number of iterations of the method: ', its
123:       endif

125: !     ** Optional: Get some information from the solver and display it
126:       call EPSGetType(eps,tname,ierr)
127:       if (rank .eq. 0) then
128:         write(*,'(A,A)') ' Solution method: ', tname
129:       endif
130:       call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER,                 &
131:      &                      PETSC_NULL_INTEGER,ierr)
132:       if (rank .eq. 0) then
133:         write(*,'(A,I2)') ' Number of requested eigenvalues:', nev
134:       endif
135:       call EPSGetTolerances(eps,tol,maxit,ierr)
136:       if (rank .eq. 0) then
137:         write(*,'(A,1PE10.4,A,I6)') ' Stopping condition: tol=', tol,   &
138:      &                              ', maxit=', maxit
139:       endif

141: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
142: !     Display solution and clean up
143: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

145: !     ** show detailed info unless -terse option is given by user
146:       call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,  &
147:      &                        '-terse',terse,ierr)
148:       if (terse) then
149:         call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr)
150:       else
151:         call PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,           &
152:      &                   PETSC_VIEWER_ASCII_INFO_DETAIL,ierr)
153:         call EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD,ierr)
154:         call EPSErrorView(eps,EPS_ERROR_RELATIVE,                       &
155:      &                   PETSC_VIEWER_STDOUT_WORLD,ierr)
156:         call PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD,ierr)
157:       endif
158:       call EPSDestroy(eps,ierr)
159:       call MatDestroy(A,ierr)

161: #if defined(PETSC_USE_COMPLEX)
162:  999  continue
163: #endif
164:       call SlepcFinalize(ierr)
165:       end

167: ! ------------------------------------------------------------------- 
168: ! 
169: !   MatIsing_Mult - user provided matrix-vector multiply 
170: !
171: !   Input Parameters:
172: !   A - matrix
173: !   x - input vector
174: !
175: !   Output Parameter:
176: !   y - output vector
177: ! 
178:       subroutine MatIsing_Mult(A,x,y,ierr)
179:       implicit none

181: #include <petsc/finclude/petscsys.h>
182: #include <petsc/finclude/petscvec.h>
183: #include <petsc/finclude/petscmat.h>

185:       Mat            A
186:       Vec            x,y
187:       PetscInt       trans,one,N
188:       PetscScalar    x_array(1),y_array(1)
189:       PetscOffset    i_x,i_y
190:       PetscErrorCode ierr

192: !     The actual routine for the matrix-vector product
193:       external mvmisg

195:       call MatGetSize(A,N,PETSC_NULL_INTEGER,ierr)
196:       call VecGetArrayRead(x,x_array,i_x,ierr)
197:       call VecGetArray(y,y_array,i_y,ierr)

199:       trans = 0
200:       one = 1
201:       call mvmisg(trans,N,one,x_array(i_x+1),N,y_array(i_y+1),N)

203:       call VecRestoreArrayRead(x,x_array,i_x,ierr)
204:       call VecRestoreArray(y,y_array,i_y,ierr)

206:       return
207:       end

209: ! ------------------------------------------------------------------- 
210: !     The actual routine for the matrix-vector product
211: !     See http://math.nist.gov/MatrixMarket/data/NEP/mvmisg/mvmisg.html

213:       SUBROUTINE MVMISG( TRANS, N, M, X, LDX, Y, LDY )
214: !     ..
215: !     .. Scalar Arguments ..
216:       PetscInt     LDY, LDX, M, N, TRANS
217: !     ..
218: !     .. Array Arguments ..
219:       PetscScalar  Y( LDY, * ), X( LDX, * )
220: !     ..
221: !
222: !  Purpose
223: !  =======
224: !
225: !  Compute
226: !
227: !               Y(:,1:M) = op(A)*X(:,1:M)
228: !
229: !  where op(A) is A or A' (the transpose of A). The A is the Ising 
230: !  matrix.
231: !
232: !  Arguments
233: !  =========
234: !
235: !  TRANS   (input) INTEGER
236: !          If TRANS = 0, compute Y(:,1:M) = A*X(:,1:M) 
237: !          If TRANS = 1, compute Y(:,1:M) = A'*X(:,1:M) 
238: !           
239: !  N       (input) INTEGER
240: !          The order of the matrix A. N has to be an even number.
241: !
242: !  M       (input) INTEGER
243: !          The number of columns of X to multiply.
244: !
245: !  X       (input) DOUBLE PRECISION array, dimension ( LDX, M )
246: !          X contains the matrix (vectors) X.
247: !
248: !  LDX     (input) INTEGER
249: !          The leading dimension of array X, LDX >= max( 1, N )
250: !
251: !  Y       (output) DOUBLE PRECISION array, dimension (LDX, M )
252: !          contains the product of the matrix op(A) with X.
253: !
254: !  LDY     (input) INTEGER
255: !          The leading dimension of array Y, LDY >= max( 1, N )
256: !
257: !  ===================================================================
258: !
259: !
260: #include <petsc/finclude/petscsys.h>

262: !     .. Local Variables .. 
263:       PetscInt    I, K 
264:       PetscReal   ALPHA, BETA
265:       PetscReal   COSA, COSB, SINA
266:       PetscReal   SINB, TEMP, TEMP1 
267: !
268: !     .. Intrinsic functions ..
269:       INTRINSIC   COS, SIN 
270: !
271:       ALPHA = PETSC_PI/4
272:       BETA = PETSC_PI/4
273:       COSA = COS( ALPHA ) 
274:       SINA = SIN( ALPHA ) 
275:       COSB = COS( BETA )
276:       SINB = SIN( BETA ) 
277: !      
278:       IF ( TRANS.EQ.0 ) THEN 
279: !
280: !     Compute Y(:,1:M) = A*X(:,1:M)

282:          DO 30 K = 1, M
283: !
284:             Y( 1, K ) = COSB*X( 1, K ) - SINB*X( N, K ) 
285:             DO 10 I = 2, N-1, 2   
286:                Y( I, K )   =  COSB*X( I, K ) + SINB*X( I+1, K )
287:                Y( I+1, K ) = -SINB*X( I, K ) + COSB*X( I+1, K )  
288:    10       CONTINUE
289:             Y( N, K ) = SINB*X( 1, K ) + COSB*X( N, K ) 
290: !
291:             DO 20 I = 1, N, 2
292:                TEMP        =  COSA*Y( I, K ) + SINA*Y( I+1, K )
293:                Y( I+1, K ) = -SINA*Y( I, K ) + COSA*Y( I+1, K )  
294:                Y( I, K )   = TEMP 
295:    20       CONTINUE  
296: !
297:    30    CONTINUE 
298: !
299:       ELSE IF ( TRANS.EQ.1 ) THEN 
300: !
301: !        Compute Y(:1:M) = A'*X(:,1:M) 
302: !
303:          DO 60 K = 1, M 
304: !
305:             DO 40 I = 1, N, 2
306:                Y( I, K )   =  COSA*X( I, K ) - SINA*X( I+1, K )
307:                Y( I+1, K ) =  SINA*X( I, K ) + COSA*X( I+1, K )  
308:    40       CONTINUE  
309:             TEMP  = COSB*Y(1,K) + SINB*Y(N,K) 
310:             DO 50 I = 2, N-1, 2   
311:                TEMP1       =  COSB*Y( I, K ) - SINB*Y( I+1, K )
312:                Y( I+1, K ) =  SINB*Y( I, K ) + COSB*Y( I+1, K )  
313:                Y( I, K )   =  TEMP1
314:    50       CONTINUE
315:             Y( N, K ) = -SINB*Y( 1, K ) + COSB*Y( N, K ) 
316:             Y( 1, K ) = TEMP 
317: !
318:    60    CONTINUE
319: !
320:       END IF 
321: !
322:       RETURN
323: !  
324: !     END OF MVMISG
325:       END 
slepc-3.7.4/src/eps/examples/tutorials/ex19.c.html0000644000175000017500000004717213107004621021315 0ustar jromanjroman
Actual source code: ex19.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Standard symmetric eigenproblem for the 3-D Laplacian built with the DM interface.\n\n"
 23: "Use -seed <k> to modify the random initial vector.\n"
 24: "Use -da_grid_x <nx> etc. to change the problem size.\n\n";

 26: #include <slepceps.h>
 27: #include <petscdmda.h>
 28: #include <petsctime.h>

 32: PetscErrorCode GetExactEigenvalues(PetscInt M,PetscInt N,PetscInt P,PetscInt nconv,PetscReal *exact)
 33: {
 34:   PetscInt       n,i,j,k,l;
 35:   PetscReal      *evals,ax,ay,az,sx,sy,sz;

 39:   ax = PETSC_PI/2/(M+1);
 40:   ay = PETSC_PI/2/(N+1);
 41:   az = PETSC_PI/2/(P+1);
 42:   n = PetscCeilReal(PetscPowReal((PetscReal)nconv,0.33333)+1);
 43:   PetscMalloc1(n*n*n,&evals);
 44:   l = 0;
 45:   for (i=1;i<=n;i++) {
 46:     sx = PetscSinReal(ax*i);
 47:     for (j=1;j<=n;j++) {
 48:       sy = PetscSinReal(ay*j);
 49:       for (k=1;k<=n;k++) {
 50:         sz = PetscSinReal(az*k);
 51:         evals[l++] = 4.0*(sx*sx+sy*sy+sz*sz);
 52:       }
 53:     }
 54:   }
 55:   PetscSortReal(n*n*n,evals);
 56:   for (i=0;i<nconv;i++) exact[i] = evals[i];
 57:   PetscFree(evals);
 58:   return(0);
 59: }

 63: PetscErrorCode FillMatrix(DM da,Mat A)
 64: {
 66:   PetscInt       i,j,k,mx,my,mz,xm,ym,zm,xs,ys,zs,idx;
 67:   PetscScalar    v[7];
 68:   MatStencil     row,col[7];

 71:   DMDAGetInfo(da,0,&mx,&my,&mz,0,0,0,0,0,0,0,0,0);
 72:   DMDAGetCorners(da,&xs,&ys,&zs,&xm,&ym,&zm);

 74:   for (k=zs;k<zs+zm;k++) {
 75:     for (j=ys;j<ys+ym;j++) {
 76:       for (i=xs;i<xs+xm;i++) {
 77:         row.i=i; row.j=j; row.k=k;
 78:         col[0].i=row.i; col[0].j=row.j; col[0].k=row.k;
 79:         v[0]=6.0;
 80:         idx=1;
 81:         if (k>0) { v[idx]=-1.0; col[idx].i=i; col[idx].j=j; col[idx].k=k-1; idx++; }
 82:         if (j>0) { v[idx]=-1.0; col[idx].i=i; col[idx].j=j-1; col[idx].k=k; idx++; }
 83:         if (i>0) { v[idx]=-1.0; col[idx].i=i-1; col[idx].j=j; col[idx].k=k; idx++; }
 84:         if (i<mx-1) { v[idx]=-1.0; col[idx].i=i+1; col[idx].j=j; col[idx].k=k; idx++; }
 85:         if (j<my-1) { v[idx]=-1.0; col[idx].i=i; col[idx].j=j+1; col[idx].k=k; idx++; }
 86:         if (k<mz-1) { v[idx]=-1.0; col[idx].i=i; col[idx].j=j; col[idx].k=k+1; idx++; }
 87:         MatSetValuesStencil(A,1,&row,idx,col,v,INSERT_VALUES);
 88:       }
 89:     }
 90:   }
 91:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 92:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 93:   return(0);
 94: }

 98: int main(int argc,char **argv)
 99: {
100:   Mat            A;               /* operator matrix */
101:   EPS            eps;             /* eigenproblem solver context */
102:   EPSType        type;
103:   DM             da;
104:   Vec            v0;
105:   PetscReal      error,tol,re,im,*exact;
106:   PetscScalar    kr,ki;
107:   PetscInt       M,N,P,m,n,p,nev,maxit,i,its,nconv,seed;
108:   PetscLogDouble t1,t2,t3;
109:   PetscBool      flg;
110:   PetscRandom    rctx;

113:   SlepcInitialize(&argc,&argv,(char*)0,help);

115:   PetscPrintf(PETSC_COMM_WORLD,"\n3-D Laplacian Eigenproblem\n\n");

117:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
118:      Compute the operator matrix that defines the eigensystem, Ax=kx
119:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

121:   DMDACreate3d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,
122:                       DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,-10,-10,-10,
123:                       PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,
124:                       1,1,NULL,NULL,NULL,&da);

126:   /* print DM information */
127:   DMDAGetInfo(da,NULL,&M,&N,&P,&m,&n,&p,NULL,NULL,NULL,NULL,NULL,NULL);
128:   PetscPrintf(PETSC_COMM_WORLD," Grid partitioning: %D %D %D\n",m,n,p);

130:   /* create and fill the matrix */
131:   DMCreateMatrix(da,&A);
132:   FillMatrix(da,A);

134:   /* create random initial vector */
135:   seed = 1;
136:   PetscOptionsGetInt(NULL,NULL,"-seed",&seed,NULL);
137:   if (seed<0) SETERRQ(PETSC_COMM_WORLD,1,"Seed must be >=0");
138:   MatCreateVecs(A,&v0,NULL);
139:   PetscRandomCreate(PETSC_COMM_WORLD,&rctx);
140:   PetscRandomSetFromOptions(rctx);
141:   for (i=0;i<seed;i++) {   /* simulate different seeds in the random generator */
142:     VecSetRandom(v0,rctx);
143:   }

145:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
146:                 Create the eigensolver and set various options
147:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

149:   /*
150:      Create eigensolver context
151:   */
152:   EPSCreate(PETSC_COMM_WORLD,&eps);

154:   /*
155:      Set operators. In this case, it is a standard eigenvalue problem
156:   */
157:   EPSSetOperators(eps,A,NULL);
158:   EPSSetProblemType(eps,EPS_HEP);

160:   /*
161:      Set specific solver options
162:   */
163:   EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);
164:   EPSSetTolerances(eps,1e-8,PETSC_DEFAULT);
165:   EPSSetInitialSpace(eps,1,&v0);

167:   /*
168:      Set solver parameters at runtime
169:   */
170:   EPSSetFromOptions(eps);

172:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
173:                       Solve the eigensystem
174:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

176:   PetscTime(&t1);
177:   EPSSetUp(eps);
178:   PetscTime(&t2);
179:   EPSSolve(eps);
180:   PetscTime(&t3);
181:   EPSGetIterationNumber(eps,&its);
182:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);

184:   /*
185:      Optional: Get some information from the solver and display it
186:   */
187:   EPSGetType(eps,&type);
188:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
189:   EPSGetDimensions(eps,&nev,NULL,NULL);
190:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
191:   EPSGetTolerances(eps,&tol,&maxit);
192:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

194:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
195:                     Display solution and clean up
196:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

198:   /*
199:      Get number of converged approximate eigenpairs
200:   */
201:   EPSGetConverged(eps,&nconv);
202:   PetscPrintf(PETSC_COMM_WORLD," Number of converged approximate eigenpairs: %D\n\n",nconv);

204:   if (nconv>0) {
205:     PetscMalloc1(nconv,&exact);
206:     GetExactEigenvalues(M,N,P,nconv,exact);
207:     /*
208:        Display eigenvalues and relative errors
209:     */
210:     PetscPrintf(PETSC_COMM_WORLD,
211:          "           k          ||Ax-kx||/||kx||   Eigenvalue Error \n"
212:          "   ----------------- ------------------ ------------------\n");

214:     for (i=0;i<nconv;i++) {
215:       /*
216:         Get converged eigenpairs: i-th eigenvalue is stored in kr (real part) and
217:         ki (imaginary part)
218:       */
219:       EPSGetEigenpair(eps,i,&kr,&ki,NULL,NULL);
220:       /*
221:          Compute the relative error associated to each eigenpair
222:       */
223:       EPSComputeError(eps,i,EPS_ERROR_RELATIVE,&error);

225: #if defined(PETSC_USE_COMPLEX)
226:       re = PetscRealPart(kr);
227:       im = PetscImaginaryPart(kr);
228: #else
229:       re = kr;
230:       im = ki;
231: #endif
232:       if (im!=0.0) SETERRQ(PETSC_COMM_WORLD,1,"Eigenvalue should be real");
233:       else {
234:         PetscPrintf(PETSC_COMM_WORLD,"   %12g       %12g        %12g\n",(double)re,(double)error,(double)PetscAbsReal(re-exact[i]));
235:       }
236:     }
237:     PetscFree(exact);
238:     PetscPrintf(PETSC_COMM_WORLD,"\n");
239:   }

241:   /*
242:      Show computing times
243:   */
244:   PetscOptionsHasName(NULL,NULL,"-showtimes",&flg);
245:   if (flg) {
246:     PetscPrintf(PETSC_COMM_WORLD," Elapsed time: %g (setup), %g (solve)\n",(double)(t2-t1),(double)(t3-t2));
247:   }

249:   /*
250:      Free work space
251:   */
252:   EPSDestroy(&eps);
253:   MatDestroy(&A);
254:   VecDestroy(&v0);
255:   PetscRandomDestroy(&rctx);
256:   DMDestroy(&da);
257:   SlepcFinalize();
258:   return ierr;
259: }

slepc-3.7.4/src/eps/examples/tutorials/ex3.c.html0000644000175000017500000003533713107004621021226 0ustar jromanjroman
Actual source code: ex3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. "
 23:   "The problem is a standard symmetric eigenproblem corresponding to the 2-D Laplacian operator.\n\n"
 24:   "The command line options are:\n"
 25:   "  -n <n>, where <n> = number of grid subdivisions in both x and y dimensions.\n\n";

 27: #include <slepceps.h>
 28: #include <petscblaslapack.h>

 30: /*
 31:    User-defined routines
 32: */
 33: PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y);
 34: PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag);

 38: int main(int argc,char **argv)
 39: {
 40:   Mat            A;               /* operator matrix */
 41:   EPS            eps;             /* eigenproblem solver context */
 42:   EPSType        type;
 43:   PetscMPIInt    size;
 44:   PetscInt       N,n=10,nev;
 45:   PetscBool      terse;

 48:   SlepcInitialize(&argc,&argv,(char*)0,help);
 49:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 50:   if (size != 1) SETERRQ(PETSC_COMM_WORLD,1,"This is a uniprocessor example only");

 52:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 53:   N = n*n;
 54:   PetscPrintf(PETSC_COMM_WORLD,"\n2-D Laplacian Eigenproblem (matrix-free version), N=%D (%Dx%D grid)\n\n",N,n,n);

 56:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 57:      Compute the operator matrix that defines the eigensystem, Ax=kx
 58:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 60:   MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,&n,&A);
 61:   MatSetFromOptions(A);
 62:   MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Laplacian2D);
 63:   MatShellSetOperation(A,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Laplacian2D);
 64:   MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Laplacian2D);

 66:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 67:                 Create the eigensolver and set various options
 68:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 70:   /*
 71:      Create eigensolver context
 72:   */
 73:   EPSCreate(PETSC_COMM_WORLD,&eps);

 75:   /*
 76:      Set operators. In this case, it is a standard eigenvalue problem
 77:   */
 78:   EPSSetOperators(eps,A,NULL);
 79:   EPSSetProblemType(eps,EPS_HEP);

 81:   /*
 82:      Set solver parameters at runtime
 83:   */
 84:   EPSSetFromOptions(eps);

 86:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 87:                       Solve the eigensystem
 88:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 90:   EPSSolve(eps);

 92:   /*
 93:      Optional: Get some information from the solver and display it
 94:   */
 95:   EPSGetType(eps,&type);
 96:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
 97:   EPSGetDimensions(eps,&nev,NULL,NULL);
 98:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

100:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101:                     Display solution and clean up
102:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

104:   /* show detailed info unless -terse option is given by user */
105:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
106:   if (terse) {
107:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
108:   } else {
109:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
110:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
111:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
112:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
113:   }
114:   EPSDestroy(&eps);
115:   MatDestroy(&A);
116:   SlepcFinalize();
117:   return ierr;
118: }

120: /*
121:     Compute the matrix vector multiplication y<---T*x where T is a nx by nx
122:     tridiagonal matrix with DD on the diagonal, DL on the subdiagonal, and
123:     DU on the superdiagonal.
124:  */
125: static void tv(int nx,const PetscScalar *x,PetscScalar *y)
126: {
127:   PetscScalar dd,dl,du;
128:   int         j;

130:   dd  = 4.0;
131:   dl  = -1.0;
132:   du  = -1.0;

134:   y[0] =  dd*x[0] + du*x[1];
135:   for (j=1;j<nx-1;j++)
136:     y[j] = dl*x[j-1] + dd*x[j] + du*x[j+1];
137:   y[nx-1] = dl*x[nx-2] + dd*x[nx-1];
138: }

142: /*
143:     Matrix-vector product subroutine for the 2D Laplacian.

145:     The matrix used is the 2 dimensional discrete Laplacian on unit square with
146:     zero Dirichlet boundary condition.

148:     Computes y <-- A*x, where A is the block tridiagonal matrix

150:                  | T -I          |
151:                  |-I  T -I       |
152:              A = |   -I  T       |
153:                  |        ...  -I|
154:                  |           -I T|

156:     The subroutine TV is called to compute y<--T*x.
157:  */
158: PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)
159: {
160:   void              *ctx;
161:   int               nx,lo,i,j;
162:   const PetscScalar *px;
163:   PetscScalar       *py;
164:   PetscErrorCode    ierr;

167:   MatShellGetContext(A,&ctx);
168:   nx = *(int*)ctx;
169:   VecGetArrayRead(x,&px);
170:   VecGetArray(y,&py);

172:   tv(nx,&px[0],&py[0]);
173:   for (i=0;i<nx;i++) py[i] -= px[nx+i];

175:   for (j=2;j<nx;j++) {
176:     lo = (j-1)*nx;
177:     tv(nx,&px[lo],&py[lo]);
178:     for (i=0;i<nx;i++) py[lo+i] -= px[lo-nx+i] + px[lo+nx+i];
179:   }

181:   lo = (nx-1)*nx;
182:   tv(nx,&px[lo],&py[lo]);
183:   for (i=0;i<nx;i++) py[lo+i] -= px[lo-nx+i];

185:   VecRestoreArrayRead(x,&px);
186:   VecRestoreArray(y,&py);
187:   return(0);
188: }

192: PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)
193: {

197:   VecSet(diag,4.0);
198:   return(0);
199: }

slepc-3.7.4/src/eps/examples/tutorials/ex12.c.html0000644000175000017500000003120713107004621021276 0ustar jromanjroman
Actual source code: ex12.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Compute all eigenvalues in an interval of a symmetric-definite problem.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 25:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n\n";

 27: #include <slepceps.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A,B;         /* matrices */
 34:   EPS            eps;         /* eigenproblem solver context */
 35:   ST             st;          /* spectral transformation context */
 36:   KSP            ksp;
 37:   PC             pc;
 38:   PetscInt       N,n=35,m,Istart,Iend,II,nev,i,j,k,*inertias;
 39:   PetscBool      flag;
 40:   PetscReal      int0,int1,*shifts;

 43:   SlepcInitialize(&argc,&argv,(char*)0,help);

 45:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 46:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 47:   if (!flag) m=n;
 48:   N = n*m;
 49:   PetscPrintf(PETSC_COMM_WORLD,"\nSymmetric-definite problem with two intervals, N=%D (%Dx%D grid)\n\n",N,n,m);

 51:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 52:      Compute the matrices that define the eigensystem, Ax=kBx
 53:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 55:   MatCreate(PETSC_COMM_WORLD,&A);
 56:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 57:   MatSetFromOptions(A);
 58:   MatSetUp(A);

 60:   MatCreate(PETSC_COMM_WORLD,&B);
 61:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);
 62:   MatSetFromOptions(B);
 63:   MatSetUp(B);

 65:   MatGetOwnershipRange(A,&Istart,&Iend);
 66:   for (II=Istart;II<Iend;II++) {
 67:     i = II/n; j = II-i*n;
 68:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); }
 69:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); }
 70:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); }
 71:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); }
 72:     MatSetValue(A,II,II,4.0,INSERT_VALUES);
 73:     MatSetValue(B,II,II,2.0,INSERT_VALUES);
 74:   }
 75:   if (Istart==0) {
 76:     MatSetValue(B,0,0,6.0,INSERT_VALUES);
 77:     MatSetValue(B,0,1,-1.0,INSERT_VALUES);
 78:     MatSetValue(B,1,0,-1.0,INSERT_VALUES);
 79:     MatSetValue(B,1,1,1.0,INSERT_VALUES);
 80:   }

 82:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 83:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 84:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 85:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);

 87:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 88:                 Create the eigensolver and set various options
 89:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 91:   EPSCreate(PETSC_COMM_WORLD,&eps);
 92:   EPSSetOperators(eps,A,B);
 93:   EPSSetProblemType(eps,EPS_GHEP);

 95:   /*
 96:      Set first interval and other settings for spectrum slicing
 97:   */
 98:   EPSSetWhichEigenpairs(eps,EPS_ALL);
 99:   EPSSetInterval(eps,1.1,1.3);
100:   EPSGetST(eps,&st);
101:   STSetType(st,STSINVERT);
102:   STGetKSP(st,&ksp);
103:   KSPGetPC(ksp,&pc);
104:   KSPSetType(ksp,KSPPREONLY);
105:   PCSetType(pc,PCCHOLESKY);
106:   EPSSetFromOptions(eps);

108:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109:                  Solve for first interval and display info
110:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

112:   EPSSolve(eps);
113:   EPSGetDimensions(eps,&nev,NULL,NULL);
114:   EPSGetInterval(eps,&int0,&int1);
115:   PetscPrintf(PETSC_COMM_WORLD," Found %D eigenvalues in interval [%g,%g]\n",nev,(double)int0,(double)int1);
116:   EPSKrylovSchurGetInertias(eps,&k,&shifts,&inertias);
117:   PetscPrintf(PETSC_COMM_WORLD," Used %D shifts (inertia):\n",k);
118:   for (i=0;i<k;i++) {
119:     PetscPrintf(PETSC_COMM_WORLD," .. %g (%D)\n",(double)shifts[i],inertias[i]);
120:   }
121:   PetscFree(shifts);
122:   PetscFree(inertias);

124:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
125:                  Solve for second interval and display info
126:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
127:   EPSSetInterval(eps,1.5,1.6);
128:   EPSSolve(eps);
129:   EPSGetDimensions(eps,&nev,NULL,NULL);
130:   EPSGetInterval(eps,&int0,&int1);
131:   PetscPrintf(PETSC_COMM_WORLD," Found %D eigenvalues in interval [%g,%g]\n",nev,(double)int0,(double)int1);
132:   EPSKrylovSchurGetInertias(eps,&k,&shifts,&inertias);
133:   PetscPrintf(PETSC_COMM_WORLD," Used %D shifts (inertia):\n",k);
134:   for (i=0;i<k;i++) {
135:     PetscPrintf(PETSC_COMM_WORLD," .. %g (%D)\n",(double)shifts[i],inertias[i]);
136:   }
137:   PetscFree(shifts);
138:   PetscFree(inertias);

140:   EPSDestroy(&eps);
141:   MatDestroy(&A);
142:   MatDestroy(&B);
143:   SlepcFinalize();
144:   return ierr;
145: }

slepc-3.7.4/src/eps/examples/tutorials/ex25.c0000644000175000017500000002036213107004621020337 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Spectrum slicing on generalized symmetric eigenproblem.\n\n" "The problem is similar to ex13.c.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B; /* matrices */ EPS eps; /* eigenproblem solver context */ ST st; /* spectral transformation context */ KSP ksp; PC pc; EPSType type; PetscInt N,n=10,m,Istart,Iend,II,nev,i,j,*inertias,ns; PetscReal inta,intb,*shifts; PetscBool flag,show=PETSC_FALSE,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); ierr = PetscOptionsGetBool(NULL,NULL,"-show_inertias",&show,NULL);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSpectrum slicing on GHEP, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, Ax=kBx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j': a tolerance used for null pivot detection (must be larger than machine epsilon) Note: depending on the interval, it may be necessary also to increase the workspace: '-mat_mumps_icntl_14 ': increase workspace with a percentage (50, 100 or more) */ ierr = PetscOptionsInsertString(NULL,"-mat_mumps_icntl_13 1 -mat_mumps_icntl_24 1 -mat_mumps_cntl_3 1e-12");CHKERRQ(ierr); #endif /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSetUp(eps);CHKERRQ(ierr); if (show) { ierr = EPSKrylovSchurGetInertias(eps,&ns,&shifts,&inertias); ierr = PetscPrintf(PETSC_COMM_WORLD,"Subintervals (after setup):\n");CHKERRQ(ierr); for (i=0;iActual source code: ex1.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions = matrix dimension.\n\n";

 26: #include <slepceps.h>

 30: int main(int argc,char **argv)
 31: {
 32:   Mat            A;           /* problem matrix */
 33:   EPS            eps;         /* eigenproblem solver context */
 34:   EPSType        type;
 35:   PetscReal      error,tol,re,im;
 36:   PetscScalar    kr,ki;
 37:   Vec            xr,xi;
 38:   PetscInt       n=30,i,Istart,Iend,nev,maxit,its,nconv;

 41:   SlepcInitialize(&argc,&argv,(char*)0,help);

 43:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 44:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem, n=%D\n\n",n);

 46:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 47:      Compute the operator matrix that defines the eigensystem, Ax=kx
 48:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 50:   MatCreate(PETSC_COMM_WORLD,&A);
 51:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 52:   MatSetFromOptions(A);
 53:   MatSetUp(A);

 55:   MatGetOwnershipRange(A,&Istart,&Iend);
 56:   for (i=Istart;i<Iend;i++) {
 57:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 58:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 59:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 60:   }
 61:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 62:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 64:   MatCreateVecs(A,NULL,&xr);
 65:   MatCreateVecs(A,NULL,&xi);

 67:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 68:                 Create the eigensolver and set various options
 69:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 70:   /*
 71:      Create eigensolver context
 72:   */
 73:   EPSCreate(PETSC_COMM_WORLD,&eps);

 75:   /*
 76:      Set operators. In this case, it is a standard eigenvalue problem
 77:   */
 78:   EPSSetOperators(eps,A,NULL);
 79:   EPSSetProblemType(eps,EPS_HEP);

 81:   /*
 82:      Set solver parameters at runtime
 83:   */
 84:   EPSSetFromOptions(eps);

 86:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 87:                       Solve the eigensystem
 88:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 90:   EPSSolve(eps);
 91:   /*
 92:      Optional: Get some information from the solver and display it
 93:   */
 94:   EPSGetIterationNumber(eps,&its);
 95:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);
 96:   EPSGetType(eps,&type);
 97:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
 98:   EPSGetDimensions(eps,&nev,NULL,NULL);
 99:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
100:   EPSGetTolerances(eps,&tol,&maxit);
101:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

103:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104:                     Display solution and clean up
105:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
106:   /*
107:      Get number of converged approximate eigenpairs
108:   */
109:   EPSGetConverged(eps,&nconv);
110:   PetscPrintf(PETSC_COMM_WORLD," Number of converged eigenpairs: %D\n\n",nconv);

112:   if (nconv>0) {
113:     /*
114:        Display eigenvalues and relative errors
115:     */
116:     PetscPrintf(PETSC_COMM_WORLD,
117:          "           k          ||Ax-kx||/||kx||\n"
118:          "   ----------------- ------------------\n");

120:     for (i=0;i<nconv;i++) {
121:       /*
122:         Get converged eigenpairs: i-th eigenvalue is stored in kr (real part) and
123:         ki (imaginary part)
124:       */
125:       EPSGetEigenpair(eps,i,&kr,&ki,xr,xi);
126:       /*
127:          Compute the relative error associated to each eigenpair
128:       */
129:       EPSComputeError(eps,i,EPS_ERROR_RELATIVE,&error);

131: #if defined(PETSC_USE_COMPLEX)
132:       re = PetscRealPart(kr);
133:       im = PetscImaginaryPart(kr);
134: #else
135:       re = kr;
136:       im = ki;
137: #endif
138:       if (im!=0.0) {
139:         PetscPrintf(PETSC_COMM_WORLD," %9f%+9fi %12g\n",(double)re,(double)im,(double)error);
140:       } else {
141:         PetscPrintf(PETSC_COMM_WORLD,"   %12f       %12g\n",(double)re,(double)error);
142:       }
143:     }
144:     PetscPrintf(PETSC_COMM_WORLD,"\n");
145:   }

147:   /*
148:      Free work space
149:   */
150:   EPSDestroy(&eps);
151:   MatDestroy(&A);
152:   VecDestroy(&xr);
153:   VecDestroy(&xi);
154:   SlepcFinalize();
155:   return ierr;
156: }
slepc-3.7.4/src/eps/examples/tutorials/ex4.c.html0000644000175000017500000002527313107004621021225 0ustar jromanjroman
Actual source code: ex4.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves a standard eigensystem Ax=kx with the matrix loaded from a file.\n"
 23:   "This example works for both real and complex numbers.\n\n"
 24:   "The command line options are:\n"
 25:   "  -file <filename>, where <filename> = matrix file in PETSc binary form.\n\n";

 27: #include <slepceps.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A;               /* operator matrix */
 34:   EPS            eps;             /* eigenproblem solver context */
 35:   EPSType        type;
 36:   PetscReal      tol;
 37:   PetscInt       nev,maxit,its;
 38:   char           filename[PETSC_MAX_PATH_LEN];
 39:   PetscViewer    viewer;
 40:   PetscBool      flg,terse;

 43:   SlepcInitialize(&argc,&argv,(char*)0,help);

 45:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 46:         Load the operator matrix that defines the eigensystem, Ax=kx
 47:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 49:   PetscPrintf(PETSC_COMM_WORLD,"\nEigenproblem stored in file.\n\n");
 50:   PetscOptionsGetString(NULL,NULL,"-file",filename,PETSC_MAX_PATH_LEN,&flg);
 51:   if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name with the -file option");

 53: #if defined(PETSC_USE_COMPLEX)
 54:   PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrix from a binary file...\n");
 55: #else
 56:   PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrix from a binary file...\n");
 57: #endif
 58:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 59:   MatCreate(PETSC_COMM_WORLD,&A);
 60:   MatSetFromOptions(A);
 61:   MatLoad(A,viewer);
 62:   PetscViewerDestroy(&viewer);

 64:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 65:                 Create the eigensolver and set various options
 66:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 68:   /*
 69:      Create eigensolver context
 70:   */
 71:   EPSCreate(PETSC_COMM_WORLD,&eps);

 73:   /*
 74:      Set operators. In this case, it is a standard eigenvalue problem
 75:   */
 76:   EPSSetOperators(eps,A,NULL);

 78:   /*
 79:      Set solver parameters at runtime
 80:   */
 81:   EPSSetFromOptions(eps);

 83:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 84:                       Solve the eigensystem
 85:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 87:   EPSSolve(eps);
 88:   EPSGetIterationNumber(eps,&its);
 89:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);

 91:   /*
 92:      Optional: Get some information from the solver and display it
 93:   */
 94:   EPSGetType(eps,&type);
 95:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
 96:   EPSGetDimensions(eps,&nev,NULL,NULL);
 97:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
 98:   EPSGetTolerances(eps,&tol,&maxit);
 99:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

101:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102:                     Display solution and clean up
103:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

105:   /* show detailed info unless -terse option is given by user */
106:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
107:   if (terse) {
108:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
109:   } else {
110:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
111:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
112:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
113:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
114:   }
115:   EPSDestroy(&eps);
116:   MatDestroy(&A);
117:   SlepcFinalize();
118:   return ierr;
119: }

slepc-3.7.4/src/eps/examples/tutorials/ex29.c0000644000175000017500000002032713107004621020344 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves the same problem as in ex5, with a user-defined stopping test." "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n" "This example illustrates how the user can set a custom stopping test function.\n\n" "The command line options are:\n" " -m , where = number of grid subdivisions in each dimension.\n" " -seconds , where = maximum time in seconds allowed for computation.\n\n"; #include #include /* User-defined routines */ PetscErrorCode MyStoppingTest(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*); PetscErrorCode MatMarkovModel(PetscInt,Mat); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ PetscReal seconds=2.5; /* maximum time allowed for computation */ PetscLogDouble deadline; /* time to abort computation */ PetscInt N,m=15,nconv; PetscBool terse; PetscViewer viewer; EPSConvergedReason reason; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); N = m*(m+1)/2; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n",N,m);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-seconds",&seconds,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Maximum time for computation is set to %g seconds.\n\n",(double)seconds);CHKERRQ(ierr); deadline = seconds; ierr = PetscTimeAdd(&deadline);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatMarkovModel(m,A);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); ierr = EPSSetStoppingTestFunction(eps,MyStoppingTest,&deadline,NULL);CHKERRQ(ierr); ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSGetConvergedReason(eps,&reason);CHKERRQ(ierr); if (reason!=EPS_CONVERGED_USER) { ierr = EPSReasonView(eps,viewer);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);CHKERRQ(ierr); } else { ierr = EPSGetConverged(eps,&nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"Eigensolve finished with %D converged eigenpairs; reason=%s\n",nconv,EPSConvergedReasons[reason]);CHKERRQ(ierr); } ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMarkovModel" /* Matrix generator for a Markov model of a random walk on a triangular grid. This subroutine generates a test matrix that models a random walk on a triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a FORTRAN subroutine to calculate the dominant invariant subspaces of a real matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295 (1980) ]. These matrices provide reasonably easy test problems for eigenvalue algorithms. The transpose of the matrix is stochastic and so it is known that one is an exact eigenvalue. One seeks the eigenvector of the transpose associated with the eigenvalue unity. The problem is to calculate the steady state probability distribution of the system, which is the eigevector associated with the eigenvalue one and scaled in such a way that the sum all the components is equal to one. Note: the code will actually compute the transpose of the stochastic matrix that contains the transition probabilities. */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A) { const PetscReal cst = 0.5/(PetscReal)(m-1); PetscReal pd,pu; PetscInt Istart,Iend,i,j,jmax,ix=0; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=1;i<=m;i++) { jmax = m-i+1; for (j=1;j<=jmax;j++) { ix = ix + 1; if (ix-1Iend) continue; /* compute only owned rows */ if (j!=jmax) { pd = cst*(PetscReal)(i+j-1); /* north */ if (i==1) { ierr = MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);CHKERRQ(ierr); } /* east */ if (j==1) { ierr = MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);CHKERRQ(ierr); } } /* south */ pu = 0.5 - cst*(PetscReal)(i+j-3); if (j>1) { ierr = MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);CHKERRQ(ierr); } /* west */ if (i>1) { ierr = MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);CHKERRQ(ierr); } } } ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MyStoppingTest" /* Function for user-defined stopping test. Checks that the computing time has not exceeded the deadline. */ PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx) { PetscErrorCode ierr; PetscLogDouble now,deadline = *(PetscLogDouble*)ctx; PetscFunctionBeginUser; /* check if usual termination conditions are met */ ierr = EPSStoppingBasic(eps,its,max_it,nconv,nev,reason,NULL);CHKERRQ(ierr); if (*reason==EPS_CONVERGED_ITERATING) { /* check if deadline has expired */ ierr = PetscTime(&now);CHKERRQ(ierr); if (now>deadline) *reason = EPS_CONVERGED_USER; } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tutorials/ex1f90.F90.html0000644000175000017500000003201313107004621021643 0ustar jromanjroman
Actual source code: ex1f90.F90

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./ex1f90 [-help] [-n <n>] [all SLEPc options] 
 21: !
 22: !  Description: Simple example that solves an eigensystem with the EPS object.
 23: !  The standard symmetric eigenvalue problem to be solved corresponds to the 
 24: !  Laplacian operator in 1 dimension. 
 25: !
 26: !  The command line options are:
 27: !    -n <n>, where <n> = number of grid points = matrix size
 28: !
 29: ! ---------------------------------------------------------------------- 
 30: !
 31:       program main

 33: #include <slepc/finclude/slepcepsdef.h>
 34:       use slepceps

 36:       implicit none

 38: ! For usage without modules, uncomment the following lines and remove 
 39: ! the previous lines between 'program main' and 'implicit none'
 40: !
 41: !#include <petsc/finclude/petsc.h>
 42: !#include <slepc/finclude/slepc.h>

 44: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 45: !     Declarations
 46: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 47: !
 48: !  Variables:
 49: !     A      operator matrix
 50: !     eps    eigenproblem solver context

 52: #if defined(PETSC_USE_FORTRAN_DATATYPES)
 53:       type(Mat)      A
 54:       type(EPS)      eps
 55: #else
 56:       Mat            A
 57:       EPS            eps
 58: #endif
 59:       EPSType        tname
 60:       PetscInt       n, i, Istart, Iend, one, two, three
 61:       PetscInt       nev
 62:       PetscInt       row(1), col(3)
 63:       PetscMPIInt    rank
 64:       PetscErrorCode ierr
 65:       PetscBool      flg, terse
 66:       PetscScalar    value(3)

 68: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 69: !     Beginning of program
 70: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 72:       one = 1
 73:       two = 2
 74:       three = 3
 75:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 76:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 77:       n = 30
 78:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 79:      &                        '-n',n,flg,ierr)

 81:       if (rank .eq. 0) then
 82:         write(*,100) n
 83:       endif
 84:  100  format (/'1-D Laplacian Eigenproblem, n =',I4,' (Fortran)')

 86: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 87: !     Compute the operator matrix that defines the eigensystem, Ax=kx
 88: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 90:       call MatCreate(PETSC_COMM_WORLD,A,ierr)
 91:       call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
 92:       call MatSetFromOptions(A,ierr)
 93:       call MatSetUp(A,ierr)

 95:       call MatGetOwnershipRange(A,Istart,Iend,ierr)
 96:       if (Istart .eq. 0) then 
 97:         row(1) = 0
 98:         col(1) = 0
 99:         col(2) = 1
100:         value(1) =  2.0
101:         value(2) = -1.0
102:         call MatSetValues(A,one,row,two,col,value,INSERT_VALUES,ierr)
103:         Istart = Istart+1
104:       endif
105:       if (Iend .eq. n) then 
106:         row(1) = n-1
107:         col(1) = n-2
108:         col(2) = n-1
109:         value(1) = -1.0
110:         value(2) =  2.0
111:         call MatSetValues(A,one,row,two,col,value,INSERT_VALUES,ierr)
112:         Iend = Iend-1
113:       endif
114:       value(1) = -1.0
115:       value(2) =  2.0
116:       value(3) = -1.0
117:       do i=Istart,Iend-1
118:         row(1) = i
119:         col(1) = i-1
120:         col(2) = i
121:         col(3) = i+1
122:         call MatSetValues(A,one,row,three,col,value,INSERT_VALUES,ierr)
123:       enddo

125:       call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
126:       call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)

128: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
129: !     Create the eigensolver and display info
130: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

132: !     ** Create eigensolver context
133:       call EPSCreate(PETSC_COMM_WORLD,eps,ierr)

135: !     ** Set operators. In this case, it is a standard eigenvalue problem
136:       call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr)
137:       call EPSSetProblemType(eps,EPS_HEP,ierr)

139: !     ** Set solver parameters at runtime
140:       call EPSSetFromOptions(eps,ierr)

142: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
143: !     Solve the eigensystem
144: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

146:       call EPSSolve(eps,ierr) 

148: !     ** Optional: Get some information from the solver and display it
149:       call EPSGetType(eps,tname,ierr)
150:       if (rank .eq. 0) then
151:         write(*,120) tname
152:       endif
153:  120  format (' Solution method: ',A)
154:       call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER,                 &
155:      &                      PETSC_NULL_INTEGER,ierr)
156:       if (rank .eq. 0) then
157:         write(*,130) nev
158:       endif
159:  130  format (' Number of requested eigenvalues:',I4)

161: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
162: !     Display solution and clean up
163: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

165: !     ** show detailed info unless -terse option is given by user
166:       call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,  &
167:      &                        '-terse',terse,ierr)
168:       if (terse) then
169:         call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr)
170:       else
171:         call PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,           &
172:      &                   PETSC_VIEWER_ASCII_INFO_DETAIL,ierr)
173:         call EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD,ierr)
174:         call EPSErrorView(eps,EPS_ERROR_RELATIVE,                       &
175:      &                   PETSC_VIEWER_STDOUT_WORLD,ierr)
176:         call PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD,ierr)
177:       endif
178:       call EPSDestroy(eps,ierr)
179:       call MatDestroy(A,ierr)

181:       call SlepcFinalize(ierr)
182:       end

slepc-3.7.4/src/eps/examples/tutorials/ex31.c0000644000175000017500000007053413107004621020342 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Power grid small signal stability analysis of WECC 9 bus system.\n\ This example is based on the 9-bus (node) example given in the book Power\n\ Systems Dynamics and Stability (Chapter 8) by P. Sauer and M. A. Pai.\n\ The power grid in this example consists of 9 buses (nodes), 3 generators,\n\ 3 loads, and 9 transmission lines. The network equations are written\n\ in current balance form using rectangular coordinates. It uses the SLEPc\n\ package to calculate the eigenvalues for small signal stability analysis\n\n"; /* This example is based on PETSc's ex9bus example (under TS). The equations for the stability analysis are described by the DAE \dot{x} = f(x,y,t) 0 = g(x,y,t) where the generators are described by differential equations, while the algebraic constraints define the network equations. The generators are modeled with a 4th order differential equation describing the electrical and mechanical dynamics. Each generator also has an exciter system modeled by 3rd order diff. eqns. describing the exciter, voltage regulator, and the feedback stabilizer mechanism. The network equations are described by nodal current balance equations. I(x,y) - Y*V = 0 where: I(x,y) is the current injected from generators and loads. Y is the admittance matrix, and V is the voltage vector - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The linearized equations for the eigenvalue analysis are \dot{\delta{x}} = f_x*\delta{x} + f_y*\delta{y} 0 = g_x*\delta{x} + g_y*\delta{y} This gives the linearized sensitivity matrix A = | f_x f_y | | g_x g_y | We are interested in the eigenvalues of the Schur complement of A \hat{A} = f_x - g_x*inv(g_y)*f_y Example contributed by: Shrirang Abhyankar */ #include #include #include #include #define freq 60 #define w_s (2*PETSC_PI*freq) /* Sizes and indices */ const PetscInt nbus = 9; /* Number of network buses */ const PetscInt ngen = 3; /* Number of generators */ const PetscInt nload = 3; /* Number of loads */ const PetscInt gbus[3] = {0,1,2}; /* Buses at which generators are incident */ const PetscInt lbus[3] = {4,5,7}; /* Buses at which loads are incident */ /* Generator real and reactive powers (found via loadflow) */ const PetscScalar PG[3] = {0.716786142395021,1.630000000000000,0.850000000000000}; const PetscScalar QG[3] = {0.270702180178785,0.066120127797275,-0.108402221791588}; /* Generator constants */ const PetscScalar H[3] = {23.64,6.4,3.01}; /* Inertia constant */ const PetscScalar Rs[3] = {0.0,0.0,0.0}; /* Stator Resistance */ const PetscScalar Xd[3] = {0.146,0.8958,1.3125}; /* d-axis reactance */ const PetscScalar Xdp[3] = {0.0608,0.1198,0.1813}; /* d-axis transient reactance */ const PetscScalar Xq[3] = {0.0969,0.8645,1.2578}; /* q-axis reactance Xq(1) set to 0.4360, value given in text 0.0969 */ const PetscScalar Xqp[3] = {0.0969,0.1969,0.25}; /* q-axis transient reactance */ const PetscScalar Td0p[3] = {8.96,6.0,5.89}; /* d-axis open circuit time constant */ const PetscScalar Tq0p[3] = {0.31,0.535,0.6}; /* q-axis open circuit time constant */ PetscScalar M[3]; /* M = 2*H/w_s */ PetscScalar D[3]; /* D = 0.1*M */ PetscScalar TM[3]; /* Mechanical Torque */ /* Exciter system constants */ const PetscScalar KA[3] = {20.0,20.0,20.0}; /* Voltage regulartor gain constant */ const PetscScalar TA[3] = {0.2,0.2,0.2}; /* Voltage regulator time constant */ const PetscScalar KE[3] = {1.0,1.0,1.0}; /* Exciter gain constant */ const PetscScalar TE[3] = {0.314,0.314,0.314}; /* Exciter time constant */ const PetscScalar KF[3] = {0.063,0.063,0.063}; /* Feedback stabilizer gain constant */ const PetscScalar TF[3] = {0.35,0.35,0.35}; /* Feedback stabilizer time constant */ const PetscScalar k1[3] = {0.0039,0.0039,0.0039}; const PetscScalar k2[3] = {1.555,1.555,1.555}; /* k1 and k2 for calculating the saturation function SE = k1*exp(k2*Efd) */ PetscScalar Vref[3]; /* Load constants We use a composite load model that describes the load and reactive powers at each time instant as follows P(t) = \sum\limits_{i=0}^ld_nsegsp \ld_alphap_i*P_D0(\frac{V_m(t)}{V_m0})^\ld_betap_i Q(t) = \sum\limits_{i=0}^ld_nsegsq \ld_alphaq_i*Q_D0(\frac{V_m(t)}{V_m0})^\ld_betaq_i where ld_nsegsp,ld_nsegsq - Number of individual load models for real and reactive power loads ld_alphap,ld_alphap - Percentage contribution (weights) or loads P_D0 - Real power load Q_D0 - Reactive power load V_m(t) - Voltage magnitude at time t V_m0 - Voltage magnitude at t = 0 ld_betap, ld_betaq - exponents describing the load model for real and reactive part Note: All loads have the same characteristic currently. */ const PetscScalar PD0[3] = {1.25,0.9,1.0}; const PetscScalar QD0[3] = {0.5,0.3,0.35}; const PetscInt ld_nsegsp[3] = {3,3,3}; const PetscScalar ld_alphap[3] = {0.0,0.0,1.0}; const PetscScalar ld_betap[3] = {2.0,1.0,0.0}; const PetscInt ld_nsegsq[3] = {3,3,3}; const PetscScalar ld_alphaq[3] = {0.0,0.0,1.0}; const PetscScalar ld_betaq[3] = {2.0,1.0,0.0}; typedef struct { DM dmgen, dmnet; /* DMs to manage generator and network subsystem */ DM dmpgrid; /* Composite DM to manage the entire power grid */ Mat Ybus; /* Network admittance matrix */ Vec V0; /* Initial voltage vector (Power flow solution) */ PetscInt neqs_gen,neqs_net,neqs_pgrid; IS is_diff; /* indices for differential equations */ IS is_alg; /* indices for algebraic equations */ } Userctx; /* Converts from machine frame (dq) to network (phase a real,imag) reference frame */ #undef __FUNCT__ #define __FUNCT__ "dq2ri" PetscErrorCode dq2ri(PetscScalar Fd,PetscScalar Fq,PetscScalar delta,PetscScalar *Fr,PetscScalar *Fi) { PetscFunctionBegin; *Fr = Fd*PetscSinScalar(delta) + Fq*PetscCosScalar(delta); *Fi = -Fd*PetscCosScalar(delta) + Fq*PetscSinScalar(delta); PetscFunctionReturn(0); } /* Converts from network frame ([phase a real,imag) to machine (dq) reference frame */ #undef __FUNCT__ #define __FUNCT__ "ri2dq" PetscErrorCode ri2dq(PetscScalar Fr,PetscScalar Fi,PetscScalar delta,PetscScalar *Fd,PetscScalar *Fq) { PetscFunctionBegin; *Fd = Fr*PetscSinScalar(delta) - Fi*PetscCosScalar(delta); *Fq = Fr*PetscCosScalar(delta) + Fi*PetscSinScalar(delta); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SetInitialGuess" PetscErrorCode SetInitialGuess(Vec X,Userctx *user) { PetscErrorCode ierr; Vec Xgen,Xnet; PetscScalar *xgen,*xnet; PetscInt i,idx=0; PetscScalar Vr,Vi,IGr,IGi,Vm,Vm2; PetscScalar Eqp,Edp,delta; PetscScalar Efd,RF,VR; /* Exciter variables */ PetscScalar Id,Iq; /* Generator dq axis currents */ PetscScalar theta,Vd,Vq,SE; PetscFunctionBegin; M[0] = 2*H[0]/w_s; M[1] = 2*H[1]/w_s; M[2] = 2*H[2]/w_s; /* D[0] = 0.1*M[0]; D[1] = 0.1*M[1]; D[2] = 0.1*M[2]; */ D[0] = D[1] = D[2] = 0.0; ierr = DMCompositeGetLocalVectors(user->dmpgrid,&Xgen,&Xnet);CHKERRQ(ierr); /* Network subsystem initialization */ ierr = VecCopy(user->V0,Xnet);CHKERRQ(ierr); /* Generator subsystem initialization */ ierr = VecGetArray(Xgen,&xgen);CHKERRQ(ierr); ierr = VecGetArray(Xnet,&xnet);CHKERRQ(ierr); for (i=0; i < ngen; i++) { Vr = xnet[2*gbus[i]]; /* Real part of generator terminal voltage */ Vi = xnet[2*gbus[i]+1]; /* Imaginary part of the generator terminal voltage */ Vm = PetscSqrtScalar(Vr*Vr + Vi*Vi); Vm2 = Vm*Vm; IGr = (Vr*PG[i] + Vi*QG[i])/Vm2; IGi = (Vi*PG[i] - Vr*QG[i])/Vm2; delta = atan2(Vi+Xq[i]*IGr,Vr-Xq[i]*IGi); /* Machine angle */ theta = PETSC_PI/2.0 - delta; Id = IGr*PetscCosScalar(theta) - IGi*PetscSinScalar(theta); /* d-axis stator current */ Iq = IGr*PetscSinScalar(theta) + IGi*PetscCosScalar(theta); /* q-axis stator current */ Vd = Vr*PetscCosScalar(theta) - Vi*PetscSinScalar(theta); Vq = Vr*PetscSinScalar(theta) + Vi*PetscCosScalar(theta); Edp = Vd + Rs[i]*Id - Xqp[i]*Iq; /* d-axis transient EMF */ Eqp = Vq + Rs[i]*Iq + Xdp[i]*Id; /* q-axis transient EMF */ TM[i] = PG[i]; /* The generator variables are ordered as [Eqp,Edp,delta,w,Id,Iq] */ xgen[idx] = Eqp; xgen[idx+1] = Edp; xgen[idx+2] = delta; xgen[idx+3] = w_s; idx = idx + 4; xgen[idx] = Id; xgen[idx+1] = Iq; idx = idx + 2; /* Exciter */ Efd = Eqp + (Xd[i] - Xdp[i])*Id; SE = k1[i]*PetscExpScalar(k2[i]*Efd); VR = KE[i]*Efd + SE; RF = KF[i]*Efd/TF[i]; xgen[idx] = Efd; xgen[idx+1] = RF; xgen[idx+2] = VR; Vref[i] = Vm + (VR/KA[i]); idx = idx + 3; } ierr = VecRestoreArray(Xgen,&xgen);CHKERRQ(ierr); ierr = VecRestoreArray(Xnet,&xnet);CHKERRQ(ierr); /* ierr = VecView(Xgen,0);CHKERRQ(ierr); */ ierr = DMCompositeGather(user->dmpgrid,X,INSERT_VALUES,Xgen,Xnet);CHKERRQ(ierr); ierr = DMCompositeRestoreLocalVectors(user->dmpgrid,&Xgen,&Xnet);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PreallocateJacobian" PetscErrorCode PreallocateJacobian(Mat J,Userctx *user) { PetscErrorCode ierr; PetscInt *d_nnz; PetscInt i,idx=0,start=0; PetscInt ncols; PetscFunctionBegin; ierr = PetscMalloc1(user->neqs_pgrid,&d_nnz);CHKERRQ(ierr); for (i=0; ineqs_pgrid; i++) d_nnz[i] = 0; /* Generator subsystem */ for (i=0; i < ngen; i++) { d_nnz[idx] += 3; d_nnz[idx+1] += 2; d_nnz[idx+2] += 2; d_nnz[idx+3] += 5; d_nnz[idx+4] += 6; d_nnz[idx+5] += 6; d_nnz[user->neqs_gen+2*gbus[i]] += 3; d_nnz[user->neqs_gen+2*gbus[i]+1] += 3; d_nnz[idx+6] += 2; d_nnz[idx+7] += 2; d_nnz[idx+8] += 5; idx = idx + 9; } start = user->neqs_gen; for (i=0; i < nbus; i++) { ierr = MatGetRow(user->Ybus,2*i,&ncols,NULL,NULL);CHKERRQ(ierr); d_nnz[start+2*i] += ncols; d_nnz[start+2*i+1] += ncols; ierr = MatRestoreRow(user->Ybus,2*i,&ncols,NULL,NULL);CHKERRQ(ierr); } ierr = MatSeqAIJSetPreallocation(J,0,d_nnz);CHKERRQ(ierr); ierr = PetscFree(d_nnz);CHKERRQ(ierr); PetscFunctionReturn(0); } /* J = [-df_dx, -df_dy dg_dx, dg_dy] */ #undef __FUNCT__ #define __FUNCT__ "ResidualJacobian" PetscErrorCode ResidualJacobian(Vec X,Mat J,void *ctx) { PetscErrorCode ierr; Userctx *user=(Userctx*)ctx; Vec Xgen,Xnet; PetscScalar *xgen,*xnet; PetscInt i,idx=0; PetscScalar Vr,Vi,Vm,Vm2; PetscScalar Eqp,Edp,delta; /* Generator variables */ PetscScalar Efd; PetscScalar Id,Iq; /* Generator dq axis currents */ PetscScalar Vd,Vq; PetscScalar val[10]; PetscInt row[2],col[10]; PetscInt net_start=user->neqs_gen; PetscScalar Zdq_inv[4],det; PetscScalar dVd_dVr,dVd_dVi,dVq_dVr,dVq_dVi,dVd_ddelta,dVq_ddelta; PetscScalar dIGr_ddelta,dIGi_ddelta,dIGr_dId,dIGr_dIq,dIGi_dId,dIGi_dIq; PetscScalar dSE_dEfd; PetscScalar dVm_dVd,dVm_dVq,dVm_dVr,dVm_dVi; PetscInt ncols; const PetscInt *cols; const PetscScalar *yvals; PetscInt k; PetscScalar PD,QD,Vm0,*v0,Vm4; PetscScalar dPD_dVr,dPD_dVi,dQD_dVr,dQD_dVi; PetscScalar dIDr_dVr,dIDr_dVi,dIDi_dVr,dIDi_dVi; PetscFunctionBegin; ierr = MatZeroEntries(J);CHKERRQ(ierr); ierr = DMCompositeGetLocalVectors(user->dmpgrid,&Xgen,&Xnet);CHKERRQ(ierr); ierr = DMCompositeScatter(user->dmpgrid,X,Xgen,Xnet);CHKERRQ(ierr); ierr = VecGetArray(Xgen,&xgen);CHKERRQ(ierr); ierr = VecGetArray(Xnet,&xnet);CHKERRQ(ierr); /* Generator subsystem */ for (i=0; i < ngen; i++) { Eqp = xgen[idx]; Edp = xgen[idx+1]; delta = xgen[idx+2]; Id = xgen[idx+4]; Iq = xgen[idx+5]; Efd = xgen[idx+6]; /* fgen[idx] = (Eqp + (Xd[i] - Xdp[i])*Id - Efd)/Td0p[i]; */ row[0] = idx; col[0] = idx; col[1] = idx+4; col[2] = idx+6; val[0] = 1/ Td0p[i]; val[1] = (Xd[i] - Xdp[i])/ Td0p[i]; val[2] = -1/Td0p[i]; ierr = MatSetValues(J,1,row,3,col,val,INSERT_VALUES);CHKERRQ(ierr); /* fgen[idx+1] = (Edp - (Xq[i] - Xqp[i])*Iq)/Tq0p[i]; */ row[0] = idx + 1; col[0] = idx + 1; col[1] = idx+5; val[0] = 1/Tq0p[i]; val[1] = -(Xq[i] - Xqp[i])/Tq0p[i]; ierr = MatSetValues(J,1,row,2,col,val,INSERT_VALUES);CHKERRQ(ierr); /* fgen[idx+2] = - w + w_s; */ row[0] = idx + 2; col[0] = idx + 2; col[1] = idx + 3; val[0] = 0; val[1] = -1; ierr = MatSetValues(J,1,row,2,col,val,INSERT_VALUES);CHKERRQ(ierr); /* fgen[idx+3] = (-TM[i] + Edp*Id + Eqp*Iq + (Xqp[i] - Xdp[i])*Id*Iq + D[i]*(w - w_s))/M[i]; */ row[0] = idx + 3; col[0] = idx; col[1] = idx + 1; col[2] = idx + 3; col[3] = idx + 4; col[4] = idx + 5; val[0] = Iq/M[i]; val[1] = Id/M[i]; val[2] = D[i]/M[i]; val[3] = (Edp + (Xqp[i]-Xdp[i])*Iq)/M[i]; val[4] = (Eqp + (Xqp[i] - Xdp[i])*Id)/M[i]; ierr = MatSetValues(J,1,row,5,col,val,INSERT_VALUES);CHKERRQ(ierr); Vr = xnet[2*gbus[i]]; /* Real part of generator terminal voltage */ Vi = xnet[2*gbus[i]+1]; /* Imaginary part of the generator terminal voltage */ ierr = ri2dq(Vr,Vi,delta,&Vd,&Vq);CHKERRQ(ierr); det = Rs[i]*Rs[i] + Xdp[i]*Xqp[i]; Zdq_inv[0] = Rs[i]/det; Zdq_inv[1] = Xqp[i]/det; Zdq_inv[2] = -Xdp[i]/det; Zdq_inv[3] = Rs[i]/det; dVd_dVr = PetscSinScalar(delta); dVd_dVi = -PetscCosScalar(delta); dVq_dVr = PetscCosScalar(delta); dVq_dVi = PetscSinScalar(delta); dVd_ddelta = Vr*PetscCosScalar(delta) + Vi*PetscSinScalar(delta); dVq_ddelta = -Vr*PetscSinScalar(delta) + Vi*PetscCosScalar(delta); /* fgen[idx+4] = Zdq_inv[0]*(-Edp + Vd) + Zdq_inv[1]*(-Eqp + Vq) + Id; */ row[0] = idx+4; col[0] = idx; col[1] = idx+1; col[2] = idx + 2; val[0] = -Zdq_inv[1]; val[1] = -Zdq_inv[0]; val[2] = Zdq_inv[0]*dVd_ddelta + Zdq_inv[1]*dVq_ddelta; col[3] = idx + 4; col[4] = net_start+2*gbus[i]; col[5] = net_start + 2*gbus[i]+1; val[3] = 1; val[4] = Zdq_inv[0]*dVd_dVr + Zdq_inv[1]*dVq_dVr; val[5] = Zdq_inv[0]*dVd_dVi + Zdq_inv[1]*dVq_dVi; ierr = MatSetValues(J,1,row,6,col,val,INSERT_VALUES);CHKERRQ(ierr); /* fgen[idx+5] = Zdq_inv[2]*(-Edp + Vd) + Zdq_inv[3]*(-Eqp + Vq) + Iq; */ row[0] = idx+5; col[0] = idx; col[1] = idx+1; col[2] = idx + 2; val[0] = -Zdq_inv[3]; val[1] = -Zdq_inv[2]; val[2] = Zdq_inv[2]*dVd_ddelta + Zdq_inv[3]*dVq_ddelta; col[3] = idx + 5; col[4] = net_start+2*gbus[i]; col[5] = net_start + 2*gbus[i]+1; val[3] = 1; val[4] = Zdq_inv[2]*dVd_dVr + Zdq_inv[3]*dVq_dVr; val[5] = Zdq_inv[2]*dVd_dVi + Zdq_inv[3]*dVq_dVi; ierr = MatSetValues(J,1,row,6,col,val,INSERT_VALUES);CHKERRQ(ierr); dIGr_ddelta = Id*PetscCosScalar(delta) - Iq*PetscSinScalar(delta); dIGi_ddelta = Id*PetscSinScalar(delta) + Iq*PetscCosScalar(delta); dIGr_dId = PetscSinScalar(delta); dIGr_dIq = PetscCosScalar(delta); dIGi_dId = -PetscCosScalar(delta); dIGi_dIq = PetscSinScalar(delta); /* fnet[2*gbus[i]] -= IGi; */ row[0] = net_start + 2*gbus[i]; col[0] = idx+2; col[1] = idx + 4; col[2] = idx + 5; val[0] = -dIGi_ddelta; val[1] = -dIGi_dId; val[2] = -dIGi_dIq; ierr = MatSetValues(J,1,row,3,col,val,INSERT_VALUES);CHKERRQ(ierr); /* fnet[2*gbus[i]+1] -= IGr; */ row[0] = net_start + 2*gbus[i]+1; col[0] = idx+2; col[1] = idx + 4; col[2] = idx + 5; val[0] = -dIGr_ddelta; val[1] = -dIGr_dId; val[2] = -dIGr_dIq; ierr = MatSetValues(J,1,row,3,col,val,INSERT_VALUES);CHKERRQ(ierr); Vm = PetscSqrtScalar(Vd*Vd + Vq*Vq); Vm2 = Vm*Vm; /* fgen[idx+6] = (KE[i]*Efd + SE - VR)/TE[i]; */ /* SE = k1[i]*PetscExpScalar(k2[i]*Efd); */ dSE_dEfd = k1[i]*k2[i]*PetscExpScalar(k2[i]*Efd); row[0] = idx + 6; col[0] = idx + 6; col[1] = idx + 8; val[0] = (KE[i] + dSE_dEfd)/TE[i]; val[1] = -1/TE[i]; ierr = MatSetValues(J,1,row,2,col,val,INSERT_VALUES);CHKERRQ(ierr); /* Exciter differential equations */ /* fgen[idx+7] = (RF - KF[i]*Efd/TF[i])/TF[i]; */ row[0] = idx + 7; col[0] = idx + 6; col[1] = idx + 7; val[0] = (-KF[i]/TF[i])/TF[i]; val[1] = 1/TF[i]; ierr = MatSetValues(J,1,row,2,col,val,INSERT_VALUES);CHKERRQ(ierr); /* fgen[idx+8] = (VR - KA[i]*RF + KA[i]*KF[i]*Efd/TF[i] - KA[i]*(Vref[i] - Vm))/TA[i]; */ /* Vm = (Vd^2 + Vq^2)^0.5; */ dVm_dVd = Vd/Vm; dVm_dVq = Vq/Vm; dVm_dVr = dVm_dVd*dVd_dVr + dVm_dVq*dVq_dVr; dVm_dVi = dVm_dVd*dVd_dVi + dVm_dVq*dVq_dVi; row[0] = idx + 8; col[0] = idx + 6; col[1] = idx + 7; col[2] = idx + 8; val[0] = (KA[i]*KF[i]/TF[i])/TA[i]; val[1] = -KA[i]/TA[i]; val[2] = 1/TA[i]; col[3] = net_start + 2*gbus[i]; col[4] = net_start + 2*gbus[i]+1; val[3] = KA[i]*dVm_dVr/TA[i]; val[4] = KA[i]*dVm_dVi/TA[i]; ierr = MatSetValues(J,1,row,5,col,val,INSERT_VALUES);CHKERRQ(ierr); idx = idx + 9; } for (i=0; iYbus,2*i,&ncols,&cols,&yvals);CHKERRQ(ierr); row[0] = net_start + 2*i; for (k=0; kYbus,2*i,&ncols,&cols,&yvals);CHKERRQ(ierr); ierr = MatGetRow(user->Ybus,2*i+1,&ncols,&cols,&yvals);CHKERRQ(ierr); row[0] = net_start + 2*i+1; for (k=0; kYbus,2*i+1,&ncols,&cols,&yvals);CHKERRQ(ierr); } ierr = MatAssemblyBegin(J,MAT_FLUSH_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(J,MAT_FLUSH_ASSEMBLY);CHKERRQ(ierr); ierr = VecGetArray(user->V0,&v0);CHKERRQ(ierr); for (i=0; i < nload; i++) { Vr = xnet[2*lbus[i]]; /* Real part of load bus voltage */ Vi = xnet[2*lbus[i]+1]; /* Imaginary part of the load bus voltage */ Vm = PetscSqrtScalar(Vr*Vr + Vi*Vi); Vm2 = Vm*Vm; Vm4 = Vm2*Vm2; Vm0 = PetscSqrtScalar(v0[2*lbus[i]]*v0[2*lbus[i]] + v0[2*lbus[i]+1]*v0[2*lbus[i]+1]); PD = QD = 0.0; dPD_dVr = dPD_dVi = dQD_dVr = dQD_dVi = 0.0; for (k=0; k < ld_nsegsp[i]; k++) { PD += ld_alphap[k]*PD0[i]*PetscPowScalar((Vm/Vm0),ld_betap[k]); dPD_dVr += ld_alphap[k]*ld_betap[k]*PD0[i]*PetscPowScalar((1/Vm0),ld_betap[k])*Vr*PetscPowScalar(Vm,(ld_betap[k]-2)); dPD_dVi += ld_alphap[k]*ld_betap[k]*PD0[i]*PetscPowScalar((1/Vm0),ld_betap[k])*Vi*PetscPowScalar(Vm,(ld_betap[k]-2)); } for (k=0; k < ld_nsegsq[i]; k++) { QD += ld_alphaq[k]*QD0[i]*PetscPowScalar((Vm/Vm0),ld_betaq[k]); dQD_dVr += ld_alphaq[k]*ld_betaq[k]*QD0[i]*PetscPowScalar((1/Vm0),ld_betaq[k])*Vr*PetscPowScalar(Vm,(ld_betaq[k]-2)); dQD_dVi += ld_alphaq[k]*ld_betaq[k]*QD0[i]*PetscPowScalar((1/Vm0),ld_betaq[k])*Vi*PetscPowScalar(Vm,(ld_betaq[k]-2)); } /* IDr = (PD*Vr + QD*Vi)/Vm2; */ /* IDi = (-QD*Vr + PD*Vi)/Vm2; */ dIDr_dVr = (dPD_dVr*Vr + dQD_dVr*Vi + PD)/Vm2 - ((PD*Vr + QD*Vi)*2*Vr)/Vm4; dIDr_dVi = (dPD_dVi*Vr + dQD_dVi*Vi + QD)/Vm2 - ((PD*Vr + QD*Vi)*2*Vi)/Vm4; dIDi_dVr = (-dQD_dVr*Vr + dPD_dVr*Vi - QD)/Vm2 - ((-QD*Vr + PD*Vi)*2*Vr)/Vm4; dIDi_dVi = (-dQD_dVi*Vr + dPD_dVi*Vi + PD)/Vm2 - ((-QD*Vr + PD*Vi)*2*Vi)/Vm4; /* fnet[2*lbus[i]] += IDi; */ row[0] = net_start + 2*lbus[i]; col[0] = net_start + 2*lbus[i]; col[1] = net_start + 2*lbus[i]+1; val[0] = dIDi_dVr; val[1] = dIDi_dVi; ierr = MatSetValues(J,1,row,2,col,val,ADD_VALUES);CHKERRQ(ierr); /* fnet[2*lbus[i]+1] += IDr; */ row[0] = net_start + 2*lbus[i]+1; col[0] = net_start + 2*lbus[i]; col[1] = net_start + 2*lbus[i]+1; val[0] = dIDr_dVr; val[1] = dIDr_dVi; ierr = MatSetValues(J,1,row,2,col,val,ADD_VALUES);CHKERRQ(ierr); } ierr = VecRestoreArray(user->V0,&v0);CHKERRQ(ierr); ierr = VecRestoreArray(Xgen,&xgen);CHKERRQ(ierr); ierr = VecRestoreArray(Xnet,&xnet);CHKERRQ(ierr); ierr = DMCompositeRestoreLocalVectors(user->dmpgrid,&Xgen,&Xnet);CHKERRQ(ierr); ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { EPS eps; EPSType type; PetscErrorCode ierr; PetscMPIInt size; Userctx user; PetscViewer Xview,Ybusview; Vec X,Xr,Xi; Mat J,Jred=NULL; IS is0,is1; PetscInt i,*idx2,its,nev,nconv; PetscReal error,re,im; PetscScalar kr,ki; PetscBool terse; ierr = SlepcInitialize(&argc,&argv,NULL,help);CHKERRQ(ierr); ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); if (size > 1) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Only for sequential runs"); /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); user.neqs_gen = 9*ngen; /* # eqs. for generator subsystem */ user.neqs_net = 2*nbus; /* # eqs. for network subsystem */ user.neqs_pgrid = user.neqs_gen + user.neqs_net; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nStability analysis in a network with %D buses and %D generators\n\n",nbus,ngen);CHKERRQ(ierr); /* Create indices for differential and algebraic equations */ ierr = PetscMalloc1(7*ngen,&idx2);CHKERRQ(ierr); for (i=0; i0) { /* Display eigenvalues and relative errors */ ierr = PetscPrintf(PETSC_COMM_WORLD, " k ||Ax-kx||/||kx||\n" " ----------------- ------------------\n");CHKERRQ(ierr); for (i=0;iActual source code: ex13.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Generalized Symmetric eigenproblem.\n\n"
 23:   "The problem is Ax = lambda Bx, with:\n"
 24:   "   A = Laplacian operator in 2-D\n"
 25:   "   B = diagonal matrix with all values equal to 4 except nulldim zeros\n\n"
 26:   "The command line options are:\n"
 27:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 28:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n"
 29:   "  -nulldim <k>, where <k> = dimension of the nullspace of B.\n\n";

 31: #include <slepceps.h>

 35: int main(int argc,char **argv)
 36: {
 37:   Mat            A,B;         /* matrices */
 38:   EPS            eps;         /* eigenproblem solver context */
 39:   ST             st;          /* spectral transformation context */
 40:   EPSType        type;
 41:   PetscInt       N,n=10,m,Istart,Iend,II,nev,i,j,nulldim=0;
 42:   PetscBool      flag,terse;

 45:   SlepcInitialize(&argc,&argv,(char*)0,help);

 47:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 48:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 49:   if (!flag) m=n;
 50:   N = n*m;
 51:   PetscOptionsGetInt(NULL,NULL,"-nulldim",&nulldim,NULL);
 52:   PetscPrintf(PETSC_COMM_WORLD,"\nGeneralized Symmetric Eigenproblem, N=%D (%Dx%D grid), null(B)=%D\n\n",N,n,m,nulldim);

 54:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 55:      Compute the matrices that define the eigensystem, Ax=kBx
 56:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 58:   MatCreate(PETSC_COMM_WORLD,&A);
 59:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 60:   MatSetFromOptions(A);
 61:   MatSetUp(A);

 63:   MatCreate(PETSC_COMM_WORLD,&B);
 64:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);
 65:   MatSetFromOptions(B);
 66:   MatSetUp(B);

 68:   MatGetOwnershipRange(A,&Istart,&Iend);
 69:   for (II=Istart;II<Iend;II++) {
 70:     i = II/n; j = II-i*n;
 71:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); }
 72:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); }
 73:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); }
 74:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); }
 75:     MatSetValue(A,II,II,4.0,INSERT_VALUES);
 76:     if (II>=nulldim) { MatSetValue(B,II,II,4.0,INSERT_VALUES); }
 77:   }

 79:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 80:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 81:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 82:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);

 84:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 85:                 Create the eigensolver and set various options
 86:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 88:   /*
 89:      Create eigensolver context
 90:   */
 91:   EPSCreate(PETSC_COMM_WORLD,&eps);

 93:   /*
 94:      Set operators. In this case, it is a generalized eigenvalue problem
 95:   */
 96:   EPSSetOperators(eps,A,B);
 97:   EPSSetProblemType(eps,EPS_GHEP);

 99:   /*
100:      Set solver parameters at runtime
101:   */
102:   EPSSetFromOptions(eps);

104:   PetscObjectTypeCompareAny((PetscObject)eps,&flag,EPSBLOPEX,EPSRQCG,"");
105:   if (flag) {
106:     EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);
107:   } else {
108:     /*
109:        Select portion of spectrum
110:     */
111:     EPSSetTarget(eps,0.0);
112:     EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);
113:     /*
114:        Use shift-and-invert to avoid solving linear systems with a singular B
115:        in case nulldim>0
116:     */
117:     PetscObjectTypeCompareAny((PetscObject)eps,&flag,EPSGD,EPSJD,"");
118:     if (!flag) {
119:       EPSGetST(eps,&st);
120:       STSetType(st,STSINVERT);
121:     }
122:   }

124:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
125:                       Solve the eigensystem
126:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

128:   EPSSolve(eps);

130:   /*
131:      Optional: Get some information from the solver and display it
132:   */
133:   EPSGetType(eps,&type);
134:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
135:   EPSGetDimensions(eps,&nev,NULL,NULL);
136:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

138:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139:                     Display solution and clean up
140:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

142:   /* show detailed info unless -terse option is given by user */
143:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
144:   if (terse) {
145:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
146:   } else {
147:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
148:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
149:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
150:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
151:   }
152:   EPSDestroy(&eps);
153:   MatDestroy(&A);
154:   MatDestroy(&B);
155:   SlepcFinalize();
156:   return ierr;
157: }

slepc-3.7.4/src/eps/examples/tutorials/ex6f.F0000644000175000017500000002450013107004621020365 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./ex6f [-help] [-m ] [all SLEPc options] ! ! Description: This example solves the eigensystem arising in the Ising ! model for ferromagnetic materials. The file mvmisg.f must be linked ! together. Information about the model can be found at the following ! site http://math.nist.gov/MatrixMarket/data/NEP ! ! The command line options are: ! -m , where is the number of 2x2 blocks, i.e. matrix size N=2*m ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! A operator matrix ! eps eigenproblem solver context Mat A EPS eps EPSType tname PetscReal tol PetscInt N, m PetscInt nev, maxit, its PetscMPIInt sz, rank PetscErrorCode ierr PetscBool flg, terse ! This is the routine to use for matrix-free approach ! external MatIsing_Mult ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) #if defined(PETSC_USE_COMPLEX) write(*,*) 'This example requires real numbers.' goto 999 #endif call MPI_Comm_size(PETSC_COMM_WORLD,sz,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) if (sz .ne. 1) then if (rank .eq. 0) then write(*,*) 'This is a uniprocessor example only!' endif SETERRQ(PETSC_COMM_WORLD,1,' ',ierr) endif m = 30 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-m',m,flg,ierr) N = 2*m if (rank .eq. 0) then write(*,*) write(*,'(A,I6,A)') 'Ising Model Eigenproblem, m=',m,', (N=2*m)' write(*,*) endif ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Register the matrix-vector subroutine for the operator that defines ! the eigensystem, Ax=kx ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,PETSC_NULL_OBJECT, & & A,ierr) call MatShellSetOperation(A,MATOP_MULT,MatIsing_Mult,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create the eigensolver and display info ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Create eigensolver context call EPSCreate(PETSC_COMM_WORLD,eps,ierr) ! ** Set operators. In this case, it is a standard eigenvalue problem call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr) call EPSSetProblemType(eps,EPS_NHEP,ierr) ! ** Set solver parameters at runtime call EPSSetFromOptions(eps,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the eigensystem ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSSolve(eps,ierr) call EPSGetIterationNumber(eps,its,ierr) if (rank .eq. 0) then write(*,'(A,I4)') ' Number of iterations of the method: ', its endif ! ** Optional: Get some information from the solver and display it call EPSGetType(eps,tname,ierr) if (rank .eq. 0) then write(*,'(A,A)') ' Solution method: ', tname endif call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER, & & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,'(A,I2)') ' Number of requested eigenvalues:', nev endif call EPSGetTolerances(eps,tol,maxit,ierr) if (rank .eq. 0) then write(*,'(A,1PE10.4,A,I6)') ' Stopping condition: tol=', tol, & & ', maxit=', maxit endif ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** show detailed info unless -terse option is given by user call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-terse',terse,ierr) if (terse) then call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr) else call PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD, & & PETSC_VIEWER_ASCII_INFO_DETAIL,ierr) call EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD,ierr) call EPSErrorView(eps,EPS_ERROR_RELATIVE, & & PETSC_VIEWER_STDOUT_WORLD,ierr) call PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD,ierr) endif call EPSDestroy(eps,ierr) call MatDestroy(A,ierr) #if defined(PETSC_USE_COMPLEX) 999 continue #endif call SlepcFinalize(ierr) end ! ------------------------------------------------------------------- ! ! MatIsing_Mult - user provided matrix-vector multiply ! ! Input Parameters: ! A - matrix ! x - input vector ! ! Output Parameter: ! y - output vector ! subroutine MatIsing_Mult(A,x,y,ierr) implicit none #include #include #include Mat A Vec x,y PetscInt trans,one,N PetscScalar x_array(1),y_array(1) PetscOffset i_x,i_y PetscErrorCode ierr ! The actual routine for the matrix-vector product external mvmisg call MatGetSize(A,N,PETSC_NULL_INTEGER,ierr) call VecGetArrayRead(x,x_array,i_x,ierr) call VecGetArray(y,y_array,i_y,ierr) trans = 0 one = 1 call mvmisg(trans,N,one,x_array(i_x+1),N,y_array(i_y+1),N) call VecRestoreArrayRead(x,x_array,i_x,ierr) call VecRestoreArray(y,y_array,i_y,ierr) return end ! ------------------------------------------------------------------- ! The actual routine for the matrix-vector product ! See http://math.nist.gov/MatrixMarket/data/NEP/mvmisg/mvmisg.html SUBROUTINE MVMISG( TRANS, N, M, X, LDX, Y, LDY ) ! .. ! .. Scalar Arguments .. PetscInt LDY, LDX, M, N, TRANS ! .. ! .. Array Arguments .. PetscScalar Y( LDY, * ), X( LDX, * ) ! .. ! ! Purpose ! ======= ! ! Compute ! ! Y(:,1:M) = op(A)*X(:,1:M) ! ! where op(A) is A or A' (the transpose of A). The A is the Ising ! matrix. ! ! Arguments ! ========= ! ! TRANS (input) INTEGER ! If TRANS = 0, compute Y(:,1:M) = A*X(:,1:M) ! If TRANS = 1, compute Y(:,1:M) = A'*X(:,1:M) ! ! N (input) INTEGER ! The order of the matrix A. N has to be an even number. ! ! M (input) INTEGER ! The number of columns of X to multiply. ! ! X (input) DOUBLE PRECISION array, dimension ( LDX, M ) ! X contains the matrix (vectors) X. ! ! LDX (input) INTEGER ! The leading dimension of array X, LDX >= max( 1, N ) ! ! Y (output) DOUBLE PRECISION array, dimension (LDX, M ) ! contains the product of the matrix op(A) with X. ! ! LDY (input) INTEGER ! The leading dimension of array Y, LDY >= max( 1, N ) ! ! =================================================================== ! ! #include ! .. Local Variables .. PetscInt I, K PetscReal ALPHA, BETA PetscReal COSA, COSB, SINA PetscReal SINB, TEMP, TEMP1 ! ! .. Intrinsic functions .. INTRINSIC COS, SIN ! ALPHA = PETSC_PI/4 BETA = PETSC_PI/4 COSA = COS( ALPHA ) SINA = SIN( ALPHA ) COSB = COS( BETA ) SINB = SIN( BETA ) ! IF ( TRANS.EQ.0 ) THEN ! ! Compute Y(:,1:M) = A*X(:,1:M) DO 30 K = 1, M ! Y( 1, K ) = COSB*X( 1, K ) - SINB*X( N, K ) DO 10 I = 2, N-1, 2 Y( I, K ) = COSB*X( I, K ) + SINB*X( I+1, K ) Y( I+1, K ) = -SINB*X( I, K ) + COSB*X( I+1, K ) 10 CONTINUE Y( N, K ) = SINB*X( 1, K ) + COSB*X( N, K ) ! DO 20 I = 1, N, 2 TEMP = COSA*Y( I, K ) + SINA*Y( I+1, K ) Y( I+1, K ) = -SINA*Y( I, K ) + COSA*Y( I+1, K ) Y( I, K ) = TEMP 20 CONTINUE ! 30 CONTINUE ! ELSE IF ( TRANS.EQ.1 ) THEN ! ! Compute Y(:1:M) = A'*X(:,1:M) ! DO 60 K = 1, M ! DO 40 I = 1, N, 2 Y( I, K ) = COSA*X( I, K ) - SINA*X( I+1, K ) Y( I+1, K ) = SINA*X( I, K ) + COSA*X( I+1, K ) 40 CONTINUE TEMP = COSB*Y(1,K) + SINB*Y(N,K) DO 50 I = 2, N-1, 2 TEMP1 = COSB*Y( I, K ) - SINB*Y( I+1, K ) Y( I+1, K ) = SINB*Y( I, K ) + COSB*Y( I+1, K ) Y( I, K ) = TEMP1 50 CONTINUE Y( N, K ) = -SINB*Y( 1, K ) + COSB*Y( N, K ) Y( 1, K ) = TEMP ! 60 CONTINUE ! END IF ! RETURN ! ! END OF MVMISG END slepc-3.7.4/src/eps/examples/tutorials/ex9.c0000644000175000017500000002446513107004621020271 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves a problem associated to the Brusselator wave model in chemical reactions, illustrating the use of shell matrices.\n\n" "The command line options are:\n" " -n , where = block dimension of the 2x2 block matrix.\n" " -L , where = bifurcation parameter.\n" " -alpha , -beta , -delta1 , -delta2 ,\n" " where = model parameters.\n\n"; #include /* This example computes the eigenvalues with largest real part of the following matrix A = [ tau1*T+(beta-1)*I alpha^2*I -beta*I tau2*T-alpha^2*I ], where T = tridiag{1,-2,1} h = 1/(n+1) tau1 = delta1/(h*L)^2 tau2 = delta2/(h*L)^2 */ /* Matrix operations */ PetscErrorCode MatMult_Brussel(Mat,Vec,Vec); PetscErrorCode MatShift_Brussel(PetscScalar*,Mat); PetscErrorCode MatGetDiagonal_Brussel(Mat,Vec); typedef struct { Mat T; Vec x1,x2,y1,y2; PetscScalar alpha,beta,tau1,tau2,sigma; } CTX_BRUSSEL; #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* eigenvalue problem matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscScalar delta1,delta2,L,h; PetscInt N=30,n,i,Istart,Iend,nev; CTX_BRUSSEL *ctx; PetscBool terse; PetscViewer viewer; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&N,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nBrusselator wave model, n=%D\n\n",N);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Generate the matrix - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create shell matrix context and set default parameters */ ierr = PetscNew(&ctx);CHKERRQ(ierr); ctx->alpha = 2.0; ctx->beta = 5.45; delta1 = 0.008; delta2 = 0.004; L = 0.51302; /* Look the command line for user-provided parameters */ ierr = PetscOptionsGetScalar(NULL,NULL,"-L",&L,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-alpha",&ctx->alpha,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-beta",&ctx->beta,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-delta1",&delta1,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-delta2",&delta2,NULL);CHKERRQ(ierr); /* Create matrix T */ ierr = MatCreate(PETSC_COMM_WORLD,&ctx->T);CHKERRQ(ierr); ierr = MatSetSizes(ctx->T,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(ctx->T);CHKERRQ(ierr); ierr = MatSetUp(ctx->T);CHKERRQ(ierr); ierr = MatGetOwnershipRange(ctx->T,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(ctx->T,i,i-1,1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iT,i,i+1,1.0,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(ctx->T,i,i,-2.0,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatAssemblyBegin(ctx->T,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(ctx->T,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->T,&n,NULL);CHKERRQ(ierr); /* Fill the remaining information in the shell matrix context and create auxiliary vectors */ h = 1.0 / (PetscReal)(N+1); ctx->tau1 = delta1 / ((h*L)*(h*L)); ctx->tau2 = delta2 / ((h*L)*(h*L)); ctx->sigma = 0.0; ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->x2);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PETSC_COMM_WORLD,1,n,PETSC_DECIDE,NULL,&ctx->y2);CHKERRQ(ierr); /* Create the shell matrix */ ierr = MatCreateShell(PETSC_COMM_WORLD,2*n,2*n,2*N,2*N,(void*)ctx,&A);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Brussel);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_SHIFT,(void(*)())MatShift_Brussel);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Brussel);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); /* Ask for the rightmost eigenvalues */ ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL);CHKERRQ(ierr); /* Set other solver options at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSReasonView(eps,viewer);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = MatDestroy(&ctx->T);CHKERRQ(ierr); ierr = VecDestroy(&ctx->x1);CHKERRQ(ierr); ierr = VecDestroy(&ctx->x2);CHKERRQ(ierr); ierr = VecDestroy(&ctx->y1);CHKERRQ(ierr); ierr = VecDestroy(&ctx->y2);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMult_Brussel" PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y) { PetscInt n; const PetscScalar *px; PetscScalar *py; CTX_BRUSSEL *ctx; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->T,&n,NULL);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->x1,px);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->x2,px+n);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->y1,py);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->y2,py+n);CHKERRQ(ierr); ierr = MatMult(ctx->T,ctx->x1,ctx->y1);CHKERRQ(ierr); ierr = VecScale(ctx->y1,ctx->tau1);CHKERRQ(ierr); ierr = VecAXPY(ctx->y1,ctx->beta - 1.0 + ctx->sigma,ctx->x1);CHKERRQ(ierr); ierr = VecAXPY(ctx->y1,ctx->alpha * ctx->alpha,ctx->x2);CHKERRQ(ierr); ierr = MatMult(ctx->T,ctx->x2,ctx->y2);CHKERRQ(ierr); ierr = VecScale(ctx->y2,ctx->tau2);CHKERRQ(ierr); ierr = VecAXPY(ctx->y2,-ctx->beta,ctx->x1);CHKERRQ(ierr); ierr = VecAXPY(ctx->y2,-ctx->alpha * ctx->alpha + ctx->sigma,ctx->x2);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); ierr = VecResetArray(ctx->x1);CHKERRQ(ierr); ierr = VecResetArray(ctx->x2);CHKERRQ(ierr); ierr = VecResetArray(ctx->y1);CHKERRQ(ierr); ierr = VecResetArray(ctx->y2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatShift_Brussel" PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y) { CTX_BRUSSEL *ctx; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(Y,(void**)&ctx);CHKERRQ(ierr); ctx->sigma += *a; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatGetDiagonal_Brussel" PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag) { Vec d1,d2; PetscInt n; PetscScalar *pd; MPI_Comm comm; CTX_BRUSSEL *ctx; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = PetscObjectGetComm((PetscObject)A,&comm);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->T,&n,NULL);CHKERRQ(ierr); ierr = VecGetArray(diag,&pd);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd,&d1);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(comm,1,n,PETSC_DECIDE,pd+n,&d2);CHKERRQ(ierr); ierr = VecSet(d1,-2.0*ctx->tau1 + ctx->beta - 1.0 + ctx->sigma);CHKERRQ(ierr); ierr = VecSet(d2,-2.0*ctx->tau2 - ctx->alpha*ctx->alpha + ctx->sigma);CHKERRQ(ierr); ierr = VecDestroy(&d1);CHKERRQ(ierr); ierr = VecDestroy(&d2);CHKERRQ(ierr); ierr = VecRestoreArray(diag,&pd);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tutorials/ex4.c0000644000175000017500000001173713107004621020262 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves a standard eigensystem Ax=kx with the matrix loaded from a file.\n" "This example works for both real and complex numbers.\n\n" "The command line options are:\n" " -file , where = matrix file in PETSc binary form.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscReal tol; PetscInt nev,maxit,its; char filename[PETSC_MAX_PATH_LEN]; PetscViewer viewer; PetscBool flg,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscPrintf(PETSC_COMM_WORLD,"\nEigenproblem stored in file.\n\n");CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-file",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name with the -file option"); #if defined(PETSC_USE_COMPLEX) ierr = PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrix from a binary file...\n");CHKERRQ(ierr); #else ierr = PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrix from a binary file...\n");CHKERRQ(ierr); #endif ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatLoad(A,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); ierr = EPSGetIterationNumber(eps,&its);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); ierr = EPSGetTolerances(eps,&tol,&maxit);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/eps/examples/tutorials/output/0000755000175000017500000000000013107004621020745 5ustar jromanjromanslepc-3.7.4/src/eps/examples/tutorials/output/ex3_1.out0000644000175000017500000000036513107004621022421 0ustar jromanjroman 2-D Laplacian Eigenproblem (matrix-free version), N=100 (10x10 grid) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.36501, 7.22871 slepc-3.7.4/src/eps/examples/tutorials/output/ex13_1.out0000644000175000017500000000036213107004621022477 0ustar jromanjroman Generalized Symmetric Eigenproblem, N=100 (10x10 grid), null(B)=0 Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.04051, 0.09963, 0.15875, 0.19282 slepc-3.7.4/src/eps/examples/tutorials/output/ex1f_1.out0000644000175000017500000000064413107004621022565 0ustar jromanjroman 1-D Laplacian Eigenproblem, n = 30 (Fortran) Number of iterations of the method: 4 Solution method: krylovschur Number of requested eigenvalues: 1 Stopping condition: tol=1.0000E-08, maxit= 100 Number of converged eigenpairs: 1 k ||Ax-kx||/||kx|| ----------------- ------------------ 3.9897E+00 4.7299E-09 slepc-3.7.4/src/eps/examples/tutorials/output/ex12_1.out0000644000175000017500000000045513107004621022501 0ustar jromanjroman Symmetric-definite problem with two intervals, N=1225 (35x35 grid) Found 58 eigenvalues in interval [1.1,1.3] Used 3 shifts (inertia): .. 1.1 (252) .. 1.20347 (280) .. 1.3 (310) Found 38 eigenvalues in interval [1.5,1.6] Used 3 shifts (inertia): .. 1.5 (376) .. 1.53168 (388) .. 1.6 (414) slepc-3.7.4/src/eps/examples/tutorials/output/ex9_2.out0000644000175000017500000000040113107004621022417 0ustar jromanjroman Brusselator wave model, n=30 Solution method: krylovschur Number of requested eigenvalues: 8 All requested eigenvalues computed up to the required tolerance: -27.77623, -25.84906, -30.25342, -30.89832, -32.93745, -35.71808, -37.44109, -38.53184 slepc-3.7.4/src/eps/examples/tutorials/output/ex6f_1.out0000644000175000017500000000064013107004621022566 0ustar jromanjroman Ising Model Eigenproblem, m= 30, (N=2*m) Number of iterations of the method: 12 Solution method: krylovschur Number of requested eigenvalues: 4 Stopping condition: tol=1.0000E-05, maxit= 1000 All requested eigenvalues computed up to the required tolerance: 0.00000+1.00000i, 0.00000-1.00000i, 0.01093+0.99994i, 0.01093-0.99994i slepc-3.7.4/src/eps/examples/tutorials/output/ex29_1.out0000644000175000017500000000023313107004621022503 0ustar jromanjroman Markov Model, N=61425 (m=350) Maximum time for computation is set to 2.5 seconds. Eigensolve finished with 0 converged eigenpairs; reason=CONVERGED_USER slepc-3.7.4/src/eps/examples/tutorials/output/ex10_1.out0000644000175000017500000000035213107004621022473 0ustar jromanjroman 1-D Laplacian Eigenproblem (shell-enabled), n=30 Solution method: krylovschur Number of requested eigenvalues: 5 All requested eigenvalues computed up to the required tolerance: 0.01026, 0.04094, 0.09172, 0.16208, 0.25131 slepc-3.7.4/src/eps/examples/tutorials/output/ex4_1.out0000644000175000017500000000052113107004621022414 0ustar jromanjroman Eigenproblem stored in file. Reading REAL matrix from a binary file... Number of iterations of the method: 5 Solution method: krylovschur Number of requested eigenvalues: 4 Stopping condition: tol=1e-08, maxit=100 All requested eigenvalues computed up to the required tolerance: -35.00752, -34.10419, -33.20131, -32.68111 slepc-3.7.4/src/eps/examples/tutorials/output/ex4_ciss_1.out0000644000175000017500000000056113107004621023441 0ustar jromanjroman Eigenproblem stored in file. Reading COMPLEX matrix from a binary file... Number of iterations of the method: 1 Solution method: ciss Number of requested eigenvalues: 1 Stopping condition: tol=1e-08, maxit=1 Found 4 eigenvalues, all of them computed up to the required tolerance: -0.04079-0.04791i, -0.04021-0.07188i, -0.03153-0.05665i, 0.00464-0.07540i slepc-3.7.4/src/eps/examples/tutorials/output/ex1_1.out0000644000175000017500000000051613107004621022415 0ustar jromanjroman 1-D Laplacian Eigenproblem, n=30 Number of iterations of the method: 4 Solution method: krylovschur Number of requested eigenvalues: 1 Stopping condition: tol=1e-08, maxit=100 Number of converged eigenpairs: 1 k ||Ax-kx||/||kx|| ----------------- ------------------ 3.989739 4.72989e-09 slepc-3.7.4/src/eps/examples/tutorials/output/ex7_1.out0000644000175000017500000000066513107004621022430 0ustar jromanjroman Generalized eigenproblem stored in file. Reading REAL matrices from binary files... Number of iterations of the method: 4 Number of linear iterations of the method: 46 Solution method: krylovschur Number of requested eigenvalues: 4 Stopping condition: tol=1e-08, maxit=100 All requested eigenvalues computed up to the required tolerance: -243874.97870+6999.66927i, -243874.97870-6999.66927i, -212991.49278, -199807.74659 slepc-3.7.4/src/eps/examples/tutorials/output/ex25_1.out0000644000175000017500000000033213107004621022477 0ustar jromanjroman Spectrum slicing on GHEP, N=100 (10x10 grid) Solution method: krylovschur 3 eigenvalues found in [0.1, 0.2] Found 3 eigenvalues, all of them computed up to the required tolerance: 0.15875, 0.19282, 0.19282 slepc-3.7.4/src/eps/examples/tutorials/output/ex19_1.out0000644000175000017500000000207613107004621022511 0ustar jromanjroman 3-D Laplacian Eigenproblem Grid partitioning: 1 1 1 Number of iterations of the method: 6 Solution method: krylovschur Number of requested eigenvalues: 8 Stopping condition: tol=1e-08, maxit=100 Number of converged approximate eigenpairs: 13 k ||Ax-kx||/||kx|| Eigenvalue Error ----------------- ------------------ ------------------ 0.243042 3.34915e-14 4.16334e-16 0.479521 5.58182e-13 4.21885e-15 0.479521 1.74895e-10 1.11022e-15 0.479521 3.70078e-12 1.88738e-15 0.716 1.699e-14 1.9984e-15 0.716 7.07904e-09 2.88658e-15 0.716 1.06562e-11 3.66374e-15 0.852307 1.37067e-10 2.10942e-15 0.852307 9.35032e-15 1.55431e-15 0.852307 1.34629e-12 3.21965e-15 0.952479 9.9195e-15 1.55431e-15 1.08879 8.90745e-13 2.44249e-15 1.08879 1.18168e-09 6.66134e-16 slepc-3.7.4/src/eps/examples/tutorials/output/ex5_1.out0000644000175000017500000000031513107004621022416 0ustar jromanjroman Markov Model, N=120 (m=15) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 1.00000, -1.00000, -0.90423, 0.90423 slepc-3.7.4/src/eps/examples/tutorials/output/ex9_1.out0000644000175000017500000000036313107004621022425 0ustar jromanjroman Brusselator wave model, n=30 Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.00019+2.13938i, 0.00019-2.13938i, -0.67192+2.52712i, -0.67192-2.52712i slepc-3.7.4/src/eps/examples/tutorials/output/ex7_ciss_1.out0000644000175000017500000000116213107004621023442 0ustar jromanjroman Generalized eigenproblem stored in file. Reading COMPLEX matrices from binary files... Number of iterations of the method: 1 Number of linear iterations of the method: 0 Solution method: ciss Number of requested eigenvalues: 1 Stopping condition: tol=1e-08, maxit=1 Found 14 eigenvalues, all of them computed up to the required tolerance: -0.52247+0.13601i, -0.45897+0.29122i, -0.39887+0.37515i, -0.34178+0.43306i, -0.28745+0.47540i, -0.23601+0.50651i, -0.18794+0.52882i, -0.14379+0.54411i, -0.10350+0.55413i, -0.07225+0.56125i, -0.06688+0.58413i, -0.05186+0.54060i, -0.02676+0.51734i, -0.01613+0.47357i slepc-3.7.4/src/eps/examples/tutorials/output/ex31_1.out0000644000175000017500000000041213107004621022473 0ustar jromanjroman Stability analysis in a network with 9 buses and 3 generators Number of iterations of the eigensolver: 1 Solution method: krylovschur Number of requested eigenvalues: 1 All requested eigenvalues computed up to the required tolerance: -1.44091+17.35854i slepc-3.7.4/src/eps/examples/tutorials/output/ex24_1.out0000644000175000017500000000027613107004621022505 0ustar jromanjroman Spectrum Folding, N=225 (15x15 grid) target=2.100000 Solution method: krylovschur Number of converged eigenpairs: 1 nconv=1 eigenvalues computed up to the required tolerance: 2.12349 slepc-3.7.4/src/eps/examples/tutorials/output/ex1f90_1.out0000644000175000017500000000044313107004621022733 0ustar jromanjroman 1-D Laplacian Eigenproblem, n = 30 (Fortran) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 slepc-3.7.4/src/eps/examples/tutorials/output/ex2_1.out0000644000175000017500000000033713107004621022417 0ustar jromanjroman 2-D Laplacian Eigenproblem, N=100 (10x10 grid) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.36501, 7.22871 slepc-3.7.4/src/eps/examples/tutorials/output/ex2_ciss.out0000644000175000017500000000051113107004621023212 0ustar jromanjroman 2-D Laplacian Eigenproblem, N=900 (30x30 grid) Solution method: ciss Number of requested eigenvalues: 1 Found 15 eigenvalues, all of them computed up to the required tolerance: 1.10416, 1.10416, 1.10455, 1.10455, 1.12947, 1.12947, 1.13426, 1.13426, 1.16015, 1.16015, 1.19338, 1.19338, 1.21093, 1.21093, 1.24413 slepc-3.7.4/src/eps/examples/tutorials/output/ex18_1.out0000644000175000017500000000037613107004621022511 0ustar jromanjroman Markov Model, N=120 (m=15) Searching closest eigenvalues to the right of 0.5. Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.51928, 0.55740, 0.57028, 0.57143 slepc-3.7.4/src/eps/examples/tutorials/output/ex30_1.out0000644000175000017500000000016213107004621022474 0ustar jromanjroman Brusselator wave model, n=100 Linear eigensolve converged (20 eigenpairs) due to CONVERGED_USER; iterations 26 slepc-3.7.4/src/eps/examples/tutorials/output/ex11_1.out0000644000175000017500000000035113107004621022473 0ustar jromanjroman Fiedler vector of a 2-D regular mesh, N=100 (10x10 grid) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.09789, 0.19577, 0.38197, 0.47985 slepc-3.7.4/src/eps/examples/tutorials/ex19.c0000644000175000017500000002255513107004621020350 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Standard symmetric eigenproblem for the 3-D Laplacian built with the DM interface.\n\n" "Use -seed to modify the random initial vector.\n" "Use -da_grid_x etc. to change the problem size.\n\n"; #include #include #include #undef __FUNCT__ #define __FUNCT__ "GetExactEigenvalues" PetscErrorCode GetExactEigenvalues(PetscInt M,PetscInt N,PetscInt P,PetscInt nconv,PetscReal *exact) { PetscInt n,i,j,k,l; PetscReal *evals,ax,ay,az,sx,sy,sz; PetscErrorCode ierr; PetscFunctionBeginUser; ax = PETSC_PI/2/(M+1); ay = PETSC_PI/2/(N+1); az = PETSC_PI/2/(P+1); n = PetscCeilReal(PetscPowReal((PetscReal)nconv,0.33333)+1); ierr = PetscMalloc1(n*n*n,&evals);CHKERRQ(ierr); l = 0; for (i=1;i<=n;i++) { sx = PetscSinReal(ax*i); for (j=1;j<=n;j++) { sy = PetscSinReal(ay*j); for (k=1;k<=n;k++) { sz = PetscSinReal(az*k); evals[l++] = 4.0*(sx*sx+sy*sy+sz*sz); } } } ierr = PetscSortReal(n*n*n,evals);CHKERRQ(ierr); for (i=0;i0) { v[idx]=-1.0; col[idx].i=i; col[idx].j=j; col[idx].k=k-1; idx++; } if (j>0) { v[idx]=-1.0; col[idx].i=i; col[idx].j=j-1; col[idx].k=k; idx++; } if (i>0) { v[idx]=-1.0; col[idx].i=i-1; col[idx].j=j; col[idx].k=k; idx++; } if (i=0"); ierr = MatCreateVecs(A,&v0,NULL);CHKERRQ(ierr); ierr = PetscRandomCreate(PETSC_COMM_WORLD,&rctx);CHKERRQ(ierr); ierr = PetscRandomSetFromOptions(rctx);CHKERRQ(ierr); for (i=0;i0) { ierr = PetscMalloc1(nconv,&exact);CHKERRQ(ierr); ierr = GetExactEigenvalues(M,N,P,nconv,exact);CHKERRQ(ierr); /* Display eigenvalues and relative errors */ ierr = PetscPrintf(PETSC_COMM_WORLD, " k ||Ax-kx||/||kx|| Eigenvalue Error \n" " ----------------- ------------------ ------------------\n");CHKERRQ(ierr); for (i=0;i Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

ex1.c: Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension
ex2.c: Standard symmetric eigenproblem corresponding to the Laplacian operator in 2 dimensions
ex3.c: Solves the same eigenproblem as in example ex2, but using a shell matrix
ex4.c: Solves a standard eigensystem Ax=kx with the matrix loaded from a file
ex5.c: Eigenvalue problem associated with a Markov model of a random walk on a triangular grid
ex7.c: Solves a generalized eigensystem Ax=kBx with matrices loaded from a file
ex9.c: Solves a problem associated to the Brusselator wave model in chemical reactions, illustrating the use of shell matrices
ex10.c: Illustrates the use of shell spectral transformations
ex11.c: Computes the smallest nonzero eigenvalue of the Laplacian of a graph
ex12.c: Compute all eigenvalues in an interval of a symmetric-definite problem
ex13.c: Generalized Symmetric eigenproblem
ex18.c: Solves the same problem as in ex5, but with a user-defined sorting criterion
ex19.c: Standard symmetric eigenproblem for the 3-D Laplacian built with the DM interface
ex24.c: Spectrum folding for a standard symmetric eigenproblem
ex25.c: Spectrum slicing on generalized symmetric eigenproblem
ex29.c: Solves the same problem as in ex5, with a user-defined stopping test
ex30.c: Illustrates the use of a region for filtering; the number of wanted eigenvalues in not known a priori
ex31.c: Power grid small signal stability analysis of WECC 9 bus system
makefile
slepc-3.7.4/src/eps/examples/tutorials/ex2.c0000644000175000017500000001171113107004621020250 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 2 dimensions.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscInt N,n=10,m,Istart,Iend,II,nev,i,j; PetscBool flag,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\n2-D Laplacian Eigenproblem, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Spectrum folding for a standard symmetric eigenproblem.\n\n" "The problem matrix is the 2-D Laplacian.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n"; #include /* User context for spectrum folding */ typedef struct { Mat A; Vec w; PetscReal target; } CTX_FOLD; /* Auxiliary routines */ PetscErrorCode MatMult_Fold(Mat,Vec,Vec); PetscErrorCode RayleighQuotient(Mat,Vec,PetscScalar*); PetscErrorCode ComputeResidualNorm(Mat,PetscScalar,Vec,PetscReal*); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,M,P; /* problem matrix, shell matrix and preconditioner */ Vec x; /* eigenvector */ EPS eps; /* eigenproblem solver context */ ST st; /* spectral transformation */ KSP ksp; PC pc; EPSType type; CTX_FOLD *ctx; PetscInt nconv,N,n=10,m,Istart,Iend,II,i,j; PetscReal *error,*evals,target=2.1,tol; PetscScalar lambda; PetscBool flag,terse,errok; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; ierr = PetscOptionsGetReal(NULL,NULL,"-target",&target,NULL);CHKERRQ(ierr); N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSpectrum Folding, N=%D (%Dx%D grid) target=%f\n\n",N,n,m,(double)target);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the 5-point stencil Laplacian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (jA = A; ctx->target = target; ierr = VecDuplicate(x,&ctx->w);CHKERRQ(ierr); ierr = MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,ctx,&M);CHKERRQ(ierr); ierr = MatSetFromOptions(M);CHKERRQ(ierr); ierr = MatShellSetOperation(M,MATOP_MULT,(void(*)())MatMult_Fold);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); ierr = EPSSetOperators(eps,M,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr); ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);CHKERRQ(ierr); ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); ierr = PetscObjectTypeCompareAny((PetscObject)eps,&flag,EPSBLOPEX,EPSRQCG,"");CHKERRQ(ierr); if (flag) { /* Build preconditioner specific for this application (diagonal of A^2) */ ierr = MatGetRowSum(A,x);CHKERRQ(ierr); ierr = VecScale(x,-1.0);CHKERRQ(ierr); ierr = VecShift(x,20.0);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&P);CHKERRQ(ierr); ierr = MatSetSizes(P,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(P);CHKERRQ(ierr); ierr = MatSetUp(P);CHKERRQ(ierr); ierr = MatDiagonalSet(P,x,INSERT_VALUES);CHKERRQ(ierr); /* Set diagonal preconditioner */ ierr = EPSGetST(eps,&st);CHKERRQ(ierr); ierr = STSetType(st,STPRECOND);CHKERRQ(ierr); ierr = STPrecondSetMatForPC(st,P);CHKERRQ(ierr); ierr = MatDestroy(&P);CHKERRQ(ierr); ierr = STGetKSP(st,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetTolerances(eps,&tol,NULL);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSGetConverged(eps,&nconv);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of converged eigenpairs: %D\n\n",nconv);CHKERRQ(ierr); if (nconv>0) { ierr = PetscMalloc2(nconv,&evals,nconv,&error);CHKERRQ(ierr); for (i=0;iw);CHKERRQ(ierr); ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMult_Fold" /* Matrix-vector product subroutine for the spectrum folding. y <-- (A-t*I)^2*x */ PetscErrorCode MatMult_Fold(Mat M,Vec x,Vec y) { CTX_FOLD *ctx; PetscScalar sigma; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); sigma = -ctx->target; ierr = MatMult(ctx->A,x,ctx->w);CHKERRQ(ierr); ierr = VecAXPY(ctx->w,sigma,x);CHKERRQ(ierr); ierr = MatMult(ctx->A,ctx->w,y);CHKERRQ(ierr); ierr = VecAXPY(y,sigma,ctx->w);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RayleighQuotient" /* Computes the Rayleigh quotient of a vector x r <-- x^T*A*x (assumes x has unit norm) */ PetscErrorCode RayleighQuotient(Mat A,Vec x,PetscScalar *r) { Vec Ax; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = VecDuplicate(x,&Ax);CHKERRQ(ierr); ierr = MatMult(A,x,Ax);CHKERRQ(ierr); ierr = VecDot(Ax,x,r);CHKERRQ(ierr); ierr = VecDestroy(&Ax);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "ComputeResidualNorm" /* Computes the residual norm of an approximate eigenvector x, |A*x-lambda*x| */ PetscErrorCode ComputeResidualNorm(Mat A,PetscScalar lambda,Vec x,PetscReal *r) { Vec Ax; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = VecDuplicate(x,&Ax);CHKERRQ(ierr); ierr = MatMult(A,x,Ax);CHKERRQ(ierr); ierr = VecAXPY(Ax,-lambda,x);CHKERRQ(ierr); ierr = VecNorm(Ax,NORM_2,r);CHKERRQ(ierr); ierr = VecDestroy(&Ax);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tutorials/ex18.c0000644000175000017500000002135013107004621020337 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion." "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n" "This example illustrates how the user can set a custom spectrum selection.\n\n" "The command line options are:\n" " -m , where = number of grid subdivisions in each dimension.\n\n"; #include /* User-defined routines */ PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx); PetscErrorCode MatMarkovModel(PetscInt m,Mat A); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscScalar target=0.5; PetscInt N,m=15,nev; PetscBool terse; PetscViewer viewer; PetscErrorCode ierr; char str[50]; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); N = m*(m+1)/2; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n",N,m);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-target",&target,NULL);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,target,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Searching closest eigenvalues to the right of %s.\n\n",str);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatMarkovModel(m,A);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); /* Set the custom comparing routine in order to obtain the eigenvalues closest to the target on the right only */ ierr = EPSSetEigenvalueComparison(eps,MyEigenSort,&target);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSReasonView(eps,viewer);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMarkovModel" /* Matrix generator for a Markov model of a random walk on a triangular grid. This subroutine generates a test matrix that models a random walk on a triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a FORTRAN subroutine to calculate the dominant invariant subspaces of a real matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295 (1980) ]. These matrices provide reasonably easy test problems for eigenvalue algorithms. The transpose of the matrix is stochastic and so it is known that one is an exact eigenvalue. One seeks the eigenvector of the transpose associated with the eigenvalue unity. The problem is to calculate the steady state probability distribution of the system, which is the eigevector associated with the eigenvalue one and scaled in such a way that the sum all the components is equal to one. Note: the code will actually compute the transpose of the stochastic matrix that contains the transition probabilities. */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A) { const PetscReal cst = 0.5/(PetscReal)(m-1); PetscReal pd,pu; PetscInt Istart,Iend,i,j,jmax,ix=0; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=1;i<=m;i++) { jmax = m-i+1; for (j=1;j<=jmax;j++) { ix = ix + 1; if (ix-1Iend) continue; /* compute only owned rows */ if (j!=jmax) { pd = cst*(PetscReal)(i+j-1); /* north */ if (i==1) { ierr = MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);CHKERRQ(ierr); } /* east */ if (j==1) { ierr = MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);CHKERRQ(ierr); } } /* south */ pu = 0.5 - cst*(PetscReal)(i+j-3); if (j>1) { ierr = MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);CHKERRQ(ierr); } /* west */ if (i>1) { ierr = MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);CHKERRQ(ierr); } } } ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MyEigenSort" /* Function for user-defined eigenvalue ordering criterion. Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose one of them as the preferred one according to the criterion. In this example, the preferred value is the one closest to the target, but on the right side. */ PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx) { PetscScalar target = *(PetscScalar*)ctx; PetscReal da,db; PetscBool aisright,bisright; PetscFunctionBeginUser; if (PetscRealPart(target) < PetscRealPart(ar)) aisright = PETSC_TRUE; else aisright = PETSC_FALSE; if (PetscRealPart(target) < PetscRealPart(br)) bisright = PETSC_TRUE; else bisright = PETSC_FALSE; if (aisright == bisright) { /* both are on the same side of the target */ da = SlepcAbsEigenvalue(ar-target,ai); db = SlepcAbsEigenvalue(br-target,bi); if (da < db) *r = -1; else if (da > db) *r = 1; else *r = 0; } else if (aisright && !bisright) *r = -1; /* 'a' is on the right */ else *r = 1; /* 'b' is on the right */ PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tutorials/Ybus.bin0000644000175000017500000000255013107004621021023 0ustar jromanjroman{Pl              1\kV?5a@1\nY2濞5a?5a@1\kV5a1\nY2/sB?6ޅ6@/. 6ޅ6?6ޅ6@/sB6ޅ6/. 1=4?ض@1 ض?ض@1=4ض1 @1\nY2濞5aCP o;@ =վ@'5L~}Y@%x.ڙ7!|5a1\nY2@ =վ@CP o;Y'5L~}7!|%x.ڙ@'5L~}Y1V?b@lB@扪 msEY'5L~}@lB@1V?bmsE扪 @%x.ڙ7!|/P|@ )L@Z\-F}7!|%x.ڙ@ )L@/P|F}Z\-@/. 6ޅ6@扪 msEAזv@^O@+e]s^8߻Ѓ(6ޅ6/. msE扪 @^O@Aזv߻Ѓ(+e]s^8@+e]s^8߻Ѓ(7M]~@-|iIF@#L{=e߻Ѓ(+e]s^8@-|iIF@7M]~ڿ{=e#L@1 ض@Z\-F}@#L{=e@z;@4Xض1 F}Z\-{=e#L@4X@@z;slepc-3.7.4/src/eps/examples/tutorials/ex7.c0000644000175000017500000002152213107004621020256 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves a generalized eigensystem Ax=kBx with matrices loaded from a file.\n" "The command line options are:\n" " -f1 -f2 , PETSc binary files containing A and B.\n" " -evecs , output file to save computed eigenvectors.\n" " -ninitial , number of user-provided initial guesses.\n" " -finitial , binary file containing vectors.\n" " -nconstr , number of user-provided constraints.\n" " -fconstr , binary file containing vectors.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B; /* matrices */ EPS eps; /* eigenproblem solver context */ ST st; KSP ksp; EPSType type; PetscReal tol; Vec xr,xi,*Iv,*Cv; PetscInt nev,maxit,i,its,lits,nconv,nini=0,ncon=0; char filename[PETSC_MAX_PATH_LEN]; PetscViewer viewer; PetscBool flg,evecs,ishermitian,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load the matrices that define the eigensystem, Ax=kBx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscPrintf(PETSC_COMM_WORLD,"\nGeneralized eigenproblem stored in file.\n\n");CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-f1",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a file name for matrix A with the -f1 option"); #if defined(PETSC_USE_COMPLEX) ierr = PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrices from binary files...\n");CHKERRQ(ierr); #else ierr = PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrices from binary files...\n");CHKERRQ(ierr); #endif ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatLoad(A,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-f2",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatLoad(B,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD," Matrix B was not provided, setting B=I\n\n");CHKERRQ(ierr); B = NULL; } ierr = MatCreateVecs(A,NULL,&xr);CHKERRQ(ierr); ierr = MatCreateVecs(A,NULL,&xi);CHKERRQ(ierr); /* Read user constraints if available */ ierr = PetscOptionsGetInt(NULL,NULL,"-nconstr",&ncon,&flg);CHKERRQ(ierr); if (flg) { if (ncon<=0) SETERRQ(PETSC_COMM_WORLD,1,"The number of constraints must be >0"); ierr = PetscOptionsGetString(NULL,NULL,"-fconstr",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must specify the name of the file storing the constraints"); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = VecDuplicateVecs(xr,ncon,&Cv);CHKERRQ(ierr); for (i=0;i0"); ierr = PetscOptionsGetString(NULL,NULL,"-finitial",filename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must specify the name of the file containing the initial vectors"); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = VecDuplicateVecs(xr,nini,&Iv);CHKERRQ(ierr); for (i=0;i0 && evecs) { ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); ierr = EPSIsHermitian(eps,&ishermitian);CHKERRQ(ierr); for (i=0;i 0) { ierr = VecDestroyVecs(nini,&Iv);CHKERRQ(ierr); } if (ncon > 0) { ierr = VecDestroyVecs(ncon,&Cv);CHKERRQ(ierr); } ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/eps/examples/tutorials/ex3.c0000644000175000017500000001544713107004621020263 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. " "The problem is a standard symmetric eigenproblem corresponding to the 2-D Laplacian operator.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in both x and y dimensions.\n\n"; #include #include /* User-defined routines */ PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y); PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscMPIInt size; PetscInt N,n=10,nev; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); if (size != 1) SETERRQ(PETSC_COMM_WORLD,1,"This is a uniprocessor example only"); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); N = n*n; ierr = PetscPrintf(PETSC_COMM_WORLD,"\n2-D Laplacian Eigenproblem (matrix-free version), N=%D (%Dx%D grid)\n\n",N,n,n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,&n,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Laplacian2D);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Laplacian2D);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Laplacian2D);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } /* Compute the matrix vector multiplication y<---T*x where T is a nx by nx tridiagonal matrix with DD on the diagonal, DL on the subdiagonal, and DU on the superdiagonal. */ static void tv(int nx,const PetscScalar *x,PetscScalar *y) { PetscScalar dd,dl,du; int j; dd = 4.0; dl = -1.0; du = -1.0; y[0] = dd*x[0] + du*x[1]; for (j=1;j. ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./ex1f [-help] [-n ] [all SLEPc options] ! ! Description: Simple example that solves an eigensystem with the EPS object. ! The standard symmetric eigenvalue problem to be solved corresponds to the ! Laplacian operator in 1 dimension. ! ! The command line options are: ! -n , where = number of grid points = matrix size ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! A operator matrix ! eps eigenproblem solver context Mat A EPS eps EPSType tname PetscReal tol, error PetscScalar kr, ki Vec xr, xi PetscInt n, i, Istart, Iend PetscInt nev, maxit, its, nconv PetscInt col(3) PetscInt i1,i2,i3 PetscMPIInt rank PetscErrorCode ierr PetscBool flg PetscScalar value(3) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 30 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-n',n,flg,ierr) if (rank .eq. 0) then write(*,100) n endif 100 format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)') ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Compute the operator matrix that defines the eigensystem, Ax=kx ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call MatCreate(PETSC_COMM_WORLD,A,ierr) call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A,ierr) call MatSetUp(A,ierr) i1 = 1 i2 = 2 i3 = 3 call MatGetOwnershipRange(A,Istart,Iend,ierr) if (Istart .eq. 0) then i = 0 col(1) = 0 col(2) = 1 value(1) = 2.0 value(2) = -1.0 call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr) Istart = Istart+1 endif if (Iend .eq. n) then i = n-1 col(1) = n-2 col(2) = n-1 value(1) = -1.0 value(2) = 2.0 call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr) Iend = Iend-1 endif value(1) = -1.0 value(2) = 2.0 value(3) = -1.0 do i=Istart,Iend-1 col(1) = i-1 col(2) = i col(3) = i+1 call MatSetValues(A,i1,i,i3,col,value,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr) call MatCreateVecs(A,xr,xi,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create the eigensolver and display info ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Create eigensolver context call EPSCreate(PETSC_COMM_WORLD,eps,ierr) ! ** Set operators. In this case, it is a standard eigenvalue problem call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr) call EPSSetProblemType(eps,EPS_HEP,ierr) ! ** Set solver parameters at runtime call EPSSetFromOptions(eps,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the eigensystem ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSSolve(eps,ierr) call EPSGetIterationNumber(eps,its,ierr) if (rank .eq. 0) then write(*,110) its endif 110 format (/' Number of iterations of the method:',I4) ! ** Optional: Get some information from the solver and display it call EPSGetType(eps,tname,ierr) if (rank .eq. 0) then write(*,120) tname endif 120 format (' Solution method: ',A) call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER, & & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,130) nev endif 130 format (' Number of requested eigenvalues:',I2) call EPSGetTolerances(eps,tol,maxit,ierr) if (rank .eq. 0) then write(*,140) tol, maxit endif 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Get number of converged eigenpairs call EPSGetConverged(eps,nconv,ierr) if (rank .eq. 0) then write(*,150) nconv endif 150 format (' Number of converged eigenpairs:',I2/) ! ** Display eigenvalues and relative errors if (nconv.gt.0) then if (rank .eq. 0) then write(*,*) ' k ||Ax-kx||/||kx||' write(*,*) ' ----------------- ------------------' endif do i=0,nconv-1 ! ** Get converged eigenpairs: i-th eigenvalue is stored in kr ! ** (real part) and ki (imaginary part) call EPSGetEigenpair(eps,i,kr,ki,xr,xi,ierr) ! ** Compute the relative error associated to each eigenpair call EPSComputeError(eps,i,EPS_ERROR_RELATIVE,error,ierr) if (rank .eq. 0) then write(*,160) PetscRealPart(kr), error endif 160 format (1P,' ',E12.4,' ',E12.4) enddo if (rank .eq. 0) then write(*,*) endif endif ! ** Free work space call EPSDestroy(eps,ierr) call MatDestroy(A,ierr) call VecDestroy(xr,ierr) call VecDestroy(xi,ierr) call SlepcFinalize(ierr) end slepc-3.7.4/src/eps/examples/tutorials/ex25.c.html0000644000175000017500000004222413107004621021303 0ustar jromanjroman

Actual source code: ex25.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Spectrum slicing on generalized symmetric eigenproblem.\n\n"
 23:   "The problem is similar to ex13.c.\n\n"
 24:   "The command line options are:\n"
 25:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n";

 28: #include <slepceps.h>

 32: int main(int argc,char **argv)
 33: {
 34:   Mat            A,B;         /* matrices */
 35:   EPS            eps;         /* eigenproblem solver context */
 36:   ST             st;          /* spectral transformation context */
 37:   KSP            ksp;
 38:   PC             pc;
 39:   EPSType        type;
 40:   PetscInt       N,n=10,m,Istart,Iend,II,nev,i,j,*inertias,ns;
 41:   PetscReal      inta,intb,*shifts;
 42:   PetscBool      flag,show=PETSC_FALSE,terse;

 45:   SlepcInitialize(&argc,&argv,(char*)0,help);

 47:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 48:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 49:   PetscOptionsGetBool(NULL,NULL,"-show_inertias",&show,NULL);
 50:   if (!flag) m=n;
 51:   N = n*m;
 52:   PetscPrintf(PETSC_COMM_WORLD,"\nSpectrum slicing on GHEP, N=%D (%Dx%D grid)\n\n",N,n,m);

 54:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 55:      Compute the matrices that define the eigensystem, Ax=kBx
 56:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 58:   MatCreate(PETSC_COMM_WORLD,&A);
 59:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 60:   MatSetFromOptions(A);
 61:   MatSetUp(A);

 63:   MatCreate(PETSC_COMM_WORLD,&B);
 64:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);
 65:   MatSetFromOptions(B);
 66:   MatSetUp(B);

 68:   MatGetOwnershipRange(A,&Istart,&Iend);
 69:   for (II=Istart;II<Iend;II++) {
 70:     i = II/n; j = II-i*n;
 71:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); }
 72:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); }
 73:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); }
 74:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); }
 75:     MatSetValue(A,II,II,4.0,INSERT_VALUES);
 76:     MatSetValue(B,II,II,4.0,INSERT_VALUES);
 77:   }

 79:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 80:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 81:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 82:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);

 84:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 85:                 Create the eigensolver and set various options
 86:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 88:   /*
 89:      Create eigensolver context
 90:   */
 91:   EPSCreate(PETSC_COMM_WORLD,&eps);

 93:   /*
 94:      Set operators and set problem type
 95:   */
 96:   EPSSetOperators(eps,A,B);
 97:   EPSSetProblemType(eps,EPS_GHEP);

 99:   /*
100:      Set interval for spectrum slicing
101:   */
102:   inta = 0.1;
103:   intb = 0.2;
104:   EPSSetInterval(eps,inta,intb);
105:   EPSSetWhichEigenpairs(eps,EPS_ALL);

107:   /*
108:      Spectrum slicing requires Krylov-Schur
109:   */
110:   EPSSetType(eps,EPSKRYLOVSCHUR);

112:   /*
113:      Set shift-and-invert with Cholesky; select MUMPS if available
114:   */

116:   EPSGetST(eps,&st);
117:   STSetType(st,STSINVERT);
118:   
119:   STGetKSP(st,&ksp);
120:   KSPSetType(ksp,KSPPREONLY);
121:   KSPGetPC(ksp,&pc);
122:   PCSetType(pc,PCCHOLESKY);
123:     
124: #if defined(PETSC_HAVE_MUMPS)
125: #if defined(PETSC_USE_COMPLEX)
126:   SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Spectrum slicing with MUMPS is not available for complex scalars");
127: #endif
128:   EPSKrylovSchurSetDetectZeros(eps,PETSC_TRUE);  /* enforce zero detection */
129:   PCFactorSetMatSolverPackage(pc,MATSOLVERMUMPS);
130:   /*
131:      Add several MUMPS options (currently there is no better way of setting this in program):
132:      '-mat_mumps_icntl_13 1': turn off ScaLAPACK for matrix inertia 
133:      '-mat_mumps_icntl_24 1': detect null pivots in factorization (for the case that a shift is equal to an eigenvalue)
134:      '-mat_mumps_cntl_3 <tol>': a tolerance used for null pivot detection (must be larger than machine epsilon)

136:      Note: depending on the interval, it may be necessary also to increase the workspace:
137:      '-mat_mumps_icntl_14 <percentage>': increase workspace with a percentage (50, 100 or more)
138:   */
139:   PetscOptionsInsertString(NULL,"-mat_mumps_icntl_13 1 -mat_mumps_icntl_24 1 -mat_mumps_cntl_3 1e-12"); 
140: #endif

142:   /*
143:      Set solver parameters at runtime
144:   */
145:   EPSSetFromOptions(eps);

147:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
148:                       Solve the eigensystem
149:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
150:   EPSSetUp(eps);
151:   if (show) {
152:     EPSKrylovSchurGetInertias(eps,&ns,&shifts,&inertias);  
153:     PetscPrintf(PETSC_COMM_WORLD,"Subintervals (after setup):\n");
154:     for (i=0;i<ns;i++) { PetscPrintf(PETSC_COMM_WORLD,"Shift %g  Inertia %D \n",shifts[i],inertias[i]); }
155:     PetscPrintf(PETSC_COMM_WORLD,"\n");
156:     PetscFree(shifts);
157:     PetscFree(inertias);
158:   }
159:   EPSSolve(eps);
160:   if (show) {
161:     EPSKrylovSchurGetInertias(eps,&ns,&shifts,&inertias);  
162:     PetscPrintf(PETSC_COMM_WORLD,"All shifts (after solve):\n");
163:     for (i=0;i<ns;i++) { PetscPrintf(PETSC_COMM_WORLD,"Shift %g  Inertia %D \n",shifts[i],inertias[i]); }
164:     PetscPrintf(PETSC_COMM_WORLD,"\n");
165:     PetscFree(shifts);
166:     PetscFree(inertias);
167:   }

169:   /*
170:      Show eigenvalues in interval and print solution
171:   */
172:   EPSGetType(eps,&type);
173:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
174:   EPSGetDimensions(eps,&nev,NULL,NULL);
175:   EPSGetInterval(eps,&inta,&intb);
176:   PetscPrintf(PETSC_COMM_WORLD," %D eigenvalues found in [%g, %g]\n",nev,(double)inta,(double)intb);

178:   /*
179:      Show detailed info unless -terse option is given by user
180:    */
181:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
182:   if (terse) {
183:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
184:   } else {
185:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
186:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
187:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
188:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
189:   }

191:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
192:                     Clean up
193:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
194:   EPSDestroy(&eps);
195:   MatDestroy(&A);
196:   MatDestroy(&B);
197:   SlepcFinalize();
198:   return ierr;
199: }

slepc-3.7.4/src/eps/examples/tutorials/ex11.c0000644000175000017500000001331213107004621020327 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\n\n" "This example illustrates EPSSetDeflationSpace(). The example graph corresponds to a " "2-D regular mesh. The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main (int argc,char **argv) { EPS eps; /* eigenproblem solver context */ Mat A; /* operator matrix */ Vec x; EPSType type; PetscInt N,n=10,m,i,j,II,Istart,Iend,nev; PetscScalar w; PetscBool flag,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nFiedler vector of a 2-D regular mesh, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx In this example, A = L(G), where L is the Laplacian of graph G, i.e. Lii = degree of node i, Lij = -1 if edge (i,j) exists in G - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); w=w+1.0; } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); w=w+1.0; } if (jActual source code: ex10.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Illustrates the use of shell spectral transformations. "
 23:   "The problem to be solved is the same as ex1.c and"
 24:   "corresponds to the Laplacian operator in 1 dimension.\n\n"
 25:   "The command line options are:\n"
 26:   "  -n <n>, where <n> = number of grid subdivisions = matrix dimension.\n\n";

 28: #include <slepceps.h>

 30: /* Define context for user-provided spectral transformation */
 31: typedef struct {
 32:   KSP        ksp;
 33: } SampleShellST;

 35: /* Declare routines for user-provided spectral transformation */
 36: PetscErrorCode STCreate_User(SampleShellST**);
 37: PetscErrorCode STSetUp_User(SampleShellST*,ST);
 38: PetscErrorCode STApply_User(ST,Vec,Vec);
 39: PetscErrorCode STBackTransform_User(ST,PetscInt,PetscScalar*,PetscScalar*);
 40: PetscErrorCode STDestroy_User(SampleShellST*);

 44: int main (int argc,char **argv)
 45: {
 46:   Mat            A;               /* operator matrix */
 47:   EPS            eps;             /* eigenproblem solver context */
 48:   ST             st;              /* spectral transformation context */
 49:   SampleShellST  *shell;          /* user-defined spectral transform context */
 50:   EPSType        type;
 51:   PetscInt       n=30,i,Istart,Iend,nev;
 52:   PetscBool      isShell,terse;

 55:   SlepcInitialize(&argc,&argv,(char*)0,help);

 57:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 58:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem (shell-enabled), n=%D\n\n",n);

 60:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 61:      Compute the operator matrix that defines the eigensystem, Ax=kx
 62:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 64:   MatCreate(PETSC_COMM_WORLD,&A);
 65:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 66:   MatSetFromOptions(A);
 67:   MatSetUp(A);

 69:   MatGetOwnershipRange(A,&Istart,&Iend);
 70:   for (i=Istart;i<Iend;i++) {
 71:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 72:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 73:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 74:   }
 75:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 76:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 78:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 79:                 Create the eigensolver and set various options
 80:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 82:   /*
 83:      Create eigensolver context
 84:   */
 85:   EPSCreate(PETSC_COMM_WORLD,&eps);

 87:   /*
 88:      Set operators. In this case, it is a standard eigenvalue problem
 89:   */
 90:   EPSSetOperators(eps,A,NULL);
 91:   EPSSetProblemType(eps,EPS_HEP);

 93:   /*
 94:      Set solver parameters at runtime
 95:   */
 96:   EPSSetFromOptions(eps);

 98:   /*
 99:      Initialize shell spectral transformation if selected by user
100:   */
101:   EPSGetST(eps,&st);
102:   PetscObjectTypeCompare((PetscObject)st,STSHELL,&isShell);
103:   if (isShell) {
104:     /* Change sorting criterion since this ST example computes values
105:        closest to 0 */
106:     EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);

108:     /* (Optional) Create a context for the user-defined spectral transform;
109:        this context can be defined to contain any application-specific data. */
110:     STCreate_User(&shell);

112:     /* (Required) Set the user-defined routine for applying the operator */
113:     STShellSetApply(st,STApply_User);
114:     STShellSetContext(st,shell);

116:     /* (Optional) Set the user-defined routine for back-transformation */
117:     STShellSetBackTransform(st,STBackTransform_User);

119:     /* (Optional) Set a name for the transformation, used for STView() */
120:     PetscObjectSetName((PetscObject)st,"MyTransformation");

122:     /* (Optional) Do any setup required for the new transformation */
123:     STSetUp_User(shell,st);
124:   }

126:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
127:                       Solve the eigensystem
128:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

130:   EPSSolve(eps);

132:   /*
133:      Optional: Get some information from the solver and display it
134:   */
135:   EPSGetType(eps,&type);
136:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
137:   EPSGetDimensions(eps,&nev,NULL,NULL);
138:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

140:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141:                     Display solution and clean up
142:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

144:   /* show detailed info unless -terse option is given by user */
145:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
146:   if (terse) {
147:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
148:   } else {
149:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
150:     EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD);
151:     EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
152:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
153:   }
154:   if (isShell) {
155:     STDestroy_User(shell);
156:   }
157:   EPSDestroy(&eps);
158:   MatDestroy(&A);
159:   SlepcFinalize();
160:   return ierr;
161: }

163: /***********************************************************************/
164: /*     Routines for a user-defined shell spectral transformation       */
165: /***********************************************************************/

169: /*
170:    STCreate_User - This routine creates a user-defined
171:    spectral transformation context.

173:    Output Parameter:
174: .  shell - user-defined spectral transformation context
175: */
176: PetscErrorCode STCreate_User(SampleShellST **shell)
177: {
178:   SampleShellST  *newctx;

182:   PetscNew(&newctx);
183:   KSPCreate(PETSC_COMM_WORLD,&newctx->ksp);
184:   KSPAppendOptionsPrefix(newctx->ksp,"st_");
185:   *shell = newctx;
186:   return(0);
187: }
188: /* ------------------------------------------------------------------- */
191: /*
192:    STSetUp_User - This routine sets up a user-defined
193:    spectral transformation context.

195:    Input Parameters:
196: .  shell - user-defined spectral transformation context
197: .  st    - spectral transformation context containing the operator matrices

199:    Output Parameter:
200: .  shell - fully set up user-defined transformation context

202:    Notes:
203:    In this example, the user-defined transformation is simply OP=A^-1.
204:    Therefore, the eigenpairs converge in reversed order. The KSP object
205:    used for the solution of linear systems with A is handled via the
206:    user-defined context SampleShellST.
207: */
208: PetscErrorCode STSetUp_User(SampleShellST *shell,ST st)
209: {
210:   Mat            A;

214:   STGetOperators(st,0,&A);
215:   KSPSetOperators(shell->ksp,A,A);
216:   KSPSetFromOptions(shell->ksp);
217:   return(0);
218: }
219: /* ------------------------------------------------------------------- */
222: /*
223:    STApply_User - This routine demonstrates the use of a
224:    user-provided spectral transformation.

226:    Input Parameters:
227: .  ctx - optional user-defined context, as set by STShellSetContext()
228: .  x - input vector

230:    Output Parameter:
231: .  y - output vector

233:    Notes:
234:    The transformation implemented in this code is just OP=A^-1 and
235:    therefore it is of little use, merely as an example of working with
236:    a STSHELL.
237: */
238: PetscErrorCode STApply_User(ST st,Vec x,Vec y)
239: {
240:   SampleShellST  *shell;

244:   STShellGetContext(st,(void**)&shell);
245:   KSPSolve(shell->ksp,x,y);
246:   return(0);
247: }
248: /* ------------------------------------------------------------------- */
251: /*
252:    STBackTransform_User - This routine demonstrates the use of a
253:    user-provided spectral transformation.

255:    Input Parameters:
256: +  ctx  - optional user-defined context, as set by STShellSetContext()
257: .  eigr - pointer to real part of eigenvalues
258: -  eigi - pointer to imaginary part of eigenvalues

260:    Output Parameters:
261: +  eigr - modified real part of eigenvalues
262: -  eigi - modified imaginary part of eigenvalues

264:    Notes:
265:    This code implements the back transformation of eigenvalues in
266:    order to retrieve the eigenvalues of the original problem. In this
267:    example, simply set k_i = 1/k_i.
268: */
269: PetscErrorCode STBackTransform_User(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
270: {
271:   PetscInt j;

274:   for (j=0;j<n;j++) {
275:     eigr[j] = 1.0 / eigr[j];
276:   }
277:   return(0);
278: }
279: /* ------------------------------------------------------------------- */
282: /*
283:    STDestroy_User - This routine destroys a user-defined
284:    spectral transformation context.

286:    Input Parameter:
287: .  shell - user-defined spectral transformation context
288: */
289: PetscErrorCode STDestroy_User(SampleShellST *shell)
290: {

294:   KSPDestroy(&shell->ksp);
295:   PetscFree(shell);
296:   return(0);
297: }

slepc-3.7.4/src/eps/examples/tutorials/ex1f90.F900000644000175000017500000001445713107004621020714 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./ex1f90 [-help] [-n ] [all SLEPc options] ! ! Description: Simple example that solves an eigensystem with the EPS object. ! The standard symmetric eigenvalue problem to be solved corresponds to the ! Laplacian operator in 1 dimension. ! ! The command line options are: ! -n , where = number of grid points = matrix size ! ! ---------------------------------------------------------------------- ! program main #include use slepceps implicit none ! For usage without modules, uncomment the following lines and remove ! the previous lines between 'program main' and 'implicit none' ! !#include !#include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! A operator matrix ! eps eigenproblem solver context #if defined(PETSC_USE_FORTRAN_DATATYPES) type(Mat) A type(EPS) eps #else Mat A EPS eps #endif EPSType tname PetscInt n, i, Istart, Iend, one, two, three PetscInt nev PetscInt row(1), col(3) PetscMPIInt rank PetscErrorCode ierr PetscBool flg, terse PetscScalar value(3) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - one = 1 two = 2 three = 3 call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 30 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-n',n,flg,ierr) if (rank .eq. 0) then write(*,100) n endif 100 format (/'1-D Laplacian Eigenproblem, n =',I4,' (Fortran)') ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Compute the operator matrix that defines the eigensystem, Ax=kx ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call MatCreate(PETSC_COMM_WORLD,A,ierr) call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A,ierr) call MatSetUp(A,ierr) call MatGetOwnershipRange(A,Istart,Iend,ierr) if (Istart .eq. 0) then row(1) = 0 col(1) = 0 col(2) = 1 value(1) = 2.0 value(2) = -1.0 call MatSetValues(A,one,row,two,col,value,INSERT_VALUES,ierr) Istart = Istart+1 endif if (Iend .eq. n) then row(1) = n-1 col(1) = n-2 col(2) = n-1 value(1) = -1.0 value(2) = 2.0 call MatSetValues(A,one,row,two,col,value,INSERT_VALUES,ierr) Iend = Iend-1 endif value(1) = -1.0 value(2) = 2.0 value(3) = -1.0 do i=Istart,Iend-1 row(1) = i col(1) = i-1 col(2) = i col(3) = i+1 call MatSetValues(A,one,row,three,col,value,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create the eigensolver and display info ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Create eigensolver context call EPSCreate(PETSC_COMM_WORLD,eps,ierr) ! ** Set operators. In this case, it is a standard eigenvalue problem call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr) call EPSSetProblemType(eps,EPS_HEP,ierr) ! ** Set solver parameters at runtime call EPSSetFromOptions(eps,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the eigensystem ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSSolve(eps,ierr) ! ** Optional: Get some information from the solver and display it call EPSGetType(eps,tname,ierr) if (rank .eq. 0) then write(*,120) tname endif 120 format (' Solution method: ',A) call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER, & & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,130) nev endif 130 format (' Number of requested eigenvalues:',I4) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** show detailed info unless -terse option is given by user call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-terse',terse,ierr) if (terse) then call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr) else call PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD, & & PETSC_VIEWER_ASCII_INFO_DETAIL,ierr) call EPSReasonView(eps,PETSC_VIEWER_STDOUT_WORLD,ierr) call EPSErrorView(eps,EPS_ERROR_RELATIVE, & & PETSC_VIEWER_STDOUT_WORLD,ierr) call PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD,ierr) endif call EPSDestroy(eps,ierr) call MatDestroy(A,ierr) call SlepcFinalize(ierr) end slepc-3.7.4/src/eps/examples/tutorials/ex18.c.html0000644000175000017500000004507013107004621021307 0ustar jromanjroman
Actual source code: ex18.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion."
 23:   "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n"
 24:   "This example illustrates how the user can set a custom spectrum selection.\n\n"
 25:   "The command line options are:\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in each dimension.\n\n";

 28: #include <slepceps.h>

 30: /*
 31:    User-defined routines
 32: */

 34: PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx);
 35: PetscErrorCode MatMarkovModel(PetscInt m,Mat A);

 39: int main(int argc,char **argv)
 40: {
 41:   Mat            A;               /* operator matrix */
 42:   EPS            eps;             /* eigenproblem solver context */
 43:   EPSType        type;
 44:   PetscScalar    target=0.5;
 45:   PetscInt       N,m=15,nev;
 46:   PetscBool      terse;
 47:   PetscViewer    viewer;
 49:   char           str[50];

 51:   SlepcInitialize(&argc,&argv,(char*)0,help);

 53:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 54:   N = m*(m+1)/2;
 55:   PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n",N,m);
 56:   PetscOptionsGetScalar(NULL,NULL,"-target",&target,NULL);
 57:   SlepcSNPrintfScalar(str,50,target,PETSC_FALSE);
 58:   PetscPrintf(PETSC_COMM_WORLD,"Searching closest eigenvalues to the right of %s.\n\n",str);

 60:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 61:      Compute the operator matrix that defines the eigensystem, Ax=kx
 62:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 64:   MatCreate(PETSC_COMM_WORLD,&A);
 65:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 66:   MatSetFromOptions(A);
 67:   MatSetUp(A);
 68:   MatMarkovModel(m,A);

 70:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 71:                 Create the eigensolver and set various options
 72:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 74:   /*
 75:      Create eigensolver context
 76:   */
 77:   EPSCreate(PETSC_COMM_WORLD,&eps);

 79:   /*
 80:      Set operators. In this case, it is a standard eigenvalue problem
 81:   */
 82:   EPSSetOperators(eps,A,NULL);
 83:   EPSSetProblemType(eps,EPS_NHEP);

 85:   /*
 86:      Set the custom comparing routine in order to obtain the eigenvalues
 87:      closest to the target on the right only
 88:   */
 89:   EPSSetEigenvalueComparison(eps,MyEigenSort,&target);

 91:   /*
 92:      Set solver parameters at runtime
 93:   */
 94:   EPSSetFromOptions(eps);

 96:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 97:                       Solve the eigensystem
 98:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

100:   EPSSolve(eps);

102:   /*
103:      Optional: Get some information from the solver and display it
104:   */
105:   EPSGetType(eps,&type);
106:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
107:   EPSGetDimensions(eps,&nev,NULL,NULL);
108:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

110:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111:                     Display solution and clean up
112:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

114:   /* show detailed info unless -terse option is given by user */
115:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
116:   if (terse) {
117:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
118:   } else {
119:     PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
120:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
121:     EPSReasonView(eps,viewer);
122:     EPSErrorView(eps,EPS_ERROR_RELATIVE,viewer);
123:     PetscViewerPopFormat(viewer);
124:   }
125:   EPSDestroy(&eps);
126:   MatDestroy(&A);
127:   SlepcFinalize();
128:   return ierr;
129: }

133: /*
134:     Matrix generator for a Markov model of a random walk on a triangular grid.

136:     This subroutine generates a test matrix that models a random walk on a
137:     triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a
138:     FORTRAN subroutine to calculate the dominant invariant subspaces of a real
139:     matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few
140:     papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295
141:     (1980) ]. These matrices provide reasonably easy test problems for eigenvalue
142:     algorithms. The transpose of the matrix  is stochastic and so it is known
143:     that one is an exact eigenvalue. One seeks the eigenvector of the transpose
144:     associated with the eigenvalue unity. The problem is to calculate the steady
145:     state probability distribution of the system, which is the eigevector
146:     associated with the eigenvalue one and scaled in such a way that the sum all
147:     the components is equal to one.

149:     Note: the code will actually compute the transpose of the stochastic matrix
150:     that contains the transition probabilities.
151: */
152: PetscErrorCode MatMarkovModel(PetscInt m,Mat A)
153: {
154:   const PetscReal cst = 0.5/(PetscReal)(m-1);
155:   PetscReal       pd,pu;
156:   PetscInt        Istart,Iend,i,j,jmax,ix=0;
157:   PetscErrorCode  ierr;

160:   MatGetOwnershipRange(A,&Istart,&Iend);
161:   for (i=1;i<=m;i++) {
162:     jmax = m-i+1;
163:     for (j=1;j<=jmax;j++) {
164:       ix = ix + 1;
165:       if (ix-1<Istart || ix>Iend) continue;  /* compute only owned rows */
166:       if (j!=jmax) {
167:         pd = cst*(PetscReal)(i+j-1);
168:         /* north */
169:         if (i==1) {
170:           MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);
171:         } else {
172:           MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);
173:         }
174:         /* east */
175:         if (j==1) {
176:           MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);
177:         } else {
178:           MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);
179:         }
180:       }
181:       /* south */
182:       pu = 0.5 - cst*(PetscReal)(i+j-3);
183:       if (j>1) {
184:         MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);
185:       }
186:       /* west */
187:       if (i>1) {
188:         MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);
189:       }
190:     }
191:   }
192:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
193:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
194:   return(0);
195: }

199: /*
200:     Function for user-defined eigenvalue ordering criterion.

202:     Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose
203:     one of them as the preferred one according to the criterion.
204:     In this example, the preferred value is the one closest to the target,
205:     but on the right side.
206: */
207: PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)
208: {
209:   PetscScalar target = *(PetscScalar*)ctx;
210:   PetscReal   da,db;
211:   PetscBool   aisright,bisright;

214:   if (PetscRealPart(target) < PetscRealPart(ar)) aisright = PETSC_TRUE;
215:   else aisright = PETSC_FALSE;
216:   if (PetscRealPart(target) < PetscRealPart(br)) bisright = PETSC_TRUE;
217:   else bisright = PETSC_FALSE;
218:   if (aisright == bisright) {
219:     /* both are on the same side of the target */
220:     da = SlepcAbsEigenvalue(ar-target,ai);
221:     db = SlepcAbsEigenvalue(br-target,bi);
222:     if (da < db) *r = -1;
223:     else if (da > db) *r = 1;
224:     else *r = 0;
225:   } else if (aisright && !bisright) *r = -1; /* 'a' is on the right */
226:   else *r = 1;  /* 'b' is on the right */
227:   return(0);
228: }
slepc-3.7.4/src/eps/examples/index.html0000644000175000017500000000126213107004621017355 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
tutorials/
makefile
slepc-3.7.4/src/eps/examples/tests/0000755000175000017500000000000013107004621016521 5ustar jromanjromanslepc-3.7.4/src/eps/examples/tests/makefile0000644000175000017500000003200713107004621020223 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/eps/examples/tests/ EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c \ test8.c test9.c test10.c test11.c test12.c test13.c \ test14.c test16.c EXAMPLESF = test7f.F test14f.F test15f.F MANSEC = EPS TESTS = test1 test2 test3 test4 test5 test6 test7f test8 test9 test10 \ test11 test12 test13 test14 test14f test15f test16 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \ test2.PETSc runtest2_1 test2.rm \ test3.PETSc runtest3_1 test3.rm \ test4.PETSc runtest4_1 test4.rm \ test6.PETSc runtest6_1 test6.rm \ test8.PETSc runtest8_1 test8.rm \ test9.PETSc runtest9_1 test9.rm \ test10.PETSc runtest10_1 test10.rm \ test11.PETSc runtest11_1 test11.rm \ test12.PETSc runtest12_1 test12.rm \ test13.PETSc runtest13_1 runtest13_2 test13.rm \ test14.PETSc runtest14_1 test14.rm \ test16.PETSc runtest16_1 test16.rm TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_2 test1.rm TESTEXAMPLES_C_NOF128 = test5.PETSc runtest5_1 test5.rm TESTEXAMPLES_FORTRAN = test7f.PETSc runtest7f_1 test7f.rm \ test14f.PETSc runtest14f_1 test14f.rm TESTEXAMPLES_BLOPEX = test5.PETSc runtest5_blopex test5.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_EPS_LIB} ${RM} test1.o test2: test2.o chkopts -${CLINKER} -o test2 test2.o ${SLEPC_EPS_LIB} ${RM} test2.o test3: test3.o chkopts -${CLINKER} -o test3 test3.o ${SLEPC_EPS_LIB} ${RM} test3.o test4: test4.o chkopts -${CLINKER} -o test4 test4.o ${SLEPC_EPS_LIB} ${RM} test4.o test5: test5.o chkopts -${CLINKER} -o test5 test5.o ${SLEPC_EPS_LIB} ${RM} test5.o test6: test6.o chkopts -${CLINKER} -o test6 test6.o ${SLEPC_EPS_LIB} ${RM} test6.o test7f: test7f.o chkopts -${FLINKER} -o test7f test7f.o ${SLEPC_EPS_LIB} ${RM} test7f.o test8: test8.o chkopts -${CLINKER} -o test8 test8.o ${SLEPC_EPS_LIB} ${RM} test8.o test9: test9.o chkopts -${CLINKER} -o test9 test9.o ${SLEPC_EPS_LIB} ${RM} test9.o test10: test10.o chkopts -${CLINKER} -o test10 test10.o ${SLEPC_EPS_LIB} ${RM} test10.o test11: test11.o chkopts -${CLINKER} -o test11 test11.o ${SLEPC_EPS_LIB} ${RM} test11.o test12: test12.o chkopts -${CLINKER} -o test12 test12.o ${SLEPC_EPS_LIB} ${RM} test12.o test13: test13.o chkopts -${CLINKER} -o test13 test13.o ${SLEPC_EPS_LIB} ${RM} test13.o test14: test14.o chkopts -${CLINKER} -o test14 test14.o ${SLEPC_EPS_LIB} ${RM} test14.o test14f: test14f.o chkopts -${FLINKER} -o test14f test14f.o ${SLEPC_EPS_LIB} ${RM} test14f.o test15f: test15f.o chkopts -${FLINKER} -o test15f test15f.o ${SLEPC_EPS_LIB} ${RM} test15f.o test16: test16.o chkopts -${CLINKER} -o test16 test16.o ${SLEPC_EPS_LIB} ${RM} test16.o #------------------------------------------------------------------------------------ EPSALL = krylovschur arnoldi lanczos gd jd gd2 EPSNS = krylovschur arnoldi gd jd gd2 EPSAR = gd jd gd2 TESTCODE = \ [ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \ ${DIFF} output/$${test}.out $${test}.tmp || \ echo "Possible problem with $${test}, diffs above"; \ ${RM} -f $${test}.tmp runtest1_1: -@test=test1_1; \ for eps in ${EPSALL}; do \ echo "eps type $$eps"; \ if [ "$$eps" = lanczos ]; then EXTRA="-eps_lanczos_reorthog full"; else EXTRA=""; fi; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test1 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest1_2: -@test=test1_2; \ ${MPIEXEC} -n 1 ./test1 -eps_interval .1,1.1 -eps_tol 1e-10 -st_type sinvert -st_ksp_type preonly -st_pc_type cholesky 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_1: -@test=test2_1; \ for eps in ${EPSALL}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test2 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest3_1: -@test=test3_1; \ for eps in ${EPSALL}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test3 -eps_type $$eps -eps_nev 4 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest4_1: -@test=test4_1; \ for eps in ${EPSALL}; do \ echo "eps type $$eps"; \ ${MPIEXEC} -n 1 ./test4 -type $$eps 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest5_1: -@test=test5_1; \ for eps in ${EPSNS}; do \ echo "eps type $$eps" >> test5_1.tmp; \ if [ "$$eps" = gd ]; then EXTRA="-eps_gd_minv 2"; \ elif [ "$$eps" = jd ]; then EXTRA="-eps_jd_minv 2"; \ elif [ "$$eps" = "gd2" ]; then eps=gd; EXTRA="-eps_gd_double_expansion"; else EXTRA=""; fi; \ ${MPIEXEC} -n 1 ./test5 -eps_type $$eps -eps_nev 4 $$EXTRA >> test5_1.tmp 2>&1; \ done; \ if (${GREP} USE_COMPLEX ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ [ x${SAVE_OUTPUT} = xyes ] && cp test5_1.tmp output/test5_1_complex.out; \ if (${DIFF} output/test5_1_complex.out test5_1.tmp) then true; \ else echo "Possible problem with test5_1, diffs above"; fi; \ else \ [ x${SAVE_OUTPUT} = xyes ] && cp test5_1.tmp output/test5_1.out; \ if (${DIFF} output/test5_1.out test5_1.tmp) then true; \ else echo "Possible problem with test5_1, diffs above"; fi; \ fi; \ ${RM} -f test5_1.tmp; runtest5_blopex: -@${MPIEXEC} -n 1 ./test5 -symm -eps_type blopex -eps_nev 4 > test5_blopex.tmp 2>&1; \ if (${DIFF} output/test5_blopex.out test5_blopex.tmp) then true; \ else echo "Possible problem with test5_blopex, diffs above"; fi; \ ${RM} -f test5_blopex.tmp; testtest5_blopex: test5.PETSc @ok=0; if [ "${PETSC_WITH_BATCH}" != "" -o "${MPIEXEC}" = "/bin/false" ]; then \ echo "Skipping BLOPEX test"; \ elif [ -f test5 ]; then \ ${MPIEXEC} -n 1 ./test5 -symm -eps_type blopex -eps_nev 4 > test5_blopex.tmp 2>&1; \ if [ "${PETSC_SCALAR}" = "complex" ]; then REFFILE=_complex; fi; \ if (${DIFF} output/test5_blopex$$REFFILE.out test5_blopex.tmp > /dev/null 2>&1) then \ echo "BLOPEX example src/eps/examples/tests/test5 run successfully with 1 MPI process"; \ else echo "Possible error running BLOPEX src/eps/examples/tests/test5 with 1 MPI process"; \ cat test5_blopex.tmp; ok=1; fi; \ ${RM} -f test5_blopex.tmp; \ ${MAKE} SLEPC_ARCH=${SLEPC_ARCH} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test5.rm ; \ else ok=1; fi; \ exit $$ok runtest6_1: -@test=test6_1; \ for eps in ${EPSNS}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test6 -eps_type $$eps -eps_nev 4 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest7f_1: -@test=test7f_1; \ ${MPIEXEC} -n 1 ./test7f -eps_nev 4 > $${test}.tmp 2>&1; \ ${TESTCODE} testtest7f: test7f.PETSc @ok=0; if [ "${PETSC_WITH_BATCH}" != "" ]; then \ echo "Running with batch filesystem; to test run src/eps/examples/tests/test7f " ; \ echo "with your systems batch system"; \ elif [ "${MPIEXEC}" = "/bin/false" ]; then \ echo "*mpiexec not found*. Please run src/eps/examples/tests/test7f manually"; \ elif [ -f test7f ]; then \ GFORTRAN_UNBUFFERED_ALL=1 ${MPIEXEC} -n 1 ./test7f -eps_nev 4 > test7f_1.tmp 2>&1; \ if (${DIFF} output/test7f_1.out test7f_1.tmp > /dev/null 2>&1) then \ echo "Fortran example src/eps/examples/tests/test7f run successfully with 1 MPI process"; \ else echo "Possible error running Fortran src/eps/examples/tests/test7f with 1 MPI process"; \ cat test7f_1.tmp; ok=1; fi; \ ${RM} -f test7f_1.tmp; \ ${MAKE} SLEPC_ARCH=${SLEPC_ARCH} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test7f.rm ; \ else ok=1; fi; \ exit $$ok runtest8_1: -@test=test8_1; \ for eps in ${EPSALL}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test8 -eps_type $$eps -eps_nev 4 -eps_ncv 24 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest9_1: -@test=test9_1; \ for eps in ${EPSNS}; do \ echo "eps type $$eps"; \ if [ "$$eps" = "krylovschur" -o "$$eps" = "arnoldi" ]; then EXTRA="-eps_ncv 7 -eps_max_it 300"; \ elif [ "$$eps" = jd ]; then EXTRA="-st_ksp_type cg"; \ else EXTRA=""; fi; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test9 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1; \ done > $${test}.tmp;\ ${TESTCODE} runtest10_1: -@test=test10_1; \ for eps in ${EPSALL}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test10 -eps_type $$eps -eps_nev 4 -m 11 2>&1; \ done > $${test}.tmp;\ ${TESTCODE} testtest10: test10.PETSc @ok=0; if [ "${PETSC_WITH_BATCH}" != "" ]; then \ echo "Running with batch filesystem; to test run src/eps/examples/tests/test10" ; \ echo "with your systems batch system"; \ elif [ "${MPIEXEC}" = "/bin/false" ]; then \ echo "*mpiexec not found*. Please run src/eps/examples/tests/test10 manually"; \ elif [ -f test10 ]; then \ ${MPIEXEC} -n 1 ./test10 -eps_nev 4 -eps_ncv 14 -m 11 -eps_largest_magnitude > test10_1.tmp 2>&1; \ if (${DIFF} output/test10_1_ks.out test10_1.tmp > /dev/null 2>&1) then \ echo "C/C++ example src/eps/examples/tests/test10 run successfully with 1 MPI process"; \ else echo "Possible error running C/C++ src/eps/examples/tests/test10 with 1 MPI process"; \ cat test10_1.tmp; ok=1; fi; \ if [ "${MPIEXEC}" != "${PETSC_DIR}/bin/petsc-mpiexec.uni" ]; then \ ${MPIEXEC} -n 2 ./test10 -eps_nev 4 -eps_ncv 14 -m 11 -eps_largest_magnitude > test10_1.tmp 2>&1; \ if (${DIFF} output/test10_1_ks.out test10_1.tmp > /dev/null 2>&1) then \ echo "C/C++ example src/eps/examples/tests/test10 run successfully with 2 MPI process"; \ else echo "Possible error running C/C++ src/eps/examples/tests/test10 with 2 MPI process"; \ cat test10_1.tmp; ok=1; fi; fi; \ ${RM} -f test10_1.tmp; \ ${MAKE} SLEPC_ARCH=${SLEPC_ARCH} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test10.rm; \ else ok=1; fi; \ exit $$ok runtest11_1: -@test=test11_1; \ for eps in krylovschur arnoldi gd jd; do \ echo "eps type $$eps"; \ if [ "$$eps" = krylovschur -o "$$eps" = arnoldi ]; then EXTRA="-st_type sinvert"; \ elif [ "$$eps" = gd ]; then EXTRA="-eps_max_it 5000"; \ fi; \ ${MPIEXEC} -n 1 ./test11 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1; \ done > $${test}.tmp;\ ${TESTCODE} runtest12_1: -@test=test12_1; \ for eps in ${EPSNS}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test12 -eps_type $$eps -eps_nev 4 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest13_1: -@test=test13_1; \ for eps in ${EPSAR}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test13 -eps_type $$eps -eps_max_it 5000 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest13_2: -@test=test13_1; \ for eps in ${EPSAR}; do \ echo "eps type $$eps"; \ if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \ ${MPIEXEC} -n 1 ./test13 -eps_type $$eps -eps_non_hermitian -eps_max_it 5000 2>&1; \ done > $${test}.tmp; \ ${TESTCODE} runtest14_1: -@test=test14_1; \ ${MPIEXEC} -n 1 ./test14 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest14f_1: -@test=test14f_1; \ ${MPIEXEC} -n 1 ./test14f 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest15f_1: -@test=test15f_1; \ ${MPIEXEC} -n 1 ./test15f -my_eps_monitor > $${test}.tmp 2>&1; \ ${TESTCODE} runtest16_1: -@test=test16_1; \ ${MPIEXEC} -n 1 ./test16 -n 200 -eps_nev 6 -eps_ncv 24 -eps_smallest_magnitude 2>&1 > $${test}.tmp; \ ${TESTCODE} slepc-3.7.4/src/eps/examples/tests/test4.c.html0000644000175000017500000002454213107004621020702 0ustar jromanjroman

Actual source code: test4.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test the solution of a HEP without calling EPSSetFromOptions (based on ex1.c).\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions = matrix dimension.\n"
 25:   "  -type <eps_type> = eps type to test.\n\n";

 27: #include <slepceps.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A;           /* problem matrix */
 34:   EPS            eps;         /* eigenproblem solver context */
 35:   EPSType        type;
 36:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 37:   PetscInt       n=30,i,Istart,Iend,nev;
 38:   PetscBool      isgd2;
 39:   char           epstype[30] = "krylovschur";

 42:   SlepcInitialize(&argc,&argv,(char*)0,help);

 44:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 45:   PetscOptionsGetString(NULL,NULL,"-type",epstype,30,NULL);
 46:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem, n=%D",n);
 47:   PetscPrintf(PETSC_COMM_WORLD,"\nEPS type: %s\n\n",epstype);

 49:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 50:      Compute the operator matrix that defines the eigensystem, Ax=kx
 51:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 53:   MatCreate(PETSC_COMM_WORLD,&A);
 54:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 55:   MatSetFromOptions(A);
 56:   MatSetUp(A);

 58:   MatGetOwnershipRange(A,&Istart,&Iend);
 59:   for (i=Istart;i<Iend;i++) {
 60:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 61:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 62:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 63:   }
 64:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 65:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 67:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 68:                 Create the eigensolver and set various options
 69:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 70:   /*
 71:      Create eigensolver context
 72:   */
 73:   EPSCreate(PETSC_COMM_WORLD,&eps);

 75:   /*
 76:      Set operators. In this case, it is a standard eigenvalue problem
 77:   */
 78:   EPSSetOperators(eps,A,NULL);
 79:   EPSSetProblemType(eps,EPS_HEP);
 80:   EPSSetDimensions(eps,4,PETSC_DEFAULT,PETSC_DEFAULT);
 81:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);

 83:   /*
 84:      Set solver parameters at runtime
 85:   */
 86:   PetscStrcmp(epstype,"gd2",&isgd2);
 87:   if (isgd2) {
 88:     EPSSetType(eps,EPSGD);
 89:     EPSGDSetDoubleExpansion(eps,PETSC_TRUE);
 90:   } else {
 91:     EPSSetType(eps,epstype);
 92:   }

 94:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 95:                       Solve the eigensystem
 96:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 98:   EPSSolve(eps);
 99:   /*
100:      Optional: Get some information from the solver and display it
101:   */
102:   EPSGetType(eps,&type);
103:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
104:   EPSGetDimensions(eps,&nev,NULL,NULL);
105:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

107:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
108:                     Display solution and clean up
109:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

111:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
112:   EPSDestroy(&eps);
113:   MatDestroy(&A);
114:   SlepcFinalize();
115:   return ierr;
116: }
slepc-3.7.4/src/eps/examples/tests/test9.c.html0000644000175000017500000004207713107004621020712 0ustar jromanjroman
Actual source code: test9.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. "
 23:   "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n"
 24:   "This example illustrates how the user can set the initial vector.\n\n"
 25:   "The command line options are:\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in each dimension.\n\n";

 28: #include <slepceps.h>

 30: /*
 31:    User-defined routines
 32: */
 33: PetscErrorCode MatMarkovModel(PetscInt m,Mat A);
 34: PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx);

 38: int main(int argc,char **argv)
 39: {
 40:   Vec            v0;              /* initial vector */
 41:   Mat            A;               /* operator matrix */
 42:   EPS            eps;             /* eigenproblem solver context */
 43:   EPSType        type;
 44:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 45:   PetscInt       N,m=15,nev;
 46:   PetscScalar    origin=0.0;

 49:   SlepcInitialize(&argc,&argv,(char*)0,help);

 51:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 52:   N = m*(m+1)/2;
 53:   PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n\n",N,m);

 55:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 56:      Compute the operator matrix that defines the eigensystem, Ax=kx
 57:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 59:   MatCreate(PETSC_COMM_WORLD,&A);
 60:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 61:   MatSetFromOptions(A);
 62:   MatSetUp(A);
 63:   MatMarkovModel(m,A);

 65:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 66:                 Create the eigensolver and set various options
 67:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 69:   /*
 70:      Create eigensolver context
 71:   */
 72:   EPSCreate(PETSC_COMM_WORLD,&eps);

 74:   /*
 75:      Set operators. In this case, it is a standard eigenvalue problem
 76:   */
 77:   EPSSetOperators(eps,A,NULL);
 78:   EPSSetProblemType(eps,EPS_NHEP);
 79:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);

 81:   /*
 82:      Set the custom comparing routine in order to obtain the eigenvalues
 83:      closest to the target on the right only
 84:   */
 85:   EPSSetEigenvalueComparison(eps,MyEigenSort,&origin);


 88:   /*
 89:      Set solver parameters at runtime
 90:   */
 91:   EPSSetFromOptions(eps);

 93:   /*
 94:      Set the initial vector. This is optional, if not done the initial
 95:      vector is set to random values
 96:   */
 97:   MatCreateVecs(A,&v0,NULL);
 98:   VecSetValue(v0,0,-1.5,INSERT_VALUES);
 99:   VecSetValue(v0,1,2.1,INSERT_VALUES);
100:   VecAssemblyBegin(v0);
101:   VecAssemblyEnd(v0);
102:   EPSSetInitialSpace(eps,1,&v0);

104:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
105:                       Solve the eigensystem
106:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

108:   EPSSolve(eps);

110:   /*
111:      Optional: Get some information from the solver and display it
112:   */
113:   EPSGetType(eps,&type);
114:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
115:   EPSGetDimensions(eps,&nev,NULL,NULL);
116:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

118:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
119:                     Display solution and clean up
120:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

122:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
123:   EPSDestroy(&eps);
124:   MatDestroy(&A);
125:   VecDestroy(&v0);
126:   SlepcFinalize();
127:   return ierr;
128: }

132: /*
133:     Matrix generator for a Markov model of a random walk on a triangular grid.

135:     This subroutine generates a test matrix that models a random walk on a
136:     triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a
137:     FORTRAN subroutine to calculate the dominant invariant subspaces of a real
138:     matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few
139:     papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295
140:     (1980) ]. These matrices provide reasonably easy test problems for eigenvalue
141:     algorithms. The transpose of the matrix  is stochastic and so it is known
142:     that one is an exact eigenvalue. One seeks the eigenvector of the transpose
143:     associated with the eigenvalue unity. The problem is to calculate the steady
144:     state probability distribution of the system, which is the eigevector
145:     associated with the eigenvalue one and scaled in such a way that the sum all
146:     the components is equal to one.

148:     Note: the code will actually compute the transpose of the stochastic matrix
149:     that contains the transition probabilities.
150: */
151: PetscErrorCode MatMarkovModel(PetscInt m,Mat A)
152: {
153:   const PetscReal cst = 0.5/(PetscReal)(m-1);
154:   PetscReal       pd,pu;
155:   PetscInt        Istart,Iend,i,j,jmax,ix=0;
156:   PetscErrorCode  ierr;

159:   MatGetOwnershipRange(A,&Istart,&Iend);
160:   for (i=1;i<=m;i++) {
161:     jmax = m-i+1;
162:     for (j=1;j<=jmax;j++) {
163:       ix = ix + 1;
164:       if (ix-1<Istart || ix>Iend) continue;  /* compute only owned rows */
165:       if (j!=jmax) {
166:         pd = cst*(PetscReal)(i+j-1);
167:         /* north */
168:         if (i==1) {
169:           MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);
170:         } else {
171:           MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);
172:         }
173:         /* east */
174:         if (j==1) {
175:           MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);
176:         } else {
177:           MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);
178:         }
179:       }
180:       /* south */
181:       pu = 0.5 - cst*(PetscReal)(i+j-3);
182:       if (j>1) {
183:         MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);
184:       }
185:       /* west */
186:       if (i>1) {
187:         MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);
188:       }
189:     }
190:   }
191:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
192:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
193:   return(0);
194: }

198: /*
199:     Function for user-defined eigenvalue ordering criterion.

201:     Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose
202:     one of them as the preferred one according to the criterion.
203:     In this example, the preferred value is the one furthest to the origin.
204: */
205: PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)
206: {
207:   PetscScalar origin = *(PetscScalar*)ctx;
208:   PetscReal   d;

211:   d = (SlepcAbsEigenvalue(br-origin,bi) - SlepcAbsEigenvalue(ar-origin,ai))/PetscMax(SlepcAbsEigenvalue(ar-origin,ai),SlepcAbsEigenvalue(br-origin,bi));
212:   *r = d > PETSC_SQRT_MACHINE_EPSILON ? 1 : (d < -PETSC_SQRT_MACHINE_EPSILON ? -1 : PetscSign(PetscRealPart(br)));
213:   return(0);
214: }
slepc-3.7.4/src/eps/examples/tests/test16.c0000644000175000017500000000716613107004621020025 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Tests a user-defined convergence test.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "MyConvergedAbsolute" /* MyConvergedAbsolute - Bizarre convergence test that requires more accuracy to positive eigenvalues compared to negative ones. */ PetscErrorCode MyConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscFunctionBegin; *errest = (PetscRealPart(eigr)<0.0)?res:100*res; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ EPS eps; /* eigenproblem solver context */ PetscInt n=30,i,Istart,Iend; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nTridiagonal Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test the solution of a HEP without calling EPSSetFromOptions (based on ex1.c).\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions = matrix dimension.\n" " -type = eps type to test.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscInt n=30,i,Istart,Iend,nev; PetscBool isgd2; char epstype[30] = "krylovschur"; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-type",epstype,30,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem, n=%D",n);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nEPS type: %s\n\n",epstype);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: test1.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Tests B-orthonormality of eigenvectors in a GHEP problem.\n\n";

 24: #include <slepceps.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat            A,B;        /* matrices */
 31:   EPS            eps;        /* eigenproblem solver context */
 32:   Vec            *X,v;
 33:   PetscReal      lev,tol=1000*PETSC_MACHINE_EPSILON;
 34:   PetscInt       N,n=45,m,Istart,Iend,II,i,j,nconv;
 35:   PetscBool      flag;

 38:   SlepcInitialize(&argc,&argv,(char*)0,help);
 39:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 40:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 41:   if (!flag) m=n;
 42:   N = n*m;
 43:   PetscPrintf(PETSC_COMM_WORLD,"\nGeneralized Symmetric Eigenproblem, N=%D (%Dx%D grid)\n\n",N,n,m);

 45:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 46:      Compute the matrices that define the eigensystem, Ax=kBx
 47:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 49:   MatCreate(PETSC_COMM_WORLD,&A);
 50:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 51:   MatSetFromOptions(A);
 52:   MatSetUp(A);

 54:   MatCreate(PETSC_COMM_WORLD,&B);
 55:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);
 56:   MatSetFromOptions(B);
 57:   MatSetUp(B);

 59:   MatGetOwnershipRange(A,&Istart,&Iend);
 60:   for (II=Istart;II<Iend;II++) {
 61:     i = II/n; j = II-i*n;
 62:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); }
 63:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); }
 64:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); }
 65:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); }
 66:     MatSetValue(A,II,II,4.0,INSERT_VALUES);
 67:     MatSetValue(B,II,II,2.0/PetscLogScalar(II+2),INSERT_VALUES);
 68:   }

 70:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 71:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 72:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 73:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
 74:   MatCreateVecs(B,&v,NULL);

 76:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 77:                 Create the eigensolver and set various options
 78:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 80:   EPSCreate(PETSC_COMM_WORLD,&eps);
 81:   EPSSetOperators(eps,A,B);
 82:   EPSSetProblemType(eps,EPS_GHEP);
 83:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);
 84:   EPSSetFromOptions(eps);

 86:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 87:                       Solve the eigensystem
 88:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 90:   EPSSolve(eps);

 92:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 93:                     Display solution and clean up
 94:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 96:   EPSGetTolerances(eps,&tol,NULL);
 97:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
 98:   EPSGetConverged(eps,&nconv);
 99:   if (nconv>0) {
100:     VecDuplicateVecs(v,nconv,&X);
101:     for (i=0;i<nconv;i++) {
102:       EPSGetEigenvector(eps,i,X[i],NULL);
103:     }
104:     SlepcCheckOrthogonality(X,nconv,NULL,nconv,B,NULL,&lev);
105:     if (lev<10*tol) {
106:       PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality below the tolerance\n");
107:     } else {
108:       PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)lev);
109:     }
110:     VecDestroyVecs(nconv,&X);
111:   }

113:   EPSDestroy(&eps);
114:   MatDestroy(&A);
115:   MatDestroy(&B);
116:   VecDestroy(&v);
117:   SlepcFinalize();
118:   return ierr;
119: }

slepc-3.7.4/src/eps/examples/tests/test12.c.html0000644000175000017500000002143013107004621020752 0ustar jromanjroman
Actual source code: test12.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Diagonal eigenproblem. Illustrates use of shell preconditioner.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions = matrix dimension.\n"
 25:   "  -seed <s>, where <s> = seed for random number generation.\n\n";

 27: #include <slepceps.h>

 31: PetscErrorCode PCApply_User(PC pc,Vec x,Vec y)
 32: {

 36:   VecCopy(x,y);
 37:   return(0);
 38: }

 42: int main(int argc,char **argv)
 43: {
 44:   Mat            A;           /* problem matrix */
 45:   EPS            eps;         /* eigenproblem solver context */
 46:   Vec            v0;          /* initial vector */
 47:   PetscRandom    rand;
 48:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 49:   PetscInt       n=30,i,Istart,Iend,seed=0x12345678;
 51:   ST             st;
 52:   KSP            ksp;
 53:   PC             pc;

 55:   SlepcInitialize(&argc,&argv,(char*)0,help);

 57:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 58:   PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%D\n\n",n);

 60:   MatCreate(PETSC_COMM_WORLD,&A);
 61:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 62:   MatSetFromOptions(A);
 63:   MatSetUp(A);
 64:   MatGetOwnershipRange(A,&Istart,&Iend);
 65:   for (i=Istart;i<Iend;i++) {
 66:     MatSetValue(A,i,i,i+1,INSERT_VALUES);
 67:   }
 68:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 69:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 71:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 72:                       Solve the eigensystem
 73:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 74:   EPSCreate(PETSC_COMM_WORLD,&eps);
 75:   EPSSetOperators(eps,A,NULL);
 76:   EPSSetProblemType(eps,EPS_HEP);
 77:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);
 78:   EPSSetFromOptions(eps);
 79:   EPSGetST(eps,&st);
 80:   STGetKSP(st,&ksp);
 81:   KSPGetPC(ksp,&pc);
 82:   PCSetType(pc,PCSHELL);
 83:   PCShellSetApply(pc,PCApply_User);
 84:   STPrecondSetMatForPC(st,A);

 86:   /* set random initial vector */
 87:   MatCreateVecs(A,&v0,NULL);
 88:   PetscRandomCreate(PETSC_COMM_WORLD,&rand);
 89:   PetscRandomSetFromOptions(rand);
 90:   PetscOptionsGetInt(NULL,NULL,"-seed",&seed,NULL);
 91:   PetscRandomSetSeed(rand,seed);
 92:   PetscRandomSeed(rand);
 93:   VecSetRandom(v0,rand);
 94:   EPSSetInitialSpace(eps,1,&v0);
 95:   /* call the solver */
 96:   EPSSolve(eps);

 98:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 99:                     Display solution and clean up
100:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
101:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
102:   EPSDestroy(&eps);
103:   MatDestroy(&A);
104:   VecDestroy(&v0);
105:   PetscRandomDestroy(&rand);
106:   SlepcFinalize();
107:   return ierr;
108: }
slepc-3.7.4/src/eps/examples/tests/test7f.F0000644000175000017500000001260713107004621020052 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./test7f [-help] [-n ] [all SLEPc options] ! ! Description: Simple example that solves an eigensystem with the EPS object. ! Same problem as ex1f but with simplified output. ! ! The command line options are: ! -n , where = number of grid points = matrix size ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! A operator matrix ! eps eigenproblem solver context Mat A EPS eps EPSType tname PetscInt n, i, Istart, Iend PetscInt nev PetscInt col(3) PetscInt i1,i2,i3 PetscMPIInt rank PetscErrorCode ierr PetscBool flg PetscScalar value(3) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 30 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-n',n,flg,ierr) if (rank .eq. 0) then write(*,100) n endif 100 format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)') ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Compute the operator matrix that defines the eigensystem, Ax=kx ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call MatCreate(PETSC_COMM_WORLD,A,ierr) call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A,ierr) call MatSetUp(A,ierr) i1 = 1 i2 = 2 i3 = 3 call MatGetOwnershipRange(A,Istart,Iend,ierr) if (Istart .eq. 0) then i = 0 col(1) = 0 col(2) = 1 value(1) = 2.0 value(2) = -1.0 call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr) Istart = Istart+1 endif if (Iend .eq. n) then i = n-1 col(1) = n-2 col(2) = n-1 value(1) = -1.0 value(2) = 2.0 call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr) Iend = Iend-1 endif value(1) = -1.0 value(2) = 2.0 value(3) = -1.0 do i=Istart,Iend-1 col(1) = i-1 col(2) = i col(3) = i+1 call MatSetValues(A,i1,i,i3,col,value,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create the eigensolver and display info ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Create eigensolver context call EPSCreate(PETSC_COMM_WORLD,eps,ierr) ! ** Set operators. In this case, it is a standard eigenvalue problem call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr) call EPSSetProblemType(eps,EPS_HEP,ierr) ! ** Set solver parameters at runtime call EPSSetFromOptions(eps,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the eigensystem ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSSolve(eps,ierr) ! ** Optional: Get some information from the solver and display it call EPSGetType(eps,tname,ierr) if (rank .eq. 0) then write(*,120) tname endif 120 format (' Solution method: ',A) call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER, & & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,130) nev endif 130 format (' Number of requested eigenvalues:',I2) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr) call EPSDestroy(eps,ierr) call MatDestroy(A,ierr) call SlepcFinalize(ierr) end slepc-3.7.4/src/eps/examples/tests/test13.c0000644000175000017500000001106413107004621020012 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test EPSSetArbitrarySelection.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "MyArbitrarySelection" PetscErrorCode MyArbitrarySelection(PetscScalar eigr,PetscScalar eigi,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx) { PetscErrorCode ierr; Vec xref = *(Vec*)ctx; PetscFunctionBeginUser; ierr = VecDot(xr,xref,rr);CHKERRQ(ierr); *rr = PetscAbsScalar(*rr); if (ri) *ri = 0.0; PetscFunctionReturn(0); } #undef __funct__ #define __funct__ "main" int main(int argc,char **argv) { Mat A; /* problem matrices */ EPS eps; /* eigenproblem solver context */ PetscScalar seigr,seigi; PetscReal tol=1000*PETSC_MACHINE_EPSILON; Vec sxr,sxi; PetscInt n=30,i,Istart,Iend,nconv; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nTridiagonal with zero diagonal, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create matrix tridiag([-1 0 -1]) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = EPSGetEigenpair(eps,0,&seigr,&seigi,sxr,sxi);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve eigenproblem using an arbitrary selection - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSetArbitrarySelection(eps,MyArbitrarySelection,&sxr);CHKERRQ(ierr); ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_MAGNITUDE);CHKERRQ(ierr); ierr = EPSSolve(eps);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD,"Problem: no eigenpairs converged.\n");CHKERRQ(ierr); } ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = VecDestroy(&sxr);CHKERRQ(ierr); ierr = VecDestroy(&sxi);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/eps/examples/tests/test10.c.html0000644000175000017500000002645213107004621020761 0ustar jromanjroman
Actual source code: test10.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\n\n"
 23:   "This example illustrates EPSSetDeflationSpace(). The example graph corresponds to a "
 24:   "2-D regular mesh. The command line options are:\n"
 25:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n\n";

 28: #include <slepceps.h>

 32: int main (int argc,char **argv)
 33: {
 34:   EPS            eps;             /* eigenproblem solver context */
 35:   Mat            A;               /* operator matrix */
 36:   Vec            x;
 37:   EPSType        type;
 38:   PetscInt       N,n=10,m,i,j,II,Istart,Iend,nev;
 39:   PetscScalar    w;
 40:   PetscBool      flag;

 43:   SlepcInitialize(&argc,&argv,(char*)0,help);

 45:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 46:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 47:   if (!flag) m=n;
 48:   N = n*m;
 49:   PetscPrintf(PETSC_COMM_WORLD,"\nFiedler vector of a 2-D regular mesh, N=%D (%Dx%D grid)\n\n",N,n,m);

 51:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 52:      Compute the operator matrix that defines the eigensystem, Ax=kx
 53:      In this example, A = L(G), where L is the Laplacian of graph G, i.e.
 54:      Lii = degree of node i, Lij = -1 if edge (i,j) exists in G
 55:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 57:   MatCreate(PETSC_COMM_WORLD,&A);
 58:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 59:   MatSetFromOptions(A);
 60:   MatSetUp(A);

 62:   MatGetOwnershipRange(A,&Istart,&Iend);
 63:   for (II=Istart;II<Iend;II++) {
 64:     i = II/n; j = II-i*n;
 65:     w = 0.0;
 66:     if (i>0) { MatSetValue(A,II,II-n,-1.0,INSERT_VALUES); w=w+1.0; }
 67:     if (i<m-1) { MatSetValue(A,II,II+n,-1.0,INSERT_VALUES); w=w+1.0; }
 68:     if (j>0) { MatSetValue(A,II,II-1,-1.0,INSERT_VALUES); w=w+1.0; }
 69:     if (j<n-1) { MatSetValue(A,II,II+1,-1.0,INSERT_VALUES); w=w+1.0; }
 70:     MatSetValue(A,II,II,w,INSERT_VALUES);
 71:   }

 73:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 74:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 76:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 77:                 Create the eigensolver and set various options
 78:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 80:   /*
 81:      Create eigensolver context
 82:   */
 83:   EPSCreate(PETSC_COMM_WORLD,&eps);

 85:   /*
 86:      Set operators. In this case, it is a standard eigenvalue problem
 87:   */
 88:   EPSSetOperators(eps,A,NULL);
 89:   EPSSetProblemType(eps,EPS_HEP);

 91:   /*
 92:      Select portion of spectrum
 93:   */
 94:   EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);

 96:   /*
 97:      Set solver parameters at runtime
 98:   */
 99:   EPSSetFromOptions(eps);

101:   /*
102:      Attach deflation space: in this case, the matrix has a constant
103:      nullspace, [1 1 ... 1]^T is the eigenvector of the zero eigenvalue
104:   */
105:   MatCreateVecs(A,&x,NULL);
106:   VecSet(x,1.0);
107:   EPSSetDeflationSpace(eps,1,&x);
108:   VecDestroy(&x);

110:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111:                       Solve the eigensystem
112:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

114:   EPSSolve(eps);

116:   /*
117:      Optional: Get some information from the solver and display it
118:   */
119:   EPSGetType(eps,&type);
120:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
121:   EPSGetDimensions(eps,&nev,NULL,NULL);
122:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

124:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
125:                     Display solution and clean up
126:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

128:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
129:   EPSDestroy(&eps);
130:   MatDestroy(&A);
131:   SlepcFinalize();
132:   return ierr;
133: }

slepc-3.7.4/src/eps/examples/tests/test15f.F0000644000175000017500000001626713107004621020137 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./test15f [-help] [-n ] [all SLEPc options] ! ! Description: Tests custom monitors from Fortran. ! ! The command line options are: ! -n , where = number of grid points = matrix size ! -my_eps_monitor, activates the custom monitor ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! A operator matrix ! eps eigenproblem solver context Mat A EPS eps EPSType tname PetscInt n, i, Istart, Iend PetscInt nev PetscInt col(3) PetscInt i1,i2,i3 PetscMPIInt rank PetscErrorCode ierr PetscBool flg PetscScalar value(3) ! Note: Any user-defined Fortran routines (such as MyEPSMonitor) ! MUST be declared as external. external MyEPSMonitor ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 30 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-n',n,flg,ierr) if (rank .eq. 0) then write(*,100) n endif 100 format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)') ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Compute the operator matrix that defines the eigensystem, Ax=kx ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call MatCreate(PETSC_COMM_WORLD,A,ierr) call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A,ierr) call MatSetUp(A,ierr) i1 = 1 i2 = 2 i3 = 3 call MatGetOwnershipRange(A,Istart,Iend,ierr) if (Istart .eq. 0) then i = 0 col(1) = 0 col(2) = 1 value(1) = 2.0 value(2) = -1.0 call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr) Istart = Istart+1 endif if (Iend .eq. n) then i = n-1 col(1) = n-2 col(2) = n-1 value(1) = -1.0 value(2) = 2.0 call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr) Iend = Iend-1 endif value(1) = -1.0 value(2) = 2.0 value(3) = -1.0 do i=Istart,Iend-1 col(1) = i-1 col(2) = i col(3) = i+1 call MatSetValues(A,i1,i,i3,col,value,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create the eigensolver and display info ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Create eigensolver context call EPSCreate(PETSC_COMM_WORLD,eps,ierr) ! ** Set operators. In this case, it is a standard eigenvalue problem call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr) call EPSSetProblemType(eps,EPS_HEP,ierr) ! ** Set user-defined monitor call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-my_eps_monitor',flg,ierr) if (flg) then call EPSMonitorSet(eps,MyEPSMonitor,PETSC_NULL_OBJECT, & & PETSC_NULL_FUNCTION,ierr) endif ! ** Set solver parameters at runtime call EPSSetFromOptions(eps,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the eigensystem ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSSolve(eps,ierr) ! ** Optional: Get some information from the solver and display it call EPSGetType(eps,tname,ierr) if (rank .eq. 0) then write(*,120) tname endif 120 format (' Solution method: ',A) call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER, & & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,130) nev endif 130 format (' Number of requested eigenvalues:',I2) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr) call EPSDestroy(eps,ierr) call MatDestroy(A,ierr) call SlepcFinalize(ierr) end ! -------------------------------------------------------------- ! ! MyEPSMonitor - This is a user-defined routine for monitoring ! the EPS iterative solvers. ! ! Input Parameters: ! eps - eigensolver context ! its - iteration number ! nconv - number of converged eigenpairs ! eigr - real part of the eigenvalues ! eigi - imaginary part of the eigenvalues ! errest- relative error estimates for each eigenpair ! nest - number of error estimates ! dummy - optional user-defined monitor context (unused here) ! subroutine MyEPSMonitor(eps,its,nconv,eigr,eigi,errest,nest,dummy,& & ierr) implicit none #include #include #include #include #include EPS eps Vec x PetscErrorCode ierr PetscInt its,nconv,nest,dummy PetscScalar eigr(*),eigi(*) PetscReal re,errest(*) PetscMPIInt rank call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) if (its .gt. 0 .and. rank .eq. 0) then re = PetscRealPart(eigr(nconv+1)) write(6,140) its,nconv,re,errest(nconv+1) endif 140 format(i3,' EPS nconv=',i2,' first unconverged value (error) ', & & f6.4,' (',g9.3,')') ierr = 0 end slepc-3.7.4/src/eps/examples/tests/makefile.html0000644000175000017500000005166213107004621021176 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/eps/examples/tests/
EXAMPLESC  = test1.c test2.c test3.c test4.c test5.c test6.c \
             test8.c test9.c test10.c test11.c test12.c test13.c \
             test14.c test16.c
EXAMPLESF  = test7f.F test14f.F test15f.F
MANSEC     = EPS
TESTS      = test1 test2 test3 test4 test5 test6 test7f test8 test9 test10 \
             test11 test12 test13 test14 test14f test15f test16

TESTEXAMPLES_C           = test1.PETSc runtest1_1 test1.rm \
                           test2.PETSc runtest2_1 test2.rm \
                           test3.PETSc runtest3_1 test3.rm \
                           test4.PETSc runtest4_1 test4.rm \
                           test6.PETSc runtest6_1 test6.rm \
                           test8.PETSc runtest8_1 test8.rm \
                           test9.PETSc runtest9_1 test9.rm \
                           test10.PETSc runtest10_1 test10.rm \
                           test11.PETSc runtest11_1 test11.rm \
                           test12.PETSc runtest12_1 test12.rm \
                           test13.PETSc runtest13_1 runtest13_2 test13.rm \
                           test14.PETSc runtest14_1 test14.rm \
                           test16.PETSc runtest16_1 test16.rm
TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_2 test1.rm
TESTEXAMPLES_C_NOF128    = test5.PETSc runtest5_1 test5.rm
TESTEXAMPLES_FORTRAN     = test7f.PETSc runtest7f_1 test7f.rm \
                           test14f.PETSc runtest14f_1 test14f.rm
TESTEXAMPLES_BLOPEX      = test5.PETSc runtest5_blopex test5.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_EPS_LIB}
	${RM} test1.o

test2: test2.o chkopts
	-${CLINKER} -o test2 test2.o ${SLEPC_EPS_LIB}
	${RM} test2.o

test3: test3.o chkopts
	-${CLINKER} -o test3 test3.o ${SLEPC_EPS_LIB}
	${RM} test3.o

test4: test4.o chkopts
	-${CLINKER} -o test4 test4.o ${SLEPC_EPS_LIB}
	${RM} test4.o

test5: test5.o chkopts
	-${CLINKER} -o test5 test5.o ${SLEPC_EPS_LIB}
	${RM} test5.o

test6: test6.o chkopts
	-${CLINKER} -o test6 test6.o ${SLEPC_EPS_LIB}
	${RM} test6.o

test7f: test7f.o chkopts
	-${FLINKER} -o test7f test7f.o ${SLEPC_EPS_LIB}
	${RM} test7f.o

test8: test8.o chkopts
	-${CLINKER} -o test8 test8.o ${SLEPC_EPS_LIB}
	${RM} test8.o

test9: test9.o chkopts
	-${CLINKER} -o test9 test9.o ${SLEPC_EPS_LIB}
	${RM} test9.o

test10: test10.o chkopts
	-${CLINKER} -o test10 test10.o ${SLEPC_EPS_LIB}
	${RM} test10.o

test11: test11.o chkopts
	-${CLINKER} -o test11 test11.o ${SLEPC_EPS_LIB}
	${RM} test11.o

test12: test12.o chkopts
	-${CLINKER} -o test12 test12.o ${SLEPC_EPS_LIB}
	${RM} test12.o

test13: test13.o chkopts
	-${CLINKER} -o test13 test13.o ${SLEPC_EPS_LIB}
	${RM} test13.o

test14: test14.o chkopts
	-${CLINKER} -o test14 test14.o ${SLEPC_EPS_LIB}
	${RM} test14.o

test14f: test14f.o chkopts
	-${FLINKER} -o test14f test14f.o ${SLEPC_EPS_LIB}
	${RM} test14f.o

test15f: test15f.o chkopts
	-${FLINKER} -o test15f test15f.o ${SLEPC_EPS_LIB}
	${RM} test15f.o

test16: test16.o chkopts
	-${CLINKER} -o test16 test16.o ${SLEPC_EPS_LIB}
	${RM} test16.o

#------------------------------------------------------------------------------------
EPSALL = krylovschur arnoldi lanczos gd jd gd2
EPSNS  = krylovschur arnoldi gd jd gd2
EPSAR  = gd jd gd2

TESTCODE = \
	[ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \
	${DIFF} output/$${test}.out $${test}.tmp || \
	echo "Possible problem with $${test}, diffs above"; \
	${RM} -f $${test}.tmp

runtest1_1:
	-@test=test1_1; \
	for eps in ${EPSALL}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = lanczos ]; then EXTRA="-eps_lanczos_reorthog full"; else EXTRA=""; fi; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test1 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1; \
	done > $${test}.tmp; \
	${TESTCODE}

runtest1_2:
	-@test=test1_2; \
	${MPIEXEC} -n 1 ./test1  -eps_interval .1,1.1 -eps_tol 1e-10 -st_type sinvert -st_ksp_type preonly -st_pc_type cholesky 2>&1 >  $${test}.tmp; \
	${TESTCODE}

runtest2_1:
	-@test=test2_1; \
	for eps in ${EPSALL}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test2 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1;    \
	done > $${test}.tmp; \
	${TESTCODE}

runtest3_1:
	-@test=test3_1; \
	for eps in ${EPSALL}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test3 -eps_type $$eps -eps_nev 4 2>&1;    \
	done > $${test}.tmp; \
	${TESTCODE}

runtest4_1:
	-@test=test4_1; \
	for eps in ${EPSALL}; do \
	   echo "eps type $$eps"; \
	   ${MPIEXEC} -n 1 ./test4 -type $$eps 2>&1;    \
	done > $${test}.tmp; \
	${TESTCODE}

runtest5_1:
	-@test=test5_1; \
	for eps in ${EPSNS}; do \
	   echo "eps type $$eps" >> test5_1.tmp; \
	   if [ "$$eps" = gd ]; then EXTRA="-eps_gd_minv 2"; \
	   elif [ "$$eps" = jd ]; then EXTRA="-eps_jd_minv 2"; \
	   elif [ "$$eps" = "gd2" ]; then eps=gd; EXTRA="-eps_gd_double_expansion"; else EXTRA=""; fi; \
	   ${MPIEXEC} -n 1 ./test5 -eps_type $$eps -eps_nev 4 $$EXTRA >> test5_1.tmp 2>&1; \
	done; \
	if (${GREP} USE_COMPLEX ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
	  [ x${SAVE_OUTPUT} = xyes ] && cp test5_1.tmp output/test5_1_complex.out; \
	  if (${DIFF} output/test5_1_complex.out test5_1.tmp) then true; \
	  else echo "Possible problem with test5_1, diffs above"; fi; \
	else \
	  [ x${SAVE_OUTPUT} = xyes ] && cp test5_1.tmp output/test5_1.out; \
	  if (${DIFF} output/test5_1.out test5_1.tmp) then true; \
	  else echo "Possible problem with test5_1, diffs above"; fi; \
	fi; \
	${RM} -f test5_1.tmp;

runtest5_blopex:
	-@${MPIEXEC} -n 1 ./test5 -symm -eps_type blopex -eps_nev 4 > test5_blopex.tmp 2>&1; \
	if (${DIFF} output/test5_blopex.out test5_blopex.tmp) then true; \
	else echo "Possible problem with test5_blopex, diffs above"; fi; \
	${RM} -f test5_blopex.tmp;

testtest5_blopex: test5.PETSc
	@ok=0; if [ "${PETSC_WITH_BATCH}" != "" -o "${MPIEXEC}" = "/bin/false" ]; then \
           echo "Skipping BLOPEX test"; \
	elif [ -f test5 ]; then \
           ${MPIEXEC} -n 1 ./test5 -symm -eps_type blopex -eps_nev 4 > test5_blopex.tmp 2>&1; \
	   if [ "${PETSC_SCALAR}" = "complex" ]; then REFFILE=_complex; fi; \
	   if (${DIFF} output/test5_blopex$$REFFILE.out test5_blopex.tmp > /dev/null 2>&1) then \
           echo "BLOPEX example src/eps/examples/tests/test5 run successfully with 1 MPI process"; \
	   else echo "Possible error running BLOPEX src/eps/examples/tests/test5 with 1 MPI process"; \
           cat test5_blopex.tmp; ok=1; fi; \
           ${RM} -f test5_blopex.tmp; \
           ${MAKE} SLEPC_ARCH=${SLEPC_ARCH} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test5.rm ; \
	else ok=1; fi; \
	exit $$ok

runtest6_1:
	-@test=test6_1; \
	for eps in ${EPSNS}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test6 -eps_type $$eps -eps_nev 4 2>&1;    \
	done > $${test}.tmp; \
	${TESTCODE}

runtest7f_1:
	-@test=test7f_1; \
	${MPIEXEC} -n 1 ./test7f -eps_nev 4 > $${test}.tmp 2>&1; \
	${TESTCODE}

testtest7f: test7f.PETSc
	@ok=0; if [ "${PETSC_WITH_BATCH}" != "" ]; then \
	   echo "Running with batch filesystem; to test run src/eps/examples/tests/test7f " ; \
	   echo "with your systems batch system"; \
        elif [ "${MPIEXEC}" = "/bin/false" ]; then \
           echo "*mpiexec not found*. Please run src/eps/examples/tests/test7f manually"; \
	elif [ -f test7f ]; then \
           GFORTRAN_UNBUFFERED_ALL=1 ${MPIEXEC} -n 1 ./test7f -eps_nev 4 > test7f_1.tmp 2>&1; \
	   if (${DIFF} output/test7f_1.out test7f_1.tmp > /dev/null 2>&1) then \
           echo "Fortran example src/eps/examples/tests/test7f run successfully with 1 MPI process"; \
	   else echo "Possible error running Fortran src/eps/examples/tests/test7f with 1 MPI process"; \
           cat test7f_1.tmp; ok=1; fi; \
           ${RM} -f test7f_1.tmp; \
           ${MAKE} SLEPC_ARCH=${SLEPC_ARCH} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test7f.rm ; \
	else ok=1; fi; \
	exit $$ok

runtest8_1:
	-@test=test8_1; \
	for eps in ${EPSALL}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test8 -eps_type $$eps -eps_nev 4 -eps_ncv 24 2>&1; \
	done > $${test}.tmp; \
	${TESTCODE}

runtest9_1:
	-@test=test9_1; \
	for eps in ${EPSNS}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = "krylovschur" -o "$$eps" = "arnoldi" ]; then EXTRA="-eps_ncv 7 -eps_max_it 300"; \
	   elif [ "$$eps" = jd ]; then EXTRA="-st_ksp_type cg"; \
           else EXTRA=""; fi; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test9 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1; \
	done > $${test}.tmp;\
	${TESTCODE}

runtest10_1:
	-@test=test10_1; \
	for eps in ${EPSALL}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test10 -eps_type $$eps -eps_nev 4 -m 11 2>&1; \
	done > $${test}.tmp;\
	${TESTCODE}

testtest10: test10.PETSc
	@ok=0; if [ "${PETSC_WITH_BATCH}" != "" ]; then \
           echo "Running with batch filesystem; to test run src/eps/examples/tests/test10" ; \
           echo "with your systems batch system"; \
        elif [ "${MPIEXEC}" = "/bin/false" ]; then \
           echo "*mpiexec not found*. Please run src/eps/examples/tests/test10 manually"; \
	elif [ -f test10 ]; then \
           ${MPIEXEC} -n 1 ./test10 -eps_nev 4 -eps_ncv 14 -m 11 -eps_largest_magnitude > test10_1.tmp 2>&1; \
	   if (${DIFF} output/test10_1_ks.out test10_1.tmp > /dev/null 2>&1) then \
           echo "C/C++ example src/eps/examples/tests/test10 run successfully with 1 MPI process"; \
	   else echo "Possible error running C/C++ src/eps/examples/tests/test10 with 1 MPI process"; \
           cat test10_1.tmp; ok=1; fi; \
	   if [ "${MPIEXEC}" != "${PETSC_DIR}/bin/petsc-mpiexec.uni" ]; then \
           ${MPIEXEC} -n 2 ./test10 -eps_nev 4 -eps_ncv 14 -m 11 -eps_largest_magnitude > test10_1.tmp 2>&1; \
	   if (${DIFF} output/test10_1_ks.out test10_1.tmp > /dev/null 2>&1) then \
           echo "C/C++ example src/eps/examples/tests/test10 run successfully with 2 MPI process"; \
	   else echo "Possible error running C/C++ src/eps/examples/tests/test10 with 2 MPI process"; \
           cat test10_1.tmp; ok=1; fi; fi; \
           ${RM} -f test10_1.tmp; \
           ${MAKE} SLEPC_ARCH=${SLEPC_ARCH} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} test10.rm; \
	else ok=1; fi; \
	exit $$ok

runtest11_1:
	-@test=test11_1; \
	for eps in krylovschur arnoldi gd jd; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = krylovschur -o "$$eps" = arnoldi ]; then EXTRA="-st_type sinvert"; \
	   elif [ "$$eps" = gd ]; then EXTRA="-eps_max_it 5000"; \
	   fi; \
	   ${MPIEXEC} -n 1 ./test11 -eps_type $$eps -eps_nev 4 $$EXTRA 2>&1; \
	done > $${test}.tmp;\
	${TESTCODE}

runtest12_1:
	-@test=test12_1; \
	for eps in ${EPSNS}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test12 -eps_type $$eps -eps_nev 4 2>&1;    \
	done > $${test}.tmp; \
	${TESTCODE}

runtest13_1:
	-@test=test13_1; \
	for eps in ${EPSAR}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test13 -eps_type $$eps -eps_max_it 5000 2>&1;    \
	done > $${test}.tmp; \
	${TESTCODE}

runtest13_2:
	-@test=test13_1; \
	for eps in ${EPSAR}; do \
	   echo "eps type $$eps"; \
	   if [ "$$eps" = gd2 ]; then eps="gd -eps_gd_double_expansion"; fi; \
	   ${MPIEXEC} -n 1 ./test13 -eps_type $$eps -eps_non_hermitian -eps_max_it 5000 2>&1;    \
	done > $${test}.tmp; \
	${TESTCODE}

runtest14_1:
	-@test=test14_1; \
	${MPIEXEC} -n 1 ./test14 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest14f_1:
	-@test=test14f_1; \
	${MPIEXEC} -n 1 ./test14f 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest15f_1:
	-@test=test15f_1; \
	${MPIEXEC} -n 1 ./test15f -my_eps_monitor > $${test}.tmp 2>&1; \
	${TESTCODE}

runtest16_1:
	-@test=test16_1; \
	${MPIEXEC} -n 1 ./test16 -n 200 -eps_nev 6 -eps_ncv 24 -eps_smallest_magnitude 2>&1 > $${test}.tmp; \
	${TESTCODE}

slepc-3.7.4/src/eps/examples/tests/test1.c0000644000175000017500000001175513107004621017736 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Tests B-orthonormality of eigenvectors in a GHEP problem.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B; /* matrices */ EPS eps; /* eigenproblem solver context */ Vec *X,v; PetscReal lev,tol=1000*PETSC_MACHINE_EPSILON; PetscInt N,n=45,m,Istart,Iend,II,i,j,nconv; PetscBool flag; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nGeneralized Symmetric Eigenproblem, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, Ax=kBx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = VecDuplicateVecs(v,nconv,&X);CHKERRQ(ierr); for (i=0;iActual source code: test15f.F
slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./test15f [-help] [-n <n>] [all SLEPc options] 
 21: !
 22: !  Description: Tests custom monitors from Fortran.
 23: !
 24: !  The command line options are:
 25: !    -n <n>, where <n> = number of grid points = matrix size
 26: !    -my_eps_monitor, activates the custom monitor
 27: !
 28: ! ---------------------------------------------------------------------- 
 29: !
 30:       program main
 31:       implicit none

 33: #include <petsc/finclude/petscsys.h>
 34: #include <petsc/finclude/petscvec.h>
 35: #include <petsc/finclude/petscmat.h>
 36: #include <slepc/finclude/slepcsys.h>
 37: #include <slepc/finclude/slepceps.h>

 39: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 40: !     Declarations
 41: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 42: !
 43: !  Variables:
 44: !     A     operator matrix
 45: !     eps   eigenproblem solver context

 47:       Mat            A
 48:       EPS            eps
 49:       EPSType        tname
 50:       PetscInt       n, i, Istart, Iend
 51:       PetscInt       nev
 52:       PetscInt       col(3)
 53:       PetscInt       i1,i2,i3
 54:       PetscMPIInt    rank
 55:       PetscErrorCode ierr
 56:       PetscBool      flg
 57:       PetscScalar    value(3)

 59: !  Note: Any user-defined Fortran routines (such as MyEPSMonitor)
 60: !  MUST be declared as external.

 62:       external MyEPSMonitor

 64: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 65: !     Beginning of program
 66: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 68:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 69:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 70:       n = 30
 71:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 72:      &                        '-n',n,flg,ierr)

 74:       if (rank .eq. 0) then
 75:         write(*,100) n
 76:       endif
 77:  100  format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')

 79: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 80: !     Compute the operator matrix that defines the eigensystem, Ax=kx
 81: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 83:       call MatCreate(PETSC_COMM_WORLD,A,ierr)
 84:       call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
 85:       call MatSetFromOptions(A,ierr)
 86:       call MatSetUp(A,ierr)

 88:       i1 = 1
 89:       i2 = 2
 90:       i3 = 3
 91:       call MatGetOwnershipRange(A,Istart,Iend,ierr)
 92:       if (Istart .eq. 0) then 
 93:         i = 0
 94:         col(1) = 0
 95:         col(2) = 1
 96:         value(1) =  2.0
 97:         value(2) = -1.0
 98:         call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr)
 99:         Istart = Istart+1
100:       endif
101:       if (Iend .eq. n) then 
102:         i = n-1
103:         col(1) = n-2
104:         col(2) = n-1
105:         value(1) = -1.0
106:         value(2) =  2.0
107:         call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr)
108:         Iend = Iend-1
109:       endif
110:       value(1) = -1.0
111:       value(2) =  2.0
112:       value(3) = -1.0
113:       do i=Istart,Iend-1
114:         col(1) = i-1
115:         col(2) = i
116:         col(3) = i+1
117:         call MatSetValues(A,i1,i,i3,col,value,INSERT_VALUES,ierr)
118:       enddo

120:       call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
121:       call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)

123: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
124: !     Create the eigensolver and display info
125: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

127: !     ** Create eigensolver context
128:       call EPSCreate(PETSC_COMM_WORLD,eps,ierr)

130: !     ** Set operators. In this case, it is a standard eigenvalue problem
131:       call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr)
132:       call EPSSetProblemType(eps,EPS_HEP,ierr)

134: !     ** Set user-defined monitor
135:       call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,  &
136:      &                        '-my_eps_monitor',flg,ierr)
137:       if (flg) then
138:         call EPSMonitorSet(eps,MyEPSMonitor,PETSC_NULL_OBJECT,          &
139:      &                     PETSC_NULL_FUNCTION,ierr)
140:       endif

142: !     ** Set solver parameters at runtime
143:       call EPSSetFromOptions(eps,ierr)

145: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
146: !     Solve the eigensystem
147: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

149:       call EPSSolve(eps,ierr) 

151: !     ** Optional: Get some information from the solver and display it
152:       call EPSGetType(eps,tname,ierr)
153:       if (rank .eq. 0) then
154:         write(*,120) tname
155:       endif
156:  120  format (' Solution method: ',A)
157:       call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER,                 &
158:      &                      PETSC_NULL_INTEGER,ierr)
159:       if (rank .eq. 0) then
160:         write(*,130) nev
161:       endif
162:  130  format (' Number of requested eigenvalues:',I2)

164: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
165: !     Display solution and clean up
166: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

168:       call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr)
169:       call EPSDestroy(eps,ierr)
170:       call MatDestroy(A,ierr)

172:       call SlepcFinalize(ierr)
173:       end

175: ! --------------------------------------------------------------
176: !
177: !  MyEPSMonitor - This is a user-defined routine for monitoring
178: !  the EPS iterative solvers.
179: !
180: !  Input Parameters:
181: !    eps   - eigensolver context
182: !    its   - iteration number
183: !    nconv - number of converged eigenpairs
184: !    eigr  - real part of the eigenvalues
185: !    eigi  - imaginary part of the eigenvalues
186: !    errest- relative error estimates for each eigenpair
187: !    nest  - number of error estimates
188: !    dummy - optional user-defined monitor context (unused here)
189: !
190:       subroutine MyEPSMonitor(eps,its,nconv,eigr,eigi,errest,nest,dummy,&
191:      &                        ierr)

193:       implicit none

195: #include <petsc/finclude/petscsys.h>
196: #include <petsc/finclude/petscvec.h>
197: #include <petsc/finclude/petscmat.h>
198: #include <slepc/finclude/slepcsys.h>
199: #include <slepc/finclude/slepceps.h>

201:       EPS            eps
202:       Vec            x
203:       PetscErrorCode ierr
204:       PetscInt       its,nconv,nest,dummy
205:       PetscScalar    eigr(*),eigi(*)
206:       PetscReal      re,errest(*)
207:       PetscMPIInt    rank

209:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
210:       if (its .gt. 0 .and. rank .eq. 0) then
211:         re = PetscRealPart(eigr(nconv+1))
212:         write(6,140) its,nconv,re,errest(nconv+1)
213:       endif

215:  140  format(i3,' EPS nconv=',i2,' first unconverged value (error) ',   &
216:      &       f6.4,' (',g9.3,')')
217:       0
218:       end


slepc-3.7.4/src/eps/examples/tests/test3.c0000644000175000017500000001170513107004621017733 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Tests multiple calls to EPSSolve with different matrix.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A1,A2; /* problem matrices */ EPS eps; /* eigenproblem solver context */ PetscReal tol=1000*PETSC_MACHINE_EPSILON,v; Vec d; PetscInt n=30,i,Istart,Iend; PetscRandom myrand; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nTridiagonal with random diagonal, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create matrix tridiag([-1 0 -1]) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A1);CHKERRQ(ierr); ierr = MatSetSizes(A1,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A1);CHKERRQ(ierr); ierr = MatSetUp(A1);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A1,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A1,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: test16.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Tests a user-defined convergence test.\n\n";

 24: #include <slepceps.h>


 29: /*
 30:   MyConvergedAbsolute - Bizarre convergence test that requires more accuracy
 31:   to positive eigenvalues compared to negative ones.
 32: */
 33: PetscErrorCode MyConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
 34: {
 36:   *errest = (PetscRealPart(eigr)<0.0)?res:100*res;
 37:   return(0);
 38: }

 42: int main(int argc,char **argv)
 43: {
 44:   Mat            A;           /* problem matrix */
 45:   EPS            eps;         /* eigenproblem solver context */
 46:   PetscInt       n=30,i,Istart,Iend;

 49:   SlepcInitialize(&argc,&argv,(char*)0,help);
 50:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 51:   PetscPrintf(PETSC_COMM_WORLD,"\nTridiagonal Eigenproblem, n=%D\n\n",n);

 53:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 54:      Compute the operator matrix that defines the eigensystem, Ax=kx
 55:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 57:   MatCreate(PETSC_COMM_WORLD,&A);
 58:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 59:   MatSetFromOptions(A);
 60:   MatSetUp(A);

 62:   MatGetOwnershipRange(A,&Istart,&Iend);
 63:   for (i=Istart;i<Iend;i++) {
 64:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 65:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 66:   }
 67:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 68:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 69:   MatShift(A,-1e-3);

 71:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 72:                         Create the eigensolver
 73:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 74:   EPSCreate(PETSC_COMM_WORLD,&eps);
 75:   EPSSetOperators(eps,A,NULL);
 76:   EPSSetProblemType(eps,EPS_HEP);
 77:   /* set user-defined convergence test */
 78:   EPSSetConvergenceTestFunction(eps,MyConvergedAbsolute,NULL,NULL);
 79:   EPSSetFromOptions(eps);

 81:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 82:                           Solve the problem
 83:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 84:   EPSSolve(eps);
 85:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);

 87:   EPSDestroy(&eps);
 88:   MatDestroy(&A);
 89:   SlepcFinalize();
 90:   return ierr;
 91: }

slepc-3.7.4/src/eps/examples/tests/test14f.F.html0000644000175000017500000004505113107004621021072 0ustar jromanjroman
Actual source code: test14f.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Description: Simple example to test the EPS Fortran interface.
 21: !
 22: ! ---------------------------------------------------------------------- 
 23: !
 24:       program main
 25:       implicit none

 27: #include <petsc/finclude/petscsys.h>
 28: #include <petsc/finclude/petscvec.h>
 29: #include <petsc/finclude/petscmat.h>
 30: #include <petsc/finclude/petscviewer.h>
 31: #include <slepc/finclude/slepcsys.h>
 32: #include <slepc/finclude/slepceps.h>

 34: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 35: !     Declarations
 36: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 37:       Mat                A,B
 38:       EPS                eps
 39:       ST                 st
 40:       KSP                ksp
 41:       DS                 ds
 42:       PetscReal          cut,tol,tolabs
 43:       PetscScalar        tget,value
 44:       PetscInt           n,i,its,Istart,Iend
 45:       PetscInt           nev,ncv,mpd
 46:       PetscBool          flg
 47:       EPSConvergedReason reason
 48:       EPSType            tname
 49:       EPSExtraction      extr
 50:       EPSBalance         bal
 51:       EPSWhich           which
 52:       EPSConv            conv
 53:       EPSProblemType     ptype
 54:       PetscMPIInt        rank
 55:       PetscErrorCode     ierr
 56:       SlepcConvMonitor   ctx
 57:       PetscViewerAndFormat vf

 59: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 60: !     Beginning of program
 61: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 63:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 64:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 65:       n = 20
 66:       if (rank .eq. 0) then
 67:         write(*,100) n
 68:       endif
 69:  100  format (/'Diagonal Eigenproblem, n =',I3,' (Fortran)')

 71:       call MatCreate(PETSC_COMM_WORLD,A,ierr)
 72:       call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
 73:       call MatSetFromOptions(A,ierr)
 74:       call MatSetUp(A,ierr)
 75:       call MatGetOwnershipRange(A,Istart,Iend,ierr)
 76:       do i=Istart,Iend-1
 77:         value = i+1
 78:         call MatSetValue(A,i,i,value,INSERT_VALUES,ierr)
 79:       enddo
 80:       call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
 81:       call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)

 83: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 84: !     Create eigensolver and test interface functions
 85: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 87:       call EPSCreate(PETSC_COMM_WORLD,eps,ierr)
 88:       call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr)
 89:       call EPSGetOperators(eps,B,PETSC_NULL_OBJECT,ierr)
 90:       call MatView(B,PETSC_NULL_OBJECT,ierr)

 92:       call EPSSetType(eps,EPSKRYLOVSCHUR,ierr)
 93:       call EPSGetType(eps,tname,ierr)
 94:       if (rank .eq. 0) then
 95:         write(*,110) tname
 96:       endif
 97:  110  format (' Type set to ',A)

 99:       call EPSGetProblemType(eps,ptype,ierr)
100:       if (rank .eq. 0) then
101:         write(*,120) ptype
102:       endif
103:  120  format (' Problem type before changing = ',I2)
104:       call EPSSetProblemType(eps,EPS_HEP,ierr)
105:       call EPSGetProblemType(eps,ptype,ierr)
106:       if (rank .eq. 0) then
107:         write(*,130) ptype
108:       endif
109:  130  format (' ... changed to ',I2)
110:       call EPSIsGeneralized(eps,flg,ierr)
111:       if (flg .and. rank .eq. 0) then
112:         write(*,*) 'generalized'
113:       endif
114:       call EPSIsHermitian(eps,flg,ierr)
115:       if (flg .and. rank .eq. 0) then
116:         write(*,*) 'hermitian'
117:       endif
118:       call EPSIsPositive(eps,flg,ierr)
119:       if (flg .and. rank .eq. 0) then
120:         write(*,*) 'positive'
121:       endif

123:       call EPSGetExtraction(eps,extr,ierr)
124:       if (rank .eq. 0) then
125:         write(*,140) extr
126:       endif
127:  140  format (' Extraction before changing = ',I2)
128:       call EPSSetExtraction(eps,EPS_HARMONIC,ierr)
129:       call EPSGetExtraction(eps,extr,ierr)
130:       if (rank .eq. 0) then
131:         write(*,150) extr
132:       endif
133:  150  format (' ... changed to ',I2)

135:       its = 8
136:       cut = 1.0e-6
137:       bal = EPS_BALANCE_ONESIDE
138:       call EPSSetBalance(eps,bal,its,cut,ierr)
139:       call EPSGetBalance(eps,bal,its,cut,ierr)
140:       if (rank .eq. 0) then
141:         write(*,160) bal,its,cut
142:       endif
143:  160  format (' Balance: ',I2,', its=',I2,', cutoff=',F8.6)

145:       tget = 4.8
146:       call EPSSetTarget(eps,tget,ierr)
147:       call EPSGetTarget(eps,tget,ierr)
148:       call EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE,ierr)
149:       call EPSGetWhichEigenpairs(eps,which,ierr)
150:       if (rank .eq. 0) then
151:         write(*,170) which,PetscRealPart(tget)
152:       endif
153:  170  format (' Which = ',I2,', target = ',F3.1)

155:       nev = 4
156:       call EPSSetDimensions(eps,nev,PETSC_DEFAULT_INTEGER,              &
157:      &                      PETSC_DEFAULT_INTEGER,ierr)
158:       call EPSGetDimensions(eps,nev,ncv,mpd,ierr)
159:       if (rank .eq. 0) then
160:         write(*,180) nev,ncv,mpd
161:       endif
162:  180  format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2)

164:       tol = 2.2e-4
165:       its = 200
166:       call EPSSetTolerances(eps,tol,its,ierr)
167:       call EPSGetTolerances(eps,tol,its,ierr)
168:       if (rank .eq. 0) then
169:         write(*,190) tol,its
170:       endif
171:  190  format (' Tolerance =',F7.5,', max_its =',I4)

173:       call EPSSetConvergenceTest(eps,EPS_CONV_ABS,ierr)
174:       call EPSGetConvergenceTest(eps,conv,ierr)
175:       if (rank .eq. 0) then
176:         write(*,200) conv
177:       endif
178:  200  format (' Convergence test =',I2)

180:       call PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,        &
181:      &                   PETSC_VIEWER_DEFAULT,vf,ierr)
182:       call EPSMonitorSet(eps,EPSMONITORFIRST,vf,                        &
183:      &                   PetscViewerAndFormatDestroy,ierr)
184:       call SlepcConvMonitorCreate(PETSC_VIEWER_STDOUT_WORLD,            &
185:      &                   PETSC_VIEWER_DEFAULT,ctx,ierr)
186:       call EPSMonitorSet(eps,EPSMONITORCONVERGED,ctx,                   &
187:      &                   SlepcConvMonitorDestroy,ierr)
188:       call EPSMonitorCancel(eps,ierr)

190:       call EPSGetST(eps,st,ierr) 
191:       call STGetKSP(st,ksp,ierr) 
192:       tol = 1.e-8
193:       tolabs = 1.e-35
194:       call KSPSetTolerances(ksp,tol,tolabs,PETSC_DEFAULT_REAL,          &
195:      &                      PETSC_DEFAULT_INTEGER,ierr)
196:       call STView(st,PETSC_NULL_OBJECT,ierr) 
197:       call EPSGetDS(eps,ds,ierr) 
198:       call DSView(ds,PETSC_NULL_OBJECT,ierr) 

200:       call EPSSetFromOptions(eps,ierr)
201:       call EPSSolve(eps,ierr) 
202:       call EPSGetConvergedReason(eps,reason,ierr)
203:       call EPSGetIterationNumber(eps,its,ierr)
204:       if (rank .eq. 0) then
205:         write(*,210) reason,its
206:       endif
207:  210  format (' Finished - converged reason =',I2,', its=',I4)

209: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
210: !     Display solution and clean up
211: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
212:       call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr)
213:       call EPSDestroy(eps,ierr)
214:       call MatDestroy(A,ierr)

216:       call SlepcFinalize(ierr)
217:       end
slepc-3.7.4/src/eps/examples/tests/test11.c.html0000644000175000017500000004624413107004621020763 0ustar jromanjroman
Actual source code: test11.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion."
 23:   "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n"
 24:   "This example illustrates how the user can set a custom spectrum selection.\n\n"
 25:   "The command line options are:\n"
 26:   "  -m <m>, where <m> = number of grid subdivisions in each dimension.\n\n";

 28: #include <slepceps.h>

 30: /*
 31:    User-defined routines
 32: */

 34: PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx);
 35: PetscErrorCode MatMarkovModel(PetscInt m,Mat A);

 39: int main(int argc,char **argv)
 40: {
 41:   Vec            v0;              /* initial vector */
 42:   Mat            A;               /* operator matrix */
 43:   EPS            eps;             /* eigenproblem solver context */
 44:   ST             st;              /* spectral transformation associated */
 45:   EPSType        type;
 46:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 47:   PetscScalar    target=0.5;
 48:   PetscInt       N,m=15,nev;
 50:   char           str[50];

 52:   SlepcInitialize(&argc,&argv,(char*)0,help);

 54:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 55:   N = m*(m+1)/2;
 56:   PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n",N,m);
 57:   PetscOptionsGetScalar(NULL,NULL,"-target",&target,NULL);
 58:   SlepcSNPrintfScalar(str,50,target,PETSC_FALSE);
 59:   PetscPrintf(PETSC_COMM_WORLD,"Searching closest eigenvalues to the right of %s.\n\n",str);

 61:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 62:      Compute the operator matrix that defines the eigensystem, Ax=kx
 63:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 65:   MatCreate(PETSC_COMM_WORLD,&A);
 66:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);
 67:   MatSetFromOptions(A);
 68:   MatSetUp(A);
 69:   MatMarkovModel(m,A);

 71:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 72:                 Create the eigensolver and set various options
 73:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 75:   /*
 76:      Create eigensolver context
 77:   */
 78:   EPSCreate(PETSC_COMM_WORLD,&eps);

 80:   /*
 81:      Set operators. In this case, it is a standard eigenvalue problem
 82:   */
 83:   EPSSetOperators(eps,A,NULL);
 84:   EPSSetProblemType(eps,EPS_NHEP);
 85:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);

 87:   /*
 88:      Set the custom comparing routine in order to obtain the eigenvalues
 89:      closest to the target on the right only
 90:   */
 91:   EPSSetEigenvalueComparison(eps,MyEigenSort,&target);

 93:   /*
 94:      Set solver parameters at runtime
 95:   */
 96:   EPSSetFromOptions(eps);

 98:   /*
 99:      Set the preconditioner based on A - target * I
100:   */
101:   EPSGetST(eps,&st);
102:   STSetShift(st,target);

104:   /*
105:      Set the initial vector. This is optional, if not done the initial
106:      vector is set to random values
107:   */
108:   MatCreateVecs(A,&v0,NULL);
109:   VecSet(v0,1.0);
110:   EPSSetInitialSpace(eps,1,&v0);

112:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
113:                       Solve the eigensystem
114:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

116:   EPSSolve(eps);

118:   /*
119:      Optional: Get some information from the solver and display it
120:   */
121:   EPSGetType(eps,&type);
122:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
123:   EPSGetDimensions(eps,&nev,NULL,NULL);
124:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

126:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
127:                     Display solution and clean up
128:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

130:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
131:   EPSDestroy(&eps);
132:   MatDestroy(&A);
133:   VecDestroy(&v0);
134:   SlepcFinalize();
135:   return ierr;
136: }

140: /*
141:     Matrix generator for a Markov model of a random walk on a triangular grid.

143:     This subroutine generates a test matrix that models a random walk on a
144:     triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a
145:     FORTRAN subroutine to calculate the dominant invariant subspaces of a real
146:     matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few
147:     papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295
148:     (1980) ]. These matrices provide reasonably easy test problems for eigenvalue
149:     algorithms. The transpose of the matrix  is stochastic and so it is known
150:     that one is an exact eigenvalue. One seeks the eigenvector of the transpose
151:     associated with the eigenvalue unity. The problem is to calculate the steady
152:     state probability distribution of the system, which is the eigevector
153:     associated with the eigenvalue one and scaled in such a way that the sum all
154:     the components is equal to one.

156:     Note: the code will actually compute the transpose of the stochastic matrix
157:     that contains the transition probabilities.
158: */
159: PetscErrorCode MatMarkovModel(PetscInt m,Mat A)
160: {
161:   const PetscReal cst = 0.5/(PetscReal)(m-1);
162:   PetscReal       pd,pu;
163:   PetscInt        Istart,Iend,i,j,jmax,ix=0;
164:   PetscErrorCode  ierr;

167:   MatGetOwnershipRange(A,&Istart,&Iend);
168:   for (i=1;i<=m;i++) {
169:     jmax = m-i+1;
170:     for (j=1;j<=jmax;j++) {
171:       ix = ix + 1;
172:       if (ix-1<Istart || ix>Iend) continue;  /* compute only owned rows */
173:       if (j!=jmax) {
174:         pd = cst*(PetscReal)(i+j-1);
175:         /* north */
176:         if (i==1) {
177:           MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);
178:         } else {
179:           MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);
180:         }
181:         /* east */
182:         if (j==1) {
183:           MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);
184:         } else {
185:           MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);
186:         }
187:       }
188:       /* south */
189:       pu = 0.5 - cst*(PetscReal)(i+j-3);
190:       if (j>1) {
191:         MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);
192:       }
193:       /* west */
194:       if (i>1) {
195:         MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);
196:       }
197:     }
198:   }
199:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
200:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
201:   return(0);
202: }

206: /*
207:     Function for user-defined eigenvalue ordering criterion.

209:     Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose
210:     one of them as the preferred one according to the criterion.
211:     In this example, the preferred value is the one closest to the target,
212:     but on the right side.
213: */
214: PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)
215: {
216:   PetscScalar target = *(PetscScalar*)ctx;
217:   PetscReal   da,db;
218:   PetscBool   aisright,bisright;

221:   if (PetscRealPart(target) < PetscRealPart(ar)) aisright = PETSC_TRUE;
222:   else aisright = PETSC_FALSE;
223:   if (PetscRealPart(target) < PetscRealPart(br)) bisright = PETSC_TRUE;
224:   else bisright = PETSC_FALSE;
225:   if (aisright == bisright) {
226:     /* both are on the same side of the target */
227:     da = SlepcAbsEigenvalue(ar-target,ai);
228:     db = SlepcAbsEigenvalue(br-target,bi);
229:     if (da < db) *r = -1;
230:     else if (da > db) *r = 1;
231:     else *r = 0;
232:   } else if (aisright && !bisright) *r = -1; /* 'a' is on the right */
233:   else *r = 1;  /* 'b' is on the right */
234:   return(0);
235: }
slepc-3.7.4/src/eps/examples/tests/test6.c.html0000644000175000017500000001726613107004621020711 0ustar jromanjroman
Actual source code: test6.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Diagonal eigenproblem.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions = matrix dimension.\n"
 25:   "  -seed <s>, where <s> = seed for random number generation.\n\n";

 27: #include <slepceps.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A;           /* problem matrix */
 34:   EPS            eps;         /* eigenproblem solver context */
 35:   Vec            v0;          /* initial vector */
 36:   PetscRandom    rand;
 37:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 38:   PetscInt       n=30,i,Istart,Iend,seed=0x12345678;

 41:   SlepcInitialize(&argc,&argv,(char*)0,help);

 43:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 44:   PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%D\n\n",n);

 46:   MatCreate(PETSC_COMM_WORLD,&A);
 47:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 48:   MatSetFromOptions(A);
 49:   MatSetUp(A);
 50:   MatGetOwnershipRange(A,&Istart,&Iend);
 51:   for (i=Istart;i<Iend;i++) {
 52:     MatSetValue(A,i,i,i+1,INSERT_VALUES);
 53:   }
 54:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 55:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 57:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 58:                       Solve the eigensystem
 59:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 60:   EPSCreate(PETSC_COMM_WORLD,&eps);
 61:   EPSSetOperators(eps,A,NULL);
 62:   EPSSetProblemType(eps,EPS_HEP);
 63:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);
 64:   EPSSetFromOptions(eps);
 65:   /* set random initial vector */
 66:   MatCreateVecs(A,&v0,NULL);
 67:   PetscRandomCreate(PETSC_COMM_WORLD,&rand);
 68:   PetscRandomSetFromOptions(rand);
 69:   PetscOptionsGetInt(NULL,NULL,"-seed",&seed,NULL);
 70:   PetscRandomSetSeed(rand,seed);
 71:   PetscRandomSeed(rand);
 72:   VecSetRandom(v0,rand);
 73:   EPSSetInitialSpace(eps,1,&v0);
 74:   /* call the solver */
 75:   EPSSolve(eps);

 77:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 78:                     Display solution and clean up
 79:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 80:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
 81:   EPSDestroy(&eps);
 82:   MatDestroy(&A);
 83:   VecDestroy(&v0);
 84:   PetscRandomDestroy(&rand);
 85:   SlepcFinalize();
 86:   return ierr;
 87: }
slepc-3.7.4/src/eps/examples/tests/test2.c.html0000644000175000017500000002466213107004621020703 0ustar jromanjroman
Actual source code: test2.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Tests multiple calls to EPSSolve with the same matrix.\n\n";

 24: #include <slepceps.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat            A;           /* problem matrix */
 31:   EPS            eps;         /* eigenproblem solver context */
 32:   ST             st;
 33:   PetscReal      tol=PetscMax(1000*PETSC_MACHINE_EPSILON,1e-9);
 34:   PetscInt       n=30,i,Istart,Iend;
 35:   PetscBool      flg;

 38:   SlepcInitialize(&argc,&argv,(char*)0,help);

 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem, n=%D\n\n",n);

 43:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 44:      Compute the operator matrix that defines the eigensystem, Ax=kx
 45:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 47:   MatCreate(PETSC_COMM_WORLD,&A);
 48:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 49:   MatSetFromOptions(A);
 50:   MatSetUp(A);

 52:   MatGetOwnershipRange(A,&Istart,&Iend);
 53:   for (i=Istart;i<Iend;i++) {
 54:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 55:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 56:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 57:   }
 58:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 59:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 61:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 62:                         Create the eigensolver
 63:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 64:   EPSCreate(PETSC_COMM_WORLD,&eps);
 65:   EPSSetOperators(eps,A,NULL);
 66:   EPSSetProblemType(eps,EPS_HEP);
 67:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);
 68:   EPSSetFromOptions(eps);

 70:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 71:                     Solve for largest eigenvalues
 72:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 73:   EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL);
 74:   EPSSolve(eps);
 75:   PetscPrintf(PETSC_COMM_WORLD," - - - Largest eigenvalues - - -\n");
 76:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);

 78:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 79:                     Solve for smallest eigenvalues
 80:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 81:   EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);
 82:   EPSSolve(eps);
 83:   PetscPrintf(PETSC_COMM_WORLD," - - - Smallest eigenvalues - - -\n");
 84:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);

 86:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 87:                     Solve for interior eigenvalues (target=2.1)
 88:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 89:   EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);
 90:   EPSSetTarget(eps,2.1);
 91:   PetscObjectTypeCompare((PetscObject)eps,EPSLANCZOS,&flg);
 92:   if (flg) {
 93:     EPSGetST(eps,&st);
 94:     STSetType(st,STSINVERT);
 95:   } else {
 96:     PetscObjectTypeCompare((PetscObject)eps,EPSKRYLOVSCHUR,&flg);
 97:     if (!flg) {
 98:       PetscObjectTypeCompare((PetscObject)eps,EPSARNOLDI,&flg);
 99:     }
100:     if (flg) {
101:       EPSSetExtraction(eps,EPS_HARMONIC);
102:     }
103:   }
104:   EPSSolve(eps);
105:   PetscPrintf(PETSC_COMM_WORLD," - - - Interior eigenvalues - - -\n");
106:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);

108:   EPSDestroy(&eps);
109:   MatDestroy(&A);
110:   SlepcFinalize();
111:   return ierr;
112: }
slepc-3.7.4/src/eps/examples/tests/output/0000755000175000017500000000000013107004621020061 5ustar jromanjromanslepc-3.7.4/src/eps/examples/tests/output/test5_1_complex.out0000644000175000017500000000171713107004621023633 0ustar jromanjromaneps type krylovschur Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.91999-0.01011i, 5.79911-0.07099i, 5.45754+0.00133i, 4.67482-0.10141i eps type arnoldi Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.91999-0.01011i, 5.79911-0.07099i, 5.45754+0.00133i, 4.67482-0.10141i eps type gd Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.91999-0.01011i, 5.79911-0.07099i, 5.45754+0.00133i, 4.67482-0.10141i eps type jd Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.91999-0.01011i, 5.79911-0.07099i, 5.45754+0.00133i, 4.67482-0.10141i eps type gd2 Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.91999-0.01011i, 5.79911-0.07099i, 5.45754+0.00133i, 4.67482-0.10141i slepc-3.7.4/src/eps/examples/tests/output/test15f_1.out0000644000175000017500000000102513107004621022323 0ustar jromanjroman 1-D Laplacian Eigenproblem, n = 30 (Fortran) 1 EPS nconv= 0 first unconverged value (error) 3.9875 (0.648E-02) 2 EPS nconv= 0 first unconverged value (error) 3.9897 (0.203E-02) 3 EPS nconv= 0 first unconverged value (error) 3.9897 (0.129E-04) 4 EPS nconv= 1 first unconverged value (error) 3.9591 (0.361E-07) Solution method: krylovschur Number of requested eigenvalues: 1 All requested eigenvalues computed up to the required tolerance: 3.98974 slepc-3.7.4/src/eps/examples/tests/output/test6_1.out0000644000175000017500000000141413107004621022077 0ustar jromanjromaneps type krylovschur Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type arnoldi Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type gd Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type jd Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type gd2 Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 slepc-3.7.4/src/eps/examples/tests/output/test10_1.out0000644000175000017500000000265713107004621022164 0ustar jromanjromaneps type krylovschur Fiedler vector of a 2-D regular mesh, N=110 (10x11 grid) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.08101, 0.09789, 0.17890, 0.31749 eps type arnoldi Fiedler vector of a 2-D regular mesh, N=110 (10x11 grid) Solution method: arnoldi Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.08101, 0.09789, 0.17890, 0.31749 eps type lanczos Fiedler vector of a 2-D regular mesh, N=110 (10x11 grid) Solution method: lanczos Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.08101, 0.09789, 0.17890, 0.31749 eps type gd Fiedler vector of a 2-D regular mesh, N=110 (10x11 grid) Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.08101, 0.09789, 0.17890, 0.31749 eps type jd Fiedler vector of a 2-D regular mesh, N=110 (10x11 grid) Solution method: jd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.08101, 0.09789, 0.17890, 0.31749 eps type gd2 Fiedler vector of a 2-D regular mesh, N=110 (10x11 grid) Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.08101, 0.09789, 0.17890, 0.31749 slepc-3.7.4/src/eps/examples/tests/output/test16_1.out0000644000175000017500000000024213107004621022156 0ustar jromanjroman Tridiagonal Eigenproblem, n=200 All requested eigenvalues computed up to the required tolerance: 0.01463, -0.01663, 0.04589, -0.04789, 0.07713, -0.07913 slepc-3.7.4/src/eps/examples/tests/output/test9_1.out0000644000175000017500000000205513107004621022104 0ustar jromanjromaneps type krylovschur Markov Model, N=120 (m=15) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 1.00000, -1.00000, 0.97137, -0.97137 eps type arnoldi Markov Model, N=120 (m=15) Solution method: arnoldi Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 1.00000, -1.00000, 0.97137, -0.97137 eps type gd Markov Model, N=120 (m=15) Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 1.00000, -1.00000, 0.97137, -0.97137 eps type jd Markov Model, N=120 (m=15) Solution method: jd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 1.00000, -1.00000, 0.97137, -0.97137 eps type gd2 Markov Model, N=120 (m=15) Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 1.00000, -1.00000, 0.97137, -0.97137 slepc-3.7.4/src/eps/examples/tests/output/test11_1.out0000644000175000017500000000204013107004621022147 0ustar jromanjromaneps type krylovschur Markov Model, N=120 (m=15) Searching closest eigenvalues to the right of 0.5. Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.51928, 0.55740, 0.57028, 0.57143 eps type arnoldi Markov Model, N=120 (m=15) Searching closest eigenvalues to the right of 0.5. Solution method: arnoldi Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.51928, 0.55740, 0.57028, 0.57143 eps type gd Markov Model, N=120 (m=15) Searching closest eigenvalues to the right of 0.5. Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.51928, 0.55740, 0.57028, 0.57143 eps type jd Markov Model, N=120 (m=15) Searching closest eigenvalues to the right of 0.5. Solution method: jd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 0.51928, 0.55740, 0.57028, 0.57143 slepc-3.7.4/src/eps/examples/tests/output/test2_1.out0000644000175000017500000000542213107004621022076 0ustar jromanjromaneps type krylovschur 1-D Laplacian Eigenproblem, n=30 - - - Largest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 - - - Smallest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 0.01026, 0.04094, 0.09172, 0.16208 - - - Interior eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 2.10130, 1.89870, 2.30286, 2.50131 eps type arnoldi 1-D Laplacian Eigenproblem, n=30 - - - Largest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 - - - Smallest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 0.01026, 0.04094, 0.09172, 0.16208 - - - Interior eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 2.10130, 1.89870, 2.30286, 2.50131 eps type lanczos 1-D Laplacian Eigenproblem, n=30 - - - Largest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 - - - Smallest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 0.01026, 0.04094, 0.09172, 0.16208 - - - Interior eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 2.10130, 1.89870, 2.30286, 2.50131 eps type gd 1-D Laplacian Eigenproblem, n=30 - - - Largest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 - - - Smallest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 0.01026, 0.04094, 0.09172, 0.16208 - - - Interior eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 2.10130, 1.89870, 2.30286, 2.50131 eps type jd 1-D Laplacian Eigenproblem, n=30 - - - Largest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 - - - Smallest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 0.01026, 0.04094, 0.09172, 0.16208 - - - Interior eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 2.10130, 1.89870, 2.30286, 2.50131 eps type gd2 1-D Laplacian Eigenproblem, n=30 - - - Largest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 - - - Smallest eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 0.01026, 0.04094, 0.09172, 0.16208 - - - Interior eigenvalues - - - All requested eigenvalues computed up to the required tolerance: 2.10130, 1.89870, 2.30286, 2.50131 slepc-3.7.4/src/eps/examples/tests/output/test3_1.out0000644000175000017500000000362413107004621022101 0ustar jromanjromaneps type krylovschur Tridiagonal with random diagonal, n=30 - - - First matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61861, 2.53982, 2.46239, 2.33322 - - - Second matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61224, 2.58655, 2.55415, 2.40928 eps type arnoldi Tridiagonal with random diagonal, n=30 - - - First matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61861, 2.53982, 2.46239, 2.33322 - - - Second matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61224, 2.58655, 2.55415, 2.40928 eps type lanczos Tridiagonal with random diagonal, n=30 - - - First matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61861, 2.53982, 2.46239, 2.33322 - - - Second matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61224, 2.58655, 2.55415, 2.40928 eps type gd Tridiagonal with random diagonal, n=30 - - - First matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61861, 2.53982, 2.46239, 2.33322 - - - Second matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61224, 2.58655, 2.55415, 2.40928 eps type jd Tridiagonal with random diagonal, n=30 - - - First matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61861, 2.53982, 2.46239, 2.33322 - - - Second matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61224, 2.58655, 2.55415, 2.40928 eps type gd2 Tridiagonal with random diagonal, n=30 - - - First matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61861, 2.53982, 2.46239, 2.33322 - - - Second matrix - - - All requested eigenvalues computed up to the required tolerance: 2.61224, 2.58655, 2.55415, 2.40928 slepc-3.7.4/src/eps/examples/tests/output/test1_2.out0000644000175000017500000000120113107004621022065 0ustar jromanjroman Generalized Symmetric Eigenproblem, N=2025 (45x45 grid) Found 48 eigenvalues, all of them computed up to the required tolerance: 0.12369, 0.15282, 0.15532, 0.19855, 0.20105, 0.25744, 0.25947, 0.27505, 0.30293, 0.30894, 0.37736, 0.38239, 0.38822, 0.39051, 0.43542, 0.44727, 0.48344, 0.51036, 0.51809, 0.53715, 0.55101, 0.59457, 0.60776, 0.61641, 0.62306, 0.66816, 0.68143, 0.70270, 0.73630, 0.74253, 0.77075, 0.78191, 0.78385, 0.80544, 0.83744, 0.86049, 0.88990, 0.90049, 0.91944, 0.94022, 0.95228, 0.96609, 0.98996, 0.99688, 1.03490, 1.06773, 1.07362, 1.09706 Level of orthogonality below the tolerance slepc-3.7.4/src/eps/examples/tests/output/test5_1.out0000644000175000017500000000143313107004621022077 0ustar jromanjromaneps type krylovschur Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.92072, 5.80648, 5.45756, 4.70098 eps type arnoldi Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.92072, 5.80648, 5.45756, 4.70098 eps type gd Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.92072, 5.80648, 5.45756, 4.70098 eps type jd Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.92072, 5.80648, 5.45756, 4.70098 eps type gd2 Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 6.92072, 5.80648, 5.45756, 4.70098 slepc-3.7.4/src/eps/examples/tests/output/test14_1.out0000644000175000017500000000252213107004621022157 0ustar jromanjroman Diagonal Eigenproblem, n=20 Mat Object: 1 MPI processes type: seqaij row 0: (0, 1.) row 1: (1, 2.) row 2: (2, 3.) row 3: (3, 4.) row 4: (4, 5.) row 5: (5, 6.) row 6: (6, 7.) row 7: (7, 8.) row 8: (8, 9.) row 9: (9, 10.) row 10: (10, 11.) row 11: (11, 12.) row 12: (12, 13.) row 13: (13, 14.) row 14: (14, 15.) row 15: (15, 16.) row 16: (16, 17.) row 17: (17, 18.) row 18: (18, 19.) row 19: (19, 20.) Type set to krylovschur Problem type before changing = 0 ... changed to 1. hermitian Extraction before changing = 0 ... changed to 1 Balance: ONESIDE, its=8, cutoff=1e-06 Which = 7, target = 4.8 Dimensions: nev=4, ncv=0, mpd=0 Tolerance = 0.00022, max_its = 200 Convergence test = 0 ST Object: 1 MPI processes type not yet set shift: 0. number of matrices: 1 KSP Object: (st_) 1 MPI processes type not yet set maximum iterations=10000, initial guess is zero tolerances: relative=1e-08, absolute=1e-50, divergence=10000. left preconditioning using DEFAULT norm type for convergence test PC Object: (st_) 1 MPI processes type not yet set PC has not been set up so information may be incomplete DS Object: 1 MPI processes type not yet set Finished - converged reason = 1, its=2 All requested eigenvalues computed up to the required tolerance: 5.00000, 4.00000, 6.00000, 3.00000 slepc-3.7.4/src/eps/examples/tests/output/test5_blopex_complex.out0000644000175000017500000000022013107004621024750 0ustar jromanjroman Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 0.93400, 1.83992, 2.38424, 3.01550 slepc-3.7.4/src/eps/examples/tests/output/test1_1.out0000644000175000017500000000252413107004621022075 0ustar jromanjromaneps type krylovschur Generalized Symmetric Eigenproblem, N=2025 (45x45 grid) All requested eigenvalues computed up to the required tolerance: 29.73524, 29.67536, 29.58873, 29.46785 Level of orthogonality below the tolerance eps type arnoldi Generalized Symmetric Eigenproblem, N=2025 (45x45 grid) All requested eigenvalues computed up to the required tolerance: 29.73524, 29.67536, 29.58873, 29.46785 Level of orthogonality below the tolerance eps type lanczos Generalized Symmetric Eigenproblem, N=2025 (45x45 grid) All requested eigenvalues computed up to the required tolerance: 29.73524, 29.67536, 29.58873, 29.46785 Level of orthogonality below the tolerance eps type gd Generalized Symmetric Eigenproblem, N=2025 (45x45 grid) All requested eigenvalues computed up to the required tolerance: 29.73524, 29.67536, 29.58873, 29.46785 Level of orthogonality below the tolerance eps type jd Generalized Symmetric Eigenproblem, N=2025 (45x45 grid) All requested eigenvalues computed up to the required tolerance: 29.73524, 29.67536, 29.58873, 29.46785 Level of orthogonality below the tolerance eps type gd2 Generalized Symmetric Eigenproblem, N=2025 (45x45 grid) All requested eigenvalues computed up to the required tolerance: 29.73524, 29.67536, 29.58873, 29.46785 Level of orthogonality below the tolerance slepc-3.7.4/src/eps/examples/tests/output/test13_1.out0000644000175000017500000000120013107004621022146 0ustar jromanjromaneps type gd Tridiagonal with zero diagonal, n=30 All requested eigenvalues computed up to the required tolerance: -1.98974 All requested eigenvalues computed up to the required tolerance: -1.98974 eps type jd Tridiagonal with zero diagonal, n=30 All requested eigenvalues computed up to the required tolerance: -1.98974 All requested eigenvalues computed up to the required tolerance: -1.98974 eps type gd2 Tridiagonal with zero diagonal, n=30 All requested eigenvalues computed up to the required tolerance: -1.98974 All requested eigenvalues computed up to the required tolerance: -1.98974 slepc-3.7.4/src/eps/examples/tests/output/test14f_1.out0000644000175000017500000000265513107004621022334 0ustar jromanjroman Diagonal Eigenproblem, n = 20 (Fortran) Mat Object: 1 MPI processes type: seqaij row 0: (0, 1.) row 1: (1, 2.) row 2: (2, 3.) row 3: (3, 4.) row 4: (4, 5.) row 5: (5, 6.) row 6: (6, 7.) row 7: (7, 8.) row 8: (8, 9.) row 9: (9, 10.) row 10: (10, 11.) row 11: (11, 12.) row 12: (12, 13.) row 13: (13, 14.) row 14: (14, 15.) row 15: (15, 16.) row 16: (16, 17.) row 17: (17, 18.) row 18: (18, 19.) row 19: (19, 20.) Type set to krylovschur Problem type before changing = 0 ... changed to 1 hermitian Extraction before changing = 0 ... changed to 1 Balance: 1, its= 8, cutoff=0.000001 Which = 7, target = 4.8 Dimensions: nev= 4, ncv= 0, mpd= 0 Tolerance =0.00022, max_its = 200 Convergence test = 0 ST Object: 1 MPI processes type not yet set shift: 0. number of matrices: 1 KSP Object: (st_) 1 MPI processes type not yet set maximum iterations=10000, initial guess is zero tolerances: relative=1e-08, absolute=1e-35, divergence=10000. left preconditioning using DEFAULT norm type for convergence test PC Object: (st_) 1 MPI processes type not yet set PC has not been set up so information may be incomplete DS Object: 1 MPI processes type not yet set Finished - converged reason = 1, its= 2 All requested eigenvalues computed up to the required tolerance: 5.00000, 4.00000, 6.00000, 3.00000 slepc-3.7.4/src/eps/examples/tests/output/test10_1_ks.out0000644000175000017500000000035113107004621022646 0ustar jromanjroman Fiedler vector of a 2-D regular mesh, N=110 (10x11 grid) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.82110, 7.58462, 7.53702, 7.30054 slepc-3.7.4/src/eps/examples/tests/output/test5_blopex.out0000644000175000017500000000022013107004621023221 0ustar jromanjroman Reading matrix from binary file... All requested eigenvalues computed up to the required tolerance: 0.96775, 1.96775, 2.38197, 3.20382 slepc-3.7.4/src/eps/examples/tests/output/test8_1.out0000644000175000017500000000276713107004621022115 0ustar jromanjromaneps type krylovschur 2-D Laplacian Eigenproblem (matrix-free version), N=100 (10x10 grid) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.60149, 7.36501 eps type arnoldi 2-D Laplacian Eigenproblem (matrix-free version), N=100 (10x10 grid) Solution method: arnoldi Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.60149, 7.36501 eps type lanczos 2-D Laplacian Eigenproblem (matrix-free version), N=100 (10x10 grid) Solution method: lanczos Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.60149, 7.36501 eps type gd 2-D Laplacian Eigenproblem (matrix-free version), N=100 (10x10 grid) Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.60149, 7.36501 eps type jd 2-D Laplacian Eigenproblem (matrix-free version), N=100 (10x10 grid) Solution method: jd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.60149, 7.36501 eps type gd2 2-D Laplacian Eigenproblem (matrix-free version), N=100 (10x10 grid) Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 7.83797, 7.60149, 7.60149, 7.36501 slepc-3.7.4/src/eps/examples/tests/output/test7f_1.out0000644000175000017500000000044013107004621022244 0ustar jromanjroman 1-D Laplacian Eigenproblem, n = 30 (Fortran) Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 slepc-3.7.4/src/eps/examples/tests/output/test12_1.out0000644000175000017500000000141413107004621022154 0ustar jromanjromaneps type krylovschur Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type arnoldi Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type gd Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type jd Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 eps type gd2 Diagonal Eigenproblem, n=30 All requested eigenvalues computed up to the required tolerance: 30.00000, 29.00000, 28.00000, 27.00000 slepc-3.7.4/src/eps/examples/tests/output/test4_1.out0000644000175000017500000000260113107004621022074 0ustar jromanjromaneps type krylovschur 1-D Laplacian Eigenproblem, n=30 EPS type: krylovschur Solution method: krylovschur Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 eps type arnoldi 1-D Laplacian Eigenproblem, n=30 EPS type: arnoldi Solution method: arnoldi Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 eps type lanczos 1-D Laplacian Eigenproblem, n=30 EPS type: lanczos Solution method: lanczos Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 eps type gd 1-D Laplacian Eigenproblem, n=30 EPS type: gd Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 eps type jd 1-D Laplacian Eigenproblem, n=30 EPS type: jd Solution method: jd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 eps type gd2 1-D Laplacian Eigenproblem, n=30 EPS type: gd2 Solution method: gd Number of requested eigenvalues: 4 All requested eigenvalues computed up to the required tolerance: 3.98974, 3.95906, 3.90828, 3.83792 slepc-3.7.4/src/eps/examples/tests/test7f.F.html0000644000175000017500000002646213107004621021021 0ustar jromanjroman
Actual source code: test7f.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./test7f [-help] [-n <n>] [all SLEPc options] 
 21: !
 22: !  Description: Simple example that solves an eigensystem with the EPS object.
 23: !  Same problem as ex1f but with simplified output.
 24: !
 25: !  The command line options are:
 26: !    -n <n>, where <n> = number of grid points = matrix size
 27: !
 28: ! ---------------------------------------------------------------------- 
 29: !
 30:       program main
 31:       implicit none

 33: #include <petsc/finclude/petscsys.h>
 34: #include <petsc/finclude/petscvec.h>
 35: #include <petsc/finclude/petscmat.h>
 36: #include <slepc/finclude/slepcsys.h>
 37: #include <slepc/finclude/slepceps.h>

 39: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 40: !     Declarations
 41: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 42: !
 43: !  Variables:
 44: !     A     operator matrix
 45: !     eps   eigenproblem solver context

 47:       Mat            A
 48:       EPS            eps
 49:       EPSType        tname
 50:       PetscInt       n, i, Istart, Iend
 51:       PetscInt       nev
 52:       PetscInt       col(3)
 53:       PetscInt       i1,i2,i3
 54:       PetscMPIInt    rank
 55:       PetscErrorCode ierr
 56:       PetscBool      flg
 57:       PetscScalar    value(3)

 59: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 60: !     Beginning of program
 61: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 63:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 64:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 65:       n = 30
 66:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 67:      &                        '-n',n,flg,ierr)

 69:       if (rank .eq. 0) then
 70:         write(*,100) n
 71:       endif
 72:  100  format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')

 74: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 75: !     Compute the operator matrix that defines the eigensystem, Ax=kx
 76: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 78:       call MatCreate(PETSC_COMM_WORLD,A,ierr)
 79:       call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
 80:       call MatSetFromOptions(A,ierr)
 81:       call MatSetUp(A,ierr)

 83:       i1 = 1
 84:       i2 = 2
 85:       i3 = 3
 86:       call MatGetOwnershipRange(A,Istart,Iend,ierr)
 87:       if (Istart .eq. 0) then 
 88:         i = 0
 89:         col(1) = 0
 90:         col(2) = 1
 91:         value(1) =  2.0
 92:         value(2) = -1.0
 93:         call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr)
 94:         Istart = Istart+1
 95:       endif
 96:       if (Iend .eq. n) then 
 97:         i = n-1
 98:         col(1) = n-2
 99:         col(2) = n-1
100:         value(1) = -1.0
101:         value(2) =  2.0
102:         call MatSetValues(A,i1,i,i2,col,value,INSERT_VALUES,ierr)
103:         Iend = Iend-1
104:       endif
105:       value(1) = -1.0
106:       value(2) =  2.0
107:       value(3) = -1.0
108:       do i=Istart,Iend-1
109:         col(1) = i-1
110:         col(2) = i
111:         col(3) = i+1
112:         call MatSetValues(A,i1,i,i3,col,value,INSERT_VALUES,ierr)
113:       enddo

115:       call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
116:       call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)

118: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
119: !     Create the eigensolver and display info
120: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

122: !     ** Create eigensolver context
123:       call EPSCreate(PETSC_COMM_WORLD,eps,ierr)

125: !     ** Set operators. In this case, it is a standard eigenvalue problem
126:       call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr)
127:       call EPSSetProblemType(eps,EPS_HEP,ierr)

129: !     ** Set solver parameters at runtime
130:       call EPSSetFromOptions(eps,ierr)

132: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
133: !     Solve the eigensystem
134: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

136:       call EPSSolve(eps,ierr) 

138: !     ** Optional: Get some information from the solver and display it
139:       call EPSGetType(eps,tname,ierr)
140:       if (rank .eq. 0) then
141:         write(*,120) tname
142:       endif
143:  120  format (' Solution method: ',A)
144:       call EPSGetDimensions(eps,nev,PETSC_NULL_INTEGER,                 &
145:      &                      PETSC_NULL_INTEGER,ierr)
146:       if (rank .eq. 0) then
147:         write(*,130) nev
148:       endif
149:  130  format (' Number of requested eigenvalues:',I2)

151: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
152: !     Display solution and clean up
153: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

155:       call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr)
156:       call EPSDestroy(eps,ierr)
157:       call MatDestroy(A,ierr)

159:       call SlepcFinalize(ierr)
160:       end

slepc-3.7.4/src/eps/examples/tests/test5.c.html0000644000175000017500000002177713107004621020712 0ustar jromanjroman
Actual source code: test5.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test EPS with different builds with a matrix loaded from a file.\n"
 23:   "This test is based on ex4.c in tutorials.\n"
 24:   "It loads test matrices available in PETSc's distribution.\n"
 25:   "Add -symm or -herm to select the symmetric/Hermitian matrix.\n\n";

 27: #include <slepceps.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            A;               /* operator matrix */
 34:   EPS            eps;             /* eigenproblem solver context */
 35:   char           filename[PETSC_MAX_PATH_LEN];
 36:   const char     *prefix,*scalar,*ints,*floats;
 37:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 38:   PetscViewer    viewer;
 39:   PetscBool      flg,symm;

 42:   SlepcInitialize(&argc,&argv,(char*)0,help);

 44:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 45:         Load the operator matrix that defines the eigensystem, Ax=kx
 46:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 47:   PetscOptionsHasName(NULL,NULL,"-symm",&symm);
 48:   PetscOptionsHasName(NULL,NULL,"-herm",&flg);
 49:   if (flg) symm=PETSC_TRUE;
 50: #if defined(PETSC_USE_COMPLEX)
 51:   prefix = symm? "hpd": "nh";
 52:   scalar = "complex";
 53: #else
 54:   prefix = symm? "spd": "ns";
 55:   scalar = "real";
 56: #endif
 57: #if defined(PETSC_USE_64BIT_INDICES)
 58:   ints   = "int64";
 59: #else
 60:   ints   = "int32";
 61: #endif
 62: #if defined(PETSC_USE_REAL_DOUBLE)
 63:   floats = "float64";
 64: #elif defined(PETSC_USE_REAL_SINGLE)
 65:   floats = "float32";
 66: #endif

 68:   PetscSNPrintf(filename,PETSC_MAX_PATH_LEN,"%s/share/petsc/datafiles/matrices/%s-%s-%s-%s",PETSC_DIR,prefix,scalar,ints,floats);
 69:   PetscPrintf(PETSC_COMM_WORLD,"\nReading matrix from binary file...\n\n");
 70:   PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);
 71:   MatCreate(PETSC_COMM_WORLD,&A);
 72:   MatSetFromOptions(A);
 73:   MatLoad(A,viewer);
 74:   PetscViewerDestroy(&viewer);

 76:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 77:                      Create the eigensolver
 78:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 79:   EPSCreate(PETSC_COMM_WORLD,&eps);
 80:   EPSSetOperators(eps,A,NULL);
 81:   if (symm) {
 82:     EPSSetProblemType(eps,EPS_HEP);
 83:   } else {
 84:     EPSSetProblemType(eps,EPS_NHEP);
 85:   }
 86:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);
 87:   EPSSetFromOptions(eps);

 89:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 90:                 Solve the eigensystem and display solution
 91:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 92:   EPSSolve(eps);
 93:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
 94:   EPSDestroy(&eps);
 95:   MatDestroy(&A);
 96:   SlepcFinalize();
 97:   return ierr;
 98: }

slepc-3.7.4/src/eps/examples/tests/index.html0000644000175000017500000000520613107004621020521 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

test1.c: Tests B-orthonormality of eigenvectors in a GHEP problem
test2.c: Tests multiple calls to EPSSolve with the same matrix
test3.c: Tests multiple calls to EPSSolve with different matrix
test4.c: Test the solution of a HEP without calling EPSSetFromOptions (based on ex1
test5.c: Test EPS with different builds with a matrix loaded from a file
test6.c: Diagonal eigenproblem
test8.c: Solves the same eigenproblem as in example ex2, but using a shell matrix
test9.c: Eigenvalue problem associated with a Markov model of a random walk on a triangular grid
test10.c: Computes the smallest nonzero eigenvalue of the Laplacian of a graph
test11.c: Solves the same problem as in ex5, but with a user-defined sorting criterion
test12.c: Diagonal eigenproblem
test13.c: Test EPSSetArbitrarySelection
test14.c: Test EPS interface functions
test16.c: Tests a user-defined convergence test
makefile
slepc-3.7.4/src/eps/examples/tests/test8.c0000644000175000017500000001460413107004621017741 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. " "The problem is a standard symmetric eigenproblem corresponding to the 2-D Laplacian operator.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in both x and y dimensions.\n\n"; #include #include /* User-defined routines */ PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y); PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscMPIInt size; PetscInt N,n=10,nev; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); if (size != 1) SETERRQ(PETSC_COMM_WORLD,1,"This is a uniprocessor example only"); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); N = n*n; ierr = PetscPrintf(PETSC_COMM_WORLD,"\n2-D Laplacian Eigenproblem (matrix-free version), N=%D (%Dx%D grid)\n\n",N,n,n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,&n,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Laplacian2D);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Laplacian2D);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Laplacian2D);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr); ierr = EPSSetTolerances(eps,tol,PETSC_DEFAULT);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } /* Compute the matrix vector multiplication y<---T*x where T is a nx by nx tridiagonal matrix with DD on the diagonal, DL on the subdiagonal, and DU on the superdiagonal. */ static void tv(int nx,const PetscScalar *x,PetscScalar *y) { PetscScalar dd,dl,du; int j; dd = 4.0; dl = -1.0; du = -1.0; y[0] = dd*x[0] + du*x[1]; for (j=1;j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Diagonal eigenproblem. Illustrates use of shell preconditioner.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions = matrix dimension.\n" " -seed , where = seed for random number generation.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "PCApply_User" PetscErrorCode PCApply_User(PC pc,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBeginUser; ierr = VecCopy(x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ EPS eps; /* eigenproblem solver context */ Vec v0; /* initial vector */ PetscRandom rand; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscInt n=30,i,Istart,Iend,seed=0x12345678; PetscErrorCode ierr; ST st; KSP ksp; PC pc; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test EPS with different builds with a matrix loaded from a file.\n" "This test is based on ex4.c in tutorials.\n" "It loads test matrices available in PETSc's distribution.\n" "Add -symm or -herm to select the symmetric/Hermitian matrix.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ char filename[PETSC_MAX_PATH_LEN]; const char *prefix,*scalar,*ints,*floats; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscViewer viewer; PetscBool flg,symm; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscOptionsHasName(NULL,NULL,"-symm",&symm);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-herm",&flg);CHKERRQ(ierr); if (flg) symm=PETSC_TRUE; #if defined(PETSC_USE_COMPLEX) prefix = symm? "hpd": "nh"; scalar = "complex"; #else prefix = symm? "spd": "ns"; scalar = "real"; #endif #if defined(PETSC_USE_64BIT_INDICES) ints = "int64"; #else ints = "int32"; #endif #if defined(PETSC_USE_REAL_DOUBLE) floats = "float64"; #elif defined(PETSC_USE_REAL_SINGLE) floats = "float32"; #endif ierr = PetscSNPrintf(filename,PETSC_MAX_PATH_LEN,"%s/share/petsc/datafiles/matrices/%s-%s-%s-%s",PETSC_DIR,prefix,scalar,ints,floats);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nReading matrix from binary file...\n\n");CHKERRQ(ierr); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatLoad(A,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); if (symm) { ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr); } else { ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); } ierr = EPSSetTolerances(eps,tol,PETSC_DEFAULT);CHKERRQ(ierr); ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem and display solution - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/eps/examples/tests/test13.c.html0000644000175000017500000002324113107004621020755 0ustar jromanjroman

Actual source code: test13.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test EPSSetArbitrarySelection.\n\n";

 24: #include <slepceps.h>

 28: PetscErrorCode MyArbitrarySelection(PetscScalar eigr,PetscScalar eigi,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)
 29: {
 30:   PetscErrorCode  ierr;
 31:   Vec             xref = *(Vec*)ctx;

 34:   VecDot(xr,xref,rr);
 35:   *rr = PetscAbsScalar(*rr);
 36:   if (ri) *ri = 0.0;
 37:   return(0);
 38: }

 42: int main(int argc,char **argv)
 43: {
 44:   Mat            A;           /* problem matrices */
 45:   EPS            eps;         /* eigenproblem solver context */
 46:   PetscScalar    seigr,seigi;
 47:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 48:   Vec            sxr,sxi;
 49:   PetscInt       n=30,i,Istart,Iend,nconv;

 52:   SlepcInitialize(&argc,&argv,(char*)0,help);

 54:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 55:   PetscPrintf(PETSC_COMM_WORLD,"\nTridiagonal with zero diagonal, n=%D\n\n",n);

 57:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 58:            Create matrix tridiag([-1 0 -1])
 59:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 60:   MatCreate(PETSC_COMM_WORLD,&A);
 61:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 62:   MatSetFromOptions(A);
 63:   MatSetUp(A);

 65:   MatGetOwnershipRange(A,&Istart,&Iend);
 66:   for (i=Istart;i<Iend;i++) {
 67:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 68:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 69:   }
 70:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 71:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 73:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 74:                         Create the eigensolver
 75:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 76:   EPSCreate(PETSC_COMM_WORLD,&eps);
 77:   EPSSetProblemType(eps,EPS_HEP);
 78:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);
 79:   EPSSetOperators(eps,A,NULL);
 80:   EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);
 81:   EPSSetFromOptions(eps);

 83:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 84:                 Solve eigenproblem and store some solution
 85:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 86:   EPSSolve(eps);
 87:   MatCreateVecs(A,&sxr,NULL);
 88:   MatCreateVecs(A,&sxi,NULL);
 89:   EPSGetConverged(eps,&nconv);
 90:   if (nconv>0) {
 91:     EPSGetEigenpair(eps,0,&seigr,&seigi,sxr,sxi);
 92:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);

 94:     /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 95:                  Solve eigenproblem using an arbitrary selection
 96:        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 97:     EPSSetArbitrarySelection(eps,MyArbitrarySelection,&sxr);
 98:     EPSSetWhichEigenpairs(eps,EPS_LARGEST_MAGNITUDE);
 99:     EPSSolve(eps);
100:     EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
101:   } else {
102:     PetscPrintf(PETSC_COMM_WORLD,"Problem: no eigenpairs converged.\n");
103:   }

105:   EPSDestroy(&eps);
106:   VecDestroy(&sxr);
107:   VecDestroy(&sxi);
108:   MatDestroy(&A);
109:   SlepcFinalize();
110:   return ierr;
111: }
slepc-3.7.4/src/eps/examples/tests/test9.c0000644000175000017500000002027113107004621017737 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. " "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n" "This example illustrates how the user can set the initial vector.\n\n" "The command line options are:\n" " -m , where = number of grid subdivisions in each dimension.\n\n"; #include /* User-defined routines */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A); PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Vec v0; /* initial vector */ Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ EPSType type; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscInt N,m=15,nev; PetscScalar origin=0.0; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); N = m*(m+1)/2; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n\n",N,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatMarkovModel(m,A);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); ierr = EPSSetTolerances(eps,tol,PETSC_DEFAULT);CHKERRQ(ierr); /* Set the custom comparing routine in order to obtain the eigenvalues closest to the target on the right only */ ierr = EPSSetEigenvalueComparison(eps,MyEigenSort,&origin);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* Set the initial vector. This is optional, if not done the initial vector is set to random values */ ierr = MatCreateVecs(A,&v0,NULL);CHKERRQ(ierr); ierr = VecSetValue(v0,0,-1.5,INSERT_VALUES);CHKERRQ(ierr); ierr = VecSetValue(v0,1,2.1,INSERT_VALUES);CHKERRQ(ierr); ierr = VecAssemblyBegin(v0);CHKERRQ(ierr); ierr = VecAssemblyEnd(v0);CHKERRQ(ierr); ierr = EPSSetInitialSpace(eps,1,&v0);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = VecDestroy(&v0);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMarkovModel" /* Matrix generator for a Markov model of a random walk on a triangular grid. This subroutine generates a test matrix that models a random walk on a triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a FORTRAN subroutine to calculate the dominant invariant subspaces of a real matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295 (1980) ]. These matrices provide reasonably easy test problems for eigenvalue algorithms. The transpose of the matrix is stochastic and so it is known that one is an exact eigenvalue. One seeks the eigenvector of the transpose associated with the eigenvalue unity. The problem is to calculate the steady state probability distribution of the system, which is the eigevector associated with the eigenvalue one and scaled in such a way that the sum all the components is equal to one. Note: the code will actually compute the transpose of the stochastic matrix that contains the transition probabilities. */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A) { const PetscReal cst = 0.5/(PetscReal)(m-1); PetscReal pd,pu; PetscInt Istart,Iend,i,j,jmax,ix=0; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=1;i<=m;i++) { jmax = m-i+1; for (j=1;j<=jmax;j++) { ix = ix + 1; if (ix-1Iend) continue; /* compute only owned rows */ if (j!=jmax) { pd = cst*(PetscReal)(i+j-1); /* north */ if (i==1) { ierr = MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);CHKERRQ(ierr); } /* east */ if (j==1) { ierr = MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);CHKERRQ(ierr); } } /* south */ pu = 0.5 - cst*(PetscReal)(i+j-3); if (j>1) { ierr = MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);CHKERRQ(ierr); } /* west */ if (i>1) { ierr = MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);CHKERRQ(ierr); } } } ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MyEigenSort" /* Function for user-defined eigenvalue ordering criterion. Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose one of them as the preferred one according to the criterion. In this example, the preferred value is the one furthest to the origin. */ PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx) { PetscScalar origin = *(PetscScalar*)ctx; PetscReal d; PetscFunctionBeginUser; d = (SlepcAbsEigenvalue(br-origin,bi) - SlepcAbsEigenvalue(ar-origin,ai))/PetscMax(SlepcAbsEigenvalue(ar-origin,ai),SlepcAbsEigenvalue(br-origin,bi)); *r = d > PETSC_SQRT_MACHINE_EPSILON ? 1 : (d < -PETSC_SQRT_MACHINE_EPSILON ? -1 : PetscSign(PetscRealPart(br))); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tests/test11.c0000644000175000017500000002156013107004621020012 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion." "It is a standard nonsymmetric eigenproblem with real eigenvalues and the rightmost eigenvalue is known to be 1.\n" "This example illustrates how the user can set a custom spectrum selection.\n\n" "The command line options are:\n" " -m , where = number of grid subdivisions in each dimension.\n\n"; #include /* User-defined routines */ PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx); PetscErrorCode MatMarkovModel(PetscInt m,Mat A); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Vec v0; /* initial vector */ Mat A; /* operator matrix */ EPS eps; /* eigenproblem solver context */ ST st; /* spectral transformation associated */ EPSType type; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscScalar target=0.5; PetscInt N,m=15,nev; PetscErrorCode ierr; char str[50]; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); N = m*(m+1)/2; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nMarkov Model, N=%D (m=%D)\n",N,m);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-target",&target,NULL);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,target,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Searching closest eigenvalues to the right of %s.\n\n",str);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatMarkovModel(m,A);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = EPSCreate(PETSC_COMM_WORLD,&eps);CHKERRQ(ierr); /* Set operators. In this case, it is a standard eigenvalue problem */ ierr = EPSSetOperators(eps,A,NULL);CHKERRQ(ierr); ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr); ierr = EPSSetTolerances(eps,tol,PETSC_DEFAULT);CHKERRQ(ierr); /* Set the custom comparing routine in order to obtain the eigenvalues closest to the target on the right only */ ierr = EPSSetEigenvalueComparison(eps,MyEigenSort,&target);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = EPSSetFromOptions(eps);CHKERRQ(ierr); /* Set the preconditioner based on A - target * I */ ierr = EPSGetST(eps,&st);CHKERRQ(ierr); ierr = STSetShift(st,target);CHKERRQ(ierr); /* Set the initial vector. This is optional, if not done the initial vector is set to random values */ ierr = MatCreateVecs(A,&v0,NULL);CHKERRQ(ierr); ierr = VecSet(v0,1.0);CHKERRQ(ierr); ierr = EPSSetInitialSpace(eps,1,&v0);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSSolve(eps);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = EPSGetType(eps,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = EPSGetDimensions(eps,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);CHKERRQ(ierr); ierr = EPSDestroy(&eps);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = VecDestroy(&v0);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } #undef __FUNCT__ #define __FUNCT__ "MatMarkovModel" /* Matrix generator for a Markov model of a random walk on a triangular grid. This subroutine generates a test matrix that models a random walk on a triangular grid. This test example was used by G. W. Stewart ["{SRRIT} - a FORTRAN subroutine to calculate the dominant invariant subspaces of a real matrix", Tech. report. TR-514, University of Maryland (1978).] and in a few papers on eigenvalue problems by Y. Saad [see e.g. LAA, vol. 34, pp. 269-295 (1980) ]. These matrices provide reasonably easy test problems for eigenvalue algorithms. The transpose of the matrix is stochastic and so it is known that one is an exact eigenvalue. One seeks the eigenvector of the transpose associated with the eigenvalue unity. The problem is to calculate the steady state probability distribution of the system, which is the eigevector associated with the eigenvalue one and scaled in such a way that the sum all the components is equal to one. Note: the code will actually compute the transpose of the stochastic matrix that contains the transition probabilities. */ PetscErrorCode MatMarkovModel(PetscInt m,Mat A) { const PetscReal cst = 0.5/(PetscReal)(m-1); PetscReal pd,pu; PetscInt Istart,Iend,i,j,jmax,ix=0; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=1;i<=m;i++) { jmax = m-i+1; for (j=1;j<=jmax;j++) { ix = ix + 1; if (ix-1Iend) continue; /* compute only owned rows */ if (j!=jmax) { pd = cst*(PetscReal)(i+j-1); /* north */ if (i==1) { ierr = MatSetValue(A,ix-1,ix,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix,pd,INSERT_VALUES);CHKERRQ(ierr); } /* east */ if (j==1) { ierr = MatSetValue(A,ix-1,ix+jmax-1,2*pd,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(A,ix-1,ix+jmax-1,pd,INSERT_VALUES);CHKERRQ(ierr); } } /* south */ pu = 0.5 - cst*(PetscReal)(i+j-3); if (j>1) { ierr = MatSetValue(A,ix-1,ix-2,pu,INSERT_VALUES);CHKERRQ(ierr); } /* west */ if (i>1) { ierr = MatSetValue(A,ix-1,ix-jmax-2,pu,INSERT_VALUES);CHKERRQ(ierr); } } } ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MyEigenSort" /* Function for user-defined eigenvalue ordering criterion. Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose one of them as the preferred one according to the criterion. In this example, the preferred value is the one closest to the target, but on the right side. */ PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx) { PetscScalar target = *(PetscScalar*)ctx; PetscReal da,db; PetscBool aisright,bisright; PetscFunctionBeginUser; if (PetscRealPart(target) < PetscRealPart(ar)) aisright = PETSC_TRUE; else aisright = PETSC_FALSE; if (PetscRealPart(target) < PetscRealPart(br)) bisright = PETSC_TRUE; else bisright = PETSC_FALSE; if (aisright == bisright) { /* both are on the same side of the target */ da = SlepcAbsEigenvalue(ar-target,ai); db = SlepcAbsEigenvalue(br-target,bi); if (da < db) *r = -1; else if (da > db) *r = 1; else *r = 0; } else if (aisright && !bisright) *r = -1; /* 'a' is on the right */ else *r = 1; /* 'b' is on the right */ PetscFunctionReturn(0); } slepc-3.7.4/src/eps/examples/tests/test14.c0000644000175000017500000001474613107004621020025 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test EPS interface functions.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B; /* problem matrix */ EPS eps; /* eigenproblem solver context */ ST st; KSP ksp; DS ds; PetscReal cut,tol; PetscScalar target; PetscInt n=20,i,its,nev,ncv,mpd,Istart,Iend; PetscBool flg; EPSConvergedReason reason; EPSType type; EPSExtraction extr; EPSBalance bal; EPSWhich which; EPSConv conv; EPSProblemType ptype; PetscErrorCode ierr; PetscViewerAndFormat *vf; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;iActual source code: test8.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. "
 23:   "The problem is a standard symmetric eigenproblem corresponding to the 2-D Laplacian operator.\n\n"
 24:   "The command line options are:\n"
 25:   "  -n <n>, where <n> = number of grid subdivisions in both x and y dimensions.\n\n";

 27: #include <slepceps.h>
 28: #include <petscblaslapack.h>

 30: /*
 31:    User-defined routines
 32: */
 33: PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y);
 34: PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag);

 38: int main(int argc,char **argv)
 39: {
 40:   Mat            A;               /* operator matrix */
 41:   EPS            eps;             /* eigenproblem solver context */
 42:   EPSType        type;
 43:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON;
 44:   PetscMPIInt    size;
 45:   PetscInt       N,n=10,nev;

 48:   SlepcInitialize(&argc,&argv,(char*)0,help);
 49:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 50:   if (size != 1) SETERRQ(PETSC_COMM_WORLD,1,"This is a uniprocessor example only");

 52:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 53:   N = n*n;
 54:   PetscPrintf(PETSC_COMM_WORLD,"\n2-D Laplacian Eigenproblem (matrix-free version), N=%D (%Dx%D grid)\n\n",N,n,n);

 56:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 57:      Compute the operator matrix that defines the eigensystem, Ax=kx
 58:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 60:   MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,&n,&A);
 61:   MatSetFromOptions(A);
 62:   MatShellSetOperation(A,MATOP_MULT,(void(*)())MatMult_Laplacian2D);
 63:   MatShellSetOperation(A,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Laplacian2D);
 64:   MatShellSetOperation(A,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Laplacian2D);

 66:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 67:                 Create the eigensolver and set various options
 68:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 70:   /*
 71:      Create eigensolver context
 72:   */
 73:   EPSCreate(PETSC_COMM_WORLD,&eps);

 75:   /*
 76:      Set operators. In this case, it is a standard eigenvalue problem
 77:   */
 78:   EPSSetOperators(eps,A,NULL);
 79:   EPSSetProblemType(eps,EPS_HEP);
 80:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);

 82:   /*
 83:      Set solver parameters at runtime
 84:   */
 85:   EPSSetFromOptions(eps);

 87:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 88:                       Solve the eigensystem
 89:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 91:   EPSSolve(eps);

 93:   /*
 94:      Optional: Get some information from the solver and display it
 95:   */
 96:   EPSGetType(eps,&type);
 97:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
 98:   EPSGetDimensions(eps,&nev,NULL,NULL);
 99:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

101:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102:                     Display solution and clean up
103:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

105:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
106:   EPSDestroy(&eps);
107:   MatDestroy(&A);
108:   SlepcFinalize();
109:   return ierr;
110: }

112: /*
113:     Compute the matrix vector multiplication y<---T*x where T is a nx by nx
114:     tridiagonal matrix with DD on the diagonal, DL on the subdiagonal, and
115:     DU on the superdiagonal.
116:  */
117: static void tv(int nx,const PetscScalar *x,PetscScalar *y)
118: {
119:   PetscScalar dd,dl,du;
120:   int         j;

122:   dd  = 4.0;
123:   dl  = -1.0;
124:   du  = -1.0;

126:   y[0] =  dd*x[0] + du*x[1];
127:   for (j=1;j<nx-1;j++)
128:     y[j] = dl*x[j-1] + dd*x[j] + du*x[j+1];
129:   y[nx-1] = dl*x[nx-2] + dd*x[nx-1];
130: }

134: /*
135:     Matrix-vector product subroutine for the 2D Laplacian.

137:     The matrix used is the 2 dimensional discrete Laplacian on unit square with
138:     zero Dirichlet boundary condition.

140:     Computes y <-- A*x, where A is the block tridiagonal matrix

142:                  | T -I          |
143:                  |-I  T -I       |
144:              A = |   -I  T       |
145:                  |        ...  -I|
146:                  |           -I T|

148:     The subroutine TV is called to compute y<--T*x.
149:  */
150: PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)
151: {
152:   void              *ctx;
153:   int               nx,lo,i,j;
154:   const PetscScalar *px;
155:   PetscScalar       *py;
156:   PetscErrorCode    ierr;

159:   MatShellGetContext(A,&ctx);
160:   nx = *(int*)ctx;
161:   VecGetArrayRead(x,&px);
162:   VecGetArray(y,&py);

164:   tv(nx,&px[0],&py[0]);
165:   for (i=0;i<nx;i++) py[i] -= px[nx+i];

167:   for (j=2;j<nx;j++) {
168:     lo = (j-1)*nx;
169:     tv(nx,&px[lo],&py[lo]);
170:     for (i=0;i<nx;i++) py[lo+i] -= px[lo-nx+i] + px[lo+nx+i];
171:   }

173:   lo = (nx-1)*nx;
174:   tv(nx,&px[lo],&py[lo]);
175:   for (i=0;i<nx;i++) py[lo+i] -= px[lo-nx+i];

177:   VecRestoreArrayRead(x,&px);
178:   VecRestoreArray(y,&py);
179:   return(0);
180: }

184: PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)
185: {

189:   VecSet(diag,4.0);
190:   return(0);
191: }

slepc-3.7.4/src/eps/examples/tests/test3.c.html0000644000175000017500000002325513107004621020701 0ustar jromanjroman
Actual source code: test3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Tests multiple calls to EPSSolve with different matrix.\n\n";

 24: #include <slepceps.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat            A1,A2;       /* problem matrices */
 31:   EPS            eps;         /* eigenproblem solver context */
 32:   PetscReal      tol=1000*PETSC_MACHINE_EPSILON,v;
 33:   Vec            d;
 34:   PetscInt       n=30,i,Istart,Iend;
 35:   PetscRandom    myrand;

 38:   SlepcInitialize(&argc,&argv,(char*)0,help);

 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"\nTridiagonal with random diagonal, n=%D\n\n",n);

 43:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 44:            Create matrix tridiag([-1 0 -1])
 45:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 46:   MatCreate(PETSC_COMM_WORLD,&A1);
 47:   MatSetSizes(A1,PETSC_DECIDE,PETSC_DECIDE,n,n);
 48:   MatSetFromOptions(A1);
 49:   MatSetUp(A1);

 51:   MatGetOwnershipRange(A1,&Istart,&Iend);
 52:   for (i=Istart;i<Iend;i++) {
 53:     if (i>0) { MatSetValue(A1,i,i-1,-1.0,INSERT_VALUES); }
 54:     if (i<n-1) { MatSetValue(A1,i,i+1,-1.0,INSERT_VALUES); }
 55:   }
 56:   MatAssemblyBegin(A1,MAT_FINAL_ASSEMBLY);
 57:   MatAssemblyEnd(A1,MAT_FINAL_ASSEMBLY);

 59:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 60:        Create two matrices by filling the diagonal with rand values
 61:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 62:   MatDuplicate(A1,MAT_COPY_VALUES,&A2);
 63:   MatCreateVecs(A1,NULL,&d);
 64:   PetscRandomCreate(PETSC_COMM_WORLD,&myrand);
 65:   PetscRandomSetFromOptions(myrand);
 66:   PetscRandomSetInterval(myrand,0.0,1.0);
 67:   for (i=Istart;i<Iend;i++) {
 68:     PetscRandomGetValueReal(myrand,&v);
 69:     VecSetValue(d,i,v,INSERT_VALUES);
 70:   }
 71:   VecAssemblyBegin(d);
 72:   VecAssemblyEnd(d);
 73:   MatDiagonalSet(A1,d,INSERT_VALUES);
 74:   for (i=Istart;i<Iend;i++) {
 75:     PetscRandomGetValueReal(myrand,&v);
 76:     VecSetValue(d,i,v,INSERT_VALUES);
 77:   }
 78:   VecAssemblyBegin(d);
 79:   VecAssemblyEnd(d);
 80:   MatDiagonalSet(A2,d,INSERT_VALUES);
 81:   VecDestroy(&d);
 82:   PetscRandomDestroy(&myrand);

 84:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 85:                         Create the eigensolver
 86:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 87:   EPSCreate(PETSC_COMM_WORLD,&eps);
 88:   EPSSetProblemType(eps,EPS_HEP);
 89:   EPSSetTolerances(eps,tol,PETSC_DEFAULT);
 90:   EPSSetOperators(eps,A1,NULL);
 91:   EPSSetFromOptions(eps);

 93:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 94:                         Solve first eigenproblem
 95:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 96:   EPSSolve(eps);
 97:   PetscPrintf(PETSC_COMM_WORLD," - - - First matrix - - -\n");
 98:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);

100:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101:                         Solve second eigenproblem
102:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
103:   EPSSetOperators(eps,A2,NULL);
104:   EPSSolve(eps);
105:   PetscPrintf(PETSC_COMM_WORLD," - - - Second matrix - - -\n");
106:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);

108:   EPSDestroy(&eps);
109:   MatDestroy(&A1);
110:   MatDestroy(&A2);
111:   SlepcFinalize();
112:   return ierr;
113: }
slepc-3.7.4/src/eps/examples/tests/test14f.F0000644000175000017500000001706013107004621020126 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Description: Simple example to test the EPS Fortran interface. ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mat A,B EPS eps ST st KSP ksp DS ds PetscReal cut,tol,tolabs PetscScalar tget,value PetscInt n,i,its,Istart,Iend PetscInt nev,ncv,mpd PetscBool flg EPSConvergedReason reason EPSType tname EPSExtraction extr EPSBalance bal EPSWhich which EPSConv conv EPSProblemType ptype PetscMPIInt rank PetscErrorCode ierr SlepcConvMonitor ctx PetscViewerAndFormat vf ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 20 if (rank .eq. 0) then write(*,100) n endif 100 format (/'Diagonal Eigenproblem, n =',I3,' (Fortran)') call MatCreate(PETSC_COMM_WORLD,A,ierr) call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A,ierr) call MatSetUp(A,ierr) call MatGetOwnershipRange(A,Istart,Iend,ierr) do i=Istart,Iend-1 value = i+1 call MatSetValue(A,i,i,value,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create eigensolver and test interface functions ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSCreate(PETSC_COMM_WORLD,eps,ierr) call EPSSetOperators(eps,A,PETSC_NULL_OBJECT,ierr) call EPSGetOperators(eps,B,PETSC_NULL_OBJECT,ierr) call MatView(B,PETSC_NULL_OBJECT,ierr) call EPSSetType(eps,EPSKRYLOVSCHUR,ierr) call EPSGetType(eps,tname,ierr) if (rank .eq. 0) then write(*,110) tname endif 110 format (' Type set to ',A) call EPSGetProblemType(eps,ptype,ierr) if (rank .eq. 0) then write(*,120) ptype endif 120 format (' Problem type before changing = ',I2) call EPSSetProblemType(eps,EPS_HEP,ierr) call EPSGetProblemType(eps,ptype,ierr) if (rank .eq. 0) then write(*,130) ptype endif 130 format (' ... changed to ',I2) call EPSIsGeneralized(eps,flg,ierr) if (flg .and. rank .eq. 0) then write(*,*) 'generalized' endif call EPSIsHermitian(eps,flg,ierr) if (flg .and. rank .eq. 0) then write(*,*) 'hermitian' endif call EPSIsPositive(eps,flg,ierr) if (flg .and. rank .eq. 0) then write(*,*) 'positive' endif call EPSGetExtraction(eps,extr,ierr) if (rank .eq. 0) then write(*,140) extr endif 140 format (' Extraction before changing = ',I2) call EPSSetExtraction(eps,EPS_HARMONIC,ierr) call EPSGetExtraction(eps,extr,ierr) if (rank .eq. 0) then write(*,150) extr endif 150 format (' ... changed to ',I2) its = 8 cut = 1.0e-6 bal = EPS_BALANCE_ONESIDE call EPSSetBalance(eps,bal,its,cut,ierr) call EPSGetBalance(eps,bal,its,cut,ierr) if (rank .eq. 0) then write(*,160) bal,its,cut endif 160 format (' Balance: ',I2,', its=',I2,', cutoff=',F8.6) tget = 4.8 call EPSSetTarget(eps,tget,ierr) call EPSGetTarget(eps,tget,ierr) call EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE,ierr) call EPSGetWhichEigenpairs(eps,which,ierr) if (rank .eq. 0) then write(*,170) which,PetscRealPart(tget) endif 170 format (' Which = ',I2,', target = ',F3.1) nev = 4 call EPSSetDimensions(eps,nev,PETSC_DEFAULT_INTEGER, & & PETSC_DEFAULT_INTEGER,ierr) call EPSGetDimensions(eps,nev,ncv,mpd,ierr) if (rank .eq. 0) then write(*,180) nev,ncv,mpd endif 180 format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2) tol = 2.2e-4 its = 200 call EPSSetTolerances(eps,tol,its,ierr) call EPSGetTolerances(eps,tol,its,ierr) if (rank .eq. 0) then write(*,190) tol,its endif 190 format (' Tolerance =',F7.5,', max_its =',I4) call EPSSetConvergenceTest(eps,EPS_CONV_ABS,ierr) call EPSGetConvergenceTest(eps,conv,ierr) if (rank .eq. 0) then write(*,200) conv endif 200 format (' Convergence test =',I2) call PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD, & & PETSC_VIEWER_DEFAULT,vf,ierr) call EPSMonitorSet(eps,EPSMONITORFIRST,vf, & & PetscViewerAndFormatDestroy,ierr) call SlepcConvMonitorCreate(PETSC_VIEWER_STDOUT_WORLD, & & PETSC_VIEWER_DEFAULT,ctx,ierr) call EPSMonitorSet(eps,EPSMONITORCONVERGED,ctx, & & SlepcConvMonitorDestroy,ierr) call EPSMonitorCancel(eps,ierr) call EPSGetST(eps,st,ierr) call STGetKSP(st,ksp,ierr) tol = 1.e-8 tolabs = 1.e-35 call KSPSetTolerances(ksp,tol,tolabs,PETSC_DEFAULT_REAL, & & PETSC_DEFAULT_INTEGER,ierr) call STView(st,PETSC_NULL_OBJECT,ierr) call EPSGetDS(eps,ds,ierr) call DSView(ds,PETSC_NULL_OBJECT,ierr) call EPSSetFromOptions(eps,ierr) call EPSSolve(eps,ierr) call EPSGetConvergedReason(eps,reason,ierr) call EPSGetIterationNumber(eps,its,ierr) if (rank .eq. 0) then write(*,210) reason,its endif 210 format (' Finished - converged reason =',I2,', its=',I4) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call EPSErrorView(eps,EPS_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr) call EPSDestroy(eps,ierr) call MatDestroy(A,ierr) call SlepcFinalize(ierr) end slepc-3.7.4/src/eps/examples/tests/test14.c.html0000644000175000017500000003473113107004621020764 0ustar jromanjroman
Actual source code: test14.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test EPS interface functions.\n\n";

 24: #include <slepceps.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat                A,B;         /* problem matrix */
 31:   EPS                eps;         /* eigenproblem solver context */
 32:   ST                 st;
 33:   KSP                ksp;
 34:   DS                 ds;
 35:   PetscReal          cut,tol;
 36:   PetscScalar        target;
 37:   PetscInt           n=20,i,its,nev,ncv,mpd,Istart,Iend;
 38:   PetscBool          flg;
 39:   EPSConvergedReason reason;
 40:   EPSType            type;
 41:   EPSExtraction      extr;
 42:   EPSBalance         bal;
 43:   EPSWhich           which;
 44:   EPSConv            conv;
 45:   EPSProblemType     ptype;
 46:   PetscErrorCode     ierr;
 47:   PetscViewerAndFormat *vf;

 49:   SlepcInitialize(&argc,&argv,(char*)0,help);
 50:   PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%D\n\n",n);

 52:   MatCreate(PETSC_COMM_WORLD,&A);
 53:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 54:   MatSetFromOptions(A);
 55:   MatSetUp(A);
 56:   MatGetOwnershipRange(A,&Istart,&Iend);
 57:   for (i=Istart;i<Iend;i++) {
 58:     MatSetValue(A,i,i,i+1,INSERT_VALUES);
 59:   }
 60:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 61:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 63:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 64:              Create eigensolver and test interface functions
 65:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 66:   EPSCreate(PETSC_COMM_WORLD,&eps);
 67:   EPSSetOperators(eps,A,NULL);
 68:   EPSGetOperators(eps,&B,NULL);
 69:   MatView(B,NULL);

 71:   EPSSetType(eps,EPSKRYLOVSCHUR);
 72:   EPSGetType(eps,&type);
 73:   PetscPrintf(PETSC_COMM_WORLD," Type set to %s\n",type);

 75:   EPSGetProblemType(eps,&ptype);
 76:   PetscPrintf(PETSC_COMM_WORLD," Problem type before changing = %d",(int)ptype);
 77:   EPSSetProblemType(eps,EPS_HEP);
 78:   EPSGetProblemType(eps,&ptype);
 79:   PetscPrintf(PETSC_COMM_WORLD," ... changed to %d.",(int)ptype);
 80:   EPSIsGeneralized(eps,&flg);
 81:   if (flg) { PetscPrintf(PETSC_COMM_WORLD," generalized"); }
 82:   EPSIsHermitian(eps,&flg);
 83:   if (flg) { PetscPrintf(PETSC_COMM_WORLD," hermitian"); }
 84:   EPSIsPositive(eps,&flg);
 85:   if (flg) { PetscPrintf(PETSC_COMM_WORLD," positive"); }

 87:   EPSGetExtraction(eps,&extr);
 88:   PetscPrintf(PETSC_COMM_WORLD,"\n Extraction before changing = %d",(int)extr);
 89:   EPSSetExtraction(eps,EPS_HARMONIC);
 90:   EPSGetExtraction(eps,&extr);
 91:   PetscPrintf(PETSC_COMM_WORLD," ... changed to %d\n",(int)extr);

 93:   EPSSetBalance(eps,EPS_BALANCE_ONESIDE,8,1e-6);
 94:   EPSGetBalance(eps,&bal,&its,&cut);
 95:   PetscPrintf(PETSC_COMM_WORLD," Balance: %s, its=%D, cutoff=%g\n",EPSBalanceTypes[bal],its,(double)cut);

 97:   EPSSetTarget(eps,4.8);
 98:   EPSGetTarget(eps,&target);
 99:   EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE);
100:   EPSGetWhichEigenpairs(eps,&which);
101:   PetscPrintf(PETSC_COMM_WORLD," Which = %d, target = %g\n",(int)which,(double)PetscRealPart(target));

103:   EPSSetDimensions(eps,4,PETSC_DEFAULT,PETSC_DEFAULT);
104:   EPSGetDimensions(eps,&nev,&ncv,&mpd);
105:   PetscPrintf(PETSC_COMM_WORLD," Dimensions: nev=%D, ncv=%D, mpd=%D\n",nev,ncv,mpd);

107:   EPSSetTolerances(eps,2.2e-4,200);
108:   EPSGetTolerances(eps,&tol,&its);
109:   PetscPrintf(PETSC_COMM_WORLD," Tolerance = %.5f, max_its = %D\n",(double)tol,its);

111:   EPSSetConvergenceTest(eps,EPS_CONV_ABS);
112:   EPSGetConvergenceTest(eps,&conv);
113:   PetscPrintf(PETSC_COMM_WORLD," Convergence test = %d\n",(int)conv);

115:   PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_DEFAULT,&vf);
116:   EPSMonitorSet(eps,(PetscErrorCode (*)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))EPSMonitorFirst,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
117:   EPSMonitorCancel(eps);

119:   EPSGetST(eps,&st);
120:   STGetKSP(st,&ksp);
121:   KSPSetTolerances(ksp,1e-8,1e-50,PETSC_DEFAULT,PETSC_DEFAULT);
122:   STView(st,NULL);
123:   EPSGetDS(eps,&ds);
124:   DSView(ds,NULL);

126:   EPSSetFromOptions(eps);
127:   EPSSolve(eps);
128:   EPSGetConvergedReason(eps,&reason);
129:   EPSGetIterationNumber(eps,&its);
130:   PetscPrintf(PETSC_COMM_WORLD," Finished - converged reason = %d, its=%D\n",(int)reason,its);

132:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133:                     Display solution and clean up
134:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
135:   EPSErrorView(eps,EPS_ERROR_RELATIVE,NULL);
136:   EPSDestroy(&eps);
137:   MatDestroy(&A);
138:   SlepcFinalize();
139:   return ierr;
140: }
slepc-3.7.4/src/eps/examples/tests/test10.c0000644000175000017500000001231013107004621020002 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\n\n" "This example illustrates EPSSetDeflationSpace(). The example graph corresponds to a " "2-D regular mesh. The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main (int argc,char **argv) { EPS eps; /* eigenproblem solver context */ Mat A; /* operator matrix */ Vec x; EPSType type; PetscInt N,n=10,m,i,j,II,Istart,Iend,nev; PetscScalar w; PetscBool flag; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nFiedler vector of a 2-D regular mesh, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx In this example, A = L(G), where L is the Laplacian of graph G, i.e. Lii = degree of node i, Lij = -1 if edge (i,j) exists in G - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(A,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); w=w+1.0; } if (i0) { ierr = MatSetValue(A,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); w=w+1.0; } if (j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Tests multiple calls to EPSSolve with the same matrix.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ EPS eps; /* eigenproblem solver context */ ST st; PetscReal tol=PetscMax(1000*PETSC_MACHINE_EPSILON,1e-9); PetscInt n=30,i,Istart,Iend; PetscBool flg; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix that defines the eigensystem, Ax=kx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Diagonal eigenproblem.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions = matrix dimension.\n" " -seed , where = seed for random number generation.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A; /* problem matrix */ EPS eps; /* eigenproblem solver context */ Vec v0; /* initial vector */ PetscRandom rand; PetscReal tol=1000*PETSC_MACHINE_EPSILON; PetscInt n=30,i,Istart,Iend,seed=0x12345678; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../include/slepc/private/epsimpl.h ../../include/slepceps.h
DIRS     = interface impls examples f90-mod
LOCDIR   = src/eps/
MANSEC   = EPS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/index.html0000644000175000017500000000317313107004621015542 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

interface/
impls/
examples/
f90-mod/
../../include/slepc/private/epsimpl.h
../../include/slepceps.h
makefile
slepc-3.7.4/src/eps/f90-mod/0000755000175000017500000000000013107004621014714 5ustar jromanjromanslepc-3.7.4/src/eps/f90-mod/makefile0000644000175000017500000000255113107004621016417 0ustar jromanjroman # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_USING_F90' # # Makes Fortran module functions from *.h90 files in include/slepc/finclude # ALL: buildmod_slepc speciallib: buildmod_slepc specialfastlib: buildmod_slepc SPECIALLIB = yes SPECIALFASTLIB = yes CFLAGS = FFLAGS = SOURCEC = SOURCEF = slepcepsmod.F SOURCEH = LIBBASE = libslepceps MANSEC = EPS LOCDIR = src/eps/f90-mod/ CLEANFILES = *.mod include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/f90-mod/makefile.html0000644000175000017500000000552413107004621017365 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#requiresdefine   'PETSC_USING_F90'
#
#   Makes Fortran module functions from *.h90 files in include/slepc/finclude
#
ALL: buildmod_slepc
speciallib: buildmod_slepc
specialfastlib: buildmod_slepc
SPECIALLIB     = yes
SPECIALFASTLIB = yes


CFLAGS     =
FFLAGS     =
SOURCEC    =
SOURCEF    = slepcepsmod.F
SOURCEH    =
LIBBASE    = libslepceps
MANSEC     = EPS
LOCDIR     = src/eps/f90-mod/
CLEANFILES = *.mod

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/f90-mod/slepcepsmod.F0000644000175000017500000000241113107004621017337 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define PETSC_USE_FORTRAN_MODULES module slepcepsdef use slepcst use slepcbv use slepcrg use slepcds #include #include end module module slepceps use slepcepsdef #include end module slepc-3.7.4/src/eps/f90-mod/index.html0000644000175000017500000000260013107004621016707 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

slepcepsmod.F
makefile
slepc-3.7.4/src/eps/f90-mod/slepcepsmod.F.html0000644000175000017500000000574513107004621020317 0ustar jromanjroman

Actual source code: slepcepsmod.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 20: #define PETSC_USE_FORTRAN_MODULES

 22:         module slepcepsdef
 23:         use slepcst
 24:         use slepcbv
 25:         use slepcrg
 26:         use slepcds
 27: #include <slepc/finclude/slepceps.h>
 28: #include <slepc/finclude/ftn-custom/slepcepsdef.h90>
 29:         end module

 31:         module slepceps
 32:         use slepcepsdef
 33: #include <slepc/finclude/slepceps.h90>
 34:         end module

slepc-3.7.4/src/eps/impls/0000755000175000017500000000000013107004621014665 5ustar jromanjromanslepc-3.7.4/src/eps/impls/makefile0000644000175000017500000000213613107004621016367 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepceps DIRS = power subspace krylov davidson cg ciss lapack external LOCDIR = src/eps/impls/ MANSEC = EPS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/0000755000175000017500000000000013107004621016507 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/makefile0000644000175000017500000000213113107004621020204 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepceps DIRS = arpack blopex blzpack primme trlan feast LOCDIR = src/eps/impls/external/ MANSEC = EPS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/blzpack/0000755000175000017500000000000013107004621020135 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/blzpack/makefile0000644000175000017500000000225313107004621021637 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresdefine 'SLEPC_HAVE_BLZPACK' CFLAGS = FFLAGS = SOURCEC = blzpack.c SOURCEF = SOURCEH = blzpackp.h LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/external/blzpack/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/blzpack/blzpackp.h.html0000644000175000017500000001401113107004621023054 0ustar jromanjroman
Actual source code: blzpackp.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private data structure used by the BLZPACK interface

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

  8:    This file is part of SLEPc.

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

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

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


 27: typedef struct {
 28:   PetscBLASInt         block_size;      /* block size */
 29:   PetscBLASInt         slice;           /* use spectrum slicing */
 30:   PetscBLASInt         nsteps;          /* maximum number of steps per run */
 31:   PetscBLASInt         *istor;
 32:   PetscReal            *rstor;
 33:   PetscScalar          *u;
 34:   PetscScalar          *v;
 35:   PetscScalar          *eig;
 36: } EPS_BLZPACK;

 38: /*
 39:    Definition of routines from the BLZPACK package
 40: */

 42: #if defined(SLEPC_BLZPACK_HAVE_UNDERSCORE)
 43: #define SLEPC_BLZPACK(lcase,ucase) lcase##_
 44: #elif defined(SLEPC_BLZPACK_HAVE_CAPS)
 45: #define SLEPC_BLZPACK(lcase,ucase) ucase
 46: #else
 47: #define SLEPC_BLZPACK(lcase,ucase) lcase
 48: #endif

 50: /*
 51:     These are real case, current version of BLZPACK only supports real
 52:     matrices
 53: */

 55: #if defined(PETSC_USE_SINGLE)
 56: /*
 57:    For these machines we must call the single precision Fortran version
 58: */
 59: #define BLZpack_ SLEPC_BLZPACK(blzdrs,BLZDRS)
 60: #else
 61: #define BLZpack_ SLEPC_BLZPACK(blzdrd,BLZDRD)
 62: #endif

 64: #define BLZistorr_ SLEPC_BLZPACK(istorr,ISTORR)
 65: #define BLZrstorr_ SLEPC_BLZPACK(rstorr,RSTORR)

 67: PETSC_EXTERN void BLZpack_(PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*);

 69: PETSC_EXTERN PetscBLASInt BLZistorr_(PetscBLASInt*,const char*,int);
 70: PETSC_EXTERN PetscReal BLZrstorr_(PetscReal*,char*,int);

 72: #endif

slepc-3.7.4/src/eps/impls/external/blzpack/blzpack.c.html0000644000175000017500000011026313107004621022675 0ustar jromanjroman
Actual source code: blzpack.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the BLZPACK package

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>    /*I "slepceps.h" I*/
 25: #include <../src/eps/impls/external/blzpack/blzpackp.h>

 27: PetscErrorCode EPSSolve_BLZPACK(EPS);

 29: const char* blzpack_error[33] = {
 30:   "",
 31:   "illegal data, LFLAG ",
 32:   "illegal data, dimension of (U), (V), (X) ",
 33:   "illegal data, leading dimension of (U), (V), (X) ",
 34:   "illegal data, leading dimension of (EIG) ",
 35:   "illegal data, number of required eigenpairs ",
 36:   "illegal data, Lanczos algorithm block size ",
 37:   "illegal data, maximum number of steps ",
 38:   "illegal data, number of starting vectors ",
 39:   "illegal data, number of eigenpairs provided ",
 40:   "illegal data, problem type flag ",
 41:   "illegal data, spectrum slicing flag ",
 42:   "illegal data, eigenvectors purification flag ",
 43:   "illegal data, level of output ",
 44:   "illegal data, output file unit ",
 45:   "illegal data, LCOMM (MPI or PVM) ",
 46:   "illegal data, dimension of ISTOR ",
 47:   "illegal data, convergence threshold ",
 48:   "illegal data, dimension of RSTOR ",
 49:   "illegal data on at least one PE ",
 50:   "ISTOR(3:14) must be equal on all PEs ",
 51:   "RSTOR(1:3) must be equal on all PEs ",
 52:   "not enough space in ISTOR to start eigensolution ",
 53:   "not enough space in RSTOR to start eigensolution ",
 54:   "illegal data, number of negative eigenvalues ",
 55:   "illegal data, entries of V ",
 56:   "illegal data, entries of X ",
 57:   "failure in computational subinterval ",
 58:   "file I/O error, blzpack.__.BQ ",
 59:   "file I/O error, blzpack.__.BX ",
 60:   "file I/O error, blzpack.__.Q ",
 61:   "file I/O error, blzpack.__.X ",
 62:   "parallel interface error "
 63: };

 67: PetscErrorCode EPSSetUp_BLZPACK(EPS eps)
 68: {
 70:   PetscInt       listor,lrstor,ncuv,k1,k2,k3,k4;
 71:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
 72:   PetscBool      issinv,istrivial,flg;

 75:   if (eps->ncv) {
 76:     if (eps->ncv < PetscMin(eps->nev+10,eps->nev*2)) SETERRQ(PetscObjectComm((PetscObject)eps),0,"Warning: BLZpack recommends that ncv be larger than min(nev+10,nev*2)");
 77:   } else eps->ncv = PetscMin(eps->nev+10,eps->nev*2);
 78:   if (eps->mpd) { PetscInfo(eps,"Warning: parameter mpd ignored\n"); }
 79:   if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n);

 81:   if (!blz->block_size) blz->block_size = 3;
 82:   if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems");
 83:   if (eps->which==EPS_ALL) {
 84:     if (eps->inta==0.0 && eps->intb==0.0) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Must define a computational interval when using EPS_ALL");
 85:     blz->slice = 1;
 86:   }
 87:   PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&issinv);
 88:   if (blz->slice || eps->isgeneralized) {
 89:     if (!issinv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Shift-and-invert ST is needed for generalized problems or spectrum slicing");
 90:   }
 91:   if (blz->slice) {
 92:     if (eps->intb >= PETSC_MAX_REAL) { /* right-open interval */
 93:       if (eps->inta <= PETSC_MIN_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The defined computational interval should have at least one of their sides bounded");
 94:       STSetDefaultShift(eps->st,eps->inta);
 95:     } else {
 96:       STSetDefaultShift(eps->st,eps->intb);
 97:     }
 98:   }
 99:   if (!eps->which) {
100:     if (issinv) eps->which = EPS_TARGET_REAL;
101:     else eps->which = EPS_SMALLEST_REAL;
102:   }
103:   if ((issinv && eps->which!=EPS_TARGET_REAL && eps->which!=EPS_TARGET_MAGNITUDE && eps->which!=EPS_ALL) || (!issinv && eps->which!=EPS_SMALLEST_REAL)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
104:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");

106:   k1 = PetscMin(eps->n,180);
107:   k2 = blz->block_size;
108:   k4 = PetscMin(eps->ncv,eps->n);
109:   k3 = 484+k1*(13+k1*2+k2+PetscMax(18,k2+2))+k2*k2*3+k4*2;

111:   listor = 123+k1*12;
112:   PetscFree(blz->istor);
113:   PetscMalloc1((17+listor),&blz->istor);
114:   PetscLogObjectMemory((PetscObject)eps,(17+listor)*sizeof(PetscBLASInt));
115:   PetscBLASIntCast(listor,&blz->istor[14]);

117:   if (blz->slice) lrstor = eps->nloc*(k2*4+k1*2+k4)+k3;
118:   else lrstor = eps->nloc*(k2*4+k1)+k3;
119: lrstor*=10;
120:   PetscFree(blz->rstor);
121:   PetscMalloc1((4+lrstor),&blz->rstor);
122:   PetscLogObjectMemory((PetscObject)eps,(4+lrstor)*sizeof(PetscReal));
123:   blz->rstor[3] = lrstor;

125:   ncuv = PetscMax(3,blz->block_size);
126:   PetscFree(blz->u);
127:   PetscMalloc1(ncuv*eps->nloc,&blz->u);
128:   PetscLogObjectMemory((PetscObject)eps,ncuv*eps->nloc*sizeof(PetscScalar));
129:   PetscFree(blz->v);
130:   PetscMalloc1(ncuv*eps->nloc,&blz->v);
131:   PetscLogObjectMemory((PetscObject)eps,ncuv*eps->nloc*sizeof(PetscScalar));

133:   PetscFree(blz->eig);
134:   PetscMalloc1(2*eps->ncv,&blz->eig);
135:   PetscLogObjectMemory((PetscObject)eps,2*eps->ncv*sizeof(PetscReal));

137:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }

139:   EPSAllocateSolution(eps,0);
140:   EPS_SetInnerProduct(eps);
141:   PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);
142:   if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage");
143:   RGIsTrivial(eps->rg,&istrivial);
144:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");
145:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test");

147:   /* dispatch solve method */
148:   eps->ops->solve = EPSSolve_BLZPACK;
149:   return(0);
150: }

154: PetscErrorCode EPSSolve_BLZPACK(EPS eps)
155: {
157:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
158:   PetscInt       nn;
159:   PetscBLASInt   i,nneig,lflag,nvopu;
160:   Vec            x,y,v0;
161:   PetscScalar    sigma,*pV;
162:   Mat            A;
163:   KSP            ksp;
164:   PC             pc;

167:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&x);
168:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&y);
169:   EPSGetStartVector(eps,0,NULL);
170:   BVSetActiveColumns(eps->V,0,0);  /* just for deflation space */
171:   BVGetColumn(eps->V,0,&v0);
172:   VecGetArray(v0,&pV);

174:   if (eps->isgeneralized && !blz->slice) {
175:     STGetShift(eps->st,&sigma); /* shift of origin */
176:     blz->rstor[0]  = sigma;        /* lower limit of eigenvalue interval */
177:     blz->rstor[1]  = sigma;        /* upper limit of eigenvalue interval */
178:   } else {
179:     sigma = 0.0;
180:     blz->rstor[0]  = eps->inta;    /* lower limit of eigenvalue interval */
181:     blz->rstor[1]  = eps->intb;    /* upper limit of eigenvalue interval */
182:   }
183:   nneig = 0;                       /* no. of eigs less than sigma */

185:   PetscBLASIntCast(eps->nloc,&blz->istor[0]); /* no. of rows of U, V, X */
186:   PetscBLASIntCast(eps->nloc,&blz->istor[1]); /* leading dim of U, V, X */
187:   PetscBLASIntCast(eps->nev,&blz->istor[2]);  /* required eigenpairs */
188:   PetscBLASIntCast(eps->ncv,&blz->istor[3]);  /* working eigenpairs */
189:   blz->istor[4]  = blz->block_size;    /* number of vectors in a block */
190:   blz->istor[5]  = blz->nsteps;        /* maximun number of steps per run */
191:   blz->istor[6]  = 1;                  /* number of starting vectors as input */
192:   blz->istor[7]  = 0;                  /* number of eigenpairs given as input */
193:   blz->istor[8]  = (blz->slice || eps->isgeneralized) ? 1 : 0;   /* problem type */
194:   blz->istor[9]  = blz->slice;         /* spectrum slicing */
195:   blz->istor[10] = eps->isgeneralized ? 1 : 0;   /* solutions refinement (purify) */
196:   blz->istor[11] = 0;                  /* level of printing */
197:   blz->istor[12] = 6;                  /* file unit for output */
198:   PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&blz->istor[13]);

200:   blz->rstor[2]  = eps->tol;           /* threshold for convergence */

202:   lflag = 0;           /* reverse communication interface flag */

204:   do {
205:     BLZpack_(blz->istor,blz->rstor,&sigma,&nneig,blz->u,blz->v,&lflag,&nvopu,blz->eig,pV);

207:     switch (lflag) {
208:     case 1:
209:       /* compute v = OP u */
210:       for (i=0;i<nvopu;i++) {
211:         VecPlaceArray(x,blz->u+i*eps->nloc);
212:         VecPlaceArray(y,blz->v+i*eps->nloc);
213:         if (blz->slice || eps->isgeneralized) {
214:           STMatSolve(eps->st,x,y);
215:         } else {
216:           STApply(eps->st,x,y);
217:         }
218:         BVOrthogonalizeVec(eps->V,y,NULL,NULL,NULL);
219:         VecResetArray(x);
220:         VecResetArray(y);
221:       }
222:       /* monitor */
223:       eps->nconv  = BLZistorr_(blz->istor,"NTEIG",5);
224:       EPSMonitor(eps,eps->its,eps->nconv,
225:         blz->rstor+BLZistorr_(blz->istor,"IRITZ",5),
226:         eps->eigi,
227:         blz->rstor+BLZistorr_(blz->istor,"IRITZ",5)+BLZistorr_(blz->istor,"JT",2),
228:         BLZistorr_(blz->istor,"NRITZ",5));
229:       eps->its = eps->its + 1;
230:       if (eps->its >= eps->max_it || eps->nconv >= eps->nev) lflag = 5;
231:       break;
232:     case 2:
233:       /* compute v = B u */
234:       for (i=0;i<nvopu;i++) {
235:         VecPlaceArray(x,blz->u+i*eps->nloc);
236:         VecPlaceArray(y,blz->v+i*eps->nloc);
237:         BVApplyMatrix(eps->V,x,y);
238:         VecResetArray(x);
239:         VecResetArray(y);
240:       }
241:       break;
242:     case 3:
243:       /* update shift */
244:       PetscInfo1(eps,"Factorization update (sigma=%g)\n",(double)sigma);
245:       STSetShift(eps->st,sigma);
246:       STGetKSP(eps->st,&ksp);
247:       KSPGetPC(ksp,&pc);
248:       PCFactorGetMatrix(pc,&A);
249:       MatGetInertia(A,&nn,NULL,NULL);
250:       PetscBLASIntCast(nn,&nneig);
251:       break;
252:     case 4:
253:       /* copy the initial vector */
254:       VecPlaceArray(x,blz->v);
255:       VecCopy(v0,x);
256:       VecResetArray(x);
257:       break;
258:     }

260:   } while (lflag > 0);

262:   VecRestoreArray(v0,&pV);
263:   BVRestoreColumn(eps->V,0,&v0);

265:   eps->nconv  = BLZistorr_(blz->istor,"NTEIG",5);
266:   eps->reason = EPS_CONVERGED_TOL;

268:   for (i=0;i<eps->nconv;i++) {
269:     eps->eigr[i]=blz->eig[i];
270:   }

272:   if (lflag!=0) {
273:     char msg[2048] = "";
274:     for (i = 0; i < 33; i++) {
275:       if (blz->istor[15] & (1 << i)) PetscStrcat(msg,blzpack_error[i]);
276:     }
277:     SETERRQ2(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error in BLZPACK (code=%d): '%s'",blz->istor[15],msg);
278:   }
279:   VecDestroy(&x);
280:   VecDestroy(&y);
281:   return(0);
282: }

286: PetscErrorCode EPSBackTransform_BLZPACK(EPS eps)
287: {
289:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;

292:   if (!blz->slice && !eps->isgeneralized) {
293:     EPSBackTransform_Default(eps);
294:   }
295:   return(0);
296: }

300: PetscErrorCode EPSReset_BLZPACK(EPS eps)
301: {
303:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;

306:   PetscFree(blz->istor);
307:   PetscFree(blz->rstor);
308:   PetscFree(blz->u);
309:   PetscFree(blz->v);
310:   PetscFree(blz->eig);
311:   return(0);
312: }

316: PetscErrorCode EPSDestroy_BLZPACK(EPS eps)
317: {

321:   PetscFree(eps->data);
322:   PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",NULL);
323:   PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",NULL);
324:   return(0);
325: }

329: PetscErrorCode EPSView_BLZPACK(EPS eps,PetscViewer viewer)
330: {
332:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
333:   PetscBool      isascii;

336:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
337:   if (isascii) {
338:     PetscViewerASCIIPrintf(viewer,"  BLZPACK: block size=%d\n",blz->block_size);
339:     PetscViewerASCIIPrintf(viewer,"  BLZPACK: maximum number of steps per run=%d\n",blz->nsteps);
340:     if (blz->slice) {
341:       PetscViewerASCIIPrintf(viewer,"  BLZPACK: computational interval [%f,%f]\n",eps->inta,eps->intb);
342:     }
343:   }
344:   return(0);
345: }

349: PetscErrorCode EPSSetFromOptions_BLZPACK(PetscOptionItems *PetscOptionsObject,EPS eps)
350: {
352:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;
353:   PetscInt       bs,n;
354:   PetscBool      flg;

357:   PetscOptionsHead(PetscOptionsObject,"EPS BLZPACK Options");

359:   bs = blz->block_size;
360:   PetscOptionsInt("-eps_blzpack_block_size","Block size","EPSBlzpackSetBlockSize",bs,&bs,&flg);
361:   if (flg) {
362:     EPSBlzpackSetBlockSize(eps,bs);
363:   }

365:   n = blz->nsteps;
366:   PetscOptionsInt("-eps_blzpack_nsteps","Number of steps","EPSBlzpackSetNSteps",n,&n,&flg);
367:   if (flg) {
368:     EPSBlzpackSetNSteps(eps,n);
369:   }

371:   PetscOptionsTail();
372:   return(0);
373: }

377: static PetscErrorCode EPSBlzpackSetBlockSize_BLZPACK(EPS eps,PetscInt bs)
378: {
380:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;

383:   if (bs == PETSC_DEFAULT) blz->block_size = 3;
384:   else if (bs <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Block size must be positive");
385:   else {
386:     PetscBLASIntCast(bs,&blz->block_size);
387:   }
388:   return(0);
389: }

393: /*@
394:    EPSBlzpackSetBlockSize - Sets the block size for the BLZPACK package.

396:    Collective on EPS

398:    Input Parameters:
399: +  eps - the eigenproblem solver context
400: -  bs - block size

402:    Options Database Key:
403: .  -eps_blzpack_block_size - Sets the value of the block size

405:    Level: advanced
406: @*/
407: PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,PetscInt bs)
408: {

414:   PetscTryMethod(eps,"EPSBlzpackSetBlockSize_C",(EPS,PetscInt),(eps,bs));
415:   return(0);
416: }

420: static PetscErrorCode EPSBlzpackSetNSteps_BLZPACK(EPS eps,PetscInt nsteps)
421: {
423:   EPS_BLZPACK    *blz = (EPS_BLZPACK*)eps->data;

426:   if (nsteps == PETSC_DEFAULT) blz->nsteps = 0;
427:   else {
428:     PetscBLASIntCast(nsteps,&blz->nsteps);
429:   }
430:   return(0);
431: }

435: /*@
436:    EPSBlzpackSetNSteps - Sets the maximum number of steps per run for the BLZPACK
437:    package.

439:    Collective on EPS

441:    Input Parameters:
442: +  eps     - the eigenproblem solver context
443: -  nsteps  - maximum number of steps

445:    Options Database Key:
446: .  -eps_blzpack_nsteps - Sets the maximum number of steps per run

448:    Level: advanced

450: @*/
451: PetscErrorCode EPSBlzpackSetNSteps(EPS eps,PetscInt nsteps)
452: {

458:   PetscTryMethod(eps,"EPSBlzpackSetNSteps_C",(EPS,PetscInt),(eps,nsteps));
459:   return(0);
460: }

464: PETSC_EXTERN PetscErrorCode EPSCreate_BLZPACK(EPS eps)
465: {
467:   EPS_BLZPACK    *blzpack;

470:   PetscNewLog(eps,&blzpack);
471:   eps->data = (void*)blzpack;

473:   eps->ops->setup                = EPSSetUp_BLZPACK;
474:   eps->ops->setfromoptions       = EPSSetFromOptions_BLZPACK;
475:   eps->ops->destroy              = EPSDestroy_BLZPACK;
476:   eps->ops->reset                = EPSReset_BLZPACK;
477:   eps->ops->view                 = EPSView_BLZPACK;
478:   eps->ops->backtransform        = EPSBackTransform_BLZPACK;
479:   PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",EPSBlzpackSetBlockSize_BLZPACK);
480:   PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",EPSBlzpackSetNSteps_BLZPACK);
481:   return(0);
482: }

slepc-3.7.4/src/eps/impls/external/blzpack/makefile.html0000644000175000017500000000503613107004621022604 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresdefine  'SLEPC_HAVE_BLZPACK'

CFLAGS   =
FFLAGS   =
SOURCEC  = blzpack.c
SOURCEF  =
SOURCEH  = blzpackp.h
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/external/blzpack/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/external/blzpack/blzpack.c0000644000175000017500000004410713107004621021735 0ustar jromanjroman/* This file implements a wrapper to the BLZPACK package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include <../src/eps/impls/external/blzpack/blzpackp.h> PetscErrorCode EPSSolve_BLZPACK(EPS); const char* blzpack_error[33] = { "", "illegal data, LFLAG ", "illegal data, dimension of (U), (V), (X) ", "illegal data, leading dimension of (U), (V), (X) ", "illegal data, leading dimension of (EIG) ", "illegal data, number of required eigenpairs ", "illegal data, Lanczos algorithm block size ", "illegal data, maximum number of steps ", "illegal data, number of starting vectors ", "illegal data, number of eigenpairs provided ", "illegal data, problem type flag ", "illegal data, spectrum slicing flag ", "illegal data, eigenvectors purification flag ", "illegal data, level of output ", "illegal data, output file unit ", "illegal data, LCOMM (MPI or PVM) ", "illegal data, dimension of ISTOR ", "illegal data, convergence threshold ", "illegal data, dimension of RSTOR ", "illegal data on at least one PE ", "ISTOR(3:14) must be equal on all PEs ", "RSTOR(1:3) must be equal on all PEs ", "not enough space in ISTOR to start eigensolution ", "not enough space in RSTOR to start eigensolution ", "illegal data, number of negative eigenvalues ", "illegal data, entries of V ", "illegal data, entries of X ", "failure in computational subinterval ", "file I/O error, blzpack.__.BQ ", "file I/O error, blzpack.__.BX ", "file I/O error, blzpack.__.Q ", "file I/O error, blzpack.__.X ", "parallel interface error " }; #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_BLZPACK" PetscErrorCode EPSSetUp_BLZPACK(EPS eps) { PetscErrorCode ierr; PetscInt listor,lrstor,ncuv,k1,k2,k3,k4; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscBool issinv,istrivial,flg; PetscFunctionBegin; if (eps->ncv) { if (eps->ncv < PetscMin(eps->nev+10,eps->nev*2)) SETERRQ(PetscObjectComm((PetscObject)eps),0,"Warning: BLZpack recommends that ncv be larger than min(nev+10,nev*2)"); } else eps->ncv = PetscMin(eps->nev+10,eps->nev*2); if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n); if (!blz->block_size) blz->block_size = 3; if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems"); if (eps->which==EPS_ALL) { if (eps->inta==0.0 && eps->intb==0.0) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Must define a computational interval when using EPS_ALL"); blz->slice = 1; } ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&issinv);CHKERRQ(ierr); if (blz->slice || eps->isgeneralized) { if (!issinv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Shift-and-invert ST is needed for generalized problems or spectrum slicing"); } if (blz->slice) { if (eps->intb >= PETSC_MAX_REAL) { /* right-open interval */ if (eps->inta <= PETSC_MIN_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The defined computational interval should have at least one of their sides bounded"); ierr = STSetDefaultShift(eps->st,eps->inta);CHKERRQ(ierr); } else { ierr = STSetDefaultShift(eps->st,eps->intb);CHKERRQ(ierr); } } if (!eps->which) { if (issinv) eps->which = EPS_TARGET_REAL; else eps->which = EPS_SMALLEST_REAL; } if ((issinv && eps->which!=EPS_TARGET_REAL && eps->which!=EPS_TARGET_MAGNITUDE && eps->which!=EPS_ALL) || (!issinv && eps->which!=EPS_SMALLEST_REAL)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); k1 = PetscMin(eps->n,180); k2 = blz->block_size; k4 = PetscMin(eps->ncv,eps->n); k3 = 484+k1*(13+k1*2+k2+PetscMax(18,k2+2))+k2*k2*3+k4*2; listor = 123+k1*12; ierr = PetscFree(blz->istor);CHKERRQ(ierr); ierr = PetscMalloc1((17+listor),&blz->istor);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,(17+listor)*sizeof(PetscBLASInt));CHKERRQ(ierr); ierr = PetscBLASIntCast(listor,&blz->istor[14]);CHKERRQ(ierr); if (blz->slice) lrstor = eps->nloc*(k2*4+k1*2+k4)+k3; else lrstor = eps->nloc*(k2*4+k1)+k3; lrstor*=10; ierr = PetscFree(blz->rstor);CHKERRQ(ierr); ierr = PetscMalloc1((4+lrstor),&blz->rstor);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,(4+lrstor)*sizeof(PetscReal));CHKERRQ(ierr); blz->rstor[3] = lrstor; ncuv = PetscMax(3,blz->block_size); ierr = PetscFree(blz->u);CHKERRQ(ierr); ierr = PetscMalloc1(ncuv*eps->nloc,&blz->u);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,ncuv*eps->nloc*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscFree(blz->v);CHKERRQ(ierr); ierr = PetscMalloc1(ncuv*eps->nloc,&blz->v);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,ncuv*eps->nloc*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscFree(blz->eig);CHKERRQ(ierr); ierr = PetscMalloc1(2*eps->ncv,&blz->eig);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,2*eps->ncv*sizeof(PetscReal));CHKERRQ(ierr); if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage"); ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering"); if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test"); /* dispatch solve method */ eps->ops->solve = EPSSolve_BLZPACK; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_BLZPACK" PetscErrorCode EPSSolve_BLZPACK(EPS eps) { PetscErrorCode ierr; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscInt nn; PetscBLASInt i,nneig,lflag,nvopu; Vec x,y,v0; PetscScalar sigma,*pV; Mat A; KSP ksp; PC pc; PetscFunctionBegin; ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&x);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&y);CHKERRQ(ierr); ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,0);CHKERRQ(ierr); /* just for deflation space */ ierr = BVGetColumn(eps->V,0,&v0);CHKERRQ(ierr); ierr = VecGetArray(v0,&pV);CHKERRQ(ierr); if (eps->isgeneralized && !blz->slice) { ierr = STGetShift(eps->st,&sigma);CHKERRQ(ierr); /* shift of origin */ blz->rstor[0] = sigma; /* lower limit of eigenvalue interval */ blz->rstor[1] = sigma; /* upper limit of eigenvalue interval */ } else { sigma = 0.0; blz->rstor[0] = eps->inta; /* lower limit of eigenvalue interval */ blz->rstor[1] = eps->intb; /* upper limit of eigenvalue interval */ } nneig = 0; /* no. of eigs less than sigma */ ierr = PetscBLASIntCast(eps->nloc,&blz->istor[0]);CHKERRQ(ierr); /* no. of rows of U, V, X */ ierr = PetscBLASIntCast(eps->nloc,&blz->istor[1]);CHKERRQ(ierr); /* leading dim of U, V, X */ ierr = PetscBLASIntCast(eps->nev,&blz->istor[2]);CHKERRQ(ierr); /* required eigenpairs */ ierr = PetscBLASIntCast(eps->ncv,&blz->istor[3]);CHKERRQ(ierr); /* working eigenpairs */ blz->istor[4] = blz->block_size; /* number of vectors in a block */ blz->istor[5] = blz->nsteps; /* maximun number of steps per run */ blz->istor[6] = 1; /* number of starting vectors as input */ blz->istor[7] = 0; /* number of eigenpairs given as input */ blz->istor[8] = (blz->slice || eps->isgeneralized) ? 1 : 0; /* problem type */ blz->istor[9] = blz->slice; /* spectrum slicing */ blz->istor[10] = eps->isgeneralized ? 1 : 0; /* solutions refinement (purify) */ blz->istor[11] = 0; /* level of printing */ blz->istor[12] = 6; /* file unit for output */ ierr = PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&blz->istor[13]);CHKERRQ(ierr); blz->rstor[2] = eps->tol; /* threshold for convergence */ lflag = 0; /* reverse communication interface flag */ do { BLZpack_(blz->istor,blz->rstor,&sigma,&nneig,blz->u,blz->v,&lflag,&nvopu,blz->eig,pV); switch (lflag) { case 1: /* compute v = OP u */ for (i=0;iu+i*eps->nloc);CHKERRQ(ierr); ierr = VecPlaceArray(y,blz->v+i*eps->nloc);CHKERRQ(ierr); if (blz->slice || eps->isgeneralized) { ierr = STMatSolve(eps->st,x,y);CHKERRQ(ierr); } else { ierr = STApply(eps->st,x,y);CHKERRQ(ierr); } ierr = BVOrthogonalizeVec(eps->V,y,NULL,NULL,NULL);CHKERRQ(ierr); ierr = VecResetArray(x);CHKERRQ(ierr); ierr = VecResetArray(y);CHKERRQ(ierr); } /* monitor */ eps->nconv = BLZistorr_(blz->istor,"NTEIG",5); ierr = EPSMonitor(eps,eps->its,eps->nconv, blz->rstor+BLZistorr_(blz->istor,"IRITZ",5), eps->eigi, blz->rstor+BLZistorr_(blz->istor,"IRITZ",5)+BLZistorr_(blz->istor,"JT",2), BLZistorr_(blz->istor,"NRITZ",5));CHKERRQ(ierr); eps->its = eps->its + 1; if (eps->its >= eps->max_it || eps->nconv >= eps->nev) lflag = 5; break; case 2: /* compute v = B u */ for (i=0;iu+i*eps->nloc);CHKERRQ(ierr); ierr = VecPlaceArray(y,blz->v+i*eps->nloc);CHKERRQ(ierr); ierr = BVApplyMatrix(eps->V,x,y);CHKERRQ(ierr); ierr = VecResetArray(x);CHKERRQ(ierr); ierr = VecResetArray(y);CHKERRQ(ierr); } break; case 3: /* update shift */ ierr = PetscInfo1(eps,"Factorization update (sigma=%g)\n",(double)sigma);CHKERRQ(ierr); ierr = STSetShift(eps->st,sigma);CHKERRQ(ierr); ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCFactorGetMatrix(pc,&A);CHKERRQ(ierr); ierr = MatGetInertia(A,&nn,NULL,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(nn,&nneig);CHKERRQ(ierr); break; case 4: /* copy the initial vector */ ierr = VecPlaceArray(x,blz->v);CHKERRQ(ierr); ierr = VecCopy(v0,x);CHKERRQ(ierr); ierr = VecResetArray(x);CHKERRQ(ierr); break; } } while (lflag > 0); ierr = VecRestoreArray(v0,&pV);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&v0);CHKERRQ(ierr); eps->nconv = BLZistorr_(blz->istor,"NTEIG",5); eps->reason = EPS_CONVERGED_TOL; for (i=0;inconv;i++) { eps->eigr[i]=blz->eig[i]; } if (lflag!=0) { char msg[2048] = ""; for (i = 0; i < 33; i++) { if (blz->istor[15] & (1 << i)) PetscStrcat(msg,blzpack_error[i]); } SETERRQ2(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error in BLZPACK (code=%d): '%s'",blz->istor[15],msg); } ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBackTransform_BLZPACK" PetscErrorCode EPSBackTransform_BLZPACK(EPS eps) { PetscErrorCode ierr; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscFunctionBegin; if (!blz->slice && !eps->isgeneralized) { ierr = EPSBackTransform_Default(eps);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_BLZPACK" PetscErrorCode EPSReset_BLZPACK(EPS eps) { PetscErrorCode ierr; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscFunctionBegin; ierr = PetscFree(blz->istor);CHKERRQ(ierr); ierr = PetscFree(blz->rstor);CHKERRQ(ierr); ierr = PetscFree(blz->u);CHKERRQ(ierr); ierr = PetscFree(blz->v);CHKERRQ(ierr); ierr = PetscFree(blz->eig);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_BLZPACK" PetscErrorCode EPSDestroy_BLZPACK(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_BLZPACK" PetscErrorCode EPSView_BLZPACK(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," BLZPACK: block size=%d\n",blz->block_size);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," BLZPACK: maximum number of steps per run=%d\n",blz->nsteps);CHKERRQ(ierr); if (blz->slice) { ierr = PetscViewerASCIIPrintf(viewer," BLZPACK: computational interval [%f,%f]\n",eps->inta,eps->intb);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_BLZPACK" PetscErrorCode EPSSetFromOptions_BLZPACK(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscInt bs,n; PetscBool flg; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS BLZPACK Options");CHKERRQ(ierr); bs = blz->block_size; ierr = PetscOptionsInt("-eps_blzpack_block_size","Block size","EPSBlzpackSetBlockSize",bs,&bs,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSBlzpackSetBlockSize(eps,bs);CHKERRQ(ierr); } n = blz->nsteps; ierr = PetscOptionsInt("-eps_blzpack_nsteps","Number of steps","EPSBlzpackSetNSteps",n,&n,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSBlzpackSetNSteps(eps,n);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBlzpackSetBlockSize_BLZPACK" static PetscErrorCode EPSBlzpackSetBlockSize_BLZPACK(EPS eps,PetscInt bs) { PetscErrorCode ierr; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscFunctionBegin; if (bs == PETSC_DEFAULT) blz->block_size = 3; else if (bs <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Block size must be positive"); else { ierr = PetscBLASIntCast(bs,&blz->block_size);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBlzpackSetBlockSize" /*@ EPSBlzpackSetBlockSize - Sets the block size for the BLZPACK package. Collective on EPS Input Parameters: + eps - the eigenproblem solver context - bs - block size Options Database Key: . -eps_blzpack_block_size - Sets the value of the block size Level: advanced @*/ PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,PetscInt bs) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,bs,2); ierr = PetscTryMethod(eps,"EPSBlzpackSetBlockSize_C",(EPS,PetscInt),(eps,bs));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBlzpackSetNSteps_BLZPACK" static PetscErrorCode EPSBlzpackSetNSteps_BLZPACK(EPS eps,PetscInt nsteps) { PetscErrorCode ierr; EPS_BLZPACK *blz = (EPS_BLZPACK*)eps->data; PetscFunctionBegin; if (nsteps == PETSC_DEFAULT) blz->nsteps = 0; else { ierr = PetscBLASIntCast(nsteps,&blz->nsteps);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBlzpackSetNSteps" /*@ EPSBlzpackSetNSteps - Sets the maximum number of steps per run for the BLZPACK package. Collective on EPS Input Parameters: + eps - the eigenproblem solver context - nsteps - maximum number of steps Options Database Key: . -eps_blzpack_nsteps - Sets the maximum number of steps per run Level: advanced @*/ PetscErrorCode EPSBlzpackSetNSteps(EPS eps,PetscInt nsteps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,nsteps,2); ierr = PetscTryMethod(eps,"EPSBlzpackSetNSteps_C",(EPS,PetscInt),(eps,nsteps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_BLZPACK" PETSC_EXTERN PetscErrorCode EPSCreate_BLZPACK(EPS eps) { PetscErrorCode ierr; EPS_BLZPACK *blzpack; PetscFunctionBegin; ierr = PetscNewLog(eps,&blzpack);CHKERRQ(ierr); eps->data = (void*)blzpack; eps->ops->setup = EPSSetUp_BLZPACK; eps->ops->setfromoptions = EPSSetFromOptions_BLZPACK; eps->ops->destroy = EPSDestroy_BLZPACK; eps->ops->reset = EPSReset_BLZPACK; eps->ops->view = EPSView_BLZPACK; eps->ops->backtransform = EPSBackTransform_BLZPACK; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetBlockSize_C",EPSBlzpackSetBlockSize_BLZPACK);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBlzpackSetNSteps_C",EPSBlzpackSetNSteps_BLZPACK);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/external/blzpack/index.html0000644000175000017500000000270313107004621022134 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

blzpackp.h
blzpack.c
makefile
slepc-3.7.4/src/eps/impls/external/blzpack/ftn-auto/0000755000175000017500000000000013107004621021672 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/blzpack/ftn-auto/makefile0000644000175000017500000000037413107004621023376 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = blzpackf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/external/blzpack/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/blzpack/ftn-auto/blzpackf.c0000644000175000017500000000275513107004621023643 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* blzpack.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsblzpacksetblocksize_ EPSBLZPACKSETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsblzpacksetblocksize_ epsblzpacksetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsblzpacksetnsteps_ EPSBLZPACKSETNSTEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsblzpacksetnsteps_ epsblzpacksetnsteps #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsblzpacksetblocksize_(EPS eps,PetscInt *bs, int *__ierr ){ *__ierr = EPSBlzpackSetBlockSize( (EPS)PetscToPointer((eps) ),*bs); } PETSC_EXTERN void PETSC_STDCALL epsblzpacksetnsteps_(EPS eps,PetscInt *nsteps, int *__ierr ){ *__ierr = EPSBlzpackSetNSteps( (EPS)PetscToPointer((eps) ),*nsteps); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/external/blzpack/blzpackp.h0000644000175000017500000000452513107004621022122 0ustar jromanjroman/* Private data structure used by the BLZPACK interface - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__BLZPACKP_H) #define __BLZPACKP_H typedef struct { PetscBLASInt block_size; /* block size */ PetscBLASInt slice; /* use spectrum slicing */ PetscBLASInt nsteps; /* maximum number of steps per run */ PetscBLASInt *istor; PetscReal *rstor; PetscScalar *u; PetscScalar *v; PetscScalar *eig; } EPS_BLZPACK; /* Definition of routines from the BLZPACK package */ #if defined(SLEPC_BLZPACK_HAVE_UNDERSCORE) #define SLEPC_BLZPACK(lcase,ucase) lcase##_ #elif defined(SLEPC_BLZPACK_HAVE_CAPS) #define SLEPC_BLZPACK(lcase,ucase) ucase #else #define SLEPC_BLZPACK(lcase,ucase) lcase #endif /* These are real case, current version of BLZPACK only supports real matrices */ #if defined(PETSC_USE_SINGLE) /* For these machines we must call the single precision Fortran version */ #define BLZpack_ SLEPC_BLZPACK(blzdrs,BLZDRS) #else #define BLZpack_ SLEPC_BLZPACK(blzdrd,BLZDRD) #endif #define BLZistorr_ SLEPC_BLZPACK(istorr,ISTORR) #define BLZrstorr_ SLEPC_BLZPACK(rstorr,RSTORR) PETSC_EXTERN void BLZpack_(PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*); PETSC_EXTERN PetscBLASInt BLZistorr_(PetscBLASInt*,const char*,int); PETSC_EXTERN PetscReal BLZrstorr_(PetscReal*,char*,int); #endif slepc-3.7.4/src/eps/impls/external/trlan/0000755000175000017500000000000013107004621017627 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/trlan/makefile0000644000175000017500000000224313107004621021330 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresdefine 'SLEPC_HAVE_TRLAN' CFLAGS = FFLAGS = SOURCEC = trlan.c SOURCEF = SOURCEH = trlanp.h LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/external/trlan/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/trlan/makefile.html0000644000175000017500000000502213107004621022271 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresdefine  'SLEPC_HAVE_TRLAN'

CFLAGS   =
FFLAGS   =
SOURCEC  = trlan.c
SOURCEF  =
SOURCEH  = trlanp.h
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/external/trlan/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/external/trlan/trlan.c.html0000644000175000017500000003576213107004621022073 0ustar jromanjroman
Actual source code: trlan.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the TRLAN package

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>
 25: #include <../src/eps/impls/external/trlan/trlanp.h>

 27: PetscErrorCode EPSSolve_TRLAN(EPS);

 29: /* Nasty global variable to access EPS data from TRLan_ */
 30: static EPS globaleps;

 34: PetscErrorCode EPSSetUp_TRLAN(EPS eps)
 35: {
 37:   PetscBool      istrivial;
 38:   EPS_TRLAN      *tr = (EPS_TRLAN*)eps->data;

 41:   PetscBLASIntCast(PetscMax(7,eps->nev+PetscMin(eps->nev,6)),&tr->maxlan);
 42:   if (eps->ncv) {
 43:     if (eps->ncv<eps->nev) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must be at least nev");
 44:   } else eps->ncv = tr->maxlan;
 45:   if (eps->mpd) { PetscInfo(eps,"Warning: parameter mpd ignored\n"); }
 46:   if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n);

 48:   if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems");

 50:   if (eps->isgeneralized) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is not available for generalized problems");

 52:   if (!eps->which) eps->which = EPS_LARGEST_REAL;
 53:   if (eps->which!=EPS_LARGEST_REAL && eps->which!=EPS_SMALLEST_REAL && eps->which!=EPS_TARGET_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
 54:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
 55:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test");

 57:   tr->restart = 0;
 58:   if (tr->maxlan+1-eps->ncv<=0) {
 59:     PetscBLASIntCast(tr->maxlan*(tr->maxlan+10),&tr->lwork);
 60:   } else {
 61:     PetscBLASIntCast(eps->nloc*(tr->maxlan+1-eps->ncv) + tr->maxlan*(tr->maxlan+10),&tr->lwork);
 62:   }
 63:   PetscMalloc1(tr->lwork,&tr->work);
 64:   PetscLogObjectMemory((PetscObject)eps,tr->lwork*sizeof(PetscReal));

 66:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }
 67:   RGIsTrivial(eps->rg,&istrivial);
 68:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");

 70:   EPSAllocateSolution(eps,0);

 72:   /* dispatch solve method */
 73:   eps->ops->solve = EPSSolve_TRLAN;
 74:   return(0);
 75: }

 79: static PetscBLASInt MatMult_TRLAN(PetscBLASInt *n,PetscBLASInt *m,PetscReal *xin,PetscBLASInt *ldx,PetscReal *yout,PetscBLASInt *ldy)
 80: {
 82:   Vec            x,y;
 83:   PetscBLASInt   i;

 86:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)globaleps),1,*n,PETSC_DECIDE,NULL,&x);
 87:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)globaleps),1,*n,PETSC_DECIDE,NULL,&y);
 88:   for (i=0;i<*m;i++) {
 89:     VecPlaceArray(x,(PetscScalar*)xin+i*(*ldx));
 90:     VecPlaceArray(y,(PetscScalar*)yout+i*(*ldy));
 91:     STApply(globaleps->st,x,y);
 92:     BVOrthogonalizeVec(globaleps->V,y,NULL,NULL,NULL);
 93:     VecResetArray(x);
 94:     VecResetArray(y);
 95:   }
 96:   VecDestroy(&x);
 97:   VecDestroy(&y);
 98:   return(0);
 99: }

103: PetscErrorCode EPSSolve_TRLAN(EPS eps)
104: {
106:   PetscInt       i;
107:   PetscBLASInt   ipar[32],n,lohi,stat,ncv;
108:   EPS_TRLAN      *tr = (EPS_TRLAN*)eps->data;
109:   PetscScalar    *pV;
110:   Vec            v0;

113:   PetscBLASIntCast(eps->ncv,&ncv);
114:   PetscBLASIntCast(eps->nloc,&n);

116:   if (eps->which==EPS_LARGEST_REAL || eps->which==EPS_TARGET_REAL) lohi = 1;
117:   else if (eps->which==EPS_SMALLEST_REAL) lohi = -1;
118:   else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");

120:   globaleps = eps;

122:   ipar[0]  = 0;            /* stat: error flag */
123:   ipar[1]  = lohi;         /* smallest (lohi<0) or largest eigenvalues (lohi>0) */
124:   PetscBLASIntCast(eps->nev,&ipar[2]); /* number of desired eigenpairs */
125:   ipar[3]  = 0;            /* number of eigenpairs already converged */
126:   ipar[4]  = tr->maxlan;   /* maximum Lanczos basis size */
127:   ipar[5]  = tr->restart;  /* restarting scheme */
128:   PetscBLASIntCast(eps->max_it,&ipar[6]); /* maximum number of MATVECs */
129: #if !defined(PETSC_HAVE_MPIUNI)
130:   PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&ipar[7]);
131: #endif
132:   ipar[8]  = 0;            /* verboseness */
133:   ipar[9]  = 99;           /* Fortran IO unit number used to write log messages */
134:   ipar[10] = 1;            /* use supplied starting vector */
135:   ipar[11] = 0;            /* checkpointing flag */
136:   ipar[12] = 98;           /* Fortran IO unit number used to write checkpoint files */
137:   ipar[13] = 0;            /* number of flops per matvec per PE (not used) */
138:   tr->work[0] = eps->tol;  /* relative tolerance on residual norms */

140:   for (i=0;i<eps->ncv;i++) eps->eigr[i]=0.0;
141:   EPSGetStartVector(eps,0,NULL);
142:   BVSetActiveColumns(eps->V,0,0);  /* just for deflation space */
143:   BVGetColumn(eps->V,0,&v0);
144:   VecGetArray(v0,&pV);

146:   PetscStackCall("TRLan",TRLan_(MatMult_TRLAN,ipar,&n,&ncv,eps->eigr,pV,&n,tr->work,&tr->lwork));

148:   VecRestoreArray(v0,&pV);
149:   BVRestoreColumn(eps->V,0,&v0);

151:   stat        = ipar[0];
152:   eps->nconv  = ipar[3];
153:   eps->its    = ipar[25];
154:   eps->reason = EPS_CONVERGED_TOL;

156:   if (stat!=0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error in TRLAN (code=%d)",stat);
157:   return(0);
158: }

162: PetscErrorCode EPSReset_TRLAN(EPS eps)
163: {
165:   EPS_TRLAN      *tr = (EPS_TRLAN*)eps->data;

168:   PetscFree(tr->work);
169:   return(0);
170: }

174: PetscErrorCode EPSDestroy_TRLAN(EPS eps)
175: {

179:   PetscFree(eps->data);
180:   return(0);
181: }

185: PETSC_EXTERN PetscErrorCode EPSCreate_TRLAN(EPS eps)
186: {
187:   EPS_TRLAN      *ctx;

191:   PetscNewLog(eps,&ctx);
192:   eps->data = (void*)ctx;

194:   eps->ops->setup                = EPSSetUp_TRLAN;
195:   eps->ops->destroy              = EPSDestroy_TRLAN;
196:   eps->ops->reset                = EPSReset_TRLAN;
197:   eps->ops->backtransform        = EPSBackTransform_Default;
198:   return(0);
199: }

slepc-3.7.4/src/eps/impls/external/trlan/index.html0000644000175000017500000000266713107004621021637 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

trlanp.h
trlan.c
makefile
slepc-3.7.4/src/eps/impls/external/trlan/trlanp.h.html0000644000175000017500000001036413107004621022247 0ustar jromanjroman

Actual source code: trlanp.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private data structure used by the TRLAN interface

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

  8:    This file is part of SLEPc.

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

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

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


 27: typedef struct {
 28:   PetscBLASInt       maxlan;
 29:   PetscBLASInt       restart;
 30:   PetscReal          *work;
 31:   PetscBLASInt       lwork;
 32: } EPS_TRLAN;

 34: /*
 35:    Definition of routines from the TRLAN package
 36:    These are real case. TRLAN currently only has DOUBLE PRECISION version
 37: */

 39: #if defined(SLEPC_TRLAN_HAVE_UNDERSCORE)
 40: #define TRLan_ trlan77_
 41: #elif defined(SLEPC_TRLAN_HAVE_CAPS)
 42: #define TRLan_ TRLAN77
 43: #else
 44: #define TRLan_ trlan77
 45: #endif

 47: PETSC_EXTERN void TRLan_(PetscBLASInt(*op)(PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*),PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);

 49: #endif

slepc-3.7.4/src/eps/impls/external/trlan/trlan.c0000644000175000017500000001736313107004621021125 0ustar jromanjroman/* This file implements a wrapper to the TRLAN package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include <../src/eps/impls/external/trlan/trlanp.h> PetscErrorCode EPSSolve_TRLAN(EPS); /* Nasty global variable to access EPS data from TRLan_ */ static EPS globaleps; #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_TRLAN" PetscErrorCode EPSSetUp_TRLAN(EPS eps) { PetscErrorCode ierr; PetscBool istrivial; EPS_TRLAN *tr = (EPS_TRLAN*)eps->data; PetscFunctionBegin; ierr = PetscBLASIntCast(PetscMax(7,eps->nev+PetscMin(eps->nev,6)),&tr->maxlan);CHKERRQ(ierr); if (eps->ncv) { if (eps->ncvnev) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must be at least nev"); } else eps->ncv = tr->maxlan; if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n); if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems"); if (eps->isgeneralized) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is not available for generalized problems"); if (!eps->which) eps->which = EPS_LARGEST_REAL; if (eps->which!=EPS_LARGEST_REAL && eps->which!=EPS_SMALLEST_REAL && eps->which!=EPS_TARGET_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test"); tr->restart = 0; if (tr->maxlan+1-eps->ncv<=0) { ierr = PetscBLASIntCast(tr->maxlan*(tr->maxlan+10),&tr->lwork);CHKERRQ(ierr); } else { ierr = PetscBLASIntCast(eps->nloc*(tr->maxlan+1-eps->ncv) + tr->maxlan*(tr->maxlan+10),&tr->lwork);CHKERRQ(ierr); } ierr = PetscMalloc1(tr->lwork,&tr->work);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,tr->lwork*sizeof(PetscReal));CHKERRQ(ierr); if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering"); ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); /* dispatch solve method */ eps->ops->solve = EPSSolve_TRLAN; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMult_TRLAN" static PetscBLASInt MatMult_TRLAN(PetscBLASInt *n,PetscBLASInt *m,PetscReal *xin,PetscBLASInt *ldx,PetscReal *yout,PetscBLASInt *ldy) { PetscErrorCode ierr; Vec x,y; PetscBLASInt i; PetscFunctionBegin; ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)globaleps),1,*n,PETSC_DECIDE,NULL,&x);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)globaleps),1,*n,PETSC_DECIDE,NULL,&y);CHKERRQ(ierr); for (i=0;i<*m;i++) { ierr = VecPlaceArray(x,(PetscScalar*)xin+i*(*ldx));CHKERRQ(ierr); ierr = VecPlaceArray(y,(PetscScalar*)yout+i*(*ldy));CHKERRQ(ierr); ierr = STApply(globaleps->st,x,y);CHKERRQ(ierr); ierr = BVOrthogonalizeVec(globaleps->V,y,NULL,NULL,NULL);CHKERRQ(ierr); ierr = VecResetArray(x);CHKERRQ(ierr); ierr = VecResetArray(y);CHKERRQ(ierr); } ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_TRLAN" PetscErrorCode EPSSolve_TRLAN(EPS eps) { PetscErrorCode ierr; PetscInt i; PetscBLASInt ipar[32],n,lohi,stat,ncv; EPS_TRLAN *tr = (EPS_TRLAN*)eps->data; PetscScalar *pV; Vec v0; PetscFunctionBegin; ierr = PetscBLASIntCast(eps->ncv,&ncv);CHKERRQ(ierr); ierr = PetscBLASIntCast(eps->nloc,&n);CHKERRQ(ierr); if (eps->which==EPS_LARGEST_REAL || eps->which==EPS_TARGET_REAL) lohi = 1; else if (eps->which==EPS_SMALLEST_REAL) lohi = -1; else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); globaleps = eps; ipar[0] = 0; /* stat: error flag */ ipar[1] = lohi; /* smallest (lohi<0) or largest eigenvalues (lohi>0) */ ierr = PetscBLASIntCast(eps->nev,&ipar[2]);CHKERRQ(ierr); /* number of desired eigenpairs */ ipar[3] = 0; /* number of eigenpairs already converged */ ipar[4] = tr->maxlan; /* maximum Lanczos basis size */ ipar[5] = tr->restart; /* restarting scheme */ ierr = PetscBLASIntCast(eps->max_it,&ipar[6]);CHKERRQ(ierr); /* maximum number of MATVECs */ #if !defined(PETSC_HAVE_MPIUNI) ierr = PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&ipar[7]);CHKERRQ(ierr); #endif ipar[8] = 0; /* verboseness */ ipar[9] = 99; /* Fortran IO unit number used to write log messages */ ipar[10] = 1; /* use supplied starting vector */ ipar[11] = 0; /* checkpointing flag */ ipar[12] = 98; /* Fortran IO unit number used to write checkpoint files */ ipar[13] = 0; /* number of flops per matvec per PE (not used) */ tr->work[0] = eps->tol; /* relative tolerance on residual norms */ for (i=0;incv;i++) eps->eigr[i]=0.0; ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,0);CHKERRQ(ierr); /* just for deflation space */ ierr = BVGetColumn(eps->V,0,&v0);CHKERRQ(ierr); ierr = VecGetArray(v0,&pV);CHKERRQ(ierr); PetscStackCall("TRLan",TRLan_(MatMult_TRLAN,ipar,&n,&ncv,eps->eigr,pV,&n,tr->work,&tr->lwork)); ierr = VecRestoreArray(v0,&pV);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&v0);CHKERRQ(ierr); stat = ipar[0]; eps->nconv = ipar[3]; eps->its = ipar[25]; eps->reason = EPS_CONVERGED_TOL; if (stat!=0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error in TRLAN (code=%d)",stat); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_TRLAN" PetscErrorCode EPSReset_TRLAN(EPS eps) { PetscErrorCode ierr; EPS_TRLAN *tr = (EPS_TRLAN*)eps->data; PetscFunctionBegin; ierr = PetscFree(tr->work);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_TRLAN" PetscErrorCode EPSDestroy_TRLAN(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_TRLAN" PETSC_EXTERN PetscErrorCode EPSCreate_TRLAN(EPS eps) { EPS_TRLAN *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; eps->ops->setup = EPSSetUp_TRLAN; eps->ops->destroy = EPSDestroy_TRLAN; eps->ops->reset = EPSReset_TRLAN; eps->ops->backtransform = EPSBackTransform_Default; PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/external/trlan/trlanp.h0000644000175000017500000000324613107004621021305 0ustar jromanjroman/* Private data structure used by the TRLAN interface - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__TRLANP_H) #define __TRLANP_H typedef struct { PetscBLASInt maxlan; PetscBLASInt restart; PetscReal *work; PetscBLASInt lwork; } EPS_TRLAN; /* Definition of routines from the TRLAN package These are real case. TRLAN currently only has DOUBLE PRECISION version */ #if defined(SLEPC_TRLAN_HAVE_UNDERSCORE) #define TRLan_ trlan77_ #elif defined(SLEPC_TRLAN_HAVE_CAPS) #define TRLan_ TRLAN77 #else #define TRLan_ trlan77 #endif PETSC_EXTERN void TRLan_(PetscBLASInt(*op)(PetscBLASInt*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscBLASInt*),PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); #endif slepc-3.7.4/src/eps/impls/external/makefile.html0000644000175000017500000000463713107004621021164 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepceps
DIRS     = arpack blopex blzpack primme trlan feast
LOCDIR   = src/eps/impls/external/
MANSEC   = EPS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/external/primme/0000755000175000017500000000000013107004621020000 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/primme/makefile0000644000175000017500000000225513107004621021504 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresdefine 'SLEPC_HAVE_PRIMME' CFLAGS = ${PRIMME_FLAGS} FFLAGS = SOURCEC = primme.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/external/primme/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/primme/primme.c.html0000644000175000017500000011602313107004621022403 0ustar jromanjroman
Actual source code: primme.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the PRIMME package

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>    /*I "slepceps.h" I*/

 26: PetscErrorCode EPSSolve_PRIMME(EPS);

 28: EXTERN_C_BEGIN
 29: #include <primme.h>
 30: EXTERN_C_END

 32: typedef struct {
 33:   primme_params primme;           /* param struc */
 34:   primme_preset_method method;    /* primme method */
 35:   Mat       A;                    /* problem matrix */
 36:   EPS       eps;                  /* EPS current context */
 37:   KSP       ksp;                  /* linear solver and preconditioner */
 38:   Vec       x,y;                  /* auxiliary vectors */
 39:   PetscReal target;               /* a copy of eps's target */
 40: } EPS_PRIMME;

 42: static void multMatvec_PRIMME(void *in,void *out,int *blockSize,primme_params *primme);
 43: static void applyPreconditioner_PRIMME(void *in,void *out,int *blockSize,struct primme_params *primme);

 45: static void par_GlobalSumDouble(void *sendBuf,void *recvBuf,int *count,primme_params *primme)
 46: {
 48:   MPI_Allreduce((double*)sendBuf,(double*)recvBuf,*count,MPI_DOUBLE,MPI_SUM,PetscObjectComm((PetscObject)primme->commInfo));CHKERRABORT(PetscObjectComm((PetscObject)primme->commInfo),ierr);
 49: }

 53: PetscErrorCode EPSSetUp_PRIMME(EPS eps)
 54: {
 56:   PetscMPIInt    numProcs,procID;
 57:   EPS_PRIMME     *ops = (EPS_PRIMME*)eps->data;
 58:   primme_params  *primme = &ops->primme;
 59:   PetscBool      istrivial,flg;

 62:   MPI_Comm_size(PetscObjectComm((PetscObject)eps),&numProcs);
 63:   MPI_Comm_rank(PetscObjectComm((PetscObject)eps),&procID);

 65:   /* Check some constraints and set some default values */
 66:   if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n);
 67:   STGetOperators(eps->st,0,&ops->A);
 68:   if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME is only available for Hermitian problems");
 69:   if (eps->isgeneralized) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME is not available for generalized problems");
 70:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
 71:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test");
 72:   if (!eps->which) eps->which = EPS_LARGEST_REAL;
 73:   if (eps->converged != EPSConvergedAbsolute) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME only supports absolute convergence test");
 74:   RGIsTrivial(eps->rg,&istrivial);
 75:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");

 77:   STSetUp(eps->st);
 78:   PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&flg);
 79:   if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME only works with STPRECOND");

 81:   /* Transfer SLEPc options to PRIMME options */
 82:   primme->n          = eps->n;
 83:   primme->nLocal     = eps->nloc;
 84:   primme->numEvals   = eps->nev;
 85:   primme->matrix     = ops;
 86:   primme->commInfo   = eps;
 87:   primme->maxMatvecs = eps->max_it;
 88:   primme->eps        = eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol;
 89:   primme->numProcs   = numProcs;
 90:   primme->procID     = procID;
 91:   primme->printLevel = 0;
 92:   primme->correctionParams.precondition = 1;

 94:   switch (eps->which) {
 95:     case EPS_LARGEST_REAL:
 96:       primme->target = primme_largest;
 97:       break;
 98:     case EPS_SMALLEST_REAL:
 99:       primme->target = primme_smallest;
100:       break;
101:     case EPS_TARGET_MAGNITUDE:
102:     case EPS_TARGET_REAL:
103:       primme->target = primme_closest_abs;
104:       primme->numTargetShifts = 1;
105:       ops->target = PetscRealPart(eps->target);
106:       primme->targetShifts = &ops->target;
107:       break;
108:     default:
109:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"'which' value not supported by PRIMME");
110:       break;
111:   }

113:   if (primme_set_method(ops->method,primme) < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME method not valid");

115:   /* If user sets ncv, maxBasisSize is modified. If not, ncv is set as maxBasisSize */
116:   if (eps->ncv) primme->maxBasisSize = eps->ncv;
117:   else eps->ncv = primme->maxBasisSize;
118:   if (eps->ncv < eps->nev+primme->maxBlockSize)  SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME needs ncv >= nev+maxBlockSize");
119:   if (eps->mpd) { PetscInfo(eps,"Warning: parameter mpd ignored\n"); }

121:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }

123:   /* Set workspace */
124:   EPSAllocateSolution(eps,0);
125:   PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);
126:   if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage");

128:   /* Setup the preconditioner */
129:   ops->eps = eps;
130:   if (primme->correctionParams.precondition) {
131:     STGetKSP(eps->st,&ops->ksp);
132:     PetscObjectTypeCompare((PetscObject)ops->ksp,KSPPREONLY,&flg);
133:     if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME only works with KSPPREONLY");
134:     primme->preconditioner = NULL;
135:     primme->applyPreconditioner = applyPreconditioner_PRIMME;
136:   }

138:   /* Prepare auxiliary vectors */
139:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,eps->n,NULL,&ops->x);
140:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,eps->n,NULL,&ops->y);
141:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ops->x);
142:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ops->y);

144:   /* dispatch solve method */
145:   eps->ops->solve = EPSSolve_PRIMME;
146:   return(0);
147: }

151: PetscErrorCode EPSSolve_PRIMME(EPS eps)
152: {
154:   EPS_PRIMME     *ops = (EPS_PRIMME*)eps->data;
155:   PetscScalar    *a;
156:   Vec            v0;
157: #if defined(PETSC_USE_COMPLEX)
158:   PetscInt       i;
159:   PetscReal      *evals;
160: #endif

163:   /* Reset some parameters left from previous runs */
164:   ops->primme.aNorm    = 1.0;
165:   ops->primme.initSize = eps->nini;
166:   ops->primme.iseed[0] = -1;

168:   /* Call PRIMME solver */
169:   BVGetColumn(eps->V,0,&v0);
170:   VecGetArray(v0,&a);
171: #if !defined(PETSC_USE_COMPLEX)
172:   dprimme(eps->eigr,a,eps->errest,&ops->primme);
173:   if (ierr) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"PRIMME library failed with error code=%d",ierr);
174: #else
175:   /* PRIMME returns real eigenvalues, but SLEPc works with complex ones */
176:   PetscMalloc1(eps->ncv,&evals);
177:   zprimme(evals,(Complex_Z*)a,eps->errest,&ops->primme);
178:   if (ierr) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"PRIMME library failed with error code=%d",ierr);
179:   for (i=0;i<eps->ncv;i++) eps->eigr[i] = evals[i];
180:   PetscFree(evals);
181: #endif
182:   VecRestoreArray(v0,&a);
183:   BVRestoreColumn(eps->V,0,&v0);

185:   eps->nconv  = ops->primme.initSize >= 0 ? ops->primme.initSize : 0;
186:   eps->reason = eps->ncv >= eps->nev ? EPS_CONVERGED_TOL: EPS_DIVERGED_ITS;
187:   eps->its    = ops->primme.stats.numOuterIterations;
188:   return(0);
189: }

193: static void multMatvec_PRIMME(void *in,void *out,int *blockSize,primme_params *primme)
194: {
196:   PetscInt       i,N = primme->n;
197:   EPS_PRIMME     *ops = (EPS_PRIMME*)primme->matrix;
198:   Vec            x = ops->x,y = ops->y;
199:   Mat            A = ops->A;

202:   for (i=0;i<*blockSize;i++) {
203:     /* build vectors using 'in' an 'out' workspace */
204:     VecPlaceArray(x,(PetscScalar*)in+N*i);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr);
205:     VecPlaceArray(y,(PetscScalar*)out+N*i);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr);

207:     MatMult(A,x,y);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr);

209:     VecResetArray(x);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr);
210:     VecResetArray(y);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr);
211:   }
212:   PetscFunctionReturnVoid();
213: }

217: static void applyPreconditioner_PRIMME(void *in,void *out,int *blockSize,struct primme_params *primme)
218: {
220:   PetscInt       i,N = primme->n;
221:   EPS_PRIMME     *ops = (EPS_PRIMME*)primme->matrix;
222:   Vec            x = ops->x,y = ops->y;

225:   for (i=0;i<*blockSize;i++) {
226:     /* build vectors using 'in' an 'out' workspace */
227:     VecPlaceArray(x,(PetscScalar*)in+N*i);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr);
228:     VecPlaceArray(y,(PetscScalar*)out+N*i);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr);
229:     KSPSolve(ops->ksp,x,y);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr);
230:     VecResetArray(x);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr);
231:     VecResetArray(y);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr);
232:   }
233:   PetscFunctionReturnVoid();
234: }

238: PetscErrorCode EPSReset_PRIMME(EPS eps)
239: {
241:   EPS_PRIMME     *ops = (EPS_PRIMME*)eps->data;

244:   primme_Free(&ops->primme);
245:   VecDestroy(&ops->x);
246:   VecDestroy(&ops->y);
247:   return(0);
248: }

252: PetscErrorCode EPSDestroy_PRIMME(EPS eps)
253: {

257:   PetscFree(eps->data);
258:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetBlockSize_C",NULL);
259:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetMethod_C",NULL);
260:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetBlockSize_C",NULL);
261:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetMethod_C",NULL);
262:   return(0);
263: }

267: PetscErrorCode EPSView_PRIMME(EPS eps,PetscViewer viewer)
268: {
269:   PetscErrorCode  ierr;
270:   PetscBool       isascii;
271:   primme_params   *primme = &((EPS_PRIMME*)eps->data)->primme;
272:   EPSPRIMMEMethod methodn;
273:   PetscMPIInt     rank;

276:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
277:   if (isascii) {
278:     PetscViewerASCIIPrintf(viewer,"  PRIMME: block size=%D\n",primme->maxBlockSize);
279:     EPSPRIMMEGetMethod(eps,&methodn);
280:     PetscViewerASCIIPrintf(viewer,"  PRIMME: solver method: %s\n",EPSPRIMMEMethods[methodn]);

282:     /* Display PRIMME params */
283:     MPI_Comm_rank(PetscObjectComm((PetscObject)eps),&rank);
284:     if (!rank) primme_display_params(*primme);
285:   }
286:   return(0);
287: }

291: PetscErrorCode EPSSetFromOptions_PRIMME(PetscOptionItems *PetscOptionsObject,EPS eps)
292: {
293:   PetscErrorCode  ierr;
294:   EPS_PRIMME      *ctx = (EPS_PRIMME*)eps->data;
295:   PetscInt        bs;
296:   EPSPRIMMEMethod meth;
297:   PetscBool       flg;
298:   KSP             ksp;

301:   PetscOptionsHead(PetscOptionsObject,"EPS PRIMME Options");
302:   PetscOptionsInt("-eps_primme_block_size","Maximum block size","EPSPRIMMESetBlockSize",ctx->primme.maxBlockSize,&bs,&flg);
303:   if (flg) {
304:     EPSPRIMMESetBlockSize(eps,bs);
305:   }
306:   PetscOptionsEnum("-eps_primme_method","Method for solving the eigenproblem","EPSPRIMMESetMethod",EPSPRIMMEMethods,(PetscEnum)ctx->method,(PetscEnum*)&meth,&flg);
307:   if (flg) {
308:     EPSPRIMMESetMethod(eps,meth);
309:   }

311:   /* Set STPrecond as the default ST */
312:   if (!((PetscObject)eps->st)->type_name) {
313:     STSetType(eps->st,STPRECOND);
314:   }
315:   STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);

317:   /* Set the default options of the KSP */
318:   STGetKSP(eps->st,&ksp);
319:   if (!((PetscObject)ksp)->type_name) {
320:     KSPSetType(ksp,KSPPREONLY);
321:   }
322:   PetscOptionsTail();
323:   return(0);
324: }

328: static PetscErrorCode EPSPRIMMESetBlockSize_PRIMME(EPS eps,PetscInt bs)
329: {
330:   EPS_PRIMME *ops = (EPS_PRIMME*)eps->data;

333:   if (bs == PETSC_DEFAULT) ops->primme.maxBlockSize = 1;
334:   else if (bs <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"PRIMME: block size must be positive");
335:   else ops->primme.maxBlockSize = bs;
336:   return(0);
337: }

341: /*@
342:    EPSPRIMMESetBlockSize - The maximum block size that PRIMME will try to use.

344:    Logically Collective on EPS

346:    Input Parameters:
347: +  eps - the eigenproblem solver context
348: -  bs - block size

350:    Options Database Key:
351: .  -eps_primme_block_size - Sets the max allowed block size value

353:    Notes:
354:    If the block size is not set, the value established by primme_initialize
355:    is used.

357:    The user should set the block size based on the architecture specifics
358:    of the target computer, as well as any a priori knowledge of multiplicities.
359:    The code does NOT require bs > 1 to find multiple eigenvalues. For some
360:    methods, keeping bs = 1 yields the best overall performance.

362:    Level: advanced

364: .seealso: EPSPRIMMEGetBlockSize()
365: @*/
366: PetscErrorCode EPSPRIMMESetBlockSize(EPS eps,PetscInt bs)
367: {

373:   PetscTryMethod(eps,"EPSPRIMMESetBlockSize_C",(EPS,PetscInt),(eps,bs));
374:   return(0);
375: }

379: static PetscErrorCode EPSPRIMMEGetBlockSize_PRIMME(EPS eps,PetscInt *bs)
380: {
381:   EPS_PRIMME *ops = (EPS_PRIMME*)eps->data;

384:   *bs = ops->primme.maxBlockSize;
385:   return(0);
386: }

390: /*@
391:    EPSPRIMMEGetBlockSize - Get the maximum block size the code will try to use.

393:    Not Collective

395:    Input Parameter:
396: .  eps - the eigenproblem solver context

398:    Output Parameter:
399: .  bs - returned block size

401:    Level: advanced

403: .seealso: EPSPRIMMESetBlockSize()
404: @*/
405: PetscErrorCode EPSPRIMMEGetBlockSize(EPS eps,PetscInt *bs)
406: {

412:   PetscUseMethod(eps,"EPSPRIMMEGetBlockSize_C",(EPS,PetscInt*),(eps,bs));
413:   return(0);
414: }

418: static PetscErrorCode EPSPRIMMESetMethod_PRIMME(EPS eps,EPSPRIMMEMethod method)
419: {
420:   EPS_PRIMME *ops = (EPS_PRIMME*)eps->data;

423:   ops->method = (primme_preset_method)method;
424:   return(0);
425: }

429: /*@
430:    EPSPRIMMESetMethod - Sets the method for the PRIMME library.

432:    Logically Collective on EPS

434:    Input Parameters:
435: +  eps - the eigenproblem solver context
436: -  method - method that will be used by PRIMME

438:    Options Database Key:
439: .  -eps_primme_method - Sets the method for the PRIMME library

441:    Note:
442:    If not set, the method defaults to EPS_PRIMME_DEFAULT_MIN_TIME.

444:    Level: advanced

446: .seealso: EPSPRIMMEGetMethod(), EPSPRIMMEMethod
447: @*/
448: PetscErrorCode EPSPRIMMESetMethod(EPS eps,EPSPRIMMEMethod method)
449: {

455:   PetscTryMethod(eps,"EPSPRIMMESetMethod_C",(EPS,EPSPRIMMEMethod),(eps,method));
456:   return(0);
457: }

461: static PetscErrorCode EPSPRIMMEGetMethod_PRIMME(EPS eps,EPSPRIMMEMethod *method)
462: {
463:   EPS_PRIMME *ops = (EPS_PRIMME*)eps->data;

466:   *method = (EPSPRIMMEMethod)ops->method;
467:   return(0);
468: }

472: /*@
473:    EPSPRIMMEGetMethod - Gets the method for the PRIMME library.

475:    Not Collective

477:    Input Parameter:
478: .  eps - the eigenproblem solver context

480:    Output Parameter:
481: .  method - method that will be used by PRIMME

483:    Level: advanced

485: .seealso: EPSPRIMMESetMethod(), EPSPRIMMEMethod
486: @*/
487: PetscErrorCode EPSPRIMMEGetMethod(EPS eps,EPSPRIMMEMethod *method)
488: {

494:   PetscUseMethod(eps,"EPSPRIMMEGetMethod_C",(EPS,EPSPRIMMEMethod*),(eps,method));
495:   return(0);
496: }

500: PETSC_EXTERN PetscErrorCode EPSCreate_PRIMME(EPS eps)
501: {
503:   EPS_PRIMME     *primme;

506:   PetscNewLog(eps,&primme);
507:   eps->data = (void*)primme;

509:   eps->ops->setup          = EPSSetUp_PRIMME;
510:   eps->ops->setfromoptions = EPSSetFromOptions_PRIMME;
511:   eps->ops->destroy        = EPSDestroy_PRIMME;
512:   eps->ops->reset          = EPSReset_PRIMME;
513:   eps->ops->view           = EPSView_PRIMME;
514:   eps->ops->backtransform  = EPSBackTransform_Default;

516:   primme_initialize(&primme->primme);
517:   primme->primme.matrixMatvec = multMatvec_PRIMME;
518:   primme->primme.globalSumDouble = par_GlobalSumDouble;
519:   primme->method = (primme_preset_method)EPS_PRIMME_DEFAULT_MIN_TIME;

521:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetBlockSize_C",EPSPRIMMESetBlockSize_PRIMME);
522:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetMethod_C",EPSPRIMMESetMethod_PRIMME);
523:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetBlockSize_C",EPSPRIMMEGetBlockSize_PRIMME);
524:   PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetMethod_C",EPSPRIMMEGetMethod_PRIMME);
525:   return(0);
526: }

slepc-3.7.4/src/eps/impls/external/primme/primme.c0000644000175000017500000004547713107004621021456 0ustar jromanjroman/* This file implements a wrapper to the PRIMME package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ PetscErrorCode EPSSolve_PRIMME(EPS); EXTERN_C_BEGIN #include EXTERN_C_END typedef struct { primme_params primme; /* param struc */ primme_preset_method method; /* primme method */ Mat A; /* problem matrix */ EPS eps; /* EPS current context */ KSP ksp; /* linear solver and preconditioner */ Vec x,y; /* auxiliary vectors */ PetscReal target; /* a copy of eps's target */ } EPS_PRIMME; static void multMatvec_PRIMME(void *in,void *out,int *blockSize,primme_params *primme); static void applyPreconditioner_PRIMME(void *in,void *out,int *blockSize,struct primme_params *primme); static void par_GlobalSumDouble(void *sendBuf,void *recvBuf,int *count,primme_params *primme) { PetscErrorCode ierr; ierr = MPI_Allreduce((double*)sendBuf,(double*)recvBuf,*count,MPI_DOUBLE,MPI_SUM,PetscObjectComm((PetscObject)primme->commInfo));CHKERRABORT(PetscObjectComm((PetscObject)primme->commInfo),ierr); } #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_PRIMME" PetscErrorCode EPSSetUp_PRIMME(EPS eps) { PetscErrorCode ierr; PetscMPIInt numProcs,procID; EPS_PRIMME *ops = (EPS_PRIMME*)eps->data; primme_params *primme = &ops->primme; PetscBool istrivial,flg; PetscFunctionBegin; ierr = MPI_Comm_size(PetscObjectComm((PetscObject)eps),&numProcs);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)eps),&procID);CHKERRQ(ierr); /* Check some constraints and set some default values */ if (!eps->max_it) eps->max_it = PetscMax(1000,eps->n); ierr = STGetOperators(eps->st,0,&ops->A);CHKERRQ(ierr); if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME is only available for Hermitian problems"); if (eps->isgeneralized) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME is not available for generalized problems"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test"); if (!eps->which) eps->which = EPS_LARGEST_REAL; if (eps->converged != EPSConvergedAbsolute) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME only supports absolute convergence test"); ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering"); ierr = STSetUp(eps->st);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME only works with STPRECOND"); /* Transfer SLEPc options to PRIMME options */ primme->n = eps->n; primme->nLocal = eps->nloc; primme->numEvals = eps->nev; primme->matrix = ops; primme->commInfo = eps; primme->maxMatvecs = eps->max_it; primme->eps = eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol; primme->numProcs = numProcs; primme->procID = procID; primme->printLevel = 0; primme->correctionParams.precondition = 1; switch (eps->which) { case EPS_LARGEST_REAL: primme->target = primme_largest; break; case EPS_SMALLEST_REAL: primme->target = primme_smallest; break; case EPS_TARGET_MAGNITUDE: case EPS_TARGET_REAL: primme->target = primme_closest_abs; primme->numTargetShifts = 1; ops->target = PetscRealPart(eps->target); primme->targetShifts = &ops->target; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"'which' value not supported by PRIMME"); break; } if (primme_set_method(ops->method,primme) < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME method not valid"); /* If user sets ncv, maxBasisSize is modified. If not, ncv is set as maxBasisSize */ if (eps->ncv) primme->maxBasisSize = eps->ncv; else eps->ncv = primme->maxBasisSize; if (eps->ncv < eps->nev+primme->maxBlockSize) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME needs ncv >= nev+maxBlockSize"); if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } /* Set workspace */ ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage"); /* Setup the preconditioner */ ops->eps = eps; if (primme->correctionParams.precondition) { ierr = STGetKSP(eps->st,&ops->ksp);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)ops->ksp,KSPPREONLY,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"PRIMME only works with KSPPREONLY"); primme->preconditioner = NULL; primme->applyPreconditioner = applyPreconditioner_PRIMME; } /* Prepare auxiliary vectors */ ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,eps->n,NULL,&ops->x);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,eps->n,NULL,&ops->y);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ops->x);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ops->y);CHKERRQ(ierr); /* dispatch solve method */ eps->ops->solve = EPSSolve_PRIMME; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_PRIMME" PetscErrorCode EPSSolve_PRIMME(EPS eps) { PetscErrorCode ierr; EPS_PRIMME *ops = (EPS_PRIMME*)eps->data; PetscScalar *a; Vec v0; #if defined(PETSC_USE_COMPLEX) PetscInt i; PetscReal *evals; #endif PetscFunctionBegin; /* Reset some parameters left from previous runs */ ops->primme.aNorm = 1.0; ops->primme.initSize = eps->nini; ops->primme.iseed[0] = -1; /* Call PRIMME solver */ ierr = BVGetColumn(eps->V,0,&v0);CHKERRQ(ierr); ierr = VecGetArray(v0,&a);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = dprimme(eps->eigr,a,eps->errest,&ops->primme); if (ierr) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"PRIMME library failed with error code=%d",ierr); #else /* PRIMME returns real eigenvalues, but SLEPc works with complex ones */ ierr = PetscMalloc1(eps->ncv,&evals);CHKERRQ(ierr); ierr = zprimme(evals,(Complex_Z*)a,eps->errest,&ops->primme); if (ierr) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"PRIMME library failed with error code=%d",ierr); for (i=0;incv;i++) eps->eigr[i] = evals[i]; ierr = PetscFree(evals);CHKERRQ(ierr); #endif ierr = VecRestoreArray(v0,&a);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&v0);CHKERRQ(ierr); eps->nconv = ops->primme.initSize >= 0 ? ops->primme.initSize : 0; eps->reason = eps->ncv >= eps->nev ? EPS_CONVERGED_TOL: EPS_DIVERGED_ITS; eps->its = ops->primme.stats.numOuterIterations; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "multMatvec_PRIMME" static void multMatvec_PRIMME(void *in,void *out,int *blockSize,primme_params *primme) { PetscErrorCode ierr; PetscInt i,N = primme->n; EPS_PRIMME *ops = (EPS_PRIMME*)primme->matrix; Vec x = ops->x,y = ops->y; Mat A = ops->A; PetscFunctionBegin; for (i=0;i<*blockSize;i++) { /* build vectors using 'in' an 'out' workspace */ ierr = VecPlaceArray(x,(PetscScalar*)in+N*i);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr); ierr = VecPlaceArray(y,(PetscScalar*)out+N*i);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr); ierr = MatMult(A,x,y);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr); ierr = VecResetArray(x);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr); ierr = VecResetArray(y);CHKERRABORT(PetscObjectComm((PetscObject)A),ierr); } PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "applyPreconditioner_PRIMME" static void applyPreconditioner_PRIMME(void *in,void *out,int *blockSize,struct primme_params *primme) { PetscErrorCode ierr; PetscInt i,N = primme->n; EPS_PRIMME *ops = (EPS_PRIMME*)primme->matrix; Vec x = ops->x,y = ops->y; PetscFunctionBegin; for (i=0;i<*blockSize;i++) { /* build vectors using 'in' an 'out' workspace */ ierr = VecPlaceArray(x,(PetscScalar*)in+N*i);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr); ierr = VecPlaceArray(y,(PetscScalar*)out+N*i);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr); ierr = KSPSolve(ops->ksp,x,y);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr); ierr = VecResetArray(x);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr); ierr = VecResetArray(y);CHKERRABORT(PetscObjectComm((PetscObject)ops->ksp),ierr); } PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_PRIMME" PetscErrorCode EPSReset_PRIMME(EPS eps) { PetscErrorCode ierr; EPS_PRIMME *ops = (EPS_PRIMME*)eps->data; PetscFunctionBegin; primme_Free(&ops->primme); ierr = VecDestroy(&ops->x);CHKERRQ(ierr); ierr = VecDestroy(&ops->y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_PRIMME" PetscErrorCode EPSDestroy_PRIMME(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetMethod_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetMethod_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_PRIMME" PetscErrorCode EPSView_PRIMME(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii; primme_params *primme = &((EPS_PRIMME*)eps->data)->primme; EPSPRIMMEMethod methodn; PetscMPIInt rank; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," PRIMME: block size=%D\n",primme->maxBlockSize);CHKERRQ(ierr); ierr = EPSPRIMMEGetMethod(eps,&methodn);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," PRIMME: solver method: %s\n",EPSPRIMMEMethods[methodn]);CHKERRQ(ierr); /* Display PRIMME params */ ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)eps),&rank);CHKERRQ(ierr); if (!rank) primme_display_params(*primme); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_PRIMME" PetscErrorCode EPSSetFromOptions_PRIMME(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; EPS_PRIMME *ctx = (EPS_PRIMME*)eps->data; PetscInt bs; EPSPRIMMEMethod meth; PetscBool flg; KSP ksp; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS PRIMME Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_primme_block_size","Maximum block size","EPSPRIMMESetBlockSize",ctx->primme.maxBlockSize,&bs,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSPRIMMESetBlockSize(eps,bs);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-eps_primme_method","Method for solving the eigenproblem","EPSPRIMMESetMethod",EPSPRIMMEMethods,(PetscEnum)ctx->method,(PetscEnum*)&meth,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSPRIMMESetMethod(eps,meth);CHKERRQ(ierr); } /* Set STPrecond as the default ST */ if (!((PetscObject)eps->st)->type_name) { ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); } ierr = STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);CHKERRQ(ierr); /* Set the default options of the KSP */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMESetBlockSize_PRIMME" static PetscErrorCode EPSPRIMMESetBlockSize_PRIMME(EPS eps,PetscInt bs) { EPS_PRIMME *ops = (EPS_PRIMME*)eps->data; PetscFunctionBegin; if (bs == PETSC_DEFAULT) ops->primme.maxBlockSize = 1; else if (bs <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"PRIMME: block size must be positive"); else ops->primme.maxBlockSize = bs; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMESetBlockSize" /*@ EPSPRIMMESetBlockSize - The maximum block size that PRIMME will try to use. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - bs - block size Options Database Key: . -eps_primme_block_size - Sets the max allowed block size value Notes: If the block size is not set, the value established by primme_initialize is used. The user should set the block size based on the architecture specifics of the target computer, as well as any a priori knowledge of multiplicities. The code does NOT require bs > 1 to find multiple eigenvalues. For some methods, keeping bs = 1 yields the best overall performance. Level: advanced .seealso: EPSPRIMMEGetBlockSize() @*/ PetscErrorCode EPSPRIMMESetBlockSize(EPS eps,PetscInt bs) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,bs,2); ierr = PetscTryMethod(eps,"EPSPRIMMESetBlockSize_C",(EPS,PetscInt),(eps,bs));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMEGetBlockSize_PRIMME" static PetscErrorCode EPSPRIMMEGetBlockSize_PRIMME(EPS eps,PetscInt *bs) { EPS_PRIMME *ops = (EPS_PRIMME*)eps->data; PetscFunctionBegin; *bs = ops->primme.maxBlockSize; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMEGetBlockSize" /*@ EPSPRIMMEGetBlockSize - Get the maximum block size the code will try to use. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . bs - returned block size Level: advanced .seealso: EPSPRIMMESetBlockSize() @*/ PetscErrorCode EPSPRIMMEGetBlockSize(EPS eps,PetscInt *bs) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(bs,2); ierr = PetscUseMethod(eps,"EPSPRIMMEGetBlockSize_C",(EPS,PetscInt*),(eps,bs));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMESetMethod_PRIMME" static PetscErrorCode EPSPRIMMESetMethod_PRIMME(EPS eps,EPSPRIMMEMethod method) { EPS_PRIMME *ops = (EPS_PRIMME*)eps->data; PetscFunctionBegin; ops->method = (primme_preset_method)method; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMESetMethod" /*@ EPSPRIMMESetMethod - Sets the method for the PRIMME library. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - method - method that will be used by PRIMME Options Database Key: . -eps_primme_method - Sets the method for the PRIMME library Note: If not set, the method defaults to EPS_PRIMME_DEFAULT_MIN_TIME. Level: advanced .seealso: EPSPRIMMEGetMethod(), EPSPRIMMEMethod @*/ PetscErrorCode EPSPRIMMESetMethod(EPS eps,EPSPRIMMEMethod method) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,method,2); ierr = PetscTryMethod(eps,"EPSPRIMMESetMethod_C",(EPS,EPSPRIMMEMethod),(eps,method));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMEGetMethod_PRIMME" static PetscErrorCode EPSPRIMMEGetMethod_PRIMME(EPS eps,EPSPRIMMEMethod *method) { EPS_PRIMME *ops = (EPS_PRIMME*)eps->data; PetscFunctionBegin; *method = (EPSPRIMMEMethod)ops->method; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPRIMMEGetMethod" /*@ EPSPRIMMEGetMethod - Gets the method for the PRIMME library. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . method - method that will be used by PRIMME Level: advanced .seealso: EPSPRIMMESetMethod(), EPSPRIMMEMethod @*/ PetscErrorCode EPSPRIMMEGetMethod(EPS eps,EPSPRIMMEMethod *method) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(method,2); ierr = PetscUseMethod(eps,"EPSPRIMMEGetMethod_C",(EPS,EPSPRIMMEMethod*),(eps,method));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_PRIMME" PETSC_EXTERN PetscErrorCode EPSCreate_PRIMME(EPS eps) { PetscErrorCode ierr; EPS_PRIMME *primme; PetscFunctionBegin; ierr = PetscNewLog(eps,&primme);CHKERRQ(ierr); eps->data = (void*)primme; eps->ops->setup = EPSSetUp_PRIMME; eps->ops->setfromoptions = EPSSetFromOptions_PRIMME; eps->ops->destroy = EPSDestroy_PRIMME; eps->ops->reset = EPSReset_PRIMME; eps->ops->view = EPSView_PRIMME; eps->ops->backtransform = EPSBackTransform_Default; primme_initialize(&primme->primme); primme->primme.matrixMatvec = multMatvec_PRIMME; primme->primme.globalSumDouble = par_GlobalSumDouble; primme->method = (primme_preset_method)EPS_PRIMME_DEFAULT_MIN_TIME; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetBlockSize_C",EPSPRIMMESetBlockSize_PRIMME);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMESetMethod_C",EPSPRIMMESetMethod_PRIMME);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetBlockSize_C",EPSPRIMMEGetBlockSize_PRIMME);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPRIMMEGetMethod_C",EPSPRIMMEGetMethod_PRIMME);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/external/primme/makefile.html0000644000175000017500000000503613107004621022447 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresdefine  'SLEPC_HAVE_PRIMME'

CFLAGS   = ${PRIMME_FLAGS}
FFLAGS   =
SOURCEC  = primme.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/external/primme/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/external/primme/index.html0000644000175000017500000000262213107004621021777 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

primme.c
makefile
slepc-3.7.4/src/eps/impls/external/primme/ftn-auto/0000755000175000017500000000000013107004621021535 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/primme/ftn-auto/makefile0000644000175000017500000000037213107004621023237 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = primmef.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/external/primme/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/primme/ftn-auto/primmef.c0000644000175000017500000000435613107004621023350 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* primme.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsprimmesetblocksize_ EPSPRIMMESETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsprimmesetblocksize_ epsprimmesetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsprimmegetblocksize_ EPSPRIMMEGETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsprimmegetblocksize_ epsprimmegetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsprimmesetmethod_ EPSPRIMMESETMETHOD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsprimmesetmethod_ epsprimmesetmethod #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsprimmegetmethod_ EPSPRIMMEGETMETHOD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsprimmegetmethod_ epsprimmegetmethod #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsprimmesetblocksize_(EPS eps,PetscInt *bs, int *__ierr ){ *__ierr = EPSPRIMMESetBlockSize( (EPS)PetscToPointer((eps) ),*bs); } PETSC_EXTERN void PETSC_STDCALL epsprimmegetblocksize_(EPS eps,PetscInt *bs, int *__ierr ){ *__ierr = EPSPRIMMEGetBlockSize( (EPS)PetscToPointer((eps) ),bs); } PETSC_EXTERN void PETSC_STDCALL epsprimmesetmethod_(EPS eps,EPSPRIMMEMethod *method, int *__ierr ){ *__ierr = EPSPRIMMESetMethod( (EPS)PetscToPointer((eps) ),*method); } PETSC_EXTERN void PETSC_STDCALL epsprimmegetmethod_(EPS eps,EPSPRIMMEMethod *method, int *__ierr ){ *__ierr = EPSPRIMMEGetMethod( (EPS)PetscToPointer((eps) ),method); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/external/arpack/0000755000175000017500000000000013107004621017750 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/arpack/makefile0000644000175000017500000000224613107004621021454 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresdefine 'SLEPC_HAVE_ARPACK' CFLAGS = FFLAGS = SOURCEC = arpack.c SOURCEF = SOURCEH = arpackp.h LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/external/arpack/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/arpack/arpack.c0000644000175000017500000003507213107004621021364 0ustar jromanjroman/* This file implements a wrapper to the ARPACK package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include <../src/eps/impls/external/arpack/arpackp.h> PetscErrorCode EPSSolve_ARPACK(EPS); #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_ARPACK" PetscErrorCode EPSSetUp_ARPACK(EPS eps) { PetscErrorCode ierr; PetscInt ncv; PetscBool flg,istrivial; EPS_ARPACK *ar = (EPS_ARPACK*)eps->data; PetscFunctionBegin; if (eps->ncv) { if (eps->ncvnev+2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The value of ncv must be at least nev+2"); } else eps->ncv = PetscMin(PetscMax(20,2*eps->nev+1),eps->n); /* set default value of ncv */ if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (!eps->max_it) eps->max_it = PetscMax(300,(PetscInt)(2*eps->n/eps->ncv)); if (!eps->which) eps->which = EPS_LARGEST_MAGNITUDE; ncv = eps->ncv; #if defined(PETSC_USE_COMPLEX) ierr = PetscFree(ar->rwork);CHKERRQ(ierr); ierr = PetscMalloc1(ncv,&ar->rwork);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,ncv*sizeof(PetscReal));CHKERRQ(ierr); ierr = PetscBLASIntCast(3*ncv*ncv+5*ncv,&ar->lworkl);CHKERRQ(ierr); ierr = PetscFree(ar->workev);CHKERRQ(ierr); ierr = PetscMalloc1(3*ncv,&ar->workev);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,3*ncv*sizeof(PetscScalar));CHKERRQ(ierr); #else if (eps->ishermitian) { ierr = PetscBLASIntCast(ncv*(ncv+8),&ar->lworkl);CHKERRQ(ierr); } else { ierr = PetscBLASIntCast(3*ncv*ncv+6*ncv,&ar->lworkl);CHKERRQ(ierr); ierr = PetscFree(ar->workev);CHKERRQ(ierr); ierr = PetscMalloc1(3*ncv,&ar->workev);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,3*ncv*sizeof(PetscScalar));CHKERRQ(ierr); } #endif ierr = PetscFree(ar->workl);CHKERRQ(ierr); ierr = PetscMalloc1(ar->lworkl,&ar->workl);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,ar->lworkl*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscFree(ar->select);CHKERRQ(ierr); ierr = PetscMalloc1(ncv,&ar->select);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,ncv*sizeof(PetscBool));CHKERRQ(ierr); ierr = PetscFree(ar->workd);CHKERRQ(ierr); ierr = PetscMalloc1(3*eps->nloc,&ar->workd);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,3*eps->nloc*sizeof(PetscScalar));CHKERRQ(ierr); if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } if (eps->balance!=EPS_BALANCE_NONE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Balancing not supported in the Arpack interface"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test"); ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); ierr = EPSSetWorkVecs(eps,2);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage"); ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering"); /* dispatch solve method */ eps->ops->solve = EPSSolve_ARPACK; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_ARPACK" PetscErrorCode EPSSolve_ARPACK(EPS eps) { PetscErrorCode ierr; EPS_ARPACK *ar = (EPS_ARPACK*)eps->data; char bmat[1],howmny[] = "A"; const char *which; PetscBLASInt n,iparam[11],ipntr[14],ido,info,nev,ncv; #if !defined(PETSC_HAVE_MPIUNI) PetscBLASInt fcomm; #endif PetscScalar sigmar,*pV,*resid; Vec v0,x,y,w = eps->work[0]; Mat A; PetscBool isSinv,isShift,rvec; #if !defined(PETSC_USE_COMPLEX) PetscScalar sigmai = 0.0; #endif PetscFunctionBegin; ierr = PetscBLASIntCast(eps->nev,&nev);CHKERRQ(ierr); ierr = PetscBLASIntCast(eps->ncv,&ncv);CHKERRQ(ierr); #if !defined(PETSC_HAVE_MPIUNI) ierr = PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&fcomm);CHKERRQ(ierr); #endif ierr = PetscBLASIntCast(eps->nloc,&n);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&x);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&y);CHKERRQ(ierr); ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,0);CHKERRQ(ierr); /* just for deflation space */ ierr = BVGetColumn(eps->V,0,&v0);CHKERRQ(ierr); ierr = VecCopy(v0,eps->work[1]);CHKERRQ(ierr); ierr = VecGetArray(v0,&pV);CHKERRQ(ierr); ierr = VecGetArray(eps->work[1],&resid);CHKERRQ(ierr); ido = 0; /* first call to reverse communication interface */ info = 1; /* indicates a initial vector is provided */ iparam[0] = 1; /* use exact shifts */ ierr = PetscBLASIntCast(eps->max_it,&iparam[2]);CHKERRQ(ierr); /* max Arnoldi iterations */ iparam[3] = 1; /* blocksize */ iparam[4] = 0; /* number of converged Ritz values */ /* Computational modes ([]=not supported): symmetric non-symmetric complex 1 1 'I' 1 'I' 1 'I' 2 3 'I' 3 'I' 3 'I' 3 2 'G' 2 'G' 2 'G' 4 3 'G' 3 'G' 3 'G' 5 [ 4 'G' ] [ 3 'G' ] 6 [ 5 'G' ] [ 4 'G' ] */ ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&isSinv);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSHIFT,&isShift);CHKERRQ(ierr); ierr = STGetShift(eps->st,&sigmar);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (isSinv) { /* shift-and-invert mode */ iparam[6] = 3; if (eps->ispositive) bmat[0] = 'G'; else bmat[0] = 'I'; } else if (isShift && eps->ispositive) { /* generalized shift mode with B positive definite */ iparam[6] = 2; bmat[0] = 'G'; } else { /* regular mode */ if (eps->ishermitian && eps->isgeneralized) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectral transformation not supported by ARPACK hermitian solver"); iparam[6] = 1; bmat[0] = 'I'; } #if !defined(PETSC_USE_COMPLEX) if (eps->ishermitian) { switch (eps->which) { case EPS_TARGET_MAGNITUDE: case EPS_LARGEST_MAGNITUDE: which = "LM"; break; case EPS_SMALLEST_MAGNITUDE: which = "SM"; break; case EPS_TARGET_REAL: case EPS_LARGEST_REAL: which = "LA"; break; case EPS_SMALLEST_REAL: which = "SA"; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Wrong value of eps->which"); } } else { #endif switch (eps->which) { case EPS_TARGET_MAGNITUDE: case EPS_LARGEST_MAGNITUDE: which = "LM"; break; case EPS_SMALLEST_MAGNITUDE: which = "SM"; break; case EPS_TARGET_REAL: case EPS_LARGEST_REAL: which = "LR"; break; case EPS_SMALLEST_REAL: which = "SR"; break; case EPS_TARGET_IMAGINARY: case EPS_LARGEST_IMAGINARY: which = "LI"; break; case EPS_SMALLEST_IMAGINARY: which = "SI"; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Wrong value of eps->which"); } #if !defined(PETSC_USE_COMPLEX) } #endif do { #if !defined(PETSC_USE_COMPLEX) if (eps->ishermitian) { PetscStackCall("ARPACKsaupd",ARPACKsaupd_(&fcomm,&ido,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info)); } else { PetscStackCall("ARPACKnaupd",ARPACKnaupd_(&fcomm,&ido,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info)); } #else PetscStackCall("ARPACKnaupd",ARPACKnaupd_(&fcomm,&ido,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,ar->rwork,&info)); #endif if (ido == -1 || ido == 1 || ido == 2) { if (ido == 1 && iparam[6] == 3 && bmat[0] == 'G') { /* special case for shift-and-invert with B semi-positive definite*/ ierr = VecPlaceArray(x,&ar->workd[ipntr[2]-1]);CHKERRQ(ierr); } else { ierr = VecPlaceArray(x,&ar->workd[ipntr[0]-1]);CHKERRQ(ierr); } ierr = VecPlaceArray(y,&ar->workd[ipntr[1]-1]);CHKERRQ(ierr); if (ido == -1) { /* Y = OP * X for for the initialization phase to force the starting vector into the range of OP */ ierr = STApply(eps->st,x,y);CHKERRQ(ierr); } else if (ido == 2) { /* Y = B * X */ ierr = BVApplyMatrix(eps->V,x,y);CHKERRQ(ierr); } else { /* ido == 1 */ if (iparam[6] == 3 && bmat[0] == 'G') { /* Y = OP * X for shift-and-invert with B semi-positive definite */ ierr = STMatSolve(eps->st,x,y);CHKERRQ(ierr); } else if (iparam[6] == 2) { /* X=A*X Y=B^-1*X for shift with B positive definite */ ierr = MatMult(A,x,y);CHKERRQ(ierr); if (sigmar != 0.0) { ierr = BVApplyMatrix(eps->V,x,w);CHKERRQ(ierr); ierr = VecAXPY(y,sigmar,w);CHKERRQ(ierr); } ierr = VecCopy(y,x);CHKERRQ(ierr); ierr = STMatSolve(eps->st,x,y);CHKERRQ(ierr); } else { /* Y = OP * X */ ierr = STApply(eps->st,x,y);CHKERRQ(ierr); } ierr = BVOrthogonalizeVec(eps->V,y,NULL,NULL,NULL);CHKERRQ(ierr); } ierr = VecResetArray(x);CHKERRQ(ierr); ierr = VecResetArray(y);CHKERRQ(ierr); } else if (ido != 99) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Internal error in ARPACK reverse comunication interface (ido=%d)",ido); } while (ido != 99); eps->nconv = iparam[4]; eps->its = iparam[2]; if (info==3) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"No shift could be applied in xxAUPD.\nTry increasing the size of NCV relative to NEV"); else if (info!=0 && info!=1) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error reported by ARPACK subroutine xxAUPD (%d)",info); rvec = PETSC_TRUE; if (eps->nconv > 0) { #if !defined(PETSC_USE_COMPLEX) if (eps->ishermitian) { ierr = EPSMonitor(eps,iparam[2],iparam[4],&ar->workl[ipntr[5]-1],eps->eigi,&ar->workl[ipntr[6]-1],eps->ncv);CHKERRQ(ierr); PetscStackCall("ARPACKseupd",ARPACKseupd_(&fcomm,&rvec,howmny,ar->select,eps->eigr,pV,&n,&sigmar,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info)); } else { ierr = EPSMonitor(eps,iparam[2],iparam[4],&ar->workl[ipntr[5]-1],&ar->workl[ipntr[6]-1],&ar->workl[ipntr[7]-1],eps->ncv);CHKERRQ(ierr); PetscStackCall("ARPACKneupd",ARPACKneupd_(&fcomm,&rvec,howmny,ar->select,eps->eigr,eps->eigi,pV,&n,&sigmar,&sigmai,ar->workev,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info)); } #else ierr = EPSMonitor(eps,eps->its,iparam[4],&ar->workl[ipntr[5]-1],eps->eigi,(PetscReal*)&ar->workl[ipntr[7]-1],eps->ncv);CHKERRQ(ierr); PetscStackCall("ARPACKneupd",ARPACKneupd_(&fcomm,&rvec,howmny,ar->select,eps->eigr,pV,&n,&sigmar,ar->workev,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,ar->rwork,&info)); #endif if (info!=0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error reported by ARPACK subroutine xxEUPD (%d)",info); } ierr = VecRestoreArray(v0,&pV);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&v0);CHKERRQ(ierr); ierr = VecRestoreArray(eps->work[1],&resid);CHKERRQ(ierr); if (eps->nconv >= eps->nev) eps->reason = EPS_CONVERGED_TOL; else eps->reason = EPS_DIVERGED_ITS; if (eps->ishermitian) { ierr = PetscMemcpy(eps->errest,&ar->workl[ipntr[8]-1],eps->nconv);CHKERRQ(ierr); } else { ierr = PetscMemcpy(eps->errest,&ar->workl[ipntr[10]-1],eps->nconv);CHKERRQ(ierr); } ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBackTransform_ARPACK" PetscErrorCode EPSBackTransform_ARPACK(EPS eps) { PetscErrorCode ierr; PetscBool isSinv; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&isSinv);CHKERRQ(ierr); if (!isSinv) { ierr = EPSBackTransform_Default(eps);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_ARPACK" PetscErrorCode EPSReset_ARPACK(EPS eps) { PetscErrorCode ierr; EPS_ARPACK *ar = (EPS_ARPACK*)eps->data; PetscFunctionBegin; ierr = PetscFree(ar->workev);CHKERRQ(ierr); ierr = PetscFree(ar->workl);CHKERRQ(ierr); ierr = PetscFree(ar->select);CHKERRQ(ierr); ierr = PetscFree(ar->workd);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscFree(ar->rwork);CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_ARPACK" PetscErrorCode EPSDestroy_ARPACK(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_ARPACK" PETSC_EXTERN PetscErrorCode EPSCreate_ARPACK(EPS eps) { EPS_ARPACK *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; eps->ops->setup = EPSSetUp_ARPACK; eps->ops->destroy = EPSDestroy_ARPACK; eps->ops->reset = EPSReset_ARPACK; eps->ops->backtransform = EPSBackTransform_ARPACK; PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/external/arpack/makefile.html0000644000175000017500000000502713107004621022417 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresdefine  'SLEPC_HAVE_ARPACK'

CFLAGS   =
FFLAGS   =
SOURCEC  = arpack.c
SOURCEF  =
SOURCEH  = arpackp.h
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/external/arpack/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/external/arpack/arpack.c.html0000644000175000017500000007247213107004621022334 0ustar jromanjroman
Actual source code: arpack.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the ARPACK package

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>
 25: #include <../src/eps/impls/external/arpack/arpackp.h>

 27: PetscErrorCode EPSSolve_ARPACK(EPS);

 31: PetscErrorCode EPSSetUp_ARPACK(EPS eps)
 32: {
 34:   PetscInt       ncv;
 35:   PetscBool      flg,istrivial;
 36:   EPS_ARPACK     *ar = (EPS_ARPACK*)eps->data;

 39:   if (eps->ncv) {
 40:     if (eps->ncv<eps->nev+2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The value of ncv must be at least nev+2");
 41:   } else eps->ncv = PetscMin(PetscMax(20,2*eps->nev+1),eps->n); /* set default value of ncv */
 42:   if (eps->mpd) { PetscInfo(eps,"Warning: parameter mpd ignored\n"); }
 43:   if (!eps->max_it) eps->max_it = PetscMax(300,(PetscInt)(2*eps->n/eps->ncv));
 44:   if (!eps->which) eps->which = EPS_LARGEST_MAGNITUDE;

 46:   ncv = eps->ncv;
 47: #if defined(PETSC_USE_COMPLEX)
 48:   PetscFree(ar->rwork);
 49:   PetscMalloc1(ncv,&ar->rwork);
 50:   PetscLogObjectMemory((PetscObject)eps,ncv*sizeof(PetscReal));
 51:   PetscBLASIntCast(3*ncv*ncv+5*ncv,&ar->lworkl);
 52:   PetscFree(ar->workev);
 53:   PetscMalloc1(3*ncv,&ar->workev);
 54:   PetscLogObjectMemory((PetscObject)eps,3*ncv*sizeof(PetscScalar));
 55: #else
 56:   if (eps->ishermitian) {
 57:     PetscBLASIntCast(ncv*(ncv+8),&ar->lworkl);
 58:   } else {
 59:     PetscBLASIntCast(3*ncv*ncv+6*ncv,&ar->lworkl);
 60:     PetscFree(ar->workev);
 61:     PetscMalloc1(3*ncv,&ar->workev);
 62:     PetscLogObjectMemory((PetscObject)eps,3*ncv*sizeof(PetscScalar));
 63:   }
 64: #endif
 65:   PetscFree(ar->workl);
 66:   PetscMalloc1(ar->lworkl,&ar->workl);
 67:   PetscLogObjectMemory((PetscObject)eps,ar->lworkl*sizeof(PetscScalar));
 68:   PetscFree(ar->select);
 69:   PetscMalloc1(ncv,&ar->select);
 70:   PetscLogObjectMemory((PetscObject)eps,ncv*sizeof(PetscBool));
 71:   PetscFree(ar->workd);
 72:   PetscMalloc1(3*eps->nloc,&ar->workd);
 73:   PetscLogObjectMemory((PetscObject)eps,3*eps->nloc*sizeof(PetscScalar));

 75:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }

 77:   if (eps->balance!=EPS_BALANCE_NONE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Balancing not supported in the Arpack interface");
 78:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
 79:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test");

 81:   EPSAllocateSolution(eps,0);
 82:   EPS_SetInnerProduct(eps);
 83:   EPSSetWorkVecs(eps,2);

 85:   PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);
 86:   if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage");
 87:   RGIsTrivial(eps->rg,&istrivial);
 88:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");

 90:   /* dispatch solve method */
 91:   eps->ops->solve = EPSSolve_ARPACK;
 92:   return(0);
 93: }

 97: PetscErrorCode EPSSolve_ARPACK(EPS eps)
 98: {
100:   EPS_ARPACK     *ar = (EPS_ARPACK*)eps->data;
101:   char           bmat[1],howmny[] = "A";
102:   const char     *which;
103:   PetscBLASInt   n,iparam[11],ipntr[14],ido,info,nev,ncv;
104: #if !defined(PETSC_HAVE_MPIUNI)
105:   PetscBLASInt   fcomm;
106: #endif
107:   PetscScalar    sigmar,*pV,*resid;
108:   Vec            v0,x,y,w = eps->work[0];
109:   Mat            A;
110:   PetscBool      isSinv,isShift,rvec;
111: #if !defined(PETSC_USE_COMPLEX)
112:   PetscScalar    sigmai = 0.0;
113: #endif

116:   PetscBLASIntCast(eps->nev,&nev);
117:   PetscBLASIntCast(eps->ncv,&ncv);
118: #if !defined(PETSC_HAVE_MPIUNI)
119:   PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&fcomm);
120: #endif
121:   PetscBLASIntCast(eps->nloc,&n);
122:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&x);
123:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&y);
124:   EPSGetStartVector(eps,0,NULL);
125:   BVSetActiveColumns(eps->V,0,0);  /* just for deflation space */
126:   BVGetColumn(eps->V,0,&v0);
127:   VecCopy(v0,eps->work[1]);
128:   VecGetArray(v0,&pV);
129:   VecGetArray(eps->work[1],&resid);

131:   ido  = 0;            /* first call to reverse communication interface */
132:   info = 1;            /* indicates a initial vector is provided */
133:   iparam[0] = 1;       /* use exact shifts */
134:   PetscBLASIntCast(eps->max_it,&iparam[2]);  /* max Arnoldi iterations */
135:   iparam[3] = 1;       /* blocksize */
136:   iparam[4] = 0;       /* number of converged Ritz values */

138:   /*
139:      Computational modes ([]=not supported):
140:             symmetric    non-symmetric    complex
141:         1     1  'I'        1  'I'         1  'I'
142:         2     3  'I'        3  'I'         3  'I'
143:         3     2  'G'        2  'G'         2  'G'
144:         4     3  'G'        3  'G'         3  'G'
145:         5   [ 4  'G' ]    [ 3  'G' ]
146:         6   [ 5  'G' ]    [ 4  'G' ]
147:    */
148:   PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&isSinv);
149:   PetscObjectTypeCompare((PetscObject)eps->st,STSHIFT,&isShift);
150:   STGetShift(eps->st,&sigmar);
151:   STGetOperators(eps->st,0,&A);

153:   if (isSinv) {
154:     /* shift-and-invert mode */
155:     iparam[6] = 3;
156:     if (eps->ispositive) bmat[0] = 'G';
157:     else bmat[0] = 'I';
158:   } else if (isShift && eps->ispositive) {
159:     /* generalized shift mode with B positive definite */
160:     iparam[6] = 2;
161:     bmat[0] = 'G';
162:   } else {
163:     /* regular mode */
164:     if (eps->ishermitian && eps->isgeneralized)
165:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectral transformation not supported by ARPACK hermitian solver");
166:     iparam[6] = 1;
167:     bmat[0] = 'I';
168:   }

170: #if !defined(PETSC_USE_COMPLEX)
171:     if (eps->ishermitian) {
172:       switch (eps->which) {
173:         case EPS_TARGET_MAGNITUDE:
174:         case EPS_LARGEST_MAGNITUDE:  which = "LM"; break;
175:         case EPS_SMALLEST_MAGNITUDE: which = "SM"; break;
176:         case EPS_TARGET_REAL:
177:         case EPS_LARGEST_REAL:       which = "LA"; break;
178:         case EPS_SMALLEST_REAL:      which = "SA"; break;
179:         default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Wrong value of eps->which");
180:       }
181:     } else {
182: #endif
183:       switch (eps->which) {
184:         case EPS_TARGET_MAGNITUDE:
185:         case EPS_LARGEST_MAGNITUDE:  which = "LM"; break;
186:         case EPS_SMALLEST_MAGNITUDE: which = "SM"; break;
187:         case EPS_TARGET_REAL:
188:         case EPS_LARGEST_REAL:       which = "LR"; break;
189:         case EPS_SMALLEST_REAL:      which = "SR"; break;
190:         case EPS_TARGET_IMAGINARY:
191:         case EPS_LARGEST_IMAGINARY:  which = "LI"; break;
192:         case EPS_SMALLEST_IMAGINARY: which = "SI"; break;
193:         default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Wrong value of eps->which");
194:       }
195: #if !defined(PETSC_USE_COMPLEX)
196:     }
197: #endif

199:   do {

201: #if !defined(PETSC_USE_COMPLEX)
202:     if (eps->ishermitian) {
203:       PetscStackCall("ARPACKsaupd",ARPACKsaupd_(&fcomm,&ido,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info));
204:     } else {
205:       PetscStackCall("ARPACKnaupd",ARPACKnaupd_(&fcomm,&ido,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info));
206:     }
207: #else
208:     PetscStackCall("ARPACKnaupd",ARPACKnaupd_(&fcomm,&ido,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,ar->rwork,&info));
209: #endif

211:     if (ido == -1 || ido == 1 || ido == 2) {
212:       if (ido == 1 && iparam[6] == 3 && bmat[0] == 'G') {
213:         /* special case for shift-and-invert with B semi-positive definite*/
214:         VecPlaceArray(x,&ar->workd[ipntr[2]-1]);
215:       } else {
216:         VecPlaceArray(x,&ar->workd[ipntr[0]-1]);
217:       }
218:       VecPlaceArray(y,&ar->workd[ipntr[1]-1]);

220:       if (ido == -1) {
221:         /* Y = OP * X for for the initialization phase to
222:            force the starting vector into the range of OP */
223:         STApply(eps->st,x,y);
224:       } else if (ido == 2) {
225:         /* Y = B * X */
226:         BVApplyMatrix(eps->V,x,y);
227:       } else { /* ido == 1 */
228:         if (iparam[6] == 3 && bmat[0] == 'G') {
229:           /* Y = OP * X for shift-and-invert with B semi-positive definite */
230:           STMatSolve(eps->st,x,y);
231:         } else if (iparam[6] == 2) {
232:           /* X=A*X Y=B^-1*X for shift with B positive definite */
233:           MatMult(A,x,y);
234:           if (sigmar != 0.0) {
235:             BVApplyMatrix(eps->V,x,w);
236:             VecAXPY(y,sigmar,w);
237:           }
238:           VecCopy(y,x);
239:           STMatSolve(eps->st,x,y);
240:         } else {
241:           /* Y = OP * X */
242:           STApply(eps->st,x,y);
243:         }
244:         BVOrthogonalizeVec(eps->V,y,NULL,NULL,NULL);
245:       }

247:       VecResetArray(x);
248:       VecResetArray(y);
249:     } else if (ido != 99) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Internal error in ARPACK reverse comunication interface (ido=%d)",ido);

251:   } while (ido != 99);

253:   eps->nconv = iparam[4];
254:   eps->its = iparam[2];

256:   if (info==3) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"No shift could be applied in xxAUPD.\nTry increasing the size of NCV relative to NEV");
257:   else if (info!=0 && info!=1) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error reported by ARPACK subroutine xxAUPD (%d)",info);

259:   rvec = PETSC_TRUE;

261:   if (eps->nconv > 0) {
262: #if !defined(PETSC_USE_COMPLEX)
263:     if (eps->ishermitian) {
264:       EPSMonitor(eps,iparam[2],iparam[4],&ar->workl[ipntr[5]-1],eps->eigi,&ar->workl[ipntr[6]-1],eps->ncv);
265:       PetscStackCall("ARPACKseupd",ARPACKseupd_(&fcomm,&rvec,howmny,ar->select,eps->eigr,pV,&n,&sigmar,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info));
266:     } else {
267:       EPSMonitor(eps,iparam[2],iparam[4],&ar->workl[ipntr[5]-1],&ar->workl[ipntr[6]-1],&ar->workl[ipntr[7]-1],eps->ncv);
268:       PetscStackCall("ARPACKneupd",ARPACKneupd_(&fcomm,&rvec,howmny,ar->select,eps->eigr,eps->eigi,pV,&n,&sigmar,&sigmai,ar->workev,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,&info));
269:     }
270: #else
271:     EPSMonitor(eps,eps->its,iparam[4],&ar->workl[ipntr[5]-1],eps->eigi,(PetscReal*)&ar->workl[ipntr[7]-1],eps->ncv);
272:     PetscStackCall("ARPACKneupd",ARPACKneupd_(&fcomm,&rvec,howmny,ar->select,eps->eigr,pV,&n,&sigmar,ar->workev,bmat,&n,which,&nev,&eps->tol,resid,&ncv,pV,&n,iparam,ipntr,ar->workd,ar->workl,&ar->lworkl,ar->rwork,&info));
273: #endif
274:     if (info!=0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error reported by ARPACK subroutine xxEUPD (%d)",info);
275:   }

277:   VecRestoreArray(v0,&pV);
278:   BVRestoreColumn(eps->V,0,&v0);
279:   VecRestoreArray(eps->work[1],&resid);
280:   if (eps->nconv >= eps->nev) eps->reason = EPS_CONVERGED_TOL;
281:   else eps->reason = EPS_DIVERGED_ITS;

283:   if (eps->ishermitian) {
284:     PetscMemcpy(eps->errest,&ar->workl[ipntr[8]-1],eps->nconv);
285:   } else {
286:     PetscMemcpy(eps->errest,&ar->workl[ipntr[10]-1],eps->nconv);
287:   }

289:   VecDestroy(&x);
290:   VecDestroy(&y);
291:   return(0);
292: }

296: PetscErrorCode EPSBackTransform_ARPACK(EPS eps)
297: {
299:   PetscBool      isSinv;

302:   PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&isSinv);
303:   if (!isSinv) {
304:     EPSBackTransform_Default(eps);
305:   }
306:   return(0);
307: }

311: PetscErrorCode EPSReset_ARPACK(EPS eps)
312: {
314:   EPS_ARPACK     *ar = (EPS_ARPACK*)eps->data;

317:   PetscFree(ar->workev);
318:   PetscFree(ar->workl);
319:   PetscFree(ar->select);
320:   PetscFree(ar->workd);
321: #if defined(PETSC_USE_COMPLEX)
322:   PetscFree(ar->rwork);
323: #endif
324:   return(0);
325: }

329: PetscErrorCode EPSDestroy_ARPACK(EPS eps)
330: {

334:   PetscFree(eps->data);
335:   return(0);
336: }

340: PETSC_EXTERN PetscErrorCode EPSCreate_ARPACK(EPS eps)
341: {
342:   EPS_ARPACK     *ctx;

346:   PetscNewLog(eps,&ctx);
347:   eps->data = (void*)ctx;

349:   eps->ops->setup                = EPSSetUp_ARPACK;
350:   eps->ops->destroy              = EPSDestroy_ARPACK;
351:   eps->ops->reset                = EPSReset_ARPACK;
352:   eps->ops->backtransform        = EPSBackTransform_ARPACK;
353:   return(0);
354: }

slepc-3.7.4/src/eps/impls/external/arpack/arpackp.h.html0000644000175000017500000004074113107004621022513 0ustar jromanjroman
Actual source code: arpackp.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private data structure used by the ARPACK interface

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

  8:    This file is part of SLEPc.

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

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

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


 27: typedef struct {
 28:   PetscBool    *select;
 29:   PetscScalar  *workev;
 30:   PetscScalar  *workd;
 31:   PetscScalar  *workl;
 32:   PetscBLASInt lworkl;
 33:   PetscReal    *rwork;
 34: } EPS_ARPACK;

 36: /*
 37:    Definition of routines from the ARPACK package
 38: */

 40: #if defined(PETSC_HAVE_MPIUNI)

 42: #if defined(PETSC_USE_COMPLEX)

 44: #if defined(PETSC_USE_REAL_SINGLE)

 46: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
 47: #define SLEPC_ARPACK(lcase,ucase) c##lcase##_
 48: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
 49: #define SLEPC_ARPACK(lcase,ucase) C##ucase
 50: #else
 51: #define SLEPC_ARPACK(lcase,ucase) c##lcase
 52: #endif

 54: #else

 56: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
 57: #define SLEPC_ARPACK(lcase,ucase) z##lcase##_
 58: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
 59: #define SLEPC_ARPACK(lcase,ucase) Z##ucase
 60: #else
 61: #define SLEPC_ARPACK(lcase,ucase) z##lcase
 62: #endif

 64: #endif

 66: #else

 68: #if defined(PETSC_USE_REAL_SINGLE)

 70: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
 71: #define SLEPC_ARPACK(lcase,ucase) s##lcase##_
 72: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
 73: #define SLEPC_ARPACK(lcase,ucase) S##ucase
 74: #else
 75: #define SLEPC_ARPACK(lcase,ucase) s##lcase
 76: #endif

 78: #else

 80: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
 81: #define SLEPC_ARPACK(lcase,ucase) d##lcase##_
 82: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
 83: #define SLEPC_ARPACK(lcase,ucase) D##ucase
 84: #else
 85: #define SLEPC_ARPACK(lcase,ucase) d##lcase
 86: #endif

 88: #endif

 90: #endif

 92: #else  /* not MPIUNI */

 94: #if defined(PETSC_USE_COMPLEX)

 96: #if defined(PETSC_USE_REAL_SINGLE)

 98: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
 99: #define SLEPC_ARPACK(lcase,ucase) pc##lcase##_
100: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
101: #define SLEPC_ARPACK(lcase,ucase) PC##ucase
102: #else
103: #define SLEPC_ARPACK(lcase,ucase) pc##lcase
104: #endif

106: #else

108: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
109: #define SLEPC_ARPACK(lcase,ucase) pz##lcase##_
110: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
111: #define SLEPC_ARPACK(lcase,ucase) PZ##ucase
112: #else
113: #define SLEPC_ARPACK(lcase,ucase) pz##lcase
114: #endif

116: #endif

118: #else

120: #if defined(PETSC_USE_REAL_SINGLE)

122: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
123: #define SLEPC_ARPACK(lcase,ucase) ps##lcase##_
124: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
125: #define SLEPC_ARPACK(lcase,ucase) PS##ucase
126: #else
127: #define SLEPC_ARPACK(lcase,ucase) ps##lcase
128: #endif

130: #else

132: #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE)
133: #define SLEPC_ARPACK(lcase,ucase) pd##lcase##_
134: #elif defined(SLEPC_ARPACK_HAVE_CAPS)
135: #define SLEPC_ARPACK(lcase,ucase) PD##ucase
136: #else
137: #define SLEPC_ARPACK(lcase,ucase) pd##lcase
138: #endif

140: #endif

142: #endif

144: #endif

146: #if defined(PETSC_HAVE_MPIUNI)

148: #define COMM_ARG

150: #if !defined(PETSC_USE_COMPLEX)

152: #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(naupd,NAUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2)
153: #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) SLEPC_ARPACK(neupd,NEUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),1,1,2)
154: #define ARPACKsaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(saupd,SAUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2)
155: #define ARPACKseupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u,v,w) SLEPC_ARPACK(seupd,SEUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,2)

157: #else

159: #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_ARPACK(naupd,NAUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,2)
160: #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) SLEPC_ARPACK(neupd,NEUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),1,1,2)

162: #endif

164: #else /* not MPIUNI */

166: #define COMM_ARG MPI_Fint*,

168: #if !defined(PETSC_USE_COMPLEX)

170: #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(naupd,NAUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2)
171: #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) SLEPC_ARPACK(neupd,NEUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),1,1,2)
172: #define ARPACKsaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(saupd,SAUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2)
173: #define ARPACKseupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u,v,w) SLEPC_ARPACK(seupd,SEUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,2)

175: #else

177: #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_ARPACK(naupd,NAUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,2)
178: #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) SLEPC_ARPACK(neupd,NEUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),1,1,2)

180: #endif

182: #endif

184: PETSC_EXTERN void   SLEPC_ARPACK(saupd,SAUPD)(COMM_ARG PetscBLASInt*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int);
185: PETSC_EXTERN void   SLEPC_ARPACK(seupd,SEUPD)(COMM_ARG PetscBool*,char*,PetscBool*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int,int);

187: #if !defined(PETSC_USE_COMPLEX)
188: PETSC_EXTERN void   SLEPC_ARPACK(naupd,NAUPD)(COMM_ARG PetscBLASInt*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int);
189: PETSC_EXTERN void   SLEPC_ARPACK(neupd,NEUPD)(COMM_ARG PetscBool*,char*,PetscBool*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int,int);
190: #else
191: PETSC_EXTERN void   SLEPC_ARPACK(naupd,NAUPD)(COMM_ARG PetscBLASInt*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,int,int);
192: PETSC_EXTERN void   SLEPC_ARPACK(neupd,NEUPD)(COMM_ARG PetscBool*,char*,PetscBool*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,int,int,int);
193: #endif

195: #endif

slepc-3.7.4/src/eps/impls/external/arpack/index.html0000644000175000017500000000267513107004621021757 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

arpackp.h
arpack.c
makefile
slepc-3.7.4/src/eps/impls/external/arpack/arpackp.h0000644000175000017500000001720013107004621021542 0ustar jromanjroman/* Private data structure used by the ARPACK interface - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__ARPACKP_H) #define __ARPACKP_H typedef struct { PetscBool *select; PetscScalar *workev; PetscScalar *workd; PetscScalar *workl; PetscBLASInt lworkl; PetscReal *rwork; } EPS_ARPACK; /* Definition of routines from the ARPACK package */ #if defined(PETSC_HAVE_MPIUNI) #if defined(PETSC_USE_COMPLEX) #if defined(PETSC_USE_REAL_SINGLE) #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) c##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) C##ucase #else #define SLEPC_ARPACK(lcase,ucase) c##lcase #endif #else #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) z##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) Z##ucase #else #define SLEPC_ARPACK(lcase,ucase) z##lcase #endif #endif #else #if defined(PETSC_USE_REAL_SINGLE) #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) s##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) S##ucase #else #define SLEPC_ARPACK(lcase,ucase) s##lcase #endif #else #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) d##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) D##ucase #else #define SLEPC_ARPACK(lcase,ucase) d##lcase #endif #endif #endif #else /* not MPIUNI */ #if defined(PETSC_USE_COMPLEX) #if defined(PETSC_USE_REAL_SINGLE) #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) pc##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) PC##ucase #else #define SLEPC_ARPACK(lcase,ucase) pc##lcase #endif #else #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) pz##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) PZ##ucase #else #define SLEPC_ARPACK(lcase,ucase) pz##lcase #endif #endif #else #if defined(PETSC_USE_REAL_SINGLE) #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) ps##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) PS##ucase #else #define SLEPC_ARPACK(lcase,ucase) ps##lcase #endif #else #if defined(SLEPC_ARPACK_HAVE_UNDERSCORE) #define SLEPC_ARPACK(lcase,ucase) pd##lcase##_ #elif defined(SLEPC_ARPACK_HAVE_CAPS) #define SLEPC_ARPACK(lcase,ucase) PD##ucase #else #define SLEPC_ARPACK(lcase,ucase) pd##lcase #endif #endif #endif #endif #if defined(PETSC_HAVE_MPIUNI) #define COMM_ARG #if !defined(PETSC_USE_COMPLEX) #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(naupd,NAUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2) #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) SLEPC_ARPACK(neupd,NEUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),1,1,2) #define ARPACKsaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(saupd,SAUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2) #define ARPACKseupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u,v,w) SLEPC_ARPACK(seupd,SEUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,2) #else #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_ARPACK(naupd,NAUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,2) #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) SLEPC_ARPACK(neupd,NEUPD) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),1,1,2) #endif #else /* not MPIUNI */ #define COMM_ARG MPI_Fint*, #if !defined(PETSC_USE_COMPLEX) #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(naupd,NAUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2) #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) SLEPC_ARPACK(neupd,NEUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),(y),1,1,2) #define ARPACKsaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) SLEPC_ARPACK(saupd,SAUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),1,2) #define ARPACKseupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u,v,w) SLEPC_ARPACK(seupd,SEUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(o),(p),(q),(r),(s),(t),(u),(v),(w),1,1,2) #else #define ARPACKnaupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) SLEPC_ARPACK(naupd,NAUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),1,2) #define ARPACKneupd_(comm,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) SLEPC_ARPACK(neupd,NEUPD) ((comm),(a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r),(s),(t),(u),(v),(w),(x),1,1,2) #endif #endif PETSC_EXTERN void SLEPC_ARPACK(saupd,SAUPD)(COMM_ARG PetscBLASInt*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int); PETSC_EXTERN void SLEPC_ARPACK(seupd,SEUPD)(COMM_ARG PetscBool*,char*,PetscBool*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int,int); #if !defined(PETSC_USE_COMPLEX) PETSC_EXTERN void SLEPC_ARPACK(naupd,NAUPD)(COMM_ARG PetscBLASInt*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int); PETSC_EXTERN void SLEPC_ARPACK(neupd,NEUPD)(COMM_ARG PetscBool*,char*,PetscBool*,PetscReal*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscReal*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,int,int,int); #else PETSC_EXTERN void SLEPC_ARPACK(naupd,NAUPD)(COMM_ARG PetscBLASInt*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,int,int); PETSC_EXTERN void SLEPC_ARPACK(neupd,NEUPD)(COMM_ARG PetscBool*,char*,PetscBool*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscScalar*,char*,PetscBLASInt*,const char*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscScalar*,PetscBLASInt*,PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,int,int,int); #endif #endif slepc-3.7.4/src/eps/impls/external/blopex/0000755000175000017500000000000013107004621020000 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/blopex/makefile0000644000175000017500000000241413107004621021501 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresdefine 'SLEPC_HAVE_BLOPEX' CFLAGS = ${BLOPEX_INCLUDE} -DBlopexInt=PetscInt FFLAGS = SOURCEC = blopex.c slepc-interface.c petsc-interface.c SOURCEF = SOURCEH = slepc-interface.h petsc-interface.h LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/external/blopex/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/blopex/slepc-interface.c0000644000175000017500000000664013107004621023216 0ustar jromanjroman/* Modification of the *temp* implementation of the BLOPEX multivector in order to wrap created PETSc vectors as multivectors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #include #include "slepc-interface.h" static void* mv_TempMultiVectorCreateFromBV(void* ii_,BlopexInt n,void* sample) { PetscErrorCode ierr; BV bv = (BV)sample; Vec v; PetscInt i,l,k,nc,useconstr=PETSC_FALSE,flg; mv_TempMultiVector *x; mv_InterfaceInterpreter *ii = (mv_InterfaceInterpreter*)ii_; x = (mv_TempMultiVector*)malloc(sizeof(mv_TempMultiVector)); if (!x) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x failed"); x->interpreter = ii; x->numVectors = n; x->vector = (void**)calloc(n,sizeof(void*)); if (!x->vector) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x->vector failed"); x->ownsVectors = 1; x->mask = NULL; x->ownsMask = 0; ierr = BVGetActiveColumns(bv,&l,&k);CHKERRABORT(PETSC_COMM_SELF,ierr); ierr = PetscObjectComposedDataGetInt((PetscObject)bv,slepc_blopex_useconstr,useconstr,flg);CHKERRABORT(PETSC_COMM_SELF,ierr); if (!l && useconstr) { ierr = BVGetNumConstraints(bv,&nc);CHKERRABORT(PETSC_COMM_SELF,ierr); l = -nc; } if (n != k-l) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"BV active columns plus constraints do not match argument n"); for (i=0;ivector[i] = (void*)v; ierr = BVRestoreColumn(bv,l+i,&v);CHKERRABORT(PETSC_COMM_SELF,ierr); } return x; } static void mv_TempMultiPETSCVectorDestroy(void* x_) { mv_TempMultiVector* x = (mv_TempMultiVector*)x_; if (!x) return; if (x->ownsVectors && x->vector) free(x->vector); if (x->mask && x->ownsMask) free(x->mask); free(x); } /* Create an InterfaceInterpreter using the PETSc implementation but overloading CreateMultiVector that doesn't create any new vector. */ int SLEPCSetupInterpreter(mv_InterfaceInterpreter *i) { PETSCSetupInterpreter(i); i->CreateMultiVector = mv_TempMultiVectorCreateFromBV; return 0; } /* Change the multivector destructor in order to destroy the multivector structure without destroy the PETSc vectors. */ void SLEPCSetupInterpreterForDignifiedDeath(mv_InterfaceInterpreter *i) { i->DestroyMultiVector = mv_TempMultiPETSCVectorDestroy; } slepc-3.7.4/src/eps/impls/external/blopex/slepc-interface.c.html0000644000175000017500000002117713107004621024163 0ustar jromanjroman

Actual source code: slepc-interface.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Modification of the *temp* implementation of the BLOPEX multivector in order
  3:    to wrap created PETSc vectors as multivectors.

  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: */

 25: #include <slepc/private/bvimpl.h>
 26: #include <stdlib.h>
 27: #include <blopex_interpreter.h>
 28: #include <blopex_temp_multivector.h>
 29: #include "slepc-interface.h"

 31: static void* mv_TempMultiVectorCreateFromBV(void* ii_,BlopexInt n,void* sample)
 32: {
 33:   PetscErrorCode          ierr;
 34:   BV                      bv = (BV)sample;
 35:   Vec                     v;
 36:   PetscInt                i,l,k,nc,useconstr=PETSC_FALSE,flg;
 37:   mv_TempMultiVector      *x;
 38:   mv_InterfaceInterpreter *ii = (mv_InterfaceInterpreter*)ii_;

 40:   x = (mv_TempMultiVector*)malloc(sizeof(mv_TempMultiVector));
 41:   if (!x) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x failed");

 43:   x->interpreter = ii;
 44:   x->numVectors  = n;

 46:   x->vector = (void**)calloc(n,sizeof(void*));
 47:   if (!x->vector) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Allocation for x->vector failed");

 49:   x->ownsVectors = 1;
 50:   x->mask = NULL;
 51:   x->ownsMask = 0;

 53:   BVGetActiveColumns(bv,&l,&k);CHKERRABORT(PETSC_COMM_SELF,ierr);
 54:   PetscObjectComposedDataGetInt((PetscObject)bv,slepc_blopex_useconstr,useconstr,flg);CHKERRABORT(PETSC_COMM_SELF,ierr);
 55:   if (!l && useconstr) {
 56:     BVGetNumConstraints(bv,&nc);CHKERRABORT(PETSC_COMM_SELF,ierr);
 57:     l = -nc;
 58:   }
 59:   if (n != k-l) SETERRABORT(PETSC_COMM_SELF,PETSC_ERR_PLIB,"BV active columns plus constraints do not match argument n");
 60:   for (i=0;i<n;i++) {
 61:     BVGetColumn(bv,l+i,&v);CHKERRABORT(PETSC_COMM_SELF,ierr);
 62:     PetscObjectReference((PetscObject)v);CHKERRABORT(PETSC_COMM_SELF,ierr);
 63:     x->vector[i] = (void*)v;
 64:     BVRestoreColumn(bv,l+i,&v);CHKERRABORT(PETSC_COMM_SELF,ierr);
 65:   }
 66:   return x;
 67: }

 69: static void mv_TempMultiPETSCVectorDestroy(void* x_)
 70: {
 71:   mv_TempMultiVector* x = (mv_TempMultiVector*)x_;

 73:   if (!x) return;

 75:   if (x->ownsVectors && x->vector) free(x->vector);
 76:   if (x->mask && x->ownsMask) free(x->mask);
 77:   free(x);
 78: }

 80: /*
 81:     Create an InterfaceInterpreter using the PETSc implementation
 82:     but overloading CreateMultiVector that doesn't create any
 83:     new vector.
 84: */
 85: int SLEPCSetupInterpreter(mv_InterfaceInterpreter *i)
 86: {
 87:   PETSCSetupInterpreter(i);
 88:   i->CreateMultiVector = mv_TempMultiVectorCreateFromBV;

 90:   return 0;
 91: }

 93: /*
 94:     Change the multivector destructor in order to destroy the multivector
 95:     structure without destroy the PETSc vectors.
 96: */
 97: void SLEPCSetupInterpreterForDignifiedDeath(mv_InterfaceInterpreter *i)
 98: {
 99:   i->DestroyMultiVector = mv_TempMultiPETSCVectorDestroy;
100: }

slepc-3.7.4/src/eps/impls/external/blopex/slepc-interface.h0000644000175000017500000000254513107004621023223 0ustar jromanjroman/* Modification of the *temp* implementation of the BLOPEX multivector in order to wrap created PETSc vectors as multivectors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(SLEPC_INTERFACE_HEADER) #define SLEPC_INTERFACE_HEADER #include #include "petsc-interface.h" PETSC_INTERN PetscInt slepc_blopex_useconstr; extern int SLEPCSetupInterpreter(mv_InterfaceInterpreter *ii); extern void SLEPCSetupInterpreterForDignifiedDeath(mv_InterfaceInterpreter *i); #endif slepc-3.7.4/src/eps/impls/external/blopex/petsc-interface.h.html0000644000175000017500000001273513107004621024200 0ustar jromanjroman
Actual source code: petsc-interface.h

slepc-3.7.4 2017-05-17
  1: /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
  2: /* @@@ BLOPEX (version 1.1) LGPL Version 2.1 or above.See www.gnu.org. */
  3: /* @@@ Copyright 2010 BLOPEX team http://code.google.com/p/blopex/     */
  4: /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */

  6: #if !defined(PETSC_INTERFACE_HEADER)
  7: #define PETSC_INTERFACE_HEADER

  9: #include "blopex_interpreter.h"

 11: BlopexInt PETSC_dpotrf_interface (char *uplo, BlopexInt *n, double *a, BlopexInt * lda, BlopexInt *info);

 13: BlopexInt PETSC_dsygv_interface (BlopexInt *itype, char *jobz, char *uplo, BlopexInt *
 14:                     n, double *a, BlopexInt *lda, double *b, BlopexInt *ldb,
 15:                     double *w, double *work, BlopexInt *lwork, BlopexInt *info);

 17: BlopexInt PETSC_zpotrf_interface (char *uplo, BlopexInt *n, komplex *a, BlopexInt * lda, BlopexInt *info);

 19: BlopexInt PETSC_zsygv_interface (BlopexInt *itype, char *jobz, char *uplo, BlopexInt *
 20:                     n, komplex *a, BlopexInt *lda, komplex *b, BlopexInt *ldb,
 21:                     double *w, komplex *work, BlopexInt *lwork, double *rwork, BlopexInt *info);

 23: void *
 24: PETSC_MimicVector(void *vvector);

 26: BlopexInt
 27: PETSC_DestroyVector(void *vvector);

 29: BlopexInt
 30: PETSC_InnerProd(void *x, void *y, void *result);

 32: BlopexInt
 33: PETSC_CopyVector(void *x, void *y);

 35: BlopexInt
 36: PETSC_ClearVector(void *x);

 38: BlopexInt
 39: PETSC_SetRandomValues(void* v, BlopexInt seed);

 41: BlopexInt
 42: PETSC_ScaleVector(void *alpha, void   *x);

 44: BlopexInt
 45: PETSC_Axpy(void *alpha,
 46:                 void   *x,
 47:                 void   *y);

 49: int
 50: LOBPCG_InitRandomContext(MPI_Comm,PetscRandom);

 52: int
 53: LOBPCG_SetFromOptionsRandomContext(void);

 55: int
 56: LOBPCG_DestroyRandomContext(void);

 58: int
 59: PETSCSetupInterpreter(mv_InterfaceInterpreter *ii);

 61: #endif /* PETSC_INTERFACE_HEADER */
slepc-3.7.4/src/eps/impls/external/blopex/makefile.html0000644000175000017500000000517513107004621022453 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresdefine  'SLEPC_HAVE_BLOPEX'

CFLAGS   = ${BLOPEX_INCLUDE} -DBlopexInt=PetscInt
FFLAGS   =
SOURCEC  = blopex.c slepc-interface.c petsc-interface.c
SOURCEF  =
SOURCEH  = slepc-interface.h petsc-interface.h
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/external/blopex/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/external/blopex/petsc-interface.c.html0000644000175000017500000003427413107004621024175 0ustar jromanjroman
Actual source code: petsc-interface.c

slepc-3.7.4 2017-05-17
  1: /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
  2: /* @@@ BLOPEX (version 1.1) LGPL Version 2.1 or above.See www.gnu.org. */
  3: /* @@@ Copyright 2010 BLOPEX team http://code.google.com/p/blopex/     */
  4: /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */
  5: /* This code was developed by Merico Argentati, Andrew Knyazev, Ilya Lashuk and Evgueni Ovtchinnikov */

  7: #include <petscvec.h>
  8: #include <petscblaslapack.h>
  9: #include "blopex_interpreter.h"
 10: #include "blopex_temp_multivector.h"
 11: #include "blopex_fortran_matrix.h"

 13: static PetscRandom LOBPCG_RandomContext = NULL;

 15: BlopexInt PETSC_dpotrf_interface (char *uplo,BlopexInt *n,double *a,BlopexInt * lda,BlopexInt *info)
 16: {
 17:   PetscBLASInt n_,lda_,info_;

 19:   /* type conversion */
 20:   n_ = *n;
 21:   lda_ = *lda;
 22:   info_ = *info;

 24:   LAPACKpotrf_(uplo,&n_,(PetscScalar*)a,&lda_,&info_);

 26:   *info = info_;
 27:   return 0;
 28: }

 30: BlopexInt PETSC_zpotrf_interface (char *uplo,BlopexInt *n,komplex *a,BlopexInt* lda,BlopexInt *info)
 31: {
 32:   PetscBLASInt n_,lda_,info_;

 34:   /* type conversion */
 35:   n_ = *n;
 36:   lda_ = (PetscBLASInt)*lda;

 38:   LAPACKpotrf_(uplo,&n_,(PetscScalar*)a,&lda_,&info_);

 40:   *info = info_;
 41:   return 0;
 42: }

 44: BlopexInt PETSC_dsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,double *a,BlopexInt *lda,double *b,BlopexInt *ldb,double *w,double *work,BlopexInt *lwork,BlopexInt *info)
 45: {
 46: #if !defined(PETSC_USE_COMPLEX)
 47:   PetscBLASInt itype_,n_,lda_,ldb_,lwork_,info_;

 49:   itype_ = *itype;
 50:   n_ = *n;
 51:   lda_ = *lda;
 52:   ldb_ = *ldb;
 53:   lwork_ = *lwork;
 54:   info_ = *info;

 56:   LAPACKsygv_(&itype_,jobz,uplo,&n_,(PetscScalar*)a,&lda_,(PetscScalar*)b,&ldb_,(PetscScalar*)w,(PetscScalar*)work,&lwork_,&info_);

 58:   *info = info_;
 59: #endif
 60:   return 0;
 61: }

 63: BlopexInt PETSC_zsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,komplex *a,BlopexInt *lda,komplex *b,BlopexInt *ldb,double *w,komplex *work,BlopexInt *lwork,double *rwork,BlopexInt *info)
 64: {
 65: #if defined(PETSC_USE_COMPLEX)
 66:   PetscBLASInt itype_,n_,lda_,ldb_,lwork_,info_;

 68:   itype_ = *itype;
 69:   n_ = *n;
 70:   lda_ = *lda;
 71:   ldb_ = *ldb;
 72:   lwork_ = *lwork;
 73:   info_ = *info;

 75:   LAPACKsygv_(&itype_,jobz,uplo,&n_,(PetscScalar*)a,&lda_,(PetscScalar*)b,&ldb_,(PetscReal*)w,(PetscScalar*)work,&lwork_,(PetscReal*)rwork,&info_);

 77:   *info = info_;
 78: #endif
 79:   return 0;
 80: }

 82: void *PETSC_MimicVector(void *vvector)
 83: {
 84:   PetscErrorCode  ierr;
 85:   Vec temp;

 87:   VecDuplicate((Vec)vvector,&temp);CHKERRABORT(PETSC_COMM_SELF,ierr);
 88:   return (void*)temp;
 89: }

 91: BlopexInt PETSC_DestroyVector(void *vvector)
 92: {
 94:   Vec v = (Vec)vvector;

 96:   VecDestroy(&v);
 97:   return 0;
 98: }

100: BlopexInt PETSC_InnerProd(void *x,void *y,void *result)
101: {

104:   VecDot((Vec)x,(Vec)y,(PetscScalar*)result);
105:   return 0;
106: }

108: BlopexInt PETSC_CopyVector(void *x,void *y)
109: {
110:   PetscErrorCode  ierr;

112:   VecCopy((Vec)x,(Vec)y);
113:   return 0;
114: }

116: BlopexInt PETSC_ClearVector(void *x)
117: {
118:   PetscErrorCode  ierr;

120:   VecSet((Vec)x,0.0);
121:   return 0;
122: }

124: BlopexInt PETSC_SetRandomValues(void* v,BlopexInt seed)
125: {

128:   /* note: without previous call to LOBPCG_InitRandomContext LOBPCG_RandomContext will be null,
129:     and VecSetRandom will use internal petsc random context */

131:   VecSetRandom((Vec)v,LOBPCG_RandomContext);
132:   return 0;
133: }

135: BlopexInt PETSC_ScaleVector(double alpha,void *x)
136: {

139:   VecScale((Vec)x,alpha);
140:   return 0;
141: }

143: BlopexInt PETSC_Axpy(void *alpha,void *x,void *y)
144: {

147:   VecAXPY((Vec)y,*(PetscScalar*)alpha,(Vec)x);
148:   return 0;
149: }

151: BlopexInt PETSC_VectorSize(void *x)
152: {
153:   PetscInt N;
154:   VecGetSize((Vec)x,&N);
155:   return N;
156: }

158: int LOBPCG_InitRandomContext(MPI_Comm comm,PetscRandom rand)
159: {
161:   /* PetscScalar rnd_bound = 1.0; */

163:   if (rand) {
164:     PetscObjectReference((PetscObject)rand);
165:     PetscRandomDestroy(&LOBPCG_RandomContext);
166:     LOBPCG_RandomContext = rand;
167:   } else {
168:     PetscRandomCreate(comm,&LOBPCG_RandomContext);
169:   }
170:   return 0;
171: }

173: int LOBPCG_SetFromOptionsRandomContext(void)
174: {
176:   PetscRandomSetFromOptions(LOBPCG_RandomContext);

178: #if defined(PETSC_USE_COMPLEX)
179:   PetscRandomSetInterval(LOBPCG_RandomContext,(PetscScalar)-1.0-1.0*PETSC_i,(PetscScalar)1.0+1.0*PETSC_i);
180: #else
181:   PetscRandomSetInterval(LOBPCG_RandomContext,(PetscScalar)-1.0,(PetscScalar)1.0);
182: #endif
183:   return 0;
184: }

186: int LOBPCG_DestroyRandomContext(void)
187: {

190:   PetscRandomDestroy(&LOBPCG_RandomContext);
191:   return 0;
192: }

194: int PETSCSetupInterpreter(mv_InterfaceInterpreter *i)
195: {
196:   i->CreateVector = PETSC_MimicVector;
197:   i->DestroyVector = PETSC_DestroyVector;
198:   i->InnerProd = PETSC_InnerProd;
199:   i->CopyVector = PETSC_CopyVector;
200:   i->ClearVector = PETSC_ClearVector;
201:   i->SetRandomValues = PETSC_SetRandomValues;
202:   i->ScaleVector = PETSC_ScaleVector;
203:   i->Axpy = PETSC_Axpy;
204:   i->VectorSize = PETSC_VectorSize;

206:   /* Multivector part */

208:   i->CreateMultiVector = mv_TempMultiVectorCreateFromSampleVector;
209:   i->CopyCreateMultiVector = mv_TempMultiVectorCreateCopy;
210:   i->DestroyMultiVector = mv_TempMultiVectorDestroy;

212:   i->Width = mv_TempMultiVectorWidth;
213:   i->Height = mv_TempMultiVectorHeight;
214:   i->SetMask = mv_TempMultiVectorSetMask;
215:   i->CopyMultiVector = mv_TempMultiVectorCopy;
216:   i->ClearMultiVector = mv_TempMultiVectorClear;
217:   i->SetRandomVectors = mv_TempMultiVectorSetRandom;
218:   i->Eval = mv_TempMultiVectorEval;

220: #if defined(PETSC_USE_COMPLEX)
221:   i->MultiInnerProd = mv_TempMultiVectorByMultiVector_complex;
222:   i->MultiInnerProdDiag = mv_TempMultiVectorByMultiVectorDiag_complex;
223:   i->MultiVecMat = mv_TempMultiVectorByMatrix_complex;
224:   i->MultiVecMatDiag = mv_TempMultiVectorByDiagonal_complex;
225:   i->MultiAxpy = mv_TempMultiVectorAxpy_complex;
226:   i->MultiXapy = mv_TempMultiVectorXapy_complex;
227: #else
228:   i->MultiInnerProd = mv_TempMultiVectorByMultiVector;
229:   i->MultiInnerProdDiag = mv_TempMultiVectorByMultiVectorDiag;
230:   i->MultiVecMat = mv_TempMultiVectorByMatrix;
231:   i->MultiVecMatDiag = mv_TempMultiVectorByDiagonal;
232:   i->MultiAxpy = mv_TempMultiVectorAxpy;
233:   i->MultiXapy = mv_TempMultiVectorXapy;
234: #endif

236:   return 0;
237: }
slepc-3.7.4/src/eps/impls/external/blopex/slepc-interface.h.html0000644000175000017500000000736413107004621024172 0ustar jromanjroman
Actual source code: slepc-interface.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Modification of the *temp* implementation of the BLOPEX multivector in order
  3:    to wrap created PETSc vectors as multivectors.

  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: */

 25: #if !defined(SLEPC_INTERFACE_HEADER)
 26: #define SLEPC_INTERFACE_HEADER

 28: #include <blopex_lobpcg.h>
 29: #include "petsc-interface.h"

 31: PETSC_INTERN PetscInt slepc_blopex_useconstr;

 33: extern int
 34: SLEPCSetupInterpreter(mv_InterfaceInterpreter *ii);

 36: extern void
 37: SLEPCSetupInterpreterForDignifiedDeath(mv_InterfaceInterpreter *i);

 39: #endif

slepc-3.7.4/src/eps/impls/external/blopex/index.html0000644000175000017500000000317613107004621022004 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

slepc-interface.h
petsc-interface.h
blopex.c
slepc-interface.c
petsc-interface.c
makefile
slepc-3.7.4/src/eps/impls/external/blopex/petsc-interface.c0000644000175000017500000001433013107004621023221 0ustar jromanjroman/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ /* @@@ BLOPEX (version 1.1) LGPL Version 2.1 or above.See www.gnu.org. */ /* @@@ Copyright 2010 BLOPEX team http://code.google.com/p/blopex/ */ /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ /* This code was developed by Merico Argentati, Andrew Knyazev, Ilya Lashuk and Evgueni Ovtchinnikov */ #include #include #include "blopex_interpreter.h" #include "blopex_temp_multivector.h" #include "blopex_fortran_matrix.h" static PetscRandom LOBPCG_RandomContext = NULL; BlopexInt PETSC_dpotrf_interface (char *uplo,BlopexInt *n,double *a,BlopexInt * lda,BlopexInt *info) { PetscBLASInt n_,lda_,info_; /* type conversion */ n_ = *n; lda_ = *lda; info_ = *info; LAPACKpotrf_(uplo,&n_,(PetscScalar*)a,&lda_,&info_); *info = info_; return 0; } BlopexInt PETSC_zpotrf_interface (char *uplo,BlopexInt *n,komplex *a,BlopexInt* lda,BlopexInt *info) { PetscBLASInt n_,lda_,info_; /* type conversion */ n_ = *n; lda_ = (PetscBLASInt)*lda; LAPACKpotrf_(uplo,&n_,(PetscScalar*)a,&lda_,&info_); *info = info_; return 0; } BlopexInt PETSC_dsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,double *a,BlopexInt *lda,double *b,BlopexInt *ldb,double *w,double *work,BlopexInt *lwork,BlopexInt *info) { #if !defined(PETSC_USE_COMPLEX) PetscBLASInt itype_,n_,lda_,ldb_,lwork_,info_; itype_ = *itype; n_ = *n; lda_ = *lda; ldb_ = *ldb; lwork_ = *lwork; info_ = *info; LAPACKsygv_(&itype_,jobz,uplo,&n_,(PetscScalar*)a,&lda_,(PetscScalar*)b,&ldb_,(PetscScalar*)w,(PetscScalar*)work,&lwork_,&info_); *info = info_; #endif return 0; } BlopexInt PETSC_zsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,komplex *a,BlopexInt *lda,komplex *b,BlopexInt *ldb,double *w,komplex *work,BlopexInt *lwork,double *rwork,BlopexInt *info) { #if defined(PETSC_USE_COMPLEX) PetscBLASInt itype_,n_,lda_,ldb_,lwork_,info_; itype_ = *itype; n_ = *n; lda_ = *lda; ldb_ = *ldb; lwork_ = *lwork; info_ = *info; LAPACKsygv_(&itype_,jobz,uplo,&n_,(PetscScalar*)a,&lda_,(PetscScalar*)b,&ldb_,(PetscReal*)w,(PetscScalar*)work,&lwork_,(PetscReal*)rwork,&info_); *info = info_; #endif return 0; } void *PETSC_MimicVector(void *vvector) { PetscErrorCode ierr; Vec temp; ierr = VecDuplicate((Vec)vvector,&temp);CHKERRABORT(PETSC_COMM_SELF,ierr); return (void*)temp; } BlopexInt PETSC_DestroyVector(void *vvector) { PetscErrorCode ierr; Vec v = (Vec)vvector; ierr = VecDestroy(&v);CHKERRQ(ierr); return 0; } BlopexInt PETSC_InnerProd(void *x,void *y,void *result) { PetscErrorCode ierr; ierr = VecDot((Vec)x,(Vec)y,(PetscScalar*)result);CHKERRQ(ierr); return 0; } BlopexInt PETSC_CopyVector(void *x,void *y) { PetscErrorCode ierr; ierr = VecCopy((Vec)x,(Vec)y);CHKERRQ(ierr); return 0; } BlopexInt PETSC_ClearVector(void *x) { PetscErrorCode ierr; ierr = VecSet((Vec)x,0.0);CHKERRQ(ierr); return 0; } BlopexInt PETSC_SetRandomValues(void* v,BlopexInt seed) { PetscErrorCode ierr; /* note: without previous call to LOBPCG_InitRandomContext LOBPCG_RandomContext will be null, and VecSetRandom will use internal petsc random context */ ierr = VecSetRandom((Vec)v,LOBPCG_RandomContext);CHKERRQ(ierr); return 0; } BlopexInt PETSC_ScaleVector(double alpha,void *x) { PetscErrorCode ierr; ierr = VecScale((Vec)x,alpha);CHKERRQ(ierr); return 0; } BlopexInt PETSC_Axpy(void *alpha,void *x,void *y) { PetscErrorCode ierr; ierr = VecAXPY((Vec)y,*(PetscScalar*)alpha,(Vec)x);CHKERRQ(ierr); return 0; } BlopexInt PETSC_VectorSize(void *x) { PetscInt N; VecGetSize((Vec)x,&N); return N; } int LOBPCG_InitRandomContext(MPI_Comm comm,PetscRandom rand) { PetscErrorCode ierr; /* PetscScalar rnd_bound = 1.0; */ if (rand) { ierr = PetscObjectReference((PetscObject)rand);CHKERRQ(ierr); ierr = PetscRandomDestroy(&LOBPCG_RandomContext);CHKERRQ(ierr); LOBPCG_RandomContext = rand; } else { ierr = PetscRandomCreate(comm,&LOBPCG_RandomContext);CHKERRQ(ierr); } return 0; } int LOBPCG_SetFromOptionsRandomContext(void) { PetscErrorCode ierr; ierr = PetscRandomSetFromOptions(LOBPCG_RandomContext);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscRandomSetInterval(LOBPCG_RandomContext,(PetscScalar)-1.0-1.0*PETSC_i,(PetscScalar)1.0+1.0*PETSC_i);CHKERRQ(ierr); #else ierr = PetscRandomSetInterval(LOBPCG_RandomContext,(PetscScalar)-1.0,(PetscScalar)1.0);CHKERRQ(ierr); #endif return 0; } int LOBPCG_DestroyRandomContext(void) { PetscErrorCode ierr; ierr = PetscRandomDestroy(&LOBPCG_RandomContext);CHKERRQ(ierr); return 0; } int PETSCSetupInterpreter(mv_InterfaceInterpreter *i) { i->CreateVector = PETSC_MimicVector; i->DestroyVector = PETSC_DestroyVector; i->InnerProd = PETSC_InnerProd; i->CopyVector = PETSC_CopyVector; i->ClearVector = PETSC_ClearVector; i->SetRandomValues = PETSC_SetRandomValues; i->ScaleVector = PETSC_ScaleVector; i->Axpy = PETSC_Axpy; i->VectorSize = PETSC_VectorSize; /* Multivector part */ i->CreateMultiVector = mv_TempMultiVectorCreateFromSampleVector; i->CopyCreateMultiVector = mv_TempMultiVectorCreateCopy; i->DestroyMultiVector = mv_TempMultiVectorDestroy; i->Width = mv_TempMultiVectorWidth; i->Height = mv_TempMultiVectorHeight; i->SetMask = mv_TempMultiVectorSetMask; i->CopyMultiVector = mv_TempMultiVectorCopy; i->ClearMultiVector = mv_TempMultiVectorClear; i->SetRandomVectors = mv_TempMultiVectorSetRandom; i->Eval = mv_TempMultiVectorEval; #if defined(PETSC_USE_COMPLEX) i->MultiInnerProd = mv_TempMultiVectorByMultiVector_complex; i->MultiInnerProdDiag = mv_TempMultiVectorByMultiVectorDiag_complex; i->MultiVecMat = mv_TempMultiVectorByMatrix_complex; i->MultiVecMatDiag = mv_TempMultiVectorByDiagonal_complex; i->MultiAxpy = mv_TempMultiVectorAxpy_complex; i->MultiXapy = mv_TempMultiVectorXapy_complex; #else i->MultiInnerProd = mv_TempMultiVectorByMultiVector; i->MultiInnerProdDiag = mv_TempMultiVectorByMultiVectorDiag; i->MultiVecMat = mv_TempMultiVectorByMatrix; i->MultiVecMatDiag = mv_TempMultiVectorByDiagonal; i->MultiAxpy = mv_TempMultiVectorAxpy; i->MultiXapy = mv_TempMultiVectorXapy; #endif return 0; } slepc-3.7.4/src/eps/impls/external/blopex/ftn-auto/0000755000175000017500000000000013107004621021535 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/blopex/ftn-auto/makefile0000644000175000017500000000037213107004621023237 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = blopexf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/external/blopex/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/blopex/ftn-auto/blopexf.c0000644000175000017500000000275113107004621023345 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* blopex.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsblopexsetblocksize_ EPSBLOPEXSETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsblopexsetblocksize_ epsblopexsetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsblopexgetblocksize_ EPSBLOPEXGETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsblopexgetblocksize_ epsblopexgetblocksize #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsblopexsetblocksize_(EPS eps,PetscInt *bs, int *__ierr ){ *__ierr = EPSBLOPEXSetBlockSize( (EPS)PetscToPointer((eps) ),*bs); } PETSC_EXTERN void PETSC_STDCALL epsblopexgetblocksize_(EPS eps,PetscInt *bs, int *__ierr ){ *__ierr = EPSBLOPEXGetBlockSize( (EPS)PetscToPointer((eps) ),bs); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/external/blopex/blopex.c0000644000175000017500000004120413107004621021436 0ustar jromanjroman/* This file implements a wrapper to the BLOPEX package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include "slepc-interface.h" #include #include #include #include PetscInt slepc_blopex_useconstr = -1; PetscErrorCode EPSSolve_BLOPEX(EPS); typedef struct { lobpcg_Tolerance tol; lobpcg_BLASLAPACKFunctions blap_fn; mv_InterfaceInterpreter ii; ST st; Vec w; PetscInt bs; /* block size */ } EPS_BLOPEX; #undef __FUNCT__ #define __FUNCT__ "Precond_FnSingleVector" static void Precond_FnSingleVector(void *data,void *x,void *y) { PetscErrorCode ierr; EPS_BLOPEX *blopex = (EPS_BLOPEX*)data; MPI_Comm comm = PetscObjectComm((PetscObject)blopex->st); KSP ksp; PetscFunctionBegin; ierr = STGetKSP(blopex->st,&ksp);CHKERRABORT(comm,ierr); ierr = KSPSolve(ksp,(Vec)x,(Vec)y);CHKERRABORT(comm,ierr); PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "Precond_FnMultiVector" static void Precond_FnMultiVector(void *data,void *x,void *y) { EPS_BLOPEX *blopex = (EPS_BLOPEX*)data; PetscFunctionBegin; blopex->ii.Eval(Precond_FnSingleVector,data,x,y); PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "OperatorASingleVector" static void OperatorASingleVector(void *data,void *x,void *y) { PetscErrorCode ierr; EPS_BLOPEX *blopex = (EPS_BLOPEX*)data; MPI_Comm comm = PetscObjectComm((PetscObject)blopex->st); Mat A,B; PetscScalar sigma; PetscInt nmat; PetscFunctionBegin; ierr = STGetNumMatrices(blopex->st,&nmat);CHKERRABORT(comm,ierr); ierr = STGetOperators(blopex->st,0,&A);CHKERRABORT(comm,ierr); if (nmat>1) { ierr = STGetOperators(blopex->st,1,&B);CHKERRABORT(comm,ierr); } ierr = MatMult(A,(Vec)x,(Vec)y);CHKERRABORT(comm,ierr); ierr = STGetShift(blopex->st,&sigma);CHKERRABORT(comm,ierr); if (sigma != 0.0) { if (nmat>1) { ierr = MatMult(B,(Vec)x,blopex->w);CHKERRABORT(comm,ierr); } else { ierr = VecCopy((Vec)x,blopex->w);CHKERRABORT(comm,ierr); } ierr = VecAXPY((Vec)y,-sigma,blopex->w);CHKERRABORT(comm,ierr); } PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "OperatorAMultiVector" static void OperatorAMultiVector(void *data,void *x,void *y) { EPS_BLOPEX *blopex = (EPS_BLOPEX*)data; PetscFunctionBegin; blopex->ii.Eval(OperatorASingleVector,data,x,y); PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "OperatorBSingleVector" static void OperatorBSingleVector(void *data,void *x,void *y) { PetscErrorCode ierr; EPS_BLOPEX *blopex = (EPS_BLOPEX*)data; MPI_Comm comm = PetscObjectComm((PetscObject)blopex->st); Mat B; PetscFunctionBegin; ierr = STGetOperators(blopex->st,1,&B);CHKERRABORT(comm,ierr); ierr = MatMult(B,(Vec)x,(Vec)y);CHKERRABORT(comm,ierr); PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "OperatorBMultiVector" static void OperatorBMultiVector(void *data,void *x,void *y) { EPS_BLOPEX *blopex = (EPS_BLOPEX*)data; PetscFunctionBegin; blopex->ii.Eval(OperatorBSingleVector,data,x,y); PetscFunctionReturnVoid(); } #undef __FUNCT__ #define __FUNCT__ "EPSSetDimensions_BLOPEX" PetscErrorCode EPSSetDimensions_BLOPEX(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd) { PetscErrorCode ierr; EPS_BLOPEX *ctx = (EPS_BLOPEX*)eps->data; PetscInt k; PetscFunctionBegin; k = ((eps->nev-1)/ctx->bs+1)*ctx->bs; if (*ncv) { /* ncv set */ if (*ncvdata; PetscBool isPrecond,istrivial,flg; PetscFunctionBegin; if (!eps->ishermitian || (eps->isgeneralized && !eps->ispositive)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"blopex only works for Hermitian problems"); if (!blopex->bs) blopex->bs = PetscMin(16,eps->nev); ierr = EPSSetDimensions_BLOPEX(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv); if (!eps->which) eps->which = EPS_SMALLEST_REAL; if (eps->which!=EPS_SMALLEST_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test"); if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering"); ierr = STSetUp(eps->st);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&isPrecond);CHKERRQ(ierr); if (!isPrecond) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"blopex only works with STPRECOND"); blopex->st = eps->st; if (eps->converged == EPSConvergedRelative) { blopex->tol.absolute = 0.0; blopex->tol.relative = eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol; } else if (eps->converged == EPSConvergedAbsolute) { blopex->tol.absolute = eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol; blopex->tol.relative = 0.0; } else SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Convergence test not supported in this solver"); SLEPCSetupInterpreter(&blopex->ii); /* allocate memory */ if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } ierr = PetscObjectTypeCompareAny((PetscObject)eps->V,&flg,BVVECS,BVCONTIGUOUS,"");CHKERRQ(ierr); if (!flg) { /* blopex only works with BVVECS or BVCONTIGUOUS */ ierr = BVSetType(eps->V,BVCONTIGUOUS);CHKERRQ(ierr); } ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = BVCreateVec(eps->V,&blopex->w);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)blopex->w);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) blopex->blap_fn.zpotrf = PETSC_zpotrf_interface; blopex->blap_fn.zhegv = PETSC_zsygv_interface; #else blopex->blap_fn.dpotrf = PETSC_dpotrf_interface; blopex->blap_fn.dsygv = PETSC_dsygv_interface; #endif /* dispatch solve method */ eps->ops->solve = EPSSolve_BLOPEX; PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_BLOPEX" PetscErrorCode EPSSolve_BLOPEX(EPS eps) { EPS_BLOPEX *blopex = (EPS_BLOPEX*)eps->data; PetscScalar sigma,*eigr=NULL; PetscReal *errest=NULL; int i,j,info,its,nconv; double *residhist=NULL; PetscErrorCode ierr; mv_MultiVectorPtr eigenvectors,constraints; #if defined(PETSC_USE_COMPLEX) komplex *lambda=NULL,*lambdahist=NULL; #else double *lambda=NULL,*lambdahist=NULL; #endif PetscFunctionBegin; ierr = STGetShift(eps->st,&sigma);CHKERRQ(ierr); ierr = PetscMalloc1(blopex->bs,&lambda);CHKERRQ(ierr); if (eps->numbermonitors>0) { ierr = PetscMalloc4(blopex->bs*(eps->max_it+1),&lambdahist,eps->ncv,&eigr,blopex->bs*(eps->max_it+1),&residhist,eps->ncv,&errest);CHKERRQ(ierr); } /* Complete the initial basis with random vectors */ for (i=eps->nini;incv;i++) { ierr = BVSetRandomColumn(eps->V,i);CHKERRQ(ierr); } while (eps->reason == EPS_CONVERGED_ITERATING) { /* Create multivector of constraints from leading columns of V */ ierr = PetscObjectComposedDataSetInt((PetscObject)eps->V,slepc_blopex_useconstr,1);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,eps->nconv);CHKERRQ(ierr); constraints = mv_MultiVectorCreateFromSampleVector(&blopex->ii,eps->nds+eps->nconv,eps->V); /* Create multivector where eigenvectors of this run will be stored */ ierr = PetscObjectComposedDataSetInt((PetscObject)eps->V,slepc_blopex_useconstr,0);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,eps->nconv,eps->nconv+blopex->bs);CHKERRQ(ierr); eigenvectors = mv_MultiVectorCreateFromSampleVector(&blopex->ii,blopex->bs,eps->V); #if defined(PETSC_USE_COMPLEX) info = lobpcg_solve_complex(eigenvectors,blopex,OperatorAMultiVector, eps->isgeneralized?blopex:NULL,eps->isgeneralized?OperatorBMultiVector:NULL, blopex,Precond_FnMultiVector,constraints, blopex->blap_fn,blopex->tol,eps->max_it,0,&its, lambda,lambdahist,blopex->bs,eps->errest+eps->nconv,residhist,blopex->bs); #else info = lobpcg_solve_double(eigenvectors,blopex,OperatorAMultiVector, eps->isgeneralized?blopex:NULL,eps->isgeneralized?OperatorBMultiVector:NULL, blopex,Precond_FnMultiVector,constraints, blopex->blap_fn,blopex->tol,eps->max_it,0,&its, lambda,lambdahist,blopex->bs,eps->errest+eps->nconv,residhist,blopex->bs); #endif if (info>0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"BLOPEX failed with exit code=%d",info); mv_MultiVectorDestroy(constraints); mv_MultiVectorDestroy(eigenvectors); for (j=0;jbs;j++) { #if defined(PETSC_USE_COMPLEX) eps->eigr[eps->nconv+j] = lambda[j].real+PETSC_i*lambda[j].imag; #else eps->eigr[eps->nconv+j] = lambda[j]; #endif } if (eps->numbermonitors>0) { for (i=0;ibs;j++) { #if defined(PETSC_USE_COMPLEX) eigr[eps->nconv+j] = lambdahist[j+i*blopex->bs].real+PETSC_i*lambdahist[j+i*blopex->bs].imag; #else eigr[eps->nconv+j] = lambdahist[j+i*blopex->bs]; #endif errest[eps->nconv+j] = residhist[j+i*blopex->bs]; if (residhist[j+i*blopex->bs]<=eps->tol) nconv++; } ierr = EPSMonitor(eps,eps->its+i,eps->nconv+nconv,eigr,eps->eigi,errest,eps->nconv+blopex->bs);CHKERRQ(ierr); } } eps->its += its; if (info==-1) { eps->reason = EPS_DIVERGED_ITS; break; } else { for (i=0;ibs;i++) { if (sigma != 0.0) eps->eigr[eps->nconv+i] += sigma; } eps->nconv += blopex->bs; if (eps->nconv>=eps->nev) eps->reason = EPS_CONVERGED_TOL; } } ierr = PetscFree(lambda);CHKERRQ(ierr); if (eps->numbermonitors>0) { ierr = PetscFree4(lambdahist,eigr,residhist,errest);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBLOPEXSetBlockSize_BLOPEX" static PetscErrorCode EPSBLOPEXSetBlockSize_BLOPEX(EPS eps,PetscInt bs) { EPS_BLOPEX *ctx = (EPS_BLOPEX*)eps->data; PetscFunctionBegin; ctx->bs = bs; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBLOPEXSetBlockSize" /*@ EPSBLOPEXSetBlockSize - Sets the block size of the BLOPEX solver. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - bs - the block size Options Database Key: . -eps_blopex_blocksize - Sets the block size Level: advanced .seealso: EPSBLOPEXGetBlockSize() @*/ PetscErrorCode EPSBLOPEXSetBlockSize(EPS eps,PetscInt bs) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,bs,2); ierr = PetscTryMethod(eps,"EPSBLOPEXSetBlockSize_C",(EPS,PetscInt),(eps,bs));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBLOPEXGetBlockSize_BLOPEX" static PetscErrorCode EPSBLOPEXGetBlockSize_BLOPEX(EPS eps,PetscInt *bs) { EPS_BLOPEX *ctx = (EPS_BLOPEX*)eps->data; PetscFunctionBegin; *bs = ctx->bs; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBLOPEXGetBlockSize" /*@ EPSBLOPEXGetBlockSize - Gets the block size used in the BLOPEX solver. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . bs - the block size Level: advanced .seealso: EPSBLOPEXSetBlockSize() @*/ PetscErrorCode EPSBLOPEXGetBlockSize(EPS eps,PetscInt *bs) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(bs,2); ierr = PetscUseMethod(eps,"EPSBLOPEXGetBlockSize_C",(EPS,PetscInt*),(eps,bs));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_BLOPEX" PetscErrorCode EPSReset_BLOPEX(EPS eps) { PetscErrorCode ierr; EPS_BLOPEX *blopex = (EPS_BLOPEX*)eps->data; PetscFunctionBegin; ierr = VecDestroy(&blopex->w);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_BLOPEX" PetscErrorCode EPSDestroy_BLOPEX(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; LOBPCG_DestroyRandomContext(); ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXSetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXGetBlockSize_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_BLOPEX" PetscErrorCode EPSView_BLOPEX(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_BLOPEX *ctx = (EPS_BLOPEX*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," BLOPEX: block size %D\n",ctx->bs);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_BLOPEX" PetscErrorCode EPSSetFromOptions_BLOPEX(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; KSP ksp; PetscBool flg; PetscInt bs; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS BLOPEX Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_blopex_blocksize","BLOPEX block size","EPSBLOPEXSetBlockSize",20,&bs,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSBLOPEXSetBlockSize(eps,bs);CHKERRQ(ierr); } LOBPCG_SetFromOptionsRandomContext(); /* Set STPrecond as the default ST */ if (!((PetscObject)eps->st)->type_name) { ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); } ierr = STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);CHKERRQ(ierr); /* Set the default options of the KSP */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_BLOPEX" PETSC_EXTERN PetscErrorCode EPSCreate_BLOPEX(EPS eps) { EPS_BLOPEX *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; eps->ops->setup = EPSSetUp_BLOPEX; eps->ops->setfromoptions = EPSSetFromOptions_BLOPEX; eps->ops->destroy = EPSDestroy_BLOPEX; eps->ops->reset = EPSReset_BLOPEX; eps->ops->view = EPSView_BLOPEX; eps->ops->backtransform = EPSBackTransform_Default; LOBPCG_InitRandomContext(PetscObjectComm((PetscObject)eps),NULL); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXSetBlockSize_C",EPSBLOPEXSetBlockSize_BLOPEX);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXGetBlockSize_C",EPSBLOPEXGetBlockSize_BLOPEX);CHKERRQ(ierr); if (slepc_blopex_useconstr < 0) { ierr = PetscObjectComposedDataRegister(&slepc_blopex_useconstr);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/external/blopex/blopex.c.html0000644000175000017500000010346713107004621022413 0ustar jromanjroman

Actual source code: blopex.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the BLOPEX package

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
 25: #include "slepc-interface.h"
 26: #include <blopex_lobpcg.h>
 27: #include <blopex_interpreter.h>
 28: #include <blopex_multivector.h>
 29: #include <blopex_temp_multivector.h>

 31: PetscInt slepc_blopex_useconstr = -1;

 33: PetscErrorCode EPSSolve_BLOPEX(EPS);

 35: typedef struct {
 36:   lobpcg_Tolerance           tol;
 37:   lobpcg_BLASLAPACKFunctions blap_fn;
 38:   mv_InterfaceInterpreter    ii;
 39:   ST                         st;
 40:   Vec                        w;
 41:   PetscInt                   bs;     /* block size */
 42: } EPS_BLOPEX;

 46: static void Precond_FnSingleVector(void *data,void *x,void *y)
 47: {
 49:   EPS_BLOPEX     *blopex = (EPS_BLOPEX*)data;
 50:   MPI_Comm       comm = PetscObjectComm((PetscObject)blopex->st);
 51:   KSP            ksp;

 54:   STGetKSP(blopex->st,&ksp);CHKERRABORT(comm,ierr);
 55:   KSPSolve(ksp,(Vec)x,(Vec)y);CHKERRABORT(comm,ierr);
 56:   PetscFunctionReturnVoid();
 57: }

 61: static void Precond_FnMultiVector(void *data,void *x,void *y)
 62: {
 63:   EPS_BLOPEX *blopex = (EPS_BLOPEX*)data;

 66:   blopex->ii.Eval(Precond_FnSingleVector,data,x,y);
 67:   PetscFunctionReturnVoid();
 68: }

 72: static void OperatorASingleVector(void *data,void *x,void *y)
 73: {
 75:   EPS_BLOPEX     *blopex = (EPS_BLOPEX*)data;
 76:   MPI_Comm       comm = PetscObjectComm((PetscObject)blopex->st);
 77:   Mat            A,B;
 78:   PetscScalar    sigma;
 79:   PetscInt       nmat;

 82:   STGetNumMatrices(blopex->st,&nmat);CHKERRABORT(comm,ierr);
 83:   STGetOperators(blopex->st,0,&A);CHKERRABORT(comm,ierr);
 84:   if (nmat>1) { STGetOperators(blopex->st,1,&B);CHKERRABORT(comm,ierr); }
 85:   MatMult(A,(Vec)x,(Vec)y);CHKERRABORT(comm,ierr);
 86:   STGetShift(blopex->st,&sigma);CHKERRABORT(comm,ierr);
 87:   if (sigma != 0.0) {
 88:     if (nmat>1) {
 89:       MatMult(B,(Vec)x,blopex->w);CHKERRABORT(comm,ierr);
 90:     } else {
 91:       VecCopy((Vec)x,blopex->w);CHKERRABORT(comm,ierr);
 92:     }
 93:     VecAXPY((Vec)y,-sigma,blopex->w);CHKERRABORT(comm,ierr);
 94:   }
 95:   PetscFunctionReturnVoid();
 96: }

100: static void OperatorAMultiVector(void *data,void *x,void *y)
101: {
102:   EPS_BLOPEX *blopex = (EPS_BLOPEX*)data;

105:   blopex->ii.Eval(OperatorASingleVector,data,x,y);
106:   PetscFunctionReturnVoid();
107: }

111: static void OperatorBSingleVector(void *data,void *x,void *y)
112: {
114:   EPS_BLOPEX     *blopex = (EPS_BLOPEX*)data;
115:   MPI_Comm       comm = PetscObjectComm((PetscObject)blopex->st);
116:   Mat            B;

119:   STGetOperators(blopex->st,1,&B);CHKERRABORT(comm,ierr);
120:   MatMult(B,(Vec)x,(Vec)y);CHKERRABORT(comm,ierr);
121:   PetscFunctionReturnVoid();
122: }

126: static void OperatorBMultiVector(void *data,void *x,void *y)
127: {
128:   EPS_BLOPEX *blopex = (EPS_BLOPEX*)data;

131:   blopex->ii.Eval(OperatorBSingleVector,data,x,y);
132:   PetscFunctionReturnVoid();
133: }

137: PetscErrorCode EPSSetDimensions_BLOPEX(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)
138: {
140:   EPS_BLOPEX     *ctx = (EPS_BLOPEX*)eps->data;
141:   PetscInt       k;

144:   k = ((eps->nev-1)/ctx->bs+1)*ctx->bs;
145:   if (*ncv) { /* ncv set */
146:     if (*ncv<k) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv is not sufficiently large");
147:   } else *ncv = k;
148:   if (!*mpd) *mpd = *ncv;
149:   else { PetscInfo(eps,"Warning: given value of mpd ignored\n"); }
150:   return(0);
151: }

155: PetscErrorCode EPSSetUp_BLOPEX(EPS eps)
156: {
157: #if defined(PETSC_MISSING_LAPACK_POTRF) || defined(PETSC_MISSING_LAPACK_SYGV)
159:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"POTRF/SYGV - Lapack routine is unavailable");
160: #else
162:   EPS_BLOPEX     *blopex = (EPS_BLOPEX*)eps->data;
163:   PetscBool      isPrecond,istrivial,flg;

166:   if (!eps->ishermitian || (eps->isgeneralized && !eps->ispositive)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"blopex only works for Hermitian problems");
167:   if (!blopex->bs) blopex->bs = PetscMin(16,eps->nev);
168:   EPSSetDimensions_BLOPEX(eps,eps->nev,&eps->ncv,&eps->mpd);
169:   if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv);
170:   if (!eps->which) eps->which = EPS_SMALLEST_REAL;
171:   if (eps->which!=EPS_SMALLEST_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
172:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
173:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test");
174:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }
175:   RGIsTrivial(eps->rg,&istrivial);
176:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");

178:   STSetUp(eps->st);
179:   PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&isPrecond);
180:   if (!isPrecond) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"blopex only works with STPRECOND");
181:   blopex->st = eps->st;

183:   if (eps->converged == EPSConvergedRelative) {
184:     blopex->tol.absolute = 0.0;
185:     blopex->tol.relative = eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol;
186:   } else if (eps->converged == EPSConvergedAbsolute) {
187:     blopex->tol.absolute = eps->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:eps->tol;
188:     blopex->tol.relative = 0.0;
189:   } else SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Convergence test not supported in this solver");

191:   SLEPCSetupInterpreter(&blopex->ii);

193:   /* allocate memory */
194:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
195:   PetscObjectTypeCompareAny((PetscObject)eps->V,&flg,BVVECS,BVCONTIGUOUS,"");
196:   if (!flg) {  /* blopex only works with BVVECS or BVCONTIGUOUS */
197:     BVSetType(eps->V,BVCONTIGUOUS);
198:   }
199:   EPSAllocateSolution(eps,0);
200:   BVCreateVec(eps->V,&blopex->w);
201:   PetscLogObjectParent((PetscObject)eps,(PetscObject)blopex->w);

203: #if defined(PETSC_USE_COMPLEX)
204:   blopex->blap_fn.zpotrf = PETSC_zpotrf_interface;
205:   blopex->blap_fn.zhegv = PETSC_zsygv_interface;
206: #else
207:   blopex->blap_fn.dpotrf = PETSC_dpotrf_interface;
208:   blopex->blap_fn.dsygv = PETSC_dsygv_interface;
209: #endif

211:   /* dispatch solve method */
212:   eps->ops->solve = EPSSolve_BLOPEX;
213:   return(0);
214: #endif
215: }

219: PetscErrorCode EPSSolve_BLOPEX(EPS eps)
220: {
221:   EPS_BLOPEX        *blopex = (EPS_BLOPEX*)eps->data;
222:   PetscScalar       sigma,*eigr=NULL;
223:   PetscReal         *errest=NULL;
224:   int               i,j,info,its,nconv;
225:   double            *residhist=NULL;
226:   PetscErrorCode    ierr;
227:   mv_MultiVectorPtr eigenvectors,constraints;
228: #if defined(PETSC_USE_COMPLEX)
229:   komplex           *lambda=NULL,*lambdahist=NULL;
230: #else
231:   double            *lambda=NULL,*lambdahist=NULL;
232: #endif

235:   STGetShift(eps->st,&sigma);
236:   PetscMalloc1(blopex->bs,&lambda);
237:   if (eps->numbermonitors>0) {
238:     PetscMalloc4(blopex->bs*(eps->max_it+1),&lambdahist,eps->ncv,&eigr,blopex->bs*(eps->max_it+1),&residhist,eps->ncv,&errest);
239:   }

241:   /* Complete the initial basis with random vectors */
242:   for (i=eps->nini;i<eps->ncv;i++) {
243:     BVSetRandomColumn(eps->V,i);
244:   }

246:   while (eps->reason == EPS_CONVERGED_ITERATING) {

248:     /* Create multivector of constraints from leading columns of V */
249:     PetscObjectComposedDataSetInt((PetscObject)eps->V,slepc_blopex_useconstr,1);
250:     BVSetActiveColumns(eps->V,0,eps->nconv);
251:     constraints = mv_MultiVectorCreateFromSampleVector(&blopex->ii,eps->nds+eps->nconv,eps->V);

253:     /* Create multivector where eigenvectors of this run will be stored */
254:     PetscObjectComposedDataSetInt((PetscObject)eps->V,slepc_blopex_useconstr,0);
255:     BVSetActiveColumns(eps->V,eps->nconv,eps->nconv+blopex->bs);
256:     eigenvectors = mv_MultiVectorCreateFromSampleVector(&blopex->ii,blopex->bs,eps->V);

258: #if defined(PETSC_USE_COMPLEX)
259:     info = lobpcg_solve_complex(eigenvectors,blopex,OperatorAMultiVector,
260:           eps->isgeneralized?blopex:NULL,eps->isgeneralized?OperatorBMultiVector:NULL,
261:           blopex,Precond_FnMultiVector,constraints,
262:           blopex->blap_fn,blopex->tol,eps->max_it,0,&its,
263:           lambda,lambdahist,blopex->bs,eps->errest+eps->nconv,residhist,blopex->bs);
264: #else
265:     info = lobpcg_solve_double(eigenvectors,blopex,OperatorAMultiVector,
266:           eps->isgeneralized?blopex:NULL,eps->isgeneralized?OperatorBMultiVector:NULL,
267:           blopex,Precond_FnMultiVector,constraints,
268:           blopex->blap_fn,blopex->tol,eps->max_it,0,&its,
269:           lambda,lambdahist,blopex->bs,eps->errest+eps->nconv,residhist,blopex->bs);
270: #endif
271:     if (info>0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"BLOPEX failed with exit code=%d",info);
272:     mv_MultiVectorDestroy(constraints);
273:     mv_MultiVectorDestroy(eigenvectors);

275:     for (j=0;j<blopex->bs;j++) {
276: #if defined(PETSC_USE_COMPLEX)
277:       eps->eigr[eps->nconv+j] = lambda[j].real+PETSC_i*lambda[j].imag;
278: #else
279:       eps->eigr[eps->nconv+j] = lambda[j];
280: #endif
281:     }

283:     if (eps->numbermonitors>0) {
284:       for (i=0;i<its;i++) {
285:         nconv = 0;
286:         for (j=0;j<blopex->bs;j++) {
287: #if defined(PETSC_USE_COMPLEX)
288:           eigr[eps->nconv+j] = lambdahist[j+i*blopex->bs].real+PETSC_i*lambdahist[j+i*blopex->bs].imag;
289: #else
290:           eigr[eps->nconv+j] = lambdahist[j+i*blopex->bs];
291: #endif
292:           errest[eps->nconv+j] = residhist[j+i*blopex->bs];
293:           if (residhist[j+i*blopex->bs]<=eps->tol) nconv++;
294:         }
295:         EPSMonitor(eps,eps->its+i,eps->nconv+nconv,eigr,eps->eigi,errest,eps->nconv+blopex->bs);
296:       }
297:     }

299:     eps->its += its;
300:     if (info==-1) {
301:       eps->reason = EPS_DIVERGED_ITS;
302:       break;
303:     } else {
304:       for (i=0;i<blopex->bs;i++) {
305:         if (sigma != 0.0) eps->eigr[eps->nconv+i] += sigma;
306:       }
307:       eps->nconv += blopex->bs;
308:       if (eps->nconv>=eps->nev) eps->reason = EPS_CONVERGED_TOL;
309:     }
310:   }

312:   PetscFree(lambda);
313:   if (eps->numbermonitors>0) {
314:     PetscFree4(lambdahist,eigr,residhist,errest);
315:   }
316:   return(0);
317: }

321: static PetscErrorCode EPSBLOPEXSetBlockSize_BLOPEX(EPS eps,PetscInt bs)
322: {
323:   EPS_BLOPEX *ctx = (EPS_BLOPEX*)eps->data;

326:   ctx->bs = bs;
327:   return(0);
328: }

332: /*@
333:    EPSBLOPEXSetBlockSize - Sets the block size of the BLOPEX solver.

335:    Logically Collective on EPS

337:    Input Parameters:
338: +  eps - the eigenproblem solver context
339: -  bs  - the block size

341:    Options Database Key:
342: .  -eps_blopex_blocksize - Sets the block size

344:    Level: advanced

346: .seealso: EPSBLOPEXGetBlockSize()
347: @*/
348: PetscErrorCode EPSBLOPEXSetBlockSize(EPS eps,PetscInt bs)
349: {

355:   PetscTryMethod(eps,"EPSBLOPEXSetBlockSize_C",(EPS,PetscInt),(eps,bs));
356:   return(0);
357: }

361: static PetscErrorCode EPSBLOPEXGetBlockSize_BLOPEX(EPS eps,PetscInt *bs)
362: {
363:   EPS_BLOPEX *ctx = (EPS_BLOPEX*)eps->data;

366:   *bs = ctx->bs;
367:   return(0);
368: }

372: /*@
373:    EPSBLOPEXGetBlockSize - Gets the block size used in the BLOPEX solver.

375:    Not Collective

377:    Input Parameter:
378: .  eps - the eigenproblem solver context

380:    Output Parameter:
381: .  bs - the block size

383:    Level: advanced

385: .seealso: EPSBLOPEXSetBlockSize()
386: @*/
387: PetscErrorCode EPSBLOPEXGetBlockSize(EPS eps,PetscInt *bs)
388: {

394:   PetscUseMethod(eps,"EPSBLOPEXGetBlockSize_C",(EPS,PetscInt*),(eps,bs));
395:   return(0);
396: }

400: PetscErrorCode EPSReset_BLOPEX(EPS eps)
401: {
403:   EPS_BLOPEX     *blopex = (EPS_BLOPEX*)eps->data;

406:   VecDestroy(&blopex->w);
407:   return(0);
408: }

412: PetscErrorCode EPSDestroy_BLOPEX(EPS eps)
413: {

417:   LOBPCG_DestroyRandomContext();
418:   PetscFree(eps->data);
419:   PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXSetBlockSize_C",NULL);
420:   PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXGetBlockSize_C",NULL);
421:   return(0);
422: }

426: PetscErrorCode EPSView_BLOPEX(EPS eps,PetscViewer viewer)
427: {
429:   EPS_BLOPEX     *ctx = (EPS_BLOPEX*)eps->data;
430:   PetscBool      isascii;

433:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
434:   if (isascii) {
435:     PetscViewerASCIIPrintf(viewer,"  BLOPEX: block size %D\n",ctx->bs);
436:   }
437:   return(0);
438: }

442: PetscErrorCode EPSSetFromOptions_BLOPEX(PetscOptionItems *PetscOptionsObject,EPS eps)
443: {
445:   KSP            ksp;
446:   PetscBool      flg;
447:   PetscInt       bs;

450:   PetscOptionsHead(PetscOptionsObject,"EPS BLOPEX Options");
451:   PetscOptionsInt("-eps_blopex_blocksize","BLOPEX block size","EPSBLOPEXSetBlockSize",20,&bs,&flg);
452:   if (flg) {
453:     EPSBLOPEXSetBlockSize(eps,bs);
454:   }
455:   LOBPCG_SetFromOptionsRandomContext();

457:   /* Set STPrecond as the default ST */
458:   if (!((PetscObject)eps->st)->type_name) {
459:     STSetType(eps->st,STPRECOND);
460:   }
461:   STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);

463:   /* Set the default options of the KSP */
464:   STGetKSP(eps->st,&ksp);
465:   if (!((PetscObject)ksp)->type_name) {
466:     KSPSetType(ksp,KSPPREONLY);
467:   }
468:   PetscOptionsTail();
469:   return(0);
470: }

474: PETSC_EXTERN PetscErrorCode EPSCreate_BLOPEX(EPS eps)
475: {
476:   EPS_BLOPEX     *ctx;

480:   PetscNewLog(eps,&ctx);
481:   eps->data = (void*)ctx;

483:   eps->ops->setup          = EPSSetUp_BLOPEX;
484:   eps->ops->setfromoptions = EPSSetFromOptions_BLOPEX;
485:   eps->ops->destroy        = EPSDestroy_BLOPEX;
486:   eps->ops->reset          = EPSReset_BLOPEX;
487:   eps->ops->view           = EPSView_BLOPEX;
488:   eps->ops->backtransform  = EPSBackTransform_Default;
489:   LOBPCG_InitRandomContext(PetscObjectComm((PetscObject)eps),NULL);
490:   PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXSetBlockSize_C",EPSBLOPEXSetBlockSize_BLOPEX);
491:   PetscObjectComposeFunction((PetscObject)eps,"EPSBLOPEXGetBlockSize_C",EPSBLOPEXGetBlockSize_BLOPEX);
492:   if (slepc_blopex_useconstr < 0) { PetscObjectComposedDataRegister(&slepc_blopex_useconstr); }
493:   return(0);
494: }

slepc-3.7.4/src/eps/impls/external/blopex/petsc-interface.h0000644000175000017500000000340313107004621023225 0ustar jromanjroman/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ /* @@@ BLOPEX (version 1.1) LGPL Version 2.1 or above.See www.gnu.org. */ /* @@@ Copyright 2010 BLOPEX team http://code.google.com/p/blopex/ */ /* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ #if !defined(PETSC_INTERFACE_HEADER) #define PETSC_INTERFACE_HEADER #include "blopex_interpreter.h" BlopexInt PETSC_dpotrf_interface (char *uplo, BlopexInt *n, double *a, BlopexInt * lda, BlopexInt *info); BlopexInt PETSC_dsygv_interface (BlopexInt *itype, char *jobz, char *uplo, BlopexInt * n, double *a, BlopexInt *lda, double *b, BlopexInt *ldb, double *w, double *work, BlopexInt *lwork, BlopexInt *info); BlopexInt PETSC_zpotrf_interface (char *uplo, BlopexInt *n, komplex *a, BlopexInt * lda, BlopexInt *info); BlopexInt PETSC_zsygv_interface (BlopexInt *itype, char *jobz, char *uplo, BlopexInt * n, komplex *a, BlopexInt *lda, komplex *b, BlopexInt *ldb, double *w, komplex *work, BlopexInt *lwork, double *rwork, BlopexInt *info); void * PETSC_MimicVector(void *vvector); BlopexInt PETSC_DestroyVector(void *vvector); BlopexInt PETSC_InnerProd(void *x, void *y, void *result); BlopexInt PETSC_CopyVector(void *x, void *y); BlopexInt PETSC_ClearVector(void *x); BlopexInt PETSC_SetRandomValues(void* v, BlopexInt seed); BlopexInt PETSC_ScaleVector(void *alpha, void *x); BlopexInt PETSC_Axpy(void *alpha, void *x, void *y); int LOBPCG_InitRandomContext(MPI_Comm,PetscRandom); int LOBPCG_SetFromOptionsRandomContext(void); int LOBPCG_DestroyRandomContext(void); int PETSCSetupInterpreter(mv_InterfaceInterpreter *ii); #endif /* PETSC_INTERFACE_HEADER */ slepc-3.7.4/src/eps/impls/external/feast/0000755000175000017500000000000013107004621017611 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/feast/makefile0000644000175000017500000000224313107004621021312 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresdefine 'SLEPC_HAVE_FEAST' CFLAGS = FFLAGS = SOURCEC = feast.c SOURCEF = SOURCEH = feastp.h LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/external/feast/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/feast/feast.c.html0000644000175000017500000006304113107004621022026 0ustar jromanjroman
Actual source code: feast.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the FEAST package

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>        /*I "slepceps.h" I*/
 25: #include <../src/eps/impls/external/feast/feastp.h>

 27: PetscErrorCode EPSSolve_FEAST(EPS);

 31: PetscErrorCode EPSSetUp_FEAST(EPS eps)
 32: {
 34:   PetscInt       ncv;
 35:   PetscBool      issinv,flg;
 36:   EPS_FEAST      *ctx = (EPS_FEAST*)eps->data;
 37:   PetscMPIInt    size;

 40:   MPI_Comm_size(PetscObjectComm((PetscObject)eps),&size);
 41:   if (size!=1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The FEAST interface is supported for sequential runs only");
 42:   if (eps->ncv) {
 43:     if (eps->ncv<eps->nev+2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The value of ncv must be at least nev+2");
 44:   } else eps->ncv = PetscMin(PetscMax(20,2*eps->nev+1),eps->n); /* set default value of ncv */
 45:   if (eps->mpd) { PetscInfo(eps,"Warning: parameter mpd ignored\n"); }
 46:   if (!eps->max_it) eps->max_it = PetscMax(300,(PetscInt)(2*eps->n/eps->ncv));
 47:   if (!eps->which) eps->which = EPS_ALL;

 49:   ncv = eps->ncv;
 50:   PetscFree4(ctx->work1,ctx->work2,ctx->Aq,ctx->Bq);
 51:   PetscMalloc4(eps->nloc*ncv,&ctx->work1,eps->nloc*ncv,&ctx->work2,ncv*ncv,&ctx->Aq,ncv*ncv,&ctx->Bq);
 52:   PetscLogObjectMemory((PetscObject)eps,(2*eps->nloc*ncv+2*ncv*ncv)*sizeof(PetscScalar));

 54:   if (!((PetscObject)(eps->st))->type_name) { /* default to shift-and-invert */
 55:     STSetType(eps->st,STSINVERT);
 56:   }
 57:   PetscObjectTypeCompareAny((PetscObject)eps->st,&issinv,STSINVERT,STCAYLEY,"");
 58:   if (!issinv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Shift-and-invert or Cayley ST is needed for FEAST");

 60:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }

 62:   if (eps->which!=EPS_ALL || (eps->inta==0.0 && eps->intb==0.0)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"FEAST must be used with a computational interval");
 63:   if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"FEAST only available for symmetric/Hermitian eigenproblems");
 64:   if (eps->balance!=EPS_BALANCE_NONE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Balancing not supported in the FEAST interface");
 65:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
 66:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test");

 68:   if (!ctx->npoints) ctx->npoints = 8;

 70:   EPSAllocateSolution(eps,0);
 71:   PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);
 72:   if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage");
 73:   EPSSetWorkVecs(eps,1);

 75:   /* dispatch solve method */
 76:   eps->ops->solve = EPSSolve_FEAST;
 77:   return(0);
 78: }

 82: PetscErrorCode EPSSolve_FEAST(EPS eps)
 83: {
 85:   EPS_FEAST      *ctx = (EPS_FEAST*)eps->data;
 86:   PetscBLASInt   n,fpm[64],ijob,info,nev,ncv,loop;
 87:   PetscReal      *evals,epsout;
 88:   PetscInt       i,k,nmat;
 89:   PetscScalar    *pV,Ze;
 90:   Vec            v0,x,y,w = eps->work[0];
 91:   Mat            A,B;

 94:   PetscBLASIntCast(eps->nev,&nev);
 95:   PetscBLASIntCast(eps->ncv,&ncv);
 96:   PetscBLASIntCast(eps->nloc,&n);

 98:   /* parameters */
 99:   FEASTinit_(fpm);
100:   fpm[0] = (eps->numbermonitors>0)? 1: 0;                      /* runtime comments */
101:   fpm[1] = ctx->npoints;                                       /* contour points */
102:   PetscBLASIntCast(eps->max_it,&fpm[3]);  /* refinement loops */
103: #if !defined(PETSC_HAVE_MPIUNI)
104:   PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&fpm[8]);
105: #endif

107:   PetscMalloc1(eps->ncv,&evals);
108:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&x);
109:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&y);
110:   BVGetColumn(eps->V,0,&v0);
111:   VecGetArray(v0,&pV);

113:   ijob = -1;           /* first call to reverse communication interface */
114:   STGetNumMatrices(eps->st,&nmat);
115:   STGetOperators(eps->st,0,&A);
116:   if (nmat>1) { STGetOperators(eps->st,1,&B); }
117:   else B = NULL;

119:   do {

121:     PetscStackCall("FEASTrci",FEASTrci_(&ijob,&n,&Ze,ctx->work1,ctx->work2,ctx->Aq,ctx->Bq,fpm,&epsout,&loop,&eps->inta,&eps->intb,&eps->ncv,evals,pV,&eps->nconv,eps->errest,&info));

123:     if (ncv!=eps->ncv) SETERRQ1(PetscObjectComm((PetscObject)eps),1,"FEAST changed value of ncv to %d",ncv);
124:     if (ijob == 10 || ijob == 20) {
125:       /* set new quadrature point */
126:       STSetShift(eps->st,-Ze);
127:     } else if (ijob == 11 || ijob == 21) {
128:       /* linear solve (A-sigma*B)\work2, overwrite work2 */
129:       for (k=0;k<ncv;k++) {
130:         VecPlaceArray(x,ctx->work2+eps->nloc*k);
131:         if (ijob == 11) {
132:           STMatSolve(eps->st,x,w);
133:         } else {
134:           STMatSolveTranspose(eps->st,x,w);
135:         }
136:         VecCopy(w,x);
137:         VecScale(x,-1.0);
138:         VecResetArray(x);
139:       }
140:     } else if (ijob == 30 || ijob == 40) {
141:       /* multiplication A*V or B*V, result in work1 */
142:       for (k=0;k<fpm[24];k++) {
143:         VecPlaceArray(x,&pV[(fpm[23]+k-1)*eps->nloc]);
144:         VecPlaceArray(y,&ctx->work1[(fpm[23]+k-1)*eps->nloc]);
145:         if (ijob == 30) {
146:           MatMult(A,x,y);
147:         } else if (nmat>1) {
148:           MatMult(B,x,y);
149:         } else {
150:           VecCopy(x,y);
151:         }
152:         VecResetArray(x);
153:         VecResetArray(y);
154:       }
155:     } else if (ijob != 0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Internal error in FEAST reverse comunication interface (ijob=%d)",ijob);

157:   } while (ijob != 0);

159:   eps->reason = EPS_CONVERGED_TOL;
160:   eps->its = loop;
161:   if (info!=0) {
162:     if (info==1) { /* No eigenvalue has been found in the proposed search interval */
163:       eps->nconv = 0;
164:     } else if (info==2) { /* FEAST did not converge "yet" */
165:       eps->reason = EPS_DIVERGED_ITS;
166:     } else SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error reported by FEAST (%d)",info);
167:   }

169:   for (i=0;i<eps->nconv;i++) eps->eigr[i] = evals[i];

171:   VecRestoreArray(v0,&pV);
172:   BVRestoreColumn(eps->V,0,&v0);
173:   VecDestroy(&x);
174:   VecDestroy(&y);
175:   PetscFree(evals);
176:   return(0);
177: }

181: PetscErrorCode EPSReset_FEAST(EPS eps)
182: {
184:   EPS_FEAST      *ctx = (EPS_FEAST*)eps->data;

187:   PetscFree4(ctx->work1,ctx->work2,ctx->Aq,ctx->Bq);
188:   return(0);
189: }

193: PetscErrorCode EPSDestroy_FEAST(EPS eps)
194: {

198:   PetscFree(eps->data);
199:   PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTSetNumPoints_C",NULL);
200:   PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTGetNumPoints_C",NULL);
201:   return(0);
202: }

206: PetscErrorCode EPSSetFromOptions_FEAST(PetscOptionItems *PetscOptionsObject,EPS eps)
207: {
209:   EPS_FEAST      *ctx = (EPS_FEAST*)eps->data;
210:   PetscInt       n;
211:   PetscBool      flg;

214:   PetscOptionsHead(PetscOptionsObject,"EPS FEAST Options");

216:   n = ctx->npoints;
217:   PetscOptionsInt("-eps_feast_num_points","Number of contour integration points","EPSFEASTSetNumPoints",n,&n,&flg);
218:   if (flg) {
219:     EPSFEASTSetNumPoints(eps,n);
220:   }

222:   PetscOptionsTail();
223:   return(0);
224: }

228: PetscErrorCode EPSView_FEAST(EPS eps,PetscViewer viewer)
229: {
231:   EPS_FEAST      *ctx = (EPS_FEAST*)eps->data;
232:   PetscBool      isascii;

235:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
236:   if (isascii) {
237:     PetscViewerASCIIPrintf(viewer,"  FEAST: number of contour integration points=%D\n",ctx->npoints);
238:   }
239:   return(0);
240: }

244: static PetscErrorCode EPSFEASTSetNumPoints_FEAST(EPS eps,PetscInt npoints)
245: {
247:   EPS_FEAST      *ctx = (EPS_FEAST*)eps->data;

250:   if (npoints == PETSC_DEFAULT) ctx->npoints = 8;
251:   else {
252:     PetscBLASIntCast(npoints,&ctx->npoints);
253:   }
254:   return(0);
255: }

259: /*@
260:    EPSFEASTSetNumPoints - Sets the number of contour integration points for
261:    the FEAST package.

263:    Collective on EPS

265:    Input Parameters:
266: +  eps     - the eigenproblem solver context
267: -  npoints - number of contour integration points

269:    Options Database Key:
270: .  -eps_feast_num_points - Sets the number of points

272:    Level: advanced

274: .seealso: EPSFEASTGetNumPoints()
275: @*/
276: PetscErrorCode EPSFEASTSetNumPoints(EPS eps,PetscInt npoints)
277: {

283:   PetscTryMethod(eps,"EPSFEASTSetNumPoints_C",(EPS,PetscInt),(eps,npoints));
284:   return(0);
285: }

289: static PetscErrorCode EPSFEASTGetNumPoints_FEAST(EPS eps,PetscInt *npoints)
290: {
291:   EPS_FEAST *ctx = (EPS_FEAST*)eps->data;

294:   *npoints = ctx->npoints;
295:   return(0);
296: }

300: /*@
301:    EPSFEASTGetNumPoints - Gets the number of contour integration points for
302:    the FEAST package.

304:    Collective on EPS

306:    Input Parameter:
307: .  eps     - the eigenproblem solver context

309:    Output Parameter:
310: -  npoints - number of contour integration points

312:    Level: advanced

314: .seealso: EPSFEASTSetNumPoints()
315: @*/
316: PetscErrorCode EPSFEASTGetNumPoints(EPS eps,PetscInt *npoints)
317: {

323:   PetscUseMethod(eps,"EPSFEASTGetNumPoints_C",(EPS,PetscInt*),(eps,npoints));
324:   return(0);
325: }

329: PETSC_EXTERN PetscErrorCode EPSCreate_FEAST(EPS eps)
330: {
331:   EPS_FEAST      *ctx;

335:   PetscNewLog(eps,&ctx);
336:   eps->data = (void*)ctx;

338:   eps->ops->setup                = EPSSetUp_FEAST;
339:   eps->ops->setfromoptions       = EPSSetFromOptions_FEAST;
340:   eps->ops->destroy              = EPSDestroy_FEAST;
341:   eps->ops->reset                = EPSReset_FEAST;
342:   eps->ops->view                 = EPSView_FEAST;
343:   PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTSetNumPoints_C",EPSFEASTSetNumPoints_FEAST);
344:   PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTGetNumPoints_C",EPSFEASTGetNumPoints_FEAST);
345:   return(0);
346: }

slepc-3.7.4/src/eps/impls/external/feast/makefile.html0000644000175000017500000000502213107004621022253 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresdefine  'SLEPC_HAVE_FEAST'

CFLAGS   =
FFLAGS   =
SOURCEC  = feast.c
SOURCEF  =
SOURCEH  = feastp.h
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/external/feast/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/external/feast/feastp.h0000644000175000017500000000611113107004621021243 0ustar jromanjroman/* Private data structure used by the FEAST interface - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__FEASTP_H) #define __FEASTP_H typedef struct { PetscScalar *work1,*work2,*Aq,*Bq; /* workspace */ PetscBLASInt npoints; /* number of contour points */ } EPS_FEAST; /* Definition of routines from the FEAST package */ #if defined(SLEPC_FEAST_HAVE_UNDERSCORE) #define SLEPC_FEAST(lcase,ucase) lcase##_ #elif defined(SLEPC_FEAST_HAVE_CAPS) #define SLEPC_FEAST(lcase,ucase) ucase #else #define SLEPC_FEAST(lcase,ucase) lcase #endif #if defined(PETSC_USE_COMPLEX) #if defined(PETSC_USE_REAL_SINGLE) #if defined(SLEPC_FEAST_HAVE_UNDERSCORE) #define SLEPC_FEASTM(lcase,ucase) cfeast_h##lcase##_ #elif defined(SLEPC_FEAST_HAVE_CAPS) #define SLEPC_FEASTM(lcase,ucase) CFEAST_H##ucase #else #define SLEPC_FEASTM(lcase,ucase) cfeast_h##lcase #endif #else #if defined(SLEPC_FEAST_HAVE_UNDERSCORE) #define SLEPC_FEASTM(lcase,ucase) zfeast_h##lcase##_ #elif defined(SLEPC_FEAST_HAVE_CAPS) #define SLEPC_FEASTM(lcase,ucase) ZFEAST_H##ucase #else #define SLEPC_FEASTM(lcase,ucase) zfeast_h##lcase #endif #endif #else #if defined(PETSC_USE_REAL_SINGLE) #if defined(SLEPC_FEAST_HAVE_UNDERSCORE) #define SLEPC_FEASTM(lcase,ucase) sfeast_s##lcase##_ #elif defined(SLEPC_FEAST_HAVE_CAPS) #define SLEPC_FEASTM(lcase,ucase) SFEAST_S##ucase #else #define SLEPC_FEASTM(lcase,ucase) sfeast_s##lcase #endif #else #if defined(SLEPC_FEAST_HAVE_UNDERSCORE) #define SLEPC_FEASTM(lcase,ucase) dfeast_s##lcase##_ #elif defined(SLEPC_FEAST_HAVE_CAPS) #define SLEPC_FEASTM(lcase,ucase) DFEAST_S##ucase #else #define SLEPC_FEASTM(lcase,ucase) dfeast_s##lcase #endif #endif #endif #define FEASTinit_(a) SLEPC_FEAST(feastinit,FEASTINIT) ((a)) #define FEASTrci_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) SLEPC_FEASTM(rci,RCI) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r)) PETSC_EXTERN void SLEPC_FEAST(feastinit,FEASTINIT)(PetscBLASInt*); PETSC_EXTERN void SLEPC_FEASTM(rci,RCI)(PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*); #endif slepc-3.7.4/src/eps/impls/external/feast/feast.c0000644000175000017500000003116413107004621021064 0ustar jromanjroman/* This file implements a wrapper to the FEAST package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include <../src/eps/impls/external/feast/feastp.h> PetscErrorCode EPSSolve_FEAST(EPS); #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_FEAST" PetscErrorCode EPSSetUp_FEAST(EPS eps) { PetscErrorCode ierr; PetscInt ncv; PetscBool issinv,flg; EPS_FEAST *ctx = (EPS_FEAST*)eps->data; PetscMPIInt size; PetscFunctionBegin; ierr = MPI_Comm_size(PetscObjectComm((PetscObject)eps),&size);CHKERRQ(ierr); if (size!=1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The FEAST interface is supported for sequential runs only"); if (eps->ncv) { if (eps->ncvnev+2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The value of ncv must be at least nev+2"); } else eps->ncv = PetscMin(PetscMax(20,2*eps->nev+1),eps->n); /* set default value of ncv */ if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (!eps->max_it) eps->max_it = PetscMax(300,(PetscInt)(2*eps->n/eps->ncv)); if (!eps->which) eps->which = EPS_ALL; ncv = eps->ncv; ierr = PetscFree4(ctx->work1,ctx->work2,ctx->Aq,ctx->Bq);CHKERRQ(ierr); ierr = PetscMalloc4(eps->nloc*ncv,&ctx->work1,eps->nloc*ncv,&ctx->work2,ncv*ncv,&ctx->Aq,ncv*ncv,&ctx->Bq);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,(2*eps->nloc*ncv+2*ncv*ncv)*sizeof(PetscScalar));CHKERRQ(ierr); if (!((PetscObject)(eps->st))->type_name) { /* default to shift-and-invert */ ierr = STSetType(eps->st,STSINVERT);CHKERRQ(ierr); } ierr = PetscObjectTypeCompareAny((PetscObject)eps->st,&issinv,STSINVERT,STCAYLEY,"");CHKERRQ(ierr); if (!issinv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Shift-and-invert or Cayley ST is needed for FEAST"); if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } if (eps->which!=EPS_ALL || (eps->inta==0.0 && eps->intb==0.0)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"FEAST must be used with a computational interval"); if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"FEAST only available for symmetric/Hermitian eigenproblems"); if (eps->balance!=EPS_BALANCE_NONE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Balancing not supported in the FEAST interface"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"External packages do not support user-defined stopping test"); if (!ctx->npoints) ctx->npoints = 8; ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->V,BVVECS,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver requires a BV with contiguous storage"); ierr = EPSSetWorkVecs(eps,1);CHKERRQ(ierr); /* dispatch solve method */ eps->ops->solve = EPSSolve_FEAST; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_FEAST" PetscErrorCode EPSSolve_FEAST(EPS eps) { PetscErrorCode ierr; EPS_FEAST *ctx = (EPS_FEAST*)eps->data; PetscBLASInt n,fpm[64],ijob,info,nev,ncv,loop; PetscReal *evals,epsout; PetscInt i,k,nmat; PetscScalar *pV,Ze; Vec v0,x,y,w = eps->work[0]; Mat A,B; PetscFunctionBegin; ierr = PetscBLASIntCast(eps->nev,&nev);CHKERRQ(ierr); ierr = PetscBLASIntCast(eps->ncv,&ncv);CHKERRQ(ierr); ierr = PetscBLASIntCast(eps->nloc,&n);CHKERRQ(ierr); /* parameters */ FEASTinit_(fpm); fpm[0] = (eps->numbermonitors>0)? 1: 0; /* runtime comments */ fpm[1] = ctx->npoints; /* contour points */ ierr = PetscBLASIntCast(eps->max_it,&fpm[3]);CHKERRQ(ierr); /* refinement loops */ #if !defined(PETSC_HAVE_MPIUNI) ierr = PetscBLASIntCast(MPI_Comm_c2f(PetscObjectComm((PetscObject)eps)),&fpm[8]);CHKERRQ(ierr); #endif ierr = PetscMalloc1(eps->ncv,&evals);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&x);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)eps),1,eps->nloc,PETSC_DECIDE,NULL,&y);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,0,&v0);CHKERRQ(ierr); ierr = VecGetArray(v0,&pV);CHKERRQ(ierr); ijob = -1; /* first call to reverse communication interface */ ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } else B = NULL; do { PetscStackCall("FEASTrci",FEASTrci_(&ijob,&n,&Ze,ctx->work1,ctx->work2,ctx->Aq,ctx->Bq,fpm,&epsout,&loop,&eps->inta,&eps->intb,&eps->ncv,evals,pV,&eps->nconv,eps->errest,&info)); if (ncv!=eps->ncv) SETERRQ1(PetscObjectComm((PetscObject)eps),1,"FEAST changed value of ncv to %d",ncv); if (ijob == 10 || ijob == 20) { /* set new quadrature point */ ierr = STSetShift(eps->st,-Ze);CHKERRQ(ierr); } else if (ijob == 11 || ijob == 21) { /* linear solve (A-sigma*B)\work2, overwrite work2 */ for (k=0;kwork2+eps->nloc*k);CHKERRQ(ierr); if (ijob == 11) { ierr = STMatSolve(eps->st,x,w);CHKERRQ(ierr); } else { ierr = STMatSolveTranspose(eps->st,x,w);CHKERRQ(ierr); } ierr = VecCopy(w,x);CHKERRQ(ierr); ierr = VecScale(x,-1.0);CHKERRQ(ierr); ierr = VecResetArray(x);CHKERRQ(ierr); } } else if (ijob == 30 || ijob == 40) { /* multiplication A*V or B*V, result in work1 */ for (k=0;knloc]);CHKERRQ(ierr); ierr = VecPlaceArray(y,&ctx->work1[(fpm[23]+k-1)*eps->nloc]);CHKERRQ(ierr); if (ijob == 30) { ierr = MatMult(A,x,y);CHKERRQ(ierr); } else if (nmat>1) { ierr = MatMult(B,x,y);CHKERRQ(ierr); } else { ierr = VecCopy(x,y);CHKERRQ(ierr); } ierr = VecResetArray(x);CHKERRQ(ierr); ierr = VecResetArray(y);CHKERRQ(ierr); } } else if (ijob != 0) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Internal error in FEAST reverse comunication interface (ijob=%d)",ijob); } while (ijob != 0); eps->reason = EPS_CONVERGED_TOL; eps->its = loop; if (info!=0) { if (info==1) { /* No eigenvalue has been found in the proposed search interval */ eps->nconv = 0; } else if (info==2) { /* FEAST did not converge "yet" */ eps->reason = EPS_DIVERGED_ITS; } else SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error reported by FEAST (%d)",info); } for (i=0;inconv;i++) eps->eigr[i] = evals[i]; ierr = VecRestoreArray(v0,&pV);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&v0);CHKERRQ(ierr); ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); ierr = PetscFree(evals);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_FEAST" PetscErrorCode EPSReset_FEAST(EPS eps) { PetscErrorCode ierr; EPS_FEAST *ctx = (EPS_FEAST*)eps->data; PetscFunctionBegin; ierr = PetscFree4(ctx->work1,ctx->work2,ctx->Aq,ctx->Bq);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_FEAST" PetscErrorCode EPSDestroy_FEAST(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTSetNumPoints_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTGetNumPoints_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_FEAST" PetscErrorCode EPSSetFromOptions_FEAST(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; EPS_FEAST *ctx = (EPS_FEAST*)eps->data; PetscInt n; PetscBool flg; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS FEAST Options");CHKERRQ(ierr); n = ctx->npoints; ierr = PetscOptionsInt("-eps_feast_num_points","Number of contour integration points","EPSFEASTSetNumPoints",n,&n,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSFEASTSetNumPoints(eps,n);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_FEAST" PetscErrorCode EPSView_FEAST(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_FEAST *ctx = (EPS_FEAST*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," FEAST: number of contour integration points=%D\n",ctx->npoints);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSFEASTSetNumPoints_FEAST" static PetscErrorCode EPSFEASTSetNumPoints_FEAST(EPS eps,PetscInt npoints) { PetscErrorCode ierr; EPS_FEAST *ctx = (EPS_FEAST*)eps->data; PetscFunctionBegin; if (npoints == PETSC_DEFAULT) ctx->npoints = 8; else { ierr = PetscBLASIntCast(npoints,&ctx->npoints);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSFEASTSetNumPoints" /*@ EPSFEASTSetNumPoints - Sets the number of contour integration points for the FEAST package. Collective on EPS Input Parameters: + eps - the eigenproblem solver context - npoints - number of contour integration points Options Database Key: . -eps_feast_num_points - Sets the number of points Level: advanced .seealso: EPSFEASTGetNumPoints() @*/ PetscErrorCode EPSFEASTSetNumPoints(EPS eps,PetscInt npoints) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,npoints,2); ierr = PetscTryMethod(eps,"EPSFEASTSetNumPoints_C",(EPS,PetscInt),(eps,npoints));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSFEASTGetNumPoints_FEAST" static PetscErrorCode EPSFEASTGetNumPoints_FEAST(EPS eps,PetscInt *npoints) { EPS_FEAST *ctx = (EPS_FEAST*)eps->data; PetscFunctionBegin; *npoints = ctx->npoints; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSFEASTGetNumPoints" /*@ EPSFEASTGetNumPoints - Gets the number of contour integration points for the FEAST package. Collective on EPS Input Parameter: . eps - the eigenproblem solver context Output Parameter: - npoints - number of contour integration points Level: advanced .seealso: EPSFEASTSetNumPoints() @*/ PetscErrorCode EPSFEASTGetNumPoints(EPS eps,PetscInt *npoints) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(npoints,2); ierr = PetscUseMethod(eps,"EPSFEASTGetNumPoints_C",(EPS,PetscInt*),(eps,npoints));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_FEAST" PETSC_EXTERN PetscErrorCode EPSCreate_FEAST(EPS eps) { EPS_FEAST *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; eps->ops->setup = EPSSetUp_FEAST; eps->ops->setfromoptions = EPSSetFromOptions_FEAST; eps->ops->destroy = EPSDestroy_FEAST; eps->ops->reset = EPSReset_FEAST; eps->ops->view = EPSView_FEAST; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTSetNumPoints_C",EPSFEASTSetNumPoints_FEAST);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSFEASTGetNumPoints_C",EPSFEASTGetNumPoints_FEAST);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/external/feast/index.html0000644000175000017500000000266713107004621021621 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

feastp.h
feast.c
makefile
slepc-3.7.4/src/eps/impls/external/feast/feastp.h.html0000644000175000017500000001777613107004621022231 0ustar jromanjroman

Actual source code: feastp.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private data structure used by the FEAST interface

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

  8:    This file is part of SLEPc.

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

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

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


 27: typedef struct {
 28:   PetscScalar  *work1,*work2,*Aq,*Bq;   /* workspace */
 29:   PetscBLASInt npoints;                 /* number of contour points */
 30: } EPS_FEAST;

 32: /*
 33:    Definition of routines from the FEAST package
 34: */

 36: #if defined(SLEPC_FEAST_HAVE_UNDERSCORE)
 37: #define SLEPC_FEAST(lcase,ucase) lcase##_
 38: #elif defined(SLEPC_FEAST_HAVE_CAPS)
 39: #define SLEPC_FEAST(lcase,ucase) ucase
 40: #else
 41: #define SLEPC_FEAST(lcase,ucase) lcase
 42: #endif

 44: #if defined(PETSC_USE_COMPLEX)

 46: #if defined(PETSC_USE_REAL_SINGLE)

 48: #if defined(SLEPC_FEAST_HAVE_UNDERSCORE)
 49: #define SLEPC_FEASTM(lcase,ucase) cfeast_h##lcase##_
 50: #elif defined(SLEPC_FEAST_HAVE_CAPS)
 51: #define SLEPC_FEASTM(lcase,ucase) CFEAST_H##ucase
 52: #else
 53: #define SLEPC_FEASTM(lcase,ucase) cfeast_h##lcase
 54: #endif

 56: #else

 58: #if defined(SLEPC_FEAST_HAVE_UNDERSCORE)
 59: #define SLEPC_FEASTM(lcase,ucase) zfeast_h##lcase##_
 60: #elif defined(SLEPC_FEAST_HAVE_CAPS)
 61: #define SLEPC_FEASTM(lcase,ucase) ZFEAST_H##ucase
 62: #else
 63: #define SLEPC_FEASTM(lcase,ucase) zfeast_h##lcase
 64: #endif

 66: #endif

 68: #else

 70: #if defined(PETSC_USE_REAL_SINGLE)

 72: #if defined(SLEPC_FEAST_HAVE_UNDERSCORE)
 73: #define SLEPC_FEASTM(lcase,ucase) sfeast_s##lcase##_
 74: #elif defined(SLEPC_FEAST_HAVE_CAPS)
 75: #define SLEPC_FEASTM(lcase,ucase) SFEAST_S##ucase
 76: #else
 77: #define SLEPC_FEASTM(lcase,ucase) sfeast_s##lcase
 78: #endif

 80: #else

 82: #if defined(SLEPC_FEAST_HAVE_UNDERSCORE)
 83: #define SLEPC_FEASTM(lcase,ucase) dfeast_s##lcase##_
 84: #elif defined(SLEPC_FEAST_HAVE_CAPS)
 85: #define SLEPC_FEASTM(lcase,ucase) DFEAST_S##ucase
 86: #else
 87: #define SLEPC_FEASTM(lcase,ucase) dfeast_s##lcase
 88: #endif

 90: #endif

 92: #endif

 94: #define FEASTinit_(a) SLEPC_FEAST(feastinit,FEASTINIT) ((a))
 95: #define FEASTrci_(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) SLEPC_FEASTM(rci,RCI) ((a),(b),(c),(d),(e),(f),(g),(h),(i),(j),(k),(l),(m),(n),(o),(p),(q),(r))

 97: PETSC_EXTERN void   SLEPC_FEAST(feastinit,FEASTINIT)(PetscBLASInt*);
 98: PETSC_EXTERN void   SLEPC_FEASTM(rci,RCI)(PetscBLASInt*,PetscBLASInt*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*,PetscReal*,PetscReal*,PetscBLASInt*,PetscReal*,PetscScalar*,PetscBLASInt*,PetscReal*,PetscBLASInt*);

100: #endif

slepc-3.7.4/src/eps/impls/external/feast/ftn-auto/0000755000175000017500000000000013107004621021346 5ustar jromanjromanslepc-3.7.4/src/eps/impls/external/feast/ftn-auto/makefile0000644000175000017500000000037013107004621023046 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = feastf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/external/feast/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/external/feast/ftn-auto/feastf.c0000644000175000017500000000276013107004621022767 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* feast.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsfeastsetnumpoints_ EPSFEASTSETNUMPOINTS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsfeastsetnumpoints_ epsfeastsetnumpoints #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsfeastgetnumpoints_ EPSFEASTGETNUMPOINTS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsfeastgetnumpoints_ epsfeastgetnumpoints #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsfeastsetnumpoints_(EPS eps,PetscInt *npoints, int *__ierr ){ *__ierr = EPSFEASTSetNumPoints( (EPS)PetscToPointer((eps) ),*npoints); } PETSC_EXTERN void PETSC_STDCALL epsfeastgetnumpoints_(EPS eps,PetscInt *npoints, int *__ierr ){ *__ierr = EPSFEASTGetNumPoints( (EPS)PetscToPointer((eps) ),npoints); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/external/index.html0000644000175000017500000000304513107004621020506 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

arpack/
blopex/
blzpack/
primme/
trlan/
feast/
makefile
slepc-3.7.4/src/eps/impls/cg/0000755000175000017500000000000013107004621015256 5ustar jromanjromanslepc-3.7.4/src/eps/impls/cg/makefile0000644000175000017500000000206513107004621016761 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepceps DIRS = rqcg lobpcg LOCDIR = src/eps/impls/cg/ MANSEC = EPS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/cg/makefile.html0000644000175000017500000000455713107004621017734 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepceps
DIRS     = rqcg lobpcg
LOCDIR   = src/eps/impls/cg/
MANSEC   = EPS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/cg/lobpcg/0000755000175000017500000000000013107004621016524 5ustar jromanjromanslepc-3.7.4/src/eps/impls/cg/lobpcg/makefile0000644000175000017500000000216013107004621020223 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = lobpcg.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/cg/lobpcg/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/cg/lobpcg/lobpcg.c0000644000175000017500000006543013107004621020146 0ustar jromanjroman/* SLEPc eigensolver: "lobpcg" Method: Locally Optimal Block Preconditioned Conjugate Gradient Algorithm: LOBPCG with soft and hard locking. Follows the implementation in BLOPEX [2]. References: [1] A. V. Knyazev, "Toward the optimal preconditioned eigensolver: locally optimal block preconditioned conjugate gradient method", SIAM J. Sci. Comput. 23(2):517-541, 2001. [2] A. V. Knyazev et al., "Block Locally Optimal Preconditioned Eigenvalue Xolvers (BLOPEX) in Hypre and PETSc", SIAM J. Sci. Comput. 29(5):2224-2239, 2007. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ typedef struct { PetscInt bs; /* block size */ PetscBool lock; /* soft locking active/inactive */ PetscReal restart; /* restart parameter */ } EPS_LOBPCG; #undef __FUNCT__ #define __FUNCT__ "EPSSetDimensions_LOBPCG" PetscErrorCode EPSSetDimensions_LOBPCG(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd) { EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscInt k; PetscFunctionBegin; k = PetscMax(3*ctx->bs,((eps->nev-1)/ctx->bs+3)*ctx->bs); if (*ncv) { /* ncv set */ if (*ncvbs; else if (*mpd!=3*ctx->bs) SETERRQ(PetscObjectComm((PetscObject)eps),1,"This solver does not allow a value of mpd different from 3*blocksize"); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_LOBPCG" PetscErrorCode EPSSetUp_LOBPCG(EPS eps) { PetscErrorCode ierr; EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscBool precond,istrivial; PetscFunctionBegin; if (!eps->ishermitian || (eps->isgeneralized && !eps->ispositive)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"LOBPCG only works for Hermitian problems"); if (!ctx->bs) ctx->bs = PetscMin(16,eps->nev); if (eps->n-eps->nds<5*ctx->bs) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The problem size is too small relative to the block size"); ierr = EPSSetDimensions_LOBPCG(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv); if (!eps->which) eps->which = EPS_SMALLEST_REAL; if (eps->which!=EPS_SMALLEST_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering"); if (!ctx->restart) ctx->restart = 0.9; ierr = STSetUp(eps->st);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&precond);CHKERRQ(ierr); if (!precond) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"LOBPCG only works with precond ST"); ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); ierr = DSSetType(eps->ds,DSGHEP);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,eps->mpd);CHKERRQ(ierr); ierr = EPSSetWorkVecs(eps,1);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_LOBPCG" PetscErrorCode EPSSolve_LOBPCG(EPS eps) { PetscErrorCode ierr; EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscInt i,j,k,ld,nv,ini,kini,nmat,nc,nconv,locked,guard,its; PetscReal norm; PetscScalar *eigr; PetscBool breakdown,countc; Mat A,B,M; Vec v,w=eps->work[0]; BV X,Y,Z,R,P,AX,BX; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } else B = NULL; guard = (PetscInt)((1.0-ctx->restart)*ctx->bs); /* number of guard vectors */ /* 1. Allocate memory */ ierr = PetscCalloc1(3*ctx->bs,&eigr);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,3*ctx->bs,&Z);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,ctx->bs,&X);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,ctx->bs,&R);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,ctx->bs,&P);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,ctx->bs,&AX);CHKERRQ(ierr); if (B) { ierr = BVDuplicateResize(eps->V,ctx->bs,&BX);CHKERRQ(ierr); } nc = eps->nds; if (nc>0 || eps->nev>ctx->bs-guard) { ierr = BVDuplicateResize(eps->V,nc+eps->nev,&Y);CHKERRQ(ierr); } if (nc>0) { for (j=0;jV,-nc+j,&v);CHKERRQ(ierr); ierr = BVInsertVec(Y,j,v);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,-nc+j,&v);CHKERRQ(ierr); } ierr = BVSetActiveColumns(Y,0,nc);CHKERRQ(ierr); } /* 2. Apply the constraints to the initial vectors */ kini = eps->nini; while (kinincv-ctx->bs) { /* Generate more initial vectors if necessary */ ierr = BVSetRandomColumn(eps->V,kini);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,kini,NULL,&norm,&breakdown);CHKERRQ(ierr); if (norm>0.0 && !breakdown) { ierr = BVScaleColumn(eps->V,kini,1.0/norm);CHKERRQ(ierr); kini++; } } nv = ctx->bs; ierr = BVSetActiveColumns(eps->V,0,nv);CHKERRQ(ierr); ierr = BVSetActiveColumns(Z,0,nv);CHKERRQ(ierr); ierr = BVCopy(eps->V,Z);CHKERRQ(ierr); ierr = BVCopy(Z,X);CHKERRQ(ierr); /* 3. B-orthogonalize initial vectors */ /* 4. Compute initial Ritz vectors */ ierr = BVMatMult(X,A,AX);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,0,0);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); ierr = BVMatProject(AX,NULL,X,M);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); ierr = DSSetIdentity(eps->ds,DS_MAT_B);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSSolve(eps->ds,eps->eigr,NULL);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_X,&M);CHKERRQ(ierr); ierr = BVMultInPlace(X,M,0,nv);CHKERRQ(ierr); ierr = BVMultInPlace(AX,M,0,nv);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_X,&M);CHKERRQ(ierr); /* 5. Initialize range of active iterates */ locked = 0; /* hard-locked vectors, the leading locked columns of V are eigenvectors */ nconv = 0; /* number of converged eigenvalues in the current block */ its = 0; /* iterations for the current block */ /* 6. Main loop */ while (eps->reason == EPS_CONVERGED_ITERATING) { if (ctx->lock) { ierr = BVSetActiveColumns(R,nconv,ctx->bs);CHKERRQ(ierr); ierr = BVSetActiveColumns(AX,nconv,ctx->bs);CHKERRQ(ierr); if (B) { ierr = BVSetActiveColumns(BX,nconv,ctx->bs);CHKERRQ(ierr); } } /* 7. Compute residuals */ ierr = DSGetMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); ierr = BVCopy(AX,R);CHKERRQ(ierr); if (B) { ierr = BVMatMult(X,B,BX);CHKERRQ(ierr); ierr = BVMult(R,-1.0,1.0,BX,M);CHKERRQ(ierr); } else { ierr = BVMult(R,-1.0,1.0,X,M);CHKERRQ(ierr); } ierr = DSRestoreMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); /* 8. Compute residual norms and update index set of active iterates */ ini = (ctx->lock)? nconv: 0; k = ini; countc = PETSC_TRUE; for (j=ini;jbs;j++) { i = locked+j; ierr = BVGetColumn(R,j,&v);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = BVRestoreColumn(R,j,&v);CHKERRQ(ierr); ierr = (*eps->converged)(eps,eps->eigr[i],eps->eigi[i],norm,&eps->errest[i],eps->convergedctx);CHKERRQ(ierr); if (countc) { if (eps->errest[i] < eps->tol) k++; else countc = PETSC_FALSE; } if (!countc && !eps->trackall) break; } nconv = k; eps->nconv = locked + nconv; if (its) { ierr = EPSMonitor(eps,eps->its+its,eps->nconv,eps->eigr,eps->eigi,eps->errest,locked+ctx->bs);CHKERRQ(ierr); } ierr = (*eps->stopping)(eps,eps->its+its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); if (eps->reason != EPS_CONVERGED_ITERATING || nconv >= ctx->bs-guard) { ierr = BVSetActiveColumns(eps->V,locked,eps->nconv);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,0,nconv);CHKERRQ(ierr); ierr = BVCopy(X,eps->V);CHKERRQ(ierr); } if (eps->reason != EPS_CONVERGED_ITERATING) { eps->its += its; break; } else if (nconv >= ctx->bs-guard) { eps->its += its; its = 0; } else its++; if (nconv >= ctx->bs-guard) { /* force hard locking of vectors and compute new R */ /* extend constraints */ ierr = BVSetActiveColumns(Y,nc+locked,nc+locked+nconv);CHKERRQ(ierr); ierr = BVCopy(X,Y);CHKERRQ(ierr); for (j=0;j0.0 && !breakdown) { ierr = BVScaleColumn(Y,nc+locked+j,1.0/norm);CHKERRQ(ierr); } else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Orthogonalization of constraints failed"); } ierr = BVSetActiveColumns(Y,0,nc+locked+nconv);CHKERRQ(ierr); /* shift work BV's */ for (j=nconv;jbs;j++) { ierr = BVCopyColumn(X,j,j-nconv);CHKERRQ(ierr); ierr = BVCopyColumn(R,j,j-nconv);CHKERRQ(ierr); ierr = BVCopyColumn(P,j,j-nconv);CHKERRQ(ierr); ierr = BVCopyColumn(AX,j,j-nconv);CHKERRQ(ierr); if (B) { ierr = BVCopyColumn(BX,j,j-nconv);CHKERRQ(ierr); } } /* set new initial vectors */ ierr = BVSetActiveColumns(eps->V,locked+ctx->bs,locked+ctx->bs+nconv);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,ctx->bs-nconv,ctx->bs);CHKERRQ(ierr); ierr = BVCopy(eps->V,X);CHKERRQ(ierr); for (j=ctx->bs-nconv;jbs;j++) { ierr = BVGetColumn(X,j,&v);CHKERRQ(ierr); ierr = BVOrthogonalizeVec(Y,v,NULL,&norm,&breakdown);CHKERRQ(ierr); if (norm>0.0 && !breakdown) { ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); } else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Orthogonalization of initial vector failed"); ierr = BVRestoreColumn(X,j,&v);CHKERRQ(ierr); } locked += nconv; nconv = 0; ierr = BVSetActiveColumns(X,nconv,ctx->bs);CHKERRQ(ierr); /* B-orthogonalize initial vectors */ ierr = BVOrthogonalize(X,NULL);CHKERRQ(ierr); ierr = BVSetActiveColumns(Z,nconv,ctx->bs);CHKERRQ(ierr); ierr = BVSetActiveColumns(AX,nconv,ctx->bs);CHKERRQ(ierr); ierr = BVCopy(X,Z);CHKERRQ(ierr); /* compute initial Ritz vectors */ nv = ctx->bs; ierr = BVMatMult(X,A,AX);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,0,0);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); ierr = BVMatProject(AX,NULL,X,M);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); ierr = DSSetIdentity(eps->ds,DS_MAT_B);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSSolve(eps->ds,eigr,NULL);CHKERRQ(ierr); ierr = DSSort(eps->ds,eigr,NULL,NULL,NULL,NULL);CHKERRQ(ierr); for (j=0;jncv) eps->eigr[locked+j] = eigr[j]; ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_X,&M);CHKERRQ(ierr); ierr = BVMultInPlace(X,M,0,nv);CHKERRQ(ierr); ierr = BVMultInPlace(AX,M,0,nv);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_X,&M);CHKERRQ(ierr); continue; /* skip the rest of the iteration */ } ini = (ctx->lock)? nconv: 0; if (ctx->lock) { ierr = BVSetActiveColumns(R,nconv,ctx->bs);CHKERRQ(ierr); ierr = BVSetActiveColumns(P,nconv,ctx->bs);CHKERRQ(ierr); ierr = BVSetActiveColumns(AX,nconv,ctx->bs);CHKERRQ(ierr); if (B) { ierr = BVSetActiveColumns(BX,nconv,ctx->bs);CHKERRQ(ierr); } } /* 9. Apply preconditioner to the residuals */ for (j=ini;jbs;j++) { ierr = BVGetColumn(R,j,&v);CHKERRQ(ierr); ierr = STMatSolve(eps->st,v,w);CHKERRQ(ierr); if (nc+locked>0) { ierr = BVOrthogonalizeVec(Y,w,NULL,&norm,&breakdown);CHKERRQ(ierr); if (norm>0.0 && !breakdown) { ierr = VecScale(w,1.0/norm);CHKERRQ(ierr); } else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Orthogonalization of preconditioned residual failed"); } ierr = VecCopy(w,v);CHKERRQ(ierr); ierr = BVRestoreColumn(R,j,&v);CHKERRQ(ierr); } /* 11. B-orthonormalize preconditioned residuals */ ierr = BVOrthogonalize(R,NULL);CHKERRQ(ierr); /* 13-16. B-orthonormalize conjugate directions */ if (its>1) { ierr = BVOrthogonalize(P,NULL);CHKERRQ(ierr); } /* 17-23. Compute symmetric Gram matrices */ ierr = BVSetActiveColumns(Z,0,ctx->bs);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,0,ctx->bs);CHKERRQ(ierr); ierr = BVCopy(X,Z);CHKERRQ(ierr); ierr = BVSetActiveColumns(Z,ctx->bs,2*ctx->bs-ini);CHKERRQ(ierr); ierr = BVCopy(R,Z);CHKERRQ(ierr); if (its>1) { ierr = BVSetActiveColumns(Z,2*ctx->bs-ini,3*ctx->bs-2*ini);CHKERRQ(ierr); ierr = BVCopy(P,Z);CHKERRQ(ierr); } if (its>1) nv = 3*ctx->bs-2*ini; else nv = 2*ctx->bs-ini; ierr = BVSetActiveColumns(Z,0,nv);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,0,0);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); ierr = BVMatProject(Z,A,Z,M);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_A,&M);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_B,&M);CHKERRQ(ierr); if (B) { ierr = BVMatProject(Z,B,Z,M);CHKERRQ(ierr); } else { ierr = BVDot(Z,Z,M);CHKERRQ(ierr); } ierr = DSRestoreMat(eps->ds,DS_MAT_B,&M);CHKERRQ(ierr); /* 24. Solve the generalized eigenvalue problem */ ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSSolve(eps->ds,eigr,NULL);CHKERRQ(ierr); ierr = DSSort(eps->ds,eigr,NULL,NULL,NULL,NULL);CHKERRQ(ierr); for (j=0;jncv) eps->eigr[locked+j] = eigr[j]; ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); /* 25-33. Compute Ritz vectors */ ierr = DSGetMat(eps->ds,DS_MAT_X,&M);CHKERRQ(ierr); ierr = BVSetActiveColumns(Z,ctx->bs,nv);CHKERRQ(ierr); if (ctx->lock) { ierr = BVSetActiveColumns(P,0,ctx->bs);CHKERRQ(ierr); } ierr = BVMult(P,1.0,0.0,Z,M);CHKERRQ(ierr); ierr = BVCopy(P,X);CHKERRQ(ierr); if (ctx->lock) { ierr = BVSetActiveColumns(P,nconv,ctx->bs);CHKERRQ(ierr); } ierr = BVSetActiveColumns(Z,0,ctx->bs);CHKERRQ(ierr); ierr = BVMult(X,1.0,1.0,Z,M);CHKERRQ(ierr); if (ctx->lock) { ierr = BVSetActiveColumns(X,nconv,ctx->bs);CHKERRQ(ierr); } ierr = BVMatMult(X,A,AX);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_X,&M);CHKERRQ(ierr); } ierr = PetscFree(eigr);CHKERRQ(ierr); ierr = BVDestroy(&Z);CHKERRQ(ierr); ierr = BVDestroy(&X);CHKERRQ(ierr); ierr = BVDestroy(&R);CHKERRQ(ierr); ierr = BVDestroy(&P);CHKERRQ(ierr); ierr = BVDestroy(&AX);CHKERRQ(ierr); if (B) { ierr = BVDestroy(&BX);CHKERRQ(ierr); } if (nc>0 || eps->nev>ctx->bs-guard) { ierr = BVDestroy(&Y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGSetBlockSize_LOBPCG" static PetscErrorCode EPSLOBPCGSetBlockSize_LOBPCG(EPS eps,PetscInt bs) { EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscFunctionBegin; ctx->bs = bs; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGSetBlockSize" /*@ EPSLOBPCGSetBlockSize - Sets the block size of the LOBPCG method. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - bs - the block size Options Database Key: . -eps_lobpcg_blocksize - Sets the block size Level: advanced .seealso: EPSLOBPCGGetBlockSize() @*/ PetscErrorCode EPSLOBPCGSetBlockSize(EPS eps,PetscInt bs) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,bs,2); ierr = PetscTryMethod(eps,"EPSLOBPCGSetBlockSize_C",(EPS,PetscInt),(eps,bs));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGGetBlockSize_LOBPCG" static PetscErrorCode EPSLOBPCGGetBlockSize_LOBPCG(EPS eps,PetscInt *bs) { EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscFunctionBegin; *bs = ctx->bs; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGGetBlockSize" /*@ EPSLOBPCGGetBlockSize - Gets the block size used in the LOBPCG method. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . bs - the block size Level: advanced .seealso: EPSLOBPCGSetBlockSize() @*/ PetscErrorCode EPSLOBPCGGetBlockSize(EPS eps,PetscInt *bs) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(bs,2); ierr = PetscUseMethod(eps,"EPSLOBPCGGetBlockSize_C",(EPS,PetscInt*),(eps,bs));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGSetRestart_LOBPCG" static PetscErrorCode EPSLOBPCGSetRestart_LOBPCG(EPS eps,PetscReal restart) { EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscFunctionBegin; if (restart==PETSC_DEFAULT) ctx->restart = 0.6; else { if (restart<0.1 || restart>1.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The restart argument must be in the range [0.1,1.0]"); ctx->restart = restart; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGSetRestart" /*@ EPSLOBPCGSetRestart - Sets the restart parameter for the LOBPCG method. The meaning of this parameter is the proportion of vectors within the current block iterate that must have converged in order to force a restart with hard locking. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - restart - the percentage of the block of vectors to force a restart Options Database Key: . -eps_lobpcg_restart - Sets the restart parameter Notes: Allowed values are in the range [0.1,1.0]. The default is 0.6. Level: advanced .seealso: EPSLOBPCGGetRestart() @*/ PetscErrorCode EPSLOBPCGSetRestart(EPS eps,PetscReal restart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveReal(eps,restart,2); ierr = PetscTryMethod(eps,"EPSLOBPCGSetRestart_C",(EPS,PetscReal),(eps,restart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGGetRestart_LOBPCG" static PetscErrorCode EPSLOBPCGGetRestart_LOBPCG(EPS eps,PetscReal *restart) { EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscFunctionBegin; *restart = ctx->restart; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGGetRestart" /*@ EPSLOBPCGGetRestart - Gets the restart parameter used in the LOBPCG method. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . restart - the restart parameter Level: advanced .seealso: EPSLOBPCGSetRestart() @*/ PetscErrorCode EPSLOBPCGGetRestart(EPS eps,PetscReal *restart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(restart,2); ierr = PetscUseMethod(eps,"EPSLOBPCGGetRestart_C",(EPS,PetscReal*),(eps,restart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGSetLocking_LOBPCG" static PetscErrorCode EPSLOBPCGSetLocking_LOBPCG(EPS eps,PetscBool lock) { EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscFunctionBegin; ctx->lock = lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGSetLocking" /*@ EPSLOBPCGSetLocking - Choose between locking and non-locking variants of the LOBPCG method. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - lock - true if the locking variant must be selected Options Database Key: . -eps_lobpcg_locking - Sets the locking flag Notes: This flag refers to soft locking (converged vectors within the current block iterate), since hard locking is always used (when nev is larger than the block size). Level: advanced .seealso: EPSLOBPCGGetLocking() @*/ PetscErrorCode EPSLOBPCGSetLocking(EPS eps,PetscBool lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,lock,2); ierr = PetscTryMethod(eps,"EPSLOBPCGSetLocking_C",(EPS,PetscBool),(eps,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGGetLocking_LOBPCG" static PetscErrorCode EPSLOBPCGGetLocking_LOBPCG(EPS eps,PetscBool *lock) { EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscFunctionBegin; *lock = ctx->lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLOBPCGGetLocking" /*@ EPSLOBPCGGetLocking - Gets the locking flag used in the LOBPCG method. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . lock - the locking flag Level: advanced .seealso: EPSLOBPCGSetLocking() @*/ PetscErrorCode EPSLOBPCGGetLocking(EPS eps,PetscBool *lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(lock,2); ierr = PetscUseMethod(eps,"EPSLOBPCGGetLocking_C",(EPS,PetscBool*),(eps,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_LOBPCG" PetscErrorCode EPSView_LOBPCG(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," LOBPCG: block size %D\n",ctx->bs);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," LOBPCG: restart parameter=%g (using %d guard vectors)\n",(double)ctx->restart,(int)((1.0-ctx->restart)*ctx->bs));CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," LOBPCG: soft locking %sactivated\n",ctx->lock?"":"de");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_LOBPCG" PetscErrorCode EPSSetFromOptions_LOBPCG(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; PetscBool lock,flg; PetscInt bs; PetscReal restart; KSP ksp; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS LOBPCG Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_lobpcg_blocksize","LOBPCG block size","EPSLOBPCGSetBlockSize",20,&bs,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSLOBPCGSetBlockSize(eps,bs);CHKERRQ(ierr); } ierr = PetscOptionsReal("-eps_lobpcg_restart","Percentage of the block of vectors to force a restart","EPSLOBPCGSetRestart",0.5,&restart,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSLOBPCGSetRestart(eps,restart);CHKERRQ(ierr); } ierr = PetscOptionsBool("-eps_lobpcg_locking","Choose between locking and non-locking variants","EPSLOBPCGSetLocking",PETSC_TRUE,&lock,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSLOBPCGSetLocking(eps,lock);CHKERRQ(ierr); } /* Set STPrecond as the default ST */ if (!((PetscObject)eps->st)->type_name) { ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); } /* Set the default options of the KSP */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_LOBPCG" PetscErrorCode EPSDestroy_LOBPCG(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetLocking_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_LOBPCG" PETSC_EXTERN PetscErrorCode EPSCreate_LOBPCG(EPS eps) { EPS_LOBPCG *lobpcg; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&lobpcg);CHKERRQ(ierr); eps->data = (void*)lobpcg; lobpcg->lock = PETSC_TRUE; eps->ops->setup = EPSSetUp_LOBPCG; eps->ops->solve = EPSSolve_LOBPCG; eps->ops->setfromoptions = EPSSetFromOptions_LOBPCG; eps->ops->destroy = EPSDestroy_LOBPCG; eps->ops->view = EPSView_LOBPCG; eps->ops->backtransform = EPSBackTransform_Default; ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); ierr = STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetBlockSize_C",EPSLOBPCGSetBlockSize_LOBPCG);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetBlockSize_C",EPSLOBPCGGetBlockSize_LOBPCG);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetRestart_C",EPSLOBPCGSetRestart_LOBPCG);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetRestart_C",EPSLOBPCGGetRestart_LOBPCG);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetLocking_C",EPSLOBPCGSetLocking_LOBPCG);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetLocking_C",EPSLOBPCGGetLocking_LOBPCG);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/cg/lobpcg/makefile.html0000644000175000017500000000467013107004621021176 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = lobpcg.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/cg/lobpcg/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/cg/lobpcg/lobpcg.c.html0000644000175000017500000017461513107004621021117 0ustar jromanjroman
Actual source code: lobpcg.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "lobpcg"

  5:    Method: Locally Optimal Block Preconditioned Conjugate Gradient

  7:    Algorithm:

  9:        LOBPCG with soft and hard locking. Follows the implementation
 10:        in BLOPEX [2].

 12:    References:

 14:        [1] A. V. Knyazev, "Toward the optimal preconditioned eigensolver:
 15:            locally optimal block preconditioned conjugate gradient method",
 16:            SIAM J. Sci. Comput. 23(2):517-541, 2001.

 18:        [2] A. V. Knyazev et al., "Block Locally Optimal Preconditioned
 19:            Eigenvalue Xolvers (BLOPEX) in Hypre and PETSc", SIAM J. Sci.
 20:            Comput. 29(5):2224-2239, 2007.

 22:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 23:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 24:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 26:    This file is part of SLEPc.

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

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

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

 42: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/

 44: typedef struct {
 45:   PetscInt  bs;        /* block size */
 46:   PetscBool lock;      /* soft locking active/inactive */
 47:   PetscReal restart;   /* restart parameter */
 48: } EPS_LOBPCG;

 52: PetscErrorCode EPSSetDimensions_LOBPCG(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)
 53: {
 54:   EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data;
 55:   PetscInt   k;

 58:   k = PetscMax(3*ctx->bs,((eps->nev-1)/ctx->bs+3)*ctx->bs);
 59:   if (*ncv) { /* ncv set */
 60:     if (*ncv<k) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv is not sufficiently large");
 61:   } else *ncv = k;
 62:   if (!*mpd) *mpd = 3*ctx->bs;
 63:   else if (*mpd!=3*ctx->bs) SETERRQ(PetscObjectComm((PetscObject)eps),1,"This solver does not allow a value of mpd different from 3*blocksize");
 64:   return(0);
 65: }

 69: PetscErrorCode EPSSetUp_LOBPCG(EPS eps)
 70: {
 72:   EPS_LOBPCG     *ctx = (EPS_LOBPCG*)eps->data;
 73:   PetscBool      precond,istrivial;

 76:   if (!eps->ishermitian || (eps->isgeneralized && !eps->ispositive)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"LOBPCG only works for Hermitian problems");
 77:   if (!ctx->bs) ctx->bs = PetscMin(16,eps->nev);
 78:   if (eps->n-eps->nds<5*ctx->bs) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The problem size is too small relative to the block size");
 79:   EPSSetDimensions_LOBPCG(eps,eps->nev,&eps->ncv,&eps->mpd);
 80:   if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv);
 81:   if (!eps->which) eps->which = EPS_SMALLEST_REAL;
 82:   if (eps->which!=EPS_SMALLEST_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
 83:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
 84:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }
 85:   RGIsTrivial(eps->rg,&istrivial);
 86:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");

 88:   if (!ctx->restart) ctx->restart = 0.9;

 90:   STSetUp(eps->st);
 91:   PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&precond);
 92:   if (!precond) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"LOBPCG only works with precond ST");

 94:   EPSAllocateSolution(eps,0);
 95:   EPS_SetInnerProduct(eps);
 96:   DSSetType(eps->ds,DSGHEP);
 97:   DSAllocate(eps->ds,eps->mpd);
 98:   EPSSetWorkVecs(eps,1);
 99:   return(0);
100: }

104: PetscErrorCode EPSSolve_LOBPCG(EPS eps)
105: {
107:   EPS_LOBPCG     *ctx = (EPS_LOBPCG*)eps->data;
108:   PetscInt       i,j,k,ld,nv,ini,kini,nmat,nc,nconv,locked,guard,its;
109:   PetscReal      norm;
110:   PetscScalar    *eigr;
111:   PetscBool      breakdown,countc;
112:   Mat            A,B,M;
113:   Vec            v,w=eps->work[0];
114:   BV             X,Y,Z,R,P,AX,BX;

117:   DSGetLeadingDimension(eps->ds,&ld);
118:   STGetNumMatrices(eps->st,&nmat);
119:   STGetOperators(eps->st,0,&A);
120:   if (nmat>1) { STGetOperators(eps->st,1,&B); }
121:   else B = NULL;

123:   guard = (PetscInt)((1.0-ctx->restart)*ctx->bs);  /* number of guard vectors */

125:   /* 1. Allocate memory */
126:   PetscCalloc1(3*ctx->bs,&eigr);
127:   BVDuplicateResize(eps->V,3*ctx->bs,&Z);
128:   BVDuplicateResize(eps->V,ctx->bs,&X);
129:   BVDuplicateResize(eps->V,ctx->bs,&R);
130:   BVDuplicateResize(eps->V,ctx->bs,&P);
131:   BVDuplicateResize(eps->V,ctx->bs,&AX);
132:   if (B) {
133:     BVDuplicateResize(eps->V,ctx->bs,&BX);
134:   }
135:   nc = eps->nds;
136:   if (nc>0 || eps->nev>ctx->bs-guard) {
137:     BVDuplicateResize(eps->V,nc+eps->nev,&Y);
138:   }
139:   if (nc>0) {
140:     for (j=0;j<nc;j++) {
141:       BVGetColumn(eps->V,-nc+j,&v);
142:       BVInsertVec(Y,j,v);
143:       BVRestoreColumn(eps->V,-nc+j,&v);
144:     }
145:     BVSetActiveColumns(Y,0,nc);
146:   }

148:   /* 2. Apply the constraints to the initial vectors */
149:   kini = eps->nini;
150:   while (kini<eps->ncv-ctx->bs) { /* Generate more initial vectors if necessary */
151:     BVSetRandomColumn(eps->V,kini);
152:     BVOrthogonalizeColumn(eps->V,kini,NULL,&norm,&breakdown);
153:     if (norm>0.0 && !breakdown) {
154:       BVScaleColumn(eps->V,kini,1.0/norm);
155:       kini++;
156:     }
157:   }
158:   nv = ctx->bs;
159:   BVSetActiveColumns(eps->V,0,nv);
160:   BVSetActiveColumns(Z,0,nv);
161:   BVCopy(eps->V,Z);
162:   BVCopy(Z,X);

164:   /* 3. B-orthogonalize initial vectors */

166:   /* 4. Compute initial Ritz vectors */
167:   BVMatMult(X,A,AX);
168:   DSSetDimensions(eps->ds,nv,0,0,0);
169:   DSGetMat(eps->ds,DS_MAT_A,&M);
170:   BVMatProject(AX,NULL,X,M);
171:   DSRestoreMat(eps->ds,DS_MAT_A,&M);
172:   DSSetIdentity(eps->ds,DS_MAT_B);
173:   DSSetState(eps->ds,DS_STATE_RAW);
174:   DSSolve(eps->ds,eps->eigr,NULL);
175:   DSSort(eps->ds,eps->eigr,NULL,NULL,NULL,NULL);
176:   DSVectors(eps->ds,DS_MAT_X,NULL,NULL);
177:   DSGetMat(eps->ds,DS_MAT_X,&M);
178:   BVMultInPlace(X,M,0,nv);
179:   BVMultInPlace(AX,M,0,nv);
180:   DSRestoreMat(eps->ds,DS_MAT_X,&M);

182:   /* 5. Initialize range of active iterates */
183:   locked = 0;  /* hard-locked vectors, the leading locked columns of V are eigenvectors */
184:   nconv  = 0;  /* number of converged eigenvalues in the current block */
185:   its    = 0;  /* iterations for the current block */

187:   /* 6. Main loop */
188:   while (eps->reason == EPS_CONVERGED_ITERATING) {

190:     if (ctx->lock) {
191:       BVSetActiveColumns(R,nconv,ctx->bs);
192:       BVSetActiveColumns(AX,nconv,ctx->bs);
193:       if (B) {
194:         BVSetActiveColumns(BX,nconv,ctx->bs);
195:       }
196:     }

198:     /* 7. Compute residuals */
199:     DSGetMat(eps->ds,DS_MAT_A,&M);
200:     BVCopy(AX,R);
201:     if (B) {
202:       BVMatMult(X,B,BX);
203:       BVMult(R,-1.0,1.0,BX,M);
204:     } else {
205:       BVMult(R,-1.0,1.0,X,M);
206:     }
207:     DSRestoreMat(eps->ds,DS_MAT_A,&M);

209:     /* 8. Compute residual norms and update index set of active iterates */
210:     ini = (ctx->lock)? nconv: 0;
211:     k = ini;
212:     countc = PETSC_TRUE;
213:     for (j=ini;j<ctx->bs;j++) {
214:       i = locked+j;
215:       BVGetColumn(R,j,&v);
216:       VecNorm(v,NORM_2,&norm);
217:       BVRestoreColumn(R,j,&v);
218:       (*eps->converged)(eps,eps->eigr[i],eps->eigi[i],norm,&eps->errest[i],eps->convergedctx);
219:       if (countc) {
220:         if (eps->errest[i] < eps->tol) k++;
221:         else countc = PETSC_FALSE;
222:       }
223:       if (!countc && !eps->trackall) break;
224:     }
225:     nconv = k;
226:     eps->nconv = locked + nconv;
227:     if (its) {
228:       EPSMonitor(eps,eps->its+its,eps->nconv,eps->eigr,eps->eigi,eps->errest,locked+ctx->bs);
229:     }
230:     (*eps->stopping)(eps,eps->its+its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);
231:     if (eps->reason != EPS_CONVERGED_ITERATING || nconv >= ctx->bs-guard) {
232:       BVSetActiveColumns(eps->V,locked,eps->nconv);
233:       BVSetActiveColumns(X,0,nconv);
234:       BVCopy(X,eps->V);
235:     }
236:     if (eps->reason != EPS_CONVERGED_ITERATING) {
237:       eps->its += its;
238:       break;
239:     } else if (nconv >= ctx->bs-guard) {
240:       eps->its += its;
241:       its = 0;
242:     } else its++;

244:     if (nconv >= ctx->bs-guard) {  /* force hard locking of vectors and compute new R */

246:       /* extend constraints */
247:       BVSetActiveColumns(Y,nc+locked,nc+locked+nconv);
248:       BVCopy(X,Y);
249:       for (j=0;j<nconv;j++) {
250:         BVOrthogonalizeColumn(Y,nc+locked+j,NULL,&norm,&breakdown);
251:         if (norm>0.0 && !breakdown) {
252:           BVScaleColumn(Y,nc+locked+j,1.0/norm);
253:         } else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Orthogonalization of constraints failed");
254:       }
255:       BVSetActiveColumns(Y,0,nc+locked+nconv);

257:       /* shift work BV's */
258:       for (j=nconv;j<ctx->bs;j++) {
259:         BVCopyColumn(X,j,j-nconv);
260:         BVCopyColumn(R,j,j-nconv);
261:         BVCopyColumn(P,j,j-nconv);
262:         BVCopyColumn(AX,j,j-nconv);
263:         if (B) {
264:           BVCopyColumn(BX,j,j-nconv);
265:         }
266:       }

268:       /* set new initial vectors */
269:       BVSetActiveColumns(eps->V,locked+ctx->bs,locked+ctx->bs+nconv);
270:       BVSetActiveColumns(X,ctx->bs-nconv,ctx->bs);
271:       BVCopy(eps->V,X);
272:       for (j=ctx->bs-nconv;j<ctx->bs;j++) {
273:         BVGetColumn(X,j,&v);
274:         BVOrthogonalizeVec(Y,v,NULL,&norm,&breakdown);
275:         if (norm>0.0 && !breakdown) {
276:           VecScale(v,1.0/norm);
277:         } else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Orthogonalization of initial vector failed");
278:         BVRestoreColumn(X,j,&v);
279:       }
280:       locked += nconv;
281:       nconv = 0;
282:       BVSetActiveColumns(X,nconv,ctx->bs);

284:       /* B-orthogonalize initial vectors */
285:       BVOrthogonalize(X,NULL);
286:       BVSetActiveColumns(Z,nconv,ctx->bs);
287:       BVSetActiveColumns(AX,nconv,ctx->bs);
288:       BVCopy(X,Z);

290:       /* compute initial Ritz vectors */
291:       nv = ctx->bs;
292:       BVMatMult(X,A,AX);
293:       DSSetDimensions(eps->ds,nv,0,0,0);
294:       DSGetMat(eps->ds,DS_MAT_A,&M);
295:       BVMatProject(AX,NULL,X,M);
296:       DSRestoreMat(eps->ds,DS_MAT_A,&M);
297:       DSSetIdentity(eps->ds,DS_MAT_B);
298:       DSSetState(eps->ds,DS_STATE_RAW);
299:       DSSolve(eps->ds,eigr,NULL);
300:       DSSort(eps->ds,eigr,NULL,NULL,NULL,NULL);
301:       for (j=0;j<nv;j++) if (locked+j<eps->ncv) eps->eigr[locked+j] = eigr[j];
302:       DSVectors(eps->ds,DS_MAT_X,NULL,NULL);
303:       DSGetMat(eps->ds,DS_MAT_X,&M);
304:       BVMultInPlace(X,M,0,nv);
305:       BVMultInPlace(AX,M,0,nv);
306:       DSRestoreMat(eps->ds,DS_MAT_X,&M);

308:       continue;   /* skip the rest of the iteration */
309:     }

311:     ini = (ctx->lock)? nconv: 0;
312:     if (ctx->lock) {
313:       BVSetActiveColumns(R,nconv,ctx->bs);
314:       BVSetActiveColumns(P,nconv,ctx->bs);
315:       BVSetActiveColumns(AX,nconv,ctx->bs);
316:       if (B) {
317:         BVSetActiveColumns(BX,nconv,ctx->bs);
318:       }
319:     }

321:     /* 9. Apply preconditioner to the residuals */
322:     for (j=ini;j<ctx->bs;j++) {
323:       BVGetColumn(R,j,&v);
324:       STMatSolve(eps->st,v,w);
325:       if (nc+locked>0) {
326:         BVOrthogonalizeVec(Y,w,NULL,&norm,&breakdown);
327:         if (norm>0.0 && !breakdown) {
328:           VecScale(w,1.0/norm);
329:         } else SETERRQ(PetscObjectComm((PetscObject)eps),1,"Orthogonalization of preconditioned residual failed");
330:       }
331:       VecCopy(w,v);
332:       BVRestoreColumn(R,j,&v);
333:     }

335:     /* 11. B-orthonormalize preconditioned residuals */
336:     BVOrthogonalize(R,NULL);

338:     /* 13-16. B-orthonormalize conjugate directions */
339:     if (its>1) {
340:       BVOrthogonalize(P,NULL);
341:     }

343:     /* 17-23. Compute symmetric Gram matrices */
344:     BVSetActiveColumns(Z,0,ctx->bs);
345:     BVSetActiveColumns(X,0,ctx->bs);
346:     BVCopy(X,Z);
347:     BVSetActiveColumns(Z,ctx->bs,2*ctx->bs-ini);
348:     BVCopy(R,Z);
349:     if (its>1) {
350:       BVSetActiveColumns(Z,2*ctx->bs-ini,3*ctx->bs-2*ini);
351:       BVCopy(P,Z);
352:     }

354:     if (its>1) nv = 3*ctx->bs-2*ini;
355:     else nv = 2*ctx->bs-ini;

357:     BVSetActiveColumns(Z,0,nv);
358:     DSSetDimensions(eps->ds,nv,0,0,0);
359:     DSGetMat(eps->ds,DS_MAT_A,&M);
360:     BVMatProject(Z,A,Z,M);
361:     DSRestoreMat(eps->ds,DS_MAT_A,&M);
362:     DSGetMat(eps->ds,DS_MAT_B,&M);
363:     if (B) {
364:       BVMatProject(Z,B,Z,M);
365:     } else {
366:       BVDot(Z,Z,M);
367:     }
368:     DSRestoreMat(eps->ds,DS_MAT_B,&M);
369:     
370:     /* 24. Solve the generalized eigenvalue problem */
371:     DSSetState(eps->ds,DS_STATE_RAW);
372:     DSSolve(eps->ds,eigr,NULL);
373:     DSSort(eps->ds,eigr,NULL,NULL,NULL,NULL);
374:     for (j=0;j<nv;j++) if (locked+j<eps->ncv) eps->eigr[locked+j] = eigr[j];
375:     DSVectors(eps->ds,DS_MAT_X,NULL,NULL);
376:     
377:     /* 25-33. Compute Ritz vectors */
378:     DSGetMat(eps->ds,DS_MAT_X,&M);
379:     BVSetActiveColumns(Z,ctx->bs,nv);
380:     if (ctx->lock) {
381:       BVSetActiveColumns(P,0,ctx->bs);
382:     }
383:     BVMult(P,1.0,0.0,Z,M);
384:     BVCopy(P,X);
385:     if (ctx->lock) {
386:       BVSetActiveColumns(P,nconv,ctx->bs);
387:     }
388:     BVSetActiveColumns(Z,0,ctx->bs);
389:     BVMult(X,1.0,1.0,Z,M);
390:     if (ctx->lock) {
391:       BVSetActiveColumns(X,nconv,ctx->bs);
392:     }
393:     BVMatMult(X,A,AX);
394:     DSRestoreMat(eps->ds,DS_MAT_X,&M);
395:   }

397:   PetscFree(eigr);
398:   BVDestroy(&Z);
399:   BVDestroy(&X);
400:   BVDestroy(&R);
401:   BVDestroy(&P);
402:   BVDestroy(&AX);
403:   if (B) {
404:     BVDestroy(&BX);
405:   }
406:   if (nc>0 || eps->nev>ctx->bs-guard) {
407:     BVDestroy(&Y);
408:   }
409:   return(0);
410: }

414: static PetscErrorCode EPSLOBPCGSetBlockSize_LOBPCG(EPS eps,PetscInt bs)
415: {
416:   EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data;

419:   ctx->bs = bs;
420:   return(0);
421: }

425: /*@
426:    EPSLOBPCGSetBlockSize - Sets the block size of the LOBPCG method.

428:    Logically Collective on EPS

430:    Input Parameters:
431: +  eps - the eigenproblem solver context
432: -  bs  - the block size

434:    Options Database Key:
435: .  -eps_lobpcg_blocksize - Sets the block size

437:    Level: advanced

439: .seealso: EPSLOBPCGGetBlockSize()
440: @*/
441: PetscErrorCode EPSLOBPCGSetBlockSize(EPS eps,PetscInt bs)
442: {

448:   PetscTryMethod(eps,"EPSLOBPCGSetBlockSize_C",(EPS,PetscInt),(eps,bs));
449:   return(0);
450: }

454: static PetscErrorCode EPSLOBPCGGetBlockSize_LOBPCG(EPS eps,PetscInt *bs)
455: {
456:   EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data;

459:   *bs = ctx->bs;
460:   return(0);
461: }

465: /*@
466:    EPSLOBPCGGetBlockSize - Gets the block size used in the LOBPCG method.

468:    Not Collective

470:    Input Parameter:
471: .  eps - the eigenproblem solver context

473:    Output Parameter:
474: .  bs - the block size

476:    Level: advanced

478: .seealso: EPSLOBPCGSetBlockSize()
479: @*/
480: PetscErrorCode EPSLOBPCGGetBlockSize(EPS eps,PetscInt *bs)
481: {

487:   PetscUseMethod(eps,"EPSLOBPCGGetBlockSize_C",(EPS,PetscInt*),(eps,bs));
488:   return(0);
489: }

493: static PetscErrorCode EPSLOBPCGSetRestart_LOBPCG(EPS eps,PetscReal restart)
494: {
495:   EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data;

498:   if (restart==PETSC_DEFAULT) ctx->restart = 0.6;
499:   else {
500:     if (restart<0.1 || restart>1.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The restart argument must be in the range [0.1,1.0]");
501:     ctx->restart = restart;
502:   }
503:   return(0);
504: }

508: /*@
509:    EPSLOBPCGSetRestart - Sets the restart parameter for the LOBPCG method.
510:    The meaning of this parameter is the proportion of vectors within the
511:    current block iterate that must have converged in order to force a
512:    restart with hard locking.

514:    Logically Collective on EPS

516:    Input Parameters:
517: +  eps - the eigenproblem solver context
518: -  restart - the percentage of the block of vectors to force a restart

520:    Options Database Key:
521: .  -eps_lobpcg_restart - Sets the restart parameter

523:    Notes:
524:    Allowed values are in the range [0.1,1.0]. The default is 0.6.

526:    Level: advanced

528: .seealso: EPSLOBPCGGetRestart()
529: @*/
530: PetscErrorCode EPSLOBPCGSetRestart(EPS eps,PetscReal restart)
531: {

537:   PetscTryMethod(eps,"EPSLOBPCGSetRestart_C",(EPS,PetscReal),(eps,restart));
538:   return(0);
539: }

543: static PetscErrorCode EPSLOBPCGGetRestart_LOBPCG(EPS eps,PetscReal *restart)
544: {
545:   EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data;

548:   *restart = ctx->restart;
549:   return(0);
550: }

554: /*@
555:    EPSLOBPCGGetRestart - Gets the restart parameter used in the LOBPCG method.

557:    Not Collective

559:    Input Parameter:
560: .  eps - the eigenproblem solver context

562:    Output Parameter:
563: .  restart - the restart parameter

565:    Level: advanced

567: .seealso: EPSLOBPCGSetRestart()
568: @*/
569: PetscErrorCode EPSLOBPCGGetRestart(EPS eps,PetscReal *restart)
570: {

576:   PetscUseMethod(eps,"EPSLOBPCGGetRestart_C",(EPS,PetscReal*),(eps,restart));
577:   return(0);
578: }

582: static PetscErrorCode EPSLOBPCGSetLocking_LOBPCG(EPS eps,PetscBool lock)
583: {
584:   EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data;

587:   ctx->lock = lock;
588:   return(0);
589: }

593: /*@
594:    EPSLOBPCGSetLocking - Choose between locking and non-locking variants of
595:    the LOBPCG method.

597:    Logically Collective on EPS

599:    Input Parameters:
600: +  eps  - the eigenproblem solver context
601: -  lock - true if the locking variant must be selected

603:    Options Database Key:
604: .  -eps_lobpcg_locking - Sets the locking flag

606:    Notes:
607:    This flag refers to soft locking (converged vectors within the current
608:    block iterate), since hard locking is always used (when nev is larger
609:    than the block size).

611:    Level: advanced

613: .seealso: EPSLOBPCGGetLocking()
614: @*/
615: PetscErrorCode EPSLOBPCGSetLocking(EPS eps,PetscBool lock)
616: {

622:   PetscTryMethod(eps,"EPSLOBPCGSetLocking_C",(EPS,PetscBool),(eps,lock));
623:   return(0);
624: }

628: static PetscErrorCode EPSLOBPCGGetLocking_LOBPCG(EPS eps,PetscBool *lock)
629: {
630:   EPS_LOBPCG *ctx = (EPS_LOBPCG*)eps->data;

633:   *lock = ctx->lock;
634:   return(0);
635: }

639: /*@
640:    EPSLOBPCGGetLocking - Gets the locking flag used in the LOBPCG method.

642:    Not Collective

644:    Input Parameter:
645: .  eps - the eigenproblem solver context

647:    Output Parameter:
648: .  lock - the locking flag

650:    Level: advanced

652: .seealso: EPSLOBPCGSetLocking()
653: @*/
654: PetscErrorCode EPSLOBPCGGetLocking(EPS eps,PetscBool *lock)
655: {

661:   PetscUseMethod(eps,"EPSLOBPCGGetLocking_C",(EPS,PetscBool*),(eps,lock));
662:   return(0);
663: }

667: PetscErrorCode EPSView_LOBPCG(EPS eps,PetscViewer viewer)
668: {
670:   EPS_LOBPCG     *ctx = (EPS_LOBPCG*)eps->data;
671:   PetscBool      isascii;

674:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
675:   if (isascii) {
676:     PetscViewerASCIIPrintf(viewer,"  LOBPCG: block size %D\n",ctx->bs);
677:     PetscViewerASCIIPrintf(viewer,"  LOBPCG: restart parameter=%g (using %d guard vectors)\n",(double)ctx->restart,(int)((1.0-ctx->restart)*ctx->bs));
678:     PetscViewerASCIIPrintf(viewer,"  LOBPCG: soft locking %sactivated\n",ctx->lock?"":"de");
679:   }
680:   return(0);
681: }

685: PetscErrorCode EPSSetFromOptions_LOBPCG(PetscOptionItems *PetscOptionsObject,EPS eps)
686: {
688:   PetscBool      lock,flg;
689:   PetscInt       bs;
690:   PetscReal      restart;
691:   KSP            ksp;

694:   PetscOptionsHead(PetscOptionsObject,"EPS LOBPCG Options");
695:   PetscOptionsInt("-eps_lobpcg_blocksize","LOBPCG block size","EPSLOBPCGSetBlockSize",20,&bs,&flg);
696:   if (flg) {
697:     EPSLOBPCGSetBlockSize(eps,bs);
698:   }
699:   PetscOptionsReal("-eps_lobpcg_restart","Percentage of the block of vectors to force a restart","EPSLOBPCGSetRestart",0.5,&restart,&flg);
700:   if (flg) {
701:     EPSLOBPCGSetRestart(eps,restart);
702:   }
703:   PetscOptionsBool("-eps_lobpcg_locking","Choose between locking and non-locking variants","EPSLOBPCGSetLocking",PETSC_TRUE,&lock,&flg);
704:   if (flg) {
705:     EPSLOBPCGSetLocking(eps,lock);
706:   }

708:   /* Set STPrecond as the default ST */
709:   if (!((PetscObject)eps->st)->type_name) {
710:     STSetType(eps->st,STPRECOND);
711:   }

713:   /* Set the default options of the KSP */
714:   STGetKSP(eps->st,&ksp);
715:   if (!((PetscObject)ksp)->type_name) {
716:     KSPSetType(ksp,KSPPREONLY);
717:   }
718:   PetscOptionsTail();
719:   return(0);
720: }

724: PetscErrorCode EPSDestroy_LOBPCG(EPS eps)
725: {

729:   PetscFree(eps->data);
730:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetBlockSize_C",NULL);
731:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetBlockSize_C",NULL);
732:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetRestart_C",NULL);
733:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetRestart_C",NULL);
734:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetLocking_C",NULL);
735:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetLocking_C",NULL);
736:   return(0);
737: }

741: PETSC_EXTERN PetscErrorCode EPSCreate_LOBPCG(EPS eps)
742: {
743:   EPS_LOBPCG     *lobpcg;

747:   PetscNewLog(eps,&lobpcg);
748:   eps->data = (void*)lobpcg;
749:   lobpcg->lock = PETSC_TRUE;

751:   eps->ops->setup          = EPSSetUp_LOBPCG;
752:   eps->ops->solve          = EPSSolve_LOBPCG;
753:   eps->ops->setfromoptions = EPSSetFromOptions_LOBPCG;
754:   eps->ops->destroy        = EPSDestroy_LOBPCG;
755:   eps->ops->view           = EPSView_LOBPCG;
756:   eps->ops->backtransform  = EPSBackTransform_Default;
757:   STSetType(eps->st,STPRECOND);
758:   STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);
759:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetBlockSize_C",EPSLOBPCGSetBlockSize_LOBPCG);
760:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetBlockSize_C",EPSLOBPCGGetBlockSize_LOBPCG);
761:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetRestart_C",EPSLOBPCGSetRestart_LOBPCG);
762:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetRestart_C",EPSLOBPCGGetRestart_LOBPCG);
763:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGSetLocking_C",EPSLOBPCGSetLocking_LOBPCG);
764:   PetscObjectComposeFunction((PetscObject)eps,"EPSLOBPCGGetLocking_C",EPSLOBPCGGetLocking_LOBPCG);
765:   return(0);
766: }

slepc-3.7.4/src/eps/impls/cg/lobpcg/index.html0000644000175000017500000000260613107004621020525 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

lobpcg.c
makefile
slepc-3.7.4/src/eps/impls/cg/lobpcg/ftn-auto/0000755000175000017500000000000013107004621020261 5ustar jromanjromanslepc-3.7.4/src/eps/impls/cg/lobpcg/ftn-auto/makefile0000644000175000017500000000036413107004621021764 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = lobpcgf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/cg/lobpcg/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/cg/lobpcg/ftn-auto/lobpcgf.c0000644000175000017500000000575713107004621022057 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* lobpcg.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslobpcgsetblocksize_ EPSLOBPCGSETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslobpcgsetblocksize_ epslobpcgsetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslobpcggetblocksize_ EPSLOBPCGGETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslobpcggetblocksize_ epslobpcggetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslobpcgsetrestart_ EPSLOBPCGSETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslobpcgsetrestart_ epslobpcgsetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslobpcggetrestart_ EPSLOBPCGGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslobpcggetrestart_ epslobpcggetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslobpcgsetlocking_ EPSLOBPCGSETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslobpcgsetlocking_ epslobpcgsetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslobpcggetlocking_ EPSLOBPCGGETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslobpcggetlocking_ epslobpcggetlocking #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epslobpcgsetblocksize_(EPS eps,PetscInt *bs, int *__ierr ){ *__ierr = EPSLOBPCGSetBlockSize( (EPS)PetscToPointer((eps) ),*bs); } PETSC_EXTERN void PETSC_STDCALL epslobpcggetblocksize_(EPS eps,PetscInt *bs, int *__ierr ){ *__ierr = EPSLOBPCGGetBlockSize( (EPS)PetscToPointer((eps) ),bs); } PETSC_EXTERN void PETSC_STDCALL epslobpcgsetrestart_(EPS eps,PetscReal *restart, int *__ierr ){ *__ierr = EPSLOBPCGSetRestart( (EPS)PetscToPointer((eps) ),*restart); } PETSC_EXTERN void PETSC_STDCALL epslobpcggetrestart_(EPS eps,PetscReal *restart, int *__ierr ){ *__ierr = EPSLOBPCGGetRestart( (EPS)PetscToPointer((eps) ),restart); } PETSC_EXTERN void PETSC_STDCALL epslobpcgsetlocking_(EPS eps,PetscBool *lock, int *__ierr ){ *__ierr = EPSLOBPCGSetLocking( (EPS)PetscToPointer((eps) ),*lock); } PETSC_EXTERN void PETSC_STDCALL epslobpcggetlocking_(EPS eps,PetscBool *lock, int *__ierr ){ *__ierr = EPSLOBPCGGetLocking( (EPS)PetscToPointer((eps) ),lock); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/cg/rqcg/0000755000175000017500000000000013107004621016212 5ustar jromanjromanslepc-3.7.4/src/eps/impls/cg/rqcg/makefile0000644000175000017500000000215413107004621017714 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = rqcg.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/cg/rqcg/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/cg/rqcg/makefile.html0000644000175000017500000000466013107004621020663 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = rqcg.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/cg/rqcg/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/cg/rqcg/rqcg.c.html0000644000175000017500000011053713107004621020264 0ustar jromanjroman
Actual source code: rqcg.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "rqcg"

  5:    Method: Rayleigh Quotient Conjugate Gradient

  7:    Algorithm:

  9:        Conjugate Gradient minimization of the Rayleigh quotient with
 10:        periodic Rayleigh-Ritz acceleration.

 12:    References:

 14:        [1] L. Bergamaschi et al., "Parallel preconditioned conjugate gradient
 15:            optimization of the Rayleigh quotient for the solution of sparse
 16:            eigenproblems", Appl. Math. Comput. 175(2):1694-1715, 2006.

 18:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 20:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 22:    This file is part of SLEPc.

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

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

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

 38: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/

 40: PetscErrorCode EPSSolve_RQCG(EPS);

 42: typedef struct {
 43:   PetscInt nrest;
 44:   BV       AV,W,P,G;
 45: } EPS_RQCG;

 49: PetscErrorCode EPSSetUp_RQCG(EPS eps)
 50: {
 52:   PetscBool      precond;
 53:   PetscInt       nmat;
 54:   EPS_RQCG       *ctx = (EPS_RQCG*)eps->data;

 57:   if (!eps->ishermitian || (eps->isgeneralized && !eps->ispositive)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"RQCG only works for Hermitian problems");
 58:   EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);
 59:   if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv);
 60:   if (!eps->which) eps->which = EPS_SMALLEST_REAL;
 61:   if (eps->which!=EPS_SMALLEST_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
 62:   if (!eps->extraction) {
 63:     EPSSetExtraction(eps,EPS_RITZ);
 64:   } else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
 65:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
 66:   /* Set STPrecond as the default ST */
 67:   if (!((PetscObject)eps->st)->type_name) {
 68:     STSetType(eps->st,STPRECOND);
 69:   }
 70:   PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&precond);
 71:   if (!precond) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"RQCG only works with precond ST");

 73:   if (!ctx->nrest) ctx->nrest = 20;

 75:   EPSAllocateSolution(eps,0);
 76:   EPS_SetInnerProduct(eps);
 77:   BVDuplicateResize(eps->V,eps->mpd,&ctx->AV);
 78:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->AV);
 79:   STGetNumMatrices(eps->st,&nmat);
 80:   if (nmat>1) {
 81:     BVDuplicate(ctx->AV,&ctx->W);
 82:     PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->W);
 83:   }
 84:   BVDuplicate(ctx->AV,&ctx->P);
 85:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->P);
 86:   BVDuplicate(ctx->AV,&ctx->G);
 87:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->G);
 88:   DSSetType(eps->ds,DSHEP);
 89:   DSAllocate(eps->ds,eps->ncv);
 90:   EPSSetWorkVecs(eps,1);
 91:   return(0);
 92: }

 96: /*
 97:    ExtractSubmatrix - Returns B = A(k+1:end,k+1:end).
 98: */
 99: static PetscErrorCode ExtractSubmatrix(Mat A,PetscInt k,Mat *B)
100: {
102:   PetscInt       j,m,n;
103:   PetscScalar    *pA,*pB;

106:   MatGetSize(A,&m,&n);
107:   MatCreateSeqDense(PETSC_COMM_SELF,m-k,n-k,NULL,B);
108:   MatDenseGetArray(A,&pA);
109:   MatDenseGetArray(*B,&pB);
110:   for (j=k;j<n;j++) {
111:     PetscMemcpy(pB+(j-k)*(m-k),pA+j*m+k,(m-k)*sizeof(PetscScalar));
112:   }
113:   MatDenseRestoreArray(A,&pA);
114:   MatDenseRestoreArray(*B,&pB);
115:   return(0);
116: }

120: PetscErrorCode EPSSolve_RQCG(EPS eps)
121: {
123:   EPS_RQCG       *ctx = (EPS_RQCG*)eps->data;
124:   PetscInt       i,j,k,ld,nv,ncv = eps->ncv,kini,nmat;
125:   PetscScalar    *C,*gamma,g,pap,pbp,pbx,pax,nu,mu,alpha,beta;
126:   PetscReal      resnorm,norm,a,b,c,disc,t;
127:   PetscBool      reset,breakdown;
128:   Mat            A,B,Q,Q1;
129:   Vec            v,av,bv,p,w=eps->work[0];

132:   DSGetLeadingDimension(eps->ds,&ld);
133:   STGetNumMatrices(eps->st,&nmat);
134:   STGetOperators(eps->st,0,&A);
135:   if (nmat>1) { STGetOperators(eps->st,1,&B); }
136:   else B = NULL;
137:   PetscMalloc1(eps->mpd,&gamma);

139:   kini = eps->nini;
140:   while (eps->reason == EPS_CONVERGED_ITERATING) {
141:     eps->its++;
142:     nv = PetscMin(eps->nconv+eps->mpd,ncv);
143:     DSSetDimensions(eps->ds,nv,0,eps->nconv,0);
144:     /* Generate more initial vectors if necessary */
145:     while (kini<nv) {
146:       BVSetRandomColumn(eps->V,kini);
147:       BVOrthogonalizeColumn(eps->V,kini,NULL,&norm,&breakdown);
148:       if (norm>0.0 && !breakdown) {
149:         BVScaleColumn(eps->V,kini,1.0/norm);
150:         kini++;
151:       }
152:     }
153:     reset = (eps->its>1 && (eps->its-1)%ctx->nrest==0)? PETSC_TRUE: PETSC_FALSE;

155:     if (reset) {
156:       /* Prevent BVDotVec below to use B-product, restored a the end */
157:       BVSetMatrix(eps->V,NULL,PETSC_FALSE);

159:       /* Compute Rayleigh quotient */
160:       BVSetActiveColumns(eps->V,eps->nconv,nv);
161:       BVSetActiveColumns(ctx->AV,0,nv-eps->nconv);
162:       BVMatMult(eps->V,A,ctx->AV);
163:       DSGetArray(eps->ds,DS_MAT_A,&C);
164:       for (i=eps->nconv;i<nv;i++) {
165:         BVSetActiveColumns(eps->V,eps->nconv,i+1);
166:         BVGetColumn(ctx->AV,i-eps->nconv,&av);
167:         BVDotVec(eps->V,av,C+eps->nconv+i*ld);
168:         BVRestoreColumn(ctx->AV,i-eps->nconv,&av);
169:         for (j=eps->nconv;j<i-1;j++) C[i+j*ld] = C[j+i*ld];
170:       }
171:       DSRestoreArray(eps->ds,DS_MAT_A,&C);
172:       DSSetState(eps->ds,DS_STATE_RAW);

174:       /* Solve projected problem */
175:       DSSolve(eps->ds,eps->eigr,eps->eigi);
176:       DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);

178:       /* Update vectors V(:,idx) = V * Y(:,idx) */
179:       DSGetMat(eps->ds,DS_MAT_Q,&Q);
180:       BVMultInPlace(eps->V,Q,eps->nconv,nv);
181:       ExtractSubmatrix(Q,eps->nconv,&Q1);
182:       BVMultInPlace(ctx->AV,Q1,0,nv-eps->nconv);
183:       MatDestroy(&Q);
184:       MatDestroy(&Q1);
185:       if (B) { BVSetMatrix(eps->V,B,PETSC_FALSE); }
186:     } else {
187:       /* No need to do Rayleigh-Ritz, just take diag(V'*A*V) */
188:       for (i=eps->nconv;i<nv;i++) {
189:         BVGetColumn(eps->V,i,&v);
190:         BVGetColumn(ctx->AV,i-eps->nconv,&av);
191:         MatMult(A,v,av);
192:         VecDot(av,v,eps->eigr+i);
193:         BVRestoreColumn(eps->V,i,&v);
194:         BVRestoreColumn(ctx->AV,i-eps->nconv,&av);
195:       }
196:     }

198:     /* Compute gradient and check convergence */
199:     k = -1;
200:     for (i=eps->nconv;i<nv;i++) {
201:       BVGetColumn(eps->V,i,&v);
202:       BVGetColumn(ctx->AV,i-eps->nconv,&av);
203:       BVGetColumn(ctx->G,i-eps->nconv,&p);
204:       if (B) {
205:         BVGetColumn(ctx->W,i-eps->nconv,&bv);
206:         MatMult(B,v,bv);
207:         VecWAXPY(p,-eps->eigr[i],bv,av);
208:         BVRestoreColumn(ctx->W,i-eps->nconv,&bv);
209:       } else {
210:         VecWAXPY(p,-eps->eigr[i],v,av);
211:       }
212:       BVRestoreColumn(eps->V,i,&v);
213:       BVRestoreColumn(ctx->AV,i-eps->nconv,&av);
214:       VecNorm(p,NORM_2,&resnorm);
215:       BVRestoreColumn(ctx->G,i-eps->nconv,&p);
216:       (*eps->converged)(eps,eps->eigr[i],0.0,resnorm,&eps->errest[i],eps->convergedctx);
217:       if (k==-1 && eps->errest[i] >= eps->tol) k = i;
218:     }
219:     if (k==-1) k = nv;
220:     (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);

222:     /* The next lines are necessary to avoid DS zeroing eigr */
223:     DSGetArray(eps->ds,DS_MAT_A,&C);
224:     for (i=eps->nconv;i<k;i++) C[i+i*ld] = eps->eigr[i];
225:     DSRestoreArray(eps->ds,DS_MAT_A,&C);

227:     if (eps->reason == EPS_CONVERGED_ITERATING) {

229:       /* Search direction */
230:       for (i=0;i<nv-eps->nconv;i++) {
231:         BVGetColumn(ctx->G,i,&v);
232:         STMatSolve(eps->st,v,w);
233:         VecDot(v,w,&g);
234:         BVRestoreColumn(ctx->G,i,&v);
235:         beta = (!reset && eps->its>1)? g/gamma[i]: 0.0;
236:         gamma[i] = g;
237:         BVGetColumn(ctx->P,i,&v);
238:         VecAXPBY(v,1.0,beta,w);
239:         if (i+eps->nconv>0) {
240:           BVSetActiveColumns(eps->V,0,i+eps->nconv);
241:           BVOrthogonalizeVec(eps->V,v,NULL,NULL,NULL);
242:         }
243:         BVRestoreColumn(ctx->P,i,&v);
244:       }

246:       /* Minimization problem */
247:       for (i=eps->nconv;i<nv;i++) {
248:         BVGetColumn(eps->V,i,&v);
249:         BVGetColumn(ctx->AV,i-eps->nconv,&av);
250:         BVGetColumn(ctx->P,i-eps->nconv,&p);
251:         VecDot(v,av,&nu);
252:         VecDot(p,av,&pax);
253:         MatMult(A,p,w);
254:         VecDot(p,w,&pap);
255:         if (B) {
256:           BVGetColumn(ctx->W,i-eps->nconv,&bv);
257:           VecDot(v,bv,&mu);
258:           VecDot(p,bv,&pbx);
259:           BVRestoreColumn(ctx->W,i-eps->nconv,&bv);
260:           MatMult(B,p,w);
261:           VecDot(p,w,&pbp);
262:         } else {
263:           VecDot(v,v,&mu);
264:           VecDot(p,v,&pbx);
265:           VecDot(p,p,&pbp);
266:         }
267:         BVRestoreColumn(ctx->AV,i-eps->nconv,&av);
268:         a = PetscRealPart(pap*pbx-pax*pbp);
269:         b = PetscRealPart(nu*pbp-mu*pap);
270:         c = PetscRealPart(mu*pax-nu*pbx);
271:         t = PetscMax(PetscMax(PetscAbsReal(a),PetscAbsReal(b)),PetscAbsReal(c));
272:         if (t!=0.0) { a /= t; b /= t; c /= t; }
273:         disc = PetscSqrtReal(PetscAbsReal(b*b-4.0*a*c));
274:         if (b>=0.0 && a!=0.0) alpha = (b+disc)/(2.0*a);
275:         else if (b!=disc) alpha = 2.0*c/(b-disc);
276:         else alpha = 0;
277:         /* Next iterate */
278:         if (alpha!=0.0) {
279:           VecAXPY(v,alpha,p);
280:         }
281:         BVRestoreColumn(eps->V,i,&v);
282:         BVRestoreColumn(ctx->P,i-eps->nconv,&p);
283:         BVOrthogonalizeColumn(eps->V,i,NULL,&norm,&breakdown);
284:         if (!breakdown && norm!=0.0) {
285:           BVScaleColumn(eps->V,i,1.0/norm);
286:         }
287:       }
288:     }

290:     EPSMonitor(eps,eps->its,k,eps->eigr,eps->eigi,eps->errest,nv);
291:     eps->nconv = k;
292:   }

294:   PetscFree(gamma);
295:   return(0);
296: }

300: static PetscErrorCode EPSRQCGSetReset_RQCG(EPS eps,PetscInt nrest)
301: {
302:   EPS_RQCG *ctx = (EPS_RQCG*)eps->data;

305:   ctx->nrest = nrest;
306:   return(0);
307: }

311: /*@
312:    EPSRQCGSetReset - Sets the reset parameter of the RQCG iteration. Every
313:    nrest iterations, the solver performs a Rayleigh-Ritz projection step.

315:    Logically Collective on EPS

317:    Input Parameters:
318: +  eps - the eigenproblem solver context
319: -  nrest - the number of iterations between resets

321:    Options Database Key:
322: .  -eps_rqcg_reset - Sets the reset parameter

324:    Level: advanced

326: .seealso: EPSRQCGGetReset()
327: @*/
328: PetscErrorCode EPSRQCGSetReset(EPS eps,PetscInt nrest)
329: {

335:   PetscTryMethod(eps,"EPSRQCGSetReset_C",(EPS,PetscInt),(eps,nrest));
336:   return(0);
337: }

341: static PetscErrorCode EPSRQCGGetReset_RQCG(EPS eps,PetscInt *nrest)
342: {
343:   EPS_RQCG *ctx = (EPS_RQCG*)eps->data;

346:   *nrest = ctx->nrest;
347:   return(0);
348: }

352: /*@
353:    EPSRQCGGetReset - Gets the reset parameter used in the RQCG method.

355:    Not Collective

357:    Input Parameter:
358: .  eps - the eigenproblem solver context

360:    Output Parameter:
361: .  nrest - the reset parameter

363:    Level: advanced

365: .seealso: EPSRQCGSetReset()
366: @*/
367: PetscErrorCode EPSRQCGGetReset(EPS eps,PetscInt *nrest)
368: {

374:   PetscUseMethod(eps,"EPSRQCGGetReset_C",(EPS,PetscInt*),(eps,nrest));
375:   return(0);
376: }

380: PetscErrorCode EPSReset_RQCG(EPS eps)
381: {
383:   EPS_RQCG       *ctx = (EPS_RQCG*)eps->data;

386:   BVDestroy(&ctx->AV);
387:   BVDestroy(&ctx->W);
388:   BVDestroy(&ctx->P);
389:   BVDestroy(&ctx->G);
390:   ctx->nrest = 0;
391:   return(0);
392: }

396: PetscErrorCode EPSSetFromOptions_RQCG(PetscOptionItems *PetscOptionsObject,EPS eps)
397: {
399:   PetscBool      flg;
400:   PetscInt       nrest;

403:   PetscOptionsHead(PetscOptionsObject,"EPS RQCG Options");
404:   PetscOptionsInt("-eps_rqcg_reset","RQCG reset parameter","EPSRQCGSetReset",20,&nrest,&flg);
405:   if (flg) {
406:     EPSRQCGSetReset(eps,nrest);
407:   }
408:   PetscOptionsTail();
409:   return(0);
410: }

414: PetscErrorCode EPSDestroy_RQCG(EPS eps)
415: {

419:   PetscFree(eps->data);
420:   PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGSetReset_C",NULL);
421:   PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGGetReset_C",NULL);
422:   return(0);
423: }

427: PetscErrorCode EPSView_RQCG(EPS eps,PetscViewer viewer)
428: {
430:   EPS_RQCG       *ctx = (EPS_RQCG*)eps->data;
431:   PetscBool      isascii;

434:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
435:   if (isascii) {
436:     PetscViewerASCIIPrintf(viewer,"  RQCG: reset every %D iterations\n",ctx->nrest);
437:   }
438:   return(0);
439: }

443: PETSC_EXTERN PetscErrorCode EPSCreate_RQCG(EPS eps)
444: {
445:   EPS_RQCG       *rqcg;

449:   PetscNewLog(eps,&rqcg);
450:   eps->data = (void*)rqcg;

452:   eps->ops->setup          = EPSSetUp_RQCG;
453:   eps->ops->solve          = EPSSolve_RQCG;
454:   eps->ops->setfromoptions = EPSSetFromOptions_RQCG;
455:   eps->ops->destroy        = EPSDestroy_RQCG;
456:   eps->ops->reset          = EPSReset_RQCG;
457:   eps->ops->view           = EPSView_RQCG;
458:   eps->ops->backtransform  = EPSBackTransform_Default;
459:   STSetType(eps->st,STPRECOND);
460:   STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);
461:   PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGSetReset_C",EPSRQCGSetReset_RQCG);
462:   PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGGetReset_C",EPSRQCGGetReset_RQCG);
463:   return(0);
464: }

slepc-3.7.4/src/eps/impls/cg/rqcg/index.html0000644000175000017500000000257613107004621020221 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

rqcg.c
makefile
slepc-3.7.4/src/eps/impls/cg/rqcg/ftn-auto/0000755000175000017500000000000013107004621017747 5ustar jromanjromanslepc-3.7.4/src/eps/impls/cg/rqcg/ftn-auto/rqcgf.c0000644000175000017500000000265313107004621021223 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* rqcg.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsrqcgsetreset_ EPSRQCGSETRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsrqcgsetreset_ epsrqcgsetreset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsrqcggetreset_ EPSRQCGGETRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsrqcggetreset_ epsrqcggetreset #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsrqcgsetreset_(EPS eps,PetscInt *nrest, int *__ierr ){ *__ierr = EPSRQCGSetReset( (EPS)PetscToPointer((eps) ),*nrest); } PETSC_EXTERN void PETSC_STDCALL epsrqcggetreset_(EPS eps,PetscInt *nrest, int *__ierr ){ *__ierr = EPSRQCGGetReset( (EPS)PetscToPointer((eps) ),nrest); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/cg/rqcg/ftn-auto/makefile0000644000175000017500000000036013107004621021446 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = rqcgf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/cg/rqcg/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/cg/rqcg/rqcg.c0000644000175000017500000004140613107004621017317 0ustar jromanjroman/* SLEPc eigensolver: "rqcg" Method: Rayleigh Quotient Conjugate Gradient Algorithm: Conjugate Gradient minimization of the Rayleigh quotient with periodic Rayleigh-Ritz acceleration. References: [1] L. Bergamaschi et al., "Parallel preconditioned conjugate gradient optimization of the Rayleigh quotient for the solution of sparse eigenproblems", Appl. Math. Comput. 175(2):1694-1715, 2006. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ PetscErrorCode EPSSolve_RQCG(EPS); typedef struct { PetscInt nrest; BV AV,W,P,G; } EPS_RQCG; #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_RQCG" PetscErrorCode EPSSetUp_RQCG(EPS eps) { PetscErrorCode ierr; PetscBool precond; PetscInt nmat; EPS_RQCG *ctx = (EPS_RQCG*)eps->data; PetscFunctionBegin; if (!eps->ishermitian || (eps->isgeneralized && !eps->ispositive)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"RQCG only works for Hermitian problems"); ierr = EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv); if (!eps->which) eps->which = EPS_SMALLEST_REAL; if (eps->which!=EPS_SMALLEST_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (!eps->extraction) { ierr = EPSSetExtraction(eps,EPS_RITZ);CHKERRQ(ierr); } else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); /* Set STPrecond as the default ST */ if (!((PetscObject)eps->st)->type_name) { ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&precond);CHKERRQ(ierr); if (!precond) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"RQCG only works with precond ST"); if (!ctx->nrest) ctx->nrest = 20; ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,eps->mpd,&ctx->AV);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->AV);CHKERRQ(ierr); ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); if (nmat>1) { ierr = BVDuplicate(ctx->AV,&ctx->W);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->W);CHKERRQ(ierr); } ierr = BVDuplicate(ctx->AV,&ctx->P);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->P);CHKERRQ(ierr); ierr = BVDuplicate(ctx->AV,&ctx->G);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->G);CHKERRQ(ierr); ierr = DSSetType(eps->ds,DSHEP);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,eps->ncv);CHKERRQ(ierr); ierr = EPSSetWorkVecs(eps,1);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "ExtractSubmatrix" /* ExtractSubmatrix - Returns B = A(k+1:end,k+1:end). */ static PetscErrorCode ExtractSubmatrix(Mat A,PetscInt k,Mat *B) { PetscErrorCode ierr; PetscInt j,m,n; PetscScalar *pA,*pB; PetscFunctionBegin; ierr = MatGetSize(A,&m,&n);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,m-k,n-k,NULL,B);CHKERRQ(ierr); ierr = MatDenseGetArray(A,&pA);CHKERRQ(ierr); ierr = MatDenseGetArray(*B,&pB);CHKERRQ(ierr); for (j=k;jdata; PetscInt i,j,k,ld,nv,ncv = eps->ncv,kini,nmat; PetscScalar *C,*gamma,g,pap,pbp,pbx,pax,nu,mu,alpha,beta; PetscReal resnorm,norm,a,b,c,disc,t; PetscBool reset,breakdown; Mat A,B,Q,Q1; Vec v,av,bv,p,w=eps->work[0]; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } else B = NULL; ierr = PetscMalloc1(eps->mpd,&gamma);CHKERRQ(ierr); kini = eps->nini; while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; nv = PetscMin(eps->nconv+eps->mpd,ncv); ierr = DSSetDimensions(eps->ds,nv,0,eps->nconv,0);CHKERRQ(ierr); /* Generate more initial vectors if necessary */ while (kiniV,kini);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,kini,NULL,&norm,&breakdown);CHKERRQ(ierr); if (norm>0.0 && !breakdown) { ierr = BVScaleColumn(eps->V,kini,1.0/norm);CHKERRQ(ierr); kini++; } } reset = (eps->its>1 && (eps->its-1)%ctx->nrest==0)? PETSC_TRUE: PETSC_FALSE; if (reset) { /* Prevent BVDotVec below to use B-product, restored a the end */ ierr = BVSetMatrix(eps->V,NULL,PETSC_FALSE);CHKERRQ(ierr); /* Compute Rayleigh quotient */ ierr = BVSetActiveColumns(eps->V,eps->nconv,nv);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->AV,0,nv-eps->nconv);CHKERRQ(ierr); ierr = BVMatMult(eps->V,A,ctx->AV);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_A,&C);CHKERRQ(ierr); for (i=eps->nconv;iV,eps->nconv,i+1);CHKERRQ(ierr); ierr = BVGetColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); ierr = BVDotVec(eps->V,av,C+eps->nconv+i*ld);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); for (j=eps->nconv;jds,DS_MAT_A,&C);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); /* Solve projected problem */ ierr = DSSolve(eps->ds,eps->eigr,eps->eigi);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);CHKERRQ(ierr); /* Update vectors V(:,idx) = V * Y(:,idx) */ ierr = DSGetMat(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,Q,eps->nconv,nv);CHKERRQ(ierr); ierr = ExtractSubmatrix(Q,eps->nconv,&Q1);CHKERRQ(ierr); ierr = BVMultInPlace(ctx->AV,Q1,0,nv-eps->nconv);CHKERRQ(ierr); ierr = MatDestroy(&Q);CHKERRQ(ierr); ierr = MatDestroy(&Q1);CHKERRQ(ierr); if (B) { ierr = BVSetMatrix(eps->V,B,PETSC_FALSE);CHKERRQ(ierr); } } else { /* No need to do Rayleigh-Ritz, just take diag(V'*A*V) */ for (i=eps->nconv;iV,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); ierr = MatMult(A,v,av);CHKERRQ(ierr); ierr = VecDot(av,v,eps->eigr+i);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); } } /* Compute gradient and check convergence */ k = -1; for (i=eps->nconv;iV,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); ierr = BVGetColumn(ctx->G,i-eps->nconv,&p);CHKERRQ(ierr); if (B) { ierr = BVGetColumn(ctx->W,i-eps->nconv,&bv);CHKERRQ(ierr); ierr = MatMult(B,v,bv);CHKERRQ(ierr); ierr = VecWAXPY(p,-eps->eigr[i],bv,av);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->W,i-eps->nconv,&bv);CHKERRQ(ierr); } else { ierr = VecWAXPY(p,-eps->eigr[i],v,av);CHKERRQ(ierr); } ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); ierr = VecNorm(p,NORM_2,&resnorm);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->G,i-eps->nconv,&p);CHKERRQ(ierr); ierr = (*eps->converged)(eps,eps->eigr[i],0.0,resnorm,&eps->errest[i],eps->convergedctx);CHKERRQ(ierr); if (k==-1 && eps->errest[i] >= eps->tol) k = i; } if (k==-1) k = nv; ierr = (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); /* The next lines are necessary to avoid DS zeroing eigr */ ierr = DSGetArray(eps->ds,DS_MAT_A,&C);CHKERRQ(ierr); for (i=eps->nconv;ieigr[i]; ierr = DSRestoreArray(eps->ds,DS_MAT_A,&C);CHKERRQ(ierr); if (eps->reason == EPS_CONVERGED_ITERATING) { /* Search direction */ for (i=0;inconv;i++) { ierr = BVGetColumn(ctx->G,i,&v);CHKERRQ(ierr); ierr = STMatSolve(eps->st,v,w);CHKERRQ(ierr); ierr = VecDot(v,w,&g);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->G,i,&v);CHKERRQ(ierr); beta = (!reset && eps->its>1)? g/gamma[i]: 0.0; gamma[i] = g; ierr = BVGetColumn(ctx->P,i,&v);CHKERRQ(ierr); ierr = VecAXPBY(v,1.0,beta,w);CHKERRQ(ierr); if (i+eps->nconv>0) { ierr = BVSetActiveColumns(eps->V,0,i+eps->nconv);CHKERRQ(ierr); ierr = BVOrthogonalizeVec(eps->V,v,NULL,NULL,NULL);CHKERRQ(ierr); } ierr = BVRestoreColumn(ctx->P,i,&v);CHKERRQ(ierr); } /* Minimization problem */ for (i=eps->nconv;iV,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); ierr = BVGetColumn(ctx->P,i-eps->nconv,&p);CHKERRQ(ierr); ierr = VecDot(v,av,&nu);CHKERRQ(ierr); ierr = VecDot(p,av,&pax);CHKERRQ(ierr); ierr = MatMult(A,p,w);CHKERRQ(ierr); ierr = VecDot(p,w,&pap);CHKERRQ(ierr); if (B) { ierr = BVGetColumn(ctx->W,i-eps->nconv,&bv);CHKERRQ(ierr); ierr = VecDot(v,bv,&mu);CHKERRQ(ierr); ierr = VecDot(p,bv,&pbx);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->W,i-eps->nconv,&bv);CHKERRQ(ierr); ierr = MatMult(B,p,w);CHKERRQ(ierr); ierr = VecDot(p,w,&pbp);CHKERRQ(ierr); } else { ierr = VecDot(v,v,&mu);CHKERRQ(ierr); ierr = VecDot(p,v,&pbx);CHKERRQ(ierr); ierr = VecDot(p,p,&pbp);CHKERRQ(ierr); } ierr = BVRestoreColumn(ctx->AV,i-eps->nconv,&av);CHKERRQ(ierr); a = PetscRealPart(pap*pbx-pax*pbp); b = PetscRealPart(nu*pbp-mu*pap); c = PetscRealPart(mu*pax-nu*pbx); t = PetscMax(PetscMax(PetscAbsReal(a),PetscAbsReal(b)),PetscAbsReal(c)); if (t!=0.0) { a /= t; b /= t; c /= t; } disc = PetscSqrtReal(PetscAbsReal(b*b-4.0*a*c)); if (b>=0.0 && a!=0.0) alpha = (b+disc)/(2.0*a); else if (b!=disc) alpha = 2.0*c/(b-disc); else alpha = 0; /* Next iterate */ if (alpha!=0.0) { ierr = VecAXPY(v,alpha,p);CHKERRQ(ierr); } ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->P,i-eps->nconv,&p);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,i,NULL,&norm,&breakdown);CHKERRQ(ierr); if (!breakdown && norm!=0.0) { ierr = BVScaleColumn(eps->V,i,1.0/norm);CHKERRQ(ierr); } } } ierr = EPSMonitor(eps,eps->its,k,eps->eigr,eps->eigi,eps->errest,nv);CHKERRQ(ierr); eps->nconv = k; } ierr = PetscFree(gamma);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSRQCGSetReset_RQCG" static PetscErrorCode EPSRQCGSetReset_RQCG(EPS eps,PetscInt nrest) { EPS_RQCG *ctx = (EPS_RQCG*)eps->data; PetscFunctionBegin; ctx->nrest = nrest; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSRQCGSetReset" /*@ EPSRQCGSetReset - Sets the reset parameter of the RQCG iteration. Every nrest iterations, the solver performs a Rayleigh-Ritz projection step. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - nrest - the number of iterations between resets Options Database Key: . -eps_rqcg_reset - Sets the reset parameter Level: advanced .seealso: EPSRQCGGetReset() @*/ PetscErrorCode EPSRQCGSetReset(EPS eps,PetscInt nrest) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,nrest,2); ierr = PetscTryMethod(eps,"EPSRQCGSetReset_C",(EPS,PetscInt),(eps,nrest));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSRQCGGetReset_RQCG" static PetscErrorCode EPSRQCGGetReset_RQCG(EPS eps,PetscInt *nrest) { EPS_RQCG *ctx = (EPS_RQCG*)eps->data; PetscFunctionBegin; *nrest = ctx->nrest; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSRQCGGetReset" /*@ EPSRQCGGetReset - Gets the reset parameter used in the RQCG method. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . nrest - the reset parameter Level: advanced .seealso: EPSRQCGSetReset() @*/ PetscErrorCode EPSRQCGGetReset(EPS eps,PetscInt *nrest) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(nrest,2); ierr = PetscUseMethod(eps,"EPSRQCGGetReset_C",(EPS,PetscInt*),(eps,nrest));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_RQCG" PetscErrorCode EPSReset_RQCG(EPS eps) { PetscErrorCode ierr; EPS_RQCG *ctx = (EPS_RQCG*)eps->data; PetscFunctionBegin; ierr = BVDestroy(&ctx->AV);CHKERRQ(ierr); ierr = BVDestroy(&ctx->W);CHKERRQ(ierr); ierr = BVDestroy(&ctx->P);CHKERRQ(ierr); ierr = BVDestroy(&ctx->G);CHKERRQ(ierr); ctx->nrest = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_RQCG" PetscErrorCode EPSSetFromOptions_RQCG(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; PetscBool flg; PetscInt nrest; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS RQCG Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_rqcg_reset","RQCG reset parameter","EPSRQCGSetReset",20,&nrest,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSRQCGSetReset(eps,nrest);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_RQCG" PetscErrorCode EPSDestroy_RQCG(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGSetReset_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGGetReset_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_RQCG" PetscErrorCode EPSView_RQCG(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_RQCG *ctx = (EPS_RQCG*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," RQCG: reset every %D iterations\n",ctx->nrest);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_RQCG" PETSC_EXTERN PetscErrorCode EPSCreate_RQCG(EPS eps) { EPS_RQCG *rqcg; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&rqcg);CHKERRQ(ierr); eps->data = (void*)rqcg; eps->ops->setup = EPSSetUp_RQCG; eps->ops->solve = EPSSolve_RQCG; eps->ops->setfromoptions = EPSSetFromOptions_RQCG; eps->ops->destroy = EPSDestroy_RQCG; eps->ops->reset = EPSReset_RQCG; eps->ops->view = EPSView_RQCG; eps->ops->backtransform = EPSBackTransform_Default; ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); ierr = STPrecondSetKSPHasMat(eps->st,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGSetReset_C",EPSRQCGSetReset_RQCG);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSRQCGGetReset_C",EPSRQCGGetReset_RQCG);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/cg/index.html0000644000175000017500000000261713107004621017261 0ustar jromanjroman Eigenvalue Problem Solver - EPS

slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

rqcg/
lobpcg/
makefile
slepc-3.7.4/src/eps/impls/subspace/0000755000175000017500000000000013107004621016472 5ustar jromanjromanslepc-3.7.4/src/eps/impls/subspace/makefile0000644000175000017500000000216213107004621020173 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = subspace.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/subspace/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/subspace/subspace.c0000644000175000017500000003050013107004621020441 0ustar jromanjroman/* SLEPc eigensolver: "subspace" Method: Subspace Iteration Algorithm: Subspace iteration with Rayleigh-Ritz projection and locking, based on the SRRIT implementation. References: [1] "Subspace Iteration in SLEPc", SLEPc Technical Report STR-3, available at http://slepc.upv.es. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_Subspace" PetscErrorCode EPSSetUp_Subspace(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv); if (!eps->which) { ierr = EPSSetWhichEigenpairs_Default(eps);CHKERRQ(ierr); } if (eps->which!=EPS_LARGEST_MAGNITUDE && eps->which!=EPS_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (!eps->extraction) { ierr = EPSSetExtraction(eps,EPS_RITZ);CHKERRQ(ierr); } else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); if (eps->ishermitian) { ierr = DSSetType(eps->ds,DSHEP);CHKERRQ(ierr); } else { ierr = DSSetType(eps->ds,DSNHEP);CHKERRQ(ierr); } ierr = DSAllocate(eps->ds,eps->ncv);CHKERRQ(ierr); ierr = EPSSetWorkVecs(eps,1);CHKERRQ(ierr); if (eps->isgeneralized && eps->ishermitian && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method does not work for indefinite problems"); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSubspaceFindGroup" /* EPSSubspaceFindGroup - Find a group of nearly equimodular eigenvalues, provided in arrays wr and wi, according to the tolerance grptol. Also the 2-norms of the residuals must be passed in (rsd). Arrays are processed from index l to index m only. The output information is: ngrp - number of entries of the group ctr - (w(l)+w(l+ngrp-1))/2 ae - average of wr(l),...,wr(l+ngrp-1) arsd - average of rsd(l),...,rsd(l+ngrp-1) */ static PetscErrorCode EPSSubspaceFindGroup(PetscInt l,PetscInt m,PetscScalar *wr,PetscScalar *wi,PetscReal *rsd,PetscReal grptol,PetscInt *ngrp,PetscReal *ctr,PetscReal *ae,PetscReal *arsd) { PetscInt i; PetscReal rmod,rmod1; PetscFunctionBegin; *ngrp = 0; *ctr = 0; rmod = SlepcAbsEigenvalue(wr[l],wi[l]); for (i=l;i grptol*(rmod+rmod1)) break; *ctr = (rmod+rmod1)/2.0; if (wi[i] != 0.0) { (*ngrp)+=2; i+=2; } else { (*ngrp)++; i++; } } *ae = 0; *arsd = 0; if (*ngrp) { for (i=l;iwork[0]; Mat H,Q; BV AV; PetscInt i,k,ld,ngrp,nogrp,*itrsd,*itrsdold; PetscInt nxtsrr,idsrr,idort,nxtort,nv,ncv = eps->ncv,its; PetscScalar *T; PetscReal arsd,oarsd,ctr,octr,ae,oae,*rsd,norm,tcond=1.0; PetscBool breakdown; /* Parameters */ PetscInt init = 5; /* Number of initial iterations */ PetscReal stpfac = 1.5; /* Max num of iter before next SRR step */ PetscReal alpha = 1.0; /* Used to predict convergence of next residual */ PetscReal beta = 1.1; /* Used to predict convergence of next residual */ PetscReal grptol = 1e-8; /* Tolerance for EPSSubspaceFindGroup */ PetscReal cnvtol = 1e-6; /* Convergence criterion for cnv */ PetscInt orttol = 2; /* Number of decimal digits whose loss can be tolerated in orthogonalization */ PetscFunctionBegin; its = 0; ierr = PetscMalloc3(ncv,&rsd,ncv,&itrsd,ncv,&itrsdold);CHKERRQ(ierr); ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = BVDuplicate(eps->V,&AV);CHKERRQ(ierr); for (i=0;inini; while (kV,k);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,k,NULL,&norm,&breakdown);CHKERRQ(ierr); if (norm>0.0 && !breakdown) { ierr = BVScaleColumn(eps->V,k,1.0/norm);CHKERRQ(ierr); k++; } } while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; nv = PetscMin(eps->nconv+eps->mpd,ncv); ierr = DSSetDimensions(eps->ds,nv,0,eps->nconv,0);CHKERRQ(ierr); /* Find group in previously computed eigenvalues */ ierr = EPSSubspaceFindGroup(eps->nconv,nv,eps->eigr,eps->eigi,rsd,grptol,&nogrp,&octr,&oae,&oarsd);CHKERRQ(ierr); /* AV(:,idx) = OP * V(:,idx) */ for (i=eps->nconv;iV,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(AV,i,&av);CHKERRQ(ierr); ierr = STApply(eps->st,v,av);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(AV,i,&av);CHKERRQ(ierr); } /* T(:,idx) = V' * AV(:,idx) */ ierr = BVSetActiveColumns(eps->V,0,nv);CHKERRQ(ierr); ierr = BVSetActiveColumns(AV,eps->nconv,nv);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = BVDot(AV,eps->V,H);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); /* Solve projected problem */ ierr = DSSolve(eps->ds,eps->eigr,eps->eigi);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);CHKERRQ(ierr); /* Update vectors V(:,idx) = V * U(:,idx) */ ierr = DSGetMat(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = BVSetActiveColumns(AV,0,nv);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,Q,eps->nconv,nv);CHKERRQ(ierr); ierr = BVMultInPlace(AV,Q,eps->nconv,nv);CHKERRQ(ierr); ierr = MatDestroy(&Q);CHKERRQ(ierr); /* Convergence check */ ierr = DSGetArray(eps->ds,DS_MAT_A,&T);CHKERRQ(ierr); ierr = EPSSubspaceResidualNorms(eps->V,AV,T,eps->nconv,nv,ld,w,rsd);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_A,&T);CHKERRQ(ierr); for (i=eps->nconv;ierrest[i] = rsd[i]; } for (;;) { /* Find group in currently computed eigenvalues */ ierr = EPSSubspaceFindGroup(eps->nconv,nv,eps->eigr,eps->eigi,eps->errest,grptol,&ngrp,&ctr,&ae,&arsd);CHKERRQ(ierr); if (ngrp!=nogrp) break; if (ngrp==0) break; if (PetscAbsReal(ae-oae)>ctr*cnvtol*(itrsd[eps->nconv]-itrsdold[eps->nconv])) break; if (arsd>ctr*eps->tol) break; eps->nconv = eps->nconv + ngrp; if (eps->nconv>=nv) break; } ierr = EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,nv);CHKERRQ(ierr); ierr = (*eps->stopping)(eps,eps->its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); if (eps->reason != EPS_CONVERGED_ITERATING) break; /* Compute nxtsrr (iteration of next projection step) */ nxtsrr = PetscMin(eps->max_it,PetscMax((PetscInt)PetscFloorReal(stpfac*its),init)); if (ngrp!=nogrp || ngrp==0 || arsd>=oarsd) { idsrr = nxtsrr - its; } else { idsrr = (PetscInt)PetscFloorReal(alpha+beta*(itrsdold[eps->nconv]-itrsd[eps->nconv])*PetscLogReal(arsd/eps->tol)/PetscLogReal(arsd/oarsd)); idsrr = PetscMax(1,idsrr); } nxtsrr = PetscMin(nxtsrr,its+idsrr); /* Compute nxtort (iteration of next orthogonalization step) */ ierr = DSCond(eps->ds,&tcond);CHKERRQ(ierr); idort = PetscMax(1,(PetscInt)PetscFloorReal(orttol/PetscMax(1,PetscLog10Real(tcond)))); nxtort = PetscMin(its+idort,nxtsrr); /* V(:,idx) = AV(:,idx) */ ierr = BVSetActiveColumns(eps->V,eps->nconv,nv);CHKERRQ(ierr); ierr = BVSetActiveColumns(AV,eps->nconv,nv);CHKERRQ(ierr); ierr = BVCopy(AV,eps->V);CHKERRQ(ierr); its++; /* Orthogonalization loop */ do { while (itsnconv;iV,i,&v);CHKERRQ(ierr); ierr = STApply(eps->st,v,w);CHKERRQ(ierr); ierr = VecCopy(w,v);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = BVNormColumn(eps->V,i,NORM_INFINITY,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,i,1/norm);CHKERRQ(ierr); } its++; } /* Orthonormalize vectors */ for (i=eps->nconv;iV,i,NULL,&norm,&breakdown);CHKERRQ(ierr); if (breakdown) { ierr = BVSetRandomColumn(eps->V,i);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,i,NULL,&norm,&breakdown);CHKERRQ(ierr); } ierr = BVScaleColumn(eps->V,i,1/norm);CHKERRQ(ierr); } nxtort = PetscMin(its+idort,nxtsrr); } while (itsds,eps->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_Subspace" PetscErrorCode EPSDestroy_Subspace(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_Subspace" PETSC_EXTERN PetscErrorCode EPSCreate_Subspace(EPS eps) { PetscFunctionBegin; eps->ops->setup = EPSSetUp_Subspace; eps->ops->solve = EPSSolve_Subspace; eps->ops->destroy = EPSDestroy_Subspace; eps->ops->backtransform = EPSBackTransform_Default; eps->ops->computevectors = EPSComputeVectors_Schur; PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/subspace/makefile.html0000644000175000017500000000467013107004621021144 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = subspace.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/subspace/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/subspace/subspace.c.html0000644000175000017500000006644513107004621021425 0ustar jromanjroman
Actual source code: subspace.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "subspace"

  5:    Method: Subspace Iteration

  7:    Algorithm:

  9:        Subspace iteration with Rayleigh-Ritz projection and locking,
 10:        based on the SRRIT implementation.

 12:    References:

 14:        [1] "Subspace Iteration in SLEPc", SLEPc Technical Report STR-3,
 15:            available at http://slepc.upv.es.

 17:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 19:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 21:    This file is part of SLEPc.

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

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

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

 37: #include <slepc/private/epsimpl.h>

 41: PetscErrorCode EPSSetUp_Subspace(EPS eps)
 42: {

 46:   EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);
 47:   if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv);
 48:   if (!eps->which) { EPSSetWhichEigenpairs_Default(eps); }
 49:   if (eps->which!=EPS_LARGEST_MAGNITUDE && eps->which!=EPS_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
 50:   if (!eps->extraction) {
 51:     EPSSetExtraction(eps,EPS_RITZ);
 52:   } else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
 53:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");

 55:   EPSAllocateSolution(eps,0);
 56:   EPS_SetInnerProduct(eps);
 57:   if (eps->ishermitian) {
 58:     DSSetType(eps->ds,DSHEP);
 59:   } else {
 60:     DSSetType(eps->ds,DSNHEP);
 61:   }
 62:   DSAllocate(eps->ds,eps->ncv);
 63:   EPSSetWorkVecs(eps,1);

 65:   if (eps->isgeneralized && eps->ishermitian && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method does not work for indefinite problems");
 66:   return(0);
 67: }

 71: /*
 72:    EPSSubspaceFindGroup - Find a group of nearly equimodular eigenvalues, provided
 73:    in arrays wr and wi, according to the tolerance grptol. Also the 2-norms
 74:    of the residuals must be passed in (rsd). Arrays are processed from index
 75:    l to index m only. The output information is:

 77:    ngrp - number of entries of the group
 78:    ctr  - (w(l)+w(l+ngrp-1))/2
 79:    ae   - average of wr(l),...,wr(l+ngrp-1)
 80:    arsd - average of rsd(l),...,rsd(l+ngrp-1)
 81: */
 82: static PetscErrorCode EPSSubspaceFindGroup(PetscInt l,PetscInt m,PetscScalar *wr,PetscScalar *wi,PetscReal *rsd,PetscReal grptol,PetscInt *ngrp,PetscReal *ctr,PetscReal *ae,PetscReal *arsd)
 83: {
 84:   PetscInt  i;
 85:   PetscReal rmod,rmod1;

 88:   *ngrp = 0;
 89:   *ctr = 0;
 90:   rmod = SlepcAbsEigenvalue(wr[l],wi[l]);

 92:   for (i=l;i<m;) {
 93:     rmod1 = SlepcAbsEigenvalue(wr[i],wi[i]);
 94:     if (PetscAbsReal(rmod-rmod1) > grptol*(rmod+rmod1)) break;
 95:     *ctr = (rmod+rmod1)/2.0;
 96:     if (wi[i] != 0.0) {
 97:       (*ngrp)+=2;
 98:       i+=2;
 99:     } else {
100:       (*ngrp)++;
101:       i++;
102:     }
103:   }

105:   *ae = 0;
106:   *arsd = 0;
107:   if (*ngrp) {
108:     for (i=l;i<l+*ngrp;i++) {
109:       (*ae) += PetscRealPart(wr[i]);
110:       (*arsd) += rsd[i]*rsd[i];
111:     }
112:     *ae = *ae / *ngrp;
113:     *arsd = PetscSqrtScalar(*arsd / *ngrp);
114:   }
115:   return(0);
116: }

120: /*
121:    EPSSubspaceResidualNorms - Computes the column norms of residual vectors
122:    OP*V(1:n,l:m) - V*T(1:m,l:m), where, on entry, OP*V has been computed and
123:    stored in AV. ldt is the leading dimension of T. On exit, rsd(l) to
124:    rsd(m) contain the computed norms.
125: */
126: static PetscErrorCode EPSSubspaceResidualNorms(BV V,BV AV,PetscScalar *T,PetscInt l,PetscInt m,PetscInt ldt,Vec w,PetscReal *rsd)
127: {
129:   PetscInt       i,k;
130:   PetscScalar    t;

133:   for (i=l;i<m;i++) {
134:     if (i==m-1 || T[i+1+ldt*i]==0.0) k=i+1;
135:     else k=i+2;
136:     BVSetActiveColumns(V,0,k);
137:     BVCopyVec(AV,i,w);
138:     BVMultVec(V,-1.0,1.0,w,T+ldt*i);
139:     VecDot(w,w,&t);
140:     rsd[i] = PetscRealPart(t);
141:   }
142:   for (i=l;i<m;i++) {
143:     if (i == m-1) {
144:       rsd[i] = PetscSqrtReal(rsd[i]);
145:     } else if (T[i+1+(ldt*i)]==0.0) {
146:       rsd[i] = PetscSqrtReal(rsd[i]);
147:     } else {
148:       rsd[i] = PetscSqrtReal((rsd[i]+rsd[i+1])/2.0);
149:       rsd[i+1] = rsd[i];
150:       i++;
151:     }
152:   }
153:   return(0);
154: }

158: PetscErrorCode EPSSolve_Subspace(EPS eps)
159: {
161:   Vec            v,av,w=eps->work[0];
162:   Mat            H,Q;
163:   BV             AV;
164:   PetscInt       i,k,ld,ngrp,nogrp,*itrsd,*itrsdold;
165:   PetscInt       nxtsrr,idsrr,idort,nxtort,nv,ncv = eps->ncv,its;
166:   PetscScalar    *T;
167:   PetscReal      arsd,oarsd,ctr,octr,ae,oae,*rsd,norm,tcond=1.0;
168:   PetscBool      breakdown;
169:   /* Parameters */
170:   PetscInt       init = 5;        /* Number of initial iterations */
171:   PetscReal      stpfac = 1.5;    /* Max num of iter before next SRR step */
172:   PetscReal      alpha = 1.0;     /* Used to predict convergence of next residual */
173:   PetscReal      beta = 1.1;      /* Used to predict convergence of next residual */
174:   PetscReal      grptol = 1e-8;   /* Tolerance for EPSSubspaceFindGroup */
175:   PetscReal      cnvtol = 1e-6;   /* Convergence criterion for cnv */
176:   PetscInt       orttol = 2;      /* Number of decimal digits whose loss
177:                                      can be tolerated in orthogonalization */

180:   its = 0;
181:   PetscMalloc3(ncv,&rsd,ncv,&itrsd,ncv,&itrsdold);
182:   DSGetLeadingDimension(eps->ds,&ld);
183:   BVDuplicate(eps->V,&AV);

185:   for (i=0;i<ncv;i++) {
186:     rsd[i] = 0.0;
187:     itrsd[i] = -1;
188:   }

190:   /* Complete the initial basis with random vectors and orthonormalize them */
191:   k = eps->nini;
192:   while (k<ncv) {
193:     BVSetRandomColumn(eps->V,k);
194:     BVOrthogonalizeColumn(eps->V,k,NULL,&norm,&breakdown);
195:     if (norm>0.0 && !breakdown) {
196:       BVScaleColumn(eps->V,k,1.0/norm);
197:       k++;
198:     }
199:   }

201:   while (eps->reason == EPS_CONVERGED_ITERATING) {
202:     eps->its++;
203:     nv = PetscMin(eps->nconv+eps->mpd,ncv);
204:     DSSetDimensions(eps->ds,nv,0,eps->nconv,0);

206:     /* Find group in previously computed eigenvalues */
207:     EPSSubspaceFindGroup(eps->nconv,nv,eps->eigr,eps->eigi,rsd,grptol,&nogrp,&octr,&oae,&oarsd);

209:     /* AV(:,idx) = OP * V(:,idx) */
210:     for (i=eps->nconv;i<nv;i++) {
211:       BVGetColumn(eps->V,i,&v);
212:       BVGetColumn(AV,i,&av);
213:       STApply(eps->st,v,av);
214:       BVRestoreColumn(eps->V,i,&v);
215:       BVRestoreColumn(AV,i,&av);
216:     }

218:     /* T(:,idx) = V' * AV(:,idx) */
219:     BVSetActiveColumns(eps->V,0,nv);
220:     BVSetActiveColumns(AV,eps->nconv,nv);
221:     DSGetMat(eps->ds,DS_MAT_A,&H);
222:     BVDot(AV,eps->V,H);
223:     DSRestoreMat(eps->ds,DS_MAT_A,&H);
224:     DSSetState(eps->ds,DS_STATE_RAW);

226:     /* Solve projected problem */
227:     DSSolve(eps->ds,eps->eigr,eps->eigi);
228:     DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);

230:     /* Update vectors V(:,idx) = V * U(:,idx) */
231:     DSGetMat(eps->ds,DS_MAT_Q,&Q);
232:     BVSetActiveColumns(AV,0,nv);
233:     BVMultInPlace(eps->V,Q,eps->nconv,nv);
234:     BVMultInPlace(AV,Q,eps->nconv,nv);
235:     MatDestroy(&Q);

237:     /* Convergence check */
238:     DSGetArray(eps->ds,DS_MAT_A,&T);
239:     EPSSubspaceResidualNorms(eps->V,AV,T,eps->nconv,nv,ld,w,rsd);
240:     DSRestoreArray(eps->ds,DS_MAT_A,&T);

242:     for (i=eps->nconv;i<nv;i++) {
243:       itrsdold[i] = itrsd[i];
244:       itrsd[i] = its;
245:       eps->errest[i] = rsd[i];
246:     }

248:     for (;;) {
249:       /* Find group in currently computed eigenvalues */
250:       EPSSubspaceFindGroup(eps->nconv,nv,eps->eigr,eps->eigi,eps->errest,grptol,&ngrp,&ctr,&ae,&arsd);
251:       if (ngrp!=nogrp) break;
252:       if (ngrp==0) break;
253:       if (PetscAbsReal(ae-oae)>ctr*cnvtol*(itrsd[eps->nconv]-itrsdold[eps->nconv])) break;
254:       if (arsd>ctr*eps->tol) break;
255:       eps->nconv = eps->nconv + ngrp;
256:       if (eps->nconv>=nv) break;
257:     }

259:     EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,nv);
260:     (*eps->stopping)(eps,eps->its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);
261:     if (eps->reason != EPS_CONVERGED_ITERATING) break;

263:     /* Compute nxtsrr (iteration of next projection step) */
264:     nxtsrr = PetscMin(eps->max_it,PetscMax((PetscInt)PetscFloorReal(stpfac*its),init));

266:     if (ngrp!=nogrp || ngrp==0 || arsd>=oarsd) {
267:       idsrr = nxtsrr - its;
268:     } else {
269:       idsrr = (PetscInt)PetscFloorReal(alpha+beta*(itrsdold[eps->nconv]-itrsd[eps->nconv])*PetscLogReal(arsd/eps->tol)/PetscLogReal(arsd/oarsd));
270:       idsrr = PetscMax(1,idsrr);
271:     }
272:     nxtsrr = PetscMin(nxtsrr,its+idsrr);

274:     /* Compute nxtort (iteration of next orthogonalization step) */
275:     DSCond(eps->ds,&tcond);
276:     idort = PetscMax(1,(PetscInt)PetscFloorReal(orttol/PetscMax(1,PetscLog10Real(tcond))));
277:     nxtort = PetscMin(its+idort,nxtsrr);

279:     /* V(:,idx) = AV(:,idx) */
280:     BVSetActiveColumns(eps->V,eps->nconv,nv);
281:     BVSetActiveColumns(AV,eps->nconv,nv);
282:     BVCopy(AV,eps->V);
283:     its++;

285:     /* Orthogonalization loop */
286:     do {
287:       while (its<nxtort) {

289:         /* A(:,idx) = OP*V(:,idx) with normalization */
290:         for (i=eps->nconv;i<nv;i++) {
291:           BVGetColumn(eps->V,i,&v);
292:           STApply(eps->st,v,w);
293:           VecCopy(w,v);
294:           BVRestoreColumn(eps->V,i,&v);
295:           BVNormColumn(eps->V,i,NORM_INFINITY,&norm);
296:           BVScaleColumn(eps->V,i,1/norm);
297:         }
298:         its++;
299:       }
300:       /* Orthonormalize vectors */
301:       for (i=eps->nconv;i<nv;i++) {
302:         BVOrthogonalizeColumn(eps->V,i,NULL,&norm,&breakdown);
303:         if (breakdown) {
304:           BVSetRandomColumn(eps->V,i);
305:           BVOrthogonalizeColumn(eps->V,i,NULL,&norm,&breakdown);
306:         }
307:         BVScaleColumn(eps->V,i,1/norm);
308:       }
309:       nxtort = PetscMin(its+idort,nxtsrr);
310:     } while (its<nxtsrr);
311:   }

313:   PetscFree3(rsd,itrsd,itrsdold);
314:   BVDestroy(&AV);
315:   /* truncate Schur decomposition and change the state to raw so that
316:      DSVectors() computes eigenvectors from scratch */
317:   DSSetDimensions(eps->ds,eps->nconv,0,0,0);
318:   DSSetState(eps->ds,DS_STATE_RAW);
319:   return(0);
320: }

324: PetscErrorCode EPSDestroy_Subspace(EPS eps)
325: {

329:   PetscFree(eps->data);
330:   return(0);
331: }

335: PETSC_EXTERN PetscErrorCode EPSCreate_Subspace(EPS eps)
336: {
338:   eps->ops->setup                = EPSSetUp_Subspace;
339:   eps->ops->solve                = EPSSolve_Subspace;
340:   eps->ops->destroy              = EPSDestroy_Subspace;
341:   eps->ops->backtransform        = EPSBackTransform_Default;
342:   eps->ops->computevectors       = EPSComputeVectors_Schur;
343:   return(0);
344: }

slepc-3.7.4/src/eps/impls/subspace/index.html0000644000175000017500000000261013107004621020466 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

subspace.c
makefile
slepc-3.7.4/src/eps/impls/makefile.html0000644000175000017500000000462213107004621017334 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepceps
DIRS     = power subspace krylov davidson cg ciss lapack external
LOCDIR   = src/eps/impls/
MANSEC   = EPS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/ciss/0000755000175000017500000000000013107004621015626 5ustar jromanjromanslepc-3.7.4/src/eps/impls/ciss/makefile0000644000175000017500000000215113107004621017325 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = ciss.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/ciss/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/ciss/ciss.c.html0000644000175000017500000046262013107004621017710 0ustar jromanjroman
Actual source code: ciss.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "ciss"

  5:    Method: Contour Integral Spectral Slicing

  7:    Algorithm:

  9:        Contour integral based on Sakurai-Sugiura method to construct a
 10:        subspace, with various eigenpair extractions (Rayleigh-Ritz,
 11:        explicit moment).

 13:    Based on code contributed by Y. Maeda, T. Sakurai.

 15:    References:

 17:        [1] T. Sakurai and H. Sugiura, "A projection method for generalized
 18:            eigenvalue problems", J. Comput. Appl. Math. 159:119-128, 2003.

 20:        [2] T. Sakurai and H. Tadano, "CIRR: a Rayleigh-Ritz type method with
 21:            contour integral for generalized eigenvalue problems", Hokkaido
 22:            Math. J. 36:745-757, 2007.

 24:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 25:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 26:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 28:    This file is part of SLEPc.

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

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

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

 44: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
 45: #include <slepcblaslapack.h>

 47: typedef struct {
 48:   /* parameters */
 49:   PetscInt          N;          /* number of integration points (32) */
 50:   PetscInt          L;          /* block size (16) */
 51:   PetscInt          M;          /* moment degree (N/4 = 4) */
 52:   PetscReal         delta;      /* threshold of singular value (1e-12) */
 53:   PetscInt          L_max;      /* maximum number of columns of the source matrix V */
 54:   PetscReal         spurious_threshold; /* discard spurious eigenpairs */
 55:   PetscBool         isreal;     /* A and B are real */
 56:   PetscInt          refine_inner;
 57:   PetscInt          refine_blocksize;
 58:   /* private data */
 59:   PetscReal         *sigma;     /* threshold for numerical rank */
 60:   PetscInt          num_subcomm;
 61:   PetscInt          subcomm_id;
 62:   PetscInt          num_solve_point;
 63:   PetscScalar       *weight;
 64:   PetscScalar       *omega;
 65:   PetscScalar       *pp;
 66:   BV                V;
 67:   BV                S;
 68:   BV                pV;
 69:   BV                Y;
 70:   Vec               xsub;
 71:   Vec               xdup;
 72:   KSP               *ksp;
 73:   Mat               *kspMat;
 74:   PetscBool         useconj;
 75:   PetscReal         est_eig;
 76:   VecScatter        scatterin;
 77:   Mat               pA,pB;
 78:   PetscSubcomm      subcomm;
 79:   PetscBool         usest;
 80:   PetscBool         usest_set;  /* whether the user set the usest flag or not */
 81:   EPSCISSQuadRule   quad;
 82:   EPSCISSExtraction extraction;
 83: } EPS_CISS;

 87: static PetscErrorCode SetSolverComm(EPS eps)
 88: {
 90:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
 91:   PetscInt       N = ctx->N;

 94:   if (ctx->useconj) N = N/2;
 95:   if (!ctx->subcomm) {
 96:     PetscSubcommCreate(PetscObjectComm((PetscObject)eps),&ctx->subcomm);
 97:     PetscSubcommSetNumber(ctx->subcomm,ctx->num_subcomm);
 98:     PetscSubcommSetType(ctx->subcomm,PETSC_SUBCOMM_INTERLACED);
 99:     PetscLogObjectMemory((PetscObject)eps,sizeof(PetscSubcomm));
100:     PetscSubcommSetFromOptions(ctx->subcomm);
101:   }
102:   ctx->subcomm_id = ctx->subcomm->color;
103:   ctx->num_solve_point = N / ctx->num_subcomm;
104:   if ((N%ctx->num_subcomm) > ctx->subcomm_id) ctx->num_solve_point+=1;
105:   return(0);
106: }

110: static PetscErrorCode CISSRedundantMat(EPS eps)
111: {
113:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
114:   Mat            A,B;
115:   PetscInt       nmat;

118:   STGetNumMatrices(eps->st,&nmat);
119:   if (ctx->subcomm->n != 1) {
120:     STGetOperators(eps->st,0,&A);
121:     MatCreateRedundantMatrix(A,ctx->subcomm->n,PetscSubcommChild(ctx->subcomm),MAT_INITIAL_MATRIX,&ctx->pA);
122:     if (nmat>1) {
123:       STGetOperators(eps->st,1,&B);
124:       MatCreateRedundantMatrix(B,ctx->subcomm->n,PetscSubcommChild(ctx->subcomm),MAT_INITIAL_MATRIX,&ctx->pB);
125:     } else ctx->pB = NULL;
126:   } else {
127:     ctx->pA = NULL;
128:     ctx->pB = NULL;
129:   }
130:   return(0);
131: }

135: static PetscErrorCode CISSScatterVec(EPS eps)
136: {
138:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
139:   IS             is1,is2;
140:   Vec            v0;
141:   PetscInt       i,j,k,mstart,mend,mlocal;
142:   PetscInt       *idx1,*idx2,mloc_sub;

145:   MatCreateVecs(ctx->pA,&ctx->xsub,NULL);
146:   MatGetLocalSize(ctx->pA,&mloc_sub,NULL);
147:   VecCreateMPI(PetscSubcommContiguousParent(ctx->subcomm),mloc_sub,PETSC_DECIDE,&ctx->xdup);
148:   if (!ctx->scatterin) {
149:     BVGetColumn(ctx->V,0,&v0);
150:     VecGetOwnershipRange(v0,&mstart,&mend);
151:     mlocal = mend - mstart;
152:     PetscMalloc2(ctx->subcomm->n*mlocal,&idx1,ctx->subcomm->n*mlocal,&idx2);
153:     j = 0;
154:     for (k=0;k<ctx->subcomm->n;k++) {
155:       for (i=mstart;i<mend;i++) {
156:         idx1[j]   = i;
157:         idx2[j++] = i + eps->n*k;
158:       }
159:     }
160:     ISCreateGeneral(PetscObjectComm((PetscObject)eps),ctx->subcomm->n*mlocal,idx1,PETSC_COPY_VALUES,&is1);
161:     ISCreateGeneral(PetscObjectComm((PetscObject)eps),ctx->subcomm->n*mlocal,idx2,PETSC_COPY_VALUES,&is2);
162:     VecScatterCreate(v0,is1,ctx->xdup,is2,&ctx->scatterin);
163:     ISDestroy(&is1);
164:     ISDestroy(&is2);
165:     PetscFree2(idx1,idx2);
166:     BVRestoreColumn(ctx->V,0,&v0);
167:   }
168:   return(0);
169: }

173: static PetscErrorCode SetPathParameter(EPS eps)
174: {
176:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
177:   PetscInt       i,j;
178:   PetscScalar    center=0.0,tmp,tmp2,*omegai;
179:   PetscReal      theta,radius=1.0,vscale,a,b,c,d,max_w=0.0,rgscale;
180: #if defined(PETSC_USE_COMPLEX) 
181:   PetscReal      start_ang,end_ang;
182: #endif
183:   PetscBool      isring=PETSC_FALSE,isellipse=PETSC_FALSE,isinterval=PETSC_FALSE;

186:   PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);
187:   PetscObjectTypeCompare((PetscObject)eps->rg,RGRING,&isring);
188:   PetscObjectTypeCompare((PetscObject)eps->rg,RGINTERVAL,&isinterval);
189:   RGGetScale(eps->rg,&rgscale);
190:   PetscMalloc1(ctx->N+1l,&omegai);
191:   RGComputeContour(eps->rg,ctx->N,ctx->omega,omegai);
192:   if (isellipse) {
193:     RGEllipseGetParameters(eps->rg,&center,&radius,&vscale);
194:     for (i=0;i<ctx->N;i++) {
195: #if defined(PETSC_USE_COMPLEX) 
196:       theta = 2.0*PETSC_PI*(i+0.5)/ctx->N;
197:       ctx->pp[i] = PetscCosReal(theta)+vscale*PetscSinReal(theta)*PETSC_i;
198:       ctx->weight[i] = rgscale*radius*(vscale*PetscCosReal(theta)+PetscSinReal(theta)*PETSC_i)/(PetscReal)ctx->N;
199: #else
200:       theta = (PETSC_PI/ctx->N)*(i+0.5);
201:       ctx->pp[i] = PetscCosReal(theta);
202:       ctx->weight[i] = PetscCosReal((ctx->N-1)*theta)/ctx->N;
203:       ctx->omega[i] = rgscale*(center + radius*ctx->pp[i]);
204: #endif
205:     }
206:   } else if (ctx->quad == EPS_CISS_QUADRULE_CHEBYSHEV) {
207:     for (i=0;i<ctx->N;i++) {
208:       theta = (PETSC_PI/ctx->N)*(i+0.5);
209:       ctx->pp[i] = PetscCosReal(theta);
210:       ctx->weight[i] = PetscCosReal((ctx->N-1)*theta)/ctx->N;
211:     }
212:     if (isinterval) {
213:       RGIntervalGetEndpoints(eps->rg,&a,&b,&c,&d);
214:       if ((c!=d || c!=0.0) && (a!=b || a!=0.0)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Endpoints of the imaginary axis or the real axis must be both zero");
215:       for (i=0;i<ctx->N;i++) {
216:         if (c==d) ctx->omega[i] = ((b-a)*(ctx->pp[i]+1.0)/2.0+a)*rgscale;
217:         if (a==b) {
218: #if defined(PETSC_USE_COMPLEX) 
219:           ctx->omega[i] = ((d-c)*(ctx->pp[i]+1.0)/2.0+c)*rgscale*PETSC_i;
220: #else
221:           SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Integration points on a vertical line require complex arithmetic");
222: #endif
223:         }
224:       }
225:     }
226:     if (isring) {  /* only supported in complex scalars */
227: #if defined(PETSC_USE_COMPLEX) 
228:       RGRingGetParameters(eps->rg,&center,&radius,&vscale,&start_ang,&end_ang,NULL);
229:       for (i=0;i<ctx->N;i++) {
230:         theta = (start_ang*2.0+(end_ang-start_ang)*(PetscRealPart(ctx->pp[i])+1.0))*PETSC_PI;
231:         ctx->omega[i] = rgscale*(center + radius*(PetscCosReal(theta)+PETSC_i*vscale*PetscSinReal(theta)));
232:       }
233: #endif
234:     }
235:   } else {
236:     if (isinterval) {
237:       RGIntervalGetEndpoints(eps->rg,&a,&b,&c,&d);
238:       center = rgscale*((b+a)/2.0+(d+c)/2.0*PETSC_PI);
239:       radius = PetscSqrtReal(PetscPowRealInt(rgscale*(b-a)/2.0,2)+PetscPowRealInt(rgscale*(d-c)/2.0,2));
240:     } else if (isring) {
241:       RGRingGetParameters(eps->rg,&center,&radius,NULL,NULL,NULL,NULL);
242:       center *= rgscale;
243:       radius *= rgscale;
244:     }
245:     for (i=0;i<ctx->N;i++) { 
246:       ctx->pp[i] = (ctx->omega[i]-center)/radius;
247:       tmp = 1; tmp2 = 1;
248:       for (j=0;j<ctx->N;j++) {
249:         tmp *= ctx->omega[j];
250:         if (i != j) tmp2 *= ctx->omega[j]-ctx->omega[i];
251:       }
252:       ctx->weight[i] = tmp/tmp2;
253:       max_w = PetscMax(PetscAbsScalar(ctx->weight[i]),max_w);
254:     }
255:     for (i=0;i<ctx->N;i++) ctx->weight[i] /= (PetscScalar)max_w;
256:   }
257:   PetscFree(omegai);
258:   return(0);
259: }

263: static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1)
264: {
266:   PetscInt       i,j,nlocal;
267:   PetscScalar    *vdata;
268:   Vec            x;

271:   BVGetSizes(V,&nlocal,NULL,NULL);
272:   for (i=i0;i<i1;i++) {
273:     BVSetRandomColumn(V,i);
274:     BVGetColumn(V,i,&x);
275:     VecGetArray(x,&vdata);
276:     for (j=0;j<nlocal;j++) {
277:       vdata[j] = PetscRealPart(vdata[j]);
278:       if (PetscRealPart(vdata[j]) < 0.5) vdata[j] = -1.0;
279:       else vdata[j] = 1.0;
280:     }
281:     VecRestoreArray(x,&vdata);
282:     BVRestoreColumn(V,i,&x);
283:   }
284:   return(0);
285: }

289: static PetscErrorCode VecScatterVecs(EPS eps,BV Vin,PetscInt n)
290: {
291:   PetscErrorCode    ierr;
292:   EPS_CISS          *ctx = (EPS_CISS*)eps->data;
293:   PetscInt          i;
294:   Vec               vi,pvi;
295:   const PetscScalar *array;

298:   for (i=0;i<n;i++) {
299:     BVGetColumn(Vin,i,&vi);
300:     VecScatterBegin(ctx->scatterin,vi,ctx->xdup,INSERT_VALUES,SCATTER_FORWARD);
301:     VecScatterEnd(ctx->scatterin,vi,ctx->xdup,INSERT_VALUES,SCATTER_FORWARD);
302:     BVRestoreColumn(Vin,i,&vi);
303:     VecGetArrayRead(ctx->xdup,&array);
304:     VecPlaceArray(ctx->xsub,array);
305:     BVGetColumn(ctx->pV,i,&pvi);
306:     VecCopy(ctx->xsub,pvi);
307:     BVRestoreColumn(ctx->pV,i,&pvi);
308:     VecResetArray(ctx->xsub);
309:     VecRestoreArrayRead(ctx->xdup,&array);
310:   }
311:   return(0);
312: }

316: static PetscErrorCode SolveLinearSystem(EPS eps,Mat A,Mat B,BV V,PetscInt L_start,PetscInt L_end,PetscBool initksp)
317: {
319:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
320:   PetscInt       i,j,p_id;
321:   Mat            Fz;
322:   PC             pc;
323:   Vec            Bvj,vj,yj;
324:   KSP            ksp;

327:   BVCreateVec(V,&Bvj);
328:   if (ctx->usest) {
329:     MatDuplicate(A,MAT_DO_NOT_COPY_VALUES,&Fz);
330:   }
331:   for (i=0;i<ctx->num_solve_point;i++) {
332:     p_id = i*ctx->subcomm->n + ctx->subcomm_id;
333:     if (!ctx->usest && initksp == PETSC_TRUE) {
334:       MatDuplicate(A,MAT_DO_NOT_COPY_VALUES,&ctx->kspMat[i]);
335:       MatCopy(A,ctx->kspMat[i],DIFFERENT_NONZERO_PATTERN);
336:       if (B) {
337:         MatAXPY(ctx->kspMat[i],-ctx->omega[p_id],B,DIFFERENT_NONZERO_PATTERN);
338:       } else {
339:         MatShift(ctx->kspMat[i],-ctx->omega[p_id]);
340:       }
341:       KSPSetOperators(ctx->ksp[i],ctx->kspMat[i],ctx->kspMat[i]);
342:       KSPSetType(ctx->ksp[i],KSPPREONLY);
343:       KSPGetPC(ctx->ksp[i],&pc);
344:       PCSetType(pc,PCLU);
345:       KSPSetFromOptions(ctx->ksp[i]);
346:     } else if (ctx->usest) {
347:       STSetShift(eps->st,ctx->omega[p_id]);
348:       STGetKSP(eps->st,&ksp);
349:     }
350:     for (j=L_start;j<L_end;j++) {
351:       BVGetColumn(V,j,&vj);
352:       BVGetColumn(ctx->Y,i*ctx->L_max+j,&yj);
353:       if (B) {
354:         MatMult(B,vj,Bvj);
355:         if (ctx->usest) {
356:           KSPSolve(ksp,Bvj,yj);
357:         } else {
358:           KSPSolve(ctx->ksp[i],Bvj,yj);
359:         }
360:       } else {
361:         if (ctx->usest) {
362:           KSPSolve(ksp,vj,yj);
363:         } else {
364:           KSPSolve(ctx->ksp[i],vj,yj);
365:         }
366:       }
367:       BVRestoreColumn(V,j,&vj);
368:       BVRestoreColumn(ctx->Y,i*ctx->L_max+j,&yj);
369:     }
370:     if (ctx->usest && i<ctx->num_solve_point-1) {  KSPReset(ksp); }
371:   }
372:   if (ctx->usest) { MatDestroy(&Fz); }
373:   VecDestroy(&Bvj);
374:   return(0);
375: }

377: #if defined(PETSC_USE_COMPLEX)
380: static PetscErrorCode EstimateNumberEigs(EPS eps,PetscInt *L_add)
381: {
383:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
384:   PetscInt       i,j,p_id;
385:   PetscScalar    tmp,m = 1,sum = 0.0;
386:   PetscReal      eta;
387:   Vec            v,vtemp,vj,yj;

390:   BVGetColumn(ctx->Y,0,&yj);
391:   VecDuplicate(yj,&v);
392:   BVRestoreColumn(ctx->Y,0,&yj);
393:   BVCreateVec(ctx->V,&vtemp);
394:   for (j=0;j<ctx->L;j++) {
395:     VecSet(v,0);
396:     for (i=0;i<ctx->num_solve_point; i++) {
397:       p_id = i*ctx->subcomm->n + ctx->subcomm_id;
398:       BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);
399:       BVMultVec(ctx->Y,ctx->weight[p_id],1,v,&m);
400:     }
401:     BVGetColumn(ctx->V,j,&vj);
402:     if (ctx->pA) {
403:       VecSet(vtemp,0);
404:       VecScatterBegin(ctx->scatterin,v,vtemp,ADD_VALUES,SCATTER_REVERSE);
405:       VecScatterEnd(ctx->scatterin,v,vtemp,ADD_VALUES,SCATTER_REVERSE);
406:       VecDot(vj,vtemp,&tmp);
407:     } else {
408:       VecDot(vj,v,&tmp);
409:     }
410:     BVRestoreColumn(ctx->V,j,&vj);
411:     if (ctx->useconj) sum += PetscRealPart(tmp)*2;
412:     else sum += tmp;
413:   }
414:   ctx->est_eig = PetscAbsScalar(sum/(PetscReal)ctx->L);
415:   eta = PetscPowReal(10.0,-PetscLog10Real(eps->tol)/ctx->N);
416:   PetscInfo1(eps,"Estimation_#Eig %f\n",(double)ctx->est_eig);
417:   *L_add = (PetscInt)PetscCeilReal((ctx->est_eig*eta)/ctx->M) - ctx->L;
418:   if (*L_add < 0) *L_add = 0;
419:   if (*L_add>ctx->L_max-ctx->L) {
420:     PetscInfo(eps,"Number of eigenvalues around the contour path may be too large\n");
421:     *L_add = ctx->L_max-ctx->L;
422:   }
423:   VecDestroy(&v);
424:   VecDestroy(&vtemp);
425:   return(0);
426: }
427: #endif

431: static PetscErrorCode CalcMu(EPS eps,PetscScalar *Mu)
432: {
434:   PetscMPIInt    sub_size,len;
435:   PetscInt       i,j,k,s;
436:   PetscScalar    *m,*temp,*temp2,*ppk,alp;
437:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
438:   Mat            M;

441:   MPI_Comm_size(PetscSubcommChild(ctx->subcomm),&sub_size);
442:   PetscMalloc3(ctx->num_solve_point*ctx->L*(ctx->L+1),&temp,2*ctx->M*ctx->L*ctx->L,&temp2,ctx->num_solve_point,&ppk);
443:   MatCreateSeqDense(PETSC_COMM_SELF,ctx->L,ctx->L_max*ctx->num_solve_point,NULL,&M);
444:   for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] = 0;
445:   BVSetActiveColumns(ctx->Y,0,ctx->L_max*ctx->num_solve_point);
446:   if (ctx->pA) {
447:     BVSetActiveColumns(ctx->pV,0,ctx->L);
448:     BVDot(ctx->Y,ctx->pV,M);
449:   } else {
450:     BVSetActiveColumns(ctx->V,0,ctx->L);
451:     BVDot(ctx->Y,ctx->V,M);
452:   }
453:   MatDenseGetArray(M,&m);
454:   for (i=0;i<ctx->num_solve_point;i++) {
455:     for (j=0;j<ctx->L;j++) {
456:       for (k=0;k<ctx->L;k++) {
457:         temp[k+j*ctx->L+i*ctx->L*ctx->L]=m[k+j*ctx->L+i*ctx->L*ctx->L_max];
458:       }
459:     }
460:   }
461:   MatDenseRestoreArray(M,&m);
462:   for (i=0;i<ctx->num_solve_point;i++) ppk[i] = 1;
463:   for (k=0;k<2*ctx->M;k++) {
464:     for (j=0;j<ctx->L;j++) {
465:       for (i=0;i<ctx->num_solve_point;i++) {
466:         alp = ppk[i]*ctx->weight[i*ctx->subcomm->n + ctx->subcomm_id];
467:         for (s=0;s<ctx->L;s++) {
468:           if (ctx->useconj) temp2[s+(j+k*ctx->L)*ctx->L] += PetscRealPart(alp*temp[s+(j+i*ctx->L)*ctx->L])*2;
469:           else temp2[s+(j+k*ctx->L)*ctx->L] += alp*temp[s+(j+i*ctx->L)*ctx->L];
470:         }
471:       }
472:     }
473:     for (i=0;i<ctx->num_solve_point;i++)
474:       ppk[i] *= ctx->pp[i*ctx->subcomm->n + ctx->subcomm_id];
475:   }
476:   for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] /= sub_size;
477:   PetscMPIIntCast(2*ctx->M*ctx->L*ctx->L,&len);
478:   MPI_Allreduce(temp2,Mu,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)eps));
479:   PetscFree3(temp,temp2,ppk);
480:   MatDestroy(&M);
481:   return(0);
482: }

486: static PetscErrorCode BlockHankel(EPS eps,PetscScalar *Mu,PetscInt s,PetscScalar *H)
487: {
488:   EPS_CISS *ctx = (EPS_CISS*)eps->data;
489:   PetscInt i,j,k,L=ctx->L,M=ctx->M;

492:   for (k=0;k<L*M;k++)
493:     for (j=0;j<M;j++)
494:       for (i=0;i<L;i++)
495:         H[j*L+i+k*L*M] = Mu[i+k*L+(j+s)*L*L];
496:   return(0);
497: }

501: static PetscErrorCode SVD_H0(EPS eps,PetscScalar *S,PetscInt *K)
502: {
503: #if defined(PETSC_MISSING_LAPACK_GESVD)
505:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable");
506: #else
508:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
509:   PetscInt       i,ml=ctx->L*ctx->M;
510:   PetscBLASInt   m,n,lda,ldu,ldvt,lwork,info;
511:   PetscScalar    *work;
512: #if defined(PETSC_USE_COMPLEX)
513:   PetscReal      *rwork;
514: #endif

517:   PetscMalloc1(5*ml,&work);
518: #if defined(PETSC_USE_COMPLEX)
519:   PetscMalloc1(5*ml,&rwork);
520: #endif
521:   PetscBLASIntCast(ml,&m);
522:   n = m; lda = m; ldu = m; ldvt = m; lwork = 5*m;
523:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
524: #if defined(PETSC_USE_COMPLEX)
525:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,rwork,&info));
526: #else
527:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,&info));
528: #endif
529:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);
530:   PetscFPTrapPop();
531:   (*K) = 0;
532:   for (i=0;i<ml;i++) {
533:     if (ctx->sigma[i]/PetscMax(ctx->sigma[0],1)>ctx->delta) (*K)++;
534:   }
535:   PetscFree(work);
536: #if defined(PETSC_USE_COMPLEX)
537:   PetscFree(rwork);
538: #endif
539:   return(0);
540: #endif
541: }

545: static PetscErrorCode ConstructS(EPS eps)
546: {
548:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
549:   PetscInt       i,j,k,vec_local_size,p_id;
550:   Vec            v,sj,yj;
551:   PetscScalar    *ppk, *v_data, m = 1;

554:   BVGetSizes(ctx->Y,&vec_local_size,NULL,NULL);
555:   PetscMalloc1(ctx->num_solve_point,&ppk);
556:   for (i=0;i<ctx->num_solve_point;i++) ppk[i] = 1;
557:   BVGetColumn(ctx->Y,0,&yj);
558:   VecDuplicate(yj,&v);
559:   BVRestoreColumn(ctx->Y,0,&yj);
560:   for (k=0;k<ctx->M;k++) {
561:     for (j=0;j<ctx->L;j++) {
562:       VecSet(v,0);
563:       for (i=0;i<ctx->num_solve_point;i++) {
564:         p_id = i*ctx->subcomm->n + ctx->subcomm_id;
565:         BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);
566:         BVMultVec(ctx->Y,ppk[i]*ctx->weight[p_id],1.0,v,&m);
567:       }
568:       if (ctx->useconj) {
569:         VecGetArray(v,&v_data);
570:         for (i=0;i<vec_local_size;i++) v_data[i] = PetscRealPart(v_data[i])*2;
571:         VecRestoreArray(v,&v_data);
572:       }
573:       BVGetColumn(ctx->S,k*ctx->L+j,&sj);
574:       if (ctx->pA) {
575:         VecSet(sj,0);
576:         VecScatterBegin(ctx->scatterin,v,sj,ADD_VALUES,SCATTER_REVERSE);
577:         VecScatterEnd(ctx->scatterin,v,sj,ADD_VALUES,SCATTER_REVERSE);
578:       } else {
579:         VecCopy(v,sj);
580:       }
581:       BVRestoreColumn(ctx->S,k*ctx->L+j,&sj);
582:     }
583:     for (i=0;i<ctx->num_solve_point;i++) {
584:       p_id = i*ctx->subcomm->n + ctx->subcomm_id;
585:       ppk[i] *= ctx->pp[p_id];
586:     }
587:   }
588:   PetscFree(ppk);
589:   VecDestroy(&v);
590:   return(0);
591: }

595: static PetscErrorCode SVD_S(BV S,PetscInt ml,PetscReal delta,PetscReal *sigma,PetscInt *K)
596: {
597: #if defined(PETSC_MISSING_LAPACK_GESVD)
599:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable");
600: #else
602:   PetscInt       i,j,k,local_size;
603:   PetscMPIInt    len;
604:   PetscScalar    *work,*temp,*B,*tempB,*s_data,*Q1,*Q2,*temp2,alpha=1,beta=0;
605:   PetscBLASInt   l,m,n,lda,ldu,ldvt,lwork,info,ldb,ldc;
606: #if defined(PETSC_USE_COMPLEX)
607:   PetscReal      *rwork;
608: #endif

611:   BVGetSizes(S,&local_size,NULL,NULL);
612:   BVGetArray(S,&s_data);
613:   PetscMalloc7(ml*ml,&temp,ml*ml,&temp2,local_size*ml,&Q1,local_size*ml,&Q2,ml*ml,&B,ml*ml,&tempB,5*ml,&work);
614:   PetscMemzero(B,ml*ml*sizeof(PetscScalar));
615: #if defined(PETSC_USE_COMPLEX)
616:   PetscMalloc1(5*ml,&rwork);
617: #endif
618:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);

620:   for (i=0;i<ml;i++) B[i*ml+i]=1;

622:   for (k=0;k<2;k++) {
623:     PetscBLASIntCast(local_size,&m);
624:     PetscBLASIntCast(ml,&l);
625:     n = l; lda = m; ldb = m; ldc = l;
626:     if (k == 0) {
627:       PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&l,&n,&m,&alpha,s_data,&lda,s_data,&ldb,&beta,temp,&ldc));
628:     } else if ((k%2)==1) {
629:       PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&l,&n,&m,&alpha,Q1,&lda,Q1,&ldb,&beta,temp,&ldc));
630:     } else {
631:       PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&l,&n,&m,&alpha,Q2,&lda,Q2,&ldb,&beta,temp,&ldc));
632:     }
633:     PetscMemzero(temp2,ml*ml*sizeof(PetscScalar));
634:     PetscMPIIntCast(ml*ml,&len);
635:     MPI_Allreduce(temp,temp2,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)S));

637:     PetscBLASIntCast(ml,&m);
638:     n = m; lda = m; lwork = 5*m, ldu = 1; ldvt = 1;
639: #if defined(PETSC_USE_COMPLEX)
640:     PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("O","N",&m,&n,temp2,&lda,sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,rwork,&info));
641: #else
642:     PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("O","N",&m,&n,temp2,&lda,sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,&info));
643: #endif
644:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);

646:     PetscBLASIntCast(local_size,&l);
647:     PetscBLASIntCast(ml,&n);
648:     m = n; lda = l; ldb = m; ldc = l;
649:     if (k==0) {
650:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&l,&n,&m,&alpha,s_data,&lda,temp2,&ldb,&beta,Q1,&ldc));
651:     } else if ((k%2)==1) {
652:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&l,&n,&m,&alpha,Q1,&lda,temp2,&ldb,&beta,Q2,&ldc));
653:     } else {
654:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&l,&n,&m,&alpha,Q2,&lda,temp2,&ldb,&beta,Q1,&ldc));
655:     }

657:     PetscBLASIntCast(ml,&l);
658:     m = l; n = l; lda = l; ldb = m; ldc = l;
659:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&l,&n,&m,&alpha,B,&lda,temp2,&ldb,&beta,tempB,&ldc));
660:     for (i=0;i<ml;i++) {
661:       sigma[i] = sqrt(sigma[i]);
662:       for (j=0;j<local_size;j++) {
663:         if ((k%2)==1) Q2[j+i*local_size]/=sigma[i];
664:         else Q1[j+i*local_size]/=sigma[i];
665:       }
666:       for (j=0;j<ml;j++) {
667:         B[j+i*ml]=tempB[j+i*ml]*sigma[i];
668:       }
669:     }
670:   }

672:   PetscBLASIntCast(ml,&m);
673:   n = m; lda = m; ldu=1; ldvt=1;
674: #if defined(PETSC_USE_COMPLEX)
675:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","O",&m,&n,B,&lda,sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,rwork,&info));
676: #else
677:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","O",&m,&n,B,&lda,sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,&info));
678: #endif
679:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);

681:   PetscBLASIntCast(local_size,&l);
682:   PetscBLASIntCast(ml,&n);
683:   m = n; lda = l; ldb = m; ldc = l;
684:   if ((k%2)==1) {
685:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","T",&l,&n,&m,&alpha,Q1,&lda,B,&ldb,&beta,s_data,&ldc));
686:   } else {
687:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","T",&l,&n,&m,&alpha,Q2,&lda,B,&ldb,&beta,s_data,&ldc));
688:   }

690:   PetscFPTrapPop();
691:   BVRestoreArray(S,&s_data);

693:   (*K) = 0;
694:   for (i=0;i<ml;i++) {
695:     if (sigma[i]/PetscMax(sigma[0],1)>delta) (*K)++;
696:   }
697:   PetscFree7(temp,temp2,Q1,Q2,B,tempB,work);
698: #if defined(PETSC_USE_COMPLEX)
699:   PetscFree(rwork);
700: #endif
701:   return(0);
702: #endif
703: }

707: static PetscErrorCode isGhost(EPS eps,PetscInt ld,PetscInt nv,PetscBool *fl)
708: {
710:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
711:   PetscInt       i,j;
712:   PetscScalar    *pX;
713:   PetscReal      *tau,s1,s2,tau_max=0.0;

716:   PetscMalloc1(nv,&tau);
717:   DSVectors(eps->ds,DS_MAT_X,NULL,NULL);
718:   DSGetArray(eps->ds,DS_MAT_X,&pX);

720:   for (i=0;i<nv;i++) {
721:     s1 = 0;
722:     s2 = 0;
723:     for (j=0;j<nv;j++) {
724:       s1 += PetscAbsScalar(PetscPowScalarInt(pX[i*ld+j],2));
725:       s2 += PetscPowRealInt(PetscAbsScalar(pX[i*ld+j]),2)/ctx->sigma[j];
726:     }
727:     tau[i] = s1/s2;
728:     tau_max = PetscMax(tau_max,tau[i]);
729:   }
730:   DSRestoreArray(eps->ds,DS_MAT_X,&pX);
731:   for (i=0;i<nv;i++) {
732:     tau[i] /= tau_max;
733:   }
734:   for (i=0;i<nv;i++) {
735:     if (tau[i]>=ctx->spurious_threshold) fl[i] = PETSC_TRUE;
736:     else fl[i] = PETSC_FALSE;
737:   }
738:   PetscFree(tau);
739:   return(0);
740: }

744: static PetscErrorCode rescale_eig(EPS eps,PetscInt nv)
745: {
747:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
748:   PetscInt       i;
749:   PetscScalar    center;
750:   PetscReal      radius,a,b,c,d,rgscale;
751: #if defined(PETSC_USE_COMPLEX) 
752:   PetscReal      start_ang,end_ang,vscale,theta;
753: #endif
754:   PetscBool      isring,isellipse,isinterval;

757:   PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);
758:   PetscObjectTypeCompare((PetscObject)eps->rg,RGRING,&isring);
759:   PetscObjectTypeCompare((PetscObject)eps->rg,RGINTERVAL,&isinterval);
760:   RGGetScale(eps->rg,&rgscale);
761:   if (isinterval) {
762:     RGIntervalGetEndpoints(eps->rg,NULL,NULL,&c,&d);
763:     if (c==d) {
764:       for (i=0;i<nv;i++) {
765: #if defined(PETSC_USE_COMPLEX)
766:         eps->eigr[i] = PetscRealPart(eps->eigr[i]);
767: #else
768:         eps->eigi[i] = 0;
769: #endif
770:       }
771:     }
772:   }
773:   if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) {
774:     if (isellipse) {
775:       RGEllipseGetParameters(eps->rg,&center,&radius,NULL);
776:       for (i=0;i<nv;i++) eps->eigr[i] = rgscale*(center + radius*eps->eigr[i]);
777:     } else if (isinterval) {
778:       RGIntervalGetEndpoints(eps->rg,&a,&b,&c,&d);
779:       if (ctx->quad == EPS_CISS_QUADRULE_CHEBYSHEV) {
780:         for (i=0;i<nv;i++) {
781:           if (c==d) eps->eigr[i] = ((b-a)*(eps->eigr[i]+1.0)/2.0+a)*rgscale;
782:           if (a==b) {
783: #if defined(PETSC_USE_COMPLEX) 
784:             eps->eigr[i] = ((d-c)*(eps->eigr[i]+1.0)/2.0+c)*rgscale*PETSC_i;
785: #else
786:             SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Integration points on a vertical line require complex arithmetic");
787: #endif
788:           }
789:         }
790:       } else {
791:         center = (b+a)/2.0+(d+c)/2.0*PETSC_PI;
792:         radius = PetscSqrtReal(PetscPowRealInt((b-a)/2.0,2)+PetscPowRealInt((d-c)/2.0,2));
793:         for (i=0;i<nv;i++) eps->eigr[i] = center + radius*eps->eigr[i];
794:       }
795:     } else if (isring) {  /* only supported in complex scalars */
796: #if defined(PETSC_USE_COMPLEX) 
797:       RGRingGetParameters(eps->rg,&center,&radius,&vscale,&start_ang,&end_ang,NULL);
798:       if (ctx->quad == EPS_CISS_QUADRULE_CHEBYSHEV) {
799:         for (i=0;i<nv;i++) {
800:           theta = (start_ang*2.0+(end_ang-start_ang)*(PetscRealPart(eps->eigr[i])+1.0))*PETSC_PI;
801:           eps->eigr[i] = rgscale*center + (rgscale*radius+PetscImaginaryPart(eps->eigr[i]))*(PetscCosReal(theta)+PETSC_i*vscale*PetscSinReal(theta));
802:         }
803:       } else {
804:         for (i=0;i<nv;i++) eps->eigr[i] = rgscale*(center + radius*eps->eigr[i]);
805:       }
806: #endif
807:     }
808:   }
809:   return(0);
810: }

814: PetscErrorCode EPSSetUp_CISS(EPS eps)
815: {
817:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
818:   PetscInt       i;
819:   PetscBool      issinvert,istrivial,isring,isellipse,isinterval,flg;
820:   PetscScalar    center;
821:   PetscReal      c,d;
822:   Mat            A;

825:   if (!eps->ncv) eps->ncv = ctx->L_max*ctx->M;
826:   else {
827:     EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);
828:     ctx->L_max = eps->ncv/ctx->M;
829:     if (ctx->L_max == 0) {
830:       ctx->L_max = 1;
831:       eps->ncv = ctx->L_max*ctx->M;
832:     }
833:     if (ctx->L > ctx->L_max) ctx->L = ctx->L_max;
834:   }
835:   if (!eps->max_it) eps->max_it = 1;
836:   if (!eps->mpd) eps->mpd = eps->ncv;
837:   if (!eps->which) eps->which = EPS_ALL;
838:   if (!eps->extraction) { EPSSetExtraction(eps,EPS_RITZ); }
839:   else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
840:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
841:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support user-defined stopping test");
842:   /* check region */
843:   RGIsTrivial(eps->rg,&istrivial);
844:   if (istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"CISS requires a nontrivial region, e.g. -rg_type ellipse ...");
845:   RGGetComplement(eps->rg,&flg);
846:   if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"A region with complement flag set is not allowed");
847:   PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);
848:   PetscObjectTypeCompare((PetscObject)eps->rg,RGRING,&isring);
849:   PetscObjectTypeCompare((PetscObject)eps->rg,RGINTERVAL,&isinterval);
850:   if (!isellipse && !isring && !isinterval) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Currently only implemented for interval, elliptic or ring regions");
851:   if (isring) {
852: #if !defined(PETSC_USE_COMPLEX)
853:     SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Ring region only supported for complex scalars");
854: #endif
855:     ctx->useconj = PETSC_FALSE;
856:   }
857:   if (isellipse) {
858:     RGEllipseGetParameters(eps->rg,&center,NULL,NULL);
859: #if defined(PETSC_USE_COMPLEX)
860:     if (ctx->isreal && PetscImaginaryPart(center) == 0.0) ctx->useconj = PETSC_TRUE;
861:     else ctx->useconj = PETSC_FALSE;
862: #else
863:     ctx->useconj = PETSC_FALSE;
864: #endif
865:   }
866:   if (isinterval) {
867:     RGIntervalGetEndpoints(eps->rg,NULL,NULL,&c,&d);
868: #if defined(PETSC_USE_COMPLEX)
869:     if (ctx->isreal && c==d) ctx->useconj = PETSC_TRUE;
870:     else ctx->useconj = PETSC_FALSE;
871: #else
872:     if (c!=d || c!=0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"In real scalars, endpoints of the imaginary axis must be both zero");
873:     ctx->useconj = PETSC_FALSE;
874: #endif
875:     if (!ctx->quad && c==d) ctx->quad = EPS_CISS_QUADRULE_CHEBYSHEV;
876:   }
877:   if (!ctx->quad) ctx->quad = EPS_CISS_QUADRULE_TRAPEZOIDAL;
878:   /* create split comm */
879:   SetSolverComm(eps);

881:   EPSAllocateSolution(eps,0);
882:   PetscMalloc4(ctx->N,&ctx->weight,ctx->N+1,&ctx->omega,ctx->N,&ctx->pp,ctx->L_max*ctx->M,&ctx->sigma);
883:   PetscLogObjectMemory((PetscObject)eps,3*ctx->N*sizeof(PetscScalar)+ctx->L_max*ctx->N*sizeof(PetscReal));

885:   /* allocate basis vectors */
886:   BVDuplicateResize(eps->V,ctx->L_max*ctx->M,&ctx->S);
887:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->S);
888:   BVDuplicateResize(eps->V,ctx->L_max,&ctx->V);
889:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->V);

891:   STGetOperators(eps->st,0,&A);
892:   PetscObjectTypeCompare((PetscObject)A,MATSHELL,&flg);
893:   if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Matrix type shell is not supported in this solver");

895:   if (!ctx->usest_set) ctx->usest = (ctx->num_subcomm>1)? PETSC_FALSE: PETSC_TRUE;
896:   if (ctx->usest && ctx->num_subcomm>1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The usest flag is not supported when partitions > 1");

898:   CISSRedundantMat(eps);
899:   if (ctx->pA) {
900:     CISSScatterVec(eps);
901:     BVCreate(PetscObjectComm((PetscObject)ctx->xsub),&ctx->pV);
902:     BVSetSizesFromVec(ctx->pV,ctx->xsub,eps->n);
903:     BVSetFromOptions(ctx->pV);
904:     BVResize(ctx->pV,ctx->L_max,PETSC_FALSE);
905:     PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->pV);
906:   }

908:   if (ctx->usest) {
909:     PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&issinvert);
910:     if (!issinvert) { STSetType(eps->st,STSINVERT); }
911:   } else {
912:     STSetType(eps->st,STSHIFT);  /* we are not going to use ST, so avoid problems in case the user provided one */
913:     PetscMalloc2(ctx->num_solve_point,&ctx->ksp,ctx->num_solve_point,&ctx->kspMat);
914:     PetscLogObjectMemory((PetscObject)eps,ctx->num_solve_point*sizeof(KSP)+ctx->num_solve_point*sizeof(Mat));
915:     for (i=0;i<ctx->num_solve_point;i++) {
916:       KSPCreate(PetscSubcommChild(ctx->subcomm),&ctx->ksp[i]);
917:       PetscObjectIncrementTabLevel((PetscObject)ctx->ksp[i],(PetscObject)eps,1);
918:       PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->ksp[i]);
919:       KSPSetOptionsPrefix(ctx->ksp[i],((PetscObject)eps)->prefix);
920:       KSPAppendOptionsPrefix(ctx->ksp[i],"eps_ciss_");
921:       KSPSetErrorIfNotConverged(ctx->ksp[i],PETSC_TRUE);
922:     }
923:   }

925:   if (ctx->pA) {
926:     BVCreate(PetscObjectComm((PetscObject)ctx->xsub),&ctx->Y);
927:     BVSetSizesFromVec(ctx->Y,ctx->xsub,eps->n);
928:     BVSetFromOptions(ctx->Y);
929:     BVResize(ctx->Y,ctx->num_solve_point*ctx->L_max,PETSC_FALSE);
930:   } else {
931:     BVDuplicateResize(eps->V,ctx->num_solve_point*ctx->L_max,&ctx->Y);
932:   }
933:   PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->Y);

935:   if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) {
936:     DSSetType(eps->ds,DSGNHEP);
937:   } else if (eps->isgeneralized) {
938:     if (eps->ishermitian && eps->ispositive) {
939:       DSSetType(eps->ds,DSGHEP);
940:     } else {
941:       DSSetType(eps->ds,DSGNHEP);
942:     }
943:   } else {
944:     if (eps->ishermitian) {
945:       DSSetType(eps->ds,DSHEP);
946:     } else {
947:       DSSetType(eps->ds,DSNHEP);
948:     }
949:   }
950:   DSAllocate(eps->ds,eps->ncv);
951:   EPSSetWorkVecs(eps,2);

953:   /* In GHEP problems, deactivate purification to avoid losing
954:      B-normalization of eigenvectors in EPSComputeVectors_Schur */
955:   eps->purify = PETSC_FALSE;

957: #if !defined(PETSC_USE_COMPLEX)
958:   if (!eps->ishermitian) { PetscInfo(eps,"Warning: complex eigenvalues are not calculated exactly without --with-scalar-type=complex in PETSc\n"); }
959: #endif
960:   return(0);
961: }

965: PetscErrorCode EPSSolve_CISS(EPS eps)
966: {
968:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
969:   Mat            A,B,X,M,pA,pB;
970:   PetscInt       i,j,ld,nmat,L_add=0,nv=0,L_base=ctx->L,inner,nlocal,*inside;
971:   PetscScalar    *Mu,*H0,*H1=NULL,*rr,*temp;
972:   PetscReal      error,max_error;
973:   PetscBool      *fl1;
974:   Vec            si,w[3];
975:   SlepcSC        sc;
976:   PetscRandom    rand;
977: #if defined(PETSC_USE_COMPLEX)
978:   PetscBool      isellipse;
979: #endif

982:   w[0] = eps->work[0];
983:   w[1] = NULL;
984:   w[2] = eps->work[1];
985:   /* override SC settings */
986:   DSGetSlepcSC(eps->ds,&sc);
987:   sc->comparison    = SlepcCompareLargestMagnitude;
988:   sc->comparisonctx = NULL;
989:   sc->map           = NULL;
990:   sc->mapobj        = NULL;
991:   VecGetLocalSize(w[0],&nlocal);
992:   DSGetLeadingDimension(eps->ds,&ld);
993:   STGetNumMatrices(eps->st,&nmat);
994:   STGetOperators(eps->st,0,&A);
995:   if (nmat>1) { STGetOperators(eps->st,1,&B); }
996:   else B = NULL;
997:   SetPathParameter(eps);
998:   CISSVecSetRandom(ctx->V,0,ctx->L);
999:   BVGetRandomContext(ctx->V,&rand);

1001:   if (ctx->pA) {
1002:     VecScatterVecs(eps,ctx->V,ctx->L);
1003:     SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,0,ctx->L,PETSC_TRUE);
1004:   } else {
1005:     SolveLinearSystem(eps,A,B,ctx->V,0,ctx->L,PETSC_TRUE);
1006:   }
1007: #if defined(PETSC_USE_COMPLEX)
1008:   PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);
1009:   if (isellipse) {
1010:     EstimateNumberEigs(eps,&L_add);
1011:   } else {
1012:     L_add = 0;
1013:   }
1014: #else
1015:   L_add = 0;
1016: #endif
1017:   if (L_add>0) {
1018:     PetscInfo2(eps,"Changing L %D -> %D by Estimate #Eig\n",ctx->L,ctx->L+L_add);
1019:     CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);
1020:     if (ctx->pA) {
1021:       VecScatterVecs(eps,ctx->V,ctx->L+L_add);
1022:       SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,ctx->L,ctx->L+L_add,PETSC_FALSE);
1023:     } else {
1024:       SolveLinearSystem(eps,A,B,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);
1025:     }
1026:     ctx->L += L_add;
1027:   }
1028:   PetscMalloc2(ctx->L*ctx->L*ctx->M*2,&Mu,ctx->L*ctx->M*ctx->L*ctx->M,&H0);
1029:   for (i=0;i<ctx->refine_blocksize;i++) {
1030:     CalcMu(eps,Mu);
1031:     BlockHankel(eps,Mu,0,H0);
1032:     SVD_H0(eps,H0,&nv);
1033:     if (ctx->sigma[0]<=ctx->delta || nv < ctx->L*ctx->M || ctx->L == ctx->L_max) break;
1034:     L_add = L_base;
1035:     if (ctx->L+L_add>ctx->L_max) L_add = ctx->L_max-ctx->L;
1036:     PetscInfo2(eps,"Changing L %D -> %D by SVD(H0)\n",ctx->L,ctx->L+L_add);
1037:     CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);
1038:     if (ctx->pA) {
1039:       VecScatterVecs(eps,ctx->V,ctx->L+L_add);
1040:       SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,ctx->L,ctx->L+L_add,PETSC_FALSE);
1041:     } else {
1042:       SolveLinearSystem(eps,A,B,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);
1043:     }
1044:     ctx->L += L_add;
1045:   }
1046:   if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) {
1047:     PetscMalloc1(ctx->L*ctx->M*ctx->L*ctx->M,&H1);
1048:   }

1050:   while (eps->reason == EPS_CONVERGED_ITERATING) {
1051:     eps->its++;
1052:     for (inner=0;inner<=ctx->refine_inner;inner++) {
1053:       if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) {
1054:         CalcMu(eps,Mu);
1055:         BlockHankel(eps,Mu,0,H0);
1056:         SVD_H0(eps,H0,&nv);
1057:         break;
1058:       } else {
1059:         ConstructS(eps);
1060:         BVSetActiveColumns(ctx->S,0,ctx->L);
1061:         BVCopy(ctx->S,ctx->V);
1062:         SVD_S(ctx->S,ctx->L*ctx->M,ctx->delta,ctx->sigma,&nv);
1063:         if (ctx->sigma[0]>ctx->delta && nv==ctx->L*ctx->M && inner!=ctx->refine_inner) {
1064:           if (ctx->pA) {
1065:             VecScatterVecs(eps,ctx->V,ctx->L);
1066:             SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,0,ctx->L,PETSC_FALSE);
1067:           } else {
1068:             SolveLinearSystem(eps,A,B,ctx->V,0,ctx->L,PETSC_FALSE);
1069:           }
1070:         } else break;
1071:       }
1072:     }
1073:     eps->nconv = 0;
1074:     if (nv == 0) eps->reason = EPS_CONVERGED_TOL;
1075:     else {
1076:       DSSetDimensions(eps->ds,nv,0,0,0);
1077:       DSSetState(eps->ds,DS_STATE_RAW);

1079:       if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) {
1080:         BlockHankel(eps,Mu,0,H0);
1081:         BlockHankel(eps,Mu,1,H1);
1082:         DSGetArray(eps->ds,DS_MAT_A,&temp);
1083:         for (j=0;j<nv;j++) {
1084:           for (i=0;i<nv;i++) {
1085:             temp[i+j*ld] = H1[i+j*ctx->L*ctx->M];
1086:           }
1087:         }
1088:         DSRestoreArray(eps->ds,DS_MAT_A,&temp);
1089:         DSGetArray(eps->ds,DS_MAT_B,&temp);
1090:         for (j=0;j<nv;j++) {
1091:           for (i=0;i<nv;i++) {
1092:             temp[i+j*ld] = H0[i+j*ctx->L*ctx->M];
1093:           }
1094:         }
1095:         DSRestoreArray(eps->ds,DS_MAT_B,&temp);
1096:       } else {
1097:         BVSetActiveColumns(ctx->S,0,nv);
1098:         DSGetMat(eps->ds,DS_MAT_A,&pA);
1099:         MatZeroEntries(pA);
1100:         BVMatProject(ctx->S,A,ctx->S,pA);
1101:         DSRestoreMat(eps->ds,DS_MAT_A,&pA);
1102:         if (B) {
1103:           DSGetMat(eps->ds,DS_MAT_B,&pB);
1104:           MatZeroEntries(pB);
1105:           BVMatProject(ctx->S,B,ctx->S,pB);
1106:           DSRestoreMat(eps->ds,DS_MAT_B,&pB);
1107:         }
1108:       }

1110:       DSSolve(eps->ds,eps->eigr,eps->eigi);
1111:       DSVectors(eps->ds,DS_MAT_X,NULL,NULL);

1113:       PetscMalloc3(nv,&fl1,nv,&inside,nv,&rr);
1114:       rescale_eig(eps,nv);
1115:       isGhost(eps,ld,nv,fl1);
1116:       RGCheckInside(eps->rg,nv,eps->eigr,eps->eigi,inside);
1117:       for (i=0;i<nv;i++) {
1118:         if (fl1[i] && inside[i]>=0) {
1119:           rr[i] = 1.0;
1120:           eps->nconv++;
1121:         } else rr[i] = 0.0;
1122:       }
1123:       DSSort(eps->ds,eps->eigr,eps->eigi,rr,NULL,&eps->nconv);
1124:       rescale_eig(eps,nv);
1125:       PetscFree3(fl1,inside,rr);
1126:       BVSetActiveColumns(eps->V,0,nv);
1127:       if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) {
1128:         ConstructS(eps);
1129:         BVSetActiveColumns(ctx->S,0,ctx->L);
1130:         BVCopy(ctx->S,ctx->V);
1131:         BVSetActiveColumns(ctx->S,0,nv);
1132:       }
1133:       BVCopy(ctx->S,eps->V);

1135:       DSVectors(eps->ds,DS_MAT_X,NULL,NULL);
1136:       DSGetMat(eps->ds,DS_MAT_X,&X);
1137:       BVMultInPlace(ctx->S,X,0,eps->nconv);
1138:       if (eps->ishermitian) {
1139:         BVMultInPlace(eps->V,X,0,eps->nconv);
1140:       }
1141:       MatDestroy(&X);
1142:       max_error = 0.0;
1143:       for (i=0;i<eps->nconv;i++) {
1144:         BVGetColumn(ctx->S,i,&si);
1145:         EPSComputeResidualNorm_Private(eps,eps->eigr[i],eps->eigi[i],si,NULL,w,&error);
1146:         (*eps->converged)(eps,eps->eigr[i],eps->eigi[i],error,&error,eps->convergedctx);
1147:         BVRestoreColumn(ctx->S,i,&si);
1148:         max_error = PetscMax(max_error,error);
1149:       }

1151:       if (max_error <= eps->tol) eps->reason = EPS_CONVERGED_TOL;
1152:       else if (eps->its >= eps->max_it) eps->reason = EPS_DIVERGED_ITS;
1153:       else {
1154:         if (eps->nconv > ctx->L) {
1155:           MatCreateSeqDense(PETSC_COMM_SELF,eps->nconv,ctx->L,NULL,&M);
1156:           MatDenseGetArray(M,&temp);
1157:           for (i=0;i<ctx->L*eps->nconv;i++) {
1158:             PetscRandomGetValue(rand,&temp[i]);
1159:             temp[i] = PetscRealPart(temp[i]);
1160:           }
1161:           MatDenseRestoreArray(M,&temp);
1162:           BVSetActiveColumns(ctx->S,0,eps->nconv);
1163:           BVMultInPlace(ctx->S,M,0,ctx->L);
1164:           MatDestroy(&M);
1165:           BVSetActiveColumns(ctx->S,0,ctx->L);
1166:           BVCopy(ctx->S,ctx->V);
1167:         }
1168:         if (ctx->pA) {
1169:           VecScatterVecs(eps,ctx->V,ctx->L);
1170:           SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,0,ctx->L,PETSC_FALSE);
1171:         } else {
1172:           SolveLinearSystem(eps,A,B,ctx->V,0,ctx->L,PETSC_FALSE);
1173:         }
1174:       }
1175:     }
1176:   }
1177:   if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) {
1178:     PetscFree(H1);
1179:   }
1180:   PetscFree2(Mu,H0);
1181:   return(0);
1182: }

1186: static PetscErrorCode EPSCISSSetSizes_CISS(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)
1187: {
1189:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;

1192:   if (ip == PETSC_DECIDE || ip == PETSC_DEFAULT) {
1193:     if (ctx->N!=32) { ctx->N =32; ctx->M = ctx->N/4; }
1194:   } else {
1195:     if (ip<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be > 0");
1196:     if (ip%2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be an even number");
1197:     if (ctx->N!=ip) { ctx->N = ip; ctx->M = ctx->N/4; }
1198:   }
1199:   if (bs == PETSC_DECIDE || bs == PETSC_DEFAULT) {
1200:     ctx->L = 16;
1201:   } else {
1202:     if (bs<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be > 0");
1203:     if (bs>ctx->L_max) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be less than or equal to the maximum number of block size");
1204:     ctx->L = bs;
1205:   }
1206:   if (ms == PETSC_DECIDE || ms == PETSC_DEFAULT) {
1207:     ctx->M = ctx->N/4;
1208:   } else {
1209:     if (ms<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be > 0");
1210:     if (ms>ctx->N) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be less than or equal to the number of integration points");
1211:     ctx->M = ms;
1212:   }
1213:   if (npart == PETSC_DECIDE || npart == PETSC_DEFAULT) {
1214:     ctx->num_subcomm = 1;
1215:   } else {
1216:     if (npart<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The npart argument must be > 0");
1217:     ctx->num_subcomm = npart;
1218:   }
1219:   if (bsmax == PETSC_DECIDE || bsmax == PETSC_DEFAULT) {
1220:     ctx->L = 256;
1221:   } else {
1222:     if (bsmax<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The bsmax argument must be > 0");
1223:     if (bsmax<ctx->L) ctx->L_max = ctx->L;
1224:     else ctx->L_max = bsmax;
1225:   }
1226:   ctx->isreal = realmats;
1227:   EPSReset(eps);   /* clean allocated arrays and force new setup */
1228:   return(0);
1229: }

1233: /*@
1234:    EPSCISSSetSizes - Sets the values of various size parameters in the CISS solver.

1236:    Logically Collective on EPS

1238:    Input Parameters:
1239: +  eps   - the eigenproblem solver context
1240: .  ip    - number of integration points
1241: .  bs    - block size
1242: .  ms    - moment size
1243: .  npart - number of partitions when splitting the communicator
1244: .  bsmax - max block size
1245: -  realmats - A and B are real

1247:    Options Database Keys:
1248: +  -eps_ciss_integration_points - Sets the number of integration points
1249: .  -eps_ciss_blocksize - Sets the block size
1250: .  -eps_ciss_moments - Sets the moment size
1251: .  -eps_ciss_partitions - Sets the number of partitions
1252: .  -eps_ciss_maxblocksize - Sets the maximum block size
1253: -  -eps_ciss_realmats - A and B are real

1255:    Note:
1256:    The default number of partitions is 1. This means the internal KSP object is shared
1257:    among all processes of the EPS communicator. Otherwise, the communicator is split
1258:    into npart communicators, so that npart KSP solves proceed simultaneously.

1260:    Level: advanced

1262: .seealso: EPSCISSGetSizes()
1263: @*/
1264: PetscErrorCode EPSCISSSetSizes(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)
1265: {

1276:   PetscTryMethod(eps,"EPSCISSSetSizes_C",(EPS,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool),(eps,ip,bs,ms,npart,bsmax,realmats));
1277:   return(0);
1278: }

1282: static PetscErrorCode EPSCISSGetSizes_CISS(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)
1283: {
1284:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1287:   if (ip) *ip = ctx->N;
1288:   if (bs) *bs = ctx->L;
1289:   if (ms) *ms = ctx->M;
1290:   if (npart) *npart = ctx->num_subcomm;
1291:   if (bsmax) *bsmax = ctx->L_max;
1292:   if (realmats) *realmats = ctx->isreal;
1293:   return(0);
1294: }

1298: /*@
1299:    EPSCISSGetSizes - Gets the values of various size parameters in the CISS solver.

1301:    Not Collective

1303:    Input Parameter:
1304: .  eps - the eigenproblem solver context

1306:    Output Parameters:
1307: +  ip    - number of integration points
1308: .  bs    - block size
1309: .  ms    - moment size
1310: .  npart - number of partitions when splitting the communicator
1311: .  bsmax - max block size
1312: -  realmats - A and B are real

1314:    Level: advanced

1316: .seealso: EPSCISSSetSizes()
1317: @*/
1318: PetscErrorCode EPSCISSGetSizes(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)
1319: {

1324:   PetscUseMethod(eps,"EPSCISSGetSizes_C",(EPS,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*),(eps,ip,bs,ms,npart,bsmax,realmats));
1325:   return(0);
1326: }

1330: static PetscErrorCode EPSCISSSetThreshold_CISS(EPS eps,PetscReal delta,PetscReal spur)
1331: {
1332:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1335:   if (delta == PETSC_DEFAULT) {
1336:     ctx->delta = 1e-12;
1337:   } else {
1338:     if (delta<=0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The delta argument must be > 0.0");
1339:     ctx->delta = delta;
1340:   }
1341:   if (spur == PETSC_DEFAULT) {
1342:     ctx->spurious_threshold = 1e-4;
1343:   } else {
1344:     if (spur<=0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The spurious threshold argument must be > 0.0");
1345:     ctx->spurious_threshold = spur;
1346:   }
1347:   return(0);
1348: }

1352: /*@
1353:    EPSCISSSetThreshold - Sets the values of various threshold parameters in
1354:    the CISS solver.

1356:    Logically Collective on EPS

1358:    Input Parameters:
1359: +  eps   - the eigenproblem solver context
1360: .  delta - threshold for numerical rank
1361: -  spur  - spurious threshold (to discard spurious eigenpairs)

1363:    Options Database Keys:
1364: +  -eps_ciss_delta - Sets the delta
1365: -  -eps_ciss_spurious_threshold - Sets the spurious threshold

1367:    Level: advanced

1369: .seealso: EPSCISSGetThreshold()
1370: @*/
1371: PetscErrorCode EPSCISSSetThreshold(EPS eps,PetscReal delta,PetscReal spur)
1372: {

1379:   PetscTryMethod(eps,"EPSCISSSetThreshold_C",(EPS,PetscReal,PetscReal),(eps,delta,spur));
1380:   return(0);
1381: }

1385: static PetscErrorCode EPSCISSGetThreshold_CISS(EPS eps,PetscReal *delta,PetscReal *spur)
1386: {
1387:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1390:   if (delta) *delta = ctx->delta;
1391:   if (spur)  *spur = ctx->spurious_threshold;
1392:   return(0);
1393: }

1397: /*@
1398:    EPSCISSGetThreshold - Gets the values of various threshold parameters
1399:    in the CISS solver.

1401:    Not Collective

1403:    Input Parameter:
1404: .  eps - the eigenproblem solver context

1406:    Output Parameters:
1407: +  delta - threshold for numerical rank
1408: -  spur  - spurious threshold (to discard spurious eigenpairs)

1410:    Level: advanced

1412: .seealso: EPSCISSSetThreshold()
1413: @*/
1414: PetscErrorCode EPSCISSGetThreshold(EPS eps,PetscReal *delta,PetscReal *spur)
1415: {

1420:   PetscUseMethod(eps,"EPSCISSGetThreshold_C",(EPS,PetscReal*,PetscReal*),(eps,delta,spur));
1421:   return(0);
1422: }

1426: static PetscErrorCode EPSCISSSetRefinement_CISS(EPS eps,PetscInt inner,PetscInt blsize)
1427: {
1428:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1431:   if (inner == PETSC_DEFAULT) {
1432:     ctx->refine_inner = 0;
1433:   } else {
1434:     if (inner<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The refine inner argument must be >= 0");
1435:     ctx->refine_inner = inner;
1436:   }
1437:   if (blsize == PETSC_DEFAULT) {
1438:     ctx->refine_blocksize = 0;
1439:   } else {
1440:     if (blsize<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The refine blocksize argument must be >= 0");
1441:     ctx->refine_blocksize = blsize;
1442:   }
1443:   return(0);
1444: }

1448: /*@
1449:    EPSCISSSetRefinement - Sets the values of various refinement parameters
1450:    in the CISS solver.

1452:    Logically Collective on EPS

1454:    Input Parameters:
1455: +  eps    - the eigenproblem solver context
1456: .  inner  - number of iterative refinement iterations (inner loop)
1457: -  blsize - number of iterative refinement iterations (blocksize loop)

1459:    Options Database Keys:
1460: +  -eps_ciss_refine_inner - Sets number of inner iterations
1461: -  -eps_ciss_refine_blocksize - Sets number of blocksize iterations

1463:    Level: advanced

1465: .seealso: EPSCISSGetRefinement()
1466: @*/
1467: PetscErrorCode EPSCISSSetRefinement(EPS eps,PetscInt inner,PetscInt blsize)
1468: {

1475:   PetscTryMethod(eps,"EPSCISSSetRefinement_C",(EPS,PetscInt,PetscInt),(eps,inner,blsize));
1476:   return(0);
1477: }

1481: static PetscErrorCode EPSCISSGetRefinement_CISS(EPS eps,PetscInt *inner,PetscInt *blsize)
1482: {
1483:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1486:   if (inner)  *inner = ctx->refine_inner;
1487:   if (blsize) *blsize = ctx->refine_blocksize;
1488:   return(0);
1489: }

1493: /*@
1494:    EPSCISSGetRefinement - Gets the values of various refinement parameters
1495:    in the CISS solver.

1497:    Not Collective

1499:    Input Parameter:
1500: .  eps - the eigenproblem solver context

1502:    Output Parameters:
1503: +  inner  - number of iterative refinement iterations (inner loop)
1504: -  blsize - number of iterative refinement iterations (blocksize loop)

1506:    Level: advanced

1508: .seealso: EPSCISSSetRefinement()
1509: @*/
1510: PetscErrorCode EPSCISSGetRefinement(EPS eps, PetscInt *inner, PetscInt *blsize)
1511: {

1516:   PetscUseMethod(eps,"EPSCISSGetRefinement_C",(EPS,PetscInt*,PetscInt*),(eps,inner,blsize));
1517:   return(0);
1518: }

1522: static PetscErrorCode EPSCISSSetUseST_CISS(EPS eps,PetscBool usest)
1523: {
1524:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1527:   ctx->usest     = usest;
1528:   ctx->usest_set = PETSC_TRUE;
1529:   return(0);
1530: }

1534: /*@
1535:    EPSCISSSetUseST - Sets a flag indicating that the CISS solver will
1536:    use the ST object for the linear solves.

1538:    Logically Collective on EPS

1540:    Input Parameters:
1541: +  eps    - the eigenproblem solver context
1542: -  usest  - boolean flag to use the ST object or not

1544:    Options Database Keys:
1545: .  -eps_ciss_usest <bool> - whether the ST object will be used or not

1547:    Level: advanced

1549: .seealso: EPSCISSGetUseST()
1550: @*/
1551: PetscErrorCode EPSCISSSetUseST(EPS eps,PetscBool usest)
1552: {

1558:   PetscTryMethod(eps,"EPSCISSSetUseST_C",(EPS,PetscBool),(eps,usest));
1559:   return(0);
1560: }

1564: static PetscErrorCode EPSCISSGetUseST_CISS(EPS eps,PetscBool *usest)
1565: {
1566:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1569:   *usest = ctx->usest;
1570:   return(0);
1571: }

1575: /*@
1576:    EPSCISSGetUseST - Gets the flag for using the ST object
1577:    in the CISS solver.

1579:    Not Collective

1581:    Input Parameter:
1582: .  eps - the eigenproblem solver context

1584:    Output Parameters:
1585: .  usest - boolean flag indicating if the ST object is being used

1587:    Level: advanced

1589: .seealso: EPSCISSSetUseST()
1590: @*/
1591: PetscErrorCode EPSCISSGetUseST(EPS eps,PetscBool *usest)
1592: {

1598:   PetscUseMethod(eps,"EPSCISSGetUseST_C",(EPS,PetscBool*),(eps,usest));
1599:   return(0);
1600: }

1604: static PetscErrorCode EPSCISSSetQuadRule_CISS(EPS eps,EPSCISSQuadRule quad)
1605: {
1606:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1609:   ctx->quad = quad;
1610:   return(0);
1611: }

1615: /*@
1616:    EPSCISSSetQuadRule - Sets the quadrature rule used in the CISS solver. 

1618:    Logically Collective on EPS

1620:    Input Parameters:
1621: +  eps  - the eigenproblem solver context
1622: -  quad - the quadrature rule

1624:    Options Database Key:
1625: .  -eps_ciss_quadrule - Sets the quadrature rule (either 'trapezoidal' or
1626:                            'chebyshev')

1628:    Notes:
1629:    By default, the trapezoidal rule is used (EPS_CISS_QUADRULE_TRAPEZOIDAL).

1631:    If the 'chebyshev' option is specified (EPS_CISS_QUADRULE_CHEBYSHEV), then
1632:    Chebyshev points are used as quadrature points.

1634:    Level: advanced

1636: .seealso: EPSCISSGetQuadRule(), EPSCISSQuadRule
1637: @*/
1638: PetscErrorCode EPSCISSSetQuadRule(EPS eps,EPSCISSQuadRule quad)
1639: {

1645:   PetscTryMethod(eps,"EPSCISSSetQuadRule_C",(EPS,EPSCISSQuadRule),(eps,quad));
1646:   return(0);
1647: }

1651: static PetscErrorCode EPSCISSGetQuadRule_CISS(EPS eps,EPSCISSQuadRule *quad)
1652: {
1653:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1656:   *quad = ctx->quad;
1657:   return(0);
1658: }

1662: /*@
1663:    EPSCISSGetQuadRule - Gets the quadrature rule used in the CISS solver.
1664:    
1665:    Not Collective

1667:    Input Parameter:
1668: .  eps - the eigenproblem solver context

1670:    Output Parameters:
1671: .  quad - quadrature rule

1673:    Level: advanced

1675: .seealso: EPSCISSSetQuadRule() EPSCISSQuadRule
1676: @*/
1677: PetscErrorCode EPSCISSGetQuadRule(EPS eps, EPSCISSQuadRule *quad)
1678: {

1684:   PetscUseMethod(eps,"EPSCISSGetQuadRule_C",(EPS,EPSCISSQuadRule*),(eps,quad));
1685:   return(0);
1686: }

1690: static PetscErrorCode EPSCISSSetExtraction_CISS(EPS eps,EPSCISSExtraction extraction)
1691: {
1692:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1695:   ctx->extraction = extraction;
1696:   return(0);
1697: }

1701: /*@
1702:    EPSCISSSetExtraction - Sets the extraction technique used in the CISS solver. 

1704:    Logically Collective on EPS

1706:    Input Parameters:
1707: +  eps        - the eigenproblem solver context
1708: -  extraction - the extraction technique

1710:    Options Database Key:
1711: .  -eps_ciss_extraction - Sets the extraction technique (either 'ritz' or
1712:                            'hankel')

1714:    Notes:
1715:    By default, the Rayleigh-Ritz extraction is used (EPS_CISS_EXTRACTION_RITZ).

1717:    If the 'hankel' option is specified (EPS_CISS_EXTRACTION_HANKEL), then
1718:    the Block Hankel method is used for extracting eigenpairs.

1720:    Level: advanced

1722: .seealso: EPSCISSGetExtraction(), EPSCISSExtraction
1723: @*/
1724: PetscErrorCode EPSCISSSetExtraction(EPS eps,EPSCISSExtraction extraction)
1725: {

1731:   PetscTryMethod(eps,"EPSCISSSetExtraction_C",(EPS,EPSCISSExtraction),(eps,extraction));
1732:   return(0);
1733: }

1737: static PetscErrorCode EPSCISSGetExtraction_CISS(EPS eps,EPSCISSExtraction *extraction)
1738: {
1739:   EPS_CISS *ctx = (EPS_CISS*)eps->data;

1742:   *extraction = ctx->extraction;
1743:   return(0);
1744: }

1748: /*@
1749:    EPSCISSGetExtraction - Gets the extraction technique used in the CISS solver.

1751:    Not Collective

1753:    Input Parameter:
1754: .  eps - the eigenproblem solver context

1756:    Output Parameters:
1757: +  extraction - extraction technique

1759:    Level: advanced

1761: .seealso: EPSCISSSetExtraction() EPSCISSExtraction
1762: @*/
1763: PetscErrorCode EPSCISSGetExtraction(EPS eps,EPSCISSExtraction *extraction)
1764: {

1770:   PetscUseMethod(eps,"EPSCISSGetExtraction_C",(EPS,EPSCISSExtraction*),(eps,extraction));
1771:   return(0);
1772: }


1777: PetscErrorCode EPSReset_CISS(EPS eps)
1778: {
1780:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
1781:   PetscInt       i;

1784:   PetscSubcommDestroy(&ctx->subcomm);
1785:   PetscFree4(ctx->weight,ctx->omega,ctx->pp,ctx->sigma);
1786:   BVDestroy(&ctx->S);
1787:   BVDestroy(&ctx->V);
1788:   BVDestroy(&ctx->Y);
1789:   if (!ctx->usest) {
1790:     for (i=0;i<ctx->num_solve_point;i++) {
1791:       KSPDestroy(&ctx->ksp[i]);
1792:     }
1793:     for (i=0;i<ctx->num_solve_point;i++) {
1794:       MatDestroy(&ctx->kspMat[i]);
1795:     }
1796:     PetscFree2(ctx->ksp,ctx->kspMat);
1797:   }
1798:   VecScatterDestroy(&ctx->scatterin);
1799:   VecDestroy(&ctx->xsub);
1800:   VecDestroy(&ctx->xdup);
1801:   if (ctx->pA) {
1802:     MatDestroy(&ctx->pA);
1803:     MatDestroy(&ctx->pB);
1804:     BVDestroy(&ctx->pV);
1805:   }
1806:   return(0);
1807: }

1811: PetscErrorCode EPSSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,EPS eps)
1812: {
1813:   PetscErrorCode    ierr;
1814:   PetscReal         r3,r4;
1815:   PetscInt          i1,i2,i3,i4,i5,i6,i7;
1816:   PetscBool         b1,b2,flg;
1817:   EPS_CISS          *ctx = (EPS_CISS*)eps->data;
1818:   EPSCISSQuadRule   quad;
1819:   EPSCISSExtraction extraction;

1822:   PetscOptionsHead(PetscOptionsObject,"EPS CISS Options");
1823:   EPSCISSGetSizes(eps,&i1,&i2,&i3,&i4,&i5,&b1);
1824:   PetscOptionsInt("-eps_ciss_integration_points","CISS number of integration points","EPSCISSSetSizes",i1,&i1,NULL);
1825:   PetscOptionsInt("-eps_ciss_blocksize","CISS block size","EPSCISSSetSizes",i2,&i2,NULL);
1826:   PetscOptionsInt("-eps_ciss_moments","CISS moment size","EPSCISSSetSizes",i3,&i3,NULL);
1827:   PetscOptionsInt("-eps_ciss_partitions","CISS number of partitions","EPSCISSSetSizes",i4,&i4,NULL);
1828:   PetscOptionsInt("-eps_ciss_maxblocksize","CISS maximum block size","EPSCISSSetSizes",i5,&i5,NULL);
1829:   PetscOptionsBool("-eps_ciss_realmats","CISS A and B are real","EPSCISSSetSizes",b1,&b1,NULL);
1830:   EPSCISSSetSizes(eps,i1,i2,i3,i4,i5,b1);

1832:   EPSCISSGetThreshold(eps,&r3,&r4);
1833:   PetscOptionsReal("-eps_ciss_delta","CISS threshold for numerical rank","EPSCISSSetThreshold",r3,&r3,NULL);
1834:   PetscOptionsReal("-eps_ciss_spurious_threshold","CISS threshold for the spurious eigenpairs","EPSCISSSetThreshold",r4,&r4,NULL);
1835:   EPSCISSSetThreshold(eps,r3,r4);

1837:   EPSCISSGetRefinement(eps,&i6,&i7);
1838:   PetscOptionsInt("-eps_ciss_refine_inner","CISS number of inner iterative refinement iterations","EPSCISSSetRefinement",i6,&i6,NULL);
1839:   PetscOptionsInt("-eps_ciss_refine_blocksize","CISS number of blocksize iterative refinement iterations","EPSCISSSetRefinement",i7,&i7,NULL);
1840:   EPSCISSSetRefinement(eps,i6,i7);

1842:   EPSCISSGetUseST(eps,&b2);
1843:   PetscOptionsBool("-eps_ciss_usest","CISS use ST for linear solves","EPSCISSSetUseST",b2,&b2,&flg);
1844:   if (flg) { EPSCISSSetUseST(eps,b2); }

1846:   PetscOptionsEnum("-eps_ciss_quadrule","Quadrature rule","EPSCISSSetQuadRule",EPSCISSQuadRules,(PetscEnum)ctx->quad,(PetscEnum*)&quad,&flg);
1847:   if (flg) { EPSCISSSetQuadRule(eps,quad); }

1849:   PetscOptionsEnum("-eps_ciss_extraction","Extraction technique","EPSCISSSetExtraction",EPSCISSExtractions,(PetscEnum)ctx->extraction,(PetscEnum*)&extraction,&flg);
1850:   if (flg) { EPSCISSSetExtraction(eps,extraction); }

1852:   PetscOptionsTail();
1853:   return(0);
1854: }

1858: PetscErrorCode EPSDestroy_CISS(EPS eps)
1859: {

1863:   PetscFree(eps->data);
1864:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetSizes_C",NULL);
1865:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetSizes_C",NULL);
1866:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetThreshold_C",NULL);
1867:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetThreshold_C",NULL);
1868:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetRefinement_C",NULL);
1869:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetRefinement_C",NULL);
1870:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetUseST_C",NULL);
1871:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetUseST_C",NULL);
1872:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetQuadRule_C",NULL);
1873:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetQuadRule_C",NULL);
1874:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetExtraction_C",NULL);
1875:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetExtraction_C",NULL);
1876:   return(0);
1877: }

1881: PetscErrorCode EPSView_CISS(EPS eps,PetscViewer viewer)
1882: {
1884:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;
1885:   PetscBool      isascii;

1888:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
1889:   if (isascii) {
1890:     PetscViewerASCIIPrintf(viewer,"  CISS: sizes { integration points: %D, block size: %D, moment size: %D, partitions: %D, maximum block size: %D }\n",ctx->N,ctx->L,ctx->M,ctx->num_subcomm,ctx->L_max);
1891:     if (ctx->isreal) {
1892:       PetscViewerASCIIPrintf(viewer,"  CISS: exploiting symmetry of integration points\n");
1893:     }
1894:     PetscViewerASCIIPrintf(viewer,"  CISS: threshold { delta: %g, spurious threshold: %g }\n",(double)ctx->delta,(double)ctx->spurious_threshold);
1895:     PetscViewerASCIIPrintf(viewer,"  CISS: iterative refinement  { inner: %D, blocksize: %D }\n",ctx->refine_inner, ctx->refine_blocksize);
1896:     if (ctx->usest) {
1897:       PetscViewerASCIIPrintf(viewer,"  CISS: using ST for linear solves\n");
1898:     }
1899:     PetscViewerASCIIPrintf(viewer,"  CISS: extraction: %s\n",EPSCISSExtractions[ctx->extraction]);
1900:     PetscViewerASCIIPrintf(viewer,"  CISS: quadrature rule: %s\n",EPSCISSQuadRules[ctx->quad]);
1901:     PetscViewerASCIIPushTab(viewer);
1902:     
1903:     if (!ctx->usest && ctx->ksp[0]) { KSPView(ctx->ksp[0],viewer); }
1904:     PetscViewerASCIIPopTab(viewer);
1905:   }
1906:   return(0);
1907: }

1911: PETSC_EXTERN PetscErrorCode EPSCreate_CISS(EPS eps)
1912: {
1914:   EPS_CISS       *ctx = (EPS_CISS*)eps->data;

1917:   PetscNewLog(eps,&ctx);
1918:   eps->data = ctx;
1919:   eps->ops->solve          = EPSSolve_CISS;
1920:   eps->ops->setup          = EPSSetUp_CISS;
1921:   eps->ops->setfromoptions = EPSSetFromOptions_CISS;
1922:   eps->ops->destroy        = EPSDestroy_CISS;
1923:   eps->ops->reset          = EPSReset_CISS;
1924:   eps->ops->view           = EPSView_CISS;
1925:   eps->ops->backtransform  = NULL;
1926:   eps->ops->computevectors = EPSComputeVectors_Schur;
1927:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetSizes_C",EPSCISSSetSizes_CISS);
1928:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetSizes_C",EPSCISSGetSizes_CISS);
1929:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetThreshold_C",EPSCISSSetThreshold_CISS);
1930:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetThreshold_C",EPSCISSGetThreshold_CISS);
1931:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetRefinement_C",EPSCISSSetRefinement_CISS);
1932:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetRefinement_C",EPSCISSGetRefinement_CISS);
1933:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetUseST_C",EPSCISSSetUseST_CISS);
1934:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetUseST_C",EPSCISSGetUseST_CISS);
1935:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetQuadRule_C",EPSCISSSetQuadRule_CISS);
1936:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetQuadRule_C",EPSCISSGetQuadRule_CISS);
1937:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetExtraction_C",EPSCISSSetExtraction_CISS);
1938:   PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetExtraction_C",EPSCISSGetExtraction_CISS);
1939:   /* set default values of parameters */
1940:   ctx->N                  = 32;
1941:   ctx->L                  = 16;
1942:   ctx->M                  = ctx->N/4;
1943:   ctx->delta              = 1e-12;
1944:   ctx->L_max              = 64;
1945:   ctx->spurious_threshold = 1e-4;
1946:   ctx->usest              = PETSC_TRUE;
1947:   ctx->usest_set          = PETSC_FALSE;
1948:   ctx->isreal             = PETSC_FALSE;
1949:   ctx->refine_inner       = 0;
1950:   ctx->refine_blocksize   = 0;
1951:   ctx->num_subcomm        = 1;
1952:   ctx->quad               = (EPSCISSQuadRule)0;
1953:   ctx->extraction         = EPS_CISS_EXTRACTION_RITZ;
1954:   return(0);
1955: }

slepc-3.7.4/src/eps/impls/ciss/makefile.html0000644000175000017500000000464713107004621020304 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = ciss.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/ciss/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/ciss/ciss.c0000644000175000017500000022154513107004621016744 0ustar jromanjroman/* SLEPc eigensolver: "ciss" Method: Contour Integral Spectral Slicing Algorithm: Contour integral based on Sakurai-Sugiura method to construct a subspace, with various eigenpair extractions (Rayleigh-Ritz, explicit moment). Based on code contributed by Y. Maeda, T. Sakurai. References: [1] T. Sakurai and H. Sugiura, "A projection method for generalized eigenvalue problems", J. Comput. Appl. Math. 159:119-128, 2003. [2] T. Sakurai and H. Tadano, "CIRR: a Rayleigh-Ritz type method with contour integral for generalized eigenvalue problems", Hokkaido Math. J. 36:745-757, 2007. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include typedef struct { /* parameters */ PetscInt N; /* number of integration points (32) */ PetscInt L; /* block size (16) */ PetscInt M; /* moment degree (N/4 = 4) */ PetscReal delta; /* threshold of singular value (1e-12) */ PetscInt L_max; /* maximum number of columns of the source matrix V */ PetscReal spurious_threshold; /* discard spurious eigenpairs */ PetscBool isreal; /* A and B are real */ PetscInt refine_inner; PetscInt refine_blocksize; /* private data */ PetscReal *sigma; /* threshold for numerical rank */ PetscInt num_subcomm; PetscInt subcomm_id; PetscInt num_solve_point; PetscScalar *weight; PetscScalar *omega; PetscScalar *pp; BV V; BV S; BV pV; BV Y; Vec xsub; Vec xdup; KSP *ksp; Mat *kspMat; PetscBool useconj; PetscReal est_eig; VecScatter scatterin; Mat pA,pB; PetscSubcomm subcomm; PetscBool usest; PetscBool usest_set; /* whether the user set the usest flag or not */ EPSCISSQuadRule quad; EPSCISSExtraction extraction; } EPS_CISS; #undef __FUNCT__ #define __FUNCT__ "SetSolverComm" static PetscErrorCode SetSolverComm(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt N = ctx->N; PetscFunctionBegin; if (ctx->useconj) N = N/2; if (!ctx->subcomm) { ierr = PetscSubcommCreate(PetscObjectComm((PetscObject)eps),&ctx->subcomm);CHKERRQ(ierr); ierr = PetscSubcommSetNumber(ctx->subcomm,ctx->num_subcomm);CHKERRQ(ierr);CHKERRQ(ierr); ierr = PetscSubcommSetType(ctx->subcomm,PETSC_SUBCOMM_INTERLACED);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,sizeof(PetscSubcomm));CHKERRQ(ierr); ierr = PetscSubcommSetFromOptions(ctx->subcomm);CHKERRQ(ierr); } ctx->subcomm_id = ctx->subcomm->color; ctx->num_solve_point = N / ctx->num_subcomm; if ((N%ctx->num_subcomm) > ctx->subcomm_id) ctx->num_solve_point+=1; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "CISSRedundantMat" static PetscErrorCode CISSRedundantMat(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; Mat A,B; PetscInt nmat; PetscFunctionBegin; ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); if (ctx->subcomm->n != 1) { ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); ierr = MatCreateRedundantMatrix(A,ctx->subcomm->n,PetscSubcommChild(ctx->subcomm),MAT_INITIAL_MATRIX,&ctx->pA);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); ierr = MatCreateRedundantMatrix(B,ctx->subcomm->n,PetscSubcommChild(ctx->subcomm),MAT_INITIAL_MATRIX,&ctx->pB);CHKERRQ(ierr); } else ctx->pB = NULL; } else { ctx->pA = NULL; ctx->pB = NULL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "CISSScatterVec" static PetscErrorCode CISSScatterVec(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; IS is1,is2; Vec v0; PetscInt i,j,k,mstart,mend,mlocal; PetscInt *idx1,*idx2,mloc_sub; PetscFunctionBegin; ierr = MatCreateVecs(ctx->pA,&ctx->xsub,NULL);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->pA,&mloc_sub,NULL);CHKERRQ(ierr); ierr = VecCreateMPI(PetscSubcommContiguousParent(ctx->subcomm),mloc_sub,PETSC_DECIDE,&ctx->xdup);CHKERRQ(ierr); if (!ctx->scatterin) { ierr = BVGetColumn(ctx->V,0,&v0);CHKERRQ(ierr); ierr = VecGetOwnershipRange(v0,&mstart,&mend);CHKERRQ(ierr); mlocal = mend - mstart; ierr = PetscMalloc2(ctx->subcomm->n*mlocal,&idx1,ctx->subcomm->n*mlocal,&idx2);CHKERRQ(ierr); j = 0; for (k=0;ksubcomm->n;k++) { for (i=mstart;in*k; } } ierr = ISCreateGeneral(PetscObjectComm((PetscObject)eps),ctx->subcomm->n*mlocal,idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr); ierr = ISCreateGeneral(PetscObjectComm((PetscObject)eps),ctx->subcomm->n*mlocal,idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr); ierr = VecScatterCreate(v0,is1,ctx->xdup,is2,&ctx->scatterin);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); ierr = ISDestroy(&is2);CHKERRQ(ierr); ierr = PetscFree2(idx1,idx2);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->V,0,&v0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SetPathParameter" static PetscErrorCode SetPathParameter(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i,j; PetscScalar center=0.0,tmp,tmp2,*omegai; PetscReal theta,radius=1.0,vscale,a,b,c,d,max_w=0.0,rgscale; #if defined(PETSC_USE_COMPLEX) PetscReal start_ang,end_ang; #endif PetscBool isring=PETSC_FALSE,isellipse=PETSC_FALSE,isinterval=PETSC_FALSE; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGRING,&isring);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGINTERVAL,&isinterval);CHKERRQ(ierr); ierr = RGGetScale(eps->rg,&rgscale);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->N+1l,&omegai);CHKERRQ(ierr); ierr = RGComputeContour(eps->rg,ctx->N,ctx->omega,omegai);CHKERRQ(ierr); if (isellipse) { ierr = RGEllipseGetParameters(eps->rg,¢er,&radius,&vscale);CHKERRQ(ierr); for (i=0;iN;i++) { #if defined(PETSC_USE_COMPLEX) theta = 2.0*PETSC_PI*(i+0.5)/ctx->N; ctx->pp[i] = PetscCosReal(theta)+vscale*PetscSinReal(theta)*PETSC_i; ctx->weight[i] = rgscale*radius*(vscale*PetscCosReal(theta)+PetscSinReal(theta)*PETSC_i)/(PetscReal)ctx->N; #else theta = (PETSC_PI/ctx->N)*(i+0.5); ctx->pp[i] = PetscCosReal(theta); ctx->weight[i] = PetscCosReal((ctx->N-1)*theta)/ctx->N; ctx->omega[i] = rgscale*(center + radius*ctx->pp[i]); #endif } } else if (ctx->quad == EPS_CISS_QUADRULE_CHEBYSHEV) { for (i=0;iN;i++) { theta = (PETSC_PI/ctx->N)*(i+0.5); ctx->pp[i] = PetscCosReal(theta); ctx->weight[i] = PetscCosReal((ctx->N-1)*theta)/ctx->N; } if (isinterval) { ierr = RGIntervalGetEndpoints(eps->rg,&a,&b,&c,&d);CHKERRQ(ierr); if ((c!=d || c!=0.0) && (a!=b || a!=0.0)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Endpoints of the imaginary axis or the real axis must be both zero"); for (i=0;iN;i++) { if (c==d) ctx->omega[i] = ((b-a)*(ctx->pp[i]+1.0)/2.0+a)*rgscale; if (a==b) { #if defined(PETSC_USE_COMPLEX) ctx->omega[i] = ((d-c)*(ctx->pp[i]+1.0)/2.0+c)*rgscale*PETSC_i; #else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Integration points on a vertical line require complex arithmetic"); #endif } } } if (isring) { /* only supported in complex scalars */ #if defined(PETSC_USE_COMPLEX) ierr = RGRingGetParameters(eps->rg,¢er,&radius,&vscale,&start_ang,&end_ang,NULL);CHKERRQ(ierr); for (i=0;iN;i++) { theta = (start_ang*2.0+(end_ang-start_ang)*(PetscRealPart(ctx->pp[i])+1.0))*PETSC_PI; ctx->omega[i] = rgscale*(center + radius*(PetscCosReal(theta)+PETSC_i*vscale*PetscSinReal(theta))); } #endif } } else { if (isinterval) { ierr = RGIntervalGetEndpoints(eps->rg,&a,&b,&c,&d);CHKERRQ(ierr); center = rgscale*((b+a)/2.0+(d+c)/2.0*PETSC_PI); radius = PetscSqrtReal(PetscPowRealInt(rgscale*(b-a)/2.0,2)+PetscPowRealInt(rgscale*(d-c)/2.0,2)); } else if (isring) { ierr = RGRingGetParameters(eps->rg,¢er,&radius,NULL,NULL,NULL,NULL);CHKERRQ(ierr); center *= rgscale; radius *= rgscale; } for (i=0;iN;i++) { ctx->pp[i] = (ctx->omega[i]-center)/radius; tmp = 1; tmp2 = 1; for (j=0;jN;j++) { tmp *= ctx->omega[j]; if (i != j) tmp2 *= ctx->omega[j]-ctx->omega[i]; } ctx->weight[i] = tmp/tmp2; max_w = PetscMax(PetscAbsScalar(ctx->weight[i]),max_w); } for (i=0;iN;i++) ctx->weight[i] /= (PetscScalar)max_w; } ierr = PetscFree(omegai);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "CISSVecSetRandom" static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1) { PetscErrorCode ierr; PetscInt i,j,nlocal; PetscScalar *vdata; Vec x; PetscFunctionBegin; ierr = BVGetSizes(V,&nlocal,NULL,NULL);CHKERRQ(ierr); for (i=i0;idata; PetscInt i; Vec vi,pvi; const PetscScalar *array; PetscFunctionBegin; for (i=0;iscatterin,vi,ctx->xdup,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->scatterin,vi,ctx->xdup,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = BVRestoreColumn(Vin,i,&vi);CHKERRQ(ierr); ierr = VecGetArrayRead(ctx->xdup,&array);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->xsub,array);CHKERRQ(ierr); ierr = BVGetColumn(ctx->pV,i,&pvi);CHKERRQ(ierr); ierr = VecCopy(ctx->xsub,pvi);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->pV,i,&pvi);CHKERRQ(ierr); ierr = VecResetArray(ctx->xsub);CHKERRQ(ierr); ierr = VecRestoreArrayRead(ctx->xdup,&array);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SolveLinearSystem" static PetscErrorCode SolveLinearSystem(EPS eps,Mat A,Mat B,BV V,PetscInt L_start,PetscInt L_end,PetscBool initksp) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i,j,p_id; Mat Fz; PC pc; Vec Bvj,vj,yj; KSP ksp; PetscFunctionBegin; ierr = BVCreateVec(V,&Bvj);CHKERRQ(ierr); if (ctx->usest) { ierr = MatDuplicate(A,MAT_DO_NOT_COPY_VALUES,&Fz);CHKERRQ(ierr); } for (i=0;inum_solve_point;i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; if (!ctx->usest && initksp == PETSC_TRUE) { ierr = MatDuplicate(A,MAT_DO_NOT_COPY_VALUES,&ctx->kspMat[i]);CHKERRQ(ierr); ierr = MatCopy(A,ctx->kspMat[i],DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); if (B) { ierr = MatAXPY(ctx->kspMat[i],-ctx->omega[p_id],B,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); } else { ierr = MatShift(ctx->kspMat[i],-ctx->omega[p_id]);CHKERRQ(ierr); } ierr = KSPSetOperators(ctx->ksp[i],ctx->kspMat[i],ctx->kspMat[i]);CHKERRQ(ierr); ierr = KSPSetType(ctx->ksp[i],KSPPREONLY);CHKERRQ(ierr); ierr = KSPGetPC(ctx->ksp[i],&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); ierr = KSPSetFromOptions(ctx->ksp[i]);CHKERRQ(ierr); } else if (ctx->usest) { ierr = STSetShift(eps->st,ctx->omega[p_id]);CHKERRQ(ierr); ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); } for (j=L_start;jY,i*ctx->L_max+j,&yj);CHKERRQ(ierr); if (B) { ierr = MatMult(B,vj,Bvj);CHKERRQ(ierr); if (ctx->usest) { ierr = KSPSolve(ksp,Bvj,yj);CHKERRQ(ierr); } else { ierr = KSPSolve(ctx->ksp[i],Bvj,yj);CHKERRQ(ierr); } } else { if (ctx->usest) { ierr = KSPSolve(ksp,vj,yj);CHKERRQ(ierr); } else { ierr = KSPSolve(ctx->ksp[i],vj,yj);CHKERRQ(ierr); } } ierr = BVRestoreColumn(V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->Y,i*ctx->L_max+j,&yj);CHKERRQ(ierr); } if (ctx->usest && inum_solve_point-1) { ierr = KSPReset(ksp);CHKERRQ(ierr); } } if (ctx->usest) { ierr = MatDestroy(&Fz);CHKERRQ(ierr); } ierr = VecDestroy(&Bvj);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_USE_COMPLEX) #undef __FUNCT__ #define __FUNCT__ "EstimateNumberEigs" static PetscErrorCode EstimateNumberEigs(EPS eps,PetscInt *L_add) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i,j,p_id; PetscScalar tmp,m = 1,sum = 0.0; PetscReal eta; Vec v,vtemp,vj,yj; PetscFunctionBegin; ierr = BVGetColumn(ctx->Y,0,&yj);CHKERRQ(ierr); ierr = VecDuplicate(yj,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->Y,0,&yj);CHKERRQ(ierr); ierr = BVCreateVec(ctx->V,&vtemp);CHKERRQ(ierr); for (j=0;jL;j++) { ierr = VecSet(v,0);CHKERRQ(ierr); for (i=0;inum_solve_point; i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; ierr = BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);CHKERRQ(ierr); ierr = BVMultVec(ctx->Y,ctx->weight[p_id],1,v,&m);CHKERRQ(ierr); } ierr = BVGetColumn(ctx->V,j,&vj);CHKERRQ(ierr); if (ctx->pA) { ierr = VecSet(vtemp,0);CHKERRQ(ierr); ierr = VecScatterBegin(ctx->scatterin,v,vtemp,ADD_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->scatterin,v,vtemp,ADD_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); ierr = VecDot(vj,vtemp,&tmp);CHKERRQ(ierr); } else { ierr = VecDot(vj,v,&tmp);CHKERRQ(ierr); } ierr = BVRestoreColumn(ctx->V,j,&vj);CHKERRQ(ierr); if (ctx->useconj) sum += PetscRealPart(tmp)*2; else sum += tmp; } ctx->est_eig = PetscAbsScalar(sum/(PetscReal)ctx->L); eta = PetscPowReal(10.0,-PetscLog10Real(eps->tol)/ctx->N); ierr = PetscInfo1(eps,"Estimation_#Eig %f\n",(double)ctx->est_eig);CHKERRQ(ierr); *L_add = (PetscInt)PetscCeilReal((ctx->est_eig*eta)/ctx->M) - ctx->L; if (*L_add < 0) *L_add = 0; if (*L_add>ctx->L_max-ctx->L) { ierr = PetscInfo(eps,"Number of eigenvalues around the contour path may be too large\n");CHKERRQ(ierr); *L_add = ctx->L_max-ctx->L; } ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&vtemp);CHKERRQ(ierr); PetscFunctionReturn(0); } #endif #undef __FUNCT__ #define __FUNCT__ "CalcMu" static PetscErrorCode CalcMu(EPS eps,PetscScalar *Mu) { PetscErrorCode ierr; PetscMPIInt sub_size,len; PetscInt i,j,k,s; PetscScalar *m,*temp,*temp2,*ppk,alp; EPS_CISS *ctx = (EPS_CISS*)eps->data; Mat M; PetscFunctionBegin; ierr = MPI_Comm_size(PetscSubcommChild(ctx->subcomm),&sub_size);CHKERRQ(ierr); ierr = PetscMalloc3(ctx->num_solve_point*ctx->L*(ctx->L+1),&temp,2*ctx->M*ctx->L*ctx->L,&temp2,ctx->num_solve_point,&ppk);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,ctx->L,ctx->L_max*ctx->num_solve_point,NULL,&M);CHKERRQ(ierr); for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] = 0; ierr = BVSetActiveColumns(ctx->Y,0,ctx->L_max*ctx->num_solve_point);CHKERRQ(ierr); if (ctx->pA) { ierr = BVSetActiveColumns(ctx->pV,0,ctx->L);CHKERRQ(ierr); ierr = BVDot(ctx->Y,ctx->pV,M);CHKERRQ(ierr); } else { ierr = BVSetActiveColumns(ctx->V,0,ctx->L);CHKERRQ(ierr); ierr = BVDot(ctx->Y,ctx->V,M);CHKERRQ(ierr); } ierr = MatDenseGetArray(M,&m);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) { for (j=0;jL;j++) { for (k=0;kL;k++) { temp[k+j*ctx->L+i*ctx->L*ctx->L]=m[k+j*ctx->L+i*ctx->L*ctx->L_max]; } } } ierr = MatDenseRestoreArray(M,&m);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) ppk[i] = 1; for (k=0;k<2*ctx->M;k++) { for (j=0;jL;j++) { for (i=0;inum_solve_point;i++) { alp = ppk[i]*ctx->weight[i*ctx->subcomm->n + ctx->subcomm_id]; for (s=0;sL;s++) { if (ctx->useconj) temp2[s+(j+k*ctx->L)*ctx->L] += PetscRealPart(alp*temp[s+(j+i*ctx->L)*ctx->L])*2; else temp2[s+(j+k*ctx->L)*ctx->L] += alp*temp[s+(j+i*ctx->L)*ctx->L]; } } } for (i=0;inum_solve_point;i++) ppk[i] *= ctx->pp[i*ctx->subcomm->n + ctx->subcomm_id]; } for (i=0;i<2*ctx->M*ctx->L*ctx->L;i++) temp2[i] /= sub_size; ierr = PetscMPIIntCast(2*ctx->M*ctx->L*ctx->L,&len);CHKERRQ(ierr); ierr = MPI_Allreduce(temp2,Mu,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)eps));CHKERRQ(ierr); ierr = PetscFree3(temp,temp2,ppk);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BlockHankel" static PetscErrorCode BlockHankel(EPS eps,PetscScalar *Mu,PetscInt s,PetscScalar *H) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i,j,k,L=ctx->L,M=ctx->M; PetscFunctionBegin; for (k=0;kdata; PetscInt i,ml=ctx->L*ctx->M; PetscBLASInt m,n,lda,ldu,ldvt,lwork,info; PetscScalar *work; #if defined(PETSC_USE_COMPLEX) PetscReal *rwork; #endif PetscFunctionBegin; ierr = PetscMalloc1(5*ml,&work);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscMalloc1(5*ml,&rwork);CHKERRQ(ierr); #endif ierr = PetscBLASIntCast(ml,&m);CHKERRQ(ierr); n = m; lda = m; ldu = m; ldvt = m; lwork = 5*m; ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,rwork,&info)); #else PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","N",&m,&n,S,&lda,ctx->sigma,NULL,&ldu,NULL,&ldvt,work,&lwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info); ierr = PetscFPTrapPop();CHKERRQ(ierr); (*K) = 0; for (i=0;isigma[i]/PetscMax(ctx->sigma[0],1)>ctx->delta) (*K)++; } ierr = PetscFree(work);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscFree(rwork);CHKERRQ(ierr); #endif PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "ConstructS" static PetscErrorCode ConstructS(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i,j,k,vec_local_size,p_id; Vec v,sj,yj; PetscScalar *ppk, *v_data, m = 1; PetscFunctionBegin; ierr = BVGetSizes(ctx->Y,&vec_local_size,NULL,NULL);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->num_solve_point,&ppk);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) ppk[i] = 1; ierr = BVGetColumn(ctx->Y,0,&yj);CHKERRQ(ierr); ierr = VecDuplicate(yj,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->Y,0,&yj);CHKERRQ(ierr); for (k=0;kM;k++) { for (j=0;jL;j++) { ierr = VecSet(v,0);CHKERRQ(ierr); for (i=0;inum_solve_point;i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; ierr = BVSetActiveColumns(ctx->Y,i*ctx->L_max+j,i*ctx->L_max+j+1);CHKERRQ(ierr); ierr = BVMultVec(ctx->Y,ppk[i]*ctx->weight[p_id],1.0,v,&m);CHKERRQ(ierr); } if (ctx->useconj) { ierr = VecGetArray(v,&v_data);CHKERRQ(ierr); for (i=0;iS,k*ctx->L+j,&sj);CHKERRQ(ierr); if (ctx->pA) { ierr = VecSet(sj,0);CHKERRQ(ierr); ierr = VecScatterBegin(ctx->scatterin,v,sj,ADD_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->scatterin,v,sj,ADD_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); } else { ierr = VecCopy(v,sj);CHKERRQ(ierr); } ierr = BVRestoreColumn(ctx->S,k*ctx->L+j,&sj);CHKERRQ(ierr); } for (i=0;inum_solve_point;i++) { p_id = i*ctx->subcomm->n + ctx->subcomm_id; ppk[i] *= ctx->pp[p_id]; } } ierr = PetscFree(ppk);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SVD_S" static PetscErrorCode SVD_S(BV S,PetscInt ml,PetscReal delta,PetscReal *sigma,PetscInt *K) { #if defined(PETSC_MISSING_LAPACK_GESVD) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,j,k,local_size; PetscMPIInt len; PetscScalar *work,*temp,*B,*tempB,*s_data,*Q1,*Q2,*temp2,alpha=1,beta=0; PetscBLASInt l,m,n,lda,ldu,ldvt,lwork,info,ldb,ldc; #if defined(PETSC_USE_COMPLEX) PetscReal *rwork; #endif PetscFunctionBegin; ierr = BVGetSizes(S,&local_size,NULL,NULL);CHKERRQ(ierr); ierr = BVGetArray(S,&s_data);CHKERRQ(ierr); ierr = PetscMalloc7(ml*ml,&temp,ml*ml,&temp2,local_size*ml,&Q1,local_size*ml,&Q2,ml*ml,&B,ml*ml,&tempB,5*ml,&work);CHKERRQ(ierr); ierr = PetscMemzero(B,ml*ml*sizeof(PetscScalar));CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscMalloc1(5*ml,&rwork);CHKERRQ(ierr); #endif ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); for (i=0;idelta) (*K)++; } ierr = PetscFree7(temp,temp2,Q1,Q2,B,tempB,work);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscFree(rwork);CHKERRQ(ierr); #endif PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "isGhost" static PetscErrorCode isGhost(EPS eps,PetscInt ld,PetscInt nv,PetscBool *fl) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i,j; PetscScalar *pX; PetscReal *tau,s1,s2,tau_max=0.0; PetscFunctionBegin; ierr = PetscMalloc1(nv,&tau);CHKERRQ(ierr); ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); for (i=0;isigma[j]; } tau[i] = s1/s2; tau_max = PetscMax(tau_max,tau[i]); } ierr = DSRestoreArray(eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); for (i=0;i=ctx->spurious_threshold) fl[i] = PETSC_TRUE; else fl[i] = PETSC_FALSE; } ierr = PetscFree(tau);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "rescale_eig" static PetscErrorCode rescale_eig(EPS eps,PetscInt nv) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i; PetscScalar center; PetscReal radius,a,b,c,d,rgscale; #if defined(PETSC_USE_COMPLEX) PetscReal start_ang,end_ang,vscale,theta; #endif PetscBool isring,isellipse,isinterval; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGRING,&isring);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGINTERVAL,&isinterval);CHKERRQ(ierr); ierr = RGGetScale(eps->rg,&rgscale);CHKERRQ(ierr); if (isinterval) { ierr = RGIntervalGetEndpoints(eps->rg,NULL,NULL,&c,&d);CHKERRQ(ierr); if (c==d) { for (i=0;ieigr[i] = PetscRealPart(eps->eigr[i]); #else eps->eigi[i] = 0; #endif } } } if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) { if (isellipse) { ierr = RGEllipseGetParameters(eps->rg,¢er,&radius,NULL);CHKERRQ(ierr); for (i=0;ieigr[i] = rgscale*(center + radius*eps->eigr[i]); } else if (isinterval) { ierr = RGIntervalGetEndpoints(eps->rg,&a,&b,&c,&d);CHKERRQ(ierr); if (ctx->quad == EPS_CISS_QUADRULE_CHEBYSHEV) { for (i=0;ieigr[i] = ((b-a)*(eps->eigr[i]+1.0)/2.0+a)*rgscale; if (a==b) { #if defined(PETSC_USE_COMPLEX) eps->eigr[i] = ((d-c)*(eps->eigr[i]+1.0)/2.0+c)*rgscale*PETSC_i; #else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Integration points on a vertical line require complex arithmetic"); #endif } } } else { center = (b+a)/2.0+(d+c)/2.0*PETSC_PI; radius = PetscSqrtReal(PetscPowRealInt((b-a)/2.0,2)+PetscPowRealInt((d-c)/2.0,2)); for (i=0;ieigr[i] = center + radius*eps->eigr[i]; } } else if (isring) { /* only supported in complex scalars */ #if defined(PETSC_USE_COMPLEX) ierr = RGRingGetParameters(eps->rg,¢er,&radius,&vscale,&start_ang,&end_ang,NULL);CHKERRQ(ierr); if (ctx->quad == EPS_CISS_QUADRULE_CHEBYSHEV) { for (i=0;ieigr[i])+1.0))*PETSC_PI; eps->eigr[i] = rgscale*center + (rgscale*radius+PetscImaginaryPart(eps->eigr[i]))*(PetscCosReal(theta)+PETSC_i*vscale*PetscSinReal(theta)); } } else { for (i=0;ieigr[i] = rgscale*(center + radius*eps->eigr[i]); } #endif } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_CISS" PetscErrorCode EPSSetUp_CISS(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i; PetscBool issinvert,istrivial,isring,isellipse,isinterval,flg; PetscScalar center; PetscReal c,d; Mat A; PetscFunctionBegin; if (!eps->ncv) eps->ncv = ctx->L_max*ctx->M; else { ierr = EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); ctx->L_max = eps->ncv/ctx->M; if (ctx->L_max == 0) { ctx->L_max = 1; eps->ncv = ctx->L_max*ctx->M; } if (ctx->L > ctx->L_max) ctx->L = ctx->L_max; } if (!eps->max_it) eps->max_it = 1; if (!eps->mpd) eps->mpd = eps->ncv; if (!eps->which) eps->which = EPS_ALL; if (!eps->extraction) { ierr = EPSSetExtraction(eps,EPS_RITZ);CHKERRQ(ierr); } else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support user-defined stopping test"); /* check region */ ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"CISS requires a nontrivial region, e.g. -rg_type ellipse ..."); ierr = RGGetComplement(eps->rg,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"A region with complement flag set is not allowed"); ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGRING,&isring);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGINTERVAL,&isinterval);CHKERRQ(ierr); if (!isellipse && !isring && !isinterval) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Currently only implemented for interval, elliptic or ring regions"); if (isring) { #if !defined(PETSC_USE_COMPLEX) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Ring region only supported for complex scalars"); #endif ctx->useconj = PETSC_FALSE; } if (isellipse) { ierr = RGEllipseGetParameters(eps->rg,¢er,NULL,NULL);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) if (ctx->isreal && PetscImaginaryPart(center) == 0.0) ctx->useconj = PETSC_TRUE; else ctx->useconj = PETSC_FALSE; #else ctx->useconj = PETSC_FALSE; #endif } if (isinterval) { ierr = RGIntervalGetEndpoints(eps->rg,NULL,NULL,&c,&d);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) if (ctx->isreal && c==d) ctx->useconj = PETSC_TRUE; else ctx->useconj = PETSC_FALSE; #else if (c!=d || c!=0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"In real scalars, endpoints of the imaginary axis must be both zero"); ctx->useconj = PETSC_FALSE; #endif if (!ctx->quad && c==d) ctx->quad = EPS_CISS_QUADRULE_CHEBYSHEV; } if (!ctx->quad) ctx->quad = EPS_CISS_QUADRULE_TRAPEZOIDAL; /* create split comm */ ierr = SetSolverComm(eps);CHKERRQ(ierr); ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = PetscMalloc4(ctx->N,&ctx->weight,ctx->N+1,&ctx->omega,ctx->N,&ctx->pp,ctx->L_max*ctx->M,&ctx->sigma);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,3*ctx->N*sizeof(PetscScalar)+ctx->L_max*ctx->N*sizeof(PetscReal));CHKERRQ(ierr); /* allocate basis vectors */ ierr = BVDuplicateResize(eps->V,ctx->L_max*ctx->M,&ctx->S);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->S);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,ctx->L_max,&ctx->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->V);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)A,MATSHELL,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Matrix type shell is not supported in this solver"); if (!ctx->usest_set) ctx->usest = (ctx->num_subcomm>1)? PETSC_FALSE: PETSC_TRUE; if (ctx->usest && ctx->num_subcomm>1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The usest flag is not supported when partitions > 1"); ierr = CISSRedundantMat(eps);CHKERRQ(ierr); if (ctx->pA) { ierr = CISSScatterVec(eps);CHKERRQ(ierr); ierr = BVCreate(PetscObjectComm((PetscObject)ctx->xsub),&ctx->pV);CHKERRQ(ierr); ierr = BVSetSizesFromVec(ctx->pV,ctx->xsub,eps->n);CHKERRQ(ierr); ierr = BVSetFromOptions(ctx->pV);CHKERRQ(ierr); ierr = BVResize(ctx->pV,ctx->L_max,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->pV);CHKERRQ(ierr); } if (ctx->usest) { ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSINVERT,&issinvert);CHKERRQ(ierr); if (!issinvert) { ierr = STSetType(eps->st,STSINVERT);CHKERRQ(ierr); } } else { ierr = STSetType(eps->st,STSHIFT);CHKERRQ(ierr); /* we are not going to use ST, so avoid problems in case the user provided one */ ierr = PetscMalloc2(ctx->num_solve_point,&ctx->ksp,ctx->num_solve_point,&ctx->kspMat);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,ctx->num_solve_point*sizeof(KSP)+ctx->num_solve_point*sizeof(Mat));CHKERRQ(ierr); for (i=0;inum_solve_point;i++) { ierr = KSPCreate(PetscSubcommChild(ctx->subcomm),&ctx->ksp[i]);CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->ksp[i],(PetscObject)eps,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->ksp[i]);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(ctx->ksp[i],((PetscObject)eps)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(ctx->ksp[i],"eps_ciss_");CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(ctx->ksp[i],PETSC_TRUE);CHKERRQ(ierr); } } if (ctx->pA) { ierr = BVCreate(PetscObjectComm((PetscObject)ctx->xsub),&ctx->Y);CHKERRQ(ierr); ierr = BVSetSizesFromVec(ctx->Y,ctx->xsub,eps->n);CHKERRQ(ierr); ierr = BVSetFromOptions(ctx->Y);CHKERRQ(ierr); ierr = BVResize(ctx->Y,ctx->num_solve_point*ctx->L_max,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = BVDuplicateResize(eps->V,ctx->num_solve_point*ctx->L_max,&ctx->Y);CHKERRQ(ierr); } ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)ctx->Y);CHKERRQ(ierr); if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) { ierr = DSSetType(eps->ds,DSGNHEP);CHKERRQ(ierr); } else if (eps->isgeneralized) { if (eps->ishermitian && eps->ispositive) { ierr = DSSetType(eps->ds,DSGHEP);CHKERRQ(ierr); } else { ierr = DSSetType(eps->ds,DSGNHEP);CHKERRQ(ierr); } } else { if (eps->ishermitian) { ierr = DSSetType(eps->ds,DSHEP);CHKERRQ(ierr); } else { ierr = DSSetType(eps->ds,DSNHEP);CHKERRQ(ierr); } } ierr = DSAllocate(eps->ds,eps->ncv);CHKERRQ(ierr); ierr = EPSSetWorkVecs(eps,2);CHKERRQ(ierr); /* In GHEP problems, deactivate purification to avoid losing B-normalization of eigenvectors in EPSComputeVectors_Schur */ eps->purify = PETSC_FALSE; #if !defined(PETSC_USE_COMPLEX) if (!eps->ishermitian) { ierr = PetscInfo(eps,"Warning: complex eigenvalues are not calculated exactly without --with-scalar-type=complex in PETSc\n");CHKERRQ(ierr); } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_CISS" PetscErrorCode EPSSolve_CISS(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; Mat A,B,X,M,pA,pB; PetscInt i,j,ld,nmat,L_add=0,nv=0,L_base=ctx->L,inner,nlocal,*inside; PetscScalar *Mu,*H0,*H1=NULL,*rr,*temp; PetscReal error,max_error; PetscBool *fl1; Vec si,w[3]; SlepcSC sc; PetscRandom rand; #if defined(PETSC_USE_COMPLEX) PetscBool isellipse; #endif PetscFunctionBegin; w[0] = eps->work[0]; w[1] = NULL; w[2] = eps->work[1]; /* override SC settings */ ierr = DSGetSlepcSC(eps->ds,&sc);CHKERRQ(ierr); sc->comparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = VecGetLocalSize(w[0],&nlocal);CHKERRQ(ierr); ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } else B = NULL; ierr = SetPathParameter(eps);CHKERRQ(ierr); ierr = CISSVecSetRandom(ctx->V,0,ctx->L);CHKERRQ(ierr); ierr = BVGetRandomContext(ctx->V,&rand);CHKERRQ(ierr); if (ctx->pA) { ierr = VecScatterVecs(eps,ctx->V,ctx->L);CHKERRQ(ierr); ierr = SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,0,ctx->L,PETSC_TRUE);CHKERRQ(ierr); } else { ierr = SolveLinearSystem(eps,A,B,ctx->V,0,ctx->L,PETSC_TRUE);CHKERRQ(ierr); } #if defined(PETSC_USE_COMPLEX) ierr = PetscObjectTypeCompare((PetscObject)eps->rg,RGELLIPSE,&isellipse);CHKERRQ(ierr); if (isellipse) { ierr = EstimateNumberEigs(eps,&L_add);CHKERRQ(ierr); } else { L_add = 0; } #else L_add = 0; #endif if (L_add>0) { ierr = PetscInfo2(eps,"Changing L %D -> %D by Estimate #Eig\n",ctx->L,ctx->L+L_add);CHKERRQ(ierr); ierr = CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);CHKERRQ(ierr); if (ctx->pA) { ierr = VecScatterVecs(eps,ctx->V,ctx->L+L_add);CHKERRQ(ierr); ierr = SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,ctx->L,ctx->L+L_add,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = SolveLinearSystem(eps,A,B,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);CHKERRQ(ierr); } ctx->L += L_add; } ierr = PetscMalloc2(ctx->L*ctx->L*ctx->M*2,&Mu,ctx->L*ctx->M*ctx->L*ctx->M,&H0);CHKERRQ(ierr); for (i=0;irefine_blocksize;i++) { ierr = CalcMu(eps,Mu);CHKERRQ(ierr); ierr = BlockHankel(eps,Mu,0,H0);CHKERRQ(ierr); ierr = SVD_H0(eps,H0,&nv);CHKERRQ(ierr); if (ctx->sigma[0]<=ctx->delta || nv < ctx->L*ctx->M || ctx->L == ctx->L_max) break; L_add = L_base; if (ctx->L+L_add>ctx->L_max) L_add = ctx->L_max-ctx->L; ierr = PetscInfo2(eps,"Changing L %D -> %D by SVD(H0)\n",ctx->L,ctx->L+L_add);CHKERRQ(ierr); ierr = CISSVecSetRandom(ctx->V,ctx->L,ctx->L+L_add);CHKERRQ(ierr); if (ctx->pA) { ierr = VecScatterVecs(eps,ctx->V,ctx->L+L_add);CHKERRQ(ierr); ierr = SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,ctx->L,ctx->L+L_add,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = SolveLinearSystem(eps,A,B,ctx->V,ctx->L,ctx->L+L_add,PETSC_FALSE);CHKERRQ(ierr); } ctx->L += L_add; } if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) { ierr = PetscMalloc1(ctx->L*ctx->M*ctx->L*ctx->M,&H1);CHKERRQ(ierr); } while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; for (inner=0;inner<=ctx->refine_inner;inner++) { if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) { ierr = CalcMu(eps,Mu);CHKERRQ(ierr); ierr = BlockHankel(eps,Mu,0,H0);CHKERRQ(ierr); ierr = SVD_H0(eps,H0,&nv);CHKERRQ(ierr); break; } else { ierr = ConstructS(eps);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,ctx->L);CHKERRQ(ierr); ierr = BVCopy(ctx->S,ctx->V);CHKERRQ(ierr); ierr = SVD_S(ctx->S,ctx->L*ctx->M,ctx->delta,ctx->sigma,&nv);CHKERRQ(ierr); if (ctx->sigma[0]>ctx->delta && nv==ctx->L*ctx->M && inner!=ctx->refine_inner) { if (ctx->pA) { ierr = VecScatterVecs(eps,ctx->V,ctx->L);CHKERRQ(ierr); ierr = SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,0,ctx->L,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = SolveLinearSystem(eps,A,B,ctx->V,0,ctx->L,PETSC_FALSE);CHKERRQ(ierr); } } else break; } } eps->nconv = 0; if (nv == 0) eps->reason = EPS_CONVERGED_TOL; else { ierr = DSSetDimensions(eps->ds,nv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) { ierr = BlockHankel(eps,Mu,0,H0);CHKERRQ(ierr); ierr = BlockHankel(eps,Mu,1,H1);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_A,&temp);CHKERRQ(ierr); for (j=0;jL*ctx->M]; } } ierr = DSRestoreArray(eps->ds,DS_MAT_A,&temp);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_B,&temp);CHKERRQ(ierr); for (j=0;jL*ctx->M]; } } ierr = DSRestoreArray(eps->ds,DS_MAT_B,&temp);CHKERRQ(ierr); } else { ierr = BVSetActiveColumns(ctx->S,0,nv);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_A,&pA);CHKERRQ(ierr); ierr = MatZeroEntries(pA);CHKERRQ(ierr); ierr = BVMatProject(ctx->S,A,ctx->S,pA);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_A,&pA);CHKERRQ(ierr); if (B) { ierr = DSGetMat(eps->ds,DS_MAT_B,&pB);CHKERRQ(ierr); ierr = MatZeroEntries(pB);CHKERRQ(ierr); ierr = BVMatProject(ctx->S,B,ctx->S,pB);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_B,&pB);CHKERRQ(ierr); } } ierr = DSSolve(eps->ds,eps->eigr,eps->eigi);CHKERRQ(ierr); ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = PetscMalloc3(nv,&fl1,nv,&inside,nv,&rr);CHKERRQ(ierr); ierr = rescale_eig(eps,nv);CHKERRQ(ierr); ierr = isGhost(eps,ld,nv,fl1);CHKERRQ(ierr); ierr = RGCheckInside(eps->rg,nv,eps->eigr,eps->eigi,inside);CHKERRQ(ierr); for (i=0;i=0) { rr[i] = 1.0; eps->nconv++; } else rr[i] = 0.0; } ierr = DSSort(eps->ds,eps->eigr,eps->eigi,rr,NULL,&eps->nconv);CHKERRQ(ierr); ierr = rescale_eig(eps,nv);CHKERRQ(ierr); ierr = PetscFree3(fl1,inside,rr);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,nv);CHKERRQ(ierr); if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) { ierr = ConstructS(eps);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,ctx->L);CHKERRQ(ierr); ierr = BVCopy(ctx->S,ctx->V);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,nv);CHKERRQ(ierr); } ierr = BVCopy(ctx->S,eps->V);CHKERRQ(ierr); ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVMultInPlace(ctx->S,X,0,eps->nconv);CHKERRQ(ierr); if (eps->ishermitian) { ierr = BVMultInPlace(eps->V,X,0,eps->nconv);CHKERRQ(ierr); } ierr = MatDestroy(&X);CHKERRQ(ierr); max_error = 0.0; for (i=0;inconv;i++) { ierr = BVGetColumn(ctx->S,i,&si);CHKERRQ(ierr); ierr = EPSComputeResidualNorm_Private(eps,eps->eigr[i],eps->eigi[i],si,NULL,w,&error);CHKERRQ(ierr); ierr = (*eps->converged)(eps,eps->eigr[i],eps->eigi[i],error,&error,eps->convergedctx);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->S,i,&si);CHKERRQ(ierr); max_error = PetscMax(max_error,error); } if (max_error <= eps->tol) eps->reason = EPS_CONVERGED_TOL; else if (eps->its >= eps->max_it) eps->reason = EPS_DIVERGED_ITS; else { if (eps->nconv > ctx->L) { ierr = MatCreateSeqDense(PETSC_COMM_SELF,eps->nconv,ctx->L,NULL,&M);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&temp);CHKERRQ(ierr); for (i=0;iL*eps->nconv;i++) { ierr = PetscRandomGetValue(rand,&temp[i]);CHKERRQ(ierr); temp[i] = PetscRealPart(temp[i]); } ierr = MatDenseRestoreArray(M,&temp);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,eps->nconv);CHKERRQ(ierr); ierr = BVMultInPlace(ctx->S,M,0,ctx->L);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); ierr = BVSetActiveColumns(ctx->S,0,ctx->L);CHKERRQ(ierr); ierr = BVCopy(ctx->S,ctx->V);CHKERRQ(ierr); } if (ctx->pA) { ierr = VecScatterVecs(eps,ctx->V,ctx->L);CHKERRQ(ierr); ierr = SolveLinearSystem(eps,ctx->pA,ctx->pB,ctx->pV,0,ctx->L,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = SolveLinearSystem(eps,A,B,ctx->V,0,ctx->L,PETSC_FALSE);CHKERRQ(ierr); } } } } if (ctx->extraction == EPS_CISS_EXTRACTION_HANKEL) { ierr = PetscFree(H1);CHKERRQ(ierr); } ierr = PetscFree2(Mu,H0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetSizes_CISS" static PetscErrorCode EPSCISSSetSizes_CISS(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; if (ip == PETSC_DECIDE || ip == PETSC_DEFAULT) { if (ctx->N!=32) { ctx->N =32; ctx->M = ctx->N/4; } } else { if (ip<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be > 0"); if (ip%2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ip argument must be an even number"); if (ctx->N!=ip) { ctx->N = ip; ctx->M = ctx->N/4; } } if (bs == PETSC_DECIDE || bs == PETSC_DEFAULT) { ctx->L = 16; } else { if (bs<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be > 0"); if (bs>ctx->L_max) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The bs argument must be less than or equal to the maximum number of block size"); ctx->L = bs; } if (ms == PETSC_DECIDE || ms == PETSC_DEFAULT) { ctx->M = ctx->N/4; } else { if (ms<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be > 0"); if (ms>ctx->N) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The ms argument must be less than or equal to the number of integration points"); ctx->M = ms; } if (npart == PETSC_DECIDE || npart == PETSC_DEFAULT) { ctx->num_subcomm = 1; } else { if (npart<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The npart argument must be > 0"); ctx->num_subcomm = npart; } if (bsmax == PETSC_DECIDE || bsmax == PETSC_DEFAULT) { ctx->L = 256; } else { if (bsmax<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The bsmax argument must be > 0"); if (bsmaxL) ctx->L_max = ctx->L; else ctx->L_max = bsmax; } ctx->isreal = realmats; ierr = EPSReset(eps);CHKERRQ(ierr); /* clean allocated arrays and force new setup */ PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetSizes" /*@ EPSCISSSetSizes - Sets the values of various size parameters in the CISS solver. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . ip - number of integration points . bs - block size . ms - moment size . npart - number of partitions when splitting the communicator . bsmax - max block size - realmats - A and B are real Options Database Keys: + -eps_ciss_integration_points - Sets the number of integration points . -eps_ciss_blocksize - Sets the block size . -eps_ciss_moments - Sets the moment size . -eps_ciss_partitions - Sets the number of partitions . -eps_ciss_maxblocksize - Sets the maximum block size - -eps_ciss_realmats - A and B are real Note: The default number of partitions is 1. This means the internal KSP object is shared among all processes of the EPS communicator. Otherwise, the communicator is split into npart communicators, so that npart KSP solves proceed simultaneously. Level: advanced .seealso: EPSCISSGetSizes() @*/ PetscErrorCode EPSCISSSetSizes(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,ip,2); PetscValidLogicalCollectiveInt(eps,bs,3); PetscValidLogicalCollectiveInt(eps,ms,4); PetscValidLogicalCollectiveInt(eps,npart,5); PetscValidLogicalCollectiveInt(eps,bsmax,6); PetscValidLogicalCollectiveBool(eps,realmats,7); ierr = PetscTryMethod(eps,"EPSCISSSetSizes_C",(EPS,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool),(eps,ip,bs,ms,npart,bsmax,realmats));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetSizes_CISS" static PetscErrorCode EPSCISSGetSizes_CISS(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; if (ip) *ip = ctx->N; if (bs) *bs = ctx->L; if (ms) *ms = ctx->M; if (npart) *npart = ctx->num_subcomm; if (bsmax) *bsmax = ctx->L_max; if (realmats) *realmats = ctx->isreal; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetSizes" /*@ EPSCISSGetSizes - Gets the values of various size parameters in the CISS solver. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: + ip - number of integration points . bs - block size . ms - moment size . npart - number of partitions when splitting the communicator . bsmax - max block size - realmats - A and B are real Level: advanced .seealso: EPSCISSSetSizes() @*/ PetscErrorCode EPSCISSGetSizes(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSCISSGetSizes_C",(EPS,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*),(eps,ip,bs,ms,npart,bsmax,realmats));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetThreshold_CISS" static PetscErrorCode EPSCISSSetThreshold_CISS(EPS eps,PetscReal delta,PetscReal spur) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; if (delta == PETSC_DEFAULT) { ctx->delta = 1e-12; } else { if (delta<=0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The delta argument must be > 0.0"); ctx->delta = delta; } if (spur == PETSC_DEFAULT) { ctx->spurious_threshold = 1e-4; } else { if (spur<=0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The spurious threshold argument must be > 0.0"); ctx->spurious_threshold = spur; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetThreshold" /*@ EPSCISSSetThreshold - Sets the values of various threshold parameters in the CISS solver. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . delta - threshold for numerical rank - spur - spurious threshold (to discard spurious eigenpairs) Options Database Keys: + -eps_ciss_delta - Sets the delta - -eps_ciss_spurious_threshold - Sets the spurious threshold Level: advanced .seealso: EPSCISSGetThreshold() @*/ PetscErrorCode EPSCISSSetThreshold(EPS eps,PetscReal delta,PetscReal spur) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveReal(eps,delta,2); PetscValidLogicalCollectiveReal(eps,spur,3); ierr = PetscTryMethod(eps,"EPSCISSSetThreshold_C",(EPS,PetscReal,PetscReal),(eps,delta,spur));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetThreshold_CISS" static PetscErrorCode EPSCISSGetThreshold_CISS(EPS eps,PetscReal *delta,PetscReal *spur) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; if (delta) *delta = ctx->delta; if (spur) *spur = ctx->spurious_threshold; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetThreshold" /*@ EPSCISSGetThreshold - Gets the values of various threshold parameters in the CISS solver. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: + delta - threshold for numerical rank - spur - spurious threshold (to discard spurious eigenpairs) Level: advanced .seealso: EPSCISSSetThreshold() @*/ PetscErrorCode EPSCISSGetThreshold(EPS eps,PetscReal *delta,PetscReal *spur) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSCISSGetThreshold_C",(EPS,PetscReal*,PetscReal*),(eps,delta,spur));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetRefinement_CISS" static PetscErrorCode EPSCISSSetRefinement_CISS(EPS eps,PetscInt inner,PetscInt blsize) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; if (inner == PETSC_DEFAULT) { ctx->refine_inner = 0; } else { if (inner<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The refine inner argument must be >= 0"); ctx->refine_inner = inner; } if (blsize == PETSC_DEFAULT) { ctx->refine_blocksize = 0; } else { if (blsize<0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The refine blocksize argument must be >= 0"); ctx->refine_blocksize = blsize; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetRefinement" /*@ EPSCISSSetRefinement - Sets the values of various refinement parameters in the CISS solver. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . inner - number of iterative refinement iterations (inner loop) - blsize - number of iterative refinement iterations (blocksize loop) Options Database Keys: + -eps_ciss_refine_inner - Sets number of inner iterations - -eps_ciss_refine_blocksize - Sets number of blocksize iterations Level: advanced .seealso: EPSCISSGetRefinement() @*/ PetscErrorCode EPSCISSSetRefinement(EPS eps,PetscInt inner,PetscInt blsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,inner,2); PetscValidLogicalCollectiveInt(eps,blsize,3); ierr = PetscTryMethod(eps,"EPSCISSSetRefinement_C",(EPS,PetscInt,PetscInt),(eps,inner,blsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetRefinement_CISS" static PetscErrorCode EPSCISSGetRefinement_CISS(EPS eps,PetscInt *inner,PetscInt *blsize) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; if (inner) *inner = ctx->refine_inner; if (blsize) *blsize = ctx->refine_blocksize; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetRefinement" /*@ EPSCISSGetRefinement - Gets the values of various refinement parameters in the CISS solver. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: + inner - number of iterative refinement iterations (inner loop) - blsize - number of iterative refinement iterations (blocksize loop) Level: advanced .seealso: EPSCISSSetRefinement() @*/ PetscErrorCode EPSCISSGetRefinement(EPS eps, PetscInt *inner, PetscInt *blsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSCISSGetRefinement_C",(EPS,PetscInt*,PetscInt*),(eps,inner,blsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetUseST_CISS" static PetscErrorCode EPSCISSSetUseST_CISS(EPS eps,PetscBool usest) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; ctx->usest = usest; ctx->usest_set = PETSC_TRUE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetUseST" /*@ EPSCISSSetUseST - Sets a flag indicating that the CISS solver will use the ST object for the linear solves. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - usest - boolean flag to use the ST object or not Options Database Keys: . -eps_ciss_usest - whether the ST object will be used or not Level: advanced .seealso: EPSCISSGetUseST() @*/ PetscErrorCode EPSCISSSetUseST(EPS eps,PetscBool usest) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,usest,2); ierr = PetscTryMethod(eps,"EPSCISSSetUseST_C",(EPS,PetscBool),(eps,usest));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetUseST_CISS" static PetscErrorCode EPSCISSGetUseST_CISS(EPS eps,PetscBool *usest) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; *usest = ctx->usest; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetUseST" /*@ EPSCISSGetUseST - Gets the flag for using the ST object in the CISS solver. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: . usest - boolean flag indicating if the ST object is being used Level: advanced .seealso: EPSCISSSetUseST() @*/ PetscErrorCode EPSCISSGetUseST(EPS eps,PetscBool *usest) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(usest,2); ierr = PetscUseMethod(eps,"EPSCISSGetUseST_C",(EPS,PetscBool*),(eps,usest));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetQuadRule_CISS" static PetscErrorCode EPSCISSSetQuadRule_CISS(EPS eps,EPSCISSQuadRule quad) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; ctx->quad = quad; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetQuadRule" /*@ EPSCISSSetQuadRule - Sets the quadrature rule used in the CISS solver. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - quad - the quadrature rule Options Database Key: . -eps_ciss_quadrule - Sets the quadrature rule (either 'trapezoidal' or 'chebyshev') Notes: By default, the trapezoidal rule is used (EPS_CISS_QUADRULE_TRAPEZOIDAL). If the 'chebyshev' option is specified (EPS_CISS_QUADRULE_CHEBYSHEV), then Chebyshev points are used as quadrature points. Level: advanced .seealso: EPSCISSGetQuadRule(), EPSCISSQuadRule @*/ PetscErrorCode EPSCISSSetQuadRule(EPS eps,EPSCISSQuadRule quad) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,quad,2); ierr = PetscTryMethod(eps,"EPSCISSSetQuadRule_C",(EPS,EPSCISSQuadRule),(eps,quad));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetQuadRule_CISS" static PetscErrorCode EPSCISSGetQuadRule_CISS(EPS eps,EPSCISSQuadRule *quad) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; *quad = ctx->quad; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetQuadRule" /*@ EPSCISSGetQuadRule - Gets the quadrature rule used in the CISS solver. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: . quad - quadrature rule Level: advanced .seealso: EPSCISSSetQuadRule() EPSCISSQuadRule @*/ PetscErrorCode EPSCISSGetQuadRule(EPS eps, EPSCISSQuadRule *quad) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(quad,2); ierr = PetscUseMethod(eps,"EPSCISSGetQuadRule_C",(EPS,EPSCISSQuadRule*),(eps,quad));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetExtraction_CISS" static PetscErrorCode EPSCISSSetExtraction_CISS(EPS eps,EPSCISSExtraction extraction) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; ctx->extraction = extraction; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSSetExtraction" /*@ EPSCISSSetExtraction - Sets the extraction technique used in the CISS solver. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - extraction - the extraction technique Options Database Key: . -eps_ciss_extraction - Sets the extraction technique (either 'ritz' or 'hankel') Notes: By default, the Rayleigh-Ritz extraction is used (EPS_CISS_EXTRACTION_RITZ). If the 'hankel' option is specified (EPS_CISS_EXTRACTION_HANKEL), then the Block Hankel method is used for extracting eigenpairs. Level: advanced .seealso: EPSCISSGetExtraction(), EPSCISSExtraction @*/ PetscErrorCode EPSCISSSetExtraction(EPS eps,EPSCISSExtraction extraction) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,extraction,2); ierr = PetscTryMethod(eps,"EPSCISSSetExtraction_C",(EPS,EPSCISSExtraction),(eps,extraction));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetExtraction_CISS" static PetscErrorCode EPSCISSGetExtraction_CISS(EPS eps,EPSCISSExtraction *extraction) { EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; *extraction = ctx->extraction; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCISSGetExtraction" /*@ EPSCISSGetExtraction - Gets the extraction technique used in the CISS solver. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: + extraction - extraction technique Level: advanced .seealso: EPSCISSSetExtraction() EPSCISSExtraction @*/ PetscErrorCode EPSCISSGetExtraction(EPS eps,EPSCISSExtraction *extraction) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(extraction,2); ierr = PetscUseMethod(eps,"EPSCISSGetExtraction_C",(EPS,EPSCISSExtraction*),(eps,extraction));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_CISS" PetscErrorCode EPSReset_CISS(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscInt i; PetscFunctionBegin; ierr = PetscSubcommDestroy(&ctx->subcomm);CHKERRQ(ierr); ierr = PetscFree4(ctx->weight,ctx->omega,ctx->pp,ctx->sigma);CHKERRQ(ierr); ierr = BVDestroy(&ctx->S);CHKERRQ(ierr); ierr = BVDestroy(&ctx->V);CHKERRQ(ierr); ierr = BVDestroy(&ctx->Y);CHKERRQ(ierr); if (!ctx->usest) { for (i=0;inum_solve_point;i++) { ierr = KSPDestroy(&ctx->ksp[i]);CHKERRQ(ierr); } for (i=0;inum_solve_point;i++) { ierr = MatDestroy(&ctx->kspMat[i]);CHKERRQ(ierr); } ierr = PetscFree2(ctx->ksp,ctx->kspMat);CHKERRQ(ierr); } ierr = VecScatterDestroy(&ctx->scatterin);CHKERRQ(ierr); ierr = VecDestroy(&ctx->xsub);CHKERRQ(ierr); ierr = VecDestroy(&ctx->xdup);CHKERRQ(ierr); if (ctx->pA) { ierr = MatDestroy(&ctx->pA);CHKERRQ(ierr); ierr = MatDestroy(&ctx->pB);CHKERRQ(ierr); ierr = BVDestroy(&ctx->pV);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_CISS" PetscErrorCode EPSSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; PetscReal r3,r4; PetscInt i1,i2,i3,i4,i5,i6,i7; PetscBool b1,b2,flg; EPS_CISS *ctx = (EPS_CISS*)eps->data; EPSCISSQuadRule quad; EPSCISSExtraction extraction; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS CISS Options");CHKERRQ(ierr); ierr = EPSCISSGetSizes(eps,&i1,&i2,&i3,&i4,&i5,&b1);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_ciss_integration_points","CISS number of integration points","EPSCISSSetSizes",i1,&i1,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_ciss_blocksize","CISS block size","EPSCISSSetSizes",i2,&i2,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_ciss_moments","CISS moment size","EPSCISSSetSizes",i3,&i3,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_ciss_partitions","CISS number of partitions","EPSCISSSetSizes",i4,&i4,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_ciss_maxblocksize","CISS maximum block size","EPSCISSSetSizes",i5,&i5,NULL);CHKERRQ(ierr); ierr = PetscOptionsBool("-eps_ciss_realmats","CISS A and B are real","EPSCISSSetSizes",b1,&b1,NULL);CHKERRQ(ierr); ierr = EPSCISSSetSizes(eps,i1,i2,i3,i4,i5,b1);CHKERRQ(ierr); ierr = EPSCISSGetThreshold(eps,&r3,&r4);CHKERRQ(ierr); ierr = PetscOptionsReal("-eps_ciss_delta","CISS threshold for numerical rank","EPSCISSSetThreshold",r3,&r3,NULL);CHKERRQ(ierr); ierr = PetscOptionsReal("-eps_ciss_spurious_threshold","CISS threshold for the spurious eigenpairs","EPSCISSSetThreshold",r4,&r4,NULL);CHKERRQ(ierr); ierr = EPSCISSSetThreshold(eps,r3,r4);CHKERRQ(ierr); ierr = EPSCISSGetRefinement(eps,&i6,&i7);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_ciss_refine_inner","CISS number of inner iterative refinement iterations","EPSCISSSetRefinement",i6,&i6,NULL);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_ciss_refine_blocksize","CISS number of blocksize iterative refinement iterations","EPSCISSSetRefinement",i7,&i7,NULL);CHKERRQ(ierr); ierr = EPSCISSSetRefinement(eps,i6,i7);CHKERRQ(ierr); ierr = EPSCISSGetUseST(eps,&b2);CHKERRQ(ierr); ierr = PetscOptionsBool("-eps_ciss_usest","CISS use ST for linear solves","EPSCISSSetUseST",b2,&b2,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSCISSSetUseST(eps,b2);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-eps_ciss_quadrule","Quadrature rule","EPSCISSSetQuadRule",EPSCISSQuadRules,(PetscEnum)ctx->quad,(PetscEnum*)&quad,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSCISSSetQuadRule(eps,quad);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-eps_ciss_extraction","Extraction technique","EPSCISSSetExtraction",EPSCISSExtractions,(PetscEnum)ctx->extraction,(PetscEnum*)&extraction,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSCISSSetExtraction(eps,extraction);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_CISS" PetscErrorCode EPSDestroy_CISS(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetThreshold_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetThreshold_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetRefinement_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetRefinement_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetUseST_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetUseST_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetQuadRule_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetQuadRule_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetExtraction_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetExtraction_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_CISS" PetscErrorCode EPSView_CISS(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," CISS: sizes { integration points: %D, block size: %D, moment size: %D, partitions: %D, maximum block size: %D }\n",ctx->N,ctx->L,ctx->M,ctx->num_subcomm,ctx->L_max);CHKERRQ(ierr); if (ctx->isreal) { ierr = PetscViewerASCIIPrintf(viewer," CISS: exploiting symmetry of integration points\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," CISS: threshold { delta: %g, spurious threshold: %g }\n",(double)ctx->delta,(double)ctx->spurious_threshold);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," CISS: iterative refinement { inner: %D, blocksize: %D }\n",ctx->refine_inner, ctx->refine_blocksize);CHKERRQ(ierr); if (ctx->usest) { ierr = PetscViewerASCIIPrintf(viewer," CISS: using ST for linear solves\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," CISS: extraction: %s\n",EPSCISSExtractions[ctx->extraction]);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," CISS: quadrature rule: %s\n",EPSCISSQuadRules[ctx->quad]);CHKERRQ(ierr); ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); if (!ctx->usest && ctx->ksp[0]) { ierr = KSPView(ctx->ksp[0],viewer);CHKERRQ(ierr); } ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_CISS" PETSC_EXTERN PetscErrorCode EPSCreate_CISS(EPS eps) { PetscErrorCode ierr; EPS_CISS *ctx = (EPS_CISS*)eps->data; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = ctx; eps->ops->solve = EPSSolve_CISS; eps->ops->setup = EPSSetUp_CISS; eps->ops->setfromoptions = EPSSetFromOptions_CISS; eps->ops->destroy = EPSDestroy_CISS; eps->ops->reset = EPSReset_CISS; eps->ops->view = EPSView_CISS; eps->ops->backtransform = NULL; eps->ops->computevectors = EPSComputeVectors_Schur; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetSizes_C",EPSCISSSetSizes_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetSizes_C",EPSCISSGetSizes_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetThreshold_C",EPSCISSSetThreshold_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetThreshold_C",EPSCISSGetThreshold_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetRefinement_C",EPSCISSSetRefinement_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetRefinement_C",EPSCISSGetRefinement_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetUseST_C",EPSCISSSetUseST_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetUseST_C",EPSCISSGetUseST_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetQuadRule_C",EPSCISSSetQuadRule_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetQuadRule_C",EPSCISSGetQuadRule_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSSetExtraction_C",EPSCISSSetExtraction_CISS);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSCISSGetExtraction_C",EPSCISSGetExtraction_CISS);CHKERRQ(ierr); /* set default values of parameters */ ctx->N = 32; ctx->L = 16; ctx->M = ctx->N/4; ctx->delta = 1e-12; ctx->L_max = 64; ctx->spurious_threshold = 1e-4; ctx->usest = PETSC_TRUE; ctx->usest_set = PETSC_FALSE; ctx->isreal = PETSC_FALSE; ctx->refine_inner = 0; ctx->refine_blocksize = 0; ctx->num_subcomm = 1; ctx->quad = (EPSCISSQuadRule)0; ctx->extraction = EPS_CISS_EXTRACTION_RITZ; PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/ciss/index.html0000644000175000017500000000257013107004621017627 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

ciss.c
makefile
slepc-3.7.4/src/eps/impls/ciss/ftn-auto/0000755000175000017500000000000013107004621017363 5ustar jromanjromanslepc-3.7.4/src/eps/impls/ciss/ftn-auto/makefile0000644000175000017500000000035513107004621021066 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = cissf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/ciss/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/ciss/ftn-auto/cissf.c0000644000175000017500000001273513107004621020646 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* ciss.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscisssetsizes_ EPSCISSSETSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscisssetsizes_ epscisssetsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscissgetsizes_ EPSCISSGETSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscissgetsizes_ epscissgetsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscisssetthreshold_ EPSCISSSETTHRESHOLD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscisssetthreshold_ epscisssetthreshold #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscissgetthreshold_ EPSCISSGETTHRESHOLD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscissgetthreshold_ epscissgetthreshold #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscisssetrefinement_ EPSCISSSETREFINEMENT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscisssetrefinement_ epscisssetrefinement #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscissgetrefinement_ EPSCISSGETREFINEMENT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscissgetrefinement_ epscissgetrefinement #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscisssetusest_ EPSCISSSETUSEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscisssetusest_ epscisssetusest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscissgetusest_ EPSCISSGETUSEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscissgetusest_ epscissgetusest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscisssetquadrule_ EPSCISSSETQUADRULE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscisssetquadrule_ epscisssetquadrule #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscissgetquadrule_ EPSCISSGETQUADRULE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscissgetquadrule_ epscissgetquadrule #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscisssetextraction_ EPSCISSSETEXTRACTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscisssetextraction_ epscisssetextraction #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epscissgetextraction_ EPSCISSGETEXTRACTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epscissgetextraction_ epscissgetextraction #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epscisssetsizes_(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats, int *__ierr ){ *__ierr = EPSCISSSetSizes( (EPS)PetscToPointer((eps) ),*ip,*bs,*ms,*npart,*bsmax,*realmats); } PETSC_EXTERN void PETSC_STDCALL epscissgetsizes_(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats, int *__ierr ){ *__ierr = EPSCISSGetSizes( (EPS)PetscToPointer((eps) ),ip,bs,ms,npart,bsmax,realmats); } PETSC_EXTERN void PETSC_STDCALL epscisssetthreshold_(EPS eps,PetscReal *delta,PetscReal *spur, int *__ierr ){ *__ierr = EPSCISSSetThreshold( (EPS)PetscToPointer((eps) ),*delta,*spur); } PETSC_EXTERN void PETSC_STDCALL epscissgetthreshold_(EPS eps,PetscReal *delta,PetscReal *spur, int *__ierr ){ *__ierr = EPSCISSGetThreshold( (EPS)PetscToPointer((eps) ),delta,spur); } PETSC_EXTERN void PETSC_STDCALL epscisssetrefinement_(EPS eps,PetscInt *inner,PetscInt *blsize, int *__ierr ){ *__ierr = EPSCISSSetRefinement( (EPS)PetscToPointer((eps) ),*inner,*blsize); } PETSC_EXTERN void PETSC_STDCALL epscissgetrefinement_(EPS eps,PetscInt *inner,PetscInt *blsize, int *__ierr ){ *__ierr = EPSCISSGetRefinement( (EPS)PetscToPointer((eps) ),inner,blsize); } PETSC_EXTERN void PETSC_STDCALL epscisssetusest_(EPS eps,PetscBool *usest, int *__ierr ){ *__ierr = EPSCISSSetUseST( (EPS)PetscToPointer((eps) ),*usest); } PETSC_EXTERN void PETSC_STDCALL epscissgetusest_(EPS eps,PetscBool *usest, int *__ierr ){ *__ierr = EPSCISSGetUseST( (EPS)PetscToPointer((eps) ),usest); } PETSC_EXTERN void PETSC_STDCALL epscisssetquadrule_(EPS eps,EPSCISSQuadRule *quad, int *__ierr ){ *__ierr = EPSCISSSetQuadRule( (EPS)PetscToPointer((eps) ),*quad); } PETSC_EXTERN void PETSC_STDCALL epscissgetquadrule_(EPS eps,EPSCISSQuadRule *quad, int *__ierr ){ *__ierr = EPSCISSGetQuadRule( (EPS)PetscToPointer((eps) ),quad); } PETSC_EXTERN void PETSC_STDCALL epscisssetextraction_(EPS eps,EPSCISSExtraction *extraction, int *__ierr ){ *__ierr = EPSCISSSetExtraction( (EPS)PetscToPointer((eps) ),*extraction); } PETSC_EXTERN void PETSC_STDCALL epscissgetextraction_(EPS eps,EPSCISSExtraction *extraction, int *__ierr ){ *__ierr = EPSCISSGetExtraction( (EPS)PetscToPointer((eps) ),extraction); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/lapack/0000755000175000017500000000000013107004621016120 5ustar jromanjromanslepc-3.7.4/src/eps/impls/lapack/makefile0000644000175000017500000000215613107004621017624 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = lapack.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/lapack/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/lapack/lapack.c.html0000644000175000017500000003514413107004621020471 0ustar jromanjroman

Actual source code: lapack.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This file implements a wrapper to the LAPACK eigenvalue subroutines.
  3:    Generalized problems are transformed to standard ones only if necessary.

  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: */

 25: #include <slepc/private/epsimpl.h>

 29: PetscErrorCode EPSSetUp_LAPACK(EPS eps)
 30: {
 31:   PetscErrorCode ierr,ierra,ierrb;
 32:   PetscBool      isshift,denseok=PETSC_FALSE;
 33:   Mat            A,B,OP,Adense=NULL,Bdense=NULL;
 34:   PetscScalar    shift,*Ap,*Bp;
 35:   PetscInt       i,ld,nmat;
 36:   KSP            ksp;
 37:   PC             pc;
 38:   Vec            v;

 41:   eps->ncv = eps->n;
 42:   if (eps->mpd) { PetscInfo(eps,"Warning: parameter mpd ignored\n"); }
 43:   if (!eps->which) { EPSSetWhichEigenpairs_Default(eps); }
 44:   if (eps->balance!=EPS_BALANCE_NONE) { PetscInfo(eps,"Warning: balancing ignored\n"); }
 45:   if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"User-defined stopping test not supported");
 46:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }
 47:   EPSAllocateSolution(eps,0);

 49:   /* attempt to get dense representations of A and B separately */
 50:   PetscObjectTypeCompare((PetscObject)eps->st,STSHIFT,&isshift);
 51:   if (isshift) {
 52:     STGetNumMatrices(eps->st,&nmat);
 53:     STGetOperators(eps->st,0,&A);
 54:     if (nmat>1) { STGetOperators(eps->st,1,&B); }
 55:     PetscPushErrorHandler(PetscIgnoreErrorHandler,NULL);
 56:     ierra = SlepcMatConvertSeqDense(A,&Adense);
 57:     if (nmat>1) {
 58:       ierrb = SlepcMatConvertSeqDense(B,&Bdense);
 59:     } else {
 60:       ierrb = 0;
 61:     }
 62:     PetscPopErrorHandler();
 63:     denseok = PetscNot(ierra || ierrb);
 64:   }

 66:   /* setup DS */
 67:   if (denseok) {
 68:     if (eps->isgeneralized) {
 69:       if (eps->ishermitian) {
 70:         if (eps->ispositive) {
 71:           DSSetType(eps->ds,DSGHEP);
 72:         } else {
 73:           DSSetType(eps->ds,DSGNHEP); /* TODO: should be DSGHIEP */
 74:         }
 75:       } else {
 76:         DSSetType(eps->ds,DSGNHEP);
 77:       }
 78:     } else {
 79:       if (eps->ishermitian) {
 80:         DSSetType(eps->ds,DSHEP);
 81:       } else {
 82:         DSSetType(eps->ds,DSNHEP);
 83:       }
 84:     }
 85:   } else {
 86:     DSSetType(eps->ds,DSNHEP);
 87:   }
 88:   DSAllocate(eps->ds,eps->ncv);
 89:   DSGetLeadingDimension(eps->ds,&ld);
 90:   DSSetDimensions(eps->ds,eps->ncv,0,0,0);

 92:   if (denseok) {
 93:     STGetShift(eps->st,&shift);
 94:     if (shift != 0.0) {
 95:       MatShift(Adense,shift);
 96:     }
 97:     /* use dummy pc and ksp to avoid problems when B is not positive definite */
 98:     STGetKSP(eps->st,&ksp);
 99:     KSPSetType(ksp,KSPPREONLY);
100:     KSPGetPC(ksp,&pc);
101:     PCSetType(pc,PCNONE);
102:   } else {
103:     PetscInfo(eps,"Using slow explicit operator\n");
104:     STComputeExplicitOperator(eps->st,&OP);
105:     MatDestroy(&Adense);
106:     SlepcMatConvertSeqDense(OP,&Adense);
107:   }

109:   /* fill DS matrices */
110:   VecCreateSeqWithArray(PETSC_COMM_SELF,1,ld,NULL,&v);
111:   DSGetArray(eps->ds,DS_MAT_A,&Ap);
112:   for (i=0;i<ld;i++) {
113:     VecPlaceArray(v,Ap+i*ld);
114:     MatGetColumnVector(Adense,v,i);
115:     VecResetArray(v);
116:   }
117:   DSRestoreArray(eps->ds,DS_MAT_A,&Ap);
118:   if (denseok && eps->isgeneralized) {
119:     DSGetArray(eps->ds,DS_MAT_B,&Bp);
120:     for (i=0;i<ld;i++) {
121:       VecPlaceArray(v,Bp+i*ld);
122:       MatGetColumnVector(Bdense,v,i);
123:       VecResetArray(v);
124:     }
125:     DSRestoreArray(eps->ds,DS_MAT_B,&Bp);
126:   }
127:   VecDestroy(&v);
128:   MatDestroy(&Adense);
129:   if (!denseok) { MatDestroy(&OP); }
130:   if (denseok && eps->isgeneralized) { MatDestroy(&Bdense); }
131:   return(0);
132: }

136: PetscErrorCode EPSSolve_LAPACK(EPS eps)
137: {
139:   PetscInt       n=eps->n,i,low,high;
140:   PetscScalar    *array,*pX;
141:   Vec            v;

144:   DSSolve(eps->ds,eps->eigr,eps->eigi);
145:   DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);

147:   /* right eigenvectors */
148:   DSVectors(eps->ds,DS_MAT_X,NULL,NULL);
149:   DSGetArray(eps->ds,DS_MAT_X,&pX);
150:   for (i=0;i<eps->ncv;i++) {
151:     BVGetColumn(eps->V,i,&v);
152:     VecGetOwnershipRange(v,&low,&high);
153:     VecGetArray(v,&array);
154:     PetscMemcpy(array,pX+i*n+low,(high-low)*sizeof(PetscScalar));
155:     VecRestoreArray(v,&array);
156:     BVRestoreColumn(eps->V,i,&v);
157:   }
158:   DSRestoreArray(eps->ds,DS_MAT_X,&pX);

160:   eps->nconv  = eps->ncv;
161:   eps->its    = 1;
162:   eps->reason = EPS_CONVERGED_TOL;
163:   return(0);
164: }

168: PETSC_EXTERN PetscErrorCode EPSCreate_LAPACK(EPS eps)
169: {
171:   eps->ops->solve                = EPSSolve_LAPACK;
172:   eps->ops->setup                = EPSSetUp_LAPACK;
173:   eps->ops->backtransform        = EPSBackTransform_Default;
174:   return(0);
175: }

slepc-3.7.4/src/eps/impls/lapack/makefile.html0000644000175000017500000000466013107004621020571 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = lapack.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/lapack/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/lapack/index.html0000644000175000017500000000260013107004621020113 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

lapack.c
makefile
slepc-3.7.4/src/eps/impls/lapack/lapack.c0000644000175000017500000001475013107004621017526 0ustar jromanjroman/* This file implements a wrapper to the LAPACK eigenvalue subroutines. Generalized problems are transformed to standard ones only if necessary. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_LAPACK" PetscErrorCode EPSSetUp_LAPACK(EPS eps) { PetscErrorCode ierr,ierra,ierrb; PetscBool isshift,denseok=PETSC_FALSE; Mat A,B,OP,Adense=NULL,Bdense=NULL; PetscScalar shift,*Ap,*Bp; PetscInt i,ld,nmat; KSP ksp; PC pc; Vec v; PetscFunctionBegin; eps->ncv = eps->n; if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (!eps->which) { ierr = EPSSetWhichEigenpairs_Default(eps);CHKERRQ(ierr); } if (eps->balance!=EPS_BALANCE_NONE) { ierr = PetscInfo(eps,"Warning: balancing ignored\n");CHKERRQ(ierr); } if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"User-defined stopping test not supported"); if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); /* attempt to get dense representations of A and B separately */ ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSHIFT,&isshift);CHKERRQ(ierr); if (isshift) { ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } PetscPushErrorHandler(PetscIgnoreErrorHandler,NULL); ierra = SlepcMatConvertSeqDense(A,&Adense);CHKERRQ(ierr); if (nmat>1) { ierrb = SlepcMatConvertSeqDense(B,&Bdense);CHKERRQ(ierr); } else { ierrb = 0; } PetscPopErrorHandler(); denseok = PetscNot(ierra || ierrb); } /* setup DS */ if (denseok) { if (eps->isgeneralized) { if (eps->ishermitian) { if (eps->ispositive) { ierr = DSSetType(eps->ds,DSGHEP);CHKERRQ(ierr); } else { ierr = DSSetType(eps->ds,DSGNHEP);CHKERRQ(ierr); /* TODO: should be DSGHIEP */ } } else { ierr = DSSetType(eps->ds,DSGNHEP);CHKERRQ(ierr); } } else { if (eps->ishermitian) { ierr = DSSetType(eps->ds,DSHEP);CHKERRQ(ierr); } else { ierr = DSSetType(eps->ds,DSNHEP);CHKERRQ(ierr); } } } else { ierr = DSSetType(eps->ds,DSNHEP);CHKERRQ(ierr); } ierr = DSAllocate(eps->ds,eps->ncv);CHKERRQ(ierr); ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,eps->ncv,0,0,0);CHKERRQ(ierr); if (denseok) { ierr = STGetShift(eps->st,&shift);CHKERRQ(ierr); if (shift != 0.0) { ierr = MatShift(Adense,shift);CHKERRQ(ierr); } /* use dummy pc and ksp to avoid problems when B is not positive definite */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCNONE);CHKERRQ(ierr); } else { ierr = PetscInfo(eps,"Using slow explicit operator\n");CHKERRQ(ierr); ierr = STComputeExplicitOperator(eps->st,&OP);CHKERRQ(ierr); ierr = MatDestroy(&Adense);CHKERRQ(ierr); ierr = SlepcMatConvertSeqDense(OP,&Adense);CHKERRQ(ierr); } /* fill DS matrices */ ierr = VecCreateSeqWithArray(PETSC_COMM_SELF,1,ld,NULL,&v);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_A,&Ap);CHKERRQ(ierr); for (i=0;ids,DS_MAT_A,&Ap);CHKERRQ(ierr); if (denseok && eps->isgeneralized) { ierr = DSGetArray(eps->ds,DS_MAT_B,&Bp);CHKERRQ(ierr); for (i=0;ids,DS_MAT_B,&Bp);CHKERRQ(ierr); } ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = MatDestroy(&Adense);CHKERRQ(ierr); if (!denseok) { ierr = MatDestroy(&OP);CHKERRQ(ierr); } if (denseok && eps->isgeneralized) { ierr = MatDestroy(&Bdense);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_LAPACK" PetscErrorCode EPSSolve_LAPACK(EPS eps) { PetscErrorCode ierr; PetscInt n=eps->n,i,low,high; PetscScalar *array,*pX; Vec v; PetscFunctionBegin; ierr = DSSolve(eps->ds,eps->eigr,eps->eigi);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);CHKERRQ(ierr); /* right eigenvectors */ ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); for (i=0;incv;i++) { ierr = BVGetColumn(eps->V,i,&v);CHKERRQ(ierr); ierr = VecGetOwnershipRange(v,&low,&high);CHKERRQ(ierr); ierr = VecGetArray(v,&array);CHKERRQ(ierr); ierr = PetscMemcpy(array,pX+i*n+low,(high-low)*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArray(v,&array);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&v);CHKERRQ(ierr); } ierr = DSRestoreArray(eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); eps->nconv = eps->ncv; eps->its = 1; eps->reason = EPS_CONVERGED_TOL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_LAPACK" PETSC_EXTERN PetscErrorCode EPSCreate_LAPACK(EPS eps) { PetscFunctionBegin; eps->ops->solve = EPSSolve_LAPACK; eps->ops->setup = EPSSetUp_LAPACK; eps->ops->backtransform = EPSBackTransform_Default; PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/power/0000755000175000017500000000000013107004621016021 5ustar jromanjromanslepc-3.7.4/src/eps/impls/power/makefile0000644000175000017500000000215413107004621017523 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = power.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/power/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/power/power.c0000644000175000017500000003402713107004621017327 0ustar jromanjroman/* SLEPc eigensolver: "power" Method: Power Iteration Algorithm: This solver implements the power iteration for finding dominant eigenpairs. It also includes the following well-known methods: - Inverse Iteration: when used in combination with shift-and-invert spectral transformation. - Rayleigh Quotient Iteration (RQI): also with shift-and-invert plus a variable shift. References: [1] "Single Vector Iteration Methods in SLEPc", SLEPc Technical Report STR-2, available at http://slepc.upv.es. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include typedef struct { EPSPowerShiftType shift_type; } EPS_POWER; #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_Power" PetscErrorCode EPSSetUp_Power(EPS eps) { PetscErrorCode ierr; EPS_POWER *power = (EPS_POWER*)eps->data; PetscBool flg,istrivial; STMatMode mode; PetscFunctionBegin; if (eps->ncv) { if (eps->ncvnev) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must be at least nev"); } else eps->ncv = eps->nev; if (eps->mpd) { ierr = PetscInfo(eps,"Warning: parameter mpd ignored\n");CHKERRQ(ierr); } if (!eps->max_it) eps->max_it = PetscMax(2000,100*eps->n); if (!eps->which) { ierr = EPSSetWhichEigenpairs_Default(eps);CHKERRQ(ierr); } if (eps->which!=EPS_LARGEST_MAGNITUDE && eps->which !=EPS_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (power->shift_type != EPS_POWER_SHIFT_CONSTANT) { ierr = PetscObjectTypeCompareAny((PetscObject)eps->st,&flg,STSINVERT,STCAYLEY,"");CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Variable shifts only allowed in shift-and-invert or Cayley ST"); ierr = STGetMatMode(eps->st,&mode);CHKERRQ(ierr); if (mode == ST_MATMODE_INPLACE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"ST matrix mode inplace does not work with variable shifts"); } if (eps->extraction) { ierr = PetscInfo(eps,"Warning: extraction type ignored\n");CHKERRQ(ierr); } if (eps->balance!=EPS_BALANCE_NONE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Balancing not supported in this solver"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering"); ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); ierr = EPSSetWorkVecs(eps,2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_Power" PetscErrorCode EPSSolve_Power(EPS eps) { #if defined(SLEPC_MISSING_LAPACK_LAEV2) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAEV2 - Lapack routine is unavailable"); #else PetscErrorCode ierr; EPS_POWER *power = (EPS_POWER*)eps->data; PetscInt k; Vec v,y,e; Mat A; PetscReal relerr,norm,rt1,rt2,cs1; PetscScalar theta,rho,delta,sigma,alpha2,beta1,sn1; PetscBool breakdown; PetscFunctionBegin; y = eps->work[1]; e = eps->work[0]; ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); ierr = STGetShift(eps->st,&sigma);CHKERRQ(ierr); /* original shift */ rho = sigma; while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; k = eps->nconv; /* y = OP v */ ierr = BVGetColumn(eps->V,k,&v);CHKERRQ(ierr); ierr = STApply(eps->st,v,y);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,k,&v);CHKERRQ(ierr); /* theta = (v,y)_B */ ierr = BVSetActiveColumns(eps->V,k,k+1);CHKERRQ(ierr); ierr = BVDotVec(eps->V,y,&theta);CHKERRQ(ierr); if (power->shift_type == EPS_POWER_SHIFT_CONSTANT) { /* direct & inverse iteration */ /* approximate eigenvalue is the Rayleigh quotient */ eps->eigr[eps->nconv] = theta; /* compute relative error as ||y-theta v||_2/|theta| */ ierr = VecCopy(y,e);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,k,&v);CHKERRQ(ierr); ierr = VecAXPY(e,-theta,v);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,k,&v);CHKERRQ(ierr); ierr = VecNorm(e,NORM_2,&norm);CHKERRQ(ierr); relerr = norm / PetscAbsScalar(theta); } else { /* RQI */ /* delta = ||y||_B */ ierr = BVNormVec(eps->V,y,NORM_2,&norm);CHKERRQ(ierr); delta = norm; /* compute relative error */ if (rho == 0.0) relerr = PETSC_MAX_REAL; else relerr = 1.0 / (norm*PetscAbsScalar(rho)); /* approximate eigenvalue is the shift */ eps->eigr[eps->nconv] = rho; /* compute new shift */ if (relerrtol) { rho = sigma; /* if converged, restore original shift */ ierr = STSetShift(eps->st,rho);CHKERRQ(ierr); } else { rho = rho + theta/(delta*delta); /* Rayleigh quotient R(v) */ if (power->shift_type == EPS_POWER_SHIFT_WILKINSON) { /* beta1 is the norm of the residual associated to R(v) */ ierr = BVGetColumn(eps->V,k,&v);CHKERRQ(ierr); ierr = VecAXPY(v,-theta/(delta*delta),y);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,k,&v);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,k,1.0/delta);CHKERRQ(ierr); ierr = BVNormColumn(eps->V,k,NORM_2,&norm);CHKERRQ(ierr); beta1 = norm; /* alpha2 = (e'*A*e)/(beta1*beta1), where e is the residual */ ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,k,&v);CHKERRQ(ierr); ierr = MatMult(A,v,e);CHKERRQ(ierr); ierr = VecDot(v,e,&alpha2);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,k,&v);CHKERRQ(ierr); alpha2 = alpha2 / (beta1 * beta1); /* choose the eigenvalue of [rho beta1; beta1 alpha2] closest to rho */ ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKlaev2",LAPACKlaev2_(&rho,&beta1,&alpha2,&rt1,&rt2,&cs1,&sn1)); ierr = PetscFPTrapPop();CHKERRQ(ierr); if (PetscAbsScalar(rt1-rho) < PetscAbsScalar(rt2-rho)) rho = rt1; else rho = rt2; } /* update operator according to new shift */ PetscPushErrorHandler(PetscIgnoreErrorHandler,NULL); ierr = STSetShift(eps->st,rho); PetscPopErrorHandler(); if (ierr) { eps->eigr[eps->nconv] = rho; relerr = PETSC_MACHINE_EPSILON; rho = sigma; ierr = STSetShift(eps->st,rho);CHKERRQ(ierr); } } } eps->errest[eps->nconv] = relerr; /* purge previously converged eigenvectors */ ierr = BVInsertVec(eps->V,k,y);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,k,NULL,&norm,NULL);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,k,1.0/norm);CHKERRQ(ierr); /* if relerrtol) { eps->nconv = eps->nconv + 1; if (eps->nconvnev) { ierr = EPSGetStartVector(eps,eps->nconv,&breakdown);CHKERRQ(ierr); if (breakdown) { eps->reason = EPS_DIVERGED_BREAKDOWN; ierr = PetscInfo(eps,"Unable to generate more start vectors\n");CHKERRQ(ierr); break; } } } ierr = EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,eps->nconv+1);CHKERRQ(ierr); ierr = (*eps->stopping)(eps,eps->its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "EPSBackTransform_Power" PetscErrorCode EPSBackTransform_Power(EPS eps) { PetscErrorCode ierr; EPS_POWER *power = (EPS_POWER*)eps->data; PetscFunctionBegin; if (power->shift_type == EPS_POWER_SHIFT_CONSTANT) { ierr = EPSBackTransform_Default(eps);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_Power" PetscErrorCode EPSSetFromOptions_Power(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; EPS_POWER *power = (EPS_POWER*)eps->data; PetscBool flg; EPSPowerShiftType shift; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS Power Options");CHKERRQ(ierr); ierr = PetscOptionsEnum("-eps_power_shift_type","Shift type","EPSPowerSetShiftType",EPSPowerShiftTypes,(PetscEnum)power->shift_type,(PetscEnum*)&shift,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSPowerSetShiftType(eps,shift);CHKERRQ(ierr); } if (power->shift_type != EPS_POWER_SHIFT_CONSTANT) { ierr = STSetType(eps->st,STSINVERT);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPowerSetShiftType_Power" static PetscErrorCode EPSPowerSetShiftType_Power(EPS eps,EPSPowerShiftType shift) { EPS_POWER *power = (EPS_POWER*)eps->data; PetscFunctionBegin; switch (shift) { case EPS_POWER_SHIFT_CONSTANT: case EPS_POWER_SHIFT_RAYLEIGH: case EPS_POWER_SHIFT_WILKINSON: power->shift_type = shift; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid shift type"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPowerSetShiftType" /*@ EPSPowerSetShiftType - Sets the type of shifts used during the power iteration. This can be used to emulate the Rayleigh Quotient Iteration (RQI) method. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - shift - the type of shift Options Database Key: . -eps_power_shift_type - Sets the shift type (either 'constant' or 'rayleigh' or 'wilkinson') Notes: By default, shifts are constant (EPS_POWER_SHIFT_CONSTANT) and the iteration is the simple power method (or inverse iteration if a shift-and-invert transformation is being used). A variable shift can be specified (EPS_POWER_SHIFT_RAYLEIGH or EPS_POWER_SHIFT_WILKINSON). In this case, the iteration behaves rather like a cubic converging method as RQI. See the users manual for details. Level: advanced .seealso: EPSPowerGetShiftType(), STSetShift(), EPSPowerShiftType @*/ PetscErrorCode EPSPowerSetShiftType(EPS eps,EPSPowerShiftType shift) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,shift,2); ierr = PetscTryMethod(eps,"EPSPowerSetShiftType_C",(EPS,EPSPowerShiftType),(eps,shift));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPowerGetShiftType_Power" static PetscErrorCode EPSPowerGetShiftType_Power(EPS eps,EPSPowerShiftType *shift) { EPS_POWER *power = (EPS_POWER*)eps->data; PetscFunctionBegin; *shift = power->shift_type; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPowerGetShiftType" /*@ EPSPowerGetShiftType - Gets the type of shifts used during the power iteration. Not Collective Input Parameter: . eps - the eigenproblem solver context Input Parameter: . shift - the type of shift Level: advanced .seealso: EPSPowerSetShiftType(), EPSPowerShiftType @*/ PetscErrorCode EPSPowerGetShiftType(EPS eps,EPSPowerShiftType *shift) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(shift,2); ierr = PetscUseMethod(eps,"EPSPowerGetShiftType_C",(EPS,EPSPowerShiftType*),(eps,shift));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_Power" PetscErrorCode EPSDestroy_Power(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPowerSetShiftType_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPowerGetShiftType_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_Power" PetscErrorCode EPSView_Power(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_POWER *power = (EPS_POWER*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," Power: %s shifts\n",EPSPowerShiftTypes[power->shift_type]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_Power" PETSC_EXTERN PetscErrorCode EPSCreate_Power(EPS eps) { EPS_POWER *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; eps->ops->setup = EPSSetUp_Power; eps->ops->solve = EPSSolve_Power; eps->ops->setfromoptions = EPSSetFromOptions_Power; eps->ops->destroy = EPSDestroy_Power; eps->ops->view = EPSView_Power; eps->ops->backtransform = EPSBackTransform_Power; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPowerSetShiftType_C",EPSPowerSetShiftType_Power);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSPowerGetShiftType_C",EPSPowerGetShiftType_Power);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/power/makefile.html0000644000175000017500000000465413107004621020475 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = power.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/power/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/power/index.html0000644000175000017500000000257413107004621020026 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

power.c
makefile
slepc-3.7.4/src/eps/impls/power/ftn-auto/0000755000175000017500000000000013107004621017556 5ustar jromanjromanslepc-3.7.4/src/eps/impls/power/ftn-auto/makefile0000644000175000017500000000035713107004621021263 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = powerf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/power/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/power/ftn-auto/powerf.c0000644000175000017500000000277213107004621021234 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* power.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epspowersetshifttype_ EPSPOWERSETSHIFTTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epspowersetshifttype_ epspowersetshifttype #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epspowergetshifttype_ EPSPOWERGETSHIFTTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epspowergetshifttype_ epspowergetshifttype #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epspowersetshifttype_(EPS eps,EPSPowerShiftType *shift, int *__ierr ){ *__ierr = EPSPowerSetShiftType( (EPS)PetscToPointer((eps) ),*shift); } PETSC_EXTERN void PETSC_STDCALL epspowergetshifttype_(EPS eps,EPSPowerShiftType *shift, int *__ierr ){ *__ierr = EPSPowerGetShiftType( (EPS)PetscToPointer((eps) ),shift); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/power/power.c.html0000644000175000017500000007472313107004621020301 0ustar jromanjroman

Actual source code: power.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "power"

  5:    Method: Power Iteration

  7:    Algorithm:

  9:        This solver implements the power iteration for finding dominant
 10:        eigenpairs. It also includes the following well-known methods:
 11:        - Inverse Iteration: when used in combination with shift-and-invert
 12:          spectral transformation.
 13:        - Rayleigh Quotient Iteration (RQI): also with shift-and-invert plus
 14:          a variable shift.

 16:    References:

 18:        [1] "Single Vector Iteration Methods in SLEPc", SLEPc Technical Report
 19:            STR-2, available at http://slepc.upv.es.

 21:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 23:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 25:    This file is part of SLEPc.

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

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

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

 41: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
 42: #include <slepcblaslapack.h>

 44: typedef struct {
 45:   EPSPowerShiftType shift_type;
 46: } EPS_POWER;

 50: PetscErrorCode EPSSetUp_Power(EPS eps)
 51: {
 53:   EPS_POWER      *power = (EPS_POWER*)eps->data;
 54:   PetscBool      flg,istrivial;
 55:   STMatMode      mode;

 58:   if (eps->ncv) {
 59:     if (eps->ncv<eps->nev) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must be at least nev");
 60:   } else eps->ncv = eps->nev;
 61:   if (eps->mpd) { PetscInfo(eps,"Warning: parameter mpd ignored\n"); }
 62:   if (!eps->max_it) eps->max_it = PetscMax(2000,100*eps->n);
 63:   if (!eps->which) { EPSSetWhichEigenpairs_Default(eps); }
 64:   if (eps->which!=EPS_LARGEST_MAGNITUDE && eps->which !=EPS_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
 65:   if (power->shift_type != EPS_POWER_SHIFT_CONSTANT) {
 66:     PetscObjectTypeCompareAny((PetscObject)eps->st,&flg,STSINVERT,STCAYLEY,"");
 67:     if (!flg) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Variable shifts only allowed in shift-and-invert or Cayley ST");
 68:     STGetMatMode(eps->st,&mode);
 69:     if (mode == ST_MATMODE_INPLACE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"ST matrix mode inplace does not work with variable shifts");
 70:   }
 71:   if (eps->extraction) { PetscInfo(eps,"Warning: extraction type ignored\n"); }
 72:   if (eps->balance!=EPS_BALANCE_NONE) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Balancing not supported in this solver");
 73:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");
 74:   RGIsTrivial(eps->rg,&istrivial);
 75:   if (!istrivial) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"This solver does not support region filtering");
 76:   EPSAllocateSolution(eps,0);
 77:   EPS_SetInnerProduct(eps);
 78:   EPSSetWorkVecs(eps,2);
 79:   return(0);
 80: }

 84: PetscErrorCode EPSSolve_Power(EPS eps)
 85: {
 86: #if defined(SLEPC_MISSING_LAPACK_LAEV2)
 88:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAEV2 - Lapack routine is unavailable");
 89: #else
 91:   EPS_POWER      *power = (EPS_POWER*)eps->data;
 92:   PetscInt       k;
 93:   Vec            v,y,e;
 94:   Mat            A;
 95:   PetscReal      relerr,norm,rt1,rt2,cs1;
 96:   PetscScalar    theta,rho,delta,sigma,alpha2,beta1,sn1;
 97:   PetscBool      breakdown;

100:   y = eps->work[1];
101:   e = eps->work[0];

103:   EPSGetStartVector(eps,0,NULL);
104:   STGetShift(eps->st,&sigma);    /* original shift */
105:   rho = sigma;

107:   while (eps->reason == EPS_CONVERGED_ITERATING) {
108:     eps->its++;
109:     k = eps->nconv;

111:     /* y = OP v */
112:     BVGetColumn(eps->V,k,&v);
113:     STApply(eps->st,v,y);
114:     BVRestoreColumn(eps->V,k,&v);

116:     /* theta = (v,y)_B */
117:     BVSetActiveColumns(eps->V,k,k+1);
118:     BVDotVec(eps->V,y,&theta);

120:     if (power->shift_type == EPS_POWER_SHIFT_CONSTANT) { /* direct & inverse iteration */

122:       /* approximate eigenvalue is the Rayleigh quotient */
123:       eps->eigr[eps->nconv] = theta;

125:       /* compute relative error as ||y-theta v||_2/|theta| */
126:       VecCopy(y,e);
127:       BVGetColumn(eps->V,k,&v);
128:       VecAXPY(e,-theta,v);
129:       BVRestoreColumn(eps->V,k,&v);
130:       VecNorm(e,NORM_2,&norm);
131:       relerr = norm / PetscAbsScalar(theta);

133:     } else {  /* RQI */

135:       /* delta = ||y||_B */
136:       BVNormVec(eps->V,y,NORM_2,&norm);
137:       delta = norm;

139:       /* compute relative error */
140:       if (rho == 0.0) relerr = PETSC_MAX_REAL;
141:       else relerr = 1.0 / (norm*PetscAbsScalar(rho));

143:       /* approximate eigenvalue is the shift */
144:       eps->eigr[eps->nconv] = rho;

146:       /* compute new shift */
147:       if (relerr<eps->tol) {
148:         rho = sigma; /* if converged, restore original shift */
149:         STSetShift(eps->st,rho);
150:       } else {
151:         rho = rho + theta/(delta*delta);  /* Rayleigh quotient R(v) */
152:         if (power->shift_type == EPS_POWER_SHIFT_WILKINSON) {
153:           /* beta1 is the norm of the residual associated to R(v) */
154:           BVGetColumn(eps->V,k,&v);
155:           VecAXPY(v,-theta/(delta*delta),y);
156:           BVRestoreColumn(eps->V,k,&v);
157:           BVScaleColumn(eps->V,k,1.0/delta);
158:           BVNormColumn(eps->V,k,NORM_2,&norm);
159:           beta1 = norm;

161:           /* alpha2 = (e'*A*e)/(beta1*beta1), where e is the residual */
162:           STGetOperators(eps->st,0,&A);
163:           BVGetColumn(eps->V,k,&v);
164:           MatMult(A,v,e);
165:           VecDot(v,e,&alpha2);
166:           BVRestoreColumn(eps->V,k,&v);
167:           alpha2 = alpha2 / (beta1 * beta1);

169:           /* choose the eigenvalue of [rho beta1; beta1 alpha2] closest to rho */
170:           PetscFPTrapPush(PETSC_FP_TRAP_OFF);
171:           PetscStackCallBLAS("LAPACKlaev2",LAPACKlaev2_(&rho,&beta1,&alpha2,&rt1,&rt2,&cs1,&sn1));
172:           PetscFPTrapPop();
173:           if (PetscAbsScalar(rt1-rho) < PetscAbsScalar(rt2-rho)) rho = rt1;
174:           else rho = rt2;
175:         }
176:         /* update operator according to new shift */
177:         PetscPushErrorHandler(PetscIgnoreErrorHandler,NULL);
178:         STSetShift(eps->st,rho);
179:         PetscPopErrorHandler();
180:         if (ierr) {
181:           eps->eigr[eps->nconv] = rho;
182:           relerr = PETSC_MACHINE_EPSILON;
183:           rho = sigma;
184:           STSetShift(eps->st,rho);
185:         }
186:       }
187:     }
188:     eps->errest[eps->nconv] = relerr;

190:     /* purge previously converged eigenvectors */
191:     BVInsertVec(eps->V,k,y);
192:     BVOrthogonalizeColumn(eps->V,k,NULL,&norm,NULL);
193:     BVScaleColumn(eps->V,k,1.0/norm);

195:     /* if relerr<tol, accept eigenpair */
196:     if (relerr<eps->tol) {
197:       eps->nconv = eps->nconv + 1;
198:       if (eps->nconv<eps->nev) {
199:         EPSGetStartVector(eps,eps->nconv,&breakdown);
200:         if (breakdown) {
201:           eps->reason = EPS_DIVERGED_BREAKDOWN;
202:           PetscInfo(eps,"Unable to generate more start vectors\n");
203:           break;
204:         }
205:       }
206:     }
207:     EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,eps->nconv+1);
208:     (*eps->stopping)(eps,eps->its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);
209:   }
210:   return(0);
211: #endif
212: }

216: PetscErrorCode EPSBackTransform_Power(EPS eps)
217: {
219:   EPS_POWER      *power = (EPS_POWER*)eps->data;

222:   if (power->shift_type == EPS_POWER_SHIFT_CONSTANT) {
223:     EPSBackTransform_Default(eps);
224:   }
225:   return(0);
226: }

230: PetscErrorCode EPSSetFromOptions_Power(PetscOptionItems *PetscOptionsObject,EPS eps)
231: {
232:   PetscErrorCode    ierr;
233:   EPS_POWER         *power = (EPS_POWER*)eps->data;
234:   PetscBool         flg;
235:   EPSPowerShiftType shift;

238:   PetscOptionsHead(PetscOptionsObject,"EPS Power Options");
239:   PetscOptionsEnum("-eps_power_shift_type","Shift type","EPSPowerSetShiftType",EPSPowerShiftTypes,(PetscEnum)power->shift_type,(PetscEnum*)&shift,&flg);
240:   if (flg) {
241:     EPSPowerSetShiftType(eps,shift);
242:   }
243:   if (power->shift_type != EPS_POWER_SHIFT_CONSTANT) {
244:     STSetType(eps->st,STSINVERT);
245:   }
246:   PetscOptionsTail();
247:   return(0);
248: }

252: static PetscErrorCode EPSPowerSetShiftType_Power(EPS eps,EPSPowerShiftType shift)
253: {
254:   EPS_POWER *power = (EPS_POWER*)eps->data;

257:   switch (shift) {
258:     case EPS_POWER_SHIFT_CONSTANT:
259:     case EPS_POWER_SHIFT_RAYLEIGH:
260:     case EPS_POWER_SHIFT_WILKINSON:
261:       power->shift_type = shift;
262:       break;
263:     default:
264:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid shift type");
265:   }
266:   return(0);
267: }

271: /*@
272:    EPSPowerSetShiftType - Sets the type of shifts used during the power
273:    iteration. This can be used to emulate the Rayleigh Quotient Iteration
274:    (RQI) method.

276:    Logically Collective on EPS

278:    Input Parameters:
279: +  eps - the eigenproblem solver context
280: -  shift - the type of shift

282:    Options Database Key:
283: .  -eps_power_shift_type - Sets the shift type (either 'constant' or
284:                            'rayleigh' or 'wilkinson')

286:    Notes:
287:    By default, shifts are constant (EPS_POWER_SHIFT_CONSTANT) and the iteration
288:    is the simple power method (or inverse iteration if a shift-and-invert
289:    transformation is being used).

291:    A variable shift can be specified (EPS_POWER_SHIFT_RAYLEIGH or
292:    EPS_POWER_SHIFT_WILKINSON). In this case, the iteration behaves rather like
293:    a cubic converging method as RQI. See the users manual for details.

295:    Level: advanced

297: .seealso: EPSPowerGetShiftType(), STSetShift(), EPSPowerShiftType
298: @*/
299: PetscErrorCode EPSPowerSetShiftType(EPS eps,EPSPowerShiftType shift)
300: {

306:   PetscTryMethod(eps,"EPSPowerSetShiftType_C",(EPS,EPSPowerShiftType),(eps,shift));
307:   return(0);
308: }

312: static PetscErrorCode EPSPowerGetShiftType_Power(EPS eps,EPSPowerShiftType *shift)
313: {
314:   EPS_POWER  *power = (EPS_POWER*)eps->data;

317:   *shift = power->shift_type;
318:   return(0);
319: }

323: /*@
324:    EPSPowerGetShiftType - Gets the type of shifts used during the power
325:    iteration.

327:    Not Collective

329:    Input Parameter:
330: .  eps - the eigenproblem solver context

332:    Input Parameter:
333: .  shift - the type of shift

335:    Level: advanced

337: .seealso: EPSPowerSetShiftType(), EPSPowerShiftType
338: @*/
339: PetscErrorCode EPSPowerGetShiftType(EPS eps,EPSPowerShiftType *shift)
340: {

346:   PetscUseMethod(eps,"EPSPowerGetShiftType_C",(EPS,EPSPowerShiftType*),(eps,shift));
347:   return(0);
348: }

352: PetscErrorCode EPSDestroy_Power(EPS eps)
353: {

357:   PetscFree(eps->data);
358:   PetscObjectComposeFunction((PetscObject)eps,"EPSPowerSetShiftType_C",NULL);
359:   PetscObjectComposeFunction((PetscObject)eps,"EPSPowerGetShiftType_C",NULL);
360:   return(0);
361: }

365: PetscErrorCode EPSView_Power(EPS eps,PetscViewer viewer)
366: {
368:   EPS_POWER      *power = (EPS_POWER*)eps->data;
369:   PetscBool      isascii;

372:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
373:   if (isascii) {
374:     PetscViewerASCIIPrintf(viewer,"  Power: %s shifts\n",EPSPowerShiftTypes[power->shift_type]);
375:   }
376:   return(0);
377: }

381: PETSC_EXTERN PetscErrorCode EPSCreate_Power(EPS eps)
382: {
383:   EPS_POWER      *ctx;

387:   PetscNewLog(eps,&ctx);
388:   eps->data = (void*)ctx;

390:   eps->ops->setup                = EPSSetUp_Power;
391:   eps->ops->solve                = EPSSolve_Power;
392:   eps->ops->setfromoptions       = EPSSetFromOptions_Power;
393:   eps->ops->destroy              = EPSDestroy_Power;
394:   eps->ops->view                 = EPSView_Power;
395:   eps->ops->backtransform        = EPSBackTransform_Power;
396:   PetscObjectComposeFunction((PetscObject)eps,"EPSPowerSetShiftType_C",EPSPowerSetShiftType_Power);
397:   PetscObjectComposeFunction((PetscObject)eps,"EPSPowerGetShiftType_C",EPSPowerGetShiftType_Power);
398:   return(0);
399: }

slepc-3.7.4/src/eps/impls/davidson/0000755000175000017500000000000013107004621016474 5ustar jromanjromanslepc-3.7.4/src/eps/impls/davidson/makefile0000644000175000017500000000236013107004621020175 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = davidson.c dvdcalcpairs.c dvdimprovex.c dvdinitv.c \ dvdschm.c dvdtestconv.c dvdupdatev.c dvdutils.c dvdgd2.c SOURCEF = SOURCEH = davidson.h LIBBASE = libslepceps DIRS = gd jd LOCDIR = src/eps/impls/davidson/ MANSEC = EPS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/davidson/dvdcalcpairs.c.html0000644000175000017500000015150113107004621022245 0ustar jromanjroman
Actual source code: dvdcalcpairs.c

slepc-3.7.4 2017-05-17
  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Step: calc the best eigenpairs in the subspace V.

  6:   For that, performs these steps:
  7:     1) Update W <- A * V
  8:     2) Update H <- V' * W
  9:     3) Obtain eigenpairs of H
 10:     4) Select some eigenpairs
 11:     5) Compute the Ritz pairs of the selected ones

 13:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 14:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 15:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 17:    This file is part of SLEPc.

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

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

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

 33:  #include davidson.h
 34: #include <slepcblaslapack.h>

 38: static PetscErrorCode dvd_calcpairs_qz_start(dvdDashboard *d)
 39: {

 43:   BVSetActiveColumns(d->eps->V,0,0);
 44:   if (d->W) { BVSetActiveColumns(d->W,0,0); }
 45:   BVSetActiveColumns(d->AX,0,0);
 46:   if (d->BX) { BVSetActiveColumns(d->BX,0,0); }
 47:   return(0);
 48: }

 52: static PetscErrorCode dvd_calcpairs_qz_d(dvdDashboard *d)
 53: {
 54:   PetscErrorCode  ierr;

 57:   BVDestroy(&d->W);
 58:   BVDestroy(&d->AX);
 59:   BVDestroy(&d->BX);
 60:   BVDestroy(&d->auxBV);
 61:   MatDestroy(&d->H);
 62:   if (d->G) { MatDestroy(&d->G); }
 63:   MatDestroy(&d->auxM);
 64:   SlepcVecPoolDestroy(&d->auxV);
 65:   PetscFree(d->nBds);
 66:   return(0);
 67: }

 69: /* in complex, d->size_H real auxiliar values are needed */
 72: static PetscErrorCode dvd_calcpairs_projeig_solve(dvdDashboard *d)
 73: {
 74:   PetscErrorCode    ierr;
 75:   Vec               v;
 76:   PetscScalar       *pA;
 77:   const PetscScalar *pv;
 78:   PetscInt          i,lV,kV,n,ld;

 81:   BVGetActiveColumns(d->eps->V,&lV,&kV);
 82:   n = kV-lV;
 83:   DSSetDimensions(d->eps->ds,n,0,0,0);
 84:   DSCopyMat(d->eps->ds,DS_MAT_A,0,0,d->H,lV,lV,n,n,PETSC_FALSE);
 85:   if (d->G) {
 86:     DSCopyMat(d->eps->ds,DS_MAT_B,0,0,d->G,lV,lV,n,n,PETSC_FALSE);
 87:   }
 88:   /* Set the signature on projected matrix B */
 89:   if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) {
 90:     DSGetLeadingDimension(d->eps->ds,&ld);
 91:     DSGetArray(d->eps->ds,DS_MAT_B,&pA);
 92:     PetscMemzero(pA,sizeof(PetscScalar)*n*ld);
 93:     VecCreateSeq(PETSC_COMM_SELF,kV,&v);
 94:     BVGetSignature(d->eps->V,v);
 95:     VecGetArrayRead(v,&pv);
 96:     for (i=0;i<n;i++) {
 97:       pA[i+ld*i] = d->nBds[i] = PetscRealPart(pv[lV+i]);
 98:     }
 99:     VecRestoreArrayRead(v,&pv);
100:     VecDestroy(&v);
101:     DSRestoreArray(d->eps->ds,DS_MAT_B,&pA);
102:   }
103:   DSSetState(d->eps->ds,DS_STATE_RAW);
104:   DSSolve(d->eps->ds,d->eigr,d->eigi);
105:   return(0);
106: }

110: /*
111:    A(lA:kA-1,lA:kA-1) <- Z(l:k-1)'*A(l:k-1,l:k-1)*Q(l,k-1), where k=l+kA-lA
112:  */
113: static PetscErrorCode EPSXDUpdateProj(Mat Q,Mat Z,PetscInt l,Mat A,PetscInt lA,PetscInt kA,Mat aux)
114: {
116:   PetscScalar    one=1.0,zero=0.0;
117:   PetscInt       i,j,dA_=kA-lA,m0,n0,ldA_,ldQ_,ldZ_,nQ_;
118:   PetscBLASInt   dA,nQ,ldA,ldQ,ldZ;
119:   PetscScalar    *pA,*pQ,*pZ,*pW;
120:   PetscBool      symm=PETSC_FALSE,set,flg;

123:   MatGetSize(A,&m0,&n0); ldA_=m0;
124:   if (m0!=n0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"A should be square");
125:   if (lA<0 || lA>m0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid initial row, column in A");
126:   if (kA<0 || kA<lA || kA>m0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid final row, column in A");
127:   MatIsHermitianKnown(A,&set,&flg);
128:   symm = set? flg: PETSC_FALSE;
129:   MatGetSize(Q,&m0,&n0); ldQ_=nQ_=m0;
130:   if (l<0 || l>n0 || l+dA_>n0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid initial column in Q");
131:   MatGetSize(Z,&m0,&n0); ldZ_=m0;
132:   if (l<0 || l>n0 || l+dA_>n0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid initial column in Z");
133:   MatGetSize(aux,&m0,&n0);
134:   if (m0*n0<nQ_*dA_) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"aux should be larger");
135:   PetscBLASIntCast(dA_,&dA);
136:   PetscBLASIntCast(nQ_,&nQ);
137:   PetscBLASIntCast(ldA_,&ldA);
138:   PetscBLASIntCast(ldQ_,&ldQ);
139:   PetscBLASIntCast(ldZ_,&ldZ);
140:   MatDenseGetArray(A,&pA);
141:   MatDenseGetArray(Q,&pQ);
142:   if (Q!=Z) { MatDenseGetArray(Z,&pZ); }
143:   else pZ = pQ;
144: #if PETSC_USE_DEBUG
145:   /* Avoid valgrind warning in xgemm and xsymm */
146:   MatZeroEntries(aux);
147: #endif
148:   MatDenseGetArray(aux,&pW);
149:   /* W = A*Q */
150:   if (symm) {
151:     /* symmetrize before multiplying */
152:     for (i=lA+1;i<lA+nQ;i++) {
153:       for (j=lA;j<i;j++) pA[i+j*ldA] = PetscConj(pA[j+i*ldA]);
154:     }
155:   }
156:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&nQ,&dA,&nQ,&one,&pA[ldA*lA+lA],&ldA,&pQ[ldQ*l+l],&ldQ,&zero,pW,&nQ));
157:   /* A = Q'*W */
158:   PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&dA,&dA,&nQ,&one,&pZ[ldZ*l+l],&ldZ,pW,&nQ,&zero,&pA[ldA*lA+lA],&ldA));
159:   MatDenseGetArray(A,&pA);
160:   MatDenseGetArray(Q,&pQ);
161:   if (Q!=Z) { MatDenseGetArray(Z,&pZ); }
162:   else pZ = pQ;
163:   MatDenseGetArray(aux,&pW);
164:   return(0);
165: }

169: static PetscErrorCode dvd_calcpairs_updateproj(dvdDashboard *d)
170: {
172:   Mat            Q,Z;
173:   PetscInt       lV,kV;
174:   PetscBool      symm;

177:   DSGetMat(d->eps->ds,DS_MAT_Q,&Q);
178:   if (d->W) { DSGetMat(d->eps->ds,DS_MAT_Z,&Z); }
179:   else Z = Q;
180:   BVGetActiveColumns(d->eps->V,&lV,&kV);
181:   EPSXDUpdateProj(Q,Z,0,d->H,lV,lV+d->V_tra_e,d->auxM);
182:   if (d->G) { EPSXDUpdateProj(Q,Z,0,d->G,lV,lV+d->V_tra_e,d->auxM); }
183:   DSRestoreMat(d->eps->ds,DS_MAT_Q,&Q);
184:   if (d->W) { DSRestoreMat(d->eps->ds,DS_MAT_Z,&Z); }

186:   PetscObjectTypeCompareAny((PetscObject)d->eps->ds,&symm,DSHEP,DSGHIEP,"");
187:   if (d->V_tra_s==0 || symm) return(0);
188:   /* Compute upper part of H (and G): H(0:l-1,l:k-1) <- W(0:l-1)' * AV(l:k-1), where
189:      k=l+d->V_tra_s */
190:   BVSetActiveColumns(d->W?d->W:d->eps->V,0,lV);
191:   BVSetActiveColumns(d->AX,lV,lV+d->V_tra_s);
192:   BVDot(d->AX,d->W?d->W:d->eps->V,d->H);
193:   if (d->G) {
194:     BVSetActiveColumns(d->BX?d->BX:d->eps->V,lV,lV+d->V_tra_s);
195:     BVDot(d->BX?d->BX:d->eps->V,d->W?d->W:d->eps->V,d->G);
196:   }
197:   PetscObjectTypeCompareAny((PetscObject)d->eps->ds,&symm,DSGHEP,"");
198:   if (!symm) {
199:     BVSetActiveColumns(d->W?d->W:d->eps->V,lV,lV+d->V_tra_s);
200:     BVSetActiveColumns(d->AX,0,lV);
201:     BVDot(d->AX,d->W?d->W:d->eps->V,d->H);
202:     if (d->G) {
203:       BVSetActiveColumns(d->BX?d->BX:d->eps->V,0,lV);
204:       BVDot(d->BX?d->BX:d->eps->V,d->W?d->W:d->eps->V,d->G);
205:     }
206:   }
207:   BVSetActiveColumns(d->eps->V,lV,kV);
208:   BVSetActiveColumns(d->AX,lV,kV);
209:   if (d->BX) { BVSetActiveColumns(d->BX,lV,kV); }
210:   if (d->W) { BVSetActiveColumns(d->W,lV,kV); }
211:   if (d->W) { dvd_harm_updateproj(d); }
212:   return(0);
213: }

217: /*
218:    BV <- BV*MT
219:  */
220: PETSC_STATIC_INLINE PetscErrorCode dvd_calcpairs_updateBV0_gen(dvdDashboard *d,BV bv,DSMatType mat)
221: {
223:   PetscInt       l,k,n;
224:   Mat            auxM;

227:   BVGetActiveColumns(d->eps->V,&l,&k);
228:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&auxM);
229:   MatZeroEntries(auxM);
230:   DSGetDimensions(d->eps->ds,&n,NULL,NULL,NULL,NULL);
231:   if (k-l!=n) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken");
232:   DSCopyMat(d->eps->ds,mat,0,0,auxM,l,l,n,d->V_tra_e,PETSC_TRUE);
233:   BVMultInPlace(bv,auxM,l,l+d->V_tra_e);
234:   MatDestroy(&auxM);
235:   return(0);
236: }

240: static PetscErrorCode dvd_calcpairs_proj(dvdDashboard *d)
241: {
243:   PetscInt       i,l,k;
244:   Vec            v1,v2;
245:   PetscScalar    *pv;

248:   BVGetActiveColumns(d->eps->V,&l,&k);
249:   /* Update AV, BV, W and the projected matrices */
250:   /* 1. S <- S*MT */
251:   if (d->V_tra_s != d->V_tra_e || d->V_tra_e > 0) {
252:     dvd_calcpairs_updateBV0_gen(d,d->eps->V,DS_MAT_Q);
253:     if (d->W) { dvd_calcpairs_updateBV0_gen(d,d->W,DS_MAT_Z); }
254:     dvd_calcpairs_updateBV0_gen(d,d->AX,DS_MAT_Q);
255:     if (d->BX) { dvd_calcpairs_updateBV0_gen(d,d->BX,DS_MAT_Q); }
256:     dvd_calcpairs_updateproj(d);
257:     /* Update signature */
258:     if (d->nBds) {
259:       VecCreateSeq(PETSC_COMM_SELF,l+d->V_tra_e,&v1);
260:       BVSetActiveColumns(d->eps->V,0,l+d->V_tra_e);
261:       BVGetSignature(d->eps->V,v1);
262:       VecGetArray(v1,&pv);
263:       for (i=0;i<d->V_tra_e;i++) pv[l+i] = d->nBds[i];
264:       VecRestoreArray(v1,&pv);
265:       BVSetSignature(d->eps->V,v1);
266:       BVSetActiveColumns(d->eps->V,l,k);
267:       VecDestroy(&v1);
268:     }
269:     k = l+d->V_tra_e;
270:     l+= d->V_tra_s;
271:   } else {
272:     /* 2. V <- orth(V, V_new) */
273:     dvd_orthV(d->eps->V,l+d->V_new_s,l+d->V_new_e);
274:     /* 3. AV <- [AV A * V(V_new_s:V_new_e-1)] */
275:     /* Check consistency */
276:     if (k-l != d->V_new_s) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken");
277:     for (i=l+d->V_new_s;i<l+d->V_new_e;i++) {
278:       BVGetColumn(d->eps->V,i,&v1);
279:       BVGetColumn(d->AX,i,&v2);
280:       MatMult(d->A,v1,v2);
281:       BVRestoreColumn(d->eps->V,i,&v1);
282:       BVRestoreColumn(d->AX,i,&v2);
283:     }
284:     /* 4. BV <- [BV B * V(V_new_s:V_new_e-1)] */
285:     if (d->BX) {
286:       /* Check consistency */
287:       if (k-l != d->V_new_s) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken");
288:       for (i=l+d->V_new_s;i<l+d->V_new_e;i++) {
289:         BVGetColumn(d->eps->V,i,&v1);
290:         BVGetColumn(d->BX,i,&v2);
291:         MatMult(d->B,v1,v2);
292:         BVRestoreColumn(d->eps->V,i,&v1);
293:         BVRestoreColumn(d->BX,i,&v2);
294:       }
295:     }
296:     /* 5. W <- [W f(AV,BV)] */
297:     if (d->W) {
298:       d->calcpairs_W(d);
299:       dvd_orthV(d->W,l+d->V_new_s,l+d->V_new_e);
300:     }
301:     /* 6. H <- W' * AX; G <- W' * BX */
302:     BVSetActiveColumns(d->eps->V,l+d->V_new_s,l+d->V_new_e);
303:     BVSetActiveColumns(d->AX,l+d->V_new_s,l+d->V_new_e);
304:     if (d->BX) { BVSetActiveColumns(d->BX,l+d->V_new_s,l+d->V_new_e); }
305:     if (d->W) { BVSetActiveColumns(d->W,l+d->V_new_s,l+d->V_new_e); }
306:     BVMatProject(d->AX,NULL,d->W?d->W:d->eps->V,d->H);
307:     if (d->G) { BVMatProject(d->BX?d->BX:d->eps->V,NULL,d->W?d->W:d->eps->V,d->G); }
308:     BVSetActiveColumns(d->eps->V,l,k);
309:     BVSetActiveColumns(d->AX,l,k);
310:     if (d->BX) { BVSetActiveColumns(d->BX,l,k); }
311:     if (d->W) { BVSetActiveColumns(d->W,l,k); }

313:     /* Perform the transformation on the projected problem */
314:     if (d->W) {
315:       d->calcpairs_proj_trans(d);
316:     }
317:     k = l+d->V_new_e;
318:   }
319:   BVSetActiveColumns(d->eps->V,l,k);
320:   BVSetActiveColumns(d->AX,l,k);
321:   if (d->BX) { BVSetActiveColumns(d->BX,l,k); }
322:   if (d->W) { BVSetActiveColumns(d->W,l,k); }

324:   /* Solve the projected problem */
325:   dvd_calcpairs_projeig_solve(d);

327:   d->V_tra_s = d->V_tra_e = 0;
328:   d->V_new_s = d->V_new_e;
329:   return(0);
330: }

334: static PetscErrorCode dvd_calcpairs_apply_arbitrary(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscScalar *rr,PetscScalar *ri)
335: {
336:   PetscInt       i,k,ld;
337:   PetscScalar    *pX;
338:   Vec            *X,xr,xi;
340: #if defined(PETSC_USE_COMPLEX)
341:   PetscInt       N=1;
342: #else
343:   PetscInt       N=2,j;
344: #endif

347:   /* Quick exit without neither arbitrary selection nor harmonic extraction */
348:   if (!d->eps->arbitrary && !d->calcpairs_eig_backtrans) return(0);

350:   /* Quick exit without arbitrary selection, but with harmonic extraction */
351:   if (d->calcpairs_eig_backtrans) {
352:     for (i=r_s; i<r_e; i++) {
353:       d->calcpairs_eig_backtrans(d,d->eigr[i],d->eigi[i],&rr[i-r_s],&ri[i-r_s]);
354:     }
355:   }
356:   if (!d->eps->arbitrary) return(0);

358:   SlepcVecPoolGetVecs(d->auxV,N,&X);
359:   DSGetLeadingDimension(d->eps->ds,&ld);
360:   for (i=r_s;i<r_e;i++) {
361:     k = i;
362:     DSVectors(d->eps->ds,DS_MAT_X,&k,NULL);
363:     DSGetArray(d->eps->ds,DS_MAT_X,&pX);
364:     dvd_improvex_compute_X(d,i,k+1,X,pX,ld);
365:     DSRestoreArray(d->eps->ds,DS_MAT_X,&pX);
366: #if !defined(PETSC_USE_COMPLEX)
367:     if (d->nX[i] != 1.0) {
368:       for (j=i;j<k+1;j++) {
369:         VecScale(X[j-i],1.0/d->nX[i]);
370:       }
371:     }
372:     xr = X[0];
373:     xi = X[1];
374:     if (i == k) {
375:       VecSet(xi,0.0);
376:     }
377: #else
378:     xr = X[0];
379:     xi = NULL;
380:     if (d->nX[i] != 1.0) {
381:       VecScale(xr,1.0/d->nX[i]);
382:     }
383: #endif
384:     (d->eps->arbitrary)(rr[i-r_s],ri[i-r_s],xr,xi,&rr[i-r_s],&ri[i-r_s],d->eps->arbitraryctx);
385: #if !defined(PETSC_USE_COMPLEX)
386:     if (i != k) {
387:       rr[i+1-r_s] = rr[i-r_s];
388:       ri[i+1-r_s] = ri[i-r_s];
389:       i++;
390:     }
391: #endif
392:   }
393:   SlepcVecPoolRestoreVecs(d->auxV,N,&X);
394:   return(0);
395: }

399: static PetscErrorCode dvd_calcpairs_selectPairs(dvdDashboard *d,PetscInt n)
400: {
401:   PetscInt       k,lV,kV,nV;
402:   PetscScalar    *rr,*ri;

406:   BVGetActiveColumns(d->eps->V,&lV,&kV);
407:   nV = kV - lV; 
408:   n = PetscMin(n,nV);
409:   if (n <= 0) return(0);
410:   /* Put the best n pairs at the beginning. Useful for restarting */
411:   if (d->eps->arbitrary || d->calcpairs_eig_backtrans) {
412:     PetscMalloc1(nV,&rr);
413:     PetscMalloc1(nV,&ri);
414:     dvd_calcpairs_apply_arbitrary(d,0,nV,rr,ri);
415:   } else {
416:     rr = d->eigr;
417:     ri = d->eigi;
418:   }
419:   k = n;
420:   DSSort(d->eps->ds,d->eigr,d->eigi,rr,ri,&k);
421:   /* Put the best pair at the beginning. Useful to check its residual */
422: #if !defined(PETSC_USE_COMPLEX)
423:   if (n != 1 && (n != 2 || d->eigi[0] == 0.0))
424: #else
425:   if (n != 1)
426: #endif
427:   {
428:     dvd_calcpairs_apply_arbitrary(d,0,nV,rr,ri);
429:     k = 1;
430:     DSSort(d->eps->ds,d->eigr,d->eigi,rr,ri,&k);
431:   }
432:   if (d->calcpairs_eigs_trans) {
433:     d->calcpairs_eigs_trans(d);
434:   }
435:   if (d->eps->arbitrary || d->calcpairs_eig_backtrans) {
436:     PetscFree(rr);
437:     PetscFree(ri);
438:   }
439:   return(0);
440: }

444: static PetscErrorCode EPSXDComputeDSConv(dvdDashboard *d)
445: {
446:   PetscErrorCode    ierr;
447:   PetscInt          i,ld;
448:   Vec               v;
449:   PetscScalar       *pA;
450:   const PetscScalar *pv;
451:   PetscBool         symm;

454:   BVSetActiveColumns(d->eps->V,0,d->eps->nconv);
455:   PetscObjectTypeCompareAny((PetscObject)d->eps->ds,&symm,DSHEP,"");
456:   if (symm) return(0);
457:   DSSetDimensions(d->eps->ds,d->eps->nconv,0,0,0);
458:   DSCopyMat(d->eps->ds,DS_MAT_A,0,0,d->H,0,0,d->eps->nconv,d->eps->nconv,PETSC_FALSE);
459:   if (d->G) {
460:     DSCopyMat(d->eps->ds,DS_MAT_B,0,0,d->G,0,0,d->eps->nconv,d->eps->nconv,PETSC_FALSE);
461:   }
462:   /* Set the signature on projected matrix B */
463:   if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) {
464:     DSGetLeadingDimension(d->eps->ds,&ld);
465:     DSGetArray(d->eps->ds,DS_MAT_B,&pA);
466:     PetscMemzero(pA,sizeof(PetscScalar)*d->eps->nconv*ld);
467:     VecCreateSeq(PETSC_COMM_SELF,d->eps->nconv,&v);
468:     BVGetSignature(d->eps->V,v);
469:     VecGetArrayRead(v,&pv);
470:     for (i=0;i<d->eps->nconv;i++) pA[i+ld*i] = pv[i];
471:     VecRestoreArrayRead(v,&pv);
472:     VecDestroy(&v);
473:     DSRestoreArray(d->eps->ds,DS_MAT_B,&pA);
474:   }
475:   DSSetState(d->eps->ds,DS_STATE_RAW);
476:   DSSolve(d->eps->ds,d->eps->eigr,d->eps->eigi);
477:   if (d->W) {
478:     for (i=0; i<d->eps->nconv; i++) {
479:       d->calcpairs_eig_backtrans(d,d->eps->eigr[i],d->eps->eigi[i],&d->eps->eigr[i],&d->eps->eigi[i]);
480:     }
481:   }
482:   return(0);
483: }

487: /*
488:    Compute the residual vectors R(i) <- (AV - BV*eigr(i))*pX(i), and also
489:    the norm associated to the Schur pair, where i = r_s..r_e
490: */
491: static PetscErrorCode dvd_calcpairs_res_0(dvdDashboard *d,PetscInt r_s,PetscInt r_e)
492: {
493:   PetscInt       i,ldpX;
494:   PetscScalar    *pX;
496:   BV             BX = d->BX?d->BX:d->eps->V;
497:   Vec            *R;

500:   DSGetLeadingDimension(d->eps->ds,&ldpX);
501:   DSGetArray(d->eps->ds,DS_MAT_Q,&pX);
502:   /* nX(i) <- ||X(i)|| */
503:   dvd_improvex_compute_X(d,r_s,r_e,NULL,pX,ldpX);
504:   SlepcVecPoolGetVecs(d->auxV,r_e-r_s,&R);
505:   for (i=r_s;i<r_e;i++) {
506:     /* R(i-r_s) <- AV*pX(i) */
507:     BVMultVec(d->AX,1.0,0.0,R[i-r_s],&pX[ldpX*i]);
508:     /* R(i-r_s) <- R(i-r_s) - eigr(i)*BX*pX(i) */
509:     BVMultVec(BX,-d->eigr[i],1.0,R[i-r_s],&pX[ldpX*i]);
510:   }
511:   DSRestoreArray(d->eps->ds,DS_MAT_Q,&pX);
512:   d->calcpairs_proj_res(d,r_s,r_e,R);
513:   SlepcVecPoolRestoreVecs(d->auxV,r_e-r_s,&R);
514:   return(0);
515: }

519: static PetscErrorCode dvd_calcpairs_proj_res(dvdDashboard *d,PetscInt r_s,PetscInt r_e,Vec *R)
520: {
521:   PetscInt       i,l,k;
523:   PetscBool      lindep=PETSC_FALSE;
524:   BV             cX;

527:   if (d->W) cX = d->W; /* If left subspace exists, R <- orth(cY, R), nR[i] <- ||R[i]|| */
528:   else if (!(DVD_IS(d->sEP, DVD_EP_STD) && DVD_IS(d->sEP, DVD_EP_HERMITIAN))) cX = d->eps->V; /* If not HEP, R <- orth(cX, R), nR[i] <- ||R[i]|| */
529:   else cX = NULL; /* Otherwise, nR[i] <- ||R[i]|| */

531:   if (cX) {
532:     BVGetActiveColumns(cX,&l,&k);
533:     BVSetActiveColumns(cX,0,l);
534:     for (i=0;i<r_e-r_s;i++) {
535:       BVOrthogonalizeVec(cX,R[i],NULL,&d->nR[r_s+i],&lindep);
536:     }
537:     BVSetActiveColumns(cX,l,k);
538:     if (lindep || (PetscAbs(d->nR[r_s+i]) < PETSC_MACHINE_EPSILON)) {
539:       PetscInfo2(d->eps,"The computed eigenvector residual %D is too low, %g!\n",r_s+i,(double)(d->nR[r_s+i]));
540:     }
541:   } else {
542:     for (i=0;i<r_e-r_s;i++) {
543:       VecNormBegin(R[i],NORM_2,&d->nR[r_s+i]);
544:     }
545:     for (i=0;i<r_e-r_s;i++) {
546:       VecNormEnd(R[i],NORM_2,&d->nR[r_s+i]);
547:     }
548:   }
549:   return(0);
550: }

554: PetscErrorCode dvd_calcpairs_qz(dvdDashboard *d,dvdBlackboard *b,PetscBool borth,PetscInt cX_proj,PetscBool harm)
555: {
557:   PetscBool      std_probl,her_probl,ind_probl,her_ind_probl;
558:   DSType         dstype;
559:   Vec            v1;

562:   std_probl = DVD_IS(d->sEP,DVD_EP_STD)? PETSC_TRUE: PETSC_FALSE;
563:   her_probl = DVD_IS(d->sEP,DVD_EP_HERMITIAN)? PETSC_TRUE: PETSC_FALSE;
564:   ind_probl = DVD_IS(d->sEP,DVD_EP_INDEFINITE)? PETSC_TRUE: PETSC_FALSE;
565:   her_ind_probl = (her_probl||ind_probl)? PETSC_TRUE: PETSC_FALSE;

567:   /* Setting configuration constrains */
568:   b->max_size_proj = PetscMax(b->max_size_proj,b->max_size_V+cX_proj);
569:   d->W_shift = d->B? PETSC_TRUE: PETSC_FALSE;
570:   if (d->B && her_ind_probl && !borth) d->BV_shift = PETSC_TRUE;
571:   else d->BV_shift = PETSC_FALSE;

573:   /* Setup the step */
574:   if (b->state >= DVD_STATE_CONF) {
575:     d->max_cX_in_proj = cX_proj;
576:     d->max_size_P = b->max_size_P;
577:     d->max_size_proj = b->max_size_proj;
578:     /* Create a DS if the method works with Schur decompositions */
579:     d->calcPairs = dvd_calcpairs_proj;
580:     d->calcpairs_residual = dvd_calcpairs_res_0;
581:     d->calcpairs_proj_res = dvd_calcpairs_proj_res;
582:     d->calcpairs_selectPairs = dvd_calcpairs_selectPairs;
583:     /* Create and configure a DS for solving the projected problems */
584:     if (d->W) dstype = DSGNHEP;    /* If we use harmonics */
585:     else {
586:       if (ind_probl) dstype = DSGHIEP;
587:       else if (std_probl) dstype = her_probl? DSHEP : DSNHEP;
588:       else dstype = her_probl? DSGHEP : DSGNHEP;
589:     }
590:     DSSetType(d->eps->ds,dstype);
591:     DSAllocate(d->eps->ds,d->eps->ncv);
592:     /* Create various vector basis */
593:     if (harm) {
594:       BVDuplicateResize(d->eps->V,d->eps->ncv,&d->W);
595:       BVSetMatrix(d->W,NULL,PETSC_FALSE);
596:     } else d->W = NULL;
597:     BVDuplicateResize(d->eps->V,d->eps->ncv,&d->AX);
598:     BVSetMatrix(d->AX,NULL,PETSC_FALSE);
599:     BVDuplicateResize(d->eps->V,d->eps->ncv,&d->auxBV);
600:     BVSetMatrix(d->auxBV,NULL,PETSC_FALSE);
601:     if (d->B) {
602:       BVDuplicateResize(d->eps->V,d->eps->ncv,&d->BX);
603:       BVSetMatrix(d->BX,NULL,PETSC_FALSE);
604:     } else d->BX = NULL;
605:     MatCreateVecs(d->A,&v1,NULL);
606:     SlepcVecPoolCreate(v1,0,&d->auxV);
607:     VecDestroy(&v1);
608:     /* Create projected problem matrices */
609:     MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&d->H);
610:     if (!std_probl) {
611:       MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&d->G);
612:     } else d->G = NULL;
613:     if (her_probl) {
614:       MatSetOption(d->H,MAT_HERMITIAN,PETSC_TRUE);
615:       if (d->G) { MatSetOption(d->G,MAT_HERMITIAN,PETSC_TRUE); }
616:     }

618:     if (ind_probl) {
619:       PetscMalloc1(d->eps->ncv,&d->nBds);
620:     } else d->nBds = NULL;
621:     MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&d->auxM);

623:     EPSDavidsonFLAdd(&d->startList,dvd_calcpairs_qz_start);
624:     EPSDavidsonFLAdd(&d->endList,EPSXDComputeDSConv);
625:     EPSDavidsonFLAdd(&d->destroyList,dvd_calcpairs_qz_d);
626:   }
627:   return(0);
628: }

slepc-3.7.4/src/eps/impls/davidson/dvdutils.c0000644000175000017500000003332513107004621020504 0ustar jromanjroman/* SLEPc eigensolver: "davidson" Some utils - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" typedef struct { PC pc; } dvdPCWrapper; /* Configure the harmonics. switch (mode) { DVD_HARM_RR: harmonic RR DVD_HARM_RRR: relative harmonic RR DVD_HARM_REIGS: rightmost eigenvalues DVD_HARM_LEIGS: largest eigenvalues } fixedTarged, if true use the target instead of the best eigenvalue target, the fixed target to be used */ typedef struct { PetscScalar Wa,Wb; /* span{W} = span{Wa*AV - Wb*BV} */ PetscScalar Pa,Pb; /* H=W'*(Pa*AV - Pb*BV), G=W'*(Wa*AV - Wb*BV) */ PetscBool withTarget; HarmType_t mode; } dvdHarmonic; typedef struct { Vec diagA, diagB; } dvdJacobiPrecond; #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_precond_d" static PetscErrorCode dvd_improvex_precond_d(dvdDashboard *d) { PetscErrorCode ierr; dvdPCWrapper *dvdpc = (dvdPCWrapper*)d->improvex_precond_data; PetscFunctionBegin; /* Free local data */ if (dvdpc->pc) { ierr = PCDestroy(&dvdpc->pc);CHKERRQ(ierr); } ierr = PetscFree(d->improvex_precond_data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_static_precond_PC_0" static PetscErrorCode dvd_static_precond_PC_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px) { PetscErrorCode ierr; dvdPCWrapper *dvdpc = (dvdPCWrapper*)d->improvex_precond_data; PetscFunctionBegin; ierr = PCApply(dvdpc->pc,x,Px);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_precond_none" /* Create a trivial preconditioner */ static PetscErrorCode dvd_precond_none(dvdDashboard *d,PetscInt i,Vec x,Vec Px) { PetscErrorCode ierr; PetscFunctionBegin; ierr = VecCopy(x,Px);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_static_precond_PC" /* Create a static preconditioner from a PC */ PetscErrorCode dvd_static_precond_PC(dvdDashboard *d,dvdBlackboard *b,PC pc) { PetscErrorCode ierr; dvdPCWrapper *dvdpc; Mat P; PetscBool t0,t1,t2; PetscFunctionBegin; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { /* If the preconditioner is valid */ if (pc) { ierr = PetscNewLog(d->eps,&dvdpc);CHKERRQ(ierr); dvdpc->pc = pc; ierr = PetscObjectReference((PetscObject)pc);CHKERRQ(ierr); d->improvex_precond_data = dvdpc; d->improvex_precond = dvd_static_precond_PC_0; /* PC saves the matrix associated with the linear system, and it has to be initialize to a valid matrix */ ierr = PCGetOperatorsSet(pc,NULL,&t0);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pc,PCNONE,&t1);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&t2);CHKERRQ(ierr); if (t0 && !t1) { ierr = PCGetOperators(pc,NULL,&P);CHKERRQ(ierr); ierr = PetscObjectReference((PetscObject)P);CHKERRQ(ierr); ierr = PCSetOperators(pc,P,P);CHKERRQ(ierr); ierr = PCSetReusePreconditioner(pc,PETSC_TRUE);CHKERRQ(ierr); ierr = MatDestroy(&P);CHKERRQ(ierr); } else if (t2) { ierr = PCSetOperators(pc,d->A,d->A);CHKERRQ(ierr); ierr = PCSetReusePreconditioner(pc,PETSC_TRUE);CHKERRQ(ierr); } else { d->improvex_precond = dvd_precond_none; } ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_improvex_precond_d);CHKERRQ(ierr); /* Else, use no preconditioner */ } else d->improvex_precond = dvd_precond_none; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_jacobi_precond_0" static PetscErrorCode dvd_jacobi_precond_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px) { PetscErrorCode ierr; dvdJacobiPrecond *dvdjp = (dvdJacobiPrecond*)d->improvex_precond_data; PetscFunctionBegin; /* Compute inv(D - eig)*x */ if (dvdjp->diagB == 0) { /* Px <- diagA - l */ ierr = VecCopy(dvdjp->diagA,Px);CHKERRQ(ierr); ierr = VecShift(Px,-d->eigr[i]);CHKERRQ(ierr); } else { /* Px <- diagA - l*diagB */ ierr = VecWAXPY(Px,-d->eigr[i],dvdjp->diagB,dvdjp->diagA);CHKERRQ(ierr); } /* Px(i) <- x/Px(i) */ ierr = VecPointwiseDivide(Px,x,Px);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_jacobi_precond_d" static PetscErrorCode dvd_jacobi_precond_d(dvdDashboard *d) { PetscErrorCode ierr; dvdJacobiPrecond *dvdjp = (dvdJacobiPrecond*)d->improvex_precond_data; PetscFunctionBegin; if (dvdjp->diagA) { ierr = VecDestroy(&dvdjp->diagA);CHKERRQ(ierr); } if (dvdjp->diagB) { ierr = VecDestroy(&dvdjp->diagB);CHKERRQ(ierr); } ierr = PetscFree(d->improvex_precond_data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_jacobi_precond" /* Create the Jacobi preconditioner for Generalized Eigenproblems */ PetscErrorCode dvd_jacobi_precond(dvdDashboard *d,dvdBlackboard *b) { PetscErrorCode ierr; dvdJacobiPrecond *dvdjp; PetscBool t; PetscFunctionBegin; /* Check if the problem matrices support GetDiagonal */ ierr = MatHasOperation(d->A,MATOP_GET_DIAGONAL,&t);CHKERRQ(ierr); if (t && d->B) { ierr = MatHasOperation(d->B,MATOP_GET_DIAGONAL,&t);CHKERRQ(ierr); } /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscNewLog(d->eps,&dvdjp);CHKERRQ(ierr); if (t) { ierr = MatCreateVecs(d->A,&dvdjp->diagA,NULL);CHKERRQ(ierr); ierr = MatGetDiagonal(d->A,dvdjp->diagA);CHKERRQ(ierr); if (d->B) { ierr = MatCreateVecs(d->B,&dvdjp->diagB,NULL);CHKERRQ(ierr); ierr = MatGetDiagonal(d->B,dvdjp->diagB);CHKERRQ(ierr); } else dvdjp->diagB = 0; d->improvex_precond_data = dvdjp; d->improvex_precond = dvd_jacobi_precond_0; ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_jacobi_precond_d);CHKERRQ(ierr); /* Else, use no preconditioner */ } else { dvdjp->diagA = dvdjp->diagB = 0; d->improvex_precond = dvd_precond_none; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_d" static PetscErrorCode dvd_harm_d(dvdDashboard *d) { PetscErrorCode ierr; PetscFunctionBegin; /* Free local data */ ierr = PetscFree(d->calcpairs_W_data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_transf" static PetscErrorCode dvd_harm_transf(dvdHarmonic *dvdh,PetscScalar t) { PetscFunctionBegin; switch (dvdh->mode) { case DVD_HARM_RR: /* harmonic RR */ dvdh->Wa = 1.0; dvdh->Wb = t; dvdh->Pa = 0.0; dvdh->Pb = -1.0; break; case DVD_HARM_RRR: /* relative harmonic RR */ dvdh->Wa = 1.0; dvdh->Wb = t; dvdh->Pa = 1.0; dvdh->Pb = 0.0; break; case DVD_HARM_REIGS: /* rightmost eigenvalues */ dvdh->Wa = 1.0; dvdh->Wb = t; dvdh->Pa = 1.0; dvdh->Pb = -PetscConj(t); break; case DVD_HARM_LEIGS: /* largest eigenvalues */ dvdh->Wa = 0.0; dvdh->Wb = 1.0; dvdh->Pa = 1.0; dvdh->Pb = 0.0; break; case DVD_HARM_NONE: default: SETERRQ(PETSC_COMM_SELF,1, "Harmonic type not supported"); } /* Check the transformation does not change the sign of the imaginary part */ #if !defined(PETSC_USE_COMPLEX) if (dvdh->Pb*dvdh->Wa - dvdh->Wb*dvdh->Pa < 0.0) { dvdh->Pa *= -1.0; dvdh->Pb *= -1.0; } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_updateW" static PetscErrorCode dvd_harm_updateW(dvdDashboard *d) { dvdHarmonic *data = (dvdHarmonic*)d->calcpairs_W_data; PetscErrorCode ierr; PetscInt l,k; BV BX = d->BX?d->BX:d->eps->V; PetscFunctionBegin; /* Update the target if it is necessary */ if (!data->withTarget) { ierr = dvd_harm_transf(data,d->eigr[0]);CHKERRQ(ierr); } /* W(i) <- Wa*AV(i) - Wb*BV(i) */ ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); if (k != l+d->V_new_s) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken"); ierr = BVSetActiveColumns(d->W,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); ierr = BVSetActiveColumns(BX,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); ierr = BVCopy(d->AX,d->W);CHKERRQ(ierr); ierr = BVScale(d->W,data->Wa);CHKERRQ(ierr); ierr = BVMult(d->W,-data->Wb,1.0,BX,NULL);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->W,l,k);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,l,k);CHKERRQ(ierr); ierr = BVSetActiveColumns(BX,l,k);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_proj" static PetscErrorCode dvd_harm_proj(dvdDashboard *d) { PetscErrorCode ierr; dvdHarmonic *data = (dvdHarmonic*)d->calcpairs_W_data; PetscInt i,j,l0,l,k,ld; PetscScalar h,g,*H,*G; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l0,&k);CHKERRQ(ierr); l = l0 + d->V_new_s; k = l0 + d->V_new_e; ierr = MatGetSize(d->H,&ld,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(d->H,&H);CHKERRQ(ierr); ierr = MatDenseGetArray(d->G,&G);CHKERRQ(ierr); /* [H G] <- [Pa*H - Pb*G, Wa*H - Wb*G] */ /* Right part */ for (i=l;iPa*h - data->Pb*g; G[ld*i+j] = data->Wa*h - data->Wb*g; } } /* Left part */ for (i=l0;iPa*h - data->Pb*g; G[ld*i+j] = data->Wa*h - data->Wb*g; } } ierr = MatDenseRestoreArray(d->H,&H);CHKERRQ(ierr); ierr = MatDenseRestoreArray(d->G,&G);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_updateproj" PetscErrorCode dvd_harm_updateproj(dvdDashboard *d) { PetscErrorCode ierr; dvdHarmonic *data = (dvdHarmonic*)d->calcpairs_W_data; PetscInt i,j,l,k,ld; PetscScalar h,g,*H,*G; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); k = l + d->V_tra_s; ierr = MatGetSize(d->H,&ld,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(d->H,&H);CHKERRQ(ierr); ierr = MatDenseGetArray(d->G,&G);CHKERRQ(ierr); /* [H G] <- [Pa*H - Pb*G, Wa*H - Wb*G] */ /* Right part */ for (i=l;iPa*h - data->Pb*g; G[ld*i+j] = data->Wa*h - data->Wb*g; } } /* Lower triangular part */ for (i=0;iPa*h - data->Pb*g; G[ld*i+j] = data->Wa*h - data->Wb*g; } } ierr = MatDenseRestoreArray(d->H,&H);CHKERRQ(ierr); ierr = MatDenseRestoreArray(d->G,&G);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_backtrans" static PetscErrorCode dvd_harm_backtrans(dvdHarmonic *data,PetscScalar *ar,PetscScalar *ai) { PetscScalar xr; #if !defined(PETSC_USE_COMPLEX) PetscScalar xi, k; #endif PetscFunctionBegin; PetscValidPointer(ar,2); xr = *ar; #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(ai,3); xi = *ai; if (xi != 0.0) { k = (data->Pa - data->Wa*xr)*(data->Pa - data->Wa*xr) + data->Wa*data->Wa*xi*xi; *ar = (data->Pb*data->Pa - (data->Pb*data->Wa + data->Wb*data->Pa)*xr + data->Wb*data->Wa*(xr*xr + xi*xi))/k; *ai = (data->Pb*data->Wa - data->Wb*data->Pa)*xi/k; } else #endif *ar = (data->Pb - data->Wb*xr) / (data->Pa - data->Wa*xr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_eig_backtrans" static PetscErrorCode dvd_harm_eig_backtrans(dvdDashboard *d,PetscScalar ar,PetscScalar ai,PetscScalar *br,PetscScalar *bi) { dvdHarmonic *data = (dvdHarmonic*)d->calcpairs_W_data; PetscErrorCode ierr; PetscFunctionBegin; ierr = dvd_harm_backtrans(data,&ar,&ai);CHKERRQ(ierr); *br = ar; *bi = ai; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_eigs_trans" static PetscErrorCode dvd_harm_eigs_trans(dvdDashboard *d) { dvdHarmonic *data = (dvdHarmonic*)d->calcpairs_W_data; PetscInt i,l,k; PetscErrorCode ierr; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); for (i=0;ieigr[i],&d->eigi[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_harm_conf" PetscErrorCode dvd_harm_conf(dvdDashboard *d,dvdBlackboard *b,HarmType_t mode,PetscBool fixedTarget,PetscScalar t) { PetscErrorCode ierr; dvdHarmonic *dvdh; PetscFunctionBegin; /* Set the problem to GNHEP: d->G maybe is upper triangular due to biorthogonality of V and W */ d->sEP = d->sA = d->sB = 0; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscNewLog(d->eps,&dvdh);CHKERRQ(ierr); dvdh->withTarget = fixedTarget; dvdh->mode = mode; if (fixedTarget) dvd_harm_transf(dvdh, t); d->calcpairs_W_data = dvdh; d->calcpairs_W = dvd_harm_updateW; d->calcpairs_proj_trans = dvd_harm_proj; d->calcpairs_eigs_trans = dvd_harm_eigs_trans; d->calcpairs_eig_backtrans = dvd_harm_eig_backtrans; ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_harm_d);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/dvdutils.c.html0000644000175000017500000006773513107004621021463 0ustar jromanjroman
Actual source code: dvdutils.c

slepc-3.7.4 2017-05-17
  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Some utils

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

 10:    This file is part of SLEPc.

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

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

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

 26:  #include davidson.h

 28: typedef struct {
 29:   PC pc;
 30: } dvdPCWrapper;

 32: /*
 33:   Configure the harmonics.
 34:   switch (mode) {
 35:   DVD_HARM_RR:    harmonic RR
 36:   DVD_HARM_RRR:   relative harmonic RR
 37:   DVD_HARM_REIGS: rightmost eigenvalues
 38:   DVD_HARM_LEIGS: largest eigenvalues
 39:   }
 40:   fixedTarged, if true use the target instead of the best eigenvalue
 41:   target, the fixed target to be used
 42: */
 43: typedef struct {
 44:   PetscScalar Wa,Wb;       /* span{W} = span{Wa*AV - Wb*BV} */
 45:   PetscScalar Pa,Pb;       /* H=W'*(Pa*AV - Pb*BV), G=W'*(Wa*AV - Wb*BV) */
 46:   PetscBool   withTarget;
 47:   HarmType_t  mode;
 48: } dvdHarmonic;

 50: typedef struct {
 51:   Vec diagA, diagB;
 52: } dvdJacobiPrecond;

 56: static PetscErrorCode dvd_improvex_precond_d(dvdDashboard *d)
 57: {
 59:   dvdPCWrapper   *dvdpc = (dvdPCWrapper*)d->improvex_precond_data;

 62:   /* Free local data */
 63:   if (dvdpc->pc) { PCDestroy(&dvdpc->pc); }
 64:   PetscFree(d->improvex_precond_data);
 65:   return(0);
 66: }

 70: static PetscErrorCode dvd_static_precond_PC_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px)
 71: {
 73:   dvdPCWrapper   *dvdpc = (dvdPCWrapper*)d->improvex_precond_data;

 76:   PCApply(dvdpc->pc,x,Px);
 77:   return(0);
 78: }

 82: /*
 83:   Create a trivial preconditioner
 84: */
 85: static PetscErrorCode dvd_precond_none(dvdDashboard *d,PetscInt i,Vec x,Vec Px)
 86: {

 90:   VecCopy(x,Px);
 91:   return(0);
 92: }

 96: /*
 97:   Create a static preconditioner from a PC
 98: */
 99: PetscErrorCode dvd_static_precond_PC(dvdDashboard *d,dvdBlackboard *b,PC pc)
100: {
102:   dvdPCWrapper   *dvdpc;
103:   Mat            P;
104:   PetscBool      t0,t1,t2;

107:   /* Setup the step */
108:   if (b->state >= DVD_STATE_CONF) {
109:     /* If the preconditioner is valid */
110:     if (pc) {
111:       PetscNewLog(d->eps,&dvdpc);
112:       dvdpc->pc = pc;
113:       PetscObjectReference((PetscObject)pc);
114:       d->improvex_precond_data = dvdpc;
115:       d->improvex_precond = dvd_static_precond_PC_0;

117:       /* PC saves the matrix associated with the linear system, and it has to
118:          be initialize to a valid matrix */
119:       PCGetOperatorsSet(pc,NULL,&t0);
120:       PetscObjectTypeCompare((PetscObject)pc,PCNONE,&t1);
121:       PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&t2);
122:       if (t0 && !t1) {
123:         PCGetOperators(pc,NULL,&P);
124:         PetscObjectReference((PetscObject)P);
125:         PCSetOperators(pc,P,P);
126:         PCSetReusePreconditioner(pc,PETSC_TRUE);
127:         MatDestroy(&P);
128:       } else if (t2) {
129:         PCSetOperators(pc,d->A,d->A);
130:         PCSetReusePreconditioner(pc,PETSC_TRUE);
131:       } else {
132:         d->improvex_precond = dvd_precond_none;
133:       }

135:       EPSDavidsonFLAdd(&d->destroyList,dvd_improvex_precond_d);

137:     /* Else, use no preconditioner */
138:     } else d->improvex_precond = dvd_precond_none;
139:   }
140:   return(0);
141: }

145: static PetscErrorCode dvd_jacobi_precond_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px)
146: {
147:   PetscErrorCode   ierr;
148:   dvdJacobiPrecond *dvdjp = (dvdJacobiPrecond*)d->improvex_precond_data;

151:   /* Compute inv(D - eig)*x */
152:   if (dvdjp->diagB == 0) {
153:     /* Px <- diagA - l */
154:     VecCopy(dvdjp->diagA,Px);
155:     VecShift(Px,-d->eigr[i]);
156:   } else {
157:     /* Px <- diagA - l*diagB */
158:     VecWAXPY(Px,-d->eigr[i],dvdjp->diagB,dvdjp->diagA);
159:   }

161:   /* Px(i) <- x/Px(i) */
162:   VecPointwiseDivide(Px,x,Px);
163:   return(0);
164: }

168: static PetscErrorCode dvd_jacobi_precond_d(dvdDashboard *d)
169: {
170:   PetscErrorCode   ierr;
171:   dvdJacobiPrecond *dvdjp = (dvdJacobiPrecond*)d->improvex_precond_data;

174:   if (dvdjp->diagA) { VecDestroy(&dvdjp->diagA); }
175:   if (dvdjp->diagB) { VecDestroy(&dvdjp->diagB); }
176:   PetscFree(d->improvex_precond_data);
177:   return(0);
178: }

182: /*
183:   Create the Jacobi preconditioner for Generalized Eigenproblems
184: */
185: PetscErrorCode dvd_jacobi_precond(dvdDashboard *d,dvdBlackboard *b)
186: {
187:   PetscErrorCode   ierr;
188:   dvdJacobiPrecond *dvdjp;
189:   PetscBool        t;

192:   /* Check if the problem matrices support GetDiagonal */
193:   MatHasOperation(d->A,MATOP_GET_DIAGONAL,&t);
194:   if (t && d->B) {
195:     MatHasOperation(d->B,MATOP_GET_DIAGONAL,&t);
196:   }

198:   /* Setup the step */
199:   if (b->state >= DVD_STATE_CONF) {
200:     PetscNewLog(d->eps,&dvdjp);
201:     if (t) {
202:       MatCreateVecs(d->A,&dvdjp->diagA,NULL);
203:       MatGetDiagonal(d->A,dvdjp->diagA);
204:       if (d->B) {
205:         MatCreateVecs(d->B,&dvdjp->diagB,NULL);
206:         MatGetDiagonal(d->B,dvdjp->diagB);
207:       } else dvdjp->diagB = 0;
208:       d->improvex_precond_data = dvdjp;
209:       d->improvex_precond = dvd_jacobi_precond_0;

211:       EPSDavidsonFLAdd(&d->destroyList,dvd_jacobi_precond_d);

213:     /* Else, use no preconditioner */
214:     } else {
215:       dvdjp->diagA = dvdjp->diagB = 0;
216:       d->improvex_precond = dvd_precond_none;
217:     }
218:   }
219:   return(0);
220: }

224: static PetscErrorCode dvd_harm_d(dvdDashboard *d)
225: {

229:   /* Free local data */
230:   PetscFree(d->calcpairs_W_data);
231:   return(0);
232: }

236: static PetscErrorCode dvd_harm_transf(dvdHarmonic *dvdh,PetscScalar t)
237: {
239:   switch (dvdh->mode) {
240:   case DVD_HARM_RR:    /* harmonic RR */
241:     dvdh->Wa = 1.0; dvdh->Wb = t;   dvdh->Pa = 0.0; dvdh->Pb = -1.0;
242:     break;
243:   case DVD_HARM_RRR:   /* relative harmonic RR */
244:     dvdh->Wa = 1.0; dvdh->Wb = t;   dvdh->Pa = 1.0; dvdh->Pb = 0.0;
245:     break;
246:   case DVD_HARM_REIGS: /* rightmost eigenvalues */
247:     dvdh->Wa = 1.0; dvdh->Wb = t;   dvdh->Pa = 1.0; dvdh->Pb = -PetscConj(t);
248:     break;
249:   case DVD_HARM_LEIGS: /* largest eigenvalues */
250:     dvdh->Wa = 0.0; dvdh->Wb = 1.0; dvdh->Pa = 1.0; dvdh->Pb = 0.0;
251:     break;
252:   case DVD_HARM_NONE:
253:   default:
254:     SETERRQ(PETSC_COMM_SELF,1, "Harmonic type not supported");
255:   }

257:   /* Check the transformation does not change the sign of the imaginary part */
258: #if !defined(PETSC_USE_COMPLEX)
259:   if (dvdh->Pb*dvdh->Wa - dvdh->Wb*dvdh->Pa < 0.0) {
260:     dvdh->Pa *= -1.0;
261:     dvdh->Pb *= -1.0;
262:   }
263: #endif
264:   return(0);
265: }

269: static PetscErrorCode dvd_harm_updateW(dvdDashboard *d)
270: {
271:   dvdHarmonic    *data = (dvdHarmonic*)d->calcpairs_W_data;
273:   PetscInt       l,k;
274:   BV             BX = d->BX?d->BX:d->eps->V;

277:   /* Update the target if it is necessary */
278:   if (!data->withTarget) {
279:     dvd_harm_transf(data,d->eigr[0]);
280:   }

282:   /* W(i) <- Wa*AV(i) - Wb*BV(i) */
283:   BVGetActiveColumns(d->eps->V,&l,&k);
284:   if (k != l+d->V_new_s) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken");
285:   BVSetActiveColumns(d->W,l+d->V_new_s,l+d->V_new_e);
286:   BVSetActiveColumns(d->AX,l+d->V_new_s,l+d->V_new_e);
287:   BVSetActiveColumns(BX,l+d->V_new_s,l+d->V_new_e);
288:   BVCopy(d->AX,d->W);
289:   BVScale(d->W,data->Wa);
290:   BVMult(d->W,-data->Wb,1.0,BX,NULL);
291:   BVSetActiveColumns(d->W,l,k);
292:   BVSetActiveColumns(d->AX,l,k);
293:   BVSetActiveColumns(BX,l,k);
294:   return(0);
295: }

299: static PetscErrorCode dvd_harm_proj(dvdDashboard *d)
300: {
302:   dvdHarmonic    *data = (dvdHarmonic*)d->calcpairs_W_data;
303:   PetscInt       i,j,l0,l,k,ld;
304:   PetscScalar    h,g,*H,*G;

307:   BVGetActiveColumns(d->eps->V,&l0,&k);
308:   l = l0 + d->V_new_s;
309:   k = l0 + d->V_new_e;
310:   MatGetSize(d->H,&ld,NULL);
311:   MatDenseGetArray(d->H,&H);
312:   MatDenseGetArray(d->G,&G);
313:   /* [H G] <- [Pa*H - Pb*G, Wa*H - Wb*G] */
314:   /* Right part */
315:   for (i=l;i<k;i++) {
316:     for (j=l0;j<k;j++) {
317:       h = H[ld*i+j];
318:       g = G[ld*i+j];
319:       H[ld*i+j] = data->Pa*h - data->Pb*g;
320:       G[ld*i+j] = data->Wa*h - data->Wb*g;
321:     }
322:   }
323:   /* Left part */
324:   for (i=l0;i<l;i++) {
325:     for (j=l;j<k;j++) {
326:       h = H[ld*i+j];
327:       g = G[ld*i+j];
328:       H[ld*i+j] = data->Pa*h - data->Pb*g;
329:       G[ld*i+j] = data->Wa*h - data->Wb*g;
330:     }
331:   }
332:   MatDenseRestoreArray(d->H,&H);
333:   MatDenseRestoreArray(d->G,&G);
334:   return(0);
335: }

339: PetscErrorCode dvd_harm_updateproj(dvdDashboard *d)
340: {
342:   dvdHarmonic    *data = (dvdHarmonic*)d->calcpairs_W_data;
343:   PetscInt       i,j,l,k,ld;
344:   PetscScalar    h,g,*H,*G;

347:   BVGetActiveColumns(d->eps->V,&l,&k);
348:   k = l + d->V_tra_s;
349:   MatGetSize(d->H,&ld,NULL);
350:   MatDenseGetArray(d->H,&H);
351:   MatDenseGetArray(d->G,&G);
352:   /* [H G] <- [Pa*H - Pb*G, Wa*H - Wb*G] */
353:   /* Right part */
354:   for (i=l;i<k;i++) {
355:     for (j=0;j<l;j++) {
356:       h = H[ld*i+j];
357:       g = G[ld*i+j];
358:       H[ld*i+j] = data->Pa*h - data->Pb*g;
359:       G[ld*i+j] = data->Wa*h - data->Wb*g;
360:     }
361:   }
362:   /* Lower triangular part */
363:   for (i=0;i<l;i++) {
364:     for (j=l;j<k;j++) {
365:       h = H[ld*i+j];
366:       g = G[ld*i+j];
367:       H[ld*i+j] = data->Pa*h - data->Pb*g;
368:       G[ld*i+j] = data->Wa*h - data->Wb*g;
369:     }
370:   }
371:   MatDenseRestoreArray(d->H,&H);
372:   MatDenseRestoreArray(d->G,&G);
373:   return(0);
374: }

378: static PetscErrorCode dvd_harm_backtrans(dvdHarmonic *data,PetscScalar *ar,PetscScalar *ai)
379: {
380:   PetscScalar xr;
381: #if !defined(PETSC_USE_COMPLEX)
382:   PetscScalar xi, k;
383: #endif

387:   xr = *ar;
388: #if !defined(PETSC_USE_COMPLEX)
390:   xi = *ai;

392:   if (xi != 0.0) {
393:     k = (data->Pa - data->Wa*xr)*(data->Pa - data->Wa*xr) + data->Wa*data->Wa*xi*xi;
394:     *ar = (data->Pb*data->Pa - (data->Pb*data->Wa + data->Wb*data->Pa)*xr + data->Wb*data->Wa*(xr*xr + xi*xi))/k;
395:     *ai = (data->Pb*data->Wa - data->Wb*data->Pa)*xi/k;
396:   } else
397: #endif
398:     *ar = (data->Pb - data->Wb*xr) / (data->Pa - data->Wa*xr);
399:   return(0);
400: }

404: static PetscErrorCode dvd_harm_eig_backtrans(dvdDashboard *d,PetscScalar ar,PetscScalar ai,PetscScalar *br,PetscScalar *bi)
405: {
406:   dvdHarmonic    *data = (dvdHarmonic*)d->calcpairs_W_data;

410:   dvd_harm_backtrans(data,&ar,&ai);
411:   *br = ar;
412:   *bi = ai;
413:   return(0);
414: }

418: static PetscErrorCode dvd_harm_eigs_trans(dvdDashboard *d)
419: {
420:   dvdHarmonic    *data = (dvdHarmonic*)d->calcpairs_W_data;
421:   PetscInt       i,l,k;

425:   BVGetActiveColumns(d->eps->V,&l,&k);
426:   for (i=0;i<k-l;i++) {
427:     dvd_harm_backtrans(data,&d->eigr[i],&d->eigi[i]);
428:   }
429:   return(0);
430: }

434: PetscErrorCode dvd_harm_conf(dvdDashboard *d,dvdBlackboard *b,HarmType_t mode,PetscBool fixedTarget,PetscScalar t)
435: {
437:   dvdHarmonic    *dvdh;

440:   /* Set the problem to GNHEP:
441:      d->G maybe is upper triangular due to biorthogonality of V and W */
442:   d->sEP = d->sA = d->sB = 0;

444:   /* Setup the step */
445:   if (b->state >= DVD_STATE_CONF) {
446:     PetscNewLog(d->eps,&dvdh);
447:     dvdh->withTarget = fixedTarget;
448:     dvdh->mode = mode;
449:     if (fixedTarget) dvd_harm_transf(dvdh, t);
450:     d->calcpairs_W_data = dvdh;
451:     d->calcpairs_W = dvd_harm_updateW;
452:     d->calcpairs_proj_trans = dvd_harm_proj;
453:     d->calcpairs_eigs_trans = dvd_harm_eigs_trans;
454:     d->calcpairs_eig_backtrans = dvd_harm_eig_backtrans;

456:     EPSDavidsonFLAdd(&d->destroyList,dvd_harm_d);
457:   }
458:   return(0);
459: }

slepc-3.7.4/src/eps/impls/davidson/dvdimprovex.c.html0000644000175000017500000027132013107004621022157 0ustar jromanjroman
Actual source code: dvdimprovex.c

slepc-3.7.4 2017-05-17
  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Step: improve the eigenvectors X

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

 10:    This file is part of SLEPc.

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

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

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

 26:  #include davidson.h
 27: #include <slepcblaslapack.h>

 29: /**** JD update step (I - Kfg'/(g'Kf)) K(A - sB) (I - Kfg'/(g'Kf)) t = (I - Kfg'/(g'Kf))r  ****/

 31: typedef struct {
 32:   PetscInt     size_X;
 33:   KSP          ksp;                /* correction equation solver */
 34:   Vec          friends;            /* reference vector for composite vectors */
 35:   PetscScalar  theta[4],thetai[2]; /* the shifts used in the correction eq. */
 36:   PetscInt     maxits;             /* maximum number of iterations */
 37:   PetscInt     r_s,r_e;            /* the selected eigenpairs to improve */
 38:   PetscInt     ksp_max_size;       /* the ksp maximum subvectors size */
 39:   PetscReal    tol;                /* the maximum solution tolerance */
 40:   PetscReal    lastTol;            /* last tol for dynamic stopping criterion */
 41:   PetscReal    fix;                /* tolerance for using the approx. eigenvalue */
 42:   PetscBool    dynamic;            /* if the dynamic stopping criterion is applied */
 43:   dvdDashboard *d;                 /* the currect dvdDashboard reference */
 44:   PC           old_pc;             /* old pc in ksp */
 45:   BV           KZ;                 /* KZ vecs for the projector KZ*inv(X'*KZ)*X' */
 46:   BV           U;                  /* new X vectors */
 47:   PetscScalar  *XKZ;               /* X'*KZ */
 48:   PetscScalar  *iXKZ;              /* inverse of XKZ */
 49:   PetscInt     ldXKZ;              /* leading dimension of XKZ */
 50:   PetscInt     size_iXKZ;          /* size of iXKZ */
 51:   PetscInt     ldiXKZ;             /* leading dimension of iXKZ */
 52:   PetscInt     size_cX;            /* last value of d->size_cX */
 53:   PetscInt     old_size_X;         /* last number of improved vectors */
 54:   PetscBLASInt *iXKZPivots;        /* array of pivots */
 55: } dvdImprovex_jd;

 59: /*
 60:    Compute (I - KZ*iXKZ*X')*V where,
 61:    V, the vectors to apply the projector,
 62:    cV, the number of vectors in V,
 63: */
 64: static PetscErrorCode dvd_improvex_apply_proj(dvdDashboard *d,Vec *V,PetscInt cV)
 65: {
 66: #if defined(PETSC_MISSING_LAPACK_GETRS)
 68:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routines are unavailable");
 69: #else
 71:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;
 72:   PetscInt       i,ldh,k,l;
 73:   PetscScalar    *h;
 74:   PetscBLASInt   cV_,n,info,ld;
 75: #if defined(PETSC_USE_COMPLEX)
 76:   PetscInt       j;
 77: #endif

 80:   if (cV > 2) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken");

 82:   /* h <- X'*V */
 83:   PetscMalloc1(data->size_iXKZ*cV,&h);
 84:   ldh = data->size_iXKZ;
 85:   BVGetActiveColumns(data->U,&l,&k);
 86:   if (ldh!=k) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken");
 87:   BVSetActiveColumns(data->U,0,k);
 88:   for (i=0;i<cV;i++) {
 89:     BVDotVec(data->U,V[i],&h[ldh*i]);
 90: #if defined(PETSC_USE_COMPLEX)
 91:     for (j=0; j<k; j++) h[ldh*i+j] = PetscConj(h[ldh*i+j]);
 92: #endif
 93:   }
 94:   BVSetActiveColumns(data->U,l,k);

 96:   /* h <- iXKZ\h */
 97:   PetscBLASIntCast(cV,&cV_);
 98:   PetscBLASIntCast(data->size_iXKZ,&n);
 99:   PetscBLASIntCast(data->ldiXKZ,&ld);
101:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
102:   PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("N",&n,&cV_,data->iXKZ,&ld,data->iXKZPivots,h,&n,&info));
103:   PetscFPTrapPop();
104:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack XGETRS %d",info);

106:   /* V <- V - KZ*h */
107:   BVSetActiveColumns(data->KZ,0,k);
108:   for (i=0;i<cV;i++) {
109:     BVMultVec(data->KZ,-1.0,1.0,V[i],&h[ldh*i]);
110:   }
111:   BVSetActiveColumns(data->KZ,l,k);
112:   PetscFree(h);
113:   return(0);
114: #endif
115: }

119: /*
120:    Compute (I - X*iXKZ*KZ')*V where,
121:    V, the vectors to apply the projector,
122:    cV, the number of vectors in V,
123: */
124: static PetscErrorCode dvd_improvex_applytrans_proj(dvdDashboard *d,Vec *V,PetscInt cV)
125: {
126: #if defined(PETSC_MISSING_LAPACK_GETRS)
128:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routines are unavailable");
129:   return(0);
130: #else
132:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;
133:   PetscInt       i,ldh,k,l;
134:   PetscScalar    *h;
135:   PetscBLASInt   cV_, n, info, ld;
136: #if defined(PETSC_USE_COMPLEX)
137:   PetscInt       j;
138: #endif

141:   if (cV > 2) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken");

143:   /* h <- KZ'*V */
144:   PetscMalloc1(data->size_iXKZ*cV,&h);
145:   ldh = data->size_iXKZ;
146:   BVGetActiveColumns(data->U,&l,&k);
147:   if (ldh!=k) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken");
148:   BVSetActiveColumns(data->KZ,0,k);
149:   for (i=0;i<cV;i++) {
150:     BVDotVec(data->KZ,V[i],&h[ldh*i]);
151: #if defined(PETSC_USE_COMPLEX)
152:     for (j=0;j<k;j++) h[ldh*i+j] = PetscConj(h[ldh*i+j]);
153: #endif
154:   }
155:   BVSetActiveColumns(data->KZ,l,k);

157:   /* h <- iXKZ\h */
158:   PetscBLASIntCast(cV,&cV_);
159:   PetscBLASIntCast(data->size_iXKZ,&n);
160:   PetscBLASIntCast(data->ldiXKZ,&ld);
162:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
163:   PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("C",&n,&cV_,data->iXKZ,&ld,data->iXKZPivots,h,&n,&info));
164:   PetscFPTrapPop();
165:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack XGETRS %d",info);

167:   /* V <- V - U*h */
168:   BVSetActiveColumns(data->U,0,k);
169:   for (i=0;i<cV;i++) {
170:     BVMultVec(data->U,-1.0,1.0,V[i],&h[ldh*i]);
171:   }
172:   BVSetActiveColumns(data->U,l,k);
173:   PetscFree(h);
174:   return(0);
175: #endif
176: }

180: static PetscErrorCode dvd_improvex_jd_end(dvdDashboard *d)
181: {
183:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;

186:   if (data->friends) { VecDestroy(&data->friends); }

188:   /* Restore the pc of ksp */
189:   if (data->old_pc) {
190:     KSPSetPC(data->ksp, data->old_pc);
191:     PCDestroy(&data->old_pc);
192:   }
193:   return(0);
194: }

198: static PetscErrorCode dvd_improvex_jd_d(dvdDashboard *d)
199: {
201:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;

204:   /* Free local data and objects */
205:   PetscFree(data->XKZ);
206:   PetscFree(data->iXKZ);
207:   PetscFree(data->iXKZPivots);
208:   BVDestroy(&data->KZ);
209:   BVDestroy(&data->U);
210:   PetscFree(data);
211:   return(0);
212: }

216: /*
217:    y <- theta[1]A*x - theta[0]*B*x
218:    auxV, two auxiliary vectors
219:  */
220: PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmult(dvdImprovex_jd *data,const Vec *x,const Vec *y)
221: {
223:   PetscInt       n,i;
224:   const Vec      *Bx;
225:   Vec            *auxV;

228:   n = data->r_e - data->r_s;
229:   for (i=0;i<n;i++) {
230:     MatMult(data->d->A,x[i],y[i]);
231:   }

233:   SlepcVecPoolGetVecs(data->d->auxV,2,&auxV);
234:   for (i=0;i<n;i++) {
235: #if !defined(PETSC_USE_COMPLEX)
236:     if (data->d->eigi[data->r_s+i] != 0.0) {
237:       if (data->d->B) {
238:         MatMult(data->d->B,x[i],auxV[0]);
239:         MatMult(data->d->B,x[i+1],auxV[1]);
240:         Bx = auxV;
241:       } else Bx = &x[i];

243:       /* y_i   <- [ t_2i+1*A*x_i   - t_2i*Bx_i + ti_i*Bx_i+1;
244:          y_i+1      t_2i+1*A*x_i+1 - ti_i*Bx_i - t_2i*Bx_i+1  ] */
245:       VecAXPBYPCZ(y[i],-data->theta[2*i],data->thetai[i],data->theta[2*i+1],Bx[0],Bx[1]);
246:       VecAXPBYPCZ(y[i+1],-data->thetai[i],-data->theta[2*i],data->theta[2*i+1],Bx[0],Bx[1]);
247:       i++;
248:     } else
249: #endif
250:     {
251:       if (data->d->B) {
252:         MatMult(data->d->B,x[i],auxV[0]);
253:         Bx = auxV;
254:       } else Bx = &x[i];
255:       VecAXPBY(y[i],-data->theta[i*2],data->theta[i*2+1],Bx[0]);
256:     }
257:   }
258:   SlepcVecPoolRestoreVecs(data->d->auxV,2,&auxV);
259:   return(0);
260: }

264: /*
265:    y <- theta[1]'*A'*x - theta[0]'*B'*x
266:  */
267: PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmulttrans(dvdImprovex_jd *data,const Vec *x,const Vec *y)
268: {
270:   PetscInt       n,i;
271:   const Vec      *Bx;
272:   Vec            *auxV;

275:   n = data->r_e - data->r_s;
276:   for (i=0;i<n;i++) {
277:     MatMultTranspose(data->d->A,x[i],y[i]);
278:   }

280:   SlepcVecPoolGetVecs(data->d->auxV,2,&auxV);
281:   for (i=0;i<n;i++) {
282: #if !defined(PETSC_USE_COMPLEX)
283:     if (data->d->eigi[data->r_s+i] != 0.0) {
284:       if (data->d->B) {
285:         MatMultTranspose(data->d->B,x[i],auxV[0]);
286:         MatMultTranspose(data->d->B,x[i+1],auxV[1]);
287:         Bx = auxV;
288:       } else Bx = &x[i];

290:       /* y_i   <- [ t_2i+1*A*x_i   - t_2i*Bx_i - ti_i*Bx_i+1;
291:          y_i+1      t_2i+1*A*x_i+1 + ti_i*Bx_i - t_2i*Bx_i+1  ] */
292:       VecAXPBYPCZ(y[i],-data->theta[2*i],-data->thetai[i],data->theta[2*i+1],Bx[0],Bx[1]);
293:       VecAXPBYPCZ(y[i+1],data->thetai[i],-data->theta[2*i],data->theta[2*i+1],Bx[0],Bx[1]);
294:       i++;
295:     } else
296: #endif
297:     {
298:       if (data->d->B) {
299:         MatMultTranspose(data->d->B,x[i],auxV[0]);
300:         Bx = auxV;
301:       } else Bx = &x[i];
302:       VecAXPBY(y[i],PetscConj(-data->theta[i*2]),PetscConj(data->theta[i*2+1]),Bx[0]);
303:     }
304:   }
305:   SlepcVecPoolRestoreVecs(data->d->auxV,2,&auxV);
306:   return(0);
307: }

311: static PetscErrorCode PCApplyBA_dvd(PC pc,PCSide side,Vec in,Vec out,Vec w)
312: {
314:   dvdImprovex_jd *data;
315:   PetscInt       n,i;
316:   const Vec      *inx,*outx,*wx;
317:   Vec            *auxV;
318:   Mat            A;

321:   PCGetOperators(pc,&A,NULL);
322:   MatShellGetContext(A,(void**)&data);
323:   VecCompGetSubVecs(in,NULL,&inx);
324:   VecCompGetSubVecs(out,NULL,&outx);
325:   VecCompGetSubVecs(w,NULL,&wx);
326:   n = data->r_e - data->r_s;
327:   SlepcVecPoolGetVecs(data->d->auxV,n,&auxV);
328:   switch (side) {
329:   case PC_LEFT:
330:     /* aux <- theta[1]A*in - theta[0]*B*in */
331:     dvd_aux_matmult(data,inx,auxV);

333:     /* out <- K * aux */
334:     for (i=0;i<n;i++) {
335:       data->d->improvex_precond(data->d,data->r_s+i,auxV[i],outx[i]);
336:     }
337:     break;
338:   case PC_RIGHT:
339:     /* aux <- K * in */
340:     for (i=0;i<n;i++) {
341:       data->d->improvex_precond(data->d,data->r_s+i,inx[i],auxV[i]);
342:     }

344:     /* out <- theta[1]A*auxV - theta[0]*B*auxV */
345:     dvd_aux_matmult(data,auxV,outx);
346:     break;
347:   case PC_SYMMETRIC:
348:     /* aux <- K^{1/2} * in */
349:     for (i=0;i<n;i++) {
350:       PCApplySymmetricRight(data->old_pc,inx[i],auxV[i]);
351:     }

353:     /* wx <- theta[1]A*auxV - theta[0]*B*auxV */
354:     dvd_aux_matmult(data,auxV,wx);

356:     /* aux <- K^{1/2} * in */
357:     for (i=0;i<n;i++) {
358:       PCApplySymmetricLeft(data->old_pc,wx[i],outx[i]);
359:     }
360:     break;
361:   default:
362:     SETERRQ(PETSC_COMM_SELF,1,"Unsupported KSP side");
363:   }
364:   /* out <- out - v*(u'*out) */
365:   dvd_improvex_apply_proj(data->d,(Vec*)outx,n);
366:   SlepcVecPoolRestoreVecs(data->d->auxV,n,&auxV);
367:   return(0);
368: }

372: static PetscErrorCode PCApply_dvd(PC pc,Vec in,Vec out)
373: {
375:   dvdImprovex_jd *data;
376:   PetscInt       n,i;
377:   const Vec      *inx, *outx;
378:   Mat            A;

381:   PCGetOperators(pc,&A,NULL);
382:   MatShellGetContext(A,(void**)&data);
383:   VecCompGetSubVecs(in,NULL,&inx);
384:   VecCompGetSubVecs(out,NULL,&outx);
385:   n = data->r_e - data->r_s;
386:   /* out <- K * in */
387:   for (i=0;i<n;i++) {
388:     data->d->improvex_precond(data->d,data->r_s+i,inx[i],outx[i]);
389:   }
390:   /* out <- out - v*(u'*out) */
391:   dvd_improvex_apply_proj(data->d,(Vec*)outx,n);
392:   return(0);
393: }

397: static PetscErrorCode PCApplyTranspose_dvd(PC pc,Vec in,Vec out)
398: {
400:   dvdImprovex_jd *data;
401:   PetscInt       n,i;
402:   const Vec      *inx, *outx;
403:   Vec            *auxV;
404:   Mat            A;

407:   PCGetOperators(pc,&A,NULL);
408:   MatShellGetContext(A,(void**)&data);
409:   VecCompGetSubVecs(in,NULL,&inx);
410:   VecCompGetSubVecs(out,NULL,&outx);
411:   n = data->r_e - data->r_s;
412:   SlepcVecPoolGetVecs(data->d->auxV,n,&auxV);
413:   /* auxV <- in */
414:   for (i=0;i<n;i++) {
415:     VecCopy(inx[i],auxV[i]);
416:   }
417:   /* auxV <- auxV - u*(v'*auxV) */
418:   dvd_improvex_applytrans_proj(data->d,auxV,n);
419:   /* out <- K' * aux */
420:   for (i=0;i<n;i++) {
421:     PCApplyTranspose(data->old_pc,auxV[i],outx[i]);
422:   }
423:   SlepcVecPoolRestoreVecs(data->d->auxV,n,&auxV);
424:   return(0);
425: }

429: static PetscErrorCode MatMult_dvd_jd(Mat A,Vec in,Vec out)
430: {
432:   dvdImprovex_jd *data;
433:   PetscInt       n;
434:   const Vec      *inx, *outx;
435:   PCSide         side;

438:   MatShellGetContext(A,(void**)&data);
439:   VecCompGetSubVecs(in,NULL,&inx);
440:   VecCompGetSubVecs(out,NULL,&outx);
441:   n = data->r_e - data->r_s;
442:   /* out <- theta[1]A*in - theta[0]*B*in */
443:   dvd_aux_matmult(data,inx,outx);
444:   KSPGetPCSide(data->ksp,&side);
445:   if (side == PC_RIGHT) {
446:     /* out <- out - v*(u'*out) */
447:     dvd_improvex_apply_proj(data->d,(Vec*)outx,n);
448:   }
449:   return(0);
450: }

454: static PetscErrorCode MatMultTranspose_dvd_jd(Mat A,Vec in,Vec out)
455: {
457:   dvdImprovex_jd *data;
458:   PetscInt       n,i;
459:   const Vec      *inx,*outx,*r;
460:   Vec            *auxV;
461:   PCSide         side;

464:   MatShellGetContext(A,(void**)&data);
465:   VecCompGetSubVecs(in,NULL,&inx);
466:   VecCompGetSubVecs(out,NULL,&outx);
467:   n = data->r_e - data->r_s;
468:   KSPGetPCSide(data->ksp,&side);
469:   if (side == PC_RIGHT) {
470:     /* auxV <- in */
471:     SlepcVecPoolGetVecs(data->d->auxV,n,&auxV);
472:     for (i=0;i<n;i++) {
473:       VecCopy(inx[i],auxV[i]);
474:     }
475:     /* auxV <- auxV - v*(u'*auxV) */
476:     dvd_improvex_applytrans_proj(data->d,auxV,n);
477:     r = auxV;
478:   } else r = inx;
479:   /* out <- theta[1]A*r - theta[0]*B*r */
480:   dvd_aux_matmulttrans(data,r,outx);
481:   if (side == PC_RIGHT) {
482:     SlepcVecPoolRestoreVecs(data->d->auxV,n,&auxV);
483:   }
484:   return(0);
485: }

489: static PetscErrorCode MatCreateVecs_dvd_jd(Mat A,Vec *right,Vec *left)
490: {
492:   Vec            *r,*l;
493:   dvdImprovex_jd *data;
494:   PetscInt       n,i;

497:   MatShellGetContext(A,(void**)&data);
498:   n = data->ksp_max_size;
499:   if (right) {
500:     PetscMalloc1(n,&r);
501:   }
502:   if (left) {
503:     PetscMalloc1(n,&l);
504:   }
505:   for (i=0;i<n;i++) {
506:     MatCreateVecs(data->d->A,right?&r[i]:NULL,left?&l[i]:NULL);
507:   }
508:   if (right) {
509:     VecCreateCompWithVecs(r,n,data->friends,right);
510:     for (i=0;i<n;i++) {
511:       VecDestroy(&r[i]);
512:     }
513:   }
514:   if (left) {
515:     VecCreateCompWithVecs(l,n,data->friends,left);
516:     for (i=0;i<n;i++) {
517:       VecDestroy(&l[i]);
518:     }
519:   }

521:   if (right) {
522:     PetscFree(r);
523:   }
524:   if (left) {
525:     PetscFree(l);
526:   }
527:   return(0);
528: }

532: static PetscErrorCode dvd_improvex_jd_start(dvdDashboard *d)
533: {
535:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;
536:   PetscInt       rA, cA, rlA, clA;
537:   Mat            A;
538:   PetscBool      t;
539:   PC             pc;
540:   Vec            v0[2];

543:   data->size_cX = data->old_size_X = 0;
544:   data->lastTol = data->dynamic?0.5:0.0;

546:   /* Setup the ksp */
547:   if (data->ksp) {
548:     /* Create the reference vector */
549:     BVGetColumn(d->eps->V,0,&v0[0]);
550:     v0[1] = v0[0];
551:     VecCreateCompWithVecs(v0,data->ksp_max_size,NULL,&data->friends);
552:     BVRestoreColumn(d->eps->V,0,&v0[0]);
553:     PetscLogObjectParent((PetscObject)d->eps,(PetscObject)data->friends);

555:     /* Save the current pc and set a PCNONE */
556:     KSPGetPC(data->ksp, &data->old_pc);
557:     PetscObjectTypeCompare((PetscObject)data->old_pc,PCNONE,&t);
558:     data->lastTol = 0.5;
559:     if (t) data->old_pc = 0;
560:     else {
561:       PetscObjectReference((PetscObject)data->old_pc);
562:       PCCreate(PetscObjectComm((PetscObject)d->eps),&pc);
563:       PCSetType(pc,PCSHELL);
564:       PCSetOperators(pc,d->A,d->A);
565:       PCSetReusePreconditioner(pc,PETSC_TRUE);
566:       PCShellSetApply(pc,PCApply_dvd);
567:       PCShellSetApplyBA(pc,PCApplyBA_dvd);
568:       PCShellSetApplyTranspose(pc,PCApplyTranspose_dvd);
569:       KSPSetPC(data->ksp,pc);
570:       PCDestroy(&pc);
571:     }

573:     /* Create the (I-v*u')*K*(A-s*B) matrix */
574:     MatGetSize(d->A,&rA,&cA);
575:     MatGetLocalSize(d->A,&rlA,&clA);
576:     MatCreateShell(PetscObjectComm((PetscObject)d->A),rlA*data->ksp_max_size,clA*data->ksp_max_size,rA*data->ksp_max_size,cA*data->ksp_max_size,data,&A);
577:     MatShellSetOperation(A,MATOP_MULT,(void(*)(void))MatMult_dvd_jd);
578:     MatShellSetOperation(A,MATOP_MULT_TRANSPOSE,(void(*)(void))MatMultTranspose_dvd_jd);
579:     MatShellSetOperation(A,MATOP_GET_VECS,(void(*)(void))MatCreateVecs_dvd_jd);

581:     /* Try to avoid KSPReset */
582:     KSPGetOperatorsSet(data->ksp,&t,NULL);
583:     if (t) {
584:       Mat      M;
585:       PetscInt rM;
586:       KSPGetOperators(data->ksp,&M,NULL);
587:       MatGetSize(M,&rM,NULL);
588:       if (rM != rA*data->ksp_max_size) { KSPReset(data->ksp); }
589:     }
590:     KSPSetOperators(data->ksp,A,A);
591:     KSPSetReusePreconditioner(data->ksp,PETSC_TRUE);
592:     KSPSetUp(data->ksp);
593:     MatDestroy(&A);
594:   } else {
595:     data->old_pc = 0;
596:     data->friends = NULL;
597:   }
598:   BVSetActiveColumns(data->KZ,0,0);
599:   BVSetActiveColumns(data->U,0,0);
600:   return(0);
601: }

605: /*
606:   Compute: u <- X, v <- K*(theta[0]*A+theta[1]*B)*X,
607:   kr <- K^{-1}*(A-eig*B)*X, being X <- V*pX[i_s..i_e-1], Y <- W*pY[i_s..i_e-1]
608:   where
609:   pX,pY, the right and left eigenvectors of the projected system
610:   ld, the leading dimension of pX and pY
611: */
612: static PetscErrorCode dvd_improvex_jd_proj_cuv(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)
613: {
614: #if defined(PETSC_MISSING_LAPACK_GETRF)
616:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF - Lapack routine is unavailable");
617: #else
619:   PetscInt       n=i_e-i_s,size_KZ,V_new,rm,i,lv,kv,lKZ,kKZ;
620:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;
621:   PetscScalar    *array;
622:   Mat            M;
623:   Vec            u[2],v[2];
624:   PetscBLASInt   s,ldXKZ,info;

627:   /* Check consistency */
628:   BVGetActiveColumns(d->eps->V,&lv,&kv);
629:   V_new = lv - data->size_cX;
630:   if (V_new > data->old_size_X) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken");
631:   data->old_size_X = n;
632:   data->size_cX = lv;

634:   /* KZ <- KZ(rm:rm+max_cX-1) */
635:   BVGetActiveColumns(data->KZ,&lKZ,&kKZ);
636:   rm = PetscMax(V_new+lKZ-d->max_cX_in_impr,0);
637:   if (rm > 0) {
638:     for (i=0;i<lKZ;i++) {
639:       BVCopyColumn(data->KZ,i+rm,i);
640:       BVCopyColumn(data->U,i+rm,i);
641:     }
642:   }

644:   /* XKZ <- XKZ(rm:rm+max_cX-1,rm:rm+max_cX-1) */
645:   if (rm > 0) {
646:     for (i=0;i<lKZ;i++) {
647:       PetscMemcpy(&data->XKZ[i*data->ldXKZ+i],&data->XKZ[(i+rm)*data->ldXKZ+i+rm],sizeof(PetscScalar)*lKZ);
648:     }
649:   }
650:   lKZ = PetscMin(d->max_cX_in_impr,lKZ+V_new);
651:   BVSetActiveColumns(data->KZ,lKZ,lKZ+n);
652:   BVSetActiveColumns(data->U,lKZ,lKZ+n);

654:   /* Compute X, KZ and KR */
655:   BVGetColumn(data->U,lKZ,u);
656:   if (n>1) { BVGetColumn(data->U,lKZ+1,&u[1]); }
657:   BVGetColumn(data->KZ,lKZ,v);
658:   if (n>1) { BVGetColumn(data->KZ,lKZ+1,&v[1]); }
659:   d->improvex_jd_proj_uv(d,i_s,i_e,u,v,kr,theta,thetai,pX,pY,ld);
660:   BVRestoreColumn(data->U,lKZ,u);
661:   if (n>1) { BVRestoreColumn(data->U,lKZ+1,&u[1]); }
662:   BVRestoreColumn(data->KZ,lKZ,v);
663:   if (n>1) { BVRestoreColumn(data->KZ,lKZ+1,&v[1]); }

665:   /* XKZ <- U'*KZ */
666:   MatCreateSeqDense(PETSC_COMM_SELF,lKZ+n,lKZ+n,NULL,&M);
667:   BVMatProject(data->KZ,NULL,data->U,M);
668:   MatDenseGetArray(M,&array);
669:   for (i=lKZ;i<lKZ+n;i++) { /* upper part */
670:     PetscMemcpy(&data->XKZ[data->ldXKZ*i],&array[i*(lKZ+n)],lKZ*sizeof(PetscScalar));
671:   }
672:   for (i=0;i<lKZ+n;i++) { /* lower part */
673:     PetscMemcpy(&data->XKZ[data->ldXKZ*i+lKZ],&array[i*(lKZ+n)+lKZ],n*sizeof(PetscScalar));
674:   }
675:   MatDenseRestoreArray(M,&array);
676:   MatDestroy(&M);

678:   /* iXKZ <- inv(XKZ) */
679:   size_KZ = lKZ+n;
680:   PetscBLASIntCast(lKZ+n,&s);
681:   data->ldiXKZ = data->size_iXKZ = size_KZ;
682:   for (i=0;i<size_KZ;i++) {
683:     PetscMemcpy(&data->iXKZ[data->ldiXKZ*i],&data->XKZ[data->ldXKZ*i],sizeof(PetscScalar)*size_KZ);
684:   }
685:   PetscBLASIntCast(data->ldiXKZ,&ldXKZ);
686:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
687:   PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&s,&s,data->iXKZ,&ldXKZ,data->iXKZPivots,&info));
688:   PetscFPTrapPop();
689:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack XGETRF %d",info);
690:   return(0);
691: #endif
692: }

696: static PetscErrorCode dvd_improvex_jd_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D)
697: {
698:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;
700:   PetscInt       i,j,n,maxits,maxits0,lits,s,ld,k,max_size_D,lV,kV;
701:   PetscScalar    *pX,*pY;
702:   PetscReal      tol,tol0;
703:   Vec            *kr,kr_comp,D_comp,D[2],kr0[2];
704:   PetscBool      odd_situation = PETSC_FALSE;

707:   BVGetActiveColumns(d->eps->V,&lV,&kV);
708:   max_size_D = d->eps->ncv-kV;
709:   /* Quick exit */
710:   if ((max_size_D == 0) || r_e-r_s <= 0) {
711:    *size_D = 0;
712:     return(0);
713:   }

715:   n = PetscMin(PetscMin(data->size_X, max_size_D), r_e-r_s);
716:   if (n == 0) SETERRQ(PETSC_COMM_SELF,1,"n == 0");
717:   if (data->size_X < r_e-r_s) SETERRQ(PETSC_COMM_SELF,1,"size_X < r_e-r_s");

719:   DSGetLeadingDimension(d->eps->ds,&ld);

721:   /* Restart lastTol if a new pair converged */
722:   if (data->dynamic && data->size_cX < lV)
723:     data->lastTol = 0.5;

725:   for (i=0,s=0;i<n;i+=s) {
726:     /* If the selected eigenvalue is complex, but the arithmetic is real... */
727: #if !defined(PETSC_USE_COMPLEX)
728:     if (d->eigi[i] != 0.0) {
729:       if (i+2 <= max_size_D) s=2;
730:       else break;
731:     } else
732: #endif
733:       s=1;

735:     data->r_s = r_s+i;
736:     data->r_e = r_s+i+s;
737:     SlepcVecPoolGetVecs(d->auxV,s,&kr);

739:     /* Compute theta, maximum iterations and tolerance */
740:     maxits = 0;
741:     tol = 1;
742:     for (j=0;j<s;j++) {
743:       d->improvex_jd_lit(d,r_s+i+j,&data->theta[2*j],&data->thetai[j],&maxits0,&tol0);
744:       maxits += maxits0;
745:       tol *= tol0;
746:     }
747:     maxits/= s;
748:     tol = data->dynamic?data->lastTol:PetscExpReal(PetscLogReal(tol)/s);

750:     /* Compute u, v and kr */
751:     k = r_s+i;
752:     DSVectors(d->eps->ds,DS_MAT_X,&k,NULL);
753:     k = r_s+i;
754:     DSVectors(d->eps->ds,DS_MAT_Y,&k,NULL);
755:     DSGetArray(d->eps->ds,DS_MAT_X,&pX);
756:     DSGetArray(d->eps->ds,DS_MAT_Y,&pY);
757:     dvd_improvex_jd_proj_cuv(d,r_s+i,r_s+i+s,kr,data->theta,data->thetai,pX,pY,ld);
758:     DSRestoreArray(d->eps->ds,DS_MAT_X,&pX);
759:     DSRestoreArray(d->eps->ds,DS_MAT_Y,&pY);

761:     /* Check if the first eigenpairs are converged */
762:     if (i == 0) {
763:       d->preTestConv(d,0,s,s,&d->npreconv);
764:       if (d->npreconv > 0) break;
765:     }

767:     /* Test the odd situation of solving Ax=b with A=I */
768: #if !defined(PETSC_USE_COMPLEX)
769:     odd_situation = (data->ksp && data->theta[0] == 1. && data->theta[1] == 0. && data->thetai[0] == 0. && d->B == NULL)? PETSC_TRUE: PETSC_FALSE;
770: #else
771:     odd_situation = (data->ksp && data->theta[0] == 1. && data->theta[1] == 0. && d->B == NULL)? PETSC_TRUE: PETSC_FALSE;
772: #endif
773:     /* If JD */
774:     if (data->ksp && !odd_situation) {
775:       /* kr <- -kr */
776:       for (j=0;j<s;j++) {
777:         VecScale(kr[j],-1.0);
778:       }

780:       /* Compose kr and D */
781:       kr0[0] = kr[0];
782:       kr0[1] = (s==2 ? kr[1] : NULL);
783:       VecCreateCompWithVecs(kr0,data->ksp_max_size,data->friends,&kr_comp);
784:       BVGetColumn(d->eps->V,kV+r_s+i,&D[0]);
785:       if (s==2) { BVGetColumn(d->eps->V,kV+r_s+i+1,&D[1]); }
786:       else D[1] = NULL;
787:       VecCreateCompWithVecs(D,data->ksp_max_size,data->friends,&D_comp);
788:       VecCompSetSubVecs(data->friends,s,NULL);

790:       /* Solve the correction equation */
791:       KSPSetTolerances(data->ksp,tol,PETSC_DEFAULT,PETSC_DEFAULT,maxits);
792:       KSPSolve(data->ksp,kr_comp,D_comp);
793:       KSPGetIterationNumber(data->ksp,&lits);

795:       /* Destroy the composed ks and D */
796:       VecDestroy(&kr_comp);
797:       VecDestroy(&D_comp);
798:       BVRestoreColumn(d->eps->V,kV+r_s+i,&D[0]);
799:       if (s==2) { BVRestoreColumn(d->eps->V,kV+r_s+i+1,&D[1]); }

801:     /* If GD */
802:     } else {
803:       BVGetColumn(d->eps->V,kV+r_s+i,&D[0]);
804:       if (s==2) { BVGetColumn(d->eps->V,kV+r_s+i+1,&D[1]); }
805:       for (j=0;j<s;j++) {
806:         d->improvex_precond(d,r_s+i+j,kr[j],D[j]);
807:       }
808:       dvd_improvex_apply_proj(d,D,s);
809:       BVRestoreColumn(d->eps->V,kV+r_s+i,&D[0]);
810:       if (s==2) { BVRestoreColumn(d->eps->V,kV+r_s+i+1,&D[1]); }
811:     }
812:     /* Prevent that short vectors are discarded in the orthogonalization */
813:     if (i == 0 && d->eps->errest[d->nconv+r_s] > PETSC_MACHINE_EPSILON && d->eps->errest[d->nconv+r_s] < PETSC_MAX_REAL) {
814:       for (j=0;j<s;j++) {
815:         BVScaleColumn(d->eps->V,kV+r_s+i+j,1.0/d->eps->errest[d->nconv+r_s]);
816:       }
817:     }
818:     SlepcVecPoolRestoreVecs(d->auxV,s,&kr);
819:   }
820:   *size_D = i;
821:   if (data->dynamic) data->lastTol = PetscMax(data->lastTol/2.0,PETSC_MACHINE_EPSILON*10.0);
822:   return(0);
823: }

827: PetscErrorCode dvd_improvex_jd(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs,PetscInt cX_impr,PetscBool dynamic)
828: {
830:   dvdImprovex_jd *data;
831:   PetscBool      useGD;
832:   PC             pc;
833:   PetscInt       size_P;

836:   /* Setting configuration constrains */
837:   PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&useGD);

839:   /* If the arithmetic is real and the problem is not Hermitian, then
840:      the block size is incremented in one */
841: #if !defined(PETSC_USE_COMPLEX)
842:   if (!DVD_IS(d->sEP,DVD_EP_HERMITIAN)) {
843:     max_bs++;
844:     b->max_size_P = PetscMax(b->max_size_P,2);
845:   } else
846: #endif
847:   {
848:     b->max_size_P = PetscMax(b->max_size_P,1);
849:   }
850:   b->max_size_X = PetscMax(b->max_size_X,max_bs);
851:   size_P = b->max_size_P+cX_impr;

853:   /* Setup the preconditioner */
854:   if (ksp) {
855:     KSPGetPC(ksp,&pc);
856:     dvd_static_precond_PC(d,b,pc);
857:   } else {
858:     dvd_static_precond_PC(d,b,0);
859:   }

861:   /* Setup the step */
862:   if (b->state >= DVD_STATE_CONF) {
863:     PetscNewLog(d->eps,&data);
864:     data->dynamic = dynamic;
865:     d->max_cX_in_impr = cX_impr;
866:     PetscMalloc1(size_P*size_P,&data->XKZ);
867:     PetscMalloc1(size_P*size_P,&data->iXKZ);
868:     PetscMalloc1(size_P,&data->iXKZPivots);
869:     data->ldXKZ = size_P;
870:     data->size_X = b->max_size_X;
871:     d->improveX_data = data;
872:     data->ksp = useGD? NULL: ksp;
873:     data->d = d;
874:     d->improveX = dvd_improvex_jd_gen;
875: #if !defined(PETSC_USE_COMPLEX)
876:     if (!DVD_IS(d->sEP,DVD_EP_HERMITIAN)) data->ksp_max_size = 2;
877:     else
878: #endif
879:       data->ksp_max_size = 1;
880:     /* Create various vector basis */
881:     BVDuplicateResize(d->eps->V,size_P,&data->KZ);
882:     BVSetMatrix(data->KZ,NULL,PETSC_FALSE);
883:     BVDuplicate(data->KZ,&data->U);

885:     EPSDavidsonFLAdd(&d->startList,dvd_improvex_jd_start);
886:     EPSDavidsonFLAdd(&d->endList,dvd_improvex_jd_end);
887:     EPSDavidsonFLAdd(&d->destroyList,dvd_improvex_jd_d);
888:   }
889:   return(0);
890: }

892: #if !defined(PETSC_USE_COMPLEX)
895: PETSC_STATIC_INLINE PetscErrorCode dvd_complex_rayleigh_quotient(Vec ur,Vec ui,Vec Axr,Vec Axi,Vec Bxr,Vec Bxi,PetscScalar *eigr,PetscScalar *eigi)
896: { 
898:   PetscScalar    rAr,iAr,rAi,iAi,rBr,iBr,rBi,iBi,b0,b2,b4,b6,b7;

901:   /* eigr = [(rAr+iAi)*(rBr+iBi) + (rAi-iAr)*(rBi-iBr)]/k
902:      eigi = [(rAi-iAr)*(rBr+iBi) - (rAr+iAi)*(rBi-iBr)]/k
903:      k    =  (rBr+iBi)*(rBr+iBi) + (rBi-iBr)*(rBi-iBr)    */
904:   VecDotBegin(Axr,ur,&rAr); /* r*A*r */
905:   VecDotBegin(Axr,ui,&iAr); /* i*A*r */
906:   VecDotBegin(Axi,ur,&rAi); /* r*A*i */
907:   VecDotBegin(Axi,ui,&iAi); /* i*A*i */
908:   VecDotBegin(Bxr,ur,&rBr); /* r*B*r */
909:   VecDotBegin(Bxr,ui,&iBr); /* i*B*r */
910:   VecDotBegin(Bxi,ur,&rBi); /* r*B*i */
911:   VecDotBegin(Bxi,ui,&iBi); /* i*B*i */
912:   VecDotEnd(Axr,ur,&rAr); /* r*A*r */
913:   VecDotEnd(Axr,ui,&iAr); /* i*A*r */
914:   VecDotEnd(Axi,ur,&rAi); /* r*A*i */
915:   VecDotEnd(Axi,ui,&iAi); /* i*A*i */
916:   VecDotEnd(Bxr,ur,&rBr); /* r*B*r */
917:   VecDotEnd(Bxr,ui,&iBr); /* i*B*r */
918:   VecDotEnd(Bxi,ur,&rBi); /* r*B*i */
919:   VecDotEnd(Bxi,ui,&iBi); /* i*B*i */
920:   b0 = rAr+iAi; /* rAr+iAi */
921:   b2 = rAi-iAr; /* rAi-iAr */
922:   b4 = rBr+iBi; /* rBr+iBi */
923:   b6 = rBi-iBr; /* rBi-iBr */
924:   b7 = b4*b4 + b6*b6; /* k */
925:   *eigr = (b0*b4 + b2*b6) / b7; /* eig_r */
926:   *eigi = (b2*b4 - b0*b6) / b7; /* eig_i */
927:   return(0);
928: }
929: #endif

933: PETSC_STATIC_INLINE PetscErrorCode dvd_compute_n_rr(PetscInt i_s,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,Vec *u,Vec *Ax,Vec *Bx)
934: {
936:   PetscInt       i;
937:   PetscScalar    b0,b1;

940:   for (i=0; i<n; i++) {
941: #if !defined(PETSC_USE_COMPLEX)
942:     if (eigi[i_s+i] != 0.0) {
943:       PetscScalar eigr0=0.0,eigi0=0.0;
944:       dvd_complex_rayleigh_quotient(u[i],u[i+1],Ax[i],Ax[i+1],Bx[i],Bx[i+1],&eigr0,&eigi0);
945:       if (PetscAbsScalar(eigr[i_s+i]-eigr0)/PetscAbsScalar(eigr[i_s+i]) > 1e-10 || PetscAbsScalar(eigi[i_s+i]-eigi0)/PetscAbsScalar(eigi[i_s+i]) > 1e-10) {
946:         PetscInfo4(u[0],"The eigenvalue %g%+gi is far from its Rayleigh quotient value %g%+gi\n",(double)eigr[i_s+i],(double)eigi[i_s+i],(double)eigr0,(double)eigi0);
947:       }
948:       i++;
949:     } else
950: #endif
951:     {
952:       VecDotBegin(Ax[i],u[i],&b0);
953:       VecDotBegin(Bx[i],u[i],&b1);
954:       VecDotEnd(Ax[i],u[i],&b0);
955:       VecDotEnd(Bx[i],u[i],&b1);
956:       b0 = b0/b1;
957:       if (PetscAbsScalar(eigr[i_s+i]-b0)/PetscAbsScalar(eigr[i_s+i]) > 1e-10) {
958:         PetscInfo4(u[0],"The eigenvalue %g+%g is far from its Rayleigh quotient value %g+%g\n",(double)PetscRealPart(eigr[i_s+i]),(double)PetscImaginaryPart(eigr[i_s+i]),(double)PetscRealPart(b0),(double)PetscImaginaryPart(b0));
959:       }
960:     }
961:   }
962:   return(0);
963: }

967: /*
968:   Compute: u <- X, v <- K*(theta[0]*A+theta[1]*B)*X,
969:   kr <- K^{-1}*(A-eig*B)*X, being X <- V*pX[i_s..i_e-1], Y <- W*pY[i_s..i_e-1]
970:   where
971:   pX,pY, the right and left eigenvectors of the projected system
972:   ld, the leading dimension of pX and pY
973: */
974: static PetscErrorCode dvd_improvex_jd_proj_uv_KZX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)
975: {
977:   PetscInt       n = i_e-i_s,i;
978:   PetscScalar    *b;
979:   Vec            *Ax,*Bx,*r;
980:   Mat            M;
981:   BV             X;

984:   BVDuplicateResize(d->eps->V,4,&X);
985:   MatCreateSeqDense(PETSC_COMM_SELF,4,4,NULL,&M);
986:   /* u <- X(i) */
987:   dvd_improvex_compute_X(d,i_s,i_e,u,pX,ld);

989:   /* v <- theta[0]A*u + theta[1]*B*u */

991:   /* Bx <- B*X(i) */
992:   Bx = kr;
993:   if (d->BX) {
994:     for (i=i_s; i<i_e; ++i) {
995:       BVMultVec(d->BX,1.0,0.0,Bx[i-i_s],&pX[ld*i]);
996:     }
997:   } else {
998:     for (i=0;i<n;i++) {
999:       if (d->B) {
1000:         MatMult(d->B, u[i], Bx[i]);
1001:       } else {
1002:         VecCopy(u[i], Bx[i]);
1003:       }
1004:     }
1005:   }

1007:   /* Ax <- A*X(i) */
1008:   SlepcVecPoolGetVecs(d->auxV,i_e-i_s,&r);
1009:   Ax = r;
1010:   for (i=i_s; i<i_e; ++i) {
1011:     BVMultVec(d->AX,1.0,0.0,Ax[i-i_s],&pX[ld*i]);
1012:   }

1014:   /* v <- Y(i) */
1015:   for (i=i_s; i<i_e; ++i) {
1016:     BVMultVec(d->W?d->W:d->eps->V,1.0,0.0,v[i-i_s],&pY[ld*i]);
1017:   }

1019:   /* Recompute the eigenvalue */
1020:   dvd_compute_n_rr(i_s,n,d->eigr,d->eigi,v,Ax,Bx);

1022:   for (i=0;i<n;i++) {
1023: #if !defined(PETSC_USE_COMPLEX)
1024:     if (d->eigi[i_s+i] != 0.0) {
1025:       /* [r_i r_i+1 kr_i kr_i+1]*= [ theta_2i'    0            1        0
1026:                                        0         theta_2i'     0        1
1027:                                      theta_2i+1 -thetai_i   -eigr_i -eigi_i
1028:                                      thetai_i    theta_2i+1  eigi_i -eigr_i ] */
1029:       MatDenseGetArray(M,&b);
1030:       b[0] = b[5] = PetscConj(theta[2*i]);
1031:       b[2] = b[7] = -theta[2*i+1];
1032:       b[6] = -(b[3] = thetai[i]);
1033:       b[1] = b[4] = 0.0;
1034:       b[8] = b[13] = 1.0/d->nX[i_s+i];
1035:       b[10] = b[15] = -d->eigr[i_s+i]/d->nX[i_s+i];
1036:       b[14] = -(b[11] = d->eigi[i_s+i]/d->nX[i_s+i]);
1037:       b[9] = b[12] = 0.0;
1038:       MatDenseRestoreArray(M,&b);
1039:       BVInsertVec(X,0,Ax[i]);
1040:       BVInsertVec(X,1,Ax[i+1]);
1041:       BVInsertVec(X,2,Bx[i]);
1042:       BVInsertVec(X,3,Bx[i+1]);
1043:       BVSetActiveColumns(X,0,4);
1044:       BVMultInPlace(X,M,0,4);
1045:       BVCopyVec(X,0,Ax[i]);
1046:       BVCopyVec(X,1,Ax[i+1]);
1047:       BVCopyVec(X,2,Bx[i]);
1048:       BVCopyVec(X,3,Bx[i+1]);
1049:       i++;
1050:     } else
1051: #endif
1052:     {
1053:       /* [Ax_i Bx_i]*= [ theta_2i'    1/nX_i
1054:                         theta_2i+1  -eig_i/nX_i ] */
1055:       MatDenseGetArray(M,&b);
1056:       b[0] = PetscConj(theta[i*2]);
1057:       b[1] = theta[i*2+1];
1058:       b[4] = 1.0/d->nX[i_s+i];
1059:       b[5] = -d->eigr[i_s+i]/d->nX[i_s+i];
1060:       MatDenseRestoreArray(M,&b);
1061:       BVInsertVec(X,0,Ax[i]);
1062:       BVInsertVec(X,1,Bx[i]);
1063:       BVSetActiveColumns(X,0,2);
1064:       BVMultInPlace(X,M,0,2);
1065:       BVCopyVec(X,0,Ax[i]);
1066:       BVCopyVec(X,1,Bx[i]);
1067:     }
1068:   }
1069:   for (i=0; i<n; i++) d->nX[i_s+i] = 1.0;

1071:   /* v <- K^{-1} r = K^{-1}(theta_2i'*Ax + theta_2i+1*Bx) */
1072:   for (i=0;i<n;i++) {
1073:     d->improvex_precond(d,i_s+i,r[i],v[i]);
1074:   }
1075:   SlepcVecPoolRestoreVecs(d->auxV,i_e-i_s,&r);

1077:   /* kr <- P*(Ax - eig_i*Bx) */
1078:   d->calcpairs_proj_res(d,i_s,i_e,kr);
1079:   BVDestroy(&X);
1080:   MatDestroy(&M);
1081:   return(0);
1082: }

1086: /*
1087:   Compute: u <- K^{-1}*X, v <- X,
1088:   kr <- K^{-1}*(A-eig*B)*X, being X <- V*pX[i_s..i_e-1]
1089:   where
1090:   pX,pY, the right and left eigenvectors of the projected system
1091:   ld, the leading dimension of pX and pY
1092: */
1093: static PetscErrorCode dvd_improvex_jd_proj_uv_KXX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)
1094: {
1096:   PetscInt       n = i_e - i_s,i;
1097:   PetscScalar    *b;
1098:   Vec            *Ax,*Bx,*r;
1099:   Mat            M;
1100:   BV             X;

1103:   BVDuplicateResize(d->eps->V,4,&X);
1104:   MatCreateSeqDense(PETSC_COMM_SELF,4,2,NULL,&M);
1105:   /* [v u] <- X(i) Y(i) */
1106:   dvd_improvex_compute_X(d,i_s,i_e,v,pX,ld);
1107:   for (i=i_s; i<i_e; ++i) {
1108:     BVMultVec(d->W?d->W:d->eps->V,1.0,0.0,u[i-i_s],&pY[ld*i]);
1109:   }

1111:   /* Bx <- B*X(i) */
1112:   SlepcVecPoolGetVecs(d->auxV,i_e-i_s,&r);
1113:   Bx = r;
1114:   if (d->BX) {
1115:     for (i=i_s; i<i_e; ++i) {
1116:       BVMultVec(d->BX,1.0,0.0,Bx[i-i_s],&pX[ld*i]);
1117:     }
1118:   } else {
1119:     if (d->B) {
1120:       for (i=0;i<n;i++) {
1121:         MatMult(d->B,v[i],Bx[i]);
1122:       }
1123:     } else Bx = v;
1124:   }

1126:   /* Ax <- A*X(i) */
1127:   Ax = kr;
1128:   for (i=i_s; i<i_e; ++i) {
1129:     BVMultVec(d->AX,1.0,0.0,Ax[i-i_s],&pX[ld*i]);
1130:   }

1132:   /* Recompute the eigenvalue */
1133:   dvd_compute_n_rr(i_s,n,d->eigr,d->eigi,u,Ax,Bx);

1135:   for (i=0;i<n;i++) {
1136:     if (d->eigi[i_s+i] == 0.0) {
1137:       /* kr <- Ax -eig*Bx */
1138:       VecAXPBY(kr[i],-d->eigr[i_s+i]/d->nX[i_s+i],1.0/d->nX[i_s+i],Bx[i]);
1139:     } else {
1140:       /* [kr_i kr_i+1 r_i r_i+1]*= [   1        0
1141:                                        0        1
1142:                                     -eigr_i -eigi_i
1143:                                      eigi_i -eigr_i] */
1144:       MatDenseGetArray(M,&b);
1145:       b[0] = b[5] = 1.0/d->nX[i_s+i];
1146:       b[2] = b[7] = -d->eigr[i_s+i]/d->nX[i_s+i];
1147:       b[6] = -(b[3] = d->eigi[i_s+i]/d->nX[i_s+i]);
1148:       b[1] = b[4] = 0.0;
1149:       MatDenseRestoreArray(M,&b);
1150:       BVInsertVec(X,0,kr[i]);
1151:       BVInsertVec(X,1,kr[i+1]);
1152:       BVInsertVec(X,2,r[i]);
1153:       BVInsertVec(X,3,r[i+1]);
1154:       BVSetActiveColumns(X,0,4);
1155:       BVMultInPlace(X,M,0,2);
1156:       BVCopyVec(X,0,kr[i]);
1157:       BVCopyVec(X,1,kr[i+1]);
1158:       i++;
1159:     }
1160:   }
1161:   for (i=0; i<n; i++) d->nX[i_s+i] = 1.0;

1163:   /* kr <- P*kr */
1164:   d->calcpairs_proj_res(d,i_s,i_e,r);
1165:   SlepcVecPoolRestoreVecs(d->auxV,i_e-i_s,&r);

1167:   /* u <- K^{-1} X(i) */
1168:   for (i=0;i<n;i++) {
1169:     d->improvex_precond(d,i_s+i,v[i],u[i]);
1170:   }
1171:   return(0);
1172: }

1176: static PetscErrorCode dvd_improvex_jd_lit_const_0(dvdDashboard *d,PetscInt i,PetscScalar* theta,PetscScalar* thetai,PetscInt *maxits,PetscReal *tol)
1177: {
1178:   dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data;
1179:   PetscReal      a;

1182:   a = SlepcAbsEigenvalue(d->eigr[i],d->eigi[i]);

1184:   if (d->nR[i]/a < data->fix) {
1185:     theta[0] = d->eigr[i];
1186:     theta[1] = 1.0;
1187: #if !defined(PETSC_USE_COMPLEX)
1188:     *thetai = d->eigi[i];
1189: #endif
1190:   } else {
1191:     theta[0] = d->target[0];
1192:     theta[1] = d->target[1];
1193: #if !defined(PETSC_USE_COMPLEX)
1194:     *thetai = 0.0;
1195: #endif
1196: }

1198: #if defined(PETSC_USE_COMPLEX)
1199:   if (thetai) *thetai = 0.0;
1200: #endif
1201:   *maxits = data->maxits;
1202:   *tol = data->tol;
1203:   return(0);
1204: }

1208: PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard *d,dvdBlackboard *b,PetscInt maxits,PetscReal tol,PetscReal fix)
1209: {
1210:   dvdImprovex_jd  *data = (dvdImprovex_jd*)d->improveX_data;

1213:   /* Setup the step */
1214:   if (b->state >= DVD_STATE_CONF) {
1215:     data->maxits = maxits;
1216:     data->tol = tol;
1217:     data->fix = fix;
1218:     d->improvex_jd_lit = dvd_improvex_jd_lit_const_0;
1219:   }
1220:   return(0);
1221: }

1225: PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard *d,dvdBlackboard *b,ProjType_t p)
1226: {
1228:   /* Setup the step */
1229:   if (b->state >= DVD_STATE_CONF) {
1230:     switch (p) {
1231:     case DVD_PROJ_KXX:
1232:       d->improvex_jd_proj_uv = dvd_improvex_jd_proj_uv_KXX;
1233:       break;
1234:     case DVD_PROJ_KZX:
1235:       d->improvex_jd_proj_uv = dvd_improvex_jd_proj_uv_KZX;
1236:       break;
1237:     }
1238:   }
1239:   return(0);
1240: }

1244: PetscErrorCode dvd_improvex_compute_X(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u_,PetscScalar *pX,PetscInt ld)
1245: {
1247:   PetscInt       n = i_e - i_s,i;
1248:   Vec            *u;

1251:   if (u_) u = u_;
1252:   else if (d->correctXnorm) {
1253:     SlepcVecPoolGetVecs(d->auxV,i_e-i_s,&u);
1254:   }
1255:   if (u_ || d->correctXnorm) {
1256:     for (i=0; i<n; i++) {
1257:       BVMultVec(d->eps->V,1.0,0.0,u[i],&pX[ld*(i+i_s)]);
1258:     }
1259:   }
1260:   /* nX(i) <- ||X(i)|| */
1261:   if (d->correctXnorm) {
1262:     for (i=0; i<n; i++) {
1263:       VecNormBegin(u[i],NORM_2,&d->nX[i_s+i]);
1264:     }
1265:     for (i=0; i<n; i++) {
1266:       VecNormEnd(u[i],NORM_2,&d->nX[i_s+i]);
1267:     }
1268: #if !defined(PETSC_USE_COMPLEX)
1269:     for (i=0;i<n;i++) {
1270:       if (d->eigi[i_s+i] != 0.0) {
1271:         d->nX[i_s+i] = d->nX[i_s+i+1] = PetscSqrtScalar(d->nX[i_s+i]*d->nX[i_s+i]+d->nX[i_s+i+1]*d->nX[i_s+i+1]);
1272:         i++;
1273:       }
1274:     }
1275: #endif
1276:   } else {
1277:     for (i=0;i<n;i++) d->nX[i_s+i] = 1.0;
1278:   }
1279:   if (d->correctXnorm && !u_) {
1280:     SlepcVecPoolRestoreVecs(d->auxV,i_e-i_s,&u);
1281:   }
1282:   return(0);
1283: }

slepc-3.7.4/src/eps/impls/davidson/dvdschm.c.html0000644000175000017500000001771013107004621021241 0ustar jromanjroman
Actual source code: dvdschm.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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:  #include davidson.h

 24: #define DVD_CHECKSUM(b) ((b)->max_size_V + (b)->max_size_oldX)

 28: PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,KSP ksp,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool doubleexp)
 29: {
 31:   PetscInt       check_sum0,check_sum1;

 34:   PetscMemzero(b,sizeof(dvdBlackboard));
 35:   b->state = DVD_STATE_PRECONF;

 37:   for (check_sum0=-1,check_sum1=DVD_CHECKSUM(b); check_sum0 != check_sum1; check_sum0 = check_sum1, check_sum1 = DVD_CHECKSUM(b)) {

 39:     /* Setup basic management of V */
 40:     dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);

 42:     /* Setup the initial subspace for V */
 43:     dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);

 45:     /* Setup the convergence in order to use the SLEPc convergence test */
 46:     dvd_testconv_slepc(d,b);

 48:     /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
 49:     dvd_calcpairs_qz(d,b,orth,cX_proj,PetscNot(harmMode==DVD_HARM_NONE));
 50:     if (harmMode != DVD_HARM_NONE) {
 51:       dvd_harm_conf(d,b,harmMode,PETSC_FALSE,0.0);
 52:     }

 54:     /* Setup the method for improving the eigenvectors */
 55:     if (doubleexp) {
 56:       dvd_improvex_gd2(d,b,ksp,bs);
 57:     } else {
 58:       dvd_improvex_jd(d,b,ksp,bs,cX_impr,PETSC_FALSE);
 59:       dvd_improvex_jd_proj_uv(d,b,DVD_PROJ_KZX);
 60:       dvd_improvex_jd_lit_const(d,b,0,0.0,0.0);
 61:     }
 62:   }
 63:   return(0);
 64: }

 68: PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,PetscBool fixedTarget,PetscScalar t,KSP ksp,PetscReal fix,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool dynamic,PetscBool doubleexp)
 69: {
 70:   PetscInt       check_sum0,check_sum1,maxits;
 71:   PetscReal      tol;

 75:   b->state = DVD_STATE_CONF;
 76:   check_sum0 = DVD_CHECKSUM(b);

 78:   /* Setup basic management of V */
 79:   dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);

 81:   /* Setup the initial subspace for V */
 82:   dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);

 84:   /* Setup the convergence in order to use the SLEPc convergence test */
 85:   dvd_testconv_slepc(d,b);

 87:   /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
 88:   dvd_calcpairs_qz(d,b,orth,cX_proj,PetscNot(harmMode==DVD_HARM_NONE));
 89:   if (harmMode != DVD_HARM_NONE) {
 90:     dvd_harm_conf(d,b,harmMode,fixedTarget,t);
 91:   }

 93:   /* Setup the method for improving the eigenvectors */
 94:   if (doubleexp) {
 95:     dvd_improvex_gd2(d,b,ksp,bs);
 96:   } else {
 97:     dvd_improvex_jd(d,b,ksp,bs,cX_impr,dynamic);
 98:     dvd_improvex_jd_proj_uv(d,b,DVD_PROJ_KZX);
 99:     KSPGetTolerances(ksp,&tol,NULL,NULL,&maxits);
100:     dvd_improvex_jd_lit_const(d,b,maxits,tol,fix);
101:   }

103:   check_sum1 = DVD_CHECKSUM(b);
104:   if (check_sum0 != check_sum1) SETERRQ(PETSC_COMM_SELF,1, "Something awful happened");
105:   return(0);
106: }
slepc-3.7.4/src/eps/impls/davidson/dvdimprovex.c0000644000175000017500000013107513107004621021216 0ustar jromanjroman/* SLEPc eigensolver: "davidson" Step: improve the eigenvectors X - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" #include /**** JD update step (I - Kfg'/(g'Kf)) K(A - sB) (I - Kfg'/(g'Kf)) t = (I - Kfg'/(g'Kf))r ****/ typedef struct { PetscInt size_X; KSP ksp; /* correction equation solver */ Vec friends; /* reference vector for composite vectors */ PetscScalar theta[4],thetai[2]; /* the shifts used in the correction eq. */ PetscInt maxits; /* maximum number of iterations */ PetscInt r_s,r_e; /* the selected eigenpairs to improve */ PetscInt ksp_max_size; /* the ksp maximum subvectors size */ PetscReal tol; /* the maximum solution tolerance */ PetscReal lastTol; /* last tol for dynamic stopping criterion */ PetscReal fix; /* tolerance for using the approx. eigenvalue */ PetscBool dynamic; /* if the dynamic stopping criterion is applied */ dvdDashboard *d; /* the currect dvdDashboard reference */ PC old_pc; /* old pc in ksp */ BV KZ; /* KZ vecs for the projector KZ*inv(X'*KZ)*X' */ BV U; /* new X vectors */ PetscScalar *XKZ; /* X'*KZ */ PetscScalar *iXKZ; /* inverse of XKZ */ PetscInt ldXKZ; /* leading dimension of XKZ */ PetscInt size_iXKZ; /* size of iXKZ */ PetscInt ldiXKZ; /* leading dimension of iXKZ */ PetscInt size_cX; /* last value of d->size_cX */ PetscInt old_size_X; /* last number of improved vectors */ PetscBLASInt *iXKZPivots; /* array of pivots */ } dvdImprovex_jd; #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_apply_proj" /* Compute (I - KZ*iXKZ*X')*V where, V, the vectors to apply the projector, cV, the number of vectors in V, */ static PetscErrorCode dvd_improvex_apply_proj(dvdDashboard *d,Vec *V,PetscInt cV) { #if defined(PETSC_MISSING_LAPACK_GETRS) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routines are unavailable"); #else PetscErrorCode ierr; dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscInt i,ldh,k,l; PetscScalar *h; PetscBLASInt cV_,n,info,ld; #if defined(PETSC_USE_COMPLEX) PetscInt j; #endif PetscFunctionBegin; if (cV > 2) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken"); /* h <- X'*V */ ierr = PetscMalloc1(data->size_iXKZ*cV,&h);CHKERRQ(ierr); ldh = data->size_iXKZ; ierr = BVGetActiveColumns(data->U,&l,&k);CHKERRQ(ierr); if (ldh!=k) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken"); ierr = BVSetActiveColumns(data->U,0,k);CHKERRQ(ierr); for (i=0;iU,V[i],&h[ldh*i]);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) for (j=0; jU,l,k);CHKERRQ(ierr); /* h <- iXKZ\h */ ierr = PetscBLASIntCast(cV,&cV_);CHKERRQ(ierr); ierr = PetscBLASIntCast(data->size_iXKZ,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(data->ldiXKZ,&ld);CHKERRQ(ierr); PetscValidScalarPointer(data->iXKZ,0); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("N",&n,&cV_,data->iXKZ,&ld,data->iXKZPivots,h,&n,&info)); ierr = PetscFPTrapPop();CHKERRQ(ierr); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack XGETRS %d",info); /* V <- V - KZ*h */ ierr = BVSetActiveColumns(data->KZ,0,k);CHKERRQ(ierr); for (i=0;iKZ,-1.0,1.0,V[i],&h[ldh*i]);CHKERRQ(ierr); } ierr = BVSetActiveColumns(data->KZ,l,k);CHKERRQ(ierr); ierr = PetscFree(h);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_applytrans_proj" /* Compute (I - X*iXKZ*KZ')*V where, V, the vectors to apply the projector, cV, the number of vectors in V, */ static PetscErrorCode dvd_improvex_applytrans_proj(dvdDashboard *d,Vec *V,PetscInt cV) { #if defined(PETSC_MISSING_LAPACK_GETRS) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routines are unavailable"); PetscFunctionReturn(0); #else PetscErrorCode ierr; dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscInt i,ldh,k,l; PetscScalar *h; PetscBLASInt cV_, n, info, ld; #if defined(PETSC_USE_COMPLEX) PetscInt j; #endif PetscFunctionBegin; if (cV > 2) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken"); /* h <- KZ'*V */ ierr = PetscMalloc1(data->size_iXKZ*cV,&h);CHKERRQ(ierr); ldh = data->size_iXKZ; ierr = BVGetActiveColumns(data->U,&l,&k);CHKERRQ(ierr); if (ldh!=k) SETERRQ(PETSC_COMM_SELF,1,"Consistency broken"); ierr = BVSetActiveColumns(data->KZ,0,k);CHKERRQ(ierr); for (i=0;iKZ,V[i],&h[ldh*i]);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) for (j=0;jKZ,l,k);CHKERRQ(ierr); /* h <- iXKZ\h */ ierr = PetscBLASIntCast(cV,&cV_);CHKERRQ(ierr); ierr = PetscBLASIntCast(data->size_iXKZ,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(data->ldiXKZ,&ld);CHKERRQ(ierr); PetscValidScalarPointer(data->iXKZ,0); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("C",&n,&cV_,data->iXKZ,&ld,data->iXKZPivots,h,&n,&info)); ierr = PetscFPTrapPop();CHKERRQ(ierr); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack XGETRS %d",info); /* V <- V - U*h */ ierr = BVSetActiveColumns(data->U,0,k);CHKERRQ(ierr); for (i=0;iU,-1.0,1.0,V[i],&h[ldh*i]);CHKERRQ(ierr); } ierr = BVSetActiveColumns(data->U,l,k);CHKERRQ(ierr); ierr = PetscFree(h);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_end" static PetscErrorCode dvd_improvex_jd_end(dvdDashboard *d) { PetscErrorCode ierr; dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscFunctionBegin; if (data->friends) { ierr = VecDestroy(&data->friends);CHKERRQ(ierr); } /* Restore the pc of ksp */ if (data->old_pc) { ierr = KSPSetPC(data->ksp, data->old_pc);CHKERRQ(ierr); ierr = PCDestroy(&data->old_pc);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_d" static PetscErrorCode dvd_improvex_jd_d(dvdDashboard *d) { PetscErrorCode ierr; dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscFunctionBegin; /* Free local data and objects */ ierr = PetscFree(data->XKZ);CHKERRQ(ierr); ierr = PetscFree(data->iXKZ);CHKERRQ(ierr); ierr = PetscFree(data->iXKZPivots);CHKERRQ(ierr); ierr = BVDestroy(&data->KZ);CHKERRQ(ierr); ierr = BVDestroy(&data->U);CHKERRQ(ierr); ierr = PetscFree(data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_aux_matmult" /* y <- theta[1]A*x - theta[0]*B*x auxV, two auxiliary vectors */ PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmult(dvdImprovex_jd *data,const Vec *x,const Vec *y) { PetscErrorCode ierr; PetscInt n,i; const Vec *Bx; Vec *auxV; PetscFunctionBegin; n = data->r_e - data->r_s; for (i=0;id->A,x[i],y[i]);CHKERRQ(ierr); } ierr = SlepcVecPoolGetVecs(data->d->auxV,2,&auxV);CHKERRQ(ierr); for (i=0;id->eigi[data->r_s+i] != 0.0) { if (data->d->B) { ierr = MatMult(data->d->B,x[i],auxV[0]);CHKERRQ(ierr); ierr = MatMult(data->d->B,x[i+1],auxV[1]);CHKERRQ(ierr); Bx = auxV; } else Bx = &x[i]; /* y_i <- [ t_2i+1*A*x_i - t_2i*Bx_i + ti_i*Bx_i+1; y_i+1 t_2i+1*A*x_i+1 - ti_i*Bx_i - t_2i*Bx_i+1 ] */ ierr = VecAXPBYPCZ(y[i],-data->theta[2*i],data->thetai[i],data->theta[2*i+1],Bx[0],Bx[1]);CHKERRQ(ierr); ierr = VecAXPBYPCZ(y[i+1],-data->thetai[i],-data->theta[2*i],data->theta[2*i+1],Bx[0],Bx[1]);CHKERRQ(ierr); i++; } else #endif { if (data->d->B) { ierr = MatMult(data->d->B,x[i],auxV[0]);CHKERRQ(ierr); Bx = auxV; } else Bx = &x[i]; ierr = VecAXPBY(y[i],-data->theta[i*2],data->theta[i*2+1],Bx[0]);CHKERRQ(ierr); } } ierr = SlepcVecPoolRestoreVecs(data->d->auxV,2,&auxV);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_aux_matmulttrans" /* y <- theta[1]'*A'*x - theta[0]'*B'*x */ PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmulttrans(dvdImprovex_jd *data,const Vec *x,const Vec *y) { PetscErrorCode ierr; PetscInt n,i; const Vec *Bx; Vec *auxV; PetscFunctionBegin; n = data->r_e - data->r_s; for (i=0;id->A,x[i],y[i]);CHKERRQ(ierr); } ierr = SlepcVecPoolGetVecs(data->d->auxV,2,&auxV);CHKERRQ(ierr); for (i=0;id->eigi[data->r_s+i] != 0.0) { if (data->d->B) { ierr = MatMultTranspose(data->d->B,x[i],auxV[0]);CHKERRQ(ierr); ierr = MatMultTranspose(data->d->B,x[i+1],auxV[1]);CHKERRQ(ierr); Bx = auxV; } else Bx = &x[i]; /* y_i <- [ t_2i+1*A*x_i - t_2i*Bx_i - ti_i*Bx_i+1; y_i+1 t_2i+1*A*x_i+1 + ti_i*Bx_i - t_2i*Bx_i+1 ] */ ierr = VecAXPBYPCZ(y[i],-data->theta[2*i],-data->thetai[i],data->theta[2*i+1],Bx[0],Bx[1]);CHKERRQ(ierr); ierr = VecAXPBYPCZ(y[i+1],data->thetai[i],-data->theta[2*i],data->theta[2*i+1],Bx[0],Bx[1]);CHKERRQ(ierr); i++; } else #endif { if (data->d->B) { ierr = MatMultTranspose(data->d->B,x[i],auxV[0]);CHKERRQ(ierr); Bx = auxV; } else Bx = &x[i]; ierr = VecAXPBY(y[i],PetscConj(-data->theta[i*2]),PetscConj(data->theta[i*2+1]),Bx[0]);CHKERRQ(ierr); } } ierr = SlepcVecPoolRestoreVecs(data->d->auxV,2,&auxV);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCApplyBA_dvd" static PetscErrorCode PCApplyBA_dvd(PC pc,PCSide side,Vec in,Vec out,Vec w) { PetscErrorCode ierr; dvdImprovex_jd *data; PetscInt n,i; const Vec *inx,*outx,*wx; Vec *auxV; Mat A; PetscFunctionBegin; ierr = PCGetOperators(pc,&A,NULL);CHKERRQ(ierr); ierr = MatShellGetContext(A,(void**)&data);CHKERRQ(ierr); ierr = VecCompGetSubVecs(in,NULL,&inx);CHKERRQ(ierr); ierr = VecCompGetSubVecs(out,NULL,&outx);CHKERRQ(ierr); ierr = VecCompGetSubVecs(w,NULL,&wx);CHKERRQ(ierr); n = data->r_e - data->r_s; ierr = SlepcVecPoolGetVecs(data->d->auxV,n,&auxV);CHKERRQ(ierr); switch (side) { case PC_LEFT: /* aux <- theta[1]A*in - theta[0]*B*in */ ierr = dvd_aux_matmult(data,inx,auxV);CHKERRQ(ierr); /* out <- K * aux */ for (i=0;id->improvex_precond(data->d,data->r_s+i,auxV[i],outx[i]);CHKERRQ(ierr); } break; case PC_RIGHT: /* aux <- K * in */ for (i=0;id->improvex_precond(data->d,data->r_s+i,inx[i],auxV[i]);CHKERRQ(ierr); } /* out <- theta[1]A*auxV - theta[0]*B*auxV */ ierr = dvd_aux_matmult(data,auxV,outx);CHKERRQ(ierr); break; case PC_SYMMETRIC: /* aux <- K^{1/2} * in */ for (i=0;iold_pc,inx[i],auxV[i]);CHKERRQ(ierr); } /* wx <- theta[1]A*auxV - theta[0]*B*auxV */ ierr = dvd_aux_matmult(data,auxV,wx);CHKERRQ(ierr); /* aux <- K^{1/2} * in */ for (i=0;iold_pc,wx[i],outx[i]);CHKERRQ(ierr); } break; default: SETERRQ(PETSC_COMM_SELF,1,"Unsupported KSP side"); } /* out <- out - v*(u'*out) */ ierr = dvd_improvex_apply_proj(data->d,(Vec*)outx,n);CHKERRQ(ierr); ierr = SlepcVecPoolRestoreVecs(data->d->auxV,n,&auxV);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCApply_dvd" static PetscErrorCode PCApply_dvd(PC pc,Vec in,Vec out) { PetscErrorCode ierr; dvdImprovex_jd *data; PetscInt n,i; const Vec *inx, *outx; Mat A; PetscFunctionBegin; ierr = PCGetOperators(pc,&A,NULL);CHKERRQ(ierr); ierr = MatShellGetContext(A,(void**)&data);CHKERRQ(ierr); ierr = VecCompGetSubVecs(in,NULL,&inx);CHKERRQ(ierr); ierr = VecCompGetSubVecs(out,NULL,&outx);CHKERRQ(ierr); n = data->r_e - data->r_s; /* out <- K * in */ for (i=0;id->improvex_precond(data->d,data->r_s+i,inx[i],outx[i]);CHKERRQ(ierr); } /* out <- out - v*(u'*out) */ ierr = dvd_improvex_apply_proj(data->d,(Vec*)outx,n);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCApplyTranspose_dvd" static PetscErrorCode PCApplyTranspose_dvd(PC pc,Vec in,Vec out) { PetscErrorCode ierr; dvdImprovex_jd *data; PetscInt n,i; const Vec *inx, *outx; Vec *auxV; Mat A; PetscFunctionBegin; ierr = PCGetOperators(pc,&A,NULL);CHKERRQ(ierr); ierr = MatShellGetContext(A,(void**)&data);CHKERRQ(ierr); ierr = VecCompGetSubVecs(in,NULL,&inx);CHKERRQ(ierr); ierr = VecCompGetSubVecs(out,NULL,&outx);CHKERRQ(ierr); n = data->r_e - data->r_s; ierr = SlepcVecPoolGetVecs(data->d->auxV,n,&auxV);CHKERRQ(ierr); /* auxV <- in */ for (i=0;id,auxV,n);CHKERRQ(ierr); /* out <- K' * aux */ for (i=0;iold_pc,auxV[i],outx[i]);CHKERRQ(ierr); } ierr = SlepcVecPoolRestoreVecs(data->d->auxV,n,&auxV);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMult_dvd_jd" static PetscErrorCode MatMult_dvd_jd(Mat A,Vec in,Vec out) { PetscErrorCode ierr; dvdImprovex_jd *data; PetscInt n; const Vec *inx, *outx; PCSide side; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&data);CHKERRQ(ierr); ierr = VecCompGetSubVecs(in,NULL,&inx);CHKERRQ(ierr); ierr = VecCompGetSubVecs(out,NULL,&outx);CHKERRQ(ierr); n = data->r_e - data->r_s; /* out <- theta[1]A*in - theta[0]*B*in */ ierr = dvd_aux_matmult(data,inx,outx);CHKERRQ(ierr); ierr = KSPGetPCSide(data->ksp,&side);CHKERRQ(ierr); if (side == PC_RIGHT) { /* out <- out - v*(u'*out) */ ierr = dvd_improvex_apply_proj(data->d,(Vec*)outx,n);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMultTranspose_dvd_jd" static PetscErrorCode MatMultTranspose_dvd_jd(Mat A,Vec in,Vec out) { PetscErrorCode ierr; dvdImprovex_jd *data; PetscInt n,i; const Vec *inx,*outx,*r; Vec *auxV; PCSide side; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&data);CHKERRQ(ierr); ierr = VecCompGetSubVecs(in,NULL,&inx);CHKERRQ(ierr); ierr = VecCompGetSubVecs(out,NULL,&outx);CHKERRQ(ierr); n = data->r_e - data->r_s; ierr = KSPGetPCSide(data->ksp,&side);CHKERRQ(ierr); if (side == PC_RIGHT) { /* auxV <- in */ ierr = SlepcVecPoolGetVecs(data->d->auxV,n,&auxV);CHKERRQ(ierr); for (i=0;id,auxV,n);CHKERRQ(ierr); r = auxV; } else r = inx; /* out <- theta[1]A*r - theta[0]*B*r */ ierr = dvd_aux_matmulttrans(data,r,outx);CHKERRQ(ierr); if (side == PC_RIGHT) { ierr = SlepcVecPoolRestoreVecs(data->d->auxV,n,&auxV);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateVecs_dvd_jd" static PetscErrorCode MatCreateVecs_dvd_jd(Mat A,Vec *right,Vec *left) { PetscErrorCode ierr; Vec *r,*l; dvdImprovex_jd *data; PetscInt n,i; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&data);CHKERRQ(ierr); n = data->ksp_max_size; if (right) { ierr = PetscMalloc1(n,&r);CHKERRQ(ierr); } if (left) { ierr = PetscMalloc1(n,&l);CHKERRQ(ierr); } for (i=0;id->A,right?&r[i]:NULL,left?&l[i]:NULL);CHKERRQ(ierr); } if (right) { ierr = VecCreateCompWithVecs(r,n,data->friends,right);CHKERRQ(ierr); for (i=0;ifriends,left);CHKERRQ(ierr); for (i=0;iimproveX_data; PetscInt rA, cA, rlA, clA; Mat A; PetscBool t; PC pc; Vec v0[2]; PetscFunctionBegin; data->size_cX = data->old_size_X = 0; data->lastTol = data->dynamic?0.5:0.0; /* Setup the ksp */ if (data->ksp) { /* Create the reference vector */ ierr = BVGetColumn(d->eps->V,0,&v0[0]);CHKERRQ(ierr); v0[1] = v0[0]; ierr = VecCreateCompWithVecs(v0,data->ksp_max_size,NULL,&data->friends);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,0,&v0[0]);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)d->eps,(PetscObject)data->friends);CHKERRQ(ierr); /* Save the current pc and set a PCNONE */ ierr = KSPGetPC(data->ksp, &data->old_pc);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)data->old_pc,PCNONE,&t);CHKERRQ(ierr); data->lastTol = 0.5; if (t) data->old_pc = 0; else { ierr = PetscObjectReference((PetscObject)data->old_pc);CHKERRQ(ierr); ierr = PCCreate(PetscObjectComm((PetscObject)d->eps),&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCSHELL);CHKERRQ(ierr); ierr = PCSetOperators(pc,d->A,d->A);CHKERRQ(ierr); ierr = PCSetReusePreconditioner(pc,PETSC_TRUE);CHKERRQ(ierr); ierr = PCShellSetApply(pc,PCApply_dvd);CHKERRQ(ierr); ierr = PCShellSetApplyBA(pc,PCApplyBA_dvd);CHKERRQ(ierr); ierr = PCShellSetApplyTranspose(pc,PCApplyTranspose_dvd);CHKERRQ(ierr); ierr = KSPSetPC(data->ksp,pc);CHKERRQ(ierr); ierr = PCDestroy(&pc);CHKERRQ(ierr); } /* Create the (I-v*u')*K*(A-s*B) matrix */ ierr = MatGetSize(d->A,&rA,&cA);CHKERRQ(ierr); ierr = MatGetLocalSize(d->A,&rlA,&clA);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)d->A),rlA*data->ksp_max_size,clA*data->ksp_max_size,rA*data->ksp_max_size,cA*data->ksp_max_size,data,&A);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT,(void(*)(void))MatMult_dvd_jd);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_MULT_TRANSPOSE,(void(*)(void))MatMultTranspose_dvd_jd);CHKERRQ(ierr); ierr = MatShellSetOperation(A,MATOP_GET_VECS,(void(*)(void))MatCreateVecs_dvd_jd);CHKERRQ(ierr); /* Try to avoid KSPReset */ ierr = KSPGetOperatorsSet(data->ksp,&t,NULL);CHKERRQ(ierr); if (t) { Mat M; PetscInt rM; ierr = KSPGetOperators(data->ksp,&M,NULL);CHKERRQ(ierr); ierr = MatGetSize(M,&rM,NULL);CHKERRQ(ierr); if (rM != rA*data->ksp_max_size) { ierr = KSPReset(data->ksp);CHKERRQ(ierr); } } ierr = KSPSetOperators(data->ksp,A,A);CHKERRQ(ierr); ierr = KSPSetReusePreconditioner(data->ksp,PETSC_TRUE);CHKERRQ(ierr); ierr = KSPSetUp(data->ksp);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); } else { data->old_pc = 0; data->friends = NULL; } ierr = BVSetActiveColumns(data->KZ,0,0);CHKERRQ(ierr); ierr = BVSetActiveColumns(data->U,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_proj_cuv" /* Compute: u <- X, v <- K*(theta[0]*A+theta[1]*B)*X, kr <- K^{-1}*(A-eig*B)*X, being X <- V*pX[i_s..i_e-1], Y <- W*pY[i_s..i_e-1] where pX,pY, the right and left eigenvectors of the projected system ld, the leading dimension of pX and pY */ static PetscErrorCode dvd_improvex_jd_proj_cuv(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld) { #if defined(PETSC_MISSING_LAPACK_GETRF) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt n=i_e-i_s,size_KZ,V_new,rm,i,lv,kv,lKZ,kKZ; dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscScalar *array; Mat M; Vec u[2],v[2]; PetscBLASInt s,ldXKZ,info; PetscFunctionBegin; /* Check consistency */ ierr = BVGetActiveColumns(d->eps->V,&lv,&kv);CHKERRQ(ierr); V_new = lv - data->size_cX; if (V_new > data->old_size_X) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken"); data->old_size_X = n; data->size_cX = lv; /* KZ <- KZ(rm:rm+max_cX-1) */ ierr = BVGetActiveColumns(data->KZ,&lKZ,&kKZ);CHKERRQ(ierr); rm = PetscMax(V_new+lKZ-d->max_cX_in_impr,0); if (rm > 0) { for (i=0;iKZ,i+rm,i);CHKERRQ(ierr); ierr = BVCopyColumn(data->U,i+rm,i);CHKERRQ(ierr); } } /* XKZ <- XKZ(rm:rm+max_cX-1,rm:rm+max_cX-1) */ if (rm > 0) { for (i=0;iXKZ[i*data->ldXKZ+i],&data->XKZ[(i+rm)*data->ldXKZ+i+rm],sizeof(PetscScalar)*lKZ);CHKERRQ(ierr); } } lKZ = PetscMin(d->max_cX_in_impr,lKZ+V_new); ierr = BVSetActiveColumns(data->KZ,lKZ,lKZ+n);CHKERRQ(ierr); ierr = BVSetActiveColumns(data->U,lKZ,lKZ+n);CHKERRQ(ierr); /* Compute X, KZ and KR */ ierr = BVGetColumn(data->U,lKZ,u);CHKERRQ(ierr); if (n>1) { ierr = BVGetColumn(data->U,lKZ+1,&u[1]);CHKERRQ(ierr); } ierr = BVGetColumn(data->KZ,lKZ,v);CHKERRQ(ierr); if (n>1) { ierr = BVGetColumn(data->KZ,lKZ+1,&v[1]);CHKERRQ(ierr); } ierr = d->improvex_jd_proj_uv(d,i_s,i_e,u,v,kr,theta,thetai,pX,pY,ld);CHKERRQ(ierr); ierr = BVRestoreColumn(data->U,lKZ,u);CHKERRQ(ierr); if (n>1) { ierr = BVRestoreColumn(data->U,lKZ+1,&u[1]);CHKERRQ(ierr); } ierr = BVRestoreColumn(data->KZ,lKZ,v);CHKERRQ(ierr); if (n>1) { ierr = BVRestoreColumn(data->KZ,lKZ+1,&v[1]);CHKERRQ(ierr); } /* XKZ <- U'*KZ */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,lKZ+n,lKZ+n,NULL,&M);CHKERRQ(ierr); ierr = BVMatProject(data->KZ,NULL,data->U,M);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&array);CHKERRQ(ierr); for (i=lKZ;iXKZ[data->ldXKZ*i],&array[i*(lKZ+n)],lKZ*sizeof(PetscScalar));CHKERRQ(ierr); } for (i=0;iXKZ[data->ldXKZ*i+lKZ],&array[i*(lKZ+n)+lKZ],n*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = MatDenseRestoreArray(M,&array);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); /* iXKZ <- inv(XKZ) */ size_KZ = lKZ+n; ierr = PetscBLASIntCast(lKZ+n,&s);CHKERRQ(ierr); data->ldiXKZ = data->size_iXKZ = size_KZ; for (i=0;iiXKZ[data->ldiXKZ*i],&data->XKZ[data->ldXKZ*i],sizeof(PetscScalar)*size_KZ);CHKERRQ(ierr); } ierr = PetscBLASIntCast(data->ldiXKZ,&ldXKZ);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&s,&s,data->iXKZ,&ldXKZ,data->iXKZPivots,&info)); ierr = PetscFPTrapPop();CHKERRQ(ierr); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack XGETRF %d",info); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_gen" static PetscErrorCode dvd_improvex_jd_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D) { dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscErrorCode ierr; PetscInt i,j,n,maxits,maxits0,lits,s,ld,k,max_size_D,lV,kV; PetscScalar *pX,*pY; PetscReal tol,tol0; Vec *kr,kr_comp,D_comp,D[2],kr0[2]; PetscBool odd_situation = PETSC_FALSE; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); max_size_D = d->eps->ncv-kV; /* Quick exit */ if ((max_size_D == 0) || r_e-r_s <= 0) { *size_D = 0; PetscFunctionReturn(0); } n = PetscMin(PetscMin(data->size_X, max_size_D), r_e-r_s); if (n == 0) SETERRQ(PETSC_COMM_SELF,1,"n == 0"); if (data->size_X < r_e-r_s) SETERRQ(PETSC_COMM_SELF,1,"size_X < r_e-r_s"); ierr = DSGetLeadingDimension(d->eps->ds,&ld);CHKERRQ(ierr); /* Restart lastTol if a new pair converged */ if (data->dynamic && data->size_cX < lV) data->lastTol = 0.5; for (i=0,s=0;ieigi[i] != 0.0) { if (i+2 <= max_size_D) s=2; else break; } else #endif s=1; data->r_s = r_s+i; data->r_e = r_s+i+s; ierr = SlepcVecPoolGetVecs(d->auxV,s,&kr);CHKERRQ(ierr); /* Compute theta, maximum iterations and tolerance */ maxits = 0; tol = 1; for (j=0;jimprovex_jd_lit(d,r_s+i+j,&data->theta[2*j],&data->thetai[j],&maxits0,&tol0);CHKERRQ(ierr); maxits += maxits0; tol *= tol0; } maxits/= s; tol = data->dynamic?data->lastTol:PetscExpReal(PetscLogReal(tol)/s); /* Compute u, v and kr */ k = r_s+i; ierr = DSVectors(d->eps->ds,DS_MAT_X,&k,NULL);CHKERRQ(ierr); k = r_s+i; ierr = DSVectors(d->eps->ds,DS_MAT_Y,&k,NULL);CHKERRQ(ierr); ierr = DSGetArray(d->eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = DSGetArray(d->eps->ds,DS_MAT_Y,&pY);CHKERRQ(ierr); ierr = dvd_improvex_jd_proj_cuv(d,r_s+i,r_s+i+s,kr,data->theta,data->thetai,pX,pY,ld);CHKERRQ(ierr); ierr = DSRestoreArray(d->eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = DSRestoreArray(d->eps->ds,DS_MAT_Y,&pY);CHKERRQ(ierr); /* Check if the first eigenpairs are converged */ if (i == 0) { ierr = d->preTestConv(d,0,s,s,&d->npreconv);CHKERRQ(ierr); if (d->npreconv > 0) break; } /* Test the odd situation of solving Ax=b with A=I */ #if !defined(PETSC_USE_COMPLEX) odd_situation = (data->ksp && data->theta[0] == 1. && data->theta[1] == 0. && data->thetai[0] == 0. && d->B == NULL)? PETSC_TRUE: PETSC_FALSE; #else odd_situation = (data->ksp && data->theta[0] == 1. && data->theta[1] == 0. && d->B == NULL)? PETSC_TRUE: PETSC_FALSE; #endif /* If JD */ if (data->ksp && !odd_situation) { /* kr <- -kr */ for (j=0;jksp_max_size,data->friends,&kr_comp);CHKERRQ(ierr); ierr = BVGetColumn(d->eps->V,kV+r_s+i,&D[0]);CHKERRQ(ierr); if (s==2) { ierr = BVGetColumn(d->eps->V,kV+r_s+i+1,&D[1]);CHKERRQ(ierr); } else D[1] = NULL; ierr = VecCreateCompWithVecs(D,data->ksp_max_size,data->friends,&D_comp);CHKERRQ(ierr); ierr = VecCompSetSubVecs(data->friends,s,NULL);CHKERRQ(ierr); /* Solve the correction equation */ ierr = KSPSetTolerances(data->ksp,tol,PETSC_DEFAULT,PETSC_DEFAULT,maxits);CHKERRQ(ierr); ierr = KSPSolve(data->ksp,kr_comp,D_comp);CHKERRQ(ierr); ierr = KSPGetIterationNumber(data->ksp,&lits);CHKERRQ(ierr); /* Destroy the composed ks and D */ ierr = VecDestroy(&kr_comp);CHKERRQ(ierr); ierr = VecDestroy(&D_comp);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,kV+r_s+i,&D[0]);CHKERRQ(ierr); if (s==2) { ierr = BVRestoreColumn(d->eps->V,kV+r_s+i+1,&D[1]);CHKERRQ(ierr); } /* If GD */ } else { ierr = BVGetColumn(d->eps->V,kV+r_s+i,&D[0]);CHKERRQ(ierr); if (s==2) { ierr = BVGetColumn(d->eps->V,kV+r_s+i+1,&D[1]);CHKERRQ(ierr); } for (j=0;jimprovex_precond(d,r_s+i+j,kr[j],D[j]);CHKERRQ(ierr); } ierr = dvd_improvex_apply_proj(d,D,s);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,kV+r_s+i,&D[0]);CHKERRQ(ierr); if (s==2) { ierr = BVRestoreColumn(d->eps->V,kV+r_s+i+1,&D[1]);CHKERRQ(ierr); } } /* Prevent that short vectors are discarded in the orthogonalization */ if (i == 0 && d->eps->errest[d->nconv+r_s] > PETSC_MACHINE_EPSILON && d->eps->errest[d->nconv+r_s] < PETSC_MAX_REAL) { for (j=0;jeps->V,kV+r_s+i+j,1.0/d->eps->errest[d->nconv+r_s]);CHKERRQ(ierr); } } ierr = SlepcVecPoolRestoreVecs(d->auxV,s,&kr);CHKERRQ(ierr); } *size_D = i; if (data->dynamic) data->lastTol = PetscMax(data->lastTol/2.0,PETSC_MACHINE_EPSILON*10.0); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd" PetscErrorCode dvd_improvex_jd(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs,PetscInt cX_impr,PetscBool dynamic) { PetscErrorCode ierr; dvdImprovex_jd *data; PetscBool useGD; PC pc; PetscInt size_P; PetscFunctionBegin; /* Setting configuration constrains */ ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&useGD);CHKERRQ(ierr); /* If the arithmetic is real and the problem is not Hermitian, then the block size is incremented in one */ #if !defined(PETSC_USE_COMPLEX) if (!DVD_IS(d->sEP,DVD_EP_HERMITIAN)) { max_bs++; b->max_size_P = PetscMax(b->max_size_P,2); } else #endif { b->max_size_P = PetscMax(b->max_size_P,1); } b->max_size_X = PetscMax(b->max_size_X,max_bs); size_P = b->max_size_P+cX_impr; /* Setup the preconditioner */ if (ksp) { ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = dvd_static_precond_PC(d,b,pc);CHKERRQ(ierr); } else { ierr = dvd_static_precond_PC(d,b,0);CHKERRQ(ierr); } /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscNewLog(d->eps,&data);CHKERRQ(ierr); data->dynamic = dynamic; d->max_cX_in_impr = cX_impr; ierr = PetscMalloc1(size_P*size_P,&data->XKZ);CHKERRQ(ierr); ierr = PetscMalloc1(size_P*size_P,&data->iXKZ);CHKERRQ(ierr); ierr = PetscMalloc1(size_P,&data->iXKZPivots);CHKERRQ(ierr); data->ldXKZ = size_P; data->size_X = b->max_size_X; d->improveX_data = data; data->ksp = useGD? NULL: ksp; data->d = d; d->improveX = dvd_improvex_jd_gen; #if !defined(PETSC_USE_COMPLEX) if (!DVD_IS(d->sEP,DVD_EP_HERMITIAN)) data->ksp_max_size = 2; else #endif data->ksp_max_size = 1; /* Create various vector basis */ ierr = BVDuplicateResize(d->eps->V,size_P,&data->KZ);CHKERRQ(ierr); ierr = BVSetMatrix(data->KZ,NULL,PETSC_FALSE);CHKERRQ(ierr); ierr = BVDuplicate(data->KZ,&data->U);CHKERRQ(ierr); ierr = EPSDavidsonFLAdd(&d->startList,dvd_improvex_jd_start);CHKERRQ(ierr); ierr = EPSDavidsonFLAdd(&d->endList,dvd_improvex_jd_end);CHKERRQ(ierr); ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_improvex_jd_d);CHKERRQ(ierr); } PetscFunctionReturn(0); } #if !defined(PETSC_USE_COMPLEX) #undef __FUNCT__ #define __FUNCT__ "dvd_complex_rayleigh_quotient" PETSC_STATIC_INLINE PetscErrorCode dvd_complex_rayleigh_quotient(Vec ur,Vec ui,Vec Axr,Vec Axi,Vec Bxr,Vec Bxi,PetscScalar *eigr,PetscScalar *eigi) { PetscErrorCode ierr; PetscScalar rAr,iAr,rAi,iAi,rBr,iBr,rBi,iBi,b0,b2,b4,b6,b7; PetscFunctionBegin; /* eigr = [(rAr+iAi)*(rBr+iBi) + (rAi-iAr)*(rBi-iBr)]/k eigi = [(rAi-iAr)*(rBr+iBi) - (rAr+iAi)*(rBi-iBr)]/k k = (rBr+iBi)*(rBr+iBi) + (rBi-iBr)*(rBi-iBr) */ ierr = VecDotBegin(Axr,ur,&rAr);CHKERRQ(ierr); /* r*A*r */ ierr = VecDotBegin(Axr,ui,&iAr);CHKERRQ(ierr); /* i*A*r */ ierr = VecDotBegin(Axi,ur,&rAi);CHKERRQ(ierr); /* r*A*i */ ierr = VecDotBegin(Axi,ui,&iAi);CHKERRQ(ierr); /* i*A*i */ ierr = VecDotBegin(Bxr,ur,&rBr);CHKERRQ(ierr); /* r*B*r */ ierr = VecDotBegin(Bxr,ui,&iBr);CHKERRQ(ierr); /* i*B*r */ ierr = VecDotBegin(Bxi,ur,&rBi);CHKERRQ(ierr); /* r*B*i */ ierr = VecDotBegin(Bxi,ui,&iBi);CHKERRQ(ierr); /* i*B*i */ ierr = VecDotEnd(Axr,ur,&rAr);CHKERRQ(ierr); /* r*A*r */ ierr = VecDotEnd(Axr,ui,&iAr);CHKERRQ(ierr); /* i*A*r */ ierr = VecDotEnd(Axi,ur,&rAi);CHKERRQ(ierr); /* r*A*i */ ierr = VecDotEnd(Axi,ui,&iAi);CHKERRQ(ierr); /* i*A*i */ ierr = VecDotEnd(Bxr,ur,&rBr);CHKERRQ(ierr); /* r*B*r */ ierr = VecDotEnd(Bxr,ui,&iBr);CHKERRQ(ierr); /* i*B*r */ ierr = VecDotEnd(Bxi,ur,&rBi);CHKERRQ(ierr); /* r*B*i */ ierr = VecDotEnd(Bxi,ui,&iBi);CHKERRQ(ierr); /* i*B*i */ b0 = rAr+iAi; /* rAr+iAi */ b2 = rAi-iAr; /* rAi-iAr */ b4 = rBr+iBi; /* rBr+iBi */ b6 = rBi-iBr; /* rBi-iBr */ b7 = b4*b4 + b6*b6; /* k */ *eigr = (b0*b4 + b2*b6) / b7; /* eig_r */ *eigi = (b2*b4 - b0*b6) / b7; /* eig_i */ PetscFunctionReturn(0); } #endif #undef __FUNCT__ #define __FUNCT__ "dvd_compute_n_rr" PETSC_STATIC_INLINE PetscErrorCode dvd_compute_n_rr(PetscInt i_s,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,Vec *u,Vec *Ax,Vec *Bx) { PetscErrorCode ierr; PetscInt i; PetscScalar b0,b1; PetscFunctionBegin; for (i=0; i 1e-10 || PetscAbsScalar(eigi[i_s+i]-eigi0)/PetscAbsScalar(eigi[i_s+i]) > 1e-10) { ierr = PetscInfo4(u[0],"The eigenvalue %g%+gi is far from its Rayleigh quotient value %g%+gi\n",(double)eigr[i_s+i],(double)eigi[i_s+i],(double)eigr0,(double)eigi0);CHKERRQ(ierr); } i++; } else #endif { ierr = VecDotBegin(Ax[i],u[i],&b0);CHKERRQ(ierr); ierr = VecDotBegin(Bx[i],u[i],&b1);CHKERRQ(ierr); ierr = VecDotEnd(Ax[i],u[i],&b0);CHKERRQ(ierr); ierr = VecDotEnd(Bx[i],u[i],&b1);CHKERRQ(ierr); b0 = b0/b1; if (PetscAbsScalar(eigr[i_s+i]-b0)/PetscAbsScalar(eigr[i_s+i]) > 1e-10) { ierr = PetscInfo4(u[0],"The eigenvalue %g+%g is far from its Rayleigh quotient value %g+%g\n",(double)PetscRealPart(eigr[i_s+i]),(double)PetscImaginaryPart(eigr[i_s+i]),(double)PetscRealPart(b0),(double)PetscImaginaryPart(b0));CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_proj_uv_KZX" /* Compute: u <- X, v <- K*(theta[0]*A+theta[1]*B)*X, kr <- K^{-1}*(A-eig*B)*X, being X <- V*pX[i_s..i_e-1], Y <- W*pY[i_s..i_e-1] where pX,pY, the right and left eigenvectors of the projected system ld, the leading dimension of pX and pY */ static PetscErrorCode dvd_improvex_jd_proj_uv_KZX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld) { PetscErrorCode ierr; PetscInt n = i_e-i_s,i; PetscScalar *b; Vec *Ax,*Bx,*r; Mat M; BV X; PetscFunctionBegin; ierr = BVDuplicateResize(d->eps->V,4,&X);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,4,4,NULL,&M);CHKERRQ(ierr); /* u <- X(i) */ ierr = dvd_improvex_compute_X(d,i_s,i_e,u,pX,ld);CHKERRQ(ierr); /* v <- theta[0]A*u + theta[1]*B*u */ /* Bx <- B*X(i) */ Bx = kr; if (d->BX) { for (i=i_s; iBX,1.0,0.0,Bx[i-i_s],&pX[ld*i]);CHKERRQ(ierr); } } else { for (i=0;iB) { ierr = MatMult(d->B, u[i], Bx[i]);CHKERRQ(ierr); } else { ierr = VecCopy(u[i], Bx[i]);CHKERRQ(ierr); } } } /* Ax <- A*X(i) */ ierr = SlepcVecPoolGetVecs(d->auxV,i_e-i_s,&r);CHKERRQ(ierr); Ax = r; for (i=i_s; iAX,1.0,0.0,Ax[i-i_s],&pX[ld*i]);CHKERRQ(ierr); } /* v <- Y(i) */ for (i=i_s; iW?d->W:d->eps->V,1.0,0.0,v[i-i_s],&pY[ld*i]);CHKERRQ(ierr); } /* Recompute the eigenvalue */ ierr = dvd_compute_n_rr(i_s,n,d->eigr,d->eigi,v,Ax,Bx);CHKERRQ(ierr); for (i=0;ieigi[i_s+i] != 0.0) { /* [r_i r_i+1 kr_i kr_i+1]*= [ theta_2i' 0 1 0 0 theta_2i' 0 1 theta_2i+1 -thetai_i -eigr_i -eigi_i thetai_i theta_2i+1 eigi_i -eigr_i ] */ ierr = MatDenseGetArray(M,&b);CHKERRQ(ierr); b[0] = b[5] = PetscConj(theta[2*i]); b[2] = b[7] = -theta[2*i+1]; b[6] = -(b[3] = thetai[i]); b[1] = b[4] = 0.0; b[8] = b[13] = 1.0/d->nX[i_s+i]; b[10] = b[15] = -d->eigr[i_s+i]/d->nX[i_s+i]; b[14] = -(b[11] = d->eigi[i_s+i]/d->nX[i_s+i]); b[9] = b[12] = 0.0; ierr = MatDenseRestoreArray(M,&b);CHKERRQ(ierr); ierr = BVInsertVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,1,Ax[i+1]);CHKERRQ(ierr); ierr = BVInsertVec(X,2,Bx[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,3,Bx[i+1]);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,0,4);CHKERRQ(ierr); ierr = BVMultInPlace(X,M,0,4);CHKERRQ(ierr); ierr = BVCopyVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVCopyVec(X,1,Ax[i+1]);CHKERRQ(ierr); ierr = BVCopyVec(X,2,Bx[i]);CHKERRQ(ierr); ierr = BVCopyVec(X,3,Bx[i+1]);CHKERRQ(ierr); i++; } else #endif { /* [Ax_i Bx_i]*= [ theta_2i' 1/nX_i theta_2i+1 -eig_i/nX_i ] */ ierr = MatDenseGetArray(M,&b);CHKERRQ(ierr); b[0] = PetscConj(theta[i*2]); b[1] = theta[i*2+1]; b[4] = 1.0/d->nX[i_s+i]; b[5] = -d->eigr[i_s+i]/d->nX[i_s+i]; ierr = MatDenseRestoreArray(M,&b);CHKERRQ(ierr); ierr = BVInsertVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,1,Bx[i]);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,0,2);CHKERRQ(ierr); ierr = BVMultInPlace(X,M,0,2);CHKERRQ(ierr); ierr = BVCopyVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVCopyVec(X,1,Bx[i]);CHKERRQ(ierr); } } for (i=0; inX[i_s+i] = 1.0; /* v <- K^{-1} r = K^{-1}(theta_2i'*Ax + theta_2i+1*Bx) */ for (i=0;iimprovex_precond(d,i_s+i,r[i],v[i]);CHKERRQ(ierr); } ierr = SlepcVecPoolRestoreVecs(d->auxV,i_e-i_s,&r);CHKERRQ(ierr); /* kr <- P*(Ax - eig_i*Bx) */ ierr = d->calcpairs_proj_res(d,i_s,i_e,kr);CHKERRQ(ierr); ierr = BVDestroy(&X);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_proj_uv_KXX" /* Compute: u <- K^{-1}*X, v <- X, kr <- K^{-1}*(A-eig*B)*X, being X <- V*pX[i_s..i_e-1] where pX,pY, the right and left eigenvectors of the projected system ld, the leading dimension of pX and pY */ static PetscErrorCode dvd_improvex_jd_proj_uv_KXX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld) { PetscErrorCode ierr; PetscInt n = i_e - i_s,i; PetscScalar *b; Vec *Ax,*Bx,*r; Mat M; BV X; PetscFunctionBegin; ierr = BVDuplicateResize(d->eps->V,4,&X);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,4,2,NULL,&M);CHKERRQ(ierr); /* [v u] <- X(i) Y(i) */ ierr = dvd_improvex_compute_X(d,i_s,i_e,v,pX,ld);CHKERRQ(ierr); for (i=i_s; iW?d->W:d->eps->V,1.0,0.0,u[i-i_s],&pY[ld*i]);CHKERRQ(ierr); } /* Bx <- B*X(i) */ ierr = SlepcVecPoolGetVecs(d->auxV,i_e-i_s,&r);CHKERRQ(ierr); Bx = r; if (d->BX) { for (i=i_s; iBX,1.0,0.0,Bx[i-i_s],&pX[ld*i]);CHKERRQ(ierr); } } else { if (d->B) { for (i=0;iB,v[i],Bx[i]);CHKERRQ(ierr); } } else Bx = v; } /* Ax <- A*X(i) */ Ax = kr; for (i=i_s; iAX,1.0,0.0,Ax[i-i_s],&pX[ld*i]);CHKERRQ(ierr); } /* Recompute the eigenvalue */ ierr = dvd_compute_n_rr(i_s,n,d->eigr,d->eigi,u,Ax,Bx);CHKERRQ(ierr); for (i=0;ieigi[i_s+i] == 0.0) { /* kr <- Ax -eig*Bx */ ierr = VecAXPBY(kr[i],-d->eigr[i_s+i]/d->nX[i_s+i],1.0/d->nX[i_s+i],Bx[i]);CHKERRQ(ierr); } else { /* [kr_i kr_i+1 r_i r_i+1]*= [ 1 0 0 1 -eigr_i -eigi_i eigi_i -eigr_i] */ ierr = MatDenseGetArray(M,&b);CHKERRQ(ierr); b[0] = b[5] = 1.0/d->nX[i_s+i]; b[2] = b[7] = -d->eigr[i_s+i]/d->nX[i_s+i]; b[6] = -(b[3] = d->eigi[i_s+i]/d->nX[i_s+i]); b[1] = b[4] = 0.0; ierr = MatDenseRestoreArray(M,&b);CHKERRQ(ierr); ierr = BVInsertVec(X,0,kr[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,1,kr[i+1]);CHKERRQ(ierr); ierr = BVInsertVec(X,2,r[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,3,r[i+1]);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,0,4);CHKERRQ(ierr); ierr = BVMultInPlace(X,M,0,2);CHKERRQ(ierr); ierr = BVCopyVec(X,0,kr[i]);CHKERRQ(ierr); ierr = BVCopyVec(X,1,kr[i+1]);CHKERRQ(ierr); i++; } } for (i=0; inX[i_s+i] = 1.0; /* kr <- P*kr */ ierr = d->calcpairs_proj_res(d,i_s,i_e,r);CHKERRQ(ierr); ierr = SlepcVecPoolRestoreVecs(d->auxV,i_e-i_s,&r);CHKERRQ(ierr); /* u <- K^{-1} X(i) */ for (i=0;iimprovex_precond(d,i_s+i,v[i],u[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_lit_const_0" static PetscErrorCode dvd_improvex_jd_lit_const_0(dvdDashboard *d,PetscInt i,PetscScalar* theta,PetscScalar* thetai,PetscInt *maxits,PetscReal *tol) { dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscReal a; PetscFunctionBegin; a = SlepcAbsEigenvalue(d->eigr[i],d->eigi[i]); if (d->nR[i]/a < data->fix) { theta[0] = d->eigr[i]; theta[1] = 1.0; #if !defined(PETSC_USE_COMPLEX) *thetai = d->eigi[i]; #endif } else { theta[0] = d->target[0]; theta[1] = d->target[1]; #if !defined(PETSC_USE_COMPLEX) *thetai = 0.0; #endif } #if defined(PETSC_USE_COMPLEX) if (thetai) *thetai = 0.0; #endif *maxits = data->maxits; *tol = data->tol; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_lit_const" PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard *d,dvdBlackboard *b,PetscInt maxits,PetscReal tol,PetscReal fix) { dvdImprovex_jd *data = (dvdImprovex_jd*)d->improveX_data; PetscFunctionBegin; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { data->maxits = maxits; data->tol = tol; data->fix = fix; d->improvex_jd_lit = dvd_improvex_jd_lit_const_0; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_jd_proj_uv" PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard *d,dvdBlackboard *b,ProjType_t p) { PetscFunctionBegin; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { switch (p) { case DVD_PROJ_KXX: d->improvex_jd_proj_uv = dvd_improvex_jd_proj_uv_KXX; break; case DVD_PROJ_KZX: d->improvex_jd_proj_uv = dvd_improvex_jd_proj_uv_KZX; break; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_compute_X" PetscErrorCode dvd_improvex_compute_X(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u_,PetscScalar *pX,PetscInt ld) { PetscErrorCode ierr; PetscInt n = i_e - i_s,i; Vec *u; PetscFunctionBegin; if (u_) u = u_; else if (d->correctXnorm) { ierr = SlepcVecPoolGetVecs(d->auxV,i_e-i_s,&u);CHKERRQ(ierr); } if (u_ || d->correctXnorm) { for (i=0; ieps->V,1.0,0.0,u[i],&pX[ld*(i+i_s)]);CHKERRQ(ierr); } } /* nX(i) <- ||X(i)|| */ if (d->correctXnorm) { for (i=0; inX[i_s+i]);CHKERRQ(ierr); } for (i=0; inX[i_s+i]);CHKERRQ(ierr); } #if !defined(PETSC_USE_COMPLEX) for (i=0;ieigi[i_s+i] != 0.0) { d->nX[i_s+i] = d->nX[i_s+i+1] = PetscSqrtScalar(d->nX[i_s+i]*d->nX[i_s+i]+d->nX[i_s+i+1]*d->nX[i_s+i+1]); i++; } } #endif } else { for (i=0;inX[i_s+i] = 1.0; } if (d->correctXnorm && !u_) { ierr = SlepcVecPoolRestoreVecs(d->auxV,i_e-i_s,&u);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/dvdupdatev.c0000644000175000017500000003364313107004621021017 0ustar jromanjroman/* SLEPc eigensolver: "davidson" Step: test for restarting, updateV, restartV - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" typedef struct { PetscInt min_size_V; /* restart with this number of eigenvectors */ PetscInt plusk; /* at restart, save plusk vectors from last iteration */ PetscInt mpd; /* max size of the searching subspace */ void *old_updateV_data; /* old updateV data */ PetscErrorCode (*old_isRestarting)(dvdDashboard*,PetscBool*); /* old isRestarting */ Mat oldU; /* previous projected right igenvectors */ Mat oldV; /* previous projected left eigenvectors */ PetscInt size_oldU; /* size of oldU */ PetscBool allResiduals; /* if computing all the residuals */ } dvdManagV_basic; #undef __FUNCT__ #define __FUNCT__ "dvd_updateV_start" static PetscErrorCode dvd_updateV_start(dvdDashboard *d) { dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscInt i; PetscFunctionBegin; for (i=0;ieps->ncv;i++) d->eigi[i] = 0.0; d->nR = d->real_nR; for (i=0;ieps->ncv;i++) d->nR[i] = PETSC_MAX_REAL; d->nX = d->real_nX; for (i=0;ieps->ncv;i++) d->errest[i] = PETSC_MAX_REAL; data->size_oldU = 0; d->nconv = 0; d->npreconv = 0; d->V_tra_s = d->V_tra_e = d->V_new_s = d->V_new_e = 0; d->size_D = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_isrestarting_fullV" static PetscErrorCode dvd_isrestarting_fullV(dvdDashboard *d,PetscBool *r) { PetscErrorCode ierr; PetscInt l,k; PetscBool restart; dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); restart = (k+2 > d->eps->ncv)? PETSC_TRUE: PETSC_FALSE; /* Check old isRestarting function */ if (!restart && data->old_isRestarting) { ierr = data->old_isRestarting(d,&restart);CHKERRQ(ierr); } *r = restart; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_managementV_basic_d" static PetscErrorCode dvd_managementV_basic_d(dvdDashboard *d) { PetscErrorCode ierr; dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscFunctionBegin; /* Restore changes in dvdDashboard */ d->updateV_data = data->old_updateV_data; /* Free local data */ if (data->oldU) { ierr = MatDestroy(&data->oldU);CHKERRQ(ierr); } if (data->oldV) { ierr = MatDestroy(&data->oldV);CHKERRQ(ierr); } ierr = PetscFree(d->real_nR);CHKERRQ(ierr); ierr = PetscFree(d->real_nX);CHKERRQ(ierr); ierr = PetscFree(data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_updateV_conv_gen" static PetscErrorCode dvd_updateV_conv_gen(dvdDashboard *d) { dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscInt npreconv,cMT,cMTX,lV,kV,nV; PetscErrorCode ierr; Mat Q; #if !defined(PETSC_USE_COMPLEX) PetscInt i; #endif PetscFunctionBegin; npreconv = d->npreconv; /* Constrains the converged pairs to nev */ #if !defined(PETSC_USE_COMPLEX) /* Tries to maintain together conjugate eigenpairs */ for (i=0; (i + (d->eigi[i]!=0.0?1:0) < npreconv) && (d->nconv + i < d->nev); i+= (d->eigi[i]!=0.0?2:1)); npreconv = i; #else npreconv = PetscMax(PetscMin(d->nev-d->nconv,npreconv),0); #endif /* Quick exit */ if (npreconv == 0) PetscFunctionReturn(0); ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); nV = kV - lV; cMT = nV - npreconv; /* Harmonics restarts wiht right eigenvectors, and other with the left ones. If the problem is standard or hermitian, left and right vectors are the same */ if (!(d->W||DVD_IS(d->sEP,DVD_EP_STD)||DVD_IS(d->sEP,DVD_EP_HERMITIAN))) { /* ps.Q <- [ps.Q(0:npreconv-1) ps.Z(npreconv:size_H-1)] */ ierr = DSGetMat(d->eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSCopyMat(d->eps->ds,DS_MAT_Z,0,npreconv,Q,0,npreconv,nV,cMT,PETSC_TRUE);CHKERRQ(ierr); ierr = DSRestoreMat(d->eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); } if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) { ierr = DSPseudoOrthogonalize(d->eps->ds,DS_MAT_Q,nV,d->nBds,&cMTX,d->nBds);CHKERRQ(ierr); } else { ierr = DSOrthogonalize(d->eps->ds,DS_MAT_Q,nV,&cMTX);CHKERRQ(ierr); } cMT = cMTX - npreconv; if (d->W) { ierr = DSOrthogonalize(d->eps->ds,DS_MAT_Z,nV,&cMTX);CHKERRQ(ierr); cMT = PetscMin(cMT,cMTX - npreconv); } /* Lock the converged pairs */ d->eigr+= npreconv; #if !defined(PETSC_USE_COMPLEX) if (d->eigi) d->eigi+= npreconv; #endif d->nconv+= npreconv; d->errest+= npreconv; /* Notify the changes in V and update the other subspaces */ d->V_tra_s = npreconv; d->V_tra_e = nV; d->V_new_s = cMT; d->V_new_e = d->V_new_s; /* Remove oldU */ data->size_oldU = 0; d->npreconv-= npreconv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_updateV_restart_gen" static PetscErrorCode dvd_updateV_restart_gen(dvdDashboard *d) { dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscInt lV,kV,nV,size_plusk,size_X,cMTX,cMTY; Mat Q; PetscErrorCode ierr; PetscFunctionBegin; /* Select size_X desired pairs from V */ ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); nV = kV - lV; size_X = PetscMin(data->min_size_V,nV); /* Add plusk eigenvectors from the previous iteration */ size_plusk = PetscMax(0,PetscMin(PetscMin(data->plusk,data->size_oldU),d->eps->ncv - size_X)); d->size_MT = nV; /* ps.Q <- orth([pX(0:size_X-1) [oldU(0:size_plusk-1); 0] ]) */ /* Harmonics restarts wiht right eigenvectors, and other with the left ones. If the problem is standard or hermitian, left and right vectors are the same */ if (!(d->W||DVD_IS(d->sEP,DVD_EP_STD)||DVD_IS(d->sEP,DVD_EP_HERMITIAN))) { ierr = DSGetMat(d->eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSCopyMat(d->eps->ds,DS_MAT_Z,0,0,Q,0,0,nV,size_X,PETSC_TRUE);CHKERRQ(ierr); ierr = DSRestoreMat(d->eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); } if (size_plusk > 0 && DVD_IS(d->sEP,DVD_EP_INDEFINITE)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Unsupported plusk>0 in indefinite eigenvalue problems"); if (size_plusk > 0) { ierr = DSCopyMat(d->eps->ds,DS_MAT_Q,0,size_X,data->oldU,0,0,nV,size_plusk,PETSC_FALSE);CHKERRQ(ierr); } if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) { ierr = DSPseudoOrthogonalize(d->eps->ds,DS_MAT_Q,size_X,d->nBds,&cMTX,d->nBds);CHKERRQ(ierr); } else { ierr = DSOrthogonalize(d->eps->ds,DS_MAT_Q,size_X+size_plusk,&cMTX);CHKERRQ(ierr); } if (d->W && size_plusk > 0) { /* ps.Z <- orth([ps.Z(0:size_X-1) [oldV(0:size_plusk-1); 0] ]) */ ierr = DSCopyMat(d->eps->ds,DS_MAT_Z,0,size_X,data->oldV,0,0,nV,size_plusk,PETSC_FALSE);CHKERRQ(ierr); ierr = DSOrthogonalize(d->eps->ds,DS_MAT_Z,size_X+size_plusk,&cMTY);CHKERRQ(ierr); cMTX = PetscMin(cMTX, cMTY); } /* Notify the changes in V and update the other subspaces */ d->V_tra_s = 0; d->V_tra_e = cMTX; d->V_new_s = d->V_tra_e; d->V_new_e = d->V_new_s; /* Remove oldU */ data->size_oldU = 0; /* Remove npreconv */ d->npreconv = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_updateV_testConv" static PetscErrorCode dvd_updateV_testConv(dvdDashboard *d,PetscInt s,PetscInt pre,PetscInt e,PetscInt *nConv) { PetscInt i,j,b; PetscReal norm; PetscErrorCode ierr; PetscBool conv, c; dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscFunctionBegin; if (nConv) *nConv = s; for (i=s,conv=PETSC_TRUE;(conv || data->allResiduals) && (i < e);i+=b) { #if !defined(PETSC_USE_COMPLEX) b = d->eigi[i]!=0.0?2:1; #else b = 1; #endif if (i+b-1 >= pre) { ierr = d->calcpairs_residual(d,i,i+b);CHKERRQ(ierr); } /* Test the Schur vector */ for (j=0,c=PETSC_TRUE;jnR[i+j]/d->nX[i+j]; c = d->testConv(d,d->eigr[i+j],d->eigi[i+j],norm,&d->errest[i+j]); } if (conv && c) { if (nConv) *nConv = i+b; } else conv = PETSC_FALSE; } pre = PetscMax(pre,i); #if !defined(PETSC_USE_COMPLEX) /* Enforce converged conjugate complex eigenpairs */ if (nConv) { for (j=0;j<*nConv;j++) if (d->eigi[j] != 0.0) j++; if (j>*nConv) (*nConv)--; } #endif for (i=pre;ierrest[i] = d->nR[i] = PETSC_MAX_REAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_updateV_update_gen" static PetscErrorCode dvd_updateV_update_gen(dvdDashboard *d) { dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscInt size_D,s,lV,kV,nV; PetscErrorCode ierr; PetscFunctionBegin; /* Select the desired pairs */ ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); nV = kV - lV; size_D = PetscMin(PetscMin(PetscMin(d->bs,nV),d->eps->ncv-nV),nV); if (size_D == 0) PetscFunctionReturn(0); /* Fill V with D */ ierr = d->improveX(d,0,size_D,&size_D);CHKERRQ(ierr); /* If D is empty, exit */ d->size_D = size_D; if (size_D == 0) PetscFunctionReturn(0); /* Get the residual of all pairs */ #if !defined(PETSC_USE_COMPLEX) s = (d->eigi[0]!=0.0)? 2: 1; #else s = 1; #endif ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); nV = kV - lV; ierr = dvd_updateV_testConv(d,s,s,data->allResiduals?nV:size_D,NULL);CHKERRQ(ierr); /* Notify the changes in V */ d->V_tra_s = 0; d->V_tra_e = 0; d->V_new_s = nV; d->V_new_e = nV+size_D; /* Save the projected eigenvectors */ if (data->plusk > 0) { ierr = MatZeroEntries(data->oldU);CHKERRQ(ierr); data->size_oldU = nV; ierr = DSCopyMat(d->eps->ds,DS_MAT_Q,0,0,data->oldU,0,0,nV,nV,PETSC_TRUE);CHKERRQ(ierr); if (d->W) { ierr = MatZeroEntries(data->oldV);CHKERRQ(ierr); ierr = DSCopyMat(d->eps->ds,DS_MAT_Z,0,0,data->oldV,0,0,nV,nV,PETSC_TRUE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_updateV_extrapol" static PetscErrorCode dvd_updateV_extrapol(dvdDashboard *d) { dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data; PetscInt i; PetscBool restart; PetscErrorCode ierr; PetscFunctionBegin; /* TODO: restrict select pairs to each case */ ierr = d->calcpairs_selectPairs(d, data->min_size_V);CHKERRQ(ierr); /* If the subspaces doesn't need restart, add new vector */ ierr = d->isRestarting(d,&restart);CHKERRQ(ierr); if (!restart) { d->size_D = 0; ierr = dvd_updateV_update_gen(d);CHKERRQ(ierr); /* If some vector were add, exit */ if (d->size_D > 0) PetscFunctionReturn(0); } /* If some eigenpairs were converged, lock them */ if (d->npreconv > 0) { i = d->npreconv; ierr = dvd_updateV_conv_gen(d);CHKERRQ(ierr); /* If some eigenpair was locked, exit */ if (i > d->npreconv) PetscFunctionReturn(0); } /* Else, a restarting is performed */ ierr = dvd_updateV_restart_gen(d);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_managementV_basic" PetscErrorCode dvd_managementV_basic(dvdDashboard *d,dvdBlackboard *b,PetscInt bs,PetscInt mpd,PetscInt min_size_V,PetscInt plusk,PetscBool harm,PetscBool allResiduals) { PetscErrorCode ierr; dvdManagV_basic *data; #if !defined(PETSC_USE_COMPLEX) PetscBool her_probl,std_probl; #endif PetscFunctionBegin; /* Setting configuration constrains */ #if !defined(PETSC_USE_COMPLEX) /* if the last converged eigenvalue is complex its conjugate pair is also converged */ her_probl = DVD_IS(d->sEP,DVD_EP_HERMITIAN)? PETSC_TRUE: PETSC_FALSE; std_probl = DVD_IS(d->sEP,DVD_EP_STD)? PETSC_TRUE: PETSC_FALSE; b->max_size_X = PetscMax(b->max_size_X,bs+((her_probl && std_probl)?0:1)); #else b->max_size_X = PetscMax(b->max_size_X,bs); #endif b->max_size_V = PetscMax(b->max_size_V,mpd); min_size_V = PetscMin(min_size_V,mpd-bs); b->size_V = PetscMax(b->size_V,b->max_size_V+b->max_size_P+b->max_nev); b->max_size_oldX = plusk; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscNewLog(d->eps,&data);CHKERRQ(ierr); data->mpd = b->max_size_V; data->min_size_V = min_size_V; d->bs = bs; data->plusk = plusk; data->allResiduals = allResiduals; d->eigr = d->eps->eigr; d->eigi = d->eps->eigi; d->errest = d->eps->errest; ierr = PetscMalloc1(d->eps->ncv,&d->real_nR);CHKERRQ(ierr); ierr = PetscMalloc1(d->eps->ncv,&d->real_nX);CHKERRQ(ierr); if (plusk > 0) { ierr = MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&data->oldU);CHKERRQ(ierr); } else data->oldU = NULL; if (harm && plusk>0) { ierr = MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&data->oldV);CHKERRQ(ierr); } else data->oldV = NULL; data->old_updateV_data = d->updateV_data; d->updateV_data = data; data->old_isRestarting = d->isRestarting; d->isRestarting = dvd_isrestarting_fullV; d->updateV = dvd_updateV_extrapol; d->preTestConv = dvd_updateV_testConv; ierr = EPSDavidsonFLAdd(&d->startList,dvd_updateV_start);CHKERRQ(ierr); ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_managementV_basic_d);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/dvdupdatev.c.html0000644000175000017500000007164413107004621021765 0ustar jromanjroman
Actual source code: dvdupdatev.c

slepc-3.7.4 2017-05-17
  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Step: test for restarting, updateV, restartV

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

 10:    This file is part of SLEPc.

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

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

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

 26:  #include davidson.h

 28: typedef struct {
 29:   PetscInt          min_size_V;        /* restart with this number of eigenvectors */
 30:   PetscInt          plusk;             /* at restart, save plusk vectors from last iteration */
 31:   PetscInt          mpd;               /* max size of the searching subspace */
 32:   void              *old_updateV_data; /* old updateV data */
 33:   PetscErrorCode    (*old_isRestarting)(dvdDashboard*,PetscBool*);  /* old isRestarting */
 34:   Mat               oldU;              /* previous projected right igenvectors */
 35:   Mat               oldV;              /* previous projected left eigenvectors */
 36:   PetscInt          size_oldU;         /* size of oldU */
 37:   PetscBool         allResiduals;      /* if computing all the residuals */
 38: } dvdManagV_basic;

 42: static PetscErrorCode dvd_updateV_start(dvdDashboard *d)
 43: {
 44:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;
 45:   PetscInt        i;

 48:   for (i=0;i<d->eps->ncv;i++) d->eigi[i] = 0.0;
 49:   d->nR = d->real_nR;
 50:   for (i=0;i<d->eps->ncv;i++) d->nR[i] = PETSC_MAX_REAL;
 51:   d->nX = d->real_nX;
 52:   for (i=0;i<d->eps->ncv;i++) d->errest[i] = PETSC_MAX_REAL;
 53:   data->size_oldU = 0;
 54:   d->nconv = 0;
 55:   d->npreconv = 0;
 56:   d->V_tra_s = d->V_tra_e = d->V_new_s = d->V_new_e = 0;
 57:   d->size_D = 0;
 58:   return(0);
 59: }

 63: static PetscErrorCode dvd_isrestarting_fullV(dvdDashboard *d,PetscBool *r)
 64: {
 65:   PetscErrorCode  ierr;
 66:   PetscInt        l,k;
 67:   PetscBool       restart;
 68:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;

 71:   BVGetActiveColumns(d->eps->V,&l,&k);
 72:   restart = (k+2 > d->eps->ncv)? PETSC_TRUE: PETSC_FALSE;

 74:   /* Check old isRestarting function */
 75:   if (!restart && data->old_isRestarting) {
 76:     data->old_isRestarting(d,&restart);
 77:   }
 78:   *r = restart;
 79:   return(0);
 80: }

 84: static PetscErrorCode dvd_managementV_basic_d(dvdDashboard *d)
 85: {
 86:   PetscErrorCode  ierr;
 87:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;

 90:   /* Restore changes in dvdDashboard */
 91:   d->updateV_data = data->old_updateV_data;

 93:   /* Free local data */
 94:   if (data->oldU) { MatDestroy(&data->oldU); }
 95:   if (data->oldV) { MatDestroy(&data->oldV); }
 96:   PetscFree(d->real_nR);
 97:   PetscFree(d->real_nX);
 98:   PetscFree(data);
 99:   return(0);
100: }

104: static PetscErrorCode dvd_updateV_conv_gen(dvdDashboard *d)
105: {
106:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;
107:   PetscInt        npreconv,cMT,cMTX,lV,kV,nV;
108:   PetscErrorCode  ierr;
109:   Mat             Q;
110: #if !defined(PETSC_USE_COMPLEX)
111:   PetscInt        i;
112: #endif

115:   npreconv = d->npreconv;
116:   /* Constrains the converged pairs to nev */
117: #if !defined(PETSC_USE_COMPLEX)
118:   /* Tries to maintain together conjugate eigenpairs */
119:   for (i=0; (i + (d->eigi[i]!=0.0?1:0) < npreconv) && (d->nconv + i < d->nev); i+= (d->eigi[i]!=0.0?2:1));
120:   npreconv = i;
121: #else
122:   npreconv = PetscMax(PetscMin(d->nev-d->nconv,npreconv),0);
123: #endif
124:   /* Quick exit */
125:   if (npreconv == 0) return(0);

127:   BVGetActiveColumns(d->eps->V,&lV,&kV);
128:   nV  = kV - lV; 
129:   cMT = nV - npreconv;
130:   /* Harmonics restarts wiht right eigenvectors, and other with the left ones.
131:      If the problem is standard or hermitian, left and right vectors are the same */
132:   if (!(d->W||DVD_IS(d->sEP,DVD_EP_STD)||DVD_IS(d->sEP,DVD_EP_HERMITIAN))) {
133:     /* ps.Q <- [ps.Q(0:npreconv-1) ps.Z(npreconv:size_H-1)] */
134:     DSGetMat(d->eps->ds,DS_MAT_Q,&Q);
135:     DSCopyMat(d->eps->ds,DS_MAT_Z,0,npreconv,Q,0,npreconv,nV,cMT,PETSC_TRUE);
136:     DSRestoreMat(d->eps->ds,DS_MAT_Q,&Q);
137:   }
138:   if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) {
139:     DSPseudoOrthogonalize(d->eps->ds,DS_MAT_Q,nV,d->nBds,&cMTX,d->nBds);
140:   } else {
141:     DSOrthogonalize(d->eps->ds,DS_MAT_Q,nV,&cMTX);
142:   }
143:   cMT = cMTX - npreconv;

145:   if (d->W) {
146:     DSOrthogonalize(d->eps->ds,DS_MAT_Z,nV,&cMTX);
147:     cMT = PetscMin(cMT,cMTX - npreconv);
148:   }

150:   /* Lock the converged pairs */
151:   d->eigr+= npreconv;
152: #if !defined(PETSC_USE_COMPLEX)
153:   if (d->eigi) d->eigi+= npreconv;
154: #endif
155:   d->nconv+= npreconv;
156:   d->errest+= npreconv;
157:   /* Notify the changes in V and update the other subspaces */
158:   d->V_tra_s = npreconv;          d->V_tra_e = nV;
159:   d->V_new_s = cMT;               d->V_new_e = d->V_new_s;
160:   /* Remove oldU */
161:   data->size_oldU = 0;

163:   d->npreconv-= npreconv;
164:   return(0);
165: }

169: static PetscErrorCode dvd_updateV_restart_gen(dvdDashboard *d)
170: {
171:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;
172:   PetscInt        lV,kV,nV,size_plusk,size_X,cMTX,cMTY;
173:   Mat             Q;
174:   PetscErrorCode  ierr;

177:   /* Select size_X desired pairs from V */
178:   BVGetActiveColumns(d->eps->V,&lV,&kV);
179:   nV = kV - lV;
180:   size_X = PetscMin(data->min_size_V,nV);

182:   /* Add plusk eigenvectors from the previous iteration */
183:   size_plusk = PetscMax(0,PetscMin(PetscMin(data->plusk,data->size_oldU),d->eps->ncv - size_X));

185:   d->size_MT = nV;
186:   /* ps.Q <- orth([pX(0:size_X-1) [oldU(0:size_plusk-1); 0] ]) */
187:   /* Harmonics restarts wiht right eigenvectors, and other with the left ones.
188:      If the problem is standard or hermitian, left and right vectors are the same */
189:   if (!(d->W||DVD_IS(d->sEP,DVD_EP_STD)||DVD_IS(d->sEP,DVD_EP_HERMITIAN))) {
190:     DSGetMat(d->eps->ds,DS_MAT_Q,&Q);
191:     DSCopyMat(d->eps->ds,DS_MAT_Z,0,0,Q,0,0,nV,size_X,PETSC_TRUE);
192:     DSRestoreMat(d->eps->ds,DS_MAT_Q,&Q);
193:   }
194:   if (size_plusk > 0 && DVD_IS(d->sEP,DVD_EP_INDEFINITE)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Unsupported plusk>0 in indefinite eigenvalue problems");
195:   if (size_plusk > 0) {
196:     DSCopyMat(d->eps->ds,DS_MAT_Q,0,size_X,data->oldU,0,0,nV,size_plusk,PETSC_FALSE);
197:   }
198:   if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) {
199:     DSPseudoOrthogonalize(d->eps->ds,DS_MAT_Q,size_X,d->nBds,&cMTX,d->nBds);
200:   } else {
201:     DSOrthogonalize(d->eps->ds,DS_MAT_Q,size_X+size_plusk,&cMTX);
202:   }

204:   if (d->W && size_plusk > 0) {
205:     /* ps.Z <- orth([ps.Z(0:size_X-1) [oldV(0:size_plusk-1); 0] ]) */
206:     DSCopyMat(d->eps->ds,DS_MAT_Z,0,size_X,data->oldV,0,0,nV,size_plusk,PETSC_FALSE);
207:     DSOrthogonalize(d->eps->ds,DS_MAT_Z,size_X+size_plusk,&cMTY);
208:     cMTX = PetscMin(cMTX, cMTY);
209:   }

211:   /* Notify the changes in V and update the other subspaces */
212:   d->V_tra_s = 0;                     d->V_tra_e = cMTX;
213:   d->V_new_s = d->V_tra_e;            d->V_new_e = d->V_new_s;

215:   /* Remove oldU */
216:   data->size_oldU = 0;

218:   /* Remove npreconv */
219:   d->npreconv = 0;
220:   return(0);
221: }

225: static PetscErrorCode dvd_updateV_testConv(dvdDashboard *d,PetscInt s,PetscInt pre,PetscInt e,PetscInt *nConv)
226: {
227:   PetscInt        i,j,b;
228:   PetscReal       norm;
229:   PetscErrorCode  ierr;
230:   PetscBool       conv, c;
231:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;

234:   if (nConv) *nConv = s;
235:   for (i=s,conv=PETSC_TRUE;(conv || data->allResiduals) && (i < e);i+=b) {
236: #if !defined(PETSC_USE_COMPLEX)
237:     b = d->eigi[i]!=0.0?2:1;
238: #else
239:     b = 1;
240: #endif
241:     if (i+b-1 >= pre) {
242:       d->calcpairs_residual(d,i,i+b);
243:     }
244:     /* Test the Schur vector */
245:     for (j=0,c=PETSC_TRUE;j<b && c;j++) {
246:       norm = d->nR[i+j]/d->nX[i+j];
247:       c = d->testConv(d,d->eigr[i+j],d->eigi[i+j],norm,&d->errest[i+j]);
248:     }
249:     if (conv && c) { if (nConv) *nConv = i+b; }
250:     else conv = PETSC_FALSE;
251:   }
252:   pre = PetscMax(pre,i);

254: #if !defined(PETSC_USE_COMPLEX)
255:   /* Enforce converged conjugate complex eigenpairs */
256:   if (nConv) {
257:     for (j=0;j<*nConv;j++) if (d->eigi[j] != 0.0) j++;
258:     if (j>*nConv) (*nConv)--;
259:   }
260: #endif
261:   for (i=pre;i<e;i++) d->errest[i] = d->nR[i] = PETSC_MAX_REAL;
262:   return(0);
263: }

267: static PetscErrorCode dvd_updateV_update_gen(dvdDashboard *d)
268: {
269:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;
270:   PetscInt        size_D,s,lV,kV,nV;
271:   PetscErrorCode  ierr;

274:   /* Select the desired pairs */
275:   BVGetActiveColumns(d->eps->V,&lV,&kV);
276:   nV = kV - lV;
277:   size_D = PetscMin(PetscMin(PetscMin(d->bs,nV),d->eps->ncv-nV),nV);
278:   if (size_D == 0) return(0);

280:   /* Fill V with D */
281:   d->improveX(d,0,size_D,&size_D);

283:   /* If D is empty, exit */
284:   d->size_D = size_D;
285:   if (size_D == 0) return(0);

287:   /* Get the residual of all pairs */
288: #if !defined(PETSC_USE_COMPLEX)
289:   s = (d->eigi[0]!=0.0)? 2: 1;
290: #else
291:   s = 1;
292: #endif
293:   BVGetActiveColumns(d->eps->V,&lV,&kV);
294:   nV = kV - lV;
295:   dvd_updateV_testConv(d,s,s,data->allResiduals?nV:size_D,NULL);

297:   /* Notify the changes in V */
298:   d->V_tra_s = 0;                 d->V_tra_e = 0;
299:   d->V_new_s = nV;                d->V_new_e = nV+size_D;

301:   /* Save the projected eigenvectors */
302:   if (data->plusk > 0) {
303:     MatZeroEntries(data->oldU);
304:     data->size_oldU = nV;
305:     DSCopyMat(d->eps->ds,DS_MAT_Q,0,0,data->oldU,0,0,nV,nV,PETSC_TRUE);
306:     if (d->W) {
307:       MatZeroEntries(data->oldV);
308:       DSCopyMat(d->eps->ds,DS_MAT_Z,0,0,data->oldV,0,0,nV,nV,PETSC_TRUE);
309:     }
310:   }
311:   return(0);
312: }

316: static PetscErrorCode dvd_updateV_extrapol(dvdDashboard *d)
317: {
318:   dvdManagV_basic *data = (dvdManagV_basic*)d->updateV_data;
319:   PetscInt        i;
320:   PetscBool       restart;
321:   PetscErrorCode  ierr;

324:   /* TODO: restrict select pairs to each case */
325:   d->calcpairs_selectPairs(d, data->min_size_V);

327:   /* If the subspaces doesn't need restart, add new vector */
328:   d->isRestarting(d,&restart);
329:   if (!restart) {
330:     d->size_D = 0;
331:     dvd_updateV_update_gen(d);

333:     /* If some vector were add, exit */
334:     if (d->size_D > 0) return(0);
335:   }

337:   /* If some eigenpairs were converged, lock them  */
338:   if (d->npreconv > 0) {
339:     i = d->npreconv;
340:     dvd_updateV_conv_gen(d);

342:     /* If some eigenpair was locked, exit */
343:     if (i > d->npreconv) return(0);
344:   }

346:   /* Else, a restarting is performed */
347:   dvd_updateV_restart_gen(d);
348:   return(0);
349: }

353: PetscErrorCode dvd_managementV_basic(dvdDashboard *d,dvdBlackboard *b,PetscInt bs,PetscInt mpd,PetscInt min_size_V,PetscInt plusk,PetscBool harm,PetscBool allResiduals)
354: {
355:   PetscErrorCode  ierr;
356:   dvdManagV_basic *data;
357: #if !defined(PETSC_USE_COMPLEX)
358:   PetscBool       her_probl,std_probl;
359: #endif

362:   /* Setting configuration constrains */
363: #if !defined(PETSC_USE_COMPLEX)
364:   /* if the last converged eigenvalue is complex its conjugate pair is also
365:      converged */
366:   her_probl = DVD_IS(d->sEP,DVD_EP_HERMITIAN)? PETSC_TRUE: PETSC_FALSE;
367:   std_probl = DVD_IS(d->sEP,DVD_EP_STD)? PETSC_TRUE: PETSC_FALSE;
368:   b->max_size_X = PetscMax(b->max_size_X,bs+((her_probl && std_probl)?0:1));
369: #else
370:   b->max_size_X = PetscMax(b->max_size_X,bs);
371: #endif

373:   b->max_size_V = PetscMax(b->max_size_V,mpd);
374:   min_size_V = PetscMin(min_size_V,mpd-bs);
375:   b->size_V = PetscMax(b->size_V,b->max_size_V+b->max_size_P+b->max_nev);
376:   b->max_size_oldX = plusk;

378:   /* Setup the step */
379:   if (b->state >= DVD_STATE_CONF) {
380:     PetscNewLog(d->eps,&data);
381:     data->mpd = b->max_size_V;
382:     data->min_size_V = min_size_V;
383:     d->bs = bs;
384:     data->plusk = plusk;
385:     data->allResiduals = allResiduals;

387:     d->eigr = d->eps->eigr;
388:     d->eigi = d->eps->eigi;
389:     d->errest = d->eps->errest;
390:     PetscMalloc1(d->eps->ncv,&d->real_nR);
391:     PetscMalloc1(d->eps->ncv,&d->real_nX);
392:     if (plusk > 0) { MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&data->oldU); }
393:     else data->oldU = NULL;
394:     if (harm && plusk>0) { MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&data->oldV); }
395:     else data->oldV = NULL;

397:     data->old_updateV_data = d->updateV_data;
398:     d->updateV_data = data;
399:     data->old_isRestarting = d->isRestarting;
400:     d->isRestarting = dvd_isrestarting_fullV;
401:     d->updateV = dvd_updateV_extrapol;
402:     d->preTestConv = dvd_updateV_testConv;
403:     EPSDavidsonFLAdd(&d->startList,dvd_updateV_start);
404:     EPSDavidsonFLAdd(&d->destroyList,dvd_managementV_basic_d);
405:   }
406:   return(0);
407: }

slepc-3.7.4/src/eps/impls/davidson/makefile.html0000644000175000017500000000506613107004621021146 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = davidson.c dvdcalcpairs.c dvdimprovex.c dvdinitv.c \
           dvdschm.c dvdtestconv.c dvdupdatev.c dvdutils.c dvdgd2.c
SOURCEF  =
SOURCEH  = davidson.h
LIBBASE  = libslepceps
DIRS     = gd jd
LOCDIR   = src/eps/impls/davidson/
MANSEC   = EPS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/davidson/dvdgd2.c0000644000175000017500000002050713107004621020016 0ustar jromanjroman/* SLEPc eigensolver: "davidson" Step: improve the eigenvectors X with GD2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" typedef struct { PetscInt size_X; } dvdImprovex_gd2; #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_gd2_d" static PetscErrorCode dvd_improvex_gd2_d(dvdDashboard *d) { PetscErrorCode ierr; dvdImprovex_gd2 *data = (dvdImprovex_gd2*)d->improveX_data; PetscFunctionBegin; /* Free local data and objects */ ierr = PetscFree(data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_gd2_gen" static PetscErrorCode dvd_improvex_gd2_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D) { dvdImprovex_gd2 *data = (dvdImprovex_gd2*)d->improveX_data; PetscErrorCode ierr; PetscInt i,j,n,s,ld,k,lv,kv,max_size_D; PetscScalar *pX,*b; Vec *Ax,*Bx,v,*x; Mat M; BV X; PetscFunctionBegin; /* Compute the number of pairs to improve */ ierr = BVGetActiveColumns(d->eps->V,&lv,&kv);CHKERRQ(ierr); max_size_D = d->eps->ncv-kv; n = PetscMin(PetscMin(data->size_X*2,max_size_D),(r_e-r_s)*2)/2; #if !defined(PETSC_USE_COMPLEX) /* If the last eigenvalue is a complex conjugate pair, n is increased by one */ for (i=0; ieigi[i] != 0.0) i++; } if (i > n) { n = PetscMin(PetscMin(data->size_X*2,max_size_D),(n+1)*2)/2; if (i > n) n--; } #endif /* Quick exit */ if (max_size_D == 0 || r_e-r_s <= 0 || n == 0) { *size_D = 0; PetscFunctionReturn(0); } ierr = BVDuplicateResize(d->eps->V,4,&X);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,4,2,NULL,&M);CHKERRQ(ierr); /* Compute the eigenvectors of the selected pairs */ for (i=0;ieps->ds,DS_MAT_X,&k,NULL);CHKERRQ(ierr); i = k+1; /* skip complex conjugate pairs */ } ierr = DSGetArray(d->eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = DSGetLeadingDimension(d->eps->ds,&ld);CHKERRQ(ierr); ierr = SlepcVecPoolGetVecs(d->auxV,n,&Ax);CHKERRQ(ierr); ierr = SlepcVecPoolGetVecs(d->auxV,n,&Bx);CHKERRQ(ierr); /* Bx <- B*X(i) */ if (d->BX) { /* Compute the norms of the eigenvectors */ if (d->correctXnorm) { ierr = dvd_improvex_compute_X(d,r_s,r_s+n,Bx,pX,ld);CHKERRQ(ierr); } else { for (i=0;inX[r_s+i] = 1.0; } for (i=0;iBX,1.0,0.0,Bx[i],&pX[ld*(r_s+i)]);CHKERRQ(ierr); } } else if (d->B) { ierr = SlepcVecPoolGetVecs(d->auxV,1,&x);CHKERRQ(ierr); for (i=0;iB,x[0],Bx[i]);CHKERRQ(ierr); } ierr = SlepcVecPoolRestoreVecs(d->auxV,1,&x);CHKERRQ(ierr); } else { /* Bx <- X */ ierr = dvd_improvex_compute_X(d,r_s,r_s+n,Bx,pX,ld);CHKERRQ(ierr); } /* Ax <- A*X(i) */ for (i=0;iAX,1.0,0.0,Ax[i],&pX[ld*(i+r_s)]);CHKERRQ(ierr); } ierr = DSRestoreArray(d->eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); for (i=0,s=0;ieigi[r_s+i] != 0.0) { /* [Ax_i Ax_i+1 Bx_i Bx_i+1]*= [ 1 0 0 1 -eigr_i -eigi_i eigi_i -eigr_i] */ ierr = MatDenseGetArray(M,&b);CHKERRQ(ierr); b[0] = b[5] = 1.0/d->nX[r_s+i]; b[2] = b[7] = -d->eigr[r_s+i]/d->nX[r_s+i]; b[6] = -(b[3] = d->eigi[r_s+i]/d->nX[r_s+i]); b[1] = b[4] = 0.0; ierr = MatDenseRestoreArray(M,&b);CHKERRQ(ierr); ierr = BVInsertVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,1,Ax[i+1]);CHKERRQ(ierr); ierr = BVInsertVec(X,2,Bx[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,3,Bx[i+1]);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,0,4);CHKERRQ(ierr); ierr = BVMultInPlace(X,M,0,2);CHKERRQ(ierr); ierr = BVCopyVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVCopyVec(X,1,Ax[i+1]);CHKERRQ(ierr); s = 2; } else #endif { /* [Ax_i Bx_i]*= [ 1/nX_i conj(eig_i/nX_i) -eig_i/nX_i 1/nX_i ] */ ierr = MatDenseGetArray(M,&b);CHKERRQ(ierr); b[0] = 1.0/d->nX[r_s+i]; b[1] = -d->eigr[r_s+i]/d->nX[r_s+i]; b[4] = PetscConj(d->eigr[r_s+i]/d->nX[r_s+i]); b[5] = 1.0/d->nX[r_s+i]; ierr = MatDenseRestoreArray(M,&b);CHKERRQ(ierr); ierr = BVInsertVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVInsertVec(X,1,Bx[i]);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,0,2);CHKERRQ(ierr); ierr = BVMultInPlace(X,M,0,2);CHKERRQ(ierr); ierr = BVCopyVec(X,0,Ax[i]);CHKERRQ(ierr); ierr = BVCopyVec(X,1,Bx[i]);CHKERRQ(ierr); s = 1; } for (j=0;jnX[r_s+i+j] = 1.0; /* Ax = R <- P*(Ax - eig_i*Bx) */ ierr = d->calcpairs_proj_res(d,r_s+i,r_s+i+s,&Ax[i]);CHKERRQ(ierr); /* Check if the first eigenpairs are converged */ if (i == 0) { ierr = d->preTestConv(d,0,s,s,&d->npreconv);CHKERRQ(ierr); if (d->npreconv > 0) break; } } /* D <- K*[Ax Bx] */ if (d->npreconv == 0) { for (i=0;ieps->V,kv+i,&v);CHKERRQ(ierr); ierr = d->improvex_precond(d,r_s+i,Ax[i],v);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,kv+i,&v);CHKERRQ(ierr); } for (i=n;ieps->V,kv+i,&v);CHKERRQ(ierr); ierr = d->improvex_precond(d,r_s+i-n,Bx[i-n],v);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,kv+i,&v);CHKERRQ(ierr); } *size_D = 2*n; #if !defined(PETSC_USE_COMPLEX) if (d->eigi[r_s] != 0.0) { s = 4; } else #endif { s = 2; } /* Prevent that short vectors are discarded in the orthogonalization */ for (i=0; ieps->errest[d->nconv+r_s+i] > PETSC_MACHINE_EPSILON && d->eps->errest[d->nconv+r_s+i] < PETSC_MAX_REAL) { ierr = BVScaleColumn(d->eps->V,i+kv,1.0/d->eps->errest[d->nconv+r_s+i]);CHKERRQ(ierr); } } } else *size_D = 0; ierr = SlepcVecPoolRestoreVecs(d->auxV,n,&Bx);CHKERRQ(ierr); ierr = SlepcVecPoolRestoreVecs(d->auxV,n,&Ax);CHKERRQ(ierr); ierr = BVDestroy(&X);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_improvex_gd2" PetscErrorCode dvd_improvex_gd2(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs) { PetscErrorCode ierr; dvdImprovex_gd2 *data; PC pc; PetscFunctionBegin; /* Setting configuration constrains */ /* If the arithmetic is real and the problem is not Hermitian, then the block size is incremented in one */ #if !defined(PETSC_USE_COMPLEX) if (!DVD_IS(d->sEP, DVD_EP_HERMITIAN)) { max_bs++; b->max_size_P = PetscMax(b->max_size_P,2); } else #endif { b->max_size_P = PetscMax(b->max_size_P,1); } b->max_size_X = PetscMax(b->max_size_X,max_bs); /* Setup the preconditioner */ if (ksp) { ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = dvd_static_precond_PC(d,b,pc);CHKERRQ(ierr); } else { ierr = dvd_static_precond_PC(d,b,0);CHKERRQ(ierr); } /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscNewLog(d->eps,&data);CHKERRQ(ierr); d->improveX_data = data; data->size_X = b->max_size_X; d->improveX = dvd_improvex_gd2_gen; ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_improvex_gd2_d);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/dvdgd2.c.html0000644000175000017500000004675713107004621021000 0ustar jromanjroman
Actual source code: dvdgd2.c

slepc-3.7.4 2017-05-17
  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Step: improve the eigenvectors X with GD2

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

 10:    This file is part of SLEPc.

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

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

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

 26:  #include davidson.h

 28: typedef struct {
 29:   PetscInt size_X;
 30: } dvdImprovex_gd2;

 34: static PetscErrorCode dvd_improvex_gd2_d(dvdDashboard *d)
 35: {
 36:   PetscErrorCode  ierr;
 37:   dvdImprovex_gd2 *data = (dvdImprovex_gd2*)d->improveX_data;

 40:   /* Free local data and objects */
 41:   PetscFree(data);
 42:   return(0);
 43: }

 47: static PetscErrorCode dvd_improvex_gd2_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D)
 48: {
 49:   dvdImprovex_gd2 *data = (dvdImprovex_gd2*)d->improveX_data;
 50:   PetscErrorCode  ierr;
 51:   PetscInt        i,j,n,s,ld,k,lv,kv,max_size_D;
 52:   PetscScalar     *pX,*b;
 53:   Vec             *Ax,*Bx,v,*x;
 54:   Mat             M;
 55:   BV              X;

 58:   /* Compute the number of pairs to improve */
 59:   BVGetActiveColumns(d->eps->V,&lv,&kv);
 60:   max_size_D = d->eps->ncv-kv;
 61:   n = PetscMin(PetscMin(data->size_X*2,max_size_D),(r_e-r_s)*2)/2;
 62: #if !defined(PETSC_USE_COMPLEX)
 63:   /* If the last eigenvalue is a complex conjugate pair, n is increased by one */
 64:   for (i=0; i<n; i++) {
 65:     if (d->eigi[i] != 0.0) i++;
 66:   }
 67:   if (i > n) {
 68:     n = PetscMin(PetscMin(data->size_X*2,max_size_D),(n+1)*2)/2;
 69:     if (i > n) n--;
 70:   }
 71: #endif

 73:   /* Quick exit */
 74:   if (max_size_D == 0 || r_e-r_s <= 0 || n == 0) {
 75:    *size_D = 0;
 76:     return(0);
 77:   }

 79:   BVDuplicateResize(d->eps->V,4,&X);
 80:   MatCreateSeqDense(PETSC_COMM_SELF,4,2,NULL,&M);

 82:   /* Compute the eigenvectors of the selected pairs */
 83:   for (i=0;i<n;) {
 84:     k = r_s+i;
 85:     DSVectors(d->eps->ds,DS_MAT_X,&k,NULL);
 86:     i = k+1; /* skip complex conjugate pairs */
 87:   }
 88:   DSGetArray(d->eps->ds,DS_MAT_X,&pX);
 89:   DSGetLeadingDimension(d->eps->ds,&ld);

 91:   SlepcVecPoolGetVecs(d->auxV,n,&Ax);
 92:   SlepcVecPoolGetVecs(d->auxV,n,&Bx);

 94:   /* Bx <- B*X(i) */
 95:   if (d->BX) {
 96:     /* Compute the norms of the eigenvectors */
 97:     if (d->correctXnorm) {
 98:       dvd_improvex_compute_X(d,r_s,r_s+n,Bx,pX,ld);
 99:     } else {
100:       for (i=0;i<n;i++) d->nX[r_s+i] = 1.0;
101:     }
102:     for (i=0;i<n;i++) {
103:       BVMultVec(d->BX,1.0,0.0,Bx[i],&pX[ld*(r_s+i)]);
104:     }
105:   } else if (d->B) {
106:     SlepcVecPoolGetVecs(d->auxV,1,&x);
107:     for (i=0;i<n;i++) {
108:       /* auxV(0) <- X(i) */
109:       dvd_improvex_compute_X(d,r_s+i,r_s+i+1,x,pX,ld);
110:       /* Bx(i) <- B*auxV(0) */
111:       MatMult(d->B,x[0],Bx[i]);
112:     }
113:     SlepcVecPoolRestoreVecs(d->auxV,1,&x);
114:   } else {
115:     /* Bx <- X */
116:     dvd_improvex_compute_X(d,r_s,r_s+n,Bx,pX,ld);
117:   }

119:   /* Ax <- A*X(i) */
120:   for (i=0;i<n;i++) {
121:     BVMultVec(d->AX,1.0,0.0,Ax[i],&pX[ld*(i+r_s)]);
122:   }

124:   DSRestoreArray(d->eps->ds,DS_MAT_X,&pX);

126:   for (i=0,s=0;i<n;i+=s) {
127: #if !defined(PETSC_USE_COMPLEX)
128:     if (d->eigi[r_s+i] != 0.0) {
129:        /* [Ax_i Ax_i+1 Bx_i Bx_i+1]*= [   1        0
130:                                           0        1
131:                                        -eigr_i -eigi_i
132:                                         eigi_i -eigr_i] */
133:       MatDenseGetArray(M,&b);
134:       b[0] = b[5] = 1.0/d->nX[r_s+i];
135:       b[2] = b[7] = -d->eigr[r_s+i]/d->nX[r_s+i];
136:       b[6] = -(b[3] = d->eigi[r_s+i]/d->nX[r_s+i]);
137:       b[1] = b[4] = 0.0;
138:       MatDenseRestoreArray(M,&b);
139:       BVInsertVec(X,0,Ax[i]);
140:       BVInsertVec(X,1,Ax[i+1]);
141:       BVInsertVec(X,2,Bx[i]);
142:       BVInsertVec(X,3,Bx[i+1]);
143:       BVSetActiveColumns(X,0,4);
144:       BVMultInPlace(X,M,0,2);
145:       BVCopyVec(X,0,Ax[i]);
146:       BVCopyVec(X,1,Ax[i+1]);
147:       s = 2;
148:     } else
149: #endif
150:     {
151:       /* [Ax_i Bx_i]*= [ 1/nX_i    conj(eig_i/nX_i)
152:                        -eig_i/nX_i     1/nX_i       ] */
153:       MatDenseGetArray(M,&b);
154:       b[0] = 1.0/d->nX[r_s+i];
155:       b[1] = -d->eigr[r_s+i]/d->nX[r_s+i];
156:       b[4] = PetscConj(d->eigr[r_s+i]/d->nX[r_s+i]);
157:       b[5] = 1.0/d->nX[r_s+i];
158:       MatDenseRestoreArray(M,&b);
159:       BVInsertVec(X,0,Ax[i]);
160:       BVInsertVec(X,1,Bx[i]);
161:       BVSetActiveColumns(X,0,2);
162:       BVMultInPlace(X,M,0,2);
163:       BVCopyVec(X,0,Ax[i]);
164:       BVCopyVec(X,1,Bx[i]);
165:       s = 1;
166:     }
167:     for (j=0;j<s;j++) d->nX[r_s+i+j] = 1.0;

169:     /* Ax = R <- P*(Ax - eig_i*Bx) */
170:     d->calcpairs_proj_res(d,r_s+i,r_s+i+s,&Ax[i]);

172:     /* Check if the first eigenpairs are converged */
173:     if (i == 0) {
174:       d->preTestConv(d,0,s,s,&d->npreconv);
175:       if (d->npreconv > 0) break;
176:     }
177:   }

179:   /* D <- K*[Ax Bx] */
180:   if (d->npreconv == 0) {
181:     for (i=0;i<n;i++) {
182:       BVGetColumn(d->eps->V,kv+i,&v);
183:       d->improvex_precond(d,r_s+i,Ax[i],v);
184:       BVRestoreColumn(d->eps->V,kv+i,&v);
185:     }
186:     for (i=n;i<n*2;i++) {
187:       BVGetColumn(d->eps->V,kv+i,&v);
188:       d->improvex_precond(d,r_s+i-n,Bx[i-n],v);
189:       BVRestoreColumn(d->eps->V,kv+i,&v);
190:     }
191:     *size_D = 2*n;
192: #if !defined(PETSC_USE_COMPLEX)
193:     if (d->eigi[r_s] != 0.0) {
194:       s = 4;
195:     } else
196: #endif
197:     {
198:       s = 2;
199:     }
200:     /* Prevent that short vectors are discarded in the orthogonalization */
201:     for (i=0; i<s && i<*size_D; i++) {
202:       if (d->eps->errest[d->nconv+r_s+i] > PETSC_MACHINE_EPSILON && d->eps->errest[d->nconv+r_s+i] < PETSC_MAX_REAL) {
203:         BVScaleColumn(d->eps->V,i+kv,1.0/d->eps->errest[d->nconv+r_s+i]);
204:       }
205:     }
206:   } else *size_D = 0;

208:   SlepcVecPoolRestoreVecs(d->auxV,n,&Bx);
209:   SlepcVecPoolRestoreVecs(d->auxV,n,&Ax);
210:   BVDestroy(&X);
211:   MatDestroy(&M);
212:   return(0);
213: }

217: PetscErrorCode dvd_improvex_gd2(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs)
218: {
219:   PetscErrorCode  ierr;
220:   dvdImprovex_gd2 *data;
221:   PC              pc;

224:   /* Setting configuration constrains */
225:   /* If the arithmetic is real and the problem is not Hermitian, then
226:      the block size is incremented in one */
227: #if !defined(PETSC_USE_COMPLEX)
228:   if (!DVD_IS(d->sEP, DVD_EP_HERMITIAN)) {
229:     max_bs++;
230:     b->max_size_P = PetscMax(b->max_size_P,2);
231:   } else
232: #endif
233:   {
234:     b->max_size_P = PetscMax(b->max_size_P,1);
235:   }
236:   b->max_size_X = PetscMax(b->max_size_X,max_bs);

238:   /* Setup the preconditioner */
239:   if (ksp) {
240:     KSPGetPC(ksp,&pc);
241:     dvd_static_precond_PC(d,b,pc);
242:   } else {
243:     dvd_static_precond_PC(d,b,0);
244:   }

246:   /* Setup the step */
247:   if (b->state >= DVD_STATE_CONF) {
248:     PetscNewLog(d->eps,&data);
249:     d->improveX_data = data;
250:     data->size_X = b->max_size_X;
251:     d->improveX = dvd_improvex_gd2_gen;

253:     EPSDavidsonFLAdd(&d->destroyList,dvd_improvex_gd2_d);
254:   }
255:   return(0);
256: }

slepc-3.7.4/src/eps/impls/davidson/jd/0000755000175000017500000000000013107004621017071 5ustar jromanjromanslepc-3.7.4/src/eps/impls/davidson/jd/makefile0000644000175000017500000000215613107004621020575 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = jd.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/davidson/jd/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/davidson/jd/jd.c0000644000175000017500000006411313107004621017637 0ustar jromanjroman/* SLEPc eigensolver: "jd" Method: Jacobi-Davidson Algorithm: Jacobi-Davidson with various subspace extraction and restart techniques. References: [1] G.L.G. Sleijpen and H.A. van der Vorst, "A Jacobi-Davidson iteration method for linear eigenvalue problems", SIAM J. Matrix Anal. Appl. 17(2):401-425, 1996. [2] E. Romero and J.E. Roman, "A parallel implementation of Davidson methods for large-scale eigenvalue problems in SLEPc", ACM Trans. Math. Software 40(2), Article 13, 2014. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include <../src/eps/impls/davidson/davidson.h> #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_JD" PetscErrorCode EPSSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; PetscBool flg,op; PetscInt opi,opi0; PetscReal opf; KSP ksp; PetscBool orth; const char *orth_list[2] = {"I","B"}; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS Jacobi-Davidson (JD) Options");CHKERRQ(ierr); ierr = EPSJDGetKrylovStart(eps,&op);CHKERRQ(ierr); ierr = PetscOptionsBool("-eps_jd_krylov_start","Start the searching subspace with a krylov basis","EPSJDSetKrylovStart",op,&op,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetKrylovStart(eps,op);CHKERRQ(ierr); } ierr = EPSJDGetBlockSize(eps,&opi);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_jd_blocksize","Number vectors add to the searching subspace","EPSJDSetBlockSize",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetBlockSize(eps,opi);CHKERRQ(ierr); } ierr = EPSJDGetRestart(eps,&opi,&opi0);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_jd_minv","Set the size of the searching subspace after restarting","EPSJDSetRestart",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetRestart(eps,opi,opi0);CHKERRQ(ierr); } ierr = PetscOptionsInt("-eps_jd_plusk","Set the number of saved eigenvectors from the previous iteration when restarting","EPSJDSetRestart",opi0,&opi0,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetRestart(eps,opi,opi0);CHKERRQ(ierr); } ierr = EPSJDGetInitialSize(eps,&opi);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_jd_initial_size","Set the initial size of the searching subspace","EPSJDSetInitialSize",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetInitialSize(eps,opi);CHKERRQ(ierr); } ierr = EPSJDGetFix(eps,&opf);CHKERRQ(ierr); ierr = PetscOptionsReal("-eps_jd_fix","Set the tolerance for changing the target in the correction equation","EPSJDSetFix",opf,&opf,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetFix(eps,opf);CHKERRQ(ierr); } ierr = EPSJDGetBOrth(eps,&orth);CHKERRQ(ierr); ierr = PetscOptionsEList("-eps_jd_borth","orthogonalization used in the search subspace","EPSJDSetBOrth",orth_list,2,orth_list[orth?1:0],&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetBOrth(eps,opi==1?PETSC_TRUE:PETSC_FALSE);CHKERRQ(ierr); } ierr = EPSJDGetConstCorrectionTol(eps,&op);CHKERRQ(ierr); ierr = PetscOptionsBool("-eps_jd_const_correction_tol","Disable the dynamic stopping criterion when solving the correction equation","EPSJDSetConstCorrectionTol",op,&op,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetConstCorrectionTol(eps,op);CHKERRQ(ierr); } ierr = EPSJDGetWindowSizes(eps,&opi,&opi0);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_jd_pwindow","(Experimental!) Set the number of converged vectors in the projector","EPSJDSetWindowSizes",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); } ierr = PetscOptionsInt("-eps_jd_qwindow","(Experimental!) Set the number of converged vectors in the projected problem","EPSJDSetWindowSizes",opi0,&opi0,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSJDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); } /* Set STPrecond as the default ST */ if (!((PetscObject)eps->st)->type_name) { ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); } ierr = STPrecondSetKSPHasMat(eps->st,PETSC_FALSE);CHKERRQ(ierr); /* Set the default options of the KSP */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPBCGSL);CHKERRQ(ierr); ierr = KSPSetTolerances(ksp,1e-4,PETSC_DEFAULT,PETSC_DEFAULT,90);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_JD" PetscErrorCode EPSSetUp_JD(EPS eps) { PetscErrorCode ierr; PetscBool t; KSP ksp; PetscFunctionBegin; /* Setup common for all davidson solvers */ ierr = EPSSetUp_XD(eps);CHKERRQ(ierr); /* Set the default options of the KSP */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPBCGSL);CHKERRQ(ierr); ierr = KSPSetTolerances(ksp,1e-4,PETSC_DEFAULT,PETSC_DEFAULT,90);CHKERRQ(ierr); } /* Check some constraints */ ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&t);CHKERRQ(ierr); if (t) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"EPSJD does not work with KSPPREONLY"); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_JD" PetscErrorCode EPSView_JD(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii,opb; PetscInt opi,opi0; PetscBool borth; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = EPSXDGetBOrth_XD(eps,&borth);CHKERRQ(ierr); if (borth) { ierr = PetscViewerASCIIPrintf(viewer," JD: search subspace is B-orthogonalized\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," JD: search subspace is orthogonalized\n");CHKERRQ(ierr); } ierr = EPSXDGetBlockSize_XD(eps,&opi);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," JD: block size=%D\n",opi);CHKERRQ(ierr); ierr = EPSXDGetKrylovStart_XD(eps,&opb);CHKERRQ(ierr); if (!opb) { ierr = PetscViewerASCIIPrintf(viewer," JD: type of the initial subspace: non-Krylov\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," JD: type of the initial subspace: Krylov\n");CHKERRQ(ierr); } ierr = EPSXDGetRestart_XD(eps,&opi,&opi0);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," JD: size of the subspace after restarting: %D\n",opi);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," JD: number of vectors after restarting from the previous iteration: %D\n",opi0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_JD" PetscErrorCode EPSDestroy_JD(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetKrylovStart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetKrylovStart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetInitialSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetInitialSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetFix_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetFix_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetConstCorrectionTol_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetConstCorrectionTol_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetWindowSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetWindowSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBOrth_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBOrth_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetKrylovStart" /*@ EPSJDSetKrylovStart - Activates or deactivates starting the searching subspace with a Krylov basis. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - krylovstart - boolean flag Options Database Key: . -eps_jd_krylov_start - Activates starting the searching subspace with a Krylov basis Level: advanced .seealso: EPSJDGetKrylovStart() @*/ PetscErrorCode EPSJDSetKrylovStart(EPS eps,PetscBool krylovstart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,krylovstart,2); ierr = PetscTryMethod(eps,"EPSJDSetKrylovStart_C",(EPS,PetscBool),(eps,krylovstart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetKrylovStart" /*@ EPSJDGetKrylovStart - Returns a flag indicating if the searching subspace is started with a Krylov basis. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: . krylovstart - boolean flag indicating if the searching subspace is started with a Krylov basis Level: advanced .seealso: EPSJDGetKrylovStart() @*/ PetscErrorCode EPSJDGetKrylovStart(EPS eps,PetscBool *krylovstart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(krylovstart,2); ierr = PetscUseMethod(eps,"EPSJDGetKrylovStart_C",(EPS,PetscBool*),(eps,krylovstart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetBlockSize" /*@ EPSJDSetBlockSize - Sets the number of vectors to be added to the searching space in every iteration. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - blocksize - number of vectors added to the search space in every iteration Options Database Key: . -eps_jd_blocksize - number of vectors added to the searching space every iteration Level: advanced .seealso: EPSJDSetKrylovStart() @*/ PetscErrorCode EPSJDSetBlockSize(EPS eps,PetscInt blocksize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,blocksize,2); ierr = PetscTryMethod(eps,"EPSJDSetBlockSize_C",(EPS,PetscInt),(eps,blocksize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetBlockSize" /*@ EPSJDGetBlockSize - Returns the number of vectors to be added to the searching space in every iteration. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . blocksize - number of vectors added to the search space in every iteration Level: advanced .seealso: EPSJDSetBlockSize() @*/ PetscErrorCode EPSJDGetBlockSize(EPS eps,PetscInt *blocksize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(blocksize,2); ierr = PetscUseMethod(eps,"EPSJDGetBlockSize_C",(EPS,PetscInt*),(eps,blocksize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetRestart" /*@ EPSJDGetRestart - Gets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: + minv - number of vectors of the searching subspace after restarting - plusk - number of vectors saved from the previous iteration Level: advanced .seealso: EPSJDSetRestart() @*/ PetscErrorCode EPSJDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSJDGetRestart_C",(EPS,PetscInt*,PetscInt*),(eps,minv,plusk));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetRestart" /*@ EPSJDSetRestart - Sets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . minv - number of vectors of the searching subspace after restarting - plusk - number of vectors saved from the previous iteration Options Database Keys: + -eps_jd_minv - number of vectors of the searching subspace after restarting - -eps_jd_plusk - number of vectors saved from the previous iteration Level: advanced .seealso: EPSJDGetRestart() @*/ PetscErrorCode EPSJDSetRestart(EPS eps,PetscInt minv,PetscInt plusk) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,minv,2); PetscValidLogicalCollectiveInt(eps,plusk,3); ierr = PetscTryMethod(eps,"EPSJDSetRestart_C",(EPS,PetscInt,PetscInt),(eps,minv,plusk));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetInitialSize" /*@ EPSJDGetInitialSize - Returns the initial size of the searching space. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . initialsize - number of vectors of the initial searching subspace Notes: If EPSJDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSJDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors. Level: advanced .seealso: EPSJDSetInitialSize(), EPSJDGetKrylovStart() @*/ PetscErrorCode EPSJDGetInitialSize(EPS eps,PetscInt *initialsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(initialsize,2); ierr = PetscUseMethod(eps,"EPSJDGetInitialSize_C",(EPS,PetscInt*),(eps,initialsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetInitialSize" /*@ EPSJDSetInitialSize - Sets the initial size of the searching space. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - initialsize - number of vectors of the initial searching subspace Options Database Key: . -eps_jd_initial_size - number of vectors of the initial searching subspace Notes: If EPSJDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSJDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors. Level: advanced .seealso: EPSJDGetInitialSize(), EPSJDGetKrylovStart() @*/ PetscErrorCode EPSJDSetInitialSize(EPS eps,PetscInt initialsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,initialsize,2); ierr = PetscTryMethod(eps,"EPSJDSetInitialSize_C",(EPS,PetscInt),(eps,initialsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetFix" /*@ EPSJDGetFix - Returns the threshold for changing the target in the correction equation. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . fix - threshold for changing the target Note: The target in the correction equation is fixed at the first iterations. When the norm of the residual vector is lower than the fix value, the target is set to the corresponding eigenvalue. Level: advanced .seealso: EPSJDSetFix() @*/ PetscErrorCode EPSJDGetFix(EPS eps,PetscReal *fix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(fix,2); ierr = PetscUseMethod(eps,"EPSJDGetFix_C",(EPS,PetscReal*),(eps,fix));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetFix" /*@ EPSJDSetFix - Sets the threshold for changing the target in the correction equation. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - fix - threshold for changing the target Options Database Key: . -eps_jd_fix - the fix value Note: The target in the correction equation is fixed at the first iterations. When the norm of the residual vector is lower than the fix value, the target is set to the corresponding eigenvalue. Level: advanced .seealso: EPSJDGetFix() @*/ PetscErrorCode EPSJDSetFix(EPS eps,PetscReal fix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveReal(eps,fix,2); ierr = PetscTryMethod(eps,"EPSJDSetFix_C",(EPS,PetscReal),(eps,fix));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetConstCorrectionTol" /*@ EPSJDSetConstCorrectionTol - If true, deactivates the dynamic stopping criterion (also called Newton) that sets the KSP relative tolerance to 0.5**i, where i is the number of EPS iterations from the last converged value. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - constant - if false, the KSP relative tolerance is set to 0.5**i. Options Database Key: . -eps_jd_const_correction_tol - Deactivates the dynamic stopping criterion. Level: advanced .seealso: EPSJDGetConstCorrectionTol() @*/ PetscErrorCode EPSJDSetConstCorrectionTol(EPS eps,PetscBool constant) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,constant,2); ierr = PetscTryMethod(eps,"EPSJDSetConstCorrectionTol_C",(EPS,PetscBool),(eps,constant));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetConstCorrectionTol" /*@ EPSJDGetConstCorrectionTol - Returns a flag indicating if the dynamic stopping is being used for solving the correction equation. If the flag is false the KSP relative tolerance is set to 0.5**i, where i is the number of EPS iterations from the last converged value. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: . constant - boolean flag indicating if the dynamic stopping criterion is not being used. Level: advanced .seealso: EPSJDGetConstCorrectionTol() @*/ PetscErrorCode EPSJDGetConstCorrectionTol(EPS eps,PetscBool *constant) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(constant,2); ierr = PetscUseMethod(eps,"EPSJDGetConstCorrectionTol_C",(EPS,PetscBool*),(eps,constant));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetWindowSizes" /*@ EPSJDGetWindowSizes - Gets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: + pwindow - number of converged vectors in the projector - qwindow - number of converged vectors in the projected problem Level: advanced .seealso: EPSJDSetWindowSizes() @*/ PetscErrorCode EPSJDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSJDGetWindowSizes_C",(EPS,PetscInt*,PetscInt*),(eps,pwindow,qwindow));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetWindowSizes" /*@ EPSJDSetWindowSizes - Sets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . pwindow - number of converged vectors in the projector - qwindow - number of converged vectors in the projected problem Options Database Keys: + -eps_jd_pwindow - set the number of converged vectors in the projector - -eps_jd_qwindow - set the number of converged vectors in the projected problem Level: advanced .seealso: EPSJDGetWindowSizes() @*/ PetscErrorCode EPSJDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,pwindow,2); PetscValidLogicalCollectiveInt(eps,qwindow,3); ierr = PetscTryMethod(eps,"EPSJDSetWindowSizes_C",(EPS,PetscInt,PetscInt),(eps,pwindow,qwindow));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetBOrth" /*@ EPSJDSetBOrth - Selects the orthogonalization that will be used in the search subspace in case of generalized Hermitian problems. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - borth - whether to B-orthogonalize the search subspace Options Database Key: . -eps_jd_borth - Set the orthogonalization used in the search subspace Level: advanced .seealso: EPSJDGetBOrth() @*/ PetscErrorCode EPSJDSetBOrth(EPS eps,PetscBool borth) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,borth,2); ierr = PetscTryMethod(eps,"EPSJDSetBOrth_C",(EPS,PetscBool),(eps,borth));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetBOrth" /*@ EPSJDGetBOrth - Returns the orthogonalization used in the search subspace in case of generalized Hermitian problems. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: . borth - whether to B-orthogonalize the search subspace Level: advanced .seealso: EPSJDSetBOrth() @*/ PetscErrorCode EPSJDGetBOrth(EPS eps,PetscBool *borth) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(borth,2); ierr = PetscUseMethod(eps,"EPSJDGetBOrth_C",(EPS,PetscBool*),(eps,borth));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_JD" PETSC_EXTERN PetscErrorCode EPSCreate_JD(EPS eps) { PetscErrorCode ierr; EPS_DAVIDSON *data; PetscFunctionBegin; ierr = PetscNewLog(eps,&data);CHKERRQ(ierr); eps->data = (void*)data; data->blocksize = 1; data->initialsize = 6; data->minv = 6; data->plusk = 0; data->ipB = PETSC_TRUE; data->fix = 0.01; data->krylovstart = PETSC_FALSE; data->dynamic = PETSC_FALSE; data->cX_in_proj = 0; data->cX_in_impr = 0; eps->ops->solve = EPSSolve_XD; eps->ops->setup = EPSSetUp_XD; eps->ops->reset = EPSReset_XD; eps->ops->backtransform = EPSBackTransform_Default; eps->ops->computevectors = EPSComputeVectors_XD; eps->ops->view = EPSView_JD; eps->ops->setfromoptions = EPSSetFromOptions_JD; eps->ops->setup = EPSSetUp_JD; eps->ops->destroy = EPSDestroy_JD; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetKrylovStart_C",EPSXDSetKrylovStart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetKrylovStart_C",EPSXDGetKrylovStart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBlockSize_C",EPSXDSetBlockSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBlockSize_C",EPSXDGetBlockSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetRestart_C",EPSXDSetRestart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetRestart_C",EPSXDGetRestart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetInitialSize_C",EPSXDSetInitialSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetInitialSize_C",EPSXDGetInitialSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetFix_C",EPSJDSetFix_JD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetFix_C",EPSXDGetFix_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetConstCorrectionTol_C",EPSJDSetConstCorrectionTol_JD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetConstCorrectionTol_C",EPSJDGetConstCorrectionTol_JD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetWindowSizes_C",EPSXDSetWindowSizes_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetWindowSizes_C",EPSXDGetWindowSizes_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBOrth_C",EPSXDSetBOrth_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBOrth_C",EPSXDGetBOrth_XD);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/jd/jd.c.html0000644000175000017500000016242513107004621020607 0ustar jromanjroman
Actual source code: jd.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "jd"

  5:    Method: Jacobi-Davidson

  7:    Algorithm:

  9:        Jacobi-Davidson with various subspace extraction and
 10:        restart techniques.

 12:    References:

 14:        [1] G.L.G. Sleijpen and H.A. van der Vorst, "A Jacobi-Davidson
 15:            iteration method for linear eigenvalue problems", SIAM J.
 16:            Matrix Anal. Appl. 17(2):401-425, 1996.

 18:        [2] E. Romero and J.E. Roman, "A parallel implementation of
 19:            Davidson methods for large-scale eigenvalue problems in
 20:            SLEPc", ACM Trans. Math. Software 40(2), Article 13, 2014.

 22:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 23:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 24:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 26:    This file is part of SLEPc.

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

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

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

 42: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
 43: #include <../src/eps/impls/davidson/davidson.h>

 47: PetscErrorCode EPSSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,EPS eps)
 48: {
 50:   PetscBool      flg,op;
 51:   PetscInt       opi,opi0;
 52:   PetscReal      opf;
 53:   KSP            ksp;
 54:   PetscBool      orth;
 55:   const char     *orth_list[2] = {"I","B"};

 58:   PetscOptionsHead(PetscOptionsObject,"EPS Jacobi-Davidson (JD) Options");

 60:   EPSJDGetKrylovStart(eps,&op);
 61:   PetscOptionsBool("-eps_jd_krylov_start","Start the searching subspace with a krylov basis","EPSJDSetKrylovStart",op,&op,&flg);
 62:   if (flg) { EPSJDSetKrylovStart(eps,op); }

 64:   EPSJDGetBlockSize(eps,&opi);
 65:   PetscOptionsInt("-eps_jd_blocksize","Number vectors add to the searching subspace","EPSJDSetBlockSize",opi,&opi,&flg);
 66:   if (flg) { EPSJDSetBlockSize(eps,opi); }

 68:   EPSJDGetRestart(eps,&opi,&opi0);
 69:   PetscOptionsInt("-eps_jd_minv","Set the size of the searching subspace after restarting","EPSJDSetRestart",opi,&opi,&flg);
 70:   if (flg) { EPSJDSetRestart(eps,opi,opi0); }

 72:   PetscOptionsInt("-eps_jd_plusk","Set the number of saved eigenvectors from the previous iteration when restarting","EPSJDSetRestart",opi0,&opi0,&flg);
 73:   if (flg) { EPSJDSetRestart(eps,opi,opi0); }

 75:   EPSJDGetInitialSize(eps,&opi);
 76:   PetscOptionsInt("-eps_jd_initial_size","Set the initial size of the searching subspace","EPSJDSetInitialSize",opi,&opi,&flg);
 77:   if (flg) { EPSJDSetInitialSize(eps,opi); }

 79:   EPSJDGetFix(eps,&opf);
 80:   PetscOptionsReal("-eps_jd_fix","Set the tolerance for changing the target in the correction equation","EPSJDSetFix",opf,&opf,&flg);
 81:   if (flg) { EPSJDSetFix(eps,opf); }

 83:   EPSJDGetBOrth(eps,&orth);
 84:   PetscOptionsEList("-eps_jd_borth","orthogonalization used in the search subspace","EPSJDSetBOrth",orth_list,2,orth_list[orth?1:0],&opi,&flg);
 85:   if (flg) { EPSJDSetBOrth(eps,opi==1?PETSC_TRUE:PETSC_FALSE); }

 87:   EPSJDGetConstCorrectionTol(eps,&op);
 88:   PetscOptionsBool("-eps_jd_const_correction_tol","Disable the dynamic stopping criterion when solving the correction equation","EPSJDSetConstCorrectionTol",op,&op,&flg);
 89:   if (flg) { EPSJDSetConstCorrectionTol(eps,op); }

 91:   EPSJDGetWindowSizes(eps,&opi,&opi0);
 92:   PetscOptionsInt("-eps_jd_pwindow","(Experimental!) Set the number of converged vectors in the projector","EPSJDSetWindowSizes",opi,&opi,&flg);
 93:   if (flg) { EPSJDSetWindowSizes(eps,opi,opi0); }

 95:   PetscOptionsInt("-eps_jd_qwindow","(Experimental!) Set the number of converged vectors in the projected problem","EPSJDSetWindowSizes",opi0,&opi0,&flg);
 96:   if (flg) { EPSJDSetWindowSizes(eps,opi,opi0); }

 98:   /* Set STPrecond as the default ST */
 99:   if (!((PetscObject)eps->st)->type_name) {
100:     STSetType(eps->st,STPRECOND);
101:   }
102:   STPrecondSetKSPHasMat(eps->st,PETSC_FALSE);

104:   /* Set the default options of the KSP */
105:   STGetKSP(eps->st,&ksp);
106:   if (!((PetscObject)ksp)->type_name) {
107:     KSPSetType(ksp,KSPBCGSL);
108:     KSPSetTolerances(ksp,1e-4,PETSC_DEFAULT,PETSC_DEFAULT,90);
109:   }
110:   PetscOptionsTail();
111:   return(0);
112: }

116: PetscErrorCode EPSSetUp_JD(EPS eps)
117: {
119:   PetscBool      t;
120:   KSP            ksp;

123:   /* Setup common for all davidson solvers */
124:   EPSSetUp_XD(eps);

126:   /* Set the default options of the KSP */
127:   STGetKSP(eps->st,&ksp);
128:   if (!((PetscObject)ksp)->type_name) {
129:     KSPSetType(ksp,KSPBCGSL);
130:     KSPSetTolerances(ksp,1e-4,PETSC_DEFAULT,PETSC_DEFAULT,90);
131:   }

133:   /* Check some constraints */
134:   PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&t);
135:   if (t) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"EPSJD does not work with KSPPREONLY");
136:   return(0);
137: }

141: PetscErrorCode EPSView_JD(EPS eps,PetscViewer viewer)
142: {
144:   PetscBool      isascii,opb;
145:   PetscInt       opi,opi0;
146:   PetscBool      borth;

149:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
150:   if (isascii) {
151:     EPSXDGetBOrth_XD(eps,&borth);
152:     if (borth) {
153:       PetscViewerASCIIPrintf(viewer,"  JD: search subspace is B-orthogonalized\n");
154:     } else {
155:       PetscViewerASCIIPrintf(viewer,"  JD: search subspace is orthogonalized\n");
156:     }
157:     EPSXDGetBlockSize_XD(eps,&opi);
158:     PetscViewerASCIIPrintf(viewer,"  JD: block size=%D\n",opi);
159:     EPSXDGetKrylovStart_XD(eps,&opb);
160:     if (!opb) {
161:       PetscViewerASCIIPrintf(viewer,"  JD: type of the initial subspace: non-Krylov\n");
162:     } else {
163:       PetscViewerASCIIPrintf(viewer,"  JD: type of the initial subspace: Krylov\n");
164:     }
165:     EPSXDGetRestart_XD(eps,&opi,&opi0);
166:     PetscViewerASCIIPrintf(viewer,"  JD: size of the subspace after restarting: %D\n",opi);
167:     PetscViewerASCIIPrintf(viewer,"  JD: number of vectors after restarting from the previous iteration: %D\n",opi0);
168:   }
169:   return(0);
170: }

174: PetscErrorCode EPSDestroy_JD(EPS eps)
175: {
176:   PetscErrorCode  ierr;

179:   PetscFree(eps->data);
180:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetKrylovStart_C",NULL);
181:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetKrylovStart_C",NULL);
182:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBlockSize_C",NULL);
183:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBlockSize_C",NULL);
184:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetRestart_C",NULL);
185:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetRestart_C",NULL);
186:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetInitialSize_C",NULL);
187:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetInitialSize_C",NULL);
188:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetFix_C",NULL);
189:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetFix_C",NULL);
190:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetConstCorrectionTol_C",NULL);
191:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetConstCorrectionTol_C",NULL);
192:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetWindowSizes_C",NULL);
193:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetWindowSizes_C",NULL);
194:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBOrth_C",NULL);
195:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBOrth_C",NULL);
196:   return(0);
197: }

201: /*@
202:    EPSJDSetKrylovStart - Activates or deactivates starting the searching
203:    subspace with a Krylov basis.

205:    Logically Collective on EPS

207:    Input Parameters:
208: +  eps - the eigenproblem solver context
209: -  krylovstart - boolean flag

211:    Options Database Key:
212: .  -eps_jd_krylov_start - Activates starting the searching subspace with a
213:     Krylov basis

215:    Level: advanced

217: .seealso: EPSJDGetKrylovStart()
218: @*/
219: PetscErrorCode EPSJDSetKrylovStart(EPS eps,PetscBool krylovstart)
220: {

226:   PetscTryMethod(eps,"EPSJDSetKrylovStart_C",(EPS,PetscBool),(eps,krylovstart));
227:   return(0);
228: }

232: /*@
233:    EPSJDGetKrylovStart - Returns a flag indicating if the searching subspace is started with a
234:    Krylov basis.

236:    Not Collective

238:    Input Parameter:
239: .  eps - the eigenproblem solver context

241:    Output Parameters:
242: .  krylovstart - boolean flag indicating if the searching subspace is started
243:    with a Krylov basis

245:    Level: advanced

247: .seealso: EPSJDGetKrylovStart()
248: @*/
249: PetscErrorCode EPSJDGetKrylovStart(EPS eps,PetscBool *krylovstart)
250: {

256:   PetscUseMethod(eps,"EPSJDGetKrylovStart_C",(EPS,PetscBool*),(eps,krylovstart));
257:   return(0);
258: }

262: /*@
263:    EPSJDSetBlockSize - Sets the number of vectors to be added to the searching space
264:    in every iteration.

266:    Logically Collective on EPS

268:    Input Parameters:
269: +  eps - the eigenproblem solver context
270: -  blocksize - number of vectors added to the search space in every iteration

272:    Options Database Key:
273: .  -eps_jd_blocksize - number of vectors added to the searching space every iteration

275:    Level: advanced

277: .seealso: EPSJDSetKrylovStart()
278: @*/
279: PetscErrorCode EPSJDSetBlockSize(EPS eps,PetscInt blocksize)
280: {

286:   PetscTryMethod(eps,"EPSJDSetBlockSize_C",(EPS,PetscInt),(eps,blocksize));
287:   return(0);
288: }

292: /*@
293:    EPSJDGetBlockSize - Returns the number of vectors to be added to the searching space
294:    in every iteration.

296:    Not Collective

298:    Input Parameter:
299: .  eps - the eigenproblem solver context

301:    Output Parameter:
302: .  blocksize - number of vectors added to the search space in every iteration

304:    Level: advanced

306: .seealso: EPSJDSetBlockSize()
307: @*/
308: PetscErrorCode EPSJDGetBlockSize(EPS eps,PetscInt *blocksize)
309: {

315:   PetscUseMethod(eps,"EPSJDGetBlockSize_C",(EPS,PetscInt*),(eps,blocksize));
316:   return(0);
317: }

321: /*@
322:    EPSJDGetRestart - Gets the number of vectors of the searching space after
323:    restarting and the number of vectors saved from the previous iteration.

325:    Not Collective

327:    Input Parameter:
328: .  eps - the eigenproblem solver context

330:    Output Parameter:
331: +  minv - number of vectors of the searching subspace after restarting
332: -  plusk - number of vectors saved from the previous iteration

334:    Level: advanced

336: .seealso: EPSJDSetRestart()
337: @*/
338: PetscErrorCode EPSJDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)
339: {

344:   PetscUseMethod(eps,"EPSJDGetRestart_C",(EPS,PetscInt*,PetscInt*),(eps,minv,plusk));
345:   return(0);
346: }

350: /*@
351:    EPSJDSetRestart - Sets the number of vectors of the searching space after
352:    restarting and the number of vectors saved from the previous iteration.

354:    Logically Collective on EPS

356:    Input Parameters:
357: +  eps - the eigenproblem solver context
358: .  minv - number of vectors of the searching subspace after restarting
359: -  plusk - number of vectors saved from the previous iteration

361:    Options Database Keys:
362: +  -eps_jd_minv - number of vectors of the searching subspace after restarting
363: -  -eps_jd_plusk - number of vectors saved from the previous iteration

365:    Level: advanced

367: .seealso: EPSJDGetRestart()
368: @*/
369: PetscErrorCode EPSJDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)
370: {

377:   PetscTryMethod(eps,"EPSJDSetRestart_C",(EPS,PetscInt,PetscInt),(eps,minv,plusk));
378:   return(0);
379: }

383: /*@
384:    EPSJDGetInitialSize - Returns the initial size of the searching space.

386:    Not Collective

388:    Input Parameter:
389: .  eps - the eigenproblem solver context

391:    Output Parameter:
392: .  initialsize - number of vectors of the initial searching subspace

394:    Notes:
395:    If EPSJDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
396:    EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
397:    provided vectors are not enough, the solver completes the subspace with
398:    random vectors. In the case of EPSJDGetKrylovStart() being PETSC_TRUE, the solver
399:    gets the first vector provided by the user or, if not available, a random vector,
400:    and expands the Krylov basis up to initialsize vectors.

402:    Level: advanced

404: .seealso: EPSJDSetInitialSize(), EPSJDGetKrylovStart()
405: @*/
406: PetscErrorCode EPSJDGetInitialSize(EPS eps,PetscInt *initialsize)
407: {

413:   PetscUseMethod(eps,"EPSJDGetInitialSize_C",(EPS,PetscInt*),(eps,initialsize));
414:   return(0);
415: }

419: /*@
420:    EPSJDSetInitialSize - Sets the initial size of the searching space.

422:    Logically Collective on EPS

424:    Input Parameters:
425: +  eps - the eigenproblem solver context
426: -  initialsize - number of vectors of the initial searching subspace

428:    Options Database Key:
429: .  -eps_jd_initial_size - number of vectors of the initial searching subspace

431:    Notes:
432:    If EPSJDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
433:    EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
434:    provided vectors are not enough, the solver completes the subspace with
435:    random vectors. In the case of EPSJDGetKrylovStart() being PETSC_TRUE, the solver
436:    gets the first vector provided by the user or, if not available, a random vector,
437:    and expands the Krylov basis up to initialsize vectors.

439:    Level: advanced

441: .seealso: EPSJDGetInitialSize(), EPSJDGetKrylovStart()
442: @*/
443: PetscErrorCode EPSJDSetInitialSize(EPS eps,PetscInt initialsize)
444: {

450:   PetscTryMethod(eps,"EPSJDSetInitialSize_C",(EPS,PetscInt),(eps,initialsize));
451:   return(0);
452: }

456: /*@
457:    EPSJDGetFix - Returns the threshold for changing the target in the correction
458:    equation.

460:    Not Collective

462:    Input Parameter:
463: .  eps - the eigenproblem solver context

465:    Output Parameter:
466: .  fix - threshold for changing the target

468:    Note:
469:    The target in the correction equation is fixed at the first iterations.
470:    When the norm of the residual vector is lower than the fix value,
471:    the target is set to the corresponding eigenvalue.

473:    Level: advanced

475: .seealso: EPSJDSetFix()
476: @*/
477: PetscErrorCode EPSJDGetFix(EPS eps,PetscReal *fix)
478: {

484:   PetscUseMethod(eps,"EPSJDGetFix_C",(EPS,PetscReal*),(eps,fix));
485:   return(0);
486: }

490: /*@
491:    EPSJDSetFix - Sets the threshold for changing the target in the correction
492:    equation.

494:    Logically Collective on EPS

496:    Input Parameters:
497: +  eps - the eigenproblem solver context
498: -  fix - threshold for changing the target

500:    Options Database Key:
501: .  -eps_jd_fix - the fix value

503:    Note:
504:    The target in the correction equation is fixed at the first iterations.
505:    When the norm of the residual vector is lower than the fix value,
506:    the target is set to the corresponding eigenvalue.

508:    Level: advanced

510: .seealso: EPSJDGetFix()
511: @*/
512: PetscErrorCode EPSJDSetFix(EPS eps,PetscReal fix)
513: {

519:   PetscTryMethod(eps,"EPSJDSetFix_C",(EPS,PetscReal),(eps,fix));
520:   return(0);
521: }

525: /*@
526:    EPSJDSetConstCorrectionTol - If true, deactivates the dynamic stopping criterion
527:    (also called Newton) that sets the KSP relative tolerance
528:    to 0.5**i, where i is the number of EPS iterations from the last converged value.

530:    Logically Collective on EPS

532:    Input Parameters:
533: +  eps - the eigenproblem solver context
534: -  constant - if false, the KSP relative tolerance is set to 0.5**i.

536:    Options Database Key:
537: .  -eps_jd_const_correction_tol - Deactivates the dynamic stopping criterion.

539:    Level: advanced

541: .seealso: EPSJDGetConstCorrectionTol()
542: @*/
543: PetscErrorCode EPSJDSetConstCorrectionTol(EPS eps,PetscBool constant)
544: {

550:   PetscTryMethod(eps,"EPSJDSetConstCorrectionTol_C",(EPS,PetscBool),(eps,constant));
551:   return(0);
552: }

556: /*@
557:    EPSJDGetConstCorrectionTol - Returns a flag indicating if the dynamic stopping is being used for
558:    solving the correction equation. If the flag is false the KSP relative tolerance is set
559:    to 0.5**i, where i is the number of EPS iterations from the last converged value.

561:    Not Collective

563:    Input Parameter:
564: .  eps - the eigenproblem solver context

566:    Output Parameters:
567: .  constant - boolean flag indicating if the dynamic stopping criterion is not being used.

569:    Level: advanced

571: .seealso: EPSJDGetConstCorrectionTol()
572: @*/
573: PetscErrorCode EPSJDGetConstCorrectionTol(EPS eps,PetscBool *constant)
574: {

580:   PetscUseMethod(eps,"EPSJDGetConstCorrectionTol_C",(EPS,PetscBool*),(eps,constant));
581:   return(0);
582: }

586: /*@
587:    EPSJDGetWindowSizes - Gets the number of converged vectors in the projected
588:    problem (or Rayleigh quotient) and in the projector employed in the correction
589:    equation.

591:    Not Collective

593:    Input Parameter:
594: .  eps - the eigenproblem solver context

596:    Output Parameter:
597: +  pwindow - number of converged vectors in the projector
598: -  qwindow - number of converged vectors in the projected problem

600:    Level: advanced

602: .seealso: EPSJDSetWindowSizes()
603: @*/
604: PetscErrorCode EPSJDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)
605: {

610:   PetscUseMethod(eps,"EPSJDGetWindowSizes_C",(EPS,PetscInt*,PetscInt*),(eps,pwindow,qwindow));
611:   return(0);
612: }

616: /*@
617:    EPSJDSetWindowSizes - Sets the number of converged vectors in the projected
618:    problem (or Rayleigh quotient) and in the projector employed in the correction
619:    equation.

621:    Logically Collective on EPS

623:    Input Parameters:
624: +  eps - the eigenproblem solver context
625: .  pwindow - number of converged vectors in the projector
626: -  qwindow - number of converged vectors in the projected problem

628:    Options Database Keys:
629: +  -eps_jd_pwindow - set the number of converged vectors in the projector
630: -  -eps_jd_qwindow - set the number of converged vectors in the projected problem

632:    Level: advanced

634: .seealso: EPSJDGetWindowSizes()
635: @*/
636: PetscErrorCode EPSJDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)
637: {

644:   PetscTryMethod(eps,"EPSJDSetWindowSizes_C",(EPS,PetscInt,PetscInt),(eps,pwindow,qwindow));
645:   return(0);
646: }

650: /*@
651:    EPSJDSetBOrth - Selects the orthogonalization that will be used in the search
652:    subspace in case of generalized Hermitian problems.

654:    Logically Collective on EPS

656:    Input Parameters:
657: +  eps   - the eigenproblem solver context
658: -  borth - whether to B-orthogonalize the search subspace

660:    Options Database Key:
661: .  -eps_jd_borth - Set the orthogonalization used in the search subspace

663:    Level: advanced

665: .seealso: EPSJDGetBOrth()
666: @*/
667: PetscErrorCode EPSJDSetBOrth(EPS eps,PetscBool borth)
668: {

674:   PetscTryMethod(eps,"EPSJDSetBOrth_C",(EPS,PetscBool),(eps,borth));
675:   return(0);
676: }

680: /*@
681:    EPSJDGetBOrth - Returns the orthogonalization used in the search
682:    subspace in case of generalized Hermitian problems.

684:    Not Collective

686:    Input Parameter:
687: .  eps - the eigenproblem solver context

689:    Output Parameters:
690: .  borth - whether to B-orthogonalize the search subspace

692:    Level: advanced

694: .seealso: EPSJDSetBOrth()
695: @*/
696: PetscErrorCode EPSJDGetBOrth(EPS eps,PetscBool *borth)
697: {

703:   PetscUseMethod(eps,"EPSJDGetBOrth_C",(EPS,PetscBool*),(eps,borth));
704:   return(0);
705: }

709: PETSC_EXTERN PetscErrorCode EPSCreate_JD(EPS eps)
710: {
712:   EPS_DAVIDSON   *data;

715:   PetscNewLog(eps,&data);
716:   eps->data = (void*)data;

718:   data->blocksize   = 1;
719:   data->initialsize = 6;
720:   data->minv        = 6;
721:   data->plusk       = 0;
722:   data->ipB         = PETSC_TRUE;
723:   data->fix         = 0.01;
724:   data->krylovstart = PETSC_FALSE;
725:   data->dynamic     = PETSC_FALSE;
726:   data->cX_in_proj  = 0;
727:   data->cX_in_impr  = 0;

729:   eps->ops->solve          = EPSSolve_XD;
730:   eps->ops->setup          = EPSSetUp_XD;
731:   eps->ops->reset          = EPSReset_XD;
732:   eps->ops->backtransform  = EPSBackTransform_Default;
733:   eps->ops->computevectors = EPSComputeVectors_XD;
734:   eps->ops->view           = EPSView_JD;
735:   eps->ops->setfromoptions = EPSSetFromOptions_JD;
736:   eps->ops->setup          = EPSSetUp_JD;
737:   eps->ops->destroy        = EPSDestroy_JD;

739:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetKrylovStart_C",EPSXDSetKrylovStart_XD);
740:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetKrylovStart_C",EPSXDGetKrylovStart_XD);
741:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBlockSize_C",EPSXDSetBlockSize_XD);
742:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBlockSize_C",EPSXDGetBlockSize_XD);
743:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetRestart_C",EPSXDSetRestart_XD);
744:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetRestart_C",EPSXDGetRestart_XD);
745:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetInitialSize_C",EPSXDSetInitialSize_XD);
746:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetInitialSize_C",EPSXDGetInitialSize_XD);
747:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetFix_C",EPSJDSetFix_JD);
748:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetFix_C",EPSXDGetFix_XD);
749:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetConstCorrectionTol_C",EPSJDSetConstCorrectionTol_JD);
750:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetConstCorrectionTol_C",EPSJDGetConstCorrectionTol_JD);
751:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetWindowSizes_C",EPSXDSetWindowSizes_XD);
752:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetWindowSizes_C",EPSXDGetWindowSizes_XD);
753:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDSetBOrth_C",EPSXDSetBOrth_XD);
754:   PetscObjectComposeFunction((PetscObject)eps,"EPSJDGetBOrth_C",EPSXDGetBOrth_XD);
755:   return(0);
756: }

slepc-3.7.4/src/eps/impls/davidson/jd/makefile.html0000644000175000017500000000467213107004621021545 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = jd.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/davidson/jd/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/davidson/jd/index.html0000644000175000017500000000260213107004621021066 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

jd.c
makefile
slepc-3.7.4/src/eps/impls/davidson/jd/ftn-auto/0000755000175000017500000000000013107004621020626 5ustar jromanjromanslepc-3.7.4/src/eps/impls/davidson/jd/ftn-auto/makefile0000644000175000017500000000036213107004621022327 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = jdf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/davidson/jd/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/davidson/jd/ftn-auto/jdf.c0000644000175000017500000001535013107004621021541 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* jd.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetkrylovstart_ EPSJDSETKRYLOVSTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetkrylovstart_ epsjdsetkrylovstart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetkrylovstart_ EPSJDGETKRYLOVSTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetkrylovstart_ epsjdgetkrylovstart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetblocksize_ EPSJDSETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetblocksize_ epsjdsetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetblocksize_ EPSJDGETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetblocksize_ epsjdgetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetrestart_ EPSJDGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetrestart_ epsjdgetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetrestart_ EPSJDSETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetrestart_ epsjdsetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetinitialsize_ EPSJDGETINITIALSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetinitialsize_ epsjdgetinitialsize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetinitialsize_ EPSJDSETINITIALSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetinitialsize_ epsjdsetinitialsize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetfix_ EPSJDGETFIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetfix_ epsjdgetfix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetfix_ EPSJDSETFIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetfix_ epsjdsetfix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetconstcorrectiontol_ EPSJDSETCONSTCORRECTIONTOL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetconstcorrectiontol_ epsjdsetconstcorrectiontol #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetconstcorrectiontol_ EPSJDGETCONSTCORRECTIONTOL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetconstcorrectiontol_ epsjdgetconstcorrectiontol #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetwindowsizes_ EPSJDGETWINDOWSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetwindowsizes_ epsjdgetwindowsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetwindowsizes_ EPSJDSETWINDOWSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetwindowsizes_ epsjdsetwindowsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdsetborth_ EPSJDSETBORTH #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdsetborth_ epsjdsetborth #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsjdgetborth_ EPSJDGETBORTH #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsjdgetborth_ epsjdgetborth #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsjdsetkrylovstart_(EPS eps,PetscBool *krylovstart, int *__ierr ){ *__ierr = EPSJDSetKrylovStart( (EPS)PetscToPointer((eps) ),*krylovstart); } PETSC_EXTERN void PETSC_STDCALL epsjdgetkrylovstart_(EPS eps,PetscBool *krylovstart, int *__ierr ){ *__ierr = EPSJDGetKrylovStart( (EPS)PetscToPointer((eps) ),krylovstart); } PETSC_EXTERN void PETSC_STDCALL epsjdsetblocksize_(EPS eps,PetscInt *blocksize, int *__ierr ){ *__ierr = EPSJDSetBlockSize( (EPS)PetscToPointer((eps) ),*blocksize); } PETSC_EXTERN void PETSC_STDCALL epsjdgetblocksize_(EPS eps,PetscInt *blocksize, int *__ierr ){ *__ierr = EPSJDGetBlockSize( (EPS)PetscToPointer((eps) ),blocksize); } PETSC_EXTERN void PETSC_STDCALL epsjdgetrestart_(EPS eps,PetscInt *minv,PetscInt *plusk, int *__ierr ){ *__ierr = EPSJDGetRestart( (EPS)PetscToPointer((eps) ),minv,plusk); } PETSC_EXTERN void PETSC_STDCALL epsjdsetrestart_(EPS eps,PetscInt *minv,PetscInt *plusk, int *__ierr ){ *__ierr = EPSJDSetRestart( (EPS)PetscToPointer((eps) ),*minv,*plusk); } PETSC_EXTERN void PETSC_STDCALL epsjdgetinitialsize_(EPS eps,PetscInt *initialsize, int *__ierr ){ *__ierr = EPSJDGetInitialSize( (EPS)PetscToPointer((eps) ),initialsize); } PETSC_EXTERN void PETSC_STDCALL epsjdsetinitialsize_(EPS eps,PetscInt *initialsize, int *__ierr ){ *__ierr = EPSJDSetInitialSize( (EPS)PetscToPointer((eps) ),*initialsize); } PETSC_EXTERN void PETSC_STDCALL epsjdgetfix_(EPS eps,PetscReal *fix, int *__ierr ){ *__ierr = EPSJDGetFix( (EPS)PetscToPointer((eps) ),fix); } PETSC_EXTERN void PETSC_STDCALL epsjdsetfix_(EPS eps,PetscReal *fix, int *__ierr ){ *__ierr = EPSJDSetFix( (EPS)PetscToPointer((eps) ),*fix); } PETSC_EXTERN void PETSC_STDCALL epsjdsetconstcorrectiontol_(EPS eps,PetscBool *constant, int *__ierr ){ *__ierr = EPSJDSetConstCorrectionTol( (EPS)PetscToPointer((eps) ),*constant); } PETSC_EXTERN void PETSC_STDCALL epsjdgetconstcorrectiontol_(EPS eps,PetscBool *constant, int *__ierr ){ *__ierr = EPSJDGetConstCorrectionTol( (EPS)PetscToPointer((eps) ),constant); } PETSC_EXTERN void PETSC_STDCALL epsjdgetwindowsizes_(EPS eps,PetscInt *pwindow,PetscInt *qwindow, int *__ierr ){ *__ierr = EPSJDGetWindowSizes( (EPS)PetscToPointer((eps) ),pwindow,qwindow); } PETSC_EXTERN void PETSC_STDCALL epsjdsetwindowsizes_(EPS eps,PetscInt *pwindow,PetscInt *qwindow, int *__ierr ){ *__ierr = EPSJDSetWindowSizes( (EPS)PetscToPointer((eps) ),*pwindow,*qwindow); } PETSC_EXTERN void PETSC_STDCALL epsjdsetborth_(EPS eps,PetscBool *borth, int *__ierr ){ *__ierr = EPSJDSetBOrth( (EPS)PetscToPointer((eps) ),*borth); } PETSC_EXTERN void PETSC_STDCALL epsjdgetborth_(EPS eps,PetscBool *borth, int *__ierr ){ *__ierr = EPSJDGetBOrth( (EPS)PetscToPointer((eps) ),borth); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/davidson/dvdinitv.c.html0000644000175000017500000003153613107004621021442 0ustar jromanjroman

Actual source code: dvdinitv.c

slepc-3.7.4 2017-05-17
  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Step: init subspace V

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

 10:    This file is part of SLEPc.

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

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

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

 26:  #include davidson.h

 28: typedef struct {
 29:   PetscInt k;                 /* desired initial subspace size */
 30:   PetscInt user;              /* number of user initial vectors */
 31:   void     *old_initV_data;   /* old initV data */
 32: } dvdInitV;

 36: static PetscErrorCode dvd_initV_classic_0(dvdDashboard *d)
 37: {
 39:   dvdInitV       *data = (dvdInitV*)d->initV_data;
 40:   PetscInt       i,user = PetscMin(data->user,d->eps->mpd), l,k;

 43:   BVGetActiveColumns(d->eps->V,&l,&k);
 44:   /* User vectors are added at the beginning, so no active column should be in V */
 45:   if (data->user>0&&l>0) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken");
 46:   /* Generate a set of random initial vectors and orthonormalize them */
 47:   for (i=l+user;i<l+data->k && i<d->eps->ncv && i-l<d->eps->mpd;i++) {
 48:     BVSetRandomColumn(d->eps->V,i);
 49:   }
 50:   d->V_tra_s = 0; d->V_tra_e = 0;
 51:   d->V_new_s = 0; d->V_new_e = i-l;

 53:   /* After that the user vectors will be destroyed */
 54:   data->user = 0;
 55:   return(0);
 56: }

 60: static PetscErrorCode dvd_initV_krylov_0(dvdDashboard *d)
 61: {
 63:   dvdInitV       *data = (dvdInitV*)d->initV_data;
 64:   PetscInt       i,user = PetscMin(data->user,d->eps->mpd),l,k;
 65:   Vec            av,v1,v2;

 68:   BVGetActiveColumns(d->eps->V,&l,&k);
 69:   /* User vectors are added at the beginning, so no active column should be in V */
 70:   if (data->user>0&&l>0) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken");

 72:   /* If needed, generate a random vector for starting the arnoldi method */
 73:   if (user == 0) {
 74:     BVSetRandomColumn(d->eps->V,l);
 75:     user = 1;
 76:   }

 78:   /* Perform k steps of Arnoldi with the operator K^{-1}*(t[1]*A-t[2]*B) */
 79:   dvd_orthV(d->eps->V,l,l+user);
 80:   for (i=l+user;i<l+data->k && i<d->eps->ncv && i-l<d->eps->mpd;i++) {
 81:     /* aux <- theta[1]A*in - theta[0]*B*in */
 82:     BVGetColumn(d->eps->V,i,&v1);
 83:     BVGetColumn(d->eps->V,i-user,&v2);
 84:     BVGetColumn(d->auxBV,0,&av);
 85:     if (d->B) {
 86:       MatMult(d->A,v2,v1);
 87:       MatMult(d->B,v2,av);
 88:       VecAXPBY(av,d->target[1],-d->target[0],v1);
 89:     } else {
 90:       MatMult(d->A,v2,av);
 91:       VecAXPBY(av,-d->target[0],d->target[1],v2);
 92:     }
 93:     d->improvex_precond(d,0,av,v1);
 94:     BVRestoreColumn(d->eps->V,i,&v1);
 95:     BVRestoreColumn(d->eps->V,i-user,&v2);
 96:     BVRestoreColumn(d->auxBV,0,&av);
 97:     dvd_orthV(d->eps->V,i,i+1);
 98:   }

100:   d->V_tra_s = 0; d->V_tra_e = 0;
101:   d->V_new_s = 0; d->V_new_e = i-l;

103:   /* After that the user vectors will be destroyed */
104:   data->user = 0;
105:   return(0);
106: }

110: static PetscErrorCode dvd_initV_d(dvdDashboard *d)
111: {
113:   dvdInitV       *data = (dvdInitV*)d->initV_data;

116:   /* Restore changes in dvdDashboard */
117:   d->initV_data = data->old_initV_data;

119:   /* Free local data */
120:   PetscFree(data);
121:   return(0);
122: }

126: PetscErrorCode dvd_initV(dvdDashboard *d, dvdBlackboard *b, PetscInt k,PetscInt user, PetscBool krylov)
127: {
129:   dvdInitV       *data;

132:   /* Setting configuration constrains */
133:   b->max_size_V = PetscMax(b->max_size_V, k);

135:   /* Setup the step */
136:   if (b->state >= DVD_STATE_CONF) {
137:     PetscNewLog(d->eps,&data);
138:     data->k = k;
139:     data->user = user;
140:     data->old_initV_data = d->initV_data;
141:     d->initV_data = data;
142:     if (krylov) d->initV = dvd_initV_krylov_0;
143:     else d->initV = dvd_initV_classic_0;
144:     EPSDavidsonFLAdd(&d->destroyList,dvd_initV_d);
145:   }
146:   return(0);
147: }

151: PetscErrorCode dvd_orthV(BV V,PetscInt V_new_s,PetscInt V_new_e)
152: {
154:   PetscInt       i,j,l,k;
155:   PetscBool      lindep;
156:   PetscReal      norm;

159:   BVGetActiveColumns(V,&l,&k);
160:   for (i=V_new_s;i<V_new_e;i++) {
161:     BVSetActiveColumns(V,0,i);
162:     for (j=0;j<3;j++) {
163:       if (j>0) {
164:         BVSetRandomColumn(V,i);
165:         PetscInfo1(V,"Orthonormalization problems adding the vector %D to the searching subspace\n",i);
166:       }
167:       BVOrthogonalizeColumn(V,i,NULL,&norm,&lindep);
168:       if (!lindep && (PetscAbsReal(norm) > PETSC_SQRT_MACHINE_EPSILON)) break;
169:     }
170:     if (lindep || (PetscAbsReal(norm) < PETSC_SQRT_MACHINE_EPSILON)) SETERRQ(PetscObjectComm((PetscObject)V),1, "Error during the orthonormalization of the vectors");
171:     BVScaleColumn(V,i,1.0/norm);
172:   }
173:   BVSetActiveColumns(V,l,k);
174:   return(0);
175: }

slepc-3.7.4/src/eps/impls/davidson/index.html0000644000175000017500000000354313107004621020476 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

gd/
jd/
davidson.h
davidson.c
dvdcalcpairs.c
dvdimprovex.c
dvdinitv.c
dvdschm.c
dvdtestconv.c
dvdupdatev.c
dvdutils.c
dvdgd2.c
makefile
slepc-3.7.4/src/eps/impls/davidson/gd/0000755000175000017500000000000013107004621017066 5ustar jromanjromanslepc-3.7.4/src/eps/impls/davidson/gd/makefile0000644000175000017500000000215613107004621020572 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = gd.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/davidson/gd/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/davidson/gd/makefile.html0000644000175000017500000000467213107004621021542 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = gd.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/davidson/gd/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/eps/impls/davidson/gd/gd.c.html0000644000175000017500000015011613107004621020573 0ustar jromanjroman
Actual source code: gd.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "gd"

  5:    Method: Generalized Davidson

  7:    Algorithm:

  9:        Generalized Davidson with various subspace extraction and
 10:        restart techniques.

 12:    References:

 14:        [1] E.R. Davidson, "Super-matrix methods", Comput. Phys. Commun.
 15:            53(2):49-60, 1989.

 17:        [2] E. Romero and J.E. Roman, "A parallel implementation of
 18:            Davidson methods for large-scale eigenvalue problems in
 19:            SLEPc", ACM Trans. Math. Software 40(2), Article 13, 2014.

 21:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 22:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 23:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 25:    This file is part of SLEPc.

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

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

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

 41: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
 42: #include <../src/eps/impls/davidson/davidson.h>

 46: PetscErrorCode EPSSetFromOptions_GD(PetscOptionItems *PetscOptionsObject,EPS eps)
 47: {
 49:   PetscBool      flg,op;
 50:   PetscInt       opi,opi0;
 51:   KSP            ksp;
 52:   PetscBool      orth;
 53:   const char     *orth_list[2] = {"I","B"};

 56:   PetscOptionsHead(PetscOptionsObject,"EPS Generalized Davidson (GD) Options");

 58:   EPSGDGetKrylovStart(eps,&op);
 59:   PetscOptionsBool("-eps_gd_krylov_start","Start the searching subspace with a krylov basis","EPSGDSetKrylovStart",op,&op,&flg);
 60:   if (flg) { EPSGDSetKrylovStart(eps,op); }

 62:   EPSGDGetBOrth(eps,&orth);
 63:   PetscOptionsEList("-eps_gd_borth","orthogonalization used in the search subspace","EPSGDSetBOrth",orth_list,2,orth_list[orth?1:0],&opi,&flg);
 64:   if (flg) { EPSGDSetBOrth(eps,opi==1?PETSC_TRUE:PETSC_FALSE); }

 66:   EPSGDGetBlockSize(eps,&opi);
 67:   PetscOptionsInt("-eps_gd_blocksize","Number vectors add to the searching subspace","EPSGDSetBlockSize",opi,&opi,&flg);
 68:   if (flg) { EPSGDSetBlockSize(eps,opi); }

 70:   EPSGDGetRestart(eps,&opi,&opi0);
 71:   PetscOptionsInt("-eps_gd_minv","Set the size of the searching subspace after restarting","EPSGDSetRestart",opi,&opi,&flg);
 72:   if (flg) { EPSGDSetRestart(eps,opi,opi0); }

 74:   PetscOptionsInt("-eps_gd_plusk","Set the number of saved eigenvectors from the previous iteration when restarting","EPSGDSetRestart",opi0,&opi0,&flg);
 75:   if (flg) { EPSGDSetRestart(eps,opi,opi0); }

 77:   EPSGDGetInitialSize(eps,&opi);
 78:   PetscOptionsInt("-eps_gd_initial_size","Set the initial size of the searching subspace","EPSGDSetInitialSize",opi,&opi,&flg);
 79:   if (flg) { EPSGDSetInitialSize(eps,opi); }

 81:   EPSGDGetWindowSizes(eps,&opi,&opi0);
 82:   PetscOptionsInt("-eps_gd_pwindow","(Experimental!) Set the number of converged vectors in the projector","EPSGDSetWindowSizes",opi,&opi,&flg);
 83:   if (flg) { EPSGDSetWindowSizes(eps,opi,opi0); }

 85:   PetscOptionsInt("-eps_gd_qwindow","(Experimental!) Set the number of converged vectors in the projected problem","EPSGDSetWindowSizes",opi0,&opi0,&flg);
 86:   if (flg) { EPSGDSetWindowSizes(eps,opi,opi0); }

 88:   PetscOptionsBool("-eps_gd_double_expansion","use the doble-expansion variant of GD","EPSGDSetDoubleExpansion",PETSC_FALSE,&op,&flg);
 89:   if (flg) { EPSGDSetDoubleExpansion(eps,op); }

 91:   /* Set STPrecond as the default ST */
 92:   if (!((PetscObject)eps->st)->type_name) {
 93:     STSetType(eps->st,STPRECOND);
 94:   }
 95:   STPrecondSetKSPHasMat(eps->st,PETSC_FALSE);

 97:   /* Set the default options of the KSP */
 98:   STGetKSP(eps->st,&ksp);
 99:   if (!((PetscObject)ksp)->type_name) {
100:     KSPSetType(ksp,KSPPREONLY);
101:   }
102:   PetscOptionsTail();
103:   return(0);
104: }

108: PetscErrorCode EPSSetUp_GD(EPS eps)
109: {
111:   PetscBool      t;
112:   KSP            ksp;

115:   /* Set KSPPREONLY as default */
116:   STGetKSP(eps->st,&ksp);
117:   if (!((PetscObject)ksp)->type_name) {
118:     KSPSetType(ksp,KSPPREONLY);
119:   }

121:   /* Setup common for all davidson solvers */
122:   EPSSetUp_XD(eps);

124:   /* Check some constraints */
125:   PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&t);
126:   if (!t) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"EPSGD only works with KSPPREONLY");
127:   return(0);
128: }

132: PetscErrorCode EPSView_GD(EPS eps,PetscViewer viewer)
133: {
135:   PetscBool      isascii,opb;
136:   PetscInt       opi,opi0;
137:   PetscBool      borth;
138:   EPS_DAVIDSON   *data = (EPS_DAVIDSON*)eps->data;

141:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
142:   if (isascii) {
143:     if (data->doubleexp) {
144:       PetscViewerASCIIPrintf(viewer,"  GD: using double expansion variant (GD2)\n");
145:     }
146:     EPSXDGetBOrth_XD(eps,&borth);
147:     if (borth) {
148:       PetscViewerASCIIPrintf(viewer,"  GD: search subspace is B-orthogonalized\n");
149:     } else {
150:       PetscViewerASCIIPrintf(viewer,"  GD: search subspace is orthogonalized\n");
151:     }
152:     EPSXDGetBlockSize_XD(eps,&opi);
153:     PetscViewerASCIIPrintf(viewer,"  GD: block size=%D\n",opi);
154:     EPSXDGetKrylovStart_XD(eps,&opb);
155:     if (!opb) {
156:       PetscViewerASCIIPrintf(viewer,"  GD: type of the initial subspace: non-Krylov\n");
157:     } else {
158:       PetscViewerASCIIPrintf(viewer,"  GD: type of the initial subspace: Krylov\n");
159:     }
160:     EPSXDGetRestart_XD(eps,&opi,&opi0);
161:     PetscViewerASCIIPrintf(viewer,"  GD: size of the subspace after restarting: %D\n",opi);
162:     PetscViewerASCIIPrintf(viewer,"  GD: number of vectors after restarting from the previous iteration: %D\n",opi0);
163:   }
164:   return(0);
165: }

169: PetscErrorCode EPSDestroy_GD(EPS eps)
170: {
171:   PetscErrorCode  ierr;

174:   PetscFree(eps->data);
175:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetKrylovStart_C",NULL);
176:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetKrylovStart_C",NULL);
177:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBOrth_C",NULL);
178:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBOrth_C",NULL);
179:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBlockSize_C",NULL);
180:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBlockSize_C",NULL);
181:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetRestart_C",NULL);
182:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetRestart_C",NULL);
183:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetInitialSize_C",NULL);
184:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetInitialSize_C",NULL);
185:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetWindowSizes_C",NULL);
186:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetWindowSizes_C",NULL);
187:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetDoubleExpansion_C",NULL);
188:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetDoubleExpansion_C",NULL);
189:   return(0);
190: }

194: /*@
195:    EPSGDSetKrylovStart - Activates or deactivates starting the searching
196:    subspace with a Krylov basis.

198:    Logically Collective on EPS

200:    Input Parameters:
201: +  eps - the eigenproblem solver context
202: -  krylovstart - boolean flag

204:    Options Database Key:
205: .  -eps_gd_krylov_start - Activates starting the searching subspace with a
206:     Krylov basis

208:    Level: advanced

210: .seealso: EPSGDGetKrylovStart()
211: @*/
212: PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart)
213: {

219:   PetscTryMethod(eps,"EPSGDSetKrylovStart_C",(EPS,PetscBool),(eps,krylovstart));
220:   return(0);
221: }

225: /*@
226:    EPSGDGetKrylovStart - Returns a flag indicating if the search subspace is started with a
227:    Krylov basis.

229:    Not Collective

231:    Input Parameter:
232: .  eps - the eigenproblem solver context

234:    Output Parameters:
235: .  krylovstart - boolean flag indicating if the search subspace is started
236:    with a Krylov basis

238:    Level: advanced

240: .seealso: EPSGDGetKrylovStart()
241: @*/
242: PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart)
243: {

249:   PetscUseMethod(eps,"EPSGDGetKrylovStart_C",(EPS,PetscBool*),(eps,krylovstart));
250:   return(0);
251: }

255: /*@
256:    EPSGDSetBlockSize - Sets the number of vectors to be added to the searching space
257:    in every iteration.

259:    Logically Collective on EPS

261:    Input Parameters:
262: +  eps - the eigenproblem solver context
263: -  blocksize - number of vectors added to the search space in every iteration

265:    Options Database Key:
266: .  -eps_gd_blocksize - number of vectors added to the search space in every iteration

268:    Level: advanced

270: .seealso: EPSGDSetKrylovStart()
271: @*/
272: PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize)
273: {

279:   PetscTryMethod(eps,"EPSGDSetBlockSize_C",(EPS,PetscInt),(eps,blocksize));
280:   return(0);
281: }

285: /*@
286:    EPSGDGetBlockSize - Returns the number of vectors to be added to the searching space
287:    in every iteration.

289:    Not Collective

291:    Input Parameter:
292: .  eps - the eigenproblem solver context

294:    Output Parameter:
295: .  blocksize - number of vectors added to the search space in every iteration

297:    Level: advanced

299: .seealso: EPSGDSetBlockSize()
300: @*/
301: PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize)
302: {

308:   PetscUseMethod(eps,"EPSGDGetBlockSize_C",(EPS,PetscInt*),(eps,blocksize));
309:   return(0);
310: }

314: /*@
315:    EPSGDGetRestart - Gets the number of vectors of the searching space after
316:    restarting and the number of vectors saved from the previous iteration.

318:    Not Collective

320:    Input Parameter:
321: .  eps - the eigenproblem solver context

323:    Output Parameter:
324: +  minv - number of vectors of the searching subspace after restarting
325: -  plusk - number of vectors saved from the previous iteration

327:    Level: advanced

329: .seealso: EPSGDSetRestart()
330: @*/
331: PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)
332: {

337:   PetscUseMethod(eps,"EPSGDGetRestart_C",(EPS,PetscInt*,PetscInt*),(eps,minv,plusk));
338:   return(0);
339: }

343: /*@
344:    EPSGDSetRestart - Sets the number of vectors of the searching space after
345:    restarting and the number of vectors saved from the previous iteration.

347:    Logically Collective on EPS

349:    Input Parameters:
350: +  eps - the eigenproblem solver context
351: .  minv - number of vectors of the searching subspace after restarting
352: -  plusk - number of vectors saved from the previous iteration

354:    Options Database Keys:
355: +  -eps_gd_minv - number of vectors of the searching subspace after restarting
356: -  -eps_gd_plusk - number of vectors saved from the previous iteration

358:    Level: advanced

360: .seealso: EPSGDSetRestart()
361: @*/
362: PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)
363: {

370:   PetscTryMethod(eps,"EPSGDSetRestart_C",(EPS,PetscInt,PetscInt),(eps,minv,plusk));
371:   return(0);
372: }

376: /*@
377:    EPSGDGetInitialSize - Returns the initial size of the searching space.

379:    Not Collective

381:    Input Parameter:
382: .  eps - the eigenproblem solver context

384:    Output Parameter:
385: .  initialsize - number of vectors of the initial searching subspace

387:    Notes:
388:    If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
389:    EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
390:    provided vectors are not enough, the solver completes the subspace with
391:    random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver
392:    gets the first vector provided by the user or, if not available, a random vector,
393:    and expands the Krylov basis up to initialsize vectors.

395:    Level: advanced

397: .seealso: EPSGDSetInitialSize(), EPSGDGetKrylovStart()
398: @*/
399: PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize)
400: {

406:   PetscUseMethod(eps,"EPSGDGetInitialSize_C",(EPS,PetscInt*),(eps,initialsize));
407:   return(0);
408: }

412: /*@
413:    EPSGDSetInitialSize - Sets the initial size of the searching space.

415:    Logically Collective on EPS

417:    Input Parameters:
418: +  eps - the eigenproblem solver context
419: -  initialsize - number of vectors of the initial searching subspace

421:    Options Database Key:
422: .  -eps_gd_initial_size - number of vectors of the initial searching subspace

424:    Notes:
425:    If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with
426:    EPSSetInitialSpace(), up to initialsize vectors will be used; and if the
427:    provided vectors are not enough, the solver completes the subspace with
428:    random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver
429:    gets the first vector provided by the user or, if not available, a random vector,
430:    and expands the Krylov basis up to initialsize vectors.

432:    Level: advanced

434: .seealso: EPSGDGetInitialSize(), EPSGDGetKrylovStart()
435: @*/
436: PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize)
437: {

443:   PetscTryMethod(eps,"EPSGDSetInitialSize_C",(EPS,PetscInt),(eps,initialsize));
444:   return(0);
445: }

449: /*@
450:    EPSGDSetBOrth - Selects the orthogonalization that will be used in the search
451:    subspace in case of generalized Hermitian problems.

453:    Logically Collective on EPS

455:    Input Parameters:
456: +  eps   - the eigenproblem solver context
457: -  borth - whether to B-orthogonalize the search subspace

459:    Options Database Key:
460: .  -eps_gd_borth - Set the orthogonalization used in the search subspace

462:    Level: advanced

464: .seealso: EPSGDGetBOrth()
465: @*/
466: PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth)
467: {

473:   PetscTryMethod(eps,"EPSGDSetBOrth_C",(EPS,PetscBool),(eps,borth));
474:   return(0);
475: }

479: /*@
480:    EPSGDGetBOrth - Returns the orthogonalization used in the search
481:    subspace in case of generalized Hermitian problems.

483:    Not Collective

485:    Input Parameter:
486: .  eps - the eigenproblem solver context

488:    Output Parameters:
489: .  borth - whether to B-orthogonalize the search subspace

491:    Level: advanced

493: .seealso: EPSGDSetBOrth()
494: @*/
495: PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth)
496: {

502:   PetscUseMethod(eps,"EPSGDGetBOrth_C",(EPS,PetscBool*),(eps,borth));
503:   return(0);
504: }

508: /*@
509:    EPSGDGetWindowSizes - Gets the number of converged vectors in the projected
510:    problem (or Rayleigh quotient) and in the projector employed in the correction
511:    equation.

513:    Not Collective

515:    Input Parameter:
516: .  eps - the eigenproblem solver context

518:    Output Parameter:
519: +  pwindow - number of converged vectors in the projector
520: -  qwindow - number of converged vectors in the projected problem

522:    Level: advanced

524: .seealso: EPSGDSetWindowSizes()
525: @*/
526: PetscErrorCode EPSGDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)
527: {

532:   PetscUseMethod(eps,"EPSGDGetWindowSizes_C",(EPS,PetscInt*,PetscInt*),(eps,pwindow,qwindow));
533:   return(0);
534: }

538: /*@
539:    EPSGDSetWindowSizes - Sets the number of converged vectors in the projected
540:    problem (or Rayleigh quotient) and in the projector employed in the correction
541:    equation.

543:    Logically Collective on EPS

545:    Input Parameters:
546: +  eps - the eigenproblem solver context
547: .  pwindow - number of converged vectors in the projector
548: -  qwindow - number of converged vectors in the projected problem

550:    Options Database Keys:
551: +  -eps_gd_pwindow - set the number of converged vectors in the projector
552: -  -eps_gd_qwindow - set the number of converged vectors in the projected problem

554:    Level: advanced

556: .seealso: EPSGDGetWindowSizes()
557: @*/
558: PetscErrorCode EPSGDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)
559: {

566:   PetscTryMethod(eps,"EPSGDSetWindowSizes_C",(EPS,PetscInt,PetscInt),(eps,pwindow,qwindow));
567:   return(0);
568: }

572: static PetscErrorCode EPSGDGetDoubleExpansion_GD(EPS eps,PetscBool *doubleexp)
573: {
574:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

577:   *doubleexp = data->doubleexp;
578:   return(0);
579: }

583: /*@
584:    EPSGDGetDoubleExpansion - Gets a flag indicating whether the double
585:    expansion variant has been activated or not.

587:    Not Collective

589:    Input Parameter:
590: .  eps - the eigenproblem solver context

592:    Output Parameter:
593: .  doubleexp - the flag

595:    Level: advanced

597: .seealso: EPSGDSetDoubleExpansion()
598: @*/
599: PetscErrorCode EPSGDGetDoubleExpansion(EPS eps,PetscBool *doubleexp)
600: {

606:   PetscUseMethod(eps,"EPSGDGetDoubleExpansion_C",(EPS,PetscBool*),(eps,doubleexp));
607:   return(0);
608: }

612: static PetscErrorCode EPSGDSetDoubleExpansion_GD(EPS eps,PetscBool doubleexp)
613: {
614:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

617:   data->doubleexp = doubleexp;
618:   return(0);
619: }

623: /*@
624:    EPSGDSetDoubleExpansion - Activate a variant where the search subspace is
625:    expanded with K*[A*x B*x] (double expansion) instead of the classic K*r,
626:    where K is the preconditioner, x the selected approximate eigenvector and
627:    r its associated residual vector.

629:    Logically Collective on EPS

631:    Input Parameters:
632: +  eps - the eigenproblem solver context
633: -  doubleexp - the boolean flag

635:    Options Database Keys:
636: .  -eps_gd_double_expansion - activate the double-expansion variant of GD

638:    Level: advanced
639: @*/
640: PetscErrorCode EPSGDSetDoubleExpansion(EPS eps,PetscBool doubleexp)
641: {

647:   PetscTryMethod(eps,"EPSGDSetDoubleExpansion_C",(EPS,PetscBool),(eps,doubleexp));
648:   return(0);
649: }

653: PETSC_EXTERN PetscErrorCode EPSCreate_GD(EPS eps)
654: {
655:   PetscErrorCode  ierr;
656:   EPS_DAVIDSON    *data;

659:   PetscNewLog(eps,&data);
660:   eps->data = (void*)data;

662:   data->blocksize   = 1;
663:   data->initialsize = 6;
664:   data->minv        = 6;
665:   data->plusk       = 0;
666:   data->ipB         = PETSC_TRUE;
667:   data->fix         = 0.0;
668:   data->krylovstart = PETSC_FALSE;
669:   data->dynamic     = PETSC_FALSE;
670:   data->cX_in_proj  = 0;
671:   data->cX_in_impr  = 0;

673:   eps->ops->solve          = EPSSolve_XD;
674:   eps->ops->setup          = EPSSetUp_XD;
675:   eps->ops->reset          = EPSReset_XD;
676:   eps->ops->backtransform  = EPSBackTransform_Default;
677:   eps->ops->computevectors = EPSComputeVectors_XD;
678:   eps->ops->view           = EPSView_GD;
679:   eps->ops->setfromoptions = EPSSetFromOptions_GD;
680:   eps->ops->setup          = EPSSetUp_GD;
681:   eps->ops->destroy        = EPSDestroy_GD;

683:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetKrylovStart_C",EPSXDSetKrylovStart_XD);
684:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetKrylovStart_C",EPSXDGetKrylovStart_XD);
685:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBOrth_C",EPSXDSetBOrth_XD);
686:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBOrth_C",EPSXDGetBOrth_XD);
687:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBlockSize_C",EPSXDSetBlockSize_XD);
688:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBlockSize_C",EPSXDGetBlockSize_XD);
689:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetRestart_C",EPSXDSetRestart_XD);
690:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetRestart_C",EPSXDGetRestart_XD);
691:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetInitialSize_C",EPSXDSetInitialSize_XD);
692:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetInitialSize_C",EPSXDGetInitialSize_XD);
693:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetWindowSizes_C",EPSXDSetWindowSizes_XD);
694:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetWindowSizes_C",EPSXDGetWindowSizes_XD);
695:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetDoubleExpansion_C",EPSGDSetDoubleExpansion_GD);
696:   PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetDoubleExpansion_C",EPSGDGetDoubleExpansion_GD);
697:   return(0);
698: }

slepc-3.7.4/src/eps/impls/davidson/gd/gd.c0000644000175000017500000005750213107004621017635 0ustar jromanjroman/* SLEPc eigensolver: "gd" Method: Generalized Davidson Algorithm: Generalized Davidson with various subspace extraction and restart techniques. References: [1] E.R. Davidson, "Super-matrix methods", Comput. Phys. Commun. 53(2):49-60, 1989. [2] E. Romero and J.E. Roman, "A parallel implementation of Davidson methods for large-scale eigenvalue problems in SLEPc", ACM Trans. Math. Software 40(2), Article 13, 2014. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include <../src/eps/impls/davidson/davidson.h> #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_GD" PetscErrorCode EPSSetFromOptions_GD(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; PetscBool flg,op; PetscInt opi,opi0; KSP ksp; PetscBool orth; const char *orth_list[2] = {"I","B"}; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS Generalized Davidson (GD) Options");CHKERRQ(ierr); ierr = EPSGDGetKrylovStart(eps,&op);CHKERRQ(ierr); ierr = PetscOptionsBool("-eps_gd_krylov_start","Start the searching subspace with a krylov basis","EPSGDSetKrylovStart",op,&op,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetKrylovStart(eps,op);CHKERRQ(ierr); } ierr = EPSGDGetBOrth(eps,&orth);CHKERRQ(ierr); ierr = PetscOptionsEList("-eps_gd_borth","orthogonalization used in the search subspace","EPSGDSetBOrth",orth_list,2,orth_list[orth?1:0],&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetBOrth(eps,opi==1?PETSC_TRUE:PETSC_FALSE);CHKERRQ(ierr); } ierr = EPSGDGetBlockSize(eps,&opi);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_gd_blocksize","Number vectors add to the searching subspace","EPSGDSetBlockSize",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetBlockSize(eps,opi);CHKERRQ(ierr); } ierr = EPSGDGetRestart(eps,&opi,&opi0);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_gd_minv","Set the size of the searching subspace after restarting","EPSGDSetRestart",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetRestart(eps,opi,opi0);CHKERRQ(ierr); } ierr = PetscOptionsInt("-eps_gd_plusk","Set the number of saved eigenvectors from the previous iteration when restarting","EPSGDSetRestart",opi0,&opi0,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetRestart(eps,opi,opi0);CHKERRQ(ierr); } ierr = EPSGDGetInitialSize(eps,&opi);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_gd_initial_size","Set the initial size of the searching subspace","EPSGDSetInitialSize",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetInitialSize(eps,opi);CHKERRQ(ierr); } ierr = EPSGDGetWindowSizes(eps,&opi,&opi0);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_gd_pwindow","(Experimental!) Set the number of converged vectors in the projector","EPSGDSetWindowSizes",opi,&opi,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); } ierr = PetscOptionsInt("-eps_gd_qwindow","(Experimental!) Set the number of converged vectors in the projected problem","EPSGDSetWindowSizes",opi0,&opi0,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetWindowSizes(eps,opi,opi0);CHKERRQ(ierr); } ierr = PetscOptionsBool("-eps_gd_double_expansion","use the doble-expansion variant of GD","EPSGDSetDoubleExpansion",PETSC_FALSE,&op,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSGDSetDoubleExpansion(eps,op);CHKERRQ(ierr); } /* Set STPrecond as the default ST */ if (!((PetscObject)eps->st)->type_name) { ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); } ierr = STPrecondSetKSPHasMat(eps->st,PETSC_FALSE);CHKERRQ(ierr); /* Set the default options of the KSP */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_GD" PetscErrorCode EPSSetUp_GD(EPS eps) { PetscErrorCode ierr; PetscBool t; KSP ksp; PetscFunctionBegin; /* Set KSPPREONLY as default */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPPREONLY);CHKERRQ(ierr); } /* Setup common for all davidson solvers */ ierr = EPSSetUp_XD(eps);CHKERRQ(ierr); /* Check some constraints */ ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&t);CHKERRQ(ierr); if (!t) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"EPSGD only works with KSPPREONLY"); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_GD" PetscErrorCode EPSView_GD(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii,opb; PetscInt opi,opi0; PetscBool borth; EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (data->doubleexp) { ierr = PetscViewerASCIIPrintf(viewer," GD: using double expansion variant (GD2)\n");CHKERRQ(ierr); } ierr = EPSXDGetBOrth_XD(eps,&borth);CHKERRQ(ierr); if (borth) { ierr = PetscViewerASCIIPrintf(viewer," GD: search subspace is B-orthogonalized\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," GD: search subspace is orthogonalized\n");CHKERRQ(ierr); } ierr = EPSXDGetBlockSize_XD(eps,&opi);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," GD: block size=%D\n",opi);CHKERRQ(ierr); ierr = EPSXDGetKrylovStart_XD(eps,&opb);CHKERRQ(ierr); if (!opb) { ierr = PetscViewerASCIIPrintf(viewer," GD: type of the initial subspace: non-Krylov\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," GD: type of the initial subspace: Krylov\n");CHKERRQ(ierr); } ierr = EPSXDGetRestart_XD(eps,&opi,&opi0);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," GD: size of the subspace after restarting: %D\n",opi);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," GD: number of vectors after restarting from the previous iteration: %D\n",opi0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_GD" PetscErrorCode EPSDestroy_GD(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetKrylovStart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetKrylovStart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBOrth_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBOrth_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBlockSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetInitialSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetInitialSize_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetWindowSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetWindowSizes_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetDoubleExpansion_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetDoubleExpansion_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetKrylovStart" /*@ EPSGDSetKrylovStart - Activates or deactivates starting the searching subspace with a Krylov basis. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - krylovstart - boolean flag Options Database Key: . -eps_gd_krylov_start - Activates starting the searching subspace with a Krylov basis Level: advanced .seealso: EPSGDGetKrylovStart() @*/ PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,krylovstart,2); ierr = PetscTryMethod(eps,"EPSGDSetKrylovStart_C",(EPS,PetscBool),(eps,krylovstart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetKrylovStart" /*@ EPSGDGetKrylovStart - Returns a flag indicating if the search subspace is started with a Krylov basis. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: . krylovstart - boolean flag indicating if the search subspace is started with a Krylov basis Level: advanced .seealso: EPSGDGetKrylovStart() @*/ PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(krylovstart,2); ierr = PetscUseMethod(eps,"EPSGDGetKrylovStart_C",(EPS,PetscBool*),(eps,krylovstart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetBlockSize" /*@ EPSGDSetBlockSize - Sets the number of vectors to be added to the searching space in every iteration. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - blocksize - number of vectors added to the search space in every iteration Options Database Key: . -eps_gd_blocksize - number of vectors added to the search space in every iteration Level: advanced .seealso: EPSGDSetKrylovStart() @*/ PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,blocksize,2); ierr = PetscTryMethod(eps,"EPSGDSetBlockSize_C",(EPS,PetscInt),(eps,blocksize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetBlockSize" /*@ EPSGDGetBlockSize - Returns the number of vectors to be added to the searching space in every iteration. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . blocksize - number of vectors added to the search space in every iteration Level: advanced .seealso: EPSGDSetBlockSize() @*/ PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(blocksize,2); ierr = PetscUseMethod(eps,"EPSGDGetBlockSize_C",(EPS,PetscInt*),(eps,blocksize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetRestart" /*@ EPSGDGetRestart - Gets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: + minv - number of vectors of the searching subspace after restarting - plusk - number of vectors saved from the previous iteration Level: advanced .seealso: EPSGDSetRestart() @*/ PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSGDGetRestart_C",(EPS,PetscInt*,PetscInt*),(eps,minv,plusk));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetRestart" /*@ EPSGDSetRestart - Sets the number of vectors of the searching space after restarting and the number of vectors saved from the previous iteration. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . minv - number of vectors of the searching subspace after restarting - plusk - number of vectors saved from the previous iteration Options Database Keys: + -eps_gd_minv - number of vectors of the searching subspace after restarting - -eps_gd_plusk - number of vectors saved from the previous iteration Level: advanced .seealso: EPSGDSetRestart() @*/ PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,minv,2); PetscValidLogicalCollectiveInt(eps,plusk,2); ierr = PetscTryMethod(eps,"EPSGDSetRestart_C",(EPS,PetscInt,PetscInt),(eps,minv,plusk));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetInitialSize" /*@ EPSGDGetInitialSize - Returns the initial size of the searching space. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . initialsize - number of vectors of the initial searching subspace Notes: If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors. Level: advanced .seealso: EPSGDSetInitialSize(), EPSGDGetKrylovStart() @*/ PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(initialsize,2); ierr = PetscUseMethod(eps,"EPSGDGetInitialSize_C",(EPS,PetscInt*),(eps,initialsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetInitialSize" /*@ EPSGDSetInitialSize - Sets the initial size of the searching space. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - initialsize - number of vectors of the initial searching subspace Options Database Key: . -eps_gd_initial_size - number of vectors of the initial searching subspace Notes: If EPSGDGetKrylovStart() is PETSC_FALSE and the user provides vectors with EPSSetInitialSpace(), up to initialsize vectors will be used; and if the provided vectors are not enough, the solver completes the subspace with random vectors. In the case of EPSGDGetKrylovStart() being PETSC_TRUE, the solver gets the first vector provided by the user or, if not available, a random vector, and expands the Krylov basis up to initialsize vectors. Level: advanced .seealso: EPSGDGetInitialSize(), EPSGDGetKrylovStart() @*/ PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,initialsize,2); ierr = PetscTryMethod(eps,"EPSGDSetInitialSize_C",(EPS,PetscInt),(eps,initialsize));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetBOrth" /*@ EPSGDSetBOrth - Selects the orthogonalization that will be used in the search subspace in case of generalized Hermitian problems. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - borth - whether to B-orthogonalize the search subspace Options Database Key: . -eps_gd_borth - Set the orthogonalization used in the search subspace Level: advanced .seealso: EPSGDGetBOrth() @*/ PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,borth,2); ierr = PetscTryMethod(eps,"EPSGDSetBOrth_C",(EPS,PetscBool),(eps,borth));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetBOrth" /*@ EPSGDGetBOrth - Returns the orthogonalization used in the search subspace in case of generalized Hermitian problems. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: . borth - whether to B-orthogonalize the search subspace Level: advanced .seealso: EPSGDSetBOrth() @*/ PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(borth,2); ierr = PetscUseMethod(eps,"EPSGDGetBOrth_C",(EPS,PetscBool*),(eps,borth));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetWindowSizes" /*@ EPSGDGetWindowSizes - Gets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: + pwindow - number of converged vectors in the projector - qwindow - number of converged vectors in the projected problem Level: advanced .seealso: EPSGDSetWindowSizes() @*/ PetscErrorCode EPSGDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSGDGetWindowSizes_C",(EPS,PetscInt*,PetscInt*),(eps,pwindow,qwindow));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetWindowSizes" /*@ EPSGDSetWindowSizes - Sets the number of converged vectors in the projected problem (or Rayleigh quotient) and in the projector employed in the correction equation. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . pwindow - number of converged vectors in the projector - qwindow - number of converged vectors in the projected problem Options Database Keys: + -eps_gd_pwindow - set the number of converged vectors in the projector - -eps_gd_qwindow - set the number of converged vectors in the projected problem Level: advanced .seealso: EPSGDGetWindowSizes() @*/ PetscErrorCode EPSGDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,pwindow,2); PetscValidLogicalCollectiveInt(eps,qwindow,3); ierr = PetscTryMethod(eps,"EPSGDSetWindowSizes_C",(EPS,PetscInt,PetscInt),(eps,pwindow,qwindow));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetDoubleExpansion_GD" static PetscErrorCode EPSGDGetDoubleExpansion_GD(EPS eps,PetscBool *doubleexp) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; *doubleexp = data->doubleexp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDGetDoubleExpansion" /*@ EPSGDGetDoubleExpansion - Gets a flag indicating whether the double expansion variant has been activated or not. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . doubleexp - the flag Level: advanced .seealso: EPSGDSetDoubleExpansion() @*/ PetscErrorCode EPSGDGetDoubleExpansion(EPS eps,PetscBool *doubleexp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(doubleexp,2); ierr = PetscUseMethod(eps,"EPSGDGetDoubleExpansion_C",(EPS,PetscBool*),(eps,doubleexp));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetDoubleExpansion_GD" static PetscErrorCode EPSGDSetDoubleExpansion_GD(EPS eps,PetscBool doubleexp) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; data->doubleexp = doubleexp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSGDSetDoubleExpansion" /*@ EPSGDSetDoubleExpansion - Activate a variant where the search subspace is expanded with K*[A*x B*x] (double expansion) instead of the classic K*r, where K is the preconditioner, x the selected approximate eigenvector and r its associated residual vector. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - doubleexp - the boolean flag Options Database Keys: . -eps_gd_double_expansion - activate the double-expansion variant of GD Level: advanced @*/ PetscErrorCode EPSGDSetDoubleExpansion(EPS eps,PetscBool doubleexp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,doubleexp,2); ierr = PetscTryMethod(eps,"EPSGDSetDoubleExpansion_C",(EPS,PetscBool),(eps,doubleexp));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_GD" PETSC_EXTERN PetscErrorCode EPSCreate_GD(EPS eps) { PetscErrorCode ierr; EPS_DAVIDSON *data; PetscFunctionBegin; ierr = PetscNewLog(eps,&data);CHKERRQ(ierr); eps->data = (void*)data; data->blocksize = 1; data->initialsize = 6; data->minv = 6; data->plusk = 0; data->ipB = PETSC_TRUE; data->fix = 0.0; data->krylovstart = PETSC_FALSE; data->dynamic = PETSC_FALSE; data->cX_in_proj = 0; data->cX_in_impr = 0; eps->ops->solve = EPSSolve_XD; eps->ops->setup = EPSSetUp_XD; eps->ops->reset = EPSReset_XD; eps->ops->backtransform = EPSBackTransform_Default; eps->ops->computevectors = EPSComputeVectors_XD; eps->ops->view = EPSView_GD; eps->ops->setfromoptions = EPSSetFromOptions_GD; eps->ops->setup = EPSSetUp_GD; eps->ops->destroy = EPSDestroy_GD; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetKrylovStart_C",EPSXDSetKrylovStart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetKrylovStart_C",EPSXDGetKrylovStart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBOrth_C",EPSXDSetBOrth_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBOrth_C",EPSXDGetBOrth_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetBlockSize_C",EPSXDSetBlockSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetBlockSize_C",EPSXDGetBlockSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetRestart_C",EPSXDSetRestart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetRestart_C",EPSXDGetRestart_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetInitialSize_C",EPSXDSetInitialSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetInitialSize_C",EPSXDGetInitialSize_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetWindowSizes_C",EPSXDSetWindowSizes_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetWindowSizes_C",EPSXDGetWindowSizes_XD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDSetDoubleExpansion_C",EPSGDSetDoubleExpansion_GD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSGDGetDoubleExpansion_C",EPSGDGetDoubleExpansion_GD);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/gd/index.html0000644000175000017500000000260213107004621021063 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

gd.c
makefile
slepc-3.7.4/src/eps/impls/davidson/gd/ftn-auto/0000755000175000017500000000000013107004621020623 5ustar jromanjromanslepc-3.7.4/src/eps/impls/davidson/gd/ftn-auto/makefile0000644000175000017500000000036213107004621022324 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = gdf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/davidson/gd/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/davidson/gd/ftn-auto/gdf.c0000644000175000017500000001405713107004621021536 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* gd.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdsetkrylovstart_ EPSGDSETKRYLOVSTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdsetkrylovstart_ epsgdsetkrylovstart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdgetkrylovstart_ EPSGDGETKRYLOVSTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdgetkrylovstart_ epsgdgetkrylovstart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdsetblocksize_ EPSGDSETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdsetblocksize_ epsgdsetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdgetblocksize_ EPSGDGETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdgetblocksize_ epsgdgetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdgetrestart_ EPSGDGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdgetrestart_ epsgdgetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdsetrestart_ EPSGDSETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdsetrestart_ epsgdsetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdgetinitialsize_ EPSGDGETINITIALSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdgetinitialsize_ epsgdgetinitialsize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdsetinitialsize_ EPSGDSETINITIALSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdsetinitialsize_ epsgdsetinitialsize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdsetborth_ EPSGDSETBORTH #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdsetborth_ epsgdsetborth #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdgetborth_ EPSGDGETBORTH #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdgetborth_ epsgdgetborth #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdgetwindowsizes_ EPSGDGETWINDOWSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdgetwindowsizes_ epsgdgetwindowsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdsetwindowsizes_ EPSGDSETWINDOWSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdsetwindowsizes_ epsgdsetwindowsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdgetdoubleexpansion_ EPSGDGETDOUBLEEXPANSION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdgetdoubleexpansion_ epsgdgetdoubleexpansion #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsgdsetdoubleexpansion_ EPSGDSETDOUBLEEXPANSION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsgdsetdoubleexpansion_ epsgdsetdoubleexpansion #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsgdsetkrylovstart_(EPS eps,PetscBool *krylovstart, int *__ierr ){ *__ierr = EPSGDSetKrylovStart( (EPS)PetscToPointer((eps) ),*krylovstart); } PETSC_EXTERN void PETSC_STDCALL epsgdgetkrylovstart_(EPS eps,PetscBool *krylovstart, int *__ierr ){ *__ierr = EPSGDGetKrylovStart( (EPS)PetscToPointer((eps) ),krylovstart); } PETSC_EXTERN void PETSC_STDCALL epsgdsetblocksize_(EPS eps,PetscInt *blocksize, int *__ierr ){ *__ierr = EPSGDSetBlockSize( (EPS)PetscToPointer((eps) ),*blocksize); } PETSC_EXTERN void PETSC_STDCALL epsgdgetblocksize_(EPS eps,PetscInt *blocksize, int *__ierr ){ *__ierr = EPSGDGetBlockSize( (EPS)PetscToPointer((eps) ),blocksize); } PETSC_EXTERN void PETSC_STDCALL epsgdgetrestart_(EPS eps,PetscInt *minv,PetscInt *plusk, int *__ierr ){ *__ierr = EPSGDGetRestart( (EPS)PetscToPointer((eps) ),minv,plusk); } PETSC_EXTERN void PETSC_STDCALL epsgdsetrestart_(EPS eps,PetscInt *minv,PetscInt *plusk, int *__ierr ){ *__ierr = EPSGDSetRestart( (EPS)PetscToPointer((eps) ),*minv,*plusk); } PETSC_EXTERN void PETSC_STDCALL epsgdgetinitialsize_(EPS eps,PetscInt *initialsize, int *__ierr ){ *__ierr = EPSGDGetInitialSize( (EPS)PetscToPointer((eps) ),initialsize); } PETSC_EXTERN void PETSC_STDCALL epsgdsetinitialsize_(EPS eps,PetscInt *initialsize, int *__ierr ){ *__ierr = EPSGDSetInitialSize( (EPS)PetscToPointer((eps) ),*initialsize); } PETSC_EXTERN void PETSC_STDCALL epsgdsetborth_(EPS eps,PetscBool *borth, int *__ierr ){ *__ierr = EPSGDSetBOrth( (EPS)PetscToPointer((eps) ),*borth); } PETSC_EXTERN void PETSC_STDCALL epsgdgetborth_(EPS eps,PetscBool *borth, int *__ierr ){ *__ierr = EPSGDGetBOrth( (EPS)PetscToPointer((eps) ),borth); } PETSC_EXTERN void PETSC_STDCALL epsgdgetwindowsizes_(EPS eps,PetscInt *pwindow,PetscInt *qwindow, int *__ierr ){ *__ierr = EPSGDGetWindowSizes( (EPS)PetscToPointer((eps) ),pwindow,qwindow); } PETSC_EXTERN void PETSC_STDCALL epsgdsetwindowsizes_(EPS eps,PetscInt *pwindow,PetscInt *qwindow, int *__ierr ){ *__ierr = EPSGDSetWindowSizes( (EPS)PetscToPointer((eps) ),*pwindow,*qwindow); } PETSC_EXTERN void PETSC_STDCALL epsgdgetdoubleexpansion_(EPS eps,PetscBool *doubleexp, int *__ierr ){ *__ierr = EPSGDGetDoubleExpansion( (EPS)PetscToPointer((eps) ),doubleexp); } PETSC_EXTERN void PETSC_STDCALL epsgdsetdoubleexpansion_(EPS eps,PetscBool *doubleexp, int *__ierr ){ *__ierr = EPSGDSetDoubleExpansion( (EPS)PetscToPointer((eps) ),*doubleexp); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/davidson/dvdtestconv.c.html0000644000175000017500000001232513107004621022151 0ustar jromanjroman

Actual source code: dvdtestconv.c

slepc-3.7.4 2017-05-17
  1: /*
  2:   SLEPc eigensolver: "davidson"

  4:   Step: test for convergence

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

 10:    This file is part of SLEPc.

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

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

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

 26:  #include davidson.h

 30: static PetscBool dvd_testconv_basic_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err)
 31: {
 32:   PetscBool conv;
 33:   PetscReal eig_norm,errest;

 36:   eig_norm = SlepcAbsEigenvalue(eigvr, eigvi);
 37:   errest = r/eig_norm;
 38:   conv = PetscNot(errest > d->tol);
 39:   if (err) *err = errest;
 40:   PetscFunctionReturn(conv);
 41: }

 45: PetscErrorCode dvd_testconv_basic(dvdDashboard *d, dvdBlackboard *b)
 46: {

 50:   /* Setup the step */
 51:   if (b->state >= DVD_STATE_CONF) {
 52:     PetscFree(d->testConv_data);
 53:     d->testConv = dvd_testconv_basic_0;
 54:   }
 55:   return(0);
 56: }

 60: static PetscBool dvd_testconv_slepc_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err)
 61: {

 65:   (*d->eps->converged)(d->eps,eigvr,eigvi,r,err,d->eps->convergedctx);CHKERRABORT(PetscObjectComm((PetscObject)d->eps),ierr);
 66:   PetscFunctionReturn(PetscNot(*err>=d->eps->tol));
 67: }

 71: PetscErrorCode dvd_testconv_slepc(dvdDashboard *d, dvdBlackboard *b)
 72: {

 76:   /* Setup the step */
 77:   if (b->state >= DVD_STATE_CONF) {
 78:     PetscFree(d->testConv_data);
 79:     d->testConv = dvd_testconv_slepc_0;
 80:   }
 81:   return(0);
 82: }

slepc-3.7.4/src/eps/impls/davidson/davidson.c.html0000644000175000017500000011164413107004621021421 0ustar jromanjroman
Actual source code: davidson.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Skeleton of Davidson solver. Actual solvers are GD and JD.

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

  8:    This file is part of SLEPc.

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

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

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

 24:  #include davidson.h

 26: static PetscBool  cited = PETSC_FALSE;
 27: static const char citation[] =
 28:   "@Article{slepc-davidson,\n"
 29:   "   author = \"E. Romero and J. E. Roman\",\n"
 30:   "   title = \"A parallel implementation of {Davidson} methods for large-scale eigenvalue problems in {SLEPc}\",\n"
 31:   "   journal = \"{ACM} Trans. Math. Software\",\n"
 32:   "   volume = \"40\",\n"
 33:   "   number = \"2\",\n"
 34:   "   pages = \"13:1--13:29\",\n"
 35:   "   year = \"2014,\"\n"
 36:   "   doi = \"http://dx.doi.org/10.1145/2543696\"\n"
 37:   "}\n";

 41: PetscErrorCode EPSSetUp_XD(EPS eps)
 42: {
 44:   EPS_DAVIDSON   *data = (EPS_DAVIDSON*)eps->data;
 45:   dvdDashboard   *dvd = &data->ddb;
 46:   dvdBlackboard  b;
 47:   PetscInt       min_size_V,plusk,bs,initv,i,cX_in_proj,cX_in_impr,nmat;
 48:   Mat            A,B;
 49:   KSP            ksp;
 50:   PetscBool      t,ipB,ispositive,dynamic;
 51:   HarmType_t     harm;
 52:   InitType_t     init;
 53:   PetscReal      fix;
 54:   PetscScalar    target;

 57:   /* Setup EPS options and get the problem specification */
 58:   EPSXDGetBlockSize_XD(eps,&bs);
 59:   if (bs <= 0) bs = 1;
 60:   if (eps->ncv) {
 61:     if (eps->ncv<eps->nev) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The value of ncv must be at least nev");
 62:   } else if (eps->mpd) eps->ncv = eps->mpd + eps->nev + bs;
 63:   else if (eps->nev<500) eps->ncv = PetscMin(eps->n-bs,PetscMax(2*eps->nev,eps->nev+15))+bs;
 64:   else eps->ncv = PetscMin(eps->n-bs,eps->nev+500)+bs;
 65:   if (!eps->mpd) eps->mpd = eps->ncv;
 66:   if (eps->mpd > eps->ncv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The mpd has to be less or equal than ncv");
 67:   if (eps->mpd < 2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The mpd has to be greater than 2");
 68:   if (!eps->max_it) eps->max_it = PetscMax(100*eps->ncv,2*eps->n);
 69:   if (!eps->which) eps->which = EPS_LARGEST_MAGNITUDE;
 70:   if (eps->ishermitian && (eps->which==EPS_LARGEST_IMAGINARY || eps->which==EPS_SMALLEST_IMAGINARY)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Wrong value of eps->which");
 71:   if (!(eps->nev + bs <= eps->ncv)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The ncv has to be greater than nev plus blocksize");
 72:   if (eps->trueres) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"-eps_true_residual is temporally disable in this solver.");

 74:   EPSXDGetRestart_XD(eps,&min_size_V,&plusk);
 75:   if (!min_size_V) min_size_V = PetscMin(PetscMax(bs,5),eps->mpd/2);
 76:   if (!(min_size_V+bs <= eps->mpd)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The value of minv must be less than mpd minus blocksize");
 77:   EPSXDGetInitialSize_XD(eps,&initv);
 78:   if (eps->mpd < initv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The initv has to be less or equal than mpd");

 80:   /* Set STPrecond as the default ST */
 81:   if (!((PetscObject)eps->st)->type_name) {
 82:     STSetType(eps->st,STPRECOND);
 83:   }
 84:   STPrecondSetKSPHasMat(eps->st,PETSC_FALSE);

 86:   /* Change the default sigma to inf if necessary */
 87:   if (eps->which == EPS_LARGEST_MAGNITUDE || eps->which == EPS_LARGEST_REAL || eps->which == EPS_LARGEST_IMAGINARY) {
 88:     STSetDefaultShift(eps->st,PETSC_MAX_REAL);
 89:   }

 91:   /* Davidson solvers only support STPRECOND */
 92:   STSetUp(eps->st);
 93:   PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&t);
 94:   if (!t) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"%s only works with precond spectral transformation",((PetscObject)eps)->type_name);

 96:   /* Setup problem specification in dvd */
 97:   STGetNumMatrices(eps->st,&nmat);
 98:   STGetOperators(eps->st,0,&A);
 99:   if (nmat>1) { STGetOperators(eps->st,1,&B); }
100:   EPSReset_XD(eps);
101:   PetscMemzero(dvd,sizeof(dvdDashboard));
102:   dvd->A = A; dvd->B = eps->isgeneralized? B: NULL;
103:   ispositive = eps->ispositive;
104:   dvd->sA = DVD_MAT_IMPLICIT | (eps->ishermitian? DVD_MAT_HERMITIAN: 0) | ((ispositive && !eps->isgeneralized) ? DVD_MAT_POS_DEF: 0);
105:   /* Asume -eps_hermitian means hermitian-definite in generalized problems */
106:   if (!ispositive && !eps->isgeneralized && eps->ishermitian) ispositive = PETSC_TRUE;
107:   if (!eps->isgeneralized) dvd->sB = DVD_MAT_IMPLICIT | DVD_MAT_HERMITIAN | DVD_MAT_IDENTITY | DVD_MAT_UNITARY | DVD_MAT_POS_DEF;
108:   else dvd->sB = DVD_MAT_IMPLICIT | (eps->ishermitian? DVD_MAT_HERMITIAN: 0) | (ispositive? DVD_MAT_POS_DEF: 0);
109:   ipB = (dvd->B && data->ipB && DVD_IS(dvd->sB,DVD_MAT_HERMITIAN))?PETSC_TRUE:PETSC_FALSE;
110:   if (data->ipB && !ipB) data->ipB = PETSC_FALSE;
111:   dvd->correctXnorm = ipB;
112:   dvd->sEP = ((!eps->isgeneralized || (eps->isgeneralized && ipB))? DVD_EP_STD: 0) | (ispositive? DVD_EP_HERMITIAN: 0) | ((eps->problem_type == EPS_GHIEP && ipB) ? DVD_EP_INDEFINITE : 0);
113:   dvd->nev        = eps->nev;
114:   dvd->which      = eps->which;
115:   dvd->withTarget = PETSC_TRUE;
116:   switch (eps->which) {
117:     case EPS_TARGET_MAGNITUDE:
118:     case EPS_TARGET_IMAGINARY:
119:       dvd->target[0] = target = eps->target;
120:       dvd->target[1] = 1.0;
121:       break;
122:     case EPS_TARGET_REAL:
123:       dvd->target[0] = PetscRealPart(target = eps->target);
124:       dvd->target[1] = 1.0;
125:       break;
126:     case EPS_LARGEST_REAL:
127:     case EPS_LARGEST_MAGNITUDE:
128:     case EPS_LARGEST_IMAGINARY: /* TODO: think about this case */
129:       dvd->target[0] = 1.0;
130:       dvd->target[1] = target = 0.0;
131:       break;
132:     case EPS_SMALLEST_MAGNITUDE:
133:     case EPS_SMALLEST_REAL:
134:     case EPS_SMALLEST_IMAGINARY: /* TODO: think about this case */
135:       dvd->target[0] = target = 0.0;
136:       dvd->target[1] = 1.0;
137:       break;
138:     case EPS_WHICH_USER:
139:       STGetShift(eps->st,&target);
140:       dvd->target[0] = target;
141:       dvd->target[1] = 1.0;
142:       break;
143:     case EPS_ALL:
144:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported option: which == EPS_ALL");
145:       break;
146:     default:
147:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported value of option 'which'");
148:   }
149:   dvd->tol = (eps->tol==PETSC_DEFAULT)? SLEPC_DEFAULT_TOL: eps->tol;
150:   dvd->eps = eps;

152:   /* Setup the extraction technique */
153:   if (!eps->extraction) {
154:     if (ipB || ispositive) eps->extraction = EPS_RITZ;
155:     else {
156:       switch (eps->which) {
157:         case EPS_TARGET_REAL:
158:         case EPS_TARGET_MAGNITUDE:
159:         case EPS_TARGET_IMAGINARY:
160:         case EPS_SMALLEST_MAGNITUDE:
161:         case EPS_SMALLEST_REAL:
162:         case EPS_SMALLEST_IMAGINARY:
163:           eps->extraction = EPS_HARMONIC;
164:           break;
165:         case EPS_LARGEST_REAL:
166:         case EPS_LARGEST_MAGNITUDE:
167:         case EPS_LARGEST_IMAGINARY:
168:           eps->extraction = EPS_HARMONIC_LARGEST;
169:           break;
170:         default:
171:           eps->extraction = EPS_RITZ;
172:       }
173:     }
174:   }
175:   switch (eps->extraction) {
176:     case EPS_RITZ:              harm = DVD_HARM_NONE; break;
177:     case EPS_HARMONIC:          harm = DVD_HARM_RR; break;
178:     case EPS_HARMONIC_RELATIVE: harm = DVD_HARM_RRR; break;
179:     case EPS_HARMONIC_RIGHT:    harm = DVD_HARM_REIGS; break;
180:     case EPS_HARMONIC_LARGEST:  harm = DVD_HARM_LEIGS; break;
181:     default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
182:   }

184:   /* Setup the type of starting subspace */
185:   EPSXDGetKrylovStart_XD(eps,&t);
186:   init = (!t)? DVD_INITV_CLASSIC : DVD_INITV_KRYLOV;

188:   /* Setup the presence of converged vectors in the projected problem and the projector */
189:   EPSXDGetWindowSizes_XD(eps,&cX_in_impr,&cX_in_proj);
190:   if (cX_in_impr>0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The option pwindow is temporally disable in this solver.");
191:   if (cX_in_proj>0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The option qwindow is temporally disable in this solver.");
192:   if (min_size_V <= cX_in_proj) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"minv has to be greater than qwindow");
193:   if (bs > 1 && cX_in_impr > 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported option: pwindow > 0 and bs > 1");

195:   /* Get the fix parameter */
196:   EPSXDGetFix_XD(eps,&fix);

198:   /* Get whether the stopping criterion is used */
199:   EPSJDGetConstCorrectionTol_JD(eps,&dynamic);

201:   /* Preconfigure dvd */
202:   STGetKSP(eps->st,&ksp);
203:   dvd_schm_basic_preconf(dvd,&b,eps->mpd,min_size_V,bs,initv,PetscAbs(eps->nini),plusk,harm,ksp,init,eps->trackall,data->ipB,cX_in_proj,cX_in_impr,data->doubleexp);

205:   /* Allocate memory */
206:   EPSAllocateSolution(eps,0);

208:   /* Setup orthogonalization */
209:   EPS_SetInnerProduct(eps);
210:   if (!(ipB && dvd->B)) {
211:     BVSetMatrix(eps->V,NULL,PETSC_FALSE);
212:   }

214:   for (i=0;i<eps->ncv;i++) eps->perm[i] = i;

216:   /* Configure dvd for a basic GD */
217:   dvd_schm_basic_conf(dvd,&b,eps->mpd,min_size_V,bs,initv,PetscAbs(eps->nini),plusk,harm,dvd->withTarget,target,ksp,fix,init,eps->trackall,data->ipB,cX_in_proj,cX_in_impr,dynamic,data->doubleexp);
218:   return(0);
219: }

223: PetscErrorCode EPSSolve_XD(EPS eps)
224: {
225:   EPS_DAVIDSON   *data = (EPS_DAVIDSON*)eps->data;
226:   dvdDashboard   *d = &data->ddb;
227:   PetscInt       l,k;

231:   PetscCitationsRegister(citation,&cited);
232:   /* Call the starting routines */
233:   EPSDavidsonFLCall(d->startList,d);

235:   while (eps->reason == EPS_CONVERGED_ITERATING) {

237:     /* Initialize V, if it is needed */
238:     BVGetActiveColumns(d->eps->V,&l,&k);
239:     if (l == k) { d->initV(d); }

241:     /* Find the best approximated eigenpairs in V, X */
242:     d->calcPairs(d);

244:     /* Test for convergence */
245:     (*eps->stopping)(eps,eps->its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);
246:     if (eps->reason != EPS_CONVERGED_ITERATING) break;

248:     /* Expand the subspace */
249:     d->updateV(d);

251:     /* Monitor progress */
252:     eps->nconv = d->nconv;
253:     eps->its++;
254:     BVGetActiveColumns(d->eps->V,&l,&k);
255:     EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,k);
256:   }

258:   /* Call the ending routines */
259:   EPSDavidsonFLCall(d->endList,d);
260:   return(0);
261: }

265: PetscErrorCode EPSReset_XD(EPS eps)
266: {
267:   EPS_DAVIDSON   *data = (EPS_DAVIDSON*)eps->data;
268:   dvdDashboard   *dvd = &data->ddb;

272:   /* Call step destructors and destroys the list */
273:   EPSDavidsonFLCall(dvd->destroyList,dvd);
274:   EPSDavidsonFLDestroy(&dvd->destroyList);
275:   EPSDavidsonFLDestroy(&dvd->startList);
276:   EPSDavidsonFLDestroy(&dvd->endList);
277:   return(0);
278: }

282: PetscErrorCode EPSXDSetKrylovStart_XD(EPS eps,PetscBool krylovstart)
283: {
284:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

287:   data->krylovstart = krylovstart;
288:   return(0);
289: }

293: PetscErrorCode EPSXDGetKrylovStart_XD(EPS eps,PetscBool *krylovstart)
294: {
295:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

298:   *krylovstart = data->krylovstart;
299:   return(0);
300: }

304: PetscErrorCode EPSXDSetBlockSize_XD(EPS eps,PetscInt blocksize)
305: {
306:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

309:   if (blocksize == PETSC_DEFAULT || blocksize == PETSC_DECIDE) blocksize = 1;
310:   if (blocksize <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid blocksize value");
311:   data->blocksize = blocksize;
312:   return(0);
313: }

317: PetscErrorCode EPSXDGetBlockSize_XD(EPS eps,PetscInt *blocksize)
318: {
319:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

322:   *blocksize = data->blocksize;
323:   return(0);
324: }

328: PetscErrorCode EPSXDSetRestart_XD(EPS eps,PetscInt minv,PetscInt plusk)
329: {
330:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

333:   if (minv == PETSC_DEFAULT || minv == PETSC_DECIDE) minv = 5;
334:   if (minv <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid minv value");
335:   if (plusk == PETSC_DEFAULT || plusk == PETSC_DECIDE) plusk = 5;
336:   if (plusk < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid plusk value");
337:   data->minv = minv;
338:   data->plusk = plusk;
339:   return(0);
340: }

344: PetscErrorCode EPSXDGetRestart_XD(EPS eps,PetscInt *minv,PetscInt *plusk)
345: {
346:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

349:   if (minv) *minv = data->minv;
350:   if (plusk) *plusk = data->plusk;
351:   return(0);
352: }

356: PetscErrorCode EPSXDGetInitialSize_XD(EPS eps,PetscInt *initialsize)
357: {
358:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

361:   *initialsize = data->initialsize;
362:   return(0);
363: }

367: PetscErrorCode EPSXDSetInitialSize_XD(EPS eps,PetscInt initialsize)
368: {
369:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

372:   if (initialsize == PETSC_DEFAULT || initialsize == PETSC_DECIDE) initialsize = 5;
373:   if (initialsize <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial size value");
374:   data->initialsize = initialsize;
375:   return(0);
376: }

380: PetscErrorCode EPSXDGetFix_XD(EPS eps,PetscReal *fix)
381: {
382:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

385:   *fix = data->fix;
386:   return(0);
387: }

391: PetscErrorCode EPSJDSetFix_JD(EPS eps,PetscReal fix)
392: {
393:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

396:   if (fix == PETSC_DEFAULT || fix == PETSC_DECIDE) fix = 0.01;
397:   if (fix < 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid fix value");
398:   data->fix = fix;
399:   return(0);
400: }

404: PetscErrorCode EPSXDSetBOrth_XD(EPS eps,PetscBool borth)
405: {
406:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

409:   data->ipB = borth;
410:   return(0);
411: }

415: PetscErrorCode EPSXDGetBOrth_XD(EPS eps,PetscBool *borth)
416: {
417:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

420:   *borth = data->ipB;
421:   return(0);
422: }

426: PetscErrorCode EPSJDSetConstCorrectionTol_JD(EPS eps,PetscBool constant)
427: {
428:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

431:   data->dynamic = PetscNot(constant);
432:   return(0);
433: }

437: PetscErrorCode EPSJDGetConstCorrectionTol_JD(EPS eps,PetscBool *constant)
438: {
439:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

442:   *constant = PetscNot(data->dynamic);
443:   return(0);
444: }

448: PetscErrorCode EPSXDSetWindowSizes_XD(EPS eps,PetscInt pwindow,PetscInt qwindow)
449: {
450:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

453:   if (pwindow == PETSC_DEFAULT || pwindow == PETSC_DECIDE) pwindow = 0;
454:   if (pwindow < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid pwindow value");
455:   if (qwindow == PETSC_DEFAULT || qwindow == PETSC_DECIDE) qwindow = 0;
456:   if (qwindow < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid qwindow value");
457:   data->cX_in_proj = qwindow;
458:   data->cX_in_impr = pwindow;
459:   return(0);
460: }

464: PetscErrorCode EPSXDGetWindowSizes_XD(EPS eps,PetscInt *pwindow,PetscInt *qwindow)
465: {
466:   EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data;

469:   if (pwindow) *pwindow = data->cX_in_impr;
470:   if (qwindow) *qwindow = data->cX_in_proj;
471:   return(0);
472: }

476: /*
477:   EPSComputeVectors_XD - Compute eigenvectors from the vectors
478:   provided by the eigensolver. This version is intended for solvers
479:   that provide Schur vectors from the QZ decomposition. Given the partial
480:   Schur decomposition OP*V=V*T, the following steps are performed:
481:       1) compute eigenvectors of (S,T): S*Z=T*Z*D
482:       2) compute eigenvectors of OP: X=V*Z
483:  */
484: PetscErrorCode EPSComputeVectors_XD(EPS eps)
485: {
487:   Mat            X;
488:   PetscBool      symm;

491:   PetscObjectTypeCompare((PetscObject)eps->ds,DSHEP,&symm);
492:   if (symm) return(0);
493:   DSVectors(eps->ds,DS_MAT_X,NULL,NULL);

495:   /* V <- V * X */
496:   DSGetMat(eps->ds,DS_MAT_X,&X);
497:   BVSetActiveColumns(eps->V,0,eps->nconv);
498:   BVMultInPlace(eps->V,X,0,eps->nconv);
499:   DSRestoreMat(eps->ds,DS_MAT_X,&X);
500:   return(0);
501: }
slepc-3.7.4/src/eps/impls/davidson/dvdcalcpairs.c0000644000175000017500000006057413107004621021313 0ustar jromanjroman/* SLEPc eigensolver: "davidson" Step: calc the best eigenpairs in the subspace V. For that, performs these steps: 1) Update W <- A * V 2) Update H <- V' * W 3) Obtain eigenpairs of H 4) Select some eigenpairs 5) Compute the Ritz pairs of the selected ones - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" #include #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_qz_start" static PetscErrorCode dvd_calcpairs_qz_start(dvdDashboard *d) { PetscErrorCode ierr; PetscFunctionBegin; ierr = BVSetActiveColumns(d->eps->V,0,0);CHKERRQ(ierr); if (d->W) { ierr = BVSetActiveColumns(d->W,0,0);CHKERRQ(ierr); } ierr = BVSetActiveColumns(d->AX,0,0);CHKERRQ(ierr); if (d->BX) { ierr = BVSetActiveColumns(d->BX,0,0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_qz_d" static PetscErrorCode dvd_calcpairs_qz_d(dvdDashboard *d) { PetscErrorCode ierr; PetscFunctionBegin; ierr = BVDestroy(&d->W);CHKERRQ(ierr); ierr = BVDestroy(&d->AX);CHKERRQ(ierr); ierr = BVDestroy(&d->BX);CHKERRQ(ierr); ierr = BVDestroy(&d->auxBV);CHKERRQ(ierr); ierr = MatDestroy(&d->H);CHKERRQ(ierr); if (d->G) { ierr = MatDestroy(&d->G);CHKERRQ(ierr); } ierr = MatDestroy(&d->auxM);CHKERRQ(ierr); ierr = SlepcVecPoolDestroy(&d->auxV);CHKERRQ(ierr); ierr = PetscFree(d->nBds);CHKERRQ(ierr); PetscFunctionReturn(0); } /* in complex, d->size_H real auxiliar values are needed */ #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_projeig_solve" static PetscErrorCode dvd_calcpairs_projeig_solve(dvdDashboard *d) { PetscErrorCode ierr; Vec v; PetscScalar *pA; const PetscScalar *pv; PetscInt i,lV,kV,n,ld; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); n = kV-lV; ierr = DSSetDimensions(d->eps->ds,n,0,0,0);CHKERRQ(ierr); ierr = DSCopyMat(d->eps->ds,DS_MAT_A,0,0,d->H,lV,lV,n,n,PETSC_FALSE);CHKERRQ(ierr); if (d->G) { ierr = DSCopyMat(d->eps->ds,DS_MAT_B,0,0,d->G,lV,lV,n,n,PETSC_FALSE);CHKERRQ(ierr); } /* Set the signature on projected matrix B */ if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) { ierr = DSGetLeadingDimension(d->eps->ds,&ld);CHKERRQ(ierr); ierr = DSGetArray(d->eps->ds,DS_MAT_B,&pA);CHKERRQ(ierr); ierr = PetscMemzero(pA,sizeof(PetscScalar)*n*ld);CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF,kV,&v);CHKERRQ(ierr); ierr = BVGetSignature(d->eps->V,v);CHKERRQ(ierr); ierr = VecGetArrayRead(v,&pv);CHKERRQ(ierr); for (i=0;inBds[i] = PetscRealPart(pv[lV+i]); } ierr = VecRestoreArrayRead(v,&pv);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = DSRestoreArray(d->eps->ds,DS_MAT_B,&pA);CHKERRQ(ierr); } ierr = DSSetState(d->eps->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSSolve(d->eps->ds,d->eigr,d->eigi);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDUpdateProj" /* A(lA:kA-1,lA:kA-1) <- Z(l:k-1)'*A(l:k-1,l:k-1)*Q(l,k-1), where k=l+kA-lA */ static PetscErrorCode EPSXDUpdateProj(Mat Q,Mat Z,PetscInt l,Mat A,PetscInt lA,PetscInt kA,Mat aux) { PetscErrorCode ierr; PetscScalar one=1.0,zero=0.0; PetscInt i,j,dA_=kA-lA,m0,n0,ldA_,ldQ_,ldZ_,nQ_; PetscBLASInt dA,nQ,ldA,ldQ,ldZ; PetscScalar *pA,*pQ,*pZ,*pW; PetscBool symm=PETSC_FALSE,set,flg; PetscFunctionBegin; ierr = MatGetSize(A,&m0,&n0);CHKERRQ(ierr); ldA_=m0; if (m0!=n0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"A should be square"); if (lA<0 || lA>m0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid initial row, column in A"); if (kA<0 || kAm0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid final row, column in A"); ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); symm = set? flg: PETSC_FALSE; ierr = MatGetSize(Q,&m0,&n0);CHKERRQ(ierr); ldQ_=nQ_=m0; if (l<0 || l>n0 || l+dA_>n0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid initial column in Q"); ierr = MatGetSize(Z,&m0,&n0);CHKERRQ(ierr); ldZ_=m0; if (l<0 || l>n0 || l+dA_>n0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Invalid initial column in Z"); ierr = MatGetSize(aux,&m0,&n0);CHKERRQ(ierr); if (m0*n0eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); if (d->W) { ierr = DSGetMat(d->eps->ds,DS_MAT_Z,&Z);CHKERRQ(ierr); } else Z = Q; ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); ierr = EPSXDUpdateProj(Q,Z,0,d->H,lV,lV+d->V_tra_e,d->auxM);CHKERRQ(ierr); if (d->G) { ierr = EPSXDUpdateProj(Q,Z,0,d->G,lV,lV+d->V_tra_e,d->auxM);CHKERRQ(ierr); } ierr = DSRestoreMat(d->eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); if (d->W) { ierr = DSRestoreMat(d->eps->ds,DS_MAT_Z,&Z);CHKERRQ(ierr); } ierr = PetscObjectTypeCompareAny((PetscObject)d->eps->ds,&symm,DSHEP,DSGHIEP,"");CHKERRQ(ierr); if (d->V_tra_s==0 || symm) PetscFunctionReturn(0); /* Compute upper part of H (and G): H(0:l-1,l:k-1) <- W(0:l-1)' * AV(l:k-1), where k=l+d->V_tra_s */ ierr = BVSetActiveColumns(d->W?d->W:d->eps->V,0,lV);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,lV,lV+d->V_tra_s);CHKERRQ(ierr); ierr = BVDot(d->AX,d->W?d->W:d->eps->V,d->H);CHKERRQ(ierr); if (d->G) { ierr = BVSetActiveColumns(d->BX?d->BX:d->eps->V,lV,lV+d->V_tra_s);CHKERRQ(ierr); ierr = BVDot(d->BX?d->BX:d->eps->V,d->W?d->W:d->eps->V,d->G);CHKERRQ(ierr); } ierr = PetscObjectTypeCompareAny((PetscObject)d->eps->ds,&symm,DSGHEP,"");CHKERRQ(ierr); if (!symm) { ierr = BVSetActiveColumns(d->W?d->W:d->eps->V,lV,lV+d->V_tra_s);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,0,lV);CHKERRQ(ierr); ierr = BVDot(d->AX,d->W?d->W:d->eps->V,d->H);CHKERRQ(ierr); if (d->G) { ierr = BVSetActiveColumns(d->BX?d->BX:d->eps->V,0,lV);CHKERRQ(ierr); ierr = BVDot(d->BX?d->BX:d->eps->V,d->W?d->W:d->eps->V,d->G);CHKERRQ(ierr); } } ierr = BVSetActiveColumns(d->eps->V,lV,kV);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,lV,kV);CHKERRQ(ierr); if (d->BX) { ierr = BVSetActiveColumns(d->BX,lV,kV);CHKERRQ(ierr); } if (d->W) { ierr = BVSetActiveColumns(d->W,lV,kV);CHKERRQ(ierr); } if (d->W) { ierr = dvd_harm_updateproj(d);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_updateBV0_gen" /* BV <- BV*MT */ PETSC_STATIC_INLINE PetscErrorCode dvd_calcpairs_updateBV0_gen(dvdDashboard *d,BV bv,DSMatType mat) { PetscErrorCode ierr; PetscInt l,k,n; Mat auxM; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&auxM);CHKERRQ(ierr); ierr = MatZeroEntries(auxM);CHKERRQ(ierr); ierr = DSGetDimensions(d->eps->ds,&n,NULL,NULL,NULL,NULL);CHKERRQ(ierr); if (k-l!=n) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken"); ierr = DSCopyMat(d->eps->ds,mat,0,0,auxM,l,l,n,d->V_tra_e,PETSC_TRUE);CHKERRQ(ierr); ierr = BVMultInPlace(bv,auxM,l,l+d->V_tra_e);CHKERRQ(ierr); ierr = MatDestroy(&auxM);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_proj" static PetscErrorCode dvd_calcpairs_proj(dvdDashboard *d) { PetscErrorCode ierr; PetscInt i,l,k; Vec v1,v2; PetscScalar *pv; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); /* Update AV, BV, W and the projected matrices */ /* 1. S <- S*MT */ if (d->V_tra_s != d->V_tra_e || d->V_tra_e > 0) { ierr = dvd_calcpairs_updateBV0_gen(d,d->eps->V,DS_MAT_Q);CHKERRQ(ierr); if (d->W) { ierr = dvd_calcpairs_updateBV0_gen(d,d->W,DS_MAT_Z);CHKERRQ(ierr); } ierr = dvd_calcpairs_updateBV0_gen(d,d->AX,DS_MAT_Q);CHKERRQ(ierr); if (d->BX) { ierr = dvd_calcpairs_updateBV0_gen(d,d->BX,DS_MAT_Q);CHKERRQ(ierr); } ierr = dvd_calcpairs_updateproj(d);CHKERRQ(ierr); /* Update signature */ if (d->nBds) { ierr = VecCreateSeq(PETSC_COMM_SELF,l+d->V_tra_e,&v1);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->eps->V,0,l+d->V_tra_e);CHKERRQ(ierr); ierr = BVGetSignature(d->eps->V,v1);CHKERRQ(ierr); ierr = VecGetArray(v1,&pv);CHKERRQ(ierr); for (i=0;iV_tra_e;i++) pv[l+i] = d->nBds[i]; ierr = VecRestoreArray(v1,&pv);CHKERRQ(ierr); ierr = BVSetSignature(d->eps->V,v1);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->eps->V,l,k);CHKERRQ(ierr); ierr = VecDestroy(&v1);CHKERRQ(ierr); } k = l+d->V_tra_e; l+= d->V_tra_s; } else { /* 2. V <- orth(V, V_new) */ ierr = dvd_orthV(d->eps->V,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); /* 3. AV <- [AV A * V(V_new_s:V_new_e-1)] */ /* Check consistency */ if (k-l != d->V_new_s) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken"); for (i=l+d->V_new_s;iV_new_e;i++) { ierr = BVGetColumn(d->eps->V,i,&v1);CHKERRQ(ierr); ierr = BVGetColumn(d->AX,i,&v2);CHKERRQ(ierr); ierr = MatMult(d->A,v1,v2);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,i,&v1);CHKERRQ(ierr); ierr = BVRestoreColumn(d->AX,i,&v2);CHKERRQ(ierr); } /* 4. BV <- [BV B * V(V_new_s:V_new_e-1)] */ if (d->BX) { /* Check consistency */ if (k-l != d->V_new_s) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken"); for (i=l+d->V_new_s;iV_new_e;i++) { ierr = BVGetColumn(d->eps->V,i,&v1);CHKERRQ(ierr); ierr = BVGetColumn(d->BX,i,&v2);CHKERRQ(ierr); ierr = MatMult(d->B,v1,v2);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,i,&v1);CHKERRQ(ierr); ierr = BVRestoreColumn(d->BX,i,&v2);CHKERRQ(ierr); } } /* 5. W <- [W f(AV,BV)] */ if (d->W) { ierr = d->calcpairs_W(d);CHKERRQ(ierr); ierr = dvd_orthV(d->W,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); } /* 6. H <- W' * AX; G <- W' * BX */ ierr = BVSetActiveColumns(d->eps->V,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); if (d->BX) { ierr = BVSetActiveColumns(d->BX,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); } if (d->W) { ierr = BVSetActiveColumns(d->W,l+d->V_new_s,l+d->V_new_e);CHKERRQ(ierr); } ierr = BVMatProject(d->AX,NULL,d->W?d->W:d->eps->V,d->H);CHKERRQ(ierr); if (d->G) { ierr = BVMatProject(d->BX?d->BX:d->eps->V,NULL,d->W?d->W:d->eps->V,d->G);CHKERRQ(ierr); } ierr = BVSetActiveColumns(d->eps->V,l,k);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,l,k);CHKERRQ(ierr); if (d->BX) { ierr = BVSetActiveColumns(d->BX,l,k);CHKERRQ(ierr); } if (d->W) { ierr = BVSetActiveColumns(d->W,l,k);CHKERRQ(ierr); } /* Perform the transformation on the projected problem */ if (d->W) { ierr = d->calcpairs_proj_trans(d);CHKERRQ(ierr); } k = l+d->V_new_e; } ierr = BVSetActiveColumns(d->eps->V,l,k);CHKERRQ(ierr); ierr = BVSetActiveColumns(d->AX,l,k);CHKERRQ(ierr); if (d->BX) { ierr = BVSetActiveColumns(d->BX,l,k);CHKERRQ(ierr); } if (d->W) { ierr = BVSetActiveColumns(d->W,l,k);CHKERRQ(ierr); } /* Solve the projected problem */ ierr = dvd_calcpairs_projeig_solve(d);CHKERRQ(ierr); d->V_tra_s = d->V_tra_e = 0; d->V_new_s = d->V_new_e; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_apply_arbitrary" static PetscErrorCode dvd_calcpairs_apply_arbitrary(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscScalar *rr,PetscScalar *ri) { PetscInt i,k,ld; PetscScalar *pX; Vec *X,xr,xi; PetscErrorCode ierr; #if defined(PETSC_USE_COMPLEX) PetscInt N=1; #else PetscInt N=2,j; #endif PetscFunctionBegin; /* Quick exit without neither arbitrary selection nor harmonic extraction */ if (!d->eps->arbitrary && !d->calcpairs_eig_backtrans) PetscFunctionReturn(0); /* Quick exit without arbitrary selection, but with harmonic extraction */ if (d->calcpairs_eig_backtrans) { for (i=r_s; icalcpairs_eig_backtrans(d,d->eigr[i],d->eigi[i],&rr[i-r_s],&ri[i-r_s]);CHKERRQ(ierr); } } if (!d->eps->arbitrary) PetscFunctionReturn(0); ierr = SlepcVecPoolGetVecs(d->auxV,N,&X);CHKERRQ(ierr); ierr = DSGetLeadingDimension(d->eps->ds,&ld);CHKERRQ(ierr); for (i=r_s;ieps->ds,DS_MAT_X,&k,NULL);CHKERRQ(ierr); ierr = DSGetArray(d->eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = dvd_improvex_compute_X(d,i,k+1,X,pX,ld);CHKERRQ(ierr); ierr = DSRestoreArray(d->eps->ds,DS_MAT_X,&pX);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) if (d->nX[i] != 1.0) { for (j=i;jnX[i]);CHKERRQ(ierr); } } xr = X[0]; xi = X[1]; if (i == k) { ierr = VecSet(xi,0.0);CHKERRQ(ierr); } #else xr = X[0]; xi = NULL; if (d->nX[i] != 1.0) { ierr = VecScale(xr,1.0/d->nX[i]);CHKERRQ(ierr); } #endif ierr = (d->eps->arbitrary)(rr[i-r_s],ri[i-r_s],xr,xi,&rr[i-r_s],&ri[i-r_s],d->eps->arbitraryctx);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) if (i != k) { rr[i+1-r_s] = rr[i-r_s]; ri[i+1-r_s] = ri[i-r_s]; i++; } #endif } ierr = SlepcVecPoolRestoreVecs(d->auxV,N,&X);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_selectPairs" static PetscErrorCode dvd_calcpairs_selectPairs(dvdDashboard *d,PetscInt n) { PetscInt k,lV,kV,nV; PetscScalar *rr,*ri; PetscErrorCode ierr; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&lV,&kV);CHKERRQ(ierr); nV = kV - lV; n = PetscMin(n,nV); if (n <= 0) PetscFunctionReturn(0); /* Put the best n pairs at the beginning. Useful for restarting */ if (d->eps->arbitrary || d->calcpairs_eig_backtrans) { ierr = PetscMalloc1(nV,&rr);CHKERRQ(ierr); ierr = PetscMalloc1(nV,&ri);CHKERRQ(ierr); ierr = dvd_calcpairs_apply_arbitrary(d,0,nV,rr,ri);CHKERRQ(ierr); } else { rr = d->eigr; ri = d->eigi; } k = n; ierr = DSSort(d->eps->ds,d->eigr,d->eigi,rr,ri,&k);CHKERRQ(ierr); /* Put the best pair at the beginning. Useful to check its residual */ #if !defined(PETSC_USE_COMPLEX) if (n != 1 && (n != 2 || d->eigi[0] == 0.0)) #else if (n != 1) #endif { ierr = dvd_calcpairs_apply_arbitrary(d,0,nV,rr,ri);CHKERRQ(ierr); k = 1; ierr = DSSort(d->eps->ds,d->eigr,d->eigi,rr,ri,&k);CHKERRQ(ierr); } if (d->calcpairs_eigs_trans) { ierr = d->calcpairs_eigs_trans(d);CHKERRQ(ierr); } if (d->eps->arbitrary || d->calcpairs_eig_backtrans) { ierr = PetscFree(rr);CHKERRQ(ierr); ierr = PetscFree(ri);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDComputeDSConv" static PetscErrorCode EPSXDComputeDSConv(dvdDashboard *d) { PetscErrorCode ierr; PetscInt i,ld; Vec v; PetscScalar *pA; const PetscScalar *pv; PetscBool symm; PetscFunctionBegin; ierr = BVSetActiveColumns(d->eps->V,0,d->eps->nconv);CHKERRQ(ierr); ierr = PetscObjectTypeCompareAny((PetscObject)d->eps->ds,&symm,DSHEP,"");CHKERRQ(ierr); if (symm) PetscFunctionReturn(0); ierr = DSSetDimensions(d->eps->ds,d->eps->nconv,0,0,0);CHKERRQ(ierr); ierr = DSCopyMat(d->eps->ds,DS_MAT_A,0,0,d->H,0,0,d->eps->nconv,d->eps->nconv,PETSC_FALSE);CHKERRQ(ierr); if (d->G) { ierr = DSCopyMat(d->eps->ds,DS_MAT_B,0,0,d->G,0,0,d->eps->nconv,d->eps->nconv,PETSC_FALSE);CHKERRQ(ierr); } /* Set the signature on projected matrix B */ if (DVD_IS(d->sEP,DVD_EP_INDEFINITE)) { ierr = DSGetLeadingDimension(d->eps->ds,&ld);CHKERRQ(ierr); ierr = DSGetArray(d->eps->ds,DS_MAT_B,&pA);CHKERRQ(ierr); ierr = PetscMemzero(pA,sizeof(PetscScalar)*d->eps->nconv*ld);CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF,d->eps->nconv,&v);CHKERRQ(ierr); ierr = BVGetSignature(d->eps->V,v);CHKERRQ(ierr); ierr = VecGetArrayRead(v,&pv);CHKERRQ(ierr); for (i=0;ieps->nconv;i++) pA[i+ld*i] = pv[i]; ierr = VecRestoreArrayRead(v,&pv);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = DSRestoreArray(d->eps->ds,DS_MAT_B,&pA);CHKERRQ(ierr); } ierr = DSSetState(d->eps->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSSolve(d->eps->ds,d->eps->eigr,d->eps->eigi);CHKERRQ(ierr); if (d->W) { for (i=0; ieps->nconv; i++) { ierr = d->calcpairs_eig_backtrans(d,d->eps->eigr[i],d->eps->eigi[i],&d->eps->eigr[i],&d->eps->eigi[i]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_res_0" /* Compute the residual vectors R(i) <- (AV - BV*eigr(i))*pX(i), and also the norm associated to the Schur pair, where i = r_s..r_e */ static PetscErrorCode dvd_calcpairs_res_0(dvdDashboard *d,PetscInt r_s,PetscInt r_e) { PetscInt i,ldpX; PetscScalar *pX; PetscErrorCode ierr; BV BX = d->BX?d->BX:d->eps->V; Vec *R; PetscFunctionBegin; ierr = DSGetLeadingDimension(d->eps->ds,&ldpX);CHKERRQ(ierr); ierr = DSGetArray(d->eps->ds,DS_MAT_Q,&pX);CHKERRQ(ierr); /* nX(i) <- ||X(i)|| */ ierr = dvd_improvex_compute_X(d,r_s,r_e,NULL,pX,ldpX);CHKERRQ(ierr); ierr = SlepcVecPoolGetVecs(d->auxV,r_e-r_s,&R);CHKERRQ(ierr); for (i=r_s;iAX,1.0,0.0,R[i-r_s],&pX[ldpX*i]);CHKERRQ(ierr); /* R(i-r_s) <- R(i-r_s) - eigr(i)*BX*pX(i) */ ierr = BVMultVec(BX,-d->eigr[i],1.0,R[i-r_s],&pX[ldpX*i]);CHKERRQ(ierr); } ierr = DSRestoreArray(d->eps->ds,DS_MAT_Q,&pX);CHKERRQ(ierr); ierr = d->calcpairs_proj_res(d,r_s,r_e,R);CHKERRQ(ierr); ierr = SlepcVecPoolRestoreVecs(d->auxV,r_e-r_s,&R);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_proj_res" static PetscErrorCode dvd_calcpairs_proj_res(dvdDashboard *d,PetscInt r_s,PetscInt r_e,Vec *R) { PetscInt i,l,k; PetscErrorCode ierr; PetscBool lindep=PETSC_FALSE; BV cX; PetscFunctionBegin; if (d->W) cX = d->W; /* If left subspace exists, R <- orth(cY, R), nR[i] <- ||R[i]|| */ else if (!(DVD_IS(d->sEP, DVD_EP_STD) && DVD_IS(d->sEP, DVD_EP_HERMITIAN))) cX = d->eps->V; /* If not HEP, R <- orth(cX, R), nR[i] <- ||R[i]|| */ else cX = NULL; /* Otherwise, nR[i] <- ||R[i]|| */ if (cX) { ierr = BVGetActiveColumns(cX,&l,&k);CHKERRQ(ierr); ierr = BVSetActiveColumns(cX,0,l);CHKERRQ(ierr); for (i=0;inR[r_s+i],&lindep);CHKERRQ(ierr); } ierr = BVSetActiveColumns(cX,l,k);CHKERRQ(ierr); if (lindep || (PetscAbs(d->nR[r_s+i]) < PETSC_MACHINE_EPSILON)) { ierr = PetscInfo2(d->eps,"The computed eigenvector residual %D is too low, %g!\n",r_s+i,(double)(d->nR[r_s+i]));CHKERRQ(ierr); } } else { for (i=0;inR[r_s+i]);CHKERRQ(ierr); } for (i=0;inR[r_s+i]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_calcpairs_qz" PetscErrorCode dvd_calcpairs_qz(dvdDashboard *d,dvdBlackboard *b,PetscBool borth,PetscInt cX_proj,PetscBool harm) { PetscErrorCode ierr; PetscBool std_probl,her_probl,ind_probl,her_ind_probl; DSType dstype; Vec v1; PetscFunctionBegin; std_probl = DVD_IS(d->sEP,DVD_EP_STD)? PETSC_TRUE: PETSC_FALSE; her_probl = DVD_IS(d->sEP,DVD_EP_HERMITIAN)? PETSC_TRUE: PETSC_FALSE; ind_probl = DVD_IS(d->sEP,DVD_EP_INDEFINITE)? PETSC_TRUE: PETSC_FALSE; her_ind_probl = (her_probl||ind_probl)? PETSC_TRUE: PETSC_FALSE; /* Setting configuration constrains */ b->max_size_proj = PetscMax(b->max_size_proj,b->max_size_V+cX_proj); d->W_shift = d->B? PETSC_TRUE: PETSC_FALSE; if (d->B && her_ind_probl && !borth) d->BV_shift = PETSC_TRUE; else d->BV_shift = PETSC_FALSE; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { d->max_cX_in_proj = cX_proj; d->max_size_P = b->max_size_P; d->max_size_proj = b->max_size_proj; /* Create a DS if the method works with Schur decompositions */ d->calcPairs = dvd_calcpairs_proj; d->calcpairs_residual = dvd_calcpairs_res_0; d->calcpairs_proj_res = dvd_calcpairs_proj_res; d->calcpairs_selectPairs = dvd_calcpairs_selectPairs; /* Create and configure a DS for solving the projected problems */ if (d->W) dstype = DSGNHEP; /* If we use harmonics */ else { if (ind_probl) dstype = DSGHIEP; else if (std_probl) dstype = her_probl? DSHEP : DSNHEP; else dstype = her_probl? DSGHEP : DSGNHEP; } ierr = DSSetType(d->eps->ds,dstype);CHKERRQ(ierr); ierr = DSAllocate(d->eps->ds,d->eps->ncv);CHKERRQ(ierr); /* Create various vector basis */ if (harm) { ierr = BVDuplicateResize(d->eps->V,d->eps->ncv,&d->W);CHKERRQ(ierr); ierr = BVSetMatrix(d->W,NULL,PETSC_FALSE);CHKERRQ(ierr); } else d->W = NULL; ierr = BVDuplicateResize(d->eps->V,d->eps->ncv,&d->AX);CHKERRQ(ierr); ierr = BVSetMatrix(d->AX,NULL,PETSC_FALSE);CHKERRQ(ierr); ierr = BVDuplicateResize(d->eps->V,d->eps->ncv,&d->auxBV);CHKERRQ(ierr); ierr = BVSetMatrix(d->auxBV,NULL,PETSC_FALSE);CHKERRQ(ierr); if (d->B) { ierr = BVDuplicateResize(d->eps->V,d->eps->ncv,&d->BX);CHKERRQ(ierr); ierr = BVSetMatrix(d->BX,NULL,PETSC_FALSE);CHKERRQ(ierr); } else d->BX = NULL; ierr = MatCreateVecs(d->A,&v1,NULL);CHKERRQ(ierr); ierr = SlepcVecPoolCreate(v1,0,&d->auxV);CHKERRQ(ierr); ierr = VecDestroy(&v1);CHKERRQ(ierr); /* Create projected problem matrices */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&d->H);CHKERRQ(ierr); if (!std_probl) { ierr = MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&d->G);CHKERRQ(ierr); } else d->G = NULL; if (her_probl) { ierr = MatSetOption(d->H,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); if (d->G) { ierr = MatSetOption(d->G,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); } } if (ind_probl) { ierr = PetscMalloc1(d->eps->ncv,&d->nBds);CHKERRQ(ierr); } else d->nBds = NULL; ierr = MatCreateSeqDense(PETSC_COMM_SELF,d->eps->ncv,d->eps->ncv,NULL,&d->auxM);CHKERRQ(ierr); ierr = EPSDavidsonFLAdd(&d->startList,dvd_calcpairs_qz_start);CHKERRQ(ierr); ierr = EPSDavidsonFLAdd(&d->endList,EPSXDComputeDSConv);CHKERRQ(ierr); ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_calcpairs_qz_d);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/davidson.c0000644000175000017500000004441713107004621020461 0ustar jromanjroman/* Skeleton of Davidson solver. Actual solvers are GD and JD. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" static PetscBool cited = PETSC_FALSE; static const char citation[] = "@Article{slepc-davidson,\n" " author = \"E. Romero and J. E. Roman\",\n" " title = \"A parallel implementation of {Davidson} methods for large-scale eigenvalue problems in {SLEPc}\",\n" " journal = \"{ACM} Trans. Math. Software\",\n" " volume = \"40\",\n" " number = \"2\",\n" " pages = \"13:1--13:29\",\n" " year = \"2014,\"\n" " doi = \"http://dx.doi.org/10.1145/2543696\"\n" "}\n"; #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_XD" PetscErrorCode EPSSetUp_XD(EPS eps) { PetscErrorCode ierr; EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; dvdDashboard *dvd = &data->ddb; dvdBlackboard b; PetscInt min_size_V,plusk,bs,initv,i,cX_in_proj,cX_in_impr,nmat; Mat A,B; KSP ksp; PetscBool t,ipB,ispositive,dynamic; HarmType_t harm; InitType_t init; PetscReal fix; PetscScalar target; PetscFunctionBegin; /* Setup EPS options and get the problem specification */ ierr = EPSXDGetBlockSize_XD(eps,&bs);CHKERRQ(ierr); if (bs <= 0) bs = 1; if (eps->ncv) { if (eps->ncvnev) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The value of ncv must be at least nev"); } else if (eps->mpd) eps->ncv = eps->mpd + eps->nev + bs; else if (eps->nev<500) eps->ncv = PetscMin(eps->n-bs,PetscMax(2*eps->nev,eps->nev+15))+bs; else eps->ncv = PetscMin(eps->n-bs,eps->nev+500)+bs; if (!eps->mpd) eps->mpd = eps->ncv; if (eps->mpd > eps->ncv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The mpd has to be less or equal than ncv"); if (eps->mpd < 2) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The mpd has to be greater than 2"); if (!eps->max_it) eps->max_it = PetscMax(100*eps->ncv,2*eps->n); if (!eps->which) eps->which = EPS_LARGEST_MAGNITUDE; if (eps->ishermitian && (eps->which==EPS_LARGEST_IMAGINARY || eps->which==EPS_SMALLEST_IMAGINARY)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Wrong value of eps->which"); if (!(eps->nev + bs <= eps->ncv)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The ncv has to be greater than nev plus blocksize"); if (eps->trueres) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"-eps_true_residual is temporally disable in this solver."); ierr = EPSXDGetRestart_XD(eps,&min_size_V,&plusk);CHKERRQ(ierr); if (!min_size_V) min_size_V = PetscMin(PetscMax(bs,5),eps->mpd/2); if (!(min_size_V+bs <= eps->mpd)) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The value of minv must be less than mpd minus blocksize"); ierr = EPSXDGetInitialSize_XD(eps,&initv);CHKERRQ(ierr); if (eps->mpd < initv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The initv has to be less or equal than mpd"); /* Set STPrecond as the default ST */ if (!((PetscObject)eps->st)->type_name) { ierr = STSetType(eps->st,STPRECOND);CHKERRQ(ierr); } ierr = STPrecondSetKSPHasMat(eps->st,PETSC_FALSE);CHKERRQ(ierr); /* Change the default sigma to inf if necessary */ if (eps->which == EPS_LARGEST_MAGNITUDE || eps->which == EPS_LARGEST_REAL || eps->which == EPS_LARGEST_IMAGINARY) { ierr = STSetDefaultShift(eps->st,PETSC_MAX_REAL);CHKERRQ(ierr); } /* Davidson solvers only support STPRECOND */ ierr = STSetUp(eps->st);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->st,STPRECOND,&t);CHKERRQ(ierr); if (!t) SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"%s only works with precond spectral transformation",((PetscObject)eps)->type_name); /* Setup problem specification in dvd */ ierr = STGetNumMatrices(eps->st,&nmat);CHKERRQ(ierr); ierr = STGetOperators(eps->st,0,&A);CHKERRQ(ierr); if (nmat>1) { ierr = STGetOperators(eps->st,1,&B);CHKERRQ(ierr); } ierr = EPSReset_XD(eps);CHKERRQ(ierr); ierr = PetscMemzero(dvd,sizeof(dvdDashboard));CHKERRQ(ierr); dvd->A = A; dvd->B = eps->isgeneralized? B: NULL; ispositive = eps->ispositive; dvd->sA = DVD_MAT_IMPLICIT | (eps->ishermitian? DVD_MAT_HERMITIAN: 0) | ((ispositive && !eps->isgeneralized) ? DVD_MAT_POS_DEF: 0); /* Asume -eps_hermitian means hermitian-definite in generalized problems */ if (!ispositive && !eps->isgeneralized && eps->ishermitian) ispositive = PETSC_TRUE; if (!eps->isgeneralized) dvd->sB = DVD_MAT_IMPLICIT | DVD_MAT_HERMITIAN | DVD_MAT_IDENTITY | DVD_MAT_UNITARY | DVD_MAT_POS_DEF; else dvd->sB = DVD_MAT_IMPLICIT | (eps->ishermitian? DVD_MAT_HERMITIAN: 0) | (ispositive? DVD_MAT_POS_DEF: 0); ipB = (dvd->B && data->ipB && DVD_IS(dvd->sB,DVD_MAT_HERMITIAN))?PETSC_TRUE:PETSC_FALSE; if (data->ipB && !ipB) data->ipB = PETSC_FALSE; dvd->correctXnorm = ipB; dvd->sEP = ((!eps->isgeneralized || (eps->isgeneralized && ipB))? DVD_EP_STD: 0) | (ispositive? DVD_EP_HERMITIAN: 0) | ((eps->problem_type == EPS_GHIEP && ipB) ? DVD_EP_INDEFINITE : 0); dvd->nev = eps->nev; dvd->which = eps->which; dvd->withTarget = PETSC_TRUE; switch (eps->which) { case EPS_TARGET_MAGNITUDE: case EPS_TARGET_IMAGINARY: dvd->target[0] = target = eps->target; dvd->target[1] = 1.0; break; case EPS_TARGET_REAL: dvd->target[0] = PetscRealPart(target = eps->target); dvd->target[1] = 1.0; break; case EPS_LARGEST_REAL: case EPS_LARGEST_MAGNITUDE: case EPS_LARGEST_IMAGINARY: /* TODO: think about this case */ dvd->target[0] = 1.0; dvd->target[1] = target = 0.0; break; case EPS_SMALLEST_MAGNITUDE: case EPS_SMALLEST_REAL: case EPS_SMALLEST_IMAGINARY: /* TODO: think about this case */ dvd->target[0] = target = 0.0; dvd->target[1] = 1.0; break; case EPS_WHICH_USER: ierr = STGetShift(eps->st,&target);CHKERRQ(ierr); dvd->target[0] = target; dvd->target[1] = 1.0; break; case EPS_ALL: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported option: which == EPS_ALL"); break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported value of option 'which'"); } dvd->tol = (eps->tol==PETSC_DEFAULT)? SLEPC_DEFAULT_TOL: eps->tol; dvd->eps = eps; /* Setup the extraction technique */ if (!eps->extraction) { if (ipB || ispositive) eps->extraction = EPS_RITZ; else { switch (eps->which) { case EPS_TARGET_REAL: case EPS_TARGET_MAGNITUDE: case EPS_TARGET_IMAGINARY: case EPS_SMALLEST_MAGNITUDE: case EPS_SMALLEST_REAL: case EPS_SMALLEST_IMAGINARY: eps->extraction = EPS_HARMONIC; break; case EPS_LARGEST_REAL: case EPS_LARGEST_MAGNITUDE: case EPS_LARGEST_IMAGINARY: eps->extraction = EPS_HARMONIC_LARGEST; break; default: eps->extraction = EPS_RITZ; } } } switch (eps->extraction) { case EPS_RITZ: harm = DVD_HARM_NONE; break; case EPS_HARMONIC: harm = DVD_HARM_RR; break; case EPS_HARMONIC_RELATIVE: harm = DVD_HARM_RRR; break; case EPS_HARMONIC_RIGHT: harm = DVD_HARM_REIGS; break; case EPS_HARMONIC_LARGEST: harm = DVD_HARM_LEIGS; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); } /* Setup the type of starting subspace */ ierr = EPSXDGetKrylovStart_XD(eps,&t);CHKERRQ(ierr); init = (!t)? DVD_INITV_CLASSIC : DVD_INITV_KRYLOV; /* Setup the presence of converged vectors in the projected problem and the projector */ ierr = EPSXDGetWindowSizes_XD(eps,&cX_in_impr,&cX_in_proj);CHKERRQ(ierr); if (cX_in_impr>0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The option pwindow is temporally disable in this solver."); if (cX_in_proj>0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"The option qwindow is temporally disable in this solver."); if (min_size_V <= cX_in_proj) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"minv has to be greater than qwindow"); if (bs > 1 && cX_in_impr > 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported option: pwindow > 0 and bs > 1"); /* Get the fix parameter */ ierr = EPSXDGetFix_XD(eps,&fix);CHKERRQ(ierr); /* Get whether the stopping criterion is used */ ierr = EPSJDGetConstCorrectionTol_JD(eps,&dynamic);CHKERRQ(ierr); /* Preconfigure dvd */ ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); ierr = dvd_schm_basic_preconf(dvd,&b,eps->mpd,min_size_V,bs,initv,PetscAbs(eps->nini),plusk,harm,ksp,init,eps->trackall,data->ipB,cX_in_proj,cX_in_impr,data->doubleexp);CHKERRQ(ierr); /* Allocate memory */ ierr = EPSAllocateSolution(eps,0);CHKERRQ(ierr); /* Setup orthogonalization */ ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); if (!(ipB && dvd->B)) { ierr = BVSetMatrix(eps->V,NULL,PETSC_FALSE);CHKERRQ(ierr); } for (i=0;incv;i++) eps->perm[i] = i; /* Configure dvd for a basic GD */ ierr = dvd_schm_basic_conf(dvd,&b,eps->mpd,min_size_V,bs,initv,PetscAbs(eps->nini),plusk,harm,dvd->withTarget,target,ksp,fix,init,eps->trackall,data->ipB,cX_in_proj,cX_in_impr,dynamic,data->doubleexp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_XD" PetscErrorCode EPSSolve_XD(EPS eps) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; dvdDashboard *d = &data->ddb; PetscInt l,k; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscCitationsRegister(citation,&cited);CHKERRQ(ierr); /* Call the starting routines */ ierr = EPSDavidsonFLCall(d->startList,d);CHKERRQ(ierr); while (eps->reason == EPS_CONVERGED_ITERATING) { /* Initialize V, if it is needed */ ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); if (l == k) { ierr = d->initV(d);CHKERRQ(ierr); } /* Find the best approximated eigenpairs in V, X */ ierr = d->calcPairs(d);CHKERRQ(ierr); /* Test for convergence */ ierr = (*eps->stopping)(eps,eps->its,eps->max_it,eps->nconv,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); if (eps->reason != EPS_CONVERGED_ITERATING) break; /* Expand the subspace */ ierr = d->updateV(d);CHKERRQ(ierr); /* Monitor progress */ eps->nconv = d->nconv; eps->its++; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); ierr = EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,k);CHKERRQ(ierr); } /* Call the ending routines */ ierr = EPSDavidsonFLCall(d->endList,d);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_XD" PetscErrorCode EPSReset_XD(EPS eps) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; dvdDashboard *dvd = &data->ddb; PetscErrorCode ierr; PetscFunctionBegin; /* Call step destructors and destroys the list */ ierr = EPSDavidsonFLCall(dvd->destroyList,dvd);CHKERRQ(ierr); ierr = EPSDavidsonFLDestroy(&dvd->destroyList);CHKERRQ(ierr); ierr = EPSDavidsonFLDestroy(&dvd->startList);CHKERRQ(ierr); ierr = EPSDavidsonFLDestroy(&dvd->endList);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDSetKrylovStart_XD" PetscErrorCode EPSXDSetKrylovStart_XD(EPS eps,PetscBool krylovstart) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; data->krylovstart = krylovstart; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDGetKrylovStart_XD" PetscErrorCode EPSXDGetKrylovStart_XD(EPS eps,PetscBool *krylovstart) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; *krylovstart = data->krylovstart; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDSetBlockSize_XD" PetscErrorCode EPSXDSetBlockSize_XD(EPS eps,PetscInt blocksize) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; if (blocksize == PETSC_DEFAULT || blocksize == PETSC_DECIDE) blocksize = 1; if (blocksize <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid blocksize value"); data->blocksize = blocksize; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDGetBlockSize_XD" PetscErrorCode EPSXDGetBlockSize_XD(EPS eps,PetscInt *blocksize) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; *blocksize = data->blocksize; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDSetRestart_XD" PetscErrorCode EPSXDSetRestart_XD(EPS eps,PetscInt minv,PetscInt plusk) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; if (minv == PETSC_DEFAULT || minv == PETSC_DECIDE) minv = 5; if (minv <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid minv value"); if (plusk == PETSC_DEFAULT || plusk == PETSC_DECIDE) plusk = 5; if (plusk < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid plusk value"); data->minv = minv; data->plusk = plusk; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDGetRestart_XD" PetscErrorCode EPSXDGetRestart_XD(EPS eps,PetscInt *minv,PetscInt *plusk) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; if (minv) *minv = data->minv; if (plusk) *plusk = data->plusk; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDGetInitialSize_XD" PetscErrorCode EPSXDGetInitialSize_XD(EPS eps,PetscInt *initialsize) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; *initialsize = data->initialsize; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDSetInitialSize_XD" PetscErrorCode EPSXDSetInitialSize_XD(EPS eps,PetscInt initialsize) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; if (initialsize == PETSC_DEFAULT || initialsize == PETSC_DECIDE) initialsize = 5; if (initialsize <= 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial size value"); data->initialsize = initialsize; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDGetFix_XD" PetscErrorCode EPSXDGetFix_XD(EPS eps,PetscReal *fix) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; *fix = data->fix; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetFix_JD" PetscErrorCode EPSJDSetFix_JD(EPS eps,PetscReal fix) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; if (fix == PETSC_DEFAULT || fix == PETSC_DECIDE) fix = 0.01; if (fix < 0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid fix value"); data->fix = fix; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDSetBOrth_XD" PetscErrorCode EPSXDSetBOrth_XD(EPS eps,PetscBool borth) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; data->ipB = borth; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDGetBOrth_XD" PetscErrorCode EPSXDGetBOrth_XD(EPS eps,PetscBool *borth) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; *borth = data->ipB; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDSetConstCorrectionTol_JD" PetscErrorCode EPSJDSetConstCorrectionTol_JD(EPS eps,PetscBool constant) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; data->dynamic = PetscNot(constant); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSJDGetConstCorrectionTol_JD" PetscErrorCode EPSJDGetConstCorrectionTol_JD(EPS eps,PetscBool *constant) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; *constant = PetscNot(data->dynamic); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDSetWindowSizes_XD" PetscErrorCode EPSXDSetWindowSizes_XD(EPS eps,PetscInt pwindow,PetscInt qwindow) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; if (pwindow == PETSC_DEFAULT || pwindow == PETSC_DECIDE) pwindow = 0; if (pwindow < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid pwindow value"); if (qwindow == PETSC_DEFAULT || qwindow == PETSC_DECIDE) qwindow = 0; if (qwindow < 0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid qwindow value"); data->cX_in_proj = qwindow; data->cX_in_impr = pwindow; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSXDGetWindowSizes_XD" PetscErrorCode EPSXDGetWindowSizes_XD(EPS eps,PetscInt *pwindow,PetscInt *qwindow) { EPS_DAVIDSON *data = (EPS_DAVIDSON*)eps->data; PetscFunctionBegin; if (pwindow) *pwindow = data->cX_in_impr; if (qwindow) *qwindow = data->cX_in_proj; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeVectors_XD" /* EPSComputeVectors_XD - Compute eigenvectors from the vectors provided by the eigensolver. This version is intended for solvers that provide Schur vectors from the QZ decomposition. Given the partial Schur decomposition OP*V=V*T, the following steps are performed: 1) compute eigenvectors of (S,T): S*Z=T*Z*D 2) compute eigenvectors of OP: X=V*Z */ PetscErrorCode EPSComputeVectors_XD(EPS eps) { PetscErrorCode ierr; Mat X; PetscBool symm; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)eps->ds,DSHEP,&symm);CHKERRQ(ierr); if (symm) PetscFunctionReturn(0); ierr = DSVectors(eps->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); /* V <- V * X */ ierr = DSGetMat(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,eps->nconv);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,X,0,eps->nconv);CHKERRQ(ierr); ierr = DSRestoreMat(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/davidson.h0000644000175000017500000003205313107004621020457 0ustar jromanjroman/* Method: General Davidson Method (includes GD and JD) References: - Ernest R. Davidson. Super-matrix methods. Computer Physics Communications, 53:49-60, May 1989. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include struct _dvdDashboard; typedef PetscErrorCode (*dvdCallback)(struct _dvdDashboard*); typedef struct _dvdFunctionList { dvdCallback f; struct _dvdFunctionList *next; } dvdFunctionList; typedef enum { DVD_HARM_NONE, DVD_HARM_RR, DVD_HARM_RRR, DVD_HARM_REIGS, DVD_HARM_LEIGS } HarmType_t; typedef enum { DVD_INITV_CLASSIC, DVD_INITV_KRYLOV } InitType_t; typedef enum { DVD_PROJ_KXX, DVD_PROJ_KZX } ProjType_t; /* Dashboard struct: contains the methods that will be employed and the tuning options. */ typedef struct _dvdDashboard { /**** Function steps ****/ /* Initialize V */ PetscErrorCode (*initV)(struct _dvdDashboard*); void *initV_data; /* Find the approximate eigenpairs from V */ PetscErrorCode (*calcPairs)(struct _dvdDashboard*); void *calcPairs_data; /* Eigenpair test for convergence */ PetscBool (*testConv)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscReal,PetscReal*); void *testConv_data; /* Improve the selected eigenpairs */ PetscErrorCode (*improveX)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt*); void *improveX_data; /* Check for restarting */ PetscErrorCode (*isRestarting)(struct _dvdDashboard*,PetscBool*); void *isRestarting_data; /* Perform restarting */ PetscErrorCode (*restartV)(struct _dvdDashboard*); void *restartV_data; /* Update V */ PetscErrorCode (*updateV)(struct _dvdDashboard*); void *updateV_data; /**** Problem specification ****/ Mat A,B; /* problem matrices */ MatType_t sA,sB; /* matrix specifications */ EPType_t sEP; /* problem specifications */ PetscInt nev; /* number of eigenpairs */ EPSWhich which; /* spectrum selection */ PetscBool withTarget; /* if there is a target */ PetscScalar target[2]; /* target value */ PetscReal tol; /* tolerance */ PetscBool correctXnorm; /* if true, norm of X are computed */ /**** Subspaces specification ****/ PetscInt nconv; /* number of converged eigenpairs */ PetscInt npreconv; /* number of pairs ready to converge */ BV W; /* left basis for harmonic case */ BV AX; /* A*V */ BV BX; /* B*V */ PetscInt size_D; /* active vectors */ PetscInt max_size_proj; /* max size projected problem */ PetscInt max_cX_in_proj; /* max vectors from cX in the projected problem */ PetscInt max_cX_in_impr; /* max vectros from cX in the projector */ PetscInt max_size_P; /* max unconverged vectors in the projector */ PetscInt bs; /* max vectors that expands the subspace every iteration */ EPS eps; /* connection to SLEPc */ /**** Auxiliary space ****/ VecPool auxV; /* auxiliary vectors */ BV auxBV; /* auxiliary vectors */ /**** Eigenvalues and errors ****/ PetscScalar *ceigr,*ceigi; /* converged eigenvalues */ PetscScalar *eigr,*eigi; /* current eigenvalues */ PetscReal *nR; /* residual norm */ PetscReal *real_nR; /* original nR */ PetscReal *nX; /* X norm */ PetscReal *real_nX; /* original nX */ PetscReal *errest; /* relative error eigenpairs */ PetscReal *nBds; /* B-norms of projected problem */ /**** Shared function and variables ****/ PetscErrorCode (*e_Vchanged)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt); void *e_Vchanged_data; PetscErrorCode (*calcpairs_residual)(struct _dvdDashboard*,PetscInt,PetscInt); PetscErrorCode (*calcpairs_selectPairs)(struct _dvdDashboard*,PetscInt); void *calcpairs_residual_data; PetscErrorCode (*improvex_precond)(struct _dvdDashboard*,PetscInt,Vec,Vec); void *improvex_precond_data; PetscErrorCode (*improvex_jd_proj_uv)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*,Vec*,Vec*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt); PetscErrorCode (*improvex_jd_lit)(struct _dvdDashboard*,PetscInt,PetscScalar*,PetscScalar*,PetscInt*,PetscReal*); PetscErrorCode (*calcpairs_W)(struct _dvdDashboard*); void *calcpairs_W_data; PetscErrorCode (*calcpairs_proj_trans)(struct _dvdDashboard*); PetscErrorCode (*calcpairs_eigs_trans)(struct _dvdDashboard*); PetscErrorCode (*calcpairs_eig_backtrans)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscScalar*,PetscScalar*); PetscErrorCode (*calcpairs_proj_res)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*); PetscErrorCode (*preTestConv)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt*); PetscErrorCode (*e_newIteration)(struct _dvdDashboard*); void *e_newIteration_data; dvdFunctionList *startList; /* starting list */ dvdFunctionList *endList; /* ending list */ dvdFunctionList *destroyList;/* destructor list */ Mat H,G; /* projected problem matrices */ Mat auxM; /* auxiliary dense matrix */ PetscInt size_MT; /* rows in MT */ PetscInt V_tra_s; PetscInt V_tra_e; /* cX <- [cX V*MT(0:V_tra_s-1)], V <- V*MT(V_tra_s:V_tra_e) */ PetscInt V_new_s; PetscInt V_new_e; /* added to V the columns V_new_s:V_new_e */ PetscBool BV_shift; /* if true BV is shifted when vectors converge */ PetscBool W_shift; /* if true W is shifted when vectors converge */ } dvdDashboard; typedef struct { /*------------------------- User parameters ---------------------------*/ PetscInt blocksize; /* block size */ PetscInt initialsize; /* initial size of V */ PetscInt minv; /* size of V after restarting */ PetscInt plusk; /* keep plusk eigenvectors from the last iteration */ PetscBool ipB; /* true if B-ortho is used */ PetscReal fix; /* the fix parameter */ PetscBool krylovstart; /* true if the starting subspace is a Krylov basis */ PetscBool dynamic; /* true if dynamic stopping criterion is used */ PetscInt cX_in_proj; /* converged vectors in the projected problem */ PetscInt cX_in_impr; /* converged vectors in the projector */ PetscBool doubleexp; /* double expansion in GD (GD2) */ /*----------------- Child objects and working data -------------------*/ dvdDashboard ddb; } EPS_DAVIDSON; #undef __FUNCT__ #define __FUNCT__ "EPSDavidsonFLAdd" PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLAdd(dvdFunctionList **fl,dvdCallback f) { PetscErrorCode ierr; dvdFunctionList *l; PetscFunctionBegin; ierr = PetscNew(&l);CHKERRQ(ierr); l->f = f; l->next = *fl; *fl = l; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDavidsonFLCall" PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLCall(dvdFunctionList *fl,dvdDashboard *d) { PetscErrorCode ierr; dvdFunctionList *l; PetscFunctionBegin; for (l=fl;l;l=l->next) { ierr = (l->f)(d);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDavidsonFLDestroy" PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLDestroy(dvdFunctionList **fl) { PetscErrorCode ierr; dvdFunctionList *l,*l0; PetscFunctionBegin; for (l=*fl;l;l=l0) { l0 = l->next; ierr = PetscFree(l);CHKERRQ(ierr); } *fl = NULL; PetscFunctionReturn(0); } /* The blackboard configuration structure: saves information about the memory and other requirements. The starting memory structure: V W? AV BV? tKZ |-----------|-----------|-----------|------------|-------| nev+mpd nev+mpd scP+mpd nev?+mpd sP+scP scP+mpd scP+mpd The final memory structure considering W_shift and BV_shift: cX V cY? W? cAV AV BcX? BV? KZ tKZ |---|-------|----|------|---|-------|----|-------|---|---| nev mpd nev mpd scP mpd nev mpd scP sP <- shift scP scP <- !shift */ typedef struct { PetscInt max_size_V; /* max size of the searching subspace (mpd) */ PetscInt max_size_X; /* max size of X (bs) */ PetscInt size_V; /* real size of V (nev+size_P+mpd) */ PetscInt max_size_oldX; /* max size of oldX */ PetscInt max_nev; /* max number of converged pairs */ PetscInt max_size_P; /* number of computed vectors for the projector */ PetscInt max_size_cP; /* number of converged vectors in the projectors */ PetscInt max_size_proj; /* max size projected problem */ PetscInt max_size_cX_proj; /* max converged vectors in the projected problem */ PetscInt state; /* method states: 0: preconfiguring 1: configuring 2: running */ } dvdBlackboard; #define DVD_STATE_PRECONF 0 #define DVD_STATE_CONF 1 #define DVD_STATE_RUN 2 /* Prototypes of non-static auxiliary functions */ PETSC_INTERN PetscErrorCode dvd_calcpairs_qz(dvdDashboard*,dvdBlackboard*,PetscBool,PetscInt,PetscBool); PETSC_INTERN PetscErrorCode dvd_improvex_gd2(dvdDashboard*,dvdBlackboard*,KSP,PetscInt); PETSC_INTERN PetscErrorCode dvd_improvex_jd(dvdDashboard*,dvdBlackboard*,KSP,PetscInt,PetscInt,PetscBool); PETSC_INTERN PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard*,dvdBlackboard*,ProjType_t); PETSC_INTERN PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard*,dvdBlackboard*,PetscInt,PetscReal,PetscReal); PETSC_INTERN PetscErrorCode dvd_improvex_compute_X(dvdDashboard*,PetscInt,PetscInt,Vec*,PetscScalar*,PetscInt); PETSC_INTERN PetscErrorCode dvd_initV(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscBool); PETSC_INTERN PetscErrorCode dvd_orthV(BV,PetscInt,PetscInt); PETSC_INTERN PetscErrorCode dvd_schm_basic_preconf(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,HarmType_t,KSP,InitType_t,PetscBool,PetscBool,PetscInt,PetscInt,PetscBool); PETSC_INTERN PetscErrorCode dvd_schm_basic_conf(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,HarmType_t,PetscBool,PetscScalar,KSP,PetscReal,InitType_t,PetscBool,PetscBool,PetscInt,PetscInt,PetscBool,PetscBool); PETSC_INTERN PetscErrorCode dvd_testconv_basic(dvdDashboard*,dvdBlackboard*); PETSC_INTERN PetscErrorCode dvd_testconv_slepc(dvdDashboard*,dvdBlackboard*); PETSC_INTERN PetscErrorCode dvd_managementV_basic(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool,PetscBool); PETSC_INTERN PetscErrorCode dvd_static_precond_PC(dvdDashboard*,dvdBlackboard*,PC); PETSC_INTERN PetscErrorCode dvd_jacobi_precond(dvdDashboard*,dvdBlackboard*); PETSC_INTERN PetscErrorCode dvd_harm_updateproj(dvdDashboard*); PETSC_INTERN PetscErrorCode dvd_harm_conf(dvdDashboard*,dvdBlackboard*,HarmType_t,PetscBool,PetscScalar); /* Internal interface routines */ PETSC_INTERN PetscErrorCode EPSReset_XD(EPS); PETSC_INTERN PetscErrorCode EPSSetUp_XD(EPS); PETSC_INTERN PetscErrorCode EPSSolve_XD(EPS); PETSC_INTERN PetscErrorCode EPSComputeVectors_XD(EPS); PETSC_INTERN PetscErrorCode EPSXDSetKrylovStart_XD(EPS,PetscBool); PETSC_INTERN PetscErrorCode EPSXDGetKrylovStart_XD(EPS,PetscBool*); PETSC_INTERN PetscErrorCode EPSXDSetBlockSize_XD(EPS,PetscInt); PETSC_INTERN PetscErrorCode EPSXDGetBlockSize_XD(EPS,PetscInt*); PETSC_INTERN PetscErrorCode EPSXDSetRestart_XD(EPS,PetscInt,PetscInt); PETSC_INTERN PetscErrorCode EPSXDGetRestart_XD(EPS,PetscInt*,PetscInt*); PETSC_INTERN PetscErrorCode EPSXDGetInitialSize_XD(EPS,PetscInt*); PETSC_INTERN PetscErrorCode EPSXDSetInitialSize_XD(EPS,PetscInt); PETSC_INTERN PetscErrorCode EPSXDGetFix_XD(EPS,PetscReal*); PETSC_INTERN PetscErrorCode EPSJDSetFix_JD(EPS,PetscReal); PETSC_INTERN PetscErrorCode EPSXDSetBOrth_XD(EPS,PetscBool); PETSC_INTERN PetscErrorCode EPSXDGetBOrth_XD(EPS,PetscBool*); PETSC_INTERN PetscErrorCode EPSJDSetConstCorrectionTol_JD(EPS,PetscBool); PETSC_INTERN PetscErrorCode EPSJDGetConstCorrectionTol_JD(EPS,PetscBool*); PETSC_INTERN PetscErrorCode EPSXDSetWindowSizes_XD(EPS,PetscInt,PetscInt); PETSC_INTERN PetscErrorCode EPSXDGetWindowSizes_XD(EPS,PetscInt*,PetscInt*); slepc-3.7.4/src/eps/impls/davidson/dvdtestconv.c0000644000175000017500000000477013107004621021213 0ustar jromanjroman/* SLEPc eigensolver: "davidson" Step: test for convergence - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" #undef __FUNCT__ #define __FUNCT__ "dvd_testconv_basic_0" static PetscBool dvd_testconv_basic_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err) { PetscBool conv; PetscReal eig_norm,errest; PetscFunctionBegin; eig_norm = SlepcAbsEigenvalue(eigvr, eigvi); errest = r/eig_norm; conv = PetscNot(errest > d->tol); if (err) *err = errest; PetscFunctionReturn(conv); } #undef __FUNCT__ #define __FUNCT__ "dvd_testconv_basic" PetscErrorCode dvd_testconv_basic(dvdDashboard *d, dvdBlackboard *b) { PetscErrorCode ierr; PetscFunctionBegin; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscFree(d->testConv_data);CHKERRQ(ierr); d->testConv = dvd_testconv_basic_0; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_testconv_slepc_0" static PetscBool dvd_testconv_slepc_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err) { PetscErrorCode ierr; PetscFunctionBegin; ierr = (*d->eps->converged)(d->eps,eigvr,eigvi,r,err,d->eps->convergedctx);CHKERRABORT(PetscObjectComm((PetscObject)d->eps),ierr); PetscFunctionReturn(PetscNot(*err>=d->eps->tol)); } #undef __FUNCT__ #define __FUNCT__ "dvd_testconv_slepc" PetscErrorCode dvd_testconv_slepc(dvdDashboard *d, dvdBlackboard *b) { PetscErrorCode ierr; PetscFunctionBegin; /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscFree(d->testConv_data);CHKERRQ(ierr); d->testConv = dvd_testconv_slepc_0; } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/dvdinitv.c0000644000175000017500000001401113107004621020464 0ustar jromanjroman/* SLEPc eigensolver: "davidson" Step: init subspace V - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" typedef struct { PetscInt k; /* desired initial subspace size */ PetscInt user; /* number of user initial vectors */ void *old_initV_data; /* old initV data */ } dvdInitV; #undef __FUNCT__ #define __FUNCT__ "dvd_initV_classic_0" static PetscErrorCode dvd_initV_classic_0(dvdDashboard *d) { PetscErrorCode ierr; dvdInitV *data = (dvdInitV*)d->initV_data; PetscInt i,user = PetscMin(data->user,d->eps->mpd), l,k; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); /* User vectors are added at the beginning, so no active column should be in V */ if (data->user>0&&l>0) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken"); /* Generate a set of random initial vectors and orthonormalize them */ for (i=l+user;ik && ieps->ncv && i-leps->mpd;i++) { ierr = BVSetRandomColumn(d->eps->V,i);CHKERRQ(ierr); } d->V_tra_s = 0; d->V_tra_e = 0; d->V_new_s = 0; d->V_new_e = i-l; /* After that the user vectors will be destroyed */ data->user = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_initV_krylov_0" static PetscErrorCode dvd_initV_krylov_0(dvdDashboard *d) { PetscErrorCode ierr; dvdInitV *data = (dvdInitV*)d->initV_data; PetscInt i,user = PetscMin(data->user,d->eps->mpd),l,k; Vec av,v1,v2; PetscFunctionBegin; ierr = BVGetActiveColumns(d->eps->V,&l,&k);CHKERRQ(ierr); /* User vectors are added at the beginning, so no active column should be in V */ if (data->user>0&&l>0) SETERRQ(PETSC_COMM_SELF,1, "Consistency broken"); /* If needed, generate a random vector for starting the arnoldi method */ if (user == 0) { ierr = BVSetRandomColumn(d->eps->V,l);CHKERRQ(ierr); user = 1; } /* Perform k steps of Arnoldi with the operator K^{-1}*(t[1]*A-t[2]*B) */ ierr = dvd_orthV(d->eps->V,l,l+user);CHKERRQ(ierr); for (i=l+user;ik && ieps->ncv && i-leps->mpd;i++) { /* aux <- theta[1]A*in - theta[0]*B*in */ ierr = BVGetColumn(d->eps->V,i,&v1);CHKERRQ(ierr); ierr = BVGetColumn(d->eps->V,i-user,&v2);CHKERRQ(ierr); ierr = BVGetColumn(d->auxBV,0,&av);CHKERRQ(ierr); if (d->B) { ierr = MatMult(d->A,v2,v1);CHKERRQ(ierr); ierr = MatMult(d->B,v2,av);CHKERRQ(ierr); ierr = VecAXPBY(av,d->target[1],-d->target[0],v1);CHKERRQ(ierr); } else { ierr = MatMult(d->A,v2,av);CHKERRQ(ierr); ierr = VecAXPBY(av,-d->target[0],d->target[1],v2);CHKERRQ(ierr); } ierr = d->improvex_precond(d,0,av,v1);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,i,&v1);CHKERRQ(ierr); ierr = BVRestoreColumn(d->eps->V,i-user,&v2);CHKERRQ(ierr); ierr = BVRestoreColumn(d->auxBV,0,&av);CHKERRQ(ierr); ierr = dvd_orthV(d->eps->V,i,i+1);CHKERRQ(ierr); } d->V_tra_s = 0; d->V_tra_e = 0; d->V_new_s = 0; d->V_new_e = i-l; /* After that the user vectors will be destroyed */ data->user = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_initV_d" static PetscErrorCode dvd_initV_d(dvdDashboard *d) { PetscErrorCode ierr; dvdInitV *data = (dvdInitV*)d->initV_data; PetscFunctionBegin; /* Restore changes in dvdDashboard */ d->initV_data = data->old_initV_data; /* Free local data */ ierr = PetscFree(data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_initV" PetscErrorCode dvd_initV(dvdDashboard *d, dvdBlackboard *b, PetscInt k,PetscInt user, PetscBool krylov) { PetscErrorCode ierr; dvdInitV *data; PetscFunctionBegin; /* Setting configuration constrains */ b->max_size_V = PetscMax(b->max_size_V, k); /* Setup the step */ if (b->state >= DVD_STATE_CONF) { ierr = PetscNewLog(d->eps,&data);CHKERRQ(ierr); data->k = k; data->user = user; data->old_initV_data = d->initV_data; d->initV_data = data; if (krylov) d->initV = dvd_initV_krylov_0; else d->initV = dvd_initV_classic_0; ierr = EPSDavidsonFLAdd(&d->destroyList,dvd_initV_d);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_orthV" PetscErrorCode dvd_orthV(BV V,PetscInt V_new_s,PetscInt V_new_e) { PetscErrorCode ierr; PetscInt i,j,l,k; PetscBool lindep; PetscReal norm; PetscFunctionBegin; ierr = BVGetActiveColumns(V,&l,&k);CHKERRQ(ierr); for (i=V_new_s;i0) { ierr = BVSetRandomColumn(V,i);CHKERRQ(ierr); ierr = PetscInfo1(V,"Orthonormalization problems adding the vector %D to the searching subspace\n",i);CHKERRQ(ierr); } ierr = BVOrthogonalizeColumn(V,i,NULL,&norm,&lindep);CHKERRQ(ierr); if (!lindep && (PetscAbsReal(norm) > PETSC_SQRT_MACHINE_EPSILON)) break; } if (lindep || (PetscAbsReal(norm) < PETSC_SQRT_MACHINE_EPSILON)) SETERRQ(PetscObjectComm((PetscObject)V),1, "Error during the orthonormalization of the vectors"); ierr = BVScaleColumn(V,i,1.0/norm);CHKERRQ(ierr); } ierr = BVSetActiveColumns(V,l,k);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/davidson/davidson.h.html0000644000175000017500000007070413107004621021427 0ustar jromanjroman
Actual source code: davidson.h

slepc-3.7.4 2017-05-17
  1: /*
  2:   Method: General Davidson Method (includes GD and JD)

  4:   References:
  5:     - Ernest R. Davidson. Super-matrix methods. Computer Physics Communications,
  6:       53:49-60, May 1989.

  8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 10:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 12:    This file is part of SLEPc.

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

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

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

 28: #include <slepc/private/epsimpl.h>
 29: #include <slepc/private/vecimplslepc.h>

 31: struct _dvdDashboard;
 32: typedef PetscErrorCode (*dvdCallback)(struct _dvdDashboard*);
 33: typedef struct _dvdFunctionList {
 34:   dvdCallback f;
 35:   struct _dvdFunctionList *next;
 36: } dvdFunctionList;

 38: typedef enum {
 39:   DVD_HARM_NONE,
 40:   DVD_HARM_RR,
 41:   DVD_HARM_RRR,
 42:   DVD_HARM_REIGS,
 43:   DVD_HARM_LEIGS
 44: } HarmType_t;

 46: typedef enum {
 47:   DVD_INITV_CLASSIC,
 48:   DVD_INITV_KRYLOV
 49: } InitType_t;

 51: typedef enum {
 52:   DVD_PROJ_KXX,
 53:   DVD_PROJ_KZX
 54: } ProjType_t;

 56: /*
 57:    Dashboard struct: contains the methods that will be employed and the tuning
 58:    options.
 59: */

 61: typedef struct _dvdDashboard {
 62:   /**** Function steps ****/
 63:   /* Initialize V */
 64:   PetscErrorCode (*initV)(struct _dvdDashboard*);
 65:   void *initV_data;

 67:   /* Find the approximate eigenpairs from V */
 68:   PetscErrorCode (*calcPairs)(struct _dvdDashboard*);
 69:   void *calcPairs_data;

 71:   /* Eigenpair test for convergence */
 72:   PetscBool (*testConv)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscReal,PetscReal*);
 73:   void *testConv_data;

 75:   /* Improve the selected eigenpairs */
 76:   PetscErrorCode (*improveX)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt*);
 77:   void *improveX_data;

 79:   /* Check for restarting */
 80:   PetscErrorCode (*isRestarting)(struct _dvdDashboard*,PetscBool*);
 81:   void *isRestarting_data;

 83:   /* Perform restarting */
 84:   PetscErrorCode (*restartV)(struct _dvdDashboard*);
 85:   void *restartV_data;

 87:   /* Update V */
 88:   PetscErrorCode (*updateV)(struct _dvdDashboard*);
 89:   void *updateV_data;

 91:   /**** Problem specification ****/
 92:   Mat         A,B;            /* problem matrices */
 93:   MatType_t   sA,sB;          /* matrix specifications */
 94:   EPType_t    sEP;            /* problem specifications */
 95:   PetscInt    nev;            /* number of eigenpairs */
 96:   EPSWhich    which;          /* spectrum selection */
 97:   PetscBool   withTarget;     /* if there is a target */
 98:   PetscScalar target[2];      /* target value */
 99:   PetscReal   tol;            /* tolerance */
100:   PetscBool   correctXnorm;   /* if true, norm of X are computed */

102:   /**** Subspaces specification ****/
103:   PetscInt nconv;             /* number of converged eigenpairs */
104:   PetscInt npreconv;          /* number of pairs ready to converge */

106:   BV       W;                 /* left basis for harmonic case */
107:   BV       AX;                /* A*V */
108:   BV       BX;                /* B*V */
109:   PetscInt size_D;            /* active vectors */
110:   PetscInt max_size_proj;     /* max size projected problem */
111:   PetscInt max_cX_in_proj;    /* max vectors from cX in the projected problem */
112:   PetscInt max_cX_in_impr;    /* max vectros from cX in the projector */
113:   PetscInt max_size_P;        /* max unconverged vectors in the projector */
114:   PetscInt bs;                /* max vectors that expands the subspace every iteration */
115:   EPS      eps;               /* connection to SLEPc */

117:   /**** Auxiliary space ****/
118:   VecPool auxV;               /* auxiliary vectors */
119:   BV      auxBV;              /* auxiliary vectors */

121:   /**** Eigenvalues and errors ****/
122:   PetscScalar *ceigr,*ceigi;  /* converged eigenvalues */
123:   PetscScalar *eigr,*eigi;    /* current eigenvalues */
124:   PetscReal   *nR;            /* residual norm */
125:   PetscReal   *real_nR;       /* original nR */
126:   PetscReal   *nX;            /* X norm */
127:   PetscReal   *real_nX;       /* original nX */
128:   PetscReal   *errest;        /* relative error eigenpairs */
129:   PetscReal   *nBds;          /* B-norms of projected problem  */

131:   /**** Shared function and variables ****/
132:   PetscErrorCode (*e_Vchanged)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt);
133:   void *e_Vchanged_data;
134:   PetscErrorCode (*calcpairs_residual)(struct _dvdDashboard*,PetscInt,PetscInt);
135:   PetscErrorCode (*calcpairs_selectPairs)(struct _dvdDashboard*,PetscInt);
136:   void *calcpairs_residual_data;
137:   PetscErrorCode (*improvex_precond)(struct _dvdDashboard*,PetscInt,Vec,Vec);
138:   void *improvex_precond_data;
139:   PetscErrorCode (*improvex_jd_proj_uv)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*,Vec*,Vec*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt);
140:   PetscErrorCode (*improvex_jd_lit)(struct _dvdDashboard*,PetscInt,PetscScalar*,PetscScalar*,PetscInt*,PetscReal*);
141:   PetscErrorCode (*calcpairs_W)(struct _dvdDashboard*);
142:   void *calcpairs_W_data;
143:   PetscErrorCode (*calcpairs_proj_trans)(struct _dvdDashboard*);
144:   PetscErrorCode (*calcpairs_eigs_trans)(struct _dvdDashboard*);
145:   PetscErrorCode (*calcpairs_eig_backtrans)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscScalar*,PetscScalar*);
146:   PetscErrorCode (*calcpairs_proj_res)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*);
147:   PetscErrorCode (*preTestConv)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt*);
148:   PetscErrorCode (*e_newIteration)(struct _dvdDashboard*);
149:   void *e_newIteration_data;

151:   dvdFunctionList *startList;  /* starting list */
152:   dvdFunctionList *endList;    /* ending list */
153:   dvdFunctionList *destroyList;/* destructor list */

155:   Mat       H,G;               /* projected problem matrices */
156:   Mat       auxM;              /* auxiliary dense matrix */
157:   PetscInt  size_MT;           /* rows in MT */

159:   PetscInt  V_tra_s;
160:   PetscInt  V_tra_e;       /* cX <- [cX V*MT(0:V_tra_s-1)], V <- V*MT(V_tra_s:V_tra_e) */
161:   PetscInt  V_new_s;
162:   PetscInt  V_new_e;           /* added to V the columns V_new_s:V_new_e */
163:   PetscBool BV_shift;          /* if true BV is shifted when vectors converge */
164:   PetscBool W_shift;           /* if true W is shifted when vectors converge */
165: } dvdDashboard;

167: typedef struct {
168:   /*------------------------- User parameters ---------------------------*/
169:   PetscInt  blocksize;     /* block size */
170:   PetscInt  initialsize;   /* initial size of V */
171:   PetscInt  minv;          /* size of V after restarting */
172:   PetscInt  plusk;         /* keep plusk eigenvectors from the last iteration */
173:   PetscBool ipB;           /* true if B-ortho is used */
174:   PetscReal fix;           /* the fix parameter */
175:   PetscBool krylovstart;   /* true if the starting subspace is a Krylov basis */
176:   PetscBool dynamic;       /* true if dynamic stopping criterion is used */
177:   PetscInt  cX_in_proj;    /* converged vectors in the projected problem */
178:   PetscInt  cX_in_impr;    /* converged vectors in the projector */
179:   PetscBool doubleexp;     /* double expansion in GD (GD2) */

181:   /*----------------- Child objects and working data -------------------*/
182:   dvdDashboard ddb;
183: } EPS_DAVIDSON;

187: PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLAdd(dvdFunctionList **fl,dvdCallback f)
188: {
190:   dvdFunctionList *l;

193:   PetscNew(&l);
194:   l->f = f;
195:   l->next = *fl;
196:   *fl = l;
197:   return(0);
198: }
199:   
202: PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLCall(dvdFunctionList *fl,dvdDashboard *d)
203: {
205:   dvdFunctionList *l;

208:   for (l=fl;l;l=l->next) { (l->f)(d); }
209:   return(0);
210: }

214: PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLDestroy(dvdFunctionList **fl)
215: {
216:   PetscErrorCode  ierr;
217:   dvdFunctionList *l,*l0;

220:   for (l=*fl;l;l=l0) {
221:     l0 = l->next;
222:     PetscFree(l);
223:   }
224:   *fl = NULL;
225:   return(0);
226: }

228: /*
229:   The blackboard configuration structure: saves information about the memory
230:   and other requirements.

232:   The starting memory structure:

234:   V           W?          AV          BV?          tKZ
235:   |-----------|-----------|-----------|------------|-------|
236:   nev+mpd     nev+mpd     scP+mpd     nev?+mpd     sP+scP
237:               scP+mpd                 scP+mpd

239:   The final memory structure considering W_shift and BV_shift:

241:   cX  V       cY?  W?     cAV AV      BcX? BV?     KZ  tKZ
242:   |---|-------|----|------|---|-------|----|-------|---|---|
243:   nev mpd     nev  mpd    scP mpd     nev  mpd     scP sP    <- shift
244:               scP                     scP                    <- !shift
245: */
246: typedef struct {
247:   PetscInt max_size_V;         /* max size of the searching subspace (mpd) */
248:   PetscInt max_size_X;         /* max size of X (bs) */
249:   PetscInt size_V;             /* real size of V (nev+size_P+mpd) */
250:   PetscInt max_size_oldX;      /* max size of oldX */
251:   PetscInt max_nev;            /* max number of converged pairs */
252:   PetscInt max_size_P;         /* number of computed vectors for the projector */
253:   PetscInt max_size_cP;        /* number of converged vectors in the projectors */
254:   PetscInt max_size_proj;      /* max size projected problem */
255:   PetscInt max_size_cX_proj;   /* max converged vectors in the projected problem */
256:   PetscInt state;              /* method states:
257:                                    0: preconfiguring
258:                                    1: configuring
259:                                    2: running */
260: } dvdBlackboard;

262: #define DVD_STATE_PRECONF 0
263: #define DVD_STATE_CONF 1
264: #define DVD_STATE_RUN 2

266: /* Prototypes of non-static auxiliary functions */
267: PETSC_INTERN PetscErrorCode dvd_calcpairs_qz(dvdDashboard*,dvdBlackboard*,PetscBool,PetscInt,PetscBool);
268: PETSC_INTERN PetscErrorCode dvd_improvex_gd2(dvdDashboard*,dvdBlackboard*,KSP,PetscInt);
269: PETSC_INTERN PetscErrorCode dvd_improvex_jd(dvdDashboard*,dvdBlackboard*,KSP,PetscInt,PetscInt,PetscBool);
270: PETSC_INTERN PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard*,dvdBlackboard*,ProjType_t);
271: PETSC_INTERN PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard*,dvdBlackboard*,PetscInt,PetscReal,PetscReal);
272: PETSC_INTERN PetscErrorCode dvd_improvex_compute_X(dvdDashboard*,PetscInt,PetscInt,Vec*,PetscScalar*,PetscInt);
273: PETSC_INTERN PetscErrorCode dvd_initV(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscBool);
274: PETSC_INTERN PetscErrorCode dvd_orthV(BV,PetscInt,PetscInt);
275: PETSC_INTERN PetscErrorCode dvd_schm_basic_preconf(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,HarmType_t,KSP,InitType_t,PetscBool,PetscBool,PetscInt,PetscInt,PetscBool);
276: PETSC_INTERN PetscErrorCode dvd_schm_basic_conf(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,HarmType_t,PetscBool,PetscScalar,KSP,PetscReal,InitType_t,PetscBool,PetscBool,PetscInt,PetscInt,PetscBool,PetscBool);
277: PETSC_INTERN PetscErrorCode dvd_testconv_basic(dvdDashboard*,dvdBlackboard*);
278: PETSC_INTERN PetscErrorCode dvd_testconv_slepc(dvdDashboard*,dvdBlackboard*);
279: PETSC_INTERN PetscErrorCode dvd_managementV_basic(dvdDashboard*,dvdBlackboard*,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool,PetscBool);
280: PETSC_INTERN PetscErrorCode dvd_static_precond_PC(dvdDashboard*,dvdBlackboard*,PC);
281: PETSC_INTERN PetscErrorCode dvd_jacobi_precond(dvdDashboard*,dvdBlackboard*);
282: PETSC_INTERN PetscErrorCode dvd_harm_updateproj(dvdDashboard*);
283: PETSC_INTERN PetscErrorCode dvd_harm_conf(dvdDashboard*,dvdBlackboard*,HarmType_t,PetscBool,PetscScalar);

285: /* Internal interface routines */
286: PETSC_INTERN PetscErrorCode EPSReset_XD(EPS);
287: PETSC_INTERN PetscErrorCode EPSSetUp_XD(EPS);
288: PETSC_INTERN PetscErrorCode EPSSolve_XD(EPS);
289: PETSC_INTERN PetscErrorCode EPSComputeVectors_XD(EPS);
290: PETSC_INTERN PetscErrorCode EPSXDSetKrylovStart_XD(EPS,PetscBool);
291: PETSC_INTERN PetscErrorCode EPSXDGetKrylovStart_XD(EPS,PetscBool*);
292: PETSC_INTERN PetscErrorCode EPSXDSetBlockSize_XD(EPS,PetscInt);
293: PETSC_INTERN PetscErrorCode EPSXDGetBlockSize_XD(EPS,PetscInt*);
294: PETSC_INTERN PetscErrorCode EPSXDSetRestart_XD(EPS,PetscInt,PetscInt);
295: PETSC_INTERN PetscErrorCode EPSXDGetRestart_XD(EPS,PetscInt*,PetscInt*);
296: PETSC_INTERN PetscErrorCode EPSXDGetInitialSize_XD(EPS,PetscInt*);
297: PETSC_INTERN PetscErrorCode EPSXDSetInitialSize_XD(EPS,PetscInt);
298: PETSC_INTERN PetscErrorCode EPSXDGetFix_XD(EPS,PetscReal*);
299: PETSC_INTERN PetscErrorCode EPSJDSetFix_JD(EPS,PetscReal);
300: PETSC_INTERN PetscErrorCode EPSXDSetBOrth_XD(EPS,PetscBool);
301: PETSC_INTERN PetscErrorCode EPSXDGetBOrth_XD(EPS,PetscBool*);
302: PETSC_INTERN PetscErrorCode EPSJDSetConstCorrectionTol_JD(EPS,PetscBool);
303: PETSC_INTERN PetscErrorCode EPSJDGetConstCorrectionTol_JD(EPS,PetscBool*);
304: PETSC_INTERN PetscErrorCode EPSXDSetWindowSizes_XD(EPS,PetscInt,PetscInt);
305: PETSC_INTERN PetscErrorCode EPSXDGetWindowSizes_XD(EPS,PetscInt*,PetscInt*);

slepc-3.7.4/src/eps/impls/davidson/dvdschm.c0000644000175000017500000001114213107004621020267 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "davidson.h" #define DVD_CHECKSUM(b) ((b)->max_size_V + (b)->max_size_oldX) #undef __FUNCT__ #define __FUNCT__ "dvd_schm_basic_preconf" PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,KSP ksp,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool doubleexp) { PetscErrorCode ierr; PetscInt check_sum0,check_sum1; PetscFunctionBegin; ierr = PetscMemzero(b,sizeof(dvdBlackboard));CHKERRQ(ierr); b->state = DVD_STATE_PRECONF; for (check_sum0=-1,check_sum1=DVD_CHECKSUM(b); check_sum0 != check_sum1; check_sum0 = check_sum1, check_sum1 = DVD_CHECKSUM(b)) { /* Setup basic management of V */ ierr = dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);CHKERRQ(ierr); /* Setup the initial subspace for V */ ierr = dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);CHKERRQ(ierr); /* Setup the convergence in order to use the SLEPc convergence test */ ierr = dvd_testconv_slepc(d,b);CHKERRQ(ierr); /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */ ierr = dvd_calcpairs_qz(d,b,orth,cX_proj,PetscNot(harmMode==DVD_HARM_NONE));CHKERRQ(ierr); if (harmMode != DVD_HARM_NONE) { ierr = dvd_harm_conf(d,b,harmMode,PETSC_FALSE,0.0);CHKERRQ(ierr); } /* Setup the method for improving the eigenvectors */ if (doubleexp) { ierr = dvd_improvex_gd2(d,b,ksp,bs);CHKERRQ(ierr); } else { ierr = dvd_improvex_jd(d,b,ksp,bs,cX_impr,PETSC_FALSE);CHKERRQ(ierr); ierr = dvd_improvex_jd_proj_uv(d,b,DVD_PROJ_KZX);CHKERRQ(ierr); ierr = dvd_improvex_jd_lit_const(d,b,0,0.0,0.0);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "dvd_schm_basic_conf" PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,PetscBool fixedTarget,PetscScalar t,KSP ksp,PetscReal fix,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool dynamic,PetscBool doubleexp) { PetscInt check_sum0,check_sum1,maxits; PetscReal tol; PetscErrorCode ierr; PetscFunctionBegin; b->state = DVD_STATE_CONF; check_sum0 = DVD_CHECKSUM(b); /* Setup basic management of V */ ierr = dvd_managementV_basic(d,b,bs,mpd,min_size_V,plusk,PetscNot(harmMode==DVD_HARM_NONE),allResiduals);CHKERRQ(ierr); /* Setup the initial subspace for V */ ierr = dvd_initV(d,b,ini_size_V,size_initV,(init==DVD_INITV_KRYLOV)?PETSC_TRUE:PETSC_FALSE);CHKERRQ(ierr); /* Setup the convergence in order to use the SLEPc convergence test */ ierr = dvd_testconv_slepc(d,b);CHKERRQ(ierr); /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */ ierr = dvd_calcpairs_qz(d,b,orth,cX_proj,PetscNot(harmMode==DVD_HARM_NONE));CHKERRQ(ierr); if (harmMode != DVD_HARM_NONE) { ierr = dvd_harm_conf(d,b,harmMode,fixedTarget,t);CHKERRQ(ierr); } /* Setup the method for improving the eigenvectors */ if (doubleexp) { ierr = dvd_improvex_gd2(d,b,ksp,bs);CHKERRQ(ierr); } else { ierr = dvd_improvex_jd(d,b,ksp,bs,cX_impr,dynamic);CHKERRQ(ierr); ierr = dvd_improvex_jd_proj_uv(d,b,DVD_PROJ_KZX);CHKERRQ(ierr); ierr = KSPGetTolerances(ksp,&tol,NULL,NULL,&maxits);CHKERRQ(ierr); ierr = dvd_improvex_jd_lit_const(d,b,maxits,tol,fix);CHKERRQ(ierr); } check_sum1 = DVD_CHECKSUM(b); if (check_sum0 != check_sum1) SETERRQ(PETSC_COMM_SELF,1, "Something awful happened"); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/index.html0000644000175000017500000000312713107004621016665 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

power/
subspace/
krylov/
davidson/
cg/
ciss/
lapack/
external/
makefile
slepc-3.7.4/src/eps/impls/krylov/0000755000175000017500000000000013107004621016213 5ustar jromanjromanslepc-3.7.4/src/eps/impls/krylov/makefile0000644000175000017500000000221513107004621017713 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = epskrylov.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = arnoldi lanczos krylovschur LOCDIR = src/eps/impls/krylov/ MANSEC = EPS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/krylov/epskrylov.c.html0000644000175000017500000010757613107004621021400 0ustar jromanjroman

Actual source code: epskrylov.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Common subroutines for all Krylov-type solvers.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/epsimpl.h>
 25: #include <slepc/private/slepcimpl.h>
 26: #include <slepcblaslapack.h>

 30: /*
 31:    EPSBasicArnoldi - Computes an m-step Arnoldi factorization. The first k
 32:    columns are assumed to be locked and therefore they are not modified. On
 33:    exit, the following relation is satisfied:

 35:                     OP * V - V * H = beta*v_m * e_m^T

 37:    where the columns of V are the Arnoldi vectors (which are B-orthonormal),
 38:    H is an upper Hessenberg matrix, e_m is the m-th vector of the canonical basis.
 39:    On exit, beta contains the B-norm of V[m] before normalization.
 40: */
 41: PetscErrorCode EPSBasicArnoldi(EPS eps,PetscBool trans,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)
 42: {
 44:   PetscInt       j,m = *M;
 45:   Vec            vj,vj1;

 48:   BVSetActiveColumns(eps->V,0,m);
 49:   for (j=k;j<m;j++) {
 50:     BVGetColumn(eps->V,j,&vj);
 51:     BVGetColumn(eps->V,j+1,&vj1);
 52:     if (trans) {
 53:       STApplyTranspose(eps->st,vj,vj1);
 54:     } else {
 55:       STApply(eps->st,vj,vj1);
 56:     }
 57:     BVRestoreColumn(eps->V,j,&vj);
 58:     BVRestoreColumn(eps->V,j+1,&vj1);
 59:     BVOrthogonalizeColumn(eps->V,j+1,H+ldh*j,beta,breakdown);
 60:     if (*breakdown) {
 61:       H[j+1+ldh*j] = 0.0;
 62:       *M = j+1;
 63:       break;
 64:     } else {
 65:       H[j+1+ldh*j] = *beta;
 66:       BVScaleColumn(eps->V,j+1,1.0/(*beta));
 67:     }
 68:   }
 69:   return(0);
 70: }

 74: /*
 75:    EPSDelayedArnoldi - This function is equivalent to EPSBasicArnoldi but
 76:    performs the computation in a different way. The main idea is that
 77:    reorthogonalization is delayed to the next Arnoldi step. This version is
 78:    more scalable but in some cases convergence may stagnate.
 79: */
 80: PetscErrorCode EPSDelayedArnoldi(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)
 81: {
 83:   PetscInt       i,j,m=*M;
 84:   Vec            u,t;
 85:   PetscScalar    shh[100],*lhh,dot,dot2;
 86:   PetscReal      norm1=0.0,norm2=1.0;
 87:   Vec            vj,vj1,vj2;

 90:   if (m<=100) lhh = shh;
 91:   else {
 92:     PetscMalloc1(m,&lhh);
 93:   }
 94:   BVCreateVec(eps->V,&u);
 95:   BVCreateVec(eps->V,&t);

 97:   BVSetActiveColumns(eps->V,0,m);
 98:   for (j=k;j<m;j++) {
 99:     BVGetColumn(eps->V,j,&vj);
100:     BVGetColumn(eps->V,j+1,&vj1);
101:     STApply(eps->st,vj,vj1);
102:     BVRestoreColumn(eps->V,j,&vj);
103:     BVRestoreColumn(eps->V,j+1,&vj1);

105:     BVDotColumnBegin(eps->V,j+1,H+ldh*j);
106:     if (j>k) {
107:       BVDotColumnBegin(eps->V,j,lhh);
108:       BVGetColumn(eps->V,j,&vj);
109:       VecDotBegin(vj,vj,&dot);
110:     }
111:     if (j>k+1) {
112:       BVNormVecBegin(eps->V,u,NORM_2,&norm2);
113:       BVGetColumn(eps->V,j-2,&vj2);
114:       VecDotBegin(u,vj2,&dot2);
115:     }

117:     BVDotColumnEnd(eps->V,j+1,H+ldh*j);
118:     if (j>k) {
119:       BVDotColumnEnd(eps->V,j,lhh);
120:       VecDotEnd(vj,vj,&dot);
121:       BVRestoreColumn(eps->V,j,&vj);
122:     }
123:     if (j>k+1) {
124:       BVNormVecEnd(eps->V,u,NORM_2,&norm2);
125:       VecDotEnd(u,vj2,&dot2);
126:       BVRestoreColumn(eps->V,j-2,&vj2);
127:     }

129:     if (j>k) {
130:       norm1 = PetscSqrtReal(PetscRealPart(dot));
131:       for (i=0;i<j;i++)
132:         H[ldh*j+i] = H[ldh*j+i]/norm1;
133:       H[ldh*j+j] = H[ldh*j+j]/dot;

135:       BVCopyVec(eps->V,j,t);
136:       BVScaleColumn(eps->V,j,1.0/norm1);
137:       BVScaleColumn(eps->V,j+1,1.0/norm1);
138:     }

140:     BVMultColumn(eps->V,-1.0,1.0,j+1,H+ldh*j);

142:     if (j>k) {
143:       BVSetActiveColumns(eps->V,0,j);
144:       BVMultVec(eps->V,-1.0,1.0,t,lhh);
145:       BVSetActiveColumns(eps->V,0,m);
146:       for (i=0;i<j;i++)
147:         H[ldh*(j-1)+i] += lhh[i];
148:     }

150:     if (j>k+1) {
151:       BVGetColumn(eps->V,j-1,&vj1);
152:       VecCopy(u,vj1);
153:       BVRestoreColumn(eps->V,j-1,&vj1);
154:       BVScaleColumn(eps->V,j-1,1.0/norm2);
155:       H[ldh*(j-2)+j-1] = norm2;
156:     }

158:     if (j<m-1) {
159:       VecCopy(t,u);
160:     }
161:   }

163:   BVNormVec(eps->V,t,NORM_2,&norm2);
164:   VecScale(t,1.0/norm2);
165:   BVGetColumn(eps->V,m-1,&vj1);
166:   VecCopy(t,vj1);
167:   BVRestoreColumn(eps->V,m-1,&vj1);
168:   H[ldh*(m-2)+m-1] = norm2;

170:   BVDotColumn(eps->V,m,lhh);

172:   BVMultColumn(eps->V,-1.0,1.0,m,lhh);
173:   for (i=0;i<m;i++)
174:     H[ldh*(m-1)+i] += lhh[i];

176:   BVNormColumn(eps->V,m,NORM_2,beta);
177:   BVScaleColumn(eps->V,m,1.0 / *beta);
178:   *breakdown = PETSC_FALSE;

180:   if (m>100) { PetscFree(lhh); }
181:   VecDestroy(&u);
182:   VecDestroy(&t);
183:   return(0);
184: }

188: /*
189:    EPSDelayedArnoldi1 - This function is similar to EPSDelayedArnoldi,
190:    but without reorthogonalization (only delayed normalization).
191: */
192: PetscErrorCode EPSDelayedArnoldi1(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)
193: {
195:   PetscInt       i,j,m=*M;
196:   PetscScalar    dot;
197:   PetscReal      norm=0.0;
198:   Vec            vj,vj1;

201:   BVSetActiveColumns(eps->V,0,m);
202:   for (j=k;j<m;j++) {
203:     BVGetColumn(eps->V,j,&vj);
204:     BVGetColumn(eps->V,j+1,&vj1);
205:     STApply(eps->st,vj,vj1);
206:     BVRestoreColumn(eps->V,j+1,&vj1);
207:     BVDotColumnBegin(eps->V,j+1,H+ldh*j);
208:     if (j>k) {
209:       VecDotBegin(vj,vj,&dot);
210:     }
211:     BVDotColumnEnd(eps->V,j+1,H+ldh*j);
212:     if (j>k) {
213:       VecDotEnd(vj,vj,&dot);
214:     }
215:     BVRestoreColumn(eps->V,j,&vj);

217:     if (j>k) {
218:       norm = PetscSqrtReal(PetscRealPart(dot));
219:       BVScaleColumn(eps->V,j,1.0/norm);
220:       H[ldh*(j-1)+j] = norm;

222:       for (i=0;i<j;i++)
223:         H[ldh*j+i] = H[ldh*j+i]/norm;
224:       H[ldh*j+j] = H[ldh*j+j]/dot;
225:       BVScaleColumn(eps->V,j+1,1.0/norm);
226:       *beta = norm;
227:     }
228:     BVMultColumn(eps->V,-1.0,1.0,j+1,H+ldh*j);
229:   }

231:   *breakdown = PETSC_FALSE;
232:   return(0);
233: }

237: /*
238:    EPSKrylovConvergence - Implements the loop that checks for convergence
239:    in Krylov methods.

241:    Input Parameters:
242:      eps   - the eigensolver; some error estimates are updated in eps->errest
243:      getall - whether all residuals must be computed
244:      kini  - initial value of k (the loop variable)
245:      nits  - number of iterations of the loop
246:      V     - set of basis vectors (used only if trueresidual is activated)
247:      nv    - number of vectors to process (dimension of Q, columns of V)
248:      beta  - norm of f (the residual vector of the Arnoldi/Lanczos factorization)
249:      corrf - correction factor for residual estimates (only in harmonic KS)

251:    Output Parameters:
252:      kout  - the first index where the convergence test failed
253: */
254: PetscErrorCode EPSKrylovConvergence(EPS eps,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscReal corrf,PetscInt *kout)
255: {
257:   PetscInt       k,newk,marker,ld,inside;
258:   PetscScalar    re,im,*Zr,*Zi,*X;
259:   PetscReal      resnorm;
260:   PetscBool      isshift,refined,istrivial;
261:   Vec            x,y,w[3];

264:   RGIsTrivial(eps->rg,&istrivial);
265:   if (eps->trueres) {
266:     BVCreateVec(eps->V,&x);
267:     BVCreateVec(eps->V,&y);
268:     BVCreateVec(eps->V,&w[0]);
269:     BVCreateVec(eps->V,&w[2]);
270: #if !defined(PETSC_USE_COMPLEX)
271:     BVCreateVec(eps->V,&w[1]);
272: #else
273:     w[1] = NULL;
274: #endif
275:   }
276:   DSGetLeadingDimension(eps->ds,&ld);
277:   DSGetRefined(eps->ds,&refined);
278:   PetscObjectTypeCompare((PetscObject)eps->st,STSHIFT,&isshift);
279:   marker = -1;
280:   if (eps->trackall) getall = PETSC_TRUE;
281:   for (k=kini;k<kini+nits;k++) {
282:     /* eigenvalue */
283:     re = eps->eigr[k];
284:     im = eps->eigi[k];
285:     if (!istrivial || eps->trueres || isshift || eps->conv==EPS_CONV_NORM) {
286:       STBackTransform(eps->st,1,&re,&im);
287:     }
288:     if (!istrivial) {
289:       RGCheckInside(eps->rg,1,&re,&im,&inside);
290:       if (marker==-1 && inside<0) marker = k;
291:       if (!(eps->trueres || isshift || eps->conv==EPS_CONV_NORM)) {  /* make sure eps->converged below uses the right value */
292:         re = eps->eigr[k];
293:         im = eps->eigi[k];
294:       }
295:     }
296:     newk = k;
297:     DSVectors(eps->ds,DS_MAT_X,&newk,&resnorm);
298:     if (eps->trueres) {
299:       DSGetArray(eps->ds,DS_MAT_X,&X);
300:       Zr = X+k*ld;
301:       if (newk==k+1) Zi = X+newk*ld;
302:       else Zi = NULL;
303:       EPSComputeRitzVector(eps,Zr,Zi,eps->V,x,y);
304:       DSRestoreArray(eps->ds,DS_MAT_X,&X);
305:       EPSComputeResidualNorm_Private(eps,re,im,x,y,w,&resnorm);
306:     }
307:     else if (!refined) resnorm *= beta*corrf;
308:     /* error estimate */
309:     (*eps->converged)(eps,re,im,resnorm,&eps->errest[k],eps->convergedctx);
310:     if (marker==-1 && eps->errest[k] >= eps->tol) marker = k;
311:     if (newk==k+1) {
312:       eps->errest[k+1] = eps->errest[k];
313:       k++;
314:     }
315:     if (marker!=-1 && !getall) break;
316:   }
317:   if (marker!=-1) k = marker;
318:   *kout = k;
319:   if (eps->trueres) {
320:     VecDestroy(&x);
321:     VecDestroy(&y);
322:     VecDestroy(&w[0]);
323:     VecDestroy(&w[2]);
324: #if !defined(PETSC_USE_COMPLEX)
325:     VecDestroy(&w[1]);
326: #endif
327:   }
328:   return(0);
329: }

333: /*
334:    EPSFullLanczos - Computes an m-step Lanczos factorization with full
335:    reorthogonalization.  At each Lanczos step, the corresponding Lanczos
336:    vector is orthogonalized with respect to all previous Lanczos vectors.
337:    This is equivalent to computing an m-step Arnoldi factorization and
338:    exploting symmetry of the operator.

340:    The first k columns are assumed to be locked and therefore they are
341:    not modified. On exit, the following relation is satisfied:

343:                     OP * V - V * T = beta_m*v_m * e_m^T

345:    where the columns of V are the Lanczos vectors (which are B-orthonormal),
346:    T is a real symmetric tridiagonal matrix, and e_m is the m-th vector of
347:    the canonical basis. The tridiagonal is stored as two arrays: alpha
348:    contains the diagonal elements, beta the off-diagonal. On exit, the last
349:    element of beta contains the B-norm of V[m] before normalization.
350: */
351: PetscErrorCode EPSFullLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown)
352: {
354:   PetscInt       j,m = *M;
355:   Vec            vj,vj1;
356:   PetscScalar    *hwork,lhwork[100];

359:   if (m > 100) {
360:     PetscMalloc1(m,&hwork);
361:   } else hwork = lhwork;

363:   BVSetActiveColumns(eps->V,0,m);
364:   for (j=k;j<m;j++) {
365:     BVGetColumn(eps->V,j,&vj);
366:     BVGetColumn(eps->V,j+1,&vj1);
367:     STApply(eps->st,vj,vj1);
368:     BVRestoreColumn(eps->V,j,&vj);
369:     BVRestoreColumn(eps->V,j+1,&vj1);
370:     BVOrthogonalizeColumn(eps->V,j+1,hwork,beta+j,breakdown);
371:     alpha[j] = PetscRealPart(hwork[j]);
372:     if (*breakdown) {
373:       *M = j+1;
374:       break;
375:     } else {
376:       BVScaleColumn(eps->V,j+1,1.0/beta[j]);
377:     }
378:   }
379:   if (m > 100) {
380:     PetscFree(hwork);
381:   }
382:   return(0);
383: }

387: PetscErrorCode EPSPseudoLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscReal *cos,Vec w)
388: {
390:   PetscInt       j,m = *M,i,ld,l;
391:   Vec            vj,vj1;
392:   PetscScalar    *hwork,lhwork[100];
393:   PetscReal      norm,norm1,norm2,t,*f,sym=0.0,fro=0.0;
394:   PetscBLASInt   j_,one=1;

397:   DSGetLeadingDimension(eps->ds,&ld);
398:   DSGetDimensions(eps->ds,NULL,NULL,&l,NULL,NULL);
399:   if (cos) *cos = 1.0;
400:   if (m > 100) {
401:     PetscMalloc1(m,&hwork);
402:   } else hwork = lhwork;

404:   BVSetActiveColumns(eps->V,0,m);
405:   for (j=k;j<m;j++) {
406:     BVGetColumn(eps->V,j,&vj);
407:     BVGetColumn(eps->V,j+1,&vj1);
408:     STApply(eps->st,vj,vj1);
409:     BVRestoreColumn(eps->V,j,&vj);
410:     BVRestoreColumn(eps->V,j+1,&vj1);
411:     BVOrthogonalizeColumn(eps->V,j+1,hwork,&norm,breakdown);
412:     alpha[j] = PetscRealPart(hwork[j]);
413:     beta[j] = PetscAbsReal(norm);
414:     DSGetArrayReal(eps->ds,DS_MAT_T,&f);
415:     if (j==k) { 
416:       for (i=l;i<j-1;i++) hwork[i]-= f[2*ld+i];
417:       for (i=0;i<l;i++) hwork[i] = 0.0;
418:     }
419:     DSRestoreArrayReal(eps->ds,DS_MAT_T,&f);
420:     hwork[j-1] -= beta[j-1];
421:     PetscBLASIntCast(j,&j_);
422:     sym = SlepcAbs(BLASnrm2_(&j_,hwork,&one),sym);
423:     fro = SlepcAbs(fro,SlepcAbs(alpha[j],beta[j]));
424:     if (j>0) fro = SlepcAbs(fro,beta[j-1]);
425:     if (sym/fro>PetscMax(PETSC_SQRT_MACHINE_EPSILON,10*eps->tol)) { *symmlost = PETSC_TRUE; *M=j+1; break; }
426:     omega[j+1] = (norm<0.0)? -1.0: 1.0;
427:     BVScaleColumn(eps->V,j+1,1.0/norm);
428:     /* */
429:     if (cos) {
430:       BVGetColumn(eps->V,j+1,&vj1);
431:       VecNorm(vj1,NORM_2,&norm1);
432:       BVApplyMatrix(eps->V,vj1,w);
433:       BVRestoreColumn(eps->V,j+1,&vj1);
434:       VecNorm(w,NORM_2,&norm2);
435:       t = 1.0/(norm1*norm2);
436:       if (*cos>t) *cos = t;
437:     }
438:   }
439:   if (m > 100) {
440:     PetscFree(hwork);
441:   }
442:   return(0);
443: }

slepc-3.7.4/src/eps/impls/krylov/epskrylov.c0000644000175000017500000003715113107004621020424 0ustar jromanjroman/* Common subroutines for all Krylov-type solvers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #undef __FUNCT__ #define __FUNCT__ "EPSBasicArnoldi" /* EPSBasicArnoldi - Computes an m-step Arnoldi factorization. The first k columns are assumed to be locked and therefore they are not modified. On exit, the following relation is satisfied: OP * V - V * H = beta*v_m * e_m^T where the columns of V are the Arnoldi vectors (which are B-orthonormal), H is an upper Hessenberg matrix, e_m is the m-th vector of the canonical basis. On exit, beta contains the B-norm of V[m] before normalization. */ PetscErrorCode EPSBasicArnoldi(EPS eps,PetscBool trans,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown) { PetscErrorCode ierr; PetscInt j,m = *M; Vec vj,vj1; PetscFunctionBegin; ierr = BVSetActiveColumns(eps->V,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); if (trans) { ierr = STApplyTranspose(eps->st,vj,vj1);CHKERRQ(ierr); } else { ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); } ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,j+1,H+ldh*j,beta,breakdown);CHKERRQ(ierr); if (*breakdown) { H[j+1+ldh*j] = 0.0; *M = j+1; break; } else { H[j+1+ldh*j] = *beta; ierr = BVScaleColumn(eps->V,j+1,1.0/(*beta));CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDelayedArnoldi" /* EPSDelayedArnoldi - This function is equivalent to EPSBasicArnoldi but performs the computation in a different way. The main idea is that reorthogonalization is delayed to the next Arnoldi step. This version is more scalable but in some cases convergence may stagnate. */ PetscErrorCode EPSDelayedArnoldi(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown) { PetscErrorCode ierr; PetscInt i,j,m=*M; Vec u,t; PetscScalar shh[100],*lhh,dot,dot2; PetscReal norm1=0.0,norm2=1.0; Vec vj,vj1,vj2; PetscFunctionBegin; if (m<=100) lhh = shh; else { ierr = PetscMalloc1(m,&lhh);CHKERRQ(ierr); } ierr = BVCreateVec(eps->V,&u);CHKERRQ(ierr); ierr = BVCreateVec(eps->V,&t);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = BVDotColumnBegin(eps->V,j+1,H+ldh*j);CHKERRQ(ierr); if (j>k) { ierr = BVDotColumnBegin(eps->V,j,lhh);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = VecDotBegin(vj,vj,&dot);CHKERRQ(ierr); } if (j>k+1) { ierr = BVNormVecBegin(eps->V,u,NORM_2,&norm2);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j-2,&vj2);CHKERRQ(ierr); ierr = VecDotBegin(u,vj2,&dot2);CHKERRQ(ierr); } ierr = BVDotColumnEnd(eps->V,j+1,H+ldh*j);CHKERRQ(ierr); if (j>k) { ierr = BVDotColumnEnd(eps->V,j,lhh);CHKERRQ(ierr); ierr = VecDotEnd(vj,vj,&dot);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); } if (j>k+1) { ierr = BVNormVecEnd(eps->V,u,NORM_2,&norm2);CHKERRQ(ierr); ierr = VecDotEnd(u,vj2,&dot2);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j-2,&vj2);CHKERRQ(ierr); } if (j>k) { norm1 = PetscSqrtReal(PetscRealPart(dot)); for (i=0;iV,j,t);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,j,1.0/norm1);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,j+1,1.0/norm1);CHKERRQ(ierr); } ierr = BVMultColumn(eps->V,-1.0,1.0,j+1,H+ldh*j);CHKERRQ(ierr); if (j>k) { ierr = BVSetActiveColumns(eps->V,0,j);CHKERRQ(ierr); ierr = BVMultVec(eps->V,-1.0,1.0,t,lhh);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,m);CHKERRQ(ierr); for (i=0;ik+1) { ierr = BVGetColumn(eps->V,j-1,&vj1);CHKERRQ(ierr); ierr = VecCopy(u,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j-1,&vj1);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,j-1,1.0/norm2);CHKERRQ(ierr); H[ldh*(j-2)+j-1] = norm2; } if (jV,t,NORM_2,&norm2);CHKERRQ(ierr); ierr = VecScale(t,1.0/norm2);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,m-1,&vj1);CHKERRQ(ierr); ierr = VecCopy(t,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,m-1,&vj1);CHKERRQ(ierr); H[ldh*(m-2)+m-1] = norm2; ierr = BVDotColumn(eps->V,m,lhh);CHKERRQ(ierr); ierr = BVMultColumn(eps->V,-1.0,1.0,m,lhh);CHKERRQ(ierr); for (i=0;iV,m,NORM_2,beta);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,m,1.0 / *beta);CHKERRQ(ierr); *breakdown = PETSC_FALSE; if (m>100) { ierr = PetscFree(lhh);CHKERRQ(ierr); } ierr = VecDestroy(&u);CHKERRQ(ierr); ierr = VecDestroy(&t);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDelayedArnoldi1" /* EPSDelayedArnoldi1 - This function is similar to EPSDelayedArnoldi, but without reorthogonalization (only delayed normalization). */ PetscErrorCode EPSDelayedArnoldi1(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown) { PetscErrorCode ierr; PetscInt i,j,m=*M; PetscScalar dot; PetscReal norm=0.0; Vec vj,vj1; PetscFunctionBegin; ierr = BVSetActiveColumns(eps->V,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = BVDotColumnBegin(eps->V,j+1,H+ldh*j);CHKERRQ(ierr); if (j>k) { ierr = VecDotBegin(vj,vj,&dot);CHKERRQ(ierr); } ierr = BVDotColumnEnd(eps->V,j+1,H+ldh*j);CHKERRQ(ierr); if (j>k) { ierr = VecDotEnd(vj,vj,&dot);CHKERRQ(ierr); } ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); if (j>k) { norm = PetscSqrtReal(PetscRealPart(dot)); ierr = BVScaleColumn(eps->V,j,1.0/norm);CHKERRQ(ierr); H[ldh*(j-1)+j] = norm; for (i=0;iV,j+1,1.0/norm);CHKERRQ(ierr); *beta = norm; } ierr = BVMultColumn(eps->V,-1.0,1.0,j+1,H+ldh*j);CHKERRQ(ierr); } *breakdown = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovConvergence" /* EPSKrylovConvergence - Implements the loop that checks for convergence in Krylov methods. Input Parameters: eps - the eigensolver; some error estimates are updated in eps->errest getall - whether all residuals must be computed kini - initial value of k (the loop variable) nits - number of iterations of the loop V - set of basis vectors (used only if trueresidual is activated) nv - number of vectors to process (dimension of Q, columns of V) beta - norm of f (the residual vector of the Arnoldi/Lanczos factorization) corrf - correction factor for residual estimates (only in harmonic KS) Output Parameters: kout - the first index where the convergence test failed */ PetscErrorCode EPSKrylovConvergence(EPS eps,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscReal corrf,PetscInt *kout) { PetscErrorCode ierr; PetscInt k,newk,marker,ld,inside; PetscScalar re,im,*Zr,*Zi,*X; PetscReal resnorm; PetscBool isshift,refined,istrivial; Vec x,y,w[3]; PetscFunctionBegin; ierr = RGIsTrivial(eps->rg,&istrivial);CHKERRQ(ierr); if (eps->trueres) { ierr = BVCreateVec(eps->V,&x);CHKERRQ(ierr); ierr = BVCreateVec(eps->V,&y);CHKERRQ(ierr); ierr = BVCreateVec(eps->V,&w[0]);CHKERRQ(ierr); ierr = BVCreateVec(eps->V,&w[2]);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = BVCreateVec(eps->V,&w[1]);CHKERRQ(ierr); #else w[1] = NULL; #endif } ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = DSGetRefined(eps->ds,&refined);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->st,STSHIFT,&isshift);CHKERRQ(ierr); marker = -1; if (eps->trackall) getall = PETSC_TRUE; for (k=kini;keigr[k]; im = eps->eigi[k]; if (!istrivial || eps->trueres || isshift || eps->conv==EPS_CONV_NORM) { ierr = STBackTransform(eps->st,1,&re,&im);CHKERRQ(ierr); } if (!istrivial) { ierr = RGCheckInside(eps->rg,1,&re,&im,&inside);CHKERRQ(ierr); if (marker==-1 && inside<0) marker = k; if (!(eps->trueres || isshift || eps->conv==EPS_CONV_NORM)) { /* make sure eps->converged below uses the right value */ re = eps->eigr[k]; im = eps->eigi[k]; } } newk = k; ierr = DSVectors(eps->ds,DS_MAT_X,&newk,&resnorm);CHKERRQ(ierr); if (eps->trueres) { ierr = DSGetArray(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); Zr = X+k*ld; if (newk==k+1) Zi = X+newk*ld; else Zi = NULL; ierr = EPSComputeRitzVector(eps,Zr,Zi,eps->V,x,y);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = EPSComputeResidualNorm_Private(eps,re,im,x,y,w,&resnorm);CHKERRQ(ierr); } else if (!refined) resnorm *= beta*corrf; /* error estimate */ ierr = (*eps->converged)(eps,re,im,resnorm,&eps->errest[k],eps->convergedctx);CHKERRQ(ierr); if (marker==-1 && eps->errest[k] >= eps->tol) marker = k; if (newk==k+1) { eps->errest[k+1] = eps->errest[k]; k++; } if (marker!=-1 && !getall) break; } if (marker!=-1) k = marker; *kout = k; if (eps->trueres) { ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&y);CHKERRQ(ierr); ierr = VecDestroy(&w[0]);CHKERRQ(ierr); ierr = VecDestroy(&w[2]);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = VecDestroy(&w[1]);CHKERRQ(ierr); #endif } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSFullLanczos" /* EPSFullLanczos - Computes an m-step Lanczos factorization with full reorthogonalization. At each Lanczos step, the corresponding Lanczos vector is orthogonalized with respect to all previous Lanczos vectors. This is equivalent to computing an m-step Arnoldi factorization and exploting symmetry of the operator. The first k columns are assumed to be locked and therefore they are not modified. On exit, the following relation is satisfied: OP * V - V * T = beta_m*v_m * e_m^T where the columns of V are the Lanczos vectors (which are B-orthonormal), T is a real symmetric tridiagonal matrix, and e_m is the m-th vector of the canonical basis. The tridiagonal is stored as two arrays: alpha contains the diagonal elements, beta the off-diagonal. On exit, the last element of beta contains the B-norm of V[m] before normalization. */ PetscErrorCode EPSFullLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown) { PetscErrorCode ierr; PetscInt j,m = *M; Vec vj,vj1; PetscScalar *hwork,lhwork[100]; PetscFunctionBegin; if (m > 100) { ierr = PetscMalloc1(m,&hwork);CHKERRQ(ierr); } else hwork = lhwork; ierr = BVSetActiveColumns(eps->V,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,j+1,hwork,beta+j,breakdown);CHKERRQ(ierr); alpha[j] = PetscRealPart(hwork[j]); if (*breakdown) { *M = j+1; break; } else { ierr = BVScaleColumn(eps->V,j+1,1.0/beta[j]);CHKERRQ(ierr); } } if (m > 100) { ierr = PetscFree(hwork);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSPseudoLanczos" PetscErrorCode EPSPseudoLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscReal *cos,Vec w) { PetscErrorCode ierr; PetscInt j,m = *M,i,ld,l; Vec vj,vj1; PetscScalar *hwork,lhwork[100]; PetscReal norm,norm1,norm2,t,*f,sym=0.0,fro=0.0; PetscBLASInt j_,one=1; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = DSGetDimensions(eps->ds,NULL,NULL,&l,NULL,NULL);CHKERRQ(ierr); if (cos) *cos = 1.0; if (m > 100) { ierr = PetscMalloc1(m,&hwork);CHKERRQ(ierr); } else hwork = lhwork; ierr = BVSetActiveColumns(eps->V,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,j+1,hwork,&norm,breakdown);CHKERRQ(ierr); alpha[j] = PetscRealPart(hwork[j]); beta[j] = PetscAbsReal(norm); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&f);CHKERRQ(ierr); if (j==k) { for (i=l;ids,DS_MAT_T,&f);CHKERRQ(ierr); hwork[j-1] -= beta[j-1]; ierr = PetscBLASIntCast(j,&j_);CHKERRQ(ierr); sym = SlepcAbs(BLASnrm2_(&j_,hwork,&one),sym); fro = SlepcAbs(fro,SlepcAbs(alpha[j],beta[j])); if (j>0) fro = SlepcAbs(fro,beta[j-1]); if (sym/fro>PetscMax(PETSC_SQRT_MACHINE_EPSILON,10*eps->tol)) { *symmlost = PETSC_TRUE; *M=j+1; break; } omega[j+1] = (norm<0.0)? -1.0: 1.0; ierr = BVScaleColumn(eps->V,j+1,1.0/norm);CHKERRQ(ierr); /* */ if (cos) { ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = VecNorm(vj1,NORM_2,&norm1);CHKERRQ(ierr); ierr = BVApplyMatrix(eps->V,vj1,w);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = VecNorm(w,NORM_2,&norm2);CHKERRQ(ierr); t = 1.0/(norm1*norm2); if (*cos>t) *cos = t; } } if (m > 100) { ierr = PetscFree(hwork);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/krylov/makefile.html0000644000175000017500000000471713107004621020667 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = epskrylov.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     = arnoldi lanczos krylovschur
LOCDIR   = src/eps/impls/krylov/
MANSEC   = EPS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/krylov/arnoldi/0000755000175000017500000000000013107004621017643 5ustar jromanjromanslepc-3.7.4/src/eps/impls/krylov/arnoldi/makefile0000644000175000017500000000216713107004621021351 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = arnoldi.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/krylov/arnoldi/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/krylov/arnoldi/arnoldi.c0000644000175000017500000002646513107004621021454 0ustar jromanjroman/* SLEPc eigensolver: "arnoldi" Method: Explicitly Restarted Arnoldi Algorithm: Arnoldi method with explicit restart and deflation. References: [1] "Arnoldi Methods in SLEPc", SLEPc Technical Report STR-4, available at http://slepc.upv.es. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ PetscErrorCode EPSSolve_Arnoldi(EPS); typedef struct { PetscBool delayed; } EPS_ARNOLDI; #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_Arnoldi" PetscErrorCode EPSSetUp_Arnoldi(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); if (eps->ncv>eps->nev+eps->mpd) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must not be larger than nev+mpd"); if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv); if (!eps->which) { ierr = EPSSetWhichEigenpairs_Default(eps);CHKERRQ(ierr); } if (eps->ishermitian && eps->ispositive && (eps->which==EPS_LARGEST_IMAGINARY || eps->which==EPS_SMALLEST_IMAGINARY)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (!eps->extraction) { ierr = EPSSetExtraction(eps,EPS_RITZ);CHKERRQ(ierr); } if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); ierr = EPSAllocateSolution(eps,1);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); ierr = DSSetType(eps->ds,DSNHEP);CHKERRQ(ierr); if (eps->extraction==EPS_REFINED || eps->extraction==EPS_REFINED_HARMONIC) { ierr = DSSetRefined(eps->ds,PETSC_TRUE);CHKERRQ(ierr); } ierr = DSSetExtraRow(eps->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,eps->ncv+1);CHKERRQ(ierr); /* dispatch solve method */ if (eps->isgeneralized && eps->ishermitian && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method does not work for indefinite problems"); eps->ops->solve = EPSSolve_Arnoldi; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_Arnoldi" PetscErrorCode EPSSolve_Arnoldi(EPS eps) { PetscErrorCode ierr; PetscInt k,nv,ld; Mat U; PetscScalar *H,*X; PetscReal beta,gamma=1.0; PetscBool breakdown,harmonic,refined; BVOrthogRefineType orthog_ref; EPS_ARNOLDI *arnoldi = (EPS_ARNOLDI*)eps->data; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = DSGetRefined(eps->ds,&refined);CHKERRQ(ierr); harmonic = (eps->extraction==EPS_HARMONIC || eps->extraction==EPS_REFINED_HARMONIC)?PETSC_TRUE:PETSC_FALSE; ierr = BVGetOrthogonalization(eps->V,NULL,&orthog_ref,NULL,NULL);CHKERRQ(ierr); /* Get the starting Arnoldi vector */ ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); /* Restart loop */ while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; /* Compute an nv-step Arnoldi factorization */ nv = PetscMin(eps->nconv+eps->mpd,eps->ncv); ierr = DSSetDimensions(eps->ds,nv,0,eps->nconv,0);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_A,&H);CHKERRQ(ierr); if (!arnoldi->delayed) { ierr = EPSBasicArnoldi(eps,PETSC_FALSE,H,ld,eps->nconv,&nv,&beta,&breakdown);CHKERRQ(ierr); } else if (orthog_ref == BV_ORTHOG_REFINE_NEVER) { ierr = EPSDelayedArnoldi1(eps,H,ld,eps->nconv,&nv,&beta,&breakdown);CHKERRQ(ierr); } else { ierr = EPSDelayedArnoldi(eps,H,ld,eps->nconv,&nv,&beta,&breakdown);CHKERRQ(ierr); } ierr = DSRestoreArray(eps->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,eps->nconv,nv);CHKERRQ(ierr); /* Compute translation of Krylov decomposition if harmonic extraction used */ if (harmonic) { ierr = DSTranslateHarmonic(eps->ds,eps->target,beta,PETSC_FALSE,NULL,&gamma);CHKERRQ(ierr); } /* Solve projected problem */ ierr = DSSolve(eps->ds,eps->eigr,eps->eigi);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSUpdateExtraRow(eps->ds);CHKERRQ(ierr); /* Check convergence */ ierr = EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,nv-eps->nconv,beta,gamma,&k);CHKERRQ(ierr); if (refined) { ierr = DSGetArray(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVMultColumn(eps->V,1.0,0.0,k,X+k*ld);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,eps->nconv,nv);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(eps->V,k,NULL,NULL,NULL);CHKERRQ(ierr); } else { ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,eps->nconv,nv);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); } ierr = (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); if (eps->reason == EPS_CONVERGED_ITERATING && breakdown) { ierr = PetscInfo2(eps,"Breakdown in Arnoldi method (it=%D norm=%g)\n",eps->its,(double)beta);CHKERRQ(ierr); ierr = EPSGetStartVector(eps,k,&breakdown);CHKERRQ(ierr); if (breakdown) { eps->reason = EPS_DIVERGED_BREAKDOWN; ierr = PetscInfo(eps,"Unable to generate more start vectors\n");CHKERRQ(ierr); } } eps->nconv = k; ierr = EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,nv);CHKERRQ(ierr); } /* truncate Schur decomposition and change the state to raw so that DSVectors() computes eigenvectors from scratch */ ierr = DSSetDimensions(eps->ds,eps->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_Arnoldi" PetscErrorCode EPSSetFromOptions_Arnoldi(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; PetscBool set,val; EPS_ARNOLDI *arnoldi = (EPS_ARNOLDI*)eps->data; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS Arnoldi Options");CHKERRQ(ierr); ierr = PetscOptionsBool("-eps_arnoldi_delayed","Arnoldi with delayed reorthogonalization","EPSArnoldiSetDelayed",arnoldi->delayed,&val,&set);CHKERRQ(ierr); if (set) { ierr = EPSArnoldiSetDelayed(eps,val);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSArnoldiSetDelayed_Arnoldi" static PetscErrorCode EPSArnoldiSetDelayed_Arnoldi(EPS eps,PetscBool delayed) { EPS_ARNOLDI *arnoldi = (EPS_ARNOLDI*)eps->data; PetscFunctionBegin; arnoldi->delayed = delayed; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSArnoldiSetDelayed" /*@ EPSArnoldiSetDelayed - Activates or deactivates delayed reorthogonalization in the Arnoldi iteration. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - delayed - boolean flag Options Database Key: . -eps_arnoldi_delayed - Activates delayed reorthogonalization in Arnoldi Note: Delayed reorthogonalization is an aggressive optimization for the Arnoldi eigensolver than may provide better scalability, but sometimes makes the solver converge less than the default algorithm. Level: advanced .seealso: EPSArnoldiGetDelayed() @*/ PetscErrorCode EPSArnoldiSetDelayed(EPS eps,PetscBool delayed) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,delayed,2); ierr = PetscTryMethod(eps,"EPSArnoldiSetDelayed_C",(EPS,PetscBool),(eps,delayed));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSArnoldiGetDelayed_Arnoldi" static PetscErrorCode EPSArnoldiGetDelayed_Arnoldi(EPS eps,PetscBool *delayed) { EPS_ARNOLDI *arnoldi = (EPS_ARNOLDI*)eps->data; PetscFunctionBegin; *delayed = arnoldi->delayed; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSArnoldiGetDelayed" /*@ EPSArnoldiGetDelayed - Gets the type of reorthogonalization used during the Arnoldi iteration. Not Collective Input Parameter: . eps - the eigenproblem solver context Input Parameter: . delayed - boolean flag indicating if delayed reorthogonalization has been enabled Level: advanced .seealso: EPSArnoldiSetDelayed() @*/ PetscErrorCode EPSArnoldiGetDelayed(EPS eps,PetscBool *delayed) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(delayed,2); ierr = PetscUseMethod(eps,"EPSArnoldiGetDelayed_C",(EPS,PetscBool*),(eps,delayed));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_Arnoldi" PetscErrorCode EPSDestroy_Arnoldi(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiSetDelayed_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiGetDelayed_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_Arnoldi" PetscErrorCode EPSView_Arnoldi(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii; EPS_ARNOLDI *arnoldi = (EPS_ARNOLDI*)eps->data; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (arnoldi->delayed) { ierr = PetscViewerASCIIPrintf(viewer," Arnoldi: using delayed reorthogonalization\n");CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_Arnoldi" PETSC_EXTERN PetscErrorCode EPSCreate_Arnoldi(EPS eps) { EPS_ARNOLDI *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; eps->ops->setup = EPSSetUp_Arnoldi; eps->ops->setfromoptions = EPSSetFromOptions_Arnoldi; eps->ops->destroy = EPSDestroy_Arnoldi; eps->ops->view = EPSView_Arnoldi; eps->ops->backtransform = EPSBackTransform_Default; eps->ops->computevectors = EPSComputeVectors_Schur; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiSetDelayed_C",EPSArnoldiSetDelayed_Arnoldi);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiGetDelayed_C",EPSArnoldiGetDelayed_Arnoldi);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/krylov/arnoldi/arnoldi.c.html0000644000175000017500000006000113107004621022377 0ustar jromanjroman
Actual source code: arnoldi.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "arnoldi"

  5:    Method: Explicitly Restarted Arnoldi

  7:    Algorithm:

  9:        Arnoldi method with explicit restart and deflation.

 11:    References:

 13:        [1] "Arnoldi Methods in SLEPc", SLEPc Technical Report STR-4,
 14:            available at http://slepc.upv.es.

 16:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 17:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 18:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 20:    This file is part of SLEPc.

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

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

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

 36: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/

 38: PetscErrorCode EPSSolve_Arnoldi(EPS);

 40: typedef struct {
 41:   PetscBool delayed;
 42: } EPS_ARNOLDI;

 46: PetscErrorCode EPSSetUp_Arnoldi(EPS eps)
 47: {

 51:   EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);
 52:   if (eps->ncv>eps->nev+eps->mpd) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must not be larger than nev+mpd");
 53:   if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv);
 54:   if (!eps->which) { EPSSetWhichEigenpairs_Default(eps); }
 55:   if (eps->ishermitian && eps->ispositive && (eps->which==EPS_LARGEST_IMAGINARY || eps->which==EPS_SMALLEST_IMAGINARY)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");

 57:   if (!eps->extraction) {
 58:     EPSSetExtraction(eps,EPS_RITZ);
 59:   }
 60:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");

 62:   EPSAllocateSolution(eps,1);
 63:   EPS_SetInnerProduct(eps);
 64:   DSSetType(eps->ds,DSNHEP);
 65:   if (eps->extraction==EPS_REFINED || eps->extraction==EPS_REFINED_HARMONIC) {
 66:     DSSetRefined(eps->ds,PETSC_TRUE);
 67:   }
 68:   DSSetExtraRow(eps->ds,PETSC_TRUE);
 69:   DSAllocate(eps->ds,eps->ncv+1);

 71:   /* dispatch solve method */
 72:   if (eps->isgeneralized && eps->ishermitian && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method does not work for indefinite problems");
 73:   eps->ops->solve = EPSSolve_Arnoldi;
 74:   return(0);
 75: }

 79: PetscErrorCode EPSSolve_Arnoldi(EPS eps)
 80: {
 81:   PetscErrorCode     ierr;
 82:   PetscInt           k,nv,ld;
 83:   Mat                U;
 84:   PetscScalar        *H,*X;
 85:   PetscReal          beta,gamma=1.0;
 86:   PetscBool          breakdown,harmonic,refined;
 87:   BVOrthogRefineType orthog_ref;
 88:   EPS_ARNOLDI        *arnoldi = (EPS_ARNOLDI*)eps->data;

 91:   DSGetLeadingDimension(eps->ds,&ld);
 92:   DSGetRefined(eps->ds,&refined);
 93:   harmonic = (eps->extraction==EPS_HARMONIC || eps->extraction==EPS_REFINED_HARMONIC)?PETSC_TRUE:PETSC_FALSE;
 94:   BVGetOrthogonalization(eps->V,NULL,&orthog_ref,NULL,NULL);

 96:   /* Get the starting Arnoldi vector */
 97:   EPSGetStartVector(eps,0,NULL);

 99:   /* Restart loop */
100:   while (eps->reason == EPS_CONVERGED_ITERATING) {
101:     eps->its++;

103:     /* Compute an nv-step Arnoldi factorization */
104:     nv = PetscMin(eps->nconv+eps->mpd,eps->ncv);
105:     DSSetDimensions(eps->ds,nv,0,eps->nconv,0);
106:     DSGetArray(eps->ds,DS_MAT_A,&H);
107:     if (!arnoldi->delayed) {
108:       EPSBasicArnoldi(eps,PETSC_FALSE,H,ld,eps->nconv,&nv,&beta,&breakdown);
109:     } else if (orthog_ref == BV_ORTHOG_REFINE_NEVER) {
110:       EPSDelayedArnoldi1(eps,H,ld,eps->nconv,&nv,&beta,&breakdown);
111:     } else {
112:       EPSDelayedArnoldi(eps,H,ld,eps->nconv,&nv,&beta,&breakdown);
113:     }
114:     DSRestoreArray(eps->ds,DS_MAT_A,&H);
115:     DSSetState(eps->ds,DS_STATE_INTERMEDIATE);
116:     BVSetActiveColumns(eps->V,eps->nconv,nv);

118:     /* Compute translation of Krylov decomposition if harmonic extraction used */
119:     if (harmonic) {
120:       DSTranslateHarmonic(eps->ds,eps->target,beta,PETSC_FALSE,NULL,&gamma);
121:     }

123:     /* Solve projected problem */
124:     DSSolve(eps->ds,eps->eigr,eps->eigi);
125:     DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);
126:     DSUpdateExtraRow(eps->ds);

128:     /* Check convergence */
129:     EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,nv-eps->nconv,beta,gamma,&k);
130:     if (refined) {
131:       DSGetArray(eps->ds,DS_MAT_X,&X);
132:       BVMultColumn(eps->V,1.0,0.0,k,X+k*ld);
133:       DSRestoreArray(eps->ds,DS_MAT_X,&X);
134:       DSGetMat(eps->ds,DS_MAT_Q,&U);
135:       BVMultInPlace(eps->V,U,eps->nconv,nv);
136:       MatDestroy(&U);
137:       BVOrthogonalizeColumn(eps->V,k,NULL,NULL,NULL);
138:     } else {
139:       DSGetMat(eps->ds,DS_MAT_Q,&U);
140:       BVMultInPlace(eps->V,U,eps->nconv,nv);
141:       MatDestroy(&U);
142:     }
143:     (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);
144:     if (eps->reason == EPS_CONVERGED_ITERATING && breakdown) {
145:       PetscInfo2(eps,"Breakdown in Arnoldi method (it=%D norm=%g)\n",eps->its,(double)beta);
146:       EPSGetStartVector(eps,k,&breakdown);
147:       if (breakdown) {
148:         eps->reason = EPS_DIVERGED_BREAKDOWN;
149:         PetscInfo(eps,"Unable to generate more start vectors\n");
150:       }
151:     }
152:     eps->nconv = k;
153:     EPSMonitor(eps,eps->its,eps->nconv,eps->eigr,eps->eigi,eps->errest,nv);
154:   }

156:   /* truncate Schur decomposition and change the state to raw so that
157:      DSVectors() computes eigenvectors from scratch */
158:   DSSetDimensions(eps->ds,eps->nconv,0,0,0);
159:   DSSetState(eps->ds,DS_STATE_RAW);
160:   return(0);
161: }

165: PetscErrorCode EPSSetFromOptions_Arnoldi(PetscOptionItems *PetscOptionsObject,EPS eps)
166: {
168:   PetscBool      set,val;
169:   EPS_ARNOLDI    *arnoldi = (EPS_ARNOLDI*)eps->data;

172:   PetscOptionsHead(PetscOptionsObject,"EPS Arnoldi Options");
173:   PetscOptionsBool("-eps_arnoldi_delayed","Arnoldi with delayed reorthogonalization","EPSArnoldiSetDelayed",arnoldi->delayed,&val,&set);
174:   if (set) {
175:     EPSArnoldiSetDelayed(eps,val);
176:   }
177:   PetscOptionsTail();
178:   return(0);
179: }

183: static PetscErrorCode EPSArnoldiSetDelayed_Arnoldi(EPS eps,PetscBool delayed)
184: {
185:   EPS_ARNOLDI *arnoldi = (EPS_ARNOLDI*)eps->data;

188:   arnoldi->delayed = delayed;
189:   return(0);
190: }

194: /*@
195:    EPSArnoldiSetDelayed - Activates or deactivates delayed reorthogonalization
196:    in the Arnoldi iteration.

198:    Logically Collective on EPS

200:    Input Parameters:
201: +  eps - the eigenproblem solver context
202: -  delayed - boolean flag

204:    Options Database Key:
205: .  -eps_arnoldi_delayed - Activates delayed reorthogonalization in Arnoldi

207:    Note:
208:    Delayed reorthogonalization is an aggressive optimization for the Arnoldi
209:    eigensolver than may provide better scalability, but sometimes makes the
210:    solver converge less than the default algorithm.

212:    Level: advanced

214: .seealso: EPSArnoldiGetDelayed()
215: @*/
216: PetscErrorCode EPSArnoldiSetDelayed(EPS eps,PetscBool delayed)
217: {

223:   PetscTryMethod(eps,"EPSArnoldiSetDelayed_C",(EPS,PetscBool),(eps,delayed));
224:   return(0);
225: }

229: static PetscErrorCode EPSArnoldiGetDelayed_Arnoldi(EPS eps,PetscBool *delayed)
230: {
231:   EPS_ARNOLDI *arnoldi = (EPS_ARNOLDI*)eps->data;

234:   *delayed = arnoldi->delayed;
235:   return(0);
236: }

240: /*@
241:    EPSArnoldiGetDelayed - Gets the type of reorthogonalization used during the Arnoldi
242:    iteration.

244:    Not Collective

246:    Input Parameter:
247: .  eps - the eigenproblem solver context

249:    Input Parameter:
250: .  delayed - boolean flag indicating if delayed reorthogonalization has been enabled

252:    Level: advanced

254: .seealso: EPSArnoldiSetDelayed()
255: @*/
256: PetscErrorCode EPSArnoldiGetDelayed(EPS eps,PetscBool *delayed)
257: {

263:   PetscUseMethod(eps,"EPSArnoldiGetDelayed_C",(EPS,PetscBool*),(eps,delayed));
264:   return(0);
265: }

269: PetscErrorCode EPSDestroy_Arnoldi(EPS eps)
270: {

274:   PetscFree(eps->data);
275:   PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiSetDelayed_C",NULL);
276:   PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiGetDelayed_C",NULL);
277:   return(0);
278: }

282: PetscErrorCode EPSView_Arnoldi(EPS eps,PetscViewer viewer)
283: {
285:   PetscBool      isascii;
286:   EPS_ARNOLDI    *arnoldi = (EPS_ARNOLDI*)eps->data;

289:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
290:   if (isascii) {
291:     if (arnoldi->delayed) {
292:       PetscViewerASCIIPrintf(viewer,"  Arnoldi: using delayed reorthogonalization\n");
293:     }
294:   }
295:   return(0);
296: }

300: PETSC_EXTERN PetscErrorCode EPSCreate_Arnoldi(EPS eps)
301: {
302:   EPS_ARNOLDI    *ctx;

306:   PetscNewLog(eps,&ctx);
307:   eps->data = (void*)ctx;

309:   eps->ops->setup                = EPSSetUp_Arnoldi;
310:   eps->ops->setfromoptions       = EPSSetFromOptions_Arnoldi;
311:   eps->ops->destroy              = EPSDestroy_Arnoldi;
312:   eps->ops->view                 = EPSView_Arnoldi;
313:   eps->ops->backtransform        = EPSBackTransform_Default;
314:   eps->ops->computevectors       = EPSComputeVectors_Schur;
315:   PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiSetDelayed_C",EPSArnoldiSetDelayed_Arnoldi);
316:   PetscObjectComposeFunction((PetscObject)eps,"EPSArnoldiGetDelayed_C",EPSArnoldiGetDelayed_Arnoldi);
317:   return(0);
318: }

slepc-3.7.4/src/eps/impls/krylov/arnoldi/makefile.html0000644000175000017500000000471113107004621022311 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = arnoldi.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/krylov/arnoldi/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/krylov/arnoldi/index.html0000644000175000017500000000262213107004621021642 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

arnoldi.c
makefile
slepc-3.7.4/src/eps/impls/krylov/arnoldi/ftn-auto/0000755000175000017500000000000013107004621021400 5ustar jromanjromanslepc-3.7.4/src/eps/impls/krylov/arnoldi/ftn-auto/makefile0000644000175000017500000000037213107004621023102 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = arnoldif.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/krylov/arnoldi/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/krylov/arnoldi/ftn-auto/arnoldif.c0000644000175000017500000000276413107004621023353 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* arnoldi.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsarnoldisetdelayed_ EPSARNOLDISETDELAYED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsarnoldisetdelayed_ epsarnoldisetdelayed #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epsarnoldigetdelayed_ EPSARNOLDIGETDELAYED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epsarnoldigetdelayed_ epsarnoldigetdelayed #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epsarnoldisetdelayed_(EPS eps,PetscBool *delayed, int *__ierr ){ *__ierr = EPSArnoldiSetDelayed( (EPS)PetscToPointer((eps) ),*delayed); } PETSC_EXTERN void PETSC_STDCALL epsarnoldigetdelayed_(EPS eps,PetscBool *delayed, int *__ierr ){ *__ierr = EPSArnoldiGetDelayed( (EPS)PetscToPointer((eps) ),delayed); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/krylov/lanczos/0000755000175000017500000000000013107004621017664 5ustar jromanjromanslepc-3.7.4/src/eps/impls/krylov/lanczos/makefile0000644000175000017500000000216713107004621021372 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = lanczos.c SOURCEF = SOURCEH = LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/krylov/lanczos/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/krylov/lanczos/makefile.html0000644000175000017500000000471113107004621022332 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = lanczos.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/krylov/lanczos/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/krylov/lanczos/lanczos.c.html0000644000175000017500000021307513107004621022454 0ustar jromanjroman
Actual source code: lanczos.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "lanczos"

  5:    Method: Explicitly Restarted Symmetric/Hermitian Lanczos

  7:    Algorithm:

  9:        Lanczos method for symmetric (Hermitian) problems, with explicit
 10:        restart and deflation. Several reorthogonalization strategies can
 11:        be selected.

 13:    References:

 15:        [1] "Lanczos Methods in SLEPc", SLEPc Technical Report STR-5,
 16:            available at http://slepc.upv.es.

 18:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 20:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 22:    This file is part of SLEPc.

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

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

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

 38: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
 39: #include <slepcblaslapack.h>

 41: PetscErrorCode EPSSolve_Lanczos(EPS);

 43: typedef struct {
 44:   EPSLanczosReorthogType reorthog;
 45:   BV                     AV;
 46: } EPS_LANCZOS;

 50: PetscErrorCode EPSSetUp_Lanczos(EPS eps)
 51: {
 52:   EPS_LANCZOS        *lanczos = (EPS_LANCZOS*)eps->data;
 53:   BVOrthogRefineType refine;
 54:   BVOrthogBlockType  btype;
 55:   PetscReal          eta;
 56:   PetscErrorCode     ierr;

 59:   EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);
 60:   if (eps->ncv>eps->nev+eps->mpd) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must not be larger than nev+mpd");
 61:   if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv);
 62:   if (!eps->which) { EPSSetWhichEigenpairs_Default(eps); }
 63:   switch (eps->which) {
 64:     case EPS_LARGEST_IMAGINARY:
 65:     case EPS_SMALLEST_IMAGINARY:
 66:     case EPS_TARGET_IMAGINARY:
 67:       SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");
 68:     default: ; /* default case to remove warning */
 69:   }
 70:   if (!eps->extraction) {
 71:     EPSSetExtraction(eps,EPS_RITZ);
 72:   } else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
 73:   if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver");

 75:   EPSAllocateSolution(eps,1);
 76:   EPS_SetInnerProduct(eps);
 77:   if (lanczos->reorthog != EPS_LANCZOS_REORTHOG_FULL) {
 78:     BVGetOrthogonalization(eps->V,NULL,&refine,&eta,&btype);
 79:     BVSetOrthogonalization(eps->V,BV_ORTHOG_MGS,refine,eta,btype);
 80:     PetscInfo(eps,"Switching to MGS orthogonalization\n");
 81:   }
 82:   if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_SELECTIVE) {
 83:     BVDuplicate(eps->V,&lanczos->AV);
 84:   }

 86:   DSSetType(eps->ds,DSHEP);
 87:   DSSetCompact(eps->ds,PETSC_TRUE);
 88:   DSAllocate(eps->ds,eps->ncv+1);
 89:   if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL) {
 90:     EPSSetWorkVecs(eps,1);
 91:   }

 93:   /* dispatch solve method */
 94:   if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems");
 95:   if (eps->isgeneralized && eps->ishermitian && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method does not work for indefinite problems");
 96:   eps->ops->solve = EPSSolve_Lanczos;
 97:   return(0);
 98: }

102: /*
103:    EPSLocalLanczos - Local reorthogonalization.

105:    This is the simplest variant. At each Lanczos step, the corresponding Lanczos vector
106:    is orthogonalized with respect to the two previous Lanczos vectors, according to
107:    the three term Lanczos recurrence. WARNING: This variant does not track the loss of
108:    orthogonality that occurs in finite-precision arithmetic and, therefore, the
109:    generated vectors are not guaranteed to be (semi-)orthogonal.
110: */
111: static PetscErrorCode EPSLocalLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown)
112: {
114:   PetscInt       i,j,m = *M;
115:   Vec            vj,vj1;
116:   PetscBool      *which,lwhich[100];
117:   PetscScalar    *hwork,lhwork[100];

120:   if (m > 100) {
121:     PetscMalloc2(m,&which,m,&hwork);
122:   } else {
123:     which = lwhich;
124:     hwork = lhwork;
125:   }
126:   for (i=0;i<k;i++) which[i] = PETSC_TRUE;

128:   BVSetActiveColumns(eps->V,0,m);
129:   for (j=k;j<m;j++) {
130:     BVGetColumn(eps->V,j,&vj);
131:     BVGetColumn(eps->V,j+1,&vj1);
132:     STApply(eps->st,vj,vj1);
133:     BVRestoreColumn(eps->V,j,&vj);
134:     BVRestoreColumn(eps->V,j+1,&vj1);
135:     which[j] = PETSC_TRUE;
136:     if (j-2>=k) which[j-2] = PETSC_FALSE;
137:     BVOrthogonalizeSomeColumn(eps->V,j+1,which,hwork,beta+j,breakdown);
138:     alpha[j] = PetscRealPart(hwork[j]);
139:     if (*breakdown) {
140:       *M = j+1;
141:       break;
142:     } else {
143:       BVScaleColumn(eps->V,j+1,1/beta[j]);
144:     }
145:   }
146:   if (m > 100) {
147:     PetscFree2(which,hwork);
148:   }
149:   return(0);
150: }

154: /*
155:    DenseTridiagonal - Solves a real tridiagonal Hermitian Eigenvalue Problem.

157:    Input Parameters:
158: +  n   - dimension of the eigenproblem
159: .  D   - pointer to the array containing the diagonal elements
160: -  E   - pointer to the array containing the off-diagonal elements

162:    Output Parameters:
163: +  w  - pointer to the array to store the computed eigenvalues
164: -  V  - pointer to the array to store the eigenvectors

166:    Notes:
167:    If V is NULL then the eigenvectors are not computed.

169:    This routine use LAPACK routines xSTEVR.
170: */
171: static PetscErrorCode DenseTridiagonal(PetscInt n_,PetscReal *D,PetscReal *E,PetscReal *w,PetscScalar *V)
172: {
173: #if defined(SLEPC_MISSING_LAPACK_STEVR)
175:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STEVR - Lapack routine is unavailable");
176: #else
178:   PetscReal      abstol = 0.0,vl,vu,*work;
179:   PetscBLASInt   il,iu,m,*isuppz,n,lwork,*iwork,liwork,info;
180:   const char     *jobz;
181: #if defined(PETSC_USE_COMPLEX)
182:   PetscInt       i,j;
183:   PetscReal      *VV;
184: #endif

187:   PetscBLASIntCast(n_,&n);
188:   PetscBLASIntCast(20*n_,&lwork);
189:   PetscBLASIntCast(10*n_,&liwork);
190:   if (V) {
191:     jobz = "V";
192: #if defined(PETSC_USE_COMPLEX)
193:     PetscMalloc1(n*n,&VV);
194: #endif
195:   } else jobz = "N";
196:   PetscMalloc3(2*n,&isuppz,lwork,&work,liwork,&iwork);
197:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
198: #if defined(PETSC_USE_COMPLEX)
199:   PetscStackCallBLAS("LAPACKstevr",LAPACKstevr_(jobz,"A",&n,D,E,&vl,&vu,&il,&iu,&abstol,&m,w,VV,&n,isuppz,work,&lwork,iwork,&liwork,&info));
200: #else
201:   PetscStackCallBLAS("LAPACKstevr",LAPACKstevr_(jobz,"A",&n,D,E,&vl,&vu,&il,&iu,&abstol,&m,w,V,&n,isuppz,work,&lwork,iwork,&liwork,&info));
202: #endif
203:   PetscFPTrapPop();
204:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DSTEVR %d",info);
205: #if defined(PETSC_USE_COMPLEX)
206:   if (V) {
207:     for (i=0;i<n;i++)
208:       for (j=0;j<n;j++)
209:         V[i*n+j] = VV[i*n+j];
210:     PetscFree(VV);
211:   }
212: #endif
213:   PetscFree3(isuppz,work,iwork);
214:   return(0);
215: #endif
216: }

220: /*
221:    EPSSelectiveLanczos - Selective reorthogonalization.
222: */
223: static PetscErrorCode EPSSelectiveLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscReal anorm)
224: {
226:   EPS_LANCZOS    *lanczos = (EPS_LANCZOS*)eps->data;
227:   PetscInt       i,j,m = *M,n,nritz=0,nritzo;
228:   Vec            vj,vj1,av;
229:   PetscReal      *d,*e,*ritz,norm;
230:   PetscScalar    *Y,*hwork;
231:   PetscBool      *which;

234:   PetscCalloc6(m+1,&d,m,&e,m,&ritz,m*m,&Y,m,&which,m,&hwork);
235:   for (i=0;i<k;i++) which[i] = PETSC_TRUE;

237:   for (j=k;j<m;j++) {
238:     BVSetActiveColumns(eps->V,0,m);

240:     /* Lanczos step */
241:     BVGetColumn(eps->V,j,&vj);
242:     BVGetColumn(eps->V,j+1,&vj1);
243:     STApply(eps->st,vj,vj1);
244:     BVRestoreColumn(eps->V,j,&vj);
245:     BVRestoreColumn(eps->V,j+1,&vj1);
246:     which[j] = PETSC_TRUE;
247:     if (j-2>=k) which[j-2] = PETSC_FALSE;
248:     BVOrthogonalizeSomeColumn(eps->V,j+1,which,hwork,&norm,breakdown);
249:     alpha[j] = PetscRealPart(hwork[j]);
250:     beta[j] = norm;
251:     if (*breakdown) {
252:       *M = j+1;
253:       break;
254:     }

256:     /* Compute eigenvalues and eigenvectors Y of the tridiagonal block */
257:     n = j-k+1;
258:     for (i=0;i<n;i++) {
259:       d[i] = alpha[i+k];
260:       e[i] = beta[i+k];
261:     }
262:     DenseTridiagonal(n,d,e,ritz,Y);

264:     /* Estimate ||A|| */
265:     for (i=0;i<n;i++)
266:       if (PetscAbsReal(ritz[i]) > anorm) anorm = PetscAbsReal(ritz[i]);

268:     /* Compute nearly converged Ritz vectors */
269:     nritzo = 0;
270:     for (i=0;i<n;i++) {
271:       if (norm*PetscAbsScalar(Y[i*n+n-1]) < PETSC_SQRT_MACHINE_EPSILON*anorm) nritzo++;
272:     }
273:     if (nritzo>nritz) {
274:       nritz = 0;
275:       for (i=0;i<n;i++) {
276:         if (norm*PetscAbsScalar(Y[i*n+n-1]) < PETSC_SQRT_MACHINE_EPSILON*anorm) {
277:           BVSetActiveColumns(eps->V,k,k+n);
278:           BVGetColumn(lanczos->AV,nritz,&av);
279:           BVMultVec(eps->V,1.0,0.0,av,Y+i*n);
280:           BVRestoreColumn(lanczos->AV,nritz,&av);
281:           nritz++;
282:         }
283:       }
284:     }
285:     if (nritz > 0) {
286:       BVGetColumn(eps->V,j+1,&vj1);
287:       BVSetActiveColumns(lanczos->AV,0,nritz);
288:       BVOrthogonalizeVec(lanczos->AV,vj1,hwork,&norm,breakdown);
289:       BVRestoreColumn(eps->V,j+1,&vj1);
290:       if (*breakdown) {
291:         *M = j+1;
292:         break;
293:       }
294:     }
295:     BVScaleColumn(eps->V,j+1,1.0/norm);
296:   }

298:   PetscFree6(d,e,ritz,Y,which,hwork);
299:   return(0);
300: }

304: static void update_omega(PetscReal *omega,PetscReal *omega_old,PetscInt j,PetscReal *alpha,PetscReal *beta,PetscReal eps1,PetscReal anorm)
305: {
306:   PetscInt  k;
307:   PetscReal T,binv;

310:   /* Estimate of contribution to roundoff errors from A*v
311:        fl(A*v) = A*v + f,
312:      where ||f|| \approx eps1*||A||.
313:      For a full matrix A, a rule-of-thumb estimate is eps1 = sqrt(n)*eps */
314:   T = eps1*anorm;
315:   binv = 1.0/beta[j+1];

317:   /* Update omega(1) using omega(0)==0 */
318:   omega_old[0]= beta[1]*omega[1] + (alpha[0]-alpha[j])*omega[0] - beta[j]*omega_old[0];
319:   if (omega_old[0] > 0) omega_old[0] = binv*(omega_old[0] + T);
320:   else omega_old[0] = binv*(omega_old[0] - T);

322:   /* Update remaining components */
323:   for (k=1;k<j-1;k++) {
324:     omega_old[k] = beta[k+1]*omega[k+1] + (alpha[k]-alpha[j])*omega[k] + beta[k]*omega[k-1] - beta[j]*omega_old[k];
325:     if (omega_old[k] > 0) omega_old[k] = binv*(omega_old[k] + T);
326:     else omega_old[k] = binv*(omega_old[k] - T);
327:   }
328:   omega_old[j-1] = binv*T;

330:   /* Swap omega and omega_old */
331:   for (k=0;k<j;k++) {
332:     omega[k] = omega_old[k];
333:     omega_old[k] = omega[k];
334:   }
335:   omega[j] = eps1;
336:   PetscFunctionReturnVoid();
337: }

341: static void compute_int(PetscBool *which,PetscReal *mu,PetscInt j,PetscReal delta,PetscReal eta)
342: {
343:   PetscInt  i,k,maxpos;
344:   PetscReal max;
345:   PetscBool found;

348:   /* initialize which */
349:   found = PETSC_FALSE;
350:   maxpos = 0;
351:   max = 0.0;
352:   for (i=0;i<j;i++) {
353:     if (PetscAbsReal(mu[i]) >= delta) {
354:       which[i] = PETSC_TRUE;
355:       found = PETSC_TRUE;
356:     } else which[i] = PETSC_FALSE;
357:     if (PetscAbsReal(mu[i]) > max) {
358:       maxpos = i;
359:       max = PetscAbsReal(mu[i]);
360:     }
361:   }
362:   if (!found) which[maxpos] = PETSC_TRUE;

364:   for (i=0;i<j;i++) {
365:     if (which[i]) {
366:       /* find left interval */
367:       for (k=i;k>=0;k--) {
368:         if (PetscAbsReal(mu[k])<eta || which[k]) break;
369:         else which[k] = PETSC_TRUE;
370:       }
371:       /* find right interval */
372:       for (k=i+1;k<j;k++) {
373:         if (PetscAbsReal(mu[k])<eta || which[k]) break;
374:         else which[k] = PETSC_TRUE;
375:       }
376:     }
377:   }
378:   PetscFunctionReturnVoid();
379: }

383: /*
384:    EPSPartialLanczos - Partial reorthogonalization.
385: */
386: static PetscErrorCode EPSPartialLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscReal anorm)
387: {
389:   EPS_LANCZOS    *lanczos = (EPS_LANCZOS*)eps->data;
390:   PetscInt       i,j,m = *M;
391:   Vec            vj,vj1;
392:   PetscReal      norm,*omega,lomega[100],*omega_old,lomega_old[100],eps1,delta,eta;
393:   PetscBool      *which,lwhich[100],*which2,lwhich2[100];
394:   PetscBool      reorth = PETSC_FALSE,force_reorth = PETSC_FALSE;
395:   PetscBool      fro = PETSC_FALSE,estimate_anorm = PETSC_FALSE;
396:   PetscScalar    *hwork,lhwork[100];

399:   if (m>100) {
400:     PetscMalloc5(m,&omega,m,&omega_old,m,&which,m,&which2,m,&hwork);
401:   } else {
402:     omega     = lomega;
403:     omega_old = lomega_old;
404:     which     = lwhich;
405:     which2    = lwhich2;
406:     hwork     = lhwork;
407:   }

409:   eps1 = PetscSqrtReal((PetscReal)eps->n)*PETSC_MACHINE_EPSILON/2;
410:   delta = PETSC_SQRT_MACHINE_EPSILON/PetscSqrtReal((PetscReal)eps->ncv);
411:   eta = PetscPowReal(PETSC_MACHINE_EPSILON,3.0/4.0)/PetscSqrtReal((PetscReal)eps->ncv);
412:   if (anorm < 0.0) {
413:     anorm = 1.0;
414:     estimate_anorm = PETSC_TRUE;
415:   }
416:   for (i=0;i<m-k;i++) omega[i] = omega_old[i] = 0.0;
417:   for (i=0;i<k;i++) which[i] = PETSC_TRUE;

419:   BVSetActiveColumns(eps->V,0,m);
420:   for (j=k;j<m;j++) {
421:     BVGetColumn(eps->V,j,&vj);
422:     BVGetColumn(eps->V,j+1,&vj1);
423:     STApply(eps->st,vj,vj1);
424:     BVRestoreColumn(eps->V,j,&vj);
425:     BVRestoreColumn(eps->V,j+1,&vj1);
426:     if (fro) {
427:       /* Lanczos step with full reorthogonalization */
428:       BVOrthogonalizeColumn(eps->V,j+1,hwork,&norm,breakdown);
429:       alpha[j] = PetscRealPart(hwork[j]);
430:     } else {
431:       /* Lanczos step */
432:       which[j] = PETSC_TRUE;
433:       if (j-2>=k) which[j-2] = PETSC_FALSE;
434:       BVOrthogonalizeSomeColumn(eps->V,j+1,which,hwork,&norm,breakdown);
435:       alpha[j] = PetscRealPart(hwork[j]);
436:       beta[j] = norm;

438:       /* Estimate ||A|| if needed */
439:       if (estimate_anorm) {
440:         if (j>k) anorm = PetscMax(anorm,PetscAbsReal(alpha[j])+norm+beta[j-1]);
441:         else anorm = PetscMax(anorm,PetscAbsReal(alpha[j])+norm);
442:       }

444:       /* Check if reorthogonalization is needed */
445:       reorth = PETSC_FALSE;
446:       if (j>k) {
447:         update_omega(omega,omega_old,j,alpha,beta-1,eps1,anorm);
448:         for (i=0;i<j-k;i++) {
449:           if (PetscAbsReal(omega[i]) > delta) reorth = PETSC_TRUE;
450:         }
451:       }
452:       if (reorth || force_reorth) {
453:         for (i=0;i<k;i++) which2[i] = PETSC_FALSE;
454:         for (i=k;i<=j;i++) which2[i] = PETSC_TRUE;
455:         if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_PERIODIC) {
456:           /* Periodic reorthogonalization */
457:           if (force_reorth) force_reorth = PETSC_FALSE;
458:           else force_reorth = PETSC_TRUE;
459:           for (i=0;i<j-k;i++) omega[i] = eps1;
460:         } else {
461:           /* Partial reorthogonalization */
462:           if (force_reorth) force_reorth = PETSC_FALSE;
463:           else {
464:             force_reorth = PETSC_TRUE;
465:             compute_int(which2+k,omega,j-k,delta,eta);
466:             for (i=0;i<j-k;i++) {
467:               if (which2[i+k]) omega[i] = eps1;
468:             }
469:           }
470:         }
471:         BVOrthogonalizeSomeColumn(eps->V,j+1,which2,hwork,&norm,breakdown);
472:       }
473:     }

475:     if (*breakdown || norm < eps->n*anorm*PETSC_MACHINE_EPSILON) {
476:       *M = j+1;
477:       break;
478:     }
479:     if (!fro && norm*delta < anorm*eps1) {
480:       fro = PETSC_TRUE;
481:       PetscInfo1(eps,"Switching to full reorthogonalization at iteration %D\n",eps->its);
482:     }
483:     beta[j] = norm;
484:     BVScaleColumn(eps->V,j+1,1.0/norm);
485:   }

487:   if (m>100) {
488:     PetscFree5(omega,omega_old,which,which2,hwork);
489:   }
490:   return(0);
491: }

495: /*
496:    EPSBasicLanczos - Computes an m-step Lanczos factorization. The first k
497:    columns are assumed to be locked and therefore they are not modified. On
498:    exit, the following relation is satisfied:

500:                     OP * V - V * T = f * e_m^T

502:    where the columns of V are the Lanczos vectors, T is a tridiagonal matrix,
503:    f is the residual vector and e_m is the m-th vector of the canonical basis.
504:    The Lanczos vectors (together with vector f) are B-orthogonal (to working
505:    accuracy) if full reorthogonalization is being used, otherwise they are
506:    (B-)semi-orthogonal. On exit, beta contains the B-norm of f and the next
507:    Lanczos vector can be computed as v_{m+1} = f / beta.

509:    This function simply calls another function which depends on the selected
510:    reorthogonalization strategy.
511: */
512: static PetscErrorCode EPSBasicLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *m,PetscBool *breakdown,PetscReal anorm)
513: {
514:   PetscErrorCode     ierr;
515:   EPS_LANCZOS        *lanczos = (EPS_LANCZOS*)eps->data;
516:   PetscScalar        *T;
517:   PetscInt           i,n=*m;
518:   PetscReal          betam;
519:   BVOrthogRefineType orthog_ref;

522:   switch (lanczos->reorthog) {
523:     case EPS_LANCZOS_REORTHOG_LOCAL:
524:       EPSLocalLanczos(eps,alpha,beta,k,m,breakdown);
525:       break;
526:     case EPS_LANCZOS_REORTHOG_SELECTIVE:
527:       EPSSelectiveLanczos(eps,alpha,beta,k,m,breakdown,anorm);
528:       break;
529:     case EPS_LANCZOS_REORTHOG_FULL:
530:       EPSFullLanczos(eps,alpha,beta,k,m,breakdown);
531:       break;
532:     case EPS_LANCZOS_REORTHOG_PARTIAL:
533:     case EPS_LANCZOS_REORTHOG_PERIODIC:
534:       EPSPartialLanczos(eps,alpha,beta,k,m,breakdown,anorm);
535:       break;
536:     case EPS_LANCZOS_REORTHOG_DELAYED:
537:       PetscMalloc1(n*n,&T);
538:       BVGetOrthogonalization(eps->V,NULL,&orthog_ref,NULL,NULL);
539:       if (orthog_ref == BV_ORTHOG_REFINE_NEVER) {
540:         EPSDelayedArnoldi1(eps,T,n,k,m,&betam,breakdown);
541:       } else {
542:         EPSDelayedArnoldi(eps,T,n,k,m,&betam,breakdown);
543:       }
544:       for (i=k;i<n-1;i++) {
545:         alpha[i] = PetscRealPart(T[n*i+i]);
546:         beta[i] = PetscRealPart(T[n*i+i+1]);
547:       }
548:       alpha[n-1] = PetscRealPart(T[n*(n-1)+n-1]);
549:       beta[n-1] = betam;
550:       PetscFree(T);
551:       break;
552:     default:
553:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid reorthogonalization type");
554:   }
555:   return(0);
556: }

560: PetscErrorCode EPSSolve_Lanczos(EPS eps)
561: {
562:   EPS_LANCZOS    *lanczos = (EPS_LANCZOS*)eps->data;
564:   PetscInt       nconv,i,j,k,l,x,n,*perm,restart,ncv=eps->ncv,r,ld;
565:   Vec            vi,vj,w;
566:   Mat            U;
567:   PetscScalar    *Y,*ritz,stmp;
568:   PetscReal      *d,*e,*bnd,anorm,beta,norm,rtmp,resnorm;
569:   PetscBool      breakdown;
570:   char           *conv,ctmp;

573:   DSGetLeadingDimension(eps->ds,&ld);
574:   PetscMalloc4(ncv,&ritz,ncv,&bnd,ncv,&perm,ncv,&conv);

576:   /* The first Lanczos vector is the normalized initial vector */
577:   EPSGetStartVector(eps,0,NULL);

579:   anorm = -1.0;
580:   nconv = 0;

582:   /* Restart loop */
583:   while (eps->reason == EPS_CONVERGED_ITERATING) {
584:     eps->its++;

586:     /* Compute an ncv-step Lanczos factorization */
587:     n = PetscMin(nconv+eps->mpd,ncv);
588:     DSGetArrayReal(eps->ds,DS_MAT_T,&d);
589:     e = d + ld;
590:     EPSBasicLanczos(eps,d,e,nconv,&n,&breakdown,anorm);
591:     beta = e[n-1];
592:     DSRestoreArrayReal(eps->ds,DS_MAT_T,&d);
593:     DSSetDimensions(eps->ds,n,0,nconv,0);
594:     DSSetState(eps->ds,DS_STATE_INTERMEDIATE);
595:     BVSetActiveColumns(eps->V,nconv,n);

597:     /* Solve projected problem */
598:     DSSolve(eps->ds,ritz,NULL);
599:     DSSort(eps->ds,ritz,NULL,NULL,NULL,NULL);

601:     /* Estimate ||A|| */
602:     for (i=nconv;i<n;i++)
603:       anorm = PetscMax(anorm,PetscAbsReal(PetscRealPart(ritz[i])));

605:     /* Compute residual norm estimates as beta*abs(Y(m,:)) + eps*||A|| */
606:     DSGetArray(eps->ds,DS_MAT_Q,&Y);
607:     for (i=nconv;i<n;i++) {
608:       resnorm = beta*PetscAbsScalar(Y[n-1+i*ld]) + PETSC_MACHINE_EPSILON*anorm;
609:       (*eps->converged)(eps,ritz[i],eps->eigi[i],resnorm,&bnd[i],eps->convergedctx);
610:       if (bnd[i]<eps->tol) conv[i] = 'C';
611:       else conv[i] = 'N';
612:     }
613:     DSRestoreArray(eps->ds,DS_MAT_Q,&Y);

615:     /* purge repeated ritz values */
616:     if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL) {
617:       for (i=nconv+1;i<n;i++) {
618:         if (conv[i] == 'C' && PetscAbsScalar((ritz[i]-ritz[i-1])/ritz[i]) < eps->tol) conv[i] = 'R';
619:       }
620:     }

622:     /* Compute restart vector */
623:     if (breakdown) {
624:       PetscInfo2(eps,"Breakdown in Lanczos method (it=%D norm=%g)\n",eps->its,(double)beta);
625:     } else {
626:       restart = nconv;
627:       while (restart<n && conv[restart] != 'N') restart++;
628:       if (restart >= n) {
629:         breakdown = PETSC_TRUE;
630:       } else {
631:         for (i=restart+1;i<n;i++) {
632:           if (conv[i] == 'N') {
633:             SlepcSCCompare(eps->sc,ritz[restart],0.0,ritz[i],0.0,&r);
634:             if (r>0) restart = i;
635:           }
636:         }
637:         DSGetArray(eps->ds,DS_MAT_Q,&Y);
638:         BVMultColumn(eps->V,1.0,0.0,n,Y+restart*ld+nconv);
639:         DSRestoreArray(eps->ds,DS_MAT_Q,&Y);
640:       }
641:     }

643:     /* Count and put converged eigenvalues first */
644:     for (i=nconv;i<n;i++) perm[i] = i;
645:     for (k=nconv;k<n;k++) {
646:       if (conv[perm[k]] != 'C') {
647:         j = k + 1;
648:         while (j<n && conv[perm[j]] != 'C') j++;
649:         if (j>=n) break;
650:         l = perm[k]; perm[k] = perm[j]; perm[j] = l;
651:       }
652:     }

654:     /* Sort eigenvectors according to permutation */
655:     DSGetArray(eps->ds,DS_MAT_Q,&Y);
656:     for (i=nconv;i<k;i++) {
657:       x = perm[i];
658:       if (x != i) {
659:         j = i + 1;
660:         while (perm[j] != i) j++;
661:         /* swap eigenvalues i and j */
662:         stmp = ritz[x]; ritz[x] = ritz[i]; ritz[i] = stmp;
663:         rtmp = bnd[x]; bnd[x] = bnd[i]; bnd[i] = rtmp;
664:         ctmp = conv[x]; conv[x] = conv[i]; conv[i] = ctmp;
665:         perm[j] = x; perm[i] = i;
666:         /* swap eigenvectors i and j */
667:         for (l=0;l<n;l++) {
668:           stmp = Y[l+x*ld]; Y[l+x*ld] = Y[l+i*ld]; Y[l+i*ld] = stmp;
669:         }
670:       }
671:     }
672:     DSRestoreArray(eps->ds,DS_MAT_Q,&Y);

674:     /* compute converged eigenvectors */
675:     DSGetMat(eps->ds,DS_MAT_Q,&U);
676:     BVMultInPlace(eps->V,U,nconv,k);
677:     MatDestroy(&U);

679:     /* purge spurious ritz values */
680:     if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL) {
681:       for (i=nconv;i<k;i++) {
682:         BVGetColumn(eps->V,i,&vi);
683:         VecNorm(vi,NORM_2,&norm);
684:         VecScale(vi,1.0/norm);
685:         w = eps->work[0];
686:         STApply(eps->st,vi,w);
687:         VecAXPY(w,-ritz[i],vi);
688:         BVRestoreColumn(eps->V,i,&vi);
689:         VecNorm(w,NORM_2,&norm);
690:         (*eps->converged)(eps,ritz[i],eps->eigi[i],norm,&bnd[i],eps->convergedctx);
691:         if (bnd[i]>=eps->tol) conv[i] = 'S';
692:       }
693:       for (i=nconv;i<k;i++) {
694:         if (conv[i] != 'C') {
695:           j = i + 1;
696:           while (j<k && conv[j] != 'C') j++;
697:           if (j>=k) break;
698:           /* swap eigenvalues i and j */
699:           stmp = ritz[j]; ritz[j] = ritz[i]; ritz[i] = stmp;
700:           rtmp = bnd[j]; bnd[j] = bnd[i]; bnd[i] = rtmp;
701:           ctmp = conv[j]; conv[j] = conv[i]; conv[i] = ctmp;
702:           /* swap eigenvectors i and j */
703:           BVGetColumn(eps->V,i,&vi);
704:           BVGetColumn(eps->V,j,&vj);
705:           VecSwap(vi,vj);
706:           BVRestoreColumn(eps->V,i,&vi);
707:           BVRestoreColumn(eps->V,j,&vj);
708:         }
709:       }
710:       k = i;
711:     }

713:     /* store ritz values and estimated errors */
714:     for (i=nconv;i<n;i++) {
715:       eps->eigr[i] = ritz[i];
716:       eps->errest[i] = bnd[i];
717:     }
718:     nconv = k;
719:     EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,n);
720:     (*eps->stopping)(eps,eps->its,eps->max_it,nconv,eps->nev,&eps->reason,eps->stoppingctx);

722:     if (eps->reason == EPS_CONVERGED_ITERATING) { /* copy restart vector */
723:       BVCopyColumn(eps->V,n,nconv);
724:       if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL && !breakdown) {
725:         /* Reorthonormalize restart vector */
726:         BVOrthogonalizeColumn(eps->V,nconv,NULL,&norm,&breakdown);
727:         BVScaleColumn(eps->V,nconv,1.0/norm);
728:       }
729:       if (breakdown) {
730:         /* Use random vector for restarting */
731:         PetscInfo(eps,"Using random vector for restart\n");
732:         EPSGetStartVector(eps,nconv,&breakdown);
733:       }
734:       if (breakdown) { /* give up */
735:         eps->reason = EPS_DIVERGED_BREAKDOWN;
736:         PetscInfo(eps,"Unable to generate more start vectors\n");
737:       }
738:     }
739:   }
740:   eps->nconv = nconv;

742:   PetscFree4(ritz,bnd,perm,conv);
743:   return(0);
744: }

748: PetscErrorCode EPSSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,EPS eps)
749: {
750:   PetscErrorCode         ierr;
751:   EPS_LANCZOS            *lanczos = (EPS_LANCZOS*)eps->data;
752:   PetscBool              flg;
753:   EPSLanczosReorthogType reorthog;

756:   PetscOptionsHead(PetscOptionsObject,"EPS Lanczos Options");
757:   PetscOptionsEnum("-eps_lanczos_reorthog","Lanczos reorthogonalization","EPSLanczosSetReorthog",EPSLanczosReorthogTypes,(PetscEnum)lanczos->reorthog,(PetscEnum*)&reorthog,&flg);
758:   if (flg) {
759:     EPSLanczosSetReorthog(eps,reorthog);
760:   }
761:   PetscOptionsTail();
762:   return(0);
763: }

767: static PetscErrorCode EPSLanczosSetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType reorthog)
768: {
769:   EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data;

772:   switch (reorthog) {
773:     case EPS_LANCZOS_REORTHOG_LOCAL:
774:     case EPS_LANCZOS_REORTHOG_FULL:
775:     case EPS_LANCZOS_REORTHOG_DELAYED:
776:     case EPS_LANCZOS_REORTHOG_SELECTIVE:
777:     case EPS_LANCZOS_REORTHOG_PERIODIC:
778:     case EPS_LANCZOS_REORTHOG_PARTIAL:
779:       lanczos->reorthog = reorthog;
780:       break;
781:     default:
782:       SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid reorthogonalization type");
783:   }
784:   return(0);
785: }

789: /*@
790:    EPSLanczosSetReorthog - Sets the type of reorthogonalization used during the Lanczos
791:    iteration.

793:    Logically Collective on EPS

795:    Input Parameters:
796: +  eps - the eigenproblem solver context
797: -  reorthog - the type of reorthogonalization

799:    Options Database Key:
800: .  -eps_lanczos_reorthog - Sets the reorthogonalization type (either 'local', 'selective',
801:                          'periodic', 'partial', 'full' or 'delayed')

803:    Level: advanced

805: .seealso: EPSLanczosGetReorthog(), EPSLanczosReorthogType
806: @*/
807: PetscErrorCode EPSLanczosSetReorthog(EPS eps,EPSLanczosReorthogType reorthog)
808: {

814:   PetscTryMethod(eps,"EPSLanczosSetReorthog_C",(EPS,EPSLanczosReorthogType),(eps,reorthog));
815:   return(0);
816: }

820: static PetscErrorCode EPSLanczosGetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType *reorthog)
821: {
822:   EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data;

825:   *reorthog = lanczos->reorthog;
826:   return(0);
827: }

831: /*@
832:    EPSLanczosGetReorthog - Gets the type of reorthogonalization used during
833:    the Lanczos iteration.

835:    Not Collective

837:    Input Parameter:
838: .  eps - the eigenproblem solver context

840:    Output Parameter:
841: .  reorthog - the type of reorthogonalization

843:    Level: advanced

845: .seealso: EPSLanczosSetReorthog(), EPSLanczosReorthogType
846: @*/
847: PetscErrorCode EPSLanczosGetReorthog(EPS eps,EPSLanczosReorthogType *reorthog)
848: {

854:   PetscUseMethod(eps,"EPSLanczosGetReorthog_C",(EPS,EPSLanczosReorthogType*),(eps,reorthog));
855:   return(0);
856: }

860: PetscErrorCode EPSReset_Lanczos(EPS eps)
861: {
863:   EPS_LANCZOS    *lanczos = (EPS_LANCZOS*)eps->data;

866:   BVDestroy(&lanczos->AV);
867:   return(0);
868: }

872: PetscErrorCode EPSDestroy_Lanczos(EPS eps)
873: {

877:   PetscFree(eps->data);
878:   PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosSetReorthog_C",NULL);
879:   PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosGetReorthog_C",NULL);
880:   return(0);
881: }

885: PetscErrorCode EPSView_Lanczos(EPS eps,PetscViewer viewer)
886: {
888:   EPS_LANCZOS    *lanczos = (EPS_LANCZOS*)eps->data;
889:   PetscBool      isascii;

892:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
893:   if (isascii) {
894:     PetscViewerASCIIPrintf(viewer,"  Lanczos: %s reorthogonalization\n",EPSLanczosReorthogTypes[lanczos->reorthog]);
895:   }
896:   return(0);
897: }

901: PETSC_EXTERN PetscErrorCode EPSCreate_Lanczos(EPS eps)
902: {
903:   EPS_LANCZOS    *ctx;

907:   PetscNewLog(eps,&ctx);
908:   eps->data = (void*)ctx;

910:   eps->ops->setup                = EPSSetUp_Lanczos;
911:   eps->ops->setfromoptions       = EPSSetFromOptions_Lanczos;
912:   eps->ops->destroy              = EPSDestroy_Lanczos;
913:   eps->ops->reset                = EPSReset_Lanczos;
914:   eps->ops->view                 = EPSView_Lanczos;
915:   eps->ops->backtransform        = EPSBackTransform_Default;
916:   eps->ops->computevectors       = EPSComputeVectors_Hermitian;
917:   PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosSetReorthog_C",EPSLanczosSetReorthog_Lanczos);
918:   PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosGetReorthog_C",EPSLanczosGetReorthog_Lanczos);
919:   return(0);
920: }

slepc-3.7.4/src/eps/impls/krylov/lanczos/index.html0000644000175000017500000000262213107004621021663 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

lanczos.c
makefile
slepc-3.7.4/src/eps/impls/krylov/lanczos/ftn-auto/0000755000175000017500000000000013107004621021421 5ustar jromanjromanslepc-3.7.4/src/eps/impls/krylov/lanczos/ftn-auto/makefile0000644000175000017500000000037213107004621023123 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = lanczosf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/krylov/lanczos/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/krylov/lanczos/ftn-auto/lanczosf.c0000644000175000017500000000303613107004621023406 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* lanczos.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslanczossetreorthog_ EPSLANCZOSSETREORTHOG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslanczossetreorthog_ epslanczossetreorthog #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epslanczosgetreorthog_ EPSLANCZOSGETREORTHOG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epslanczosgetreorthog_ epslanczosgetreorthog #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epslanczossetreorthog_(EPS eps,EPSLanczosReorthogType *reorthog, int *__ierr ){ *__ierr = EPSLanczosSetReorthog( (EPS)PetscToPointer((eps) ),*reorthog); } PETSC_EXTERN void PETSC_STDCALL epslanczosgetreorthog_(EPS eps,EPSLanczosReorthogType *reorthog, int *__ierr ){ *__ierr = EPSLanczosGetReorthog( (EPS)PetscToPointer((eps) ),reorthog); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/krylov/lanczos/lanczos.c0000644000175000017500000007725613107004621021522 0ustar jromanjroman/* SLEPc eigensolver: "lanczos" Method: Explicitly Restarted Symmetric/Hermitian Lanczos Algorithm: Lanczos method for symmetric (Hermitian) problems, with explicit restart and deflation. Several reorthogonalization strategies can be selected. References: [1] "Lanczos Methods in SLEPc", SLEPc Technical Report STR-5, available at http://slepc.upv.es. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include PetscErrorCode EPSSolve_Lanczos(EPS); typedef struct { EPSLanczosReorthogType reorthog; BV AV; } EPS_LANCZOS; #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_Lanczos" PetscErrorCode EPSSetUp_Lanczos(EPS eps) { EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data; BVOrthogRefineType refine; BVOrthogBlockType btype; PetscReal eta; PetscErrorCode ierr; PetscFunctionBegin; ierr = EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); if (eps->ncv>eps->nev+eps->mpd) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must not be larger than nev+mpd"); if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv); if (!eps->which) { ierr = EPSSetWhichEigenpairs_Default(eps);CHKERRQ(ierr); } switch (eps->which) { case EPS_LARGEST_IMAGINARY: case EPS_SMALLEST_IMAGINARY: case EPS_TARGET_IMAGINARY: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); default: ; /* default case to remove warning */ } if (!eps->extraction) { ierr = EPSSetExtraction(eps,EPS_RITZ);CHKERRQ(ierr); } else if (eps->extraction!=EPS_RITZ) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not supported in this solver"); ierr = EPSAllocateSolution(eps,1);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); if (lanczos->reorthog != EPS_LANCZOS_REORTHOG_FULL) { ierr = BVGetOrthogonalization(eps->V,NULL,&refine,&eta,&btype);CHKERRQ(ierr); ierr = BVSetOrthogonalization(eps->V,BV_ORTHOG_MGS,refine,eta,btype);CHKERRQ(ierr); ierr = PetscInfo(eps,"Switching to MGS orthogonalization\n");CHKERRQ(ierr); } if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_SELECTIVE) { ierr = BVDuplicate(eps->V,&lanczos->AV);CHKERRQ(ierr); } ierr = DSSetType(eps->ds,DSHEP);CHKERRQ(ierr); ierr = DSSetCompact(eps->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,eps->ncv+1);CHKERRQ(ierr); if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL) { ierr = EPSSetWorkVecs(eps,1);CHKERRQ(ierr); } /* dispatch solve method */ if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems"); if (eps->isgeneralized && eps->ishermitian && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Requested method does not work for indefinite problems"); eps->ops->solve = EPSSolve_Lanczos; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLocalLanczos" /* EPSLocalLanczos - Local reorthogonalization. This is the simplest variant. At each Lanczos step, the corresponding Lanczos vector is orthogonalized with respect to the two previous Lanczos vectors, according to the three term Lanczos recurrence. WARNING: This variant does not track the loss of orthogonality that occurs in finite-precision arithmetic and, therefore, the generated vectors are not guaranteed to be (semi-)orthogonal. */ static PetscErrorCode EPSLocalLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown) { PetscErrorCode ierr; PetscInt i,j,m = *M; Vec vj,vj1; PetscBool *which,lwhich[100]; PetscScalar *hwork,lhwork[100]; PetscFunctionBegin; if (m > 100) { ierr = PetscMalloc2(m,&which,m,&hwork);CHKERRQ(ierr); } else { which = lwhich; hwork = lhwork; } for (i=0;iV,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); which[j] = PETSC_TRUE; if (j-2>=k) which[j-2] = PETSC_FALSE; ierr = BVOrthogonalizeSomeColumn(eps->V,j+1,which,hwork,beta+j,breakdown);CHKERRQ(ierr); alpha[j] = PetscRealPart(hwork[j]); if (*breakdown) { *M = j+1; break; } else { ierr = BVScaleColumn(eps->V,j+1,1/beta[j]);CHKERRQ(ierr); } } if (m > 100) { ierr = PetscFree2(which,hwork);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DenseTridiagonal" /* DenseTridiagonal - Solves a real tridiagonal Hermitian Eigenvalue Problem. Input Parameters: + n - dimension of the eigenproblem . D - pointer to the array containing the diagonal elements - E - pointer to the array containing the off-diagonal elements Output Parameters: + w - pointer to the array to store the computed eigenvalues - V - pointer to the array to store the eigenvectors Notes: If V is NULL then the eigenvectors are not computed. This routine use LAPACK routines xSTEVR. */ static PetscErrorCode DenseTridiagonal(PetscInt n_,PetscReal *D,PetscReal *E,PetscReal *w,PetscScalar *V) { #if defined(SLEPC_MISSING_LAPACK_STEVR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STEVR - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscReal abstol = 0.0,vl,vu,*work; PetscBLASInt il,iu,m,*isuppz,n,lwork,*iwork,liwork,info; const char *jobz; #if defined(PETSC_USE_COMPLEX) PetscInt i,j; PetscReal *VV; #endif PetscFunctionBegin; ierr = PetscBLASIntCast(n_,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(20*n_,&lwork);CHKERRQ(ierr); ierr = PetscBLASIntCast(10*n_,&liwork);CHKERRQ(ierr); if (V) { jobz = "V"; #if defined(PETSC_USE_COMPLEX) ierr = PetscMalloc1(n*n,&VV);CHKERRQ(ierr); #endif } else jobz = "N"; ierr = PetscMalloc3(2*n,&isuppz,lwork,&work,liwork,&iwork);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKstevr",LAPACKstevr_(jobz,"A",&n,D,E,&vl,&vu,&il,&iu,&abstol,&m,w,VV,&n,isuppz,work,&lwork,iwork,&liwork,&info)); #else PetscStackCallBLAS("LAPACKstevr",LAPACKstevr_(jobz,"A",&n,D,E,&vl,&vu,&il,&iu,&abstol,&m,w,V,&n,isuppz,work,&lwork,iwork,&liwork,&info)); #endif ierr = PetscFPTrapPop();CHKERRQ(ierr); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DSTEVR %d",info); #if defined(PETSC_USE_COMPLEX) if (V) { for (i=0;idata; PetscInt i,j,m = *M,n,nritz=0,nritzo; Vec vj,vj1,av; PetscReal *d,*e,*ritz,norm; PetscScalar *Y,*hwork; PetscBool *which; PetscFunctionBegin; ierr = PetscCalloc6(m+1,&d,m,&e,m,&ritz,m*m,&Y,m,&which,m,&hwork);CHKERRQ(ierr); for (i=0;iV,0,m);CHKERRQ(ierr); /* Lanczos step */ ierr = BVGetColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); which[j] = PETSC_TRUE; if (j-2>=k) which[j-2] = PETSC_FALSE; ierr = BVOrthogonalizeSomeColumn(eps->V,j+1,which,hwork,&norm,breakdown);CHKERRQ(ierr); alpha[j] = PetscRealPart(hwork[j]); beta[j] = norm; if (*breakdown) { *M = j+1; break; } /* Compute eigenvalues and eigenvectors Y of the tridiagonal block */ n = j-k+1; for (i=0;i anorm) anorm = PetscAbsReal(ritz[i]); /* Compute nearly converged Ritz vectors */ nritzo = 0; for (i=0;inritz) { nritz = 0; for (i=0;iV,k,k+n);CHKERRQ(ierr); ierr = BVGetColumn(lanczos->AV,nritz,&av);CHKERRQ(ierr); ierr = BVMultVec(eps->V,1.0,0.0,av,Y+i*n);CHKERRQ(ierr); ierr = BVRestoreColumn(lanczos->AV,nritz,&av);CHKERRQ(ierr); nritz++; } } } if (nritz > 0) { ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = BVSetActiveColumns(lanczos->AV,0,nritz);CHKERRQ(ierr); ierr = BVOrthogonalizeVec(lanczos->AV,vj1,hwork,&norm,breakdown);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); if (*breakdown) { *M = j+1; break; } } ierr = BVScaleColumn(eps->V,j+1,1.0/norm);CHKERRQ(ierr); } ierr = PetscFree6(d,e,ritz,Y,which,hwork);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "update_omega" static void update_omega(PetscReal *omega,PetscReal *omega_old,PetscInt j,PetscReal *alpha,PetscReal *beta,PetscReal eps1,PetscReal anorm) { PetscInt k; PetscReal T,binv; PetscFunctionBegin; /* Estimate of contribution to roundoff errors from A*v fl(A*v) = A*v + f, where ||f|| \approx eps1*||A||. For a full matrix A, a rule-of-thumb estimate is eps1 = sqrt(n)*eps */ T = eps1*anorm; binv = 1.0/beta[j+1]; /* Update omega(1) using omega(0)==0 */ omega_old[0]= beta[1]*omega[1] + (alpha[0]-alpha[j])*omega[0] - beta[j]*omega_old[0]; if (omega_old[0] > 0) omega_old[0] = binv*(omega_old[0] + T); else omega_old[0] = binv*(omega_old[0] - T); /* Update remaining components */ for (k=1;k 0) omega_old[k] = binv*(omega_old[k] + T); else omega_old[k] = binv*(omega_old[k] - T); } omega_old[j-1] = binv*T; /* Swap omega and omega_old */ for (k=0;k= delta) { which[i] = PETSC_TRUE; found = PETSC_TRUE; } else which[i] = PETSC_FALSE; if (PetscAbsReal(mu[i]) > max) { maxpos = i; max = PetscAbsReal(mu[i]); } } if (!found) which[maxpos] = PETSC_TRUE; for (i=0;i=0;k--) { if (PetscAbsReal(mu[k])data; PetscInt i,j,m = *M; Vec vj,vj1; PetscReal norm,*omega,lomega[100],*omega_old,lomega_old[100],eps1,delta,eta; PetscBool *which,lwhich[100],*which2,lwhich2[100]; PetscBool reorth = PETSC_FALSE,force_reorth = PETSC_FALSE; PetscBool fro = PETSC_FALSE,estimate_anorm = PETSC_FALSE; PetscScalar *hwork,lhwork[100]; PetscFunctionBegin; if (m>100) { ierr = PetscMalloc5(m,&omega,m,&omega_old,m,&which,m,&which2,m,&hwork);CHKERRQ(ierr); } else { omega = lomega; omega_old = lomega_old; which = lwhich; which2 = lwhich2; hwork = lhwork; } eps1 = PetscSqrtReal((PetscReal)eps->n)*PETSC_MACHINE_EPSILON/2; delta = PETSC_SQRT_MACHINE_EPSILON/PetscSqrtReal((PetscReal)eps->ncv); eta = PetscPowReal(PETSC_MACHINE_EPSILON,3.0/4.0)/PetscSqrtReal((PetscReal)eps->ncv); if (anorm < 0.0) { anorm = 1.0; estimate_anorm = PETSC_TRUE; } for (i=0;iV,0,m);CHKERRQ(ierr); for (j=k;jV,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); ierr = STApply(eps->st,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j+1,&vj1);CHKERRQ(ierr); if (fro) { /* Lanczos step with full reorthogonalization */ ierr = BVOrthogonalizeColumn(eps->V,j+1,hwork,&norm,breakdown);CHKERRQ(ierr); alpha[j] = PetscRealPart(hwork[j]); } else { /* Lanczos step */ which[j] = PETSC_TRUE; if (j-2>=k) which[j-2] = PETSC_FALSE; ierr = BVOrthogonalizeSomeColumn(eps->V,j+1,which,hwork,&norm,breakdown);CHKERRQ(ierr); alpha[j] = PetscRealPart(hwork[j]); beta[j] = norm; /* Estimate ||A|| if needed */ if (estimate_anorm) { if (j>k) anorm = PetscMax(anorm,PetscAbsReal(alpha[j])+norm+beta[j-1]); else anorm = PetscMax(anorm,PetscAbsReal(alpha[j])+norm); } /* Check if reorthogonalization is needed */ reorth = PETSC_FALSE; if (j>k) { update_omega(omega,omega_old,j,alpha,beta-1,eps1,anorm); for (i=0;i delta) reorth = PETSC_TRUE; } } if (reorth || force_reorth) { for (i=0;ireorthog == EPS_LANCZOS_REORTHOG_PERIODIC) { /* Periodic reorthogonalization */ if (force_reorth) force_reorth = PETSC_FALSE; else force_reorth = PETSC_TRUE; for (i=0;iV,j+1,which2,hwork,&norm,breakdown);CHKERRQ(ierr); } } if (*breakdown || norm < eps->n*anorm*PETSC_MACHINE_EPSILON) { *M = j+1; break; } if (!fro && norm*delta < anorm*eps1) { fro = PETSC_TRUE; ierr = PetscInfo1(eps,"Switching to full reorthogonalization at iteration %D\n",eps->its);CHKERRQ(ierr); } beta[j] = norm; ierr = BVScaleColumn(eps->V,j+1,1.0/norm);CHKERRQ(ierr); } if (m>100) { ierr = PetscFree5(omega,omega_old,which,which2,hwork);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSBasicLanczos" /* EPSBasicLanczos - Computes an m-step Lanczos factorization. The first k columns are assumed to be locked and therefore they are not modified. On exit, the following relation is satisfied: OP * V - V * T = f * e_m^T where the columns of V are the Lanczos vectors, T is a tridiagonal matrix, f is the residual vector and e_m is the m-th vector of the canonical basis. The Lanczos vectors (together with vector f) are B-orthogonal (to working accuracy) if full reorthogonalization is being used, otherwise they are (B-)semi-orthogonal. On exit, beta contains the B-norm of f and the next Lanczos vector can be computed as v_{m+1} = f / beta. This function simply calls another function which depends on the selected reorthogonalization strategy. */ static PetscErrorCode EPSBasicLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *m,PetscBool *breakdown,PetscReal anorm) { PetscErrorCode ierr; EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data; PetscScalar *T; PetscInt i,n=*m; PetscReal betam; BVOrthogRefineType orthog_ref; PetscFunctionBegin; switch (lanczos->reorthog) { case EPS_LANCZOS_REORTHOG_LOCAL: ierr = EPSLocalLanczos(eps,alpha,beta,k,m,breakdown);CHKERRQ(ierr); break; case EPS_LANCZOS_REORTHOG_SELECTIVE: ierr = EPSSelectiveLanczos(eps,alpha,beta,k,m,breakdown,anorm);CHKERRQ(ierr); break; case EPS_LANCZOS_REORTHOG_FULL: ierr = EPSFullLanczos(eps,alpha,beta,k,m,breakdown);CHKERRQ(ierr); break; case EPS_LANCZOS_REORTHOG_PARTIAL: case EPS_LANCZOS_REORTHOG_PERIODIC: ierr = EPSPartialLanczos(eps,alpha,beta,k,m,breakdown,anorm);CHKERRQ(ierr); break; case EPS_LANCZOS_REORTHOG_DELAYED: ierr = PetscMalloc1(n*n,&T);CHKERRQ(ierr); ierr = BVGetOrthogonalization(eps->V,NULL,&orthog_ref,NULL,NULL);CHKERRQ(ierr); if (orthog_ref == BV_ORTHOG_REFINE_NEVER) { ierr = EPSDelayedArnoldi1(eps,T,n,k,m,&betam,breakdown);CHKERRQ(ierr); } else { ierr = EPSDelayedArnoldi(eps,T,n,k,m,&betam,breakdown);CHKERRQ(ierr); } for (i=k;idata; PetscErrorCode ierr; PetscInt nconv,i,j,k,l,x,n,*perm,restart,ncv=eps->ncv,r,ld; Vec vi,vj,w; Mat U; PetscScalar *Y,*ritz,stmp; PetscReal *d,*e,*bnd,anorm,beta,norm,rtmp,resnorm; PetscBool breakdown; char *conv,ctmp; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = PetscMalloc4(ncv,&ritz,ncv,&bnd,ncv,&perm,ncv,&conv);CHKERRQ(ierr); /* The first Lanczos vector is the normalized initial vector */ ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); anorm = -1.0; nconv = 0; /* Restart loop */ while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; /* Compute an ncv-step Lanczos factorization */ n = PetscMin(nconv+eps->mpd,ncv); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&d);CHKERRQ(ierr); e = d + ld; ierr = EPSBasicLanczos(eps,d,e,nconv,&n,&breakdown,anorm);CHKERRQ(ierr); beta = e[n-1]; ierr = DSRestoreArrayReal(eps->ds,DS_MAT_T,&d);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,n,0,nconv,0);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,nconv,n);CHKERRQ(ierr); /* Solve projected problem */ ierr = DSSolve(eps->ds,ritz,NULL);CHKERRQ(ierr); ierr = DSSort(eps->ds,ritz,NULL,NULL,NULL,NULL);CHKERRQ(ierr); /* Estimate ||A|| */ for (i=nconv;ids,DS_MAT_Q,&Y);CHKERRQ(ierr); for (i=nconv;iconverged)(eps,ritz[i],eps->eigi[i],resnorm,&bnd[i],eps->convergedctx);CHKERRQ(ierr); if (bnd[i]tol) conv[i] = 'C'; else conv[i] = 'N'; } ierr = DSRestoreArray(eps->ds,DS_MAT_Q,&Y);CHKERRQ(ierr); /* purge repeated ritz values */ if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL) { for (i=nconv+1;itol) conv[i] = 'R'; } } /* Compute restart vector */ if (breakdown) { ierr = PetscInfo2(eps,"Breakdown in Lanczos method (it=%D norm=%g)\n",eps->its,(double)beta);CHKERRQ(ierr); } else { restart = nconv; while (restart= n) { breakdown = PETSC_TRUE; } else { for (i=restart+1;isc,ritz[restart],0.0,ritz[i],0.0,&r);CHKERRQ(ierr); if (r>0) restart = i; } } ierr = DSGetArray(eps->ds,DS_MAT_Q,&Y);CHKERRQ(ierr); ierr = BVMultColumn(eps->V,1.0,0.0,n,Y+restart*ld+nconv);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_Q,&Y);CHKERRQ(ierr); } } /* Count and put converged eigenvalues first */ for (i=nconv;i=n) break; l = perm[k]; perm[k] = perm[j]; perm[j] = l; } } /* Sort eigenvectors according to permutation */ ierr = DSGetArray(eps->ds,DS_MAT_Q,&Y);CHKERRQ(ierr); for (i=nconv;ids,DS_MAT_Q,&Y);CHKERRQ(ierr); /* compute converged eigenvectors */ ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,nconv,k);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); /* purge spurious ritz values */ if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL) { for (i=nconv;iV,i,&vi);CHKERRQ(ierr); ierr = VecNorm(vi,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(vi,1.0/norm);CHKERRQ(ierr); w = eps->work[0]; ierr = STApply(eps->st,vi,w);CHKERRQ(ierr); ierr = VecAXPY(w,-ritz[i],vi);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&vi);CHKERRQ(ierr); ierr = VecNorm(w,NORM_2,&norm);CHKERRQ(ierr); ierr = (*eps->converged)(eps,ritz[i],eps->eigi[i],norm,&bnd[i],eps->convergedctx);CHKERRQ(ierr); if (bnd[i]>=eps->tol) conv[i] = 'S'; } for (i=nconv;i=k) break; /* swap eigenvalues i and j */ stmp = ritz[j]; ritz[j] = ritz[i]; ritz[i] = stmp; rtmp = bnd[j]; bnd[j] = bnd[i]; bnd[i] = rtmp; ctmp = conv[j]; conv[j] = conv[i]; conv[i] = ctmp; /* swap eigenvectors i and j */ ierr = BVGetColumn(eps->V,i,&vi);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,j,&vj);CHKERRQ(ierr); ierr = VecSwap(vi,vj);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,i,&vi);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,j,&vj);CHKERRQ(ierr); } } k = i; } /* store ritz values and estimated errors */ for (i=nconv;ieigr[i] = ritz[i]; eps->errest[i] = bnd[i]; } nconv = k; ierr = EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,n);CHKERRQ(ierr); ierr = (*eps->stopping)(eps,eps->its,eps->max_it,nconv,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); if (eps->reason == EPS_CONVERGED_ITERATING) { /* copy restart vector */ ierr = BVCopyColumn(eps->V,n,nconv);CHKERRQ(ierr); if (lanczos->reorthog == EPS_LANCZOS_REORTHOG_LOCAL && !breakdown) { /* Reorthonormalize restart vector */ ierr = BVOrthogonalizeColumn(eps->V,nconv,NULL,&norm,&breakdown);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,nconv,1.0/norm);CHKERRQ(ierr); } if (breakdown) { /* Use random vector for restarting */ ierr = PetscInfo(eps,"Using random vector for restart\n");CHKERRQ(ierr); ierr = EPSGetStartVector(eps,nconv,&breakdown);CHKERRQ(ierr); } if (breakdown) { /* give up */ eps->reason = EPS_DIVERGED_BREAKDOWN; ierr = PetscInfo(eps,"Unable to generate more start vectors\n");CHKERRQ(ierr); } } } eps->nconv = nconv; ierr = PetscFree4(ritz,bnd,perm,conv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_Lanczos" PetscErrorCode EPSSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data; PetscBool flg; EPSLanczosReorthogType reorthog; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS Lanczos Options");CHKERRQ(ierr); ierr = PetscOptionsEnum("-eps_lanczos_reorthog","Lanczos reorthogonalization","EPSLanczosSetReorthog",EPSLanczosReorthogTypes,(PetscEnum)lanczos->reorthog,(PetscEnum*)&reorthog,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSLanczosSetReorthog(eps,reorthog);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLanczosSetReorthog_Lanczos" static PetscErrorCode EPSLanczosSetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType reorthog) { EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data; PetscFunctionBegin; switch (reorthog) { case EPS_LANCZOS_REORTHOG_LOCAL: case EPS_LANCZOS_REORTHOG_FULL: case EPS_LANCZOS_REORTHOG_DELAYED: case EPS_LANCZOS_REORTHOG_SELECTIVE: case EPS_LANCZOS_REORTHOG_PERIODIC: case EPS_LANCZOS_REORTHOG_PARTIAL: lanczos->reorthog = reorthog; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid reorthogonalization type"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLanczosSetReorthog" /*@ EPSLanczosSetReorthog - Sets the type of reorthogonalization used during the Lanczos iteration. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - reorthog - the type of reorthogonalization Options Database Key: . -eps_lanczos_reorthog - Sets the reorthogonalization type (either 'local', 'selective', 'periodic', 'partial', 'full' or 'delayed') Level: advanced .seealso: EPSLanczosGetReorthog(), EPSLanczosReorthogType @*/ PetscErrorCode EPSLanczosSetReorthog(EPS eps,EPSLanczosReorthogType reorthog) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveEnum(eps,reorthog,2); ierr = PetscTryMethod(eps,"EPSLanczosSetReorthog_C",(EPS,EPSLanczosReorthogType),(eps,reorthog));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLanczosGetReorthog_Lanczos" static PetscErrorCode EPSLanczosGetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType *reorthog) { EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data; PetscFunctionBegin; *reorthog = lanczos->reorthog; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLanczosGetReorthog" /*@ EPSLanczosGetReorthog - Gets the type of reorthogonalization used during the Lanczos iteration. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . reorthog - the type of reorthogonalization Level: advanced .seealso: EPSLanczosSetReorthog(), EPSLanczosReorthogType @*/ PetscErrorCode EPSLanczosGetReorthog(EPS eps,EPSLanczosReorthogType *reorthog) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(reorthog,2); ierr = PetscUseMethod(eps,"EPSLanczosGetReorthog_C",(EPS,EPSLanczosReorthogType*),(eps,reorthog));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_Lanczos" PetscErrorCode EPSReset_Lanczos(EPS eps) { PetscErrorCode ierr; EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data; PetscFunctionBegin; ierr = BVDestroy(&lanczos->AV);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_Lanczos" PetscErrorCode EPSDestroy_Lanczos(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosSetReorthog_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosGetReorthog_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_Lanczos" PetscErrorCode EPSView_Lanczos(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_LANCZOS *lanczos = (EPS_LANCZOS*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," Lanczos: %s reorthogonalization\n",EPSLanczosReorthogTypes[lanczos->reorthog]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_Lanczos" PETSC_EXTERN PetscErrorCode EPSCreate_Lanczos(EPS eps) { EPS_LANCZOS *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; eps->ops->setup = EPSSetUp_Lanczos; eps->ops->setfromoptions = EPSSetFromOptions_Lanczos; eps->ops->destroy = EPSDestroy_Lanczos; eps->ops->reset = EPSReset_Lanczos; eps->ops->view = EPSView_Lanczos; eps->ops->backtransform = EPSBackTransform_Default; eps->ops->computevectors = EPSComputeVectors_Hermitian; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosSetReorthog_C",EPSLanczosSetReorthog_Lanczos);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSLanczosGetReorthog_C",EPSLanczosGetReorthog_Lanczos);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/krylov/krylovschur/0000755000175000017500000000000013107004621020606 5ustar jromanjromanslepc-3.7.4/src/eps/impls/krylov/krylovschur/makefile0000644000175000017500000000225513107004621022312 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = krylovschur.c ks-symm.c ks-slice.c ks-indef.c SOURCEF = SOURCEH = krylovschur.h LIBBASE = libslepceps DIRS = MANSEC = EPS LOCDIR = src/eps/impls/krylov/krylovschur/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/krylov/krylovschur/ks-symm.c0000644000175000017500000001036213107004621022354 0ustar jromanjroman/* SLEPc eigensolver: "krylovschur" Method: Krylov-Schur for symmetric eigenproblems - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include "krylovschur.h" #undef __FUNCT__ #define __FUNCT__ "EPSSolve_KrylovSchur_Symm" PetscErrorCode EPSSolve_KrylovSchur_Symm(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscInt k,l,ld,nv,nconv; Mat U; PetscReal *a,*b,beta; PetscBool breakdown; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); /* Get the starting Lanczos vector */ ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); l = 0; /* Restart loop */ while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; /* Compute an nv-step Lanczos factorization */ nv = PetscMin(eps->nconv+eps->mpd,eps->ncv); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); b = a + ld; ierr = EPSFullLanczos(eps,a,b,eps->nconv+l,&nv,&breakdown);CHKERRQ(ierr); beta = b[nv-1]; ierr = DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(eps->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); } ierr = BVSetActiveColumns(eps->V,eps->nconv,nv);CHKERRQ(ierr); /* Solve projected problem */ ierr = DSSolve(eps->ds,eps->eigr,NULL);CHKERRQ(ierr); if (eps->arbitrary) { ierr = EPSGetArbitraryValues(eps,eps->rr,eps->ri);CHKERRQ(ierr); } ierr = DSSort(eps->ds,eps->eigr,NULL,eps->rr,eps->ri,NULL);CHKERRQ(ierr); ierr = DSUpdateExtraRow(eps->ds);CHKERRQ(ierr); /* Check convergence */ ierr = EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,nv-eps->nconv,beta,1.0,&k);CHKERRQ(ierr); ierr = (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); nconv = k; /* Update l */ if (eps->reason != EPS_CONVERGED_ITERATING || breakdown) l = 0; else l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep)); if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */ if (eps->reason == EPS_CONVERGED_ITERATING) { if (breakdown) { /* Start a new Lanczos factorization */ ierr = PetscInfo2(eps,"Breakdown in Krylov-Schur method (it=%D norm=%g)\n",eps->its,(double)beta);CHKERRQ(ierr); if (knev) { ierr = EPSGetStartVector(eps,k,&breakdown);CHKERRQ(ierr); if (breakdown) { eps->reason = EPS_DIVERGED_BREAKDOWN; ierr = PetscInfo(eps,"Unable to generate more start vectors\n");CHKERRQ(ierr); } } } else { /* Prepare the Rayleigh quotient for restart */ ierr = DSTruncate(eps->ds,k+l);CHKERRQ(ierr); } } /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */ ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,eps->nconv,k+l);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); /* Normalize u and append it to V */ if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) { ierr = BVCopyColumn(eps->V,nv,k+l);CHKERRQ(ierr); } eps->nconv = k; ierr = EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,nv);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/krylov/krylovschur/ks-slice.c0000644000175000017500000016565213107004621022503 0ustar jromanjroman/* SLEPc eigensolver: "krylovschur" Method: Krylov-Schur with spectrum slicing for symmetric eigenproblems References: [1] R.G. Grimes et al., "A shifted block Lanczos algorithm for solving sparse symmetric generalized eigenproblems", SIAM J. Matrix Anal. Appl. 15(1):228-272, 1994. [2] C. Campos and J.E. Roman, "Spectrum slicing strategies based on restarted Lanczos methods", Numer. Algor. 60(2):279-295, 2012. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include "krylovschur.h" static PetscBool cited = PETSC_FALSE; static const char citation[] = "@Article{slepc-slice,\n" " author = \"C. Campos and J. E. Roman\",\n" " title = \"Strategies for spectrum slicing based on restarted {Lanczos} methods\",\n" " journal = \"Numer. Algorithms\",\n" " volume = \"60\",\n" " number = \"2\",\n" " pages = \"279--295\",\n" " year = \"2012,\"\n" " doi = \"http://dx.doi.org/10.1007/s11075-012-9564-z\"\n" "}\n"; #define SLICE_PTOL PETSC_SQRT_MACHINE_EPSILON #undef __FUNCT__ #define __FUNCT__ "EPSSliceResetSR" static PetscErrorCode EPSSliceResetSR(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; EPS_SR sr=ctx->sr; EPS_shift s; PetscFunctionBegin; if (sr) { if (ctx->npart>1) { ierr = BVDestroy(&sr->V);CHKERRQ(ierr); ierr = PetscFree4(sr->eigr,sr->eigi,sr->errest,sr->perm);CHKERRQ(ierr); } /* Reviewing list of shifts to free memory */ s = sr->s0; if (s) { while (s->neighb[1]) { s = s->neighb[1]; ierr = PetscFree(s->neighb[0]);CHKERRQ(ierr); } ierr = PetscFree(s);CHKERRQ(ierr); } ierr = PetscFree(sr);CHKERRQ(ierr); } ctx->sr = NULL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_KrylovSchur_Slice" PetscErrorCode EPSReset_KrylovSchur_Slice(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; if (!ctx->global) PetscFunctionReturn(0); /* Destroy auxiliary EPS */ ierr = EPSSliceResetSR(ctx->eps);CHKERRQ(ierr); ierr = EPSDestroy(&ctx->eps);CHKERRQ(ierr); if (ctx->npart>1) { ierr = PetscSubcommDestroy(&ctx->subc);CHKERRQ(ierr); if (ctx->commset) { ierr = MPI_Comm_free(&ctx->commrank);CHKERRQ(ierr); ctx->commset = PETSC_FALSE; } } ierr = PetscFree(ctx->subintervals);CHKERRQ(ierr); ierr = PetscFree(ctx->nconv_loc);CHKERRQ(ierr); ierr = EPSSliceResetSR(eps);CHKERRQ(ierr); ierr = PetscFree(ctx->inertias);CHKERRQ(ierr); ierr = PetscFree(ctx->shifts);CHKERRQ(ierr); if (ctx->npart>1) { ierr = ISDestroy(&ctx->isrow);CHKERRQ(ierr); ierr = ISDestroy(&ctx->iscol);CHKERRQ(ierr); ierr = MatDestroyMatrices(1,&ctx->submata);CHKERRQ(ierr); ierr = MatDestroyMatrices(1,&ctx->submatb);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSliceAllocateSolution" /* EPSSliceAllocateSolution - Allocate memory storage for common variables such as eigenvalues and eigenvectors. The argument extra is used for methods that require a working basis slightly larger than ncv. */ static PetscErrorCode EPSSliceAllocateSolution(EPS eps,PetscInt extra) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscReal eta; PetscInt k; PetscLogDouble cnt; BVType type; BVOrthogType orthog_type; BVOrthogRefineType orthog_ref; BVOrthogBlockType ob_type; Mat matrix; Vec t; EPS_SR sr = ctx->sr; PetscFunctionBegin; /* allocate space for eigenvalues and friends */ k = PetscMax(1,sr->numEigs); ierr = PetscFree4(sr->eigr,sr->eigi,sr->errest,sr->perm);CHKERRQ(ierr); ierr = PetscMalloc4(k,&sr->eigr,k,&sr->eigi,k,&sr->errest,k,&sr->perm);CHKERRQ(ierr); cnt = 2*k*sizeof(PetscScalar) + 2*k*sizeof(PetscReal) + k*sizeof(PetscInt); ierr = PetscLogObjectMemory((PetscObject)eps,cnt);CHKERRQ(ierr); /* allocate sr->V and transfer options from eps->V */ ierr = BVDestroy(&sr->V);CHKERRQ(ierr); ierr = BVCreate(PetscObjectComm((PetscObject)eps),&sr->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)eps,(PetscObject)sr->V);CHKERRQ(ierr); if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } if (!((PetscObject)(eps->V))->type_name) { ierr = BVSetType(sr->V,BVSVEC);CHKERRQ(ierr); } else { ierr = BVGetType(eps->V,&type);CHKERRQ(ierr); ierr = BVSetType(sr->V,type);CHKERRQ(ierr); } ierr = STMatCreateVecs(eps->st,&t,NULL);CHKERRQ(ierr); ierr = BVSetSizesFromVec(sr->V,t,k);CHKERRQ(ierr); ierr = VecDestroy(&t);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); ierr = BVGetMatrix(eps->V,&matrix,NULL);CHKERRQ(ierr); ierr = BVSetMatrix(sr->V,matrix,PETSC_FALSE);CHKERRQ(ierr); ierr = BVGetOrthogonalization(eps->V,&orthog_type,&orthog_ref,&eta,&ob_type);CHKERRQ(ierr); ierr = BVSetOrthogonalization(sr->V,orthog_type,orthog_ref,eta,ob_type);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSliceGetEPS" static PetscErrorCode EPSSliceGetEPS(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data,*ctx_local; BV V; BVType type; PetscReal eta; BVOrthogType orthog_type; BVOrthogRefineType orthog_ref; BVOrthogBlockType ob_type; Mat A,B=NULL,Ar,Br=NULL; PetscInt i; PetscReal h,a,b; PetscMPIInt rank; EPS_SR sr=ctx->sr; PC pc; PCType pctype; KSP ksp; KSPType ksptype; STType sttype; PetscObjectState Astate,Bstate=0; PetscObjectId Aid,Bid=0; const MatSolverPackage stype; PetscFunctionBegin; ierr = EPSGetOperators(eps,&A,&B);CHKERRQ(ierr); if (ctx->npart==1) { if (!ctx->eps) { ierr = EPSCreate(((PetscObject)eps)->comm,&ctx->eps);CHKERRQ(ierr); } ierr = EPSSetType(ctx->eps,((PetscObject)eps)->type_name);CHKERRQ(ierr); ierr = EPSSetOperators(ctx->eps,A,B);CHKERRQ(ierr); a = eps->inta; b = eps->intb; } else { ierr = PetscObjectStateGet((PetscObject)A,&Astate);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)A,&Aid);CHKERRQ(ierr); if (B) { ierr = PetscObjectStateGet((PetscObject)B,&Bstate);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)B,&Bid);CHKERRQ(ierr); } if (!ctx->subc) { /* Create context for subcommunicators */ ierr = PetscSubcommCreate(PetscObjectComm((PetscObject)eps),&ctx->subc);CHKERRQ(ierr); ierr = PetscSubcommSetNumber(ctx->subc,ctx->npart);CHKERRQ(ierr);CHKERRQ(ierr); ierr = PetscSubcommSetType(ctx->subc,PETSC_SUBCOMM_CONTIGUOUS);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,sizeof(PetscSubcomm));CHKERRQ(ierr); /* Duplicate matrices */ ierr = MatCreateRedundantMatrix(A,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Ar);CHKERRQ(ierr); ctx->Astate = Astate; ctx->Aid = Aid; if (B) { ierr = MatCreateRedundantMatrix(B,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Br);CHKERRQ(ierr); ctx->Bstate = Bstate; ctx->Bid = Bid; } } else { if (ctx->Astate != Astate || (B && ctx->Bstate != Bstate) || ctx->Aid != Aid || (B && ctx->Bid != Bid)) { ierr = EPSGetOperators(ctx->eps,&Ar,&Br);CHKERRQ(ierr); ierr = MatCreateRedundantMatrix(A,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Ar);CHKERRQ(ierr); ctx->Astate = Astate; ctx->Aid = Aid; if (B) { ierr = MatCreateRedundantMatrix(B,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Br);CHKERRQ(ierr); ctx->Bstate = Bstate; ctx->Bid = Bid; } ierr = EPSSetOperators(ctx->eps,Ar,Br);CHKERRQ(ierr); ierr = MatDestroy(&Ar);CHKERRQ(ierr); ierr = MatDestroy(&Br);CHKERRQ(ierr); } } /* Determine subintervals */ if (!ctx->subintset) { /* uniform distribution if no set by user */ if (!sr->hasEnd) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Global interval must be bounded for splitting it in uniform subintervals"); h = (eps->intb-eps->inta)/ctx->npart; a = eps->inta+ctx->subc->color*h; b = (ctx->subc->color==ctx->npart-1)?eps->intb:eps->inta+(ctx->subc->color+1)*h; ierr = PetscFree(ctx->subintervals);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->npart+1,&ctx->subintervals);CHKERRQ(ierr); for (i=0;inpart;i++) ctx->subintervals[i] = eps->inta+h*i; ctx->subintervals[ctx->npart] = eps->intb; } else { a = ctx->subintervals[ctx->subc->color]; b = ctx->subintervals[ctx->subc->color+1]; } if (!ctx->eps) { /* Create auxiliary EPS */ ierr = EPSCreate(PetscSubcommChild(ctx->subc),&ctx->eps);CHKERRQ(ierr); ierr = EPSSetOperators(ctx->eps,Ar,Br);CHKERRQ(ierr); ierr = MatDestroy(&Ar);CHKERRQ(ierr); ierr = MatDestroy(&Br);CHKERRQ(ierr); } /* Create subcommunicator grouping processes with same rank */ if (ctx->commset) { ierr = MPI_Comm_free(&ctx->commrank);CHKERRQ(ierr); } ierr = MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);CHKERRQ(ierr); ierr = MPI_Comm_split(((PetscObject)eps)->comm,rank,ctx->subc->color,&ctx->commrank);CHKERRQ(ierr); ctx->commset = PETSC_TRUE; } ierr = EPSSetType(ctx->eps,((PetscObject)eps)->type_name);CHKERRQ(ierr); /* Transfer options for ST, KSP and PC */ ierr = STGetType(eps->st,&sttype);CHKERRQ(ierr); ierr = STSetType(ctx->eps->st,sttype);CHKERRQ(ierr); ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); ierr = KSPGetType(ksp,&ksptype);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCGetType(pc,&pctype);CHKERRQ(ierr); ierr = PCFactorGetMatSolverPackage(pc,&stype);CHKERRQ(ierr); ierr = STGetKSP(ctx->eps->st,&ksp);CHKERRQ(ierr); ierr = KSPSetType(ksp,ksptype);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetType(pc,pctype);CHKERRQ(ierr); if (stype) { ierr = PCFactorSetMatSolverPackage(pc,stype);CHKERRQ(ierr); } ierr = EPSSetConvergenceTest(ctx->eps,eps->conv);CHKERRQ(ierr); ierr = EPSSetInterval(ctx->eps,a,b);CHKERRQ(ierr); ctx_local = (EPS_KRYLOVSCHUR*)ctx->eps->data; ctx_local->npart = ctx->npart; ctx_local->detect = ctx->detect; ctx_local->global = PETSC_FALSE; ctx_local->eps = eps; ctx_local->subc = ctx->subc; ctx_local->commrank = ctx->commrank; ierr = EPSSetDimensions(ctx->eps,ctx->nev,ctx->ncv,ctx->mpd);CHKERRQ(ierr); ierr = EPSKrylovSchurSetLocking(ctx->eps,ctx->lock);CHKERRQ(ierr); /* transfer options from eps->V */ ierr = EPSGetBV(ctx->eps,&V);CHKERRQ(ierr); if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } if (!((PetscObject)(eps->V))->type_name) { ierr = BVSetType(V,BVSVEC);CHKERRQ(ierr); } else { ierr = BVGetType(eps->V,&type);CHKERRQ(ierr); ierr = BVSetType(V,type);CHKERRQ(ierr); } ierr = BVGetOrthogonalization(eps->V,&orthog_type,&orthog_ref,&eta,&ob_type);CHKERRQ(ierr); ierr = BVSetOrthogonalization(V,orthog_type,orthog_ref,eta,ob_type);CHKERRQ(ierr); ctx->eps->which = eps->which; ctx->eps->max_it = eps->max_it; ctx->eps->tol = eps->tol; ctx->eps->purify = eps->purify; if (eps->tol==PETSC_DEFAULT) eps->tol = SLEPC_DEFAULT_TOL; ierr = EPSSetProblemType(ctx->eps,eps->problem_type);CHKERRQ(ierr); ierr = EPSSetUp(ctx->eps);CHKERRQ(ierr); ctx->eps->nconv = 0; ctx->eps->its = 0; for (i=0;ieps->ncv;i++) { ctx->eps->eigr[i] = 0.0; ctx->eps->eigi[i] = 0.0; ctx->eps->errest[i] = 0.0; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSliceGetInertia" static PetscErrorCode EPSSliceGetInertia(EPS eps,PetscReal shift,PetscInt *inertia,PetscInt *zeros) { PetscErrorCode ierr; KSP ksp; PC pc; Mat F; PetscReal nzshift; PetscFunctionBegin; if (shift >= PETSC_MAX_REAL) { /* Right-open interval */ if (inertia) *inertia = eps->n; } else if (shift <= PETSC_MIN_REAL) { if (inertia) *inertia = 0; if (zeros) *zeros = 0; } else { /* If the shift is zero, perturb it to a very small positive value. The goal is that the nonzero pattern is the same in all cases and reuse the symbolic factorizations */ nzshift = (shift==0.0)? 10.0/PETSC_MAX_REAL: shift; ierr = STSetShift(eps->st,nzshift);CHKERRQ(ierr); ierr = STSetUp(eps->st);CHKERRQ(ierr); ierr = STGetKSP(eps->st,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCFactorGetMatrix(pc,&F);CHKERRQ(ierr); ierr = MatGetInertia(F,inertia,zeros,NULL);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_KrylovSchur_Slice" PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS eps) { PetscErrorCode ierr; PetscBool issinv; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data,*ctx_glob; EPS_SR sr,sr_loc,sr_glob; PetscInt nEigs,dssz=1,i,zeros=0,off=0; PetscMPIInt nproc,rank,aux; PetscReal r; MPI_Request req; Mat A,B=NULL; PetscFunctionBegin; if (ctx->global) { if (eps->inta==0.0 && eps->intb==0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Must define a computational interval when using EPS_ALL"); if (eps->intb >= PETSC_MAX_REAL && eps->inta <= PETSC_MIN_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"The defined computational interval should have at least one of their sides bounded"); if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectrum slicing only available for symmetric/Hermitian eigenproblems"); if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs cannot be used with spectrum slicing"); if (!((PetscObject)(eps->st))->type_name) { /* default to shift-and-invert */ ierr = STSetType(eps->st,STSINVERT);CHKERRQ(ierr); } ierr = PetscObjectTypeCompareAny((PetscObject)eps->st,&issinv,STSINVERT,STCAYLEY,"");CHKERRQ(ierr); if (!issinv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Shift-and-invert or Cayley ST is needed for spectrum slicing"); if (eps->tol==PETSC_DEFAULT) eps->tol = SLEPC_DEFAULT_TOL*1e-2; /* use tighter tolerance */ if (!eps->max_it) eps->max_it = 100; if (ctx->nev==1) ctx->nev = PetscMin(40,eps->n); /* nev not set, use default value */ if (eps->n>10 && ctx->nev<10) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"nev cannot be less than 10 in spectrum slicing runs"); } eps->ops->backtransform = NULL; /* create spectrum slicing context and initialize it */ ierr = EPSSliceResetSR(eps);CHKERRQ(ierr); ierr = PetscNewLog(eps,&sr);CHKERRQ(ierr); ctx->sr = sr; sr->itsKs = 0; sr->nleap = 0; sr->nMAXCompl = eps->nev/4; sr->iterCompl = eps->max_it/4; sr->sPres = NULL; sr->nS = 0; if (ctx->npart==1 || ctx->global) { /* check presence of ends and finding direction */ if ((eps->inta > PETSC_MIN_REAL && eps->inta != 0.0) || eps->intb >= PETSC_MAX_REAL) { sr->int0 = eps->inta; sr->int1 = eps->intb; sr->dir = 1; if (eps->intb >= PETSC_MAX_REAL) { /* Right-open interval */ sr->hasEnd = PETSC_FALSE; } else sr->hasEnd = PETSC_TRUE; } else { sr->int0 = eps->intb; sr->int1 = eps->inta; sr->dir = -1; sr->hasEnd = PetscNot(eps->inta <= PETSC_MIN_REAL); } } if (ctx->global) { /* prevent computation of factorization in global eps */ ierr = STSetTransform(eps->st,PETSC_FALSE);CHKERRQ(ierr); ierr = EPSSetDimensions_Default(eps,ctx->nev,&ctx->ncv,&ctx->mpd);CHKERRQ(ierr); /* create subintervals and initialize auxiliary eps for slicing runs */ ierr = EPSSliceGetEPS(eps);CHKERRQ(ierr); sr_loc = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr; if (ctx->npart>1) { if ((sr->dir>0&&ctx->subc->color==0)||(sr->dir<0&&ctx->subc->color==ctx->npart-1)) sr->inertia0 = sr_loc->inertia0; ierr = MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);CHKERRQ(ierr); if (rank==0) { ierr = MPI_Bcast(&sr->inertia0,1,MPIU_INT,(sr->dir>0)?0:ctx->npart-1,ctx->commrank);CHKERRQ(ierr); } ierr = MPI_Bcast(&sr->inertia0,1,MPIU_INT,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ierr = PetscFree(ctx->nconv_loc);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->npart,&ctx->nconv_loc);CHKERRQ(ierr); ierr = MPI_Comm_size(((PetscObject)eps)->comm,&nproc);CHKERRQ(ierr); if (sr->dir<0) off = 1; if (nproc%ctx->npart==0) { /* subcommunicators with the same size */ ierr = PetscMPIIntCast(sr_loc->numEigs,&aux);CHKERRQ(ierr); ierr = MPI_Allgather(&aux,1,MPI_INT,ctx->nconv_loc,1,MPI_INT,ctx->commrank);CHKERRQ(ierr); ierr = MPI_Allgather(sr_loc->dir==sr->dir?&sr_loc->int0:&sr_loc->int1,1,MPIU_REAL,ctx->subintervals+off,1,MPIU_REAL,ctx->commrank);CHKERRQ(ierr); } else { ierr = MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);CHKERRQ(ierr); if (!rank) { ierr = PetscMPIIntCast(sr_loc->numEigs,&aux);CHKERRQ(ierr); ierr = MPI_Allgather(&aux,1,MPI_INT,ctx->nconv_loc,1,MPI_INT,ctx->commrank);CHKERRQ(ierr); ierr = MPI_Allgather(sr_loc->dir==sr->dir?&sr_loc->int0:&sr_loc->int1,1,MPIU_REAL,ctx->subintervals+off,1,MPIU_REAL,ctx->commrank);CHKERRQ(ierr); } ierr = PetscMPIIntCast(ctx->npart,&aux);CHKERRQ(ierr); ierr = MPI_Bcast(ctx->nconv_loc,aux,MPI_INT,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ierr = MPI_Bcast(ctx->subintervals+off,aux,MPIU_REAL,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); } nEigs = 0; for (i=0;inpart;i++) nEigs += ctx->nconv_loc[i]; } else { nEigs = sr_loc->numEigs; sr->inertia0 = sr_loc->inertia0; } sr->inertia1 = sr->inertia0+sr->dir*nEigs; sr->numEigs = nEigs; eps->nev = nEigs; eps->ncv = nEigs; eps->mpd = nEigs; } else { ctx_glob = (EPS_KRYLOVSCHUR*)ctx->eps->data; sr_glob = ctx_glob->sr; if (ctx->npart>1) { sr->dir = sr_glob->dir; sr->int0 = (sr->dir==1)?eps->inta:eps->intb; sr->int1 = (sr->dir==1)?eps->intb:eps->inta; if ((sr->dir>0&&ctx->subc->color==ctx->npart-1)||(sr->dir<0&&ctx->subc->color==0)) sr->hasEnd = sr_glob->hasEnd; else sr->hasEnd = PETSC_TRUE; } /* compute inertia0 */ ierr = EPSSliceGetInertia(eps,sr->int0,&sr->inertia0,ctx->detect?&zeros:NULL);CHKERRQ(ierr); if (zeros) { /* error in factorization */ if (ctx->npart==1 || ctx_glob->subintset || ((sr->dir>0 && ctx->subc->color==0) || (sr->dir<0 && ctx->subc->color==ctx->npart-1))) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_USER,"Found singular matrix for the transformed problem in an interval endpoint defined by user"); else { /* perturb shift */ sr->int0 *= (1.0+SLICE_PTOL); ierr = EPSSliceGetInertia(eps,sr->int0,&sr->inertia0,&zeros);CHKERRQ(ierr); if (zeros) SETERRQ1(((PetscObject)eps)->comm,PETSC_ERR_CONV_FAILED,"Inertia computation fails in %g",sr->int1); } } if (ctx->npart>1) { /* inertia1 is received from neighbour */ ierr = MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);CHKERRQ(ierr); if (!rank) { if ((sr->dir>0 && ctx->subc->color>0) || (sr->dir<0 && ctx->subc->colornpart-1)) { /* send inertia0 to neighbour0 */ ierr = MPI_Isend(&(sr->inertia0),1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req);CHKERRQ(ierr); ierr = MPI_Isend(&(sr->int0),1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req);CHKERRQ(ierr); } if ((sr->dir>0 && ctx->subc->colornpart-1)|| (sr->dir<0 && ctx->subc->color>0)) { /* receive inertia1 from neighbour1 */ ierr = MPI_Recv(&(sr->inertia1),1,MPIU_INT,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE);CHKERRQ(ierr); ierr = MPI_Recv(&(sr->int1),1,MPIU_REAL,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE);CHKERRQ(ierr); } } if ((sr->dir>0 && ctx->subc->colornpart-1)||(sr->dir<0 && ctx->subc->color>0)) { ierr = MPI_Bcast(&sr->inertia1,1,MPIU_INT,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ierr = MPI_Bcast(&sr->int1,1,MPIU_REAL,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); } else sr_glob->inertia1 = sr->inertia1; } /* last process in eps comm computes inertia1 */ if (ctx->npart==1 || ((sr->dir>0 && ctx->subc->color==ctx->npart-1) || (sr->dir<0 && ctx->subc->color==0))) { ierr = EPSSliceGetInertia(eps,sr->int1,&sr->inertia1,ctx->detect?&zeros:NULL);CHKERRQ(ierr); if (zeros) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_USER,"Found singular matrix for the transformed problem in an interval endpoint defined by user"); if (sr->hasEnd) { sr->dir = -sr->dir; r = sr->int0; sr->int0 = sr->int1; sr->int1 = r; i = sr->inertia0; sr->inertia0 = sr->inertia1; sr->inertia1 = i; } } /* number of eigenvalues in interval */ sr->numEigs = (sr->dir)*(sr->inertia1 - sr->inertia0); if (ctx->npart>1) { /* memory allocate for subinterval eigenpairs */ ierr = EPSSliceAllocateSolution(eps,1);CHKERRQ(ierr); } dssz = eps->ncv+1; } ierr = DSSetType(eps->ds,DSHEP);CHKERRQ(ierr); ierr = DSSetCompact(eps->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,dssz);CHKERRQ(ierr); /* keep state of subcomm matrices to check that the user does not modify them */ ierr = EPSGetOperators(eps,&A,&B);CHKERRQ(ierr); ierr = PetscObjectStateGet((PetscObject)A,&ctx->Astate);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)A,&ctx->Aid);CHKERRQ(ierr); if (B) { ierr = PetscObjectStateGet((PetscObject)B,&ctx->Bstate);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)B,&ctx->Bid);CHKERRQ(ierr); } else { ctx->Bstate=0; ctx->Bid=0; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSliceGatherEigenVectors" static PetscErrorCode EPSSliceGatherEigenVectors(EPS eps) { PetscErrorCode ierr; Vec v,vg,v_loc; IS is1,is2; VecScatter vec_sc; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscInt nloc,m0,n0,i,si,idx,*idx1,*idx2,j; PetscScalar *array; EPS_SR sr_loc; BV V_loc; PetscFunctionBegin; sr_loc = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr; V_loc = sr_loc->V; /* Gather parallel eigenvectors */ ierr = BVGetColumn(eps->V,0,&v);CHKERRQ(ierr); ierr = VecGetOwnershipRange(v,&n0,&m0);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&v);CHKERRQ(ierr); ierr = BVGetColumn(ctx->eps->V,0,&v);CHKERRQ(ierr); ierr = VecGetLocalSize(v,&nloc);CHKERRQ(ierr); ierr = BVRestoreColumn(ctx->eps->V,0,&v);CHKERRQ(ierr); ierr = PetscMalloc2(m0-n0,&idx1,m0-n0,&idx2);CHKERRQ(ierr); ierr = VecCreateMPI(PetscObjectComm((PetscObject)eps),nloc,PETSC_DECIDE,&vg);CHKERRQ(ierr); idx = -1; for (si=0;sinpart;si++) { j = 0; for (i=n0;in*si; } ierr = ISCreateGeneral(PetscObjectComm((PetscObject)eps),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr); ierr = ISCreateGeneral(PetscObjectComm((PetscObject)eps),(m0-n0),idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,0,&v);CHKERRQ(ierr); ierr = VecScatterCreate(v,is1,vg,is2,&vec_sc);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,0,&v);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); ierr = ISDestroy(&is2);CHKERRQ(ierr); for (i=0;inconv_loc[si];i++) { ierr = BVGetColumn(eps->V,++idx,&v);CHKERRQ(ierr); if (ctx->subc->color==si) { ierr = BVGetColumn(V_loc,i,&v_loc);CHKERRQ(ierr); ierr = VecGetArray(v_loc,&array);CHKERRQ(ierr); ierr = VecPlaceArray(vg,array);CHKERRQ(ierr); } ierr = VecScatterBegin(vec_sc,vg,v,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); ierr = VecScatterEnd(vec_sc,vg,v,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); if (ctx->subc->color==si) { ierr = VecResetArray(vg);CHKERRQ(ierr); ierr = VecRestoreArray(v_loc,&array);CHKERRQ(ierr); ierr = BVRestoreColumn(V_loc,i,&v_loc);CHKERRQ(ierr); } ierr = BVRestoreColumn(eps->V,idx,&v);CHKERRQ(ierr); } ierr = VecScatterDestroy(&vec_sc);CHKERRQ(ierr); } ierr = PetscFree2(idx1,idx2);CHKERRQ(ierr); ierr = VecDestroy(&vg);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSComputeVectors_Slice" /* EPSComputeVectors_Slice - Recover Eigenvectors from subcomunicators */ PetscErrorCode EPSComputeVectors_Slice(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; if (ctx->global && ctx->npart>1) { ierr = EPSComputeVectors(ctx->eps);CHKERRQ(ierr); ierr = EPSSliceGatherEigenVectors(eps);CHKERRQ(ierr); } PetscFunctionReturn(0); } #define SWAP(a,b,t) {t=a;a=b;b=t;} #undef __FUNCT__ #define __FUNCT__ "EPSSliceGetInertias" static PetscErrorCode EPSSliceGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscInt i=0,j,tmpi; PetscReal v,tmpr; EPS_shift s; PetscFunctionBegin; if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first"); if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()"); if (!ctx->sr->s0) { /* EPSSolve not called yet */ *n = 2; } else { *n = 1; s = ctx->sr->s0; while (s) { (*n)++; s = s->neighb[1]; } } ierr = PetscMalloc1(*n,shifts);CHKERRQ(ierr); ierr = PetscMalloc1(*n,inertias);CHKERRQ(ierr); if (!ctx->sr->s0) { /* EPSSolve not called yet */ (*shifts)[0] = ctx->sr->int0; (*shifts)[1] = ctx->sr->int1; (*inertias)[0] = ctx->sr->inertia0; (*inertias)[1] = ctx->sr->inertia1; } else { s = ctx->sr->s0; while (s) { (*shifts)[i] = s->value; (*inertias)[i++] = s->inertia; s = s->neighb[1]; } (*shifts)[i] = ctx->sr->int1; (*inertias)[i] = ctx->sr->inertia1; } /* remove possible duplicate in last position */ if ((*shifts)[(*n)-1]==(*shifts)[(*n)-2]) (*n)--; /* sort result */ for (i=0;i<*n;i++) { v = (*shifts)[i]; for (j=i+1;j<*n;j++) { if (v > (*shifts)[j]) { SWAP((*shifts)[i],(*shifts)[j],tmpr); SWAP((*inertias)[i],(*inertias)[j],tmpi); v = (*shifts)[i]; } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSliceGatherSolution" static PetscErrorCode EPSSliceGatherSolution(EPS eps) { PetscErrorCode ierr; PetscMPIInt rank,nproc; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscInt i,idx,j; PetscInt *perm_loc,off=0,*inertias_loc,ns; PetscScalar *eigr_loc; EPS_SR sr_loc; PetscReal *shifts_loc; PetscMPIInt *disp,*ns_loc,aux; PetscFunctionBegin; eps->nconv = 0; for (i=0;inpart;i++) eps->nconv += ctx->nconv_loc[i]; sr_loc = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr; /* Gather the shifts used and the inertias computed */ ierr = EPSSliceGetInertias(ctx->eps,&ns,&shifts_loc,&inertias_loc);CHKERRQ(ierr); if (ctx->sr->dir>0 && shifts_loc[ns-1]==sr_loc->int1 && ctx->subc->colornpart-1) ns--; if (ctx->sr->dir<0 && shifts_loc[ns-1]==sr_loc->int0 && ctx->subc->color>0) { ns--; for (i=0;inpart,&ns_loc);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);CHKERRQ(ierr); ierr = PetscMPIIntCast(ns,&aux);CHKERRQ(ierr); if (rank==0) { ierr = MPI_Allgather(&aux,1,MPI_INT,ns_loc,1,MPI_INT,ctx->commrank);CHKERRQ(ierr); } ierr = PetscMPIIntCast(ctx->npart,&aux);CHKERRQ(ierr); ierr = MPI_Bcast(ns_loc,aux,MPI_INT,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ctx->nshifts = 0; for (i=0;inpart;i++) ctx->nshifts += ns_loc[i]; ierr = PetscFree(ctx->inertias);CHKERRQ(ierr); ierr = PetscFree(ctx->shifts);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->nshifts,&ctx->inertias);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->nshifts,&ctx->shifts);CHKERRQ(ierr); /* Gather eigenvalues (same ranks have fully set of eigenvalues)*/ eigr_loc = sr_loc->eigr; perm_loc = sr_loc->perm; ierr = MPI_Comm_size(((PetscObject)eps)->comm,&nproc);CHKERRQ(ierr); ierr = PetscMalloc1(ctx->npart,&disp);CHKERRQ(ierr); disp[0] = 0; for (i=1;inpart;i++) disp[i] = disp[i-1]+ctx->nconv_loc[i-1]; if (nproc%ctx->npart==0) { /* subcommunicators with the same size */ ierr = PetscMPIIntCast(sr_loc->numEigs,&aux);CHKERRQ(ierr); ierr = MPI_Allgatherv(eigr_loc,aux,MPIU_SCALAR,eps->eigr,ctx->nconv_loc,disp,MPIU_SCALAR,ctx->commrank);CHKERRQ(ierr); /* eigenvalues */ ierr = MPI_Allgatherv(perm_loc,aux,MPIU_INT,eps->perm,ctx->nconv_loc,disp,MPIU_INT,ctx->commrank);CHKERRQ(ierr); /* perm */ for (i=1;inpart;i++) disp[i] = disp[i-1]+ns_loc[i-1]; ierr = PetscMPIIntCast(ns,&aux);CHKERRQ(ierr); ierr = MPI_Allgatherv(shifts_loc,aux,MPIU_REAL,ctx->shifts,ns_loc,disp,MPIU_REAL,ctx->commrank);CHKERRQ(ierr); /* shifts */ ierr = MPI_Allgatherv(inertias_loc,aux,MPIU_INT,ctx->inertias,ns_loc,disp,MPIU_INT,ctx->commrank);CHKERRQ(ierr); /* inertias */ ierr = MPI_Allreduce(&sr_loc->itsKs,&eps->its,1,MPIU_INT,MPI_SUM,ctx->commrank);CHKERRQ(ierr); } else { /* subcommunicators with different size */ ierr = MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);CHKERRQ(ierr); if (rank==0) { ierr = PetscMPIIntCast(sr_loc->numEigs,&aux);CHKERRQ(ierr); ierr = MPI_Allgatherv(eigr_loc,aux,MPIU_SCALAR,eps->eigr,ctx->nconv_loc,disp,MPIU_SCALAR,ctx->commrank);CHKERRQ(ierr); /* eigenvalues */ ierr = MPI_Allgatherv(perm_loc,aux,MPIU_INT,eps->perm,ctx->nconv_loc,disp,MPIU_INT,ctx->commrank);CHKERRQ(ierr); /* perm */ for (i=1;inpart;i++) disp[i] = disp[i-1]+ns_loc[i-1]; ierr = PetscMPIIntCast(ns,&aux);CHKERRQ(ierr); ierr = MPI_Allgatherv(shifts_loc,aux,MPIU_REAL,ctx->shifts,ns_loc,disp,MPIU_REAL,ctx->commrank);CHKERRQ(ierr); /* shifts */ ierr = MPI_Allgatherv(inertias_loc,aux,MPIU_INT,ctx->inertias,ns_loc,disp,MPIU_INT,ctx->commrank);CHKERRQ(ierr); /* inertias */ ierr = MPI_Allreduce(&sr_loc->itsKs,&eps->its,1,MPIU_INT,MPI_SUM,ctx->commrank);CHKERRQ(ierr); } ierr = PetscMPIIntCast(eps->nconv,&aux);CHKERRQ(ierr); ierr = MPI_Bcast(eps->eigr,aux,MPIU_SCALAR,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ierr = MPI_Bcast(eps->perm,aux,MPIU_INT,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ierr = MPI_Bcast(ctx->shifts,ctx->nshifts,MPIU_REAL,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ierr = PetscMPIIntCast(ctx->nshifts,&aux);CHKERRQ(ierr); ierr = MPI_Bcast(ctx->inertias,aux,MPIU_INT,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); ierr = MPI_Bcast(&eps->its,1,MPIU_INT,0,PetscSubcommChild(ctx->subc));CHKERRQ(ierr); } /* Update global array eps->perm */ idx = ctx->nconv_loc[0]; for (i=1;inpart;i++) { off += ctx->nconv_loc[i-1]; for (j=0;jnconv_loc[i];j++) eps->perm[idx++] += off; } /* Gather parallel eigenvectors */ ierr = PetscFree(ns_loc);CHKERRQ(ierr); ierr = PetscFree(disp);CHKERRQ(ierr); ierr = PetscFree(shifts_loc);CHKERRQ(ierr); ierr = PetscFree(inertias_loc);CHKERRQ(ierr); PetscFunctionReturn(0); } /* Fills the fields of a shift structure */ #undef __FUNCT__ #define __FUNCT__ "EPSCreateShift" static PetscErrorCode EPSCreateShift(EPS eps,PetscReal val,EPS_shift neighb0,EPS_shift neighb1) { PetscErrorCode ierr; EPS_shift s,*pending2; PetscInt i; EPS_SR sr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; sr = ctx->sr; ierr = PetscNewLog(eps,&s);CHKERRQ(ierr); s->value = val; s->neighb[0] = neighb0; if (neighb0) neighb0->neighb[1] = s; s->neighb[1] = neighb1; if (neighb1) neighb1->neighb[0] = s; s->comp[0] = PETSC_FALSE; s->comp[1] = PETSC_FALSE; s->index = -1; s->neigs = 0; s->nconv[0] = s->nconv[1] = 0; s->nsch[0] = s->nsch[1]=0; /* Inserts in the stack of pending shifts */ /* If needed, the array is resized */ if (sr->nPend >= sr->maxPend) { sr->maxPend *= 2; ierr = PetscMalloc1(sr->maxPend,&pending2);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,sizeof(EPS_shift));CHKERRQ(ierr); for (i=0;inPend;i++) pending2[i] = sr->pending[i]; ierr = PetscFree(sr->pending);CHKERRQ(ierr); sr->pending = pending2; } sr->pending[sr->nPend++]=s; PetscFunctionReturn(0); } /* Prepare for Rational Krylov update */ #undef __FUNCT__ #define __FUNCT__ "EPSPrepareRational" static PetscErrorCode EPSPrepareRational(EPS eps) { EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscErrorCode ierr; PetscInt dir,i,k,ld,nv; PetscScalar *A; EPS_SR sr = ctx->sr; Vec v; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); dir = (sr->sPres->neighb[0] == sr->sPrev)?1:-1; dir*=sr->dir; k = 0; for (i=0;inS;i++) { if (dir*PetscRealPart(sr->S[i])>0.0) { sr->S[k] = sr->S[i]; sr->S[sr->nS+k] = sr->S[sr->nS+i]; ierr = BVGetColumn(sr->Vnext,k,&v);CHKERRQ(ierr); ierr = BVCopyVec(eps->V,eps->nconv+i,v);CHKERRQ(ierr); ierr = BVRestoreColumn(sr->Vnext,k,&v);CHKERRQ(ierr); k++; if (k>=sr->nS/2)break; } } /* Copy to DS */ ierr = DSGetArray(eps->ds,DS_MAT_A,&A);CHKERRQ(ierr); ierr = PetscMemzero(A,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;iS[i]; A[k+i*ld] = sr->S[sr->nS+i]; } sr->nS = k; ierr = DSRestoreArray(eps->ds,DS_MAT_A,&A);CHKERRQ(ierr); ierr = DSGetDimensions(eps->ds,&nv,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,0,k);CHKERRQ(ierr); /* Append u to V */ ierr = BVGetColumn(sr->Vnext,sr->nS,&v);CHKERRQ(ierr); ierr = BVCopyVec(eps->V,sr->nv,v);CHKERRQ(ierr); ierr = BVRestoreColumn(sr->Vnext,sr->nS,&v);CHKERRQ(ierr); PetscFunctionReturn(0); } /* Provides next shift to be computed */ #undef __FUNCT__ #define __FUNCT__ "EPSExtractShift" static PetscErrorCode EPSExtractShift(EPS eps) { PetscErrorCode ierr; PetscInt iner,zeros=0; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; EPS_SR sr; PetscReal newShift; EPS_shift sPres; PetscFunctionBegin; sr = ctx->sr; if (sr->nPend > 0) { sr->sPrev = sr->sPres; sr->sPres = sr->pending[--sr->nPend]; sPres = sr->sPres; ierr = EPSSliceGetInertia(eps,sPres->value,&iner,ctx->detect?&zeros:NULL);CHKERRQ(ierr); if (zeros) { newShift = sPres->value*(1.0+SLICE_PTOL); if (sr->dir*(sPres->neighb[0] && newShift-sPres->neighb[0]->value) < 0) newShift = (sPres->value+sPres->neighb[0]->value)/2; else if (sPres->neighb[1] && sr->dir*(sPres->neighb[1]->value-newShift) < 0) newShift = (sPres->value+sPres->neighb[1]->value)/2; ierr = EPSSliceGetInertia(eps,newShift,&iner,&zeros);CHKERRQ(ierr); if (zeros) SETERRQ1(((PetscObject)eps)->comm,PETSC_ERR_CONV_FAILED,"Inertia computation fails in %g",newShift); sPres->value = newShift; } sr->sPres->inertia = iner; eps->target = sr->sPres->value; eps->reason = EPS_CONVERGED_ITERATING; eps->its = 0; } else sr->sPres = NULL; PetscFunctionReturn(0); } /* Symmetric KrylovSchur adapted to spectrum slicing: Allows searching an specific amount of eigenvalues in the subintervals left and right. Returns whether the search has succeeded */ #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchur_Slice" static PetscErrorCode EPSKrylovSchur_Slice(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscInt i,conv,k,l,ld,nv,*iwork,j,p; Mat U; PetscScalar *Q,*A,rtmp; PetscReal *a,*b,beta; PetscBool breakdown; PetscInt count0,count1; PetscReal lambda; EPS_shift sPres; PetscBool complIterating; PetscBool sch0,sch1; PetscInt iterCompl=0,n0,n1; EPS_SR sr = ctx->sr; PetscFunctionBegin; /* Spectrum slicing data */ sPres = sr->sPres; complIterating =PETSC_FALSE; sch1 = sch0 = PETSC_TRUE; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = PetscMalloc1(2*ld,&iwork);CHKERRQ(ierr); count0=0;count1=0; /* Found on both sides */ if (sr->nS > 0 && (sPres->neighb[0] == sr->sPrev || sPres->neighb[1] == sr->sPrev)) { /* Rational Krylov */ ierr = DSTranslateRKS(eps->ds,sr->sPrev->value-sPres->value);CHKERRQ(ierr); ierr = DSGetDimensions(eps->ds,NULL,NULL,NULL,&l,NULL);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,l+1,0,0,0);CHKERRQ(ierr); ierr = BVSetActiveColumns(eps->V,0,l+1);CHKERRQ(ierr); ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,0,l+1);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); } else { /* Get the starting Lanczos vector */ ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); l = 0; } /* Restart loop */ while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; sr->itsKs++; /* Compute an nv-step Lanczos factorization */ nv = PetscMin(eps->nconv+eps->mpd,eps->ncv); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); b = a + ld; ierr = EPSFullLanczos(eps,a,b,eps->nconv+l,&nv,&breakdown);CHKERRQ(ierr); sr->nv = nv; beta = b[nv-1]; ierr = DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(eps->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); } ierr = BVSetActiveColumns(eps->V,eps->nconv,nv);CHKERRQ(ierr); /* Solve projected problem and compute residual norm estimates */ if (eps->its == 1 && l > 0) {/* After rational update */ ierr = DSGetArray(eps->ds,DS_MAT_A,&A);CHKERRQ(ierr); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); b = a + ld; k = eps->nconv+l; A[k*ld+k-1] = A[(k-1)*ld+k]; A[k*ld+k] = a[k]; for (j=k+1; j< nv; j++) { A[j*ld+j] = a[j]; A[j*ld+j-1] = b[j-1] ; A[(j-1)*ld+j] = b[j-1]; } ierr = DSRestoreArray(eps->ds,DS_MAT_A,&A);CHKERRQ(ierr); ierr = DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSSolve(eps->ds,eps->eigr,NULL);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSSetCompact(eps->ds,PETSC_TRUE);CHKERRQ(ierr); } else { /* Restart */ ierr = DSSolve(eps->ds,eps->eigr,NULL);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,NULL,NULL,NULL,NULL);CHKERRQ(ierr); } /* Residual */ ierr = EPSKrylovConvergence(eps,PETSC_TRUE,eps->nconv,nv-eps->nconv,beta,1.0,&k);CHKERRQ(ierr); if (ctx->lock) { /* Check convergence */ ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); b = a + ld; conv = 0; j = k = eps->nconv; for (i=eps->nconv;ierrest[i] < eps->tol) conv++; for (i=eps->nconv;ierrest[i] < eps->tol) { iwork[j++]=i; } else iwork[conv+k++]=i; } for (i=eps->nconv;ieigr[i]); b[i]=eps->errest[i]; } for (i=eps->nconv;ieigr[i] = a[iwork[i]]; eps->errest[i] = b[iwork[i]]; } for (i=eps->nconv;ieigr[i]); b[i]=eps->errest[i]; } ierr = DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); for (i=eps->nconv;ids,DS_MAT_Q,&Q);CHKERRQ(ierr); k=eps->nconv+conv; } /* Checking values obtained for completing */ for (i=0;iback[i]=eps->eigr[i]; } ierr = STBackTransform(eps->st,k,sr->back,eps->eigi);CHKERRQ(ierr); count0=count1=0; for (i=0;iback[i]); if (((sr->dir)*(sPres->value - lambda) > 0) && ((sr->dir)*(lambda - sPres->ext[0]) > 0)) count0++; if (((sr->dir)*(lambda - sPres->value) > 0) && ((sr->dir)*(sPres->ext[1] - lambda) > 0)) count1++; } if (k>eps->nev && eps->ncv-k<5) eps->reason = EPS_CONVERGED_TOL; else { /* Checks completion */ if ((!sch0||count0 >= sPres->nsch[0]) && (!sch1 ||count1 >= sPres->nsch[1])) { eps->reason = EPS_CONVERGED_TOL; } else { if (!complIterating && eps->its >= eps->max_it) eps->reason = EPS_DIVERGED_ITS; if (complIterating) { if (--iterCompl <= 0) eps->reason = EPS_DIVERGED_ITS; } else if (k >= eps->nev) { n0 = sPres->nsch[0]-count0; n1 = sPres->nsch[1]-count1; if (sr->iterCompl>0 && ((n0>0 && n0<= sr->nMAXCompl)||(n1>0&&n1<=sr->nMAXCompl))) { /* Iterating for completion*/ complIterating = PETSC_TRUE; if (n0 >sr->nMAXCompl)sch0 = PETSC_FALSE; if (n1 >sr->nMAXCompl)sch1 = PETSC_FALSE; iterCompl = sr->iterCompl; } else eps->reason = EPS_CONVERGED_TOL; } } } /* Update l */ if (eps->reason == EPS_CONVERGED_ITERATING) l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep)); else l = 0; if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */ if (breakdown) l=0; if (eps->reason == EPS_CONVERGED_ITERATING) { if (breakdown) { /* Start a new Lanczos factorization */ ierr = PetscInfo2(eps,"Breakdown in Krylov-Schur method (it=%D norm=%g)\n",eps->its,(double)beta);CHKERRQ(ierr); ierr = EPSGetStartVector(eps,k,&breakdown);CHKERRQ(ierr); if (breakdown) { eps->reason = EPS_DIVERGED_BREAKDOWN; ierr = PetscInfo(eps,"Unable to generate more start vectors\n");CHKERRQ(ierr); } } else { /* Prepare the Rayleigh quotient for restart */ ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); b = a + ld; for (i=k;ieigr[i]); b[i] = PetscRealPart(Q[nv-1+i*ld]*beta); } ierr = DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); } } /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */ ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,eps->nconv,k+l);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); /* Normalize u and append it to V */ if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) { ierr = BVCopyColumn(eps->V,nv,k+l);CHKERRQ(ierr); } eps->nconv = k; if (eps->reason != EPS_CONVERGED_ITERATING) { /* Store approximated values for next shift */ ierr = DSGetArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); sr->nS = l; for (i=0;iS[i] = eps->eigr[i+k];/* Diagonal elements */ sr->S[i+l] = Q[nv-1+(i+k)*ld]*beta; /* Out of diagonal elements */ } ierr = DSRestoreArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); } } /* Check for completion */ for (i=0;i< eps->nconv; i++) { if ((sr->dir)*PetscRealPart(eps->eigr[i])>0) sPres->nconv[1]++; else sPres->nconv[0]++; } sPres->comp[0] = PetscNot(count0 < sPres->nsch[0]); sPres->comp[1] = PetscNot(count1 < sPres->nsch[1]); if (count0 > sPres->nsch[0] || count1 > sPres->nsch[1])SETERRQ(PetscObjectComm((PetscObject)eps),1,"Mismatch between number of values found and information from inertia, consider using EPSKrylovSchurSetDetectZeros()"); ierr = PetscFree(iwork);CHKERRQ(ierr); PetscFunctionReturn(0); } /* Obtains value of subsequent shift */ #undef __FUNCT__ #define __FUNCT__ "EPSGetNewShiftValue" static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS) { PetscReal lambda,d_prev; PetscInt i,idxP; EPS_SR sr; EPS_shift sPres,s; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; sr = ctx->sr; sPres = sr->sPres; if (sPres->neighb[side]) { /* Completing a previous interval */ if (!sPres->neighb[side]->neighb[side] && sPres->neighb[side]->nconv[side]==0) { /* One of the ends might be too far from eigenvalues */ if (side) *newS = (sPres->value + PetscRealPart(sr->eigr[sr->perm[sr->indexEig-1]]))/2; else *newS = (sPres->value + PetscRealPart(sr->eigr[sr->perm[0]]))/2; } else *newS=(sPres->value + sPres->neighb[side]->value)/2; } else { /* (Only for side=1). Creating a new interval. */ if (sPres->neigs==0) {/* No value has been accepted*/ if (sPres->neighb[0]) { /* Multiplying by 10 the previous distance */ *newS = sPres->value + 10*(sr->dir)*PetscAbsReal(sPres->value - sPres->neighb[0]->value); sr->nleap++; /* Stops when the interval is open and no values are found in the last 5 shifts (there might be infinite eigenvalues) */ if (!sr->hasEnd && sr->nleap > 5) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unable to compute the wanted eigenvalues with open interval"); } else { /* First shift */ if (eps->nconv != 0) { /* Unaccepted values give information for next shift */ idxP=0;/* Number of values left from shift */ for (i=0;inconv;i++) { lambda = PetscRealPart(eps->eigr[i]); if ((sr->dir)*(lambda - sPres->value) <0) idxP++; else break; } /* Avoiding subtraction of eigenvalues (might be the same).*/ if (idxP>0) { d_prev = PetscAbsReal(sPres->value - PetscRealPart(eps->eigr[0]))/(idxP+0.3); } else { d_prev = PetscAbsReal(sPres->value - PetscRealPart(eps->eigr[eps->nconv-1]))/(eps->nconv+0.3); } *newS = sPres->value + ((sr->dir)*d_prev*eps->nev)/2; } else { /* No values found, no information for next shift */ SETERRQ(PetscObjectComm((PetscObject)eps),1,"First shift renders no information"); } } } else { /* Accepted values found */ sr->nleap = 0; /* Average distance of values in previous subinterval */ s = sPres->neighb[0]; while (s && PetscAbs(s->inertia - sPres->inertia)==0) { s = s->neighb[0];/* Looking for previous shifts with eigenvalues within */ } if (s) { d_prev = PetscAbsReal((sPres->value - s->value)/(sPres->inertia - s->inertia)); } else { /* First shift. Average distance obtained with values in this shift */ /* first shift might be too far from first wanted eigenvalue (no values found outside the interval)*/ if ((sr->dir)*(PetscRealPart(sr->eigr[0])-sPres->value)>0 && PetscAbsReal((PetscRealPart(sr->eigr[sr->indexEig-1]) - PetscRealPart(sr->eigr[0]))/PetscRealPart(sr->eigr[0])) > PetscSqrtReal(eps->tol)) { d_prev = PetscAbsReal((PetscRealPart(sr->eigr[sr->indexEig-1]) - PetscRealPart(sr->eigr[0])))/(sPres->neigs+0.3); } else { d_prev = PetscAbsReal(PetscRealPart(sr->eigr[sr->indexEig-1]) - sPres->value)/(sPres->neigs+0.3); } } /* Average distance is used for next shift by adding it to value on the right or to shift */ if ((sr->dir)*(PetscRealPart(sr->eigr[sPres->index + sPres->neigs -1]) - sPres->value)>0) { *newS = PetscRealPart(sr->eigr[sPres->index + sPres->neigs -1])+ ((sr->dir)*d_prev*(eps->nev))/2; } else { /* Last accepted value is on the left of shift. Adding to shift */ *newS = sPres->value + ((sr->dir)*d_prev*(eps->nev))/2; } } /* End of interval can not be surpassed */ if ((sr->dir)*(sr->int1 - *newS) < 0) *newS = sr->int1; }/* of neighb[side]==null */ PetscFunctionReturn(0); } /* Function for sorting an array of real values */ #undef __FUNCT__ #define __FUNCT__ "sortRealEigenvalues" static PetscErrorCode sortRealEigenvalues(PetscScalar *r,PetscInt *perm,PetscInt nr,PetscBool prev,PetscInt dir) { PetscReal re; PetscInt i,j,tmp; PetscFunctionBegin; if (!prev) for (i=0;i=0 && dir*(re - PetscRealPart(r[perm[j]])) <= 0) { tmp = perm[j]; perm[j] = perm[j+1]; perm[j+1] = tmp; j--; } } PetscFunctionReturn(0); } /* Stores the pairs obtained since the last shift in the global arrays */ #undef __FUNCT__ #define __FUNCT__ "EPSStoreEigenpairs" static PetscErrorCode EPSStoreEigenpairs(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscReal lambda,err,norm; PetscInt i,count; PetscBool iscayley; EPS_SR sr = ctx->sr; EPS_shift sPres; Vec v,w; PetscFunctionBegin; sPres = sr->sPres; sPres->index = sr->indexEig; count = sr->indexEig; /* Back-transform */ ierr = STBackTransform(eps->st,eps->nconv,eps->eigr,eps->eigi);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)eps->st,STCAYLEY,&iscayley);CHKERRQ(ierr); /* Sort eigenvalues */ ierr = sortRealEigenvalues(eps->eigr,eps->perm,eps->nconv,PETSC_FALSE,sr->dir);CHKERRQ(ierr); /* Values stored in global array */ for (i=0;inconv;i++) { lambda = PetscRealPart(eps->eigr[eps->perm[i]]); err = eps->errest[eps->perm[i]]; if ((sr->dir)*(lambda - sPres->ext[0]) > 0 && (sr->dir)*(sPres->ext[1] - lambda) > 0) {/* Valid value */ if (count>=sr->numEigs) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unexpected error in Spectrum Slicing"); sr->eigr[count] = lambda; sr->errest[count] = err; /* Explicit purification */ if (eps->purify) { ierr = BVGetColumn(sr->V,count,&v);CHKERRQ(ierr); ierr = BVGetColumn(eps->V,eps->perm[i],&w);CHKERRQ(ierr); ierr = STApply(eps->st,w,v);CHKERRQ(ierr); ierr = BVRestoreColumn(sr->V,count,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,eps->perm[i],&w);CHKERRQ(ierr); ierr = BVNormColumn(sr->V,count,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(sr->V,count,1.0/norm);CHKERRQ(ierr); } else { ierr = BVGetColumn(eps->V,eps->perm[i],&w);CHKERRQ(ierr); ierr = BVInsertVec(sr->V,count,w);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,eps->perm[i],&w);CHKERRQ(ierr); ierr = BVNormColumn(sr->V,count,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(sr->V,count,1.0/norm);CHKERRQ(ierr); } count++; } } sPres->neigs = count - sr->indexEig; sr->indexEig = count; /* Global ordering array updating */ ierr = sortRealEigenvalues(sr->eigr,sr->perm,count,PETSC_TRUE,sr->dir);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSLookForDeflation" static PetscErrorCode EPSLookForDeflation(EPS eps) { PetscErrorCode ierr; PetscReal val; PetscInt i,count0=0,count1=0; EPS_shift sPres; PetscInt ini,fin,k,idx0,idx1; EPS_SR sr; Vec v; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; sr = ctx->sr; sPres = sr->sPres; if (sPres->neighb[0]) ini = (sr->dir)*(sPres->neighb[0]->inertia - sr->inertia0); else ini = 0; fin = sr->indexEig; /* Selection of ends for searching new values */ if (!sPres->neighb[0]) sPres->ext[0] = sr->int0;/* First shift */ else sPres->ext[0] = sPres->neighb[0]->value; if (!sPres->neighb[1]) { if (sr->hasEnd) sPres->ext[1] = sr->int1; else sPres->ext[1] = (sr->dir > 0)?PETSC_MAX_REAL:PETSC_MIN_REAL; } else sPres->ext[1] = sPres->neighb[1]->value; /* Selection of values between right and left ends */ for (i=ini;ieigr[sr->perm[i]]); /* Values to the right of left shift */ if ((sr->dir)*(val - sPres->ext[1]) < 0) { if ((sr->dir)*(val - sPres->value) < 0) count0++; else count1++; } else break; } /* The number of values on each side are found */ if (sPres->neighb[0]) { sPres->nsch[0] = (sr->dir)*(sPres->inertia - sPres->neighb[0]->inertia)-count0; if (sPres->nsch[0]<0)SETERRQ(PetscObjectComm((PetscObject)eps),1,"Mismatch between number of values found and information from inertia, consider using EPSKrylovSchurSetDetectZeros()"); } else sPres->nsch[0] = 0; if (sPres->neighb[1]) { sPres->nsch[1] = (sr->dir)*(sPres->neighb[1]->inertia - sPres->inertia) - count1; if (sPres->nsch[1]<0)SETERRQ(PetscObjectComm((PetscObject)eps),1,"Mismatch between number of values found and information from inertia, consider using EPSKrylovSchurSetDetectZeros()"); } else sPres->nsch[1] = (sr->dir)*(sr->inertia1 - sPres->inertia); /* Completing vector of indexes for deflation */ idx0 = ini; idx1 = ini+count0+count1; k=0; for (i=idx0;iidxDef[k++]=sr->perm[i]; ierr = BVDuplicateResize(eps->V,k+eps->ncv+1,&sr->Vnext);CHKERRQ(ierr); ierr = BVSetNumConstraints(sr->Vnext,k);CHKERRQ(ierr); for (i=0;iVnext,-i-1,&v);CHKERRQ(ierr); ierr = BVCopyVec(sr->V,sr->idxDef[i],v);CHKERRQ(ierr); ierr = BVRestoreColumn(sr->Vnext,-i-1,&v);CHKERRQ(ierr); } /* For rational Krylov */ if (sr->nS>0 && (sr->sPrev == sr->sPres->neighb[0] || sr->sPrev == sr->sPres->neighb[1])) { ierr = EPSPrepareRational(eps);CHKERRQ(ierr); } eps->nconv = 0; /* Get rid of temporary Vnext */ ierr = BVDestroy(&eps->V);CHKERRQ(ierr); eps->V = sr->Vnext; sr->Vnext = NULL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_KrylovSchur_Slice" PetscErrorCode EPSSolve_KrylovSchur_Slice(EPS eps) { PetscErrorCode ierr; PetscInt i,lds; PetscReal newS; EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data; EPS_SR sr=ctx->sr; Mat A,B=NULL; PetscObjectState Astate,Bstate=0; PetscObjectId Aid,Bid=0; PetscFunctionBegin; ierr = PetscCitationsRegister(citation,&cited);CHKERRQ(ierr); if (ctx->global) { ierr = EPSSolve_KrylovSchur_Slice(ctx->eps);CHKERRQ(ierr); ctx->eps->state = EPS_STATE_SOLVED; eps->reason = EPS_CONVERGED_TOL; if (ctx->npart>1) { /* Gather solution from subsolvers */ ierr = EPSSliceGatherSolution(eps);CHKERRQ(ierr); } else { eps->nconv = sr->numEigs; eps->its = ctx->eps->its; ierr = PetscFree(ctx->inertias);CHKERRQ(ierr); ierr = PetscFree(ctx->shifts);CHKERRQ(ierr); ierr = EPSSliceGetInertias(ctx->eps,&ctx->nshifts,&ctx->shifts,&ctx->inertias);CHKERRQ(ierr); } } else { if (ctx->npart==1) { sr->eigr = ctx->eps->eigr; sr->eigi = ctx->eps->eigi; sr->perm = ctx->eps->perm; sr->errest = ctx->eps->errest; sr->V = ctx->eps->V; } /* Check that the user did not modify subcomm matrices */ ierr = EPSGetOperators(eps,&A,&B);CHKERRQ(ierr); ierr = PetscObjectStateGet((PetscObject)A,&Astate);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)A,&Aid);CHKERRQ(ierr); if (B) { ierr = PetscObjectStateGet((PetscObject)B,&Bstate);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)B,&Bid);CHKERRQ(ierr); } if (Astate!=ctx->Astate || (B && Bstate!=ctx->Bstate) || Aid!=ctx->Aid || (B && Bid!=ctx->Bid)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Subcomm matrices have been modified by user"); /* Only with eigenvalues present in the interval ...*/ if (sr->numEigs==0) { eps->reason = EPS_CONVERGED_TOL; PetscFunctionReturn(0); } /* Array of pending shifts */ sr->maxPend = 100; /* Initial size */ sr->nPend = 0; ierr = PetscMalloc1(sr->maxPend,&sr->pending);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,(sr->maxPend)*sizeof(EPS_shift));CHKERRQ(ierr); ierr = EPSCreateShift(eps,sr->int0,NULL,NULL);CHKERRQ(ierr); /* extract first shift */ sr->sPrev = NULL; sr->sPres = sr->pending[--sr->nPend]; sr->sPres->inertia = sr->inertia0; eps->target = sr->sPres->value; sr->s0 = sr->sPres; sr->indexEig = 0; /* Memory reservation for auxiliary variables */ lds = PetscMin(eps->mpd,eps->ncv); ierr = PetscCalloc1(lds*lds,&sr->S);CHKERRQ(ierr); ierr = PetscMalloc1(eps->ncv,&sr->back);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,(sr->numEigs+2*eps->ncv)*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;inumEigs;i++) { sr->eigr[i] = 0.0; sr->eigi[i] = 0.0; sr->errest[i] = 0.0; sr->perm[i] = i; } /* Vectors for deflation */ ierr = PetscMalloc1(sr->numEigs,&sr->idxDef);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)eps,sr->numEigs*sizeof(PetscInt));CHKERRQ(ierr); sr->indexEig = 0; /* Main loop */ while (sr->sPres) { /* Search for deflation */ ierr = EPSLookForDeflation(eps);CHKERRQ(ierr); /* KrylovSchur */ ierr = EPSKrylovSchur_Slice(eps);CHKERRQ(ierr); ierr = EPSStoreEigenpairs(eps);CHKERRQ(ierr); /* Select new shift */ if (!sr->sPres->comp[1]) { ierr = EPSGetNewShiftValue(eps,1,&newS);CHKERRQ(ierr); ierr = EPSCreateShift(eps,newS,sr->sPres,sr->sPres->neighb[1]);CHKERRQ(ierr); } if (!sr->sPres->comp[0]) { /* Completing earlier interval */ ierr = EPSGetNewShiftValue(eps,0,&newS);CHKERRQ(ierr); ierr = EPSCreateShift(eps,newS,sr->sPres->neighb[0],sr->sPres);CHKERRQ(ierr); } /* Preparing for a new search of values */ ierr = EPSExtractShift(eps);CHKERRQ(ierr); } /* Updating eps values prior to exit */ ierr = PetscFree(sr->S);CHKERRQ(ierr); ierr = PetscFree(sr->idxDef);CHKERRQ(ierr); ierr = PetscFree(sr->pending);CHKERRQ(ierr); ierr = PetscFree(sr->back);CHKERRQ(ierr); ierr = BVDuplicateResize(eps->V,eps->ncv+1,&sr->Vnext);CHKERRQ(ierr); ierr = BVSetNumConstraints(sr->Vnext,0);CHKERRQ(ierr); ierr = BVDestroy(&eps->V);CHKERRQ(ierr); eps->V = sr->Vnext; eps->nconv = sr->indexEig; eps->reason = EPS_CONVERGED_TOL; eps->its = sr->itsKs; eps->nds = 0; } PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/krylov/krylovschur/makefile.html0000644000175000017500000000500713107004621023253 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = krylovschur.c ks-symm.c ks-slice.c ks-indef.c
SOURCEF  =
SOURCEH  = krylovschur.h
LIBBASE  = libslepceps
DIRS     =
MANSEC   = EPS
LOCDIR   = src/eps/impls/krylov/krylovschur/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/eps/impls/krylov/krylovschur/ks-slice.c.html0000644000175000017500000037105213107004621023437 0ustar jromanjroman
Actual source code: ks-slice.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "krylovschur"

  5:    Method: Krylov-Schur with spectrum slicing for symmetric eigenproblems

  7:    References:

  9:        [1] R.G. Grimes et al., "A shifted block Lanczos algorithm for
 10:            solving sparse symmetric generalized eigenproblems", SIAM J.
 11:            Matrix Anal. Appl. 15(1):228-272, 1994.

 13:        [2] C. Campos and J.E. Roman, "Spectrum slicing strategies based
 14:            on restarted Lanczos methods", Numer. Algor. 60(2):279-295,
 15:            2012.

 17:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 19:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 21:    This file is part of SLEPc.

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

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

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

 37: #include <slepc/private/epsimpl.h>
 38:  #include krylovschur.h

 40: static PetscBool  cited = PETSC_FALSE;
 41: static const char citation[] =
 42:   "@Article{slepc-slice,\n"
 43:   "   author = \"C. Campos and J. E. Roman\",\n"
 44:   "   title = \"Strategies for spectrum slicing based on restarted {Lanczos} methods\",\n"
 45:   "   journal = \"Numer. Algorithms\",\n"
 46:   "   volume = \"60\",\n"
 47:   "   number = \"2\",\n"
 48:   "   pages = \"279--295\",\n"
 49:   "   year = \"2012,\"\n"
 50:   "   doi = \"http://dx.doi.org/10.1007/s11075-012-9564-z\"\n"
 51:   "}\n";

 53: #define SLICE_PTOL PETSC_SQRT_MACHINE_EPSILON

 57: static PetscErrorCode EPSSliceResetSR(EPS eps) {
 58:   PetscErrorCode  ierr;
 59:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;
 60:   EPS_SR          sr=ctx->sr;
 61:   EPS_shift       s;

 64:   if (sr) {
 65:     if (ctx->npart>1) {
 66:       BVDestroy(&sr->V);
 67:       PetscFree4(sr->eigr,sr->eigi,sr->errest,sr->perm);
 68:     }
 69:     /* Reviewing list of shifts to free memory */
 70:     s = sr->s0;
 71:     if (s) {
 72:       while (s->neighb[1]) {
 73:         s = s->neighb[1];
 74:         PetscFree(s->neighb[0]);
 75:       }
 76:       PetscFree(s);
 77:     }
 78:     PetscFree(sr);
 79:   }
 80:   ctx->sr = NULL;
 81:   return(0);
 82: }

 86: PetscErrorCode EPSReset_KrylovSchur_Slice(EPS eps)
 87: {
 88:   PetscErrorCode  ierr;
 89:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;

 92:   if (!ctx->global) return(0);
 93:   /* Destroy auxiliary EPS */
 94:   EPSSliceResetSR(ctx->eps);
 95:   EPSDestroy(&ctx->eps);
 96:   if (ctx->npart>1) {
 97:     PetscSubcommDestroy(&ctx->subc);
 98:     if (ctx->commset) {
 99:       MPI_Comm_free(&ctx->commrank);
100:       ctx->commset = PETSC_FALSE;
101:     }
102:   }
103:   PetscFree(ctx->subintervals);
104:   PetscFree(ctx->nconv_loc);
105:   EPSSliceResetSR(eps);
106:   PetscFree(ctx->inertias);
107:   PetscFree(ctx->shifts);
108:   if (ctx->npart>1) {
109:     ISDestroy(&ctx->isrow);
110:     ISDestroy(&ctx->iscol);
111:     MatDestroyMatrices(1,&ctx->submata);
112:     MatDestroyMatrices(1,&ctx->submatb);
113:   }
114:   return(0);
115: }

119: /*
120:   EPSSliceAllocateSolution - Allocate memory storage for common variables such
121:   as eigenvalues and eigenvectors. The argument extra is used for methods
122:   that require a working basis slightly larger than ncv.
123: */
124: static PetscErrorCode EPSSliceAllocateSolution(EPS eps,PetscInt extra)
125: {
126:   PetscErrorCode     ierr;
127:   EPS_KRYLOVSCHUR    *ctx=(EPS_KRYLOVSCHUR*)eps->data;
128:   PetscReal          eta;
129:   PetscInt           k;
130:   PetscLogDouble     cnt;
131:   BVType             type;
132:   BVOrthogType       orthog_type;
133:   BVOrthogRefineType orthog_ref;
134:   BVOrthogBlockType  ob_type;
135:   Mat                matrix;
136:   Vec                t;
137:   EPS_SR             sr = ctx->sr;

140:   /* allocate space for eigenvalues and friends */
141:   k = PetscMax(1,sr->numEigs);
142:   PetscFree4(sr->eigr,sr->eigi,sr->errest,sr->perm);
143:   PetscMalloc4(k,&sr->eigr,k,&sr->eigi,k,&sr->errest,k,&sr->perm);
144:   cnt = 2*k*sizeof(PetscScalar) + 2*k*sizeof(PetscReal) + k*sizeof(PetscInt);
145:   PetscLogObjectMemory((PetscObject)eps,cnt);

147:   /* allocate sr->V and transfer options from eps->V */
148:   BVDestroy(&sr->V);
149:   BVCreate(PetscObjectComm((PetscObject)eps),&sr->V);
150:   PetscLogObjectParent((PetscObject)eps,(PetscObject)sr->V);
151:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
152:   if (!((PetscObject)(eps->V))->type_name) {
153:     BVSetType(sr->V,BVSVEC);
154:   } else {
155:     BVGetType(eps->V,&type);
156:     BVSetType(sr->V,type);
157:   }
158:   STMatCreateVecs(eps->st,&t,NULL);
159:   BVSetSizesFromVec(sr->V,t,k);
160:   VecDestroy(&t);
161:   EPS_SetInnerProduct(eps);
162:   BVGetMatrix(eps->V,&matrix,NULL);
163:   BVSetMatrix(sr->V,matrix,PETSC_FALSE);
164:   BVGetOrthogonalization(eps->V,&orthog_type,&orthog_ref,&eta,&ob_type);
165:   BVSetOrthogonalization(sr->V,orthog_type,orthog_ref,eta,ob_type);
166:   return(0);
167: }

171: static PetscErrorCode EPSSliceGetEPS(EPS eps)
172: {
173:   PetscErrorCode     ierr;
174:   EPS_KRYLOVSCHUR    *ctx=(EPS_KRYLOVSCHUR*)eps->data,*ctx_local;
175:   BV                 V;
176:   BVType             type;
177:   PetscReal          eta;
178:   BVOrthogType       orthog_type;
179:   BVOrthogRefineType orthog_ref;
180:   BVOrthogBlockType  ob_type;
181:   Mat                A,B=NULL,Ar,Br=NULL;
182:   PetscInt           i;
183:   PetscReal          h,a,b;
184:   PetscMPIInt        rank;
185:   EPS_SR             sr=ctx->sr;
186:   PC                 pc;
187:   PCType             pctype;
188:   KSP                ksp;
189:   KSPType            ksptype;
190:   STType             sttype;
191:   PetscObjectState   Astate,Bstate=0;
192:   PetscObjectId      Aid,Bid=0;
193:   const MatSolverPackage stype;

196:   EPSGetOperators(eps,&A,&B);
197:   if (ctx->npart==1) {
198:     if (!ctx->eps) { EPSCreate(((PetscObject)eps)->comm,&ctx->eps); }
199:     EPSSetType(ctx->eps,((PetscObject)eps)->type_name);
200:     EPSSetOperators(ctx->eps,A,B);
201:     a = eps->inta; b = eps->intb;
202:   } else {
203:     PetscObjectStateGet((PetscObject)A,&Astate);
204:     PetscObjectGetId((PetscObject)A,&Aid);
205:     if (B) {
206:       PetscObjectStateGet((PetscObject)B,&Bstate);
207:       PetscObjectGetId((PetscObject)B,&Bid);
208:     }
209:     if (!ctx->subc) {
210:       /* Create context for subcommunicators */
211:       PetscSubcommCreate(PetscObjectComm((PetscObject)eps),&ctx->subc);
212:       PetscSubcommSetNumber(ctx->subc,ctx->npart);
213:       PetscSubcommSetType(ctx->subc,PETSC_SUBCOMM_CONTIGUOUS);
214:       PetscLogObjectMemory((PetscObject)eps,sizeof(PetscSubcomm));

216:       /* Duplicate matrices */
217:       MatCreateRedundantMatrix(A,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Ar);
218:       ctx->Astate = Astate;
219:       ctx->Aid = Aid;
220:       if (B) {
221:         MatCreateRedundantMatrix(B,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Br);
222:         ctx->Bstate = Bstate;
223:         ctx->Bid = Bid;
224:       }
225:     } else {
226:       if (ctx->Astate != Astate || (B && ctx->Bstate != Bstate) || ctx->Aid != Aid || (B && ctx->Bid != Bid)) {
227:         EPSGetOperators(ctx->eps,&Ar,&Br);
228:         MatCreateRedundantMatrix(A,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Ar);
229:         ctx->Astate = Astate;
230:         ctx->Aid = Aid;
231:         if (B) {
232:           MatCreateRedundantMatrix(B,0,PetscSubcommChild(ctx->subc),MAT_INITIAL_MATRIX,&Br);
233:           ctx->Bstate = Bstate;
234:           ctx->Bid = Bid;
235:         }
236:         EPSSetOperators(ctx->eps,Ar,Br);
237:         MatDestroy(&Ar);
238:         MatDestroy(&Br);
239:       }
240:     }

242:     /* Determine subintervals */
243:     if (!ctx->subintset) { /* uniform distribution if no set by user */
244:       if (!sr->hasEnd) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Global interval must be bounded for splitting it in uniform subintervals");
245:       h = (eps->intb-eps->inta)/ctx->npart;
246:       a = eps->inta+ctx->subc->color*h;
247:       b = (ctx->subc->color==ctx->npart-1)?eps->intb:eps->inta+(ctx->subc->color+1)*h;
248:       PetscFree(ctx->subintervals);
249:       PetscMalloc1(ctx->npart+1,&ctx->subintervals);
250:       for (i=0;i<ctx->npart;i++) ctx->subintervals[i] = eps->inta+h*i;
251:       ctx->subintervals[ctx->npart] = eps->intb;
252:     } else {
253:       a = ctx->subintervals[ctx->subc->color];
254:       b = ctx->subintervals[ctx->subc->color+1];
255:     }

257:     if (!ctx->eps) {
258:       /* Create auxiliary EPS */
259:       EPSCreate(PetscSubcommChild(ctx->subc),&ctx->eps);
260:       EPSSetOperators(ctx->eps,Ar,Br);
261:       MatDestroy(&Ar);
262:       MatDestroy(&Br);
263:     }

265:     /* Create subcommunicator grouping processes with same rank */
266:     if (ctx->commset) { MPI_Comm_free(&ctx->commrank); }
267:     MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);
268:     MPI_Comm_split(((PetscObject)eps)->comm,rank,ctx->subc->color,&ctx->commrank);
269:     ctx->commset = PETSC_TRUE;
270:   }
271:   EPSSetType(ctx->eps,((PetscObject)eps)->type_name);

273:   /* Transfer options for ST, KSP and PC */
274:   STGetType(eps->st,&sttype);
275:   STSetType(ctx->eps->st,sttype);
276:   STGetKSP(eps->st,&ksp);
277:   KSPGetType(ksp,&ksptype);
278:   KSPGetPC(ksp,&pc);
279:   PCGetType(pc,&pctype);
280:   PCFactorGetMatSolverPackage(pc,&stype);
281:   STGetKSP(ctx->eps->st,&ksp);
282:   KSPSetType(ksp,ksptype);
283:   KSPGetPC(ksp,&pc);
284:   PCSetType(pc,pctype);
285:   if (stype) { PCFactorSetMatSolverPackage(pc,stype); }

287:   EPSSetConvergenceTest(ctx->eps,eps->conv);
288:   EPSSetInterval(ctx->eps,a,b);
289:   ctx_local = (EPS_KRYLOVSCHUR*)ctx->eps->data;
290:   ctx_local->npart = ctx->npart;
291:   ctx_local->detect = ctx->detect;
292:   ctx_local->global = PETSC_FALSE;
293:   ctx_local->eps = eps;
294:   ctx_local->subc = ctx->subc;
295:   ctx_local->commrank = ctx->commrank;

297:   EPSSetDimensions(ctx->eps,ctx->nev,ctx->ncv,ctx->mpd);
298:   EPSKrylovSchurSetLocking(ctx->eps,ctx->lock);

300:   /* transfer options from eps->V */
301:   EPSGetBV(ctx->eps,&V);
302:   if (!eps->V) { EPSGetBV(eps,&eps->V); }
303:   if (!((PetscObject)(eps->V))->type_name) {
304:     BVSetType(V,BVSVEC);
305:   } else {
306:     BVGetType(eps->V,&type);
307:     BVSetType(V,type);
308:   }
309:   BVGetOrthogonalization(eps->V,&orthog_type,&orthog_ref,&eta,&ob_type);
310:   BVSetOrthogonalization(V,orthog_type,orthog_ref,eta,ob_type);
311:   ctx->eps->which = eps->which;
312:   ctx->eps->max_it = eps->max_it;
313:   ctx->eps->tol = eps->tol;
314:   ctx->eps->purify = eps->purify;
315:   if (eps->tol==PETSC_DEFAULT) eps->tol = SLEPC_DEFAULT_TOL;
316:   EPSSetProblemType(ctx->eps,eps->problem_type);
317:   EPSSetUp(ctx->eps);
318:   ctx->eps->nconv = 0;
319:   ctx->eps->its   = 0;
320:   for (i=0;i<ctx->eps->ncv;i++) {
321:     ctx->eps->eigr[i]   = 0.0;
322:     ctx->eps->eigi[i]   = 0.0;
323:     ctx->eps->errest[i] = 0.0;
324:   }
325:   return(0);
326: }

330: static PetscErrorCode EPSSliceGetInertia(EPS eps,PetscReal shift,PetscInt *inertia,PetscInt *zeros)
331: {
333:   KSP            ksp;
334:   PC             pc;
335:   Mat            F;
336:   PetscReal      nzshift;

339:   if (shift >= PETSC_MAX_REAL) { /* Right-open interval */
340:     if (inertia) *inertia = eps->n;
341:   } else if (shift <= PETSC_MIN_REAL) {
342:     if (inertia) *inertia = 0;
343:     if (zeros) *zeros = 0;
344:   } else {
345:     /* If the shift is zero, perturb it to a very small positive value.
346:        The goal is that the nonzero pattern is the same in all cases and reuse
347:        the symbolic factorizations */
348:     nzshift = (shift==0.0)? 10.0/PETSC_MAX_REAL: shift;
349:     STSetShift(eps->st,nzshift);
350:     STSetUp(eps->st);
351:     STGetKSP(eps->st,&ksp);
352:     KSPGetPC(ksp,&pc);
353:     PCFactorGetMatrix(pc,&F);
354:     MatGetInertia(F,inertia,zeros,NULL);
355:   }
356:   return(0);
357: }

361: PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS eps)
362: {
363:   PetscErrorCode  ierr;
364:   PetscBool       issinv;
365:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data,*ctx_glob;
366:   EPS_SR          sr,sr_loc,sr_glob;
367:   PetscInt        nEigs,dssz=1,i,zeros=0,off=0;
368:   PetscMPIInt     nproc,rank,aux;
369:   PetscReal       r;
370:   MPI_Request     req;
371:   Mat             A,B=NULL;

374:   if (ctx->global) {
375:     if (eps->inta==0.0 && eps->intb==0.0) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Must define a computational interval when using EPS_ALL");
376:     if (eps->intb >= PETSC_MAX_REAL && eps->inta <= PETSC_MIN_REAL) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"The defined computational interval should have at least one of their sides bounded");
377:     if (!eps->ishermitian) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectrum slicing only available for symmetric/Hermitian eigenproblems");
378:     if (eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs cannot be used with spectrum slicing");
379:     if (!((PetscObject)(eps->st))->type_name) { /* default to shift-and-invert */
380:       STSetType(eps->st,STSINVERT);
381:     }
382:     PetscObjectTypeCompareAny((PetscObject)eps->st,&issinv,STSINVERT,STCAYLEY,"");
383:     if (!issinv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Shift-and-invert or Cayley ST is needed for spectrum slicing");
384:     if (eps->tol==PETSC_DEFAULT) eps->tol = SLEPC_DEFAULT_TOL*1e-2;  /* use tighter tolerance */
385:     if (!eps->max_it) eps->max_it = 100;
386:     if (ctx->nev==1) ctx->nev = PetscMin(40,eps->n);  /* nev not set, use default value */
387:     if (eps->n>10 && ctx->nev<10) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"nev cannot be less than 10 in spectrum slicing runs");
388:   }
389:   eps->ops->backtransform = NULL;

391:   /* create spectrum slicing context and initialize it */
392:   EPSSliceResetSR(eps);
393:   PetscNewLog(eps,&sr);
394:   ctx->sr = sr;
395:   sr->itsKs = 0;
396:   sr->nleap = 0;
397:   sr->nMAXCompl = eps->nev/4;
398:   sr->iterCompl = eps->max_it/4;
399:   sr->sPres = NULL;
400:   sr->nS = 0;

402:   if (ctx->npart==1 || ctx->global) {
403:     /* check presence of ends and finding direction */
404:     if ((eps->inta > PETSC_MIN_REAL && eps->inta != 0.0) || eps->intb >= PETSC_MAX_REAL) {
405:       sr->int0 = eps->inta;
406:       sr->int1 = eps->intb;
407:       sr->dir = 1;
408:       if (eps->intb >= PETSC_MAX_REAL) { /* Right-open interval */
409:         sr->hasEnd = PETSC_FALSE;
410:       } else sr->hasEnd = PETSC_TRUE;
411:     } else {
412:       sr->int0 = eps->intb;
413:       sr->int1 = eps->inta;
414:       sr->dir = -1;
415:       sr->hasEnd = PetscNot(eps->inta <= PETSC_MIN_REAL);
416:     }
417:   }
418:   if (ctx->global) {
419:     /* prevent computation of factorization in global eps */
420:     STSetTransform(eps->st,PETSC_FALSE);
421:     EPSSetDimensions_Default(eps,ctx->nev,&ctx->ncv,&ctx->mpd);
422:     /* create subintervals and initialize auxiliary eps for slicing runs */
423:     EPSSliceGetEPS(eps);
424:     sr_loc = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr;
425:     if (ctx->npart>1) {
426:       if ((sr->dir>0&&ctx->subc->color==0)||(sr->dir<0&&ctx->subc->color==ctx->npart-1)) sr->inertia0 = sr_loc->inertia0;
427:       MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);
428:       if (rank==0) {
429:         MPI_Bcast(&sr->inertia0,1,MPIU_INT,(sr->dir>0)?0:ctx->npart-1,ctx->commrank);
430:       }
431:       MPI_Bcast(&sr->inertia0,1,MPIU_INT,0,PetscSubcommChild(ctx->subc));
432:       PetscFree(ctx->nconv_loc);
433:       PetscMalloc1(ctx->npart,&ctx->nconv_loc);
434:       MPI_Comm_size(((PetscObject)eps)->comm,&nproc);
435:       if (sr->dir<0) off = 1;
436:       if (nproc%ctx->npart==0) { /* subcommunicators with the same size */
437:         PetscMPIIntCast(sr_loc->numEigs,&aux);
438:         MPI_Allgather(&aux,1,MPI_INT,ctx->nconv_loc,1,MPI_INT,ctx->commrank);
439:         MPI_Allgather(sr_loc->dir==sr->dir?&sr_loc->int0:&sr_loc->int1,1,MPIU_REAL,ctx->subintervals+off,1,MPIU_REAL,ctx->commrank);
440:       } else {
441:         MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);
442:         if (!rank) {
443:           PetscMPIIntCast(sr_loc->numEigs,&aux);
444:           MPI_Allgather(&aux,1,MPI_INT,ctx->nconv_loc,1,MPI_INT,ctx->commrank);
445:           MPI_Allgather(sr_loc->dir==sr->dir?&sr_loc->int0:&sr_loc->int1,1,MPIU_REAL,ctx->subintervals+off,1,MPIU_REAL,ctx->commrank);
446:         }
447:         PetscMPIIntCast(ctx->npart,&aux);
448:         MPI_Bcast(ctx->nconv_loc,aux,MPI_INT,0,PetscSubcommChild(ctx->subc));
449:         MPI_Bcast(ctx->subintervals+off,aux,MPIU_REAL,0,PetscSubcommChild(ctx->subc));
450:       }
451:       nEigs = 0;
452:       for (i=0;i<ctx->npart;i++) nEigs += ctx->nconv_loc[i];
453:     } else {
454:       nEigs = sr_loc->numEigs;
455:       sr->inertia0 = sr_loc->inertia0;
456:     }
457:     sr->inertia1 = sr->inertia0+sr->dir*nEigs;
458:     sr->numEigs = nEigs;
459:     eps->nev = nEigs;
460:     eps->ncv = nEigs;
461:     eps->mpd = nEigs;
462:   } else {
463:     ctx_glob = (EPS_KRYLOVSCHUR*)ctx->eps->data;
464:     sr_glob = ctx_glob->sr;
465:     if (ctx->npart>1) {
466:       sr->dir = sr_glob->dir;
467:       sr->int0 = (sr->dir==1)?eps->inta:eps->intb;
468:       sr->int1 = (sr->dir==1)?eps->intb:eps->inta;
469:       if ((sr->dir>0&&ctx->subc->color==ctx->npart-1)||(sr->dir<0&&ctx->subc->color==0)) sr->hasEnd = sr_glob->hasEnd;
470:       else sr->hasEnd = PETSC_TRUE;
471:     }

473:     /* compute inertia0 */
474:     EPSSliceGetInertia(eps,sr->int0,&sr->inertia0,ctx->detect?&zeros:NULL);
475:     if (zeros) { /* error in factorization */
476:       if (ctx->npart==1 || ctx_glob->subintset || ((sr->dir>0 && ctx->subc->color==0) || (sr->dir<0 && ctx->subc->color==ctx->npart-1))) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_USER,"Found singular matrix for the transformed problem in an interval endpoint defined by user");
477:       else { /* perturb shift */
478:         sr->int0 *= (1.0+SLICE_PTOL);
479:         EPSSliceGetInertia(eps,sr->int0,&sr->inertia0,&zeros);
480:         if (zeros) SETERRQ1(((PetscObject)eps)->comm,PETSC_ERR_CONV_FAILED,"Inertia computation fails in %g",sr->int1);
481:       }
482:     }
483:     if (ctx->npart>1) {
484:       /* inertia1 is received from neighbour */
485:       MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);
486:       if (!rank) {
487:         if ((sr->dir>0 && ctx->subc->color>0) || (sr->dir<0 && ctx->subc->color<ctx->npart-1)) { /* send inertia0 to neighbour0 */
488:           MPI_Isend(&(sr->inertia0),1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req);
489:           MPI_Isend(&(sr->int0),1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req);
490:         }
491:         if ((sr->dir>0 && ctx->subc->color<ctx->npart-1)|| (sr->dir<0 && ctx->subc->color>0)) { /* receive inertia1 from neighbour1 */
492:           MPI_Recv(&(sr->inertia1),1,MPIU_INT,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE);
493:           MPI_Recv(&(sr->int1),1,MPIU_REAL,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE);
494:         }
495:       }
496:       if ((sr->dir>0 && ctx->subc->color<ctx->npart-1)||(sr->dir<0 && ctx->subc->color>0)) {
497:         MPI_Bcast(&sr->inertia1,1,MPIU_INT,0,PetscSubcommChild(ctx->subc));
498:         MPI_Bcast(&sr->int1,1,MPIU_REAL,0,PetscSubcommChild(ctx->subc));
499:       } else sr_glob->inertia1 = sr->inertia1;
500:     }

502:     /* last process in eps comm computes inertia1 */
503:     if (ctx->npart==1 || ((sr->dir>0 && ctx->subc->color==ctx->npart-1) || (sr->dir<0 && ctx->subc->color==0))) {
504:       EPSSliceGetInertia(eps,sr->int1,&sr->inertia1,ctx->detect?&zeros:NULL);
505:       if (zeros) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_USER,"Found singular matrix for the transformed problem in an interval endpoint defined by user");
506:       if (sr->hasEnd) {
507:         sr->dir = -sr->dir; r = sr->int0; sr->int0 = sr->int1; sr->int1 = r;
508:         i = sr->inertia0; sr->inertia0 = sr->inertia1; sr->inertia1 = i;
509:       }
510:     }

512:     /* number of eigenvalues in interval */
513:     sr->numEigs = (sr->dir)*(sr->inertia1 - sr->inertia0);
514:     if (ctx->npart>1) {
515:       /* memory allocate for subinterval eigenpairs */
516:       EPSSliceAllocateSolution(eps,1);
517:     }
518:     dssz = eps->ncv+1;
519:   }
520:   DSSetType(eps->ds,DSHEP);
521:   DSSetCompact(eps->ds,PETSC_TRUE);
522:   DSAllocate(eps->ds,dssz);
523:   /* keep state of subcomm matrices to check that the user does not modify them */
524:   EPSGetOperators(eps,&A,&B);
525:   PetscObjectStateGet((PetscObject)A,&ctx->Astate);
526:   PetscObjectGetId((PetscObject)A,&ctx->Aid);
527:   if (B) { 
528:     PetscObjectStateGet((PetscObject)B,&ctx->Bstate);
529:     PetscObjectGetId((PetscObject)B,&ctx->Bid);
530:   } else {
531:     ctx->Bstate=0;
532:     ctx->Bid=0;
533:   }
534:   return(0);
535: }

539: static PetscErrorCode EPSSliceGatherEigenVectors(EPS eps)
540: {
541:   PetscErrorCode  ierr;
542:   Vec             v,vg,v_loc;
543:   IS              is1,is2;
544:   VecScatter      vec_sc;
545:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;
546:   PetscInt        nloc,m0,n0,i,si,idx,*idx1,*idx2,j;
547:   PetscScalar     *array;
548:   EPS_SR          sr_loc;
549:   BV              V_loc;

552:   sr_loc = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr;
553:   V_loc = sr_loc->V;

555:   /* Gather parallel eigenvectors */
556:   BVGetColumn(eps->V,0,&v);
557:   VecGetOwnershipRange(v,&n0,&m0);
558:   BVRestoreColumn(eps->V,0,&v);
559:   BVGetColumn(ctx->eps->V,0,&v);
560:   VecGetLocalSize(v,&nloc);
561:   BVRestoreColumn(ctx->eps->V,0,&v);
562:   PetscMalloc2(m0-n0,&idx1,m0-n0,&idx2);
563:   VecCreateMPI(PetscObjectComm((PetscObject)eps),nloc,PETSC_DECIDE,&vg);
564:   idx = -1;
565:   for (si=0;si<ctx->npart;si++) {
566:     j = 0;
567:     for (i=n0;i<m0;i++) {
568:       idx1[j]   = i;
569:       idx2[j++] = i+eps->n*si;
570:     }
571:     ISCreateGeneral(PetscObjectComm((PetscObject)eps),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);
572:     ISCreateGeneral(PetscObjectComm((PetscObject)eps),(m0-n0),idx2,PETSC_COPY_VALUES,&is2);
573:     BVGetColumn(eps->V,0,&v);
574:     VecScatterCreate(v,is1,vg,is2,&vec_sc);
575:     BVRestoreColumn(eps->V,0,&v);
576:     ISDestroy(&is1);
577:     ISDestroy(&is2);
578:     for (i=0;i<ctx->nconv_loc[si];i++) {
579:       BVGetColumn(eps->V,++idx,&v);
580:       if (ctx->subc->color==si) {
581:         BVGetColumn(V_loc,i,&v_loc);
582:         VecGetArray(v_loc,&array);
583:         VecPlaceArray(vg,array);
584:       }
585:       VecScatterBegin(vec_sc,vg,v,INSERT_VALUES,SCATTER_REVERSE);
586:       VecScatterEnd(vec_sc,vg,v,INSERT_VALUES,SCATTER_REVERSE);
587:       if (ctx->subc->color==si) {
588:         VecResetArray(vg);
589:         VecRestoreArray(v_loc,&array);
590:         BVRestoreColumn(V_loc,i,&v_loc);
591:       }
592:       BVRestoreColumn(eps->V,idx,&v);
593:     }
594:     VecScatterDestroy(&vec_sc);
595:   }
596:   PetscFree2(idx1,idx2);
597:   VecDestroy(&vg);
598:   return(0);
599: }

603: /*
604:   EPSComputeVectors_Slice - Recover Eigenvectors from subcomunicators
605:  */
606: PetscErrorCode EPSComputeVectors_Slice(EPS eps)
607: {
608:   PetscErrorCode  ierr;
609:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;

612:   if (ctx->global && ctx->npart>1) {
613:     EPSComputeVectors(ctx->eps);
614:     EPSSliceGatherEigenVectors(eps);
615:   }
616:   return(0);
617: }

619: #define SWAP(a,b,t) {t=a;a=b;b=t;}

623: static PetscErrorCode EPSSliceGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)
624: {
625:   PetscErrorCode  ierr;
626:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;
627:   PetscInt        i=0,j,tmpi;
628:   PetscReal       v,tmpr;
629:   EPS_shift       s;

632:   if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first");
633:   if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()");
634:   if (!ctx->sr->s0) {  /* EPSSolve not called yet */
635:     *n = 2;
636:   } else {
637:     *n = 1;
638:     s = ctx->sr->s0;
639:     while (s) {
640:       (*n)++;
641:       s = s->neighb[1];
642:     }
643:   }
644:   PetscMalloc1(*n,shifts);
645:   PetscMalloc1(*n,inertias);
646:   if (!ctx->sr->s0) {  /* EPSSolve not called yet */
647:     (*shifts)[0]   = ctx->sr->int0;
648:     (*shifts)[1]   = ctx->sr->int1;
649:     (*inertias)[0] = ctx->sr->inertia0;
650:     (*inertias)[1] = ctx->sr->inertia1;
651:   } else {
652:     s = ctx->sr->s0;
653:     while (s) {
654:       (*shifts)[i]     = s->value;
655:       (*inertias)[i++] = s->inertia;
656:       s = s->neighb[1];
657:     }
658:     (*shifts)[i]   = ctx->sr->int1;
659:     (*inertias)[i] = ctx->sr->inertia1;
660:   }
661:   /* remove possible duplicate in last position */
662:   if ((*shifts)[(*n)-1]==(*shifts)[(*n)-2]) (*n)--;
663:   /* sort result */
664:   for (i=0;i<*n;i++) {
665:     v = (*shifts)[i];
666:     for (j=i+1;j<*n;j++) {
667:       if (v > (*shifts)[j]) {
668:         SWAP((*shifts)[i],(*shifts)[j],tmpr);
669:         SWAP((*inertias)[i],(*inertias)[j],tmpi);
670:         v = (*shifts)[i];
671:       }
672:     }
673:   }
674:   return(0);
675: }

679: static PetscErrorCode EPSSliceGatherSolution(EPS eps)
680: {
681:   PetscErrorCode  ierr;
682:   PetscMPIInt     rank,nproc;
683:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;
684:   PetscInt        i,idx,j;
685:   PetscInt        *perm_loc,off=0,*inertias_loc,ns;
686:   PetscScalar     *eigr_loc;
687:   EPS_SR          sr_loc;
688:   PetscReal       *shifts_loc;
689:   PetscMPIInt     *disp,*ns_loc,aux;

692:   eps->nconv = 0;
693:   for (i=0;i<ctx->npart;i++) eps->nconv += ctx->nconv_loc[i];
694:   sr_loc = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr;

696:   /* Gather the shifts used and the inertias computed */
697:   EPSSliceGetInertias(ctx->eps,&ns,&shifts_loc,&inertias_loc);
698:   if (ctx->sr->dir>0 && shifts_loc[ns-1]==sr_loc->int1 && ctx->subc->color<ctx->npart-1) ns--;
699:   if (ctx->sr->dir<0 && shifts_loc[ns-1]==sr_loc->int0 && ctx->subc->color>0) {
700:     ns--;
701:     for (i=0;i<ns;i++) {
702:       inertias_loc[i] = inertias_loc[i+1];
703:       shifts_loc[i] = shifts_loc[i+1];
704:     }
705:   }
706:   PetscMalloc1(ctx->npart,&ns_loc);
707:   MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);
708:   PetscMPIIntCast(ns,&aux);
709:   if (rank==0) { MPI_Allgather(&aux,1,MPI_INT,ns_loc,1,MPI_INT,ctx->commrank); }
710:   PetscMPIIntCast(ctx->npart,&aux);
711:   MPI_Bcast(ns_loc,aux,MPI_INT,0,PetscSubcommChild(ctx->subc));
712:   ctx->nshifts = 0;
713:   for (i=0;i<ctx->npart;i++) ctx->nshifts += ns_loc[i];
714:   PetscFree(ctx->inertias);
715:   PetscFree(ctx->shifts);
716:   PetscMalloc1(ctx->nshifts,&ctx->inertias);
717:   PetscMalloc1(ctx->nshifts,&ctx->shifts);

719:   /* Gather eigenvalues (same ranks have fully set of eigenvalues)*/
720:   eigr_loc = sr_loc->eigr;
721:   perm_loc = sr_loc->perm;
722:   MPI_Comm_size(((PetscObject)eps)->comm,&nproc);
723:   PetscMalloc1(ctx->npart,&disp);
724:   disp[0] = 0;
725:   for (i=1;i<ctx->npart;i++) disp[i] = disp[i-1]+ctx->nconv_loc[i-1];
726:   if (nproc%ctx->npart==0) { /* subcommunicators with the same size */
727:     PetscMPIIntCast(sr_loc->numEigs,&aux);
728:     MPI_Allgatherv(eigr_loc,aux,MPIU_SCALAR,eps->eigr,ctx->nconv_loc,disp,MPIU_SCALAR,ctx->commrank); /* eigenvalues */
729:     MPI_Allgatherv(perm_loc,aux,MPIU_INT,eps->perm,ctx->nconv_loc,disp,MPIU_INT,ctx->commrank); /* perm */
730:     for (i=1;i<ctx->npart;i++) disp[i] = disp[i-1]+ns_loc[i-1];
731:     PetscMPIIntCast(ns,&aux);
732:     MPI_Allgatherv(shifts_loc,aux,MPIU_REAL,ctx->shifts,ns_loc,disp,MPIU_REAL,ctx->commrank); /* shifts */
733:     MPI_Allgatherv(inertias_loc,aux,MPIU_INT,ctx->inertias,ns_loc,disp,MPIU_INT,ctx->commrank); /* inertias */
734:     MPI_Allreduce(&sr_loc->itsKs,&eps->its,1,MPIU_INT,MPI_SUM,ctx->commrank);
735:   } else { /* subcommunicators with different size */
736:     MPI_Comm_rank(PetscSubcommChild(ctx->subc),&rank);
737:     if (rank==0) {
738:       PetscMPIIntCast(sr_loc->numEigs,&aux);
739:       MPI_Allgatherv(eigr_loc,aux,MPIU_SCALAR,eps->eigr,ctx->nconv_loc,disp,MPIU_SCALAR,ctx->commrank); /* eigenvalues */
740:       MPI_Allgatherv(perm_loc,aux,MPIU_INT,eps->perm,ctx->nconv_loc,disp,MPIU_INT,ctx->commrank); /* perm */
741:       for (i=1;i<ctx->npart;i++) disp[i] = disp[i-1]+ns_loc[i-1];
742:       PetscMPIIntCast(ns,&aux);
743:       MPI_Allgatherv(shifts_loc,aux,MPIU_REAL,ctx->shifts,ns_loc,disp,MPIU_REAL,ctx->commrank); /* shifts */
744:       MPI_Allgatherv(inertias_loc,aux,MPIU_INT,ctx->inertias,ns_loc,disp,MPIU_INT,ctx->commrank); /* inertias */
745:       MPI_Allreduce(&sr_loc->itsKs,&eps->its,1,MPIU_INT,MPI_SUM,ctx->commrank);
746:     }
747:     PetscMPIIntCast(eps->nconv,&aux);
748:     MPI_Bcast(eps->eigr,aux,MPIU_SCALAR,0,PetscSubcommChild(ctx->subc));
749:     MPI_Bcast(eps->perm,aux,MPIU_INT,0,PetscSubcommChild(ctx->subc));
750:     MPI_Bcast(ctx->shifts,ctx->nshifts,MPIU_REAL,0,PetscSubcommChild(ctx->subc));
751:     PetscMPIIntCast(ctx->nshifts,&aux);
752:     MPI_Bcast(ctx->inertias,aux,MPIU_INT,0,PetscSubcommChild(ctx->subc));
753:     MPI_Bcast(&eps->its,1,MPIU_INT,0,PetscSubcommChild(ctx->subc));
754:   }
755:   /* Update global array eps->perm */
756:   idx = ctx->nconv_loc[0];
757:   for (i=1;i<ctx->npart;i++) {
758:     off += ctx->nconv_loc[i-1];
759:     for (j=0;j<ctx->nconv_loc[i];j++) eps->perm[idx++] += off;
760:   }

762:   /* Gather parallel eigenvectors */
763:   PetscFree(ns_loc);
764:   PetscFree(disp);
765:   PetscFree(shifts_loc);
766:   PetscFree(inertias_loc);
767:   return(0);
768: }

770: /*
771:    Fills the fields of a shift structure
772: */
775: static PetscErrorCode EPSCreateShift(EPS eps,PetscReal val,EPS_shift neighb0,EPS_shift neighb1)
776: {
777:   PetscErrorCode  ierr;
778:   EPS_shift       s,*pending2;
779:   PetscInt        i;
780:   EPS_SR          sr;
781:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;

784:   sr = ctx->sr;
785:   PetscNewLog(eps,&s);
786:   s->value = val;
787:   s->neighb[0] = neighb0;
788:   if (neighb0) neighb0->neighb[1] = s;
789:   s->neighb[1] = neighb1;
790:   if (neighb1) neighb1->neighb[0] = s;
791:   s->comp[0] = PETSC_FALSE;
792:   s->comp[1] = PETSC_FALSE;
793:   s->index = -1;
794:   s->neigs = 0;
795:   s->nconv[0] = s->nconv[1] = 0;
796:   s->nsch[0] = s->nsch[1]=0;
797:   /* Inserts in the stack of pending shifts */
798:   /* If needed, the array is resized */
799:   if (sr->nPend >= sr->maxPend) {
800:     sr->maxPend *= 2;
801:     PetscMalloc1(sr->maxPend,&pending2);
802:     PetscLogObjectMemory((PetscObject)eps,sizeof(EPS_shift));
803:     for (i=0;i<sr->nPend;i++) pending2[i] = sr->pending[i];
804:     PetscFree(sr->pending);
805:     sr->pending = pending2;
806:   }
807:   sr->pending[sr->nPend++]=s;
808:   return(0);
809: }

811: /* Prepare for Rational Krylov update */
814: static PetscErrorCode EPSPrepareRational(EPS eps)
815: {
816:   EPS_KRYLOVSCHUR  *ctx=(EPS_KRYLOVSCHUR*)eps->data;
817:   PetscErrorCode   ierr;
818:   PetscInt         dir,i,k,ld,nv;
819:   PetscScalar      *A;
820:   EPS_SR           sr = ctx->sr;
821:   Vec              v;

824:   DSGetLeadingDimension(eps->ds,&ld);
825:   dir = (sr->sPres->neighb[0] == sr->sPrev)?1:-1;
826:   dir*=sr->dir;
827:   k = 0;
828:   for (i=0;i<sr->nS;i++) {
829:     if (dir*PetscRealPart(sr->S[i])>0.0) {
830:       sr->S[k] = sr->S[i];
831:       sr->S[sr->nS+k] = sr->S[sr->nS+i];
832:       BVGetColumn(sr->Vnext,k,&v);
833:       BVCopyVec(eps->V,eps->nconv+i,v);
834:       BVRestoreColumn(sr->Vnext,k,&v);
835:       k++;
836:       if (k>=sr->nS/2)break;
837:     }
838:   }
839:   /* Copy to DS */
840:   DSGetArray(eps->ds,DS_MAT_A,&A);
841:   PetscMemzero(A,ld*ld*sizeof(PetscScalar));
842:   for (i=0;i<k;i++) {
843:     A[i*(1+ld)] = sr->S[i];
844:     A[k+i*ld] = sr->S[sr->nS+i];
845:   }
846:   sr->nS = k;
847:   DSRestoreArray(eps->ds,DS_MAT_A,&A);
848:   DSGetDimensions(eps->ds,&nv,NULL,NULL,NULL,NULL);
849:   DSSetDimensions(eps->ds,nv,0,0,k);
850:   /* Append u to V */
851:   BVGetColumn(sr->Vnext,sr->nS,&v);
852:   BVCopyVec(eps->V,sr->nv,v);
853:   BVRestoreColumn(sr->Vnext,sr->nS,&v);
854:   return(0);
855: }

857: /* Provides next shift to be computed */
860: static PetscErrorCode EPSExtractShift(EPS eps)
861: {
862:   PetscErrorCode   ierr;
863:   PetscInt         iner,zeros=0;
864:   EPS_KRYLOVSCHUR  *ctx=(EPS_KRYLOVSCHUR*)eps->data;
865:   EPS_SR           sr;
866:   PetscReal        newShift;
867:   EPS_shift        sPres;

870:   sr = ctx->sr;
871:   if (sr->nPend > 0) {
872:     sr->sPrev = sr->sPres;
873:     sr->sPres = sr->pending[--sr->nPend];
874:     sPres = sr->sPres;
875:     EPSSliceGetInertia(eps,sPres->value,&iner,ctx->detect?&zeros:NULL);
876:     if (zeros) {
877:       newShift = sPres->value*(1.0+SLICE_PTOL);
878:       if (sr->dir*(sPres->neighb[0] && newShift-sPres->neighb[0]->value) < 0) newShift = (sPres->value+sPres->neighb[0]->value)/2;
879:       else if (sPres->neighb[1] && sr->dir*(sPres->neighb[1]->value-newShift) < 0) newShift = (sPres->value+sPres->neighb[1]->value)/2;
880:       EPSSliceGetInertia(eps,newShift,&iner,&zeros);
881:       if (zeros) SETERRQ1(((PetscObject)eps)->comm,PETSC_ERR_CONV_FAILED,"Inertia computation fails in %g",newShift);
882:       sPres->value = newShift;
883:     }
884:     sr->sPres->inertia = iner;
885:     eps->target = sr->sPres->value;
886:     eps->reason = EPS_CONVERGED_ITERATING;
887:     eps->its = 0;
888:   } else sr->sPres = NULL;
889:   return(0);
890: }

892: /*
893:    Symmetric KrylovSchur adapted to spectrum slicing:
894:    Allows searching an specific amount of eigenvalues in the subintervals left and right.
895:    Returns whether the search has succeeded
896: */
899: static PetscErrorCode EPSKrylovSchur_Slice(EPS eps)
900: {
901:   PetscErrorCode  ierr;
902:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;
903:   PetscInt        i,conv,k,l,ld,nv,*iwork,j,p;
904:   Mat             U;
905:   PetscScalar     *Q,*A,rtmp;
906:   PetscReal       *a,*b,beta;
907:   PetscBool       breakdown;
908:   PetscInt        count0,count1;
909:   PetscReal       lambda;
910:   EPS_shift       sPres;
911:   PetscBool       complIterating;
912:   PetscBool       sch0,sch1;
913:   PetscInt        iterCompl=0,n0,n1;
914:   EPS_SR          sr = ctx->sr;

917:   /* Spectrum slicing data */
918:   sPres = sr->sPres;
919:   complIterating =PETSC_FALSE;
920:   sch1 = sch0 = PETSC_TRUE;
921:   DSGetLeadingDimension(eps->ds,&ld);
922:   PetscMalloc1(2*ld,&iwork);
923:   count0=0;count1=0; /* Found on both sides */
924:   if (sr->nS > 0 && (sPres->neighb[0] == sr->sPrev || sPres->neighb[1] == sr->sPrev)) {
925:     /* Rational Krylov */
926:     DSTranslateRKS(eps->ds,sr->sPrev->value-sPres->value);
927:     DSGetDimensions(eps->ds,NULL,NULL,NULL,&l,NULL);
928:     DSSetDimensions(eps->ds,l+1,0,0,0);
929:     BVSetActiveColumns(eps->V,0,l+1);
930:     DSGetMat(eps->ds,DS_MAT_Q,&U);
931:     BVMultInPlace(eps->V,U,0,l+1);
932:     MatDestroy(&U);
933:   } else {
934:     /* Get the starting Lanczos vector */
935:     EPSGetStartVector(eps,0,NULL);
936:     l = 0;
937:   }
938:   /* Restart loop */
939:   while (eps->reason == EPS_CONVERGED_ITERATING) {
940:     eps->its++; sr->itsKs++;
941:     /* Compute an nv-step Lanczos factorization */
942:     nv = PetscMin(eps->nconv+eps->mpd,eps->ncv);
943:     DSGetArrayReal(eps->ds,DS_MAT_T,&a);
944:     b = a + ld;
945:     EPSFullLanczos(eps,a,b,eps->nconv+l,&nv,&breakdown);
946:     sr->nv = nv;
947:     beta = b[nv-1];
948:     DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
949:     DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);
950:     if (l==0) {
951:       DSSetState(eps->ds,DS_STATE_INTERMEDIATE);
952:     } else {
953:       DSSetState(eps->ds,DS_STATE_RAW);
954:     }
955:     BVSetActiveColumns(eps->V,eps->nconv,nv);

957:     /* Solve projected problem and compute residual norm estimates */
958:     if (eps->its == 1 && l > 0) {/* After rational update */
959:       DSGetArray(eps->ds,DS_MAT_A,&A);
960:       DSGetArrayReal(eps->ds,DS_MAT_T,&a);
961:       b = a + ld;
962:       k = eps->nconv+l;
963:       A[k*ld+k-1] = A[(k-1)*ld+k];
964:       A[k*ld+k] = a[k];
965:       for (j=k+1; j< nv; j++) {
966:         A[j*ld+j] = a[j];
967:         A[j*ld+j-1] = b[j-1] ;
968:         A[(j-1)*ld+j] = b[j-1];
969:       }
970:       DSRestoreArray(eps->ds,DS_MAT_A,&A);
971:       DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
972:       DSSolve(eps->ds,eps->eigr,NULL);
973:       DSSort(eps->ds,eps->eigr,NULL,NULL,NULL,NULL);
974:       DSSetCompact(eps->ds,PETSC_TRUE);
975:     } else { /* Restart */
976:       DSSolve(eps->ds,eps->eigr,NULL);
977:       DSSort(eps->ds,eps->eigr,NULL,NULL,NULL,NULL);
978:     }
979:     /* Residual */
980:     EPSKrylovConvergence(eps,PETSC_TRUE,eps->nconv,nv-eps->nconv,beta,1.0,&k);

982:     if (ctx->lock) {
983:       /* Check convergence */
984:       DSGetArrayReal(eps->ds,DS_MAT_T,&a);
985:       b = a + ld;
986:       conv = 0;
987:       j = k = eps->nconv;
988:       for (i=eps->nconv;i<nv;i++) if (eps->errest[i] < eps->tol) conv++;
989:       for (i=eps->nconv;i<nv;i++) {
990:         if (eps->errest[i] < eps->tol) {
991:           iwork[j++]=i;
992:         } else iwork[conv+k++]=i;
993:       }
994:       for (i=eps->nconv;i<nv;i++) {
995:         a[i]=PetscRealPart(eps->eigr[i]);
996:         b[i]=eps->errest[i];
997:       }
998:       for (i=eps->nconv;i<nv;i++) {
999:         eps->eigr[i] = a[iwork[i]];
1000:         eps->errest[i] = b[iwork[i]];
1001:       }
1002:       for (i=eps->nconv;i<nv;i++) {
1003:         a[i]=PetscRealPart(eps->eigr[i]);
1004:         b[i]=eps->errest[i];
1005:       }
1006:       DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
1007:       DSGetArray(eps->ds,DS_MAT_Q,&Q);
1008:       for (i=eps->nconv;i<nv;i++) {
1009:         p=iwork[i];
1010:         if (p!=i) {
1011:           j=i+1;
1012:           while (iwork[j]!=i) j++;
1013:           iwork[j]=p;iwork[i]=i;
1014:           for (k=0;k<nv;k++) {
1015:             rtmp=Q[k+p*ld];Q[k+p*ld]=Q[k+i*ld];Q[k+i*ld]=rtmp;
1016:           }
1017:         }
1018:       }
1019:       DSRestoreArray(eps->ds,DS_MAT_Q,&Q);
1020:       k=eps->nconv+conv;
1021:     }

1023:     /* Checking values obtained for completing */
1024:     for (i=0;i<k;i++) {
1025:       sr->back[i]=eps->eigr[i];
1026:     }
1027:     STBackTransform(eps->st,k,sr->back,eps->eigi);
1028:     count0=count1=0;
1029:     for (i=0;i<k;i++) {
1030:       lambda = PetscRealPart(sr->back[i]);
1031:       if (((sr->dir)*(sPres->value - lambda) > 0) && ((sr->dir)*(lambda - sPres->ext[0]) > 0)) count0++;
1032:       if (((sr->dir)*(lambda - sPres->value) > 0) && ((sr->dir)*(sPres->ext[1] - lambda) > 0)) count1++;
1033:     }
1034:     if (k>eps->nev && eps->ncv-k<5) eps->reason = EPS_CONVERGED_TOL;
1035:     else {
1036:       /* Checks completion */
1037:       if ((!sch0||count0 >= sPres->nsch[0]) && (!sch1 ||count1 >= sPres->nsch[1])) {
1038:         eps->reason = EPS_CONVERGED_TOL;
1039:       } else {
1040:         if (!complIterating && eps->its >= eps->max_it) eps->reason = EPS_DIVERGED_ITS;
1041:         if (complIterating) {
1042:           if (--iterCompl <= 0) eps->reason = EPS_DIVERGED_ITS;
1043:         } else if (k >= eps->nev) {
1044:           n0 = sPres->nsch[0]-count0;
1045:           n1 = sPres->nsch[1]-count1;
1046:           if (sr->iterCompl>0 && ((n0>0 && n0<= sr->nMAXCompl)||(n1>0&&n1<=sr->nMAXCompl))) {
1047:             /* Iterating for completion*/
1048:             complIterating = PETSC_TRUE;
1049:             if (n0 >sr->nMAXCompl)sch0 = PETSC_FALSE;
1050:             if (n1 >sr->nMAXCompl)sch1 = PETSC_FALSE;
1051:             iterCompl = sr->iterCompl;
1052:           } else eps->reason = EPS_CONVERGED_TOL;
1053:         }
1054:       }
1055:     }
1056:     /* Update l */
1057:     if (eps->reason == EPS_CONVERGED_ITERATING) l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep));
1058:     else l = 0;
1059:     if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */
1060:     if (breakdown) l=0;

1062:     if (eps->reason == EPS_CONVERGED_ITERATING) {
1063:       if (breakdown) {
1064:         /* Start a new Lanczos factorization */
1065:         PetscInfo2(eps,"Breakdown in Krylov-Schur method (it=%D norm=%g)\n",eps->its,(double)beta);
1066:         EPSGetStartVector(eps,k,&breakdown);
1067:         if (breakdown) {
1068:           eps->reason = EPS_DIVERGED_BREAKDOWN;
1069:           PetscInfo(eps,"Unable to generate more start vectors\n");
1070:         }
1071:       } else {
1072:         /* Prepare the Rayleigh quotient for restart */
1073:         DSGetArrayReal(eps->ds,DS_MAT_T,&a);
1074:         DSGetArray(eps->ds,DS_MAT_Q,&Q);
1075:         b = a + ld;
1076:         for (i=k;i<k+l;i++) {
1077:           a[i] = PetscRealPart(eps->eigr[i]);
1078:           b[i] = PetscRealPart(Q[nv-1+i*ld]*beta);
1079:         }
1080:         DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
1081:         DSRestoreArray(eps->ds,DS_MAT_Q,&Q);
1082:       }
1083:     }
1084:     /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */
1085:     DSGetMat(eps->ds,DS_MAT_Q,&U);
1086:     BVMultInPlace(eps->V,U,eps->nconv,k+l);
1087:     MatDestroy(&U);

1089:     /* Normalize u and append it to V */
1090:     if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) {
1091:       BVCopyColumn(eps->V,nv,k+l);
1092:     }
1093:     eps->nconv = k;
1094:     if (eps->reason != EPS_CONVERGED_ITERATING) {
1095:       /* Store approximated values for next shift */
1096:       DSGetArray(eps->ds,DS_MAT_Q,&Q);
1097:       sr->nS = l;
1098:       for (i=0;i<l;i++) {
1099:         sr->S[i] = eps->eigr[i+k];/* Diagonal elements */
1100:         sr->S[i+l] = Q[nv-1+(i+k)*ld]*beta; /* Out of diagonal elements */
1101:       }
1102:       DSRestoreArray(eps->ds,DS_MAT_Q,&Q);
1103:     }
1104:   }
1105:   /* Check for completion */
1106:   for (i=0;i< eps->nconv; i++) {
1107:     if ((sr->dir)*PetscRealPart(eps->eigr[i])>0) sPres->nconv[1]++;
1108:     else sPres->nconv[0]++;
1109:   }
1110:   sPres->comp[0] = PetscNot(count0 < sPres->nsch[0]);
1111:   sPres->comp[1] = PetscNot(count1 < sPres->nsch[1]);
1112:   if (count0 > sPres->nsch[0] || count1 > sPres->nsch[1])SETERRQ(PetscObjectComm((PetscObject)eps),1,"Mismatch between number of values found and information from inertia, consider using EPSKrylovSchurSetDetectZeros()");
1113:   PetscFree(iwork);
1114:   return(0);
1115: }

1117: /*
1118:   Obtains value of subsequent shift
1119: */
1122: static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS)
1123: {
1124:   PetscReal       lambda,d_prev;
1125:   PetscInt        i,idxP;
1126:   EPS_SR          sr;
1127:   EPS_shift       sPres,s;
1128:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;

1131:   sr = ctx->sr;
1132:   sPres = sr->sPres;
1133:   if (sPres->neighb[side]) {
1134:   /* Completing a previous interval */
1135:     if (!sPres->neighb[side]->neighb[side] && sPres->neighb[side]->nconv[side]==0) { /* One of the ends might be too far from eigenvalues */
1136:       if (side) *newS = (sPres->value + PetscRealPart(sr->eigr[sr->perm[sr->indexEig-1]]))/2;
1137:       else *newS = (sPres->value + PetscRealPart(sr->eigr[sr->perm[0]]))/2;
1138:     } else *newS=(sPres->value + sPres->neighb[side]->value)/2;
1139:   } else { /* (Only for side=1). Creating a new interval. */
1140:     if (sPres->neigs==0) {/* No value has been accepted*/
1141:       if (sPres->neighb[0]) {
1142:         /* Multiplying by 10 the previous distance */
1143:         *newS = sPres->value + 10*(sr->dir)*PetscAbsReal(sPres->value - sPres->neighb[0]->value);
1144:         sr->nleap++;
1145:         /* Stops when the interval is open and no values are found in the last 5 shifts (there might be infinite eigenvalues) */
1146:         if (!sr->hasEnd && sr->nleap > 5) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unable to compute the wanted eigenvalues with open interval");
1147:       } else { /* First shift */
1148:         if (eps->nconv != 0) {
1149:           /* Unaccepted values give information for next shift */
1150:           idxP=0;/* Number of values left from shift */
1151:           for (i=0;i<eps->nconv;i++) {
1152:             lambda = PetscRealPart(eps->eigr[i]);
1153:             if ((sr->dir)*(lambda - sPres->value) <0) idxP++;
1154:             else break;
1155:           }
1156:           /* Avoiding subtraction of eigenvalues (might be the same).*/
1157:           if (idxP>0) {
1158:             d_prev = PetscAbsReal(sPres->value - PetscRealPart(eps->eigr[0]))/(idxP+0.3);
1159:           } else {
1160:             d_prev = PetscAbsReal(sPres->value - PetscRealPart(eps->eigr[eps->nconv-1]))/(eps->nconv+0.3);
1161:           }
1162:           *newS = sPres->value + ((sr->dir)*d_prev*eps->nev)/2;
1163:         } else { /* No values found, no information for next shift */
1164:           SETERRQ(PetscObjectComm((PetscObject)eps),1,"First shift renders no information");
1165:         }
1166:       }
1167:     } else { /* Accepted values found */
1168:       sr->nleap = 0;
1169:       /* Average distance of values in previous subinterval */
1170:       s = sPres->neighb[0];
1171:       while (s && PetscAbs(s->inertia - sPres->inertia)==0) {
1172:         s = s->neighb[0];/* Looking for previous shifts with eigenvalues within */
1173:       }
1174:       if (s) {
1175:         d_prev = PetscAbsReal((sPres->value - s->value)/(sPres->inertia - s->inertia));
1176:       } else { /* First shift. Average distance obtained with values in this shift */
1177:         /* first shift might be too far from first wanted eigenvalue (no values found outside the interval)*/
1178:         if ((sr->dir)*(PetscRealPart(sr->eigr[0])-sPres->value)>0 && PetscAbsReal((PetscRealPart(sr->eigr[sr->indexEig-1]) - PetscRealPart(sr->eigr[0]))/PetscRealPart(sr->eigr[0])) > PetscSqrtReal(eps->tol)) {
1179:           d_prev =  PetscAbsReal((PetscRealPart(sr->eigr[sr->indexEig-1]) - PetscRealPart(sr->eigr[0])))/(sPres->neigs+0.3);
1180:         } else {
1181:           d_prev = PetscAbsReal(PetscRealPart(sr->eigr[sr->indexEig-1]) - sPres->value)/(sPres->neigs+0.3);
1182:         }
1183:       }
1184:       /* Average distance is used for next shift by adding it to value on the right or to shift */
1185:       if ((sr->dir)*(PetscRealPart(sr->eigr[sPres->index + sPres->neigs -1]) - sPres->value)>0) {
1186:         *newS = PetscRealPart(sr->eigr[sPres->index + sPres->neigs -1])+ ((sr->dir)*d_prev*(eps->nev))/2;
1187:       } else { /* Last accepted value is on the left of shift. Adding to shift */
1188:         *newS = sPres->value + ((sr->dir)*d_prev*(eps->nev))/2;
1189:       }
1190:     }
1191:     /* End of interval can not be surpassed */
1192:     if ((sr->dir)*(sr->int1 - *newS) < 0) *newS = sr->int1;
1193:   }/* of neighb[side]==null */
1194:   return(0);
1195: }

1197: /*
1198:   Function for sorting an array of real values
1199: */
1202: static PetscErrorCode sortRealEigenvalues(PetscScalar *r,PetscInt *perm,PetscInt nr,PetscBool prev,PetscInt dir)
1203: {
1204:   PetscReal      re;
1205:   PetscInt       i,j,tmp;

1208:   if (!prev) for (i=0;i<nr;i++) perm[i] = i;
1209:   /* Insertion sort */
1210:   for (i=1;i<nr;i++) {
1211:     re = PetscRealPart(r[perm[i]]);
1212:     j = i-1;
1213:     while (j>=0 && dir*(re - PetscRealPart(r[perm[j]])) <= 0) {
1214:       tmp = perm[j]; perm[j] = perm[j+1]; perm[j+1] = tmp; j--;
1215:     }
1216:   }
1217:   return(0);
1218: }

1220: /* Stores the pairs obtained since the last shift in the global arrays */
1223: static PetscErrorCode EPSStoreEigenpairs(EPS eps)
1224: {
1225:   PetscErrorCode  ierr;
1226:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;
1227:   PetscReal       lambda,err,norm;
1228:   PetscInt        i,count;
1229:   PetscBool       iscayley;
1230:   EPS_SR          sr = ctx->sr;
1231:   EPS_shift       sPres;
1232:   Vec             v,w;

1235:   sPres = sr->sPres;
1236:   sPres->index = sr->indexEig;
1237:   count = sr->indexEig;
1238:   /* Back-transform */
1239:   STBackTransform(eps->st,eps->nconv,eps->eigr,eps->eigi);
1240:   PetscObjectTypeCompare((PetscObject)eps->st,STCAYLEY,&iscayley);
1241:   /* Sort eigenvalues */
1242:   sortRealEigenvalues(eps->eigr,eps->perm,eps->nconv,PETSC_FALSE,sr->dir);
1243:   /* Values stored in global array */
1244:   for (i=0;i<eps->nconv;i++) {
1245:     lambda = PetscRealPart(eps->eigr[eps->perm[i]]);
1246:     err = eps->errest[eps->perm[i]];

1248:     if ((sr->dir)*(lambda - sPres->ext[0]) > 0 && (sr->dir)*(sPres->ext[1] - lambda) > 0) {/* Valid value */
1249:       if (count>=sr->numEigs) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unexpected error in Spectrum Slicing");
1250:       sr->eigr[count] = lambda;
1251:       sr->errest[count] = err;
1252:       /* Explicit purification */
1253:       if (eps->purify) {
1254:         BVGetColumn(sr->V,count,&v);
1255:         BVGetColumn(eps->V,eps->perm[i],&w);
1256:         STApply(eps->st,w,v);
1257:         BVRestoreColumn(sr->V,count,&v);
1258:         BVRestoreColumn(eps->V,eps->perm[i],&w);
1259:         BVNormColumn(sr->V,count,NORM_2,&norm);
1260:         BVScaleColumn(sr->V,count,1.0/norm);
1261:       } else {
1262:         BVGetColumn(eps->V,eps->perm[i],&w);
1263:         BVInsertVec(sr->V,count,w);
1264:         BVRestoreColumn(eps->V,eps->perm[i],&w);
1265:         BVNormColumn(sr->V,count,NORM_2,&norm);
1266:         BVScaleColumn(sr->V,count,1.0/norm);
1267:       }
1268:       count++;
1269:     }
1270:   }
1271:   sPres->neigs = count - sr->indexEig;
1272:   sr->indexEig = count;
1273:   /* Global ordering array updating */
1274:   sortRealEigenvalues(sr->eigr,sr->perm,count,PETSC_TRUE,sr->dir);
1275:   return(0);
1276: }

1280: static PetscErrorCode EPSLookForDeflation(EPS eps)
1281: {
1282:   PetscErrorCode  ierr;
1283:   PetscReal       val;
1284:   PetscInt        i,count0=0,count1=0;
1285:   EPS_shift       sPres;
1286:   PetscInt        ini,fin,k,idx0,idx1;
1287:   EPS_SR          sr;
1288:   Vec             v;
1289:   EPS_KRYLOVSCHUR *ctx=(EPS_KRYLOVSCHUR*)eps->data;

1292:   sr = ctx->sr;
1293:   sPres = sr->sPres;

1295:   if (sPres->neighb[0]) ini = (sr->dir)*(sPres->neighb[0]->inertia - sr->inertia0);
1296:   else ini = 0;
1297:   fin = sr->indexEig;
1298:   /* Selection of ends for searching new values */
1299:   if (!sPres->neighb[0]) sPres->ext[0] = sr->int0;/* First shift */
1300:   else sPres->ext[0] = sPres->neighb[0]->value;
1301:   if (!sPres->neighb[1]) {
1302:     if (sr->hasEnd) sPres->ext[1] = sr->int1;
1303:     else sPres->ext[1] = (sr->dir > 0)?PETSC_MAX_REAL:PETSC_MIN_REAL;
1304:   } else sPres->ext[1] = sPres->neighb[1]->value;
1305:   /* Selection of values between right and left ends */
1306:   for (i=ini;i<fin;i++) {
1307:     val=PetscRealPart(sr->eigr[sr->perm[i]]);
1308:     /* Values to the right of left shift */
1309:     if ((sr->dir)*(val - sPres->ext[1]) < 0) {
1310:       if ((sr->dir)*(val - sPres->value) < 0) count0++;
1311:       else count1++;
1312:     } else break;
1313:   }
1314:   /* The number of values on each side are found */
1315:   if (sPres->neighb[0]) {
1316:     sPres->nsch[0] = (sr->dir)*(sPres->inertia - sPres->neighb[0]->inertia)-count0;
1317:     if (sPres->nsch[0]<0)SETERRQ(PetscObjectComm((PetscObject)eps),1,"Mismatch between number of values found and information from inertia, consider using EPSKrylovSchurSetDetectZeros()");
1318:   } else sPres->nsch[0] = 0;

1320:   if (sPres->neighb[1]) {
1321:     sPres->nsch[1] = (sr->dir)*(sPres->neighb[1]->inertia - sPres->inertia) - count1;
1322:     if (sPres->nsch[1]<0)SETERRQ(PetscObjectComm((PetscObject)eps),1,"Mismatch between number of values found and information from inertia, consider using EPSKrylovSchurSetDetectZeros()");
1323:   } else sPres->nsch[1] = (sr->dir)*(sr->inertia1 - sPres->inertia);

1325:   /* Completing vector of indexes for deflation */
1326:   idx0 = ini;
1327:   idx1 = ini+count0+count1;
1328:   k=0;
1329:   for (i=idx0;i<idx1;i++) sr->idxDef[k++]=sr->perm[i];
1330:   BVDuplicateResize(eps->V,k+eps->ncv+1,&sr->Vnext);
1331:   BVSetNumConstraints(sr->Vnext,k);
1332:   for (i=0;i<k;i++) {
1333:     BVGetColumn(sr->Vnext,-i-1,&v);
1334:     BVCopyVec(sr->V,sr->idxDef[i],v);
1335:     BVRestoreColumn(sr->Vnext,-i-1,&v);
1336:   }

1338:   /* For rational Krylov */
1339:   if (sr->nS>0 && (sr->sPrev == sr->sPres->neighb[0] || sr->sPrev == sr->sPres->neighb[1])) {
1340:     EPSPrepareRational(eps);
1341:   }
1342:   eps->nconv = 0;
1343:   /* Get rid of temporary Vnext */
1344:   BVDestroy(&eps->V);
1345:   eps->V = sr->Vnext;
1346:   sr->Vnext = NULL;
1347:   return(0);
1348: }

1352: PetscErrorCode EPSSolve_KrylovSchur_Slice(EPS eps)
1353: {
1354:   PetscErrorCode   ierr;
1355:   PetscInt         i,lds;
1356:   PetscReal        newS;
1357:   EPS_KRYLOVSCHUR  *ctx=(EPS_KRYLOVSCHUR*)eps->data;
1358:   EPS_SR           sr=ctx->sr;
1359:   Mat              A,B=NULL;
1360:   PetscObjectState Astate,Bstate=0;
1361:   PetscObjectId    Aid,Bid=0;

1364:   PetscCitationsRegister(citation,&cited);
1365:   if (ctx->global) {
1366:     EPSSolve_KrylovSchur_Slice(ctx->eps);
1367:     ctx->eps->state = EPS_STATE_SOLVED;
1368:     eps->reason = EPS_CONVERGED_TOL;
1369:     if (ctx->npart>1) {
1370:       /* Gather solution from subsolvers */
1371:       EPSSliceGatherSolution(eps);
1372:     } else {
1373:       eps->nconv = sr->numEigs;
1374:       eps->its   = ctx->eps->its;
1375:       PetscFree(ctx->inertias);
1376:       PetscFree(ctx->shifts);
1377:       EPSSliceGetInertias(ctx->eps,&ctx->nshifts,&ctx->shifts,&ctx->inertias);
1378:     }
1379:   } else {
1380:     if (ctx->npart==1) {
1381:       sr->eigr   = ctx->eps->eigr;
1382:       sr->eigi   = ctx->eps->eigi;
1383:       sr->perm   = ctx->eps->perm;
1384:       sr->errest = ctx->eps->errest;
1385:       sr->V      = ctx->eps->V;
1386:     }
1387:     /* Check that the user did not modify subcomm matrices */
1388:     EPSGetOperators(eps,&A,&B);
1389:     PetscObjectStateGet((PetscObject)A,&Astate);
1390:     PetscObjectGetId((PetscObject)A,&Aid);
1391:     if (B) { 
1392:       PetscObjectStateGet((PetscObject)B,&Bstate);
1393:       PetscObjectGetId((PetscObject)B,&Bid);
1394:     }
1395:     if (Astate!=ctx->Astate || (B && Bstate!=ctx->Bstate) || Aid!=ctx->Aid || (B && Bid!=ctx->Bid)) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Subcomm matrices have been modified by user");
1396:     /* Only with eigenvalues present in the interval ...*/
1397:     if (sr->numEigs==0) {
1398:       eps->reason = EPS_CONVERGED_TOL;
1399:       return(0);
1400:     }
1401:     /* Array of pending shifts */
1402:     sr->maxPend = 100; /* Initial size */
1403:     sr->nPend = 0;
1404:     PetscMalloc1(sr->maxPend,&sr->pending);
1405:     PetscLogObjectMemory((PetscObject)eps,(sr->maxPend)*sizeof(EPS_shift));
1406:     EPSCreateShift(eps,sr->int0,NULL,NULL);
1407:     /* extract first shift */
1408:     sr->sPrev = NULL;
1409:     sr->sPres = sr->pending[--sr->nPend];
1410:     sr->sPres->inertia = sr->inertia0;
1411:     eps->target = sr->sPres->value;
1412:     sr->s0 = sr->sPres;
1413:     sr->indexEig = 0;
1414:     /* Memory reservation for auxiliary variables */
1415:     lds = PetscMin(eps->mpd,eps->ncv);
1416:     PetscCalloc1(lds*lds,&sr->S);
1417:     PetscMalloc1(eps->ncv,&sr->back);
1418:     PetscLogObjectMemory((PetscObject)eps,(sr->numEigs+2*eps->ncv)*sizeof(PetscScalar));
1419:     for (i=0;i<sr->numEigs;i++) {
1420:       sr->eigr[i]   = 0.0;
1421:       sr->eigi[i]   = 0.0;
1422:       sr->errest[i] = 0.0;
1423:       sr->perm[i]   = i;
1424:     }
1425:     /* Vectors for deflation */
1426:     PetscMalloc1(sr->numEigs,&sr->idxDef);
1427:     PetscLogObjectMemory((PetscObject)eps,sr->numEigs*sizeof(PetscInt));
1428:     sr->indexEig = 0;
1429:     /* Main loop */
1430:     while (sr->sPres) {
1431:       /* Search for deflation */
1432:       EPSLookForDeflation(eps);
1433:       /* KrylovSchur */
1434:       EPSKrylovSchur_Slice(eps);

1436:       EPSStoreEigenpairs(eps);
1437:       /* Select new shift */
1438:       if (!sr->sPres->comp[1]) {
1439:         EPSGetNewShiftValue(eps,1,&newS);
1440:         EPSCreateShift(eps,newS,sr->sPres,sr->sPres->neighb[1]);
1441:       }
1442:       if (!sr->sPres->comp[0]) {
1443:         /* Completing earlier interval */
1444:         EPSGetNewShiftValue(eps,0,&newS);
1445:         EPSCreateShift(eps,newS,sr->sPres->neighb[0],sr->sPres);
1446:       }
1447:       /* Preparing for a new search of values */
1448:       EPSExtractShift(eps);
1449:     }

1451:     /* Updating eps values prior to exit */
1452:     PetscFree(sr->S);
1453:     PetscFree(sr->idxDef);
1454:     PetscFree(sr->pending);
1455:     PetscFree(sr->back);
1456:     BVDuplicateResize(eps->V,eps->ncv+1,&sr->Vnext);
1457:     BVSetNumConstraints(sr->Vnext,0);
1458:     BVDestroy(&eps->V);
1459:     eps->V      = sr->Vnext;
1460:     eps->nconv  = sr->indexEig;
1461:     eps->reason = EPS_CONVERGED_TOL;
1462:     eps->its    = sr->itsKs;
1463:     eps->nds    = 0;
1464:   }
1465:   return(0);
1466: }

slepc-3.7.4/src/eps/impls/krylov/krylovschur/krylovschur.h.html0000644000175000017500000002713713107004621024327 0ustar jromanjroman
Actual source code: krylovschur.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private header for Krylov-Schur.

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

  8:    This file is part of SLEPc.

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

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

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


 27: PETSC_INTERN PetscErrorCode EPSReset_KrylovSchur_Slice(EPS);
 28: PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Default(EPS);
 29: PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Symm(EPS);
 30: PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Slice(EPS);
 31: PETSC_INTERN PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS);
 32: PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Indefinite(EPS);
 33: PETSC_INTERN PetscErrorCode EPSGetArbitraryValues(EPS,PetscScalar*,PetscScalar*);

 35: /* Structure characterizing a shift in spectrum slicing */
 36: typedef struct _n_shift *EPS_shift;
 37: struct _n_shift {
 38:   PetscReal     value;
 39:   PetscInt      inertia;
 40:   PetscBool     comp[2];      /* Shows completion of subintervals (left and right) */
 41:   EPS_shift     neighb[2];    /* Adjacent shifts */
 42:   PetscInt      index;        /* Index in eig where found values are stored */
 43:   PetscInt      neigs;        /* Number of values found */
 44:   PetscReal     ext[2];       /* Limits for accepted values */
 45:   PetscInt      nsch[2];      /* Number of missing values for each subinterval */
 46:   PetscInt      nconv[2];     /* Converged on each side (accepted or not) */
 47: };

 49: /* Structure for storing the state of spectrum slicing */
 50: struct _n_SR {
 51:   PetscReal     int0,int1;    /* Extremes of the interval */
 52:   PetscInt      dir;          /* Determines the order of values in eig (+1 incr, -1 decr) */
 53:   PetscBool     hasEnd;       /* Tells whether the interval has an end */
 54:   PetscInt      inertia0,inertia1;
 55:   PetscScalar   *back;
 56:   PetscInt      numEigs;      /* Number of eigenvalues in the interval */
 57:   PetscInt      indexEig;
 58:   EPS_shift     sPres;        /* Present shift */
 59:   EPS_shift     *pending;     /* Pending shifts array */
 60:   PetscInt      nPend;        /* Number of pending shifts */
 61:   PetscInt      maxPend;      /* Size of "pending" array */
 62:   PetscInt      *idxDef;      /* For deflation */
 63:   PetscInt      nMAXCompl;
 64:   PetscInt      iterCompl;
 65:   PetscInt      itsKs;        /* Krylovschur restarts */
 66:   PetscInt      nleap;
 67:   EPS_shift     s0;           /* Initial shift */
 68:   PetscScalar   *S;           /* Matrix for projected problem */
 69:   PetscInt      nS;
 70:   EPS_shift     sPrev;
 71:   PetscInt      nv;           /* position of restart vector */
 72:   BV            V;            /* working basis (for subsolve) */
 73:   BV            Vnext;        /* temporary working basis during change of shift */
 74:   PetscScalar   *eigr,*eigi;  /* eigenvalues (for subsolve) */
 75:   PetscReal     *errest;      /* error estimates (for subsolve) */
 76:   PetscInt      *perm;        /* permutation (for subsolve) */
 77: };
 78: typedef struct _n_SR *EPS_SR;

 80: typedef struct {
 81:   PetscReal        keep;               /* restart parameter */
 82:   PetscBool        lock;               /* locking/non-locking variant */
 83:   /* the following are used only in spectrum slicing */
 84:   EPS_SR           sr;                 /* spectrum slicing context */
 85:   PetscInt         nev;                /* number of eigenvalues to compute */
 86:   PetscInt         ncv;                /* number of basis vectors */
 87:   PetscInt         mpd;                /* maximum dimension of projected problem */
 88:   PetscInt         npart;              /* number of partitions of subcommunicator */
 89:   PetscBool        detect;             /* check for zeros during factorizations */
 90:   PetscReal        *subintervals;      /* partition of global interval */
 91:   PetscBool        subintset;          /* subintervals set by user */
 92:   PetscMPIInt      *nconv_loc;         /* converged eigenpairs for each subinterval */
 93:   EPS              eps;                /* additional eps for slice runs */
 94:   PetscBool        global;             /* flag distinguishing global from local eps */
 95:   PetscReal        *shifts;            /* array containing global shifts */
 96:   PetscInt         *inertias;          /* array containing global inertias */
 97:   PetscInt         nshifts;            /* elements in the arrays of shifts and inertias */
 98:   PetscSubcomm     subc;               /* context for subcommunicators */
 99:   MPI_Comm         commrank;           /* group processes with same rank in subcommunicators */
100:   PetscBool        commset;            /* flag indicating that commrank was created */
101:   PetscObjectState Astate,Bstate;      /* state of subcommunicator matrices */
102:   PetscObjectId    Aid,Bid;            /* Id of subcommunicator matrices */
103:   IS               isrow,iscol;        /* index sets used in update of subcomm mats */
104:   Mat              *submata,*submatb;  /* seq matrices used in update of subcomm mats */
105: } EPS_KRYLOVSCHUR;

107: #endif
slepc-3.7.4/src/eps/impls/krylov/krylovschur/krylovschur.h0000644000175000017500000001263413107004621023360 0ustar jromanjroman/* Private header for Krylov-Schur. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__KRYLOVSCHUR_H) #define __KRYLOVSCHUR_H PETSC_INTERN PetscErrorCode EPSReset_KrylovSchur_Slice(EPS); PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Default(EPS); PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Symm(EPS); PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Slice(EPS); PETSC_INTERN PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS); PETSC_INTERN PetscErrorCode EPSSolve_KrylovSchur_Indefinite(EPS); PETSC_INTERN PetscErrorCode EPSGetArbitraryValues(EPS,PetscScalar*,PetscScalar*); /* Structure characterizing a shift in spectrum slicing */ typedef struct _n_shift *EPS_shift; struct _n_shift { PetscReal value; PetscInt inertia; PetscBool comp[2]; /* Shows completion of subintervals (left and right) */ EPS_shift neighb[2]; /* Adjacent shifts */ PetscInt index; /* Index in eig where found values are stored */ PetscInt neigs; /* Number of values found */ PetscReal ext[2]; /* Limits for accepted values */ PetscInt nsch[2]; /* Number of missing values for each subinterval */ PetscInt nconv[2]; /* Converged on each side (accepted or not) */ }; /* Structure for storing the state of spectrum slicing */ struct _n_SR { PetscReal int0,int1; /* Extremes of the interval */ PetscInt dir; /* Determines the order of values in eig (+1 incr, -1 decr) */ PetscBool hasEnd; /* Tells whether the interval has an end */ PetscInt inertia0,inertia1; PetscScalar *back; PetscInt numEigs; /* Number of eigenvalues in the interval */ PetscInt indexEig; EPS_shift sPres; /* Present shift */ EPS_shift *pending; /* Pending shifts array */ PetscInt nPend; /* Number of pending shifts */ PetscInt maxPend; /* Size of "pending" array */ PetscInt *idxDef; /* For deflation */ PetscInt nMAXCompl; PetscInt iterCompl; PetscInt itsKs; /* Krylovschur restarts */ PetscInt nleap; EPS_shift s0; /* Initial shift */ PetscScalar *S; /* Matrix for projected problem */ PetscInt nS; EPS_shift sPrev; PetscInt nv; /* position of restart vector */ BV V; /* working basis (for subsolve) */ BV Vnext; /* temporary working basis during change of shift */ PetscScalar *eigr,*eigi; /* eigenvalues (for subsolve) */ PetscReal *errest; /* error estimates (for subsolve) */ PetscInt *perm; /* permutation (for subsolve) */ }; typedef struct _n_SR *EPS_SR; typedef struct { PetscReal keep; /* restart parameter */ PetscBool lock; /* locking/non-locking variant */ /* the following are used only in spectrum slicing */ EPS_SR sr; /* spectrum slicing context */ PetscInt nev; /* number of eigenvalues to compute */ PetscInt ncv; /* number of basis vectors */ PetscInt mpd; /* maximum dimension of projected problem */ PetscInt npart; /* number of partitions of subcommunicator */ PetscBool detect; /* check for zeros during factorizations */ PetscReal *subintervals; /* partition of global interval */ PetscBool subintset; /* subintervals set by user */ PetscMPIInt *nconv_loc; /* converged eigenpairs for each subinterval */ EPS eps; /* additional eps for slice runs */ PetscBool global; /* flag distinguishing global from local eps */ PetscReal *shifts; /* array containing global shifts */ PetscInt *inertias; /* array containing global inertias */ PetscInt nshifts; /* elements in the arrays of shifts and inertias */ PetscSubcomm subc; /* context for subcommunicators */ MPI_Comm commrank; /* group processes with same rank in subcommunicators */ PetscBool commset; /* flag indicating that commrank was created */ PetscObjectState Astate,Bstate; /* state of subcommunicator matrices */ PetscObjectId Aid,Bid; /* Id of subcommunicator matrices */ IS isrow,iscol; /* index sets used in update of subcomm mats */ Mat *submata,*submatb; /* seq matrices used in update of subcomm mats */ } EPS_KRYLOVSCHUR; #endif slepc-3.7.4/src/eps/impls/krylov/krylovschur/ks-indef.c.html0000644000175000017500000003555613107004621023433 0ustar jromanjroman
Actual source code: ks-indef.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "krylovschur"

  5:    Method: Krylov-Schur for symmetric-indefinite eigenproblems

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

 11:    This file is part of SLEPc.

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

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

 22:    You  should have received a copy of the GNU Lesser General  Public  License
 23:    along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 24:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 25: */
 26: #include <slepc/private/epsimpl.h>
 27:  #include krylovschur.h

 31: PetscErrorCode EPSSolve_KrylovSchur_Indefinite(EPS eps)
 32: {
 33:   PetscErrorCode  ierr;
 34:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
 35:   PetscInt        i,k,l,ld,nv,t,nconv=0;
 36:   Mat             U;
 37:   Vec             vomega,w=eps->work[0];
 38:   PetscScalar     *Q,*aux;
 39:   PetscReal       *a,*b,*r,beta,beta1=1.0,*omega;
 40:   PetscBool       breakdown=PETSC_FALSE,symmlost=PETSC_FALSE;

 43:   DSGetLeadingDimension(eps->ds,&ld);

 45:   /* Get the starting Lanczos vector */
 46:   EPSGetStartVector(eps,0,NULL);

 48:   /* Extract sigma[0] from BV, computed during normalization */
 49:   BVSetActiveColumns(eps->V,0,1);
 50:   VecCreateSeq(PETSC_COMM_SELF,1,&vomega);
 51:   BVGetSignature(eps->V,vomega);
 52:   VecGetArray(vomega,&aux);
 53:   DSGetArrayReal(eps->ds,DS_MAT_D,&omega);
 54:   omega[0] = PetscRealPart(aux[0]);
 55:   DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);
 56:   VecRestoreArray(vomega,&aux);
 57:   VecDestroy(&vomega);
 58:   l = 0;

 60:   /* Restart loop */
 61:   while (eps->reason == EPS_CONVERGED_ITERATING) {
 62:     eps->its++;

 64:     /* Compute an nv-step Lanczos factorization */
 65:     nv = PetscMin(eps->nconv+eps->mpd,eps->ncv);
 66:     DSGetArrayReal(eps->ds,DS_MAT_T,&a);
 67:     b = a + ld;
 68:     DSGetArrayReal(eps->ds,DS_MAT_D,&omega);
 69:     EPSPseudoLanczos(eps,a,b,omega,eps->nconv+l,&nv,&breakdown,&symmlost,NULL,w);
 70:     if (symmlost) {
 71:       eps->reason = EPS_DIVERGED_SYMMETRY_LOST;
 72:       if (nv==eps->nconv+l+1) { eps->nconv = nconv; break; }
 73:     }
 74:     beta = b[nv-1];
 75:     DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
 76:     DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);
 77:     DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);
 78:     if (l==0) {
 79:       DSSetState(eps->ds,DS_STATE_INTERMEDIATE);
 80:     } else {
 81:       DSSetState(eps->ds,DS_STATE_RAW);
 82:     }
 83:     BVSetActiveColumns(eps->V,eps->nconv,nv);

 85:     /* Solve projected problem */
 86:     DSSolve(eps->ds,eps->eigr,eps->eigi);
 87:     DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);

 89:     /* Check convergence */
 90:     DSGetDimensions(eps->ds,NULL,NULL,NULL,NULL,&t);
 91: #if 0
 92:     /* take into account also left residual */
 93:     BVGetColumn(eps->V,nv,&u);
 94:     VecNorm(u,NORM_2,&beta1);
 95:     BVRestoreColumn(eps->V,nv,&u);
 96:     VecNorm(w,NORM_2,&beta2);  /* w contains B*V[nv] */
 97:     beta1 = PetscMax(beta1,beta2);
 98: #endif
 99:     EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,t-eps->nconv,beta*beta1,1.0,&k);
100:     (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);
101:     nconv = k;

103:     /* Update l */
104:     if (eps->reason != EPS_CONVERGED_ITERATING || breakdown) l = 0;
105:     else {
106:       l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep));
107:       l = PetscMin(l,t);
108:       DSGetArrayReal(eps->ds,DS_MAT_T,&a);
109:       if (*(a+ld+k+l-1)!=0) {
110:         if (k+l<t-1) l = l+1;
111:         else l = l-1;
112:       }
113:       DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
114:     }
115:     if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */

117:     if (eps->reason == EPS_CONVERGED_ITERATING) {
118:       if (breakdown) {
119:         SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_CONV_FAILED,"Breakdown in Indefinite Krylov-Schur (beta=%g)",beta);
120:       } else {
121:         /* Prepare the Rayleigh quotient for restart */
122:         DSGetArray(eps->ds,DS_MAT_Q,&Q);
123:         DSGetArrayReal(eps->ds,DS_MAT_T,&a);
124:         DSGetArrayReal(eps->ds,DS_MAT_D,&omega);
125:         b = a + ld;
126:         r = a + 2*ld;
127:         for (i=k;i<k+l;i++) {
128:           r[i] = PetscRealPart(Q[nv-1+i*ld]*beta);
129:         }
130:         b[k+l-1] = r[k+l-1];
131:         omega[k+l] = omega[nv];
132:         DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
133:         DSRestoreArray(eps->ds,DS_MAT_Q,&Q);
134:         DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);
135:       }
136:     }
137:     /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */
138:     DSGetMat(eps->ds,DS_MAT_Q,&U);
139:     BVMultInPlace(eps->V,U,eps->nconv,k+l);
140:     MatDestroy(&U);

142:     /* Move restart vector and update signature */
143:     if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) {
144:       BVCopyColumn(eps->V,nv,k+l);
145:       DSGetArrayReal(eps->ds,DS_MAT_D,&omega);
146:       VecCreateSeq(PETSC_COMM_SELF,k+l,&vomega);
147:       VecGetArray(vomega,&aux);
148:       for (i=0;i<k+l;i++) aux[i] = omega[i];
149:       VecRestoreArray(vomega,&aux);
150:       BVSetActiveColumns(eps->V,0,k+l);
151:       BVSetSignature(eps->V,vomega);
152:       VecDestroy(&vomega);
153:       DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);
154:     }

156:     eps->nconv = k;
157:     EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,nv);
158:   }
159:   DSSetDimensions(eps->ds,eps->nconv,0,0,0);
160:   DSSetState(eps->ds,DS_STATE_RAW);
161:   return(0);
162: }

slepc-3.7.4/src/eps/impls/krylov/krylovschur/krylovschur.c0000644000175000017500000015054513107004621023357 0ustar jromanjroman/* SLEPc eigensolver: "krylovschur" Method: Krylov-Schur Algorithm: Single-vector Krylov-Schur method for non-symmetric problems, including harmonic extraction. References: [1] "Krylov-Schur Methods in SLEPc", SLEPc Technical Report STR-7, available at http://slepc.upv.es. [2] G.W. Stewart, "A Krylov-Schur Algorithm for Large Eigenproblems", SIAM J. Matrix Anal. App. 23(3):601-614, 2001. [3] "Practical Implementation of Harmonic Krylov-Schur", SLEPc Technical Report STR-9, available at http://slepc.upv.es. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepceps.h" I*/ #include "krylovschur.h" #undef __FUNCT__ #define __FUNCT__ "EPSGetArbitraryValues" PetscErrorCode EPSGetArbitraryValues(EPS eps,PetscScalar *rr,PetscScalar *ri) { PetscErrorCode ierr; PetscInt i,newi,ld,n,l; Vec xr=eps->work[0],xi=eps->work[1]; PetscScalar re,im,*Zr,*Zi,*X; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); ierr = DSGetDimensions(eps->ds,&n,NULL,&l,NULL,NULL);CHKERRQ(ierr); for (i=l;ieigr[i]; im = eps->eigi[i]; ierr = STBackTransform(eps->st,1,&re,&im);CHKERRQ(ierr); newi = i; ierr = DSVectors(eps->ds,DS_MAT_X,&newi,NULL);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); Zr = X+i*ld; if (newi==i+1) Zi = X+newi*ld; else Zi = NULL; ierr = EPSComputeRitzVector(eps,Zr,Zi,eps->V,xr,xi);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = (*eps->arbitrary)(re,im,xr,xi,rr+i,ri+i,eps->arbitraryctx);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetUp_KrylovSchur" PetscErrorCode EPSSetUp_KrylovSchur(EPS eps) { PetscErrorCode ierr; PetscReal eta; BVOrthogType otype; BVOrthogBlockType obtype; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; enum { EPS_KS_DEFAULT,EPS_KS_SYMM,EPS_KS_SLICE,EPS_KS_INDEF } variant; PetscFunctionBegin; /* spectrum slicing requires special treatment of default values */ if (eps->which==EPS_ALL) { ierr = EPSSetUp_KrylovSchur_Slice(eps);CHKERRQ(ierr); } else { ierr = EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);CHKERRQ(ierr); if (eps->ncv>eps->nev+eps->mpd) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must not be larger than nev+mpd"); if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv); if (!eps->which) { ierr = EPSSetWhichEigenpairs_Default(eps);CHKERRQ(ierr); } } if (!ctx->lock && eps->mpdncv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant"); if (eps->isgeneralized && eps->ishermitian && !eps->ispositive && eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not implemented for indefinite problems"); if (eps->ishermitian && eps->ispositive && (eps->which==EPS_LARGEST_IMAGINARY || eps->which==EPS_SMALLEST_IMAGINARY)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which"); if (!eps->extraction) { ierr = EPSSetExtraction(eps,EPS_RITZ);CHKERRQ(ierr); } else if (eps->extraction!=EPS_RITZ && eps->extraction!=EPS_HARMONIC) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); if (eps->extraction==EPS_HARMONIC && ctx->lock) { ierr = PetscInfo(eps,"Locking was requested but will be deactivated since is not supported with harmonic extraction\n");CHKERRQ(ierr); } if (!ctx->keep) ctx->keep = 0.5; ierr = EPSAllocateSolution(eps,1);CHKERRQ(ierr); ierr = EPS_SetInnerProduct(eps);CHKERRQ(ierr); if (eps->arbitrary) { ierr = EPSSetWorkVecs(eps,2);CHKERRQ(ierr); } else if (eps->ishermitian && !eps->ispositive){ ierr = EPSSetWorkVecs(eps,1);CHKERRQ(ierr); } /* dispatch solve method */ if (eps->ishermitian) { if (eps->which==EPS_ALL) { if (eps->isgeneralized && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectrum slicing not implemented for indefinite problems"); else variant = EPS_KS_SLICE; } else if (eps->isgeneralized && !eps->ispositive) { variant = EPS_KS_INDEF; } else { switch (eps->extraction) { case EPS_RITZ: variant = EPS_KS_SYMM; break; case EPS_HARMONIC: variant = EPS_KS_DEFAULT; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); } } } else { switch (eps->extraction) { case EPS_RITZ: variant = EPS_KS_DEFAULT; break; case EPS_HARMONIC: variant = EPS_KS_DEFAULT; break; default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type"); } } switch (variant) { case EPS_KS_DEFAULT: eps->ops->solve = EPSSolve_KrylovSchur_Default; eps->ops->computevectors = EPSComputeVectors_Schur; ierr = DSSetType(eps->ds,DSNHEP);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,eps->ncv+1);CHKERRQ(ierr); break; case EPS_KS_SYMM: eps->ops->solve = EPSSolve_KrylovSchur_Symm; eps->ops->computevectors = EPSComputeVectors_Hermitian; ierr = DSSetType(eps->ds,DSHEP);CHKERRQ(ierr); ierr = DSSetCompact(eps->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSSetExtraRow(eps->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,eps->ncv+1);CHKERRQ(ierr); break; case EPS_KS_SLICE: if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectrum slicing does not support user-defined stopping test"); eps->ops->solve = EPSSolve_KrylovSchur_Slice; eps->ops->computevectors = EPSComputeVectors_Slice; break; case EPS_KS_INDEF: eps->ops->solve = EPSSolve_KrylovSchur_Indefinite; eps->ops->computevectors = EPSComputeVectors_Indefinite; ierr = DSSetType(eps->ds,DSGHIEP);CHKERRQ(ierr); ierr = DSSetCompact(eps->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(eps->ds,eps->ncv+1);CHKERRQ(ierr); /* force reorthogonalization for pseudo-Lanczos */ ierr = BVGetOrthogonalization(eps->V,&otype,NULL,&eta,&obtype);CHKERRQ(ierr); ierr = BVSetOrthogonalization(eps->V,otype,BV_ORTHOG_REFINE_ALWAYS,eta,obtype);CHKERRQ(ierr); break; default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unexpected error"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSolve_KrylovSchur_Default" PetscErrorCode EPSSolve_KrylovSchur_Default(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscInt i,j,*pj,k,l,nv,ld,nconv; Mat U; PetscScalar *S,*Q,*g; PetscReal beta,gamma=1.0; PetscBool breakdown,harmonic; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); harmonic = (eps->extraction==EPS_HARMONIC || eps->extraction==EPS_REFINED_HARMONIC)?PETSC_TRUE:PETSC_FALSE; if (harmonic) { ierr = PetscMalloc1(ld,&g);CHKERRQ(ierr); } if (eps->arbitrary) pj = &j; else pj = NULL; /* Get the starting Arnoldi vector */ ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); l = 0; /* Restart loop */ while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; /* Compute an nv-step Arnoldi factorization */ nv = PetscMin(eps->nconv+eps->mpd,eps->ncv); ierr = DSGetArray(eps->ds,DS_MAT_A,&S);CHKERRQ(ierr); ierr = EPSBasicArnoldi(eps,PETSC_FALSE,S,ld,eps->nconv+l,&nv,&beta,&breakdown);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_A,&S);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(eps->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); } ierr = BVSetActiveColumns(eps->V,eps->nconv,nv);CHKERRQ(ierr); /* Compute translation of Krylov decomposition if harmonic extraction used */ if (harmonic) { ierr = DSTranslateHarmonic(eps->ds,eps->target,beta,PETSC_FALSE,g,&gamma);CHKERRQ(ierr); } /* Solve projected problem */ ierr = DSSolve(eps->ds,eps->eigr,eps->eigi);CHKERRQ(ierr); if (eps->arbitrary) { ierr = EPSGetArbitraryValues(eps,eps->rr,eps->ri);CHKERRQ(ierr); j=1; } ierr = DSSort(eps->ds,eps->eigr,eps->eigi,eps->rr,eps->ri,pj);CHKERRQ(ierr); /* Check convergence */ ierr = EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,nv-eps->nconv,beta,gamma,&k);CHKERRQ(ierr); ierr = (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); nconv = k; /* Update l */ if (eps->reason != EPS_CONVERGED_ITERATING || breakdown) l = 0; else { l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep)); #if !defined(PETSC_USE_COMPLEX) ierr = DSGetArray(eps->ds,DS_MAT_A,&S);CHKERRQ(ierr); if (S[k+l+(k+l-1)*ld] != 0.0) { if (k+lds,DS_MAT_A,&S);CHKERRQ(ierr); #endif } if ((!ctx->lock || harmonic) && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */ if (eps->reason == EPS_CONVERGED_ITERATING) { if (breakdown) { /* Start a new Arnoldi factorization */ ierr = PetscInfo2(eps,"Breakdown in Krylov-Schur method (it=%D norm=%g)\n",eps->its,(double)beta);CHKERRQ(ierr); if (knev) { ierr = EPSGetStartVector(eps,k,&breakdown);CHKERRQ(ierr); if (breakdown) { eps->reason = EPS_DIVERGED_BREAKDOWN; ierr = PetscInfo(eps,"Unable to generate more start vectors\n");CHKERRQ(ierr); } } } else { /* Undo translation of Krylov decomposition */ if (harmonic) { ierr = DSSetDimensions(eps->ds,nv,0,k,l);CHKERRQ(ierr); ierr = DSTranslateHarmonic(eps->ds,0.0,beta,PETSC_TRUE,g,&gamma);CHKERRQ(ierr); /* gamma u^ = u - U*g~ */ ierr = BVMultColumn(eps->V,-1.0,1.0,nv,g);CHKERRQ(ierr); ierr = BVScaleColumn(eps->V,nv,1.0/gamma);CHKERRQ(ierr); } /* Prepare the Rayleigh quotient for restart */ ierr = DSGetArray(eps->ds,DS_MAT_A,&S);CHKERRQ(ierr); ierr = DSGetArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); for (i=k;ids,DS_MAT_A,&S);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); } } /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */ ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,eps->nconv,k+l);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) { ierr = BVCopyColumn(eps->V,nv,k+l);CHKERRQ(ierr); } eps->nconv = k; ierr = EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,nv);CHKERRQ(ierr); } if (harmonic) { ierr = PetscFree(g);CHKERRQ(ierr); } /* truncate Schur decomposition and change the state to raw so that DSVectors() computes eigenvectors from scratch */ ierr = DSSetDimensions(eps->ds,eps->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetRestart_KrylovSchur" static PetscErrorCode EPSKrylovSchurSetRestart_KrylovSchur(EPS eps,PetscReal keep) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; if (keep==PETSC_DEFAULT) ctx->keep = 0.5; else { if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]"); ctx->keep = keep; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetRestart" /*@ EPSKrylovSchurSetRestart - Sets the restart parameter for the Krylov-Schur method, in particular the proportion of basis vectors that must be kept after restart. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - keep - the number of vectors to be kept at restart Options Database Key: . -eps_krylovschur_restart - Sets the restart parameter Notes: Allowed values are in the range [0.1,0.9]. The default is 0.5. Level: advanced .seealso: EPSKrylovSchurGetRestart() @*/ PetscErrorCode EPSKrylovSchurSetRestart(EPS eps,PetscReal keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveReal(eps,keep,2); ierr = PetscTryMethod(eps,"EPSKrylovSchurSetRestart_C",(EPS,PetscReal),(eps,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetRestart_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetRestart_KrylovSchur(EPS eps,PetscReal *keep) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; *keep = ctx->keep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetRestart" /*@ EPSKrylovSchurGetRestart - Gets the restart parameter used in the Krylov-Schur method. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . keep - the restart parameter Level: advanced .seealso: EPSKrylovSchurSetRestart() @*/ PetscErrorCode EPSKrylovSchurGetRestart(EPS eps,PetscReal *keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(keep,2); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetRestart_C",(EPS,PetscReal*),(eps,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetLocking_KrylovSchur" static PetscErrorCode EPSKrylovSchurSetLocking_KrylovSchur(EPS eps,PetscBool lock) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; ctx->lock = lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetLocking" /*@ EPSKrylovSchurSetLocking - Choose between locking and non-locking variants of the Krylov-Schur method. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - lock - true if the locking variant must be selected Options Database Key: . -eps_krylovschur_locking - Sets the locking flag Notes: The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant). Level: advanced .seealso: EPSKrylovSchurGetLocking() @*/ PetscErrorCode EPSKrylovSchurSetLocking(EPS eps,PetscBool lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,lock,2); ierr = PetscTryMethod(eps,"EPSKrylovSchurSetLocking_C",(EPS,PetscBool),(eps,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetLocking_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetLocking_KrylovSchur(EPS eps,PetscBool *lock) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; *lock = ctx->lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetLocking" /*@ EPSKrylovSchurGetLocking - Gets the locking flag used in the Krylov-Schur method. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . lock - the locking flag Level: advanced .seealso: EPSKrylovSchurSetLocking() @*/ PetscErrorCode EPSKrylovSchurGetLocking(EPS eps,PetscBool *lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(lock,2); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetLocking_C",(EPS,PetscBool*),(eps,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetPartitions_KrylovSchur" static PetscErrorCode EPSKrylovSchurSetPartitions_KrylovSchur(EPS eps,PetscInt npart) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscMPIInt size; PetscFunctionBegin; if (ctx->npart!=npart) { if (ctx->commset) { ierr = PetscSubcommDestroy(&ctx->subc);CHKERRQ(ierr); } if (ctx->eps) { ierr = EPSDestroy(&ctx->eps);CHKERRQ(ierr); } } if (npart == PETSC_DEFAULT || npart == PETSC_DECIDE) { ctx->npart = 1; } else { ierr = MPI_Comm_size(PetscObjectComm((PetscObject)eps),&size);CHKERRQ(ierr); if (npart<1 || npart>size) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart"); ctx->npart = npart; } eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetPartitions" /*@ EPSKrylovSchurSetPartitions - Sets the number of partitions for the case of doing spectrum slicing for a computational interval with the communicator split in several sub-communicators. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - npart - number of partitions Options Database Key: . -eps_krylovschur_partitions - Sets the number of partitions Notes: By default, npart=1 so all processes in the communicator participate in the processing of the whole interval. If npart>1 then the interval is divided into npart subintervals, each of them being processed by a subset of processes. The interval is split proportionally unless the separation points are specified with EPSKrylovSchurSetSubintervals(). Level: advanced .seealso: EPSKrylovSchurSetSubintervals(), EPSSetInterval() @*/ PetscErrorCode EPSKrylovSchurSetPartitions(EPS eps,PetscInt npart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,npart,2); ierr = PetscTryMethod(eps,"EPSKrylovSchurSetPartitions_C",(EPS,PetscInt),(eps,npart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetPartitions_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetPartitions_KrylovSchur(EPS eps,PetscInt *npart) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; *npart = ctx->npart; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetPartitions" /*@ EPSKrylovSchurGetPartitions - Gets the number of partitions of the communicator in case of spectrum slicing. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . npart - number of partitions Level: advanced .seealso: EPSKrylovSchurSetPartitions() @*/ PetscErrorCode EPSKrylovSchurGetPartitions(EPS eps,PetscInt *npart) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(npart,2); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetPartitions_C",(EPS,PetscInt*),(eps,npart));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetDetectZeros_KrylovSchur" static PetscErrorCode EPSKrylovSchurSetDetectZeros_KrylovSchur(EPS eps,PetscBool detect) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; ctx->detect = detect; eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetDetectZeros" /*@ EPSKrylovSchurSetDetectZeros - Sets a flag to enforce detection of zeros during the factorizations throughout the spectrum slicing computation. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - detect - check for zeros Options Database Key: . -eps_krylovschur_detect_zeros - Check for zeros; this takes an optional bool value (0/1/no/yes/true/false) Notes: A zero in the factorization indicates that a shift coincides with an eigenvalue. This flag is turned off by default, and may be necessary in some cases, especially when several partitions are being used. This feature currently requires an external package for factorizations with support for zero detection, e.g. MUMPS. Level: advanced .seealso: EPSKrylovSchurSetPartitions(), EPSSetInterval() @*/ PetscErrorCode EPSKrylovSchurSetDetectZeros(EPS eps,PetscBool detect) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveBool(eps,detect,2); ierr = PetscTryMethod(eps,"EPSKrylovSchurSetDetectZeros_C",(EPS,PetscBool),(eps,detect));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetDetectZeros_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetDetectZeros_KrylovSchur(EPS eps,PetscBool *detect) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; *detect = ctx->detect; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetDetectZeros" /*@ EPSKrylovSchurGetDetectZeros - Gets the flag that enforces zero detection in spectrum slicing. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameter: . detect - whether zeros detection is enforced during factorizations Level: advanced .seealso: EPSKrylovSchurSetDetectZeros() @*/ PetscErrorCode EPSKrylovSchurGetDetectZeros(EPS eps,PetscBool *detect) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(detect,2); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetDetectZeros_C",(EPS,PetscBool*),(eps,detect));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetDimensions_KrylovSchur" static PetscErrorCode EPSKrylovSchurSetDimensions_KrylovSchur(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; if (nev<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0"); ctx->nev = nev; if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) { ctx->ncv = 0; } else { if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0"); ctx->ncv = ncv; } if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) { ctx->mpd = 0; } else { if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0"); ctx->mpd = mpd; } eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetDimensions" /*@ EPSKrylovSchurSetDimensions - Sets the dimensions used for each subsolve step in case of doing spectrum slicing for a computational interval. The meaning of the parameters is the same as in EPSSetDimensions(). Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context . nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the subsolve - mpd - the maximum dimension allowed for the projected problem Options Database Key: + -eps_krylovschur_nev - Sets the number of eigenvalues . -eps_krylovschur_ncv - Sets the dimension of the subspace - -eps_krylovschur_mpd - Sets the maximum projected dimension Level: advanced .seealso: EPSKrylovSchurGetDimensions(), EPSSetDimensions(), EPSSetInterval() @*/ PetscErrorCode EPSKrylovSchurSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveInt(eps,nev,2); PetscValidLogicalCollectiveInt(eps,ncv,3); PetscValidLogicalCollectiveInt(eps,mpd,4); ierr = PetscTryMethod(eps,"EPSKrylovSchurSetDimensions_C",(EPS,PetscInt,PetscInt,PetscInt),(eps,nev,ncv,mpd));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetDimensions_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetDimensions_KrylovSchur(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd) { EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; if (nev) *nev = ctx->nev; if (ncv) *ncv = ctx->ncv; if (mpd) *mpd = ctx->mpd; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetDimensions" /*@ EPSKrylovSchurGetDimensions - Gets the dimensions used for each subsolve step in case of doing spectrum slicing for a computational interval. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: + nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the subsolve - mpd - the maximum dimension allowed for the projected problem Level: advanced .seealso: EPSKrylovSchurSetDimensions() @*/ PetscErrorCode EPSKrylovSchurGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetDimensions_C",(EPS,PetscInt*,PetscInt*,PetscInt*),(eps,nev,ncv,mpd));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetSubintervals_KrylovSchur" static PetscErrorCode EPSKrylovSchurSetSubintervals_KrylovSchur(EPS eps,PetscReal* subint) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscInt i; PetscFunctionBegin; if (subint[0]!=eps->inta || subint[ctx->npart]!=eps->intb) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"First and last values must match the endpoints of EPSSetInterval()"); for (i=0;inpart;i++) if (subint[i]>=subint[i+1]) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Array must contain values in ascending order"); if (ctx->subintervals) { ierr = PetscFree(ctx->subintervals);CHKERRQ(ierr); } ierr = PetscMalloc1(ctx->npart+1,&ctx->subintervals);CHKERRQ(ierr); for (i=0;inpart+1;i++) ctx->subintervals[i] = subint[i]; ctx->subintset = PETSC_TRUE; eps->state = EPS_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurSetSubintervals" /*@C EPSKrylovSchurSetSubintervals - Sets the points that delimit the subintervals to be used in spectrum slicing with several partitions. Logically Collective on EPS Input Parameters: + eps - the eigenproblem solver context - subint - array of real values specifying subintervals Notes: This function must be called after EPSKrylovSchurSetPartitions(). For npart partitions, the argument subint must contain npart+1 real values sorted in ascending order: subint_0, subint_1, ..., subint_npart, where the first and last values must coincide with the interval endpoints set with EPSSetInterval(). The subintervals are then defined by two consecutive points: [subint_0,subint_1], [subint_1,subint_2], and so on. Level: advanced .seealso: EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubintervals(), EPSSetInterval() @*/ PetscErrorCode EPSKrylovSchurSetSubintervals(EPS eps,PetscReal *subint) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscTryMethod(eps,"EPSKrylovSchurSetSubintervals_C",(EPS,PetscReal*),(eps,subint));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubintervals_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetSubintervals_KrylovSchur(EPS eps,PetscReal **subint) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscInt i; PetscFunctionBegin; if (!ctx->subintset) { if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first"); if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()"); } ierr = PetscMalloc1(ctx->npart+1,subint);CHKERRQ(ierr); for (i=0;i<=ctx->npart;i++) (*subint)[i] = ctx->subintervals[i]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubintervals" /*@C EPSKrylovSchurGetSubintervals - Returns the points that delimit the subintervals used in spectrum slicing with several partitions. Logically Collective on EPS Input Parameter: . eps - the eigenproblem solver context Output Parameter: . subint - array of real values specifying subintervals Notes: If the user passed values with EPSKrylovSchurSetSubintervals(), then the same values are returned. Otherwise, the values computed internally are obtained. This function is only available for spectrum slicing runs. The returned array has length npart+1 (see EPSKrylovSchurGetPartitions()) and should be freed by the user. Fortran Notes: The calling sequence from Fortran is .vb EPSKrylovSchurGetSubintervals(eps,subint,ierr) double precision subint(npart+1) output .ve Level: advanced .seealso: EPSKrylovSchurSetSubintervals(), EPSKrylovSchurGetPartitions(), EPSSetInterval() @*/ PetscErrorCode EPSKrylovSchurGetSubintervals(EPS eps,PetscReal** subint) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidPointer(subint,2); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetSubintervals_C",(EPS,PetscReal**),(eps,subint));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetInertias_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetInertias_KrylovSchur(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscInt i; EPS_SR sr = ctx->sr; PetscFunctionBegin; if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first"); if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()"); switch (eps->state) { case EPS_STATE_INITIAL: break; case EPS_STATE_SETUP: *n = ctx->npart+1; ierr = PetscMalloc1(*n,shifts);CHKERRQ(ierr); ierr = PetscMalloc1(*n,inertias);CHKERRQ(ierr); (*shifts)[0] = eps->inta; (*inertias)[0] = (sr->dir==1)?sr->inertia0:sr->inertia1; if (ctx->npart==1) { (*shifts)[1] = eps->intb; (*inertias)[1] = (sr->dir==1)?sr->inertia1:sr->inertia0; } else { for (i=1;i<*n;i++) { (*shifts)[i] = ctx->subintervals[i]; (*inertias)[i] = (*inertias)[i-1]+ctx->nconv_loc[i-1]; } } break; case EPS_STATE_SOLVED: case EPS_STATE_EIGENVECTORS: *n = ctx->nshifts; ierr = PetscMalloc1(*n,shifts);CHKERRQ(ierr); ierr = PetscMalloc1(*n,inertias);CHKERRQ(ierr); for (i=0;i<*n;i++) { (*shifts)[i] = ctx->shifts[i]; (*inertias)[i] = ctx->inertias[i]; } break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetInertias" /*@C EPSKrylovSchurGetInertias - Gets the values of the shifts and their corresponding inertias in case of doing spectrum slicing for a computational interval. Not Collective Input Parameter: . eps - the eigenproblem solver context Output Parameters: + n - number of shifts, including the endpoints of the interval . shifts - the values of the shifts used internally in the solver - inertias - the values of the inertia in each shift Notes: If called after EPSSolve(), all shifts used internally by the solver are returned (including both endpoints and any intermediate ones). If called before EPSSolve() and after EPSSetUp() then only the information of the endpoints of subintervals is available. This function is only available for spectrum slicing runs. The returned arrays should be freed by the user. Level: advanced .seealso: EPSSetInterval(), EPSKrylovSchurSetSubintervals() @*/ PetscErrorCode EPSKrylovSchurGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidIntPointer(n,2); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetInertias_C",(EPS,PetscInt*,PetscReal**,PetscInt**),(eps,n,shifts,inertias));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubcommInfo_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetSubcommInfo_KrylovSchur(EPS eps,PetscInt *k,PetscInt *n,Vec *v) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; EPS_SR sr = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr; PetscFunctionBegin; if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first"); if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()"); if (k) *k = (ctx->npart==1)? 0: ctx->subc->color; if (n) *n = sr->numEigs; if (v) { ierr = BVCreateVec(sr->V,v);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubcommInfo" /*@C EPSKrylovSchurGetSubcommInfo - Gets information related to the case of doing spectrum slicing for a computational interval with multiple communicators. Collective on the subcommunicator (if v is given) Input Parameter: . eps - the eigenproblem solver context Output Parameters: + k - index of the subinterval for the calling process . n - number of eigenvalues found in the k-th subinterval - v - a vector owned by processes in the subcommunicator with dimensions compatible for locally computed eigenvectors (or NULL) Notes: This function is only available for spectrum slicing runs. The returned Vec should be destroyed by the user. Level: advanced .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommPairs() @*/ PetscErrorCode EPSKrylovSchurGetSubcommInfo(EPS eps,PetscInt *k,PetscInt *n,Vec *v) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetSubcommInfo_C",(EPS,PetscInt*,PetscInt*,Vec*),(eps,k,n,v));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubcommPairs_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetSubcommPairs_KrylovSchur(EPS eps,PetscInt i,PetscScalar *eig,Vec v) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; EPS_SR sr = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr; PetscFunctionBegin; EPSCheckSolved(eps,1); if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()"); if (i<0 || i>=sr->numEigs) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); if (eig) *eig = sr->eigr[sr->perm[i]]; if (v) { ierr = BVCopyVec(sr->V,sr->perm[i],v);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubcommPairs" /*@C EPSKrylovSchurGetSubcommPairs - Gets the i-th eigenpair stored internally in the subcommunicator to which the calling process belongs. Collective on the subcommunicator (if v is given) Input Parameter: + eps - the eigenproblem solver context - i - index of the solution Output Parameters: + eig - the eigenvalue - v - the eigenvector Notes: It is allowed to pass NULL for v if the eigenvector is not required. Otherwise, the caller must provide a valid Vec objects, i.e., it must be created by the calling program with EPSKrylovSchurGetSubcommInfo(). The index i should be a value between 0 and n-1, where n is the number of vectors in the local subinterval, see EPSKrylovSchurGetSubcommInfo(). Level: advanced .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommInfo(), EPSKrylovSchurGetSubcommMats() @*/ PetscErrorCode EPSKrylovSchurGetSubcommPairs(EPS eps,PetscInt i,PetscScalar *eig,Vec v) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (v) PetscValidLogicalCollectiveInt(v,i,2); ierr = PetscUseMethod(eps,"EPSKrylovSchurGetSubcommPairs_C",(EPS,PetscInt,PetscScalar*,Vec),(eps,i,eig,v));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubcommMats_KrylovSchur" static PetscErrorCode EPSKrylovSchurGetSubcommMats_KrylovSchur(EPS eps,Mat *A,Mat *B) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscFunctionBegin; if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()"); if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first"); ierr = EPSGetOperators(ctx->eps,A,B);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurGetSubcommMats" /*@C EPSKrylovSchurGetSubcommMats - Gets the eigenproblem matrices stored internally in the subcommunicator to which the calling process belongs. Collective on the subcommunicator Input Parameter: . eps - the eigenproblem solver context Output Parameters: + A - the matrix associated with the eigensystem - B - the second matrix in the case of generalized eigenproblems Notes: This is the analog of EPSGetOperators(), but returns the matrices distributed differently (in the subcommunicator rather than in the parent communicator). These matrices should not be modified by the user. Level: advanced .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommInfo() @*/ PetscErrorCode EPSKrylovSchurGetSubcommMats(EPS eps,Mat *A,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); ierr = PetscTryMethod(eps,"EPSKrylovSchurGetSubcommMats_C",(EPS,Mat*,Mat*),(eps,A,B));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurUpdateSubcommMats_KrylovSchur" static PetscErrorCode EPSKrylovSchurUpdateSubcommMats_KrylovSchur(EPS eps,PetscScalar a,PetscScalar ap,Mat Au,PetscScalar b,PetscScalar bp, Mat Bu,MatStructure str,PetscBool globalup) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data,*subctx; Mat A,B=NULL,Ag,Bg=NULL; PetscBool reuse=PETSC_TRUE; PetscFunctionBegin; if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()"); if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first"); ierr = EPSGetOperators(eps,&Ag,&Bg);CHKERRQ(ierr); ierr = EPSGetOperators(ctx->eps,&A,&B);CHKERRQ(ierr); ierr = MatScale(A,a);CHKERRQ(ierr); if (Au) { ierr = MatAXPY(A,ap,Au,str);CHKERRQ(ierr); } if (B) ierr = MatScale(B,b);CHKERRQ(ierr); if (Bu) { ierr = MatAXPY(B,bp,Bu,str);CHKERRQ(ierr); } ierr = EPSSetOperators(ctx->eps,A,B);CHKERRQ(ierr); /* Update stored matrix state */ subctx = (EPS_KRYLOVSCHUR*)ctx->eps->data; ierr = PetscObjectStateGet((PetscObject)A,&subctx->Astate);CHKERRQ(ierr); if (B) { ierr = PetscObjectStateGet((PetscObject)B,&subctx->Bstate);CHKERRQ(ierr); } /* Update matrices in the parent communicator if requested by user */ if (globalup) { if (ctx->npart>1) { if (!ctx->isrow) { ierr = MatGetOwnershipIS(Ag,&ctx->isrow,&ctx->iscol);CHKERRQ(ierr); reuse = PETSC_FALSE; } if (str==DIFFERENT_NONZERO_PATTERN) reuse = PETSC_FALSE; if (ctx->submata && !reuse) { ierr = MatDestroyMatrices(1,&ctx->submata);CHKERRQ(ierr); } ierr = MatGetSubMatrices(A,1,&ctx->isrow,&ctx->iscol,(reuse)?MAT_REUSE_MATRIX:MAT_INITIAL_MATRIX,&ctx->submata);CHKERRQ(ierr); ierr = MatCreateMPIMatConcatenateSeqMat(((PetscObject)Ag)->comm,ctx->submata[0],PETSC_DECIDE,MAT_REUSE_MATRIX,&Ag);CHKERRQ(ierr); if (B) { if (ctx->submatb && !reuse) { ierr = MatDestroyMatrices(1,&ctx->submatb);CHKERRQ(ierr); } ierr = MatGetSubMatrices(B,1,&ctx->isrow,&ctx->iscol,(reuse)?MAT_REUSE_MATRIX:MAT_INITIAL_MATRIX,&ctx->submatb);CHKERRQ(ierr); ierr = MatCreateMPIMatConcatenateSeqMat(((PetscObject)Bg)->comm,ctx->submatb[0],PETSC_DECIDE,MAT_REUSE_MATRIX,&Bg);CHKERRQ(ierr); } } ierr = PetscObjectStateGet((PetscObject)Ag,&ctx->Astate);CHKERRQ(ierr); if (Bg) { ierr = PetscObjectStateGet((PetscObject)Bg,&ctx->Bstate);CHKERRQ(ierr); } } ierr = EPSSetOperators(eps,Ag,Bg);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSKrylovSchurUpdateSubcommMats" /*@C EPSKrylovSchurUpdateSubcommMats - Update the eigenproblem matrices stored internally in the subcommunicator to which the calling process belongs. Collective on EPS Input Parameters: + eps - the eigenproblem solver context . s - scalar that multiplies the existing A matrix . a - scalar used in the axpy operation on A . Au - matrix used in the axpy operation on A . t - scalar that multiplies the existing B matrix . b - scalar used in the axpy operation on B . Bu - matrix used in the axpy operation on B . str - structure flag - globalup - flag indicating if global matrices must be updated Notes: This function modifies the eigenproblem matrices at the subcommunicator level, and optionally updates the global matrices in the parent communicator. The updates are expressed as A <-- s*A + a*Au, B <-- t*B + b*Bu. It is possible to update one of the matrices, or both. The matrices Au and Bu must be equal in all subcommunicators. The str flag is passed to the MatAXPY() operations to perform the updates. If globalup is true, communication is carried out to reconstruct the updated matrices in the parent communicator. The user must be warned that if global matrices are not in sync with subcommunicator matrices, the errors computed by EPSComputeError() will be wrong even if the computed solution is correct (the synchronization may be done only once at the end). Level: advanced .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommMats() @*/ PetscErrorCode EPSKrylovSchurUpdateSubcommMats(EPS eps,PetscScalar s,PetscScalar a,Mat Au,PetscScalar t,PetscScalar b, Mat Bu,MatStructure str,PetscBool globalup) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); PetscValidLogicalCollectiveScalar(eps,s,2); PetscValidLogicalCollectiveScalar(eps,a,3); if (Au) PetscValidHeaderSpecific(Au,MAT_CLASSID,4); PetscValidLogicalCollectiveScalar(eps,t,5); PetscValidLogicalCollectiveScalar(eps,b,6); if (Bu) PetscValidHeaderSpecific(Bu,MAT_CLASSID,7); PetscValidLogicalCollectiveEnum(eps,str,8); PetscValidLogicalCollectiveBool(eps,globalup,9); ierr = PetscTryMethod(eps,"EPSKrylovSchurUpdateSubcommMats_C",(EPS,PetscScalar,PetscScalar,Mat,PetscScalar,PetscScalar,Mat,MatStructure,PetscBool),(eps,s,a,Au,t,b,Bu,str,globalup));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSSetFromOptions_KrylovSchur" PetscErrorCode EPSSetFromOptions_KrylovSchur(PetscOptionItems *PetscOptionsObject,EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscBool flg,lock,b,f1,f2,f3; PetscReal keep; PetscInt i,j,k; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"EPS Krylov-Schur Options");CHKERRQ(ierr); ierr = PetscOptionsReal("-eps_krylovschur_restart","Proportion of vectors kept after restart","EPSKrylovSchurSetRestart",0.5,&keep,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSKrylovSchurSetRestart(eps,keep);CHKERRQ(ierr); } ierr = PetscOptionsBool("-eps_krylovschur_locking","Choose between locking and non-locking variants","EPSKrylovSchurSetLocking",PETSC_TRUE,&lock,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSKrylovSchurSetLocking(eps,lock);CHKERRQ(ierr); } i = ctx->npart; ierr = PetscOptionsInt("-eps_krylovschur_partitions","Number of partitions of the communicator for spectrum slicing","EPSKrylovSchurSetPartitions",ctx->npart,&i,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSKrylovSchurSetPartitions(eps,i);CHKERRQ(ierr); } b = ctx->detect; ierr = PetscOptionsBool("-eps_krylovschur_detect_zeros","Check zeros during factorizations at subinterval boundaries","EPSKrylovSchurSetDetectZeros",ctx->detect,&b,&flg);CHKERRQ(ierr); if (flg) { ierr = EPSKrylovSchurSetDetectZeros(eps,b);CHKERRQ(ierr); } i = 1; j = k = PETSC_DECIDE; ierr = PetscOptionsInt("-eps_krylovschur_nev","Number of eigenvalues to compute in each subsolve (only for spectrum slicing)","EPSKrylovSchurSetDimensions",40,&i,&f1);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_krylovschur_ncv","Number of basis vectors in each subsolve (only for spectrum slicing)","EPSKrylovSchurSetDimensions",80,&j,&f2);CHKERRQ(ierr); ierr = PetscOptionsInt("-eps_krylovschur_mpd","Maximum dimension of projected problem in each subsolve (only for spectrum slicing)","EPSKrylovSchurSetDimensions",80,&k,&f3);CHKERRQ(ierr); if (f1 || f2 || f3) { ierr = EPSKrylovSchurSetDimensions(eps,i,j,k);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSView_KrylovSchur" PetscErrorCode EPSView_KrylovSchur(EPS eps,PetscViewer viewer) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," Krylov-Schur: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Krylov-Schur: using the %slocking variant\n",ctx->lock?"":"non-");CHKERRQ(ierr); if (eps->which==EPS_ALL) { ierr = PetscViewerASCIIPrintf(viewer," Krylov-Schur: doing spectrum slicing with nev=%D, ncv=%D, mpd=%D\n",ctx->nev,ctx->ncv,ctx->mpd);CHKERRQ(ierr); if (ctx->npart>1) { ierr = PetscViewerASCIIPrintf(viewer," Krylov-Schur: multi-communicator spectrum slicing with %D partitions\n",ctx->npart);CHKERRQ(ierr); if (ctx->detect) { ierr = PetscViewerASCIIPrintf(viewer," Krylov-Schur: detecting zeros when factorizing at subinterval boundaries\n");CHKERRQ(ierr); } } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSDestroy_KrylovSchur" PetscErrorCode EPSDestroy_KrylovSchur(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(eps->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetPartitions_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetPartitions_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDetectZeros_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDetectZeros_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDimensions_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDimensions_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetSubintervals_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubintervals_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetInertias_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommInfo_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommPairs_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommMats_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurUpdateSubcommMats_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSReset_KrylovSchur" PetscErrorCode EPSReset_KrylovSchur(EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; if (eps->which==EPS_ALL) { ierr = EPSReset_KrylovSchur_Slice(eps);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSCreate_KrylovSchur" PETSC_EXTERN PetscErrorCode EPSCreate_KrylovSchur(EPS eps) { EPS_KRYLOVSCHUR *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(eps,&ctx);CHKERRQ(ierr); eps->data = (void*)ctx; ctx->lock = PETSC_TRUE; ctx->nev = 1; ctx->npart = 1; ctx->detect = PETSC_FALSE; ctx->global = PETSC_TRUE; eps->ops->setup = EPSSetUp_KrylovSchur; eps->ops->setfromoptions = EPSSetFromOptions_KrylovSchur; eps->ops->destroy = EPSDestroy_KrylovSchur; eps->ops->reset = EPSReset_KrylovSchur; eps->ops->view = EPSView_KrylovSchur; eps->ops->backtransform = EPSBackTransform_Default; ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetRestart_C",EPSKrylovSchurSetRestart_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetRestart_C",EPSKrylovSchurGetRestart_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetLocking_C",EPSKrylovSchurSetLocking_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetLocking_C",EPSKrylovSchurGetLocking_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetPartitions_C",EPSKrylovSchurSetPartitions_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetPartitions_C",EPSKrylovSchurGetPartitions_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDetectZeros_C",EPSKrylovSchurSetDetectZeros_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDetectZeros_C",EPSKrylovSchurGetDetectZeros_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDimensions_C",EPSKrylovSchurSetDimensions_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDimensions_C",EPSKrylovSchurGetDimensions_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetSubintervals_C",EPSKrylovSchurSetSubintervals_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubintervals_C",EPSKrylovSchurGetSubintervals_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetInertias_C",EPSKrylovSchurGetInertias_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommInfo_C",EPSKrylovSchurGetSubcommInfo_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommPairs_C",EPSKrylovSchurGetSubcommPairs_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommMats_C",EPSKrylovSchurGetSubcommMats_KrylovSchur);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurUpdateSubcommMats_C",EPSKrylovSchurUpdateSubcommMats_KrylovSchur);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/krylov/krylovschur/index.html0000644000175000017500000000313213107004621022602 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

krylovschur.h
krylovschur.c
ks-symm.c
ks-slice.c
ks-indef.c
makefile
slepc-3.7.4/src/eps/impls/krylov/krylovschur/ks-indef.c0000644000175000017500000001514213107004621022455 0ustar jromanjroman/* SLEPc eigensolver: "krylovschur" Method: Krylov-Schur for symmetric-indefinite eigenproblems - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include "krylovschur.h" #undef __FUNCT__ #define __FUNCT__ "EPSSolve_KrylovSchur_Indefinite" PetscErrorCode EPSSolve_KrylovSchur_Indefinite(EPS eps) { PetscErrorCode ierr; EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data; PetscInt i,k,l,ld,nv,t,nconv=0; Mat U; Vec vomega,w=eps->work[0]; PetscScalar *Q,*aux; PetscReal *a,*b,*r,beta,beta1=1.0,*omega; PetscBool breakdown=PETSC_FALSE,symmlost=PETSC_FALSE; PetscFunctionBegin; ierr = DSGetLeadingDimension(eps->ds,&ld);CHKERRQ(ierr); /* Get the starting Lanczos vector */ ierr = EPSGetStartVector(eps,0,NULL);CHKERRQ(ierr); /* Extract sigma[0] from BV, computed during normalization */ ierr = BVSetActiveColumns(eps->V,0,1);CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF,1,&vomega);CHKERRQ(ierr); ierr = BVGetSignature(eps->V,vomega);CHKERRQ(ierr); ierr = VecGetArray(vomega,&aux);CHKERRQ(ierr); ierr = DSGetArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); omega[0] = PetscRealPart(aux[0]); ierr = DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); ierr = VecRestoreArray(vomega,&aux);CHKERRQ(ierr); ierr = VecDestroy(&vomega);CHKERRQ(ierr); l = 0; /* Restart loop */ while (eps->reason == EPS_CONVERGED_ITERATING) { eps->its++; /* Compute an nv-step Lanczos factorization */ nv = PetscMin(eps->nconv+eps->mpd,eps->ncv); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); b = a + ld; ierr = DSGetArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); ierr = EPSPseudoLanczos(eps,a,b,omega,eps->nconv+l,&nv,&breakdown,&symmlost,NULL,w);CHKERRQ(ierr); if (symmlost) { eps->reason = EPS_DIVERGED_SYMMETRY_LOST; if (nv==eps->nconv+l+1) { eps->nconv = nconv; break; } } beta = b[nv-1]; ierr = DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); ierr = DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(eps->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); } ierr = BVSetActiveColumns(eps->V,eps->nconv,nv);CHKERRQ(ierr); /* Solve projected problem */ ierr = DSSolve(eps->ds,eps->eigr,eps->eigi);CHKERRQ(ierr); ierr = DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL);CHKERRQ(ierr); /* Check convergence */ ierr = DSGetDimensions(eps->ds,NULL,NULL,NULL,NULL,&t);CHKERRQ(ierr); #if 0 /* take into account also left residual */ ierr = BVGetColumn(eps->V,nv,&u);CHKERRQ(ierr); ierr = VecNorm(u,NORM_2,&beta1);CHKERRQ(ierr); ierr = BVRestoreColumn(eps->V,nv,&u);CHKERRQ(ierr); ierr = VecNorm(w,NORM_2,&beta2);CHKERRQ(ierr); /* w contains B*V[nv] */ beta1 = PetscMax(beta1,beta2); #endif ierr = EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,t-eps->nconv,beta*beta1,1.0,&k);CHKERRQ(ierr); ierr = (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);CHKERRQ(ierr); nconv = k; /* Update l */ if (eps->reason != EPS_CONVERGED_ITERATING || breakdown) l = 0; else { l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep)); l = PetscMin(l,t); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); if (*(a+ld+k+l-1)!=0) { if (k+lds,DS_MAT_T,&a);CHKERRQ(ierr); } if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */ if (eps->reason == EPS_CONVERGED_ITERATING) { if (breakdown) { SETERRQ1(PetscObjectComm((PetscObject)eps),PETSC_ERR_CONV_FAILED,"Breakdown in Indefinite Krylov-Schur (beta=%g)",beta); } else { /* Prepare the Rayleigh quotient for restart */ ierr = DSGetArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSGetArrayReal(eps->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSGetArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); b = a + ld; r = a + 2*ld; for (i=k;ids,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSRestoreArray(eps->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); } } /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */ ierr = DSGetMat(eps->ds,DS_MAT_Q,&U);CHKERRQ(ierr); ierr = BVMultInPlace(eps->V,U,eps->nconv,k+l);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); /* Move restart vector and update signature */ if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) { ierr = BVCopyColumn(eps->V,nv,k+l);CHKERRQ(ierr); ierr = DSGetArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF,k+l,&vomega);CHKERRQ(ierr); ierr = VecGetArray(vomega,&aux);CHKERRQ(ierr); for (i=0;iV,0,k+l);CHKERRQ(ierr); ierr = BVSetSignature(eps->V,vomega);CHKERRQ(ierr); ierr = VecDestroy(&vomega);CHKERRQ(ierr); ierr = DSRestoreArrayReal(eps->ds,DS_MAT_D,&omega);CHKERRQ(ierr); } eps->nconv = k; ierr = EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,nv);CHKERRQ(ierr); } ierr = DSSetDimensions(eps->ds,eps->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(eps->ds,DS_STATE_RAW);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/eps/impls/krylov/krylovschur/ftn-auto/0000755000175000017500000000000013107004621022343 5ustar jromanjromanslepc-3.7.4/src/eps/impls/krylov/krylovschur/ftn-auto/makefile0000644000175000017500000000040213107004621024037 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = krylovschurf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepceps LOCDIR = src/eps/impls/krylov/krylovschur/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/eps/impls/krylov/krylovschur/ftn-auto/krylovschurf.c0000644000175000017500000001170613107004621025255 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* krylovschur.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepceps.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschursetrestart_ EPSKRYLOVSCHURSETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschursetrestart_ epskrylovschursetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschurgetrestart_ EPSKRYLOVSCHURGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschurgetrestart_ epskrylovschurgetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschursetlocking_ EPSKRYLOVSCHURSETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschursetlocking_ epskrylovschursetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschurgetlocking_ EPSKRYLOVSCHURGETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschurgetlocking_ epskrylovschurgetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschursetpartitions_ EPSKRYLOVSCHURSETPARTITIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschursetpartitions_ epskrylovschursetpartitions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschurgetpartitions_ EPSKRYLOVSCHURGETPARTITIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschurgetpartitions_ epskrylovschurgetpartitions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschursetdetectzeros_ EPSKRYLOVSCHURSETDETECTZEROS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschursetdetectzeros_ epskrylovschursetdetectzeros #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschurgetdetectzeros_ EPSKRYLOVSCHURGETDETECTZEROS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschurgetdetectzeros_ epskrylovschurgetdetectzeros #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschursetdimensions_ EPSKRYLOVSCHURSETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschursetdimensions_ epskrylovschursetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define epskrylovschurgetdimensions_ EPSKRYLOVSCHURGETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define epskrylovschurgetdimensions_ epskrylovschurgetdimensions #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL epskrylovschursetrestart_(EPS eps,PetscReal *keep, int *__ierr ){ *__ierr = EPSKrylovSchurSetRestart( (EPS)PetscToPointer((eps) ),*keep); } PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetrestart_(EPS eps,PetscReal *keep, int *__ierr ){ *__ierr = EPSKrylovSchurGetRestart( (EPS)PetscToPointer((eps) ),keep); } PETSC_EXTERN void PETSC_STDCALL epskrylovschursetlocking_(EPS eps,PetscBool *lock, int *__ierr ){ *__ierr = EPSKrylovSchurSetLocking( (EPS)PetscToPointer((eps) ),*lock); } PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetlocking_(EPS eps,PetscBool *lock, int *__ierr ){ *__ierr = EPSKrylovSchurGetLocking( (EPS)PetscToPointer((eps) ),lock); } PETSC_EXTERN void PETSC_STDCALL epskrylovschursetpartitions_(EPS eps,PetscInt *npart, int *__ierr ){ *__ierr = EPSKrylovSchurSetPartitions( (EPS)PetscToPointer((eps) ),*npart); } PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetpartitions_(EPS eps,PetscInt *npart, int *__ierr ){ *__ierr = EPSKrylovSchurGetPartitions( (EPS)PetscToPointer((eps) ),npart); } PETSC_EXTERN void PETSC_STDCALL epskrylovschursetdetectzeros_(EPS eps,PetscBool *detect, int *__ierr ){ *__ierr = EPSKrylovSchurSetDetectZeros( (EPS)PetscToPointer((eps) ),*detect); } PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetdetectzeros_(EPS eps,PetscBool *detect, int *__ierr ){ *__ierr = EPSKrylovSchurGetDetectZeros( (EPS)PetscToPointer((eps) ),detect); } PETSC_EXTERN void PETSC_STDCALL epskrylovschursetdimensions_(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = EPSKrylovSchurSetDimensions( (EPS)PetscToPointer((eps) ),*nev,*ncv,*mpd); } PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetdimensions_(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = EPSKrylovSchurGetDimensions( (EPS)PetscToPointer((eps) ),nev,ncv,mpd); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/eps/impls/krylov/krylovschur/krylovschur.c.html0000644000175000017500000034240513107004621024320 0ustar jromanjroman

Actual source code: krylovschur.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "krylovschur"

  5:    Method: Krylov-Schur

  7:    Algorithm:

  9:        Single-vector Krylov-Schur method for non-symmetric problems,
 10:        including harmonic extraction.

 12:    References:

 14:        [1] "Krylov-Schur Methods in SLEPc", SLEPc Technical Report STR-7,
 15:            available at http://slepc.upv.es.

 17:        [2] G.W. Stewart, "A Krylov-Schur Algorithm for Large Eigenproblems",
 18:            SIAM J. Matrix Anal. App. 23(3):601-614, 2001.

 20:        [3] "Practical Implementation of Harmonic Krylov-Schur", SLEPc Technical
 21:             Report STR-9, available at http://slepc.upv.es.

 23:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 24:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 25:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 27:    This file is part of SLEPc.

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

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

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

 43: #include <slepc/private/epsimpl.h>                /*I "slepceps.h" I*/
 44:  #include krylovschur.h

 48: PetscErrorCode EPSGetArbitraryValues(EPS eps,PetscScalar *rr,PetscScalar *ri)
 49: {
 51:   PetscInt       i,newi,ld,n,l;
 52:   Vec            xr=eps->work[0],xi=eps->work[1];
 53:   PetscScalar    re,im,*Zr,*Zi,*X;

 56:   DSGetLeadingDimension(eps->ds,&ld);
 57:   DSGetDimensions(eps->ds,&n,NULL,&l,NULL,NULL);
 58:   for (i=l;i<n;i++) {
 59:     re = eps->eigr[i];
 60:     im = eps->eigi[i];
 61:     STBackTransform(eps->st,1,&re,&im);
 62:     newi = i;
 63:     DSVectors(eps->ds,DS_MAT_X,&newi,NULL);
 64:     DSGetArray(eps->ds,DS_MAT_X,&X);
 65:     Zr = X+i*ld;
 66:     if (newi==i+1) Zi = X+newi*ld;
 67:     else Zi = NULL;
 68:     EPSComputeRitzVector(eps,Zr,Zi,eps->V,xr,xi);
 69:     DSRestoreArray(eps->ds,DS_MAT_X,&X);
 70:     (*eps->arbitrary)(re,im,xr,xi,rr+i,ri+i,eps->arbitraryctx);
 71:   }
 72:   return(0);
 73: }

 77: PetscErrorCode EPSSetUp_KrylovSchur(EPS eps)
 78: {
 79:   PetscErrorCode    ierr;
 80:   PetscReal         eta;
 81:   BVOrthogType      otype;
 82:   BVOrthogBlockType obtype;
 83:   EPS_KRYLOVSCHUR   *ctx = (EPS_KRYLOVSCHUR*)eps->data;
 84:   enum { EPS_KS_DEFAULT,EPS_KS_SYMM,EPS_KS_SLICE,EPS_KS_INDEF } variant;

 87:   /* spectrum slicing requires special treatment of default values */
 88:   if (eps->which==EPS_ALL) {
 89:     EPSSetUp_KrylovSchur_Slice(eps);
 90:   } else {
 91:     EPSSetDimensions_Default(eps,eps->nev,&eps->ncv,&eps->mpd);
 92:     if (eps->ncv>eps->nev+eps->mpd) SETERRQ(PetscObjectComm((PetscObject)eps),1,"The value of ncv must not be larger than nev+mpd");
 93:     if (!eps->max_it) eps->max_it = PetscMax(100,2*eps->n/eps->ncv);
 94:     if (!eps->which) { EPSSetWhichEigenpairs_Default(eps); }
 95:   }
 96:   if (!ctx->lock && eps->mpd<eps->ncv) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant");

 98:   if (eps->isgeneralized && eps->ishermitian && !eps->ispositive && eps->arbitrary) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Arbitrary selection of eigenpairs not implemented for indefinite problems");
 99:   if (eps->ishermitian && eps->ispositive && (eps->which==EPS_LARGEST_IMAGINARY || eps->which==EPS_SMALLEST_IMAGINARY)) SETERRQ(PetscObjectComm((PetscObject)eps),1,"Wrong value of eps->which");

101:   if (!eps->extraction) {
102:     EPSSetExtraction(eps,EPS_RITZ);
103:   } else if (eps->extraction!=EPS_RITZ && eps->extraction!=EPS_HARMONIC)
104:     SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
105:   if (eps->extraction==EPS_HARMONIC && ctx->lock) { PetscInfo(eps,"Locking was requested but will be deactivated since is not supported with harmonic extraction\n"); }

107:   if (!ctx->keep) ctx->keep = 0.5;

109:   EPSAllocateSolution(eps,1);
110:   EPS_SetInnerProduct(eps);
111:   if (eps->arbitrary) {
112:     EPSSetWorkVecs(eps,2);
113:   } else if (eps->ishermitian && !eps->ispositive){
114:     EPSSetWorkVecs(eps,1);
115:   }

117:   /* dispatch solve method */
118:   if (eps->ishermitian) {
119:     if (eps->which==EPS_ALL) {
120:       if (eps->isgeneralized && !eps->ispositive) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectrum slicing not implemented for indefinite problems");
121:       else variant = EPS_KS_SLICE;
122:     } else if (eps->isgeneralized && !eps->ispositive) {
123:       variant = EPS_KS_INDEF;
124:     } else {
125:       switch (eps->extraction) {
126:         case EPS_RITZ:     variant = EPS_KS_SYMM; break;
127:         case EPS_HARMONIC: variant = EPS_KS_DEFAULT; break;
128:         default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
129:       }
130:     }
131:   } else {
132:     switch (eps->extraction) {
133:       case EPS_RITZ:     variant = EPS_KS_DEFAULT; break;
134:       case EPS_HARMONIC: variant = EPS_KS_DEFAULT; break;
135:       default: SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Unsupported extraction type");
136:     }
137:   }
138:   switch (variant) {
139:     case EPS_KS_DEFAULT:
140:       eps->ops->solve = EPSSolve_KrylovSchur_Default;
141:       eps->ops->computevectors = EPSComputeVectors_Schur;
142:       DSSetType(eps->ds,DSNHEP);
143:       DSAllocate(eps->ds,eps->ncv+1);
144:       break;
145:     case EPS_KS_SYMM:
146:       eps->ops->solve = EPSSolve_KrylovSchur_Symm;
147:       eps->ops->computevectors = EPSComputeVectors_Hermitian;
148:       DSSetType(eps->ds,DSHEP);
149:       DSSetCompact(eps->ds,PETSC_TRUE);
150:       DSSetExtraRow(eps->ds,PETSC_TRUE);
151:       DSAllocate(eps->ds,eps->ncv+1);
152:       break;
153:     case EPS_KS_SLICE:
154:       if (eps->stopping!=EPSStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Spectrum slicing does not support user-defined stopping test");
155:       eps->ops->solve = EPSSolve_KrylovSchur_Slice;
156:       eps->ops->computevectors = EPSComputeVectors_Slice;
157:       break;
158:     case EPS_KS_INDEF:
159:       eps->ops->solve = EPSSolve_KrylovSchur_Indefinite;
160:       eps->ops->computevectors = EPSComputeVectors_Indefinite;
161:       DSSetType(eps->ds,DSGHIEP);
162:       DSSetCompact(eps->ds,PETSC_TRUE);
163:       DSAllocate(eps->ds,eps->ncv+1);
164:       /* force reorthogonalization for pseudo-Lanczos */
165:       BVGetOrthogonalization(eps->V,&otype,NULL,&eta,&obtype);
166:       BVSetOrthogonalization(eps->V,otype,BV_ORTHOG_REFINE_ALWAYS,eta,obtype);
167:       break;
168:     default: SETERRQ(PetscObjectComm((PetscObject)eps),1,"Unexpected error");
169:   }
170:   return(0);
171: }

175: PetscErrorCode EPSSolve_KrylovSchur_Default(EPS eps)
176: {
177:   PetscErrorCode  ierr;
178:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
179:   PetscInt        i,j,*pj,k,l,nv,ld,nconv;
180:   Mat             U;
181:   PetscScalar     *S,*Q,*g;
182:   PetscReal       beta,gamma=1.0;
183:   PetscBool       breakdown,harmonic;

186:   DSGetLeadingDimension(eps->ds,&ld);
187:   harmonic = (eps->extraction==EPS_HARMONIC || eps->extraction==EPS_REFINED_HARMONIC)?PETSC_TRUE:PETSC_FALSE;
188:   if (harmonic) { PetscMalloc1(ld,&g); }
189:   if (eps->arbitrary) pj = &j;
190:   else pj = NULL;

192:   /* Get the starting Arnoldi vector */
193:   EPSGetStartVector(eps,0,NULL);
194:   l = 0;

196:   /* Restart loop */
197:   while (eps->reason == EPS_CONVERGED_ITERATING) {
198:     eps->its++;

200:     /* Compute an nv-step Arnoldi factorization */
201:     nv = PetscMin(eps->nconv+eps->mpd,eps->ncv);
202:     DSGetArray(eps->ds,DS_MAT_A,&S);
203:     EPSBasicArnoldi(eps,PETSC_FALSE,S,ld,eps->nconv+l,&nv,&beta,&breakdown);
204:     DSRestoreArray(eps->ds,DS_MAT_A,&S);
205:     DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);
206:     if (l==0) {
207:       DSSetState(eps->ds,DS_STATE_INTERMEDIATE);
208:     } else {
209:       DSSetState(eps->ds,DS_STATE_RAW);
210:     }
211:     BVSetActiveColumns(eps->V,eps->nconv,nv);

213:     /* Compute translation of Krylov decomposition if harmonic extraction used */
214:     if (harmonic) {
215:       DSTranslateHarmonic(eps->ds,eps->target,beta,PETSC_FALSE,g,&gamma);
216:     }

218:     /* Solve projected problem */
219:     DSSolve(eps->ds,eps->eigr,eps->eigi);
220:     if (eps->arbitrary) {
221:       EPSGetArbitraryValues(eps,eps->rr,eps->ri);
222:       j=1;
223:     }
224:     DSSort(eps->ds,eps->eigr,eps->eigi,eps->rr,eps->ri,pj);

226:     /* Check convergence */
227:     EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,nv-eps->nconv,beta,gamma,&k);
228:     (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);
229:     nconv = k;

231:     /* Update l */
232:     if (eps->reason != EPS_CONVERGED_ITERATING || breakdown) l = 0;
233:     else {
234:       l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep));
235: #if !defined(PETSC_USE_COMPLEX)
236:       DSGetArray(eps->ds,DS_MAT_A,&S);
237:       if (S[k+l+(k+l-1)*ld] != 0.0) {
238:         if (k+l<nv-1) l = l+1;
239:         else l = l-1;
240:       }
241:       DSRestoreArray(eps->ds,DS_MAT_A,&S);
242: #endif
243:     }
244:     if ((!ctx->lock || harmonic) && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */

246:     if (eps->reason == EPS_CONVERGED_ITERATING) {
247:       if (breakdown) {
248:         /* Start a new Arnoldi factorization */
249:         PetscInfo2(eps,"Breakdown in Krylov-Schur method (it=%D norm=%g)\n",eps->its,(double)beta);
250:         if (k<eps->nev) {
251:           EPSGetStartVector(eps,k,&breakdown);
252:           if (breakdown) {
253:             eps->reason = EPS_DIVERGED_BREAKDOWN;
254:             PetscInfo(eps,"Unable to generate more start vectors\n");
255:           }
256:         }
257:       } else {
258:         /* Undo translation of Krylov decomposition */
259:         if (harmonic) {
260:           DSSetDimensions(eps->ds,nv,0,k,l);
261:           DSTranslateHarmonic(eps->ds,0.0,beta,PETSC_TRUE,g,&gamma);
262:           /* gamma u^ = u - U*g~ */
263:           BVMultColumn(eps->V,-1.0,1.0,nv,g);
264:           BVScaleColumn(eps->V,nv,1.0/gamma);
265:         }
266:         /* Prepare the Rayleigh quotient for restart */
267:         DSGetArray(eps->ds,DS_MAT_A,&S);
268:         DSGetArray(eps->ds,DS_MAT_Q,&Q);
269:         for (i=k;i<k+l;i++) {
270:           S[k+l+i*ld] = Q[nv-1+i*ld]*beta*gamma;
271:         }
272:         DSRestoreArray(eps->ds,DS_MAT_A,&S);
273:         DSRestoreArray(eps->ds,DS_MAT_Q,&Q);
274:       }
275:     }
276:     /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */
277:     DSGetMat(eps->ds,DS_MAT_Q,&U);
278:     BVMultInPlace(eps->V,U,eps->nconv,k+l);
279:     MatDestroy(&U);

281:     if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) {
282:       BVCopyColumn(eps->V,nv,k+l);
283:     }
284:     eps->nconv = k;
285:     EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,nv);
286:   }

288:   if (harmonic) { PetscFree(g); }
289:   /* truncate Schur decomposition and change the state to raw so that
290:      DSVectors() computes eigenvectors from scratch */
291:   DSSetDimensions(eps->ds,eps->nconv,0,0,0);
292:   DSSetState(eps->ds,DS_STATE_RAW);
293:   return(0);
294: }

298: static PetscErrorCode EPSKrylovSchurSetRestart_KrylovSchur(EPS eps,PetscReal keep)
299: {
300:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

303:   if (keep==PETSC_DEFAULT) ctx->keep = 0.5;
304:   else {
305:     if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]");
306:     ctx->keep = keep;
307:   }
308:   return(0);
309: }

313: /*@
314:    EPSKrylovSchurSetRestart - Sets the restart parameter for the Krylov-Schur
315:    method, in particular the proportion of basis vectors that must be kept
316:    after restart.

318:    Logically Collective on EPS

320:    Input Parameters:
321: +  eps - the eigenproblem solver context
322: -  keep - the number of vectors to be kept at restart

324:    Options Database Key:
325: .  -eps_krylovschur_restart - Sets the restart parameter

327:    Notes:
328:    Allowed values are in the range [0.1,0.9]. The default is 0.5.

330:    Level: advanced

332: .seealso: EPSKrylovSchurGetRestart()
333: @*/
334: PetscErrorCode EPSKrylovSchurSetRestart(EPS eps,PetscReal keep)
335: {

341:   PetscTryMethod(eps,"EPSKrylovSchurSetRestart_C",(EPS,PetscReal),(eps,keep));
342:   return(0);
343: }

347: static PetscErrorCode EPSKrylovSchurGetRestart_KrylovSchur(EPS eps,PetscReal *keep)
348: {
349:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

352:   *keep = ctx->keep;
353:   return(0);
354: }

358: /*@
359:    EPSKrylovSchurGetRestart - Gets the restart parameter used in the
360:    Krylov-Schur method.

362:    Not Collective

364:    Input Parameter:
365: .  eps - the eigenproblem solver context

367:    Output Parameter:
368: .  keep - the restart parameter

370:    Level: advanced

372: .seealso: EPSKrylovSchurSetRestart()
373: @*/
374: PetscErrorCode EPSKrylovSchurGetRestart(EPS eps,PetscReal *keep)
375: {

381:   PetscUseMethod(eps,"EPSKrylovSchurGetRestart_C",(EPS,PetscReal*),(eps,keep));
382:   return(0);
383: }

387: static PetscErrorCode EPSKrylovSchurSetLocking_KrylovSchur(EPS eps,PetscBool lock)
388: {
389:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

392:   ctx->lock = lock;
393:   return(0);
394: }

398: /*@
399:    EPSKrylovSchurSetLocking - Choose between locking and non-locking variants of
400:    the Krylov-Schur method.

402:    Logically Collective on EPS

404:    Input Parameters:
405: +  eps  - the eigenproblem solver context
406: -  lock - true if the locking variant must be selected

408:    Options Database Key:
409: .  -eps_krylovschur_locking - Sets the locking flag

411:    Notes:
412:    The default is to lock converged eigenpairs when the method restarts.
413:    This behaviour can be changed so that all directions are kept in the
414:    working subspace even if already converged to working accuracy (the
415:    non-locking variant).

417:    Level: advanced

419: .seealso: EPSKrylovSchurGetLocking()
420: @*/
421: PetscErrorCode EPSKrylovSchurSetLocking(EPS eps,PetscBool lock)
422: {

428:   PetscTryMethod(eps,"EPSKrylovSchurSetLocking_C",(EPS,PetscBool),(eps,lock));
429:   return(0);
430: }

434: static PetscErrorCode EPSKrylovSchurGetLocking_KrylovSchur(EPS eps,PetscBool *lock)
435: {
436:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

439:   *lock = ctx->lock;
440:   return(0);
441: }

445: /*@
446:    EPSKrylovSchurGetLocking - Gets the locking flag used in the Krylov-Schur
447:    method.

449:    Not Collective

451:    Input Parameter:
452: .  eps - the eigenproblem solver context

454:    Output Parameter:
455: .  lock - the locking flag

457:    Level: advanced

459: .seealso: EPSKrylovSchurSetLocking()
460: @*/
461: PetscErrorCode EPSKrylovSchurGetLocking(EPS eps,PetscBool *lock)
462: {

468:   PetscUseMethod(eps,"EPSKrylovSchurGetLocking_C",(EPS,PetscBool*),(eps,lock));
469:   return(0);
470: }

474: static PetscErrorCode EPSKrylovSchurSetPartitions_KrylovSchur(EPS eps,PetscInt npart)
475: {
476:   PetscErrorCode  ierr;
477:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
478:   PetscMPIInt     size;

481:   if (ctx->npart!=npart) {
482:     if (ctx->commset) { PetscSubcommDestroy(&ctx->subc); }
483:     if (ctx->eps) { EPSDestroy(&ctx->eps); }
484:   } 
485:   if (npart == PETSC_DEFAULT || npart == PETSC_DECIDE) {
486:     ctx->npart = 1;
487:   } else {
488:     MPI_Comm_size(PetscObjectComm((PetscObject)eps),&size);
489:     if (npart<1 || npart>size) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart");
490:     ctx->npart = npart;
491:   }
492:   eps->state = EPS_STATE_INITIAL;
493:   return(0);
494: }

498: /*@
499:    EPSKrylovSchurSetPartitions - Sets the number of partitions for the
500:    case of doing spectrum slicing for a computational interval with the
501:    communicator split in several sub-communicators.

503:    Logically Collective on EPS

505:    Input Parameters:
506: +  eps   - the eigenproblem solver context
507: -  npart - number of partitions

509:    Options Database Key:
510: .  -eps_krylovschur_partitions <npart> - Sets the number of partitions

512:    Notes:
513:    By default, npart=1 so all processes in the communicator participate in
514:    the processing of the whole interval. If npart>1 then the interval is
515:    divided into npart subintervals, each of them being processed by a
516:    subset of processes.

518:    The interval is split proportionally unless the separation points are
519:    specified with EPSKrylovSchurSetSubintervals().

521:    Level: advanced

523: .seealso: EPSKrylovSchurSetSubintervals(), EPSSetInterval()
524: @*/
525: PetscErrorCode EPSKrylovSchurSetPartitions(EPS eps,PetscInt npart)
526: {

532:   PetscTryMethod(eps,"EPSKrylovSchurSetPartitions_C",(EPS,PetscInt),(eps,npart));
533:   return(0);
534: }

538: static PetscErrorCode EPSKrylovSchurGetPartitions_KrylovSchur(EPS eps,PetscInt *npart)
539: {
540:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

543:   *npart  = ctx->npart;
544:   return(0);
545: }

549: /*@
550:    EPSKrylovSchurGetPartitions - Gets the number of partitions of the
551:    communicator in case of spectrum slicing.

553:    Not Collective

555:    Input Parameter:
556: .  eps - the eigenproblem solver context

558:    Output Parameter:
559: .  npart - number of partitions

561:    Level: advanced

563: .seealso: EPSKrylovSchurSetPartitions()
564: @*/
565: PetscErrorCode EPSKrylovSchurGetPartitions(EPS eps,PetscInt *npart)
566: {

572:   PetscUseMethod(eps,"EPSKrylovSchurGetPartitions_C",(EPS,PetscInt*),(eps,npart));
573:   return(0);
574: }

578: static PetscErrorCode EPSKrylovSchurSetDetectZeros_KrylovSchur(EPS eps,PetscBool detect)
579: {
580:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

583:   ctx->detect = detect;
584:   eps->state  = EPS_STATE_INITIAL;
585:   return(0);
586: }

590: /*@
591:    EPSKrylovSchurSetDetectZeros - Sets a flag to enforce detection of
592:    zeros during the factorizations throughout the spectrum slicing computation.

594:    Logically Collective on EPS

596:    Input Parameters:
597: +  eps    - the eigenproblem solver context
598: -  detect - check for zeros

600:    Options Database Key:
601: .  -eps_krylovschur_detect_zeros - Check for zeros; this takes an optional
602:    bool value (0/1/no/yes/true/false)

604:    Notes:
605:    A zero in the factorization indicates that a shift coincides with an eigenvalue.

607:    This flag is turned off by default, and may be necessary in some cases,
608:    especially when several partitions are being used. This feature currently
609:    requires an external package for factorizations with support for zero
610:    detection, e.g. MUMPS.

612:    Level: advanced

614: .seealso: EPSKrylovSchurSetPartitions(), EPSSetInterval()
615: @*/
616: PetscErrorCode EPSKrylovSchurSetDetectZeros(EPS eps,PetscBool detect)
617: {

623:   PetscTryMethod(eps,"EPSKrylovSchurSetDetectZeros_C",(EPS,PetscBool),(eps,detect));
624:   return(0);
625: }

629: static PetscErrorCode EPSKrylovSchurGetDetectZeros_KrylovSchur(EPS eps,PetscBool *detect)
630: {
631:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

634:   *detect = ctx->detect;
635:   return(0);
636: }

640: /*@
641:    EPSKrylovSchurGetDetectZeros - Gets the flag that enforces zero detection
642:    in spectrum slicing.

644:    Not Collective

646:    Input Parameter:
647: .  eps - the eigenproblem solver context

649:    Output Parameter:
650: .  detect - whether zeros detection is enforced during factorizations

652:    Level: advanced

654: .seealso: EPSKrylovSchurSetDetectZeros()
655: @*/
656: PetscErrorCode EPSKrylovSchurGetDetectZeros(EPS eps,PetscBool *detect)
657: {

663:   PetscUseMethod(eps,"EPSKrylovSchurGetDetectZeros_C",(EPS,PetscBool*),(eps,detect));
664:   return(0);
665: }

669: static PetscErrorCode EPSKrylovSchurSetDimensions_KrylovSchur(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)
670: {
671:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

674:   if (nev<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
675:   ctx->nev = nev;
676:   if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) {
677:     ctx->ncv = 0;
678:   } else {
679:     if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
680:     ctx->ncv = ncv;
681:   }
682:   if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) {
683:     ctx->mpd = 0;
684:   } else {
685:     if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
686:     ctx->mpd = mpd;
687:   }
688:   eps->state = EPS_STATE_INITIAL;
689:   return(0);
690: }

694: /*@
695:    EPSKrylovSchurSetDimensions - Sets the dimensions used for each subsolve
696:    step in case of doing spectrum slicing for a computational interval.
697:    The meaning of the parameters is the same as in EPSSetDimensions().

699:    Logically Collective on EPS

701:    Input Parameters:
702: +  eps - the eigenproblem solver context
703: .  nev - number of eigenvalues to compute
704: .  ncv - the maximum dimension of the subspace to be used by the subsolve
705: -  mpd - the maximum dimension allowed for the projected problem

707:    Options Database Key:
708: +  -eps_krylovschur_nev <nev> - Sets the number of eigenvalues
709: .  -eps_krylovschur_ncv <ncv> - Sets the dimension of the subspace
710: -  -eps_krylovschur_mpd <mpd> - Sets the maximum projected dimension

712:    Level: advanced

714: .seealso: EPSKrylovSchurGetDimensions(), EPSSetDimensions(), EPSSetInterval()
715: @*/
716: PetscErrorCode EPSKrylovSchurSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)
717: {

725:   PetscTryMethod(eps,"EPSKrylovSchurSetDimensions_C",(EPS,PetscInt,PetscInt,PetscInt),(eps,nev,ncv,mpd));
726:   return(0);
727: }

731: static PetscErrorCode EPSKrylovSchurGetDimensions_KrylovSchur(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
732: {
733:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

736:   if (nev) *nev = ctx->nev;
737:   if (ncv) *ncv = ctx->ncv;
738:   if (mpd) *mpd = ctx->mpd;
739:   return(0);
740: }

744: /*@
745:    EPSKrylovSchurGetDimensions - Gets the dimensions used for each subsolve
746:    step in case of doing spectrum slicing for a computational interval.

748:    Not Collective

750:    Input Parameter:
751: .  eps - the eigenproblem solver context

753:    Output Parameters:
754: +  nev - number of eigenvalues to compute
755: .  ncv - the maximum dimension of the subspace to be used by the subsolve
756: -  mpd - the maximum dimension allowed for the projected problem

758:    Level: advanced

760: .seealso: EPSKrylovSchurSetDimensions()
761: @*/
762: PetscErrorCode EPSKrylovSchurGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
763: {

768:   PetscUseMethod(eps,"EPSKrylovSchurGetDimensions_C",(EPS,PetscInt*,PetscInt*,PetscInt*),(eps,nev,ncv,mpd));
769:   return(0);
770: }

774: static PetscErrorCode EPSKrylovSchurSetSubintervals_KrylovSchur(EPS eps,PetscReal* subint)
775: {
776:   PetscErrorCode  ierr;
777:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
778:   PetscInt        i;

781:   if (subint[0]!=eps->inta || subint[ctx->npart]!=eps->intb) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"First and last values must match the endpoints of EPSSetInterval()");
782:   for (i=0;i<ctx->npart;i++) if (subint[i]>=subint[i+1]) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Array must contain values in ascending order");
783:   if (ctx->subintervals) { PetscFree(ctx->subintervals); }
784:   PetscMalloc1(ctx->npart+1,&ctx->subintervals);
785:   for (i=0;i<ctx->npart+1;i++) ctx->subintervals[i] = subint[i];
786:   ctx->subintset = PETSC_TRUE;
787:   eps->state = EPS_STATE_INITIAL;
788:   return(0);
789: }

793: /*@C
794:    EPSKrylovSchurSetSubintervals - Sets the points that delimit the
795:    subintervals to be used in spectrum slicing with several partitions.

797:    Logically Collective on EPS

799:    Input Parameters:
800: +  eps    - the eigenproblem solver context
801: -  subint - array of real values specifying subintervals

803:    Notes:
804:    This function must be called after EPSKrylovSchurSetPartitions(). For npart
805:    partitions, the argument subint must contain npart+1 real values sorted in
806:    ascending order: subint_0, subint_1, ..., subint_npart, where the first
807:    and last values must coincide with the interval endpoints set with
808:    EPSSetInterval().

810:    The subintervals are then defined by two consecutive points: [subint_0,subint_1],
811:    [subint_1,subint_2], and so on.

813:    Level: advanced

815: .seealso: EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubintervals(), EPSSetInterval()
816: @*/
817: PetscErrorCode EPSKrylovSchurSetSubintervals(EPS eps,PetscReal *subint)
818: {

823:   PetscTryMethod(eps,"EPSKrylovSchurSetSubintervals_C",(EPS,PetscReal*),(eps,subint));
824:   return(0);
825: }

829: static PetscErrorCode EPSKrylovSchurGetSubintervals_KrylovSchur(EPS eps,PetscReal **subint)
830: {
831:   PetscErrorCode  ierr;
832:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
833:   PetscInt        i;

836:   if (!ctx->subintset) {
837:     if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first");
838:     if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()");
839:   }
840:   PetscMalloc1(ctx->npart+1,subint);
841:   for (i=0;i<=ctx->npart;i++) (*subint)[i] = ctx->subintervals[i];
842:   return(0);
843: }

847: /*@C
848:    EPSKrylovSchurGetSubintervals - Returns the points that delimit the
849:    subintervals used in spectrum slicing with several partitions.

851:    Logically Collective on EPS

853:    Input Parameter:
854: .  eps    - the eigenproblem solver context

856:    Output Parameter:
857: .  subint - array of real values specifying subintervals

859:    Notes:
860:    If the user passed values with EPSKrylovSchurSetSubintervals(), then the
861:    same values are returned. Otherwise, the values computed internally are
862:    obtained.

864:    This function is only available for spectrum slicing runs.

866:    The returned array has length npart+1 (see EPSKrylovSchurGetPartitions())
867:    and should be freed by the user.

869:    Fortran Notes:
870:    The calling sequence from Fortran is
871: .vb
872:    EPSKrylovSchurGetSubintervals(eps,subint,ierr)
873:    double precision subint(npart+1) output
874: .ve

876:    Level: advanced

878: .seealso: EPSKrylovSchurSetSubintervals(), EPSKrylovSchurGetPartitions(), EPSSetInterval()
879: @*/
880: PetscErrorCode EPSKrylovSchurGetSubintervals(EPS eps,PetscReal** subint)
881: {

887:   PetscUseMethod(eps,"EPSKrylovSchurGetSubintervals_C",(EPS,PetscReal**),(eps,subint));
888:   return(0);
889: }

893: static PetscErrorCode EPSKrylovSchurGetInertias_KrylovSchur(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)
894: {
895:   PetscErrorCode  ierr;
896:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
897:   PetscInt        i;
898:   EPS_SR          sr = ctx->sr;

901:   if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first");
902:   if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()");
903:   switch (eps->state) {
904:   case EPS_STATE_INITIAL:
905:     break;
906:   case EPS_STATE_SETUP:
907:     *n = ctx->npart+1;
908:     PetscMalloc1(*n,shifts);
909:     PetscMalloc1(*n,inertias);
910:     (*shifts)[0] = eps->inta;
911:     (*inertias)[0] = (sr->dir==1)?sr->inertia0:sr->inertia1;
912:     if (ctx->npart==1) {
913:       (*shifts)[1] = eps->intb;
914:       (*inertias)[1] = (sr->dir==1)?sr->inertia1:sr->inertia0;
915:     } else {
916:       for (i=1;i<*n;i++) {
917:         (*shifts)[i] = ctx->subintervals[i];
918:         (*inertias)[i] = (*inertias)[i-1]+ctx->nconv_loc[i-1];
919:       }
920:     }
921:     break;
922:   case EPS_STATE_SOLVED:
923:   case EPS_STATE_EIGENVECTORS:
924:     *n = ctx->nshifts;
925:     PetscMalloc1(*n,shifts);
926:     PetscMalloc1(*n,inertias);
927:     for (i=0;i<*n;i++) {
928:       (*shifts)[i] = ctx->shifts[i];
929:       (*inertias)[i] = ctx->inertias[i];
930:     }
931:     break;
932:   }
933:   return(0);
934: }

938: /*@C
939:    EPSKrylovSchurGetInertias - Gets the values of the shifts and their
940:    corresponding inertias in case of doing spectrum slicing for a
941:    computational interval.

943:    Not Collective

945:    Input Parameter:
946: .  eps - the eigenproblem solver context

948:    Output Parameters:
949: +  n        - number of shifts, including the endpoints of the interval
950: .  shifts   - the values of the shifts used internally in the solver
951: -  inertias - the values of the inertia in each shift

953:    Notes:
954:    If called after EPSSolve(), all shifts used internally by the solver are
955:    returned (including both endpoints and any intermediate ones). If called
956:    before EPSSolve() and after EPSSetUp() then only the information of the
957:    endpoints of subintervals is available.

959:    This function is only available for spectrum slicing runs.

961:    The returned arrays should be freed by the user.

963:    Level: advanced

965: .seealso: EPSSetInterval(), EPSKrylovSchurSetSubintervals()
966: @*/
967: PetscErrorCode EPSKrylovSchurGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)
968: {

974:   PetscUseMethod(eps,"EPSKrylovSchurGetInertias_C",(EPS,PetscInt*,PetscReal**,PetscInt**),(eps,n,shifts,inertias));
975:   return(0);
976: }

980: static PetscErrorCode EPSKrylovSchurGetSubcommInfo_KrylovSchur(EPS eps,PetscInt *k,PetscInt *n,Vec *v)
981: {
982:   PetscErrorCode  ierr;
983:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
984:   EPS_SR          sr = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr;

987:   if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first");
988:   if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()");
989:   if (k) *k = (ctx->npart==1)? 0: ctx->subc->color;
990:   if (n) *n = sr->numEigs;
991:   if (v) {
992:     BVCreateVec(sr->V,v);
993:   }
994:   return(0);
995: }

999: /*@C
1000:    EPSKrylovSchurGetSubcommInfo - Gets information related to the case of
1001:    doing spectrum slicing for a computational interval with multiple
1002:    communicators.

1004:    Collective on the subcommunicator (if v is given)

1006:    Input Parameter:
1007: .  eps - the eigenproblem solver context

1009:    Output Parameters:
1010: +  k - index of the subinterval for the calling process
1011: .  n - number of eigenvalues found in the k-th subinterval
1012: -  v - a vector owned by processes in the subcommunicator with dimensions
1013:        compatible for locally computed eigenvectors (or NULL)

1015:    Notes:
1016:    This function is only available for spectrum slicing runs.

1018:    The returned Vec should be destroyed by the user.

1020:    Level: advanced

1022: .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommPairs()
1023: @*/
1024: PetscErrorCode EPSKrylovSchurGetSubcommInfo(EPS eps,PetscInt *k,PetscInt *n,Vec *v)
1025: {

1030:   PetscUseMethod(eps,"EPSKrylovSchurGetSubcommInfo_C",(EPS,PetscInt*,PetscInt*,Vec*),(eps,k,n,v));
1031:   return(0);
1032: }

1036: static PetscErrorCode EPSKrylovSchurGetSubcommPairs_KrylovSchur(EPS eps,PetscInt i,PetscScalar *eig,Vec v)
1037: {
1038:   PetscErrorCode  ierr;
1039:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
1040:   EPS_SR          sr = ((EPS_KRYLOVSCHUR*)ctx->eps->data)->sr;

1043:   EPSCheckSolved(eps,1);
1044:   if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()");
1045:   if (i<0 || i>=sr->numEigs) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
1046:   if (eig) *eig = sr->eigr[sr->perm[i]];
1047:   if (v) { BVCopyVec(sr->V,sr->perm[i],v); }
1048:   return(0);
1049: }

1053: /*@C
1054:    EPSKrylovSchurGetSubcommPairs - Gets the i-th eigenpair stored
1055:    internally in the subcommunicator to which the calling process belongs.

1057:    Collective on the subcommunicator (if v is given)

1059:    Input Parameter:
1060: +  eps - the eigenproblem solver context
1061: -  i   - index of the solution

1063:    Output Parameters:
1064: +  eig - the eigenvalue
1065: -  v   - the eigenvector

1067:    Notes:
1068:    It is allowed to pass NULL for v if the eigenvector is not required.
1069:    Otherwise, the caller must provide a valid Vec objects, i.e.,
1070:    it must be created by the calling program with EPSKrylovSchurGetSubcommInfo().

1072:    The index i should be a value between 0 and n-1, where n is the number of
1073:    vectors in the local subinterval, see EPSKrylovSchurGetSubcommInfo().

1075:    Level: advanced

1077: .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommInfo(), EPSKrylovSchurGetSubcommMats()
1078: @*/
1079: PetscErrorCode EPSKrylovSchurGetSubcommPairs(EPS eps,PetscInt i,PetscScalar *eig,Vec v)
1080: {

1086:   PetscUseMethod(eps,"EPSKrylovSchurGetSubcommPairs_C",(EPS,PetscInt,PetscScalar*,Vec),(eps,i,eig,v));
1087:   return(0);
1088: }

1092: static PetscErrorCode EPSKrylovSchurGetSubcommMats_KrylovSchur(EPS eps,Mat *A,Mat *B)
1093: {
1094:   PetscErrorCode  ierr;
1095:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;

1098:   if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()");
1099:   if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first");
1100:   EPSGetOperators(ctx->eps,A,B);
1101:   return(0);
1102: }

1106: /*@C
1107:    EPSKrylovSchurGetSubcommMats - Gets the eigenproblem matrices stored
1108:    internally in the subcommunicator to which the calling process belongs.

1110:    Collective on the subcommunicator

1112:    Input Parameter:
1113: .  eps - the eigenproblem solver context

1115:    Output Parameters:
1116: +  A  - the matrix associated with the eigensystem
1117: -  B  - the second matrix in the case of generalized eigenproblems

1119:    Notes:
1120:    This is the analog of EPSGetOperators(), but returns the matrices distributed
1121:    differently (in the subcommunicator rather than in the parent communicator).

1123:    These matrices should not be modified by the user.

1125:    Level: advanced

1127: .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommInfo()
1128: @*/
1129: PetscErrorCode EPSKrylovSchurGetSubcommMats(EPS eps,Mat *A,Mat *B)
1130: {

1135:   PetscTryMethod(eps,"EPSKrylovSchurGetSubcommMats_C",(EPS,Mat*,Mat*),(eps,A,B));
1136:   return(0);
1137: }

1141: static PetscErrorCode EPSKrylovSchurUpdateSubcommMats_KrylovSchur(EPS eps,PetscScalar a,PetscScalar ap,Mat Au,PetscScalar b,PetscScalar bp, Mat Bu,MatStructure str,PetscBool globalup)
1142: {
1143:   PetscErrorCode  ierr;
1144:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data,*subctx;
1145:   Mat             A,B=NULL,Ag,Bg=NULL;
1146:   PetscBool       reuse=PETSC_TRUE;
1147:    
1149:   if (!ctx->sr) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Only available in interval computations, see EPSSetInterval()");
1150:   if (!eps->state) SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSetUp() first");
1151:   EPSGetOperators(eps,&Ag,&Bg);
1152:   EPSGetOperators(ctx->eps,&A,&B);
1153:   
1154:   MatScale(A,a);
1155:   if (Au) {
1156:     MatAXPY(A,ap,Au,str);
1157:   }
1158:   if (B) MatScale(B,b);
1159:   if (Bu) {
1160:     MatAXPY(B,bp,Bu,str);
1161:   }
1162:   EPSSetOperators(ctx->eps,A,B);

1164:   /* Update stored matrix state */
1165:   subctx = (EPS_KRYLOVSCHUR*)ctx->eps->data;
1166:   PetscObjectStateGet((PetscObject)A,&subctx->Astate);
1167:   if (B) { PetscObjectStateGet((PetscObject)B,&subctx->Bstate); }

1169:   /* Update matrices in the parent communicator if requested by user */
1170:   if (globalup) {
1171:     if (ctx->npart>1) {
1172:       if (!ctx->isrow) {
1173:         MatGetOwnershipIS(Ag,&ctx->isrow,&ctx->iscol);
1174:         reuse = PETSC_FALSE;
1175:       }
1176:       if (str==DIFFERENT_NONZERO_PATTERN) reuse = PETSC_FALSE;
1177:       if (ctx->submata && !reuse) {
1178:         MatDestroyMatrices(1,&ctx->submata);
1179:       }
1180:       MatGetSubMatrices(A,1,&ctx->isrow,&ctx->iscol,(reuse)?MAT_REUSE_MATRIX:MAT_INITIAL_MATRIX,&ctx->submata);
1181:       MatCreateMPIMatConcatenateSeqMat(((PetscObject)Ag)->comm,ctx->submata[0],PETSC_DECIDE,MAT_REUSE_MATRIX,&Ag);
1182:       if (B) {
1183:         if (ctx->submatb && !reuse) {
1184:           MatDestroyMatrices(1,&ctx->submatb);
1185:         }
1186:         MatGetSubMatrices(B,1,&ctx->isrow,&ctx->iscol,(reuse)?MAT_REUSE_MATRIX:MAT_INITIAL_MATRIX,&ctx->submatb);
1187:         MatCreateMPIMatConcatenateSeqMat(((PetscObject)Bg)->comm,ctx->submatb[0],PETSC_DECIDE,MAT_REUSE_MATRIX,&Bg);
1188:       }
1189:     }
1190:     PetscObjectStateGet((PetscObject)Ag,&ctx->Astate);
1191:     if (Bg) { PetscObjectStateGet((PetscObject)Bg,&ctx->Bstate); }
1192:   }
1193:   EPSSetOperators(eps,Ag,Bg);
1194:   return(0);
1195: }

1199: /*@C
1200:    EPSKrylovSchurUpdateSubcommMats - Update the eigenproblem matrices stored
1201:    internally in the subcommunicator to which the calling process belongs.

1203:    Collective on EPS

1205:    Input Parameters:
1206: +  eps - the eigenproblem solver context
1207: .  s   - scalar that multiplies the existing A matrix
1208: .  a   - scalar used in the axpy operation on A
1209: .  Au  - matrix used in the axpy operation on A
1210: .  t   - scalar that multiplies the existing B matrix
1211: .  b   - scalar used in the axpy operation on B
1212: .  Bu  - matrix used in the axpy operation on B
1213: .  str - structure flag
1214: -  globalup - flag indicating if global matrices must be updated

1216:    Notes:
1217:    This function modifies the eigenproblem matrices at the subcommunicator level,
1218:    and optionally updates the global matrices in the parent communicator. The updates
1219:    are expressed as A <-- s*A + a*Au,  B <-- t*B + b*Bu.

1221:    It is possible to update one of the matrices, or both.

1223:    The matrices Au and Bu must be equal in all subcommunicators.

1225:    The str flag is passed to the MatAXPY() operations to perform the updates.

1227:    If globalup is true, communication is carried out to reconstruct the updated
1228:    matrices in the parent communicator. The user must be warned that if global
1229:    matrices are not in sync with subcommunicator matrices, the errors computed
1230:    by EPSComputeError() will be wrong even if the computed solution is correct
1231:    (the synchronization may be done only once at the end).

1233:    Level: advanced

1235: .seealso: EPSSetInterval(), EPSKrylovSchurSetPartitions(), EPSKrylovSchurGetSubcommMats()
1236: @*/
1237: PetscErrorCode EPSKrylovSchurUpdateSubcommMats(EPS eps,PetscScalar s,PetscScalar a,Mat Au,PetscScalar t,PetscScalar b, Mat Bu,MatStructure str,PetscBool globalup)
1238: {

1251:   PetscTryMethod(eps,"EPSKrylovSchurUpdateSubcommMats_C",(EPS,PetscScalar,PetscScalar,Mat,PetscScalar,PetscScalar,Mat,MatStructure,PetscBool),(eps,s,a,Au,t,b,Bu,str,globalup));
1252:   return(0);
1253: }

1257: PetscErrorCode EPSSetFromOptions_KrylovSchur(PetscOptionItems *PetscOptionsObject,EPS eps)
1258: {
1259:   PetscErrorCode  ierr;
1260:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
1261:   PetscBool       flg,lock,b,f1,f2,f3;
1262:   PetscReal       keep;
1263:   PetscInt        i,j,k;

1266:   PetscOptionsHead(PetscOptionsObject,"EPS Krylov-Schur Options");
1267:   PetscOptionsReal("-eps_krylovschur_restart","Proportion of vectors kept after restart","EPSKrylovSchurSetRestart",0.5,&keep,&flg);
1268:   if (flg) {
1269:     EPSKrylovSchurSetRestart(eps,keep);
1270:   }
1271:   PetscOptionsBool("-eps_krylovschur_locking","Choose between locking and non-locking variants","EPSKrylovSchurSetLocking",PETSC_TRUE,&lock,&flg);
1272:   if (flg) {
1273:     EPSKrylovSchurSetLocking(eps,lock);
1274:   }
1275:   i = ctx->npart;
1276:   PetscOptionsInt("-eps_krylovschur_partitions","Number of partitions of the communicator for spectrum slicing","EPSKrylovSchurSetPartitions",ctx->npart,&i,&flg);
1277:   if (flg) {
1278:     EPSKrylovSchurSetPartitions(eps,i);
1279:   }
1280:   b = ctx->detect;
1281:   PetscOptionsBool("-eps_krylovschur_detect_zeros","Check zeros during factorizations at subinterval boundaries","EPSKrylovSchurSetDetectZeros",ctx->detect,&b,&flg);
1282:   if (flg) {
1283:     EPSKrylovSchurSetDetectZeros(eps,b);
1284:   }
1285:   i = 1;
1286:   j = k = PETSC_DECIDE;
1287:   PetscOptionsInt("-eps_krylovschur_nev","Number of eigenvalues to compute in each subsolve (only for spectrum slicing)","EPSKrylovSchurSetDimensions",40,&i,&f1);
1288:   PetscOptionsInt("-eps_krylovschur_ncv","Number of basis vectors in each subsolve (only for spectrum slicing)","EPSKrylovSchurSetDimensions",80,&j,&f2);
1289:   PetscOptionsInt("-eps_krylovschur_mpd","Maximum dimension of projected problem in each subsolve (only for spectrum slicing)","EPSKrylovSchurSetDimensions",80,&k,&f3);
1290:   if (f1 || f2 || f3) {
1291:     EPSKrylovSchurSetDimensions(eps,i,j,k);
1292:   }
1293:   PetscOptionsTail();
1294:   return(0);
1295: }

1299: PetscErrorCode EPSView_KrylovSchur(EPS eps,PetscViewer viewer)
1300: {
1301:   PetscErrorCode  ierr;
1302:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
1303:   PetscBool       isascii;

1306:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
1307:   if (isascii) {
1308:     PetscViewerASCIIPrintf(viewer,"  Krylov-Schur: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));
1309:     PetscViewerASCIIPrintf(viewer,"  Krylov-Schur: using the %slocking variant\n",ctx->lock?"":"non-");
1310:     if (eps->which==EPS_ALL) {
1311:       PetscViewerASCIIPrintf(viewer,"  Krylov-Schur: doing spectrum slicing with nev=%D, ncv=%D, mpd=%D\n",ctx->nev,ctx->ncv,ctx->mpd);
1312:       if (ctx->npart>1) {
1313:         PetscViewerASCIIPrintf(viewer,"  Krylov-Schur: multi-communicator spectrum slicing with %D partitions\n",ctx->npart);
1314:         if (ctx->detect) { PetscViewerASCIIPrintf(viewer,"  Krylov-Schur: detecting zeros when factorizing at subinterval boundaries\n"); }
1315:       }
1316:     }
1317:   }
1318:   return(0);
1319: }

1323: PetscErrorCode EPSDestroy_KrylovSchur(EPS eps)
1324: {

1328:   PetscFree(eps->data);
1329:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetRestart_C",NULL);
1330:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetRestart_C",NULL);
1331:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetLocking_C",NULL);
1332:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetLocking_C",NULL);
1333:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetPartitions_C",NULL);
1334:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetPartitions_C",NULL);
1335:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDetectZeros_C",NULL);
1336:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDetectZeros_C",NULL);
1337:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDimensions_C",NULL);
1338:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDimensions_C",NULL);
1339:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetSubintervals_C",NULL);
1340:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubintervals_C",NULL);
1341:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetInertias_C",NULL);
1342:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommInfo_C",NULL);
1343:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommPairs_C",NULL);
1344:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommMats_C",NULL);
1345:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurUpdateSubcommMats_C",NULL);
1346:   return(0);
1347: }

1351: PetscErrorCode EPSReset_KrylovSchur(EPS eps)
1352: {
1355:   if (eps->which==EPS_ALL) {
1356:     EPSReset_KrylovSchur_Slice(eps);
1357:   }
1358:   return(0);
1359: }

1363: PETSC_EXTERN PetscErrorCode EPSCreate_KrylovSchur(EPS eps)
1364: {
1365:   EPS_KRYLOVSCHUR *ctx;
1366:   PetscErrorCode  ierr;

1369:   PetscNewLog(eps,&ctx);
1370:   eps->data   = (void*)ctx;
1371:   ctx->lock   = PETSC_TRUE;
1372:   ctx->nev    = 1;
1373:   ctx->npart  = 1;
1374:   ctx->detect = PETSC_FALSE;
1375:   ctx->global = PETSC_TRUE;

1377:   eps->ops->setup          = EPSSetUp_KrylovSchur;
1378:   eps->ops->setfromoptions = EPSSetFromOptions_KrylovSchur;
1379:   eps->ops->destroy        = EPSDestroy_KrylovSchur;
1380:   eps->ops->reset          = EPSReset_KrylovSchur;
1381:   eps->ops->view           = EPSView_KrylovSchur;
1382:   eps->ops->backtransform  = EPSBackTransform_Default;
1383:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetRestart_C",EPSKrylovSchurSetRestart_KrylovSchur);
1384:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetRestart_C",EPSKrylovSchurGetRestart_KrylovSchur);
1385:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetLocking_C",EPSKrylovSchurSetLocking_KrylovSchur);
1386:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetLocking_C",EPSKrylovSchurGetLocking_KrylovSchur);
1387:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetPartitions_C",EPSKrylovSchurSetPartitions_KrylovSchur);
1388:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetPartitions_C",EPSKrylovSchurGetPartitions_KrylovSchur);
1389:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDetectZeros_C",EPSKrylovSchurSetDetectZeros_KrylovSchur);
1390:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDetectZeros_C",EPSKrylovSchurGetDetectZeros_KrylovSchur);
1391:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetDimensions_C",EPSKrylovSchurSetDimensions_KrylovSchur);
1392:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetDimensions_C",EPSKrylovSchurGetDimensions_KrylovSchur);
1393:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurSetSubintervals_C",EPSKrylovSchurSetSubintervals_KrylovSchur);
1394:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubintervals_C",EPSKrylovSchurGetSubintervals_KrylovSchur);
1395:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetInertias_C",EPSKrylovSchurGetInertias_KrylovSchur);
1396:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommInfo_C",EPSKrylovSchurGetSubcommInfo_KrylovSchur);
1397:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommPairs_C",EPSKrylovSchurGetSubcommPairs_KrylovSchur);
1398:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurGetSubcommMats_C",EPSKrylovSchurGetSubcommMats_KrylovSchur);
1399:   PetscObjectComposeFunction((PetscObject)eps,"EPSKrylovSchurUpdateSubcommMats_C",EPSKrylovSchurUpdateSubcommMats_KrylovSchur);
1400:   return(0);
1401: }

slepc-3.7.4/src/eps/impls/krylov/krylovschur/ks-symm.c.html0000644000175000017500000002303613107004621023321 0ustar jromanjroman
Actual source code: ks-symm.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc eigensolver: "krylovschur"

  5:    Method: Krylov-Schur for symmetric eigenproblems

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

 11:    This file is part of SLEPc.

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

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

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

 27: #include <slepc/private/epsimpl.h>
 28:  #include krylovschur.h

 32: PetscErrorCode EPSSolve_KrylovSchur_Symm(EPS eps)
 33: {
 34:   PetscErrorCode  ierr;
 35:   EPS_KRYLOVSCHUR *ctx = (EPS_KRYLOVSCHUR*)eps->data;
 36:   PetscInt        k,l,ld,nv,nconv;
 37:   Mat             U;
 38:   PetscReal       *a,*b,beta;
 39:   PetscBool       breakdown;

 42:   DSGetLeadingDimension(eps->ds,&ld);

 44:   /* Get the starting Lanczos vector */
 45:   EPSGetStartVector(eps,0,NULL);
 46:   l = 0;

 48:   /* Restart loop */
 49:   while (eps->reason == EPS_CONVERGED_ITERATING) {
 50:     eps->its++;

 52:     /* Compute an nv-step Lanczos factorization */
 53:     nv = PetscMin(eps->nconv+eps->mpd,eps->ncv);
 54:     DSGetArrayReal(eps->ds,DS_MAT_T,&a);
 55:     b = a + ld;
 56:     EPSFullLanczos(eps,a,b,eps->nconv+l,&nv,&breakdown);
 57:     beta = b[nv-1];
 58:     DSRestoreArrayReal(eps->ds,DS_MAT_T,&a);
 59:     DSSetDimensions(eps->ds,nv,0,eps->nconv,eps->nconv+l);
 60:     if (l==0) {
 61:       DSSetState(eps->ds,DS_STATE_INTERMEDIATE);
 62:     } else {
 63:       DSSetState(eps->ds,DS_STATE_RAW);
 64:     }
 65:     BVSetActiveColumns(eps->V,eps->nconv,nv);

 67:     /* Solve projected problem */
 68:     DSSolve(eps->ds,eps->eigr,NULL);
 69:     if (eps->arbitrary) { EPSGetArbitraryValues(eps,eps->rr,eps->ri); }
 70:     DSSort(eps->ds,eps->eigr,NULL,eps->rr,eps->ri,NULL);
 71:     DSUpdateExtraRow(eps->ds);

 73:     /* Check convergence */
 74:     EPSKrylovConvergence(eps,PETSC_FALSE,eps->nconv,nv-eps->nconv,beta,1.0,&k);
 75:     (*eps->stopping)(eps,eps->its,eps->max_it,k,eps->nev,&eps->reason,eps->stoppingctx);
 76:     nconv = k;

 78:     /* Update l */
 79:     if (eps->reason != EPS_CONVERGED_ITERATING || breakdown) l = 0;
 80:     else l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep));
 81:     if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */

 83:     if (eps->reason == EPS_CONVERGED_ITERATING) {
 84:       if (breakdown) {
 85:         /* Start a new Lanczos factorization */
 86:         PetscInfo2(eps,"Breakdown in Krylov-Schur method (it=%D norm=%g)\n",eps->its,(double)beta);
 87:         if (k<eps->nev) {
 88:           EPSGetStartVector(eps,k,&breakdown);
 89:           if (breakdown) {
 90:             eps->reason = EPS_DIVERGED_BREAKDOWN;
 91:             PetscInfo(eps,"Unable to generate more start vectors\n");
 92:           }
 93:         }
 94:       } else {
 95:         /* Prepare the Rayleigh quotient for restart */
 96:         DSTruncate(eps->ds,k+l);
 97:       }
 98:     }
 99:     /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */
100:     DSGetMat(eps->ds,DS_MAT_Q,&U);
101:     BVMultInPlace(eps->V,U,eps->nconv,k+l);
102:     MatDestroy(&U);

104:     /* Normalize u and append it to V */
105:     if (eps->reason == EPS_CONVERGED_ITERATING && !breakdown) {
106:       BVCopyColumn(eps->V,nv,k+l);
107:     }

109:     eps->nconv = k;
110:     EPSMonitor(eps,eps->its,nconv,eps->eigr,eps->eigi,eps->errest,nv);
111:   }
112:   return(0);
113: }

slepc-3.7.4/src/eps/impls/krylov/index.html0000644000175000017500000000277213107004621020220 0ustar jromanjroman Eigenvalue Problem Solver - EPS
slepc-3.7.4 2017-05-17

Eigenvalue Problem Solver - EPS: Examples

The Eigenvalue Problem Solver (EPS) is the object provided by SLEPc for specifying a linear eigenvalue problem, either in standard or generalized form. It provides uniform and efficient access to all of the linear eigensolvers included in the package.

EPS users can set various options at runtime via the options database (e.g., -eps_nev 4 -eps_type arnoldi). Options can also be set directly in application codes by calling the corresponding routines (e.g., EPSSetDimensions() / EPSSetType()).

arnoldi/
lanczos/
krylovschur/
epskrylov.c
makefile
slepc-3.7.4/src/makefile.html0000644000175000017500000000430113107004621015413 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

DIRS     = sys eps svd pep nep mfn

LOCDIR   = src/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/index.html0000644000175000017500000000137013107004621014750 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

sys/
eps/
svd/
pep/
nep/
mfn/
makefile
slepc-3.7.4/src/sys/0000755000175000017500000000000013107004621013570 5ustar jromanjromanslepc-3.7.4/src/sys/makefile0000644000175000017500000000223413107004621015271 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = slepcinit.c slepcutil.c slepcsc.c dlregisslepc.c SOURCEF = SOURCEH = LIBBASE = libslepcsys MANSEC = sys LOCDIR = src/sys/ DIRS = classes vec f90-mod include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/slepcinit.c.html0000644000175000017500000006155413107004621016704 0ustar jromanjroman

Actual source code: slepcinit.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/slepcimpl.h>           /*I "slepcsys.h" I*/
 23: #include <slepc/private/vecimplslepc.h>

 27: /*@C
 28:     SlepcGetVersion - Gets the SLEPc version information in a string.

 30:     Input Parameter:
 31: .   len - length of the string

 33:     Output Parameter:
 34: .   version - version string

 36:     Fortran Note:
 37:     This routine is not supported in Fortran.

 39:     Level: intermediate
 40: @*/
 41: PetscErrorCode SlepcGetVersion(char version[],size_t len)
 42: {

 46: #if (SLEPC_VERSION_RELEASE == 1)
 47:   PetscSNPrintf(version,len,"SLEPc Release Version %d.%d.%d, %s",SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_DATE);
 48: #else
 49:   PetscSNPrintf(version,len,"SLEPc Development GIT revision: %d  GIT Date: %s",SLEPC_VERSION_GIT,SLEPC_VERSION_DATE_GIT);
 50: #endif
 51:   return(0);
 52: }

 56: /*
 57:    SlepcPrintVersion - Prints SLEPc version info.

 59:    Collective on MPI_Comm
 60: */
 61: static PetscErrorCode SlepcPrintVersion(MPI_Comm comm)
 62: {
 64:   char           version[256];

 67:   SlepcGetVersion(version,256);
 68:   (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");
 69:   (*PetscHelpPrintf)(comm,"%s\n",version);
 70:   (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO);
 71:   (*PetscHelpPrintf)(comm,"See docs/manual.html for help.\n");
 72:   (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR);
 73:   return(0);
 74: }

 78: /*
 79:    SlepcPrintHelpIntro - Prints introductory SLEPc help info.

 81:    Collective on MPI_Comm
 82: */
 83: static PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)
 84: {
 85:   PetscErrorCode  ierr;

 88:   (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n");
 89:   (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n");
 90:   (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");
 91:   return(0);
 92: }

 94: /* ------------------------Nasty global variables -------------------------------*/
 95: /*
 96:    Indicates whether SLEPc started PETSc, or whether it was
 97:    already started before SLEPc was initialized.
 98: */
 99: PetscBool SlepcBeganPetsc = PETSC_FALSE;
100: PetscBool SlepcInitializeCalled = PETSC_FALSE;

102: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

106: static PetscErrorCode SlepcLoadDynamicLibrary(const char *name,PetscBool *found)
107: {
108:   char           libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN];

112:   PetscStrcpy(libs,SLEPC_LIB_DIR);
113:   PetscStrcat(libs,"/libslepc");
114:   PetscStrcat(libs,name);
115:   PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,found);
116:   if (*found) {
117:     PetscDLLibraryAppend(PETSC_COMM_WORLD,&PetscDLLibrariesLoaded,dlib);
118:   }
119:   return(0);
120: }

124: /*
125:     SlepcInitialize_DynamicLibraries - Adds the default dynamic link libraries to the
126:     search path.
127: */
128: PetscErrorCode SlepcInitialize_DynamicLibraries(void)
129: {
131:   PetscBool      found;
132:   PetscBool      preload;

135:   preload = PETSC_FALSE;
136:   PetscOptionsGetBool(NULL,NULL,"-dynamic_library_preload",&preload,NULL);
137:   if (preload) {
138: #if defined(PETSC_USE_SINGLE_LIBRARY)
139:     SlepcLoadDynamicLibrary("",&found);
140:     if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!");
141: #else
142:     SlepcLoadDynamicLibrary("sys",&found);
143:     if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!");
144:     SlepcLoadDynamicLibrary("eps",&found);
145:     if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!");
146:     SlepcLoadDynamicLibrary("pep",&found);
147:     if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!");
148:     SlepcLoadDynamicLibrary("nep",&found);
149:     if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!");
150:     SlepcLoadDynamicLibrary("svd",&found);
151:     if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!");
152:     SlepcLoadDynamicLibrary("mfn",&found);
153:     if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!");
154: #endif
155:   }

157: #if defined(PETSC_HAVE_THREADSAFETY)
158:   STInitializePackage();
159:   DSInitializePackage();
160:   FNInitializePackage();
161:   BVInitializePackage();
162:   RGInitializePackage();
163:   EPSInitializePackage();
164:   SVDInitializePackage();
165:   PEPInitializePackage();
166:   NEPInitializePackage();
167:   MFNInitializePackage();
168: #endif
169:   return(0);
170: }
171: #endif

175: PetscErrorCode SlepcCitationsInitialize()
176: {

180:   PetscCitationsRegister("@Article{slepc-toms,\n"
181:     "   author = \"Vicente Hernandez and Jose E. Roman and Vicente Vidal\",\n"
182:     "   title = \"{SLEPc}: A Scalable and Flexible Toolkit for the Solution of Eigenvalue Problems\",\n"
183:     "   journal = \"{ACM} Trans. Math. Software\",\n"
184:     "   volume = \"31\",\n"
185:     "   number = \"3\",\n"
186:     "   pages = \"351--362\",\n"
187:     "   year = \"2005,\"\n"
188:     "   doi = \"http://dx.doi.org/10.1145/1089014.1089019\"\n"
189:     "}\n",NULL);
190:   PetscCitationsRegister("@TechReport{slepc-manual,\n"
191:     "   author = \"J. E. Roman and C. Campos and E. Romero and A. Tomas\",\n"
192:     "   title = \"{SLEPc} Users Manual\",\n"
193:     "   number = \"DSIC-II/24/02 - Revision 3.7\",\n"
194:     "   institution = \"D. Sistemes Inform\\`atics i Computaci\\'o, Universitat Polit\\`ecnica de Val\\`encia\",\n"
195:     "   year = \"2016\"\n"
196:     "}\n",NULL);
197:   return(0);
198: }

202: /*@C
203:    SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls
204:    PetscInitialize() if that has not been called yet, so this routine should
205:    always be called near the beginning of your program.

207:    Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set

209:    Input Parameters:
210: +  argc - count of number of command line arguments
211: .  args - the command line arguments
212: .  file - [optional] PETSc database file, defaults to ~username/.petscrc
213:           (use NULL for default)
214: -  help - [optional] Help message to print, use NULL for no message

216:    Fortran Note:
217:    Fortran syntax is very similar to that of PetscInitialize()

219:    Level: beginner

221: .seealso: SlepcFinalize(), PetscInitialize()
222: @*/
223: PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[])
224: {
226:   PetscBool      flg;

229:   if (SlepcInitializeCalled) return(0);
230:   PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);
231:   PetscInitialized(&flg);
232:   if (!flg) {
233:     PetscInitialize(argc,args,file,help);
234:     SlepcBeganPetsc = PETSC_TRUE;
235:   }

237:   SlepcCitationsInitialize();

239: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
240:   SlepcInitialize_DynamicLibraries();
241: #endif

243: #if defined(PETSC_HAVE_DRAND48)
244:   /* work-around for Cygwin drand48() initialization bug */
245:   srand48(0);
246: #endif

248:   SlepcInitializeCalled = PETSC_TRUE;
249:   PetscInfo(0,"SLEPc successfully started\n");
250:   return(0);
251: }

255: /*@
256:    SlepcFinalize - Checks for options to be called at the conclusion
257:    of the SLEPc program and calls PetscFinalize().

259:    Collective on PETSC_COMM_WORLD

261:    Level: beginner

263: .seealso: SlepcInitialize(), PetscFinalize()
264: @*/
265: PetscErrorCode SlepcFinalize(void)
266: {
267:   PetscErrorCode 0;

270:   PetscInfo(0,"SlepcFinalize() called\n");
271:   if (SlepcBeganPetsc) {
272:     PetscFinalize();
273:   }
274:   SlepcInitializeCalled = PETSC_FALSE;
275:   PetscFunctionReturn(ierr);
276: }

280: /*@C
281:    SlepcInitializeNoArguments - Calls SlepcInitialize() from C/C++ without
282:    the command line arguments.

284:    Collective

286:    Level: advanced

288: .seealso: SlepcInitialize(), SlepcInitializeFortran()
289: @*/
290: PetscErrorCode SlepcInitializeNoArguments(void)
291: {
293:   int            argc = 0;
294:   char           **args = 0;

297:   SlepcInitialize(&argc,&args,NULL,NULL);
298:   PetscFunctionReturn(ierr);
299: }

303: /*@
304:    SlepcInitialized - Determine whether SLEPc is initialized.

306:    Level: beginner

308: .seealso: SlepcInitialize(), SlepcInitializeFortran()
309: @*/
310: PetscErrorCode SlepcInitialized(PetscBool *isInitialized)
311: {
314:   *isInitialized = SlepcInitializeCalled;
315:   return(0);
316: }

318: PETSC_EXTERN PetscBool PetscBeganMPI;

322: /*
323:    SlepcInitializeNoPointers - Calls SlepcInitialize() from C/C++ without the pointers
324:    to argc and args (analogue to PetscInitializeNoPointers).

326:    Collective

328:    Level: advanced

330: .seealso: SlepcInitialize()
331: */
332: PetscErrorCode SlepcInitializeNoPointers(int argc,char **args,const char *filename,const char *help)
333: {
335:   int            myargc = argc;
336:   char           **myargs = args;

339:   SlepcInitialize(&myargc,&myargs,filename,help);
340:   PetscPopSignalHandler();
341:   PetscBeganMPI = PETSC_FALSE;
342:   PetscFunctionReturn(ierr);
343: }

slepc-3.7.4/src/sys/slepcsc.c.html0000644000175000017500000005676313107004621016354 0ustar jromanjroman
Actual source code: slepcsc.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/slepcimpl.h>     /*I "slepcsys.h" I*/
 23: #include <slepcrg.h>
 24: #include <slepcst.h>

 28: /*@
 29:    SlepcSCCompare - Compares two (possibly complex) values according
 30:    to a certain criterion.

 32:    Not Collective

 34:    Input Parameters:
 35: +  sc  - the sorting criterion context
 36: .  ar  - real part of the 1st value
 37: .  ai  - imaginary part of the 1st value
 38: .  br  - real part of the 2nd value
 39: -  bi  - imaginary part of the 2nd value

 41:    Output Parameter:
 42: .  res - result of comparison

 44:    Notes:
 45:    Returns an integer less than, equal to, or greater than zero if the first
 46:    value is considered to be respectively less than, equal to, or greater
 47:    than the second one.

 49:    Level: developer

 51: .seealso: SlepcSortEigenvalues(), SlepcSC
 52: @*/
 53: PetscErrorCode SlepcSCCompare(SlepcSC sc,PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res)
 54: {
 56:   PetscScalar    re[2],im[2];
 57:   PetscInt       cin[2];
 58:   PetscBool      inside[2];

 62: #if defined(PETSC_USE_DEBUG)
 63:   if (!sc->comparison) SETERRQ(PETSC_COMM_SELF,1,"Undefined comparison function");
 64: #endif
 65:   re[0] = ar; re[1] = br;
 66:   im[0] = ai; im[1] = bi;
 67:   if (sc->map) {
 68:     (*sc->map)(sc->mapobj,2,re,im);
 69:   }
 70:   if (sc->rg) {
 71:     RGCheckInside(sc->rg,2,re,im,cin);
 72:     inside[0] = PetscNot(cin[0]<0);
 73:     inside[1] = PetscNot(cin[1]<0);
 74:     if (inside[0] && !inside[1]) *res = -1;
 75:     else if (!inside[0] && inside[1]) *res = 1;
 76:     else {
 77:       (*sc->comparison)(re[0],im[0],re[1],im[1],res,sc->comparisonctx);
 78:     }
 79:   } else {
 80:     (*sc->comparison)(re[0],im[0],re[1],im[1],res,sc->comparisonctx);
 81:   }
 82:   return(0);
 83: }

 87: /*@
 88:    SlepcSortEigenvalues - Sorts a list of eigenvalues according to the 
 89:    sorting criterion specified in a SlepcSC context.

 91:    Not Collective

 93:    Input Parameters:
 94: +  sc   - the sorting criterion context
 95: .  n    - number of eigenvalues in the list
 96: .  eigr - pointer to the array containing the eigenvalues
 97: -  eigi - imaginary part of the eigenvalues (only when using real numbers)

 99:    Input/Output Parameter:
100: .  perm - permutation array. Must be initialized to 0:n-1 on input.

102:    Note:
103:    The result is a list of indices in the original eigenvalue array
104:    corresponding to the first n eigenvalues sorted in the specified
105:    criterion.

107:    Level: developer

109: .seealso: SlepcSCCompare(), SlepcSC
110: @*/
111: PetscErrorCode SlepcSortEigenvalues(SlepcSC sc,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm)
112: {
114:   PetscScalar    re,im;
115:   PetscInt       i,j,result,tmp;

122:   /* insertion sort */
123:   for (i=n-1;i>=0;i--) {
124:     re = eigr[perm[i]];
125:     im = eigi[perm[i]];
126:     j = i+1;
127: #if !defined(PETSC_USE_COMPLEX)
128:     if (im!=0) {
129:       /* complex eigenvalue */
130:       i--;
131:       im = eigi[perm[i]];
132:     }
133: #endif
134:     while (j<n) {
135:       SlepcSCCompare(sc,re,im,eigr[perm[j]],eigi[perm[j]],&result);
136:       if (result<0) break;
137: #if !defined(PETSC_USE_COMPLEX)
138:       /* keep together every complex conjugated eigenpair */
139:       if (!im) {
140:         if (eigi[perm[j]] == 0.0) {
141: #endif
142:           tmp = perm[j-1]; perm[j-1] = perm[j]; perm[j] = tmp;
143:           j++;
144: #if !defined(PETSC_USE_COMPLEX)
145:         } else {
146:           tmp = perm[j-1]; perm[j-1] = perm[j]; perm[j] = perm[j+1]; perm[j+1] = tmp;
147:           j+=2;
148:         }
149:       } else {
150:         if (eigi[perm[j]] == 0.0) {
151:           tmp = perm[j-2]; perm[j-2] = perm[j]; perm[j] = perm[j-1]; perm[j-1] = tmp;
152:           j++;
153:         } else {
154:           tmp = perm[j-2]; perm[j-2] = perm[j]; perm[j] = tmp;
155:           tmp = perm[j-1]; perm[j-1] = perm[j+1]; perm[j+1] = tmp;
156:           j+=2;
157:         }
158:       }
159: #endif
160:     }
161:   }
162:   return(0);
163: }

167: /*
168:    SlepcMap_ST - Gateway function to call STBackTransform from outside ST.
169: */
170: PetscErrorCode SlepcMap_ST(PetscObject obj,PetscInt n,PetscScalar* eigr,PetscScalar* eigi)
171: {

175:   STBackTransform((ST)obj,n,eigr,eigi);
176:   return(0);
177: }

181: PetscErrorCode SlepcCompareLargestMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
182: {
183:   PetscReal a,b;

186:   a = SlepcAbsEigenvalue(ar,ai);
187:   b = SlepcAbsEigenvalue(br,bi);
188:   if (a<b) *result = 1;
189:   else if (a>b) *result = -1;
190:   else *result = 0;
191:   return(0);
192: }

196: PetscErrorCode SlepcCompareSmallestMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
197: {
198:   PetscReal a,b;

201:   a = SlepcAbsEigenvalue(ar,ai);
202:   b = SlepcAbsEigenvalue(br,bi);
203:   if (a>b) *result = 1;
204:   else if (a<b) *result = -1;
205:   else *result = 0;
206:   return(0);
207: }

211: PetscErrorCode SlepcCompareLargestReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
212: {
213:   PetscReal a,b;

216:   a = PetscRealPart(ar);
217:   b = PetscRealPart(br);
218:   if (a<b) *result = 1;
219:   else if (a>b) *result = -1;
220:   else *result = 0;
221:   return(0);
222: }

226: PetscErrorCode SlepcCompareSmallestReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
227: {
228:   PetscReal a,b;

231:   a = PetscRealPart(ar);
232:   b = PetscRealPart(br);
233:   if (a>b) *result = 1;
234:   else if (a<b) *result = -1;
235:   else *result = 0;
236:   return(0);
237: }

241: PetscErrorCode SlepcCompareLargestImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
242: {
243:   PetscReal a,b;

246: #if defined(PETSC_USE_COMPLEX)
247:   a = PetscImaginaryPart(ar);
248:   b = PetscImaginaryPart(br);
249: #else
250:   a = PetscAbsReal(ai);
251:   b = PetscAbsReal(bi);
252: #endif
253:   if (a<b) *result = 1;
254:   else if (a>b) *result = -1;
255:   else *result = 0;
256:   return(0);
257: }

261: PetscErrorCode SlepcCompareSmallestImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
262: {
263:   PetscReal a,b;

266: #if defined(PETSC_USE_COMPLEX)
267:   a = PetscImaginaryPart(ar);
268:   b = PetscImaginaryPart(br);
269: #else
270:   a = PetscAbsReal(ai);
271:   b = PetscAbsReal(bi);
272: #endif
273:   if (a>b) *result = 1;
274:   else if (a<b) *result = -1;
275:   else *result = 0;
276:   return(0);
277: }

281: PetscErrorCode SlepcCompareTargetMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
282: {
283:   PetscReal   a,b;
284:   PetscScalar *target = (PetscScalar*)ctx;

287:   /* complex target only allowed if scalartype=complex */
288:   a = SlepcAbsEigenvalue(ar-(*target),ai);
289:   b = SlepcAbsEigenvalue(br-(*target),bi);
290:   if (a>b) *result = 1;
291:   else if (a<b) *result = -1;
292:   else *result = 0;
293:   return(0);
294: }

298: PetscErrorCode SlepcCompareTargetReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
299: {
300:   PetscReal   a,b;
301:   PetscScalar *target = (PetscScalar*)ctx;

304:   a = PetscAbsReal(PetscRealPart(ar-(*target)));
305:   b = PetscAbsReal(PetscRealPart(br-(*target)));
306:   if (a>b) *result = 1;
307:   else if (a<b) *result = -1;
308:   else *result = 0;
309:   return(0);
310: }

314: PetscErrorCode SlepcCompareTargetImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
315: {
316:   PetscReal   a,b;
317: #if defined(PETSC_USE_COMPLEX)
318:   PetscScalar *target = (PetscScalar*)ctx;
319: #endif

322: #if !defined(PETSC_USE_COMPLEX)
323:   /* complex target only allowed if scalartype=complex */
324:   a = PetscAbsReal(ai);
325:   b = PetscAbsReal(bi);
326: #else
327:   a = PetscAbsReal(PetscImaginaryPart(ar-(*target)));
328:   b = PetscAbsReal(PetscImaginaryPart(br-(*target)));
329: #endif
330:   if (a>b) *result = 1;
331:   else if (a<b) *result = -1;
332:   else *result = 0;
333:   return(0);
334: }

338: /*
339:    Used in the SVD for computing smallest singular values
340:    from the cyclic matrix.
341: */
342: PetscErrorCode SlepcCompareSmallestPosReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)
343: {
344:   PetscReal a,b;
345:   PetscBool aisright,bisright;

348:   if (PetscRealPart(ar)>0.0) aisright = PETSC_TRUE;
349:   else aisright = PETSC_FALSE;
350:   if (PetscRealPart(br)>0.0) bisright = PETSC_TRUE;
351:   else bisright = PETSC_FALSE;
352:   if (aisright == bisright) { /* same sign */
353:     a = SlepcAbsEigenvalue(ar,ai);
354:     b = SlepcAbsEigenvalue(br,bi);
355:     if (a>b) *result = 1;
356:     else if (a<b) *result = -1;
357:     else *result = 0;
358:   } else if (aisright && !bisright) *result = -1; /* 'a' is on the right */
359:   else *result = 1;  /* 'b' is on the right */
360:   return(0);
361: }

slepc-3.7.4/src/sys/makefile.html0000644000175000017500000000461713107004621016243 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = slepcinit.c slepcutil.c slepcsc.c dlregisslepc.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
MANSEC   = sys
LOCDIR   = src/sys/
DIRS     = classes vec f90-mod

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/slepcutil.c0000644000175000017500000005572013107004621015751 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsys.h" I*/ #undef __FUNCT__ #define __FUNCT__ "SlepcVecNormalize" /*@C SlepcVecNormalize - Normalizes a possibly complex vector by the 2-norm. Collective on Vec Input parameters: + xr - the real part of the vector (overwritten on output) . xi - the imaginary part of the vector (not referenced if iscomplex is false) - iscomplex - a flag indicating if the vector is complex Output parameter: . norm - the vector norm before normalization (can be set to NULL) Level: developer @*/ PetscErrorCode SlepcVecNormalize(Vec xr,Vec xi,PetscBool iscomplex,PetscReal *norm) { PetscErrorCode ierr; #if !defined(PETSC_USE_COMPLEX) PetscReal normr,normi,alpha; #endif PetscFunctionBegin; PetscValidHeaderSpecific(xr,VEC_CLASSID,1); #if !defined(PETSC_USE_COMPLEX) if (iscomplex) { PetscValidHeaderSpecific(xi,VEC_CLASSID,2); ierr = VecNormBegin(xr,NORM_2,&normr);CHKERRQ(ierr); ierr = VecNormBegin(xi,NORM_2,&normi);CHKERRQ(ierr); ierr = VecNormEnd(xr,NORM_2,&normr);CHKERRQ(ierr); ierr = VecNormEnd(xi,NORM_2,&normi);CHKERRQ(ierr); alpha = SlepcAbsEigenvalue(normr,normi); if (norm) *norm = alpha; alpha = 1.0 / alpha; ierr = VecScale(xr,alpha);CHKERRQ(ierr); ierr = VecScale(xi,alpha);CHKERRQ(ierr); } else #endif { ierr = VecNormalize(xr,norm);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcMatConvertSeqDense" /*@C SlepcMatConvertSeqDense - Converts a parallel matrix to another one in sequential dense format replicating the values in every processor. Collective on Mat Input parameters: + A - the source matrix - B - the target matrix Level: developer @*/ PetscErrorCode SlepcMatConvertSeqDense(Mat mat,Mat *newmat) { PetscErrorCode ierr; PetscInt m,n; PetscMPIInt size; PetscBool flg; Mat *M; IS isrow,iscol; PetscFunctionBegin; PetscValidHeaderSpecific(mat,MAT_CLASSID,1); PetscValidPointer(newmat,2); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)mat),&size);CHKERRQ(ierr); if (size > 1) { ierr = MatHasOperation(mat,MATOP_GET_SUBMATRICES,&flg);CHKERRQ(ierr); if (!flg) SETERRQ1(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"Mat type %s",((PetscObject)mat)->type_name); /* assemble full matrix on every processor */ ierr = MatGetSize(mat,&m,&n);CHKERRQ(ierr); ierr = ISCreateStride(PETSC_COMM_SELF,m,0,1,&isrow);CHKERRQ(ierr); ierr = ISCreateStride(PETSC_COMM_SELF,n,0,1,&iscol);CHKERRQ(ierr); ierr = MatGetSubMatrices(mat,1,&isrow,&iscol,MAT_INITIAL_MATRIX,&M);CHKERRQ(ierr); ierr = ISDestroy(&isrow);CHKERRQ(ierr); ierr = ISDestroy(&iscol);CHKERRQ(ierr); /* Fake support for "inplace" convert */ if (*newmat == mat) { ierr = MatDestroy(&mat);CHKERRQ(ierr); } /* convert matrix to MatSeqDense */ ierr = MatConvert(*M,MATSEQDENSE,MAT_INITIAL_MATRIX,newmat);CHKERRQ(ierr); ierr = MatDestroyMatrices(1,&M);CHKERRQ(ierr); } else { /* convert matrix to MatSeqDense */ ierr = MatConvert(mat,MATSEQDENSE,MAT_INITIAL_MATRIX,newmat);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcMatTile_SeqAIJ" static PetscErrorCode SlepcMatTile_SeqAIJ(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat G) { PetscErrorCode ierr; PetscInt i,j,M1,M2,N1,N2,*nnz,ncols,*scols; PetscScalar *svals,*buf; const PetscInt *cols; const PetscScalar *vals; PetscFunctionBegin; ierr = MatGetSize(A,&M1,&N1);CHKERRQ(ierr); ierr = MatGetSize(D,&M2,&N2);CHKERRQ(ierr); ierr = PetscCalloc1(M1+M2,&nnz);CHKERRQ(ierr); /* Preallocate for A */ if (a!=0.0) { for (i=0;iviewer = viewer; (*ctx)->format = format; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcConvMonitorDestroy" /*@C SlepcConvMonitorDestroy - Destroys a SlepcConvMonitor context. Collective on PetscViewer Input Parameters: . ctx - the SlepcConvMonitor context to be destroyed. Level: developer .seealso: SlepcConvMonitorCreate() @*/ PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor *ctx) { PetscErrorCode ierr; PetscFunctionBegin; if (!*ctx) PetscFunctionReturn(0); ierr = PetscViewerDestroy(&(*ctx)->viewer);CHKERRQ(ierr); ierr = PetscFree(*ctx);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcBasisReference_Private" /* Given n vectors in V, this function gets references of them into W. If m<0 then some previous non-processed vectors remain in W and must be freed. */ PetscErrorCode SlepcBasisReference_Private(PetscInt n,Vec *V,PetscInt *m,Vec **W) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; ierr = SlepcBasisDestroy_Private(m,W);CHKERRQ(ierr); if (n>0) { ierr = PetscMalloc1(n,W);CHKERRQ(ierr); for (i=0;i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsys.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "SlepcGetVersion" /*@C SlepcGetVersion - Gets the SLEPc version information in a string. Input Parameter: . len - length of the string Output Parameter: . version - version string Fortran Note: This routine is not supported in Fortran. Level: intermediate @*/ PetscErrorCode SlepcGetVersion(char version[],size_t len) { PetscErrorCode ierr; PetscFunctionBegin; #if (SLEPC_VERSION_RELEASE == 1) ierr = PetscSNPrintf(version,len,"SLEPc Release Version %d.%d.%d, %s",SLEPC_VERSION_MAJOR,SLEPC_VERSION_MINOR,SLEPC_VERSION_SUBMINOR,SLEPC_VERSION_DATE);CHKERRQ(ierr); #else ierr = PetscSNPrintf(version,len,"SLEPc Development GIT revision: %d GIT Date: %s",SLEPC_VERSION_GIT,SLEPC_VERSION_DATE_GIT);CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcPrintVersion" /* SlepcPrintVersion - Prints SLEPc version info. Collective on MPI_Comm */ static PetscErrorCode SlepcPrintVersion(MPI_Comm comm) { PetscErrorCode ierr; char version[256]; PetscFunctionBegin; ierr = SlepcGetVersion(version,256);CHKERRQ(ierr); ierr = (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");CHKERRQ(ierr); ierr = (*PetscHelpPrintf)(comm,"%s\n",version);CHKERRQ(ierr); ierr = (*PetscHelpPrintf)(comm,SLEPC_AUTHOR_INFO);CHKERRQ(ierr); ierr = (*PetscHelpPrintf)(comm,"See docs/manual.html for help.\n");CHKERRQ(ierr); ierr = (*PetscHelpPrintf)(comm,"SLEPc libraries linked from %s\n",SLEPC_LIB_DIR);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcPrintHelpIntro" /* SlepcPrintHelpIntro - Prints introductory SLEPc help info. Collective on MPI_Comm */ static PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm) { PetscErrorCode ierr; PetscFunctionBegin; ierr = (*PetscHelpPrintf)(comm,"SLEPc help information includes that for the PETSc libraries, which provide\n");CHKERRQ(ierr); ierr = (*PetscHelpPrintf)(comm,"low-level system infrastructure and linear algebra tools.\n");CHKERRQ(ierr); ierr = (*PetscHelpPrintf)(comm,"--------------------------------------------------------------------------\n");CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------Nasty global variables -------------------------------*/ /* Indicates whether SLEPc started PETSc, or whether it was already started before SLEPc was initialized. */ PetscBool SlepcBeganPetsc = PETSC_FALSE; PetscBool SlepcInitializeCalled = PETSC_FALSE; #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) #undef __FUNCT__ #define __FUNCT__ "SlepcLoadDynamicLibrary" static PetscErrorCode SlepcLoadDynamicLibrary(const char *name,PetscBool *found) { char libs[PETSC_MAX_PATH_LEN],dlib[PETSC_MAX_PATH_LEN]; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscStrcpy(libs,SLEPC_LIB_DIR);CHKERRQ(ierr); ierr = PetscStrcat(libs,"/libslepc");CHKERRQ(ierr); ierr = PetscStrcat(libs,name);CHKERRQ(ierr); ierr = PetscDLLibraryRetrieve(PETSC_COMM_WORLD,libs,dlib,1024,found);CHKERRQ(ierr); if (*found) { ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&PetscDLLibrariesLoaded,dlib);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcInitialize_DynamicLibraries" /* SlepcInitialize_DynamicLibraries - Adds the default dynamic link libraries to the search path. */ PetscErrorCode SlepcInitialize_DynamicLibraries(void) { PetscErrorCode ierr; PetscBool found; PetscBool preload; PetscFunctionBegin; preload = PETSC_FALSE; ierr = PetscOptionsGetBool(NULL,NULL,"-dynamic_library_preload",&preload,NULL);CHKERRQ(ierr); if (preload) { #if defined(PETSC_USE_SINGLE_LIBRARY) ierr = SlepcLoadDynamicLibrary("",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!"); #else ierr = SlepcLoadDynamicLibrary("sys",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!"); ierr = SlepcLoadDynamicLibrary("eps",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!"); ierr = SlepcLoadDynamicLibrary("pep",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!"); ierr = SlepcLoadDynamicLibrary("nep",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!"); ierr = SlepcLoadDynamicLibrary("svd",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!"); ierr = SlepcLoadDynamicLibrary("mfn",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate SLEPc dynamic library\nYou cannot move the dynamic libraries!"); #endif } #if defined(PETSC_HAVE_THREADSAFETY) ierr = STInitializePackage();CHKERRQ(ierr); ierr = DSInitializePackage();CHKERRQ(ierr); ierr = FNInitializePackage();CHKERRQ(ierr); ierr = BVInitializePackage();CHKERRQ(ierr); ierr = RGInitializePackage();CHKERRQ(ierr); ierr = EPSInitializePackage();CHKERRQ(ierr); ierr = SVDInitializePackage();CHKERRQ(ierr); ierr = PEPInitializePackage();CHKERRQ(ierr); ierr = NEPInitializePackage();CHKERRQ(ierr); ierr = MFNInitializePackage();CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #endif #undef __FUNCT__ #define __FUNCT__ "SlepcCitationsInitialize" PetscErrorCode SlepcCitationsInitialize() { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscCitationsRegister("@Article{slepc-toms,\n" " author = \"Vicente Hernandez and Jose E. Roman and Vicente Vidal\",\n" " title = \"{SLEPc}: A Scalable and Flexible Toolkit for the Solution of Eigenvalue Problems\",\n" " journal = \"{ACM} Trans. Math. Software\",\n" " volume = \"31\",\n" " number = \"3\",\n" " pages = \"351--362\",\n" " year = \"2005,\"\n" " doi = \"http://dx.doi.org/10.1145/1089014.1089019\"\n" "}\n",NULL);CHKERRQ(ierr); ierr = PetscCitationsRegister("@TechReport{slepc-manual,\n" " author = \"J. E. Roman and C. Campos and E. Romero and A. Tomas\",\n" " title = \"{SLEPc} Users Manual\",\n" " number = \"DSIC-II/24/02 - Revision 3.7\",\n" " institution = \"D. Sistemes Inform\\`atics i Computaci\\'o, Universitat Polit\\`ecnica de Val\\`encia\",\n" " year = \"2016\"\n" "}\n",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcInitialize" /*@C SlepcInitialize - Initializes the SLEPc library. SlepcInitialize() calls PetscInitialize() if that has not been called yet, so this routine should always be called near the beginning of your program. Collective on MPI_COMM_WORLD or PETSC_COMM_WORLD if it has been set Input Parameters: + argc - count of number of command line arguments . args - the command line arguments . file - [optional] PETSc database file, defaults to ~username/.petscrc (use NULL for default) - help - [optional] Help message to print, use NULL for no message Fortran Note: Fortran syntax is very similar to that of PetscInitialize() Level: beginner .seealso: SlepcFinalize(), PetscInitialize() @*/ PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[]) { PetscErrorCode ierr; PetscBool flg; PetscFunctionBegin; if (SlepcInitializeCalled) PetscFunctionReturn(0); ierr = PetscSetHelpVersionFunctions(SlepcPrintHelpIntro,SlepcPrintVersion);CHKERRQ(ierr); ierr = PetscInitialized(&flg);CHKERRQ(ierr); if (!flg) { ierr = PetscInitialize(argc,args,file,help);CHKERRQ(ierr); SlepcBeganPetsc = PETSC_TRUE; } ierr = SlepcCitationsInitialize();CHKERRQ(ierr); #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) ierr = SlepcInitialize_DynamicLibraries();CHKERRQ(ierr); #endif #if defined(PETSC_HAVE_DRAND48) /* work-around for Cygwin drand48() initialization bug */ srand48(0); #endif SlepcInitializeCalled = PETSC_TRUE; ierr = PetscInfo(0,"SLEPc successfully started\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcFinalize" /*@ SlepcFinalize - Checks for options to be called at the conclusion of the SLEPc program and calls PetscFinalize(). Collective on PETSC_COMM_WORLD Level: beginner .seealso: SlepcInitialize(), PetscFinalize() @*/ PetscErrorCode SlepcFinalize(void) { PetscErrorCode ierr = 0; PetscFunctionBegin; ierr = PetscInfo(0,"SlepcFinalize() called\n");CHKERRQ(ierr); if (SlepcBeganPetsc) { ierr = PetscFinalize(); } SlepcInitializeCalled = PETSC_FALSE; PetscFunctionReturn(ierr); } #undef __FUNCT__ #define __FUNCT__ "SlepcInitializeNoArguments" /*@C SlepcInitializeNoArguments - Calls SlepcInitialize() from C/C++ without the command line arguments. Collective Level: advanced .seealso: SlepcInitialize(), SlepcInitializeFortran() @*/ PetscErrorCode SlepcInitializeNoArguments(void) { PetscErrorCode ierr; int argc = 0; char **args = 0; PetscFunctionBegin; ierr = SlepcInitialize(&argc,&args,NULL,NULL); PetscFunctionReturn(ierr); } #undef __FUNCT__ #define __FUNCT__ "SlepcInitialized" /*@ SlepcInitialized - Determine whether SLEPc is initialized. Level: beginner .seealso: SlepcInitialize(), SlepcInitializeFortran() @*/ PetscErrorCode SlepcInitialized(PetscBool *isInitialized) { PetscFunctionBegin; PetscValidPointer(isInitialized,1); *isInitialized = SlepcInitializeCalled; PetscFunctionReturn(0); } PETSC_EXTERN PetscBool PetscBeganMPI; #undef __FUNCT__ #define __FUNCT__ "SlepcInitializeNoPointers" /* SlepcInitializeNoPointers - Calls SlepcInitialize() from C/C++ without the pointers to argc and args (analogue to PetscInitializeNoPointers). Collective Level: advanced .seealso: SlepcInitialize() */ PetscErrorCode SlepcInitializeNoPointers(int argc,char **args,const char *filename,const char *help) { PetscErrorCode ierr; int myargc = argc; char **myargs = args; PetscFunctionBegin; ierr = SlepcInitialize(&myargc,&myargs,filename,help);CHKERRQ(ierr); ierr = PetscPopSignalHandler();CHKERRQ(ierr); PetscBeganMPI = PETSC_FALSE; PetscFunctionReturn(ierr); } slepc-3.7.4/src/sys/vec/0000755000175000017500000000000013107004621014345 5ustar jromanjromanslepc-3.7.4/src/sys/vec/makefile0000644000175000017500000000217013107004621016045 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = veccomp.c pool.c SOURCEF = SOURCEH = veccomp0.h LIBBASE = libslepcsys DIRS = MANSEC = sys LOCDIR = src/sys/vec/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/vec/makefile.html0000644000175000017500000000456313107004621017020 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = veccomp.c pool.c
SOURCEF  =
SOURCEH  = veccomp0.h
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = sys
LOCDIR   = src/sys/vec/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/vec/veccomp0.h0000644000175000017500000002350413107004621016236 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #if defined(__WITH_MPI__) #define __SUF__(A) A##_MPI #else #define __SUF__(A) A##_Seq #endif #define __QUOTEME_(x) #x #define __QUOTEME(x) __QUOTEME_(x) #define __SUF_C__(A) __QUOTEME(__SUF__(A)) #undef __FUNCT__ #define __FUNCT__ __SUF_C__(VecDot_Comp) PetscErrorCode __SUF__(VecDot_Comp)(Vec a,Vec b,PetscScalar *z) { PetscScalar sum = 0.0,work; PetscInt i; PetscErrorCode ierr; Vec_Comp *as = (Vec_Comp*)a->data,*bs = (Vec_Comp*)b->data; PetscFunctionBegin; SlepcValidVecComp(a); SlepcValidVecComp(b); if (as->x[0]->ops->dot_local) { for (i=0,sum=0.0;in->n;i++) { ierr = as->x[i]->ops->dot_local(as->x[i],bs->x[i],&work);CHKERRQ(ierr); sum += work; } #if defined(__WITH_MPI__) work = sum; ierr = MPI_Allreduce(&work,&sum,1,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); #endif } else { for (i=0,sum=0.0;in->n;i++) { ierr = VecDot(as->x[i],bs->x[i],&work);CHKERRQ(ierr); sum += work; } } *z = sum; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ __SUF_C__(VecMDot_Comp) PetscErrorCode __SUF__(VecMDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z) { PetscScalar *work,*work0,*r; PetscErrorCode ierr; Vec_Comp *as = (Vec_Comp*)a->data; Vec *bx; PetscInt i,j; PetscFunctionBegin; SlepcValidVecComp(a); for (i=0;in->n == 0) { *z = 0; PetscFunctionReturn(0); } ierr = PetscMalloc2(n,&work0,n,&bx);CHKERRQ(ierr); #if defined(__WITH_MPI__) if (as->x[0]->ops->mdot_local) { r = work0; work = z; } else #endif { r = z; work = work0; } /* z[i] <- a.x' * b[i].x */ for (i=0;idata)->x[0]; if (as->x[0]->ops->mdot_local) { ierr = as->x[0]->ops->mdot_local(as->x[0],n,bx,r);CHKERRQ(ierr); } else { ierr = VecMDot(as->x[0],n,bx,r);CHKERRQ(ierr); } for (j=0;jn->n;j++) { for (i=0;idata)->x[j]; if (as->x[0]->ops->mdot_local) { ierr = as->x[j]->ops->mdot_local(as->x[j],n,bx,work);CHKERRQ(ierr); } else { ierr = VecMDot(as->x[j],n,bx,work);CHKERRQ(ierr); } for (i=0;ix[0]->ops->mdot_local) { /* z[i] <- Allreduce(work[i]) */ ierr = MPI_Allreduce(r,z,n,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); } #endif ierr = PetscFree2(work0,bx);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ __SUF_C__(VecTDot_Comp) PetscErrorCode __SUF__(VecTDot_Comp)(Vec a,Vec b,PetscScalar *z) { PetscScalar sum = 0.0,work; PetscInt i; PetscErrorCode ierr; Vec_Comp *as = (Vec_Comp*)a->data,*bs = (Vec_Comp*)b->data; PetscFunctionBegin; SlepcValidVecComp(a); SlepcValidVecComp(b); if (as->x[0]->ops->tdot_local) { for (i=0,sum=0.0;in->n;i++) { ierr = as->x[i]->ops->tdot_local(as->x[i],bs->x[i],&work);CHKERRQ(ierr); sum += work; } #if defined(__WITH_MPI__) work = sum; ierr = MPI_Allreduce(&work,&sum,1,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); #endif } else { for (i=0,sum=0.0;in->n;i++) { ierr = VecTDot(as->x[i],bs->x[i],&work);CHKERRQ(ierr); sum += work; } } *z = sum; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ __SUF_C__(VecMTDot_Comp) PetscErrorCode __SUF__(VecMTDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z) { PetscScalar *work,*work0,*r; PetscErrorCode ierr; Vec_Comp *as = (Vec_Comp*)a->data; Vec *bx; PetscInt i,j; PetscFunctionBegin; SlepcValidVecComp(a); for (i=0;in->n == 0) { *z = 0; PetscFunctionReturn(0); } ierr = PetscMalloc2(n,&work0,n,&bx);CHKERRQ(ierr); #if defined(__WITH_MPI__) if (as->x[0]->ops->mtdot_local) { r = work0; work = z; } else #endif { r = z; work = work0; } /* z[i] <- a.x' * b[i].x */ for (i=0;idata)->x[0]; if (as->x[0]->ops->mtdot_local) { ierr = as->x[0]->ops->mtdot_local(as->x[0],n,bx,r);CHKERRQ(ierr); } else { ierr = VecMTDot(as->x[0],n,bx,r);CHKERRQ(ierr); } for (j=0;jn->n;j++) { for (i=0;idata)->x[j]; if (as->x[0]->ops->mtdot_local) { ierr = as->x[j]->ops->mtdot_local(as->x[j],n,bx,work);CHKERRQ(ierr); } else { ierr = VecMTDot(as->x[j],n,bx,work);CHKERRQ(ierr); } for (i=0;ix[0]->ops->mtdot_local) { /* z[i] <- Allreduce(work[i]) */ ierr = MPI_Allreduce(r,z,n,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); } #endif ierr = PetscFree2(work0,bx);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ __SUF_C__(VecNorm_Comp) PetscErrorCode __SUF__(VecNorm_Comp)(Vec a,NormType t,PetscReal *norm) { PetscReal work[3],s=0.0; PetscErrorCode ierr; Vec_Comp *as = (Vec_Comp*)a->data; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(a); /* Initialize norm */ switch (t) { case NORM_1: case NORM_INFINITY: *norm = 0.0; break; case NORM_2: case NORM_FROBENIUS: *norm = 1.0; s = 0.0; break; case NORM_1_AND_2: norm[0] = 0.0; norm[1] = 1.0; s = 0.0; break; } for (i=0;in->n;i++) { if (as->x[0]->ops->norm_local) { ierr = as->x[0]->ops->norm_local(as->x[i],t,work);CHKERRQ(ierr); } else { ierr = VecNorm(as->x[i],t,work);CHKERRQ(ierr); } /* norm+= work */ switch (t) { case NORM_1: *norm+= *work; break; case NORM_2: case NORM_FROBENIUS: AddNorm2(norm,&s,*work); break; case NORM_1_AND_2: norm[0]+= work[0]; AddNorm2(&norm[1],&s,work[1]); break; case NORM_INFINITY: *norm = PetscMax(*norm,*work); break; } } /* If def(__WITH_MPI__) and exists norm_local */ #if defined(__WITH_MPI__) if (as->x[0]->ops->norm_local) { PetscReal work0[3]; /* norm <- Allreduce(work) */ switch (t) { case NORM_1: work[0] = *norm; ierr = MPI_Allreduce(work,norm,1,MPIU_REAL,MPIU_SUM,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); break; case NORM_2: case NORM_FROBENIUS: work[0] = *norm; work[1] = s; ierr = MPI_Allreduce(work,work0,1,MPIU_NORM2,MPIU_NORM2_SUM,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); *norm = GetNorm2(work0[0],work0[1]); break; case NORM_1_AND_2: work[0] = norm[0]; work[1] = norm[1]; work[2] = s; ierr = MPI_Allreduce(work,work0,1,MPIU_NORM1_AND_2,MPIU_NORM2_SUM,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); norm[0] = work0[0]; norm[1] = GetNorm2(work0[1],work0[2]); break; case NORM_INFINITY: work[0] = *norm; ierr = MPI_Allreduce(work,norm,1,MPIU_REAL,MPIU_MAX,PetscObjectComm((PetscObject)a));CHKERRQ(ierr); break; } } #else /* Norm correction */ switch (t) { case NORM_2: case NORM_FROBENIUS: *norm = GetNorm2(*norm,s); break; case NORM_1_AND_2: norm[1] = GetNorm2(norm[1],s); break; default: ; } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ __SUF_C__(VecDotNorm2_Comp) PetscErrorCode __SUF__(VecDotNorm2_Comp)(Vec v,Vec w,PetscScalar *dp,PetscScalar *nm) { PetscErrorCode ierr; PetscScalar dp0,nm0,dp1,nm1; const PetscScalar *vx,*wx; Vec_Comp *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data; PetscInt i,n; PetscBool t0,t1; #if defined(__WITH_MPI__) PetscScalar work[4]; #endif PetscFunctionBegin; /* Compute recursively the local part */ dp0 = nm0 = 0.0; ierr = PetscObjectTypeCompare((PetscObject)v,VECCOMP,&t0);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)w,VECCOMP,&t1);CHKERRQ(ierr); if (t0 && t1) { SlepcValidVecComp(v); SlepcValidVecComp(w); for (i=0;in->n;i++) { ierr = VecDotNorm2_Comp_Seq(vs->x[i],ws->x[i],&dp1,&nm1);CHKERRQ(ierr); dp0 += dp1; nm0 += nm1; } } else if (!t0 && !t1) { ierr = VecGetLocalSize(v,&n);CHKERRQ(ierr); ierr = VecGetArrayRead(v,&vx);CHKERRQ(ierr); ierr = VecGetArrayRead(w,&wx);CHKERRQ(ierr); for (i=0;iActual source code: veccomp0.h
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <petsc/private/vecimpl.h>

 24: #if defined(__WITH_MPI__)
 26: #else
 28: #endif


 36: PetscErrorCode __SUF__(VecDot_Comp)(Vec a,Vec b,PetscScalar *z)
 37: {
 38:   PetscScalar    sum = 0.0,work;
 39:   PetscInt       i;
 41:   Vec_Comp       *as = (Vec_Comp*)a->data,*bs = (Vec_Comp*)b->data;

 44:   SlepcValidVecComp(a);
 45:   SlepcValidVecComp(b);
 46:   if (as->x[0]->ops->dot_local) {
 47:     for (i=0,sum=0.0;i<as->n->n;i++) {
 48:       as->x[i]->ops->dot_local(as->x[i],bs->x[i],&work);
 49:       sum += work;
 50:     }
 51: #if defined(__WITH_MPI__)
 52:     work = sum;
 53:     MPI_Allreduce(&work,&sum,1,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));
 54: #endif
 55:   } else {
 56:     for (i=0,sum=0.0;i<as->n->n;i++) {
 57:       VecDot(as->x[i],bs->x[i],&work);
 58:       sum += work;
 59:     }
 60:   }
 61:   *z = sum;
 62:   return(0);
 63: }

 67: PetscErrorCode __SUF__(VecMDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z)
 68: {
 69:   PetscScalar    *work,*work0,*r;
 71:   Vec_Comp       *as = (Vec_Comp*)a->data;
 72:   Vec            *bx;
 73:   PetscInt       i,j;

 76:   SlepcValidVecComp(a);
 77:   for (i=0;i<n;i++) SlepcValidVecComp(b[i]);

 79:   if (as->n->n == 0) {
 80:     *z = 0;
 81:     return(0);
 82:   }

 84:   PetscMalloc2(n,&work0,n,&bx);

 86: #if defined(__WITH_MPI__)
 87:   if (as->x[0]->ops->mdot_local) {
 88:     r = work0; work = z;
 89:   } else
 90: #endif
 91:   {
 92:     r = z; work = work0;
 93:   }

 95:   /* z[i] <- a.x' * b[i].x */
 96:   for (i=0;i<n;i++) bx[i] = ((Vec_Comp*)b[i]->data)->x[0];
 97:   if (as->x[0]->ops->mdot_local) {
 98:     as->x[0]->ops->mdot_local(as->x[0],n,bx,r);
 99:   } else {
100:     VecMDot(as->x[0],n,bx,r);
101:   }
102:   for (j=0;j<as->n->n;j++) {
103:     for (i=0;i<n;i++) bx[i] = ((Vec_Comp*)b[i]->data)->x[j];
104:     if (as->x[0]->ops->mdot_local) {
105:       as->x[j]->ops->mdot_local(as->x[j],n,bx,work);
106:     } else {
107:       VecMDot(as->x[j],n,bx,work);
108:     }
109:     for (i=0;i<n;i++) r[i] += work[i];
110:   }

112:   /* If def(__WITH_MPI__) and exists mdot_local */
113: #if defined(__WITH_MPI__)
114:   if (as->x[0]->ops->mdot_local) {
115:     /* z[i] <- Allreduce(work[i]) */
116:     MPI_Allreduce(r,z,n,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));
117:   }
118: #endif

120:   PetscFree2(work0,bx);
121:   return(0);
122: }

126: PetscErrorCode __SUF__(VecTDot_Comp)(Vec a,Vec b,PetscScalar *z)
127: {
128:   PetscScalar    sum = 0.0,work;
129:   PetscInt       i;
131:   Vec_Comp       *as = (Vec_Comp*)a->data,*bs = (Vec_Comp*)b->data;

134:   SlepcValidVecComp(a);
135:   SlepcValidVecComp(b);
136:   if (as->x[0]->ops->tdot_local) {
137:     for (i=0,sum=0.0;i<as->n->n;i++) {
138:       as->x[i]->ops->tdot_local(as->x[i],bs->x[i],&work);
139:       sum += work;
140:     }
141: #if defined(__WITH_MPI__)
142:     work = sum;
143:     MPI_Allreduce(&work,&sum,1,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));
144: #endif
145:   } else {
146:     for (i=0,sum=0.0;i<as->n->n;i++) {
147:       VecTDot(as->x[i],bs->x[i],&work);
148:       sum += work;
149:     }
150:   }
151:   *z = sum;
152:   return(0);
153: }

157: PetscErrorCode __SUF__(VecMTDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z)
158: {
159:   PetscScalar    *work,*work0,*r;
161:   Vec_Comp       *as = (Vec_Comp*)a->data;
162:   Vec            *bx;
163:   PetscInt       i,j;

166:   SlepcValidVecComp(a);
167:   for (i=0;i<n;i++) SlepcValidVecComp(b[i]);

169:   if (as->n->n == 0) {
170:     *z = 0;
171:     return(0);
172:   }

174:   PetscMalloc2(n,&work0,n,&bx);

176: #if defined(__WITH_MPI__)
177:   if (as->x[0]->ops->mtdot_local) {
178:     r = work0; work = z;
179:   } else
180: #endif
181:   {
182:     r = z; work = work0;
183:   }

185:   /* z[i] <- a.x' * b[i].x */
186:   for (i=0;i<n;i++) bx[i] = ((Vec_Comp*)b[i]->data)->x[0];
187:   if (as->x[0]->ops->mtdot_local) {
188:     as->x[0]->ops->mtdot_local(as->x[0],n,bx,r);
189:   } else {
190:     VecMTDot(as->x[0],n,bx,r);
191:   }
192:   for (j=0;j<as->n->n;j++) {
193:     for (i=0;i<n;i++) bx[i] = ((Vec_Comp*)b[i]->data)->x[j];
194:     if (as->x[0]->ops->mtdot_local) {
195:       as->x[j]->ops->mtdot_local(as->x[j],n,bx,work);
196:     } else {
197:       VecMTDot(as->x[j],n,bx,work);
198:     }
199:     for (i=0;i<n;i++) r[i] += work[i];
200:   }

202:   /* If def(__WITH_MPI__) and exists mtdot_local */
203: #if defined(__WITH_MPI__)
204:   if (as->x[0]->ops->mtdot_local) {
205:     /* z[i] <- Allreduce(work[i]) */
206:     MPI_Allreduce(r,z,n,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)a));
207:   }
208: #endif

210:   PetscFree2(work0,bx);
211:   return(0);
212: }

216: PetscErrorCode __SUF__(VecNorm_Comp)(Vec a,NormType t,PetscReal *norm)
217: {
218:   PetscReal      work[3],s=0.0;
220:   Vec_Comp       *as = (Vec_Comp*)a->data;
221:   PetscInt       i;

224:   SlepcValidVecComp(a);
225:   /* Initialize norm */
226:   switch (t) {
227:     case NORM_1: case NORM_INFINITY: *norm = 0.0; break;
228:     case NORM_2: case NORM_FROBENIUS: *norm = 1.0; s = 0.0; break;
229:     case NORM_1_AND_2: norm[0] = 0.0; norm[1] = 1.0; s = 0.0; break;
230:   }
231:   for (i=0;i<as->n->n;i++) {
232:     if (as->x[0]->ops->norm_local) {
233:       as->x[0]->ops->norm_local(as->x[i],t,work);
234:     } else {
235:       VecNorm(as->x[i],t,work);
236:     }
237:     /* norm+= work */
238:     switch (t) {
239:       case NORM_1: *norm+= *work; break;
240:       case NORM_2: case NORM_FROBENIUS: AddNorm2(norm,&s,*work); break;
241:       case NORM_1_AND_2: norm[0]+= work[0]; AddNorm2(&norm[1],&s,work[1]); break;
242:       case NORM_INFINITY: *norm = PetscMax(*norm,*work); break;
243:     }
244:   }

246:   /* If def(__WITH_MPI__) and exists norm_local */
247: #if defined(__WITH_MPI__)
248:   if (as->x[0]->ops->norm_local) {
249:     PetscReal work0[3];
250:     /* norm <- Allreduce(work) */
251:     switch (t) {
252:     case NORM_1:
253:       work[0] = *norm;
254:       MPI_Allreduce(work,norm,1,MPIU_REAL,MPIU_SUM,PetscObjectComm((PetscObject)a));
255:       break;
256:     case NORM_2: case NORM_FROBENIUS:
257:       work[0] = *norm; work[1] = s;
258:       MPI_Allreduce(work,work0,1,MPIU_NORM2,MPIU_NORM2_SUM,PetscObjectComm((PetscObject)a));
259:       *norm = GetNorm2(work0[0],work0[1]);
260:       break;
261:     case NORM_1_AND_2:
262:       work[0] = norm[0]; work[1] = norm[1]; work[2] = s;
263:       MPI_Allreduce(work,work0,1,MPIU_NORM1_AND_2,MPIU_NORM2_SUM,PetscObjectComm((PetscObject)a));
264:       norm[0] = work0[0];
265:       norm[1] = GetNorm2(work0[1],work0[2]);
266:       break;
267:     case NORM_INFINITY:
268:       work[0] = *norm;
269:       MPI_Allreduce(work,norm,1,MPIU_REAL,MPIU_MAX,PetscObjectComm((PetscObject)a));
270:       break;
271:     }
272:   }
273: #else
274:   /* Norm correction */
275:   switch (t) {
276:     case NORM_2: case NORM_FROBENIUS: *norm = GetNorm2(*norm,s); break;
277:     case NORM_1_AND_2: norm[1] = GetNorm2(norm[1],s); break;
278:     default: ;
279:   }
280: #endif
281:   return(0);
282: }

286: PetscErrorCode __SUF__(VecDotNorm2_Comp)(Vec v,Vec w,PetscScalar *dp,PetscScalar *nm)
287: {
288:   PetscErrorCode    ierr;
289:   PetscScalar       dp0,nm0,dp1,nm1;
290:   const PetscScalar *vx,*wx;
291:   Vec_Comp          *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data;
292:   PetscInt          i,n;
293:   PetscBool         t0,t1;
294: #if defined(__WITH_MPI__)
295:   PetscScalar       work[4];
296: #endif

299:   /* Compute recursively the local part */
300:   dp0 = nm0 = 0.0;
301:   PetscObjectTypeCompare((PetscObject)v,VECCOMP,&t0);
302:   PetscObjectTypeCompare((PetscObject)w,VECCOMP,&t1);
303:   if (t0 && t1) {
304:     SlepcValidVecComp(v);
305:     SlepcValidVecComp(w);
306:     for (i=0;i<vs->n->n;i++) {
307:       VecDotNorm2_Comp_Seq(vs->x[i],ws->x[i],&dp1,&nm1);
308:       dp0 += dp1;
309:       nm0 += nm1;
310:     }
311:   } else if (!t0 && !t1) {
312:     VecGetLocalSize(v,&n);
313:     VecGetArrayRead(v,&vx);
314:     VecGetArrayRead(w,&wx);
315:     for (i=0;i<n;i++) {
316:       dp0 += vx[i]*PetscConj(wx[i]);
317:       nm0 += wx[i]*PetscConj(wx[i]);
318:     }
319:     VecRestoreArrayRead(v,&vx);
320:     VecRestoreArrayRead(w,&wx);
321:   } else SETERRQ(PetscObjectComm((PetscObject)v),PETSC_ERR_ARG_INCOMP,"Incompatible vector types");

323: #if defined(__WITH_MPI__)
324:     /* [dp, nm] <- Allreduce([dp0, nm0]) */
325:     work[0] = dp0; work[1] = nm0;
326:     MPI_Allreduce(work,&work[2],2,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)v));
327:     *dp = work[2]; *nm = work[3];
328: #else
329:     *dp = dp0; *nm = nm0;
330: #endif
331:   return(0);
332: }


slepc-3.7.4/src/sys/vec/veccomp.c0000644000175000017500000005350013107004621016150 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcvec.h" I*/ /* Private MPI datatypes and operators */ static MPI_Datatype MPIU_NORM2=0, MPIU_NORM1_AND_2=0; static MPI_Op MPIU_NORM2_SUM=0; static PetscBool VecCompInitialized = PETSC_FALSE; /* Private inline functions */ PETSC_STATIC_INLINE void SumNorm2(PetscReal *,PetscReal *,PetscReal *,PetscReal *); PETSC_STATIC_INLINE PetscReal GetNorm2(PetscReal,PetscReal); PETSC_STATIC_INLINE void AddNorm2(PetscReal *,PetscReal *,PetscReal); #include "veccomp0.h" #define __WITH_MPI__ #include "veccomp0.h" PETSC_STATIC_INLINE void SumNorm2(PetscReal *ssq0,PetscReal *scale0,PetscReal *ssq1,PetscReal *scale1) { PetscReal q; if (*scale0 > *scale1) { q = *scale1/(*scale0); *ssq1 = *ssq0 + q*q*(*ssq1); *scale1 = *scale0; } else { q = *scale0/(*scale1); *ssq1 += q*q*(*ssq0); } } PETSC_STATIC_INLINE PetscReal GetNorm2(PetscReal ssq,PetscReal scale) { return scale*PetscSqrtReal(ssq); } PETSC_STATIC_INLINE void AddNorm2(PetscReal *ssq,PetscReal *scale,PetscReal x) { PetscReal absx,q; if (x != 0.0) { absx = PetscAbs(x); if (*scale < absx) { q = *scale/absx; *ssq = 1.0 + *ssq*q*q; *scale = absx; } else { q = absx/(*scale); *ssq += q*q; } } } #undef __FUNCT__ #define __FUNCT__ "SlepcSumNorm2_Local" static void SlepcSumNorm2_Local(void *in,void *out,PetscMPIInt *cnt,MPI_Datatype *datatype) { PetscInt i,count = *cnt; PetscFunctionBegin; if (*datatype == MPIU_NORM2) { PetscReal *xin = (PetscReal*)in,*xout = (PetscReal*)out; for (i=0; idata; PetscInt i; PetscErrorCode ierr; PetscFunctionBegin; #if defined(PETSC_USE_LOG) PetscLogObjectState((PetscObject)v,"Length=%D",v->map->n); #endif for (i=0;inx;i++) { ierr = VecDestroy(&vs->x[i]);CHKERRQ(ierr); } if (--vs->n->friends <= 0) { ierr = PetscFree(vs->n);CHKERRQ(ierr); } ierr = PetscFree(vs->x);CHKERRQ(ierr); ierr = PetscFree(vs);CHKERRQ(ierr); PetscFunctionReturn(0); } static struct _VecOps DvOps = {VecDuplicate_Comp, /* 1 */ VecDuplicateVecs_Comp, VecDestroyVecs_Comp, VecDot_Comp_MPI, VecMDot_Comp_MPI, VecNorm_Comp_MPI, VecTDot_Comp_MPI, VecMTDot_Comp_MPI, VecScale_Comp, VecCopy_Comp, /* 10 */ VecSet_Comp, VecSwap_Comp, VecAXPY_Comp, VecAXPBY_Comp, VecMAXPY_Comp, VecAYPX_Comp, VecWAXPY_Comp, VecAXPBYPCZ_Comp, VecPointwiseMult_Comp, VecPointwiseDivide_Comp, 0, /* 20 */ 0,0, 0 /*VecGetArray_Seq*/, VecGetSize_Comp, VecGetLocalSize_Comp, 0/*VecRestoreArray_Seq*/, VecMax_Comp, VecMin_Comp, VecSetRandom_Comp, 0, /* 30 */ 0, VecDestroy_Comp, VecView_Comp, 0/*VecPlaceArray_Seq*/, 0/*VecReplaceArray_Seq*/, VecDot_Comp_Seq, 0, VecNorm_Comp_Seq, VecMDot_Comp_Seq, 0, /* 40 */ 0, VecReciprocal_Comp, VecConjugate_Comp, 0,0, 0/*VecResetArray_Seq*/, 0, VecMaxPointwiseDivide_Comp, VecPointwiseMax_Comp, VecPointwiseMaxAbs_Comp, VecPointwiseMin_Comp, 0, VecSqrtAbs_Comp, VecAbs_Comp, VecExp_Comp, VecLog_Comp, 0/*VecShift_Comp*/, 0, 0, 0, VecDotNorm2_Comp_MPI }; #undef __FUNCT__ #define __FUNCT__ "VecDuplicateVecs_Comp" PetscErrorCode VecDuplicateVecs_Comp(Vec w,PetscInt m,Vec *V[]) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(w,VEC_CLASSID,1); PetscValidPointer(V,3); if (m<=0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"m must be > 0: m = %D",m); ierr = PetscMalloc1(m,V);CHKERRQ(ierr); for (i=0;i 0: m = %D",m); for (i=0;idata) { ierr = PetscFree(v->data);CHKERRQ(ierr); } ierr = PetscNewLog(v,&s);CHKERRQ(ierr); ierr = PetscMemcpy(v->ops,&DvOps,sizeof(DvOps));CHKERRQ(ierr); v->data = (void*)s; v->petscnative = PETSC_FALSE; /* Allocate the array of Vec, if it is needed to be done */ if (x_to_me != PETSC_TRUE) { ierr = PetscMalloc(sizeof(Vec)*nx,&s->x);CHKERRQ(ierr); ierr = PetscMemcpy(s->x,x,sizeof(Vec)*nx);CHKERRQ(ierr); } else s->x = x; s->nx = nx; /* Allocate the shared structure, if it is not given */ if (!n) { for (i=0;in = n; n->n = nx; n->N = N; n->lN = lN; n->friends = 1; } else { /* If not, check in the vector in the shared structure */ s->n = n; s->n->friends++; } /* Set the virtual sizes as the real sizes of the vector */ ierr = VecSetSizes(v,s->n->lN,s->n->N);CHKERRQ(ierr); ierr = PetscObjectChangeTypeName((PetscObject)v,VECCOMP);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecCreate_Comp" PETSC_EXTERN PetscErrorCode VecCreate_Comp(Vec V) { PetscErrorCode ierr; PetscFunctionBegin; ierr = VecCreate_Comp_Private(V,NULL,0,PETSC_FALSE,NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecCreateComp" /*@C VecCreateComp - Creates a new vector containing several subvectors, each stored separately. Collective on Vec Input Parameters: + comm - communicator for the new Vec . Nx - array of (initial) global sizes of child vectors . n - number of child vectors . t - type of the child vectors - Vparent - (optional) template vector Output Parameter: . V - new vector Notes: This is similar to PETSc's VecNest but customized for SLEPc's needs. In particular, the number of child vectors can be modified dynamically, with VecCompSetSubVecs(). Level: developer .seealso: VecCreateCompWithVecs(), VecCompSetSubVecs() @*/ PetscErrorCode VecCreateComp(MPI_Comm comm,PetscInt *Nx,PetscInt n,VecType t,Vec Vparent,Vec *V) { PetscErrorCode ierr; Vec *x; PetscInt i; PetscFunctionBegin; ierr = VecCreate(comm,V);CHKERRQ(ierr); ierr = PetscMalloc1(n,&x);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)*V,n*sizeof(Vec));CHKERRQ(ierr); for (i=0;idata)->n:NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecCreateCompWithVecs" /*@C VecCreateCompWithVecs - Creates a new vector containing several subvectors, each stored separately, from an array of Vecs. Collective on Vec Input Parameters: + x - array of Vecs . n - number of child vectors - Vparent - (optional) template vector Output Parameter: . V - new vector Level: developer .seealso: VecCreateComp() @*/ PetscErrorCode VecCreateCompWithVecs(Vec *x,PetscInt n,Vec Vparent,Vec *V) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; ierr = VecCreate(PetscObjectComm((PetscObject)x[0]),V);CHKERRQ(ierr); for (i=0;idata)->n:NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecDuplicate_Comp" PetscErrorCode VecDuplicate_Comp(Vec win,Vec *V) { PetscErrorCode ierr; Vec *x; PetscInt i; Vec_Comp *s = (Vec_Comp*)win->data; PetscFunctionBegin; SlepcValidVecComp(win); ierr = VecCreate(PetscObjectComm((PetscObject)win),V);CHKERRQ(ierr); ierr = PetscMalloc1(s->nx,&x);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)*V,s->nx*sizeof(Vec));CHKERRQ(ierr); for (i=0;inx;i++) { if (s->x[i]) { ierr = VecDuplicate(s->x[i],&x[i]);CHKERRQ(ierr); } else x[i] = NULL; } ierr = VecCreate_Comp_Private(*V,x,s->nx,PETSC_TRUE,s->n);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecCompGetSubVecs" /*@C VecCompGetSubVecs - Returns the entire array of vectors defining a compound vector. Collective on Vec Input Parameter: . win - compound vector Output Parameters: + n - number of child vectors - x - array of child vectors Level: developer .seealso: VecCreateComp() @*/ PetscErrorCode VecCompGetSubVecs(Vec win,PetscInt *n,const Vec **x) { Vec_Comp *s = (Vec_Comp*)win->data; PetscFunctionBegin; SlepcValidVecComp(win); if (x) *x = s->x; if (n) *n = s->nx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecCompSetSubVecs" /*@C VecCompSetSubVecs - Resets the number of subvectors defining a compound vector, of replaces the subvectors. Collective on Vec Input Parameters: + win - compound vector . n - number of child vectors - x - array of child vectors Level: developer .seealso: VecCreateComp() @*/ PetscErrorCode VecCompSetSubVecs(Vec win,PetscInt n,Vec *x) { Vec_Comp *s = (Vec_Comp*)win->data; PetscErrorCode ierr; PetscFunctionBegin; if (x) { if (n > s->nx) { ierr = PetscFree(s->x);CHKERRQ(ierr); ierr = PetscMalloc(sizeof(Vec)*n,&s->x);CHKERRQ(ierr); } ierr = PetscMemcpy(s->x,x,sizeof(Vec)*n);CHKERRQ(ierr); s->nx = n; } s->n->n = n; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecAXPY_Comp" PetscErrorCode VecAXPY_Comp(Vec v,PetscScalar alpha,Vec w) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); SlepcValidVecComp(w); for (i=0;in->n;i++) { ierr = VecAXPY(vs->x[i],alpha,ws->x[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecAYPX_Comp" PetscErrorCode VecAYPX_Comp(Vec v,PetscScalar alpha,Vec w) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); SlepcValidVecComp(w); for (i=0;in->n;i++) { ierr = VecAYPX(vs->x[i],alpha,ws->x[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecAXPBY_Comp" PetscErrorCode VecAXPBY_Comp(Vec v,PetscScalar alpha,PetscScalar beta,Vec w) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); SlepcValidVecComp(w); for (i=0;in->n;i++) { ierr = VecAXPBY(vs->x[i],alpha,beta,ws->x[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecMAXPY_Comp" PetscErrorCode VecMAXPY_Comp(Vec v,PetscInt n,const PetscScalar *alpha,Vec *w) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data; Vec *wx; PetscInt i,j; PetscFunctionBegin; SlepcValidVecComp(v); for (i=0;in->n;j++) { for (i=0;idata)->x[j]; ierr = VecMAXPY(vs->x[j],n,alpha,wx);CHKERRQ(ierr); } ierr = PetscFree(wx);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecWAXPY_Comp" PetscErrorCode VecWAXPY_Comp(Vec v,PetscScalar alpha,Vec w,Vec z) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data,*zs = (Vec_Comp*)z->data; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); SlepcValidVecComp(w); SlepcValidVecComp(z); for (i=0;in->n;i++) { ierr = VecWAXPY(vs->x[i],alpha,ws->x[i],zs->x[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecAXPBYPCZ_Comp" PetscErrorCode VecAXPBYPCZ_Comp(Vec v,PetscScalar alpha,PetscScalar beta,PetscScalar gamma,Vec w,Vec z) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data,*zs = (Vec_Comp*)z->data; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); SlepcValidVecComp(w); SlepcValidVecComp(z); for (i=0;in->n;i++) { ierr = VecAXPBYPCZ(vs->x[i],alpha,beta,gamma,ws->x[i],zs->x[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecGetSize_Comp" PetscErrorCode VecGetSize_Comp(Vec v,PetscInt *size) { Vec_Comp *vs = (Vec_Comp*)v->data; PetscFunctionBegin; SlepcValidVecComp(v); PetscValidIntPointer(size,2); *size = vs->n->N; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecGetLocalSize_Comp" PetscErrorCode VecGetLocalSize_Comp(Vec v,PetscInt *size) { Vec_Comp *vs = (Vec_Comp*)v->data; PetscFunctionBegin; SlepcValidVecComp(v); PetscValidIntPointer(size,2); *size = vs->n->lN; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecMax_Comp" PetscErrorCode VecMax_Comp(Vec v,PetscInt *idx,PetscReal *z) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data; PetscInt idxp,s=0,s0; PetscReal zp,z0; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); if (!idx && !z) PetscFunctionReturn(0); if (vs->n->n > 0) { ierr = VecMax(vs->x[0],idx?&idxp:NULL,&zp);CHKERRQ(ierr); } else { zp = PETSC_MIN_REAL; if (idx) idxp = -1; } for (i=1;in->n;i++) { ierr = VecGetSize(vs->x[i-1],&s0);CHKERRQ(ierr); s += s0; ierr = VecMax(vs->x[i],idx?&idxp:NULL,&z0);CHKERRQ(ierr); if (zp < z0) { if (idx) *idx = s+idxp; zp = z0; } } if (z) *z = zp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecMin_Comp" PetscErrorCode VecMin_Comp(Vec v,PetscInt *idx,PetscReal *z) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data; PetscInt idxp,s=0,s0; PetscReal zp,z0; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); if (!idx && !z) PetscFunctionReturn(0); if (vs->n->n > 0) { ierr = VecMin(vs->x[0],idx?&idxp:NULL,&zp);CHKERRQ(ierr); } else { zp = PETSC_MAX_REAL; if (idx) idxp = -1; } for (i=1;in->n;i++) { ierr = VecGetSize(vs->x[i-1],&s0);CHKERRQ(ierr); s += s0; ierr = VecMin(vs->x[i],idx?&idxp:NULL,&z0);CHKERRQ(ierr); if (zp > z0) { if (idx) *idx = s+idxp; zp = z0; } } if (z) *z = zp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecMaxPointwiseDivide_Comp" PetscErrorCode VecMaxPointwiseDivide_Comp(Vec v,Vec w,PetscReal *m) { PetscErrorCode ierr; Vec_Comp *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data; PetscReal work; PetscInt i; PetscFunctionBegin; SlepcValidVecComp(v); SlepcValidVecComp(w); if (!m || vs->n->n == 0) PetscFunctionReturn(0); ierr = VecMaxPointwiseDivide(vs->x[0],ws->x[0],m);CHKERRQ(ierr); for (i=1;in->n;i++) { ierr = VecMaxPointwiseDivide(vs->x[i],ws->x[i],&work);CHKERRQ(ierr); *m = PetscMax(*m,work); } PetscFunctionReturn(0); } #define __QUOTEME__(x) #x #define __COMPOSE2__(A,B) A##B #define __COMPOSE3__(A,B,C) A##B##C #define __FUNC_TEMPLATE1__(NAME) \ PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v) \ { \ PetscErrorCode ierr; \ Vec_Comp *vs = (Vec_Comp*)v->data; \ PetscInt i; \ \ PetscFunctionBegin; \ SlepcValidVecComp(v); \ for (i=0;in->n;i++) { \ ierr = __COMPOSE2__(Vec,NAME)(vs->x[i]);CHKERRQ(ierr); \ } \ PetscFunctionReturn(0);\ } #undef __FUNCT__ #define __FUNCT__ "VecConjugate_Comp" __FUNC_TEMPLATE1__(Conjugate) #undef __FUNCT__ #define __FUNCT__ "VecReciprocal_Comp" __FUNC_TEMPLATE1__(Reciprocal) #undef __FUNCT__ #define __FUNCT__ "VecSqrtAbs_Comp" __FUNC_TEMPLATE1__(SqrtAbs) #undef __FUNCT__ #define __FUNCT__ "VecAbs_Comp" __FUNC_TEMPLATE1__(Abs) #undef __FUNCT__ #define __FUNCT__ "VecExp_Comp" __FUNC_TEMPLATE1__(Exp) #undef __FUNCT__ #define __FUNCT__ "VecLog_Comp" __FUNC_TEMPLATE1__(Log) #define __FUNC_TEMPLATE2__(NAME,T0) \ PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v,T0 __a) \ { \ PetscErrorCode ierr; \ Vec_Comp *vs = (Vec_Comp*)v->data; \ PetscInt i; \ \ PetscFunctionBegin; \ SlepcValidVecComp(v); \ for (i=0;in->n;i++) { \ ierr = __COMPOSE2__(Vec,NAME)(vs->x[i],__a);CHKERRQ(ierr); \ } \ PetscFunctionReturn(0);\ } #undef __FUNCT__ #define __FUNCT__ "VecSet_Comp" __FUNC_TEMPLATE2__(Set,PetscScalar) #undef __FUNCT__ #define __FUNCT__ "VecView_Comp" __FUNC_TEMPLATE2__(View,PetscViewer) #undef __FUNCT__ #define __FUNCT__ "VecScale_Comp" __FUNC_TEMPLATE2__(Scale,PetscScalar) #undef __FUNCT__ #define __FUNCT__ "VecSetRandom_Comp" __FUNC_TEMPLATE2__(SetRandom,PetscRandom) #undef __FUNCT__ #define __FUNCT__ "VecShift_Comp" __FUNC_TEMPLATE2__(Shift,PetscScalar) #define __FUNC_TEMPLATE3__(NAME) \ PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v,Vec w) \ { \ PetscErrorCode ierr; \ Vec_Comp *vs = (Vec_Comp*)v->data,\ *ws = (Vec_Comp*)w->data; \ PetscInt i; \ \ PetscFunctionBegin; \ SlepcValidVecComp(v); \ SlepcValidVecComp(w); \ for (i=0;in->n;i++) { \ ierr = __COMPOSE2__(Vec,NAME)(vs->x[i],ws->x[i]);CHKERRQ(ierr); \ } \ PetscFunctionReturn(0);\ } #undef __FUNCT__ #define __FUNCT__ "VecCopy_Comp" __FUNC_TEMPLATE3__(Copy) #undef __FUNCT__ #define __FUNCT__ "VecSwap_Comp" __FUNC_TEMPLATE3__(Swap) #define __FUNC_TEMPLATE4__(NAME) \ PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v,Vec w,Vec z) \ { \ PetscErrorCode ierr; \ Vec_Comp *vs = (Vec_Comp*)v->data, \ *ws = (Vec_Comp*)w->data, \ *zs = (Vec_Comp*)z->data; \ PetscInt i; \ \ PetscFunctionBegin; \ SlepcValidVecComp(v); \ SlepcValidVecComp(w); \ SlepcValidVecComp(z); \ for (i=0;in->n;i++) { \ ierr = __COMPOSE2__(Vec,NAME)(vs->x[i],ws->x[i],zs->x[i]);CHKERRQ(ierr); \ } \ PetscFunctionReturn(0);\ } #undef __FUNCT__ #define __FUNCT__ "VecPointwiseMax_Comp" __FUNC_TEMPLATE4__(PointwiseMax) #undef __FUNCT__ #define __FUNCT__ "VecPointwiseMaxAbs_Comp" __FUNC_TEMPLATE4__(PointwiseMaxAbs) #undef __FUNCT__ #define __FUNCT__ "VecPointwiseMin_Comp" __FUNC_TEMPLATE4__(PointwiseMin) #undef __FUNCT__ #define __FUNCT__ "VecPointwiseMult_Comp" __FUNC_TEMPLATE4__(PointwiseMult) #undef __FUNCT__ #define __FUNCT__ "VecPointwiseDivide_Comp" __FUNC_TEMPLATE4__(PointwiseDivide) slepc-3.7.4/src/sys/vec/index.html0000644000175000017500000000237313107004621016347 0ustar jromanjroman SLEPc System Routines
slepc-3.7.4 2017-05-17

SLEPc System routines

SLEPc provides a variety of "system" level routines. These routines are generally tools used by other SLEPc routines and are not intended for application programmers (except the basic SlepcInitialize() / SlepcFinalize()).

Useful tools for application programmers can be found in PETSc's system routines, including parallel file access, synchronized printing to screen, and many other programming aids.

veccomp0.h
veccomp.c
pool.c
makefile
slepc-3.7.4/src/sys/vec/pool.c.html0000644000175000017500000003013613107004621016430 0ustar jromanjroman

Actual source code: pool.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Implementation of a pool of Vec using VecDuplicateVecs.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/vecimplslepc.h>       /*I "slepcvec.h" I*/

 28: /*@C
 29:    SlepcVecPoolCreate - Create a pool of Vec.

 31:    Collective on VecPool

 33:    Input Parameters:
 34: +  v - template vector.
 35: -  init_size - first guess of maximum vectors.

 37:    Output Parameter:
 38: .  pool - the pool context.

 40:    Level: developer

 42: .seealso: SlepcVecPoolGetVecs(), SlepcVecPoolDestroy()
 43: @*/
 44: PetscErrorCode SlepcVecPoolCreate(Vec v,PetscInt init_size,VecPool *p)
 45: {
 47:   VecPool_       *pool;

 53:   if (init_size<0) SETERRQ(PetscObjectComm((PetscObject)v),PETSC_ERR_ARG_WRONG,"init_size should be positive");
 54:   PetscCalloc1(1,&pool);
 55:   PetscObjectReference((PetscObject)v);
 56:   pool->v     = v;
 57:   pool->guess = init_size;
 58:   *p = pool;
 59:   return(0);
 60: }

 64: /*@C
 65:    SlepcVecPoolDestroy - Destroy the pool of Vec.

 67:    Collective on VecPool

 69:    Input Parameters:
 70: .  pool - pool of Vec.

 72:    Level: developer

 74: .seealso: SlepcVecPoolGetVecs(), SlepcVecPoolCreate()
 75: @*/
 76: PetscErrorCode SlepcVecPoolDestroy(VecPool *p)
 77: {
 79:   VecPool_       *pool = (VecPool_*)*p;

 83:   VecDestroy(&pool->v);
 84:   if (pool->vecs) { VecDestroyVecs(pool->n,&pool->vecs); }
 85:   pool->n     = 0;
 86:   pool->used  = 0;
 87:   pool->guess = 0;
 88:   if (pool->next) { SlepcVecPoolDestroy((VecPool*)&pool->next); }
 89:   PetscFree(pool);
 90:   *p = NULL;
 91:   return(0);
 92: }

 96: /*@C
 97:    SlepcVecPoolGetVecs - Get an array of Vec from the pool.

 99:    Collective on VecPool

101:    Input Parameters:
102: +  pool - pool of Vec.
103: -  n - number of vectors.

105:    Output Parameter:
106: .  vecs - vectors

108:    Level: developer

110: .seealso: SlepcVecPoolRestoreVecs()
111: @*/
112: PetscErrorCode SlepcVecPoolGetVecs(VecPool p,PetscInt n,Vec **vecs)
113: {
115:   VecPool_       *pool = (VecPool_*)p;

120:   if (n<0) SETERRQ(PetscObjectComm((PetscObject)pool->v),PETSC_ERR_ARG_OUTOFRANGE,"n should be positive");
121:   while (pool->next) pool = pool->next;
122:   if (pool->n-pool->used < n) {
123:     pool->guess = PetscMax(p->guess,pool->used+n);
124:     if (pool->vecs && pool->used == 0) {
125:       VecDestroyVecs(pool->n,&pool->vecs);
126:     }
127:     if (pool->vecs) {
128:       SlepcVecPoolCreate(p->v,pool->guess-pool->used,&pool->next);
129:       pool = pool->next;
130:     }
131:     pool->n = pool->guess;
132:     VecDuplicateVecs(p->v,pool->n,&pool->vecs);
133:   }
134:   *vecs = pool->vecs + pool->used;
135:   pool->used += n;
136:   return(0);
137: }

141: /*@C
142:    SlepcVecPoolRestoreVecs - Get back an array of Vec previously returned by
143:    SlepcVecPoolGetVecs().

145:    Collective on VecPool

147:    Input Parameters:
148: +  pool - pool of Vec.
149: .  n - number of vectors.
150: -  vecs - vectors

152:    Level: developer

154: .seealso: SlepcVecPoolGetVecs()
155: @*/
156: PetscErrorCode SlepcVecPoolRestoreVecs(VecPool p,PetscInt n,Vec **vecs)
157: {
159:   VecPool_       *pool = (VecPool_*)p, *pool0 = pool;

162:   while (pool->next) pool = (pool0 = pool)->next;
163:   if (pool->used == 0 && pool0 != pool) {
164:     pool0->guess = pool0->used + pool->guess;
165:     SlepcVecPoolDestroy((VecPool*)&pool);
166:     pool = pool0;
167:     pool->next = NULL;
168:   }
169:   pool->used -= n;
170:   if (pool->used < 0) SETERRQ(PetscObjectComm((PetscObject)pool->v),PETSC_ERR_ARG_OUTOFRANGE,"Unmatched SlepcVecPoolRestoreVecs");
171:   return(0);
172: }
slepc-3.7.4/src/sys/vec/pool.c0000644000175000017500000001143213107004621015463 0ustar jromanjroman/* Implementation of a pool of Vec using VecDuplicateVecs. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcvec.h" I*/ #undef __FUNCT__ #define __FUNCT__ "SlepcVecPoolCreate" /*@C SlepcVecPoolCreate - Create a pool of Vec. Collective on VecPool Input Parameters: + v - template vector. - init_size - first guess of maximum vectors. Output Parameter: . pool - the pool context. Level: developer .seealso: SlepcVecPoolGetVecs(), SlepcVecPoolDestroy() @*/ PetscErrorCode SlepcVecPoolCreate(Vec v,PetscInt init_size,VecPool *p) { PetscErrorCode ierr; VecPool_ *pool; PetscFunctionBegin; PetscValidHeaderSpecific(v,VEC_CLASSID,1); PetscValidLogicalCollectiveInt(v,init_size,2); PetscValidPointer(p,3); if (init_size<0) SETERRQ(PetscObjectComm((PetscObject)v),PETSC_ERR_ARG_WRONG,"init_size should be positive"); ierr = PetscCalloc1(1,&pool);CHKERRQ(ierr); ierr = PetscObjectReference((PetscObject)v);CHKERRQ(ierr); pool->v = v; pool->guess = init_size; *p = pool; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcVecPoolDestroy" /*@C SlepcVecPoolDestroy - Destroy the pool of Vec. Collective on VecPool Input Parameters: . pool - pool of Vec. Level: developer .seealso: SlepcVecPoolGetVecs(), SlepcVecPoolCreate() @*/ PetscErrorCode SlepcVecPoolDestroy(VecPool *p) { PetscErrorCode ierr; VecPool_ *pool = (VecPool_*)*p; PetscFunctionBegin; PetscValidPointer(p,1); ierr = VecDestroy(&pool->v);CHKERRQ(ierr); if (pool->vecs) { ierr = VecDestroyVecs(pool->n,&pool->vecs);CHKERRQ(ierr); } pool->n = 0; pool->used = 0; pool->guess = 0; if (pool->next) { ierr = SlepcVecPoolDestroy((VecPool*)&pool->next);CHKERRQ(ierr); } ierr = PetscFree(pool);CHKERRQ(ierr); *p = NULL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcVecPoolGetVecs" /*@C SlepcVecPoolGetVecs - Get an array of Vec from the pool. Collective on VecPool Input Parameters: + pool - pool of Vec. - n - number of vectors. Output Parameter: . vecs - vectors Level: developer .seealso: SlepcVecPoolRestoreVecs() @*/ PetscErrorCode SlepcVecPoolGetVecs(VecPool p,PetscInt n,Vec **vecs) { PetscErrorCode ierr; VecPool_ *pool = (VecPool_*)p; PetscFunctionBegin; PetscValidPointer(p,1); PetscValidPointer(vecs,3); if (n<0) SETERRQ(PetscObjectComm((PetscObject)pool->v),PETSC_ERR_ARG_OUTOFRANGE,"n should be positive"); while (pool->next) pool = pool->next; if (pool->n-pool->used < n) { pool->guess = PetscMax(p->guess,pool->used+n); if (pool->vecs && pool->used == 0) { ierr = VecDestroyVecs(pool->n,&pool->vecs);CHKERRQ(ierr); } if (pool->vecs) { ierr = SlepcVecPoolCreate(p->v,pool->guess-pool->used,&pool->next);CHKERRQ(ierr); pool = pool->next; } pool->n = pool->guess; ierr = VecDuplicateVecs(p->v,pool->n,&pool->vecs);CHKERRQ(ierr); } *vecs = pool->vecs + pool->used; pool->used += n; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcVecPoolRestoreVecs" /*@C SlepcVecPoolRestoreVecs - Get back an array of Vec previously returned by SlepcVecPoolGetVecs(). Collective on VecPool Input Parameters: + pool - pool of Vec. . n - number of vectors. - vecs - vectors Level: developer .seealso: SlepcVecPoolGetVecs() @*/ PetscErrorCode SlepcVecPoolRestoreVecs(VecPool p,PetscInt n,Vec **vecs) { PetscErrorCode ierr; VecPool_ *pool = (VecPool_*)p, *pool0 = pool; PetscFunctionBegin; while (pool->next) pool = (pool0 = pool)->next; if (pool->used == 0 && pool0 != pool) { pool0->guess = pool0->used + pool->guess; ierr = SlepcVecPoolDestroy((VecPool*)&pool);CHKERRQ(ierr); pool = pool0; pool->next = NULL; } pool->used -= n; if (pool->used < 0) SETERRQ(PetscObjectComm((PetscObject)pool->v),PETSC_ERR_ARG_OUTOFRANGE,"Unmatched SlepcVecPoolRestoreVecs"); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/vec/veccomp.c.html0000644000175000017500000013532413107004621017120 0ustar jromanjroman
Actual source code: veccomp.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/vecimplslepc.h>     /*I "slepcvec.h" I*/

 24: /* Private MPI datatypes and operators */
 25: static MPI_Datatype MPIU_NORM2=0, MPIU_NORM1_AND_2=0;
 26: static MPI_Op MPIU_NORM2_SUM=0;
 27: static PetscBool VecCompInitialized = PETSC_FALSE;

 29: /* Private inline functions */
 30: PETSC_STATIC_INLINE void SumNorm2(PetscReal *,PetscReal *,PetscReal *,PetscReal *);
 31: PETSC_STATIC_INLINE PetscReal GetNorm2(PetscReal,PetscReal);
 32: PETSC_STATIC_INLINE void AddNorm2(PetscReal *,PetscReal *,PetscReal);

 34: #include "veccomp0.h"

 37: #include "veccomp0.h"

 39: PETSC_STATIC_INLINE void SumNorm2(PetscReal *ssq0,PetscReal *scale0,PetscReal *ssq1,PetscReal *scale1)
 40: {
 41:   PetscReal q;
 42:   if (*scale0 > *scale1) {
 43:     q = *scale1/(*scale0);
 44:     *ssq1 = *ssq0 + q*q*(*ssq1);
 45:     *scale1 = *scale0;
 46:   } else {
 47:     q = *scale0/(*scale1);
 48:     *ssq1 += q*q*(*ssq0);
 49:   }
 50: }

 52: PETSC_STATIC_INLINE PetscReal GetNorm2(PetscReal ssq,PetscReal scale)
 53: {
 54:   return scale*PetscSqrtReal(ssq);
 55: }

 57: PETSC_STATIC_INLINE void AddNorm2(PetscReal *ssq,PetscReal *scale,PetscReal x)
 58: {
 59:   PetscReal absx,q;
 60:   if (x != 0.0) {
 61:     absx = PetscAbs(x);
 62:     if (*scale < absx) {
 63:       q = *scale/absx;
 64:       *ssq = 1.0 + *ssq*q*q;
 65:       *scale = absx;
 66:     } else {
 67:       q = absx/(*scale);
 68:       *ssq += q*q;
 69:     }
 70:   }
 71: }

 75: static void SlepcSumNorm2_Local(void *in,void *out,PetscMPIInt *cnt,MPI_Datatype *datatype)
 76: {
 77:   PetscInt i,count = *cnt;

 80:   if (*datatype == MPIU_NORM2) {
 81:     PetscReal *xin = (PetscReal*)in,*xout = (PetscReal*)out;
 82:     for (i=0; i<count; i++) {
 83:       SumNorm2(&xin[i*2],&xin[i*2+1],&xout[i*2],&xout[i*2+1]);
 84:     }
 85:   } else if (*datatype == MPIU_NORM1_AND_2) {
 86:     PetscReal *xin = (PetscReal*)in,*xout = (PetscReal*)out;
 87:     for (i=0; i<count; i++) {
 88:       xout[i*3]+= xin[i*3];
 89:       SumNorm2(&xin[i*3+1],&xin[i*3+2],&xout[i*3+1],&xout[i*3+2]);
 90:     }
 91:   } else {
 92:     (*PetscErrorPrintf)("Can only handle MPIU_NORM* data types");
 93:     MPI_Abort(MPI_COMM_WORLD,1);
 94:   }
 95:   PetscFunctionReturnVoid();
 96: }

100: static PetscErrorCode VecNormCompEnd(void)
101: {

105:   MPI_Type_free(&MPIU_NORM2);
106:   MPI_Type_free(&MPIU_NORM1_AND_2);
107:   MPI_Op_free(&MPIU_NORM2_SUM);
108:   VecCompInitialized = PETSC_FALSE;
109:   return(0);
110: }

114: static PetscErrorCode VecNormCompInit()
115: {

119:   MPI_Type_contiguous(sizeof(PetscReal)*2,MPI_BYTE,&MPIU_NORM2);
120:   MPI_Type_commit(&MPIU_NORM2);
121:   MPI_Type_contiguous(sizeof(PetscReal)*3,MPI_BYTE,&MPIU_NORM1_AND_2);
122:   MPI_Type_commit(&MPIU_NORM1_AND_2);
123:   MPI_Op_create(SlepcSumNorm2_Local,1,&MPIU_NORM2_SUM);
124:   PetscRegisterFinalize(VecNormCompEnd);
125:   return(0);
126: }

130: PetscErrorCode VecDestroy_Comp(Vec v)
131: {
132:   Vec_Comp       *vs = (Vec_Comp*)v->data;
133:   PetscInt       i;

137: #if defined(PETSC_USE_LOG)
138:   PetscLogObjectState((PetscObject)v,"Length=%D",v->map->n);
139: #endif
140:   for (i=0;i<vs->nx;i++) {
141:     VecDestroy(&vs->x[i]);
142:   }
143:   if (--vs->n->friends <= 0) {
144:     PetscFree(vs->n);
145:   }
146:   PetscFree(vs->x);
147:   PetscFree(vs);
148:   return(0);
149: }

151: static struct _VecOps DvOps = {VecDuplicate_Comp, /* 1 */
152:             VecDuplicateVecs_Comp,
153:             VecDestroyVecs_Comp,
154:             VecDot_Comp_MPI,
155:             VecMDot_Comp_MPI,
156:             VecNorm_Comp_MPI,
157:             VecTDot_Comp_MPI,
158:             VecMTDot_Comp_MPI,
159:             VecScale_Comp,
160:             VecCopy_Comp, /* 10 */
161:             VecSet_Comp,
162:             VecSwap_Comp,
163:             VecAXPY_Comp,
164:             VecAXPBY_Comp,
165:             VecMAXPY_Comp,
166:             VecAYPX_Comp,
167:             VecWAXPY_Comp,
168:             VecAXPBYPCZ_Comp,
169:             VecPointwiseMult_Comp,
170:             VecPointwiseDivide_Comp,
171:             0, /* 20 */
172:             0,0,
173:             0 /*VecGetArray_Seq*/,
174:             VecGetSize_Comp,
175:             VecGetLocalSize_Comp,
176:             0/*VecRestoreArray_Seq*/,
177:             VecMax_Comp,
178:             VecMin_Comp,
179:             VecSetRandom_Comp,
180:             0, /* 30 */
181:             0,
182:             VecDestroy_Comp,
183:             VecView_Comp,
184:             0/*VecPlaceArray_Seq*/,
185:             0/*VecReplaceArray_Seq*/,
186:             VecDot_Comp_Seq,
187:             0,
188:             VecNorm_Comp_Seq,
189:             VecMDot_Comp_Seq,
190:             0, /* 40 */
191:             0,
192:             VecReciprocal_Comp,
193:             VecConjugate_Comp,
194:             0,0,
195:             0/*VecResetArray_Seq*/,
196:             0,
197:             VecMaxPointwiseDivide_Comp,
198:             VecPointwiseMax_Comp,
199:             VecPointwiseMaxAbs_Comp,
200:             VecPointwiseMin_Comp,
201:             0,
202:             VecSqrtAbs_Comp,
203:             VecAbs_Comp,
204:             VecExp_Comp,
205:             VecLog_Comp,
206:             0/*VecShift_Comp*/,
207:             0,
208:             0,
209:             0,
210:             VecDotNorm2_Comp_MPI
211:           };

215: PetscErrorCode VecDuplicateVecs_Comp(Vec w,PetscInt m,Vec *V[])
216: {
218:   PetscInt       i;

223:   if (m<=0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"m must be > 0: m = %D",m);
224:   PetscMalloc1(m,V);
225:   for (i=0;i<m;i++) { VecDuplicate(w,*V+i); }
226:   return(0);
227: }

231: PetscErrorCode VecDestroyVecs_Comp(PetscInt m,Vec v[])
232: {
234:   PetscInt       i;

238:   if (m<=0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"m must be > 0: m = %D",m);
239:   for (i=0;i<m;i++) if (v[i]) { VecDestroy(&v[i]); }
240:   PetscFree(v);
241:   return(0);
242: }

246: static PetscErrorCode VecCreate_Comp_Private(Vec v,Vec *x,PetscInt nx,PetscBool x_to_me,Vec_Comp_N *n)
247: {
248:   Vec_Comp       *s;
250:   PetscInt       N=0,lN=0,i,k;

253:   if (!VecCompInitialized) {
254:     VecCompInitialized = PETSC_TRUE;
255:     VecRegister(VECCOMP,VecCreate_Comp);
256:     VecNormCompInit();
257:   }

259:   /* Allocate a new Vec_Comp */
260:   if (v->data) { PetscFree(v->data); }
261:   PetscNewLog(v,&s);
262:   PetscMemcpy(v->ops,&DvOps,sizeof(DvOps));
263:   v->data        = (void*)s;
264:   v->petscnative = PETSC_FALSE;

266:   /* Allocate the array of Vec, if it is needed to be done */
267:   if (x_to_me != PETSC_TRUE) {
268:     PetscMalloc(sizeof(Vec)*nx,&s->x);
269:     PetscMemcpy(s->x,x,sizeof(Vec)*nx);
270:   } else s->x = x;

272:   s->nx = nx;

274:   /* Allocate the shared structure, if it is not given */
275:   if (!n) {
276:     for (i=0;i<nx;i++) {
277:       VecGetSize(x[i],&k);
278:       N+= k;
279:       VecGetLocalSize(x[i],&k);
280:       lN+= k;
281:     }
282:     PetscNewLog(v,&n);
283:     s->n = n;
284:     n->n = nx;
285:     n->N = N;
286:     n->lN = lN;
287:     n->friends = 1;
288:   } else { /* If not, check in the vector in the shared structure */
289:     s->n = n;
290:     s->n->friends++;
291:   }

293:   /* Set the virtual sizes as the real sizes of the vector */
294:   VecSetSizes(v,s->n->lN,s->n->N);

296:   PetscObjectChangeTypeName((PetscObject)v,VECCOMP);
297:   return(0);
298: }

302: PETSC_EXTERN PetscErrorCode VecCreate_Comp(Vec V)
303: {

307:   VecCreate_Comp_Private(V,NULL,0,PETSC_FALSE,NULL);
308:   return(0);
309: }

313: /*@C
314:    VecCreateComp - Creates a new vector containing several subvectors,
315:    each stored separately.

317:    Collective on Vec

319:    Input Parameters:
320: +  comm - communicator for the new Vec
321: .  Nx   - array of (initial) global sizes of child vectors
322: .  n    - number of child vectors
323: .  t    - type of the child vectors
324: -  Vparent - (optional) template vector

326:    Output Parameter:
327: .  V - new vector

329:    Notes:
330:    This is similar to PETSc's VecNest but customized for SLEPc's needs. In particular,
331:    the number of child vectors can be modified dynamically, with VecCompSetSubVecs().

333:    Level: developer

335: .seealso: VecCreateCompWithVecs(), VecCompSetSubVecs()
336: @*/
337: PetscErrorCode VecCreateComp(MPI_Comm comm,PetscInt *Nx,PetscInt n,VecType t,Vec Vparent,Vec *V)
338: {
340:   Vec            *x;
341:   PetscInt       i;

344:   VecCreate(comm,V);
345:   PetscMalloc1(n,&x);
346:   PetscLogObjectMemory((PetscObject)*V,n*sizeof(Vec));
347:   for (i=0;i<n;i++) {
348:     VecCreate(comm,&x[i]);
349:     VecSetSizes(x[i],PETSC_DECIDE,Nx[i]);
350:     VecSetType(x[i],t);
351:   }
352:   VecCreate_Comp_Private(*V,x,n,PETSC_TRUE,Vparent?((Vec_Comp*)Vparent->data)->n:NULL);
353:   return(0);
354: }

358: /*@C
359:    VecCreateCompWithVecs - Creates a new vector containing several subvectors,
360:    each stored separately, from an array of Vecs.

362:    Collective on Vec

364:    Input Parameters:
365: +  x - array of Vecs
366: .  n - number of child vectors
367: -  Vparent - (optional) template vector

369:    Output Parameter:
370: .  V - new vector

372:    Level: developer

374: .seealso: VecCreateComp()
375: @*/
376: PetscErrorCode VecCreateCompWithVecs(Vec *x,PetscInt n,Vec Vparent,Vec *V)
377: {
379:   PetscInt       i;

382:   VecCreate(PetscObjectComm((PetscObject)x[0]),V);
383:   for (i=0;i<n;i++) {
384:     PetscObjectReference((PetscObject)x[i]);
385:   }
386:   VecCreate_Comp_Private(*V,x,n,PETSC_FALSE,Vparent?((Vec_Comp*)Vparent->data)->n:NULL);
387:   return(0);
388: }

392: PetscErrorCode VecDuplicate_Comp(Vec win,Vec *V)
393: {
395:   Vec            *x;
396:   PetscInt       i;
397:   Vec_Comp       *s = (Vec_Comp*)win->data;

400:   SlepcValidVecComp(win);
401:   VecCreate(PetscObjectComm((PetscObject)win),V);
402:   PetscMalloc1(s->nx,&x);
403:   PetscLogObjectMemory((PetscObject)*V,s->nx*sizeof(Vec));
404:   for (i=0;i<s->nx;i++) {
405:     if (s->x[i]) {
406:       VecDuplicate(s->x[i],&x[i]);
407:     } else x[i] = NULL;
408:   }
409:   VecCreate_Comp_Private(*V,x,s->nx,PETSC_TRUE,s->n);
410:   return(0);
411: }

415: /*@C
416:    VecCompGetSubVecs - Returns the entire array of vectors defining a
417:    compound vector.

419:    Collective on Vec

421:    Input Parameter:
422: .  win - compound vector

424:    Output Parameters:
425: +  n - number of child vectors
426: -  x - array of child vectors

428:    Level: developer

430: .seealso: VecCreateComp()
431: @*/
432: PetscErrorCode VecCompGetSubVecs(Vec win,PetscInt *n,const Vec **x)
433: {
434:   Vec_Comp *s = (Vec_Comp*)win->data;

437:   SlepcValidVecComp(win);
438:   if (x) *x = s->x;
439:   if (n) *n = s->nx;
440:   return(0);
441: }

445: /*@C
446:    VecCompSetSubVecs - Resets the number of subvectors defining a compound vector,
447:    of replaces the subvectors.

449:    Collective on Vec

451:    Input Parameters:
452: +  win - compound vector
453: .  n - number of child vectors
454: -  x - array of child vectors

456:    Level: developer

458: .seealso: VecCreateComp()
459: @*/
460: PetscErrorCode VecCompSetSubVecs(Vec win,PetscInt n,Vec *x)
461: {
462:   Vec_Comp       *s = (Vec_Comp*)win->data;

466:   if (x) {
467:     if (n > s->nx) {
468:       PetscFree(s->x);
469:       PetscMalloc(sizeof(Vec)*n,&s->x);
470:     }
471:     PetscMemcpy(s->x,x,sizeof(Vec)*n);
472:     s->nx = n;
473:   }
474:   s->n->n = n;
475:   return(0);
476: }

480: PetscErrorCode VecAXPY_Comp(Vec v,PetscScalar alpha,Vec w)
481: {
483:   Vec_Comp       *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data;
484:   PetscInt       i;

487:   SlepcValidVecComp(v);
488:   SlepcValidVecComp(w);
489:   for (i=0;i<vs->n->n;i++) {
490:     VecAXPY(vs->x[i],alpha,ws->x[i]);
491:   }
492:   return(0);
493: }

497: PetscErrorCode VecAYPX_Comp(Vec v,PetscScalar alpha,Vec w)
498: {
500:   Vec_Comp       *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data;
501:   PetscInt       i;

504:   SlepcValidVecComp(v);
505:   SlepcValidVecComp(w);
506:   for (i=0;i<vs->n->n;i++) {
507:     VecAYPX(vs->x[i],alpha,ws->x[i]);
508:   }
509:   return(0);
510: }

514: PetscErrorCode VecAXPBY_Comp(Vec v,PetscScalar alpha,PetscScalar beta,Vec w)
515: {
517:   Vec_Comp       *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data;
518:   PetscInt       i;

521:   SlepcValidVecComp(v);
522:   SlepcValidVecComp(w);
523:   for (i=0;i<vs->n->n;i++) {
524:     VecAXPBY(vs->x[i],alpha,beta,ws->x[i]);
525:   }
526:   return(0);
527: }

531: PetscErrorCode VecMAXPY_Comp(Vec v,PetscInt n,const PetscScalar *alpha,Vec *w)
532: {
534:   Vec_Comp       *vs = (Vec_Comp*)v->data;
535:   Vec            *wx;
536:   PetscInt       i,j;

539:   SlepcValidVecComp(v);
540:   for (i=0;i<n;i++) SlepcValidVecComp(w[i]);

542:   PetscMalloc(sizeof(Vec)*n,&wx);

544:   for (j=0;j<vs->n->n;j++) {
545:     for (i=0;i<n;i++) wx[i] = ((Vec_Comp*)w[i]->data)->x[j];
546:     VecMAXPY(vs->x[j],n,alpha,wx);
547:   }

549:   PetscFree(wx);
550:   return(0);
551: }

555: PetscErrorCode VecWAXPY_Comp(Vec v,PetscScalar alpha,Vec w,Vec z)
556: {
558:   Vec_Comp       *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data,*zs = (Vec_Comp*)z->data;
559:   PetscInt       i;

562:   SlepcValidVecComp(v);
563:   SlepcValidVecComp(w);
564:   SlepcValidVecComp(z);
565:   for (i=0;i<vs->n->n;i++) {
566:     VecWAXPY(vs->x[i],alpha,ws->x[i],zs->x[i]);
567:   }
568:   return(0);
569: }

573: PetscErrorCode VecAXPBYPCZ_Comp(Vec v,PetscScalar alpha,PetscScalar beta,PetscScalar gamma,Vec w,Vec z)
574: {
575:   PetscErrorCode  ierr;
576:   Vec_Comp        *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data,*zs = (Vec_Comp*)z->data;
577:   PetscInt        i;

580:   SlepcValidVecComp(v);
581:   SlepcValidVecComp(w);
582:   SlepcValidVecComp(z);
583:   for (i=0;i<vs->n->n;i++) {
584:     VecAXPBYPCZ(vs->x[i],alpha,beta,gamma,ws->x[i],zs->x[i]);
585:   }
586:   return(0);
587: }

591: PetscErrorCode VecGetSize_Comp(Vec v,PetscInt *size)
592: {
593:   Vec_Comp *vs = (Vec_Comp*)v->data;

596:   SlepcValidVecComp(v);
598:   *size = vs->n->N;
599:   return(0);
600: }

604: PetscErrorCode VecGetLocalSize_Comp(Vec v,PetscInt *size)
605: {
606:   Vec_Comp *vs = (Vec_Comp*)v->data;

609:   SlepcValidVecComp(v);
611:   *size = vs->n->lN;
612:   return(0);
613: }

617: PetscErrorCode VecMax_Comp(Vec v,PetscInt *idx,PetscReal *z)
618: {
620:   Vec_Comp       *vs = (Vec_Comp*)v->data;
621:   PetscInt       idxp,s=0,s0;
622:   PetscReal      zp,z0;
623:   PetscInt       i;

626:   SlepcValidVecComp(v);
627:   if (!idx && !z) return(0);

629:   if (vs->n->n > 0) {
630:     VecMax(vs->x[0],idx?&idxp:NULL,&zp);
631:   } else {
632:     zp = PETSC_MIN_REAL;
633:     if (idx) idxp = -1;
634:   }
635:   for (i=1;i<vs->n->n;i++) {
636:     VecGetSize(vs->x[i-1],&s0);
637:     s += s0;
638:     VecMax(vs->x[i],idx?&idxp:NULL,&z0);
639:     if (zp < z0) {
640:       if (idx) *idx = s+idxp;
641:       zp = z0;
642:     }
643:   }
644:   if (z) *z = zp;
645:   return(0);
646: }

650: PetscErrorCode VecMin_Comp(Vec v,PetscInt *idx,PetscReal *z)
651: {
653:   Vec_Comp       *vs = (Vec_Comp*)v->data;
654:   PetscInt       idxp,s=0,s0;
655:   PetscReal      zp,z0;
656:   PetscInt       i;

659:   SlepcValidVecComp(v);
660:   if (!idx && !z) return(0);

662:   if (vs->n->n > 0) {
663:     VecMin(vs->x[0],idx?&idxp:NULL,&zp);
664:   } else {
665:     zp = PETSC_MAX_REAL;
666:     if (idx) idxp = -1;
667:   }
668:   for (i=1;i<vs->n->n;i++) {
669:     VecGetSize(vs->x[i-1],&s0);
670:     s += s0;
671:     VecMin(vs->x[i],idx?&idxp:NULL,&z0);
672:     if (zp > z0) {
673:       if (idx) *idx = s+idxp;
674:       zp = z0;
675:     }
676:   }
677:   if (z) *z = zp;
678:   return(0);
679: }

683: PetscErrorCode VecMaxPointwiseDivide_Comp(Vec v,Vec w,PetscReal *m)
684: {
686:   Vec_Comp       *vs = (Vec_Comp*)v->data,*ws = (Vec_Comp*)w->data;
687:   PetscReal      work;
688:   PetscInt       i;

691:   SlepcValidVecComp(v);
692:   SlepcValidVecComp(w);
693:   if (!m || vs->n->n == 0) return(0);
694:   VecMaxPointwiseDivide(vs->x[0],ws->x[0],m);
695:   for (i=1;i<vs->n->n;i++) {
696:     VecMaxPointwiseDivide(vs->x[i],ws->x[i],&work);
697:     *m = PetscMax(*m,work);
698:   }
699:   return(0);
700: }



708: PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v) \
709: { \
710:   PetscErrorCode  ierr; \
711:   Vec_Comp        *vs = (Vec_Comp*)v->data; \
712:   PetscInt        i; \
713: \
715:   SlepcValidVecComp(v); \
716:   for (i=0;i<vs->n->n;i++) { \
717:     __COMPOSE2__(Vec,NAME)(vs->x[i]); \
718:   } \
719:   return(0);\
720: }

724: __FUNC_TEMPLATE1__(Conjugate)

728: __FUNC_TEMPLATE1__(Reciprocal)

732: __FUNC_TEMPLATE1__(SqrtAbs)

736: __FUNC_TEMPLATE1__(Abs)

740: __FUNC_TEMPLATE1__(Exp)

744: __FUNC_TEMPLATE1__(Log)


748: PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v,T0 __a) \
749: { \
750:   PetscErrorCode  ierr; \
751:   Vec_Comp        *vs = (Vec_Comp*)v->data; \
752:   PetscInt        i; \
753: \
755:   SlepcValidVecComp(v); \
756:   for (i=0;i<vs->n->n;i++) { \
757:     __COMPOSE2__(Vec,NAME)(vs->x[i],__a); \
758:   } \
759:   return(0);\
760: }

764: __FUNC_TEMPLATE2__(Set,PetscScalar)

768: __FUNC_TEMPLATE2__(View,PetscViewer)

772: __FUNC_TEMPLATE2__(Scale,PetscScalar)

776: __FUNC_TEMPLATE2__(SetRandom,PetscRandom)

780: __FUNC_TEMPLATE2__(Shift,PetscScalar)


784: PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v,Vec w) \
785: { \
786:   PetscErrorCode  ierr; \
787:   Vec_Comp        *vs = (Vec_Comp*)v->data,\
788:                   *ws = (Vec_Comp*)w->data; \
789:   PetscInt        i; \
790: \
792:   SlepcValidVecComp(v); \
793:   SlepcValidVecComp(w); \
794:   for (i=0;i<vs->n->n;i++) { \
795:     __COMPOSE2__(Vec,NAME)(vs->x[i],ws->x[i]); \
796:   } \
797:   return(0);\
798: }

802: __FUNC_TEMPLATE3__(Copy)

806: __FUNC_TEMPLATE3__(Swap)


810: PetscErrorCode __COMPOSE3__(Vec,NAME,_Comp)(Vec v,Vec w,Vec z) \
811: { \
812:   PetscErrorCode  ierr; \
813:   Vec_Comp        *vs = (Vec_Comp*)v->data, \
814:                   *ws = (Vec_Comp*)w->data, \
815:                   *zs = (Vec_Comp*)z->data; \
816:   PetscInt        i; \
817: \
819:   SlepcValidVecComp(v); \
820:   SlepcValidVecComp(w); \
821:   SlepcValidVecComp(z); \
822:   for (i=0;i<vs->n->n;i++) { \
823:     __COMPOSE2__(Vec,NAME)(vs->x[i],ws->x[i],zs->x[i]); \
824:   } \
825:   return(0);\
826: }

830: __FUNC_TEMPLATE4__(PointwiseMax)

834: __FUNC_TEMPLATE4__(PointwiseMaxAbs)

838: __FUNC_TEMPLATE4__(PointwiseMin)

842: __FUNC_TEMPLATE4__(PointwiseMult)

846: __FUNC_TEMPLATE4__(PointwiseDivide)
slepc-3.7.4/src/sys/classes/0000755000175000017500000000000013107004621015225 5ustar jromanjromanslepc-3.7.4/src/sys/classes/makefile0000644000175000017500000000215613107004621016731 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = SOURCEF = SOURCEH = LIBBASE = libslepcsys MANSEC = sys LOCDIR = src/sys/classes/ DIRS = ds fn st bv rg include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/0000755000175000017500000000000013107004621015633 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/makefile0000644000175000017500000000217713107004621017342 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../../../include/slepc/private/dsimpl.h ../../../../include/slepcds.h DIRS = interface impls examples LOCDIR = src/sys/classes/ds/ MANSEC = DS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/interface/0000755000175000017500000000000013107004621017573 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/interface/makefile0000644000175000017500000000220513107004621021272 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dsbasic.c dsops.c dspriv.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/interface/dspriv.c.html0000644000175000017500000013114313107004621022214 0ustar jromanjroman
Actual source code: dspriv.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private DS routines

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>      /*I "slepcds.h" I*/
 25: #include <slepcblaslapack.h>

 29: PetscErrorCode DSAllocateMat_Private(DS ds,DSMatType m)
 30: {
 31:   size_t         sz;
 32:   PetscInt       n,d;
 33:   PetscBool      ispep;

 37:   PetscObjectTypeCompare((PetscObject)ds,DSPEP,&ispep);
 38:   if (ispep) {
 39:     DSPEPGetDegree(ds,&d);
 40:   }
 41:   if (ispep && (m==DS_MAT_A || m==DS_MAT_B || m==DS_MAT_W || m==DS_MAT_U || m==DS_MAT_X || m==DS_MAT_Y)) n = d*ds->ld;
 42:   else n = ds->ld;
 43:   switch (m) {
 44:     case DS_MAT_T:
 45:       sz = 3*ds->ld*sizeof(PetscScalar);
 46:       break;
 47:     case DS_MAT_D:
 48:       sz = ds->ld*sizeof(PetscScalar);
 49:       break;
 50:     case DS_MAT_X:
 51:       sz = ds->ld*n*sizeof(PetscScalar);
 52:       break;
 53:     case DS_MAT_Y:
 54:       sz = ds->ld*n*sizeof(PetscScalar);
 55:       break;
 56:     default:
 57:       sz = n*n*sizeof(PetscScalar);
 58:   }
 59:   if (ds->mat[m]) {
 60:     PetscFree(ds->mat[m]);
 61:   } else {
 62:     PetscLogObjectMemory((PetscObject)ds,sz);
 63:   }
 64:   PetscMalloc(sz,&ds->mat[m]);
 65:   PetscMemzero(ds->mat[m],sz);
 66:   return(0);
 67: }

 71: PetscErrorCode DSAllocateMatReal_Private(DS ds,DSMatType m)
 72: {
 73:   size_t         sz;

 77:   if (m==DS_MAT_T) sz = 3*ds->ld*sizeof(PetscReal);
 78:   else if (m==DS_MAT_D) sz = ds->ld*sizeof(PetscReal);
 79:   else sz = ds->ld*ds->ld*sizeof(PetscReal);
 80:   if (!ds->rmat[m]) {
 81:     PetscLogObjectMemory((PetscObject)ds,sz);
 82:     PetscMalloc(sz,&ds->rmat[m]);
 83:   }
 84:   PetscMemzero(ds->rmat[m],sz);
 85:   return(0);
 86: }

 90: PetscErrorCode DSAllocateWork_Private(DS ds,PetscInt s,PetscInt r,PetscInt i)
 91: {

 95:   if (s>ds->lwork) {
 96:     PetscFree(ds->work);
 97:     PetscMalloc1(s,&ds->work);
 98:     PetscLogObjectMemory((PetscObject)ds,(s-ds->lwork)*sizeof(PetscScalar));
 99:     ds->lwork = s;
100:   }
101:   if (r>ds->lrwork) {
102:     PetscFree(ds->rwork);
103:     PetscMalloc1(r,&ds->rwork);
104:     PetscLogObjectMemory((PetscObject)ds,(r-ds->lrwork)*sizeof(PetscReal));
105:     ds->lrwork = r;
106:   }
107:   if (i>ds->liwork) {
108:     PetscFree(ds->iwork);
109:     PetscMalloc1(i,&ds->iwork);
110:     PetscLogObjectMemory((PetscObject)ds,(i-ds->liwork)*sizeof(PetscBLASInt));
111:     ds->liwork = i;
112:   }
113:   return(0);
114: }

118: /*@C
119:    DSViewMat - Prints one of the internal DS matrices.

121:    Collective on DS

123:    Input Parameters:
124: +  ds     - the direct solver context
125: .  viewer - visualization context
126: -  m      - matrix to display

128:    Note:
129:    Works only for ascii viewers. Set the viewer in Matlab format if
130:    want to paste into Matlab.

132:    Level: developer

134: .seealso: DSView()
135: @*/
136: PetscErrorCode DSViewMat(DS ds,PetscViewer viewer,DSMatType m)
137: {
138:   PetscErrorCode    ierr;
139:   PetscInt          i,j,rows,cols,d;
140:   PetscScalar       *v;
141:   PetscViewerFormat format;
142:   PetscBool         ispep;
143: #if defined(PETSC_USE_COMPLEX)
144:   PetscBool         allreal = PETSC_TRUE;
145: #endif

148:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
149:   if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS");
150:   PetscViewerGetFormat(viewer,&format);
151:   if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) return(0);
152:   PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
153:   if (ds->state==DS_STATE_TRUNCATED && m>=DS_MAT_Q) rows = ds->t;
154:   else rows = (m==DS_MAT_A && ds->extrarow)? ds->n+1: ds->n;
155:   cols = (ds->m!=0)? ds->m: ds->n;
156:   PetscObjectTypeCompare((PetscObject)ds,DSPEP,&ispep);
157:   if (ispep) {
158:     DSPEPGetDegree(ds,&d);
159:   }
160:   if (ispep && (m==DS_MAT_X || m==DS_MAT_Y)) cols = d*ds->n;
161: #if defined(PETSC_USE_COMPLEX)
162:   /* determine if matrix has all real values */
163:   v = ds->mat[m];
164:   for (i=0;i<rows;i++)
165:     for (j=0;j<cols;j++)
166:       if (PetscImaginaryPart(v[i+j*ds->ld])) { allreal = PETSC_FALSE; break; }
167: #endif
168:   if (format == PETSC_VIEWER_ASCII_MATLAB) {
169:     PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",rows,cols);
170:     PetscViewerASCIIPrintf(viewer,"%s = [\n",DSMatName[m]);
171:   } else {
172:     PetscViewerASCIIPrintf(viewer,"Matrix %s =\n",DSMatName[m]);
173:   }

175:   for (i=0;i<rows;i++) {
176:     v = ds->mat[m]+i;
177:     for (j=0;j<cols;j++) {
178: #if defined(PETSC_USE_COMPLEX)
179:       if (allreal) {
180:         PetscViewerASCIIPrintf(viewer,"%18.16e ",PetscRealPart(*v));
181:       } else {
182:         PetscViewerASCIIPrintf(viewer,"%18.16e%+18.16ei ",PetscRealPart(*v),PetscImaginaryPart(*v));
183:       }
184: #else
185:       PetscViewerASCIIPrintf(viewer,"%18.16e ",*v);
186: #endif
187:       v += ds->ld;
188:     }
189:     PetscViewerASCIIPrintf(viewer,"\n");
190:   }

192:   if (format == PETSC_VIEWER_ASCII_MATLAB) {
193:     PetscViewerASCIIPrintf(viewer,"];\n");
194:   }
195:   PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
196:   PetscViewerFlush(viewer);
197:   return(0);
198: }

202: PetscErrorCode DSSortEigenvalues_Private(DS ds,PetscScalar *wr,PetscScalar *wi,PetscInt *perm,PetscBool isghiep)
203: {
205:   PetscScalar    re,im,wi0;
206:   PetscInt       n,i,j,result,tmp1,tmp2=0,d=1;

209:   n = ds->t;   /* sort only first t pairs if truncated */
210:   /* insertion sort */
211:   i=ds->l+1;
212: #if !defined(PETSC_USE_COMPLEX)
213:   if (wi && wi[perm[i-1]]!=0.0) i++; /* initial value is complex */
214: #else
215:   if (isghiep && PetscImaginaryPart(wr[perm[i-1]])!=0.0) i++;
216: #endif
217:   for (;i<n;i+=d) {
218:     re = wr[perm[i]];
219:     if (wi) im = wi[perm[i]];
220:     else im = 0.0;
221:     tmp1 = perm[i];
222: #if !defined(PETSC_USE_COMPLEX)
223:     if (im!=0.0) { d = 2; tmp2 = perm[i+1]; }
224:     else d = 1;
225: #else
226:     if (isghiep && PetscImaginaryPart(re)!=0.0) { d = 2; tmp2 = perm[i+1]; }
227:     else d = 1;
228: #endif
229:     j = i-1;
230:     if (wi) wi0 = wi[perm[j]];
231:     else wi0 = 0.0;
232:     SlepcSCCompare(ds->sc,re,im,wr[perm[j]],wi0,&result);
233:     while (result<0 && j>=ds->l) {
234:       perm[j+d] = perm[j];
235:       j--;
236: #if !defined(PETSC_USE_COMPLEX)
237:       if (wi && wi[perm[j+1]]!=0)
238: #else
239:       if (isghiep && PetscImaginaryPart(wr[perm[j+1]])!=0)
240: #endif
241:         { perm[j+d] = perm[j]; j--; }

243:       if (j>=ds->l) {
244:         if (wi) wi0 = wi[perm[j]];
245:         else wi0 = 0.0;
246:         SlepcSCCompare(ds->sc,re,im,wr[perm[j]],wi0,&result);
247:       }
248:     }
249:     perm[j+1] = tmp1;
250:     if (d==2) perm[j+2] = tmp2;
251:   }
252:   return(0);
253: }

257: PetscErrorCode DSSortEigenvaluesReal_Private(DS ds,PetscReal *eig,PetscInt *perm)
258: {
260:   PetscScalar    re;
261:   PetscInt       i,j,result,tmp,l,n;

264:   n = ds->t;   /* sort only first t pairs if truncated */
265:   l = ds->l;
266:   /* insertion sort */
267:   for (i=l+1;i<n;i++) {
268:     re = eig[perm[i]];
269:     j = i-1;
270:     SlepcSCCompare(ds->sc,re,0.0,eig[perm[j]],0.0,&result);
271:     while (result<0 && j>=l) {
272:       tmp = perm[j]; perm[j] = perm[j+1]; perm[j+1] = tmp; j--;
273:       if (j>=l) {
274:         SlepcSCCompare(ds->sc,re,0.0,eig[perm[j]],0.0,&result);
275:       }
276:     }
277:   }
278:   return(0);
279: }

283: /*
284:   DSCopyMatrix_Private - Copies the trailing block of a matrix (from
285:   rows/columns l to n).
286: */
287: PetscErrorCode DSCopyMatrix_Private(DS ds,DSMatType dst,DSMatType src)
288: {
290:   PetscInt    j,m,off,ld;
291:   PetscScalar *S,*D;

294:   ld  = ds->ld;
295:   m   = ds->n-ds->l;
296:   off = ds->l+ds->l*ld;
297:   S   = ds->mat[src];
298:   D   = ds->mat[dst];
299:   for (j=0;j<m;j++) {
300:     PetscMemcpy(D+off+j*ld,S+off+j*ld,m*sizeof(PetscScalar));
301:   }
302:   return(0);
303: }

307: PetscErrorCode DSPermuteColumns_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat,PetscInt *perm)
308: {
309:   PetscInt    i,j,k,p,ld;
310:   PetscScalar *Q,rtmp;

313:   ld = ds->ld;
314:   Q  = ds->mat[mat];
315:   for (i=l;i<n;i++) {
316:     p = perm[i];
317:     if (p != i) {
318:       j = i + 1;
319:       while (perm[j] != i) j++;
320:       perm[j] = p; perm[i] = i;
321:       /* swap columns i and j */
322:       for (k=0;k<n;k++) {
323:         rtmp = Q[k+p*ld]; Q[k+p*ld] = Q[k+i*ld]; Q[k+i*ld] = rtmp;
324:       }
325:     }
326:   }
327:   return(0);
328: }

332: PetscErrorCode DSPermuteRows_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat,PetscInt *perm)
333: {
334:   PetscInt    i,j,m=ds->m,k,p,ld;
335:   PetscScalar *Q,rtmp;

338:   if (!m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set");
339:   ld = ds->ld;
340:   Q  = ds->mat[mat];
341:   for (i=l;i<n;i++) {
342:     p = perm[i];
343:     if (p != i) {
344:       j = i + 1;
345:       while (perm[j] != i) j++;
346:       perm[j] = p; perm[i] = i;
347:       /* swap rows i and j */
348:       for (k=0;k<m;k++) {
349:         rtmp = Q[p+k*ld]; Q[p+k*ld] = Q[i+k*ld]; Q[i+k*ld] = rtmp;
350:       }
351:     }
352:   }
353:   return(0);
354: }

358: PetscErrorCode DSPermuteBoth_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat1,DSMatType mat2,PetscInt *perm)
359: {
360:   PetscInt    i,j,m=ds->m,k,p,ld;
361:   PetscScalar *U,*VT,rtmp;

364:   if (!m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set");
365:   ld = ds->ld;
366:   U  = ds->mat[mat1];
367:   VT = ds->mat[mat2];
368:   for (i=l;i<n;i++) {
369:     p = perm[i];
370:     if (p != i) {
371:       j = i + 1;
372:       while (perm[j] != i) j++;
373:       perm[j] = p; perm[i] = i;
374:       /* swap columns i and j of U */
375:       for (k=0;k<n;k++) {
376:         rtmp = U[k+p*ld]; U[k+p*ld] = U[k+i*ld]; U[k+i*ld] = rtmp;
377:       }
378:       /* swap rows i and j of VT */
379:       for (k=0;k<m;k++) {
380:         rtmp = VT[p+k*ld]; VT[p+k*ld] = VT[i+k*ld]; VT[i+k*ld] = rtmp;
381:       }
382:     }
383:   }
384:   return(0);
385: }

389: /*@
390:    DSSetIdentity - Copy the identity (a diagonal matrix with ones) on the
391:    active part of a matrix.

393:    Logically Collective on DS

395:    Input Parameters:
396: +  ds     - the direct solver context
397: -  mat    - the matrix to modify

399:    Level: intermediate
400: @*/
401: PetscErrorCode DSSetIdentity(DS ds,DSMatType mat)
402: {
404:   PetscScalar    *x;
405:   PetscInt       i,ld,n,l;

408:   DSGetDimensions(ds,&n,NULL,&l,NULL,NULL);
409:   DSGetLeadingDimension(ds,&ld);
410:   PetscLogEventBegin(DS_Other,ds,0,0,0);
411:   DSGetArray(ds,mat,&x);
412:   PetscMemzero(&x[ld*l],ld*(n-l)*sizeof(PetscScalar));
413:   for (i=l;i<n;i++) {
414:     x[ld*i+i] = 1.0;
415:   }
416:   DSRestoreArray(ds,mat,&x);
417:   PetscLogEventEnd(DS_Other,ds,0,0,0);
418:   return(0);
419: }

423: /*@C
424:    DSOrthogonalize - Orthogonalize the columns of a matrix.

426:    Logically Collective on DS

428:    Input Parameters:
429: +  ds   - the direct solver context
430: .  mat  - a matrix
431: -  cols - number of columns to orthogonalize (starting from column zero)

433:    Output Parameter:
434: .  lindcols - (optional) number of linearly independent columns of the matrix

436:    Level: developer

438: .seealso: DSPseudoOrthogonalize()
439: @*/
440: PetscErrorCode DSOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscInt *lindcols)
441: {
442: #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR)
444:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routine is unavailable");
445: #else
447:   PetscInt       n,l,ld;
448:   PetscBLASInt   ld_,rA,cA,info,ltau,lw;
449:   PetscScalar    *A,*tau,*w,saux,dummy;

453:   DSCheckAlloc(ds,1);

457:   DSGetDimensions(ds,&n,NULL,&l,NULL,NULL);
458:   DSGetLeadingDimension(ds,&ld);
459:   n = n - l;
460:   if (cols > n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid number of columns");
461:   if (n == 0 || cols == 0) return(0);

463:   PetscLogEventBegin(DS_Other,ds,0,0,0);
464:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
465:   DSGetArray(ds,mat,&A);
466:   PetscBLASIntCast(PetscMin(cols,n),&ltau);
467:   PetscBLASIntCast(ld,&ld_);
468:   PetscBLASIntCast(n,&rA);
469:   PetscBLASIntCast(cols,&cA);
470:   lw = -1;
471:   PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&rA,&cA,A,&ld_,&dummy,&saux,&lw,&info));
472:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);
473:   lw = (PetscBLASInt)PetscRealPart(saux);
474:   DSAllocateWork_Private(ds,lw+ltau,0,0);
475:   tau = ds->work;
476:   w = &tau[ltau];
477:   PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&rA,&cA,&A[ld*l+l],&ld_,tau,w,&lw,&info));
478:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);
479:   PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&rA,&ltau,&ltau,&A[ld*l+l],&ld_,tau,w,&lw,&info));
480:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info);
481:   if (lindcols) *lindcols = ltau;

483:   PetscFPTrapPop();
484:   PetscLogEventEnd(DS_Other,ds,0,0,0);
485:   DSRestoreArray(ds,mat,&A);
486:   PetscObjectStateIncrease((PetscObject)ds);
487:   return(0);
488: #endif
489: }

493: /*
494:   Compute C <- a*A*B + b*C, where
495:     ldC, the leading dimension of C,
496:     ldA, the leading dimension of A,
497:     rA, cA, rows and columns of A,
498:     At, if true use the transpose of A instead,
499:     ldB, the leading dimension of B,
500:     rB, cB, rows and columns of B,
501:     Bt, if true use the transpose of B instead
502: */
503: static PetscErrorCode SlepcMatDenseMult(PetscScalar *C,PetscInt _ldC,PetscScalar b,PetscScalar a,const PetscScalar *A,PetscInt _ldA,PetscInt rA,PetscInt cA,PetscBool At,const PetscScalar *B,PetscInt _ldB,PetscInt rB,PetscInt cB,PetscBool Bt)
504: {
506:   PetscInt       tmp;
507:   PetscBLASInt   m, n, k, ldA = _ldA, ldB = _ldB, ldC = _ldC;
508:   const char     *N = "N", *T = "C", *qA = N, *qB = N;

511:   if ((rA == 0) || (cB == 0)) return(0);

516:   /* Transpose if needed */
517:   if (At) tmp = rA, rA = cA, cA = tmp, qA = T;
518:   if (Bt) tmp = rB, rB = cB, cB = tmp, qB = T;

520:   /* Check size */
521:   if (cA != rB) SETERRQ(PETSC_COMM_SELF,1, "Matrix dimensions do not match");

523:   /* Do stub */
524:   if ((rA == 1) && (cA == 1) && (cB == 1)) {
525:     if (!At && !Bt) *C = *A * *B;
526:     else if (At && !Bt) *C = PetscConj(*A) * *B;
527:     else if (!At && Bt) *C = *A * PetscConj(*B);
528:     else *C = PetscConj(*A) * PetscConj(*B);
529:     m = n = k = 1;
530:   } else {
531:     m = rA; n = cB; k = cA;
532:     PetscStackCallBLAS("BLASgemm",BLASgemm_(qA,qB,&m,&n,&k,&a,(PetscScalar*)A,&ldA,(PetscScalar*)B,&ldB,&b,C,&ldC));
533:   }

535:   PetscLogFlops(m*n*2*k);
536:   return(0);
537: }

541: /*@C
542:    DSPseudoOrthogonalize - Orthogonalize the columns of a matrix with Modified
543:    Gram-Schmidt in an indefinite inner product space defined by a signature.

545:    Logically Collective on DS

547:    Input Parameters:
548: +  ds   - the direct solver context
549: .  mat  - the matrix
550: .  cols - number of columns to orthogonalize (starting from column zero)
551: -  s    - the signature that defines the inner product

553:    Output Parameters:
554: +  lindcols - (optional) linearly independent columns of the matrix
555: -  ns   - (optional) the new norm of the vectors

557:    Level: developer

559: .seealso: DSOrthogonalize()
560: @*/
561: PetscErrorCode DSPseudoOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscReal *s,PetscInt *lindcols,PetscReal *ns)
562: {
564:   PetscInt       i,j,k,l,n,ld;
565:   PetscBLASInt   one=1,rA_;
566:   PetscScalar    alpha,*A,*A_,*m,*h,nr0;
567:   PetscReal      nr_o,nr,*ns_;

571:   DSCheckAlloc(ds,1);
575:   DSGetDimensions(ds,&n,NULL,&l,NULL,NULL);
576:   DSGetLeadingDimension(ds,&ld);
577:   n = n - l;
578:   if (cols > n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid number of columns");
579:   if (n == 0 || cols == 0) return(0);
580:   PetscBLASIntCast(n,&rA_);
581:   DSGetArray(ds,mat,&A_);
582:   A = &A_[ld*l+l];
583:   DSAllocateWork_Private(ds,n+cols,ns?0:cols,0);
584:   m = ds->work;
585:   h = &m[n];
586:   ns_ = ns ? ns : ds->rwork;
587:   PetscLogEventBegin(DS_Other,ds,0,0,0);
588:   for (i=0; i<cols; i++) {
589:     /* m <- diag(s)*A[i] */
590:     for (k=0; k<n; k++) m[k] = s[k]*A[k+i*ld];
591:     /* nr_o <- mynorm(A[i]'*m), mynorm(x) = sign(x)*sqrt(|x|) */
592:     SlepcMatDenseMult(&nr0,1,0.0,1.0,&A[ld*i],ld,n,1,PETSC_TRUE,m,n,n,1,PETSC_FALSE);
593:     nr = nr_o = PetscSign(PetscRealPart(nr0))*PetscSqrtReal(PetscAbsScalar(nr0));
594:     for (j=0; j<3 && i>0; j++) {
595:       /* h <- A[0:i-1]'*m */
596:       SlepcMatDenseMult(h,i,0.0,1.0,A,ld,n,i,PETSC_TRUE,m,n,n,1,PETSC_FALSE);
597:       /* h <- diag(ns)*h */
598:       for (k=0; k<i; k++) h[k] *= ns_[k];
599:       /* A[i] <- A[i] - A[0:i-1]*h */
600:       SlepcMatDenseMult(&A[ld*i],ld,1.0,-1.0,A,ld,n,i,PETSC_FALSE,h,i,i,1,PETSC_FALSE);
601:       /* m <- diag(s)*A[i] */
602:       for (k=0; k<n; k++) m[k] = s[k]*A[k+i*ld];
603:       /* nr_o <- mynorm(A[i]'*m) */
604:       SlepcMatDenseMult(&nr0,1,0.0,1.0,&A[ld*i],ld,n,1,PETSC_TRUE,m,n,n,1,PETSC_FALSE);
605:       nr = PetscSign(PetscRealPart(nr0))*PetscSqrtReal(PetscAbsScalar(nr0));
606:       if (PetscAbs(nr) < PETSC_MACHINE_EPSILON) SETERRQ(PETSC_COMM_SELF,1,"Linear dependency detected");
607:       if (PetscAbs(nr) > 0.7*PetscAbs(nr_o)) break;
608:       nr_o = nr;
609:     }
610:     ns_[i] = PetscSign(nr);
611:     /* A[i] <- A[i]/|nr| */
612:     alpha = 1.0/PetscAbs(nr);
613:     PetscStackCallBLAS("BLASscal",BLASscal_(&rA_,&alpha,&A[i*ld],&one));
614:   }
615:   PetscLogEventEnd(DS_Other,ds,0,0,0);
616:   DSRestoreArray(ds,mat,&A_);
617:   PetscObjectStateIncrease((PetscObject)ds);
618:   if (lindcols) *lindcols = cols;
619:   return(0);
620: }
slepc-3.7.4/src/sys/classes/ds/interface/makefile.html0000644000175000017500000000472413107004621022245 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dsbasic.c dsops.c dspriv.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/interface/dsbasic.c0000644000175000017500000006147313107004621021362 0ustar jromanjroman/* Basic DS routines - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcds.h" I*/ PetscFunctionList DSList = 0; PetscBool DSRegisterAllCalled = PETSC_FALSE; PetscClassId DS_CLASSID = 0; PetscLogEvent DS_Solve = 0,DS_Vectors = 0,DS_Other = 0; static PetscBool DSPackageInitialized = PETSC_FALSE; const char *DSMatName[DS_NUM_MAT] = {"A","B","C","T","D","Q","Z","X","Y","U","VT","W","E0","E1","E2","E3","E4","E5","E6","E7","E8","E9"}; DSMatType DSMatExtra[DS_NUM_EXTRA] = {DS_MAT_E0,DS_MAT_E1,DS_MAT_E2,DS_MAT_E3,DS_MAT_E4,DS_MAT_E5,DS_MAT_E6,DS_MAT_E7,DS_MAT_E8,DS_MAT_E9}; #undef __FUNCT__ #define __FUNCT__ "DSFinalizePackage" /*@C DSFinalizePackage - This function destroys everything in the SLEPc interface to the DS package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode DSFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&DSList);CHKERRQ(ierr); DSPackageInitialized = PETSC_FALSE; DSRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSInitializePackage" /*@C DSInitializePackage - This function initializes everything in the DS package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to DSCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode DSInitializePackage() { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (DSPackageInitialized) PetscFunctionReturn(0); DSPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("Direct Solver",&DS_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = DSRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("DSSolve",DS_CLASSID,&DS_Solve);CHKERRQ(ierr); ierr = PetscLogEventRegister("DSVectors",DS_CLASSID,&DS_Vectors);CHKERRQ(ierr); ierr = PetscLogEventRegister("DSOther",DS_CLASSID,&DS_Other);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"ds",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(DS_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"ds",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(DS_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(DSFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCreate" /*@ DSCreate - Creates a DS context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . newds - location to put the DS context Level: beginner Note: DS objects are not intended for normal users but only for advanced user that for instance implement their own solvers. .seealso: DSDestroy(), DS @*/ PetscErrorCode DSCreate(MPI_Comm comm,DS *newds) { DS ds; PetscInt i; PetscErrorCode ierr; PetscFunctionBegin; PetscValidPointer(newds,2); *newds = 0; ierr = DSInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(ds,DS_CLASSID,"DS","Direct Solver (or Dense System)","DS",comm,DSDestroy,DSView);CHKERRQ(ierr); ds->state = DS_STATE_RAW; ds->method = 0; ds->compact = PETSC_FALSE; ds->refined = PETSC_FALSE; ds->extrarow = PETSC_FALSE; ds->ld = 0; ds->l = 0; ds->n = 0; ds->m = 0; ds->k = 0; ds->t = 0; ds->bs = 1; ds->sc = NULL; for (i=0;imat[i] = NULL; ds->rmat[i] = NULL; ds->omat[i] = NULL; } ds->perm = NULL; ds->data = NULL; ds->work = NULL; ds->rwork = NULL; ds->iwork = NULL; ds->lwork = 0; ds->lrwork = 0; ds->liwork = 0; *newds = ds; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetOptionsPrefix" /*@C DSSetOptionsPrefix - Sets the prefix used for searching for all DS options in the database. Logically Collective on DS Input Parameters: + ds - the direct solver context - prefix - the prefix string to prepend to all DS option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: DSAppendOptionsPrefix() @*/ PetscErrorCode DSSetOptionsPrefix(DS ds,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); ierr = PetscObjectSetOptionsPrefix((PetscObject)ds,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSAppendOptionsPrefix" /*@C DSAppendOptionsPrefix - Appends to the prefix used for searching for all DS options in the database. Logically Collective on DS Input Parameters: + ds - the direct solver context - prefix - the prefix string to prepend to all DS option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: DSSetOptionsPrefix() @*/ PetscErrorCode DSAppendOptionsPrefix(DS ds,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)ds,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetOptionsPrefix" /*@C DSGetOptionsPrefix - Gets the prefix used for searching for all DS options in the database. Not Collective Input Parameters: . ds - the direct solver context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: DSSetOptionsPrefix(), DSAppendOptionsPrefix() @*/ PetscErrorCode DSGetOptionsPrefix(DS ds,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)ds,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetType" /*@C DSSetType - Selects the type for the DS object. Logically Collective on DS Input Parameter: + ds - the direct solver context - type - a known type Level: intermediate .seealso: DSGetType() @*/ PetscErrorCode DSSetType(DS ds,DSType type) { PetscErrorCode ierr,(*r)(DS); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)ds,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(DSList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested DS type %s",type); ierr = PetscMemzero(ds->ops,sizeof(struct _DSOps));CHKERRQ(ierr); ierr = PetscObjectChangeTypeName((PetscObject)ds,type);CHKERRQ(ierr); ierr = (*r)(ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetType" /*@C DSGetType - Gets the DS type name (as a string) from the DS context. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . name - name of the direct solver Level: intermediate .seealso: DSSetType() @*/ PetscErrorCode DSGetType(DS ds,DSType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)ds)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetMethod" /*@ DSSetMethod - Selects the method to be used to solve the problem. Logically Collective on DS Input Parameter: + ds - the direct solver context - meth - an index indentifying the method Level: intermediate .seealso: DSGetMethod() @*/ PetscErrorCode DSSetMethod(DS ds,PetscInt meth) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveInt(ds,meth,2); if (meth<0) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The method must be a non-negative integer"); if (meth>DS_MAX_SOLVE) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Too large value for the method"); ds->method = meth; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetMethod" /*@ DSGetMethod - Gets the method currently used in the DS. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . meth - identifier of the method Level: intermediate .seealso: DSSetMethod() @*/ PetscErrorCode DSGetMethod(DS ds,PetscInt *meth) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(meth,2); *meth = ds->method; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetCompact" /*@ DSSetCompact - Switch to compact storage of matrices. Logically Collective on DS Input Parameter: + ds - the direct solver context - comp - a boolean flag Notes: Compact storage is used in some DS types such as DSHEP when the matrix is tridiagonal. This flag can be used to indicate whether the user provides the matrix entries via the compact form (the tridiagonal DS_MAT_T) or the non-compact one (DS_MAT_A). The default is PETSC_FALSE. Level: advanced .seealso: DSGetCompact() @*/ PetscErrorCode DSSetCompact(DS ds,PetscBool comp) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveBool(ds,comp,2); ds->compact = comp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetCompact" /*@ DSGetCompact - Gets the compact storage flag. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . comp - the flag Level: advanced .seealso: DSSetCompact() @*/ PetscErrorCode DSGetCompact(DS ds,PetscBool *comp) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(comp,2); *comp = ds->compact; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetExtraRow" /*@ DSSetExtraRow - Sets a flag to indicate that the matrix has one extra row. Logically Collective on DS Input Parameter: + ds - the direct solver context - ext - a boolean flag Notes: In Krylov methods it is useful that the matrix representing the direct solver has one extra row, i.e., has dimension (n+1) x n. If this flag is activated, all transformations applied to the right of the matrix also affect this additional row. In that case, (n+1) must be less or equal than the leading dimension. The default is PETSC_FALSE. Level: advanced .seealso: DSSolve(), DSAllocate(), DSGetExtraRow() @*/ PetscErrorCode DSSetExtraRow(DS ds,PetscBool ext) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveBool(ds,ext,2); if (ds->n>0 && ds->n==ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Cannot set extra row after setting n=ld"); ds->extrarow = ext; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetExtraRow" /*@ DSGetExtraRow - Gets the extra row flag. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . ext - the flag Level: advanced .seealso: DSSetExtraRow() @*/ PetscErrorCode DSGetExtraRow(DS ds,PetscBool *ext) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(ext,2); *ext = ds->extrarow; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetRefined" /*@ DSSetRefined - Sets a flag to indicate that refined vectors must be computed. Logically Collective on DS Input Parameter: + ds - the direct solver context - ref - a boolean flag Notes: Normally the vectors returned in DS_MAT_X are eigenvectors of the projected matrix. With this flag activated, DSVectors() will return the right singular vector of the smallest singular value of matrix \tilde{A}-theta*I, where \tilde{A} is the extended (n+1)xn matrix and theta is the Ritz value. This is used in the refined Ritz approximation. The default is PETSC_FALSE. Level: advanced .seealso: DSVectors(), DSGetRefined() @*/ PetscErrorCode DSSetRefined(DS ds,PetscBool ref) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveBool(ds,ref,2); ds->refined = ref; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetRefined" /*@ DSGetRefined - Gets the refined vectors flag. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . ref - the flag Level: advanced .seealso: DSSetRefined() @*/ PetscErrorCode DSGetRefined(DS ds,PetscBool *ref) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(ref,2); *ref = ds->refined; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetBlockSize" /*@ DSSetBlockSize - Sets the block size. Logically Collective on DS Input Parameter: + ds - the direct solver context - bs - the block size Level: intermediate .seealso: DSGetBlockSize() @*/ PetscErrorCode DSSetBlockSize(DS ds,PetscInt bs) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveInt(ds,bs,2); if (bs<1) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The block size must be at least one"); ds->bs = bs; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetBlockSize" /*@ DSGetBlockSize - Gets the block size. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . bs - block size Level: intermediate .seealso: DSSetBlockSize() @*/ PetscErrorCode DSGetBlockSize(DS ds,PetscInt *bs) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(bs,2); *bs = ds->bs; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetSlepcSC" /*@C DSSetSlepcSC - Sets the sorting criterion context. Not Collective Input Parameters: + ds - the direct solver context - sc - a pointer to the sorting criterion context Level: developer .seealso: DSGetSlepcSC(), DSSort() @*/ PetscErrorCode DSSetSlepcSC(DS ds,SlepcSC sc) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(sc,2); if (ds->sc) { ierr = PetscFree(ds->sc);CHKERRQ(ierr); } ds->sc = sc; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetSlepcSC" /*@C DSGetSlepcSC - Gets the sorting criterion context. Not Collective Input Parameter: . ds - the direct solver context Output Parameters: . sc - a pointer to the sorting criterion context Level: developer .seealso: DSSetSlepcSC(), DSSort() @*/ PetscErrorCode DSGetSlepcSC(DS ds,SlepcSC *sc) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(sc,2); if (!ds->sc) { ierr = PetscNewLog(ds,&ds->sc);CHKERRQ(ierr); } *sc = ds->sc; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetFromOptions" /*@ DSSetFromOptions - Sets DS options from the options database. Collective on DS Input Parameters: . ds - the direct solver context Notes: To see all options, run your program with the -help option. Level: beginner @*/ PetscErrorCode DSSetFromOptions(DS ds) { PetscErrorCode ierr; PetscInt bs,meth; PetscBool flag; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); ierr = DSRegisterAll();CHKERRQ(ierr); /* Set default type (we do not allow changing it with -ds_type) */ if (!((PetscObject)ds)->type_name) { ierr = DSSetType(ds,DSNHEP);CHKERRQ(ierr); } ierr = PetscObjectOptionsBegin((PetscObject)ds);CHKERRQ(ierr); ierr = PetscOptionsInt("-ds_block_size","Block size for the dense system solver","DSSetBlockSize",ds->bs,&bs,&flag);CHKERRQ(ierr); if (flag) { ierr = DSSetBlockSize(ds,bs);CHKERRQ(ierr); } ierr = PetscOptionsInt("-ds_method","Method to be used for the dense system","DSSetMethod",ds->method,&meth,&flag);CHKERRQ(ierr); if (flag) { ierr = DSSetMethod(ds,meth);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)ds);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView" /*@C DSView - Prints the DS data structure. Collective on DS Input Parameters: + ds - the direct solver context - viewer - optional visualization context Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner .seealso: DSViewMat() @*/ PetscErrorCode DSView(DS ds,PetscViewer viewer) { PetscBool isascii,issvd; const char *state; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ds)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(ds,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); ierr = PetscObjectPrintClassNamePrefixType((PetscObject)ds,viewer);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) { switch (ds->state) { case DS_STATE_RAW: state = "raw"; break; case DS_STATE_INTERMEDIATE: state = "intermediate"; break; case DS_STATE_CONDENSED: state = "condensed"; break; case DS_STATE_TRUNCATED: state = "truncated"; break; default: SETERRQ(PetscObjectComm((PetscObject)ds),1,"Wrong value of ds->state"); } ierr = PetscViewerASCIIPrintf(viewer," current state: %s\n",state);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)ds,DSSVD,&issvd);CHKERRQ(ierr); if (issvd) { ierr = PetscViewerASCIIPrintf(viewer," dimensions: ld=%D, n=%D, m=%D, l=%D, k=%D",ds->ld,ds->n,ds->m,ds->l,ds->k);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," dimensions: ld=%D, n=%D, l=%D, k=%D",ds->ld,ds->n,ds->l,ds->k);CHKERRQ(ierr); } if (ds->state==DS_STATE_TRUNCATED) { ierr = PetscViewerASCIIPrintf(viewer,", t=%D\n",ds->t);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," flags:%s%s%s\n",ds->compact?" compact":"",ds->extrarow?" extrarow":"",ds->refined?" refined":"");CHKERRQ(ierr); } if (ds->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*ds->ops->view)(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSAllocate" /*@ DSAllocate - Allocates memory for internal storage or matrices in DS. Logically Collective on DS Input Parameters: + ds - the direct solver context - ld - leading dimension (maximum allowed dimension for the matrices, including the extra row if present) Level: intermediate .seealso: DSGetLeadingDimension(), DSSetDimensions(), DSSetExtraRow() @*/ PetscErrorCode DSAllocate(DS ds,PetscInt ld) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveInt(ds,ld,2); if (ld<1) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Leading dimension should be at least one"); ds->ld = ld; ierr = (*ds->ops->allocate)(ds,ld);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSReset" /*@ DSReset - Resets the DS context to the initial state. Collective on DS Input Parameter: . ds - the direct solver context Level: advanced .seealso: DSDestroy() @*/ PetscErrorCode DSReset(DS ds) { PetscInt i; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); ds->state = DS_STATE_RAW; ds->compact = PETSC_FALSE; ds->refined = PETSC_FALSE; ds->extrarow = PETSC_FALSE; ds->ld = 0; ds->l = 0; ds->n = 0; ds->m = 0; ds->k = 0; for (i=0;imat[i]);CHKERRQ(ierr); ierr = PetscFree(ds->rmat[i]);CHKERRQ(ierr); ierr = MatDestroy(&ds->omat[i]);CHKERRQ(ierr); } ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscFree(ds->work);CHKERRQ(ierr); ierr = PetscFree(ds->rwork);CHKERRQ(ierr); ierr = PetscFree(ds->iwork);CHKERRQ(ierr); ds->lwork = 0; ds->lrwork = 0; ds->liwork = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDestroy" /*@ DSDestroy - Destroys DS context that was created with DSCreate(). Collective on DS Input Parameter: . ds - the direct solver context Level: beginner .seealso: DSCreate() @*/ PetscErrorCode DSDestroy(DS *ds) { PetscErrorCode ierr; PetscFunctionBegin; if (!*ds) PetscFunctionReturn(0); PetscValidHeaderSpecific(*ds,DS_CLASSID,1); if (--((PetscObject)(*ds))->refct > 0) { *ds = 0; PetscFunctionReturn(0); } ierr = DSReset(*ds);CHKERRQ(ierr); if ((*ds)->ops->destroy) { ierr = (*(*ds)->ops->destroy)(*ds);CHKERRQ(ierr); } ierr = PetscFree((*ds)->sc);CHKERRQ(ierr); ierr = PetscHeaderDestroy(ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSRegister" /*@C DSRegister - Adds a direct solver to the DS package. Not collective Input Parameters: + name - name of a new user-defined DS - routine_create - routine to create context Notes: DSRegister() may be called multiple times to add several user-defined direct solvers. Level: advanced .seealso: DSRegisterAll() @*/ PetscErrorCode DSRegister(const char *name,PetscErrorCode (*function)(DS)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&DSList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } PETSC_EXTERN PetscErrorCode DSCreate_HEP(DS); PETSC_EXTERN PetscErrorCode DSCreate_NHEP(DS); PETSC_EXTERN PetscErrorCode DSCreate_GHEP(DS); PETSC_EXTERN PetscErrorCode DSCreate_GHIEP(DS); PETSC_EXTERN PetscErrorCode DSCreate_GNHEP(DS); PETSC_EXTERN PetscErrorCode DSCreate_SVD(DS); PETSC_EXTERN PetscErrorCode DSCreate_PEP(DS); PETSC_EXTERN PetscErrorCode DSCreate_NEP(DS); #undef __FUNCT__ #define __FUNCT__ "DSRegisterAll" /*@C DSRegisterAll - Registers all of the direct solvers in the DS package. Not Collective Level: advanced @*/ PetscErrorCode DSRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (DSRegisterAllCalled) PetscFunctionReturn(0); DSRegisterAllCalled = PETSC_TRUE; ierr = DSRegister(DSHEP,DSCreate_HEP);CHKERRQ(ierr); ierr = DSRegister(DSNHEP,DSCreate_NHEP);CHKERRQ(ierr); ierr = DSRegister(DSGHEP,DSCreate_GHEP);CHKERRQ(ierr); ierr = DSRegister(DSGHIEP,DSCreate_GHIEP);CHKERRQ(ierr); ierr = DSRegister(DSGNHEP,DSCreate_GNHEP);CHKERRQ(ierr); ierr = DSRegister(DSSVD,DSCreate_SVD);CHKERRQ(ierr); ierr = DSRegister(DSPEP,DSCreate_PEP);CHKERRQ(ierr); ierr = DSRegister(DSNEP,DSCreate_NEP);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/interface/dspriv.c0000644000175000017500000004736513107004621021265 0ustar jromanjroman/* Private DS routines - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcds.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "DSAllocateMat_Private" PetscErrorCode DSAllocateMat_Private(DS ds,DSMatType m) { size_t sz; PetscInt n,d; PetscBool ispep; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)ds,DSPEP,&ispep);CHKERRQ(ierr); if (ispep) { ierr = DSPEPGetDegree(ds,&d);CHKERRQ(ierr); } if (ispep && (m==DS_MAT_A || m==DS_MAT_B || m==DS_MAT_W || m==DS_MAT_U || m==DS_MAT_X || m==DS_MAT_Y)) n = d*ds->ld; else n = ds->ld; switch (m) { case DS_MAT_T: sz = 3*ds->ld*sizeof(PetscScalar); break; case DS_MAT_D: sz = ds->ld*sizeof(PetscScalar); break; case DS_MAT_X: sz = ds->ld*n*sizeof(PetscScalar); break; case DS_MAT_Y: sz = ds->ld*n*sizeof(PetscScalar); break; default: sz = n*n*sizeof(PetscScalar); } if (ds->mat[m]) { ierr = PetscFree(ds->mat[m]);CHKERRQ(ierr); } else { ierr = PetscLogObjectMemory((PetscObject)ds,sz);CHKERRQ(ierr); } ierr = PetscMalloc(sz,&ds->mat[m]);CHKERRQ(ierr); ierr = PetscMemzero(ds->mat[m],sz);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSAllocateMatReal_Private" PetscErrorCode DSAllocateMatReal_Private(DS ds,DSMatType m) { size_t sz; PetscErrorCode ierr; PetscFunctionBegin; if (m==DS_MAT_T) sz = 3*ds->ld*sizeof(PetscReal); else if (m==DS_MAT_D) sz = ds->ld*sizeof(PetscReal); else sz = ds->ld*ds->ld*sizeof(PetscReal); if (!ds->rmat[m]) { ierr = PetscLogObjectMemory((PetscObject)ds,sz);CHKERRQ(ierr); ierr = PetscMalloc(sz,&ds->rmat[m]);CHKERRQ(ierr); } ierr = PetscMemzero(ds->rmat[m],sz);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSAllocateWork_Private" PetscErrorCode DSAllocateWork_Private(DS ds,PetscInt s,PetscInt r,PetscInt i) { PetscErrorCode ierr; PetscFunctionBegin; if (s>ds->lwork) { ierr = PetscFree(ds->work);CHKERRQ(ierr); ierr = PetscMalloc1(s,&ds->work);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,(s-ds->lwork)*sizeof(PetscScalar));CHKERRQ(ierr); ds->lwork = s; } if (r>ds->lrwork) { ierr = PetscFree(ds->rwork);CHKERRQ(ierr); ierr = PetscMalloc1(r,&ds->rwork);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,(r-ds->lrwork)*sizeof(PetscReal));CHKERRQ(ierr); ds->lrwork = r; } if (i>ds->liwork) { ierr = PetscFree(ds->iwork);CHKERRQ(ierr); ierr = PetscMalloc1(i,&ds->iwork);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,(i-ds->liwork)*sizeof(PetscBLASInt));CHKERRQ(ierr); ds->liwork = i; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSViewMat" /*@C DSViewMat - Prints one of the internal DS matrices. Collective on DS Input Parameters: + ds - the direct solver context . viewer - visualization context - m - matrix to display Note: Works only for ascii viewers. Set the viewer in Matlab format if want to paste into Matlab. Level: developer .seealso: DSView() @*/ PetscErrorCode DSViewMat(DS ds,PetscViewer viewer,DSMatType m) { PetscErrorCode ierr; PetscInt i,j,rows,cols,d; PetscScalar *v; PetscViewerFormat format; PetscBool ispep; #if defined(PETSC_USE_COMPLEX) PetscBool allreal = PETSC_TRUE; #endif PetscFunctionBegin; if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS"); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) PetscFunctionReturn(0); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); if (ds->state==DS_STATE_TRUNCATED && m>=DS_MAT_Q) rows = ds->t; else rows = (m==DS_MAT_A && ds->extrarow)? ds->n+1: ds->n; cols = (ds->m!=0)? ds->m: ds->n; ierr = PetscObjectTypeCompare((PetscObject)ds,DSPEP,&ispep);CHKERRQ(ierr); if (ispep) { ierr = DSPEPGetDegree(ds,&d);CHKERRQ(ierr); } if (ispep && (m==DS_MAT_X || m==DS_MAT_Y)) cols = d*ds->n; #if defined(PETSC_USE_COMPLEX) /* determine if matrix has all real values */ v = ds->mat[m]; for (i=0;ild])) { allreal = PETSC_FALSE; break; } #endif if (format == PETSC_VIEWER_ASCII_MATLAB) { ierr = PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",rows,cols);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s = [\n",DSMatName[m]);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"Matrix %s =\n",DSMatName[m]);CHKERRQ(ierr); } for (i=0;imat[m]+i; for (j=0;jld; } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } if (format == PETSC_VIEWER_ASCII_MATLAB) { ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerFlush(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSortEigenvalues_Private" PetscErrorCode DSSortEigenvalues_Private(DS ds,PetscScalar *wr,PetscScalar *wi,PetscInt *perm,PetscBool isghiep) { PetscErrorCode ierr; PetscScalar re,im,wi0; PetscInt n,i,j,result,tmp1,tmp2=0,d=1; PetscFunctionBegin; n = ds->t; /* sort only first t pairs if truncated */ /* insertion sort */ i=ds->l+1; #if !defined(PETSC_USE_COMPLEX) if (wi && wi[perm[i-1]]!=0.0) i++; /* initial value is complex */ #else if (isghiep && PetscImaginaryPart(wr[perm[i-1]])!=0.0) i++; #endif for (;isc,re,im,wr[perm[j]],wi0,&result);CHKERRQ(ierr); while (result<0 && j>=ds->l) { perm[j+d] = perm[j]; j--; #if !defined(PETSC_USE_COMPLEX) if (wi && wi[perm[j+1]]!=0) #else if (isghiep && PetscImaginaryPart(wr[perm[j+1]])!=0) #endif { perm[j+d] = perm[j]; j--; } if (j>=ds->l) { if (wi) wi0 = wi[perm[j]]; else wi0 = 0.0; ierr = SlepcSCCompare(ds->sc,re,im,wr[perm[j]],wi0,&result);CHKERRQ(ierr); } } perm[j+1] = tmp1; if (d==2) perm[j+2] = tmp2; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSortEigenvaluesReal_Private" PetscErrorCode DSSortEigenvaluesReal_Private(DS ds,PetscReal *eig,PetscInt *perm) { PetscErrorCode ierr; PetscScalar re; PetscInt i,j,result,tmp,l,n; PetscFunctionBegin; n = ds->t; /* sort only first t pairs if truncated */ l = ds->l; /* insertion sort */ for (i=l+1;isc,re,0.0,eig[perm[j]],0.0,&result);CHKERRQ(ierr); while (result<0 && j>=l) { tmp = perm[j]; perm[j] = perm[j+1]; perm[j+1] = tmp; j--; if (j>=l) { ierr = SlepcSCCompare(ds->sc,re,0.0,eig[perm[j]],0.0,&result);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCopyMatrix_Private" /* DSCopyMatrix_Private - Copies the trailing block of a matrix (from rows/columns l to n). */ PetscErrorCode DSCopyMatrix_Private(DS ds,DSMatType dst,DSMatType src) { PetscErrorCode ierr; PetscInt j,m,off,ld; PetscScalar *S,*D; PetscFunctionBegin; ld = ds->ld; m = ds->n-ds->l; off = ds->l+ds->l*ld; S = ds->mat[src]; D = ds->mat[dst]; for (j=0;jld; Q = ds->mat[mat]; for (i=l;im,k,p,ld; PetscScalar *Q,rtmp; PetscFunctionBegin; if (!m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set"); ld = ds->ld; Q = ds->mat[mat]; for (i=l;im,k,p,ld; PetscScalar *U,*VT,rtmp; PetscFunctionBegin; if (!m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set"); ld = ds->ld; U = ds->mat[mat1]; VT = ds->mat[mat2]; for (i=l;i n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid number of columns"); if (n == 0 || cols == 0) PetscFunctionReturn(0); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&A);CHKERRQ(ierr); ierr = PetscBLASIntCast(PetscMin(cols,n),<au);CHKERRQ(ierr); ierr = PetscBLASIntCast(ld,&ld_);CHKERRQ(ierr); ierr = PetscBLASIntCast(n,&rA);CHKERRQ(ierr); ierr = PetscBLASIntCast(cols,&cA);CHKERRQ(ierr); lw = -1; PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&rA,&cA,A,&ld_,&dummy,&saux,&lw,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info); lw = (PetscBLASInt)PetscRealPart(saux); ierr = DSAllocateWork_Private(ds,lw+ltau,0,0);CHKERRQ(ierr); tau = ds->work; w = &tau[ltau]; PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&rA,&cA,&A[ld*l+l],&ld_,tau,w,&lw,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info); PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&rA,<au,<au,&A[ld*l+l],&ld_,tau,w,&lw,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info); if (lindcols) *lindcols = ltau; ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = DSRestoreArray(ds,mat,&A);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "SlepcMatDenseMult" /* Compute C <- a*A*B + b*C, where ldC, the leading dimension of C, ldA, the leading dimension of A, rA, cA, rows and columns of A, At, if true use the transpose of A instead, ldB, the leading dimension of B, rB, cB, rows and columns of B, Bt, if true use the transpose of B instead */ static PetscErrorCode SlepcMatDenseMult(PetscScalar *C,PetscInt _ldC,PetscScalar b,PetscScalar a,const PetscScalar *A,PetscInt _ldA,PetscInt rA,PetscInt cA,PetscBool At,const PetscScalar *B,PetscInt _ldB,PetscInt rB,PetscInt cB,PetscBool Bt) { PetscErrorCode ierr; PetscInt tmp; PetscBLASInt m, n, k, ldA = _ldA, ldB = _ldB, ldC = _ldC; const char *N = "N", *T = "C", *qA = N, *qB = N; PetscFunctionBegin; if ((rA == 0) || (cB == 0)) PetscFunctionReturn(0); PetscValidScalarPointer(C,1); PetscValidScalarPointer(A,5); PetscValidScalarPointer(B,10); /* Transpose if needed */ if (At) tmp = rA, rA = cA, cA = tmp, qA = T; if (Bt) tmp = rB, rB = cB, cB = tmp, qB = T; /* Check size */ if (cA != rB) SETERRQ(PETSC_COMM_SELF,1, "Matrix dimensions do not match"); /* Do stub */ if ((rA == 1) && (cA == 1) && (cB == 1)) { if (!At && !Bt) *C = *A * *B; else if (At && !Bt) *C = PetscConj(*A) * *B; else if (!At && Bt) *C = *A * PetscConj(*B); else *C = PetscConj(*A) * PetscConj(*B); m = n = k = 1; } else { m = rA; n = cB; k = cA; PetscStackCallBLAS("BLASgemm",BLASgemm_(qA,qB,&m,&n,&k,&a,(PetscScalar*)A,&ldA,(PetscScalar*)B,&ldB,&b,C,&ldC)); } ierr = PetscLogFlops(m*n*2*k);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSPseudoOrthogonalize" /*@C DSPseudoOrthogonalize - Orthogonalize the columns of a matrix with Modified Gram-Schmidt in an indefinite inner product space defined by a signature. Logically Collective on DS Input Parameters: + ds - the direct solver context . mat - the matrix . cols - number of columns to orthogonalize (starting from column zero) - s - the signature that defines the inner product Output Parameters: + lindcols - (optional) linearly independent columns of the matrix - ns - (optional) the new norm of the vectors Level: developer .seealso: DSOrthogonalize() @*/ PetscErrorCode DSPseudoOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscReal *s,PetscInt *lindcols,PetscReal *ns) { PetscErrorCode ierr; PetscInt i,j,k,l,n,ld; PetscBLASInt one=1,rA_; PetscScalar alpha,*A,*A_,*m,*h,nr0; PetscReal nr_o,nr,*ns_; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidLogicalCollectiveEnum(ds,mat,2); PetscValidLogicalCollectiveInt(ds,cols,3); PetscValidRealPointer(s,4); ierr = DSGetDimensions(ds,&n,NULL,&l,NULL,NULL);CHKERRQ(ierr); ierr = DSGetLeadingDimension(ds,&ld);CHKERRQ(ierr); n = n - l; if (cols > n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid number of columns"); if (n == 0 || cols == 0) PetscFunctionReturn(0); ierr = PetscBLASIntCast(n,&rA_);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&A_);CHKERRQ(ierr); A = &A_[ld*l+l]; ierr = DSAllocateWork_Private(ds,n+cols,ns?0:cols,0);CHKERRQ(ierr); m = ds->work; h = &m[n]; ns_ = ns ? ns : ds->rwork; ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); for (i=0; i0; j++) { /* h <- A[0:i-1]'*m */ ierr = SlepcMatDenseMult(h,i,0.0,1.0,A,ld,n,i,PETSC_TRUE,m,n,n,1,PETSC_FALSE);CHKERRQ(ierr); /* h <- diag(ns)*h */ for (k=0; k 0.7*PetscAbs(nr_o)) break; nr_o = nr; } ns_[i] = PetscSign(nr); /* A[i] <- A[i]/|nr| */ alpha = 1.0/PetscAbs(nr); PetscStackCallBLAS("BLASscal",BLASscal_(&rA_,&alpha,&A[i*ld],&one)); } ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = DSRestoreArray(ds,mat,&A_);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); if (lindcols) *lindcols = cols; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/interface/dsops.c.html0000644000175000017500000021472313107004621022043 0ustar jromanjroman
Actual source code: dsops.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    DS operations: DSSolve(), DSVectors(), etc

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>      /*I "slepcds.h" I*/

 28: /*@
 29:    DSGetLeadingDimension - Returns the leading dimension of the allocated
 30:    matrices.

 32:    Not Collective

 34:    Input Parameter:
 35: .  ds - the direct solver context

 37:    Output Parameter:
 38: .  ld - leading dimension (maximum allowed dimension for the matrices)

 40:    Level: advanced

 42: .seealso: DSAllocate(), DSSetDimensions()
 43: @*/
 44: PetscErrorCode DSGetLeadingDimension(DS ds,PetscInt *ld)
 45: {
 49:   *ld = ds->ld;
 50:   return(0);
 51: }

 55: /*@
 56:    DSSetState - Change the state of the DS object.

 58:    Logically Collective on DS

 60:    Input Parameters:
 61: +  ds    - the direct solver context
 62: -  state - the new state

 64:    Notes:
 65:    The state indicates that the dense system is in an initial state (raw),
 66:    in an intermediate state (such as tridiagonal, Hessenberg or
 67:    Hessenberg-triangular), in a condensed state (such as diagonal, Schur or
 68:    generalized Schur), or in a truncated state.

 70:    This function is normally used to return to the raw state when the
 71:    condensed structure is destroyed.

 73:    Level: advanced

 75: .seealso: DSGetState()
 76: @*/
 77: PetscErrorCode DSSetState(DS ds,DSStateType state)
 78: {

 84:   switch (state) {
 85:     case DS_STATE_RAW:
 86:     case DS_STATE_INTERMEDIATE:
 87:     case DS_STATE_CONDENSED:
 88:     case DS_STATE_TRUNCATED:
 89:       if (ds->state<state) { PetscInfo(ds,"DS state has been increased\n"); }
 90:       ds->state = state;
 91:       break;
 92:     default:
 93:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Wrong state");
 94:   }
 95:   return(0);
 96: }

100: /*@
101:    DSGetState - Returns the current state.

103:    Not Collective

105:    Input Parameter:
106: .  ds - the direct solver context

108:    Output Parameter:
109: .  state - current state

111:    Level: advanced

113: .seealso: DSSetState()
114: @*/
115: PetscErrorCode DSGetState(DS ds,DSStateType *state)
116: {
120:   *state = ds->state;
121:   return(0);
122: }

126: /*@
127:    DSSetDimensions - Resize the matrices in the DS object.

129:    Logically Collective on DS

131:    Input Parameters:
132: +  ds - the direct solver context
133: .  n  - the new size
134: .  m  - the new column size (only for DSSVD)
135: .  l  - number of locked (inactive) leading columns
136: -  k  - intermediate dimension (e.g., position of arrow)

138:    Notes:
139:    The internal arrays are not reallocated.

141:    The value m is not used except in the case of DSSVD, pass 0 otherwise.

143:    Level: intermediate

145: .seealso: DSGetDimensions(), DSAllocate()
146: @*/
147: PetscErrorCode DSSetDimensions(DS ds,PetscInt n,PetscInt m,PetscInt l,PetscInt k)
148: {
151:   DSCheckAlloc(ds,1);
156:   if (n==PETSC_DECIDE || n==PETSC_DEFAULT) {
157:     ds->n = ds->ld;
158:   } else {
159:     if (n<0 || n>ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of n. Must be between 0 and ld");
160:     if (ds->extrarow && n+1>ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"A value of n equal to ld leaves no room for extra row");
161:     ds->n = n;
162:   }
163:   ds->t = ds->n;   /* truncated length equal to the new dimension */
164:   if (m) {
165:     if (m==PETSC_DECIDE || m==PETSC_DEFAULT) {
166:       ds->m = ds->ld;
167:     } else {
168:       if (m<0 || m>ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of m. Must be between 0 and ld");
169:       ds->m = m;
170:     }
171:   }
172:   if (l==PETSC_DECIDE || l==PETSC_DEFAULT) {
173:     ds->l = 0;
174:   } else {
175:     if (l<0 || l>ds->n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of l. Must be between 0 and n");
176:     ds->l = l;
177:   }
178:   if (k==PETSC_DECIDE || k==PETSC_DEFAULT) {
179:     ds->k = ds->n/2;
180:   } else {
181:     if (k<0 || k>ds->n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of k. Must be between 0 and n");
182:     ds->k = k;
183:   }
184:   return(0);
185: }

189: /*@
190:    DSGetDimensions - Returns the current dimensions.

192:    Not Collective

194:    Input Parameter:
195: .  ds - the direct solver context

197:    Output Parameter:
198: +  n  - the current size
199: .  m  - the current column size (only for DSSVD)
200: .  l  - number of locked (inactive) leading columns
201: .  k  - intermediate dimension (e.g., position of arrow)
202: -  t  - truncated length

204:    Level: intermediate

206:    Note:
207:    The t parameter makes sense only if DSTruncate() has been called.
208:    Otherwise its value equals n.

210: .seealso: DSSetDimensions(), DSTruncate()
211: @*/
212: PetscErrorCode DSGetDimensions(DS ds,PetscInt *n,PetscInt *m,PetscInt *l,PetscInt *k,PetscInt *t)
213: {
216:   DSCheckAlloc(ds,1);
217:   if (n) *n = ds->n;
218:   if (m) *m = ds->m;
219:   if (l) *l = ds->l;
220:   if (k) *k = ds->k;
221:   if (t) *t = ds->t;
222:   return(0);
223: }

227: /*@
228:    DSTruncate - Truncates the system represented in the DS object.

230:    Logically Collective on DS

232:    Input Parameters:
233: +  ds - the direct solver context
234: -  n  - the new size

236:    Note:
237:    The new size is set to n. In cases where the extra row is meaningful,
238:    the first n elements are kept as the extra row for the new system.

240:    Level: advanced

242: .seealso: DSSetDimensions(), DSSetExtraRow(), DSStateType
243: @*/
244: PetscErrorCode DSTruncate(DS ds,PetscInt n)
245: {

250:   DSCheckAlloc(ds,1);
251:   DSCheckSolved(ds,1);
253:   if (!ds->ops->truncate) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
254:   if (n<ds->l || n>ds->n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of n. Must be between l and n");
255:   PetscLogEventBegin(DS_Other,ds,0,0,0);
256:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
257:   (*ds->ops->truncate)(ds,n);
258:   PetscFPTrapPop();
259:   PetscLogEventEnd(DS_Other,ds,0,0,0);
260:   ds->state = DS_STATE_TRUNCATED;
261:   PetscObjectStateIncrease((PetscObject)ds);
262:   return(0);
263: }

267: /*@
268:    DSGetMat - Returns a sequential dense Mat object containing the requested
269:    matrix. 

271:    Not Collective

273:    Input Parameters:
274: +  ds - the direct solver context
275: -  m  - the requested matrix

277:    Output Parameter:
278: .  A  - Mat object

280:    Notes:
281:    The Mat is created with sizes equal to the current DS dimensions (nxm),
282:    then it is filled with the values that would be obtained with DSGetArray()
283:    (not DSGetArrayReal()). If the DS was truncated, then the number of rows
284:    is equal to the dimension prior to truncation, see DSTruncate().
285:    The communicator is always PETSC_COMM_SELF.

287:    When no longer needed, the user can either destroy the matrix or call
288:    DSRestoreMat(). The latter will copy back the modified values.

290:    Level: advanced

292: .seealso: DSRestoreMat(), DSSetDimensions(), DSGetArray(), DSGetArrayReal(), DSTruncate()
293: @*/
294: PetscErrorCode DSGetMat(DS ds,DSMatType m,Mat *A)
295: {
297:   PetscInt       j,rows,cols,arows,acols;
298:   PetscBool      create=PETSC_FALSE;
299:   PetscScalar    *pA,*M;

303:   DSCheckAlloc(ds,1);
306:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
307:   if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS");

309:   rows = PetscMax(ds->n,ds->t);
310:   cols = ds->m? ds->m: ds->n;
311:   if (!ds->omat[m]) create=PETSC_TRUE;
312:   else {
313:     MatGetSize(ds->omat[m],&arows,&acols);
314:     if (arows!=rows || acols!=cols) {
315:       MatDestroy(&ds->omat[m]);
316:       create=PETSC_TRUE;
317:     }
318:   }
319:   if (create) {
320:     MatCreateSeqDense(PETSC_COMM_SELF,rows,cols,NULL,&ds->omat[m]);
321:   }
322:   PetscObjectReference((PetscObject)ds->omat[m]);
323:   *A = ds->omat[m];
324:   M  = ds->mat[m];
325:   MatDenseGetArray(*A,&pA);
326:   for (j=0;j<cols;j++) {
327:     PetscMemcpy(pA+j*rows,M+j*ds->ld,rows*sizeof(PetscScalar));
328:   }
329:   MatDenseRestoreArray(*A,&pA);
330:   return(0);
331: }

335: /*@
336:    DSRestoreMat - Restores the matrix after DSGetMat() was called.

338:    Not Collective

340:    Input Parameters:
341: +  ds - the direct solver context
342: .  m  - the requested matrix
343: -  A  - the fetched Mat object

345:    Notes:
346:    A call to this function must match a previous call of DSGetMat().
347:    The effect is that the contents of the Mat are copied back to the
348:    DS internal array, and the matrix is destroyed.

350:    It is not compulsory to call this function, the matrix obtained with
351:    DSGetMat() can simply be destroyed if entries need not be copied back.

353:    Level: advanced

355: .seealso: DSGetMat(), DSRestoreArray(), DSRestoreArrayReal()
356: @*/
357: PetscErrorCode DSRestoreMat(DS ds,DSMatType m,Mat *A)
358: {
360:   PetscInt       j,rows,cols;
361:   PetscScalar    *pA,*M;

365:   DSCheckAlloc(ds,1);
368:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
369:   if (!ds->omat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"DSRestoreMat must match a previous call to DSGetMat");
370:   if (ds->omat[m]!=*A) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Mat argument is not the same as the one obtained with DSGetMat");

372:   MatGetSize(*A,&rows,&cols);
373:   M  = ds->mat[m];
374:   MatDenseGetArray(*A,&pA);
375:   for (j=0;j<cols;j++) {
376:     PetscMemcpy(M+j*ds->ld,pA+j*rows,rows*sizeof(PetscScalar));
377:   }
378:   MatDenseRestoreArray(*A,&pA);
379:   MatDestroy(A);
380:   return(0);
381: }

385: /*@C
386:    DSGetArray - Returns a pointer to one of the internal arrays used to
387:    represent matrices. You MUST call DSRestoreArray() when you no longer
388:    need to access the array.

390:    Not Collective

392:    Input Parameters:
393: +  ds - the direct solver context
394: -  m  - the requested matrix

396:    Output Parameter:
397: .  a  - pointer to the values

399:    Level: advanced

401: .seealso: DSRestoreArray(), DSGetArrayReal()
402: @*/
403: PetscErrorCode DSGetArray(DS ds,DSMatType m,PetscScalar *a[])
404: {
407:   DSCheckAlloc(ds,1);
409:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
410:   if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS");
411:   *a = ds->mat[m];
412:   CHKMEMQ;
413:   return(0);
414: }

418: /*@C
419:    DSRestoreArray - Restores the matrix after DSGetArray() was called.

421:    Not Collective

423:    Input Parameters:
424: +  ds - the direct solver context
425: .  m  - the requested matrix
426: -  a  - pointer to the values

428:    Level: advanced

430: .seealso: DSGetArray(), DSGetArrayReal()
431: @*/
432: PetscErrorCode DSRestoreArray(DS ds,DSMatType m,PetscScalar *a[])
433: {

438:   DSCheckAlloc(ds,1);
440:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
441:   CHKMEMQ;
442:   *a = 0;
443:   PetscObjectStateIncrease((PetscObject)ds);
444:   return(0);
445: }

449: /*@C
450:    DSGetArrayReal - Returns a pointer to one of the internal arrays used to
451:    represent real matrices. You MUST call DSRestoreArrayReal() when you no longer
452:    need to access the array.

454:    Not Collective

456:    Input Parameters:
457: +  ds - the direct solver context
458: -  m  - the requested matrix

460:    Output Parameter:
461: .  a  - pointer to the values

463:    Level: advanced

465: .seealso: DSRestoreArrayReal(), DSGetArray()
466: @*/
467: PetscErrorCode DSGetArrayReal(DS ds,DSMatType m,PetscReal *a[])
468: {
471:   DSCheckAlloc(ds,1);
473:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
474:   if (!ds->rmat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS");
475:   *a = ds->rmat[m];
476:   CHKMEMQ;
477:   return(0);
478: }

482: /*@C
483:    DSRestoreArrayReal - Restores the matrix after DSGetArrayReal() was called.

485:    Not Collective

487:    Input Parameters:
488: +  ds - the direct solver context
489: .  m  - the requested matrix
490: -  a  - pointer to the values

492:    Level: advanced

494: .seealso: DSGetArrayReal(), DSGetArray()
495: @*/
496: PetscErrorCode DSRestoreArrayReal(DS ds,DSMatType m,PetscReal *a[])
497: {

502:   DSCheckAlloc(ds,1);
504:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
505:   CHKMEMQ;
506:   *a = 0;
507:   PetscObjectStateIncrease((PetscObject)ds);
508:   return(0);
509: }

513: /*@
514:    DSSolve - Solves the problem.

516:    Logically Collective on DS

518:    Input Parameters:
519: +  ds   - the direct solver context
520: .  eigr - array to store the computed eigenvalues (real part)
521: -  eigi - array to store the computed eigenvalues (imaginary part)

523:    Note:
524:    This call brings the dense system to condensed form. No ordering
525:    of the eigenvalues is enforced (for this, call DSSort() afterwards).

527:    Level: intermediate

529: .seealso: DSSort(), DSStateType
530: @*/
531: PetscErrorCode DSSolve(DS ds,PetscScalar *eigr,PetscScalar *eigi)
532: {

537:   DSCheckAlloc(ds,1);
539:   if (ds->state>=DS_STATE_CONDENSED) return(0);
540:   if (!ds->ops->solve[ds->method]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The specified method number does not exist for this DS");
541:   PetscLogEventBegin(DS_Solve,ds,0,0,0);
542:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
543:   (*ds->ops->solve[ds->method])(ds,eigr,eigi);
544:   PetscFPTrapPop();
545:   PetscLogEventEnd(DS_Solve,ds,0,0,0);
546:   ds->state = DS_STATE_CONDENSED;
547:   PetscObjectStateIncrease((PetscObject)ds);
548:   return(0);
549: }

553: /*@C
554:    DSSort - Sorts the result of DSSolve() according to a given sorting
555:    criterion.

557:    Logically Collective on DS

559:    Input Parameters:
560: +  ds   - the direct solver context
561: .  eigr - array containing the computed eigenvalues (real part)
562: .  eigi - array containing the computed eigenvalues (imaginary part)
563: .  rr   - (optional) array containing auxiliary values (real part)
564: -  ri   - (optional) array containing auxiliary values (imaginary part)

566:    Input/Output Parameter:
567: .  k    - (optional) number of elements in the leading group

569:    Notes:
570:    This routine sorts the arrays provided in eigr and eigi, and also
571:    sorts the dense system stored inside ds (assumed to be in condensed form).
572:    The sorting criterion is specified with DSSetSlepcSC().

574:    If arrays rr and ri are provided, then a (partial) reordering based on these
575:    values rather than on the eigenvalues is performed. In symmetric problems
576:    a total order is obtained (parameter k is ignored), but otherwise the result
577:    is sorted only partially. In this latter case, it is only guaranteed that
578:    all the first k elements satisfy the comparison with any of the last n-k
579:    elements. The output value of parameter k is the final number of elements in
580:    the first set.

582:    Level: intermediate

584: .seealso: DSSolve(), DSSetSlepcSC()
585: @*/
586: PetscErrorCode DSSort(DS ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
587: {
589:   PetscInt       i;

593:   DSCheckSolved(ds,1);
596:   if (ds->state==DS_STATE_TRUNCATED) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Cannot sort a truncated DS");
597:   if (!ds->ops->sort) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
598:   if (!ds->sc) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Must provide a sorting criterion first");
599:   if (k && !rr) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Argument k can only be used together with rr");

601:   for (i=0;i<ds->n;i++) ds->perm[i] = i;   /* initialize to trivial permutation */
602:   PetscLogEventBegin(DS_Other,ds,0,0,0);
603:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
604:   (*ds->ops->sort)(ds,eigr,eigi,rr,ri,k);
605:   PetscFPTrapPop();
606:   PetscLogEventEnd(DS_Other,ds,0,0,0);
607:   PetscObjectStateIncrease((PetscObject)ds);
608:   return(0);
609: }

613: /*@C
614:    DSVectors - Compute vectors associated to the dense system such
615:    as eigenvectors.

617:    Logically Collective on DS

619:    Input Parameters:
620: +  ds  - the direct solver context
621: -  mat - the matrix, used to indicate which vectors are required

623:    Input/Output Parameter:
624: -  j   - (optional) index of vector to be computed

626:    Output Parameter:
627: .  rnorm - (optional) computed residual norm

629:    Notes:
630:    Allowed values for mat are DS_MAT_X, DS_MAT_Y, DS_MAT_U and DS_MAT_VT, to
631:    compute right or left eigenvectors, or left or right singular vectors,
632:    respectively.

634:    If NULL is passed in argument j then all vectors are computed,
635:    otherwise j indicates which vector must be computed. In real non-symmetric
636:    problems, on exit the index j will be incremented when a complex conjugate
637:    pair is found.

639:    This function can be invoked after the dense problem has been solved,
640:    to get the residual norm estimate of the associated Ritz pair. In that
641:    case, the relevant information is returned in rnorm.

643:    For computing eigenvectors, LAPACK's _trevc is used so the matrix must
644:    be in (quasi-)triangular form, or call DSSolve() first.

646:    Level: intermediate

648: .seealso: DSSolve()
649: @*/
650: PetscErrorCode DSVectors(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
651: {

656:   DSCheckAlloc(ds,1);
658:   if (!ds->ops->vectors) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
659:   if (rnorm && !j) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Must give a value of j");
660:   if (!ds->mat[mat]) { DSAllocateMat_Private(ds,mat); }
661:   PetscLogEventBegin(DS_Vectors,ds,0,0,0);
662:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
663:   (*ds->ops->vectors)(ds,mat,j,rnorm);
664:   PetscFPTrapPop();
665:   PetscLogEventEnd(DS_Vectors,ds,0,0,0);
666:   PetscObjectStateIncrease((PetscObject)ds);
667:   return(0);
668: }

672: /*@
673:    DSNormalize - Normalize a column or all the columns of a matrix. Considers
674:    the case when the columns represent the real and the imaginary part of a vector.

676:    Logically Collective on DS

678:    Input Parameter:
679: +  ds  - the direct solver context
680: .  mat - the matrix to be modified
681: -  col - the column to normalize or -1 to normalize all of them

683:    Notes:
684:    The columns are normalized with respect to the 2-norm.

686:    If col and col+1 (or col-1 and col) represent the real and the imaginary
687:    part of a vector, both columns are scaled.

689:    Level: advanced

691: .seealso: DSMatType
692: @*/
693: PetscErrorCode DSNormalize(DS ds,DSMatType mat,PetscInt col)
694: {

699:   DSCheckSolved(ds,1);
702:   if (!ds->ops->normalize) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
703:   if (col<-1) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"col should be at least minus one");
704:   PetscLogEventBegin(DS_Other,ds,0,0,0);
705:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
706:   (*ds->ops->normalize)(ds,mat,col);
707:   PetscFPTrapPop();
708:   PetscLogEventEnd(DS_Other,ds,0,0,0);
709:   return(0);
710: }

714: /*@
715:    DSUpdateExtraRow - Performs all necessary operations so that the extra
716:    row gets up-to-date after a call to DSSolve().

718:    Not Collective

720:    Input Parameters:
721: .  ds - the direct solver context

723:    Level: advanced

725: .seealso: DSSolve(), DSSetExtraRow()
726: @*/
727: PetscErrorCode DSUpdateExtraRow(DS ds)
728: {

733:   DSCheckAlloc(ds,1);
734:   if (!ds->ops->update) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
735:   if (!ds->extrarow) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Should have called DSSetExtraRow");
736:   PetscLogEventBegin(DS_Other,ds,0,0,0);
737:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
738:   (*ds->ops->update)(ds);
739:   PetscFPTrapPop();
740:   PetscLogEventEnd(DS_Other,ds,0,0,0);
741:   return(0);
742: }

746: /*@
747:    DSCond - Compute the inf-norm condition number of the first matrix
748:    as cond(A) = norm(A)*norm(inv(A)).

750:    Not Collective

752:    Input Parameters:
753: +  ds - the direct solver context
754: -  cond - the computed condition number

756:    Level: advanced

758: .seealso: DSSolve()
759: @*/
760: PetscErrorCode DSCond(DS ds,PetscReal *cond)
761: {

766:   DSCheckAlloc(ds,1);
768:   if (!ds->ops->cond) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
769:   PetscLogEventBegin(DS_Other,ds,0,0,0);
770:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
771:   (*ds->ops->cond)(ds,cond);
772:   PetscFPTrapPop();
773:   PetscLogEventEnd(DS_Other,ds,0,0,0);
774:   return(0);
775: }

779: /*@C
780:    DSTranslateHarmonic - Computes a translation of the dense system.

782:    Logically Collective on DS

784:    Input Parameters:
785: +  ds      - the direct solver context
786: .  tau     - the translation amount
787: .  beta    - last component of vector b
788: -  recover - boolean flag to indicate whether to recover or not

790:    Output Parameters:
791: +  g       - the computed vector (optional)
792: -  gamma   - scale factor (optional)

794:    Notes:
795:    This function is intended for use in the context of Krylov methods only.
796:    It computes a translation of a Krylov decomposition in order to extract
797:    eigenpair approximations by harmonic Rayleigh-Ritz.
798:    The matrix is updated as A + g*b' where g = (A-tau*eye(n))'\b and
799:    vector b is assumed to be beta*e_n^T.

801:    The gamma factor is defined as sqrt(1+g'*g) and can be interpreted as
802:    the factor by which the residual of the Krylov decomposition is scaled.

804:    If the recover flag is activated, the computed translation undoes the
805:    translation done previously. In that case, parameter tau is ignored.

807:    Level: developer
808: @*/
809: PetscErrorCode DSTranslateHarmonic(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *g,PetscReal *gamma)
810: {

815:   DSCheckAlloc(ds,1);
816:   if (!ds->ops->transharm) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
817:   PetscLogEventBegin(DS_Other,ds,0,0,0);
818:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
819:   (*ds->ops->transharm)(ds,tau,beta,recover,g,gamma);
820:   PetscFPTrapPop();
821:   PetscLogEventEnd(DS_Other,ds,0,0,0);
822:   ds->state = DS_STATE_RAW;
823:   PetscObjectStateIncrease((PetscObject)ds);
824:   return(0);
825: }

829: /*@
830:    DSTranslateRKS - Computes a modification of the dense system corresponding
831:    to an update of the shift in a rational Krylov method.

833:    Logically Collective on DS

835:    Input Parameters:
836: +  ds    - the direct solver context
837: -  alpha - the translation amount

839:    Notes:
840:    This function is intended for use in the context of Krylov methods only.
841:    It takes the leading (k+1,k) submatrix of A, containing the truncated
842:    Rayleigh quotient of a Krylov-Schur relation computed from a shift
843:    sigma1 and transforms it to obtain a Krylov relation as if computed
844:    from a different shift sigma2. The new matrix is computed as
845:    1.0/alpha*(eye(k)-Q*inv(R)), where [Q,R]=qr(eye(k)-alpha*A) and
846:    alpha = sigma1-sigma2.

848:    Matrix Q is placed in DS_MAT_Q so that it can be used to update the
849:    Krylov basis.

851:    Level: developer
852: @*/
853: PetscErrorCode DSTranslateRKS(DS ds,PetscScalar alpha)
854: {

859:   DSCheckAlloc(ds,1);
860:   if (!ds->ops->transrks) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name);
861:   PetscLogEventBegin(DS_Other,ds,0,0,0);
862:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
863:   (*ds->ops->transrks)(ds,alpha);
864:   PetscFPTrapPop();
865:   PetscLogEventEnd(DS_Other,ds,0,0,0);
866:   ds->state   = DS_STATE_RAW;
867:   ds->compact = PETSC_FALSE;
868:   PetscObjectStateIncrease((PetscObject)ds);
869:   return(0);
870: }

874: /*@
875:    DSCopyMat - Copies the contents of a sequential dense Mat object to
876:    the indicated DS matrix, or vice versa. 

878:    Not Collective

880:    Input Parameters:
881: +  ds   - the direct solver context
882: .  m    - the requested matrix
883: .  mr   - first row of m to be considered
884: .  mc   - first column of m to be considered
885: .  A    - Mat object
886: .  Ar   - first row of A to be considered
887: .  Ac   - first column of A to be considered
888: .  rows - number of rows to copy
889: .  cols - number of columns to copy
890: -  out  - whether the data is copied out of the DS

892:    Note:
893:    If out=true, the values of the DS matrix m are copied to A, otherwise
894:    the entries of A are copied to the DS.

896:    Level: developer

898: .seealso: DSGetMat()
899: @*/
900: PetscErrorCode DSCopyMat(DS ds,DSMatType m,PetscInt mr,PetscInt mc,Mat A,PetscInt Ar,PetscInt Ac,PetscInt rows,PetscInt cols,PetscBool out)
901: {
903:   PetscInt       j,mrows,mcols,arows,acols;
904:   PetscScalar    *pA,*M;

908:   DSCheckAlloc(ds,1);
918:   if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix");
919:   if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS");
920:   if (!rows || !cols) return(0);

922:   mrows = PetscMax(ds->n,ds->t);
923:   mcols = ds->m? ds->m: ds->n;
924:   MatGetSize(A,&arows,&acols);
925:   if (mr<0 || mr>=mrows) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial row in m");
926:   if (mc<0 || mc>=mcols) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial column in m");
927:   if (Ar<0 || Ar>=arows) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial row in A");
928:   if (Ac<0 || Ac>=acols) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial column in A");
929:   if (mr+rows>mrows || Ar+rows>arows) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid number of rows");
930:   if (mc+cols>mcols || Ac+cols>acols) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid number of columns");

932:   M  = ds->mat[m];
933:   MatDenseGetArray(A,&pA);
934:   for (j=0;j<cols;j++) {
935:     if (out) {
936:       PetscMemcpy(pA+(Ac+j)*arows+Ar,M+(mc+j)*ds->ld+mr,rows*sizeof(PetscScalar));
937:     } else {
938:       PetscMemcpy(M+(mc+j)*ds->ld+mr,pA+(Ac+j)*arows+Ar,rows*sizeof(PetscScalar));
939:     }
940:   }
941:   MatDenseRestoreArray(A,&pA);
942:   return(0);
943: }

slepc-3.7.4/src/sys/classes/ds/interface/index.html0000644000175000017500000000230213107004621021565 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dsbasic.c
dsops.c
dspriv.c
makefile
slepc-3.7.4/src/sys/classes/ds/interface/ftn-auto/0000755000175000017500000000000013107004621021330 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/interface/ftn-auto/makefile0000644000175000017500000000041513107004621023030 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = dsprivf.c dsopsf.c dsbasicf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/ds/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/interface/ftn-auto/dsprivf.c0000644000175000017500000000206213107004621023151 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* dspriv.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcds.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetidentity_ DSSETIDENTITY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetidentity_ dssetidentity #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL dssetidentity_(DS ds,DSMatType *mat, int *__ierr ){ *__ierr = DSSetIdentity( (DS)PetscToPointer((ds) ),*mat); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/ds/interface/ftn-auto/dsopsf.c0000644000175000017500000001307413107004621022777 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* dsops.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcds.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetleadingdimension_ DSGETLEADINGDIMENSION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetleadingdimension_ dsgetleadingdimension #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetstate_ DSSETSTATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetstate_ dssetstate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetstate_ DSGETSTATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetstate_ dsgetstate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetdimensions_ DSSETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetdimensions_ dssetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetdimensions_ DSGETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetdimensions_ dsgetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dstruncate_ DSTRUNCATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dstruncate_ dstruncate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetmat_ DSGETMAT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetmat_ dsgetmat #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsrestoremat_ DSRESTOREMAT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsrestoremat_ dsrestoremat #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssolve_ DSSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssolve_ dssolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsnormalize_ DSNORMALIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsnormalize_ dsnormalize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsupdateextrarow_ DSUPDATEEXTRAROW #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsupdateextrarow_ dsupdateextrarow #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dscond_ DSCOND #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dscond_ dscond #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dstranslaterks_ DSTRANSLATERKS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dstranslaterks_ dstranslaterks #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dscopymat_ DSCOPYMAT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dscopymat_ dscopymat #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL dsgetleadingdimension_(DS ds,PetscInt *ld, int *__ierr ){ *__ierr = DSGetLeadingDimension( (DS)PetscToPointer((ds) ),ld); } PETSC_EXTERN void PETSC_STDCALL dssetstate_(DS ds,DSStateType *state, int *__ierr ){ *__ierr = DSSetState( (DS)PetscToPointer((ds) ),*state); } PETSC_EXTERN void PETSC_STDCALL dsgetstate_(DS ds,DSStateType *state, int *__ierr ){ *__ierr = DSGetState( (DS)PetscToPointer((ds) ),state); } PETSC_EXTERN void PETSC_STDCALL dssetdimensions_(DS ds,PetscInt *n,PetscInt *m,PetscInt *l,PetscInt *k, int *__ierr ){ *__ierr = DSSetDimensions( (DS)PetscToPointer((ds) ),*n,*m,*l,*k); } PETSC_EXTERN void PETSC_STDCALL dsgetdimensions_(DS ds,PetscInt *n,PetscInt *m,PetscInt *l,PetscInt *k,PetscInt *t, int *__ierr ){ *__ierr = DSGetDimensions( (DS)PetscToPointer((ds) ),n,m,l,k,t); } PETSC_EXTERN void PETSC_STDCALL dstruncate_(DS ds,PetscInt *n, int *__ierr ){ *__ierr = DSTruncate( (DS)PetscToPointer((ds) ),*n); } PETSC_EXTERN void PETSC_STDCALL dsgetmat_(DS ds,DSMatType *m,Mat *A, int *__ierr ){ *__ierr = DSGetMat( (DS)PetscToPointer((ds) ),*m,A); } PETSC_EXTERN void PETSC_STDCALL dsrestoremat_(DS ds,DSMatType *m,Mat *A, int *__ierr ){ *__ierr = DSRestoreMat( (DS)PetscToPointer((ds) ),*m,A); } PETSC_EXTERN void PETSC_STDCALL dssolve_(DS ds,PetscScalar *eigr,PetscScalar *eigi, int *__ierr ){ *__ierr = DSSolve( (DS)PetscToPointer((ds) ),eigr,eigi); } PETSC_EXTERN void PETSC_STDCALL dsnormalize_(DS ds,DSMatType *mat,PetscInt *col, int *__ierr ){ *__ierr = DSNormalize( (DS)PetscToPointer((ds) ),*mat,*col); } PETSC_EXTERN void PETSC_STDCALL dsupdateextrarow_(DS ds, int *__ierr ){ *__ierr = DSUpdateExtraRow( (DS)PetscToPointer((ds) )); } PETSC_EXTERN void PETSC_STDCALL dscond_(DS ds,PetscReal *cond, int *__ierr ){ *__ierr = DSCond( (DS)PetscToPointer((ds) ),cond); } PETSC_EXTERN void PETSC_STDCALL dstranslaterks_(DS ds,PetscScalar *alpha, int *__ierr ){ *__ierr = DSTranslateRKS( (DS)PetscToPointer((ds) ),*alpha); } PETSC_EXTERN void PETSC_STDCALL dscopymat_(DS ds,DSMatType *m,PetscInt *mr,PetscInt *mc,Mat A,PetscInt *Ar,PetscInt *Ac,PetscInt *rows,PetscInt *cols,PetscBool *out, int *__ierr ){ *__ierr = DSCopyMat( (DS)PetscToPointer((ds) ),*m,*mr,*mc, (Mat)PetscToPointer((A) ),*Ar,*Ac,*rows,*cols,*out); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/ds/interface/ftn-auto/dsbasicf.c0000644000175000017500000001300113107004621023245 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* dsbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcds.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define dscreate_ DSCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dscreate_ dscreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetmethod_ DSSETMETHOD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetmethod_ dssetmethod #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetmethod_ DSGETMETHOD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetmethod_ dsgetmethod #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetcompact_ DSSETCOMPACT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetcompact_ dssetcompact #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetcompact_ DSGETCOMPACT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetcompact_ dsgetcompact #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetextrarow_ DSSETEXTRAROW #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetextrarow_ dssetextrarow #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetextrarow_ DSGETEXTRAROW #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetextrarow_ dsgetextrarow #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetrefined_ DSSETREFINED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetrefined_ dssetrefined #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetrefined_ DSGETREFINED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetrefined_ dsgetrefined #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetblocksize_ DSSETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetblocksize_ dssetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsgetblocksize_ DSGETBLOCKSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsgetblocksize_ dsgetblocksize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dssetfromoptions_ DSSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dssetfromoptions_ dssetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsallocate_ DSALLOCATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsallocate_ dsallocate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsreset_ DSRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsreset_ dsreset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsdestroy_ DSDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsdestroy_ dsdestroy #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL dscreate_(MPI_Fint * comm,DS *newds, int *__ierr ){ *__ierr = DSCreate( MPI_Comm_f2c(*(comm)),newds); } PETSC_EXTERN void PETSC_STDCALL dssetmethod_(DS ds,PetscInt *meth, int *__ierr ){ *__ierr = DSSetMethod( (DS)PetscToPointer((ds) ),*meth); } PETSC_EXTERN void PETSC_STDCALL dsgetmethod_(DS ds,PetscInt *meth, int *__ierr ){ *__ierr = DSGetMethod( (DS)PetscToPointer((ds) ),meth); } PETSC_EXTERN void PETSC_STDCALL dssetcompact_(DS ds,PetscBool *comp, int *__ierr ){ *__ierr = DSSetCompact( (DS)PetscToPointer((ds) ),*comp); } PETSC_EXTERN void PETSC_STDCALL dsgetcompact_(DS ds,PetscBool *comp, int *__ierr ){ *__ierr = DSGetCompact( (DS)PetscToPointer((ds) ),comp); } PETSC_EXTERN void PETSC_STDCALL dssetextrarow_(DS ds,PetscBool *ext, int *__ierr ){ *__ierr = DSSetExtraRow( (DS)PetscToPointer((ds) ),*ext); } PETSC_EXTERN void PETSC_STDCALL dsgetextrarow_(DS ds,PetscBool *ext, int *__ierr ){ *__ierr = DSGetExtraRow( (DS)PetscToPointer((ds) ),ext); } PETSC_EXTERN void PETSC_STDCALL dssetrefined_(DS ds,PetscBool *ref, int *__ierr ){ *__ierr = DSSetRefined( (DS)PetscToPointer((ds) ),*ref); } PETSC_EXTERN void PETSC_STDCALL dsgetrefined_(DS ds,PetscBool *ref, int *__ierr ){ *__ierr = DSGetRefined( (DS)PetscToPointer((ds) ),ref); } PETSC_EXTERN void PETSC_STDCALL dssetblocksize_(DS ds,PetscInt *bs, int *__ierr ){ *__ierr = DSSetBlockSize( (DS)PetscToPointer((ds) ),*bs); } PETSC_EXTERN void PETSC_STDCALL dsgetblocksize_(DS ds,PetscInt *bs, int *__ierr ){ *__ierr = DSGetBlockSize( (DS)PetscToPointer((ds) ),bs); } PETSC_EXTERN void PETSC_STDCALL dssetfromoptions_(DS ds, int *__ierr ){ *__ierr = DSSetFromOptions( (DS)PetscToPointer((ds) )); } PETSC_EXTERN void PETSC_STDCALL dsallocate_(DS ds,PetscInt *ld, int *__ierr ){ *__ierr = DSAllocate( (DS)PetscToPointer((ds) ),*ld); } PETSC_EXTERN void PETSC_STDCALL dsreset_(DS ds, int *__ierr ){ *__ierr = DSReset( (DS)PetscToPointer((ds) )); } PETSC_EXTERN void PETSC_STDCALL dsdestroy_(DS *ds, int *__ierr ){ *__ierr = DSDestroy(ds); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/ds/interface/dsops.c0000644000175000017500000007473113107004621021103 0ustar jromanjroman/* DS operations: DSSolve(), DSVectors(), etc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcds.h" I*/ #undef __FUNCT__ #define __FUNCT__ "DSGetLeadingDimension" /*@ DSGetLeadingDimension - Returns the leading dimension of the allocated matrices. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . ld - leading dimension (maximum allowed dimension for the matrices) Level: advanced .seealso: DSAllocate(), DSSetDimensions() @*/ PetscErrorCode DSGetLeadingDimension(DS ds,PetscInt *ld) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(ld,2); *ld = ds->ld; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetState" /*@ DSSetState - Change the state of the DS object. Logically Collective on DS Input Parameters: + ds - the direct solver context - state - the new state Notes: The state indicates that the dense system is in an initial state (raw), in an intermediate state (such as tridiagonal, Hessenberg or Hessenberg-triangular), in a condensed state (such as diagonal, Schur or generalized Schur), or in a truncated state. This function is normally used to return to the raw state when the condensed structure is destroyed. Level: advanced .seealso: DSGetState() @*/ PetscErrorCode DSSetState(DS ds,DSStateType state) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveEnum(ds,state,2); switch (state) { case DS_STATE_RAW: case DS_STATE_INTERMEDIATE: case DS_STATE_CONDENSED: case DS_STATE_TRUNCATED: if (ds->statestate = state; break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Wrong state"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetState" /*@ DSGetState - Returns the current state. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: . state - current state Level: advanced .seealso: DSSetState() @*/ PetscErrorCode DSGetState(DS ds,DSStateType *state) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(state,2); *state = ds->state; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSetDimensions" /*@ DSSetDimensions - Resize the matrices in the DS object. Logically Collective on DS Input Parameters: + ds - the direct solver context . n - the new size . m - the new column size (only for DSSVD) . l - number of locked (inactive) leading columns - k - intermediate dimension (e.g., position of arrow) Notes: The internal arrays are not reallocated. The value m is not used except in the case of DSSVD, pass 0 otherwise. Level: intermediate .seealso: DSGetDimensions(), DSAllocate() @*/ PetscErrorCode DSSetDimensions(DS ds,PetscInt n,PetscInt m,PetscInt l,PetscInt k) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidLogicalCollectiveInt(ds,n,2); PetscValidLogicalCollectiveInt(ds,m,3); PetscValidLogicalCollectiveInt(ds,l,4); PetscValidLogicalCollectiveInt(ds,k,5); if (n==PETSC_DECIDE || n==PETSC_DEFAULT) { ds->n = ds->ld; } else { if (n<0 || n>ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of n. Must be between 0 and ld"); if (ds->extrarow && n+1>ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"A value of n equal to ld leaves no room for extra row"); ds->n = n; } ds->t = ds->n; /* truncated length equal to the new dimension */ if (m) { if (m==PETSC_DECIDE || m==PETSC_DEFAULT) { ds->m = ds->ld; } else { if (m<0 || m>ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of m. Must be between 0 and ld"); ds->m = m; } } if (l==PETSC_DECIDE || l==PETSC_DEFAULT) { ds->l = 0; } else { if (l<0 || l>ds->n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of l. Must be between 0 and n"); ds->l = l; } if (k==PETSC_DECIDE || k==PETSC_DEFAULT) { ds->k = ds->n/2; } else { if (k<0 || k>ds->n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of k. Must be between 0 and n"); ds->k = k; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetDimensions" /*@ DSGetDimensions - Returns the current dimensions. Not Collective Input Parameter: . ds - the direct solver context Output Parameter: + n - the current size . m - the current column size (only for DSSVD) . l - number of locked (inactive) leading columns . k - intermediate dimension (e.g., position of arrow) - t - truncated length Level: intermediate Note: The t parameter makes sense only if DSTruncate() has been called. Otherwise its value equals n. .seealso: DSSetDimensions(), DSTruncate() @*/ PetscErrorCode DSGetDimensions(DS ds,PetscInt *n,PetscInt *m,PetscInt *l,PetscInt *k,PetscInt *t) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); if (n) *n = ds->n; if (m) *m = ds->m; if (l) *l = ds->l; if (k) *k = ds->k; if (t) *t = ds->t; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSTruncate" /*@ DSTruncate - Truncates the system represented in the DS object. Logically Collective on DS Input Parameters: + ds - the direct solver context - n - the new size Note: The new size is set to n. In cases where the extra row is meaningful, the first n elements are kept as the extra row for the new system. Level: advanced .seealso: DSSetDimensions(), DSSetExtraRow(), DSStateType @*/ PetscErrorCode DSTruncate(DS ds,PetscInt n) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); DSCheckSolved(ds,1); PetscValidLogicalCollectiveInt(ds,n,2); if (!ds->ops->truncate) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); if (nl || n>ds->n) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of n. Must be between l and n"); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->truncate)(ds,n);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); ds->state = DS_STATE_TRUNCATED; ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetMat" /*@ DSGetMat - Returns a sequential dense Mat object containing the requested matrix. Not Collective Input Parameters: + ds - the direct solver context - m - the requested matrix Output Parameter: . A - Mat object Notes: The Mat is created with sizes equal to the current DS dimensions (nxm), then it is filled with the values that would be obtained with DSGetArray() (not DSGetArrayReal()). If the DS was truncated, then the number of rows is equal to the dimension prior to truncation, see DSTruncate(). The communicator is always PETSC_COMM_SELF. When no longer needed, the user can either destroy the matrix or call DSRestoreMat(). The latter will copy back the modified values. Level: advanced .seealso: DSRestoreMat(), DSSetDimensions(), DSGetArray(), DSGetArrayReal(), DSTruncate() @*/ PetscErrorCode DSGetMat(DS ds,DSMatType m,Mat *A) { PetscErrorCode ierr; PetscInt j,rows,cols,arows,acols; PetscBool create=PETSC_FALSE; PetscScalar *pA,*M; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidLogicalCollectiveEnum(ds,m,2); PetscValidPointer(A,3); if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS"); rows = PetscMax(ds->n,ds->t); cols = ds->m? ds->m: ds->n; if (!ds->omat[m]) create=PETSC_TRUE; else { ierr = MatGetSize(ds->omat[m],&arows,&acols);CHKERRQ(ierr); if (arows!=rows || acols!=cols) { ierr = MatDestroy(&ds->omat[m]);CHKERRQ(ierr); create=PETSC_TRUE; } } if (create) { ierr = MatCreateSeqDense(PETSC_COMM_SELF,rows,cols,NULL,&ds->omat[m]);CHKERRQ(ierr); } ierr = PetscObjectReference((PetscObject)ds->omat[m]);CHKERRQ(ierr); *A = ds->omat[m]; M = ds->mat[m]; ierr = MatDenseGetArray(*A,&pA);CHKERRQ(ierr); for (j=0;jld,rows*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = MatDenseRestoreArray(*A,&pA);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSRestoreMat" /*@ DSRestoreMat - Restores the matrix after DSGetMat() was called. Not Collective Input Parameters: + ds - the direct solver context . m - the requested matrix - A - the fetched Mat object Notes: A call to this function must match a previous call of DSGetMat(). The effect is that the contents of the Mat are copied back to the DS internal array, and the matrix is destroyed. It is not compulsory to call this function, the matrix obtained with DSGetMat() can simply be destroyed if entries need not be copied back. Level: advanced .seealso: DSGetMat(), DSRestoreArray(), DSRestoreArrayReal() @*/ PetscErrorCode DSRestoreMat(DS ds,DSMatType m,Mat *A) { PetscErrorCode ierr; PetscInt j,rows,cols; PetscScalar *pA,*M; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidLogicalCollectiveEnum(ds,m,2); PetscValidPointer(A,3); if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); if (!ds->omat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"DSRestoreMat must match a previous call to DSGetMat"); if (ds->omat[m]!=*A) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Mat argument is not the same as the one obtained with DSGetMat"); ierr = MatGetSize(*A,&rows,&cols);CHKERRQ(ierr); M = ds->mat[m]; ierr = MatDenseGetArray(*A,&pA);CHKERRQ(ierr); for (j=0;jld,pA+j*rows,rows*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = MatDenseRestoreArray(*A,&pA);CHKERRQ(ierr); ierr = MatDestroy(A);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetArray" /*@C DSGetArray - Returns a pointer to one of the internal arrays used to represent matrices. You MUST call DSRestoreArray() when you no longer need to access the array. Not Collective Input Parameters: + ds - the direct solver context - m - the requested matrix Output Parameter: . a - pointer to the values Level: advanced .seealso: DSRestoreArray(), DSGetArrayReal() @*/ PetscErrorCode DSGetArray(DS ds,DSMatType m,PetscScalar *a[]) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidPointer(a,2); if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS"); *a = ds->mat[m]; CHKMEMQ; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSRestoreArray" /*@C DSRestoreArray - Restores the matrix after DSGetArray() was called. Not Collective Input Parameters: + ds - the direct solver context . m - the requested matrix - a - pointer to the values Level: advanced .seealso: DSGetArray(), DSGetArrayReal() @*/ PetscErrorCode DSRestoreArray(DS ds,DSMatType m,PetscScalar *a[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidPointer(a,2); if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); CHKMEMQ; *a = 0; ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGetArrayReal" /*@C DSGetArrayReal - Returns a pointer to one of the internal arrays used to represent real matrices. You MUST call DSRestoreArrayReal() when you no longer need to access the array. Not Collective Input Parameters: + ds - the direct solver context - m - the requested matrix Output Parameter: . a - pointer to the values Level: advanced .seealso: DSRestoreArrayReal(), DSGetArray() @*/ PetscErrorCode DSGetArrayReal(DS ds,DSMatType m,PetscReal *a[]) { PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidPointer(a,2); if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); if (!ds->rmat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS"); *a = ds->rmat[m]; CHKMEMQ; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSRestoreArrayReal" /*@C DSRestoreArrayReal - Restores the matrix after DSGetArrayReal() was called. Not Collective Input Parameters: + ds - the direct solver context . m - the requested matrix - a - pointer to the values Level: advanced .seealso: DSGetArrayReal(), DSGetArray() @*/ PetscErrorCode DSRestoreArrayReal(DS ds,DSMatType m,PetscReal *a[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidPointer(a,2); if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); CHKMEMQ; *a = 0; ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSolve" /*@ DSSolve - Solves the problem. Logically Collective on DS Input Parameters: + ds - the direct solver context . eigr - array to store the computed eigenvalues (real part) - eigi - array to store the computed eigenvalues (imaginary part) Note: This call brings the dense system to condensed form. No ordering of the eigenvalues is enforced (for this, call DSSort() afterwards). Level: intermediate .seealso: DSSort(), DSStateType @*/ PetscErrorCode DSSolve(DS ds,PetscScalar *eigr,PetscScalar *eigi) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidPointer(eigr,2); if (ds->state>=DS_STATE_CONDENSED) PetscFunctionReturn(0); if (!ds->ops->solve[ds->method]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The specified method number does not exist for this DS"); ierr = PetscLogEventBegin(DS_Solve,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->solve[ds->method])(ds,eigr,eigi);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Solve,ds,0,0,0);CHKERRQ(ierr); ds->state = DS_STATE_CONDENSED; ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSort" /*@C DSSort - Sorts the result of DSSolve() according to a given sorting criterion. Logically Collective on DS Input Parameters: + ds - the direct solver context . eigr - array containing the computed eigenvalues (real part) . eigi - array containing the computed eigenvalues (imaginary part) . rr - (optional) array containing auxiliary values (real part) - ri - (optional) array containing auxiliary values (imaginary part) Input/Output Parameter: . k - (optional) number of elements in the leading group Notes: This routine sorts the arrays provided in eigr and eigi, and also sorts the dense system stored inside ds (assumed to be in condensed form). The sorting criterion is specified with DSSetSlepcSC(). If arrays rr and ri are provided, then a (partial) reordering based on these values rather than on the eigenvalues is performed. In symmetric problems a total order is obtained (parameter k is ignored), but otherwise the result is sorted only partially. In this latter case, it is only guaranteed that all the first k elements satisfy the comparison with any of the last n-k elements. The output value of parameter k is the final number of elements in the first set. Level: intermediate .seealso: DSSolve(), DSSetSlepcSC() @*/ PetscErrorCode DSSort(DS ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckSolved(ds,1); PetscValidPointer(eigr,2); if (rr) PetscValidPointer(rr,4); if (ds->state==DS_STATE_TRUNCATED) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Cannot sort a truncated DS"); if (!ds->ops->sort) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); if (!ds->sc) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Must provide a sorting criterion first"); if (k && !rr) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Argument k can only be used together with rr"); for (i=0;in;i++) ds->perm[i] = i; /* initialize to trivial permutation */ ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->sort)(ds,eigr,eigi,rr,ri,k);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors" /*@C DSVectors - Compute vectors associated to the dense system such as eigenvectors. Logically Collective on DS Input Parameters: + ds - the direct solver context - mat - the matrix, used to indicate which vectors are required Input/Output Parameter: - j - (optional) index of vector to be computed Output Parameter: . rnorm - (optional) computed residual norm Notes: Allowed values for mat are DS_MAT_X, DS_MAT_Y, DS_MAT_U and DS_MAT_VT, to compute right or left eigenvectors, or left or right singular vectors, respectively. If NULL is passed in argument j then all vectors are computed, otherwise j indicates which vector must be computed. In real non-symmetric problems, on exit the index j will be incremented when a complex conjugate pair is found. This function can be invoked after the dense problem has been solved, to get the residual norm estimate of the associated Ritz pair. In that case, the relevant information is returned in rnorm. For computing eigenvectors, LAPACK's _trevc is used so the matrix must be in (quasi-)triangular form, or call DSSolve() first. Level: intermediate .seealso: DSSolve() @*/ PetscErrorCode DSVectors(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidLogicalCollectiveEnum(ds,mat,2); if (!ds->ops->vectors) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); if (rnorm && !j) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Must give a value of j"); if (!ds->mat[mat]) { ierr = DSAllocateMat_Private(ds,mat);CHKERRQ(ierr); } ierr = PetscLogEventBegin(DS_Vectors,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->vectors)(ds,mat,j,rnorm);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Vectors,ds,0,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNormalize" /*@ DSNormalize - Normalize a column or all the columns of a matrix. Considers the case when the columns represent the real and the imaginary part of a vector. Logically Collective on DS Input Parameter: + ds - the direct solver context . mat - the matrix to be modified - col - the column to normalize or -1 to normalize all of them Notes: The columns are normalized with respect to the 2-norm. If col and col+1 (or col-1 and col) represent the real and the imaginary part of a vector, both columns are scaled. Level: advanced .seealso: DSMatType @*/ PetscErrorCode DSNormalize(DS ds,DSMatType mat,PetscInt col) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckSolved(ds,1); PetscValidLogicalCollectiveEnum(ds,mat,2); PetscValidLogicalCollectiveInt(ds,col,3); if (!ds->ops->normalize) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); if (col<-1) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"col should be at least minus one"); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->normalize)(ds,mat,col);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSUpdateExtraRow" /*@ DSUpdateExtraRow - Performs all necessary operations so that the extra row gets up-to-date after a call to DSSolve(). Not Collective Input Parameters: . ds - the direct solver context Level: advanced .seealso: DSSolve(), DSSetExtraRow() @*/ PetscErrorCode DSUpdateExtraRow(DS ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); if (!ds->ops->update) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); if (!ds->extrarow) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Should have called DSSetExtraRow"); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->update)(ds);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCond" /*@ DSCond - Compute the inf-norm condition number of the first matrix as cond(A) = norm(A)*norm(inv(A)). Not Collective Input Parameters: + ds - the direct solver context - cond - the computed condition number Level: advanced .seealso: DSSolve() @*/ PetscErrorCode DSCond(DS ds,PetscReal *cond) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidPointer(cond,2); if (!ds->ops->cond) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->cond)(ds,cond);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSTranslateHarmonic" /*@C DSTranslateHarmonic - Computes a translation of the dense system. Logically Collective on DS Input Parameters: + ds - the direct solver context . tau - the translation amount . beta - last component of vector b - recover - boolean flag to indicate whether to recover or not Output Parameters: + g - the computed vector (optional) - gamma - scale factor (optional) Notes: This function is intended for use in the context of Krylov methods only. It computes a translation of a Krylov decomposition in order to extract eigenpair approximations by harmonic Rayleigh-Ritz. The matrix is updated as A + g*b' where g = (A-tau*eye(n))'\b and vector b is assumed to be beta*e_n^T. The gamma factor is defined as sqrt(1+g'*g) and can be interpreted as the factor by which the residual of the Krylov decomposition is scaled. If the recover flag is activated, the computed translation undoes the translation done previously. In that case, parameter tau is ignored. Level: developer @*/ PetscErrorCode DSTranslateHarmonic(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *g,PetscReal *gamma) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); if (!ds->ops->transharm) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->transharm)(ds,tau,beta,recover,g,gamma);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); ds->state = DS_STATE_RAW; ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSTranslateRKS" /*@ DSTranslateRKS - Computes a modification of the dense system corresponding to an update of the shift in a rational Krylov method. Logically Collective on DS Input Parameters: + ds - the direct solver context - alpha - the translation amount Notes: This function is intended for use in the context of Krylov methods only. It takes the leading (k+1,k) submatrix of A, containing the truncated Rayleigh quotient of a Krylov-Schur relation computed from a shift sigma1 and transforms it to obtain a Krylov relation as if computed from a different shift sigma2. The new matrix is computed as 1.0/alpha*(eye(k)-Q*inv(R)), where [Q,R]=qr(eye(k)-alpha*A) and alpha = sigma1-sigma2. Matrix Q is placed in DS_MAT_Q so that it can be used to update the Krylov basis. Level: developer @*/ PetscErrorCode DSTranslateRKS(DS ds,PetscScalar alpha) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); if (!ds->ops->transrks) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_SUP,"DS type %s",((PetscObject)ds)->type_name); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = (*ds->ops->transrks)(ds,alpha);CHKERRQ(ierr); ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); ds->state = DS_STATE_RAW; ds->compact = PETSC_FALSE; ierr = PetscObjectStateIncrease((PetscObject)ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCopyMat" /*@ DSCopyMat - Copies the contents of a sequential dense Mat object to the indicated DS matrix, or vice versa. Not Collective Input Parameters: + ds - the direct solver context . m - the requested matrix . mr - first row of m to be considered . mc - first column of m to be considered . A - Mat object . Ar - first row of A to be considered . Ac - first column of A to be considered . rows - number of rows to copy . cols - number of columns to copy - out - whether the data is copied out of the DS Note: If out=true, the values of the DS matrix m are copied to A, otherwise the entries of A are copied to the DS. Level: developer .seealso: DSGetMat() @*/ PetscErrorCode DSCopyMat(DS ds,DSMatType m,PetscInt mr,PetscInt mc,Mat A,PetscInt Ar,PetscInt Ac,PetscInt rows,PetscInt cols,PetscBool out) { PetscErrorCode ierr; PetscInt j,mrows,mcols,arows,acols; PetscScalar *pA,*M; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); DSCheckAlloc(ds,1); PetscValidLogicalCollectiveEnum(ds,m,2); PetscValidHeaderSpecific(A,MAT_CLASSID,3); PetscValidLogicalCollectiveBool(ds,out,4); PetscValidLogicalCollectiveInt(ds,mr,5); PetscValidLogicalCollectiveInt(ds,mc,6); PetscValidLogicalCollectiveInt(ds,Ar,7); PetscValidLogicalCollectiveInt(ds,Ac,8); PetscValidLogicalCollectiveInt(ds,rows,9); PetscValidLogicalCollectiveInt(ds,rows,10); if (m>=DS_NUM_MAT) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"Invalid matrix"); if (!ds->mat[m]) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONGSTATE,"Requested matrix was not created in this DS"); if (!rows || !cols) PetscFunctionReturn(0); mrows = PetscMax(ds->n,ds->t); mcols = ds->m? ds->m: ds->n; ierr = MatGetSize(A,&arows,&acols);CHKERRQ(ierr); if (mr<0 || mr>=mrows) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial row in m"); if (mc<0 || mc>=mcols) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial column in m"); if (Ar<0 || Ar>=arows) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial row in A"); if (Ac<0 || Ac>=acols) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid initial column in A"); if (mr+rows>mrows || Ar+rows>arows) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid number of rows"); if (mc+cols>mcols || Ac+cols>acols) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid number of columns"); M = ds->mat[m]; ierr = MatDenseGetArray(A,&pA);CHKERRQ(ierr); for (j=0;jld+mr,rows*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemcpy(M+(mc+j)*ds->ld+mr,pA+(Ac+j)*arows+Ar,rows*sizeof(PetscScalar));CHKERRQ(ierr); } } ierr = MatDenseRestoreArray(A,&pA);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/interface/ftn-custom/0000755000175000017500000000000013107004621021672 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/interface/ftn-custom/makefile0000644000175000017500000000222313107004621023371 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zdsf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/ds/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/interface/ftn-custom/zdsf.c0000644000175000017500000001002613107004621023003 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define dssettype_ DSSETTYPE #define dsgettype_ DSGETTYPE #define dssetoptionsprefix_ DSSETOPTIONSPREFIX #define dsappendoptionsprefix_ DSAPPENDOPTIONSPREFIX #define dsgetoptionsprefix_ DSGETOPTIONSPREFIX #define dsview_ DSVIEW #define dsviewmat_ DSVIEWMAT #define dsvectors_ DSVECTORS #define dssort_ DSSORT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define dssettype_ dssettype #define dsgettype_ dsgettype #define dssetoptionsprefix_ dssetoptionsprefix #define dsappendoptionsprefix_ dsappendoptionsprefix #define dsgetoptionsprefix_ dsgetoptionsprefix #define dsview_ dsview #define dsviewmat_ dsviewmat #define dsvectors_ dsvectors #define dssort_ dssort #endif PETSC_EXTERN void PETSC_STDCALL dssettype_(DS *ds,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = DSSetType(*ds,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL dsgettype_(DS *ds,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { DSType tname; *ierr = DSGetType(*ds,&tname);if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL dssetoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = DSSetOptionsPrefix(*ds,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL dsappendoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = DSAppendOptionsPrefix(*ds,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL dsgetoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = DSGetOptionsPrefix(*ds,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL dsview_(DS *ds,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = DSView(*ds,v); } PETSC_EXTERN void PETSC_STDCALL dsviewmat_(DS *ds,PetscViewer *viewer,DSMatType *m,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = DSViewMat(*ds,v,*m); } PETSC_EXTERN void PETSC_STDCALL dsvectors_(DS *ds,DSMatType *mat,PetscInt *j,PetscReal *rnorm,PetscErrorCode *ierr) { CHKFORTRANNULLINTEGER(j); CHKFORTRANNULLREAL(rnorm); *ierr = DSVectors(*ds,*mat,j,rnorm); } PETSC_EXTERN void PETSC_STDCALL dssort_(DS *ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k,PetscErrorCode *ierr) { CHKFORTRANNULLSCALAR(eigr); CHKFORTRANNULLSCALAR(eigi); CHKFORTRANNULLSCALAR(rr); CHKFORTRANNULLSCALAR(ri); CHKFORTRANNULLINTEGER(k); *ierr = DSSort(*ds,eigr,eigi,rr,ri,k); } slepc-3.7.4/src/sys/classes/ds/interface/dsbasic.c.html0000644000175000017500000020275013107004621022320 0ustar jromanjroman

Actual source code: dsbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Basic DS routines

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>      /*I "slepcds.h" I*/

 26: PetscFunctionList DSList = 0;
 27: PetscBool         DSRegisterAllCalled = PETSC_FALSE;
 28: PetscClassId      DS_CLASSID = 0;
 29: PetscLogEvent     DS_Solve = 0,DS_Vectors = 0,DS_Other = 0;
 30: static PetscBool  DSPackageInitialized = PETSC_FALSE;
 31: const char        *DSMatName[DS_NUM_MAT] = {"A","B","C","T","D","Q","Z","X","Y","U","VT","W","E0","E1","E2","E3","E4","E5","E6","E7","E8","E9"};
 32: DSMatType         DSMatExtra[DS_NUM_EXTRA] = {DS_MAT_E0,DS_MAT_E1,DS_MAT_E2,DS_MAT_E3,DS_MAT_E4,DS_MAT_E5,DS_MAT_E6,DS_MAT_E7,DS_MAT_E8,DS_MAT_E9};

 36: /*@C
 37:    DSFinalizePackage - This function destroys everything in the SLEPc interface
 38:    to the DS package. It is called from SlepcFinalize().

 40:    Level: developer

 42: .seealso: SlepcFinalize()
 43: @*/
 44: PetscErrorCode DSFinalizePackage(void)
 45: {

 49:   PetscFunctionListDestroy(&DSList);
 50:   DSPackageInitialized = PETSC_FALSE;
 51:   DSRegisterAllCalled  = PETSC_FALSE;
 52:   return(0);
 53: }

 57: /*@C
 58:   DSInitializePackage - This function initializes everything in the DS package.
 59:   It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 60:   on the first call to DSCreate() when using static libraries.

 62:   Level: developer

 64: .seealso: SlepcInitialize()
 65: @*/
 66: PetscErrorCode DSInitializePackage()
 67: {
 68:   char             logList[256];
 69:   char             *className;
 70:   PetscBool        opt;
 71:   PetscErrorCode   ierr;

 74:   if (DSPackageInitialized) return(0);
 75:   DSPackageInitialized = PETSC_TRUE;
 76:   /* Register Classes */
 77:   PetscClassIdRegister("Direct Solver",&DS_CLASSID);
 78:   /* Register Constructors */
 79:   DSRegisterAll();
 80:   /* Register Events */
 81:   PetscLogEventRegister("DSSolve",DS_CLASSID,&DS_Solve);
 82:   PetscLogEventRegister("DSVectors",DS_CLASSID,&DS_Vectors);
 83:   PetscLogEventRegister("DSOther",DS_CLASSID,&DS_Other);
 84:   /* Process info exclusions */
 85:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 86:   if (opt) {
 87:     PetscStrstr(logList,"ds",&className);
 88:     if (className) {
 89:       PetscInfoDeactivateClass(DS_CLASSID);
 90:     }
 91:   }
 92:   /* Process summary exclusions */
 93:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 94:   if (opt) {
 95:     PetscStrstr(logList,"ds",&className);
 96:     if (className) {
 97:       PetscLogEventDeactivateClass(DS_CLASSID);
 98:     }
 99:   }
100:   PetscRegisterFinalize(DSFinalizePackage);
101:   return(0);
102: }

106: /*@
107:    DSCreate - Creates a DS context.

109:    Collective on MPI_Comm

111:    Input Parameter:
112: .  comm - MPI communicator

114:    Output Parameter:
115: .  newds - location to put the DS context

117:    Level: beginner

119:    Note:
120:    DS objects are not intended for normal users but only for
121:    advanced user that for instance implement their own solvers.

123: .seealso: DSDestroy(), DS
124: @*/
125: PetscErrorCode DSCreate(MPI_Comm comm,DS *newds)
126: {
127:   DS             ds;
128:   PetscInt       i;

133:   *newds = 0;
134:   DSInitializePackage();
135:   SlepcHeaderCreate(ds,DS_CLASSID,"DS","Direct Solver (or Dense System)","DS",comm,DSDestroy,DSView);

137:   ds->state         = DS_STATE_RAW;
138:   ds->method        = 0;
139:   ds->compact       = PETSC_FALSE;
140:   ds->refined       = PETSC_FALSE;
141:   ds->extrarow      = PETSC_FALSE;
142:   ds->ld            = 0;
143:   ds->l             = 0;
144:   ds->n             = 0;
145:   ds->m             = 0;
146:   ds->k             = 0;
147:   ds->t             = 0;
148:   ds->bs            = 1;
149:   ds->sc            = NULL;

151:   for (i=0;i<DS_NUM_MAT;i++) {
152:     ds->mat[i]      = NULL;
153:     ds->rmat[i]     = NULL;
154:     ds->omat[i]     = NULL;
155:   }
156:   ds->perm          = NULL;
157:   ds->data          = NULL;
158:   ds->work          = NULL;
159:   ds->rwork         = NULL;
160:   ds->iwork         = NULL;
161:   ds->lwork         = 0;
162:   ds->lrwork        = 0;
163:   ds->liwork        = 0;

165:   *newds = ds;
166:   return(0);
167: }

171: /*@C
172:    DSSetOptionsPrefix - Sets the prefix used for searching for all
173:    DS options in the database.

175:    Logically Collective on DS

177:    Input Parameters:
178: +  ds - the direct solver context
179: -  prefix - the prefix string to prepend to all DS option requests

181:    Notes:
182:    A hyphen (-) must NOT be given at the beginning of the prefix name.
183:    The first character of all runtime options is AUTOMATICALLY the
184:    hyphen.

186:    Level: advanced

188: .seealso: DSAppendOptionsPrefix()
189: @*/
190: PetscErrorCode DSSetOptionsPrefix(DS ds,const char *prefix)
191: {

196:   PetscObjectSetOptionsPrefix((PetscObject)ds,prefix);
197:   return(0);
198: }

202: /*@C
203:    DSAppendOptionsPrefix - Appends to the prefix used for searching for all
204:    DS options in the database.

206:    Logically Collective on DS

208:    Input Parameters:
209: +  ds - the direct solver context
210: -  prefix - the prefix string to prepend to all DS option requests

212:    Notes:
213:    A hyphen (-) must NOT be given at the beginning of the prefix name.
214:    The first character of all runtime options is AUTOMATICALLY the hyphen.

216:    Level: advanced

218: .seealso: DSSetOptionsPrefix()
219: @*/
220: PetscErrorCode DSAppendOptionsPrefix(DS ds,const char *prefix)
221: {

226:   PetscObjectAppendOptionsPrefix((PetscObject)ds,prefix);
227:   return(0);
228: }

232: /*@C
233:    DSGetOptionsPrefix - Gets the prefix used for searching for all
234:    DS options in the database.

236:    Not Collective

238:    Input Parameters:
239: .  ds - the direct solver context

241:    Output Parameters:
242: .  prefix - pointer to the prefix string used is returned

244:    Note:
245:    On the Fortran side, the user should pass in a string 'prefix' of
246:    sufficient length to hold the prefix.

248:    Level: advanced

250: .seealso: DSSetOptionsPrefix(), DSAppendOptionsPrefix()
251: @*/
252: PetscErrorCode DSGetOptionsPrefix(DS ds,const char *prefix[])
253: {

259:   PetscObjectGetOptionsPrefix((PetscObject)ds,prefix);
260:   return(0);
261: }

265: /*@C
266:    DSSetType - Selects the type for the DS object.

268:    Logically Collective on DS

270:    Input Parameter:
271: +  ds   - the direct solver context
272: -  type - a known type

274:    Level: intermediate

276: .seealso: DSGetType()
277: @*/
278: PetscErrorCode DSSetType(DS ds,DSType type)
279: {
280:   PetscErrorCode ierr,(*r)(DS);
281:   PetscBool      match;


287:   PetscObjectTypeCompare((PetscObject)ds,type,&match);
288:   if (match) return(0);

290:    PetscFunctionListFind(DSList,type,&r);
291:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested DS type %s",type);

293:   PetscMemzero(ds->ops,sizeof(struct _DSOps));

295:   PetscObjectChangeTypeName((PetscObject)ds,type);
296:   (*r)(ds);
297:   return(0);
298: }

302: /*@C
303:    DSGetType - Gets the DS type name (as a string) from the DS context.

305:    Not Collective

307:    Input Parameter:
308: .  ds - the direct solver context

310:    Output Parameter:
311: .  name - name of the direct solver

313:    Level: intermediate

315: .seealso: DSSetType()
316: @*/
317: PetscErrorCode DSGetType(DS ds,DSType *type)
318: {
322:   *type = ((PetscObject)ds)->type_name;
323:   return(0);
324: }

328: /*@
329:    DSSetMethod - Selects the method to be used to solve the problem.

331:    Logically Collective on DS

333:    Input Parameter:
334: +  ds   - the direct solver context
335: -  meth - an index indentifying the method

337:    Level: intermediate

339: .seealso: DSGetMethod()
340: @*/
341: PetscErrorCode DSSetMethod(DS ds,PetscInt meth)
342: {
346:   if (meth<0) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The method must be a non-negative integer");
347:   if (meth>DS_MAX_SOLVE) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Too large value for the method");
348:   ds->method = meth;
349:   return(0);
350: }

354: /*@
355:    DSGetMethod - Gets the method currently used in the DS.

357:    Not Collective

359:    Input Parameter:
360: .  ds - the direct solver context

362:    Output Parameter:
363: .  meth - identifier of the method

365:    Level: intermediate

367: .seealso: DSSetMethod()
368: @*/
369: PetscErrorCode DSGetMethod(DS ds,PetscInt *meth)
370: {
374:   *meth = ds->method;
375:   return(0);
376: }

380: /*@
381:    DSSetCompact - Switch to compact storage of matrices.

383:    Logically Collective on DS

385:    Input Parameter:
386: +  ds   - the direct solver context
387: -  comp - a boolean flag

389:    Notes:
390:    Compact storage is used in some DS types such as DSHEP when the matrix
391:    is tridiagonal. This flag can be used to indicate whether the user
392:    provides the matrix entries via the compact form (the tridiagonal DS_MAT_T)
393:    or the non-compact one (DS_MAT_A).

395:    The default is PETSC_FALSE.

397:    Level: advanced

399: .seealso: DSGetCompact()
400: @*/
401: PetscErrorCode DSSetCompact(DS ds,PetscBool comp)
402: {
406:   ds->compact = comp;
407:   return(0);
408: }

412: /*@
413:    DSGetCompact - Gets the compact storage flag.

415:    Not Collective

417:    Input Parameter:
418: .  ds - the direct solver context

420:    Output Parameter:
421: .  comp - the flag

423:    Level: advanced

425: .seealso: DSSetCompact()
426: @*/
427: PetscErrorCode DSGetCompact(DS ds,PetscBool *comp)
428: {
432:   *comp = ds->compact;
433:   return(0);
434: }

438: /*@
439:    DSSetExtraRow - Sets a flag to indicate that the matrix has one extra
440:    row.

442:    Logically Collective on DS

444:    Input Parameter:
445: +  ds  - the direct solver context
446: -  ext - a boolean flag

448:    Notes:
449:    In Krylov methods it is useful that the matrix representing the direct solver
450:    has one extra row, i.e., has dimension (n+1) x n. If this flag is activated, all
451:    transformations applied to the right of the matrix also affect this additional
452:    row. In that case, (n+1) must be less or equal than the leading dimension.

454:    The default is PETSC_FALSE.

456:    Level: advanced

458: .seealso: DSSolve(), DSAllocate(), DSGetExtraRow()
459: @*/
460: PetscErrorCode DSSetExtraRow(DS ds,PetscBool ext)
461: {
465:   if (ds->n>0 && ds->n==ds->ld) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ORDER,"Cannot set extra row after setting n=ld");
466:   ds->extrarow = ext;
467:   return(0);
468: }

472: /*@
473:    DSGetExtraRow - Gets the extra row flag.

475:    Not Collective

477:    Input Parameter:
478: .  ds - the direct solver context

480:    Output Parameter:
481: .  ext - the flag

483:    Level: advanced

485: .seealso: DSSetExtraRow()
486: @*/
487: PetscErrorCode DSGetExtraRow(DS ds,PetscBool *ext)
488: {
492:   *ext = ds->extrarow;
493:   return(0);
494: }

498: /*@
499:    DSSetRefined - Sets a flag to indicate that refined vectors must be
500:    computed.

502:    Logically Collective on DS

504:    Input Parameter:
505: +  ds  - the direct solver context
506: -  ref - a boolean flag

508:    Notes:
509:    Normally the vectors returned in DS_MAT_X are eigenvectors of the
510:    projected matrix. With this flag activated, DSVectors() will return
511:    the right singular vector of the smallest singular value of matrix
512:    \tilde{A}-theta*I, where \tilde{A} is the extended (n+1)xn matrix
513:    and theta is the Ritz value. This is used in the refined Ritz
514:    approximation.

516:    The default is PETSC_FALSE.

518:    Level: advanced

520: .seealso: DSVectors(), DSGetRefined()
521: @*/
522: PetscErrorCode DSSetRefined(DS ds,PetscBool ref)
523: {
527:   ds->refined = ref;
528:   return(0);
529: }

533: /*@
534:    DSGetRefined - Gets the refined vectors flag.

536:    Not Collective

538:    Input Parameter:
539: .  ds - the direct solver context

541:    Output Parameter:
542: .  ref - the flag

544:    Level: advanced

546: .seealso: DSSetRefined()
547: @*/
548: PetscErrorCode DSGetRefined(DS ds,PetscBool *ref)
549: {
553:   *ref = ds->refined;
554:   return(0);
555: }

559: /*@
560:    DSSetBlockSize - Sets the block size.

562:    Logically Collective on DS

564:    Input Parameter:
565: +  ds - the direct solver context
566: -  bs - the block size

568:    Level: intermediate

570: .seealso: DSGetBlockSize()
571: @*/
572: PetscErrorCode DSSetBlockSize(DS ds,PetscInt bs)
573: {
577:   if (bs<1) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The block size must be at least one");
578:   ds->bs = bs;
579:   return(0);
580: }

584: /*@
585:    DSGetBlockSize - Gets the block size.

587:    Not Collective

589:    Input Parameter:
590: .  ds - the direct solver context

592:    Output Parameter:
593: .  bs - block size

595:    Level: intermediate

597: .seealso: DSSetBlockSize()
598: @*/
599: PetscErrorCode DSGetBlockSize(DS ds,PetscInt *bs)
600: {
604:   *bs = ds->bs;
605:   return(0);
606: }

610: /*@C
611:    DSSetSlepcSC - Sets the sorting criterion context.

613:    Not Collective

615:    Input Parameters:
616: +  ds - the direct solver context
617: -  sc - a pointer to the sorting criterion context

619:    Level: developer

621: .seealso: DSGetSlepcSC(), DSSort()
622: @*/
623: PetscErrorCode DSSetSlepcSC(DS ds,SlepcSC sc)
624: {

630:   if (ds->sc) {
631:     PetscFree(ds->sc);
632:   }
633:   ds->sc = sc;
634:   return(0);
635: }

639: /*@C
640:    DSGetSlepcSC - Gets the sorting criterion context.

642:    Not Collective

644:    Input Parameter:
645: .  ds - the direct solver context

647:    Output Parameters:
648: .  sc - a pointer to the sorting criterion context

650:    Level: developer

652: .seealso: DSSetSlepcSC(), DSSort()
653: @*/
654: PetscErrorCode DSGetSlepcSC(DS ds,SlepcSC *sc)
655: {

661:   if (!ds->sc) {
662:     PetscNewLog(ds,&ds->sc);
663:   }
664:   *sc = ds->sc;
665:   return(0);
666: }

670: /*@
671:    DSSetFromOptions - Sets DS options from the options database.

673:    Collective on DS

675:    Input Parameters:
676: .  ds - the direct solver context

678:    Notes:
679:    To see all options, run your program with the -help option.

681:    Level: beginner
682: @*/
683: PetscErrorCode DSSetFromOptions(DS ds)
684: {
686:   PetscInt       bs,meth;
687:   PetscBool      flag;

691:   DSRegisterAll();
692:   /* Set default type (we do not allow changing it with -ds_type) */
693:   if (!((PetscObject)ds)->type_name) {
694:     DSSetType(ds,DSNHEP);
695:   }
696:   PetscObjectOptionsBegin((PetscObject)ds);
697:     PetscOptionsInt("-ds_block_size","Block size for the dense system solver","DSSetBlockSize",ds->bs,&bs,&flag);
698:     if (flag) { DSSetBlockSize(ds,bs); }
699:     PetscOptionsInt("-ds_method","Method to be used for the dense system","DSSetMethod",ds->method,&meth,&flag);
700:     if (flag) { DSSetMethod(ds,meth); }
701:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)ds);
702:   PetscOptionsEnd();
703:   return(0);
704: }

708: /*@C
709:    DSView - Prints the DS data structure.

711:    Collective on DS

713:    Input Parameters:
714: +  ds - the direct solver context
715: -  viewer - optional visualization context

717:    Note:
718:    The available visualization contexts include
719: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
720: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
721:          output where only the first processor opens
722:          the file.  All other processors send their
723:          data to the first processor to print.

725:    The user can open an alternative visualization context with
726:    PetscViewerASCIIOpen() - output to a specified file.

728:    Level: beginner

730: .seealso: DSViewMat()
731: @*/
732: PetscErrorCode DSView(DS ds,PetscViewer viewer)
733: {
734:   PetscBool         isascii,issvd;
735:   const char        *state;
736:   PetscViewerFormat format;
737:   PetscErrorCode    ierr;

741:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)ds));
744:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
745:   if (isascii) {
746:     PetscViewerGetFormat(viewer,&format);
747:     PetscObjectPrintClassNamePrefixType((PetscObject)ds,viewer);
748:     if (format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
749:       switch (ds->state) {
750:         case DS_STATE_RAW:          state = "raw"; break;
751:         case DS_STATE_INTERMEDIATE: state = "intermediate"; break;
752:         case DS_STATE_CONDENSED:    state = "condensed"; break;
753:         case DS_STATE_TRUNCATED:    state = "truncated"; break;
754:         default: SETERRQ(PetscObjectComm((PetscObject)ds),1,"Wrong value of ds->state");
755:       }
756:       PetscViewerASCIIPrintf(viewer,"  current state: %s\n",state);
757:       PetscObjectTypeCompare((PetscObject)ds,DSSVD,&issvd);
758:       if (issvd) {
759:         PetscViewerASCIIPrintf(viewer,"  dimensions: ld=%D, n=%D, m=%D, l=%D, k=%D",ds->ld,ds->n,ds->m,ds->l,ds->k);
760:       } else {
761:         PetscViewerASCIIPrintf(viewer,"  dimensions: ld=%D, n=%D, l=%D, k=%D",ds->ld,ds->n,ds->l,ds->k);
762:       }
763:       if (ds->state==DS_STATE_TRUNCATED) {
764:         PetscViewerASCIIPrintf(viewer,", t=%D\n",ds->t);
765:       } else {
766:         PetscViewerASCIIPrintf(viewer,"\n");
767:       }
768:       PetscViewerASCIIPrintf(viewer,"  flags:%s%s%s\n",ds->compact?" compact":"",ds->extrarow?" extrarow":"",ds->refined?" refined":"");
769:     }
770:     if (ds->ops->view) {
771:       PetscViewerASCIIPushTab(viewer);
772:       (*ds->ops->view)(ds,viewer);
773:       PetscViewerASCIIPopTab(viewer);
774:     }
775:   }
776:   return(0);
777: }

781: /*@
782:    DSAllocate - Allocates memory for internal storage or matrices in DS.

784:    Logically Collective on DS

786:    Input Parameters:
787: +  ds - the direct solver context
788: -  ld - leading dimension (maximum allowed dimension for the matrices, including
789:         the extra row if present)

791:    Level: intermediate

793: .seealso: DSGetLeadingDimension(), DSSetDimensions(), DSSetExtraRow()
794: @*/
795: PetscErrorCode DSAllocate(DS ds,PetscInt ld)
796: {

802:   if (ld<1) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Leading dimension should be at least one");
803:   ds->ld = ld;
804:   (*ds->ops->allocate)(ds,ld);
805:   return(0);
806: }

810: /*@
811:    DSReset - Resets the DS context to the initial state.

813:    Collective on DS

815:    Input Parameter:
816: .  ds - the direct solver context

818:    Level: advanced

820: .seealso: DSDestroy()
821: @*/
822: PetscErrorCode DSReset(DS ds)
823: {
824:   PetscInt       i;

829:   ds->state    = DS_STATE_RAW;
830:   ds->compact  = PETSC_FALSE;
831:   ds->refined  = PETSC_FALSE;
832:   ds->extrarow = PETSC_FALSE;
833:   ds->ld       = 0;
834:   ds->l        = 0;
835:   ds->n        = 0;
836:   ds->m        = 0;
837:   ds->k        = 0;
838:   for (i=0;i<DS_NUM_MAT;i++) {
839:     PetscFree(ds->mat[i]);
840:     PetscFree(ds->rmat[i]);
841:     MatDestroy(&ds->omat[i]);
842:   }
843:   PetscFree(ds->perm);
844:   PetscFree(ds->work);
845:   PetscFree(ds->rwork);
846:   PetscFree(ds->iwork);
847:   ds->lwork         = 0;
848:   ds->lrwork        = 0;
849:   ds->liwork        = 0;
850:   return(0);
851: }

855: /*@
856:    DSDestroy - Destroys DS context that was created with DSCreate().

858:    Collective on DS

860:    Input Parameter:
861: .  ds - the direct solver context

863:    Level: beginner

865: .seealso: DSCreate()
866: @*/
867: PetscErrorCode DSDestroy(DS *ds)
868: {

872:   if (!*ds) return(0);
874:   if (--((PetscObject)(*ds))->refct > 0) { *ds = 0; return(0); }
875:   DSReset(*ds);
876:   if ((*ds)->ops->destroy) { (*(*ds)->ops->destroy)(*ds); }
877:   PetscFree((*ds)->sc);
878:   PetscHeaderDestroy(ds);
879:   return(0);
880: }

884: /*@C
885:    DSRegister - Adds a direct solver to the DS package.

887:    Not collective

889:    Input Parameters:
890: +  name - name of a new user-defined DS
891: -  routine_create - routine to create context

893:    Notes:
894:    DSRegister() may be called multiple times to add several user-defined
895:    direct solvers.

897:    Level: advanced

899: .seealso: DSRegisterAll()
900: @*/
901: PetscErrorCode DSRegister(const char *name,PetscErrorCode (*function)(DS))
902: {

906:   PetscFunctionListAdd(&DSList,name,function);
907:   return(0);
908: }

910: PETSC_EXTERN PetscErrorCode DSCreate_HEP(DS);
911: PETSC_EXTERN PetscErrorCode DSCreate_NHEP(DS);
912: PETSC_EXTERN PetscErrorCode DSCreate_GHEP(DS);
913: PETSC_EXTERN PetscErrorCode DSCreate_GHIEP(DS);
914: PETSC_EXTERN PetscErrorCode DSCreate_GNHEP(DS);
915: PETSC_EXTERN PetscErrorCode DSCreate_SVD(DS);
916: PETSC_EXTERN PetscErrorCode DSCreate_PEP(DS);
917: PETSC_EXTERN PetscErrorCode DSCreate_NEP(DS);

921: /*@C
922:    DSRegisterAll - Registers all of the direct solvers in the DS package.

924:    Not Collective

926:    Level: advanced
927: @*/
928: PetscErrorCode DSRegisterAll(void)
929: {

933:   if (DSRegisterAllCalled) return(0);
934:   DSRegisterAllCalled = PETSC_TRUE;
935:   DSRegister(DSHEP,DSCreate_HEP);
936:   DSRegister(DSNHEP,DSCreate_NHEP);
937:   DSRegister(DSGHEP,DSCreate_GHEP);
938:   DSRegister(DSGHIEP,DSCreate_GHIEP);
939:   DSRegister(DSGNHEP,DSCreate_GNHEP);
940:   DSRegister(DSSVD,DSCreate_SVD);
941:   DSRegister(DSPEP,DSCreate_PEP);
942:   DSRegister(DSNEP,DSCreate_NEP);
943:   return(0);
944: }

slepc-3.7.4/src/sys/classes/ds/examples/0000755000175000017500000000000013107004621017451 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/examples/makefile0000644000175000017500000000202013107004621021143 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/sys/classes/ds/examples/ DIRS = tests include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/examples/makefile.html0000644000175000017500000000445313107004621022122 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/sys/classes/ds/examples/
DIRS     = tests

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/ds/examples/index.html0000644000175000017500000000124013107004621021443 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
makefile
slepc-3.7.4/src/sys/classes/ds/examples/tests/0000755000175000017500000000000013107004621020613 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/examples/tests/makefile0000644000175000017500000001403313107004621022314 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/sys/classes/ds/examples/tests/ EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c \ test12.c test13.c test15.c EXAMPLESF = test14f.F MANSEC = DS TESTS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test12 test13 \ test14f test15 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \ test2.PETSc runtest2_1 test2.rm \ test3.PETSc runtest3_1 test3.rm \ test4.PETSc runtest4_1 test4.rm \ test5.PETSc runtest5_1 test5.rm \ test6.PETSc runtest6_1 test6.rm \ test7.PETSc runtest7_1 test7.rm \ test8.PETSc runtest8_1 test8.rm \ test9.PETSc runtest9_1 test9.rm \ test12.PETSc runtest12_1 test12.rm \ test15.PETSc runtest15_1 test15.rm TESTEXAMPLES_C_NOCOMPLEX = test13.PETSc runtest13_1 test13.rm TESTEXAMPLES_FORTRAN = test14f.PETSc runtest14f_1 test14f.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB} ${RM} test1.o test2: test2.o chkopts -${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB} ${RM} test2.o test3: test3.o chkopts -${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB} ${RM} test3.o test4: test4.o chkopts -${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB} ${RM} test4.o test5: test5.o chkopts -${CLINKER} -o test5 test5.o ${SLEPC_SYS_LIB} ${RM} test5.o test6: test6.o chkopts -${CLINKER} -o test6 test6.o ${SLEPC_SYS_LIB} ${RM} test6.o test7: test7.o chkopts -${CLINKER} -o test7 test7.o ${SLEPC_SYS_LIB} ${RM} test7.o test8: test8.o chkopts -${CLINKER} -o test8 test8.o ${SLEPC_SYS_LIB} ${RM} test8.o test9: test9.o chkopts -${CLINKER} -o test9 test9.o ${SLEPC_SYS_LIB} ${RM} test9.o test12: test12.o chkopts -${CLINKER} -o test12 test12.o ${SLEPC_SYS_LIB} ${RM} test12.o test13: test13.o chkopts -${CLINKER} -o test13 test13.o ${SLEPC_SYS_LIB} ${RM} test13.o test14f: test14f.o chkopts -${FLINKER} -o test14f test14f.o ${SLEPC_SYS_LIB} ${RM} test14f.o test15: test15.o chkopts -${CLINKER} -o test15 test15.o ${SLEPC_SYS_LIB} ${RM} test15.o #------------------------------------------------------------------------------------ runtest1_1: -@${MPIEXEC} -n 1 ./test1 > test1_1.tmp 2>&1; \ if (${DIFF} output/test1_1.out test1_1.tmp) then true; \ else echo "Possible problem with test1_1, diffs above"; fi; \ ${RM} -f test1_1.tmp runtest2_1: -@${MPIEXEC} -n 1 ./test2 -n 12 > test2_1.tmp 2>&1; \ if (${DIFF} output/test2_1.out test2_1.tmp) then true; \ else echo "Possible problem with test2_1, diffs above"; fi; \ ${RM} -f test2_1.tmp runtest3_1: -@${MPIEXEC} -n 1 ./test3 > test3_1.tmp 2>&1; \ if (${DIFF} output/test3_1.out test3_1.tmp) then true; \ else echo "Possible problem with test3_1, diffs above"; fi; \ ${RM} -f test3_1.tmp runtest4_1: -@${MPIEXEC} -n 1 ./test4 > test4_1.tmp 2>&1; \ if (${DIFF} output/test4_1.out test4_1.tmp) then true; \ else echo "Possible problem with test4_1, diffs above"; fi; \ ${RM} -f test4_1.tmp runtest5_1: -@${MPIEXEC} -n 1 ./test5 > test5_1.tmp 2>&1; \ if (${DIFF} output/test5_1.out test5_1.tmp) then true; \ else echo "Possible problem with test5_1, diffs above"; fi; \ ${RM} -f test5_1.tmp runtest6_1: -@${MPIEXEC} -n 1 ./test6 > test6_1.tmp 2>&1; \ if (${DIFF} output/test6_1.out test6_1.tmp) then true; \ else echo "Possible problem with test6_1, diffs above"; fi; \ ${RM} -f test6_1.tmp runtest7_1: -@${MPIEXEC} -n 1 ./test7 > test7_1.tmp 2>&1; \ if (${DIFF} output/test7_1.out test7_1.tmp) then true; \ else echo "Possible problem with test7_1, diffs above"; fi; \ ${RM} -f test7_1.tmp runtest8_1: -@${MPIEXEC} -n 1 ./test8 > test8_1.tmp 2>&1; \ if (${DIFF} output/test8_1.out test8_1.tmp) then true; \ else echo "Possible problem with test8_1, diffs above"; fi; \ ${RM} -f test8_1.tmp runtest9_1: -@${MPIEXEC} -n 1 ./test9 > test9_1.tmp 2>&1; \ if (${DIFF} output/test9_1.out test9_1.tmp) then true; \ else echo "Possible problem with test9_1, diffs above"; fi; \ ${RM} -f test9_1.tmp runtest12_1: -@${MPIEXEC} -n 1 ./test12 > test12_1.tmp 2>&1; \ if (${DIFF} output/test12_1.out test12_1.tmp) then true; \ else echo "Possible problem with test12_1, diffs above"; fi; \ ${RM} -f test12_1.tmp runtest13_1: -@${MPIEXEC} -n 1 ./test13 > test13_1.tmp 2>&1; \ if (${DIFF} output/test13_1.out test13_1.tmp) then true; \ else echo "Possible problem with test13_1, diffs above"; fi; \ ${RM} -f test13_1.tmp runtest14f_1: -@${MPIEXEC} -n 1 ./test14f > test14f_1.tmp 2>&1; \ if (${DIFF} output/test14f_1.out test14f_1.tmp) then true; \ else echo "Possible problem with test14f_1, diffs above"; fi; \ ${RM} -f test14f_1.tmp runtest15_1: -@${MPIEXEC} -n 1 ./test15 > test15_1.tmp 2>&1; \ if (${DIFF} output/test15_1.out test15_1.tmp) then true; \ else echo "Possible problem with test15_1, diffs above"; fi; \ ${RM} -f test15_1.tmp slepc-3.7.4/src/sys/classes/ds/examples/tests/test4.c.html0000644000175000017500000002742213107004621022774 0ustar jromanjroman

Actual source code: test4.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSGNHEP.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscScalar    *A,*B,*X,*wr,*wi;
 34:   PetscReal      re,im,rnorm,aux;
 35:   PetscInt       i,j,n=10,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type GNHEP - dimension %D.\n",n);
 42:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 44:   /* Create DS object */
 45:   DSCreate(PETSC_COMM_WORLD,&ds);
 46:   DSSetType(ds,DSGNHEP);
 47:   DSSetFromOptions(ds);
 48:   ld = n+2;  /* test leading dimension larger than n */
 49:   DSAllocate(ds,ld);
 50:   DSSetDimensions(ds,n,0,0,0);

 52:   /* Set up viewer */
 53:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 54:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 55:   DSView(ds,viewer);
 56:   PetscViewerPopFormat(viewer);
 57:   if (verbose) {
 58:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 59:   }

 61:   /* Fill A with Grcar matrix */
 62:   DSGetArray(ds,DS_MAT_A,&A);
 63:   PetscMemzero(A,sizeof(PetscScalar)*ld*n);
 64:   for (i=1;i<n;i++) A[i+(i-1)*ld]=-1.0;
 65:   for (j=0;j<4;j++) {
 66:     for (i=0;i<n-j;i++) A[i+(i+j)*ld]=1.0;
 67:   }
 68:   DSRestoreArray(ds,DS_MAT_A,&A);
 69:   /* Fill B with an identity matrix */
 70:   DSGetArray(ds,DS_MAT_B,&B);
 71:   PetscMemzero(B,sizeof(PetscScalar)*ld*n);
 72:   for (i=0;i<n;i++) B[i+i*ld]=1.0;
 73:   DSRestoreArray(ds,DS_MAT_B,&B);

 75:   if (verbose) {
 76:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 77:     DSView(ds,viewer);
 78:   }

 80:   /* Solve */
 81:   PetscMalloc2(n,&wr,n,&wi);
 82:   DSGetSlepcSC(ds,&sc);
 83:   sc->comparison    = SlepcCompareLargestMagnitude;
 84:   sc->comparisonctx = NULL;
 85:   sc->map           = NULL;
 86:   sc->mapobj        = NULL;
 87:   DSSolve(ds,wr,wi);
 88:   DSSort(ds,wr,wi,NULL,NULL,NULL);
 89:   if (verbose) {
 90:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 91:     DSView(ds,viewer);
 92:   }

 94:   /* Print eigenvalues */
 95:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
 96:   for (i=0;i<n;i++) {
 97: #if defined(PETSC_USE_COMPLEX)
 98:     re = PetscRealPart(wr[i]);
 99:     im = PetscImaginaryPart(wr[i]);
100: #else
101:     re = wr[i];
102:     im = wi[i];
103: #endif
104:     if (PetscAbs(im)<1e-10) {
105:       PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)re);
106:     } else {
107:       PetscViewerASCIIPrintf(viewer,"  %.5f%+.5fi\n",(double)re,(double)im);
108:     }
109:   }

111:   /* Eigenvectors */
112:   j = 2;
113:   DSVectors(ds,DS_MAT_X,&j,&rnorm);  /* third eigenvector */
114:   PetscPrintf(PETSC_COMM_WORLD,"Value of rnorm for 3rd vector = %.3f\n",(double)rnorm);
115:   DSVectors(ds,DS_MAT_X,NULL,NULL);  /* all eigenvectors */
116:   j = 0;
117:   rnorm = 0.0;
118:   DSGetArray(ds,DS_MAT_X,&X);
119:   for (i=0;i<n;i++) {
120: #if defined(PETSC_USE_COMPLEX)
121:     aux = PetscAbsScalar(X[i+j*ld]);
122: #else
123:     if (PetscAbs(wi[j])==0.0) aux = PetscAbsScalar(X[i+j*ld]);
124:     else aux = SlepcAbsEigenvalue(X[i+j*ld],X[i+(j+1)*ld]);
125: #endif
126:     rnorm += aux*aux;
127:   }
128:   DSRestoreArray(ds,DS_MAT_X,&X);
129:   rnorm = PetscSqrtReal(rnorm);
130:   PetscPrintf(PETSC_COMM_WORLD,"Norm of 1st vector = %.3f\n",(double)rnorm);
131:   if (verbose) {
132:     PetscPrintf(PETSC_COMM_WORLD,"After vectors - - - - - - - - -\n");
133:     DSView(ds,viewer);
134:   }

136:   PetscFree2(wr,wi);
137:   DSDestroy(&ds);
138:   SlepcFinalize();
139:   return ierr;
140: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test9.c.html0000644000175000017500000002172613107004621023002 0ustar jromanjroman
Actual source code: test9.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSGHEP.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscReal      re;
 34:   PetscScalar    *A,*B,*eig;
 35:   PetscInt       i,j,n=10,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a System of type GHEP - dimension %D.\n",n);
 42:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 44:   /* Create DS object */
 45:   DSCreate(PETSC_COMM_WORLD,&ds);
 46:   DSSetType(ds,DSGHEP);
 47:   DSSetFromOptions(ds);
 48:   ld = n+2;  /* test leading dimension larger than n */
 49:   DSAllocate(ds,ld);
 50:   DSSetDimensions(ds,n,0,0,0);

 52:   /* Set up viewer */
 53:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 54:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 55:   DSView(ds,viewer);
 56:   PetscViewerPopFormat(viewer);
 57:   if (verbose) {
 58:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 59:   }

 61:   /* Fill with a symmetric Toeplitz matrix */
 62:   DSGetArray(ds,DS_MAT_A,&A);
 63:   DSGetArray(ds,DS_MAT_B,&B);
 64:   for (i=0;i<n;i++) A[i+i*ld]=2.0;
 65:   for (j=1;j<3;j++) {
 66:     for (i=0;i<n-j;i++) { A[i+(i+j)*ld]=1.0; A[(i+j)+i*ld]=1.0; }
 67:   }
 68:   for (j=1;j<3;j++) { A[0+j*ld]=-1.0*(j+2); A[j+0*ld]=-1.0*(j+2); }
 69:   /* Diagonal matrix */
 70:   for (i=0;i<n;i++) B[i+i*ld]=0.1*(i+1);
 71:   DSRestoreArray(ds,DS_MAT_A,&A);
 72:   DSRestoreArray(ds,DS_MAT_B,&B);
 73:   DSSetState(ds,DS_STATE_RAW);
 74:   if (verbose) {
 75:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 76:     DSView(ds,viewer);
 77:   }

 79:   /* Solve */
 80:   PetscMalloc1(n,&eig);
 81:   DSGetSlepcSC(ds,&sc);
 82:   sc->comparison    = SlepcCompareLargestMagnitude;
 83:   sc->comparisonctx = NULL;
 84:   sc->map           = NULL;
 85:   sc->mapobj        = NULL;
 86:   DSSolve(ds,eig,NULL);
 87:   DSSort(ds,eig,NULL,NULL,NULL,NULL);
 88:   if (verbose) {
 89:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 90:     DSView(ds,viewer);
 91:   }

 93:   /* Print eigenvalues */
 94:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
 95:   for (i=0;i<n;i++) {
 96:     re = PetscRealPart(eig[i]);
 97:     PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)re);
 98:   }
 99:   PetscFree(eig);
100:   DSDestroy(&ds);
101:   SlepcFinalize();
102:   return ierr;
103: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test4.c0000644000175000017500000001174713107004621022034 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSGNHEP.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscScalar *A,*B,*X,*wr,*wi; PetscReal re,im,rnorm,aux; PetscInt i,j,n=10,ld; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type GNHEP - dimension %D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSGNHEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill A with Grcar matrix */ ierr = DSGetArray(ds,DS_MAT_A,&A);CHKERRQ(ierr); ierr = PetscMemzero(A,sizeof(PetscScalar)*ld*n);CHKERRQ(ierr); for (i=1;icomparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,wr,wi);CHKERRQ(ierr); ierr = DSSort(ds,wr,wi,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;iActual source code: test1.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSNHEP.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscScalar    *A,*X,*wr,*wi;
 34:   PetscReal      re,im,rnorm,aux;
 35:   PetscInt       i,j,n=10,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose,extrarow;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type NHEP - dimension %D.\n",n);
 42:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 43:   PetscOptionsHasName(NULL,NULL,"-extrarow",&extrarow);

 45:   /* Create DS object */
 46:   DSCreate(PETSC_COMM_WORLD,&ds);
 47:   DSSetType(ds,DSNHEP);
 48:   DSSetFromOptions(ds);
 49:   ld = n+2;  /* test leading dimension larger than n */
 50:   DSAllocate(ds,ld);
 51:   DSSetDimensions(ds,n,0,0,0);
 52:   DSSetExtraRow(ds,extrarow);

 54:   /* Set up viewer */
 55:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 56:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 57:   DSView(ds,viewer);
 58:   PetscViewerPopFormat(viewer);
 59:   if (verbose) {
 60:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 61:   }

 63:   /* Fill with Grcar matrix */
 64:   DSGetArray(ds,DS_MAT_A,&A);
 65:   for (i=1;i<n;i++) A[i+(i-1)*ld]=-1.0;
 66:   for (j=0;j<4;j++) {
 67:     for (i=0;i<n-j;i++) A[i+(i+j)*ld]=1.0;
 68:   }
 69:   if (extrarow) A[n+(n-1)*ld]=-1.0;
 70:   DSRestoreArray(ds,DS_MAT_A,&A);
 71:   DSSetState(ds,DS_STATE_INTERMEDIATE);
 72:   if (verbose) {
 73:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 74:     DSView(ds,viewer);
 75:   }

 77:   /* Solve */
 78:   PetscMalloc2(n,&wr,n,&wi);
 79:   DSGetSlepcSC(ds,&sc);
 80:   sc->comparison    = SlepcCompareLargestMagnitude;
 81:   sc->comparisonctx = NULL;
 82:   sc->map           = NULL;
 83:   sc->mapobj        = NULL;
 84:   DSSolve(ds,wr,wi);
 85:   DSSort(ds,wr,wi,NULL,NULL,NULL);
 86:   if (extrarow) { DSUpdateExtraRow(ds); }
 87:   if (verbose) {
 88:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 89:     DSView(ds,viewer);
 90:   }

 92:   /* Print eigenvalues */
 93:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
 94:   for (i=0;i<n;i++) {
 95: #if defined(PETSC_USE_COMPLEX)
 96:     re = PetscRealPart(wr[i]);
 97:     im = PetscImaginaryPart(wr[i]);
 98: #else
 99:     re = wr[i];
100:     im = wi[i];
101: #endif
102:     if (PetscAbs(im)<1e-10) {
103:       PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)re);
104:     } else {
105:       PetscViewerASCIIPrintf(viewer,"  %.5f%+.5fi\n",(double)re,(double)im);
106:     }
107:   }

109:   /* Eigenvectors */
110:   j = 2;
111:   DSVectors(ds,DS_MAT_X,&j,&rnorm);  /* third eigenvector */
112:   PetscPrintf(PETSC_COMM_WORLD,"Value of rnorm for 3rd vector = %.3f\n",(double)rnorm);
113:   DSVectors(ds,DS_MAT_X,NULL,NULL);  /* all eigenvectors */
114:   j = 0;
115:   rnorm = 0.0;
116:   DSGetArray(ds,DS_MAT_X,&X);
117:   for (i=0;i<n;i++) {
118: #if defined(PETSC_USE_COMPLEX)
119:     aux = PetscAbsScalar(X[i+j*ld]);
120: #else
121:     if (PetscAbs(wi[j])==0.0) aux = PetscAbsScalar(X[i+j*ld]);
122:     else aux = SlepcAbsEigenvalue(X[i+j*ld],X[i+(j+1)*ld]);
123: #endif
124:     rnorm += aux*aux;
125:   }
126:   DSRestoreArray(ds,DS_MAT_X,&X);
127:   rnorm = PetscSqrtReal(rnorm);
128:   PetscPrintf(PETSC_COMM_WORLD,"Norm of 1st vector = %.3f\n",(double)rnorm);
129:   if (verbose) {
130:     PetscPrintf(PETSC_COMM_WORLD,"After vectors - - - - - - - - -\n");
131:     DSView(ds,viewer);
132:   }

134:   PetscFree2(wr,wi);
135:   DSDestroy(&ds);
136:   SlepcFinalize();
137:   return ierr;
138: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test12.c.html0000644000175000017500000002770413107004621023056 0ustar jromanjroman
Actual source code: test12.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSNEP.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   FN             f1,f2,f3,funs[3];
 33:   PetscScalar    *Id,*A,*B,*wr,*wi,coeffs[2];
 34:   PetscReal      tau=0.001,h,a=20,xi,re,im;
 35:   PetscInt       i,n=10,ld,nev;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscOptionsGetReal(NULL,NULL,"-tau",&tau,NULL);
 42:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type NEP - dimension %D, tau=%g.\n",n,(double)tau);
 43:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 45:   /* Create DS object */
 46:   DSCreate(PETSC_COMM_WORLD,&ds);
 47:   DSSetType(ds,DSNEP);
 48:   DSSetFromOptions(ds);

 50:   /* Set functions (prior to DSAllocate) */
 51:   FNCreate(PETSC_COMM_WORLD,&f1);
 52:   FNSetType(f1,FNRATIONAL);
 53:   coeffs[0] = -1.0; coeffs[1] = 0.0;
 54:   FNRationalSetNumerator(f1,2,coeffs);

 56:   FNCreate(PETSC_COMM_WORLD,&f2);
 57:   FNSetType(f2,FNRATIONAL);
 58:   coeffs[0] = 1.0;
 59:   FNRationalSetNumerator(f2,1,coeffs);

 61:   FNCreate(PETSC_COMM_WORLD,&f3);
 62:   FNSetType(f3,FNEXP);
 63:   FNSetScale(f3,-tau,1.0);

 65:   funs[0] = f1;
 66:   funs[1] = f2;
 67:   funs[2] = f3;
 68:   DSNEPSetFN(ds,3,funs);

 70:   /* Set dimensions */
 71:   ld = n+2;  /* test leading dimension larger than n */
 72:   DSAllocate(ds,ld);
 73:   DSSetDimensions(ds,n,0,0,0);

 75:   /* Set up viewer */
 76:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 77:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 78:   DSView(ds,viewer);
 79:   PetscViewerPopFormat(viewer);
 80:   if (verbose) {
 81:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 82:   }

 84:   /* Fill matrices */
 85:   DSGetArray(ds,DS_MAT_E0,&Id);
 86:   for (i=0;i<n;i++) Id[i+i*ld]=1.0;
 87:   DSRestoreArray(ds,DS_MAT_E0,&Id);
 88:   h = PETSC_PI/(PetscReal)(n+1);
 89:   DSGetArray(ds,DS_MAT_E1,&A);
 90:   for (i=0;i<n;i++) A[i+i*ld]=-2.0/(h*h)+a;
 91:   for (i=1;i<n;i++) {
 92:     A[i+(i-1)*ld]=1.0/(h*h);
 93:     A[(i-1)+i*ld]=1.0/(h*h);
 94:   }
 95:   DSRestoreArray(ds,DS_MAT_E1,&A);
 96:   DSGetArray(ds,DS_MAT_E2,&B);
 97:   for (i=0;i<n;i++) {
 98:     xi = (i+1)*h;
 99:     B[i+i*ld] = -4.1+xi*(1.0-PetscExpReal(xi-PETSC_PI));
100:   }
101:   DSRestoreArray(ds,DS_MAT_E2,&B);

103:   if (verbose) {
104:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
105:     DSView(ds,viewer);
106:   }

108:   /* Solve */
109:   PetscMalloc2(n,&wr,n,&wi);
110:   DSSolve(ds,wr,wi);
111:   if (verbose) {
112:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
113:     DSView(ds,viewer);
114:   }

116:   /* Print first eigenvalue */
117:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalue =\n");
118:   nev = 1;
119:   for (i=0;i<nev;i++) {
120: #if defined(PETSC_USE_COMPLEX)
121:     re = PetscRealPart(wr[i]);
122:     im = PetscImaginaryPart(wr[i]);
123: #else
124:     re = wr[i];
125:     im = wi[i];
126: #endif
127:     if (PetscAbs(im)<1e-10) {
128:       PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)re);
129:     } else {
130:       PetscViewerASCIIPrintf(viewer,"  %.5f%+.5fi\n",(double)re,(double)im);
131:     }
132:   }

134:   PetscFree2(wr,wi);
135:   FNDestroy(&f1);
136:   FNDestroy(&f2);
137:   FNDestroy(&f3);
138:   DSDestroy(&ds);
139:   SlepcFinalize();
140:   return ierr;
141: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test15.c0000644000175000017500000001024013107004621022101 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSPEP.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscScalar *K,*C,*M,*wr,*wi,z=1.0; PetscReal re,im; PetscInt i,n=10,d=2,ld; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type PEP - n=%D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSPEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ierr = DSPEPSetDegree(ds,d);CHKERRQ(ierr); /* Set dimensions */ ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill matrices */ ierr = DSGetArray(ds,DS_MAT_E0,&K);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestReal; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,wr,wi);CHKERRQ(ierr); ierr = DSSort(ds,wr,wi,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print first eigenvalue */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSHEP with block size larger than one.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscScalar *A,*eig; PetscInt i,j,n,ld,bs,maxbw=3,nblks=8; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-maxbw",&maxbw,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-nblks",&nblks,NULL);CHKERRQ(ierr); n = maxbw*nblks; bs = maxbw; ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a block HEP Dense System - dimension %D (bandwidth=%D, blocks=%D).\n",n,maxbw,nblks);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSHEP);CHKERRQ(ierr); ierr = DSSetMethod(ds,3);CHKERRQ(ierr); /* Select block divide-and-conquer */ ierr = DSSetBlockSize(ds,bs);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n; ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill with a symmetric band Toeplitz matrix */ ierr = DSGetArray(ds,DS_MAT_A,&A);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareSmallestReal; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,eig,NULL);CHKERRQ(ierr); ierr = DSSort(ds,eig,NULL,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/sys/classes/ds/examples/tests/
EXAMPLESC  = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c \
             test12.c test13.c test15.c
EXAMPLESF  = test14f.F
MANSEC     = DS
TESTS      = test1 test2 test3 test4 test5 test6 test7 test8 test9 test12 test13 \
             test14f test15

TESTEXAMPLES_C           = test1.PETSc runtest1_1 test1.rm \
                           test2.PETSc runtest2_1 test2.rm \
                           test3.PETSc runtest3_1 test3.rm \
                           test4.PETSc runtest4_1 test4.rm \
                           test5.PETSc runtest5_1 test5.rm \
                           test6.PETSc runtest6_1 test6.rm \
                           test7.PETSc runtest7_1 test7.rm \
                           test8.PETSc runtest8_1 test8.rm \
                           test9.PETSc runtest9_1 test9.rm \
                           test12.PETSc runtest12_1 test12.rm \
                           test15.PETSc runtest15_1 test15.rm
TESTEXAMPLES_C_NOCOMPLEX = test13.PETSc runtest13_1 test13.rm
TESTEXAMPLES_FORTRAN     = test14f.PETSc runtest14f_1 test14f.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB}
	${RM} test1.o

test2: test2.o chkopts
	-${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB}
	${RM} test2.o

test3: test3.o chkopts
	-${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB}
	${RM} test3.o

test4: test4.o chkopts
	-${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB}
	${RM} test4.o

test5: test5.o chkopts
	-${CLINKER} -o test5 test5.o ${SLEPC_SYS_LIB}
	${RM} test5.o

test6: test6.o chkopts
	-${CLINKER} -o test6 test6.o ${SLEPC_SYS_LIB}
	${RM} test6.o

test7: test7.o chkopts
	-${CLINKER} -o test7 test7.o ${SLEPC_SYS_LIB}
	${RM} test7.o

test8: test8.o chkopts
	-${CLINKER} -o test8 test8.o ${SLEPC_SYS_LIB}
	${RM} test8.o

test9: test9.o chkopts
	-${CLINKER} -o test9 test9.o ${SLEPC_SYS_LIB}
	${RM} test9.o

test12: test12.o chkopts
	-${CLINKER} -o test12 test12.o ${SLEPC_SYS_LIB}
	${RM} test12.o

test13: test13.o chkopts
	-${CLINKER} -o test13 test13.o ${SLEPC_SYS_LIB}
	${RM} test13.o

test14f: test14f.o chkopts
	-${FLINKER} -o test14f test14f.o ${SLEPC_SYS_LIB}
	${RM} test14f.o

test15: test15.o chkopts
	-${CLINKER} -o test15 test15.o ${SLEPC_SYS_LIB}
	${RM} test15.o

#------------------------------------------------------------------------------------

runtest1_1:
	-@${MPIEXEC} -n 1 ./test1 > test1_1.tmp 2>&1; \
	  if (${DIFF} output/test1_1.out test1_1.tmp) then true; \
	  else echo "Possible problem with test1_1, diffs above"; fi; \
	  ${RM} -f test1_1.tmp

runtest2_1:
	-@${MPIEXEC} -n 1 ./test2 -n 12 > test2_1.tmp 2>&1; \
	  if (${DIFF} output/test2_1.out test2_1.tmp) then true; \
	  else echo "Possible problem with test2_1, diffs above"; fi; \
	  ${RM} -f test2_1.tmp

runtest3_1:
	-@${MPIEXEC} -n 1 ./test3 > test3_1.tmp 2>&1; \
	  if (${DIFF} output/test3_1.out test3_1.tmp) then true; \
	  else echo "Possible problem with test3_1, diffs above"; fi; \
	  ${RM} -f test3_1.tmp

runtest4_1:
	-@${MPIEXEC} -n 1 ./test4 > test4_1.tmp 2>&1; \
	  if (${DIFF} output/test4_1.out test4_1.tmp) then true; \
	  else echo "Possible problem with test4_1, diffs above"; fi; \
	  ${RM} -f test4_1.tmp

runtest5_1:
	-@${MPIEXEC} -n 1 ./test5 > test5_1.tmp 2>&1; \
	  if (${DIFF} output/test5_1.out test5_1.tmp) then true; \
	  else echo "Possible problem with test5_1, diffs above"; fi; \
	  ${RM} -f test5_1.tmp

runtest6_1:
	-@${MPIEXEC} -n 1 ./test6 > test6_1.tmp 2>&1; \
	  if (${DIFF} output/test6_1.out test6_1.tmp) then true; \
	  else echo "Possible problem with test6_1, diffs above"; fi; \
	  ${RM} -f test6_1.tmp

runtest7_1:
	-@${MPIEXEC} -n 1 ./test7 > test7_1.tmp 2>&1; \
	  if (${DIFF} output/test7_1.out test7_1.tmp) then true; \
	  else echo "Possible problem with test7_1, diffs above"; fi; \
	  ${RM} -f test7_1.tmp

runtest8_1:
	-@${MPIEXEC} -n 1 ./test8 > test8_1.tmp 2>&1; \
	  if (${DIFF} output/test8_1.out test8_1.tmp) then true; \
	  else echo "Possible problem with test8_1, diffs above"; fi; \
	  ${RM} -f test8_1.tmp

runtest9_1:
	-@${MPIEXEC} -n 1 ./test9 > test9_1.tmp 2>&1; \
	  if (${DIFF} output/test9_1.out test9_1.tmp) then true; \
	  else echo "Possible problem with test9_1, diffs above"; fi; \
	  ${RM} -f test9_1.tmp

runtest12_1:
	-@${MPIEXEC} -n 1 ./test12 > test12_1.tmp 2>&1; \
	  if (${DIFF} output/test12_1.out test12_1.tmp) then true; \
	  else echo "Possible problem with test12_1, diffs above"; fi; \
	  ${RM} -f test12_1.tmp

runtest13_1:
	-@${MPIEXEC} -n 1 ./test13 > test13_1.tmp 2>&1; \
	  if (${DIFF} output/test13_1.out test13_1.tmp) then true; \
	  else echo "Possible problem with test13_1, diffs above"; fi; \
	  ${RM} -f test13_1.tmp

runtest14f_1:
	-@${MPIEXEC} -n 1 ./test14f > test14f_1.tmp 2>&1; \
	  if (${DIFF} output/test14f_1.out test14f_1.tmp) then true; \
	  else echo "Possible problem with test14f_1, diffs above"; fi; \
	  ${RM} -f test14f_1.tmp

runtest15_1:
	-@${MPIEXEC} -n 1 ./test15 > test15_1.tmp 2>&1; \
	  if (${DIFF} output/test15_1.out test15_1.tmp) then true; \
	  else echo "Possible problem with test15_1, diffs above"; fi; \
	  ${RM} -f test15_1.tmp

slepc-3.7.4/src/sys/classes/ds/examples/tests/test1.c0000644000175000017500000001172113107004621022021 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSNHEP.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscScalar *A,*X,*wr,*wi; PetscReal re,im,rnorm,aux; PetscInt i,j,n=10,ld; PetscViewer viewer; PetscBool verbose,extrarow; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type NHEP - dimension %D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-extrarow",&extrarow);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSNHEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); ierr = DSSetExtraRow(ds,extrarow);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill with Grcar matrix */ ierr = DSGetArray(ds,DS_MAT_A,&A);CHKERRQ(ierr); for (i=1;icomparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,wr,wi);CHKERRQ(ierr); ierr = DSSort(ds,wr,wi,NULL,NULL,NULL);CHKERRQ(ierr); if (extrarow) { ierr = DSUpdateExtraRow(ds);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSHEP with compact storage.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscReal *T; PetscScalar *eig; PetscInt i,n=10,l=2,k=5,ld; PetscViewer viewer; PetscBool verbose,extrarow; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type HEP with compact storage - dimension %D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); if (l>n || k>n || l>k) SETERRQ(PETSC_COMM_WORLD,1,"Wrong value of dimensions"); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-extrarow",&extrarow);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSHEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,l,k);CHKERRQ(ierr); ierr = DSSetCompact(ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSSetExtraRow(ds,extrarow);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill arrow-tridiagonal matrix */ ierr = DSGetArrayReal(ds,DS_MAT_T,&T);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,eig,NULL);CHKERRQ(ierr); ierr = DSSort(ds,eig,NULL,NULL,NULL,NULL);CHKERRQ(ierr); if (extrarow) { ierr = DSUpdateExtraRow(ds);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;iActual source code: test14f.F
slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./test14f [-help] [-n <n>] [all SLEPc options] 
 21: !
 22: !  Description: Simple example that tests solving a DSNHEP problem.
 23: !
 24: !  The command line options are:
 25: !    -n <n>, where <n> = matrix size
 26: !
 27: ! ---------------------------------------------------------------------- 
 28: !
 29:       program main
 30:       implicit none

 32: #include <petsc/finclude/petscsys.h>
 33: #include <petsc/finclude/petscmat.h>
 34: #include <slepc/finclude/slepcds.h>

 36: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 37: !     Declarations
 38: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 39: !
 40: !  Variables:
 41: !     A     problem matrix
 42: !     ds    dense solver context

 44:       Mat            A
 45:       DS             ds
 46:       PetscInt       n, i, ld, zero
 47:       PetscMPIInt    rank
 48:       PetscErrorCode ierr
 49:       PetscBool      flg
 50:       PetscScalar    aa(1), wr(100), wi(100)
 51:       PetscReal      re, im
 52:       PetscOffset    ia

 54: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 55: !     Beginning of program
 56: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 58:       zero = 0
 59:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 60:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 61:       n = 10
 62:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 63:      &                        '-n',n,flg,ierr)
 64:       if (n .gt. 100) then
 65:         if (rank .eq. 0) then
 66:           write(*,100) n
 67:         endif
 68:         SETERRQ(PETSC_COMM_SELF,1,' ',ierr)
 69:       endif
 70:  100  format (/'Program currently limited to n=100, you set n=',I3)

 72:       if (rank .eq. 0) then
 73:         write(*,110) n
 74:       endif
 75:  110  format (/'Solve a Dense System of type NHEP, n =',I3,' (Fortran)')

 77: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 78: !     Create DS object
 79: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 81:       call DSCreate(PETSC_COMM_WORLD,ds,ierr)
 82:       call DSSetType(ds,DSNHEP,ierr)
 83:       call DSSetFromOptions(ds,ierr)
 84:       ld = n
 85:       call DSAllocate(ds,ld,ierr)
 86:       call DSSetDimensions(ds,n,zero,zero,zero,ierr)

 88: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 89: !     Fill with Grcar matrix
 90: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 92:       call DSGetMat(ds,DS_MAT_A,A,ierr)
 93:       call MatDenseGetArray(A,aa,ia,ierr)
 94:       call FillUpMatrix(n,aa(ia+1))
 95:       call MatDenseRestoreArray(A,aa,ia,ierr)
 96:       call DSRestoreMat(ds,DS_MAT_A,A,ierr)
 97:       call DSSetState(ds,DS_STATE_INTERMEDIATE,ierr)

 99: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
100: !     Solve the problem and show eigenvalues
101: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

103:       call DSSolve(ds,wr,wi,ierr) 
104: !     call DSSort(ds,wr,wi,PETSC_NULL_SCALAR,PETSC_NULL_SCALAR,         &
105: !    &            PETSC_NULL_INTEGER,ierr) 

107:       if (rank .eq. 0) then
108:         write(*,*) 'Computed eigenvalues ='
109:         do i=1,n
110: #if defined(PETSC_USE_COMPLEX)
111:           re = PetscRealPart(wr(i))
112:           im = PetscImaginaryPart(wr(i))
113: #else
114:           re = wr(i)
115:           im = wi(i)
116: #endif
117:           if (abs(im).lt.1.d-10) then
118:             write(*,120) re
119:           else
120:             write(*,130) re, im
121:           endif
122:         end do
123:       endif
124:  120  format ('  ',F8.5)
125:  130  format ('  ',F8.5,SP,F8.5,'i')

127: !     *** Clean up
128:       call DSDestroy(ds,ierr)
129:       call SlepcFinalize(ierr)
130:       end

132: ! -----------------------------------------------------------------

134:       subroutine FillUpMatrix(n,X)
135:       PetscInt    n,i,j
136:       PetscScalar X(n,n)

138:       do i=2,n
139:         X(i,i-1) = -1.d0
140:       end do
141:       do j=0,3
142:         do i=1,n-j
143:           X(i,i+j) = 1.d0
144:         end do
145:       end do
146:       return
147:       end

slepc-3.7.4/src/sys/classes/ds/examples/tests/test6.c.html0000644000175000017500000002513013107004621022770 0ustar jromanjroman
Actual source code: test6.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSGHIEP with compact storage.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscReal      *T,*s,re,im;
 34:   PetscScalar    *eigr,*eigi;
 35:   PetscInt       i,n=10,l=2,k=5,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type GHIEP with compact storage - dimension %D.\n",n);
 42:   PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 44:   if (l>n || k>n || l>k) SETERRQ(PETSC_COMM_WORLD,1,"Wrong value of dimensions");
 45:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 47:   /* Create DS object */
 48:   DSCreate(PETSC_COMM_WORLD,&ds);
 49:   DSSetType(ds,DSGHIEP);
 50:   DSSetFromOptions(ds);
 51:   ld = n+2;  /* test leading dimension larger than n */
 52:   DSAllocate(ds,ld);
 53:   DSSetDimensions(ds,n,0,l,k);
 54:   DSSetCompact(ds,PETSC_TRUE);

 56:   /* Set up viewer */
 57:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 58:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 59:   DSView(ds,viewer);
 60:   PetscViewerPopFormat(viewer);
 61:   if (verbose) {
 62:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 63:   }

 65:   /* Fill arrow-tridiagonal matrix */
 66:   DSGetArrayReal(ds,DS_MAT_T,&T);
 67:   DSGetArrayReal(ds,DS_MAT_D,&s);
 68:   for (i=0;i<n;i++) T[i] = (PetscReal)(i+1);
 69:   for (i=k;i<n-1;i++) T[i+ld] = 1.0;
 70:   for (i=l;i<k;i++) T[i+2*ld] = 1.0;
 71:   T[2*ld+l+1] = -7; T[ld+k+1] = -7;
 72:   /* Signature matrix */
 73:   for (i=0;i<n;i++) s[i] = 1.0;
 74:   s[l+1] = -1.0;
 75:   s[k+1] = -1.0;
 76:   DSRestoreArrayReal(ds,DS_MAT_T,&T);
 77:   DSRestoreArrayReal(ds,DS_MAT_D,&s);
 78:   if (l==0 && k==0) {
 79:     DSSetState(ds,DS_STATE_INTERMEDIATE);
 80:   } else {
 81:     DSSetState(ds,DS_STATE_RAW);
 82:   }
 83:   if (verbose) {
 84:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 85:     DSView(ds,viewer);
 86:   }

 88:   /* Solve */
 89:   PetscCalloc2(n,&eigr,n,&eigi);
 90:   DSGetSlepcSC(ds,&sc);
 91:   sc->comparison    = SlepcCompareLargestMagnitude;
 92:   sc->comparisonctx = NULL;
 93:   sc->map           = NULL;
 94:   sc->mapobj        = NULL;
 95:   DSSolve(ds,eigr,eigi);
 96:   DSSort(ds,eigr,eigi,NULL,NULL,NULL);
 97:   if (verbose) {
 98:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 99:     DSView(ds,viewer);
100:   }

102:   /* Print eigenvalues */
103:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
104:   for (i=0;i<n;i++) {
105: #if defined(PETSC_USE_COMPLEX)
106:     re = PetscRealPart(eigr[i]);
107:     im = PetscImaginaryPart(eigr[i]);
108: #else
109:     re = eigr[i];
110:     im = eigi[i];
111: #endif
112:     if (PetscAbs(im)<1e-10) {
113:       PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)re);
114:     } else {
115:       PetscViewerASCIIPrintf(viewer,"  %.5f%+.5fi\n",(double)re,(double)im);
116:     }
117:   }
118:   PetscFree2(eigr,eigi);
119:   DSDestroy(&ds);
120:   SlepcFinalize();
121:   return ierr;
122: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test2.c.html0000644000175000017500000002523513107004621022772 0ustar jromanjroman
Actual source code: test2.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSHEP.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscScalar    *A,*X,*eig;
 34:   PetscReal      rnorm,aux;
 35:   PetscInt       i,j,n=10,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose,extrarow;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type HEP - dimension %D.\n",n);
 42:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 43:   PetscOptionsHasName(NULL,NULL,"-extrarow",&extrarow);

 45:   /* Create DS object */
 46:   DSCreate(PETSC_COMM_WORLD,&ds);
 47:   DSSetType(ds,DSHEP);
 48:   DSSetFromOptions(ds);
 49:   ld = n+2;  /* test leading dimension larger than n */
 50:   DSAllocate(ds,ld);
 51:   DSSetDimensions(ds,n,0,0,0);
 52:   DSSetExtraRow(ds,extrarow);

 54:   /* Set up viewer */
 55:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 56:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 57:   DSView(ds,viewer);
 58:   PetscViewerPopFormat(viewer);
 59:   if (verbose) {
 60:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 61:   }

 63:   /* Fill with a symmetric Toeplitz matrix */
 64:   DSGetArray(ds,DS_MAT_A,&A);
 65:   for (i=0;i<n;i++) A[i+i*ld]=2.0;
 66:   for (j=1;j<3;j++) {
 67:     for (i=0;i<n-j;i++) { A[i+(i+j)*ld]=1.0; A[(i+j)+i*ld]=1.0; }
 68:   }
 69:   if (extrarow) { A[n+(n-2)*ld]=1.0; A[n+(n-1)*ld]=1.0; }
 70:   DSRestoreArray(ds,DS_MAT_A,&A);
 71:   DSSetState(ds,DS_STATE_RAW);
 72:   if (verbose) {
 73:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 74:     DSView(ds,viewer);
 75:   }

 77:   /* Solve */
 78:   PetscMalloc1(n,&eig);
 79:   DSGetSlepcSC(ds,&sc);
 80:   sc->comparison    = SlepcCompareLargestMagnitude;
 81:   sc->comparisonctx = NULL;
 82:   sc->map           = NULL;
 83:   sc->mapobj        = NULL;
 84:   DSSolve(ds,eig,NULL);
 85:   DSSort(ds,eig,NULL,NULL,NULL,NULL);
 86:   if (extrarow) { DSUpdateExtraRow(ds); }
 87:   if (verbose) {
 88:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 89:     DSView(ds,viewer);
 90:   }

 92:   /* Print eigenvalues */
 93:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
 94:   for (i=0;i<n;i++) {
 95:     PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)PetscRealPart(eig[i]));
 96:   }

 98:   /* Eigenvectors */
 99:   j = 2;
100:   DSVectors(ds,DS_MAT_X,&j,&rnorm);  /* third eigenvector */
101:   PetscPrintf(PETSC_COMM_WORLD,"Value of rnorm for 3rd vector = %.3f\n",(double)rnorm);
102:   DSVectors(ds,DS_MAT_X,NULL,NULL);  /* all eigenvectors */
103:   j = 0;
104:   rnorm = 0.0;
105:   DSGetArray(ds,DS_MAT_X,&X);
106:   for (i=0;i<n;i++) {
107:     aux = PetscAbsScalar(X[i+j*ld]);
108:     rnorm += aux*aux;
109:   }
110:   DSRestoreArray(ds,DS_MAT_X,&X);
111:   rnorm = PetscSqrtReal(rnorm);
112:   PetscPrintf(PETSC_COMM_WORLD,"Norm of 1st vector = %.3f\n",(double)rnorm);
113:   if (verbose) {
114:     PetscPrintf(PETSC_COMM_WORLD,"After vectors - - - - - - - - -\n");
115:     DSView(ds,viewer);
116:   }

118:   PetscFree(eig);
119:   DSDestroy(&ds);
120:   SlepcFinalize();
121:   return ierr;
122: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test7.c0000644000175000017500000000734313107004621022034 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSSVD.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscReal sigma; PetscScalar *A,*w; PetscInt i,j,k,n=15,m=10,ld; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); k = PetscMin(n,m); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type SVD - dimension %Dx%D.\n",n,m);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSSVD);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,m,0,0);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill with a rectangular Toeplitz matrix */ ierr = DSGetArray(ds,DS_MAT_A,&A);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestReal; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,w,NULL);CHKERRQ(ierr); ierr = DSSort(ds,w,NULL,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print singular values */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed singular values =\n");CHKERRQ(ierr); for (i=0;iActual source code: test5.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSGHIEP.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscReal      re,im;
 34:   PetscScalar    *A,*B,*eigr,*eigi;
 35:   PetscInt       i,j,n=10,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type GHIEP - dimension %D.\n",n);
 42:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 44:   /* Create DS object */
 45:   DSCreate(PETSC_COMM_WORLD,&ds);
 46:   DSSetType(ds,DSGHIEP);
 47:   DSSetFromOptions(ds);
 48:   ld = n+2;  /* test leading dimension larger than n */
 49:   DSAllocate(ds,ld);
 50:   DSSetDimensions(ds,n,0,0,0);

 52:   /* Set up viewer */
 53:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 54:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 55:   DSView(ds,viewer);
 56:   PetscViewerPopFormat(viewer);
 57:   if (verbose) {
 58:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 59:   }

 61:   /* Fill with a symmetric Toeplitz matrix */
 62:   DSGetArray(ds,DS_MAT_A,&A);
 63:   DSGetArray(ds,DS_MAT_B,&B);
 64:   for (i=0;i<n;i++) A[i+i*ld]=2.0;
 65:   for (j=1;j<3;j++) {
 66:     for (i=0;i<n-j;i++) { A[i+(i+j)*ld]=1.0; A[(i+j)+i*ld]=1.0; }
 67:   }
 68:   for (j=1;j<3;j++) { A[0+j*ld]=-1.0*(j+2); A[j+0*ld]=-1.0*(j+2); }
 69:   /* Signature matrix */
 70:   for (i=0;i<n;i++) B[i+i*ld]=1.0;
 71:   B[0] = -1.0;
 72:   B[n-1+(n-1)*ld] = -1.0;
 73:   DSRestoreArray(ds,DS_MAT_A,&A);
 74:   DSRestoreArray(ds,DS_MAT_B,&B);
 75:   DSSetState(ds,DS_STATE_RAW);
 76:   if (verbose) {
 77:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 78:     DSView(ds,viewer);
 79:   }

 81:   /* Solve */
 82:   PetscCalloc2(n,&eigr,n,&eigi);
 83:   DSGetSlepcSC(ds,&sc);
 84:   sc->comparison    = SlepcCompareLargestMagnitude;
 85:   sc->comparisonctx = NULL;
 86:   sc->map           = NULL;
 87:   sc->mapobj        = NULL;
 88:   DSSolve(ds,eigr,eigi);
 89:   DSSort(ds,eigr,eigi,NULL,NULL,NULL);
 90:   if (verbose) {
 91:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 92:     DSView(ds,viewer);
 93:   }

 95:   /* Print eigenvalues */
 96:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
 97:   for (i=0;i<n;i++) {
 98: #if defined(PETSC_USE_COMPLEX)
 99:     re = PetscRealPart(eigr[i]);
100:     im = PetscImaginaryPart(eigr[i]);
101: #else
102:     re = eigr[i];
103:     im = eigi[i];
104: #endif
105:     if (PetscAbs(im)<1e-10) {
106:       PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)re);
107:     } else {
108:       PetscViewerASCIIPrintf(viewer,"  %.5f%+.5fi\n",(double)re,(double)im);
109:     }
110:   }
111:   PetscFree2(eigr,eigi);
112:   DSDestroy(&ds);
113:   SlepcFinalize();
114:   return ierr;
115: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/index.html0000644000175000017500000000344013107004621022611 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

test1.c: Test DSNHEP
test2.c: Test DSHEP
test3.c: Test DSHEP with compact storage
test4.c: Test DSGNHEP
test5.c: Test DSGHIEP
test6.c: Test DSGHIEP with compact storage
test7.c: Test DSSVD
test8.c: Test DSSVD with compact storage
test9.c: Test DSGHEP
test12.c: Test DSNEP
test13.c: Test DSHEP with block size larger than one
test15.c: Test DSPEP
makefile
slepc-3.7.4/src/sys/classes/ds/examples/tests/test8.c0000644000175000017500000000763713107004621022043 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSSVD with compact storage.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscReal *T,sigma; PetscScalar *w; PetscInt i,n=10,m,l=2,k=5,ld; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); m = n; ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type SVD with compact storage - dimension %Dx%D.\n",n,m);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); if (l>n || k>n || l>k) SETERRQ(PETSC_COMM_WORLD,1,"Wrong value of dimensions"); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSSVD);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,m,l,k);CHKERRQ(ierr); ierr = DSSetCompact(ds,PETSC_TRUE);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill upper arrow-tridiagonal matrix */ ierr = DSGetArrayReal(ds,DS_MAT_T,&T);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestReal; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,w,NULL);CHKERRQ(ierr); ierr = DSSort(ds,w,NULL,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print singular values */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed singular values =\n");CHKERRQ(ierr); for (i=0;i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSNEP.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; FN f1,f2,f3,funs[3]; PetscScalar *Id,*A,*B,*wr,*wi,coeffs[2]; PetscReal tau=0.001,h,a=20,xi,re,im; PetscInt i,n=10,ld,nev; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-tau",&tau,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type NEP - dimension %D, tau=%g.\n",n,(double)tau);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSNEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); /* Set functions (prior to DSAllocate) */ ierr = FNCreate(PETSC_COMM_WORLD,&f1);CHKERRQ(ierr); ierr = FNSetType(f1,FNRATIONAL);CHKERRQ(ierr); coeffs[0] = -1.0; coeffs[1] = 0.0; ierr = FNRationalSetNumerator(f1,2,coeffs);CHKERRQ(ierr); ierr = FNCreate(PETSC_COMM_WORLD,&f2);CHKERRQ(ierr); ierr = FNSetType(f2,FNRATIONAL);CHKERRQ(ierr); coeffs[0] = 1.0; ierr = FNRationalSetNumerator(f2,1,coeffs);CHKERRQ(ierr); ierr = FNCreate(PETSC_COMM_WORLD,&f3);CHKERRQ(ierr); ierr = FNSetType(f3,FNEXP);CHKERRQ(ierr); ierr = FNSetScale(f3,-tau,1.0);CHKERRQ(ierr); funs[0] = f1; funs[1] = f2; funs[2] = f3; ierr = DSNEPSetFN(ds,3,funs);CHKERRQ(ierr); /* Set dimensions */ ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill matrices */ ierr = DSGetArray(ds,DS_MAT_E0,&Id);CHKERRQ(ierr); for (i=0;iActual source code: test7.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSSVD.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscReal      sigma;
 34:   PetscScalar    *A,*w;
 35:   PetscInt       i,j,k,n=15,m=10,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 42:   k = PetscMin(n,m);
 43:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type SVD - dimension %Dx%D.\n",n,m);
 44:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 46:   /* Create DS object */
 47:   DSCreate(PETSC_COMM_WORLD,&ds);
 48:   DSSetType(ds,DSSVD);
 49:   DSSetFromOptions(ds);
 50:   ld = n+2;  /* test leading dimension larger than n */
 51:   DSAllocate(ds,ld);
 52:   DSSetDimensions(ds,n,m,0,0);

 54:   /* Set up viewer */
 55:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 56:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 57:   DSView(ds,viewer);
 58:   PetscViewerPopFormat(viewer);
 59:   if (verbose) {
 60:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 61:   }

 63:   /* Fill with a rectangular Toeplitz matrix */
 64:   DSGetArray(ds,DS_MAT_A,&A);
 65:   for (i=0;i<k;i++) A[i+i*ld]=1.0;
 66:   for (j=1;j<3;j++) {
 67:     for (i=0;i<n-j;i++) { if ((i+j)<m) A[i+(i+j)*ld]=(PetscScalar)(j+1); }
 68:   }
 69:   for (j=1;j<n/2;j++) {
 70:     for (i=0;i<n-j;i++) { if ((i+j)<n && i<m) A[(i+j)+i*ld]=-1.0; }
 71:   }
 72:   DSRestoreArray(ds,DS_MAT_A,&A);
 73:   DSSetState(ds,DS_STATE_RAW);
 74:   if (verbose) {
 75:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 76:     DSView(ds,viewer);
 77:   }

 79:   /* Solve */
 80:   PetscMalloc1(k,&w);
 81:   DSGetSlepcSC(ds,&sc);
 82:   sc->comparison    = SlepcCompareLargestReal;
 83:   sc->comparisonctx = NULL;
 84:   sc->map           = NULL;
 85:   sc->mapobj        = NULL;
 86:   DSSolve(ds,w,NULL);
 87:   DSSort(ds,w,NULL,NULL,NULL,NULL);
 88:   if (verbose) {
 89:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 90:     DSView(ds,viewer);
 91:   }

 93:   /* Print singular values */
 94:   PetscPrintf(PETSC_COMM_WORLD,"Computed singular values =\n");
 95:   for (i=0;i<k;i++) {
 96:     sigma = PetscRealPart(w[i]);
 97:     PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)sigma);
 98:   }
 99:   PetscFree(w);
100:   DSDestroy(&ds);
101:   SlepcFinalize();
102:   return ierr;
103: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test5.c0000644000175000017500000001013013107004621022016 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSGHIEP.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscReal re,im; PetscScalar *A,*B,*eigr,*eigi; PetscInt i,j,n=10,ld; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type GHIEP - dimension %D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSGHIEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill with a symmetric Toeplitz matrix */ ierr = DSGetArray(ds,DS_MAT_A,&A);CHKERRQ(ierr); ierr = DSGetArray(ds,DS_MAT_B,&B);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,eigr,eigi);CHKERRQ(ierr); ierr = DSSort(ds,eigr,eigi,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;iActual source code: test13.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSHEP with block size larger than one.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscScalar    *A,*eig;
 34:   PetscInt       i,j,n,ld,bs,maxbw=3,nblks=8;
 35:   PetscViewer    viewer;
 36:   PetscBool      verbose;

 38:   SlepcInitialize(&argc,&argv,(char*)0,help);
 39:   PetscOptionsGetInt(NULL,NULL,"-maxbw",&maxbw,NULL);
 40:   PetscOptionsGetInt(NULL,NULL,"-nblks",&nblks,NULL);
 41:   n = maxbw*nblks;
 42:   bs = maxbw;
 43:   PetscPrintf(PETSC_COMM_WORLD,"Solve a block HEP Dense System - dimension %D (bandwidth=%D, blocks=%D).\n",n,maxbw,nblks);
 44:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 46:   /* Create DS object */
 47:   DSCreate(PETSC_COMM_WORLD,&ds);
 48:   DSSetType(ds,DSHEP);
 49:   DSSetMethod(ds,3);   /* Select block divide-and-conquer */
 50:   DSSetBlockSize(ds,bs);
 51:   DSSetFromOptions(ds);
 52:   ld = n;
 53:   DSAllocate(ds,ld);
 54:   DSSetDimensions(ds,n,0,0,0);

 56:   /* Set up viewer */
 57:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 58:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 59:   DSView(ds,viewer);
 60:   PetscViewerPopFormat(viewer);
 61:   if (verbose) {
 62:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 63:   }

 65:   /* Fill with a symmetric band Toeplitz matrix */
 66:   DSGetArray(ds,DS_MAT_A,&A);
 67:   for (i=0;i<n;i++) A[i+i*ld]=2.0;
 68:   for (j=1;j<=bs;j++) {
 69:     for (i=0;i<n-j;i++) { A[i+(i+j)*ld]=1.0; A[(i+j)+i*ld]=1.0; }
 70:   }
 71:   DSRestoreArray(ds,DS_MAT_A,&A);
 72:   DSSetState(ds,DS_STATE_RAW);
 73:   if (verbose) {
 74:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 75:     DSView(ds,viewer);
 76:   }

 78:   /* Solve */
 79:   PetscMalloc1(n,&eig);
 80:   DSGetSlepcSC(ds,&sc);
 81:   sc->comparison    = SlepcCompareSmallestReal;
 82:   sc->comparisonctx = NULL;
 83:   sc->map           = NULL;
 84:   sc->mapobj        = NULL;
 85:   DSSolve(ds,eig,NULL);
 86:   DSSort(ds,eig,NULL,NULL,NULL,NULL);
 87:   if (verbose) {
 88:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 89:     DSView(ds,viewer);
 90:   }

 92:   /* Print eigenvalues */
 93:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
 94:   for (i=0;i<n;i++) {
 95:     PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)PetscRealPart(eig[i]));
 96:   }

 98:   PetscFree(eig);
 99:   DSDestroy(&ds);
100:   SlepcFinalize();
101:   return ierr;
102: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test9.c0000644000175000017500000000740313107004621022033 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSGHEP.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscReal re; PetscScalar *A,*B,*eig; PetscInt i,j,n=10,ld; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a System of type GHEP - dimension %D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSGHEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill with a symmetric Toeplitz matrix */ ierr = DSGetArray(ds,DS_MAT_A,&A);CHKERRQ(ierr); ierr = DSGetArray(ds,DS_MAT_B,&B);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,eig,NULL);CHKERRQ(ierr); ierr = DSSort(ds,eig,NULL,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;iActual source code: test8.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSSVD with compact storage.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscReal      *T,sigma;
 34:   PetscScalar    *w;
 35:   PetscInt       i,n=10,m,l=2,k=5,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   m = n;
 42:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type SVD with compact storage - dimension %Dx%D.\n",n,m);
 43:   PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);
 44:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 45:   if (l>n || k>n || l>k) SETERRQ(PETSC_COMM_WORLD,1,"Wrong value of dimensions");
 46:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 48:   /* Create DS object */
 49:   DSCreate(PETSC_COMM_WORLD,&ds);
 50:   DSSetType(ds,DSSVD);
 51:   DSSetFromOptions(ds);
 52:   ld = n+2;  /* test leading dimension larger than n */
 53:   DSAllocate(ds,ld);
 54:   DSSetDimensions(ds,n,m,l,k);
 55:   DSSetCompact(ds,PETSC_TRUE);

 57:   /* Set up viewer */
 58:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 59:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 60:   DSView(ds,viewer);
 61:   PetscViewerPopFormat(viewer);
 62:   if (verbose) {
 63:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 64:   }

 66:   /* Fill upper arrow-tridiagonal matrix */
 67:   DSGetArrayReal(ds,DS_MAT_T,&T);
 68:   for (i=0;i<n;i++) T[i] = (PetscReal)(i+1);
 69:   for (i=l;i<n-1;i++) T[i+ld] = 1.0;
 70:   DSRestoreArrayReal(ds,DS_MAT_T,&T);
 71:   if (l==0 && k==0) {
 72:     DSSetState(ds,DS_STATE_INTERMEDIATE);
 73:   } else {
 74:     DSSetState(ds,DS_STATE_RAW);
 75:   }
 76:   if (verbose) {
 77:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 78:     DSView(ds,viewer);
 79:   }

 81:   /* Solve */
 82:   PetscMalloc1(n,&w);
 83:   DSGetSlepcSC(ds,&sc);
 84:   sc->comparison    = SlepcCompareLargestReal;
 85:   sc->comparisonctx = NULL;
 86:   sc->map           = NULL;
 87:   sc->mapobj        = NULL;
 88:   DSSolve(ds,w,NULL);
 89:   DSSort(ds,w,NULL,NULL,NULL,NULL);
 90:   if (verbose) {
 91:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 92:     DSView(ds,viewer);
 93:   }

 95:   /* Print singular values */
 96:   PetscPrintf(PETSC_COMM_WORLD,"Computed singular values =\n");
 97:   for (i=0;i<n;i++) {
 98:     sigma = PetscRealPart(w[i]);
 99:     PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)sigma);
100:   }
101:   PetscFree(w);
102:   DSDestroy(&ds);
103:   SlepcFinalize();
104:   return ierr;
105: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test3.c.html0000644000175000017500000002322213107004621022765 0ustar jromanjroman
Actual source code: test3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSHEP with compact storage.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscReal      *T;
 34:   PetscScalar    *eig;
 35:   PetscInt       i,n=10,l=2,k=5,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose,extrarow;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type HEP with compact storage - dimension %D.\n",n);
 42:   PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 44:   if (l>n || k>n || l>k) SETERRQ(PETSC_COMM_WORLD,1,"Wrong value of dimensions");
 45:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 46:   PetscOptionsHasName(NULL,NULL,"-extrarow",&extrarow);

 48:   /* Create DS object */
 49:   DSCreate(PETSC_COMM_WORLD,&ds);
 50:   DSSetType(ds,DSHEP);
 51:   DSSetFromOptions(ds);
 52:   ld = n+2;  /* test leading dimension larger than n */
 53:   DSAllocate(ds,ld);
 54:   DSSetDimensions(ds,n,0,l,k);
 55:   DSSetCompact(ds,PETSC_TRUE);
 56:   DSSetExtraRow(ds,extrarow);

 58:   /* Set up viewer */
 59:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 60:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 61:   DSView(ds,viewer);
 62:   PetscViewerPopFormat(viewer);
 63:   if (verbose) {
 64:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 65:   }

 67:   /* Fill arrow-tridiagonal matrix */
 68:   DSGetArrayReal(ds,DS_MAT_T,&T);
 69:   for (i=0;i<n;i++) T[i] = (PetscReal)(i+1);
 70:   for (i=l;i<n-1;i++) T[i+ld] = 1.0;
 71:   if (extrarow) T[n-1+ld] = 1.0;
 72:   DSRestoreArrayReal(ds,DS_MAT_T,&T);
 73:   if (l==0 && k==0) {
 74:     DSSetState(ds,DS_STATE_INTERMEDIATE);
 75:   } else {
 76:     DSSetState(ds,DS_STATE_RAW);
 77:   }
 78:   if (verbose) {
 79:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 80:     DSView(ds,viewer);
 81:   }

 83:   /* Solve */
 84:   PetscMalloc1(n,&eig);
 85:   DSGetSlepcSC(ds,&sc);
 86:   sc->comparison    = SlepcCompareLargestMagnitude;
 87:   sc->comparisonctx = NULL;
 88:   sc->map           = NULL;
 89:   sc->mapobj        = NULL;
 90:   DSSolve(ds,eig,NULL);
 91:   DSSort(ds,eig,NULL,NULL,NULL,NULL);
 92:   if (extrarow) { DSUpdateExtraRow(ds); }
 93:   if (verbose) {
 94:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 95:     DSView(ds,viewer);
 96:   }

 98:   /* Print eigenvalues */
 99:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
100:   for (i=0;i<n;i++) {
101:     PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)PetscRealPart(eig[i]));
102:   }

104:   PetscFree(eig);
105:   DSDestroy(&ds);
106:   SlepcFinalize();
107:   return ierr;
108: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test14f.F0000644000175000017500000001117313107004621022217 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./test14f [-help] [-n ] [all SLEPc options] ! ! Description: Simple example that tests solving a DSNHEP problem. ! ! The command line options are: ! -n , where = matrix size ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! A problem matrix ! ds dense solver context Mat A DS ds PetscInt n, i, ld, zero PetscMPIInt rank PetscErrorCode ierr PetscBool flg PetscScalar aa(1), wr(100), wi(100) PetscReal re, im PetscOffset ia ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - zero = 0 call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 10 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-n',n,flg,ierr) if (n .gt. 100) then if (rank .eq. 0) then write(*,100) n endif SETERRQ(PETSC_COMM_SELF,1,' ',ierr) endif 100 format (/'Program currently limited to n=100, you set n=',I3) if (rank .eq. 0) then write(*,110) n endif 110 format (/'Solve a Dense System of type NHEP, n =',I3,' (Fortran)') ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create DS object ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call DSCreate(PETSC_COMM_WORLD,ds,ierr) call DSSetType(ds,DSNHEP,ierr) call DSSetFromOptions(ds,ierr) ld = n call DSAllocate(ds,ld,ierr) call DSSetDimensions(ds,n,zero,zero,zero,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Fill with Grcar matrix ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call DSGetMat(ds,DS_MAT_A,A,ierr) call MatDenseGetArray(A,aa,ia,ierr) call FillUpMatrix(n,aa(ia+1)) call MatDenseRestoreArray(A,aa,ia,ierr) call DSRestoreMat(ds,DS_MAT_A,A,ierr) call DSSetState(ds,DS_STATE_INTERMEDIATE,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the problem and show eigenvalues ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call DSSolve(ds,wr,wi,ierr) ! call DSSort(ds,wr,wi,PETSC_NULL_SCALAR,PETSC_NULL_SCALAR, & ! & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,*) 'Computed eigenvalues =' do i=1,n #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(wr(i)) im = PetscImaginaryPart(wr(i)) #else re = wr(i) im = wi(i) #endif if (abs(im).lt.1.d-10) then write(*,120) re else write(*,130) re, im endif end do endif 120 format (' ',F8.5) 130 format (' ',F8.5,SP,F8.5,'i') ! *** Clean up call DSDestroy(ds,ierr) call SlepcFinalize(ierr) end ! ----------------------------------------------------------------- subroutine FillUpMatrix(n,X) PetscInt n,i,j PetscScalar X(n,n) do i=2,n X(i,i-1) = -1.d0 end do do j=0,3 do i=1,n-j X(i,i+j) = 1.d0 end do end do return end slepc-3.7.4/src/sys/classes/ds/examples/tests/test15.c.html0000644000175000017500000002407413107004621023056 0ustar jromanjroman
Actual source code: test15.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test DSPEP.\n\n";

 24: #include <slepcds.h>

 28: int main(int argc,char **argv)
 29: {
 31:   DS             ds;
 32:   SlepcSC        sc;
 33:   PetscScalar    *K,*C,*M,*wr,*wi,z=1.0;
 34:   PetscReal      re,im;
 35:   PetscInt       i,n=10,d=2,ld;
 36:   PetscViewer    viewer;
 37:   PetscBool      verbose;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type PEP - n=%D.\n",n);
 42:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);

 44:   /* Create DS object */
 45:   DSCreate(PETSC_COMM_WORLD,&ds);
 46:   DSSetType(ds,DSPEP);
 47:   DSSetFromOptions(ds);
 48:   DSPEPSetDegree(ds,d);

 50:   /* Set dimensions */
 51:   ld = n+2;  /* test leading dimension larger than n */
 52:   DSAllocate(ds,ld);
 53:   DSSetDimensions(ds,n,0,0,0);

 55:   /* Set up viewer */
 56:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
 57:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);
 58:   DSView(ds,viewer);
 59:   PetscViewerPopFormat(viewer);
 60:   if (verbose) {
 61:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
 62:   }

 64:   /* Fill matrices */
 65:   DSGetArray(ds,DS_MAT_E0,&K);
 66:   for (i=0;i<n-1;i++) K[i+i*ld] = 2.0*n;
 67:   K[n-1+(n-1)*ld] = 1.0*n;
 68:   for (i=1;i<n;i++) {
 69:     K[i+(i-1)*ld] = -1.0*n;
 70:     K[(i-1)+i*ld] = -1.0*n;
 71:   }
 72:   DSRestoreArray(ds,DS_MAT_E0,&K);
 73:   DSGetArray(ds,DS_MAT_E1,&C);
 74:   C[n-1+(n-1)*ld] = 2.0*PETSC_PI/z;
 75:   DSRestoreArray(ds,DS_MAT_E1,&C);
 76:   DSGetArray(ds,DS_MAT_E2,&M);
 77:   for (i=0;i<n-1;i++) M[i+i*ld] = -4.0*PETSC_PI*PETSC_PI/n;
 78:   M[i+i*ld] = -2.0*PETSC_PI*PETSC_PI/n;
 79:   DSRestoreArray(ds,DS_MAT_E2,&M);

 81:   if (verbose) {
 82:     PetscPrintf(PETSC_COMM_WORLD,"Initial - - - - - - - - -\n");
 83:     DSView(ds,viewer);
 84:   }

 86:   /* Solve */
 87:   PetscMalloc2(d*n,&wr,d*n,&wi);
 88:   DSGetSlepcSC(ds,&sc);
 89:   sc->comparison    = SlepcCompareLargestReal;
 90:   sc->comparisonctx = NULL;
 91:   sc->map           = NULL;
 92:   sc->mapobj        = NULL;
 93:   DSSolve(ds,wr,wi);
 94:   DSSort(ds,wr,wi,NULL,NULL,NULL);
 95:   if (verbose) {
 96:     PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");
 97:     DSView(ds,viewer);
 98:   }

100:   /* Print first eigenvalue */
101:   PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");
102:   for (i=0;i<d*n;i++) {
103: #if defined(PETSC_USE_COMPLEX)
104:     re = PetscRealPart(wr[i]);
105:     im = PetscImaginaryPart(wr[i]);
106: #else
107:     re = wr[i];
108:     im = wi[i];
109: #endif
110:     if (PetscAbs(im)<1e-10) {
111:       PetscViewerASCIIPrintf(viewer,"  %.5f\n",(double)re);
112:     } else {
113:       PetscViewerASCIIPrintf(viewer,"  %.5f%+.5fi\n",(double)re,(double)im);
114:     }
115:   }

117:   PetscFree2(wr,wi);
118:   DSDestroy(&ds);
119:   SlepcFinalize();
120:   return ierr;
121: }
slepc-3.7.4/src/sys/classes/ds/examples/tests/test2.c0000644000175000017500000001107113107004621022020 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSHEP.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscScalar *A,*X,*eig; PetscReal rnorm,aux; PetscInt i,j,n=10,ld; PetscViewer viewer; PetscBool verbose,extrarow; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type HEP - dimension %D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-extrarow",&extrarow);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSHEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,0,0);CHKERRQ(ierr); ierr = DSSetExtraRow(ds,extrarow);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill with a symmetric Toeplitz matrix */ ierr = DSGetArray(ds,DS_MAT_A,&A);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,eig,NULL);CHKERRQ(ierr); ierr = DSSort(ds,eig,NULL,NULL,NULL,NULL);CHKERRQ(ierr); if (extrarow) { ierr = DSUpdateExtraRow(ds);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test DSGHIEP with compact storage.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; DS ds; SlepcSC sc; PetscReal *T,*s,re,im; PetscScalar *eigr,*eigi; PetscInt i,n=10,l=2,k=5,ld; PetscViewer viewer; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Solve a Dense System of type GHIEP with compact storage - dimension %D.\n",n);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); if (l>n || k>n || l>k) SETERRQ(PETSC_COMM_WORLD,1,"Wrong value of dimensions"); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); /* Create DS object */ ierr = DSCreate(PETSC_COMM_WORLD,&ds);CHKERRQ(ierr); ierr = DSSetType(ds,DSGHIEP);CHKERRQ(ierr); ierr = DSSetFromOptions(ds);CHKERRQ(ierr); ld = n+2; /* test leading dimension larger than n */ ierr = DSAllocate(ds,ld);CHKERRQ(ierr); ierr = DSSetDimensions(ds,n,0,l,k);CHKERRQ(ierr); ierr = DSSetCompact(ds,PETSC_TRUE);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill arrow-tridiagonal matrix */ ierr = DSGetArrayReal(ds,DS_MAT_T,&T);CHKERRQ(ierr); ierr = DSGetArrayReal(ds,DS_MAT_D,&s);CHKERRQ(ierr); for (i=0;icomparison = SlepcCompareLargestMagnitude; sc->comparisonctx = NULL; sc->map = NULL; sc->mapobj = NULL; ierr = DSSolve(ds,eigr,eigi);CHKERRQ(ierr); ierr = DSSort(ds,eigr,eigi,NULL,NULL,NULL);CHKERRQ(ierr); if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"After solve - - - - - - - - -\n");CHKERRQ(ierr); ierr = DSView(ds,viewer);CHKERRQ(ierr); } /* Print eigenvalues */ ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed eigenvalues =\n");CHKERRQ(ierr); for (i=0;i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../../../include/slepc/private/dsimpl.h ../../../../include/slepcds.h
DIRS     = interface impls examples
LOCDIR   = src/sys/classes/ds/
MANSEC   = DS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/index.html0000644000175000017500000000254113107004621017632 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

interface/
impls/
examples/
../../../../include/slepc/private/dsimpl.h
../../../../include/slepcds.h
makefile
slepc-3.7.4/src/sys/classes/ds/impls/0000755000175000017500000000000013107004621016757 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/makefile0000644000175000017500000000212513107004621020457 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcsys DIRS = hep nhep ghep ghiep gnhep svd pep nep LOCDIR = src/sys/classes/ds/impls/ MANSEC = DS include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/gnhep/0000755000175000017500000000000013107004621020060 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/gnhep/makefile0000644000175000017500000000216613107004621021565 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dsgnhep.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/gnhep/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/gnhep/dsgnhep.c.html0000644000175000017500000014327413107004621022632 0ustar jromanjroman

Actual source code: dsgnhep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/dsimpl.h>
 23: #include <slepcblaslapack.h>

 25: /*
 26:   1) Patterns of A and B
 27:       DS_STATE_RAW:       DS_STATE_INTERM/CONDENSED
 28:        0       n-1              0       n-1
 29:       -------------            -------------
 30:     0 |* * * * * *|          0 |* * * * * *|
 31:       |* * * * * *|            |  * * * * *|
 32:       |* * * * * *|            |    * * * *|
 33:       |* * * * * *|            |    * * * *|
 34:       |* * * * * *|            |        * *|
 35:   n-1 |* * * * * *|        n-1 |          *|
 36:       -------------            -------------

 38:   2) Moreover, P and Q are assumed to be the identity in DS_STATE_INTERMEDIATE.
 39: */


 42: static PetscErrorCode CleanDenseSchur(PetscInt n,PetscInt k,PetscScalar *S,PetscInt ldS,PetscScalar *T,PetscInt ldT,PetscScalar *X,PetscInt ldX,PetscScalar *Y,PetscInt ldY,PetscBool doProd);

 46: PetscErrorCode DSAllocate_GNHEP(DS ds,PetscInt ld)
 47: {

 51:   DSAllocateMat_Private(ds,DS_MAT_A);
 52:   DSAllocateMat_Private(ds,DS_MAT_B);
 53:   DSAllocateMat_Private(ds,DS_MAT_Z);
 54:   DSAllocateMat_Private(ds,DS_MAT_Q);
 55:   PetscFree(ds->perm);
 56:   PetscMalloc1(ld,&ds->perm);
 57:   PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));
 58:   return(0);
 59: }

 63: PetscErrorCode DSView_GNHEP(DS ds,PetscViewer viewer)
 64: {

 68:   DSViewMat(ds,viewer,DS_MAT_A);
 69:   DSViewMat(ds,viewer,DS_MAT_B);
 70:   if (ds->state>DS_STATE_INTERMEDIATE) {
 71:     DSViewMat(ds,viewer,DS_MAT_Z);
 72:     DSViewMat(ds,viewer,DS_MAT_Q);
 73:   }
 74:   if (ds->mat[DS_MAT_X]) {
 75:     DSViewMat(ds,viewer,DS_MAT_X);
 76:   }
 77:   if (ds->mat[DS_MAT_Y]) {
 78:     DSViewMat(ds,viewer,DS_MAT_Y);
 79:   }
 80:   return(0);
 81: }

 85: static PetscErrorCode DSVectors_GNHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)
 86: {
 87: #if defined(SLEPC_MISSING_LAPACK_TGEVC)
 89:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGEVC - Lapack routine is unavailable");
 90: #else
 92:   PetscInt       i;
 93:   PetscBLASInt   n,ld,mout,info,*select,mm,inc = 1;
 94:   PetscScalar    *X,*Y,*Z,*A = ds->mat[DS_MAT_A],*B = ds->mat[DS_MAT_B],tmp,fone=1.0,fzero=0.0;
 95:   PetscReal      norm;
 96:   PetscBool      iscomplex = PETSC_FALSE;
 97:   const char     *side;

100:   PetscBLASIntCast(ds->n,&n);
101:   PetscBLASIntCast(ds->ld,&ld);
102:   if (left) {
103:     X = NULL;
104:     Y = &ds->mat[DS_MAT_Y][ld*(*k)];
105:     side = "L";
106:   } else {
107:     X = &ds->mat[DS_MAT_X][ld*(*k)];
108:     Y = NULL;
109:     side = "R";
110:   }
111:   Z = left? Y: X;
112:   DSAllocateWork_Private(ds,0,0,ld);
113:   select = ds->iwork;
114:   for (i=0;i<n;i++) select[i] = (PetscBLASInt)PETSC_FALSE;
115:   if (ds->state <= DS_STATE_INTERMEDIATE) {
116:     DSSetIdentity(ds,DS_MAT_Q);
117:     DSSetIdentity(ds,DS_MAT_Z);
118:   }
119:   CleanDenseSchur(n,0,A,ld,B,ld,ds->mat[DS_MAT_Q],ld,ds->mat[DS_MAT_Z],ld,PETSC_TRUE);
120:   if (ds->state < DS_STATE_CONDENSED) {
121:     DSSetState(ds,DS_STATE_CONDENSED);
122:   }

124:   /* compute k-th eigenvector */
125:   select[*k] = (PetscBLASInt)PETSC_TRUE;
126: #if defined(PETSC_USE_COMPLEX)
127:   mm = 1;
128:   DSAllocateWork_Private(ds,2*ld,2*ld,0);
129:   PetscStackCallBLAS("LAPACKtgevc",LAPACKtgevc_(side,"S",select,&n,A,&ld,B,&ld,Y,&ld,X,&ld,&mm,&mout,ds->work,ds->rwork,&info));
130: #else
131:   if ((*k)<n-1 && (A[ld*(*k)+(*k)+1] != 0.0 || B[ld*(*k)+(*k)+1] != 0.0)) iscomplex = PETSC_TRUE;
132:   mm = iscomplex? 2: 1;
133:   DSAllocateWork_Private(ds,6*ld,0,0);
134:   PetscStackCallBLAS("LAPACKtgevc",LAPACKtgevc_(side,"S",select,&n,A,&ld,B,&ld,Y,&ld,X,&ld,&mm,&mout,ds->work,&info));
135: #endif
136:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTGEVC %i",info);
137:   if (!select[*k] || mout != mm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong arguments in call to Lapack xTGEVC");

139:   /* accumulate and normalize eigenvectors */
140:   PetscMemcpy(ds->work,Z,mm*ld*sizeof(PetscScalar));
141:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&mm,&n,&fone,ds->mat[left?DS_MAT_Z:DS_MAT_Q],&ld,ds->work,&ld,&fzero,Z,&ld));
142:   norm = BLASnrm2_(&n,Z,&inc);
143: #if !defined(PETSC_USE_COMPLEX)
144:   if (iscomplex) {
145:     tmp = BLASnrm2_(&n,Z+ld,&inc);
146:     norm = SlepcAbsEigenvalue(norm,tmp);
147:   }
148: #endif
149:   tmp = 1.0 / norm;
150:   PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z,&inc));
151: #if !defined(PETSC_USE_COMPLEX)
152:   if (iscomplex) PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z+ld,&inc));
153: #endif

155:   /* set output arguments */
156:   if (iscomplex) (*k)++;
157:   if (rnorm) {
158:     if (iscomplex) *rnorm = SlepcAbsEigenvalue(Z[n-1],Z[n-1+ld]);
159:     else *rnorm = PetscAbsScalar(Z[n-1]);
160:   }
161:   return(0);
162: #endif
163: }

167: static PetscErrorCode DSVectors_GNHEP_Eigen_All(DS ds,PetscBool left)
168: {
169: #if defined(SLEPC_MISSING_LAPACK_TGEVC)
171:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGEVC - Lapack routine is unavailable");
172: #else
174:   PetscInt       i;
175:   PetscBLASInt   n,ld,mout,info,inc = 1;
176:   PetscBool      iscomplex;
177:   PetscScalar    *X,*Y,*Z,*A = ds->mat[DS_MAT_A],*B = ds->mat[DS_MAT_B],tmp;
178:   PetscReal      norm;
179:   const char     *side,*back;

182:   PetscBLASIntCast(ds->n,&n);
183:   PetscBLASIntCast(ds->ld,&ld);
184:   if (left) {
185:     X = NULL;
186:     Y = ds->mat[DS_MAT_Y];
187:     side = "L";
188:   } else {
189:     X = ds->mat[DS_MAT_X];
190:     Y = NULL;
191:     side = "R";
192:   }
193:   Z = left? Y: X;
194:   if (ds->state <= DS_STATE_INTERMEDIATE) {
195:     DSSetIdentity(ds,DS_MAT_Q);
196:     DSSetIdentity(ds,DS_MAT_Z);
197:   }
198:   CleanDenseSchur(n,0,A,ld,B,ld,ds->mat[DS_MAT_Q],ld,ds->mat[DS_MAT_Z],ld,PETSC_TRUE);
199:   if (ds->state>=DS_STATE_CONDENSED) {
200:     /* DSSolve() has been called, backtransform with matrix Q */
201:     back = "B";
202:     PetscMemcpy(left?Y:X,ds->mat[left?DS_MAT_Z:DS_MAT_Q],ld*ld*sizeof(PetscScalar));
203:   } else {
204:     back = "A";
205:     DSSetState(ds,DS_STATE_CONDENSED);
206:   }
207: #if defined(PETSC_USE_COMPLEX)
208:   DSAllocateWork_Private(ds,2*ld,2*ld,0);
209:   PetscStackCallBLAS("LAPACKtgevc",LAPACKtgevc_(side,back,NULL,&n,A,&ld,B,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,ds->rwork,&info));
210: #else
211:   DSAllocateWork_Private(ds,6*ld,0,0);
212:   PetscStackCallBLAS("LAPACKtgevc",LAPACKtgevc_(side,back,NULL,&n,A,&ld,B,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,&info));
213: #endif
214:   if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xTGEVC %i",info);

216:   /* normalize eigenvectors */
217:   for (i=0;i<n;i++) {
218:     iscomplex = (i<n-1 && (A[i+1+i*ld]!=0.0 || B[i+1+i*ld]!=0.0))? PETSC_TRUE: PETSC_FALSE;
219:     norm = BLASnrm2_(&n,Z+i*ld,&inc);
220: #if !defined(PETSC_USE_COMPLEX)
221:     if (iscomplex) {
222:       tmp = BLASnrm2_(&n,Z+(i+1)*ld,&inc);
223:       norm = SlepcAbsEigenvalue(norm,tmp);
224:     }
225: #endif
226:     tmp = 1.0 / norm;
227:     PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z+i*ld,&inc));
228: #if !defined(PETSC_USE_COMPLEX)
229:     if (iscomplex) PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z+(i+1)*ld,&inc));
230: #endif
231:     if (iscomplex) i++;
232:   }
233:   return(0);
234: #endif
235: }

239: PetscErrorCode DSVectors_GNHEP(DS ds,DSMatType mat,PetscInt *k,PetscReal *rnorm)
240: {

244:   switch (mat) {
245:     case DS_MAT_X:
246:     case DS_MAT_Y:
247:       if (k) {
248:         DSVectors_GNHEP_Eigen_Some(ds,k,rnorm,mat == DS_MAT_Y?PETSC_TRUE:PETSC_FALSE);
249:       } else {
250:         DSVectors_GNHEP_Eigen_All(ds,mat == DS_MAT_Y?PETSC_TRUE:PETSC_FALSE);
251:       }
252:       break;
253:     default:
254:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
255:   }
256:   return(0);
257: }

261: PetscErrorCode DSNormalize_GNHEP(DS ds,DSMatType mat,PetscInt col)
262: {
264:   PetscInt       i,i0,i1;
265:   PetscBLASInt   ld,n,one = 1;
266:   PetscScalar    *A = ds->mat[DS_MAT_A],*B = ds->mat[DS_MAT_B],norm,*x;
267: #if !defined(PETSC_USE_COMPLEX)
268:   PetscScalar    norm0;
269: #endif

272:   switch (mat) {
273:     case DS_MAT_X:
274:     case DS_MAT_Y:
275:     case DS_MAT_Q:
276:     case DS_MAT_Z:
277:       /* Supported matrices */
278:       break;
279:     case DS_MAT_U:
280:     case DS_MAT_VT:
281:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
282:       break;
283:     default:
284:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
285:   }

287:   PetscBLASIntCast(ds->n,&n);
288:   PetscBLASIntCast(ds->ld,&ld);
289:   DSGetArray(ds,mat,&x);
290:   if (col < 0) {
291:     i0 = 0; i1 = ds->n;
292:   } else if (col>0 && (A[ds->ld*(col-1)+col] != 0.0 || (B && B[ds->ld*(col-1)+col] != 0.0))) {
293:     i0 = col-1; i1 = col+1;
294:   } else {
295:     i0 = col; i1 = col+1;
296:   }
297:   for (i=i0;i<i1;i++) {
298: #if !defined(PETSC_USE_COMPLEX)
299:     if (i<n-1 && (A[ds->ld*i+i+1] != 0.0 || (B && B[ds->ld*i+i+1] != 0.0))) {
300:       norm = BLASnrm2_(&n,&x[ld*i],&one);
301:       norm0 = BLASnrm2_(&n,&x[ld*(i+1)],&one);
302:       norm = 1.0/SlepcAbsEigenvalue(norm,norm0);
303:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
304:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*(i+1)],&one));
305:       i++;
306:     } else
307: #endif
308:     {
309:       norm = BLASnrm2_(&n,&x[ld*i],&one);
310:       norm = 1.0/norm;
311:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
312:     }
313:   }
314:   return(0);
315: }

319: static PetscErrorCode DSSort_GNHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
320: {
321: #if defined(PETSC_MISSING_LAPACK_TGSEN)
323:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGSEN - Lapack routine is unavailable");
324: #else
326:   PetscInt       i;
327:   PetscBLASInt   info,n,ld,mout,lwork,liwork,*iwork,*selection,zero_=0,true_=1;
328:   PetscScalar    *S = ds->mat[DS_MAT_A],*T = ds->mat[DS_MAT_B],*Q = ds->mat[DS_MAT_Q],*Z = ds->mat[DS_MAT_Z],*work,*beta;

331:   if (!ds->sc) return(0);
332:   PetscBLASIntCast(ds->n,&n);
333:   PetscBLASIntCast(ds->ld,&ld);
334: #if !defined(PETSC_USE_COMPLEX)
335:   lwork = 4*n+16;
336: #else
337:   lwork = 1;
338: #endif
339:   liwork = 1;
340:   DSAllocateWork_Private(ds,lwork+2*n,0,liwork+n);
341:   beta      = ds->work;
342:   work      = ds->work + n;
343:   lwork     = ds->lwork - n;
344:   selection = ds->iwork;
345:   iwork     = ds->iwork + n;
346:   liwork    = ds->liwork - n;
347:   /* Compute the selected eigenvalue to be in the leading position */
348:   DSSortEigenvalues_Private(ds,rr,ri,ds->perm,PETSC_FALSE);
349:   PetscMemzero(selection,n*sizeof(PetscBLASInt));
350:   for (i=0; i<*k; i++) selection[ds->perm[i]] = 1;
351: #if !defined(PETSC_USE_COMPLEX)
352:   PetscStackCallBLAS("LAPACKtgsen",LAPACKtgsen_(&zero_,&true_,&true_,selection,&n,S,&ld,T,&ld,wr,wi,beta,Z,&ld,Q,&ld,&mout,NULL,NULL,NULL,work,&lwork,iwork,&liwork,&info));
353: #else
354:   PetscStackCallBLAS("LAPACKtgsen",LAPACKtgsen_(&zero_,&true_,&true_,selection,&n,S,&ld,T,&ld,wr,beta,Z,&ld,Q,&ld,&mout,NULL,NULL,NULL,work,&lwork,iwork,&liwork,&info));
355: #endif
356:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTGSEN %d",info);
357:   *k = mout;
358:   for (i=0;i<n;i++) {
359:     if (beta[i]==0.0) wr[i] = (PetscRealPart(wr[i])>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
360:     else wr[i] /= beta[i];
361: #if !defined(PETSC_USE_COMPLEX)
362:     if (beta[i]==0.0) wi[i] = (wi[i]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
363:     else wi[i] /= beta[i];
364: #endif
365:   }
366:   return(0);
367: #endif
368: }

372: static PetscErrorCode DSSort_GNHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi)
373: {
374: #if defined(SLEPC_MISSING_LAPACK_TGEXC) || !defined(PETSC_USE_COMPLEX) && (defined(SLEPC_MISSING_LAPACK_LAMCH) || defined(SLEPC_MISSING_LAPACK_LAG2))
376:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGEXC/LAMCH/LAG2 - Lapack routines are unavailable");
377: #else
379:   PetscScalar    re;
380:   PetscInt       i,j,pos,result;
381:   PetscBLASInt   ifst,ilst,info,n,ld,one=1;
382:   PetscScalar    *S = ds->mat[DS_MAT_A],*T = ds->mat[DS_MAT_B],*Z = ds->mat[DS_MAT_Z],*Q = ds->mat[DS_MAT_Q];
383: #if !defined(PETSC_USE_COMPLEX)
384:   PetscBLASInt   lwork;
385:   PetscScalar    *work,a,safmin,scale1,scale2,im;
386: #endif

389:   if (!ds->sc) return(0);
390:   PetscBLASIntCast(ds->n,&n);
391:   PetscBLASIntCast(ds->ld,&ld);
392: #if !defined(PETSC_USE_COMPLEX)
393:   lwork = -1;
394:   PetscStackCallBLAS("LAPACKtgexc",LAPACKtgexc_(&one,&one,&ld,NULL,&ld,NULL,&ld,NULL,&ld,NULL,&ld,&one,&one,&a,&lwork,&info));
395:   safmin = LAPACKlamch_("S");
396:   PetscBLASIntCast((PetscInt)a,&lwork);
397:   DSAllocateWork_Private(ds,lwork,0,0);
398:   work = ds->work;
399: #endif
400:   /* selection sort */
401:   for (i=ds->l;i<n-1;i++) {
402:     re = wr[i];
403: #if !defined(PETSC_USE_COMPLEX)
404:     im = wi[i];
405: #endif
406:     pos = 0;
407:     j = i+1; /* j points to the next eigenvalue */
408: #if !defined(PETSC_USE_COMPLEX)
409:     if (im != 0) j=i+2;
410: #endif
411:     /* find minimum eigenvalue */
412:     for (;j<n;j++) {
413: #if !defined(PETSC_USE_COMPLEX)
414:       SlepcSCCompare(ds->sc,re,im,wr[j],wi[j],&result);
415: #else
416:       SlepcSCCompare(ds->sc,re,0.0,wr[j],0.0,&result);
417: #endif
418:       if (result > 0) {
419:         re = wr[j];
420: #if !defined(PETSC_USE_COMPLEX)
421:         im = wi[j];
422: #endif
423:         pos = j;
424:       }
425: #if !defined(PETSC_USE_COMPLEX)
426:       if (wi[j] != 0) j++;
427: #endif
428:     }
429:     if (pos) {
430:       /* interchange blocks */
431:       PetscBLASIntCast(pos+1,&ifst);
432:       PetscBLASIntCast(i+1,&ilst);
433: #if !defined(PETSC_USE_COMPLEX)
434:       PetscStackCallBLAS("LAPACKtgexc",LAPACKtgexc_(&one,&one,&n,S,&ld,T,&ld,Z,&ld,Q,&ld,&ifst,&ilst,work,&lwork,&info));
435: #else
436:       PetscStackCallBLAS("LAPACKtgexc",LAPACKtgexc_(&one,&one,&n,S,&ld,T,&ld,Z,&ld,Q,&ld,&ifst,&ilst,&info));
437: #endif
438:       if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xTGEXC %i",info);
439:       /* recover original eigenvalues from T and S matrices */
440:       for (j=i;j<n;j++) {
441: #if !defined(PETSC_USE_COMPLEX)
442:         if (j<n-1 && S[j*ld+j+1] != 0.0) {
443:           /* complex conjugate eigenvalue */
444:           PetscStackCallBLAS("LAPACKlag2",LAPACKlag2_(S+j*ld+j,&ld,T+j*ld+j,&ld,&safmin,&scale1,&scale2,&re,&a,&im));
445:           wr[j] = re / scale1;
446:           wi[j] = im / scale1;
447:           wr[j+1] = a / scale2;
448:           wi[j+1] = -wi[j];
449:           j++;
450:         } else
451: #endif
452:         {
453:           if (T[j*ld+j] == 0.0) wr[j] = (PetscRealPart(S[j*ld+j])>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
454:           else wr[j] = S[j*ld+j] / T[j*ld+j];
455: #if !defined(PETSC_USE_COMPLEX)
456:           wi[j] = 0.0;
457: #endif
458:         }
459:       }
460:     }
461: #if !defined(PETSC_USE_COMPLEX)
462:     if (wi[i] != 0.0) i++;
463: #endif
464:   }
465:   return(0);
466: #endif
467: }

471: PetscErrorCode DSSort_GNHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
472: {

476:   if (!rr || wr == rr) {
477:     DSSort_GNHEP_Total(ds,wr,wi);
478:   } else {
479:     DSSort_GNHEP_Arbitrary(ds,wr,wi,rr,ri,k);
480:   }
481:   return(0);
482: }

486: /*
487:    Write zeros from the column k to n in the lower triangular part of the
488:    matrices S and T, and inside 2-by-2 diagonal blocks of T in order to
489:    make (S,T) a valid Schur decompositon.
490: */
491: static PetscErrorCode CleanDenseSchur(PetscInt n,PetscInt k,PetscScalar *S,PetscInt ldS,PetscScalar *T,PetscInt ldT,PetscScalar *X,PetscInt ldX,PetscScalar *Y,PetscInt ldY,PetscBool doProd)
492: {
493: #if defined(SLEPC_MISSING_LAPACK_LASV2)
495:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LASV2 - Lapack routine is unavailable");
496: #else
497:   PetscInt       i,j;
498: #if defined(PETSC_USE_COMPLEX)
499:   PetscScalar    s;
500: #else
502:   PetscBLASInt   ldS_,ldT_,n_i,n_i_2,one=1,n_,i_2,i_;
503:   PetscScalar    b11,b22,sr,cr,sl,cl;
504: #endif

507:   if (!doProd && X) {
508:     for (i=0;i<n;i++) for (j=0;j<n;j++) X[ldX*i+j] = 0.0;
509:     for (i=0;i<n;i++) X[ldX*i+i] = 1.0;
510:   }
511:   if (!doProd && Y) {
512:     for (i=0;i<n;i++) for (j=0;j<n;j++) Y[ldY*i+j] = 0.0;
513:     for (i=0;i<n;i++) Y[ldX*i+i] = 1.0;
514:   }

516: #if defined(PETSC_USE_COMPLEX)
517:   for (i=k; i<n; i++) {
518:     /* Some functions need the diagonal elements in T be real */
519:     if (T && PetscImaginaryPart(T[ldT*i+i]) != 0.0) {
520:       s = PetscConj(T[ldT*i+i])/PetscAbsScalar(T[ldT*i+i]);
521:       for (j=0;j<=i;j++) {
522:         T[ldT*i+j] *= s;
523:         S[ldS*i+j] *= s;
524:       }
525:       T[ldT*i+i] = PetscRealPart(T[ldT*i+i]);
526:       if (X) for (j=0;j<n;j++) X[ldX*i+j] *= s;
527:     }
528:     j = i+1;
529:     if (j<n) {
530:       S[ldS*i+j] = 0.0;
531:       if (T) T[ldT*i+j] = 0.0;
532:     }
533:   }
534: #else
535:   PetscBLASIntCast(ldS,&ldS_);
536:   PetscBLASIntCast(ldT,&ldT_);
537:   PetscBLASIntCast(n,&n_);
538:   for (i=k;i<n-1;i++) {
539:     if (S[ldS*i+i+1] != 0.0) {
540:       /* Check if T(i+1,i) and T(i,i+1) are zero */
541:       if (T[ldT*(i+1)+i] != 0.0 || T[ldT*i+i+1] != 0.0) {
542:         /* Check if T(i+1,i) and T(i,i+1) are negligible */
543:         if (PetscAbs(T[ldT*(i+1)+i])+PetscAbs(T[ldT*i+i+1]) < (PetscAbs(T[ldT*i+i])+PetscAbs(T[ldT*(i+1)+i+1]))*PETSC_MACHINE_EPSILON) {
544:           T[ldT*i+i+1] = 0.0;
545:           T[ldT*(i+1)+i] = 0.0;

547:         } else {
548:           /* If one of T(i+1,i) or T(i,i+1) is negligible, we make zero the other element */
549:           if (PetscAbs(T[ldT*i+i+1]) < (PetscAbs(T[ldT*i+i])+PetscAbs(T[ldT*(i+1)+i+1])+PetscAbs(T[ldT*(i+1)+i]))*PETSC_MACHINE_EPSILON) {
550:             PetscStackCallBLAS("LAPACKlasv2",LAPACKlasv2_(&T[ldT*i+i],&T[ldT*(i+1)+i],&T[ldT*(i+1)+i+1],&b22,&b11,&sl,&cl,&sr,&cr));
551:           } else if (PetscAbs(T[ldT*(i+1)+i]) < (PetscAbs(T[ldT*i+i])+PetscAbs(T[ldT*(i+1)+i+1])+PetscAbs(T[ldT*i+i+1]))*PETSC_MACHINE_EPSILON) {
552:             PetscStackCallBLAS("LAPACKlasv2",LAPACKlasv2_(&T[ldT*i+i],&T[ldT*i+i+1],&T[ldT*(i+1)+i+1],&b22,&b11,&sr,&cr,&sl,&cl));
553:           } else {
554:             SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Unsupported format. Call DSSolve before this function");
555:           }
556:           PetscBLASIntCast(n-i,&n_i);
557:           n_i_2 = n_i - 2;
558:           PetscBLASIntCast(i+2,&i_2);
559:           PetscBLASIntCast(i,&i_);
560:           if (b11 < 0.0) {
561:             cr  = -cr;
562:             sr  = -sr;
563:             b11 = -b11;
564:             b22 = -b22;
565:           }
566:           PetscStackCallBLAS("BLASrot",BLASrot_(&n_i,&S[ldS*i+i],&ldS_,&S[ldS*i+i+1],&ldS_,&cl,&sl));
567:           PetscStackCallBLAS("BLASrot",BLASrot_(&i_2,&S[ldS*i],&one,&S[ldS*(i+1)],&one,&cr,&sr));
568:           PetscStackCallBLAS("BLASrot",BLASrot_(&n_i_2,&T[ldT*(i+2)+i],&ldT_,&T[ldT*(i+2)+i+1],&ldT_,&cl,&sl));
569:           PetscStackCallBLAS("BLASrot",BLASrot_(&i_,&T[ldT*i],&one,&T[ldT*(i+1)],&one,&cr,&sr));
570:           if (X) PetscStackCallBLAS("BLASrot",BLASrot_(&n_,&X[ldX*i],&one,&X[ldX*(i+1)],&one,&cr,&sr));
571:           if (Y) PetscStackCallBLAS("BLASrot",BLASrot_(&n_,&Y[ldY*i],&one,&Y[ldY*(i+1)],&one,&cl,&sl));
572:           T[ldT*i+i] = b11;
573:           T[ldT*i+i+1] = 0.0;
574:           T[ldT*(i+1)+i] = 0.0;
575:           T[ldT*(i+1)+i+1] = b22;
576:         }
577:       }
578:     i++;
579:     }
580:   }
581: #endif
582:   return(0);
583: #endif
584: }

588: PetscErrorCode DSSolve_GNHEP(DS ds,PetscScalar *wr,PetscScalar *wi)
589: {
590: #if defined(PETSC_MISSING_LAPACK_GGES)
592:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GGES - Lapack routines are unavailable");
593: #else
595:   PetscScalar    *work,*beta,a;
596:   PetscInt       i;
597:   PetscBLASInt   lwork,info,n,ld,iaux;
598:   PetscScalar    *A = ds->mat[DS_MAT_A],*B = ds->mat[DS_MAT_B],*Z = ds->mat[DS_MAT_Z],*Q = ds->mat[DS_MAT_Q];

601: #if !defined(PETSC_USE_COMPLEX)
603: #endif
604:   PetscBLASIntCast(ds->n,&n);
605:   PetscBLASIntCast(ds->ld,&ld);
606:   lwork = -1;
607: #if !defined(PETSC_USE_COMPLEX)
608:   PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,wi,NULL,Z,&ld,Q,&ld,&a,&lwork,NULL,&info));
609:   PetscBLASIntCast((PetscInt)a,&lwork);
610:   DSAllocateWork_Private(ds,lwork+ld,0,0);
611:   beta = ds->work;
612:   work = beta+ds->n;
613:   PetscBLASIntCast(ds->lwork-ds->n,&lwork);
614:   PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,wi,beta,Z,&ld,Q,&ld,work,&lwork,NULL,&info));
615: #else
616:   PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,NULL,Z,&ld,Q,&ld,&a,&lwork,NULL,NULL,&info));
617:   PetscBLASIntCast((PetscInt)PetscRealPart(a),&lwork);
618:   DSAllocateWork_Private(ds,lwork+ld,8*ld,0);
619:   beta = ds->work;
620:   work = beta+ds->n;
621:   PetscBLASIntCast(ds->lwork-ds->n,&lwork);
622:   PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,beta,Z,&ld,Q,&ld,work,&lwork,ds->rwork,NULL,&info));
623: #endif
624:   if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xGGES %i",info);
625:   for (i=0;i<n;i++) {
626:     if (beta[i]==0.0) wr[i] = (PetscRealPart(wr[i])>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
627:     else wr[i] /= beta[i];
628: #if !defined(PETSC_USE_COMPLEX)
629:     if (beta[i]==0.0) wi[i] = (wi[i]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
630:     else wi[i] /= beta[i];
631: #else
632:     if (wi) wi[i] = 0.0;
633: #endif
634:   }
635:   return(0);
636: #endif
637: }

641: PETSC_EXTERN PetscErrorCode DSCreate_GNHEP(DS ds)
642: {
644:   ds->ops->allocate      = DSAllocate_GNHEP;
645:   ds->ops->view          = DSView_GNHEP;
646:   ds->ops->vectors       = DSVectors_GNHEP;
647:   ds->ops->solve[0]      = DSSolve_GNHEP;
648:   ds->ops->sort          = DSSort_GNHEP;
649:   ds->ops->normalize     = DSNormalize_GNHEP;
650:   return(0);
651: }

slepc-3.7.4/src/sys/classes/ds/impls/gnhep/makefile.html0000644000175000017500000000471113107004621022526 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dsgnhep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/gnhep/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/gnhep/index.html0000644000175000017500000000216613107004621022062 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dsgnhep.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/gnhep/dsgnhep.c0000644000175000017500000005602713107004621021666 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include /* 1) Patterns of A and B DS_STATE_RAW: DS_STATE_INTERM/CONDENSED 0 n-1 0 n-1 ------------- ------------- 0 |* * * * * *| 0 |* * * * * *| |* * * * * *| | * * * * *| |* * * * * *| | * * * *| |* * * * * *| | * * * *| |* * * * * *| | * *| n-1 |* * * * * *| n-1 | *| ------------- ------------- 2) Moreover, P and Q are assumed to be the identity in DS_STATE_INTERMEDIATE. */ static PetscErrorCode CleanDenseSchur(PetscInt n,PetscInt k,PetscScalar *S,PetscInt ldS,PetscScalar *T,PetscInt ldT,PetscScalar *X,PetscInt ldX,PetscScalar *Y,PetscInt ldY,PetscBool doProd); #undef __FUNCT__ #define __FUNCT__ "DSAllocate_GNHEP" PetscErrorCode DSAllocate_GNHEP(DS ds,PetscInt ld) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_B);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_Z);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_Q);CHKERRQ(ierr); ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView_GNHEP" PetscErrorCode DSView_GNHEP(DS ds,PetscViewer viewer) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSViewMat(ds,viewer,DS_MAT_A);CHKERRQ(ierr); ierr = DSViewMat(ds,viewer,DS_MAT_B);CHKERRQ(ierr); if (ds->state>DS_STATE_INTERMEDIATE) { ierr = DSViewMat(ds,viewer,DS_MAT_Z);CHKERRQ(ierr); ierr = DSViewMat(ds,viewer,DS_MAT_Q);CHKERRQ(ierr); } if (ds->mat[DS_MAT_X]) { ierr = DSViewMat(ds,viewer,DS_MAT_X);CHKERRQ(ierr); } if (ds->mat[DS_MAT_Y]) { ierr = DSViewMat(ds,viewer,DS_MAT_Y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_GNHEP_Eigen_Some" static PetscErrorCode DSVectors_GNHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left) { #if defined(SLEPC_MISSING_LAPACK_TGEVC) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGEVC - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt n,ld,mout,info,*select,mm,inc = 1; PetscScalar *X,*Y,*Z,*A = ds->mat[DS_MAT_A],*B = ds->mat[DS_MAT_B],tmp,fone=1.0,fzero=0.0; PetscReal norm; PetscBool iscomplex = PETSC_FALSE; const char *side; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); if (left) { X = NULL; Y = &ds->mat[DS_MAT_Y][ld*(*k)]; side = "L"; } else { X = &ds->mat[DS_MAT_X][ld*(*k)]; Y = NULL; side = "R"; } Z = left? Y: X; ierr = DSAllocateWork_Private(ds,0,0,ld);CHKERRQ(ierr); select = ds->iwork; for (i=0;istate <= DS_STATE_INTERMEDIATE) { ierr = DSSetIdentity(ds,DS_MAT_Q);CHKERRQ(ierr); ierr = DSSetIdentity(ds,DS_MAT_Z);CHKERRQ(ierr); } ierr = CleanDenseSchur(n,0,A,ld,B,ld,ds->mat[DS_MAT_Q],ld,ds->mat[DS_MAT_Z],ld,PETSC_TRUE);CHKERRQ(ierr); if (ds->state < DS_STATE_CONDENSED) { ierr = DSSetState(ds,DS_STATE_CONDENSED);CHKERRQ(ierr); } /* compute k-th eigenvector */ select[*k] = (PetscBLASInt)PETSC_TRUE; #if defined(PETSC_USE_COMPLEX) mm = 1; ierr = DSAllocateWork_Private(ds,2*ld,2*ld,0);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKtgevc",LAPACKtgevc_(side,"S",select,&n,A,&ld,B,&ld,Y,&ld,X,&ld,&mm,&mout,ds->work,ds->rwork,&info)); #else if ((*k)work,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTGEVC %i",info); if (!select[*k] || mout != mm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong arguments in call to Lapack xTGEVC"); /* accumulate and normalize eigenvectors */ ierr = PetscMemcpy(ds->work,Z,mm*ld*sizeof(PetscScalar));CHKERRQ(ierr); PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&mm,&n,&fone,ds->mat[left?DS_MAT_Z:DS_MAT_Q],&ld,ds->work,&ld,&fzero,Z,&ld)); norm = BLASnrm2_(&n,Z,&inc); #if !defined(PETSC_USE_COMPLEX) if (iscomplex) { tmp = BLASnrm2_(&n,Z+ld,&inc); norm = SlepcAbsEigenvalue(norm,tmp); } #endif tmp = 1.0 / norm; PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z,&inc)); #if !defined(PETSC_USE_COMPLEX) if (iscomplex) PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z+ld,&inc)); #endif /* set output arguments */ if (iscomplex) (*k)++; if (rnorm) { if (iscomplex) *rnorm = SlepcAbsEigenvalue(Z[n-1],Z[n-1+ld]); else *rnorm = PetscAbsScalar(Z[n-1]); } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSVectors_GNHEP_Eigen_All" static PetscErrorCode DSVectors_GNHEP_Eigen_All(DS ds,PetscBool left) { #if defined(SLEPC_MISSING_LAPACK_TGEVC) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGEVC - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt n,ld,mout,info,inc = 1; PetscBool iscomplex; PetscScalar *X,*Y,*Z,*A = ds->mat[DS_MAT_A],*B = ds->mat[DS_MAT_B],tmp; PetscReal norm; const char *side,*back; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); if (left) { X = NULL; Y = ds->mat[DS_MAT_Y]; side = "L"; } else { X = ds->mat[DS_MAT_X]; Y = NULL; side = "R"; } Z = left? Y: X; if (ds->state <= DS_STATE_INTERMEDIATE) { ierr = DSSetIdentity(ds,DS_MAT_Q);CHKERRQ(ierr); ierr = DSSetIdentity(ds,DS_MAT_Z);CHKERRQ(ierr); } ierr = CleanDenseSchur(n,0,A,ld,B,ld,ds->mat[DS_MAT_Q],ld,ds->mat[DS_MAT_Z],ld,PETSC_TRUE);CHKERRQ(ierr); if (ds->state>=DS_STATE_CONDENSED) { /* DSSolve() has been called, backtransform with matrix Q */ back = "B"; ierr = PetscMemcpy(left?Y:X,ds->mat[left?DS_MAT_Z:DS_MAT_Q],ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); } else { back = "A"; ierr = DSSetState(ds,DS_STATE_CONDENSED);CHKERRQ(ierr); } #if defined(PETSC_USE_COMPLEX) ierr = DSAllocateWork_Private(ds,2*ld,2*ld,0);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKtgevc",LAPACKtgevc_(side,back,NULL,&n,A,&ld,B,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,ds->rwork,&info)); #else ierr = DSAllocateWork_Private(ds,6*ld,0,0);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKtgevc",LAPACKtgevc_(side,back,NULL,&n,A,&ld,B,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,&info)); #endif if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xTGEVC %i",info); /* normalize eigenvectors */ for (i=0;imat[DS_MAT_A],*B = ds->mat[DS_MAT_B],norm,*x; #if !defined(PETSC_USE_COMPLEX) PetscScalar norm0; #endif PetscFunctionBegin; switch (mat) { case DS_MAT_X: case DS_MAT_Y: case DS_MAT_Q: case DS_MAT_Z: /* Supported matrices */ break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&x);CHKERRQ(ierr); if (col < 0) { i0 = 0; i1 = ds->n; } else if (col>0 && (A[ds->ld*(col-1)+col] != 0.0 || (B && B[ds->ld*(col-1)+col] != 0.0))) { i0 = col-1; i1 = col+1; } else { i0 = col; i1 = col+1; } for (i=i0;ild*i+i+1] != 0.0 || (B && B[ds->ld*i+i+1] != 0.0))) { norm = BLASnrm2_(&n,&x[ld*i],&one); norm0 = BLASnrm2_(&n,&x[ld*(i+1)],&one); norm = 1.0/SlepcAbsEigenvalue(norm,norm0); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one)); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*(i+1)],&one)); i++; } else #endif { norm = BLASnrm2_(&n,&x[ld*i],&one); norm = 1.0/norm; PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one)); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSort_GNHEP_Arbitrary" static PetscErrorCode DSSort_GNHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k) { #if defined(PETSC_MISSING_LAPACK_TGSEN) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGSEN - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt info,n,ld,mout,lwork,liwork,*iwork,*selection,zero_=0,true_=1; PetscScalar *S = ds->mat[DS_MAT_A],*T = ds->mat[DS_MAT_B],*Q = ds->mat[DS_MAT_Q],*Z = ds->mat[DS_MAT_Z],*work,*beta; PetscFunctionBegin; if (!ds->sc) PetscFunctionReturn(0); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) lwork = 4*n+16; #else lwork = 1; #endif liwork = 1; ierr = DSAllocateWork_Private(ds,lwork+2*n,0,liwork+n);CHKERRQ(ierr); beta = ds->work; work = ds->work + n; lwork = ds->lwork - n; selection = ds->iwork; iwork = ds->iwork + n; liwork = ds->liwork - n; /* Compute the selected eigenvalue to be in the leading position */ ierr = DSSortEigenvalues_Private(ds,rr,ri,ds->perm,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscMemzero(selection,n*sizeof(PetscBLASInt));CHKERRQ(ierr); for (i=0; i<*k; i++) selection[ds->perm[i]] = 1; #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKtgsen",LAPACKtgsen_(&zero_,&true_,&true_,selection,&n,S,&ld,T,&ld,wr,wi,beta,Z,&ld,Q,&ld,&mout,NULL,NULL,NULL,work,&lwork,iwork,&liwork,&info)); #else PetscStackCallBLAS("LAPACKtgsen",LAPACKtgsen_(&zero_,&true_,&true_,selection,&n,S,&ld,T,&ld,wr,beta,Z,&ld,Q,&ld,&mout,NULL,NULL,NULL,work,&lwork,iwork,&liwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTGSEN %d",info); *k = mout; for (i=0;i0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else wr[i] /= beta[i]; #if !defined(PETSC_USE_COMPLEX) if (beta[i]==0.0) wi[i] = (wi[i]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else wi[i] /= beta[i]; #endif } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSSort_GNHEP_Total" static PetscErrorCode DSSort_GNHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(SLEPC_MISSING_LAPACK_TGEXC) || !defined(PETSC_USE_COMPLEX) && (defined(SLEPC_MISSING_LAPACK_LAMCH) || defined(SLEPC_MISSING_LAPACK_LAG2)) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TGEXC/LAMCH/LAG2 - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscScalar re; PetscInt i,j,pos,result; PetscBLASInt ifst,ilst,info,n,ld,one=1; PetscScalar *S = ds->mat[DS_MAT_A],*T = ds->mat[DS_MAT_B],*Z = ds->mat[DS_MAT_Z],*Q = ds->mat[DS_MAT_Q]; #if !defined(PETSC_USE_COMPLEX) PetscBLASInt lwork; PetscScalar *work,a,safmin,scale1,scale2,im; #endif PetscFunctionBegin; if (!ds->sc) PetscFunctionReturn(0); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) lwork = -1; PetscStackCallBLAS("LAPACKtgexc",LAPACKtgexc_(&one,&one,&ld,NULL,&ld,NULL,&ld,NULL,&ld,NULL,&ld,&one,&one,&a,&lwork,&info)); safmin = LAPACKlamch_("S"); ierr = PetscBLASIntCast((PetscInt)a,&lwork);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,lwork,0,0);CHKERRQ(ierr); work = ds->work; #endif /* selection sort */ for (i=ds->l;isc,re,im,wr[j],wi[j],&result);CHKERRQ(ierr); #else ierr = SlepcSCCompare(ds->sc,re,0.0,wr[j],0.0,&result);CHKERRQ(ierr); #endif if (result > 0) { re = wr[j]; #if !defined(PETSC_USE_COMPLEX) im = wi[j]; #endif pos = j; } #if !defined(PETSC_USE_COMPLEX) if (wi[j] != 0) j++; #endif } if (pos) { /* interchange blocks */ ierr = PetscBLASIntCast(pos+1,&ifst);CHKERRQ(ierr); ierr = PetscBLASIntCast(i+1,&ilst);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKtgexc",LAPACKtgexc_(&one,&one,&n,S,&ld,T,&ld,Z,&ld,Q,&ld,&ifst,&ilst,work,&lwork,&info)); #else PetscStackCallBLAS("LAPACKtgexc",LAPACKtgexc_(&one,&one,&n,S,&ld,T,&ld,Z,&ld,Q,&ld,&ifst,&ilst,&info)); #endif if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xTGEXC %i",info); /* recover original eigenvalues from T and S matrices */ for (j=i;j0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else wr[j] = S[j*ld+j] / T[j*ld+j]; #if !defined(PETSC_USE_COMPLEX) wi[j] = 0.0; #endif } } } #if !defined(PETSC_USE_COMPLEX) if (wi[i] != 0.0) i++; #endif } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSSort_GNHEP" PetscErrorCode DSSort_GNHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k) { PetscErrorCode ierr; PetscFunctionBegin; if (!rr || wr == rr) { ierr = DSSort_GNHEP_Total(ds,wr,wi);CHKERRQ(ierr); } else { ierr = DSSort_GNHEP_Arbitrary(ds,wr,wi,rr,ri,k);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "CleanDenseSchur" /* Write zeros from the column k to n in the lower triangular part of the matrices S and T, and inside 2-by-2 diagonal blocks of T in order to make (S,T) a valid Schur decompositon. */ static PetscErrorCode CleanDenseSchur(PetscInt n,PetscInt k,PetscScalar *S,PetscInt ldS,PetscScalar *T,PetscInt ldT,PetscScalar *X,PetscInt ldX,PetscScalar *Y,PetscInt ldY,PetscBool doProd) { #if defined(SLEPC_MISSING_LAPACK_LASV2) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LASV2 - Lapack routine is unavailable"); #else PetscInt i,j; #if defined(PETSC_USE_COMPLEX) PetscScalar s; #else PetscErrorCode ierr; PetscBLASInt ldS_,ldT_,n_i,n_i_2,one=1,n_,i_2,i_; PetscScalar b11,b22,sr,cr,sl,cl; #endif PetscFunctionBegin; if (!doProd && X) { for (i=0;imat[DS_MAT_A],*B = ds->mat[DS_MAT_B],*Z = ds->mat[DS_MAT_Z],*Q = ds->mat[DS_MAT_Q]; PetscFunctionBegin; #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(wi,3); #endif ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); lwork = -1; #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,wi,NULL,Z,&ld,Q,&ld,&a,&lwork,NULL,&info)); ierr = PetscBLASIntCast((PetscInt)a,&lwork);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,lwork+ld,0,0);CHKERRQ(ierr); beta = ds->work; work = beta+ds->n; ierr = PetscBLASIntCast(ds->lwork-ds->n,&lwork);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,wi,beta,Z,&ld,Q,&ld,work,&lwork,NULL,&info)); #else PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,NULL,Z,&ld,Q,&ld,&a,&lwork,NULL,NULL,&info)); ierr = PetscBLASIntCast((PetscInt)PetscRealPart(a),&lwork);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,lwork+ld,8*ld,0);CHKERRQ(ierr); beta = ds->work; work = beta+ds->n; ierr = PetscBLASIntCast(ds->lwork-ds->n,&lwork);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgges",LAPACKgges_("V","V","N",NULL,&n,A,&ld,B,&ld,&iaux,wr,beta,Z,&ld,Q,&ld,work,&lwork,ds->rwork,NULL,&info)); #endif if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xGGES %i",info); for (i=0;i0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else wr[i] /= beta[i]; #if !defined(PETSC_USE_COMPLEX) if (beta[i]==0.0) wi[i] = (wi[i]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else wi[i] /= beta[i]; #else if (wi) wi[i] = 0.0; #endif } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSCreate_GNHEP" PETSC_EXTERN PetscErrorCode DSCreate_GNHEP(DS ds) { PetscFunctionBegin; ds->ops->allocate = DSAllocate_GNHEP; ds->ops->view = DSView_GNHEP; ds->ops->vectors = DSVectors_GNHEP; ds->ops->solve[0] = DSSolve_GNHEP; ds->ops->sort = DSSort_GNHEP; ds->ops->normalize = DSNormalize_GNHEP; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/ghep/0000755000175000017500000000000013107004621017702 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/ghep/makefile0000644000175000017500000000216413107004621021405 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dsghep.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/ghep/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/ghep/makefile.html0000644000175000017500000000470513107004621022353 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dsghep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/ghep/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/ghep/dsghep.c0000644000175000017500000001713413107004621021326 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "DSAllocate_GHEP" PetscErrorCode DSAllocate_GHEP(DS ds,PetscInt ld) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_B);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_Q);CHKERRQ(ierr); ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView_GHEP" PetscErrorCode DSView_GHEP(DS ds,PetscViewer viewer) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSViewMat(ds,viewer,DS_MAT_A);CHKERRQ(ierr); ierr = DSViewMat(ds,viewer,DS_MAT_B);CHKERRQ(ierr); if (ds->state>DS_STATE_INTERMEDIATE) { ierr = DSViewMat(ds,viewer,DS_MAT_Q);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_GHEP" PetscErrorCode DSVectors_GHEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm) { PetscScalar *Q = ds->mat[DS_MAT_Q]; PetscInt ld = ds->ld,i; PetscErrorCode ierr; PetscFunctionBegin; if (rnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); switch (mat) { case DS_MAT_X: case DS_MAT_Y: if (j) { if (ds->state>=DS_STATE_CONDENSED) { ierr = PetscMemcpy(ds->mat[mat]+(*j)*ld,Q+(*j)*ld,ld*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemzero(ds->mat[mat]+(*j)*ld,ld*sizeof(PetscScalar));CHKERRQ(ierr); *(ds->mat[mat]+(*j)+(*j)*ld) = 1.0; } } else { if (ds->state>=DS_STATE_CONDENSED) { ierr = PetscMemcpy(ds->mat[mat],Q,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemzero(ds->mat[mat],ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;in;i++) *(ds->mat[mat]+i+i*ld) = 1.0; } } break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNormalize_GHEP" PetscErrorCode DSNormalize_GHEP(DS ds,DSMatType mat,PetscInt col) { PetscErrorCode ierr; PetscInt i,i0,i1; PetscBLASInt ld,n,one = 1; PetscScalar norm,*x; PetscFunctionBegin; switch (mat) { case DS_MAT_X: case DS_MAT_Y: case DS_MAT_Q: break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } /* All the matrices resulting from DSVectors and DSSolve are B-normalized, but function returns 2-normalized vectors. */ ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&x);CHKERRQ(ierr); if (col < 0) { i0 = 0; i1 = ds->n; } else { i0 = col; i1 = col+1; } for (i=i0;ild; PetscScalar *A; PetscFunctionBegin; if (!ds->sc) PetscFunctionReturn(0); n = ds->n; l = ds->l; A = ds->mat[DS_MAT_A]; perm = ds->perm; for (i=l;in-ds->l,&n1);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(5*ds->n+3,&liwork);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscBLASIntCast(ds->n*ds->n+2*ds->n,&lwork);CHKERRQ(ierr); ierr = PetscBLASIntCast(2*ds->n*ds->n+5*ds->n+1+n1,&lrwork);CHKERRQ(ierr); #else ierr = PetscBLASIntCast(2*ds->n*ds->n+6*ds->n+1,&lwork);CHKERRQ(ierr); #endif ierr = DSAllocateWork_Private(ds,lwork,lrwork,liwork);CHKERRQ(ierr); work = ds->work; iwork = ds->iwork; off = ds->l+ds->l*ld; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; Q = ds->mat[DS_MAT_Q]; #if defined(PETSC_USE_COMPLEX) rr = ds->rwork; rwork = ds->rwork + n1; lrwork = ds->lrwork - n1; PetscStackCallBLAS("LAPACKsygvd",LAPACKsygvd_(&itype,"V","U",&n1,A+off,&ld,B+off,&ld,rr,work,&lwork,rwork,&lrwork,iwork,&liwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack ZHEGVD %d",info); for (i=0;il+i] = rr[i]; #else PetscStackCallBLAS("LAPACKsygvd",LAPACKsygvd_(&itype,"V","U",&n1,A+off,&ld,B+off,&ld,wr+ds->l,work,&lwork,iwork,&liwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DSYGVD %d",info); #endif ierr = PetscMemzero(Q+ds->l*ld,n1*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=ds->l;in;i++) { ierr = PetscMemcpy(Q+ds->l+i*ld,A+ds->l+i*ld,n1*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = PetscMemzero(B+ds->l*ld,n1*ld*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMemzero(A+ds->l*ld,n1*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=ds->l;in;i++) { if (wi) wi[i] = 0.0; B[i+i*ld] = 1.0; A[i+i*ld] = wr[i]; } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSCreate_GHEP" PETSC_EXTERN PetscErrorCode DSCreate_GHEP(DS ds) { PetscFunctionBegin; ds->ops->allocate = DSAllocate_GHEP; ds->ops->view = DSView_GHEP; ds->ops->vectors = DSVectors_GHEP; ds->ops->solve[0] = DSSolve_GHEP; ds->ops->sort = DSSort_GHEP; ds->ops->normalize = DSNormalize_GHEP; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/ghep/index.html0000644000175000017500000000216213107004621021700 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dsghep.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/ghep/dsghep.c.html0000644000175000017500000004126213107004621022270 0ustar jromanjroman

Actual source code: dsghep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/dsimpl.h>
 23: #include <slepcblaslapack.h>

 27: PetscErrorCode DSAllocate_GHEP(DS ds,PetscInt ld)
 28: {

 32:   DSAllocateMat_Private(ds,DS_MAT_A);
 33:   DSAllocateMat_Private(ds,DS_MAT_B);
 34:   DSAllocateMat_Private(ds,DS_MAT_Q);
 35:   PetscFree(ds->perm);
 36:   PetscMalloc1(ld,&ds->perm);
 37:   PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));
 38:   return(0);
 39: }

 43: PetscErrorCode DSView_GHEP(DS ds,PetscViewer viewer)
 44: {

 48:   DSViewMat(ds,viewer,DS_MAT_A);
 49:   DSViewMat(ds,viewer,DS_MAT_B);
 50:   if (ds->state>DS_STATE_INTERMEDIATE) {
 51:     DSViewMat(ds,viewer,DS_MAT_Q);
 52:   }
 53:   return(0);
 54: }

 58: PetscErrorCode DSVectors_GHEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
 59: {
 60:   PetscScalar    *Q = ds->mat[DS_MAT_Q];
 61:   PetscInt       ld = ds->ld,i;

 65:   if (rnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
 66:   switch (mat) {
 67:     case DS_MAT_X:
 68:     case DS_MAT_Y:
 69:       if (j) {
 70:         if (ds->state>=DS_STATE_CONDENSED) {
 71:           PetscMemcpy(ds->mat[mat]+(*j)*ld,Q+(*j)*ld,ld*sizeof(PetscScalar));
 72:         } else {
 73:           PetscMemzero(ds->mat[mat]+(*j)*ld,ld*sizeof(PetscScalar));
 74:           *(ds->mat[mat]+(*j)+(*j)*ld) = 1.0;
 75:         }
 76:       } else {
 77:         if (ds->state>=DS_STATE_CONDENSED) {
 78:           PetscMemcpy(ds->mat[mat],Q,ld*ld*sizeof(PetscScalar));
 79:         } else {
 80:           PetscMemzero(ds->mat[mat],ld*ld*sizeof(PetscScalar));
 81:           for (i=0;i<ds->n;i++) *(ds->mat[mat]+i+i*ld) = 1.0;
 82:         }
 83:       }
 84:       break;
 85:     case DS_MAT_U:
 86:     case DS_MAT_VT:
 87:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
 88:       break;
 89:     default:
 90:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
 91:   }
 92:   return(0);
 93: }

 97: PetscErrorCode DSNormalize_GHEP(DS ds,DSMatType mat,PetscInt col)
 98: {
100:   PetscInt       i,i0,i1;
101:   PetscBLASInt   ld,n,one = 1;
102:   PetscScalar    norm,*x;

105:   switch (mat) {
106:     case DS_MAT_X:
107:     case DS_MAT_Y:
108:     case DS_MAT_Q:
109:       break;
110:     case DS_MAT_U:
111:     case DS_MAT_VT:
112:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
113:       break;
114:     default:
115:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
116:   }
117:   /* All the matrices resulting from DSVectors and DSSolve are B-normalized,
118:      but function returns 2-normalized vectors. */
119:   PetscBLASIntCast(ds->n,&n);
120:   PetscBLASIntCast(ds->ld,&ld);
121:   DSGetArray(ds,mat,&x);
122:   if (col < 0) {
123:     i0 = 0; i1 = ds->n;
124:   } else {
125:     i0 = col; i1 = col+1;
126:   }
127:   for (i=i0;i<i1;i++) {
128:     norm = BLASnrm2_(&n,&x[ld*i],&one);
129:     norm = 1.0/norm;
130:     PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
131:   }
132:   return(0);
133: }

137: PetscErrorCode DSSort_GHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
138: {
140:   PetscInt       n,l,i,*perm,ld=ds->ld;
141:   PetscScalar    *A;

144:   if (!ds->sc) return(0);
145:   n = ds->n;
146:   l = ds->l;
147:   A  = ds->mat[DS_MAT_A];
148:   perm = ds->perm;
149:   for (i=l;i<n;i++) wr[i] = A[i+i*ld];
150:   if (rr) {
151:     DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);
152:   } else {
153:     DSSortEigenvalues_Private(ds,wr,NULL,perm,PETSC_FALSE);
154:   }
155:   for (i=l;i<n;i++) A[i+i*ld] = wr[perm[i]];
156:   for (i=l;i<n;i++) wr[i] = A[i+i*ld];
157:   DSPermuteColumns_Private(ds,l,n,DS_MAT_Q,perm);
158:   return(0);
159: }

163: PetscErrorCode DSSolve_GHEP(DS ds,PetscScalar *wr,PetscScalar *wi)
164: {
165: #if defined(SLEPC_MISSING_LAPACK_SYGVD)
167:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"SYGVD - Lapack routine is unavailable");
168: #else
170:   PetscScalar    *work,*A,*B,*Q;
171:   PetscBLASInt   itype = 1,*iwork,info,n1,liwork,ld,lrwork=0,lwork;
172:   PetscInt       off,i;
173: #if defined(PETSC_USE_COMPLEX)
174:   PetscReal      *rwork,*rr;
175: #endif

178:   PetscBLASIntCast(ds->n-ds->l,&n1);
179:   PetscBLASIntCast(ds->ld,&ld);
180:   PetscBLASIntCast(5*ds->n+3,&liwork);
181: #if defined(PETSC_USE_COMPLEX)
182:   PetscBLASIntCast(ds->n*ds->n+2*ds->n,&lwork);
183:   PetscBLASIntCast(2*ds->n*ds->n+5*ds->n+1+n1,&lrwork);
184: #else
185:   PetscBLASIntCast(2*ds->n*ds->n+6*ds->n+1,&lwork);
186: #endif
187:   DSAllocateWork_Private(ds,lwork,lrwork,liwork);
188:   work = ds->work;
189:   iwork = ds->iwork;
190:   off = ds->l+ds->l*ld;
191:   A = ds->mat[DS_MAT_A];
192:   B = ds->mat[DS_MAT_B];
193:   Q = ds->mat[DS_MAT_Q];
194: #if defined(PETSC_USE_COMPLEX)
195:   rr = ds->rwork;
196:   rwork = ds->rwork + n1;
197:   lrwork = ds->lrwork - n1;
198:   PetscStackCallBLAS("LAPACKsygvd",LAPACKsygvd_(&itype,"V","U",&n1,A+off,&ld,B+off,&ld,rr,work,&lwork,rwork,&lrwork,iwork,&liwork,&info));
199:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack ZHEGVD %d",info);
200:   for (i=0;i<n1;i++) wr[ds->l+i] = rr[i];
201: #else
202:   PetscStackCallBLAS("LAPACKsygvd",LAPACKsygvd_(&itype,"V","U",&n1,A+off,&ld,B+off,&ld,wr+ds->l,work,&lwork,iwork,&liwork,&info));
203:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DSYGVD %d",info);
204: #endif
205:   PetscMemzero(Q+ds->l*ld,n1*ld*sizeof(PetscScalar));
206:   for (i=ds->l;i<ds->n;i++) {
207:     PetscMemcpy(Q+ds->l+i*ld,A+ds->l+i*ld,n1*sizeof(PetscScalar));
208:   }
209:   PetscMemzero(B+ds->l*ld,n1*ld*sizeof(PetscScalar));
210:   PetscMemzero(A+ds->l*ld,n1*ld*sizeof(PetscScalar));
211:   for (i=ds->l;i<ds->n;i++) {
212:     if (wi) wi[i] = 0.0;
213:     B[i+i*ld] = 1.0;
214:     A[i+i*ld] = wr[i];
215:   }
216:   return(0);
217: #endif
218: }

222: PETSC_EXTERN PetscErrorCode DSCreate_GHEP(DS ds)
223: {
225:   ds->ops->allocate      = DSAllocate_GHEP;
226:   ds->ops->view          = DSView_GHEP;
227:   ds->ops->vectors       = DSVectors_GHEP;
228:   ds->ops->solve[0]      = DSSolve_GHEP;
229:   ds->ops->sort          = DSSort_GHEP;
230:   ds->ops->normalize     = DSNormalize_GHEP;
231:   return(0);
232: }

slepc-3.7.4/src/sys/classes/ds/impls/svd/0000755000175000017500000000000013107004621017553 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/svd/makefile0000644000175000017500000000216213107004621021254 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dssvd.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/svd/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/svd/dssvd.c.html0000644000175000017500000005741213107004621022016 0ustar jromanjroman
Actual source code: dssvd.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/dsimpl.h>
 23: #include <slepcblaslapack.h>

 27: PetscErrorCode DSAllocate_SVD(DS ds,PetscInt ld)
 28: {

 32:   DSAllocateMat_Private(ds,DS_MAT_A);
 33:   DSAllocateMat_Private(ds,DS_MAT_U);
 34:   DSAllocateMat_Private(ds,DS_MAT_VT);
 35:   DSAllocateMatReal_Private(ds,DS_MAT_T);
 36:   PetscFree(ds->perm);
 37:   PetscMalloc1(ld,&ds->perm);
 38:   PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));
 39:   return(0);
 40: }

 42: /*   0       l           k                 n-1
 43:     -----------------------------------------
 44:     |*       .           .                  |
 45:     |  *     .           .                  |
 46:     |    *   .           .                  |
 47:     |      * .           .                  |
 48:     |        o           o                  |
 49:     |          o         o                  |
 50:     |            o       o                  |
 51:     |              o     o                  |
 52:     |                o   o                  |
 53:     |                  o o                  |
 54:     |                    o x                |
 55:     |                      x x              |
 56:     |                        x x            |
 57:     |                          x x          |
 58:     |                            x x        |
 59:     |                              x x      |
 60:     |                                x x    |
 61:     |                                  x x  |
 62:     |                                    x x|
 63:     |                                      x|
 64:     -----------------------------------------
 65: */

 69: static PetscErrorCode DSSwitchFormat_SVD(DS ds,PetscBool tocompact)
 70: {
 72:   PetscReal      *T = ds->rmat[DS_MAT_T];
 73:   PetscScalar    *A = ds->mat[DS_MAT_A];
 74:   PetscInt       i,m=ds->m,k=ds->k,ld=ds->ld;

 77:   if (!m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set");
 78:   if (tocompact) { /* switch from dense (arrow) to compact storage */
 79:     PetscMemzero(T,3*ld*sizeof(PetscReal));
 80:     for (i=0;i<k;i++) {
 81:       T[i] = PetscRealPart(A[i+i*ld]);
 82:       T[i+ld] = PetscRealPart(A[i+k*ld]);
 83:     }
 84:     for (i=k;i<m-1;i++) {
 85:       T[i] = PetscRealPart(A[i+i*ld]);
 86:       T[i+ld] = PetscRealPart(A[i+(i+1)*ld]);
 87:     }
 88:     T[m-1] = PetscRealPart(A[m-1+(m-1)*ld]);
 89:   } else { /* switch from compact (arrow) to dense storage */
 90:     PetscMemzero(A,ld*ld*sizeof(PetscScalar));
 91:     for (i=0;i<k;i++) {
 92:       A[i+i*ld] = T[i];
 93:       A[i+k*ld] = T[i+ld];
 94:     }
 95:     A[k+k*ld] = T[k];
 96:     for (i=k+1;i<m;i++) {
 97:       A[i+i*ld] = T[i];
 98:       A[i-1+i*ld] = T[i-1+ld];
 99:     }
100:   }
101:   return(0);
102: }

106: PetscErrorCode DSView_SVD(DS ds,PetscViewer viewer)
107: {
108:   PetscErrorCode    ierr;
109:   PetscViewerFormat format;
110:   PetscInt          i,j,r,c;
111:   PetscReal         value;

114:   PetscViewerGetFormat(viewer,&format);
115:   if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
116:     return(0);
117:   }
118:   if (ds->compact) {
119:     if (!ds->m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set");
120:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
121:     if (format == PETSC_VIEWER_ASCII_MATLAB) {
122:       PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",ds->n,ds->m);
123:       PetscViewerASCIIPrintf(viewer,"zzz = zeros(%D,3);\n",2*ds->n);
124:       PetscViewerASCIIPrintf(viewer,"zzz = [\n");
125:       for (i=0;i<PetscMin(ds->n,ds->m);i++) {
126:         PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_T]+i));
127:       }
128:       for (i=0;i<PetscMin(ds->n,ds->m)-1;i++) {
129:         r = PetscMax(i+2,ds->k+1);
130:         c = i+1;
131:         PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",c,r,*(ds->rmat[DS_MAT_T]+ds->ld+i));
132:       }
133:       PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(zzz);\n",DSMatName[DS_MAT_T]);
134:     } else {
135:       for (i=0;i<ds->n;i++) {
136:         for (j=0;j<ds->m;j++) {
137:           if (i==j) value = *(ds->rmat[DS_MAT_T]+i);
138:           else if (i<ds->k && j==ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+PetscMin(i,j));
139:           else if (i==j+1 && i>ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+i-1);
140:           else value = 0.0;
141:           PetscViewerASCIIPrintf(viewer," %18.16e ",value);
142:         }
143:         PetscViewerASCIIPrintf(viewer,"\n");
144:       }
145:     }
146:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
147:     PetscViewerFlush(viewer);
148:   } else {
149:     DSViewMat(ds,viewer,DS_MAT_A);
150:   }
151:   if (ds->state>DS_STATE_INTERMEDIATE) {
152:     DSViewMat(ds,viewer,DS_MAT_U);
153:     DSViewMat(ds,viewer,DS_MAT_VT);
154:   }
155:   return(0);
156: }

160: PetscErrorCode DSVectors_SVD(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
161: {
163:   switch (mat) {
164:     case DS_MAT_U:
165:     case DS_MAT_VT:
166:       break;
167:     default:
168:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
169:   }
170:   return(0);
171: }

175: PetscErrorCode DSSort_SVD(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
176: {
178:   PetscInt       n,l,i,*perm,ld=ds->ld;
179:   PetscScalar    *A;
180:   PetscReal      *d;

183:   if (!ds->sc) return(0);
184:   l = ds->l;
185:   n = PetscMin(ds->n,ds->m);
186:   A = ds->mat[DS_MAT_A];
187:   d = ds->rmat[DS_MAT_T];
188:   perm = ds->perm;
189:   if (!rr) {
190:     DSSortEigenvaluesReal_Private(ds,d,perm);
191:   } else {
192:     DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);
193:   }
194:   for (i=l;i<n;i++) wr[i] = d[perm[i]];
195:   DSPermuteBoth_Private(ds,l,n,DS_MAT_U,DS_MAT_VT,perm);
196:   for (i=l;i<n;i++) d[i] = PetscRealPart(wr[i]);
197:   if (!ds->compact) {
198:     for (i=l;i<n;i++) A[i+i*ld] = wr[i];
199:   }
200:   return(0);
201: }

205: PetscErrorCode DSSolve_SVD_DC(DS ds,PetscScalar *wr,PetscScalar *wi)
206: {
207: #if defined(SLEPC_MISSING_LAPACK_GESDD) || defined(SLEPC_MISSING_LAPACK_BDSDC)
209:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESDD/BDSDC - Lapack routines are unavailable");
210: #else
212:   PetscInt       i;
213:   PetscBLASInt   n1,n2,n3,m2,m3,info,l,n,m,nm,ld,off,lwork;
214:   PetscScalar    *A,*U,*VT,qwork;
215:   PetscReal      *d,*e,*Ur,*VTr;
216: #if defined(PETSC_USE_COMPLEX)
217:   PetscInt       j;
218: #endif

221:   PetscBLASIntCast(ds->n,&n);
222:   PetscBLASIntCast(ds->m,&m);
223:   PetscBLASIntCast(ds->l,&l);
224:   PetscBLASIntCast(ds->ld,&ld);
225:   PetscBLASIntCast(ds->k-l+1,&n1); /* size of leading block, excl. locked */
226:   PetscBLASIntCast(n-ds->k-1,&n2); /* size of trailing block */
227:   PetscBLASIntCast(m-ds->k-1,&m2);
228:   n3 = n1+n2;
229:   m3 = n1+m2;
230:   off = l+l*ld;
231:   A  = ds->mat[DS_MAT_A];
232:   U  = ds->mat[DS_MAT_U];
233:   VT = ds->mat[DS_MAT_VT];
234:   d  = ds->rmat[DS_MAT_T];
235:   e  = ds->rmat[DS_MAT_T]+ld;
236:   PetscMemzero(U,ld*ld*sizeof(PetscScalar));
237:   for (i=0;i<l;i++) U[i+i*ld] = 1.0;
238:   PetscMemzero(VT,ld*ld*sizeof(PetscScalar));
239:   for (i=0;i<l;i++) VT[i+i*ld] = 1.0;

241:   if (ds->state>DS_STATE_RAW) {
242:     /* Solve bidiagonal SVD problem */
243:     for (i=0;i<l;i++) wr[i] = d[i];
244:     DSAllocateWork_Private(ds,0,3*ld*ld+4*ld,8*ld);
245: #if defined(PETSC_USE_COMPLEX)
246:     DSAllocateMatReal_Private(ds,DS_MAT_U);
247:     DSAllocateMatReal_Private(ds,DS_MAT_VT);
248:     Ur  = ds->rmat[DS_MAT_U];
249:     VTr = ds->rmat[DS_MAT_VT];
250: #else
251:     Ur  = U;
252:     VTr = VT;
253: #endif
254:     PetscStackCallBLAS("LAPACKbdsdc",LAPACKbdsdc_("U","I",&n3,d+l,e+l,Ur+off,&ld,VTr+off,&ld,NULL,NULL,ds->rwork,ds->iwork,&info));
255:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xBDSDC %d",info);
256: #if defined(PETSC_USE_COMPLEX)
257:     for (i=l;i<n;i++) {
258:       for (j=0;j<n;j++) {
259:         U[i+j*ld] = Ur[i+j*ld];
260:         VT[i+j*ld] = VTr[i+j*ld];
261:       }
262:     }
263: #endif
264:   } else {
265:     /* Solve general rectangular SVD problem */
266:     if (ds->compact) { DSSwitchFormat_SVD(ds,PETSC_FALSE); }
267:     for (i=0;i<l;i++) wr[i] = d[i];
268:     nm = PetscMin(n,m);
269:     DSAllocateWork_Private(ds,0,0,8*nm);
270:     lwork = -1;
271: #if defined(PETSC_USE_COMPLEX)
272:     DSAllocateWork_Private(ds,0,5*nm*nm+7*nm,0);
273:     PetscStackCallBLAS("LAPACKgesdd",LAPACKgesdd_("A",&n3,&m3,A+off,&ld,d+l,U+off,&ld,VT+off,&ld,&qwork,&lwork,ds->rwork,ds->iwork,&info));
274: #else
275:     PetscStackCallBLAS("LAPACKgesdd",LAPACKgesdd_("A",&n3,&m3,A+off,&ld,d+l,U+off,&ld,VT+off,&ld,&qwork,&lwork,ds->iwork,&info));
276: #endif
277:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESDD %d",info);
278:     PetscBLASIntCast((PetscInt)PetscRealPart(qwork),&lwork);
279:     DSAllocateWork_Private(ds,lwork,0,0);
280: #if defined(PETSC_USE_COMPLEX)
281:     PetscStackCallBLAS("LAPACKgesdd",LAPACKgesdd_("A",&n3,&m3,A+off,&ld,d+l,U+off,&ld,VT+off,&ld,ds->work,&lwork,ds->rwork,ds->iwork,&info));
282: #else
283:     PetscStackCallBLAS("LAPACKgesdd",LAPACKgesdd_("A",&n3,&m3,A+off,&ld,d+l,U+off,&ld,VT+off,&ld,ds->work,&lwork,ds->iwork,&info));
284: #endif
285:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESDD %d",info);
286:   }
287:   for (i=l;i<PetscMin(ds->n,ds->m);i++) wr[i] = d[i];

289:   /* Create diagonal matrix as a result */
290:   if (ds->compact) {
291:     PetscMemzero(e,(n-1)*sizeof(PetscReal));
292:   } else {
293:     for (i=l;i<n;i++) {
294:       PetscMemzero(A+l+i*ld,(n-l)*sizeof(PetscScalar));
295:     }
296:     for (i=l;i<n;i++) A[i+i*ld] = d[i];
297:   }
298:   return(0);
299: #endif
300: }

304: PETSC_EXTERN PetscErrorCode DSCreate_SVD(DS ds)
305: {
307:   ds->ops->allocate      = DSAllocate_SVD;
308:   ds->ops->view          = DSView_SVD;
309:   ds->ops->vectors       = DSVectors_SVD;
310:   ds->ops->solve[0]      = DSSolve_SVD_DC;
311:   ds->ops->sort          = DSSort_SVD;
312:   return(0);
313: }

slepc-3.7.4/src/sys/classes/ds/impls/svd/dssvd.c0000644000175000017500000002651413107004621021052 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "DSAllocate_SVD" PetscErrorCode DSAllocate_SVD(DS ds,PetscInt ld) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_U);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_VT);CHKERRQ(ierr); ierr = DSAllocateMatReal_Private(ds,DS_MAT_T);CHKERRQ(ierr); ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } /* 0 l k n-1 ----------------------------------------- |* . . | | * . . | | * . . | | * . . | | o o | | o o | | o o | | o o | | o o | | o o | | o x | | x x | | x x | | x x | | x x | | x x | | x x | | x x | | x x| | x| ----------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "DSSwitchFormat_SVD" static PetscErrorCode DSSwitchFormat_SVD(DS ds,PetscBool tocompact) { PetscErrorCode ierr; PetscReal *T = ds->rmat[DS_MAT_T]; PetscScalar *A = ds->mat[DS_MAT_A]; PetscInt i,m=ds->m,k=ds->k,ld=ds->ld; PetscFunctionBegin; if (!m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set"); if (tocompact) { /* switch from dense (arrow) to compact storage */ ierr = PetscMemzero(T,3*ld*sizeof(PetscReal));CHKERRQ(ierr); for (i=0;icompact) { if (!ds->m) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_WRONG,"m was not set"); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_MATLAB) { ierr = PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",ds->n,ds->m);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"zzz = zeros(%D,3);\n",2*ds->n);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"zzz = [\n");CHKERRQ(ierr); for (i=0;in,ds->m);i++) { ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_T]+i));CHKERRQ(ierr); } for (i=0;in,ds->m)-1;i++) { r = PetscMax(i+2,ds->k+1); c = i+1; ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",c,r,*(ds->rmat[DS_MAT_T]+ds->ld+i));CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(zzz);\n",DSMatName[DS_MAT_T]);CHKERRQ(ierr); } else { for (i=0;in;i++) { for (j=0;jm;j++) { if (i==j) value = *(ds->rmat[DS_MAT_T]+i); else if (ik && j==ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+PetscMin(i,j)); else if (i==j+1 && i>ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+i-1); else value = 0.0; ierr = PetscViewerASCIIPrintf(viewer," %18.16e ",value);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerFlush(viewer);CHKERRQ(ierr); } else { ierr = DSViewMat(ds,viewer,DS_MAT_A);CHKERRQ(ierr); } if (ds->state>DS_STATE_INTERMEDIATE) { ierr = DSViewMat(ds,viewer,DS_MAT_U);CHKERRQ(ierr); ierr = DSViewMat(ds,viewer,DS_MAT_VT);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_SVD" PetscErrorCode DSVectors_SVD(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm) { PetscFunctionBegin; switch (mat) { case DS_MAT_U: case DS_MAT_VT: break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSort_SVD" PetscErrorCode DSSort_SVD(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k) { PetscErrorCode ierr; PetscInt n,l,i,*perm,ld=ds->ld; PetscScalar *A; PetscReal *d; PetscFunctionBegin; if (!ds->sc) PetscFunctionReturn(0); l = ds->l; n = PetscMin(ds->n,ds->m); A = ds->mat[DS_MAT_A]; d = ds->rmat[DS_MAT_T]; perm = ds->perm; if (!rr) { ierr = DSSortEigenvaluesReal_Private(ds,d,perm);CHKERRQ(ierr); } else { ierr = DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);CHKERRQ(ierr); } for (i=l;icompact) { for (i=l;in,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->m,&m);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->l,&l);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->k-l+1,&n1);CHKERRQ(ierr); /* size of leading block, excl. locked */ ierr = PetscBLASIntCast(n-ds->k-1,&n2);CHKERRQ(ierr); /* size of trailing block */ ierr = PetscBLASIntCast(m-ds->k-1,&m2);CHKERRQ(ierr); n3 = n1+n2; m3 = n1+m2; off = l+l*ld; A = ds->mat[DS_MAT_A]; U = ds->mat[DS_MAT_U]; VT = ds->mat[DS_MAT_VT]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T]+ld; ierr = PetscMemzero(U,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;istate>DS_STATE_RAW) { /* Solve bidiagonal SVD problem */ for (i=0;irmat[DS_MAT_U]; VTr = ds->rmat[DS_MAT_VT]; #else Ur = U; VTr = VT; #endif PetscStackCallBLAS("LAPACKbdsdc",LAPACKbdsdc_("U","I",&n3,d+l,e+l,Ur+off,&ld,VTr+off,&ld,NULL,NULL,ds->rwork,ds->iwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xBDSDC %d",info); #if defined(PETSC_USE_COMPLEX) for (i=l;icompact) { ierr = DSSwitchFormat_SVD(ds,PETSC_FALSE);CHKERRQ(ierr); } for (i=0;irwork,ds->iwork,&info)); #else PetscStackCallBLAS("LAPACKgesdd",LAPACKgesdd_("A",&n3,&m3,A+off,&ld,d+l,U+off,&ld,VT+off,&ld,&qwork,&lwork,ds->iwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESDD %d",info); ierr = PetscBLASIntCast((PetscInt)PetscRealPart(qwork),&lwork);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,lwork,0,0);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKgesdd",LAPACKgesdd_("A",&n3,&m3,A+off,&ld,d+l,U+off,&ld,VT+off,&ld,ds->work,&lwork,ds->rwork,ds->iwork,&info)); #else PetscStackCallBLAS("LAPACKgesdd",LAPACKgesdd_("A",&n3,&m3,A+off,&ld,d+l,U+off,&ld,VT+off,&ld,ds->work,&lwork,ds->iwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESDD %d",info); } for (i=l;in,ds->m);i++) wr[i] = d[i]; /* Create diagonal matrix as a result */ if (ds->compact) { ierr = PetscMemzero(e,(n-1)*sizeof(PetscReal));CHKERRQ(ierr); } else { for (i=l;iops->allocate = DSAllocate_SVD; ds->ops->view = DSView_SVD; ds->ops->vectors = DSVectors_SVD; ds->ops->solve[0] = DSSolve_SVD_DC; ds->ops->sort = DSSort_SVD; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/svd/makefile.html0000644000175000017500000000470113107004621022220 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dssvd.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/svd/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/svd/index.html0000644000175000017500000000215613107004621021554 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dssvd.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/nep/0000755000175000017500000000000013107004621017541 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/nep/makefile0000644000175000017500000000216213107004621021242 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dsnep.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/nep/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/nep/dsnep.c.html0000644000175000017500000010501613107004621021764 0ustar jromanjroman

Actual source code: dsnep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/dsimpl.h>       /*I "slepcds.h" I*/
 23: #include <slepcblaslapack.h>

 25: typedef struct {
 26:   PetscInt nf;                 /* number of functions in f[] */
 27:   FN       f[DS_NUM_EXTRA];    /* functions defining the nonlinear operator */
 28: } DS_NEP;

 32: /*
 33:    DSNEPComputeMatrix - Build the matrix associated with a nonlinear operator
 34:    T(lambda) or its derivative T'(lambda), given the parameter lambda, where
 35:    T(lambda) = sum_i E_i*f_i(lambda). The result is written in mat.
 36: */
 37: static PetscErrorCode DSNEPComputeMatrix(DS ds,PetscScalar lambda,PetscBool deriv,DSMatType mat)
 38: {
 40:   DS_NEP         *ctx = (DS_NEP*)ds->data;
 41:   PetscScalar    *T,*E,alpha;
 42:   PetscInt       i,ld,n;
 43:   PetscBLASInt   k,inc=1;

 46:   DSGetDimensions(ds,&n,NULL,NULL,NULL,NULL);
 47:   DSGetLeadingDimension(ds,&ld);
 48:   PetscBLASIntCast(ld*n,&k);
 49:   PetscLogEventBegin(DS_Other,ds,0,0,0);
 50:   DSGetArray(ds,mat,&T);
 51:   PetscMemzero(T,k*sizeof(PetscScalar));
 52:   for (i=0;i<ctx->nf;i++) {
 53:     if (deriv) {
 54:       FNEvaluateDerivative(ctx->f[i],lambda,&alpha);
 55:     } else {
 56:       FNEvaluateFunction(ctx->f[i],lambda,&alpha);
 57:     }
 58:     E = ds->mat[DSMatExtra[i]];
 59:     PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&k,&alpha,E,&inc,T,&inc));
 60:   }
 61:   DSRestoreArray(ds,mat,&T);
 62:   PetscLogEventEnd(DS_Other,ds,0,0,0);
 63:   return(0);
 64: }

 68: PetscErrorCode DSAllocate_NEP(DS ds,PetscInt ld)
 69: {
 71:   DS_NEP         *ctx = (DS_NEP*)ds->data;
 72:   PetscInt       i;

 75:   if (!ctx->nf) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"DSNEP requires passing some functions via DSSetFN()");
 76:   DSAllocateMat_Private(ds,DS_MAT_X);
 77:   for (i=0;i<ctx->nf;i++) {
 78:     DSAllocateMat_Private(ds,DSMatExtra[i]);
 79:   }
 80:   PetscFree(ds->perm);
 81:   PetscMalloc1(ld,&ds->perm);
 82:   PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));
 83:   return(0);
 84: }

 88: PetscErrorCode DSView_NEP(DS ds,PetscViewer viewer)
 89: {
 90:   PetscErrorCode    ierr;
 91:   DS_NEP            *ctx = (DS_NEP*)ds->data;
 92:   PetscViewerFormat format;
 93:   PetscInt          i;

 96:   PetscViewerGetFormat(viewer,&format);
 97:   PetscViewerASCIIPrintf(viewer,"  number of functions: %D\n",ctx->nf);
 98:   if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) return(0);
 99:   for (i=0;i<ctx->nf;i++) {
100:     FNView(ctx->f[i],viewer);
101:     DSViewMat(ds,viewer,DSMatExtra[i]);
102:   }
103:   if (ds->state>DS_STATE_INTERMEDIATE) {
104:     DSViewMat(ds,viewer,DS_MAT_X);
105:   }
106:   return(0);
107: }

111: PetscErrorCode DSVectors_NEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
112: {
114:   if (rnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
115:   switch (mat) {
116:     case DS_MAT_X:
117:       break;
118:     case DS_MAT_Y:
119:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
120:       break;
121:     default:
122:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
123:   }
124:   return(0);
125: }

129: PetscErrorCode DSNormalize_NEP(DS ds,DSMatType mat,PetscInt col)
130: {
132:   PetscInt       i,i0,i1;
133:   PetscBLASInt   ld,n,one = 1;
134:   PetscScalar    norm,*x;

137:   switch (mat) {
138:     case DS_MAT_X:
139:       break;
140:     case DS_MAT_Y:
141:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
142:       break;
143:     default:
144:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
145:   }
146:   PetscBLASIntCast(ds->n,&n);
147:   PetscBLASIntCast(ds->ld,&ld);
148:   DSGetArray(ds,mat,&x);
149:   if (col < 0) {
150:     i0 = 0; i1 = ds->n;
151:   } else {
152:     i0 = col; i1 = col+1;
153:   }
154:   for (i=i0;i<i1;i++) {
155:     norm = BLASnrm2_(&n,&x[ld*i],&one);
156:     norm = 1.0/norm;
157:     PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
158:   }
159:   return(0);
160: }

164: PetscErrorCode DSSort_NEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
165: {
167:   PetscInt       n,l,i,*perm,ld=ds->ld;
168:   PetscScalar    *A;

171:   if (!ds->sc) return(0);
172:   n = ds->n;
173:   l = ds->l;
174:   A  = ds->mat[DS_MAT_A];
175:   perm = ds->perm;
176:   for (i=l;i<n;i++) wr[i] = A[i+i*ld];
177:   if (rr) {
178:     DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);
179:   } else {
180:     DSSortEigenvalues_Private(ds,wr,NULL,perm,PETSC_FALSE);
181:   }
182:   for (i=l;i<n;i++) A[i+i*ld] = wr[perm[i]];
183:   for (i=l;i<n;i++) wr[i] = A[i+i*ld];
184:   DSPermuteColumns_Private(ds,l,n,DS_MAT_Q,perm);
185:   return(0);
186: }

190: PetscErrorCode DSSolve_NEP_SLP(DS ds,PetscScalar *wr,PetscScalar *wi)
191: {
192: #if defined(SLEPC_MISSING_LAPACK_GGEV)
194:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GGEV - Lapack routine is unavailable");
195: #else
197:   PetscScalar    *A,*B,*W,*X,*work,*alpha,*beta;
198:   PetscScalar    norm,sigma,lambda,mu,re,re2;
199:   PetscBLASInt   info,n,ld,lrwork=0,lwork,one=1;
200:   PetscInt       it,pos,j,maxit=100,result;
201:   PetscReal      tol;
202: #if defined(PETSC_USE_COMPLEX)
203:   PetscReal      *rwork;
204: #else
205:   PetscReal      *alphai,im,im2;
206: #endif

209:   if (!ds->mat[DS_MAT_A]) {
210:     DSAllocateMat_Private(ds,DS_MAT_A);
211:   }
212:   if (!ds->mat[DS_MAT_B]) {
213:     DSAllocateMat_Private(ds,DS_MAT_B);
214:   }
215:   if (!ds->mat[DS_MAT_W]) {
216:     DSAllocateMat_Private(ds,DS_MAT_W);
217:   }
218:   PetscBLASIntCast(ds->n,&n);
219:   PetscBLASIntCast(ds->ld,&ld);
220: #if defined(PETSC_USE_COMPLEX)
221:   PetscBLASIntCast(2*ds->n+2*ds->n,&lwork);
222:   PetscBLASIntCast(8*ds->n,&lrwork);
223: #else
224:   PetscBLASIntCast(3*ds->n+8*ds->n,&lwork);
225: #endif
226:   DSAllocateWork_Private(ds,lwork,lrwork,0);
227:   alpha = ds->work;
228:   beta = ds->work + ds->n;
229: #if defined(PETSC_USE_COMPLEX)
230:   work = ds->work + 2*ds->n;
231:   lwork -= 2*ds->n;
232: #else
233:   alphai = ds->work + 2*ds->n;
234:   work = ds->work + 3*ds->n;
235:   lwork -= 3*ds->n;
236: #endif
237:   A = ds->mat[DS_MAT_A];
238:   B = ds->mat[DS_MAT_B];
239:   W = ds->mat[DS_MAT_W];
240:   X = ds->mat[DS_MAT_X];

242:   sigma = 0.0;
243:   lambda = sigma;
244:   tol = 1000*n*PETSC_MACHINE_EPSILON;

246:   for (it=0;it<maxit;it++) {

248:     /* evaluate T and T' */
249:     DSNEPComputeMatrix(ds,lambda,PETSC_FALSE,DS_MAT_A);
250:     DSNEPComputeMatrix(ds,lambda,PETSC_TRUE,DS_MAT_B);

252:     /* compute eigenvalue correction mu and eigenvector u */
253: #if defined(PETSC_USE_COMPLEX)
254:     rwork = ds->rwork;
255:     PetscStackCallBLAS("LAPACKggev",LAPACKggev_("N","V",&n,A,&ld,B,&ld,alpha,beta,NULL,&ld,W,&ld,work,&lwork,rwork,&info));
256:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack ZGGEV %d",info);
257: #else
258:     PetscStackCallBLAS("LAPACKggev",LAPACKggev_("N","V",&n,A,&ld,B,&ld,alpha,alphai,beta,NULL,&ld,W,&ld,work,&lwork,&info));
259:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DGGEV %d",info);
260: #endif

262:     /* find smallest eigenvalue */
263:     j = 0;
264:     if (beta[j]==0.0) re = (PetscRealPart(alpha[j])>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
265:     else re = alpha[j]/beta[j];
266: #if !defined(PETSC_USE_COMPLEX)
267:     if (beta[j]==0.0) im = (alphai[j]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
268:     else im = alphai[j]/beta[j];
269: #endif
270:     pos = 0;
271:     for (j=1;j<n;j++) {
272:       if (beta[j]==0.0) re2 = (PetscRealPart(alpha[j])>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
273:       else re2 = alpha[j]/beta[j];
274: #if !defined(PETSC_USE_COMPLEX)
275:       if (beta[j]==0.0) im2 = (alphai[j]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
276:       else im2 = alphai[j]/beta[j];
277:       SlepcCompareSmallestMagnitude(re,im,re2,im2,&result,NULL);
278: #else
279:       SlepcCompareSmallestMagnitude(re,0.0,re2,0.0,&result,NULL);
280: #endif
281:       if (result > 0) {
282:         re = re2;
283: #if !defined(PETSC_USE_COMPLEX)
284:         im = im2;
285: #endif
286:         pos = j;
287:       }
288:     }

290: #if !defined(PETSC_USE_COMPLEX)
291:     if (im!=0.0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"DSNEP found a complex eigenvalue; try rerunning with complex scalars");
292: #endif
293:     mu = alpha[pos];
294:     PetscMemcpy(X,W+pos*ld,n*sizeof(PetscScalar));
295:     norm = BLASnrm2_(&n,X,&one);
296:     norm = 1.0/norm;
297:     PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X,&one));

299:     /* correct eigenvalue approximation */
300:     lambda = lambda - mu;
301:     if (PetscAbsScalar(mu)<=tol) break;
302:   }

304:   wr[0] = lambda;
305:   if (wi) wi[0] = 0.0;

307:   if (it==maxit) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_CONV_FAILED,"DSNEP did not converge");
308:   return(0);
309: #endif
310: }

314: static PetscErrorCode DSNEPSetFN_NEP(DS ds,PetscInt n,FN fn[])
315: {
317:   DS_NEP         *ctx = (DS_NEP*)ds->data;
318:   PetscInt       i;

321:   if (n<=0) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Must have one or more functions, you have %D",n);
322:   if (n>DS_NUM_EXTRA) SETERRQ2(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Too many functions, you specified %D but the limit is %D",n,DS_NUM_EXTRA);
323:   if (ds->ld) { PetscInfo(ds,"DSNEPSetFN() called after DSAllocate()\n"); }
324:   for (i=0;i<ctx->nf;i++) {
325:     FNDestroy(&ctx->f[i]);
326:   }
327:   for (i=0;i<n;i++) {
328:     PetscObjectReference((PetscObject)fn[i]);
329:     ctx->f[i] = fn[i];
330:   }
331:   ctx->nf = n;
332:   return(0);
333: }

337: /*@
338:    DSNEPSetFN - Sets a number of functions that define the nonlinear
339:    eigenproblem.

341:    Collective on DS and FN

343:    Input Parameters:
344: +  ds - the direct solver context
345: .  n  - number of functions
346: -  fn - array of functions

348:    Notes:
349:    The nonlinear eigenproblem is defined in terms of the split nonlinear
350:    operator T(lambda) = sum_i A_i*f_i(lambda).

352:    This function must be called before DSAllocate(). Then DSAllocate()
353:    will allocate an extra matrix A_i per each function, that can be
354:    filled in the usual way.

356:    Level: advanced

358: .seealso: DSNEPGetFN(), DSAllocate()
359:  @*/
360: PetscErrorCode DSNEPSetFN(DS ds,PetscInt n,FN fn[])
361: {
362:   PetscInt       i;

369:   for (i=0;i<n;i++) {
372:   }
373:   PetscTryMethod(ds,"DSNEPSetFN_C",(DS,PetscInt,FN[]),(ds,n,fn));
374:   return(0);
375: }

379: static PetscErrorCode DSNEPGetFN_NEP(DS ds,PetscInt k,FN *fn)
380: {
381:   DS_NEP *ctx = (DS_NEP*)ds->data;

384:   if (k<0 || k>=ctx->nf) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",ctx->nf-1);
385:   *fn = ctx->f[k];
386:   return(0);
387: }

391: /*@
392:    DSNEPGetFN - Gets the functions associated with the nonlinear DS.

394:    Not collective, though parallel FNs are returned if the DS is parallel

396:    Input Parameter:
397: +  ds - the direct solver context
398: -  k  - the index of the requested function (starting in 0)

400:    Output Parameter:
401: .  fn - the function

403:    Level: advanced

405: .seealso: DSNEPSetFN()
406: @*/
407: PetscErrorCode DSNEPGetFN(DS ds,PetscInt k,FN *fn)
408: {

414:   PetscUseMethod(ds,"DSNEPGetFN_C",(DS,PetscInt,FN*),(ds,k,fn));
415:   return(0);
416: }

420: static PetscErrorCode DSNEPGetNumFN_NEP(DS ds,PetscInt *n)
421: {
422:   DS_NEP *ctx = (DS_NEP*)ds->data;

425:   *n = ctx->nf;
426:   return(0);
427: }

431: /*@
432:    DSNEPGetNumFN - Returns the number of functions stored internally by
433:    the DS.

435:    Not collective

437:    Input Parameter:
438: .  ds - the direct solver context

440:    Output Parameters:
441: .  n - the number of functions passed in DSNEPSetFN()

443:    Level: advanced

445: .seealso: DSNEPSetFN()
446: @*/
447: PetscErrorCode DSNEPGetNumFN(DS ds,PetscInt *n)
448: {

454:   PetscUseMethod(ds,"DSNEPGetNumFN_C",(DS,PetscInt*),(ds,n));
455:   return(0);
456: }

460: PetscErrorCode DSDestroy_NEP(DS ds)
461: {
463:   DS_NEP         *ctx = (DS_NEP*)ds->data;
464:   PetscInt       i;

467:   for (i=0;i<ctx->nf;i++) {
468:     FNDestroy(&ctx->f[i]);
469:   }
470:   PetscFree(ds->data);
471:   PetscObjectComposeFunction((PetscObject)ds,"DSNEPSetFN_C",NULL);
472:   PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetFN_C",NULL);
473:   PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetNumFN_C",NULL);
474:   return(0);
475: }

479: PETSC_EXTERN PetscErrorCode DSCreate_NEP(DS ds)
480: {
481:   DS_NEP         *ctx;

485:   PetscNewLog(ds,&ctx);
486:   ds->data = (void*)ctx;

488:   ds->ops->allocate      = DSAllocate_NEP;
489:   ds->ops->view          = DSView_NEP;
490:   ds->ops->vectors       = DSVectors_NEP;
491:   ds->ops->solve[0]      = DSSolve_NEP_SLP;
492:   ds->ops->sort          = DSSort_NEP;
493:   ds->ops->normalize     = DSNormalize_NEP;
494:   ds->ops->destroy       = DSDestroy_NEP;
495:   PetscObjectComposeFunction((PetscObject)ds,"DSNEPSetFN_C",DSNEPSetFN_NEP);
496:   PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetFN_C",DSNEPGetFN_NEP);
497:   PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetNumFN_C",DSNEPGetNumFN_NEP);
498:   return(0);
499: }

slepc-3.7.4/src/sys/classes/ds/impls/nep/makefile.html0000644000175000017500000000470113107004621022206 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dsnep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/nep/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/nep/dsnep.c0000644000175000017500000003644313107004621021030 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcds.h" I*/ #include typedef struct { PetscInt nf; /* number of functions in f[] */ FN f[DS_NUM_EXTRA]; /* functions defining the nonlinear operator */ } DS_NEP; #undef __FUNCT__ #define __FUNCT__ "DSNEPComputeMatrix" /* DSNEPComputeMatrix - Build the matrix associated with a nonlinear operator T(lambda) or its derivative T'(lambda), given the parameter lambda, where T(lambda) = sum_i E_i*f_i(lambda). The result is written in mat. */ static PetscErrorCode DSNEPComputeMatrix(DS ds,PetscScalar lambda,PetscBool deriv,DSMatType mat) { PetscErrorCode ierr; DS_NEP *ctx = (DS_NEP*)ds->data; PetscScalar *T,*E,alpha; PetscInt i,ld,n; PetscBLASInt k,inc=1; PetscFunctionBegin; ierr = DSGetDimensions(ds,&n,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSGetLeadingDimension(ds,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ld*n,&k);CHKERRQ(ierr); ierr = PetscLogEventBegin(DS_Other,ds,0,0,0);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&T);CHKERRQ(ierr); ierr = PetscMemzero(T,k*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;inf;i++) { if (deriv) { ierr = FNEvaluateDerivative(ctx->f[i],lambda,&alpha);CHKERRQ(ierr); } else { ierr = FNEvaluateFunction(ctx->f[i],lambda,&alpha);CHKERRQ(ierr); } E = ds->mat[DSMatExtra[i]]; PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&k,&alpha,E,&inc,T,&inc)); } ierr = DSRestoreArray(ds,mat,&T);CHKERRQ(ierr); ierr = PetscLogEventEnd(DS_Other,ds,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSAllocate_NEP" PetscErrorCode DSAllocate_NEP(DS ds,PetscInt ld) { PetscErrorCode ierr; DS_NEP *ctx = (DS_NEP*)ds->data; PetscInt i; PetscFunctionBegin; if (!ctx->nf) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"DSNEP requires passing some functions via DSSetFN()"); ierr = DSAllocateMat_Private(ds,DS_MAT_X);CHKERRQ(ierr); for (i=0;inf;i++) { ierr = DSAllocateMat_Private(ds,DSMatExtra[i]);CHKERRQ(ierr); } ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView_NEP" PetscErrorCode DSView_NEP(DS ds,PetscViewer viewer) { PetscErrorCode ierr; DS_NEP *ctx = (DS_NEP*)ds->data; PetscViewerFormat format; PetscInt i; PetscFunctionBegin; ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of functions: %D\n",ctx->nf);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) PetscFunctionReturn(0); for (i=0;inf;i++) { ierr = FNView(ctx->f[i],viewer);CHKERRQ(ierr); ierr = DSViewMat(ds,viewer,DSMatExtra[i]);CHKERRQ(ierr); } if (ds->state>DS_STATE_INTERMEDIATE) { ierr = DSViewMat(ds,viewer,DS_MAT_X);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_NEP" PetscErrorCode DSVectors_NEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm) { PetscFunctionBegin; if (rnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); switch (mat) { case DS_MAT_X: break; case DS_MAT_Y: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNormalize_NEP" PetscErrorCode DSNormalize_NEP(DS ds,DSMatType mat,PetscInt col) { PetscErrorCode ierr; PetscInt i,i0,i1; PetscBLASInt ld,n,one = 1; PetscScalar norm,*x; PetscFunctionBegin; switch (mat) { case DS_MAT_X: break; case DS_MAT_Y: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&x);CHKERRQ(ierr); if (col < 0) { i0 = 0; i1 = ds->n; } else { i0 = col; i1 = col+1; } for (i=i0;ild; PetscScalar *A; PetscFunctionBegin; if (!ds->sc) PetscFunctionReturn(0); n = ds->n; l = ds->l; A = ds->mat[DS_MAT_A]; perm = ds->perm; for (i=l;imat[DS_MAT_A]) { ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); } if (!ds->mat[DS_MAT_B]) { ierr = DSAllocateMat_Private(ds,DS_MAT_B);CHKERRQ(ierr); } if (!ds->mat[DS_MAT_W]) { ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); } ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscBLASIntCast(2*ds->n+2*ds->n,&lwork);CHKERRQ(ierr); ierr = PetscBLASIntCast(8*ds->n,&lrwork);CHKERRQ(ierr); #else ierr = PetscBLASIntCast(3*ds->n+8*ds->n,&lwork);CHKERRQ(ierr); #endif ierr = DSAllocateWork_Private(ds,lwork,lrwork,0);CHKERRQ(ierr); alpha = ds->work; beta = ds->work + ds->n; #if defined(PETSC_USE_COMPLEX) work = ds->work + 2*ds->n; lwork -= 2*ds->n; #else alphai = ds->work + 2*ds->n; work = ds->work + 3*ds->n; lwork -= 3*ds->n; #endif A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; W = ds->mat[DS_MAT_W]; X = ds->mat[DS_MAT_X]; sigma = 0.0; lambda = sigma; tol = 1000*n*PETSC_MACHINE_EPSILON; for (it=0;itrwork; PetscStackCallBLAS("LAPACKggev",LAPACKggev_("N","V",&n,A,&ld,B,&ld,alpha,beta,NULL,&ld,W,&ld,work,&lwork,rwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack ZGGEV %d",info); #else PetscStackCallBLAS("LAPACKggev",LAPACKggev_("N","V",&n,A,&ld,B,&ld,alpha,alphai,beta,NULL,&ld,W,&ld,work,&lwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DGGEV %d",info); #endif /* find smallest eigenvalue */ j = 0; if (beta[j]==0.0) re = (PetscRealPart(alpha[j])>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else re = alpha[j]/beta[j]; #if !defined(PETSC_USE_COMPLEX) if (beta[j]==0.0) im = (alphai[j]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else im = alphai[j]/beta[j]; #endif pos = 0; for (j=1;j0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else re2 = alpha[j]/beta[j]; #if !defined(PETSC_USE_COMPLEX) if (beta[j]==0.0) im2 = (alphai[j]>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else im2 = alphai[j]/beta[j]; ierr = SlepcCompareSmallestMagnitude(re,im,re2,im2,&result,NULL);CHKERRQ(ierr); #else ierr = SlepcCompareSmallestMagnitude(re,0.0,re2,0.0,&result,NULL);CHKERRQ(ierr); #endif if (result > 0) { re = re2; #if !defined(PETSC_USE_COMPLEX) im = im2; #endif pos = j; } } #if !defined(PETSC_USE_COMPLEX) if (im!=0.0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"DSNEP found a complex eigenvalue; try rerunning with complex scalars"); #endif mu = alpha[pos]; ierr = PetscMemcpy(X,W+pos*ld,n*sizeof(PetscScalar));CHKERRQ(ierr); norm = BLASnrm2_(&n,X,&one); norm = 1.0/norm; PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X,&one)); /* correct eigenvalue approximation */ lambda = lambda - mu; if (PetscAbsScalar(mu)<=tol) break; } wr[0] = lambda; if (wi) wi[0] = 0.0; if (it==maxit) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_CONV_FAILED,"DSNEP did not converge"); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSNEPSetFN_NEP" static PetscErrorCode DSNEPSetFN_NEP(DS ds,PetscInt n,FN fn[]) { PetscErrorCode ierr; DS_NEP *ctx = (DS_NEP*)ds->data; PetscInt i; PetscFunctionBegin; if (n<=0) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Must have one or more functions, you have %D",n); if (n>DS_NUM_EXTRA) SETERRQ2(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Too many functions, you specified %D but the limit is %D",n,DS_NUM_EXTRA); if (ds->ld) { ierr = PetscInfo(ds,"DSNEPSetFN() called after DSAllocate()\n");CHKERRQ(ierr); } for (i=0;inf;i++) { ierr = FNDestroy(&ctx->f[i]);CHKERRQ(ierr); } for (i=0;if[i] = fn[i]; } ctx->nf = n; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNEPSetFN" /*@ DSNEPSetFN - Sets a number of functions that define the nonlinear eigenproblem. Collective on DS and FN Input Parameters: + ds - the direct solver context . n - number of functions - fn - array of functions Notes: The nonlinear eigenproblem is defined in terms of the split nonlinear operator T(lambda) = sum_i A_i*f_i(lambda). This function must be called before DSAllocate(). Then DSAllocate() will allocate an extra matrix A_i per each function, that can be filled in the usual way. Level: advanced .seealso: DSNEPGetFN(), DSAllocate() @*/ PetscErrorCode DSNEPSetFN(DS ds,PetscInt n,FN fn[]) { PetscInt i; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveInt(ds,n,2); PetscValidPointer(fn,3); for (i=0;idata; PetscFunctionBegin; if (k<0 || k>=ctx->nf) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",ctx->nf-1); *fn = ctx->f[k]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNEPGetFN" /*@ DSNEPGetFN - Gets the functions associated with the nonlinear DS. Not collective, though parallel FNs are returned if the DS is parallel Input Parameter: + ds - the direct solver context - k - the index of the requested function (starting in 0) Output Parameter: . fn - the function Level: advanced .seealso: DSNEPSetFN() @*/ PetscErrorCode DSNEPGetFN(DS ds,PetscInt k,FN *fn) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(fn,3); ierr = PetscUseMethod(ds,"DSNEPGetFN_C",(DS,PetscInt,FN*),(ds,k,fn));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNEPGetNumFN_NEP" static PetscErrorCode DSNEPGetNumFN_NEP(DS ds,PetscInt *n) { DS_NEP *ctx = (DS_NEP*)ds->data; PetscFunctionBegin; *n = ctx->nf; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNEPGetNumFN" /*@ DSNEPGetNumFN - Returns the number of functions stored internally by the DS. Not collective Input Parameter: . ds - the direct solver context Output Parameters: . n - the number of functions passed in DSNEPSetFN() Level: advanced .seealso: DSNEPSetFN() @*/ PetscErrorCode DSNEPGetNumFN(DS ds,PetscInt *n) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(n,2); ierr = PetscUseMethod(ds,"DSNEPGetNumFN_C",(DS,PetscInt*),(ds,n));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDestroy_NEP" PetscErrorCode DSDestroy_NEP(DS ds) { PetscErrorCode ierr; DS_NEP *ctx = (DS_NEP*)ds->data; PetscInt i; PetscFunctionBegin; for (i=0;inf;i++) { ierr = FNDestroy(&ctx->f[i]);CHKERRQ(ierr); } ierr = PetscFree(ds->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSNEPSetFN_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetFN_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetNumFN_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCreate_NEP" PETSC_EXTERN PetscErrorCode DSCreate_NEP(DS ds) { DS_NEP *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(ds,&ctx);CHKERRQ(ierr); ds->data = (void*)ctx; ds->ops->allocate = DSAllocate_NEP; ds->ops->view = DSView_NEP; ds->ops->vectors = DSVectors_NEP; ds->ops->solve[0] = DSSolve_NEP_SLP; ds->ops->sort = DSSort_NEP; ds->ops->normalize = DSNormalize_NEP; ds->ops->destroy = DSDestroy_NEP; ierr = PetscObjectComposeFunction((PetscObject)ds,"DSNEPSetFN_C",DSNEPSetFN_NEP);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetFN_C",DSNEPGetFN_NEP);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSNEPGetNumFN_C",DSNEPGetNumFN_NEP);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/nep/index.html0000644000175000017500000000215613107004621021542 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dsnep.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/nep/ftn-auto/0000755000175000017500000000000013107004621021276 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/nep/ftn-auto/makefile0000644000175000017500000000037013107004621022776 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = dsnepf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/ds/impls/nep/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/nep/ftn-auto/dsnepf.c0000644000175000017500000000327413107004621022727 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* dsnep.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcds.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsnepsetfn_ DSNEPSETFN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsnepsetfn_ dsnepsetfn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsnepgetfn_ DSNEPGETFN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsnepgetfn_ dsnepgetfn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dsnepgetnumfn_ DSNEPGETNUMFN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dsnepgetnumfn_ dsnepgetnumfn #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL dsnepsetfn_(DS ds,PetscInt *n,FN fn[], int *__ierr ){ *__ierr = DSNEPSetFN( (DS)PetscToPointer((ds) ),*n,fn); } PETSC_EXTERN void PETSC_STDCALL dsnepgetfn_(DS ds,PetscInt *k,FN *fn, int *__ierr ){ *__ierr = DSNEPGetFN( (DS)PetscToPointer((ds) ),*k,fn); } PETSC_EXTERN void PETSC_STDCALL dsnepgetnumfn_(DS ds,PetscInt *n, int *__ierr ){ *__ierr = DSNEPGetNumFN( (DS)PetscToPointer((ds) ),n); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/ds/impls/makefile.html0000644000175000017500000000463413107004621021431 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcsys
DIRS     = hep nhep ghep ghiep gnhep svd pep nep
LOCDIR   = src/sys/classes/ds/impls/
MANSEC   = DS

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/index.html0000644000175000017500000000245313107004621020760 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

hep/
nhep/
ghep/
ghiep/
gnhep/
svd/
pep/
nep/
makefile
slepc-3.7.4/src/sys/classes/ds/impls/nhep/0000755000175000017500000000000013107004621017711 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/nhep/makefile0000644000175000017500000000216413107004621021414 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dsnhep.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/nhep/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/nhep/dsnhep.c0000644000175000017500000006350613107004621021350 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "DSAllocate_NHEP" PetscErrorCode DSAllocate_NHEP(DS ds,PetscInt ld) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_Q);CHKERRQ(ierr); ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView_NHEP" PetscErrorCode DSView_NHEP(DS ds,PetscViewer viewer) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSViewMat(ds,viewer,DS_MAT_A);CHKERRQ(ierr); if (ds->state>DS_STATE_INTERMEDIATE) { ierr = DSViewMat(ds,viewer,DS_MAT_Q);CHKERRQ(ierr); } if (ds->mat[DS_MAT_X]) { ierr = DSViewMat(ds,viewer,DS_MAT_X);CHKERRQ(ierr); } if (ds->mat[DS_MAT_Y]) { ierr = DSViewMat(ds,viewer,DS_MAT_Y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_NHEP_Refined_Some" static PetscErrorCode DSVectors_NHEP_Refined_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left) { #if defined(PETSC_MISSING_LAPACK_GESVD) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,j; PetscBLASInt info,ld,n,n1,lwork,inc=1; PetscScalar sdummy,done=1.0,zero=0.0; PetscReal *sigma; PetscBool iscomplex = PETSC_FALSE; PetscScalar *A = ds->mat[DS_MAT_A]; PetscScalar *Q = ds->mat[DS_MAT_Q]; PetscScalar *X = ds->mat[left?DS_MAT_Y:DS_MAT_X]; PetscScalar *W; PetscFunctionBegin; if (left) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented for left vectors"); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); n1 = n+1; if ((*k)mat[DS_MAT_W]; lwork = 5*ld; sigma = ds->rwork+5*ld; /* build A-w*I in W */ for (j=0;jwork,&lwork,&info)); #else PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","O",&n1,&n,W,&ld,sigma,&sdummy,&ld,&sdummy,&ld,ds->work,&lwork,ds->rwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info); /* the smallest singular value is the new error estimate */ if (rnorm) *rnorm = sigma[n-1]; /* update vector with right singular vector associated to smallest singular value, accumulating the transformation matrix Q */ PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&done,Q,&ld,W+n-1,&ld,&zero,X+(*k)*ld,&inc)); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSVectors_NHEP_Refined_All" static PetscErrorCode DSVectors_NHEP_Refined_All(DS ds,PetscBool left) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; for (i=0;in;i++) { ierr = DSVectors_NHEP_Refined_Some(ds,&i,NULL,left);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_NHEP_Eigen_Some" static PetscErrorCode DSVectors_NHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left) { #if defined(SLEPC_MISSING_LAPACK_TREVC) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREVC - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt mm=1,mout,info,ld,n,*select,inc = 1; PetscScalar tmp,done=1.0,zero=0.0; PetscReal norm; PetscBool iscomplex = PETSC_FALSE; PetscScalar *A = ds->mat[DS_MAT_A]; PetscScalar *Q = ds->mat[DS_MAT_Q]; PetscScalar *X = ds->mat[left?DS_MAT_Y:DS_MAT_X]; PetscScalar *Y; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,0,0,ld);CHKERRQ(ierr); select = ds->iwork; for (i=0;iwork,&info)); #else ierr = DSAllocateWork_Private(ds,2*ld,ld,0);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_(left?"L":"R","S",select,&n,A,&ld,Y,&ld,Y,&ld,&mm,&mout,ds->work,ds->rwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTREVC %d",info); if (mout != mm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Inconsistent arguments"); /* accumulate and normalize eigenvectors */ if (ds->state>=DS_STATE_CONDENSED) { ierr = PetscMemcpy(ds->work,Y,mout*ld*sizeof(PetscScalar));CHKERRQ(ierr); PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&done,Q,&ld,ds->work,&inc,&zero,Y,&inc)); #if !defined(PETSC_USE_COMPLEX) if (iscomplex) PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&done,Q,&ld,ds->work+ld,&inc,&zero,Y+ld,&inc)); #endif norm = BLASnrm2_(&n,Y,&inc); #if !defined(PETSC_USE_COMPLEX) if (iscomplex) { tmp = BLASnrm2_(&n,Y+ld,&inc); norm = SlepcAbsEigenvalue(norm,tmp); } #endif tmp = 1.0 / norm; PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Y,&inc)); #if !defined(PETSC_USE_COMPLEX) if (iscomplex) PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Y+ld,&inc)); #endif } /* set output arguments */ if (iscomplex) (*k)++; if (rnorm) { if (iscomplex) *rnorm = SlepcAbsEigenvalue(Y[n-1],Y[n-1+ld]); else *rnorm = PetscAbsScalar(Y[n-1]); } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSVectors_NHEP_Eigen_All" static PetscErrorCode DSVectors_NHEP_Eigen_All(DS ds,PetscBool left) { #if defined(SLEPC_MISSING_LAPACK_TREVC) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREVC - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt n,ld,mout,info,inc = 1; PetscBool iscomplex; PetscScalar *X,*Y,*Z,*A = ds->mat[DS_MAT_A],tmp; PetscReal norm; const char *side,*back; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); if (left) { X = NULL; Y = ds->mat[DS_MAT_Y]; side = "L"; } else { X = ds->mat[DS_MAT_X]; Y = NULL; side = "R"; } Z = left? Y: X; if (ds->state>=DS_STATE_CONDENSED) { /* DSSolve() has been called, backtransform with matrix Q */ back = "B"; ierr = PetscMemcpy(Z,ds->mat[DS_MAT_Q],ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); } else back = "A"; #if !defined(PETSC_USE_COMPLEX) ierr = DSAllocateWork_Private(ds,3*ld,0,0);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_(side,back,NULL,&n,A,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,&info)); #else ierr = DSAllocateWork_Private(ds,2*ld,ld,0);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_(side,back,NULL,&n,A,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,ds->rwork,&info)); #endif if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xTREVC %i",info); /* normalize eigenvectors */ for (i=0;irefined) { if (!ds->extrarow) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Refined vectors require activating the extra row"); if (j) { ierr = DSVectors_NHEP_Refined_Some(ds,j,rnorm,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = DSVectors_NHEP_Refined_All(ds,PETSC_FALSE);CHKERRQ(ierr); } } else { if (j) { ierr = DSVectors_NHEP_Eigen_Some(ds,j,rnorm,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = DSVectors_NHEP_Eigen_All(ds,PETSC_FALSE);CHKERRQ(ierr); } } break; case DS_MAT_Y: if (ds->refined) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); if (j) { ierr = DSVectors_NHEP_Eigen_Some(ds,j,rnorm,PETSC_TRUE);CHKERRQ(ierr); } else { ierr = DSVectors_NHEP_Eigen_All(ds,PETSC_TRUE);CHKERRQ(ierr); } break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } if (ds->state < DS_STATE_CONDENSED) { ierr = DSSetState(ds,DS_STATE_CONDENSED);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNormalize_NHEP" PetscErrorCode DSNormalize_NHEP(DS ds,DSMatType mat,PetscInt col) { PetscErrorCode ierr; PetscInt i,i0,i1; PetscBLASInt ld,n,one = 1; PetscScalar *A = ds->mat[DS_MAT_A],norm,*x; #if !defined(PETSC_USE_COMPLEX) PetscScalar norm0; #endif PetscFunctionBegin; switch (mat) { case DS_MAT_X: case DS_MAT_Y: case DS_MAT_Q: /* Supported matrices */ break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&x);CHKERRQ(ierr); if (col < 0) { i0 = 0; i1 = ds->n; } else if (col>0 && A[ds->ld*(col-1)+col] != 0.0) { i0 = col-1; i1 = col+1; } else { i0 = col; i1 = col+1; } for (i=i0;ild*i+i+1] != 0.0) { norm = BLASnrm2_(&n,&x[ld*i],&one); norm0 = BLASnrm2_(&n,&x[ld*(i+1)],&one); norm = 1.0/SlepcAbsEigenvalue(norm,norm0); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one)); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*(i+1)],&one)); i++; } else #endif { norm = BLASnrm2_(&n,&x[ld*i],&one); norm = 1.0/norm; PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one)); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSort_NHEP_Arbitrary" static PetscErrorCode DSSort_NHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k) { #if defined(PETSC_MISSING_LAPACK_TRSEN) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TRSEN - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt info,n,ld,mout,lwork,*selection; PetscScalar *T = ds->mat[DS_MAT_A],*Q = ds->mat[DS_MAT_Q],*work; #if !defined(PETSC_USE_COMPLEX) PetscBLASInt *iwork,liwork; #endif PetscFunctionBegin; if (!k) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must supply argument k"); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) lwork = n; liwork = 1; ierr = DSAllocateWork_Private(ds,lwork,0,liwork+n);CHKERRQ(ierr); work = ds->work; lwork = ds->lwork; selection = ds->iwork; iwork = ds->iwork + n; liwork = ds->liwork - n; #else lwork = 1; ierr = DSAllocateWork_Private(ds,lwork,0,n);CHKERRQ(ierr); work = ds->work; selection = ds->iwork; #endif /* Compute the selected eigenvalue to be in the leading position */ ierr = DSSortEigenvalues_Private(ds,rr,ri,ds->perm,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscMemzero(selection,n*sizeof(PetscBLASInt));CHKERRQ(ierr); for (i=0;i<*k;i++) selection[ds->perm[i]] = 1; #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKtrsen",LAPACKtrsen_("N","V",selection,&n,T,&ld,Q,&ld,wr,wi,&mout,NULL,NULL,work,&lwork,iwork,&liwork,&info)); #else PetscStackCallBLAS("LAPACKtrsen",LAPACKtrsen_("N","V",selection,&n,T,&ld,Q,&ld,wr,&mout,NULL,NULL,work,&lwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTRSEN %d",info); *k = mout; PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSSort_NHEP_Total" static PetscErrorCode DSSort_NHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(SLEPC_MISSING_LAPACK_TREXC) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREXC - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscScalar re; PetscInt i,j,pos,result; PetscBLASInt ifst,ilst,info,n,ld; PetscScalar *T = ds->mat[DS_MAT_A]; PetscScalar *Q = ds->mat[DS_MAT_Q]; #if !defined(PETSC_USE_COMPLEX) PetscScalar *work,im; #endif PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = DSAllocateWork_Private(ds,ld,0,0);CHKERRQ(ierr); work = ds->work; #endif /* selection sort */ for (i=ds->l;isc,re,im,wr[j],wi[j],&result);CHKERRQ(ierr); #else ierr = SlepcSCCompare(ds->sc,re,0.0,wr[j],0.0,&result);CHKERRQ(ierr); #endif if (result > 0) { re = wr[j]; #if !defined(PETSC_USE_COMPLEX) im = wi[j]; #endif pos = j; } #if !defined(PETSC_USE_COMPLEX) if (wi[j] != 0) j++; #endif } if (pos) { /* interchange blocks */ ierr = PetscBLASIntCast(pos+1,&ifst);CHKERRQ(ierr); ierr = PetscBLASIntCast(i+1,&ilst);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKtrexc",LAPACKtrexc_("V",&n,T,&ld,Q,&ld,&ifst,&ilst,work,&info)); #else PetscStackCallBLAS("LAPACKtrexc",LAPACKtrexc_("V",&n,T,&ld,Q,&ld,&ifst,&ilst,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTREXC %d",info); /* recover original eigenvalues from T matrix */ for (j=i;jn,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); A = ds->mat[DS_MAT_A]; Q = ds->mat[DS_MAT_Q]; ierr = DSAllocateWork_Private(ds,2*ld,0,0);CHKERRQ(ierr); x = ds->work; y = ds->work+ld; for (i=0;ik = n; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSolve_NHEP" PetscErrorCode DSSolve_NHEP(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(SLEPC_MISSING_LAPACK_GEHRD) || defined(SLEPC_MISSING_LAPACK_ORGHR) || defined(PETSC_MISSING_LAPACK_HSEQR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEHRD/ORGHR/HSEQR - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscScalar *work,*tau; PetscInt i,j; PetscBLASInt ilo,lwork,info,n,ld; PetscScalar *A = ds->mat[DS_MAT_A]; PetscScalar *Q = ds->mat[DS_MAT_Q]; PetscFunctionBegin; #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(wi,3); #endif ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->l+1,&ilo);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,ld+ld*ld,0,0);CHKERRQ(ierr); tau = ds->work; work = ds->work+ld; lwork = ld*ld; /* initialize orthogonal matrix */ ierr = PetscMemzero(Q,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;istatel;j++) { if (j==n-1 || A[j+1+j*ld] == 0.0) { /* real eigenvalue */ wr[j] = A[j+j*ld]; wi[j] = 0.0; } else { /* complex eigenvalue */ wr[j] = A[j+j*ld]; wr[j+1] = A[j+j*ld]; wi[j] = PetscSqrtReal(PetscAbsReal(A[j+1+j*ld])) * PetscSqrtReal(PetscAbsReal(A[j+(j+1)*ld])); wi[j+1] = -wi[j]; j++; } } #else PetscStackCallBLAS("LAPACKhseqr",LAPACKhseqr_("S","V",&n,&ilo,&n,A,&ld,wr,Q,&ld,work,&lwork,&info)); if (wi) for (i=ds->l;ild,l=ds->l; PetscScalar *A; PetscFunctionBegin; if (ds->state==DS_STATE_CONDENSED) ds->t = ds->n; A = ds->mat[DS_MAT_A]; /* be careful not to break a diagonal 2x2 block */ if (A[n+(n-1)*ld]==0.0) newn = n; else { if (nn-1) newn = n+1; else newn = n-1; } if (ds->extrarow && ds->k==ds->n) { /* copy entries of extra row to the new position, then clean last row */ for (i=l;in+i*ld]; for (i=l;in;i++) A[ds->n+i*ld] = 0.0; } ds->k = 0; ds->n = newn; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCond_NHEP" PetscErrorCode DSCond_NHEP(DS ds,PetscReal *cond) { #if defined(PETSC_MISSING_LAPACK_GETRF) || defined(PETSC_MISSING_LAPACK_GETRI) || defined(SLEPC_MISSING_LAPACK_LANGE) || defined(SLEPC_MISSING_LAPACK_LANHS) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF/GETRI/LANGE/LANHS - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscScalar *work; PetscReal *rwork; PetscBLASInt *ipiv; PetscBLASInt lwork,info,n,ld; PetscReal hn,hin; PetscScalar *A; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); lwork = 8*ld; ierr = DSAllocateWork_Private(ds,lwork,ld,ld);CHKERRQ(ierr); work = ds->work; rwork = ds->rwork; ipiv = ds->iwork; /* use workspace matrix W to avoid overwriting A */ ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); A = ds->mat[DS_MAT_W]; ierr = PetscMemcpy(A,ds->mat[DS_MAT_A],sizeof(PetscScalar)*ds->ld*ds->ld);CHKERRQ(ierr); /* norm of A */ if (ds->staten,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); A = ds->mat[DS_MAT_A]; if (!recover) { ierr = DSAllocateWork_Private(ds,0,0,ld);CHKERRQ(ierr); ipiv = ds->iwork; if (!g) { ierr = DSAllocateWork_Private(ds,ld,0,0);CHKERRQ(ierr); g = ds->work; } /* use workspace matrix W to factor A-tau*eye(n) */ ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); B = ds->mat[DS_MAT_W]; ierr = PetscMemcpy(B,A,sizeof(PetscScalar)*ld*ld);CHKERRQ(ierr); /* Vector g initialy stores b = beta*e_n^T */ ierr = PetscMemzero(g,n*sizeof(PetscScalar));CHKERRQ(ierr); g[n-1] = beta; /* g = (A-tau*eye(n))'\b */ for (i=0;i0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_MAT_LU_ZRPVT,"Bad LU factorization"); ierr = PetscLogFlops(2.0*n*n*n/3.0);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("C",&n,&one,B,&ld,ipiv,g,&ld,&info)); if (info) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"GETRS - Bad solve"); ierr = PetscLogFlops(2.0*n*n-n);CHKERRQ(ierr); /* A = A + g*b' */ for (i=0;iwork; Q = ds->mat[DS_MAT_Q]; /* g^ = -Q(:,idx)'*g */ ierr = PetscBLASIntCast(ds->l+ds->k,&ncol);CHKERRQ(ierr); PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n,&ncol,&dmone,Q,&ld,g,&one,&dzero,ghat,&one)); /* A = A + g^*b' */ for (i=0;il+ds->k;i++) for (j=ds->l;jl+ds->k;j++) A[i+j*ld] += ghat[i]*Q[n-1+j*ld]*beta; /* g~ = (I-Q(:,idx)*Q(:,idx)')*g = g+Q(:,idx)*g^ */ PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&ncol,&done,Q,&ld,ghat,&one,&done,g,&one)); } /* Compute gamma factor */ if (gamma) { gnorm = 0.0; for (i=0;iops->allocate = DSAllocate_NHEP; ds->ops->view = DSView_NHEP; ds->ops->vectors = DSVectors_NHEP; ds->ops->solve[0] = DSSolve_NHEP; ds->ops->sort = DSSort_NHEP; ds->ops->truncate = DSTruncate_NHEP; ds->ops->update = DSUpdateExtraRow_NHEP; ds->ops->cond = DSCond_NHEP; ds->ops->transharm = DSTranslateHarmonic_NHEP; ds->ops->normalize = DSNormalize_NHEP; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/nhep/makefile.html0000644000175000017500000000470513107004621022362 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dsnhep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/nhep/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/nhep/dsnhep.c.html0000644000175000017500000015765113107004621022320 0ustar jromanjroman
Actual source code: dsnhep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/dsimpl.h>
 23: #include <slepcblaslapack.h>

 27: PetscErrorCode DSAllocate_NHEP(DS ds,PetscInt ld)
 28: {

 32:   DSAllocateMat_Private(ds,DS_MAT_A);
 33:   DSAllocateMat_Private(ds,DS_MAT_Q);
 34:   PetscFree(ds->perm);
 35:   PetscMalloc1(ld,&ds->perm);
 36:   PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));
 37:   return(0);
 38: }

 42: PetscErrorCode DSView_NHEP(DS ds,PetscViewer viewer)
 43: {

 47:   DSViewMat(ds,viewer,DS_MAT_A);
 48:   if (ds->state>DS_STATE_INTERMEDIATE) {
 49:     DSViewMat(ds,viewer,DS_MAT_Q);
 50:   }
 51:   if (ds->mat[DS_MAT_X]) {
 52:     DSViewMat(ds,viewer,DS_MAT_X);
 53:   }
 54:   if (ds->mat[DS_MAT_Y]) {
 55:     DSViewMat(ds,viewer,DS_MAT_Y);
 56:   }
 57:   return(0);
 58: }

 62: static PetscErrorCode DSVectors_NHEP_Refined_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)
 63: {
 64: #if defined(PETSC_MISSING_LAPACK_GESVD)
 66:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable");
 67: #else
 69:   PetscInt       i,j;
 70:   PetscBLASInt   info,ld,n,n1,lwork,inc=1;
 71:   PetscScalar    sdummy,done=1.0,zero=0.0;
 72:   PetscReal      *sigma;
 73:   PetscBool      iscomplex = PETSC_FALSE;
 74:   PetscScalar    *A = ds->mat[DS_MAT_A];
 75:   PetscScalar    *Q = ds->mat[DS_MAT_Q];
 76:   PetscScalar    *X = ds->mat[left?DS_MAT_Y:DS_MAT_X];
 77:   PetscScalar    *W;

 80:   if (left) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented for left vectors");
 81:   PetscBLASIntCast(ds->n,&n);
 82:   PetscBLASIntCast(ds->ld,&ld);
 83:   n1 = n+1;
 84:   if ((*k)<n-1 && A[(*k)+1+(*k)*ld]!=0.0) iscomplex = PETSC_TRUE;
 85:   if (iscomplex) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented for complex eigenvalues yet");
 86:   DSAllocateWork_Private(ds,5*ld,6*ld,0);
 87:   DSAllocateMat_Private(ds,DS_MAT_W);
 88:   W = ds->mat[DS_MAT_W];
 89:   lwork = 5*ld;
 90:   sigma = ds->rwork+5*ld;

 92:   /* build A-w*I in W */
 93:   for (j=0;j<n;j++)
 94:     for (i=0;i<=n;i++)
 95:       W[i+j*ld] = A[i+j*ld];
 96:   for (i=0;i<n;i++)
 97:     W[i+i*ld] -= A[(*k)+(*k)*ld];

 99:   /* compute SVD of W */
100: #if !defined(PETSC_USE_COMPLEX)
101:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","O",&n1,&n,W,&ld,sigma,&sdummy,&ld,&sdummy,&ld,ds->work,&lwork,&info));
102: #else
103:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("N","O",&n1,&n,W,&ld,sigma,&sdummy,&ld,&sdummy,&ld,ds->work,&lwork,ds->rwork,&info));
104: #endif
105:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);

107:   /* the smallest singular value is the new error estimate */
108:   if (rnorm) *rnorm = sigma[n-1];

110:   /* update vector with right singular vector associated to smallest singular value,
111:      accumulating the transformation matrix Q */
112:   PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&done,Q,&ld,W+n-1,&ld,&zero,X+(*k)*ld,&inc));
113:   return(0);
114: #endif
115: }

119: static PetscErrorCode DSVectors_NHEP_Refined_All(DS ds,PetscBool left)
120: {
122:   PetscInt       i;

125:   for (i=0;i<ds->n;i++) {
126:     DSVectors_NHEP_Refined_Some(ds,&i,NULL,left);
127:   }
128:   return(0);
129: }

133: static PetscErrorCode DSVectors_NHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)
134: {
135: #if defined(SLEPC_MISSING_LAPACK_TREVC)
137:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREVC - Lapack routine is unavailable");
138: #else
140:   PetscInt       i;
141:   PetscBLASInt   mm=1,mout,info,ld,n,*select,inc = 1;
142:   PetscScalar    tmp,done=1.0,zero=0.0;
143:   PetscReal      norm;
144:   PetscBool      iscomplex = PETSC_FALSE;
145:   PetscScalar    *A = ds->mat[DS_MAT_A];
146:   PetscScalar    *Q = ds->mat[DS_MAT_Q];
147:   PetscScalar    *X = ds->mat[left?DS_MAT_Y:DS_MAT_X];
148:   PetscScalar    *Y;

151:   PetscBLASIntCast(ds->n,&n);
152:   PetscBLASIntCast(ds->ld,&ld);
153:   DSAllocateWork_Private(ds,0,0,ld);
154:   select = ds->iwork;
155:   for (i=0;i<n;i++) select[i] = (PetscBLASInt)PETSC_FALSE;

157:   /* compute k-th eigenvector Y of A */
158:   Y = X+(*k)*ld;
159:   select[*k] = (PetscBLASInt)PETSC_TRUE;
160: #if !defined(PETSC_USE_COMPLEX)
161:   if ((*k)<n-1 && A[(*k)+1+(*k)*ld]!=0.0) iscomplex = PETSC_TRUE;
162:   mm = iscomplex? 2: 1;
163:   if (iscomplex) select[(*k)+1] = (PetscBLASInt)PETSC_TRUE;
164:   DSAllocateWork_Private(ds,3*ld,0,0);
165:   PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_(left?"L":"R","S",select,&n,A,&ld,Y,&ld,Y,&ld,&mm,&mout,ds->work,&info));
166: #else
167:   DSAllocateWork_Private(ds,2*ld,ld,0);
168:   PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_(left?"L":"R","S",select,&n,A,&ld,Y,&ld,Y,&ld,&mm,&mout,ds->work,ds->rwork,&info));
169: #endif
170:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTREVC %d",info);
171:   if (mout != mm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Inconsistent arguments");

173:   /* accumulate and normalize eigenvectors */
174:   if (ds->state>=DS_STATE_CONDENSED) {
175:     PetscMemcpy(ds->work,Y,mout*ld*sizeof(PetscScalar));
176:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&done,Q,&ld,ds->work,&inc,&zero,Y,&inc));
177: #if !defined(PETSC_USE_COMPLEX)
178:     if (iscomplex) PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&done,Q,&ld,ds->work+ld,&inc,&zero,Y+ld,&inc));
179: #endif
180:     norm = BLASnrm2_(&n,Y,&inc);
181: #if !defined(PETSC_USE_COMPLEX)
182:     if (iscomplex) {
183:       tmp = BLASnrm2_(&n,Y+ld,&inc);
184:       norm = SlepcAbsEigenvalue(norm,tmp);
185:     }
186: #endif
187:     tmp = 1.0 / norm;
188:     PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Y,&inc));
189: #if !defined(PETSC_USE_COMPLEX)
190:     if (iscomplex) PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Y+ld,&inc));
191: #endif
192:   }

194:   /* set output arguments */
195:   if (iscomplex) (*k)++;
196:   if (rnorm) {
197:     if (iscomplex) *rnorm = SlepcAbsEigenvalue(Y[n-1],Y[n-1+ld]);
198:     else *rnorm = PetscAbsScalar(Y[n-1]);
199:   }
200:   return(0);
201: #endif
202: }

206: static PetscErrorCode DSVectors_NHEP_Eigen_All(DS ds,PetscBool left)
207: {
208: #if defined(SLEPC_MISSING_LAPACK_TREVC)
210:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREVC - Lapack routine is unavailable");
211: #else
213:   PetscInt       i;
214:   PetscBLASInt   n,ld,mout,info,inc = 1;
215:   PetscBool      iscomplex;
216:   PetscScalar    *X,*Y,*Z,*A = ds->mat[DS_MAT_A],tmp;
217:   PetscReal      norm;
218:   const char     *side,*back;

221:   PetscBLASIntCast(ds->n,&n);
222:   PetscBLASIntCast(ds->ld,&ld);
223:   if (left) {
224:     X = NULL;
225:     Y = ds->mat[DS_MAT_Y];
226:     side = "L";
227:   } else {
228:     X = ds->mat[DS_MAT_X];
229:     Y = NULL;
230:     side = "R";
231:   }
232:   Z = left? Y: X;
233:   if (ds->state>=DS_STATE_CONDENSED) {
234:     /* DSSolve() has been called, backtransform with matrix Q */
235:     back = "B";
236:     PetscMemcpy(Z,ds->mat[DS_MAT_Q],ld*ld*sizeof(PetscScalar));
237:   } else back = "A";
238: #if !defined(PETSC_USE_COMPLEX)
239:   DSAllocateWork_Private(ds,3*ld,0,0);
240:   PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_(side,back,NULL,&n,A,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,&info));
241: #else
242:   DSAllocateWork_Private(ds,2*ld,ld,0);
243:   PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_(side,back,NULL,&n,A,&ld,Y,&ld,X,&ld,&n,&mout,ds->work,ds->rwork,&info));
244: #endif
245:   if (info) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_LIB,"Error in Lapack xTREVC %i",info);

247:   /* normalize eigenvectors */
248:   for (i=0;i<n;i++) {
249:     iscomplex = (i<n-1 && A[i+1+i*ld]!=0.0)? PETSC_TRUE: PETSC_FALSE;
250:     norm = BLASnrm2_(&n,Z+i*ld,&inc);
251: #if !defined(PETSC_USE_COMPLEX)
252:     if (iscomplex) {
253:       tmp = BLASnrm2_(&n,Z+(i+1)*ld,&inc);
254:       norm = SlepcAbsEigenvalue(norm,tmp);
255:     }
256: #endif
257:     tmp = 1.0 / norm;
258:     PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z+i*ld,&inc));
259: #if !defined(PETSC_USE_COMPLEX)
260:     if (iscomplex) PetscStackCallBLAS("BLASscal",BLASscal_(&n,&tmp,Z+(i+1)*ld,&inc));
261: #endif
262:     if (iscomplex) i++;
263:   }
264:   return(0);
265: #endif
266: }

270: PetscErrorCode DSVectors_NHEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
271: {

275:   switch (mat) {
276:     case DS_MAT_X:
277:       if (ds->refined) {
278:         if (!ds->extrarow) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Refined vectors require activating the extra row");
279:         if (j) {
280:           DSVectors_NHEP_Refined_Some(ds,j,rnorm,PETSC_FALSE);
281:         } else {
282:           DSVectors_NHEP_Refined_All(ds,PETSC_FALSE);
283:         }
284:       } else {
285:         if (j) {
286:           DSVectors_NHEP_Eigen_Some(ds,j,rnorm,PETSC_FALSE);
287:         } else {
288:           DSVectors_NHEP_Eigen_All(ds,PETSC_FALSE);
289:         }
290:       }
291:       break;
292:     case DS_MAT_Y:
293:       if (ds->refined) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
294:       if (j) {
295:         DSVectors_NHEP_Eigen_Some(ds,j,rnorm,PETSC_TRUE);
296:       } else {
297:         DSVectors_NHEP_Eigen_All(ds,PETSC_TRUE);
298:       }
299:       break;
300:     case DS_MAT_U:
301:     case DS_MAT_VT:
302:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
303:       break;
304:     default:
305:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
306:   }
307:   if (ds->state < DS_STATE_CONDENSED) {
308:     DSSetState(ds,DS_STATE_CONDENSED);
309:   }
310:   return(0);
311: }

315: PetscErrorCode DSNormalize_NHEP(DS ds,DSMatType mat,PetscInt col)
316: {
318:   PetscInt       i,i0,i1;
319:   PetscBLASInt   ld,n,one = 1;
320:   PetscScalar    *A = ds->mat[DS_MAT_A],norm,*x;
321: #if !defined(PETSC_USE_COMPLEX)
322:   PetscScalar    norm0;
323: #endif

326:   switch (mat) {
327:     case DS_MAT_X:
328:     case DS_MAT_Y:
329:     case DS_MAT_Q:
330:       /* Supported matrices */
331:       break;
332:     case DS_MAT_U:
333:     case DS_MAT_VT:
334:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
335:       break;
336:     default:
337:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
338:   }

340:   PetscBLASIntCast(ds->n,&n);
341:   PetscBLASIntCast(ds->ld,&ld);
342:   DSGetArray(ds,mat,&x);
343:   if (col < 0) {
344:     i0 = 0; i1 = ds->n;
345:   } else if (col>0 && A[ds->ld*(col-1)+col] != 0.0) {
346:     i0 = col-1; i1 = col+1;
347:   } else {
348:     i0 = col; i1 = col+1;
349:   }
350:   for (i=i0;i<i1;i++) {
351: #if !defined(PETSC_USE_COMPLEX)
352:     if (i<n-1 && A[ds->ld*i+i+1] != 0.0) {
353:       norm = BLASnrm2_(&n,&x[ld*i],&one);
354:       norm0 = BLASnrm2_(&n,&x[ld*(i+1)],&one);
355:       norm = 1.0/SlepcAbsEigenvalue(norm,norm0);
356:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
357:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*(i+1)],&one));
358:       i++;
359:     } else
360: #endif
361:     {
362:       norm = BLASnrm2_(&n,&x[ld*i],&one);
363:       norm = 1.0/norm;
364:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
365:     }
366:   }
367:   return(0);
368: }

372: static PetscErrorCode DSSort_NHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
373: {
374: #if defined(PETSC_MISSING_LAPACK_TRSEN)
376:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TRSEN - Lapack routine is unavailable");
377: #else
379:   PetscInt       i;
380:   PetscBLASInt   info,n,ld,mout,lwork,*selection;
381:   PetscScalar    *T = ds->mat[DS_MAT_A],*Q = ds->mat[DS_MAT_Q],*work;
382: #if !defined(PETSC_USE_COMPLEX)
383:   PetscBLASInt   *iwork,liwork;
384: #endif

387:   if (!k) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must supply argument k");
388:   PetscBLASIntCast(ds->n,&n);
389:   PetscBLASIntCast(ds->ld,&ld);
390: #if !defined(PETSC_USE_COMPLEX)
391:   lwork = n;
392:   liwork = 1;
393:   DSAllocateWork_Private(ds,lwork,0,liwork+n);
394:   work = ds->work;
395:   lwork = ds->lwork;
396:   selection = ds->iwork;
397:   iwork = ds->iwork + n;
398:   liwork = ds->liwork - n;
399: #else
400:   lwork = 1;
401:   DSAllocateWork_Private(ds,lwork,0,n);
402:   work = ds->work;
403:   selection = ds->iwork;
404: #endif
405:   /* Compute the selected eigenvalue to be in the leading position */
406:   DSSortEigenvalues_Private(ds,rr,ri,ds->perm,PETSC_FALSE);
407:   PetscMemzero(selection,n*sizeof(PetscBLASInt));
408:   for (i=0;i<*k;i++) selection[ds->perm[i]] = 1;
409: #if !defined(PETSC_USE_COMPLEX)
410:   PetscStackCallBLAS("LAPACKtrsen",LAPACKtrsen_("N","V",selection,&n,T,&ld,Q,&ld,wr,wi,&mout,NULL,NULL,work,&lwork,iwork,&liwork,&info));
411: #else
412:   PetscStackCallBLAS("LAPACKtrsen",LAPACKtrsen_("N","V",selection,&n,T,&ld,Q,&ld,wr,&mout,NULL,NULL,work,&lwork,&info));
413: #endif
414:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTRSEN %d",info);
415:   *k = mout;
416:   return(0);
417: #endif
418: }

422: static PetscErrorCode DSSort_NHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi)
423: {
424: #if defined(SLEPC_MISSING_LAPACK_TREXC)
426:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREXC - Lapack routine is unavailable");
427: #else
429:   PetscScalar    re;
430:   PetscInt       i,j,pos,result;
431:   PetscBLASInt   ifst,ilst,info,n,ld;
432:   PetscScalar    *T = ds->mat[DS_MAT_A];
433:   PetscScalar    *Q = ds->mat[DS_MAT_Q];
434: #if !defined(PETSC_USE_COMPLEX)
435:   PetscScalar    *work,im;
436: #endif

439:   PetscBLASIntCast(ds->n,&n);
440:   PetscBLASIntCast(ds->ld,&ld);
441: #if !defined(PETSC_USE_COMPLEX)
442:   DSAllocateWork_Private(ds,ld,0,0);
443:   work = ds->work;
444: #endif
445:   /* selection sort */
446:   for (i=ds->l;i<n-1;i++) {
447:     re = wr[i];
448: #if !defined(PETSC_USE_COMPLEX)
449:     im = wi[i];
450: #endif
451:     pos = 0;
452:     j=i+1; /* j points to the next eigenvalue */
453: #if !defined(PETSC_USE_COMPLEX)
454:     if (im != 0) j=i+2;
455: #endif
456:     /* find minimum eigenvalue */
457:     for (;j<n;j++) {
458: #if !defined(PETSC_USE_COMPLEX)
459:       SlepcSCCompare(ds->sc,re,im,wr[j],wi[j],&result);
460: #else
461:       SlepcSCCompare(ds->sc,re,0.0,wr[j],0.0,&result);
462: #endif
463:       if (result > 0) {
464:         re = wr[j];
465: #if !defined(PETSC_USE_COMPLEX)
466:         im = wi[j];
467: #endif
468:         pos = j;
469:       }
470: #if !defined(PETSC_USE_COMPLEX)
471:       if (wi[j] != 0) j++;
472: #endif
473:     }
474:     if (pos) {
475:       /* interchange blocks */
476:       PetscBLASIntCast(pos+1,&ifst);
477:       PetscBLASIntCast(i+1,&ilst);
478: #if !defined(PETSC_USE_COMPLEX)
479:       PetscStackCallBLAS("LAPACKtrexc",LAPACKtrexc_("V",&n,T,&ld,Q,&ld,&ifst,&ilst,work,&info));
480: #else
481:       PetscStackCallBLAS("LAPACKtrexc",LAPACKtrexc_("V",&n,T,&ld,Q,&ld,&ifst,&ilst,&info));
482: #endif
483:       if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTREXC %d",info);
484:       /* recover original eigenvalues from T matrix */
485:       for (j=i;j<n;j++) {
486:         wr[j] = T[j+j*ld];
487: #if !defined(PETSC_USE_COMPLEX)
488:         if (j<n-1 && T[j+1+j*ld] != 0.0) {
489:           /* complex conjugate eigenvalue */
490:           wi[j] = PetscSqrtReal(PetscAbsReal(T[j+1+j*ld])) *
491:                   PetscSqrtReal(PetscAbsReal(T[j+(j+1)*ld]));
492:           wr[j+1] = wr[j];
493:           wi[j+1] = -wi[j];
494:           j++;
495:         } else {
496:           wi[j] = 0.0;
497:         }
498: #endif
499:       }
500:     }
501: #if !defined(PETSC_USE_COMPLEX)
502:     if (wi[i] != 0) i++;
503: #endif
504:   }
505:   return(0);
506: #endif
507: }

511: PetscErrorCode DSSort_NHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
512: {

516:   if (!rr || wr == rr) {
517:     DSSort_NHEP_Total(ds,wr,wi);
518:   } else {
519:     DSSort_NHEP_Arbitrary(ds,wr,wi,rr,ri,k);
520:   }
521:   return(0);
522: }

526: PetscErrorCode DSUpdateExtraRow_NHEP(DS ds)
527: {
529:   PetscInt       i;
530:   PetscBLASInt   n,ld,incx=1;
531:   PetscScalar    *A,*Q,*x,*y,one=1.0,zero=0.0;

534:   PetscBLASIntCast(ds->n,&n);
535:   PetscBLASIntCast(ds->ld,&ld);
536:   A  = ds->mat[DS_MAT_A];
537:   Q  = ds->mat[DS_MAT_Q];
538:   DSAllocateWork_Private(ds,2*ld,0,0);
539:   x = ds->work;
540:   y = ds->work+ld;
541:   for (i=0;i<n;i++) x[i] = PetscConj(A[n+i*ld]);
542:   PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n,&n,&one,Q,&ld,x,&incx,&zero,y,&incx));
543:   for (i=0;i<n;i++) A[n+i*ld] = PetscConj(y[i]);
544:   ds->k = n;
545:   return(0);
546: }

550: PetscErrorCode DSSolve_NHEP(DS ds,PetscScalar *wr,PetscScalar *wi)
551: {
552: #if defined(SLEPC_MISSING_LAPACK_GEHRD) || defined(SLEPC_MISSING_LAPACK_ORGHR) || defined(PETSC_MISSING_LAPACK_HSEQR)
554:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEHRD/ORGHR/HSEQR - Lapack routines are unavailable");
555: #else
557:   PetscScalar    *work,*tau;
558:   PetscInt       i,j;
559:   PetscBLASInt   ilo,lwork,info,n,ld;
560:   PetscScalar    *A = ds->mat[DS_MAT_A];
561:   PetscScalar    *Q = ds->mat[DS_MAT_Q];

564: #if !defined(PETSC_USE_COMPLEX)
566: #endif
567:   PetscBLASIntCast(ds->n,&n);
568:   PetscBLASIntCast(ds->ld,&ld);
569:   PetscBLASIntCast(ds->l+1,&ilo);
570:   DSAllocateWork_Private(ds,ld+ld*ld,0,0);
571:   tau  = ds->work;
572:   work = ds->work+ld;
573:   lwork = ld*ld;

575:   /* initialize orthogonal matrix */
576:   PetscMemzero(Q,ld*ld*sizeof(PetscScalar));
577:   for (i=0;i<n;i++)
578:     Q[i+i*ld] = 1.0;
579:   if (n==1) { /* quick return */
580:     wr[0] = A[0];
581:     wi[0] = 0.0;
582:     return(0);
583:   }

585:   /* reduce to upper Hessenberg form */
586:   if (ds->state<DS_STATE_INTERMEDIATE) {
587:     PetscStackCallBLAS("LAPACKgehrd",LAPACKgehrd_(&n,&ilo,&n,A,&ld,tau,work,&lwork,&info));
588:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEHRD %d",info);
589:     for (j=0;j<n-1;j++) {
590:       for (i=j+2;i<n;i++) {
591:         Q[i+j*ld] = A[i+j*ld];
592:         A[i+j*ld] = 0.0;
593:       }
594:     }
595:     PetscStackCallBLAS("LAPACKorghr",LAPACKorghr_(&n,&ilo,&n,Q,&ld,tau,work,&lwork,&info));
596:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGHR %d",info);
597:   }

599:   /* compute the (real) Schur form */
600: #if !defined(PETSC_USE_COMPLEX)
601:   PetscStackCallBLAS("LAPACKhseqr",LAPACKhseqr_("S","V",&n,&ilo,&n,A,&ld,wr,wi,Q,&ld,work,&lwork,&info));
602:   for (j=0;j<ds->l;j++) {
603:     if (j==n-1 || A[j+1+j*ld] == 0.0) {
604:       /* real eigenvalue */
605:       wr[j] = A[j+j*ld];
606:       wi[j] = 0.0;
607:     } else {
608:       /* complex eigenvalue */
609:       wr[j] = A[j+j*ld];
610:       wr[j+1] = A[j+j*ld];
611:       wi[j] = PetscSqrtReal(PetscAbsReal(A[j+1+j*ld])) *
612:               PetscSqrtReal(PetscAbsReal(A[j+(j+1)*ld]));
613:       wi[j+1] = -wi[j];
614:       j++;
615:     }
616:   }
617: #else
618:   PetscStackCallBLAS("LAPACKhseqr",LAPACKhseqr_("S","V",&n,&ilo,&n,A,&ld,wr,Q,&ld,work,&lwork,&info));
619:   if (wi) for (i=ds->l;i<n;i++) wi[i] = 0.0;
620: #endif
621:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xHSEQR %d",info);
622:   return(0);
623: #endif
624: }

628: PetscErrorCode DSTruncate_NHEP(DS ds,PetscInt n)
629: {
630:   PetscInt       i,newn,ld=ds->ld,l=ds->l;
631:   PetscScalar    *A;

634:   if (ds->state==DS_STATE_CONDENSED) ds->t = ds->n;
635:   A = ds->mat[DS_MAT_A];
636:   /* be careful not to break a diagonal 2x2 block */
637:   if (A[n+(n-1)*ld]==0.0) newn = n;
638:   else {
639:     if (n<ds->n-1) newn = n+1;
640:     else newn = n-1;
641:   }
642:   if (ds->extrarow && ds->k==ds->n) {
643:     /* copy entries of extra row to the new position, then clean last row */
644:     for (i=l;i<newn;i++) A[newn+i*ld] = A[ds->n+i*ld];
645:     for (i=l;i<ds->n;i++) A[ds->n+i*ld] = 0.0;
646:   }
647:   ds->k = 0;
648:   ds->n = newn;
649:   return(0);
650: }

654: PetscErrorCode DSCond_NHEP(DS ds,PetscReal *cond)
655: {
656: #if defined(PETSC_MISSING_LAPACK_GETRF) || defined(PETSC_MISSING_LAPACK_GETRI) || defined(SLEPC_MISSING_LAPACK_LANGE) || defined(SLEPC_MISSING_LAPACK_LANHS)
658:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF/GETRI/LANGE/LANHS - Lapack routines are unavailable");
659: #else
661:   PetscScalar    *work;
662:   PetscReal      *rwork;
663:   PetscBLASInt   *ipiv;
664:   PetscBLASInt   lwork,info,n,ld;
665:   PetscReal      hn,hin;
666:   PetscScalar    *A;

669:   PetscBLASIntCast(ds->n,&n);
670:   PetscBLASIntCast(ds->ld,&ld);
671:   lwork = 8*ld;
672:   DSAllocateWork_Private(ds,lwork,ld,ld);
673:   work  = ds->work;
674:   rwork = ds->rwork;
675:   ipiv  = ds->iwork;

677:   /* use workspace matrix W to avoid overwriting A */
678:   DSAllocateMat_Private(ds,DS_MAT_W);
679:   A = ds->mat[DS_MAT_W];
680:   PetscMemcpy(A,ds->mat[DS_MAT_A],sizeof(PetscScalar)*ds->ld*ds->ld);

682:   /* norm of A */
683:   if (ds->state<DS_STATE_INTERMEDIATE) hn = LAPACKlange_("I",&n,&n,A,&ld,rwork);
684:   else hn = LAPACKlanhs_("I",&n,A,&ld,rwork);

686:   /* norm of inv(A) */
687:   PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&n,&n,A,&ld,ipiv,&info));
688:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGETRF %d",info);
689:   PetscStackCallBLAS("LAPACKgetri",LAPACKgetri_(&n,A,&ld,ipiv,work,&lwork,&info));
690:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGETRI %d",info);
691:   hin = LAPACKlange_("I",&n,&n,A,&ld,rwork);

693:   *cond = hn*hin;
694:   return(0);
695: #endif
696: }

700: PetscErrorCode DSTranslateHarmonic_NHEP(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *gin,PetscReal *gamma)
701: {
702: #if defined(PETSC_MISSING_LAPACK_GETRF) || defined(PETSC_MISSING_LAPACK_GETRS)
704:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF/GETRS - Lapack routines are unavailable");
705: #else
707:   PetscInt       i,j;
708:   PetscBLASInt   *ipiv,info,n,ld,one=1,ncol;
709:   PetscScalar    *A,*B,*Q,*g=gin,*ghat;
710:   PetscScalar    done=1.0,dmone=-1.0,dzero=0.0;
711:   PetscReal      gnorm;

714:   PetscBLASIntCast(ds->n,&n);
715:   PetscBLASIntCast(ds->ld,&ld);
716:   A  = ds->mat[DS_MAT_A];

718:   if (!recover) {

720:     DSAllocateWork_Private(ds,0,0,ld);
721:     ipiv = ds->iwork;
722:     if (!g) {
723:       DSAllocateWork_Private(ds,ld,0,0);
724:       g = ds->work;
725:     }
726:     /* use workspace matrix W to factor A-tau*eye(n) */
727:     DSAllocateMat_Private(ds,DS_MAT_W);
728:     B = ds->mat[DS_MAT_W];
729:     PetscMemcpy(B,A,sizeof(PetscScalar)*ld*ld);

731:     /* Vector g initialy stores b = beta*e_n^T */
732:     PetscMemzero(g,n*sizeof(PetscScalar));
733:     g[n-1] = beta;

735:     /* g = (A-tau*eye(n))'\b */
736:     for (i=0;i<n;i++)
737:       B[i+i*ld] -= tau;
738:     PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&n,&n,B,&ld,ipiv,&info));
739:     if (info<0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Bad argument to LU factorization");
740:     if (info>0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_MAT_LU_ZRPVT,"Bad LU factorization");
741:     PetscLogFlops(2.0*n*n*n/3.0);
742:     PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("C",&n,&one,B,&ld,ipiv,g,&ld,&info));
743:     if (info) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"GETRS - Bad solve");
744:     PetscLogFlops(2.0*n*n-n);

746:     /* A = A + g*b' */
747:     for (i=0;i<n;i++)
748:       A[i+(n-1)*ld] += g[i]*beta;

750:   } else { /* recover */

753:     DSAllocateWork_Private(ds,ld,0,0);
754:     ghat = ds->work;
755:     Q    = ds->mat[DS_MAT_Q];

757:     /* g^ = -Q(:,idx)'*g */
758:     PetscBLASIntCast(ds->l+ds->k,&ncol);
759:     PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n,&ncol,&dmone,Q,&ld,g,&one,&dzero,ghat,&one));

761:     /* A = A + g^*b' */
762:     for (i=0;i<ds->l+ds->k;i++)
763:       for (j=ds->l;j<ds->l+ds->k;j++)
764:         A[i+j*ld] += ghat[i]*Q[n-1+j*ld]*beta;

766:     /* g~ = (I-Q(:,idx)*Q(:,idx)')*g = g+Q(:,idx)*g^ */
767:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&ncol,&done,Q,&ld,ghat,&one,&done,g,&one));
768:   }

770:   /* Compute gamma factor */
771:   if (gamma) {
772:     gnorm = 0.0;
773:     for (i=0;i<n;i++)
774:       gnorm = gnorm + PetscRealPart(g[i]*PetscConj(g[i]));
775:     *gamma = PetscSqrtReal(1.0+gnorm);
776:   }
777:   return(0);
778: #endif
779: }

783: PETSC_EXTERN PetscErrorCode DSCreate_NHEP(DS ds)
784: {
786:   ds->ops->allocate      = DSAllocate_NHEP;
787:   ds->ops->view          = DSView_NHEP;
788:   ds->ops->vectors       = DSVectors_NHEP;
789:   ds->ops->solve[0]      = DSSolve_NHEP;
790:   ds->ops->sort          = DSSort_NHEP;
791:   ds->ops->truncate      = DSTruncate_NHEP;
792:   ds->ops->update        = DSUpdateExtraRow_NHEP;
793:   ds->ops->cond          = DSCond_NHEP;
794:   ds->ops->transharm     = DSTranslateHarmonic_NHEP;
795:   ds->ops->normalize     = DSNormalize_NHEP;
796:   return(0);
797: }

slepc-3.7.4/src/sys/classes/ds/impls/nhep/index.html0000644000175000017500000000216213107004621021707 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dsnhep.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/pep/0000755000175000017500000000000013107004621017543 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/pep/makefile0000644000175000017500000000216213107004621021244 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dspep.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/pep/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/pep/dspep.c.html0000644000175000017500000006516213107004621021777 0ustar jromanjroman

Actual source code: dspep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/dsimpl.h>       /*I "slepcds.h" I*/
 23: #include <slepcblaslapack.h>

 25: typedef struct {
 26:   PetscInt d;              /* polynomial degree */
 27: } DS_PEP;

 31: PetscErrorCode DSAllocate_PEP(DS ds,PetscInt ld)
 32: {
 34:   DS_PEP         *ctx = (DS_PEP*)ds->data;
 35:   PetscInt       i;

 38:   if (!ctx->d) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"DSPEP requires specifying the polynomial degree via DSPEPSetDegree()");
 39:   DSAllocateMat_Private(ds,DS_MAT_X);
 40:   DSAllocateMat_Private(ds,DS_MAT_Y);
 41:   for (i=0;i<=ctx->d;i++) {
 42:     DSAllocateMat_Private(ds,DSMatExtra[i]);
 43:   }
 44:   PetscFree(ds->perm);
 45:   PetscMalloc1(ld*ctx->d,&ds->perm);
 46:   PetscLogObjectMemory((PetscObject)ds,ld*ctx->d*sizeof(PetscInt));
 47:   return(0);
 48: }

 52: PetscErrorCode DSView_PEP(DS ds,PetscViewer viewer)
 53: {
 54:   PetscErrorCode    ierr;
 55:   DS_PEP            *ctx = (DS_PEP*)ds->data;
 56:   PetscViewerFormat format;
 57:   PetscInt          i;

 60:   PetscViewerGetFormat(viewer,&format);
 61:   PetscViewerASCIIPrintf(viewer,"  polynomial degree: %D\n",ctx->d);
 62:   if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) return(0);
 63:   for (i=0;i<=ctx->d;i++) {
 64:     DSViewMat(ds,viewer,DSMatExtra[i]);
 65:   }
 66:   if (ds->state>DS_STATE_INTERMEDIATE) {
 67:     ds->m = ctx->d*ds->n;  /* temporarily set number of columns */
 68:     DSViewMat(ds,viewer,DS_MAT_X);
 69:     ds->m = 0;
 70:   }
 71:   return(0);
 72: }

 76: PetscErrorCode DSVectors_PEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
 77: {
 79:   if (rnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
 80:   switch (mat) {
 81:     case DS_MAT_X:
 82:       break;
 83:     case DS_MAT_Y:
 84:       break;
 85:     default:
 86:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
 87:   }
 88:   return(0);
 89: }

 93: PetscErrorCode DSNormalize_PEP(DS ds,DSMatType mat,PetscInt col)
 94: {
 96:   switch (mat) {
 97:     case DS_MAT_X:
 98:       break;
 99:     case DS_MAT_Y:
100:       break;
101:     default:
102:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
103:   }
104:   return(0);
105: }

109: PetscErrorCode DSSort_PEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *kout)
110: {
112:   DS_PEP         *ctx = (DS_PEP*)ds->data;
113:   PetscInt       n,i,j,k,p,*perm,told,ld;
114:   PetscScalar    *A,*X,*Y,rtmp,rtmp2;

117:   if (!ds->sc) return(0);
118:   n = ds->n*ctx->d;
119:   A  = ds->mat[DS_MAT_A];
120:   perm = ds->perm;
121:   for (i=0;i<n;i++) perm[i] = i;
122:   told = ds->t;
123:   ds->t = n;  /* force the sorting routines to consider d*n eigenvalues */
124:   if (rr) {
125:     DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);
126:   } else {
127:     DSSortEigenvalues_Private(ds,wr,wi,perm,PETSC_FALSE);
128:   }
129:   ds->t = told;  /* restore value of t */
130:   for (i=0;i<n;i++) A[i]  = wr[perm[i]];
131:   for (i=0;i<n;i++) wr[i] = A[i];
132:   for (i=0;i<n;i++) A[i]  = wi[perm[i]];
133:   for (i=0;i<n;i++) wi[i] = A[i];
134:   /* cannot use DSPermuteColumns_Private() since matrix is not square */
135:   ld = ds->ld;
136:   X  = ds->mat[DS_MAT_X];
137:   Y  = ds->mat[DS_MAT_Y];
138:   for (i=0;i<n;i++) {
139:     p = perm[i];
140:     if (p != i) {
141:       j = i + 1;
142:       while (perm[j] != i) j++;
143:       perm[j] = p; perm[i] = i;
144:       /* swap columns i and j */
145:       for (k=0;k<ds->n;k++) {
146:         rtmp  = X[k+p*ld]; X[k+p*ld] = X[k+i*ld]; X[k+i*ld] = rtmp;
147:         rtmp2 = Y[k+p*ld]; Y[k+p*ld] = Y[k+i*ld]; Y[k+i*ld] = rtmp2;
148:       }
149:     }
150:   }
151:   return(0);
152: }

156: PetscErrorCode DSSolve_PEP_QZ(DS ds,PetscScalar *wr,PetscScalar *wi)
157: {
158: #if defined(SLEPC_MISSING_LAPACK_GGEV)
160:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GGEV - Lapack routine is unavailable");
161: #else
163:   DS_PEP         *ctx = (DS_PEP*)ds->data;
164:   PetscInt       i,j,off;
165:   PetscScalar    *A,*B,*W,*X,*U,*Y,*E,*work,*beta,norm;
166:   PetscBLASInt   info,n,ldd,nd,lrwork=0,lwork,one=1;
167: #if defined(PETSC_USE_COMPLEX)
168:   PetscReal      *rwork;
169: #else
170:   PetscScalar    norm0;
171: #endif

174:   if (!ds->mat[DS_MAT_A]) {
175:     DSAllocateMat_Private(ds,DS_MAT_A);
176:   }
177:   if (!ds->mat[DS_MAT_B]) {
178:     DSAllocateMat_Private(ds,DS_MAT_B);
179:   }
180:   if (!ds->mat[DS_MAT_W]) {
181:     DSAllocateMat_Private(ds,DS_MAT_W);
182:   }
183:   if (!ds->mat[DS_MAT_U]) {
184:     DSAllocateMat_Private(ds,DS_MAT_U);
185:   }
186:   PetscBLASIntCast(ds->n*ctx->d,&nd);
187:   PetscBLASIntCast(ds->n,&n);
188:   PetscBLASIntCast(ds->ld*ctx->d,&ldd);
189: #if defined(PETSC_USE_COMPLEX)
190:   PetscBLASIntCast(nd+2*nd,&lwork);
191:   PetscBLASIntCast(8*nd,&lrwork);
192: #else
193:   PetscBLASIntCast(nd+8*nd,&lwork);
194: #endif
195:   DSAllocateWork_Private(ds,lwork,lrwork,0);
196:   beta = ds->work;
197:   work = ds->work + nd;
198:   lwork -= nd;
199:   A = ds->mat[DS_MAT_A];
200:   B = ds->mat[DS_MAT_B];
201:   W = ds->mat[DS_MAT_W];
202:   U = ds->mat[DS_MAT_U];
203:   X = ds->mat[DS_MAT_X];
204:   Y = ds->mat[DS_MAT_Y];
205:   E = ds->mat[DSMatExtra[ctx->d]];

207:   /* build matrices A and B of the linearization */
208:   PetscMemzero(A,ldd*ldd*sizeof(PetscScalar));
209:   for (i=0;i<nd-ds->n;i++) A[i+(i+ds->n)*ldd] = -1.0;
210:   for (i=0;i<ctx->d;i++) {
211:     off = i*ds->n*ldd+(ctx->d-1)*ds->n;
212:     for (j=0;j<ds->n;j++) {
213:       PetscMemcpy(A+off+j*ldd,ds->mat[DSMatExtra[i]]+j*ds->ld,ds->n*sizeof(PetscScalar));
214:     }
215:   }
216:   PetscMemzero(B,ldd*ldd*sizeof(PetscScalar));
217:   for (i=0;i<nd-ds->n;i++) B[i+i*ldd] = -1.0;
218:   off = (ctx->d-1)*ds->n*(ldd+1);
219:   for (j=0;j<ds->n;j++) {
220:     for (i=0;i<ds->n;i++) B[off+i+j*ldd] = -E[i+j*ds->ld];
221:   }

223:   /* solve generalized eigenproblem */
224: #if defined(PETSC_USE_COMPLEX)
225:   rwork = ds->rwork;
226:   PetscStackCallBLAS("LAPACKggev",LAPACKggev_("V","V",&nd,A,&ldd,B,&ldd,wr,beta,U,&ldd,W,&ldd,work,&lwork,rwork,&info));
227:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack ZGGEV %d",info);
228: #else
229:   PetscStackCallBLAS("LAPACKggev",LAPACKggev_("V","V",&nd,A,&ldd,B,&ldd,wr,wi,beta,U,&ldd,W,&ldd,work,&lwork,&info));
230:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DGGEV %d",info);
231: #endif

233:   /* copy eigenvalues */
234:   for (i=0;i<nd;i++) {
235:     if (beta[i]==0.0) wr[i] = (PetscRealPart(wr[i])>0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL;
236:     else wr[i] /= beta[i];
237: #if !defined(PETSC_USE_COMPLEX)
238:     if (beta[i]==0.0) wi[i] = 0.0;
239:     else wi[i] /= beta[i];
240: #else
241:     if (wi) wi[i] = 0.0;
242: #endif
243:   }

245:   /* copy and normalize eigenvectors */
246:   for (j=0;j<nd;j++) {
247:     PetscMemcpy(X+j*ds->ld,W+j*ldd,ds->n*sizeof(PetscScalar));
248:     PetscMemcpy(Y+j*ds->ld,U+ds->n*(ctx->d-1)+j*ldd,ds->n*sizeof(PetscScalar));
249:   }
250:   for (j=0;j<nd;j++) {
251: #if !defined(PETSC_USE_COMPLEX)
252:     if (wi[j] != 0.0) {
253:       norm = BLASnrm2_(&n,X+j*ds->ld,&one);
254:       norm0 = BLASnrm2_(&n,X+(j+1)*ds->ld,&one);
255:       norm = 1.0/SlepcAbsEigenvalue(norm,norm0);
256:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X+j*ds->ld,&one));
257:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X+(j+1)*ds->ld,&one));
258:       norm = BLASnrm2_(&n,Y+j*ds->ld,&one);
259:       norm0 = BLASnrm2_(&n,Y+(j+1)*ds->ld,&one);
260:       norm = 1.0/SlepcAbsEigenvalue(norm,norm0);
261:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,Y+j*ds->ld,&one));
262:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,Y+(j+1)*ds->ld,&one));
263:       j++;
264:     } else
265: #endif
266:     {
267:       norm = 1.0/BLASnrm2_(&n,X+j*ds->ld,&one);
268:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X+j*ds->ld,&one));
269:       norm = 1.0/BLASnrm2_(&n,Y+j*ds->ld,&one);
270:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,Y+j*ds->ld,&one));
271:     }
272:   }
273:   return(0);
274: #endif
275: }

279: static PetscErrorCode DSPEPSetDegree_PEP(DS ds,PetscInt d)
280: {
281:   DS_PEP *ctx = (DS_PEP*)ds->data;

284:   if (d<0) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The degree must be a non-negative integer");
285:   if (d>=DS_NUM_EXTRA) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Only implemented for polynomials of degree at most %D",DS_NUM_EXTRA-1);
286:   ctx->d = d;
287:   return(0);
288: }

292: /*@
293:    DSPEPSetDegree - Sets the polynomial degree for a DSPEP.

295:    Logically Collective on DS

297:    Input Parameters:
298: +  ds - the direct solver context
299: -  d  - the degree

301:    Level: intermediate

303: .seealso: DSPEPGetDegree()
304: @*/
305: PetscErrorCode DSPEPSetDegree(DS ds,PetscInt d)
306: {

312:   PetscTryMethod(ds,"DSPEPSetDegree_C",(DS,PetscInt),(ds,d));
313:   return(0);
314: }

318: static PetscErrorCode DSPEPGetDegree_PEP(DS ds,PetscInt *d)
319: {
320:   DS_PEP *ctx = (DS_PEP*)ds->data;

323:   *d = ctx->d;
324:   return(0);
325: }

329: /*@
330:    DSPEPGetDegree - Returns the polynomial degree for a DSPEP.

332:    Not collective

334:    Input Parameter:
335: .  ds - the direct solver context

337:    Output Parameters:
338: .  d - the degree

340:    Level: intermediate

342: .seealso: DSPEPSetDegree()
343: @*/
344: PetscErrorCode DSPEPGetDegree(DS ds,PetscInt *d)
345: {

351:   PetscUseMethod(ds,"DSPEPGetDegree_C",(DS,PetscInt*),(ds,d));
352:   return(0);
353: }

357: PetscErrorCode DSDestroy_PEP(DS ds)
358: {

362:   PetscFree(ds->data);
363:   PetscObjectComposeFunction((PetscObject)ds,"DSPEPSetDegree_C",NULL);
364:   PetscObjectComposeFunction((PetscObject)ds,"DSPEPGetDegree_C",NULL);
365:   return(0);
366: }

370: PETSC_EXTERN PetscErrorCode DSCreate_PEP(DS ds)
371: {
372:   DS_PEP         *ctx;

376:   PetscNewLog(ds,&ctx);
377:   ds->data = (void*)ctx;

379:   ds->ops->allocate      = DSAllocate_PEP;
380:   ds->ops->view          = DSView_PEP;
381:   ds->ops->vectors       = DSVectors_PEP;
382:   ds->ops->solve[0]      = DSSolve_PEP_QZ;
383:   ds->ops->sort          = DSSort_PEP;
384:   ds->ops->normalize     = DSNormalize_PEP;
385:   ds->ops->destroy       = DSDestroy_PEP;
386:   PetscObjectComposeFunction((PetscObject)ds,"DSPEPSetDegree_C",DSPEPSetDegree_PEP);
387:   PetscObjectComposeFunction((PetscObject)ds,"DSPEPGetDegree_C",DSPEPGetDegree_PEP);
388:   return(0);
389: }

slepc-3.7.4/src/sys/classes/ds/impls/pep/makefile.html0000644000175000017500000000470113107004621022210 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dspep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/pep/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/pep/dspep.c0000644000175000017500000003007413107004621021026 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcds.h" I*/ #include typedef struct { PetscInt d; /* polynomial degree */ } DS_PEP; #undef __FUNCT__ #define __FUNCT__ "DSAllocate_PEP" PetscErrorCode DSAllocate_PEP(DS ds,PetscInt ld) { PetscErrorCode ierr; DS_PEP *ctx = (DS_PEP*)ds->data; PetscInt i; PetscFunctionBegin; if (!ctx->d) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"DSPEP requires specifying the polynomial degree via DSPEPSetDegree()"); ierr = DSAllocateMat_Private(ds,DS_MAT_X);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_Y);CHKERRQ(ierr); for (i=0;i<=ctx->d;i++) { ierr = DSAllocateMat_Private(ds,DSMatExtra[i]);CHKERRQ(ierr); } ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld*ctx->d,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*ctx->d*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView_PEP" PetscErrorCode DSView_PEP(DS ds,PetscViewer viewer) { PetscErrorCode ierr; DS_PEP *ctx = (DS_PEP*)ds->data; PetscViewerFormat format; PetscInt i; PetscFunctionBegin; ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," polynomial degree: %D\n",ctx->d);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) PetscFunctionReturn(0); for (i=0;i<=ctx->d;i++) { ierr = DSViewMat(ds,viewer,DSMatExtra[i]);CHKERRQ(ierr); } if (ds->state>DS_STATE_INTERMEDIATE) { ds->m = ctx->d*ds->n; /* temporarily set number of columns */ ierr = DSViewMat(ds,viewer,DS_MAT_X);CHKERRQ(ierr); ds->m = 0; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_PEP" PetscErrorCode DSVectors_PEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm) { PetscFunctionBegin; if (rnorm) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); switch (mat) { case DS_MAT_X: break; case DS_MAT_Y: break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNormalize_PEP" PetscErrorCode DSNormalize_PEP(DS ds,DSMatType mat,PetscInt col) { PetscFunctionBegin; switch (mat) { case DS_MAT_X: break; case DS_MAT_Y: break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSort_PEP" PetscErrorCode DSSort_PEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *kout) { PetscErrorCode ierr; DS_PEP *ctx = (DS_PEP*)ds->data; PetscInt n,i,j,k,p,*perm,told,ld; PetscScalar *A,*X,*Y,rtmp,rtmp2; PetscFunctionBegin; if (!ds->sc) PetscFunctionReturn(0); n = ds->n*ctx->d; A = ds->mat[DS_MAT_A]; perm = ds->perm; for (i=0;it; ds->t = n; /* force the sorting routines to consider d*n eigenvalues */ if (rr) { ierr = DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = DSSortEigenvalues_Private(ds,wr,wi,perm,PETSC_FALSE);CHKERRQ(ierr); } ds->t = told; /* restore value of t */ for (i=0;ild; X = ds->mat[DS_MAT_X]; Y = ds->mat[DS_MAT_Y]; for (i=0;in;k++) { rtmp = X[k+p*ld]; X[k+p*ld] = X[k+i*ld]; X[k+i*ld] = rtmp; rtmp2 = Y[k+p*ld]; Y[k+p*ld] = Y[k+i*ld]; Y[k+i*ld] = rtmp2; } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSolve_PEP_QZ" PetscErrorCode DSSolve_PEP_QZ(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(SLEPC_MISSING_LAPACK_GGEV) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GGEV - Lapack routine is unavailable"); #else PetscErrorCode ierr; DS_PEP *ctx = (DS_PEP*)ds->data; PetscInt i,j,off; PetscScalar *A,*B,*W,*X,*U,*Y,*E,*work,*beta,norm; PetscBLASInt info,n,ldd,nd,lrwork=0,lwork,one=1; #if defined(PETSC_USE_COMPLEX) PetscReal *rwork; #else PetscScalar norm0; #endif PetscFunctionBegin; if (!ds->mat[DS_MAT_A]) { ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); } if (!ds->mat[DS_MAT_B]) { ierr = DSAllocateMat_Private(ds,DS_MAT_B);CHKERRQ(ierr); } if (!ds->mat[DS_MAT_W]) { ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); } if (!ds->mat[DS_MAT_U]) { ierr = DSAllocateMat_Private(ds,DS_MAT_U);CHKERRQ(ierr); } ierr = PetscBLASIntCast(ds->n*ctx->d,&nd);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld*ctx->d,&ldd);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscBLASIntCast(nd+2*nd,&lwork);CHKERRQ(ierr); ierr = PetscBLASIntCast(8*nd,&lrwork);CHKERRQ(ierr); #else ierr = PetscBLASIntCast(nd+8*nd,&lwork);CHKERRQ(ierr); #endif ierr = DSAllocateWork_Private(ds,lwork,lrwork,0);CHKERRQ(ierr); beta = ds->work; work = ds->work + nd; lwork -= nd; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; W = ds->mat[DS_MAT_W]; U = ds->mat[DS_MAT_U]; X = ds->mat[DS_MAT_X]; Y = ds->mat[DS_MAT_Y]; E = ds->mat[DSMatExtra[ctx->d]]; /* build matrices A and B of the linearization */ ierr = PetscMemzero(A,ldd*ldd*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;in;i++) A[i+(i+ds->n)*ldd] = -1.0; for (i=0;id;i++) { off = i*ds->n*ldd+(ctx->d-1)*ds->n; for (j=0;jn;j++) { ierr = PetscMemcpy(A+off+j*ldd,ds->mat[DSMatExtra[i]]+j*ds->ld,ds->n*sizeof(PetscScalar));CHKERRQ(ierr); } } ierr = PetscMemzero(B,ldd*ldd*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;in;i++) B[i+i*ldd] = -1.0; off = (ctx->d-1)*ds->n*(ldd+1); for (j=0;jn;j++) { for (i=0;in;i++) B[off+i+j*ldd] = -E[i+j*ds->ld]; } /* solve generalized eigenproblem */ #if defined(PETSC_USE_COMPLEX) rwork = ds->rwork; PetscStackCallBLAS("LAPACKggev",LAPACKggev_("V","V",&nd,A,&ldd,B,&ldd,wr,beta,U,&ldd,W,&ldd,work,&lwork,rwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack ZGGEV %d",info); #else PetscStackCallBLAS("LAPACKggev",LAPACKggev_("V","V",&nd,A,&ldd,B,&ldd,wr,wi,beta,U,&ldd,W,&ldd,work,&lwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DGGEV %d",info); #endif /* copy eigenvalues */ for (i=0;i0.0)? PETSC_MAX_REAL: PETSC_MIN_REAL; else wr[i] /= beta[i]; #if !defined(PETSC_USE_COMPLEX) if (beta[i]==0.0) wi[i] = 0.0; else wi[i] /= beta[i]; #else if (wi) wi[i] = 0.0; #endif } /* copy and normalize eigenvectors */ for (j=0;jld,W+j*ldd,ds->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMemcpy(Y+j*ds->ld,U+ds->n*(ctx->d-1)+j*ldd,ds->n*sizeof(PetscScalar));CHKERRQ(ierr); } for (j=0;jld,&one); norm0 = BLASnrm2_(&n,X+(j+1)*ds->ld,&one); norm = 1.0/SlepcAbsEigenvalue(norm,norm0); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X+j*ds->ld,&one)); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X+(j+1)*ds->ld,&one)); norm = BLASnrm2_(&n,Y+j*ds->ld,&one); norm0 = BLASnrm2_(&n,Y+(j+1)*ds->ld,&one); norm = 1.0/SlepcAbsEigenvalue(norm,norm0); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,Y+j*ds->ld,&one)); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,Y+(j+1)*ds->ld,&one)); j++; } else #endif { norm = 1.0/BLASnrm2_(&n,X+j*ds->ld,&one); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,X+j*ds->ld,&one)); norm = 1.0/BLASnrm2_(&n,Y+j*ds->ld,&one); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,Y+j*ds->ld,&one)); } } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSPEPSetDegree_PEP" static PetscErrorCode DSPEPSetDegree_PEP(DS ds,PetscInt d) { DS_PEP *ctx = (DS_PEP*)ds->data; PetscFunctionBegin; if (d<0) SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"The degree must be a non-negative integer"); if (d>=DS_NUM_EXTRA) SETERRQ1(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Only implemented for polynomials of degree at most %D",DS_NUM_EXTRA-1); ctx->d = d; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSPEPSetDegree" /*@ DSPEPSetDegree - Sets the polynomial degree for a DSPEP. Logically Collective on DS Input Parameters: + ds - the direct solver context - d - the degree Level: intermediate .seealso: DSPEPGetDegree() @*/ PetscErrorCode DSPEPSetDegree(DS ds,PetscInt d) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidLogicalCollectiveInt(ds,d,2); ierr = PetscTryMethod(ds,"DSPEPSetDegree_C",(DS,PetscInt),(ds,d));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSPEPGetDegree_PEP" static PetscErrorCode DSPEPGetDegree_PEP(DS ds,PetscInt *d) { DS_PEP *ctx = (DS_PEP*)ds->data; PetscFunctionBegin; *d = ctx->d; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSPEPGetDegree" /*@ DSPEPGetDegree - Returns the polynomial degree for a DSPEP. Not collective Input Parameter: . ds - the direct solver context Output Parameters: . d - the degree Level: intermediate .seealso: DSPEPSetDegree() @*/ PetscErrorCode DSPEPGetDegree(DS ds,PetscInt *d) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ds,DS_CLASSID,1); PetscValidPointer(d,2); ierr = PetscUseMethod(ds,"DSPEPGetDegree_C",(DS,PetscInt*),(ds,d));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSDestroy_PEP" PetscErrorCode DSDestroy_PEP(DS ds) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(ds->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSPEPSetDegree_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSPEPGetDegree_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCreate_PEP" PETSC_EXTERN PetscErrorCode DSCreate_PEP(DS ds) { DS_PEP *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(ds,&ctx);CHKERRQ(ierr); ds->data = (void*)ctx; ds->ops->allocate = DSAllocate_PEP; ds->ops->view = DSView_PEP; ds->ops->vectors = DSVectors_PEP; ds->ops->solve[0] = DSSolve_PEP_QZ; ds->ops->sort = DSSort_PEP; ds->ops->normalize = DSNormalize_PEP; ds->ops->destroy = DSDestroy_PEP; ierr = PetscObjectComposeFunction((PetscObject)ds,"DSPEPSetDegree_C",DSPEPSetDegree_PEP);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)ds,"DSPEPGetDegree_C",DSPEPGetDegree_PEP);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/pep/index.html0000644000175000017500000000215613107004621021544 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dspep.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/pep/ftn-auto/0000755000175000017500000000000013107004621021300 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/pep/ftn-auto/makefile0000644000175000017500000000037013107004621023000 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = dspepf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/ds/impls/pep/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/pep/ftn-auto/dspepf.c0000644000175000017500000000260713107004621022732 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* dspep.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcds.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define dspepsetdegree_ DSPEPSETDEGREE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dspepsetdegree_ dspepsetdegree #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define dspepgetdegree_ DSPEPGETDEGREE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define dspepgetdegree_ dspepgetdegree #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL dspepsetdegree_(DS ds,PetscInt *d, int *__ierr ){ *__ierr = DSPEPSetDegree( (DS)PetscToPointer((ds) ),*d); } PETSC_EXTERN void PETSC_STDCALL dspepgetdegree_(DS ds,PetscInt *d, int *__ierr ){ *__ierr = DSPEPGetDegree( (DS)PetscToPointer((ds) ),d); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/ds/impls/ghiep/0000755000175000017500000000000013107004621020053 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/ghiep/makefile0000644000175000017500000000221213107004621021550 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dsghiep.c invit.c hz.c dqds.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/ghiep/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/ghiep/hz.c.html0000644000175000017500000006342213107004621021612 0ustar jromanjroman

Actual source code: hz.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    HZ iteration for generalized symmetric-indefinite eigenproblem.
  3:    Based on Matlab code from David Watkins.

  5:    References:

  7:        [1] D.S. Watkins, The Matrix Eigenvalue Problem: GR and Krylov Subspace
  8:            Methods, SIAM, 2007.

 10:        [2] M.A. Brebner, J. Grad, "Eigenvalues of Ax = lambda Bx for real
 11:            symmetric matrices A and B computed by reduction to pseudosymmetric
 12:            form and the HR process", Linear Alg. Appl. 43:99-118, 1982.

 14:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 15:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 16:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 18:    This file is part of SLEPc.

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

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

 29:    You  should have received a copy of the GNU Lesser General  Public  License
 30:    along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 31:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 32: */
 33: #include <slepc/private/dsimpl.h>
 34: #include <slepcblaslapack.h>

 38: /*
 39:    Sets up a 2-by-2 matrix to eliminate y in the vector [x y]'.
 40:    Transformation is rotator if sygn = 1 and hyperbolic if sygn = -1.
 41: */
 42: static PetscErrorCode UnifiedRotation(PetscReal x,PetscReal y,PetscReal sygn,PetscReal *rot,PetscReal *rcond,PetscBool *swap)
 43: {
 44:   PetscReal nrm,c,s;

 47:   *swap = PETSC_FALSE;
 48:   if (y == 0) {
 49:     rot[0] = 1.0; rot[1] = 0.0; rot[2] = 0.0; rot[3] = 1.0;
 50:     *rcond = 1.0;
 51:   } else {
 52:     nrm = PetscMax(PetscAbs(x),PetscAbs(y));
 53:     c = x/nrm; s = y/nrm;
 54:     if (sygn == 1.0) {  /* set up a rotator */
 55:       nrm = PetscSqrtReal(c*c+s*s);
 56:       c = c/nrm; s = s/nrm;
 57:       /* rot = [c s; -s c]; */
 58:       rot[0] = c; rot[1] = -s; rot[2] = s; rot[3] = c;
 59:       *rcond = 1.0;
 60:     } else if (sygn == -1) {  /* set up a hyperbolic transformation */
 61:       nrm = c*c-s*s;
 62:       if (nrm > 0) nrm = PetscSqrtReal(nrm);
 63:       else if (nrm < 0) {
 64:         nrm = PetscSqrtReal(-nrm);
 65:         *swap = PETSC_TRUE;
 66:       } else   /* breakdown */
 67:         SETERRQ(PETSC_COMM_SELF,1,"Breakdown in construction of hyperbolic transformation");
 68:       c = c/nrm; s = s/nrm;
 69:       /* rot = [c -s; -s c]; */
 70:       rot[0] = c; rot[1] = -s; rot[2] = -s; rot[3] = c;
 71:       *rcond = PetscAbs(PetscAbs(s)-PetscAbs(c))/(PetscAbs(s)+PetscAbs(c));
 72:     } else SETERRQ(PETSC_COMM_SELF,1,"Value of sygn sent to transetup must be 1 or -1");
 73:   }
 74:   return(0);
 75: }

 79: static PetscErrorCode HZStep(PetscBLASInt ntop,PetscBLASInt nn,PetscReal tr,PetscReal dt,PetscReal *aa,PetscReal *bb,PetscReal *dd,PetscScalar *uu,PetscInt n,PetscInt ld,PetscBool *flag)
 80: {
 82:   PetscBLASInt   one=1;
 83:   PetscInt       k,jj,ii;
 84:   PetscBLASInt   n_;
 85:   PetscReal      bulge10,bulge20,bulge30,bulge31,bulge41,bulge42;
 86:   PetscReal      sygn,rcond=1.0,worstcond,rot[4],buf[2],t;
 87:   PetscScalar    rtmp;
 88:   PetscBool      swap;

 91:   worstcond = 1.0;
 92:   PetscBLASIntCast(n,&n_);

 94:   /* Build initial bulge that sets step in motion */
 95:   bulge10 = dd[ntop+1]*(aa[ntop]*(aa[ntop] - dd[ntop]*tr) + dt*dd[ntop]*dd[ntop]) + dd[ntop]*bb[ntop]*bb[ntop];
 96:   bulge20 = bb[ntop]*(dd[ntop+1]*aa[ntop] + dd[ntop]*aa[ntop+1] - dd[ntop]*dd[ntop+1]*tr);
 97:   bulge30 = bb[ntop]*bb[ntop+1]*dd[ntop];
 98:   bulge31 = 0.0;
 99:   bulge41 = 0.0;
100:   bulge42 = 0.0;

102:   /* Chase the bulge */
103:   for (jj=ntop;jj<nn-1;jj++) {

105:     /* Check for trivial bulge */
106:     if (jj>ntop && PetscMax(PetscMax(PetscAbs(bulge10),PetscAbs(bulge20)),PetscAbs(bulge30))<PETSC_MACHINE_EPSILON*(PetscAbs(aa[jj]) + PetscAbs(aa[jj+1]))) {
107:       bb[jj-1] = 0.0;  /* deflate and move on */

109:     } else { /* carry out the step */

111:       /* Annihilate tip entry bulge30 */
112:       if (bulge30 != 0.0) {

114:         /* Make an interchange if necessary to ensure that the
115:            first transformation is othogonal, not hyperbolic.  */
116:         if (dd[jj+1] != dd[jj+2]) { /* make an interchange */
117:           if (dd[jj] != dd[jj+1]) {  /* interchange 1st and 2nd */
118:             buf[0] = bulge20; bulge20 = bulge10; bulge10 = buf[0];
119:             buf[0] = aa[jj]; aa[jj] = aa[jj+1]; aa[jj+1] = buf[0];
120:             buf[0] = bb[jj+1]; bb[jj+1] = bulge31; bulge31 = buf[0];
121:             buf[0] = dd[jj]; dd[jj] = dd[jj+1]; dd[jj+1] = buf[0];
122:             for (k=0;k<n;k++) {
123:               rtmp = uu[k+jj*ld]; uu[k+jj*ld] = uu[k+(jj+1)*ld]; uu[k+(jj+1)*ld] = rtmp;
124:             }
125:           } else {  /* interchange 1st and 3rd */
126:             buf[0] = bulge30; bulge30 = bulge10; bulge10 = buf[0];
127:             buf[0] = aa[jj]; aa[jj] = aa[jj+2]; aa[jj+2] = buf[0];
128:             buf[0] = bb[jj]; bb[jj] = bb[jj+1]; bb[jj+1] = buf[0];
129:             buf[0] = dd[jj]; dd[jj] = dd[jj+2]; dd[jj+2] = buf[0];
130:             if (jj + 2 < nn-1) {
131:               bulge41 = bb[jj+2];
132:               bb[jj+2] = 0;
133:             }
134:             for (k=0;k<n;k++) {
135:               rtmp = uu[k+jj*ld]; uu[k+jj*ld] = uu[k+(jj+2)*ld]; uu[k+(jj+2)*ld] = rtmp;
136:             }
137:           }
138:         }

140:         /* Set up transforming matrix rot. */
141:         UnifiedRotation(bulge20,bulge30,1,rot,&rcond,&swap);

143:         /* Apply transforming matrix rot to T. */
144:         bulge20 = rot[0]*bulge20 + rot[2]*bulge30;
145:         buf[0] = rot[0]*bb[jj] + rot[2]*bulge31;
146:         buf[1] = rot[1]*bb[jj] + rot[3]*bulge31;
147:         bb[jj] = buf[0];
148:         bulge31 = buf[1];
149:         buf[0] = rot[0]*rot[0]*aa[jj+1] + 2.0*rot[0]*rot[2]*bb[jj+1] + rot[2]*rot[2]*aa[jj+2];
150:         buf[1] = rot[1]*rot[1]*aa[jj+1] + 2.0*rot[3]*rot[1]*bb[jj+1] + rot[3]*rot[3]*aa[jj+2];
151:         bb[jj+1] = rot[1]*rot[0]*aa[jj+1] + rot[3]*rot[2]*aa[jj+2] + (rot[3]*rot[0] + rot[1]*rot[2])*bb[jj+1];
152:         aa[jj+1] = buf[0];
153:         aa[jj+2] = buf[1];
154:         if (jj + 2 < nn-1) {
155:           bulge42 = bb[jj+2]*rot[2];
156:           bb[jj+2] = bb[jj+2]*rot[3];
157:         }

159:         /* Accumulate transforming matrix */
160:         PetscStackCallBLAS("BLASrot",BLASrot_(&n_,uu+(jj+1)*ld,&one,uu+(jj+2)*ld,&one,&rot[0],&rot[2]));
161:       }

163:       /* Annihilate inner entry bulge20 */
164:       if (bulge20 != 0.0) {

166:         /* Begin by setting up transforming matrix rot */
167:         sygn = dd[jj]*dd[jj+1];
168:         UnifiedRotation(bulge10,bulge20,sygn,rot,&rcond,&swap);
169:         if (rcond<PETSC_MACHINE_EPSILON) {
170:           SETERRQ1(PETSC_COMM_SELF,0,"Transforming matrix is numerically singular rcond=%g",rcond);
171:           *flag = PETSC_TRUE;
172:           return(0);
173:         }
174:         if (rcond < worstcond) worstcond = rcond;

176:         /* Apply transforming matrix rot to T */
177:         if (jj > ntop) bb[jj-1] = rot[0]*bulge10 + rot[2]*bulge20;
178:         buf[0] = rot[0]*rot[0]*aa[jj] + 2*rot[0]*rot[2]*bb[jj] + rot[2]*rot[2]*aa[jj+1];
179:         buf[1] = rot[1]*rot[1]*aa[jj] + 2*rot[3]*rot[1]*bb[jj] + rot[3]*rot[3]*aa[jj+1];
180:         bb[jj] = rot[1]*rot[0]*aa[jj] + rot[3]*rot[2]*aa[jj+1] + (rot[3]*rot[0] + rot[1]*rot[2])*bb[jj];
181:         aa[jj] = buf[0];
182:         aa[jj+1] = buf[1];
183:         if (jj + 1 < nn-1) {
184:           /* buf = [ bulge31 bb(jj+1) ] * rot' */
185:           buf[0] = rot[0]*bulge31 + rot[2]*bb[jj+1];
186:           buf[1] = rot[1]*bulge31 + rot[3]*bb[jj+1];
187:           bulge31 = buf[0];
188:           bb[jj+1] = buf[1];
189:         }
190:         if (jj + 2 < nn-1) {
191:           /* buf = [bulge41 bulge42] * rot' */
192:           buf[0] = rot[0]*bulge41 + rot[2]*bulge42;
193:           buf[1] = rot[1]*bulge41 + rot[3]*bulge42;
194:           bulge41 = buf[0];
195:           bulge42 = buf[1];
196:         }

198:         /* Apply transforming matrix rot to D */
199:         if (swap == 1) {
200:           buf[0] = dd[jj]; dd[jj] = dd[jj+1]; dd[jj+1] = buf[0];
201:         }

203:         /* Accumulate transforming matrix, uu(jj:jj+1,:) = rot*uu(jj:jj+1,:) */
204:         if (sygn==1) {
205:           PetscStackCallBLAS("BLASrot",BLASrot_(&n_,uu+jj*ld,&one,uu+(jj+1)*ld,&one,&rot[0],&rot[2]));
206:         } else {
207:           if (PetscAbsReal(rot[0])>PetscAbsReal(rot[1])) { /* Type I */
208:             t = rot[1]/rot[0];
209:             for (ii=0;ii<n;ii++) {
210:               uu[jj*ld+ii] = rot[0]*uu[jj*ld+ii] + rot[1]*uu[(jj+1)*ld+ii];
211:               uu[(jj+1)*ld+ii] = t*uu[jj*ld+ii] + uu[(jj+1)*ld+ii]/rot[0];
212:             }
213:           } else { /* Type II */
214:             t = rot[0]/rot[1];
215:             for (ii=0;ii<n;ii++) {
216:               rtmp = uu[jj*ld+ii];
217:               uu[jj*ld+ii] = rot[0]*uu[jj*ld+ii] + rot[1]*uu[(jj+1)*ld+ii];
218:               uu[(jj+1)*ld+ii] = t*uu[jj*ld+ii] + rtmp/rot[1];
219:             }
220:           }
221:         }
222:       }
223:     }

225:     /* Adjust bulge for next step */
226:     bulge10 = bb[jj];
227:     bulge20 = bulge31;
228:     bulge30 = bulge41;
229:     bulge31 = bulge42;
230:     bulge41 = 0.0;
231:     bulge42 = 0.0;
232:   }
233:   return(0);
234: }

238: static PetscErrorCode HZIteration(PetscBLASInt nn,PetscBLASInt cgd,PetscReal *aa,PetscReal *bb,PetscReal *dd,PetscScalar *uu,PetscBLASInt ld)
239: {
241:   PetscBLASInt   j2,one=1;
242:   PetscInt       its,nits,nstop,jj,ntop,nbot,ntry;
243:   PetscReal      htr,det,dis,dif,tn,kt,c,s,tr,dt;
244:   PetscBool      flag=PETSC_FALSE;

247:   its = 0;
248:   nbot = nn-1;
249:   nits = 0;
250:   nstop = 40*(nn - cgd);

252:   while (nbot >= cgd && nits < nstop) {

254:     /* Check for zeros on the subdiagonal */
255:     jj = nbot - 1;
256:     while (jj>=cgd && PetscAbs(bb[jj])>PETSC_MACHINE_EPSILON*(PetscAbs(aa[jj])+PetscAbs(aa[jj+1]))) jj = jj-1;
257:     if (jj>=cgd) bb[jj]=0;
258:     ntop = jj + 1;  /* starting point for step */
259:     if (ntop == nbot) {  /* isolate single eigenvalue */
260:       nbot = ntop - 1;
261:       its = 0;
262:     } else if (ntop+1 == nbot) {  /* isolate pair of eigenvalues */
263:       htr = 0.5*(aa[ntop]*dd[ntop] + aa[nbot]*dd[nbot]);
264:       det = dd[ntop]*dd[nbot]*(aa[ntop]*aa[nbot]-bb[ntop]*bb[ntop]);
265:       dis = htr*htr - det;
266:       if (dis > 0) {  /* distinct real eigenvalues */
267:         if (dd[ntop] == dd[nbot]) {  /* separate the eigenvalues by a Jacobi rotator */
268:           dif = aa[ntop]-aa[nbot];
269:           if (2.0*PetscAbs(bb[ntop])<=dif) {
270:             tn = 2*bb[ntop]/dif;
271:             tn = tn/(1.0 + PetscSqrtScalar(1.0+tn*tn));
272:           } else {
273:             kt = dif/(2.0*bb[ntop]);
274:             tn = PetscSign(kt)/(PetscAbs(kt)+PetscSqrtScalar(1.0+kt*kt));
275:           }
276:           c = 1.0/PetscSqrtScalar(1.0 + tn*tn);
277:           s = c*tn;
278:           aa[ntop] = aa[ntop] + tn*bb[ntop];
279:           aa[nbot] = aa[nbot] - tn*bb[ntop];
280:           bb[ntop] = 0;
281:           j2 = nn-cgd;
282:           PetscStackCallBLAS("BLASrot",BLASrot_(&j2,uu+ntop*ld+cgd,&one,uu+nbot*ld+cgd,&one,&c,&s));
283:         }
284:       }
285:       nbot = ntop - 1;
286:     } else {  /* Do an HZ iteration */
287:       its = its + 1;
288:       nits = nits + 1;
289:       tr = aa[nbot-1]*dd[nbot-1] + aa[nbot]*dd[nbot];
290:       dt = dd[nbot-1]*dd[nbot]*(aa[nbot-1]*aa[nbot]-bb[nbot-1]*bb[nbot-1]);
291:       for (ntry=1;ntry<=6;ntry++) {
292:         HZStep(ntop,nbot+1,tr,dt,aa,bb,dd,uu,nn,ld,&flag);
293:         if (!flag) break;
294:         else if (ntry == 6) SETERRQ(PETSC_COMM_SELF,1,"Unable to complete hz step on six tries");
295:         else {
296:           tr = 0.9*tr; dt = 0.81*dt;
297:         }
298:       }
299:     }
300:   }
301:   return(0);
302: }

306: PetscErrorCode DSSolve_GHIEP_HZ(DS ds,PetscScalar *wr,PetscScalar *wi)
307: {
309:   PetscInt       off;
310:   PetscBLASInt   n1,ld;
311:   PetscScalar    *A,*B,*Q;
312:   PetscReal      *d,*e,*s;
313: #if defined(PETSC_USE_COMPLEX)
314:   PetscInt       i;
315: #endif

318: #if !defined(PETSC_USE_COMPLEX)
320: #endif
321:   PetscBLASIntCast(ds->ld,&ld);
322:   n1  = ds->n - ds->l;
323:   off = ds->l + ds->l*ld;
324:   A   = ds->mat[DS_MAT_A];
325:   B   = ds->mat[DS_MAT_B];
326:   Q   = ds->mat[DS_MAT_Q];
327:   d   = ds->rmat[DS_MAT_T];
328:   e   = ds->rmat[DS_MAT_T] + ld;
329:   s   = ds->rmat[DS_MAT_D];
330:   /* Quick return */
331:   if (n1 == 1) {
332:     *(Q+off) = 1;
333:     if (ds->compact) {
334:       wr[ds->l] = d[ds->l]/s[ds->l]; wi[ds->l] = 0.0;
335:     } else {
336:       d[ds->l] = PetscRealPart(A[off]); s[ds->l] = PetscRealPart(B[off]);
337:       wr[ds->l] = d[ds->l]/s[ds->l]; wi[ds->l] = 0.0;
338:     }
339:     return(0);
340:   }
341:   /* Reduce to pseudotriadiagonal form */
342:   DSIntermediate_GHIEP(ds);
343:   HZIteration(ds->n,ds->l,d,e,s,Q,ld);
344:   if (!ds->compact) {
345:     DSSwitchFormat_GHIEP(ds,PETSC_FALSE);
346:   }
347:   /* Undo from diagonal the blocks whith real eigenvalues*/
348:   DSGHIEPRealBlocks(ds);

350:   /* Recover eigenvalues from diagonal */
351:   DSGHIEPComplexEigs(ds,0,ds->n,wr,wi);
352: #if defined(PETSC_USE_COMPLEX)
353:   if (wi) {
354:     for (i=ds->l;i<ds->n;i++) wi[i] = 0.0;
355:   }
356: #endif
357:   ds->t = ds->n;
358:   return(0);
359: }

slepc-3.7.4/src/sys/classes/ds/impls/ghiep/makefile.html0000644000175000017500000000473513107004621022527 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dsghiep.c invit.c hz.c dqds.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/ghiep/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/ghiep/dsghiep.c.html0000644000175000017500000021512513107004621022613 0ustar jromanjroman
Actual source code: dsghiep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: #include <slepc/private/dsimpl.h>
 22: #include <slepcblaslapack.h>

 26: PetscErrorCode DSAllocate_GHIEP(DS ds,PetscInt ld)
 27: {

 31:   DSAllocateMat_Private(ds,DS_MAT_A);
 32:   DSAllocateMat_Private(ds,DS_MAT_B);
 33:   DSAllocateMat_Private(ds,DS_MAT_Q);
 34:   DSAllocateMatReal_Private(ds,DS_MAT_T);
 35:   DSAllocateMatReal_Private(ds,DS_MAT_D);
 36:   PetscFree(ds->perm);
 37:   PetscMalloc1(ld,&ds->perm);
 38:   PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));
 39:   return(0);
 40: }

 44: PetscErrorCode DSSwitchFormat_GHIEP(DS ds,PetscBool tocompact)
 45: {
 47:   PetscReal      *T,*S;
 48:   PetscScalar    *A,*B;
 49:   PetscInt       i,n,ld;

 52:   A = ds->mat[DS_MAT_A];
 53:   B = ds->mat[DS_MAT_B];
 54:   T = ds->rmat[DS_MAT_T];
 55:   S = ds->rmat[DS_MAT_D];
 56:   n = ds->n;
 57:   ld = ds->ld;
 58:   if (tocompact) { /* switch from dense (arrow) to compact storage */
 59:     PetscMemzero(T,3*ld*sizeof(PetscReal));
 60:     PetscMemzero(S,ld*sizeof(PetscReal));
 61:     for (i=0;i<n-1;i++) {
 62:       T[i] = PetscRealPart(A[i+i*ld]);
 63:       T[ld+i] = PetscRealPart(A[i+1+i*ld]);
 64:       S[i] = PetscRealPart(B[i+i*ld]);
 65:     }
 66:     T[n-1] = PetscRealPart(A[n-1+(n-1)*ld]);
 67:     S[n-1] = PetscRealPart(B[n-1+(n-1)*ld]);
 68:     for (i=ds->l;i< ds->k;i++) T[2*ld+i] = PetscRealPart(A[ds->k+i*ld]);
 69:   } else { /* switch from compact (arrow) to dense storage */
 70:     PetscMemzero(A,ld*ld*sizeof(PetscScalar));
 71:     PetscMemzero(B,ld*ld*sizeof(PetscScalar));
 72:     for (i=0;i<n-1;i++) {
 73:       A[i+i*ld] = T[i];
 74:       A[i+1+i*ld] = T[ld+i];
 75:       A[i+(i+1)*ld] = T[ld+i];
 76:       B[i+i*ld] = S[i];
 77:     }
 78:     A[n-1+(n-1)*ld] = T[n-1];
 79:     B[n-1+(n-1)*ld] = S[n-1];
 80:     for (i=ds->l;i<ds->k;i++) {
 81:       A[ds->k+i*ld] = T[2*ld+i];
 82:       A[i+ds->k*ld] = T[2*ld+i];
 83:     }
 84:   }
 85:   return(0);
 86: }

 90: PetscErrorCode DSView_GHIEP(DS ds,PetscViewer viewer)
 91: {
 92:   PetscErrorCode    ierr;
 93:   PetscViewerFormat format;
 94:   PetscInt          i,j;
 95:   PetscReal         value;
 96:   const char        *methodname[] = {
 97:                      "HR method",
 98:                      "QR + Inverse Iteration",
 99:                      "QR",
100:                      "DQDS + Inverse Iteration "
101:   };
102:   const int         nmeth=sizeof(methodname)/sizeof(methodname[0]);

105:   PetscViewerGetFormat(viewer,&format);
106:   if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
107:     if (ds->method>=nmeth) {
108:       PetscViewerASCIIPrintf(viewer,"solving the problem with: INVALID METHOD\n");
109:     } else {
110:       PetscViewerASCIIPrintf(viewer,"solving the problem with: %s\n",methodname[ds->method]);
111:     }
112:     return(0);
113:   }
114:   if (ds->compact) {
115:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
116:     if (format == PETSC_VIEWER_ASCII_MATLAB) {
117:       PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",ds->n,ds->n);
118:       PetscViewerASCIIPrintf(viewer,"zzz = zeros(%D,3);\n",3*ds->n);
119:       PetscViewerASCIIPrintf(viewer,"zzz = [\n");
120:       for (i=0;i<ds->n;i++) {
121:         PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_T]+i));
122:       }
123:       for (i=0;i<ds->n-1;i++) {
124:         if (*(ds->rmat[DS_MAT_T]+ds->ld+i) !=0 && i!=ds->k-1) {
125:           PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",i+2,i+1,*(ds->rmat[DS_MAT_T]+ds->ld+i));
126:           PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",i+1,i+2,*(ds->rmat[DS_MAT_T]+ds->ld+i));
127:         }
128:       }
129:       for (i = ds->l;i<ds->k;i++) {
130:         if (*(ds->rmat[DS_MAT_T]+2*ds->ld+i)) {
131:           PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",ds->k+1,i+1,*(ds->rmat[DS_MAT_T]+2*ds->ld+i));
132:           PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",i+1,ds->k+1,*(ds->rmat[DS_MAT_T]+2*ds->ld+i));
133:         }
134:       }
135:       PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(zzz);\n",DSMatName[DS_MAT_A]);

137:       PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",ds->n,ds->n);
138:       PetscViewerASCIIPrintf(viewer,"omega = zeros(%D,3);\n",3*ds->n);
139:       PetscViewerASCIIPrintf(viewer,"omega = [\n");
140:       for (i=0;i<ds->n;i++) {
141:         PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_D]+i));
142:       }
143:       PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(omega);\n",DSMatName[DS_MAT_B]);

145:     } else {
146:       PetscViewerASCIIPrintf(viewer,"T\n");
147:       for (i=0;i<ds->n;i++) {
148:         for (j=0;j<ds->n;j++) {
149:           if (i==j) value = *(ds->rmat[DS_MAT_T]+i);
150:           else if (i==j+1 || j==i+1) value = *(ds->rmat[DS_MAT_T]+ds->ld+PetscMin(i,j));
151:           else if ((i<ds->k && j==ds->k) || (i==ds->k && j<ds->k)) value = *(ds->rmat[DS_MAT_T]+2*ds->ld+PetscMin(i,j));
152:           else value = 0.0;
153:           PetscViewerASCIIPrintf(viewer," %18.16e ",value);
154:         }
155:         PetscViewerASCIIPrintf(viewer,"\n");
156:       }
157:       PetscViewerASCIIPrintf(viewer,"omega\n");
158:       for (i=0;i<ds->n;i++) {
159:         for (j=0;j<ds->n;j++) {
160:           if (i==j) value = *(ds->rmat[DS_MAT_D]+i);
161:           else value = 0.0;
162:           PetscViewerASCIIPrintf(viewer," %18.16e ",value);
163:         }
164:         PetscViewerASCIIPrintf(viewer,"\n");
165:       }
166:     }
167:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
168:     PetscViewerFlush(viewer);
169:   } else {
170:     DSViewMat(ds,viewer,DS_MAT_A);
171:     DSViewMat(ds,viewer,DS_MAT_B);
172:   }
173:   if (ds->state>DS_STATE_INTERMEDIATE) {
174:     DSViewMat(ds,viewer,DS_MAT_Q);
175:   }
176:   return(0);
177: }

181: static PetscErrorCode DSVectors_GHIEP_Eigen_Some(DS ds,PetscInt *idx,PetscReal *rnorm)
182: {
183: #if defined(SLEPC_MISSING_LAPACK_LAG2)
185:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAG2 - Lapack routine is unavailable");
186: #else
188:   PetscReal      b[4],M[4],d1,d2,s1,s2,e;
189:   PetscReal      scal1,scal2,wr1,wr2,wi,ep,norm;
190:   PetscScalar    *Q,*X,Y[4],alpha,zeroS = 0.0;
191:   PetscInt       k;
192:   PetscBLASInt   two = 2,n_,ld,one=1;
193: #if !defined(PETSC_USE_COMPLEX)
194:   PetscBLASInt   four=4;
195: #endif

198:   X = ds->mat[DS_MAT_X];
199:   Q = ds->mat[DS_MAT_Q];
200:   k = *idx;
201:   PetscBLASIntCast(ds->n,&n_);
202:   PetscBLASIntCast(ds->ld,&ld);
203:   if (k < ds->n-1) {
204:     e = (ds->compact)?*(ds->rmat[DS_MAT_T]+ld+k):PetscRealPart(*(ds->mat[DS_MAT_A]+(k+1)+ld*k));
205:   } else e = 0.0;
206:   if (e == 0.0) {/* Real */
207:     if (ds->state>=DS_STATE_CONDENSED) {
208:       PetscMemcpy(X+k*ld,Q+k*ld,ld*sizeof(PetscScalar));
209:     } else {
210:       PetscMemzero(X+k*ds->ld,ds->ld*sizeof(PetscScalar));
211:       X[k+k*ds->ld] = 1.0;
212:     }
213:     if (rnorm) {
214:       *rnorm = PetscAbsScalar(X[ds->n-1+k*ld]);
215:     }
216:   } else { /* 2x2 block */
217:     if (ds->compact) {
218:       s1 = *(ds->rmat[DS_MAT_D]+k);
219:       d1 = *(ds->rmat[DS_MAT_T]+k);
220:       s2 = *(ds->rmat[DS_MAT_D]+k+1);
221:       d2 = *(ds->rmat[DS_MAT_T]+k+1);
222:     } else {
223:       s1 = PetscRealPart(*(ds->mat[DS_MAT_B]+k*ld+k));
224:       d1 = PetscRealPart(*(ds->mat[DS_MAT_A]+k+k*ld));
225:       s2 = PetscRealPart(*(ds->mat[DS_MAT_B]+(k+1)*ld+k+1));
226:       d2 = PetscRealPart(*(ds->mat[DS_MAT_A]+k+1+(k+1)*ld));
227:     }
228:     M[0] = d1; M[1] = e; M[2] = e; M[3]= d2;
229:     b[0] = s1; b[1] = 0.0; b[2] = 0.0; b[3] = s2;
230:     ep = LAPACKlamch_("S");
231:     /* Compute eigenvalues of the block */
232:     PetscStackCallBLAS("LAPACKlag2",LAPACKlag2_(M,&two,b,&two,&ep,&scal1,&scal2,&wr1,&wr2,&wi));
233:     if (wi==0.0)  /* Real eigenvalues */
234:       SETERRQ(PETSC_COMM_SELF,1,"Real block in DSVectors_GHIEP");
235:     else { /* Complex eigenvalues */
236:       if (scal1<ep) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FP,"Nearly infinite eigenvalue");
237:       wr1 /= scal1; wi /= scal1;
238: #if !defined(PETSC_USE_COMPLEX)
239:       if (SlepcAbs(s1*d1-wr1,wi)<SlepcAbs(s2*d2-wr1,wi)) {
240:         Y[0] = wr1-s2*d2; Y[1] = s2*e; Y[2] = wi; Y[3] = 0.0;
241:       } else {
242:         Y[0] = s1*e; Y[1] = wr1-s1*d1; Y[2] = 0.0; Y[3] = wi;
243:       }
244:       norm = BLASnrm2_(&four,Y,&one);
245:       norm = 1/norm;
246:       if (ds->state >= DS_STATE_CONDENSED) {
247:         alpha = norm;
248:         PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n_,&two,&two,&alpha,ds->mat[DS_MAT_Q]+k*ld,&ld,Y,&two,&zeroS,X+k*ld,&ld));
249:         if (rnorm) *rnorm = SlepcAbsEigenvalue(X[ds->n-1+k*ld],X[ds->n-1+(k+1)*ld]);
250:       } else {
251:         PetscMemzero(X+k*ld,2*ld*sizeof(PetscScalar));
252:         X[k*ld+k] = Y[0]*norm; X[k*ld+k+1] = Y[1]*norm;
253:         X[(k+1)*ld+k] = Y[2]*norm; X[(k+1)*ld+k+1] = Y[3]*norm;
254:       }
255: #else
256:       if (SlepcAbs(s1*d1-wr1,wi)<SlepcAbs(s2*d2-wr1,wi)) {
257:         Y[0] = wr1-s2*d2+PETSC_i*wi; Y[1] = s2*e;
258:       } else {
259:         Y[0] = s1*e; Y[1] = wr1-s1*d1+PETSC_i*wi;
260:       }
261:       norm = BLASnrm2_(&two,Y,&one);
262:       norm = 1/norm;
263:       if (ds->state >= DS_STATE_CONDENSED) {
264:         alpha = norm;
265:         PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&two,&alpha,ds->mat[DS_MAT_Q]+k*ld,&ld,Y,&one,&zeroS,X+k*ld,&one));
266:         if (rnorm) *rnorm = PetscAbsScalar(X[ds->n-1+k*ld]);
267:       } else {
268:         PetscMemzero(X+k*ld,2*ld*sizeof(PetscScalar));
269:         X[k*ld+k] = Y[0]*norm; X[k*ld+k+1] = Y[1]*norm;
270:       }
271:       X[(k+1)*ld+k] = PetscConj(X[k*ld+k]); X[(k+1)*ld+k+1] = PetscConj(X[k*ld+k+1]);
272: #endif
273:       (*idx)++;
274:     }
275:   }
276:   return(0);
277: #endif
278: }

282: PetscErrorCode DSVectors_GHIEP(DS ds,DSMatType mat,PetscInt *k,PetscReal *rnorm)
283: {
284:   PetscInt       i;
285:   PetscReal      e;

289:   switch (mat) {
290:     case DS_MAT_X:
291:     case DS_MAT_Y:
292:       if (k) {
293:         DSVectors_GHIEP_Eigen_Some(ds,k,rnorm);
294:       } else {
295:         for (i=0; i<ds->n; i++) {
296:           e = (ds->compact)?*(ds->rmat[DS_MAT_T]+ds->ld+i):PetscRealPart(*(ds->mat[DS_MAT_A]+(i+1)+ds->ld*i));
297:           if (e == 0.0) {/* real */
298:             if (ds->state >= DS_STATE_CONDENSED) {
299:               PetscMemcpy(ds->mat[mat]+i*ds->ld,ds->mat[DS_MAT_Q]+i*ds->ld,ds->ld*sizeof(PetscScalar));
300:             } else {
301:               PetscMemzero(ds->mat[mat]+i*ds->ld,ds->ld*sizeof(PetscScalar));
302:               *(ds->mat[mat]+i+i*ds->ld) = 1.0;
303:             }
304:           } else {
305:             DSVectors_GHIEP_Eigen_Some(ds,&i,rnorm);
306:           }
307:         }
308:       }
309:       break;
310:     case DS_MAT_U:
311:     case DS_MAT_VT:
312:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
313:       break;
314:     default:
315:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
316:   }
317:   return(0);
318: }

322: /*
323:   Extract the eigenvalues contained in the block-diagonal of the indefinite problem.
324:   Only the index range n0..n1 is processed.
325: */
326: PetscErrorCode DSGHIEPComplexEigs(DS ds,PetscInt n0,PetscInt n1,PetscScalar *wr,PetscScalar *wi)
327: {
328: #if defined(SLEPC_MISSING_LAPACK_LAG2)
330:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAG2 - Lapack routine is unavailable");
331: #else
332:   PetscInt     k,ld;
333:   PetscBLASInt two=2;
334:   PetscScalar  *A,*B;
335:   PetscReal    *D,*T;
336:   PetscReal    b[4],M[4],d1,d2,s1,s2,e;
337:   PetscReal    scal1,scal2,ep,wr1,wr2,wi1;

340:   ld = ds->ld;
341:   A = ds->mat[DS_MAT_A];
342:   B = ds->mat[DS_MAT_B];
343:   D = ds->rmat[DS_MAT_D];
344:   T = ds->rmat[DS_MAT_T];
345:   for (k=n0;k<n1;k++) {
346:     if (k < n1-1) {
347:       e = (ds->compact)?T[ld+k]:PetscRealPart(A[(k+1)+ld*k]);
348:     } else {
349:       e = 0.0;
350:     }
351:     if (e==0.0) {
352:       /* real eigenvalue */
353:       wr[k] = (ds->compact)?T[k]/D[k]:A[k+k*ld]/B[k+k*ld];
354: #if !defined(PETSC_USE_COMPLEX)
355:       wi[k] = 0.0 ;
356: #endif
357:     } else {
358:       /* diagonal block */
359:       if (ds->compact) {
360:         s1 = D[k];
361:         d1 = T[k];
362:         s2 = D[k+1];
363:         d2 = T[k+1];
364:       } else {
365:         s1 = PetscRealPart(B[k*ld+k]);
366:         d1 = PetscRealPart(A[k+k*ld]);
367:         s2 = PetscRealPart(B[(k+1)*ld+k+1]);
368:         d2 = PetscRealPart(A[k+1+(k+1)*ld]);
369:       }
370:       M[0] = d1; M[1] = e; M[2] = e; M[3]= d2;
371:       b[0] = s1; b[1] = 0.0; b[2] = 0.0; b[3] = s2;
372:       ep = LAPACKlamch_("S");
373:       /* Compute eigenvalues of the block */
374:       PetscStackCallBLAS("LAPACKlag2",LAPACKlag2_(M,&two,b,&two,&ep,&scal1,&scal2,&wr1,&wr2,&wi1));
375:       if (scal1<ep) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FP,"Nearly infinite eigenvalue");
376:       wr[k] = wr1/scal1;
377:       if (wi1==0.0) { /* Real eigenvalues */
378:         if (scal2<ep) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FP,"Nearly infinite eigenvalue");
379:         wr[k+1] = wr2/scal2;
380: #if !defined(PETSC_USE_COMPLEX)
381:         wi[k] = 0.0;
382:         wi[k+1] = 0.0;
383: #endif
384:       } else { /* Complex eigenvalues */
385: #if !defined(PETSC_USE_COMPLEX)
386:         wr[k+1] = wr[k];
387:         wi[k] = wi1/scal1;
388:         wi[k+1] = -wi[k];
389: #else
390:         wr[k] += PETSC_i*wi1/scal1;
391:         wr[k+1] = PetscConj(wr[k]);
392: #endif
393:       }
394:       k++;
395:     }
396:   }
397: #if defined(PETSC_USE_COMPLEX)
398:   if (wi) {
399:     for (k=n0;k<n1;k++) wi[k] = 0.0;
400:   }
401: #endif
402:   return(0);
403: #endif
404: }

408: PetscErrorCode DSSort_GHIEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
409: {
411:   PetscInt       n,i,*perm;
412:   PetscReal      *d,*e,*s;

415: #if !defined(PETSC_USE_COMPLEX)
417: #endif
418:   n = ds->n;
419:   d = ds->rmat[DS_MAT_T];
420:   e = d + ds->ld;
421:   s = ds->rmat[DS_MAT_D];
422:   DSAllocateWork_Private(ds,ds->ld,ds->ld,0);
423:   perm = ds->perm;
424:   if (!rr) {
425:     rr = wr;
426:     ri = wi;
427:   }
428:   DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_TRUE);
429:   if (!ds->compact) { DSSwitchFormat_GHIEP(ds,PETSC_TRUE); }
430:   PetscMemcpy(ds->work,wr,n*sizeof(PetscScalar));
431:   for (i=ds->l;i<n;i++) wr[i] = *(ds->work+perm[i]);
432: #if !defined(PETSC_USE_COMPLEX)
433:   PetscMemcpy(ds->work,wi,n*sizeof(PetscScalar));
434:   for (i=ds->l;i<n;i++) wi[i] = *(ds->work+perm[i]);
435: #endif
436:   PetscMemcpy(ds->rwork,s,n*sizeof(PetscReal));
437:   for (i=ds->l;i<n;i++) s[i] = *(ds->rwork+perm[i]);
438:   PetscMemcpy(ds->rwork,d,n*sizeof(PetscReal));
439:   for (i=ds->l;i<n;i++) d[i] = *(ds->rwork+perm[i]);
440:   PetscMemcpy(ds->rwork,e,(n-1)*sizeof(PetscReal));
441:   PetscMemzero(e+ds->l,(n-1-ds->l)*sizeof(PetscScalar));
442:   for (i=ds->l;i<n-1;i++) {
443:     if (perm[i]<n-1) e[i] = *(ds->rwork+perm[i]);
444:   }
445:   if (!ds->compact) { DSSwitchFormat_GHIEP(ds,PETSC_FALSE); }
446:   DSPermuteColumns_Private(ds,ds->l,n,DS_MAT_Q,perm);
447:   return(0);
448: }


453: /*
454:   Get eigenvectors with inverse iteration.
455:   The system matrix is in Hessenberg form.
456: */
457: PetscErrorCode DSGHIEPInverseIteration(DS ds,PetscScalar *wr,PetscScalar *wi)
458: {
459: #if defined(SLEPC_MISSING_LAPACK_HSEIN)
461:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"HSEIN - Lapack routine is unavailable");
462: #else
464:   PetscInt       i,off;
465:   PetscBLASInt   *select,*infoC,ld,n1,mout,info;
466:   PetscScalar    *A,*B,*H,*X;
467:   PetscReal      *s,*d,*e;
468: #if defined(PETSC_USE_COMPLEX)
469:   PetscInt       j;
470: #endif

473:   PetscBLASIntCast(ds->ld,&ld);
474:   PetscBLASIntCast(ds->n-ds->l,&n1);
475:   DSAllocateWork_Private(ds,ld*ld+2*ld,ld,2*ld);
476:   DSAllocateMat_Private(ds,DS_MAT_W);
477:   A = ds->mat[DS_MAT_A];
478:   B = ds->mat[DS_MAT_B];
479:   H = ds->mat[DS_MAT_W];
480:   s = ds->rmat[DS_MAT_D];
481:   d = ds->rmat[DS_MAT_T];
482:   e = d + ld;
483:   select = ds->iwork;
484:   infoC = ds->iwork + ld;
485:   off = ds->l+ds->l*ld;
486:   if (ds->compact) {
487:     H[off] = d[ds->l]*s[ds->l];
488:     H[off+ld] = e[ds->l]*s[ds->l];
489:     for (i=ds->l+1;i<ds->n-1;i++) {
490:       H[i+(i-1)*ld] = e[i-1]*s[i];
491:       H[i+i*ld] = d[i]*s[i];
492:       H[i+(i+1)*ld] = e[i]*s[i];
493:     }
494:     H[ds->n-1+(ds->n-2)*ld] = e[ds->n-2]*s[ds->n-1];
495:     H[ds->n-1+(ds->n-1)*ld] = d[ds->n-1]*s[ds->n-1];
496:   } else {
497:     s[ds->l] = PetscRealPart(B[off]);
498:     H[off] = A[off]*s[ds->l];
499:     H[off+ld] = A[off+ld]*s[ds->l];
500:     for (i=ds->l+1;i<ds->n-1;i++) {
501:       s[i] = PetscRealPart(B[i+i*ld]);
502:       H[i+(i-1)*ld] = A[i+(i-1)*ld]*s[i];
503:       H[i+i*ld]     = A[i+i*ld]*s[i];
504:       H[i+(i+1)*ld] = A[i+(i+1)*ld]*s[i];
505:     }
506:     s[ds->n-1] = PetscRealPart(B[ds->n-1+(ds->n-1)*ld]);
507:     H[ds->n-1+(ds->n-2)*ld] = A[ds->n-1+(ds->n-2)*ld]*s[ds->n-1];
508:     H[ds->n-1+(ds->n-1)*ld] = A[ds->n-1+(ds->n-1)*ld]*s[ds->n-1];
509:   }
510:   DSAllocateMat_Private(ds,DS_MAT_X);
511:   X = ds->mat[DS_MAT_X];
512:   for (i=0;i<n1;i++) select[i] = 1;
513: #if !defined(PETSC_USE_COMPLEX)
514:   PetscStackCallBLAS("LAPACKhsein",LAPACKhsein_("R","N","N",select,&n1,H+off,&ld,wr+ds->l,wi+ds->l,NULL,&ld,X+off,&ld,&n1,&mout,ds->work,NULL,infoC,&info));
515: #else
516:   PetscStackCallBLAS("LAPACKhsein",LAPACKhsein_("R","N","N",select,&n1,H+off,&ld,wr+ds->l,NULL,&ld,X+off,&ld,&n1,&mout,ds->work,ds->rwork,NULL,infoC,&info));

518:   /* Separate real and imaginary part of complex eigenvectors */
519:   for (j=ds->l;j<ds->n;j++) {
520:     if (PetscAbsReal(PetscImaginaryPart(wr[j])) > PetscAbsScalar(wr[j])*PETSC_SQRT_MACHINE_EPSILON) {
521:       for (i=ds->l;i<ds->n;i++) {
522:         X[i+(j+1)*ds->ld] = PetscImaginaryPart(X[i+j*ds->ld]);
523:         X[i+j*ds->ld] = PetscRealPart(X[i+j*ds->ld]);
524:       }
525:       j++;
526:     }
527:   }
528: #endif
529:   if (info<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in hsein routine %D",-i);
530:   if (info>0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Convergence error in hsein routine %D",i);
531:   DSGHIEPOrthogEigenv(ds,DS_MAT_X,wr,wi,PETSC_TRUE);
532:   return(0);
533: #endif
534: }


539: /*
540:    Undo 2x2 blocks that have real eigenvalues.
541: */
542: PetscErrorCode DSGHIEPRealBlocks(DS ds)
543: {
544: #if defined(SLEPC_MISSING_LAPACK_LAG2)
546:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAG2 - Lapack routine is unavailable");
547: #else
549:   PetscInt       i;
550:   PetscReal      e,d1,d2,s1,s2,ss1,ss2,t,dd,ss;
551:   PetscReal      maxy,ep,scal1,scal2,snorm;
552:   PetscReal      *T,*D,b[4],M[4],wr1,wr2,wi;
553:   PetscScalar    *A,*B,Y[4],oneS = 1.0,zeroS = 0.0;
554:   PetscBLASInt   m,two=2,ld;
555:   PetscBool      isreal;

558:   PetscBLASIntCast(ds->ld,&ld);
559:   PetscBLASIntCast(ds->n-ds->l,&m);
560:   A = ds->mat[DS_MAT_A];
561:   B = ds->mat[DS_MAT_B];
562:   T = ds->rmat[DS_MAT_T];
563:   D = ds->rmat[DS_MAT_D];
564:   DSAllocateWork_Private(ds,2*m,0,0);
565:   for (i=ds->l;i<ds->n-1;i++) {
566:     e = (ds->compact)?T[ld+i]:PetscRealPart(A[(i+1)+ld*i]);
567:     if (e != 0.0) { /* 2x2 block */
568:       if (ds->compact) {
569:         s1 = D[i];
570:         d1 = T[i];
571:         s2 = D[i+1];
572:         d2 = T[i+1];
573:       } else {
574:         s1 = PetscRealPart(B[i*ld+i]);
575:         d1 = PetscRealPart(A[i*ld+i]);
576:         s2 = PetscRealPart(B[(i+1)*ld+i+1]);
577:         d2 = PetscRealPart(A[(i+1)*ld+i+1]);
578:       }
579:       isreal = PETSC_FALSE;
580:       if (s1==s2) { /* apply a Jacobi rotation to compute the eigendecomposition */
581:         dd = d1-d2;
582:         if (2*PetscAbsReal(e) <= dd) {
583:           t = 2*e/dd;
584:           t = t/(1 + PetscSqrtReal(1+t*t));
585:         } else {
586:           t = dd/(2*e);
587:           ss = (t>=0)?1.0:-1.0;
588:           t = ss/(PetscAbsReal(t)+PetscSqrtReal(1+t*t));
589:         }
590:         Y[0] = 1/PetscSqrtReal(1 + t*t); Y[3] = Y[0]; /* c */
591:         Y[1] = Y[0]*t; Y[2] = -Y[1]; /* s */
592:         wr1 = d1+t*e;
593:         wr2 = d2-t*e;
594:         ss1 = s1; ss2 = s2;
595:         isreal = PETSC_TRUE;
596:       } else {
597:         ss1 = 1.0; ss2 = 1.0,
598:         M[0] = d1; M[1] = e; M[2] = e; M[3]= d2;
599:         b[0] = s1; b[1] = 0.0; b[2] = 0.0; b[3] = s2;
600:         ep = LAPACKlamch_("S");

602:         /* Compute eigenvalues of the block */
603:         PetscStackCallBLAS("LAPACKlag2",LAPACKlag2_(M,&two,b,&two,&ep,&scal1,&scal2,&wr1,&wr2,&wi));
604:         if (wi==0.0) { /* Real eigenvalues */
605:           isreal = PETSC_TRUE;
606:           if (scal1<ep||scal2<ep) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FP,"Nearly infinite eigenvalue");
607:           wr1 /= scal1; wr2 /= scal2;
608:           if (PetscAbsReal(s1*d1-wr1)<PetscAbsReal(s2*d2-wr1)) {
609:             Y[0] = wr1-s2*d2;
610:             Y[1] = s2*e;
611:           } else {
612:             Y[0] = s1*e;
613:             Y[1] = wr1-s1*d1;
614:           }
615:           /* normalize with a signature*/
616:           maxy = PetscMax(PetscAbsScalar(Y[0]),PetscAbsScalar(Y[1]));
617:           scal1 = PetscRealPart(Y[0])/maxy; scal2 = PetscRealPart(Y[1])/maxy;
618:           snorm = scal1*scal1*s1 + scal2*scal2*s2;
619:           if (snorm<0) { ss1 = -1.0; snorm = -snorm; }
620:           snorm = maxy*PetscSqrtReal(snorm); Y[0] = Y[0]/snorm; Y[1] = Y[1]/snorm;
621:           if (PetscAbsReal(s1*d1-wr2)<PetscAbsReal(s2*d2-wr2)) {
622:             Y[2] = wr2-s2*d2;
623:             Y[3] = s2*e;
624:           } else {
625:             Y[2] = s1*e;
626:             Y[3] = wr2-s1*d1;
627:           }
628:           maxy = PetscMax(PetscAbsScalar(Y[2]),PetscAbsScalar(Y[3]));
629:           scal1 = PetscRealPart(Y[2])/maxy; scal2 = PetscRealPart(Y[3])/maxy;
630:           snorm = scal1*scal1*s1 + scal2*scal2*s2;
631:           if (snorm<0) { ss2 = -1.0; snorm = -snorm; }
632:           snorm = maxy*PetscSqrtReal(snorm);Y[2] = Y[2]/snorm; Y[3] = Y[3]/snorm;
633:         }
634:         wr1 *= ss1; wr2 *= ss2;
635:       }
636:       if (isreal) {
637:         if (ds->compact) {
638:           D[i] = ss1;
639:           T[i] = wr1;
640:           D[i+1] = ss2;
641:           T[i+1] = wr2;
642:           T[ld+i] = 0.0;
643:         } else {
644:           B[i*ld+i] = ss1;
645:           A[i*ld+i] = wr1;
646:           B[(i+1)*ld+i+1] = ss2;
647:           A[(i+1)*ld+i+1] = wr2;
648:           A[(i+1)+ld*i] = 0.0;
649:           A[i+ld*(i+1)] = 0.0;
650:         }
651:         PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&m,&two,&two,&oneS,ds->mat[DS_MAT_Q]+ds->l+i*ld,&ld,Y,&two,&zeroS,ds->work,&m));
652:         PetscMemcpy(ds->mat[DS_MAT_Q]+ds->l+i*ld,ds->work,m*sizeof(PetscScalar));
653:         PetscMemcpy(ds->mat[DS_MAT_Q]+ds->l+(i+1)*ld,ds->work+m,m*sizeof(PetscScalar));
654:       }
655:       i++;
656:     }
657:   }
658:   return(0);
659: #endif
660: }

664: PetscErrorCode DSSolve_GHIEP_QR_II(DS ds,PetscScalar *wr,PetscScalar *wi)
665: {
666: #if defined(PETSC_MISSING_LAPACK_HSEQR)
668:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"HSEQR - Lapack routine is unavailable");
669: #else
671:   PetscInt       i,off;
672:   PetscBLASInt   n1,ld,one,info,lwork;
673:   PetscScalar    *H,*A,*B,*Q;
674:   PetscReal      *d,*e,*s;
675: #if defined(PETSC_USE_COMPLEX)
676:   PetscInt       j;
677: #endif

680: #if !defined(PETSC_USE_COMPLEX)
682: #endif
683:   one = 1;
684:   PetscBLASIntCast(ds->n-ds->l,&n1);
685:   PetscBLASIntCast(ds->ld,&ld);
686:   off = ds->l + ds->l*ld;
687:   A = ds->mat[DS_MAT_A];
688:   B = ds->mat[DS_MAT_B];
689:   Q = ds->mat[DS_MAT_Q];
690:   d = ds->rmat[DS_MAT_T];
691:   e = ds->rmat[DS_MAT_T] + ld;
692:   s = ds->rmat[DS_MAT_D];
693:   DSAllocateWork_Private(ds,ld*ld,2*ld,ld*2);
694:   lwork = ld*ld;

696:   /* Quick return if possible */
697:   if (n1 == 1) {
698:     *(Q+off) = 1;
699:     if (!ds->compact) {
700:       d[ds->l] = PetscRealPart(A[off]);
701:       s[ds->l] = PetscRealPart(B[off]);
702:     }
703:     wr[ds->l] = d[ds->l]/s[ds->l];
704:     if (wi) wi[ds->l] = 0.0;
705:     return(0);
706:   }
707:   /* Reduce to pseudotriadiagonal form */
708:   DSIntermediate_GHIEP(ds);

710:   /* Compute Eigenvalues (QR)*/
711:   DSAllocateMat_Private(ds,DS_MAT_W);
712:   H = ds->mat[DS_MAT_W];
713:   if (ds->compact) {
714:     H[off] = d[ds->l]*s[ds->l];
715:     H[off+ld] = e[ds->l]*s[ds->l];
716:     for (i=ds->l+1;i<ds->n-1;i++) {
717:       H[i+(i-1)*ld] = e[i-1]*s[i];
718:       H[i+i*ld]     = d[i]*s[i];
719:       H[i+(i+1)*ld] = e[i]*s[i];
720:     }
721:     H[ds->n-1+(ds->n-2)*ld] = e[ds->n-2]*s[ds->n-1];
722:     H[ds->n-1+(ds->n-1)*ld] = d[ds->n-1]*s[ds->n-1];
723:   } else {
724:     s[ds->l] = PetscRealPart(B[off]);
725:     H[off] = A[off]*s[ds->l];
726:     H[off+ld] = A[off+ld]*s[ds->l];
727:     for (i=ds->l+1;i<ds->n-1;i++) {
728:       s[i] = PetscRealPart(B[i+i*ld]);
729:       H[i+(i-1)*ld] = A[i+(i-1)*ld]*s[i];
730:       H[i+i*ld]     = A[i+i*ld]*s[i];
731:       H[i+(i+1)*ld] = A[i+(i+1)*ld]*s[i];
732:     }
733:     s[ds->n-1] = PetscRealPart(B[ds->n-1+(ds->n-1)*ld]);
734:     H[ds->n-1+(ds->n-2)*ld] = A[ds->n-1+(ds->n-2)*ld]*s[ds->n-1];
735:     H[ds->n-1+(ds->n-1)*ld] = A[ds->n-1+(ds->n-1)*ld]*s[ds->n-1];
736:   }

738: #if !defined(PETSC_USE_COMPLEX)
739:   PetscStackCallBLAS("LAPACKhseqr",LAPACKhseqr_("E","N",&n1,&one,&n1,H+off,&ld,wr+ds->l,wi+ds->l,NULL,&ld,ds->work,&lwork,&info));
740: #else
741:   PetscStackCallBLAS("LAPACKhseqr",LAPACKhseqr_("E","N",&n1,&one,&n1,H+off,&ld,wr+ds->l,NULL,&ld,ds->work,&lwork,&info));

743:   /* Sort to have consecutive conjugate pairs */
744:   for (i=ds->l;i<ds->n;i++) {
745:       j=i+1;
746:       while (j<ds->n && (PetscAbsScalar(wr[i]-PetscConj(wr[j]))>PetscAbsScalar(wr[i])*PETSC_SQRT_MACHINE_EPSILON)) j++;
747:       if (j==ds->n) {
748:         if (PetscAbsReal(PetscImaginaryPart(wr[i]))<PetscAbsScalar(wr[i])*PETSC_SQRT_MACHINE_EPSILON) wr[i]=PetscRealPart(wr[i]);
749:         else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Found complex without conjugate pair");
750:       } else { /* complex eigenvalue */
751:         wr[j] = wr[i+1];
752:         if (PetscImaginaryPart(wr[i])<0) wr[i] = PetscConj(wr[i]);
753:         wr[i+1] = PetscConj(wr[i]);
754:         i++;
755:       }
756:   }
757: #endif
758:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xHSEQR %d",&info);
759:   /* Compute Eigenvectors with Inverse Iteration */
760:   DSGHIEPInverseIteration(ds,wr,wi);

762:   /* Recover eigenvalues from diagonal */
763:   DSGHIEPComplexEigs(ds,0,ds->l,wr,wi);
764: #if defined(PETSC_USE_COMPLEX)
765:   if (wi) {
766:     for (i=ds->l;i<ds->n;i++) wi[i] = 0.0;
767:   }
768: #endif
769:   return(0);
770: #endif
771: }

775: PetscErrorCode DSSolve_GHIEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi)
776: {
777: #if defined(SLEPC_MISSING_LAPACK_GEEVX)
779:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEEVX - Lapack routine is unavailable");
780: #else
782:   PetscInt       i,off,nwu=0,n,lw,lwr,nwru=0;
783:   PetscBLASInt   n_,ld,info,lwork,ilo,ihi;
784:   PetscScalar    *H,*A,*B,*Q,*X;
785:   PetscReal      *d,*s,*scale,nrm,*rcde,*rcdv;
786: #if defined(PETSC_USE_COMPLEX)
787:   PetscInt       j,k;
788: #endif

791: #if !defined(PETSC_USE_COMPLEX)
793: #endif
794:   n = ds->n-ds->l;
795:   PetscBLASIntCast(n,&n_);
796:   PetscBLASIntCast(ds->ld,&ld);
797:   off = ds->l + ds->l*ld;
798:   A = ds->mat[DS_MAT_A];
799:   B = ds->mat[DS_MAT_B];
800:   Q = ds->mat[DS_MAT_Q];
801:   d = ds->rmat[DS_MAT_T];
802:   s = ds->rmat[DS_MAT_D];
803:   lw = 14*ld+ld*ld;
804:   lwr = 7*ld;
805:   DSAllocateWork_Private(ds,lw,lwr,0);
806:   scale = ds->rwork+nwru;
807:   nwru += ld;
808:   rcde = ds->rwork+nwru;
809:   nwru += ld;
810:   rcdv = ds->rwork+nwru;
811:   nwru += ld;
812:   /* Quick return if possible */
813:   if (n_ == 1) {
814:     *(Q+off) = 1;
815:     if (!ds->compact) {
816:       d[ds->l] = PetscRealPart(A[off]);
817:       s[ds->l] = PetscRealPart(B[off]);
818:     }
819:     wr[ds->l] = d[ds->l]/s[ds->l];
820:     if (wi) wi[ds->l] = 0.0;
821:     return(0);
822:   }

824:   /* Form pseudo-symmetric matrix */
825:   H =  ds->work+nwu;
826:   nwu += n*n;
827:   PetscMemzero(H,n*n*sizeof(PetscScalar));
828:   if (ds->compact) {
829:     for (i=0;i<n-1;i++) {
830:       H[i+i*n]     = s[ds->l+i]*d[ds->l+i];
831:       H[i+1+i*n]   = s[ds->l+i+1]*d[ld+ds->l+i];
832:       H[i+(i+1)*n] = s[ds->l+i]*d[ld+ds->l+i];
833:     }
834:     H[n-1+(n-1)*n] = s[ds->l+n-1]*d[ds->l+n-1];
835:     for (i=0;i<ds->k-ds->l;i++) {
836:       H[ds->k-ds->l+i*n] = s[ds->k]*d[2*ld+ds->l+i];
837:       H[i+(ds->k-ds->l)*n] = s[i+ds->l]*d[2*ld+ds->l+i];
838:     }
839:   } else {
840:     for (i=0;i<n-1;i++) {
841:       H[i+i*n]     = B[off+i+i*ld]*A[off+i+i*ld];
842:       H[i+1+i*n]   = B[off+i+1+(i+1)*ld]*A[off+i+1+i*ld];
843:       H[i+(i+1)*n] = B[off+i+i*ld]*A[off+i+(i+1)*ld];
844:     }
845:     H[n-1+(n-1)*n] = B[off+n-1+(n-1)*ld]*A[off+n-1+(n-1)*n];
846:     for (i=0;i<ds->k-ds->l;i++) {
847:       H[ds->k-ds->l+i*n] = B[ds->k*(1+ld)]*A[off+ds->k-ds->l+i*ld];
848:       H[i+(ds->k-ds->l)*n] = B[(i+ds->l)*(1+ld)]*A[off+i+(ds->k-ds->l)*ld];
849:     }
850:   }
851:  
852:   /* Compute eigenpairs */
853:   PetscBLASIntCast(lw-nwu,&lwork);  
854:   DSAllocateMat_Private(ds,DS_MAT_X);
855:   X = ds->mat[DS_MAT_X];
856: #if !defined(PETSC_USE_COMPLEX)
857:   PetscStackCallBLAS("LAPACKgeevx",LAPACKgeevx_("B","N","V","N",&n_,H,&n_,wr+ds->l,wi+ds->l,NULL,&ld,X+off,&ld,&ilo,&ihi,scale,&nrm,rcde,rcdv,ds->work+nwu,&lwork,NULL,&info));
858: #else
859:   PetscStackCallBLAS("LAPACKgeevx",LAPACKgeevx_("B","N","V","N",&n_,H,&n_,wr+ds->l,NULL,&ld,X+off,&ld,&ilo,&ihi,scale,&nrm,rcde,rcdv,ds->work+nwu,&lwork,ds->rwork+nwru,&info));

861:   /* Sort to have consecutive conjugate pairs 
862:      Separate real and imaginary part of complex eigenvectors*/
863:   for (i=ds->l;i<ds->n;i++) {
864:     j=i+1;
865:     while (j<ds->n && (PetscAbsScalar(wr[i]-PetscConj(wr[j]))>PetscAbsScalar(wr[i])*PETSC_SQRT_MACHINE_EPSILON)) j++;
866:     if (j==ds->n) {
867:       if (PetscAbsReal(PetscImaginaryPart(wr[i]))<PetscAbsScalar(wr[i])*PETSC_SQRT_MACHINE_EPSILON) {
868:         wr[i]=PetscRealPart(wr[i]); /* real eigenvalue */
869:         for (k=ds->l;k<ds->n;k++) {
870:           X[k+i*ds->ld] = PetscRealPart(X[k+i*ds->ld]);
871:         }
872:       } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Found complex without conjugate pair");
873:     } else { /* complex eigenvalue */
874:       if (j!=i+1) {
875:         wr[j] = wr[i+1];
876:         PetscMemcpy(X+j*ds->ld,X+(i+1)*ds->ld,ds->ld*sizeof(PetscScalar));
877:       }
878:       if (PetscImaginaryPart(wr[i])<0) {
879:         wr[i] = PetscConj(wr[i]);
880:         for (k=ds->l;k<ds->n;k++) {
881:           X[k+(i+1)*ds->ld] = -PetscImaginaryPart(X[k+i*ds->ld]);
882:           X[k+i*ds->ld] = PetscRealPart(X[k+i*ds->ld]);
883:         }
884:       } else {
885:         for (k=ds->l;k<ds->n;k++) {
886:           X[k+(i+1)*ds->ld] = PetscImaginaryPart(X[k+i*ds->ld]);
887:           X[k+i*ds->ld] = PetscRealPart(X[k+i*ds->ld]);
888:         }
889:       }
890:       wr[i+1] = PetscConj(wr[i]);
891:       i++;
892:     }
893:   }
894: #endif
895:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xHSEQR %d",&info);

897:   /* Compute real s-orthonormal basis */
898:   DSGHIEPOrthogEigenv(ds,DS_MAT_X,wr,wi,PETSC_FALSE);

900:   /* Recover eigenvalues from diagonal */
901:   DSGHIEPComplexEigs(ds,0,ds->l,wr,wi);
902: #if defined(PETSC_USE_COMPLEX)
903:   if (wi) {
904:     for (i=ds->l;i<ds->n;i++) wi[i] = 0.0;
905:   }
906: #endif
907:   return(0);
908: #endif
909: }

913: PetscErrorCode DSNormalize_GHIEP(DS ds,DSMatType mat,PetscInt col)
914: {
916:   PetscInt       i,i0,i1;
917:   PetscBLASInt   ld,n,one = 1;
918:   PetscScalar    *A = ds->mat[DS_MAT_A],norm,*x;
919: #if !defined(PETSC_USE_COMPLEX)
920:   PetscScalar    norm0;
921: #endif

924:   switch (mat) {
925:     case DS_MAT_X:
926:     case DS_MAT_Y:
927:     case DS_MAT_Q:
928:       /* Supported matrices */
929:       break;
930:     case DS_MAT_U:
931:     case DS_MAT_VT:
932:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
933:       break;
934:     default:
935:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
936:   }

938:   PetscBLASIntCast(ds->n,&n);
939:   PetscBLASIntCast(ds->ld,&ld);
940:   DSGetArray(ds,mat,&x);
941:   if (col < 0) {
942:     i0 = 0; i1 = ds->n;
943:   } else if (col>0 && A[ds->ld*(col-1)+col] != 0.0) {
944:     i0 = col-1; i1 = col+1;
945:   } else {
946:     i0 = col; i1 = col+1;
947:   }
948:   for (i=i0; i<i1; i++) {
949: #if !defined(PETSC_USE_COMPLEX)
950:     if (i<n-1 && A[ds->ld*i+i+1] != 0.0) {
951:       norm = BLASnrm2_(&n,&x[ld*i],&one);
952:       norm0 = BLASnrm2_(&n,&x[ld*(i+1)],&one);
953:       norm = 1.0/SlepcAbsEigenvalue(norm,norm0);
954:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
955:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*(i+1)],&one));
956:       i++;
957:     } else
958: #endif
959:     {
960:       norm = BLASnrm2_(&n,&x[ld*i],&one);
961:       norm = 1.0/norm;
962:       PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one));
963:     }
964:   }
965:   return(0);
966: }

970: PETSC_EXTERN PetscErrorCode DSCreate_GHIEP(DS ds)
971: {
973:   ds->ops->allocate      = DSAllocate_GHIEP;
974:   ds->ops->view          = DSView_GHIEP;
975:   ds->ops->vectors       = DSVectors_GHIEP;
976:   ds->ops->solve[0]      = DSSolve_GHIEP_HZ;
977:   ds->ops->solve[1]      = DSSolve_GHIEP_QR_II;
978:   ds->ops->solve[2]      = DSSolve_GHIEP_QR;
979:   ds->ops->solve[3]      = DSSolve_GHIEP_DQDS_II;
980:   ds->ops->sort          = DSSort_GHIEP;
981:   ds->ops->normalize     = DSNormalize_GHIEP;
982:   return(0);
983: }

slepc-3.7.4/src/sys/classes/ds/impls/ghiep/hz.c0000644000175000017500000003156713107004621020654 0ustar jromanjroman/* HZ iteration for generalized symmetric-indefinite eigenproblem. Based on Matlab code from David Watkins. References: [1] D.S. Watkins, The Matrix Eigenvalue Problem: GR and Krylov Subspace Methods, SIAM, 2007. [2] M.A. Brebner, J. Grad, "Eigenvalues of Ax = lambda Bx for real symmetric matrices A and B computed by reduction to pseudosymmetric form and the HR process", Linear Alg. Appl. 43:99-118, 1982. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "UnifiedRotation" /* Sets up a 2-by-2 matrix to eliminate y in the vector [x y]'. Transformation is rotator if sygn = 1 and hyperbolic if sygn = -1. */ static PetscErrorCode UnifiedRotation(PetscReal x,PetscReal y,PetscReal sygn,PetscReal *rot,PetscReal *rcond,PetscBool *swap) { PetscReal nrm,c,s; PetscFunctionBegin; *swap = PETSC_FALSE; if (y == 0) { rot[0] = 1.0; rot[1] = 0.0; rot[2] = 0.0; rot[3] = 1.0; *rcond = 1.0; } else { nrm = PetscMax(PetscAbs(x),PetscAbs(y)); c = x/nrm; s = y/nrm; if (sygn == 1.0) { /* set up a rotator */ nrm = PetscSqrtReal(c*c+s*s); c = c/nrm; s = s/nrm; /* rot = [c s; -s c]; */ rot[0] = c; rot[1] = -s; rot[2] = s; rot[3] = c; *rcond = 1.0; } else if (sygn == -1) { /* set up a hyperbolic transformation */ nrm = c*c-s*s; if (nrm > 0) nrm = PetscSqrtReal(nrm); else if (nrm < 0) { nrm = PetscSqrtReal(-nrm); *swap = PETSC_TRUE; } else /* breakdown */ SETERRQ(PETSC_COMM_SELF,1,"Breakdown in construction of hyperbolic transformation"); c = c/nrm; s = s/nrm; /* rot = [c -s; -s c]; */ rot[0] = c; rot[1] = -s; rot[2] = -s; rot[3] = c; *rcond = PetscAbs(PetscAbs(s)-PetscAbs(c))/(PetscAbs(s)+PetscAbs(c)); } else SETERRQ(PETSC_COMM_SELF,1,"Value of sygn sent to transetup must be 1 or -1"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "HZStep" static PetscErrorCode HZStep(PetscBLASInt ntop,PetscBLASInt nn,PetscReal tr,PetscReal dt,PetscReal *aa,PetscReal *bb,PetscReal *dd,PetscScalar *uu,PetscInt n,PetscInt ld,PetscBool *flag) { PetscErrorCode ierr; PetscBLASInt one=1; PetscInt k,jj,ii; PetscBLASInt n_; PetscReal bulge10,bulge20,bulge30,bulge31,bulge41,bulge42; PetscReal sygn,rcond=1.0,worstcond,rot[4],buf[2],t; PetscScalar rtmp; PetscBool swap; PetscFunctionBegin; worstcond = 1.0; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); /* Build initial bulge that sets step in motion */ bulge10 = dd[ntop+1]*(aa[ntop]*(aa[ntop] - dd[ntop]*tr) + dt*dd[ntop]*dd[ntop]) + dd[ntop]*bb[ntop]*bb[ntop]; bulge20 = bb[ntop]*(dd[ntop+1]*aa[ntop] + dd[ntop]*aa[ntop+1] - dd[ntop]*dd[ntop+1]*tr); bulge30 = bb[ntop]*bb[ntop+1]*dd[ntop]; bulge31 = 0.0; bulge41 = 0.0; bulge42 = 0.0; /* Chase the bulge */ for (jj=ntop;jjntop && PetscMax(PetscMax(PetscAbs(bulge10),PetscAbs(bulge20)),PetscAbs(bulge30)) ntop) bb[jj-1] = rot[0]*bulge10 + rot[2]*bulge20; buf[0] = rot[0]*rot[0]*aa[jj] + 2*rot[0]*rot[2]*bb[jj] + rot[2]*rot[2]*aa[jj+1]; buf[1] = rot[1]*rot[1]*aa[jj] + 2*rot[3]*rot[1]*bb[jj] + rot[3]*rot[3]*aa[jj+1]; bb[jj] = rot[1]*rot[0]*aa[jj] + rot[3]*rot[2]*aa[jj+1] + (rot[3]*rot[0] + rot[1]*rot[2])*bb[jj]; aa[jj] = buf[0]; aa[jj+1] = buf[1]; if (jj + 1 < nn-1) { /* buf = [ bulge31 bb(jj+1) ] * rot' */ buf[0] = rot[0]*bulge31 + rot[2]*bb[jj+1]; buf[1] = rot[1]*bulge31 + rot[3]*bb[jj+1]; bulge31 = buf[0]; bb[jj+1] = buf[1]; } if (jj + 2 < nn-1) { /* buf = [bulge41 bulge42] * rot' */ buf[0] = rot[0]*bulge41 + rot[2]*bulge42; buf[1] = rot[1]*bulge41 + rot[3]*bulge42; bulge41 = buf[0]; bulge42 = buf[1]; } /* Apply transforming matrix rot to D */ if (swap == 1) { buf[0] = dd[jj]; dd[jj] = dd[jj+1]; dd[jj+1] = buf[0]; } /* Accumulate transforming matrix, uu(jj:jj+1,:) = rot*uu(jj:jj+1,:) */ if (sygn==1) { PetscStackCallBLAS("BLASrot",BLASrot_(&n_,uu+jj*ld,&one,uu+(jj+1)*ld,&one,&rot[0],&rot[2])); } else { if (PetscAbsReal(rot[0])>PetscAbsReal(rot[1])) { /* Type I */ t = rot[1]/rot[0]; for (ii=0;ii= cgd && nits < nstop) { /* Check for zeros on the subdiagonal */ jj = nbot - 1; while (jj>=cgd && PetscAbs(bb[jj])>PETSC_MACHINE_EPSILON*(PetscAbs(aa[jj])+PetscAbs(aa[jj+1]))) jj = jj-1; if (jj>=cgd) bb[jj]=0; ntop = jj + 1; /* starting point for step */ if (ntop == nbot) { /* isolate single eigenvalue */ nbot = ntop - 1; its = 0; } else if (ntop+1 == nbot) { /* isolate pair of eigenvalues */ htr = 0.5*(aa[ntop]*dd[ntop] + aa[nbot]*dd[nbot]); det = dd[ntop]*dd[nbot]*(aa[ntop]*aa[nbot]-bb[ntop]*bb[ntop]); dis = htr*htr - det; if (dis > 0) { /* distinct real eigenvalues */ if (dd[ntop] == dd[nbot]) { /* separate the eigenvalues by a Jacobi rotator */ dif = aa[ntop]-aa[nbot]; if (2.0*PetscAbs(bb[ntop])<=dif) { tn = 2*bb[ntop]/dif; tn = tn/(1.0 + PetscSqrtScalar(1.0+tn*tn)); } else { kt = dif/(2.0*bb[ntop]); tn = PetscSign(kt)/(PetscAbs(kt)+PetscSqrtScalar(1.0+kt*kt)); } c = 1.0/PetscSqrtScalar(1.0 + tn*tn); s = c*tn; aa[ntop] = aa[ntop] + tn*bb[ntop]; aa[nbot] = aa[nbot] - tn*bb[ntop]; bb[ntop] = 0; j2 = nn-cgd; PetscStackCallBLAS("BLASrot",BLASrot_(&j2,uu+ntop*ld+cgd,&one,uu+nbot*ld+cgd,&one,&c,&s)); } } nbot = ntop - 1; } else { /* Do an HZ iteration */ its = its + 1; nits = nits + 1; tr = aa[nbot-1]*dd[nbot-1] + aa[nbot]*dd[nbot]; dt = dd[nbot-1]*dd[nbot]*(aa[nbot-1]*aa[nbot]-bb[nbot-1]*bb[nbot-1]); for (ntry=1;ntry<=6;ntry++) { ierr = HZStep(ntop,nbot+1,tr,dt,aa,bb,dd,uu,nn,ld,&flag);CHKERRQ(ierr); if (!flag) break; else if (ntry == 6) SETERRQ(PETSC_COMM_SELF,1,"Unable to complete hz step on six tries"); else { tr = 0.9*tr; dt = 0.81*dt; } } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSolve_GHIEP_HZ" PetscErrorCode DSSolve_GHIEP_HZ(DS ds,PetscScalar *wr,PetscScalar *wi) { PetscErrorCode ierr; PetscInt off; PetscBLASInt n1,ld; PetscScalar *A,*B,*Q; PetscReal *d,*e,*s; #if defined(PETSC_USE_COMPLEX) PetscInt i; #endif PetscFunctionBegin; #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(wi,3); #endif ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); n1 = ds->n - ds->l; off = ds->l + ds->l*ld; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; Q = ds->mat[DS_MAT_Q]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T] + ld; s = ds->rmat[DS_MAT_D]; /* Quick return */ if (n1 == 1) { *(Q+off) = 1; if (ds->compact) { wr[ds->l] = d[ds->l]/s[ds->l]; wi[ds->l] = 0.0; } else { d[ds->l] = PetscRealPart(A[off]); s[ds->l] = PetscRealPart(B[off]); wr[ds->l] = d[ds->l]/s[ds->l]; wi[ds->l] = 0.0; } PetscFunctionReturn(0); } /* Reduce to pseudotriadiagonal form */ ierr = DSIntermediate_GHIEP(ds);CHKERRQ(ierr); ierr = HZIteration(ds->n,ds->l,d,e,s,Q,ld);CHKERRQ(ierr); if (!ds->compact) { ierr = DSSwitchFormat_GHIEP(ds,PETSC_FALSE);CHKERRQ(ierr); } /* Undo from diagonal the blocks whith real eigenvalues*/ ierr = DSGHIEPRealBlocks(ds);CHKERRQ(ierr); /* Recover eigenvalues from diagonal */ ierr = DSGHIEPComplexEigs(ds,0,ds->n,wr,wi);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) if (wi) { for (i=ds->l;in;i++) wi[i] = 0.0; } #endif ds->t = ds->n; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/ghiep/index.html0000644000175000017500000000234313107004621022052 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dsghiep.c
invit.c
hz.c
dqds.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/ghiep/invit.c.html0000644000175000017500000016077113107004621022327 0ustar jromanjroman

Actual source code: invit.c

slepc-3.7.4 2017-05-17
  1: /*

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

  7:    This file is part of SLEPc.

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

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

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

 25: struct HRtr
 26: {
 27:   PetscScalar *data;
 28:   PetscInt    m;
 29:   PetscInt    idx[2];
 30:   PetscInt    n[2];
 31:   PetscScalar tau[2];
 32:   PetscReal   alpha;
 33:   PetscReal   cs;
 34:   PetscReal   sn;
 35:   PetscInt    type;
 36: };

 40: /*
 41:   Generates a hyperbolic rotation
 42:     if x1*x1 - x2*x2 != 0
 43:       r = sqrt(|x1*x1 - x2*x2|)
 44:       c = x1/r  s = x2/r

 46:       | c -s||x1|   |d*r|
 47:       |-s  c||x2| = | 0 |
 48:       where d = 1 for type==1 and -1 for type==2
 49:   Returns the condition number of the reduction
 50: */
 51: static PetscErrorCode HRGen(PetscReal x1,PetscReal x2,PetscInt *type,PetscReal *c,PetscReal *s,PetscReal *r,PetscReal *cond)
 52: {
 53:   PetscReal t,n2,xa,xb;
 54:   PetscInt  type_;

 57:   if (x2==0.0) {
 58:     *r = PetscAbsReal(x1);
 59:     *c = (x1>=0)?1.0:-1.0;
 60:     *s = 0.0;
 61:     if (type) *type = 1;
 62:     return(0);
 63:   }
 64:   if (PetscAbsReal(x1) == PetscAbsReal(x2)) {
 65:     /* hyperbolic rotation doesn't exist */
 66:     *c = 0.0;
 67:     *s = 0.0;
 68:     *r = 0.0;
 69:     if (type) *type = 0;
 70:     *cond = PETSC_MAX_REAL;
 71:     return(0);
 72:   }

 74:   if (PetscAbsReal(x1)>PetscAbsReal(x2)) {
 75:     xa = x1; xb = x2; type_ = 1;
 76:   } else {
 77:     xa = x2; xb = x1; type_ = 2;
 78:   }
 79:   t = xb/xa;
 80:   n2 = PetscAbsReal(1 - t*t);
 81:   *r = PetscSqrtReal(n2)*PetscAbsReal(xa);
 82:   *c = x1/(*r);
 83:   *s = x2/(*r);
 84:   if (type_ == 2) *r *= -1;
 85:   if (type) *type = type_;
 86:   if (cond) *cond = (PetscAbsReal(*c) + PetscAbsReal(*s))/PetscAbsReal(PetscAbsReal(*c) - PetscAbsReal(*s));
 87:   return(0);
 88: }

 92: /*
 93:                                 |c  s|
 94:   Applies an hyperbolic rotator |s  c|
 95:            |c  s|
 96:     [x1 x2]|s  c|
 97: */
 98: static PetscErrorCode HRApply(PetscInt n,PetscScalar *x1,PetscInt inc1,PetscScalar *x2,PetscInt inc2,PetscReal c,PetscReal s)
 99: {
100:   PetscInt    i;
101:   PetscReal   t;
102:   PetscScalar tmp;

105:   if (PetscAbsReal(c)>PetscAbsReal(s)) { /* Type I */
106:     t = s/c;
107:     for (i=0;i<n;i++) {
108:       x1[i*inc1] = c*x1[i*inc1] + s*x2[i*inc2];
109:       x2[i*inc2] = t*x1[i*inc1] + x2[i*inc2]/c;
110:     }
111:   } else { /* Type II */
112:     t = c/s;
113:     for (i=0;i<n;i++) {
114:       tmp = x1[i*inc1];
115:       x1[i*inc1] = c*x1[i*inc1] + s*x2[i*inc2];
116:       x2[i*inc2] = t*x1[i*inc1] + tmp/s;
117:     }
118:   }
119:   return(0);
120: }

124: /*
125:   Reduction to tridiagonal-diagonal form (see F. Tisseur, SIMAX 26(1), 2004).

127:   Input:
128:     A symmetric (only lower triangular part is referred)
129:     s vector +1 and -1 (signature matrix)
130:   Output:
131:     d,e
132:     s
133:     Q s-orthogonal matrix with Q^T*A*Q = T (symmetric tridiagonal matrix)
134: */
135: static PetscErrorCode TridiagDiag_HHR(PetscInt n,PetscScalar *A,PetscInt lda,PetscReal *s,PetscScalar* Q,PetscInt ldq,PetscBool flip,PetscReal *d,PetscReal *e,PetscInt *perm_,PetscScalar *work,PetscReal *rwork,PetscBLASInt *iwork)
136: {
137: #if defined(SLEPC_MISSING_LAPACK_LARFG) || defined(SLEPC_MISSING_LAPACK_LARF)
139:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LARFG/LARF - Lapack routines are unavailable");
140: #else
142:   PetscInt       i,j,k,*ii,*jj,i0=0,ik=0,tmp,type;
143:   PetscInt       nwu=0;
144:   PetscReal      *ss,cond=1.0,cs,sn,r;
145:   PetscScalar    tau,t,*AA;
146:   PetscBLASInt   n0,n1,ni,inc=1,m,n_,lda_,ldq_,*perm;
147:   PetscBool      breakdown = PETSC_TRUE;

150:   if (n<3) {
151:     if (n==1) Q[0]=1;
152:     if (n==2) {
153:       Q[0] = Q[1+ldq] = 1;
154:       Q[1] = Q[ldq] = 0;
155:     }
156:     return(0);
157:   }
158:   PetscBLASIntCast(lda,&lda_);
159:   PetscBLASIntCast(n,&n_);
160:   PetscBLASIntCast(ldq,&ldq_);
161:   ss = rwork;
162:   perm = iwork;
163:   AA = work;
164:   for (i=0;i<n;i++) {
165:     PetscMemcpy(AA+i*n,A+i*lda,n*sizeof(PetscScalar));
166:   }
167:   nwu += n*n;
168:   k=0;
169:   while (breakdown && k<n) {
170:     breakdown = PETSC_FALSE;
171:     /* Classify (and flip) A and s according to sign */
172:     if (flip) {
173:       for (i=0;i<n;i++) {
174:         perm[i] = n-1-perm_[i];
175:         if (perm[i]==0) i0 = i;
176:         if (perm[i]==k) ik = i;
177:       }
178:     } else {
179:       for (i=0;i<n;i++) {
180:         perm[i] = perm_[i];
181:         if (perm[i]==0) i0 = i;
182:         if (perm[i]==k) ik = i;
183:       }
184:     }
185:     perm[ik] = 0;
186:     perm[i0] = k;
187:     i=1;
188:     while (i<n-1 && s[perm[i-1]]==s[perm[0]]) {
189:       if (s[perm[i]]!=s[perm[0]]) {
190:         j=i+1;
191:         while (j<n-1 && s[perm[j]]!=s[perm[0]])j++;
192:         tmp = perm[i]; perm[i] = perm[j]; perm[j] = tmp;
193:       }
194:       i++;
195:     }
196:     for (i=0;i<n;i++) {
197:       ss[i] = s[perm[i]];
198:     }
199:     if (flip) {
200:       ii = &j;
201:       jj = &i;
202:     } else {
203:       ii = &i;
204:       jj = &j;
205:     }
206:     for (i=0;i<n;i++)
207:       for (j=0;j<n;j++)
208:         A[i+j*lda] = AA[perm[*ii]+perm[*jj]*n];
209:     /* Initialize Q */
210:     for (i=0;i<n;i++) {
211:       PetscMemzero(Q+i*ldq,n*sizeof(PetscScalar));
212:       Q[perm[i]+i*ldq] = 1.0;
213:     }
214:     for (ni=1;ni<n && ss[ni]==ss[0]; ni++);
215:     n0 = ni-1;
216:     n1 = n_-ni;
217:     for (j=0;j<n-2;j++) {
218:       PetscBLASIntCast(n-j-1,&m);
219:       /* Forming and applying reflectors */
220:       if (n0 > 1) {
221:         PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0,A+ni-n0+j*lda,A+ni-n0+j*lda+1,&inc,&tau));
222:         /* Apply reflector */
223:         if (PetscAbsScalar(tau) != 0.0) {
224:           t=*(A+ni-n0+j*lda);  *(A+ni-n0+j*lda)=1.0;
225:           PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&m,&n0,A+ni-n0+j*lda,&inc,&tau,A+j+1+(j+1)*lda,&lda_,work+nwu));
226:           PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0,&m,A+ni-n0+j*lda,&inc,&tau,A+j+1+(j+1)*lda,&lda_,work+nwu));
227:           /* Update Q */
228:           PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n0,A+ni-n0+j*lda,&inc,&tau,Q+(j+1)*ldq,&ldq_,work+nwu));
229:           *(A+ni-n0+j*lda) = t;
230:           for (i=1;i<n0;i++) {
231:             *(A+ni-n0+j*lda+i) = 0.0;  *(A+j+(ni-n0+i)*lda) = 0.0;
232:           }
233:           *(A+j+(ni-n0)*lda) = *(A+ni-n0+j*lda);
234:         }
235:       }
236:       if (n1 > 1) {
237:         PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1,A+n-n1+j*lda,A+n-n1+j*lda+1,&inc,&tau));
238:         /* Apply reflector */
239:         if (PetscAbsScalar(tau) != 0.0) {
240:           t=*(A+n-n1+j*lda);  *(A+n-n1+j*lda)=1.0;
241:           PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&m,&n1,A+n-n1+j*lda,&inc,&tau,A+j+1+(n-n1)*lda,&lda_,work+nwu));
242:           PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1,&m,A+n-n1+j*lda,&inc,&tau,A+n-n1+(j+1)*lda,&lda_,work+nwu));
243:           /* Update Q */
244:           PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n1,A+n-n1+j*lda,&inc,&tau,Q+(n-n1)*ldq,&ldq_,work+nwu));
245:           *(A+n-n1+j*lda) = t;
246:           for (i=1;i<n1;i++) {
247:             *(A+n-n1+i+j*lda) = 0.0;  *(A+j+(n-n1+i)*lda) = 0.0;
248:           }
249:           *(A+j+(n-n1)*lda) = *(A+n-n1+j*lda);
250:         }
251:       }
252:       /* Hyperbolic rotation */
253:       if (n0 > 0 && n1 > 0) {
254:         HRGen(PetscRealPart(A[ni-n0+j*lda]),PetscRealPart(A[n-n1+j*lda]),&type,&cs,&sn,&r,&cond);
255:         /* Check condition number */
256:         if (cond > 1.0/(10*PETSC_SQRT_MACHINE_EPSILON)) {
257:           breakdown = PETSC_TRUE;
258:           k++;
259:           if (k==n || flip)
260:             SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Breakdown in construction of hyperbolic transformation");
261:           break;
262:         }
263:         A[ni-n0+j*lda] = r; A[n-n1+j*lda] = 0.0;
264:         A[j+(ni-n0)*lda] = r; A[j+(n-n1)*lda] = 0.0;
265:         /* Apply to A */
266:         HRApply(m,A+j+1+(ni-n0)*lda,1,A+j+1+(n-n1)*lda,1,cs,-sn);
267:         HRApply(m,A+ni-n0+(j+1)*lda,lda,A+n-n1+(j+1)*lda,lda,cs,-sn);

269:         /* Update Q */
270:         HRApply(n,Q+(ni-n0)*ldq,1,Q+(n-n1)*ldq,1,cs,-sn);
271:         if (type==2) {
272:           ss[ni-n0] = -ss[ni-n0]; ss[n-n1] = -ss[n-n1];
273:           n0++;ni++;n1--;
274:         }
275:       }
276:       if (n0>0) n0--;
277:       else n1--;
278:     }
279:   }

281:   /* flip matrices */
282:   if (flip) {
283:     for (i=0;i<n-1;i++) {
284:       d[i] = PetscRealPart(A[n-i-1+(n-i-1)*lda]);
285:       e[i] = PetscRealPart(A[n-i-1+(n-i-2)*lda]);
286:       s[i] = ss[n-i-1];
287:     }
288:     s[n-1] = ss[0];
289:     d[n-1] = PetscRealPart(A[0]);
290:     for (i=0;i<n;i++) {
291:       ierr=PetscMemcpy(work+i*n,Q+i*ldq,n*sizeof(PetscScalar));
292:     }
293:     for (i=0;i<n;i++)
294:       for (j=0;j<n;j++)
295:         Q[i+j*ldq] = work[i+(n-j-1)*n];
296:   } else {
297:     for (i=0;i<n-1;i++) {
298:       d[i] = PetscRealPart(A[i+i*lda]);
299:       e[i] = PetscRealPart(A[i+1+i*lda]);
300:       s[i] = ss[i];
301:     }
302:     s[n-1] = ss[n-1];
303:     d[n-1] = PetscRealPart(A[n-1 + (n-1)*lda]);
304:   }
305:   return(0);
306: #endif
307: }

311: static PetscErrorCode MadeHRtr(PetscInt sz,PetscInt n,PetscInt idx0,PetscInt n0,PetscInt idx1,PetscInt n1,struct HRtr *tr1,struct HRtr *tr2,PetscReal *ncond,PetscScalar *work)
312: {
313: #if defined(SLEPC_MISSING_LAPACK_LARFG) || defined(SLEPC_MISSING_LAPACK_LARF)
315:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LARFG/LARF - Lapack routines are unavailable");
316: #else
318:   PetscScalar    *x,*y;
319:   PetscReal       ncond2;
320:   PetscBLASInt   n0_,n1_,inc=1;

323:   /* Hyperbolic transformation to make zeros in x */
324:   x = tr1->data;
325:   tr1->n[0] = n0;
326:   tr1->n[1] = n1;
327:   tr1->idx[0] = idx0;
328:   tr1->idx[1] = idx1;
329:   PetscBLASIntCast(tr1->n[0],&n0_);
330:   PetscBLASIntCast(tr1->n[1],&n1_);
331:   if (tr1->n[0] > 1) {
332:     PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0_,x+tr1->idx[0],x+tr1->idx[0]+1,&inc,tr1->tau));
333:   }
334:   if (tr1->n[1]> 1) {
335:     PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1_,x+tr1->idx[1],x+tr1->idx[1]+1,&inc,tr1->tau+1));
336:   }
337:   if (tr1->idx[0]<tr1->idx[1]) {
338:     HRGen(PetscRealPart(x[tr1->idx[0]]),PetscRealPart(x[tr1->idx[1]]),&(tr1->type),&(tr1->cs),&(tr1->sn),&(tr1->alpha),ncond);  
339:   } else {
340:     tr1->alpha = PetscRealPart(x[tr1->idx[0]]);
341:     *ncond = 1.0;
342:   }
343:   if (sz==2) {
344:     y = tr2->data;
345:     /* Apply first transformation to second column */
346:     if (tr1->n[0] > 1 && PetscAbsScalar(tr1->tau[0])!=0.0) {
347:       x[tr1->idx[0]] = 1.0;
348:       PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0_,&inc,x+tr1->idx[0],&inc,tr1->tau,y+tr1->idx[0],&n0_,work));
349:     }
350:     if (tr1->n[1] > 1 && PetscAbsScalar(tr1->tau[1])!=0.0) {
351:       x[tr1->idx[1]] = 1.0;
352:       PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1_,&inc,x+tr1->idx[1],&inc,tr1->tau+1,y+tr1->idx[1],&n1_,work));
353:     }
354:     if (tr1->idx[0]<tr1->idx[1]) {
355:       HRApply(1,y+tr1->idx[0],1,y+tr1->idx[1],1,tr1->cs,-tr1->sn);
356:     }
357:     tr2->n[0] = tr1->n[0];
358:     tr2->n[1] = tr1->n[1];
359:     tr2->idx[0] = tr1->idx[0];
360:     tr2->idx[1] = tr1->idx[1];
361:     if (tr1->idx[0]<tr1->idx[1] && tr1->type==2) {
362:       tr2->idx[1]++; tr2->n[1]--; tr2->n[0]++;
363:     }
364:     if (tr2->n[0]>0) {
365:       tr2->n[0]--; tr2->idx[0]++;
366:       if (tr2->n[1]==0) tr2->idx[1] = tr2->idx[0];
367:     } else {
368:       tr2->n[1]--; tr2->idx[1]++; tr2->idx[0] = tr2->idx[1];
369:     }
370:     /* Hyperbolic transformation to make zeros in y */
371:     PetscBLASIntCast(tr2->n[0],&n0_);
372:     PetscBLASIntCast(tr2->n[1],&n1_);
373:     if (tr2->n[0] > 1) {
374:       PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0_,y+tr2->idx[0],y+tr2->idx[0]+1,&inc,tr2->tau));
375:     }
376:     if (tr2->n[1]> 1) {
377:       PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1_,y+tr2->idx[1],y+tr2->idx[1]+1,&inc,tr2->tau+1));
378:     }
379:     if (tr2->idx[0]<tr2->idx[1]) {
380:       HRGen(PetscRealPart(y[tr2->idx[0]]),PetscRealPart(y[tr2->idx[1]]),&(tr2->type),&(tr2->cs),&(tr2->sn),&(tr2->alpha),&ncond2);  
381:     } else {
382:     tr2->alpha = PetscRealPart(y[tr2->idx[0]]);
383:     ncond2 = 1.0;
384:     }
385:     if (ncond2>*ncond) *ncond = ncond2;
386:   }
387:   return(0);
388: #endif
389: }

393: /*
394:   Auxiliary function to try perform one iteration of hr routine,
395:   checking condition number. If it is < tolD, apply the
396:   transformation to H and R, if not, ok=false and it do nothing
397:   tolE, tolerance to exchange complex pairs to improve conditioning
398: */
399: static PetscErrorCode TryHRIt(PetscInt n,PetscInt j,PetscInt sz,PetscScalar *H,PetscInt ldh,PetscScalar *R,PetscInt ldr,PetscReal *s,PetscBool *exg,PetscBool *ok,PetscInt *n0,PetscInt *n1,PetscInt *idx0,PetscInt *idx1,PetscReal *cond,PetscScalar *work)
400: {
401: #if defined(SLEPC_MISSING_LAPACK_LARF)
403:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LARF - Lapack routine is unavailable");
404: #else
406:   struct HRtr    *tr1,*tr2,tr1_t,tr2_t,tr1_te,tr2_te;
407:   PetscScalar    *x,*y;
408:   PetscReal      ncond,ncond_e;
409:   PetscInt       nwu=0,i,d=1;
410:   PetscBLASInt   n0_,n1_,inc=1,mh,mr,n_,ldr_,ldh_;
411:   PetscReal      tolD = 1e+5;

414:   if (cond) *cond = 1.0;
415:   PetscBLASIntCast(n,&n_);
416:   PetscBLASIntCast(ldr,&ldr_);
417:   PetscBLASIntCast(ldh,&ldh_);
418:   x = work+nwu;
419:   nwu += n;
420:   PetscMemcpy(x,R+j*ldr,n*sizeof(PetscScalar));
421:   *exg = PETSC_FALSE;
422:   *ok = PETSC_TRUE;
423:   tr1_t.data = x;
424:   if (sz==1) {
425:     /* Hyperbolic transformation to make zeros in x */
426:     MadeHRtr(sz,n,*idx0,*n0,*idx1,*n1,&tr1_t,NULL,&ncond,work+nwu);
427:     /* Check condition number to single column*/
428:     if (ncond>tolD) {
429:       *ok = PETSC_FALSE;
430:     }
431:     tr1 = &tr1_t;
432:     tr2 = &tr2_t;    
433:   } else {
434:     y = work+nwu;
435:     nwu += n;
436:     PetscMemcpy(y,R+(j+1)*ldr,n*sizeof(PetscScalar));
437:     tr2_t.data = y;
438:     MadeHRtr(sz,n,*idx0,*n0,*idx1,*n1,&tr1_t,&tr2_t,&ncond,work+nwu);
439:     /* Computing hyperbolic transformations also for exchanged vectors */
440:     tr1_te.data = work+nwu;
441:     nwu += n;
442:     PetscMemcpy(tr1_te.data,R+(j+1)*ldr,n*sizeof(PetscScalar));
443:     tr2_te.data = work+nwu;
444:     nwu += n;
445:     PetscMemcpy(tr2_te.data,R+j*ldr,n*sizeof(PetscScalar));
446:     MadeHRtr(sz,n,*idx0,*n0,*idx1,*n1,&tr1_te,&tr2_te,&ncond_e,work+nwu);
447:     if (ncond > d*ncond_e) {
448:       *exg = PETSC_TRUE;
449:       tr1 = &tr1_te;
450:       tr2 = &tr2_te;
451:       ncond = ncond_e;
452:     } else {
453:       tr1 = &tr1_t;
454:       tr2 = &tr2_t;
455:     }
456:     if (ncond>tolD) *ok = PETSC_FALSE;
457:   }
458:   if (*ok) {
459:     /* Everything is OK, apply transformations to R and H */
460:     /* First column */
461:     if (cond && *cond<ncond) *cond = ncond;
462:     x = tr1->data;
463:     PetscBLASIntCast(tr1->n[0],&n0_);
464:     PetscBLASIntCast(tr1->n[1],&n1_); 
465:     PetscBLASIntCast(n-j-sz,&mr);
466:     if (tr1->n[0] > 1 && PetscAbsScalar(tr1->tau[0])!=0.0) {
467:       x[tr1->idx[0]] = 1.0;
468:       PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0_,&mr,x+tr1->idx[0],&inc,tr1->tau,R+(j+sz)*ldr+tr1->idx[0],&ldr_,work+nwu));
469:       PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n0_,x+tr1->idx[0],&inc,tr1->tau,H+(tr1->idx[0])*ldh,&ldh_,work+nwu));
470:     }
471:     if (tr1->n[1] > 1 && PetscAbsScalar(tr1->tau[1])!=0.0) {
472:       x[tr1->idx[1]] = 1.0;
473:       PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1_,&mr,x+tr1->idx[1],&inc,tr1->tau+1,R+(j+sz)*ldr+tr1->idx[1],&ldr_,work+nwu));
474:       PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n1_,x+tr1->idx[1],&inc,tr1->tau+1,H+(tr1->idx[1])*ldh,&ldh_,work+nwu));
475:     }
476:     if (tr1->idx[0]<tr1->idx[1]) {
477:       HRApply(mr,R+(j+sz)*ldr+tr1->idx[0],ldr,R+(j+sz)*ldr+tr1->idx[1],ldr,tr1->cs,-tr1->sn);
478:       if (tr1->type==1) {
479:         HRApply(n,H+(tr1->idx[0])*ldh,1,H+(tr1->idx[1])*ldh,1,tr1->cs,tr1->sn);
480:       } else {
481:         HRApply(n,H+(tr1->idx[0])*ldh,1,H+(tr1->idx[1])*ldh,1,-tr1->cs,-tr1->sn);
482:         s[tr1->idx[0]] = -s[tr1->idx[0]];
483:         s[tr1->idx[1]] = -s[tr1->idx[1]];
484:       }
485:     }
486:     for (i=0;i<tr1->idx[0];i++) *(R+j*ldr+i) = x[i];  
487:     for (i=tr1->idx[0]+1;i<n;i++) *(R+j*ldr+i) = 0.0;
488:     *(R+j*ldr+tr1->idx[0]) = tr1->alpha;
489:     if (sz==2) {
490:       y = tr2->data;
491:       /* Second column */
492:       PetscBLASIntCast(tr2->n[0],&n0_);
493:       PetscBLASIntCast(tr2->n[1],&n1_); 
494:       PetscBLASIntCast(n-j-sz,&mr);
495:       PetscBLASIntCast(n-tr2->idx[0],&mh);
496:       if (tr2->n[0] > 1 && PetscAbsScalar(tr2->tau[0])!=0.0) {
497:         y[tr2->idx[0]] = 1.0;
498:         PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0_,&mr,y+tr2->idx[0],&inc,tr2->tau,R+(j+2)*ldr+tr2->idx[0],&ldr_,work+nwu));
499:         PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n0_,y+tr2->idx[0],&inc,tr2->tau,H+(tr2->idx[0])*ldh,&ldh_,work+nwu));
500:       }
501:       if (tr2->n[1] > 1 && PetscAbsScalar(tr2->tau[1])!=0.0) {
502:         y[tr2->idx[1]] = 1.0;
503:         PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1_,&mr,y+tr2->idx[1],&inc,tr2->tau+1,R+(j+2)*ldr+tr2->idx[1],&ldr_,work+nwu));
504:         PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n1_,y+tr2->idx[1],&inc,tr2->tau+1,H+(tr2->idx[1])*ldh,&ldh_,work+nwu));
505:       }
506:       if (tr2->idx[0]<tr2->idx[1]) {
507:         HRApply(mr,R+(j+2)*ldr+tr2->idx[0],ldr,R+(j+2)*ldr+tr2->idx[1],ldr,tr2->cs,-tr2->sn);
508:         if (tr2->type==1) {
509:           HRApply(n,H+(tr2->idx[0])*ldh,1,H+(tr2->idx[1])*ldh,1,tr2->cs,tr2->sn);
510:         } else {
511:           HRApply(n,H+(tr2->idx[0])*ldh,1,H+(tr2->idx[1])*ldh,1,-tr2->cs,-tr2->sn);
512:           s[tr2->idx[0]] = -s[tr2->idx[0]];
513:           s[tr2->idx[1]] = -s[tr2->idx[1]];
514:         }
515:       }
516:       for (i=0;i<tr2->idx[0]-1;i++) *(R+(j+1)*ldr+i) = y[i];
517:       *(R+(j+1)*ldr+tr2->idx[0]-1) = y[tr2->idx[0]-1];
518:       for (i=tr2->idx[0]+1;i<n;i++) *(R+(j+1)*ldr+i) = 0.0;
519:       *(R+(j+1)*ldr+tr2->idx[0]) = tr2->alpha;
520:       *n0 = tr2->n[0];
521:       *n1 = tr2->n[1];
522:       *idx0 = tr2->idx[0];
523:       *idx1 = tr2->idx[1];
524:       if (tr2->idx[0]<tr2->idx[1] && tr2->type==2) {
525:         (*idx1)++; (*n1)--; (*n0)++;
526:       }
527:     } else {
528:       *n0 = tr1->n[0];
529:       *n1 = tr1->n[1];
530:       *idx0 = tr1->idx[0];
531:       *idx1 = tr1->idx[1];
532:       if (tr1->idx[0]<tr1->idx[1] && tr1->type==2) {
533:         (*idx1)++; (*n1)--; (*n0)++;
534:       }      
535:     }
536:     if (*n0>0) {
537:       (*n0)--; (*idx0)++;
538:       if (*n1==0) *idx1 = *idx0;
539:     } else {
540:       (*n1)--; (*idx1)++; *idx0 = *idx1;
541:     }
542:   }
543:   return(0);
544: #endif
545: }

549: /*
550:   compute V = HR whit H s-orthogonal and R upper triangular
551: */
552: static PetscErrorCode PseudoOrthog_HR(PetscInt *nv,PetscScalar *V,PetscInt ldv,PetscReal *s,PetscScalar *R,PetscInt ldr,PetscBLASInt *perm,PetscBLASInt *cmplxEig,PetscBool *breakdown,PetscScalar *work)
553: {
555:   PetscInt       i,j,n,n0,n1,np,idx0,idx1,sz=1,k=0,t1,t2,nwu=0;
556:   PetscScalar    *col1,*col2;
557:   PetscBool      exg=PETSC_FALSE,ok=PETSC_FALSE;

560:   n = *nv;
561:   col1 = work+nwu;
562:   nwu += n;
563:   col2 = work+nwu;
564:   nwu += n;
565:   /* Sort R and s according to sing(s) */
566:   np = 0;
567:   for (i=0;i<n;i++) if (s[i]>0) np++;
568:   if (s[0]>0) n1 = np;
569:   else n1 = n-np;
570:   n0 = 0;
571:   for (i=0;i<n;i++) {
572:     if (s[i]==s[0]) {
573:       s[n0] = s[0];
574:       perm[n0++] = i;
575:     } else perm[n1++] = i;
576:   }
577:   for (i=n0;i<n;i++) s[i] = -s[0];
578:   n1 -= n0;
579:   idx0 = 0;
580:   idx1 = n0;
581:   if (idx1==n) idx1=idx0;
582:   for (i=0;i<n;i++) {
583:     for (j=0;j<n;j++) R[j*ldr+i] = V[j*ldv+perm[i]];
584:   }
585:   /* Initialize H */
586:   for (i=0;i<n;i++) {
587:     PetscMemzero(V+i*ldv,n*sizeof(PetscScalar));
588:     V[perm[i]+i*ldv] = 1.0;
589:   }
590:   for (i=0;i<n;i++) perm[i] = i;
591:   j = 0;
592:   while (j<n-k) {
593:     if (cmplxEig[j]==0) sz=1;
594:     else sz=2;
595:     TryHRIt(n,j,sz,V,ldv,R,ldr,s,&exg,&ok,&n0,&n1,&idx0,&idx1,NULL,work+nwu);
596:     if (ok) {
597:       if (exg) cmplxEig[j] = -cmplxEig[j];
598:       j = j+sz;
599:     } else { /* to be discarded */
600:       k = k+1;
601:       if (cmplxEig[j]==0) {
602:         if (j<n) {
603:           t1 = perm[j];
604:           for (i=j;i<n-1;i++) perm[i] = perm[i+1];
605:           perm[n-1] = t1;
606:           t1 = cmplxEig[j];
607:           for (i=j;i<n-1;i++) cmplxEig[i] = cmplxEig[i+1];
608:           cmplxEig[n-1] = t1;
609:           PetscMemcpy(col1,R+j*ldr,n*sizeof(PetscScalar));
610:           for (i=j;i<n-1;i++) { 
611:             PetscMemcpy(R+i*ldr,R+(i+1)*ldr,n*sizeof(PetscScalar));
612:           }
613:           PetscMemcpy(R+(n-1)*ldr,col1,n*sizeof(PetscScalar));
614:         }
615:       } else {
616:         k = k+1;
617:         if (j<n-1) {
618:           t1 = perm[j];
619:           t2 = perm[j+1];
620:           for (i=j;i<n-2;i++) perm[i] = perm[i+2];
621:           perm[n-2] = t1;
622:           perm[n-1] = t2;
623:           t1 = cmplxEig[j];
624:           t2 = cmplxEig[j+1];
625:           for (i=j;i<n-2;i++) cmplxEig[i] = cmplxEig[i+2];
626:           cmplxEig[n-2] = t1;
627:           cmplxEig[n-1] = t2;
628:           PetscMemcpy(col1,R+j*ldr,n*sizeof(PetscScalar));
629:           PetscMemcpy(col2,R+(j+1)*ldr,n*sizeof(PetscScalar));
630:           for (i=j;i<n-2;i++) {
631:             PetscMemcpy(R+i*ldr,R+(i+2)*ldr,n*sizeof(PetscScalar));
632:           }
633:           PetscMemcpy(R+(n-2)*ldr,col1,n*sizeof(PetscScalar));
634:           PetscMemcpy(R+(n-1)*ldr,col2,n*sizeof(PetscScalar));
635:         }
636:       }
637:     }
638:   }
639:   if (k!=0) {
640:     if (breakdown) *breakdown = PETSC_TRUE;
641:     *nv = n-k;
642:   }
643:   return(0);
644: }

648: PetscErrorCode DSGHIEPOrthogEigenv(DS ds,DSMatType mat,PetscScalar *wr,PetscScalar *wi,PetscBool accum)
649: {
651:   PetscInt       lws,nwus=0,nwui=0,lwi;
652:   PetscInt       off,n,nv,ld,i,ldr,l;
653:   PetscScalar    *W,*X,*R,*ts,zeroS=0.0,oneS=1.0;
654:   PetscReal      *s,vi,vr,tr,*d,*e;
655:   PetscBLASInt   ld_,n_,nv_,*perm,*cmplxEig;

658:   l = ds->l;
659:   n = ds->n-l;
660:   PetscBLASIntCast(n,&n_);
661:   ld = ds->ld;
662:   PetscBLASIntCast(ld,&ld_);
663:   off = l*ld+l;
664:   s = ds->rmat[DS_MAT_D];
665:   if (!ds->compact) {
666:     for (i=l;i<ds->n;i++) s[i] = PetscRealPart(*(ds->mat[DS_MAT_B]+i*ld+i));
667:   }
668:   lws = n*n+7*n;
669:   lwi = 2*n;
670:   DSAllocateWork_Private(ds,lws,0,lwi);
671:   R = ds->work+nwus;
672:   nwus += n*n;
673:   ldr = n;
674:   perm = ds->iwork + nwui;
675:   nwui += n;
676:   cmplxEig = ds->iwork+nwui;
677:   X = ds->mat[mat];
678:   for (i=0;i<n;i++) {
679: #if defined(PETSC_USE_COMPLEX)
680:     vi = PetscImaginaryPart(wr[l+i]);
681: #else
682:     vi = PetscRealPart(wi[l+i]);
683: #endif
684:     if (vi!=0) {
685:       cmplxEig[i] = 1;
686:       cmplxEig[i+1] = 2;
687:       i++;
688:     } else cmplxEig[i] = 0;
689:   }
690:   nv = n;
691:   
692:   /* Perform HR decomposition */
693:   /* Hyperbolic rotators */
694:   PseudoOrthog_HR(&nv,X+off,ld,s+l,R,ldr,perm,cmplxEig,NULL,ds->work+nwus);
695:   /* Sort wr,wi perm */ 
696:   ts = ds->work+nwus;
697:   PetscMemcpy(ts,wr+l,n*sizeof(PetscScalar));
698:   for (i=0;i<n;i++) wr[i+l] = ts[perm[i]];
699: #if !defined(PETSC_USE_COMPLEX)
700:   PetscMemcpy(ts,wi+l,n*sizeof(PetscScalar));
701:   for (i=0;i<n;i++) wi[i+l] = ts[perm[i]];
702: #endif
703:   /* Projected Matrix */
704:   PetscMemzero(ds->rmat[DS_MAT_T]+2*ld,ld*sizeof(PetscReal));
705:   d = ds->rmat[DS_MAT_T];
706:   e = d+ld;
707:   for (i=0;i<nv;i++) {
708:     if (cmplxEig[i]==0) { /* Real */
709:       d[l+i] = PetscRealPart(wr[l+i]*s[l+i]);
710:       e[l+i] = 0.0;
711:     } else {
712:       vr = PetscRealPart(wr[l+i]);
713: #if defined(PETSC_USE_COMPLEX)
714:       vi = PetscImaginaryPart(wr[l+i]);
715: #else
716:       vi = PetscRealPart(wi[l+i]);
717: #endif
718:       if (cmplxEig[i]==-1) vi = -vi;
719:       tr = PetscRealPart((R[i+(i+1)*ldr]/R[i+i*ldr]))*vi;
720:       d[l+i] = (vr-tr)*s[l+i];
721:       d[l+i+1] = (vr+tr)*s[l+i+1];
722:       e[l+i] = PetscRealPart(s[l+i]*(R[(i+1)+(i+1)*ldr]/R[i+i*ldr])*vi);
723:       e[l+i+1] = 0.0;
724:       i++;
725:     }
726:   }
727:   /* accumulate previous Q */
728:   if (accum) {
729:     PetscBLASIntCast(nv,&nv_);
730:     DSAllocateMat_Private(ds,DS_MAT_W);
731:     W = ds->mat[DS_MAT_W];
732:     DSCopyMatrix_Private(ds,DS_MAT_W,DS_MAT_Q);
733:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n_,&nv_,&n_,&oneS,W+off,&ld_,X+off,&ld_,&zeroS,ds->mat[DS_MAT_Q]+off,&ld_));
734:   } else {
735:     PetscMemzero(ds->mat[DS_MAT_Q],ld*ld*sizeof(PetscScalar));
736:     for (i=0;i<ds->l;i++) *(ds->mat[DS_MAT_Q]+i+i*ld) = 1.0;
737:     for (i=0;i<n;i++) { PetscMemcpy(ds->mat[DS_MAT_Q]+off+i*ld,X+off+i*ld,n*sizeof(PetscScalar)); }
738:   }
739:   ds->t = nv+l;
740:   if (!ds->compact) { DSSwitchFormat_GHIEP(ds,PETSC_FALSE); }  
741:   return(0);
742: }

746: /*
747:    Reduce to tridiagonal-diagonal pair by means of TridiagDiag_HHR.
748: */
749: PetscErrorCode DSIntermediate_GHIEP(DS ds)
750: {
752:   PetscInt       i,ld,off;
753:   PetscInt       nwall,nwallr,nwalli;
754:   PetscScalar    *A,*B,*Q;
755:   PetscReal      *d,*e,*s;

758:   ld = ds->ld;
759:   A = ds->mat[DS_MAT_A];
760:   B = ds->mat[DS_MAT_B];
761:   Q = ds->mat[DS_MAT_Q];
762:   d = ds->rmat[DS_MAT_T];
763:   e = ds->rmat[DS_MAT_T]+ld;
764:   s = ds->rmat[DS_MAT_D];
765:   off = ds->l+ds->l*ld;
766:   PetscMemzero(Q,ld*ld*sizeof(PetscScalar));
767:   nwall = ld*ld+ld;
768:   nwallr = ld;
769:   nwalli = ld;
770:   DSAllocateWork_Private(ds,nwall,nwallr,nwalli);
771:   for (i=0;i<ds->n;i++) Q[i+i*ld]=1.0;
772:   for (i=0;i<ds->n-ds->l;i++) *(ds->perm+i)=i;
773:   if (ds->compact) {
774:     if (ds->state < DS_STATE_INTERMEDIATE) {
775:       DSSwitchFormat_GHIEP(ds,PETSC_FALSE);
776:       TridiagDiag_HHR(ds->k-ds->l+1,A+off,ld,s+ds->l,Q+off,ld,PETSC_TRUE,d+ds->l,e+ds->l,ds->perm,ds->work,ds->rwork,ds->iwork);
777:       ds->k = ds->l;
778:       PetscMemzero(d+2*ld+ds->l,(ds->n-ds->l)*sizeof(PetscReal));
779:     }
780:   } else {
781:     if (ds->state < DS_STATE_INTERMEDIATE) {
782:       for (i=0;i<ds->n;i++) s[i] = PetscRealPart(B[i+i*ld]);
783:       TridiagDiag_HHR(ds->n-ds->l,A+off,ld,s+ds->l,Q+off,ld,PETSC_FALSE,d+ds->l,e+ds->l,ds->perm,ds->work,ds->rwork,ds->iwork);
784:       PetscMemzero(d+2*ld,(ds->n)*sizeof(PetscReal));
785:       ds->k = ds->l;
786:       DSSwitchFormat_GHIEP(ds,PETSC_FALSE);
787:     } else {
788:       DSSwitchFormat_GHIEP(ds,PETSC_TRUE);
789:     }
790:   }
791:   return(0);
792: }

slepc-3.7.4/src/sys/classes/ds/impls/ghiep/dqds.c.html0000644000175000017500000016167313107004621022133 0ustar jromanjroman
Actual source code: dqds.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    DQDS-type dense solver for generalized symmetric-indefinite eigenproblem.
  3:    Based on Matlab code from Carla Ferreira.

  5:    References:

  7:        [1] C. Ferreira, B. Parlett, "Real DQDS for the nonsymmetric tridiagonal
  8:            eigenvalue problem", preprint, 2012.

 10:        [2] C. Ferreira. The unsymmetric tridiagonal eigenvalue problem. Ph.D
 11:            Thesis, University of Minho, 2007.

 13:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 14:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 15:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 17:    This file is part of SLEPc.

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

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

 28:    You  should have received a copy of the GNU Lesser General  Public  License
 29:    along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 30:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 31: */
 32: #include <slepc/private/dsimpl.h>
 33: #include <slepcblaslapack.h>

 37: /*
 38:   INPUT:
 39:     a ---- diagonal of J
 40:     b ---- subdiagonal of J;
 41:     the superdiagonal of J is all 1's

 43:   OUTPUT:
 44:     For an eigenvalue lambda of J we have:
 45:       gl=<real(lambda)<=gr
 46:       -sigma=<imag(lambda)<=sigma
 47: */
 48: static PetscErrorCode ScanJ(PetscInt n,PetscReal *a,PetscReal *b,PetscReal *gl,PetscReal *gr,PetscReal *sigma)
 49: {
 50:   PetscInt  i;
 51:   PetscReal b0,b1,rad;

 54:   /* For original matrix C, C_bal=T+S; T-symmetric and S=skew-symmetric
 55:    C_bal is the balanced form of C */
 56:   /* Bounds on the imaginary part of C (Gersgorin bound for S)*/
 57:   *sigma = 0.0;
 58:   b0 = 0.0;
 59:   for (i=0;i<n-1;i++) {
 60:     if (b[i]<0.0) b1 = PetscSqrtReal(-b[i]);
 61:     else b1 = 0.0;
 62:     *sigma = PetscMax(*sigma,b1+b0);
 63:     b0 = b1;
 64:   }
 65:   *sigma = PetscMax(*sigma,b0);
 66:   /* Gersgorin bounds for T (=Gersgorin bounds on the real part for C) */
 67:   rad = (b[0]>0.0)?PetscSqrtReal(b[0]):0.0; /* rad = b1+b0, b0 = 0 */
 68:   *gr = a[0]+rad;
 69:   *gl = a[0]-rad;
 70:   b0 = rad;
 71:   for (i=1;i<n-1;i++) {
 72:     b1 = (b[i]>0.0)?PetscSqrtReal(b[i]):0.0;
 73:     rad = b0+b1;
 74:     *gr = PetscMax(*gr,a[i]+rad);
 75:     *gl = PetscMin(*gl,a[i]-rad);
 76:     b0 = b1;
 77:   }
 78:   rad = b0;
 79:   *gr = PetscMax(*gr,a[n-1]+rad);
 80:   *gl = PetscMin(*gl,a[n-1]-rad);
 81:   return(0);
 82: }

 86: /*
 87:   INPUT:
 88:     a  - vector with the diagonal elements
 89:     b  - vector with the subdiagonal elements
 90:     gl - Gersgorin left bound (real axis)
 91:     gr - Gersgorin right bound (real axis)
 92:   OUTPUT:
 93:     eigvalue - multiple eigenvalue (if there is an eigenvalue)
 94:     m        - its multiplicity    (m=0 if there isn't a multiple eigenvalue)
 95:     X        - matrix of generalized eigenvectors
 96:     shift
 97:     dim(work)=5*n+4
 98: */
 99: static PetscErrorCode Prologue(PetscInt n,PetscReal *a,PetscReal *b,PetscReal gl,PetscReal gr,PetscInt *m,PetscReal *shift,PetscReal *work)
100: {

103:   PetscReal      mu,tol,*a1,*y,*yp,*x,*xp;
104:   PetscInt       i,k;

107:   *m = 0;
108:   mu = 0.0;
109:   for (i=0;i<n;i++) mu += a[i];
110:   mu /= n;
111:   tol = n*PETSC_MACHINE_EPSILON*(gr-gl);
112:   a1 = work; /* size n */
113:   y = work+n; /* size n+1 */
114:   yp = y+n+1; /* size n+1. yp is the derivative of y (p for "prime") */
115:   x = yp+n+1; /* size n+1 */
116:   xp = x+n+1; /* size n+1 */
117:   for (i=0;i<n;i++) a1[i] = mu-a[i];
118:   x[0] = 1;
119:   xp[0] = 0;
120:   x[1] = a1[0];
121:   xp[1] = 1;
122:   for (i=1;i<n;i++) {
123:     x[i+1]=a1[i]*x[i]-b[i-1]*x[i-1];
124:     xp[i+1]=a1[i]*xp[i]+x[i]-b[i-1]*xp[i-1];
125:   }
126:   *shift = mu;
127:   if (PetscAbsReal(x[n])<tol) {
128:     /* mu is an eigenvalue */
129:     *m = *m+1;
130:     if (PetscAbsReal(xp[n])<tol) {
131:       /* mu is a multiple eigenvalue; Is it the one-point spectrum case? */
132:       k = 0;
133:       while (PetscAbsReal(xp[n])<tol && k<n-1) {
134:         PetscMemcpy(x,y,(n+1)*sizeof(PetscReal));
135:         PetscMemcpy(xp,yp,(n+1)*sizeof(PetscReal));
136:         x[k] = 0.0;
137:         k++;
138:         x[k] = 1.0;
139:         xp[k] = 0.0;
140:         x[k+1] = a1[k] + y[k];
141:         xp[k+1] = 1+yp[k];
142:         for (i=k+1;i<n;i++) {
143:           x[i+1] = a1[i]*x[i]-b[i-1]*x[i-1]+y[i];
144:           xp[i+1]=a1[i]*xp[i]+x[i]-b[i-1]*xp[i-1]+yp[i];
145:         }
146:         *m = *m+1;
147:       }
148:     }
149:   }
150: /*
151:   When mu is not an eigenvalue or it it an eigenvalue but it is not the one-point spectrum case, we will always have shift=mu

153:   Need to check for overflow!

155:   After calling Prologue, eigenComplexdqds and eigen3dqds will test if m==n in which case we have the one-point spectrum case;
156:   If m!=0, the only output to be used is the shift returned.
157: */
158:   return(0);
159: }

163: static PetscErrorCode LUfac(PetscInt n,PetscReal *a,PetscReal *b,PetscReal shift,PetscReal tol,PetscReal norm,PetscReal *L,PetscReal *U,PetscInt *fail,PetscReal *work)
164: {
165:   PetscInt       i;
166:   PetscReal      *a1;

169:   a1 = work;
170:   for (i=0;i<n;i++) a1[i] = a[i]-shift;
171:   *fail = 0;
172:   for (i=0;i<n-1;i++) {
173:     U[i] = a1[i];
174:     L[i] = b[i]/U[i];
175:     a1[i+1] = a1[i+1]-L[i];
176:   }
177:   U[n-1] = a1[n-1];

179:   /* Check if there are NaN values */
180:   for (i=0;i<n-1 && !*fail;i++) {
181:     if (PetscIsInfOrNanReal(L[i])) *fail=1;
182:     if (PetscIsInfOrNanReal(U[i])) *fail=1;
183:   }
184:   if (!*fail && PetscIsInfOrNanReal(U[n-1])) *fail=1;

186:   for (i=0;i<n-1 && !*fail;i++) {
187:     if (PetscAbsReal(L[i])>tol*norm) *fail = 1;  /* This demands IEEE arithmetic */
188:     if (PetscAbsReal(U[i])>tol*norm) *fail = 1;
189:   }
190:   if (!*fail && PetscAbsReal(U[n-1])>tol*norm) *fail = 1;
191:   return(0);
192: }

196: static PetscErrorCode RealDQDS(PetscInt n,PetscReal *L,PetscReal *U,PetscReal shift,PetscReal tol,PetscReal norm,PetscReal *L1,PetscReal *U1,PetscInt *fail)
197: {
198:   PetscReal d;
199:   PetscInt  i;

202:   *fail = 0;
203:   d = U[0]-shift;
204:   for (i=0;i<n-1;i++) {
205:     U1[i] = d+L[i];
206:     L1[i] = L[i]*(U[i+1]/U1[i]);
207:     d = d*(U[i+1]/U1[i])-shift;
208:   }
209:   U1[n-1]=d;

211:   /* The following demands IEEE arithmetic */
212:   for (i=0;i<n-1 && !*fail;i++) {
213:     if (PetscIsInfOrNanReal(L1[i])) *fail=1;
214:     if (PetscIsInfOrNanReal(U1[i])) *fail=1;
215:   }
216:   if (!*fail && PetscIsInfOrNanReal(U1[n-1])) *fail=1;
217:   for (i=0;i<n-1 && !*fail;i++) {
218:     if (PetscAbsReal(L1[i])>tol*norm) *fail=1;
219:     if (PetscAbsReal(U1[i])>tol*norm) *fail=1;
220:   }
221:   if (!*fail && PetscAbsReal(U1[n-1])>tol*norm) *fail=1;
222:   return(0);
223: }

227: static PetscErrorCode TridqdsZhuang3(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscInt *fail)
228: {
229:   PetscReal xl,yl,xr,yr,zr;
230:   PetscInt  i;

233:   *fail = 0;
234:   xr = 1.0;
235:   yr = e[0];
236:   zr = 0.0;
237:   /* Step 1 */
238:   /* the efect of Z1 */
239:   xr = xr*q[0]+yr;
240:   /* the inverse of L1 */
241:   xl = (q[0]+e[0])*(q[0]+e[0])+q[1]*e[0]-sum*(q[0]+e[0])+prod;
242:   yl = -(q[2]*e[1]*q[1]*e[0])/xl;
243:   xl = -(q[1]*e[0]*(q[0]+e[0]+q[1]+e[1]-sum))/xl;
244:   /* the efect of L1 */
245:   q[0] = xr-xl;
246:   xr = yr-xl;
247:   yr = zr-yl-xl*e[1];
248:   /*the inverse of Y1 */
249:   xr = xr/q[0];
250:   yr = yr/q[0];
251:   /*the effect of Y1 inverse */
252:   e[0] = xl+yr+xr*q[1];
253:   xl = yl+zr+yr*q[2];      /* zr=0  when n=3 */
254:   /*the effect of Y1 */
255:   xr = 1.0-xr;
256:   yr = e[1]-yr;

258:   /* STEP n-1 */

260:   if (PetscAbsReal(e[n-3])>tolDef*PetscAbsReal(xl) || PetscAbsReal(e[n-3])>tolDef*PetscAbsReal(q[n-3])) {
261:     /* the efect of Zn-1 */
262:     xr = xr*q[n-2]+yr;
263:     /* the inverse of Ln-1 */
264:     xl = -xl/e[n-3];
265:     /* the efect of Ln-1 */
266:     q[n-2] = xr-xl;
267:     xr = yr-xl;
268:     /*the inverse of Yn-1 */
269:     xr = xr/q[n-2];
270:     /*the effect of the inverse of Yn-1 */
271:     e[n-2] = xl+xr*q[n-1];
272:     /*the effects of Yn-1 */
273:     xr = 1.0-xr;
274:     /* STEP n */
275:     /*the effect of Zn */
276:     xr = xr*q[n-1];
277:     /*the inverse of Ln=I */
278:     /*the effect of Ln */
279:     q[n-1] = xr;
280:     /* the inverse of  Yn-1=I */

282:   } else { /* Free deflation */
283:     e[n-2] = (e[n-3]+(xr*q[n-2]+yr)+q[n-1])*0.5;       /* Sum=trace/2 */
284:     q[n-2] = (e[n-3]+q[n-2]*xr)*q[n-1]-xl;             /* det */
285:     q[n-1] = e[n-2]*e[n-2]-q[n-2];
286:     *fail = 2;
287:   }

289:   /* The following demands IEEE arithmetic */
290:   for (i=0;i<n-1 && !*fail;i++) {
291:     if (PetscIsInfOrNanReal(e[i])) *fail=1;
292:     if (PetscIsInfOrNanReal(q[i])) *fail=1;
293:   }
294:   if (!*fail && PetscIsInfOrNanReal(q[n-1])) *fail=1;
295:   for (i=0;i<n-1 && !*fail;i++) {
296:     if (PetscAbsReal(e[i])>tol*norm) *fail=1;
297:     if (PetscAbsReal(q[i])>tol*norm) *fail=1;
298:   }
299:   if (!*fail && PetscAbsReal(q[n-1])>tol*norm) *fail=1;
300:   return(0);
301: }

305: static PetscErrorCode TridqdsZhuang(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscReal *e1,PetscReal *q1,PetscInt *fail)
306: {
308:   PetscInt       i;
309:   PetscReal      xl,yl,xr,yr,zr;

312:   for (i=0;i<n-1;i++) {
313:     e1[i] = e[i];
314:     q1[i] = q[i];
315:   }
316:   q1[n-1] = q[n-1];
317:   *fail = 0;
318:   if (n>3) {   /* For n>3 */
319:     *fail = 0;
320:     xr = 1;
321:     yr = e1[0];
322:     zr = 0;
323:     /* step 1 */
324:     /* the efect of Z1 */
325:     xr = xr*q1[0]+yr;
326:     /* the inverse of L1 */
327:     xl = (q1[0]+e1[0])*(q1[0]+e1[0])+q1[1]*e1[0]-sum*(q1[0]+e1[0])+prod;
328:     yl = -(q1[2]*e1[1]*q1[1]*e1[0])/xl;
329:     xl = -(q1[1]*e1[0]*(q1[0]+e1[0]+q1[1]+e1[1]-sum))/xl;
330:     /* the efect of L1 */
331:     q1[0] = xr-xl;
332:     xr = yr-xl;
333:     yr = zr-yl-xl*e1[1];
334:     zr = -yl*e1[2];
335:     /* the inverse of Y1 */
336:     xr = xr/q1[0];
337:     yr = yr/q1[0];
338:     zr = zr/q1[0];
339:     /* the effect of Y1 inverse */
340:     e1[0] = xl+yr+xr*q1[1];
341:     xl = yl+zr+yr*q1[2];
342:     yl = zr*q1[3];
343:     /* the effect of Y1 */
344:     xr = 1-xr;
345:     yr = e1[1]-yr;
346:     zr = -zr;
347:     /* step i=2,...,n-3 */
348:     for (i=1;i<n-3;i++) {
349:       /* the efect of Zi */
350:       xr = xr*q1[i]+yr;
351:       /* the inverse of Li */
352:       xl = -xl/e1[i-1];
353:       yl = -yl/e1[i-1];
354:       /* the efect of Li */
355:       q1[i] = xr-xl;
356:       xr = yr-xl;
357:       yr = zr-yl-xl*e1[i+1];
358:       zr = -yl*e1[i+2];
359:       /* the inverse of Yi */
360:       xr = xr/q1[i];
361:       yr = yr/q1[i];
362:       zr = zr/q1[i];
363:       /* the effect of the inverse of Yi */
364:       e1[i] = xl+yr+xr*q1[i+1];
365:       xl = yl+zr+yr*q1[i+2];
366:       yl = zr*q1[i+3];
367:       /* the effects of Yi */
368:       xr = 1.0-xr;
369:       yr = e1[i+1]-yr;
370:       zr = -zr;
371:     }

373:     /* STEP n-2            zr is no longer needed */

375:     /* the efect of Zn-2 */
376:     xr = xr*q1[n-3]+yr;
377:     /* the inverse of Ln-2 */
378:     xl = -xl/e1[n-4];
379:     yl = -yl/e1[n-4];
380:     /* the efect of Ln-2 */
381:     q1[n-3] = xr-xl;
382:     xr = yr-xl;
383:     yr = zr-yl-xl*e1[n-2];
384:     /* the inverse of Yn-2 */
385:     xr = xr/q1[n-3];
386:     yr = yr/q1[n-3];
387:     /* the effect of the inverse of Yn-2 */
388:     e1[n-3] = xl+yr+xr*q1[n-2];
389:     xl = yl+yr*q1[n-1];
390:     /* the effect of Yn-2 */
391:     xr = 1.0-xr;
392:     yr = e1[n-2]-yr;

394:     /* STEP n-1           yl and yr are no longer needed */
395:     /* Testing for EARLY DEFLATION */

397:     if (PetscAbsReal(e1[n-3])>tolDef*PetscAbsReal(xl) || PetscAbsReal(e1[n-3])>tolDef*PetscAbsReal(q1[n-3])) {
398:       /* the efect of Zn-1 */
399:       xr = xr*q1[n-2]+yr;
400:       /* the inverse of Ln-1 */
401:       xl = -xl/e1[n-3];
402:       /* the efect of Ln-1 */
403:       q1[n-2] = xr-xl;
404:       xr = yr-xl;
405:       /*the inverse of Yn-1 */
406:       xr = xr/q1[n-2];
407:       /*the effect of the inverse of Yn-1 */
408:       e1[n-2] = xl+xr*q1[n-1];
409:       /*the effects of Yn-1 */
410:       xr = 1.0-xr;

412:       /* STEP n;     xl no longer needed */
413:       /* the effect of Zn */
414:       xr = xr*q1[n-1];
415:       /* the inverse of Ln = I */
416:       /* the effect of Ln */
417:       q1[n-1] = xr;
418:       /* the inverse of  Yn-1=I */

420:     } else {  /* FREE DEFLATION */
421:       e1[n-2] = (e1[n-3]+xr*q1[n-2]+yr+q1[n-1])*0.5;     /* sum=trace/2 */
422:       q1[n-2] = (e1[n-3]+q1[n-2]*xr)*q1[n-1]-xl;         /* det */
423:       q1[n-1] = e1[n-2]*e1[n-2]-q1[n-2];
424:       *fail = 2;
425:     }

427:     for (i=0;i<n-1 && !*fail;i++) {
428:       if (PetscIsInfOrNanReal(e1[i])) *fail=1;
429:       if (PetscIsInfOrNanReal(q1[i])) *fail=1;
430:     }
431:     if (!*fail && PetscIsInfOrNanReal(q1[n-1])) *fail=1;
432:     for (i=0;i<n-1 && !*fail;i++) {
433:       if (PetscAbsReal(e1[i])>tol*norm) *fail = 1;  /* This demands IEEE arithmetic */
434:       if (PetscAbsReal(q1[i])>tol*norm) *fail = 1;
435:     }
436:     if (!*fail && PetscAbsReal(q1[n-1])>tol*norm) *fail = 1;

438:   } else {  /* The case n=3 */
439:     TridqdsZhuang3(n,e1,q1,sum,prod,tol,norm,tolDef,fail);
440:   }
441:   return(0);
442: }

446: static PetscErrorCode DSGHIEP_Eigen3DQDS(PetscInt n,PetscReal *a,PetscReal *b,PetscReal *c,PetscScalar *wr,PetscScalar *wi,PetscReal *work)
447: {
448:   PetscInt       totalIt=0;       /* Total Number of Iterations  */
449:   PetscInt       totalFail=0;     /* Total number of failures */
450:   PetscInt       nFail=0;         /* Number of failures per transformation */
451:   PetscReal      tolZero=1.0/16;  /* Tolerance for zero shifts */
452:   PetscInt       maxIt=10*n;      /* Maximum number of iterations */
453:   PetscInt       maxFail=10*n;    /* Maximum number of failures allowed per each transformation */
454:   PetscReal      tolDef=PETSC_MACHINE_EPSILON;  /* Tolerance for deflation eps, 10*eps, 100*eps */
455:   PetscReal      tolGrowth=100000;
457:   PetscInt       i,k,nwu=0,begin,ind,flag,dim,m,*split,lastSplit;
458:   PetscReal      norm,gr,gl,sigma,delta,meanEig,*U,*L,*U1,*L1;
459:   PetscReal      acShift,initialShift,shift=0.0,sum,det,disc,prod,x1,x2;
460:   PetscBool      test1,test2;

463:   dim = n;
464:   /* Test if the matrix is unreduced */
465:   for (i=0;i<n-1;i++) {
466:     if (PetscAbsReal(b[i])==0.0 || PetscAbsReal(c[i])==0.0) SETERRQ(PETSC_COMM_SELF,1,"Initial tridiagonal matrix is not unreduced");
467:   }
468:   U = work;
469:   L = work+n;
470:   U1 = work+2*n;
471:   L1 = work+3*n;
472:   nwu = 4*n;
473:   if (wi) {
474:     PetscMemzero(wi,n*sizeof(PetscScalar));
475:   }
476:   /* Normalization - the J form of C */
477:   for (i=0;i<n-1;i++) b[i] *= c[i]; /* subdiagonal of the J form */

479:   /* Scan matrix J  ---- Finding a box of inclusion for the eigenvalues */
480:   norm = 0.0;
481:   for (i=0;i<n-1;i++) {
482:     norm = PetscMax(norm,PetscMax(PetscAbsReal(a[i]),PetscAbsReal(b[i])));
483:   }
484:   norm = PetscMax(norm,PetscMax(1,PetscAbsReal(a[n-1])));
485:   ScanJ(n,a,b,&gl,&gr,&sigma);
486:   delta = (gr-gl)/n; /* How much to add to the shift, in case of failure (element growth) */
487:   meanEig = 0.0;
488:   for (i=0;i<n;i++) meanEig += a[i];
489:   meanEig /= n; /* shift = initial shift = mean of eigenvalues */
490:   Prologue(n,a,b,gl,gr,&m,&shift,work+nwu);
491:   if (m==n) { /* Multiple eigenvalue, we have the one-point spectrum case */
492:     for (i=0;i<dim;i++) {
493:       wr[i] = shift;
494:       if (wi) wi[i] = 0.0;
495:     }
496:     return(0);
497:   }
498:   /* Initial LU Factorization */
499:   if (delta==0.0) shift=0.0;  /* The case when all eigenvalues are pure imaginary */
500:   LUfac(n,a,b,shift,tolGrowth,norm,L,U,&flag,work+nwu); /* flag=1 failure; flag=0 successful transformation*/
501:   while (flag==1 && nFail<maxFail) {
502:     shift=shift+delta;
503:     if (shift>gr || shift<gl) { /* Successive failures */
504:       shift=meanEig;
505:       delta=-delta;
506:     }
507:     nFail=nFail+1;
508:     LUfac(n,a,b,shift,tolGrowth,norm,L,U,&flag,work+nwu); /* flag=1 failure; flag=0 successful transformation*/
509:   }
510:   if (nFail==maxFail) SETERRQ(PETSC_COMM_SELF,1,"Maximun number of failures reached in Initial LU factorization");
511:   /* Successful Initial transformation */
512:   totalFail = totalFail+nFail;
513:   nFail = 0;
514:   acShift = 0;
515:   initialShift = shift;
516:   shift = 0;
517:   begin = 0;
518:   lastSplit = 0;
519:   PetscMalloc1(n,&split);
520:   split[lastSplit] = begin;
521:   while (begin!=-1) {
522:     while (n-begin>2 && totalIt<maxIt) {
523:       /* Check for deflation before performing a transformation */
524:       test1 = (PetscAbsReal(L[n-2])<tolDef*PetscAbsReal(U[n-2])
525:             && PetscAbsReal(L[n-2])<tolDef*PetscAbsReal(U[n-1]+acShift)
526:             && PetscAbsReal(L[n-2]*U[n])<tolDef*PetscAbsReal(acShift+U[n-1])
527:             && PetscAbsReal(L[n-2])*(PetscAbsReal(U[n-2])+1)<tolDef*PetscAbsReal(acShift+U[n-1]))? PETSC_TRUE: PETSC_FALSE;
528:       if (flag==2) {  /* Early 2x2 deflation */
529:         test2 = PETSC_TRUE;
530:       } else {
531:         if (n-begin>4) {
532:           test2 = (PetscAbsReal(L[n-3])<tolDef*PetscAbsReal(U[n-3])
533:                && PetscAbsReal(L[n-3]*(U[n-4]+L[n-4]))< tolDef*PetscAbsReal(U[n-4]*(U[n-3]+L[n-3])+L[n-4]*L[n-3]))? PETSC_TRUE: PETSC_FALSE;
534:         } else { /* n-begin+1=3 */
535:           test2 = (PetscAbsReal(L[begin])<tolDef*PetscAbsReal(U[begin]))? PETSC_TRUE: PETSC_FALSE;
536:         }
537:       }
538:       while (test2 || test1) {
539:         /* 2x2 deflation */
540:         if (test2) {
541:           if (flag==2) { /* Early deflation */
542:             sum = L[n-2];
543:             det = U[n-2];
544:             disc = U[n-1];
545:             flag = 0;
546:           } else {
547:             sum = (L[n-2]+(U[n-2]+U[n-1]))/2;
548:             disc = (L[n-2]*(L[n-2]+2*(U[n-2]+U[n-1]))+(U[n-2]-U[n-1])*(U[n-2]-U[n-1]))/4;
549:             det = U[n-2]*U[n-1];
550:           }
551:           if (disc<=0) {
552: #if !defined(PETSC_USE_COMPLEX)
553:             wr[--n] = sum+acShift; if (wi) wi[n] = PetscSqrtReal(-disc);
554:             wr[--n] = sum+acShift; if (wi) wi[n] = -PetscSqrtReal(-disc);
555: #else
556:             wr[--n] = sum-PETSC_i*PetscSqrtReal(-disc)+acShift; if (wi) wi[n] = 0.0;
557:             wr[--n] = sum+PETSC_i*PetscSqrtReal(-disc)+acShift; if (wi) wi[n] = 0.0;
558: #endif
559:           } else {
560:             if (sum==0.0) {
561:               x1 = PetscSqrtReal(disc);
562:               x2 = -x1;
563:             } else {
564:               x1 = ((sum>=0.0)?1.0:-1.0)*(PetscAbsReal(sum)+PetscSqrtReal(disc));
565:               x2 = det/x1;
566:             }
567:             wr[--n] = x1+acShift;
568:             wr[--n] = x2+acShift;
569:           }
570:         } else { /* test1 -- 1x1 deflation */
571:           x1 = U[n-1]+acShift;
572:           wr[--n] = x1;
573:         }

575:         if (n<=begin+2) {
576:           break;
577:         } else {
578:           test1 = (PetscAbsReal(L[n-2])<tolDef*PetscAbsReal(U[n-2])
579:                 && PetscAbsReal(L[n-2])<tolDef*PetscAbsReal(U[n-1]+acShift)
580:                 && PetscAbsReal(L[n-2]*U[n-1])<tolDef*PetscAbsReal(acShift+U[n-1])
581:                 && PetscAbsReal(L[n-2])*(PetscAbsReal(U[n-2])+1)< tolDef*PetscAbsReal(acShift+U[n-1]))? PETSC_TRUE: PETSC_FALSE;
582:           if (n-begin>4) {
583:             test2 = (PetscAbsReal(L[n-3])<tolDef*PetscAbsReal(U[n-3])
584:                   && PetscAbsReal(L[n-3]*(U[n-4]+L[n-4]))< tolDef*PetscAbsReal(U[n-4]*(U[n-3]+L[n-3])+L[n-4]*L[n-3]))? PETSC_TRUE: PETSC_FALSE;
585:           } else { /* n-begin+1=3 */
586:             test2 = (PetscAbsReal(L[begin])<tolDef*PetscAbsReal(U[begin]))? PETSC_TRUE: PETSC_FALSE;
587:           }
588:         }
589:       } /* end "WHILE deflations" */
590:       /* After deflation */
591:       if (n>begin+3) {
592:         ind = begin;
593:         for (k=n-4;k>=begin+1;k--) {
594:           if (PetscAbsReal(L[k])<tolDef*PetscAbsReal(U[k])
595:            && PetscAbsReal(L[k]*U[k+1]*(U[k+2]+L[k+2])*(U[k-1]+L[k-1]))<tolDef*PetscAbsReal((U[k-1]*(U[k]+L[k])+L[k-1]*L[k])*(U[k+1]*(U[k+2]+L[k+2])+L[k+1]*L[k+2]))) {
596:             ind=k;
597:             break;
598:           }
599:         }
600:         if (ind>begin || PetscAbsReal(L[begin]) <tolDef*PetscAbsReal(U[begin])) {
601:           lastSplit = lastSplit+1;
602:           split[lastSplit] = begin;
603:           L[ind] = acShift; /* Use of L[ind] to save acShift */
604:           begin = ind+1;
605:         }
606:       }

608:       if (n>begin+2) {
609:         disc = (L[n-2]*(L[n-2]+2*(U[n-2]+U[n-1]))+(U[n-2]-U[n-1])*(U[n-2]-U[n-1]))/4;
610:         if ((PetscAbsReal(L[n-2])>tolZero) && (PetscAbsReal(L[n-3])>tolZero)) { /* L's are big */
611:           shift = 0;
612:           RealDQDS(n-begin,L+begin,U+begin,0,tolGrowth,norm,L1+begin,U1+begin,&flag);
613:           if (flag) {  /* Failure */
614:             TridqdsZhuang(n-begin,L+begin,U+begin,0.0,0.0,tolGrowth,norm,tolDef,L1+begin,U1+begin,&flag);
615:             shift = 0.0;
616:             while (flag==1 && nFail<maxFail) {  /* Successive failures */
617:               shift = shift+delta;
618:               if (shift>gr-acShift || shift<gl-acShift) {
619:                 shift = meanEig-acShift;
620:                 delta = -delta;
621:               }
622:               nFail++;
623:               RealDQDS(n-begin,L+begin,U+begin,0,tolGrowth,norm,L1+begin,U1+begin,&flag);
624:             }
625:           }
626:         } else { /* L's are small */
627:           if (disc<0) {  /* disc <0   Complex case; Francis shift; 3dqds */
628:             sum = U[n-2]+L[n-2]+U[n-1];
629:             prod = U[n-2]*U[n-1];
630:             TridqdsZhuang(n-begin,L+begin,U+begin,sum,prod,tolGrowth,norm,tolDef,L1+begin,U1+begin,&flag);
631:             shift = 0.0; /* Restoring transformation */
632:             while (flag==1 && nFail<maxFail) { /* In case of failure */
633:               shift = shift+U[n-1];  /* first time shift=0 */
634:               RealDQDS(n-begin,L+begin,U+begin,shift,tolGrowth,norm,L1+begin,U1+begin,&flag);
635:               nFail++;
636:             }
637:           } else  { /* disc >0  Real case; real Wilkinson shift; dqds */
638:             sum = (L[n-2]+U[n-2]+U[n-1])/2;
639:             if (sum==0.0) {
640:               x1 = PetscSqrtReal(disc);
641:               x2 = -x1;
642:             } else {
643:               x1 = ((sum>=0)?1.0:-1.0)*(PetscAbsReal(sum)+PetscSqrtReal(disc));
644:               x2 = U[n-2]*U[n-1]/x1;
645:             }
646:             /* Take the eigenvalue closest to UL(n,n) */
647:             if (PetscAbsReal(x1-U[n-1])<PetscAbsReal(x2-U[n-1])) {
648:               shift = x1;
649:             } else {
650:               shift = x2;
651:             }
652:             RealDQDS(n-begin,L+begin,U+begin,shift,tolGrowth,norm,L1+begin,U1+begin,&flag);
653:             /* In case of failure */
654:             while (flag==1 && nFail<maxFail) {
655:               sum = 2*shift;
656:               prod = shift*shift;
657:               TridqdsZhuang(n-1-begin,L+begin,U+begin,sum,prod,tolGrowth,norm,tolDef,L1+begin,U1+begin,&flag);
658:               /* In case of successive failures */
659:               if (shift==0.0) {
660:                 shift = PetscMin(PetscAbsReal(L[n-2]),PetscAbsReal(L[n-3]))*delta;
661:               } else {
662:                 shift=shift+delta;
663:               }
664:               if (shift>gr-acShift || shift<gl-acShift) {
665:                 shift = meanEig-acShift;
666:                 delta = -delta;
667:               }
668:               if (!flag) { /* We changed from real dqds to 3dqds */
669:                 shift=0;
670:               }
671:               nFail++;
672:             }
673:           }
674:         } /* end "if tolZero" */
675:         if (nFail==maxFail) SETERRQ(PETSC_COMM_SELF,1,"Maximun number of failures reached. No convergence in DQDS");
676:         /* Successful Transformation; flag==0 */
677:         totalIt++;
678:         acShift = shift+acShift;
679:         for (i=begin;i<n-1;i++) {
680:           L[i] = L1[i];
681:           U[i] = U1[i];
682:         }
683:         U[n-1] = U1[n-1];
684:         totalFail = totalFail+nFail;
685:         nFail = 0;
686:       }  /* end "if n>begin+1" */
687:     }  /* end WHILE 1 */
688:     if (totalIt>=maxIt) SETERRQ(PETSC_COMM_SELF,1,"Maximun number of iterations reached. No convergence in DQDS");
689:     /* END: n=2 or n=1  % n=begin+1 or n=begin */
690:     if (n==begin+2) {
691:       sum = (L[n-2]+U[n-2]+U[n-1])/2;
692:       disc = (L[n-2]*(L[n-2]+2*(U[n-2]+U[n-1]))+(U[n-2]-U[n-1])*(U[n-2]-U[n-1]))/4;
693:       if (disc<=0) {  /* Complex case */
694:         /* Deflation 2 */
695: #if !defined(PETSC_USE_COMPLEX)
696:         wr[--n] = sum+acShift; if (wi) wi[n] = PetscSqrtReal(-disc);
697:         wr[--n] = sum+acShift; if (wi) wi[n] = -PetscSqrtReal(-disc);
698: #else
699:         wr[--n] = sum-PETSC_i*PetscSqrtReal(-disc)+acShift; if (wi) wi[n] = 0.0;
700:         wr[--n] = sum+PETSC_i*PetscSqrtReal(-disc)+acShift; if (wi) wi[n] = 0.0;
701: #endif
702:       } else { /* Real case */
703:         if (sum==0.0) {
704:           x1 = PetscSqrtReal(disc);
705:           x2 = -x1;
706:         } else {
707:           x1 = ((sum>=0)?1.0:-1.0)*(PetscAbsReal(sum)+PetscSqrtReal(disc));
708:           x2 = U[n-2]*U[n-1]/x1;
709:         }
710:         /* Deflation 2 */
711:         wr[--n] = x2+acShift;
712:         wr[--n] = x1+acShift;
713:       }
714:     } else { /* n=1   n=begin */
715:       /* deflation 1 */
716:       x1 = U[n-1]+acShift;
717:       wr[--n] = x1;
718:     }
719:     switch (n) {
720:       case 0:
721:         begin = -1;
722:         break;
723:       case 1:
724:         acShift = L[begin-1];
725:         begin = split[lastSplit];
726:         lastSplit--;
727:         break;
728:       default : /* n>=2 */
729:         acShift = L[begin-1];
730:         begin = split[lastSplit];
731:         lastSplit--;
732:     }
733:   }/* While begin~=-1 */
734:   for (i=0;i<dim;i++) {
735:     wr[i] = wr[i]+initialShift;
736:   }
737:   PetscFree(split);
738:   return(0);
739: }

743: PetscErrorCode DSSolve_GHIEP_DQDS_II(DS ds,PetscScalar *wr,PetscScalar *wi)
744: {
746:   PetscInt       i,off,ld,nwall,nwu;
747:   PetscScalar    *A,*B,*Q,*vi;
748:   PetscReal      *d,*e,*s,*a,*b,*c;

751: #if !defined(PETSC_USE_COMPLEX)
753: #endif
754:   ld = ds->ld;
755:   off = ds->l + ds->l*ld;
756:   A = ds->mat[DS_MAT_A];
757:   B = ds->mat[DS_MAT_B];
758:   Q = ds->mat[DS_MAT_Q];
759:   d = ds->rmat[DS_MAT_T];
760:   e = ds->rmat[DS_MAT_T] + ld;
761:   s = ds->rmat[DS_MAT_D];
762:   /* Quick return if possible */
763:   if (ds->n-ds->l == 1) {
764:     *(Q+off) = 1;
765:     if (!ds->compact) {
766:       d[ds->l] = PetscRealPart(A[off]);
767:       s[ds->l] = PetscRealPart(B[off]);
768:     }
769:     wr[ds->l] = d[ds->l]/s[ds->l];
770:     if (wi) wi[ds->l] = 0.0;
771:     return(0);
772:   }
773:   nwall = 12*ld+4;
774:   DSAllocateWork_Private(ds,0,nwall,0);
775:   /* Reduce to pseudotriadiagonal form */
776:   DSIntermediate_GHIEP(ds);

778:   /* Compute Eigenvalues (DQDS) */
779:   /* Form pseudosymmetric tridiagonal */
780:   a = ds->rwork;
781:   b = a+ld;
782:   c = b+ld;
783:   nwu = 3*ld;
784:   if (ds->compact) {
785:     for (i=ds->l;i<ds->n-1;i++) {
786:       a[i] = d[i]*s[i];
787:       b[i] = e[i]*s[i+1];
788:       c[i] = e[i]*s[i];
789:     }
790:     a[ds->n-1] = d[ds->n-1]*s[ds->n-1];
791:   } else {
792:     for (i=ds->l;i<ds->n-1;i++) {
793:       a[i] = PetscRealPart(A[i+i*ld]*B[i+i*ld]);
794:       b[i] = PetscRealPart(A[i+1+i*ld]*s[i+1]);
795:       c[i] = PetscRealPart(A[i+(i+1)*ld]*s[i]);
796:     }
797:     a[ds->n-1] = PetscRealPart(A[ds->n-1+(ds->n-1)*ld]*B[ds->n-1+(ds->n-1)*ld]);
798:   }
799:   vi = (wi)?wi+ds->l:NULL;
800:   DSGHIEP_Eigen3DQDS(ds->n-ds->l,a+ds->l,b+ds->l,c+ds->l,wr+ds->l,vi,ds->rwork+nwu);

802:   /* Compute Eigenvectors with Inverse Iteration */
803:   DSGHIEPInverseIteration(ds,wr,wi);

805:   /* Recover eigenvalues from diagonal */
806:   DSGHIEPComplexEigs(ds,0,ds->l,wr,wi);
807: #if defined(PETSC_USE_COMPLEX)
808:   if (wi) {
809:     for (i=ds->l;i<ds->n;i++) wi[i] = 0.0;
810:   }
811: #endif
812:   return(0);
813: }

slepc-3.7.4/src/sys/classes/ds/impls/ghiep/dsghiep.c0000644000175000017500000010324513107004621021647 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "DSAllocate_GHIEP" PetscErrorCode DSAllocate_GHIEP(DS ds,PetscInt ld) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_B);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_Q);CHKERRQ(ierr); ierr = DSAllocateMatReal_Private(ds,DS_MAT_T);CHKERRQ(ierr); ierr = DSAllocateMatReal_Private(ds,DS_MAT_D);CHKERRQ(ierr); ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSwitchFormat_GHIEP" PetscErrorCode DSSwitchFormat_GHIEP(DS ds,PetscBool tocompact) { PetscErrorCode ierr; PetscReal *T,*S; PetscScalar *A,*B; PetscInt i,n,ld; PetscFunctionBegin; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; T = ds->rmat[DS_MAT_T]; S = ds->rmat[DS_MAT_D]; n = ds->n; ld = ds->ld; if (tocompact) { /* switch from dense (arrow) to compact storage */ ierr = PetscMemzero(T,3*ld*sizeof(PetscReal));CHKERRQ(ierr); ierr = PetscMemzero(S,ld*sizeof(PetscReal));CHKERRQ(ierr); for (i=0;il;i< ds->k;i++) T[2*ld+i] = PetscRealPart(A[ds->k+i*ld]); } else { /* switch from compact (arrow) to dense storage */ ierr = PetscMemzero(A,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMemzero(B,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;il;ik;i++) { A[ds->k+i*ld] = T[2*ld+i]; A[i+ds->k*ld] = T[2*ld+i]; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView_GHIEP" PetscErrorCode DSView_GHIEP(DS ds,PetscViewer viewer) { PetscErrorCode ierr; PetscViewerFormat format; PetscInt i,j; PetscReal value; const char *methodname[] = { "HR method", "QR + Inverse Iteration", "QR", "DQDS + Inverse Iteration " }; const int nmeth=sizeof(methodname)/sizeof(methodname[0]); PetscFunctionBegin; ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) { if (ds->method>=nmeth) { ierr = PetscViewerASCIIPrintf(viewer,"solving the problem with: INVALID METHOD\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"solving the problem with: %s\n",methodname[ds->method]);CHKERRQ(ierr); } PetscFunctionReturn(0); } if (ds->compact) { ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_MATLAB) { ierr = PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",ds->n,ds->n);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"zzz = zeros(%D,3);\n",3*ds->n);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"zzz = [\n");CHKERRQ(ierr); for (i=0;in;i++) { ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_T]+i));CHKERRQ(ierr); } for (i=0;in-1;i++) { if (*(ds->rmat[DS_MAT_T]+ds->ld+i) !=0 && i!=ds->k-1) { ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",i+2,i+1,*(ds->rmat[DS_MAT_T]+ds->ld+i));CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",i+1,i+2,*(ds->rmat[DS_MAT_T]+ds->ld+i));CHKERRQ(ierr); } } for (i = ds->l;ik;i++) { if (*(ds->rmat[DS_MAT_T]+2*ds->ld+i)) { ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",ds->k+1,i+1,*(ds->rmat[DS_MAT_T]+2*ds->ld+i));CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",i+1,ds->k+1,*(ds->rmat[DS_MAT_T]+2*ds->ld+i));CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(zzz);\n",DSMatName[DS_MAT_A]);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",ds->n,ds->n);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"omega = zeros(%D,3);\n",3*ds->n);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"omega = [\n");CHKERRQ(ierr); for (i=0;in;i++) { ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_D]+i));CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(omega);\n",DSMatName[DS_MAT_B]);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"T\n");CHKERRQ(ierr); for (i=0;in;i++) { for (j=0;jn;j++) { if (i==j) value = *(ds->rmat[DS_MAT_T]+i); else if (i==j+1 || j==i+1) value = *(ds->rmat[DS_MAT_T]+ds->ld+PetscMin(i,j)); else if ((ik && j==ds->k) || (i==ds->k && jk)) value = *(ds->rmat[DS_MAT_T]+2*ds->ld+PetscMin(i,j)); else value = 0.0; ierr = PetscViewerASCIIPrintf(viewer," %18.16e ",value);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"omega\n");CHKERRQ(ierr); for (i=0;in;i++) { for (j=0;jn;j++) { if (i==j) value = *(ds->rmat[DS_MAT_D]+i); else value = 0.0; ierr = PetscViewerASCIIPrintf(viewer," %18.16e ",value);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerFlush(viewer);CHKERRQ(ierr); } else { ierr = DSViewMat(ds,viewer,DS_MAT_A);CHKERRQ(ierr); ierr = DSViewMat(ds,viewer,DS_MAT_B);CHKERRQ(ierr); } if (ds->state>DS_STATE_INTERMEDIATE) { ierr = DSViewMat(ds,viewer,DS_MAT_Q);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_GHIEP_Eigen_Some" static PetscErrorCode DSVectors_GHIEP_Eigen_Some(DS ds,PetscInt *idx,PetscReal *rnorm) { #if defined(SLEPC_MISSING_LAPACK_LAG2) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAG2 - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscReal b[4],M[4],d1,d2,s1,s2,e; PetscReal scal1,scal2,wr1,wr2,wi,ep,norm; PetscScalar *Q,*X,Y[4],alpha,zeroS = 0.0; PetscInt k; PetscBLASInt two = 2,n_,ld,one=1; #if !defined(PETSC_USE_COMPLEX) PetscBLASInt four=4; #endif PetscFunctionBegin; X = ds->mat[DS_MAT_X]; Q = ds->mat[DS_MAT_Q]; k = *idx; ierr = PetscBLASIntCast(ds->n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); if (k < ds->n-1) { e = (ds->compact)?*(ds->rmat[DS_MAT_T]+ld+k):PetscRealPart(*(ds->mat[DS_MAT_A]+(k+1)+ld*k)); } else e = 0.0; if (e == 0.0) {/* Real */ if (ds->state>=DS_STATE_CONDENSED) { ierr = PetscMemcpy(X+k*ld,Q+k*ld,ld*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemzero(X+k*ds->ld,ds->ld*sizeof(PetscScalar));CHKERRQ(ierr); X[k+k*ds->ld] = 1.0; } if (rnorm) { *rnorm = PetscAbsScalar(X[ds->n-1+k*ld]); } } else { /* 2x2 block */ if (ds->compact) { s1 = *(ds->rmat[DS_MAT_D]+k); d1 = *(ds->rmat[DS_MAT_T]+k); s2 = *(ds->rmat[DS_MAT_D]+k+1); d2 = *(ds->rmat[DS_MAT_T]+k+1); } else { s1 = PetscRealPart(*(ds->mat[DS_MAT_B]+k*ld+k)); d1 = PetscRealPart(*(ds->mat[DS_MAT_A]+k+k*ld)); s2 = PetscRealPart(*(ds->mat[DS_MAT_B]+(k+1)*ld+k+1)); d2 = PetscRealPart(*(ds->mat[DS_MAT_A]+k+1+(k+1)*ld)); } M[0] = d1; M[1] = e; M[2] = e; M[3]= d2; b[0] = s1; b[1] = 0.0; b[2] = 0.0; b[3] = s2; ep = LAPACKlamch_("S"); /* Compute eigenvalues of the block */ PetscStackCallBLAS("LAPACKlag2",LAPACKlag2_(M,&two,b,&two,&ep,&scal1,&scal2,&wr1,&wr2,&wi)); if (wi==0.0) /* Real eigenvalues */ SETERRQ(PETSC_COMM_SELF,1,"Real block in DSVectors_GHIEP"); else { /* Complex eigenvalues */ if (scal1state >= DS_STATE_CONDENSED) { alpha = norm; PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n_,&two,&two,&alpha,ds->mat[DS_MAT_Q]+k*ld,&ld,Y,&two,&zeroS,X+k*ld,&ld)); if (rnorm) *rnorm = SlepcAbsEigenvalue(X[ds->n-1+k*ld],X[ds->n-1+(k+1)*ld]); } else { ierr = PetscMemzero(X+k*ld,2*ld*sizeof(PetscScalar));CHKERRQ(ierr); X[k*ld+k] = Y[0]*norm; X[k*ld+k+1] = Y[1]*norm; X[(k+1)*ld+k] = Y[2]*norm; X[(k+1)*ld+k+1] = Y[3]*norm; } #else if (SlepcAbs(s1*d1-wr1,wi)state >= DS_STATE_CONDENSED) { alpha = norm; PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&two,&alpha,ds->mat[DS_MAT_Q]+k*ld,&ld,Y,&one,&zeroS,X+k*ld,&one)); if (rnorm) *rnorm = PetscAbsScalar(X[ds->n-1+k*ld]); } else { ierr = PetscMemzero(X+k*ld,2*ld*sizeof(PetscScalar));CHKERRQ(ierr); X[k*ld+k] = Y[0]*norm; X[k*ld+k+1] = Y[1]*norm; } X[(k+1)*ld+k] = PetscConj(X[k*ld+k]); X[(k+1)*ld+k+1] = PetscConj(X[k*ld+k+1]); #endif (*idx)++; } } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSVectors_GHIEP" PetscErrorCode DSVectors_GHIEP(DS ds,DSMatType mat,PetscInt *k,PetscReal *rnorm) { PetscInt i; PetscReal e; PetscErrorCode ierr; PetscFunctionBegin; switch (mat) { case DS_MAT_X: case DS_MAT_Y: if (k) { ierr = DSVectors_GHIEP_Eigen_Some(ds,k,rnorm);CHKERRQ(ierr); } else { for (i=0; in; i++) { e = (ds->compact)?*(ds->rmat[DS_MAT_T]+ds->ld+i):PetscRealPart(*(ds->mat[DS_MAT_A]+(i+1)+ds->ld*i)); if (e == 0.0) {/* real */ if (ds->state >= DS_STATE_CONDENSED) { ierr = PetscMemcpy(ds->mat[mat]+i*ds->ld,ds->mat[DS_MAT_Q]+i*ds->ld,ds->ld*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemzero(ds->mat[mat]+i*ds->ld,ds->ld*sizeof(PetscScalar));CHKERRQ(ierr); *(ds->mat[mat]+i+i*ds->ld) = 1.0; } } else { ierr = DSVectors_GHIEP_Eigen_Some(ds,&i,rnorm);CHKERRQ(ierr); } } } break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGHIEPComplexEigs" /* Extract the eigenvalues contained in the block-diagonal of the indefinite problem. Only the index range n0..n1 is processed. */ PetscErrorCode DSGHIEPComplexEigs(DS ds,PetscInt n0,PetscInt n1,PetscScalar *wr,PetscScalar *wi) { #if defined(SLEPC_MISSING_LAPACK_LAG2) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAG2 - Lapack routine is unavailable"); #else PetscInt k,ld; PetscBLASInt two=2; PetscScalar *A,*B; PetscReal *D,*T; PetscReal b[4],M[4],d1,d2,s1,s2,e; PetscReal scal1,scal2,ep,wr1,wr2,wi1; PetscFunctionBegin; ld = ds->ld; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; D = ds->rmat[DS_MAT_D]; T = ds->rmat[DS_MAT_T]; for (k=n0;kcompact)?T[ld+k]:PetscRealPart(A[(k+1)+ld*k]); } else { e = 0.0; } if (e==0.0) { /* real eigenvalue */ wr[k] = (ds->compact)?T[k]/D[k]:A[k+k*ld]/B[k+k*ld]; #if !defined(PETSC_USE_COMPLEX) wi[k] = 0.0 ; #endif } else { /* diagonal block */ if (ds->compact) { s1 = D[k]; d1 = T[k]; s2 = D[k+1]; d2 = T[k+1]; } else { s1 = PetscRealPart(B[k*ld+k]); d1 = PetscRealPart(A[k+k*ld]); s2 = PetscRealPart(B[(k+1)*ld+k+1]); d2 = PetscRealPart(A[k+1+(k+1)*ld]); } M[0] = d1; M[1] = e; M[2] = e; M[3]= d2; b[0] = s1; b[1] = 0.0; b[2] = 0.0; b[3] = s2; ep = LAPACKlamch_("S"); /* Compute eigenvalues of the block */ PetscStackCallBLAS("LAPACKlag2",LAPACKlag2_(M,&two,b,&two,&ep,&scal1,&scal2,&wr1,&wr2,&wi1)); if (scal1n; d = ds->rmat[DS_MAT_T]; e = d + ds->ld; s = ds->rmat[DS_MAT_D]; ierr = DSAllocateWork_Private(ds,ds->ld,ds->ld,0);CHKERRQ(ierr); perm = ds->perm; if (!rr) { rr = wr; ri = wi; } ierr = DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_TRUE);CHKERRQ(ierr); if (!ds->compact) { ierr = DSSwitchFormat_GHIEP(ds,PETSC_TRUE);CHKERRQ(ierr); } ierr = PetscMemcpy(ds->work,wr,n*sizeof(PetscScalar));CHKERRQ(ierr); for (i=ds->l;iwork+perm[i]); #if !defined(PETSC_USE_COMPLEX) ierr = PetscMemcpy(ds->work,wi,n*sizeof(PetscScalar));CHKERRQ(ierr); for (i=ds->l;iwork+perm[i]); #endif ierr = PetscMemcpy(ds->rwork,s,n*sizeof(PetscReal));CHKERRQ(ierr); for (i=ds->l;irwork+perm[i]); ierr = PetscMemcpy(ds->rwork,d,n*sizeof(PetscReal));CHKERRQ(ierr); for (i=ds->l;irwork+perm[i]); ierr = PetscMemcpy(ds->rwork,e,(n-1)*sizeof(PetscReal));CHKERRQ(ierr); ierr = PetscMemzero(e+ds->l,(n-1-ds->l)*sizeof(PetscScalar));CHKERRQ(ierr); for (i=ds->l;irwork+perm[i]); } if (!ds->compact) { ierr = DSSwitchFormat_GHIEP(ds,PETSC_FALSE);CHKERRQ(ierr); } ierr = DSPermuteColumns_Private(ds,ds->l,n,DS_MAT_Q,perm);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGHIEPInverseIteration" /* Get eigenvectors with inverse iteration. The system matrix is in Hessenberg form. */ PetscErrorCode DSGHIEPInverseIteration(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(SLEPC_MISSING_LAPACK_HSEIN) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"HSEIN - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,off; PetscBLASInt *select,*infoC,ld,n1,mout,info; PetscScalar *A,*B,*H,*X; PetscReal *s,*d,*e; #if defined(PETSC_USE_COMPLEX) PetscInt j; #endif PetscFunctionBegin; ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->n-ds->l,&n1);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,ld*ld+2*ld,ld,2*ld);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; H = ds->mat[DS_MAT_W]; s = ds->rmat[DS_MAT_D]; d = ds->rmat[DS_MAT_T]; e = d + ld; select = ds->iwork; infoC = ds->iwork + ld; off = ds->l+ds->l*ld; if (ds->compact) { H[off] = d[ds->l]*s[ds->l]; H[off+ld] = e[ds->l]*s[ds->l]; for (i=ds->l+1;in-1;i++) { H[i+(i-1)*ld] = e[i-1]*s[i]; H[i+i*ld] = d[i]*s[i]; H[i+(i+1)*ld] = e[i]*s[i]; } H[ds->n-1+(ds->n-2)*ld] = e[ds->n-2]*s[ds->n-1]; H[ds->n-1+(ds->n-1)*ld] = d[ds->n-1]*s[ds->n-1]; } else { s[ds->l] = PetscRealPart(B[off]); H[off] = A[off]*s[ds->l]; H[off+ld] = A[off+ld]*s[ds->l]; for (i=ds->l+1;in-1;i++) { s[i] = PetscRealPart(B[i+i*ld]); H[i+(i-1)*ld] = A[i+(i-1)*ld]*s[i]; H[i+i*ld] = A[i+i*ld]*s[i]; H[i+(i+1)*ld] = A[i+(i+1)*ld]*s[i]; } s[ds->n-1] = PetscRealPart(B[ds->n-1+(ds->n-1)*ld]); H[ds->n-1+(ds->n-2)*ld] = A[ds->n-1+(ds->n-2)*ld]*s[ds->n-1]; H[ds->n-1+(ds->n-1)*ld] = A[ds->n-1+(ds->n-1)*ld]*s[ds->n-1]; } ierr = DSAllocateMat_Private(ds,DS_MAT_X);CHKERRQ(ierr); X = ds->mat[DS_MAT_X]; for (i=0;il,wi+ds->l,NULL,&ld,X+off,&ld,&n1,&mout,ds->work,NULL,infoC,&info)); #else PetscStackCallBLAS("LAPACKhsein",LAPACKhsein_("R","N","N",select,&n1,H+off,&ld,wr+ds->l,NULL,&ld,X+off,&ld,&n1,&mout,ds->work,ds->rwork,NULL,infoC,&info)); /* Separate real and imaginary part of complex eigenvectors */ for (j=ds->l;jn;j++) { if (PetscAbsReal(PetscImaginaryPart(wr[j])) > PetscAbsScalar(wr[j])*PETSC_SQRT_MACHINE_EPSILON) { for (i=ds->l;in;i++) { X[i+(j+1)*ds->ld] = PetscImaginaryPart(X[i+j*ds->ld]); X[i+j*ds->ld] = PetscRealPart(X[i+j*ds->ld]); } j++; } } #endif if (info<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in hsein routine %D",-i); if (info>0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Convergence error in hsein routine %D",i); ierr = DSGHIEPOrthogEigenv(ds,DS_MAT_X,wr,wi,PETSC_TRUE);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSGHIEPRealBlocks" /* Undo 2x2 blocks that have real eigenvalues. */ PetscErrorCode DSGHIEPRealBlocks(DS ds) { #if defined(SLEPC_MISSING_LAPACK_LAG2) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAG2 - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscReal e,d1,d2,s1,s2,ss1,ss2,t,dd,ss; PetscReal maxy,ep,scal1,scal2,snorm; PetscReal *T,*D,b[4],M[4],wr1,wr2,wi; PetscScalar *A,*B,Y[4],oneS = 1.0,zeroS = 0.0; PetscBLASInt m,two=2,ld; PetscBool isreal; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->n-ds->l,&m);CHKERRQ(ierr); A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; T = ds->rmat[DS_MAT_T]; D = ds->rmat[DS_MAT_D]; ierr = DSAllocateWork_Private(ds,2*m,0,0);CHKERRQ(ierr); for (i=ds->l;in-1;i++) { e = (ds->compact)?T[ld+i]:PetscRealPart(A[(i+1)+ld*i]); if (e != 0.0) { /* 2x2 block */ if (ds->compact) { s1 = D[i]; d1 = T[i]; s2 = D[i+1]; d2 = T[i+1]; } else { s1 = PetscRealPart(B[i*ld+i]); d1 = PetscRealPart(A[i*ld+i]); s2 = PetscRealPart(B[(i+1)*ld+i+1]); d2 = PetscRealPart(A[(i+1)*ld+i+1]); } isreal = PETSC_FALSE; if (s1==s2) { /* apply a Jacobi rotation to compute the eigendecomposition */ dd = d1-d2; if (2*PetscAbsReal(e) <= dd) { t = 2*e/dd; t = t/(1 + PetscSqrtReal(1+t*t)); } else { t = dd/(2*e); ss = (t>=0)?1.0:-1.0; t = ss/(PetscAbsReal(t)+PetscSqrtReal(1+t*t)); } Y[0] = 1/PetscSqrtReal(1 + t*t); Y[3] = Y[0]; /* c */ Y[1] = Y[0]*t; Y[2] = -Y[1]; /* s */ wr1 = d1+t*e; wr2 = d2-t*e; ss1 = s1; ss2 = s2; isreal = PETSC_TRUE; } else { ss1 = 1.0; ss2 = 1.0, M[0] = d1; M[1] = e; M[2] = e; M[3]= d2; b[0] = s1; b[1] = 0.0; b[2] = 0.0; b[3] = s2; ep = LAPACKlamch_("S"); /* Compute eigenvalues of the block */ PetscStackCallBLAS("LAPACKlag2",LAPACKlag2_(M,&two,b,&two,&ep,&scal1,&scal2,&wr1,&wr2,&wi)); if (wi==0.0) { /* Real eigenvalues */ isreal = PETSC_TRUE; if (scal1compact) { D[i] = ss1; T[i] = wr1; D[i+1] = ss2; T[i+1] = wr2; T[ld+i] = 0.0; } else { B[i*ld+i] = ss1; A[i*ld+i] = wr1; B[(i+1)*ld+i+1] = ss2; A[(i+1)*ld+i+1] = wr2; A[(i+1)+ld*i] = 0.0; A[i+ld*(i+1)] = 0.0; } PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&m,&two,&two,&oneS,ds->mat[DS_MAT_Q]+ds->l+i*ld,&ld,Y,&two,&zeroS,ds->work,&m)); ierr = PetscMemcpy(ds->mat[DS_MAT_Q]+ds->l+i*ld,ds->work,m*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMemcpy(ds->mat[DS_MAT_Q]+ds->l+(i+1)*ld,ds->work+m,m*sizeof(PetscScalar));CHKERRQ(ierr); } i++; } } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSSolve_GHIEP_QR_II" PetscErrorCode DSSolve_GHIEP_QR_II(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(PETSC_MISSING_LAPACK_HSEQR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"HSEQR - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,off; PetscBLASInt n1,ld,one,info,lwork; PetscScalar *H,*A,*B,*Q; PetscReal *d,*e,*s; #if defined(PETSC_USE_COMPLEX) PetscInt j; #endif PetscFunctionBegin; #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(wi,3); #endif one = 1; ierr = PetscBLASIntCast(ds->n-ds->l,&n1);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); off = ds->l + ds->l*ld; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; Q = ds->mat[DS_MAT_Q]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T] + ld; s = ds->rmat[DS_MAT_D]; ierr = DSAllocateWork_Private(ds,ld*ld,2*ld,ld*2);CHKERRQ(ierr); lwork = ld*ld; /* Quick return if possible */ if (n1 == 1) { *(Q+off) = 1; if (!ds->compact) { d[ds->l] = PetscRealPart(A[off]); s[ds->l] = PetscRealPart(B[off]); } wr[ds->l] = d[ds->l]/s[ds->l]; if (wi) wi[ds->l] = 0.0; PetscFunctionReturn(0); } /* Reduce to pseudotriadiagonal form */ ierr = DSIntermediate_GHIEP(ds);CHKERRQ(ierr); /* Compute Eigenvalues (QR)*/ ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); H = ds->mat[DS_MAT_W]; if (ds->compact) { H[off] = d[ds->l]*s[ds->l]; H[off+ld] = e[ds->l]*s[ds->l]; for (i=ds->l+1;in-1;i++) { H[i+(i-1)*ld] = e[i-1]*s[i]; H[i+i*ld] = d[i]*s[i]; H[i+(i+1)*ld] = e[i]*s[i]; } H[ds->n-1+(ds->n-2)*ld] = e[ds->n-2]*s[ds->n-1]; H[ds->n-1+(ds->n-1)*ld] = d[ds->n-1]*s[ds->n-1]; } else { s[ds->l] = PetscRealPart(B[off]); H[off] = A[off]*s[ds->l]; H[off+ld] = A[off+ld]*s[ds->l]; for (i=ds->l+1;in-1;i++) { s[i] = PetscRealPart(B[i+i*ld]); H[i+(i-1)*ld] = A[i+(i-1)*ld]*s[i]; H[i+i*ld] = A[i+i*ld]*s[i]; H[i+(i+1)*ld] = A[i+(i+1)*ld]*s[i]; } s[ds->n-1] = PetscRealPart(B[ds->n-1+(ds->n-1)*ld]); H[ds->n-1+(ds->n-2)*ld] = A[ds->n-1+(ds->n-2)*ld]*s[ds->n-1]; H[ds->n-1+(ds->n-1)*ld] = A[ds->n-1+(ds->n-1)*ld]*s[ds->n-1]; } #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKhseqr",LAPACKhseqr_("E","N",&n1,&one,&n1,H+off,&ld,wr+ds->l,wi+ds->l,NULL,&ld,ds->work,&lwork,&info)); #else PetscStackCallBLAS("LAPACKhseqr",LAPACKhseqr_("E","N",&n1,&one,&n1,H+off,&ld,wr+ds->l,NULL,&ld,ds->work,&lwork,&info)); /* Sort to have consecutive conjugate pairs */ for (i=ds->l;in;i++) { j=i+1; while (jn && (PetscAbsScalar(wr[i]-PetscConj(wr[j]))>PetscAbsScalar(wr[i])*PETSC_SQRT_MACHINE_EPSILON)) j++; if (j==ds->n) { if (PetscAbsReal(PetscImaginaryPart(wr[i]))l,wr,wi);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) if (wi) { for (i=ds->l;in;i++) wi[i] = 0.0; } #endif PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSSolve_GHIEP_QR" PetscErrorCode DSSolve_GHIEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(SLEPC_MISSING_LAPACK_GEEVX) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEEVX - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,off,nwu=0,n,lw,lwr,nwru=0; PetscBLASInt n_,ld,info,lwork,ilo,ihi; PetscScalar *H,*A,*B,*Q,*X; PetscReal *d,*s,*scale,nrm,*rcde,*rcdv; #if defined(PETSC_USE_COMPLEX) PetscInt j,k; #endif PetscFunctionBegin; #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(wi,3); #endif n = ds->n-ds->l; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); off = ds->l + ds->l*ld; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; Q = ds->mat[DS_MAT_Q]; d = ds->rmat[DS_MAT_T]; s = ds->rmat[DS_MAT_D]; lw = 14*ld+ld*ld; lwr = 7*ld; ierr = DSAllocateWork_Private(ds,lw,lwr,0);CHKERRQ(ierr); scale = ds->rwork+nwru; nwru += ld; rcde = ds->rwork+nwru; nwru += ld; rcdv = ds->rwork+nwru; nwru += ld; /* Quick return if possible */ if (n_ == 1) { *(Q+off) = 1; if (!ds->compact) { d[ds->l] = PetscRealPart(A[off]); s[ds->l] = PetscRealPart(B[off]); } wr[ds->l] = d[ds->l]/s[ds->l]; if (wi) wi[ds->l] = 0.0; PetscFunctionReturn(0); } /* Form pseudo-symmetric matrix */ H = ds->work+nwu; nwu += n*n; ierr = PetscMemzero(H,n*n*sizeof(PetscScalar));CHKERRQ(ierr); if (ds->compact) { for (i=0;il+i]*d[ds->l+i]; H[i+1+i*n] = s[ds->l+i+1]*d[ld+ds->l+i]; H[i+(i+1)*n] = s[ds->l+i]*d[ld+ds->l+i]; } H[n-1+(n-1)*n] = s[ds->l+n-1]*d[ds->l+n-1]; for (i=0;ik-ds->l;i++) { H[ds->k-ds->l+i*n] = s[ds->k]*d[2*ld+ds->l+i]; H[i+(ds->k-ds->l)*n] = s[i+ds->l]*d[2*ld+ds->l+i]; } } else { for (i=0;ik-ds->l;i++) { H[ds->k-ds->l+i*n] = B[ds->k*(1+ld)]*A[off+ds->k-ds->l+i*ld]; H[i+(ds->k-ds->l)*n] = B[(i+ds->l)*(1+ld)]*A[off+i+(ds->k-ds->l)*ld]; } } /* Compute eigenpairs */ ierr = PetscBLASIntCast(lw-nwu,&lwork);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_X);CHKERRQ(ierr); X = ds->mat[DS_MAT_X]; #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKgeevx",LAPACKgeevx_("B","N","V","N",&n_,H,&n_,wr+ds->l,wi+ds->l,NULL,&ld,X+off,&ld,&ilo,&ihi,scale,&nrm,rcde,rcdv,ds->work+nwu,&lwork,NULL,&info)); #else PetscStackCallBLAS("LAPACKgeevx",LAPACKgeevx_("B","N","V","N",&n_,H,&n_,wr+ds->l,NULL,&ld,X+off,&ld,&ilo,&ihi,scale,&nrm,rcde,rcdv,ds->work+nwu,&lwork,ds->rwork+nwru,&info)); /* Sort to have consecutive conjugate pairs Separate real and imaginary part of complex eigenvectors*/ for (i=ds->l;in;i++) { j=i+1; while (jn && (PetscAbsScalar(wr[i]-PetscConj(wr[j]))>PetscAbsScalar(wr[i])*PETSC_SQRT_MACHINE_EPSILON)) j++; if (j==ds->n) { if (PetscAbsReal(PetscImaginaryPart(wr[i]))l;kn;k++) { X[k+i*ds->ld] = PetscRealPart(X[k+i*ds->ld]); } } else SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Found complex without conjugate pair"); } else { /* complex eigenvalue */ if (j!=i+1) { wr[j] = wr[i+1]; ierr = PetscMemcpy(X+j*ds->ld,X+(i+1)*ds->ld,ds->ld*sizeof(PetscScalar));CHKERRQ(ierr); } if (PetscImaginaryPart(wr[i])<0) { wr[i] = PetscConj(wr[i]); for (k=ds->l;kn;k++) { X[k+(i+1)*ds->ld] = -PetscImaginaryPart(X[k+i*ds->ld]); X[k+i*ds->ld] = PetscRealPart(X[k+i*ds->ld]); } } else { for (k=ds->l;kn;k++) { X[k+(i+1)*ds->ld] = PetscImaginaryPart(X[k+i*ds->ld]); X[k+i*ds->ld] = PetscRealPart(X[k+i*ds->ld]); } } wr[i+1] = PetscConj(wr[i]); i++; } } #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xHSEQR %d",&info); /* Compute real s-orthonormal basis */ ierr = DSGHIEPOrthogEigenv(ds,DS_MAT_X,wr,wi,PETSC_FALSE);CHKERRQ(ierr); /* Recover eigenvalues from diagonal */ ierr = DSGHIEPComplexEigs(ds,0,ds->l,wr,wi);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) if (wi) { for (i=ds->l;in;i++) wi[i] = 0.0; } #endif PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSNormalize_GHIEP" PetscErrorCode DSNormalize_GHIEP(DS ds,DSMatType mat,PetscInt col) { PetscErrorCode ierr; PetscInt i,i0,i1; PetscBLASInt ld,n,one = 1; PetscScalar *A = ds->mat[DS_MAT_A],norm,*x; #if !defined(PETSC_USE_COMPLEX) PetscScalar norm0; #endif PetscFunctionBegin; switch (mat) { case DS_MAT_X: case DS_MAT_Y: case DS_MAT_Q: /* Supported matrices */ break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = DSGetArray(ds,mat,&x);CHKERRQ(ierr); if (col < 0) { i0 = 0; i1 = ds->n; } else if (col>0 && A[ds->ld*(col-1)+col] != 0.0) { i0 = col-1; i1 = col+1; } else { i0 = col; i1 = col+1; } for (i=i0; ild*i+i+1] != 0.0) { norm = BLASnrm2_(&n,&x[ld*i],&one); norm0 = BLASnrm2_(&n,&x[ld*(i+1)],&one); norm = 1.0/SlepcAbsEigenvalue(norm,norm0); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one)); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*(i+1)],&one)); i++; } else #endif { norm = BLASnrm2_(&n,&x[ld*i],&one); norm = 1.0/norm; PetscStackCallBLAS("BLASscal",BLASscal_(&n,&norm,&x[ld*i],&one)); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCreate_GHIEP" PETSC_EXTERN PetscErrorCode DSCreate_GHIEP(DS ds) { PetscFunctionBegin; ds->ops->allocate = DSAllocate_GHIEP; ds->ops->view = DSView_GHIEP; ds->ops->vectors = DSVectors_GHIEP; ds->ops->solve[0] = DSSolve_GHIEP_HZ; ds->ops->solve[1] = DSSolve_GHIEP_QR_II; ds->ops->solve[2] = DSSolve_GHIEP_QR; ds->ops->solve[3] = DSSolve_GHIEP_DQDS_II; ds->ops->sort = DSSort_GHIEP; ds->ops->normalize = DSNormalize_GHIEP; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/ghiep/invit.c0000644000175000017500000006511013107004621021353 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include struct HRtr { PetscScalar *data; PetscInt m; PetscInt idx[2]; PetscInt n[2]; PetscScalar tau[2]; PetscReal alpha; PetscReal cs; PetscReal sn; PetscInt type; }; #undef __FUNCT__ #define __FUNCT__ "HRGen" /* Generates a hyperbolic rotation if x1*x1 - x2*x2 != 0 r = sqrt(|x1*x1 - x2*x2|) c = x1/r s = x2/r | c -s||x1| |d*r| |-s c||x2| = | 0 | where d = 1 for type==1 and -1 for type==2 Returns the condition number of the reduction */ static PetscErrorCode HRGen(PetscReal x1,PetscReal x2,PetscInt *type,PetscReal *c,PetscReal *s,PetscReal *r,PetscReal *cond) { PetscReal t,n2,xa,xb; PetscInt type_; PetscFunctionBegin; if (x2==0.0) { *r = PetscAbsReal(x1); *c = (x1>=0)?1.0:-1.0; *s = 0.0; if (type) *type = 1; PetscFunctionReturn(0); } if (PetscAbsReal(x1) == PetscAbsReal(x2)) { /* hyperbolic rotation doesn't exist */ *c = 0.0; *s = 0.0; *r = 0.0; if (type) *type = 0; *cond = PETSC_MAX_REAL; PetscFunctionReturn(0); } if (PetscAbsReal(x1)>PetscAbsReal(x2)) { xa = x1; xb = x2; type_ = 1; } else { xa = x2; xb = x1; type_ = 2; } t = xb/xa; n2 = PetscAbsReal(1 - t*t); *r = PetscSqrtReal(n2)*PetscAbsReal(xa); *c = x1/(*r); *s = x2/(*r); if (type_ == 2) *r *= -1; if (type) *type = type_; if (cond) *cond = (PetscAbsReal(*c) + PetscAbsReal(*s))/PetscAbsReal(PetscAbsReal(*c) - PetscAbsReal(*s)); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "HRApply" /* |c s| Applies an hyperbolic rotator |s c| |c s| [x1 x2]|s c| */ static PetscErrorCode HRApply(PetscInt n,PetscScalar *x1,PetscInt inc1,PetscScalar *x2,PetscInt inc2,PetscReal c,PetscReal s) { PetscInt i; PetscReal t; PetscScalar tmp; PetscFunctionBegin; if (PetscAbsReal(c)>PetscAbsReal(s)) { /* Type I */ t = s/c; for (i=0;i 1) { PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0,A+ni-n0+j*lda,A+ni-n0+j*lda+1,&inc,&tau)); /* Apply reflector */ if (PetscAbsScalar(tau) != 0.0) { t=*(A+ni-n0+j*lda); *(A+ni-n0+j*lda)=1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&m,&n0,A+ni-n0+j*lda,&inc,&tau,A+j+1+(j+1)*lda,&lda_,work+nwu)); PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0,&m,A+ni-n0+j*lda,&inc,&tau,A+j+1+(j+1)*lda,&lda_,work+nwu)); /* Update Q */ PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n0,A+ni-n0+j*lda,&inc,&tau,Q+(j+1)*ldq,&ldq_,work+nwu)); *(A+ni-n0+j*lda) = t; for (i=1;i 1) { PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1,A+n-n1+j*lda,A+n-n1+j*lda+1,&inc,&tau)); /* Apply reflector */ if (PetscAbsScalar(tau) != 0.0) { t=*(A+n-n1+j*lda); *(A+n-n1+j*lda)=1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&m,&n1,A+n-n1+j*lda,&inc,&tau,A+j+1+(n-n1)*lda,&lda_,work+nwu)); PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1,&m,A+n-n1+j*lda,&inc,&tau,A+n-n1+(j+1)*lda,&lda_,work+nwu)); /* Update Q */ PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n1,A+n-n1+j*lda,&inc,&tau,Q+(n-n1)*ldq,&ldq_,work+nwu)); *(A+n-n1+j*lda) = t; for (i=1;i 0 && n1 > 0) { ierr = HRGen(PetscRealPart(A[ni-n0+j*lda]),PetscRealPart(A[n-n1+j*lda]),&type,&cs,&sn,&r,&cond);CHKERRQ(ierr); /* Check condition number */ if (cond > 1.0/(10*PETSC_SQRT_MACHINE_EPSILON)) { breakdown = PETSC_TRUE; k++; if (k==n || flip) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Breakdown in construction of hyperbolic transformation"); break; } A[ni-n0+j*lda] = r; A[n-n1+j*lda] = 0.0; A[j+(ni-n0)*lda] = r; A[j+(n-n1)*lda] = 0.0; /* Apply to A */ ierr = HRApply(m,A+j+1+(ni-n0)*lda,1,A+j+1+(n-n1)*lda,1,cs,-sn);CHKERRQ(ierr); ierr = HRApply(m,A+ni-n0+(j+1)*lda,lda,A+n-n1+(j+1)*lda,lda,cs,-sn);CHKERRQ(ierr); /* Update Q */ ierr = HRApply(n,Q+(ni-n0)*ldq,1,Q+(n-n1)*ldq,1,cs,-sn);CHKERRQ(ierr); if (type==2) { ss[ni-n0] = -ss[ni-n0]; ss[n-n1] = -ss[n-n1]; n0++;ni++;n1--; } } if (n0>0) n0--; else n1--; } } /* flip matrices */ if (flip) { for (i=0;idata; tr1->n[0] = n0; tr1->n[1] = n1; tr1->idx[0] = idx0; tr1->idx[1] = idx1; ierr = PetscBLASIntCast(tr1->n[0],&n0_);CHKERRQ(ierr); ierr = PetscBLASIntCast(tr1->n[1],&n1_);CHKERRQ(ierr); if (tr1->n[0] > 1) { PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0_,x+tr1->idx[0],x+tr1->idx[0]+1,&inc,tr1->tau)); } if (tr1->n[1]> 1) { PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1_,x+tr1->idx[1],x+tr1->idx[1]+1,&inc,tr1->tau+1)); } if (tr1->idx[0]idx[1]) { ierr = HRGen(PetscRealPart(x[tr1->idx[0]]),PetscRealPart(x[tr1->idx[1]]),&(tr1->type),&(tr1->cs),&(tr1->sn),&(tr1->alpha),ncond);CHKERRQ(ierr); } else { tr1->alpha = PetscRealPart(x[tr1->idx[0]]); *ncond = 1.0; } if (sz==2) { y = tr2->data; /* Apply first transformation to second column */ if (tr1->n[0] > 1 && PetscAbsScalar(tr1->tau[0])!=0.0) { x[tr1->idx[0]] = 1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0_,&inc,x+tr1->idx[0],&inc,tr1->tau,y+tr1->idx[0],&n0_,work)); } if (tr1->n[1] > 1 && PetscAbsScalar(tr1->tau[1])!=0.0) { x[tr1->idx[1]] = 1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1_,&inc,x+tr1->idx[1],&inc,tr1->tau+1,y+tr1->idx[1],&n1_,work)); } if (tr1->idx[0]idx[1]) { ierr = HRApply(1,y+tr1->idx[0],1,y+tr1->idx[1],1,tr1->cs,-tr1->sn);CHKERRQ(ierr); } tr2->n[0] = tr1->n[0]; tr2->n[1] = tr1->n[1]; tr2->idx[0] = tr1->idx[0]; tr2->idx[1] = tr1->idx[1]; if (tr1->idx[0]idx[1] && tr1->type==2) { tr2->idx[1]++; tr2->n[1]--; tr2->n[0]++; } if (tr2->n[0]>0) { tr2->n[0]--; tr2->idx[0]++; if (tr2->n[1]==0) tr2->idx[1] = tr2->idx[0]; } else { tr2->n[1]--; tr2->idx[1]++; tr2->idx[0] = tr2->idx[1]; } /* Hyperbolic transformation to make zeros in y */ ierr = PetscBLASIntCast(tr2->n[0],&n0_);CHKERRQ(ierr); ierr = PetscBLASIntCast(tr2->n[1],&n1_);CHKERRQ(ierr); if (tr2->n[0] > 1) { PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0_,y+tr2->idx[0],y+tr2->idx[0]+1,&inc,tr2->tau)); } if (tr2->n[1]> 1) { PetscStackCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1_,y+tr2->idx[1],y+tr2->idx[1]+1,&inc,tr2->tau+1)); } if (tr2->idx[0]idx[1]) { ierr = HRGen(PetscRealPart(y[tr2->idx[0]]),PetscRealPart(y[tr2->idx[1]]),&(tr2->type),&(tr2->cs),&(tr2->sn),&(tr2->alpha),&ncond2);CHKERRQ(ierr); } else { tr2->alpha = PetscRealPart(y[tr2->idx[0]]); ncond2 = 1.0; } if (ncond2>*ncond) *ncond = ncond2; } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "TryHRIt" /* Auxiliary function to try perform one iteration of hr routine, checking condition number. If it is < tolD, apply the transformation to H and R, if not, ok=false and it do nothing tolE, tolerance to exchange complex pairs to improve conditioning */ static PetscErrorCode TryHRIt(PetscInt n,PetscInt j,PetscInt sz,PetscScalar *H,PetscInt ldh,PetscScalar *R,PetscInt ldr,PetscReal *s,PetscBool *exg,PetscBool *ok,PetscInt *n0,PetscInt *n1,PetscInt *idx0,PetscInt *idx1,PetscReal *cond,PetscScalar *work) { #if defined(SLEPC_MISSING_LAPACK_LARF) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LARF - Lapack routine is unavailable"); #else PetscErrorCode ierr; struct HRtr *tr1,*tr2,tr1_t,tr2_t,tr1_te,tr2_te; PetscScalar *x,*y; PetscReal ncond,ncond_e; PetscInt nwu=0,i,d=1; PetscBLASInt n0_,n1_,inc=1,mh,mr,n_,ldr_,ldh_; PetscReal tolD = 1e+5; PetscFunctionBegin; if (cond) *cond = 1.0; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldr,&ldr_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldh,&ldh_);CHKERRQ(ierr); x = work+nwu; nwu += n; ierr = PetscMemcpy(x,R+j*ldr,n*sizeof(PetscScalar));CHKERRQ(ierr); *exg = PETSC_FALSE; *ok = PETSC_TRUE; tr1_t.data = x; if (sz==1) { /* Hyperbolic transformation to make zeros in x */ ierr = MadeHRtr(sz,n,*idx0,*n0,*idx1,*n1,&tr1_t,NULL,&ncond,work+nwu);CHKERRQ(ierr); /* Check condition number to single column*/ if (ncond>tolD) { *ok = PETSC_FALSE; } tr1 = &tr1_t; tr2 = &tr2_t; } else { y = work+nwu; nwu += n; ierr = PetscMemcpy(y,R+(j+1)*ldr,n*sizeof(PetscScalar));CHKERRQ(ierr); tr2_t.data = y; ierr = MadeHRtr(sz,n,*idx0,*n0,*idx1,*n1,&tr1_t,&tr2_t,&ncond,work+nwu);CHKERRQ(ierr); /* Computing hyperbolic transformations also for exchanged vectors */ tr1_te.data = work+nwu; nwu += n; ierr = PetscMemcpy(tr1_te.data,R+(j+1)*ldr,n*sizeof(PetscScalar));CHKERRQ(ierr); tr2_te.data = work+nwu; nwu += n; ierr = PetscMemcpy(tr2_te.data,R+j*ldr,n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MadeHRtr(sz,n,*idx0,*n0,*idx1,*n1,&tr1_te,&tr2_te,&ncond_e,work+nwu);CHKERRQ(ierr); if (ncond > d*ncond_e) { *exg = PETSC_TRUE; tr1 = &tr1_te; tr2 = &tr2_te; ncond = ncond_e; } else { tr1 = &tr1_t; tr2 = &tr2_t; } if (ncond>tolD) *ok = PETSC_FALSE; } if (*ok) { /* Everything is OK, apply transformations to R and H */ /* First column */ if (cond && *conddata; ierr = PetscBLASIntCast(tr1->n[0],&n0_);CHKERRQ(ierr); ierr = PetscBLASIntCast(tr1->n[1],&n1_);CHKERRQ(ierr); ierr = PetscBLASIntCast(n-j-sz,&mr);CHKERRQ(ierr); if (tr1->n[0] > 1 && PetscAbsScalar(tr1->tau[0])!=0.0) { x[tr1->idx[0]] = 1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0_,&mr,x+tr1->idx[0],&inc,tr1->tau,R+(j+sz)*ldr+tr1->idx[0],&ldr_,work+nwu)); PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n0_,x+tr1->idx[0],&inc,tr1->tau,H+(tr1->idx[0])*ldh,&ldh_,work+nwu)); } if (tr1->n[1] > 1 && PetscAbsScalar(tr1->tau[1])!=0.0) { x[tr1->idx[1]] = 1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1_,&mr,x+tr1->idx[1],&inc,tr1->tau+1,R+(j+sz)*ldr+tr1->idx[1],&ldr_,work+nwu)); PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n1_,x+tr1->idx[1],&inc,tr1->tau+1,H+(tr1->idx[1])*ldh,&ldh_,work+nwu)); } if (tr1->idx[0]idx[1]) { ierr = HRApply(mr,R+(j+sz)*ldr+tr1->idx[0],ldr,R+(j+sz)*ldr+tr1->idx[1],ldr,tr1->cs,-tr1->sn);CHKERRQ(ierr); if (tr1->type==1) { ierr = HRApply(n,H+(tr1->idx[0])*ldh,1,H+(tr1->idx[1])*ldh,1,tr1->cs,tr1->sn);CHKERRQ(ierr); } else { ierr = HRApply(n,H+(tr1->idx[0])*ldh,1,H+(tr1->idx[1])*ldh,1,-tr1->cs,-tr1->sn);CHKERRQ(ierr); s[tr1->idx[0]] = -s[tr1->idx[0]]; s[tr1->idx[1]] = -s[tr1->idx[1]]; } } for (i=0;iidx[0];i++) *(R+j*ldr+i) = x[i]; for (i=tr1->idx[0]+1;iidx[0]) = tr1->alpha; if (sz==2) { y = tr2->data; /* Second column */ ierr = PetscBLASIntCast(tr2->n[0],&n0_);CHKERRQ(ierr); ierr = PetscBLASIntCast(tr2->n[1],&n1_);CHKERRQ(ierr); ierr = PetscBLASIntCast(n-j-sz,&mr);CHKERRQ(ierr); ierr = PetscBLASIntCast(n-tr2->idx[0],&mh);CHKERRQ(ierr); if (tr2->n[0] > 1 && PetscAbsScalar(tr2->tau[0])!=0.0) { y[tr2->idx[0]] = 1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n0_,&mr,y+tr2->idx[0],&inc,tr2->tau,R+(j+2)*ldr+tr2->idx[0],&ldr_,work+nwu)); PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n0_,y+tr2->idx[0],&inc,tr2->tau,H+(tr2->idx[0])*ldh,&ldh_,work+nwu)); } if (tr2->n[1] > 1 && PetscAbsScalar(tr2->tau[1])!=0.0) { y[tr2->idx[1]] = 1.0; PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("L",&n1_,&mr,y+tr2->idx[1],&inc,tr2->tau+1,R+(j+2)*ldr+tr2->idx[1],&ldr_,work+nwu)); PetscStackCallBLAS("LAPACKlarf",LAPACKlarf_("R",&n_,&n1_,y+tr2->idx[1],&inc,tr2->tau+1,H+(tr2->idx[1])*ldh,&ldh_,work+nwu)); } if (tr2->idx[0]idx[1]) { ierr = HRApply(mr,R+(j+2)*ldr+tr2->idx[0],ldr,R+(j+2)*ldr+tr2->idx[1],ldr,tr2->cs,-tr2->sn);CHKERRQ(ierr); if (tr2->type==1) { ierr = HRApply(n,H+(tr2->idx[0])*ldh,1,H+(tr2->idx[1])*ldh,1,tr2->cs,tr2->sn);CHKERRQ(ierr); } else { ierr = HRApply(n,H+(tr2->idx[0])*ldh,1,H+(tr2->idx[1])*ldh,1,-tr2->cs,-tr2->sn);CHKERRQ(ierr); s[tr2->idx[0]] = -s[tr2->idx[0]]; s[tr2->idx[1]] = -s[tr2->idx[1]]; } } for (i=0;iidx[0]-1;i++) *(R+(j+1)*ldr+i) = y[i]; *(R+(j+1)*ldr+tr2->idx[0]-1) = y[tr2->idx[0]-1]; for (i=tr2->idx[0]+1;iidx[0]) = tr2->alpha; *n0 = tr2->n[0]; *n1 = tr2->n[1]; *idx0 = tr2->idx[0]; *idx1 = tr2->idx[1]; if (tr2->idx[0]idx[1] && tr2->type==2) { (*idx1)++; (*n1)--; (*n0)++; } } else { *n0 = tr1->n[0]; *n1 = tr1->n[1]; *idx0 = tr1->idx[0]; *idx1 = tr1->idx[1]; if (tr1->idx[0]idx[1] && tr1->type==2) { (*idx1)++; (*n1)--; (*n0)++; } } if (*n0>0) { (*n0)--; (*idx0)++; if (*n1==0) *idx1 = *idx0; } else { (*n1)--; (*idx1)++; *idx0 = *idx1; } } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "PseudoOrthog_HR" /* compute V = HR whit H s-orthogonal and R upper triangular */ static PetscErrorCode PseudoOrthog_HR(PetscInt *nv,PetscScalar *V,PetscInt ldv,PetscReal *s,PetscScalar *R,PetscInt ldr,PetscBLASInt *perm,PetscBLASInt *cmplxEig,PetscBool *breakdown,PetscScalar *work) { PetscErrorCode ierr; PetscInt i,j,n,n0,n1,np,idx0,idx1,sz=1,k=0,t1,t2,nwu=0; PetscScalar *col1,*col2; PetscBool exg=PETSC_FALSE,ok=PETSC_FALSE; PetscFunctionBegin; n = *nv; col1 = work+nwu; nwu += n; col2 = work+nwu; nwu += n; /* Sort R and s according to sing(s) */ np = 0; for (i=0;i0) np++; if (s[0]>0) n1 = np; else n1 = n-np; n0 = 0; for (i=0;il; n = ds->n-l; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ld = ds->ld; ierr = PetscBLASIntCast(ld,&ld_);CHKERRQ(ierr); off = l*ld+l; s = ds->rmat[DS_MAT_D]; if (!ds->compact) { for (i=l;in;i++) s[i] = PetscRealPart(*(ds->mat[DS_MAT_B]+i*ld+i)); } lws = n*n+7*n; lwi = 2*n; ierr = DSAllocateWork_Private(ds,lws,0,lwi);CHKERRQ(ierr); R = ds->work+nwus; nwus += n*n; ldr = n; perm = ds->iwork + nwui; nwui += n; cmplxEig = ds->iwork+nwui; X = ds->mat[mat]; for (i=0;iwork+nwus);CHKERRQ(ierr); /* Sort wr,wi perm */ ts = ds->work+nwus; ierr = PetscMemcpy(ts,wr+l,n*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;irmat[DS_MAT_T]+2*ld,ld*sizeof(PetscReal));CHKERRQ(ierr); d = ds->rmat[DS_MAT_T]; e = d+ld; for (i=0;imat[DS_MAT_W]; ierr = DSCopyMatrix_Private(ds,DS_MAT_W,DS_MAT_Q);CHKERRQ(ierr); PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n_,&nv_,&n_,&oneS,W+off,&ld_,X+off,&ld_,&zeroS,ds->mat[DS_MAT_Q]+off,&ld_)); } else { ierr = PetscMemzero(ds->mat[DS_MAT_Q],ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;il;i++) *(ds->mat[DS_MAT_Q]+i+i*ld) = 1.0; for (i=0;imat[DS_MAT_Q]+off+i*ld,X+off+i*ld,n*sizeof(PetscScalar));CHKERRQ(ierr); } } ds->t = nv+l; if (!ds->compact) { ierr = DSSwitchFormat_GHIEP(ds,PETSC_FALSE);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSIntermediate_GHIEP" /* Reduce to tridiagonal-diagonal pair by means of TridiagDiag_HHR. */ PetscErrorCode DSIntermediate_GHIEP(DS ds) { PetscErrorCode ierr; PetscInt i,ld,off; PetscInt nwall,nwallr,nwalli; PetscScalar *A,*B,*Q; PetscReal *d,*e,*s; PetscFunctionBegin; ld = ds->ld; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; Q = ds->mat[DS_MAT_Q]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T]+ld; s = ds->rmat[DS_MAT_D]; off = ds->l+ds->l*ld; ierr = PetscMemzero(Q,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); nwall = ld*ld+ld; nwallr = ld; nwalli = ld; ierr = DSAllocateWork_Private(ds,nwall,nwallr,nwalli);CHKERRQ(ierr); for (i=0;in;i++) Q[i+i*ld]=1.0; for (i=0;in-ds->l;i++) *(ds->perm+i)=i; if (ds->compact) { if (ds->state < DS_STATE_INTERMEDIATE) { ierr = DSSwitchFormat_GHIEP(ds,PETSC_FALSE);CHKERRQ(ierr); ierr = TridiagDiag_HHR(ds->k-ds->l+1,A+off,ld,s+ds->l,Q+off,ld,PETSC_TRUE,d+ds->l,e+ds->l,ds->perm,ds->work,ds->rwork,ds->iwork);CHKERRQ(ierr); ds->k = ds->l; ierr = PetscMemzero(d+2*ld+ds->l,(ds->n-ds->l)*sizeof(PetscReal));CHKERRQ(ierr); } } else { if (ds->state < DS_STATE_INTERMEDIATE) { for (i=0;in;i++) s[i] = PetscRealPart(B[i+i*ld]); ierr = TridiagDiag_HHR(ds->n-ds->l,A+off,ld,s+ds->l,Q+off,ld,PETSC_FALSE,d+ds->l,e+ds->l,ds->perm,ds->work,ds->rwork,ds->iwork);CHKERRQ(ierr); ierr = PetscMemzero(d+2*ld,(ds->n)*sizeof(PetscReal));CHKERRQ(ierr); ds->k = ds->l; ierr = DSSwitchFormat_GHIEP(ds,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = DSSwitchFormat_GHIEP(ds,PETSC_TRUE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/ghiep/dqds.c0000644000175000017500000006467013107004621021167 0ustar jromanjroman/* DQDS-type dense solver for generalized symmetric-indefinite eigenproblem. Based on Matlab code from Carla Ferreira. References: [1] C. Ferreira, B. Parlett, "Real DQDS for the nonsymmetric tridiagonal eigenvalue problem", preprint, 2012. [2] C. Ferreira. The unsymmetric tridiagonal eigenvalue problem. Ph.D Thesis, University of Minho, 2007. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "ScanJ" /* INPUT: a ---- diagonal of J b ---- subdiagonal of J; the superdiagonal of J is all 1's OUTPUT: For an eigenvalue lambda of J we have: gl=0.0)?PetscSqrtReal(b[0]):0.0; /* rad = b1+b0, b0 = 0 */ *gr = a[0]+rad; *gl = a[0]-rad; b0 = rad; for (i=1;i0.0)?PetscSqrtReal(b[i]):0.0; rad = b0+b1; *gr = PetscMax(*gr,a[i]+rad); *gl = PetscMin(*gl,a[i]-rad); b0 = b1; } rad = b0; *gr = PetscMax(*gr,a[n-1]+rad); *gl = PetscMin(*gl,a[n-1]-rad); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Prologue" /* INPUT: a - vector with the diagonal elements b - vector with the subdiagonal elements gl - Gersgorin left bound (real axis) gr - Gersgorin right bound (real axis) OUTPUT: eigvalue - multiple eigenvalue (if there is an eigenvalue) m - its multiplicity (m=0 if there isn't a multiple eigenvalue) X - matrix of generalized eigenvectors shift dim(work)=5*n+4 */ static PetscErrorCode Prologue(PetscInt n,PetscReal *a,PetscReal *b,PetscReal gl,PetscReal gr,PetscInt *m,PetscReal *shift,PetscReal *work) { PetscErrorCode ierr; PetscReal mu,tol,*a1,*y,*yp,*x,*xp; PetscInt i,k; PetscFunctionBegin; *m = 0; mu = 0.0; for (i=0;itol*norm) *fail = 1; /* This demands IEEE arithmetic */ if (PetscAbsReal(U[i])>tol*norm) *fail = 1; } if (!*fail && PetscAbsReal(U[n-1])>tol*norm) *fail = 1; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RealDQDS" static PetscErrorCode RealDQDS(PetscInt n,PetscReal *L,PetscReal *U,PetscReal shift,PetscReal tol,PetscReal norm,PetscReal *L1,PetscReal *U1,PetscInt *fail) { PetscReal d; PetscInt i; PetscFunctionBegin; *fail = 0; d = U[0]-shift; for (i=0;itol*norm) *fail=1; if (PetscAbsReal(U1[i])>tol*norm) *fail=1; } if (!*fail && PetscAbsReal(U1[n-1])>tol*norm) *fail=1; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "TridqdsZhuang3" static PetscErrorCode TridqdsZhuang3(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscInt *fail) { PetscReal xl,yl,xr,yr,zr; PetscInt i; PetscFunctionBegin; *fail = 0; xr = 1.0; yr = e[0]; zr = 0.0; /* Step 1 */ /* the efect of Z1 */ xr = xr*q[0]+yr; /* the inverse of L1 */ xl = (q[0]+e[0])*(q[0]+e[0])+q[1]*e[0]-sum*(q[0]+e[0])+prod; yl = -(q[2]*e[1]*q[1]*e[0])/xl; xl = -(q[1]*e[0]*(q[0]+e[0]+q[1]+e[1]-sum))/xl; /* the efect of L1 */ q[0] = xr-xl; xr = yr-xl; yr = zr-yl-xl*e[1]; /*the inverse of Y1 */ xr = xr/q[0]; yr = yr/q[0]; /*the effect of Y1 inverse */ e[0] = xl+yr+xr*q[1]; xl = yl+zr+yr*q[2]; /* zr=0 when n=3 */ /*the effect of Y1 */ xr = 1.0-xr; yr = e[1]-yr; /* STEP n-1 */ if (PetscAbsReal(e[n-3])>tolDef*PetscAbsReal(xl) || PetscAbsReal(e[n-3])>tolDef*PetscAbsReal(q[n-3])) { /* the efect of Zn-1 */ xr = xr*q[n-2]+yr; /* the inverse of Ln-1 */ xl = -xl/e[n-3]; /* the efect of Ln-1 */ q[n-2] = xr-xl; xr = yr-xl; /*the inverse of Yn-1 */ xr = xr/q[n-2]; /*the effect of the inverse of Yn-1 */ e[n-2] = xl+xr*q[n-1]; /*the effects of Yn-1 */ xr = 1.0-xr; /* STEP n */ /*the effect of Zn */ xr = xr*q[n-1]; /*the inverse of Ln=I */ /*the effect of Ln */ q[n-1] = xr; /* the inverse of Yn-1=I */ } else { /* Free deflation */ e[n-2] = (e[n-3]+(xr*q[n-2]+yr)+q[n-1])*0.5; /* Sum=trace/2 */ q[n-2] = (e[n-3]+q[n-2]*xr)*q[n-1]-xl; /* det */ q[n-1] = e[n-2]*e[n-2]-q[n-2]; *fail = 2; } /* The following demands IEEE arithmetic */ for (i=0;itol*norm) *fail=1; if (PetscAbsReal(q[i])>tol*norm) *fail=1; } if (!*fail && PetscAbsReal(q[n-1])>tol*norm) *fail=1; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "TridqdsZhuang" static PetscErrorCode TridqdsZhuang(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscReal *e1,PetscReal *q1,PetscInt *fail) { PetscErrorCode ierr; PetscInt i; PetscReal xl,yl,xr,yr,zr; PetscFunctionBegin; for (i=0;i3) { /* For n>3 */ *fail = 0; xr = 1; yr = e1[0]; zr = 0; /* step 1 */ /* the efect of Z1 */ xr = xr*q1[0]+yr; /* the inverse of L1 */ xl = (q1[0]+e1[0])*(q1[0]+e1[0])+q1[1]*e1[0]-sum*(q1[0]+e1[0])+prod; yl = -(q1[2]*e1[1]*q1[1]*e1[0])/xl; xl = -(q1[1]*e1[0]*(q1[0]+e1[0]+q1[1]+e1[1]-sum))/xl; /* the efect of L1 */ q1[0] = xr-xl; xr = yr-xl; yr = zr-yl-xl*e1[1]; zr = -yl*e1[2]; /* the inverse of Y1 */ xr = xr/q1[0]; yr = yr/q1[0]; zr = zr/q1[0]; /* the effect of Y1 inverse */ e1[0] = xl+yr+xr*q1[1]; xl = yl+zr+yr*q1[2]; yl = zr*q1[3]; /* the effect of Y1 */ xr = 1-xr; yr = e1[1]-yr; zr = -zr; /* step i=2,...,n-3 */ for (i=1;itolDef*PetscAbsReal(xl) || PetscAbsReal(e1[n-3])>tolDef*PetscAbsReal(q1[n-3])) { /* the efect of Zn-1 */ xr = xr*q1[n-2]+yr; /* the inverse of Ln-1 */ xl = -xl/e1[n-3]; /* the efect of Ln-1 */ q1[n-2] = xr-xl; xr = yr-xl; /*the inverse of Yn-1 */ xr = xr/q1[n-2]; /*the effect of the inverse of Yn-1 */ e1[n-2] = xl+xr*q1[n-1]; /*the effects of Yn-1 */ xr = 1.0-xr; /* STEP n; xl no longer needed */ /* the effect of Zn */ xr = xr*q1[n-1]; /* the inverse of Ln = I */ /* the effect of Ln */ q1[n-1] = xr; /* the inverse of Yn-1=I */ } else { /* FREE DEFLATION */ e1[n-2] = (e1[n-3]+xr*q1[n-2]+yr+q1[n-1])*0.5; /* sum=trace/2 */ q1[n-2] = (e1[n-3]+q1[n-2]*xr)*q1[n-1]-xl; /* det */ q1[n-1] = e1[n-2]*e1[n-2]-q1[n-2]; *fail = 2; } for (i=0;itol*norm) *fail = 1; /* This demands IEEE arithmetic */ if (PetscAbsReal(q1[i])>tol*norm) *fail = 1; } if (!*fail && PetscAbsReal(q1[n-1])>tol*norm) *fail = 1; } else { /* The case n=3 */ ierr = TridqdsZhuang3(n,e1,q1,sum,prod,tol,norm,tolDef,fail);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSGHIEP_Eigen3DQDS" static PetscErrorCode DSGHIEP_Eigen3DQDS(PetscInt n,PetscReal *a,PetscReal *b,PetscReal *c,PetscScalar *wr,PetscScalar *wi,PetscReal *work) { PetscInt totalIt=0; /* Total Number of Iterations */ PetscInt totalFail=0; /* Total number of failures */ PetscInt nFail=0; /* Number of failures per transformation */ PetscReal tolZero=1.0/16; /* Tolerance for zero shifts */ PetscInt maxIt=10*n; /* Maximum number of iterations */ PetscInt maxFail=10*n; /* Maximum number of failures allowed per each transformation */ PetscReal tolDef=PETSC_MACHINE_EPSILON; /* Tolerance for deflation eps, 10*eps, 100*eps */ PetscReal tolGrowth=100000; PetscErrorCode ierr; PetscInt i,k,nwu=0,begin,ind,flag,dim,m,*split,lastSplit; PetscReal norm,gr,gl,sigma,delta,meanEig,*U,*L,*U1,*L1; PetscReal acShift,initialShift,shift=0.0,sum,det,disc,prod,x1,x2; PetscBool test1,test2; PetscFunctionBegin; dim = n; /* Test if the matrix is unreduced */ for (i=0;igr || shift2 && totalIt4) { test2 = (PetscAbsReal(L[n-3])=0.0)?1.0:-1.0)*(PetscAbsReal(sum)+PetscSqrtReal(disc)); x2 = det/x1; } wr[--n] = x1+acShift; wr[--n] = x2+acShift; } } else { /* test1 -- 1x1 deflation */ x1 = U[n-1]+acShift; wr[--n] = x1; } if (n<=begin+2) { break; } else { test1 = (PetscAbsReal(L[n-2])4) { test2 = (PetscAbsReal(L[n-3])begin+3) { ind = begin; for (k=n-4;k>=begin+1;k--) { if (PetscAbsReal(L[k])begin || PetscAbsReal(L[begin]) begin+2) { disc = (L[n-2]*(L[n-2]+2*(U[n-2]+U[n-1]))+(U[n-2]-U[n-1])*(U[n-2]-U[n-1]))/4; if ((PetscAbsReal(L[n-2])>tolZero) && (PetscAbsReal(L[n-3])>tolZero)) { /* L's are big */ shift = 0; ierr = RealDQDS(n-begin,L+begin,U+begin,0,tolGrowth,norm,L1+begin,U1+begin,&flag);CHKERRQ(ierr); if (flag) { /* Failure */ ierr = TridqdsZhuang(n-begin,L+begin,U+begin,0.0,0.0,tolGrowth,norm,tolDef,L1+begin,U1+begin,&flag);CHKERRQ(ierr); shift = 0.0; while (flag==1 && nFailgr-acShift || shift0 Real case; real Wilkinson shift; dqds */ sum = (L[n-2]+U[n-2]+U[n-1])/2; if (sum==0.0) { x1 = PetscSqrtReal(disc); x2 = -x1; } else { x1 = ((sum>=0)?1.0:-1.0)*(PetscAbsReal(sum)+PetscSqrtReal(disc)); x2 = U[n-2]*U[n-1]/x1; } /* Take the eigenvalue closest to UL(n,n) */ if (PetscAbsReal(x1-U[n-1])gr-acShift || shiftbegin+1" */ } /* end WHILE 1 */ if (totalIt>=maxIt) SETERRQ(PETSC_COMM_SELF,1,"Maximun number of iterations reached. No convergence in DQDS"); /* END: n=2 or n=1 % n=begin+1 or n=begin */ if (n==begin+2) { sum = (L[n-2]+U[n-2]+U[n-1])/2; disc = (L[n-2]*(L[n-2]+2*(U[n-2]+U[n-1]))+(U[n-2]-U[n-1])*(U[n-2]-U[n-1]))/4; if (disc<=0) { /* Complex case */ /* Deflation 2 */ #if !defined(PETSC_USE_COMPLEX) wr[--n] = sum+acShift; if (wi) wi[n] = PetscSqrtReal(-disc); wr[--n] = sum+acShift; if (wi) wi[n] = -PetscSqrtReal(-disc); #else wr[--n] = sum-PETSC_i*PetscSqrtReal(-disc)+acShift; if (wi) wi[n] = 0.0; wr[--n] = sum+PETSC_i*PetscSqrtReal(-disc)+acShift; if (wi) wi[n] = 0.0; #endif } else { /* Real case */ if (sum==0.0) { x1 = PetscSqrtReal(disc); x2 = -x1; } else { x1 = ((sum>=0)?1.0:-1.0)*(PetscAbsReal(sum)+PetscSqrtReal(disc)); x2 = U[n-2]*U[n-1]/x1; } /* Deflation 2 */ wr[--n] = x2+acShift; wr[--n] = x1+acShift; } } else { /* n=1 n=begin */ /* deflation 1 */ x1 = U[n-1]+acShift; wr[--n] = x1; } switch (n) { case 0: begin = -1; break; case 1: acShift = L[begin-1]; begin = split[lastSplit]; lastSplit--; break; default : /* n>=2 */ acShift = L[begin-1]; begin = split[lastSplit]; lastSplit--; } }/* While begin~=-1 */ for (i=0;ild; off = ds->l + ds->l*ld; A = ds->mat[DS_MAT_A]; B = ds->mat[DS_MAT_B]; Q = ds->mat[DS_MAT_Q]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T] + ld; s = ds->rmat[DS_MAT_D]; /* Quick return if possible */ if (ds->n-ds->l == 1) { *(Q+off) = 1; if (!ds->compact) { d[ds->l] = PetscRealPart(A[off]); s[ds->l] = PetscRealPart(B[off]); } wr[ds->l] = d[ds->l]/s[ds->l]; if (wi) wi[ds->l] = 0.0; PetscFunctionReturn(0); } nwall = 12*ld+4; ierr = DSAllocateWork_Private(ds,0,nwall,0);CHKERRQ(ierr); /* Reduce to pseudotriadiagonal form */ ierr = DSIntermediate_GHIEP(ds);CHKERRQ(ierr); /* Compute Eigenvalues (DQDS) */ /* Form pseudosymmetric tridiagonal */ a = ds->rwork; b = a+ld; c = b+ld; nwu = 3*ld; if (ds->compact) { for (i=ds->l;in-1;i++) { a[i] = d[i]*s[i]; b[i] = e[i]*s[i+1]; c[i] = e[i]*s[i]; } a[ds->n-1] = d[ds->n-1]*s[ds->n-1]; } else { for (i=ds->l;in-1;i++) { a[i] = PetscRealPart(A[i+i*ld]*B[i+i*ld]); b[i] = PetscRealPart(A[i+1+i*ld]*s[i+1]); c[i] = PetscRealPart(A[i+(i+1)*ld]*s[i]); } a[ds->n-1] = PetscRealPart(A[ds->n-1+(ds->n-1)*ld]*B[ds->n-1+(ds->n-1)*ld]); } vi = (wi)?wi+ds->l:NULL; ierr = DSGHIEP_Eigen3DQDS(ds->n-ds->l,a+ds->l,b+ds->l,c+ds->l,wr+ds->l,vi,ds->rwork+nwu);CHKERRQ(ierr); /* Compute Eigenvectors with Inverse Iteration */ ierr = DSGHIEPInverseIteration(ds,wr,wi);CHKERRQ(ierr); /* Recover eigenvalues from diagonal */ ierr = DSGHIEPComplexEigs(ds,0,ds->l,wr,wi);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) if (wi) { for (i=ds->l;in;i++) wi[i] = 0.0; } #endif PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/hep/0000755000175000017500000000000013107004621017533 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/hep/makefile0000644000175000017500000000216613107004621021240 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = dshep.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = bdc MANSEC = DS LOCDIR = src/sys/classes/ds/impls/hep/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/hep/dshep.c.html0000644000175000017500000017313013107004621021752 0ustar jromanjroman
Actual source code: dshep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/dsimpl.h>
 23: #include <slepcblaslapack.h>

 27: PetscErrorCode DSAllocate_HEP(DS ds,PetscInt ld)
 28: {

 32:   DSAllocateMat_Private(ds,DS_MAT_A);
 33:   DSAllocateMat_Private(ds,DS_MAT_Q);
 34:   DSAllocateMatReal_Private(ds,DS_MAT_T);
 35:   PetscFree(ds->perm);
 36:   PetscMalloc1(ld,&ds->perm);
 37:   PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));
 38:   return(0);
 39: }

 41: /*   0       l           k                 n-1
 42:     -----------------------------------------
 43:     |*       .           .                  |
 44:     |  *     .           .                  |
 45:     |    *   .           .                  |
 46:     |      * .           .                  |
 47:     |. . . . o           o                  |
 48:     |          o         o                  |
 49:     |            o       o                  |
 50:     |              o     o                  |
 51:     |                o   o                  |
 52:     |                  o o                  |
 53:     |. . . . o o o o o o o x                |
 54:     |                    x x x              |
 55:     |                      x x x            |
 56:     |                        x x x          |
 57:     |                          x x x        |
 58:     |                            x x x      |
 59:     |                              x x x    |
 60:     |                                x x x  |
 61:     |                                  x x x|
 62:     |                                    x x|
 63:     -----------------------------------------
 64: */

 68: static PetscErrorCode DSSwitchFormat_HEP(DS ds,PetscBool tocompact)
 69: {
 71:   PetscReal      *T = ds->rmat[DS_MAT_T];
 72:   PetscScalar    *A = ds->mat[DS_MAT_A];
 73:   PetscInt       i,n=ds->n,k=ds->k,ld=ds->ld;

 76:   if (tocompact) { /* switch from dense (arrow) to compact storage */
 77:     PetscMemzero(T,3*ld*sizeof(PetscReal));
 78:     for (i=0;i<k;i++) {
 79:       T[i] = PetscRealPart(A[i+i*ld]);
 80:       T[i+ld] = PetscRealPart(A[k+i*ld]);
 81:     }
 82:     for (i=k;i<n-1;i++) {
 83:       T[i] = PetscRealPart(A[i+i*ld]);
 84:       T[i+ld] = PetscRealPart(A[i+1+i*ld]);
 85:     }
 86:     T[n-1] = PetscRealPart(A[n-1+(n-1)*ld]);
 87:     if (ds->extrarow) T[n-1+ld] = PetscRealPart(A[n+(n-1)*ld]);
 88:   } else { /* switch from compact (arrow) to dense storage */
 89:     PetscMemzero(A,ld*ld*sizeof(PetscScalar));
 90:     for (i=0;i<k;i++) {
 91:       A[i+i*ld] = T[i];
 92:       A[k+i*ld] = T[i+ld];
 93:       A[i+k*ld] = T[i+ld];
 94:     }
 95:     A[k+k*ld] = T[k];
 96:     for (i=k+1;i<n;i++) {
 97:       A[i+i*ld] = T[i];
 98:       A[i-1+i*ld] = T[i-1+ld];
 99:       A[i+(i-1)*ld] = T[i-1+ld];
100:     }
101:     if (ds->extrarow) A[n+(n-1)*ld] = T[n-1+ld];
102:   }
103:   return(0);
104: }

108: PetscErrorCode DSView_HEP(DS ds,PetscViewer viewer)
109: {
110:   PetscErrorCode    ierr;
111:   PetscViewerFormat format;
112:   PetscInt          i,j,r,c,rows;
113:   PetscReal         value;
114:   const char        *methodname[] = {
115:                      "Implicit QR method (_steqr)",
116:                      "Relatively Robust Representations (_stevr)",
117:                      "Divide and Conquer method (_stedc)",
118:                      "Block Divide and Conquer method (dsbtdc)"
119:   };
120:   const int         nmeth=sizeof(methodname)/sizeof(methodname[0]);

123:   PetscViewerGetFormat(viewer,&format);
124:   if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
125:     if (ds->bs>1) {
126:       PetscViewerASCIIPrintf(viewer,"block size: %D\n",ds->bs);
127:     }
128:     if (ds->method>=nmeth) {
129:       PetscViewerASCIIPrintf(viewer,"solving the problem with: INVALID METHOD\n");
130:     } else {
131:       PetscViewerASCIIPrintf(viewer,"solving the problem with: %s\n",methodname[ds->method]);
132:     }
133:     return(0);
134:   }
135:   if (ds->compact) {
136:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
137:     rows = ds->extrarow? ds->n+1: ds->n;
138:     if (format == PETSC_VIEWER_ASCII_MATLAB) {
139:       PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",rows,ds->n);
140:       PetscViewerASCIIPrintf(viewer,"zzz = zeros(%D,3);\n",3*ds->n);
141:       PetscViewerASCIIPrintf(viewer,"zzz = [\n");
142:       for (i=0;i<ds->n;i++) {
143:         PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_T]+i));
144:       }
145:       for (i=0;i<rows-1;i++) {
146:         r = PetscMax(i+2,ds->k+1);
147:         c = i+1;
148:         PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",r,c,*(ds->rmat[DS_MAT_T]+ds->ld+i));
149:         if (i<ds->n-1 && ds->k<ds->n) { /* do not print vertical arrow when k=n */
150:           PetscViewerASCIIPrintf(viewer,"%D %D  %18.16e\n",c,r,*(ds->rmat[DS_MAT_T]+ds->ld+i));
151:         }
152:       }
153:       PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(zzz);\n",DSMatName[DS_MAT_T]);
154:     } else {
155:       for (i=0;i<rows;i++) {
156:         for (j=0;j<ds->n;j++) {
157:           if (i==j) value = *(ds->rmat[DS_MAT_T]+i);
158:           else if ((i<ds->k && j==ds->k) || (i==ds->k && j<ds->k)) value = *(ds->rmat[DS_MAT_T]+ds->ld+PetscMin(i,j));
159:           else if (i==j+1 && i>ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+i-1);
160:           else if (i+1==j && j>ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+j-1);
161:           else value = 0.0;
162:           PetscViewerASCIIPrintf(viewer," %18.16e ",value);
163:         }
164:         PetscViewerASCIIPrintf(viewer,"\n");
165:       }
166:     }
167:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
168:     PetscViewerFlush(viewer);
169:   } else {
170:     DSViewMat(ds,viewer,DS_MAT_A);
171:   }
172:   if (ds->state>DS_STATE_INTERMEDIATE) {
173:     DSViewMat(ds,viewer,DS_MAT_Q);
174:   }
175:   return(0);
176: }

180: PetscErrorCode DSVectors_HEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)
181: {
182:   PetscScalar    *Q = ds->mat[DS_MAT_Q];
183:   PetscInt       ld = ds->ld,i;

187:   switch (mat) {
188:     case DS_MAT_X:
189:     case DS_MAT_Y:
190:       if (j) {
191:         if (ds->state>=DS_STATE_CONDENSED) {
192:           PetscMemcpy(ds->mat[mat]+(*j)*ld,Q+(*j)*ld,ld*sizeof(PetscScalar));
193:         } else {
194:           PetscMemzero(ds->mat[mat]+(*j)*ld,ld*sizeof(PetscScalar));
195:           *(ds->mat[mat]+(*j)+(*j)*ld) = 1.0;
196:         }
197:       } else {
198:         if (ds->state>=DS_STATE_CONDENSED) {
199:           PetscMemcpy(ds->mat[mat],Q,ld*ld*sizeof(PetscScalar));
200:         } else {
201:           PetscMemzero(ds->mat[mat],ld*ld*sizeof(PetscScalar));
202:           for (i=0;i<ds->n;i++) *(ds->mat[mat]+i+i*ld) = 1.0;
203:         }
204:       }
205:       if (rnorm && j) *rnorm = PetscAbsScalar(Q[ds->n-1+(*j)*ld]);
206:       break;
207:     case DS_MAT_U:
208:     case DS_MAT_VT:
209:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
210:       break;
211:     default:
212:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
213:   }
214:   return(0);
215: }

219: PetscErrorCode DSNormalize_HEP(DS ds,DSMatType mat,PetscInt col)
220: {
222:   switch (mat) {
223:     case DS_MAT_X:
224:     case DS_MAT_Y:
225:     case DS_MAT_Q:
226:       /* All the matrices resulting from DSVectors and DSSolve are already normalized */
227:       break;
228:     case DS_MAT_U:
229:     case DS_MAT_VT:
230:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet");
231:       break;
232:     default:
233:       SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter");
234:   }
235:   return(0);
236: }

240: /*
241:   ARROWTRIDIAG reduces a symmetric arrowhead matrix of the form

243:                 [ d 0 0 0 e ]
244:                 [ 0 d 0 0 e ]
245:             A = [ 0 0 d 0 e ]
246:                 [ 0 0 0 d e ]
247:                 [ e e e e d ]

249:   to tridiagonal form

251:                 [ d e 0 0 0 ]
252:                 [ e d e 0 0 ]
253:    T = Q'*A*Q = [ 0 e d e 0 ],
254:                 [ 0 0 e d e ]
255:                 [ 0 0 0 e d ]

257:   where Q is an orthogonal matrix. Rutishauser's algorithm is used to
258:   perform the reduction, which requires O(n**2) flops. The accumulation
259:   of the orthogonal factor Q, however, requires O(n**3) flops.

261:   Arguments
262:   =========

264:   N       (input) INTEGER
265:           The order of the matrix A.  N >= 0.

267:   D       (input/output) DOUBLE PRECISION array, dimension (N)
268:           On entry, the diagonal entries of the matrix A to be
269:           reduced.
270:           On exit, the diagonal entries of the reduced matrix T.

272:   E       (input/output) DOUBLE PRECISION array, dimension (N-1)
273:           On entry, the off-diagonal entries of the matrix A to be
274:           reduced.
275:           On exit, the subdiagonal entries of the reduced matrix T.

277:   Q       (input/output) DOUBLE PRECISION array, dimension (LDQ, N)
278:           On exit, the orthogonal matrix Q.

280:   LDQ     (input) INTEGER
281:           The leading dimension of the array Q.

283:   Note
284:   ====
285:   Based on Fortran code contributed by Daniel Kressner
286: */
287: static PetscErrorCode ArrowTridiag(PetscBLASInt n,PetscReal *d,PetscReal *e,PetscScalar *Q,PetscBLASInt ld)
288: {
289: #if defined(SLEPC_MISSING_LAPACK_LARTG)
291:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LARTG - Lapack routine is unavailable");
292: #else
293:   PetscBLASInt i,j,j2,one=1;
294:   PetscReal    c,s,p,off,temp;

297:   if (n<=2) return(0);

299:   for (j=0;j<n-2;j++) {

301:     /* Eliminate entry e(j) by a rotation in the planes (j,j+1) */
302:     temp = e[j+1];
303:     PetscStackCallBLAS("LAPACKlartg",LAPACKlartg_(&temp,&e[j],&c,&s,&e[j+1]));
304:     s = -s;

306:     /* Apply rotation to diagonal elements */
307:     temp   = d[j+1];
308:     e[j]   = c*s*(temp-d[j]);
309:     d[j+1] = s*s*d[j] + c*c*temp;
310:     d[j]   = c*c*d[j] + s*s*temp;

312:     /* Apply rotation to Q */
313:     j2 = j+2;
314:     PetscStackCallBLAS("BLASrot",BLASrot_(&j2,Q+j*ld,&one,Q+(j+1)*ld,&one,&c,&s));

316:     /* Chase newly introduced off-diagonal entry to the top left corner */
317:     for (i=j-1;i>=0;i--) {
318:       off  = -s*e[i];
319:       e[i] = c*e[i];
320:       temp = e[i+1];
321:       PetscStackCallBLAS("LAPACKlartg",LAPACKlartg_(&temp,&off,&c,&s,&e[i+1]));
322:       s = -s;
323:       temp = (d[i]-d[i+1])*s - 2.0*c*e[i];
324:       p = s*temp;
325:       d[i+1] += p;
326:       d[i] -= p;
327:       e[i] = -e[i] - c*temp;
328:       j2 = j+2;
329:       PetscStackCallBLAS("BLASrot",BLASrot_(&j2,Q+i*ld,&one,Q+(i+1)*ld,&one,&c,&s));
330:     }
331:   }
332:   return(0);
333: #endif
334: }

338: /*
339:    Reduce to tridiagonal form by means of ArrowTridiag.
340: */
341: static PetscErrorCode DSIntermediate_HEP(DS ds)
342: {
343: #if defined(SLEPC_MISSING_LAPACK_SYTRD) || defined(SLEPC_MISSING_LAPACK_ORGTR)
345:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"SYTRD/ORGTR - Lapack routine is unavailable");
346: #else
348:   PetscInt       i;
349:   PetscBLASInt   n1,n2,n3,lwork,info,l,n,ld,off;
350:   PetscScalar    *A,*Q,*work,*tau;
351:   PetscReal      *d,*e;

354:   PetscBLASIntCast(ds->n,&n);
355:   PetscBLASIntCast(ds->l,&l);
356:   PetscBLASIntCast(ds->ld,&ld);
357:   PetscBLASIntCast(ds->k-l+1,&n1); /* size of leading block, excl. locked */
358:   PetscBLASIntCast(n-ds->k-1,&n2); /* size of trailing block */
359:   n3 = n1+n2;
360:   off = l+l*ld;
361:   A  = ds->mat[DS_MAT_A];
362:   Q  = ds->mat[DS_MAT_Q];
363:   d  = ds->rmat[DS_MAT_T];
364:   e  = ds->rmat[DS_MAT_T]+ld;
365:   PetscMemzero(Q,ld*ld*sizeof(PetscScalar));
366:   for (i=0;i<n;i++) Q[i+i*ld] = 1.0;

368:   if (ds->compact) {

370:     if (ds->state<DS_STATE_INTERMEDIATE) ArrowTridiag(n1,d+l,e+l,Q+off,ld);

372:   } else {

374:     for (i=0;i<l;i++) { d[i] = PetscRealPart(A[i+i*ld]); e[i] = 0.0; }

376:     if (ds->state<DS_STATE_INTERMEDIATE) {
377:       DSCopyMatrix_Private(ds,DS_MAT_Q,DS_MAT_A);
378:       DSAllocateWork_Private(ds,ld+ld*ld,0,0);
379:       tau  = ds->work;
380:       work = ds->work+ld;
381:       lwork = ld*ld;
382:       PetscStackCallBLAS("LAPACKsytrd",LAPACKsytrd_("L",&n3,Q+off,&ld,d+l,e+l,tau,work,&lwork,&info));
383:       if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xSYTRD %d",info);
384:       PetscStackCallBLAS("LAPACKorgtr",LAPACKorgtr_("L",&n3,Q+off,&ld,tau,work,&lwork,&info));
385:       if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGTR %d",info);
386:     } else {
387:       /* copy tridiagonal to d,e */
388:       for (i=l;i<n;i++) d[i] = PetscRealPart(A[i+i*ld]);
389:       for (i=l;i<n-1;i++) e[i] = PetscRealPart(A[(i+1)+i*ld]);
390:     }
391:   }
392:   return(0);
393: #endif
394: }

398: PetscErrorCode DSSort_HEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)
399: {
401:   PetscInt       n,l,i,*perm,ld=ds->ld;
402:   PetscScalar    *A;
403:   PetscReal      *d;

406:   if (!ds->sc) return(0);
407:   n = ds->n;
408:   l = ds->l;
409:   A = ds->mat[DS_MAT_A];
410:   d = ds->rmat[DS_MAT_T];
411:   perm = ds->perm;
412:   if (!rr) {
413:     DSSortEigenvaluesReal_Private(ds,d,perm);
414:   } else {
415:     DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);
416:   }
417:   for (i=l;i<n;i++) wr[i] = d[perm[i]];
418:   DSPermuteColumns_Private(ds,l,n,DS_MAT_Q,perm);
419:   for (i=l;i<n;i++) d[i] = PetscRealPart(wr[i]);
420:   if (!ds->compact) {
421:     for (i=l;i<n;i++) A[i+i*ld] = wr[i];
422:   }
423:   return(0);
424: }

428: PetscErrorCode DSUpdateExtraRow_HEP(DS ds)
429: {
431:   PetscInt       i;
432:   PetscBLASInt   n,ld,incx=1;
433:   PetscScalar    *A,*Q,*x,*y,one=1.0,zero=0.0;
434:   PetscReal      *e,beta;

437:   PetscBLASIntCast(ds->n,&n);
438:   PetscBLASIntCast(ds->ld,&ld);
439:   A  = ds->mat[DS_MAT_A];
440:   Q  = ds->mat[DS_MAT_Q];
441:   e  = ds->rmat[DS_MAT_T]+ld;

443:   if (ds->compact) {
444:     beta = e[n-1];   /* in compact, we assume all entries are zero except the last one */
445:     for (i=0;i<n;i++) e[i] = PetscRealPart(beta*Q[n-1+i*ld]);
446:     ds->k = n;
447:   } else {
448:     DSAllocateWork_Private(ds,2*ld,0,0);
449:     x = ds->work;
450:     y = ds->work+ld;
451:     for (i=0;i<n;i++) x[i] = PetscConj(A[n+i*ld]);
452:     PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n,&n,&one,Q,&ld,x,&incx,&zero,y,&incx));
453:     for (i=0;i<n;i++) A[n+i*ld] = PetscConj(y[i]);
454:     ds->k = n;
455:   }
456:   return(0);
457: }

461: PetscErrorCode DSSolve_HEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi)
462: {
463: #if defined(PETSC_MISSING_LAPACK_STEQR)
465:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STEQR - Lapack routine is unavailable");
466: #else
468:   PetscInt       i;
469:   PetscBLASInt   n1,n2,n3,info,l,n,ld,off;
470:   PetscScalar    *Q,*A;
471:   PetscReal      *d,*e;

474:   if (ds->bs>1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for bs>1");
475:   PetscBLASIntCast(ds->n,&n);
476:   PetscBLASIntCast(ds->l,&l);
477:   PetscBLASIntCast(ds->ld,&ld);
478:   PetscBLASIntCast(ds->k-l+1,&n1); /* size of leading block, excl. locked */
479:   PetscBLASIntCast(n-ds->k-1,&n2); /* size of trailing block */
480:   n3 = n1+n2;
481:   off = l+l*ld;
482:   Q  = ds->mat[DS_MAT_Q];
483:   A  = ds->mat[DS_MAT_A];
484:   d  = ds->rmat[DS_MAT_T];
485:   e  = ds->rmat[DS_MAT_T]+ld;

487:   /* Reduce to tridiagonal form */
488:   DSIntermediate_HEP(ds);

490:   /* Solve the tridiagonal eigenproblem */
491:   for (i=0;i<l;i++) wr[i] = d[i];

493:   DSAllocateWork_Private(ds,0,2*ld,0);
494:   PetscStackCallBLAS("LAPACKsteqr",LAPACKsteqr_("V",&n3,d+l,e+l,Q+off,&ld,ds->rwork,&info));
495:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xSTEQR %d",info);
496:   for (i=l;i<n;i++) wr[i] = d[i];

498:   /* Create diagonal matrix as a result */
499:   if (ds->compact) {
500:     PetscMemzero(e,(n-1)*sizeof(PetscReal));
501:   } else {
502:     for (i=l;i<n;i++) {
503:       PetscMemzero(A+l+i*ld,(n-l)*sizeof(PetscScalar));
504:     }
505:     for (i=l;i<n;i++) A[i+i*ld] = d[i];
506:   }

508:   /* Set zero wi */
509:   if (wi) for (i=l;i<n;i++) wi[i] = 0.0;
510:   return(0);
511: #endif
512: }

516: PetscErrorCode DSSolve_HEP_MRRR(DS ds,PetscScalar *wr,PetscScalar *wi)
517: {
518: #if defined(SLEPC_MISSING_LAPACK_STEVR)
520:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STEVR - Lapack routine is unavailable");
521: #else
523:   PetscInt       i;
524:   PetscBLASInt   n1,n2,n3,lwork,liwork,info,l,n,m,ld,off,il,iu,*isuppz;
525:   PetscScalar    *A,*Q,*W=NULL,one=1.0,zero=0.0;
526:   PetscReal      *d,*e,abstol=0.0,vl,vu;
527: #if defined(PETSC_USE_COMPLEX)
528:   PetscInt       j;
529:   PetscReal      *ritz;
530: #endif

533:   if (ds->bs>1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for bs>1");
534:   PetscBLASIntCast(ds->n,&n);
535:   PetscBLASIntCast(ds->l,&l);
536:   PetscBLASIntCast(ds->ld,&ld);
537:   PetscBLASIntCast(ds->k-l+1,&n1); /* size of leading block, excl. locked */
538:   PetscBLASIntCast(n-ds->k-1,&n2); /* size of trailing block */
539:   n3 = n1+n2;
540:   off = l+l*ld;
541:   A  = ds->mat[DS_MAT_A];
542:   Q  = ds->mat[DS_MAT_Q];
543:   d  = ds->rmat[DS_MAT_T];
544:   e  = ds->rmat[DS_MAT_T]+ld;

546:   /* Reduce to tridiagonal form */
547:   DSIntermediate_HEP(ds);

549:   /* Solve the tridiagonal eigenproblem */
550:   for (i=0;i<l;i++) wr[i] = d[i];

552:   if (ds->state<DS_STATE_INTERMEDIATE) {  /* Q contains useful info */
553:     DSAllocateMat_Private(ds,DS_MAT_W);
554:     DSCopyMatrix_Private(ds,DS_MAT_W,DS_MAT_Q);
555:     W = ds->mat[DS_MAT_W];
556:   }
557: #if defined(PETSC_USE_COMPLEX)
558:   DSAllocateMatReal_Private(ds,DS_MAT_Q);
559: #endif
560:   lwork = 20*ld;
561:   liwork = 10*ld;
562:   DSAllocateWork_Private(ds,0,lwork+ld,liwork+2*ld);
563:   isuppz = ds->iwork+liwork;
564: #if defined(PETSC_USE_COMPLEX)
565:   ritz = ds->rwork+lwork;
566:   PetscStackCallBLAS("LAPACKstevr",LAPACKstevr_("V","A",&n3,d+l,e+l,&vl,&vu,&il,&iu,&abstol,&m,ritz+l,ds->rmat[DS_MAT_Q]+off,&ld,isuppz,ds->rwork,&lwork,ds->iwork,&liwork,&info));
567:   for (i=l;i<n;i++) wr[i] = ritz[i];
568: #else
569:   PetscStackCallBLAS("LAPACKstevr",LAPACKstevr_("V","A",&n3,d+l,e+l,&vl,&vu,&il,&iu,&abstol,&m,wr+l,Q+off,&ld,isuppz,ds->rwork,&lwork,ds->iwork,&liwork,&info));
570: #endif
571:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DSTEVR %d",info);
572: #if defined(PETSC_USE_COMPLEX)
573:   for (i=l;i<n;i++)
574:     for (j=l;j<n;j++)
575:       Q[i+j*ld] = (ds->rmat[DS_MAT_Q])[i+j*ld];
576: #endif
577:   if (ds->state<DS_STATE_INTERMEDIATE) {  /* accumulate previous Q */
578:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n3,&n3,&n3,&one,W+off,&ld,Q+off,&ld,&zero,A+off,&ld));
579:     DSCopyMatrix_Private(ds,DS_MAT_Q,DS_MAT_A);
580:   }
581:   for (i=l;i<n;i++) d[i] = PetscRealPart(wr[i]);

583:   /* Create diagonal matrix as a result */
584:   if (ds->compact) {
585:     PetscMemzero(e,(n-1)*sizeof(PetscReal));
586:   } else {
587:     for (i=l;i<n;i++) {
588:       PetscMemzero(A+l+i*ld,(n-l)*sizeof(PetscScalar));
589:     }
590:     for (i=l;i<n;i++) A[i+i*ld] = d[i];
591:   }

593:   /* Set zero wi */
594:   if (wi) for (i=l;i<n;i++) wi[i] = 0.0;
595:   return(0);
596: #endif
597: }

601: PetscErrorCode DSSolve_HEP_DC(DS ds,PetscScalar *wr,PetscScalar *wi)
602: {
603: #if defined(SLEPC_MISSING_LAPACK_STEDC)
605:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STEDC - Lapack routine is unavailable");
606: #else
608:   PetscInt       i;
609:   PetscBLASInt   n1,info,l,ld,off,lrwork,liwork;
610:   PetscScalar    *Q,*A;
611:   PetscReal      *d,*e;
612: #if defined(PETSC_USE_COMPLEX)
613:   PetscBLASInt   lwork;
614:   PetscInt       j;
615: #endif

618:   if (ds->bs>1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for bs>1");
619:   PetscBLASIntCast(ds->l,&l);
620:   PetscBLASIntCast(ds->ld,&ld);
621:   PetscBLASIntCast(ds->n-ds->l,&n1);
622:   off = l+l*ld;
623:   Q  = ds->mat[DS_MAT_Q];
624:   A  = ds->mat[DS_MAT_A];
625:   d  = ds->rmat[DS_MAT_T];
626:   e  = ds->rmat[DS_MAT_T]+ld;

628:   /* Reduce to tridiagonal form */
629:   DSIntermediate_HEP(ds);

631:   /* Solve the tridiagonal eigenproblem */
632:   for (i=0;i<l;i++) wr[i] = d[i];

634:   lrwork = 5*n1*n1+3*n1+1;
635:   liwork = 5*n1*n1+6*n1+6;
636: #if !defined(PETSC_USE_COMPLEX)
637:   DSAllocateWork_Private(ds,0,lrwork,liwork);
638:   PetscStackCallBLAS("LAPACKstedc",LAPACKstedc_("V",&n1,d+l,e+l,Q+off,&ld,ds->rwork,&lrwork,ds->iwork,&liwork,&info));
639: #else
640:   lwork = ld*ld;
641:   DSAllocateWork_Private(ds,lwork,lrwork,liwork);
642:   PetscStackCallBLAS("LAPACKstedc",LAPACKstedc_("V",&n1,d+l,e+l,Q+off,&ld,ds->work,&lwork,ds->rwork,&lrwork,ds->iwork,&liwork,&info));
643:   /* Fixing Lapack bug*/
644:   for (j=ds->l;j<ds->n;j++)
645:     for (i=0;i<ds->l;i++) Q[i+j*ld] = 0.0;
646: #endif
647:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xSTEDC %d",info);
648:   for (i=l;i<ds->n;i++) wr[i] = d[i];

650:   /* Create diagonal matrix as a result */
651:   if (ds->compact) {
652:     PetscMemzero(e,(ds->n-1)*sizeof(PetscReal));
653:   } else {
654:     for (i=l;i<ds->n;i++) {
655:       PetscMemzero(A+l+i*ld,(ds->n-l)*sizeof(PetscScalar));
656:     }
657:     for (i=l;i<ds->n;i++) A[i+i*ld] = d[i];
658:   }

660:   /* Set zero wi */
661:   if (wi) for (i=l;i<ds->n;i++) wi[i] = 0.0;
662:   return(0);
663: #endif
664: }

666: #if !defined(PETSC_USE_COMPLEX)
669: PetscErrorCode DSSolve_HEP_BDC(DS ds,PetscScalar *wr,PetscScalar *wi)
670: {
672:   PetscBLASInt   i,j,k,m,n,info,nblks,bs,ld,lde,lrwork,liwork,*ksizes,*iwork,mingapi;
673:   PetscScalar    *Q,*A;
674:   PetscReal      *D,*E,*d,*e,tol=PETSC_MACHINE_EPSILON/2,tau1=1e-16,tau2=1e-18,*rwork,mingap;

677:   if (ds->l>0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for l>1");
678:   if (ds->compact) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented for compact storage");
679:   PetscBLASIntCast(ds->ld,&ld);
680:   PetscBLASIntCast(ds->bs,&bs);
681:   PetscBLASIntCast(ds->n,&n);
682:   nblks = n/bs;
683:   Q  = ds->mat[DS_MAT_Q];
684:   A  = ds->mat[DS_MAT_A];
685:   d  = ds->rmat[DS_MAT_T];
686:   e  = ds->rmat[DS_MAT_T]+ld;
687:   lrwork = 4*n*n+60*n+1;
688:   liwork = 5*n+5*nblks-1;
689:   lde = 2*bs+1;
690:   DSAllocateWork_Private(ds,bs*n+lde*lde*(nblks-1),lrwork,nblks+liwork);
691:   D      = ds->work;
692:   E      = ds->work+bs*n;
693:   rwork  = ds->rwork;
694:   ksizes = ds->iwork;
695:   iwork  = ds->iwork+nblks;
696:   PetscMemzero(iwork,liwork*sizeof(PetscBLASInt));

698:   /* Copy matrix to block tridiagonal format */
699:   j=0;
700:   for (i=0;i<nblks;i++) {
701:     ksizes[i]=bs;
702:     for (k=0;k<bs;k++)
703:       for (m=0;m<bs;m++)
704:         D[k+m*bs+i*bs*bs] = PetscRealPart(A[j+k+(j+m)*n]);
705:     j = j + bs;
706:   }
707:   j=0;
708:   for (i=0;i<nblks-1;i++) {
709:     for (k=0;k<bs;k++)
710:       for (m=0;m<bs;m++)
711:         E[k+m*lde+i*lde*lde] = PetscRealPart(A[j+bs+k+(j+m)*n]);
712:     j = j + bs;
713:   }

715:   /* Solve the block tridiagonal eigenproblem */
716:   BDC_dsbtdc_("D","A",n,nblks,ksizes,D,bs,bs,E,lde,lde,tol,tau1,tau2,d,
717:            Q,n,rwork,lrwork,iwork,liwork,&mingap,&mingapi,&info,1,1);
718:   for (i=0;i<ds->n;i++) wr[i] = d[i];

720:   /* Create diagonal matrix as a result */
721:   if (ds->compact) {
722:     PetscMemzero(e,(ds->n-1)*sizeof(PetscReal));
723:   } else {
724:     for (i=0;i<ds->n;i++) {
725:       PetscMemzero(A+i*ld,ds->n*sizeof(PetscScalar));
726:     }
727:     for (i=0;i<ds->n;i++) A[i+i*ld] = wr[i];
728:   }

730:   /* Set zero wi */
731:   if (wi) for (i=0;i<ds->n;i++) wi[i] = 0.0;
732:   return(0);
733: }
734: #endif

738: PetscErrorCode DSTruncate_HEP(DS ds,PetscInt n)
739: {
740:   PetscInt       i,ld=ds->ld,l=ds->l;
741:   PetscScalar    *A;

744:   if (ds->state==DS_STATE_CONDENSED) ds->t = ds->n;
745:   A = ds->mat[DS_MAT_A];
746:   if (!ds->compact && ds->extrarow && ds->k==ds->n) {
747:     for (i=l;i<n;i++) A[n+i*ld] = A[ds->n+i*ld];
748:   }
749:   if (ds->extrarow) ds->k = n;
750:   else ds->k = 0;
751:   ds->n = n;
752:   return(0);
753: }

757: PetscErrorCode DSCond_HEP(DS ds,PetscReal *cond)
758: {
759: #if defined(PETSC_MISSING_LAPACK_GETRF) || defined(PETSC_MISSING_LAPACK_GETRI) || defined(SLEPC_MISSING_LAPACK_LANGE)
761:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF/GETRI/LANGE - Lapack routines are unavailable");
762: #else
764:   PetscScalar    *work;
765:   PetscReal      *rwork;
766:   PetscBLASInt   *ipiv;
767:   PetscBLASInt   lwork,info,n,ld;
768:   PetscReal      hn,hin;
769:   PetscScalar    *A;

772:   PetscBLASIntCast(ds->n,&n);
773:   PetscBLASIntCast(ds->ld,&ld);
774:   lwork = 8*ld;
775:   DSAllocateWork_Private(ds,lwork,ld,ld);
776:   work  = ds->work;
777:   rwork = ds->rwork;
778:   ipiv  = ds->iwork;
779:   DSSwitchFormat_HEP(ds,PETSC_FALSE);

781:   /* use workspace matrix W to avoid overwriting A */
782:   DSAllocateMat_Private(ds,DS_MAT_W);
783:   A = ds->mat[DS_MAT_W];
784:   PetscMemcpy(A,ds->mat[DS_MAT_A],sizeof(PetscScalar)*ds->ld*ds->ld);

786:   /* norm of A */
787:   hn = LAPACKlange_("I",&n,&n,A,&ld,rwork);

789:   /* norm of inv(A) */
790:   PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&n,&n,A,&ld,ipiv,&info));
791:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGETRF %d",info);
792:   PetscStackCallBLAS("LAPACKgetri",LAPACKgetri_(&n,A,&ld,ipiv,work,&lwork,&info));
793:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGETRI %d",info);
794:   hin = LAPACKlange_("I",&n,&n,A,&ld,rwork);

796:   *cond = hn*hin;
797:   return(0);
798: #endif
799: }

803: PetscErrorCode DSTranslateRKS_HEP(DS ds,PetscScalar alpha)
804: {
805: #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR)
807:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routines are unavailable");
808: #else
810:   PetscInt       i,j,k=ds->k;
811:   PetscScalar    *Q,*A,*R,*tau,*work;
812:   PetscBLASInt   ld,n1,n0,lwork,info;

815:   PetscBLASIntCast(ds->ld,&ld);
816:   DSAllocateWork_Private(ds,ld*ld,0,0);
817:   tau = ds->work;
818:   work = ds->work+ld;
819:   PetscBLASIntCast(ld*(ld-1),&lwork);
820:   DSAllocateMat_Private(ds,DS_MAT_W);
821:   A  = ds->mat[DS_MAT_A];
822:   Q  = ds->mat[DS_MAT_Q];
823:   R  = ds->mat[DS_MAT_W];
824:   /* Copy I+alpha*A */
825:   PetscMemzero(Q,ld*ld*sizeof(PetscScalar));
826:   PetscMemzero(R,ld*ld*sizeof(PetscScalar));
827:   for (i=0;i<k;i++) {
828:     Q[i+i*ld] = 1.0 + alpha*A[i+i*ld];
829:     Q[k+i*ld] = alpha*A[k+i*ld];
830:   }
831:   /* Compute qr */
832:   PetscBLASIntCast(k+1,&n1);
833:   PetscBLASIntCast(k,&n0);
834:   PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&n1,&n0,Q,&ld,tau,work,&lwork,&info));
835:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);
836:   /* Copy R from Q */
837:   for (j=0;j<k;j++)
838:     for (i=0;i<=j;i++)
839:       R[i+j*ld] = Q[i+j*ld];
840:   /* Compute orthogonal matrix in Q */
841:   PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&n1,&n1,&n0,Q,&ld,tau,work,&lwork,&info));
842:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info);
843:   /* Compute the updated matrix of projected problem */
844:   for (j=0;j<k;j++)
845:     for (i=0;i<k+1;i++)
846:       A[j*ld+i] = Q[i*ld+j];
847:   alpha = -1.0/alpha;
848:   PetscStackCallBLAS("BLAStrsm",BLAStrsm_("R","U","N","N",&n1,&n0,&alpha,R,&ld,A,&ld));
849:   for (i=0;i<k;i++)
850:     A[ld*i+i]-=alpha;
851:   return(0);
852: #endif
853: }

857: PETSC_EXTERN PetscErrorCode DSCreate_HEP(DS ds)
858: {
860:   ds->ops->allocate      = DSAllocate_HEP;
861:   ds->ops->view          = DSView_HEP;
862:   ds->ops->vectors       = DSVectors_HEP;
863:   ds->ops->solve[0]      = DSSolve_HEP_QR;
864:   ds->ops->solve[1]      = DSSolve_HEP_MRRR;
865:   ds->ops->solve[2]      = DSSolve_HEP_DC;
866: #if !defined(PETSC_USE_COMPLEX)
867:   ds->ops->solve[3]      = DSSolve_HEP_BDC;
868: #endif
869:   ds->ops->sort          = DSSort_HEP;
870:   ds->ops->truncate      = DSTruncate_HEP;
871:   ds->ops->update        = DSUpdateExtraRow_HEP;
872:   ds->ops->cond          = DSCond_HEP;
873:   ds->ops->transrks      = DSTranslateRKS_HEP;
874:   ds->ops->normalize     = DSNormalize_HEP;
875:   return(0);
876: }

slepc-3.7.4/src/sys/classes/ds/impls/hep/dshep.c0000644000175000017500000007237613107004621021021 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #undef __FUNCT__ #define __FUNCT__ "DSAllocate_HEP" PetscErrorCode DSAllocate_HEP(DS ds,PetscInt ld) { PetscErrorCode ierr; PetscFunctionBegin; ierr = DSAllocateMat_Private(ds,DS_MAT_A);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_Q);CHKERRQ(ierr); ierr = DSAllocateMatReal_Private(ds,DS_MAT_T);CHKERRQ(ierr); ierr = PetscFree(ds->perm);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ds->perm);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)ds,ld*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); } /* 0 l k n-1 ----------------------------------------- |* . . | | * . . | | * . . | | * . . | |. . . . o o | | o o | | o o | | o o | | o o | | o o | |. . . . o o o o o o o x | | x x x | | x x x | | x x x | | x x x | | x x x | | x x x | | x x x | | x x x| | x x| ----------------------------------------- */ #undef __FUNCT__ #define __FUNCT__ "DSSwitchFormat_HEP" static PetscErrorCode DSSwitchFormat_HEP(DS ds,PetscBool tocompact) { PetscErrorCode ierr; PetscReal *T = ds->rmat[DS_MAT_T]; PetscScalar *A = ds->mat[DS_MAT_A]; PetscInt i,n=ds->n,k=ds->k,ld=ds->ld; PetscFunctionBegin; if (tocompact) { /* switch from dense (arrow) to compact storage */ ierr = PetscMemzero(T,3*ld*sizeof(PetscReal));CHKERRQ(ierr); for (i=0;iextrarow) T[n-1+ld] = PetscRealPart(A[n+(n-1)*ld]); } else { /* switch from compact (arrow) to dense storage */ ierr = PetscMemzero(A,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;iextrarow) A[n+(n-1)*ld] = T[n-1+ld]; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSView_HEP" PetscErrorCode DSView_HEP(DS ds,PetscViewer viewer) { PetscErrorCode ierr; PetscViewerFormat format; PetscInt i,j,r,c,rows; PetscReal value; const char *methodname[] = { "Implicit QR method (_steqr)", "Relatively Robust Representations (_stevr)", "Divide and Conquer method (_stedc)", "Block Divide and Conquer method (dsbtdc)" }; const int nmeth=sizeof(methodname)/sizeof(methodname[0]); PetscFunctionBegin; ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) { if (ds->bs>1) { ierr = PetscViewerASCIIPrintf(viewer,"block size: %D\n",ds->bs);CHKERRQ(ierr); } if (ds->method>=nmeth) { ierr = PetscViewerASCIIPrintf(viewer,"solving the problem with: INVALID METHOD\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"solving the problem with: %s\n",methodname[ds->method]);CHKERRQ(ierr); } PetscFunctionReturn(0); } if (ds->compact) { ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); rows = ds->extrarow? ds->n+1: ds->n; if (format == PETSC_VIEWER_ASCII_MATLAB) { ierr = PetscViewerASCIIPrintf(viewer,"%% Size = %D %D\n",rows,ds->n);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"zzz = zeros(%D,3);\n",3*ds->n);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"zzz = [\n");CHKERRQ(ierr); for (i=0;in;i++) { ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",i+1,i+1,*(ds->rmat[DS_MAT_T]+i));CHKERRQ(ierr); } for (i=0;ik+1); c = i+1; ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",r,c,*(ds->rmat[DS_MAT_T]+ds->ld+i));CHKERRQ(ierr); if (in-1 && ds->kn) { /* do not print vertical arrow when k=n */ ierr = PetscViewerASCIIPrintf(viewer,"%D %D %18.16e\n",c,r,*(ds->rmat[DS_MAT_T]+ds->ld+i));CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,"];\n%s = spconvert(zzz);\n",DSMatName[DS_MAT_T]);CHKERRQ(ierr); } else { for (i=0;in;j++) { if (i==j) value = *(ds->rmat[DS_MAT_T]+i); else if ((ik && j==ds->k) || (i==ds->k && jk)) value = *(ds->rmat[DS_MAT_T]+ds->ld+PetscMin(i,j)); else if (i==j+1 && i>ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+i-1); else if (i+1==j && j>ds->k) value = *(ds->rmat[DS_MAT_T]+ds->ld+j-1); else value = 0.0; ierr = PetscViewerASCIIPrintf(viewer," %18.16e ",value);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerFlush(viewer);CHKERRQ(ierr); } else { ierr = DSViewMat(ds,viewer,DS_MAT_A);CHKERRQ(ierr); } if (ds->state>DS_STATE_INTERMEDIATE) { ierr = DSViewMat(ds,viewer,DS_MAT_Q);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSVectors_HEP" PetscErrorCode DSVectors_HEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm) { PetscScalar *Q = ds->mat[DS_MAT_Q]; PetscInt ld = ds->ld,i; PetscErrorCode ierr; PetscFunctionBegin; switch (mat) { case DS_MAT_X: case DS_MAT_Y: if (j) { if (ds->state>=DS_STATE_CONDENSED) { ierr = PetscMemcpy(ds->mat[mat]+(*j)*ld,Q+(*j)*ld,ld*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemzero(ds->mat[mat]+(*j)*ld,ld*sizeof(PetscScalar));CHKERRQ(ierr); *(ds->mat[mat]+(*j)+(*j)*ld) = 1.0; } } else { if (ds->state>=DS_STATE_CONDENSED) { ierr = PetscMemcpy(ds->mat[mat],Q,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemzero(ds->mat[mat],ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;in;i++) *(ds->mat[mat]+i+i*ld) = 1.0; } } if (rnorm && j) *rnorm = PetscAbsScalar(Q[ds->n-1+(*j)*ld]); break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSNormalize_HEP" PetscErrorCode DSNormalize_HEP(DS ds,DSMatType mat,PetscInt col) { PetscFunctionBegin; switch (mat) { case DS_MAT_X: case DS_MAT_Y: case DS_MAT_Q: /* All the matrices resulting from DSVectors and DSSolve are already normalized */ break; case DS_MAT_U: case DS_MAT_VT: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented yet"); break; default: SETERRQ(PetscObjectComm((PetscObject)ds),PETSC_ERR_ARG_OUTOFRANGE,"Invalid mat parameter"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "ArrowTridiag" /* ARROWTRIDIAG reduces a symmetric arrowhead matrix of the form [ d 0 0 0 e ] [ 0 d 0 0 e ] A = [ 0 0 d 0 e ] [ 0 0 0 d e ] [ e e e e d ] to tridiagonal form [ d e 0 0 0 ] [ e d e 0 0 ] T = Q'*A*Q = [ 0 e d e 0 ], [ 0 0 e d e ] [ 0 0 0 e d ] where Q is an orthogonal matrix. Rutishauser's algorithm is used to perform the reduction, which requires O(n**2) flops. The accumulation of the orthogonal factor Q, however, requires O(n**3) flops. Arguments ========= N (input) INTEGER The order of the matrix A. N >= 0. D (input/output) DOUBLE PRECISION array, dimension (N) On entry, the diagonal entries of the matrix A to be reduced. On exit, the diagonal entries of the reduced matrix T. E (input/output) DOUBLE PRECISION array, dimension (N-1) On entry, the off-diagonal entries of the matrix A to be reduced. On exit, the subdiagonal entries of the reduced matrix T. Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N) On exit, the orthogonal matrix Q. LDQ (input) INTEGER The leading dimension of the array Q. Note ==== Based on Fortran code contributed by Daniel Kressner */ static PetscErrorCode ArrowTridiag(PetscBLASInt n,PetscReal *d,PetscReal *e,PetscScalar *Q,PetscBLASInt ld) { #if defined(SLEPC_MISSING_LAPACK_LARTG) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LARTG - Lapack routine is unavailable"); #else PetscBLASInt i,j,j2,one=1; PetscReal c,s,p,off,temp; PetscFunctionBegin; if (n<=2) PetscFunctionReturn(0); for (j=0;j=0;i--) { off = -s*e[i]; e[i] = c*e[i]; temp = e[i+1]; PetscStackCallBLAS("LAPACKlartg",LAPACKlartg_(&temp,&off,&c,&s,&e[i+1])); s = -s; temp = (d[i]-d[i+1])*s - 2.0*c*e[i]; p = s*temp; d[i+1] += p; d[i] -= p; e[i] = -e[i] - c*temp; j2 = j+2; PetscStackCallBLAS("BLASrot",BLASrot_(&j2,Q+i*ld,&one,Q+(i+1)*ld,&one,&c,&s)); } } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSIntermediate_HEP" /* Reduce to tridiagonal form by means of ArrowTridiag. */ static PetscErrorCode DSIntermediate_HEP(DS ds) { #if defined(SLEPC_MISSING_LAPACK_SYTRD) || defined(SLEPC_MISSING_LAPACK_ORGTR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"SYTRD/ORGTR - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt n1,n2,n3,lwork,info,l,n,ld,off; PetscScalar *A,*Q,*work,*tau; PetscReal *d,*e; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->l,&l);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->k-l+1,&n1);CHKERRQ(ierr); /* size of leading block, excl. locked */ ierr = PetscBLASIntCast(n-ds->k-1,&n2);CHKERRQ(ierr); /* size of trailing block */ n3 = n1+n2; off = l+l*ld; A = ds->mat[DS_MAT_A]; Q = ds->mat[DS_MAT_Q]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T]+ld; ierr = PetscMemzero(Q,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;icompact) { if (ds->statestatework; work = ds->work+ld; lwork = ld*ld; PetscStackCallBLAS("LAPACKsytrd",LAPACKsytrd_("L",&n3,Q+off,&ld,d+l,e+l,tau,work,&lwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xSYTRD %d",info); PetscStackCallBLAS("LAPACKorgtr",LAPACKorgtr_("L",&n3,Q+off,&ld,tau,work,&lwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGTR %d",info); } else { /* copy tridiagonal to d,e */ for (i=l;ild; PetscScalar *A; PetscReal *d; PetscFunctionBegin; if (!ds->sc) PetscFunctionReturn(0); n = ds->n; l = ds->l; A = ds->mat[DS_MAT_A]; d = ds->rmat[DS_MAT_T]; perm = ds->perm; if (!rr) { ierr = DSSortEigenvaluesReal_Private(ds,d,perm);CHKERRQ(ierr); } else { ierr = DSSortEigenvalues_Private(ds,rr,ri,perm,PETSC_FALSE);CHKERRQ(ierr); } for (i=l;icompact) { for (i=l;in,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); A = ds->mat[DS_MAT_A]; Q = ds->mat[DS_MAT_Q]; e = ds->rmat[DS_MAT_T]+ld; if (ds->compact) { beta = e[n-1]; /* in compact, we assume all entries are zero except the last one */ for (i=0;ik = n; } else { ierr = DSAllocateWork_Private(ds,2*ld,0,0);CHKERRQ(ierr); x = ds->work; y = ds->work+ld; for (i=0;ik = n; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSSolve_HEP_QR" PetscErrorCode DSSolve_HEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi) { #if defined(PETSC_MISSING_LAPACK_STEQR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STEQR - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i; PetscBLASInt n1,n2,n3,info,l,n,ld,off; PetscScalar *Q,*A; PetscReal *d,*e; PetscFunctionBegin; if (ds->bs>1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for bs>1"); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->l,&l);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->k-l+1,&n1);CHKERRQ(ierr); /* size of leading block, excl. locked */ ierr = PetscBLASIntCast(n-ds->k-1,&n2);CHKERRQ(ierr); /* size of trailing block */ n3 = n1+n2; off = l+l*ld; Q = ds->mat[DS_MAT_Q]; A = ds->mat[DS_MAT_A]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T]+ld; /* Reduce to tridiagonal form */ ierr = DSIntermediate_HEP(ds);CHKERRQ(ierr); /* Solve the tridiagonal eigenproblem */ for (i=0;irwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xSTEQR %d",info); for (i=l;icompact) { ierr = PetscMemzero(e,(n-1)*sizeof(PetscReal));CHKERRQ(ierr); } else { for (i=l;ibs>1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for bs>1"); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->l,&l);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->k-l+1,&n1);CHKERRQ(ierr); /* size of leading block, excl. locked */ ierr = PetscBLASIntCast(n-ds->k-1,&n2);CHKERRQ(ierr); /* size of trailing block */ n3 = n1+n2; off = l+l*ld; A = ds->mat[DS_MAT_A]; Q = ds->mat[DS_MAT_Q]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T]+ld; /* Reduce to tridiagonal form */ ierr = DSIntermediate_HEP(ds);CHKERRQ(ierr); /* Solve the tridiagonal eigenproblem */ for (i=0;istatemat[DS_MAT_W]; } #if defined(PETSC_USE_COMPLEX) ierr = DSAllocateMatReal_Private(ds,DS_MAT_Q);CHKERRQ(ierr); #endif lwork = 20*ld; liwork = 10*ld; ierr = DSAllocateWork_Private(ds,0,lwork+ld,liwork+2*ld);CHKERRQ(ierr); isuppz = ds->iwork+liwork; #if defined(PETSC_USE_COMPLEX) ritz = ds->rwork+lwork; PetscStackCallBLAS("LAPACKstevr",LAPACKstevr_("V","A",&n3,d+l,e+l,&vl,&vu,&il,&iu,&abstol,&m,ritz+l,ds->rmat[DS_MAT_Q]+off,&ld,isuppz,ds->rwork,&lwork,ds->iwork,&liwork,&info)); for (i=l;irwork,&lwork,ds->iwork,&liwork,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack DSTEVR %d",info); #if defined(PETSC_USE_COMPLEX) for (i=l;irmat[DS_MAT_Q])[i+j*ld]; #endif if (ds->statecompact) { ierr = PetscMemzero(e,(n-1)*sizeof(PetscReal));CHKERRQ(ierr); } else { for (i=l;ibs>1) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for bs>1"); ierr = PetscBLASIntCast(ds->l,&l);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->n-ds->l,&n1);CHKERRQ(ierr); off = l+l*ld; Q = ds->mat[DS_MAT_Q]; A = ds->mat[DS_MAT_A]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T]+ld; /* Reduce to tridiagonal form */ ierr = DSIntermediate_HEP(ds);CHKERRQ(ierr); /* Solve the tridiagonal eigenproblem */ for (i=0;irwork,&lrwork,ds->iwork,&liwork,&info)); #else lwork = ld*ld; ierr = DSAllocateWork_Private(ds,lwork,lrwork,liwork);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKstedc",LAPACKstedc_("V",&n1,d+l,e+l,Q+off,&ld,ds->work,&lwork,ds->rwork,&lrwork,ds->iwork,&liwork,&info)); /* Fixing Lapack bug*/ for (j=ds->l;jn;j++) for (i=0;il;i++) Q[i+j*ld] = 0.0; #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xSTEDC %d",info); for (i=l;in;i++) wr[i] = d[i]; /* Create diagonal matrix as a result */ if (ds->compact) { ierr = PetscMemzero(e,(ds->n-1)*sizeof(PetscReal));CHKERRQ(ierr); } else { for (i=l;in;i++) { ierr = PetscMemzero(A+l+i*ld,(ds->n-l)*sizeof(PetscScalar));CHKERRQ(ierr); } for (i=l;in;i++) A[i+i*ld] = d[i]; } /* Set zero wi */ if (wi) for (i=l;in;i++) wi[i] = 0.0; PetscFunctionReturn(0); #endif } #if !defined(PETSC_USE_COMPLEX) #undef __FUNCT__ #define __FUNCT__ "DSSolve_HEP_BDC" PetscErrorCode DSSolve_HEP_BDC(DS ds,PetscScalar *wr,PetscScalar *wi) { PetscErrorCode ierr; PetscBLASInt i,j,k,m,n,info,nblks,bs,ld,lde,lrwork,liwork,*ksizes,*iwork,mingapi; PetscScalar *Q,*A; PetscReal *D,*E,*d,*e,tol=PETSC_MACHINE_EPSILON/2,tau1=1e-16,tau2=1e-18,*rwork,mingap; PetscFunctionBegin; if (ds->l>0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"This method is not prepared for l>1"); if (ds->compact) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Not implemented for compact storage"); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->bs,&bs);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); nblks = n/bs; Q = ds->mat[DS_MAT_Q]; A = ds->mat[DS_MAT_A]; d = ds->rmat[DS_MAT_T]; e = ds->rmat[DS_MAT_T]+ld; lrwork = 4*n*n+60*n+1; liwork = 5*n+5*nblks-1; lde = 2*bs+1; ierr = DSAllocateWork_Private(ds,bs*n+lde*lde*(nblks-1),lrwork,nblks+liwork);CHKERRQ(ierr); D = ds->work; E = ds->work+bs*n; rwork = ds->rwork; ksizes = ds->iwork; iwork = ds->iwork+nblks; ierr = PetscMemzero(iwork,liwork*sizeof(PetscBLASInt));CHKERRQ(ierr); /* Copy matrix to block tridiagonal format */ j=0; for (i=0;in;i++) wr[i] = d[i]; /* Create diagonal matrix as a result */ if (ds->compact) { ierr = PetscMemzero(e,(ds->n-1)*sizeof(PetscReal));CHKERRQ(ierr); } else { for (i=0;in;i++) { ierr = PetscMemzero(A+i*ld,ds->n*sizeof(PetscScalar));CHKERRQ(ierr); } for (i=0;in;i++) A[i+i*ld] = wr[i]; } /* Set zero wi */ if (wi) for (i=0;in;i++) wi[i] = 0.0; PetscFunctionReturn(0); } #endif #undef __FUNCT__ #define __FUNCT__ "DSTruncate_HEP" PetscErrorCode DSTruncate_HEP(DS ds,PetscInt n) { PetscInt i,ld=ds->ld,l=ds->l; PetscScalar *A; PetscFunctionBegin; if (ds->state==DS_STATE_CONDENSED) ds->t = ds->n; A = ds->mat[DS_MAT_A]; if (!ds->compact && ds->extrarow && ds->k==ds->n) { for (i=l;in+i*ld]; } if (ds->extrarow) ds->k = n; else ds->k = 0; ds->n = n; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "DSCond_HEP" PetscErrorCode DSCond_HEP(DS ds,PetscReal *cond) { #if defined(PETSC_MISSING_LAPACK_GETRF) || defined(PETSC_MISSING_LAPACK_GETRI) || defined(SLEPC_MISSING_LAPACK_LANGE) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF/GETRI/LANGE - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscScalar *work; PetscReal *rwork; PetscBLASInt *ipiv; PetscBLASInt lwork,info,n,ld; PetscReal hn,hin; PetscScalar *A; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->n,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); lwork = 8*ld; ierr = DSAllocateWork_Private(ds,lwork,ld,ld);CHKERRQ(ierr); work = ds->work; rwork = ds->rwork; ipiv = ds->iwork; ierr = DSSwitchFormat_HEP(ds,PETSC_FALSE);CHKERRQ(ierr); /* use workspace matrix W to avoid overwriting A */ ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); A = ds->mat[DS_MAT_W]; ierr = PetscMemcpy(A,ds->mat[DS_MAT_A],sizeof(PetscScalar)*ds->ld*ds->ld);CHKERRQ(ierr); /* norm of A */ hn = LAPACKlange_("I",&n,&n,A,&ld,rwork); /* norm of inv(A) */ PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&n,&n,A,&ld,ipiv,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGETRF %d",info); PetscStackCallBLAS("LAPACKgetri",LAPACKgetri_(&n,A,&ld,ipiv,work,&lwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGETRI %d",info); hin = LAPACKlange_("I",&n,&n,A,&ld,rwork); *cond = hn*hin; PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "DSTranslateRKS_HEP" PetscErrorCode DSTranslateRKS_HEP(DS ds,PetscScalar alpha) { #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscInt i,j,k=ds->k; PetscScalar *Q,*A,*R,*tau,*work; PetscBLASInt ld,n1,n0,lwork,info; PetscFunctionBegin; ierr = PetscBLASIntCast(ds->ld,&ld);CHKERRQ(ierr); ierr = DSAllocateWork_Private(ds,ld*ld,0,0);CHKERRQ(ierr); tau = ds->work; work = ds->work+ld; ierr = PetscBLASIntCast(ld*(ld-1),&lwork);CHKERRQ(ierr); ierr = DSAllocateMat_Private(ds,DS_MAT_W);CHKERRQ(ierr); A = ds->mat[DS_MAT_A]; Q = ds->mat[DS_MAT_Q]; R = ds->mat[DS_MAT_W]; /* Copy I+alpha*A */ ierr = PetscMemzero(Q,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMemzero(R,ld*ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;iops->allocate = DSAllocate_HEP; ds->ops->view = DSView_HEP; ds->ops->vectors = DSVectors_HEP; ds->ops->solve[0] = DSSolve_HEP_QR; ds->ops->solve[1] = DSSolve_HEP_MRRR; ds->ops->solve[2] = DSSolve_HEP_DC; #if !defined(PETSC_USE_COMPLEX) ds->ops->solve[3] = DSSolve_HEP_BDC; #endif ds->ops->sort = DSSort_HEP; ds->ops->truncate = DSTruncate_HEP; ds->ops->update = DSUpdateExtraRow_HEP; ds->ops->cond = DSCond_HEP; ds->ops->transrks = DSTranslateRKS_HEP; ds->ops->normalize = DSNormalize_HEP; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/ds/impls/hep/makefile.html0000644000175000017500000000470513107004621022204 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = dshep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     = bdc
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/hep/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/0000755000175000017500000000000013107004621020263 5ustar jromanjromanslepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/makefile0000644000175000017500000000226513107004621021770 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib #requiresscalar real CFLAGS = FFLAGS = SOURCEC = dibtdc.c dlaed3m.c dmerg2.c dsbtdc.c dsrtdf.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = DS LOCDIR = src/sys/classes/ds/impls/hep/bdc/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dmerg2.c0000644000175000017500000003540313107004621021614 0ustar jromanjroman/* BDC - Block-divide and conquer (see description in README file). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include PetscErrorCode BDC_dmerg2_(const char *jobz,PetscBLASInt rkct,PetscBLASInt n, PetscReal *ev,PetscReal *q,PetscBLASInt ldq,PetscBLASInt *indxq, PetscReal *rho,PetscReal *u,PetscBLASInt sbrkp1,PetscReal *v, PetscBLASInt sbrk,PetscBLASInt cutpnt,PetscReal *work,PetscBLASInt lwork, PetscBLASInt *iwork,PetscReal tol,PetscBLASInt *info,PetscBLASInt jobz_len) { /* -- Routine written in LAPACK Version 3.0 style -- */ /* *************************************************** */ /* Written by */ /* Michael Moldaschl and Wilfried Gansterer */ /* University of Vienna */ /* last modification: March 16, 2014 */ /* Small adaptations of original code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* see http://dx.doi.org/10.1137/S1064827501399432 */ /* *************************************************** */ /* Purpose */ /* ======= */ /* DMERG2 computes the updated eigensystem of a diagonal matrix after */ /* modification by a rank-one symmetric matrix. The diagonal matrix */ /* consists of two diagonal submatrices, and the vectors defining the */ /* rank-1 matrix similarly have two underlying subvectors each. */ /* The dimension of the first subproblem is CUTPNT, the dimension of */ /* the second subproblem is N-CUTPNT. */ /* T = Q(in) ( EV(in) + RHO * Z*Z' ) Q'(in) = Q(out) * EV(out) * Q'(out) */ /* where Z = Q'[V U']', where V is a row vector and U is a column */ /* vector with dimensions corresponding to the two underlying */ /* subproblems. */ /* The eigenvectors of the original matrix are stored in Q, and the */ /* eigenvalues in EV. The algorithm consists of three stages: */ /* The first stage consists of deflating the size of the problem */ /* when there are multiple eigenvalues or if there is a zero in */ /* the Z vector. For each such occurrence the dimension of the */ /* secular equation problem is reduced by one. This stage is */ /* performed by the routine DSRTDF. */ /* The second stage consists of calculating the updated */ /* eigenvalues. This is done by finding the roots of the secular */ /* equation via the routine DLAED4 (as called by DLAED3M). */ /* This routine also calculates the eigenvectors of the current */ /* problem. */ /* If( JOBZ.EQ.'D' ) then the final stage consists */ /* of computing the updated eigenvectors directly using the updated */ /* eigenvalues. The eigenvectors for the current problem are multiplied */ /* with the eigenvectors from the overall problem. */ /* Arguments */ /* ========= */ /* JOBZ (input) CHARACTER*1 */ /* = 'N': Compute eigenvalues only (not implemented); */ /* = 'D': Compute eigenvalues and eigenvectors. */ /* Eigenvectors are accumulated in the divide-and-conquer */ /* process. */ /* RKCT (input) INTEGER */ /* The number of the rank modification which is accounted for */ /* (RKCT >= 1). Required parameter, because the update operation of the */ /* modification vector can be performed much more efficiently */ /* if RKCT.EQ.1. In that case, the eigenvector matrix is still */ /* block-diagonal. For RKCT.GE.2 the eigenvector matrix for the update */ /* operation has filled up and is a full matrix. */ /* N (input) INTEGER */ /* The dimension of the symmetric block tridiagonal matrix. */ /* N >= 0. */ /* EV (input/output) DOUBLE PRECISION array, dimension (N) */ /* On entry, the eigenvalues (=diagonal values) of the */ /* rank-1-perturbed matrix. */ /* On exit, the eigenvalues of the repaired matrix. */ /* Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N) */ /* On entry, the eigenvectors of the rank-1-perturbed matrix. */ /* On exit, the eigenvectors of the repaired tridiagonal matrix. */ /* LDQ (input) INTEGER */ /* The leading dimension of the array Q. LDQ >= max(1,N). */ /* INDXQ (input/output) INTEGER array, dimension (N) */ /* On entry, the permutation which separately sorts the two */ /* subproblems in EV into ascending order. */ /* On exit, the permutation which will reintegrate the */ /* subproblems back into sorted order, */ /* i.e. EV( INDXQ( I = 1, N ) ) will be in ascending order. */ /* RHO (input/output) DOUBLE PRECISION */ /* The scalar in the rank-1 perturbation. Modified (multiplied */ /* by 2) in DSRTDF. */ /* U (input) DOUBLE PRECISION array; dimension (SBRKP1), where SBRKP1 */ /* is the size of the first (original) block after CUTPNT. */ /* The column vector of the rank-1 subdiagonal connecting the */ /* two diagonal subproblems. */ /* Theoretically, zero entries might have to be appended after U */ /* in order to make it have dimension (N-CUTPNT). However, this */ /* is not required because it can be accounted for in the */ /* matrix-vector product using the argument SBRKP1. */ /* SBRKP1 (input) INTEGER */ /* Dimension of the relevant (non-zero) part of the vector U. */ /* Equal to the size of the first original block after the */ /* breakpoint. */ /* V (input) DOUBLE PRECISION array; dimension (SBRK), where SBRK */ /* is the size of the last (original) block before CUTPNT. */ /* The row vector of the rank-1 subdiagonal connecting the two */ /* diagonal subproblems. */ /* Theoretically, zero entries might have to be inserted in front */ /* of V in order to make it have dimension (CUTPNT). However, this */ /* is not required because it can be accounted for in the */ /* matrix-vector product using the argument SBRK. */ /* SBRK (input) INTEGER */ /* Dimension of the relevant (non-zero) part of the vector V. */ /* Equal to the size of the last original block before the */ /* breakpoint. */ /* CUTPNT (input) INTEGER */ /* The location of the last eigenvalue of the leading diagonal */ /* block. min(1,N) <= CUTPNT <= max(1,N). */ /* WORK (workspace) DOUBLE PRECISION array, dimension (LWORK) */ /* LWORK (input) INTEGER */ /* The dimension of the array WORK. */ /* In order to guarantee correct results in all cases, */ /* LWORK must be at least ( 2*N**2 + 3*N ). In many cases, */ /* less workspace is required. The absolute minimum required is */ /* ( N**2 + 3*N ). */ /* If the workspace provided is not sufficient, the routine will */ /* return a corresponding error code and report how much workspace */ /* was missing (see INFO). */ /* NOTE: This parameter is needed for determining whether enough */ /* workspace is provided, and, if not, for computing how */ /* much workspace is needed. */ /* IWORK (workspace) INTEGER array, dimension ( 4*N ) */ /* TOL (input) DOUBLE PRECISION */ /* User specified deflation tolerance for the routine DSRTDF. */ /* INFO (output) INTEGER */ /* = 0: successful exit. */ /* < -200: not enough workspace */ /* ABS(INFO + 200) numbers have to be stored in addition */ /* to the workspace provided, otherwise some eigenvectors */ /* will be incorrect. */ /* < 0, > -99: if INFO.EQ.-i, the i-th argument had an */ /* illegal value. */ /* > 0: if INFO.EQ.1, an eigenvalue did not converge */ /* if INFO.EQ.2, the deflation counters DZ and DE do not sum */ /* up to the total number N-K of components */ /* deflated */ /* Further Details */ /* =============== */ /* Based on code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* Based on the design of the LAPACK code Dlaed1.f written by Jeff */ /* Rutter, Computer Science Division, University of California at */ /* Berkeley, and modified by Francoise Tisseur, University of Tennessee. */ /* ===================================================================== */ #if defined(SLEPC_MISSING_LAPACK_LAMRG) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAMRG - Lapack routine is unavailable"); #else PetscBLASInt i, k, n1, n2, de, is, dz, iw, iz, iq2, nmc, cpp1; PetscBLASInt indx, indxc, indxp, lwmin, idlmda; PetscBLASInt spneed, coltyp, tmpcut, i__1, i__2, one=1, mone=-1; char defl[1]; PetscReal done = 1.0, dzero = 0.0; PetscErrorCode ierr; PetscFunctionBegin; *info = 0; lwmin = n*n + n * 3; if (n < 0) { *info = -3; } else if (ldq < PetscMax(1,n)) { *info = -6; } else if (cutpnt < PetscMin(1,n) || cutpnt > PetscMax(1,n)) { *info = -13; } else if (lwork < lwmin) { *info = -15; } if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DMERG2",-(*info)); /* **************************************************************************** */ /* Quick return if possible */ if (n == 0) PetscFunctionReturn(0); /* **************************************************************************** */ /* The following values are integer pointers which indicate */ /* the portion of the workspace used by a particular array in DSRTDF */ /* and DLAED3M. */ iz = 0; idlmda = iz + n; iw = idlmda + n; iq2 = iw + n; is = iq2 + n * n; /* After the pointer IS the matrix S is stored and read in WORK */ /* in the routine DLAED3M. */ indx = 0; indxc = indx + n; coltyp = indxc + n; indxp = coltyp + n; /* If eigenvectors are to be accumulated in the divide-and-conquer */ /* process ( JOBZ.EQ.'D' ) form the z-vector which consists of */ /* Q_1^T * V and Q_2^T * U. */ cpp1 = cutpnt + 1; if (rkct == 1) { /* for the first rank modification the eigenvector matrix has */ /* special block-diagonal structure and therefore Q_1^T * V and */ /* Q_2^T * U can be formed separately. */ PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrk, &cutpnt, &done, &q[cutpnt - sbrk], &ldq, v, &one, &dzero, &work[iz], &one)); nmc = n - cutpnt; PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrkp1, &nmc, &done, &q[cpp1-1 + (cpp1-1)*ldq], &ldq, u, &one, &dzero, &work[iz + cutpnt], &one)); } else { /* for the higher rank modifications, the vectors V and U */ /* have to be multiplied with the full eigenvector matrix */ PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrk, &n, &done, &q[cutpnt - sbrk], &ldq, v, &one, &dzero, &work[iz], &one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrkp1, &n, &done, &q[cpp1-1], &ldq, u, &one, &done, &work[iz], &one)); } /* **************************************************************************** */ /* Deflate eigenvalues. */ if (rkct == 1) { /* for the first rank modification we need the actual cutpoint */ n1 = cutpnt; tmpcut = cutpnt; } else { /* for the later rank modifications there is no actual cutpoint any more */ n1 = n; /* The original value of CUTPNT has to be preserved for the next time */ /* this subroutine is called (therefore, CUTPNT is an INPUT parameter */ /* and not to be changed). Thus, assign N to TMPCUT and use the local */ /* variable TMPCUT from now on for the cut point. */ tmpcut = n; } /* initialize the flag DEFL (indicates whether deflation occurred - */ /* this information is needed later in DLAED3M) */ *(unsigned char *)defl = '0'; /* call DSRTDF for deflation */ ierr = BDC_dsrtdf_(&k, n, n1, ev, q, ldq, indxq, rho, &work[iz], &work[idlmda], &work[iw], &work[iq2], &iwork[indx], &iwork[indxc], &iwork[indxp], &iwork[coltyp], tol, &dz, &de, info); CHKERRQ(ierr); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dmerg2: error in dsrtdf, info = %d",*info); if (k < n) { /* ....some deflation occurred in dsrtdf, set the flag DEFL */ /* (needed in DLAED3M.f, since Givens rotations need to be */ /* applied to the eigenvector matrix only if some deflation */ /* happened) */ *(unsigned char *)defl = '1'; } /* **************************************************************************** */ /* Solve the Secular Equation. */ if (k != 0 || k == 0) { /* ....not everything was deflated. */ /* ....check whether enough workspace is available: */ /* Note that the following (upper) bound SPNEED for the workspace */ /* requirements should also hold in the extreme case TMPCUT=N, */ /* which happens for every rank modification after the first one. */ i__1 = (iwork[coltyp] + iwork[coltyp+1]) * k; i__2 = (iwork[coltyp+1] + iwork[coltyp + 2]) * k; spneed = is + PetscMax(i__1,i__2) - 1; if (spneed > lwork) SETERRQ1(PETSC_COMM_SELF,1,"dmerg2: Workspace needed exceeds the workspace provided by %d numbers",spneed-lwork); /* calling DLAED3M for solving the secular equation. */ ierr = BDC_dlaed3m_(jobz, defl, k, n, tmpcut, ev, q, ldq, *rho, &work[idlmda], &work[iq2], &iwork[indxc], &iwork[coltyp], &work[iw], &work[is], info, 1, 1);CHKERRQ(ierr); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dmerg2: error in dlaed3m, info = %d",*info); /* Prepare the INDXQ sorting permutation. */ n1 = k; n2 = n - k; PetscStackCallBLAS("LAPACKlamrg",LAPACKlamrg_(&n1, &n2, ev, &one, &mone, indxq)); if (k == 0) { for (i = 0; i < n; ++i) indxq[i] = i+1; } } else { /* ....everything was deflated (K.EQ.0) */ for (i = 0; i < n; ++i) indxq[i] = i+1; } PetscFunctionReturn(0); #endif } slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dibtdc.c.html0000644000175000017500000017325113107004621022634 0ustar jromanjroman
Actual source code: dibtdc.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BDC - Block-divide and conquer (see description in README file).

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>
 25: #include <slepcblaslapack.h>

 27: static PetscErrorCode cutlr_(PetscBLASInt start,PetscBLASInt n,PetscBLASInt blkct, 
 28:         PetscBLASInt *bsizes,PetscBLASInt *ranks,PetscBLASInt *cut,
 29:         PetscBLASInt *lsum,PetscBLASInt *lblks,PetscBLASInt *info)
 30: {
 31: /*  -- Routine written in LAPACK Version 3.0 style -- */
 32: /* *************************************************** */
 33: /*     Written by */
 34: /*     Michael Moldaschl and Wilfried Gansterer */
 35: /*     University of Vienna */
 36: /*     last modification: March 16, 2014 */

 38: /*     Small adaptations of original code written by */
 39: /*     Wilfried Gansterer and Bob Ward, */
 40: /*     Department of Computer Science, University of Tennessee */
 41: /*     see http://dx.doi.org/10.1137/S1064827501399432 */
 42: /* *************************************************** */

 44: /*  Purpose */
 45: /*  ======= */

 47: /*  CUTLR computes the optimal cut in a sequence of BLKCT neighboring */
 48: /*  blocks whose sizes are given by the array BSIZES. */
 49: /*  The sum of all block sizes in the sequence considered is given by N. */
 50: /*  The cut is optimal in the sense that the difference of the sizes of */
 51: /*  the resulting two halves is minimum over all cuts with minimum ranks */
 52: /*  between blocks of the sequence considered. */

 54: /*  Arguments */
 55: /*  ========= */

 57: /*  START  (input) INTEGER */
 58: /*         In the original array KSIZES of the calling routine DIBTDC, */
 59: /*         the position where the sequence considered in this routine starts. */
 60: /*         START >= 1. */

 62: /*  N      (input) INTEGER */
 63: /*         The sum of all the block sizes of the sequence to be cut = */
 64: /*         = sum_{i=1}^{BLKCT} BSIZES( I ). */
 65: /*         N >= 3. */

 67: /*  BLKCT  (input) INTEGER */
 68: /*         The number of blocks in the sequence to be cut. */
 69: /*         BLKCT >= 3. */

 71: /*  BSIZES (input) INTEGER array, dimension (BLKCT) */
 72: /*         The dimensions of the (quadratic) blocks of the sequence to be */
 73: /*         cut. sum_{i=1}^{BLKCT} BSIZES( I ) = N. */

 75: /*  RANKS  (input) INTEGER array, dimension (BLKCT-1) */
 76: /*         The ranks determining the approximations of the off-diagonal */
 77: /*         blocks in the sequence considered. */

 79: /*  CUT    (output) INTEGER */
 80: /*         After the optimum cut has been determined, the position (in the */
 81: /*         overall problem as worked on in DIBTDC !) of the last block in */
 82: /*         the first half of the sequence to be cut. */
 83: /*         START <= CUT <= START+BLKCT-2. */

 85: /*  LSUM   (output) INTEGER */
 86: /*         After the optimum cut has been determined, the sum of the */
 87: /*         block sizes in the first half of the sequence to be cut. */
 88: /*         LSUM < N. */

 90: /*  LBLKS  (output) INTEGER */
 91: /*         After the optimum cut has been determined, the number of the */
 92: /*         blocks in the first half of the sequence to be cut. */
 93: /*         1 <= LBLKS < BLKCT. */

 95: /*  INFO   (output) INTEGER */
 96: /*          = 0:  successful exit. */
 97: /*          < 0:  illegal arguments. */
 98: /*                if INFO = -i, the i-th (input) argument had an illegal */
 99: /*                value. */
100: /*          > 0:  illegal results. */
101: /*                if INFO = i, the i-th (output) argument had an illegal */
102: /*                value. */

104: /*  Further Details */
105: /*  =============== */

107: /*  Based on code written by */
108: /*     Wilfried Gansterer and Bob Ward, */
109: /*     Department of Computer Science, University of Tennessee */

111: /*  ===================================================================== */

113:   PetscBLASInt i, ksk, kchk, ksum, nhalf, deviat, mindev, minrnk, tmpsum;

116:   *info = 0;
117:   *lblks = 1;
118:   *lsum = 1;
119:   *cut = start;

121:   if (start < 1) {
122:     *info = -1;
123:   } else if (n < 3) {
124:     *info = -2;
125:   } else if (blkct < 3) {
126:     *info = -3;
127:   }
128:   if (*info == 0) {
129:     ksum = 0;
130:     kchk = 0;
131:     for (i = 0; i < blkct; ++i) {
132:       ksk = bsizes[i];
133:       ksum += ksk;
134:       if (ksk < 1) kchk = 1;
135:     }
136:     if (ksum != n || kchk == 1) *info = -4;
137:   }
138:   if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in CUTLR",-(*info));

140:   /* determine smallest rank in the range considered */

142:   minrnk = n;
143:   for (i = 0; i < blkct-1; ++i) {
144:     if (ranks[i] < minrnk) minrnk = ranks[i];
145:   }

147:   /* determine best cut among those with smallest rank */

149:   nhalf = n / 2;
150:   tmpsum = 0;
151:   mindev = n;
152:   for (i = 0; i < blkct; ++i) {
153:     tmpsum += bsizes[i];
154:     if (ranks[i] == minrnk) {

156:       /* determine deviation from "optimal" cut NHALF */

158:       deviat = tmpsum - nhalf;
159:       if (deviat<0) deviat = -deviat;

161:       /* compare to best deviation so far */

163:       if (deviat < mindev) {
164:         mindev = deviat;
165:         *cut = start + i;
166:         *lblks = i + 1;
167:         *lsum = tmpsum;
168:       }
169:     }
170:   }

172:   if (*cut < start || *cut >= start + blkct - 1) {
173:     *info = 6;
174:   } else if (*lsum < 1 || *lsum >= n) {
175:     *info = 7;
176:   } else if (*lblks < 1 || *lblks >= blkct) {
177:     *info = 8;
178:   }
179:   return(0);
180: }


183: PetscErrorCode BDC_dibtdc_(const char *jobz,PetscBLASInt n,PetscBLASInt nblks, 
184:         PetscBLASInt *ksizes,PetscReal *d,PetscBLASInt l1d,PetscBLASInt l2d, 
185:         PetscReal *e,PetscBLASInt *rank,PetscBLASInt l1e,PetscBLASInt l2e,
186:         PetscReal tol,PetscReal *ev,PetscReal *z,PetscBLASInt ldz,PetscReal *work, 
187:         PetscBLASInt lwork,PetscBLASInt *iwork,PetscBLASInt liwork,
188:         PetscBLASInt *info,PetscBLASInt jobz_len)
189: {
190: /*  -- Routine written in LAPACK Version 3.0 style -- */
191: /* *************************************************** */
192: /*     Written by */
193: /*     Michael Moldaschl and Wilfried Gansterer */
194: /*     University of Vienna */
195: /*     last modification: March 16, 2014 */

197: /*     Small adaptations of original code written by */
198: /*     Wilfried Gansterer and Bob Ward, */
199: /*     Department of Computer Science, University of Tennessee */
200: /*     see http://dx.doi.org/10.1137/S1064827501399432 */
201: /* *************************************************** */

203: /*  Purpose */
204: /*  ======= */

206: /*  DIBTDC computes all eigenvalues and corresponding eigenvectors of a */
207: /*  symmetric irreducible block tridiagonal matrix with rank RANK matrices */
208: /*  as the subdiagonal blocks using a block divide and conquer method. */

210: /*  Arguments */
211: /*  ========= */

213: /*  JOBZ    (input) CHARACTER*1 */
214: /*          = 'N':  Compute eigenvalues only (not implemented); */
215: /*          = 'D':  Compute eigenvalues and eigenvectors. */
216: /*                  Eigenvectors are accumulated in the */
217: /*                  divide-and-conquer process. */

219: /*  N      (input) INTEGER */
220: /*         The dimension of the symmetric irreducible block tridiagonal */
221: /*         matrix.  N >= 2. */

223: /*  NBLKS  (input) INTEGER, 2 <= NBLKS <= N */
224: /*         The number of diagonal blocks in the matrix. */

226: /*  KSIZES (input) INTEGER array, dimension (NBLKS) */
227: /*         The dimension of the square diagonal blocks from top left */
228: /*         to bottom right.  KSIZES(I) >= 1 for all I, and the sum of */
229: /*         KSIZES(I) for I = 1 to NBLKS has to be equal to N. */

231: /*  D      (input) DOUBLE PRECISION array, dimension (L1D,L2D,NBLKS) */
232: /*         The lower triangular elements of the symmetric diagonal */
233: /*         blocks of the block tridiagonal matrix.  Elements of the top */
234: /*         left diagonal block, which is of dimension KSIZES(1), are */
235: /*         contained in D(*,*,1); the elements of the next diagonal */
236: /*         block, which is of dimension KSIZES(2), are contained in */
237: /*         D(*,*,2); etc. */

239: /*  L1D    (input) INTEGER */
240: /*         The leading dimension of the array D.  L1D >= max(3,KMAX), */
241: /*         where KMAX is the dimension of the largest diagonal block. */

243: /*  L2D    (input) INTEGER */
244: /*         The second dimension of the array D.  L2D >= max(3,KMAX), */
245: /*         where KMAX is as stated in L1D above. */

247: /*  E      (input) DOUBLE PRECISION array, dimension (L1E,L2E,NBLKS-1) */
248: /*         Contains the elements of the scalars (singular values) and */
249: /*         vectors (singular vectors) defining the rank RANK subdiagonal */
250: /*         blocks of the matrix. */
251: /*         E(1:RANK(K),RANK(K)+1,K) holds the RANK(K) scalars, */
252: /*         E(:,1:RANK(K),K) holds the RANK(K) column vectors, and */
253: /*         E(:,RANK(K)+2:2*RANK(K)+1,K) holds the row vectors for the K-th */
254: /*         subdiagonal block. */

256: /*  RANK   (input) INTEGER array, dimension (NBLKS-1). */
257: /*         The ranks of all the subdiagonal blocks contained in the array E. */
258: /*         RANK( K ) <= MIN( KSIZES( K ), KSIZES( K+1 ) ) */

260: /*  L1E    (input) INTEGER */
261: /*         The leading dimension of the array E.  L1E >= max(3,2*KMAX+1), */
262: /*         where KMAX is as stated in L1D above. */

264: /*  L2E    (input) INTEGER */
265: /*         The second dimension of the array E.  L2E >= max(3,2*KMAX+1), */
266: /*         where KMAX is as stated in L1D above. */

268: /*  TOL    (input) DOUBLE PRECISION, TOL <= 1.0D-1 */
269: /*         User specified deflation tolerance for the routine DMERG2. */
270: /*         If ( 1.0D-1 >= TOL >= 20*EPS ) then TOL is used as */
271: /*         the deflation tolerance in DSRTDF. */
272: /*         If ( TOL < 20*EPS ) then the standard deflation tolerance from */
273: /*         LAPACK is used as the deflation tolerance in DSRTDF. */

275: /*  EV     (output) DOUBLE PRECISION array, dimension (N) */
276: /*         If INFO = 0, then EV contains the eigenvalues of the */
277: /*         symmetric block tridiagonal matrix in ascending order. */

279: /*  Z      (input/output) DOUBLE PRECISION array, dimension (LDZ, N) */
280: /*         On entry, Z will be the identity matrix. */
281: /*         On exit, Z contains the eigenvectors of the block tridiagonal */
282: /*         matrix. */

284: /*  LDZ    (input) INTEGER */
285: /*         The leading dimension of the array Z.  LDZ >= max(1,N). */

287: /*  WORK   (workspace) DOUBLE PRECISION array, dimension (LWORK) */

289: /*  LWORK   (input) INTEGER */
290: /*          The dimension of the array WORK. */
291: /*          In order to guarantee correct results in all cases, */
292: /*          LWORK must be at least ( 2*N**2 + 3*N ). In many cases, */
293: /*          less workspace is required. The absolute minimum required is */
294: /*          ( N**2 + 3*N ). */
295: /*          If the workspace provided is not sufficient, the routine will */
296: /*          return a corresponding error code and report how much workspace */
297: /*          was missing (see INFO). */

299: /*  IWORK  (workspace) INTEGER array, dimension (LIWORK) */

301: /*  LIWORK  (input) INTEGER */
302: /*          The dimension of the array IWORK. */
303: /*          LIWORK must be at least ( 5*N + 3 + 4*NBLKS - 4 ): */
304: /*                 5*KMAX+3 for DSYEVD, 5*N for ????, */
305: /*                 4*NBLKS-4 for the preprocessing (merging order) */
306: /*          Summarizing, the minimum integer workspace needed is */
307: /*          MAX( 5*N, 5*KMAX + 3 ) + 4*NBLKS - 4 */

309: /*  INFO   (output) INTEGER */
310: /*          = 0:  successful exit. */
311: /*          < 0, > -99: illegal arguments. */
312: /*                if INFO = -i, the i-th argument had an illegal value. */
313: /*          = -99: error in the preprocessing (call of CUTLR). */
314: /*          < -200: not enough workspace. Space for ABS(INFO + 200) */
315: /*                numbers is required in addition to the workspace provided, */
316: /*                otherwise some eigenvectors will be incorrect. */
317: /*          > 0:  The algorithm failed to compute an eigenvalue while */
318: /*                working on the submatrix lying in rows and columns */
319: /*                INFO/(N+1) through mod(INFO,N+1). */

321: /*  Further Details */
322: /*  =============== */

324: /*  Based on code written by */
325: /*     Wilfried Gansterer and Bob Ward, */
326: /*     Department of Computer Science, University of Tennessee */

328: /*  This routine is comparable to Dlaed0.f from LAPACK. */

330: /*  ===================================================================== */

332: #if defined(SLEPC_MISSING_LAPACK_LACPY) || defined(PETSC_MISSING_LAPACK_SYEV)
334:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LACPY/SYEV - Lapack routine is unavailable");
335: #else
336:   PetscBLASInt   i, j, k, np, rp1, ksk, one=1;
337:   PetscBLASInt   cut, mat1, kchk, kbrk, blks, kmax, icut, size, ksum, lsum;
338:   PetscBLASInt   lblks, rblks, isize, lwmin, ilsum;
339:   PetscBLASInt   start, vstrt, istck1, istck2, istck3, merged;
340:   PetscBLASInt   liwmin, matsiz, startp, istrtp;
341:   PetscReal      rho, done=1.0, dmone=-1.0;

345:   *info = 0;

347:   if (*(unsigned char *)jobz != 'N' && *(unsigned char *)jobz != 'D') {
348:     *info = -1;
349:   } else if (n < 2) {
350:     *info = -2;
351:   } else if (nblks < 2 || nblks > n) {
352:     *info = -3;
353:   }
354:   if (*info == 0) {
355:     ksum = 0;
356:     kmax = 0;
357:     kchk = 0;
358:     for (k = 0; k < nblks; ++k) {
359:       ksk = ksizes[k];
360:       ksum += ksk;
361:       if (ksk > kmax) kmax = ksk;
362:       if (ksk < 1) kchk = 1;
363:     }
364:     lwmin = n*n + n * 3;
365:     liwmin = PetscMax(n * 5,kmax * 5 + 3) + 4*nblks - 4;
366:     if (ksum != n || kchk == 1) {
367:       *info = -4;
368:     } else if (l1d < PetscMax(3,kmax)) {
369:       *info = -6;
370:     } else if (l2d < PetscMax(3,kmax)) {
371:       *info = -7;
372:     } else if (l1e < PetscMax(3,2*kmax + 1)) {
373:       *info = -10;
374:     } else if (l2e < PetscMax(3,2*kmax + 1)) {
375:       *info = -11;
376:     } else if (tol > .1) {
377:       *info = -12;
378:     } else if (ldz < PetscMax(1,n)) {
379:       *info = -15;
380:     } else if (lwork < lwmin) {
381:       *info = -17;
382:     } else if (liwork < liwmin) {
383:       *info = -19;
384:     }
385:   }
386:   if (*info == 0) {
387:     for (k = 0; k < nblks-1; ++k) {
388:       if (rank[k] > PetscMin(ksizes[k],ksizes[k+1]) || rank[k] < 1) *info = -9;
389:     }
390:   }

392:   if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DIBTDC",-(*info));

394: /* **************************************************************************** */

396:   /* ...Preprocessing..................................................... */
397:   /*    Determine the optimal order for merging the subblocks and how much */
398:   /*    workspace will be needed for the merging (determined by the last */
399:   /*    merge). Cutpoints for the merging operations are determined and stored */
400:   /*    in reverse chronological order (starting with the final merging */
401:   /*    operation). */
402:   
403:   /*    integer workspace requirements for the preprocessing: */
404:   /*         4*(NBLKS-1) for merging history */
405:   /*         at most 3*(NBLKS-1) for stack */

407:   start = 1;
408:   size = n;
409:   blks = nblks;
410:   merged = 0;
411:   k = 0;

413:   /* integer workspace used for the stack is not needed any more after the */
414:   /* preprocessing and therefore can use part of the 5*N */
415:   /* integer workspace needed later on in the code */

417:   istck1 = 0;
418:   istck2 = istck1 + nblks;
419:   istck3 = istck2 + nblks;

421:   /* integer workspace used for storing the order of merges starts AFTER */
422:   /* the integer workspace 5*N+3 which is needed later on in the code */
423:   /* (5*KMAX+3 for DSYEVD, 4*N in DMERG2) */

425:   istrtp = n * 5 + 4;
426:   icut = istrtp + nblks - 1;
427:   isize = icut + nblks - 1;
428:   ilsum = isize + nblks - 1;

430: L200:

432:   if (nblks >= 3) {

434:     /* Determine the cut point. Note that in the routine CUTLR it is */
435:     /* chosen such that it yields the best balanced merging operation */
436:     /* among all the rank modifications with minimum rank. */

438:     cutlr_(start, size, blks, &ksizes[start-1], &rank[start-1], &cut, 
439:                   &lsum, &lblks, info);
440:     if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in cutlr, info = %d",*info);

442:   } else {
443:     cut = 1;
444:     lsum = ksizes[0];
445:     lblks = 1;
446:   }

448:   ++merged;
449:   startp = 0;
450:   for (i = 0; i < start-1; ++i) startp += ksizes[i];
451:   iwork[istrtp + (nblks - 1) - merged-1] = startp + 1;
452:   iwork[icut + (nblks - 1) - merged-1] = cut;
453:   iwork[isize + (nblks - 1) - merged-1] = size;
454:   iwork[ilsum + (nblks - 1) - merged-1] = lsum;

456:   if (lblks == 2) {

458:     /* one merge in left branch, left branch done */
459:     ++merged;
460:     iwork[istrtp + (nblks - 1) - merged-1] = startp + 1;
461:     iwork[icut + (nblks - 1) - merged-1] = start;
462:     iwork[isize + (nblks - 1) - merged-1] = lsum;
463:     iwork[ilsum + (nblks - 1) - merged-1] = ksizes[start-1];
464:   }

466:   if (lblks == 1 || lblks == 2) {

468:     /* left branch done, continue on the right side */
469:     start += lblks;
470:     size -= lsum;
471:     blks -= lblks;

473:     if (blks <= 0) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in preprocessing, blks = %d",blks);

475:     if (blks == 2) {

477:       /* one merge in right branch, right branch done */
478:       ++merged;
479:       startp += lsum;
480:       iwork[istrtp + (nblks - 1) - merged-1] = startp + 1;
481:       iwork[icut + (nblks - 1) - merged-1] = start;
482:       iwork[isize + (nblks - 1) - merged-1] = size;
483:       iwork[ilsum + (nblks - 1) - merged-1] = ksizes[start-1];
484:     }

486:     if (blks == 1 || blks == 2) {

488:       /* get the next subproblem from the stack or finished */

490:       if (k >= 1) {

492:         /* something left on the stack */
493:         start = iwork[istck1 + k-1];
494:         size = iwork[istck2 + k-1];
495:         blks = iwork[istck3 + k-1];
496:         --k;
497:         goto L200;
498:       } else {

500:         /* nothing left on the stack */
501:         if (merged != nblks-1) SETERRQ(PETSC_COMM_SELF,1,"ERROR in preprocessing - not enough merges performed");

503:         /* exit preprocessing */

505:       }
506:     } else {

508:       /* BLKS.GE.3, and therefore analyze the right side */

510:       goto L200;
511:     }
512:   } else {

514:     /* LBLKS.GE.3, and therefore check the right side and */
515:     /* put it on the stack if required */

517:     rblks = blks - lblks;
518:     if (rblks >= 3) {
519:       ++k;
520:       iwork[istck1 + k-1] = cut + 1;
521:       iwork[istck2 + k-1] = size - lsum;
522:       iwork[istck3 + k-1] = rblks;
523:     } else if (rblks == 2) {

525:       /* one merge in right branch, right branch done */
526:       /* (note that nothing needs to be done if RBLKS.EQ.1 !) */

528:       ++merged;
529:       startp += lsum;
530:       iwork[istrtp + (nblks - 1) - merged-1] = startp + 1;
531:       iwork[icut + (nblks - 1) - merged-1] = start + lblks;
532:       iwork[isize + (nblks - 1) - merged-1] = size - lsum;
533:       iwork[ilsum + (nblks - 1) - merged-1] = ksizes[start + lblks-1];
534:     }
535:     if (rblks <= 0) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: ERROR in preprocessing - rblks = %d",rblks);

537:     /* continue on the left side */

539:     size = lsum;
540:     blks = lblks;
541:     goto L200;
542:   }

544:   /*  SIZE = IWORK( ISIZE+NBLKS-2 ) */
545:   /*  MAT1 = IWORK( ILSUM+NBLKS-2 ) */
546:   
547:   /* Note: after the dimensions SIZE and MAT1 of the last merging */
548:   /* operation have been determined, an upper bound for the workspace */
549:   /* requirements which is independent of how much deflation occurs in */
550:   /* the last merging operation could be determined as follows */
551:   /* (based on (3.15) and (3.19) from UT-CS-00-447): */
552:   
553:   /*  IF( MAT1.LE.N/2 ) THEN */
554:   /*     WSPREQ = 3*N + 3/2*( SIZE-MAT1 )**2 + N*N/2 + MAT1*MAT1 */
555:   /*  ELSE */
556:   /*     WSPREQ = 3*N + 3/2*MAT1*MAT1 + N*N/2 + ( SIZE-MAT1 )**2 */
557:   /*  END IF */
558:   
559:   /*  IF( LWORK-WSPREQ.LT.0 )THEN */
560:   /*          not enough work space provided */
561:   /*     INFO = -200 - ( WSPREQ-LWORK ) */
562:   /*     RETURN */
563:   /*  END IF */
564:   /*  However, this is not really useful, since the actual check whether */
565:   /*  enough workspace is provided happens in DMERG2.f ! */

567: /* ************************************************************************* */

569:   /* ...Solve subproblems................................... */
570:   
571:   /* Divide the matrix into NBLKS submatrices using rank-r */
572:   /* modifications (cuts) and solve for their eigenvalues and */
573:   /* eigenvectors. Initialize index array to sort eigenvalues. */
574:   
575:   /* first block: ...................................... */
576:   
577:   /*    correction for block 1: D1 - V1 \Sigma1 V1^T */

579:   ksk = ksizes[0];
580:   rp1 = rank[0];

582:   /* initialize the proper part of Z with the diagonal block D1 */
583:   /* (the correction will be made in Z and then the call of DSYEVD will */
584:   /*  overwrite it with the eigenvectors) */

586:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, d, &l1d, z, &ldz));

588:   /* copy D1 into WORK (in order to be able to restore it afterwards) */

590:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, d, &l1d, work, &ksk));

592:   /* copy V1 into the first RANK(1) columns of D1 and then */
593:   /* multiply with \Sigma1 */

595:   for (i = 0; i < rank[0]; ++i) {
596:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(rp1 + i+1)*l1e], &one, &d[i*l1d], &one));
597:     PetscStackCallBLAS("BLASscal",BLASscal_(&ksk, &e[i + rp1*l1e], &d[i*l1d], &one));
598:   }

600:   /* multiply the first RANK( 1 ) columns of D1 with V1^T and */
601:   /* subtract the result from the proper part of Z (previously */
602:   /* initialized with D1) */

604:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, rank, &dmone,
605:           d, &l1d, &e[(rank[0]+1)*l1e], &l1e, &done, z, &ldz));

607:   /* restore the original D1 from WORK */

609:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, work, &ksk, d, &l1d));

611:   /* eigenanalysis of block 1 (using DSYEVD) */

613:   PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V", "L", &ksk, z, &ldz, ev, work, &lwork, info));
614:   if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in DSYEVD for block 1, info = %d",*info);

616:   /* EV( 1: ) contains the eigenvalues in ascending order */
617:   /* (they are returned this way by DSYEVD) */

619:   for (i = 0; i < ksk; ++i) iwork[i] = i+1;

621:     /* intermediate blocks: .............................. */

623:     np = ksk;

625:     /* remaining number of blocks */

627:     if (nblks > 2) {
628:       for (k = 1; k < nblks-1; ++k) {

630:       /* correction for block K: */
631:       /* Dk - U(k-1) \Sigma(k-1) U(k-1)^T - Vk \Sigmak Vk^T */

633:       ksk = ksizes[k];
634:       rp1 = rank[k];

636:       /* initialize the proper part of Z with the diagonal block Dk */
637:       /* (the correction will be made in Z and then the call of DSYEVD will */
638:       /*  overwrite it with the eigenvectors) */

640:       PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[k*l1d*l2d], &l1d, &z[np+np*ldz], &ldz));

642:       /* copy Dk into WORK (in order to be able to restore it afterwards) */

644:       PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[k*l1d*l2d], &l1d, work, &ksk));

646:       /* copy U(K-1) into the first RANK(K-1) columns of Dk and then */
647:       /* multiply with \Sigma(K-1) */

649:       for (i = 0; i < rank[k-1]; ++i) {
650:         PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(i+(k-1)*l2e)*l1e], &one, &d[(i+k*l2d)*l1d], &one));
651:         PetscStackCallBLAS("BLASscal",BLASscal_(&ksk, &e[i+(rank[k-1]+(k-1)*l2e)*l1e], &d[(i+k*l2d)*l1d], &one));
652:       }

654:       /* multiply the first RANK(K-1) columns of Dk with U(k-1)^T and */
655:       /* subtract the result from the proper part of Z (previously */
656:       /* initialized with Dk) */

658:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, &rank[k-1],
659:                     &dmone, &d[k*l1d*l2d],
660:                     &l1d, &e[(k-1)*l1e*l2e], &l1e, &done, &z[np+np*ldz], &ldz));

662:       /* copy Vk into the first RANK(K) columns of Dk and then */
663:       /* multiply with \Sigmak */

665:       for (i = 0; i < rank[k]; ++i) {
666:         PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(rp1+i+1 + k*l2e)*l1e], &one, &d[(i + k*l2d)*l1d], &one));
667:         PetscStackCallBLAS("BLASscal",BLASscal_(&ksk, &e[i + (rp1 + k*l2e)*l1e], &d[(i + k*l2d)*l1d], &one));
668:       }

670:       /* multiply the first RANK(K) columns of Dk with Vk^T and */
671:       /* subtract the result from the proper part of Z (previously */
672:       /* updated with [- U(k-1) \Sigma(k-1) U(k-1)^T] ) */

674:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, &rank[k],
675:                     &dmone, &d[k*l1d*l2d], &l1d,
676:                     &e[(rank[k]+1 + k*l2e)*l1e], &l1e, &done, &z[np+np*ldz], &ldz));

678:       /* restore the original Dk from WORK */

680:       PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, work, &ksk, &d[k*l1d*l2d], &l1d));

682:       /* eigenanalysis of block K (using dsyevd) */

684:       PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V", "L", &ksk, &z[np+np*ldz],
685:                      &ldz, &ev[np], work, &lwork, info));
686:       if (*info) SETERRQ2(PETSC_COMM_SELF,1,"dibtdc: Error in DSYEVD for block %d, info = %d",k,*info);

688:       /* EV( NPP1: ) contains the eigenvalues in ascending order */
689:       /* (they are returned this way by DSYEVD) */

691:       for (i = 0; i < ksk; ++i) iwork[np + i] = i+1;

693:       /* update NP */
694:       np += ksk;
695:     }
696:   }

698:   /* last block: ....................................... */
699:   
700:   /*    correction for block NBLKS: */
701:   /*    D(nblks) - U(nblks-1) \Sigma(nblks-1) U(nblks-1)^T */

703:   ksk = ksizes[nblks-1];

705:   /* initialize the proper part of Z with the diagonal block D(nblks) */
706:   /* (the correction will be made in Z and then the call of DSYEVD will */
707:   /* overwrite it with the eigenvectors) */

709:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[(nblks-1)*l1d*l2d], &l1d, &z[np+np*ldz], &ldz));

711:   /* copy D(nblks) into WORK (in order to be able to restore it afterwards) */

713:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[(nblks-1)*l1d*l2d], &l1d, work, &ksk));

715:   /* copy U(nblks-1) into the first RANK(nblks-1) columns of D(nblks) and then */
716:   /* multiply with \Sigma(nblks-1) */

718:   for (i = 0; i < rank[nblks-2]; ++i) {
719:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(i + (nblks-2)*l2e)*l1e],
720:               &one, &d[(i + (nblks-1)*l2d)*l1d], &one));
721:     PetscStackCallBLAS("BLASscal",BLASscal_(&ksk,
722:               &e[i + (rank[nblks-2] + (nblks-2)*l2e)*l1e],
723:               &d[(i + (nblks-1)*l2d)*l1d], &one));
724:   }

726:   /* multiply the first RANK(nblks-1) columns of D(nblks) with U(nblks-1)^T */
727:   /* and subtract the result from the proper part of Z (previously */
728:   /* initialized with D(nblks) ) */

730:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, &rank[nblks - 2],
731:           &dmone, &d[(nblks-1)*l1d*l2d], &l1d,
732:           &e[(nblks-2)*l1e*l2e], &l1e, &done, &z[np+np*ldz], &ldz));

734:   /* restore the original D(nblks) from WORK */

736:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, work, &ksk, &d[(nblks-1)*l1d*l2d], &l1d));

738:   /* eigenanalysis of block NBLKS (using dsyevd) */

740:   PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V", "L", &ksk, &z[np+np*ldz], &ldz, &ev[np], work, &lwork, info));
741:   if (*info) SETERRQ2(PETSC_COMM_SELF,1,"dibtdc: Error in DSYEVD for block %d, info = %d",nblks,*info);

743:   /* EV( NPP1: ) contains the eigenvalues in ascending order */
744:   /* (they are returned this way by DSYEVD) */

746:   for (i = 0; i < ksk; ++i) iwork[np + i] = i+1;

748:   /* note that from here on the entire workspace is available again */


751:   /* Perform all the merging operations. */

753:   vstrt = 0;
754:   for (i = 0; i < nblks-1; ++i) {

756:     /* MATSIZ = total size of the current rank RANK modification problem */

758:     matsiz = iwork[isize + i - 1];
759:     np = iwork[istrtp + i - 1];
760:     kbrk = iwork[icut + i - 1];
761:     mat1 = iwork[ilsum + i - 1];
762:     vstrt += np;

764:     for (j = 0; j < rank[kbrk-1]; ++j) {

766:       /* NOTE: The parameter RHO in DMERG2 is modified in DSRTDF */
767:       /*       (multiplied by 2) ! In order not to change the */
768:       /*       singular value stored in E( :, RANK( KBRK )+1, KBRK ), */
769:       /*       we do not pass on this variable as an argument to DMERG2, */
770:       /*       but we assign a separate variable RHO here which is passed */
771:       /*       on to DMERG2. */
772:       /*       Alternative solution in F90: */
773:       /*       pass E( :,RANK( KBRK )+1,KBRK ) to an INTENT( IN ) parameter */
774:       /*       in DMERG2. */

776:       rho = e[j + (rank[kbrk-1] + (kbrk-1)*l2e)*l1e];

778:       /* eigenvectors are accumulated ( JOBZ.EQ.'D' ) */

780:       BDC_dmerg2_(jobz, j+1, matsiz, &ev[np-1], &z[np-1+(np-1)*ldz], 
781:                     ldz, &iwork[np-1], &rho, &e[(j + (kbrk-1)*l2e)*l1e],
782:                     ksizes[kbrk], &e[(rank[kbrk-1]+j+1 + (kbrk-1)*l2e)*l1e],
783:                     ksizes[kbrk-1], mat1, work, lwork, &iwork[n], tol, info, 1);
784:                     
785:       if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in dmerg2, info = %d",*info);
786:     }

788:     /* at this point all RANK( KBRK ) rank-one modifications corresponding */
789:     /* to the current off-diagonal block are finished. */
790:     /* Move on to the next off-diagonal block. */

792:   }

794:   /* Re-merge the eigenvalues/vectors which were deflated at the final */
795:   /* merging step by sorting all eigenvalues and eigenvectors according */
796:   /* to the permutation stored in IWORK. */
797:   
798:   /* copy eigenvalues and eigenvectors in ordered form into WORK */
799:   /* (eigenvalues into WORK( 1:N ), eigenvectors into WORK( N+1:N+1+N^2 ) ) */

801:   for (i = 0; i < n; ++i) {
802:     j = iwork[i];
803:     work[i] = ev[j-1];
804:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, &z[(j-1)*ldz], &one, &work[n*(i+1)], &one));
805:   }

807:   /* copy ordered eigenvalues back from WORK( 1:N ) into EV */

809:   PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, work, &one, ev, &one));

811:   /* copy ordered eigenvectors back from WORK( N+1:N+1+N^2 ) into Z */

813:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n, &n, &work[n], &n, z, &ldz));
814:   return(0);
815: #endif
816: }

slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/makefile.html0000644000175000017500000000505113107004621022727 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

#requiresscalar    real

CFLAGS   =
FFLAGS   =
SOURCEC  = dibtdc.c dlaed3m.c dmerg2.c dsbtdc.c dsrtdf.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = DS
LOCDIR   = src/sys/classes/ds/impls/hep/bdc/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dlaed3m.c.html0000644000175000017500000006636313107004621022721 0ustar jromanjroman
Actual source code: dlaed3m.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BDC - Block-divide and conquer (see description in README file).

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>
 25: #include <slepcblaslapack.h>

 27: PetscErrorCode BDC_dlaed3m_(const char *jobz,const char *defl,PetscBLASInt k,PetscBLASInt n,
 28:         PetscBLASInt n1,PetscReal *d,PetscReal *q,PetscBLASInt ldq,
 29:         PetscReal rho,PetscReal *dlamda,PetscReal *q2,PetscBLASInt *indx, 
 30:         PetscBLASInt *ctot,PetscReal *w,PetscReal *s,PetscBLASInt *info,
 31:         PetscBLASInt jobz_len,PetscBLASInt defl_len)
 32: {
 33: /*  -- Routine written in LAPACK version 3.0 style -- */
 34: /* *************************************************** */
 35: /*     Written by */
 36: /*     Michael Moldaschl and Wilfried Gansterer */
 37: /*     University of Vienna */
 38: /*     last modification: March 16, 2014 */

 40: /*     Small adaptations of original code written by */
 41: /*     Wilfried Gansterer and Bob Ward, */
 42: /*     Department of Computer Science, University of Tennessee */
 43: /*     see http://dx.doi.org/10.1137/S1064827501399432 */
 44: /* *************************************************** */

 46: /*  Purpose */
 47: /*  ======= */

 49: /*  DLAED3M finds the roots of the secular equation, as defined by the */
 50: /*  values in D, W, and RHO, between 1 and K.  It makes the */
 51: /*  appropriate calls to DLAED4 and then updates the eigenvectors by */
 52: /*  multiplying the matrix of eigenvectors of the pair of eigensystems */
 53: /*  being combined by the matrix of eigenvectors of the K-by-K system */
 54: /*  which is solved here. */

 56: /*  This code makes very mild assumptions about floating point */
 57: /*  arithmetic. It will work on machines with a guard digit in */
 58: /*  add/subtract, or on those binary machines without guard digits */
 59: /*  which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */
 60: /*  It could conceivably fail on hexadecimal or decimal machines */
 61: /*  without guard digits, but we know of none. */

 63: /*  Arguments */
 64: /*  ========= */

 66: /*  JOBZ    (input) CHARACTER*1 */
 67: /*          = 'N':  Do not accumulate eigenvectors (not implemented); */
 68: /*          = 'D':  Do accumulate eigenvectors in the divide-and-conquer */
 69: /*                  process. */

 71: /*  DEFL    (input) CHARACTER*1 */
 72: /*          = '0':  No deflation happened in DSRTDF */
 73: /*          = '1':  Some deflation happened in DSRTDF (and therefore some */
 74: /*                  Givens rotations need to be applied to the computed */
 75: /*                  eigenvector matrix Q) */

 77: /*  K       (input) INTEGER */
 78: /*          The number of terms in the rational function to be solved by */
 79: /*          DLAED4. 0 <= K <= N. */

 81: /*  N       (input) INTEGER */
 82: /*          The number of rows and columns in the Q matrix. */
 83: /*          N >= K (deflation may result in N>K). */

 85: /*  N1      (input) INTEGER */
 86: /*          The location of the last eigenvalue in the leading submatrix. */
 87: /*          min(1,N) <= N1 <= max(1,N-1). */

 89: /*  D       (output) DOUBLE PRECISION array, dimension (N) */
 90: /*          D(I) contains the updated eigenvalues for */
 91: /*          1 <= I <= K. */

 93: /*  Q       (output) DOUBLE PRECISION array, dimension (LDQ,N) */
 94: /*          Initially the first K columns are used as workspace. */
 95: /*          On output the columns 1 to K contain */
 96: /*          the updated eigenvectors. */

 98: /*  LDQ     (input) INTEGER */
 99: /*          The leading dimension of the array Q.  LDQ >= max(1,N). */

101: /*  RHO     (input) DOUBLE PRECISION */
102: /*          The value of the parameter in the rank one update equation. */
103: /*          RHO >= 0 required. */

105: /*  DLAMDA  (input/output) DOUBLE PRECISION array, dimension (K) */
106: /*          The first K elements of this array contain the old roots */
107: /*          of the deflated updating problem.  These are the poles */
108: /*          of the secular equation. May be changed on output by */
109: /*          having lowest order bit set to zero on Cray X-MP, Cray Y-MP, */
110: /*          Cray-2, or Cray C-90, as described above. */

112: /*  Q2      (input) DOUBLE PRECISION array, dimension (LDQ2, N) */
113: /*          The first K columns of this matrix contain the non-deflated */
114: /*          eigenvectors for the split problem. */

116: /*  INDX    (input) INTEGER array, dimension (N) */
117: /*          The permutation used to arrange the columns of the deflated */
118: /*          Q matrix into three groups (see DLAED2). */
119: /*          The rows of the eigenvectors found by DLAED4 must be likewise */
120: /*          permuted before the matrix multiply can take place. */

122: /*  CTOT    (input) INTEGER array, dimension (4) */
123: /*          A count of the total number of the various types of columns */
124: /*          in Q, as described in INDX.  The fourth column type is any */
125: /*          column which has been deflated. */

127: /*  W       (input/output) DOUBLE PRECISION array, dimension (K) */
128: /*          The first K elements of this array contain the components */
129: /*          of the deflation-adjusted updating vector. Destroyed on */
130: /*          output. */

132: /*  S       (workspace) DOUBLE PRECISION array, dimension */
133: /*          ( MAX(CTOT(1)+CTOT(2),CTOT(2)+CTOT(3)) + 1 )*K */
134: /*          Will contain parts of the eigenvectors of the repaired matrix */
135: /*          which will be multiplied by the previously accumulated */
136: /*          eigenvectors to update the system. This array is a major */
137: /*          source of workspace requirements ! */

139: /*  INFO    (output) INTEGER */
140: /*          = 0:  successful exit. */
141: /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
142: /*          > 0:  if INFO = i, eigenpair i was not computed successfully */

144: /*  Further Details */
145: /*  =============== */

147: /*  Based on code written by */
148: /*     Wilfried Gansterer and Bob Ward, */
149: /*     Department of Computer Science, University of Tennessee */
150: /*  Based on the design of the LAPACK code DLAED3 with small modifications */
151: /*  (Note that in contrast to the original DLAED3, this routine */
152: /*  DOES NOT require that N1 <= N/2) */

154: /*  Based on contributions by */
155: /*     Jeff Rutter, Computer Science Division, University of California */
156: /*     at Berkeley, USA */
157: /*  Modified by Francoise Tisseur, University of Tennessee. */

159: /*  ===================================================================== */

161: #if defined(SLEPC_MISSING_LAPACK_LAED4) || defined(SLEPC_MISSING_LAPACK_LACPY) || defined(SLEPC_MISSING_LAPACK_LASET)
163:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAED4/LACPY/LASET - Lapack routine is unavailable");
164: #else
165:   PetscReal    temp, done = 1.0, dzero = 0.0;
166:   PetscBLASInt i, j, n2, n12, ii, n23, iq2, i1, one=1;

169:   *info = 0;

171:   if (k < 0) {
172:     *info = -3;
173:   } else if (n < k) {
174:     *info = -4;
175:   } else if (n1 < PetscMin(1,n) || n1 > PetscMax(1,n)) {
176:     *info = -5;
177:   } else if (ldq < PetscMax(1,n)) {
178:     *info = -8;
179:   } else if (rho < 0.) {
180:     *info = -9;
181:   }
182:   if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DLAED3M",-(*info));

184:   /* Quick return if possible */

186:   if (k == 0) return(0);

188:   /* Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */
189:   /* be computed with high relative accuracy (barring over/underflow). */
190:   /* This is a problem on machines without a guard digit in */
191:   /* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */
192:   /* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */
193:   /* which on any of these machines zeros out the bottommost */
194:   /* bit of DLAMDA(I) if it is 1; this makes the subsequent */
195:   /* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */
196:   /* occurs. On binary machines with a guard digit (almost all */
197:   /* machines) it does not change DLAMDA(I) at all. On hexadecimal */
198:   /* and decimal machines with a guard digit, it slightly */
199:   /* changes the bottommost bits of DLAMDA(I). It does not account */
200:   /* for hexadecimal or decimal machines without guard digits */
201:   /* (we know of none). We use a subroutine call to compute */
202:   /* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating */
203:   /* this code. */

205:   for (i = 0; i < k; ++i) {
206:     dlamda[i] = LAPACKlamc3_(&dlamda[i], &dlamda[i]) - dlamda[i];
207:   }

209:   for (j = 1; j <= k; ++j) {

211:     /* ....calling DLAED4 for eigenpair J.... */

213:     PetscStackCallBLAS("LAPACKlaed4",LAPACKlaed4_(&k, &j, dlamda, w, &q[(j-1)*ldq], &rho, &d[j-1], info));
214:     if (*info) SETERRQ3(PETSC_COMM_SELF,1,"Error in dlaed4, info = %d, failed when computing D(%d)=%g",*info,j,d[j-1]);

216:     if (j < k) {

218:       /* If the zero finder terminated properly, but the computed */
219:       /* eigenvalues are not ordered, issue an error statement */
220:       /* but continue computation. */

222:       if (dlamda[j-1] >= dlamda[j]) SETERRQ2(PETSC_COMM_SELF,1,"DLAMDA(%d) is greater or equal than DLAMDA(%d)", j, j+1);
223:       if (d[j-1] < dlamda[j-1] || d[j-1] > dlamda[j]) SETERRQ6(PETSC_COMM_SELF,1,"DLAMDA(%d) = %g D(%d) = %g DLAMDA(%d) = %g", j, dlamda[j-1], j, d[j-1], j+1, dlamda[j]);
224:     }
225:   }

227:   if (k == 1) goto L110;

229:   if (k == 2) {

231:     /* permute the components of Q(:,J) (the information returned by DLAED4 */
232:     /* necessary to construct the eigenvectors) according to the permutation */
233:     /* stored in INDX, resulting from deflation */

235:     for (j = 0; j < k; ++j) {
236:       w[0] = q[0+j*ldq];
237:       w[1] = q[1+j*ldq];
238:       ii = indx[0];
239:       q[0+j*ldq] = w[ii-1];
240:       ii = indx[1];
241:       q[1+j*ldq] = w[ii-1];
242:     }
243:     goto L110;
244:   }

246:   /* ....K.GE.3.... */
247:   /* Compute updated W (used for computing the eigenvectors corresponding */
248:   /* to the previously computed eigenvalues). */

250:   PetscStackCallBLAS("BLAScopy",BLAScopy_(&k, w, &one, s, &one));

252:   /* Initialize W(I) = Q(I,I) */

254:   i1 = ldq + 1;
255:   PetscStackCallBLAS("BLAScopy",BLAScopy_(&k, q, &i1, w, &one));
256:   for (j = 0; j < k; ++j) {
257:     for (i = 0; i < j; ++i) {
258:       w[i] *= q[i+j*ldq] / (dlamda[i] - dlamda[j]);
259:     }
260:     for (i = j + 1; i < k; ++i) {
261:       w[i] *= q[i+j*ldq] / (dlamda[i] - dlamda[j]);
262:     }
263:   }
264:   for (i = 0; i < k; ++i) {
265:     temp = PetscSqrtReal(-w[i]);
266:     if (temp<0) temp = -temp;
267:     w[i] =  (s[i] >= 0) ? temp : -temp;
268:   }

270:   /* Compute eigenvectors of the modified rank-1 modification (using the */
271:   /* vector W). */

273:   for (j = 0; j < k; ++j) {
274:     for (i = 0; i < k; ++i) {
275:       s[i] = w[i] / q[i+j*ldq];
276:     }
277:     temp = BLASnrm2_(&k, s, &one);
278:     for (i = 0; i < k; ++i) {

280:       /* apply the permutation resulting from deflation as stored */
281:       /* in INDX */

283:       ii = indx[i];
284:       q[i+j*ldq] = s[ii-1] / temp;
285:     }
286:   }

288: /* ************************************************************************** */

290:   /* ....updating the eigenvectors.... */

292: L110:

294:   n2 = n - n1;
295:   n12 = ctot[0] + ctot[1];
296:   n23 = ctot[1] + ctot[2];
297:   if (*(unsigned char *)jobz == 'D') {

299:     /* Compute the updated eigenvectors. (NOTE that every call of */
300:     /* DGEMM requires three DISTINCT arrays) */

302:     /* copy Q( CTOT(1)+1:K,1:K ) to S */

304:     PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n23, &k, &q[ctot[0]], &ldq, s, &n23));
305:     iq2 = n1 * n12 + 1;

307:     if (n23 != 0) {

309:       /* multiply the second part of Q2 (the eigenvectors of the */
310:       /* lower block) with S and write the result into the lower part of */
311:       /* Q, i.e., Q( N1+1:N,1:K ) */

313:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "N", &n2, &k, &n23, &done,
314:                   &q2[iq2-1], &n2, s, &n23, &dzero, &q[n1], &ldq));
315:     } else {
316:       PetscStackCallBLAS("LAPACKlaset",LAPACKlaset_("A", &n2, &k, &dzero, &dzero, &q[n1], &ldq));
317:     }

319:     /* copy Q( 1:CTOT(1)+CTOT(2),1:K ) to S */

321:     PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n12, &k, q, &ldq, s, &n12));

323:     if (n12 != 0) {

325:       /* multiply the first part of Q2 (the eigenvectors of the */
326:       /* upper block) with S and write the result into the upper part of */
327:       /* Q, i.e., Q( 1:N1,1:K ) */

329:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "N", &n1, &k, &n12, &done,
330:                   q2, &n1, s, &n12, &dzero, q, &ldq));
331:     } else {
332:       PetscStackCallBLAS("LAPACKlaset",LAPACKlaset_("A", &n1, &k, &dzero, &dzero, q, &ldq));
333:     }
334:   }
335:   return(0);
336: #endif
337: }

slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dsrtdf.c.html0000644000175000017500000011341013107004621022660 0ustar jromanjroman
Actual source code: dsrtdf.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BDC - Block-divide and conquer (see description in README file).

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>
 25: #include <slepcblaslapack.h>

 27: PetscErrorCode BDC_dsrtdf_(PetscBLASInt *k,PetscBLASInt n,PetscBLASInt n1, 
 28:         PetscReal *d,PetscReal *q,PetscBLASInt ldq,PetscBLASInt *indxq, 
 29:         PetscReal *rho,PetscReal *z,PetscReal *dlamda,PetscReal *w, 
 30:         PetscReal *q2,PetscBLASInt *indx,PetscBLASInt *indxc,PetscBLASInt *indxp, 
 31:         PetscBLASInt *coltyp,PetscReal reltol,PetscBLASInt *dz,PetscBLASInt *de, 
 32:         PetscBLASInt *info)
 33: {
 34: /*  -- Routine written in LAPACK Version 3.0 style -- */
 35: /* *************************************************** */
 36: /*     Written by */
 37: /*     Michael Moldaschl and Wilfried Gansterer */
 38: /*     University of Vienna */
 39: /*     last modification: March 16, 2014 */

 41: /*     Small adaptations of original code written by */
 42: /*     Wilfried Gansterer and Bob Ward, */
 43: /*     Department of Computer Science, University of Tennessee */
 44: /*     see http://dx.doi.org/10.1137/S1064827501399432 */
 45: /* *************************************************** */

 47: /*  Purpose */
 48: /*  ======= */

 50: /*  DSRTDF merges the two sets of eigenvalues of a rank-one modified */
 51: /*  diagonal matrix D+ZZ^T together into a single sorted set. Then it tries */
 52: /*  to deflate the size of the problem. */
 53: /*  There are two ways in which deflation can occur:  when two or more */
 54: /*  eigenvalues of D are close together or if there is a tiny entry in the */
 55: /*  Z vector.  For each such occurrence the order of the related secular */
 56: /*  equation problem is reduced by one. */

 58: /*  Arguments */
 59: /*  ========= */

 61: /*  K      (output) INTEGER */
 62: /*         The number of non-deflated eigenvalues, and the order of the */
 63: /*         related secular equation. 0 <= K <=N. */

 65: /*  N      (input) INTEGER */
 66: /*         The dimension of the diagonal matrix.  N >= 0. */

 68: /*  N1     (input) INTEGER */
 69: /*         The location of the last eigenvalue in the leading sub-matrix. */
 70: /*         min(1,N) <= N1 <= max(1,N). */

 72: /*  D      (input/output) DOUBLE PRECISION array, dimension (N) */
 73: /*         On entry, D contains the eigenvalues of the two submatrices to */
 74: /*         be combined. */
 75: /*         On exit, D contains the trailing (N-K) updated eigenvalues */
 76: /*         (those which were deflated) sorted into increasing order. */

 78: /*  Q      (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */
 79: /*         On entry, Q contains the eigenvectors of two submatrices in */
 80: /*         the two square blocks with corners at (1,1), (N1,N1) */
 81: /*         and (N1+1, N1+1), (N,N). */
 82: /*         On exit, Q contains the trailing (N-K) updated eigenvectors */
 83: /*         (those which were deflated) in its last N-K columns. */

 85: /*  LDQ    (input) INTEGER */
 86: /*         The leading dimension of the array Q.  LDQ >= max(1,N). */

 88: /*  INDXQ  (input/output) INTEGER array, dimension (N) */
 89: /*         The permutation which separately sorts the two sub-problems */
 90: /*         in D into ascending order.  Note that elements in the second */
 91: /*         half of this permutation must first have N1 added to their */
 92: /*         values. Destroyed on exit. */

 94: /*  RHO    (input/output) DOUBLE PRECISION */
 95: /*         On entry, the off-diagonal element associated with the rank-1 */
 96: /*         cut which originally split the two submatrices which are now */
 97: /*         being recombined. */
 98: /*         On exit, RHO has been modified to the value required by */
 99: /*         DLAED3M (made positive and multiplied by two, such that */
100: /*         the modification vector has norm one). */

102: /*  Z      (input/output) DOUBLE PRECISION array, dimension (N) */
103: /*         On entry, Z contains the updating vector. */
104: /*         On exit, the contents of Z has been destroyed by the updating */
105: /*         process. */

107: /*  DLAMDA (output) DOUBLE PRECISION array, dimension (N) */
108: /*         A copy of the first K non-deflated eigenvalues which */
109: /*         will be used by DLAED3M to form the secular equation. */

111: /*  W      (output) DOUBLE PRECISION array, dimension (N) */
112: /*         The first K values of the final deflation-altered z-vector */
113: /*         which will be passed to DLAED3M. */

115: /*  Q2     (output) DOUBLE PRECISION array, dimension */
116: /*         ( N*N ) (if everything is deflated) or */
117: /*         ( N1*(COLTYP(1)+COLTYP(2)) + (N-N1)*(COLTYP(2)+COLTYP(3)) ) */
118: /*         (if not everything is deflated) */
119: /*         If everything is deflated, then N*N intermediate workspace */
120: /*         is needed in Q2. */
121: /*         If not everything is deflated, Q2 contains on exit a copy of the */
122: /*         first K non-deflated eigenvectors which will be used by */
123: /*         DLAED3M in a matrix multiply (DGEMM) to accumulate the new */
124: /*         eigenvectors, followed by the N-K deflated eigenvectors. */

126: /*  INDX   (workspace) INTEGER array, dimension (N) */
127: /*         The permutation used to sort the contents of DLAMDA into */
128: /*         ascending order. */

130: /*  INDXC  (output) INTEGER array, dimension (N) */
131: /*         The permutation used to arrange the columns of the deflated */
132: /*         Q matrix into three groups:  columns in the first group contain */
133: /*         non-zero elements only at and above N1 (type 1), columns in the */
134: /*         second group are dense (type 2), and columns in the third group */
135: /*         contain non-zero elements only below N1 (type 3). */

137: /*  INDXP  (workspace) INTEGER array, dimension (N) */
138: /*         The permutation used to place deflated values of D at the end */
139: /*         of the array.  INDXP(1:K) points to the nondeflated D-values */
140: /*         and INDXP(K+1:N) points to the deflated eigenvalues. */

142: /*  COLTYP (workspace/output) INTEGER array, dimension (N) */
143: /*         During execution, a label which will indicate which of the */
144: /*         following types a column in the Q2 matrix is: */
145: /*         1 : non-zero in the upper half only; */
146: /*         2 : dense; */
147: /*         3 : non-zero in the lower half only; */
148: /*         4 : deflated. */
149: /*         On exit, COLTYP(i) is the number of columns of type i, */
150: /*         for i=1 to 4 only. */

152: /*  RELTOL (input) DOUBLE PRECISION */
153: /*         User specified deflation tolerance. If RELTOL.LT.20*EPS, then */
154: /*         the standard value used in the original LAPACK routines is used. */

156: /*  DZ     (output) INTEGER, DZ.GE.0 */
157: /*         counts the deflation due to a small component in the modification */
158: /*         vector. */

160: /*  DE     (output) INTEGER, DE.GE.0 */
161: /*         counts the deflation due to close eigenvalues. */

163: /*  INFO   (output) INTEGER */
164: /*          = 0:  successful exit. */
165: /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */

167: /*  Further Details */
168: /*  =============== */

170: /*  Based on code written by */
171: /*  Wilfried Gansterer and Bob Ward, */
172: /*  Department of Computer Science, University of Tennessee */

174: /*  Based on the design of the LAPACK code DLAED2 with modifications */
175: /*  to allow a block divide and conquer scheme */

177: /*  DLAED2 was written by Jeff Rutter, Computer Science Division, University */
178: /*  of California at Berkeley, USA, and modified by Francoise Tisseur, */
179: /*  University of Tennessee. */

181: /*  ===================================================================== */

183: #if defined(SLEPC_MISSING_LAPACK_LAMRG) || defined(SLEPC_MISSING_LAPACK_LACPY)
185:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAMRG/LACPY - Lapack routine is unavailable");
186: #else
187:   PetscReal    c, s, t, eps, tau, tol, dmax, dmone = -1.;
188:   PetscBLASInt i, j, i1, k2, n2, ct, nj, pj=0, js, iq1, iq2;
189:   PetscBLASInt psm[4], imax, jmax, ctot[4], factmp=1, one=1;

192:   *info = 0;

194:   if (n < 0) {
195:     *info = -2;
196:   } else if (n1 < PetscMin(1,n) || n1 > PetscMax(1,n)) {
197:     *info = -3;
198:   } else if (ldq < PetscMax(1,n)) {
199:     *info = -6;
200:   }
201:   if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DSRTDF",-(*info));

203:   /* Initialize deflation counters */

205:   *dz = 0;
206:   *de = 0;

208: /* **************************************************************************** */

210:   /* Quick return if possible */

212:   if (n == 0) return(0);

214: /* **************************************************************************** */

216:   n2 = n - n1;

218:   /* Modify Z so that RHO is positive. */

220:   if (*rho < 0.) {
221:     PetscStackCallBLAS("BLASscal",BLASscal_(&n2, &dmone, &z[n1], &one));
222:   }

224:   /* Normalize z so that norm2(z) = 1.  Since z is the concatenation of */
225:   /* two normalized vectors, norm2(z) = sqrt(2). (NOTE that this holds also */
226:   /* here in the approximate block-tridiagonal D&C because the two vectors are */
227:   /* singular vectors, but it would not necessarily hold in a D&C for a */
228:   /* general banded matrix !) */

230:   t = 1. / PetscSqrtReal(2.);
231:   PetscStackCallBLAS("BLASscal",BLASscal_(&n, &t, z, &one));

233:   /* NOTE: at this point the value of RHO is modified in order to */
234:   /*       normalize Z:    RHO = ABS( norm2(z)**2 * RHO */
235:   /*       in our case:    norm2(z) = sqrt(2), and therefore: */

237:   *rho = PetscAbs(*rho * 2.);

239:   /* Sort the eigenvalues into increasing order */

241:   for (i = n1; i < n; ++i) indxq[i] += n1;

243:   /* re-integrate the deflated parts from the last pass */

245:   for (i = 0; i < n; ++i) dlamda[i] = d[indxq[i]-1];
246:   PetscStackCallBLAS("LAPACKlamrg",LAPACKlamrg_(&n1, &n2, dlamda, &one, &one, indxc));
247:   for (i = 0; i < n; ++i) indx[i] = indxq[indxc[i]-1];
248:   for (i = 0; i < n; ++i) indxq[i] = 0;

250:   /* Calculate the allowable deflation tolerance */

252:   /* imax = BLASamax_(&n, z, &one); */
253:   imax = 1;
254:   dmax = PetscAbsReal(z[0]);
255:   for (i=1;i<n;i++) {
256:     if (PetscAbsReal(z[i])>dmax) {
257:       imax = i+1;
258:       dmax = PetscAbsReal(z[i]);
259:     }
260:   }
261:   /* jmax = BLASamax_(&n, d, &one); */
262:   jmax = 1;
263:   dmax = PetscAbsReal(d[0]);
264:   for (i=1;i<n;i++) {
265:     if (PetscAbsReal(d[i])>dmax) {
266:       jmax = i+1;
267:       dmax = PetscAbsReal(d[i]);
268:     }
269:   }

271:   eps = LAPACKlamch_("Epsilon");
272:   if (reltol < eps * 20) {
273:     /* use the standard deflation tolerance from the original LAPACK code */
274:     tol = eps * 8. * PetscMax(PetscAbs(d[jmax-1]),PetscAbs(z[imax-1]));
275:   } else {
276:     /* otherwise set TOL to the input parameter RELTOL ! */
277:     tol = reltol * PetscMax(PetscAbs(d[jmax-1]),PetscAbs(z[imax-1]));
278:   }

280:   /* If the rank-1 modifier is small enough, no more needs to be done */
281:   /* except to reorganize Q so that its columns correspond with the */
282:   /* elements in D. */

284:   if (*rho * PetscAbs(z[imax-1]) <= tol) {

286:     /* complete deflation because of small rank-one modifier */
287:     /* NOTE: in this case we need N*N space in the array Q2 ! */

289:     *dz = n;
290:     *k = 0;
291:     iq2 = 1;
292:     for (j = 0; j < n; ++j) {
293:       i = indx[j];
294:       indxq[j] = i;
295:       PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, &q[(i-1)*ldq], &one, &q2[iq2-1], &one));
296:       dlamda[j] = d[i-1];
297:       iq2 += n;
298:     }
299:     PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n, &n, q2, &n, q, &ldq));
300:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, dlamda, &one, d, &one));
301:     return(0);
302:   }

304:   /* If there are multiple eigenvalues then the problem deflates.  Here */
305:   /* the number of equal eigenvalues is found.  As each equal */
306:   /* eigenvalue is found, an elementary reflector is computed to rotate */
307:   /* the corresponding eigensubspace so that the corresponding */
308:   /* components of Z are zero in this new basis. */
309:   
310:   /* initialize the column types */

312:   /* first N1 columns are initially (before deflation) of type 1 */
313:   for (i = 0; i < n1; ++i) coltyp[i] = 1;
314:   /* columns N1+1 to N are initially (before deflation) of type 3 */
315:   for (i = n1; i < n; ++i) coltyp[i] = 3;

317:   *k = 0;
318:   k2 = n + 1;
319:   for (j = 0; j < n; ++j) {
320:     nj = indx[j]-1;
321:     if (*rho * PetscAbs(z[nj]) <= tol) {

323:       /* Deflate due to small z component. */
324:       ++(*dz);
325:       --k2;

327:       /* deflated eigenpair, therefore column type 4 */
328:       coltyp[nj] = 4;
329:       indxp[k2-1] = nj+1;
330:       indxq[k2-1] = nj+1;
331:       if (j+1 == n) goto L100;
332:     } else {

334:       /* not deflated */
335:       pj = nj;
336:       goto L80;
337:     }
338:   }
339:   factmp = 1;
340: L80:
341:   ++j;
342:   nj = indx[j]-1;
343:   if (j+1 > n) goto L100;
344:   if (*rho * PetscAbs(z[nj]) <= tol) {

346:     /* Deflate due to small z component. */
347:     ++(*dz);
348:     --k2;
349:     coltyp[nj] = 4;
350:     indxp[k2-1] = nj+1;
351:     indxq[k2-1] = nj+1;
352:   } else {

354:     /* Check if eigenvalues are close enough to allow deflation. */
355:     s = z[pj];
356:     c = z[nj];

358:     /* Find sqrt(a**2+b**2) without overflow or */
359:     /* destructive underflow. */

361:     tau = LAPACKlapy2_(&c, &s);
362:     t = d[nj] - d[pj];
363:     c /= tau;
364:     s = -s / tau;
365:     if (PetscAbs(t * c * s) <= tol) {

367:       /* Deflate due to close eigenvalues. */
368:       ++(*de);
369:       z[nj] = tau;
370:       z[pj] = 0.;
371:       if (coltyp[nj] != coltyp[pj]) coltyp[nj] = 2;

373:         /* if deflation happens across the two eigenvector blocks */
374:         /* (eigenvalues corresponding to different blocks), then */
375:         /* on column in the eigenvector matrix fills up completely */
376:         /* (changes from type 1 or 3 to type 2) */

378:         /* eigenpair PJ is deflated, therefore the column type changes */
379:         /* to 4 */

381:         coltyp[pj] = 4;
382:         PetscStackCallBLAS("BLASrot",BLASrot_(&n, &q[pj*ldq], &one, &q[nj*ldq], &one, &c, &s));
383:         t = d[pj] * (c * c) + d[nj] * (s * s);
384:         d[nj] = d[pj] * (s * s) + d[nj] * (c * c);
385:         d[pj] = t;
386:         --k2;
387:         i = 1;
388: L90:
389:         if (k2 + i <= n) {
390:           if (d[pj] < d[indxp[k2 + i-1]-1]) {
391:             indxp[k2 + i - 2] = indxp[k2 + i - 1];
392:             indxq[k2 + i - 2] = indxq[k2 + i - 1];
393:             indxp[k2 + i - 1] = pj + 1;
394:             indxq[k2 + i - 2] = pj + 1;
395:             ++i;
396:             goto L90;
397:           } else {
398:             indxp[k2 + i - 2] = pj + 1;
399:             indxq[k2 + i - 2] = pj + 1;
400:           }
401:         } else {
402:           indxp[k2 + i - 2] = pj + 1;
403:           indxq[k2 + i - 2] = pj + 1;
404:         }
405:         pj = nj;
406:         factmp = -1;
407:       } else {

409:       /* do not deflate */
410:       ++(*k);
411:       dlamda[*k-1] = d[pj];
412:       w[*k-1] = z[pj];
413:       indxp[*k-1] = pj + 1;
414:       indxq[*k-1] = pj + 1;
415:       factmp = 1;
416:       pj = nj;
417:     }
418:   }
419:   goto L80;
420: L100:

422:   /* Record the last eigenvalue. */
423:   ++(*k);
424:   dlamda[*k-1] = d[pj];
425:   w[*k-1] = z[pj];
426:   indxp[*k-1] = pj+1;
427:   indxq[*k-1] = (pj+1) * factmp;

429:   /* Count up the total number of the various types of columns, then */
430:   /* form a permutation which positions the four column types into */
431:   /* four uniform groups (although one or more of these groups may be */
432:   /* empty). */

434:   for (j = 0; j < 4; ++j) ctot[j] = 0;
435:   for (j = 0; j < n; ++j) {
436:     ct = coltyp[j];
437:     ++ctot[ct-1];
438:   }

440:   /* PSM(*) = Position in SubMatrix (of types 1 through 4) */
441:   psm[0] = 1;
442:   psm[1] = ctot[0] + 1;
443:   psm[2] = psm[1] + ctot[1];
444:   psm[3] = psm[2] + ctot[2];
445:   *k = n - ctot[3];

447:   /* Fill out the INDXC array so that the permutation which it induces */
448:   /* will place all type-1 columns first, all type-2 columns next, */
449:   /* then all type-3's, and finally all type-4's. */

451:   for (j = 0; j < n; ++j) {
452:     js = indxp[j];
453:     ct = coltyp[js-1];
454:     indx[psm[ct - 1]-1] = js;
455:     indxc[psm[ct - 1]-1] = j+1;
456:     ++psm[ct - 1];
457:   }

459:   /* Sort the eigenvalues and corresponding eigenvectors into DLAMDA */
460:   /* and Q2 respectively.  The eigenvalues/vectors which were not */
461:   /* deflated go into the first K slots of DLAMDA and Q2 respectively, */
462:   /* while those which were deflated go into the last N - K slots. */

464:   i = 0;
465:   iq1 = 0;
466:   iq2 = (ctot[0] + ctot[1]) * n1;
467:   for (j = 0; j < ctot[0]; ++j) {
468:     js = indx[i];
469:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&n1, &q[(js-1)*ldq], &one, &q2[iq1], &one));
470:     z[i] = d[js-1];
471:     ++i;
472:     iq1 += n1;
473:   }

475:   for (j = 0; j < ctot[1]; ++j) {
476:     js = indx[i];
477:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&n1, &q[(js-1)*ldq], &one, &q2[iq1], &one));
478:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&n2, &q[n1+(js-1)*ldq], &one, &q2[iq2], &one));
479:     z[i] = d[js-1];
480:     ++i;
481:     iq1 += n1;
482:     iq2 += n2;
483:   }

485:   for (j = 0; j < ctot[2]; ++j) {
486:     js = indx[i];
487:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&n2, &q[n1+(js-1)*ldq], &one, &q2[iq2], &one));
488:     z[i] = d[js-1];
489:     ++i;
490:     iq2 += n2;
491:   }

493:   iq1 = iq2;
494:   for (j = 0; j < ctot[3]; ++j) {
495:     js = indx[i];
496:     PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, &q[(js-1)*ldq], &one, &q2[iq2], &one));
497:     iq2 += n;
498:     z[i] = d[js-1];
499:     ++i;
500:   }

502:   /* The deflated eigenvalues and their corresponding vectors go back */
503:   /* into the last N - K slots of D and Q respectively. */

505:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n, &ctot[3], &q2[iq1], &n, &q[*k*ldq], &ldq));
506:   i1 = n - *k;
507:   PetscStackCallBLAS("BLAScopy",BLAScopy_(&i1, &z[*k], &one, &d[*k], &one));

509:   /* Copy CTOT into COLTYP for referencing in DLAED3M. */

511:   for (j = 0; j < 4; ++j) coltyp[j] = ctot[j];
512:   return(0);
513: #endif
514: }

slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dsbtdc.c.html0000644000175000017500000016474213107004621022653 0ustar jromanjroman
Actual source code: dsbtdc.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BDC - Block-divide and conquer (see description in README file).

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>
 25: #include <slepcblaslapack.h>

 27: PetscErrorCode BDC_dsbtdc_(const char *jobz,const char *jobacc,PetscBLASInt n, 
 28:         PetscBLASInt nblks,PetscBLASInt *ksizes,PetscReal *d,PetscBLASInt l1d, 
 29:         PetscBLASInt l2d,PetscReal *e,PetscBLASInt l1e,PetscBLASInt l2e,PetscReal tol,
 30:         PetscReal tau1,PetscReal tau2,PetscReal *ev,PetscReal *z,PetscBLASInt ldz,
 31:         PetscReal *work,PetscBLASInt lwork,PetscBLASInt *iwork,PetscBLASInt liwork, 
 32:         PetscReal *mingap,PetscBLASInt *mingapi,PetscBLASInt *info, 
 33:         PetscBLASInt jobz_len,PetscBLASInt jobacc_len)
 34: {
 35: /*  -- Routine written in LAPACK Version 3.0 style -- */
 36: /* *************************************************** */
 37: /*     Written by */
 38: /*     Michael Moldaschl and Wilfried Gansterer */
 39: /*     University of Vienna */
 40: /*     last modification: March 28, 2014 */

 42: /*     Small adaptations of original code written by */
 43: /*     Wilfried Gansterer and Bob Ward, */
 44: /*     Department of Computer Science, University of Tennessee */
 45: /*     see http://dx.doi.org/10.1137/S1064827501399432 */
 46: /* *************************************************** */

 48: /*  Purpose */
 49: /*  ======= */

 51: /*  DSBTDC computes approximations to all eigenvalues and eigenvectors */
 52: /*  of a symmetric block tridiagonal matrix using the divide and */
 53: /*  conquer method with lower rank approximations to the subdiagonal blocks. */

 55: /*  This code makes very mild assumptions about floating point */
 56: /*  arithmetic. It will work on machines with a guard digit in */
 57: /*  add/subtract, or on those binary machines without guard digits */
 58: /*  which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */
 59: /*  It could conceivably fail on hexadecimal or decimal machines */
 60: /*  without guard digits, but we know of none.  See DLAED3M for details. */

 62: /*  Arguments */
 63: /*  ========= */

 65: /*  JOBZ    (input) CHARACTER*1 */
 66: /*          = 'N':  Compute eigenvalues only (not implemented); */
 67: /*          = 'D':  Compute eigenvalues and eigenvectors. Eigenvectors */
 68: /*                  are accumulated in the divide-and-conquer process. */

 70: /*  JOBACC  (input) CHARACTER*1 */
 71: /*          = 'A' ("automatic"): The accuracy parameters TAU1 and TAU2 */
 72: /*                               are determined automatically from the */
 73: /*                               parameter TOL according to the analytical */
 74: /*                               bounds. In that case the input values of */
 75: /*                               TAU1 and TAU2 are irrelevant (ignored). */
 76: /*          = 'M' ("manual"): The input values of the accuracy parameters */
 77: /*                            TAU1 and TAU2 are used. In that case the input */
 78: /*                            value of the parameter TOL is irrelevant */
 79: /*                            (ignored). */

 81: /*  N       (input) INTEGER */
 82: /*          The dimension of the symmetric block tridiagonal matrix. */
 83: /*          N >= 1. */

 85: /*  NBLKS   (input) INTEGER, 1 <= NBLKS <= N */
 86: /*          The number of diagonal blocks in the matrix. */

 88: /*  KSIZES  (input) INTEGER array, dimension (NBLKS) */
 89: /*          The dimensions of the square diagonal blocks from top left */
 90: /*          to bottom right.  KSIZES(I) >= 1 for all I, and the sum of */
 91: /*          KSIZES(I) for I = 1 to NBLKS has to be equal to N. */

 93: /*  D       (input) DOUBLE PRECISION array, dimension (L1D,L2D,NBLKS) */
 94: /*          The lower triangular elements of the symmetric diagonal */
 95: /*          blocks of the block tridiagonal matrix. The elements of the top */
 96: /*          left diagonal block, which is of dimension KSIZES(1), have to */
 97: /*          be placed in D(*,*,1); the elements of the next diagonal */
 98: /*          block, which is of dimension KSIZES(2), have to be placed in */
 99: /*          D(*,*,2); etc. */

101: /*  L1D     (input) INTEGER */
102: /*          The leading dimension of the array D.  L1D >= max(3,KMAX), */
103: /*          where KMAX is the dimension of the largest diagonal block, */
104: /*          i.e.,  KMAX = max_I ( KSIZES(I) ). */

106: /*  L2D     (input) INTEGER */
107: /*          The second dimension of the array D.  L2D >= max(3,KMAX), */
108: /*          where KMAX is as stated in L1D above. */

110: /*  E       (input) DOUBLE PRECISION array, dimension (L1E,L2E,NBLKS-1) */
111: /*          The elements of the subdiagonal blocks of the */
112: /*          block tridiagonal matrix. The elements of the top left */
113: /*          subdiagonal block, which is KSIZES(2) x KSIZES(1), have to be */
114: /*          placed in E(*,*,1); the elements of the next subdiagonal block, */
115: /*          which is KSIZES(3) x KSIZES(2), have to be placed in E(*,*,2); etc. */
116: /*          During runtime, the original contents of E(*,*,K) is */
117: /*          overwritten by the singular vectors and singular values of */
118: /*          the lower rank representation. */

120: /*  L1E     (input) INTEGER */
121: /*          The leading dimension of the array E.  L1E >= max(3,2*KMAX+1), */
122: /*          where KMAX is as stated in L1D above. The size of L1E enables */
123: /*          the storage of ALL singular vectors and singular values for */
124: /*          the corresponding off-diagonal block in E(*,*,K) and therefore */
125: /*          there are no restrictions on the rank of the approximation */
126: /*          (only the "natural" restriction */
127: /*          RANK( K ) .LE. MIN( KSIZES( K ),KSIZES( K+1 ) )). */

129: /*  L2E     (input) INTEGER */
130: /*          The second dimension of the array E.  L2E >= max(3,2*KMAX+1), */
131: /*          where KMAX is as stated in L1D above. The size of L2E enables */
132: /*          the storage of ALL singular vectors and singular values for */
133: /*          the corresponding off-diagonal block in E(*,*,K) and therefore */
134: /*          there are no restrictions on the rank of the approximation */
135: /*          (only the "natural" restriction */
136: /*          RANK( K ) .LE. MIN( KSIZES( K ),KSIZES( K+1 ) )). */

138: /*  TOL     (input) DOUBLE PRECISION, TOL.LE.TOLMAX */
139: /*          User specified tolerance for the residuals of the computed */
140: /*          eigenpairs. If ( JOBACC.EQ.'A' ) then it is used to determine */
141: /*          TAU1 and TAU2; ignored otherwise. */
142: /*          If ( TOL.LT.40*EPS .AND. JOBACC.EQ.'A' ) then TAU1 is set to machine */
143: /*          epsilon and TAU2 is set to the standard deflation tolerance from */
144: /*          LAPACK. */

146: /*  TAU1    (input) DOUBLE PRECISION, TAU1.LE.TOLMAX/2 */
147: /*          User specified tolerance for determining the rank of the */
148: /*          lower rank approximations to the off-diagonal blocks. */
149: /*          The rank for each off-diagonal block is determined such that */
150: /*          the resulting absolute eigenvalue error is less than or equal */
151: /*          to TAU1. */
152: /*          If ( JOBACC.EQ.'A' ) then TAU1 is determined automatically from */
153: /*             TOL and the input value is ignored. */
154: /*          If ( JOBACC.EQ.'M' .AND. TAU1.LT.20*EPS ) then TAU1 is set to */
155: /*             machine epsilon. */

157: /*  TAU2    (input) DOUBLE PRECISION, TAU2.LE.TOLMAX/2 */
158: /*          User specified deflation tolerance for the routine DIBTDC. */
159: /*          If ( 1.0D-1.GT.TAU2.GT.20*EPS ) then TAU2 is used as */
160: /*          the deflation tolerance in DSRTDF (EPS is the machine epsilon). */
161: /*          If ( TAU2.LE.20*EPS ) then the standard deflation tolerance from */
162: /*          LAPACK is used as the deflation tolerance in DSRTDF. */
163: /*          If ( JOBACC.EQ.'A' ) then TAU2 is determined automatically from */
164: /*             TOL and the input value is ignored. */
165: /*          If ( JOBACC.EQ.'M' .AND. TAU2.LT.20*EPS ) then TAU2 is set to */
166: /*             the standard deflation tolerance from LAPACK. */

168: /*  EV      (output) DOUBLE PRECISION array, dimension (N) */
169: /*          If INFO = 0, then EV contains the computed eigenvalues of the */
170: /*          symmetric block tridiagonal matrix in ascending order. */

172: /*  Z       (output) DOUBLE PRECISION array, dimension (LDZ,N) */
173: /*          If ( JOBZ.EQ.'D' .AND. INFO = 0 ) */
174: /*          then Z contains the orthonormal eigenvectors of the symmetric */
175: /*          block tridiagonal matrix computed by the routine DIBTDC */
176: /*          (accumulated in the divide-and-conquer process). */
177: /*          If ( -199 < INFO < -99 ) then Z contains the orthonormal */
178: /*          eigenvectors of the symmetric block tridiagonal matrix, */
179: /*          computed without divide-and-conquer (quick returns). */
180: /*          Otherwise not referenced. */

182: /*  LDZ     (input) INTEGER */
183: /*          The leading dimension of the array Z.  LDZ >= max(1,N). */

185: /*  WORK    (workspace/output) DOUBLE PRECISION array, dimension (LWORK) */

187: /*  LWORK   (input) INTEGER */
188: /*          The dimension of the array WORK. */
189: /*          If NBLKS.EQ.1, then LWORK has to be at least 2N^2+6N+1 */
190: /*          (for the call of DSYEVD). */
191: /*          If NBLKS.GE.2 and ( JOBZ.EQ.'D' ) then the absolute minimum */
192: /*             required for DIBTDC is ( N**2 + 3*N ). This will not always */
193: /*             suffice, though, the routine will return a corresponding */
194: /*             error code and report how much work space was missing (see */
195: /*             INFO). */
196: /*          In order to guarantee correct results in all cases where */
197: /*          NBLKS.GE.2, LWORK must be at least ( 2*N**2 + 3*N ). */

199: /*  IWORK   (workspace/output) INTEGER array, dimension (LIWORK) */

201: /*  LIWORK  (input) INTEGER */
202: /*          The dimension of the array IWORK. */
203: /*          LIWORK must be at least ( 5*N + 5*NBLKS - 1 ) (for DIBTDC) */
204: /*          Note that this should also suffice for the call of DSYEVD on a */
205: /*          diagonal block which requires ( 5*KMAX + 3 ). */


208: /*  MINGAP  (output) DOUBLE PRECISION */
209: /*          The minimum "gap" between the approximate eigenvalues */
210: /*          computed, i.e., MIN( ABS( EV( I+1 )-EV( I ) ) for I=1,2,..., N-1 */
211: /*          IF ( MINGAP.LE.TOL/10 ) THEN a warning flag is returned in INFO, */
212: /*          because the computed eigenvectors may be unreliable individually */
213: /*          (only the subspaces spanned are approximated reliably). */

215: /*  MINGAPI (output) INTEGER */
216: /*          Index I where the minimum gap in the spectrum occurred. */

218: /*  INFO    (output) INTEGER */
219: /*          = 0:  successful exit, no special cases occurred. */
220: /*          < -200: not enough workspace. Space for ABS(INFO + 200) */
221: /*                numbers is required in addition to the workspace provided, */
222: /*                otherwise some of the computed eigenvectors will be incorrect. */
223: /*          < -99, > -199: successful exit, but quick returns. */
224: /*                if INFO = -100, successful exit, but the input matrix */
225: /*                                was the zero matrix and no */
226: /*                                divide-and-conquer was performed */
227: /*                if INFO = -101, successful exit, but N was 1 and no */
228: /*                                divide-and-conquer was performed */
229: /*                if INFO = -102, successful exit, but only a single */
230: /*                                dense block. Standard dense solver */
231: /*                                was called, no divide-and-conquer was */
232: /*                                performed */
233: /*                if INFO = -103, successful exit, but warning that */
234: /*                                MINGAP.LE.TOL/10 and therefore the */
235: /*                                eigenvectors corresponding to close */
236: /*                                approximate eigenvalues may individually */
237: /*                                be unreliable (although taken together they */
238: /*                                do approximate the corresponding subspace to */
239: /*                                the desired accuracy) */
240: /*          = -99: error in the preprocessing in DIBTDC (when determining */
241: /*                 the merging order). */
242: /*          < 0, > -99: illegal arguments. */
243: /*                if INFO = -i, the i-th argument had an illegal value. */
244: /*          > 0:  The algorithm failed to compute an eigenvalue while */
245: /*                working on the submatrix lying in rows and columns */
246: /*                INFO/(N+1) through mod(INFO,N+1). */

248: /*  Further Details */
249: /*  =============== */

251: /*  Small modifications of code written by */
252: /*     Wilfried Gansterer and Bob Ward, */
253: /*     Department of Computer Science, University of Tennessee */
254: /*     see http://dx.doi.org/10.1137/S1064827501399432 */

256: /*  Based on the design of the LAPACK code sstedc.f written by Jeff */
257: /*  Rutter, Computer Science Division, University of California at */
258: /*  Berkeley, and modified by Francoise Tisseur, University of Tennessee. */

260: /*  ===================================================================== */

262: /*     .. Parameters .. */

264: #define TOLMAX 0.1

266: /*        TOLMAX       .... upper bound for tolerances TOL, TAU1, TAU2 */
267: /*                          NOTE: in the routine DIBTDC, the value */
268: /*                                1.D-1 is hardcoded for TOLMAX ! */

270: #if defined(SLEPC_MISSING_LAPACK_SYEVD) || defined(PETSC_MISSING_LAPACK_GESVD) || defined(SLEPC_MISSING_LAPACK_LASET) || defined(SLEPC_MISSING_LAPACK_LASCL)
272:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"SYEVD/GESVD/LASET/LASCL - Lapack routine is unavailable");
273: #else
274:   PetscBLASInt   i, j, k, i1, iwspc, lwmin, start;
275:   PetscBLASInt   ii, ip, jp, nk, rk, np, iu, rp1, ldu;
276:   PetscBLASInt   ksk, ivt, iend, kchk, kmax, one=1, zero=0;
277:   PetscBLASInt   ldvt, ksum, kskp1, spneed, nrblks, liwmin, isvals;
278:   PetscReal      p, d2, eps, dmax, emax, done = 1.0, dzero = 0.0;
279:   PetscReal      dnrm, tiny, anorm, exdnrm=0, dropsv, absdiff;

283:   /* Determine machine epsilon. */
284:   eps = LAPACKlamch_("Epsilon");

286:   *info = 0;

288:   if (*(unsigned char *)jobz != 'N' && *(unsigned char *)jobz != 'D') {
289:     *info = -1;
290:   } else if (*(unsigned char *)jobacc != 'A' && *(unsigned char *)jobacc != 'M') {
291:     *info = -2;
292:   } else if (n < 1) {
293:     *info = -3;
294:   } else if (nblks < 1 || nblks > n) {
295:     *info = -4;
296:   }
297:   if (*info == 0) {
298:     ksum = 0;
299:     kmax = 0;
300:     kchk = 0;
301:     for (k = 0; k < nblks; ++k) {
302:       ksk = ksizes[k];
303:       ksum += ksk;
304:       if (ksk > kmax) kmax = ksk;
305:       if (ksk < 1) kchk = 1;
306:     }
307:     if (nblks == 1) lwmin = 2*n*n + n*6 + 1;
308:     else lwmin = n*n + n*3;
309:     liwmin = n * 5 + nblks * 5 - 4;
310:     if (ksum != n || kchk == 1) {
311:       *info = -5;
312:     } else if (l1d < PetscMax(3,kmax)) {
313:       *info = -7;
314:     } else if (l2d < PetscMax(3,kmax)) {
315:       *info = -8;
316:     } else if (l1e < PetscMax(3,2*kmax+1)) {
317:       *info = -10;
318:     } else if (l2e < PetscMax(3,2*kmax+1)) {
319:       *info = -11;
320:     } else if (*(unsigned char *)jobacc == 'A' && tol > TOLMAX) {
321:       *info = -12;
322:     } else if (*(unsigned char *)jobacc == 'M' && tau1 > TOLMAX/2) {
323:       *info = -13;
324:     } else if (*(unsigned char *)jobacc == 'M' && tau2 > TOLMAX/2) {
325:       *info = -14;
326:     } else if (ldz < PetscMax(1,n)) {
327:       *info = -17;
328:     } else if (lwork < lwmin) {
329:       *info = -19;
330:     } else if (liwork < liwmin) {
331:       *info = -21;
332:     }
333:   }

335:   if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DSBTDC",-(*info));

337:   /* Quick return if possible */

339:   if (n == 1) {
340:     ev[0] = d[0];
341:     z[0] = 1.;
342:     *info = -101;
343:     return(0);
344:   }

346:   /* If NBLKS is equal to 1, then solve the problem with standard */
347:   /* dense solver (in this case KSIZES(1) = N). */

349:   if (nblks == 1) {
350:     PetscPrintf(PETSC_COMM_WORLD," dsbtdc: This branch still needs to be checked!\n");
351:     for (i = 0; i < n; ++i) {
352:       for (j = 0; j <= i; ++j) {
353:         z[i + j*ldz] = d[i + j*l1d];
354:       }
355:     }
356:     PetscStackCallBLAS("LAPACKsyevd",LAPACKsyevd_("V", "L", &n, z, &ldz, ev, work, &lwork, iwork, &liwork, info));
357:     if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DSYEVD, info = %d",*info);
358:     *info = -102;
359:     return(0);
360:   }

362:   /* determine the accuracy parameters (if requested) */

364:   if (*(unsigned char *)jobacc == 'A') {
365:     tau1 = tol / 2;
366:     if (tau1 < eps * 20) tau1 = eps;
367:     tau2 = tol / 2;
368:   }

370:   /* Initialize Z as the identity matrix */

372:   if (*(unsigned char *)jobz == 'D') {
373:     PetscStackCallBLAS("LAPACKlaset",LAPACKlaset_("Full", &n, &n, &dzero, &done, z, &ldz));
374:   }

376:   /* Determine the off-diagonal ranks, form and store the lower rank */
377:   /* approximations based on the tolerance parameters, the */
378:   /* RANK( K ) largest singular values and the associated singular */
379:   /* vectors of each subdiagonal block. Also find the maximum norm of */
380:   /* the subdiagonal blocks (in EMAX). */
381:   
382:   /* Compute SVDs of the subdiagonal blocks.... */

384:   /* EMAX .... maximum norm of the off-diagonal blocks */

386:   emax = 0.;
387:   for (k = 0; k < nblks-1; ++k) {
388:     ksk = ksizes[k];
389:     kskp1 = ksizes[k+1];
390:     isvals = 0;

392:     /* Note that min(KSKP1,KSK).LE.N/2 (equality possible for */
393:     /* NBLKS=2), and therefore storing the singular values requires */
394:     /* at most N/2 entries of the *        array WORK. */

396:     iu = isvals + n / 2;
397:     ivt = isvals + n / 2;

399:     /* Call of DGESVD: The space for U is not referenced, since */
400:     /* JOBU='O' and therefore this portion of the array WORK */
401:     /* is not referenced for U. */

403:     ldu = kskp1;
404:     ldvt = PetscMin(kskp1,ksk);
405:     iwspc = ivt + n * n / 2;

407:     /* Note that the minimum workspace required for this call */
408:     /* of DGESVD is: N/2 for storing the singular values + N**2/2 for */
409:     /* storing V^T + 5*N/2 workspace =  N**2/2 + 3*N. */

411:     i1 = lwork - iwspc;
412:     PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("O", "S", &kskp1, &ksk,
413:             &e[k*l1e*l2e], &l1e, &work[isvals],
414:             &work[iu], &ldu, &work[ivt], &ldvt, &work[iwspc], &i1, info));
415:     if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DGESVD, info = %d",*info);

417:     /* Note that after the return from DGESVD U is stored in */
418:     /* E(*,*,K), and V^{\top} is stored in WORK( IVT, IVT+1, .... ) */

420:     /* determine the ranks RANK() for the approximations */

422:     rk = PetscMin(ksk,kskp1);
423: L8:
424:     dropsv = work[isvals - 1 + rk];

426:     if (dropsv * 2. <= tau1) {

428:       /* the error caused by dropping singular value RK is */
429:       /* small enough, try to reduce the rank by one more */

431:       --rk;
432:       if (rk > 0) goto L8;
433:       else iwork[k] = 0;
434:     } else {

436:       /* the error caused by dropping singular value RK is */
437:       /* too large already, RK is the rank required to achieve the */
438:       /* desired accuracy */

440:       iwork[k] = rk;
441:     }

443: /* ************************************************************************** */

445:     /* Store the first RANK( K ) terms of the SVD of the current */
446:     /* off-diagonal block. */
447:     /* NOTE that here it is required that L1E, L2E >= 2*KMAX+1 in order */
448:     /* to have enough space for storing singular vectors and values up */
449:     /* to the full SVD of an off-diagonal block !!!! */
450:    
451:     /* u1-u_RANK(K) is already contained in E(:,1:RANK(K),K) (as a */
452:     /* result of the call of DGESVD !), the sigma1-sigmaK are to be */
453:     /* stored in E(1:RANK(K),RANK(K)+1,K),  and v1-v_RANK(K) are to be */
454:     /* stored in E(:,RANK(K)+2:2*RANK(K)+1,K) */

456:     rp1 = iwork[k];
457:     for (j = 0; j < iwork[k]; ++j) {

459:       /* store sigma_J in E( J,RANK( K )+1,K ) */

461:       e[j + (rp1 + k*l2e)* l1e] = work[isvals + j];

463:       /* update maximum norm of subdiagonal blocks */

465:       if (e[j + (rp1 + k*l2e)*l1e] > emax) {
466:         emax = e[j + (rp1 + k*l2e)*l1e];
467:       }

469:       /* store v_J in E( :,RANK( K )+1+J,K ) */
470:       /* (note that WORK contains V^{\top} and therefore */
471:       /* we need to read rowwise !) */

473:       for (i = 1; i <= ksk; ++i) {
474:         e[i-1 + (rp1+j+1 + k*l2e)*l1e] = work[ivt+j + (i-1)*ldvt];
475:       }
476:     }

478:   }

480:   /* Compute the maximum norm of diagonal blocks and store the norm */
481:   /* of each diagonal block in E(RP1,RP1,K) (after the singular values); */
482:   /* store the norm of the last diagonal block in EXDNRM. */
483:   
484:   /* DMAX .... maximum one-norm of the diagonal blocks */

486:   dmax = 0.;
487:   for (k = 0; k < nblks; ++k) {
488:     rp1 = iwork[k];

490:     /* compute the one-norm of diagonal block K */

492:     dnrm = LAPACKlansy_("1", "L", &ksizes[k], &d[k*l1d*l2d], &l1d, work);
493:     if (k+1 == nblks) exdnrm = dnrm;
494:     else e[rp1 + (rp1 + k*l2e)*l1e] = dnrm;
495:     if (dnrm > dmax) dmax = dnrm;
496:   }

498:   /* Check for zero matrix. */

500:   if (emax == 0. && dmax == 0.) {
501:     for (i = 0; i < n; ++i) ev[i] = 0.;
502:     *info = -100;
503:     return(0);
504:   }

506: /* **************************************************************** */

508:   /* ....Identify irreducible parts of the block tridiagonal matrix */
509:   /* [while ( START <= NBLKS )].... */

511:   start = 0;
512:   np = 0;
513: L10:
514:   if (start < nblks) {

516:     /* Let IEND be the number of the next subdiagonal block such that */
517:     /* its RANK is 0 or IEND = NBLKS if no such subdiagonal exists. */
518:     /* The matrix identified by the elements between the diagonal block START */
519:     /* and the diagonal block IEND constitutes an independent (irreducible) */
520:     /* sub-problem. */

522:     iend = start;

524: L20:
525:     if (iend < nblks) {
526:       rk = iwork[iend];

528:       /* NOTE: if RANK( IEND ).EQ.0 then decoupling happens due to */
529:       /*       reduced accuracy requirements ! (because in this case */
530:       /*       we would not merge the corresponding two diagonal blocks) */
531:       
532:       /* NOTE: seems like any combination may potentially happen: */
533:       /*       (i) RANK = 0 but no decoupling due to small norm of */
534:       /*           off-diagonal block (corresponding diagonal blocks */
535:       /*           also have small norm) as well as */
536:       /*       (ii) RANK > 0 but decoupling due to small norm of */
537:       /*           off-diagonal block (corresponding diagonal blocks */
538:       /*           have very large norm) */
539:       /*       case (i) is ruled out by checking for RANK = 0 above */
540:       /*       (we decide to decouple all the time when the rank */
541:       /*       of an off-diagonal block is zero, independently of */
542:       /*       the norms of the corresponding diagonal blocks. */

544:       if (rk > 0) {

546:         /* check for decoupling due to small norm of off-diagonal block */
547:         /* (relative to the norms of the corresponding diagonal blocks) */

549:         if (iend == nblks-2) {
550:           d2 = PetscSqrtReal(exdnrm);
551:         } else {
552:           d2 = PetscSqrtReal(e[iwork[iend+1] + (iwork[iend+1] + (iend+1)*l2e)*l1e]);
553:         }

555:         /* this definition of TINY is analogous to the definition */
556:         /* in the tridiagonal divide&conquer (dstedc) */

558:         tiny = eps * PetscSqrtReal(e[iwork[iend] + (iwork[iend] + iend*l2e)*l1e])*d2;
559:         if (e[(iwork[iend] + iend*l2e)*l1e] > tiny) {

561:           /* no decoupling due to small norm of off-diagonal block */

563:           ++iend;
564:           goto L20;
565:         }
566:       }
567:     }

569:     /* ....(Sub) Problem determined: between diagonal blocks */
570:     /*     START and IEND. Compute its size and solve it.... */

572:     nrblks = iend - start + 1;
573:     if (nrblks == 1) {

575:       /* Isolated problem is a single diagonal block */

577:       nk = ksizes[start];

579:       /* copy this isolated block into Z */

581:       for (i = 0; i < nk; ++i) {
582:         ip = np + i + 1;
583:         for (j = 0; j <= i; ++j) {
584:           jp = np + j + 1;
585:           z[ip + jp*ldz] = d[i + (j + start*l2d)*l1d];
586:         }
587:       }

589:       /* check whether there is enough workspace */

591:       spneed = 2*nk*nk + nk * 6 + 1;
592:       if (spneed > lwork) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: not enough workspace for DSYEVD, info = %d",lwork - 200 - spneed);

594:       PetscStackCallBLAS("LAPACKsyevd",LAPACKsyevd_("V", "L", &nk,
595:                     &z[np + np*ldz], &ldz, &ev[np],
596:                     work, &lwork, &iwork[nblks-1], &liwork, info));
597:       if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DSYEVD, info = %d",*info);
598:       start = iend + 1;
599:       np += nk;

601:       /* go to the next irreducible subproblem */

603:       goto L10;
604:     }

606:     /* ....Isolated problem consists of more than one diagonal block. */
607:     /*     Start the divide and conquer algorithm.... */
608:     
609:     /* Scale: Divide by the maximum of all norms of diagonal blocks */
610:     /*        and singular values of the subdiagonal blocks */
611:     
612:     /* ....determine maximum of the norms of all diagonal and subdiagonal */
613:     /*     blocks.... */

615:     if (iend == nblks-1) anorm = exdnrm;
616:     else anorm = e[iwork[iend] + (iwork[iend] + iend*l2e)*l1e];
617:     for (k = start; k < iend; ++k) {
618:       rp1 = iwork[k];

620:       /* norm of diagonal block */
621:       anorm = PetscMax(anorm,e[rp1 + (rp1 + k*l2e)*l1e]);

623:       /* singular value of subdiagonal block */
624:       anorm = PetscMax(anorm,e[(rp1 + k*l2e)*l1e]);
625:     }

627:     nk = 0;
628:     for (k = start; k < iend+1; ++k) {
629:       ksk = ksizes[k];
630:       nk += ksk;

632:       /* scale the diagonal block */
633:       PetscStackCallBLAS("LAPACKlascl",LAPACKlascl_("L", &zero, &zero,
634:                     &anorm, &done, &ksk, &ksk, &d[k*l2d*l1d], &l1d, info));
635:       if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DLASCL, info = %d",*info);

637:       /* scale the (approximated) off-diagonal block by dividing its */
638:       /* singular values */

640:       if (k != iend) {

642:         /* the last subdiagonal block has index IEND-1 !!!! */
643:         for (i = 0; i < iwork[k]; ++i) {
644:           e[i + (iwork[k] + k*l2e)*l1e] /= anorm;
645:         }
646:       }
647:     }

649:     /* call the block-tridiagonal divide-and-conquer on the */
650:     /* irreducible subproblem which has been identified */

652:     BDC_dibtdc_(jobz, nk, nrblks, &ksizes[start], &d[start*l1d*l2d], l1d, l2d,
653:                 &e[start*l2e*l1e], &iwork[start], l1e, l2e, tau2, &ev[np],
654:                 &z[np + np*ldz], ldz, work, lwork, &iwork[nblks-1], liwork, info, 1);
655:                 
656:     if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DIBTDC, info = %d",*info);

658: /* ************************************************************************** */

660:     /* Scale back the computed eigenvalues. */

662:     PetscStackCallBLAS("LAPACKlascl",LAPACKlascl_("G", &zero, &zero, &done,
663:             &anorm, &nk, &one, &ev[np], &nk, info));
664:     if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DLASCL, info = %d",*info);

666:     start = iend + 1;
667:     np += nk;

669:     /* Go to the next irreducible subproblem. */

671:     goto L10;
672:   }

674:   /* ....If the problem split any number of times, then the eigenvalues */
675:   /* will not be properly ordered. Here we permute the eigenvalues */
676:   /* (and the associated eigenvectors) across the irreducible parts */
677:   /* into ascending order.... */
678:   
679:   /*  IF( NRBLKS.LT.NBLKS )THEN */
680:   
681:   /*    Use Selection Sort to minimize swaps of eigenvectors */

683:   for (ii = 1; ii < n; ++ii) {
684:     i = ii;
685:     k = i;
686:     p = ev[i];
687:     for (j = ii; j < n; ++j) {
688:       if (ev[j] < p) {
689:         k = j;
690:         p = ev[j];
691:       }
692:     }
693:     if (k != i) {
694:       ev[k] = ev[i];
695:       ev[i] = p;
696:       PetscStackCallBLAS("BLASswap",BLASswap_(&n, &z[i*ldz], &one, &z[k*ldz], &one));
697:     }
698:   }

700:   /* ...Compute MINGAP (minimum difference between neighboring eigenvalue */
701:   /*    approximations).............................................. */

703:   *mingap = ev[1] - ev[0];
704:   if (*mingap < 0.) SETERRQ2(PETSC_COMM_SELF,1,"dsbtdc: Eigenvalue approximations are not ordered properly. Approximation %d is larger than approximation %d.",1,2);
705:   *mingapi = 1;
706:   for (i = 2; i < n; ++i) {
707:     absdiff = ev[i] - ev[i-1];
708:     if (absdiff < 0.) {
709:       SETERRQ2(PETSC_COMM_SELF,1,"dsbtdc: Eigenvalue approximations are not ordered properly. Approximation %d is larger than approximation %d.",i,i+1);
710:     } else if (absdiff < *mingap) {
711:       *mingap = absdiff;
712:       *mingapi = i;
713:     }
714:   }

716:   /* check whether the minimum gap between eigenvalue approximations */
717:   /* may indicate severe inaccuracies in the eigenvector approximations */

719:   if (*mingap <= tol / 10) *info = -103;
720:   return(0);
721: #endif
722: }

slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/README0000644000175000017500000000212313107004621021141 0ustar jromanjroman - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BDC - Block-divide and conquer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This directory contains a C translation and adaption of BDC: ******BLOCK DIVIDE-AND-CONQUER ALGORITHM***************** * Written by * * Michael Moldaschl and Wilfried Gansterer * * University of Vienna * * last modification: March 16, 2014 * * * * Small adaptations of the original * * version written by * * Wilfried Gansterer and Bob Ward, * * University of Tennessee * * (see http://dx.doi.org/10.1137/S1064827501399432) * ********************************************************* The translation to C was done with f2c, and edited later to adapt the code to PETSc standards. slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/index.html0000644000175000017500000000243613107004621022265 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

dibtdc.c
dlaed3m.c
dmerg2.c
dsbtdc.c
dsrtdf.c
makefile
slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dibtdc.c0000644000175000017500000007230613107004621021670 0ustar jromanjroman/* BDC - Block-divide and conquer (see description in README file). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include static PetscErrorCode cutlr_(PetscBLASInt start,PetscBLASInt n,PetscBLASInt blkct, PetscBLASInt *bsizes,PetscBLASInt *ranks,PetscBLASInt *cut, PetscBLASInt *lsum,PetscBLASInt *lblks,PetscBLASInt *info) { /* -- Routine written in LAPACK Version 3.0 style -- */ /* *************************************************** */ /* Written by */ /* Michael Moldaschl and Wilfried Gansterer */ /* University of Vienna */ /* last modification: March 16, 2014 */ /* Small adaptations of original code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* see http://dx.doi.org/10.1137/S1064827501399432 */ /* *************************************************** */ /* Purpose */ /* ======= */ /* CUTLR computes the optimal cut in a sequence of BLKCT neighboring */ /* blocks whose sizes are given by the array BSIZES. */ /* The sum of all block sizes in the sequence considered is given by N. */ /* The cut is optimal in the sense that the difference of the sizes of */ /* the resulting two halves is minimum over all cuts with minimum ranks */ /* between blocks of the sequence considered. */ /* Arguments */ /* ========= */ /* START (input) INTEGER */ /* In the original array KSIZES of the calling routine DIBTDC, */ /* the position where the sequence considered in this routine starts. */ /* START >= 1. */ /* N (input) INTEGER */ /* The sum of all the block sizes of the sequence to be cut = */ /* = sum_{i=1}^{BLKCT} BSIZES( I ). */ /* N >= 3. */ /* BLKCT (input) INTEGER */ /* The number of blocks in the sequence to be cut. */ /* BLKCT >= 3. */ /* BSIZES (input) INTEGER array, dimension (BLKCT) */ /* The dimensions of the (quadratic) blocks of the sequence to be */ /* cut. sum_{i=1}^{BLKCT} BSIZES( I ) = N. */ /* RANKS (input) INTEGER array, dimension (BLKCT-1) */ /* The ranks determining the approximations of the off-diagonal */ /* blocks in the sequence considered. */ /* CUT (output) INTEGER */ /* After the optimum cut has been determined, the position (in the */ /* overall problem as worked on in DIBTDC !) of the last block in */ /* the first half of the sequence to be cut. */ /* START <= CUT <= START+BLKCT-2. */ /* LSUM (output) INTEGER */ /* After the optimum cut has been determined, the sum of the */ /* block sizes in the first half of the sequence to be cut. */ /* LSUM < N. */ /* LBLKS (output) INTEGER */ /* After the optimum cut has been determined, the number of the */ /* blocks in the first half of the sequence to be cut. */ /* 1 <= LBLKS < BLKCT. */ /* INFO (output) INTEGER */ /* = 0: successful exit. */ /* < 0: illegal arguments. */ /* if INFO = -i, the i-th (input) argument had an illegal */ /* value. */ /* > 0: illegal results. */ /* if INFO = i, the i-th (output) argument had an illegal */ /* value. */ /* Further Details */ /* =============== */ /* Based on code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* ===================================================================== */ PetscBLASInt i, ksk, kchk, ksum, nhalf, deviat, mindev, minrnk, tmpsum; PetscFunctionBegin; *info = 0; *lblks = 1; *lsum = 1; *cut = start; if (start < 1) { *info = -1; } else if (n < 3) { *info = -2; } else if (blkct < 3) { *info = -3; } if (*info == 0) { ksum = 0; kchk = 0; for (i = 0; i < blkct; ++i) { ksk = bsizes[i]; ksum += ksk; if (ksk < 1) kchk = 1; } if (ksum != n || kchk == 1) *info = -4; } if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in CUTLR",-(*info)); /* determine smallest rank in the range considered */ minrnk = n; for (i = 0; i < blkct-1; ++i) { if (ranks[i] < minrnk) minrnk = ranks[i]; } /* determine best cut among those with smallest rank */ nhalf = n / 2; tmpsum = 0; mindev = n; for (i = 0; i < blkct; ++i) { tmpsum += bsizes[i]; if (ranks[i] == minrnk) { /* determine deviation from "optimal" cut NHALF */ deviat = tmpsum - nhalf; if (deviat<0) deviat = -deviat; /* compare to best deviation so far */ if (deviat < mindev) { mindev = deviat; *cut = start + i; *lblks = i + 1; *lsum = tmpsum; } } } if (*cut < start || *cut >= start + blkct - 1) { *info = 6; } else if (*lsum < 1 || *lsum >= n) { *info = 7; } else if (*lblks < 1 || *lblks >= blkct) { *info = 8; } PetscFunctionReturn(0); } PetscErrorCode BDC_dibtdc_(const char *jobz,PetscBLASInt n,PetscBLASInt nblks, PetscBLASInt *ksizes,PetscReal *d,PetscBLASInt l1d,PetscBLASInt l2d, PetscReal *e,PetscBLASInt *rank,PetscBLASInt l1e,PetscBLASInt l2e, PetscReal tol,PetscReal *ev,PetscReal *z,PetscBLASInt ldz,PetscReal *work, PetscBLASInt lwork,PetscBLASInt *iwork,PetscBLASInt liwork, PetscBLASInt *info,PetscBLASInt jobz_len) { /* -- Routine written in LAPACK Version 3.0 style -- */ /* *************************************************** */ /* Written by */ /* Michael Moldaschl and Wilfried Gansterer */ /* University of Vienna */ /* last modification: March 16, 2014 */ /* Small adaptations of original code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* see http://dx.doi.org/10.1137/S1064827501399432 */ /* *************************************************** */ /* Purpose */ /* ======= */ /* DIBTDC computes all eigenvalues and corresponding eigenvectors of a */ /* symmetric irreducible block tridiagonal matrix with rank RANK matrices */ /* as the subdiagonal blocks using a block divide and conquer method. */ /* Arguments */ /* ========= */ /* JOBZ (input) CHARACTER*1 */ /* = 'N': Compute eigenvalues only (not implemented); */ /* = 'D': Compute eigenvalues and eigenvectors. */ /* Eigenvectors are accumulated in the */ /* divide-and-conquer process. */ /* N (input) INTEGER */ /* The dimension of the symmetric irreducible block tridiagonal */ /* matrix. N >= 2. */ /* NBLKS (input) INTEGER, 2 <= NBLKS <= N */ /* The number of diagonal blocks in the matrix. */ /* KSIZES (input) INTEGER array, dimension (NBLKS) */ /* The dimension of the square diagonal blocks from top left */ /* to bottom right. KSIZES(I) >= 1 for all I, and the sum of */ /* KSIZES(I) for I = 1 to NBLKS has to be equal to N. */ /* D (input) DOUBLE PRECISION array, dimension (L1D,L2D,NBLKS) */ /* The lower triangular elements of the symmetric diagonal */ /* blocks of the block tridiagonal matrix. Elements of the top */ /* left diagonal block, which is of dimension KSIZES(1), are */ /* contained in D(*,*,1); the elements of the next diagonal */ /* block, which is of dimension KSIZES(2), are contained in */ /* D(*,*,2); etc. */ /* L1D (input) INTEGER */ /* The leading dimension of the array D. L1D >= max(3,KMAX), */ /* where KMAX is the dimension of the largest diagonal block. */ /* L2D (input) INTEGER */ /* The second dimension of the array D. L2D >= max(3,KMAX), */ /* where KMAX is as stated in L1D above. */ /* E (input) DOUBLE PRECISION array, dimension (L1E,L2E,NBLKS-1) */ /* Contains the elements of the scalars (singular values) and */ /* vectors (singular vectors) defining the rank RANK subdiagonal */ /* blocks of the matrix. */ /* E(1:RANK(K),RANK(K)+1,K) holds the RANK(K) scalars, */ /* E(:,1:RANK(K),K) holds the RANK(K) column vectors, and */ /* E(:,RANK(K)+2:2*RANK(K)+1,K) holds the row vectors for the K-th */ /* subdiagonal block. */ /* RANK (input) INTEGER array, dimension (NBLKS-1). */ /* The ranks of all the subdiagonal blocks contained in the array E. */ /* RANK( K ) <= MIN( KSIZES( K ), KSIZES( K+1 ) ) */ /* L1E (input) INTEGER */ /* The leading dimension of the array E. L1E >= max(3,2*KMAX+1), */ /* where KMAX is as stated in L1D above. */ /* L2E (input) INTEGER */ /* The second dimension of the array E. L2E >= max(3,2*KMAX+1), */ /* where KMAX is as stated in L1D above. */ /* TOL (input) DOUBLE PRECISION, TOL <= 1.0D-1 */ /* User specified deflation tolerance for the routine DMERG2. */ /* If ( 1.0D-1 >= TOL >= 20*EPS ) then TOL is used as */ /* the deflation tolerance in DSRTDF. */ /* If ( TOL < 20*EPS ) then the standard deflation tolerance from */ /* LAPACK is used as the deflation tolerance in DSRTDF. */ /* EV (output) DOUBLE PRECISION array, dimension (N) */ /* If INFO = 0, then EV contains the eigenvalues of the */ /* symmetric block tridiagonal matrix in ascending order. */ /* Z (input/output) DOUBLE PRECISION array, dimension (LDZ, N) */ /* On entry, Z will be the identity matrix. */ /* On exit, Z contains the eigenvectors of the block tridiagonal */ /* matrix. */ /* LDZ (input) INTEGER */ /* The leading dimension of the array Z. LDZ >= max(1,N). */ /* WORK (workspace) DOUBLE PRECISION array, dimension (LWORK) */ /* LWORK (input) INTEGER */ /* The dimension of the array WORK. */ /* In order to guarantee correct results in all cases, */ /* LWORK must be at least ( 2*N**2 + 3*N ). In many cases, */ /* less workspace is required. The absolute minimum required is */ /* ( N**2 + 3*N ). */ /* If the workspace provided is not sufficient, the routine will */ /* return a corresponding error code and report how much workspace */ /* was missing (see INFO). */ /* IWORK (workspace) INTEGER array, dimension (LIWORK) */ /* LIWORK (input) INTEGER */ /* The dimension of the array IWORK. */ /* LIWORK must be at least ( 5*N + 3 + 4*NBLKS - 4 ): */ /* 5*KMAX+3 for DSYEVD, 5*N for ????, */ /* 4*NBLKS-4 for the preprocessing (merging order) */ /* Summarizing, the minimum integer workspace needed is */ /* MAX( 5*N, 5*KMAX + 3 ) + 4*NBLKS - 4 */ /* INFO (output) INTEGER */ /* = 0: successful exit. */ /* < 0, > -99: illegal arguments. */ /* if INFO = -i, the i-th argument had an illegal value. */ /* = -99: error in the preprocessing (call of CUTLR). */ /* < -200: not enough workspace. Space for ABS(INFO + 200) */ /* numbers is required in addition to the workspace provided, */ /* otherwise some eigenvectors will be incorrect. */ /* > 0: The algorithm failed to compute an eigenvalue while */ /* working on the submatrix lying in rows and columns */ /* INFO/(N+1) through mod(INFO,N+1). */ /* Further Details */ /* =============== */ /* Based on code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* This routine is comparable to Dlaed0.f from LAPACK. */ /* ===================================================================== */ #if defined(SLEPC_MISSING_LAPACK_LACPY) || defined(PETSC_MISSING_LAPACK_SYEV) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LACPY/SYEV - Lapack routine is unavailable"); #else PetscBLASInt i, j, k, np, rp1, ksk, one=1; PetscBLASInt cut, mat1, kchk, kbrk, blks, kmax, icut, size, ksum, lsum; PetscBLASInt lblks, rblks, isize, lwmin, ilsum; PetscBLASInt start, vstrt, istck1, istck2, istck3, merged; PetscBLASInt liwmin, matsiz, startp, istrtp; PetscReal rho, done=1.0, dmone=-1.0; PetscErrorCode ierr; PetscFunctionBegin; *info = 0; if (*(unsigned char *)jobz != 'N' && *(unsigned char *)jobz != 'D') { *info = -1; } else if (n < 2) { *info = -2; } else if (nblks < 2 || nblks > n) { *info = -3; } if (*info == 0) { ksum = 0; kmax = 0; kchk = 0; for (k = 0; k < nblks; ++k) { ksk = ksizes[k]; ksum += ksk; if (ksk > kmax) kmax = ksk; if (ksk < 1) kchk = 1; } lwmin = n*n + n * 3; liwmin = PetscMax(n * 5,kmax * 5 + 3) + 4*nblks - 4; if (ksum != n || kchk == 1) { *info = -4; } else if (l1d < PetscMax(3,kmax)) { *info = -6; } else if (l2d < PetscMax(3,kmax)) { *info = -7; } else if (l1e < PetscMax(3,2*kmax + 1)) { *info = -10; } else if (l2e < PetscMax(3,2*kmax + 1)) { *info = -11; } else if (tol > .1) { *info = -12; } else if (ldz < PetscMax(1,n)) { *info = -15; } else if (lwork < lwmin) { *info = -17; } else if (liwork < liwmin) { *info = -19; } } if (*info == 0) { for (k = 0; k < nblks-1; ++k) { if (rank[k] > PetscMin(ksizes[k],ksizes[k+1]) || rank[k] < 1) *info = -9; } } if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DIBTDC",-(*info)); /* **************************************************************************** */ /* ...Preprocessing..................................................... */ /* Determine the optimal order for merging the subblocks and how much */ /* workspace will be needed for the merging (determined by the last */ /* merge). Cutpoints for the merging operations are determined and stored */ /* in reverse chronological order (starting with the final merging */ /* operation). */ /* integer workspace requirements for the preprocessing: */ /* 4*(NBLKS-1) for merging history */ /* at most 3*(NBLKS-1) for stack */ start = 1; size = n; blks = nblks; merged = 0; k = 0; /* integer workspace used for the stack is not needed any more after the */ /* preprocessing and therefore can use part of the 5*N */ /* integer workspace needed later on in the code */ istck1 = 0; istck2 = istck1 + nblks; istck3 = istck2 + nblks; /* integer workspace used for storing the order of merges starts AFTER */ /* the integer workspace 5*N+3 which is needed later on in the code */ /* (5*KMAX+3 for DSYEVD, 4*N in DMERG2) */ istrtp = n * 5 + 4; icut = istrtp + nblks - 1; isize = icut + nblks - 1; ilsum = isize + nblks - 1; L200: if (nblks >= 3) { /* Determine the cut point. Note that in the routine CUTLR it is */ /* chosen such that it yields the best balanced merging operation */ /* among all the rank modifications with minimum rank. */ ierr = cutlr_(start, size, blks, &ksizes[start-1], &rank[start-1], &cut, &lsum, &lblks, info);CHKERRQ(ierr); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in cutlr, info = %d",*info); } else { cut = 1; lsum = ksizes[0]; lblks = 1; } ++merged; startp = 0; for (i = 0; i < start-1; ++i) startp += ksizes[i]; iwork[istrtp + (nblks - 1) - merged-1] = startp + 1; iwork[icut + (nblks - 1) - merged-1] = cut; iwork[isize + (nblks - 1) - merged-1] = size; iwork[ilsum + (nblks - 1) - merged-1] = lsum; if (lblks == 2) { /* one merge in left branch, left branch done */ ++merged; iwork[istrtp + (nblks - 1) - merged-1] = startp + 1; iwork[icut + (nblks - 1) - merged-1] = start; iwork[isize + (nblks - 1) - merged-1] = lsum; iwork[ilsum + (nblks - 1) - merged-1] = ksizes[start-1]; } if (lblks == 1 || lblks == 2) { /* left branch done, continue on the right side */ start += lblks; size -= lsum; blks -= lblks; if (blks <= 0) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in preprocessing, blks = %d",blks); if (blks == 2) { /* one merge in right branch, right branch done */ ++merged; startp += lsum; iwork[istrtp + (nblks - 1) - merged-1] = startp + 1; iwork[icut + (nblks - 1) - merged-1] = start; iwork[isize + (nblks - 1) - merged-1] = size; iwork[ilsum + (nblks - 1) - merged-1] = ksizes[start-1]; } if (blks == 1 || blks == 2) { /* get the next subproblem from the stack or finished */ if (k >= 1) { /* something left on the stack */ start = iwork[istck1 + k-1]; size = iwork[istck2 + k-1]; blks = iwork[istck3 + k-1]; --k; goto L200; } else { /* nothing left on the stack */ if (merged != nblks-1) SETERRQ(PETSC_COMM_SELF,1,"ERROR in preprocessing - not enough merges performed"); /* exit preprocessing */ } } else { /* BLKS.GE.3, and therefore analyze the right side */ goto L200; } } else { /* LBLKS.GE.3, and therefore check the right side and */ /* put it on the stack if required */ rblks = blks - lblks; if (rblks >= 3) { ++k; iwork[istck1 + k-1] = cut + 1; iwork[istck2 + k-1] = size - lsum; iwork[istck3 + k-1] = rblks; } else if (rblks == 2) { /* one merge in right branch, right branch done */ /* (note that nothing needs to be done if RBLKS.EQ.1 !) */ ++merged; startp += lsum; iwork[istrtp + (nblks - 1) - merged-1] = startp + 1; iwork[icut + (nblks - 1) - merged-1] = start + lblks; iwork[isize + (nblks - 1) - merged-1] = size - lsum; iwork[ilsum + (nblks - 1) - merged-1] = ksizes[start + lblks-1]; } if (rblks <= 0) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: ERROR in preprocessing - rblks = %d",rblks); /* continue on the left side */ size = lsum; blks = lblks; goto L200; } /* SIZE = IWORK( ISIZE+NBLKS-2 ) */ /* MAT1 = IWORK( ILSUM+NBLKS-2 ) */ /* Note: after the dimensions SIZE and MAT1 of the last merging */ /* operation have been determined, an upper bound for the workspace */ /* requirements which is independent of how much deflation occurs in */ /* the last merging operation could be determined as follows */ /* (based on (3.15) and (3.19) from UT-CS-00-447): */ /* IF( MAT1.LE.N/2 ) THEN */ /* WSPREQ = 3*N + 3/2*( SIZE-MAT1 )**2 + N*N/2 + MAT1*MAT1 */ /* ELSE */ /* WSPREQ = 3*N + 3/2*MAT1*MAT1 + N*N/2 + ( SIZE-MAT1 )**2 */ /* END IF */ /* IF( LWORK-WSPREQ.LT.0 )THEN */ /* not enough work space provided */ /* INFO = -200 - ( WSPREQ-LWORK ) */ /* RETURN */ /* END IF */ /* However, this is not really useful, since the actual check whether */ /* enough workspace is provided happens in DMERG2.f ! */ /* ************************************************************************* */ /* ...Solve subproblems................................... */ /* Divide the matrix into NBLKS submatrices using rank-r */ /* modifications (cuts) and solve for their eigenvalues and */ /* eigenvectors. Initialize index array to sort eigenvalues. */ /* first block: ...................................... */ /* correction for block 1: D1 - V1 \Sigma1 V1^T */ ksk = ksizes[0]; rp1 = rank[0]; /* initialize the proper part of Z with the diagonal block D1 */ /* (the correction will be made in Z and then the call of DSYEVD will */ /* overwrite it with the eigenvectors) */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, d, &l1d, z, &ldz)); /* copy D1 into WORK (in order to be able to restore it afterwards) */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, d, &l1d, work, &ksk)); /* copy V1 into the first RANK(1) columns of D1 and then */ /* multiply with \Sigma1 */ for (i = 0; i < rank[0]; ++i) { PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(rp1 + i+1)*l1e], &one, &d[i*l1d], &one)); PetscStackCallBLAS("BLASscal",BLASscal_(&ksk, &e[i + rp1*l1e], &d[i*l1d], &one)); } /* multiply the first RANK( 1 ) columns of D1 with V1^T and */ /* subtract the result from the proper part of Z (previously */ /* initialized with D1) */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, rank, &dmone, d, &l1d, &e[(rank[0]+1)*l1e], &l1e, &done, z, &ldz)); /* restore the original D1 from WORK */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, work, &ksk, d, &l1d)); /* eigenanalysis of block 1 (using DSYEVD) */ PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V", "L", &ksk, z, &ldz, ev, work, &lwork, info)); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in DSYEVD for block 1, info = %d",*info); /* EV( 1: ) contains the eigenvalues in ascending order */ /* (they are returned this way by DSYEVD) */ for (i = 0; i < ksk; ++i) iwork[i] = i+1; /* intermediate blocks: .............................. */ np = ksk; /* remaining number of blocks */ if (nblks > 2) { for (k = 1; k < nblks-1; ++k) { /* correction for block K: */ /* Dk - U(k-1) \Sigma(k-1) U(k-1)^T - Vk \Sigmak Vk^T */ ksk = ksizes[k]; rp1 = rank[k]; /* initialize the proper part of Z with the diagonal block Dk */ /* (the correction will be made in Z and then the call of DSYEVD will */ /* overwrite it with the eigenvectors) */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[k*l1d*l2d], &l1d, &z[np+np*ldz], &ldz)); /* copy Dk into WORK (in order to be able to restore it afterwards) */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[k*l1d*l2d], &l1d, work, &ksk)); /* copy U(K-1) into the first RANK(K-1) columns of Dk and then */ /* multiply with \Sigma(K-1) */ for (i = 0; i < rank[k-1]; ++i) { PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(i+(k-1)*l2e)*l1e], &one, &d[(i+k*l2d)*l1d], &one)); PetscStackCallBLAS("BLASscal",BLASscal_(&ksk, &e[i+(rank[k-1]+(k-1)*l2e)*l1e], &d[(i+k*l2d)*l1d], &one)); } /* multiply the first RANK(K-1) columns of Dk with U(k-1)^T and */ /* subtract the result from the proper part of Z (previously */ /* initialized with Dk) */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, &rank[k-1], &dmone, &d[k*l1d*l2d], &l1d, &e[(k-1)*l1e*l2e], &l1e, &done, &z[np+np*ldz], &ldz)); /* copy Vk into the first RANK(K) columns of Dk and then */ /* multiply with \Sigmak */ for (i = 0; i < rank[k]; ++i) { PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(rp1+i+1 + k*l2e)*l1e], &one, &d[(i + k*l2d)*l1d], &one)); PetscStackCallBLAS("BLASscal",BLASscal_(&ksk, &e[i + (rp1 + k*l2e)*l1e], &d[(i + k*l2d)*l1d], &one)); } /* multiply the first RANK(K) columns of Dk with Vk^T and */ /* subtract the result from the proper part of Z (previously */ /* updated with [- U(k-1) \Sigma(k-1) U(k-1)^T] ) */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, &rank[k], &dmone, &d[k*l1d*l2d], &l1d, &e[(rank[k]+1 + k*l2e)*l1e], &l1e, &done, &z[np+np*ldz], &ldz)); /* restore the original Dk from WORK */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, work, &ksk, &d[k*l1d*l2d], &l1d)); /* eigenanalysis of block K (using dsyevd) */ PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V", "L", &ksk, &z[np+np*ldz], &ldz, &ev[np], work, &lwork, info)); if (*info) SETERRQ2(PETSC_COMM_SELF,1,"dibtdc: Error in DSYEVD for block %d, info = %d",k,*info); /* EV( NPP1: ) contains the eigenvalues in ascending order */ /* (they are returned this way by DSYEVD) */ for (i = 0; i < ksk; ++i) iwork[np + i] = i+1; /* update NP */ np += ksk; } } /* last block: ....................................... */ /* correction for block NBLKS: */ /* D(nblks) - U(nblks-1) \Sigma(nblks-1) U(nblks-1)^T */ ksk = ksizes[nblks-1]; /* initialize the proper part of Z with the diagonal block D(nblks) */ /* (the correction will be made in Z and then the call of DSYEVD will */ /* overwrite it with the eigenvectors) */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[(nblks-1)*l1d*l2d], &l1d, &z[np+np*ldz], &ldz)); /* copy D(nblks) into WORK (in order to be able to restore it afterwards) */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, &d[(nblks-1)*l1d*l2d], &l1d, work, &ksk)); /* copy U(nblks-1) into the first RANK(nblks-1) columns of D(nblks) and then */ /* multiply with \Sigma(nblks-1) */ for (i = 0; i < rank[nblks-2]; ++i) { PetscStackCallBLAS("BLAScopy",BLAScopy_(&ksk, &e[(i + (nblks-2)*l2e)*l1e], &one, &d[(i + (nblks-1)*l2d)*l1d], &one)); PetscStackCallBLAS("BLASscal",BLASscal_(&ksk, &e[i + (rank[nblks-2] + (nblks-2)*l2e)*l1e], &d[(i + (nblks-1)*l2d)*l1d], &one)); } /* multiply the first RANK(nblks-1) columns of D(nblks) with U(nblks-1)^T */ /* and subtract the result from the proper part of Z (previously */ /* initialized with D(nblks) ) */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "T", &ksk, &ksk, &rank[nblks - 2], &dmone, &d[(nblks-1)*l1d*l2d], &l1d, &e[(nblks-2)*l1e*l2e], &l1e, &done, &z[np+np*ldz], &ldz)); /* restore the original D(nblks) from WORK */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L", &ksk, &ksk, work, &ksk, &d[(nblks-1)*l1d*l2d], &l1d)); /* eigenanalysis of block NBLKS (using dsyevd) */ PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V", "L", &ksk, &z[np+np*ldz], &ldz, &ev[np], work, &lwork, info)); if (*info) SETERRQ2(PETSC_COMM_SELF,1,"dibtdc: Error in DSYEVD for block %d, info = %d",nblks,*info); /* EV( NPP1: ) contains the eigenvalues in ascending order */ /* (they are returned this way by DSYEVD) */ for (i = 0; i < ksk; ++i) iwork[np + i] = i+1; /* note that from here on the entire workspace is available again */ /* Perform all the merging operations. */ vstrt = 0; for (i = 0; i < nblks-1; ++i) { /* MATSIZ = total size of the current rank RANK modification problem */ matsiz = iwork[isize + i - 1]; np = iwork[istrtp + i - 1]; kbrk = iwork[icut + i - 1]; mat1 = iwork[ilsum + i - 1]; vstrt += np; for (j = 0; j < rank[kbrk-1]; ++j) { /* NOTE: The parameter RHO in DMERG2 is modified in DSRTDF */ /* (multiplied by 2) ! In order not to change the */ /* singular value stored in E( :, RANK( KBRK )+1, KBRK ), */ /* we do not pass on this variable as an argument to DMERG2, */ /* but we assign a separate variable RHO here which is passed */ /* on to DMERG2. */ /* Alternative solution in F90: */ /* pass E( :,RANK( KBRK )+1,KBRK ) to an INTENT( IN ) parameter */ /* in DMERG2. */ rho = e[j + (rank[kbrk-1] + (kbrk-1)*l2e)*l1e]; /* eigenvectors are accumulated ( JOBZ.EQ.'D' ) */ ierr = BDC_dmerg2_(jobz, j+1, matsiz, &ev[np-1], &z[np-1+(np-1)*ldz], ldz, &iwork[np-1], &rho, &e[(j + (kbrk-1)*l2e)*l1e], ksizes[kbrk], &e[(rank[kbrk-1]+j+1 + (kbrk-1)*l2e)*l1e], ksizes[kbrk-1], mat1, work, lwork, &iwork[n], tol, info, 1); CHKERRQ(ierr); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dibtdc: Error in dmerg2, info = %d",*info); } /* at this point all RANK( KBRK ) rank-one modifications corresponding */ /* to the current off-diagonal block are finished. */ /* Move on to the next off-diagonal block. */ } /* Re-merge the eigenvalues/vectors which were deflated at the final */ /* merging step by sorting all eigenvalues and eigenvectors according */ /* to the permutation stored in IWORK. */ /* copy eigenvalues and eigenvectors in ordered form into WORK */ /* (eigenvalues into WORK( 1:N ), eigenvectors into WORK( N+1:N+1+N^2 ) ) */ for (i = 0; i < n; ++i) { j = iwork[i]; work[i] = ev[j-1]; PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, &z[(j-1)*ldz], &one, &work[n*(i+1)], &one)); } /* copy ordered eigenvalues back from WORK( 1:N ) into EV */ PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, work, &one, ev, &one)); /* copy ordered eigenvectors back from WORK( N+1:N+1+N^2 ) into Z */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n, &n, &work[n], &n, z, &ldz)); PetscFunctionReturn(0); #endif } slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dsrtdf.c0000644000175000017500000004262713107004621021730 0ustar jromanjroman/* BDC - Block-divide and conquer (see description in README file). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include PetscErrorCode BDC_dsrtdf_(PetscBLASInt *k,PetscBLASInt n,PetscBLASInt n1, PetscReal *d,PetscReal *q,PetscBLASInt ldq,PetscBLASInt *indxq, PetscReal *rho,PetscReal *z,PetscReal *dlamda,PetscReal *w, PetscReal *q2,PetscBLASInt *indx,PetscBLASInt *indxc,PetscBLASInt *indxp, PetscBLASInt *coltyp,PetscReal reltol,PetscBLASInt *dz,PetscBLASInt *de, PetscBLASInt *info) { /* -- Routine written in LAPACK Version 3.0 style -- */ /* *************************************************** */ /* Written by */ /* Michael Moldaschl and Wilfried Gansterer */ /* University of Vienna */ /* last modification: March 16, 2014 */ /* Small adaptations of original code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* see http://dx.doi.org/10.1137/S1064827501399432 */ /* *************************************************** */ /* Purpose */ /* ======= */ /* DSRTDF merges the two sets of eigenvalues of a rank-one modified */ /* diagonal matrix D+ZZ^T together into a single sorted set. Then it tries */ /* to deflate the size of the problem. */ /* There are two ways in which deflation can occur: when two or more */ /* eigenvalues of D are close together or if there is a tiny entry in the */ /* Z vector. For each such occurrence the order of the related secular */ /* equation problem is reduced by one. */ /* Arguments */ /* ========= */ /* K (output) INTEGER */ /* The number of non-deflated eigenvalues, and the order of the */ /* related secular equation. 0 <= K <=N. */ /* N (input) INTEGER */ /* The dimension of the diagonal matrix. N >= 0. */ /* N1 (input) INTEGER */ /* The location of the last eigenvalue in the leading sub-matrix. */ /* min(1,N) <= N1 <= max(1,N). */ /* D (input/output) DOUBLE PRECISION array, dimension (N) */ /* On entry, D contains the eigenvalues of the two submatrices to */ /* be combined. */ /* On exit, D contains the trailing (N-K) updated eigenvalues */ /* (those which were deflated) sorted into increasing order. */ /* Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N) */ /* On entry, Q contains the eigenvectors of two submatrices in */ /* the two square blocks with corners at (1,1), (N1,N1) */ /* and (N1+1, N1+1), (N,N). */ /* On exit, Q contains the trailing (N-K) updated eigenvectors */ /* (those which were deflated) in its last N-K columns. */ /* LDQ (input) INTEGER */ /* The leading dimension of the array Q. LDQ >= max(1,N). */ /* INDXQ (input/output) INTEGER array, dimension (N) */ /* The permutation which separately sorts the two sub-problems */ /* in D into ascending order. Note that elements in the second */ /* half of this permutation must first have N1 added to their */ /* values. Destroyed on exit. */ /* RHO (input/output) DOUBLE PRECISION */ /* On entry, the off-diagonal element associated with the rank-1 */ /* cut which originally split the two submatrices which are now */ /* being recombined. */ /* On exit, RHO has been modified to the value required by */ /* DLAED3M (made positive and multiplied by two, such that */ /* the modification vector has norm one). */ /* Z (input/output) DOUBLE PRECISION array, dimension (N) */ /* On entry, Z contains the updating vector. */ /* On exit, the contents of Z has been destroyed by the updating */ /* process. */ /* DLAMDA (output) DOUBLE PRECISION array, dimension (N) */ /* A copy of the first K non-deflated eigenvalues which */ /* will be used by DLAED3M to form the secular equation. */ /* W (output) DOUBLE PRECISION array, dimension (N) */ /* The first K values of the final deflation-altered z-vector */ /* which will be passed to DLAED3M. */ /* Q2 (output) DOUBLE PRECISION array, dimension */ /* ( N*N ) (if everything is deflated) or */ /* ( N1*(COLTYP(1)+COLTYP(2)) + (N-N1)*(COLTYP(2)+COLTYP(3)) ) */ /* (if not everything is deflated) */ /* If everything is deflated, then N*N intermediate workspace */ /* is needed in Q2. */ /* If not everything is deflated, Q2 contains on exit a copy of the */ /* first K non-deflated eigenvectors which will be used by */ /* DLAED3M in a matrix multiply (DGEMM) to accumulate the new */ /* eigenvectors, followed by the N-K deflated eigenvectors. */ /* INDX (workspace) INTEGER array, dimension (N) */ /* The permutation used to sort the contents of DLAMDA into */ /* ascending order. */ /* INDXC (output) INTEGER array, dimension (N) */ /* The permutation used to arrange the columns of the deflated */ /* Q matrix into three groups: columns in the first group contain */ /* non-zero elements only at and above N1 (type 1), columns in the */ /* second group are dense (type 2), and columns in the third group */ /* contain non-zero elements only below N1 (type 3). */ /* INDXP (workspace) INTEGER array, dimension (N) */ /* The permutation used to place deflated values of D at the end */ /* of the array. INDXP(1:K) points to the nondeflated D-values */ /* and INDXP(K+1:N) points to the deflated eigenvalues. */ /* COLTYP (workspace/output) INTEGER array, dimension (N) */ /* During execution, a label which will indicate which of the */ /* following types a column in the Q2 matrix is: */ /* 1 : non-zero in the upper half only; */ /* 2 : dense; */ /* 3 : non-zero in the lower half only; */ /* 4 : deflated. */ /* On exit, COLTYP(i) is the number of columns of type i, */ /* for i=1 to 4 only. */ /* RELTOL (input) DOUBLE PRECISION */ /* User specified deflation tolerance. If RELTOL.LT.20*EPS, then */ /* the standard value used in the original LAPACK routines is used. */ /* DZ (output) INTEGER, DZ.GE.0 */ /* counts the deflation due to a small component in the modification */ /* vector. */ /* DE (output) INTEGER, DE.GE.0 */ /* counts the deflation due to close eigenvalues. */ /* INFO (output) INTEGER */ /* = 0: successful exit. */ /* < 0: if INFO = -i, the i-th argument had an illegal value. */ /* Further Details */ /* =============== */ /* Based on code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* Based on the design of the LAPACK code DLAED2 with modifications */ /* to allow a block divide and conquer scheme */ /* DLAED2 was written by Jeff Rutter, Computer Science Division, University */ /* of California at Berkeley, USA, and modified by Francoise Tisseur, */ /* University of Tennessee. */ /* ===================================================================== */ #if defined(SLEPC_MISSING_LAPACK_LAMRG) || defined(SLEPC_MISSING_LAPACK_LACPY) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAMRG/LACPY - Lapack routine is unavailable"); #else PetscReal c, s, t, eps, tau, tol, dmax, dmone = -1.; PetscBLASInt i, j, i1, k2, n2, ct, nj, pj=0, js, iq1, iq2; PetscBLASInt psm[4], imax, jmax, ctot[4], factmp=1, one=1; PetscFunctionBegin; *info = 0; if (n < 0) { *info = -2; } else if (n1 < PetscMin(1,n) || n1 > PetscMax(1,n)) { *info = -3; } else if (ldq < PetscMax(1,n)) { *info = -6; } if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DSRTDF",-(*info)); /* Initialize deflation counters */ *dz = 0; *de = 0; /* **************************************************************************** */ /* Quick return if possible */ if (n == 0) PetscFunctionReturn(0); /* **************************************************************************** */ n2 = n - n1; /* Modify Z so that RHO is positive. */ if (*rho < 0.) { PetscStackCallBLAS("BLASscal",BLASscal_(&n2, &dmone, &z[n1], &one)); } /* Normalize z so that norm2(z) = 1. Since z is the concatenation of */ /* two normalized vectors, norm2(z) = sqrt(2). (NOTE that this holds also */ /* here in the approximate block-tridiagonal D&C because the two vectors are */ /* singular vectors, but it would not necessarily hold in a D&C for a */ /* general banded matrix !) */ t = 1. / PetscSqrtReal(2.); PetscStackCallBLAS("BLASscal",BLASscal_(&n, &t, z, &one)); /* NOTE: at this point the value of RHO is modified in order to */ /* normalize Z: RHO = ABS( norm2(z)**2 * RHO */ /* in our case: norm2(z) = sqrt(2), and therefore: */ *rho = PetscAbs(*rho * 2.); /* Sort the eigenvalues into increasing order */ for (i = n1; i < n; ++i) indxq[i] += n1; /* re-integrate the deflated parts from the last pass */ for (i = 0; i < n; ++i) dlamda[i] = d[indxq[i]-1]; PetscStackCallBLAS("LAPACKlamrg",LAPACKlamrg_(&n1, &n2, dlamda, &one, &one, indxc)); for (i = 0; i < n; ++i) indx[i] = indxq[indxc[i]-1]; for (i = 0; i < n; ++i) indxq[i] = 0; /* Calculate the allowable deflation tolerance */ /* imax = BLASamax_(&n, z, &one); */ imax = 1; dmax = PetscAbsReal(z[0]); for (i=1;idmax) { imax = i+1; dmax = PetscAbsReal(z[i]); } } /* jmax = BLASamax_(&n, d, &one); */ jmax = 1; dmax = PetscAbsReal(d[0]); for (i=1;idmax) { jmax = i+1; dmax = PetscAbsReal(d[i]); } } eps = LAPACKlamch_("Epsilon"); if (reltol < eps * 20) { /* use the standard deflation tolerance from the original LAPACK code */ tol = eps * 8. * PetscMax(PetscAbs(d[jmax-1]),PetscAbs(z[imax-1])); } else { /* otherwise set TOL to the input parameter RELTOL ! */ tol = reltol * PetscMax(PetscAbs(d[jmax-1]),PetscAbs(z[imax-1])); } /* If the rank-1 modifier is small enough, no more needs to be done */ /* except to reorganize Q so that its columns correspond with the */ /* elements in D. */ if (*rho * PetscAbs(z[imax-1]) <= tol) { /* complete deflation because of small rank-one modifier */ /* NOTE: in this case we need N*N space in the array Q2 ! */ *dz = n; *k = 0; iq2 = 1; for (j = 0; j < n; ++j) { i = indx[j]; indxq[j] = i; PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, &q[(i-1)*ldq], &one, &q2[iq2-1], &one)); dlamda[j] = d[i-1]; iq2 += n; } PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n, &n, q2, &n, q, &ldq)); PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, dlamda, &one, d, &one)); PetscFunctionReturn(0); } /* If there are multiple eigenvalues then the problem deflates. Here */ /* the number of equal eigenvalues is found. As each equal */ /* eigenvalue is found, an elementary reflector is computed to rotate */ /* the corresponding eigensubspace so that the corresponding */ /* components of Z are zero in this new basis. */ /* initialize the column types */ /* first N1 columns are initially (before deflation) of type 1 */ for (i = 0; i < n1; ++i) coltyp[i] = 1; /* columns N1+1 to N are initially (before deflation) of type 3 */ for (i = n1; i < n; ++i) coltyp[i] = 3; *k = 0; k2 = n + 1; for (j = 0; j < n; ++j) { nj = indx[j]-1; if (*rho * PetscAbs(z[nj]) <= tol) { /* Deflate due to small z component. */ ++(*dz); --k2; /* deflated eigenpair, therefore column type 4 */ coltyp[nj] = 4; indxp[k2-1] = nj+1; indxq[k2-1] = nj+1; if (j+1 == n) goto L100; } else { /* not deflated */ pj = nj; goto L80; } } factmp = 1; L80: ++j; nj = indx[j]-1; if (j+1 > n) goto L100; if (*rho * PetscAbs(z[nj]) <= tol) { /* Deflate due to small z component. */ ++(*dz); --k2; coltyp[nj] = 4; indxp[k2-1] = nj+1; indxq[k2-1] = nj+1; } else { /* Check if eigenvalues are close enough to allow deflation. */ s = z[pj]; c = z[nj]; /* Find sqrt(a**2+b**2) without overflow or */ /* destructive underflow. */ tau = LAPACKlapy2_(&c, &s); t = d[nj] - d[pj]; c /= tau; s = -s / tau; if (PetscAbs(t * c * s) <= tol) { /* Deflate due to close eigenvalues. */ ++(*de); z[nj] = tau; z[pj] = 0.; if (coltyp[nj] != coltyp[pj]) coltyp[nj] = 2; /* if deflation happens across the two eigenvector blocks */ /* (eigenvalues corresponding to different blocks), then */ /* on column in the eigenvector matrix fills up completely */ /* (changes from type 1 or 3 to type 2) */ /* eigenpair PJ is deflated, therefore the column type changes */ /* to 4 */ coltyp[pj] = 4; PetscStackCallBLAS("BLASrot",BLASrot_(&n, &q[pj*ldq], &one, &q[nj*ldq], &one, &c, &s)); t = d[pj] * (c * c) + d[nj] * (s * s); d[nj] = d[pj] * (s * s) + d[nj] * (c * c); d[pj] = t; --k2; i = 1; L90: if (k2 + i <= n) { if (d[pj] < d[indxp[k2 + i-1]-1]) { indxp[k2 + i - 2] = indxp[k2 + i - 1]; indxq[k2 + i - 2] = indxq[k2 + i - 1]; indxp[k2 + i - 1] = pj + 1; indxq[k2 + i - 2] = pj + 1; ++i; goto L90; } else { indxp[k2 + i - 2] = pj + 1; indxq[k2 + i - 2] = pj + 1; } } else { indxp[k2 + i - 2] = pj + 1; indxq[k2 + i - 2] = pj + 1; } pj = nj; factmp = -1; } else { /* do not deflate */ ++(*k); dlamda[*k-1] = d[pj]; w[*k-1] = z[pj]; indxp[*k-1] = pj + 1; indxq[*k-1] = pj + 1; factmp = 1; pj = nj; } } goto L80; L100: /* Record the last eigenvalue. */ ++(*k); dlamda[*k-1] = d[pj]; w[*k-1] = z[pj]; indxp[*k-1] = pj+1; indxq[*k-1] = (pj+1) * factmp; /* Count up the total number of the various types of columns, then */ /* form a permutation which positions the four column types into */ /* four uniform groups (although one or more of these groups may be */ /* empty). */ for (j = 0; j < 4; ++j) ctot[j] = 0; for (j = 0; j < n; ++j) { ct = coltyp[j]; ++ctot[ct-1]; } /* PSM(*) = Position in SubMatrix (of types 1 through 4) */ psm[0] = 1; psm[1] = ctot[0] + 1; psm[2] = psm[1] + ctot[1]; psm[3] = psm[2] + ctot[2]; *k = n - ctot[3]; /* Fill out the INDXC array so that the permutation which it induces */ /* will place all type-1 columns first, all type-2 columns next, */ /* then all type-3's, and finally all type-4's. */ for (j = 0; j < n; ++j) { js = indxp[j]; ct = coltyp[js-1]; indx[psm[ct - 1]-1] = js; indxc[psm[ct - 1]-1] = j+1; ++psm[ct - 1]; } /* Sort the eigenvalues and corresponding eigenvectors into DLAMDA */ /* and Q2 respectively. The eigenvalues/vectors which were not */ /* deflated go into the first K slots of DLAMDA and Q2 respectively, */ /* while those which were deflated go into the last N - K slots. */ i = 0; iq1 = 0; iq2 = (ctot[0] + ctot[1]) * n1; for (j = 0; j < ctot[0]; ++j) { js = indx[i]; PetscStackCallBLAS("BLAScopy",BLAScopy_(&n1, &q[(js-1)*ldq], &one, &q2[iq1], &one)); z[i] = d[js-1]; ++i; iq1 += n1; } for (j = 0; j < ctot[1]; ++j) { js = indx[i]; PetscStackCallBLAS("BLAScopy",BLAScopy_(&n1, &q[(js-1)*ldq], &one, &q2[iq1], &one)); PetscStackCallBLAS("BLAScopy",BLAScopy_(&n2, &q[n1+(js-1)*ldq], &one, &q2[iq2], &one)); z[i] = d[js-1]; ++i; iq1 += n1; iq2 += n2; } for (j = 0; j < ctot[2]; ++j) { js = indx[i]; PetscStackCallBLAS("BLAScopy",BLAScopy_(&n2, &q[n1+(js-1)*ldq], &one, &q2[iq2], &one)); z[i] = d[js-1]; ++i; iq2 += n2; } iq1 = iq2; for (j = 0; j < ctot[3]; ++j) { js = indx[i]; PetscStackCallBLAS("BLAScopy",BLAScopy_(&n, &q[(js-1)*ldq], &one, &q2[iq2], &one)); iq2 += n; z[i] = d[js-1]; ++i; } /* The deflated eigenvalues and their corresponding vectors go back */ /* into the last N - K slots of D and Q respectively. */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n, &ctot[3], &q2[iq1], &n, &q[*k*ldq], &ldq)); i1 = n - *k; PetscStackCallBLAS("BLAScopy",BLAScopy_(&i1, &z[*k], &one, &d[*k], &one)); /* Copy CTOT into COLTYP for referencing in DLAED3M. */ for (j = 0; j < 4; ++j) coltyp[j] = ctot[j]; PetscFunctionReturn(0); #endif } slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dsbtdc.c0000644000175000017500000007030513107004621021677 0ustar jromanjroman/* BDC - Block-divide and conquer (see description in README file). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include PetscErrorCode BDC_dsbtdc_(const char *jobz,const char *jobacc,PetscBLASInt n, PetscBLASInt nblks,PetscBLASInt *ksizes,PetscReal *d,PetscBLASInt l1d, PetscBLASInt l2d,PetscReal *e,PetscBLASInt l1e,PetscBLASInt l2e,PetscReal tol, PetscReal tau1,PetscReal tau2,PetscReal *ev,PetscReal *z,PetscBLASInt ldz, PetscReal *work,PetscBLASInt lwork,PetscBLASInt *iwork,PetscBLASInt liwork, PetscReal *mingap,PetscBLASInt *mingapi,PetscBLASInt *info, PetscBLASInt jobz_len,PetscBLASInt jobacc_len) { /* -- Routine written in LAPACK Version 3.0 style -- */ /* *************************************************** */ /* Written by */ /* Michael Moldaschl and Wilfried Gansterer */ /* University of Vienna */ /* last modification: March 28, 2014 */ /* Small adaptations of original code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* see http://dx.doi.org/10.1137/S1064827501399432 */ /* *************************************************** */ /* Purpose */ /* ======= */ /* DSBTDC computes approximations to all eigenvalues and eigenvectors */ /* of a symmetric block tridiagonal matrix using the divide and */ /* conquer method with lower rank approximations to the subdiagonal blocks. */ /* This code makes very mild assumptions about floating point */ /* arithmetic. It will work on machines with a guard digit in */ /* add/subtract, or on those binary machines without guard digits */ /* which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */ /* It could conceivably fail on hexadecimal or decimal machines */ /* without guard digits, but we know of none. See DLAED3M for details. */ /* Arguments */ /* ========= */ /* JOBZ (input) CHARACTER*1 */ /* = 'N': Compute eigenvalues only (not implemented); */ /* = 'D': Compute eigenvalues and eigenvectors. Eigenvectors */ /* are accumulated in the divide-and-conquer process. */ /* JOBACC (input) CHARACTER*1 */ /* = 'A' ("automatic"): The accuracy parameters TAU1 and TAU2 */ /* are determined automatically from the */ /* parameter TOL according to the analytical */ /* bounds. In that case the input values of */ /* TAU1 and TAU2 are irrelevant (ignored). */ /* = 'M' ("manual"): The input values of the accuracy parameters */ /* TAU1 and TAU2 are used. In that case the input */ /* value of the parameter TOL is irrelevant */ /* (ignored). */ /* N (input) INTEGER */ /* The dimension of the symmetric block tridiagonal matrix. */ /* N >= 1. */ /* NBLKS (input) INTEGER, 1 <= NBLKS <= N */ /* The number of diagonal blocks in the matrix. */ /* KSIZES (input) INTEGER array, dimension (NBLKS) */ /* The dimensions of the square diagonal blocks from top left */ /* to bottom right. KSIZES(I) >= 1 for all I, and the sum of */ /* KSIZES(I) for I = 1 to NBLKS has to be equal to N. */ /* D (input) DOUBLE PRECISION array, dimension (L1D,L2D,NBLKS) */ /* The lower triangular elements of the symmetric diagonal */ /* blocks of the block tridiagonal matrix. The elements of the top */ /* left diagonal block, which is of dimension KSIZES(1), have to */ /* be placed in D(*,*,1); the elements of the next diagonal */ /* block, which is of dimension KSIZES(2), have to be placed in */ /* D(*,*,2); etc. */ /* L1D (input) INTEGER */ /* The leading dimension of the array D. L1D >= max(3,KMAX), */ /* where KMAX is the dimension of the largest diagonal block, */ /* i.e., KMAX = max_I ( KSIZES(I) ). */ /* L2D (input) INTEGER */ /* The second dimension of the array D. L2D >= max(3,KMAX), */ /* where KMAX is as stated in L1D above. */ /* E (input) DOUBLE PRECISION array, dimension (L1E,L2E,NBLKS-1) */ /* The elements of the subdiagonal blocks of the */ /* block tridiagonal matrix. The elements of the top left */ /* subdiagonal block, which is KSIZES(2) x KSIZES(1), have to be */ /* placed in E(*,*,1); the elements of the next subdiagonal block, */ /* which is KSIZES(3) x KSIZES(2), have to be placed in E(*,*,2); etc. */ /* During runtime, the original contents of E(*,*,K) is */ /* overwritten by the singular vectors and singular values of */ /* the lower rank representation. */ /* L1E (input) INTEGER */ /* The leading dimension of the array E. L1E >= max(3,2*KMAX+1), */ /* where KMAX is as stated in L1D above. The size of L1E enables */ /* the storage of ALL singular vectors and singular values for */ /* the corresponding off-diagonal block in E(*,*,K) and therefore */ /* there are no restrictions on the rank of the approximation */ /* (only the "natural" restriction */ /* RANK( K ) .LE. MIN( KSIZES( K ),KSIZES( K+1 ) )). */ /* L2E (input) INTEGER */ /* The second dimension of the array E. L2E >= max(3,2*KMAX+1), */ /* where KMAX is as stated in L1D above. The size of L2E enables */ /* the storage of ALL singular vectors and singular values for */ /* the corresponding off-diagonal block in E(*,*,K) and therefore */ /* there are no restrictions on the rank of the approximation */ /* (only the "natural" restriction */ /* RANK( K ) .LE. MIN( KSIZES( K ),KSIZES( K+1 ) )). */ /* TOL (input) DOUBLE PRECISION, TOL.LE.TOLMAX */ /* User specified tolerance for the residuals of the computed */ /* eigenpairs. If ( JOBACC.EQ.'A' ) then it is used to determine */ /* TAU1 and TAU2; ignored otherwise. */ /* If ( TOL.LT.40*EPS .AND. JOBACC.EQ.'A' ) then TAU1 is set to machine */ /* epsilon and TAU2 is set to the standard deflation tolerance from */ /* LAPACK. */ /* TAU1 (input) DOUBLE PRECISION, TAU1.LE.TOLMAX/2 */ /* User specified tolerance for determining the rank of the */ /* lower rank approximations to the off-diagonal blocks. */ /* The rank for each off-diagonal block is determined such that */ /* the resulting absolute eigenvalue error is less than or equal */ /* to TAU1. */ /* If ( JOBACC.EQ.'A' ) then TAU1 is determined automatically from */ /* TOL and the input value is ignored. */ /* If ( JOBACC.EQ.'M' .AND. TAU1.LT.20*EPS ) then TAU1 is set to */ /* machine epsilon. */ /* TAU2 (input) DOUBLE PRECISION, TAU2.LE.TOLMAX/2 */ /* User specified deflation tolerance for the routine DIBTDC. */ /* If ( 1.0D-1.GT.TAU2.GT.20*EPS ) then TAU2 is used as */ /* the deflation tolerance in DSRTDF (EPS is the machine epsilon). */ /* If ( TAU2.LE.20*EPS ) then the standard deflation tolerance from */ /* LAPACK is used as the deflation tolerance in DSRTDF. */ /* If ( JOBACC.EQ.'A' ) then TAU2 is determined automatically from */ /* TOL and the input value is ignored. */ /* If ( JOBACC.EQ.'M' .AND. TAU2.LT.20*EPS ) then TAU2 is set to */ /* the standard deflation tolerance from LAPACK. */ /* EV (output) DOUBLE PRECISION array, dimension (N) */ /* If INFO = 0, then EV contains the computed eigenvalues of the */ /* symmetric block tridiagonal matrix in ascending order. */ /* Z (output) DOUBLE PRECISION array, dimension (LDZ,N) */ /* If ( JOBZ.EQ.'D' .AND. INFO = 0 ) */ /* then Z contains the orthonormal eigenvectors of the symmetric */ /* block tridiagonal matrix computed by the routine DIBTDC */ /* (accumulated in the divide-and-conquer process). */ /* If ( -199 < INFO < -99 ) then Z contains the orthonormal */ /* eigenvectors of the symmetric block tridiagonal matrix, */ /* computed without divide-and-conquer (quick returns). */ /* Otherwise not referenced. */ /* LDZ (input) INTEGER */ /* The leading dimension of the array Z. LDZ >= max(1,N). */ /* WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK) */ /* LWORK (input) INTEGER */ /* The dimension of the array WORK. */ /* If NBLKS.EQ.1, then LWORK has to be at least 2N^2+6N+1 */ /* (for the call of DSYEVD). */ /* If NBLKS.GE.2 and ( JOBZ.EQ.'D' ) then the absolute minimum */ /* required for DIBTDC is ( N**2 + 3*N ). This will not always */ /* suffice, though, the routine will return a corresponding */ /* error code and report how much work space was missing (see */ /* INFO). */ /* In order to guarantee correct results in all cases where */ /* NBLKS.GE.2, LWORK must be at least ( 2*N**2 + 3*N ). */ /* IWORK (workspace/output) INTEGER array, dimension (LIWORK) */ /* LIWORK (input) INTEGER */ /* The dimension of the array IWORK. */ /* LIWORK must be at least ( 5*N + 5*NBLKS - 1 ) (for DIBTDC) */ /* Note that this should also suffice for the call of DSYEVD on a */ /* diagonal block which requires ( 5*KMAX + 3 ). */ /* MINGAP (output) DOUBLE PRECISION */ /* The minimum "gap" between the approximate eigenvalues */ /* computed, i.e., MIN( ABS( EV( I+1 )-EV( I ) ) for I=1,2,..., N-1 */ /* IF ( MINGAP.LE.TOL/10 ) THEN a warning flag is returned in INFO, */ /* because the computed eigenvectors may be unreliable individually */ /* (only the subspaces spanned are approximated reliably). */ /* MINGAPI (output) INTEGER */ /* Index I where the minimum gap in the spectrum occurred. */ /* INFO (output) INTEGER */ /* = 0: successful exit, no special cases occurred. */ /* < -200: not enough workspace. Space for ABS(INFO + 200) */ /* numbers is required in addition to the workspace provided, */ /* otherwise some of the computed eigenvectors will be incorrect. */ /* < -99, > -199: successful exit, but quick returns. */ /* if INFO = -100, successful exit, but the input matrix */ /* was the zero matrix and no */ /* divide-and-conquer was performed */ /* if INFO = -101, successful exit, but N was 1 and no */ /* divide-and-conquer was performed */ /* if INFO = -102, successful exit, but only a single */ /* dense block. Standard dense solver */ /* was called, no divide-and-conquer was */ /* performed */ /* if INFO = -103, successful exit, but warning that */ /* MINGAP.LE.TOL/10 and therefore the */ /* eigenvectors corresponding to close */ /* approximate eigenvalues may individually */ /* be unreliable (although taken together they */ /* do approximate the corresponding subspace to */ /* the desired accuracy) */ /* = -99: error in the preprocessing in DIBTDC (when determining */ /* the merging order). */ /* < 0, > -99: illegal arguments. */ /* if INFO = -i, the i-th argument had an illegal value. */ /* > 0: The algorithm failed to compute an eigenvalue while */ /* working on the submatrix lying in rows and columns */ /* INFO/(N+1) through mod(INFO,N+1). */ /* Further Details */ /* =============== */ /* Small modifications of code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* see http://dx.doi.org/10.1137/S1064827501399432 */ /* Based on the design of the LAPACK code sstedc.f written by Jeff */ /* Rutter, Computer Science Division, University of California at */ /* Berkeley, and modified by Francoise Tisseur, University of Tennessee. */ /* ===================================================================== */ /* .. Parameters .. */ #define TOLMAX 0.1 /* TOLMAX .... upper bound for tolerances TOL, TAU1, TAU2 */ /* NOTE: in the routine DIBTDC, the value */ /* 1.D-1 is hardcoded for TOLMAX ! */ #if defined(SLEPC_MISSING_LAPACK_SYEVD) || defined(PETSC_MISSING_LAPACK_GESVD) || defined(SLEPC_MISSING_LAPACK_LASET) || defined(SLEPC_MISSING_LAPACK_LASCL) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"SYEVD/GESVD/LASET/LASCL - Lapack routine is unavailable"); #else PetscBLASInt i, j, k, i1, iwspc, lwmin, start; PetscBLASInt ii, ip, jp, nk, rk, np, iu, rp1, ldu; PetscBLASInt ksk, ivt, iend, kchk, kmax, one=1, zero=0; PetscBLASInt ldvt, ksum, kskp1, spneed, nrblks, liwmin, isvals; PetscReal p, d2, eps, dmax, emax, done = 1.0, dzero = 0.0; PetscReal dnrm, tiny, anorm, exdnrm=0, dropsv, absdiff; PetscErrorCode ierr; PetscFunctionBegin; /* Determine machine epsilon. */ eps = LAPACKlamch_("Epsilon"); *info = 0; if (*(unsigned char *)jobz != 'N' && *(unsigned char *)jobz != 'D') { *info = -1; } else if (*(unsigned char *)jobacc != 'A' && *(unsigned char *)jobacc != 'M') { *info = -2; } else if (n < 1) { *info = -3; } else if (nblks < 1 || nblks > n) { *info = -4; } if (*info == 0) { ksum = 0; kmax = 0; kchk = 0; for (k = 0; k < nblks; ++k) { ksk = ksizes[k]; ksum += ksk; if (ksk > kmax) kmax = ksk; if (ksk < 1) kchk = 1; } if (nblks == 1) lwmin = 2*n*n + n*6 + 1; else lwmin = n*n + n*3; liwmin = n * 5 + nblks * 5 - 4; if (ksum != n || kchk == 1) { *info = -5; } else if (l1d < PetscMax(3,kmax)) { *info = -7; } else if (l2d < PetscMax(3,kmax)) { *info = -8; } else if (l1e < PetscMax(3,2*kmax+1)) { *info = -10; } else if (l2e < PetscMax(3,2*kmax+1)) { *info = -11; } else if (*(unsigned char *)jobacc == 'A' && tol > TOLMAX) { *info = -12; } else if (*(unsigned char *)jobacc == 'M' && tau1 > TOLMAX/2) { *info = -13; } else if (*(unsigned char *)jobacc == 'M' && tau2 > TOLMAX/2) { *info = -14; } else if (ldz < PetscMax(1,n)) { *info = -17; } else if (lwork < lwmin) { *info = -19; } else if (liwork < liwmin) { *info = -21; } } if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DSBTDC",-(*info)); /* Quick return if possible */ if (n == 1) { ev[0] = d[0]; z[0] = 1.; *info = -101; PetscFunctionReturn(0); } /* If NBLKS is equal to 1, then solve the problem with standard */ /* dense solver (in this case KSIZES(1) = N). */ if (nblks == 1) { ierr = PetscPrintf(PETSC_COMM_WORLD," dsbtdc: This branch still needs to be checked!\n");CHKERRQ(ierr); for (i = 0; i < n; ++i) { for (j = 0; j <= i; ++j) { z[i + j*ldz] = d[i + j*l1d]; } } PetscStackCallBLAS("LAPACKsyevd",LAPACKsyevd_("V", "L", &n, z, &ldz, ev, work, &lwork, iwork, &liwork, info)); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DSYEVD, info = %d",*info); *info = -102; PetscFunctionReturn(0); } /* determine the accuracy parameters (if requested) */ if (*(unsigned char *)jobacc == 'A') { tau1 = tol / 2; if (tau1 < eps * 20) tau1 = eps; tau2 = tol / 2; } /* Initialize Z as the identity matrix */ if (*(unsigned char *)jobz == 'D') { PetscStackCallBLAS("LAPACKlaset",LAPACKlaset_("Full", &n, &n, &dzero, &done, z, &ldz)); } /* Determine the off-diagonal ranks, form and store the lower rank */ /* approximations based on the tolerance parameters, the */ /* RANK( K ) largest singular values and the associated singular */ /* vectors of each subdiagonal block. Also find the maximum norm of */ /* the subdiagonal blocks (in EMAX). */ /* Compute SVDs of the subdiagonal blocks.... */ /* EMAX .... maximum norm of the off-diagonal blocks */ emax = 0.; for (k = 0; k < nblks-1; ++k) { ksk = ksizes[k]; kskp1 = ksizes[k+1]; isvals = 0; /* Note that min(KSKP1,KSK).LE.N/2 (equality possible for */ /* NBLKS=2), and therefore storing the singular values requires */ /* at most N/2 entries of the * array WORK. */ iu = isvals + n / 2; ivt = isvals + n / 2; /* Call of DGESVD: The space for U is not referenced, since */ /* JOBU='O' and therefore this portion of the array WORK */ /* is not referenced for U. */ ldu = kskp1; ldvt = PetscMin(kskp1,ksk); iwspc = ivt + n * n / 2; /* Note that the minimum workspace required for this call */ /* of DGESVD is: N/2 for storing the singular values + N**2/2 for */ /* storing V^T + 5*N/2 workspace = N**2/2 + 3*N. */ i1 = lwork - iwspc; PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("O", "S", &kskp1, &ksk, &e[k*l1e*l2e], &l1e, &work[isvals], &work[iu], &ldu, &work[ivt], &ldvt, &work[iwspc], &i1, info)); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DGESVD, info = %d",*info); /* Note that after the return from DGESVD U is stored in */ /* E(*,*,K), and V^{\top} is stored in WORK( IVT, IVT+1, .... ) */ /* determine the ranks RANK() for the approximations */ rk = PetscMin(ksk,kskp1); L8: dropsv = work[isvals - 1 + rk]; if (dropsv * 2. <= tau1) { /* the error caused by dropping singular value RK is */ /* small enough, try to reduce the rank by one more */ --rk; if (rk > 0) goto L8; else iwork[k] = 0; } else { /* the error caused by dropping singular value RK is */ /* too large already, RK is the rank required to achieve the */ /* desired accuracy */ iwork[k] = rk; } /* ************************************************************************** */ /* Store the first RANK( K ) terms of the SVD of the current */ /* off-diagonal block. */ /* NOTE that here it is required that L1E, L2E >= 2*KMAX+1 in order */ /* to have enough space for storing singular vectors and values up */ /* to the full SVD of an off-diagonal block !!!! */ /* u1-u_RANK(K) is already contained in E(:,1:RANK(K),K) (as a */ /* result of the call of DGESVD !), the sigma1-sigmaK are to be */ /* stored in E(1:RANK(K),RANK(K)+1,K), and v1-v_RANK(K) are to be */ /* stored in E(:,RANK(K)+2:2*RANK(K)+1,K) */ rp1 = iwork[k]; for (j = 0; j < iwork[k]; ++j) { /* store sigma_J in E( J,RANK( K )+1,K ) */ e[j + (rp1 + k*l2e)* l1e] = work[isvals + j]; /* update maximum norm of subdiagonal blocks */ if (e[j + (rp1 + k*l2e)*l1e] > emax) { emax = e[j + (rp1 + k*l2e)*l1e]; } /* store v_J in E( :,RANK( K )+1+J,K ) */ /* (note that WORK contains V^{\top} and therefore */ /* we need to read rowwise !) */ for (i = 1; i <= ksk; ++i) { e[i-1 + (rp1+j+1 + k*l2e)*l1e] = work[ivt+j + (i-1)*ldvt]; } } } /* Compute the maximum norm of diagonal blocks and store the norm */ /* of each diagonal block in E(RP1,RP1,K) (after the singular values); */ /* store the norm of the last diagonal block in EXDNRM. */ /* DMAX .... maximum one-norm of the diagonal blocks */ dmax = 0.; for (k = 0; k < nblks; ++k) { rp1 = iwork[k]; /* compute the one-norm of diagonal block K */ dnrm = LAPACKlansy_("1", "L", &ksizes[k], &d[k*l1d*l2d], &l1d, work); if (k+1 == nblks) exdnrm = dnrm; else e[rp1 + (rp1 + k*l2e)*l1e] = dnrm; if (dnrm > dmax) dmax = dnrm; } /* Check for zero matrix. */ if (emax == 0. && dmax == 0.) { for (i = 0; i < n; ++i) ev[i] = 0.; *info = -100; PetscFunctionReturn(0); } /* **************************************************************** */ /* ....Identify irreducible parts of the block tridiagonal matrix */ /* [while ( START <= NBLKS )].... */ start = 0; np = 0; L10: if (start < nblks) { /* Let IEND be the number of the next subdiagonal block such that */ /* its RANK is 0 or IEND = NBLKS if no such subdiagonal exists. */ /* The matrix identified by the elements between the diagonal block START */ /* and the diagonal block IEND constitutes an independent (irreducible) */ /* sub-problem. */ iend = start; L20: if (iend < nblks) { rk = iwork[iend]; /* NOTE: if RANK( IEND ).EQ.0 then decoupling happens due to */ /* reduced accuracy requirements ! (because in this case */ /* we would not merge the corresponding two diagonal blocks) */ /* NOTE: seems like any combination may potentially happen: */ /* (i) RANK = 0 but no decoupling due to small norm of */ /* off-diagonal block (corresponding diagonal blocks */ /* also have small norm) as well as */ /* (ii) RANK > 0 but decoupling due to small norm of */ /* off-diagonal block (corresponding diagonal blocks */ /* have very large norm) */ /* case (i) is ruled out by checking for RANK = 0 above */ /* (we decide to decouple all the time when the rank */ /* of an off-diagonal block is zero, independently of */ /* the norms of the corresponding diagonal blocks. */ if (rk > 0) { /* check for decoupling due to small norm of off-diagonal block */ /* (relative to the norms of the corresponding diagonal blocks) */ if (iend == nblks-2) { d2 = PetscSqrtReal(exdnrm); } else { d2 = PetscSqrtReal(e[iwork[iend+1] + (iwork[iend+1] + (iend+1)*l2e)*l1e]); } /* this definition of TINY is analogous to the definition */ /* in the tridiagonal divide&conquer (dstedc) */ tiny = eps * PetscSqrtReal(e[iwork[iend] + (iwork[iend] + iend*l2e)*l1e])*d2; if (e[(iwork[iend] + iend*l2e)*l1e] > tiny) { /* no decoupling due to small norm of off-diagonal block */ ++iend; goto L20; } } } /* ....(Sub) Problem determined: between diagonal blocks */ /* START and IEND. Compute its size and solve it.... */ nrblks = iend - start + 1; if (nrblks == 1) { /* Isolated problem is a single diagonal block */ nk = ksizes[start]; /* copy this isolated block into Z */ for (i = 0; i < nk; ++i) { ip = np + i + 1; for (j = 0; j <= i; ++j) { jp = np + j + 1; z[ip + jp*ldz] = d[i + (j + start*l2d)*l1d]; } } /* check whether there is enough workspace */ spneed = 2*nk*nk + nk * 6 + 1; if (spneed > lwork) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: not enough workspace for DSYEVD, info = %d",lwork - 200 - spneed); PetscStackCallBLAS("LAPACKsyevd",LAPACKsyevd_("V", "L", &nk, &z[np + np*ldz], &ldz, &ev[np], work, &lwork, &iwork[nblks-1], &liwork, info)); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DSYEVD, info = %d",*info); start = iend + 1; np += nk; /* go to the next irreducible subproblem */ goto L10; } /* ....Isolated problem consists of more than one diagonal block. */ /* Start the divide and conquer algorithm.... */ /* Scale: Divide by the maximum of all norms of diagonal blocks */ /* and singular values of the subdiagonal blocks */ /* ....determine maximum of the norms of all diagonal and subdiagonal */ /* blocks.... */ if (iend == nblks-1) anorm = exdnrm; else anorm = e[iwork[iend] + (iwork[iend] + iend*l2e)*l1e]; for (k = start; k < iend; ++k) { rp1 = iwork[k]; /* norm of diagonal block */ anorm = PetscMax(anorm,e[rp1 + (rp1 + k*l2e)*l1e]); /* singular value of subdiagonal block */ anorm = PetscMax(anorm,e[(rp1 + k*l2e)*l1e]); } nk = 0; for (k = start; k < iend+1; ++k) { ksk = ksizes[k]; nk += ksk; /* scale the diagonal block */ PetscStackCallBLAS("LAPACKlascl",LAPACKlascl_("L", &zero, &zero, &anorm, &done, &ksk, &ksk, &d[k*l2d*l1d], &l1d, info)); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DLASCL, info = %d",*info); /* scale the (approximated) off-diagonal block by dividing its */ /* singular values */ if (k != iend) { /* the last subdiagonal block has index IEND-1 !!!! */ for (i = 0; i < iwork[k]; ++i) { e[i + (iwork[k] + k*l2e)*l1e] /= anorm; } } } /* call the block-tridiagonal divide-and-conquer on the */ /* irreducible subproblem which has been identified */ ierr = BDC_dibtdc_(jobz, nk, nrblks, &ksizes[start], &d[start*l1d*l2d], l1d, l2d, &e[start*l2e*l1e], &iwork[start], l1e, l2e, tau2, &ev[np], &z[np + np*ldz], ldz, work, lwork, &iwork[nblks-1], liwork, info, 1); CHKERRQ(ierr); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DIBTDC, info = %d",*info); /* ************************************************************************** */ /* Scale back the computed eigenvalues. */ PetscStackCallBLAS("LAPACKlascl",LAPACKlascl_("G", &zero, &zero, &done, &anorm, &nk, &one, &ev[np], &nk, info)); if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dsbtdc: Error in DLASCL, info = %d",*info); start = iend + 1; np += nk; /* Go to the next irreducible subproblem. */ goto L10; } /* ....If the problem split any number of times, then the eigenvalues */ /* will not be properly ordered. Here we permute the eigenvalues */ /* (and the associated eigenvectors) across the irreducible parts */ /* into ascending order.... */ /* IF( NRBLKS.LT.NBLKS )THEN */ /* Use Selection Sort to minimize swaps of eigenvectors */ for (ii = 1; ii < n; ++ii) { i = ii; k = i; p = ev[i]; for (j = ii; j < n; ++j) { if (ev[j] < p) { k = j; p = ev[j]; } } if (k != i) { ev[k] = ev[i]; ev[i] = p; PetscStackCallBLAS("BLASswap",BLASswap_(&n, &z[i*ldz], &one, &z[k*ldz], &one)); } } /* ...Compute MINGAP (minimum difference between neighboring eigenvalue */ /* approximations).............................................. */ *mingap = ev[1] - ev[0]; if (*mingap < 0.) SETERRQ2(PETSC_COMM_SELF,1,"dsbtdc: Eigenvalue approximations are not ordered properly. Approximation %d is larger than approximation %d.",1,2); *mingapi = 1; for (i = 2; i < n; ++i) { absdiff = ev[i] - ev[i-1]; if (absdiff < 0.) { SETERRQ2(PETSC_COMM_SELF,1,"dsbtdc: Eigenvalue approximations are not ordered properly. Approximation %d is larger than approximation %d.",i,i+1); } else if (absdiff < *mingap) { *mingap = absdiff; *mingapi = i; } } /* check whether the minimum gap between eigenvalue approximations */ /* may indicate severe inaccuracies in the eigenvector approximations */ if (*mingap <= tol / 10) *info = -103; PetscFunctionReturn(0); #endif } slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dlaed3m.c0000644000175000017500000003124213107004621021742 0ustar jromanjroman/* BDC - Block-divide and conquer (see description in README file). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include PetscErrorCode BDC_dlaed3m_(const char *jobz,const char *defl,PetscBLASInt k,PetscBLASInt n, PetscBLASInt n1,PetscReal *d,PetscReal *q,PetscBLASInt ldq, PetscReal rho,PetscReal *dlamda,PetscReal *q2,PetscBLASInt *indx, PetscBLASInt *ctot,PetscReal *w,PetscReal *s,PetscBLASInt *info, PetscBLASInt jobz_len,PetscBLASInt defl_len) { /* -- Routine written in LAPACK version 3.0 style -- */ /* *************************************************** */ /* Written by */ /* Michael Moldaschl and Wilfried Gansterer */ /* University of Vienna */ /* last modification: March 16, 2014 */ /* Small adaptations of original code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* see http://dx.doi.org/10.1137/S1064827501399432 */ /* *************************************************** */ /* Purpose */ /* ======= */ /* DLAED3M finds the roots of the secular equation, as defined by the */ /* values in D, W, and RHO, between 1 and K. It makes the */ /* appropriate calls to DLAED4 and then updates the eigenvectors by */ /* multiplying the matrix of eigenvectors of the pair of eigensystems */ /* being combined by the matrix of eigenvectors of the K-by-K system */ /* which is solved here. */ /* This code makes very mild assumptions about floating point */ /* arithmetic. It will work on machines with a guard digit in */ /* add/subtract, or on those binary machines without guard digits */ /* which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. */ /* It could conceivably fail on hexadecimal or decimal machines */ /* without guard digits, but we know of none. */ /* Arguments */ /* ========= */ /* JOBZ (input) CHARACTER*1 */ /* = 'N': Do not accumulate eigenvectors (not implemented); */ /* = 'D': Do accumulate eigenvectors in the divide-and-conquer */ /* process. */ /* DEFL (input) CHARACTER*1 */ /* = '0': No deflation happened in DSRTDF */ /* = '1': Some deflation happened in DSRTDF (and therefore some */ /* Givens rotations need to be applied to the computed */ /* eigenvector matrix Q) */ /* K (input) INTEGER */ /* The number of terms in the rational function to be solved by */ /* DLAED4. 0 <= K <= N. */ /* N (input) INTEGER */ /* The number of rows and columns in the Q matrix. */ /* N >= K (deflation may result in N>K). */ /* N1 (input) INTEGER */ /* The location of the last eigenvalue in the leading submatrix. */ /* min(1,N) <= N1 <= max(1,N-1). */ /* D (output) DOUBLE PRECISION array, dimension (N) */ /* D(I) contains the updated eigenvalues for */ /* 1 <= I <= K. */ /* Q (output) DOUBLE PRECISION array, dimension (LDQ,N) */ /* Initially the first K columns are used as workspace. */ /* On output the columns 1 to K contain */ /* the updated eigenvectors. */ /* LDQ (input) INTEGER */ /* The leading dimension of the array Q. LDQ >= max(1,N). */ /* RHO (input) DOUBLE PRECISION */ /* The value of the parameter in the rank one update equation. */ /* RHO >= 0 required. */ /* DLAMDA (input/output) DOUBLE PRECISION array, dimension (K) */ /* The first K elements of this array contain the old roots */ /* of the deflated updating problem. These are the poles */ /* of the secular equation. May be changed on output by */ /* having lowest order bit set to zero on Cray X-MP, Cray Y-MP, */ /* Cray-2, or Cray C-90, as described above. */ /* Q2 (input) DOUBLE PRECISION array, dimension (LDQ2, N) */ /* The first K columns of this matrix contain the non-deflated */ /* eigenvectors for the split problem. */ /* INDX (input) INTEGER array, dimension (N) */ /* The permutation used to arrange the columns of the deflated */ /* Q matrix into three groups (see DLAED2). */ /* The rows of the eigenvectors found by DLAED4 must be likewise */ /* permuted before the matrix multiply can take place. */ /* CTOT (input) INTEGER array, dimension (4) */ /* A count of the total number of the various types of columns */ /* in Q, as described in INDX. The fourth column type is any */ /* column which has been deflated. */ /* W (input/output) DOUBLE PRECISION array, dimension (K) */ /* The first K elements of this array contain the components */ /* of the deflation-adjusted updating vector. Destroyed on */ /* output. */ /* S (workspace) DOUBLE PRECISION array, dimension */ /* ( MAX(CTOT(1)+CTOT(2),CTOT(2)+CTOT(3)) + 1 )*K */ /* Will contain parts of the eigenvectors of the repaired matrix */ /* which will be multiplied by the previously accumulated */ /* eigenvectors to update the system. This array is a major */ /* source of workspace requirements ! */ /* INFO (output) INTEGER */ /* = 0: successful exit. */ /* < 0: if INFO = -i, the i-th argument had an illegal value. */ /* > 0: if INFO = i, eigenpair i was not computed successfully */ /* Further Details */ /* =============== */ /* Based on code written by */ /* Wilfried Gansterer and Bob Ward, */ /* Department of Computer Science, University of Tennessee */ /* Based on the design of the LAPACK code DLAED3 with small modifications */ /* (Note that in contrast to the original DLAED3, this routine */ /* DOES NOT require that N1 <= N/2) */ /* Based on contributions by */ /* Jeff Rutter, Computer Science Division, University of California */ /* at Berkeley, USA */ /* Modified by Francoise Tisseur, University of Tennessee. */ /* ===================================================================== */ #if defined(SLEPC_MISSING_LAPACK_LAED4) || defined(SLEPC_MISSING_LAPACK_LACPY) || defined(SLEPC_MISSING_LAPACK_LASET) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAED4/LACPY/LASET - Lapack routine is unavailable"); #else PetscReal temp, done = 1.0, dzero = 0.0; PetscBLASInt i, j, n2, n12, ii, n23, iq2, i1, one=1; PetscFunctionBegin; *info = 0; if (k < 0) { *info = -3; } else if (n < k) { *info = -4; } else if (n1 < PetscMin(1,n) || n1 > PetscMax(1,n)) { *info = -5; } else if (ldq < PetscMax(1,n)) { *info = -8; } else if (rho < 0.) { *info = -9; } if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DLAED3M",-(*info)); /* Quick return if possible */ if (k == 0) PetscFunctionReturn(0); /* Modify values DLAMDA(i) to make sure all DLAMDA(i)-DLAMDA(j) can */ /* be computed with high relative accuracy (barring over/underflow). */ /* This is a problem on machines without a guard digit in */ /* add/subtract (Cray XMP, Cray YMP, Cray C 90 and Cray 2). */ /* The following code replaces DLAMDA(I) by 2*DLAMDA(I)-DLAMDA(I), */ /* which on any of these machines zeros out the bottommost */ /* bit of DLAMDA(I) if it is 1; this makes the subsequent */ /* subtractions DLAMDA(I)-DLAMDA(J) unproblematic when cancellation */ /* occurs. On binary machines with a guard digit (almost all */ /* machines) it does not change DLAMDA(I) at all. On hexadecimal */ /* and decimal machines with a guard digit, it slightly */ /* changes the bottommost bits of DLAMDA(I). It does not account */ /* for hexadecimal or decimal machines without guard digits */ /* (we know of none). We use a subroutine call to compute */ /* 2*DLAMBDA(I) to prevent optimizing compilers from eliminating */ /* this code. */ for (i = 0; i < k; ++i) { dlamda[i] = LAPACKlamc3_(&dlamda[i], &dlamda[i]) - dlamda[i]; } for (j = 1; j <= k; ++j) { /* ....calling DLAED4 for eigenpair J.... */ PetscStackCallBLAS("LAPACKlaed4",LAPACKlaed4_(&k, &j, dlamda, w, &q[(j-1)*ldq], &rho, &d[j-1], info)); if (*info) SETERRQ3(PETSC_COMM_SELF,1,"Error in dlaed4, info = %d, failed when computing D(%d)=%g",*info,j,d[j-1]); if (j < k) { /* If the zero finder terminated properly, but the computed */ /* eigenvalues are not ordered, issue an error statement */ /* but continue computation. */ if (dlamda[j-1] >= dlamda[j]) SETERRQ2(PETSC_COMM_SELF,1,"DLAMDA(%d) is greater or equal than DLAMDA(%d)", j, j+1); if (d[j-1] < dlamda[j-1] || d[j-1] > dlamda[j]) SETERRQ6(PETSC_COMM_SELF,1,"DLAMDA(%d) = %g D(%d) = %g DLAMDA(%d) = %g", j, dlamda[j-1], j, d[j-1], j+1, dlamda[j]); } } if (k == 1) goto L110; if (k == 2) { /* permute the components of Q(:,J) (the information returned by DLAED4 */ /* necessary to construct the eigenvectors) according to the permutation */ /* stored in INDX, resulting from deflation */ for (j = 0; j < k; ++j) { w[0] = q[0+j*ldq]; w[1] = q[1+j*ldq]; ii = indx[0]; q[0+j*ldq] = w[ii-1]; ii = indx[1]; q[1+j*ldq] = w[ii-1]; } goto L110; } /* ....K.GE.3.... */ /* Compute updated W (used for computing the eigenvectors corresponding */ /* to the previously computed eigenvalues). */ PetscStackCallBLAS("BLAScopy",BLAScopy_(&k, w, &one, s, &one)); /* Initialize W(I) = Q(I,I) */ i1 = ldq + 1; PetscStackCallBLAS("BLAScopy",BLAScopy_(&k, q, &i1, w, &one)); for (j = 0; j < k; ++j) { for (i = 0; i < j; ++i) { w[i] *= q[i+j*ldq] / (dlamda[i] - dlamda[j]); } for (i = j + 1; i < k; ++i) { w[i] *= q[i+j*ldq] / (dlamda[i] - dlamda[j]); } } for (i = 0; i < k; ++i) { temp = PetscSqrtReal(-w[i]); if (temp<0) temp = -temp; w[i] = (s[i] >= 0) ? temp : -temp; } /* Compute eigenvectors of the modified rank-1 modification (using the */ /* vector W). */ for (j = 0; j < k; ++j) { for (i = 0; i < k; ++i) { s[i] = w[i] / q[i+j*ldq]; } temp = BLASnrm2_(&k, s, &one); for (i = 0; i < k; ++i) { /* apply the permutation resulting from deflation as stored */ /* in INDX */ ii = indx[i]; q[i+j*ldq] = s[ii-1] / temp; } } /* ************************************************************************** */ /* ....updating the eigenvectors.... */ L110: n2 = n - n1; n12 = ctot[0] + ctot[1]; n23 = ctot[1] + ctot[2]; if (*(unsigned char *)jobz == 'D') { /* Compute the updated eigenvectors. (NOTE that every call of */ /* DGEMM requires three DISTINCT arrays) */ /* copy Q( CTOT(1)+1:K,1:K ) to S */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n23, &k, &q[ctot[0]], &ldq, s, &n23)); iq2 = n1 * n12 + 1; if (n23 != 0) { /* multiply the second part of Q2 (the eigenvectors of the */ /* lower block) with S and write the result into the lower part of */ /* Q, i.e., Q( N1+1:N,1:K ) */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "N", &n2, &k, &n23, &done, &q2[iq2-1], &n2, s, &n23, &dzero, &q[n1], &ldq)); } else { PetscStackCallBLAS("LAPACKlaset",LAPACKlaset_("A", &n2, &k, &dzero, &dzero, &q[n1], &ldq)); } /* copy Q( 1:CTOT(1)+CTOT(2),1:K ) to S */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("A", &n12, &k, q, &ldq, s, &n12)); if (n12 != 0) { /* multiply the first part of Q2 (the eigenvectors of the */ /* upper block) with S and write the result into the upper part of */ /* Q, i.e., Q( 1:N1,1:K ) */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N", "N", &n1, &k, &n12, &done, q2, &n1, s, &n12, &dzero, q, &ldq)); } else { PetscStackCallBLAS("LAPACKlaset",LAPACKlaset_("A", &n1, &k, &dzero, &dzero, q, &ldq)); } } PetscFunctionReturn(0); #endif } slepc-3.7.4/src/sys/classes/ds/impls/hep/bdc/dmerg2.c.html0000644000175000017500000007424113107004621022562 0ustar jromanjroman

Actual source code: dmerg2.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BDC - Block-divide and conquer (see description in README file).

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/dsimpl.h>
 25: #include <slepcblaslapack.h>

 27: PetscErrorCode BDC_dmerg2_(const char *jobz,PetscBLASInt rkct,PetscBLASInt n, 
 28:         PetscReal *ev,PetscReal *q,PetscBLASInt ldq,PetscBLASInt *indxq, 
 29:         PetscReal *rho,PetscReal *u,PetscBLASInt sbrkp1,PetscReal *v, 
 30:         PetscBLASInt sbrk,PetscBLASInt cutpnt,PetscReal *work,PetscBLASInt lwork, 
 31:         PetscBLASInt *iwork,PetscReal tol,PetscBLASInt *info,PetscBLASInt jobz_len)
 32: {
 33: /*  -- Routine written in LAPACK Version 3.0 style -- */
 34: /* *************************************************** */
 35: /*     Written by */
 36: /*     Michael Moldaschl and Wilfried Gansterer */
 37: /*     University of Vienna */
 38: /*     last modification: March 16, 2014 */

 40: /*     Small adaptations of original code written by */
 41: /*     Wilfried Gansterer and Bob Ward, */
 42: /*     Department of Computer Science, University of Tennessee */
 43: /*     see http://dx.doi.org/10.1137/S1064827501399432 */
 44: /* *************************************************** */

 46: /*  Purpose */
 47: /*  ======= */

 49: /*  DMERG2 computes the updated eigensystem of a diagonal matrix after */
 50: /*  modification by a rank-one symmetric matrix.  The diagonal matrix */
 51: /*  consists of two diagonal submatrices, and the vectors defining the */
 52: /*  rank-1 matrix similarly have two underlying subvectors each. */
 53: /*  The dimension of the first subproblem is CUTPNT, the dimension of */
 54: /*  the second subproblem is N-CUTPNT. */

 56: /*  T = Q(in) ( EV(in) + RHO * Z*Z' ) Q'(in) = Q(out) * EV(out) * Q'(out) */

 58: /*     where Z = Q'[V U']', where V is a row vector and U is a column */
 59: /*     vector with dimensions corresponding to the two underlying */
 60: /*     subproblems. */

 62: /*     The eigenvectors of the original matrix are stored in Q, and the */
 63: /*     eigenvalues in EV.  The algorithm consists of three stages: */

 65: /*        The first stage consists of deflating the size of the problem */
 66: /*        when there are multiple eigenvalues or if there is a zero in */
 67: /*        the Z vector.  For each such occurrence the dimension of the */
 68: /*        secular equation problem is reduced by one.  This stage is */
 69: /*        performed by the routine DSRTDF. */

 71: /*        The second stage consists of calculating the updated */
 72: /*        eigenvalues. This is done by finding the roots of the secular */
 73: /*        equation via the routine DLAED4 (as called by DLAED3M). */
 74: /*        This routine also calculates the eigenvectors of the current */
 75: /*        problem. */

 77: /*        If( JOBZ.EQ.'D' ) then the final stage consists */
 78: /*        of computing the updated eigenvectors directly using the updated */
 79: /*        eigenvalues. The eigenvectors for the current problem are multiplied */
 80: /*        with the eigenvectors from the overall problem. */

 82: /*  Arguments */
 83: /*  ========= */

 85: /*  JOBZ   (input) CHARACTER*1 */
 86: /*          = 'N': Compute eigenvalues only (not implemented); */
 87: /*          = 'D': Compute eigenvalues and eigenvectors. */
 88: /*                 Eigenvectors are accumulated in the divide-and-conquer */
 89: /*                 process. */

 91: /*  RKCT   (input) INTEGER */
 92: /*         The number of the rank modification which is accounted for */
 93: /*         (RKCT >= 1). Required parameter, because the update operation of the */
 94: /*         modification vector can be performed much more efficiently */
 95: /*         if RKCT.EQ.1. In that case, the eigenvector matrix is still */
 96: /*         block-diagonal. For RKCT.GE.2 the eigenvector matrix for the update */
 97: /*         operation has filled up and is a full matrix. */

 99: /*  N      (input) INTEGER */
100: /*         The dimension of the symmetric block tridiagonal matrix. */
101: /*         N >= 0. */

103: /*  EV     (input/output) DOUBLE PRECISION array, dimension (N) */
104: /*         On entry, the eigenvalues (=diagonal values) of the */
105: /*         rank-1-perturbed matrix. */
106: /*         On exit, the eigenvalues of the repaired matrix. */

108: /*  Q      (input/output) DOUBLE PRECISION array, dimension (LDQ,N) */
109: /*         On entry, the eigenvectors of the rank-1-perturbed matrix. */
110: /*         On exit, the eigenvectors of the repaired tridiagonal matrix. */

112: /*  LDQ    (input) INTEGER */
113: /*         The leading dimension of the array Q.  LDQ >= max(1,N). */

115: /*  INDXQ  (input/output) INTEGER array, dimension (N) */
116: /*         On entry, the permutation which separately sorts the two */
117: /*         subproblems in EV into ascending order. */
118: /*         On exit, the permutation which will reintegrate the */
119: /*         subproblems back into sorted order, */
120: /*         i.e. EV( INDXQ( I = 1, N ) ) will be in ascending order. */

122: /*  RHO    (input/output) DOUBLE PRECISION */
123: /*         The scalar in the rank-1 perturbation. Modified (multiplied */
124: /*         by 2) in DSRTDF. */

126: /*  U      (input) DOUBLE PRECISION array; dimension (SBRKP1), where SBRKP1 */
127: /*         is the size of the first (original) block after CUTPNT. */
128: /*         The column vector of the rank-1 subdiagonal connecting the */
129: /*         two diagonal subproblems. */
130: /*         Theoretically, zero entries might have to be appended after U */
131: /*         in order to make it have dimension (N-CUTPNT). However, this */
132: /*         is not required because it can be accounted for in the */
133: /*         matrix-vector product using the argument SBRKP1. */

135: /*  SBRKP1 (input) INTEGER */
136: /*         Dimension of the relevant (non-zero) part of the vector U. */
137: /*         Equal to the size of the first original block after the */
138: /*         breakpoint. */

140: /*  V      (input) DOUBLE PRECISION array; dimension (SBRK), where SBRK */
141: /*         is the size of the last (original) block before CUTPNT. */
142: /*         The row vector of the rank-1 subdiagonal connecting the two */
143: /*         diagonal subproblems. */
144: /*         Theoretically, zero entries might have to be inserted in front */
145: /*         of V in order to make it have dimension (CUTPNT). However, this */
146: /*         is not required because it can be accounted for in the */
147: /*         matrix-vector product using the argument SBRK. */

149: /*  SBRK   (input) INTEGER */
150: /*         Dimension of the relevant (non-zero) part of the vector V. */
151: /*         Equal to the size of the last original block before the */
152: /*         breakpoint. */

154: /*  CUTPNT (input) INTEGER */
155: /*         The location of the last eigenvalue of the leading diagonal */
156: /*         block.  min(1,N) <= CUTPNT <= max(1,N). */

158: /*  WORK   (workspace) DOUBLE PRECISION array, dimension (LWORK) */

160: /*  LWORK  (input) INTEGER */
161: /*         The dimension of the array WORK. */
162: /*         In order to guarantee correct results in all cases, */
163: /*         LWORK must be at least ( 2*N**2 + 3*N  ). In many cases, */
164: /*         less workspace is required. The absolute minimum required is */
165: /*         ( N**2 + 3*N ). */
166: /*         If the workspace provided is not sufficient, the routine will */
167: /*         return a corresponding error code and report how much workspace */
168: /*         was missing (see INFO). */
169: /*         NOTE: This parameter is needed for determining whether enough */
170: /*               workspace is provided, and, if not, for computing how */
171: /*               much workspace is needed. */

173: /*  IWORK  (workspace) INTEGER array, dimension ( 4*N ) */

175: /*  TOL    (input) DOUBLE PRECISION */
176: /*         User specified deflation tolerance for the routine DSRTDF. */

178: /*  INFO   (output) INTEGER */
179: /*          = 0:  successful exit. */
180: /*          < -200: not enough workspace */
181: /*                ABS(INFO + 200) numbers have to be stored in addition */
182: /*                to the workspace provided, otherwise some eigenvectors */
183: /*                will be incorrect. */
184: /*          < 0, > -99:  if INFO.EQ.-i, the i-th argument had an */
185: /*                       illegal value. */
186: /*          > 0:  if INFO.EQ.1, an eigenvalue did not converge */
187: /*                if INFO.EQ.2, the deflation counters DZ and DE do not sum */
188: /*                              up to the total number N-K of components */
189: /*                              deflated */

191: /*  Further Details */
192: /*  =============== */

194: /*  Based on code written by */
195: /*     Wilfried Gansterer and Bob Ward, */
196: /*     Department of Computer Science, University of Tennessee */

198: /*  Based on the design of the LAPACK code Dlaed1.f written by Jeff */
199: /*  Rutter, Computer Science Division, University of California at */
200: /*  Berkeley, and modified by Francoise Tisseur, University of Tennessee. */

202: /*  ===================================================================== */

204: #if defined(SLEPC_MISSING_LAPACK_LAMRG)
206:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"LAMRG - Lapack routine is unavailable");
207: #else
208:   PetscBLASInt   i, k, n1, n2, de, is, dz, iw, iz, iq2, nmc, cpp1;
209:   PetscBLASInt   indx, indxc, indxp, lwmin, idlmda;
210:   PetscBLASInt   spneed, coltyp, tmpcut, i__1, i__2, one=1, mone=-1;
211:   char           defl[1];
212:   PetscReal      done = 1.0, dzero = 0.0;

216:   *info = 0;
217:   lwmin = n*n + n * 3;

219:   if (n < 0) {
220:     *info = -3;
221:   } else if (ldq < PetscMax(1,n)) {
222:     *info = -6;
223:   } else if (cutpnt < PetscMin(1,n) || cutpnt > PetscMax(1,n)) {
224:     *info = -13;
225:   } else if (lwork < lwmin) {
226:     *info = -15;
227:   }
228:   if (*info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong argument %d in DMERG2",-(*info));

230: /* **************************************************************************** */

232:   /* Quick return if possible */

234:   if (n == 0) return(0);

236: /* **************************************************************************** */

238:   /* The following values are integer pointers which indicate */
239:   /* the portion of the workspace used by a particular array in DSRTDF */
240:   /* and DLAED3M. */

242:   iz = 0;
243:   idlmda = iz + n;
244:   iw = idlmda + n;
245:   iq2 = iw + n;
246:   is = iq2 + n * n;

248:   /* After the pointer IS the matrix S is stored and read in WORK */
249:   /* in the routine DLAED3M. */

251:   indx = 0;
252:   indxc = indx + n;
253:   coltyp = indxc + n;
254:   indxp = coltyp + n;

256:   /* If eigenvectors are to be accumulated in the divide-and-conquer */
257:   /* process ( JOBZ.EQ.'D' ) form the z-vector which consists of */
258:   /* Q_1^T * V and Q_2^T * U. */

260:   cpp1 = cutpnt + 1;
261:   if (rkct == 1) {

263:     /* for the first rank modification the eigenvector matrix has */
264:     /* special block-diagonal structure and therefore Q_1^T * V and */
265:     /* Q_2^T * U can be formed separately. */

267:     PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrk, &cutpnt, &done,
268:               &q[cutpnt - sbrk], &ldq, v, &one, &dzero, &work[iz], &one));
269:     nmc = n - cutpnt;
270:     PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrkp1, &nmc, &done,
271:               &q[cpp1-1 + (cpp1-1)*ldq], &ldq, u,
272:               &one, &dzero, &work[iz + cutpnt], &one));

274:   } else {

276:     /* for the higher rank modifications, the vectors V and U */
277:     /* have to be multiplied with the full eigenvector matrix */

279:     PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrk, &n, &done,
280:               &q[cutpnt - sbrk], &ldq, v, &one, &dzero, &work[iz], &one));
281:     PetscStackCallBLAS("BLASgemv",BLASgemv_("T", &sbrkp1, &n, &done, &q[cpp1-1],
282:               &ldq, u, &one, &done, &work[iz], &one));

284:   }

286: /* **************************************************************************** */

288:   /* Deflate eigenvalues. */

290:   if (rkct == 1) {

292:     /* for the first rank modification we need the actual cutpoint */

294:     n1 = cutpnt;
295:     tmpcut = cutpnt;
296:   } else {

298:     /* for the later rank modifications there is no actual cutpoint any more */

300:     n1 = n;

302:     /* The original value of CUTPNT has to be preserved for the next time */
303:     /* this subroutine is called (therefore, CUTPNT is an INPUT parameter */
304:     /* and not to be changed). Thus, assign N to TMPCUT and use the local */
305:     /* variable TMPCUT from now on for the cut point. */

307:     tmpcut = n;
308:   }

310:   /* initialize the flag DEFL (indicates whether deflation occurred - */
311:   /* this information is needed later in DLAED3M) */

313:   *(unsigned char *)defl = '0';

315:   /* call DSRTDF for deflation */

317:   BDC_dsrtdf_(&k, n, n1, ev, q, ldq, indxq, rho, &work[iz],
318:           &work[idlmda], &work[iw], &work[iq2], &iwork[indx],
319:           &iwork[indxc], &iwork[indxp], &iwork[coltyp], tol, &dz, &de, info);
320:           
321:   if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dmerg2: error in dsrtdf, info = %d",*info);

323:   if (k < n) {

325:    /* ....some deflation occurred in dsrtdf, set the flag DEFL */
326:    /*     (needed in DLAED3M.f, since Givens rotations need to be */
327:    /*     applied to the eigenvector matrix only if some deflation */
328:    /*     happened) */

330:     *(unsigned char *)defl = '1';
331:   }

333: /* **************************************************************************** */

335:   /* Solve the Secular Equation. */

337:   if (k != 0 || k == 0) {

339:     /* ....not everything was deflated. */
340:      
341:     /* ....check whether enough workspace is available: */
342:      
343:     /* Note that the following (upper) bound SPNEED for the workspace */
344:     /* requirements should also hold in the extreme case TMPCUT=N, */
345:     /* which happens for every rank modification after the first one. */

347:     i__1 = (iwork[coltyp] + iwork[coltyp+1]) * k;
348:     i__2 = (iwork[coltyp+1] + iwork[coltyp + 2]) * k;
349:     spneed = is + PetscMax(i__1,i__2) - 1;

351:     if (spneed > lwork) SETERRQ1(PETSC_COMM_SELF,1,"dmerg2: Workspace needed exceeds the workspace provided by %d numbers",spneed-lwork);

353:     /* calling DLAED3M for solving the secular equation. */

355:     BDC_dlaed3m_(jobz, defl, k, n, tmpcut, ev, q, ldq, 
356:                 *rho, &work[idlmda], &work[iq2], &iwork[indxc], &iwork[coltyp],
357:                 &work[iw], &work[is], info, 1, 1);
358:     if (*info) SETERRQ1(PETSC_COMM_SELF,1,"dmerg2: error in dlaed3m, info = %d",*info);

360:     /* Prepare the INDXQ sorting permutation. */

362:     n1 = k;
363:     n2 = n - k;
364:     PetscStackCallBLAS("LAPACKlamrg",LAPACKlamrg_(&n1, &n2, ev, &one, &mone, indxq));
365:     if (k == 0) {
366:       for (i = 0; i < n; ++i) indxq[i] = i+1;
367:     }

369:   } else {

371:     /* ....everything was deflated (K.EQ.0) */

373:     for (i = 0; i < n; ++i) indxq[i] = i+1;
374:   }
375:   return(0);
376: #endif
377: }

slepc-3.7.4/src/sys/classes/ds/impls/hep/index.html0000644000175000017500000000221213107004621021525 0ustar jromanjroman Direct Solver (or Dense System) - DS
slepc-3.7.4 2017-05-17

Direct Solver (or Dense System) - DS

The DS package provides auxiliary routines that are internally used by the different SLEPc solvers. It is used to represent low-dimensional eigenproblems that must be solved within iterative solvers with direct methods. It can be seen as a structured wrapper to LAPACK functionality.

These routines are usually not needed by application programmers.

bdc/
dshep.c
makefile
slepc-3.7.4/src/sys/classes/bv/0000755000175000017500000000000013107004621015634 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/makefile0000644000175000017500000000220113107004621017327 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../../../include/slepc/private/bvimpl.h ../../../../include/slepcbv.h DIRS = interface impls examples LOCDIR = src/sys/classes/bv/ MANSEC = BV include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/interface/0000755000175000017500000000000013107004621017574 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/interface/makefile0000644000175000017500000000226013107004621021274 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = bvbasic.c bvfunc.c bvops.c bvglobal.c bvblas.c bvorthog.c bvregis.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = BV LOCDIR = src/sys/classes/bv/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/interface/bvbasic.c0000644000175000017500000013502013107004621021352 0ustar jromanjroman/* Basic BV routines. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcbv.h" I*/ PetscBool BVRegisterAllCalled = PETSC_FALSE; PetscFunctionList BVList = 0; #undef __FUNCT__ #define __FUNCT__ "BVSetType" /*@C BVSetType - Selects the type for the BV object. Logically Collective on BV Input Parameter: + bv - the basis vectors context - type - a known type Options Database Key: . -bv_type - Sets BV type Level: intermediate .seealso: BVGetType() @*/ PetscErrorCode BVSetType(BV bv,BVType type) { PetscErrorCode ierr,(*r)(BV); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)bv,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(BVList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested BV type %s",type); if (bv->ops->destroy) { ierr = (*bv->ops->destroy)(bv);CHKERRQ(ierr); } ierr = PetscMemzero(bv->ops,sizeof(struct _BVOps));CHKERRQ(ierr); ierr = PetscObjectChangeTypeName((PetscObject)bv,type);CHKERRQ(ierr); if (bv->n < 0 && bv->N < 0) { bv->ops->create = r; } else { ierr = PetscLogEventBegin(BV_Create,bv,0,0,0);CHKERRQ(ierr); ierr = (*r)(bv);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_Create,bv,0,0,0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetType" /*@C BVGetType - Gets the BV type name (as a string) from the BV context. Not Collective Input Parameter: . bv - the basis vectors context Output Parameter: . name - name of the type of basis vectors Level: intermediate .seealso: BVSetType() @*/ PetscErrorCode BVGetType(BV bv,BVType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)bv)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetSizes" /*@ BVSetSizes - Sets the local and global sizes, and the number of columns. Collective on BV Input Parameters: + bv - the basis vectors . n - the local size (or PETSC_DECIDE to have it set) . N - the global size (or PETSC_DECIDE) - m - the number of columns Notes: n and N cannot be both PETSC_DECIDE. If one processor calls this with N of PETSC_DECIDE then all processors must, otherwise the program will hang. Level: beginner .seealso: BVSetSizesFromVec(), BVGetSizes(), BVResize() @*/ PetscErrorCode BVSetSizes(BV bv,PetscInt n,PetscInt N,PetscInt m) { PetscErrorCode ierr; PetscInt ma; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); if (N >= 0) PetscValidLogicalCollectiveInt(bv,N,3); PetscValidLogicalCollectiveInt(bv,m,4); if (N >= 0 && n > N) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Local size %D cannot be larger than global size %D",n,N); if (m <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Number of columns %D must be positive",m); if ((bv->n >= 0 || bv->N >= 0) && (bv->n != n || bv->N != N)) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot change/reset vector sizes to %D local %D global after previously setting them to %D local %D global",n,N,bv->n,bv->N); if (bv->m > 0 && bv->m != m) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot change the number of columns to %D after previously setting it to %D; use BVResize()",m,bv->m); bv->n = n; bv->N = N; bv->m = m; bv->k = m; if (!bv->t) { /* create template vector and get actual dimensions */ ierr = VecCreate(PetscObjectComm((PetscObject)bv),&bv->t);CHKERRQ(ierr); ierr = VecSetSizes(bv->t,bv->n,bv->N);CHKERRQ(ierr); ierr = VecSetFromOptions(bv->t);CHKERRQ(ierr); ierr = VecGetSize(bv->t,&bv->N);CHKERRQ(ierr); ierr = VecGetLocalSize(bv->t,&bv->n);CHKERRQ(ierr); if (bv->matrix) { /* check compatible dimensions of user-provided matrix */ ierr = MatGetLocalSize(bv->matrix,&ma,NULL);CHKERRQ(ierr); if (bv->n!=ma) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Local dimension %D does not match that of matrix given at BVSetMatrix %D",bv->n,ma); } } if (bv->ops->create) { ierr = PetscLogEventBegin(BV_Create,bv,0,0,0);CHKERRQ(ierr); ierr = (*bv->ops->create)(bv);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_Create,bv,0,0,0);CHKERRQ(ierr); bv->ops->create = 0; bv->defersfo = PETSC_FALSE; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetSizesFromVec" /*@ BVSetSizesFromVec - Sets the local and global sizes, and the number of columns. Local and global sizes are specified indirectly by passing a template vector. Collective on BV Input Parameters: + bv - the basis vectors . t - the template vector - m - the number of columns Level: beginner .seealso: BVSetSizes(), BVGetSizes(), BVResize() @*/ PetscErrorCode BVSetSizesFromVec(BV bv,Vec t,PetscInt m) { PetscErrorCode ierr; PetscInt ma; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidHeaderSpecific(t,VEC_CLASSID,2); PetscCheckSameComm(bv,1,t,2); PetscValidLogicalCollectiveInt(bv,m,3); if (m <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Number of columns %D must be positive",m); if (bv->t) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Template vector was already set by a previous call to BVSetSizes/FromVec"); ierr = VecGetSize(t,&bv->N);CHKERRQ(ierr); ierr = VecGetLocalSize(t,&bv->n);CHKERRQ(ierr); if (bv->matrix) { /* check compatible dimensions of user-provided matrix */ ierr = MatGetLocalSize(bv->matrix,&ma,NULL);CHKERRQ(ierr); if (bv->n!=ma) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Local dimension %D does not match that of matrix given at BVSetMatrix %D",bv->n,ma); } bv->m = m; bv->k = m; bv->t = t; ierr = PetscObjectReference((PetscObject)t);CHKERRQ(ierr); if (bv->ops->create) { ierr = (*bv->ops->create)(bv);CHKERRQ(ierr); bv->ops->create = 0; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetSizes" /*@ BVGetSizes - Returns the local and global sizes, and the number of columns. Not Collective Input Parameter: . bv - the basis vectors Output Parameters: + n - the local size . N - the global size - m - the number of columns Note: Normal usage requires that bv has already been given its sizes, otherwise the call fails. However, this function can also be used to determine if a BV object has been initialized completely (sizes and type). For this, call with n=NULL and N=NULL, then a return value of m=0 indicates that the BV object is not ready for use yet. Level: beginner .seealso: BVSetSizes(), BVSetSizesFromVec() @*/ PetscErrorCode BVGetSizes(BV bv,PetscInt *n,PetscInt *N,PetscInt *m) { PetscFunctionBegin; if (!bv) { if (m && !n && !N) *m = 0; PetscFunctionReturn(0); } PetscValidHeaderSpecific(bv,BV_CLASSID,1); if (n || N) BVCheckSizes(bv,1); if (n) *n = bv->n; if (N) *N = bv->N; if (m) *m = bv->m; if (m && !n && !N && !((PetscObject)bv)->type_name) *m = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetNumConstraints" /*@ BVSetNumConstraints - Set the number of constraints. Logically Collective on BV Input Parameters: + V - basis vectors - nc - number of constraints Notes: This function sets the number of constraints to nc and marks all remaining columns as regular. Normal user would call BVInsertConstraints() instead. If nc is smaller than the previously set value, then some of the constraints are discarded. In particular, using nc=0 removes all constraints preserving the content of regular columns. Level: developer .seealso: BVInsertConstraints() @*/ PetscErrorCode BVSetNumConstraints(BV V,PetscInt nc) { PetscErrorCode ierr; PetscInt total,diff,i; Vec x,y; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidLogicalCollectiveInt(V,nc,2); if (nc<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Number of constraints (given %D) cannot be negative",nc); PetscValidType(V,1); BVCheckSizes(V,1); if (V->ci[0]!=-V->nc-1 || V->ci[1]!=-V->nc-1) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Cannot call BVSetNumConstraints after BVGetColumn"); diff = nc-V->nc; if (!diff) PetscFunctionReturn(0); total = V->nc+V->m; if (total-nc<=0) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Not enough columns for the given nc value"); if (diff<0) { /* lessen constraints, shift contents of BV */ for (i=0;im;i++) { ierr = BVGetColumn(V,i,&x);CHKERRQ(ierr); ierr = BVGetColumn(V,i+diff,&y);CHKERRQ(ierr); ierr = VecCopy(x,y);CHKERRQ(ierr); ierr = BVRestoreColumn(V,i,&x);CHKERRQ(ierr); ierr = BVRestoreColumn(V,i+diff,&y);CHKERRQ(ierr); } } V->nc = nc; V->ci[0] = -V->nc-1; V->ci[1] = -V->nc-1; V->l = 0; V->m = total-nc; V->k = V->m; ierr = PetscObjectStateIncrease((PetscObject)V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetNumConstraints" /*@ BVGetNumConstraints - Returns the number of constraints. Not Collective Input Parameter: . bv - the basis vectors Output Parameters: . nc - the number of constraints Level: advanced .seealso: BVGetSizes(), BVInsertConstraints() @*/ PetscErrorCode BVGetNumConstraints(BV bv,PetscInt *nc) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidPointer(nc,2); *nc = bv->nc; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVResize" /*@ BVResize - Change the number of columns. Collective on BV Input Parameters: + bv - the basis vectors . m - the new number of columns - copy - a flag indicating whether current values should be kept Note: Internal storage is reallocated. If the copy flag is set to true, then the contents are copied to the leading part of the new space. Level: advanced .seealso: BVSetSizes(), BVSetSizesFromVec() @*/ PetscErrorCode BVResize(BV bv,PetscInt m,PetscBool copy) { PetscErrorCode ierr; PetscReal *omega; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,m,2); PetscValidLogicalCollectiveBool(bv,copy,3); PetscValidType(bv,1); if (m <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Number of columns %D must be positive",m); if (bv->nc) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Cannot resize a BV with constraints"); if (bv->m == m) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_Create,bv,0,0,0);CHKERRQ(ierr); ierr = (*bv->ops->resize)(bv,m,copy);CHKERRQ(ierr); ierr = PetscFree2(bv->h,bv->c);CHKERRQ(ierr); if (bv->omega) { ierr = PetscMalloc1(m,&omega);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)bv,m*sizeof(PetscReal));CHKERRQ(ierr); for (i=0;iomega,PetscMin(m,bv->m)*sizeof(PetscReal));CHKERRQ(ierr); } ierr = PetscFree(bv->omega);CHKERRQ(ierr); bv->omega = omega; } bv->m = m; bv->k = PetscMin(bv->k,m); bv->l = PetscMin(bv->l,m); ierr = PetscLogEventEnd(BV_Create,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetActiveColumns" /*@ BVSetActiveColumns - Specify the columns that will be involved in operations. Logically Collective on BV Input Parameters: + bv - the basis vectors context . l - number of leading columns - k - number of active columns Notes: In operations such as BVMult() or BVDot(), only the first k columns are considered. This is useful when the BV is filled from left to right, so the last m-k columns do not have relevant information. Also in operations such as BVMult() or BVDot(), the first l columns are normally not included in the computation. See the manpage of each operation. In orthogonalization operations, the first l columns are treated differently: they participate in the orthogonalization but the computed coefficients are not stored. Level: intermediate .seealso: BVGetActiveColumns(), BVSetSizes() @*/ PetscErrorCode BVSetActiveColumns(BV bv,PetscInt l,PetscInt k) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,l,2); PetscValidLogicalCollectiveInt(bv,k,3); BVCheckSizes(bv,1); if (k==PETSC_DECIDE || k==PETSC_DEFAULT) { bv->k = bv->m; } else { if (k<0 || k>bv->m) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of k. Must be between 0 and m"); bv->k = k; } if (l==PETSC_DECIDE || l==PETSC_DEFAULT) { bv->l = 0; } else { if (l<0 || l>bv->k) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of l. Must be between 0 and k"); bv->l = l; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetActiveColumns" /*@ BVGetActiveColumns - Returns the current active dimensions. Not Collective Input Parameter: . bv - the basis vectors context Output Parameter: + l - number of leading columns - k - number of active columns Level: intermediate .seealso: BVSetActiveColumns() @*/ PetscErrorCode BVGetActiveColumns(BV bv,PetscInt *l,PetscInt *k) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); if (l) *l = bv->l; if (k) *k = bv->k; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetMatrix" /*@ BVSetMatrix - Specifies the inner product to be used in orthogonalization. Collective on BV Input Parameters: + bv - the basis vectors context . B - a symmetric matrix (may be NULL) - indef - a flag indicating if the matrix is indefinite Notes: This is used to specify a non-standard inner product, whose matrix representation is given by B. Then, all inner products required during orthogonalization are computed as (x,y)_B=y^H*B*x rather than the standard form (x,y)=y^H*x. Matrix B must be real symmetric (or complex Hermitian). A genuine inner product requires that B is also positive (semi-)definite. However, we also allow for an indefinite B (setting indef=PETSC_TRUE), in which case the orthogonalization uses an indefinite inner product. This affects operations BVDot(), BVNorm(), BVOrthogonalize(), and variants. Setting B=NULL has the same effect as if the identity matrix was passed. Level: advanced .seealso: BVGetMatrix(), BVDot(), BVNorm(), BVOrthogonalize() @*/ PetscErrorCode BVSetMatrix(BV bv,Mat B,PetscBool indef) { PetscErrorCode ierr; PetscInt m,n; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveBool(bv,indef,3); if (B) { PetscValidHeaderSpecific(B,MAT_CLASSID,2); ierr = MatGetLocalSize(B,&m,&n);CHKERRQ(ierr); if (m!=n) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Matrix must be square"); if (bv->m && bv->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension BV %D, Mat %D",bv->n,n); } ierr = MatDestroy(&bv->matrix);CHKERRQ(ierr); if (B) PetscObjectReference((PetscObject)B); bv->matrix = B; bv->indef = indef; if (B && !bv->Bx) { ierr = MatCreateVecs(B,&bv->Bx,NULL);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->Bx);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetMatrix" /*@ BVGetMatrix - Retrieves the matrix representation of the inner product. Not collective, though a parallel Mat may be returned Input Parameter: . bv - the basis vectors context Output Parameter: + B - the matrix of the inner product (may be NULL) - indef - the flag indicating if the matrix is indefinite Level: advanced .seealso: BVSetMatrix() @*/ PetscErrorCode BVGetMatrix(BV bv,Mat *B,PetscBool *indef) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); if (B) *B = bv->matrix; if (indef) *indef = bv->indef; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVApplyMatrix" /*@ BVApplyMatrix - Multiplies a vector by the matrix representation of the inner product. Neighbor-wise Collective on BV and Vec Input Parameter: + bv - the basis vectors context - x - the vector Output Parameter: . y - the result Note: If no matrix was specified this function copies the vector. Level: advanced .seealso: BVSetMatrix(), BVApplyMatrixBV() @*/ PetscErrorCode BVApplyMatrix(BV bv,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidHeaderSpecific(x,VEC_CLASSID,2); PetscValidHeaderSpecific(y,VEC_CLASSID,3); if (bv->matrix) { ierr = BV_IPMatMult(bv,x);CHKERRQ(ierr); ierr = VecCopy(bv->Bx,y);CHKERRQ(ierr); } else { ierr = VecCopy(x,y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVApplyMatrixBV" /*@ BVApplyMatrixBV - Multiplies the BV vectors by the matrix representation of the inner product. Neighbor-wise Collective on BV Input Parameter: . X - the basis vectors context Output Parameter: . Y - the basis vectors to store the result (optional) Note: This function computes Y = B*X, where B is the matrix given with BVSetMatrix(). This operation is computed as in BVMatMult(). If no matrix was specified, then it just copies Y = X. If no Y is given, the result is stored internally in the cached BV. Level: developer .seealso: BVSetMatrix(), BVApplyMatrix(), BVMatMult(), BVGetCachedBV() @*/ PetscErrorCode BVApplyMatrixBV(BV X,BV Y) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); if (Y) { PetscValidHeaderSpecific(Y,BV_CLASSID,2); if (X->matrix) { ierr = BVMatMult(X,X->matrix,Y);CHKERRQ(ierr); } else { ierr = BVCopy(X,Y);CHKERRQ(ierr); } } else { ierr = BV_IPMatMultBV(X);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetCachedBV" /*@ BVGetCachedBV - Returns a BV object stored internally that holds the result of B*X after a call to BVApplyMatrixBV(). Not collective Input Parameter: . bv - the basis vectors context Output Parameter: . cached - the cached BV Note: The function will return a NULL if BVApplyMatrixBV() was not called yet. Level: developer .seealso: BVApplyMatrixBV() @*/ PetscErrorCode BVGetCachedBV(BV bv,BV *cached) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidPointer(cached,2); *cached = bv->cached; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetSignature" /*@ BVSetSignature - Sets the signature matrix to be used in orthogonalization. Logically Collective on BV Input Parameter: + bv - the basis vectors context - omega - a vector representing the diagonal of the signature matrix Note: The signature matrix Omega = V'*B*V is relevant only for an indefinite B. Level: developer .seealso: BVSetMatrix(), BVGetSignature() @*/ PetscErrorCode BVSetSignature(BV bv,Vec omega) { PetscErrorCode ierr; PetscInt i,n; const PetscScalar *pomega; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); BVCheckSizes(bv,1); PetscValidHeaderSpecific(omega,VEC_CLASSID,2); PetscValidType(omega,2); ierr = VecGetSize(omega,&n);CHKERRQ(ierr); if (n!=bv->k) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_SIZ,"Vec argument has %D elements, should be %D",n,bv->k); ierr = BV_AllocateSignature(bv);CHKERRQ(ierr); if (bv->indef) { ierr = VecGetArrayRead(omega,&pomega);CHKERRQ(ierr); for (i=0;iomega[bv->nc+i] = PetscRealPart(pomega[i]); ierr = VecRestoreArrayRead(omega,&pomega);CHKERRQ(ierr); } else { ierr = PetscInfo(bv,"Ignoring signature because BV is not indefinite\n");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetSignature" /*@ BVGetSignature - Retrieves the signature matrix from last orthogonalization. Not collective Input Parameter: . bv - the basis vectors context Output Parameter: . omega - a vector representing the diagonal of the signature matrix Note: The signature matrix Omega = V'*B*V is relevant only for an indefinite B. Level: developer .seealso: BVSetMatrix(), BVSetSignature() @*/ PetscErrorCode BVGetSignature(BV bv,Vec omega) { PetscErrorCode ierr; PetscInt i,n; PetscScalar *pomega; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); BVCheckSizes(bv,1); PetscValidHeaderSpecific(omega,VEC_CLASSID,2); PetscValidType(omega,2); ierr = VecGetSize(omega,&n);CHKERRQ(ierr); if (n!=bv->k) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_SIZ,"Vec argument has %D elements, should be %D",n,bv->k); if (bv->indef && bv->omega) { ierr = VecGetArray(omega,&pomega);CHKERRQ(ierr); for (i=0;iomega[bv->nc+i]; ierr = VecRestoreArray(omega,&pomega);CHKERRQ(ierr); } else { ierr = VecSet(omega,1.0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetRandomContext" /*@ BVSetRandomContext - Sets the PetscRandom object associated with the BV, to be used in operations that need random numbers. Collective on BV Input Parameters: + bv - the basis vectors context - rand - the random number generator context Level: advanced .seealso: BVGetRandomContext(), BVSetRandom(), BVSetRandomColumn() @*/ PetscErrorCode BVSetRandomContext(BV bv,PetscRandom rand) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidHeaderSpecific(rand,PETSC_RANDOM_CLASSID,2); PetscCheckSameComm(bv,1,rand,2); ierr = PetscObjectReference((PetscObject)rand);CHKERRQ(ierr); ierr = PetscRandomDestroy(&bv->rand);CHKERRQ(ierr); bv->rand = rand; ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->rand);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetRandomContext" /*@ BVGetRandomContext - Gets the PetscRandom object associated with the BV. Not Collective Input Parameter: . bv - the basis vectors context Output Parameter: . rand - the random number generator context Level: advanced .seealso: BVSetRandomContext(), BVSetRandom(), BVSetRandomColumn() @*/ PetscErrorCode BVGetRandomContext(BV bv,PetscRandom* rand) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidPointer(rand,2); if (!bv->rand) { ierr = PetscRandomCreate(PetscObjectComm((PetscObject)bv),&bv->rand);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->rand);CHKERRQ(ierr); if (bv->rrandom) { ierr = PetscRandomSetSeed(bv->rand,0x12345678);CHKERRQ(ierr); ierr = PetscRandomSeed(bv->rand);CHKERRQ(ierr); } } *rand = bv->rand; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetFromOptions" /*@ BVSetFromOptions - Sets BV options from the options database. Collective on BV Input Parameter: . bv - the basis vectors context Level: beginner @*/ PetscErrorCode BVSetFromOptions(BV bv) { PetscErrorCode ierr; char type[256]; PetscBool flg; PetscReal r; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); ierr = BVRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)bv);CHKERRQ(ierr); ierr = PetscOptionsFList("-bv_type","Basis Vectors type","BVSetType",BVList,(char*)(((PetscObject)bv)->type_name?((PetscObject)bv)->type_name:BVSVEC),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = BVSetType(bv,type);CHKERRQ(ierr); } /* Set the type if it was never set. */ if (!((PetscObject)bv)->type_name) { ierr = BVSetType(bv,BVSVEC);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-bv_orthog_type","Orthogonalization method","BVSetOrthogonalization",BVOrthogTypes,(PetscEnum)bv->orthog_type,(PetscEnum*)&bv->orthog_type,NULL);CHKERRQ(ierr); ierr = PetscOptionsEnum("-bv_orthog_refine","Iterative refinement mode during orthogonalization","BVSetOrthogonalization",BVOrthogRefineTypes,(PetscEnum)bv->orthog_ref,(PetscEnum*)&bv->orthog_ref,NULL);CHKERRQ(ierr); ierr = PetscOptionsEnum("-bv_orthog_block","Block orthogonalization method","BVSetOrthogonalization",BVOrthogBlockTypes,(PetscEnum)bv->orthog_block,(PetscEnum*)&bv->orthog_block,NULL);CHKERRQ(ierr); r = bv->orthog_eta; ierr = PetscOptionsReal("-bv_orthog_eta","Parameter of iterative refinement during orthogonalization","BVSetOrthogonalization",r,&r,NULL);CHKERRQ(ierr); ierr = BVSetOrthogonalization(bv,bv->orthog_type,bv->orthog_ref,r,bv->orthog_block);CHKERRQ(ierr); ierr = PetscOptionsEnum("-bv_matmult","Method for BVMatMult","BVSetMatMultMethod",BVMatMultTypes,(PetscEnum)bv->vmm,(PetscEnum*)&bv->vmm,NULL);CHKERRQ(ierr); /* undocumented option to generate random vectors that are independent of the number of processes */ ierr = PetscOptionsGetBool(NULL,NULL,"-bv_reproducible_random",&bv->rrandom,NULL);CHKERRQ(ierr); if (!bv->rand) { ierr = BVGetRandomContext(bv,&bv->rand);CHKERRQ(ierr); } ierr = PetscRandomSetFromOptions(bv->rand);CHKERRQ(ierr); if (bv->ops->create) bv->defersfo = PETSC_TRUE; /* defer call to setfromoptions */ else if (bv->ops->setfromoptions) { ierr = (*bv->ops->setfromoptions)(PetscOptionsObject,bv);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)bv);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetOrthogonalization" /*@ BVSetOrthogonalization - Specifies the method used for the orthogonalization of vectors (classical or modified Gram-Schmidt with or without refinement), and for the block-orthogonalization (simultaneous orthogonalization of a set of vectors). Logically Collective on BV Input Parameters: + bv - the basis vectors context . type - the method of vector orthogonalization . refine - type of refinement . eta - parameter for selective refinement - block - the method of block orthogonalization Options Database Keys: + -bv_orthog_type - Where is cgs for Classical Gram-Schmidt orthogonalization (default) or mgs for Modified Gram-Schmidt orthogonalization . -bv_orthog_refine - Where is one of never, ifneeded (default) or always . -bv_orthog_eta - For setting the value of eta - -bv_orthog_block - Where is the block-orthogonalization method Notes: The default settings work well for most problems. The parameter eta should be a real value between 0 and 1 (or PETSC_DEFAULT). The value of eta is used only when the refinement type is "ifneeded". When using several processors, MGS is likely to result in bad scalability. If the method set for block orthogonalization is GS, then the computation is done column by column with the vector orthogonalization. Level: advanced .seealso: BVOrthogonalizeColumn(), BVGetOrthogonalization(), BVOrthogType, BVOrthogRefineType, BVOrthogBlockType @*/ PetscErrorCode BVSetOrthogonalization(BV bv,BVOrthogType type,BVOrthogRefineType refine,PetscReal eta,BVOrthogBlockType block) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveEnum(bv,type,2); PetscValidLogicalCollectiveEnum(bv,refine,3); PetscValidLogicalCollectiveReal(bv,eta,4); PetscValidLogicalCollectiveEnum(bv,block,5); switch (type) { case BV_ORTHOG_CGS: case BV_ORTHOG_MGS: bv->orthog_type = type; break; default: SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown orthogonalization type"); } switch (refine) { case BV_ORTHOG_REFINE_NEVER: case BV_ORTHOG_REFINE_IFNEEDED: case BV_ORTHOG_REFINE_ALWAYS: bv->orthog_ref = refine; break; default: SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown refinement type"); } if (eta == PETSC_DEFAULT) { bv->orthog_eta = 0.7071; } else { if (eta <= 0.0 || eta > 1.0) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Invalid eta value"); bv->orthog_eta = eta; } switch (block) { case BV_ORTHOG_BLOCK_GS: case BV_ORTHOG_BLOCK_CHOL: bv->orthog_block = block; break; default: SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown block orthogonalization type"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetOrthogonalization" /*@ BVGetOrthogonalization - Gets the orthogonalization settings from the BV object. Not Collective Input Parameter: . bv - basis vectors context Output Parameter: + type - the method of vector orthogonalization . refine - type of refinement . eta - parameter for selective refinement - block - the method of block orthogonalization Level: advanced .seealso: BVOrthogonalizeColumn(), BVSetOrthogonalization(), BVOrthogType, BVOrthogRefineType, BVOrthogBlockType @*/ PetscErrorCode BVGetOrthogonalization(BV bv,BVOrthogType *type,BVOrthogRefineType *refine,PetscReal *eta,BVOrthogBlockType *block) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); if (type) *type = bv->orthog_type; if (refine) *refine = bv->orthog_ref; if (eta) *eta = bv->orthog_eta; if (block) *block = bv->orthog_block; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetMatMultMethod" /*@ BVSetMatMultMethod - Specifies the method used for the BVMatMult() operation. Logically Collective on BV Input Parameters: + bv - the basis vectors context - method - the method for the BVMatMult() operation Options Database Keys: . -bv_matmult - choose one of the methods: vecs, mat, mat_save Note: Allowed values are: + BV_MATMULT_VECS - perform a matrix-vector multiply per each column . BV_MATMULT_MAT - carry out a MatMatMult() product with a dense matrix - BV_MATMULT_MAT_SAVE - call MatMatMult() and keep auxiliary matrices The default is BV_MATMULT_MAT. Level: advanced .seealso: BVMatMult(), BVGetMatMultMethod(), BVMatMultType @*/ PetscErrorCode BVSetMatMultMethod(BV bv,BVMatMultType method) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveEnum(bv,method,2); switch (method) { case BV_MATMULT_VECS: case BV_MATMULT_MAT: case BV_MATMULT_MAT_SAVE: bv->vmm = method; break; default: SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown matmult method"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetMatMultMethod" /*@ BVGetMatMultMethod - Gets the method used for the BVMatMult() operation. Not Collective Input Parameter: . bv - basis vectors context Output Parameter: . method - the method for the BVMatMult() operation Level: advanced .seealso: BVMatMult(), BVSetMatMultMethod(), BVMatMultType @*/ PetscErrorCode BVGetMatMultMethod(BV bv,BVMatMultType *method) { PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidPointer(bv,method); *method = bv->vmm; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetColumn" /*@ BVGetColumn - Returns a Vec object that contains the entries of the requested column of the basis vectors object. Logically Collective on BV Input Parameters: + bv - the basis vectors context - j - the index of the requested column Output Parameter: . v - vector containing the jth column Notes: The returned Vec must be seen as a reference (not a copy) of the BV column, that is, modifying the Vec will change the BV entries as well. The returned Vec must not be destroyed. BVRestoreColumn() must be called when it is no longer needed. At most, two columns can be fetched, that is, this function can only be called twice before the corresponding BVRestoreColumn() is invoked. A negative index j selects the i-th constraint, where i=-j. Constraints should not be modified. Level: beginner .seealso: BVRestoreColumn(), BVInsertConstraints() @*/ PetscErrorCode BVGetColumn(BV bv,PetscInt j,Vec *v) { PetscErrorCode ierr; PetscInt l; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidType(bv,1); BVCheckSizes(bv,1); PetscValidLogicalCollectiveInt(bv,j,2); if (j<0 && -j>bv->nc) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested constraint %D but only %D are available",-j,bv->nc); if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested column %D but only %D are available",j,bv->m); if (j==bv->ci[0] || j==bv->ci[1]) SETERRQ1(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Column %D already fetched in a previous call to BVGetColumn",j); l = BVAvailableVec; if (l==-1) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Too many requested columns; you must call BVRestoreColumn for one of the previously fetched columns"); ierr = (*bv->ops->getcolumn)(bv,j,v);CHKERRQ(ierr); bv->ci[l] = j; ierr = PetscObjectStateGet((PetscObject)bv->cv[l],&bv->st[l]);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)bv->cv[l],&bv->id[l]);CHKERRQ(ierr); *v = bv->cv[l]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreColumn" /*@ BVRestoreColumn - Restore a column obtained with BVGetColumn(). Logically Collective on BV Input Parameters: + bv - the basis vectors context . j - the index of the column - v - vector obtained with BVGetColumn() Note: The arguments must match the corresponding call to BVGetColumn(). Level: beginner .seealso: BVGetColumn() @*/ PetscErrorCode BVRestoreColumn(BV bv,PetscInt j,Vec *v) { PetscErrorCode ierr; PetscObjectId id; PetscObjectState st; PetscInt l; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidType(bv,1); BVCheckSizes(bv,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidPointer(v,3); PetscValidHeaderSpecific(*v,VEC_CLASSID,3); if (j<0 && -j>bv->nc) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested constraint %D but only %D are available",-j,bv->nc); if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested column %D but only %D are available",j,bv->m); if (j!=bv->ci[0] && j!=bv->ci[1]) SETERRQ1(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Column %D has not been fetched with a call to BVGetColumn",j); l = (j==bv->ci[0])? 0: 1; ierr = PetscObjectGetId((PetscObject)*v,&id);CHKERRQ(ierr); if (id!=bv->id[l]) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Argument 3 is not the same Vec that was obtained with BVGetColumn"); ierr = PetscObjectStateGet((PetscObject)*v,&st);CHKERRQ(ierr); if (st!=bv->st[l]) { ierr = PetscObjectStateIncrease((PetscObject)bv);CHKERRQ(ierr); } if (bv->ops->restorecolumn) { ierr = (*bv->ops->restorecolumn)(bv,j,v);CHKERRQ(ierr); } else bv->cv[l] = NULL; bv->ci[l] = -bv->nc-1; bv->st[l] = -1; bv->id[l] = 0; *v = NULL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArray" /*@C BVGetArray - Returns a pointer to a contiguous array that contains this processor's portion of the BV data. Logically Collective on BV Input Parameters: . bv - the basis vectors context Output Parameter: . a - location to put pointer to the array Notes: BVRestoreArray() must be called when access to the array is no longer needed. This operation may imply a data copy, for BV types that do not store data contiguously in memory. The pointer will normally point to the first entry of the first column, but if the BV has constraints then these go before the regular columns. Level: advanced .seealso: BVRestoreArray(), BVInsertConstraints() @*/ PetscErrorCode BVGetArray(BV bv,PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidType(bv,1); BVCheckSizes(bv,1); ierr = (*bv->ops->getarray)(bv,a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArray" /*@C BVRestoreArray - Restore the BV object after BVGetArray() has been called. Logically Collective on BV Input Parameters: + bv - the basis vectors context - a - location of pointer to array obtained from BVGetArray() Note: This operation may imply a data copy, for BV types that do not store data contiguously in memory. Level: advanced .seealso: BVGetColumn() @*/ PetscErrorCode BVRestoreArray(BV bv,PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidType(bv,1); BVCheckSizes(bv,1); if (bv->ops->restorearray) { ierr = (*bv->ops->restorearray)(bv,a);CHKERRQ(ierr); } if (a) *a = NULL; ierr = PetscObjectStateIncrease((PetscObject)bv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArrayRead" /*@C BVGetArrayRead - Returns a read-only pointer to a contiguous array that contains this processor's portion of the BV data. Not Collective Input Parameters: . bv - the basis vectors context Output Parameter: . a - location to put pointer to the array Notes: BVRestoreArrayRead() must be called when access to the array is no longer needed. This operation may imply a data copy, for BV types that do not store data contiguously in memory. The pointer will normally point to the first entry of the first column, but if the BV has constraints then these go before the regular columns. Level: advanced .seealso: BVRestoreArray(), BVInsertConstraints() @*/ PetscErrorCode BVGetArrayRead(BV bv,const PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidType(bv,1); BVCheckSizes(bv,1); ierr = (*bv->ops->getarrayread)(bv,a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArrayRead" /*@C BVRestoreArrayRead - Restore the BV object after BVGetArrayRead() has been called. Logically Collective on BV Input Parameters: + bv - the basis vectors context - a - location of pointer to array obtained from BVGetArrayRead() Level: advanced .seealso: BVGetColumn() @*/ PetscErrorCode BVRestoreArrayRead(BV bv,const PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidType(bv,1); BVCheckSizes(bv,1); if (bv->ops->restorearrayread) { ierr = (*bv->ops->restorearrayread)(bv,a);CHKERRQ(ierr); } if (a) *a = NULL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCreateVec" /*@ BVCreateVec - Creates a new Vec object with the same type and dimensions as the columns of the basis vectors object. Collective on BV Input Parameter: . bv - the basis vectors context Output Parameter: . v - the new vector Note: The user is responsible of destroying the returned vector. Level: beginner @*/ PetscErrorCode BVCreateVec(BV bv,Vec *v) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); BVCheckSizes(bv,1); PetscValidPointer(v,2); ierr = VecDuplicate(bv->t,v);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDuplicate_Private" PETSC_STATIC_INLINE PetscErrorCode BVDuplicate_Private(BV V,PetscInt m,BV *W) { PetscErrorCode ierr; PetscFunctionBegin; ierr = BVCreate(PetscObjectComm((PetscObject)V),W);CHKERRQ(ierr); ierr = BVSetSizesFromVec(*W,V->t,m);CHKERRQ(ierr); ierr = BVSetType(*W,((PetscObject)V)->type_name);CHKERRQ(ierr); ierr = BVSetMatrix(*W,V->matrix,V->indef);CHKERRQ(ierr); ierr = BVSetOrthogonalization(*W,V->orthog_type,V->orthog_ref,V->orthog_eta,V->orthog_block);CHKERRQ(ierr); (*W)->vmm = V->vmm; (*W)->rrandom = V->rrandom; if (V->ops->duplicate) { ierr = (*V->ops->duplicate)(V,W);CHKERRQ(ierr); } ierr = PetscObjectStateIncrease((PetscObject)*W);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDuplicate" /*@ BVDuplicate - Creates a new basis vector object of the same type and dimensions as an existing one. Collective on BV Input Parameter: . V - basis vectors context Output Parameter: . W - location to put the new BV Notes: The new BV has the same type and dimensions as V, and it shares the same template vector. Also, the inner product matrix and orthogonalization options are copied. BVDuplicate() DOES NOT COPY the entries, but rather allocates storage for the new basis vectors. Use BVCopy() to copy the contents. Level: intermediate .seealso: BVDuplicateResize(), BVCreate(), BVSetSizesFromVec(), BVCopy() @*/ PetscErrorCode BVDuplicate(BV V,BV *W) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidPointer(W,2); ierr = BVDuplicate_Private(V,V->m,W);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDuplicateResize" /*@ BVDuplicateResize - Creates a new basis vector object of the same type and dimensions as an existing one, but with possibly different number of columns. Collective on BV Input Parameter: + V - basis vectors context - m - the new number of columns Output Parameter: . W - location to put the new BV Note: This is equivalent of a call to BVDuplicate() followed by BVResize(). The contents of V are not copied to W. Level: intermediate .seealso: BVDuplicate(), BVResize() @*/ PetscErrorCode BVDuplicateResize(BV V,PetscInt m,BV *W) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidLogicalCollectiveInt(V,m,2); PetscValidPointer(W,3); ierr = BVDuplicate_Private(V,m,W);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCopy" /*@ BVCopy - Copies a basis vector object into another one, W <- V. Logically Collective on BV Input Parameter: . V - basis vectors context Output Parameter: . W - the copy Note: Both V and W must be distributed in the same manner; local copies are done. Only active columns (excluding the leading ones) are copied. In the destination W, columns are overwritten starting from the leading ones. Constraints are not copied. Level: beginner .seealso: BVCopyVec(), BVCopyColumn(), BVDuplicate(), BVSetActiveColumns() @*/ PetscErrorCode BVCopy(BV V,BV W) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidHeaderSpecific(W,BV_CLASSID,2); PetscValidType(W,2); BVCheckSizes(W,2); PetscCheckSameTypeAndComm(V,1,W,2); if (V->n!=W->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension V %D, W %D",V->n,W->n); if (V->k-V->l>W->m-W->l) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"W has %D non-leading columns, not enough to store %D columns",W->m-W->l,V->k-V->l); if (!V->n) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_Copy,V,W,0,0);CHKERRQ(ierr); if (V->indef && V->matrix && V->indef==W->indef && V->matrix==W->matrix) { /* copy signature */ ierr = BV_AllocateSignature(W);CHKERRQ(ierr); ierr = PetscMemcpy(W->omega+W->nc+W->l,V->omega+V->nc+V->l,(V->k-V->l)*sizeof(PetscReal));CHKERRQ(ierr); } ierr = (*V->ops->copy)(V,W);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_Copy,V,W,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCopyVec" /*@ BVCopyVec - Copies one of the columns of a basis vectors object into a Vec. Logically Collective on BV Input Parameter: + V - basis vectors context - j - the column number to be copied Output Parameter: . w - the copied column Note: Both V and w must be distributed in the same manner; local copies are done. Level: beginner .seealso: BVCopy(), BVCopyColumn(), BVInsertVec() @*/ PetscErrorCode BVCopyVec(BV V,PetscInt j,Vec w) { PetscErrorCode ierr; PetscInt n,N; Vec z; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidLogicalCollectiveInt(V,j,2); PetscValidHeaderSpecific(w,VEC_CLASSID,3); PetscCheckSameComm(V,1,w,3); ierr = VecGetSize(w,&N);CHKERRQ(ierr); ierr = VecGetLocalSize(w,&n);CHKERRQ(ierr); if (N!=V->N || n!=V->n) SETERRQ4(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,V->N,V->n); ierr = PetscLogEventBegin(BV_Copy,V,w,0,0);CHKERRQ(ierr); ierr = BVGetColumn(V,j,&z);CHKERRQ(ierr); ierr = VecCopy(z,w);CHKERRQ(ierr); ierr = BVRestoreColumn(V,j,&z);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_Copy,V,w,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCopyColumn" /*@ BVCopyColumn - Copies the values from one of the columns to another one. Logically Collective on BV Input Parameter: + V - basis vectors context . j - the number of the source column - i - the number of the destination column Level: beginner .seealso: BVCopy(), BVCopyVec() @*/ PetscErrorCode BVCopyColumn(BV V,PetscInt j,PetscInt i) { PetscErrorCode ierr; Vec z,w; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidLogicalCollectiveInt(V,j,2); PetscValidLogicalCollectiveInt(V,i,3); if (j==i) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_Copy,V,0,0,0);CHKERRQ(ierr); if (V->omega) V->omega[i] = V->omega[j]; ierr = BVGetColumn(V,j,&z);CHKERRQ(ierr); ierr = BVGetColumn(V,i,&w);CHKERRQ(ierr); ierr = VecCopy(z,w);CHKERRQ(ierr); ierr = BVRestoreColumn(V,j,&z);CHKERRQ(ierr); ierr = BVRestoreColumn(V,i,&w);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_Copy,V,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/interface/bvblas.c0000644000175000017500000003714713107004621021225 0ustar jromanjroman/* BV private kernels that use the BLAS. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #define BLOCKSIZE 64 #undef __FUNCT__ #define __FUNCT__ "BVMult_BLAS_Private" /* C := alpha*A*B + beta*C A is mxk (ld=m), B is kxn (ld=ldb), C is mxn (ld=m) */ PetscErrorCode BVMult_BLAS_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,PetscInt ldb_,PetscScalar alpha,const PetscScalar *A,const PetscScalar *B,PetscScalar beta,PetscScalar *C) { PetscErrorCode ierr; PetscBLASInt m,n,k,ldb; #if defined(PETSC_HAVE_FBLASLAPACK) || defined(PETSC_HAVE_F2CBLASLAPACK) PetscBLASInt l,bs=BLOCKSIZE; #endif PetscFunctionBegin; ierr = PetscBLASIntCast(m_,&m);CHKERRQ(ierr); ierr = PetscBLASIntCast(n_,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(k_,&k);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldb_,&ldb);CHKERRQ(ierr); #if defined(PETSC_HAVE_FBLASLAPACK) || defined(PETSC_HAVE_F2CBLASLAPACK) l = m % bs; if (l) PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&l,&n,&k,&alpha,(PetscScalar*)A,&m,(PetscScalar*)B,&ldb,&beta,C,&m)); for (;lwork,&l)); for (j=0;jwork+j*l,l*sizeof(PetscScalar));CHKERRQ(ierr); } } for (;lwork,&bs)); for (j=0;jwork+j*bs,bs*sizeof(PetscScalar));CHKERRQ(ierr); } } ierr = PetscLogFlops(2.0*m*n*k);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlace_Vecs_Private" /* V := V*B V is mxn (ld=m), B is nxn (ld=k) */ PetscErrorCode BVMultInPlace_Vecs_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,Vec *V,const PetscScalar *B,PetscBool btrans) { PetscErrorCode ierr; PetscScalar zero=0.0,one=1.0,*out,*pout; const PetscScalar *pin; PetscBLASInt m,n,k,l,bs=BLOCKSIZE; PetscInt j; const char *bt; PetscFunctionBegin; ierr = PetscBLASIntCast(m_,&m);CHKERRQ(ierr); ierr = PetscBLASIntCast(n_,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(k_,&k);CHKERRQ(ierr); ierr = BVAllocateWork_Private(bv,2*BLOCKSIZE*n_);CHKERRQ(ierr); out = bv->work+BLOCKSIZE*n_; if (btrans) bt = "C"; else bt = "N"; l = m % bs; if (l) { for (j=0;jwork+j*l,pin,l*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArrayRead(V[j],&pin);CHKERRQ(ierr); } PetscStackCallBLAS("BLASgemm",BLASgemm_("N",bt,&l,&n,&n,&one,bv->work,&l,(PetscScalar*)B,&k,&zero,out,&l)); for (j=0;jwork+j*bs,pin+l,bs*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArrayRead(V[j],&pin);CHKERRQ(ierr); } PetscStackCallBLAS("BLASgemm",BLASgemm_("N",bt,&bs,&n,&n,&one,bv->work,&bs,(PetscScalar*)B,&k,&zero,out,&bs)); for (j=0;jwork,&ldc)); else { ierr = PetscMemzero(bv->work,m*n*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = PetscMPIIntCast(m*n,&len);CHKERRQ(ierr); ierr = MPI_Allreduce(bv->work,C,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv));CHKERRQ(ierr); } else { ierr = BVAllocateWork_Private(bv,2*m*n);CHKERRQ(ierr); CC = bv->work+m*n; if (k) PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&m,&n,&k,&one,(PetscScalar*)A,&k,(PetscScalar*)B,&k,&zero,bv->work,&m)); else { ierr = PetscMemzero(bv->work,m*n*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = PetscMPIIntCast(m*n,&len);CHKERRQ(ierr); ierr = MPI_Allreduce(bv->work,CC,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv));CHKERRQ(ierr); for (j=0;jwork,&one)); } else { ierr = PetscMemzero(bv->work,k*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = PetscMPIIntCast(k,&len);CHKERRQ(ierr); ierr = MPI_Allreduce(bv->work,y,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv));CHKERRQ(ierr); } else { if (n) PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n,&k,&done,A,&n,x,&one,&zero,y,&one)); } ierr = PetscLogFlops(2.0*n*k);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVScale_BLAS_Private" /* Scale n scalars */ PetscErrorCode BVScale_BLAS_Private(BV bv,PetscInt n_,PetscScalar *A,PetscScalar alpha) { PetscErrorCode ierr; PetscBLASInt n,one=1; PetscFunctionBegin; if (alpha == (PetscScalar)0.0) { ierr = PetscMemzero(A,n_*sizeof(PetscScalar));CHKERRQ(ierr); } else if (alpha!=(PetscScalar)1.0) { ierr = PetscBLASIntCast(n_,&n);CHKERRQ(ierr); PetscStackCallBLAS("BLASscal",BLASscal_(&n,&alpha,A,&one)); ierr = PetscLogFlops(n);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_LAPACK_Private" /* Compute ||A|| for an mxn matrix */ PetscErrorCode BVNorm_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,const PetscScalar *A,NormType type,PetscReal *nrm,PetscBool mpi) { PetscErrorCode ierr; PetscBLASInt m,n,i,j; PetscMPIInt len; PetscReal lnrm,*rwork=NULL,*rwork2=NULL; PetscFunctionBegin; ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = PetscBLASIntCast(m_,&m);CHKERRQ(ierr); ierr = PetscBLASIntCast(n_,&n);CHKERRQ(ierr); if (type==NORM_FROBENIUS || type==NORM_2) { lnrm = LAPACKlange_("F",&m,&n,(PetscScalar*)A,&m,rwork); if (mpi) { lnrm = lnrm*lnrm; ierr = MPI_Allreduce(&lnrm,nrm,1,MPIU_REAL,MPIU_SUM,PetscObjectComm((PetscObject)bv));CHKERRQ(ierr); *nrm = PetscSqrtReal(*nrm); } else *nrm = lnrm; ierr = PetscLogFlops(2.0*m*n);CHKERRQ(ierr); } else if (type==NORM_1) { if (mpi) { ierr = BVAllocateWork_Private(bv,2*n_);CHKERRQ(ierr); rwork = (PetscReal*)bv->work; rwork2 = rwork+n_; ierr = PetscMemzero(rwork,n_*sizeof(PetscReal));CHKERRQ(ierr); ierr = PetscMemzero(rwork2,n_*sizeof(PetscReal));CHKERRQ(ierr); for (j=0;j *nrm) *nrm = rwork2[j]; } else { *nrm = LAPACKlange_("O",&m,&n,(PetscScalar*)A,&m,rwork); } ierr = PetscLogFlops(1.0*m*n);CHKERRQ(ierr); } else if (type==NORM_INFINITY) { ierr = BVAllocateWork_Private(bv,m_);CHKERRQ(ierr); rwork = (PetscReal*)bv->work; lnrm = LAPACKlange_("I",&m,&n,(PetscScalar*)A,&m,rwork); if (mpi) { ierr = MPI_Allreduce(&lnrm,nrm,1,MPIU_REAL,MPIU_MAX,PetscObjectComm((PetscObject)bv));CHKERRQ(ierr); } else *nrm = lnrm; ierr = PetscLogFlops(1.0*m*n);CHKERRQ(ierr); } ierr = PetscFPTrapPop();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalize_LAPACK_Private" /* QR factorization of an mxn matrix */ PetscErrorCode BVOrthogonalize_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,PetscScalar *Q,PetscScalar *R,PetscBool mpi) { #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscBLASInt m,n,i,j,k,l,nb,lwork,info; PetscScalar *tau,*work,*Rl=NULL,*A=NULL,*C=NULL,one=1.0,zero=0.0; PetscMPIInt rank,size,len; PetscFunctionBegin; ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); ierr = PetscBLASIntCast(m_,&m);CHKERRQ(ierr); ierr = PetscBLASIntCast(n_,&n);CHKERRQ(ierr); k = PetscMin(m,n); nb = 16; if (mpi) { ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)bv),&rank);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)bv),&size);CHKERRQ(ierr); ierr = BVAllocateWork_Private(bv,k+n*nb+n*n+n*n*size+m*n);CHKERRQ(ierr); } else { ierr = BVAllocateWork_Private(bv,k+n*nb);CHKERRQ(ierr); } tau = bv->work; work = bv->work+k; ierr = PetscBLASIntCast(n*nb,&lwork);CHKERRQ(ierr); if (mpi) { Rl = bv->work+k+n*nb; A = bv->work+k+n*nb+n*n; C = bv->work+k+n*nb+n*n+n*n*size; } /* Compute QR */ PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&m,&n,Q,&m,tau,work,&lwork,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info); /* Extract R */ if (R || mpi) { ierr = PetscMemzero(mpi? Rl: R,n*n*sizeof(PetscScalar));CHKERRQ(ierr); for (j=0;j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcbv.h" I*/ PetscClassId BV_CLASSID = 0; PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0; static PetscBool BVPackageInitialized = PETSC_FALSE; const char *BVOrthogTypes[] = {"CGS","MGS","BVOrthogType","BV_ORTHOG_",0}; const char *BVOrthogRefineTypes[] = {"IFNEEDED","NEVER","ALWAYS","BVOrthogRefineType","BV_ORTHOG_REFINE_",0}; const char *BVOrthogBlockTypes[] = {"GS","CHOL","BVOrthogBlockType","BV_ORTHOG_BLOCK_",0}; const char *BVMatMultTypes[] = {"VECS","MAT","MAT_SAVE","BVMatMultType","BV_MATMULT_",0}; #undef __FUNCT__ #define __FUNCT__ "BVFinalizePackage" /*@C BVFinalizePackage - This function destroys everything in the Slepc interface to the BV package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode BVFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&BVList);CHKERRQ(ierr); BVPackageInitialized = PETSC_FALSE; BVRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVInitializePackage" /*@C BVInitializePackage - This function initializes everything in the BV package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to BVCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode BVInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (BVPackageInitialized) PetscFunctionReturn(0); BVPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("Basis Vectors",&BV_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = BVRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("BVCreate",BV_CLASSID,&BV_Create);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVCopy",BV_CLASSID,&BV_Copy);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVMult",BV_CLASSID,&BV_Mult);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVMultVec",BV_CLASSID,&BV_MultVec);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVMultInPlace",BV_CLASSID,&BV_MultInPlace);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVDot",BV_CLASSID,&BV_Dot);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVDotVec",BV_CLASSID,&BV_DotVec);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVOrthogonalize",BV_CLASSID,&BV_Orthogonalize);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVOrthogonalizeV",BV_CLASSID,&BV_OrthogonalizeVec);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVScale",BV_CLASSID,&BV_Scale);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVNorm",BV_CLASSID,&BV_Norm);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVNormVec",BV_CLASSID,&BV_NormVec);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVSetRandom",BV_CLASSID,&BV_SetRandom);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVMatMult",BV_CLASSID,&BV_MatMult);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVMatMultVec",BV_CLASSID,&BV_MatMultVec);CHKERRQ(ierr); ierr = PetscLogEventRegister("BVMatProject",BV_CLASSID,&BV_MatProject);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"bv",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(BV_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"bv",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(BV_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(BVFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDestroy" /*@ BVDestroy - Destroys BV context that was created with BVCreate(). Collective on BV Input Parameter: . bv - the basis vectors context Level: beginner .seealso: BVCreate() @*/ PetscErrorCode BVDestroy(BV *bv) { PetscErrorCode ierr; PetscFunctionBegin; if (!*bv) PetscFunctionReturn(0); PetscValidHeaderSpecific(*bv,BV_CLASSID,1); if (--((PetscObject)(*bv))->refct > 0) { *bv = 0; PetscFunctionReturn(0); } if ((*bv)->ops->destroy) { ierr = (*(*bv)->ops->destroy)(*bv);CHKERRQ(ierr); } ierr = VecDestroy(&(*bv)->t);CHKERRQ(ierr); ierr = MatDestroy(&(*bv)->matrix);CHKERRQ(ierr); ierr = VecDestroy(&(*bv)->Bx);CHKERRQ(ierr); ierr = BVDestroy(&(*bv)->cached);CHKERRQ(ierr); ierr = PetscFree((*bv)->work);CHKERRQ(ierr); ierr = PetscFree2((*bv)->h,(*bv)->c);CHKERRQ(ierr); ierr = PetscFree((*bv)->omega);CHKERRQ(ierr); ierr = MatDestroy(&(*bv)->B);CHKERRQ(ierr); ierr = MatDestroy(&(*bv)->C);CHKERRQ(ierr); ierr = PetscRandomDestroy(&(*bv)->rand);CHKERRQ(ierr); ierr = PetscHeaderDestroy(bv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCreate" /*@ BVCreate - Creates a basis vectors context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . bv - location to put the basis vectors context Level: beginner .seealso: BVSetUp(), BVDestroy(), BV @*/ PetscErrorCode BVCreate(MPI_Comm comm,BV *newbv) { PetscErrorCode ierr; BV bv; PetscFunctionBegin; PetscValidPointer(newbv,2); *newbv = 0; ierr = BVInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(bv,BV_CLASSID,"BV","Basis Vectors","BV",comm,BVDestroy,BVView);CHKERRQ(ierr); bv->t = NULL; bv->n = -1; bv->N = -1; bv->m = 0; bv->l = 0; bv->k = 0; bv->nc = 0; bv->orthog_type = BV_ORTHOG_CGS; bv->orthog_ref = BV_ORTHOG_REFINE_IFNEEDED; bv->orthog_eta = 0.7071; bv->orthog_block = BV_ORTHOG_BLOCK_GS; bv->matrix = NULL; bv->indef = PETSC_FALSE; bv->vmm = BV_MATMULT_MAT; bv->Bx = NULL; bv->xid = 0; bv->xstate = 0; bv->cv[0] = NULL; bv->cv[1] = NULL; bv->ci[0] = -1; bv->ci[1] = -1; bv->st[0] = -1; bv->st[1] = -1; bv->id[0] = 0; bv->id[1] = 0; bv->h = NULL; bv->c = NULL; bv->omega = NULL; bv->B = NULL; bv->C = NULL; bv->Aid = 0; bv->defersfo = PETSC_FALSE; bv->cached = NULL; bv->bvstate = 0; bv->rand = NULL; bv->rrandom = PETSC_FALSE; bv->work = NULL; bv->lwork = 0; bv->data = NULL; *newbv = bv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVInsertVec" /*@ BVInsertVec - Insert a vector into the specified column. Collective on BV Input Parameters: + V - basis vectors . j - the column of V to be overwritten - w - the vector to be copied Level: intermediate .seealso: BVInsertVecs() @*/ PetscErrorCode BVInsertVec(BV V,PetscInt j,Vec w) { PetscErrorCode ierr; PetscInt n,N; Vec v; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidLogicalCollectiveInt(V,j,2); PetscValidHeaderSpecific(w,VEC_CLASSID,3); PetscValidType(V,1); BVCheckSizes(V,1); PetscCheckSameComm(V,1,w,3); ierr = VecGetSize(w,&N);CHKERRQ(ierr); ierr = VecGetLocalSize(w,&n);CHKERRQ(ierr); if (N!=V->N || n!=V->n) SETERRQ4(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,V->N,V->n); if (j<-V->nc || j>=V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, should be between %D and %D",j,-V->nc,V->m-1); ierr = BVGetColumn(V,j,&v);CHKERRQ(ierr); ierr = VecCopy(w,v);CHKERRQ(ierr); ierr = BVRestoreColumn(V,j,&v);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVInsertVecs" /*@ BVInsertVecs - Insert a set of vectors into the specified columns. Collective on BV Input Parameters: + V - basis vectors . s - first column of V to be overwritten . W - set of vectors to be copied - orth - flag indicating if the vectors must be orthogonalized Input/Output Parameter: . m - number of input vectors, on output the number of linearly independent vectors Notes: Copies the contents of vectors W to V(:,s:s+n). If the orthogonalization flag is set, then the vectors are copied one by one and then orthogonalized against the previous ones. If any of them is linearly dependent then it is discarded and the value of m is decreased. Level: intermediate .seealso: BVInsertVec(), BVOrthogonalizeColumn() @*/ PetscErrorCode BVInsertVecs(BV V,PetscInt s,PetscInt *m,Vec *W,PetscBool orth) { PetscErrorCode ierr; PetscInt n,N,i,ndep; PetscBool lindep; PetscReal norm; Vec v; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidLogicalCollectiveInt(V,s,2); PetscValidPointer(m,3); PetscValidLogicalCollectiveInt(V,*m,3); if (!*m) PetscFunctionReturn(0); if (*m<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Number of vectors (given %D) cannot be negative",*m); PetscValidPointer(W,4); PetscValidHeaderSpecific(*W,VEC_CLASSID,4); PetscValidLogicalCollectiveBool(V,orth,5); PetscValidType(V,1); BVCheckSizes(V,1); PetscCheckSameComm(V,1,*W,4); ierr = VecGetSize(*W,&N);CHKERRQ(ierr); ierr = VecGetLocalSize(*W,&n);CHKERRQ(ierr); if (N!=V->N || n!=V->n) SETERRQ4(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,V->N,V->n); if (s<0 || s>=V->m) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument s has wrong value %D, should be between 0 and %D",s,V->m-1); if (s+(*m)>V->m) SETERRQ1(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Too many vectors provided, there is only room for %D",V->m); ndep = 0; for (i=0;i<*m;i++) { ierr = BVGetColumn(V,s+i-ndep,&v);CHKERRQ(ierr); ierr = VecCopy(W[i],v);CHKERRQ(ierr); ierr = BVRestoreColumn(V,s+i-ndep,&v);CHKERRQ(ierr); if (orth) { ierr = BVOrthogonalizeColumn(V,s+i-ndep,NULL,&norm,&lindep);CHKERRQ(ierr); if (norm==0.0 || lindep) { ierr = PetscInfo1(V,"Removing linearly dependent vector %D\n",i);CHKERRQ(ierr); ndep++; } else { ierr = BVScaleColumn(V,s+i-ndep,1.0/norm);CHKERRQ(ierr); } } } *m -= ndep; ierr = PetscObjectStateIncrease((PetscObject)V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVInsertConstraints" /*@ BVInsertConstraints - Insert a set of vectors as constraints. Collective on BV Input Parameters: + V - basis vectors - C - set of vectors to be inserted as constraints Input/Output Parameter: . nc - number of input vectors, on output the number of linearly independent vectors Notes: The constraints are relevant only during orthogonalization. Constraint vectors span a subspace that is deflated in every orthogonalization operation, so they are intended for removing those directions from the orthogonal basis computed in regular BV columns. Constraints are not stored in regular BV colums, but in a special part of the storage. They can be accessed with negative indices in BVGetColumn(). This operation is DESTRUCTIVE, meaning that all data contained in the columns of V is lost. This is typically invoked just after creating the BV. Once a set of constraints has been set, it is not allowed to call this function again. The vectors are copied one by one and then orthogonalized against the previous ones. If any of them is linearly dependent then it is discarded and the value of nc is decreased. The behaviour is similar to BVInsertVecs(). Level: advanced .seealso: BVInsertVecs(), BVOrthogonalizeColumn(), BVGetColumn(), BVGetNumConstraints() @*/ PetscErrorCode BVInsertConstraints(BV V,PetscInt *nc,Vec *C) { PetscErrorCode ierr; PetscInt msave; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidPointer(nc,2); PetscValidLogicalCollectiveInt(V,*nc,2); if (!*nc) PetscFunctionReturn(0); if (*nc<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Number of constraints (given %D) cannot be negative",*nc); PetscValidPointer(C,3); PetscValidHeaderSpecific(*C,VEC_CLASSID,3); PetscValidType(V,1); BVCheckSizes(V,1); PetscCheckSameComm(V,1,*C,3); if (V->nc) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_WRONGSTATE,"Constraints already present in this BV object"); if (V->ci[0]!=-1 || V->ci[1]!=-1) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Cannot call BVInsertConstraints after BVGetColumn"); msave = V->m; ierr = BVResize(V,*nc+V->m,PETSC_FALSE);CHKERRQ(ierr); ierr = BVInsertVecs(V,0,nc,C,PETSC_TRUE);CHKERRQ(ierr); V->nc = *nc; V->m = msave; V->ci[0] = -V->nc-1; V->ci[1] = -V->nc-1; ierr = PetscObjectStateIncrease((PetscObject)V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetOptionsPrefix" /*@C BVSetOptionsPrefix - Sets the prefix used for searching for all BV options in the database. Logically Collective on BV Input Parameters: + bv - the basis vectors context - prefix - the prefix string to prepend to all BV option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: BVAppendOptionsPrefix(), BVGetOptionsPrefix() @*/ PetscErrorCode BVSetOptionsPrefix(BV bv,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); ierr = PetscObjectSetOptionsPrefix((PetscObject)bv,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVAppendOptionsPrefix" /*@C BVAppendOptionsPrefix - Appends to the prefix used for searching for all BV options in the database. Logically Collective on BV Input Parameters: + bv - the basis vectors context - prefix - the prefix string to prepend to all BV option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: BVSetOptionsPrefix(), BVGetOptionsPrefix() @*/ PetscErrorCode BVAppendOptionsPrefix(BV bv,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)bv,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetOptionsPrefix" /*@C BVGetOptionsPrefix - Gets the prefix used for searching for all BV options in the database. Not Collective Input Parameters: . bv - the basis vectors context Output Parameters: . prefix - pointer to the prefix string used, is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: BVSetOptionsPrefix(), BVAppendOptionsPrefix() @*/ PetscErrorCode BVGetOptionsPrefix(BV bv,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)bv,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVView_Default" static PetscErrorCode BVView_Default(BV bv,PetscViewer viewer) { PetscErrorCode ierr; PetscInt j; Vec v; PetscViewerFormat format; PetscBool isascii,ismatlab=PETSC_FALSE; const char *bvname,*name; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_MATLAB) ismatlab = PETSC_TRUE; } if (ismatlab) { ierr = PetscObjectGetName((PetscObject)bv,&bvname);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s=[];\n",bvname);CHKERRQ(ierr); } for (j=-bv->nc;jm;j++) { ierr = BVGetColumn(bv,j,&v);CHKERRQ(ierr); ierr = VecView(v,viewer);CHKERRQ(ierr); if (ismatlab) { ierr = PetscObjectGetName((PetscObject)v,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s=[%s,%s];clear %s\n",bvname,bvname,name,name);CHKERRQ(ierr); } ierr = BVRestoreColumn(bv,j,&v);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVView" /*@C BVView - Prints the BV data structure. Collective on BV Input Parameters: + bv - the BV context - viewer - optional visualization context Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization contexts with PetscViewerASCIIOpen() (output to a specified file). Level: beginner .seealso: PetscViewerASCIIOpen() @*/ PetscErrorCode BVView(BV bv,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii; PetscViewerFormat format; const char *orthname[2] = {"classical","modified"}; const char *refname[3] = {"if needed","never","always"}; const char *borthname[2] = {"Gram-Schmidt","Cholesky"}; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); if (!viewer) { ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)bv),&viewer);CHKERRQ(ierr); } PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)bv,viewer);CHKERRQ(ierr); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) { ierr = PetscViewerASCIIPrintf(viewer,"%D columns of global length %D\n",bv->m,bv->N);CHKERRQ(ierr); if (bv->nc>0) { ierr = PetscViewerASCIIPrintf(viewer,"number of constraints: %D\n",bv->nc);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"vector orthogonalization method: %s Gram-Schmidt\n",orthname[bv->orthog_type]);CHKERRQ(ierr); switch (bv->orthog_ref) { case BV_ORTHOG_REFINE_IFNEEDED: ierr = PetscViewerASCIIPrintf(viewer,"orthogonalization refinement: %s (eta: %g)\n",refname[bv->orthog_ref],(double)bv->orthog_eta);CHKERRQ(ierr); break; case BV_ORTHOG_REFINE_NEVER: case BV_ORTHOG_REFINE_ALWAYS: ierr = PetscViewerASCIIPrintf(viewer,"orthogonalization refinement: %s\n",refname[bv->orthog_ref]);CHKERRQ(ierr); break; } ierr = PetscViewerASCIIPrintf(viewer,"block orthogonalization method: %s\n",borthname[bv->orthog_block]);CHKERRQ(ierr); if (bv->matrix) { if (bv->indef) { ierr = PetscViewerASCIIPrintf(viewer,"indefinite inner product\n");CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"non-standard inner product\n");CHKERRQ(ierr); } ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);CHKERRQ(ierr); ierr = MatView(bv->matrix,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } switch (bv->vmm) { case BV_MATMULT_VECS: ierr = PetscViewerASCIIPrintf(viewer,"doing matmult as matrix-vector products\n");CHKERRQ(ierr); break; case BV_MATMULT_MAT: ierr = PetscViewerASCIIPrintf(viewer,"doing matmult as a single matrix-matrix product\n");CHKERRQ(ierr); break; case BV_MATMULT_MAT_SAVE: ierr = PetscViewerASCIIPrintf(viewer,"doing matmult as a single matrix-matrix product, saving aux matrices\n");CHKERRQ(ierr); break; } if (bv->rrandom) { ierr = PetscViewerASCIIPrintf(viewer,"generating random vectors independent of the number of processes\n");CHKERRQ(ierr); } } else { if (bv->ops->view) { ierr = (*bv->ops->view)(bv,viewer);CHKERRQ(ierr); } else { ierr = BVView_Default(bv,viewer);CHKERRQ(ierr); } } ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } else { ierr = (*bv->ops->view)(bv,viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRegister" /*@C BVRegister - Adds a new storage format to the BV package. Not collective Input Parameters: + name - name of a new user-defined BV - function - routine to create context Notes: BVRegister() may be called multiple times to add several user-defined basis vectors. Level: advanced .seealso: BVRegisterAll() @*/ PetscErrorCode BVRegister(const char *name,PetscErrorCode (*function)(BV)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&BVList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVAllocateWork_Private" PetscErrorCode BVAllocateWork_Private(BV bv,PetscInt s) { PetscErrorCode ierr; PetscFunctionBegin; if (s>bv->lwork) { ierr = PetscFree(bv->work);CHKERRQ(ierr); ierr = PetscMalloc1(s,&bv->work);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)bv,(s-bv->lwork)*sizeof(PetscScalar));CHKERRQ(ierr); bv->lwork = s; } PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/interface/bvops.c.html0000644000175000017500000013572713107004621022053 0ustar jromanjroman

Actual source code: bvops.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV operations, except those involving global communication.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>      /*I "slepcbv.h" I*/

 28: /*@
 29:    BVMult - Computes Y = beta*Y + alpha*X*Q.

 31:    Logically Collective on BV

 33:    Input Parameters:
 34: +  Y,X        - basis vectors
 35: .  alpha,beta - scalars
 36: -  Q          - (optional) sequential dense matrix

 38:    Output Parameter:
 39: .  Y          - the modified basis vectors

 41:    Notes:
 42:    X and Y must be different objects. The case X=Y can be addressed with
 43:    BVMultInPlace().

 45:    If matrix Q is NULL, then an AXPY operation Y = beta*Y + alpha*X is done
 46:    (i.e. results as if Q = identity). If provided,
 47:    the matrix Q must be a sequential dense Mat, with all entries equal on
 48:    all processes (otherwise each process will compute a different update).
 49:    The dimensions of Q must be at least m,n where m is the number of active
 50:    columns of X and n is the number of active columns of Y.

 52:    The leading columns of Y are not modified. Also, if X has leading
 53:    columns specified, then these columns do not participate in the computation.
 54:    Hence, only rows (resp. columns) of Q starting from lx (resp. ly) are used,
 55:    where lx (resp. ly) is the number of leading columns of X (resp. Y).

 57:    Level: intermediate

 59: .seealso: BVMultVec(), BVMultColumn(), BVMultInPlace(), BVSetActiveColumns()
 60: @*/
 61: PetscErrorCode BVMult(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)
 62: {
 64:   PetscBool      match;
 65:   PetscInt       m,n;

 74:   BVCheckSizes(Y,1);
 76:   BVCheckSizes(X,4);
 79:   if (X==Y) SETERRQ(PetscObjectComm((PetscObject)Y),PETSC_ERR_ARG_WRONG,"X and Y arguments must be different");
 80:   if (Q) {
 81:     PetscObjectTypeCompare((PetscObject)Q,MATSEQDENSE,&match);
 82:     if (!match) SETERRQ(PetscObjectComm((PetscObject)Y),PETSC_ERR_SUP,"Mat argument must be of type seqdense");
 83:     MatGetSize(Q,&m,&n);
 84:     if (m<X->k) SETERRQ2(PetscObjectComm((PetscObject)Y),PETSC_ERR_ARG_SIZ,"Mat argument has %D rows, should have at least %D",m,X->k);
 85:     if (n<Y->k) SETERRQ2(PetscObjectComm((PetscObject)Y),PETSC_ERR_ARG_SIZ,"Mat argument has %D columns, should have at least %D",n,Y->k);
 86:   }
 87:   if (X->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, Y %D",X->n,Y->n);

 89:   PetscLogEventBegin(BV_Mult,X,Y,0,0);
 90:   (*Y->ops->mult)(Y,alpha,beta,X,Q);
 91:   PetscLogEventEnd(BV_Mult,X,Y,0,0);
 92:   PetscObjectStateIncrease((PetscObject)Y);
 93:   return(0);
 94: }

 98: /*@
 99:    BVMultVec - Computes y = beta*y + alpha*X*q.

101:    Logically Collective on BV and Vec

103:    Input Parameters:
104: +  X          - a basis vectors object
105: .  alpha,beta - scalars
106: .  y          - a vector
107: -  q          - an array of scalars

109:    Output Parameter:
110: .  y          - the modified vector

112:    Notes:
113:    This operation is the analogue of BVMult() but with a BV and a Vec,
114:    instead of two BV. Note that arguments are listed in different order
115:    with respect to BVMult().

117:    If X has leading columns specified, then these columns do not participate
118:    in the computation.

120:    The length of array q must be equal to the number of active columns of X
121:    minus the number of leading columns, i.e. the first entry of q multiplies
122:    the first non-leading column.

124:    Level: intermediate

126: .seealso: BVMult(), BVMultColumn(), BVMultInPlace(), BVSetActiveColumns()
127: @*/
128: PetscErrorCode BVMultVec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)
129: {
131:   PetscInt       n,N;

140:   BVCheckSizes(X,1);

144:   VecGetSize(y,&N);
145:   VecGetLocalSize(y,&n);
146:   if (N!=X->N || n!=X->n) SETERRQ4(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,X->N,X->n);

148:   PetscLogEventBegin(BV_MultVec,X,y,0,0);
149:   (*X->ops->multvec)(X,alpha,beta,y,q);
150:   PetscLogEventEnd(BV_MultVec,X,y,0,0);
151:   return(0);
152: }

156: /*@
157:    BVMultColumn - Computes y = beta*y + alpha*X*q, where y is the j-th column
158:    of X.

160:    Logically Collective on BV

162:    Input Parameters:
163: +  X          - a basis vectors object
164: .  alpha,beta - scalars
165: .  j          - the column index
166: -  q          - an array of scalars

168:    Notes:
169:    This operation is equivalent to BVMultVec() but it uses column j of X
170:    rather than taking a Vec as an argument. The number of active columns of
171:    X is set to j before the computation, and restored afterwards.
172:    If X has leading columns specified, then these columns do not participate
173:    in the computation. Therefore, the length of array q must be equal to j
174:    minus the number of leading columns.

176:    Level: advanced

178: .seealso: BVMult(), BVMultVec(), BVMultInPlace(), BVSetActiveColumns()
179: @*/
180: PetscErrorCode BVMultColumn(BV X,PetscScalar alpha,PetscScalar beta,PetscInt j,PetscScalar *q)
181: {
183:   PetscInt       ksave;
184:   Vec            y;

193:   BVCheckSizes(X,1);

195:   if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative");
196:   if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m);

198:   PetscLogEventBegin(BV_MultVec,X,0,0,0);
199:   ksave = X->k;
200:   X->k = j;
201:   BVGetColumn(X,j,&y);
202:   (*X->ops->multvec)(X,alpha,beta,y,q);
203:   BVRestoreColumn(X,j,&y);
204:   X->k = ksave;
205:   PetscLogEventEnd(BV_MultVec,X,0,0,0);
206:   return(0);
207: }

211: /*@
212:    BVMultInPlace - Update a set of vectors as V(:,s:e-1) = V*Q(:,s:e-1).

214:    Logically Collective on BV

216:    Input Parameters:
217: +  Q - a sequential dense matrix
218: .  s - first column of V to be overwritten
219: -  e - first column of V not to be overwritten

221:    Input/Output Parameter:
222: .  V - basis vectors

224:    Notes:
225:    The matrix Q must be a sequential dense Mat, with all entries equal on
226:    all processes (otherwise each process will compute a different update).

228:    This function computes V(:,s:e-1) = V*Q(:,s:e-1), that is, given a set of
229:    vectors V, columns from s to e-1 are overwritten with columns from s to
230:    e-1 of the matrix-matrix product V*Q. Only columns s to e-1 of Q are
231:    referenced.

233:    Level: intermediate

235: .seealso: BVMult(), BVMultVec(), BVMultInPlaceTranspose(), BVSetActiveColumns()
236: @*/
237: PetscErrorCode BVMultInPlace(BV V,Mat Q,PetscInt s,PetscInt e)
238: {
240:   PetscBool      match;
241:   PetscInt       m,n;

249:   BVCheckSizes(V,1);
251:   PetscObjectTypeCompare((PetscObject)Q,MATSEQDENSE,&match);
252:   if (!match) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Mat argument must be of type seqdense");

254:   if (s<V->l || s>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument s has wrong value %D, should be between %D and %D",s,V->l,V->m);
255:   if (e<V->l || e>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument e has wrong value %D, should be between %D and %D",e,V->l,V->m);
256:   MatGetSize(Q,&m,&n);
257:   if (m<V->k) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument has %D rows, should have at least %D",m,V->k);
258:   if (e>n) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument only has %D columns, the requested value of e is larger: %D",n,e);
259:   if (s>=e) return(0);

261:   PetscLogEventBegin(BV_MultInPlace,V,Q,0,0);
262:   (*V->ops->multinplace)(V,Q,s,e);
263:   PetscLogEventEnd(BV_MultInPlace,V,Q,0,0);
264:   PetscObjectStateIncrease((PetscObject)V);
265:   return(0);
266: }

270: /*@
271:    BVMultInPlaceTranspose - Update a set of vectors as V(:,s:e-1) = V*Q'(:,s:e-1).

273:    Logically Collective on BV

275:    Input Parameters:
276: +  Q - a sequential dense matrix
277: .  s - first column of V to be overwritten
278: -  e - first column of V not to be overwritten

280:    Input/Output Parameter:
281: .  V - basis vectors

283:    Notes:
284:    This is a variant of BVMultInPlace() where the conjugate transpose
285:    of Q is used.

287:    Level: intermediate

289: .seealso: BVMultInPlace()
290: @*/
291: PetscErrorCode BVMultInPlaceTranspose(BV V,Mat Q,PetscInt s,PetscInt e)
292: {
294:   PetscBool      match;
295:   PetscInt       m,n;

303:   BVCheckSizes(V,1);
305:   PetscObjectTypeCompare((PetscObject)Q,MATSEQDENSE,&match);
306:   if (!match) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Mat argument must be of type seqdense");

308:   if (s<V->l || s>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument s has wrong value %D, should be between %D and %D",s,V->l,V->m);
309:   if (e<V->l || e>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument e has wrong value %D, should be between %D and %D",e,V->l,V->m);
310:   MatGetSize(Q,&m,&n);
311:   if (n<V->k) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument has %D columns, should have at least %D",n,V->k);
312:   if (e>m) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument only has %D rows, the requested value of e is larger: %D",m,e);
313:   if (s>=e || !V->n) return(0);

315:   PetscLogEventBegin(BV_MultInPlace,V,Q,0,0);
316:   (*V->ops->multinplacetrans)(V,Q,s,e);
317:   PetscLogEventEnd(BV_MultInPlace,V,Q,0,0);
318:   PetscObjectStateIncrease((PetscObject)V);
319:   return(0);
320: }

324: /*@
325:    BVScale - Multiply the BV entries by a scalar value.

327:    Logically Collective on BV

329:    Input Parameters:
330: +  bv    - basis vectors
331: -  alpha - scaling factor

333:    Note:
334:    All active columns (except the leading ones) are scaled.

336:    Level: intermediate

338: .seealso: BVScaleColumn(), BVSetActiveColumns()
339: @*/
340: PetscErrorCode BVScale(BV bv,PetscScalar alpha)
341: {

348:   BVCheckSizes(bv,1);
349:   if (alpha == (PetscScalar)1.0) return(0);

351:   PetscLogEventBegin(BV_Scale,bv,0,0,0);
352:   if (bv->n) {
353:     (*bv->ops->scale)(bv,-1,alpha);
354:   }
355:   PetscLogEventEnd(BV_Scale,bv,0,0,0);
356:   PetscObjectStateIncrease((PetscObject)bv);
357:   return(0);
358: }

362: /*@
363:    BVScaleColumn - Scale one column of a BV.

365:    Logically Collective on BV

367:    Input Parameters:
368: +  bv    - basis vectors
369: .  j     - column number to be scaled
370: -  alpha - scaling factor

372:    Level: intermediate

374: .seealso: BVScale(), BVSetActiveColumns()
375: @*/
376: PetscErrorCode BVScaleColumn(BV bv,PetscInt j,PetscScalar alpha)
377: {

385:   BVCheckSizes(bv,1);

387:   if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m);
388:   if (alpha == (PetscScalar)1.0) return(0);

390:   PetscLogEventBegin(BV_Scale,bv,0,0,0);
391:   if (bv->n) {
392:     (*bv->ops->scale)(bv,j,alpha);
393:   }
394:   PetscLogEventEnd(BV_Scale,bv,0,0,0);
395:   PetscObjectStateIncrease((PetscObject)bv);
396:   return(0);
397: }

401: /*@
402:    BVSetRandom - Set the columns of a BV to random numbers.

404:    Logically Collective on BV

406:    Input Parameters:
407: .  bv - basis vectors

409:    Note:
410:    All active columns (except the leading ones) are modified.

412:    Level: advanced

414: .seealso: BVSetRandomContext(), BVSetRandomColumn(), BVSetActiveColumns()
415: @*/
416: PetscErrorCode BVSetRandom(BV bv)
417: {
419:   PetscInt       i,low,high,k;
420:   PetscScalar    *px,t;
421:   Vec            x;

426:   BVCheckSizes(bv,1);

428:   BVGetRandomContext(bv,&bv->rand);
429:   PetscLogEventBegin(BV_SetRandom,bv,0,0,0);
430:   for (k=bv->l;k<bv->k;k++) {
431:     BVGetColumn(bv,k,&x);
432:     if (bv->rrandom) {  /* generate the same vector irrespective of number of processes */
433:       VecGetOwnershipRange(x,&low,&high);
434:       VecGetArray(x,&px);
435:       for (i=0;i<bv->N;i++) {
436:         PetscRandomGetValue(bv->rand,&t);
437:         if (i>=low && i<high) px[i-low] = t;
438:       }
439:       VecRestoreArray(x,&px);
440:     } else {
441:       VecSetRandom(x,bv->rand);
442:     }
443:     BVRestoreColumn(bv,k,&x);
444:   }
445:   PetscLogEventEnd(BV_SetRandom,bv,0,0,0);
446:   PetscObjectStateIncrease((PetscObject)bv);
447:   return(0);
448: }

452: /*@
453:    BVSetRandomColumn - Set one column of a BV to random numbers.

455:    Logically Collective on BV

457:    Input Parameters:
458: +  bv - basis vectors
459: -  j  - column number to be set

461:    Level: advanced

463: .seealso: BVSetRandomContext(), BVSetRandom(), BVSetActiveColumns()
464: @*/
465: PetscErrorCode BVSetRandomColumn(BV bv,PetscInt j)
466: {
468:   PetscInt       i,low,high;
469:   PetscScalar    *px,t;
470:   Vec            x;

476:   BVCheckSizes(bv,1);
477:   if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m);

479:   BVGetRandomContext(bv,&bv->rand);
480:   PetscLogEventBegin(BV_SetRandom,bv,0,0,0);
481:   BVGetColumn(bv,j,&x);
482:   if (bv->rrandom) {  /* generate the same vector irrespective of number of processes */
483:     VecGetOwnershipRange(x,&low,&high);
484:     VecGetArray(x,&px);
485:     for (i=0;i<bv->N;i++) {
486:       PetscRandomGetValue(bv->rand,&t);
487:       if (i>=low && i<high) px[i-low] = t;
488:     }
489:     VecRestoreArray(x,&px);
490:   } else {
491:     VecSetRandom(x,bv->rand);
492:   }
493:   BVRestoreColumn(bv,j,&x);
494:   PetscLogEventEnd(BV_SetRandom,bv,0,0,0);
495:   PetscObjectStateIncrease((PetscObject)bv);
496:   return(0);
497: }

501: /*@
502:    BVMatMult - Computes the matrix-vector product for each column, Y=A*V.

504:    Neighbor-wise Collective on Mat and BV

506:    Input Parameters:
507: +  V - basis vectors context
508: -  A - the matrix

510:    Output Parameter:
511: .  Y - the result

513:    Note:
514:    Both V and Y must be distributed in the same manner. Only active columns
515:    (excluding the leading ones) are processed.
516:    In the result Y, columns are overwritten starting from the leading ones.

518:    It is possible to choose whether the computation is done column by column
519:    or as a Mat-Mat product, see BVSetMatMultMethod().

521:    Level: beginner

523: .seealso: BVCopy(), BVSetActiveColumns(), BVMatMultColumn(), BVMatMultHermitianTranspose(), BVSetMatMultMethod()
524: @*/
525: PetscErrorCode BVMatMult(BV V,Mat A,BV Y)
526: {

532:   BVCheckSizes(V,1);
537:   BVCheckSizes(Y,3);
540:   if (V->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension V %D, Y %D",V->n,Y->n);
541:   if (V->k-V->l>Y->m-Y->l) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Y has %D non-leading columns, not enough to store %D columns",Y->m-Y->l,V->k-V->l);

543:   PetscLogEventBegin(BV_MatMult,V,A,Y,0);
544:   (*V->ops->matmult)(V,A,Y);
545:   PetscLogEventEnd(BV_MatMult,V,A,Y,0);
546:   return(0);
547: }

551: /*@
552:    BVMatMultHermitianTranspose - Computes the matrix-vector product with the
553:    conjugate transpose of a matrix for each column, Y=A^H*V.

555:    Neighbor-wise Collective on Mat and BV

557:    Input Parameters:
558: +  V - basis vectors context
559: -  A - the matrix

561:    Output Parameter:
562: .  Y - the result

564:    Note:
565:    Both V and Y must be distributed in the same manner. Only active columns
566:    (excluding the leading ones) are processed.
567:    In the result Y, columns are overwritten starting from the leading ones.

569:    As opposed to BVMatMult(), this operation is always done column by column,
570:    with a sequence of calls to MatMultHermitianTranspose().

572:    Level: beginner

574: .seealso: BVCopy(), BVSetActiveColumns(), BVMatMult(), BVMatMultColumn()
575: @*/
576: PetscErrorCode BVMatMultHermitianTranspose(BV V,Mat A,BV Y)
577: {
579:   PetscInt       j;
580:   Vec            z,f;

585:   BVCheckSizes(V,1);
590:   BVCheckSizes(Y,3);
593:   if (V->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension V %D, Y %D",V->n,Y->n);
594:   if (V->k-V->l>Y->m-Y->l) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Y has %D non-leading columns, not enough to store %D columns",Y->m-Y->l,V->k-V->l);

596:   PetscLogEventBegin(BV_MatMult,V,A,Y,0);
597:   for (j=0;j<V->k-V->l;j++) {
598:     BVGetColumn(V,V->l+j,&z);
599:     BVGetColumn(Y,Y->l+j,&f);
600:     MatMultHermitianTranspose(A,z,f);
601:     BVRestoreColumn(V,V->l+j,&z);
602:     BVRestoreColumn(Y,Y->l+j,&f);
603:   }
604:   PetscLogEventEnd(BV_MatMult,V,A,Y,0);
605:   return(0);
606: }

610: /*@
611:    BVMatMultColumn - Computes the matrix-vector product for a specified
612:    column, storing the result in the next column: v_{j+1}=A*v_j.

614:    Neighbor-wise Collective on Mat and BV

616:    Input Parameters:
617: +  V - basis vectors context
618: .  A - the matrix
619: -  j - the column

621:    Output Parameter:
622: .  Y - the result

624:    Level: beginner

626: .seealso: BVMatMult()
627: @*/
628: PetscErrorCode BVMatMultColumn(BV V,Mat A,PetscInt j)
629: {
631:   Vec            vj,vj1;

636:   BVCheckSizes(V,1);
639:   if (j<0) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative");
640:   if (j+1>=V->m) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Result should go in index j+1=%D but BV only has %D columns",j+1,V->m);

642:   PetscLogEventBegin(BV_MatMultVec,V,A,0,0);
643:   BVGetColumn(V,j,&vj);
644:   BVGetColumn(V,j+1,&vj1);
645:   MatMult(A,vj,vj1);
646:   BVRestoreColumn(V,j,&vj);
647:   BVRestoreColumn(V,j+1,&vj1);
648:   PetscLogEventEnd(BV_MatMultVec,V,A,0,0);
649:   return(0);
650: }

slepc-3.7.4/src/sys/classes/bv/interface/bvregis.c0000644000175000017500000000343613107004621021407 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcbv.h" I*/ PETSC_EXTERN PetscErrorCode BVCreate_Vecs(BV); PETSC_EXTERN PetscErrorCode BVCreate_Contiguous(BV); PETSC_EXTERN PetscErrorCode BVCreate_Svec(BV); PETSC_EXTERN PetscErrorCode BVCreate_Mat(BV); #undef __FUNCT__ #define __FUNCT__ "BVRegisterAll" /*@C BVRegisterAll - Registers all of the storage variants in the BV package. Not Collective Level: advanced .seealso: BVRegister() @*/ PetscErrorCode BVRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (BVRegisterAllCalled) PetscFunctionReturn(0); BVRegisterAllCalled = PETSC_TRUE; ierr = BVRegister(BVVECS,BVCreate_Vecs);CHKERRQ(ierr); ierr = BVRegister(BVCONTIGUOUS,BVCreate_Contiguous);CHKERRQ(ierr); ierr = BVRegister(BVSVEC,BVCreate_Svec);CHKERRQ(ierr); ierr = BVRegister(BVMAT,BVCreate_Mat);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/interface/bvbasic.c.html0000644000175000017500000034764013107004621022332 0ustar jromanjroman
Actual source code: bvbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Basic BV routines.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>      /*I "slepcbv.h" I*/

 26: PetscBool         BVRegisterAllCalled = PETSC_FALSE;
 27: PetscFunctionList BVList = 0;

 31: /*@C
 32:    BVSetType - Selects the type for the BV object.

 34:    Logically Collective on BV

 36:    Input Parameter:
 37: +  bv   - the basis vectors context
 38: -  type - a known type

 40:    Options Database Key:
 41: .  -bv_type <type> - Sets BV type

 43:    Level: intermediate

 45: .seealso: BVGetType()
 46: @*/
 47: PetscErrorCode BVSetType(BV bv,BVType type)
 48: {
 49:   PetscErrorCode ierr,(*r)(BV);
 50:   PetscBool      match;


 56:   PetscObjectTypeCompare((PetscObject)bv,type,&match);
 57:   if (match) return(0);

 59:    PetscFunctionListFind(BVList,type,&r);
 60:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested BV type %s",type);

 62:   if (bv->ops->destroy) { (*bv->ops->destroy)(bv); }
 63:   PetscMemzero(bv->ops,sizeof(struct _BVOps));

 65:   PetscObjectChangeTypeName((PetscObject)bv,type);
 66:   if (bv->n < 0 && bv->N < 0) {
 67:     bv->ops->create = r;
 68:   } else {
 69:     PetscLogEventBegin(BV_Create,bv,0,0,0);
 70:     (*r)(bv);
 71:     PetscLogEventEnd(BV_Create,bv,0,0,0);
 72:   }
 73:   return(0);
 74: }

 78: /*@C
 79:    BVGetType - Gets the BV type name (as a string) from the BV context.

 81:    Not Collective

 83:    Input Parameter:
 84: .  bv - the basis vectors context

 86:    Output Parameter:
 87: .  name - name of the type of basis vectors

 89:    Level: intermediate

 91: .seealso: BVSetType()
 92: @*/
 93: PetscErrorCode BVGetType(BV bv,BVType *type)
 94: {
 98:   *type = ((PetscObject)bv)->type_name;
 99:   return(0);
100: }

104: /*@
105:    BVSetSizes - Sets the local and global sizes, and the number of columns.

107:    Collective on BV

109:    Input Parameters:
110: +  bv - the basis vectors
111: .  n  - the local size (or PETSC_DECIDE to have it set)
112: .  N  - the global size (or PETSC_DECIDE)
113: -  m  - the number of columns

115:    Notes:
116:    n and N cannot be both PETSC_DECIDE.
117:    If one processor calls this with N of PETSC_DECIDE then all processors must,
118:    otherwise the program will hang.

120:    Level: beginner

122: .seealso: BVSetSizesFromVec(), BVGetSizes(), BVResize()
123: @*/
124: PetscErrorCode BVSetSizes(BV bv,PetscInt n,PetscInt N,PetscInt m)
125: {
127:   PetscInt       ma;

133:   if (N >= 0 && n > N) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Local size %D cannot be larger than global size %D",n,N);
134:   if (m <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Number of columns %D must be positive",m);
135:   if ((bv->n >= 0 || bv->N >= 0) && (bv->n != n || bv->N != N)) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot change/reset vector sizes to %D local %D global after previously setting them to %D local %D global",n,N,bv->n,bv->N);
136:   if (bv->m > 0 && bv->m != m) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot change the number of columns to %D after previously setting it to %D; use BVResize()",m,bv->m);
137:   bv->n = n;
138:   bv->N = N;
139:   bv->m = m;
140:   bv->k = m;
141:   if (!bv->t) {  /* create template vector and get actual dimensions */
142:     VecCreate(PetscObjectComm((PetscObject)bv),&bv->t);
143:     VecSetSizes(bv->t,bv->n,bv->N);
144:     VecSetFromOptions(bv->t);
145:     VecGetSize(bv->t,&bv->N);
146:     VecGetLocalSize(bv->t,&bv->n);
147:     if (bv->matrix) {  /* check compatible dimensions of user-provided matrix */
148:       MatGetLocalSize(bv->matrix,&ma,NULL);
149:       if (bv->n!=ma) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Local dimension %D does not match that of matrix given at BVSetMatrix %D",bv->n,ma);
150:     }
151:   }
152:   if (bv->ops->create) {
153:     PetscLogEventBegin(BV_Create,bv,0,0,0);
154:     (*bv->ops->create)(bv);
155:     PetscLogEventEnd(BV_Create,bv,0,0,0);
156:     bv->ops->create = 0;
157:     bv->defersfo = PETSC_FALSE;
158:   }
159:   return(0);
160: }

164: /*@
165:    BVSetSizesFromVec - Sets the local and global sizes, and the number of columns.
166:    Local and global sizes are specified indirectly by passing a template vector.

168:    Collective on BV

170:    Input Parameters:
171: +  bv - the basis vectors
172: .  t  - the template vector
173: -  m  - the number of columns

175:    Level: beginner

177: .seealso: BVSetSizes(), BVGetSizes(), BVResize()
178: @*/
179: PetscErrorCode BVSetSizesFromVec(BV bv,Vec t,PetscInt m)
180: {
182:   PetscInt       ma;

189:   if (m <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Number of columns %D must be positive",m);
190:   if (bv->t) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Template vector was already set by a previous call to BVSetSizes/FromVec");
191:   VecGetSize(t,&bv->N);
192:   VecGetLocalSize(t,&bv->n);
193:   if (bv->matrix) {  /* check compatible dimensions of user-provided matrix */
194:     MatGetLocalSize(bv->matrix,&ma,NULL);
195:     if (bv->n!=ma) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Local dimension %D does not match that of matrix given at BVSetMatrix %D",bv->n,ma);
196:   }
197:   bv->m = m;
198:   bv->k = m;
199:   bv->t = t;
200:   PetscObjectReference((PetscObject)t);
201:   if (bv->ops->create) {
202:     (*bv->ops->create)(bv);
203:     bv->ops->create = 0;
204:   }
205:   return(0);
206: }

210: /*@
211:    BVGetSizes - Returns the local and global sizes, and the number of columns.

213:    Not Collective

215:    Input Parameter:
216: .  bv - the basis vectors

218:    Output Parameters:
219: +  n  - the local size
220: .  N  - the global size
221: -  m  - the number of columns

223:    Note:
224:    Normal usage requires that bv has already been given its sizes, otherwise
225:    the call fails. However, this function can also be used to determine if
226:    a BV object has been initialized completely (sizes and type). For this,
227:    call with n=NULL and N=NULL, then a return value of m=0 indicates that
228:    the BV object is not ready for use yet.

230:    Level: beginner

232: .seealso: BVSetSizes(), BVSetSizesFromVec()
233: @*/
234: PetscErrorCode BVGetSizes(BV bv,PetscInt *n,PetscInt *N,PetscInt *m)
235: {
237:   if (!bv) {
238:     if (m && !n && !N) *m = 0;
239:     return(0);
240:   }
242:   if (n || N) BVCheckSizes(bv,1);
243:   if (n) *n = bv->n;
244:   if (N) *N = bv->N;
245:   if (m) *m = bv->m;
246:   if (m && !n && !N && !((PetscObject)bv)->type_name) *m = 0;
247:   return(0);
248: }

252: /*@
253:    BVSetNumConstraints - Set the number of constraints.

255:    Logically Collective on BV

257:    Input Parameters:
258: +  V  - basis vectors
259: -  nc - number of constraints

261:    Notes:
262:    This function sets the number of constraints to nc and marks all remaining
263:    columns as regular. Normal user would call BVInsertConstraints() instead.

265:    If nc is smaller than the previously set value, then some of the constraints
266:    are discarded. In particular, using nc=0 removes all constraints preserving
267:    the content of regular columns.

269:    Level: developer

271: .seealso: BVInsertConstraints()
272: @*/
273: PetscErrorCode BVSetNumConstraints(BV V,PetscInt nc)
274: {
276:   PetscInt       total,diff,i;
277:   Vec            x,y;

282:   if (nc<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Number of constraints (given %D) cannot be negative",nc);
284:   BVCheckSizes(V,1);
285:   if (V->ci[0]!=-V->nc-1 || V->ci[1]!=-V->nc-1) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Cannot call BVSetNumConstraints after BVGetColumn");

287:   diff = nc-V->nc;
288:   if (!diff) return(0);
289:   total = V->nc+V->m;
290:   if (total-nc<=0) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Not enough columns for the given nc value");
291:   if (diff<0) {  /* lessen constraints, shift contents of BV */
292:     for (i=0;i<V->m;i++) {
293:       BVGetColumn(V,i,&x);
294:       BVGetColumn(V,i+diff,&y);
295:       VecCopy(x,y);
296:       BVRestoreColumn(V,i,&x);
297:       BVRestoreColumn(V,i+diff,&y);
298:     }
299:   }
300:   V->nc = nc;
301:   V->ci[0] = -V->nc-1;
302:   V->ci[1] = -V->nc-1;
303:   V->l = 0;
304:   V->m = total-nc;
305:   V->k = V->m;
306:   PetscObjectStateIncrease((PetscObject)V);
307:   return(0);
308: }

312: /*@
313:    BVGetNumConstraints - Returns the number of constraints.

315:    Not Collective

317:    Input Parameter:
318: .  bv - the basis vectors

320:    Output Parameters:
321: .  nc - the number of constraints

323:    Level: advanced

325: .seealso: BVGetSizes(), BVInsertConstraints()
326: @*/
327: PetscErrorCode BVGetNumConstraints(BV bv,PetscInt *nc)
328: {
332:   *nc = bv->nc;
333:   return(0);
334: }

338: /*@
339:    BVResize - Change the number of columns.

341:    Collective on BV

343:    Input Parameters:
344: +  bv   - the basis vectors
345: .  m    - the new number of columns
346: -  copy - a flag indicating whether current values should be kept

348:    Note:
349:    Internal storage is reallocated. If the copy flag is set to true, then
350:    the contents are copied to the leading part of the new space.

352:    Level: advanced

354: .seealso: BVSetSizes(), BVSetSizesFromVec()
355: @*/
356: PetscErrorCode BVResize(BV bv,PetscInt m,PetscBool copy)
357: {
359:   PetscReal      *omega;
360:   PetscInt       i;

367:   if (m <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Number of columns %D must be positive",m);
368:   if (bv->nc) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Cannot resize a BV with constraints");
369:   if (bv->m == m) return(0);

371:   PetscLogEventBegin(BV_Create,bv,0,0,0);
372:   (*bv->ops->resize)(bv,m,copy);
373:   PetscFree2(bv->h,bv->c);
374:   if (bv->omega) {
375:     PetscMalloc1(m,&omega);
376:     PetscLogObjectMemory((PetscObject)bv,m*sizeof(PetscReal));
377:     for (i=0;i<m;i++) omega[i] = 1.0;
378:     if (copy) {
379:       PetscMemcpy(omega,bv->omega,PetscMin(m,bv->m)*sizeof(PetscReal));
380:     }
381:     PetscFree(bv->omega);
382:     bv->omega = omega;
383:   }
384:   bv->m = m;
385:   bv->k = PetscMin(bv->k,m);
386:   bv->l = PetscMin(bv->l,m);
387:   PetscLogEventEnd(BV_Create,bv,0,0,0);
388:   return(0);
389: }

393: /*@
394:    BVSetActiveColumns - Specify the columns that will be involved in operations.

396:    Logically Collective on BV

398:    Input Parameters:
399: +  bv - the basis vectors context
400: .  l  - number of leading columns
401: -  k  - number of active columns

403:    Notes:
404:    In operations such as BVMult() or BVDot(), only the first k columns are
405:    considered. This is useful when the BV is filled from left to right, so
406:    the last m-k columns do not have relevant information.

408:    Also in operations such as BVMult() or BVDot(), the first l columns are
409:    normally not included in the computation. See the manpage of each
410:    operation.

412:    In orthogonalization operations, the first l columns are treated
413:    differently: they participate in the orthogonalization but the computed
414:    coefficients are not stored.

416:    Level: intermediate

418: .seealso: BVGetActiveColumns(), BVSetSizes()
419: @*/
420: PetscErrorCode BVSetActiveColumns(BV bv,PetscInt l,PetscInt k)
421: {
426:   BVCheckSizes(bv,1);
427:   if (k==PETSC_DECIDE || k==PETSC_DEFAULT) {
428:     bv->k = bv->m;
429:   } else {
430:     if (k<0 || k>bv->m) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of k. Must be between 0 and m");
431:     bv->k = k;
432:   }
433:   if (l==PETSC_DECIDE || l==PETSC_DEFAULT) {
434:     bv->l = 0;
435:   } else {
436:     if (l<0 || l>bv->k) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of l. Must be between 0 and k");
437:     bv->l = l;
438:   }
439:   return(0);
440: }

444: /*@
445:    BVGetActiveColumns - Returns the current active dimensions.

447:    Not Collective

449:    Input Parameter:
450: .  bv - the basis vectors context

452:    Output Parameter:
453: +  l  - number of leading columns
454: -  k  - number of active columns

456:    Level: intermediate

458: .seealso: BVSetActiveColumns()
459: @*/
460: PetscErrorCode BVGetActiveColumns(BV bv,PetscInt *l,PetscInt *k)
461: {
464:   if (l) *l = bv->l;
465:   if (k) *k = bv->k;
466:   return(0);
467: }

471: /*@
472:    BVSetMatrix - Specifies the inner product to be used in orthogonalization.

474:    Collective on BV

476:    Input Parameters:
477: +  bv    - the basis vectors context
478: .  B     - a symmetric matrix (may be NULL)
479: -  indef - a flag indicating if the matrix is indefinite

481:    Notes:
482:    This is used to specify a non-standard inner product, whose matrix
483:    representation is given by B. Then, all inner products required during
484:    orthogonalization are computed as (x,y)_B=y^H*B*x rather than the
485:    standard form (x,y)=y^H*x.

487:    Matrix B must be real symmetric (or complex Hermitian). A genuine inner
488:    product requires that B is also positive (semi-)definite. However, we
489:    also allow for an indefinite B (setting indef=PETSC_TRUE), in which
490:    case the orthogonalization uses an indefinite inner product.

492:    This affects operations BVDot(), BVNorm(), BVOrthogonalize(), and variants.

494:    Setting B=NULL has the same effect as if the identity matrix was passed.

496:    Level: advanced

498: .seealso: BVGetMatrix(), BVDot(), BVNorm(), BVOrthogonalize()
499: @*/
500: PetscErrorCode BVSetMatrix(BV bv,Mat B,PetscBool indef)
501: {
503:   PetscInt       m,n;

508:   if (B) {
510:     MatGetLocalSize(B,&m,&n);
511:     if (m!=n) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Matrix must be square");
512:     if (bv->m && bv->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension BV %D, Mat %D",bv->n,n);
513:   }
514:   MatDestroy(&bv->matrix);
515:   if (B) PetscObjectReference((PetscObject)B);
516:   bv->matrix = B;
517:   bv->indef  = indef;
518:   if (B && !bv->Bx) {
519:     MatCreateVecs(B,&bv->Bx,NULL);
520:     PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->Bx);
521:   }
522:   return(0);
523: }

527: /*@
528:    BVGetMatrix - Retrieves the matrix representation of the inner product.

530:    Not collective, though a parallel Mat may be returned

532:    Input Parameter:
533: .  bv    - the basis vectors context

535:    Output Parameter:
536: +  B     - the matrix of the inner product (may be NULL)
537: -  indef - the flag indicating if the matrix is indefinite

539:    Level: advanced

541: .seealso: BVSetMatrix()
542: @*/
543: PetscErrorCode BVGetMatrix(BV bv,Mat *B,PetscBool *indef)
544: {
547:   if (B)     *B     = bv->matrix;
548:   if (indef) *indef = bv->indef;
549:   return(0);
550: }

554: /*@
555:    BVApplyMatrix - Multiplies a vector by the matrix representation of the
556:    inner product.

558:    Neighbor-wise Collective on BV and Vec

560:    Input Parameter:
561: +  bv - the basis vectors context
562: -  x  - the vector

564:    Output Parameter:
565: .  y  - the result

567:    Note:
568:    If no matrix was specified this function copies the vector.

570:    Level: advanced

572: .seealso: BVSetMatrix(), BVApplyMatrixBV()
573: @*/
574: PetscErrorCode BVApplyMatrix(BV bv,Vec x,Vec y)
575: {

582:   if (bv->matrix) {
583:     BV_IPMatMult(bv,x);
584:     VecCopy(bv->Bx,y);
585:   } else {
586:     VecCopy(x,y);
587:   }
588:   return(0);
589: }

593: /*@
594:    BVApplyMatrixBV - Multiplies the BV vectors by the matrix representation
595:    of the inner product.

597:    Neighbor-wise Collective on BV

599:    Input Parameter:
600: .  X - the basis vectors context

602:    Output Parameter:
603: .  Y - the basis vectors to store the result (optional)

605:    Note:
606:    This function computes Y = B*X, where B is the matrix given with
607:    BVSetMatrix(). This operation is computed as in BVMatMult().
608:    If no matrix was specified, then it just copies Y = X.

610:    If no Y is given, the result is stored internally in the cached BV.

612:    Level: developer

614: .seealso: BVSetMatrix(), BVApplyMatrix(), BVMatMult(), BVGetCachedBV()
615: @*/
616: PetscErrorCode BVApplyMatrixBV(BV X,BV Y)
617: {

622:   if (Y) {
624:     if (X->matrix) {
625:       BVMatMult(X,X->matrix,Y);
626:     } else {
627:       BVCopy(X,Y);
628:     }
629:   } else {
630:     BV_IPMatMultBV(X);
631:   }
632:   return(0);
633: }

637: /*@
638:    BVGetCachedBV - Returns a BV object stored internally that holds the
639:    result of B*X after a call to BVApplyMatrixBV().

641:    Not collective

643:    Input Parameter:
644: .  bv    - the basis vectors context

646:    Output Parameter:
647: .  cached - the cached BV

649:    Note:
650:    The function will return a NULL if BVApplyMatrixBV() was not called yet.

652:    Level: developer

654: .seealso: BVApplyMatrixBV()
655: @*/
656: PetscErrorCode BVGetCachedBV(BV bv,BV *cached)
657: {
661:   *cached = bv->cached;
662:   return(0);
663: }

667: /*@
668:    BVSetSignature - Sets the signature matrix to be used in orthogonalization.

670:    Logically Collective on BV

672:    Input Parameter:
673: +  bv    - the basis vectors context
674: -  omega - a vector representing the diagonal of the signature matrix

676:    Note:
677:    The signature matrix Omega = V'*B*V is relevant only for an indefinite B.

679:    Level: developer

681: .seealso: BVSetMatrix(), BVGetSignature()
682: @*/
683: PetscErrorCode BVSetSignature(BV bv,Vec omega)
684: {
685:   PetscErrorCode    ierr;
686:   PetscInt          i,n;
687:   const PetscScalar *pomega;

691:   BVCheckSizes(bv,1);

695:   VecGetSize(omega,&n);
696:   if (n!=bv->k) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_SIZ,"Vec argument has %D elements, should be %D",n,bv->k);
697:   BV_AllocateSignature(bv);
698:   if (bv->indef) {
699:     VecGetArrayRead(omega,&pomega);
700:     for (i=0;i<n;i++) bv->omega[bv->nc+i] = PetscRealPart(pomega[i]);
701:     VecRestoreArrayRead(omega,&pomega);
702:   } else {
703:     PetscInfo(bv,"Ignoring signature because BV is not indefinite\n");
704:   }
705:   return(0);
706: }

710: /*@
711:    BVGetSignature - Retrieves the signature matrix from last orthogonalization.

713:    Not collective

715:    Input Parameter:
716: .  bv    - the basis vectors context

718:    Output Parameter:
719: .  omega - a vector representing the diagonal of the signature matrix

721:    Note:
722:    The signature matrix Omega = V'*B*V is relevant only for an indefinite B.

724:    Level: developer

726: .seealso: BVSetMatrix(), BVSetSignature()
727: @*/
728: PetscErrorCode BVGetSignature(BV bv,Vec omega)
729: {
731:   PetscInt       i,n;
732:   PetscScalar    *pomega;

736:   BVCheckSizes(bv,1);

740:   VecGetSize(omega,&n);
741:   if (n!=bv->k) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_SIZ,"Vec argument has %D elements, should be %D",n,bv->k);
742:   if (bv->indef && bv->omega) {
743:     VecGetArray(omega,&pomega);
744:     for (i=0;i<n;i++) pomega[i] = bv->omega[bv->nc+i];
745:     VecRestoreArray(omega,&pomega);
746:   } else {
747:     VecSet(omega,1.0);
748:   }
749:   return(0);
750: }

754: /*@
755:    BVSetRandomContext - Sets the PetscRandom object associated with the BV,
756:    to be used in operations that need random numbers.

758:    Collective on BV

760:    Input Parameters:
761: +  bv   - the basis vectors context
762: -  rand - the random number generator context

764:    Level: advanced

766: .seealso: BVGetRandomContext(), BVSetRandom(), BVSetRandomColumn()
767: @*/
768: PetscErrorCode BVSetRandomContext(BV bv,PetscRandom rand)
769: {

776:   PetscObjectReference((PetscObject)rand);
777:   PetscRandomDestroy(&bv->rand);
778:   bv->rand = rand;
779:   PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->rand);
780:   return(0);
781: }

785: /*@
786:    BVGetRandomContext - Gets the PetscRandom object associated with the BV.

788:    Not Collective

790:    Input Parameter:
791: .  bv - the basis vectors context

793:    Output Parameter:
794: .  rand - the random number generator context

796:    Level: advanced

798: .seealso: BVSetRandomContext(), BVSetRandom(), BVSetRandomColumn()
799: @*/
800: PetscErrorCode BVGetRandomContext(BV bv,PetscRandom* rand)
801: {

807:   if (!bv->rand) {
808:     PetscRandomCreate(PetscObjectComm((PetscObject)bv),&bv->rand);
809:     PetscLogObjectParent((PetscObject)bv,(PetscObject)bv->rand);
810:     if (bv->rrandom) {
811:       PetscRandomSetSeed(bv->rand,0x12345678);
812:       PetscRandomSeed(bv->rand);
813:     }
814:   }
815:   *rand = bv->rand;
816:   return(0);
817: }

821: /*@
822:    BVSetFromOptions - Sets BV options from the options database.

824:    Collective on BV

826:    Input Parameter:
827: .  bv - the basis vectors context

829:    Level: beginner
830: @*/
831: PetscErrorCode BVSetFromOptions(BV bv)
832: {
834:   char           type[256];
835:   PetscBool      flg;
836:   PetscReal      r;

840:   BVRegisterAll();
841:   PetscObjectOptionsBegin((PetscObject)bv);
842:     PetscOptionsFList("-bv_type","Basis Vectors type","BVSetType",BVList,(char*)(((PetscObject)bv)->type_name?((PetscObject)bv)->type_name:BVSVEC),type,256,&flg);
843:     if (flg) {
844:       BVSetType(bv,type);
845:     }
846:     /*
847:       Set the type if it was never set.
848:     */
849:     if (!((PetscObject)bv)->type_name) {
850:       BVSetType(bv,BVSVEC);
851:     }

853:     PetscOptionsEnum("-bv_orthog_type","Orthogonalization method","BVSetOrthogonalization",BVOrthogTypes,(PetscEnum)bv->orthog_type,(PetscEnum*)&bv->orthog_type,NULL);
854:     PetscOptionsEnum("-bv_orthog_refine","Iterative refinement mode during orthogonalization","BVSetOrthogonalization",BVOrthogRefineTypes,(PetscEnum)bv->orthog_ref,(PetscEnum*)&bv->orthog_ref,NULL);
855:     PetscOptionsEnum("-bv_orthog_block","Block orthogonalization method","BVSetOrthogonalization",BVOrthogBlockTypes,(PetscEnum)bv->orthog_block,(PetscEnum*)&bv->orthog_block,NULL);
856:     r = bv->orthog_eta;
857:     PetscOptionsReal("-bv_orthog_eta","Parameter of iterative refinement during orthogonalization","BVSetOrthogonalization",r,&r,NULL);
858:     BVSetOrthogonalization(bv,bv->orthog_type,bv->orthog_ref,r,bv->orthog_block);

860:     PetscOptionsEnum("-bv_matmult","Method for BVMatMult","BVSetMatMultMethod",BVMatMultTypes,(PetscEnum)bv->vmm,(PetscEnum*)&bv->vmm,NULL);

862:     /* undocumented option to generate random vectors that are independent of the number of processes */
863:     PetscOptionsGetBool(NULL,NULL,"-bv_reproducible_random",&bv->rrandom,NULL);

865:     if (!bv->rand) { BVGetRandomContext(bv,&bv->rand); }
866:     PetscRandomSetFromOptions(bv->rand);

868:     if (bv->ops->create) bv->defersfo = PETSC_TRUE;   /* defer call to setfromoptions */
869:     else if (bv->ops->setfromoptions) {
870:       (*bv->ops->setfromoptions)(PetscOptionsObject,bv);
871:     }
872:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)bv);
873:   PetscOptionsEnd();
874:   return(0);
875: }

879: /*@
880:    BVSetOrthogonalization - Specifies the method used for the orthogonalization of
881:    vectors (classical or modified Gram-Schmidt with or without refinement), and
882:    for the block-orthogonalization (simultaneous orthogonalization of a set of
883:    vectors).

885:    Logically Collective on BV

887:    Input Parameters:
888: +  bv     - the basis vectors context
889: .  type   - the method of vector orthogonalization
890: .  refine - type of refinement
891: .  eta    - parameter for selective refinement
892: -  block  - the method of block orthogonalization

894:    Options Database Keys:
895: +  -bv_orthog_type <type> - Where <type> is cgs for Classical Gram-Schmidt orthogonalization
896:                          (default) or mgs for Modified Gram-Schmidt orthogonalization
897: .  -bv_orthog_refine <ref> - Where <ref> is one of never, ifneeded (default) or always
898: .  -bv_orthog_eta <eta> -  For setting the value of eta
899: -  -bv_orthog_block <block> - Where <block> is the block-orthogonalization method

901:    Notes:
902:    The default settings work well for most problems.

904:    The parameter eta should be a real value between 0 and 1 (or PETSC_DEFAULT).
905:    The value of eta is used only when the refinement type is "ifneeded".

907:    When using several processors, MGS is likely to result in bad scalability.

909:    If the method set for block orthogonalization is GS, then the computation
910:    is done column by column with the vector orthogonalization.

912:    Level: advanced

914: .seealso: BVOrthogonalizeColumn(), BVGetOrthogonalization(), BVOrthogType, BVOrthogRefineType, BVOrthogBlockType
915: @*/
916: PetscErrorCode BVSetOrthogonalization(BV bv,BVOrthogType type,BVOrthogRefineType refine,PetscReal eta,BVOrthogBlockType block)
917: {
924:   switch (type) {
925:     case BV_ORTHOG_CGS:
926:     case BV_ORTHOG_MGS:
927:       bv->orthog_type = type;
928:       break;
929:     default:
930:       SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown orthogonalization type");
931:   }
932:   switch (refine) {
933:     case BV_ORTHOG_REFINE_NEVER:
934:     case BV_ORTHOG_REFINE_IFNEEDED:
935:     case BV_ORTHOG_REFINE_ALWAYS:
936:       bv->orthog_ref = refine;
937:       break;
938:     default:
939:       SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown refinement type");
940:   }
941:   if (eta == PETSC_DEFAULT) {
942:     bv->orthog_eta = 0.7071;
943:   } else {
944:     if (eta <= 0.0 || eta > 1.0) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Invalid eta value");
945:     bv->orthog_eta = eta;
946:   }
947:   switch (block) {
948:     case BV_ORTHOG_BLOCK_GS:
949:     case BV_ORTHOG_BLOCK_CHOL:
950:       bv->orthog_block = block;
951:       break;
952:     default:
953:       SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown block orthogonalization type");
954:   }
955:   return(0);
956: }

960: /*@
961:    BVGetOrthogonalization - Gets the orthogonalization settings from the BV object.

963:    Not Collective

965:    Input Parameter:
966: .  bv - basis vectors context

968:    Output Parameter:
969: +  type   - the method of vector orthogonalization
970: .  refine - type of refinement
971: .  eta    - parameter for selective refinement
972: -  block  - the method of block orthogonalization

974:    Level: advanced

976: .seealso: BVOrthogonalizeColumn(), BVSetOrthogonalization(), BVOrthogType, BVOrthogRefineType, BVOrthogBlockType
977: @*/
978: PetscErrorCode BVGetOrthogonalization(BV bv,BVOrthogType *type,BVOrthogRefineType *refine,PetscReal *eta,BVOrthogBlockType *block)
979: {
982:   if (type)   *type   = bv->orthog_type;
983:   if (refine) *refine = bv->orthog_ref;
984:   if (eta)    *eta    = bv->orthog_eta;
985:   if (block)  *block  = bv->orthog_block;
986:   return(0);
987: }

991: /*@
992:    BVSetMatMultMethod - Specifies the method used for the BVMatMult() operation.

994:    Logically Collective on BV

996:    Input Parameters:
997: +  bv     - the basis vectors context
998: -  method - the method for the BVMatMult() operation

1000:    Options Database Keys:
1001: .  -bv_matmult <meth> - choose one of the methods: vecs, mat, mat_save

1003:    Note:
1004:    Allowed values are:
1005: +  BV_MATMULT_VECS - perform a matrix-vector multiply per each column
1006: .  BV_MATMULT_MAT - carry out a MatMatMult() product with a dense matrix
1007: -  BV_MATMULT_MAT_SAVE - call MatMatMult() and keep auxiliary matrices
1008:    The default is BV_MATMULT_MAT.

1010:    Level: advanced

1012: .seealso: BVMatMult(), BVGetMatMultMethod(), BVMatMultType
1013: @*/
1014: PetscErrorCode BVSetMatMultMethod(BV bv,BVMatMultType method)
1015: {
1019:   switch (method) {
1020:     case BV_MATMULT_VECS:
1021:     case BV_MATMULT_MAT:
1022:     case BV_MATMULT_MAT_SAVE:
1023:       bv->vmm = method;
1024:       break;
1025:     default:
1026:       SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Unknown matmult method");
1027:   }
1028:   return(0);
1029: }

1033: /*@
1034:    BVGetMatMultMethod - Gets the method used for the BVMatMult() operation.

1036:    Not Collective

1038:    Input Parameter:
1039: .  bv - basis vectors context

1041:    Output Parameter:
1042: .  method - the method for the BVMatMult() operation

1044:    Level: advanced

1046: .seealso: BVMatMult(), BVSetMatMultMethod(), BVMatMultType
1047: @*/
1048: PetscErrorCode BVGetMatMultMethod(BV bv,BVMatMultType *method)
1049: {
1053:   *method = bv->vmm;
1054:   return(0);
1055: }

1059: /*@
1060:    BVGetColumn - Returns a Vec object that contains the entries of the
1061:    requested column of the basis vectors object.

1063:    Logically Collective on BV

1065:    Input Parameters:
1066: +  bv - the basis vectors context
1067: -  j  - the index of the requested column

1069:    Output Parameter:
1070: .  v  - vector containing the jth column

1072:    Notes:
1073:    The returned Vec must be seen as a reference (not a copy) of the BV
1074:    column, that is, modifying the Vec will change the BV entries as well.

1076:    The returned Vec must not be destroyed. BVRestoreColumn() must be
1077:    called when it is no longer needed. At most, two columns can be fetched,
1078:    that is, this function can only be called twice before the corresponding
1079:    BVRestoreColumn() is invoked.

1081:    A negative index j selects the i-th constraint, where i=-j. Constraints
1082:    should not be modified.

1084:    Level: beginner

1086: .seealso: BVRestoreColumn(), BVInsertConstraints()
1087: @*/
1088: PetscErrorCode BVGetColumn(BV bv,PetscInt j,Vec *v)
1089: {
1091:   PetscInt       l;

1096:   BVCheckSizes(bv,1);
1098:   if (j<0 && -j>bv->nc) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested constraint %D but only %D are available",-j,bv->nc);
1099:   if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested column %D but only %D are available",j,bv->m);
1100:   if (j==bv->ci[0] || j==bv->ci[1]) SETERRQ1(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Column %D already fetched in a previous call to BVGetColumn",j);
1101:   l = BVAvailableVec;
1102:   if (l==-1) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Too many requested columns; you must call BVRestoreColumn for one of the previously fetched columns");
1103:   (*bv->ops->getcolumn)(bv,j,v);
1104:   bv->ci[l] = j;
1105:   PetscObjectStateGet((PetscObject)bv->cv[l],&bv->st[l]);
1106:   PetscObjectGetId((PetscObject)bv->cv[l],&bv->id[l]);
1107:   *v = bv->cv[l];
1108:   return(0);
1109: }

1113: /*@
1114:    BVRestoreColumn - Restore a column obtained with BVGetColumn().

1116:    Logically Collective on BV

1118:    Input Parameters:
1119: +  bv - the basis vectors context
1120: .  j  - the index of the column
1121: -  v  - vector obtained with BVGetColumn()

1123:    Note:
1124:    The arguments must match the corresponding call to BVGetColumn().

1126:    Level: beginner

1128: .seealso: BVGetColumn()
1129: @*/
1130: PetscErrorCode BVRestoreColumn(BV bv,PetscInt j,Vec *v)
1131: {
1132:   PetscErrorCode   ierr;
1133:   PetscObjectId    id;
1134:   PetscObjectState st;
1135:   PetscInt         l;

1140:   BVCheckSizes(bv,1);
1144:   if (j<0 && -j>bv->nc) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested constraint %D but only %D are available",-j,bv->nc);
1145:   if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"You requested column %D but only %D are available",j,bv->m);
1146:   if (j!=bv->ci[0] && j!=bv->ci[1]) SETERRQ1(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Column %D has not been fetched with a call to BVGetColumn",j);
1147:   l = (j==bv->ci[0])? 0: 1;
1148:   PetscObjectGetId((PetscObject)*v,&id);
1149:   if (id!=bv->id[l]) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_WRONG,"Argument 3 is not the same Vec that was obtained with BVGetColumn");
1150:   PetscObjectStateGet((PetscObject)*v,&st);
1151:   if (st!=bv->st[l]) {
1152:     PetscObjectStateIncrease((PetscObject)bv);
1153:   }
1154:   if (bv->ops->restorecolumn) {
1155:     (*bv->ops->restorecolumn)(bv,j,v);
1156:   } else bv->cv[l] = NULL;
1157:   bv->ci[l] = -bv->nc-1;
1158:   bv->st[l] = -1;
1159:   bv->id[l] = 0;
1160:   *v = NULL;
1161:   return(0);
1162: }

1166: /*@C
1167:    BVGetArray - Returns a pointer to a contiguous array that contains this
1168:    processor's portion of the BV data.

1170:    Logically Collective on BV

1172:    Input Parameters:
1173: .  bv - the basis vectors context

1175:    Output Parameter:
1176: .  a  - location to put pointer to the array

1178:    Notes:
1179:    BVRestoreArray() must be called when access to the array is no longer needed.
1180:    This operation may imply a data copy, for BV types that do not store
1181:    data contiguously in memory.

1183:    The pointer will normally point to the first entry of the first column,
1184:    but if the BV has constraints then these go before the regular columns.

1186:    Level: advanced

1188: .seealso: BVRestoreArray(), BVInsertConstraints()
1189: @*/
1190: PetscErrorCode BVGetArray(BV bv,PetscScalar **a)
1191: {

1197:   BVCheckSizes(bv,1);
1198:   (*bv->ops->getarray)(bv,a);
1199:   return(0);
1200: }

1204: /*@C
1205:    BVRestoreArray - Restore the BV object after BVGetArray() has been called.

1207:    Logically Collective on BV

1209:    Input Parameters:
1210: +  bv - the basis vectors context
1211: -  a  - location of pointer to array obtained from BVGetArray()

1213:    Note:
1214:    This operation may imply a data copy, for BV types that do not store
1215:    data contiguously in memory.

1217:    Level: advanced

1219: .seealso: BVGetColumn()
1220: @*/
1221: PetscErrorCode BVRestoreArray(BV bv,PetscScalar **a)
1222: {

1228:   BVCheckSizes(bv,1);
1229:   if (bv->ops->restorearray) {
1230:     (*bv->ops->restorearray)(bv,a);
1231:   }
1232:   if (a) *a = NULL;
1233:   PetscObjectStateIncrease((PetscObject)bv);
1234:   return(0);
1235: }

1239: /*@C
1240:    BVGetArrayRead - Returns a read-only pointer to a contiguous array that
1241:    contains this processor's portion of the BV data.

1243:    Not Collective

1245:    Input Parameters:
1246: .  bv - the basis vectors context

1248:    Output Parameter:
1249: .  a  - location to put pointer to the array

1251:    Notes:
1252:    BVRestoreArrayRead() must be called when access to the array is no
1253:    longer needed. This operation may imply a data copy, for BV types that
1254:    do not store data contiguously in memory.

1256:    The pointer will normally point to the first entry of the first column,
1257:    but if the BV has constraints then these go before the regular columns.

1259:    Level: advanced

1261: .seealso: BVRestoreArray(), BVInsertConstraints()
1262: @*/
1263: PetscErrorCode BVGetArrayRead(BV bv,const PetscScalar **a)
1264: {

1270:   BVCheckSizes(bv,1);
1271:   (*bv->ops->getarrayread)(bv,a);
1272:   return(0);
1273: }

1277: /*@C
1278:    BVRestoreArrayRead - Restore the BV object after BVGetArrayRead() has
1279:    been called.

1281:    Logically Collective on BV

1283:    Input Parameters:
1284: +  bv - the basis vectors context
1285: -  a  - location of pointer to array obtained from BVGetArrayRead()

1287:    Level: advanced

1289: .seealso: BVGetColumn()
1290: @*/
1291: PetscErrorCode BVRestoreArrayRead(BV bv,const PetscScalar **a)
1292: {

1298:   BVCheckSizes(bv,1);
1299:   if (bv->ops->restorearrayread) {
1300:     (*bv->ops->restorearrayread)(bv,a);
1301:   }
1302:   if (a) *a = NULL;
1303:   return(0);
1304: }

1308: /*@
1309:    BVCreateVec - Creates a new Vec object with the same type and dimensions
1310:    as the columns of the basis vectors object.

1312:    Collective on BV

1314:    Input Parameter:
1315: .  bv - the basis vectors context

1317:    Output Parameter:
1318: .  v  - the new vector

1320:    Note:
1321:    The user is responsible of destroying the returned vector.

1323:    Level: beginner
1324: @*/
1325: PetscErrorCode BVCreateVec(BV bv,Vec *v)
1326: {

1331:   BVCheckSizes(bv,1);
1333:   VecDuplicate(bv->t,v);
1334:   return(0);
1335: }

1339: PETSC_STATIC_INLINE PetscErrorCode BVDuplicate_Private(BV V,PetscInt m,BV *W)
1340: {

1344:   BVCreate(PetscObjectComm((PetscObject)V),W);
1345:   BVSetSizesFromVec(*W,V->t,m);
1346:   BVSetType(*W,((PetscObject)V)->type_name);
1347:   BVSetMatrix(*W,V->matrix,V->indef);
1348:   BVSetOrthogonalization(*W,V->orthog_type,V->orthog_ref,V->orthog_eta,V->orthog_block);
1349:   (*W)->vmm     = V->vmm;
1350:   (*W)->rrandom = V->rrandom;
1351:   if (V->ops->duplicate) { (*V->ops->duplicate)(V,W); }
1352:   PetscObjectStateIncrease((PetscObject)*W);
1353:   return(0);
1354: }

1358: /*@
1359:    BVDuplicate - Creates a new basis vector object of the same type and
1360:    dimensions as an existing one.

1362:    Collective on BV

1364:    Input Parameter:
1365: .  V - basis vectors context

1367:    Output Parameter:
1368: .  W - location to put the new BV

1370:    Notes:
1371:    The new BV has the same type and dimensions as V, and it shares the same
1372:    template vector. Also, the inner product matrix and orthogonalization
1373:    options are copied.

1375:    BVDuplicate() DOES NOT COPY the entries, but rather allocates storage
1376:    for the new basis vectors. Use BVCopy() to copy the contents.

1378:    Level: intermediate

1380: .seealso: BVDuplicateResize(), BVCreate(), BVSetSizesFromVec(), BVCopy()
1381: @*/
1382: PetscErrorCode BVDuplicate(BV V,BV *W)
1383: {

1389:   BVCheckSizes(V,1);
1391:   BVDuplicate_Private(V,V->m,W);
1392:   return(0);
1393: }

1397: /*@
1398:    BVDuplicateResize - Creates a new basis vector object of the same type and
1399:    dimensions as an existing one, but with possibly different number of columns.

1401:    Collective on BV

1403:    Input Parameter:
1404: +  V - basis vectors context
1405: -  m - the new number of columns

1407:    Output Parameter:
1408: .  W - location to put the new BV

1410:    Note:
1411:    This is equivalent of a call to BVDuplicate() followed by BVResize(). The
1412:    contents of V are not copied to W.

1414:    Level: intermediate

1416: .seealso: BVDuplicate(), BVResize()
1417: @*/
1418: PetscErrorCode BVDuplicateResize(BV V,PetscInt m,BV *W)
1419: {

1425:   BVCheckSizes(V,1);
1428:   BVDuplicate_Private(V,m,W);
1429:   return(0);
1430: }

1434: /*@
1435:    BVCopy - Copies a basis vector object into another one, W <- V.

1437:    Logically Collective on BV

1439:    Input Parameter:
1440: .  V - basis vectors context

1442:    Output Parameter:
1443: .  W - the copy

1445:    Note:
1446:    Both V and W must be distributed in the same manner; local copies are
1447:    done. Only active columns (excluding the leading ones) are copied.
1448:    In the destination W, columns are overwritten starting from the leading ones.
1449:    Constraints are not copied.

1451:    Level: beginner

1453: .seealso: BVCopyVec(), BVCopyColumn(), BVDuplicate(), BVSetActiveColumns()
1454: @*/
1455: PetscErrorCode BVCopy(BV V,BV W)
1456: {

1462:   BVCheckSizes(V,1);
1465:   BVCheckSizes(W,2);
1467:   if (V->n!=W->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension V %D, W %D",V->n,W->n);
1468:   if (V->k-V->l>W->m-W->l) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"W has %D non-leading columns, not enough to store %D columns",W->m-W->l,V->k-V->l);
1469:   if (!V->n) return(0);

1471:   PetscLogEventBegin(BV_Copy,V,W,0,0);
1472:   if (V->indef && V->matrix && V->indef==W->indef && V->matrix==W->matrix) {
1473:     /* copy signature */
1474:     BV_AllocateSignature(W);
1475:     PetscMemcpy(W->omega+W->nc+W->l,V->omega+V->nc+V->l,(V->k-V->l)*sizeof(PetscReal));
1476:   }
1477:   (*V->ops->copy)(V,W);
1478:   PetscLogEventEnd(BV_Copy,V,W,0,0);
1479:   return(0);
1480: }

1484: /*@
1485:    BVCopyVec - Copies one of the columns of a basis vectors object into a Vec.

1487:    Logically Collective on BV

1489:    Input Parameter:
1490: +  V - basis vectors context
1491: -  j - the column number to be copied

1493:    Output Parameter:
1494: .  w - the copied column

1496:    Note:
1497:    Both V and w must be distributed in the same manner; local copies are done.

1499:    Level: beginner

1501: .seealso: BVCopy(), BVCopyColumn(), BVInsertVec()
1502: @*/
1503: PetscErrorCode BVCopyVec(BV V,PetscInt j,Vec w)
1504: {
1506:   PetscInt       n,N;
1507:   Vec            z;

1512:   BVCheckSizes(V,1);

1517:   VecGetSize(w,&N);
1518:   VecGetLocalSize(w,&n);
1519:   if (N!=V->N || n!=V->n) SETERRQ4(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,V->N,V->n);

1521:   PetscLogEventBegin(BV_Copy,V,w,0,0);
1522:   BVGetColumn(V,j,&z);
1523:   VecCopy(z,w);
1524:   BVRestoreColumn(V,j,&z);
1525:   PetscLogEventEnd(BV_Copy,V,w,0,0);
1526:   return(0);
1527: }

1531: /*@
1532:    BVCopyColumn - Copies the values from one of the columns to another one.

1534:    Logically Collective on BV

1536:    Input Parameter:
1537: +  V - basis vectors context
1538: .  j - the number of the source column
1539: -  i - the number of the destination column

1541:    Level: beginner

1543: .seealso: BVCopy(), BVCopyVec()
1544: @*/
1545: PetscErrorCode BVCopyColumn(BV V,PetscInt j,PetscInt i)
1546: {
1548:   Vec            z,w;

1553:   BVCheckSizes(V,1);
1556:   if (j==i) return(0);

1558:   PetscLogEventBegin(BV_Copy,V,0,0,0);
1559:   if (V->omega) V->omega[i] = V->omega[j];
1560:   BVGetColumn(V,j,&z);
1561:   BVGetColumn(V,i,&w);
1562:   VecCopy(z,w);
1563:   BVRestoreColumn(V,j,&z);
1564:   BVRestoreColumn(V,i,&w);
1565:   PetscLogEventEnd(BV_Copy,V,0,0,0);
1566:   return(0);
1567: }

slepc-3.7.4/src/sys/classes/bv/interface/makefile.html0000644000175000017500000000477713107004621022256 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = bvbasic.c bvfunc.c bvops.c bvglobal.c bvblas.c bvorthog.c bvregis.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = BV
LOCDIR   = src/sys/classes/bv/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/bv/interface/bvops.c0000644000175000017500000005346213107004621021103 0ustar jromanjroman/* BV operations, except those involving global communication. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcbv.h" I*/ #undef __FUNCT__ #define __FUNCT__ "BVMult" /*@ BVMult - Computes Y = beta*Y + alpha*X*Q. Logically Collective on BV Input Parameters: + Y,X - basis vectors . alpha,beta - scalars - Q - (optional) sequential dense matrix Output Parameter: . Y - the modified basis vectors Notes: X and Y must be different objects. The case X=Y can be addressed with BVMultInPlace(). If matrix Q is NULL, then an AXPY operation Y = beta*Y + alpha*X is done (i.e. results as if Q = identity). If provided, the matrix Q must be a sequential dense Mat, with all entries equal on all processes (otherwise each process will compute a different update). The dimensions of Q must be at least m,n where m is the number of active columns of X and n is the number of active columns of Y. The leading columns of Y are not modified. Also, if X has leading columns specified, then these columns do not participate in the computation. Hence, only rows (resp. columns) of Q starting from lx (resp. ly) are used, where lx (resp. ly) is the number of leading columns of X (resp. Y). Level: intermediate .seealso: BVMultVec(), BVMultColumn(), BVMultInPlace(), BVSetActiveColumns() @*/ PetscErrorCode BVMult(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q) { PetscErrorCode ierr; PetscBool match; PetscInt m,n; PetscFunctionBegin; PetscValidHeaderSpecific(Y,BV_CLASSID,1); PetscValidLogicalCollectiveScalar(Y,alpha,2); PetscValidLogicalCollectiveScalar(Y,beta,3); PetscValidHeaderSpecific(X,BV_CLASSID,4); if (Q) PetscValidHeaderSpecific(Q,MAT_CLASSID,5); PetscValidType(Y,1); BVCheckSizes(Y,1); PetscValidType(X,4); BVCheckSizes(X,4); if (Q) PetscValidType(Q,5); PetscCheckSameTypeAndComm(Y,1,X,4); if (X==Y) SETERRQ(PetscObjectComm((PetscObject)Y),PETSC_ERR_ARG_WRONG,"X and Y arguments must be different"); if (Q) { ierr = PetscObjectTypeCompare((PetscObject)Q,MATSEQDENSE,&match);CHKERRQ(ierr); if (!match) SETERRQ(PetscObjectComm((PetscObject)Y),PETSC_ERR_SUP,"Mat argument must be of type seqdense"); ierr = MatGetSize(Q,&m,&n);CHKERRQ(ierr); if (mk) SETERRQ2(PetscObjectComm((PetscObject)Y),PETSC_ERR_ARG_SIZ,"Mat argument has %D rows, should have at least %D",m,X->k); if (nk) SETERRQ2(PetscObjectComm((PetscObject)Y),PETSC_ERR_ARG_SIZ,"Mat argument has %D columns, should have at least %D",n,Y->k); } if (X->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, Y %D",X->n,Y->n); ierr = PetscLogEventBegin(BV_Mult,X,Y,0,0);CHKERRQ(ierr); ierr = (*Y->ops->mult)(Y,alpha,beta,X,Q);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_Mult,X,Y,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)Y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultVec" /*@ BVMultVec - Computes y = beta*y + alpha*X*q. Logically Collective on BV and Vec Input Parameters: + X - a basis vectors object . alpha,beta - scalars . y - a vector - q - an array of scalars Output Parameter: . y - the modified vector Notes: This operation is the analogue of BVMult() but with a BV and a Vec, instead of two BV. Note that arguments are listed in different order with respect to BVMult(). If X has leading columns specified, then these columns do not participate in the computation. The length of array q must be equal to the number of active columns of X minus the number of leading columns, i.e. the first entry of q multiplies the first non-leading column. Level: intermediate .seealso: BVMult(), BVMultColumn(), BVMultInPlace(), BVSetActiveColumns() @*/ PetscErrorCode BVMultVec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q) { PetscErrorCode ierr; PetscInt n,N; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidLogicalCollectiveScalar(X,alpha,2); PetscValidLogicalCollectiveScalar(X,beta,3); PetscValidHeaderSpecific(y,VEC_CLASSID,4); PetscValidPointer(q,5); PetscValidType(X,1); BVCheckSizes(X,1); PetscValidType(y,4); PetscCheckSameComm(X,1,y,4); ierr = VecGetSize(y,&N);CHKERRQ(ierr); ierr = VecGetLocalSize(y,&n);CHKERRQ(ierr); if (N!=X->N || n!=X->n) SETERRQ4(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,X->N,X->n); ierr = PetscLogEventBegin(BV_MultVec,X,y,0,0);CHKERRQ(ierr); ierr = (*X->ops->multvec)(X,alpha,beta,y,q);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_MultVec,X,y,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultColumn" /*@ BVMultColumn - Computes y = beta*y + alpha*X*q, where y is the j-th column of X. Logically Collective on BV Input Parameters: + X - a basis vectors object . alpha,beta - scalars . j - the column index - q - an array of scalars Notes: This operation is equivalent to BVMultVec() but it uses column j of X rather than taking a Vec as an argument. The number of active columns of X is set to j before the computation, and restored afterwards. If X has leading columns specified, then these columns do not participate in the computation. Therefore, the length of array q must be equal to j minus the number of leading columns. Level: advanced .seealso: BVMult(), BVMultVec(), BVMultInPlace(), BVSetActiveColumns() @*/ PetscErrorCode BVMultColumn(BV X,PetscScalar alpha,PetscScalar beta,PetscInt j,PetscScalar *q) { PetscErrorCode ierr; PetscInt ksave; Vec y; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidLogicalCollectiveScalar(X,alpha,2); PetscValidLogicalCollectiveScalar(X,beta,3); PetscValidLogicalCollectiveInt(X,j,4); PetscValidPointer(q,5); PetscValidType(X,1); BVCheckSizes(X,1); if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative"); if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m); ierr = PetscLogEventBegin(BV_MultVec,X,0,0,0);CHKERRQ(ierr); ksave = X->k; X->k = j; ierr = BVGetColumn(X,j,&y);CHKERRQ(ierr); ierr = (*X->ops->multvec)(X,alpha,beta,y,q);CHKERRQ(ierr); ierr = BVRestoreColumn(X,j,&y);CHKERRQ(ierr); X->k = ksave; ierr = PetscLogEventEnd(BV_MultVec,X,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlace" /*@ BVMultInPlace - Update a set of vectors as V(:,s:e-1) = V*Q(:,s:e-1). Logically Collective on BV Input Parameters: + Q - a sequential dense matrix . s - first column of V to be overwritten - e - first column of V not to be overwritten Input/Output Parameter: . V - basis vectors Notes: The matrix Q must be a sequential dense Mat, with all entries equal on all processes (otherwise each process will compute a different update). This function computes V(:,s:e-1) = V*Q(:,s:e-1), that is, given a set of vectors V, columns from s to e-1 are overwritten with columns from s to e-1 of the matrix-matrix product V*Q. Only columns s to e-1 of Q are referenced. Level: intermediate .seealso: BVMult(), BVMultVec(), BVMultInPlaceTranspose(), BVSetActiveColumns() @*/ PetscErrorCode BVMultInPlace(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; PetscBool match; PetscInt m,n; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidHeaderSpecific(Q,MAT_CLASSID,2); PetscValidLogicalCollectiveInt(V,s,3); PetscValidLogicalCollectiveInt(V,e,4); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidType(Q,2); ierr = PetscObjectTypeCompare((PetscObject)Q,MATSEQDENSE,&match);CHKERRQ(ierr); if (!match) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Mat argument must be of type seqdense"); if (sl || s>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument s has wrong value %D, should be between %D and %D",s,V->l,V->m); if (el || e>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument e has wrong value %D, should be between %D and %D",e,V->l,V->m); ierr = MatGetSize(Q,&m,&n);CHKERRQ(ierr); if (mk) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument has %D rows, should have at least %D",m,V->k); if (e>n) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument only has %D columns, the requested value of e is larger: %D",n,e); if (s>=e) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_MultInPlace,V,Q,0,0);CHKERRQ(ierr); ierr = (*V->ops->multinplace)(V,Q,s,e);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_MultInPlace,V,Q,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlaceTranspose" /*@ BVMultInPlaceTranspose - Update a set of vectors as V(:,s:e-1) = V*Q'(:,s:e-1). Logically Collective on BV Input Parameters: + Q - a sequential dense matrix . s - first column of V to be overwritten - e - first column of V not to be overwritten Input/Output Parameter: . V - basis vectors Notes: This is a variant of BVMultInPlace() where the conjugate transpose of Q is used. Level: intermediate .seealso: BVMultInPlace() @*/ PetscErrorCode BVMultInPlaceTranspose(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; PetscBool match; PetscInt m,n; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidHeaderSpecific(Q,MAT_CLASSID,2); PetscValidLogicalCollectiveInt(V,s,3); PetscValidLogicalCollectiveInt(V,e,4); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidType(Q,2); ierr = PetscObjectTypeCompare((PetscObject)Q,MATSEQDENSE,&match);CHKERRQ(ierr); if (!match) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Mat argument must be of type seqdense"); if (sl || s>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument s has wrong value %D, should be between %D and %D",s,V->l,V->m); if (el || e>V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument e has wrong value %D, should be between %D and %D",e,V->l,V->m); ierr = MatGetSize(Q,&m,&n);CHKERRQ(ierr); if (nk) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument has %D columns, should have at least %D",n,V->k); if (e>m) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument only has %D rows, the requested value of e is larger: %D",m,e); if (s>=e || !V->n) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_MultInPlace,V,Q,0,0);CHKERRQ(ierr); ierr = (*V->ops->multinplacetrans)(V,Q,s,e);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_MultInPlace,V,Q,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVScale" /*@ BVScale - Multiply the BV entries by a scalar value. Logically Collective on BV Input Parameters: + bv - basis vectors - alpha - scaling factor Note: All active columns (except the leading ones) are scaled. Level: intermediate .seealso: BVScaleColumn(), BVSetActiveColumns() @*/ PetscErrorCode BVScale(BV bv,PetscScalar alpha) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveScalar(bv,alpha,2); PetscValidType(bv,1); BVCheckSizes(bv,1); if (alpha == (PetscScalar)1.0) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_Scale,bv,0,0,0);CHKERRQ(ierr); if (bv->n) { ierr = (*bv->ops->scale)(bv,-1,alpha);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_Scale,bv,0,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)bv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVScaleColumn" /*@ BVScaleColumn - Scale one column of a BV. Logically Collective on BV Input Parameters: + bv - basis vectors . j - column number to be scaled - alpha - scaling factor Level: intermediate .seealso: BVScale(), BVSetActiveColumns() @*/ PetscErrorCode BVScaleColumn(BV bv,PetscInt j,PetscScalar alpha) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidLogicalCollectiveScalar(bv,alpha,3); PetscValidType(bv,1); BVCheckSizes(bv,1); if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m); if (alpha == (PetscScalar)1.0) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_Scale,bv,0,0,0);CHKERRQ(ierr); if (bv->n) { ierr = (*bv->ops->scale)(bv,j,alpha);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_Scale,bv,0,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)bv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetRandom" /*@ BVSetRandom - Set the columns of a BV to random numbers. Logically Collective on BV Input Parameters: . bv - basis vectors Note: All active columns (except the leading ones) are modified. Level: advanced .seealso: BVSetRandomContext(), BVSetRandomColumn(), BVSetActiveColumns() @*/ PetscErrorCode BVSetRandom(BV bv) { PetscErrorCode ierr; PetscInt i,low,high,k; PetscScalar *px,t; Vec x; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidType(bv,1); BVCheckSizes(bv,1); ierr = BVGetRandomContext(bv,&bv->rand);CHKERRQ(ierr); ierr = PetscLogEventBegin(BV_SetRandom,bv,0,0,0);CHKERRQ(ierr); for (k=bv->l;kk;k++) { ierr = BVGetColumn(bv,k,&x);CHKERRQ(ierr); if (bv->rrandom) { /* generate the same vector irrespective of number of processes */ ierr = VecGetOwnershipRange(x,&low,&high);CHKERRQ(ierr); ierr = VecGetArray(x,&px);CHKERRQ(ierr); for (i=0;iN;i++) { ierr = PetscRandomGetValue(bv->rand,&t);CHKERRQ(ierr); if (i>=low && irand);CHKERRQ(ierr); } ierr = BVRestoreColumn(bv,k,&x);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_SetRandom,bv,0,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)bv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetRandomColumn" /*@ BVSetRandomColumn - Set one column of a BV to random numbers. Logically Collective on BV Input Parameters: + bv - basis vectors - j - column number to be set Level: advanced .seealso: BVSetRandomContext(), BVSetRandom(), BVSetActiveColumns() @*/ PetscErrorCode BVSetRandomColumn(BV bv,PetscInt j) { PetscErrorCode ierr; PetscInt i,low,high; PetscScalar *px,t; Vec x; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidType(bv,1); BVCheckSizes(bv,1); if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m); ierr = BVGetRandomContext(bv,&bv->rand);CHKERRQ(ierr); ierr = PetscLogEventBegin(BV_SetRandom,bv,0,0,0);CHKERRQ(ierr); ierr = BVGetColumn(bv,j,&x);CHKERRQ(ierr); if (bv->rrandom) { /* generate the same vector irrespective of number of processes */ ierr = VecGetOwnershipRange(x,&low,&high);CHKERRQ(ierr); ierr = VecGetArray(x,&px);CHKERRQ(ierr); for (i=0;iN;i++) { ierr = PetscRandomGetValue(bv->rand,&t);CHKERRQ(ierr); if (i>=low && irand);CHKERRQ(ierr); } ierr = BVRestoreColumn(bv,j,&x);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_SetRandom,bv,0,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)bv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatMult" /*@ BVMatMult - Computes the matrix-vector product for each column, Y=A*V. Neighbor-wise Collective on Mat and BV Input Parameters: + V - basis vectors context - A - the matrix Output Parameter: . Y - the result Note: Both V and Y must be distributed in the same manner. Only active columns (excluding the leading ones) are processed. In the result Y, columns are overwritten starting from the leading ones. It is possible to choose whether the computation is done column by column or as a Mat-Mat product, see BVSetMatMultMethod(). Level: beginner .seealso: BVCopy(), BVSetActiveColumns(), BVMatMultColumn(), BVMatMultHermitianTranspose(), BVSetMatMultMethod() @*/ PetscErrorCode BVMatMult(BV V,Mat A,BV Y) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidHeaderSpecific(A,MAT_CLASSID,2); PetscValidType(A,2); PetscValidHeaderSpecific(Y,BV_CLASSID,3); PetscValidType(Y,3); BVCheckSizes(Y,3); PetscCheckSameComm(V,1,A,2); PetscCheckSameTypeAndComm(V,1,Y,3); if (V->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension V %D, Y %D",V->n,Y->n); if (V->k-V->l>Y->m-Y->l) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Y has %D non-leading columns, not enough to store %D columns",Y->m-Y->l,V->k-V->l); ierr = PetscLogEventBegin(BV_MatMult,V,A,Y,0);CHKERRQ(ierr); ierr = (*V->ops->matmult)(V,A,Y);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_MatMult,V,A,Y,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatMultHermitianTranspose" /*@ BVMatMultHermitianTranspose - Computes the matrix-vector product with the conjugate transpose of a matrix for each column, Y=A^H*V. Neighbor-wise Collective on Mat and BV Input Parameters: + V - basis vectors context - A - the matrix Output Parameter: . Y - the result Note: Both V and Y must be distributed in the same manner. Only active columns (excluding the leading ones) are processed. In the result Y, columns are overwritten starting from the leading ones. As opposed to BVMatMult(), this operation is always done column by column, with a sequence of calls to MatMultHermitianTranspose(). Level: beginner .seealso: BVCopy(), BVSetActiveColumns(), BVMatMult(), BVMatMultColumn() @*/ PetscErrorCode BVMatMultHermitianTranspose(BV V,Mat A,BV Y) { PetscErrorCode ierr; PetscInt j; Vec z,f; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidHeaderSpecific(A,MAT_CLASSID,2); PetscValidType(A,2); PetscValidHeaderSpecific(Y,BV_CLASSID,3); PetscValidType(Y,3); BVCheckSizes(Y,3); PetscCheckSameComm(V,1,A,2); PetscCheckSameTypeAndComm(V,1,Y,3); if (V->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension V %D, Y %D",V->n,Y->n); if (V->k-V->l>Y->m-Y->l) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Y has %D non-leading columns, not enough to store %D columns",Y->m-Y->l,V->k-V->l); ierr = PetscLogEventBegin(BV_MatMult,V,A,Y,0);CHKERRQ(ierr); for (j=0;jk-V->l;j++) { ierr = BVGetColumn(V,V->l+j,&z);CHKERRQ(ierr); ierr = BVGetColumn(Y,Y->l+j,&f);CHKERRQ(ierr); ierr = MatMultHermitianTranspose(A,z,f);CHKERRQ(ierr); ierr = BVRestoreColumn(V,V->l+j,&z);CHKERRQ(ierr); ierr = BVRestoreColumn(Y,Y->l+j,&f);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_MatMult,V,A,Y,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatMultColumn" /*@ BVMatMultColumn - Computes the matrix-vector product for a specified column, storing the result in the next column: v_{j+1}=A*v_j. Neighbor-wise Collective on Mat and BV Input Parameters: + V - basis vectors context . A - the matrix - j - the column Output Parameter: . Y - the result Level: beginner .seealso: BVMatMult() @*/ PetscErrorCode BVMatMultColumn(BV V,Mat A,PetscInt j) { PetscErrorCode ierr; Vec vj,vj1; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); PetscValidHeaderSpecific(A,MAT_CLASSID,2); PetscCheckSameComm(V,1,A,2); if (j<0) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative"); if (j+1>=V->m) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Result should go in index j+1=%D but BV only has %D columns",j+1,V->m); ierr = PetscLogEventBegin(BV_MatMultVec,V,A,0,0);CHKERRQ(ierr); ierr = BVGetColumn(V,j,&vj);CHKERRQ(ierr); ierr = BVGetColumn(V,j+1,&vj1);CHKERRQ(ierr); ierr = MatMult(A,vj,vj1);CHKERRQ(ierr); ierr = BVRestoreColumn(V,j,&vj);CHKERRQ(ierr); ierr = BVRestoreColumn(V,j+1,&vj1);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_MatMultVec,V,A,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/interface/bvglobal.c.html0000644000175000017500000025520113107004621022500 0ustar jromanjroman
Actual source code: bvglobal.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV operations involving global communication.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>      /*I "slepcbv.h" I*/

 28: /*
 29:   BVDot for the particular case of non-standard inner product with
 30:   matrix B, which is assumed to be symmetric (or complex Hermitian)
 31: */
 32: PETSC_STATIC_INLINE PetscErrorCode BVDot_Private(BV X,BV Y,Mat M)
 33: {
 35:   PetscObjectId  idx,idy;
 36:   PetscInt       i,j,jend,m;
 37:   PetscScalar    *marray;
 38:   PetscBool      symm=PETSC_FALSE;
 39:   Vec            z;

 42:   MatGetSize(M,&m,NULL);
 43:   MatDenseGetArray(M,&marray);
 44:   PetscObjectGetId((PetscObject)X,&idx);
 45:   PetscObjectGetId((PetscObject)Y,&idy);
 46:   if (idx==idy) symm=PETSC_TRUE;  /* M=X'BX is symmetric */
 47:   jend = X->k;
 48:   for (j=X->l;j<jend;j++) {
 49:     if (symm) Y->k = j+1;
 50:     BVGetColumn(X,j,&z);
 51:     (*Y->ops->dotvec)(Y,z,marray+j*m+Y->l);
 52:     BVRestoreColumn(X,j,&z);
 53:     if (symm) {
 54:       for (i=X->l;i<j;i++)
 55:         marray[j+i*m] = PetscConj(marray[i+j*m]);
 56:     }
 57:   }
 58:   MatDenseRestoreArray(M,&marray);
 59:   return(0);
 60: }

 64: /*@
 65:    BVDot - Computes the 'block-dot' product of two basis vectors objects.

 67:    Collective on BV

 69:    Input Parameters:
 70: +  X, Y - basis vectors
 71: -  M    - Mat object where the result must be placed

 73:    Output Parameter:
 74: .  M    - the resulting matrix

 76:    Notes:
 77:    This is the generalization of VecDot() for a collection of vectors, M = Y^H*X.
 78:    The result is a matrix M whose entry m_ij is equal to y_i^H x_j (where y_i^H
 79:    denotes the conjugate transpose of y_i).

 81:    If a non-standard inner product has been specified with BVSetMatrix(),
 82:    then the result is M = Y^H*B*X. In this case, both X and Y must have
 83:    the same associated matrix.

 85:    On entry, M must be a sequential dense Mat with dimensions m,n at least, where
 86:    m is the number of active columns of Y and n is the number of active columns of X.
 87:    Only rows (resp. columns) of M starting from ly (resp. lx) are computed,
 88:    where ly (resp. lx) is the number of leading columns of Y (resp. X).

 90:    X and Y need not be different objects.

 92:    Level: intermediate

 94: .seealso: BVDotVec(), BVDotColumn(), BVSetActiveColumns(), BVSetMatrix()
 95: @*/
 96: PetscErrorCode BVDot(BV X,BV Y,Mat M)
 97: {
 99:   PetscBool      match;
100:   PetscInt       m,n;
101:   Mat            B;

108:   BVCheckSizes(X,1);
110:   BVCheckSizes(Y,2);
113:   PetscObjectTypeCompare((PetscObject)M,MATSEQDENSE,&match);
114:   if (!match) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_SUP,"Mat argument must be of type seqdense");

116:   MatGetSize(M,&m,&n);
117:   if (m<Y->k) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Mat argument has %D rows, should have at least %D",m,Y->k);
118:   if (n<X->k) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Mat argument has %D columns, should have at least %D",n,X->k);
119:   if (X->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, Y %D",X->n,Y->n);
120:   if (X->matrix!=Y->matrix) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"X and Y must have the same inner product matrix");
121:   if (X->l==X->k || Y->l==Y->k) return(0);

123:   PetscLogEventBegin(BV_Dot,X,Y,0,0);
124:   if (X->matrix) { /* non-standard inner product */
125:     if (X->vmm==BV_MATMULT_VECS) {
126:       /* perform computation column by column */
127:       BVDot_Private(X,Y,M);
128:     } else {
129:       /* compute BX first */
130:       BV_IPMatMultBV(X);
131:       B = X->matrix;
132:       X->matrix = NULL;
133:       (*X->ops->dot)(X->cached,Y,M);
134:       X->matrix = B;
135:     }
136:   } else {
137:     (*X->ops->dot)(X,Y,M);
138:   }
139:   PetscLogEventEnd(BV_Dot,X,Y,0,0);
140:   return(0);
141: }

145: /*@
146:    BVDotVec - Computes multiple dot products of a vector against all the
147:    column vectors of a BV.

149:    Collective on BV and Vec

151:    Input Parameters:
152: +  X - basis vectors
153: -  y - a vector

155:    Output Parameter:
156: .  m - an array where the result must be placed

158:    Notes:
159:    This is analogue to VecMDot(), but using BV to represent a collection
160:    of vectors. The result is m = X^H*y, so m_i is equal to x_j^H y. Note
161:    that here X is transposed as opposed to BVDot().

163:    If a non-standard inner product has been specified with BVSetMatrix(),
164:    then the result is m = X^H*B*y.

166:    The length of array m must be equal to the number of active columns of X
167:    minus the number of leading columns, i.e. the first entry of m is the
168:    product of the first non-leading column with y.

170:    Level: intermediate

172: .seealso: BVDot(), BVDotColumn(), BVSetActiveColumns(), BVSetMatrix()
173: @*/
174: PetscErrorCode BVDotVec(BV X,Vec y,PetscScalar *m)
175: {
177:   PetscInt       n;

183:   BVCheckSizes(X,1);

187:   VecGetLocalSize(y,&n);
188:   if (X->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, y %D",X->n,n);

190:   PetscLogEventBegin(BV_DotVec,X,y,0,0);
191:   (*X->ops->dotvec)(X,y,m);
192:   PetscLogEventEnd(BV_DotVec,X,y,0,0);
193:   return(0);
194: }

198: /*@
199:    BVDotVecBegin - Starts a split phase dot product computation.

201:    Input Parameters:
202: +  X - basis vectors
203: .  y - a vector
204: -  m - an array where the result will go (can be NULL)

206:    Note:
207:    Each call to BVDotVecBegin() should be paired with a call to BVDotVecEnd().

209:    Level: advanced

211: .seealso: BVDotVecEnd(), BVDotVec()
212: @*/
213: PetscErrorCode BVDotVecBegin(BV X,Vec y,PetscScalar *m)
214: {
215:   PetscErrorCode      ierr;
216:   PetscInt            i,n,nv;
217:   PetscSplitReduction *sr;
218:   MPI_Comm            comm;

224:   BVCheckSizes(X,1);

228:   VecGetLocalSize(y,&n);
229:   if (X->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, y %D",X->n,n);

231:   if (X->ops->dotvec_begin) {
232:     (*X->ops->dotvec_begin)(X,y,m);
233:   } else {
234:     nv = X->k-X->l;
235:     PetscObjectGetComm((PetscObject)X,&comm);
236:     PetscSplitReductionGet(comm,&sr);
237:     if (sr->state != STATE_BEGIN) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Called before all VecxxxEnd() called");
238:     for (i=0;i<nv;i++) {
239:       if (sr->numopsbegin+i >= sr->maxops) {
240:         PetscSplitReductionExtend(sr);
241:       }
242:       sr->reducetype[sr->numopsbegin+i] = REDUCE_SUM;
243:       sr->invecs[sr->numopsbegin+i]     = (void*)X;
244:     }
245:     PetscLogEventBegin(BV_DotVec,X,y,0,0);
246:     (*X->ops->dotvec_local)(X,y,sr->lvalues+sr->numopsbegin);
247:     sr->numopsbegin += nv;
248:     PetscLogEventEnd(BV_DotVec,X,y,0,0);
249:   }
250:   return(0);
251: }

255: /*@
256:    BVDotVecEnd - Ends a split phase dot product computation.

258:    Input Parameters:
259: +  X - basis vectors
260: .  y - a vector
261: -  m - an array where the result will go

263:    Note:
264:    Each call to BVDotVecBegin() should be paired with a call to BVDotVecEnd().

266:    Level: advanced

268: .seealso: BVDotVecBegin(), BVDotVec()
269: @*/
270: PetscErrorCode BVDotVecEnd(BV X,Vec y,PetscScalar *m)
271: {
272:   PetscErrorCode      ierr;
273:   PetscInt            i,nv;
274:   PetscSplitReduction *sr;
275:   MPI_Comm            comm;

280:   BVCheckSizes(X,1);

282:   if (X->ops->dotvec_end) {
283:     (*X->ops->dotvec_end)(X,y,m);
284:   } else {
285:     nv = X->k-X->l;
286:     PetscObjectGetComm((PetscObject)X,&comm);
287:     PetscSplitReductionGet(comm,&sr);
288:     PetscSplitReductionEnd(sr);

290:     if (sr->numopsend >= sr->numopsbegin) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() more times than VecxxxBegin()");
291:     if ((void*)X != sr->invecs[sr->numopsend]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called BVxxxEnd() in a different order or with a different BV than BVxxxBegin()");
292:     if (sr->reducetype[sr->numopsend] != REDUCE_SUM) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Wrong type of reduction");
293:     for (i=0;i<nv;i++) m[i] = sr->gvalues[sr->numopsend++];

295:     /* Finished getting all the results so reset to no outstanding requests */
296:     if (sr->numopsend == sr->numopsbegin) {
297:       sr->state       = STATE_BEGIN;
298:       sr->numopsend   = 0;
299:       sr->numopsbegin = 0;
300:     }
301:   }
302:   return(0);
303: }

307: /*@
308:    BVDotColumn - Computes multiple dot products of a column against all the
309:    previous columns of a BV.

311:    Collective on BV

313:    Input Parameters:
314: +  X - basis vectors
315: -  j - the column index

317:    Output Parameter:
318: .  m - an array where the result must be placed

320:    Notes:
321:    This operation is equivalent to BVDotVec() but it uses column j of X
322:    rather than taking a Vec as an argument. The number of active columns of
323:    X is set to j before the computation, and restored afterwards.
324:    If X has leading columns specified, then these columns do not participate
325:    in the computation. Therefore, the length of array m must be equal to j
326:    minus the number of leading columns.

328:    Level: advanced

330: .seealso: BVDot(), BVDotVec(), BVSetActiveColumns(), BVSetMatrix()
331: @*/
332: PetscErrorCode BVDotColumn(BV X,PetscInt j,PetscScalar *m)
333: {
335:   PetscInt       ksave;
336:   Vec            y;

342:   BVCheckSizes(X,1);

344:   if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative");
345:   if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m);

347:   PetscLogEventBegin(BV_DotVec,X,0,0,0);
348:   ksave = X->k;
349:   X->k = j;
350:   BVGetColumn(X,j,&y);
351:   (*X->ops->dotvec)(X,y,m);
352:   BVRestoreColumn(X,j,&y);
353:   X->k = ksave;
354:   PetscLogEventEnd(BV_DotVec,X,0,0,0);
355:   return(0);
356: }

360: /*@
361:    BVDotColumnBegin - Starts a split phase dot product computation.

363:    Input Parameters:
364: +  X - basis vectors
365: -  j - the column index
366: -  m - an array where the result will go (can be NULL)

368:    Note:
369:    Each call to BVDotColumnBegin() should be paired with a call to BVDotColumnEnd().

371:    Level: advanced

373: .seealso: BVDotColumnEnd(), BVDotColumn()
374: @*/
375: PetscErrorCode BVDotColumnBegin(BV X,PetscInt j,PetscScalar *m)
376: {
377:   PetscErrorCode      ierr;
378:   PetscInt            i,nv,ksave;
379:   PetscSplitReduction *sr;
380:   MPI_Comm            comm;
381:   Vec                 y;

387:   BVCheckSizes(X,1);

389:   if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative");
390:   if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m);
391:   ksave = X->k;
392:   X->k = j;
393:   BVGetColumn(X,j,&y);

395:   if (X->ops->dotvec_begin) {
396:     (*X->ops->dotvec_begin)(X,y,m);
397:   } else {
398:     nv = X->k-X->l;
399:     PetscObjectGetComm((PetscObject)X,&comm);
400:     PetscSplitReductionGet(comm,&sr);
401:     if (sr->state != STATE_BEGIN) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Called before all VecxxxEnd() called");
402:     for (i=0;i<nv;i++) {
403:       if (sr->numopsbegin+i >= sr->maxops) {
404:         PetscSplitReductionExtend(sr);
405:       }
406:       sr->reducetype[sr->numopsbegin+i] = REDUCE_SUM;
407:       sr->invecs[sr->numopsbegin+i]     = (void*)X;
408:     }
409:     PetscLogEventBegin(BV_DotVec,X,0,0,0);
410:     (*X->ops->dotvec_local)(X,y,sr->lvalues+sr->numopsbegin);
411:     sr->numopsbegin += nv;
412:     PetscLogEventEnd(BV_DotVec,X,0,0,0);
413:   }
414:   BVRestoreColumn(X,j,&y);
415:   X->k = ksave;
416:   return(0);
417: }

421: /*@
422:    BVDotColumnEnd - Ends a split phase dot product computation.

424:    Input Parameters:
425: +  X - basis vectors
426: .  j - the column index
427: -  m - an array where the result will go

429:    Notes:
430:    Each call to BVDotColumnBegin() should be paired with a call to BVDotColumnEnd().

432:    Level: advanced

434: .seealso: BVDotColumnBegin(), BVDotColumn()
435: @*/
436: PetscErrorCode BVDotColumnEnd(BV X,PetscInt j,PetscScalar *m)
437: {
438:   PetscErrorCode      ierr;
439:   PetscInt            i,nv,ksave;
440:   PetscSplitReduction *sr;
441:   MPI_Comm            comm;
442:   Vec                 y;

448:   BVCheckSizes(X,1);

450:   if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative");
451:   if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m);
452:   ksave = X->k;
453:   X->k = j;

455:   if (X->ops->dotvec_end) {
456:     BVGetColumn(X,j,&y);
457:     (*X->ops->dotvec_end)(X,y,m);
458:     BVRestoreColumn(X,j,&y);
459:   } else {
460:     nv = X->k-X->l;
461:     PetscObjectGetComm((PetscObject)X,&comm);
462:     PetscSplitReductionGet(comm,&sr);
463:     PetscSplitReductionEnd(sr);

465:     if (sr->numopsend >= sr->numopsbegin) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() more times than VecxxxBegin()");
466:     if ((void*)X != sr->invecs[sr->numopsend]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called BVxxxEnd() in a different order or with a different BV than BVxxxBegin()");
467:     if (sr->reducetype[sr->numopsend] != REDUCE_SUM) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Wrong type of reduction");
468:     for (i=0;i<nv;i++) m[i] = sr->gvalues[sr->numopsend++];

470:     /* Finished getting all the results so reset to no outstanding requests */
471:     if (sr->numopsend == sr->numopsbegin) {
472:       sr->state       = STATE_BEGIN;
473:       sr->numopsend   = 0;
474:       sr->numopsbegin = 0;
475:     }
476:   }
477:   X->k = ksave;
478:   return(0);
479: }

483: PETSC_STATIC_INLINE PetscErrorCode BVNorm_Private(BV bv,Vec z,NormType type,PetscReal *val)
484: {
486:   PetscScalar    p;

489:   BV_IPMatMult(bv,z);
490:   VecDot(bv->Bx,z,&p);
491:   BV_SafeSqrt(bv,p,val);
492:   return(0);
493: }

497: PETSC_STATIC_INLINE PetscErrorCode BVNorm_Begin_Private(BV bv,Vec z,NormType type,PetscReal *val)
498: {
500:   PetscScalar    p;

503:   BV_IPMatMult(bv,z);
504:   VecDotBegin(bv->Bx,z,&p);
505:   return(0);
506: }

510: PETSC_STATIC_INLINE PetscErrorCode BVNorm_End_Private(BV bv,Vec z,NormType type,PetscReal *val)
511: {
513:   PetscScalar    p;

516:   VecDotEnd(bv->Bx,z,&p);
517:   BV_SafeSqrt(bv,p,val);
518:   return(0);
519: }

523: /*@
524:    BVNorm - Computes the matrix norm of the BV.

526:    Collective on BV

528:    Input Parameters:
529: +  bv   - basis vectors
530: -  type - the norm type

532:    Output Parameter:
533: .  val  - the norm

535:    Notes:
536:    All active columns (except the leading ones) are considered as a matrix.
537:    The allowed norms are NORM_1, NORM_FROBENIUS, and NORM_INFINITY.

539:    This operation fails if a non-standard inner product has been
540:    specified with BVSetMatrix().

542:    Level: intermediate

544: .seealso: BVNormVec(), BVNormColumn(), BVSetActiveColumns(), BVSetMatrix()
545: @*/
546: PetscErrorCode BVNorm(BV bv,NormType type,PetscReal *val)
547: {

555:   BVCheckSizes(bv,1);

557:   if (type==NORM_2 || type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available");
558:   if (bv->matrix) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Matrix norm not available for non-standard inner product");

560:   PetscLogEventBegin(BV_Norm,bv,0,0,0);
561:   (*bv->ops->norm)(bv,-1,type,val);
562:   PetscLogEventEnd(BV_Norm,bv,0,0,0);
563:   return(0);
564: }

568: /*@
569:    BVNormVec - Computes the norm of a given vector.

571:    Collective on BV

573:    Input Parameters:
574: +  bv   - basis vectors
575: .  v    - the vector
576: -  type - the norm type

578:    Output Parameter:
579: .  val  - the norm

581:    Notes:
582:    This is the analogue of BVNormColumn() but for a vector that is not in the BV.
583:    If a non-standard inner product has been specified with BVSetMatrix(),
584:    then the returned value is sqrt(v'*B*v), where B is the inner product
585:    matrix (argument 'type' is ignored). Otherwise, VecNorm() is called.

587:    Level: developer

589: .seealso: BVNorm(), BVNormColumn(), BVSetMatrix()
590: @*/
591: PetscErrorCode BVNormVec(BV bv,Vec v,NormType type,PetscReal *val)
592: {
594:   PetscInt       n;

602:   BVCheckSizes(bv,1);

606:   if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available");

608:   PetscLogEventBegin(BV_NormVec,bv,0,0,0);
609:   if (bv->matrix) { /* non-standard inner product */
610:     VecGetLocalSize(v,&n);
611:     if (bv->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension bv %D, v %D",bv->n,n);
612:     BVNorm_Private(bv,v,type,val);
613:   } else {
614:     VecNorm(v,type,val);
615:   }
616:   PetscLogEventEnd(BV_NormVec,bv,0,0,0);
617:   return(0);
618: }

622: /*@
623:    BVNormVecBegin - Starts a split phase norm computation.

625:    Input Parameters:
626: +  bv   - basis vectors
627: .  v    - the vector
628: .  type - the norm type
629: -  val  - the norm

631:    Note:
632:    Each call to BVNormVecBegin() should be paired with a call to BVNormVecEnd().

634:    Level: advanced

636: .seealso: BVNormVecEnd(), BVNormVec()
637: @*/
638: PetscErrorCode BVNormVecBegin(BV bv,Vec v,NormType type,PetscReal *val)
639: {
641:   PetscInt       n;

649:   BVCheckSizes(bv,1);

653:   if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available");

655:   PetscLogEventBegin(BV_NormVec,bv,0,0,0);
656:   if (bv->matrix) { /* non-standard inner product */
657:     VecGetLocalSize(v,&n);
658:     if (bv->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension bv %D, v %D",bv->n,n);
659:     BVNorm_Begin_Private(bv,v,type,val);
660:   } else {
661:     VecNormBegin(v,type,val);
662:   }
663:   PetscLogEventEnd(BV_NormVec,bv,0,0,0);
664:   return(0);
665: }

669: /*@
670:    BVNormVecEnd - Ends a split phase norm computation.

672:    Input Parameters:
673: +  bv   - basis vectors
674: .  v    - the vector
675: .  type - the norm type
676: -  val  - the norm

678:    Note:
679:    Each call to BVNormVecBegin() should be paired with a call to BVNormVecEnd().

681:    Level: advanced

683: .seealso: BVNormVecBegin(), BVNormVec()
684: @*/
685: PetscErrorCode BVNormVecEnd(BV bv,Vec v,NormType type,PetscReal *val)
686: {

694:   BVCheckSizes(bv,1);

696:   if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available");

698:   if (bv->matrix) { /* non-standard inner product */
699:     BVNorm_End_Private(bv,v,type,val);
700:   } else {
701:     VecNormEnd(v,type,val);
702:   }
703:   return(0);
704: }

708: /*@
709:    BVNormColumn - Computes the vector norm of a selected column.

711:    Collective on BV

713:    Input Parameters:
714: +  bv   - basis vectors
715: .  j    - column number to be used
716: -  type - the norm type

718:    Output Parameter:
719: .  val  - the norm

721:    Notes:
722:    The norm of V[j] is computed (NORM_1, NORM_2, or NORM_INFINITY).
723:    If a non-standard inner product has been specified with BVSetMatrix(),
724:    then the returned value is sqrt(V[j]'*B*V[j]), 
725:    where B is the inner product matrix (argument 'type' is ignored).

727:    Level: intermediate

729: .seealso: BVNorm(), BVNormVec(), BVSetActiveColumns(), BVSetMatrix()
730: @*/
731: PetscErrorCode BVNormColumn(BV bv,PetscInt j,NormType type,PetscReal *val)
732: {
734:   Vec            z;

742:   BVCheckSizes(bv,1);

744:   if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m);
745:   if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available");

747:   PetscLogEventBegin(BV_NormVec,bv,0,0,0);
748:   if (bv->matrix) { /* non-standard inner product */
749:     BVGetColumn(bv,j,&z);
750:     BVNorm_Private(bv,z,type,val);
751:     BVRestoreColumn(bv,j,&z);
752:   } else {
753:     (*bv->ops->norm)(bv,j,type,val);
754:   }
755:   PetscLogEventEnd(BV_NormVec,bv,0,0,0);
756:   return(0);
757: }

761: /*@
762:    BVNormColumnBegin - Starts a split phase norm computation.

764:    Input Parameters:
765: +  bv   - basis vectors
766: .  j    - column number to be used
767: .  type - the norm type
768: -  val  - the norm

770:    Note:
771:    Each call to BVNormColumnBegin() should be paired with a call to BVNormColumnEnd().

773:    Level: advanced

775: .seealso: BVNormColumnEnd(), BVNormColumn()
776: @*/
777: PetscErrorCode BVNormColumnBegin(BV bv,PetscInt j,NormType type,PetscReal *val)
778: {
779:   PetscErrorCode      ierr;
780:   PetscSplitReduction *sr;
781:   PetscReal           lresult;
782:   MPI_Comm            comm;
783:   Vec                 z;

791:   BVCheckSizes(bv,1);

793:   if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m);
794:   if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available");

796:   PetscLogEventBegin(BV_NormVec,bv,0,0,0);
797:   BVGetColumn(bv,j,&z);
798:   if (bv->matrix) { /* non-standard inner product */
799:     BVNorm_Begin_Private(bv,z,type,val);
800:   } else if (bv->ops->norm_begin) {
801:     (*bv->ops->norm_begin)(bv,j,type,val);
802:   } else {
803:     PetscObjectGetComm((PetscObject)z,&comm);
804:     PetscSplitReductionGet(comm,&sr);
805:     if (sr->state != STATE_BEGIN) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Called before all VecxxxEnd() called");
806:     if (sr->numopsbegin >= sr->maxops) {
807:       PetscSplitReductionExtend(sr);
808:     }
809:     sr->invecs[sr->numopsbegin] = (void*)bv;
810:     (*bv->ops->norm_local)(bv,j,type,&lresult);
811:     if (type == NORM_2) lresult = lresult*lresult;
812:     if (type == NORM_MAX) sr->reducetype[sr->numopsbegin] = REDUCE_MAX;
813:     else sr->reducetype[sr->numopsbegin] = REDUCE_SUM;
814:     sr->lvalues[sr->numopsbegin++] = lresult;
815:   }
816:   BVRestoreColumn(bv,j,&z);
817:   PetscLogEventEnd(BV_NormVec,bv,0,0,0);
818:   return(0);
819: }

823: /*@
824:    BVNormColumnEnd - Ends a split phase norm computation.

826:    Input Parameters:
827: +  bv   - basis vectors
828: .  j    - column number to be used
829: .  type - the norm type
830: -  val  - the norm

832:    Note:
833:    Each call to BVNormColumnBegin() should be paired with a call to BVNormColumnEnd().

835:    Level: advanced

837: .seealso: BVNormColumnBegin(), BVNormColumn()
838: @*/
839: PetscErrorCode BVNormColumnEnd(BV bv,PetscInt j,NormType type,PetscReal *val)
840: {
841:   PetscErrorCode      ierr;
842:   PetscSplitReduction *sr;
843:   MPI_Comm            comm;
844:   Vec                 z;

852:   BVCheckSizes(bv,1);

854:   if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available");

856:   BVGetColumn(bv,j,&z);
857:   if (bv->matrix) { /* non-standard inner product */
858:     BVNorm_End_Private(bv,z,type,val);
859:   } else if (bv->ops->norm_end) {
860:     (*bv->ops->norm_end)(bv,j,type,val);
861:   } else {
862:     PetscObjectGetComm((PetscObject)z,&comm);
863:     PetscSplitReductionGet(comm,&sr);
864:     PetscSplitReductionEnd(sr);

866:     if (sr->numopsend >= sr->numopsbegin) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() more times then VecxxxBegin()");
867:     if ((void*)bv != sr->invecs[sr->numopsend]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() in a different order or with a different vector than VecxxxBegin()");
868:     if (sr->reducetype[sr->numopsend] != REDUCE_MAX && type == NORM_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called BVNormEnd(,NORM_MAX,) on a reduction started with VecDotBegin() or NORM_1 or NORM_2");
869:     *val = PetscRealPart(sr->gvalues[sr->numopsend++]);
870:     if (type == NORM_2) *val = PetscSqrtReal(*val);
871:     if (sr->numopsend == sr->numopsbegin) {
872:       sr->state       = STATE_BEGIN;
873:       sr->numopsend   = 0;
874:       sr->numopsbegin = 0;
875:     }
876:   }
877:   BVRestoreColumn(bv,j,&z);
878:   return(0);
879: }

883: /*
884:   Compute Y^H*A*X: right part column by column (with MatMult) and bottom
885:   part row by row (with MatMultHermitianTranspose); result placed in marray[*,ldm]
886: */
887: PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Vec(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm)
888: {
890:   PetscInt       i,j,lx,ly,kx,ky,ulim;
891:   Vec            z,f;

894:   lx = X->l; kx = X->k;
895:   ly = Y->l; ky = Y->k;
896:   BVCreateVec(X,&f);
897:   for (j=lx;j<kx;j++) {
898:     BVGetColumn(X,j,&z);
899:     MatMult(A,z,f);
900:     BVRestoreColumn(X,j,&z);
901:     ulim = PetscMin(ly+(j-lx)+1,ky);
902:     Y->l = 0; Y->k = ulim;
903:     (*Y->ops->dotvec)(Y,f,marray+j*ldm);
904:     if (symm) {
905:       for (i=0;i<j;i++) marray[j+i*ldm] = PetscConj(marray[i+j*ldm]);
906:     }
907:   }
908:   if (!symm) {
909:     BV_AllocateCoeffs(Y);
910:     for (j=ly;j<ky;j++) {
911:       BVGetColumn(Y,j,&z);
912:       MatMultHermitianTranspose(A,z,f);
913:       BVRestoreColumn(Y,j,&z);
914:       ulim = PetscMin(lx+(j-ly),kx);
915:       X->l = 0; X->k = ulim;
916:       (*X->ops->dotvec)(X,f,Y->h);
917:       for (i=0;i<ulim;i++) marray[j+i*ldm] = PetscConj(Y->h[i]);
918:     }
919:   }
920:   VecDestroy(&f);
921:   X->l = lx; X->k = kx;
922:   Y->l = ly; Y->k = ky;
923:   return(0);
924: }

928: /*
929:   Compute Y^H*A*X= [   --   | Y0'*W1 ]
930:                    [ Y1'*W0 | Y1'*W1 ]
931:   Allocates auxiliary BV to store the result of A*X, then one BVDot
932:   call for top-right part and another one for bottom part;
933:   result placed in marray[*,ldm]
934: */
935: PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm)
936: {
938:   PetscInt       j,lx,ly,kx,ky;
939:   PetscScalar    *harray;
940:   Mat            H;
941:   BV             W;

944:   lx = X->l; kx = X->k;
945:   ly = Y->l; ky = Y->k;
946:   BVDuplicate(X,&W);
947:   X->l = 0; X->k = kx;
948:   BVMatMult(X,A,W);

950:   /* top-right part, Y0'*AX1 */
951:   if (ly>0 && lx<kx) {
952:     MatCreateSeqDense(PETSC_COMM_SELF,ly,kx,NULL,&H);
953:     W->l = lx; W->k = kx;
954:     Y->l = 0;  Y->k = ly;
955:     BVDot(W,Y,H);
956:     MatDenseGetArray(H,&harray);
957:     for (j=lx;j<kx;j++) {
958:       PetscMemcpy(marray+j*ldm,harray+j*ly,ly*sizeof(PetscScalar));
959:     }
960:     MatDenseRestoreArray(H,&harray);
961:     MatDestroy(&H);
962:   }

964:   /* bottom part, Y1'*AX */
965:   if (kx>0 && ly<ky) {
966:     MatCreateSeqDense(PETSC_COMM_SELF,ky,kx,NULL,&H);
967:     W->l = 0;  W->k = kx;
968:     Y->l = ly; Y->k = ky;
969:     BVDot(W,Y,H);
970:     MatDenseGetArray(H,&harray);
971:     for (j=0;j<kx;j++) {
972:       PetscMemcpy(marray+j*ldm+ly,harray+j*ky+ly,(ky-ly)*sizeof(PetscScalar));
973:     }
974:     MatDenseRestoreArray(H,&harray);
975:     MatDestroy(&H);
976:   }
977:   BVDestroy(&W);
978:   X->l = lx; X->k = kx;
979:   Y->l = ly; Y->k = ky;
980:   return(0);
981: }

985: /*
986:   Compute Y^H*A*X= [   --   | Y0'*W1 ]
987:                    [ Y1'*W0 | Y1'*W1 ]
988:   First stage: allocate auxiliary BV to store A*X1, one BVDot for right part;
989:   Second stage: resize BV to accomodate A'*Y1, then call BVDot for transpose of
990:   bottom-left part; result placed in marray[*,ldm]
991: */
992: PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult_2(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm)
993: {
995:   PetscInt       i,j,lx,ly,kx,ky;
996:   PetscScalar    *harray;
997:   Mat            H;
998:   BV             W;

1001:   lx = X->l; kx = X->k;
1002:   ly = Y->l; ky = Y->k;

1004:   /* right part, Y'*AX1 */
1005:   BVDuplicateResize(X,kx-lx,&W);
1006:   if (ky>0 && lx<kx) {
1007:     BVMatMult(X,A,W);
1008:     MatCreateSeqDense(PETSC_COMM_SELF,ky,kx-lx,NULL,&H);
1009:     Y->l = 0; Y->k = ky;
1010:     BVDot(W,Y,H);
1011:     MatDenseGetArray(H,&harray);
1012:     for (j=lx;j<kx;j++) {
1013:       PetscMemcpy(marray+j*ldm,harray+(j-lx)*ky,ky*sizeof(PetscScalar));
1014:     }
1015:     MatDenseRestoreArray(H,&harray);
1016:     MatDestroy(&H);
1017:   }

1019:   /* bottom-left part, Y1'*AX0 */
1020:   if (lx>0 && ly<ky) {
1021:     if (symm) {
1022:       /* do not compute, just copy symmetric elements */
1023:       for (i=ly;i<ky;i++) {
1024:         for (j=0;j<lx;j++) marray[i+j*ldm] = PetscConj(marray[j+i*ldm]);
1025:       }
1026:     } else {
1027:       BVResize(W,ky-ly,PETSC_FALSE);
1028:       Y->l = ly; Y->k = ky;
1029:       BVMatMultHermitianTranspose(Y,A,W);
1030:       MatCreateSeqDense(PETSC_COMM_SELF,lx,ky-ly,NULL,&H);
1031:       X->l = 0; X->k = lx;
1032:       BVDot(W,X,H);
1033:       MatDenseGetArray(H,&harray);
1034:       for (i=0;i<ky-ly;i++) {
1035:         for (j=0;j<lx;j++) {
1036:           marray[i+j*ldm+ly] = PetscConj(harray[j+i*(ky-ly)]);
1037:         }
1038:       }
1039:       MatDenseRestoreArray(H,&harray);
1040:       MatDestroy(&H);
1041:     }
1042:   }
1043:   BVDestroy(&W);
1044:   X->l = lx; X->k = kx;
1045:   Y->l = ly; Y->k = ky;
1046:   return(0);
1047: }

1051: /*
1052:   Compute Y^H*X = [   --   | Y0'*X1 ]     (X contains A*X):
1053:                   [ Y1'*X0 | Y1'*X1 ]
1054:   one BVDot call for top-right part and another one for bottom part;
1055:   result placed in marray[*,ldm]
1056: */
1057: PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Dot(BV X,BV Y,PetscScalar *marray,PetscInt ldm)
1058: {
1060:   PetscInt       j,lx,ly,kx,ky;
1061:   PetscScalar    *harray;
1062:   Mat            H;

1065:   lx = X->l; kx = X->k;
1066:   ly = Y->l; ky = Y->k;

1068:   /* top-right part, Y0'*X1 */
1069:   if (ly>0 && lx<kx) {
1070:     MatCreateSeqDense(PETSC_COMM_SELF,ly,kx,NULL,&H);
1071:     X->l = lx; X->k = kx;
1072:     Y->l = 0;  Y->k = ly;
1073:     BVDot(X,Y,H);
1074:     MatDenseGetArray(H,&harray);
1075:     for (j=lx;j<kx;j++) {
1076:       PetscMemcpy(marray+j*ldm,harray+j*ly,ly*sizeof(PetscScalar));
1077:     }
1078:     MatDenseRestoreArray(H,&harray);
1079:     MatDestroy(&H);
1080:   }

1082:   /* bottom part, Y1'*X */
1083:   if (kx>0 && ly<ky) {
1084:     MatCreateSeqDense(PETSC_COMM_SELF,ky,kx,NULL,&H);
1085:     X->l = 0;  X->k = kx;
1086:     Y->l = ly; Y->k = ky;
1087:     BVDot(X,Y,H);
1088:     MatDenseGetArray(H,&harray);
1089:     for (j=0;j<kx;j++) {
1090:       PetscMemcpy(marray+j*ldm+ly,harray+j*ky+ly,(ky-ly)*sizeof(PetscScalar));
1091:     }
1092:     MatDenseRestoreArray(H,&harray);
1093:     MatDestroy(&H);
1094:   }
1095:   X->l = lx; X->k = kx;
1096:   Y->l = ly; Y->k = ky;
1097:   return(0);
1098: }

1102: /*@
1103:    BVMatProject - Computes the projection of a matrix onto a subspace.

1105:    Collective on BV

1107:    Input Parameters:
1108: +  X - basis vectors
1109: .  A - (optional) matrix to be projected
1110: .  Y - left basis vectors, can be equal to X
1111: -  M - Mat object where the result must be placed

1113:    Output Parameter:
1114: .  M - the resulting matrix

1116:    Notes:
1117:    If A=NULL, then it is assumed that X already contains A*X.

1119:    This operation is similar to BVDot(), with important differences.
1120:    The goal is to compute the matrix resulting from the orthogonal projection
1121:    of A onto the subspace spanned by the columns of X, M = X^H*A*X, or the
1122:    oblique projection onto X along Y, M = Y^H*A*X.

1124:    A difference with respect to BVDot() is that the standard inner product
1125:    is always used, regardless of a non-standard inner product being specified
1126:    with BVSetMatrix().

1128:    On entry, M must be a sequential dense Mat with dimensions ky,kx at least,
1129:    where ky (resp. kx) is the number of active columns of Y (resp. X).
1130:    Another difference with respect to BVDot() is that all entries of M are
1131:    computed except the leading ly,lx part, where ly (resp. lx) is the
1132:    number of leading columns of Y (resp. X). Hence, the leading columns of
1133:    X and Y participate in the computation, as opposed to BVDot().
1134:    The leading part of M is assumed to be already available from previous
1135:    computations.

1137:    In the orthogonal projection case, Y=X, some computation can be saved if
1138:    A is real symmetric (or complex Hermitian). In order to exploit this
1139:    property, the symmetry flag of A must be set with MatSetOption().

1141:    Level: intermediate

1143: .seealso: BVDot(), BVSetActiveColumns(), BVSetMatrix()
1144: @*/
1145: PetscErrorCode BVMatProject(BV X,Mat A,BV Y,Mat M)
1146: {
1148:   PetscBool      match,set,flg,symm=PETSC_FALSE;
1149:   PetscInt       m,n;
1150:   PetscScalar    *marray;
1151:   Mat            Xmatrix,Ymatrix;
1152:   PetscObjectId  idx,idy;

1160:   BVCheckSizes(X,1);
1161:   if (A) {
1164:   }
1166:   BVCheckSizes(Y,3);
1169:   PetscObjectTypeCompare((PetscObject)M,MATSEQDENSE,&match);
1170:   if (!match) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_SUP,"Matrix M must be of type seqdense");

1172:   MatGetSize(M,&m,&n);
1173:   if (m<Y->k) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Matrix M has %D rows, should have at least %D",m,Y->k);
1174:   if (n<X->k) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Matrix M has %D columns, should have at least %D",n,X->k);
1175:   if (X->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, Y %D",X->n,Y->n);

1177:   PetscLogEventBegin(BV_MatProject,X,A,Y,0);
1178:   /* temporarily set standard inner product */
1179:   Xmatrix = X->matrix;
1180:   Ymatrix = Y->matrix;
1181:   X->matrix = Y->matrix = NULL;

1183:   PetscObjectGetId((PetscObject)X,&idx);
1184:   PetscObjectGetId((PetscObject)Y,&idy);
1185:   if (!A && idx==idy) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Cannot set X=Y if A=NULL");

1187:   MatDenseGetArray(M,&marray);

1189:   if (A && idx==idy) { /* check symmetry of M=X'AX */
1190:     MatIsHermitianKnown(A,&set,&flg);
1191:     symm = set? flg: PETSC_FALSE;
1192:   }

1194:   if (A) { 
1195:     if (X->vmm==BV_MATMULT_VECS) {
1196:       /* perform computation column by column */
1197:       BVMatProject_Vec(X,A,Y,marray,m,symm);
1198:     } else {
1199:       /* use BVMatMult, then BVDot */
1200:       MatHasOperation(A,MATOP_MULT_TRANSPOSE,&flg);
1201:       if (symm || (flg && X->l>=X->k/2 && Y->l>=Y->k/2)) {
1202:         BVMatProject_MatMult_2(X,A,Y,marray,m,symm);
1203:       } else {
1204:         BVMatProject_MatMult(X,A,Y,marray,m);
1205:       }
1206:     }
1207:   } else {
1208:     /* use BVDot on subblocks */
1209:     BVMatProject_Dot(X,Y,marray,m);
1210:   }

1212:   MatDenseRestoreArray(M,&marray);
1213:   PetscLogEventEnd(BV_MatProject,X,A,Y,0);
1214:   /* restore non-standard inner product */
1215:   X->matrix = Xmatrix;
1216:   Y->matrix = Ymatrix;
1217:   return(0);
1218: }

slepc-3.7.4/src/sys/classes/bv/interface/bvorthog.c0000644000175000017500000005370613107004621021605 0ustar jromanjroman/* BV orthogonalization routines. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcbv.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalizeMGS1" /* BVOrthogonalizeMGS1 - Compute one step of Modified Gram-Schmidt */ static PetscErrorCode BVOrthogonalizeMGS1(BV bv,PetscInt k,Vec v,PetscBool *which,PetscScalar *H) { PetscErrorCode ierr; PetscInt i; PetscScalar dot; Vec vi,z; PetscFunctionBegin; z = v; for (i=-bv->nc;i=0 && !which[i]) continue; ierr = BVGetColumn(bv,i,&vi);CHKERRQ(ierr); /* h_i = ( v, v_i ) */ if (bv->matrix) { ierr = BV_IPMatMult(bv,v);CHKERRQ(ierr); z = bv->Bx; } ierr = VecDot(z,vi,&dot);CHKERRQ(ierr); /* v <- v - h_i v_i */ if (bv->indef) dot /= bv->omega[bv->nc+i]; ierr = VecAXPY(v,-dot,vi);CHKERRQ(ierr); if (bv->indef) dot *= bv->omega[bv->nc+i]; if (H) H[bv->nc+i] += dot; ierr = BVRestoreColumn(bv,i,&vi);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalizeCGS1" /* BVOrthogonalizeCGS1 - Compute |v'| (estimated), |v| and one step of CGS with only one global synchronization */ PetscErrorCode BVOrthogonalizeCGS1(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *onorm,PetscReal *norm) { PetscErrorCode ierr; PetscInt i; PetscReal sum,nrm,beta; Vec w=v; PetscFunctionBegin; /* h = W^* v ; alpha = (v, v) */ bv->k = j; if (onorm || norm) { if (!v) { bv->k++; ierr = BVGetColumn(bv,j,&w);CHKERRQ(ierr); } ierr = BVDotVec(bv,w,H);CHKERRQ(ierr); if (!v) { ierr = BVRestoreColumn(bv,j,&w);CHKERRQ(ierr); bv->k--; ierr = BV_SafeSqrt(bv,H[bv->nc+j],&beta);CHKERRQ(ierr); } else { ierr = BVNormVec(bv,w,NORM_2,&beta);CHKERRQ(ierr); } } else { if (!v) { ierr = BVDotColumn(bv,j,H);CHKERRQ(ierr); } else { ierr = BVDotVec(bv,w,H);CHKERRQ(ierr); } } /* q = v - V h */ if (bv->indef) { for (i=0;inc+j;i++) H[i] /= bv->omega[i]; /* apply inverse of signature */ } if (!v) { ierr = BVMultColumn(bv,-1.0,1.0,j,H);CHKERRQ(ierr); } else { ierr = BVMultVec(bv,-1.0,1.0,w,H);CHKERRQ(ierr); } if (bv->indef) { for (i=0;inc+j;i++) H[i] *= bv->omega[i]; /* revert signature */ } /* compute |v| */ if (onorm) *onorm = beta; if (bv->indef) { if (!v) { ierr = BVNormColumn(bv,j,NORM_2,&nrm);CHKERRQ(ierr); } else { ierr = BVNormVec(bv,w,NORM_2,&nrm);CHKERRQ(ierr); } if (norm) *norm = nrm; bv->omega[bv->nc+j] = (nrm<0.0)? -1.0: 1.0; } else if (norm) { /* estimate |v'| from |v| */ sum = 0.0; for (i=0;inc+j;i++) sum += PetscRealPart(H[i]*PetscConj(H[i])); *norm = beta*beta-sum; if (*norm <= 0.0) { if (!v) { ierr = BVNormColumn(bv,j,NORM_2,norm);CHKERRQ(ierr); } else { ierr = BVNormVec(bv,w,NORM_2,norm);CHKERRQ(ierr); } } else *norm = PetscSqrtReal(*norm); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalizeMGS" /* BVOrthogonalizeMGS - Orthogonalize with modified Gram-Schmidt */ static PetscErrorCode BVOrthogonalizeMGS(BV bv,PetscInt j,Vec v,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep) { PetscErrorCode ierr; PetscReal onrm,nrm; PetscInt k,l; Vec w; PetscFunctionBegin; if (v) { w = v; k = bv->k; } else { ierr = BVGetColumn(bv,j,&w);CHKERRQ(ierr); k = j; } ierr = PetscMemzero(bv->h,(bv->nc+k)*sizeof(PetscScalar));CHKERRQ(ierr); switch (bv->orthog_ref) { case BV_ORTHOG_REFINE_IFNEEDED: /* first step */ ierr = BVNormVec(bv,w,NORM_2,&onrm);CHKERRQ(ierr); ierr = BVOrthogonalizeMGS1(bv,k,w,which,bv->h);CHKERRQ(ierr); ierr = BVNormVec(bv,w,NORM_2,&nrm);CHKERRQ(ierr); /* ||q|| < eta ||h|| */ l = 1; while (l<3 && nrm && nrm < bv->orthog_eta*onrm) { l++; onrm = nrm; ierr = BVOrthogonalizeMGS1(bv,k,w,which,bv->c);CHKERRQ(ierr); ierr = BVNormVec(bv,w,NORM_2,&nrm);CHKERRQ(ierr); } if (lindep) *lindep = PetscNot(nrm >= bv->orthog_eta*onrm); break; case BV_ORTHOG_REFINE_NEVER: ierr = BVOrthogonalizeMGS1(bv,k,w,which,bv->h);CHKERRQ(ierr); /* compute |v| */ if (norm || lindep) { ierr = BVNormVec(bv,w,NORM_2,&nrm);CHKERRQ(ierr); } /* linear dependence check: just test for exactly zero norm */ if (lindep) *lindep = PetscNot(nrm); break; case BV_ORTHOG_REFINE_ALWAYS: /* first step */ ierr = BVOrthogonalizeMGS1(bv,k,w,which,bv->h);CHKERRQ(ierr); if (lindep) { ierr = BVNormVec(bv,w,NORM_2,&onrm);CHKERRQ(ierr); } /* second step */ ierr = BVOrthogonalizeMGS1(bv,k,w,which,bv->h);CHKERRQ(ierr); if (norm || lindep) { ierr = BVNormVec(bv,w,NORM_2,&nrm);CHKERRQ(ierr); } if (lindep) *lindep = PetscNot(nrm && nrm >= bv->orthog_eta*onrm); break; } if (bv->indef) { ierr = BVNormVec(bv,w,NORM_2,&nrm);CHKERRQ(ierr); bv->omega[bv->nc+j] = (nrm<0.0)? -1.0: 1.0; } if (!v) { ierr = BVRestoreColumn(bv,j,&w);CHKERRQ(ierr); } if (norm) *norm = nrm; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalizeCGS" /* BVOrthogonalizeCGS - Orthogonalize with classical Gram-Schmidt */ static PetscErrorCode BVOrthogonalizeCGS(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep) { PetscErrorCode ierr; PetscReal onrm,nrm; PetscInt i,k,l; PetscFunctionBegin; if (v) k = bv->k; else k = j; switch (bv->orthog_ref) { case BV_ORTHOG_REFINE_IFNEEDED: ierr = BVOrthogonalizeCGS1(bv,k,v,bv->h,&onrm,&nrm);CHKERRQ(ierr); /* ||q|| < eta ||h|| */ l = 1; while (l<3 && nrm && nrm < bv->orthog_eta*onrm) { l++; ierr = BVOrthogonalizeCGS1(bv,k,v,bv->c,&onrm,&nrm);CHKERRQ(ierr); for (i=0;inc+k;i++) bv->h[i] += bv->c[i]; } if (norm) *norm = nrm; if (lindep) *lindep = PetscNot(nrm >= bv->orthog_eta*onrm); break; case BV_ORTHOG_REFINE_NEVER: ierr = BVOrthogonalizeCGS1(bv,k,v,bv->h,NULL,NULL);CHKERRQ(ierr); /* compute |v| */ if (norm || lindep) { if (v) { ierr = BVNormVec(bv,v,NORM_2,&nrm);CHKERRQ(ierr); } else { ierr = BVNormColumn(bv,k,NORM_2,&nrm);CHKERRQ(ierr); } } if (norm) *norm = nrm; /* linear dependence check: just test for exactly zero norm */ if (lindep) *lindep = PetscNot(nrm); break; case BV_ORTHOG_REFINE_ALWAYS: ierr = BVOrthogonalizeCGS1(bv,k,v,bv->h,NULL,NULL);CHKERRQ(ierr); if (lindep) { ierr = BVOrthogonalizeCGS1(bv,k,v,bv->c,&onrm,&nrm);CHKERRQ(ierr); if (norm) *norm = nrm; *lindep = PetscNot(nrm && nrm >= bv->orthog_eta*onrm); } else { ierr = BVOrthogonalizeCGS1(bv,k,v,bv->c,NULL,norm);CHKERRQ(ierr); } for (i=0;inc+k;i++) bv->h[i] += bv->c[i]; break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalizeVec" /*@ BVOrthogonalizeVec - Orthogonalize a given vector with respect to all active columns. Collective on BV Input Parameters: + bv - the basis vectors context - v - the vector Output Parameters: + H - (optional) coefficients computed during orthogonalization . norm - (optional) norm of the vector after being orthogonalized - lindep - (optional) flag indicating that refinement did not improve the quality of orthogonalization Notes: This function is equivalent to BVOrthogonalizeColumn() but orthogonalizes a vector as an argument rather than taking one of the BV columns. The vector is orthogonalized against all active columns. Level: advanced .seealso: BVOrthogonalizeColumn(), BVSetOrthogonalization(), BVSetActiveColumns() @*/ PetscErrorCode BVOrthogonalizeVec(BV bv,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep) { PetscErrorCode ierr; PetscInt i,ksave,lsave; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidHeaderSpecific(v,VEC_CLASSID,2); PetscValidType(bv,1); BVCheckSizes(bv,1); PetscValidType(v,2); PetscCheckSameComm(bv,1,v,2); ierr = PetscLogEventBegin(BV_OrthogonalizeVec,bv,0,0,0);CHKERRQ(ierr); ksave = bv->k; lsave = bv->l; bv->l = -bv->nc; /* must also orthogonalize against constraints and leading columns */ ierr = BV_AllocateCoeffs(bv);CHKERRQ(ierr); ierr = BV_AllocateSignature(bv);CHKERRQ(ierr); switch (bv->orthog_type) { case BV_ORTHOG_CGS: ierr = BVOrthogonalizeCGS(bv,0,v,H,norm,lindep);CHKERRQ(ierr); break; case BV_ORTHOG_MGS: ierr = BVOrthogonalizeMGS(bv,0,v,NULL,H,norm,lindep);CHKERRQ(ierr); break; } bv->k = ksave; bv->l = lsave; if (H) for (i=bv->l;ik;i++) H[i-bv->l] = bv->h[bv->nc+i]; ierr = PetscLogEventEnd(BV_OrthogonalizeVec,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalizeColumn" /*@ BVOrthogonalizeColumn - Orthogonalize one of the column vectors with respect to the previous ones. Collective on BV Input Parameters: + bv - the basis vectors context - j - index of column to be orthogonalized Output Parameters: + H - (optional) coefficients computed during orthogonalization . norm - (optional) norm of the vector after being orthogonalized - lindep - (optional) flag indicating that refinement did not improve the quality of orthogonalization Notes: This function applies an orthogonal projector to project vector V[j] onto the orthogonal complement of the span of the columns of V[0..j-1], where V[.] are the vectors of BV. The columns V[0..j-1] are assumed to be mutually orthonormal. Leading columns V[0..l-1] also participate in the orthogonalization. If a non-standard inner product has been specified with BVSetMatrix(), then the vector is B-orthogonalized, using the non-standard inner product defined by matrix B. The output vector satisfies V[j]'*B*V[0..j-1] = 0. This routine does not normalize the resulting vector. Level: advanced .seealso: BVSetOrthogonalization(), BVSetMatrix(), BVSetActiveColumns(), BVOrthogonalize(), BVOrthogonalizeVec() @*/ PetscErrorCode BVOrthogonalizeColumn(BV bv,PetscInt j,PetscScalar *H,PetscReal *norm,PetscBool *lindep) { PetscErrorCode ierr; PetscInt i,ksave,lsave; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidType(bv,1); BVCheckSizes(bv,1); if (j<0) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative"); if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,bv->m); ierr = PetscLogEventBegin(BV_OrthogonalizeVec,bv,0,0,0);CHKERRQ(ierr); ksave = bv->k; lsave = bv->l; bv->l = -bv->nc; /* must also orthogonalize against constraints and leading columns */ ierr = BV_AllocateCoeffs(bv);CHKERRQ(ierr); ierr = BV_AllocateSignature(bv);CHKERRQ(ierr); switch (bv->orthog_type) { case BV_ORTHOG_CGS: ierr = BVOrthogonalizeCGS(bv,j,NULL,H,norm,lindep);CHKERRQ(ierr); break; case BV_ORTHOG_MGS: ierr = BVOrthogonalizeMGS(bv,j,NULL,NULL,H,norm,lindep);CHKERRQ(ierr); break; } bv->k = ksave; bv->l = lsave; if (H) for (i=bv->l;il] = bv->h[bv->nc+i]; ierr = PetscLogEventEnd(BV_OrthogonalizeVec,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalizeSomeColumn" /*@ BVOrthogonalizeSomeColumn - Orthogonalize one of the column vectors with respect to some of the previous ones. Collective on BV Input Parameters: + bv - the basis vectors context . j - index of column to be orthogonalized - which - logical array indicating selected columns Output Parameters: + H - (optional) coefficients computed during orthogonalization . norm - (optional) norm of the vector after being orthogonalized - lindep - (optional) flag indicating that refinement did not improve the quality of orthogonalization Notes: This function is similar to BVOrthogonalizeColumn(), but V[j] is orthogonalized only against columns V[i] having which[i]=PETSC_TRUE. The length of array which must be j at least. The use of this operation is restricted to MGS orthogonalization type. Level: advanced .seealso: BVOrthogonalizeColumn(), BVSetOrthogonalization() @*/ PetscErrorCode BVOrthogonalizeSomeColumn(BV bv,PetscInt j,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep) { PetscErrorCode ierr; PetscInt i,ksave,lsave; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidPointer(which,3); PetscValidType(bv,1); BVCheckSizes(bv,1); if (j<0) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative"); if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,bv->m); if (bv->orthog_type!=BV_ORTHOG_MGS) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Operation only available for MGS orthogonalization"); ierr = PetscLogEventBegin(BV_OrthogonalizeVec,bv,0,0,0);CHKERRQ(ierr); ksave = bv->k; lsave = bv->l; bv->l = -bv->nc; /* must also orthogonalize against constraints and leading columns */ ierr = BV_AllocateCoeffs(bv);CHKERRQ(ierr); ierr = BV_AllocateSignature(bv);CHKERRQ(ierr); ierr = BVOrthogonalizeMGS(bv,j,NULL,which,H,norm,lindep);CHKERRQ(ierr); bv->k = ksave; bv->l = lsave; if (H) for (i=bv->l;il] = bv->h[bv->nc+i]; ierr = PetscLogEventEnd(BV_OrthogonalizeVec,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalize_GS" /* Orthogonalize a set of vectors with Gram-Schmidt, column by column. */ static PetscErrorCode BVOrthogonalize_GS(BV V,Mat R) { PetscErrorCode ierr; PetscScalar *r=NULL; PetscReal norm; PetscInt j,ldr; Vec v; PetscFunctionBegin; if (R) { ierr = MatGetSize(R,&ldr,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(R,&r);CHKERRQ(ierr); } if (V->matrix) { ierr = BV_AllocateCachedBV(V);CHKERRQ(ierr); ierr = BVSetActiveColumns(V->cached,V->l,V->k);CHKERRQ(ierr); } for (j=V->l;jk;j++) { if (R) { ierr = BVOrthogonalizeColumn(V,j,r+j*ldr+V->l,&norm,NULL);CHKERRQ(ierr); r[j+j*ldr] = norm; } else { ierr = BVOrthogonalizeColumn(V,j,NULL,&norm,NULL);CHKERRQ(ierr); } if (!norm) SETERRQ(PETSC_COMM_SELF,1,"Breakdown in BVOrthogonalize due to a linearly dependent column"); if (V->matrix) { /* fill cached BV */ ierr = BVGetColumn(V->cached,j,&v);CHKERRQ(ierr); ierr = VecCopy(V->Bx,v);CHKERRQ(ierr); ierr = BVRestoreColumn(V->cached,j,&v);CHKERRQ(ierr); } ierr = BVScaleColumn(V,j,1.0/norm);CHKERRQ(ierr); } if (R) { ierr = MatDenseRestoreArray(R,&r);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCholeskyFactorInvert" /* Compute the upper Cholesky factor in R and its inverse in S. */ static PetscErrorCode MatCholeskyFactorInvert(Mat R,PetscInt l,Mat *S) { #if defined(PETSC_MISSING_LAPACK_POTRF) || defined(SLEPC_MISSING_LAPACK_TRTRI) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"POTRF/TRTRI - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,n,m,ld; PetscScalar *pR,*pS; PetscBLASInt info,n_,l_,m_,ld_; PetscFunctionBegin; ierr = MatGetSize(R,&m,NULL);CHKERRQ(ierr); n = m-l; ierr = PetscBLASIntCast(m,&m_);CHKERRQ(ierr); ierr = PetscBLASIntCast(l,&l_);CHKERRQ(ierr); ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ld = m; ld_ = m_; ierr = MatCreateSeqDense(PETSC_COMM_SELF,ld,ld,NULL,S);CHKERRQ(ierr); ierr = MatDenseGetArray(R,&pR);CHKERRQ(ierr); ierr = MatDenseGetArray(*S,&pS);CHKERRQ(ierr); /* save a copy of matrix in S */ for (i=l;ik,V->k,NULL,&R);CHKERRQ(ierr); } ierr = BVDot(V,V,R);CHKERRQ(ierr); ierr = MatCholeskyFactorInvert(R,V->l,&S);CHKERRQ(ierr); ierr = BVMultInPlace(V,S,V->l,V->k);CHKERRQ(ierr); ierr = MatDestroy(&S);CHKERRQ(ierr); if (!Rin) { ierr = MatDestroy(&R);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalize" /*@ BVOrthogonalize - Orthogonalize all columns (except leading ones), that is, compute the QR decomposition. Collective on BV Input Parameter: . V - basis vectors Output Parameters: + V - the modified basis vectors - R - a sequential dense matrix (or NULL) Notes: On input, matrix R must be a sequential dense Mat, with at least as many rows and columns as the number of active columns of V. The output satisfies V0 = V*R (where V0 represent the input V) and V'*V = I. If V has leading columns, then they are not modified (are assumed to be already orthonormal) and the corresponding part of R is not referenced. Can pass NULL if R is not required. The method to be used for block orthogonalization can be set with BVSetOrthogonalization(). If set to GS, the computation is done column by column with successive calls to BVOrthogonalizeColumn(). If V is rank-deficient or very ill-conditioned, that is, one or more columns are (almost) linearly dependent with respect to the rest, then the algorithm may break down or result in larger numerical error. Linearly dependent columns are essentially replaced by random directions, and the corresponding diagonal entry in R is set to (nearly) zero. Level: intermediate .seealso: BVOrthogonalizeColumn(), BVOrthogonalizeVec(), BVSetActiveColumns(), BVSetOrthogonalization(), BVOrthogBlockType @*/ PetscErrorCode BVOrthogonalize(BV V,Mat R) { PetscErrorCode ierr; PetscBool match; PetscInt m,n; PetscFunctionBegin; PetscValidHeaderSpecific(V,BV_CLASSID,1); PetscValidType(V,1); BVCheckSizes(V,1); if (R) { PetscValidHeaderSpecific(R,MAT_CLASSID,2); PetscValidType(R,2); if (V->l>0 && V->orthog_block==BV_ORTHOG_BLOCK_GS) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Cannot request matrix R in Gram-Schmidt orthogonalization if l>0"); ierr = PetscObjectTypeCompare((PetscObject)R,MATSEQDENSE,&match);CHKERRQ(ierr); if (!match) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Mat argument must be of type seqdense"); ierr = MatGetSize(R,&m,&n);CHKERRQ(ierr); if (m!=n) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument is not square, it has %D rows and %D columns",m,n); if (nk) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat size %D is smaller than the number of BV active columns %D",n,V->k); } if (V->nc) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Not implemented for BV with constraints, use BVOrthogonalizeColumn() instead"); ierr = PetscLogEventBegin(BV_Orthogonalize,V,R,0,0);CHKERRQ(ierr); switch (V->orthog_block) { case BV_ORTHOG_BLOCK_GS: /* proceed column by column with Gram-Schmidt */ ierr = BVOrthogonalize_GS(V,R);CHKERRQ(ierr); break; case BV_ORTHOG_BLOCK_CHOL: ierr = BVOrthogonalize_Chol(V,R);CHKERRQ(ierr); /*if (V->ops->orthogonalize) { ierr = (*V->ops->orthogonalize)(V,R);CHKERRQ(ierr); }*/ break; } ierr = PetscLogEventEnd(BV_Orthogonalize,V,R,0,0);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)V);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/interface/bvblas.c.html0000644000175000017500000010044313107004621022156 0ustar jromanjroman
Actual source code: bvblas.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV private kernels that use the BLAS.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>
 25: #include <slepcblaslapack.h>

 27: #define BLOCKSIZE 64

 31: /*
 32:     C := alpha*A*B + beta*C

 34:     A is mxk (ld=m), B is kxn (ld=ldb), C is mxn (ld=m)
 35: */
 36: PetscErrorCode BVMult_BLAS_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,PetscInt ldb_,PetscScalar alpha,const PetscScalar *A,const PetscScalar *B,PetscScalar beta,PetscScalar *C)
 37: {
 39:   PetscBLASInt   m,n,k,ldb;
 40: #if defined(PETSC_HAVE_FBLASLAPACK) || defined(PETSC_HAVE_F2CBLASLAPACK)
 41:   PetscBLASInt   l,bs=BLOCKSIZE;
 42: #endif

 45:   PetscBLASIntCast(m_,&m);
 46:   PetscBLASIntCast(n_,&n);
 47:   PetscBLASIntCast(k_,&k);
 48:   PetscBLASIntCast(ldb_,&ldb);
 49: #if defined(PETSC_HAVE_FBLASLAPACK) || defined(PETSC_HAVE_F2CBLASLAPACK)
 50:   l = m % bs;
 51:   if (l) PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&l,&n,&k,&alpha,(PetscScalar*)A,&m,(PetscScalar*)B,&ldb,&beta,C,&m));
 52:   for (;l<m;l+=bs) {
 53:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&bs,&n,&k,&alpha,(PetscScalar*)A+l,&m,(PetscScalar*)B,&ldb,&beta,C+l,&m));
 54:   }
 55: #else
 56:   if (m) PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&m,&n,&k,&alpha,(PetscScalar*)A,&m,(PetscScalar*)B,&ldb,&beta,C,&m));
 57: #endif
 58:   PetscLogFlops(2.0*m*n*k);
 59:   return(0);
 60: }

 64: /*
 65:     y := alpha*A*x + beta*y

 67:     A is nxk (ld=n)
 68: */
 69: PetscErrorCode BVMultVec_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,PetscScalar alpha,const PetscScalar *A,const PetscScalar *x,PetscScalar beta,PetscScalar *y)
 70: {
 72:   PetscBLASInt   n,k,one=1;

 75:   PetscBLASIntCast(n_,&n);
 76:   PetscBLASIntCast(k_,&k);
 77:   if (n) PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&k,&alpha,A,&n,x,&one,&beta,y,&one));
 78:   PetscLogFlops(2.0*n*k);
 79:   return(0);
 80: }

 84: /*
 85:     A(:,s:e-1) := A*B(:,s:e-1)

 87:     A is mxk (ld=m), B is kxn (ld=ldb)  n=e-s
 88: */
 89: PetscErrorCode BVMultInPlace_BLAS_Private(BV bv,PetscInt m_,PetscInt k_,PetscInt ldb_,PetscInt s,PetscInt e,PetscScalar *A,const PetscScalar *B,PetscBool btrans)
 90: {
 92:   PetscScalar    *pb,zero=0.0,one=1.0;
 93:   PetscBLASInt   m,n,k,l,ldb,bs=BLOCKSIZE;
 94:   PetscInt       j,n_=e-s;
 95:   const char     *bt;

 98:   PetscBLASIntCast(m_,&m);
 99:   PetscBLASIntCast(n_,&n);
100:   PetscBLASIntCast(k_,&k);
101:   PetscBLASIntCast(ldb_,&ldb);
102:   BVAllocateWork_Private(bv,BLOCKSIZE*n_);
103:   if (btrans) {
104:     pb = (PetscScalar*)B+s;
105:     bt = "C";
106:   } else {
107:     pb = (PetscScalar*)B+s*ldb;
108:     bt = "N";
109:   }
110:   l = m % bs;
111:   if (l) {
112:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N",bt,&l,&n,&k,&one,A,&m,pb,&ldb,&zero,bv->work,&l));
113:     for (j=0;j<n;j++) {
114:       PetscMemcpy(A+(s+j)*m,bv->work+j*l,l*sizeof(PetscScalar));
115:     }
116:   }
117:   for (;l<m;l+=bs) {
118:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N",bt,&bs,&n,&k,&one,A+l,&m,pb,&ldb,&zero,bv->work,&bs));
119:     for (j=0;j<n;j++) {
120:       PetscMemcpy(A+(s+j)*m+l,bv->work+j*bs,bs*sizeof(PetscScalar));
121:     }
122:   }
123:   PetscLogFlops(2.0*m*n*k);
124:   return(0);
125: }

129: /*
130:     V := V*B

132:     V is mxn (ld=m), B is nxn (ld=k)
133: */
134: PetscErrorCode BVMultInPlace_Vecs_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,Vec *V,const PetscScalar *B,PetscBool btrans)
135: {
136:   PetscErrorCode    ierr;
137:   PetscScalar       zero=0.0,one=1.0,*out,*pout;
138:   const PetscScalar *pin;
139:   PetscBLASInt      m,n,k,l,bs=BLOCKSIZE;
140:   PetscInt          j;
141:   const char        *bt;

144:   PetscBLASIntCast(m_,&m);
145:   PetscBLASIntCast(n_,&n);
146:   PetscBLASIntCast(k_,&k);
147:   BVAllocateWork_Private(bv,2*BLOCKSIZE*n_);
148:   out = bv->work+BLOCKSIZE*n_;
149:   if (btrans) bt = "C";
150:   else bt = "N";
151:   l = m % bs;
152:   if (l) {
153:     for (j=0;j<n;j++) {
154:       VecGetArrayRead(V[j],&pin);
155:       PetscMemcpy(bv->work+j*l,pin,l*sizeof(PetscScalar));
156:       VecRestoreArrayRead(V[j],&pin);
157:     }
158:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N",bt,&l,&n,&n,&one,bv->work,&l,(PetscScalar*)B,&k,&zero,out,&l));
159:     for (j=0;j<n;j++) {
160:       VecGetArray(V[j],&pout);
161:       PetscMemcpy(pout,out+j*l,l*sizeof(PetscScalar));
162:       VecRestoreArray(V[j],&pout);
163:     }
164:   }
165:   for (;l<m;l+=bs) {
166:     for (j=0;j<n;j++) {
167:       VecGetArrayRead(V[j],&pin);
168:       PetscMemcpy(bv->work+j*bs,pin+l,bs*sizeof(PetscScalar));
169:       VecRestoreArrayRead(V[j],&pin);
170:     }
171:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N",bt,&bs,&n,&n,&one,bv->work,&bs,(PetscScalar*)B,&k,&zero,out,&bs));
172:     for (j=0;j<n;j++) {
173:       VecGetArray(V[j],&pout);
174:       PetscMemcpy(pout+l,out+j*bs,bs*sizeof(PetscScalar));
175:       VecRestoreArray(V[j],&pout);
176:     }
177:   }
178:   PetscLogFlops(2.0*n*n*k);
179:   return(0);
180: }

184: /*
185:     B := alpha*A + beta*B

187:     A,B are nxk (ld=n)
188: */
189: PetscErrorCode BVAXPY_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,PetscScalar alpha,const PetscScalar *A,PetscScalar beta,PetscScalar *B)
190: {
192:   PetscBLASInt   m,one=1;

195:   PetscBLASIntCast(n_*k_,&m);
196:   if (beta!=(PetscScalar)1.0) {
197:     PetscStackCallBLAS("BLASscal",BLASscal_(&m,&beta,B,&one));
198:     PetscLogFlops(m);
199:   }
200:   PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&m,&alpha,A,&one,B,&one));
201:   PetscLogFlops(2.0*m);
202:   return(0);
203: }

207: /*
208:     C := A'*B

210:     A' is mxk (ld=k), B is kxn (ld=k), C is mxn (ld=ldc)
211: */
212: PetscErrorCode BVDot_BLAS_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,PetscInt ldc_,const PetscScalar *A,const PetscScalar *B,PetscScalar *C,PetscBool mpi)
213: {
215:   PetscScalar    zero=0.0,one=1.0,*CC;
216:   PetscBLASInt   m,n,k,ldc,j,len;

219:   PetscBLASIntCast(m_,&m);
220:   PetscBLASIntCast(n_,&n);
221:   PetscBLASIntCast(k_,&k);
222:   PetscBLASIntCast(ldc_,&ldc);
223:   if (mpi) {
224:     if (ldc==m) {
225:       BVAllocateWork_Private(bv,m*n);
226:       if (k) PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&m,&n,&k,&one,(PetscScalar*)A,&k,(PetscScalar*)B,&k,&zero,bv->work,&ldc));
227:       else { PetscMemzero(bv->work,m*n*sizeof(PetscScalar)); }
228:       PetscMPIIntCast(m*n,&len);
229:       MPI_Allreduce(bv->work,C,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv));
230:     } else {
231:       BVAllocateWork_Private(bv,2*m*n);
232:       CC = bv->work+m*n;
233:       if (k) PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&m,&n,&k,&one,(PetscScalar*)A,&k,(PetscScalar*)B,&k,&zero,bv->work,&m));
234:       else { PetscMemzero(bv->work,m*n*sizeof(PetscScalar)); }
235:       PetscMPIIntCast(m*n,&len);
236:       MPI_Allreduce(bv->work,CC,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv));
237:       for (j=0;j<n;j++) {
238:         PetscMemcpy(C+j*ldc,CC+j*m,m*sizeof(PetscScalar));
239:       }
240:     }
241:   } else {
242:     if (k) PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&m,&n,&k,&one,(PetscScalar*)A,&k,(PetscScalar*)B,&k,&zero,C,&ldc));
243:   }
244:   PetscLogFlops(2.0*m*n*k);
245:   return(0);
246: }

250: /*
251:     y := A'*x

253:     A is nxk (ld=n)
254: */
255: PetscErrorCode BVDotVec_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,const PetscScalar *A,const PetscScalar *x,PetscScalar *y,PetscBool mpi)
256: {
258:   PetscScalar    zero=0.0,done=1.0;
259:   PetscBLASInt   n,k,one=1,len;

262:   PetscBLASIntCast(n_,&n);
263:   PetscBLASIntCast(k_,&k);
264:   if (mpi) {
265:     BVAllocateWork_Private(bv,k);
266:     if (n) {
267:       PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n,&k,&done,A,&n,x,&one,&zero,bv->work,&one));
268:     } else {
269:       PetscMemzero(bv->work,k*sizeof(PetscScalar));
270:     }
271:     PetscMPIIntCast(k,&len);
272:     MPI_Allreduce(bv->work,y,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv));
273:   } else {
274:     if (n) PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n,&k,&done,A,&n,x,&one,&zero,y,&one));
275:   }
276:   PetscLogFlops(2.0*n*k);
277:   return(0);
278: }

282: /*
283:     Scale n scalars
284: */
285: PetscErrorCode BVScale_BLAS_Private(BV bv,PetscInt n_,PetscScalar *A,PetscScalar alpha)
286: {
288:   PetscBLASInt   n,one=1;

291:   if (alpha == (PetscScalar)0.0) {
292:     PetscMemzero(A,n_*sizeof(PetscScalar));
293:   } else if (alpha!=(PetscScalar)1.0) {
294:     PetscBLASIntCast(n_,&n);
295:     PetscStackCallBLAS("BLASscal",BLASscal_(&n,&alpha,A,&one));
296:     PetscLogFlops(n);
297:   }
298:   return(0);
299: }

303: /*
304:     Compute ||A|| for an mxn matrix
305: */
306: PetscErrorCode BVNorm_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,const PetscScalar *A,NormType type,PetscReal *nrm,PetscBool mpi)
307: {
309:   PetscBLASInt   m,n,i,j;
310:   PetscMPIInt    len;
311:   PetscReal      lnrm,*rwork=NULL,*rwork2=NULL;

314:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
315:   PetscBLASIntCast(m_,&m);
316:   PetscBLASIntCast(n_,&n);
317:   if (type==NORM_FROBENIUS || type==NORM_2) {
318:     lnrm = LAPACKlange_("F",&m,&n,(PetscScalar*)A,&m,rwork);
319:     if (mpi) {
320:       lnrm = lnrm*lnrm;
321:       MPI_Allreduce(&lnrm,nrm,1,MPIU_REAL,MPIU_SUM,PetscObjectComm((PetscObject)bv));
322:       *nrm = PetscSqrtReal(*nrm);
323:     } else *nrm = lnrm;
324:     PetscLogFlops(2.0*m*n);
325:   } else if (type==NORM_1) {
326:     if (mpi) {
327:       BVAllocateWork_Private(bv,2*n_);
328:       rwork = (PetscReal*)bv->work;
329:       rwork2 = rwork+n_;
330:       PetscMemzero(rwork,n_*sizeof(PetscReal));
331:       PetscMemzero(rwork2,n_*sizeof(PetscReal));
332:       for (j=0;j<n_;j++) {
333:         for (i=0;i<m_;i++) {
334:           rwork[j] += PetscAbsScalar(A[i+j*m_]);
335:         }
336:       }
337:       PetscMPIIntCast(n_,&len);
338:       MPI_Allreduce(rwork,rwork2,len,MPIU_REAL,MPIU_SUM,PetscObjectComm((PetscObject)bv));
339:       *nrm = 0.0;
340:       for (j=0;j<n_;j++) if (rwork2[j] > *nrm) *nrm = rwork2[j];
341:     } else {
342:       *nrm = LAPACKlange_("O",&m,&n,(PetscScalar*)A,&m,rwork);
343:     }
344:     PetscLogFlops(1.0*m*n);
345:   } else if (type==NORM_INFINITY) {
346:     BVAllocateWork_Private(bv,m_);
347:     rwork = (PetscReal*)bv->work;
348:     lnrm = LAPACKlange_("I",&m,&n,(PetscScalar*)A,&m,rwork);
349:     if (mpi) {
350:       MPI_Allreduce(&lnrm,nrm,1,MPIU_REAL,MPIU_MAX,PetscObjectComm((PetscObject)bv));
351:     } else *nrm = lnrm;
352:     PetscLogFlops(1.0*m*n);
353:   }
354:   PetscFPTrapPop();
355:   return(0);
356: }

360: /*
361:     QR factorization of an mxn matrix
362: */
363: PetscErrorCode BVOrthogonalize_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,PetscScalar *Q,PetscScalar *R,PetscBool mpi)
364: {
365: #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR)
367:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routines are unavailable");
368: #else
370:   PetscBLASInt   m,n,i,j,k,l,nb,lwork,info;
371:   PetscScalar    *tau,*work,*Rl=NULL,*A=NULL,*C=NULL,one=1.0,zero=0.0;
372:   PetscMPIInt    rank,size,len;

375:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
376:   PetscBLASIntCast(m_,&m);
377:   PetscBLASIntCast(n_,&n);
378:   k = PetscMin(m,n);
379:   nb = 16;
380:   if (mpi) {
381:     MPI_Comm_rank(PetscObjectComm((PetscObject)bv),&rank);
382:     MPI_Comm_size(PetscObjectComm((PetscObject)bv),&size);
383:     BVAllocateWork_Private(bv,k+n*nb+n*n+n*n*size+m*n);
384:   } else {
385:     BVAllocateWork_Private(bv,k+n*nb);
386:    }
387:   tau = bv->work;
388:   work = bv->work+k;
389:   PetscBLASIntCast(n*nb,&lwork);
390:   if (mpi) {
391:     Rl = bv->work+k+n*nb;
392:     A  = bv->work+k+n*nb+n*n;
393:     C  = bv->work+k+n*nb+n*n+n*n*size;
394:   }

396:   /* Compute QR */
397:   PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&m,&n,Q,&m,tau,work,&lwork,&info));
398:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);

400:   /* Extract R */
401:   if (R || mpi) {
402:     PetscMemzero(mpi? Rl: R,n*n*sizeof(PetscScalar));
403:     for (j=0;j<n;j++) {
404:       for (i=0;i<=j;i++) {
405:         if (mpi) Rl[i+j*n] = Q[i+j*m];
406:         else R[i+j*n] = Q[i+j*m];
407:       }
408:     }
409:   }

411:   /* Compute orthogonal matrix in Q */
412:   PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&m,&n,&k,Q,&m,tau,work,&lwork,&info));
413:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info);

415:   if (mpi) {

417:     /* Stack triangular matrices */
418:     PetscBLASIntCast(n*size,&l);
419:     PetscMPIIntCast(n,&len);
420:     for (j=0;j<n;j++) {
421:       MPI_Allgather(Rl+j*n,len,MPIU_SCALAR,A+j*l,len,MPIU_SCALAR,PetscObjectComm((PetscObject)bv));
422:     }

424:     /* Compute QR */
425:     PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&l,&n,A,&l,tau,work,&lwork,&info));
426:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);

428:     /* Extract R */
429:     if (R) {
430:       PetscMemzero(R,n*n*sizeof(PetscScalar));
431:       for (j=0;j<n;j++)
432:         for (i=0;i<=j;i++)
433:           R[i+j*n] = A[i+j*l];
434:     }

436:     /* Accumulate orthogonal matrix */
437:     PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&l,&n,&n,A,&l,tau,work,&lwork,&info));
438:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info);
439:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&m,&n,&n,&one,Q,&m,A+rank*n,&l,&zero,C,&m));
440:     PetscMemcpy(Q,C,m*n*sizeof(PetscScalar));
441:   }

443:   PetscLogFlops(3.0*m*n*n);
444:   PetscFPTrapPop();
445:   return(0);
446: #endif
447: }

slepc-3.7.4/src/sys/classes/bv/interface/bvfunc.c.html0000644000175000017500000014773713107004621022211 0ustar jromanjroman
Actual source code: bvfunc.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV (basis vectors) interface routines, callable by users.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>            /*I "slepcbv.h" I*/

 26: PetscClassId     BV_CLASSID = 0;
 27: PetscLogEvent    BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;
 28: static PetscBool BVPackageInitialized = PETSC_FALSE;

 30: const char *BVOrthogTypes[] = {"CGS","MGS","BVOrthogType","BV_ORTHOG_",0};
 31: const char *BVOrthogRefineTypes[] = {"IFNEEDED","NEVER","ALWAYS","BVOrthogRefineType","BV_ORTHOG_REFINE_",0};
 32: const char *BVOrthogBlockTypes[] = {"GS","CHOL","BVOrthogBlockType","BV_ORTHOG_BLOCK_",0};
 33: const char *BVMatMultTypes[] = {"VECS","MAT","MAT_SAVE","BVMatMultType","BV_MATMULT_",0};

 37: /*@C
 38:    BVFinalizePackage - This function destroys everything in the Slepc interface
 39:    to the BV package. It is called from SlepcFinalize().

 41:    Level: developer

 43: .seealso: SlepcFinalize()
 44: @*/
 45: PetscErrorCode BVFinalizePackage(void)
 46: {

 50:   PetscFunctionListDestroy(&BVList);
 51:   BVPackageInitialized = PETSC_FALSE;
 52:   BVRegisterAllCalled  = PETSC_FALSE;
 53:   return(0);
 54: }

 58: /*@C
 59:    BVInitializePackage - This function initializes everything in the BV package.
 60:    It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 61:    on the first call to BVCreate() when using static libraries.

 63:    Level: developer

 65: .seealso: SlepcInitialize()
 66: @*/
 67: PetscErrorCode BVInitializePackage(void)
 68: {
 69:   char           logList[256];
 70:   char           *className;
 71:   PetscBool      opt;

 75:   if (BVPackageInitialized) return(0);
 76:   BVPackageInitialized = PETSC_TRUE;
 77:   /* Register Classes */
 78:   PetscClassIdRegister("Basis Vectors",&BV_CLASSID);
 79:   /* Register Constructors */
 80:   BVRegisterAll();
 81:   /* Register Events */
 82:   PetscLogEventRegister("BVCreate",BV_CLASSID,&BV_Create);
 83:   PetscLogEventRegister("BVCopy",BV_CLASSID,&BV_Copy);
 84:   PetscLogEventRegister("BVMult",BV_CLASSID,&BV_Mult);
 85:   PetscLogEventRegister("BVMultVec",BV_CLASSID,&BV_MultVec);
 86:   PetscLogEventRegister("BVMultInPlace",BV_CLASSID,&BV_MultInPlace);
 87:   PetscLogEventRegister("BVDot",BV_CLASSID,&BV_Dot);
 88:   PetscLogEventRegister("BVDotVec",BV_CLASSID,&BV_DotVec);
 89:   PetscLogEventRegister("BVOrthogonalize",BV_CLASSID,&BV_Orthogonalize);
 90:   PetscLogEventRegister("BVOrthogonalizeV",BV_CLASSID,&BV_OrthogonalizeVec);
 91:   PetscLogEventRegister("BVScale",BV_CLASSID,&BV_Scale);
 92:   PetscLogEventRegister("BVNorm",BV_CLASSID,&BV_Norm);
 93:   PetscLogEventRegister("BVNormVec",BV_CLASSID,&BV_NormVec);
 94:   PetscLogEventRegister("BVSetRandom",BV_CLASSID,&BV_SetRandom);
 95:   PetscLogEventRegister("BVMatMult",BV_CLASSID,&BV_MatMult);
 96:   PetscLogEventRegister("BVMatMultVec",BV_CLASSID,&BV_MatMultVec);
 97:   PetscLogEventRegister("BVMatProject",BV_CLASSID,&BV_MatProject);
 98:   /* Process info exclusions */
 99:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
100:   if (opt) {
101:     PetscStrstr(logList,"bv",&className);
102:     if (className) {
103:       PetscInfoDeactivateClass(BV_CLASSID);
104:     }
105:   }
106:   /* Process summary exclusions */
107:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
108:   if (opt) {
109:     PetscStrstr(logList,"bv",&className);
110:     if (className) {
111:       PetscLogEventDeactivateClass(BV_CLASSID);
112:     }
113:   }
114:   PetscRegisterFinalize(BVFinalizePackage);
115:   return(0);
116: }

120: /*@
121:    BVDestroy - Destroys BV context that was created with BVCreate().

123:    Collective on BV

125:    Input Parameter:
126: .  bv - the basis vectors context

128:    Level: beginner

130: .seealso: BVCreate()
131: @*/
132: PetscErrorCode BVDestroy(BV *bv)
133: {

137:   if (!*bv) return(0);
139:   if (--((PetscObject)(*bv))->refct > 0) { *bv = 0; return(0); }
140:   if ((*bv)->ops->destroy) { (*(*bv)->ops->destroy)(*bv); }
141:   VecDestroy(&(*bv)->t);
142:   MatDestroy(&(*bv)->matrix);
143:   VecDestroy(&(*bv)->Bx);
144:   BVDestroy(&(*bv)->cached);
145:   PetscFree((*bv)->work);
146:   PetscFree2((*bv)->h,(*bv)->c);
147:   PetscFree((*bv)->omega);
148:   MatDestroy(&(*bv)->B);
149:   MatDestroy(&(*bv)->C);
150:   PetscRandomDestroy(&(*bv)->rand);
151:   PetscHeaderDestroy(bv);
152:   return(0);
153: }

157: /*@
158:    BVCreate - Creates a basis vectors context.

160:    Collective on MPI_Comm

162:    Input Parameter:
163: .  comm - MPI communicator

165:    Output Parameter:
166: .  bv - location to put the basis vectors context

168:    Level: beginner

170: .seealso: BVSetUp(), BVDestroy(), BV
171: @*/
172: PetscErrorCode BVCreate(MPI_Comm comm,BV *newbv)
173: {
175:   BV             bv;

179:   *newbv = 0;
180:   BVInitializePackage();
181:   SlepcHeaderCreate(bv,BV_CLASSID,"BV","Basis Vectors","BV",comm,BVDestroy,BVView);

183:   bv->t            = NULL;
184:   bv->n            = -1;
185:   bv->N            = -1;
186:   bv->m            = 0;
187:   bv->l            = 0;
188:   bv->k            = 0;
189:   bv->nc           = 0;
190:   bv->orthog_type  = BV_ORTHOG_CGS;
191:   bv->orthog_ref   = BV_ORTHOG_REFINE_IFNEEDED;
192:   bv->orthog_eta   = 0.7071;
193:   bv->orthog_block = BV_ORTHOG_BLOCK_GS;
194:   bv->matrix       = NULL;
195:   bv->indef        = PETSC_FALSE;
196:   bv->vmm          = BV_MATMULT_MAT;

198:   bv->Bx           = NULL;
199:   bv->xid          = 0;
200:   bv->xstate       = 0;
201:   bv->cv[0]        = NULL;
202:   bv->cv[1]        = NULL;
203:   bv->ci[0]        = -1;
204:   bv->ci[1]        = -1;
205:   bv->st[0]        = -1;
206:   bv->st[1]        = -1;
207:   bv->id[0]        = 0;
208:   bv->id[1]        = 0;
209:   bv->h            = NULL;
210:   bv->c            = NULL;
211:   bv->omega        = NULL;
212:   bv->B            = NULL;
213:   bv->C            = NULL;
214:   bv->Aid          = 0;
215:   bv->defersfo     = PETSC_FALSE;
216:   bv->cached       = NULL;
217:   bv->bvstate      = 0;
218:   bv->rand         = NULL;
219:   bv->rrandom      = PETSC_FALSE;
220:   bv->work         = NULL;
221:   bv->lwork        = 0;
222:   bv->data         = NULL;

224:   *newbv = bv;
225:   return(0);
226: }

230: /*@
231:    BVInsertVec - Insert a vector into the specified column.

233:    Collective on BV

235:    Input Parameters:
236: +  V - basis vectors
237: .  j - the column of V to be overwritten
238: -  w - the vector to be copied

240:    Level: intermediate

242: .seealso: BVInsertVecs()
243: @*/
244: PetscErrorCode BVInsertVec(BV V,PetscInt j,Vec w)
245: {
247:   PetscInt       n,N;
248:   Vec            v;

255:   BVCheckSizes(V,1);

258:   VecGetSize(w,&N);
259:   VecGetLocalSize(w,&n);
260:   if (N!=V->N || n!=V->n) SETERRQ4(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,V->N,V->n);
261:   if (j<-V->nc || j>=V->m) SETERRQ3(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, should be between %D and %D",j,-V->nc,V->m-1);

263:   BVGetColumn(V,j,&v);
264:   VecCopy(w,v);
265:   BVRestoreColumn(V,j,&v);
266:   PetscObjectStateIncrease((PetscObject)V);
267:   return(0);
268: }

272: /*@
273:    BVInsertVecs - Insert a set of vectors into the specified columns.

275:    Collective on BV

277:    Input Parameters:
278: +  V - basis vectors
279: .  s - first column of V to be overwritten
280: .  W - set of vectors to be copied
281: -  orth - flag indicating if the vectors must be orthogonalized

283:    Input/Output Parameter:
284: .  m - number of input vectors, on output the number of linearly independent
285:        vectors

287:    Notes:
288:    Copies the contents of vectors W to V(:,s:s+n). If the orthogonalization
289:    flag is set, then the vectors are copied one by one and then orthogonalized
290:    against the previous ones. If any of them is linearly dependent then it
291:    is discarded and the value of m is decreased.

293:    Level: intermediate

295: .seealso: BVInsertVec(), BVOrthogonalizeColumn()
296: @*/
297: PetscErrorCode BVInsertVecs(BV V,PetscInt s,PetscInt *m,Vec *W,PetscBool orth)
298: {
300:   PetscInt       n,N,i,ndep;
301:   PetscBool      lindep;
302:   PetscReal      norm;
303:   Vec            v;

310:   if (!*m) return(0);
311:   if (*m<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Number of vectors (given %D) cannot be negative",*m);
316:   BVCheckSizes(V,1);

319:   VecGetSize(*W,&N);
320:   VecGetLocalSize(*W,&n);
321:   if (N!=V->N || n!=V->n) SETERRQ4(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_INCOMP,"Vec sizes (global %D, local %D) do not match BV sizes (global %D, local %D)",N,n,V->N,V->n);
322:   if (s<0 || s>=V->m) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Argument s has wrong value %D, should be between 0 and %D",s,V->m-1);
323:   if (s+(*m)>V->m) SETERRQ1(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_OUTOFRANGE,"Too many vectors provided, there is only room for %D",V->m);

325:   ndep = 0;
326:   for (i=0;i<*m;i++) {
327:     BVGetColumn(V,s+i-ndep,&v);
328:     VecCopy(W[i],v);
329:     BVRestoreColumn(V,s+i-ndep,&v);
330:     if (orth) {
331:       BVOrthogonalizeColumn(V,s+i-ndep,NULL,&norm,&lindep);
332:       if (norm==0.0 || lindep) {
333:         PetscInfo1(V,"Removing linearly dependent vector %D\n",i);
334:         ndep++;
335:       } else {
336:         BVScaleColumn(V,s+i-ndep,1.0/norm);
337:       }
338:     }
339:   }
340:   *m -= ndep;
341:   PetscObjectStateIncrease((PetscObject)V);
342:   return(0);
343: }

347: /*@
348:    BVInsertConstraints - Insert a set of vectors as constraints.

350:    Collective on BV

352:    Input Parameters:
353: +  V - basis vectors
354: -  C - set of vectors to be inserted as constraints

356:    Input/Output Parameter:
357: .  nc - number of input vectors, on output the number of linearly independent
358:        vectors

360:    Notes:
361:    The constraints are relevant only during orthogonalization. Constraint
362:    vectors span a subspace that is deflated in every orthogonalization
363:    operation, so they are intended for removing those directions from the
364:    orthogonal basis computed in regular BV columns.

366:    Constraints are not stored in regular BV colums, but in a special part of
367:    the storage. They can be accessed with negative indices in BVGetColumn().

369:    This operation is DESTRUCTIVE, meaning that all data contained in the
370:    columns of V is lost. This is typically invoked just after creating the BV.
371:    Once a set of constraints has been set, it is not allowed to call this
372:    function again.

374:    The vectors are copied one by one and then orthogonalized against the
375:    previous ones. If any of them is linearly dependent then it is discarded
376:    and the value of nc is decreased. The behaviour is similar to BVInsertVecs().

378:    Level: advanced

380: .seealso: BVInsertVecs(), BVOrthogonalizeColumn(), BVGetColumn(), BVGetNumConstraints()
381: @*/
382: PetscErrorCode BVInsertConstraints(BV V,PetscInt *nc,Vec *C)
383: {
385:   PetscInt       msave;

391:   if (!*nc) return(0);
392:   if (*nc<0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Number of constraints (given %D) cannot be negative",*nc);
396:   BVCheckSizes(V,1);
398:   if (V->nc) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_WRONGSTATE,"Constraints already present in this BV object");
399:   if (V->ci[0]!=-1 || V->ci[1]!=-1) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Cannot call BVInsertConstraints after BVGetColumn");

401:   msave = V->m;
402:   BVResize(V,*nc+V->m,PETSC_FALSE);
403:   BVInsertVecs(V,0,nc,C,PETSC_TRUE);
404:   V->nc = *nc;
405:   V->m  = msave;
406:   V->ci[0] = -V->nc-1;
407:   V->ci[1] = -V->nc-1;
408:   PetscObjectStateIncrease((PetscObject)V);
409:   return(0);
410: }

414: /*@C
415:    BVSetOptionsPrefix - Sets the prefix used for searching for all
416:    BV options in the database.

418:    Logically Collective on BV

420:    Input Parameters:
421: +  bv     - the basis vectors context
422: -  prefix - the prefix string to prepend to all BV option requests

424:    Notes:
425:    A hyphen (-) must NOT be given at the beginning of the prefix name.
426:    The first character of all runtime options is AUTOMATICALLY the
427:    hyphen.

429:    Level: advanced

431: .seealso: BVAppendOptionsPrefix(), BVGetOptionsPrefix()
432: @*/
433: PetscErrorCode BVSetOptionsPrefix(BV bv,const char *prefix)
434: {

439:   PetscObjectSetOptionsPrefix((PetscObject)bv,prefix);
440:   return(0);
441: }

445: /*@C
446:    BVAppendOptionsPrefix - Appends to the prefix used for searching for all
447:    BV options in the database.

449:    Logically Collective on BV

451:    Input Parameters:
452: +  bv     - the basis vectors context
453: -  prefix - the prefix string to prepend to all BV option requests

455:    Notes:
456:    A hyphen (-) must NOT be given at the beginning of the prefix name.
457:    The first character of all runtime options is AUTOMATICALLY the
458:    hyphen.

460:    Level: advanced

462: .seealso: BVSetOptionsPrefix(), BVGetOptionsPrefix()
463: @*/
464: PetscErrorCode BVAppendOptionsPrefix(BV bv,const char *prefix)
465: {

470:   PetscObjectAppendOptionsPrefix((PetscObject)bv,prefix);
471:   return(0);
472: }

476: /*@C
477:    BVGetOptionsPrefix - Gets the prefix used for searching for all
478:    BV options in the database.

480:    Not Collective

482:    Input Parameters:
483: .  bv - the basis vectors context

485:    Output Parameters:
486: .  prefix - pointer to the prefix string used, is returned

488:    Note:
489:    On the Fortran side, the user should pass in a string 'prefix' of
490:    sufficient length to hold the prefix.

492:    Level: advanced

494: .seealso: BVSetOptionsPrefix(), BVAppendOptionsPrefix()
495: @*/
496: PetscErrorCode BVGetOptionsPrefix(BV bv,const char *prefix[])
497: {

503:   PetscObjectGetOptionsPrefix((PetscObject)bv,prefix);
504:   return(0);
505: }

509: static PetscErrorCode BVView_Default(BV bv,PetscViewer viewer)
510: {
511:   PetscErrorCode    ierr;
512:   PetscInt          j;
513:   Vec               v;
514:   PetscViewerFormat format;
515:   PetscBool         isascii,ismatlab=PETSC_FALSE;
516:   const char        *bvname,*name;

519:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
520:   if (isascii) {
521:     PetscViewerGetFormat(viewer,&format);
522:     if (format == PETSC_VIEWER_ASCII_MATLAB) ismatlab = PETSC_TRUE;
523:   }
524:   if (ismatlab) {
525:     PetscObjectGetName((PetscObject)bv,&bvname);
526:     PetscViewerASCIIPrintf(viewer,"%s=[];\n",bvname);
527:   }
528:   for (j=-bv->nc;j<bv->m;j++) {
529:     BVGetColumn(bv,j,&v);
530:     VecView(v,viewer);
531:     if (ismatlab) {
532:       PetscObjectGetName((PetscObject)v,&name);
533:       PetscViewerASCIIPrintf(viewer,"%s=[%s,%s];clear %s\n",bvname,bvname,name,name);
534:     }
535:     BVRestoreColumn(bv,j,&v);
536:   }
537:   return(0);
538: }

542: /*@C
543:    BVView - Prints the BV data structure.

545:    Collective on BV

547:    Input Parameters:
548: +  bv     - the BV context
549: -  viewer - optional visualization context

551:    Note:
552:    The available visualization contexts include
553: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
554: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
555:          output where only the first processor opens
556:          the file.  All other processors send their
557:          data to the first processor to print.

559:    The user can open an alternative visualization contexts with
560:    PetscViewerASCIIOpen() (output to a specified file).

562:    Level: beginner

564: .seealso: PetscViewerASCIIOpen()
565: @*/
566: PetscErrorCode BVView(BV bv,PetscViewer viewer)
567: {
568:   PetscErrorCode    ierr;
569:   PetscBool         isascii;
570:   PetscViewerFormat format;
571:   const char        *orthname[2] = {"classical","modified"};
572:   const char        *refname[3] = {"if needed","never","always"};
573:   const char        *borthname[2] = {"Gram-Schmidt","Cholesky"};

577:   if (!viewer) {
578:     PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)bv),&viewer);
579:   }

582:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
583:   if (isascii) {
584:     PetscObjectPrintClassNamePrefixType((PetscObject)bv,viewer);
585:     PetscViewerGetFormat(viewer,&format);
586:     PetscViewerASCIIPushTab(viewer);
587:     if (format == PETSC_VIEWER_ASCII_INFO || format == PETSC_VIEWER_ASCII_INFO_DETAIL) {
588:       PetscViewerASCIIPrintf(viewer,"%D columns of global length %D\n",bv->m,bv->N);
589:       if (bv->nc>0) {
590:         PetscViewerASCIIPrintf(viewer,"number of constraints: %D\n",bv->nc);
591:       }
592:       PetscViewerASCIIPrintf(viewer,"vector orthogonalization method: %s Gram-Schmidt\n",orthname[bv->orthog_type]);
593:       switch (bv->orthog_ref) {
594:         case BV_ORTHOG_REFINE_IFNEEDED:
595:           PetscViewerASCIIPrintf(viewer,"orthogonalization refinement: %s (eta: %g)\n",refname[bv->orthog_ref],(double)bv->orthog_eta);
596:           break;
597:         case BV_ORTHOG_REFINE_NEVER:
598:         case BV_ORTHOG_REFINE_ALWAYS:
599:           PetscViewerASCIIPrintf(viewer,"orthogonalization refinement: %s\n",refname[bv->orthog_ref]);
600:           break;
601:       }
602:       PetscViewerASCIIPrintf(viewer,"block orthogonalization method: %s\n",borthname[bv->orthog_block]);
603:       if (bv->matrix) {
604:         if (bv->indef) {
605:           PetscViewerASCIIPrintf(viewer,"indefinite inner product\n");
606:         } else {
607:           PetscViewerASCIIPrintf(viewer,"non-standard inner product\n");
608:         }
609:         PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);
610:         MatView(bv->matrix,viewer);
611:         PetscViewerPopFormat(viewer);
612:       }
613:       switch (bv->vmm) {
614:         case BV_MATMULT_VECS:
615:           PetscViewerASCIIPrintf(viewer,"doing matmult as matrix-vector products\n");
616:           break;
617:         case BV_MATMULT_MAT:
618:           PetscViewerASCIIPrintf(viewer,"doing matmult as a single matrix-matrix product\n");
619:           break;
620:         case BV_MATMULT_MAT_SAVE:
621:           PetscViewerASCIIPrintf(viewer,"doing matmult as a single matrix-matrix product, saving aux matrices\n");
622:           break;
623:       }
624:       if (bv->rrandom) { 
625:         PetscViewerASCIIPrintf(viewer,"generating random vectors independent of the number of processes\n");
626:       }
627:     } else {
628:       if (bv->ops->view) { (*bv->ops->view)(bv,viewer); }
629:       else { BVView_Default(bv,viewer); }
630:     }
631:     PetscViewerASCIIPopTab(viewer);
632:   } else {
633:     (*bv->ops->view)(bv,viewer);
634:   }
635:   return(0);
636: }

640: /*@C
641:    BVRegister - Adds a new storage format to the BV package.

643:    Not collective

645:    Input Parameters:
646: +  name     - name of a new user-defined BV
647: -  function - routine to create context

649:    Notes:
650:    BVRegister() may be called multiple times to add several user-defined
651:    basis vectors.

653:    Level: advanced

655: .seealso: BVRegisterAll()
656: @*/
657: PetscErrorCode BVRegister(const char *name,PetscErrorCode (*function)(BV))
658: {

662:   PetscFunctionListAdd(&BVList,name,function);
663:   return(0);
664: }

668: PetscErrorCode BVAllocateWork_Private(BV bv,PetscInt s)
669: {

673:   if (s>bv->lwork) {
674:     PetscFree(bv->work);
675:     PetscMalloc1(s,&bv->work);
676:     PetscLogObjectMemory((PetscObject)bv,(s-bv->lwork)*sizeof(PetscScalar));
677:     bv->lwork = s;
678:   }
679:   return(0);
680: }

slepc-3.7.4/src/sys/classes/bv/interface/index.html0000644000175000017500000000242413107004621021573 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

bvbasic.c
bvfunc.c
bvops.c
bvglobal.c
bvblas.c
bvorthog.c
bvregis.c
makefile
slepc-3.7.4/src/sys/classes/bv/interface/ftn-auto/0000755000175000017500000000000013107004621021331 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/interface/ftn-auto/makefile0000644000175000017500000000044513107004621023034 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = bvopsf.c bvorthogf.c bvfuncf.c bvbasicf.c bvglobalf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/bv/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/interface/ftn-auto/bvopsf.c0000644000175000017500000001225013107004621022774 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* bvops.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcbv.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmult_ BVMULT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmult_ bvmult #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmultvec_ BVMULTVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmultvec_ bvmultvec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmultcolumn_ BVMULTCOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmultcolumn_ bvmultcolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmultinplace_ BVMULTINPLACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmultinplace_ bvmultinplace #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmultinplacetranspose_ BVMULTINPLACETRANSPOSE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmultinplacetranspose_ bvmultinplacetranspose #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvscale_ BVSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvscale_ bvscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvscalecolumn_ BVSCALECOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvscalecolumn_ bvscalecolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetrandom_ BVSETRANDOM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetrandom_ bvsetrandom #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetrandomcolumn_ BVSETRANDOMCOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetrandomcolumn_ bvsetrandomcolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmatmult_ BVMATMULT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmatmult_ bvmatmult #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmatmulthermitiantranspose_ BVMATMULTHERMITIANTRANSPOSE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmatmulthermitiantranspose_ bvmatmulthermitiantranspose #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmatmultcolumn_ BVMATMULTCOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmatmultcolumn_ bvmatmultcolumn #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL bvmult_(BV Y,PetscScalar *alpha,PetscScalar *beta,BV X,Mat Q, int *__ierr ){ *__ierr = BVMult( (BV)PetscToPointer((Y) ),*alpha,*beta, (BV)PetscToPointer((X) ), (Mat)PetscToPointer((Q) )); } PETSC_EXTERN void PETSC_STDCALL bvmultvec_(BV X,PetscScalar *alpha,PetscScalar *beta,Vec y,PetscScalar *q, int *__ierr ){ *__ierr = BVMultVec( (BV)PetscToPointer((X) ),*alpha,*beta, (Vec)PetscToPointer((y) ),q); } PETSC_EXTERN void PETSC_STDCALL bvmultcolumn_(BV X,PetscScalar *alpha,PetscScalar *beta,PetscInt *j,PetscScalar *q, int *__ierr ){ *__ierr = BVMultColumn( (BV)PetscToPointer((X) ),*alpha,*beta,*j,q); } PETSC_EXTERN void PETSC_STDCALL bvmultinplace_(BV V,Mat Q,PetscInt *s,PetscInt *e, int *__ierr ){ *__ierr = BVMultInPlace( (BV)PetscToPointer((V) ), (Mat)PetscToPointer((Q) ),*s,*e); } PETSC_EXTERN void PETSC_STDCALL bvmultinplacetranspose_(BV V,Mat Q,PetscInt *s,PetscInt *e, int *__ierr ){ *__ierr = BVMultInPlaceTranspose( (BV)PetscToPointer((V) ), (Mat)PetscToPointer((Q) ),*s,*e); } PETSC_EXTERN void PETSC_STDCALL bvscale_(BV bv,PetscScalar *alpha, int *__ierr ){ *__ierr = BVScale( (BV)PetscToPointer((bv) ),*alpha); } PETSC_EXTERN void PETSC_STDCALL bvscalecolumn_(BV bv,PetscInt *j,PetscScalar *alpha, int *__ierr ){ *__ierr = BVScaleColumn( (BV)PetscToPointer((bv) ),*j,*alpha); } PETSC_EXTERN void PETSC_STDCALL bvsetrandom_(BV bv, int *__ierr ){ *__ierr = BVSetRandom( (BV)PetscToPointer((bv) )); } PETSC_EXTERN void PETSC_STDCALL bvsetrandomcolumn_(BV bv,PetscInt *j, int *__ierr ){ *__ierr = BVSetRandomColumn( (BV)PetscToPointer((bv) ),*j); } PETSC_EXTERN void PETSC_STDCALL bvmatmult_(BV V,Mat A,BV Y, int *__ierr ){ *__ierr = BVMatMult( (BV)PetscToPointer((V) ), (Mat)PetscToPointer((A) ), (BV)PetscToPointer((Y) )); } PETSC_EXTERN void PETSC_STDCALL bvmatmulthermitiantranspose_(BV V,Mat A,BV Y, int *__ierr ){ *__ierr = BVMatMultHermitianTranspose( (BV)PetscToPointer((V) ), (Mat)PetscToPointer((A) ), (BV)PetscToPointer((Y) )); } PETSC_EXTERN void PETSC_STDCALL bvmatmultcolumn_(BV V,Mat A,PetscInt *j, int *__ierr ){ *__ierr = BVMatMultColumn( (BV)PetscToPointer((V) ), (Mat)PetscToPointer((A) ),*j); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/bv/interface/ftn-auto/bvorthogf.c0000644000175000017500000000467113107004621023505 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* bvorthog.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcbv.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvorthogonalizevec_ BVORTHOGONALIZEVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvorthogonalizevec_ bvorthogonalizevec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvorthogonalizecolumn_ BVORTHOGONALIZECOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvorthogonalizecolumn_ bvorthogonalizecolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvorthogonalizesomecolumn_ BVORTHOGONALIZESOMECOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvorthogonalizesomecolumn_ bvorthogonalizesomecolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvorthogonalize_ BVORTHOGONALIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvorthogonalize_ bvorthogonalize #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL bvorthogonalizevec_(BV bv,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep, int *__ierr ){ *__ierr = BVOrthogonalizeVec( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((v) ),H,norm,lindep); } PETSC_EXTERN void PETSC_STDCALL bvorthogonalizecolumn_(BV bv,PetscInt *j,PetscScalar *H,PetscReal *norm,PetscBool *lindep, int *__ierr ){ *__ierr = BVOrthogonalizeColumn( (BV)PetscToPointer((bv) ),*j,H,norm,lindep); } PETSC_EXTERN void PETSC_STDCALL bvorthogonalizesomecolumn_(BV bv,PetscInt *j,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep, int *__ierr ){ *__ierr = BVOrthogonalizeSomeColumn( (BV)PetscToPointer((bv) ),*j,which,H,norm,lindep); } PETSC_EXTERN void PETSC_STDCALL bvorthogonalize_(BV V,Mat R, int *__ierr ){ *__ierr = BVOrthogonalize( (BV)PetscToPointer((V) ), (Mat)PetscToPointer((R) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/bv/interface/ftn-auto/bvfuncf.c0000644000175000017500000000457413107004621023140 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* bvfunc.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcbv.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdestroy_ BVDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdestroy_ bvdestroy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvcreate_ BVCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvcreate_ bvcreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvinsertvec_ BVINSERTVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvinsertvec_ bvinsertvec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvinsertvecs_ BVINSERTVECS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvinsertvecs_ bvinsertvecs #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvinsertconstraints_ BVINSERTCONSTRAINTS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvinsertconstraints_ bvinsertconstraints #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL bvdestroy_(BV *bv, int *__ierr ){ *__ierr = BVDestroy(bv); } PETSC_EXTERN void PETSC_STDCALL bvcreate_(MPI_Fint * comm,BV *newbv, int *__ierr ){ *__ierr = BVCreate( MPI_Comm_f2c(*(comm)),newbv); } PETSC_EXTERN void PETSC_STDCALL bvinsertvec_(BV V,PetscInt *j,Vec w, int *__ierr ){ *__ierr = BVInsertVec( (BV)PetscToPointer((V) ),*j, (Vec)PetscToPointer((w) )); } PETSC_EXTERN void PETSC_STDCALL bvinsertvecs_(BV V,PetscInt *s,PetscInt *m,Vec *W,PetscBool *orth, int *__ierr ){ *__ierr = BVInsertVecs( (BV)PetscToPointer((V) ),*s,m,W,*orth); } PETSC_EXTERN void PETSC_STDCALL bvinsertconstraints_(BV V,PetscInt *nc,Vec *C, int *__ierr ){ *__ierr = BVInsertConstraints( (BV)PetscToPointer((V) ),nc,C); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/bv/interface/ftn-auto/bvbasicf.c0000644000175000017500000002671713107004621023271 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* bvbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcbv.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetsizes_ BVSETSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetsizes_ bvsetsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetsizesfromvec_ BVSETSIZESFROMVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetsizesfromvec_ bvsetsizesfromvec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetsizes_ BVGETSIZES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetsizes_ bvgetsizes #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetnumconstraints_ BVSETNUMCONSTRAINTS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetnumconstraints_ bvsetnumconstraints #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetnumconstraints_ BVGETNUMCONSTRAINTS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetnumconstraints_ bvgetnumconstraints #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvresize_ BVRESIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvresize_ bvresize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetactivecolumns_ BVSETACTIVECOLUMNS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetactivecolumns_ bvsetactivecolumns #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetactivecolumns_ BVGETACTIVECOLUMNS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetactivecolumns_ bvgetactivecolumns #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetmatrix_ BVSETMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetmatrix_ bvsetmatrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetmatrix_ BVGETMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetmatrix_ bvgetmatrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvapplymatrix_ BVAPPLYMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvapplymatrix_ bvapplymatrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvapplymatrixbv_ BVAPPLYMATRIXBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvapplymatrixbv_ bvapplymatrixbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetcachedbv_ BVGETCACHEDBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetcachedbv_ bvgetcachedbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetsignature_ BVSETSIGNATURE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetsignature_ bvsetsignature #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetsignature_ BVGETSIGNATURE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetsignature_ bvgetsignature #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetrandomcontext_ BVSETRANDOMCONTEXT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetrandomcontext_ bvsetrandomcontext #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetrandomcontext_ BVGETRANDOMCONTEXT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetrandomcontext_ bvgetrandomcontext #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetfromoptions_ BVSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetfromoptions_ bvsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetorthogonalization_ BVSETORTHOGONALIZATION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetorthogonalization_ bvsetorthogonalization #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetorthogonalization_ BVGETORTHOGONALIZATION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetorthogonalization_ bvgetorthogonalization #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvsetmatmultmethod_ BVSETMATMULTMETHOD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvsetmatmultmethod_ bvsetmatmultmethod #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetmatmultmethod_ BVGETMATMULTMETHOD #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetmatmultmethod_ bvgetmatmultmethod #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvgetcolumn_ BVGETCOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvgetcolumn_ bvgetcolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvrestorecolumn_ BVRESTORECOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvrestorecolumn_ bvrestorecolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvcreatevec_ BVCREATEVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvcreatevec_ bvcreatevec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvduplicate_ BVDUPLICATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvduplicate_ bvduplicate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvduplicateresize_ BVDUPLICATERESIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvduplicateresize_ bvduplicateresize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvcopy_ BVCOPY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvcopy_ bvcopy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvcopyvec_ BVCOPYVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvcopyvec_ bvcopyvec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvcopycolumn_ BVCOPYCOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvcopycolumn_ bvcopycolumn #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL bvsetsizes_(BV bv,PetscInt *n,PetscInt *N,PetscInt *m, int *__ierr ){ *__ierr = BVSetSizes( (BV)PetscToPointer((bv) ),*n,*N,*m); } PETSC_EXTERN void PETSC_STDCALL bvsetsizesfromvec_(BV bv,Vec t,PetscInt *m, int *__ierr ){ *__ierr = BVSetSizesFromVec( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((t) ),*m); } PETSC_EXTERN void PETSC_STDCALL bvgetsizes_(BV bv,PetscInt *n,PetscInt *N,PetscInt *m, int *__ierr ){ *__ierr = BVGetSizes( (BV)PetscToPointer((bv) ),n,N,m); } PETSC_EXTERN void PETSC_STDCALL bvsetnumconstraints_(BV V,PetscInt *nc, int *__ierr ){ *__ierr = BVSetNumConstraints( (BV)PetscToPointer((V) ),*nc); } PETSC_EXTERN void PETSC_STDCALL bvgetnumconstraints_(BV bv,PetscInt *nc, int *__ierr ){ *__ierr = BVGetNumConstraints( (BV)PetscToPointer((bv) ),nc); } PETSC_EXTERN void PETSC_STDCALL bvresize_(BV bv,PetscInt *m,PetscBool *copy, int *__ierr ){ *__ierr = BVResize( (BV)PetscToPointer((bv) ),*m,*copy); } PETSC_EXTERN void PETSC_STDCALL bvsetactivecolumns_(BV bv,PetscInt *l,PetscInt *k, int *__ierr ){ *__ierr = BVSetActiveColumns( (BV)PetscToPointer((bv) ),*l,*k); } PETSC_EXTERN void PETSC_STDCALL bvgetactivecolumns_(BV bv,PetscInt *l,PetscInt *k, int *__ierr ){ *__ierr = BVGetActiveColumns( (BV)PetscToPointer((bv) ),l,k); } PETSC_EXTERN void PETSC_STDCALL bvsetmatrix_(BV bv,Mat B,PetscBool *indef, int *__ierr ){ *__ierr = BVSetMatrix( (BV)PetscToPointer((bv) ), (Mat)PetscToPointer((B) ),*indef); } PETSC_EXTERN void PETSC_STDCALL bvgetmatrix_(BV bv,Mat *B,PetscBool *indef, int *__ierr ){ *__ierr = BVGetMatrix( (BV)PetscToPointer((bv) ),B,indef); } PETSC_EXTERN void PETSC_STDCALL bvapplymatrix_(BV bv,Vec x,Vec y, int *__ierr ){ *__ierr = BVApplyMatrix( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((x) ), (Vec)PetscToPointer((y) )); } PETSC_EXTERN void PETSC_STDCALL bvapplymatrixbv_(BV X,BV Y, int *__ierr ){ *__ierr = BVApplyMatrixBV( (BV)PetscToPointer((X) ), (BV)PetscToPointer((Y) )); } PETSC_EXTERN void PETSC_STDCALL bvgetcachedbv_(BV bv,BV *cached, int *__ierr ){ *__ierr = BVGetCachedBV( (BV)PetscToPointer((bv) ),cached); } PETSC_EXTERN void PETSC_STDCALL bvsetsignature_(BV bv,Vec omega, int *__ierr ){ *__ierr = BVSetSignature( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((omega) )); } PETSC_EXTERN void PETSC_STDCALL bvgetsignature_(BV bv,Vec omega, int *__ierr ){ *__ierr = BVGetSignature( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((omega) )); } PETSC_EXTERN void PETSC_STDCALL bvsetrandomcontext_(BV bv,PetscRandom rand, int *__ierr ){ *__ierr = BVSetRandomContext( (BV)PetscToPointer((bv) ), (PetscRandom)PetscToPointer((rand) )); } PETSC_EXTERN void PETSC_STDCALL bvgetrandomcontext_(BV bv,PetscRandom* rand, int *__ierr ){ *__ierr = BVGetRandomContext( (BV)PetscToPointer((bv) ),rand); } PETSC_EXTERN void PETSC_STDCALL bvsetfromoptions_(BV bv, int *__ierr ){ *__ierr = BVSetFromOptions( (BV)PetscToPointer((bv) )); } PETSC_EXTERN void PETSC_STDCALL bvsetorthogonalization_(BV bv,BVOrthogType *type,BVOrthogRefineType *refine,PetscReal *eta,BVOrthogBlockType *block, int *__ierr ){ *__ierr = BVSetOrthogonalization( (BV)PetscToPointer((bv) ),*type,*refine,*eta,*block); } PETSC_EXTERN void PETSC_STDCALL bvgetorthogonalization_(BV bv,BVOrthogType *type,BVOrthogRefineType *refine,PetscReal *eta,BVOrthogBlockType *block, int *__ierr ){ *__ierr = BVGetOrthogonalization( (BV)PetscToPointer((bv) ),type,refine,eta,block); } PETSC_EXTERN void PETSC_STDCALL bvsetmatmultmethod_(BV bv,BVMatMultType *method, int *__ierr ){ *__ierr = BVSetMatMultMethod( (BV)PetscToPointer((bv) ),*method); } PETSC_EXTERN void PETSC_STDCALL bvgetmatmultmethod_(BV bv,BVMatMultType *method, int *__ierr ){ *__ierr = BVGetMatMultMethod( (BV)PetscToPointer((bv) ),method); } PETSC_EXTERN void PETSC_STDCALL bvgetcolumn_(BV bv,PetscInt *j,Vec *v, int *__ierr ){ *__ierr = BVGetColumn( (BV)PetscToPointer((bv) ),*j,v); } PETSC_EXTERN void PETSC_STDCALL bvrestorecolumn_(BV bv,PetscInt *j,Vec *v, int *__ierr ){ *__ierr = BVRestoreColumn( (BV)PetscToPointer((bv) ),*j,v); } PETSC_EXTERN void PETSC_STDCALL bvcreatevec_(BV bv,Vec *v, int *__ierr ){ *__ierr = BVCreateVec( (BV)PetscToPointer((bv) ),v); } PETSC_EXTERN void PETSC_STDCALL bvduplicate_(BV V,BV *W, int *__ierr ){ *__ierr = BVDuplicate( (BV)PetscToPointer((V) ),W); } PETSC_EXTERN void PETSC_STDCALL bvduplicateresize_(BV V,PetscInt *m,BV *W, int *__ierr ){ *__ierr = BVDuplicateResize( (BV)PetscToPointer((V) ),*m,W); } PETSC_EXTERN void PETSC_STDCALL bvcopy_(BV V,BV W, int *__ierr ){ *__ierr = BVCopy( (BV)PetscToPointer((V) ), (BV)PetscToPointer((W) )); } PETSC_EXTERN void PETSC_STDCALL bvcopyvec_(BV V,PetscInt *j,Vec w, int *__ierr ){ *__ierr = BVCopyVec( (BV)PetscToPointer((V) ),*j, (Vec)PetscToPointer((w) )); } PETSC_EXTERN void PETSC_STDCALL bvcopycolumn_(BV V,PetscInt *j,PetscInt *i, int *__ierr ){ *__ierr = BVCopyColumn( (BV)PetscToPointer((V) ),*j,*i); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/bv/interface/ftn-auto/bvglobalf.c0000644000175000017500000001416013107004621023435 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* bvglobal.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcbv.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdot_ BVDOT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdot_ bvdot #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdotvec_ BVDOTVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdotvec_ bvdotvec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdotvecbegin_ BVDOTVECBEGIN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdotvecbegin_ bvdotvecbegin #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdotvecend_ BVDOTVECEND #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdotvecend_ bvdotvecend #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdotcolumn_ BVDOTCOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdotcolumn_ bvdotcolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdotcolumnbegin_ BVDOTCOLUMNBEGIN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdotcolumnbegin_ bvdotcolumnbegin #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvdotcolumnend_ BVDOTCOLUMNEND #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvdotcolumnend_ bvdotcolumnend #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvnorm_ BVNORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvnorm_ bvnorm #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvnormvec_ BVNORMVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvnormvec_ bvnormvec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvnormvecbegin_ BVNORMVECBEGIN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvnormvecbegin_ bvnormvecbegin #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvnormvecend_ BVNORMVECEND #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvnormvecend_ bvnormvecend #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvnormcolumn_ BVNORMCOLUMN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvnormcolumn_ bvnormcolumn #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvnormcolumnbegin_ BVNORMCOLUMNBEGIN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvnormcolumnbegin_ bvnormcolumnbegin #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvnormcolumnend_ BVNORMCOLUMNEND #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvnormcolumnend_ bvnormcolumnend #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define bvmatproject_ BVMATPROJECT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define bvmatproject_ bvmatproject #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL bvdot_(BV X,BV Y,Mat M, int *__ierr ){ *__ierr = BVDot( (BV)PetscToPointer((X) ), (BV)PetscToPointer((Y) ), (Mat)PetscToPointer((M) )); } PETSC_EXTERN void PETSC_STDCALL bvdotvec_(BV X,Vec y,PetscScalar *m, int *__ierr ){ *__ierr = BVDotVec( (BV)PetscToPointer((X) ), (Vec)PetscToPointer((y) ),m); } PETSC_EXTERN void PETSC_STDCALL bvdotvecbegin_(BV X,Vec y,PetscScalar *m, int *__ierr ){ *__ierr = BVDotVecBegin( (BV)PetscToPointer((X) ), (Vec)PetscToPointer((y) ),m); } PETSC_EXTERN void PETSC_STDCALL bvdotvecend_(BV X,Vec y,PetscScalar *m, int *__ierr ){ *__ierr = BVDotVecEnd( (BV)PetscToPointer((X) ), (Vec)PetscToPointer((y) ),m); } PETSC_EXTERN void PETSC_STDCALL bvdotcolumn_(BV X,PetscInt *j,PetscScalar *m, int *__ierr ){ *__ierr = BVDotColumn( (BV)PetscToPointer((X) ),*j,m); } PETSC_EXTERN void PETSC_STDCALL bvdotcolumnbegin_(BV X,PetscInt *j,PetscScalar *m, int *__ierr ){ *__ierr = BVDotColumnBegin( (BV)PetscToPointer((X) ),*j,m); } PETSC_EXTERN void PETSC_STDCALL bvdotcolumnend_(BV X,PetscInt *j,PetscScalar *m, int *__ierr ){ *__ierr = BVDotColumnEnd( (BV)PetscToPointer((X) ),*j,m); } PETSC_EXTERN void PETSC_STDCALL bvnorm_(BV bv,NormType *type,PetscReal *val, int *__ierr ){ *__ierr = BVNorm( (BV)PetscToPointer((bv) ),*type,val); } PETSC_EXTERN void PETSC_STDCALL bvnormvec_(BV bv,Vec v,NormType *type,PetscReal *val, int *__ierr ){ *__ierr = BVNormVec( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((v) ),*type,val); } PETSC_EXTERN void PETSC_STDCALL bvnormvecbegin_(BV bv,Vec v,NormType *type,PetscReal *val, int *__ierr ){ *__ierr = BVNormVecBegin( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((v) ),*type,val); } PETSC_EXTERN void PETSC_STDCALL bvnormvecend_(BV bv,Vec v,NormType *type,PetscReal *val, int *__ierr ){ *__ierr = BVNormVecEnd( (BV)PetscToPointer((bv) ), (Vec)PetscToPointer((v) ),*type,val); } PETSC_EXTERN void PETSC_STDCALL bvnormcolumn_(BV bv,PetscInt *j,NormType *type,PetscReal *val, int *__ierr ){ *__ierr = BVNormColumn( (BV)PetscToPointer((bv) ),*j,*type,val); } PETSC_EXTERN void PETSC_STDCALL bvnormcolumnbegin_(BV bv,PetscInt *j,NormType *type,PetscReal *val, int *__ierr ){ *__ierr = BVNormColumnBegin( (BV)PetscToPointer((bv) ),*j,*type,val); } PETSC_EXTERN void PETSC_STDCALL bvnormcolumnend_(BV bv,PetscInt *j,NormType *type,PetscReal *val, int *__ierr ){ *__ierr = BVNormColumnEnd( (BV)PetscToPointer((bv) ),*j,*type,val); } PETSC_EXTERN void PETSC_STDCALL bvmatproject_(BV X,Mat A,BV Y,Mat M, int *__ierr ){ *__ierr = BVMatProject( (BV)PetscToPointer((X) ), (Mat)PetscToPointer((A) ), (BV)PetscToPointer((Y) ), (Mat)PetscToPointer((M) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/bv/interface/bvregis.c.html0000644000175000017500000001220313107004621022342 0ustar jromanjroman

Actual source code: bvregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/bvimpl.h>          /*I   "slepcbv.h"   I*/

 24: PETSC_EXTERN PetscErrorCode BVCreate_Vecs(BV);
 25: PETSC_EXTERN PetscErrorCode BVCreate_Contiguous(BV);
 26: PETSC_EXTERN PetscErrorCode BVCreate_Svec(BV);
 27: PETSC_EXTERN PetscErrorCode BVCreate_Mat(BV);

 31: /*@C
 32:    BVRegisterAll - Registers all of the storage variants in the BV package.

 34:    Not Collective

 36:    Level: advanced

 38: .seealso: BVRegister()
 39: @*/
 40: PetscErrorCode BVRegisterAll(void)
 41: {

 45:   if (BVRegisterAllCalled) return(0);
 46:   BVRegisterAllCalled = PETSC_TRUE;
 47:   BVRegister(BVVECS,BVCreate_Vecs);
 48:   BVRegister(BVCONTIGUOUS,BVCreate_Contiguous);
 49:   BVRegister(BVSVEC,BVCreate_Svec);
 50:   BVRegister(BVMAT,BVCreate_Mat);
 51:   return(0);
 52: }

slepc-3.7.4/src/sys/classes/bv/interface/bvorthog.c.html0000644000175000017500000014341513107004621022545 0ustar jromanjroman
Actual source code: bvorthog.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV orthogonalization routines.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>          /*I   "slepcbv.h"   I*/
 25: #include <slepcblaslapack.h>

 29: /*
 30:    BVOrthogonalizeMGS1 - Compute one step of Modified Gram-Schmidt
 31: */
 32: static PetscErrorCode BVOrthogonalizeMGS1(BV bv,PetscInt k,Vec v,PetscBool *which,PetscScalar *H)
 33: {
 35:   PetscInt       i;
 36:   PetscScalar    dot;
 37:   Vec            vi,z;

 40:   z = v;
 41:   for (i=-bv->nc;i<k;i++) {
 42:     if (which && i>=0 && !which[i]) continue;
 43:     BVGetColumn(bv,i,&vi);
 44:     /* h_i = ( v, v_i ) */
 45:     if (bv->matrix) {
 46:       BV_IPMatMult(bv,v);
 47:       z = bv->Bx;
 48:     }
 49:     VecDot(z,vi,&dot);
 50:     /* v <- v - h_i v_i */
 51:     if (bv->indef) dot /= bv->omega[bv->nc+i];
 52:     VecAXPY(v,-dot,vi);
 53:     if (bv->indef) dot *= bv->omega[bv->nc+i];
 54:     if (H) H[bv->nc+i] += dot;
 55:     BVRestoreColumn(bv,i,&vi);
 56:   }
 57:   return(0);
 58: }

 62: /*
 63:    BVOrthogonalizeCGS1 - Compute |v'| (estimated), |v| and one step of CGS with
 64:    only one global synchronization
 65: */
 66: PetscErrorCode BVOrthogonalizeCGS1(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *onorm,PetscReal *norm)
 67: {
 69:   PetscInt       i;
 70:   PetscReal      sum,nrm,beta;
 71:   Vec            w=v;

 74:   /* h = W^* v ; alpha = (v, v) */
 75:   bv->k = j;
 76:   if (onorm || norm) {
 77:     if (!v) {
 78:       bv->k++;
 79:       BVGetColumn(bv,j,&w);
 80:     }
 81:     BVDotVec(bv,w,H);
 82:     if (!v) {
 83:       BVRestoreColumn(bv,j,&w);
 84:       bv->k--;
 85:       BV_SafeSqrt(bv,H[bv->nc+j],&beta);
 86:     } else {
 87:       BVNormVec(bv,w,NORM_2,&beta);
 88:     }
 89:   } else {
 90:     if (!v) { BVDotColumn(bv,j,H); }
 91:     else { BVDotVec(bv,w,H); }
 92:   }

 94:   /* q = v - V h */
 95:   if (bv->indef) {
 96:     for (i=0;i<bv->nc+j;i++) H[i] /= bv->omega[i];  /* apply inverse of signature */
 97:   }
 98:   if (!v) { BVMultColumn(bv,-1.0,1.0,j,H); }
 99:   else { BVMultVec(bv,-1.0,1.0,w,H); }
100:   if (bv->indef) {
101:     for (i=0;i<bv->nc+j;i++) H[i] *= bv->omega[i];  /* revert signature */
102:   }

104:   /* compute |v| */
105:   if (onorm) *onorm = beta;

107:   if (bv->indef) {
108:     if (!v) { BVNormColumn(bv,j,NORM_2,&nrm); }
109:     else { BVNormVec(bv,w,NORM_2,&nrm); }
110:     if (norm) *norm = nrm;
111:     bv->omega[bv->nc+j] = (nrm<0.0)? -1.0: 1.0;
112:   } else if (norm) {
113:     /* estimate |v'| from |v| */
114:     sum = 0.0;
115:     for (i=0;i<bv->nc+j;i++) sum += PetscRealPart(H[i]*PetscConj(H[i]));
116:     *norm = beta*beta-sum;
117:     if (*norm <= 0.0) {
118:       if (!v) { BVNormColumn(bv,j,NORM_2,norm); }
119:       else { BVNormVec(bv,w,NORM_2,norm); }
120:     } else *norm = PetscSqrtReal(*norm);
121:   }
122:   return(0);
123: }

127: /*
128:   BVOrthogonalizeMGS - Orthogonalize with modified Gram-Schmidt
129: */
130: static PetscErrorCode BVOrthogonalizeMGS(BV bv,PetscInt j,Vec v,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
131: {
133:   PetscReal      onrm,nrm;
134:   PetscInt       k,l;
135:   Vec            w;

138:   if (v) {
139:     w = v;
140:     k = bv->k;
141:   } else {
142:     BVGetColumn(bv,j,&w);
143:     k = j;
144:   }
145:   PetscMemzero(bv->h,(bv->nc+k)*sizeof(PetscScalar));
146:   switch (bv->orthog_ref) {

148:   case BV_ORTHOG_REFINE_IFNEEDED:
149:     /* first step */
150:     BVNormVec(bv,w,NORM_2,&onrm);
151:     BVOrthogonalizeMGS1(bv,k,w,which,bv->h);
152:     BVNormVec(bv,w,NORM_2,&nrm);
153:     /* ||q|| < eta ||h|| */
154:     l = 1;
155:     while (l<3 && nrm && nrm < bv->orthog_eta*onrm) {
156:       l++;
157:       onrm = nrm;
158:       BVOrthogonalizeMGS1(bv,k,w,which,bv->c);
159:       BVNormVec(bv,w,NORM_2,&nrm);
160:     }
161:     if (lindep) *lindep = PetscNot(nrm >= bv->orthog_eta*onrm);
162:     break;

164:   case BV_ORTHOG_REFINE_NEVER:
165:     BVOrthogonalizeMGS1(bv,k,w,which,bv->h);
166:     /* compute |v| */
167:     if (norm || lindep) {
168:       BVNormVec(bv,w,NORM_2,&nrm);
169:     }
170:     /* linear dependence check: just test for exactly zero norm */
171:     if (lindep) *lindep = PetscNot(nrm);
172:     break;

174:   case BV_ORTHOG_REFINE_ALWAYS:
175:     /* first step */
176:     BVOrthogonalizeMGS1(bv,k,w,which,bv->h);
177:     if (lindep) {
178:       BVNormVec(bv,w,NORM_2,&onrm);
179:     }
180:     /* second step */
181:     BVOrthogonalizeMGS1(bv,k,w,which,bv->h);
182:     if (norm || lindep) {
183:       BVNormVec(bv,w,NORM_2,&nrm);
184:     }
185:     if (lindep) *lindep = PetscNot(nrm && nrm >= bv->orthog_eta*onrm);
186:     break;
187:   }
188:   if (bv->indef) {
189:     BVNormVec(bv,w,NORM_2,&nrm);
190:     bv->omega[bv->nc+j] = (nrm<0.0)? -1.0: 1.0;
191:   }
192:   if (!v) { BVRestoreColumn(bv,j,&w); }
193:   if (norm) *norm = nrm;
194:   return(0);
195: }

199: /*
200:   BVOrthogonalizeCGS - Orthogonalize with classical Gram-Schmidt
201: */
202: static PetscErrorCode BVOrthogonalizeCGS(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
203: {
205:   PetscReal      onrm,nrm;
206:   PetscInt       i,k,l;

209:   if (v) k = bv->k;
210:   else k = j;
211:   switch (bv->orthog_ref) {

213:   case BV_ORTHOG_REFINE_IFNEEDED:
214:     BVOrthogonalizeCGS1(bv,k,v,bv->h,&onrm,&nrm);
215:     /* ||q|| < eta ||h|| */
216:     l = 1;
217:     while (l<3 && nrm && nrm < bv->orthog_eta*onrm) {
218:       l++;
219:       BVOrthogonalizeCGS1(bv,k,v,bv->c,&onrm,&nrm);
220:       for (i=0;i<bv->nc+k;i++) bv->h[i] += bv->c[i];
221:     }
222:     if (norm) *norm = nrm;
223:     if (lindep) *lindep = PetscNot(nrm >= bv->orthog_eta*onrm);
224:     break;

226:   case BV_ORTHOG_REFINE_NEVER:
227:     BVOrthogonalizeCGS1(bv,k,v,bv->h,NULL,NULL);
228:     /* compute |v| */
229:     if (norm || lindep) {
230:       if (v) { BVNormVec(bv,v,NORM_2,&nrm); }
231:       else { BVNormColumn(bv,k,NORM_2,&nrm); }
232:     }
233:     if (norm) *norm = nrm;
234:     /* linear dependence check: just test for exactly zero norm */
235:     if (lindep) *lindep = PetscNot(nrm);
236:     break;

238:   case BV_ORTHOG_REFINE_ALWAYS:
239:     BVOrthogonalizeCGS1(bv,k,v,bv->h,NULL,NULL);
240:     if (lindep) {
241:       BVOrthogonalizeCGS1(bv,k,v,bv->c,&onrm,&nrm);
242:       if (norm) *norm = nrm;
243:       *lindep = PetscNot(nrm && nrm >= bv->orthog_eta*onrm);
244:     } else {
245:       BVOrthogonalizeCGS1(bv,k,v,bv->c,NULL,norm);
246:     }
247:     for (i=0;i<bv->nc+k;i++) bv->h[i] += bv->c[i];
248:     break;
249:   }
250:   return(0);
251: }

255: /*@
256:    BVOrthogonalizeVec - Orthogonalize a given vector with respect to all
257:    active columns.

259:    Collective on BV

261:    Input Parameters:
262: +  bv     - the basis vectors context
263: -  v      - the vector

265:    Output Parameters:
266: +  H      - (optional) coefficients computed during orthogonalization
267: .  norm   - (optional) norm of the vector after being orthogonalized
268: -  lindep - (optional) flag indicating that refinement did not improve the quality
269:             of orthogonalization

271:    Notes:
272:    This function is equivalent to BVOrthogonalizeColumn() but orthogonalizes
273:    a vector as an argument rather than taking one of the BV columns. The
274:    vector is orthogonalized against all active columns.

276:    Level: advanced

278: .seealso: BVOrthogonalizeColumn(), BVSetOrthogonalization(), BVSetActiveColumns()
279: @*/
280: PetscErrorCode BVOrthogonalizeVec(BV bv,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
281: {
283:   PetscInt       i,ksave,lsave;

289:   BVCheckSizes(bv,1);

293:   PetscLogEventBegin(BV_OrthogonalizeVec,bv,0,0,0);
294:   ksave = bv->k;
295:   lsave = bv->l;
296:   bv->l = -bv->nc;  /* must also orthogonalize against constraints and leading columns */
297:   BV_AllocateCoeffs(bv);
298:   BV_AllocateSignature(bv);
299:   switch (bv->orthog_type) {
300:   case BV_ORTHOG_CGS:
301:     BVOrthogonalizeCGS(bv,0,v,H,norm,lindep);
302:     break;
303:   case BV_ORTHOG_MGS:
304:     BVOrthogonalizeMGS(bv,0,v,NULL,H,norm,lindep);
305:     break;
306:   }
307:   bv->k = ksave;
308:   bv->l = lsave;
309:   if (H) for (i=bv->l;i<bv->k;i++) H[i-bv->l] = bv->h[bv->nc+i];
310:   PetscLogEventEnd(BV_OrthogonalizeVec,bv,0,0,0);
311:   return(0);
312: }

316: /*@
317:    BVOrthogonalizeColumn - Orthogonalize one of the column vectors with respect to
318:    the previous ones.

320:    Collective on BV

322:    Input Parameters:
323: +  bv     - the basis vectors context
324: -  j      - index of column to be orthogonalized

326:    Output Parameters:
327: +  H      - (optional) coefficients computed during orthogonalization
328: .  norm   - (optional) norm of the vector after being orthogonalized
329: -  lindep - (optional) flag indicating that refinement did not improve the quality
330:             of orthogonalization

332:    Notes:
333:    This function applies an orthogonal projector to project vector V[j] onto
334:    the orthogonal complement of the span of the columns of V[0..j-1],
335:    where V[.] are the vectors of BV. The columns V[0..j-1] are assumed to be
336:    mutually orthonormal.

338:    Leading columns V[0..l-1] also participate in the orthogonalization.

340:    If a non-standard inner product has been specified with BVSetMatrix(),
341:    then the vector is B-orthogonalized, using the non-standard inner product
342:    defined by matrix B. The output vector satisfies V[j]'*B*V[0..j-1] = 0.

344:    This routine does not normalize the resulting vector.

346:    Level: advanced

348: .seealso: BVSetOrthogonalization(), BVSetMatrix(), BVSetActiveColumns(), BVOrthogonalize(), BVOrthogonalizeVec()
349: @*/
350: PetscErrorCode BVOrthogonalizeColumn(BV bv,PetscInt j,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
351: {
353:   PetscInt       i,ksave,lsave;

359:   BVCheckSizes(bv,1);
360:   if (j<0) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative");
361:   if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,bv->m);

363:   PetscLogEventBegin(BV_OrthogonalizeVec,bv,0,0,0);
364:   ksave = bv->k;
365:   lsave = bv->l;
366:   bv->l = -bv->nc;  /* must also orthogonalize against constraints and leading columns */
367:   BV_AllocateCoeffs(bv);
368:   BV_AllocateSignature(bv);
369:   switch (bv->orthog_type) {
370:   case BV_ORTHOG_CGS:
371:     BVOrthogonalizeCGS(bv,j,NULL,H,norm,lindep);
372:     break;
373:   case BV_ORTHOG_MGS:
374:     BVOrthogonalizeMGS(bv,j,NULL,NULL,H,norm,lindep);
375:     break;
376:   }
377:   bv->k = ksave;
378:   bv->l = lsave;
379:   if (H) for (i=bv->l;i<j;i++) H[i-bv->l] = bv->h[bv->nc+i];
380:   PetscLogEventEnd(BV_OrthogonalizeVec,bv,0,0,0);
381:   return(0);
382: }

386: /*@
387:    BVOrthogonalizeSomeColumn - Orthogonalize one of the column vectors with
388:    respect to some of the previous ones.

390:    Collective on BV

392:    Input Parameters:
393: +  bv     - the basis vectors context
394: .  j      - index of column to be orthogonalized
395: -  which  - logical array indicating selected columns

397:    Output Parameters:
398: +  H      - (optional) coefficients computed during orthogonalization
399: .  norm   - (optional) norm of the vector after being orthogonalized
400: -  lindep - (optional) flag indicating that refinement did not improve the quality
401:             of orthogonalization

403:    Notes:
404:    This function is similar to BVOrthogonalizeColumn(), but V[j] is
405:    orthogonalized only against columns V[i] having which[i]=PETSC_TRUE.
406:    The length of array which must be j at least.

408:    The use of this operation is restricted to MGS orthogonalization type.

410:    Level: advanced

412: .seealso: BVOrthogonalizeColumn(), BVSetOrthogonalization()
413: @*/
414: PetscErrorCode BVOrthogonalizeSomeColumn(BV bv,PetscInt j,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep)
415: {
417:   PetscInt       i,ksave,lsave;

424:   BVCheckSizes(bv,1);
425:   if (j<0) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative");
426:   if (j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,bv->m);
427:   if (bv->orthog_type!=BV_ORTHOG_MGS) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Operation only available for MGS orthogonalization");

429:   PetscLogEventBegin(BV_OrthogonalizeVec,bv,0,0,0);
430:   ksave = bv->k;
431:   lsave = bv->l;
432:   bv->l = -bv->nc;  /* must also orthogonalize against constraints and leading columns */
433:   BV_AllocateCoeffs(bv);
434:   BV_AllocateSignature(bv);
435:   BVOrthogonalizeMGS(bv,j,NULL,which,H,norm,lindep);
436:   bv->k = ksave;
437:   bv->l = lsave;
438:   if (H) for (i=bv->l;i<j;i++) H[i-bv->l] = bv->h[bv->nc+i];
439:   PetscLogEventEnd(BV_OrthogonalizeVec,bv,0,0,0);
440:   return(0);
441: }

445: /*
446:    Orthogonalize a set of vectors with Gram-Schmidt, column by column.
447:  */
448: static PetscErrorCode BVOrthogonalize_GS(BV V,Mat R)
449: {
451:   PetscScalar    *r=NULL;
452:   PetscReal      norm;
453:   PetscInt       j,ldr;
454:   Vec            v;

457:   if (R) {
458:     MatGetSize(R,&ldr,NULL);
459:     MatDenseGetArray(R,&r);
460:   }
461:   if (V->matrix) {
462:     BV_AllocateCachedBV(V);
463:     BVSetActiveColumns(V->cached,V->l,V->k);
464:   }
465:   for (j=V->l;j<V->k;j++) {
466:     if (R) {
467:       BVOrthogonalizeColumn(V,j,r+j*ldr+V->l,&norm,NULL);
468:       r[j+j*ldr] = norm;
469:     } else {
470:       BVOrthogonalizeColumn(V,j,NULL,&norm,NULL);
471:     }
472:     if (!norm) SETERRQ(PETSC_COMM_SELF,1,"Breakdown in BVOrthogonalize due to a linearly dependent column");
473:     if (V->matrix) { /* fill cached BV */
474:       BVGetColumn(V->cached,j,&v);
475:       VecCopy(V->Bx,v);
476:       BVRestoreColumn(V->cached,j,&v);
477:     }
478:     BVScaleColumn(V,j,1.0/norm);
479:   }
480:   if (R) { MatDenseRestoreArray(R,&r); }
481:   return(0);
482: }

486: /*
487:    Compute the upper Cholesky factor in R and its inverse in S.
488:  */
489: static PetscErrorCode MatCholeskyFactorInvert(Mat R,PetscInt l,Mat *S)
490: {
491: #if defined(PETSC_MISSING_LAPACK_POTRF) || defined(SLEPC_MISSING_LAPACK_TRTRI)
493:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"POTRF/TRTRI - Lapack routine is unavailable");
494: #else
496:   PetscInt       i,n,m,ld;
497:   PetscScalar    *pR,*pS;
498:   PetscBLASInt   info,n_,l_,m_,ld_;

501:   MatGetSize(R,&m,NULL);
502:   n = m-l;
503:   PetscBLASIntCast(m,&m_);
504:   PetscBLASIntCast(l,&l_);
505:   PetscBLASIntCast(n,&n_);
506:   ld  = m;
507:   ld_ = m_;
508:   MatCreateSeqDense(PETSC_COMM_SELF,ld,ld,NULL,S);
509:   MatDenseGetArray(R,&pR);
510:   MatDenseGetArray(*S,&pS);

512:   /* save a copy of matrix in S */
513:   for (i=l;i<m;i++) {
514:     PetscMemcpy(pS+i*ld+l,pR+i*ld+l,n*sizeof(PetscScalar));
515:   }

517:   /* compute upper Cholesky factor in R */
518:   PetscStackCallBLAS("LAPACKpotrf",LAPACKpotrf_("U",&n_,pR+l*ld+l,&ld_,&info));
519:   PetscLogFlops((1.0*n*n*n)/3.0);

521:   if (info) {  /* LAPACKpotrf failed, retry on diagonally perturbed matrix */
522:     for (i=l;i<m;i++) {
523:       PetscMemcpy(pR+i*ld+l,pS+i*ld+l,n*sizeof(PetscScalar));
524:       pR[i+i*ld] += 50.0*PETSC_MACHINE_EPSILON;
525:     }
526:     PetscStackCallBLAS("LAPACKpotrf",LAPACKpotrf_("U",&n_,pR+l*ld+l,&ld_,&info));
527:     if (info) SETERRQ1(PETSC_COMM_SELF,1,"Error in Cholesky factorization, info=%D",(PetscInt)info);
528:     PetscLogFlops((1.0*n*n*n)/3.0);
529:   }

531:   /* compute S = inv(R) */
532:   PetscMemzero(pS,m*m*sizeof(PetscScalar));
533:   for (i=l;i<m;i++) {
534:     PetscMemcpy(pS+i*ld+l,pR+i*ld+l,n*sizeof(PetscScalar));
535:   }
536:   PetscStackCallBLAS("LAPACKtrtri",LAPACKtrtri_("U","N",&n_,pS+l*ld+l,&ld_,&info));
537:   if (info) SETERRQ1(PETSC_COMM_SELF,1,"Error in xTRTRI, info=%D",(PetscInt)info);
538:   PetscLogFlops(1.0*n*n*n);

540:   /* Zero out entries below the diagonal */
541:   for (i=l;i<m-1;i++) {
542:     PetscMemzero(pR+i*ld+i+1,(m-i-1)*sizeof(PetscScalar));
543:     PetscMemzero(pS+i*ld+i+1,(m-i-1)*sizeof(PetscScalar));
544:   }
545:   MatDenseRestoreArray(R,&pR);
546:   MatDenseRestoreArray(*S,&pS);
547:   return(0);
548: #endif
549: }

553: /*
554:    Orthogonalize a set of vectors with Cholesky: R=chol(V'*V), Q=V*inv(R)
555:  */
556: static PetscErrorCode BVOrthogonalize_Chol(BV V,Mat Rin)
557: {
559:   Mat            S,R=Rin;

562:   if (!Rin) {
563:     MatCreateSeqDense(PETSC_COMM_SELF,V->k,V->k,NULL,&R);
564:   }
565:   BVDot(V,V,R);
566:   MatCholeskyFactorInvert(R,V->l,&S);
567:   BVMultInPlace(V,S,V->l,V->k);
568:   MatDestroy(&S);
569:   if (!Rin) {
570:     MatDestroy(&R);
571:   }
572:   return(0);
573: }

577: /*@
578:    BVOrthogonalize - Orthogonalize all columns (except leading ones), that is,
579:    compute the QR decomposition.

581:    Collective on BV

583:    Input Parameter:
584: .  V - basis vectors

586:    Output Parameters:
587: +  V - the modified basis vectors
588: -  R - a sequential dense matrix (or NULL)

590:    Notes:
591:    On input, matrix R must be a sequential dense Mat, with at least as many rows
592:    and columns as the number of active columns of V. The output satisfies
593:    V0 = V*R (where V0 represent the input V) and V'*V = I.

595:    If V has leading columns, then they are not modified (are assumed to be already
596:    orthonormal) and the corresponding part of R is not referenced.

598:    Can pass NULL if R is not required.

600:    The method to be used for block orthogonalization can be set with
601:    BVSetOrthogonalization(). If set to GS, the computation is done column by
602:    column with successive calls to BVOrthogonalizeColumn().

604:    If V is rank-deficient or very ill-conditioned, that is, one or more columns are
605:    (almost) linearly dependent with respect to the rest, then the algorithm may
606:    break down or result in larger numerical error. Linearly dependent columns are
607:    essentially replaced by random directions, and the corresponding diagonal entry
608:    in R is set to (nearly) zero.

610:    Level: intermediate

612: .seealso: BVOrthogonalizeColumn(), BVOrthogonalizeVec(), BVSetActiveColumns(), BVSetOrthogonalization(), BVOrthogBlockType
613: @*/
614: PetscErrorCode BVOrthogonalize(BV V,Mat R)
615: {
617:   PetscBool      match;
618:   PetscInt       m,n;

623:   BVCheckSizes(V,1);
624:   if (R) {
627:     if (V->l>0 && V->orthog_block==BV_ORTHOG_BLOCK_GS) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Cannot request matrix R in Gram-Schmidt orthogonalization if l>0");
628:     PetscObjectTypeCompare((PetscObject)R,MATSEQDENSE,&match);
629:     if (!match) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Mat argument must be of type seqdense");
630:     MatGetSize(R,&m,&n);
631:     if (m!=n) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat argument is not square, it has %D rows and %D columns",m,n);
632:     if (n<V->k) SETERRQ2(PetscObjectComm((PetscObject)V),PETSC_ERR_ARG_SIZ,"Mat size %D is smaller than the number of BV active columns %D",n,V->k);
633:   }
634:   if (V->nc) SETERRQ(PetscObjectComm((PetscObject)V),PETSC_ERR_SUP,"Not implemented for BV with constraints, use BVOrthogonalizeColumn() instead");

636:   PetscLogEventBegin(BV_Orthogonalize,V,R,0,0);
637:   switch (V->orthog_block) {
638:   case BV_ORTHOG_BLOCK_GS: /* proceed column by column with Gram-Schmidt */
639:     BVOrthogonalize_GS(V,R);
640:     break;
641:   case BV_ORTHOG_BLOCK_CHOL:
642:     BVOrthogonalize_Chol(V,R);
643:     /*if (V->ops->orthogonalize) {
644:       (*V->ops->orthogonalize)(V,R);
645:     }*/
646:     break;
647:   }
648:   PetscLogEventEnd(BV_Orthogonalize,V,R,0,0);
649:   PetscObjectStateIncrease((PetscObject)V);
650:   return(0);
651: }

slepc-3.7.4/src/sys/classes/bv/interface/bvglobal.c0000644000175000017500000011712013107004621021532 0ustar jromanjroman/* BV operations involving global communication. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcbv.h" I*/ #undef __FUNCT__ #define __FUNCT__ "BVDot_Private" /* BVDot for the particular case of non-standard inner product with matrix B, which is assumed to be symmetric (or complex Hermitian) */ PETSC_STATIC_INLINE PetscErrorCode BVDot_Private(BV X,BV Y,Mat M) { PetscErrorCode ierr; PetscObjectId idx,idy; PetscInt i,j,jend,m; PetscScalar *marray; PetscBool symm=PETSC_FALSE; Vec z; PetscFunctionBegin; ierr = MatGetSize(M,&m,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&marray);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)X,&idx);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)Y,&idy);CHKERRQ(ierr); if (idx==idy) symm=PETSC_TRUE; /* M=X'BX is symmetric */ jend = X->k; for (j=X->l;jk = j+1; ierr = BVGetColumn(X,j,&z);CHKERRQ(ierr); ierr = (*Y->ops->dotvec)(Y,z,marray+j*m+Y->l);CHKERRQ(ierr); ierr = BVRestoreColumn(X,j,&z);CHKERRQ(ierr); if (symm) { for (i=X->l;ik) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Mat argument has %D rows, should have at least %D",m,Y->k); if (nk) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Mat argument has %D columns, should have at least %D",n,X->k); if (X->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, Y %D",X->n,Y->n); if (X->matrix!=Y->matrix) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"X and Y must have the same inner product matrix"); if (X->l==X->k || Y->l==Y->k) PetscFunctionReturn(0); ierr = PetscLogEventBegin(BV_Dot,X,Y,0,0);CHKERRQ(ierr); if (X->matrix) { /* non-standard inner product */ if (X->vmm==BV_MATMULT_VECS) { /* perform computation column by column */ ierr = BVDot_Private(X,Y,M);CHKERRQ(ierr); } else { /* compute BX first */ ierr = BV_IPMatMultBV(X);CHKERRQ(ierr); B = X->matrix; X->matrix = NULL; ierr = (*X->ops->dot)(X->cached,Y,M);CHKERRQ(ierr); X->matrix = B; } } else { ierr = (*X->ops->dot)(X,Y,M);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_Dot,X,Y,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec" /*@ BVDotVec - Computes multiple dot products of a vector against all the column vectors of a BV. Collective on BV and Vec Input Parameters: + X - basis vectors - y - a vector Output Parameter: . m - an array where the result must be placed Notes: This is analogue to VecMDot(), but using BV to represent a collection of vectors. The result is m = X^H*y, so m_i is equal to x_j^H y. Note that here X is transposed as opposed to BVDot(). If a non-standard inner product has been specified with BVSetMatrix(), then the result is m = X^H*B*y. The length of array m must be equal to the number of active columns of X minus the number of leading columns, i.e. the first entry of m is the product of the first non-leading column with y. Level: intermediate .seealso: BVDot(), BVDotColumn(), BVSetActiveColumns(), BVSetMatrix() @*/ PetscErrorCode BVDotVec(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; PetscInt n; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidHeaderSpecific(y,VEC_CLASSID,2); PetscValidType(X,1); BVCheckSizes(X,1); PetscValidType(y,2); PetscCheckSameTypeAndComm(X,1,y,2); ierr = VecGetLocalSize(y,&n);CHKERRQ(ierr); if (X->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, y %D",X->n,n); ierr = PetscLogEventBegin(BV_DotVec,X,y,0,0);CHKERRQ(ierr); ierr = (*X->ops->dotvec)(X,y,m);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_DotVec,X,y,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVecBegin" /*@ BVDotVecBegin - Starts a split phase dot product computation. Input Parameters: + X - basis vectors . y - a vector - m - an array where the result will go (can be NULL) Note: Each call to BVDotVecBegin() should be paired with a call to BVDotVecEnd(). Level: advanced .seealso: BVDotVecEnd(), BVDotVec() @*/ PetscErrorCode BVDotVecBegin(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; PetscInt i,n,nv; PetscSplitReduction *sr; MPI_Comm comm; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidHeaderSpecific(y,VEC_CLASSID,2); PetscValidType(X,1); BVCheckSizes(X,1); PetscValidType(y,2); PetscCheckSameTypeAndComm(X,1,y,2); ierr = VecGetLocalSize(y,&n);CHKERRQ(ierr); if (X->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, y %D",X->n,n); if (X->ops->dotvec_begin) { ierr = (*X->ops->dotvec_begin)(X,y,m);CHKERRQ(ierr); } else { nv = X->k-X->l; ierr = PetscObjectGetComm((PetscObject)X,&comm);CHKERRQ(ierr); ierr = PetscSplitReductionGet(comm,&sr);CHKERRQ(ierr); if (sr->state != STATE_BEGIN) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Called before all VecxxxEnd() called"); for (i=0;inumopsbegin+i >= sr->maxops) { ierr = PetscSplitReductionExtend(sr);CHKERRQ(ierr); } sr->reducetype[sr->numopsbegin+i] = REDUCE_SUM; sr->invecs[sr->numopsbegin+i] = (void*)X; } ierr = PetscLogEventBegin(BV_DotVec,X,y,0,0);CHKERRQ(ierr); ierr = (*X->ops->dotvec_local)(X,y,sr->lvalues+sr->numopsbegin);CHKERRQ(ierr); sr->numopsbegin += nv; ierr = PetscLogEventEnd(BV_DotVec,X,y,0,0);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVecEnd" /*@ BVDotVecEnd - Ends a split phase dot product computation. Input Parameters: + X - basis vectors . y - a vector - m - an array where the result will go Note: Each call to BVDotVecBegin() should be paired with a call to BVDotVecEnd(). Level: advanced .seealso: BVDotVecBegin(), BVDotVec() @*/ PetscErrorCode BVDotVecEnd(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; PetscInt i,nv; PetscSplitReduction *sr; MPI_Comm comm; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidType(X,1); BVCheckSizes(X,1); if (X->ops->dotvec_end) { ierr = (*X->ops->dotvec_end)(X,y,m);CHKERRQ(ierr); } else { nv = X->k-X->l; ierr = PetscObjectGetComm((PetscObject)X,&comm);CHKERRQ(ierr); ierr = PetscSplitReductionGet(comm,&sr);CHKERRQ(ierr); ierr = PetscSplitReductionEnd(sr);CHKERRQ(ierr); if (sr->numopsend >= sr->numopsbegin) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() more times than VecxxxBegin()"); if ((void*)X != sr->invecs[sr->numopsend]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called BVxxxEnd() in a different order or with a different BV than BVxxxBegin()"); if (sr->reducetype[sr->numopsend] != REDUCE_SUM) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Wrong type of reduction"); for (i=0;igvalues[sr->numopsend++]; /* Finished getting all the results so reset to no outstanding requests */ if (sr->numopsend == sr->numopsbegin) { sr->state = STATE_BEGIN; sr->numopsend = 0; sr->numopsbegin = 0; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotColumn" /*@ BVDotColumn - Computes multiple dot products of a column against all the previous columns of a BV. Collective on BV Input Parameters: + X - basis vectors - j - the column index Output Parameter: . m - an array where the result must be placed Notes: This operation is equivalent to BVDotVec() but it uses column j of X rather than taking a Vec as an argument. The number of active columns of X is set to j before the computation, and restored afterwards. If X has leading columns specified, then these columns do not participate in the computation. Therefore, the length of array m must be equal to j minus the number of leading columns. Level: advanced .seealso: BVDot(), BVDotVec(), BVSetActiveColumns(), BVSetMatrix() @*/ PetscErrorCode BVDotColumn(BV X,PetscInt j,PetscScalar *m) { PetscErrorCode ierr; PetscInt ksave; Vec y; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidLogicalCollectiveInt(X,j,2); PetscValidType(X,1); BVCheckSizes(X,1); if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative"); if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m); ierr = PetscLogEventBegin(BV_DotVec,X,0,0,0);CHKERRQ(ierr); ksave = X->k; X->k = j; ierr = BVGetColumn(X,j,&y);CHKERRQ(ierr); ierr = (*X->ops->dotvec)(X,y,m);CHKERRQ(ierr); ierr = BVRestoreColumn(X,j,&y);CHKERRQ(ierr); X->k = ksave; ierr = PetscLogEventEnd(BV_DotVec,X,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotColumnBegin" /*@ BVDotColumnBegin - Starts a split phase dot product computation. Input Parameters: + X - basis vectors - j - the column index - m - an array where the result will go (can be NULL) Note: Each call to BVDotColumnBegin() should be paired with a call to BVDotColumnEnd(). Level: advanced .seealso: BVDotColumnEnd(), BVDotColumn() @*/ PetscErrorCode BVDotColumnBegin(BV X,PetscInt j,PetscScalar *m) { PetscErrorCode ierr; PetscInt i,nv,ksave; PetscSplitReduction *sr; MPI_Comm comm; Vec y; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidLogicalCollectiveInt(X,j,2); PetscValidType(X,1); BVCheckSizes(X,1); if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative"); if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m); ksave = X->k; X->k = j; ierr = BVGetColumn(X,j,&y);CHKERRQ(ierr); if (X->ops->dotvec_begin) { ierr = (*X->ops->dotvec_begin)(X,y,m);CHKERRQ(ierr); } else { nv = X->k-X->l; ierr = PetscObjectGetComm((PetscObject)X,&comm);CHKERRQ(ierr); ierr = PetscSplitReductionGet(comm,&sr);CHKERRQ(ierr); if (sr->state != STATE_BEGIN) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Called before all VecxxxEnd() called"); for (i=0;inumopsbegin+i >= sr->maxops) { ierr = PetscSplitReductionExtend(sr);CHKERRQ(ierr); } sr->reducetype[sr->numopsbegin+i] = REDUCE_SUM; sr->invecs[sr->numopsbegin+i] = (void*)X; } ierr = PetscLogEventBegin(BV_DotVec,X,0,0,0);CHKERRQ(ierr); ierr = (*X->ops->dotvec_local)(X,y,sr->lvalues+sr->numopsbegin);CHKERRQ(ierr); sr->numopsbegin += nv; ierr = PetscLogEventEnd(BV_DotVec,X,0,0,0);CHKERRQ(ierr); } ierr = BVRestoreColumn(X,j,&y);CHKERRQ(ierr); X->k = ksave; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotColumnEnd" /*@ BVDotColumnEnd - Ends a split phase dot product computation. Input Parameters: + X - basis vectors . j - the column index - m - an array where the result will go Notes: Each call to BVDotColumnBegin() should be paired with a call to BVDotColumnEnd(). Level: advanced .seealso: BVDotColumnBegin(), BVDotColumn() @*/ PetscErrorCode BVDotColumnEnd(BV X,PetscInt j,PetscScalar *m) { PetscErrorCode ierr; PetscInt i,nv,ksave; PetscSplitReduction *sr; MPI_Comm comm; Vec y; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); PetscValidLogicalCollectiveInt(X,j,2); PetscValidType(X,1); BVCheckSizes(X,1); if (j<0) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j must be non-negative"); if (j>=X->m) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_OUTOFRANGE,"Index j=%D but BV only has %D columns",j,X->m); ksave = X->k; X->k = j; if (X->ops->dotvec_end) { ierr = BVGetColumn(X,j,&y);CHKERRQ(ierr); ierr = (*X->ops->dotvec_end)(X,y,m);CHKERRQ(ierr); ierr = BVRestoreColumn(X,j,&y);CHKERRQ(ierr); } else { nv = X->k-X->l; ierr = PetscObjectGetComm((PetscObject)X,&comm);CHKERRQ(ierr); ierr = PetscSplitReductionGet(comm,&sr);CHKERRQ(ierr); ierr = PetscSplitReductionEnd(sr);CHKERRQ(ierr); if (sr->numopsend >= sr->numopsbegin) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() more times than VecxxxBegin()"); if ((void*)X != sr->invecs[sr->numopsend]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called BVxxxEnd() in a different order or with a different BV than BVxxxBegin()"); if (sr->reducetype[sr->numopsend] != REDUCE_SUM) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Wrong type of reduction"); for (i=0;igvalues[sr->numopsend++]; /* Finished getting all the results so reset to no outstanding requests */ if (sr->numopsend == sr->numopsbegin) { sr->state = STATE_BEGIN; sr->numopsend = 0; sr->numopsbegin = 0; } } X->k = ksave; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Private" PETSC_STATIC_INLINE PetscErrorCode BVNorm_Private(BV bv,Vec z,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscScalar p; PetscFunctionBegin; ierr = BV_IPMatMult(bv,z);CHKERRQ(ierr); ierr = VecDot(bv->Bx,z,&p);CHKERRQ(ierr); ierr = BV_SafeSqrt(bv,p,val);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Begin_Private" PETSC_STATIC_INLINE PetscErrorCode BVNorm_Begin_Private(BV bv,Vec z,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscScalar p; PetscFunctionBegin; ierr = BV_IPMatMult(bv,z);CHKERRQ(ierr); ierr = VecDotBegin(bv->Bx,z,&p);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_End_Private" PETSC_STATIC_INLINE PetscErrorCode BVNorm_End_Private(BV bv,Vec z,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscScalar p; PetscFunctionBegin; ierr = VecDotEnd(bv->Bx,z,&p);CHKERRQ(ierr); ierr = BV_SafeSqrt(bv,p,val);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm" /*@ BVNorm - Computes the matrix norm of the BV. Collective on BV Input Parameters: + bv - basis vectors - type - the norm type Output Parameter: . val - the norm Notes: All active columns (except the leading ones) are considered as a matrix. The allowed norms are NORM_1, NORM_FROBENIUS, and NORM_INFINITY. This operation fails if a non-standard inner product has been specified with BVSetMatrix(). Level: intermediate .seealso: BVNormVec(), BVNormColumn(), BVSetActiveColumns(), BVSetMatrix() @*/ PetscErrorCode BVNorm(BV bv,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveEnum(bv,type,2); PetscValidPointer(val,3); PetscValidType(bv,1); BVCheckSizes(bv,1); if (type==NORM_2 || type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available"); if (bv->matrix) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Matrix norm not available for non-standard inner product"); ierr = PetscLogEventBegin(BV_Norm,bv,0,0,0);CHKERRQ(ierr); ierr = (*bv->ops->norm)(bv,-1,type,val);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_Norm,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNormVec" /*@ BVNormVec - Computes the norm of a given vector. Collective on BV Input Parameters: + bv - basis vectors . v - the vector - type - the norm type Output Parameter: . val - the norm Notes: This is the analogue of BVNormColumn() but for a vector that is not in the BV. If a non-standard inner product has been specified with BVSetMatrix(), then the returned value is sqrt(v'*B*v), where B is the inner product matrix (argument 'type' is ignored). Otherwise, VecNorm() is called. Level: developer .seealso: BVNorm(), BVNormColumn(), BVSetMatrix() @*/ PetscErrorCode BVNormVec(BV bv,Vec v,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscInt n; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidHeaderSpecific(v,VEC_CLASSID,2); PetscValidLogicalCollectiveEnum(bv,type,3); PetscValidPointer(val,4); PetscValidType(bv,1); BVCheckSizes(bv,1); PetscValidType(v,2); PetscCheckSameComm(bv,1,v,2); if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available"); ierr = PetscLogEventBegin(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); if (bv->matrix) { /* non-standard inner product */ ierr = VecGetLocalSize(v,&n);CHKERRQ(ierr); if (bv->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension bv %D, v %D",bv->n,n); ierr = BVNorm_Private(bv,v,type,val);CHKERRQ(ierr); } else { ierr = VecNorm(v,type,val);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNormVecBegin" /*@ BVNormVecBegin - Starts a split phase norm computation. Input Parameters: + bv - basis vectors . v - the vector . type - the norm type - val - the norm Note: Each call to BVNormVecBegin() should be paired with a call to BVNormVecEnd(). Level: advanced .seealso: BVNormVecEnd(), BVNormVec() @*/ PetscErrorCode BVNormVecBegin(BV bv,Vec v,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscInt n; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidHeaderSpecific(v,VEC_CLASSID,2); PetscValidLogicalCollectiveEnum(bv,type,3); PetscValidPointer(val,4); PetscValidType(bv,1); BVCheckSizes(bv,1); PetscValidType(v,2); PetscCheckSameTypeAndComm(bv,1,v,2); if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available"); ierr = PetscLogEventBegin(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); if (bv->matrix) { /* non-standard inner product */ ierr = VecGetLocalSize(v,&n);CHKERRQ(ierr); if (bv->n!=n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension bv %D, v %D",bv->n,n); ierr = BVNorm_Begin_Private(bv,v,type,val);CHKERRQ(ierr); } else { ierr = VecNormBegin(v,type,val);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNormVecEnd" /*@ BVNormVecEnd - Ends a split phase norm computation. Input Parameters: + bv - basis vectors . v - the vector . type - the norm type - val - the norm Note: Each call to BVNormVecBegin() should be paired with a call to BVNormVecEnd(). Level: advanced .seealso: BVNormVecBegin(), BVNormVec() @*/ PetscErrorCode BVNormVecEnd(BV bv,Vec v,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveEnum(bv,type,3); PetscValidPointer(val,4); PetscValidType(bv,1); BVCheckSizes(bv,1); if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available"); if (bv->matrix) { /* non-standard inner product */ ierr = BVNorm_End_Private(bv,v,type,val);CHKERRQ(ierr); } else { ierr = VecNormEnd(v,type,val);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNormColumn" /*@ BVNormColumn - Computes the vector norm of a selected column. Collective on BV Input Parameters: + bv - basis vectors . j - column number to be used - type - the norm type Output Parameter: . val - the norm Notes: The norm of V[j] is computed (NORM_1, NORM_2, or NORM_INFINITY). If a non-standard inner product has been specified with BVSetMatrix(), then the returned value is sqrt(V[j]'*B*V[j]), where B is the inner product matrix (argument 'type' is ignored). Level: intermediate .seealso: BVNorm(), BVNormVec(), BVSetActiveColumns(), BVSetMatrix() @*/ PetscErrorCode BVNormColumn(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; Vec z; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidLogicalCollectiveEnum(bv,type,3); PetscValidPointer(val,4); PetscValidType(bv,1); BVCheckSizes(bv,1); if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m); if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available"); ierr = PetscLogEventBegin(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); if (bv->matrix) { /* non-standard inner product */ ierr = BVGetColumn(bv,j,&z);CHKERRQ(ierr); ierr = BVNorm_Private(bv,z,type,val);CHKERRQ(ierr); ierr = BVRestoreColumn(bv,j,&z);CHKERRQ(ierr); } else { ierr = (*bv->ops->norm)(bv,j,type,val);CHKERRQ(ierr); } ierr = PetscLogEventEnd(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNormColumnBegin" /*@ BVNormColumnBegin - Starts a split phase norm computation. Input Parameters: + bv - basis vectors . j - column number to be used . type - the norm type - val - the norm Note: Each call to BVNormColumnBegin() should be paired with a call to BVNormColumnEnd(). Level: advanced .seealso: BVNormColumnEnd(), BVNormColumn() @*/ PetscErrorCode BVNormColumnBegin(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscSplitReduction *sr; PetscReal lresult; MPI_Comm comm; Vec z; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidLogicalCollectiveEnum(bv,type,3); PetscValidPointer(val,4); PetscValidType(bv,1); BVCheckSizes(bv,1); if (j<0 || j>=bv->m) SETERRQ2(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Argument j has wrong value %D, the number of columns is %D",j,bv->m); if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available"); ierr = PetscLogEventBegin(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); ierr = BVGetColumn(bv,j,&z);CHKERRQ(ierr); if (bv->matrix) { /* non-standard inner product */ ierr = BVNorm_Begin_Private(bv,z,type,val);CHKERRQ(ierr); } else if (bv->ops->norm_begin) { ierr = (*bv->ops->norm_begin)(bv,j,type,val);CHKERRQ(ierr); } else { ierr = PetscObjectGetComm((PetscObject)z,&comm);CHKERRQ(ierr); ierr = PetscSplitReductionGet(comm,&sr);CHKERRQ(ierr); if (sr->state != STATE_BEGIN) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Called before all VecxxxEnd() called"); if (sr->numopsbegin >= sr->maxops) { ierr = PetscSplitReductionExtend(sr);CHKERRQ(ierr); } sr->invecs[sr->numopsbegin] = (void*)bv; ierr = (*bv->ops->norm_local)(bv,j,type,&lresult);CHKERRQ(ierr); if (type == NORM_2) lresult = lresult*lresult; if (type == NORM_MAX) sr->reducetype[sr->numopsbegin] = REDUCE_MAX; else sr->reducetype[sr->numopsbegin] = REDUCE_SUM; sr->lvalues[sr->numopsbegin++] = lresult; } ierr = BVRestoreColumn(bv,j,&z);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_NormVec,bv,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNormColumnEnd" /*@ BVNormColumnEnd - Ends a split phase norm computation. Input Parameters: + bv - basis vectors . j - column number to be used . type - the norm type - val - the norm Note: Each call to BVNormColumnBegin() should be paired with a call to BVNormColumnEnd(). Level: advanced .seealso: BVNormColumnBegin(), BVNormColumn() @*/ PetscErrorCode BVNormColumnEnd(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscSplitReduction *sr; MPI_Comm comm; Vec z; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); PetscValidLogicalCollectiveInt(bv,j,2); PetscValidLogicalCollectiveEnum(bv,type,3); PetscValidPointer(val,4); PetscValidType(bv,1); BVCheckSizes(bv,1); if (type==NORM_1_AND_2) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_SUP,"Requested norm not available"); ierr = BVGetColumn(bv,j,&z);CHKERRQ(ierr); if (bv->matrix) { /* non-standard inner product */ ierr = BVNorm_End_Private(bv,z,type,val);CHKERRQ(ierr); } else if (bv->ops->norm_end) { ierr = (*bv->ops->norm_end)(bv,j,type,val);CHKERRQ(ierr); } else { ierr = PetscObjectGetComm((PetscObject)z,&comm);CHKERRQ(ierr); ierr = PetscSplitReductionGet(comm,&sr);CHKERRQ(ierr); ierr = PetscSplitReductionEnd(sr);CHKERRQ(ierr); if (sr->numopsend >= sr->numopsbegin) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() more times then VecxxxBegin()"); if ((void*)bv != sr->invecs[sr->numopsend]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called VecxxxEnd() in a different order or with a different vector than VecxxxBegin()"); if (sr->reducetype[sr->numopsend] != REDUCE_MAX && type == NORM_MAX) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Called BVNormEnd(,NORM_MAX,) on a reduction started with VecDotBegin() or NORM_1 or NORM_2"); *val = PetscRealPart(sr->gvalues[sr->numopsend++]); if (type == NORM_2) *val = PetscSqrtReal(*val); if (sr->numopsend == sr->numopsbegin) { sr->state = STATE_BEGIN; sr->numopsend = 0; sr->numopsbegin = 0; } } ierr = BVRestoreColumn(bv,j,&z);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatProject_Vec" /* Compute Y^H*A*X: right part column by column (with MatMult) and bottom part row by row (with MatMultHermitianTranspose); result placed in marray[*,ldm] */ PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Vec(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm) { PetscErrorCode ierr; PetscInt i,j,lx,ly,kx,ky,ulim; Vec z,f; PetscFunctionBegin; lx = X->l; kx = X->k; ly = Y->l; ky = Y->k; ierr = BVCreateVec(X,&f);CHKERRQ(ierr); for (j=lx;jl = 0; Y->k = ulim; ierr = (*Y->ops->dotvec)(Y,f,marray+j*ldm);CHKERRQ(ierr); if (symm) { for (i=0;il = 0; X->k = ulim; ierr = (*X->ops->dotvec)(X,f,Y->h);CHKERRQ(ierr); for (i=0;ih[i]); } } ierr = VecDestroy(&f);CHKERRQ(ierr); X->l = lx; X->k = kx; Y->l = ly; Y->k = ky; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatProject_MatMult" /* Compute Y^H*A*X= [ -- | Y0'*W1 ] [ Y1'*W0 | Y1'*W1 ] Allocates auxiliary BV to store the result of A*X, then one BVDot call for top-right part and another one for bottom part; result placed in marray[*,ldm] */ PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm) { PetscErrorCode ierr; PetscInt j,lx,ly,kx,ky; PetscScalar *harray; Mat H; BV W; PetscFunctionBegin; lx = X->l; kx = X->k; ly = Y->l; ky = Y->k; ierr = BVDuplicate(X,&W);CHKERRQ(ierr); X->l = 0; X->k = kx; ierr = BVMatMult(X,A,W);CHKERRQ(ierr); /* top-right part, Y0'*AX1 */ if (ly>0 && lxl = lx; W->k = kx; Y->l = 0; Y->k = ly; ierr = BVDot(W,Y,H);CHKERRQ(ierr); ierr = MatDenseGetArray(H,&harray);CHKERRQ(ierr); for (j=lx;j0 && lyl = 0; W->k = kx; Y->l = ly; Y->k = ky; ierr = BVDot(W,Y,H);CHKERRQ(ierr); ierr = MatDenseGetArray(H,&harray);CHKERRQ(ierr); for (j=0;jl = lx; X->k = kx; Y->l = ly; Y->k = ky; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatProject_MatMult_2" /* Compute Y^H*A*X= [ -- | Y0'*W1 ] [ Y1'*W0 | Y1'*W1 ] First stage: allocate auxiliary BV to store A*X1, one BVDot for right part; Second stage: resize BV to accomodate A'*Y1, then call BVDot for transpose of bottom-left part; result placed in marray[*,ldm] */ PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult_2(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm) { PetscErrorCode ierr; PetscInt i,j,lx,ly,kx,ky; PetscScalar *harray; Mat H; BV W; PetscFunctionBegin; lx = X->l; kx = X->k; ly = Y->l; ky = Y->k; /* right part, Y'*AX1 */ ierr = BVDuplicateResize(X,kx-lx,&W);CHKERRQ(ierr); if (ky>0 && lxl = 0; Y->k = ky; ierr = BVDot(W,Y,H);CHKERRQ(ierr); ierr = MatDenseGetArray(H,&harray);CHKERRQ(ierr); for (j=lx;j0 && lyl = ly; Y->k = ky; ierr = BVMatMultHermitianTranspose(Y,A,W);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,lx,ky-ly,NULL,&H);CHKERRQ(ierr); X->l = 0; X->k = lx; ierr = BVDot(W,X,H);CHKERRQ(ierr); ierr = MatDenseGetArray(H,&harray);CHKERRQ(ierr); for (i=0;il = lx; X->k = kx; Y->l = ly; Y->k = ky; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatProject_Dot" /* Compute Y^H*X = [ -- | Y0'*X1 ] (X contains A*X): [ Y1'*X0 | Y1'*X1 ] one BVDot call for top-right part and another one for bottom part; result placed in marray[*,ldm] */ PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Dot(BV X,BV Y,PetscScalar *marray,PetscInt ldm) { PetscErrorCode ierr; PetscInt j,lx,ly,kx,ky; PetscScalar *harray; Mat H; PetscFunctionBegin; lx = X->l; kx = X->k; ly = Y->l; ky = Y->k; /* top-right part, Y0'*X1 */ if (ly>0 && lxl = lx; X->k = kx; Y->l = 0; Y->k = ly; ierr = BVDot(X,Y,H);CHKERRQ(ierr); ierr = MatDenseGetArray(H,&harray);CHKERRQ(ierr); for (j=lx;j0 && lyl = 0; X->k = kx; Y->l = ly; Y->k = ky; ierr = BVDot(X,Y,H);CHKERRQ(ierr); ierr = MatDenseGetArray(H,&harray);CHKERRQ(ierr); for (j=0;jl = lx; X->k = kx; Y->l = ly; Y->k = ky; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatProject" /*@ BVMatProject - Computes the projection of a matrix onto a subspace. Collective on BV Input Parameters: + X - basis vectors . A - (optional) matrix to be projected . Y - left basis vectors, can be equal to X - M - Mat object where the result must be placed Output Parameter: . M - the resulting matrix Notes: If A=NULL, then it is assumed that X already contains A*X. This operation is similar to BVDot(), with important differences. The goal is to compute the matrix resulting from the orthogonal projection of A onto the subspace spanned by the columns of X, M = X^H*A*X, or the oblique projection onto X along Y, M = Y^H*A*X. A difference with respect to BVDot() is that the standard inner product is always used, regardless of a non-standard inner product being specified with BVSetMatrix(). On entry, M must be a sequential dense Mat with dimensions ky,kx at least, where ky (resp. kx) is the number of active columns of Y (resp. X). Another difference with respect to BVDot() is that all entries of M are computed except the leading ly,lx part, where ly (resp. lx) is the number of leading columns of Y (resp. X). Hence, the leading columns of X and Y participate in the computation, as opposed to BVDot(). The leading part of M is assumed to be already available from previous computations. In the orthogonal projection case, Y=X, some computation can be saved if A is real symmetric (or complex Hermitian). In order to exploit this property, the symmetry flag of A must be set with MatSetOption(). Level: intermediate .seealso: BVDot(), BVSetActiveColumns(), BVSetMatrix() @*/ PetscErrorCode BVMatProject(BV X,Mat A,BV Y,Mat M) { PetscErrorCode ierr; PetscBool match,set,flg,symm=PETSC_FALSE; PetscInt m,n; PetscScalar *marray; Mat Xmatrix,Ymatrix; PetscObjectId idx,idy; PetscFunctionBegin; PetscValidHeaderSpecific(X,BV_CLASSID,1); if (A) PetscValidHeaderSpecific(A,MAT_CLASSID,2); PetscValidHeaderSpecific(Y,BV_CLASSID,3); PetscValidHeaderSpecific(M,MAT_CLASSID,4); PetscValidType(X,1); BVCheckSizes(X,1); if (A) { PetscValidType(A,2); PetscCheckSameComm(X,1,A,2); } PetscValidType(Y,3); BVCheckSizes(Y,3); PetscValidType(M,4); PetscCheckSameTypeAndComm(X,1,Y,3); ierr = PetscObjectTypeCompare((PetscObject)M,MATSEQDENSE,&match);CHKERRQ(ierr); if (!match) SETERRQ(PetscObjectComm((PetscObject)X),PETSC_ERR_SUP,"Matrix M must be of type seqdense"); ierr = MatGetSize(M,&m,&n);CHKERRQ(ierr); if (mk) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Matrix M has %D rows, should have at least %D",m,Y->k); if (nk) SETERRQ2(PetscObjectComm((PetscObject)X),PETSC_ERR_ARG_SIZ,"Matrix M has %D columns, should have at least %D",n,X->k); if (X->n!=Y->n) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Mismatching local dimension X %D, Y %D",X->n,Y->n); ierr = PetscLogEventBegin(BV_MatProject,X,A,Y,0);CHKERRQ(ierr); /* temporarily set standard inner product */ Xmatrix = X->matrix; Ymatrix = Y->matrix; X->matrix = Y->matrix = NULL; ierr = PetscObjectGetId((PetscObject)X,&idx);CHKERRQ(ierr); ierr = PetscObjectGetId((PetscObject)Y,&idy);CHKERRQ(ierr); if (!A && idx==idy) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Cannot set X=Y if A=NULL"); ierr = MatDenseGetArray(M,&marray);CHKERRQ(ierr); if (A && idx==idy) { /* check symmetry of M=X'AX */ ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); symm = set? flg: PETSC_FALSE; } if (A) { if (X->vmm==BV_MATMULT_VECS) { /* perform computation column by column */ ierr = BVMatProject_Vec(X,A,Y,marray,m,symm);CHKERRQ(ierr); } else { /* use BVMatMult, then BVDot */ ierr = MatHasOperation(A,MATOP_MULT_TRANSPOSE,&flg);CHKERRQ(ierr); if (symm || (flg && X->l>=X->k/2 && Y->l>=Y->k/2)) { ierr = BVMatProject_MatMult_2(X,A,Y,marray,m,symm);CHKERRQ(ierr); } else { ierr = BVMatProject_MatMult(X,A,Y,marray,m);CHKERRQ(ierr); } } } else { /* use BVDot on subblocks */ ierr = BVMatProject_Dot(X,Y,marray,m);CHKERRQ(ierr); } ierr = MatDenseRestoreArray(M,&marray);CHKERRQ(ierr); ierr = PetscLogEventEnd(BV_MatProject,X,A,Y,0);CHKERRQ(ierr); /* restore non-standard inner product */ X->matrix = Xmatrix; Y->matrix = Ymatrix; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/interface/ftn-custom/0000755000175000017500000000000013107004621021673 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/interface/ftn-custom/makefile0000644000175000017500000000222313107004621023372 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zbvf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/bv/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/interface/ftn-custom/zbvf.c0000644000175000017500000000603513107004621023012 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define bvsettype_ BVSETTYPE #define bvgettype_ BVGETTYPE #define bvsetoptionsprefix_ BVSETOPTIONSPREFIX #define bvappendoptionsprefix_ BVAPPENDOPTIONSPREFIX #define bvgetoptionsprefix_ BVGETOPTIONSPREFIX #define bvview_ BVVIEW #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define bvsettype_ bvsettype #define bvgettype_ bvgettype #define bvsetoptionsprefix_ bvsetoptionsprefix #define bvappendoptionsprefix_ bvappendoptionsprefix #define bvgetoptionsprefix_ bvgetoptionsprefix #define bvview_ bvview #endif PETSC_EXTERN void PETSC_STDCALL bvsettype_(BV *bv,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = BVSetType(*bv,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL bvgettype_(BV *bv,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { BVType tname; *ierr = BVGetType(*bv,&tname); if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL bvsetoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = BVSetOptionsPrefix(*bv,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL bvappendoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = BVAppendOptionsPrefix(*bv,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL bvgetoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = BVGetOptionsPrefix(*bv,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL bvview_(BV *bv,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = BVView(*bv,v); } slepc-3.7.4/src/sys/classes/bv/examples/0000755000175000017500000000000013107004621017452 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/examples/makefile0000644000175000017500000000202013107004621021144 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/sys/classes/bv/examples/ DIRS = tests include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/examples/makefile.html0000644000175000017500000000445313107004621022123 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/sys/classes/bv/examples/
DIRS     = tests

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/bv/examples/index.html0000644000175000017500000000124013107004621021444 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
makefile
slepc-3.7.4/src/sys/classes/bv/examples/tests/0000755000175000017500000000000013107004621020614 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/examples/tests/makefile0000644000175000017500000002414013107004621022315 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/sys/classes/bv/examples/tests/ EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c test10.c test11.c test12.c EXAMPLESF = MANSEC = BV TESTS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 TESTEXAMPLES_C = test1.PETSc runtest1_1 runtest1_2 runtest1_3 runtest1_4 test1.rm \ test2.PETSc runtest2_1 runtest2_2 runtest2_3 runtest2_4 \ runtest2_5 runtest2_6 runtest2_7 runtest2_8 test2.rm \ test3.PETSc runtest3_1 runtest3_2 runtest3_3 runtest3_4 test3.rm \ test4.PETSc runtest4_1 runtest4_2 runtest4_3 runtest4_4 test4.rm \ test5.PETSc runtest5_1 runtest5_2 runtest5_3 runtest5_4 test5.rm \ test6.PETSc runtest6_1 runtest6_2 runtest6_3 runtest6_4 test6.rm \ test7.PETSc runtest7_1 runtest7_2 runtest7_3 runtest7_4 test7.rm \ test8.PETSc runtest8_1 runtest8_2 runtest8_3 runtest8_4 test8.rm \ test9.PETSc runtest9_1 runtest9_2 runtest9_3 runtest9_4 test9.rm \ test10.PETSc runtest10_1 runtest10_2 runtest10_3 runtest10_4 test10.rm \ test11.PETSc runtest11_1 runtest11_2 runtest11_3 runtest11_4 \ runtest11_5 runtest11_6 runtest11_7 runtest11_8 test11.rm \ test12.PETSc runtest12_1 test12.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB} ${RM} test1.o test2: test2.o chkopts -${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB} ${RM} test2.o test3: test3.o chkopts -${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB} ${RM} test3.o test4: test4.o chkopts -${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB} ${RM} test4.o test5: test5.o chkopts -${CLINKER} -o test5 test5.o ${SLEPC_SYS_LIB} ${RM} test5.o test6: test6.o chkopts -${CLINKER} -o test6 test6.o ${SLEPC_SYS_LIB} ${RM} test6.o test7: test7.o chkopts -${CLINKER} -o test7 test7.o ${SLEPC_SYS_LIB} ${RM} test7.o test8: test8.o chkopts -${CLINKER} -o test8 test8.o ${SLEPC_SYS_LIB} ${RM} test8.o test9: test9.o chkopts -${CLINKER} -o test9 test9.o ${SLEPC_SYS_LIB} ${RM} test9.o test10: test10.o chkopts -${CLINKER} -o test10 test10.o ${SLEPC_SYS_LIB} ${RM} test10.o test11: test11.o chkopts -${CLINKER} -o test11 test11.o ${SLEPC_SYS_LIB} ${RM} test11.o test12: test12.o chkopts -${CLINKER} -o test12 test12.o ${SLEPC_SYS_LIB} ${RM} test12.o #------------------------------------------------------------------------------------ TESTCODE = \ [ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \ ${DIFF} output/$${test}.out $${test}.tmp || \ echo "Possible problem with $${test}, diffs above"; \ ${RM} -f $${test}.tmp runtest1_1: -@test=test1_1; \ ${MPIEXEC} -n 1 ./test1 -bv_type vecs -verbose 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest1_2: -@test=test1_2; \ ${MPIEXEC} -n 1 ./test1 -bv_type contiguous -verbose 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest1_3: -@test=test1_3; \ ${MPIEXEC} -n 1 ./test1 -bv_type svec -verbose 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest1_4: -@test=test1_4; \ ${MPIEXEC} -n 1 ./test1 -bv_type mat -verbose 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_1: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type vecs -bv_orthog_type cgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_2: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type contiguous -bv_orthog_type cgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_3: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type svec -bv_orthog_type cgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_4: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type mat -bv_orthog_type cgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_5: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type vecs -bv_orthog_type mgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_6: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type contiguous -bv_orthog_type mgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_7: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type svec -bv_orthog_type mgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_8: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -bv_type mat -bv_orthog_type mgs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3_1: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3_2: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3_3: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3_4: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_1: -@test=test4_1; \ ${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_2: -@test=test4_1; \ ${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_3: -@test=test4_1; \ ${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type svec -trans 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_4: -@test=test4_1; \ ${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type mat -trans 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest5_1: -@test=test5_1; \ ${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest5_2: -@test=test5_1; \ ${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest5_3: -@test=test5_1; \ ${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest5_4: -@test=test5_1; \ ${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest6_1: -@test=test6_1; \ ${MPIEXEC} -n 1 ./test6 -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest6_2: -@test=test6_1; \ ${MPIEXEC} -n 1 ./test6 -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest6_3: -@test=test6_1; \ ${MPIEXEC} -n 1 ./test6 -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest6_4: -@test=test6_1; \ ${MPIEXEC} -n 1 ./test6 -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest7_1: -@test=test7_1; \ ${MPIEXEC} -n 1 ./test7 -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest7_2: -@test=test7_1; \ ${MPIEXEC} -n 1 ./test7 -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest7_3: -@test=test7_1; \ ${MPIEXEC} -n 1 ./test7 -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest7_4: -@test=test7_1; \ ${MPIEXEC} -n 1 ./test7 -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest8_1: -@test=test8_1; \ ${MPIEXEC} -n 1 ./test8 -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest8_2: -@test=test8_1; \ ${MPIEXEC} -n 1 ./test8 -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest8_3: -@test=test8_1; \ ${MPIEXEC} -n 1 ./test8 -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest8_4: -@test=test8_1; \ ${MPIEXEC} -n 1 ./test8 -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest9_1: -@test=test9_1; \ ${MPIEXEC} -n 1 ./test9 -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest9_2: -@test=test9_1; \ ${MPIEXEC} -n 1 ./test9 -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest9_3: -@test=test9_1; \ ${MPIEXEC} -n 1 ./test9 -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest9_4: -@test=test9_1; \ ${MPIEXEC} -n 1 ./test9 -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest10_1: -@test=test10_1; \ ${MPIEXEC} -n 2 ./test10 -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest10_2: -@test=test10_1; \ ${MPIEXEC} -n 2 ./test10 -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest10_3: -@test=test10_1; \ ${MPIEXEC} -n 2 ./test10 -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest10_4: -@test=test10_1; \ ${MPIEXEC} -n 2 ./test10 -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_1: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_2: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_3: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_4: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_5: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type vecs 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_6: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type contiguous 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_7: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type svec 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest11_8: -@test=test11_1; \ ${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type mat 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest12_1: -@test=test12_1; \ ${MPIEXEC} -n 1 ./test12 -bv_orthog_block gs mat 2>&1 > $${test}.tmp; \ ${TESTCODE} #runtest12_2: # -@test=test12_1; \ # ${MPIEXEC} -n 1 ./test12 -bv_orthog_block chol mat 2>&1 > $${test}.tmp; \ # ${TESTCODE} slepc-3.7.4/src/sys/classes/bv/examples/tests/test4.c.html0000644000175000017500000004034713107004621022776 0ustar jromanjroman

Actual source code: test4.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV operations, changing the number of active columns.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   Vec            t,v;
 32:   Mat            Q,M;
 33:   BV             X,Y;
 34:   PetscInt       i,j,n=10,kx=6,lx=3,ky=5,ly=2;
 35:   PetscScalar    *q,*z;
 36:   PetscReal      nrm;
 37:   PetscViewer    view;
 38:   PetscBool      verbose,trans;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-kx",&kx,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-lx",&lx,NULL);
 44:   PetscOptionsGetInt(NULL,NULL,"-ky",&ky,NULL);
 45:   PetscOptionsGetInt(NULL,NULL,"-ly",&ly,NULL);
 46:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 47:   PetscPrintf(PETSC_COMM_WORLD,"First BV with %D active columns (%D leading columns) of dimension %D.\n",kx,lx,n);
 48:   PetscPrintf(PETSC_COMM_WORLD,"Second BV with %D active columns (%D leading columns) of dimension %D.\n",ky,ly,n);

 50:   /* Create template vector */
 51:   VecCreate(PETSC_COMM_WORLD,&t);
 52:   VecSetSizes(t,PETSC_DECIDE,n);
 53:   VecSetFromOptions(t);

 55:   /* Create BV object X */
 56:   BVCreate(PETSC_COMM_WORLD,&X);
 57:   PetscObjectSetName((PetscObject)X,"X");
 58:   BVSetSizesFromVec(X,t,kx+2);  /* two extra columns to test active columns */
 59:   BVSetFromOptions(X);
 60:   BVSetActiveColumns(X,lx,kx);

 62:   /* Set up viewer */
 63:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 64:   if (verbose) {
 65:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 66:   }

 68:   /* Fill X entries */
 69:   for (j=0;j<kx+2;j++) {
 70:     BVGetColumn(X,j,&v);
 71:     VecSet(v,0.0);
 72:     for (i=0;i<4;i++) {
 73:       if (i+j<n) {
 74:         VecSetValue(v,i+j,(PetscScalar)(3*i+j-2),INSERT_VALUES);
 75:       }
 76:     }
 77:     VecAssemblyBegin(v);
 78:     VecAssemblyEnd(v);
 79:     BVRestoreColumn(X,j,&v);
 80:   }
 81:   if (verbose) {
 82:     BVView(X,view);
 83:   }

 85:   /* Create BV object Y */
 86:   BVCreate(PETSC_COMM_WORLD,&Y);
 87:   PetscObjectSetName((PetscObject)Y,"Y");
 88:   BVSetSizesFromVec(Y,t,ky+1);
 89:   BVSetFromOptions(Y);
 90:   BVSetActiveColumns(Y,ly,ky);

 92:   /* Fill Y entries */
 93:   for (j=0;j<ky+1;j++) {
 94:     BVGetColumn(Y,j,&v);
 95:     VecSet(v,(PetscScalar)(j+1)/4.0);
 96:     BVRestoreColumn(Y,j,&v);
 97:   }
 98:   if (verbose) {
 99:     BVView(Y,view);
100:   }

102:   /* Create Mat */
103:   MatCreateSeqDense(PETSC_COMM_SELF,kx,ky,NULL,&Q);
104:   PetscObjectSetName((PetscObject)Q,"Q");
105:   MatDenseGetArray(Q,&q);
106:   for (i=0;i<kx;i++)
107:     for (j=0;j<ky;j++)
108:       q[i+j*kx] = (i<j)? 2.0: -0.5;
109:   MatDenseRestoreArray(Q,&q);
110:   if (verbose) {
111:     MatView(Q,NULL);
112:   }

114:   /* Test BVMult */
115:   BVMult(Y,2.0,1.0,X,Q);
116:   if (verbose) {
117:     PetscPrintf(PETSC_COMM_WORLD,"After BVMult - - - - - - - - -\n");
118:     BVView(Y,view);
119:   }

121:   /* Test BVMultVec */
122:   BVGetColumn(Y,0,&v);
123:   PetscMalloc1(kx-lx,&z);
124:   z[0] = 2.0;
125:   for (i=1;i<kx-lx;i++) z[i] = -0.5*z[i-1];
126:   BVMultVec(X,-1.0,1.0,v,z);
127:   PetscFree(z);
128:   BVRestoreColumn(Y,0,&v);
129:   if (verbose) {
130:     PetscPrintf(PETSC_COMM_WORLD,"After BVMultVec - - - - - - -\n");
131:     BVView(Y,view);
132:   }

134:   /* Test BVDot */
135:   MatCreateSeqDense(PETSC_COMM_SELF,ky,kx,NULL,&M);
136:   PetscObjectSetName((PetscObject)M,"M");
137:   BVDot(X,Y,M);
138:   if (verbose) {
139:     PetscPrintf(PETSC_COMM_WORLD,"After BVDot - - - - - - - - -\n");
140:     MatView(M,NULL);
141:   }

143:   /* Test BVDotVec */
144:   BVGetColumn(Y,0,&v);
145:   PetscMalloc1(kx-lx,&z);
146:   BVDotVec(X,v,z);
147:   BVRestoreColumn(Y,0,&v);
148:   if (verbose) {
149:     PetscPrintf(PETSC_COMM_WORLD,"After BVDotVec - - - - - - -\n");
150:     VecCreateSeqWithArray(PETSC_COMM_SELF,1,kx-lx,z,&v);
151:     PetscObjectSetName((PetscObject)v,"z");
152:     VecView(v,view);
153:     VecDestroy(&v);
154:   }
155:   PetscFree(z);

157:   /* Test BVMultInPlace and BVScale */
158:   PetscOptionsHasName(NULL,NULL,"-trans",&trans);
159:   if (trans) {
160:     Mat Qt;
161:     MatTranspose(Q,MAT_INITIAL_MATRIX,&Qt);
162:     BVMultInPlaceTranspose(X,Qt,lx+1,ky);
163:     MatDestroy(&Qt);
164:   } else {
165:     BVMultInPlace(X,Q,lx+1,ky);
166:   }
167:   BVScale(X,2.0);
168:   if (verbose) {
169:     PetscPrintf(PETSC_COMM_WORLD,"After BVMultInPlace - - - - -\n");
170:     BVView(X,view);
171:   }

173:   /* Test BVNorm */
174:   BVNormColumn(X,lx,NORM_2,&nrm);
175:   PetscPrintf(PETSC_COMM_WORLD,"2-Norm or X[%D] = %g\n",lx,(double)nrm);
176:   BVNorm(X,NORM_FROBENIUS,&nrm);
177:   PetscPrintf(PETSC_COMM_WORLD,"Frobenius Norm or X = %g\n",(double)nrm);

179:   BVDestroy(&X);
180:   BVDestroy(&Y);
181:   MatDestroy(&Q);
182:   MatDestroy(&M);
183:   VecDestroy(&t);
184:   SlepcFinalize();
185:   return ierr;
186: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test9.c.html0000644000175000017500000004301413107004621022775 0ustar jromanjroman
Actual source code: test9.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV matrix projection.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   Vec            t,v;
 32:   Mat            B,G,H0,H1;
 33:   BV             X,Y,Z;
 34:   PetscInt       i,j,n=20,kx=6,lx=3,ky=5,ly=2,Istart,Iend,col[5];
 35:   PetscScalar    alpha,value[] = { -1, 1, 1, 1, 1 };
 36:   PetscViewer    view;
 37:   PetscReal      norm;
 38:   PetscBool      verbose;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-kx",&kx,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-lx",&lx,NULL);
 44:   PetscOptionsGetInt(NULL,NULL,"-ky",&ky,NULL);
 45:   PetscOptionsGetInt(NULL,NULL,"-ly",&ly,NULL);
 46:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 47:   PetscPrintf(PETSC_COMM_WORLD,"Test BV projection (n=%D).\n",n);
 48:   PetscPrintf(PETSC_COMM_WORLD,"X has %D active columns (%D leading columns).\n",kx,lx);
 49:   PetscPrintf(PETSC_COMM_WORLD,"Y has %D active columns (%D leading columns).\n",ky,ly);

 51:   /* Set up viewer */
 52:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 53:   if (verbose) {
 54:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 55:   }

 57:   /* Create non-symmetric matrix G (Toeplitz) */
 58:   MatCreate(PETSC_COMM_WORLD,&G);
 59:   MatSetSizes(G,PETSC_DECIDE,PETSC_DECIDE,n,n);
 60:   MatSetFromOptions(G);
 61:   MatSetUp(G);
 62:   PetscObjectSetName((PetscObject)G,"G");

 64:   MatGetOwnershipRange(G,&Istart,&Iend);
 65:   for (i=Istart;i<Iend;i++) {
 66:     col[0]=i-1; col[1]=i; col[2]=i+1; col[3]=i+2; col[4]=i+3;
 67:     if (i==0) {
 68:       MatSetValues(G,1,&i,PetscMin(4,n-i),col+1,value+1,INSERT_VALUES);
 69:     } else {
 70:       MatSetValues(G,1,&i,PetscMin(5,n-i+1),col,value,INSERT_VALUES);
 71:     }
 72:   }
 73:   MatAssemblyBegin(G,MAT_FINAL_ASSEMBLY);
 74:   MatAssemblyEnd(G,MAT_FINAL_ASSEMBLY);
 75:   if (verbose) {
 76:     MatView(G,view);
 77:   }

 79:   /* Create symmetric matrix B (1-D Laplacian) */
 80:   MatCreate(PETSC_COMM_WORLD,&B);
 81:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
 82:   MatSetFromOptions(B);
 83:   MatSetUp(B);
 84:   PetscObjectSetName((PetscObject)B,"B");

 86:   MatGetOwnershipRange(B,&Istart,&Iend);
 87:   for (i=Istart;i<Iend;i++) {
 88:     if (i>0) { MatSetValue(B,i,i-1,-1.0,INSERT_VALUES); }
 89:     if (i<n-1) { MatSetValue(B,i,i+1,-1.0,INSERT_VALUES); }
 90:     MatSetValue(B,i,i,2.0,INSERT_VALUES);
 91:   }
 92:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 93:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
 94:   MatCreateVecs(B,&t,NULL);
 95:   if (verbose) {
 96:     MatView(B,view);
 97:   }

 99:   /* Create BV object X */
100:   BVCreate(PETSC_COMM_WORLD,&X);
101:   PetscObjectSetName((PetscObject)X,"X");
102:   BVSetSizesFromVec(X,t,kx+2);  /* two extra columns to test active columns */
103:   BVSetFromOptions(X);

105:   /* Fill X entries */
106:   for (j=0;j<kx+2;j++) {
107:     BVGetColumn(X,j,&v);
108:     VecSet(v,0.0);
109:     for (i=0;i<4;i++) {
110:       if (i+j<n) {
111: #if defined(PETSC_USE_COMPLEX)
112:         alpha = (PetscReal)(3*i+j-2)+(PetscReal)(2*i)*PETSC_i;
113: #else
114:         alpha = (PetscReal)(3*i+j-2);
115: #endif
116:         VecSetValue(v,i+j,alpha,INSERT_VALUES);
117:       }
118:     }
119:     VecAssemblyBegin(v);
120:     VecAssemblyEnd(v);
121:     BVRestoreColumn(X,j,&v);
122:   }
123:   if (verbose) {
124:     BVView(X,view);
125:   }

127:   /* Duplicate BV object and store Z=G*X */
128:   BVDuplicate(X,&Z);
129:   PetscObjectSetName((PetscObject)Z,"Z");
130:   BVSetActiveColumns(X,0,kx);
131:   BVMatMult(X,G,Z);
132:   BVSetActiveColumns(X,lx,kx);
133:   BVSetActiveColumns(Z,lx,kx);

135:   /* Create BV object Y */
136:   BVCreate(PETSC_COMM_WORLD,&Y);
137:   PetscObjectSetName((PetscObject)Y,"Y");
138:   BVSetSizesFromVec(Y,t,ky+1);
139:   BVSetFromOptions(Y);
140:   BVSetActiveColumns(Y,ly,ky);

142:   /* Fill Y entries */
143:   for (j=0;j<ky+1;j++) {
144:     BVGetColumn(Y,j,&v);
145: #if defined(PETSC_USE_COMPLEX)
146:     alpha = (PetscReal)(j+1)/4.0-(PetscReal)j*PETSC_i;
147: #else
148:     alpha = (PetscReal)(j+1)/4.0;
149: #endif
150:     VecSet(v,(PetscScalar)(j+1)/4.0);
151:     BVRestoreColumn(Y,j,&v);
152:   }
153:   if (verbose) {
154:     BVView(Y,view);
155:   }

157:   /* Test BVMatProject for non-symmetric matrix G */
158:   MatCreateSeqDense(PETSC_COMM_SELF,ky,kx,NULL,&H0);
159:   PetscObjectSetName((PetscObject)H0,"H0");
160:   BVMatProject(X,G,Y,H0);
161:   if (verbose) {
162:     MatView(H0,view);
163:   }

165:   /* Test BVMatProject with previously stored G*X */
166:   MatCreateSeqDense(PETSC_COMM_SELF,ky,kx,NULL,&H1);
167:   PetscObjectSetName((PetscObject)H1,"H1");
168:   BVMatProject(Z,NULL,Y,H1);
169:   if (verbose) {
170:     MatView(H1,view);
171:   }

173:   /* Check that H0 and H1 are equal */
174:   MatAXPY(H0,-1.0,H1,SAME_NONZERO_PATTERN);
175:   MatNorm(H0,NORM_1,&norm);
176:   if (norm<10*PETSC_MACHINE_EPSILON) {
177:     PetscPrintf(PETSC_COMM_WORLD,"||H0-H1|| < 10*eps\n");
178:   } else {
179:     PetscPrintf(PETSC_COMM_WORLD,"||H0-H1||=%g\n",(double)norm);
180:   }
181:   MatDestroy(&H0);
182:   MatDestroy(&H1);

184:   /* Test BVMatProject for symmetric matrix B with orthogonal projection */
185:   MatCreateSeqDense(PETSC_COMM_SELF,kx,kx,NULL,&H0);
186:   PetscObjectSetName((PetscObject)H0,"H0");
187:   BVMatProject(X,B,X,H0);
188:   if (verbose) {
189:     MatView(H0,view);
190:   }

192:   /* Repeat previous test with symmetry flag set */
193:   MatSetOption(B,MAT_HERMITIAN,PETSC_TRUE);
194:   MatCreateSeqDense(PETSC_COMM_SELF,kx,kx,NULL,&H1);
195:   PetscObjectSetName((PetscObject)H1,"H1");
196:   BVMatProject(X,B,X,H1);
197:   if (verbose) {
198:     MatView(H1,view);
199:   }

201:   /* Check that H0 and H1 are equal */
202:   MatAXPY(H0,-1.0,H1,SAME_NONZERO_PATTERN);
203:   MatNorm(H0,NORM_1,&norm);
204:   if (norm<10*PETSC_MACHINE_EPSILON) {
205:     PetscPrintf(PETSC_COMM_WORLD,"||H0-H1|| < 10*eps\n");
206:   } else {
207:     PetscPrintf(PETSC_COMM_WORLD,"||H0-H1||=%g\n",(double)norm);
208:   }
209:   MatDestroy(&H0);
210:   MatDestroy(&H1);

212:   BVDestroy(&X);
213:   BVDestroy(&Y);
214:   BVDestroy(&Z);
215:   MatDestroy(&B);
216:   MatDestroy(&G);
217:   VecDestroy(&t);
218:   SlepcFinalize();
219:   return ierr;
220: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test4.c0000644000175000017500000001550113107004621022025 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV operations, changing the number of active columns.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Vec t,v; Mat Q,M; BV X,Y; PetscInt i,j,n=10,kx=6,lx=3,ky=5,ly=2; PetscScalar *q,*z; PetscReal nrm; PetscViewer view; PetscBool verbose,trans; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-kx",&kx,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-lx",&lx,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-ky",&ky,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-ly",&ly,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"First BV with %D active columns (%D leading columns) of dimension %D.\n",kx,lx,n);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Second BV with %D active columns (%D leading columns) of dimension %D.\n",ky,ly,n);CHKERRQ(ierr); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,kx+2);CHKERRQ(ierr); /* two extra columns to test active columns */ ierr = BVSetFromOptions(X);CHKERRQ(ierr); ierr = BVSetActiveColumns(X,lx,kx);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill X entries */ for (j=0;jActual source code: test1.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV operations.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   Vec            t,v;
 32:   Mat            Q,M;
 33:   BV             X,Y;
 34:   PetscInt       i,j,n=10,k=5,l=3;
 35:   PetscScalar    *q,*z;
 36:   PetscReal      nrm;
 37:   PetscViewer    view;
 38:   PetscBool      verbose;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);
 44:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 45:   PetscPrintf(PETSC_COMM_WORLD,"Test BV with %D columns of dimension %D.\n",k,n);

 47:   /* Create template vector */
 48:   VecCreate(PETSC_COMM_WORLD,&t);
 49:   VecSetSizes(t,PETSC_DECIDE,n);
 50:   VecSetFromOptions(t);

 52:   /* Create BV object X */
 53:   BVCreate(PETSC_COMM_WORLD,&X);
 54:   PetscObjectSetName((PetscObject)X,"X");
 55:   BVSetSizesFromVec(X,t,k);
 56:   BVSetFromOptions(X);

 58:   /* Set up viewer */
 59:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 60:   if (!verbose) {
 61:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_INFO_DETAIL);
 62:     BVView(X,view);
 63:     PetscViewerPopFormat(view);
 64:   }

 66:   /* Fill X entries */
 67:   for (j=0;j<k;j++) {
 68:     BVGetColumn(X,j,&v);
 69:     VecSet(v,0.0);
 70:     for (i=0;i<4;i++) {
 71:       if (i+j<n) {
 72:         VecSetValue(v,i+j,(PetscScalar)(3*i+j-2),INSERT_VALUES);
 73:       }
 74:     }
 75:     VecAssemblyBegin(v);
 76:     VecAssemblyEnd(v);
 77:     BVRestoreColumn(X,j,&v);
 78:   }
 79:   if (verbose) {
 80:     BVView(X,view);
 81:   }

 83:   /* Create BV object Y */
 84:   BVCreate(PETSC_COMM_WORLD,&Y);
 85:   PetscObjectSetName((PetscObject)Y,"Y");
 86:   BVSetSizesFromVec(Y,t,l);
 87:   BVSetFromOptions(Y);

 89:   /* Fill Y entries */
 90:   for (j=0;j<l;j++) {
 91:     BVGetColumn(Y,j,&v);
 92:     VecSet(v,(PetscScalar)(j+1)/4.0);
 93:     BVRestoreColumn(Y,j,&v);
 94:   }
 95:   if (verbose) {
 96:     BVView(Y,view);
 97:   }

 99:   /* Create Mat */
100:   MatCreateSeqDense(PETSC_COMM_SELF,k,l,NULL,&Q);
101:   PetscObjectSetName((PetscObject)Q,"Q");
102:   MatDenseGetArray(Q,&q);
103:   for (i=0;i<k;i++)
104:     for (j=0;j<l;j++)
105:       q[i+j*k] = (i<j)? 2.0: -0.5;
106:   MatDenseRestoreArray(Q,&q);
107:   if (verbose) {
108:     MatView(Q,NULL);
109:   }

111:   /* Test BVMult */
112:   BVMult(Y,2.0,1.0,X,Q);
113:   if (verbose) {
114:     PetscPrintf(PETSC_COMM_WORLD,"After BVMult - - - - - - - - -\n");
115:     BVView(Y,view);
116:   }

118:   /* Test BVMultVec */
119:   BVGetColumn(Y,0,&v);
120:   PetscMalloc1(k,&z);
121:   z[0] = 2.0;
122:   for (i=1;i<k;i++) z[i] = -0.5*z[i-1];
123:   BVMultVec(X,-1.0,1.0,v,z);
124:   PetscFree(z);
125:   BVRestoreColumn(Y,0,&v);
126:   if (verbose) {
127:     PetscPrintf(PETSC_COMM_WORLD,"After BVMultVec - - - - - - -\n");
128:     BVView(Y,view);
129:   }

131:   /* Test BVDot */
132:   MatCreateSeqDense(PETSC_COMM_SELF,l,k,NULL,&M);
133:   PetscObjectSetName((PetscObject)M,"M");
134:   BVDot(X,Y,M);
135:   if (verbose) {
136:     PetscPrintf(PETSC_COMM_WORLD,"After BVDot - - - - - - - - -\n");
137:     MatView(M,NULL);
138:   }

140:   /* Test BVDotVec */
141:   BVGetColumn(Y,0,&v);
142:   PetscMalloc1(k,&z);
143:   BVDotVec(X,v,z);
144:   BVRestoreColumn(Y,0,&v);
145:   if (verbose) {
146:     PetscPrintf(PETSC_COMM_WORLD,"After BVDotVec - - - - - - -\n");
147:     VecCreateSeqWithArray(PETSC_COMM_SELF,1,k,z,&v);
148:     PetscObjectSetName((PetscObject)v,"z");
149:     VecView(v,view);
150:     VecDestroy(&v);
151:   }
152:   PetscFree(z);

154:   /* Test BVMultInPlace and BVScale */
155:   BVMultInPlace(X,Q,1,l);
156:   BVScale(X,2.0);
157:   if (verbose) {
158:     PetscPrintf(PETSC_COMM_WORLD,"After BVMultInPlace - - - - -\n");
159:     BVView(X,view);
160:   }

162:   /* Test BVNorm */
163:   BVNormColumn(X,0,NORM_2,&nrm);
164:   PetscPrintf(PETSC_COMM_WORLD,"2-Norm or X[0] = %g\n",(double)nrm);
165:   BVNorm(X,NORM_FROBENIUS,&nrm);
166:   PetscPrintf(PETSC_COMM_WORLD,"Frobenius Norm or X = %g\n",(double)nrm);

168:   BVDestroy(&X);
169:   BVDestroy(&Y);
170:   MatDestroy(&Q);
171:   MatDestroy(&M);
172:   VecDestroy(&t);
173:   SlepcFinalize();
174:   return ierr;
175: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test12.c.html0000644000175000017500000003155413107004621023055 0ustar jromanjroman
Actual source code: test12.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test block orthogonalization on a rank-deficient BV.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   BV             X,Z;
 32:   Mat            M,R;
 33:   Vec            v,w,t;
 34:   PetscInt       i,j,n=20,k=8;
 35:   PetscViewer    view;
 36:   PetscBool      verbose;
 37:   PetscReal      norm;
 38:   PetscScalar    alpha;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 43:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 44:   PetscPrintf(PETSC_COMM_WORLD,"Test BV block orthogonalization (length %D, k=%D).\n",n,k);
 45:   if (k<6) SETERRQ(PETSC_COMM_SELF,1,"k must be at least 6");

 47:   /* Create template vector */
 48:   VecCreate(PETSC_COMM_WORLD,&t);
 49:   VecSetSizes(t,PETSC_DECIDE,n);
 50:   VecSetFromOptions(t);

 52:   /* Create BV object X */
 53:   BVCreate(PETSC_COMM_WORLD,&X);
 54:   PetscObjectSetName((PetscObject)X,"X");
 55:   BVSetSizesFromVec(X,t,k);
 56:   BVSetFromOptions(X);

 58:   /* Set up viewer */
 59:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 60:   if (verbose) {
 61:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 62:   }

 64:   /* Fill X entries (first half) */
 65:   for (j=0;j<k/2;j++) {
 66:     BVGetColumn(X,j,&v);
 67:     VecSet(v,0.0);
 68:     for (i=0;i<=n/2;i++) {
 69:       if (i+j<n) {
 70:         alpha = (3.0*i+j-2)/(2*(i+j+1));
 71:         VecSetValue(v,i+j,alpha,INSERT_VALUES);
 72:       }
 73:     }
 74:     VecAssemblyBegin(v);
 75:     VecAssemblyEnd(v);
 76:     BVRestoreColumn(X,j,&v);
 77:   }

 79:   /* make middle column linearly dependent wrt columns 0 and 1 */
 80:   BVCopyColumn(X,0,j);
 81:   BVGetColumn(X,j,&v);
 82:   BVGetColumn(X,1,&w);
 83:   VecAXPY(v,0.5,w);
 84:   BVRestoreColumn(X,1,&w);
 85:   BVRestoreColumn(X,j,&v);
 86:   j++;

 88:   /* Fill X entries (second half) */
 89:   for (;j<k-1;j++) {
 90:     BVGetColumn(X,j,&v);
 91:     VecSet(v,0.0);
 92:     for (i=0;i<=n/2;i++) {
 93:       if (i+j<n) {
 94:         alpha = (3.0*i+j-2)/(2*(i+j+1));
 95:         VecSetValue(v,i+j,alpha,INSERT_VALUES);
 96:       }
 97:     }
 98:     VecAssemblyBegin(v);
 99:     VecAssemblyEnd(v);
100:     BVRestoreColumn(X,j,&v);
101:   }

103:   /* make middle column linearly dependent wrt columns 1 and k/2+1 */
104:   BVCopyColumn(X,1,j);
105:   BVGetColumn(X,j,&v);
106:   BVGetColumn(X,k/2+1,&w);
107:   VecAXPY(v,-1.2,w);
108:   BVRestoreColumn(X,k/2+1,&w);
109:   BVRestoreColumn(X,j,&v);

111:   if (verbose) {
112:     BVView(X,view);
113:   }

115:   /* Create a copy on Z */
116:   BVDuplicate(X,&Z);
117:   PetscObjectSetName((PetscObject)Z,"Z");
118:   BVCopy(X,Z);

120:   /* Test BVOrthogonalize */
121:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&R);
122:   PetscObjectSetName((PetscObject)R,"R");
123:   BVOrthogonalize(X,R);
124:   if (verbose) {
125:     BVView(X,view);
126:     MatView(R,view);
127:   }

129:   /* Check orthogonality */
130:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&M);
131:   MatShift(M,1.0);   /* set leading part to identity */
132:   BVDot(X,X,M);
133:   MatShift(M,-1.0);
134:   MatNorm(M,NORM_1,&norm);
135:   if (norm<100*PETSC_MACHINE_EPSILON) {
136:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
137:   } else {
138:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)norm);
139:   }

141:   /* Check residual */
142:   BVMult(Z,-1.0,1.0,X,R);
143:   BVNorm(Z,NORM_FROBENIUS,&norm);
144:   if (norm<100*PETSC_MACHINE_EPSILON) {
145:     PetscPrintf(PETSC_COMM_WORLD,"Residual ||X-QR|| < 100*eps\n");
146:   } else {
147:     PetscPrintf(PETSC_COMM_WORLD,"Residual ||X-QR||: %g\n",(double)norm);
148:   }

150:   MatDestroy(&R);
151:   MatDestroy(&M);
152:   BVDestroy(&X);
153:   BVDestroy(&Z);
154:   VecDestroy(&t);
155:   SlepcFinalize();
156:   return ierr;
157: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test10.c.html0000644000175000017500000002536013107004621023051 0ustar jromanjroman
Actual source code: test10.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test split reductions in BV.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   Vec            t,v,w,y,z,zsplit;
 32:   BV             X;
 33:   PetscInt       i,j,n=10,k=5;
 34:   PetscScalar    *zarray;
 35:   PetscReal      nrm;

 37:   SlepcInitialize(&argc,&argv,(char*)0,help);
 38:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 39:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 40:   if (k<3) SETERRQ(PETSC_COMM_SELF,1,"Should specify at least k=3 columns");
 41:   PetscPrintf(PETSC_COMM_WORLD,"BV split ops (%D columns of dimension %D).\n",k,n);

 43:   /* Create template vector */
 44:   VecCreate(PETSC_COMM_WORLD,&t);
 45:   VecSetSizes(t,PETSC_DECIDE,n);
 46:   VecSetFromOptions(t);
 47:   VecDuplicate(t,&v);
 48:   VecSet(v,1.0);

 50:   /* Create BV object X */
 51:   BVCreate(PETSC_COMM_WORLD,&X);
 52:   PetscObjectSetName((PetscObject)X,"X");
 53:   BVSetSizesFromVec(X,t,k);
 54:   BVSetFromOptions(X);

 56:   /* Fill X entries */
 57:   for (j=0;j<k;j++) {
 58:     BVGetColumn(X,j,&w);
 59:     VecSet(w,0.0);
 60:     for (i=0;i<4;i++) {
 61:       if (i+j<n) {
 62:         VecSetValue(w,i+j,(PetscScalar)(3*i+j-2),INSERT_VALUES);
 63:       }
 64:     }
 65:     VecAssemblyBegin(w);
 66:     VecAssemblyEnd(w);
 67:     BVRestoreColumn(X,j,&w);
 68:   }

 70:   /* Use regular operations */
 71:   VecCreateSeq(PETSC_COMM_SELF,k+6,&z);
 72:   VecGetArray(z,&zarray);
 73:   BVGetColumn(X,0,&w);
 74:   VecDot(w,v,zarray);
 75:   BVRestoreColumn(X,0,&w);
 76:   BVDotVec(X,v,zarray+1);
 77:   BVDotColumn(X,2,zarray+1+k);

 79:   BVGetColumn(X,1,&y);
 80:   VecNorm(y,NORM_2,&nrm);
 81:   BVRestoreColumn(X,1,&y);
 82:   zarray[k+3] = nrm;
 83:   BVNormVec(X,v,NORM_2,&nrm);
 84:   zarray[k+4] = nrm;
 85:   BVNormColumn(X,0,NORM_2,&nrm);
 86:   zarray[k+5] = nrm;
 87:   VecRestoreArray(z,&zarray);

 89:   /* Use split operations */
 90:   VecCreateSeq(PETSC_COMM_SELF,k+6,&zsplit);
 91:   VecGetArray(zsplit,&zarray);
 92:   BVGetColumn(X,0,&w);
 93:   VecDotBegin(w,v,zarray);
 94:   BVDotVecBegin(X,v,zarray+1);
 95:   BVDotColumnBegin(X,2,zarray+1+k);
 96:   VecDotEnd(w,v,zarray);
 97:   BVRestoreColumn(X,0,&w);
 98:   BVDotVecEnd(X,v,zarray+1);
 99:   BVDotColumnEnd(X,2,zarray+1+k);

101:   BVGetColumn(X,1,&y);
102:   VecNormBegin(y,NORM_2,&nrm);
103:   BVNormVecBegin(X,v,NORM_2,&nrm);
104:   BVNormColumnBegin(X,0,NORM_2,&nrm);
105:   VecNormEnd(y,NORM_2,&nrm);
106:   BVRestoreColumn(X,1,&y);
107:   zarray[k+3] = nrm;
108:   BVNormVecEnd(X,v,NORM_2,&nrm);
109:   zarray[k+4] = nrm;
110:   BVNormColumnEnd(X,0,NORM_2,&nrm);
111:   zarray[k+5] = nrm;
112:   VecRestoreArray(zsplit,&zarray);

114:   /* Show difference */
115:   VecAXPY(z,-1.0,zsplit);
116:   VecNorm(z,NORM_1,&nrm);
117:   PetscSynchronizedPrintf(PETSC_COMM_WORLD,"%g\n",(double)nrm);
118:   PetscSynchronizedFlush(PETSC_COMM_WORLD,NULL);

120:   BVDestroy(&X);
121:   VecDestroy(&t);
122:   VecDestroy(&v);
123:   VecDestroy(&z);
124:   VecDestroy(&zsplit);
125:   SlepcFinalize();
126:   return ierr;
127: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/makefile.html0000644000175000017500000003601313107004621023262 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/sys/classes/bv/examples/tests/
EXAMPLESC  = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c test10.c test11.c test12.c
EXAMPLESF  =
MANSEC     = BV
TESTS      = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12

TESTEXAMPLES_C       = test1.PETSc runtest1_1 runtest1_2 runtest1_3 runtest1_4 test1.rm \
                       test2.PETSc runtest2_1 runtest2_2 runtest2_3 runtest2_4 \
                                   runtest2_5 runtest2_6 runtest2_7 runtest2_8 test2.rm \
                       test3.PETSc runtest3_1 runtest3_2 runtest3_3 runtest3_4 test3.rm \
                       test4.PETSc runtest4_1 runtest4_2 runtest4_3 runtest4_4 test4.rm \
                       test5.PETSc runtest5_1 runtest5_2 runtest5_3 runtest5_4 test5.rm \
                       test6.PETSc runtest6_1 runtest6_2 runtest6_3 runtest6_4 test6.rm \
                       test7.PETSc runtest7_1 runtest7_2 runtest7_3 runtest7_4 test7.rm \
                       test8.PETSc runtest8_1 runtest8_2 runtest8_3 runtest8_4 test8.rm \
                       test9.PETSc runtest9_1 runtest9_2 runtest9_3 runtest9_4 test9.rm \
                       test10.PETSc runtest10_1 runtest10_2 runtest10_3 runtest10_4 test10.rm \
                       test11.PETSc runtest11_1 runtest11_2 runtest11_3 runtest11_4 \
                                    runtest11_5 runtest11_6 runtest11_7 runtest11_8 test11.rm \
                       test12.PETSc runtest12_1 test12.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB}
	${RM} test1.o

test2: test2.o chkopts
	-${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB}
	${RM} test2.o

test3: test3.o chkopts
	-${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB}
	${RM} test3.o

test4: test4.o chkopts
	-${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB}
	${RM} test4.o

test5: test5.o chkopts
	-${CLINKER} -o test5 test5.o ${SLEPC_SYS_LIB}
	${RM} test5.o

test6: test6.o chkopts
	-${CLINKER} -o test6 test6.o ${SLEPC_SYS_LIB}
	${RM} test6.o

test7: test7.o chkopts
	-${CLINKER} -o test7 test7.o ${SLEPC_SYS_LIB}
	${RM} test7.o

test8: test8.o chkopts
	-${CLINKER} -o test8 test8.o ${SLEPC_SYS_LIB}
	${RM} test8.o

test9: test9.o chkopts
	-${CLINKER} -o test9 test9.o ${SLEPC_SYS_LIB}
	${RM} test9.o

test10: test10.o chkopts
	-${CLINKER} -o test10 test10.o ${SLEPC_SYS_LIB}
	${RM} test10.o

test11: test11.o chkopts
	-${CLINKER} -o test11 test11.o ${SLEPC_SYS_LIB}
	${RM} test11.o

test12: test12.o chkopts
	-${CLINKER} -o test12 test12.o ${SLEPC_SYS_LIB}
	${RM} test12.o

#------------------------------------------------------------------------------------

TESTCODE = \
	[ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \
	${DIFF} output/$${test}.out $${test}.tmp || \
	echo "Possible problem with $${test}, diffs above"; \
	${RM} -f $${test}.tmp

runtest1_1:
	-@test=test1_1; \
	${MPIEXEC} -n 1 ./test1 -bv_type vecs -verbose 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest1_2:
	-@test=test1_2; \
	${MPIEXEC} -n 1 ./test1 -bv_type contiguous -verbose 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest1_3:
	-@test=test1_3; \
	${MPIEXEC} -n 1 ./test1 -bv_type svec -verbose 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest1_4:
	-@test=test1_4; \
	${MPIEXEC} -n 1 ./test1 -bv_type mat -verbose 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_1:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type vecs -bv_orthog_type cgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_2:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type contiguous -bv_orthog_type cgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_3:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type svec -bv_orthog_type cgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_4:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type mat -bv_orthog_type cgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_5:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type vecs -bv_orthog_type mgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_6:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type contiguous -bv_orthog_type mgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_7:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type svec -bv_orthog_type mgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_8:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -bv_type mat -bv_orthog_type mgs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3_1:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3_2:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3_3:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3_4:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_1:
	-@test=test4_1; \
	${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_2:
	-@test=test4_1; \
	${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_3:
	-@test=test4_1; \
	${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type svec -trans 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_4:
	-@test=test4_1; \
	${MPIEXEC} -n 1 ./test4 -n 18 -kx 12 -ky 8 -bv_type mat -trans 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest5_1:
	-@test=test5_1; \
	${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest5_2:
	-@test=test5_1; \
	${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest5_3:
	-@test=test5_1; \
	${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest5_4:
	-@test=test5_1; \
	${MPIEXEC} -n 1 ./test5 -bv_orthog_refine always -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest6_1:
	-@test=test6_1; \
	${MPIEXEC} -n 1 ./test6 -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest6_2:
	-@test=test6_1; \
	${MPIEXEC} -n 1 ./test6 -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest6_3:
	-@test=test6_1; \
	${MPIEXEC} -n 1 ./test6 -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest6_4:
	-@test=test6_1; \
	${MPIEXEC} -n 1 ./test6 -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest7_1:
	-@test=test7_1; \
	${MPIEXEC} -n 1 ./test7 -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest7_2:
	-@test=test7_1; \
	${MPIEXEC} -n 1 ./test7 -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest7_3:
	-@test=test7_1; \
	${MPIEXEC} -n 1 ./test7 -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest7_4:
	-@test=test7_1; \
	${MPIEXEC} -n 1 ./test7 -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest8_1:
	-@test=test8_1; \
	${MPIEXEC} -n 1 ./test8 -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest8_2:
	-@test=test8_1; \
	${MPIEXEC} -n 1 ./test8 -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest8_3:
	-@test=test8_1; \
	${MPIEXEC} -n 1 ./test8 -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest8_4:
	-@test=test8_1; \
	${MPIEXEC} -n 1 ./test8 -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest9_1:
	-@test=test9_1; \
	${MPIEXEC} -n 1 ./test9 -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest9_2:
	-@test=test9_1; \
	${MPIEXEC} -n 1 ./test9 -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest9_3:
	-@test=test9_1; \
	${MPIEXEC} -n 1 ./test9 -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest9_4:
	-@test=test9_1; \
	${MPIEXEC} -n 1 ./test9 -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest10_1:
	-@test=test10_1; \
	${MPIEXEC} -n 2 ./test10 -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest10_2:
	-@test=test10_1; \
	${MPIEXEC} -n 2 ./test10 -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest10_3:
	-@test=test10_1; \
	${MPIEXEC} -n 2 ./test10 -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest10_4:
	-@test=test10_1; \
	${MPIEXEC} -n 2 ./test10 -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_1:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_2:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_3:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_4:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block gs -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_5:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type vecs 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_6:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type contiguous 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_7:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type svec 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest11_8:
	-@test=test11_1; \
	${MPIEXEC} -n 2 ./test11 -bv_orthog_block chol -bv_type mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest12_1:
	-@test=test12_1; \
	${MPIEXEC} -n 1 ./test12 -bv_orthog_block gs mat 2>&1 > $${test}.tmp; \
	${TESTCODE}

#runtest12_2:
#	-@test=test12_1; \
#	${MPIEXEC} -n 1 ./test12 -bv_orthog_block chol mat 2>&1 > $${test}.tmp; \
#	${TESTCODE}

slepc-3.7.4/src/sys/classes/bv/examples/tests/test1.c0000644000175000017500000001412313107004621022021 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV operations.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Vec t,v; Mat Q,M; BV X,Y; PetscInt i,j,n=10,k=5,l=3; PetscScalar *q,*z; PetscReal nrm; PetscViewer view; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV with %D columns of dimension %D.\n",k,n);CHKERRQ(ierr); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,k);CHKERRQ(ierr); ierr = BVSetFromOptions(X);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);CHKERRQ(ierr); if (!verbose) { ierr = PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = BVView(X,view);CHKERRQ(ierr); ierr = PetscViewerPopFormat(view);CHKERRQ(ierr); } /* Fill X entries */ for (j=0;j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV operations with non-standard inner product.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Vec t,v; Mat B,M; BV X; PetscInt i,j,n=10,k=5,Istart,Iend; PetscScalar alpha; PetscReal nrm; PetscViewer view; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV with non-standard inner product (n=%D, k=%D).\n",n,k);CHKERRQ(ierr); /* Create inner product matrix */ ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)B,"B");CHKERRQ(ierr); ierr = MatGetOwnershipRange(B,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(B,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: test11.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV block orthogonalization.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 30:   PetscErrorCode    ierr;
 31:   BV                X,Y,Z,cached;
 32:   Mat               B,M;
 33:   Vec               v,t;
 34:   PetscInt          i,j,n=20,l=2,k=8,Istart,Iend;
 35:   PetscViewer       view;
 36:   PetscBool         verbose;
 37:   PetscReal         norm;
 38:   PetscScalar       alpha;
 39:   BVOrthogBlockType btype;

 41:   SlepcInitialize(&argc,&argv,(char*)0,help);
 42:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);
 44:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 45:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 46:   PetscPrintf(PETSC_COMM_WORLD,"Test BV block orthogonalization (length %D, l=%D, k=%D).\n",n,l,k);

 48:   /* Create template vector */
 49:   VecCreate(PETSC_COMM_WORLD,&t);
 50:   VecSetSizes(t,PETSC_DECIDE,n);
 51:   VecSetFromOptions(t);

 53:   /* Create BV object X */
 54:   BVCreate(PETSC_COMM_WORLD,&X);
 55:   PetscObjectSetName((PetscObject)X,"X");
 56:   BVSetSizesFromVec(X,t,k);
 57:   BVSetFromOptions(X);
 58:   BVGetOrthogonalization(X,NULL,NULL,NULL,&btype);

 60:   /* Set up viewer */
 61:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 62:   if (verbose) {
 63:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 64:   }

 66:   /* Fill X entries */
 67:   for (j=0;j<k;j++) {
 68:     BVGetColumn(X,j,&v);
 69:     VecSet(v,0.0);
 70:     for (i=0;i<=n/2;i++) {
 71:       if (i+j<n) {
 72:         alpha = (3.0*i+j-2)/(2*(i+j+1));
 73:         VecSetValue(v,i+j,alpha,INSERT_VALUES);
 74:       }
 75:     }
 76:     VecAssemblyBegin(v);
 77:     VecAssemblyEnd(v);
 78:     BVRestoreColumn(X,j,&v);
 79:   }
 80:   if (btype==BV_ORTHOG_BLOCK_GS) {  /* GS requires the leading columns to be orthogonal */
 81:     for (j=0;j<l;j++) {
 82:       BVOrthogonalizeColumn(X,j,NULL,&norm,NULL);
 83:       alpha = 1.0/norm;
 84:       BVScaleColumn(X,j,alpha);
 85:     }
 86:   }
 87:   if (verbose) {
 88:     BVView(X,view);
 89:   }

 91:   /* Create copy on Y */
 92:   BVDuplicate(X,&Y);
 93:   PetscObjectSetName((PetscObject)Y,"Y");
 94:   BVCopy(X,Y);
 95:   BVSetActiveColumns(Y,l,k);
 96:   BVSetActiveColumns(X,l,k);

 98:   /* Test BVOrthogonalize */
 99:   BVOrthogonalize(Y,NULL);
100:   if (verbose) {
101:     BVView(Y,view);
102:   }

104:   /* Check orthogonality */
105:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&M);
106:   MatShift(M,1.0);   /* set leading part to identity */
107:   BVDot(Y,Y,M);
108:   MatShift(M,-1.0);
109:   MatNorm(M,NORM_1,&norm);
110:   if (norm<100*PETSC_MACHINE_EPSILON) {
111:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
112:   } else {
113:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)norm);
114:   }

116:   /* Create inner product matrix */
117:   MatCreate(PETSC_COMM_WORLD,&B);
118:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
119:   MatSetFromOptions(B);
120:   MatSetUp(B);
121:   PetscObjectSetName((PetscObject)B,"B");

123:   MatGetOwnershipRange(B,&Istart,&Iend);
124:   for (i=Istart;i<Iend;i++) {
125:     if (i>0) { MatSetValue(B,i,i-1,-1.0,INSERT_VALUES); }
126:     if (i<n-1) { MatSetValue(B,i,i+1,-1.0,INSERT_VALUES); }
127:     MatSetValue(B,i,i,2.0,INSERT_VALUES);
128:   }
129:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
130:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);

132:   /* Prepare to repeat test, now with a non-standard inner product */
133:   BVCopy(X,Y);
134:   BVDuplicate(X,&Z);
135:   PetscObjectSetName((PetscObject)Z,"Z");
136:   BVSetActiveColumns(Z,l,k);
137:   BVSetMatrix(X,B,PETSC_FALSE);
138:   BVSetMatrix(Y,B,PETSC_FALSE);
139:   if (btype==BV_ORTHOG_BLOCK_GS) {  /* GS requires the leading columns to be orthogonal */
140:     for (j=0;j<l;j++) {
141:       BVOrthogonalizeColumn(Y,j,NULL,&norm,NULL);
142:       alpha = 1.0/norm;
143:       BVScaleColumn(Y,j,alpha);
144:     }
145:   }
146:   if (verbose) {
147:     BVView(X,view);
148:   }

150:   /* Test BVOrthogonalize */
151:   BVOrthogonalize(Y,NULL);
152:   if (verbose) {
153:     BVView(Y,view);
154:   }

156:   /* Extract cached BV and check it is equal to B*X */
157:   BVGetCachedBV(Y,&cached);
158:   BVMatMult(X,B,Z);
159:   BVMult(Z,-1.0,1.0,cached,NULL);
160:   BVNorm(Z,NORM_FROBENIUS,&norm);
161:   if (norm<100*PETSC_MACHINE_EPSILON) {
162:     PetscPrintf(PETSC_COMM_WORLD,"Residual ||cached-BX|| < 100*eps\n");
163:   } else {
164:     PetscPrintf(PETSC_COMM_WORLD,"Residual ||cached-BX||: %g\n",(double)norm);
165:   }

167:   /* Check orthogonality */
168:   MatZeroEntries(M);
169:   MatShift(M,1.0);   /* set leading part to identity */
170:   BVDot(Y,Y,M);
171:   MatShift(M,-1.0);
172:   MatNorm(M,NORM_1,&norm);
173:   if (norm<100*PETSC_MACHINE_EPSILON) {
174:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
175:   } else {
176:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)norm);
177:   }

179:   MatDestroy(&M);
180:   MatDestroy(&B);
181:   BVDestroy(&X);
182:   BVDestroy(&Y);
183:   BVDestroy(&Z);
184:   VecDestroy(&t);
185:   SlepcFinalize();
186:   return ierr;
187: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test6.c.html0000644000175000017500000002323013107004621022770 0ustar jromanjroman
Actual source code: test6.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV orthogonalization functions with constraints.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   BV             X;
 32:   Mat            M;
 33:   Vec            v,t,*C;
 34:   PetscInt       i,j,n=20,k=8,nc=2;
 35:   PetscViewer    view;
 36:   PetscBool      verbose;
 37:   PetscReal      norm;
 38:   PetscScalar    alpha;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-nc",&nc,NULL);
 44:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 45:   PetscPrintf(PETSC_COMM_WORLD,"Test BV orthogonalization with %D columns + %D constraints, of length %D.\n",k,nc,n);

 47:   /* Create template vector */
 48:   VecCreate(PETSC_COMM_WORLD,&t);
 49:   VecSetSizes(t,PETSC_DECIDE,n);
 50:   VecSetFromOptions(t);

 52:   /* Create BV object X */
 53:   BVCreate(PETSC_COMM_WORLD,&X);
 54:   PetscObjectSetName((PetscObject)X,"X");
 55:   BVSetSizesFromVec(X,t,k);
 56:   BVSetFromOptions(X);

 58:   /* Generate constraints and attach them to X */
 59:   if (nc>0) {
 60:     VecDuplicateVecs(t,nc,&C);
 61:     for (j=0;j<nc;j++) {
 62:       for (i=0;i<=j;i++) {
 63:         VecSetValue(C[j],i,1.0,INSERT_VALUES);
 64:       }
 65:       VecAssemblyBegin(C[j]);
 66:       VecAssemblyEnd(C[j]);
 67:     }
 68:     BVInsertConstraints(X,&nc,C);
 69:     VecDestroyVecs(nc,&C);
 70:   }

 72:   /* Set up viewer */
 73:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 74:   if (verbose) {
 75:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 76:   }

 78:   /* Fill X entries */
 79:   for (j=0;j<k;j++) {
 80:     BVGetColumn(X,j,&v);
 81:     VecSet(v,0.0);
 82:     for (i=0;i<=n/2;i++) {
 83:       if (i+j<n) {
 84:         alpha = (3.0*i+j-2)/(2*(i+j+1));
 85:         VecSetValue(v,i+j,alpha,INSERT_VALUES);
 86:       }
 87:     }
 88:     VecAssemblyBegin(v);
 89:     VecAssemblyEnd(v);
 90:     BVRestoreColumn(X,j,&v);
 91:   }
 92:   if (verbose) {
 93:     BVView(X,view);
 94:   }

 96:   /* Test BVOrthogonalizeColumn */
 97:   for (j=0;j<k;j++) {
 98:     BVOrthogonalizeColumn(X,j,NULL,&norm,NULL);
 99:     alpha = 1.0/norm;
100:     BVScaleColumn(X,j,alpha);
101:   }
102:   if (verbose) {
103:     BVView(X,view);
104:   }

106:   /* Check orthogonality */
107:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&M);
108:   BVDot(X,X,M);
109:   MatShift(M,-1.0);
110:   MatNorm(M,NORM_1,&norm);
111:   if (norm<100*PETSC_MACHINE_EPSILON) {
112:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
113:   } else {
114:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)norm);
115:   }

117:   MatDestroy(&M);
118:   BVDestroy(&X);
119:   VecDestroy(&t);
120:   SlepcFinalize();
121:   return ierr;
122: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test2.c.html0000644000175000017500000003111413107004621022764 0ustar jromanjroman
Actual source code: test2.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV orthogonalization functions.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   BV             X,Y,Z;
 32:   Mat            M,R;
 33:   Vec            v,t,e;
 34:   PetscInt       i,j,n=20,k=8;
 35:   PetscViewer    view;
 36:   PetscBool      verbose;
 37:   PetscReal      norm;
 38:   PetscScalar    alpha;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 43:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 44:   PetscPrintf(PETSC_COMM_WORLD,"Test BV orthogonalization with %D columns of length %D.\n",k,n);

 46:   /* Create template vector */
 47:   VecCreate(PETSC_COMM_WORLD,&t);
 48:   VecSetSizes(t,PETSC_DECIDE,n);
 49:   VecSetFromOptions(t);

 51:   /* Create BV object X */
 52:   BVCreate(PETSC_COMM_WORLD,&X);
 53:   PetscObjectSetName((PetscObject)X,"X");
 54:   BVSetSizesFromVec(X,t,k);
 55:   BVSetFromOptions(X);

 57:   /* Set up viewer */
 58:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 59:   if (verbose) {
 60:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 61:   }

 63:   /* Fill X entries */
 64:   for (j=0;j<k;j++) {
 65:     BVGetColumn(X,j,&v);
 66:     VecSet(v,0.0);
 67:     for (i=0;i<=n/2;i++) {
 68:       if (i+j<n) {
 69:         alpha = (3.0*i+j-2)/(2*(i+j+1));
 70:         VecSetValue(v,i+j,alpha,INSERT_VALUES);
 71:       }
 72:     }
 73:     VecAssemblyBegin(v);
 74:     VecAssemblyEnd(v);
 75:     BVRestoreColumn(X,j,&v);
 76:   }
 77:   if (verbose) {
 78:     BVView(X,view);
 79:   }

 81:   /* Create copies on Y and Z */
 82:   BVDuplicate(X,&Y);
 83:   PetscObjectSetName((PetscObject)Y,"Y");
 84:   BVCopy(X,Y);
 85:   BVDuplicate(X,&Z);
 86:   PetscObjectSetName((PetscObject)Z,"Z");
 87:   BVCopy(X,Z);

 89:   /* Test BVOrthogonalizeColumn */
 90:   for (j=0;j<k;j++) {
 91:     BVOrthogonalizeColumn(X,j,NULL,&norm,NULL);
 92:     alpha = 1.0/norm;
 93:     BVScaleColumn(X,j,alpha);
 94:   }
 95:   if (verbose) {
 96:     BVView(X,view);
 97:   }

 99:   /* Check orthogonality */
100:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&M);
101:   BVDot(X,X,M);
102:   MatShift(M,-1.0);
103:   MatNorm(M,NORM_1,&norm);
104:   if (norm<100*PETSC_MACHINE_EPSILON) {
105:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
106:   } else {
107:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)norm);
108:   }

110:   /* Test BVOrthogonalize */
111:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&R);
112:   PetscObjectSetName((PetscObject)R,"R");
113:   BVOrthogonalize(Y,R);
114:   if (verbose) {
115:     BVView(Y,view);
116:     MatView(R,view);
117:   }

119:   /* Check orthogonality */
120:   BVDot(Y,Y,M);
121:   MatShift(M,-1.0);
122:   MatNorm(M,NORM_1,&norm);
123:   if (norm<100*PETSC_MACHINE_EPSILON) {
124:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
125:   } else {
126:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)norm);
127:   }

129:   /* Check residual */
130:   BVMult(Z,-1.0,1.0,Y,R);
131:   BVNorm(Z,NORM_FROBENIUS,&norm);
132:   if (norm<100*PETSC_MACHINE_EPSILON) {
133:     PetscPrintf(PETSC_COMM_WORLD,"Residual ||X-QR|| < 100*eps\n");
134:   } else {
135:     PetscPrintf(PETSC_COMM_WORLD,"Residual ||X-QR||: %g\n",(double)norm);
136:   }

138:   /* Test BVOrthogonalizeVec */
139:   VecDuplicate(t,&e);
140:   VecSet(e,1.0);
141:   BVOrthogonalizeVec(X,e,NULL,&norm,NULL);
142:   PetscPrintf(PETSC_COMM_WORLD,"Norm of ones(n,1) after orthogonalizing against X: %g\n",(double)norm);

144:   MatDestroy(&M);
145:   MatDestroy(&R);
146:   BVDestroy(&X);
147:   BVDestroy(&Y);
148:   BVDestroy(&Z);
149:   VecDestroy(&e);
150:   VecDestroy(&t);
151:   SlepcFinalize();
152:   return ierr;
153: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test7.c0000644000175000017500000001351613107004621022034 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test multiplication of a Mat times a BV.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Vec t,v; Mat B; BV X,Y,Z,Zcopy; PetscInt i,j,n=10,k=5,Istart,Iend; PetscScalar *pZ; PetscReal norm; PetscViewer view; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BVMatMult (n=%D, k=%D).\n",n,k);CHKERRQ(ierr); /* Create Laplacian matrix */ ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)B,"B");CHKERRQ(ierr); ierr = MatGetOwnershipRange(B,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(B,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i=Istart && j=Istart && jActual source code: test5.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV operations with indefinite inner product.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   Vec            t,v;
 32:   Mat            B,M;
 33:   Vec            omega;
 34:   BV             X,Y;
 35:   PetscInt       i,j,n=10,k=5,Istart,Iend;
 36:   PetscScalar    alpha;
 37:   PetscReal      nrm;
 38:   PetscViewer    view;
 39:   PetscBool      verbose;

 41:   SlepcInitialize(&argc,&argv,(char*)0,help);
 42:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 43:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 44:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 45:   PetscPrintf(PETSC_COMM_WORLD,"Test BV with indefinite inner product (n=%D, k=%D).\n",n,k);

 47:   /* Create inner product matrix (standard involutionary permutation) */
 48:   MatCreate(PETSC_COMM_WORLD,&B);
 49:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
 50:   MatSetFromOptions(B);
 51:   MatSetUp(B);
 52:   PetscObjectSetName((PetscObject)B,"B");

 54:   MatGetOwnershipRange(B,&Istart,&Iend);
 55:   for (i=Istart;i<Iend;i++) {
 56:     MatSetValue(B,i,n-i-1,1.0,INSERT_VALUES);
 57:   }
 58:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 59:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
 60:   MatCreateVecs(B,&t,NULL);

 62:   /* Create BV object X */
 63:   BVCreate(PETSC_COMM_WORLD,&X);
 64:   PetscObjectSetName((PetscObject)X,"X");
 65:   BVSetSizesFromVec(X,t,k);
 66:   BVSetFromOptions(X);
 67:   BVSetMatrix(X,B,PETSC_TRUE);

 69:   /* Set up viewer */
 70:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 71:   if (verbose) {
 72:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 73:   }

 75:   /* Fill X entries */
 76:   for (j=0;j<k;j++) {
 77:     BVGetColumn(X,j,&v);
 78:     VecSet(v,-1.0);
 79:     for (i=0;i<4;i++) {
 80:       if (i+j<n) {
 81:         VecSetValue(v,i+j,(PetscScalar)(3*i+j-2),INSERT_VALUES);
 82:       }
 83:     }
 84:     VecAssemblyBegin(v);
 85:     VecAssemblyEnd(v);
 86:     BVRestoreColumn(X,j,&v);
 87:   }
 88:   if (verbose) {
 89:     MatView(B,view);
 90:     BVView(X,view);
 91:   }

 93:   /* Test BVNormColumn */
 94:   BVNormColumn(X,0,NORM_2,&nrm);
 95:   PetscPrintf(PETSC_COMM_WORLD,"B-Norm or X[0] = %g\n",(double)nrm);

 97:   /* Test BVOrthogonalizeColumn */
 98:   for (j=0;j<k;j++) {
 99:     BVOrthogonalizeColumn(X,j,NULL,&nrm,NULL);
100:     alpha = 1.0/nrm;
101:     BVScaleColumn(X,j,alpha);
102:   }
103:   if (verbose) {
104:     BVView(X,view);
105:   }

107:   /* Create a copy on Y */
108:   BVDuplicate(X,&Y);
109:   PetscObjectSetName((PetscObject)Y,"Y");
110:   BVCopy(X,Y);

112:   /* Check orthogonality */
113:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&M);
114:   BVDot(Y,Y,M);
115:   VecCreateSeq(PETSC_COMM_SELF,k,&omega);
116:   BVGetSignature(Y,omega);
117:   VecScale(omega,-1.0);
118:   MatDiagonalSet(M,omega,ADD_VALUES);
119:   VecDestroy(&omega);
120:   MatNorm(M,NORM_1,&nrm);
121:   if (nrm<100*PETSC_MACHINE_EPSILON) {
122:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
123:   } else {
124:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)nrm);
125:   }

127:   BVDestroy(&X);
128:   BVDestroy(&Y);
129:   MatDestroy(&M);
130:   MatDestroy(&B);
131:   VecDestroy(&t);
132:   SlepcFinalize();
133:   return ierr;
134: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/index.html0000644000175000017500000000370513107004621022616 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

test1.c: Test BV operations
test2.c: Test BV orthogonalization functions
test3.c: Test BV operations with non-standard inner product
test4.c: Test BV operations, changing the number of active columns
test5.c: Test BV operations with indefinite inner product
test6.c: Test BV orthogonalization functions with constraints
test7.c: Test multiplication of a Mat times a BV
test8.c: Test BV orthogonalization with selected columns
test9.c: Test BV matrix projection
test10.c: Test split reductions in BV
test11.c: Test BV block orthogonalization
test12.c: Test block orthogonalization on a rank-deficient BV
makefile
slepc-3.7.4/src/sys/classes/bv/examples/tests/test8.c0000644000175000017500000001023013107004621022023 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV orthogonalization with selected columns.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; BV X; Vec v,t,z; PetscInt i,j,n=20,k=8; PetscViewer view; PetscBool verbose,*which; PetscReal norm; PetscScalar alpha,*pz; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV orthogonalization with selected columns of length %D.\n",n);CHKERRQ(ierr); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,k);CHKERRQ(ierr); ierr = BVSetOrthogonalization(X,BV_ORTHOG_MGS,BV_ORTHOG_REFINE_IFNEEDED,PETSC_DEFAULT,BV_ORTHOG_BLOCK_GS);CHKERRQ(ierr); ierr = BVSetFromOptions(X);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill X entries */ for (j=0;j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test block orthogonalization on a rank-deficient BV.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; BV X,Z; Mat M,R; Vec v,w,t; PetscInt i,j,n=20,k=8; PetscViewer view; PetscBool verbose; PetscReal norm; PetscScalar alpha; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV block orthogonalization (length %D, k=%D).\n",n,k);CHKERRQ(ierr); if (k<6) SETERRQ(PETSC_COMM_SELF,1,"k must be at least 6"); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,k);CHKERRQ(ierr); ierr = BVSetFromOptions(X);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill X entries (first half) */ for (j=0;jActual source code: test7.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test multiplication of a Mat times a BV.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   Vec            t,v;
 32:   Mat            B;
 33:   BV             X,Y,Z,Zcopy;
 34:   PetscInt       i,j,n=10,k=5,Istart,Iend;
 35:   PetscScalar    *pZ;
 36:   PetscReal      norm;
 37:   PetscViewer    view;
 38:   PetscBool      verbose;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 43:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 44:   PetscPrintf(PETSC_COMM_WORLD,"Test BVMatMult (n=%D, k=%D).\n",n,k);

 46:   /* Create Laplacian matrix */
 47:   MatCreate(PETSC_COMM_WORLD,&B);
 48:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
 49:   MatSetFromOptions(B);
 50:   MatSetUp(B);
 51:   PetscObjectSetName((PetscObject)B,"B");

 53:   MatGetOwnershipRange(B,&Istart,&Iend);
 54:   for (i=Istart;i<Iend;i++) {
 55:     if (i>0) { MatSetValue(B,i,i-1,-1.0,INSERT_VALUES); }
 56:     if (i<n-1) { MatSetValue(B,i,i+1,-1.0,INSERT_VALUES); }
 57:     MatSetValue(B,i,i,2.0,INSERT_VALUES);
 58:   }
 59:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 60:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
 61:   MatCreateVecs(B,&t,NULL);

 63:   /* Create BV object X */
 64:   BVCreate(PETSC_COMM_WORLD,&X);
 65:   PetscObjectSetName((PetscObject)X,"X");
 66:   BVSetSizesFromVec(X,t,k);
 67:   BVSetFromOptions(X);

 69:   /* Set up viewer */
 70:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 71:   if (verbose) {
 72:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 73:   }

 75:   /* Fill X entries */
 76:   for (j=0;j<k;j++) {
 77:     BVGetColumn(X,j,&v);
 78:     VecSet(v,0.0);
 79:     for (i=Istart;i<PetscMin(j+1,Iend);i++) {
 80:       VecSetValue(v,i,1.0,INSERT_VALUES);
 81:     }
 82:     VecAssemblyBegin(v);
 83:     VecAssemblyEnd(v);
 84:     BVRestoreColumn(X,j,&v);
 85:   }
 86:   if (verbose) {
 87:     MatView(B,view);
 88:     BVView(X,view);
 89:   }

 91:   /* Create BV object Y */
 92:   BVDuplicateResize(X,k+4,&Y);
 93:   PetscObjectSetName((PetscObject)Y,"Y");
 94:   BVSetActiveColumns(Y,2,k+2);

 96:   /* Test BVMatMult */
 97:   BVMatMult(X,B,Y);
 98:   if (verbose) {
 99:     BVView(Y,view);
100:   }

102:   /* Create BV object Z */
103:   BVDuplicate(X,&Z);
104:   PetscObjectSetName((PetscObject)Z,"Z");

106:   /* Fill Z entries */
107:   for (j=0;j<k;j++) {
108:     BVGetColumn(Z,j,&v);
109:     VecSet(v,0.0);
110:     if (!Istart) { VecSetValue(v,0,1.0,ADD_VALUES); }
111:     if (j<n && j>=Istart && j<Iend) { VecSetValue(v,j,1.0,ADD_VALUES); }
112:     if (j+1<n && j>=Istart && j<Iend) { VecSetValue(v,j+1,-1.0,ADD_VALUES); }
113:     VecAssemblyBegin(v);
114:     VecAssemblyEnd(v);
115:     BVRestoreColumn(Z,j,&v);
116:   }
117:   if (verbose) {
118:     BVView(Z,view);
119:   }

121:   /* Save a copy of Z */
122:   BVDuplicate(Z,&Zcopy);
123:   BVCopy(Z,Zcopy);

125:   /* Test BVMult, check result of previous operations */
126:   BVMult(Z,-1.0,1.0,Y,NULL);
127:   BVNorm(Z,NORM_FROBENIUS,&norm);
128:   PetscPrintf(PETSC_COMM_WORLD,"Norm of error: %g\n",(double)norm);

130:   /* Test BVMatMultColumn, multiply Y(:,2), result in Y(:,3) */
131:   BVMatMultColumn(Y,B,2);
132:   if (verbose) {
133:     BVView(Y,view);
134:   }

136:   /* Test BVGetArray, modify Z to match Y */
137:   BVCopy(Zcopy,Z);
138:   BVGetArray(Z,&pZ);
139:   if (Istart==0) {
140:     if (Iend<3) SETERRQ(PETSC_COMM_SELF,1,"First process must have at least 3 rows");
141:     pZ[Iend]   = 5.0;   /* modify 3 first entries of second column */
142:     pZ[Iend+1] = -4.0;
143:     pZ[Iend+2] = 1.0;
144:   }
145:   BVRestoreArray(Z,&pZ);
146:   if (verbose) {
147:     BVView(Z,view);
148:   }

150:   /* Check result again with BVMult */
151:   BVMult(Z,-1.0,1.0,Y,NULL);
152:   BVNorm(Z,NORM_FROBENIUS,&norm);
153:   PetscPrintf(PETSC_COMM_WORLD,"Norm of error: %g\n",(double)norm);

155:   BVDestroy(&X);
156:   BVDestroy(&Y);
157:   BVDestroy(&Z);
158:   BVDestroy(&Zcopy);
159:   MatDestroy(&B);
160:   VecDestroy(&t);
161:   SlepcFinalize();
162:   return ierr;
163: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test5.c0000644000175000017500000001151513107004621022027 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV operations with indefinite inner product.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Vec t,v; Mat B,M; Vec omega; BV X,Y; PetscInt i,j,n=10,k=5,Istart,Iend; PetscScalar alpha; PetscReal nrm; PetscViewer view; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV with indefinite inner product (n=%D, k=%D).\n",n,k);CHKERRQ(ierr); /* Create inner product matrix (standard involutionary permutation) */ ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)B,"B");CHKERRQ(ierr); ierr = MatGetOwnershipRange(B,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV matrix projection.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Vec t,v; Mat B,G,H0,H1; BV X,Y,Z; PetscInt i,j,n=20,kx=6,lx=3,ky=5,ly=2,Istart,Iend,col[5]; PetscScalar alpha,value[] = { -1, 1, 1, 1, 1 }; PetscViewer view; PetscReal norm; PetscBool verbose; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-kx",&kx,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-lx",&lx,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-ky",&ky,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-ly",&ly,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV projection (n=%D).\n",n);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"X has %D active columns (%D leading columns).\n",kx,lx);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Y has %D active columns (%D leading columns).\n",ky,ly);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Create non-symmetric matrix G (Toeplitz) */ ierr = MatCreate(PETSC_COMM_WORLD,&G);CHKERRQ(ierr); ierr = MatSetSizes(G,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(G);CHKERRQ(ierr); ierr = MatSetUp(G);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)G,"G");CHKERRQ(ierr); ierr = MatGetOwnershipRange(G,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(B,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV block orthogonalization.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; BV X,Y,Z,cached; Mat B,M; Vec v,t; PetscInt i,j,n=20,l=2,k=8,Istart,Iend; PetscViewer view; PetscBool verbose; PetscReal norm; PetscScalar alpha; BVOrthogBlockType btype; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-l",&l,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV block orthogonalization (length %D, l=%D, k=%D).\n",n,l,k);CHKERRQ(ierr); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,k);CHKERRQ(ierr); ierr = BVSetFromOptions(X);CHKERRQ(ierr); ierr = BVGetOrthogonalization(X,NULL,NULL,NULL,&btype);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill X entries */ for (j=0;j0) { ierr = MatSetValue(B,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: test8.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV orthogonalization with selected columns.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   BV             X;
 32:   Vec            v,t,z;
 33:   PetscInt       i,j,n=20,k=8;
 34:   PetscViewer    view;
 35:   PetscBool      verbose,*which;
 36:   PetscReal      norm;
 37:   PetscScalar    alpha,*pz;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 42:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 43:   PetscPrintf(PETSC_COMM_WORLD,"Test BV orthogonalization with selected columns of length %D.\n",n);

 45:   /* Create template vector */
 46:   VecCreate(PETSC_COMM_WORLD,&t);
 47:   VecSetSizes(t,PETSC_DECIDE,n);
 48:   VecSetFromOptions(t);

 50:   /* Create BV object X */
 51:   BVCreate(PETSC_COMM_WORLD,&X);
 52:   PetscObjectSetName((PetscObject)X,"X");
 53:   BVSetSizesFromVec(X,t,k);
 54:   BVSetOrthogonalization(X,BV_ORTHOG_MGS,BV_ORTHOG_REFINE_IFNEEDED,PETSC_DEFAULT,BV_ORTHOG_BLOCK_GS);
 55:   BVSetFromOptions(X);

 57:   /* Set up viewer */
 58:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 59:   if (verbose) {
 60:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 61:   }

 63:   /* Fill X entries */
 64:   for (j=0;j<k;j++) {
 65:     BVGetColumn(X,j,&v);
 66:     VecSet(v,0.0);
 67:     for (i=0;i<=n/2;i++) {
 68:       if (i+j<n) {
 69:         alpha = (3.0*i+j-2)/(2*(i+j+1));
 70:         VecSetValue(v,i+j,alpha,INSERT_VALUES);
 71:       }
 72:     }
 73:     VecAssemblyBegin(v);
 74:     VecAssemblyEnd(v);
 75:     BVRestoreColumn(X,j,&v);
 76:   }
 77:   if (verbose) {
 78:     BVView(X,view);
 79:   }

 81:   /* Orthonormalize first k-1 columns */
 82:   for (j=0;j<k-1;j++) {
 83:     BVOrthogonalizeColumn(X,j,NULL,&norm,NULL);
 84:     alpha = 1.0/norm;
 85:     BVScaleColumn(X,j,alpha);
 86:   }
 87:   if (verbose) {
 88:     BVView(X,view);
 89:   }

 91:   /* Select odd columns and orthogonalize last column against those only */
 92:   PetscMalloc1(k,&which);
 93:   for (i=0;i<k;i++) which[i] = (i%2)? PETSC_TRUE: PETSC_FALSE;
 94:   BVOrthogonalizeSomeColumn(X,k-1,which,NULL,NULL,NULL);
 95:   PetscFree(which);
 96:   if (verbose) {
 97:     BVView(X,view);
 98:   }

100:   /* Check orthogonality */
101:   PetscPrintf(PETSC_COMM_WORLD,"Orthogonalization coefficients:\n");
102:   VecCreateSeq(PETSC_COMM_SELF,k-1,&z);
103:   PetscObjectSetName((PetscObject)z,"z");
104:   VecGetArray(z,&pz);
105:   BVDotColumn(X,k-1,pz);
106:   for (i=0;i<k-1;i++) {
107:     if (PetscAbsScalar(pz[i])<PETSC_MACHINE_EPSILON) pz[i]=0.0;
108:   }
109:   VecRestoreArray(z,&pz);
110:   VecView(z,view);
111:   VecDestroy(&z);

113:   BVDestroy(&X);
114:   VecDestroy(&t);
115:   SlepcFinalize();
116:   return ierr;
117: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test3.c.html0000644000175000017500000002410513107004621022767 0ustar jromanjroman
Actual source code: test3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test BV operations with non-standard inner product.\n\n";

 24: #include <slepcbv.h>

 28: int main(int argc,char **argv)
 29: {
 31:   Vec            t,v;
 32:   Mat            B,M;
 33:   BV             X;
 34:   PetscInt       i,j,n=10,k=5,Istart,Iend;
 35:   PetscScalar    alpha;
 36:   PetscReal      nrm;
 37:   PetscViewer    view;
 38:   PetscBool      verbose;

 40:   SlepcInitialize(&argc,&argv,(char*)0,help);
 41:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 42:   PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);
 43:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 44:   PetscPrintf(PETSC_COMM_WORLD,"Test BV with non-standard inner product (n=%D, k=%D).\n",n,k);

 46:   /* Create inner product matrix */
 47:   MatCreate(PETSC_COMM_WORLD,&B);
 48:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
 49:   MatSetFromOptions(B);
 50:   MatSetUp(B);
 51:   PetscObjectSetName((PetscObject)B,"B");

 53:   MatGetOwnershipRange(B,&Istart,&Iend);
 54:   for (i=Istart;i<Iend;i++) {
 55:     if (i>0) { MatSetValue(B,i,i-1,-1.0,INSERT_VALUES); }
 56:     if (i<n-1) { MatSetValue(B,i,i+1,-1.0,INSERT_VALUES); }
 57:     MatSetValue(B,i,i,2.0,INSERT_VALUES);
 58:   }
 59:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 60:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
 61:   MatCreateVecs(B,&t,NULL);

 63:   /* Create BV object X */
 64:   BVCreate(PETSC_COMM_WORLD,&X);
 65:   PetscObjectSetName((PetscObject)X,"X");
 66:   BVSetSizesFromVec(X,t,k);
 67:   BVSetFromOptions(X);
 68:   BVSetMatrix(X,B,PETSC_FALSE);

 70:   /* Set up viewer */
 71:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);
 72:   if (verbose) {
 73:     PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);
 74:   }

 76:   /* Fill X entries */
 77:   for (j=0;j<k;j++) {
 78:     BVGetColumn(X,j,&v);
 79:     VecSet(v,0.0);
 80:     for (i=0;i<4;i++) {
 81:       if (i+j<n) {
 82:         VecSetValue(v,i+j,(PetscScalar)(3*i+j-2),INSERT_VALUES);
 83:       }
 84:     }
 85:     VecAssemblyBegin(v);
 86:     VecAssemblyEnd(v);
 87:     BVRestoreColumn(X,j,&v);
 88:   }
 89:   if (verbose) {
 90:     MatView(B,view);
 91:     BVView(X,view);
 92:   }

 94:   /* Test BVNormColumn */
 95:   BVNormColumn(X,0,NORM_2,&nrm);
 96:   PetscPrintf(PETSC_COMM_WORLD,"B-Norm or X[0] = %g\n",(double)nrm);

 98:   /* Test BVOrthogonalizeColumn */
 99:   for (j=0;j<k;j++) {
100:     BVOrthogonalizeColumn(X,j,NULL,&nrm,NULL);
101:     alpha = 1.0/nrm;
102:     BVScaleColumn(X,j,alpha);
103:   }
104:   if (verbose) {
105:     BVView(X,view);
106:   }

108:   /* Check orthogonality */
109:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&M);
110:   BVDot(X,X,M);
111:   MatShift(M,-1.0);
112:   MatNorm(M,NORM_1,&nrm);
113:   if (nrm<100*PETSC_MACHINE_EPSILON) {
114:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality < 100*eps\n");
115:   } else {
116:     PetscPrintf(PETSC_COMM_WORLD,"Level of orthogonality: %g\n",(double)nrm);
117:   }

119:   BVDestroy(&X);
120:   MatDestroy(&M);
121:   MatDestroy(&B);
122:   VecDestroy(&t);
123:   SlepcFinalize();
124:   return ierr;
125: }
slepc-3.7.4/src/sys/classes/bv/examples/tests/test10.c0000644000175000017500000001137513107004621022107 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test split reductions in BV.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; Vec t,v,w,y,z,zsplit; BV X; PetscInt i,j,n=10,k=5; PetscScalar *zarray; PetscReal nrm; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); if (k<3) SETERRQ(PETSC_COMM_SELF,1,"Should specify at least k=3 columns"); ierr = PetscPrintf(PETSC_COMM_WORLD,"BV split ops (%D columns of dimension %D).\n",k,n);CHKERRQ(ierr); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); ierr = VecDuplicate(t,&v);CHKERRQ(ierr); ierr = VecSet(v,1.0);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,k);CHKERRQ(ierr); ierr = BVSetFromOptions(X);CHKERRQ(ierr); /* Fill X entries */ for (j=0;j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV orthogonalization functions.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; BV X,Y,Z; Mat M,R; Vec v,t,e; PetscInt i,j,n=20,k=8; PetscViewer view; PetscBool verbose; PetscReal norm; PetscScalar alpha; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV orthogonalization with %D columns of length %D.\n",k,n);CHKERRQ(ierr); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,k);CHKERRQ(ierr); ierr = BVSetFromOptions(X);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&view);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(view,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Fill X entries */ for (j=0;j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test BV orthogonalization functions with constraints.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; BV X; Mat M; Vec v,t,*C; PetscInt i,j,n=20,k=8,nc=2; PetscViewer view; PetscBool verbose; PetscReal norm; PetscScalar alpha; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-k",&k,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-nc",&nc,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Test BV orthogonalization with %D columns + %D constraints, of length %D.\n",k,nc,n);CHKERRQ(ierr); /* Create template vector */ ierr = VecCreate(PETSC_COMM_WORLD,&t);CHKERRQ(ierr); ierr = VecSetSizes(t,PETSC_DECIDE,n);CHKERRQ(ierr); ierr = VecSetFromOptions(t);CHKERRQ(ierr); /* Create BV object X */ ierr = BVCreate(PETSC_COMM_WORLD,&X);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)X,"X");CHKERRQ(ierr); ierr = BVSetSizesFromVec(X,t,k);CHKERRQ(ierr); ierr = BVSetFromOptions(X);CHKERRQ(ierr); /* Generate constraints and attach them to X */ if (nc>0) { ierr = VecDuplicateVecs(t,nc,&C);CHKERRQ(ierr); for (j=0;j
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../../../include/slepc/private/bvimpl.h ../../../../include/slepcbv.h
DIRS     = interface impls examples
LOCDIR   = src/sys/classes/bv/
MANSEC   = BV

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/bv/index.html0000644000175000017500000000240513107004621017632 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

interface/
impls/
examples/
../../../../include/slepc/private/bvimpl.h
../../../../include/slepcbv.h
makefile
slepc-3.7.4/src/sys/classes/bv/impls/0000755000175000017500000000000013107004621016760 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/impls/makefile0000644000175000017500000000211213107004621020454 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcsys DIRS = vecs contiguous svec mat LOCDIR = src/sys/classes/bv/impls/ MANSEC = BV include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/impls/mat/0000755000175000017500000000000013107004621017541 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/impls/mat/makefile0000644000175000017500000000216513107004621021245 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = bvmat.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = BV LOCDIR = src/sys/classes/bv/impls/svec/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/impls/mat/makefile.html0000644000175000017500000000470413107004621022211 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = bvmat.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = BV
LOCDIR   = src/sys/classes/bv/impls/svec/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/bv/impls/mat/bvmat.c.html0000644000175000017500000007562513107004621022000 0ustar jromanjroman
Actual source code: bvmat.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV implemented with a dense Mat

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>

 26: typedef struct {
 27:   Mat       A;
 28:   PetscBool mpi;
 29: } BV_MAT;

 33: PetscErrorCode BVMult_Mat(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)
 34: {
 36:   BV_MAT         *y = (BV_MAT*)Y->data,*x = (BV_MAT*)X->data;
 37:   PetscScalar    *px,*py,*q;
 38:   PetscInt       ldq;

 41:   MatDenseGetArray(x->A,&px);
 42:   MatDenseGetArray(y->A,&py);
 43:   if (Q) {
 44:     MatGetSize(Q,&ldq,NULL);
 45:     MatDenseGetArray(Q,&q);
 46:     BVMult_BLAS_Private(Y,Y->n,Y->k-Y->l,X->k-X->l,ldq,alpha,px+(X->nc+X->l)*X->n,q+Y->l*ldq+X->l,beta,py+(Y->nc+Y->l)*Y->n);
 47:     MatDenseRestoreArray(Q,&q);
 48:   } else {
 49:     BVAXPY_BLAS_Private(Y,Y->n,Y->k-Y->l,alpha,px+(X->nc+X->l)*X->n,beta,py+(Y->nc+Y->l)*Y->n);
 50:   }
 51:   MatDenseRestoreArray(x->A,&px);
 52:   MatDenseRestoreArray(y->A,&py);
 53:   return(0);
 54: }

 58: PetscErrorCode BVMultVec_Mat(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)
 59: {
 61:   BV_MAT         *x = (BV_MAT*)X->data;
 62:   PetscScalar    *px,*py;

 65:   MatDenseGetArray(x->A,&px);
 66:   VecGetArray(y,&py);
 67:   BVMultVec_BLAS_Private(X,X->n,X->k-X->l,alpha,px+(X->nc+X->l)*X->n,q,beta,py);
 68:   MatDenseRestoreArray(x->A,&px);
 69:   VecRestoreArray(y,&py);
 70:   return(0);
 71: }

 75: PetscErrorCode BVMultInPlace_Mat(BV V,Mat Q,PetscInt s,PetscInt e)
 76: {
 78:   BV_MAT         *ctx = (BV_MAT*)V->data;
 79:   PetscScalar    *pv,*q;
 80:   PetscInt       ldq;

 83:   MatGetSize(Q,&ldq,NULL);
 84:   MatDenseGetArray(ctx->A,&pv);
 85:   MatDenseGetArray(Q,&q);
 86:   BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_FALSE);
 87:   MatDenseRestoreArray(Q,&q);
 88:   MatDenseRestoreArray(ctx->A,&pv);
 89:   return(0);
 90: }

 94: PetscErrorCode BVMultInPlaceTranspose_Mat(BV V,Mat Q,PetscInt s,PetscInt e)
 95: {
 97:   BV_MAT         *ctx = (BV_MAT*)V->data;
 98:   PetscScalar    *pv,*q;
 99:   PetscInt       ldq;

102:   MatGetSize(Q,&ldq,NULL);
103:   MatDenseGetArray(ctx->A,&pv);
104:   MatDenseGetArray(Q,&q);
105:   BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_TRUE);
106:   MatDenseRestoreArray(Q,&q);
107:   MatDenseRestoreArray(ctx->A,&pv);
108:   return(0);
109: }

113: PetscErrorCode BVDot_Mat(BV X,BV Y,Mat M)
114: {
116:   BV_MAT         *x = (BV_MAT*)X->data,*y = (BV_MAT*)Y->data;
117:   PetscScalar    *px,*py,*m;
118:   PetscInt       ldm;

121:   MatGetSize(M,&ldm,NULL);
122:   MatDenseGetArray(x->A,&px);
123:   MatDenseGetArray(y->A,&py);
124:   MatDenseGetArray(M,&m);
125:   BVDot_BLAS_Private(X,Y->k-Y->l,X->k-X->l,X->n,ldm,py+(Y->nc+Y->l)*Y->n,px+(X->nc+X->l)*X->n,m+X->l*ldm+Y->l,x->mpi);
126:   MatDenseRestoreArray(M,&m);
127:   MatDenseRestoreArray(x->A,&px);
128:   MatDenseRestoreArray(y->A,&py);
129:   return(0);
130: }

134: PetscErrorCode BVDotVec_Mat(BV X,Vec y,PetscScalar *m)
135: {
136:   PetscErrorCode    ierr;
137:   BV_MAT            *x = (BV_MAT*)X->data;
138:   PetscScalar       *px;
139:   const PetscScalar *py;
140:   Vec               z = y;

143:   if (X->matrix) {
144:     BV_IPMatMult(X,y);
145:     z = X->Bx;
146:   }
147:   MatDenseGetArray(x->A,&px);
148:   VecGetArrayRead(z,&py);
149:   BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,x->mpi);
150:   VecRestoreArrayRead(z,&py);
151:   MatDenseRestoreArray(x->A,&px);
152:   return(0);
153: }

157: PetscErrorCode BVDotVec_Local_Mat(BV X,Vec y,PetscScalar *m)
158: {
160:   BV_MAT         *x = (BV_MAT*)X->data;
161:   PetscScalar    *px,*py;
162:   Vec            z = y;

165:   if (X->matrix) {
166:     BV_IPMatMult(X,y);
167:     z = X->Bx;
168:   }
169:   MatDenseGetArray(x->A,&px);
170:   VecGetArray(z,&py);
171:   BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,PETSC_FALSE);
172:   VecRestoreArray(z,&py);
173:   MatDenseRestoreArray(x->A,&px);
174:   return(0);
175: }

179: PetscErrorCode BVScale_Mat(BV bv,PetscInt j,PetscScalar alpha)
180: {
182:   BV_MAT         *ctx = (BV_MAT*)bv->data;
183:   PetscScalar    *array;

186:   MatDenseGetArray(ctx->A,&array);
187:   if (j<0) {
188:     BVScale_BLAS_Private(bv,(bv->k-bv->l)*bv->n,array+(bv->nc+bv->l)*bv->n,alpha);
189:   } else {
190:     BVScale_BLAS_Private(bv,bv->n,array+(bv->nc+j)*bv->n,alpha);
191:   }
192:   MatDenseRestoreArray(ctx->A,&array);
193:   return(0);
194: }

198: PetscErrorCode BVNorm_Mat(BV bv,PetscInt j,NormType type,PetscReal *val)
199: {
201:   BV_MAT         *ctx = (BV_MAT*)bv->data;
202:   PetscScalar    *array;

205:   MatDenseGetArray(ctx->A,&array);
206:   if (j<0) {
207:     BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,ctx->mpi);
208:   } else {
209:     BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,ctx->mpi);
210:   }
211:   MatDenseRestoreArray(ctx->A,&array);
212:   return(0);
213: }

217: PetscErrorCode BVNorm_Local_Mat(BV bv,PetscInt j,NormType type,PetscReal *val)
218: {
220:   BV_MAT         *ctx = (BV_MAT*)bv->data;
221:   PetscScalar    *array;

224:   MatDenseGetArray(ctx->A,&array);
225:   if (j<0) {
226:     BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,PETSC_FALSE);
227:   } else {
228:     BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,PETSC_FALSE);
229:   }
230:   MatDenseRestoreArray(ctx->A,&array);
231:   return(0);
232: }

236: PetscErrorCode BVOrthogonalize_Mat(BV V,Mat R)
237: {
239:   BV_MAT         *ctx = (BV_MAT*)V->data;
240:   PetscScalar    *pv,*r=NULL;

243:   if (R) { MatDenseGetArray(R,&r); }
244:   MatDenseGetArray(ctx->A,&pv);
245:   BVOrthogonalize_LAPACK_Private(V,V->n,V->k,pv+V->nc*V->n,r,ctx->mpi);
246:   MatDenseRestoreArray(ctx->A,&pv);
247:   if (R) { MatDenseRestoreArray(R,&r); }
248:   return(0);
249: }

253: PetscErrorCode BVMatMult_Mat(BV V,Mat A,BV W)
254: {
256:   BV_MAT         *v = (BV_MAT*)V->data,*w = (BV_MAT*)W->data;
257:   PetscScalar    *pv,*pw,*pb,*pc;
258:   PetscInt       j,m;
259:   PetscBool      flg;

262:   MatDenseGetArray(v->A,&pv);
263:   MatDenseGetArray(w->A,&pw);
264:   MatHasOperation(A,MATOP_MAT_MULT,&flg);
265:   if (V->vmm && flg) {
266:     m = V->k-V->l;
267:     if (V->vmm==BV_MATMULT_MAT_SAVE) {
268:       BV_AllocateMatMult(V,A,m);
269:       MatDenseGetArray(V->B,&pb);
270:       PetscMemcpy(pb,pv+(V->nc+V->l)*V->n,m*V->n*sizeof(PetscScalar));
271:       MatDenseRestoreArray(V->B,&pb);
272:     } else {  /* BV_MATMULT_MAT */
273:       MatCreateDense(PetscObjectComm((PetscObject)V),V->n,PETSC_DECIDE,V->N,m,pv+(V->nc+V->l)*V->n,&V->B);
274:     }
275:     if (!V->C) {
276:       MatMatMultSymbolic(A,V->B,PETSC_DEFAULT,&V->C);
277:     }
278:     MatMatMultNumeric(A,V->B,V->C);
279:     MatDenseGetArray(V->C,&pc);
280:     PetscMemcpy(pw+(W->nc+W->l)*W->n,pc,m*V->n*sizeof(PetscScalar));
281:     MatDenseRestoreArray(V->C,&pc);
282:     if (V->vmm==BV_MATMULT_MAT) {
283:       MatDestroy(&V->B);
284:       MatDestroy(&V->C);
285:     }
286:   } else {
287:     for (j=0;j<V->k-V->l;j++) {
288:       VecPlaceArray(V->cv[1],pv+(V->nc+V->l+j)*V->n);
289:       VecPlaceArray(W->cv[1],pw+(W->nc+W->l+j)*W->n);
290:       MatMult(A,V->cv[1],W->cv[1]);
291:       VecResetArray(V->cv[1]);
292:       VecResetArray(W->cv[1]);
293:     }
294:   }
295:   MatDenseRestoreArray(v->A,&pv);
296:   MatDenseRestoreArray(w->A,&pw);
297:   return(0);
298: }

302: PetscErrorCode BVCopy_Mat(BV V,BV W)
303: {
305:   BV_MAT         *v = (BV_MAT*)V->data,*w = (BV_MAT*)W->data;
306:   PetscScalar    *pv,*pw,*pvc,*pwc;

309:   MatDenseGetArray(v->A,&pv);
310:   MatDenseGetArray(w->A,&pw);
311:   pvc = pv+(V->nc+V->l)*V->n;
312:   pwc = pw+(W->nc+W->l)*W->n;
313:   PetscMemcpy(pwc,pvc,(V->k-V->l)*V->n*sizeof(PetscScalar));
314:   MatDenseRestoreArray(v->A,&pv);
315:   MatDenseRestoreArray(w->A,&pw);
316:   return(0);
317: }

321: PetscErrorCode BVResize_Mat(BV bv,PetscInt m,PetscBool copy)
322: {
324:   BV_MAT         *ctx = (BV_MAT*)bv->data;
325:   PetscScalar    *pA,*pnew;
326:   Mat            A;
327:   char           str[50];

330:   MatCreateDense(PetscObjectComm((PetscObject)bv->t),bv->n,PETSC_DECIDE,PETSC_DECIDE,m,NULL,&A);
331:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
332:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
333:   PetscLogObjectParent((PetscObject)bv,(PetscObject)A);
334:   if (((PetscObject)bv)->name) {
335:     PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);
336:     PetscObjectSetName((PetscObject)A,str);
337:   }
338:   if (copy) {
339:     MatDenseGetArray(ctx->A,&pA);
340:     MatDenseGetArray(A,&pnew);
341:     PetscMemcpy(pnew,pA,PetscMin(m,bv->m)*bv->n*sizeof(PetscScalar));
342:     MatDenseRestoreArray(ctx->A,&pA);
343:     MatDenseRestoreArray(A,&pnew);
344:   }
345:   MatDestroy(&ctx->A);
346:   ctx->A = A;
347:   return(0);
348: }

352: PetscErrorCode BVGetColumn_Mat(BV bv,PetscInt j,Vec *v)
353: {
355:   BV_MAT         *ctx = (BV_MAT*)bv->data;
356:   PetscScalar    *pA;
357:   PetscInt       l;

360:   l = BVAvailableVec;
361:   MatDenseGetArray(ctx->A,&pA);
362:   VecPlaceArray(bv->cv[l],pA+(bv->nc+j)*bv->n);
363:   return(0);
364: }

368: PetscErrorCode BVRestoreColumn_Mat(BV bv,PetscInt j,Vec *v)
369: {
371:   BV_MAT         *ctx = (BV_MAT*)bv->data;
372:   PetscScalar    *pA;
373:   PetscInt       l;

376:   l = (j==bv->ci[0])? 0: 1;
377:   VecResetArray(bv->cv[l]);
378:   MatDenseRestoreArray(ctx->A,&pA);
379:   return(0);
380: }

384: PetscErrorCode BVGetArray_Mat(BV bv,PetscScalar **a)
385: {
387:   BV_MAT         *ctx = (BV_MAT*)bv->data;

390:   MatDenseGetArray(ctx->A,a);
391:   return(0);
392: }

396: PetscErrorCode BVRestoreArray_Mat(BV bv,PetscScalar **a)
397: {
399:   BV_MAT         *ctx = (BV_MAT*)bv->data;

402:   if (a) { MatDenseRestoreArray(ctx->A,a); }
403:   return(0);
404: }

408: PetscErrorCode BVGetArrayRead_Mat(BV bv,const PetscScalar **a)
409: {
411:   BV_MAT         *ctx = (BV_MAT*)bv->data;

414:   MatDenseGetArray(ctx->A,(PetscScalar**)a);
415:   return(0);
416: }

420: PetscErrorCode BVRestoreArrayRead_Mat(BV bv,const PetscScalar **a)
421: {
423:   BV_MAT         *ctx = (BV_MAT*)bv->data;

426:   if (a) { MatDenseRestoreArray(ctx->A,(PetscScalar**)a); }
427:   return(0);
428: }

432: PetscErrorCode BVView_Mat(BV bv,PetscViewer viewer)
433: {
434:   PetscErrorCode    ierr;
435:   BV_MAT            *ctx = (BV_MAT*)bv->data;
436:   PetscViewerFormat format;
437:   PetscBool         isascii;
438:   const char        *bvname,*name;

441:   MatView(ctx->A,viewer);
442:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
443:   if (isascii) {
444:     PetscViewerGetFormat(viewer,&format);
445:     if (format == PETSC_VIEWER_ASCII_MATLAB) {
446:       PetscObjectGetName((PetscObject)bv,&bvname);
447:       PetscObjectGetName((PetscObject)ctx->A,&name);
448:       PetscViewerASCIIPrintf(viewer,"%s=%s;clear %s\n",bvname,name,name);
449:       if (bv->nc) {
450:         PetscViewerASCIIPrintf(viewer,"%s=%s(:,%D:end);\n",bvname,bvname,bv->nc+1);
451:       }
452:     }
453:   }
454:   return(0);
455: }

459: PetscErrorCode BVDestroy_Mat(BV bv)
460: {
462:   BV_MAT         *ctx = (BV_MAT*)bv->data;

465:   MatDestroy(&ctx->A);
466:   VecDestroy(&bv->cv[0]);
467:   VecDestroy(&bv->cv[1]);
468:   PetscFree(bv->data);
469:   return(0);
470: }

474: PETSC_EXTERN PetscErrorCode BVCreate_Mat(BV bv)
475: {
477:   BV_MAT         *ctx;
478:   PetscInt       nloc,bs;
479:   PetscBool      seq;
480:   char           str[50];

483:   PetscNewLog(bv,&ctx);
484:   bv->data = (void*)ctx;

486:   PetscObjectTypeCompare((PetscObject)bv->t,VECMPI,&ctx->mpi);
487:   if (!ctx->mpi) {
488:     PetscObjectTypeCompare((PetscObject)bv->t,VECSEQ,&seq);
489:     if (!seq) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot create a BVMAT from a non-standard template vector");
490:   }

492:   VecGetLocalSize(bv->t,&nloc);
493:   VecGetBlockSize(bv->t,&bs);

495:   MatCreateDense(PetscObjectComm((PetscObject)bv->t),nloc,PETSC_DECIDE,PETSC_DECIDE,bv->m,NULL,&ctx->A);
496:   MatAssemblyBegin(ctx->A,MAT_FINAL_ASSEMBLY);
497:   MatAssemblyEnd(ctx->A,MAT_FINAL_ASSEMBLY);
498:   PetscLogObjectParent((PetscObject)bv,(PetscObject)ctx->A);
499:   if (((PetscObject)bv)->name) {
500:     PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);
501:     PetscObjectSetName((PetscObject)ctx->A,str);
502:   }

504:   if (ctx->mpi) {
505:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[0]);
506:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[1]);
507:   } else {
508:     VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[0]);
509:     VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[1]);
510:   }

512:   bv->ops->mult             = BVMult_Mat;
513:   bv->ops->multvec          = BVMultVec_Mat;
514:   bv->ops->multinplace      = BVMultInPlace_Mat;
515:   bv->ops->multinplacetrans = BVMultInPlaceTranspose_Mat;
516:   bv->ops->dot              = BVDot_Mat;
517:   bv->ops->dotvec           = BVDotVec_Mat;
518:   bv->ops->dotvec_local     = BVDotVec_Local_Mat;
519:   bv->ops->scale            = BVScale_Mat;
520:   bv->ops->norm             = BVNorm_Mat;
521:   bv->ops->norm_local       = BVNorm_Local_Mat;
522:   /*bv->ops->orthogonalize    = BVOrthogonalize_Mat;*/
523:   bv->ops->matmult          = BVMatMult_Mat;
524:   bv->ops->copy             = BVCopy_Mat;
525:   bv->ops->resize           = BVResize_Mat;
526:   bv->ops->getcolumn        = BVGetColumn_Mat;
527:   bv->ops->restorecolumn    = BVRestoreColumn_Mat;
528:   bv->ops->getarray         = BVGetArray_Mat;
529:   bv->ops->restorearray     = BVRestoreArray_Mat;
530:   bv->ops->getarrayread     = BVGetArrayRead_Mat;
531:   bv->ops->restorearrayread = BVRestoreArrayRead_Mat;
532:   bv->ops->destroy          = BVDestroy_Mat;
533:   if (!ctx->mpi) bv->ops->view = BVView_Mat;
534:   return(0);
535: }

slepc-3.7.4/src/sys/classes/bv/impls/mat/bvmat.c0000644000175000017500000004412413107004621021023 0ustar jromanjroman/* BV implemented with a dense Mat - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include typedef struct { Mat A; PetscBool mpi; } BV_MAT; #undef __FUNCT__ #define __FUNCT__ "BVMult_Mat" PetscErrorCode BVMult_Mat(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q) { PetscErrorCode ierr; BV_MAT *y = (BV_MAT*)Y->data,*x = (BV_MAT*)X->data; PetscScalar *px,*py,*q; PetscInt ldq; PetscFunctionBegin; ierr = MatDenseGetArray(x->A,&px);CHKERRQ(ierr); ierr = MatDenseGetArray(y->A,&py);CHKERRQ(ierr); if (Q) { ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMult_BLAS_Private(Y,Y->n,Y->k-Y->l,X->k-X->l,ldq,alpha,px+(X->nc+X->l)*X->n,q+Y->l*ldq+X->l,beta,py+(Y->nc+Y->l)*Y->n);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); } else { ierr = BVAXPY_BLAS_Private(Y,Y->n,Y->k-Y->l,alpha,px+(X->nc+X->l)*X->n,beta,py+(Y->nc+Y->l)*Y->n);CHKERRQ(ierr); } ierr = MatDenseRestoreArray(x->A,&px);CHKERRQ(ierr); ierr = MatDenseRestoreArray(y->A,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultVec_Mat" PetscErrorCode BVMultVec_Mat(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q) { PetscErrorCode ierr; BV_MAT *x = (BV_MAT*)X->data; PetscScalar *px,*py; PetscFunctionBegin; ierr = MatDenseGetArray(x->A,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = BVMultVec_BLAS_Private(X,X->n,X->k-X->l,alpha,px+(X->nc+X->l)*X->n,q,beta,py);CHKERRQ(ierr); ierr = MatDenseRestoreArray(x->A,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlace_Mat" PetscErrorCode BVMultInPlace_Mat(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)V->data; PetscScalar *pv,*q; PetscInt ldq; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(ctx->A,&pv);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_FALSE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); ierr = MatDenseRestoreArray(ctx->A,&pv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlaceTranspose_Mat" PetscErrorCode BVMultInPlaceTranspose_Mat(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)V->data; PetscScalar *pv,*q; PetscInt ldq; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(ctx->A,&pv);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_TRUE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); ierr = MatDenseRestoreArray(ctx->A,&pv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDot_Mat" PetscErrorCode BVDot_Mat(BV X,BV Y,Mat M) { PetscErrorCode ierr; BV_MAT *x = (BV_MAT*)X->data,*y = (BV_MAT*)Y->data; PetscScalar *px,*py,*m; PetscInt ldm; PetscFunctionBegin; ierr = MatGetSize(M,&ldm,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(x->A,&px);CHKERRQ(ierr); ierr = MatDenseGetArray(y->A,&py);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&m);CHKERRQ(ierr); ierr = BVDot_BLAS_Private(X,Y->k-Y->l,X->k-X->l,X->n,ldm,py+(Y->nc+Y->l)*Y->n,px+(X->nc+X->l)*X->n,m+X->l*ldm+Y->l,x->mpi);CHKERRQ(ierr); ierr = MatDenseRestoreArray(M,&m);CHKERRQ(ierr); ierr = MatDenseRestoreArray(x->A,&px);CHKERRQ(ierr); ierr = MatDenseRestoreArray(y->A,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Mat" PetscErrorCode BVDotVec_Mat(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_MAT *x = (BV_MAT*)X->data; PetscScalar *px; const PetscScalar *py; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = MatDenseGetArray(x->A,&px);CHKERRQ(ierr); ierr = VecGetArrayRead(z,&py);CHKERRQ(ierr); ierr = BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,x->mpi);CHKERRQ(ierr); ierr = VecRestoreArrayRead(z,&py);CHKERRQ(ierr); ierr = MatDenseRestoreArray(x->A,&px);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Local_Mat" PetscErrorCode BVDotVec_Local_Mat(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_MAT *x = (BV_MAT*)X->data; PetscScalar *px,*py; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = MatDenseGetArray(x->A,&px);CHKERRQ(ierr); ierr = VecGetArray(z,&py);CHKERRQ(ierr); ierr = BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,PETSC_FALSE);CHKERRQ(ierr); ierr = VecRestoreArray(z,&py);CHKERRQ(ierr); ierr = MatDenseRestoreArray(x->A,&px);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVScale_Mat" PetscErrorCode BVScale_Mat(BV bv,PetscInt j,PetscScalar alpha) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscScalar *array; PetscFunctionBegin; ierr = MatDenseGetArray(ctx->A,&array);CHKERRQ(ierr); if (j<0) { ierr = BVScale_BLAS_Private(bv,(bv->k-bv->l)*bv->n,array+(bv->nc+bv->l)*bv->n,alpha);CHKERRQ(ierr); } else { ierr = BVScale_BLAS_Private(bv,bv->n,array+(bv->nc+j)*bv->n,alpha);CHKERRQ(ierr); } ierr = MatDenseRestoreArray(ctx->A,&array);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Mat" PetscErrorCode BVNorm_Mat(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscScalar *array; PetscFunctionBegin; ierr = MatDenseGetArray(ctx->A,&array);CHKERRQ(ierr); if (j<0) { ierr = BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,ctx->mpi);CHKERRQ(ierr); } else { ierr = BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,ctx->mpi);CHKERRQ(ierr); } ierr = MatDenseRestoreArray(ctx->A,&array);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Local_Mat" PetscErrorCode BVNorm_Local_Mat(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscScalar *array; PetscFunctionBegin; ierr = MatDenseGetArray(ctx->A,&array);CHKERRQ(ierr); if (j<0) { ierr = BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,PETSC_FALSE);CHKERRQ(ierr); } ierr = MatDenseRestoreArray(ctx->A,&array);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalize_Mat" PetscErrorCode BVOrthogonalize_Mat(BV V,Mat R) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)V->data; PetscScalar *pv,*r=NULL; PetscFunctionBegin; if (R) { ierr = MatDenseGetArray(R,&r);CHKERRQ(ierr); } ierr = MatDenseGetArray(ctx->A,&pv);CHKERRQ(ierr); ierr = BVOrthogonalize_LAPACK_Private(V,V->n,V->k,pv+V->nc*V->n,r,ctx->mpi);CHKERRQ(ierr); ierr = MatDenseRestoreArray(ctx->A,&pv);CHKERRQ(ierr); if (R) { ierr = MatDenseRestoreArray(R,&r);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatMult_Mat" PetscErrorCode BVMatMult_Mat(BV V,Mat A,BV W) { PetscErrorCode ierr; BV_MAT *v = (BV_MAT*)V->data,*w = (BV_MAT*)W->data; PetscScalar *pv,*pw,*pb,*pc; PetscInt j,m; PetscBool flg; PetscFunctionBegin; ierr = MatDenseGetArray(v->A,&pv);CHKERRQ(ierr); ierr = MatDenseGetArray(w->A,&pw);CHKERRQ(ierr); ierr = MatHasOperation(A,MATOP_MAT_MULT,&flg);CHKERRQ(ierr); if (V->vmm && flg) { m = V->k-V->l; if (V->vmm==BV_MATMULT_MAT_SAVE) { ierr = BV_AllocateMatMult(V,A,m);CHKERRQ(ierr); ierr = MatDenseGetArray(V->B,&pb);CHKERRQ(ierr); ierr = PetscMemcpy(pb,pv+(V->nc+V->l)*V->n,m*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(V->B,&pb);CHKERRQ(ierr); } else { /* BV_MATMULT_MAT */ ierr = MatCreateDense(PetscObjectComm((PetscObject)V),V->n,PETSC_DECIDE,V->N,m,pv+(V->nc+V->l)*V->n,&V->B);CHKERRQ(ierr); } if (!V->C) { ierr = MatMatMultSymbolic(A,V->B,PETSC_DEFAULT,&V->C);CHKERRQ(ierr); } ierr = MatMatMultNumeric(A,V->B,V->C);CHKERRQ(ierr); ierr = MatDenseGetArray(V->C,&pc);CHKERRQ(ierr); ierr = PetscMemcpy(pw+(W->nc+W->l)*W->n,pc,m*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(V->C,&pc);CHKERRQ(ierr); if (V->vmm==BV_MATMULT_MAT) { ierr = MatDestroy(&V->B);CHKERRQ(ierr); ierr = MatDestroy(&V->C);CHKERRQ(ierr); } } else { for (j=0;jk-V->l;j++) { ierr = VecPlaceArray(V->cv[1],pv+(V->nc+V->l+j)*V->n);CHKERRQ(ierr); ierr = VecPlaceArray(W->cv[1],pw+(W->nc+W->l+j)*W->n);CHKERRQ(ierr); ierr = MatMult(A,V->cv[1],W->cv[1]);CHKERRQ(ierr); ierr = VecResetArray(V->cv[1]);CHKERRQ(ierr); ierr = VecResetArray(W->cv[1]);CHKERRQ(ierr); } } ierr = MatDenseRestoreArray(v->A,&pv);CHKERRQ(ierr); ierr = MatDenseRestoreArray(w->A,&pw);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCopy_Mat" PetscErrorCode BVCopy_Mat(BV V,BV W) { PetscErrorCode ierr; BV_MAT *v = (BV_MAT*)V->data,*w = (BV_MAT*)W->data; PetscScalar *pv,*pw,*pvc,*pwc; PetscFunctionBegin; ierr = MatDenseGetArray(v->A,&pv);CHKERRQ(ierr); ierr = MatDenseGetArray(w->A,&pw);CHKERRQ(ierr); pvc = pv+(V->nc+V->l)*V->n; pwc = pw+(W->nc+W->l)*W->n; ierr = PetscMemcpy(pwc,pvc,(V->k-V->l)*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(v->A,&pv);CHKERRQ(ierr); ierr = MatDenseRestoreArray(w->A,&pw);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVResize_Mat" PetscErrorCode BVResize_Mat(BV bv,PetscInt m,PetscBool copy) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscScalar *pA,*pnew; Mat A; char str[50]; PetscFunctionBegin; ierr = MatCreateDense(PetscObjectComm((PetscObject)bv->t),bv->n,PETSC_DECIDE,PETSC_DECIDE,m,NULL,&A);CHKERRQ(ierr); ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)A);CHKERRQ(ierr); if (((PetscObject)bv)->name) { ierr = PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)A,str);CHKERRQ(ierr); } if (copy) { ierr = MatDenseGetArray(ctx->A,&pA);CHKERRQ(ierr); ierr = MatDenseGetArray(A,&pnew);CHKERRQ(ierr); ierr = PetscMemcpy(pnew,pA,PetscMin(m,bv->m)*bv->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(ctx->A,&pA);CHKERRQ(ierr); ierr = MatDenseRestoreArray(A,&pnew);CHKERRQ(ierr); } ierr = MatDestroy(&ctx->A);CHKERRQ(ierr); ctx->A = A; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetColumn_Mat" PetscErrorCode BVGetColumn_Mat(BV bv,PetscInt j,Vec *v) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscScalar *pA; PetscInt l; PetscFunctionBegin; l = BVAvailableVec; ierr = MatDenseGetArray(ctx->A,&pA);CHKERRQ(ierr); ierr = VecPlaceArray(bv->cv[l],pA+(bv->nc+j)*bv->n);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreColumn_Mat" PetscErrorCode BVRestoreColumn_Mat(BV bv,PetscInt j,Vec *v) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscScalar *pA; PetscInt l; PetscFunctionBegin; l = (j==bv->ci[0])? 0: 1; ierr = VecResetArray(bv->cv[l]);CHKERRQ(ierr); ierr = MatDenseRestoreArray(ctx->A,&pA);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArray_Mat" PetscErrorCode BVGetArray_Mat(BV bv,PetscScalar **a) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscFunctionBegin; ierr = MatDenseGetArray(ctx->A,a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArray_Mat" PetscErrorCode BVRestoreArray_Mat(BV bv,PetscScalar **a) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscFunctionBegin; if (a) { ierr = MatDenseRestoreArray(ctx->A,a);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArrayRead_Mat" PetscErrorCode BVGetArrayRead_Mat(BV bv,const PetscScalar **a) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscFunctionBegin; ierr = MatDenseGetArray(ctx->A,(PetscScalar**)a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArrayRead_Mat" PetscErrorCode BVRestoreArrayRead_Mat(BV bv,const PetscScalar **a) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscFunctionBegin; if (a) { ierr = MatDenseRestoreArray(ctx->A,(PetscScalar**)a);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVView_Mat" PetscErrorCode BVView_Mat(BV bv,PetscViewer viewer) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscViewerFormat format; PetscBool isascii; const char *bvname,*name; PetscFunctionBegin; ierr = MatView(ctx->A,viewer);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_MATLAB) { ierr = PetscObjectGetName((PetscObject)bv,&bvname);CHKERRQ(ierr); ierr = PetscObjectGetName((PetscObject)ctx->A,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s=%s;clear %s\n",bvname,name,name);CHKERRQ(ierr); if (bv->nc) { ierr = PetscViewerASCIIPrintf(viewer,"%s=%s(:,%D:end);\n",bvname,bvname,bv->nc+1);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDestroy_Mat" PetscErrorCode BVDestroy_Mat(BV bv) { PetscErrorCode ierr; BV_MAT *ctx = (BV_MAT*)bv->data; PetscFunctionBegin; ierr = MatDestroy(&ctx->A);CHKERRQ(ierr); ierr = VecDestroy(&bv->cv[0]);CHKERRQ(ierr); ierr = VecDestroy(&bv->cv[1]);CHKERRQ(ierr); ierr = PetscFree(bv->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCreate_Mat" PETSC_EXTERN PetscErrorCode BVCreate_Mat(BV bv) { PetscErrorCode ierr; BV_MAT *ctx; PetscInt nloc,bs; PetscBool seq; char str[50]; PetscFunctionBegin; ierr = PetscNewLog(bv,&ctx);CHKERRQ(ierr); bv->data = (void*)ctx; ierr = PetscObjectTypeCompare((PetscObject)bv->t,VECMPI,&ctx->mpi);CHKERRQ(ierr); if (!ctx->mpi) { ierr = PetscObjectTypeCompare((PetscObject)bv->t,VECSEQ,&seq);CHKERRQ(ierr); if (!seq) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot create a BVMAT from a non-standard template vector"); } ierr = VecGetLocalSize(bv->t,&nloc);CHKERRQ(ierr); ierr = VecGetBlockSize(bv->t,&bs);CHKERRQ(ierr); ierr = MatCreateDense(PetscObjectComm((PetscObject)bv->t),nloc,PETSC_DECIDE,PETSC_DECIDE,bv->m,NULL,&ctx->A);CHKERRQ(ierr); ierr = MatAssemblyBegin(ctx->A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(ctx->A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)ctx->A);CHKERRQ(ierr); if (((PetscObject)bv)->name) { ierr = PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)ctx->A,str);CHKERRQ(ierr); } if (ctx->mpi) { ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[0]);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[1]);CHKERRQ(ierr); } else { ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[0]);CHKERRQ(ierr); ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[1]);CHKERRQ(ierr); } bv->ops->mult = BVMult_Mat; bv->ops->multvec = BVMultVec_Mat; bv->ops->multinplace = BVMultInPlace_Mat; bv->ops->multinplacetrans = BVMultInPlaceTranspose_Mat; bv->ops->dot = BVDot_Mat; bv->ops->dotvec = BVDotVec_Mat; bv->ops->dotvec_local = BVDotVec_Local_Mat; bv->ops->scale = BVScale_Mat; bv->ops->norm = BVNorm_Mat; bv->ops->norm_local = BVNorm_Local_Mat; /*bv->ops->orthogonalize = BVOrthogonalize_Mat;*/ bv->ops->matmult = BVMatMult_Mat; bv->ops->copy = BVCopy_Mat; bv->ops->resize = BVResize_Mat; bv->ops->getcolumn = BVGetColumn_Mat; bv->ops->restorecolumn = BVRestoreColumn_Mat; bv->ops->getarray = BVGetArray_Mat; bv->ops->restorearray = BVRestoreArray_Mat; bv->ops->getarrayread = BVGetArrayRead_Mat; bv->ops->restorearrayread = BVRestoreArrayRead_Mat; bv->ops->destroy = BVDestroy_Mat; if (!ctx->mpi) bv->ops->view = BVView_Mat; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/impls/mat/index.html0000644000175000017500000000202213107004621021532 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

bvmat.c
makefile
slepc-3.7.4/src/sys/classes/bv/impls/vecs/0000755000175000017500000000000013107004621017720 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/impls/vecs/makefile0000644000175000017500000000216413107004621021423 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = vecs.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = BV LOCDIR = src/sys/classes/bv/impls/vecs/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/impls/vecs/vecs.c0000644000175000017500000004452213107004621021033 0ustar jromanjroman/* BV implemented as an array of independent Vecs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include typedef struct { Vec *V; PetscInt vmip; /* Version of BVMultInPlace: 0: memory-efficient version, uses VecGetArray (default in CPU) 1: version that allocates (e-s) work vectors in every call (default in GPU) */ } BV_VECS; #undef __FUNCT__ #define __FUNCT__ "BVMult_Vecs" PetscErrorCode BVMult_Vecs(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q) { PetscErrorCode ierr; BV_VECS *y = (BV_VECS*)Y->data,*x = (BV_VECS*)X->data; PetscScalar *q,*s=NULL; PetscInt i,j,ldq; PetscFunctionBegin; if (Q) { ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); if (alpha!=1.0) { ierr = BVAllocateWork_Private(Y,X->k-X->l);CHKERRQ(ierr); s = Y->work; } ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); for (j=Y->l;jk;j++) { ierr = VecScale(y->V[Y->nc+j],beta);CHKERRQ(ierr); if (alpha!=1.0) { for (i=X->l;ik;i++) s[i-X->l] = alpha*q[i+j*ldq]; } else s = q+j*ldq+X->l; ierr = VecMAXPY(y->V[Y->nc+j],X->k-X->l,s,x->V+X->nc+X->l);CHKERRQ(ierr); } ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); } else { for (j=0;jk-Y->l;j++) { ierr = VecScale(y->V[Y->nc+Y->l+j],beta);CHKERRQ(ierr); ierr = VecAXPY(y->V[Y->nc+Y->l+j],alpha,x->V[X->nc+X->l+j]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultVec_Vecs" PetscErrorCode BVMultVec_Vecs(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q) { PetscErrorCode ierr; BV_VECS *x = (BV_VECS*)X->data; PetscScalar *s=NULL; PetscInt i; PetscFunctionBegin; if (alpha!=1.0) { ierr = BVAllocateWork_Private(X,X->k-X->l);CHKERRQ(ierr); s = X->work; } ierr = VecScale(y,beta);CHKERRQ(ierr); if (alpha!=1.0) { for (i=0;ik-X->l;i++) s[i] = alpha*q[i]; } else s = q; ierr = VecMAXPY(y,X->k-X->l,s,x->V+X->nc+X->l);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlace_Vecs_ME" /* BVMultInPlace_Vecs_ME - V(:,s:e-1) = V*Q(:,s:e-1) for regular vectors. Memory-efficient version, uses VecGetArray (default in CPU) Writing V = [ V1 V2 V3 ] and Q(:,s:e-1) = [ Q1 Q2 Q3 ]', where V2 corresponds to the columns s:e-1, the computation is done as V2 := V2*Q2 + V1*Q1 + V3*Q3 */ PetscErrorCode BVMultInPlace_Vecs_ME(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)V->data; PetscScalar *q; PetscInt i,ldq; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); /* V2 := V2*Q2 */ ierr = BVMultInPlace_Vecs_Private(V,V->n,e-s,ldq,ctx->V+V->nc+s,q+s*ldq+s,PETSC_FALSE);CHKERRQ(ierr); /* V2 += V1*Q1 + V3*Q3 */ for (i=s;iV->l) { ierr = VecMAXPY(ctx->V[V->nc+i],s-V->l,q+i*ldq+V->l,ctx->V+V->nc+V->l);CHKERRQ(ierr); } if (V->k>e) { ierr = VecMAXPY(ctx->V[V->nc+i],V->k-e,q+i*ldq+e,ctx->V+V->nc+e);CHKERRQ(ierr); } } ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlace_Vecs_Alloc" /* BVMultInPlace_Vecs_Alloc - V(:,s:e-1) = V*Q(:,s:e-1) for regular vectors. Version that allocates (e-s) work vectors in every call (default in GPU) */ PetscErrorCode BVMultInPlace_Vecs_Alloc(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)V->data; PetscScalar *q; PetscInt i,ldq; Vec *W; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = VecDuplicateVecs(V->t,e-s,&W);CHKERRQ(ierr); for (i=s;ik-V->l,q+i*ldq+V->l,ctx->V+V->nc+V->l);CHKERRQ(ierr); } for (i=s;iV[V->nc+i]);CHKERRQ(ierr); } ierr = VecDestroyVecs(e-s,&W);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlaceTranspose_Vecs" /* BVMultInPlaceTranspose_Vecs - V(:,s:e-1) = V*Q'(:,s:e-1) for regular vectors. */ PetscErrorCode BVMultInPlaceTranspose_Vecs(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)V->data; PetscScalar *q; PetscInt i,j,ldq,n; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,&n);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); /* V2 := V2*Q2' */ ierr = BVMultInPlace_Vecs_Private(V,V->n,e-s,ldq,ctx->V+V->nc+s,q+s*ldq+s,PETSC_TRUE);CHKERRQ(ierr); /* V2 += V1*Q1' + V3*Q3' */ for (i=s;il;jV[V->nc+i],q[i+j*ldq],ctx->V[V->nc+j]);CHKERRQ(ierr); } for (j=e;jV[V->nc+i],q[i+j*ldq],ctx->V[V->nc+j]);CHKERRQ(ierr); } } ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDot_Vecs" PetscErrorCode BVDot_Vecs(BV X,BV Y,Mat M) { PetscErrorCode ierr; BV_VECS *x = (BV_VECS*)X->data,*y = (BV_VECS*)Y->data; PetscScalar *m; PetscInt j,ldm; PetscFunctionBegin; ierr = MatGetSize(M,&ldm,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&m);CHKERRQ(ierr); for (j=X->l;jk;j++) { ierr = VecMDot(x->V[X->nc+j],Y->k-Y->l,y->V+Y->nc+Y->l,m+j*ldm+Y->l);CHKERRQ(ierr); } ierr = MatDenseRestoreArray(M,&m);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Vecs" PetscErrorCode BVDotVec_Vecs(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_VECS *x = (BV_VECS*)X->data; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = VecMDot(z,X->k-X->l,x->V+X->nc+X->l,m);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Begin_Vecs" PetscErrorCode BVDotVec_Begin_Vecs(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_VECS *x = (BV_VECS*)X->data; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = VecMDotBegin(z,X->k-X->l,x->V+X->nc+X->l,m);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_End_Vecs" PetscErrorCode BVDotVec_End_Vecs(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_VECS *x = (BV_VECS*)X->data; PetscFunctionBegin; ierr = VecMDotEnd(y,X->k-X->l,x->V+X->nc+X->l,m);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVScale_Vecs" PetscErrorCode BVScale_Vecs(BV bv,PetscInt j,PetscScalar alpha) { PetscErrorCode ierr; PetscInt i; BV_VECS *ctx = (BV_VECS*)bv->data; PetscFunctionBegin; if (j<0) { for (i=bv->l;ik;i++) { ierr = VecScale(ctx->V[bv->nc+i],alpha);CHKERRQ(ierr); } } else { ierr = VecScale(ctx->V[bv->nc+j],alpha);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Vecs" PetscErrorCode BVNorm_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; PetscInt i; PetscReal nrm; BV_VECS *ctx = (BV_VECS*)bv->data; PetscFunctionBegin; if (j<0) { switch (type) { case NORM_FROBENIUS: *val = 0.0; for (i=bv->l;ik;i++) { ierr = VecNorm(ctx->V[bv->nc+i],NORM_2,&nrm);CHKERRQ(ierr); *val += nrm*nrm; } *val = PetscSqrtReal(*val); break; default: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Requested norm not implemented in BVVECS"); } } else { ierr = VecNorm(ctx->V[bv->nc+j],type,val);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Begin_Vecs" PetscErrorCode BVNorm_Begin_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscFunctionBegin; if (j<0) { switch (type) { default: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Requested norm not implemented in BVVECS"); } } else { ierr = VecNormBegin(ctx->V[bv->nc+j],type,val);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_End_Vecs" PetscErrorCode BVNorm_End_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscFunctionBegin; if (j<0) { switch (type) { default: SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Requested norm not implemented in BVVECS"); } } else { ierr = VecNormEnd(ctx->V[bv->nc+j],type,val);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatMult_Vecs" PetscErrorCode BVMatMult_Vecs(BV V,Mat A,BV W) { PetscErrorCode ierr; BV_VECS *v = (BV_VECS*)V->data,*w = (BV_VECS*)W->data; PetscInt j; PetscFunctionBegin; if (V->vmm) { ierr = PetscInfo(V,"BVMatMult_Vecs: ignoring method\n");CHKERRQ(ierr); } for (j=0;jk-V->l;j++) { ierr = MatMult(A,v->V[V->nc+V->l+j],w->V[W->nc+W->l+j]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCopy_Vecs" PetscErrorCode BVCopy_Vecs(BV V,BV W) { PetscErrorCode ierr; BV_VECS *v = (BV_VECS*)V->data,*w = (BV_VECS*)W->data; PetscInt j; PetscFunctionBegin; for (j=0;jk-V->l;j++) { ierr = VecCopy(v->V[V->nc+V->l+j],w->V[W->nc+W->l+j]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVResize_Vecs" PetscErrorCode BVResize_Vecs(BV bv,PetscInt m,PetscBool copy) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; Vec *newV; PetscInt j; char str[50]; PetscFunctionBegin; ierr = VecDuplicateVecs(bv->t,m,&newV);CHKERRQ(ierr); ierr = PetscLogObjectParents(bv,m,newV);CHKERRQ(ierr); if (((PetscObject)bv)->name) { for (j=0;jname,j);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)newV[j],str);CHKERRQ(ierr); } } if (copy) { for (j=0;jm);j++) { ierr = VecCopy(ctx->V[j],newV[j]);CHKERRQ(ierr); } } ierr = VecDestroyVecs(bv->m,&ctx->V);CHKERRQ(ierr); ctx->V = newV; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetColumn_Vecs" PetscErrorCode BVGetColumn_Vecs(BV bv,PetscInt j,Vec *v) { BV_VECS *ctx = (BV_VECS*)bv->data; PetscInt l; PetscFunctionBegin; l = BVAvailableVec; bv->cv[l] = ctx->V[bv->nc+j]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArray_Vecs" PetscErrorCode BVGetArray_Vecs(BV bv,PetscScalar **a) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscInt j; const PetscScalar *p; PetscFunctionBegin; ierr = PetscMalloc1((bv->nc+bv->m)*bv->n,a);CHKERRQ(ierr); for (j=0;jnc+bv->m;j++) { ierr = VecGetArrayRead(ctx->V[j],&p);CHKERRQ(ierr); ierr = PetscMemcpy(*a+j*bv->n,p,bv->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArrayRead(ctx->V[j],&p);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArray_Vecs" PetscErrorCode BVRestoreArray_Vecs(BV bv,PetscScalar **a) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscInt j; PetscScalar *p; PetscFunctionBegin; for (j=0;jnc+bv->m;j++) { ierr = VecGetArray(ctx->V[j],&p);CHKERRQ(ierr); ierr = PetscMemcpy(p,*a+j*bv->n,bv->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArray(ctx->V[j],&p);CHKERRQ(ierr); } ierr = PetscFree(*a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArrayRead_Vecs" PetscErrorCode BVGetArrayRead_Vecs(BV bv,const PetscScalar **a) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscInt j; const PetscScalar *p; PetscFunctionBegin; ierr = PetscMalloc1((bv->nc+bv->m)*bv->n,a);CHKERRQ(ierr); for (j=0;jnc+bv->m;j++) { ierr = VecGetArrayRead(ctx->V[j],&p);CHKERRQ(ierr); ierr = PetscMemcpy((PetscScalar*)*a+j*bv->n,p,bv->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArrayRead(ctx->V[j],&p);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArrayRead_Vecs" PetscErrorCode BVRestoreArrayRead_Vecs(BV bv,const PetscScalar **a) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(*a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVVecsSetVmip" /* Sets the value of vmip flag and resets ops->multinplace accordingly */ PETSC_STATIC_INLINE PetscErrorCode BVVecsSetVmip(BV bv,PetscInt vmip) { typedef PetscErrorCode (*fmultinplace)(BV,Mat,PetscInt,PetscInt); fmultinplace multinplace[2] = {BVMultInPlace_Vecs_ME, BVMultInPlace_Vecs_Alloc}; BV_VECS *ctx = (BV_VECS*)bv->data; PetscFunctionBegin; ctx->vmip = vmip; bv->ops->multinplace = multinplace[vmip]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVSetFromOptions_Vecs" PetscErrorCode BVSetFromOptions_Vecs(PetscOptionItems *PetscOptionsObject,BV bv) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"BV Vecs Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-bv_vecs_vmip","Version of BVMultInPlace operation","",ctx->vmip,&ctx->vmip,NULL);CHKERRQ(ierr); if (ctx->vmip<0 || ctx->vmip>1) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Wrong version of BVMultInPlace"); ierr = BVVecsSetVmip(bv,ctx->vmip);CHKERRQ(ierr); ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVView_Vecs" PetscErrorCode BVView_Vecs(BV bv,PetscViewer viewer) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscInt j; PetscViewerFormat format; PetscBool isascii,ismatlab=PETSC_FALSE; const char *bvname,*name; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_MATLAB) ismatlab = PETSC_TRUE; } if (ismatlab) { ierr = PetscObjectGetName((PetscObject)bv,&bvname);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s=[];\n",bvname);CHKERRQ(ierr); } for (j=bv->nc;jnc+bv->m;j++) { ierr = VecView(ctx->V[j],viewer);CHKERRQ(ierr); if (ismatlab) { ierr = PetscObjectGetName((PetscObject)ctx->V[j],&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s=[%s,%s];clear %s\n",bvname,bvname,name,name);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDestroy_Vecs" PetscErrorCode BVDestroy_Vecs(BV bv) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)bv->data; PetscFunctionBegin; ierr = VecDestroyVecs(bv->nc+bv->m,&ctx->V);CHKERRQ(ierr); ierr = PetscFree(bv->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDuplicate_Vecs" PetscErrorCode BVDuplicate_Vecs(BV V,BV *W) { PetscErrorCode ierr; BV_VECS *ctx = (BV_VECS*)V->data; PetscFunctionBegin; ierr = BVVecsSetVmip(*W,ctx->vmip);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCreate_Vecs" PETSC_EXTERN PetscErrorCode BVCreate_Vecs(BV bv) { PetscErrorCode ierr; BV_VECS *ctx; PetscInt j; PetscBool iscusp; char str[50]; PetscFunctionBegin; ierr = PetscNewLog(bv,&ctx);CHKERRQ(ierr); bv->data = (void*)ctx; ierr = VecDuplicateVecs(bv->t,bv->m,&ctx->V);CHKERRQ(ierr); ierr = PetscLogObjectParents(bv,bv->m,ctx->V);CHKERRQ(ierr); if (((PetscObject)bv)->name) { for (j=0;jm;j++) { ierr = PetscSNPrintf(str,50,"%s_%D",((PetscObject)bv)->name,j);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)ctx->V[j],str);CHKERRQ(ierr); } } /* Default version of BVMultInPlace */ ierr = PetscObjectTypeCompareAny((PetscObject)bv->t,&iscusp,VECSEQCUSP,VECMPICUSP,"");CHKERRQ(ierr); ctx->vmip = iscusp? 1: 0; /* Deferred call to setfromoptions */ if (bv->defersfo) { ierr = PetscObjectOptionsBegin((PetscObject)bv);CHKERRQ(ierr); ierr = BVSetFromOptions_Vecs(PetscOptionsObject,bv);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); } ierr = BVVecsSetVmip(bv,ctx->vmip);CHKERRQ(ierr); bv->ops->mult = BVMult_Vecs; bv->ops->multvec = BVMultVec_Vecs; bv->ops->multinplacetrans = BVMultInPlaceTranspose_Vecs; bv->ops->dot = BVDot_Vecs; bv->ops->dotvec = BVDotVec_Vecs; bv->ops->dotvec_begin = BVDotVec_Begin_Vecs; bv->ops->dotvec_end = BVDotVec_End_Vecs; bv->ops->scale = BVScale_Vecs; bv->ops->norm = BVNorm_Vecs; bv->ops->norm_begin = BVNorm_Begin_Vecs; bv->ops->norm_end = BVNorm_End_Vecs; bv->ops->matmult = BVMatMult_Vecs; bv->ops->copy = BVCopy_Vecs; bv->ops->resize = BVResize_Vecs; bv->ops->getcolumn = BVGetColumn_Vecs; bv->ops->getarray = BVGetArray_Vecs; bv->ops->restorearray = BVRestoreArray_Vecs; bv->ops->getarrayread = BVGetArrayRead_Vecs; bv->ops->restorearrayread = BVRestoreArrayRead_Vecs; bv->ops->destroy = BVDestroy_Vecs; bv->ops->duplicate = BVDuplicate_Vecs; bv->ops->setfromoptions = BVSetFromOptions_Vecs; bv->ops->view = BVView_Vecs; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/impls/vecs/vecs.c.html0000644000175000017500000011023113107004621021765 0ustar jromanjroman

Actual source code: vecs.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV implemented as an array of independent Vecs

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>

 26: typedef struct {
 27:   Vec      *V;
 28:   PetscInt vmip;   /* Version of BVMultInPlace:
 29:        0: memory-efficient version, uses VecGetArray (default in CPU)
 30:        1: version that allocates (e-s) work vectors in every call (default in GPU) */
 31: } BV_VECS;

 35: PetscErrorCode BVMult_Vecs(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)
 36: {
 38:   BV_VECS        *y = (BV_VECS*)Y->data,*x = (BV_VECS*)X->data;
 39:   PetscScalar    *q,*s=NULL;
 40:   PetscInt       i,j,ldq;

 43:   if (Q) {
 44:     MatGetSize(Q,&ldq,NULL);
 45:     if (alpha!=1.0) {
 46:       BVAllocateWork_Private(Y,X->k-X->l);
 47:       s = Y->work;
 48:     }
 49:     MatDenseGetArray(Q,&q);
 50:     for (j=Y->l;j<Y->k;j++) {
 51:       VecScale(y->V[Y->nc+j],beta);
 52:       if (alpha!=1.0) {
 53:         for (i=X->l;i<X->k;i++) s[i-X->l] = alpha*q[i+j*ldq];
 54:       } else s = q+j*ldq+X->l;
 55:       VecMAXPY(y->V[Y->nc+j],X->k-X->l,s,x->V+X->nc+X->l);
 56:     }
 57:     MatDenseRestoreArray(Q,&q);
 58:   } else {
 59:     for (j=0;j<Y->k-Y->l;j++) {
 60:       VecScale(y->V[Y->nc+Y->l+j],beta);
 61:       VecAXPY(y->V[Y->nc+Y->l+j],alpha,x->V[X->nc+X->l+j]);
 62:     }
 63:   }
 64:   return(0);
 65: }

 69: PetscErrorCode BVMultVec_Vecs(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)
 70: {
 72:   BV_VECS        *x = (BV_VECS*)X->data;
 73:   PetscScalar    *s=NULL;
 74:   PetscInt       i;

 77:   if (alpha!=1.0) {
 78:     BVAllocateWork_Private(X,X->k-X->l);
 79:     s = X->work;
 80:   }
 81:   VecScale(y,beta);
 82:   if (alpha!=1.0) {
 83:     for (i=0;i<X->k-X->l;i++) s[i] = alpha*q[i];
 84:   } else s = q;
 85:   VecMAXPY(y,X->k-X->l,s,x->V+X->nc+X->l);
 86:   return(0);
 87: }

 91: /*
 92:    BVMultInPlace_Vecs_ME - V(:,s:e-1) = V*Q(:,s:e-1) for regular vectors.

 94:    Memory-efficient version, uses VecGetArray (default in CPU)

 96:    Writing V = [ V1 V2 V3 ] and Q(:,s:e-1) = [ Q1 Q2 Q3 ]', where V2
 97:    corresponds to the columns s:e-1, the computation is done as
 98:                   V2 := V2*Q2 + V1*Q1 + V3*Q3
 99: */
100: PetscErrorCode BVMultInPlace_Vecs_ME(BV V,Mat Q,PetscInt s,PetscInt e)
101: {
103:   BV_VECS        *ctx = (BV_VECS*)V->data;
104:   PetscScalar    *q;
105:   PetscInt       i,ldq;

108:   MatGetSize(Q,&ldq,NULL);
109:   MatDenseGetArray(Q,&q);
110:   /* V2 := V2*Q2 */
111:   BVMultInPlace_Vecs_Private(V,V->n,e-s,ldq,ctx->V+V->nc+s,q+s*ldq+s,PETSC_FALSE);
112:   /* V2 += V1*Q1 + V3*Q3 */
113:   for (i=s;i<e;i++) {
114:     if (s>V->l) {
115:       VecMAXPY(ctx->V[V->nc+i],s-V->l,q+i*ldq+V->l,ctx->V+V->nc+V->l);
116:     }
117:     if (V->k>e) {
118:       VecMAXPY(ctx->V[V->nc+i],V->k-e,q+i*ldq+e,ctx->V+V->nc+e);
119:     }
120:   }
121:   MatDenseRestoreArray(Q,&q);
122:   return(0);
123: }

127: /*
128:    BVMultInPlace_Vecs_Alloc - V(:,s:e-1) = V*Q(:,s:e-1) for regular vectors.

130:    Version that allocates (e-s) work vectors in every call (default in GPU)
131: */
132: PetscErrorCode BVMultInPlace_Vecs_Alloc(BV V,Mat Q,PetscInt s,PetscInt e)
133: {
135:   BV_VECS        *ctx = (BV_VECS*)V->data;
136:   PetscScalar    *q;
137:   PetscInt       i,ldq;
138:   Vec            *W;

141:   MatGetSize(Q,&ldq,NULL);
142:   MatDenseGetArray(Q,&q);
143:   VecDuplicateVecs(V->t,e-s,&W);
144:   for (i=s;i<e;i++) {
145:     VecMAXPY(W[i-s],V->k-V->l,q+i*ldq+V->l,ctx->V+V->nc+V->l);
146:   }
147:   for (i=s;i<e;i++) {
148:     VecCopy(W[i-s],ctx->V[V->nc+i]);
149:   }
150:   VecDestroyVecs(e-s,&W);
151:   MatDenseRestoreArray(Q,&q);
152:   return(0);
153: }

157: /*
158:    BVMultInPlaceTranspose_Vecs - V(:,s:e-1) = V*Q'(:,s:e-1) for regular vectors.
159: */
160: PetscErrorCode BVMultInPlaceTranspose_Vecs(BV V,Mat Q,PetscInt s,PetscInt e)
161: {
163:   BV_VECS        *ctx = (BV_VECS*)V->data;
164:   PetscScalar    *q;
165:   PetscInt       i,j,ldq,n;

168:   MatGetSize(Q,&ldq,&n);
169:   MatDenseGetArray(Q,&q);
170:   /* V2 := V2*Q2' */
171:   BVMultInPlace_Vecs_Private(V,V->n,e-s,ldq,ctx->V+V->nc+s,q+s*ldq+s,PETSC_TRUE);
172:   /* V2 += V1*Q1' + V3*Q3' */
173:   for (i=s;i<e;i++) {
174:     for (j=V->l;j<s;j++) {
175:       VecAXPY(ctx->V[V->nc+i],q[i+j*ldq],ctx->V[V->nc+j]);
176:     }
177:     for (j=e;j<n;j++) {
178:       VecAXPY(ctx->V[V->nc+i],q[i+j*ldq],ctx->V[V->nc+j]);
179:     }
180:   }
181:   MatDenseRestoreArray(Q,&q);
182:   return(0);
183: }

187: PetscErrorCode BVDot_Vecs(BV X,BV Y,Mat M)
188: {
190:   BV_VECS        *x = (BV_VECS*)X->data,*y = (BV_VECS*)Y->data;
191:   PetscScalar    *m;
192:   PetscInt       j,ldm;

195:   MatGetSize(M,&ldm,NULL);
196:   MatDenseGetArray(M,&m);
197:   for (j=X->l;j<X->k;j++) {
198:     VecMDot(x->V[X->nc+j],Y->k-Y->l,y->V+Y->nc+Y->l,m+j*ldm+Y->l);
199:   }
200:   MatDenseRestoreArray(M,&m);
201:   return(0);
202: }

206: PetscErrorCode BVDotVec_Vecs(BV X,Vec y,PetscScalar *m)
207: {
209:   BV_VECS        *x = (BV_VECS*)X->data;
210:   Vec            z = y;

213:   if (X->matrix) {
214:     BV_IPMatMult(X,y);
215:     z = X->Bx;
216:   }
217:   VecMDot(z,X->k-X->l,x->V+X->nc+X->l,m);
218:   return(0);
219: }

223: PetscErrorCode BVDotVec_Begin_Vecs(BV X,Vec y,PetscScalar *m)
224: {
226:   BV_VECS        *x = (BV_VECS*)X->data;
227:   Vec            z = y;

230:   if (X->matrix) {
231:     BV_IPMatMult(X,y);
232:     z = X->Bx;
233:   }
234:   VecMDotBegin(z,X->k-X->l,x->V+X->nc+X->l,m);
235:   return(0);
236: }

240: PetscErrorCode BVDotVec_End_Vecs(BV X,Vec y,PetscScalar *m)
241: {
243:   BV_VECS        *x = (BV_VECS*)X->data;

246:   VecMDotEnd(y,X->k-X->l,x->V+X->nc+X->l,m);
247:   return(0);
248: }

252: PetscErrorCode BVScale_Vecs(BV bv,PetscInt j,PetscScalar alpha)
253: {
255:   PetscInt       i;
256:   BV_VECS        *ctx = (BV_VECS*)bv->data;

259:   if (j<0) {
260:     for (i=bv->l;i<bv->k;i++) {
261:       VecScale(ctx->V[bv->nc+i],alpha);
262:     }
263:   } else {
264:     VecScale(ctx->V[bv->nc+j],alpha);
265:   }
266:   return(0);
267: }

271: PetscErrorCode BVNorm_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)
272: {
274:   PetscInt       i;
275:   PetscReal      nrm;
276:   BV_VECS        *ctx = (BV_VECS*)bv->data;

279:   if (j<0) {
280:     switch (type) {
281:     case NORM_FROBENIUS:
282:       *val = 0.0;
283:       for (i=bv->l;i<bv->k;i++) {
284:         VecNorm(ctx->V[bv->nc+i],NORM_2,&nrm);
285:         *val += nrm*nrm;
286:       }
287:       *val = PetscSqrtReal(*val);
288:       break;
289:     default:
290:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Requested norm not implemented in BVVECS");
291:     }
292:   } else {
293:     VecNorm(ctx->V[bv->nc+j],type,val);
294:   }
295:   return(0);
296: }

300: PetscErrorCode BVNorm_Begin_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)
301: {
303:   BV_VECS        *ctx = (BV_VECS*)bv->data;

306:   if (j<0) {
307:     switch (type) {
308:     default:
309:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Requested norm not implemented in BVVECS");
310:     }
311:   } else {
312:     VecNormBegin(ctx->V[bv->nc+j],type,val);
313:   }
314:   return(0);
315: }

319: PetscErrorCode BVNorm_End_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)
320: {
322:   BV_VECS        *ctx = (BV_VECS*)bv->data;

325:   if (j<0) {
326:     switch (type) {
327:     default:
328:       SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Requested norm not implemented in BVVECS");
329:     }
330:   } else {
331:     VecNormEnd(ctx->V[bv->nc+j],type,val);
332:   }
333:   return(0);
334: }

338: PetscErrorCode BVMatMult_Vecs(BV V,Mat A,BV W)
339: {
341:   BV_VECS        *v = (BV_VECS*)V->data,*w = (BV_VECS*)W->data;
342:   PetscInt       j;

345:   if (V->vmm) { PetscInfo(V,"BVMatMult_Vecs: ignoring method\n"); }
346:   for (j=0;j<V->k-V->l;j++) {
347:     MatMult(A,v->V[V->nc+V->l+j],w->V[W->nc+W->l+j]);
348:   }
349:   return(0);
350: }

354: PetscErrorCode BVCopy_Vecs(BV V,BV W)
355: {
357:   BV_VECS        *v = (BV_VECS*)V->data,*w = (BV_VECS*)W->data;
358:   PetscInt       j;

361:   for (j=0;j<V->k-V->l;j++) {
362:     VecCopy(v->V[V->nc+V->l+j],w->V[W->nc+W->l+j]);
363:   }
364:   return(0);
365: }

369: PetscErrorCode BVResize_Vecs(BV bv,PetscInt m,PetscBool copy)
370: {
372:   BV_VECS        *ctx = (BV_VECS*)bv->data;
373:   Vec            *newV;
374:   PetscInt       j;
375:   char           str[50];

378:   VecDuplicateVecs(bv->t,m,&newV);
379:   PetscLogObjectParents(bv,m,newV);
380:   if (((PetscObject)bv)->name) {
381:     for (j=0;j<m;j++) {
382:       PetscSNPrintf(str,50,"%s_%D",((PetscObject)bv)->name,j);
383:       PetscObjectSetName((PetscObject)newV[j],str);
384:     }
385:   }
386:   if (copy) {
387:     for (j=0;j<PetscMin(m,bv->m);j++) {
388:       VecCopy(ctx->V[j],newV[j]);
389:     }
390:   }
391:   VecDestroyVecs(bv->m,&ctx->V);
392:   ctx->V = newV;
393:   return(0);
394: }

398: PetscErrorCode BVGetColumn_Vecs(BV bv,PetscInt j,Vec *v)
399: {
400:   BV_VECS  *ctx = (BV_VECS*)bv->data;
401:   PetscInt l;

404:   l = BVAvailableVec;
405:   bv->cv[l] = ctx->V[bv->nc+j];
406:   return(0);
407: }

411: PetscErrorCode BVGetArray_Vecs(BV bv,PetscScalar **a)
412: {
413:   PetscErrorCode    ierr;
414:   BV_VECS           *ctx = (BV_VECS*)bv->data;
415:   PetscInt          j;
416:   const PetscScalar *p;

419:   PetscMalloc1((bv->nc+bv->m)*bv->n,a);
420:   for (j=0;j<bv->nc+bv->m;j++) {
421:     VecGetArrayRead(ctx->V[j],&p);
422:     PetscMemcpy(*a+j*bv->n,p,bv->n*sizeof(PetscScalar));
423:     VecRestoreArrayRead(ctx->V[j],&p);
424:   }
425:   return(0);
426: }

430: PetscErrorCode BVRestoreArray_Vecs(BV bv,PetscScalar **a)
431: {
433:   BV_VECS        *ctx = (BV_VECS*)bv->data;
434:   PetscInt       j;
435:   PetscScalar    *p;

438:   for (j=0;j<bv->nc+bv->m;j++) {
439:     VecGetArray(ctx->V[j],&p);
440:     PetscMemcpy(p,*a+j*bv->n,bv->n*sizeof(PetscScalar));
441:     VecRestoreArray(ctx->V[j],&p);
442:   }
443:   PetscFree(*a);
444:   return(0);
445: }

449: PetscErrorCode BVGetArrayRead_Vecs(BV bv,const PetscScalar **a)
450: {
451:   PetscErrorCode    ierr;
452:   BV_VECS           *ctx = (BV_VECS*)bv->data;
453:   PetscInt          j;
454:   const PetscScalar *p;

457:   PetscMalloc1((bv->nc+bv->m)*bv->n,a);
458:   for (j=0;j<bv->nc+bv->m;j++) {
459:     VecGetArrayRead(ctx->V[j],&p);
460:     PetscMemcpy((PetscScalar*)*a+j*bv->n,p,bv->n*sizeof(PetscScalar));
461:     VecRestoreArrayRead(ctx->V[j],&p);
462:   }
463:   return(0);
464: }

468: PetscErrorCode BVRestoreArrayRead_Vecs(BV bv,const PetscScalar **a)
469: {

473:   PetscFree(*a);
474:   return(0);
475: }

479: /*
480:    Sets the value of vmip flag and resets ops->multinplace accordingly
481:  */
482: PETSC_STATIC_INLINE PetscErrorCode BVVecsSetVmip(BV bv,PetscInt vmip)
483: {
484:   typedef PetscErrorCode (*fmultinplace)(BV,Mat,PetscInt,PetscInt);
485:   fmultinplace multinplace[2] = {BVMultInPlace_Vecs_ME, BVMultInPlace_Vecs_Alloc};
486:   BV_VECS      *ctx = (BV_VECS*)bv->data;

489:   ctx->vmip            = vmip;
490:   bv->ops->multinplace = multinplace[vmip];
491:   return(0);
492: }

496: PetscErrorCode BVSetFromOptions_Vecs(PetscOptionItems *PetscOptionsObject,BV bv)
497: {
499:   BV_VECS        *ctx = (BV_VECS*)bv->data;

502:   PetscOptionsHead(PetscOptionsObject,"BV Vecs Options");
503:     PetscOptionsInt("-bv_vecs_vmip","Version of BVMultInPlace operation","",ctx->vmip,&ctx->vmip,NULL);
504:     if (ctx->vmip<0 || ctx->vmip>1) SETERRQ(PetscObjectComm((PetscObject)bv),PETSC_ERR_ARG_OUTOFRANGE,"Wrong version of BVMultInPlace");
505:     BVVecsSetVmip(bv,ctx->vmip);
506:   PetscOptionsTail();
507:   return(0);
508: }

512: PetscErrorCode BVView_Vecs(BV bv,PetscViewer viewer)
513: {
514:   PetscErrorCode    ierr;
515:   BV_VECS           *ctx = (BV_VECS*)bv->data;
516:   PetscInt          j;
517:   PetscViewerFormat format;
518:   PetscBool         isascii,ismatlab=PETSC_FALSE;
519:   const char        *bvname,*name;

522:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
523:   if (isascii) {
524:     PetscViewerGetFormat(viewer,&format);
525:     if (format == PETSC_VIEWER_ASCII_MATLAB) ismatlab = PETSC_TRUE;
526:   }
527:   if (ismatlab) {
528:     PetscObjectGetName((PetscObject)bv,&bvname);
529:     PetscViewerASCIIPrintf(viewer,"%s=[];\n",bvname);
530:   }
531:   for (j=bv->nc;j<bv->nc+bv->m;j++) {
532:     VecView(ctx->V[j],viewer);
533:     if (ismatlab) {
534:       PetscObjectGetName((PetscObject)ctx->V[j],&name);
535:       PetscViewerASCIIPrintf(viewer,"%s=[%s,%s];clear %s\n",bvname,bvname,name,name);
536:     }
537:   }
538:   return(0);
539: }

543: PetscErrorCode BVDestroy_Vecs(BV bv)
544: {
546:   BV_VECS        *ctx = (BV_VECS*)bv->data;

549:   VecDestroyVecs(bv->nc+bv->m,&ctx->V);
550:   PetscFree(bv->data);
551:   return(0);
552: }

556: PetscErrorCode BVDuplicate_Vecs(BV V,BV *W)
557: {
559:   BV_VECS        *ctx = (BV_VECS*)V->data;

562:   BVVecsSetVmip(*W,ctx->vmip);
563:   return(0);
564: }

568: PETSC_EXTERN PetscErrorCode BVCreate_Vecs(BV bv)
569: {
571:   BV_VECS        *ctx;
572:   PetscInt       j;
573:   PetscBool      iscusp;
574:   char           str[50];

577:   PetscNewLog(bv,&ctx);
578:   bv->data = (void*)ctx;

580:   VecDuplicateVecs(bv->t,bv->m,&ctx->V);
581:   PetscLogObjectParents(bv,bv->m,ctx->V);
582:   if (((PetscObject)bv)->name) {
583:     for (j=0;j<bv->m;j++) {
584:       PetscSNPrintf(str,50,"%s_%D",((PetscObject)bv)->name,j);
585:       PetscObjectSetName((PetscObject)ctx->V[j],str);
586:     }
587:   }

589:   /* Default version of BVMultInPlace */
590:   PetscObjectTypeCompareAny((PetscObject)bv->t,&iscusp,VECSEQCUSP,VECMPICUSP,"");
591:   ctx->vmip = iscusp? 1: 0;

593:   /* Deferred call to setfromoptions */
594:   if (bv->defersfo) {
595:     PetscObjectOptionsBegin((PetscObject)bv);
596:     BVSetFromOptions_Vecs(PetscOptionsObject,bv);
597:     PetscOptionsEnd();
598:   }
599:   BVVecsSetVmip(bv,ctx->vmip);

601:   bv->ops->mult             = BVMult_Vecs;
602:   bv->ops->multvec          = BVMultVec_Vecs;
603:   bv->ops->multinplacetrans = BVMultInPlaceTranspose_Vecs;
604:   bv->ops->dot              = BVDot_Vecs;
605:   bv->ops->dotvec           = BVDotVec_Vecs;
606:   bv->ops->dotvec_begin     = BVDotVec_Begin_Vecs;
607:   bv->ops->dotvec_end       = BVDotVec_End_Vecs;
608:   bv->ops->scale            = BVScale_Vecs;
609:   bv->ops->norm             = BVNorm_Vecs;
610:   bv->ops->norm_begin       = BVNorm_Begin_Vecs;
611:   bv->ops->norm_end         = BVNorm_End_Vecs;
612:   bv->ops->matmult          = BVMatMult_Vecs;
613:   bv->ops->copy             = BVCopy_Vecs;
614:   bv->ops->resize           = BVResize_Vecs;
615:   bv->ops->getcolumn        = BVGetColumn_Vecs;
616:   bv->ops->getarray         = BVGetArray_Vecs;
617:   bv->ops->restorearray     = BVRestoreArray_Vecs;
618:   bv->ops->getarrayread     = BVGetArrayRead_Vecs;
619:   bv->ops->restorearrayread = BVRestoreArrayRead_Vecs;
620:   bv->ops->destroy          = BVDestroy_Vecs;
621:   bv->ops->duplicate        = BVDuplicate_Vecs;
622:   bv->ops->setfromoptions   = BVSetFromOptions_Vecs;
623:   bv->ops->view             = BVView_Vecs;
624:   return(0);
625: }

slepc-3.7.4/src/sys/classes/bv/impls/vecs/makefile.html0000644000175000017500000000470513107004621022371 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = vecs.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = BV
LOCDIR   = src/sys/classes/bv/impls/vecs/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/bv/impls/vecs/index.html0000644000175000017500000000202213107004621021711 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

vecs.c
makefile
slepc-3.7.4/src/sys/classes/bv/impls/makefile.html0000644000175000017500000000462113107004621021426 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcsys
DIRS     = vecs contiguous svec mat
LOCDIR   = src/sys/classes/bv/impls/
MANSEC   = BV

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/bv/impls/index.html0000644000175000017500000000214513107004621020757 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

vecs/
contiguous/
svec/
mat/
makefile
slepc-3.7.4/src/sys/classes/bv/impls/svec/0000755000175000017500000000000013107004621017720 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/impls/svec/makefile0000644000175000017500000000216413107004621021423 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = svec.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = BV LOCDIR = src/sys/classes/bv/impls/svec/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/impls/svec/makefile.html0000644000175000017500000000470513107004621022371 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = svec.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = BV
LOCDIR   = src/sys/classes/bv/impls/svec/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/bv/impls/svec/svec.c.html0000644000175000017500000007606013107004621022000 0ustar jromanjroman
Actual source code: svec.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV implemented as a single Vec

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>

 26: typedef struct {
 27:   Vec       v;
 28:   PetscBool mpi;
 29: } BV_SVEC;

 33: PetscErrorCode BVMult_Svec(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)
 34: {
 35:   PetscErrorCode    ierr;
 36:   BV_SVEC           *y = (BV_SVEC*)Y->data,*x = (BV_SVEC*)X->data;
 37:   const PetscScalar *px;
 38:   PetscScalar       *py,*q;
 39:   PetscInt          ldq;

 42:   VecGetArrayRead(x->v,&px);
 43:   VecGetArray(y->v,&py);
 44:   if (Q) {
 45:     MatGetSize(Q,&ldq,NULL);
 46:     MatDenseGetArray(Q,&q);
 47:     BVMult_BLAS_Private(Y,Y->n,Y->k-Y->l,X->k-X->l,ldq,alpha,px+(X->nc+X->l)*X->n,q+Y->l*ldq+X->l,beta,py+(Y->nc+Y->l)*Y->n);
 48:     MatDenseRestoreArray(Q,&q);
 49:   } else {
 50:     BVAXPY_BLAS_Private(Y,Y->n,Y->k-Y->l,alpha,px+(X->nc+X->l)*X->n,beta,py+(Y->nc+Y->l)*Y->n);
 51:   }
 52:   VecRestoreArrayRead(x->v,&px);
 53:   VecRestoreArray(y->v,&py);
 54:   return(0);
 55: }

 59: PetscErrorCode BVMultVec_Svec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)
 60: {
 62:   BV_SVEC        *x = (BV_SVEC*)X->data;
 63:   PetscScalar    *px,*py;

 66:   VecGetArray(x->v,&px);
 67:   VecGetArray(y,&py);
 68:   BVMultVec_BLAS_Private(X,X->n,X->k-X->l,alpha,px+(X->nc+X->l)*X->n,q,beta,py);
 69:   VecRestoreArray(x->v,&px);
 70:   VecRestoreArray(y,&py);
 71:   return(0);
 72: }

 76: PetscErrorCode BVMultInPlace_Svec(BV V,Mat Q,PetscInt s,PetscInt e)
 77: {
 79:   BV_SVEC        *ctx = (BV_SVEC*)V->data;
 80:   PetscScalar    *pv,*q;
 81:   PetscInt       ldq;

 84:   MatGetSize(Q,&ldq,NULL);
 85:   VecGetArray(ctx->v,&pv);
 86:   MatDenseGetArray(Q,&q);
 87:   BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_FALSE);
 88:   MatDenseRestoreArray(Q,&q);
 89:   VecRestoreArray(ctx->v,&pv);
 90:   return(0);
 91: }

 95: PetscErrorCode BVMultInPlaceTranspose_Svec(BV V,Mat Q,PetscInt s,PetscInt e)
 96: {
 98:   BV_SVEC        *ctx = (BV_SVEC*)V->data;
 99:   PetscScalar    *pv,*q;
100:   PetscInt       ldq;

103:   MatGetSize(Q,&ldq,NULL);
104:   VecGetArray(ctx->v,&pv);
105:   MatDenseGetArray(Q,&q);
106:   BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_TRUE);
107:   MatDenseRestoreArray(Q,&q);
108:   VecRestoreArray(ctx->v,&pv);
109:   return(0);
110: }

114: PetscErrorCode BVDot_Svec(BV X,BV Y,Mat M)
115: {
116:   PetscErrorCode    ierr;
117:   BV_SVEC           *x = (BV_SVEC*)X->data,*y = (BV_SVEC*)Y->data;
118:   const PetscScalar *px,*py;
119:   PetscScalar       *m;
120:   PetscInt          ldm;

123:   MatGetSize(M,&ldm,NULL);
124:   VecGetArrayRead(x->v,&px);
125:   VecGetArrayRead(y->v,&py);
126:   MatDenseGetArray(M,&m);
127:   BVDot_BLAS_Private(X,Y->k-Y->l,X->k-X->l,X->n,ldm,py+(Y->nc+Y->l)*Y->n,px+(X->nc+X->l)*X->n,m+X->l*ldm+Y->l,x->mpi);
128:   MatDenseRestoreArray(M,&m);
129:   VecRestoreArrayRead(x->v,&px);
130:   VecRestoreArrayRead(y->v,&py);
131:   return(0);
132: }

136: PetscErrorCode BVDotVec_Svec(BV X,Vec y,PetscScalar *m)
137: {
138:   PetscErrorCode    ierr;
139:   BV_SVEC           *x = (BV_SVEC*)X->data;
140:   const PetscScalar *px,*py;
141:   Vec               z = y;

144:   if (X->matrix) {
145:     BV_IPMatMult(X,y);
146:     z = X->Bx;
147:   }
148:   VecGetArrayRead(x->v,&px);
149:   VecGetArrayRead(z,&py);
150:   BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,x->mpi);
151:   VecRestoreArrayRead(z,&py);
152:   VecRestoreArrayRead(x->v,&px);
153:   return(0);
154: }

158: PetscErrorCode BVDotVec_Local_Svec(BV X,Vec y,PetscScalar *m)
159: {
161:   BV_SVEC        *x = (BV_SVEC*)X->data;
162:   PetscScalar    *px,*py;
163:   Vec            z = y;

166:   if (X->matrix) {
167:     BV_IPMatMult(X,y);
168:     z = X->Bx;
169:   }
170:   VecGetArray(x->v,&px);
171:   VecGetArray(z,&py);
172:   BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,PETSC_FALSE);
173:   VecRestoreArray(z,&py);
174:   VecRestoreArray(x->v,&px);
175:   return(0);
176: }

180: PetscErrorCode BVScale_Svec(BV bv,PetscInt j,PetscScalar alpha)
181: {
183:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;
184:   PetscScalar    *array;

187:   VecGetArray(ctx->v,&array);
188:   if (j<0) {
189:     BVScale_BLAS_Private(bv,(bv->k-bv->l)*bv->n,array+(bv->nc+bv->l)*bv->n,alpha);
190:   } else {
191:     BVScale_BLAS_Private(bv,bv->n,array+(bv->nc+j)*bv->n,alpha);
192:   }
193:   VecRestoreArray(ctx->v,&array);
194:   return(0);
195: }

199: PetscErrorCode BVNorm_Svec(BV bv,PetscInt j,NormType type,PetscReal *val)
200: {
202:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;
203:   PetscScalar    *array;

206:   VecGetArray(ctx->v,&array);
207:   if (j<0) {
208:     BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,ctx->mpi);
209:   } else {
210:     BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,ctx->mpi);
211:   }
212:   VecRestoreArray(ctx->v,&array);
213:   return(0);
214: }

218: PetscErrorCode BVNorm_Local_Svec(BV bv,PetscInt j,NormType type,PetscReal *val)
219: {
221:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;
222:   PetscScalar    *array;

225:   VecGetArray(ctx->v,&array);
226:   if (j<0) {
227:     BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,PETSC_FALSE);
228:   } else {
229:     BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,PETSC_FALSE);
230:   }
231:   VecRestoreArray(ctx->v,&array);
232:   return(0);
233: }

237: PetscErrorCode BVOrthogonalize_Svec(BV V,Mat R)
238: {
240:   BV_SVEC        *ctx = (BV_SVEC*)V->data;
241:   PetscScalar    *pv,*r=NULL;

244:   if (R) { MatDenseGetArray(R,&r); }
245:   VecGetArray(ctx->v,&pv);
246:   BVOrthogonalize_LAPACK_Private(V,V->n,V->k,pv+V->nc*V->n,r,ctx->mpi);
247:   VecRestoreArray(ctx->v,&pv);
248:   if (R) { MatDenseRestoreArray(R,&r); }
249:   return(0);
250: }

254: PetscErrorCode BVMatMult_Svec(BV V,Mat A,BV W)
255: {
257:   BV_SVEC        *v = (BV_SVEC*)V->data,*w = (BV_SVEC*)W->data;
258:   PetscScalar    *pv,*pw,*pb,*pc;
259:   PetscInt       j,m;
260:   PetscBool      flg;

263:   VecGetArray(v->v,&pv);
264:   VecGetArray(w->v,&pw);
265:   MatHasOperation(A,MATOP_MAT_MULT,&flg);
266:   if (V->vmm && flg) {
267:     m = V->k-V->l;
268:     if (V->vmm==BV_MATMULT_MAT_SAVE) {
269:       BV_AllocateMatMult(V,A,m);
270:       MatDenseGetArray(V->B,&pb);
271:       PetscMemcpy(pb,pv+(V->nc+V->l)*V->n,m*V->n*sizeof(PetscScalar));
272:       MatDenseRestoreArray(V->B,&pb);
273:     } else {  /* BV_MATMULT_MAT */
274:       MatCreateDense(PetscObjectComm((PetscObject)V),V->n,PETSC_DECIDE,V->N,m,pv+(V->nc+V->l)*V->n,&V->B);
275:     }
276:     if (!V->C) {
277:       MatMatMultSymbolic(A,V->B,PETSC_DEFAULT,&V->C);
278:     }
279:     MatMatMultNumeric(A,V->B,V->C);
280:     MatDenseGetArray(V->C,&pc);
281:     PetscMemcpy(pw+(W->nc+W->l)*W->n,pc,m*V->n*sizeof(PetscScalar));
282:     MatDenseRestoreArray(V->C,&pc);
283:     if (V->vmm==BV_MATMULT_MAT) {
284:       MatDestroy(&V->B);
285:       MatDestroy(&V->C);
286:     }
287:   } else {
288:     for (j=0;j<V->k-V->l;j++) {
289:       VecPlaceArray(V->cv[1],pv+(V->nc+V->l+j)*V->n);
290:       VecPlaceArray(W->cv[1],pw+(W->nc+W->l+j)*W->n);
291:       MatMult(A,V->cv[1],W->cv[1]);
292:       VecResetArray(V->cv[1]);
293:       VecResetArray(W->cv[1]);
294:     }
295:   }
296:   VecRestoreArray(v->v,&pv);
297:   VecRestoreArray(w->v,&pw);
298:   return(0);
299: }

303: PetscErrorCode BVCopy_Svec(BV V,BV W)
304: {
306:   BV_SVEC        *v = (BV_SVEC*)V->data,*w = (BV_SVEC*)W->data;
307:   PetscScalar    *pv,*pw,*pvc,*pwc;

310:   VecGetArray(v->v,&pv);
311:   VecGetArray(w->v,&pw);
312:   pvc = pv+(V->nc+V->l)*V->n;
313:   pwc = pw+(W->nc+W->l)*W->n;
314:   PetscMemcpy(pwc,pvc,(V->k-V->l)*V->n*sizeof(PetscScalar));
315:   VecRestoreArray(v->v,&pv);
316:   VecRestoreArray(w->v,&pw);
317:   return(0);
318: }

322: PetscErrorCode BVResize_Svec(BV bv,PetscInt m,PetscBool copy)
323: {
325:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;
326:   PetscScalar    *pv,*pnew;
327:   PetscInt       bs;
328:   Vec            vnew;
329:   char           str[50];

332:   VecGetBlockSize(bv->t,&bs);
333:   VecCreate(PetscObjectComm((PetscObject)bv->t),&vnew);
334:   VecSetType(vnew,((PetscObject)bv->t)->type_name);
335:   VecSetSizes(vnew,m*bv->n,PETSC_DECIDE);
336:   VecSetBlockSize(vnew,bs);
337:   PetscLogObjectParent((PetscObject)bv,(PetscObject)vnew);
338:   if (((PetscObject)bv)->name) {
339:     PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);
340:     PetscObjectSetName((PetscObject)vnew,str);
341:   }
342:   if (copy) {
343:     VecGetArray(ctx->v,&pv);
344:     VecGetArray(vnew,&pnew);
345:     PetscMemcpy(pnew,pv,PetscMin(m,bv->m)*bv->n*sizeof(PetscScalar));
346:     VecRestoreArray(ctx->v,&pv);
347:     VecRestoreArray(vnew,&pnew);
348:   }
349:   VecDestroy(&ctx->v);
350:   ctx->v = vnew;
351:   return(0);
352: }

356: PetscErrorCode BVGetColumn_Svec(BV bv,PetscInt j,Vec *v)
357: {
359:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;
360:   PetscScalar    *pv;
361:   PetscInt       l;

364:   l = BVAvailableVec;
365:   VecGetArray(ctx->v,&pv);
366:   VecPlaceArray(bv->cv[l],pv+(bv->nc+j)*bv->n);
367:   return(0);
368: }

372: PetscErrorCode BVRestoreColumn_Svec(BV bv,PetscInt j,Vec *v)
373: {
375:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;
376:   PetscInt       l;

379:   l = (j==bv->ci[0])? 0: 1;
380:   VecResetArray(bv->cv[l]);
381:   VecRestoreArray(ctx->v,NULL);
382:   return(0);
383: }

387: PetscErrorCode BVGetArray_Svec(BV bv,PetscScalar **a)
388: {
390:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;

393:   VecGetArray(ctx->v,a);
394:   return(0);
395: }

399: PetscErrorCode BVRestoreArray_Svec(BV bv,PetscScalar **a)
400: {
402:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;

405:   VecRestoreArray(ctx->v,a);
406:   return(0);
407: }

411: PetscErrorCode BVGetArrayRead_Svec(BV bv,const PetscScalar **a)
412: {
414:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;

417:   VecGetArrayRead(ctx->v,a);
418:   return(0);
419: }

423: PetscErrorCode BVRestoreArrayRead_Svec(BV bv,const PetscScalar **a)
424: {
426:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;

429:   VecRestoreArrayRead(ctx->v,a);
430:   return(0);
431: }

435: PetscErrorCode BVView_Svec(BV bv,PetscViewer viewer)
436: {
437:   PetscErrorCode    ierr;
438:   BV_SVEC           *ctx = (BV_SVEC*)bv->data;
439:   PetscViewerFormat format;
440:   PetscBool         isascii;
441:   const char        *bvname,*name;

444:   VecView(ctx->v,viewer);
445:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
446:   if (isascii) {
447:     PetscViewerGetFormat(viewer,&format);
448:     if (format == PETSC_VIEWER_ASCII_MATLAB) {
449:       PetscObjectGetName((PetscObject)bv,&bvname);
450:       PetscObjectGetName((PetscObject)ctx->v,&name);
451:       PetscViewerASCIIPrintf(viewer,"%s=reshape(%s,%D,%D);clear %s\n",bvname,name,bv->N,bv->nc+bv->m,name);
452:       if (bv->nc) {
453:         PetscViewerASCIIPrintf(viewer,"%s=%s(:,%D:end);\n",bvname,bvname,bv->nc+1);
454:       }
455:     }
456:   }
457:   return(0);
458: }

462: PetscErrorCode BVDestroy_Svec(BV bv)
463: {
465:   BV_SVEC        *ctx = (BV_SVEC*)bv->data;

468:   VecDestroy(&ctx->v);
469:   VecDestroy(&bv->cv[0]);
470:   VecDestroy(&bv->cv[1]);
471:   PetscFree(bv->data);
472:   return(0);
473: }

477: PETSC_EXTERN PetscErrorCode BVCreate_Svec(BV bv)
478: {
480:   BV_SVEC        *ctx;
481:   PetscInt       nloc,bs;
482:   PetscBool      seq;
483:   char           str[50];

486:   PetscNewLog(bv,&ctx);
487:   bv->data = (void*)ctx;

489:   PetscObjectTypeCompare((PetscObject)bv->t,VECMPI,&ctx->mpi);
490:   if (!ctx->mpi) {
491:     PetscObjectTypeCompare((PetscObject)bv->t,VECSEQ,&seq);
492:     if (!seq) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot create a BVSVEC from a non-standard template vector");
493:   }

495:   VecGetLocalSize(bv->t,&nloc);
496:   VecGetBlockSize(bv->t,&bs);

498:   VecCreate(PetscObjectComm((PetscObject)bv->t),&ctx->v);
499:   VecSetType(ctx->v,((PetscObject)bv->t)->type_name);
500:   VecSetSizes(ctx->v,bv->m*nloc,PETSC_DECIDE);
501:   VecSetBlockSize(ctx->v,bs);
502:   PetscLogObjectParent((PetscObject)bv,(PetscObject)ctx->v);
503:   if (((PetscObject)bv)->name) {
504:     PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);
505:     PetscObjectSetName((PetscObject)ctx->v,str);
506:   }

508:   if (ctx->mpi) {
509:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[0]);
510:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[1]);
511:   } else {
512:     VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[0]);
513:     VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[1]);
514:   }

516:   bv->ops->mult             = BVMult_Svec;
517:   bv->ops->multvec          = BVMultVec_Svec;
518:   bv->ops->multinplace      = BVMultInPlace_Svec;
519:   bv->ops->multinplacetrans = BVMultInPlaceTranspose_Svec;
520:   bv->ops->dot              = BVDot_Svec;
521:   bv->ops->dotvec           = BVDotVec_Svec;
522:   bv->ops->dotvec_local     = BVDotVec_Local_Svec;
523:   bv->ops->scale            = BVScale_Svec;
524:   bv->ops->norm             = BVNorm_Svec;
525:   bv->ops->norm_local       = BVNorm_Local_Svec;
526:   /*bv->ops->orthogonalize    = BVOrthogonalize_Svec;*/
527:   bv->ops->matmult          = BVMatMult_Svec;
528:   bv->ops->copy             = BVCopy_Svec;
529:   bv->ops->resize           = BVResize_Svec;
530:   bv->ops->getcolumn        = BVGetColumn_Svec;
531:   bv->ops->restorecolumn    = BVRestoreColumn_Svec;
532:   bv->ops->getarray         = BVGetArray_Svec;
533:   bv->ops->restorearray     = BVRestoreArray_Svec;
534:   bv->ops->getarrayread     = BVGetArrayRead_Svec;
535:   bv->ops->restorearrayread = BVRestoreArrayRead_Svec;
536:   bv->ops->destroy          = BVDestroy_Svec;
537:   if (!ctx->mpi) bv->ops->view = BVView_Svec;
538:   return(0);
539: }

slepc-3.7.4/src/sys/classes/bv/impls/svec/svec.c0000644000175000017500000004420013107004621021024 0ustar jromanjroman/* BV implemented as a single Vec - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include typedef struct { Vec v; PetscBool mpi; } BV_SVEC; #undef __FUNCT__ #define __FUNCT__ "BVMult_Svec" PetscErrorCode BVMult_Svec(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q) { PetscErrorCode ierr; BV_SVEC *y = (BV_SVEC*)Y->data,*x = (BV_SVEC*)X->data; const PetscScalar *px; PetscScalar *py,*q; PetscInt ldq; PetscFunctionBegin; ierr = VecGetArrayRead(x->v,&px);CHKERRQ(ierr); ierr = VecGetArray(y->v,&py);CHKERRQ(ierr); if (Q) { ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMult_BLAS_Private(Y,Y->n,Y->k-Y->l,X->k-X->l,ldq,alpha,px+(X->nc+X->l)*X->n,q+Y->l*ldq+X->l,beta,py+(Y->nc+Y->l)*Y->n);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); } else { ierr = BVAXPY_BLAS_Private(Y,Y->n,Y->k-Y->l,alpha,px+(X->nc+X->l)*X->n,beta,py+(Y->nc+Y->l)*Y->n);CHKERRQ(ierr); } ierr = VecRestoreArrayRead(x->v,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y->v,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultVec_Svec" PetscErrorCode BVMultVec_Svec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q) { PetscErrorCode ierr; BV_SVEC *x = (BV_SVEC*)X->data; PetscScalar *px,*py; PetscFunctionBegin; ierr = VecGetArray(x->v,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = BVMultVec_BLAS_Private(X,X->n,X->k-X->l,alpha,px+(X->nc+X->l)*X->n,q,beta,py);CHKERRQ(ierr); ierr = VecRestoreArray(x->v,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlace_Svec" PetscErrorCode BVMultInPlace_Svec(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)V->data; PetscScalar *pv,*q; PetscInt ldq; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = VecGetArray(ctx->v,&pv);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_FALSE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); ierr = VecRestoreArray(ctx->v,&pv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlaceTranspose_Svec" PetscErrorCode BVMultInPlaceTranspose_Svec(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)V->data; PetscScalar *pv,*q; PetscInt ldq; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = VecGetArray(ctx->v,&pv);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,pv+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_TRUE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); ierr = VecRestoreArray(ctx->v,&pv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDot_Svec" PetscErrorCode BVDot_Svec(BV X,BV Y,Mat M) { PetscErrorCode ierr; BV_SVEC *x = (BV_SVEC*)X->data,*y = (BV_SVEC*)Y->data; const PetscScalar *px,*py; PetscScalar *m; PetscInt ldm; PetscFunctionBegin; ierr = MatGetSize(M,&ldm,NULL);CHKERRQ(ierr); ierr = VecGetArrayRead(x->v,&px);CHKERRQ(ierr); ierr = VecGetArrayRead(y->v,&py);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&m);CHKERRQ(ierr); ierr = BVDot_BLAS_Private(X,Y->k-Y->l,X->k-X->l,X->n,ldm,py+(Y->nc+Y->l)*Y->n,px+(X->nc+X->l)*X->n,m+X->l*ldm+Y->l,x->mpi);CHKERRQ(ierr); ierr = MatDenseRestoreArray(M,&m);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x->v,&px);CHKERRQ(ierr); ierr = VecRestoreArrayRead(y->v,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Svec" PetscErrorCode BVDotVec_Svec(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_SVEC *x = (BV_SVEC*)X->data; const PetscScalar *px,*py; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = VecGetArrayRead(x->v,&px);CHKERRQ(ierr); ierr = VecGetArrayRead(z,&py);CHKERRQ(ierr); ierr = BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,x->mpi);CHKERRQ(ierr); ierr = VecRestoreArrayRead(z,&py);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x->v,&px);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Local_Svec" PetscErrorCode BVDotVec_Local_Svec(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_SVEC *x = (BV_SVEC*)X->data; PetscScalar *px,*py; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = VecGetArray(x->v,&px);CHKERRQ(ierr); ierr = VecGetArray(z,&py);CHKERRQ(ierr); ierr = BVDotVec_BLAS_Private(X,X->n,X->k-X->l,px+(X->nc+X->l)*X->n,py,m,PETSC_FALSE);CHKERRQ(ierr); ierr = VecRestoreArray(z,&py);CHKERRQ(ierr); ierr = VecRestoreArray(x->v,&px);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVScale_Svec" PetscErrorCode BVScale_Svec(BV bv,PetscInt j,PetscScalar alpha) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscScalar *array; PetscFunctionBegin; ierr = VecGetArray(ctx->v,&array);CHKERRQ(ierr); if (j<0) { ierr = BVScale_BLAS_Private(bv,(bv->k-bv->l)*bv->n,array+(bv->nc+bv->l)*bv->n,alpha);CHKERRQ(ierr); } else { ierr = BVScale_BLAS_Private(bv,bv->n,array+(bv->nc+j)*bv->n,alpha);CHKERRQ(ierr); } ierr = VecRestoreArray(ctx->v,&array);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Svec" PetscErrorCode BVNorm_Svec(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscScalar *array; PetscFunctionBegin; ierr = VecGetArray(ctx->v,&array);CHKERRQ(ierr); if (j<0) { ierr = BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,ctx->mpi);CHKERRQ(ierr); } else { ierr = BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,ctx->mpi);CHKERRQ(ierr); } ierr = VecRestoreArray(ctx->v,&array);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Local_Svec" PetscErrorCode BVNorm_Local_Svec(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscScalar *array; PetscFunctionBegin; ierr = VecGetArray(ctx->v,&array);CHKERRQ(ierr); if (j<0) { ierr = BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,array+(bv->nc+bv->l)*bv->n,type,val,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = BVNorm_LAPACK_Private(bv,bv->n,1,array+(bv->nc+j)*bv->n,type,val,PETSC_FALSE);CHKERRQ(ierr); } ierr = VecRestoreArray(ctx->v,&array);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalize_Svec" PetscErrorCode BVOrthogonalize_Svec(BV V,Mat R) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)V->data; PetscScalar *pv,*r=NULL; PetscFunctionBegin; if (R) { ierr = MatDenseGetArray(R,&r);CHKERRQ(ierr); } ierr = VecGetArray(ctx->v,&pv);CHKERRQ(ierr); ierr = BVOrthogonalize_LAPACK_Private(V,V->n,V->k,pv+V->nc*V->n,r,ctx->mpi);CHKERRQ(ierr); ierr = VecRestoreArray(ctx->v,&pv);CHKERRQ(ierr); if (R) { ierr = MatDenseRestoreArray(R,&r);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatMult_Svec" PetscErrorCode BVMatMult_Svec(BV V,Mat A,BV W) { PetscErrorCode ierr; BV_SVEC *v = (BV_SVEC*)V->data,*w = (BV_SVEC*)W->data; PetscScalar *pv,*pw,*pb,*pc; PetscInt j,m; PetscBool flg; PetscFunctionBegin; ierr = VecGetArray(v->v,&pv);CHKERRQ(ierr); ierr = VecGetArray(w->v,&pw);CHKERRQ(ierr); ierr = MatHasOperation(A,MATOP_MAT_MULT,&flg);CHKERRQ(ierr); if (V->vmm && flg) { m = V->k-V->l; if (V->vmm==BV_MATMULT_MAT_SAVE) { ierr = BV_AllocateMatMult(V,A,m);CHKERRQ(ierr); ierr = MatDenseGetArray(V->B,&pb);CHKERRQ(ierr); ierr = PetscMemcpy(pb,pv+(V->nc+V->l)*V->n,m*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(V->B,&pb);CHKERRQ(ierr); } else { /* BV_MATMULT_MAT */ ierr = MatCreateDense(PetscObjectComm((PetscObject)V),V->n,PETSC_DECIDE,V->N,m,pv+(V->nc+V->l)*V->n,&V->B);CHKERRQ(ierr); } if (!V->C) { ierr = MatMatMultSymbolic(A,V->B,PETSC_DEFAULT,&V->C);CHKERRQ(ierr); } ierr = MatMatMultNumeric(A,V->B,V->C);CHKERRQ(ierr); ierr = MatDenseGetArray(V->C,&pc);CHKERRQ(ierr); ierr = PetscMemcpy(pw+(W->nc+W->l)*W->n,pc,m*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(V->C,&pc);CHKERRQ(ierr); if (V->vmm==BV_MATMULT_MAT) { ierr = MatDestroy(&V->B);CHKERRQ(ierr); ierr = MatDestroy(&V->C);CHKERRQ(ierr); } } else { for (j=0;jk-V->l;j++) { ierr = VecPlaceArray(V->cv[1],pv+(V->nc+V->l+j)*V->n);CHKERRQ(ierr); ierr = VecPlaceArray(W->cv[1],pw+(W->nc+W->l+j)*W->n);CHKERRQ(ierr); ierr = MatMult(A,V->cv[1],W->cv[1]);CHKERRQ(ierr); ierr = VecResetArray(V->cv[1]);CHKERRQ(ierr); ierr = VecResetArray(W->cv[1]);CHKERRQ(ierr); } } ierr = VecRestoreArray(v->v,&pv);CHKERRQ(ierr); ierr = VecRestoreArray(w->v,&pw);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCopy_Svec" PetscErrorCode BVCopy_Svec(BV V,BV W) { PetscErrorCode ierr; BV_SVEC *v = (BV_SVEC*)V->data,*w = (BV_SVEC*)W->data; PetscScalar *pv,*pw,*pvc,*pwc; PetscFunctionBegin; ierr = VecGetArray(v->v,&pv);CHKERRQ(ierr); ierr = VecGetArray(w->v,&pw);CHKERRQ(ierr); pvc = pv+(V->nc+V->l)*V->n; pwc = pw+(W->nc+W->l)*W->n; ierr = PetscMemcpy(pwc,pvc,(V->k-V->l)*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArray(v->v,&pv);CHKERRQ(ierr); ierr = VecRestoreArray(w->v,&pw);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVResize_Svec" PetscErrorCode BVResize_Svec(BV bv,PetscInt m,PetscBool copy) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscScalar *pv,*pnew; PetscInt bs; Vec vnew; char str[50]; PetscFunctionBegin; ierr = VecGetBlockSize(bv->t,&bs);CHKERRQ(ierr); ierr = VecCreate(PetscObjectComm((PetscObject)bv->t),&vnew);CHKERRQ(ierr); ierr = VecSetType(vnew,((PetscObject)bv->t)->type_name);CHKERRQ(ierr); ierr = VecSetSizes(vnew,m*bv->n,PETSC_DECIDE);CHKERRQ(ierr); ierr = VecSetBlockSize(vnew,bs);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)vnew);CHKERRQ(ierr); if (((PetscObject)bv)->name) { ierr = PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)vnew,str);CHKERRQ(ierr); } if (copy) { ierr = VecGetArray(ctx->v,&pv);CHKERRQ(ierr); ierr = VecGetArray(vnew,&pnew);CHKERRQ(ierr); ierr = PetscMemcpy(pnew,pv,PetscMin(m,bv->m)*bv->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArray(ctx->v,&pv);CHKERRQ(ierr); ierr = VecRestoreArray(vnew,&pnew);CHKERRQ(ierr); } ierr = VecDestroy(&ctx->v);CHKERRQ(ierr); ctx->v = vnew; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetColumn_Svec" PetscErrorCode BVGetColumn_Svec(BV bv,PetscInt j,Vec *v) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscScalar *pv; PetscInt l; PetscFunctionBegin; l = BVAvailableVec; ierr = VecGetArray(ctx->v,&pv);CHKERRQ(ierr); ierr = VecPlaceArray(bv->cv[l],pv+(bv->nc+j)*bv->n);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreColumn_Svec" PetscErrorCode BVRestoreColumn_Svec(BV bv,PetscInt j,Vec *v) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscInt l; PetscFunctionBegin; l = (j==bv->ci[0])? 0: 1; ierr = VecResetArray(bv->cv[l]);CHKERRQ(ierr); ierr = VecRestoreArray(ctx->v,NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArray_Svec" PetscErrorCode BVGetArray_Svec(BV bv,PetscScalar **a) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscFunctionBegin; ierr = VecGetArray(ctx->v,a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArray_Svec" PetscErrorCode BVRestoreArray_Svec(BV bv,PetscScalar **a) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscFunctionBegin; ierr = VecRestoreArray(ctx->v,a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArrayRead_Svec" PetscErrorCode BVGetArrayRead_Svec(BV bv,const PetscScalar **a) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscFunctionBegin; ierr = VecGetArrayRead(ctx->v,a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVRestoreArrayRead_Svec" PetscErrorCode BVRestoreArrayRead_Svec(BV bv,const PetscScalar **a) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscFunctionBegin; ierr = VecRestoreArrayRead(ctx->v,a);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVView_Svec" PetscErrorCode BVView_Svec(BV bv,PetscViewer viewer) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscViewerFormat format; PetscBool isascii; const char *bvname,*name; PetscFunctionBegin; ierr = VecView(ctx->v,viewer);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); if (format == PETSC_VIEWER_ASCII_MATLAB) { ierr = PetscObjectGetName((PetscObject)bv,&bvname);CHKERRQ(ierr); ierr = PetscObjectGetName((PetscObject)ctx->v,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s=reshape(%s,%D,%D);clear %s\n",bvname,name,bv->N,bv->nc+bv->m,name);CHKERRQ(ierr); if (bv->nc) { ierr = PetscViewerASCIIPrintf(viewer,"%s=%s(:,%D:end);\n",bvname,bvname,bv->nc+1);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDestroy_Svec" PetscErrorCode BVDestroy_Svec(BV bv) { PetscErrorCode ierr; BV_SVEC *ctx = (BV_SVEC*)bv->data; PetscFunctionBegin; ierr = VecDestroy(&ctx->v);CHKERRQ(ierr); ierr = VecDestroy(&bv->cv[0]);CHKERRQ(ierr); ierr = VecDestroy(&bv->cv[1]);CHKERRQ(ierr); ierr = PetscFree(bv->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCreate_Svec" PETSC_EXTERN PetscErrorCode BVCreate_Svec(BV bv) { PetscErrorCode ierr; BV_SVEC *ctx; PetscInt nloc,bs; PetscBool seq; char str[50]; PetscFunctionBegin; ierr = PetscNewLog(bv,&ctx);CHKERRQ(ierr); bv->data = (void*)ctx; ierr = PetscObjectTypeCompare((PetscObject)bv->t,VECMPI,&ctx->mpi);CHKERRQ(ierr); if (!ctx->mpi) { ierr = PetscObjectTypeCompare((PetscObject)bv->t,VECSEQ,&seq);CHKERRQ(ierr); if (!seq) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot create a BVSVEC from a non-standard template vector"); } ierr = VecGetLocalSize(bv->t,&nloc);CHKERRQ(ierr); ierr = VecGetBlockSize(bv->t,&bs);CHKERRQ(ierr); ierr = VecCreate(PetscObjectComm((PetscObject)bv->t),&ctx->v);CHKERRQ(ierr); ierr = VecSetType(ctx->v,((PetscObject)bv->t)->type_name);CHKERRQ(ierr); ierr = VecSetSizes(ctx->v,bv->m*nloc,PETSC_DECIDE);CHKERRQ(ierr); ierr = VecSetBlockSize(ctx->v,bs);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)bv,(PetscObject)ctx->v);CHKERRQ(ierr); if (((PetscObject)bv)->name) { ierr = PetscSNPrintf(str,50,"%s_0",((PetscObject)bv)->name);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)ctx->v,str);CHKERRQ(ierr); } if (ctx->mpi) { ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[0]);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,NULL,&bv->cv[1]);CHKERRQ(ierr); } else { ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[0]);CHKERRQ(ierr); ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,NULL,&bv->cv[1]);CHKERRQ(ierr); } bv->ops->mult = BVMult_Svec; bv->ops->multvec = BVMultVec_Svec; bv->ops->multinplace = BVMultInPlace_Svec; bv->ops->multinplacetrans = BVMultInPlaceTranspose_Svec; bv->ops->dot = BVDot_Svec; bv->ops->dotvec = BVDotVec_Svec; bv->ops->dotvec_local = BVDotVec_Local_Svec; bv->ops->scale = BVScale_Svec; bv->ops->norm = BVNorm_Svec; bv->ops->norm_local = BVNorm_Local_Svec; /*bv->ops->orthogonalize = BVOrthogonalize_Svec;*/ bv->ops->matmult = BVMatMult_Svec; bv->ops->copy = BVCopy_Svec; bv->ops->resize = BVResize_Svec; bv->ops->getcolumn = BVGetColumn_Svec; bv->ops->restorecolumn = BVRestoreColumn_Svec; bv->ops->getarray = BVGetArray_Svec; bv->ops->restorearray = BVRestoreArray_Svec; bv->ops->getarrayread = BVGetArrayRead_Svec; bv->ops->restorearrayread = BVRestoreArrayRead_Svec; bv->ops->destroy = BVDestroy_Svec; if (!ctx->mpi) bv->ops->view = BVView_Svec; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/bv/impls/svec/index.html0000644000175000017500000000202213107004621021711 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

svec.c
makefile
slepc-3.7.4/src/sys/classes/bv/impls/contiguous/0000755000175000017500000000000013107004621021157 5ustar jromanjromanslepc-3.7.4/src/sys/classes/bv/impls/contiguous/makefile0000644000175000017500000000217413107004621022663 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = contig.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = BV LOCDIR = src/sys/classes/bv/impls/contiguous/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/bv/impls/contiguous/makefile.html0000644000175000017500000000473113107004621023627 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = contig.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = BV
LOCDIR   = src/sys/classes/bv/impls/contiguous/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/bv/impls/contiguous/index.html0000644000175000017500000000204213107004621023152 0ustar jromanjroman Basis Vectors - BV
slepc-3.7.4 2017-05-17

Basis Vectors - BV

The BV package provides the concept of a block of vectors that represent the basis of a subspace. It is a convenient way of handling a collection of vectors that often operate together, rather than working with an array of Vec.

These routines are usually not needed by application programmers.

contig.c
makefile
slepc-3.7.4/src/sys/classes/bv/impls/contiguous/contig.c.html0000644000175000017500000006333313107004621023561 0ustar jromanjroman

Actual source code: contig.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    BV implemented as an array of Vecs sharing a contiguous array for elements

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/bvimpl.h>

 26: typedef struct {
 27:   Vec         *V;
 28:   PetscScalar *array;
 29:   PetscBool   mpi;
 30: } BV_CONTIGUOUS;

 34: PetscErrorCode BVMult_Contiguous(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)
 35: {
 37:   BV_CONTIGUOUS  *y = (BV_CONTIGUOUS*)Y->data,*x = (BV_CONTIGUOUS*)X->data;
 38:   PetscScalar    *q;
 39:   PetscInt       ldq;

 42:   if (Q) {
 43:     MatGetSize(Q,&ldq,NULL);
 44:     MatDenseGetArray(Q,&q);
 45:     BVMult_BLAS_Private(Y,Y->n,Y->k-Y->l,X->k-X->l,ldq,alpha,x->array+(X->nc+X->l)*X->n,q+Y->l*ldq+X->l,beta,y->array+(Y->nc+Y->l)*Y->n);
 46:     MatDenseRestoreArray(Q,&q);
 47:   } else {
 48:     BVAXPY_BLAS_Private(Y,Y->n,Y->k-Y->l,alpha,x->array+(X->nc+X->l)*X->n,beta,y->array+(Y->nc+Y->l)*Y->n);
 49:   }
 50:   return(0);
 51: }

 55: PetscErrorCode BVMultVec_Contiguous(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)
 56: {
 58:   BV_CONTIGUOUS  *x = (BV_CONTIGUOUS*)X->data;
 59:   PetscScalar    *py;

 62:   VecGetArray(y,&py);
 63:   BVMultVec_BLAS_Private(X,X->n,X->k-X->l,alpha,x->array+(X->nc+X->l)*X->n,q,beta,py);
 64:   VecRestoreArray(y,&py);
 65:   return(0);
 66: }

 70: PetscErrorCode BVMultInPlace_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e)
 71: {
 73:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)V->data;
 74:   PetscScalar    *q;
 75:   PetscInt       ldq;

 78:   MatGetSize(Q,&ldq,NULL);
 79:   MatDenseGetArray(Q,&q);
 80:   BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,ctx->array+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_FALSE);
 81:   MatDenseRestoreArray(Q,&q);
 82:   return(0);
 83: }

 87: PetscErrorCode BVMultInPlaceTranspose_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e)
 88: {
 90:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)V->data;
 91:   PetscScalar    *q;
 92:   PetscInt       ldq;

 95:   MatGetSize(Q,&ldq,NULL);
 96:   MatDenseGetArray(Q,&q);
 97:   BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,ctx->array+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_TRUE);
 98:   MatDenseRestoreArray(Q,&q);
 99:   return(0);
100: }

104: PetscErrorCode BVDot_Contiguous(BV X,BV Y,Mat M)
105: {
107:   BV_CONTIGUOUS  *x = (BV_CONTIGUOUS*)X->data,*y = (BV_CONTIGUOUS*)Y->data;
108:   PetscScalar    *m;
109:   PetscInt       ldm;

112:   MatGetSize(M,&ldm,NULL);
113:   MatDenseGetArray(M,&m);
114:   BVDot_BLAS_Private(X,Y->k-Y->l,X->k-X->l,X->n,ldm,y->array+(Y->nc+Y->l)*Y->n,x->array+(X->nc+X->l)*X->n,m+X->l*ldm+Y->l,x->mpi);
115:   MatDenseRestoreArray(M,&m);
116:   return(0);
117: }

121: PetscErrorCode BVDotVec_Contiguous(BV X,Vec y,PetscScalar *m)
122: {
123:   PetscErrorCode    ierr;
124:   BV_CONTIGUOUS     *x = (BV_CONTIGUOUS*)X->data;
125:   const PetscScalar *py;
126:   Vec               z = y;

129:   if (X->matrix) {
130:     BV_IPMatMult(X,y);
131:     z = X->Bx;
132:   }
133:   VecGetArrayRead(z,&py);
134:   BVDotVec_BLAS_Private(X,X->n,X->k-X->l,x->array+(X->nc+X->l)*X->n,py,m,x->mpi);
135:   VecRestoreArrayRead(z,&py);
136:   return(0);
137: }

141: PetscErrorCode BVDotVec_Local_Contiguous(BV X,Vec y,PetscScalar *m)
142: {
144:   BV_CONTIGUOUS  *x = (BV_CONTIGUOUS*)X->data;
145:   PetscScalar    *py;
146:   Vec            z = y;

149:   if (X->matrix) {
150:     BV_IPMatMult(X,y);
151:     z = X->Bx;
152:   }
153:   VecGetArray(z,&py);
154:   BVDotVec_BLAS_Private(X,X->n,X->k-X->l,x->array+(X->nc+X->l)*X->n,py,m,PETSC_FALSE);
155:   VecRestoreArray(z,&py);
156:   return(0);
157: }

161: PetscErrorCode BVScale_Contiguous(BV bv,PetscInt j,PetscScalar alpha)
162: {
164:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)bv->data;

167:   if (j<0) {
168:     BVScale_BLAS_Private(bv,(bv->k-bv->l)*bv->n,ctx->array+(bv->nc+bv->l)*bv->n,alpha);
169:   } else {
170:     BVScale_BLAS_Private(bv,bv->n,ctx->array+(bv->nc+j)*bv->n,alpha);
171:   }
172:   return(0);
173: }

177: PetscErrorCode BVNorm_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val)
178: {
180:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)bv->data;

183:   if (j<0) {
184:     BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,ctx->array+(bv->nc+bv->l)*bv->n,type,val,ctx->mpi);
185:   } else {
186:     BVNorm_LAPACK_Private(bv,bv->n,1,ctx->array+(bv->nc+j)*bv->n,type,val,ctx->mpi);
187:   }
188:   return(0);
189: }

193: PetscErrorCode BVNorm_Local_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val)
194: {
196:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)bv->data;

199:   if (j<0) {
200:     BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,ctx->array+(bv->nc+bv->l)*bv->n,type,val,PETSC_FALSE);
201:   } else {
202:     BVNorm_LAPACK_Private(bv,bv->n,1,ctx->array+(bv->nc+j)*bv->n,type,val,PETSC_FALSE);
203:   }
204:   return(0);
205: }

209: PetscErrorCode BVOrthogonalize_Contiguous(BV V,Mat R)
210: {
212:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)V->data;
213:   PetscScalar    *r=NULL;

216:   if (R) { MatDenseGetArray(R,&r); }
217:   BVOrthogonalize_LAPACK_Private(V,V->n,V->k,ctx->array+V->nc*V->n,r,ctx->mpi);
218:   if (R) { MatDenseRestoreArray(R,&r); }
219:   return(0);
220: }

224: PetscErrorCode BVMatMult_Contiguous(BV V,Mat A,BV W)
225: {
227:   BV_CONTIGUOUS  *v = (BV_CONTIGUOUS*)V->data,*w = (BV_CONTIGUOUS*)W->data;
228:   PetscScalar    *pb,*pc;
229:   PetscInt       j,m;
230:   PetscBool      flg;

233:   MatHasOperation(A,MATOP_MAT_MULT,&flg);
234:   if (V->vmm && flg) {
235:     m = V->k-V->l;
236:     if (V->vmm==BV_MATMULT_MAT_SAVE) {
237:       BV_AllocateMatMult(V,A,m);
238:       MatDenseGetArray(V->B,&pb);
239:       PetscMemcpy(pb,v->array+(V->nc+V->l)*V->n,m*V->n*sizeof(PetscScalar));
240:       MatDenseRestoreArray(V->B,&pb);
241:     } else {  /* BV_MATMULT_MAT */
242:       MatCreateDense(PetscObjectComm((PetscObject)V),V->n,PETSC_DECIDE,V->N,m,v->array+(V->nc+V->l)*V->n,&V->B);
243:     }
244:     if (!V->C) {
245:       MatMatMultSymbolic(A,V->B,PETSC_DEFAULT,&V->C);
246:     }
247:     MatMatMultNumeric(A,V->B,V->C);
248:     MatDenseGetArray(V->C,&pc);
249:     PetscMemcpy(w->array+(W->nc+W->l)*W->n,pc,m*V->n*sizeof(PetscScalar));
250:     MatDenseRestoreArray(V->C,&pc);
251:     if (V->vmm==BV_MATMULT_MAT) {
252:       MatDestroy(&V->B);
253:       MatDestroy(&V->C);
254:     }
255:   } else {
256:     for (j=0;j<V->k-V->l;j++) {
257:       MatMult(A,v->V[V->nc+V->l+j],w->V[W->nc+W->l+j]);
258:     }
259:   }
260:   return(0);
261: }

265: PetscErrorCode BVCopy_Contiguous(BV V,BV W)
266: {
268:   BV_CONTIGUOUS  *v = (BV_CONTIGUOUS*)V->data,*w = (BV_CONTIGUOUS*)W->data;
269:   PetscScalar    *pvc,*pwc;

272:   pvc = v->array+(V->nc+V->l)*V->n;
273:   pwc = w->array+(W->nc+W->l)*W->n;
274:   PetscMemcpy(pwc,pvc,(V->k-V->l)*V->n*sizeof(PetscScalar));
275:   return(0);
276: }

280: PetscErrorCode BVResize_Contiguous(BV bv,PetscInt m,PetscBool copy)
281: {
283:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)bv->data;
284:   PetscInt       j,bs;
285:   PetscScalar    *newarray;
286:   Vec            *newV;
287:   char           str[50];

290:   VecGetBlockSize(bv->t,&bs);
291:   PetscMalloc1(m*bv->n,&newarray);
292:   PetscMemzero(newarray,m*bv->n*sizeof(PetscScalar));
293:   PetscMalloc1(m,&newV);
294:   for (j=0;j<m;j++) {
295:     if (ctx->mpi) {
296:       VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,bv->n,PETSC_DECIDE,newarray+j*bv->n,newV+j);
297:     } else {
298:       VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,bv->n,newarray+j*bv->n,newV+j);
299:     }
300:   }
301:   PetscLogObjectParents(bv,m,newV);
302:   if (((PetscObject)bv)->name) {
303:     for (j=0;j<m;j++) {
304:       PetscSNPrintf(str,50,"%s_%d",((PetscObject)bv)->name,(int)j);
305:       PetscObjectSetName((PetscObject)newV[j],str);
306:     }
307:   }
308:   if (copy) {
309:     PetscMemcpy(newarray,ctx->array,PetscMin(m,bv->m)*bv->n*sizeof(PetscScalar));
310:   }
311:   VecDestroyVecs(bv->m,&ctx->V);
312:   ctx->V = newV;
313:   PetscFree(ctx->array);
314:   ctx->array = newarray;
315:   return(0);
316: }

320: PetscErrorCode BVGetColumn_Contiguous(BV bv,PetscInt j,Vec *v)
321: {
322:   BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data;
323:   PetscInt      l;

326:   l = BVAvailableVec;
327:   bv->cv[l] = ctx->V[bv->nc+j];
328:   return(0);
329: }

333: PetscErrorCode BVGetArray_Contiguous(BV bv,PetscScalar **a)
334: {
335:   BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data;

338:   *a = ctx->array;
339:   return(0);
340: }

344: PetscErrorCode BVGetArrayRead_Contiguous(BV bv,const PetscScalar **a)
345: {
346:   BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data;

349:   *a = ctx->array;
350:   return(0);
351: }

355: PetscErrorCode BVDestroy_Contiguous(BV bv)
356: {
358:   BV_CONTIGUOUS  *ctx = (BV_CONTIGUOUS*)bv->data;

361:   VecDestroyVecs(bv->nc+bv->m,&ctx->V);
362:   PetscFree(ctx->array);
363:   PetscFree(bv->data);
364:   return(0);
365: }

369: PETSC_EXTERN PetscErrorCode BVCreate_Contiguous(BV bv)
370: {
372:   BV_CONTIGUOUS  *ctx;
373:   PetscInt       j,nloc,bs;
374:   PetscBool      seq;
375:   char           str[50];

378:   PetscNewLog(bv,&ctx);
379:   bv->data = (void*)ctx;

381:   PetscObjectTypeCompare((PetscObject)bv->t,VECMPI,&ctx->mpi);
382:   if (!ctx->mpi) {
383:     PetscObjectTypeCompare((PetscObject)bv->t,VECSEQ,&seq);
384:     if (!seq) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot create a contiguous BV from a non-standard template vector");
385:   }

387:   VecGetLocalSize(bv->t,&nloc);
388:   VecGetBlockSize(bv->t,&bs);
389:   PetscMalloc1(bv->m*nloc,&ctx->array);
390:   PetscMemzero(ctx->array,bv->m*nloc*sizeof(PetscScalar));
391:   PetscMalloc1(bv->m,&ctx->V);
392:   for (j=0;j<bv->m;j++) {
393:     if (ctx->mpi) {
394:       VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,ctx->array+j*nloc,ctx->V+j);
395:     } else {
396:       VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,ctx->array+j*nloc,ctx->V+j);
397:     }
398:   }
399:   PetscLogObjectParents(bv,bv->m,ctx->V);
400:   if (((PetscObject)bv)->name) {
401:     for (j=0;j<bv->m;j++) {
402:       PetscSNPrintf(str,50,"%s_%d",((PetscObject)bv)->name,(int)j);
403:       PetscObjectSetName((PetscObject)ctx->V[j],str);
404:     }
405:   }

407:   bv->ops->mult             = BVMult_Contiguous;
408:   bv->ops->multvec          = BVMultVec_Contiguous;
409:   bv->ops->multinplace      = BVMultInPlace_Contiguous;
410:   bv->ops->multinplacetrans = BVMultInPlaceTranspose_Contiguous;
411:   bv->ops->dot              = BVDot_Contiguous;
412:   bv->ops->dotvec           = BVDotVec_Contiguous;
413:   bv->ops->dotvec_local     = BVDotVec_Local_Contiguous;
414:   bv->ops->scale            = BVScale_Contiguous;
415:   bv->ops->norm             = BVNorm_Contiguous;
416:   bv->ops->norm_local       = BVNorm_Local_Contiguous;
417:   /*bv->ops->orthogonalize    = BVOrthogonalize_Contiguous;*/
418:   bv->ops->matmult          = BVMatMult_Contiguous;
419:   bv->ops->copy             = BVCopy_Contiguous;
420:   bv->ops->resize           = BVResize_Contiguous;
421:   bv->ops->getcolumn        = BVGetColumn_Contiguous;
422:   bv->ops->getarray         = BVGetArray_Contiguous;
423:   bv->ops->getarrayread     = BVGetArrayRead_Contiguous;
424:   bv->ops->destroy          = BVDestroy_Contiguous;
425:   return(0);
426: }

slepc-3.7.4/src/sys/classes/bv/impls/contiguous/contig.c0000644000175000017500000003436113107004621022615 0ustar jromanjroman/* BV implemented as an array of Vecs sharing a contiguous array for elements - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include typedef struct { Vec *V; PetscScalar *array; PetscBool mpi; } BV_CONTIGUOUS; #undef __FUNCT__ #define __FUNCT__ "BVMult_Contiguous" PetscErrorCode BVMult_Contiguous(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q) { PetscErrorCode ierr; BV_CONTIGUOUS *y = (BV_CONTIGUOUS*)Y->data,*x = (BV_CONTIGUOUS*)X->data; PetscScalar *q; PetscInt ldq; PetscFunctionBegin; if (Q) { ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMult_BLAS_Private(Y,Y->n,Y->k-Y->l,X->k-X->l,ldq,alpha,x->array+(X->nc+X->l)*X->n,q+Y->l*ldq+X->l,beta,y->array+(Y->nc+Y->l)*Y->n);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); } else { ierr = BVAXPY_BLAS_Private(Y,Y->n,Y->k-Y->l,alpha,x->array+(X->nc+X->l)*X->n,beta,y->array+(Y->nc+Y->l)*Y->n);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultVec_Contiguous" PetscErrorCode BVMultVec_Contiguous(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q) { PetscErrorCode ierr; BV_CONTIGUOUS *x = (BV_CONTIGUOUS*)X->data; PetscScalar *py; PetscFunctionBegin; ierr = VecGetArray(y,&py);CHKERRQ(ierr); ierr = BVMultVec_BLAS_Private(X,X->n,X->k-X->l,alpha,x->array+(X->nc+X->l)*X->n,q,beta,py);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlace_Contiguous" PetscErrorCode BVMultInPlace_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)V->data; PetscScalar *q; PetscInt ldq; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,ctx->array+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_FALSE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMultInPlaceTranspose_Contiguous" PetscErrorCode BVMultInPlaceTranspose_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)V->data; PetscScalar *q; PetscInt ldq; PetscFunctionBegin; ierr = MatGetSize(Q,&ldq,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(Q,&q);CHKERRQ(ierr); ierr = BVMultInPlace_BLAS_Private(V,V->n,V->k-V->l,ldq,s-V->l,e-V->l,ctx->array+(V->nc+V->l)*V->n,q+V->l*ldq+V->l,PETSC_TRUE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Q,&q);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDot_Contiguous" PetscErrorCode BVDot_Contiguous(BV X,BV Y,Mat M) { PetscErrorCode ierr; BV_CONTIGUOUS *x = (BV_CONTIGUOUS*)X->data,*y = (BV_CONTIGUOUS*)Y->data; PetscScalar *m; PetscInt ldm; PetscFunctionBegin; ierr = MatGetSize(M,&ldm,NULL);CHKERRQ(ierr); ierr = MatDenseGetArray(M,&m);CHKERRQ(ierr); ierr = BVDot_BLAS_Private(X,Y->k-Y->l,X->k-X->l,X->n,ldm,y->array+(Y->nc+Y->l)*Y->n,x->array+(X->nc+X->l)*X->n,m+X->l*ldm+Y->l,x->mpi);CHKERRQ(ierr); ierr = MatDenseRestoreArray(M,&m);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Contiguous" PetscErrorCode BVDotVec_Contiguous(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_CONTIGUOUS *x = (BV_CONTIGUOUS*)X->data; const PetscScalar *py; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = VecGetArrayRead(z,&py);CHKERRQ(ierr); ierr = BVDotVec_BLAS_Private(X,X->n,X->k-X->l,x->array+(X->nc+X->l)*X->n,py,m,x->mpi);CHKERRQ(ierr); ierr = VecRestoreArrayRead(z,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDotVec_Local_Contiguous" PetscErrorCode BVDotVec_Local_Contiguous(BV X,Vec y,PetscScalar *m) { PetscErrorCode ierr; BV_CONTIGUOUS *x = (BV_CONTIGUOUS*)X->data; PetscScalar *py; Vec z = y; PetscFunctionBegin; if (X->matrix) { ierr = BV_IPMatMult(X,y);CHKERRQ(ierr); z = X->Bx; } ierr = VecGetArray(z,&py);CHKERRQ(ierr); ierr = BVDotVec_BLAS_Private(X,X->n,X->k-X->l,x->array+(X->nc+X->l)*X->n,py,m,PETSC_FALSE);CHKERRQ(ierr); ierr = VecRestoreArray(z,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVScale_Contiguous" PetscErrorCode BVScale_Contiguous(BV bv,PetscInt j,PetscScalar alpha) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscFunctionBegin; if (j<0) { ierr = BVScale_BLAS_Private(bv,(bv->k-bv->l)*bv->n,ctx->array+(bv->nc+bv->l)*bv->n,alpha);CHKERRQ(ierr); } else { ierr = BVScale_BLAS_Private(bv,bv->n,ctx->array+(bv->nc+j)*bv->n,alpha);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Contiguous" PetscErrorCode BVNorm_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscFunctionBegin; if (j<0) { ierr = BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,ctx->array+(bv->nc+bv->l)*bv->n,type,val,ctx->mpi);CHKERRQ(ierr); } else { ierr = BVNorm_LAPACK_Private(bv,bv->n,1,ctx->array+(bv->nc+j)*bv->n,type,val,ctx->mpi);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVNorm_Local_Contiguous" PetscErrorCode BVNorm_Local_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscFunctionBegin; if (j<0) { ierr = BVNorm_LAPACK_Private(bv,bv->n,bv->k-bv->l,ctx->array+(bv->nc+bv->l)*bv->n,type,val,PETSC_FALSE);CHKERRQ(ierr); } else { ierr = BVNorm_LAPACK_Private(bv,bv->n,1,ctx->array+(bv->nc+j)*bv->n,type,val,PETSC_FALSE);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVOrthogonalize_Contiguous" PetscErrorCode BVOrthogonalize_Contiguous(BV V,Mat R) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)V->data; PetscScalar *r=NULL; PetscFunctionBegin; if (R) { ierr = MatDenseGetArray(R,&r);CHKERRQ(ierr); } ierr = BVOrthogonalize_LAPACK_Private(V,V->n,V->k,ctx->array+V->nc*V->n,r,ctx->mpi);CHKERRQ(ierr); if (R) { ierr = MatDenseRestoreArray(R,&r);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVMatMult_Contiguous" PetscErrorCode BVMatMult_Contiguous(BV V,Mat A,BV W) { PetscErrorCode ierr; BV_CONTIGUOUS *v = (BV_CONTIGUOUS*)V->data,*w = (BV_CONTIGUOUS*)W->data; PetscScalar *pb,*pc; PetscInt j,m; PetscBool flg; PetscFunctionBegin; ierr = MatHasOperation(A,MATOP_MAT_MULT,&flg);CHKERRQ(ierr); if (V->vmm && flg) { m = V->k-V->l; if (V->vmm==BV_MATMULT_MAT_SAVE) { ierr = BV_AllocateMatMult(V,A,m);CHKERRQ(ierr); ierr = MatDenseGetArray(V->B,&pb);CHKERRQ(ierr); ierr = PetscMemcpy(pb,v->array+(V->nc+V->l)*V->n,m*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(V->B,&pb);CHKERRQ(ierr); } else { /* BV_MATMULT_MAT */ ierr = MatCreateDense(PetscObjectComm((PetscObject)V),V->n,PETSC_DECIDE,V->N,m,v->array+(V->nc+V->l)*V->n,&V->B);CHKERRQ(ierr); } if (!V->C) { ierr = MatMatMultSymbolic(A,V->B,PETSC_DEFAULT,&V->C);CHKERRQ(ierr); } ierr = MatMatMultNumeric(A,V->B,V->C);CHKERRQ(ierr); ierr = MatDenseGetArray(V->C,&pc);CHKERRQ(ierr); ierr = PetscMemcpy(w->array+(W->nc+W->l)*W->n,pc,m*V->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatDenseRestoreArray(V->C,&pc);CHKERRQ(ierr); if (V->vmm==BV_MATMULT_MAT) { ierr = MatDestroy(&V->B);CHKERRQ(ierr); ierr = MatDestroy(&V->C);CHKERRQ(ierr); } } else { for (j=0;jk-V->l;j++) { ierr = MatMult(A,v->V[V->nc+V->l+j],w->V[W->nc+W->l+j]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCopy_Contiguous" PetscErrorCode BVCopy_Contiguous(BV V,BV W) { PetscErrorCode ierr; BV_CONTIGUOUS *v = (BV_CONTIGUOUS*)V->data,*w = (BV_CONTIGUOUS*)W->data; PetscScalar *pvc,*pwc; PetscFunctionBegin; pvc = v->array+(V->nc+V->l)*V->n; pwc = w->array+(W->nc+W->l)*W->n; ierr = PetscMemcpy(pwc,pvc,(V->k-V->l)*V->n*sizeof(PetscScalar));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVResize_Contiguous" PetscErrorCode BVResize_Contiguous(BV bv,PetscInt m,PetscBool copy) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscInt j,bs; PetscScalar *newarray; Vec *newV; char str[50]; PetscFunctionBegin; ierr = VecGetBlockSize(bv->t,&bs);CHKERRQ(ierr); ierr = PetscMalloc1(m*bv->n,&newarray);CHKERRQ(ierr); ierr = PetscMemzero(newarray,m*bv->n*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMalloc1(m,&newV);CHKERRQ(ierr); for (j=0;jmpi) { ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,bv->n,PETSC_DECIDE,newarray+j*bv->n,newV+j);CHKERRQ(ierr); } else { ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,bv->n,newarray+j*bv->n,newV+j);CHKERRQ(ierr); } } ierr = PetscLogObjectParents(bv,m,newV);CHKERRQ(ierr); if (((PetscObject)bv)->name) { for (j=0;jname,(int)j);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)newV[j],str);CHKERRQ(ierr); } } if (copy) { ierr = PetscMemcpy(newarray,ctx->array,PetscMin(m,bv->m)*bv->n*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = VecDestroyVecs(bv->m,&ctx->V);CHKERRQ(ierr); ctx->V = newV; ierr = PetscFree(ctx->array);CHKERRQ(ierr); ctx->array = newarray; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetColumn_Contiguous" PetscErrorCode BVGetColumn_Contiguous(BV bv,PetscInt j,Vec *v) { BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscInt l; PetscFunctionBegin; l = BVAvailableVec; bv->cv[l] = ctx->V[bv->nc+j]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArray_Contiguous" PetscErrorCode BVGetArray_Contiguous(BV bv,PetscScalar **a) { BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscFunctionBegin; *a = ctx->array; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVGetArrayRead_Contiguous" PetscErrorCode BVGetArrayRead_Contiguous(BV bv,const PetscScalar **a) { BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscFunctionBegin; *a = ctx->array; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVDestroy_Contiguous" PetscErrorCode BVDestroy_Contiguous(BV bv) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx = (BV_CONTIGUOUS*)bv->data; PetscFunctionBegin; ierr = VecDestroyVecs(bv->nc+bv->m,&ctx->V);CHKERRQ(ierr); ierr = PetscFree(ctx->array);CHKERRQ(ierr); ierr = PetscFree(bv->data);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "BVCreate_Contiguous" PETSC_EXTERN PetscErrorCode BVCreate_Contiguous(BV bv) { PetscErrorCode ierr; BV_CONTIGUOUS *ctx; PetscInt j,nloc,bs; PetscBool seq; char str[50]; PetscFunctionBegin; ierr = PetscNewLog(bv,&ctx);CHKERRQ(ierr); bv->data = (void*)ctx; ierr = PetscObjectTypeCompare((PetscObject)bv->t,VECMPI,&ctx->mpi);CHKERRQ(ierr); if (!ctx->mpi) { ierr = PetscObjectTypeCompare((PetscObject)bv->t,VECSEQ,&seq);CHKERRQ(ierr); if (!seq) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot create a contiguous BV from a non-standard template vector"); } ierr = VecGetLocalSize(bv->t,&nloc);CHKERRQ(ierr); ierr = VecGetBlockSize(bv->t,&bs);CHKERRQ(ierr); ierr = PetscMalloc1(bv->m*nloc,&ctx->array);CHKERRQ(ierr); ierr = PetscMemzero(ctx->array,bv->m*nloc*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMalloc1(bv->m,&ctx->V);CHKERRQ(ierr); for (j=0;jm;j++) { if (ctx->mpi) { ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,PETSC_DECIDE,ctx->array+j*nloc,ctx->V+j);CHKERRQ(ierr); } else { ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)bv->t),bs,nloc,ctx->array+j*nloc,ctx->V+j);CHKERRQ(ierr); } } ierr = PetscLogObjectParents(bv,bv->m,ctx->V);CHKERRQ(ierr); if (((PetscObject)bv)->name) { for (j=0;jm;j++) { ierr = PetscSNPrintf(str,50,"%s_%d",((PetscObject)bv)->name,(int)j);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)ctx->V[j],str);CHKERRQ(ierr); } } bv->ops->mult = BVMult_Contiguous; bv->ops->multvec = BVMultVec_Contiguous; bv->ops->multinplace = BVMultInPlace_Contiguous; bv->ops->multinplacetrans = BVMultInPlaceTranspose_Contiguous; bv->ops->dot = BVDot_Contiguous; bv->ops->dotvec = BVDotVec_Contiguous; bv->ops->dotvec_local = BVDotVec_Local_Contiguous; bv->ops->scale = BVScale_Contiguous; bv->ops->norm = BVNorm_Contiguous; bv->ops->norm_local = BVNorm_Local_Contiguous; /*bv->ops->orthogonalize = BVOrthogonalize_Contiguous;*/ bv->ops->matmult = BVMatMult_Contiguous; bv->ops->copy = BVCopy_Contiguous; bv->ops->resize = BVResize_Contiguous; bv->ops->getcolumn = BVGetColumn_Contiguous; bv->ops->getarray = BVGetArray_Contiguous; bv->ops->getarrayread = BVGetArrayRead_Contiguous; bv->ops->destroy = BVDestroy_Contiguous; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/0000755000175000017500000000000013107004621015653 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/makefile0000644000175000017500000000220113107004621017346 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../../../include/slepc/private/stimpl.h ../../../../include/slepcst.h DIRS = interface impls examples LOCDIR = src/sys/classes/st/ MANSEC = ST include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/interface/0000755000175000017500000000000013107004621017613 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/interface/makefile0000644000175000017500000000224713107004621021320 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = stfunc.c stset.c stsolve.c stsles.c stregis.c stshellmat.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = ST LOCDIR = src/sys/classes/st/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/interface/stregis.c.html0000644000175000017500000001303513107004621022404 0ustar jromanjroman
Actual source code: stregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/stimpl.h>          /*I   "slepcst.h"   I*/

 24: PETSC_EXTERN PetscErrorCode STCreate_Shell(ST);
 25: PETSC_EXTERN PetscErrorCode STCreate_Shift(ST);
 26: PETSC_EXTERN PetscErrorCode STCreate_Sinvert(ST);
 27: PETSC_EXTERN PetscErrorCode STCreate_Cayley(ST);
 28: PETSC_EXTERN PetscErrorCode STCreate_Precond(ST);

 32: /*@C
 33:    STRegisterAll - Registers all of the spectral transformations in the ST package.

 35:    Not Collective

 37:    Level: advanced

 39: .seealso: STRegister()
 40: @*/
 41: PetscErrorCode STRegisterAll(void)
 42: {

 46:   if (STRegisterAllCalled) return(0);
 47:   STRegisterAllCalled = PETSC_TRUE;
 48:   STRegister(STSHELL,STCreate_Shell);
 49:   STRegister(STSHIFT,STCreate_Shift);
 50:   STRegister(STSINVERT,STCreate_Sinvert);
 51:   STRegister(STCAYLEY,STCreate_Cayley);
 52:   STRegister(STPRECOND,STCreate_Precond);
 53:   return(0);
 54: }

slepc-3.7.4/src/sys/classes/st/interface/stsolve.c0000644000175000017500000004064113107004621021463 0ustar jromanjroman/* The ST (spectral transformation) interface routines, callable by users. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ #undef __FUNCT__ #define __FUNCT__ "STApply" /*@ STApply - Applies the spectral transformation operator to a vector, for instance (A - sB)^-1 B in the case of the shift-and-invert transformation and generalized eigenproblem. Collective on ST and Vec Input Parameters: + st - the spectral transformation context - x - input vector Output Parameter: . y - output vector Level: developer .seealso: STApplyTranspose() @*/ PetscErrorCode STApply(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(x,VEC_CLASSID,2); PetscValidHeaderSpecific(y,VEC_CLASSID,3); PetscValidType(st,1); STCheckMatrices(st,1); if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors"); VecLocked(y,3); if (st->state!=ST_STATE_SETUP) { ierr = STSetUp(st);CHKERRQ(ierr); } if (!st->ops->apply) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"ST does not have apply"); ierr = VecLockPush(x);CHKERRQ(ierr); ierr = PetscLogEventBegin(ST_Apply,st,x,y,0);CHKERRQ(ierr); if (st->D) { /* with balancing */ ierr = VecPointwiseDivide(st->wb,x,st->D);CHKERRQ(ierr); ierr = (*st->ops->apply)(st,st->wb,y);CHKERRQ(ierr); ierr = VecPointwiseMult(y,y,st->D);CHKERRQ(ierr); } else { ierr = (*st->ops->apply)(st,x,y);CHKERRQ(ierr); } ierr = PetscLogEventEnd(ST_Apply,st,x,y,0);CHKERRQ(ierr); ierr = VecLockPop(x);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STApplyTranspose" /*@ STApplyTranspose - Applies the transpose of the operator to a vector, for instance B^T(A - sB)^-T in the case of the shift-and-invert transformation and generalized eigenproblem. Collective on ST and Vec Input Parameters: + st - the spectral transformation context - x - input vector Output Parameter: . y - output vector Level: developer .seealso: STApply() @*/ PetscErrorCode STApplyTranspose(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(x,VEC_CLASSID,2); PetscValidHeaderSpecific(y,VEC_CLASSID,3); PetscValidType(st,1); STCheckMatrices(st,1); if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors"); VecLocked(y,3); if (st->state!=ST_STATE_SETUP) { ierr = STSetUp(st);CHKERRQ(ierr); } if (!st->ops->applytrans) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"ST does not have applytrans"); ierr = VecLockPush(x);CHKERRQ(ierr); ierr = PetscLogEventBegin(ST_ApplyTranspose,st,x,y,0);CHKERRQ(ierr); if (st->D) { /* with balancing */ ierr = VecPointwiseMult(st->wb,x,st->D);CHKERRQ(ierr); ierr = (*st->ops->applytrans)(st,st->wb,y);CHKERRQ(ierr); ierr = VecPointwiseDivide(y,y,st->D);CHKERRQ(ierr); } else { ierr = (*st->ops->applytrans)(st,x,y);CHKERRQ(ierr); } ierr = PetscLogEventEnd(ST_ApplyTranspose,st,x,y,0);CHKERRQ(ierr); ierr = VecLockPop(x);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetBilinearForm" /*@ STGetBilinearForm - Returns the matrix used in the bilinear form with a generalized problem with semi-definite B. Not collective, though a parallel Mat may be returned Input Parameters: . st - the spectral transformation context Output Parameter: . B - output matrix Notes: The output matrix B must be destroyed after use. It will be NULL in case of standard eigenproblems. Level: developer @*/ PetscErrorCode STGetBilinearForm(ST st,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidType(st,1); PetscValidPointer(B,2); STCheckMatrices(st,1); ierr = (*st->ops->getbilinearform)(st,B);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetBilinearForm_Default" PetscErrorCode STGetBilinearForm_Default(ST st,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; if (st->nmat==1) *B = NULL; else { *B = st->A[1]; ierr = PetscObjectReference((PetscObject)*B);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STComputeExplicitOperator" /*@ STComputeExplicitOperator - Computes the explicit operator associated to the eigenvalue problem with the specified spectral transformation. Collective on ST Input Parameter: . st - the spectral transform context Output Parameter: . mat - the explicit operator Notes: This routine builds a matrix containing the explicit operator. For example, in generalized problems with shift-and-invert spectral transformation the result would be matrix (A - s B)^-1 B. This computation is done by applying the operator to columns of the identity matrix. This is analogous to MatComputeExplicitOperator(). Level: advanced .seealso: STApply() @*/ PetscErrorCode STComputeExplicitOperator(ST st,Mat *mat) { PetscErrorCode ierr; Vec in,out; PetscInt i,M,m,*rows,start,end; const PetscScalar *array; PetscScalar one = 1.0; PetscMPIInt size; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(mat,2); STCheckMatrices(st,1); if (st->nmat>2) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_WRONGSTATE,"Can only be used with 1 or 2 matrices"); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)st),&size);CHKERRQ(ierr); ierr = MatCreateVecs(st->A[0],&in,&out);CHKERRQ(ierr); ierr = VecGetSize(out,&M);CHKERRQ(ierr); ierr = VecGetLocalSize(out,&m);CHKERRQ(ierr); ierr = VecSetOption(in,VEC_IGNORE_OFF_PROC_ENTRIES,PETSC_TRUE);CHKERRQ(ierr); ierr = VecGetOwnershipRange(out,&start,&end);CHKERRQ(ierr); ierr = PetscMalloc1(m,&rows);CHKERRQ(ierr); for (i=0;istate==ST_STATE_SETUP) PetscFunctionReturn(0); ierr = PetscInfo(st,"Setting up new ST\n");CHKERRQ(ierr); ierr = PetscLogEventBegin(ST_SetUp,st,0,0,0);CHKERRQ(ierr); if (!((PetscObject)st)->type_name) { ierr = STSetType(st,STSHIFT);CHKERRQ(ierr); } if (!st->T) { ierr = PetscMalloc1(PetscMax(2,st->nmat),&st->T);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)st,PetscMax(2,st->nmat)*sizeof(Mat));CHKERRQ(ierr); for (i=0;inmat);i++) st->T[i] = NULL; } else if (st->state!=ST_STATE_UPDATED) { for (i=0;inmat);i++) { ierr = MatDestroy(&st->T[i]);CHKERRQ(ierr); } } if (st->state!=ST_STATE_UPDATED) { ierr = MatDestroy(&st->P);CHKERRQ(ierr); } if (st->D) { ierr = MatGetLocalSize(st->A[0],NULL,&n);CHKERRQ(ierr); ierr = VecGetLocalSize(st->D,&k);CHKERRQ(ierr); if (n != k) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Balance matrix has wrong dimension %D (should be %D)",k,n); if (!st->wb) { ierr = VecDuplicate(st->D,&st->wb);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)st,(PetscObject)st->wb);CHKERRQ(ierr); } } if (st->ops->setup) { ierr = (*st->ops->setup)(st);CHKERRQ(ierr); } st->state = ST_STATE_SETUP; ierr = PetscLogEventEnd(ST_SetUp,st,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatMAXPY_Private" /* Computes coefficients for the transformed polynomial, and stores the result in argument S. alpha - value of the parameter of the transformed polynomial beta - value of the previous shift (only used in inplace mode) k - number of A matrices involved in the computation coeffs - coefficients of the expansion initial - true if this is the first time (only relevant for shell mode) */ PetscErrorCode STMatMAXPY_Private(ST st,PetscScalar alpha,PetscScalar beta,PetscInt k,PetscScalar *coeffs,PetscBool initial,Mat *S) { PetscErrorCode ierr; PetscInt *matIdx=NULL,nmat,i,ini=-1; PetscScalar t=1.0,ta,gamma; PetscBool nz=PETSC_FALSE; PetscFunctionBegin; nmat = st->nmat-k; switch (st->shift_matrix) { case ST_MATMODE_INPLACE: if (st->nmat>2) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"ST_MATMODE_INPLACE not supported for polynomial eigenproblems"); if (initial) { ierr = PetscObjectReference((PetscObject)st->A[0]);CHKERRQ(ierr); *S = st->A[0]; gamma = alpha; } else gamma = alpha-beta; if (gamma != 0.0) { if (st->nmat>1) { ierr = MatAXPY(*S,gamma,st->A[1],st->str);CHKERRQ(ierr); } else { ierr = MatShift(*S,gamma);CHKERRQ(ierr); } } break; case ST_MATMODE_SHELL: if (initial) { if (st->nmat>2) { ierr = PetscMalloc1(nmat,&matIdx);CHKERRQ(ierr); for (i=0;inmat>2) { ierr = PetscFree(matIdx);CHKERRQ(ierr); } } else { ierr = STMatShellShift(*S,alpha);CHKERRQ(ierr); } break; case ST_MATMODE_COPY: if (coeffs) { for (i=0;iA[k+ini]);CHKERRQ(ierr); *S = st->A[k+ini]; } else { if (*S && *S!=st->A[k+ini]) { ierr = MatSetOption(*S,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr); ierr = MatCopy(st->A[k+ini],*S,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); } else { ierr = MatDestroy(S);CHKERRQ(ierr); ierr = MatDuplicate(st->A[k+ini],MAT_COPY_VALUES,S);CHKERRQ(ierr); ierr = MatSetOption(*S,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)st,(PetscObject)*S);CHKERRQ(ierr); } if (coeffs && coeffs[ini]!=1.0) { ierr = MatScale(*S,coeffs[ini]);CHKERRQ(ierr); } for (i=ini+k+1;inmat);i++) { t *= alpha; ta = t; if (coeffs) ta *= coeffs[i-k]; if (ta!=0.0) { if (st->nmat>1) { ierr = MatAXPY(*S,ta,st->A[i],st->str);CHKERRQ(ierr); } else { ierr = MatShift(*S,ta);CHKERRQ(ierr); } } } } } ierr = STMatSetHermitian(st,*S);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCoeffs_Monomial" /* Computes the values of the coefficients required by STMatMAXPY_Private for the case of monomial basis. */ PetscErrorCode STCoeffs_Monomial(ST st, PetscScalar *coeffs) { PetscInt k,i,ini,inip; PetscFunctionBegin; /* Compute binomial coefficients */ ini = (st->nmat*(st->nmat-1))/2; for (i=0;inmat;i++) coeffs[ini+i]=1.0; for (k=st->nmat-1;k>=1;k--) { inip = ini+1; ini = (k*(k-1))/2; coeffs[ini] = 1.0; for (i=1;iops->postsolve) { ierr = (*st->ops->postsolve)(st);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STBackTransform" /*@ STBackTransform - Back-transformation phase, intended for spectral transformations which require to transform the computed eigenvalues back to the original eigenvalue problem. Not Collective Input Parameters: st - the spectral transformation context eigr - real part of a computed eigenvalue eigi - imaginary part of a computed eigenvalue Level: developer @*/ PetscErrorCode STBackTransform(ST st,PetscInt n,PetscScalar* eigr,PetscScalar* eigi) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidType(st,1); if (st->ops->backtransform) { ierr = (*st->ops->backtransform)(st,n,eigr,eigi);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatSetUp" /*@ STMatSetUp - Build the preconditioner matrix used in STMatSolve(). Collective on ST Input Parameters: + st - the spectral transformation context . sigma - the shift - coeffs - the coefficients (may be NULL) Note: This function is not intended to be called by end users, but by SLEPc solvers that use ST. It builds matrix st->P as follows, then calls KSPSetUp(). .vb If (coeffs): st->P = Sum_{i=0:nmat-1} coeffs[i]*sigma^i*A_i. else st->P = Sum_{i=0:nmat-1} sigma^i*A_i .ve Level: developer .seealso: STMatSolve() @*/ PetscErrorCode STMatSetUp(ST st,PetscScalar sigma,PetscScalar *coeffs) { PetscErrorCode ierr; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveScalar(st,sigma,2); STCheckMatrices(st,1); ierr = PetscLogEventBegin(ST_MatSetUp,st,0,0,0);CHKERRQ(ierr); ierr = STMatMAXPY_Private(st,sigma,0.0,0,coeffs,PETSC_TRUE,&st->P);CHKERRQ(ierr); if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = STCheckFactorPackage(st);CHKERRQ(ierr); ierr = KSPSetOperators(st->ksp,st->P,st->P);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)st,STPRECOND,&flg);CHKERRQ(ierr); if (!flg) { ierr = KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);CHKERRQ(ierr); } ierr = KSPSetUp(st->ksp);CHKERRQ(ierr); ierr = PetscLogEventEnd(ST_MatSetUp,st,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/interface/stshellmat.c0000644000175000017500000001526113107004621022144 0ustar jromanjroman/* This file contains the subroutines which implement various operations of the matrix associated to the shift-and-invert technique for eigenvalue problems, and also a subroutine to create it. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include typedef struct { PetscScalar alpha; PetscScalar *coeffs; ST st; Vec z; PetscInt nmat; PetscInt *matIdx; } ST_SHELLMAT; #undef __FUNCT__ #define __FUNCT__ "STMatShellShift" PetscErrorCode STMatShellShift(Mat A,PetscScalar alpha) { PetscErrorCode ierr; ST_SHELLMAT *ctx; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ctx->alpha = alpha; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMult_Shell" /* For i=0:nmat-1 computes y = (sum_i (coeffs[i]*alpha^i*st->A[idx[i]]))x If null coeffs computes with coeffs[i]=1.0 */ static PetscErrorCode MatMult_Shell(Mat A,Vec x,Vec y) { PetscErrorCode ierr; ST_SHELLMAT *ctx; ST st; PetscInt i; PetscScalar t=1.0,c; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); st = ctx->st; ierr = MatMult(st->A[ctx->matIdx[0]],x,y);CHKERRQ(ierr); if (ctx->coeffs && ctx->coeffs[0]!=1.0) { ierr = VecScale(y,ctx->coeffs[0]);CHKERRQ(ierr); } if (ctx->alpha!=0.0) { for (i=1;inmat;i++) { ierr = MatMult(st->A[ctx->matIdx[i]],x,ctx->z);CHKERRQ(ierr); t *= ctx->alpha; c = (ctx->coeffs)?t*ctx->coeffs[i]:t; ierr = VecAXPY(y,c,ctx->z);CHKERRQ(ierr); } if (ctx->nmat==1) { /* y = (A + alpha*I) x */ ierr = VecAXPY(y,ctx->alpha,x);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMultTranspose_Shell" static PetscErrorCode MatMultTranspose_Shell(Mat A,Vec x,Vec y) { PetscErrorCode ierr; ST_SHELLMAT *ctx; ST st; PetscInt i; PetscScalar t=1.0,c; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); st = ctx->st; ierr = MatMultTranspose(st->A[ctx->matIdx[0]],x,y);CHKERRQ(ierr); if (ctx->coeffs && ctx->coeffs[0]!=1.0) { ierr = VecScale(y,ctx->coeffs[0]);CHKERRQ(ierr); } if (ctx->alpha!=0.0) { for (i=1;inmat;i++) { ierr = MatMultTranspose(st->A[ctx->matIdx[i]],x,ctx->z);CHKERRQ(ierr); t *= ctx->alpha; c = (ctx->coeffs)?t*ctx->coeffs[i]:t; ierr = VecAXPY(y,c,ctx->z);CHKERRQ(ierr); } if (ctx->nmat==1) { /* y = (A + alpha*I) x */ ierr = VecAXPY(y,ctx->alpha,x);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatGetDiagonal_Shell" static PetscErrorCode MatGetDiagonal_Shell(Mat A,Vec diag) { PetscErrorCode ierr; ST_SHELLMAT *ctx; ST st; Vec diagb; PetscInt i; PetscScalar t=1.0,c; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); st = ctx->st; ierr = MatGetDiagonal(st->A[ctx->matIdx[0]],diag);CHKERRQ(ierr); if (ctx->coeffs && ctx->coeffs[0]!=1.0) { ierr = VecScale(diag,ctx->coeffs[0]);CHKERRQ(ierr); } if (ctx->alpha!=0.0) { if (ctx->nmat==1) { /* y = (A + alpha*I) x */ ierr = VecShift(diag,ctx->alpha);CHKERRQ(ierr); } else { ierr = VecDuplicate(diag,&diagb);CHKERRQ(ierr); for (i=1;inmat;i++) { ierr = MatGetDiagonal(st->A[ctx->matIdx[i]],diagb);CHKERRQ(ierr); t *= ctx->alpha; c = (ctx->coeffs)?t*ctx->coeffs[i]:t; ierr = VecAYPX(diag,c,diagb);CHKERRQ(ierr); } ierr = VecDestroy(&diagb);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatDestroy_Shell" static PetscErrorCode MatDestroy_Shell(Mat A) { PetscErrorCode ierr; ST_SHELLMAT *ctx; PetscFunctionBegin; ierr = MatShellGetContext(A,(void**)&ctx);CHKERRQ(ierr); ierr = VecDestroy(&ctx->z);CHKERRQ(ierr); ierr = PetscFree(ctx->matIdx);CHKERRQ(ierr); ierr = PetscFree(ctx->coeffs);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatShellCreate" PetscErrorCode STMatShellCreate(ST st,PetscScalar alpha,PetscInt nmat,PetscInt *matIdx,PetscScalar *coeffs,Mat *mat) { PetscErrorCode ierr; PetscInt n,m,N,M,i; PetscBool has=PETSC_FALSE,hasA,hasB; ST_SHELLMAT *ctx; PetscFunctionBegin; ierr = MatGetSize(st->A[0],&M,&N);CHKERRQ(ierr); ierr = MatGetLocalSize(st->A[0],&m,&n);CHKERRQ(ierr); ierr = PetscNew(&ctx);CHKERRQ(ierr); ctx->st = st; ctx->alpha = alpha; ctx->nmat = matIdx?nmat:st->nmat; ierr = PetscMalloc1(ctx->nmat,&ctx->matIdx);CHKERRQ(ierr); if (matIdx) { for (i=0;inmat;i++) ctx->matIdx[i] = matIdx[i]; } else { ctx->matIdx[0] = 0; if (ctx->nmat>1) ctx->matIdx[1] = 1; } if (coeffs) { ierr = PetscMalloc1(ctx->nmat,&ctx->coeffs);CHKERRQ(ierr); for (i=0;inmat;i++) ctx->coeffs[i] = coeffs[i]; } ierr = MatCreateVecs(st->A[0],&ctx->z,NULL);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)st),m,n,M,N,(void*)ctx,mat);CHKERRQ(ierr); ierr = MatShellSetOperation(*mat,MATOP_MULT,(void(*)(void))MatMult_Shell);CHKERRQ(ierr); ierr = MatShellSetOperation(*mat,MATOP_MULT_TRANSPOSE,(void(*)(void))MatMultTranspose_Shell);CHKERRQ(ierr); ierr = MatShellSetOperation(*mat,MATOP_DESTROY,(void(*)(void))MatDestroy_Shell);CHKERRQ(ierr); ierr = MatHasOperation(st->A[ctx->matIdx[0]],MATOP_GET_DIAGONAL,&hasA);CHKERRQ(ierr); if (st->nmat>1) { has = hasA; for (i=1;inmat;i++) { ierr = MatHasOperation(st->A[ctx->matIdx[i]],MATOP_GET_DIAGONAL,&hasB);CHKERRQ(ierr); has = (has && hasB)? PETSC_TRUE: PETSC_FALSE; } } if ((hasA && st->nmat==1) || has) { ierr = MatShellSetOperation(*mat,MATOP_GET_DIAGONAL,(void(*)(void))MatGetDiagonal_Shell);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/interface/makefile.html0000644000175000017500000000476613107004621022273 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = stfunc.c stset.c stsolve.c stsles.c stregis.c stshellmat.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = ST
LOCDIR   = src/sys/classes/st/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/interface/stset.c0000644000175000017500000002747613107004621021141 0ustar jromanjroman/* Routines to set ST methods and options. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ PetscBool STRegisterAllCalled = PETSC_FALSE; PetscFunctionList STList = 0; #undef __FUNCT__ #define __FUNCT__ "STSetType" /*@C STSetType - Builds ST for a particular spectral transformation. Logically Collective on ST Input Parameter: + st - the spectral transformation context. - type - a known type Options Database Key: . -st_type - Sets ST type Use -help for a list of available transformations Notes: See "slepc/include/slepcst.h" for available transformations Normally, it is best to use the EPSSetFromOptions() command and then set the ST type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the many different transformations. Level: beginner .seealso: EPSSetType() @*/ PetscErrorCode STSetType(ST st,STType type) { PetscErrorCode ierr,(*r)(ST); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)st,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(STList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested ST type %s",type); if (st->ops->destroy) { ierr = (*st->ops->destroy)(st);CHKERRQ(ierr); } ierr = PetscMemzero(st->ops,sizeof(struct _STOps));CHKERRQ(ierr); st->state = ST_STATE_INITIAL; ierr = PetscObjectChangeTypeName((PetscObject)st,type);CHKERRQ(ierr); ierr = (*r)(st);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetType" /*@C STGetType - Gets the ST type name (as a string) from the ST context. Not Collective Input Parameter: . st - the spectral transformation context Output Parameter: . name - name of the spectral transformation Level: intermediate .seealso: STSetType() @*/ PetscErrorCode STGetType(ST st,STType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)st)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetFromOptions" /*@ STSetFromOptions - Sets ST options from the options database. This routine must be called before STSetUp() if the user is to be allowed to set the type of transformation. Collective on ST Input Parameter: . st - the spectral transformation context Level: beginner @*/ PetscErrorCode STSetFromOptions(ST st) { PetscErrorCode ierr; PetscInt i; PetscScalar s; char type[256]; PetscBool flg; const char *mode_list[3] = {"copy","inplace","shell"}; const char *structure_list[3] = {"same","different","subset"}; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); ierr = STRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)st);CHKERRQ(ierr); ierr = PetscOptionsFList("-st_type","Spectral Transformation type","STSetType",STList,(char*)(((PetscObject)st)->type_name?((PetscObject)st)->type_name:STSHIFT),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = STSetType(st,type);CHKERRQ(ierr); } /* Set the type if it was never set. */ if (!((PetscObject)st)->type_name) { ierr = STSetType(st,STSHIFT);CHKERRQ(ierr); } ierr = PetscOptionsScalar("-st_shift","Value of the shift","STSetShift",st->sigma,&s,&flg);CHKERRQ(ierr); if (flg) { ierr = STSetShift(st,s);CHKERRQ(ierr); } ierr = PetscOptionsEList("-st_matmode","Matrix mode for transformed matrices","STSetMatMode",mode_list,3,mode_list[st->shift_matrix],&i,&flg);CHKERRQ(ierr); if (flg) st->shift_matrix = (STMatMode)i; ierr = PetscOptionsEList("-st_matstructure","Shift nonzero pattern","STSetMatStructure",structure_list,3,structure_list[st->str],&i,&flg);CHKERRQ(ierr); if (flg) { switch (i) { case 0: ierr = STSetMatStructure(st,SAME_NONZERO_PATTERN);CHKERRQ(ierr); break; case 1: ierr = STSetMatStructure(st,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); break; case 2: ierr = STSetMatStructure(st,SUBSET_NONZERO_PATTERN);CHKERRQ(ierr); break; } } ierr = PetscOptionsBool("-st_transform","Whether transformed matrices are computed or not","STSetTransform",st->transform,&st->transform,&flg);CHKERRQ(ierr); if (st->ops->setfromoptions) { ierr = (*st->ops->setfromoptions)(PetscOptionsObject,st);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)st);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPSetFromOptions(st->ksp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetMatStructure" /*@ STSetMatStructure - Sets an internal MatStructure attribute to indicate which is the relation of the sparsity pattern of all ST matrices. Logically Collective on ST Input Parameters: + st - the spectral transformation context - str - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or SUBSET_NONZERO_PATTERN Options Database Key: . -st_matstructure - Indicates the structure flag, where is one of 'same' (matrices have the same nonzero pattern), 'different' (different nonzero pattern) or 'subset' (pattern is a subset of the first one). Notes: By default, the sparsity patterns are assumed to be different. If the patterns are equal or a subset then it is recommended to set this attribute for efficiency reasons (in particular, for internal MatAXPY() operations). This function has no effect in the case of standard eigenproblems. Level: advanced .seealso: STSetOperators(), MatAXPY() @*/ PetscErrorCode STSetMatStructure(ST st,MatStructure str) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveEnum(st,str,2); switch (str) { case SAME_NONZERO_PATTERN: case DIFFERENT_NONZERO_PATTERN: case SUBSET_NONZERO_PATTERN: st->str = str; break; default: SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_OUTOFRANGE,"Invalid matrix structure flag"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetMatStructure" /*@ STGetMatStructure - Gets the internal MatStructure attribute to indicate which is the relation of the sparsity pattern of the matrices. Not Collective Input Parameters: . st - the spectral transformation context Output Parameters: . str - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or SUBSET_NONZERO_PATTERN Level: advanced .seealso: STSetMatStructure(), STSetOperators(), MatAXPY() @*/ PetscErrorCode STGetMatStructure(ST st,MatStructure *str) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(str,2); *str = st->str; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetMatMode" /*@ STSetMatMode - Sets a flag to indicate how the transformed matrices are being stored in the spectral transformations. Logically Collective on ST Input Parameters: + st - the spectral transformation context - mode - the mode flag, one of ST_MATMODE_COPY, ST_MATMODE_INPLACE, or ST_MATMODE_SHELL Options Database Key: . -st_matmode - Indicates the mode flag, where is one of 'copy', 'inplace', 'shell' (see explanation below). Notes: By default (ST_MATMODE_COPY), a copy of matrix A is made and then this copy is modified explicitly, e.g. A <- (A - s B). With ST_MATMODE_INPLACE, the original matrix A is modified at STSetUp() and changes are reverted at the end of the computations. With respect to the previous one, this mode avoids a copy of matrix A. However, a drawback is that the recovered matrix might be slightly different from the original one (due to roundoff). With ST_MATMODE_SHELL, the solver works with an implicit shell matrix that represents the shifted matrix. This mode is the most efficient in creating the shifted matrix but it places serious limitations to the linear solves performed in each iteration of the eigensolver (typically, only interative solvers with Jacobi preconditioning can be used). In the two first modes the efficiency of the computation can be controlled with STSetMatStructure(). Level: intermediate .seealso: STSetOperators(), STSetMatStructure(), STGetMatMode(), STMatMode @*/ PetscErrorCode STSetMatMode(ST st,STMatMode mode) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveEnum(st,mode,2); st->shift_matrix = mode; st->state = ST_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetMatMode" /*@ STGetMatMode - Gets a flag that indicates how the transformed matrices are stored in spectral transformations. Not Collective Input Parameter: . st - the spectral transformation context Output Parameter: . mode - the mode flag Level: intermediate .seealso: STSetMatMode(), STMatMode @*/ PetscErrorCode STGetMatMode(ST st,STMatMode *mode) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(mode,2); *mode = st->shift_matrix; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetTransform" /*@ STSetTransform - Sets a flag to indicate whether the transformed matrices are computed or not. Logically Collective on ST Input Parameters: + st - the spectral transformation context - flg - the boolean flag Options Database Key: . -st_transform - Activate/deactivate the computation of matrices. Notes: This flag is intended for the case of polynomial eigenproblems solved via linearization. If this flag is off (default) the spectral transformation is applied to the linearization (handled by the eigensolver), otherwise it is applied to the original problem. Level: developer .seealso: STMatSolve(), STMatMult(), STSetMatStructure(), STGetTransform() @*/ PetscErrorCode STSetTransform(ST st,PetscBool flg) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveBool(st,flg,2); if (st->transform != flg) { st->transform = flg; st->state = ST_STATE_INITIAL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetTransform" /*@ STGetTransform - Gets a flag that that indicates whether the transformed matrices are computed or not. Not Collective Input Parameter: . st - the spectral transformation context Output Parameter: . flg - the flag Level: developer .seealso: STSetTransform() @*/ PetscErrorCode STGetTransform(ST st,PetscBool *flg) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(flg,2); *flg = st->transform; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/interface/stsolve.c.html0000644000175000017500000010611213107004621022422 0ustar jromanjroman
Actual source code: stsolve.c

slepc-3.7.4 2017-05-17
  1: /*
  2:     The ST (spectral transformation) interface routines, callable by users.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/stimpl.h>            /*I "slepcst.h" I*/

 28: /*@
 29:    STApply - Applies the spectral transformation operator to a vector, for
 30:    instance (A - sB)^-1 B in the case of the shift-and-invert transformation
 31:    and generalized eigenproblem.

 33:    Collective on ST and Vec

 35:    Input Parameters:
 36: +  st - the spectral transformation context
 37: -  x  - input vector

 39:    Output Parameter:
 40: .  y - output vector

 42:    Level: developer

 44: .seealso: STApplyTranspose()
 45: @*/
 46: PetscErrorCode STApply(ST st,Vec x,Vec y)
 47: {

 55:   STCheckMatrices(st,1);
 56:   if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors");
 57:   VecLocked(y,3);

 59:   if (st->state!=ST_STATE_SETUP) { STSetUp(st); }

 61:   if (!st->ops->apply) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"ST does not have apply");
 62:   VecLockPush(x);
 63:   PetscLogEventBegin(ST_Apply,st,x,y,0);
 64:   if (st->D) { /* with balancing */
 65:     VecPointwiseDivide(st->wb,x,st->D);
 66:     (*st->ops->apply)(st,st->wb,y);
 67:     VecPointwiseMult(y,y,st->D);
 68:   } else {
 69:     (*st->ops->apply)(st,x,y);
 70:   }
 71:   PetscLogEventEnd(ST_Apply,st,x,y,0);
 72:   VecLockPop(x);
 73:   return(0);
 74: }

 78: /*@
 79:    STApplyTranspose - Applies the transpose of the operator to a vector, for
 80:    instance B^T(A - sB)^-T in the case of the shift-and-invert transformation
 81:    and generalized eigenproblem.

 83:    Collective on ST and Vec

 85:    Input Parameters:
 86: +  st - the spectral transformation context
 87: -  x  - input vector

 89:    Output Parameter:
 90: .  y - output vector

 92:    Level: developer

 94: .seealso: STApply()
 95: @*/
 96: PetscErrorCode STApplyTranspose(ST st,Vec x,Vec y)
 97: {

105:   STCheckMatrices(st,1);
106:   if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors");
107:   VecLocked(y,3);

109:   if (st->state!=ST_STATE_SETUP) { STSetUp(st); }

111:   if (!st->ops->applytrans) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"ST does not have applytrans");
112:   VecLockPush(x);
113:   PetscLogEventBegin(ST_ApplyTranspose,st,x,y,0);
114:   if (st->D) { /* with balancing */
115:     VecPointwiseMult(st->wb,x,st->D);
116:     (*st->ops->applytrans)(st,st->wb,y);
117:     VecPointwiseDivide(y,y,st->D);
118:   } else {
119:     (*st->ops->applytrans)(st,x,y);
120:   }
121:   PetscLogEventEnd(ST_ApplyTranspose,st,x,y,0);
122:   VecLockPop(x);
123:   return(0);
124: }

128: /*@
129:    STGetBilinearForm - Returns the matrix used in the bilinear form with a
130:    generalized problem with semi-definite B.

132:    Not collective, though a parallel Mat may be returned

134:    Input Parameters:
135: .  st - the spectral transformation context

137:    Output Parameter:
138: .  B - output matrix

140:    Notes:
141:    The output matrix B must be destroyed after use. It will be NULL in
142:    case of standard eigenproblems.

144:    Level: developer
145: @*/
146: PetscErrorCode STGetBilinearForm(ST st,Mat *B)
147: {

154:   STCheckMatrices(st,1);
155:   (*st->ops->getbilinearform)(st,B);
156:   return(0);
157: }

161: PetscErrorCode STGetBilinearForm_Default(ST st,Mat *B)
162: {

166:   if (st->nmat==1) *B = NULL;
167:   else {
168:     *B = st->A[1];
169:     PetscObjectReference((PetscObject)*B);
170:   }
171:   return(0);
172: }

176: /*@
177:    STComputeExplicitOperator - Computes the explicit operator associated
178:    to the eigenvalue problem with the specified spectral transformation.

180:    Collective on ST

182:    Input Parameter:
183: .  st - the spectral transform context

185:    Output Parameter:
186: .  mat - the explicit operator

188:    Notes:
189:    This routine builds a matrix containing the explicit operator. For
190:    example, in generalized problems with shift-and-invert spectral
191:    transformation the result would be matrix (A - s B)^-1 B.

193:    This computation is done by applying the operator to columns of the
194:    identity matrix. This is analogous to MatComputeExplicitOperator().

196:    Level: advanced

198: .seealso: STApply()
199: @*/
200: PetscErrorCode STComputeExplicitOperator(ST st,Mat *mat)
201: {
202:   PetscErrorCode    ierr;
203:   Vec               in,out;
204:   PetscInt          i,M,m,*rows,start,end;
205:   const PetscScalar *array;
206:   PetscScalar       one = 1.0;
207:   PetscMPIInt       size;

212:   STCheckMatrices(st,1);
213:   if (st->nmat>2) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_WRONGSTATE,"Can only be used with 1 or 2 matrices");
214:   MPI_Comm_size(PetscObjectComm((PetscObject)st),&size);

216:   MatCreateVecs(st->A[0],&in,&out);
217:   VecGetSize(out,&M);
218:   VecGetLocalSize(out,&m);
219:   VecSetOption(in,VEC_IGNORE_OFF_PROC_ENTRIES,PETSC_TRUE);
220:   VecGetOwnershipRange(out,&start,&end);
221:   PetscMalloc1(m,&rows);
222:   for (i=0;i<m;i++) rows[i] = start + i;

224:   MatCreate(PetscObjectComm((PetscObject)st),mat);
225:   MatSetSizes(*mat,m,m,M,M);
226:   if (size == 1) {
227:     MatSetType(*mat,MATSEQDENSE);
228:     MatSeqDenseSetPreallocation(*mat,NULL);
229:   } else {
230:     MatSetType(*mat,MATMPIAIJ);
231:     MatMPIAIJSetPreallocation(*mat,m,NULL,M-m,NULL);
232:   }

234:   for (i=0;i<M;i++) {
235:     VecSet(in,0.0);
236:     VecSetValues(in,1,&i,&one,INSERT_VALUES);
237:     VecAssemblyBegin(in);
238:     VecAssemblyEnd(in);

240:     STApply(st,in,out);

242:     VecGetArrayRead(out,&array);
243:     MatSetValues(*mat,m,rows,1,&i,array,INSERT_VALUES);
244:     VecRestoreArrayRead(out,&array);
245:   }
246:   PetscFree(rows);
247:   VecDestroy(&in);
248:   VecDestroy(&out);
249:   MatAssemblyBegin(*mat,MAT_FINAL_ASSEMBLY);
250:   MatAssemblyEnd(*mat,MAT_FINAL_ASSEMBLY);
251:   return(0);
252: }

256: /*@
257:    STSetUp - Prepares for the use of a spectral transformation.

259:    Collective on ST

261:    Input Parameter:
262: .  st - the spectral transformation context

264:    Level: advanced

266: .seealso: STCreate(), STApply(), STDestroy()
267: @*/
268: PetscErrorCode STSetUp(ST st)
269: {
270:   PetscInt       i,n,k;

275:   STCheckMatrices(st,1);
276:   if (st->state==ST_STATE_SETUP) return(0);
277:   PetscInfo(st,"Setting up new ST\n");
278:   PetscLogEventBegin(ST_SetUp,st,0,0,0);
279:   if (!((PetscObject)st)->type_name) {
280:     STSetType(st,STSHIFT);
281:   }
282:   if (!st->T) {
283:     PetscMalloc1(PetscMax(2,st->nmat),&st->T);
284:     PetscLogObjectMemory((PetscObject)st,PetscMax(2,st->nmat)*sizeof(Mat));
285:     for (i=0;i<PetscMax(2,st->nmat);i++) st->T[i] = NULL;
286:   } else if (st->state!=ST_STATE_UPDATED) {
287:     for (i=0;i<PetscMax(2,st->nmat);i++) {
288:       MatDestroy(&st->T[i]);
289:     }
290:   }
291:   if (st->state!=ST_STATE_UPDATED) { MatDestroy(&st->P); }
292:   if (st->D) {
293:     MatGetLocalSize(st->A[0],NULL,&n);
294:     VecGetLocalSize(st->D,&k);
295:     if (n != k) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Balance matrix has wrong dimension %D (should be %D)",k,n);
296:     if (!st->wb) {
297:       VecDuplicate(st->D,&st->wb);
298:       PetscLogObjectParent((PetscObject)st,(PetscObject)st->wb);
299:     }
300:   }
301:   if (st->ops->setup) { (*st->ops->setup)(st); }
302:   st->state = ST_STATE_SETUP;
303:   PetscLogEventEnd(ST_SetUp,st,0,0,0);
304:   return(0);
305: }

309: /*
310:    Computes coefficients for the transformed polynomial,
311:    and stores the result in argument S.

313:    alpha - value of the parameter of the transformed polynomial
314:    beta - value of the previous shift (only used in inplace mode)
315:    k - number of A matrices involved in the computation
316:    coeffs - coefficients of the expansion
317:    initial - true if this is the first time (only relevant for shell mode)
318: */
319: PetscErrorCode STMatMAXPY_Private(ST st,PetscScalar alpha,PetscScalar beta,PetscInt k,PetscScalar *coeffs,PetscBool initial,Mat *S)
320: {
322:   PetscInt       *matIdx=NULL,nmat,i,ini=-1;
323:   PetscScalar    t=1.0,ta,gamma;
324:   PetscBool      nz=PETSC_FALSE;

327:   nmat = st->nmat-k;
328:   switch (st->shift_matrix) {
329:   case ST_MATMODE_INPLACE:
330:     if (st->nmat>2) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"ST_MATMODE_INPLACE not supported for polynomial eigenproblems");
331:     if (initial) {
332:       PetscObjectReference((PetscObject)st->A[0]);
333:       *S = st->A[0];
334:       gamma = alpha;
335:     } else gamma = alpha-beta;
336:     if (gamma != 0.0) {
337:       if (st->nmat>1) {
338:         MatAXPY(*S,gamma,st->A[1],st->str);
339:       } else {
340:         MatShift(*S,gamma);
341:       }
342:     }
343:     break;
344:   case ST_MATMODE_SHELL:
345:     if (initial) {
346:       if (st->nmat>2) {
347:         PetscMalloc1(nmat,&matIdx);
348:         for (i=0;i<nmat;i++) matIdx[i] = k+i;
349:       }
350:       STMatShellCreate(st,alpha,nmat,matIdx,coeffs,S);
351:       PetscLogObjectParent((PetscObject)st,(PetscObject)*S);
352:       if (st->nmat>2) { PetscFree(matIdx); }
353:     } else {
354:       STMatShellShift(*S,alpha);
355:     }
356:     break;
357:   case ST_MATMODE_COPY:
358:     if (coeffs) {
359:       for (i=0;i<nmat && ini==-1;i++) {
360:         if (coeffs[i]!=0.0) ini = i;
361:         else t *= alpha;
362:       }
363:       if (coeffs[ini] != 1.0) nz = PETSC_TRUE;
364:       for (i=ini+1;i<nmat&&!nz;i++) if (coeffs[i]!=0.0) nz = PETSC_TRUE;
365:     } else { nz = PETSC_TRUE; ini = 0; }
366:     if ((alpha == 0.0 || !nz) && t==1.0) {
367:       MatDestroy(S);
368:       PetscObjectReference((PetscObject)st->A[k+ini]);
369:       *S = st->A[k+ini];
370:     } else {
371:       if (*S && *S!=st->A[k+ini]) {
372:         MatSetOption(*S,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);
373:         MatCopy(st->A[k+ini],*S,DIFFERENT_NONZERO_PATTERN);
374:       } else {
375:         MatDestroy(S);
376:         MatDuplicate(st->A[k+ini],MAT_COPY_VALUES,S);
377:         MatSetOption(*S,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);
378:         PetscLogObjectParent((PetscObject)st,(PetscObject)*S);
379:       }
380:       if (coeffs && coeffs[ini]!=1.0) {
381:         MatScale(*S,coeffs[ini]);
382:       }
383:       for (i=ini+k+1;i<PetscMax(2,st->nmat);i++) {
384:         t *= alpha;
385:         ta = t;
386:         if (coeffs) ta *= coeffs[i-k];
387:         if (ta!=0.0) {
388:           if (st->nmat>1) {
389:             MatAXPY(*S,ta,st->A[i],st->str);
390:           } else {
391:             MatShift(*S,ta);
392:           }
393:         }
394:       }
395:     }
396:   }
397:   STMatSetHermitian(st,*S);
398:   return(0);
399: }

403: /*
404:    Computes the values of the coefficients required by STMatMAXPY_Private
405:    for the case of monomial basis.
406: */
407: PetscErrorCode STCoeffs_Monomial(ST st, PetscScalar *coeffs)
408: {
409:   PetscInt  k,i,ini,inip;  

412:   /* Compute binomial coefficients */
413:   ini = (st->nmat*(st->nmat-1))/2;
414:   for (i=0;i<st->nmat;i++) coeffs[ini+i]=1.0;
415:   for (k=st->nmat-1;k>=1;k--) {
416:     inip = ini+1;
417:     ini = (k*(k-1))/2;
418:     coeffs[ini] = 1.0;
419:     for (i=1;i<k;i++) coeffs[ini+i] = coeffs[ini+i-1]+coeffs[inip+i-1];
420:   }
421:   return(0);
422: }

426: /*@
427:    STPostSolve - Optional post-solve phase, intended for any actions that must
428:    be performed on the ST object after the eigensolver has finished.

430:    Collective on ST

432:    Input Parameters:
433: .  st  - the spectral transformation context

435:    Level: developer

437: .seealso: EPSSolve()
438: @*/
439: PetscErrorCode STPostSolve(ST st)
440: {

446:   if (st->ops->postsolve) {
447:     (*st->ops->postsolve)(st);
448:   }
449:   return(0);
450: }

454: /*@
455:    STBackTransform - Back-transformation phase, intended for
456:    spectral transformations which require to transform the computed
457:    eigenvalues back to the original eigenvalue problem.

459:    Not Collective

461:    Input Parameters:
462:    st   - the spectral transformation context
463:    eigr - real part of a computed eigenvalue
464:    eigi - imaginary part of a computed eigenvalue

466:    Level: developer
467: @*/
468: PetscErrorCode STBackTransform(ST st,PetscInt n,PetscScalar* eigr,PetscScalar* eigi)
469: {

475:   if (st->ops->backtransform) {
476:     (*st->ops->backtransform)(st,n,eigr,eigi);
477:   }
478:   return(0);
479: }

483: /*@
484:    STMatSetUp - Build the preconditioner matrix used in STMatSolve().

486:    Collective on ST

488:    Input Parameters:
489: +  st     - the spectral transformation context
490: .  sigma  - the shift
491: -  coeffs - the coefficients (may be NULL)

493:    Note:
494:    This function is not intended to be called by end users, but by SLEPc
495:    solvers that use ST. It builds matrix st->P as follows, then calls KSPSetUp().
496: .vb
497:     If (coeffs):  st->P = Sum_{i=0:nmat-1} coeffs[i]*sigma^i*A_i.
498:     else          st->P = Sum_{i=0:nmat-1} sigma^i*A_i
499: .ve

501:    Level: developer

503: .seealso: STMatSolve()
504: @*/
505: PetscErrorCode STMatSetUp(ST st,PetscScalar sigma,PetscScalar *coeffs)
506: {
508:   PetscBool      flg;

513:   STCheckMatrices(st,1);

515:   PetscLogEventBegin(ST_MatSetUp,st,0,0,0);
516:   STMatMAXPY_Private(st,sigma,0.0,0,coeffs,PETSC_TRUE,&st->P);
517:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
518:   STCheckFactorPackage(st);
519:   KSPSetOperators(st->ksp,st->P,st->P);
520:   PetscObjectTypeCompare((PetscObject)st,STPRECOND,&flg);
521:   if (!flg) {
522:     KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);
523:   }
524:   KSPSetUp(st->ksp);
525:   PetscLogEventEnd(ST_MatSetUp,st,0,0,0);
526:   return(0);
527: }

slepc-3.7.4/src/sys/classes/st/interface/stsles.c.html0000644000175000017500000007007213107004621022245 0ustar jromanjroman
Actual source code: stsles.c

slepc-3.7.4 2017-05-17
  1: /*
  2:     The ST (spectral transformation) interface routines related to the
  3:     KSP object associated to it.

  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: */

 25: #include <slepc/private/stimpl.h>            /*I "slepcst.h" I*/

 29: /*@
 30:    STMatMult - Computes the matrix-vector product y = T[k] x, where T[k] is
 31:    the k-th matrix of the spectral transformation.

 33:    Collective on ST

 35:    Input Parameters:
 36: +  st - the spectral transformation context
 37: .  k  - index of matrix to use
 38: -  x  - the vector to be multiplied

 40:    Output Parameter:
 41: .  y - the result

 43:    Level: developer

 45: .seealso: STMatMultTranspose()
 46: @*/
 47: PetscErrorCode STMatMult(ST st,PetscInt k,Vec x,Vec y)
 48: {

 56:   STCheckMatrices(st,1);
 57:   if (k<0 || k>=PetscMax(2,st->nmat)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat);
 58:   if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors");
 59:   VecLocked(y,3);

 61:   if (st->state!=ST_STATE_SETUP) { STSetUp(st); }
 62:   VecLockPush(x);
 63:   PetscLogEventBegin(ST_MatMult,st,x,y,0);
 64:   if (!st->T[k]) {
 65:     /* T[k]=NULL means identity matrix */
 66:     VecCopy(x,y);
 67:   } else {
 68:     MatMult(st->T[k],x,y);
 69:   }
 70:   PetscLogEventEnd(ST_MatMult,st,x,y,0);
 71:   VecLockPop(x);
 72:   return(0);
 73: }

 77: /*@
 78:    STMatMultTranspose - Computes the matrix-vector product y = T[k]' x, where T[k] is
 79:    the k-th matrix of the spectral transformation.

 81:    Collective on ST

 83:    Input Parameters:
 84: +  st - the spectral transformation context
 85: .  k  - index of matrix to use
 86: -  x  - the vector to be multiplied

 88:    Output Parameter:
 89: .  y - the result

 91:    Level: developer

 93: .seealso: STMatMult()
 94: @*/
 95: PetscErrorCode STMatMultTranspose(ST st,PetscInt k,Vec x,Vec y)
 96: {

104:   STCheckMatrices(st,1);
105:   if (k<0 || k>=PetscMax(2,st->nmat)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat);
106:   if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors");
107:   VecLocked(y,3);

109:   if (st->state!=ST_STATE_SETUP) { STSetUp(st); }
110:   VecLockPush(x);
111:   PetscLogEventBegin(ST_MatMultTranspose,st,x,y,0);
112:   if (!st->T[k]) {
113:     /* T[k]=NULL means identity matrix */
114:     VecCopy(x,y);
115:   } else {
116:     MatMultTranspose(st->T[k],x,y);
117:   }
118:   PetscLogEventEnd(ST_MatMultTranspose,st,x,y,0);
119:   VecLockPop(x);
120:   return(0);
121: }

125: /*@
126:    STMatSolve - Solves P x = b, where P is the preconditioner matrix of
127:    the spectral transformation, using a KSP object stored internally.

129:    Collective on ST

131:    Input Parameters:
132: +  st - the spectral transformation context
133: -  b  - right hand side vector

135:    Output Parameter:
136: .  x - computed solution

138:    Level: developer

140: .seealso: STMatSolveTranspose()
141: @*/
142: PetscErrorCode STMatSolve(ST st,Vec b,Vec x)
143: {
145:   PetscInt       its;
146:   PetscBool      flg;

152:   STCheckMatrices(st,1);
153:   if (x == b) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and b must be different vectors");
154:   VecLocked(x,3);

156:   if (st->state!=ST_STATE_SETUP) { STSetUp(st); }
157:   VecLockPush(b);
158:   PetscLogEventBegin(ST_MatSolve,st,b,x,0);
159:   PetscObjectTypeCompareAny((PetscObject)st,&flg,STPRECOND,STSHELL,"");
160:   if (!flg && !st->P) {
161:     /* P=NULL means identity matrix */
162:     VecCopy(b,x);
163:     return(0);
164:   }
165:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
166:   KSPSolve(st->ksp,b,x);
167:   KSPGetIterationNumber(st->ksp,&its);
168:   PetscInfo1(st,"Linear solve iterations=%D\n",its);
169:   PetscLogEventEnd(ST_MatSolve,st,b,x,0);
170:   VecLockPop(b);
171:   return(0);
172: }

176: /*@
177:    STMatSolveTranspose - Solves P' x = b, where P is the preconditioner matrix of
178:    the spectral transformation, using a KSP object stored internally.

180:    Collective on ST

182:    Input Parameters:
183: .  st - the spectral transformation context
184: .  b  - right hand side vector

186:    Output Parameter:
187: .  x - computed solution

189:    Level: developer

191: .seealso: STMatSolve()
192: @*/
193: PetscErrorCode STMatSolveTranspose(ST st,Vec b,Vec x)
194: {
196:   PetscInt       its;
197:   PetscBool      flg;

203:   STCheckMatrices(st,1);
204:   if (x == b) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and b must be different vectors");
205:   VecLocked(x,3);

207:   if (st->state!=ST_STATE_SETUP) { STSetUp(st); }
208:   VecLockPush(b);
209:   PetscLogEventBegin(ST_MatSolveTranspose,st,b,x,0);
210:   PetscObjectTypeCompareAny((PetscObject)st,&flg,STPRECOND,STSHELL,"");
211:   if (!flg && !st->P) {
212:     /* P=NULL means identity matrix */
213:     VecCopy(b,x);
214:     return(0);
215:   }
216:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
217:   KSPSolveTranspose(st->ksp,b,x);
218:   KSPGetIterationNumber(st->ksp,&its);
219:   PetscInfo1(st,"Linear solve iterations=%D\n",its);
220:   PetscLogEventEnd(ST_MatSolveTranspose,st,b,x,0);
221:   VecLockPop(b);
222:   return(0);
223: }

227: /*
228:    STMatSetHermitian - Sets the Hermitian flag to the ST matrix.

230:    Input Parameters:
231: .  st - the spectral transformation context
232: .  M  - matrix
233: */
234: PetscErrorCode STMatSetHermitian(ST st,Mat M)
235: {
236: #if defined(PETSC_USE_COMPLEX)
238:   PetscBool      set,aherm,mherm;
239:   PetscInt       i;
240: #endif

243: #if defined(PETSC_USE_COMPLEX)
244:   mherm = PETSC_FALSE;
245:   for (i=0;i<st->nmat;i++) {
246:     MatIsHermitianKnown(st->A[i],&set,&aherm);
247:     if (!set) aherm = PETSC_FALSE;
248:     mherm = (mherm && aherm)? PETSC_TRUE: PETSC_FALSE;
249:     if (PetscRealPart(st->sigma)==0.0) break;
250:   }
251:   mherm = (mherm && PetscImaginaryPart(st->sigma)==0.0)? PETSC_TRUE: PETSC_FALSE;
252:   MatSetOption(M,MAT_HERMITIAN,mherm);
253: #endif
254:   return(0);
255: }

259: PetscErrorCode STCheckFactorPackage(ST st)
260: {
261:   PetscErrorCode         ierr;
262:   PC                     pc;
263:   PetscMPIInt            size;
264:   PetscBool              flg;
265:   const MatSolverPackage stype;

268:   MPI_Comm_size(PetscObjectComm((PetscObject)st),&size);
269:   if (size==1) return(0);
270:   KSPGetPC(st->ksp,&pc);
271:   PCFactorGetMatSolverPackage(pc,&stype);
272:   if (stype) {   /* currently selected PC is a factorization */
273:     PetscStrcmp(stype,MATSOLVERPETSC,&flg);
274:     if (flg) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"You chose to solve linear systems with a factorization, but in parallel runs you need to select an external package; see the users guide for details");
275:   }
276:   return(0);
277: }

281: /*@
282:    STSetKSP - Sets the KSP object associated with the spectral
283:    transformation.

285:    Collective on ST

287:    Input Parameters:
288: +  st   - the spectral transformation context
289: -  ksp  - the linear system context

291:    Level: advanced
292: @*/
293: PetscErrorCode STSetKSP(ST st,KSP ksp)
294: {

301:   PetscObjectReference((PetscObject)ksp);
302:   KSPDestroy(&st->ksp);
303:   st->ksp = ksp;
304:   PetscLogObjectParent((PetscObject)st,(PetscObject)st->ksp);
305:   return(0);
306: }

310: /*@
311:    STGetKSP - Gets the KSP object associated with the spectral
312:    transformation.

314:    Not Collective

316:    Input Parameter:
317: .  st - the spectral transformation context

319:    Output Parameter:
320: .  ksp  - the linear system context

322:    Level: intermediate
323: @*/
324: PetscErrorCode STGetKSP(ST st,KSP* ksp)
325: {

331:   if (!st->ksp) {
332:     KSPCreate(PetscObjectComm((PetscObject)st),&st->ksp);
333:     KSPSetOptionsPrefix(st->ksp,((PetscObject)st)->prefix);
334:     KSPAppendOptionsPrefix(st->ksp,"st_");
335:     PetscObjectIncrementTabLevel((PetscObject)st->ksp,(PetscObject)st,1);
336:     PetscLogObjectParent((PetscObject)st,(PetscObject)st->ksp);
337:     KSPSetTolerances(st->ksp,SLEPC_DEFAULT_TOL,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);
338:   }
339:   *ksp = st->ksp;
340:   return(0);
341: }

345: PetscErrorCode STCheckNullSpace_Default(ST st,BV V)
346: {
348:   PetscInt       nc,i,c;
349:   PetscReal      norm;
350:   Vec            *T,w,vi;
351:   Mat            A;
352:   PC             pc;
353:   MatNullSpace   nullsp;

356:   BVGetNumConstraints(V,&nc);
357:   PetscMalloc1(nc,&T);
358:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
359:   KSPGetPC(st->ksp,&pc);
360:   PCGetOperators(pc,&A,NULL);
361:   MatCreateVecs(A,NULL,&w);
362:   c = 0;
363:   for (i=0;i<nc;i++) {
364:     BVGetColumn(V,-nc+i,&vi);
365:     MatMult(A,vi,w);
366:     VecNorm(w,NORM_2,&norm);
367:     if (norm < 1e-8) {
368:       PetscInfo2(st,"Vector %D norm=%g\n",i,(double)norm);
369:       BVCreateVec(V,T+c);
370:       VecCopy(vi,T[c]);
371:       c++;
372:     }
373:     BVRestoreColumn(V,-nc+i,&vi);
374:   }
375:   VecDestroy(&w);
376:   if (c>0) {
377:     MatNullSpaceCreate(PetscObjectComm((PetscObject)st),PETSC_FALSE,c,T,&nullsp);
378:     MatSetNullSpace(A,nullsp);
379:     MatNullSpaceDestroy(&nullsp);
380:     VecDestroyVecs(c,&T);
381:   } else {
382:     PetscFree(T);
383:   }
384:   return(0);
385: }

389: /*@
390:    STCheckNullSpace - Given a basis vectors object, this function tests each
391:    of its constraint vectors to be a nullspace vector of the coefficient
392:    matrix of the associated KSP object. All these nullspace vectors are passed
393:    to the KSP object.

395:    Collective on ST

397:    Input Parameters:
398: +  st - the spectral transformation context
399: -  V  - basis vectors to be checked

401:    Note:
402:    This function allows to handle singular pencils and to solve some problems
403:    in which the nullspace is important (see the users guide for details).

405:    Level: developer

407: .seealso: EPSSetDeflationSpace()
408: @*/
409: PetscErrorCode STCheckNullSpace(ST st,BV V)
410: {
412:   PetscInt       nc;


420:   BVGetNumConstraints(V,&nc);
421:   if (nc && st->ops->checknullspace) {
422:     (*st->ops->checknullspace)(st,V);
423:   }
424:   return(0);
425: }

slepc-3.7.4/src/sys/classes/st/interface/stshellmat.c.html0000644000175000017500000003206613107004621023111 0ustar jromanjroman
Actual source code: stshellmat.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       This file contains the subroutines which implement various operations
  3:       of the matrix associated to the shift-and-invert technique for eigenvalue
  4:       problems, and also a subroutine to create it.

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

 10:    This file is part of SLEPc.

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

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

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

 26: #include <slepc/private/stimpl.h>

 28: typedef struct {
 29:   PetscScalar alpha;
 30:   PetscScalar *coeffs;
 31:   ST          st;
 32:   Vec         z;
 33:   PetscInt    nmat;
 34:   PetscInt    *matIdx;
 35: } ST_SHELLMAT;

 39: PetscErrorCode STMatShellShift(Mat A,PetscScalar alpha)
 40: {
 42:   ST_SHELLMAT    *ctx;

 45:   MatShellGetContext(A,(void**)&ctx);
 46:   ctx->alpha = alpha;
 47:   return(0);
 48: }

 52: /*
 53:   For i=0:nmat-1 computes y = (sum_i (coeffs[i]*alpha^i*st->A[idx[i]]))x
 54:   If null coeffs computes with coeffs[i]=1.0  
 55: */
 56: static PetscErrorCode MatMult_Shell(Mat A,Vec x,Vec y)
 57: {
 59:   ST_SHELLMAT    *ctx;
 60:   ST             st;
 61:   PetscInt       i;
 62:   PetscScalar    t=1.0,c;

 65:   MatShellGetContext(A,(void**)&ctx);
 66:   st = ctx->st;
 67:   MatMult(st->A[ctx->matIdx[0]],x,y);
 68:   if (ctx->coeffs && ctx->coeffs[0]!=1.0) {
 69:     VecScale(y,ctx->coeffs[0]);
 70:   }
 71:   if (ctx->alpha!=0.0) {
 72:     for (i=1;i<ctx->nmat;i++) {
 73:       MatMult(st->A[ctx->matIdx[i]],x,ctx->z);
 74:       t *= ctx->alpha;
 75:       c = (ctx->coeffs)?t*ctx->coeffs[i]:t;
 76:       VecAXPY(y,c,ctx->z);
 77:     }
 78:     if (ctx->nmat==1) {    /* y = (A + alpha*I) x */
 79:       VecAXPY(y,ctx->alpha,x);
 80:     }
 81:   }
 82:   return(0);
 83: }

 87: static PetscErrorCode MatMultTranspose_Shell(Mat A,Vec x,Vec y)
 88: {
 90:   ST_SHELLMAT    *ctx;
 91:   ST             st;
 92:   PetscInt       i;
 93:   PetscScalar    t=1.0,c;

 96:   MatShellGetContext(A,(void**)&ctx);
 97:   st = ctx->st;
 98:   MatMultTranspose(st->A[ctx->matIdx[0]],x,y);
 99:   if (ctx->coeffs && ctx->coeffs[0]!=1.0) {
100:     VecScale(y,ctx->coeffs[0]);
101:   }
102:   if (ctx->alpha!=0.0) {
103:     for (i=1;i<ctx->nmat;i++) {
104:       MatMultTranspose(st->A[ctx->matIdx[i]],x,ctx->z);
105:       t *= ctx->alpha;
106:       c = (ctx->coeffs)?t*ctx->coeffs[i]:t;
107:       VecAXPY(y,c,ctx->z);
108:     }
109:     if (ctx->nmat==1) {    /* y = (A + alpha*I) x */
110:       VecAXPY(y,ctx->alpha,x);
111:     }
112:   }
113:   return(0);
114: }

118: static PetscErrorCode MatGetDiagonal_Shell(Mat A,Vec diag)
119: {
121:   ST_SHELLMAT    *ctx;
122:   ST             st;
123:   Vec            diagb;
124:   PetscInt       i;
125:   PetscScalar    t=1.0,c;

128:   MatShellGetContext(A,(void**)&ctx);
129:   st = ctx->st;
130:   MatGetDiagonal(st->A[ctx->matIdx[0]],diag);
131:   if (ctx->coeffs && ctx->coeffs[0]!=1.0) {
132:     VecScale(diag,ctx->coeffs[0]);
133:   }
134:   if (ctx->alpha!=0.0) {
135:     if (ctx->nmat==1) {    /* y = (A + alpha*I) x */
136:       VecShift(diag,ctx->alpha);
137:     } else {
138:       VecDuplicate(diag,&diagb);
139:       for (i=1;i<ctx->nmat;i++) {
140:         MatGetDiagonal(st->A[ctx->matIdx[i]],diagb);
141:         t *= ctx->alpha;
142:         c = (ctx->coeffs)?t*ctx->coeffs[i]:t;
143:         VecAYPX(diag,c,diagb);
144:       }
145:       VecDestroy(&diagb);
146:     }
147:   }
148:   return(0);
149: }

153: static PetscErrorCode MatDestroy_Shell(Mat A)
154: {
156:   ST_SHELLMAT    *ctx;

159:   MatShellGetContext(A,(void**)&ctx);
160:   VecDestroy(&ctx->z);
161:   PetscFree(ctx->matIdx);
162:   PetscFree(ctx->coeffs);
163:   PetscFree(ctx);
164:   return(0);
165: }

169: PetscErrorCode STMatShellCreate(ST st,PetscScalar alpha,PetscInt nmat,PetscInt *matIdx,PetscScalar *coeffs,Mat *mat)
170: {
172:   PetscInt       n,m,N,M,i;
173:   PetscBool      has=PETSC_FALSE,hasA,hasB;
174:   ST_SHELLMAT    *ctx;

177:   MatGetSize(st->A[0],&M,&N);
178:   MatGetLocalSize(st->A[0],&m,&n);
179:   PetscNew(&ctx);
180:   ctx->st = st;
181:   ctx->alpha = alpha;
182:   ctx->nmat = matIdx?nmat:st->nmat;
183:   PetscMalloc1(ctx->nmat,&ctx->matIdx);
184:   if (matIdx) {
185:     for (i=0;i<ctx->nmat;i++) ctx->matIdx[i] = matIdx[i];
186:   } else {
187:     ctx->matIdx[0] = 0;
188:     if (ctx->nmat>1) ctx->matIdx[1] = 1;
189:   }
190:   if (coeffs) {
191:     PetscMalloc1(ctx->nmat,&ctx->coeffs);
192:     for (i=0;i<ctx->nmat;i++) ctx->coeffs[i] = coeffs[i];
193:   }
194:   MatCreateVecs(st->A[0],&ctx->z,NULL);
195:   MatCreateShell(PetscObjectComm((PetscObject)st),m,n,M,N,(void*)ctx,mat);
196:   MatShellSetOperation(*mat,MATOP_MULT,(void(*)(void))MatMult_Shell);
197:   MatShellSetOperation(*mat,MATOP_MULT_TRANSPOSE,(void(*)(void))MatMultTranspose_Shell);
198:   MatShellSetOperation(*mat,MATOP_DESTROY,(void(*)(void))MatDestroy_Shell);

200:   MatHasOperation(st->A[ctx->matIdx[0]],MATOP_GET_DIAGONAL,&hasA);
201:   if (st->nmat>1) {
202:     has = hasA;
203:     for (i=1;i<ctx->nmat;i++) {
204:       MatHasOperation(st->A[ctx->matIdx[i]],MATOP_GET_DIAGONAL,&hasB);
205:       has = (has && hasB)? PETSC_TRUE: PETSC_FALSE;
206:     }
207:   }
208:   if ((hasA && st->nmat==1) || has) {
209:     MatShellSetOperation(*mat,MATOP_GET_DIAGONAL,(void(*)(void))MatGetDiagonal_Shell);
210:   }
211:   return(0);
212: }

slepc-3.7.4/src/sys/classes/st/interface/stsles.c0000644000175000017500000003214313107004621021277 0ustar jromanjroman/* The ST (spectral transformation) interface routines related to the KSP object associated to it. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ #undef __FUNCT__ #define __FUNCT__ "STMatMult" /*@ STMatMult - Computes the matrix-vector product y = T[k] x, where T[k] is the k-th matrix of the spectral transformation. Collective on ST Input Parameters: + st - the spectral transformation context . k - index of matrix to use - x - the vector to be multiplied Output Parameter: . y - the result Level: developer .seealso: STMatMultTranspose() @*/ PetscErrorCode STMatMult(ST st,PetscInt k,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveInt(st,k,2); PetscValidHeaderSpecific(x,VEC_CLASSID,3); PetscValidHeaderSpecific(y,VEC_CLASSID,4); STCheckMatrices(st,1); if (k<0 || k>=PetscMax(2,st->nmat)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat); if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors"); VecLocked(y,3); if (st->state!=ST_STATE_SETUP) { ierr = STSetUp(st);CHKERRQ(ierr); } ierr = VecLockPush(x);CHKERRQ(ierr); ierr = PetscLogEventBegin(ST_MatMult,st,x,y,0);CHKERRQ(ierr); if (!st->T[k]) { /* T[k]=NULL means identity matrix */ ierr = VecCopy(x,y);CHKERRQ(ierr); } else { ierr = MatMult(st->T[k],x,y);CHKERRQ(ierr); } ierr = PetscLogEventEnd(ST_MatMult,st,x,y,0);CHKERRQ(ierr); ierr = VecLockPop(x);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatMultTranspose" /*@ STMatMultTranspose - Computes the matrix-vector product y = T[k]' x, where T[k] is the k-th matrix of the spectral transformation. Collective on ST Input Parameters: + st - the spectral transformation context . k - index of matrix to use - x - the vector to be multiplied Output Parameter: . y - the result Level: developer .seealso: STMatMult() @*/ PetscErrorCode STMatMultTranspose(ST st,PetscInt k,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveInt(st,k,2); PetscValidHeaderSpecific(x,VEC_CLASSID,3); PetscValidHeaderSpecific(y,VEC_CLASSID,4); STCheckMatrices(st,1); if (k<0 || k>=PetscMax(2,st->nmat)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat); if (x == y) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and y must be different vectors"); VecLocked(y,3); if (st->state!=ST_STATE_SETUP) { ierr = STSetUp(st);CHKERRQ(ierr); } ierr = VecLockPush(x);CHKERRQ(ierr); ierr = PetscLogEventBegin(ST_MatMultTranspose,st,x,y,0);CHKERRQ(ierr); if (!st->T[k]) { /* T[k]=NULL means identity matrix */ ierr = VecCopy(x,y);CHKERRQ(ierr); } else { ierr = MatMultTranspose(st->T[k],x,y);CHKERRQ(ierr); } ierr = PetscLogEventEnd(ST_MatMultTranspose,st,x,y,0);CHKERRQ(ierr); ierr = VecLockPop(x);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatSolve" /*@ STMatSolve - Solves P x = b, where P is the preconditioner matrix of the spectral transformation, using a KSP object stored internally. Collective on ST Input Parameters: + st - the spectral transformation context - b - right hand side vector Output Parameter: . x - computed solution Level: developer .seealso: STMatSolveTranspose() @*/ PetscErrorCode STMatSolve(ST st,Vec b,Vec x) { PetscErrorCode ierr; PetscInt its; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(b,VEC_CLASSID,2); PetscValidHeaderSpecific(x,VEC_CLASSID,3); STCheckMatrices(st,1); if (x == b) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and b must be different vectors"); VecLocked(x,3); if (st->state!=ST_STATE_SETUP) { ierr = STSetUp(st);CHKERRQ(ierr); } ierr = VecLockPush(b);CHKERRQ(ierr); ierr = PetscLogEventBegin(ST_MatSolve,st,b,x,0);CHKERRQ(ierr); ierr = PetscObjectTypeCompareAny((PetscObject)st,&flg,STPRECOND,STSHELL,"");CHKERRQ(ierr); if (!flg && !st->P) { /* P=NULL means identity matrix */ ierr = VecCopy(b,x);CHKERRQ(ierr); PetscFunctionReturn(0); } if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPSolve(st->ksp,b,x);CHKERRQ(ierr); ierr = KSPGetIterationNumber(st->ksp,&its);CHKERRQ(ierr); ierr = PetscInfo1(st,"Linear solve iterations=%D\n",its);CHKERRQ(ierr); ierr = PetscLogEventEnd(ST_MatSolve,st,b,x,0);CHKERRQ(ierr); ierr = VecLockPop(b);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatSolveTranspose" /*@ STMatSolveTranspose - Solves P' x = b, where P is the preconditioner matrix of the spectral transformation, using a KSP object stored internally. Collective on ST Input Parameters: . st - the spectral transformation context . b - right hand side vector Output Parameter: . x - computed solution Level: developer .seealso: STMatSolve() @*/ PetscErrorCode STMatSolveTranspose(ST st,Vec b,Vec x) { PetscErrorCode ierr; PetscInt its; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(b,VEC_CLASSID,2); PetscValidHeaderSpecific(x,VEC_CLASSID,3); STCheckMatrices(st,1); if (x == b) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_IDN,"x and b must be different vectors"); VecLocked(x,3); if (st->state!=ST_STATE_SETUP) { ierr = STSetUp(st);CHKERRQ(ierr); } ierr = VecLockPush(b);CHKERRQ(ierr); ierr = PetscLogEventBegin(ST_MatSolveTranspose,st,b,x,0);CHKERRQ(ierr); ierr = PetscObjectTypeCompareAny((PetscObject)st,&flg,STPRECOND,STSHELL,"");CHKERRQ(ierr); if (!flg && !st->P) { /* P=NULL means identity matrix */ ierr = VecCopy(b,x);CHKERRQ(ierr); PetscFunctionReturn(0); } if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPSolveTranspose(st->ksp,b,x);CHKERRQ(ierr); ierr = KSPGetIterationNumber(st->ksp,&its);CHKERRQ(ierr); ierr = PetscInfo1(st,"Linear solve iterations=%D\n",its);CHKERRQ(ierr); ierr = PetscLogEventEnd(ST_MatSolveTranspose,st,b,x,0);CHKERRQ(ierr); ierr = VecLockPop(b);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatSetHermitian" /* STMatSetHermitian - Sets the Hermitian flag to the ST matrix. Input Parameters: . st - the spectral transformation context . M - matrix */ PetscErrorCode STMatSetHermitian(ST st,Mat M) { #if defined(PETSC_USE_COMPLEX) PetscErrorCode ierr; PetscBool set,aherm,mherm; PetscInt i; #endif PetscFunctionBegin; #if defined(PETSC_USE_COMPLEX) mherm = PETSC_FALSE; for (i=0;inmat;i++) { ierr = MatIsHermitianKnown(st->A[i],&set,&aherm);CHKERRQ(ierr); if (!set) aherm = PETSC_FALSE; mherm = (mherm && aherm)? PETSC_TRUE: PETSC_FALSE; if (PetscRealPart(st->sigma)==0.0) break; } mherm = (mherm && PetscImaginaryPart(st->sigma)==0.0)? PETSC_TRUE: PETSC_FALSE; ierr = MatSetOption(M,MAT_HERMITIAN,mherm);CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCheckFactorPackage" PetscErrorCode STCheckFactorPackage(ST st) { PetscErrorCode ierr; PC pc; PetscMPIInt size; PetscBool flg; const MatSolverPackage stype; PetscFunctionBegin; ierr = MPI_Comm_size(PetscObjectComm((PetscObject)st),&size);CHKERRQ(ierr); if (size==1) PetscFunctionReturn(0); ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = PCFactorGetMatSolverPackage(pc,&stype);CHKERRQ(ierr); if (stype) { /* currently selected PC is a factorization */ ierr = PetscStrcmp(stype,MATSOLVERPETSC,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"You chose to solve linear systems with a factorization, but in parallel runs you need to select an external package; see the users guide for details"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetKSP" /*@ STSetKSP - Sets the KSP object associated with the spectral transformation. Collective on ST Input Parameters: + st - the spectral transformation context - ksp - the linear system context Level: advanced @*/ PetscErrorCode STSetKSP(ST st,KSP ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(ksp,KSP_CLASSID,2); PetscCheckSameComm(st,1,ksp,2); ierr = PetscObjectReference((PetscObject)ksp);CHKERRQ(ierr); ierr = KSPDestroy(&st->ksp);CHKERRQ(ierr); st->ksp = ksp; ierr = PetscLogObjectParent((PetscObject)st,(PetscObject)st->ksp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetKSP" /*@ STGetKSP - Gets the KSP object associated with the spectral transformation. Not Collective Input Parameter: . st - the spectral transformation context Output Parameter: . ksp - the linear system context Level: intermediate @*/ PetscErrorCode STGetKSP(ST st,KSP* ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(ksp,2); if (!st->ksp) { ierr = KSPCreate(PetscObjectComm((PetscObject)st),&st->ksp);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(st->ksp,((PetscObject)st)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)st->ksp,(PetscObject)st,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)st,(PetscObject)st->ksp);CHKERRQ(ierr); ierr = KSPSetTolerances(st->ksp,SLEPC_DEFAULT_TOL,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr); } *ksp = st->ksp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCheckNullSpace_Default" PetscErrorCode STCheckNullSpace_Default(ST st,BV V) { PetscErrorCode ierr; PetscInt nc,i,c; PetscReal norm; Vec *T,w,vi; Mat A; PC pc; MatNullSpace nullsp; PetscFunctionBegin; ierr = BVGetNumConstraints(V,&nc);CHKERRQ(ierr); ierr = PetscMalloc1(nc,&T);CHKERRQ(ierr); if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = PCGetOperators(pc,&A,NULL);CHKERRQ(ierr); ierr = MatCreateVecs(A,NULL,&w);CHKERRQ(ierr); c = 0; for (i=0;i0) { ierr = MatNullSpaceCreate(PetscObjectComm((PetscObject)st),PETSC_FALSE,c,T,&nullsp);CHKERRQ(ierr); ierr = MatSetNullSpace(A,nullsp);CHKERRQ(ierr); ierr = MatNullSpaceDestroy(&nullsp);CHKERRQ(ierr); ierr = VecDestroyVecs(c,&T);CHKERRQ(ierr); } else { ierr = PetscFree(T);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCheckNullSpace" /*@ STCheckNullSpace - Given a basis vectors object, this function tests each of its constraint vectors to be a nullspace vector of the coefficient matrix of the associated KSP object. All these nullspace vectors are passed to the KSP object. Collective on ST Input Parameters: + st - the spectral transformation context - V - basis vectors to be checked Note: This function allows to handle singular pencils and to solve some problems in which the nullspace is important (see the users guide for details). Level: developer .seealso: EPSSetDeflationSpace() @*/ PetscErrorCode STCheckNullSpace(ST st,BV V) { PetscErrorCode ierr; PetscInt nc; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(V,BV_CLASSID,2); PetscValidType(st,1); PetscCheckSameComm(st,1,V,2); ierr = BVGetNumConstraints(V,&nc);CHKERRQ(ierr); if (nc && st->ops->checknullspace) { ierr = (*st->ops->checknullspace)(st,V);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/interface/stfunc.c.html0000644000175000017500000017173013107004621022235 0ustar jromanjroman
Actual source code: stfunc.c

slepc-3.7.4 2017-05-17
  1: /*
  2:     The ST (spectral transformation) interface routines, callable by users.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/stimpl.h>            /*I "slepcst.h" I*/

 26: PetscClassId     ST_CLASSID = 0;
 27: PetscLogEvent    ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;
 28: static PetscBool STPackageInitialized = PETSC_FALSE;

 32: /*@C
 33:    STFinalizePackage - This function destroys everything in the Slepc interface
 34:    to the ST package. It is called from SlepcFinalize().

 36:    Level: developer

 38: .seealso: SlepcFinalize()
 39: @*/
 40: PetscErrorCode STFinalizePackage(void)
 41: {

 45:   PetscFunctionListDestroy(&STList);
 46:   STPackageInitialized = PETSC_FALSE;
 47:   STRegisterAllCalled  = PETSC_FALSE;
 48:   return(0);
 49: }

 53: /*@C
 54:    STInitializePackage - This function initializes everything in the ST package.
 55:    It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 56:    on the first call to STCreate() when using static libraries.

 58:    Level: developer

 60: .seealso: SlepcInitialize()
 61: @*/
 62: PetscErrorCode STInitializePackage(void)
 63: {
 64:   char           logList[256];
 65:   char           *className;
 66:   PetscBool      opt;

 70:   if (STPackageInitialized) return(0);
 71:   STPackageInitialized = PETSC_TRUE;
 72:   /* Register Classes */
 73:   PetscClassIdRegister("Spectral Transform",&ST_CLASSID);
 74:   /* Register Constructors */
 75:   STRegisterAll();
 76:   /* Register Events */
 77:   PetscLogEventRegister("STSetUp",ST_CLASSID,&ST_SetUp);
 78:   PetscLogEventRegister("STApply",ST_CLASSID,&ST_Apply);
 79:   PetscLogEventRegister("STApplyTranspose",ST_CLASSID,&ST_ApplyTranspose);
 80:   PetscLogEventRegister("STMatSetUp",ST_CLASSID,&ST_MatSetUp);
 81:   PetscLogEventRegister("STMatMult",ST_CLASSID,&ST_MatMult);
 82:   PetscLogEventRegister("STMatMultTranspose",ST_CLASSID,&ST_MatMultTranspose);
 83:   PetscLogEventRegister("STMatSolve",ST_CLASSID,&ST_MatSolve);
 84:   PetscLogEventRegister("STMatSolveTranspose",ST_CLASSID,&ST_MatSolveTranspose);
 85:   /* Process info exclusions */
 86:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 87:   if (opt) {
 88:     PetscStrstr(logList,"st",&className);
 89:     if (className) {
 90:       PetscInfoDeactivateClass(ST_CLASSID);
 91:     }
 92:   }
 93:   /* Process summary exclusions */
 94:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 95:   if (opt) {
 96:     PetscStrstr(logList,"st",&className);
 97:     if (className) {
 98:       PetscLogEventDeactivateClass(ST_CLASSID);
 99:     }
100:   }
101:   PetscRegisterFinalize(STFinalizePackage);
102:   return(0);
103: }

107: /*@
108:    STReset - Resets the ST context and removes any allocated objects.

110:    Collective on ST

112:    Input Parameter:
113: .  st - the spectral transformation context

115:    Level: advanced

117: .seealso: STDestroy()
118: @*/
119: PetscErrorCode STReset(ST st)
120: {

125:   if (st->ops->reset) { (*st->ops->reset)(st); }
126:   if (st->ksp) { KSPReset(st->ksp); }
127:   MatDestroyMatrices(PetscMax(2,st->nmat),&st->T);
128:   VecDestroy(&st->w);
129:   VecDestroy(&st->wb);
130:   st->state = ST_STATE_INITIAL;
131:   return(0);
132: }

136: /*@
137:    STDestroy - Destroys ST context that was created with STCreate().

139:    Collective on ST

141:    Input Parameter:
142: .  st - the spectral transformation context

144:    Level: beginner

146: .seealso: STCreate(), STSetUp()
147: @*/
148: PetscErrorCode STDestroy(ST *st)
149: {

153:   if (!*st) return(0);
155:   if (--((PetscObject)(*st))->refct > 0) { *st = 0; return(0); }
156:   STReset(*st);
157:   MatDestroyMatrices(PetscMax(2,(*st)->nmat),&(*st)->A);
158:   PetscFree((*st)->Astate);
159:   if ((*st)->ops->destroy) { (*(*st)->ops->destroy)(*st); }
160:   MatDestroy(&(*st)->P);
161:   VecDestroy(&(*st)->D);
162:   KSPDestroy(&(*st)->ksp);
163:   PetscHeaderDestroy(st);
164:   return(0);
165: }

169: /*@
170:    STCreate - Creates a spectral transformation context.

172:    Collective on MPI_Comm

174:    Input Parameter:
175: .  comm - MPI communicator

177:    Output Parameter:
178: .  st - location to put the spectral transformation context

180:    Level: beginner

182: .seealso: STSetUp(), STApply(), STDestroy(), ST
183: @*/
184: PetscErrorCode STCreate(MPI_Comm comm,ST *newst)
185: {
187:   ST             st;

191:   *newst = 0;
192:   STInitializePackage();
193:   SlepcHeaderCreate(st,ST_CLASSID,"ST","Spectral Transformation","ST",comm,STDestroy,STView);

195:   st->A            = NULL;
196:   st->Astate       = NULL;
197:   st->T            = NULL;
198:   st->P            = NULL;
199:   st->nmat         = 0;
200:   st->sigma        = 0.0;
201:   st->sigma_set    = PETSC_FALSE;
202:   st->defsigma     = 0.0;
203:   st->shift_matrix = ST_MATMODE_COPY;
204:   st->str          = DIFFERENT_NONZERO_PATTERN;
205:   st->transform    = PETSC_FALSE;

207:   st->ksp          = NULL;
208:   st->w            = NULL;
209:   st->D            = NULL;
210:   st->wb           = NULL;
211:   st->data         = NULL;
212:   st->state        = ST_STATE_INITIAL;

214:   *newst = st;
215:   return(0);
216: }

220: /*@
221:    STSetOperators - Sets the matrices associated with the eigenvalue problem.

223:    Collective on ST and Mat

225:    Input Parameters:
226: +  st - the spectral transformation context
227: .  n  - number of matrices in array A
228: -  A  - the array of matrices associated with the eigensystem

230:    Notes:
231:    It must be called before STSetUp(). If it is called again after STSetUp() then
232:    the ST object is reset.

234:    Level: intermediate

236: .seealso: STGetOperators(), STGetNumMatrices(), STSetUp(), STReset()
237:  @*/
238: PetscErrorCode STSetOperators(ST st,PetscInt n,Mat A[])
239: {
240:   PetscInt       i;
242:   PetscBool      same=PETSC_TRUE;

247:   if (n <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Must have one or more matrices, you have %D",n);
250:   if (st->state) {
251:     if (n!=st->nmat) same = PETSC_FALSE;
252:     for (i=0;same&&i<n;i++) {
253:       if (A[i]!=st->A[i]) same = PETSC_FALSE;
254:     }
255:     if (!same) { STReset(st); }
256:   } else same = PETSC_FALSE;
257:   if (!same) {
258:     MatDestroyMatrices(PetscMax(2,st->nmat),&st->A);
259:     PetscCalloc1(PetscMax(2,n),&st->A);
260:     PetscLogObjectMemory((PetscObject)st,PetscMax(2,n)*sizeof(Mat));
261:     PetscFree(st->Astate);
262:     PetscMalloc1(PetscMax(2,n),&st->Astate);
263:     PetscLogObjectMemory((PetscObject)st,PetscMax(2,n)*sizeof(PetscInt));
264:   }
265:   for (i=0;i<n;i++) {
267:     PetscObjectReference((PetscObject)A[i]);
268:     MatDestroy(&st->A[i]);
269:     st->A[i] = A[i];
270:     st->Astate[i] = ((PetscObject)A[i])->state;
271:   }
272:   if (n==1) {
273:     st->A[1] = NULL;
274:     st->Astate[1] = 0;
275:   }
276:   st->nmat = n;
277:   if (same) st->state = ST_STATE_UPDATED;
278:   else st->state = ST_STATE_INITIAL;
279:   return(0);
280: }

284: /*@
285:    STGetOperators - Gets the matrices associated with the original eigensystem.

287:    Not collective, though parallel Mats are returned if the ST is parallel

289:    Input Parameter:
290: +  st - the spectral transformation context
291: -  k  - the index of the requested matrix (starting in 0)

293:    Output Parameters:
294: .  A - the requested matrix

296:    Level: intermediate

298: .seealso: STSetOperators(), STGetNumMatrices()
299: @*/
300: PetscErrorCode STGetOperators(ST st,PetscInt k,Mat *A)
301: {
306:   STCheckMatrices(st,1);
307:   if (k<0 || k>=st->nmat) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat-1);
308:   if (((PetscObject)st->A[k])->state!=st->Astate[k]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot retrieve original matrices (have been modified)");
309:   *A = st->A[k];
310:   return(0);
311: }

315: /*@
316:    STGetTOperators - Gets the matrices associated with the transformed eigensystem.

318:    Not collective, though parallel Mats are returned if the ST is parallel

320:    Input Parameter:
321: +  st - the spectral transformation context
322: -  k  - the index of the requested matrix (starting in 0)

324:    Output Parameters:
325: .  T - the requested matrix

327:    Level: developer

329: .seealso: STGetOperators(), STGetNumMatrices()
330: @*/
331: PetscErrorCode STGetTOperators(ST st,PetscInt k,Mat *T)
332: {
337:   STCheckMatrices(st,1);
338:   if (k<0 || k>=st->nmat) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat-1);
339:   if (!st->T) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_POINTER,"There are no transformed matrices");
340:   *T = st->T[k];
341:   return(0);
342: }

346: /*@
347:    STGetNumMatrices - Returns the number of matrices stored in the ST.

349:    Not collective

351:    Input Parameter:
352: .  st - the spectral transformation context

354:    Output Parameters:
355: .  n - the number of matrices passed in STSetOperators()

357:    Level: intermediate

359: .seealso: STSetOperators()
360: @*/
361: PetscErrorCode STGetNumMatrices(ST st,PetscInt *n)
362: {
366:   *n = st->nmat;
367:   return(0);
368: }

372: /*@
373:    STSetShift - Sets the shift associated with the spectral transformation.

375:    Logically Collective on ST

377:    Input Parameters:
378: +  st - the spectral transformation context
379: -  shift - the value of the shift

381:    Notes:
382:    In some spectral transformations, changing the shift may have associated
383:    a lot of work, for example recomputing a factorization.

385:    This function is normally not directly called by users, since the shift is
386:    indirectly set by EPSSetTarget().

388:    Level: intermediate

390: .seealso: EPSSetTarget(), STGetShift(), STSetDefaultShift()
391: @*/
392: PetscErrorCode STSetShift(ST st,PetscScalar shift)
393: {

399:   if (st->state==ST_STATE_SETUP && st->sigma != shift) {
400:     if (st->ops->setshift) {
401:       (*st->ops->setshift)(st,shift);
402:     }
403:   }
404:   st->sigma = shift;
405:   st->sigma_set = PETSC_TRUE;
406:   return(0);
407: }

411: /*@
412:    STGetShift - Gets the shift associated with the spectral transformation.

414:    Not Collective

416:    Input Parameter:
417: .  st - the spectral transformation context

419:    Output Parameter:
420: .  shift - the value of the shift

422:    Level: intermediate

424: .seealso: STSetShift()
425: @*/
426: PetscErrorCode STGetShift(ST st,PetscScalar* shift)
427: {
431:   *shift = st->sigma;
432:   return(0);
433: }

437: /*@
438:    STSetDefaultShift - Sets the value of the shift that should be employed if
439:    the user did not specify one.

441:    Logically Collective on ST

443:    Input Parameters:
444: +  st - the spectral transformation context
445: -  defaultshift - the default value of the shift

447:    Level: developer

449: .seealso: STSetShift()
450: @*/
451: PetscErrorCode STSetDefaultShift(ST st,PetscScalar defaultshift)
452: {
456:   st->defsigma = defaultshift;
457:   return(0);
458: }

462: /*@
463:    STScaleShift - Multiply the shift with a given factor.

465:    Logically Collective on ST

467:    Input Parameters:
468: +  st     - the spectral transformation context
469: -  factor - the scaling factor

471:    Note:
472:    This function does not update the transformation matrices, as opposed to
473:    STSetShift().

475:    Level: developer

477: .seealso: STSetShift()
478: @*/
479: PetscErrorCode STScaleShift(ST st,PetscScalar factor)
480: {
484:   st->sigma *= factor;
485:   return(0);
486: }

490: /*@
491:    STSetBalanceMatrix - Sets the diagonal matrix to be used for balancing.

493:    Collective on ST and Vec

495:    Input Parameters:
496: +  st - the spectral transformation context
497: -  D  - the diagonal matrix (represented as a vector)

499:    Notes:
500:    If this matrix is set, STApply will effectively apply D*OP*D^{-1}.

502:    Balancing is usually set via EPSSetBalance, but the advanced user may use
503:    this function to bypass the usual balancing methods.

505:    Level: developer

507: .seealso: EPSSetBalance(), STApply(), STGetBalanceMatrix()
508: @*/
509: PetscErrorCode STSetBalanceMatrix(ST st,Vec D)
510: {

517:   PetscObjectReference((PetscObject)D);
518:   VecDestroy(&st->D);
519:   st->D = D;
520:   st->state = ST_STATE_INITIAL;
521:   return(0);
522: }

526: /*@
527:    STGetBalanceMatrix - Gets the balance matrix used by the spectral transformation.

529:    Not collective, but vector is shared by all processors that share the ST

531:    Input Parameter:
532: .  st - the spectral transformation context

534:    Output Parameter:
535: .  D  - the diagonal matrix (represented as a vector)

537:    Note:
538:    If the matrix was not set, a null pointer will be returned.

540:    Level: developer

542: .seealso: STSetBalanceMatrix()
543: @*/
544: PetscErrorCode STGetBalanceMatrix(ST st,Vec *D)
545: {
549:   *D = st->D;
550:   return(0);
551: }

555: /*@C
556:    STMatCreateVecs - Get vector(s) compatible with the ST matrices.

558:    Collective on ST

560:    Input Parameter:
561: .  st - the spectral transformation context

563:    Output Parameters:
564: +  right - (optional) vector that the matrix can be multiplied against
565: -  left  - (optional) vector that the matrix vector product can be stored in

567:    Level: developer
568: @*/
569: PetscErrorCode STMatCreateVecs(ST st,Vec *right,Vec *left)
570: {

574:   STCheckMatrices(st,1);
575:   MatCreateVecs(st->A[0],right,left);
576:   return(0);
577: }

581: /*@
582:    STMatGetSize - Returns the number of rows and columns of the ST matrices.

584:    Not Collective

586:    Input Parameter:
587: .  st - the spectral transformation context

589:    Output Parameters:
590: +  m - the number of global rows
591: -  n - the number of global columns

593:    Level: developer
594: @*/
595: PetscErrorCode STMatGetSize(ST st,PetscInt *m,PetscInt *n)
596: {

600:   STCheckMatrices(st,1);
601:   MatGetSize(st->A[0],m,n);
602:   return(0);
603: }

607: /*@
608:    STMatGetLocalSize - Returns the number of local rows and columns of the ST matrices.

610:    Not Collective

612:    Input Parameter:
613: .  st - the spectral transformation context

615:    Output Parameters:
616: +  m - the number of local rows
617: -  n - the number of local columns

619:    Level: developer
620: @*/
621: PetscErrorCode STMatGetLocalSize(ST st,PetscInt *m,PetscInt *n)
622: {

626:   STCheckMatrices(st,1);
627:   MatGetLocalSize(st->A[0],m,n);
628:   return(0);
629: } 

633: /*@C
634:    STSetOptionsPrefix - Sets the prefix used for searching for all
635:    ST options in the database.

637:    Logically Collective on ST

639:    Input Parameters:
640: +  st     - the spectral transformation context
641: -  prefix - the prefix string to prepend to all ST option requests

643:    Notes:
644:    A hyphen (-) must NOT be given at the beginning of the prefix name.
645:    The first character of all runtime options is AUTOMATICALLY the
646:    hyphen.

648:    Level: advanced

650: .seealso: STAppendOptionsPrefix(), STGetOptionsPrefix()
651: @*/
652: PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix)
653: {

658:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
659:   KSPSetOptionsPrefix(st->ksp,prefix);
660:   KSPAppendOptionsPrefix(st->ksp,"st_");
661:   PetscObjectSetOptionsPrefix((PetscObject)st,prefix);
662:   return(0);
663: }

667: /*@C
668:    STAppendOptionsPrefix - Appends to the prefix used for searching for all
669:    ST options in the database.

671:    Logically Collective on ST

673:    Input Parameters:
674: +  st     - the spectral transformation context
675: -  prefix - the prefix string to prepend to all ST option requests

677:    Notes:
678:    A hyphen (-) must NOT be given at the beginning of the prefix name.
679:    The first character of all runtime options is AUTOMATICALLY the
680:    hyphen.

682:    Level: advanced

684: .seealso: STSetOptionsPrefix(), STGetOptionsPrefix()
685: @*/
686: PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix)
687: {

692:   PetscObjectAppendOptionsPrefix((PetscObject)st,prefix);
693:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
694:   KSPSetOptionsPrefix(st->ksp,((PetscObject)st)->prefix);
695:   KSPAppendOptionsPrefix(st->ksp,"st_");
696:   return(0);
697: }

701: /*@C
702:    STGetOptionsPrefix - Gets the prefix used for searching for all
703:    ST options in the database.

705:    Not Collective

707:    Input Parameters:
708: .  st - the spectral transformation context

710:    Output Parameters:
711: .  prefix - pointer to the prefix string used, is returned

713:    Note:
714:    On the Fortran side, the user should pass in a string 'prefix' of
715:    sufficient length to hold the prefix.

717:    Level: advanced

719: .seealso: STSetOptionsPrefix(), STAppendOptionsPrefix()
720: @*/
721: PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[])
722: {

728:   PetscObjectGetOptionsPrefix((PetscObject)st,prefix);
729:   return(0);
730: }

734: /*@C
735:    STView - Prints the ST data structure.

737:    Collective on ST

739:    Input Parameters:
740: +  st - the ST context
741: -  viewer - optional visualization context

743:    Note:
744:    The available visualization contexts include
745: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
746: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
747:          output where only the first processor opens
748:          the file.  All other processors send their
749:          data to the first processor to print.

751:    The user can open an alternative visualization contexts with
752:    PetscViewerASCIIOpen() (output to a specified file).

754:    Level: beginner

756: .seealso: EPSView(), PetscViewerASCIIOpen()
757: @*/
758: PetscErrorCode STView(ST st,PetscViewer viewer)
759: {
761:   STType         cstr;
762:   const char*    pat;
763:   char           str[50];
764:   PetscBool      isascii,isstring,flg;

768:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)st));

772:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
773:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERSTRING,&isstring);
774:   if (isascii) {
775:     PetscObjectPrintClassNamePrefixType((PetscObject)st,viewer);
776:     if (st->ops->view) {
777:       PetscViewerASCIIPushTab(viewer);
778:       (*st->ops->view)(st,viewer);
779:       PetscViewerASCIIPopTab(viewer);
780:     }
781:     SlepcSNPrintfScalar(str,50,st->sigma,PETSC_FALSE);
782:     PetscViewerASCIIPrintf(viewer,"  shift: %s\n",str);
783:     PetscViewerASCIIPrintf(viewer,"  number of matrices: %D\n",st->nmat);
784:     switch (st->shift_matrix) {
785:     case ST_MATMODE_COPY:
786:       break;
787:     case ST_MATMODE_INPLACE:
788:       PetscViewerASCIIPrintf(viewer,"  shifting the matrix and unshifting at exit\n");
789:       break;
790:     case ST_MATMODE_SHELL:
791:       PetscViewerASCIIPrintf(viewer,"  using a shell matrix\n");
792:       break;
793:     }
794:     if (st->nmat>1 && st->shift_matrix != ST_MATMODE_SHELL) {
795:       switch (st->str) {
796:         case SAME_NONZERO_PATTERN:      pat = "same nonzero pattern";break;
797:         case DIFFERENT_NONZERO_PATTERN: pat = "different nonzero pattern";break;
798:         case SUBSET_NONZERO_PATTERN:    pat = "subset nonzero pattern";break;
799:         default: SETERRQ(PetscObjectComm((PetscObject)st),1,"Wrong structure flag");
800:       }
801:       PetscViewerASCIIPrintf(viewer,"  all matrices have %s\n",pat);
802:     }
803:     if (st->transform && st->nmat>2) {
804:       PetscViewerASCIIPrintf(viewer,"  computing transformed matrices\n");
805:     }
806:   } else if (isstring) {
807:     STGetType(st,&cstr);
808:     PetscViewerStringSPrintf(viewer," %-7.7s",cstr);
809:     if (st->ops->view) { (*st->ops->view)(st,viewer); }
810:   }
811:   PetscObjectTypeCompare((PetscObject)st,STSHIFT,&flg);
812:   if (st->nmat>1 || !flg) {
813:     if (!st->ksp) { STGetKSP(st,&st->ksp); }
814:     PetscViewerASCIIPushTab(viewer);
815:     KSPView(st->ksp,viewer);
816:     PetscViewerASCIIPopTab(viewer);
817:   }
818:   return(0);
819: }

823: /*@C
824:    STRegister - Adds a method to the spectral transformation package.

826:    Not collective

828:    Input Parameters:
829: +  name - name of a new user-defined transformation
830: -  function - routine to create method context

832:    Notes:
833:    STRegister() may be called multiple times to add several user-defined
834:    spectral transformations.

836:    Sample usage:
837: .vb
838:     STRegister("my_transform",MyTransformCreate);
839: .ve

841:    Then, your spectral transform can be chosen with the procedural interface via
842: $     STSetType(st,"my_transform")
843:    or at runtime via the option
844: $     -st_type my_transform

846:    Level: advanced

848: .seealso: STRegisterAll()
849: @*/
850: PetscErrorCode STRegister(const char *name,PetscErrorCode (*function)(ST))
851: {

855:   PetscFunctionListAdd(&STList,name,function);
856:   return(0);
857: }

slepc-3.7.4/src/sys/classes/st/interface/index.html0000644000175000017500000000423513107004621021614 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

stfunc.c
stset.c
stsolve.c
stsles.c
stregis.c
stshellmat.c
makefile
slepc-3.7.4/src/sys/classes/st/interface/ftn-auto/0000755000175000017500000000000013107004621021350 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/interface/ftn-auto/makefile0000644000175000017500000000042713107004621023053 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = stfuncf.c stsetf.c stslesf.c stsolvef.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/st/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/interface/ftn-auto/stfuncf.c0000644000175000017500000001334713107004621023174 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* stfunc.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcst.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define streset_ STRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define streset_ streset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stdestroy_ STDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stdestroy_ stdestroy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stcreate_ STCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stcreate_ stcreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetoperators_ STSETOPERATORS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetoperators_ stsetoperators #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetoperators_ STGETOPERATORS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetoperators_ stgetoperators #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgettoperators_ STGETTOPERATORS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgettoperators_ stgettoperators #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetnummatrices_ STGETNUMMATRICES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetnummatrices_ stgetnummatrices #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetshift_ STSETSHIFT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetshift_ stsetshift #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetshift_ STGETSHIFT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetshift_ stgetshift #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetdefaultshift_ STSETDEFAULTSHIFT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetdefaultshift_ stsetdefaultshift #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stscaleshift_ STSCALESHIFT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stscaleshift_ stscaleshift #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetbalancematrix_ STSETBALANCEMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetbalancematrix_ stsetbalancematrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetbalancematrix_ STGETBALANCEMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetbalancematrix_ stgetbalancematrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stmatgetsize_ STMATGETSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stmatgetsize_ stmatgetsize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stmatgetlocalsize_ STMATGETLOCALSIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stmatgetlocalsize_ stmatgetlocalsize #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL streset_(ST st, int *__ierr ){ *__ierr = STReset( (ST)PetscToPointer((st) )); } PETSC_EXTERN void PETSC_STDCALL stdestroy_(ST *st, int *__ierr ){ *__ierr = STDestroy(st); } PETSC_EXTERN void PETSC_STDCALL stcreate_(MPI_Fint * comm,ST *newst, int *__ierr ){ *__ierr = STCreate( MPI_Comm_f2c(*(comm)),newst); } PETSC_EXTERN void PETSC_STDCALL stsetoperators_(ST st,PetscInt *n,Mat A[], int *__ierr ){ *__ierr = STSetOperators( (ST)PetscToPointer((st) ),*n,A); } PETSC_EXTERN void PETSC_STDCALL stgetoperators_(ST st,PetscInt *k,Mat *A, int *__ierr ){ *__ierr = STGetOperators( (ST)PetscToPointer((st) ),*k,A); } PETSC_EXTERN void PETSC_STDCALL stgettoperators_(ST st,PetscInt *k,Mat *T, int *__ierr ){ *__ierr = STGetTOperators( (ST)PetscToPointer((st) ),*k,T); } PETSC_EXTERN void PETSC_STDCALL stgetnummatrices_(ST st,PetscInt *n, int *__ierr ){ *__ierr = STGetNumMatrices( (ST)PetscToPointer((st) ),n); } PETSC_EXTERN void PETSC_STDCALL stsetshift_(ST st,PetscScalar *shift, int *__ierr ){ *__ierr = STSetShift( (ST)PetscToPointer((st) ),*shift); } PETSC_EXTERN void PETSC_STDCALL stgetshift_(ST st,PetscScalar* shift, int *__ierr ){ *__ierr = STGetShift( (ST)PetscToPointer((st) ),shift); } PETSC_EXTERN void PETSC_STDCALL stsetdefaultshift_(ST st,PetscScalar *defaultshift, int *__ierr ){ *__ierr = STSetDefaultShift( (ST)PetscToPointer((st) ),*defaultshift); } PETSC_EXTERN void PETSC_STDCALL stscaleshift_(ST st,PetscScalar *factor, int *__ierr ){ *__ierr = STScaleShift( (ST)PetscToPointer((st) ),*factor); } PETSC_EXTERN void PETSC_STDCALL stsetbalancematrix_(ST st,Vec D, int *__ierr ){ *__ierr = STSetBalanceMatrix( (ST)PetscToPointer((st) ), (Vec)PetscToPointer((D) )); } PETSC_EXTERN void PETSC_STDCALL stgetbalancematrix_(ST st,Vec *D, int *__ierr ){ *__ierr = STGetBalanceMatrix( (ST)PetscToPointer((st) ),D); } PETSC_EXTERN void PETSC_STDCALL stmatgetsize_(ST st,PetscInt *m,PetscInt *n, int *__ierr ){ *__ierr = STMatGetSize( (ST)PetscToPointer((st) ),m,n); } PETSC_EXTERN void PETSC_STDCALL stmatgetlocalsize_(ST st,PetscInt *m,PetscInt *n, int *__ierr ){ *__ierr = STMatGetLocalSize( (ST)PetscToPointer((st) ),m,n); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/st/interface/ftn-auto/stsetf.c0000644000175000017500000000614413107004621023031 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* stset.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcst.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetfromoptions_ STSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetfromoptions_ stsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetmatstructure_ STSETMATSTRUCTURE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetmatstructure_ stsetmatstructure #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetmatstructure_ STGETMATSTRUCTURE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetmatstructure_ stgetmatstructure #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetmatmode_ STSETMATMODE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetmatmode_ stsetmatmode #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetmatmode_ STGETMATMODE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetmatmode_ stgetmatmode #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsettransform_ STSETTRANSFORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsettransform_ stsettransform #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgettransform_ STGETTRANSFORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgettransform_ stgettransform #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL stsetfromoptions_(ST st, int *__ierr ){ *__ierr = STSetFromOptions( (ST)PetscToPointer((st) )); } PETSC_EXTERN void PETSC_STDCALL stsetmatstructure_(ST st,MatStructure *str, int *__ierr ){ *__ierr = STSetMatStructure( (ST)PetscToPointer((st) ),*str); } PETSC_EXTERN void PETSC_STDCALL stgetmatstructure_(ST st,MatStructure *str, int *__ierr ){ *__ierr = STGetMatStructure( (ST)PetscToPointer((st) ),str); } PETSC_EXTERN void PETSC_STDCALL stsetmatmode_(ST st,STMatMode *mode, int *__ierr ){ *__ierr = STSetMatMode( (ST)PetscToPointer((st) ),*mode); } PETSC_EXTERN void PETSC_STDCALL stgetmatmode_(ST st,STMatMode *mode, int *__ierr ){ *__ierr = STGetMatMode( (ST)PetscToPointer((st) ),mode); } PETSC_EXTERN void PETSC_STDCALL stsettransform_(ST st,PetscBool *flg, int *__ierr ){ *__ierr = STSetTransform( (ST)PetscToPointer((st) ),*flg); } PETSC_EXTERN void PETSC_STDCALL stgettransform_(ST st,PetscBool *flg, int *__ierr ){ *__ierr = STGetTransform( (ST)PetscToPointer((st) ),flg); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/st/interface/ftn-auto/stslesf.c0000644000175000017500000000642313107004621023204 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* stsles.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcst.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define stmatmult_ STMATMULT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stmatmult_ stmatmult #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stmatmulttranspose_ STMATMULTTRANSPOSE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stmatmulttranspose_ stmatmulttranspose #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stmatsolve_ STMATSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stmatsolve_ stmatsolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stmatsolvetranspose_ STMATSOLVETRANSPOSE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stmatsolvetranspose_ stmatsolvetranspose #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetksp_ STSETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetksp_ stsetksp #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetksp_ STGETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetksp_ stgetksp #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stchecknullspace_ STCHECKNULLSPACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stchecknullspace_ stchecknullspace #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL stmatmult_(ST st,PetscInt *k,Vec x,Vec y, int *__ierr ){ *__ierr = STMatMult( (ST)PetscToPointer((st) ),*k, (Vec)PetscToPointer((x) ), (Vec)PetscToPointer((y) )); } PETSC_EXTERN void PETSC_STDCALL stmatmulttranspose_(ST st,PetscInt *k,Vec x,Vec y, int *__ierr ){ *__ierr = STMatMultTranspose( (ST)PetscToPointer((st) ),*k, (Vec)PetscToPointer((x) ), (Vec)PetscToPointer((y) )); } PETSC_EXTERN void PETSC_STDCALL stmatsolve_(ST st,Vec b,Vec x, int *__ierr ){ *__ierr = STMatSolve( (ST)PetscToPointer((st) ), (Vec)PetscToPointer((b) ), (Vec)PetscToPointer((x) )); } PETSC_EXTERN void PETSC_STDCALL stmatsolvetranspose_(ST st,Vec b,Vec x, int *__ierr ){ *__ierr = STMatSolveTranspose( (ST)PetscToPointer((st) ), (Vec)PetscToPointer((b) ), (Vec)PetscToPointer((x) )); } PETSC_EXTERN void PETSC_STDCALL stsetksp_(ST st,KSP ksp, int *__ierr ){ *__ierr = STSetKSP( (ST)PetscToPointer((st) ), (KSP)PetscToPointer((ksp) )); } PETSC_EXTERN void PETSC_STDCALL stgetksp_(ST st,KSP* ksp, int *__ierr ){ *__ierr = STGetKSP( (ST)PetscToPointer((st) ),ksp); } PETSC_EXTERN void PETSC_STDCALL stchecknullspace_(ST st,BV V, int *__ierr ){ *__ierr = STCheckNullSpace( (ST)PetscToPointer((st) ), (BV)PetscToPointer((V) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/st/interface/ftn-auto/stsolvef.c0000644000175000017500000000701613107004621023365 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* stsolve.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcst.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define stapply_ STAPPLY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stapply_ stapply #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stapplytranspose_ STAPPLYTRANSPOSE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stapplytranspose_ stapplytranspose #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stgetbilinearform_ STGETBILINEARFORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stgetbilinearform_ stgetbilinearform #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stcomputeexplicitoperator_ STCOMPUTEEXPLICITOPERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stcomputeexplicitoperator_ stcomputeexplicitoperator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stsetup_ STSETUP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stsetup_ stsetup #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stpostsolve_ STPOSTSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stpostsolve_ stpostsolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stbacktransform_ STBACKTRANSFORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stbacktransform_ stbacktransform #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stmatsetup_ STMATSETUP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stmatsetup_ stmatsetup #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL stapply_(ST st,Vec x,Vec y, int *__ierr ){ *__ierr = STApply( (ST)PetscToPointer((st) ), (Vec)PetscToPointer((x) ), (Vec)PetscToPointer((y) )); } PETSC_EXTERN void PETSC_STDCALL stapplytranspose_(ST st,Vec x,Vec y, int *__ierr ){ *__ierr = STApplyTranspose( (ST)PetscToPointer((st) ), (Vec)PetscToPointer((x) ), (Vec)PetscToPointer((y) )); } PETSC_EXTERN void PETSC_STDCALL stgetbilinearform_(ST st,Mat *B, int *__ierr ){ *__ierr = STGetBilinearForm( (ST)PetscToPointer((st) ),B); } PETSC_EXTERN void PETSC_STDCALL stcomputeexplicitoperator_(ST st,Mat *mat, int *__ierr ){ *__ierr = STComputeExplicitOperator( (ST)PetscToPointer((st) ),mat); } PETSC_EXTERN void PETSC_STDCALL stsetup_(ST st, int *__ierr ){ *__ierr = STSetUp( (ST)PetscToPointer((st) )); } PETSC_EXTERN void PETSC_STDCALL stpostsolve_(ST st, int *__ierr ){ *__ierr = STPostSolve( (ST)PetscToPointer((st) )); } PETSC_EXTERN void PETSC_STDCALL stbacktransform_(ST st,PetscInt *n,PetscScalar* eigr,PetscScalar* eigi, int *__ierr ){ *__ierr = STBackTransform( (ST)PetscToPointer((st) ),*n,eigr,eigi); } PETSC_EXTERN void PETSC_STDCALL stmatsetup_(ST st,PetscScalar *sigma,PetscScalar *coeffs, int *__ierr ){ *__ierr = STMatSetUp( (ST)PetscToPointer((st) ),*sigma,coeffs); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/st/interface/stregis.c0000644000175000017500000000363513107004621021446 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ PETSC_EXTERN PetscErrorCode STCreate_Shell(ST); PETSC_EXTERN PetscErrorCode STCreate_Shift(ST); PETSC_EXTERN PetscErrorCode STCreate_Sinvert(ST); PETSC_EXTERN PetscErrorCode STCreate_Cayley(ST); PETSC_EXTERN PetscErrorCode STCreate_Precond(ST); #undef __FUNCT__ #define __FUNCT__ "STRegisterAll" /*@C STRegisterAll - Registers all of the spectral transformations in the ST package. Not Collective Level: advanced .seealso: STRegister() @*/ PetscErrorCode STRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (STRegisterAllCalled) PetscFunctionReturn(0); STRegisterAllCalled = PETSC_TRUE; ierr = STRegister(STSHELL,STCreate_Shell);CHKERRQ(ierr); ierr = STRegister(STSHIFT,STCreate_Shift);CHKERRQ(ierr); ierr = STRegister(STSINVERT,STCreate_Sinvert);CHKERRQ(ierr); ierr = STRegister(STCAYLEY,STCreate_Cayley);CHKERRQ(ierr); ierr = STRegister(STPRECOND,STCreate_Precond);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/interface/stset.c.html0000644000175000017500000007461113107004621022075 0ustar jromanjroman

Actual source code: stset.c

slepc-3.7.4 2017-05-17
  1: /*
  2:     Routines to set ST methods and options.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/stimpl.h>      /*I "slepcst.h" I*/

 26: PetscBool         STRegisterAllCalled = PETSC_FALSE;
 27: PetscFunctionList STList = 0;

 31: /*@C
 32:    STSetType - Builds ST for a particular spectral transformation.

 34:    Logically Collective on ST

 36:    Input Parameter:
 37: +  st   - the spectral transformation context.
 38: -  type - a known type

 40:    Options Database Key:
 41: .  -st_type <type> - Sets ST type

 43:    Use -help for a list of available transformations

 45:    Notes:
 46:    See "slepc/include/slepcst.h" for available transformations

 48:    Normally, it is best to use the EPSSetFromOptions() command and
 49:    then set the ST type from the options database rather than by using
 50:    this routine.  Using the options database provides the user with
 51:    maximum flexibility in evaluating the many different transformations.

 53:    Level: beginner

 55: .seealso: EPSSetType()

 57: @*/
 58: PetscErrorCode STSetType(ST st,STType type)
 59: {
 60:   PetscErrorCode ierr,(*r)(ST);
 61:   PetscBool      match;


 67:   PetscObjectTypeCompare((PetscObject)st,type,&match);
 68:   if (match) return(0);

 70:    PetscFunctionListFind(STList,type,&r);
 71:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested ST type %s",type);

 73:   if (st->ops->destroy) { (*st->ops->destroy)(st); }
 74:   PetscMemzero(st->ops,sizeof(struct _STOps));

 76:   st->state = ST_STATE_INITIAL;
 77:   PetscObjectChangeTypeName((PetscObject)st,type);
 78:   (*r)(st);
 79:   return(0);
 80: }

 84: /*@C
 85:    STGetType - Gets the ST type name (as a string) from the ST context.

 87:    Not Collective

 89:    Input Parameter:
 90: .  st - the spectral transformation context

 92:    Output Parameter:
 93: .  name - name of the spectral transformation

 95:    Level: intermediate

 97: .seealso: STSetType()

 99: @*/
100: PetscErrorCode STGetType(ST st,STType *type)
101: {
105:   *type = ((PetscObject)st)->type_name;
106:   return(0);
107: }

111: /*@
112:    STSetFromOptions - Sets ST options from the options database.
113:    This routine must be called before STSetUp() if the user is to be
114:    allowed to set the type of transformation.

116:    Collective on ST

118:    Input Parameter:
119: .  st - the spectral transformation context

121:    Level: beginner
122: @*/
123: PetscErrorCode STSetFromOptions(ST st)
124: {
126:   PetscInt       i;
127:   PetscScalar    s;
128:   char           type[256];
129:   PetscBool      flg;
130:   const char     *mode_list[3] = {"copy","inplace","shell"};
131:   const char     *structure_list[3] = {"same","different","subset"};

135:   STRegisterAll();
136:   PetscObjectOptionsBegin((PetscObject)st);
137:     PetscOptionsFList("-st_type","Spectral Transformation type","STSetType",STList,(char*)(((PetscObject)st)->type_name?((PetscObject)st)->type_name:STSHIFT),type,256,&flg);
138:     if (flg) {
139:       STSetType(st,type);
140:     }
141:     /*
142:       Set the type if it was never set.
143:     */
144:     if (!((PetscObject)st)->type_name) {
145:       STSetType(st,STSHIFT);
146:     }

148:     PetscOptionsScalar("-st_shift","Value of the shift","STSetShift",st->sigma,&s,&flg);
149:     if (flg) {
150:       STSetShift(st,s);
151:     }

153:     PetscOptionsEList("-st_matmode","Matrix mode for transformed matrices","STSetMatMode",mode_list,3,mode_list[st->shift_matrix],&i,&flg);
154:     if (flg) st->shift_matrix = (STMatMode)i;

156:     PetscOptionsEList("-st_matstructure","Shift nonzero pattern","STSetMatStructure",structure_list,3,structure_list[st->str],&i,&flg);
157:     if (flg) {
158:       switch (i) {
159:         case 0: STSetMatStructure(st,SAME_NONZERO_PATTERN); break;
160:         case 1: STSetMatStructure(st,DIFFERENT_NONZERO_PATTERN); break;
161:         case 2: STSetMatStructure(st,SUBSET_NONZERO_PATTERN); break;
162:       }
163:     }

165:     PetscOptionsBool("-st_transform","Whether transformed matrices are computed or not","STSetTransform",st->transform,&st->transform,&flg);

167:     if (st->ops->setfromoptions) {
168:       (*st->ops->setfromoptions)(PetscOptionsObject,st);
169:     }
170:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)st);
171:   PetscOptionsEnd();
172:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
173:   KSPSetFromOptions(st->ksp);
174:   return(0);
175: }

179: /*@
180:    STSetMatStructure - Sets an internal MatStructure attribute to
181:    indicate which is the relation of the sparsity pattern of all ST matrices.

183:    Logically Collective on ST

185:    Input Parameters:
186: +  st  - the spectral transformation context
187: -  str - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or
188:          SUBSET_NONZERO_PATTERN

190:    Options Database Key:
191: .  -st_matstructure <str> - Indicates the structure flag, where <str> is one
192:          of 'same' (matrices have the same nonzero pattern), 'different'
193:          (different nonzero pattern) or 'subset' (pattern is a subset of the
194:          first one).

196:    Notes:
197:    By default, the sparsity patterns are assumed to be different. If the
198:    patterns are equal or a subset then it is recommended to set this attribute
199:    for efficiency reasons (in particular, for internal MatAXPY() operations).

201:    This function has no effect in the case of standard eigenproblems.

203:    Level: advanced

205: .seealso: STSetOperators(), MatAXPY()
206: @*/
207: PetscErrorCode STSetMatStructure(ST st,MatStructure str)
208: {
212:   switch (str) {
213:     case SAME_NONZERO_PATTERN:
214:     case DIFFERENT_NONZERO_PATTERN:
215:     case SUBSET_NONZERO_PATTERN:
216:       st->str = str;
217:       break;
218:     default:
219:       SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_ARG_OUTOFRANGE,"Invalid matrix structure flag");
220:   }
221:   return(0);
222: }

226: /*@
227:    STGetMatStructure - Gets the internal MatStructure attribute to
228:    indicate which is the relation of the sparsity pattern of the matrices.

230:    Not Collective

232:    Input Parameters:
233: .  st  - the spectral transformation context

235:    Output Parameters:
236: .  str - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or
237:          SUBSET_NONZERO_PATTERN

239:    Level: advanced

241: .seealso: STSetMatStructure(), STSetOperators(), MatAXPY()
242: @*/
243: PetscErrorCode STGetMatStructure(ST st,MatStructure *str)
244: {
248:   *str = st->str;
249:   return(0);
250: }

254: /*@
255:    STSetMatMode - Sets a flag to indicate how the transformed matrices are
256:    being stored in the spectral transformations.

258:    Logically Collective on ST

260:    Input Parameters:
261: +  st - the spectral transformation context
262: -  mode - the mode flag, one of ST_MATMODE_COPY,
263:           ST_MATMODE_INPLACE, or ST_MATMODE_SHELL

265:    Options Database Key:
266: .  -st_matmode <mode> - Indicates the mode flag, where <mode> is one of
267:           'copy', 'inplace', 'shell' (see explanation below).

269:    Notes:
270:    By default (ST_MATMODE_COPY), a copy of matrix A is made and then
271:    this copy is modified explicitly, e.g. A <- (A - s B).

273:    With ST_MATMODE_INPLACE, the original matrix A is modified at STSetUp()
274:    and changes are reverted at the end of the computations. With respect to
275:    the previous one, this mode avoids a copy of matrix A. However, a
276:    drawback is that the recovered matrix might be slightly different
277:    from the original one (due to roundoff).

279:    With ST_MATMODE_SHELL, the solver works with an implicit shell
280:    matrix that represents the shifted matrix. This mode is the most efficient
281:    in creating the shifted matrix but it places serious limitations to the
282:    linear solves performed in each iteration of the eigensolver (typically,
283:    only interative solvers with Jacobi preconditioning can be used).

285:    In the two first modes the efficiency of the computation 
286:    can be controlled with STSetMatStructure().

288:    Level: intermediate

290: .seealso: STSetOperators(), STSetMatStructure(), STGetMatMode(), STMatMode
291: @*/
292: PetscErrorCode STSetMatMode(ST st,STMatMode mode)
293: {
297:   st->shift_matrix = mode;
298:   st->state = ST_STATE_INITIAL;
299:   return(0);
300: }

304: /*@
305:    STGetMatMode - Gets a flag that indicates how the transformed matrices
306:    are stored in spectral transformations.

308:    Not Collective

310:    Input Parameter:
311: .  st - the spectral transformation context

313:    Output Parameter:
314: .  mode - the mode flag

316:    Level: intermediate

318: .seealso: STSetMatMode(), STMatMode
319: @*/
320: PetscErrorCode STGetMatMode(ST st,STMatMode *mode)
321: {
325:   *mode = st->shift_matrix;
326:   return(0);
327: }

331: /*@
332:    STSetTransform - Sets a flag to indicate whether the transformed matrices are
333:    computed or not.

335:    Logically Collective on ST

337:    Input Parameters:
338: +  st  - the spectral transformation context
339: -  flg - the boolean flag

341:    Options Database Key:
342: .  -st_transform <bool> - Activate/deactivate the computation of matrices.

344:    Notes:
345:    This flag is intended for the case of polynomial eigenproblems solved
346:    via linearization. If this flag is off (default) the spectral transformation
347:    is applied to the linearization (handled by the eigensolver), otherwise
348:    it is applied to the original problem.

350:    Level: developer

352: .seealso: STMatSolve(), STMatMult(), STSetMatStructure(), STGetTransform()
353: @*/
354: PetscErrorCode STSetTransform(ST st,PetscBool flg)
355: {
359:   if (st->transform != flg) {
360:     st->transform = flg;
361:     st->state = ST_STATE_INITIAL;
362:   }
363:   return(0);
364: }

368: /*@
369:    STGetTransform - Gets a flag that that indicates whether the transformed
370:    matrices are computed or not.

372:    Not Collective

374:    Input Parameter:
375: .  st - the spectral transformation context

377:    Output Parameter:
378: .  flg - the flag

380:    Level: developer

382: .seealso: STSetTransform()
383: @*/
384: PetscErrorCode STGetTransform(ST st,PetscBool *flg)
385: {
389:   *flg = st->transform;
390:   return(0);
391: }

slepc-3.7.4/src/sys/classes/st/interface/stfunc.c0000644000175000017500000006055313107004621021272 0ustar jromanjroman/* The ST (spectral transformation) interface routines, callable by users. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ PetscClassId ST_CLASSID = 0; PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0; static PetscBool STPackageInitialized = PETSC_FALSE; #undef __FUNCT__ #define __FUNCT__ "STFinalizePackage" /*@C STFinalizePackage - This function destroys everything in the Slepc interface to the ST package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode STFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&STList);CHKERRQ(ierr); STPackageInitialized = PETSC_FALSE; STRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STInitializePackage" /*@C STInitializePackage - This function initializes everything in the ST package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to STCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode STInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (STPackageInitialized) PetscFunctionReturn(0); STPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("Spectral Transform",&ST_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = STRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("STSetUp",ST_CLASSID,&ST_SetUp);CHKERRQ(ierr); ierr = PetscLogEventRegister("STApply",ST_CLASSID,&ST_Apply);CHKERRQ(ierr); ierr = PetscLogEventRegister("STApplyTranspose",ST_CLASSID,&ST_ApplyTranspose);CHKERRQ(ierr); ierr = PetscLogEventRegister("STMatSetUp",ST_CLASSID,&ST_MatSetUp);CHKERRQ(ierr); ierr = PetscLogEventRegister("STMatMult",ST_CLASSID,&ST_MatMult);CHKERRQ(ierr); ierr = PetscLogEventRegister("STMatMultTranspose",ST_CLASSID,&ST_MatMultTranspose);CHKERRQ(ierr); ierr = PetscLogEventRegister("STMatSolve",ST_CLASSID,&ST_MatSolve);CHKERRQ(ierr); ierr = PetscLogEventRegister("STMatSolveTranspose",ST_CLASSID,&ST_MatSolveTranspose);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"st",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(ST_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"st",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(ST_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(STFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STReset" /*@ STReset - Resets the ST context and removes any allocated objects. Collective on ST Input Parameter: . st - the spectral transformation context Level: advanced .seealso: STDestroy() @*/ PetscErrorCode STReset(ST st) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); if (st->ops->reset) { ierr = (*st->ops->reset)(st);CHKERRQ(ierr); } if (st->ksp) { ierr = KSPReset(st->ksp);CHKERRQ(ierr); } ierr = MatDestroyMatrices(PetscMax(2,st->nmat),&st->T);CHKERRQ(ierr); ierr = VecDestroy(&st->w);CHKERRQ(ierr); ierr = VecDestroy(&st->wb);CHKERRQ(ierr); st->state = ST_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STDestroy" /*@ STDestroy - Destroys ST context that was created with STCreate(). Collective on ST Input Parameter: . st - the spectral transformation context Level: beginner .seealso: STCreate(), STSetUp() @*/ PetscErrorCode STDestroy(ST *st) { PetscErrorCode ierr; PetscFunctionBegin; if (!*st) PetscFunctionReturn(0); PetscValidHeaderSpecific(*st,ST_CLASSID,1); if (--((PetscObject)(*st))->refct > 0) { *st = 0; PetscFunctionReturn(0); } ierr = STReset(*st);CHKERRQ(ierr); ierr = MatDestroyMatrices(PetscMax(2,(*st)->nmat),&(*st)->A);CHKERRQ(ierr); ierr = PetscFree((*st)->Astate);CHKERRQ(ierr); if ((*st)->ops->destroy) { ierr = (*(*st)->ops->destroy)(*st);CHKERRQ(ierr); } ierr = MatDestroy(&(*st)->P);CHKERRQ(ierr); ierr = VecDestroy(&(*st)->D);CHKERRQ(ierr); ierr = KSPDestroy(&(*st)->ksp);CHKERRQ(ierr); ierr = PetscHeaderDestroy(st);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCreate" /*@ STCreate - Creates a spectral transformation context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . st - location to put the spectral transformation context Level: beginner .seealso: STSetUp(), STApply(), STDestroy(), ST @*/ PetscErrorCode STCreate(MPI_Comm comm,ST *newst) { PetscErrorCode ierr; ST st; PetscFunctionBegin; PetscValidPointer(newst,2); *newst = 0; ierr = STInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(st,ST_CLASSID,"ST","Spectral Transformation","ST",comm,STDestroy,STView);CHKERRQ(ierr); st->A = NULL; st->Astate = NULL; st->T = NULL; st->P = NULL; st->nmat = 0; st->sigma = 0.0; st->sigma_set = PETSC_FALSE; st->defsigma = 0.0; st->shift_matrix = ST_MATMODE_COPY; st->str = DIFFERENT_NONZERO_PATTERN; st->transform = PETSC_FALSE; st->ksp = NULL; st->w = NULL; st->D = NULL; st->wb = NULL; st->data = NULL; st->state = ST_STATE_INITIAL; *newst = st; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetOperators" /*@ STSetOperators - Sets the matrices associated with the eigenvalue problem. Collective on ST and Mat Input Parameters: + st - the spectral transformation context . n - number of matrices in array A - A - the array of matrices associated with the eigensystem Notes: It must be called before STSetUp(). If it is called again after STSetUp() then the ST object is reset. Level: intermediate .seealso: STGetOperators(), STGetNumMatrices(), STSetUp(), STReset() @*/ PetscErrorCode STSetOperators(ST st,PetscInt n,Mat A[]) { PetscInt i; PetscErrorCode ierr; PetscBool same=PETSC_TRUE; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveInt(st,n,2); if (n <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Must have one or more matrices, you have %D",n); PetscValidPointer(A,3); PetscCheckSameComm(st,1,*A,3); if (st->state) { if (n!=st->nmat) same = PETSC_FALSE; for (i=0;same&&iA[i]) same = PETSC_FALSE; } if (!same) { ierr = STReset(st);CHKERRQ(ierr); } } else same = PETSC_FALSE; if (!same) { ierr = MatDestroyMatrices(PetscMax(2,st->nmat),&st->A);CHKERRQ(ierr); ierr = PetscCalloc1(PetscMax(2,n),&st->A);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)st,PetscMax(2,n)*sizeof(Mat));CHKERRQ(ierr); ierr = PetscFree(st->Astate);CHKERRQ(ierr); ierr = PetscMalloc1(PetscMax(2,n),&st->Astate);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)st,PetscMax(2,n)*sizeof(PetscInt));CHKERRQ(ierr); } for (i=0;iA[i]);CHKERRQ(ierr); st->A[i] = A[i]; st->Astate[i] = ((PetscObject)A[i])->state; } if (n==1) { st->A[1] = NULL; st->Astate[1] = 0; } st->nmat = n; if (same) st->state = ST_STATE_UPDATED; else st->state = ST_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetOperators" /*@ STGetOperators - Gets the matrices associated with the original eigensystem. Not collective, though parallel Mats are returned if the ST is parallel Input Parameter: + st - the spectral transformation context - k - the index of the requested matrix (starting in 0) Output Parameters: . A - the requested matrix Level: intermediate .seealso: STSetOperators(), STGetNumMatrices() @*/ PetscErrorCode STGetOperators(ST st,PetscInt k,Mat *A) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveInt(st,k,2); PetscValidPointer(A,3); STCheckMatrices(st,1); if (k<0 || k>=st->nmat) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat-1); if (((PetscObject)st->A[k])->state!=st->Astate[k]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot retrieve original matrices (have been modified)"); *A = st->A[k]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetTOperators" /*@ STGetTOperators - Gets the matrices associated with the transformed eigensystem. Not collective, though parallel Mats are returned if the ST is parallel Input Parameter: + st - the spectral transformation context - k - the index of the requested matrix (starting in 0) Output Parameters: . T - the requested matrix Level: developer .seealso: STGetOperators(), STGetNumMatrices() @*/ PetscErrorCode STGetTOperators(ST st,PetscInt k,Mat *T) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveInt(st,k,2); PetscValidPointer(T,3); STCheckMatrices(st,1); if (k<0 || k>=st->nmat) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",st->nmat-1); if (!st->T) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_POINTER,"There are no transformed matrices"); *T = st->T[k]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetNumMatrices" /*@ STGetNumMatrices - Returns the number of matrices stored in the ST. Not collective Input Parameter: . st - the spectral transformation context Output Parameters: . n - the number of matrices passed in STSetOperators() Level: intermediate .seealso: STSetOperators() @*/ PetscErrorCode STGetNumMatrices(ST st,PetscInt *n) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(n,2); *n = st->nmat; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetShift" /*@ STSetShift - Sets the shift associated with the spectral transformation. Logically Collective on ST Input Parameters: + st - the spectral transformation context - shift - the value of the shift Notes: In some spectral transformations, changing the shift may have associated a lot of work, for example recomputing a factorization. This function is normally not directly called by users, since the shift is indirectly set by EPSSetTarget(). Level: intermediate .seealso: EPSSetTarget(), STGetShift(), STSetDefaultShift() @*/ PetscErrorCode STSetShift(ST st,PetscScalar shift) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveScalar(st,shift,2); if (st->state==ST_STATE_SETUP && st->sigma != shift) { if (st->ops->setshift) { ierr = (*st->ops->setshift)(st,shift);CHKERRQ(ierr); } } st->sigma = shift; st->sigma_set = PETSC_TRUE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetShift" /*@ STGetShift - Gets the shift associated with the spectral transformation. Not Collective Input Parameter: . st - the spectral transformation context Output Parameter: . shift - the value of the shift Level: intermediate .seealso: STSetShift() @*/ PetscErrorCode STGetShift(ST st,PetscScalar* shift) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidScalarPointer(shift,2); *shift = st->sigma; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetDefaultShift" /*@ STSetDefaultShift - Sets the value of the shift that should be employed if the user did not specify one. Logically Collective on ST Input Parameters: + st - the spectral transformation context - defaultshift - the default value of the shift Level: developer .seealso: STSetShift() @*/ PetscErrorCode STSetDefaultShift(ST st,PetscScalar defaultshift) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveScalar(st,defaultshift,2); st->defsigma = defaultshift; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STScaleShift" /*@ STScaleShift - Multiply the shift with a given factor. Logically Collective on ST Input Parameters: + st - the spectral transformation context - factor - the scaling factor Note: This function does not update the transformation matrices, as opposed to STSetShift(). Level: developer .seealso: STSetShift() @*/ PetscErrorCode STScaleShift(ST st,PetscScalar factor) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveScalar(st,factor,2); st->sigma *= factor; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetBalanceMatrix" /*@ STSetBalanceMatrix - Sets the diagonal matrix to be used for balancing. Collective on ST and Vec Input Parameters: + st - the spectral transformation context - D - the diagonal matrix (represented as a vector) Notes: If this matrix is set, STApply will effectively apply D*OP*D^{-1}. Balancing is usually set via EPSSetBalance, but the advanced user may use this function to bypass the usual balancing methods. Level: developer .seealso: EPSSetBalance(), STApply(), STGetBalanceMatrix() @*/ PetscErrorCode STSetBalanceMatrix(ST st,Vec D) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(D,VEC_CLASSID,2); PetscCheckSameComm(st,1,D,2); ierr = PetscObjectReference((PetscObject)D);CHKERRQ(ierr); ierr = VecDestroy(&st->D);CHKERRQ(ierr); st->D = D; st->state = ST_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetBalanceMatrix" /*@ STGetBalanceMatrix - Gets the balance matrix used by the spectral transformation. Not collective, but vector is shared by all processors that share the ST Input Parameter: . st - the spectral transformation context Output Parameter: . D - the diagonal matrix (represented as a vector) Note: If the matrix was not set, a null pointer will be returned. Level: developer .seealso: STSetBalanceMatrix() @*/ PetscErrorCode STGetBalanceMatrix(ST st,Vec *D) { PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(D,2); *D = st->D; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatCreateVecs" /*@C STMatCreateVecs - Get vector(s) compatible with the ST matrices. Collective on ST Input Parameter: . st - the spectral transformation context Output Parameters: + right - (optional) vector that the matrix can be multiplied against - left - (optional) vector that the matrix vector product can be stored in Level: developer @*/ PetscErrorCode STMatCreateVecs(ST st,Vec *right,Vec *left) { PetscErrorCode ierr; PetscFunctionBegin; STCheckMatrices(st,1); ierr = MatCreateVecs(st->A[0],right,left);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatGetSize" /*@ STMatGetSize - Returns the number of rows and columns of the ST matrices. Not Collective Input Parameter: . st - the spectral transformation context Output Parameters: + m - the number of global rows - n - the number of global columns Level: developer @*/ PetscErrorCode STMatGetSize(ST st,PetscInt *m,PetscInt *n) { PetscErrorCode ierr; PetscFunctionBegin; STCheckMatrices(st,1); ierr = MatGetSize(st->A[0],m,n);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STMatGetLocalSize" /*@ STMatGetLocalSize - Returns the number of local rows and columns of the ST matrices. Not Collective Input Parameter: . st - the spectral transformation context Output Parameters: + m - the number of local rows - n - the number of local columns Level: developer @*/ PetscErrorCode STMatGetLocalSize(ST st,PetscInt *m,PetscInt *n) { PetscErrorCode ierr; PetscFunctionBegin; STCheckMatrices(st,1); ierr = MatGetLocalSize(st->A[0],m,n);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetOptionsPrefix" /*@C STSetOptionsPrefix - Sets the prefix used for searching for all ST options in the database. Logically Collective on ST Input Parameters: + st - the spectral transformation context - prefix - the prefix string to prepend to all ST option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: STAppendOptionsPrefix(), STGetOptionsPrefix() @*/ PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPSetOptionsPrefix(st->ksp,prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STAppendOptionsPrefix" /*@C STAppendOptionsPrefix - Appends to the prefix used for searching for all ST options in the database. Logically Collective on ST Input Parameters: + st - the spectral transformation context - prefix - the prefix string to prepend to all ST option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: STSetOptionsPrefix(), STGetOptionsPrefix() @*/ PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr); if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPSetOptionsPrefix(st->ksp,((PetscObject)st)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetOptionsPrefix" /*@C STGetOptionsPrefix - Gets the prefix used for searching for all ST options in the database. Not Collective Input Parameters: . st - the spectral transformation context Output Parameters: . prefix - pointer to the prefix string used, is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: STSetOptionsPrefix(), STAppendOptionsPrefix() @*/ PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STView" /*@C STView - Prints the ST data structure. Collective on ST Input Parameters: + st - the ST context - viewer - optional visualization context Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization contexts with PetscViewerASCIIOpen() (output to a specified file). Level: beginner .seealso: EPSView(), PetscViewerASCIIOpen() @*/ PetscErrorCode STView(ST st,PetscViewer viewer) { PetscErrorCode ierr; STType cstr; const char* pat; char str[50]; PetscBool isascii,isstring,flg; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)st)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(st,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERSTRING,&isstring);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)st,viewer);CHKERRQ(ierr); if (st->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } ierr = SlepcSNPrintfScalar(str,50,st->sigma,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," shift: %s\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of matrices: %D\n",st->nmat);CHKERRQ(ierr); switch (st->shift_matrix) { case ST_MATMODE_COPY: break; case ST_MATMODE_INPLACE: ierr = PetscViewerASCIIPrintf(viewer," shifting the matrix and unshifting at exit\n");CHKERRQ(ierr); break; case ST_MATMODE_SHELL: ierr = PetscViewerASCIIPrintf(viewer," using a shell matrix\n");CHKERRQ(ierr); break; } if (st->nmat>1 && st->shift_matrix != ST_MATMODE_SHELL) { switch (st->str) { case SAME_NONZERO_PATTERN: pat = "same nonzero pattern";break; case DIFFERENT_NONZERO_PATTERN: pat = "different nonzero pattern";break; case SUBSET_NONZERO_PATTERN: pat = "subset nonzero pattern";break; default: SETERRQ(PetscObjectComm((PetscObject)st),1,"Wrong structure flag"); } ierr = PetscViewerASCIIPrintf(viewer," all matrices have %s\n",pat);CHKERRQ(ierr); } if (st->transform && st->nmat>2) { ierr = PetscViewerASCIIPrintf(viewer," computing transformed matrices\n");CHKERRQ(ierr); } } else if (isstring) { ierr = STGetType(st,&cstr);CHKERRQ(ierr); ierr = PetscViewerStringSPrintf(viewer," %-7.7s",cstr);CHKERRQ(ierr); if (st->ops->view) { ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr); } } ierr = PetscObjectTypeCompare((PetscObject)st,STSHIFT,&flg);CHKERRQ(ierr); if (st->nmat>1 || !flg) { if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = KSPView(st->ksp,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STRegister" /*@C STRegister - Adds a method to the spectral transformation package. Not collective Input Parameters: + name - name of a new user-defined transformation - function - routine to create method context Notes: STRegister() may be called multiple times to add several user-defined spectral transformations. Sample usage: .vb STRegister("my_transform",MyTransformCreate); .ve Then, your spectral transform can be chosen with the procedural interface via $ STSetType(st,"my_transform") or at runtime via the option $ -st_type my_transform Level: advanced .seealso: STRegisterAll() @*/ PetscErrorCode STRegister(const char *name,PetscErrorCode (*function)(ST)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&STList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/interface/ftn-custom/0000755000175000017500000000000013107004621021712 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/interface/ftn-custom/makefile0000644000175000017500000000222313107004621023411 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zstf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/st/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/interface/ftn-custom/zstf.c0000644000175000017500000000603513107004621023050 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define stsettype_ STSETTYPE #define stgettype_ STGETTYPE #define stsetoptionsprefix_ STSETOPTIONSPREFIX #define stappendoptionsprefix_ STAPPENDOPTIONSPREFIX #define stgetoptionsprefix_ STGETOPTIONSPREFIX #define stview_ STVIEW #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define stsettype_ stsettype #define stgettype_ stgettype #define stsetoptionsprefix_ stsetoptionsprefix #define stappendoptionsprefix_ stappendoptionsprefix #define stgetoptionsprefix_ stgetoptionsprefix #define stview_ stview #endif PETSC_EXTERN void PETSC_STDCALL stsettype_(ST *st,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = STSetType(*st,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL stgettype_(ST *st,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { STType tname; *ierr = STGetType(*st,&tname); if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL stsetoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = STSetOptionsPrefix(*st,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL stappendoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = STAppendOptionsPrefix(*st,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL stgetoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = STGetOptionsPrefix(*st,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL stview_(ST *st,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = STView(*st,v); } slepc-3.7.4/src/sys/classes/st/examples/0000755000175000017500000000000013107004621017471 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/examples/makefile0000644000175000017500000000202013107004621021163 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/sys/classes/st/examples/ DIRS = tests include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/examples/makefile.html0000644000175000017500000000445313107004621022142 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/sys/classes/st/examples/
DIRS     = tests

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/st/examples/index.html0000644000175000017500000000124013107004621021463 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
makefile
slepc-3.7.4/src/sys/classes/st/examples/tests/0000755000175000017500000000000013107004621020633 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/examples/tests/makefile0000644000175000017500000000655513107004621022346 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/sys/classes/st/examples/tests/ EXAMPLESC = test1.c test2.c test3.c test4.c EXAMPLESF = MANSEC = ST TESTS = test1 test2 test3 test4 TESTEXAMPLES_C = test1.PETSc runtest1_1 runtest1_2 test1.rm \ test2.PETSc runtest2_1 runtest2_2 runtest2_3 test2.rm \ test3.PETSc runtest3_1 runtest3_2 runtest3_3 test3.rm \ test4.PETSc runtest4_1 runtest4_2 runtest4_3 runtest4_4 test4.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB} ${RM} test1.o test2: test2.o chkopts -${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB} ${RM} test2.o test3: test3.o chkopts -${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB} ${RM} test3.o test4: test4.o chkopts -${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB} ${RM} test4.o #------------------------------------------------------------------------------------ TESTCODE = \ [ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \ ${DIFF} output/$${test}.out $${test}.tmp || \ echo "Possible problem with $${test}, diffs above"; \ ${RM} -f $${test}.tmp runtest1_1: -@test=test1_1; \ ${MPIEXEC} -n 1 ./test1 -st_matmode inplace 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest1_2: -@test=test1_1; \ ${MPIEXEC} -n 1 ./test1 -st_matmode shell 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_1: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_2: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -st_matmode inplace 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest2_3: -@test=test2_1; \ ${MPIEXEC} -n 1 ./test2 -st_matmode shell 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3_1: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3_2: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 -st_matmode inplace 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3_3: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 -st_matmode shell 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_1: -@test=test4_1; \ ${MPIEXEC} -n 1 ./test4 -st_transform 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_2: -@test=test4_1; \ ${MPIEXEC} -n 1 ./test4 -st_transform -st_matmode shell 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_3: -@test=test4_2; \ ${MPIEXEC} -n 1 ./test4 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest4_4: -@test=test4_2; \ ${MPIEXEC} -n 1 ./test4 -st_matmode shell 2>&1 > $${test}.tmp; \ ${TESTCODE} slepc-3.7.4/src/sys/classes/st/examples/tests/test4.c.html0000644000175000017500000003435013107004621023012 0ustar jromanjroman

Actual source code: test4.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test ST with four matrices.\n\n";

 24: #include <slepcst.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat            A,B,C,D,mat[4];
 31:   ST             st;
 32:   KSP            ksp;
 33:   Vec            v,w;
 34:   STType         type;
 35:   PetscScalar    sigma;
 36:   PetscInt       n=10,i,Istart,Iend;

 39:   SlepcInitialize(&argc,&argv,(char*)0,help);
 40:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 41:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian plus diagonal, n=%D\n\n",n);
 42:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 43:      Compute the operator matrix for the 1-D Laplacian
 44:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 46:   MatCreate(PETSC_COMM_WORLD,&A);
 47:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 48:   MatSetFromOptions(A);
 49:   MatSetUp(A);

 51:   MatCreate(PETSC_COMM_WORLD,&B);
 52:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
 53:   MatSetFromOptions(B);
 54:   MatSetUp(B);

 56:   MatCreate(PETSC_COMM_WORLD,&C);
 57:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n);
 58:   MatSetFromOptions(C);
 59:   MatSetUp(C);

 61:   MatCreate(PETSC_COMM_WORLD,&D);
 62:   MatSetSizes(D,PETSC_DECIDE,PETSC_DECIDE,n,n);
 63:   MatSetFromOptions(D);
 64:   MatSetUp(D);

 66:   MatGetOwnershipRange(A,&Istart,&Iend);
 67:   for (i=Istart;i<Iend;i++) {
 68:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 69:     if (i>0) {
 70:       MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);
 71:       MatSetValue(B,i,i,(PetscScalar)i,INSERT_VALUES);
 72:     } else {
 73:       MatSetValue(B,i,i,-1.0,INSERT_VALUES);
 74:     }
 75:     if (i<n-1) {
 76:       MatSetValue(A,i,i+1,-1.0,INSERT_VALUES);
 77:     }
 78:     MatSetValue(C,i,n-i-1,1.0,INSERT_VALUES);
 79:     MatSetValue(D,i,i,i*.1,INSERT_VALUES);
 80:     if (i==0) {
 81:       MatSetValue(D,0,n-1,1.0,INSERT_VALUES);
 82:     }
 83:     if (i==n-1) {
 84:       MatSetValue(D,n-1,0,1.0,INSERT_VALUES);
 85:     }
 86:   }

 88:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 89:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 90:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 91:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
 92:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
 93:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
 94:   MatAssemblyBegin(D,MAT_FINAL_ASSEMBLY);
 95:   MatAssemblyEnd(D,MAT_FINAL_ASSEMBLY);
 96:   MatCreateVecs(A,&v,&w);
 97:   VecSet(v,1.0);

 99:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100:                 Create the spectral transformation object
101:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
102:   STCreate(PETSC_COMM_WORLD,&st);
103:   mat[0] = A;
104:   mat[1] = B;
105:   mat[2] = C;
106:   mat[3] = D;
107:   STSetOperators(st,4,mat);
108:   STGetKSP(st,&ksp);
109:   KSPSetTolerances(ksp,100*PETSC_MACHINE_EPSILON,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);
110:   STSetFromOptions(st);
111:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
112:               Apply the transformed operator for several ST's
113:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
114:   /* shift, sigma=0.0 */
115:   STSetUp(st);
116:   STGetType(st,&type);
117:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
118:   for (i=0;i<4;i++) {
119:     STMatMult(st,i,v,w);
120:     PetscPrintf(PETSC_COMM_WORLD,"k= %D\n",i);
121:     VecView(w,NULL);
122:   }
123:   STMatSolve(st,v,w);
124:   PetscPrintf(PETSC_COMM_WORLD,"solve\n");
125:   VecView(w,NULL);

127:   /* shift, sigma=0.1 */
128:   sigma = 0.1;
129:   STSetShift(st,sigma);
130:   STGetShift(st,&sigma);
131:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
132:   for (i=0;i<4;i++) {
133:     STMatMult(st,i,v,w);
134:     PetscPrintf(PETSC_COMM_WORLD,"k= %D\n",i);
135:     VecView(w,NULL);
136:   }
137:   STMatSolve(st,v,w);
138:   PetscPrintf(PETSC_COMM_WORLD,"solve\n");
139:   VecView(w,NULL);

141:   /* sinvert, sigma=0.1 */
142:   STPostSolve(st);
143:   STSetType(st,STSINVERT);
144:   STGetType(st,&type);
145:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
146:   STGetShift(st,&sigma);
147:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
148:   for (i=0;i<4;i++) {
149:     STMatMult(st,i,v,w);
150:     PetscPrintf(PETSC_COMM_WORLD,"k= %D\n",i);
151:     VecView(w,NULL);
152:   }
153:   STMatSolve(st,v,w);
154:   PetscPrintf(PETSC_COMM_WORLD,"solve\n");
155:   VecView(w,NULL);

157:   /* sinvert, sigma=-0.5 */
158:   sigma = -0.5;
159:   STSetShift(st,sigma);
160:   STGetShift(st,&sigma);
161:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
162:   for (i=0;i<4;i++) {
163:     STMatMult(st,i,v,w);
164:     PetscPrintf(PETSC_COMM_WORLD,"k= %D\n",i);
165:     VecView(w,NULL);
166:   }
167:   STMatSolve(st,v,w);
168:   PetscPrintf(PETSC_COMM_WORLD,"solve\n");
169:   VecView(w,NULL);
170:   STDestroy(&st);
171:   MatDestroy(&A);
172:   MatDestroy(&B);
173:   MatDestroy(&C);
174:   MatDestroy(&D);
175:   VecDestroy(&v);
176:   VecDestroy(&w);
177:   SlepcFinalize();
178:   return ierr;
179: }
slepc-3.7.4/src/sys/classes/st/examples/tests/test4.c0000644000175000017500000001611113107004621022042 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test ST with four matrices.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B,C,D,mat[4]; ST st; KSP ksp; Vec v,w; STType type; PetscScalar sigma; PetscInt n=10,i,Istart,Iend; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian plus diagonal, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix for the 1-D Laplacian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&C);CHKERRQ(ierr); ierr = MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(C);CHKERRQ(ierr); ierr = MatSetUp(C);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&D);CHKERRQ(ierr); ierr = MatSetSizes(D,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(D);CHKERRQ(ierr); ierr = MatSetUp(D);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); ierr = MatSetValue(B,i,i,(PetscScalar)i,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(B,i,i,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: test1.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test ST with shell matrices.\n\n";

 24: #include <slepcst.h>

 26: static PetscErrorCode MatGetDiagonal_Shell(Mat S,Vec diag);
 27: static PetscErrorCode MatMultTranspose_Shell(Mat S,Vec x,Vec y);
 28: static PetscErrorCode MatMult_Shell(Mat S,Vec x,Vec y);
 29: static PetscErrorCode MatDuplicate_Shell(Mat S,MatDuplicateOption op,Mat *M);

 33: static PetscErrorCode MyShellMatCreate(Mat *A,Mat *M)
 34: {
 36:   MPI_Comm       comm;
 37:   PetscInt       n;

 40:   MatGetSize(*A,&n,NULL);
 41:   PetscObjectGetComm((PetscObject)*A,&comm);
 42:   MatCreateShell(comm,PETSC_DECIDE,PETSC_DECIDE,n,n,A,M);
 43:   MatSetFromOptions(*M);
 44:   MatShellSetOperation(*M,MATOP_MULT,(void(*)())MatMult_Shell);
 45:   MatShellSetOperation(*M,MATOP_MULT_TRANSPOSE,(void(*)())MatMultTranspose_Shell);
 46:   MatShellSetOperation(*M,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Shell);
 47:   MatShellSetOperation(*M,MATOP_DUPLICATE,(void(*)())MatDuplicate_Shell);
 48:   return(0);
 49: }

 53: int main(int argc,char **argv)
 54: {
 55:   Mat            A,S,mat[1];
 56:   ST             st;
 57:   Vec            v,w;
 58:   STType         type;
 59:   KSP            ksp;
 60:   PC             pc;
 61:   PetscScalar    sigma;
 62:   PetscInt       n=10,i,Istart,Iend;

 65:   SlepcInitialize(&argc,&argv,(char*)0,help);
 66:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 67:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian with shell matrices, n=%D\n\n",n);

 69:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 70:      Compute the operator matrix for the 1-D Laplacian
 71:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 73:   MatCreate(PETSC_COMM_WORLD,&A);
 74:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 75:   MatSetFromOptions(A);
 76:   MatSetUp(A);

 78:   MatGetOwnershipRange(A,&Istart,&Iend);
 79:   for (i=Istart;i<Iend;i++) {
 80:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 81:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 82:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 83:   }
 84:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 85:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);

 87:   /* create the shell version of A */
 88:   MyShellMatCreate(&A,&S);

 90:   /* work vectors */
 91:   MatCreateVecs(A,&v,&w);
 92:   VecSet(v,1.0);

 94:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 95:                 Create the spectral transformation object
 96:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 98:   STCreate(PETSC_COMM_WORLD,&st);
 99:   mat[0] = S;
100:   STSetOperators(st,1,mat);
101:   STSetTransform(st,PETSC_TRUE);
102:   STSetFromOptions(st);


105:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106:               Apply the transformed operator for several ST's
107:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

109:   /* shift, sigma=0.0 */
110:   STSetUp(st);
111:   STGetType(st,&type);
112:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
113:   STApply(st,v,w);
114:   VecView(w,NULL);

116:   /* shift, sigma=0.1 */
117:   sigma = 0.1;
118:   STSetShift(st,sigma);
119:   STGetShift(st,&sigma);
120:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
121:   STApply(st,v,w);
122:   VecView(w,NULL);

124:   /* sinvert, sigma=0.1 */
125:   STPostSolve(st);   /* undo changes if inplace */
126:   STSetType(st,STSINVERT);
127:   STGetKSP(st,&ksp);
128:   KSPSetType(ksp,KSPGMRES);
129:   KSPGetPC(ksp,&pc);
130:   PCSetType(pc,PCJACOBI);
131:   STGetType(st,&type);
132:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
133:   STGetShift(st,&sigma);
134:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
135:   STApply(st,v,w);
136:   VecView(w,NULL);

138:   /* sinvert, sigma=-0.5 */
139:   sigma = -0.5;
140:   STSetShift(st,sigma);
141:   STGetShift(st,&sigma);
142:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
143:   STApply(st,v,w);
144:   VecView(w,NULL);

146:   STDestroy(&st);
147:   MatDestroy(&A);
148:   MatDestroy(&S);
149:   VecDestroy(&v);
150:   VecDestroy(&w);
151:   SlepcFinalize();
152:   return ierr;
153: }

157: static PetscErrorCode MatMult_Shell(Mat S,Vec x,Vec y)
158: {
159:   PetscErrorCode    ierr;
160:   Mat               *A;

163:   MatShellGetContext(S,&A);
164:   MatMult(*A,x,y);
165:   return(0);
166: }

170: static PetscErrorCode MatMultTranspose_Shell(Mat S,Vec x,Vec y)
171: {
172:   PetscErrorCode    ierr;
173:   Mat               *A;

176:   MatShellGetContext(S,&A);
177:   MatMultTranspose(*A,x,y);
178:   return(0);
179: }

183: static PetscErrorCode MatGetDiagonal_Shell(Mat S,Vec diag)
184: {
185:   PetscErrorCode    ierr;
186:   Mat               *A;

189:   MatShellGetContext(S,&A);
190:   MatGetDiagonal(*A,diag);
191:   return(0);
192: }

196: static PetscErrorCode MatDuplicate_Shell(Mat S,MatDuplicateOption op,Mat *M)
197: {
199:   Mat            *A;

202:   MatShellGetContext(S,&A);
203:   MyShellMatCreate(A,M);
204:   return(0);
205: }

slepc-3.7.4/src/sys/classes/st/examples/tests/makefile.html0000644000175000017500000001306213107004621023300 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/sys/classes/st/examples/tests/
EXAMPLESC  = test1.c test2.c test3.c test4.c
EXAMPLESF  =
MANSEC     = ST
TESTS      = test1 test2 test3 test4

TESTEXAMPLES_C       = test1.PETSc runtest1_1 runtest1_2 test1.rm \
                       test2.PETSc runtest2_1 runtest2_2 runtest2_3 test2.rm \
                       test3.PETSc runtest3_1 runtest3_2 runtest3_3 test3.rm \
                       test4.PETSc runtest4_1 runtest4_2 runtest4_3 runtest4_4 test4.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB}
	${RM} test1.o

test2: test2.o chkopts
	-${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB}
	${RM} test2.o

test3: test3.o chkopts
	-${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB}
	${RM} test3.o

test4: test4.o chkopts
	-${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB}
	${RM} test4.o

#------------------------------------------------------------------------------------

TESTCODE = \
	[ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \
	${DIFF} output/$${test}.out $${test}.tmp || \
	echo "Possible problem with $${test}, diffs above"; \
	${RM} -f $${test}.tmp

runtest1_1:
	-@test=test1_1; \
	${MPIEXEC} -n 1 ./test1 -st_matmode inplace 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest1_2:
	-@test=test1_1; \
	${MPIEXEC} -n 1 ./test1 -st_matmode shell 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_1:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_2:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -st_matmode inplace 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest2_3:
	-@test=test2_1; \
	${MPIEXEC} -n 1 ./test2 -st_matmode shell 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3_1:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3_2:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 -st_matmode inplace 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3_3:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 -st_matmode shell 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_1:
	-@test=test4_1; \
	${MPIEXEC} -n 1 ./test4 -st_transform 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_2:
	-@test=test4_1; \
	${MPIEXEC} -n 1 ./test4 -st_transform -st_matmode shell 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_3:
	-@test=test4_2; \
	${MPIEXEC} -n 1 ./test4 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest4_4:
	-@test=test4_2; \
	${MPIEXEC} -n 1 ./test4 -st_matmode shell 2>&1 > $${test}.tmp; \
	${TESTCODE}

slepc-3.7.4/src/sys/classes/st/examples/tests/test1.c0000644000175000017500000001636113107004621022046 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test ST with shell matrices.\n\n"; #include static PetscErrorCode MatGetDiagonal_Shell(Mat S,Vec diag); static PetscErrorCode MatMultTranspose_Shell(Mat S,Vec x,Vec y); static PetscErrorCode MatMult_Shell(Mat S,Vec x,Vec y); static PetscErrorCode MatDuplicate_Shell(Mat S,MatDuplicateOption op,Mat *M); #undef __FUNCT__ #define __FUNCT__ "MyShellMatCreate" static PetscErrorCode MyShellMatCreate(Mat *A,Mat *M) { PetscErrorCode ierr; MPI_Comm comm; PetscInt n; PetscFunctionBeginUser; ierr = MatGetSize(*A,&n,NULL);CHKERRQ(ierr); ierr = PetscObjectGetComm((PetscObject)*A,&comm);CHKERRQ(ierr); ierr = MatCreateShell(comm,PETSC_DECIDE,PETSC_DECIDE,n,n,A,M);CHKERRQ(ierr); ierr = MatSetFromOptions(*M);CHKERRQ(ierr); ierr = MatShellSetOperation(*M,MATOP_MULT,(void(*)())MatMult_Shell);CHKERRQ(ierr); ierr = MatShellSetOperation(*M,MATOP_MULT_TRANSPOSE,(void(*)())MatMultTranspose_Shell);CHKERRQ(ierr); ierr = MatShellSetOperation(*M,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Shell);CHKERRQ(ierr); ierr = MatShellSetOperation(*M,MATOP_DUPLICATE,(void(*)())MatDuplicate_Shell);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,S,mat[1]; ST st; Vec v,w; STType type; KSP ksp; PC pc; PetscScalar sigma; PetscInt n=10,i,Istart,Iend; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian with shell matrices, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix for the 1-D Laplacian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test ST with two matrices.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B,M,mat[2]; ST st; Vec v,w; STType type; PetscScalar sigma,tau; PetscInt n=10,i,Istart,Iend; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian plus diagonal, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix for the 1-D Laplacian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&B);CHKERRQ(ierr); ierr = MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(B);CHKERRQ(ierr); ierr = MatSetUp(B);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); ierr = MatSetValue(B,i,i,(PetscScalar)i,INSERT_VALUES);CHKERRQ(ierr); } else { ierr = MatSetValue(B,i,i,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: test2.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test ST with one matrix.\n\n";

 24: #include <slepcst.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat            A,B,mat[1];
 31:   ST             st;
 32:   Vec            v,w;
 33:   STType         type;
 34:   PetscScalar    sigma,tau;
 35:   PetscInt       n=10,i,Istart,Iend;

 38:   SlepcInitialize(&argc,&argv,(char*)0,help);
 39:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 40:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian, n=%D\n\n",n);

 42:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 43:      Compute the operator matrix for the 1-D Laplacian
 44:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 46:   MatCreate(PETSC_COMM_WORLD,&A);
 47:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 48:   MatSetFromOptions(A);
 49:   MatSetUp(A);

 51:   MatGetOwnershipRange(A,&Istart,&Iend);
 52:   for (i=Istart;i<Iend;i++) {
 53:     if (i>0) { MatSetValue(A,i,i-1,-1.0,INSERT_VALUES); }
 54:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 55:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 56:   }
 57:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 58:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 59:   MatCreateVecs(A,&v,&w);
 60:   VecSet(v,1.0);

 62:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 63:                 Create the spectral transformation object
 64:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 66:   STCreate(PETSC_COMM_WORLD,&st);
 67:   mat[0] = A;
 68:   STSetOperators(st,1,mat);
 69:   STSetTransform(st,PETSC_TRUE);
 70:   STSetFromOptions(st);

 72:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 73:               Apply the transformed operator for several ST's
 74:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 76:   /* shift, sigma=0.0 */
 77:   STSetUp(st);
 78:   STGetType(st,&type);
 79:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
 80:   STApply(st,v,w);
 81:   VecView(w,NULL);

 83:   /* shift, sigma=0.1 */
 84:   sigma = 0.1;
 85:   STSetShift(st,sigma);
 86:   STGetShift(st,&sigma);
 87:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
 88:   STApply(st,v,w);
 89:   VecView(w,NULL);

 91:   /* sinvert, sigma=0.1 */
 92:   STPostSolve(st);   /* undo changes if inplace */
 93:   STSetType(st,STSINVERT);
 94:   STGetType(st,&type);
 95:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
 96:   STGetShift(st,&sigma);
 97:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
 98:   STApply(st,v,w);
 99:   VecView(w,NULL);

101:   /* sinvert, sigma=-0.5 */
102:   sigma = -0.5;
103:   STSetShift(st,sigma);
104:   STGetShift(st,&sigma);
105:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
106:   STApply(st,v,w);
107:   VecView(w,NULL);

109:   /* cayley, sigma=-0.5, tau=-0.5 (equal to sigma by default) */
110:   STPostSolve(st);   /* undo changes if inplace */
111:   STSetType(st,STCAYLEY);
112:   STSetUp(st);
113:   STGetType(st,&type);
114:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
115:   STGetShift(st,&sigma);
116:   STCayleyGetAntishift(st,&tau);
117:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g, antishift=%g\n",(double)PetscRealPart(sigma),(double)PetscRealPart(tau));
118:   STApply(st,v,w);
119:   VecView(w,NULL);

121:   /* cayley, sigma=1.1, tau=1.1 (still equal to sigma) */
122:   sigma = 1.1;
123:   STSetShift(st,sigma);
124:   STGetShift(st,&sigma);
125:   STCayleyGetAntishift(st,&tau);
126:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g, antishift=%g\n",(double)PetscRealPart(sigma),(double)PetscRealPart(tau));
127:   STApply(st,v,w);
128:   VecView(w,NULL);

130:   /* cayley, sigma=1.1, tau=-1.0 */
131:   tau = -1.0;
132:   STCayleySetAntishift(st,tau);
133:   STGetShift(st,&sigma);
134:   STCayleyGetAntishift(st,&tau);
135:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g, antishift=%g\n",(double)PetscRealPart(sigma),(double)PetscRealPart(tau));
136:   STApply(st,v,w);
137:   VecView(w,NULL);

139:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
140:                   Check inner product matrix in Cayley
141:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
142:   STGetBilinearForm(st,&B);
143:   MatMult(B,v,w);
144:   VecView(w,NULL);

146:   STDestroy(&st);
147:   MatDestroy(&A);
148:   MatDestroy(&B);
149:   VecDestroy(&v);
150:   VecDestroy(&w);
151:   SlepcFinalize();
152:   return ierr;
153: }
slepc-3.7.4/src/sys/classes/st/examples/tests/output/0000755000175000017500000000000013107004621022173 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/examples/tests/output/test2_1.out0000644000175000017500000000210113107004621024177 0ustar jromanjroman 1-D Laplacian, n=10 ST type shift Vec Object: 1 MPI processes type: seq 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. With shift=0.1 Vec Object: 1 MPI processes type: seq 0.9 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 0.9 ST type sinvert With shift=0.1 Vec Object: 1 MPI processes type: seq -18.0797 -35.3515 -50.0881 -60.8159 -66.4621 -66.4621 -60.8159 -50.0881 -35.3515 -18.0797 With shift=-0.5 Vec Object: 1 MPI processes type: seq 0.998536 1.49634 1.74231 1.85944 1.9063 1.9063 1.85944 1.74231 1.49634 0.998536 ST type cayley With shift=-0.5, antishift=-0.5 Vec Object: 1 MPI processes type: seq 0.00146413 -0.49634 -0.742313 -0.859444 -0.906296 -0.906296 -0.859444 -0.742313 -0.49634 0.00146413 With shift=1.1, antishift=1.1 Vec Object: 1 MPI processes type: seq -0.48258 -2.53432 -2.89831 -1.17416 0.741569 0.741569 -1.17416 -2.89831 -2.53432 -0.48258 With shift=1.1, antishift=-1. Vec Object: 1 MPI processes type: seq 0.93261 0.839349 0.822804 0.901175 0.988253 0.988253 0.901175 0.822804 0.839349 0.93261 Vec Object: 1 MPI processes type: seq 0. -1. -1. -1. -1. -1. -1. -1. -1. 0. slepc-3.7.4/src/sys/classes/st/examples/tests/output/test3_1.out0000644000175000017500000000213713107004621024211 0ustar jromanjroman 1-D Laplacian plus diagonal, n=10 ST type shift Vec Object: 1 MPI processes type: seq -1. 0. 0. 0. 0. 0. 0. 0. 0. 0.111111 With shift=0.1 Vec Object: 1 MPI processes type: seq -1.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 0.0111111 ST type sinvert With shift=0.1 Vec Object: 1 MPI processes type: seq 0.882432 2.85311 3.53847 1.51614 -3.96103 -11.8538 -18.8197 -20.4937 -14.8222 -5.2929 With shift=-0.5 Vec Object: 1 MPI processes type: seq 0.0585408 1.08781 1.66099 1.89515 1.97204 1.99301 1.99649 1.98947 1.94557 1.68393 ST type cayley With shift=-0.5, antishift=-0.5 Vec Object: 1 MPI processes type: seq 0.941459 -0.0878112 -0.660987 -0.895151 -0.97204 -0.993008 -0.996495 -0.989466 -0.945566 -0.683933 With shift=1.1, antishift=1.1 Vec Object: 1 MPI processes type: seq -0.865819 -2.58404 -2.55982 0.896001 -1.90499 -0.724035 -1.06089 -0.995864 -0.962683 -1.25789 With shift=1.1, antishift=-1. Vec Object: 1 MPI processes type: seq 0.91519 0.837089 0.83819 0.995273 0.867955 0.921635 0.906323 0.909279 0.910787 0.897369 Vec Object: 1 MPI processes type: seq 2. -1. -2. -3. -4. -5. -6. -7. -8. -8. slepc-3.7.4/src/sys/classes/st/examples/tests/output/test1_1.out0000644000175000017500000000101613107004621024202 0ustar jromanjroman 1-D Laplacian with shell matrices, n=10 ST type shift Vec Object: 1 MPI processes type: seq 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. With shift=0.1 Vec Object: 1 MPI processes type: seq 0.9 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 -0.1 0.9 ST type sinvert With shift=0.1 Vec Object: 1 MPI processes type: seq -18.0797 -35.3515 -50.0881 -60.8159 -66.4621 -66.4621 -60.8159 -50.0881 -35.3515 -18.0797 With shift=-0.5 Vec Object: 1 MPI processes type: seq 0.998536 1.49634 1.74231 1.85944 1.9063 1.9063 1.85944 1.74231 1.49634 0.998536 slepc-3.7.4/src/sys/classes/st/examples/tests/output/test4_2.out0000644000175000017500000000317013107004621024211 0ustar jromanjroman 1-D Laplacian plus diagonal, n=10 ST type shift k= 0 Vec Object: 1 MPI processes type: seq 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. k= 1 Vec Object: 1 MPI processes type: seq -1. 1. 2. 3. 4. 5. 6. 7. 8. 9. k= 2 Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. k= 3 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 solve Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. With shift=0.1 k= 0 Vec Object: 1 MPI processes type: seq 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. k= 1 Vec Object: 1 MPI processes type: seq -1. 1. 2. 3. 4. 5. 6. 7. 8. 9. k= 2 Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. k= 3 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 solve Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. ST type sinvert With shift=0.1 k= 0 Vec Object: 1 MPI processes type: seq 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. k= 1 Vec Object: 1 MPI processes type: seq -1. 1. 2. 3. 4. 5. 6. 7. 8. 9. k= 2 Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. k= 3 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 solve Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. With shift=-0.5 k= 0 Vec Object: 1 MPI processes type: seq 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. k= 1 Vec Object: 1 MPI processes type: seq -1. 1. 2. 3. 4. 5. 6. 7. 8. 9. k= 2 Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. k= 3 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 solve Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. slepc-3.7.4/src/sys/classes/st/examples/tests/output/test4_1.out0000644000175000017500000000400713107004621024210 0ustar jromanjroman 1-D Laplacian plus diagonal, n=10 ST type shift k= 0 Vec Object: 1 MPI processes type: seq 1. 0. 0. 0. 0. 0. 0. 0. 0. 1. k= 1 Vec Object: 1 MPI processes type: seq -1. 1. 2. 3. 4. 5. 6. 7. 8. 9. k= 2 Vec Object: 1 MPI processes type: seq 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. k= 3 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 solve Vec Object: 1 MPI processes type: seq 0.1 10. 5. 3.33333 2.5 2. 1.66667 1.42857 1.25 1. With shift=0.1 k= 0 Vec Object: 1 MPI processes type: seq 0.911 0.1101 0.2102 0.3103 0.4104 0.5105 0.6106 0.7107 0.8108 1.9119 k= 1 Vec Object: 1 MPI processes type: seq -0.77 1.203 2.206 3.209 4.212 5.215 6.218 7.221 8.224 9.257 k= 2 Vec Object: 1 MPI processes type: seq 1.3 1.03 1.06 1.09 1.12 1.15 1.18 1.21 1.24 1.57 k= 3 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 solve Vec Object: 1 MPI processes type: seq 0.1 10. 5. 3.33333 2.5 2. 1.66667 1.42857 1.25 1. ST type sinvert With shift=0.1 k= 0 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 k= 1 Vec Object: 1 MPI processes type: seq 1.3 1.03 1.06 1.09 1.12 1.15 1.18 1.21 1.24 1.57 k= 2 Vec Object: 1 MPI processes type: seq -0.77 1.203 2.206 3.209 4.212 5.215 6.218 7.221 8.224 9.257 k= 3 Vec Object: 1 MPI processes type: seq 0.911 0.1101 0.2102 0.3103 0.4104 0.5105 0.6106 0.7107 0.8108 1.9119 solve Vec Object: 1 MPI processes type: seq 2.04158 2.88687 3.03214 2.79837 2.42188 2.03545 1.69199 1.39272 1.09965 0.716051 With shift=-0.5 k= 0 Vec Object: 1 MPI processes type: seq 1. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.9 k= 1 Vec Object: 1 MPI processes type: seq -0.5 0.85 0.7 0.55 0.4 0.25 0.1 -0.05 -0.2 -1.85 k= 2 Vec Object: 1 MPI processes type: seq -1.25 0.075 1.15 2.225 3.3 4.375 5.45 6.525 7.6 9.425 k= 3 Vec Object: 1 MPI processes type: seq 1.625 -0.2625 -0.775 -1.2875 -1.8 -2.3125 -2.825 -3.3375 -3.85 -3.4875 solve Vec Object: 1 MPI processes type: seq -3.55381 -9.71 -13.1628 -2.65643 8.80516 1.62157 -8.516 5.86903 -5.09177 1.39619 slepc-3.7.4/src/sys/classes/st/examples/tests/index.html0000644000175000017500000000425613107004621022637 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

test1.c: Test ST with shell matrices
test2.c: Test ST with one matrix
test3.c: Test ST with two matrices
test4.c: Test ST with four matrices
makefile
slepc-3.7.4/src/sys/classes/st/examples/tests/test3.c.html0000644000175000017500000003526013107004621023012 0ustar jromanjroman

Actual source code: test3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test ST with two matrices.\n\n";

 24: #include <slepcst.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat            A,B,M,mat[2];
 31:   ST             st;
 32:   Vec            v,w;
 33:   STType         type;
 34:   PetscScalar    sigma,tau;
 35:   PetscInt       n=10,i,Istart,Iend;

 38:   SlepcInitialize(&argc,&argv,(char*)0,help);
 39:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 40:   PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian plus diagonal, n=%D\n\n",n);

 42:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 43:      Compute the operator matrix for the 1-D Laplacian
 44:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 46:   MatCreate(PETSC_COMM_WORLD,&A);
 47:   MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);
 48:   MatSetFromOptions(A);
 49:   MatSetUp(A);

 51:   MatCreate(PETSC_COMM_WORLD,&B);
 52:   MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n);
 53:   MatSetFromOptions(B);
 54:   MatSetUp(B);

 56:   MatGetOwnershipRange(A,&Istart,&Iend);
 57:   for (i=Istart;i<Iend;i++) {
 58:     MatSetValue(A,i,i,2.0,INSERT_VALUES);
 59:     if (i>0) {
 60:       MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);
 61:       MatSetValue(B,i,i,(PetscScalar)i,INSERT_VALUES);
 62:     } else {
 63:       MatSetValue(B,i,i,-1.0,INSERT_VALUES);
 64:     }
 65:     if (i<n-1) { MatSetValue(A,i,i+1,-1.0,INSERT_VALUES); }
 66:   }
 67:   MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);
 68:   MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);
 69:   MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
 70:   MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
 71:   MatCreateVecs(A,&v,&w);
 72:   VecSet(v,1.0);

 74:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 75:                 Create the spectral transformation object
 76:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 78:   STCreate(PETSC_COMM_WORLD,&st);
 79:   mat[0] = A;
 80:   mat[1] = B;
 81:   STSetOperators(st,2,mat);
 82:   STSetTransform(st,PETSC_TRUE);
 83:   STSetFromOptions(st);

 85:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 86:               Apply the transformed operator for several ST's
 87:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 89:   /* shift, sigma=0.0 */
 90:   STSetUp(st);
 91:   STGetType(st,&type);
 92:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
 93:   STApply(st,v,w);
 94:   VecView(w,NULL);

 96:   /* shift, sigma=0.1 */
 97:   sigma = 0.1;
 98:   STSetShift(st,sigma);
 99:   STGetShift(st,&sigma);
100:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
101:   STApply(st,v,w);
102:   VecView(w,NULL);

104:   /* sinvert, sigma=0.1 */
105:   STPostSolve(st);   /* undo changes if inplace */
106:   STSetType(st,STSINVERT);
107:   STGetType(st,&type);
108:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
109:   STGetShift(st,&sigma);
110:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
111:   STApply(st,v,w);
112:   VecView(w,NULL);

114:   /* sinvert, sigma=-0.5 */
115:   sigma = -0.5;
116:   STSetShift(st,sigma);
117:   STGetShift(st,&sigma);
118:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g\n",(double)PetscRealPart(sigma));
119:   STApply(st,v,w);
120:   VecView(w,NULL);

122:   /* cayley, sigma=-0.5, tau=-0.5 (equal to sigma by default) */
123:   STPostSolve(st);   /* undo changes if inplace */
124:   STSetType(st,STCAYLEY);
125:   STSetUp(st);
126:   STGetType(st,&type);
127:   PetscPrintf(PETSC_COMM_WORLD,"ST type %s\n",type);
128:   STGetShift(st,&sigma);
129:   STCayleyGetAntishift(st,&tau);
130:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g, antishift=%g\n",(double)PetscRealPart(sigma),(double)PetscRealPart(tau));
131:   STApply(st,v,w);
132:   VecView(w,NULL);

134:   /* cayley, sigma=1.1, tau=1.1 (still equal to sigma) */
135:   sigma = 1.1;
136:   STSetShift(st,sigma);
137:   STGetShift(st,&sigma);
138:   STCayleyGetAntishift(st,&tau);
139:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g, antishift=%g\n",(double)PetscRealPart(sigma),(double)PetscRealPart(tau));
140:   STApply(st,v,w);
141:   VecView(w,NULL);

143:   /* cayley, sigma=1.1, tau=-1.0 */
144:   tau = -1.0;
145:   STCayleySetAntishift(st,tau);
146:   STGetShift(st,&sigma);
147:   STCayleyGetAntishift(st,&tau);
148:   PetscPrintf(PETSC_COMM_WORLD,"With shift=%g, antishift=%g\n",(double)PetscRealPart(sigma),(double)PetscRealPart(tau));
149:   STApply(st,v,w);
150:   VecView(w,NULL);

152:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
153:                   Check inner product matrix in Cayley
154:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
155:   STGetBilinearForm(st,&M);
156:   MatMult(M,v,w);
157:   VecView(w,NULL);

159:   STDestroy(&st);
160:   MatDestroy(&A);
161:   MatDestroy(&B);
162:   MatDestroy(&M);
163:   VecDestroy(&v);
164:   VecDestroy(&w);
165:   SlepcFinalize();
166:   return ierr;
167: }
slepc-3.7.4/src/sys/classes/st/examples/tests/test2.c0000644000175000017500000001456513107004621022053 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test ST with one matrix.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A,B,mat[1]; ST st; Vec v,w; STType type; PetscScalar sigma,tau; PetscInt n=10,i,Istart,Iend; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n1-D Laplacian, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the operator matrix for the 1-D Laplacian - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A);CHKERRQ(ierr); ierr = MatSetUp(A);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(A,i,i-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../../../include/slepc/private/stimpl.h ../../../../include/slepcst.h
DIRS     = interface impls examples
LOCDIR   = src/sys/classes/st/
MANSEC   = ST

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/index.html0000644000175000017500000000426713107004621017661 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

interface/
impls/
examples/
../../../../include/slepc/private/stimpl.h
../../../../include/slepcst.h
makefile
slepc-3.7.4/src/sys/classes/st/impls/0000755000175000017500000000000013107004621016777 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/cayley/0000755000175000017500000000000013107004621020265 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/cayley/makefile0000644000175000017500000000217013107004621021765 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = cayley.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = ST LOCDIR = src/sys/classes/st/impls/cayley/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/cayley/cayley.c.html0000644000175000017500000006436313107004621022676 0ustar jromanjroman

Actual source code: cayley.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       Implements the Cayley spectral transform.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/stimpl.h>          /*I "slepcst.h" I*/

 26: typedef struct {
 27:   PetscScalar nu;
 28:   PetscBool   nu_set;
 29:   Vec         w2;
 30: } ST_CAYLEY;

 34: PetscErrorCode STApply_Cayley(ST st,Vec x,Vec y)
 35: {

 39:   /* standard eigenproblem: y = (A - sI)^-1 (A + tI)x */
 40:   /* generalized eigenproblem: y = (A - sB)^-1 (A + tB)x */
 41:   MatMult(st->T[0],x,st->w);
 42:   STMatSolve(st,st->w,y);
 43:   return(0);
 44: }

 48: PetscErrorCode STApplyTranspose_Cayley(ST st,Vec x,Vec y)
 49: {

 53:   /* standard eigenproblem: y =  (A + tI)^T (A - sI)^-T x */
 54:   /* generalized eigenproblem: y = (A + tB)^T (A - sB)^-T x */
 55:   STMatSolveTranspose(st,x,st->w);
 56:   MatMultTranspose(st->T[0],st->w,y);
 57:   return(0);
 58: }

 62: static PetscErrorCode MatMult_Cayley(Mat B,Vec x,Vec y)
 63: {
 65:   ST             st;
 66:   ST_CAYLEY      *ctx;
 67:   PetscScalar    nu;

 70:   MatShellGetContext(B,(void**)&st);
 71:   ctx = (ST_CAYLEY*)st->data;
 72:   nu = ctx->nu;

 74:   if (st->shift_matrix == ST_MATMODE_INPLACE) { nu = nu + st->sigma; };

 76:   if (st->nmat>1) {
 77:     /* generalized eigenproblem: y = (A + tB)x */
 78:     MatMult(st->A[0],x,y);
 79:     MatMult(st->A[1],x,ctx->w2);
 80:     VecAXPY(y,nu,ctx->w2);
 81:   } else {
 82:     /* standard eigenproblem: y = (A + tI)x */
 83:     MatMult(st->A[0],x,y);
 84:     VecAXPY(y,nu,x);
 85:   }
 86:   return(0);
 87: }

 91: PetscErrorCode STGetBilinearForm_Cayley(ST st,Mat *B)
 92: {

 96:   STSetUp(st);
 97:   *B = st->T[0];
 98:   PetscObjectReference((PetscObject)*B);
 99:   return(0);
100: }

104: PetscErrorCode STBackTransform_Cayley(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
105: {
106:   ST_CAYLEY   *ctx = (ST_CAYLEY*)st->data;
107:   PetscInt    j;
108: #if !defined(PETSC_USE_COMPLEX)
109:   PetscScalar t,i,r;
110: #endif

113: #if !defined(PETSC_USE_COMPLEX)
114:   for (j=0;j<n;j++) {
115:     if (eigi[j] == 0.0) eigr[j] = (ctx->nu + eigr[j] * st->sigma) / (eigr[j] - 1.0);
116:     else {
117:       r = eigr[j];
118:       i = eigi[j];
119:       r = st->sigma * (r * r + i * i - r) + ctx->nu * (r - 1);
120:       i = - st->sigma * i - ctx->nu * i;
121:       t = i * i + r * (r - 2.0) + 1.0;
122:       eigr[j] = r / t;
123:       eigi[j] = i / t;
124:     }
125:   }
126: #else
127:   for (j=0;j<n;j++) {
128:     eigr[j] = (ctx->nu + eigr[j] * st->sigma) / (eigr[j] - 1.0);
129:   }
130: #endif
131:   return(0);
132: }

136: PetscErrorCode STPostSolve_Cayley(ST st)
137: {

141:   if (st->shift_matrix == ST_MATMODE_INPLACE) {
142:     if (st->nmat>1) {
143:       MatAXPY(st->A[0],st->sigma,st->A[1],st->str);
144:     } else {
145:       MatShift(st->A[0],st->sigma);
146:     }
147:     st->Astate[0] = ((PetscObject)st->A[0])->state;
148:     st->state = ST_STATE_INITIAL;
149:   }
150:   return(0);
151: }

155: PetscErrorCode STSetUp_Cayley(ST st)
156: {
158:   PetscInt       n,m;
159:   ST_CAYLEY      *ctx = (ST_CAYLEY*)st->data;

162:   ST_AllocateWorkVec(st);

164:   /* if the user did not set the shift, use the target value */
165:   if (!st->sigma_set) st->sigma = st->defsigma;

167:   if (!ctx->nu_set) ctx->nu = st->sigma;
168:   if (ctx->nu == 0.0 && st->sigma == 0.0) SETERRQ(PetscObjectComm((PetscObject)st),1,"Values of shift and antishift cannot be zero simultaneously");

170:   /* T[0] = A+nu*B */
171:   if (st->shift_matrix==ST_MATMODE_INPLACE) {
172:     MatGetLocalSize(st->A[0],&n,&m);
173:     MatCreateShell(PetscObjectComm((PetscObject)st),n,m,PETSC_DETERMINE,PETSC_DETERMINE,st,&st->T[0]);
174:     MatShellSetOperation(st->T[0],MATOP_MULT,(void(*)(void))MatMult_Cayley);
175:     PetscLogObjectParent((PetscObject)st,(PetscObject)st->T[0]);
176:   } else {
177:     STMatMAXPY_Private(st,ctx->nu,0.0,0,NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[0]);
178:   }

180:   /* T[1] = A-sigma*B */
181:   STMatMAXPY_Private(st,-st->sigma,0.0,0,NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[1]);
182:   PetscObjectReference((PetscObject)st->T[1]);
183:   MatDestroy(&st->P);
184:   st->P = st->T[1];
185:   if (st->nmat>1) {
186:     VecDestroy(&ctx->w2);
187:     MatCreateVecs(st->A[1],&ctx->w2,NULL);
188:     PetscLogObjectParent((PetscObject)st,(PetscObject)ctx->w2);
189:   }
190:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
191:   STCheckFactorPackage(st);
192:   KSPSetOperators(st->ksp,st->P,st->P);
193:   KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);
194:   KSPSetUp(st->ksp);
195:   return(0);
196: }

200: PetscErrorCode STSetShift_Cayley(ST st,PetscScalar newshift)
201: {
203:   ST_CAYLEY      *ctx = (ST_CAYLEY*)st->data;

206:   if (newshift==0.0 && (!ctx->nu_set || (ctx->nu_set && ctx->nu==0.0))) SETERRQ(PetscObjectComm((PetscObject)st),1,"Values of shift and antishift cannot be zero simultaneously");

208:   if (!ctx->nu_set) {
209:     if (st->shift_matrix!=ST_MATMODE_INPLACE) {
210:       STMatMAXPY_Private(st,newshift,ctx->nu,0,NULL,PETSC_FALSE,&st->T[0]);
211:     }
212:     ctx->nu = newshift;
213:   }
214:   STMatMAXPY_Private(st,-newshift,-st->sigma,0,NULL,PETSC_FALSE,&st->T[1]);
215:   if (st->P!=st->T[1]) {
216:     MatDestroy(&st->P);
217:     st->P = st->T[1];
218:     PetscObjectReference((PetscObject)st->P);
219:   }
220:   KSPSetOperators(st->ksp,st->P,st->P);
221:   KSPSetUp(st->ksp);
222:   return(0);
223: }

227: PetscErrorCode STSetFromOptions_Cayley(PetscOptionItems *PetscOptionsObject,ST st)
228: {
230:   PetscScalar    nu;
231:   PetscBool      flg;
232:   ST_CAYLEY      *ctx = (ST_CAYLEY*)st->data;
233:   PC             pc;
234:   PCType         pctype;
235:   KSPType        ksptype;

238:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
239:   KSPGetPC(st->ksp,&pc);
240:   KSPGetType(st->ksp,&ksptype);
241:   PCGetType(pc,&pctype);
242:   if (!pctype && !ksptype) {
243:     if (st->shift_matrix == ST_MATMODE_SHELL) {
244:       /* in shell mode use GMRES with Jacobi as the default */
245:       KSPSetType(st->ksp,KSPGMRES);
246:       PCSetType(pc,PCJACOBI);
247:     } else {
248:       /* use direct solver as default */
249:       KSPSetType(st->ksp,KSPPREONLY);
250:       PCSetType(pc,PCLU);
251:     }
252:   }

254:   PetscOptionsHead(PetscOptionsObject,"ST Cayley Options");
255:   PetscOptionsScalar("-st_cayley_antishift","Value of the antishift","STCayleySetAntishift",ctx->nu,&nu,&flg);
256:   if (flg) {
257:     STCayleySetAntishift(st,nu);
258:   }
259:   PetscOptionsTail();
260:   return(0);
261: }

265: static PetscErrorCode STCayleySetAntishift_Cayley(ST st,PetscScalar newshift)
266: {
268:   ST_CAYLEY *ctx = (ST_CAYLEY*)st->data;

271:   if (st->state && st->shift_matrix!=ST_MATMODE_INPLACE) {
272:     STMatMAXPY_Private(st,newshift,ctx->nu,0,NULL,PETSC_FALSE,&st->T[0]);
273:   }
274:   ctx->nu     = newshift;
275:   ctx->nu_set = PETSC_TRUE;
276:   return(0);
277: }

281: /*@
282:    STCayleySetAntishift - Sets the value of the anti-shift for the Cayley
283:    spectral transformation.

285:    Logically Collective on ST

287:    Input Parameters:
288: +  st  - the spectral transformation context
289: -  nu  - the anti-shift

291:    Options Database Key:
292: .  -st_cayley_antishift - Sets the value of the anti-shift

294:    Level: intermediate

296:    Note:
297:    In the generalized Cayley transform, the operator can be expressed as
298:    OP = inv(A - sigma B)*(A + nu B). This function sets the value of nu.
299:    Use STSetShift() for setting sigma.

301: .seealso: STSetShift(), STCayleyGetAntishift()
302: @*/
303: PetscErrorCode STCayleySetAntishift(ST st,PetscScalar nu)
304: {

310:   PetscTryMethod(st,"STCayleySetAntishift_C",(ST,PetscScalar),(st,nu));
311:   return(0);
312: }
315: static PetscErrorCode STCayleyGetAntishift_Cayley(ST st,PetscScalar *nu)
316: {
317:   ST_CAYLEY *ctx = (ST_CAYLEY*)st->data;

320:   *nu = ctx->nu;
321:   return(0);
322: }

326: /*@
327:    STCayleyGetAntishift - Gets the value of the anti-shift used in the Cayley
328:    spectral transformation.

330:    Not Collective

332:    Input Parameter:
333: .  st  - the spectral transformation context

335:    Output Parameter:
336: .  nu  - the anti-shift

338:    Level: intermediate

340: .seealso: STGetShift(), STCayleySetAntishift()
341: @*/
342: PetscErrorCode STCayleyGetAntishift(ST st,PetscScalar *nu)
343: {

349:   PetscUseMethod(st,"STCayleyGetAntishift_C",(ST,PetscScalar*),(st,nu));
350:   return(0);
351: }

355: PetscErrorCode STView_Cayley(ST st,PetscViewer viewer)
356: {
358:   char           str[50];
359:   ST_CAYLEY      *ctx = (ST_CAYLEY*)st->data;
360:   PetscBool      isascii;

363:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
364:   if (isascii) {
365:     SlepcSNPrintfScalar(str,50,ctx->nu,PETSC_FALSE);
366:     PetscViewerASCIIPrintf(viewer,"  Cayley: antishift: %s\n",str);
367:   }
368:   return(0);
369: }

373: PetscErrorCode STReset_Cayley(ST st)
374: {
376:   ST_CAYLEY      *ctx = (ST_CAYLEY*)st->data;

379:   VecDestroy(&ctx->w2);
380:   return(0);
381: }

385: PetscErrorCode STDestroy_Cayley(ST st)
386: {

390:   PetscFree(st->data);
391:   PetscObjectComposeFunction((PetscObject)st,"STCayleySetAntishift_C",NULL);
392:   PetscObjectComposeFunction((PetscObject)st,"STCayleyGetAntishift_C",NULL);
393:   return(0);
394: }

398: PETSC_EXTERN PetscErrorCode STCreate_Cayley(ST st)
399: {
401:   ST_CAYLEY      *ctx;

404:   PetscNewLog(st,&ctx);
405:   st->data = (void*)ctx;

407:   st->ops->apply           = STApply_Cayley;
408:   st->ops->getbilinearform = STGetBilinearForm_Cayley;
409:   st->ops->applytrans      = STApplyTranspose_Cayley;
410:   st->ops->postsolve       = STPostSolve_Cayley;
411:   st->ops->backtransform   = STBackTransform_Cayley;
412:   st->ops->setfromoptions  = STSetFromOptions_Cayley;
413:   st->ops->setup           = STSetUp_Cayley;
414:   st->ops->setshift        = STSetShift_Cayley;
415:   st->ops->destroy         = STDestroy_Cayley;
416:   st->ops->reset           = STReset_Cayley;
417:   st->ops->view            = STView_Cayley;
418:   st->ops->checknullspace  = STCheckNullSpace_Default;
419:   PetscObjectComposeFunction((PetscObject)st,"STCayleySetAntishift_C",STCayleySetAntishift_Cayley);
420:   PetscObjectComposeFunction((PetscObject)st,"STCayleyGetAntishift_C",STCayleyGetAntishift_Cayley);
421:   return(0);
422: }

slepc-3.7.4/src/sys/classes/st/impls/cayley/cayley.c0000644000175000017500000003200313107004621021715 0ustar jromanjroman/* Implements the Cayley spectral transform. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ typedef struct { PetscScalar nu; PetscBool nu_set; Vec w2; } ST_CAYLEY; #undef __FUNCT__ #define __FUNCT__ "STApply_Cayley" PetscErrorCode STApply_Cayley(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; /* standard eigenproblem: y = (A - sI)^-1 (A + tI)x */ /* generalized eigenproblem: y = (A - sB)^-1 (A + tB)x */ ierr = MatMult(st->T[0],x,st->w);CHKERRQ(ierr); ierr = STMatSolve(st,st->w,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STApplyTranspose_Cayley" PetscErrorCode STApplyTranspose_Cayley(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; /* standard eigenproblem: y = (A + tI)^T (A - sI)^-T x */ /* generalized eigenproblem: y = (A + tB)^T (A - sB)^-T x */ ierr = STMatSolveTranspose(st,x,st->w);CHKERRQ(ierr); ierr = MatMultTranspose(st->T[0],st->w,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMult_Cayley" static PetscErrorCode MatMult_Cayley(Mat B,Vec x,Vec y) { PetscErrorCode ierr; ST st; ST_CAYLEY *ctx; PetscScalar nu; PetscFunctionBegin; ierr = MatShellGetContext(B,(void**)&st);CHKERRQ(ierr); ctx = (ST_CAYLEY*)st->data; nu = ctx->nu; if (st->shift_matrix == ST_MATMODE_INPLACE) { nu = nu + st->sigma; }; if (st->nmat>1) { /* generalized eigenproblem: y = (A + tB)x */ ierr = MatMult(st->A[0],x,y);CHKERRQ(ierr); ierr = MatMult(st->A[1],x,ctx->w2);CHKERRQ(ierr); ierr = VecAXPY(y,nu,ctx->w2);CHKERRQ(ierr); } else { /* standard eigenproblem: y = (A + tI)x */ ierr = MatMult(st->A[0],x,y);CHKERRQ(ierr); ierr = VecAXPY(y,nu,x);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STGetBilinearForm_Cayley" PetscErrorCode STGetBilinearForm_Cayley(ST st,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; ierr = STSetUp(st);CHKERRQ(ierr); *B = st->T[0]; ierr = PetscObjectReference((PetscObject)*B);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STBackTransform_Cayley" PetscErrorCode STBackTransform_Cayley(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) { ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PetscInt j; #if !defined(PETSC_USE_COMPLEX) PetscScalar t,i,r; #endif PetscFunctionBegin; #if !defined(PETSC_USE_COMPLEX) for (j=0;jnu + eigr[j] * st->sigma) / (eigr[j] - 1.0); else { r = eigr[j]; i = eigi[j]; r = st->sigma * (r * r + i * i - r) + ctx->nu * (r - 1); i = - st->sigma * i - ctx->nu * i; t = i * i + r * (r - 2.0) + 1.0; eigr[j] = r / t; eigi[j] = i / t; } } #else for (j=0;jnu + eigr[j] * st->sigma) / (eigr[j] - 1.0); } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPostSolve_Cayley" PetscErrorCode STPostSolve_Cayley(ST st) { PetscErrorCode ierr; PetscFunctionBegin; if (st->shift_matrix == ST_MATMODE_INPLACE) { if (st->nmat>1) { ierr = MatAXPY(st->A[0],st->sigma,st->A[1],st->str);CHKERRQ(ierr); } else { ierr = MatShift(st->A[0],st->sigma);CHKERRQ(ierr); } st->Astate[0] = ((PetscObject)st->A[0])->state; st->state = ST_STATE_INITIAL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetUp_Cayley" PetscErrorCode STSetUp_Cayley(ST st) { PetscErrorCode ierr; PetscInt n,m; ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PetscFunctionBegin; ierr = ST_AllocateWorkVec(st);CHKERRQ(ierr); /* if the user did not set the shift, use the target value */ if (!st->sigma_set) st->sigma = st->defsigma; if (!ctx->nu_set) ctx->nu = st->sigma; if (ctx->nu == 0.0 && st->sigma == 0.0) SETERRQ(PetscObjectComm((PetscObject)st),1,"Values of shift and antishift cannot be zero simultaneously"); /* T[0] = A+nu*B */ if (st->shift_matrix==ST_MATMODE_INPLACE) { ierr = MatGetLocalSize(st->A[0],&n,&m);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)st),n,m,PETSC_DETERMINE,PETSC_DETERMINE,st,&st->T[0]);CHKERRQ(ierr); ierr = MatShellSetOperation(st->T[0],MATOP_MULT,(void(*)(void))MatMult_Cayley);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)st,(PetscObject)st->T[0]);CHKERRQ(ierr); } else { ierr = STMatMAXPY_Private(st,ctx->nu,0.0,0,NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[0]);CHKERRQ(ierr); } /* T[1] = A-sigma*B */ ierr = STMatMAXPY_Private(st,-st->sigma,0.0,0,NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[1]);CHKERRQ(ierr); ierr = PetscObjectReference((PetscObject)st->T[1]);CHKERRQ(ierr); ierr = MatDestroy(&st->P);CHKERRQ(ierr); st->P = st->T[1]; if (st->nmat>1) { ierr = VecDestroy(&ctx->w2);CHKERRQ(ierr); ierr = MatCreateVecs(st->A[1],&ctx->w2,NULL);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)st,(PetscObject)ctx->w2);CHKERRQ(ierr); } if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = STCheckFactorPackage(st);CHKERRQ(ierr); ierr = KSPSetOperators(st->ksp,st->P,st->P);CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);CHKERRQ(ierr); ierr = KSPSetUp(st->ksp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetShift_Cayley" PetscErrorCode STSetShift_Cayley(ST st,PetscScalar newshift) { PetscErrorCode ierr; ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PetscFunctionBegin; if (newshift==0.0 && (!ctx->nu_set || (ctx->nu_set && ctx->nu==0.0))) SETERRQ(PetscObjectComm((PetscObject)st),1,"Values of shift and antishift cannot be zero simultaneously"); if (!ctx->nu_set) { if (st->shift_matrix!=ST_MATMODE_INPLACE) { ierr = STMatMAXPY_Private(st,newshift,ctx->nu,0,NULL,PETSC_FALSE,&st->T[0]);CHKERRQ(ierr); } ctx->nu = newshift; } ierr = STMatMAXPY_Private(st,-newshift,-st->sigma,0,NULL,PETSC_FALSE,&st->T[1]);CHKERRQ(ierr); if (st->P!=st->T[1]) { ierr = MatDestroy(&st->P);CHKERRQ(ierr); st->P = st->T[1]; ierr = PetscObjectReference((PetscObject)st->P);CHKERRQ(ierr); } ierr = KSPSetOperators(st->ksp,st->P,st->P);CHKERRQ(ierr); ierr = KSPSetUp(st->ksp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetFromOptions_Cayley" PetscErrorCode STSetFromOptions_Cayley(PetscOptionItems *PetscOptionsObject,ST st) { PetscErrorCode ierr; PetscScalar nu; PetscBool flg; ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PC pc; PCType pctype; KSPType ksptype; PetscFunctionBegin; if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = KSPGetType(st->ksp,&ksptype);CHKERRQ(ierr); ierr = PCGetType(pc,&pctype);CHKERRQ(ierr); if (!pctype && !ksptype) { if (st->shift_matrix == ST_MATMODE_SHELL) { /* in shell mode use GMRES with Jacobi as the default */ ierr = KSPSetType(st->ksp,KSPGMRES);CHKERRQ(ierr); ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr); } else { /* use direct solver as default */ ierr = KSPSetType(st->ksp,KSPPREONLY);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); } } ierr = PetscOptionsHead(PetscOptionsObject,"ST Cayley Options");CHKERRQ(ierr); ierr = PetscOptionsScalar("-st_cayley_antishift","Value of the antishift","STCayleySetAntishift",ctx->nu,&nu,&flg);CHKERRQ(ierr); if (flg) { ierr = STCayleySetAntishift(st,nu);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCayleySetAntishift_Cayley" static PetscErrorCode STCayleySetAntishift_Cayley(ST st,PetscScalar newshift) { PetscErrorCode ierr; ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PetscFunctionBegin; if (st->state && st->shift_matrix!=ST_MATMODE_INPLACE) { ierr = STMatMAXPY_Private(st,newshift,ctx->nu,0,NULL,PETSC_FALSE,&st->T[0]);CHKERRQ(ierr); } ctx->nu = newshift; ctx->nu_set = PETSC_TRUE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCayleySetAntishift" /*@ STCayleySetAntishift - Sets the value of the anti-shift for the Cayley spectral transformation. Logically Collective on ST Input Parameters: + st - the spectral transformation context - nu - the anti-shift Options Database Key: . -st_cayley_antishift - Sets the value of the anti-shift Level: intermediate Note: In the generalized Cayley transform, the operator can be expressed as OP = inv(A - sigma B)*(A + nu B). This function sets the value of nu. Use STSetShift() for setting sigma. .seealso: STSetShift(), STCayleyGetAntishift() @*/ PetscErrorCode STCayleySetAntishift(ST st,PetscScalar nu) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveScalar(st,nu,2); ierr = PetscTryMethod(st,"STCayleySetAntishift_C",(ST,PetscScalar),(st,nu));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCayleyGetAntishift_Cayley" static PetscErrorCode STCayleyGetAntishift_Cayley(ST st,PetscScalar *nu) { ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PetscFunctionBegin; *nu = ctx->nu; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCayleyGetAntishift" /*@ STCayleyGetAntishift - Gets the value of the anti-shift used in the Cayley spectral transformation. Not Collective Input Parameter: . st - the spectral transformation context Output Parameter: . nu - the anti-shift Level: intermediate .seealso: STGetShift(), STCayleySetAntishift() @*/ PetscErrorCode STCayleyGetAntishift(ST st,PetscScalar *nu) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidScalarPointer(nu,2); ierr = PetscUseMethod(st,"STCayleyGetAntishift_C",(ST,PetscScalar*),(st,nu));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STView_Cayley" PetscErrorCode STView_Cayley(ST st,PetscViewer viewer) { PetscErrorCode ierr; char str[50]; ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = SlepcSNPrintfScalar(str,50,ctx->nu,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Cayley: antishift: %s\n",str);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STReset_Cayley" PetscErrorCode STReset_Cayley(ST st) { PetscErrorCode ierr; ST_CAYLEY *ctx = (ST_CAYLEY*)st->data; PetscFunctionBegin; ierr = VecDestroy(&ctx->w2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STDestroy_Cayley" PetscErrorCode STDestroy_Cayley(ST st) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(st->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STCayleySetAntishift_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STCayleyGetAntishift_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCreate_Cayley" PETSC_EXTERN PetscErrorCode STCreate_Cayley(ST st) { PetscErrorCode ierr; ST_CAYLEY *ctx; PetscFunctionBegin; ierr = PetscNewLog(st,&ctx);CHKERRQ(ierr); st->data = (void*)ctx; st->ops->apply = STApply_Cayley; st->ops->getbilinearform = STGetBilinearForm_Cayley; st->ops->applytrans = STApplyTranspose_Cayley; st->ops->postsolve = STPostSolve_Cayley; st->ops->backtransform = STBackTransform_Cayley; st->ops->setfromoptions = STSetFromOptions_Cayley; st->ops->setup = STSetUp_Cayley; st->ops->setshift = STSetShift_Cayley; st->ops->destroy = STDestroy_Cayley; st->ops->reset = STReset_Cayley; st->ops->view = STView_Cayley; st->ops->checknullspace = STCheckNullSpace_Default; ierr = PetscObjectComposeFunction((PetscObject)st,"STCayleySetAntishift_C",STCayleySetAntishift_Cayley);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STCayleyGetAntishift_C",STCayleyGetAntishift_Cayley);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/impls/cayley/makefile.html0000644000175000017500000000471513107004621022737 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = cayley.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = ST
LOCDIR   = src/sys/classes/st/impls/cayley/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/impls/cayley/index.html0000644000175000017500000000371413107004621022267 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

cayley.c
makefile
slepc-3.7.4/src/sys/classes/st/impls/cayley/ftn-auto/0000755000175000017500000000000013107004621022022 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/cayley/ftn-auto/makefile0000644000175000017500000000037413107004621023526 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = cayleyf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/st/impls/cayley/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/cayley/ftn-auto/cayleyf.c0000644000175000017500000000273213107004621023626 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* cayley.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcst.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define stcayleysetantishift_ STCAYLEYSETANTISHIFT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stcayleysetantishift_ stcayleysetantishift #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stcayleygetantishift_ STCAYLEYGETANTISHIFT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stcayleygetantishift_ stcayleygetantishift #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL stcayleysetantishift_(ST st,PetscScalar *nu, int *__ierr ){ *__ierr = STCayleySetAntishift( (ST)PetscToPointer((st) ),*nu); } PETSC_EXTERN void PETSC_STDCALL stcayleygetantishift_(ST st,PetscScalar *nu, int *__ierr ){ *__ierr = STCayleyGetAntishift( (ST)PetscToPointer((st) ),nu); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/st/impls/makefile0000644000175000017500000000212413107004621020476 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcsys DIRS = shell shift sinvert cayley precond LOCDIR = src/sys/classes/st/impls/ MANSEC = ST include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/precond/0000755000175000017500000000000013107004621020431 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/precond/makefile0000644000175000017500000000217213107004621022133 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = precond.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = ST LOCDIR = src/sys/classes/st/impls/precond/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/precond/makefile.html0000644000175000017500000000472113107004621023100 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = precond.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = ST
LOCDIR   = src/sys/classes/st/impls/precond/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/impls/precond/precond.c.html0000644000175000017500000006572413107004621023210 0ustar jromanjroman
Actual source code: precond.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       Implements the ST class for preconditioned eigenvalue methods.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/stimpl.h>          /*I "slepcst.h" I*/

 26: typedef struct {
 27:   PetscBool setmat;
 28: } ST_PRECOND;

 32: static PetscErrorCode STSetDefaultPrecond(ST st)
 33: {
 35:   PC             pc;
 36:   PCType         pctype;
 37:   Mat            P;
 38:   PetscBool      t0,t1;
 39:   KSP            ksp;

 42:   STGetKSP(st,&ksp);
 43:   KSPGetPC(ksp,&pc);
 44:   PetscObjectGetType((PetscObject)pc,&pctype);
 45:   STPrecondGetMatForPC(st,&P);
 46:   if (!pctype && st->A && st->A[0]) {
 47:     if (P || st->shift_matrix == ST_MATMODE_SHELL) {
 48:       PCSetType(pc,PCJACOBI);
 49:     } else {
 50:       MatHasOperation(st->A[0],MATOP_DUPLICATE,&t0);
 51:       if (st->nmat>1) {
 52:         MatHasOperation(st->A[0],MATOP_AXPY,&t1);
 53:       } else t1 = PETSC_TRUE;
 54:       PCSetType(pc,(t0 && t1)?PCJACOBI:PCNONE);
 55:     }
 56:   }
 57:   return(0);
 58: }

 62: PetscErrorCode STSetFromOptions_Precond(PetscOptionItems *PetscOptionsObject,ST st)
 63: {

 67:   STSetDefaultPrecond(st);
 68:   return(0);
 69: }

 73: PetscErrorCode STSetUp_Precond(ST st)
 74: {
 75:   Mat            P;
 76:   PC             pc;
 77:   PetscBool      t0,setmat,destroyP=PETSC_FALSE,builtP;

 81:   /* if the user did not set the shift, use the target value */
 82:   if (!st->sigma_set) st->sigma = st->defsigma;

 84:   /* If either pc is none and no matrix has to be set, or pc is shell , exit */
 85:   STSetDefaultPrecond(st);
 86:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
 87:   KSPGetPC(st->ksp,&pc);
 88:   PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&t0);
 89:   if (t0) return(0);
 90:   PetscObjectTypeCompare((PetscObject)pc,PCNONE,&t0);
 91:   STPrecondGetKSPHasMat(st,&setmat);
 92:   if (t0 && !setmat) return(0);

 94:   /* Check if a user matrix is set */
 95:   STPrecondGetMatForPC(st,&P);

 97:   /* If not, create A - shift*B */
 98:   if (P) {
 99:     builtP = PETSC_FALSE;
100:     destroyP = PETSC_TRUE;
101:     PetscObjectReference((PetscObject)P);
102:   } else {
103:     builtP = PETSC_TRUE;

105:     if (!(PetscAbsScalar(st->sigma) < PETSC_MAX_REAL) && st->nmat>1) {
106:       P = st->A[1];
107:       destroyP = PETSC_FALSE;
108:     } else if (st->sigma == 0.0) {
109:       P = st->A[0];
110:       destroyP = PETSC_FALSE;
111:     } else if (PetscAbsScalar(st->sigma) < PETSC_MAX_REAL && st->shift_matrix != ST_MATMODE_SHELL) {
112:       if (st->shift_matrix == ST_MATMODE_INPLACE) {
113:         P = st->A[0];
114:         destroyP = PETSC_FALSE;
115:       } else {
116:         MatDuplicate(st->A[0],MAT_COPY_VALUES,&P);
117:         destroyP = PETSC_TRUE;
118:       }
119:       if (st->nmat>1) {
120:         MatAXPY(P,-st->sigma,st->A[1],st->str);
121:       } else {
122:         MatShift(P,-st->sigma);
123:       }
124:       /* TODO: in case of ST_MATMODE_INPLACE should keep the Hermitian flag of st->A and restore at the end */
125:       STMatSetHermitian(st,P);
126:     } else builtP = PETSC_FALSE;
127:   }

129:   /* If P was not possible to obtain, set pc to PCNONE */
130:   if (!P) {
131:     PCSetType(pc,PCNONE);

133:     /* If some matrix has to be set to ksp, a shell matrix is created */
134:     if (setmat) {
135:       STMatShellCreate(st,-st->sigma,0,NULL,NULL,&P);
136:       STMatSetHermitian(st,P);
137:       destroyP = PETSC_TRUE;
138:     }
139:   }

141:   KSPSetOperators(st->ksp,setmat?P:NULL,P);

143:   if (destroyP) {
144:     MatDestroy(&P);
145:   } else if (st->shift_matrix == ST_MATMODE_INPLACE && builtP) {
146:     if (st->sigma != 0.0 && PetscAbsScalar(st->sigma) < PETSC_MAX_REAL) {
147:       if (st->nmat>1) {
148:         MatAXPY(st->A[0],st->sigma,st->A[1],st->str);
149:       } else {
150:         MatShift(st->A[0],st->sigma);
151:       }
152:     }
153:   }
154:   return(0);
155: }

159: PetscErrorCode STSetShift_Precond(ST st,PetscScalar newshift)
160: {

164:   /* Nothing to be done if STSetUp has not been called yet */
165:   if (!st->state) return(0);
166:   st->sigma = newshift;
167:   if (st->shift_matrix != ST_MATMODE_SHELL) {
168:     STSetUp_Precond(st);
169:   }
170:   return(0);
171: }

175: static PetscErrorCode STPrecondGetMatForPC_Precond(ST st,Mat *mat)
176: {
178:   PC             pc;
179:   PetscBool      flag;

182:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
183:   KSPGetPC(st->ksp,&pc);
184:   PCGetOperatorsSet(pc,NULL,&flag);
185:   if (flag) {
186:     PCGetOperators(pc,NULL,mat);
187:   } else *mat = NULL;
188:   return(0);
189: }

193: /*@
194:    STPrecondGetMatForPC - Returns the matrix previously set by STPrecondSetMatForPC().

196:    Not Collective, but the Mat is shared by all processors that share the ST

198:    Input Parameter:
199: .  st - the spectral transformation context

201:    Output Parameter:
202: .  mat - the matrix that will be used in constructing the preconditioner or
203:    NULL if no matrix was set by STPrecondSetMatForPC().

205:    Level: advanced

207: .seealso: STPrecondSetMatForPC()
208: @*/
209: PetscErrorCode STPrecondGetMatForPC(ST st,Mat *mat)
210: {

216:   PetscUseMethod(st,"STPrecondGetMatForPC_C",(ST,Mat*),(st,mat));
217:   return(0);
218: }

222: static PetscErrorCode STPrecondSetMatForPC_Precond(ST st,Mat mat)
223: {
224:   PC             pc;
225:   Mat            A;
226:   PetscBool      flag;

230:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
231:   KSPGetPC(st->ksp,&pc);
232:   /* Yes, all these lines are needed to safely set mat as the preconditioner
233:      matrix in pc */
234:   PCGetOperatorsSet(pc,&flag,NULL);
235:   if (flag) {
236:     PCGetOperators(pc,&A,NULL);
237:     PetscObjectReference((PetscObject)A);
238:   } else A = NULL;
239:   PetscObjectReference((PetscObject)mat);
240:   PCSetOperators(pc,A,mat);
241:   MatDestroy(&A);
242:   MatDestroy(&mat);
243:   STPrecondSetKSPHasMat(st,PETSC_TRUE);
244:   return(0);
245: }

249: /*@
250:    STPrecondSetMatForPC - Sets the matrix that must be used to build the preconditioner.

252:    Logically Collective on ST and Mat

254:    Input Parameter:
255: +  st - the spectral transformation context
256: -  mat - the matrix that will be used in constructing the preconditioner

258:    Level: advanced

260:    Notes:
261:    This matrix will be passed to the KSP object (via KSPSetOperators) as
262:    the matrix to be used when constructing the preconditioner.
263:    If no matrix is set or mat is set to NULL, A - sigma*B will
264:    be used to build the preconditioner, being sigma the value set by STSetShift().

266: .seealso: STPrecondSetMatForPC(), STSetShift()
267: @*/
268: PetscErrorCode STPrecondSetMatForPC(ST st,Mat mat)
269: {

276:   PetscTryMethod(st,"STPrecondSetMatForPC_C",(ST,Mat),(st,mat));
277:   return(0);
278: }

282: static PetscErrorCode STPrecondSetKSPHasMat_Precond(ST st,PetscBool setmat)
283: {
284:   ST_PRECOND *data = (ST_PRECOND*)st->data;

287:   data->setmat = setmat;
288:   return(0);
289: }

293: /*@
294:    STPrecondSetKSPHasMat - Sets a flag indicating that during STSetUp the coefficient
295:    matrix of the KSP linear system (A) must be set to be the same matrix as the
296:    preconditioner (P).

298:    Collective on ST

300:    Input Parameter:
301: +  st - the spectral transformation context
302: -  setmat - the flag

304:    Notes:
305:    In most cases, the preconditioner matrix is used only in the PC object, but
306:    in external solvers this matrix must be provided also as the A-matrix in
307:    the KSP object.

309:    Level: developer

311: .seealso: STPrecondGetKSPHasMat(), STSetShift()
312: @*/
313: PetscErrorCode STPrecondSetKSPHasMat(ST st,PetscBool setmat)
314: {

320:   PetscTryMethod(st,"STPrecondSetKSPHasMat_C",(ST,PetscBool),(st,setmat));
321:   return(0);
322: }

326: static PetscErrorCode STPrecondGetKSPHasMat_Precond(ST st,PetscBool *setmat)
327: {
328:   ST_PRECOND *data = (ST_PRECOND*)st->data;

331:   *setmat = data->setmat;
332:   return(0);
333: }

337: /*@
338:    STPrecondGetKSPHasMat - Returns the flag indicating if the coefficient
339:    matrix of the KSP linear system (A) is set to be the same matrix as the
340:    preconditioner (P).

342:    Not Collective

344:    Input Parameter:
345: .  st - the spectral transformation context

347:    Output Parameter:
348: .  setmat - the flag

350:    Level: developer

352: .seealso: STPrecondSetKSPHasMat(), STSetShift()
353: @*/
354: PetscErrorCode STPrecondGetKSPHasMat(ST st,PetscBool *setmat)
355: {

361:   PetscUseMethod(st,"STPrecondGetKSPHasMat_C",(ST,PetscBool*),(st,setmat));
362:   return(0);
363: }

367: PetscErrorCode STDestroy_Precond(ST st)
368: {

372:   PetscFree(st->data);
373:   PetscObjectComposeFunction((PetscObject)st,"STPrecondGetMatForPC_C",NULL);
374:   PetscObjectComposeFunction((PetscObject)st,"STPrecondSetMatForPC_C",NULL);
375:   PetscObjectComposeFunction((PetscObject)st,"STPrecondGetKSPHasMat_C",NULL);
376:   PetscObjectComposeFunction((PetscObject)st,"STPrecondSetKSPHasMat_C",NULL);
377:   return(0);
378: }

382: PETSC_EXTERN PetscErrorCode STCreate_Precond(ST st)
383: {
385:   ST_PRECOND     *ctx;

388:   PetscNewLog(st,&ctx);
389:   st->data = (void*)ctx;

391:   st->ops->getbilinearform = STGetBilinearForm_Default;
392:   st->ops->setup           = STSetUp_Precond;
393:   st->ops->setshift        = STSetShift_Precond;
394:   st->ops->destroy         = STDestroy_Precond;
395:   st->ops->setfromoptions  = STSetFromOptions_Precond;

397:   PetscObjectComposeFunction((PetscObject)st,"STPrecondGetMatForPC_C",STPrecondGetMatForPC_Precond);
398:   PetscObjectComposeFunction((PetscObject)st,"STPrecondSetMatForPC_C",STPrecondSetMatForPC_Precond);
399:   PetscObjectComposeFunction((PetscObject)st,"STPrecondGetKSPHasMat_C",STPrecondGetKSPHasMat_Precond);
400:   PetscObjectComposeFunction((PetscObject)st,"STPrecondSetKSPHasMat_C",STPrecondSetKSPHasMat_Precond);

402:   STPrecondSetKSPHasMat_Precond(st,PETSC_TRUE);
403:   return(0);
404: }

slepc-3.7.4/src/sys/classes/st/impls/precond/precond.c0000644000175000017500000003111313107004621022226 0ustar jromanjroman/* Implements the ST class for preconditioned eigenvalue methods. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ typedef struct { PetscBool setmat; } ST_PRECOND; #undef __FUNCT__ #define __FUNCT__ "STSetDefaultPrecond" static PetscErrorCode STSetDefaultPrecond(ST st) { PetscErrorCode ierr; PC pc; PCType pctype; Mat P; PetscBool t0,t1; KSP ksp; PetscFunctionBegin; ierr = STGetKSP(st,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PetscObjectGetType((PetscObject)pc,&pctype);CHKERRQ(ierr); ierr = STPrecondGetMatForPC(st,&P);CHKERRQ(ierr); if (!pctype && st->A && st->A[0]) { if (P || st->shift_matrix == ST_MATMODE_SHELL) { ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr); } else { ierr = MatHasOperation(st->A[0],MATOP_DUPLICATE,&t0);CHKERRQ(ierr); if (st->nmat>1) { ierr = MatHasOperation(st->A[0],MATOP_AXPY,&t1);CHKERRQ(ierr); } else t1 = PETSC_TRUE; ierr = PCSetType(pc,(t0 && t1)?PCJACOBI:PCNONE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetFromOptions_Precond" PetscErrorCode STSetFromOptions_Precond(PetscOptionItems *PetscOptionsObject,ST st) { PetscErrorCode ierr; PetscFunctionBegin; ierr = STSetDefaultPrecond(st);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetUp_Precond" PetscErrorCode STSetUp_Precond(ST st) { Mat P; PC pc; PetscBool t0,setmat,destroyP=PETSC_FALSE,builtP; PetscErrorCode ierr; PetscFunctionBegin; /* if the user did not set the shift, use the target value */ if (!st->sigma_set) st->sigma = st->defsigma; /* If either pc is none and no matrix has to be set, or pc is shell , exit */ ierr = STSetDefaultPrecond(st);CHKERRQ(ierr); if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pc,PCSHELL,&t0);CHKERRQ(ierr); if (t0) PetscFunctionReturn(0); ierr = PetscObjectTypeCompare((PetscObject)pc,PCNONE,&t0);CHKERRQ(ierr); ierr = STPrecondGetKSPHasMat(st,&setmat);CHKERRQ(ierr); if (t0 && !setmat) PetscFunctionReturn(0); /* Check if a user matrix is set */ ierr = STPrecondGetMatForPC(st,&P);CHKERRQ(ierr); /* If not, create A - shift*B */ if (P) { builtP = PETSC_FALSE; destroyP = PETSC_TRUE; ierr = PetscObjectReference((PetscObject)P);CHKERRQ(ierr); } else { builtP = PETSC_TRUE; if (!(PetscAbsScalar(st->sigma) < PETSC_MAX_REAL) && st->nmat>1) { P = st->A[1]; destroyP = PETSC_FALSE; } else if (st->sigma == 0.0) { P = st->A[0]; destroyP = PETSC_FALSE; } else if (PetscAbsScalar(st->sigma) < PETSC_MAX_REAL && st->shift_matrix != ST_MATMODE_SHELL) { if (st->shift_matrix == ST_MATMODE_INPLACE) { P = st->A[0]; destroyP = PETSC_FALSE; } else { ierr = MatDuplicate(st->A[0],MAT_COPY_VALUES,&P);CHKERRQ(ierr); destroyP = PETSC_TRUE; } if (st->nmat>1) { ierr = MatAXPY(P,-st->sigma,st->A[1],st->str);CHKERRQ(ierr); } else { ierr = MatShift(P,-st->sigma);CHKERRQ(ierr); } /* TODO: in case of ST_MATMODE_INPLACE should keep the Hermitian flag of st->A and restore at the end */ ierr = STMatSetHermitian(st,P);CHKERRQ(ierr); } else builtP = PETSC_FALSE; } /* If P was not possible to obtain, set pc to PCNONE */ if (!P) { ierr = PCSetType(pc,PCNONE);CHKERRQ(ierr); /* If some matrix has to be set to ksp, a shell matrix is created */ if (setmat) { ierr = STMatShellCreate(st,-st->sigma,0,NULL,NULL,&P);CHKERRQ(ierr); ierr = STMatSetHermitian(st,P);CHKERRQ(ierr); destroyP = PETSC_TRUE; } } ierr = KSPSetOperators(st->ksp,setmat?P:NULL,P);CHKERRQ(ierr); if (destroyP) { ierr = MatDestroy(&P);CHKERRQ(ierr); } else if (st->shift_matrix == ST_MATMODE_INPLACE && builtP) { if (st->sigma != 0.0 && PetscAbsScalar(st->sigma) < PETSC_MAX_REAL) { if (st->nmat>1) { ierr = MatAXPY(st->A[0],st->sigma,st->A[1],st->str);CHKERRQ(ierr); } else { ierr = MatShift(st->A[0],st->sigma);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetShift_Precond" PetscErrorCode STSetShift_Precond(ST st,PetscScalar newshift) { PetscErrorCode ierr; PetscFunctionBegin; /* Nothing to be done if STSetUp has not been called yet */ if (!st->state) PetscFunctionReturn(0); st->sigma = newshift; if (st->shift_matrix != ST_MATMODE_SHELL) { ierr = STSetUp_Precond(st);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondGetMatForPC_Precond" static PetscErrorCode STPrecondGetMatForPC_Precond(ST st,Mat *mat) { PetscErrorCode ierr; PC pc; PetscBool flag; PetscFunctionBegin; if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = PCGetOperatorsSet(pc,NULL,&flag);CHKERRQ(ierr); if (flag) { ierr = PCGetOperators(pc,NULL,mat);CHKERRQ(ierr); } else *mat = NULL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondGetMatForPC" /*@ STPrecondGetMatForPC - Returns the matrix previously set by STPrecondSetMatForPC(). Not Collective, but the Mat is shared by all processors that share the ST Input Parameter: . st - the spectral transformation context Output Parameter: . mat - the matrix that will be used in constructing the preconditioner or NULL if no matrix was set by STPrecondSetMatForPC(). Level: advanced .seealso: STPrecondSetMatForPC() @*/ PetscErrorCode STPrecondGetMatForPC(ST st,Mat *mat) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(mat,2); ierr = PetscUseMethod(st,"STPrecondGetMatForPC_C",(ST,Mat*),(st,mat));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondSetMatForPC_Precond" static PetscErrorCode STPrecondSetMatForPC_Precond(ST st,Mat mat) { PC pc; Mat A; PetscBool flag; PetscErrorCode ierr; PetscFunctionBegin; if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); /* Yes, all these lines are needed to safely set mat as the preconditioner matrix in pc */ ierr = PCGetOperatorsSet(pc,&flag,NULL);CHKERRQ(ierr); if (flag) { ierr = PCGetOperators(pc,&A,NULL);CHKERRQ(ierr); ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr); } else A = NULL; ierr = PetscObjectReference((PetscObject)mat);CHKERRQ(ierr); ierr = PCSetOperators(pc,A,mat);CHKERRQ(ierr); ierr = MatDestroy(&A);CHKERRQ(ierr); ierr = MatDestroy(&mat);CHKERRQ(ierr); ierr = STPrecondSetKSPHasMat(st,PETSC_TRUE);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondSetMatForPC" /*@ STPrecondSetMatForPC - Sets the matrix that must be used to build the preconditioner. Logically Collective on ST and Mat Input Parameter: + st - the spectral transformation context - mat - the matrix that will be used in constructing the preconditioner Level: advanced Notes: This matrix will be passed to the KSP object (via KSPSetOperators) as the matrix to be used when constructing the preconditioner. If no matrix is set or mat is set to NULL, A - sigma*B will be used to build the preconditioner, being sigma the value set by STSetShift(). .seealso: STPrecondSetMatForPC(), STSetShift() @*/ PetscErrorCode STPrecondSetMatForPC(ST st,Mat mat) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidHeaderSpecific(mat,MAT_CLASSID,2); PetscCheckSameComm(st,1,mat,2); ierr = PetscTryMethod(st,"STPrecondSetMatForPC_C",(ST,Mat),(st,mat));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondSetKSPHasMat_Precond" static PetscErrorCode STPrecondSetKSPHasMat_Precond(ST st,PetscBool setmat) { ST_PRECOND *data = (ST_PRECOND*)st->data; PetscFunctionBegin; data->setmat = setmat; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondSetKSPHasMat" /*@ STPrecondSetKSPHasMat - Sets a flag indicating that during STSetUp the coefficient matrix of the KSP linear system (A) must be set to be the same matrix as the preconditioner (P). Collective on ST Input Parameter: + st - the spectral transformation context - setmat - the flag Notes: In most cases, the preconditioner matrix is used only in the PC object, but in external solvers this matrix must be provided also as the A-matrix in the KSP object. Level: developer .seealso: STPrecondGetKSPHasMat(), STSetShift() @*/ PetscErrorCode STPrecondSetKSPHasMat(ST st,PetscBool setmat) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidLogicalCollectiveBool(st,setmat,2); ierr = PetscTryMethod(st,"STPrecondSetKSPHasMat_C",(ST,PetscBool),(st,setmat));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondGetKSPHasMat_Precond" static PetscErrorCode STPrecondGetKSPHasMat_Precond(ST st,PetscBool *setmat) { ST_PRECOND *data = (ST_PRECOND*)st->data; PetscFunctionBegin; *setmat = data->setmat; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPrecondGetKSPHasMat" /*@ STPrecondGetKSPHasMat - Returns the flag indicating if the coefficient matrix of the KSP linear system (A) is set to be the same matrix as the preconditioner (P). Not Collective Input Parameter: . st - the spectral transformation context Output Parameter: . setmat - the flag Level: developer .seealso: STPrecondSetKSPHasMat(), STSetShift() @*/ PetscErrorCode STPrecondGetKSPHasMat(ST st,PetscBool *setmat) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(setmat,2); ierr = PetscUseMethod(st,"STPrecondGetKSPHasMat_C",(ST,PetscBool*),(st,setmat));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STDestroy_Precond" PetscErrorCode STDestroy_Precond(ST st) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(st->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondGetMatForPC_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondSetMatForPC_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondGetKSPHasMat_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondSetKSPHasMat_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCreate_Precond" PETSC_EXTERN PetscErrorCode STCreate_Precond(ST st) { PetscErrorCode ierr; ST_PRECOND *ctx; PetscFunctionBegin; ierr = PetscNewLog(st,&ctx);CHKERRQ(ierr); st->data = (void*)ctx; st->ops->getbilinearform = STGetBilinearForm_Default; st->ops->setup = STSetUp_Precond; st->ops->setshift = STSetShift_Precond; st->ops->destroy = STDestroy_Precond; st->ops->setfromoptions = STSetFromOptions_Precond; ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondGetMatForPC_C",STPrecondGetMatForPC_Precond);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondSetMatForPC_C",STPrecondSetMatForPC_Precond);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondGetKSPHasMat_C",STPrecondGetKSPHasMat_Precond);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STPrecondSetKSPHasMat_C",STPrecondSetKSPHasMat_Precond);CHKERRQ(ierr); ierr = STPrecondSetKSPHasMat_Precond(st,PETSC_TRUE);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/impls/precond/index.html0000644000175000017500000000372013107004621022430 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

precond.c
makefile
slepc-3.7.4/src/sys/classes/st/impls/precond/ftn-auto/0000755000175000017500000000000013107004621022166 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/precond/ftn-auto/makefile0000644000175000017500000000037613107004621023674 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = precondf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/st/impls/precond/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/precond/ftn-auto/precondf.c0000644000175000017500000000437413107004621024142 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* precond.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcst.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define stprecondgetmatforpc_ STPRECONDGETMATFORPC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stprecondgetmatforpc_ stprecondgetmatforpc #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stprecondsetmatforpc_ STPRECONDSETMATFORPC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stprecondsetmatforpc_ stprecondsetmatforpc #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stprecondsetksphasmat_ STPRECONDSETKSPHASMAT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stprecondsetksphasmat_ stprecondsetksphasmat #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define stprecondgetksphasmat_ STPRECONDGETKSPHASMAT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stprecondgetksphasmat_ stprecondgetksphasmat #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL stprecondgetmatforpc_(ST st,Mat *mat, int *__ierr ){ *__ierr = STPrecondGetMatForPC( (ST)PetscToPointer((st) ),mat); } PETSC_EXTERN void PETSC_STDCALL stprecondsetmatforpc_(ST st,Mat mat, int *__ierr ){ *__ierr = STPrecondSetMatForPC( (ST)PetscToPointer((st) ), (Mat)PetscToPointer((mat) )); } PETSC_EXTERN void PETSC_STDCALL stprecondsetksphasmat_(ST st,PetscBool *setmat, int *__ierr ){ *__ierr = STPrecondSetKSPHasMat( (ST)PetscToPointer((st) ),*setmat); } PETSC_EXTERN void PETSC_STDCALL stprecondgetksphasmat_(ST st,PetscBool *setmat, int *__ierr ){ *__ierr = STPrecondGetKSPHasMat( (ST)PetscToPointer((st) ),setmat); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/st/impls/makefile.html0000644000175000017500000000463313107004621021450 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcsys
DIRS     = shell shift sinvert cayley precond
LOCDIR   = src/sys/classes/st/impls/
MANSEC   = ST

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/impls/shell/0000755000175000017500000000000013107004621020106 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/shell/shell.c.html0000644000175000017500000006641213107004621022335 0ustar jromanjroman
Actual source code: shell.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    This provides a simple shell interface for programmers to
  3:    create their own spectral transformations without writing much
  4:    interface code.

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

 10:    This file is part of SLEPc.

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

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

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

 26: #include <slepc/private/stimpl.h>        /*I "slepcst.h" I*/

 28: typedef struct {
 29:   void           *ctx;                       /* user provided context */
 30:   PetscErrorCode (*apply)(ST,Vec,Vec);
 31:   PetscErrorCode (*applytrans)(ST,Vec,Vec);
 32:   PetscErrorCode (*backtransform)(ST,PetscInt n,PetscScalar*,PetscScalar*);
 33: } ST_SHELL;

 37: /*@C
 38:    STShellGetContext - Returns the user-provided context associated with a shell ST

 40:    Not Collective

 42:    Input Parameter:
 43: .  st - spectral transformation context

 45:    Output Parameter:
 46: .  ctx - the user provided context

 48:    Level: advanced

 50:    Notes:
 51:    This routine is intended for use within various shell routines

 53: .seealso: STShellSetContext()
 54: @*/
 55: PetscErrorCode STShellGetContext(ST st,void **ctx)
 56: {
 58:   PetscBool      flg;

 63:   PetscObjectTypeCompare((PetscObject)st,STSHELL,&flg);
 64:   if (!flg) *ctx = 0;
 65:   else      *ctx = ((ST_SHELL*)(st->data))->ctx;
 66:   return(0);
 67: }

 71: /*@
 72:    STShellSetContext - Sets the context for a shell ST

 74:    Logically Collective on ST

 76:    Input Parameters:
 77: +  st - the shell ST
 78: -  ctx - the context

 80:    Level: advanced

 82:    Fortran Notes:
 83:    To use this from Fortran you must write a Fortran interface definition
 84:    for this function that tells Fortran the Fortran derived data type that
 85:    you are passing in as the ctx argument.

 87: .seealso: STShellGetContext()
 88: @*/
 89: PetscErrorCode STShellSetContext(ST st,void *ctx)
 90: {
 91:   ST_SHELL       *shell = (ST_SHELL*)st->data;
 93:   PetscBool      flg;

 97:   PetscObjectTypeCompare((PetscObject)st,STSHELL,&flg);
 98:   if (flg) shell->ctx = ctx;
 99:   return(0);
100: }

104: PetscErrorCode STApply_Shell(ST st,Vec x,Vec y)
105: {
106:   PetscErrorCode   ierr;
107:   ST_SHELL         *shell = (ST_SHELL*)st->data;
108:   PetscObjectState instate,outstate;

111:   if (!shell->apply) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_USER,"No apply() routine provided to Shell ST");
112:   PetscObjectStateGet((PetscObject)y,&instate);
113:   PetscStackCall("STSHELL user function apply()",(*shell->apply)(st,x,y);CHKERRQ(ierr));
114:   PetscObjectStateGet((PetscObject)y,&outstate);
115:   if (instate == outstate) {
116:     /* user forgot to increase the state of the output vector */
117:     PetscObjectStateIncrease((PetscObject)y);
118:   }
119:   return(0);
120: }

124: PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y)
125: {
127:   ST_SHELL       *shell = (ST_SHELL*)st->data;
128:   PetscObjectState instate,outstate;

131:   if (!shell->applytrans) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_USER,"No applytranspose() routine provided to Shell ST");
132:   PetscObjectStateGet((PetscObject)y,&instate);
133:   PetscStackCall("STSHELL user function applytrans()",(*shell->applytrans)(st,x,y);CHKERRQ(ierr));
134:   PetscObjectStateGet((PetscObject)y,&outstate);
135:   if (instate == outstate) {
136:     /* user forgot to increase the state of the output vector */
137:     PetscObjectStateIncrease((PetscObject)y);
138:   }
139:   return(0);
140: }

144: PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
145: {
147:   ST_SHELL       *shell = (ST_SHELL*)st->data;

150:   if (shell->backtransform) PetscStackCall("STSHELL user function backtransform()",(*shell->backtransform)(st,n,eigr,eigi);CHKERRQ(ierr));
151:   return(0);
152: }

156: PetscErrorCode STDestroy_Shell(ST st)
157: {

161:   PetscFree(st->data);
162:   PetscObjectComposeFunction((PetscObject)st,"STShellSetApply_C",NULL);
163:   PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyTranspose_C",NULL);
164:   PetscObjectComposeFunction((PetscObject)st,"STShellSetBackTransform_C",NULL);
165:   return(0);
166: }

170: static PetscErrorCode STShellSetApply_Shell(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
171: {
172:   ST_SHELL *shell = (ST_SHELL*)st->data;

175:   shell->apply = apply;
176:   return(0);
177: }

181: static PetscErrorCode STShellSetApplyTranspose_Shell(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
182: {
183:   ST_SHELL *shell = (ST_SHELL*)st->data;

186:   shell->applytrans = applytrans;
187:   return(0);
188: }

192: static PetscErrorCode STShellSetBackTransform_Shell(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
193: {
194:   ST_SHELL *shell = (ST_SHELL*)st->data;

197:   shell->backtransform = backtr;
198:   return(0);
199: }

203: /*@C
204:    STShellSetApply - Sets routine to use as the application of the
205:    operator to a vector in the user-defined spectral transformation.

207:    Logically Collective on ST

209:    Input Parameters:
210: +  st    - the spectral transformation context
211: -  apply - the application-provided transformation routine

213:    Calling sequence of apply:
214: $   apply(ST st,Vec xin,Vec xout)

216: +  st   - the spectral transformation context
217: .  xin  - input vector
218: -  xout - output vector

220:    Level: advanced

222: .seealso: STShellSetBackTransform(), STShellSetApplyTranspose()
223: @*/
224: PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
225: {

230:   PetscTryMethod(st,"STShellSetApply_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,apply));
231:   return(0);
232: }

236: /*@C
237:    STShellSetApplyTranspose - Sets routine to use as the application of the
238:    transposed operator to a vector in the user-defined spectral transformation.

240:    Logically Collective on ST

242:    Input Parameters:
243: +  st    - the spectral transformation context
244: -  applytrans - the application-provided transformation routine

246:    Calling sequence of applytrans:
247: $   applytrans(ST st,Vec xin,Vec xout)

249: +  st   - the spectral transformation context
250: .  xin  - input vector
251: -  xout - output vector

253:    Level: advanced

255: .seealso: STShellSetApply(), STShellSetBackTransform()
256: @*/
257: PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
258: {

263:   PetscTryMethod(st,"STShellSetApplyTranspose_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,applytrans));
264:   return(0);
265: }

269: /*@C
270:    STShellSetBackTransform - Sets the routine to be called after the
271:    eigensolution process has finished in order to transform back the
272:    computed eigenvalues.

274:    Logically Collective on ST

276:    Input Parameters:
277: +  st     - the spectral transformation context
278: -  backtr - the application-provided backtransform routine

280:    Calling sequence of backtr:
281: $   backtr(ST st,PetscScalar *eigr,PetscScalar *eigi)

283: +  st   - the spectral transformation context
284: .  eigr - pointer ot the real part of the eigenvalue to transform back
285: -  eigi - pointer ot the imaginary part

287:    Level: advanced

289: .seealso: STShellSetApply(), STShellSetApplyTranspose()
290: @*/
291: PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
292: {

297:   PetscTryMethod(st,"STShellSetBackTransform_C",(ST,PetscErrorCode (*)(ST,PetscInt,PetscScalar*,PetscScalar*)),(st,backtr));
298:   return(0);
299: }

303: PetscErrorCode STSetFromOptions_Shell(PetscOptionItems *PetscOptionsObject,ST st)
304: {
306:   PC             pc;
307:   PCType         pctype;
308:   KSPType        ksptype;

311:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
312:   KSPGetPC(st->ksp,&pc);
313:   KSPGetType(st->ksp,&ksptype);
314:   PCGetType(pc,&pctype);
315:   if (!pctype && !ksptype) {
316:     if (st->shift_matrix == ST_MATMODE_SHELL) {
317:       /* in shell mode use GMRES with Jacobi as the default */
318:       KSPSetType(st->ksp,KSPGMRES);
319:       PCSetType(pc,PCJACOBI);
320:     } else {
321:       /* use direct solver as default */
322:       KSPSetType(st->ksp,KSPPREONLY);
323:       PCSetType(pc,PCLU);
324:     }
325:   }
326:   return(0);
327: }

329: /*MC
330:    STSHELL - Creates a new spectral transformation class.
331:           This is intended to provide a simple class to use with EPS.
332:           You should not use this if you plan to make a complete class.

334:   Level: advanced

336:   Usage:
337: $             PetscErrorCode (*apply)(void*,Vec,Vec);
338: $             PetscErrorCode (*applytrans)(void*,Vec,Vec);
339: $             PetscErrorCode (*backtr)(void*,PetscScalar*,PetscScalar*);
340: $             STCreate(comm,&st);
341: $             STSetType(st,STSHELL);
342: $             STShellSetApply(st,apply);
343: $             STShellSetApplyTranspose(st,applytrans);
344: $             STShellSetBackTransform(st,backtr);    (optional)

346: M*/

350: PETSC_EXTERN PetscErrorCode STCreate_Shell(ST st)
351: {
353:   ST_SHELL       *ctx;

356:   PetscNewLog(st,&ctx);
357:   st->data = (void*)ctx;

359:   st->ops->apply          = STApply_Shell;
360:   st->ops->applytrans     = STApplyTranspose_Shell;
361:   st->ops->backtransform  = STBackTransform_Shell;
362:   st->ops->setfromoptions = STSetFromOptions_Shell;
363:   st->ops->destroy        = STDestroy_Shell;
364:   PetscObjectComposeFunction((PetscObject)st,"STShellSetApply_C",STShellSetApply_Shell);
365:   PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyTranspose_C",STShellSetApplyTranspose_Shell);
366:   PetscObjectComposeFunction((PetscObject)st,"STShellSetBackTransform_C",STShellSetBackTransform_Shell);
367:   return(0);
368: }

slepc-3.7.4/src/sys/classes/st/impls/shell/makefile0000644000175000017500000000216613107004621021613 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = shell.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = ST LOCDIR = src/sys/classes/st/impls/shell/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/shell/shell.c0000644000175000017500000002710213107004621021363 0ustar jromanjroman/* This provides a simple shell interface for programmers to create their own spectral transformations without writing much interface code. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcst.h" I*/ typedef struct { void *ctx; /* user provided context */ PetscErrorCode (*apply)(ST,Vec,Vec); PetscErrorCode (*applytrans)(ST,Vec,Vec); PetscErrorCode (*backtransform)(ST,PetscInt n,PetscScalar*,PetscScalar*); } ST_SHELL; #undef __FUNCT__ #define __FUNCT__ "STShellGetContext" /*@C STShellGetContext - Returns the user-provided context associated with a shell ST Not Collective Input Parameter: . st - spectral transformation context Output Parameter: . ctx - the user provided context Level: advanced Notes: This routine is intended for use within various shell routines .seealso: STShellSetContext() @*/ PetscErrorCode STShellGetContext(ST st,void **ctx) { PetscErrorCode ierr; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); PetscValidPointer(ctx,2); ierr = PetscObjectTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr); if (!flg) *ctx = 0; else *ctx = ((ST_SHELL*)(st->data))->ctx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STShellSetContext" /*@ STShellSetContext - Sets the context for a shell ST Logically Collective on ST Input Parameters: + st - the shell ST - ctx - the context Level: advanced Fortran Notes: To use this from Fortran you must write a Fortran interface definition for this function that tells Fortran the Fortran derived data type that you are passing in as the ctx argument. .seealso: STShellGetContext() @*/ PetscErrorCode STShellSetContext(ST st,void *ctx) { ST_SHELL *shell = (ST_SHELL*)st->data; PetscErrorCode ierr; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); ierr = PetscObjectTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr); if (flg) shell->ctx = ctx; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STApply_Shell" PetscErrorCode STApply_Shell(ST st,Vec x,Vec y) { PetscErrorCode ierr; ST_SHELL *shell = (ST_SHELL*)st->data; PetscObjectState instate,outstate; PetscFunctionBegin; if (!shell->apply) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_USER,"No apply() routine provided to Shell ST"); ierr = PetscObjectStateGet((PetscObject)y,&instate);CHKERRQ(ierr); PetscStackCall("STSHELL user function apply()",ierr = (*shell->apply)(st,x,y);CHKERRQ(ierr)); ierr = PetscObjectStateGet((PetscObject)y,&outstate);CHKERRQ(ierr); if (instate == outstate) { /* user forgot to increase the state of the output vector */ ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STApplyTranspose_Shell" PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y) { PetscErrorCode ierr; ST_SHELL *shell = (ST_SHELL*)st->data; PetscObjectState instate,outstate; PetscFunctionBegin; if (!shell->applytrans) SETERRQ(PetscObjectComm((PetscObject)st),PETSC_ERR_USER,"No applytranspose() routine provided to Shell ST"); ierr = PetscObjectStateGet((PetscObject)y,&instate);CHKERRQ(ierr); PetscStackCall("STSHELL user function applytrans()",ierr = (*shell->applytrans)(st,x,y);CHKERRQ(ierr)); ierr = PetscObjectStateGet((PetscObject)y,&outstate);CHKERRQ(ierr); if (instate == outstate) { /* user forgot to increase the state of the output vector */ ierr = PetscObjectStateIncrease((PetscObject)y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STBackTransform_Shell" PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) { PetscErrorCode ierr; ST_SHELL *shell = (ST_SHELL*)st->data; PetscFunctionBegin; if (shell->backtransform) PetscStackCall("STSHELL user function backtransform()",ierr = (*shell->backtransform)(st,n,eigr,eigi);CHKERRQ(ierr)); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STDestroy_Shell" PetscErrorCode STDestroy_Shell(ST st) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(st->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STShellSetApply_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyTranspose_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STShellSetBackTransform_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STShellSetApply_Shell" static PetscErrorCode STShellSetApply_Shell(ST st,PetscErrorCode (*apply)(ST,Vec,Vec)) { ST_SHELL *shell = (ST_SHELL*)st->data; PetscFunctionBegin; shell->apply = apply; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STShellSetApplyTranspose_Shell" static PetscErrorCode STShellSetApplyTranspose_Shell(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec)) { ST_SHELL *shell = (ST_SHELL*)st->data; PetscFunctionBegin; shell->applytrans = applytrans; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STShellSetBackTransform_Shell" static PetscErrorCode STShellSetBackTransform_Shell(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*)) { ST_SHELL *shell = (ST_SHELL*)st->data; PetscFunctionBegin; shell->backtransform = backtr; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STShellSetApply" /*@C STShellSetApply - Sets routine to use as the application of the operator to a vector in the user-defined spectral transformation. Logically Collective on ST Input Parameters: + st - the spectral transformation context - apply - the application-provided transformation routine Calling sequence of apply: $ apply(ST st,Vec xin,Vec xout) + st - the spectral transformation context . xin - input vector - xout - output vector Level: advanced .seealso: STShellSetBackTransform(), STShellSetApplyTranspose() @*/ PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); ierr = PetscTryMethod(st,"STShellSetApply_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,apply));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STShellSetApplyTranspose" /*@C STShellSetApplyTranspose - Sets routine to use as the application of the transposed operator to a vector in the user-defined spectral transformation. Logically Collective on ST Input Parameters: + st - the spectral transformation context - applytrans - the application-provided transformation routine Calling sequence of applytrans: $ applytrans(ST st,Vec xin,Vec xout) + st - the spectral transformation context . xin - input vector - xout - output vector Level: advanced .seealso: STShellSetApply(), STShellSetBackTransform() @*/ PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); ierr = PetscTryMethod(st,"STShellSetApplyTranspose_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,applytrans));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STShellSetBackTransform" /*@C STShellSetBackTransform - Sets the routine to be called after the eigensolution process has finished in order to transform back the computed eigenvalues. Logically Collective on ST Input Parameters: + st - the spectral transformation context - backtr - the application-provided backtransform routine Calling sequence of backtr: $ backtr(ST st,PetscScalar *eigr,PetscScalar *eigi) + st - the spectral transformation context . eigr - pointer ot the real part of the eigenvalue to transform back - eigi - pointer ot the imaginary part Level: advanced .seealso: STShellSetApply(), STShellSetApplyTranspose() @*/ PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(st,ST_CLASSID,1); ierr = PetscTryMethod(st,"STShellSetBackTransform_C",(ST,PetscErrorCode (*)(ST,PetscInt,PetscScalar*,PetscScalar*)),(st,backtr));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetFromOptions_Shell" PetscErrorCode STSetFromOptions_Shell(PetscOptionItems *PetscOptionsObject,ST st) { PetscErrorCode ierr; PC pc; PCType pctype; KSPType ksptype; PetscFunctionBegin; if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = KSPGetType(st->ksp,&ksptype);CHKERRQ(ierr); ierr = PCGetType(pc,&pctype);CHKERRQ(ierr); if (!pctype && !ksptype) { if (st->shift_matrix == ST_MATMODE_SHELL) { /* in shell mode use GMRES with Jacobi as the default */ ierr = KSPSetType(st->ksp,KSPGMRES);CHKERRQ(ierr); ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr); } else { /* use direct solver as default */ ierr = KSPSetType(st->ksp,KSPPREONLY);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); } } PetscFunctionReturn(0); } /*MC STSHELL - Creates a new spectral transformation class. This is intended to provide a simple class to use with EPS. You should not use this if you plan to make a complete class. Level: advanced Usage: $ PetscErrorCode (*apply)(void*,Vec,Vec); $ PetscErrorCode (*applytrans)(void*,Vec,Vec); $ PetscErrorCode (*backtr)(void*,PetscScalar*,PetscScalar*); $ STCreate(comm,&st); $ STSetType(st,STSHELL); $ STShellSetApply(st,apply); $ STShellSetApplyTranspose(st,applytrans); $ STShellSetBackTransform(st,backtr); (optional) M*/ #undef __FUNCT__ #define __FUNCT__ "STCreate_Shell" PETSC_EXTERN PetscErrorCode STCreate_Shell(ST st) { PetscErrorCode ierr; ST_SHELL *ctx; PetscFunctionBegin; ierr = PetscNewLog(st,&ctx);CHKERRQ(ierr); st->data = (void*)ctx; st->ops->apply = STApply_Shell; st->ops->applytrans = STApplyTranspose_Shell; st->ops->backtransform = STBackTransform_Shell; st->ops->setfromoptions = STSetFromOptions_Shell; st->ops->destroy = STDestroy_Shell; ierr = PetscObjectComposeFunction((PetscObject)st,"STShellSetApply_C",STShellSetApply_Shell);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyTranspose_C",STShellSetApplyTranspose_Shell);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)st,"STShellSetBackTransform_C",STShellSetBackTransform_Shell);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/impls/shell/makefile.html0000644000175000017500000000471113107004621022554 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = shell.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = ST
LOCDIR   = src/sys/classes/st/impls/shell/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/impls/shell/index.html0000644000175000017500000000371013107004621022104 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

shell.c
makefile
slepc-3.7.4/src/sys/classes/st/impls/shell/ftn-auto/0000755000175000017500000000000013107004621021643 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/shell/ftn-auto/makefile0000644000175000017500000000037213107004621023345 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = shellf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/st/impls/shell/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/shell/ftn-auto/shellf.c0000644000175000017500000000210213107004621023257 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* shell.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcst.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define stshellsetcontext_ STSHELLSETCONTEXT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define stshellsetcontext_ stshellsetcontext #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL stshellsetcontext_(ST st,void*ctx, int *__ierr ){ *__ierr = STShellSetContext( (ST)PetscToPointer((st) ),ctx); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/st/impls/shell/ftn-custom/0000755000175000017500000000000013107004621022205 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/shell/ftn-custom/makefile0000644000175000017500000000222713107004621023710 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zshell.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/st/impls/shell/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/shell/ftn-custom/zshell.c0000644000175000017500000000725013107004621023656 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define stshellgetcontext_ STSHELLGETCONTEXT #define stshellsetapply_ STSHELLSETAPPLY #define stshellsetapplytranspose_ STSHELLSETAPPLYTRANSPOSE #define stshellsetbacktransform_ STSHELLSETBACKTRANSFORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define stshellgetcontext_ stshellgetcontext #define stshellsetapply_ stshellsetapply #define stshellsetapplytranspose_ stshellsetapplytranspose #define stshellsetbacktransform_ stshellsetbacktransform #endif static struct { PetscFortranCallbackId apply; PetscFortranCallbackId applytranspose; PetscFortranCallbackId backtransform; } _cb; /* These are not extern C because they are passed into non-extern C user level functions */ #undef __FUNCT__ #define __FUNCT__ "ourshellapply" static PetscErrorCode ourshellapply(ST st,Vec x,Vec y) { PetscObjectUseFortranCallback(st,_cb.apply,(ST*,Vec*,Vec*,PetscErrorCode*),(&st,&x,&y,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourshellapplytranspose" static PetscErrorCode ourshellapplytranspose(ST st,Vec x,Vec y) { PetscObjectUseFortranCallback(st,_cb.applytranspose,(ST*,Vec*,Vec*,PetscErrorCode*),(&st,&x,&y,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourshellbacktransform" static PetscErrorCode ourshellbacktransform(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) { PetscObjectUseFortranCallback(st,_cb.backtransform,(ST*,PetscInt*,PetscScalar*,PetscScalar*,PetscErrorCode*),(&st,&n,eigr,eigi,&ierr)); } PETSC_EXTERN void PETSC_STDCALL stshellgetcontext_(ST *st,void **ctx,PetscErrorCode *ierr) { *ierr = STShellGetContext(*st,ctx); } PETSC_EXTERN void PETSC_STDCALL stshellsetapply_(ST *st,void (PETSC_STDCALL *apply)(void*,Vec*,Vec*,PetscErrorCode*),PetscErrorCode *ierr) { *ierr = PetscObjectSetFortranCallback((PetscObject)*st,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.apply,(PetscVoidFunction)apply,NULL); if (*ierr) return; *ierr = STShellSetApply(*st,ourshellapply); } PETSC_EXTERN void PETSC_STDCALL stshellsetapplytranspose_(ST *st,void (PETSC_STDCALL *applytranspose)(void*,Vec*,Vec*,PetscErrorCode*),PetscErrorCode *ierr) { *ierr = PetscObjectSetFortranCallback((PetscObject)*st,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.applytranspose,(PetscVoidFunction)applytranspose,NULL); if (*ierr) return; *ierr = STShellSetApplyTranspose(*st,ourshellapplytranspose); } PETSC_EXTERN void PETSC_STDCALL stshellsetbacktransform_(ST *st,void (PETSC_STDCALL *backtransform)(void*,PetscScalar*,PetscScalar*,PetscErrorCode*),PetscErrorCode *ierr) { *ierr = PetscObjectSetFortranCallback((PetscObject)*st,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.backtransform,(PetscVoidFunction)backtransform,NULL); if (*ierr) return; *ierr = STShellSetBackTransform(*st,ourshellbacktransform); } slepc-3.7.4/src/sys/classes/st/impls/shift/0000755000175000017500000000000013107004621020114 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/shift/makefile0000644000175000017500000000216613107004621021621 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = shift.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = ST LOCDIR = src/sys/classes/st/impls/shift/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/shift/makefile.html0000644000175000017500000000471113107004621022562 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = shift.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = ST
LOCDIR   = src/sys/classes/st/impls/shift/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/impls/shift/shift.c0000644000175000017500000001524013107004621021377 0ustar jromanjroman/* Shift spectral transformation, applies (A + sigma I) as operator, or inv(B)(A + sigma B) for generalized problems - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #undef __FUNCT__ #define __FUNCT__ "STApply_Shift" PetscErrorCode STApply_Shift(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; if (st->nmat>1) { /* generalized eigenproblem: y = B^-1 (A - sB) x */ ierr = MatMult(st->T[0],x,st->w);CHKERRQ(ierr); ierr = STMatSolve(st,st->w,y);CHKERRQ(ierr); } else { /* standard eigenproblem: y = (A - sI) x */ ierr = MatMult(st->T[0],x,y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STApplyTranspose_Shift" PetscErrorCode STApplyTranspose_Shift(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; if (st->nmat>1) { /* generalized eigenproblem: y = (A - sB)^T B^-T x */ ierr = STMatSolveTranspose(st,x,st->w);CHKERRQ(ierr); ierr = MatMultTranspose(st->T[0],st->w,y);CHKERRQ(ierr); } else { /* standard eigenproblem: y = (A^T - sI) x */ ierr = MatMultTranspose(st->T[0],x,y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STBackTransform_Shift" PetscErrorCode STBackTransform_Shift(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) { PetscInt j; PetscFunctionBegin; for (j=0;jsigma; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPostSolve_Shift" PetscErrorCode STPostSolve_Shift(ST st) { PetscErrorCode ierr; PetscFunctionBegin; if (st->shift_matrix == ST_MATMODE_INPLACE) { if (st->nmat>1) { ierr = MatAXPY(st->A[0],st->sigma,st->A[1],st->str);CHKERRQ(ierr); } else { ierr = MatShift(st->A[0],st->sigma);CHKERRQ(ierr); } st->Astate[0] = ((PetscObject)st->A[0])->state; st->state = ST_STATE_INITIAL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetUp_Shift" PetscErrorCode STSetUp_Shift(ST st) { PetscErrorCode ierr; PetscInt k,nc,nmat=PetscMax(st->nmat,2); PetscScalar *coeffs=NULL; PetscFunctionBegin; if (st->nmat>1) { ierr = ST_AllocateWorkVec(st);CHKERRQ(ierr); } if (nmat<3 || st->transform) { if (nmat>2) { nc = (nmat*(nmat+1))/2; ierr = PetscMalloc1(nc,&coeffs);CHKERRQ(ierr); /* Compute coeffs */ ierr = STCoeffs_Monomial(st,coeffs);CHKERRQ(ierr); } /* T[n] = A_n */ k = nmat-1; ierr = PetscObjectReference((PetscObject)st->A[k]);CHKERRQ(ierr); ierr = MatDestroy(&st->T[k]);CHKERRQ(ierr); st->T[k] = st->A[k]; for (k=0;k2?st->sigma:-st->sigma,0.0,k,coeffs?coeffs+((nmat-k)*(nmat-k-1))/2:NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[k]);CHKERRQ(ierr); } if (nmat>2) { ierr = PetscFree(coeffs);CHKERRQ(ierr); } } else { for (k=0;kA[k]);CHKERRQ(ierr); ierr = MatDestroy(&st->T[k]);CHKERRQ(ierr); st->T[k] = st->A[k]; } } if (nmat>=2 && st->transform) { ierr = PetscObjectReference((PetscObject)st->T[nmat-1]);CHKERRQ(ierr); ierr = MatDestroy(&st->P);CHKERRQ(ierr); st->P = st->T[nmat-1]; } if (st->P) { if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = STCheckFactorPackage(st);CHKERRQ(ierr); ierr = KSPSetOperators(st->ksp,st->P,st->P);CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);CHKERRQ(ierr); ierr = KSPSetUp(st->ksp);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetShift_Shift" PetscErrorCode STSetShift_Shift(ST st,PetscScalar newshift) { PetscErrorCode ierr; PetscInt k,nc,nmat=PetscMax(st->nmat,2); PetscScalar *coeffs=NULL; PetscFunctionBegin; if (st->transform) { if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) { nc = (nmat*(nmat+1))/2; ierr = PetscMalloc1(nc,&coeffs);CHKERRQ(ierr); /* Compute coeffs */ ierr = STCoeffs_Monomial(st,coeffs);CHKERRQ(ierr); } for (k=0;k2?newshift:-newshift,nmat>2?st->sigma:-st->sigma,k,coeffs?coeffs+((nmat-k)*(nmat-k-1))/2:NULL,PETSC_FALSE,&st->T[k]);CHKERRQ(ierr); } if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) { ierr = PetscFree(coeffs);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetFromOptions_Shift" PetscErrorCode STSetFromOptions_Shift(PetscOptionItems *PetscOptionsObject,ST st) { PetscErrorCode ierr; PC pc; PCType pctype; KSPType ksptype; PetscFunctionBegin; if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = KSPGetType(st->ksp,&ksptype);CHKERRQ(ierr); ierr = PCGetType(pc,&pctype);CHKERRQ(ierr); if (!pctype && !ksptype) { if (st->shift_matrix == ST_MATMODE_SHELL) { /* in shell mode use GMRES with Jacobi as the default */ ierr = KSPSetType(st->ksp,KSPGMRES);CHKERRQ(ierr); ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr); } else { /* use direct solver as default */ ierr = KSPSetType(st->ksp,KSPPREONLY);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCreate_Shift" PETSC_EXTERN PetscErrorCode STCreate_Shift(ST st) { PetscFunctionBegin; st->ops->apply = STApply_Shift; st->ops->getbilinearform = STGetBilinearForm_Default; st->ops->applytrans = STApplyTranspose_Shift; st->ops->postsolve = STPostSolve_Shift; st->ops->backtransform = STBackTransform_Shift; st->ops->setfromoptions = STSetFromOptions_Shift; st->ops->setup = STSetUp_Shift; st->ops->setshift = STSetShift_Shift; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/st/impls/shift/index.html0000644000175000017500000000371013107004621022112 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

shift.c
makefile
slepc-3.7.4/src/sys/classes/st/impls/shift/shift.c.html0000644000175000017500000003310313107004621022340 0ustar jromanjroman

Actual source code: shift.c

slepc-3.7.4 2017-05-17
  1: /*
  2:     Shift spectral transformation, applies (A + sigma I) as operator, or
  3:     inv(B)(A + sigma B) for generalized problems

  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: */

 25: #include <slepc/private/stimpl.h>

 29: PetscErrorCode STApply_Shift(ST st,Vec x,Vec y)
 30: {

 34:   if (st->nmat>1) {
 35:     /* generalized eigenproblem: y = B^-1 (A - sB) x */
 36:     MatMult(st->T[0],x,st->w);
 37:     STMatSolve(st,st->w,y);
 38:   } else {
 39:     /* standard eigenproblem: y = (A - sI) x */
 40:     MatMult(st->T[0],x,y);
 41:   }
 42:   return(0);
 43: }

 47: PetscErrorCode STApplyTranspose_Shift(ST st,Vec x,Vec y)
 48: {

 52:   if (st->nmat>1) {
 53:     /* generalized eigenproblem: y = (A - sB)^T B^-T  x */
 54:     STMatSolveTranspose(st,x,st->w);
 55:     MatMultTranspose(st->T[0],st->w,y);
 56:   } else {
 57:     /* standard eigenproblem: y = (A^T - sI) x */
 58:     MatMultTranspose(st->T[0],x,y);
 59:   }
 60:   return(0);
 61: }

 65: PetscErrorCode STBackTransform_Shift(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
 66: {
 67:   PetscInt j;

 70:   for (j=0;j<n;j++) {
 71:     eigr[j] += st->sigma;
 72:   }
 73:   return(0);
 74: }

 78: PetscErrorCode STPostSolve_Shift(ST st)
 79: {

 83:   if (st->shift_matrix == ST_MATMODE_INPLACE) {
 84:     if (st->nmat>1) {
 85:       MatAXPY(st->A[0],st->sigma,st->A[1],st->str);
 86:     } else {
 87:       MatShift(st->A[0],st->sigma);
 88:     }
 89:     st->Astate[0] = ((PetscObject)st->A[0])->state;
 90:     st->state = ST_STATE_INITIAL;
 91:   }
 92:   return(0);
 93: }

 97: PetscErrorCode STSetUp_Shift(ST st)
 98: {
100:   PetscInt       k,nc,nmat=PetscMax(st->nmat,2);
101:   PetscScalar    *coeffs=NULL;

104:   if (st->nmat>1) {
105:     ST_AllocateWorkVec(st);
106:   }
107:   if (nmat<3 || st->transform) {
108:     if (nmat>2) {
109:       nc = (nmat*(nmat+1))/2;
110:       PetscMalloc1(nc,&coeffs);
111:       /* Compute coeffs */
112:       STCoeffs_Monomial(st,coeffs);
113:     }
114:     /* T[n] = A_n */
115:     k = nmat-1;
116:     PetscObjectReference((PetscObject)st->A[k]);
117:     MatDestroy(&st->T[k]);
118:     st->T[k] = st->A[k];
119:     for (k=0;k<nmat-1;k++) {
120:       STMatMAXPY_Private(st,nmat>2?st->sigma:-st->sigma,0.0,k,coeffs?coeffs+((nmat-k)*(nmat-k-1))/2:NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[k]);
121:     }
122:      if (nmat>2) { PetscFree(coeffs); }
123:   } else {
124:     for (k=0;k<nmat;k++) {
125:       PetscObjectReference((PetscObject)st->A[k]);
126:       MatDestroy(&st->T[k]);
127:       st->T[k] = st->A[k];
128:     }
129:   }
130:   if (nmat>=2 && st->transform) {
131:     PetscObjectReference((PetscObject)st->T[nmat-1]);
132:     MatDestroy(&st->P);
133:     st->P = st->T[nmat-1];
134:   }
135:   if (st->P) {
136:     if (!st->ksp) { STGetKSP(st,&st->ksp); }
137:     STCheckFactorPackage(st);
138:     KSPSetOperators(st->ksp,st->P,st->P);
139:     KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);
140:     KSPSetUp(st->ksp);
141:   }
142:   return(0);
143: }

147: PetscErrorCode STSetShift_Shift(ST st,PetscScalar newshift)
148: {
150:   PetscInt       k,nc,nmat=PetscMax(st->nmat,2);
151:   PetscScalar    *coeffs=NULL;

154:   if (st->transform) {
155:     if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) {
156:       nc = (nmat*(nmat+1))/2;
157:       PetscMalloc1(nc,&coeffs);
158:       /* Compute coeffs */
159:       STCoeffs_Monomial(st,coeffs);
160:     }
161:     for (k=0;k<nmat-1;k++) {
162:       STMatMAXPY_Private(st,nmat>2?newshift:-newshift,nmat>2?st->sigma:-st->sigma,k,coeffs?coeffs+((nmat-k)*(nmat-k-1))/2:NULL,PETSC_FALSE,&st->T[k]);
163:     }
164:     if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) {
165:         PetscFree(coeffs);
166:     }
167:   }
168:   return(0);
169: }

173: PetscErrorCode STSetFromOptions_Shift(PetscOptionItems *PetscOptionsObject,ST st)
174: {
176:   PC             pc;
177:   PCType         pctype;
178:   KSPType        ksptype;

181:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
182:   KSPGetPC(st->ksp,&pc);
183:   KSPGetType(st->ksp,&ksptype);
184:   PCGetType(pc,&pctype);
185:   if (!pctype && !ksptype) {
186:     if (st->shift_matrix == ST_MATMODE_SHELL) {
187:       /* in shell mode use GMRES with Jacobi as the default */
188:       KSPSetType(st->ksp,KSPGMRES);
189:       PCSetType(pc,PCJACOBI);
190:     } else {
191:       /* use direct solver as default */
192:       KSPSetType(st->ksp,KSPPREONLY);
193:       PCSetType(pc,PCLU);
194:     }
195:   }
196:   return(0);
197: }

201: PETSC_EXTERN PetscErrorCode STCreate_Shift(ST st)
202: {
204:   st->ops->apply           = STApply_Shift;
205:   st->ops->getbilinearform = STGetBilinearForm_Default;
206:   st->ops->applytrans      = STApplyTranspose_Shift;
207:   st->ops->postsolve       = STPostSolve_Shift;
208:   st->ops->backtransform   = STBackTransform_Shift;
209:   st->ops->setfromoptions  = STSetFromOptions_Shift;
210:   st->ops->setup           = STSetUp_Shift;
211:   st->ops->setshift        = STSetShift_Shift;
212:   return(0);
213: }
slepc-3.7.4/src/sys/classes/st/impls/index.html0000644000175000017500000000407713107004621021004 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

shell/
shift/
sinvert/
cayley/
precond/
makefile
slepc-3.7.4/src/sys/classes/st/impls/sinvert/0000755000175000017500000000000013107004621020471 5ustar jromanjromanslepc-3.7.4/src/sys/classes/st/impls/sinvert/makefile0000644000175000017500000000217213107004621022173 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = sinvert.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = ST LOCDIR = src/sys/classes/st/impls/sinvert/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/st/impls/sinvert/sinvert.c.html0000644000175000017500000003700313107004621023275 0ustar jromanjroman

Actual source code: sinvert.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       Implements the shift-and-invert technique for eigenvalue problems.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/stimpl.h>

 28: PetscErrorCode STApply_Sinvert(ST st,Vec x,Vec y)
 29: {

 33:   if (st->nmat>1) {
 34:     /* generalized eigenproblem: y = (A - sB)^-1 B x */
 35:     MatMult(st->T[0],x,st->w);
 36:     STMatSolve(st,st->w,y);
 37:   } else {
 38:     /* standard eigenproblem: y = (A - sI)^-1 x */
 39:     STMatSolve(st,x,y);
 40:   }
 41:   return(0);
 42: }

 46: PetscErrorCode STApplyTranspose_Sinvert(ST st,Vec x,Vec y)
 47: {

 51:   if (st->nmat>1) {
 52:     /* generalized eigenproblem: y = B^T (A - sB)^-T x */
 53:     STMatSolveTranspose(st,x,st->w);
 54:     MatMultTranspose(st->T[0],st->w,y);
 55:   } else {
 56:     /* standard eigenproblem: y = (A - sI)^-T x */
 57:     STMatSolveTranspose(st,x,y);
 58:   }
 59:   return(0);
 60: }

 64: PetscErrorCode STBackTransform_Sinvert(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
 65: {
 66:   PetscInt    j;
 67: #if !defined(PETSC_USE_COMPLEX)
 68:   PetscScalar t;
 69: #endif

 72: #if !defined(PETSC_USE_COMPLEX)
 73:   for (j=0;j<n;j++) {
 74:     if (eigi[j] == 0) eigr[j] = 1.0 / eigr[j] + st->sigma;
 75:     else {
 76:       t = eigr[j] * eigr[j] + eigi[j] * eigi[j];
 77:       eigr[j] = eigr[j] / t + st->sigma;
 78:       eigi[j] = - eigi[j] / t;
 79:     }
 80:   }
 81: #else
 82:   for (j=0;j<n;j++) {
 83:     eigr[j] = 1.0 / eigr[j] + st->sigma;
 84:   }
 85: #endif
 86:   return(0);
 87: }

 91: PetscErrorCode STPostSolve_Sinvert(ST st)
 92: {

 96:   if (st->shift_matrix == ST_MATMODE_INPLACE) {
 97:     if (st->nmat>1) {
 98:       MatAXPY(st->A[0],st->sigma,st->A[1],st->str);
 99:     } else {
100:       MatShift(st->A[0],st->sigma);
101:     }
102:     st->Astate[0] = ((PetscObject)st->A[0])->state;
103:     st->state = ST_STATE_INITIAL;
104:   }
105:   return(0);
106: }

110: PetscErrorCode STSetUp_Sinvert(ST st)
111: {
113:   PetscInt       k,nc,nmat=PetscMax(st->nmat,2);
114:   PetscScalar    *coeffs=NULL;

117:   if (st->nmat>1) {
118:     ST_AllocateWorkVec(st);
119:   }
120:   /* if the user did not set the shift, use the target value */
121:   if (!st->sigma_set) st->sigma = st->defsigma;
122:   if (st->transform) {
123:     if (nmat>2) {
124:       nc = (nmat*(nmat+1))/2;
125:       PetscMalloc1(nc,&coeffs);
126:       /* Compute coeffs */
127:       STCoeffs_Monomial(st,coeffs);
128:     }
129:     /* T[0] = A_n */
130:     k = nmat-1;
131:     PetscObjectReference((PetscObject)st->A[k]);
132:     MatDestroy(&st->T[0]);
133:     st->T[0] = st->A[k];
134:     for (k=1;k<nmat;k++) {
135:       STMatMAXPY_Private(st,nmat>2?st->sigma:-st->sigma,0.0,nmat-k-1,coeffs?coeffs+(k*(k+1))/2:NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[k]);
136:     }
137:     if (nmat>2) { PetscFree(coeffs); }
138:     PetscObjectReference((PetscObject)st->T[nmat-1]);
139:     MatDestroy(&st->P);
140:     st->P = st->T[nmat-1];
141:   } else {
142:     for (k=0;k<nmat;k++) {
143:       PetscObjectReference((PetscObject)st->A[k]);
144:       MatDestroy(&st->T[k]);
145:       st->T[k] = st->A[k];
146:     }
147:   } 
148:   if (st->P) {
149:     if (!st->ksp) { STGetKSP(st,&st->ksp); }
150:     STCheckFactorPackage(st);
151:     KSPSetOperators(st->ksp,st->P,st->P);
152:     KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);
153:     KSPSetUp(st->ksp);
154:   }
155:   return(0);
156: }

160: PetscErrorCode STSetShift_Sinvert(ST st,PetscScalar newshift)
161: {
163:   PetscInt       nmat=PetscMax(st->nmat,2),k,nc;
164:   PetscScalar    *coeffs=NULL;

167:   if (st->transform) {
168:     if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) {
169:       nc = (nmat*(nmat+1))/2;
170:       PetscMalloc1(nc,&coeffs);
171:       /* Compute coeffs */
172:       STCoeffs_Monomial(st,coeffs);
173:     }
174:     for (k=1;k<nmat;k++) {
175:       STMatMAXPY_Private(st,nmat>2?newshift:-newshift,nmat>2?st->sigma:-st->sigma,nmat-k-1,coeffs?coeffs+(k*(k+1))/2:NULL,PETSC_FALSE,&st->T[k]);
176:     }
177:     if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) {
178:       PetscFree(coeffs);
179:     }
180:     if (st->P!=st->T[nmat-1]) {
181:       MatDestroy(&st->P);
182:       st->P = st->T[nmat-1];
183:       PetscObjectReference((PetscObject)st->P);
184:     }
185:   }
186:   if (st->P) {
187:     if (!st->ksp) { STGetKSP(st,&st->ksp); }
188:     KSPSetOperators(st->ksp,st->P,st->P);
189:     KSPSetUp(st->ksp);
190:   }
191:   return(0);
192: }

196: PetscErrorCode STSetFromOptions_Sinvert(PetscOptionItems *PetscOptionsObject,ST st)
197: {
199:   PC             pc;
200:   PCType         pctype;
201:   KSPType        ksptype;

204:   if (!st->ksp) { STGetKSP(st,&st->ksp); }
205:   KSPGetPC(st->ksp,&pc);
206:   KSPGetType(st->ksp,&ksptype);
207:   PCGetType(pc,&pctype);
208:   if (!pctype && !ksptype) {
209:     if (st->shift_matrix == ST_MATMODE_SHELL) {
210:       /* in shell mode use GMRES with Jacobi as the default */
211:       KSPSetType(st->ksp,KSPGMRES);
212:       PCSetType(pc,PCJACOBI);
213:     } else {
214:       /* use direct solver as default */
215:       KSPSetType(st->ksp,KSPPREONLY);
216:       PCSetType(pc,PCLU);
217:     }
218:   }
219:   return(0);
220: }

224: PETSC_EXTERN PetscErrorCode STCreate_Sinvert(ST st)
225: {
227:   st->ops->apply           = STApply_Sinvert;
228:   st->ops->getbilinearform = STGetBilinearForm_Default;
229:   st->ops->applytrans      = STApplyTranspose_Sinvert;
230:   st->ops->postsolve       = STPostSolve_Sinvert;
231:   st->ops->backtransform   = STBackTransform_Sinvert;
232:   st->ops->setup           = STSetUp_Sinvert;
233:   st->ops->setshift        = STSetShift_Sinvert;
234:   st->ops->setfromoptions  = STSetFromOptions_Sinvert;
235:   st->ops->checknullspace  = STCheckNullSpace_Default;
236:   return(0);
237: }
slepc-3.7.4/src/sys/classes/st/impls/sinvert/makefile.html0000644000175000017500000000472113107004621023140 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = sinvert.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = ST
LOCDIR   = src/sys/classes/st/impls/sinvert/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/st/impls/sinvert/index.html0000644000175000017500000000372013107004621022470 0ustar jromanjroman Spectral Transformation - ST
slepc-3.7.4 2017-05-17

Spectral Transformation - ST

The Spectral Transformation (ST) class encapsulates the functionality required for acceleration techniques based on the transformation of the spectrum. As explained in the SLEPc Users Manual, the eigensolvers implemented in EPS work by applying an operator to a set of vectors and this operator can adopt different forms. The ST object handles all the different possibilities in a uniform way, so that the solver can proceed without knowing which transformation has been selected.

The type of spectral transformation can be specified at run time (e.g., -st_type sinvert) as well as several parameters such as the value of the shift (e.g., -st_shift 1.5).

Polynomial eigensolvers in PEP also support spectral transformation, see the users guide for details.

ST objects are always related to a solver object (either EPS or PEP). Users should not create a standalone ST object. ST options can also be set directly in application codes by first extracting the ST context from the EPS context via EPSGetST() and then directly calling the ST routines (e.g., STSetType() / STSetShift()).

sinvert.c
makefile
slepc-3.7.4/src/sys/classes/st/impls/sinvert/sinvert.c0000644000175000017500000001671613107004621022342 0ustar jromanjroman/* Implements the shift-and-invert technique for eigenvalue problems. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #undef __FUNCT__ #define __FUNCT__ "STApply_Sinvert" PetscErrorCode STApply_Sinvert(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; if (st->nmat>1) { /* generalized eigenproblem: y = (A - sB)^-1 B x */ ierr = MatMult(st->T[0],x,st->w);CHKERRQ(ierr); ierr = STMatSolve(st,st->w,y);CHKERRQ(ierr); } else { /* standard eigenproblem: y = (A - sI)^-1 x */ ierr = STMatSolve(st,x,y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STApplyTranspose_Sinvert" PetscErrorCode STApplyTranspose_Sinvert(ST st,Vec x,Vec y) { PetscErrorCode ierr; PetscFunctionBegin; if (st->nmat>1) { /* generalized eigenproblem: y = B^T (A - sB)^-T x */ ierr = STMatSolveTranspose(st,x,st->w);CHKERRQ(ierr); ierr = MatMultTranspose(st->T[0],st->w,y);CHKERRQ(ierr); } else { /* standard eigenproblem: y = (A - sI)^-T x */ ierr = STMatSolveTranspose(st,x,y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STBackTransform_Sinvert" PetscErrorCode STBackTransform_Sinvert(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) { PetscInt j; #if !defined(PETSC_USE_COMPLEX) PetscScalar t; #endif PetscFunctionBegin; #if !defined(PETSC_USE_COMPLEX) for (j=0;jsigma; else { t = eigr[j] * eigr[j] + eigi[j] * eigi[j]; eigr[j] = eigr[j] / t + st->sigma; eigi[j] = - eigi[j] / t; } } #else for (j=0;jsigma; } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STPostSolve_Sinvert" PetscErrorCode STPostSolve_Sinvert(ST st) { PetscErrorCode ierr; PetscFunctionBegin; if (st->shift_matrix == ST_MATMODE_INPLACE) { if (st->nmat>1) { ierr = MatAXPY(st->A[0],st->sigma,st->A[1],st->str);CHKERRQ(ierr); } else { ierr = MatShift(st->A[0],st->sigma);CHKERRQ(ierr); } st->Astate[0] = ((PetscObject)st->A[0])->state; st->state = ST_STATE_INITIAL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetUp_Sinvert" PetscErrorCode STSetUp_Sinvert(ST st) { PetscErrorCode ierr; PetscInt k,nc,nmat=PetscMax(st->nmat,2); PetscScalar *coeffs=NULL; PetscFunctionBegin; if (st->nmat>1) { ierr = ST_AllocateWorkVec(st);CHKERRQ(ierr); } /* if the user did not set the shift, use the target value */ if (!st->sigma_set) st->sigma = st->defsigma; if (st->transform) { if (nmat>2) { nc = (nmat*(nmat+1))/2; ierr = PetscMalloc1(nc,&coeffs);CHKERRQ(ierr); /* Compute coeffs */ ierr = STCoeffs_Monomial(st,coeffs);CHKERRQ(ierr); } /* T[0] = A_n */ k = nmat-1; ierr = PetscObjectReference((PetscObject)st->A[k]);CHKERRQ(ierr); ierr = MatDestroy(&st->T[0]);CHKERRQ(ierr); st->T[0] = st->A[k]; for (k=1;k2?st->sigma:-st->sigma,0.0,nmat-k-1,coeffs?coeffs+(k*(k+1))/2:NULL,PetscNot(st->state==ST_STATE_UPDATED),&st->T[k]);CHKERRQ(ierr); } if (nmat>2) { ierr = PetscFree(coeffs);CHKERRQ(ierr); } ierr = PetscObjectReference((PetscObject)st->T[nmat-1]);CHKERRQ(ierr); ierr = MatDestroy(&st->P);CHKERRQ(ierr); st->P = st->T[nmat-1]; } else { for (k=0;kA[k]);CHKERRQ(ierr); ierr = MatDestroy(&st->T[k]);CHKERRQ(ierr); st->T[k] = st->A[k]; } } if (st->P) { if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = STCheckFactorPackage(st);CHKERRQ(ierr); ierr = KSPSetOperators(st->ksp,st->P,st->P);CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(st->ksp,PETSC_TRUE);CHKERRQ(ierr); ierr = KSPSetUp(st->ksp);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetShift_Sinvert" PetscErrorCode STSetShift_Sinvert(ST st,PetscScalar newshift) { PetscErrorCode ierr; PetscInt nmat=PetscMax(st->nmat,2),k,nc; PetscScalar *coeffs=NULL; PetscFunctionBegin; if (st->transform) { if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) { nc = (nmat*(nmat+1))/2; ierr = PetscMalloc1(nc,&coeffs);CHKERRQ(ierr); /* Compute coeffs */ ierr = STCoeffs_Monomial(st,coeffs);CHKERRQ(ierr); } for (k=1;k2?newshift:-newshift,nmat>2?st->sigma:-st->sigma,nmat-k-1,coeffs?coeffs+(k*(k+1))/2:NULL,PETSC_FALSE,&st->T[k]);CHKERRQ(ierr); } if (st->shift_matrix == ST_MATMODE_COPY && nmat>2) { ierr = PetscFree(coeffs);CHKERRQ(ierr); } if (st->P!=st->T[nmat-1]) { ierr = MatDestroy(&st->P);CHKERRQ(ierr); st->P = st->T[nmat-1]; ierr = PetscObjectReference((PetscObject)st->P);CHKERRQ(ierr); } } if (st->P) { if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPSetOperators(st->ksp,st->P,st->P);CHKERRQ(ierr); ierr = KSPSetUp(st->ksp);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STSetFromOptions_Sinvert" PetscErrorCode STSetFromOptions_Sinvert(PetscOptionItems *PetscOptionsObject,ST st) { PetscErrorCode ierr; PC pc; PCType pctype; KSPType ksptype; PetscFunctionBegin; if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); } ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr); ierr = KSPGetType(st->ksp,&ksptype);CHKERRQ(ierr); ierr = PCGetType(pc,&pctype);CHKERRQ(ierr); if (!pctype && !ksptype) { if (st->shift_matrix == ST_MATMODE_SHELL) { /* in shell mode use GMRES with Jacobi as the default */ ierr = KSPSetType(st->ksp,KSPGMRES);CHKERRQ(ierr); ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr); } else { /* use direct solver as default */ ierr = KSPSetType(st->ksp,KSPPREONLY);CHKERRQ(ierr); ierr = PCSetType(pc,PCLU);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "STCreate_Sinvert" PETSC_EXTERN PetscErrorCode STCreate_Sinvert(ST st) { PetscFunctionBegin; st->ops->apply = STApply_Sinvert; st->ops->getbilinearform = STGetBilinearForm_Default; st->ops->applytrans = STApplyTranspose_Sinvert; st->ops->postsolve = STPostSolve_Sinvert; st->ops->backtransform = STBackTransform_Sinvert; st->ops->setup = STSetUp_Sinvert; st->ops->setshift = STSetShift_Sinvert; st->ops->setfromoptions = STSetFromOptions_Sinvert; st->ops->checknullspace = STCheckNullSpace_Default; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/0000755000175000017500000000000013107004621015630 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/makefile0000644000175000017500000000220013107004621017322 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../../../include/slepc/private/fnimpl.h ../../../../include/slepcfn.h DIRS = interface impls examples LOCDIR = src/sys/classes/fn/ MANSEC = FN include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/interface/0000755000175000017500000000000013107004621017570 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/interface/makefile0000644000175000017500000000217613107004621021276 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fnbasic.c fnregis.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/interface/fnbasic.c0000644000175000017500000007026613107004621021354 0ustar jromanjroman/* Basic routines - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #include PetscFunctionList FNList = 0; PetscBool FNRegisterAllCalled = PETSC_FALSE; PetscClassId FN_CLASSID = 0; PetscLogEvent FN_Evaluate = 0; static PetscBool FNPackageInitialized = PETSC_FALSE; #undef __FUNCT__ #define __FUNCT__ "FNFinalizePackage" /*@C FNFinalizePackage - This function destroys everything in the Slepc interface to the FN package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode FNFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&FNList);CHKERRQ(ierr); FNPackageInitialized = PETSC_FALSE; FNRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNInitializePackage" /*@C FNInitializePackage - This function initializes everything in the FN package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to FNCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode FNInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (FNPackageInitialized) PetscFunctionReturn(0); FNPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("Math Function",&FN_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = FNRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("FNEvaluate",FN_CLASSID,&FN_Evaluate);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"fn",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(FN_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"fn",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(FN_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(FNFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate" /*@ FNCreate - Creates an FN context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . newfn - location to put the FN context Level: beginner .seealso: FNDestroy(), FN @*/ PetscErrorCode FNCreate(MPI_Comm comm,FN *newfn) { FN fn; PetscErrorCode ierr; PetscFunctionBegin; PetscValidPointer(newfn,2); *newfn = 0; ierr = FNInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(fn,FN_CLASSID,"FN","Math Function","FN",comm,FNDestroy,FNView);CHKERRQ(ierr); fn->alpha = 1.0; fn->beta = 1.0; fn->nw = 0; fn->cw = 0; fn->data = NULL; *newfn = fn; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNSetOptionsPrefix" /*@C FNSetOptionsPrefix - Sets the prefix used for searching for all FN options in the database. Logically Collective on FN Input Parameters: + fn - the math function context - prefix - the prefix string to prepend to all FN option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: FNAppendOptionsPrefix() @*/ PetscErrorCode FNSetOptionsPrefix(FN fn,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); ierr = PetscObjectSetOptionsPrefix((PetscObject)fn,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNAppendOptionsPrefix" /*@C FNAppendOptionsPrefix - Appends to the prefix used for searching for all FN options in the database. Logically Collective on FN Input Parameters: + fn - the math function context - prefix - the prefix string to prepend to all FN option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: FNSetOptionsPrefix() @*/ PetscErrorCode FNAppendOptionsPrefix(FN fn,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)fn,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNGetOptionsPrefix" /*@C FNGetOptionsPrefix - Gets the prefix used for searching for all FN options in the database. Not Collective Input Parameters: . fn - the math function context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: FNSetOptionsPrefix(), FNAppendOptionsPrefix() @*/ PetscErrorCode FNGetOptionsPrefix(FN fn,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)fn,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNSetType" /*@C FNSetType - Selects the type for the FN object. Logically Collective on FN Input Parameter: + fn - the math function context - type - a known type Notes: The default is FNRATIONAL, which includes polynomials as a particular case as well as simple functions such as f(x)=x and f(x)=constant. Level: intermediate .seealso: FNGetType() @*/ PetscErrorCode FNSetType(FN fn,FNType type) { PetscErrorCode ierr,(*r)(FN); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)fn,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(FNList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested FN type %s",type); if (fn->ops->destroy) { ierr = (*fn->ops->destroy)(fn);CHKERRQ(ierr); } ierr = PetscMemzero(fn->ops,sizeof(struct _FNOps));CHKERRQ(ierr); ierr = PetscObjectChangeTypeName((PetscObject)fn,type);CHKERRQ(ierr); ierr = (*r)(fn);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNGetType" /*@C FNGetType - Gets the FN type name (as a string) from the FN context. Not Collective Input Parameter: . fn - the math function context Output Parameter: . name - name of the math function Level: intermediate .seealso: FNSetType() @*/ PetscErrorCode FNGetType(FN fn,FNType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)fn)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNSetScale" /*@ FNSetScale - Sets the scaling parameters that define the matematical function. Logically Collective on FN Input Parameters: + fn - the math function context . alpha - inner scaling (argument) - beta - outer scaling (result) Notes: Given a function f(x) specified by the FN type, the scaling parameters can be used to realize the function beta*f(alpha*x). So when these values are given, the procedure for function evaluation will first multiply the argument by alpha, then evaluate the function itself, and finally scale the result by beta. Likewise, these values are also considered when evaluating the derivative. If you want to provide only one of the two scaling factors, set the other one to 1.0. Level: intermediate .seealso: FNGetScale(), FNEvaluateFunction() @*/ PetscErrorCode FNSetScale(FN fn,PetscScalar alpha,PetscScalar beta) { PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidLogicalCollectiveScalar(fn,alpha,2); PetscValidLogicalCollectiveScalar(fn,beta,2); fn->alpha = alpha; fn->beta = beta; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNGetScale" /*@ FNGetScale - Gets the scaling parameters that define the matematical function. Not Collective Input Parameter: . fn - the math function context Output Parameters: + alpha - inner scaling (argument) - beta - outer scaling (result) Level: intermediate .seealso: FNSetScale() @*/ PetscErrorCode FNGetScale(FN fn,PetscScalar *alpha,PetscScalar *beta) { PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); if (alpha) *alpha = fn->alpha; if (beta) *beta = fn->beta; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction" /*@ FNEvaluateFunction - Computes the value of the function f(x) for a given x. Logically Collective on FN Input Parameters: + fn - the math function context - x - the value where the function must be evaluated Output Parameter: . y - the result of f(x) Note: Scaling factors are taken into account, so the actual function evaluation will return beta*f(alpha*x). Level: intermediate .seealso: FNEvaluateDerivative(), FNEvaluateFunctionMat(), FNSetScale() @*/ PetscErrorCode FNEvaluateFunction(FN fn,PetscScalar x,PetscScalar *y) { PetscErrorCode ierr; PetscScalar xf,yf; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidLogicalCollectiveScalar(fn,x,2); PetscValidType(fn,1); PetscValidPointer(y,3); ierr = PetscLogEventBegin(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); xf = fn->alpha*x; ierr = (*fn->ops->evaluatefunction)(fn,xf,&yf);CHKERRQ(ierr); *y = fn->beta*yf; ierr = PetscLogEventEnd(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative" /*@ FNEvaluateDerivative - Computes the value of the derivative f'(x) for a given x. Logically Collective on FN Input Parameters: + fn - the math function context - x - the value where the derivative must be evaluated Output Parameter: . y - the result of f'(x) Note: Scaling factors are taken into account, so the actual derivative evaluation will return alpha*beta*f'(alpha*x). Level: intermediate .seealso: FNEvaluateFunction() @*/ PetscErrorCode FNEvaluateDerivative(FN fn,PetscScalar x,PetscScalar *y) { PetscErrorCode ierr; PetscScalar xf,yf; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidLogicalCollectiveScalar(fn,x,2); PetscValidType(fn,1); PetscValidPointer(y,3); ierr = PetscLogEventBegin(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); xf = fn->alpha*x; ierr = (*fn->ops->evaluatederivative)(fn,xf,&yf);CHKERRQ(ierr); *y = fn->alpha*fn->beta*yf; ierr = PetscLogEventEnd(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMat_Sym_Private" static PetscErrorCode FNEvaluateFunctionMat_Sym_Private(FN fn,PetscScalar *As,PetscScalar *Bs,PetscInt m,PetscBool firstonly) { #if defined(PETSC_MISSING_LAPACK_SYEV) || defined(SLEPC_MISSING_LAPACK_LACPY) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"SYEV/LACPY - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscInt i,j; PetscBLASInt n,k,ld,lwork,info; PetscScalar *Q,*W,*work,a,x,y,one=1.0,zero=0.0; PetscReal *eig,dummy; #if defined(PETSC_USE_COMPLEX) PetscReal *rwork,rdummy; #endif PetscFunctionBegin; ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ld = n; k = firstonly? 1: n; /* workspace query and memory allocation */ lwork = -1; #if defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,As,&ld,&dummy,&a,&lwork,&rdummy,&info)); ierr = PetscBLASIntCast((PetscInt)PetscRealPart(a),&lwork);CHKERRQ(ierr); ierr = PetscMalloc5(m,&eig,m*m,&Q,m*k,&W,lwork,&work,PetscMax(1,3*m-2),&rwork);CHKERRQ(ierr); #else PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,As,&ld,&dummy,&a,&lwork,&info)); ierr = PetscBLASIntCast((PetscInt)PetscRealPart(a),&lwork);CHKERRQ(ierr); ierr = PetscMalloc4(m,&eig,m*m,&Q,m*k,&W,lwork,&work);CHKERRQ(ierr); #endif /* compute eigendecomposition */ PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L",&n,&n,As,&ld,Q,&ld)); #if defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,Q,&ld,eig,work,&lwork,rwork,&info)); #else PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,Q,&ld,eig,work,&lwork,&info)); #endif if (info) SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_LIB,"Error in Lapack xSYEV %i",info); /* W = f(Lambda)*Q' */ for (i=0;iops->evaluatefunction)(fn,x,&y);CHKERRQ(ierr); /* y = f(x) */ for (j=0;jalpha!=(PetscScalar)1.0) { ierr = FN_AllocateWorkMat(fn,A,&M);CHKERRQ(ierr); ierr = MatScale(M,fn->alpha);CHKERRQ(ierr); } else M = A; /* destination matrix */ F = inplace? A: B; /* evaluate matrix function */ ierr = PetscLogEventBegin(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); if (symm) { if (fn->ops->evaluatefunctionmatsym) { ierr = (*fn->ops->evaluatefunctionmatsym)(fn,M,F);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMat_Sym_Default(fn,M,F);CHKERRQ(ierr); } } else { if (fn->ops->evaluatefunctionmat) { ierr = (*fn->ops->evaluatefunctionmat)(fn,M,F);CHKERRQ(ierr); } else SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Matrix function not implemented in FN type %s",((PetscObject)fn)->type_name); } ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); if (fn->alpha!=(PetscScalar)1.0) { ierr = FN_FreeWorkMat(fn,&M);CHKERRQ(ierr); } /* scale result */ ierr = MatScale(F,fn->beta);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMatVec_Default" /* FNEvaluateFunctionMatVec_Default - computes the full matrix f(A) and then copies the first column. */ static PetscErrorCode FNEvaluateFunctionMatVec_Default(FN fn,Mat A,Vec v) { PetscErrorCode ierr; Mat F; PetscFunctionBegin; ierr = FN_AllocateWorkMat(fn,A,&F);CHKERRQ(ierr); if (fn->ops->evaluatefunctionmat) { ierr = (*fn->ops->evaluatefunctionmat)(fn,A,F);CHKERRQ(ierr); } else SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Matrix function not implemented in FN type %s",((PetscObject)fn)->type_name); ierr = MatGetColumnVector(F,v,0);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&F);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMatVec_Sym_Default" /* FNEvaluateFunctionMatVec_Sym_Default - given a symmetric matrix A, compute the matrix function as f(A)=Q*f(D)*Q' where the spectral decomposition of A is A=Q*D*Q'. Only the first column is computed. */ static PetscErrorCode FNEvaluateFunctionMatVec_Sym_Default(FN fn,Mat A,Vec v) { PetscErrorCode ierr; PetscInt m; PetscScalar *As,*vs; PetscFunctionBegin; ierr = MatDenseGetArray(A,&As);CHKERRQ(ierr); ierr = VecGetArray(v,&vs);CHKERRQ(ierr); ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat_Sym_Private(fn,As,vs,m,PETSC_TRUE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(A,&As);CHKERRQ(ierr); ierr = VecRestoreArray(v,&vs);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMatVec" /*@ FNEvaluateFunctionMatVec - Computes the first column of the matrix f(A) for a given matrix A. Logically Collective on FN Input Parameters: + fn - the math function context - A - matrix on which the function must be evaluated Output Parameter: . v - vector to hold the first column of f(A) Notes: This operation is similar to FNEvaluateFunctionMat() but returns only the first column of f(A), hence saving computations in most cases. Level: advanced .seealso: FNEvaluateFunction(), FNEvaluateFunctionMat() @*/ PetscErrorCode FNEvaluateFunctionMatVec(FN fn,Mat A,Vec v) { PetscErrorCode ierr; PetscBool match,set,flg,symm=PETSC_FALSE; PetscInt m,n; Mat M; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidHeaderSpecific(A,MAT_CLASSID,2); PetscValidHeaderSpecific(v,VEC_CLASSID,3); PetscValidType(fn,1); PetscValidType(A,2); PetscValidType(v,3); ierr = PetscObjectTypeCompare((PetscObject)A,MATSEQDENSE,&match);CHKERRQ(ierr); if (!match) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Mat A must be of type seqdense"); ierr = MatGetSize(A,&m,&n);CHKERRQ(ierr); if (m!=n) SETERRQ2(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_SIZ,"Mat A is not square (has %D rows, %D cols)",m,n); ierr = VecGetSize(v,&m);CHKERRQ(ierr); if (m!=n) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_SIZ,"Matrix A and vector v must have the same size"); /* check symmetry of A */ ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); symm = set? flg: PETSC_FALSE; /* scale argument */ if (fn->alpha!=(PetscScalar)1.0) { ierr = FN_AllocateWorkMat(fn,A,&M);CHKERRQ(ierr); ierr = MatScale(M,fn->alpha);CHKERRQ(ierr); } else M = A; /* evaluate matrix function */ ierr = PetscLogEventBegin(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); ierr = PetscFPTrapPush(PETSC_FP_TRAP_OFF);CHKERRQ(ierr); if (symm) { if (fn->ops->evaluatefunctionmatvecsym) { ierr = (*fn->ops->evaluatefunctionmatvecsym)(fn,M,v);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMatVec_Sym_Default(fn,M,v);CHKERRQ(ierr); } } else { if (fn->ops->evaluatefunctionmatvec) { ierr = (*fn->ops->evaluatefunctionmatvec)(fn,M,v);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMatVec_Default(fn,M,v);CHKERRQ(ierr); } } ierr = PetscFPTrapPop();CHKERRQ(ierr); ierr = PetscLogEventEnd(FN_Evaluate,fn,0,0,0);CHKERRQ(ierr); if (fn->alpha!=(PetscScalar)1.0) { ierr = FN_FreeWorkMat(fn,&M);CHKERRQ(ierr); } /* scale result */ ierr = VecScale(v,fn->beta);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNSetFromOptions" /*@ FNSetFromOptions - Sets FN options from the options database. Collective on FN Input Parameters: . fn - the math function context Notes: To see all options, run your program with the -help option. Level: beginner @*/ PetscErrorCode FNSetFromOptions(FN fn) { PetscErrorCode ierr; char type[256]; PetscScalar array[2]; PetscInt k; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); ierr = FNRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)fn);CHKERRQ(ierr); ierr = PetscOptionsFList("-fn_type","Math function type","FNSetType",FNList,(char*)(((PetscObject)fn)->type_name?((PetscObject)fn)->type_name:FNRATIONAL),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = FNSetType(fn,type);CHKERRQ(ierr); } /* Set the type if it was never set. */ if (!((PetscObject)fn)->type_name) { ierr = FNSetType(fn,FNRATIONAL);CHKERRQ(ierr); } k = 2; array[0] = 0.0; array[1] = 0.0; ierr = PetscOptionsScalarArray("-fn_scale","Scale factors (one or two scalar values separated with a comma without spaces)","FNSetScale",array,&k,&flg);CHKERRQ(ierr); if (flg) { if (k<2) array[1] = 1.0; ierr = FNSetScale(fn,array[0],array[1]);CHKERRQ(ierr); } if (fn->ops->setfromoptions) { ierr = (*fn->ops->setfromoptions)(PetscOptionsObject,fn);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)fn);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNView" /*@C FNView - Prints the FN data structure. Collective on FN Input Parameters: + fn - the math function context - viewer - optional visualization context Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner @*/ PetscErrorCode FNView(FN fn,PetscViewer viewer) { PetscBool isascii; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)fn)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(fn,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)fn,viewer);CHKERRQ(ierr); if (fn->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*fn->ops->view)(fn,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNDuplicate" /*@ FNDuplicate - Duplicates a math function, copying all parameters, possibly with a different communicator. Collective on FN Input Parameters: + fn - the math function context - comm - MPI communicator Output Parameter: . newfn - location to put the new FN context Note: In order to use the same MPI communicator as in the original object, use PetscObjectComm((PetscObject)fn). Level: developer .seealso: FNCreate() @*/ PetscErrorCode FNDuplicate(FN fn,MPI_Comm comm,FN *newfn) { PetscErrorCode ierr; FNType type; PetscScalar alpha,beta; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidType(fn,1); PetscValidPointer(newfn,3); ierr = FNCreate(comm,newfn);CHKERRQ(ierr); ierr = FNGetType(fn,&type);CHKERRQ(ierr); ierr = FNSetType(*newfn,type);CHKERRQ(ierr); ierr = FNGetScale(fn,&alpha,&beta);CHKERRQ(ierr); ierr = FNSetScale(*newfn,alpha,beta);CHKERRQ(ierr); if (fn->ops->duplicate) { ierr = (*fn->ops->duplicate)(fn,comm,newfn);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNDestroy" /*@ FNDestroy - Destroys FN context that was created with FNCreate(). Collective on FN Input Parameter: . fn - the math function context Level: beginner .seealso: FNCreate() @*/ PetscErrorCode FNDestroy(FN *fn) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; if (!*fn) PetscFunctionReturn(0); PetscValidHeaderSpecific(*fn,FN_CLASSID,1); if (--((PetscObject)(*fn))->refct > 0) { *fn = 0; PetscFunctionReturn(0); } if ((*fn)->ops->destroy) { ierr = (*(*fn)->ops->destroy)(*fn);CHKERRQ(ierr); } for (i=0;i<(*fn)->nw;i++) { ierr = MatDestroy(&(*fn)->W[i]);CHKERRQ(ierr); } ierr = PetscHeaderDestroy(fn);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRegister" /*@C FNRegister - Adds a mathematical function to the FN package. Not collective Input Parameters: + name - name of a new user-defined FN - function - routine to create context Notes: FNRegister() may be called multiple times to add several user-defined functions. Level: advanced .seealso: FNRegisterAll() @*/ PetscErrorCode FNRegister(const char *name,PetscErrorCode (*function)(FN)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&FNList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/interface/fnregis.c.html0000644000175000017500000001363313107004621022342 0ustar jromanjroman

Actual source code: fnregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/

 24: PETSC_EXTERN PetscErrorCode FNCreate_Combine(FN);
 25: PETSC_EXTERN PetscErrorCode FNCreate_Rational(FN);
 26: PETSC_EXTERN PetscErrorCode FNCreate_Exp(FN);
 27: PETSC_EXTERN PetscErrorCode FNCreate_Log(FN);
 28: PETSC_EXTERN PetscErrorCode FNCreate_Phi(FN);
 29: PETSC_EXTERN PetscErrorCode FNCreate_Sqrt(FN);
 30: PETSC_EXTERN PetscErrorCode FNCreate_Invsqrt(FN);

 34: /*@C
 35:    FNRegisterAll - Registers all of the math functions in the FN package.

 37:    Not Collective

 39:    Level: advanced
 40: @*/
 41: PetscErrorCode FNRegisterAll(void)
 42: {

 46:   if (FNRegisterAllCalled) return(0);
 47:   FNRegisterAllCalled = PETSC_TRUE;
 48:   FNRegister(FNCOMBINE,FNCreate_Combine);
 49:   FNRegister(FNRATIONAL,FNCreate_Rational);
 50:   FNRegister(FNEXP,FNCreate_Exp);
 51:   FNRegister(FNLOG,FNCreate_Log);
 52:   FNRegister(FNPHI,FNCreate_Phi);
 53:   FNRegister(FNSQRT,FNCreate_Sqrt);
 54:   FNRegister(FNINVSQRT,FNCreate_Invsqrt);
 55:   return(0);
 56: }

slepc-3.7.4/src/sys/classes/fn/interface/makefile.html0000644000175000017500000000471513107004621022242 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fnbasic.c fnregis.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/fn/interface/fnregis.c0000644000175000017500000000407213107004621021374 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ PETSC_EXTERN PetscErrorCode FNCreate_Combine(FN); PETSC_EXTERN PetscErrorCode FNCreate_Rational(FN); PETSC_EXTERN PetscErrorCode FNCreate_Exp(FN); PETSC_EXTERN PetscErrorCode FNCreate_Log(FN); PETSC_EXTERN PetscErrorCode FNCreate_Phi(FN); PETSC_EXTERN PetscErrorCode FNCreate_Sqrt(FN); PETSC_EXTERN PetscErrorCode FNCreate_Invsqrt(FN); #undef __FUNCT__ #define __FUNCT__ "FNRegisterAll" /*@C FNRegisterAll - Registers all of the math functions in the FN package. Not Collective Level: advanced @*/ PetscErrorCode FNRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (FNRegisterAllCalled) PetscFunctionReturn(0); FNRegisterAllCalled = PETSC_TRUE; ierr = FNRegister(FNCOMBINE,FNCreate_Combine);CHKERRQ(ierr); ierr = FNRegister(FNRATIONAL,FNCreate_Rational);CHKERRQ(ierr); ierr = FNRegister(FNEXP,FNCreate_Exp);CHKERRQ(ierr); ierr = FNRegister(FNLOG,FNCreate_Log);CHKERRQ(ierr); ierr = FNRegister(FNPHI,FNCreate_Phi);CHKERRQ(ierr); ierr = FNRegister(FNSQRT,FNCreate_Sqrt);CHKERRQ(ierr); ierr = FNRegister(FNINVSQRT,FNCreate_Invsqrt);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/interface/index.html0000644000175000017500000000220613107004621021565 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fnbasic.c
fnregis.c
makefile
slepc-3.7.4/src/sys/classes/fn/interface/fnbasic.c.html0000644000175000017500000020251313107004621022307 0ustar jromanjroman

Actual source code: fnbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      Basic routines

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/
 25: #include <slepcblaslapack.h>

 27: PetscFunctionList FNList = 0;
 28: PetscBool         FNRegisterAllCalled = PETSC_FALSE;
 29: PetscClassId      FN_CLASSID = 0;
 30: PetscLogEvent     FN_Evaluate = 0;
 31: static PetscBool  FNPackageInitialized = PETSC_FALSE;

 35: /*@C
 36:    FNFinalizePackage - This function destroys everything in the Slepc interface
 37:    to the FN package. It is called from SlepcFinalize().

 39:    Level: developer

 41: .seealso: SlepcFinalize()
 42: @*/
 43: PetscErrorCode FNFinalizePackage(void)
 44: {

 48:   PetscFunctionListDestroy(&FNList);
 49:   FNPackageInitialized = PETSC_FALSE;
 50:   FNRegisterAllCalled  = PETSC_FALSE;
 51:   return(0);
 52: }

 56: /*@C
 57:   FNInitializePackage - This function initializes everything in the FN package.
 58:   It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 59:   on the first call to FNCreate() when using static libraries.

 61:   Level: developer

 63: .seealso: SlepcInitialize()
 64: @*/
 65: PetscErrorCode FNInitializePackage(void)
 66: {
 67:   char             logList[256];
 68:   char             *className;
 69:   PetscBool        opt;
 70:   PetscErrorCode   ierr;

 73:   if (FNPackageInitialized) return(0);
 74:   FNPackageInitialized = PETSC_TRUE;
 75:   /* Register Classes */
 76:   PetscClassIdRegister("Math Function",&FN_CLASSID);
 77:   /* Register Constructors */
 78:   FNRegisterAll();
 79:   /* Register Events */
 80:   PetscLogEventRegister("FNEvaluate",FN_CLASSID,&FN_Evaluate);
 81:   /* Process info exclusions */
 82:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 83:   if (opt) {
 84:     PetscStrstr(logList,"fn",&className);
 85:     if (className) {
 86:       PetscInfoDeactivateClass(FN_CLASSID);
 87:     }
 88:   }
 89:   /* Process summary exclusions */
 90:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 91:   if (opt) {
 92:     PetscStrstr(logList,"fn",&className);
 93:     if (className) {
 94:       PetscLogEventDeactivateClass(FN_CLASSID);
 95:     }
 96:   }
 97:   PetscRegisterFinalize(FNFinalizePackage);
 98:   return(0);
 99: }

103: /*@
104:    FNCreate - Creates an FN context.

106:    Collective on MPI_Comm

108:    Input Parameter:
109: .  comm - MPI communicator

111:    Output Parameter:
112: .  newfn - location to put the FN context

114:    Level: beginner

116: .seealso: FNDestroy(), FN
117: @*/
118: PetscErrorCode FNCreate(MPI_Comm comm,FN *newfn)
119: {
120:   FN             fn;

125:   *newfn = 0;
126:   FNInitializePackage();
127:   SlepcHeaderCreate(fn,FN_CLASSID,"FN","Math Function","FN",comm,FNDestroy,FNView);

129:   fn->alpha    = 1.0;
130:   fn->beta     = 1.0;

132:   fn->nw       = 0;
133:   fn->cw       = 0;
134:   fn->data     = NULL;

136:   *newfn = fn;
137:   return(0);
138: }

142: /*@C
143:    FNSetOptionsPrefix - Sets the prefix used for searching for all
144:    FN options in the database.

146:    Logically Collective on FN

148:    Input Parameters:
149: +  fn - the math function context
150: -  prefix - the prefix string to prepend to all FN option requests

152:    Notes:
153:    A hyphen (-) must NOT be given at the beginning of the prefix name.
154:    The first character of all runtime options is AUTOMATICALLY the
155:    hyphen.

157:    Level: advanced

159: .seealso: FNAppendOptionsPrefix()
160: @*/
161: PetscErrorCode FNSetOptionsPrefix(FN fn,const char *prefix)
162: {

167:   PetscObjectSetOptionsPrefix((PetscObject)fn,prefix);
168:   return(0);
169: }

173: /*@C
174:    FNAppendOptionsPrefix - Appends to the prefix used for searching for all
175:    FN options in the database.

177:    Logically Collective on FN

179:    Input Parameters:
180: +  fn - the math function context
181: -  prefix - the prefix string to prepend to all FN option requests

183:    Notes:
184:    A hyphen (-) must NOT be given at the beginning of the prefix name.
185:    The first character of all runtime options is AUTOMATICALLY the hyphen.

187:    Level: advanced

189: .seealso: FNSetOptionsPrefix()
190: @*/
191: PetscErrorCode FNAppendOptionsPrefix(FN fn,const char *prefix)
192: {

197:   PetscObjectAppendOptionsPrefix((PetscObject)fn,prefix);
198:   return(0);
199: }

203: /*@C
204:    FNGetOptionsPrefix - Gets the prefix used for searching for all
205:    FN options in the database.

207:    Not Collective

209:    Input Parameters:
210: .  fn - the math function context

212:    Output Parameters:
213: .  prefix - pointer to the prefix string used is returned

215:    Note:
216:    On the Fortran side, the user should pass in a string 'prefix' of
217:    sufficient length to hold the prefix.

219:    Level: advanced

221: .seealso: FNSetOptionsPrefix(), FNAppendOptionsPrefix()
222: @*/
223: PetscErrorCode FNGetOptionsPrefix(FN fn,const char *prefix[])
224: {

230:   PetscObjectGetOptionsPrefix((PetscObject)fn,prefix);
231:   return(0);
232: }

236: /*@C
237:    FNSetType - Selects the type for the FN object.

239:    Logically Collective on FN

241:    Input Parameter:
242: +  fn   - the math function context
243: -  type - a known type

245:    Notes:
246:    The default is FNRATIONAL, which includes polynomials as a particular
247:    case as well as simple functions such as f(x)=x and f(x)=constant.

249:    Level: intermediate

251: .seealso: FNGetType()
252: @*/
253: PetscErrorCode FNSetType(FN fn,FNType type)
254: {
255:   PetscErrorCode ierr,(*r)(FN);
256:   PetscBool      match;


262:   PetscObjectTypeCompare((PetscObject)fn,type,&match);
263:   if (match) return(0);

265:    PetscFunctionListFind(FNList,type,&r);
266:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested FN type %s",type);

268:   if (fn->ops->destroy) { (*fn->ops->destroy)(fn); }
269:   PetscMemzero(fn->ops,sizeof(struct _FNOps));

271:   PetscObjectChangeTypeName((PetscObject)fn,type);
272:   (*r)(fn);
273:   return(0);
274: }

278: /*@C
279:    FNGetType - Gets the FN type name (as a string) from the FN context.

281:    Not Collective

283:    Input Parameter:
284: .  fn - the math function context

286:    Output Parameter:
287: .  name - name of the math function

289:    Level: intermediate

291: .seealso: FNSetType()
292: @*/
293: PetscErrorCode FNGetType(FN fn,FNType *type)
294: {
298:   *type = ((PetscObject)fn)->type_name;
299:   return(0);
300: }

304: /*@
305:    FNSetScale - Sets the scaling parameters that define the matematical function.

307:    Logically Collective on FN

309:    Input Parameters:
310: +  fn    - the math function context
311: .  alpha - inner scaling (argument)
312: -  beta  - outer scaling (result)

314:    Notes:
315:    Given a function f(x) specified by the FN type, the scaling parameters can
316:    be used to realize the function beta*f(alpha*x). So when these values are given,
317:    the procedure for function evaluation will first multiply the argument by alpha,
318:    then evaluate the function itself, and finally scale the result by beta.
319:    Likewise, these values are also considered when evaluating the derivative.

321:    If you want to provide only one of the two scaling factors, set the other
322:    one to 1.0.

324:    Level: intermediate

326: .seealso: FNGetScale(), FNEvaluateFunction()
327: @*/
328: PetscErrorCode FNSetScale(FN fn,PetscScalar alpha,PetscScalar beta)
329: {
334:   fn->alpha = alpha;
335:   fn->beta  = beta;
336:   return(0);
337: }

341: /*@
342:    FNGetScale - Gets the scaling parameters that define the matematical function.

344:    Not Collective

346:    Input Parameter:
347: .  fn    - the math function context

349:    Output Parameters:
350: +  alpha - inner scaling (argument)
351: -  beta  - outer scaling (result)

353:    Level: intermediate

355: .seealso: FNSetScale()
356: @*/
357: PetscErrorCode FNGetScale(FN fn,PetscScalar *alpha,PetscScalar *beta)
358: {
361:   if (alpha) *alpha = fn->alpha;
362:   if (beta)  *beta  = fn->beta;
363:   return(0);
364: }

368: /*@
369:    FNEvaluateFunction - Computes the value of the function f(x) for a given x.

371:    Logically Collective on FN

373:    Input Parameters:
374: +  fn - the math function context
375: -  x  - the value where the function must be evaluated

377:    Output Parameter:
378: .  y  - the result of f(x)

380:    Note:
381:    Scaling factors are taken into account, so the actual function evaluation
382:    will return beta*f(alpha*x).

384:    Level: intermediate

386: .seealso: FNEvaluateDerivative(), FNEvaluateFunctionMat(), FNSetScale()
387: @*/
388: PetscErrorCode FNEvaluateFunction(FN fn,PetscScalar x,PetscScalar *y)
389: {
391:   PetscScalar    xf,yf;

398:   PetscLogEventBegin(FN_Evaluate,fn,0,0,0);
399:   xf = fn->alpha*x;
400:   (*fn->ops->evaluatefunction)(fn,xf,&yf);
401:   *y = fn->beta*yf;
402:   PetscLogEventEnd(FN_Evaluate,fn,0,0,0);
403:   return(0);
404: }

408: /*@
409:    FNEvaluateDerivative - Computes the value of the derivative f'(x) for a given x.

411:    Logically Collective on FN

413:    Input Parameters:
414: +  fn - the math function context
415: -  x  - the value where the derivative must be evaluated

417:    Output Parameter:
418: .  y  - the result of f'(x)

420:    Note:
421:    Scaling factors are taken into account, so the actual derivative evaluation will
422:    return alpha*beta*f'(alpha*x).

424:    Level: intermediate

426: .seealso: FNEvaluateFunction()
427: @*/
428: PetscErrorCode FNEvaluateDerivative(FN fn,PetscScalar x,PetscScalar *y)
429: {
431:   PetscScalar    xf,yf;

438:   PetscLogEventBegin(FN_Evaluate,fn,0,0,0);
439:   xf = fn->alpha*x;
440:   (*fn->ops->evaluatederivative)(fn,xf,&yf);
441:   *y = fn->alpha*fn->beta*yf;
442:   PetscLogEventEnd(FN_Evaluate,fn,0,0,0);
443:   return(0);
444: }

448: static PetscErrorCode FNEvaluateFunctionMat_Sym_Private(FN fn,PetscScalar *As,PetscScalar *Bs,PetscInt m,PetscBool firstonly)
449: {
450: #if defined(PETSC_MISSING_LAPACK_SYEV) || defined(SLEPC_MISSING_LAPACK_LACPY)
452:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"SYEV/LACPY - Lapack routines are unavailable");
453: #else
455:   PetscInt       i,j;
456:   PetscBLASInt   n,k,ld,lwork,info;
457:   PetscScalar    *Q,*W,*work,a,x,y,one=1.0,zero=0.0;
458:   PetscReal      *eig,dummy;
459: #if defined(PETSC_USE_COMPLEX)
460:   PetscReal      *rwork,rdummy;
461: #endif

464:   PetscBLASIntCast(m,&n);
465:   ld = n;
466:   k = firstonly? 1: n;

468:   /* workspace query and memory allocation */
469:   lwork = -1;
470: #if defined(PETSC_USE_COMPLEX)
471:   PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,As,&ld,&dummy,&a,&lwork,&rdummy,&info));
472:   PetscBLASIntCast((PetscInt)PetscRealPart(a),&lwork);
473:   PetscMalloc5(m,&eig,m*m,&Q,m*k,&W,lwork,&work,PetscMax(1,3*m-2),&rwork);
474: #else
475:   PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,As,&ld,&dummy,&a,&lwork,&info));
476:   PetscBLASIntCast((PetscInt)PetscRealPart(a),&lwork);
477:   PetscMalloc4(m,&eig,m*m,&Q,m*k,&W,lwork,&work);
478: #endif

480:   /* compute eigendecomposition */
481:   PetscStackCallBLAS("LAPACKlacpy",LAPACKlacpy_("L",&n,&n,As,&ld,Q,&ld));
482: #if defined(PETSC_USE_COMPLEX)
483:   PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,Q,&ld,eig,work,&lwork,rwork,&info));
484: #else
485:   PetscStackCallBLAS("LAPACKsyev",LAPACKsyev_("V","L",&n,Q,&ld,eig,work,&lwork,&info));
486: #endif
487:   if (info) SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_LIB,"Error in Lapack xSYEV %i",info);

489:   /* W = f(Lambda)*Q' */
490:   for (i=0;i<n;i++) {
491:     x = eig[i];
492:     (*fn->ops->evaluatefunction)(fn,x,&y);  /* y = f(x) */
493:     for (j=0;j<k;j++) W[i+j*ld] = Q[j+i*ld]*y;
494:   }
495:   /* Bs = Q*W */
496:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&k,&n,&one,Q,&ld,W,&ld,&zero,Bs,&ld));
497: #if defined(PETSC_USE_COMPLEX)
498:   PetscFree5(eig,Q,W,work,rwork);
499: #else
500:   PetscFree4(eig,Q,W,work);
501: #endif
502:   return(0);
503: #endif
504: }

508: /*
509:    FNEvaluateFunctionMat_Sym_Default - given a symmetric matrix A,
510:    compute the matrix function as f(A)=Q*f(D)*Q' where the spectral
511:    decomposition of A is A=Q*D*Q'
512: */
513: static PetscErrorCode FNEvaluateFunctionMat_Sym_Default(FN fn,Mat A,Mat B)
514: {
516:   PetscInt       m;
517:   PetscScalar    *As,*Bs;

520:   MatDenseGetArray(A,&As);
521:   MatDenseGetArray(B,&Bs);
522:   MatGetSize(A,&m,NULL);
523:   FNEvaluateFunctionMat_Sym_Private(fn,As,Bs,m,PETSC_FALSE);
524:   MatDenseRestoreArray(A,&As);
525:   MatDenseRestoreArray(B,&Bs);
526:   return(0);
527: }

531: /*@
532:    FNEvaluateFunctionMat - Computes the value of the function f(A) for a given
533:    matrix A, where the result is also a matrix.

535:    Logically Collective on FN

537:    Input Parameters:
538: +  fn - the math function context
539: -  A  - matrix on which the function must be evaluated

541:    Output Parameter:
542: .  B  - (optional) matrix resulting from evaluating f(A)

544:    Notes:
545:    Matrix A must be a square sequential dense Mat, with all entries equal on
546:    all processes (otherwise each process will compute different results).
547:    If matrix B is provided, it must also be a square sequential dense Mat, and
548:    both matrices must have the same dimensions. If B is NULL (or B=A) then the
549:    function will perform an in-place computation, overwriting A with f(A).

551:    If A is known to be real symmetric or complex Hermitian then it is
552:    recommended to set the appropriate flag with MatSetOption(), so that
553:    a different algorithm that exploits symmetry is used.

555:    Scaling factors are taken into account, so the actual function evaluation
556:    will return beta*f(alpha*A).

558:    Level: advanced

560: .seealso: FNEvaluateFunction(), FNEvaluateFunctionMatVec()
561: @*/
562: PetscErrorCode FNEvaluateFunctionMat(FN fn,Mat A,Mat B)
563: {
565:   PetscBool      match,set,flg,symm=PETSC_FALSE,inplace=PETSC_FALSE;
566:   PetscInt       m,n,n1;
567:   Mat            M,F;

574:   if (B) {
577:   } else inplace = PETSC_TRUE;
578:   PetscObjectTypeCompare((PetscObject)A,MATSEQDENSE,&match);
579:   if (!match) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Mat A must be of type seqdense");
580:   MatGetSize(A,&m,&n);
581:   if (m!=n) SETERRQ2(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_SIZ,"Mat A is not square (has %D rows, %D cols)",m,n);
582:   if (!inplace) {
583:     PetscObjectTypeCompare((PetscObject)B,MATSEQDENSE,&match);
584:     if (!match) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Mat B must be of type seqdense");
585:     n1 = n;
586:     MatGetSize(B,&m,&n);
587:     if (m!=n) SETERRQ2(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_SIZ,"Mat B is not square (has %D rows, %D cols)",m,n);
588:     if (n1!=n) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_SIZ,"Matrices A and B must have the same dimension");
589:   }

591:   /* check symmetry of A */
592:   MatIsHermitianKnown(A,&set,&flg);
593:   symm = set? flg: PETSC_FALSE;

595:   /* scale argument */
596:   if (fn->alpha!=(PetscScalar)1.0) {
597:     FN_AllocateWorkMat(fn,A,&M);
598:     MatScale(M,fn->alpha);
599:   } else M = A;

601:   /* destination matrix */
602:   F = inplace? A: B;

604:   /* evaluate matrix function */
605:   PetscLogEventBegin(FN_Evaluate,fn,0,0,0);
606:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
607:   if (symm) {
608:     if (fn->ops->evaluatefunctionmatsym) {
609:       (*fn->ops->evaluatefunctionmatsym)(fn,M,F);
610:     } else {
611:       FNEvaluateFunctionMat_Sym_Default(fn,M,F);
612:     }
613:   } else {
614:     if (fn->ops->evaluatefunctionmat) {
615:       (*fn->ops->evaluatefunctionmat)(fn,M,F);
616:     } else SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Matrix function not implemented in FN type %s",((PetscObject)fn)->type_name);
617:   }
618:   PetscFPTrapPop();
619:   PetscLogEventEnd(FN_Evaluate,fn,0,0,0);

621:   if (fn->alpha!=(PetscScalar)1.0) {
622:     FN_FreeWorkMat(fn,&M);
623:   }

625:   /* scale result */
626:   MatScale(F,fn->beta);
627:   return(0);
628: }

632: /*
633:    FNEvaluateFunctionMatVec_Default - computes the full matrix f(A)
634:    and then copies the first column.
635: */
636: static PetscErrorCode FNEvaluateFunctionMatVec_Default(FN fn,Mat A,Vec v)
637: {
639:   Mat            F;

642:   FN_AllocateWorkMat(fn,A,&F);
643:   if (fn->ops->evaluatefunctionmat) {
644:     (*fn->ops->evaluatefunctionmat)(fn,A,F);
645:   } else SETERRQ1(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Matrix function not implemented in FN type %s",((PetscObject)fn)->type_name);
646:   MatGetColumnVector(F,v,0);
647:   FN_FreeWorkMat(fn,&F);
648:   return(0);
649: }

653: /*
654:    FNEvaluateFunctionMatVec_Sym_Default - given a symmetric matrix A,
655:    compute the matrix function as f(A)=Q*f(D)*Q' where the spectral
656:    decomposition of A is A=Q*D*Q'. Only the first column is computed.
657: */
658: static PetscErrorCode FNEvaluateFunctionMatVec_Sym_Default(FN fn,Mat A,Vec v)
659: {
661:   PetscInt       m;
662:   PetscScalar    *As,*vs;

665:   MatDenseGetArray(A,&As);
666:   VecGetArray(v,&vs);
667:   MatGetSize(A,&m,NULL);
668:   FNEvaluateFunctionMat_Sym_Private(fn,As,vs,m,PETSC_TRUE);
669:   MatDenseRestoreArray(A,&As);
670:   VecRestoreArray(v,&vs);
671:   return(0);
672: }

676: /*@
677:    FNEvaluateFunctionMatVec - Computes the first column of the matrix f(A)
678:    for a given matrix A.

680:    Logically Collective on FN

682:    Input Parameters:
683: +  fn - the math function context
684: -  A  - matrix on which the function must be evaluated

686:    Output Parameter:
687: .  v  - vector to hold the first column of f(A)

689:    Notes:
690:    This operation is similar to FNEvaluateFunctionMat() but returns only
691:    the first column of f(A), hence saving computations in most cases.

693:    Level: advanced

695: .seealso: FNEvaluateFunction(), FNEvaluateFunctionMat()
696: @*/
697: PetscErrorCode FNEvaluateFunctionMatVec(FN fn,Mat A,Vec v)
698: {
700:   PetscBool      match,set,flg,symm=PETSC_FALSE;
701:   PetscInt       m,n;
702:   Mat            M;

711:   PetscObjectTypeCompare((PetscObject)A,MATSEQDENSE,&match);
712:   if (!match) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_SUP,"Mat A must be of type seqdense");
713:   MatGetSize(A,&m,&n);
714:   if (m!=n) SETERRQ2(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_SIZ,"Mat A is not square (has %D rows, %D cols)",m,n);
715:   VecGetSize(v,&m);
716:   if (m!=n) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_SIZ,"Matrix A and vector v must have the same size");

718:   /* check symmetry of A */
719:   MatIsHermitianKnown(A,&set,&flg);
720:   symm = set? flg: PETSC_FALSE;

722:   /* scale argument */
723:   if (fn->alpha!=(PetscScalar)1.0) {
724:     FN_AllocateWorkMat(fn,A,&M);
725:     MatScale(M,fn->alpha);
726:   } else M = A;

728:   /* evaluate matrix function */
729:   PetscLogEventBegin(FN_Evaluate,fn,0,0,0);
730:   PetscFPTrapPush(PETSC_FP_TRAP_OFF);
731:   if (symm) {
732:     if (fn->ops->evaluatefunctionmatvecsym) {
733:       (*fn->ops->evaluatefunctionmatvecsym)(fn,M,v);
734:     } else {
735:       FNEvaluateFunctionMatVec_Sym_Default(fn,M,v);
736:     }
737:   } else {
738:     if (fn->ops->evaluatefunctionmatvec) {
739:       (*fn->ops->evaluatefunctionmatvec)(fn,M,v);
740:     } else {
741:       FNEvaluateFunctionMatVec_Default(fn,M,v);
742:     }
743:   }
744:   PetscFPTrapPop();
745:   PetscLogEventEnd(FN_Evaluate,fn,0,0,0);

747:   if (fn->alpha!=(PetscScalar)1.0) {
748:     FN_FreeWorkMat(fn,&M);
749:   }

751:   /* scale result */
752:   VecScale(v,fn->beta);
753:   return(0);
754: }

758: /*@
759:    FNSetFromOptions - Sets FN options from the options database.

761:    Collective on FN

763:    Input Parameters:
764: .  fn - the math function context

766:    Notes:
767:    To see all options, run your program with the -help option.

769:    Level: beginner
770: @*/
771: PetscErrorCode FNSetFromOptions(FN fn)
772: {
774:   char           type[256];
775:   PetscScalar    array[2];
776:   PetscInt       k;
777:   PetscBool      flg;

781:   FNRegisterAll();
782:   PetscObjectOptionsBegin((PetscObject)fn);
783:     PetscOptionsFList("-fn_type","Math function type","FNSetType",FNList,(char*)(((PetscObject)fn)->type_name?((PetscObject)fn)->type_name:FNRATIONAL),type,256,&flg);
784:     if (flg) {
785:       FNSetType(fn,type);
786:     }
787:     /*
788:       Set the type if it was never set.
789:     */
790:     if (!((PetscObject)fn)->type_name) {
791:       FNSetType(fn,FNRATIONAL);
792:     }

794:     k = 2;
795:     array[0] = 0.0; array[1] = 0.0;
796:     PetscOptionsScalarArray("-fn_scale","Scale factors (one or two scalar values separated with a comma without spaces)","FNSetScale",array,&k,&flg);
797:     if (flg) {
798:       if (k<2) array[1] = 1.0;
799:       FNSetScale(fn,array[0],array[1]);
800:     }

802:     if (fn->ops->setfromoptions) {
803:       (*fn->ops->setfromoptions)(PetscOptionsObject,fn);
804:     }
805:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)fn);
806:   PetscOptionsEnd();
807:   return(0);
808: }

812: /*@C
813:    FNView - Prints the FN data structure.

815:    Collective on FN

817:    Input Parameters:
818: +  fn - the math function context
819: -  viewer - optional visualization context

821:    Note:
822:    The available visualization contexts include
823: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
824: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
825:          output where only the first processor opens
826:          the file.  All other processors send their
827:          data to the first processor to print.

829:    The user can open an alternative visualization context with
830:    PetscViewerASCIIOpen() - output to a specified file.

832:    Level: beginner
833: @*/
834: PetscErrorCode FNView(FN fn,PetscViewer viewer)
835: {
836:   PetscBool      isascii;

841:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)fn));
844:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
845:   if (isascii) {
846:     PetscObjectPrintClassNamePrefixType((PetscObject)fn,viewer);
847:     if (fn->ops->view) {
848:       PetscViewerASCIIPushTab(viewer);
849:       (*fn->ops->view)(fn,viewer);
850:       PetscViewerASCIIPopTab(viewer);
851:     }
852:   }
853:   return(0);
854: }

858: /*@
859:    FNDuplicate - Duplicates a math function, copying all parameters, possibly with a
860:    different communicator.

862:    Collective on FN

864:    Input Parameters:
865: +  fn   - the math function context
866: -  comm - MPI communicator

868:    Output Parameter:
869: .  newfn - location to put the new FN context

871:    Note:
872:    In order to use the same MPI communicator as in the original object,
873:    use PetscObjectComm((PetscObject)fn).

875:    Level: developer

877: .seealso: FNCreate()
878: @*/
879: PetscErrorCode FNDuplicate(FN fn,MPI_Comm comm,FN *newfn)
880: {
882:   FNType         type;
883:   PetscScalar    alpha,beta;

889:   FNCreate(comm,newfn);
890:   FNGetType(fn,&type);
891:   FNSetType(*newfn,type);
892:   FNGetScale(fn,&alpha,&beta);
893:   FNSetScale(*newfn,alpha,beta);
894:   if (fn->ops->duplicate) {
895:     (*fn->ops->duplicate)(fn,comm,newfn);
896:   }
897:   return(0);
898: }

902: /*@
903:    FNDestroy - Destroys FN context that was created with FNCreate().

905:    Collective on FN

907:    Input Parameter:
908: .  fn - the math function context

910:    Level: beginner

912: .seealso: FNCreate()
913: @*/
914: PetscErrorCode FNDestroy(FN *fn)
915: {
917:   PetscInt       i;

920:   if (!*fn) return(0);
922:   if (--((PetscObject)(*fn))->refct > 0) { *fn = 0; return(0); }
923:   if ((*fn)->ops->destroy) { (*(*fn)->ops->destroy)(*fn); }
924:   for (i=0;i<(*fn)->nw;i++) {
925:     MatDestroy(&(*fn)->W[i]);
926:   }
927:   PetscHeaderDestroy(fn);
928:   return(0);
929: }

933: /*@C
934:    FNRegister - Adds a mathematical function to the FN package.

936:    Not collective

938:    Input Parameters:
939: +  name - name of a new user-defined FN
940: -  function - routine to create context

942:    Notes:
943:    FNRegister() may be called multiple times to add several user-defined functions.

945:    Level: advanced

947: .seealso: FNRegisterAll()
948: @*/
949: PetscErrorCode FNRegister(const char *name,PetscErrorCode (*function)(FN))
950: {

954:   PetscFunctionListAdd(&FNList,name,function);
955:   return(0);
956: }

slepc-3.7.4/src/sys/classes/fn/interface/ftn-auto/0000755000175000017500000000000013107004621021325 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/interface/ftn-auto/makefile0000644000175000017500000000037213107004621023027 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = fnbasicf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/fn/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/interface/ftn-auto/fnbasicf.c0000644000175000017500000001046413107004621023251 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* fnbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define fncreate_ FNCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fncreate_ fncreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnsetscale_ FNSETSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnsetscale_ fnsetscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fngetscale_ FNGETSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fngetscale_ fngetscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnevaluatefunction_ FNEVALUATEFUNCTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnevaluatefunction_ fnevaluatefunction #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnevaluatederivative_ FNEVALUATEDERIVATIVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnevaluatederivative_ fnevaluatederivative #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnevaluatefunctionmat_ FNEVALUATEFUNCTIONMAT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnevaluatefunctionmat_ fnevaluatefunctionmat #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnevaluatefunctionmatvec_ FNEVALUATEFUNCTIONMATVEC #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnevaluatefunctionmatvec_ fnevaluatefunctionmatvec #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnsetfromoptions_ FNSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnsetfromoptions_ fnsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnduplicate_ FNDUPLICATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnduplicate_ fnduplicate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fndestroy_ FNDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fndestroy_ fndestroy #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL fncreate_(MPI_Fint * comm,FN *newfn, int *__ierr ){ *__ierr = FNCreate( MPI_Comm_f2c(*(comm)),newfn); } PETSC_EXTERN void PETSC_STDCALL fnsetscale_(FN fn,PetscScalar *alpha,PetscScalar *beta, int *__ierr ){ *__ierr = FNSetScale( (FN)PetscToPointer((fn) ),*alpha,*beta); } PETSC_EXTERN void PETSC_STDCALL fngetscale_(FN fn,PetscScalar *alpha,PetscScalar *beta, int *__ierr ){ *__ierr = FNGetScale( (FN)PetscToPointer((fn) ),alpha,beta); } PETSC_EXTERN void PETSC_STDCALL fnevaluatefunction_(FN fn,PetscScalar *x,PetscScalar *y, int *__ierr ){ *__ierr = FNEvaluateFunction( (FN)PetscToPointer((fn) ),*x,y); } PETSC_EXTERN void PETSC_STDCALL fnevaluatederivative_(FN fn,PetscScalar *x,PetscScalar *y, int *__ierr ){ *__ierr = FNEvaluateDerivative( (FN)PetscToPointer((fn) ),*x,y); } PETSC_EXTERN void PETSC_STDCALL fnevaluatefunctionmat_(FN fn,Mat A,Mat B, int *__ierr ){ *__ierr = FNEvaluateFunctionMat( (FN)PetscToPointer((fn) ), (Mat)PetscToPointer((A) ), (Mat)PetscToPointer((B) )); } PETSC_EXTERN void PETSC_STDCALL fnevaluatefunctionmatvec_(FN fn,Mat A,Vec v, int *__ierr ){ *__ierr = FNEvaluateFunctionMatVec( (FN)PetscToPointer((fn) ), (Mat)PetscToPointer((A) ), (Vec)PetscToPointer((v) )); } PETSC_EXTERN void PETSC_STDCALL fnsetfromoptions_(FN fn, int *__ierr ){ *__ierr = FNSetFromOptions( (FN)PetscToPointer((fn) )); } PETSC_EXTERN void PETSC_STDCALL fnduplicate_(FN fn,MPI_Fint * comm,FN *newfn, int *__ierr ){ *__ierr = FNDuplicate( (FN)PetscToPointer((fn) ), MPI_Comm_f2c(*(comm)),newfn); } PETSC_EXTERN void PETSC_STDCALL fndestroy_(FN *fn, int *__ierr ){ *__ierr = FNDestroy(fn); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/fn/interface/ftn-custom/0000755000175000017500000000000013107004621021667 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/interface/ftn-custom/makefile0000644000175000017500000000221113107004621023363 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zfnf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/fn/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/interface/ftn-custom/zfnf.c0000644000175000017500000000613313107004621023001 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define fnview_ FNVIEW #define fnsetoptionsprefix_ FNSETOPTIONSPREFIX #define fnappendoptionsprefix_ FNAPPENDOPTIONSPREFIX #define fngetoptionsprefix_ FNGETOPTIONSPREFIX #define fnsettype_ FNSETTYPE #define fngettype_ FNGETTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define fnview_ fnview #define fnsetoptionsprefix_ fnsetoptionsprefix #define fnappendoptionsprefix_ fnappendoptionsprefix #define fngetoptionsprefix_ fngetoptionsprefix #define fnsettype_ fnsettype #define fngettype_ fngettype #endif PETSC_EXTERN void PETSC_STDCALL fnview_(FN *fn,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = FNView(*fn,v); } PETSC_EXTERN void PETSC_STDCALL fnsetoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = FNSetOptionsPrefix(*fn,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL fnappendoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = FNAppendOptionsPrefix(*fn,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL fngetoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = FNGetOptionsPrefix(*fn,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL fnsettype_(FN *fn,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = FNSetType(*fn,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL fngettype_(FN *fn,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { FNType tname; *ierr = FNGetType(*fn,&tname);if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } slepc-3.7.4/src/sys/classes/fn/examples/0000755000175000017500000000000013107004621017446 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/examples/makefile0000644000175000017500000000202013107004621021140 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/sys/classes/fn/examples/ DIRS = tests include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/examples/makefile.html0000644000175000017500000000445313107004621022117 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/sys/classes/fn/examples/
DIRS     = tests

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/examples/index.html0000644000175000017500000000124013107004621021440 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
makefile
slepc-3.7.4/src/sys/classes/fn/examples/tests/0000755000175000017500000000000013107004621020610 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/examples/tests/makefile0000644000175000017500000001263213107004621022314 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/sys/classes/fn/examples/tests/ EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c EXAMPLESF = MANSEC = FN TESTS = test1 test2 test3 test4 test5 test6 test7 test8 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \ test2.PETSc runtest2_1 test2.rm \ test3.PETSc runtest3_1 runtest3_2 test3.rm \ test4.PETSc runtest4_1 test4.rm \ test5.PETSc runtest5_1 runtest5_2 test5.rm \ test6.PETSc runtest6_1 runtest6_2 test6.rm \ test7.PETSc runtest7_1 runtest7_2 test7.rm \ test8.PETSc runtest8_1 runtest8_2 test8.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB} ${RM} test1.o test2: test2.o chkopts -${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB} ${RM} test2.o test3: test3.o chkopts -${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB} ${RM} test3.o test4: test4.o chkopts -${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB} ${RM} test4.o test5: test5.o chkopts -${CLINKER} -o test5 test5.o ${SLEPC_SYS_LIB} ${RM} test5.o test6: test6.o chkopts -${CLINKER} -o test6 test6.o ${SLEPC_SYS_LIB} ${RM} test6.o test7: test7.o chkopts -${CLINKER} -o test7 test7.o ${SLEPC_SYS_LIB} ${RM} test7.o test8: test8.o chkopts -${CLINKER} -o test8 test8.o ${SLEPC_SYS_LIB} ${RM} test8.o #------------------------------------------------------------------------------------ runtest1_1: -@${MPIEXEC} -n 1 ./test1 > test1_1.tmp 2>&1; \ if (${DIFF} output/test1_1.out test1_1.tmp) then true; \ else echo "Possible problem with test1_1, diffs above"; fi; \ ${RM} -f test1_1.tmp runtest2_1: -@${MPIEXEC} -n 1 ./test2 > test2_1.tmp 2>&1; \ if (${DIFF} output/test2_1.out test2_1.tmp) then true; \ else echo "Possible problem with test2_1, diffs above"; fi; \ ${RM} -f test2_1.tmp runtest3_1: -@${MPIEXEC} -n 1 ./test3 > test3_1.tmp 2>&1; \ if (${DIFF} output/test3_1.out test3_1.tmp) then true; \ else echo "Possible problem with test3_1, diffs above"; fi; \ ${RM} -f test3_1.tmp runtest3_2: -@${MPIEXEC} -n 1 ./test3 -inplace > test3_1.tmp 2>&1; \ if (${DIFF} output/test3_1.out test3_1.tmp) then true; \ else echo "Possible problem with test3_1, diffs above"; fi; \ ${RM} -f test3_1.tmp runtest4_1: -@${MPIEXEC} -n 1 ./test4 -f1_fn_type exp -f1_fn_scale -2.5 -f2_fn_type rational -f2_fn_rational_numerator -1,1 -f2_fn_rational_denominator 1,-6,4 > test4_1.tmp 2>&1; \ if (${DIFF} output/test4_1.out test4_1.tmp) then true; \ else echo "Possible problem with test4_1, diffs above"; fi; \ ${RM} -f test4_1.tmp runtest5_1: -@${MPIEXEC} -n 1 ./test5 > test5_1.tmp 2>&1; \ if (${DIFF} output/test5_1.out test5_1.tmp) then true; \ else echo "Possible problem with test5_1, diffs above"; fi; \ ${RM} -f test5_1.tmp runtest5_2: -@${MPIEXEC} -n 1 ./test5 -inplace > test5_1.tmp 2>&1; \ if (${DIFF} output/test5_1.out test5_1.tmp) then true; \ else echo "Possible problem with test5_1, diffs above"; fi; \ ${RM} -f test5_1.tmp runtest6_1: -@${MPIEXEC} -n 1 ./test6 > test6_1.tmp 2>&1; \ if (${DIFF} output/test6_1.out test6_1.tmp) then true; \ else echo "Possible problem with test6_1, diffs above"; fi; \ ${RM} -f test6_1.tmp runtest6_2: -@${MPIEXEC} -n 1 ./test6 -inplace > test6_1.tmp 2>&1; \ if (${DIFF} output/test6_1.out test6_1.tmp) then true; \ else echo "Possible problem with test6_1, diffs above"; fi; \ ${RM} -f test6_1.tmp runtest7_1: -@${MPIEXEC} -n 1 ./test7 -tau .13 -eta 2 -n 19 > test7_1.tmp 2>&1; \ if (${DIFF} output/test7_1.out test7_1.tmp) then true; \ else echo "Possible problem with test7_1, diffs above"; fi; \ ${RM} -f test7_1.tmp runtest7_2: -@${MPIEXEC} -n 1 ./test7 -tau .13 -eta 2 -n 19 -inplace > test7_1.tmp 2>&1; \ if (${DIFF} output/test7_1.out test7_1.tmp) then true; \ else echo "Possible problem with test7_1, diffs above"; fi; \ ${RM} -f test7_1.tmp runtest8_1: -@${MPIEXEC} -n 1 ./test8 -tau 0.9 -eta 0.5 -n 10 > test8_1.tmp 2>&1; \ if (${DIFF} output/test8_1.out test8_1.tmp) then true; \ else echo "Possible problem with test8_1, diffs above"; fi; \ ${RM} -f test8_1.tmp runtest8_2: -@${MPIEXEC} -n 1 ./test8 -tau 0.9 -eta 0.5 -n 10 -inplace > test8_1.tmp 2>&1; \ if (${DIFF} output/test8_1.out test8_1.tmp) then true; \ else echo "Possible problem with test8_1, diffs above"; fi; \ ${RM} -f test8_1.tmp slepc-3.7.4/src/sys/classes/fn/examples/tests/test4.c.html0000644000175000017500000001147013107004621022765 0ustar jromanjroman

Actual source code: test4.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test setting FN parameters from the command line.\n\n";

 24: #include <slepcfn.h>

 28: int main(int argc,char **argv)
 29: {
 31:   FN             fn1,fn2;

 33:   SlepcInitialize(&argc,&argv,(char*)0,help);
 34:   FNCreate(PETSC_COMM_WORLD,&fn1);
 35:   FNSetOptionsPrefix(fn1,"f1_");
 36:   FNSetFromOptions(fn1);
 37:   FNView(fn1,NULL);
 38:   FNDestroy(&fn1);
 39:   FNCreate(PETSC_COMM_WORLD,&fn2);
 40:   FNSetOptionsPrefix(fn2,"f2_");
 41:   FNSetFromOptions(fn2);
 42:   FNView(fn2,NULL);
 43:   FNDestroy(&fn2);
 44:   SlepcFinalize();
 45:   return ierr;
 46: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/test4.c0000644000175000017500000000326113107004621022021 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test setting FN parameters from the command line.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN fn1,fn2; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = FNCreate(PETSC_COMM_WORLD,&fn1);CHKERRQ(ierr); ierr = FNSetOptionsPrefix(fn1,"f1_");CHKERRQ(ierr); ierr = FNSetFromOptions(fn1);CHKERRQ(ierr); ierr = FNView(fn1,NULL);CHKERRQ(ierr); ierr = FNDestroy(&fn1);CHKERRQ(ierr); ierr = FNCreate(PETSC_COMM_WORLD,&fn2);CHKERRQ(ierr); ierr = FNSetOptionsPrefix(fn2,"f2_");CHKERRQ(ierr); ierr = FNSetFromOptions(fn2);CHKERRQ(ierr); ierr = FNView(fn2,NULL);CHKERRQ(ierr); ierr = FNDestroy(&fn2);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/sys/classes/fn/examples/tests/test1.c.html0000644000175000017500000002572513107004621022772 0ustar jromanjroman
Actual source code: test1.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test rational function.\n\n";

 24: #include <slepcfn.h>

 28: int main(int argc,char **argv)
 29: {
 31:   FN             fn;
 32:   PetscInt       na,nb;
 33:   PetscScalar    x,y,yp,p[10],q[10],five=5.0;
 34:   char           strx[50],str[50];

 36:   SlepcInitialize(&argc,&argv,(char*)0,help);
 37:   FNCreate(PETSC_COMM_WORLD,&fn);

 39:   /* polynomial p(x) */
 40:   na = 5;
 41:   p[0] = -3.1; p[1] = 1.1; p[2] = 1.0; p[3] = -2.0; p[4] = 3.5;
 42:   FNSetType(fn,FNRATIONAL);
 43:   FNRationalSetNumerator(fn,na,p);
 44:   FNView(fn,NULL);
 45:   x = 2.2;
 46:   SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);
 47:   FNEvaluateFunction(fn,x,&y);
 48:   FNEvaluateDerivative(fn,x,&yp);
 49:   SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);
 50:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
 51:   SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);
 52:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

 54:   /* inverse of polynomial 1/q(x) */
 55:   nb = 3;
 56:   q[0] = -3.1; q[1] = 1.1; q[2] = 1.0;
 57:   FNSetType(fn,FNRATIONAL);
 58:   FNRationalSetNumerator(fn,0,NULL);  /* reset previous values */
 59:   FNRationalSetDenominator(fn,nb,q);
 60:   FNView(fn,NULL);
 61:   x = 2.2;
 62:   SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);
 63:   FNEvaluateFunction(fn,x,&y);
 64:   FNEvaluateDerivative(fn,x,&yp);
 65:   SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);
 66:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
 67:   SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);
 68:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

 70:   /* rational p(x)/q(x) */
 71:   na = 2; nb = 3;
 72:   p[0] = -3.1; p[1] = 1.1;
 73:   q[0] = 1.0; q[1] = -2.0; q[2] = 3.5;
 74:   FNSetType(fn,FNRATIONAL);
 75:   FNRationalSetNumerator(fn,na,p);
 76:   FNRationalSetDenominator(fn,nb,q);
 77:   FNView(fn,NULL);
 78:   x = 2.2;
 79:   SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);
 80:   FNEvaluateFunction(fn,x,&y);
 81:   FNEvaluateDerivative(fn,x,&yp);
 82:   SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);
 83:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
 84:   SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);
 85:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

 87:   /* constant */
 88:   FNSetType(fn,FNRATIONAL);
 89:   FNRationalSetNumerator(fn,1,&five);
 90:   FNRationalSetDenominator(fn,0,NULL);  /* reset previous values */
 91:   FNView(fn,NULL);
 92:   x = 2.2;
 93:   SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);
 94:   FNEvaluateFunction(fn,x,&y);
 95:   FNEvaluateDerivative(fn,x,&yp);
 96:   SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);
 97:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
 98:   SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);
 99:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

101:   FNDestroy(&fn);
102:   SlepcFinalize();
103:   return ierr;
104: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/makefile.html0000644000175000017500000002162513107004621023261 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/sys/classes/fn/examples/tests/
EXAMPLESC  = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c
EXAMPLESF  =
MANSEC     = FN
TESTS      = test1 test2 test3 test4 test5 test6 test7 test8

TESTEXAMPLES_C       = test1.PETSc runtest1_1 test1.rm \
                       test2.PETSc runtest2_1 test2.rm \
                       test3.PETSc runtest3_1 runtest3_2 test3.rm \
                       test4.PETSc runtest4_1 test4.rm \
                       test5.PETSc runtest5_1 runtest5_2 test5.rm \
                       test6.PETSc runtest6_1 runtest6_2 test6.rm \
                       test7.PETSc runtest7_1 runtest7_2 test7.rm \
                       test8.PETSc runtest8_1 runtest8_2 test8.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB}
	${RM} test1.o

test2: test2.o chkopts
	-${CLINKER} -o test2 test2.o ${SLEPC_SYS_LIB}
	${RM} test2.o

test3: test3.o chkopts
	-${CLINKER} -o test3 test3.o ${SLEPC_SYS_LIB}
	${RM} test3.o

test4: test4.o chkopts
	-${CLINKER} -o test4 test4.o ${SLEPC_SYS_LIB}
	${RM} test4.o

test5: test5.o chkopts
	-${CLINKER} -o test5 test5.o ${SLEPC_SYS_LIB}
	${RM} test5.o

test6: test6.o chkopts
	-${CLINKER} -o test6 test6.o ${SLEPC_SYS_LIB}
	${RM} test6.o

test7: test7.o chkopts
	-${CLINKER} -o test7 test7.o ${SLEPC_SYS_LIB}
	${RM} test7.o

test8: test8.o chkopts
	-${CLINKER} -o test8 test8.o ${SLEPC_SYS_LIB}
	${RM} test8.o

#------------------------------------------------------------------------------------

runtest1_1:
	-@${MPIEXEC} -n 1 ./test1 > test1_1.tmp 2>&1; \
	  if (${DIFF} output/test1_1.out test1_1.tmp) then true; \
	  else echo "Possible problem with test1_1, diffs above"; fi; \
	  ${RM} -f test1_1.tmp

runtest2_1:
	-@${MPIEXEC} -n 1 ./test2 > test2_1.tmp 2>&1; \
	  if (${DIFF} output/test2_1.out test2_1.tmp) then true; \
	  else echo "Possible problem with test2_1, diffs above"; fi; \
	  ${RM} -f test2_1.tmp

runtest3_1:
	-@${MPIEXEC} -n 1 ./test3 > test3_1.tmp 2>&1; \
	  if (${DIFF} output/test3_1.out test3_1.tmp) then true; \
	  else echo "Possible problem with test3_1, diffs above"; fi; \
	  ${RM} -f test3_1.tmp

runtest3_2:
	-@${MPIEXEC} -n 1 ./test3 -inplace > test3_1.tmp 2>&1; \
	  if (${DIFF} output/test3_1.out test3_1.tmp) then true; \
	  else echo "Possible problem with test3_1, diffs above"; fi; \
	  ${RM} -f test3_1.tmp

runtest4_1:
	-@${MPIEXEC} -n 1 ./test4 -f1_fn_type exp -f1_fn_scale -2.5 -f2_fn_type rational -f2_fn_rational_numerator -1,1 -f2_fn_rational_denominator 1,-6,4 > test4_1.tmp 2>&1; \
	  if (${DIFF} output/test4_1.out test4_1.tmp) then true; \
	  else echo "Possible problem with test4_1, diffs above"; fi; \
	  ${RM} -f test4_1.tmp

runtest5_1:
	-@${MPIEXEC} -n 1 ./test5 > test5_1.tmp 2>&1; \
	  if (${DIFF} output/test5_1.out test5_1.tmp) then true; \
	  else echo "Possible problem with test5_1, diffs above"; fi; \
	  ${RM} -f test5_1.tmp

runtest5_2:
	-@${MPIEXEC} -n 1 ./test5 -inplace > test5_1.tmp 2>&1; \
	  if (${DIFF} output/test5_1.out test5_1.tmp) then true; \
	  else echo "Possible problem with test5_1, diffs above"; fi; \
	  ${RM} -f test5_1.tmp

runtest6_1:
	-@${MPIEXEC} -n 1 ./test6 > test6_1.tmp 2>&1; \
	  if (${DIFF} output/test6_1.out test6_1.tmp) then true; \
	  else echo "Possible problem with test6_1, diffs above"; fi; \
	  ${RM} -f test6_1.tmp

runtest6_2:
	-@${MPIEXEC} -n 1 ./test6 -inplace > test6_1.tmp 2>&1; \
	  if (${DIFF} output/test6_1.out test6_1.tmp) then true; \
	  else echo "Possible problem with test6_1, diffs above"; fi; \
	  ${RM} -f test6_1.tmp

runtest7_1:
	-@${MPIEXEC} -n 1 ./test7 -tau .13 -eta 2 -n 19 > test7_1.tmp 2>&1; \
	  if (${DIFF} output/test7_1.out test7_1.tmp) then true; \
	  else echo "Possible problem with test7_1, diffs above"; fi; \
	  ${RM} -f test7_1.tmp

runtest7_2:
	-@${MPIEXEC} -n 1 ./test7 -tau .13 -eta 2 -n 19 -inplace > test7_1.tmp 2>&1; \
	  if (${DIFF} output/test7_1.out test7_1.tmp) then true; \
	  else echo "Possible problem with test7_1, diffs above"; fi; \
	  ${RM} -f test7_1.tmp

runtest8_1:
	-@${MPIEXEC} -n 1 ./test8 -tau 0.9 -eta 0.5 -n 10 > test8_1.tmp 2>&1; \
	  if (${DIFF} output/test8_1.out test8_1.tmp) then true; \
	  else echo "Possible problem with test8_1, diffs above"; fi; \
	  ${RM} -f test8_1.tmp

runtest8_2:
	-@${MPIEXEC} -n 1 ./test8 -tau 0.9 -eta 0.5 -n 10 -inplace > test8_1.tmp 2>&1; \
	  if (${DIFF} output/test8_1.out test8_1.tmp) then true; \
	  else echo "Possible problem with test8_1, diffs above"; fi; \
	  ${RM} -f test8_1.tmp

slepc-3.7.4/src/sys/classes/fn/examples/tests/test1.c0000644000175000017500000001053313107004621022016 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test rational function.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN fn; PetscInt na,nb; PetscScalar x,y,yp,p[10],q[10],five=5.0; char strx[50],str[50]; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = FNCreate(PETSC_COMM_WORLD,&fn);CHKERRQ(ierr); /* polynomial p(x) */ na = 5; p[0] = -3.1; p[1] = 1.1; p[2] = 1.0; p[3] = -2.0; p[4] = 3.5; ierr = FNSetType(fn,FNRATIONAL);CHKERRQ(ierr); ierr = FNRationalSetNumerator(fn,na,p);CHKERRQ(ierr); ierr = FNView(fn,NULL);CHKERRQ(ierr); x = 2.2; ierr = SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);CHKERRQ(ierr); ierr = FNEvaluateFunction(fn,x,&y);CHKERRQ(ierr); ierr = FNEvaluateDerivative(fn,x,&yp);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f'(%s)=%s\n",strx,str);CHKERRQ(ierr); /* inverse of polynomial 1/q(x) */ nb = 3; q[0] = -3.1; q[1] = 1.1; q[2] = 1.0; ierr = FNSetType(fn,FNRATIONAL);CHKERRQ(ierr); ierr = FNRationalSetNumerator(fn,0,NULL);CHKERRQ(ierr); /* reset previous values */ ierr = FNRationalSetDenominator(fn,nb,q);CHKERRQ(ierr); ierr = FNView(fn,NULL);CHKERRQ(ierr); x = 2.2; ierr = SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);CHKERRQ(ierr); ierr = FNEvaluateFunction(fn,x,&y);CHKERRQ(ierr); ierr = FNEvaluateDerivative(fn,x,&yp);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f'(%s)=%s\n",strx,str);CHKERRQ(ierr); /* rational p(x)/q(x) */ na = 2; nb = 3; p[0] = -3.1; p[1] = 1.1; q[0] = 1.0; q[1] = -2.0; q[2] = 3.5; ierr = FNSetType(fn,FNRATIONAL);CHKERRQ(ierr); ierr = FNRationalSetNumerator(fn,na,p);CHKERRQ(ierr); ierr = FNRationalSetDenominator(fn,nb,q);CHKERRQ(ierr); ierr = FNView(fn,NULL);CHKERRQ(ierr); x = 2.2; ierr = SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);CHKERRQ(ierr); ierr = FNEvaluateFunction(fn,x,&y);CHKERRQ(ierr); ierr = FNEvaluateDerivative(fn,x,&yp);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f'(%s)=%s\n",strx,str);CHKERRQ(ierr); /* constant */ ierr = FNSetType(fn,FNRATIONAL);CHKERRQ(ierr); ierr = FNRationalSetNumerator(fn,1,&five);CHKERRQ(ierr); ierr = FNRationalSetDenominator(fn,0,NULL);CHKERRQ(ierr); /* reset previous values */ ierr = FNView(fn,NULL);CHKERRQ(ierr); x = 2.2; ierr = SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);CHKERRQ(ierr); ierr = FNEvaluateFunction(fn,x,&y);CHKERRQ(ierr); ierr = FNEvaluateDerivative(fn,x,&yp);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f'(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = FNDestroy(&fn);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/sys/classes/fn/examples/tests/test3.c0000644000175000017500000001211613107004621022017 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test matrix exponential.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "TestMatExp" /* Compute matrix exponential B = expm(A) */ PetscErrorCode TestMatExp(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace) { PetscErrorCode ierr; PetscBool set,flg; PetscInt n; Mat F; Vec v,f0; PetscReal nrm; PetscFunctionBeginUser; ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&F);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)F,"F");CHKERRQ(ierr); /* compute square root */ if (inplace) { ierr = MatCopy(A,F,SAME_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); if (set && flg) { ierr = MatSetOption(F,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); } ierr = FNEvaluateFunctionMat(fn,F,NULL);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMat(fn,A,F);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(A,viewer);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed expm(A) - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(F,viewer);CHKERRQ(ierr); } /* print matrix norm for checking */ ierr = MatNorm(F,NORM_1,&nrm);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"The 1-norm of f(A) is %g\n",(double)nrm);CHKERRQ(ierr); /* check FNEvaluateFunctionMatVec() */ ierr = MatCreateVecs(A,&v,&f0);CHKERRQ(ierr); ierr = MatGetColumnVector(F,f0,0);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(fn,A,v);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,f0);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&nrm);CHKERRQ(ierr); if (nrm>100*PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);CHKERRQ(ierr); } ierr = MatDestroy(&F);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&f0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN fn; Mat A; PetscInt i,j,n=10; PetscScalar *As,tau=1.0,eta=1.0; PetscViewer viewer; PetscBool verbose,inplace; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-eta",&eta,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix exponential, n=%D.\n",n);CHKERRQ(ierr); /* Create exponential function eta*exp(tau*x) */ ierr = FNCreate(PETSC_COMM_WORLD,&fn);CHKERRQ(ierr); ierr = FNSetType(fn,FNEXP);CHKERRQ(ierr); ierr = FNSetScale(fn,tau,eta);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = FNView(fn,viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Create matrices */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)A,"A");CHKERRQ(ierr); /* Fill A with a symmetric Toeplitz matrix */ ierr = MatDenseGetArray(A,&As);CHKERRQ(ierr); for (i=0;iActual source code: test6.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    Define the function

 24:         f(x) = (1-x^2) exp( -x/(1+x^2) )

 26:    with the following tree:

 28:             f(x)                  f(x)              (combined by product)
 29:            /    \                 g(x) = 1-x^2      (polynomial)
 30:         g(x)    h(x)              h(x)              (combined by composition)
 31:                /    \             r(x) = -x/(1+x^2) (rational)
 32:              r(x)   e(x)          e(x) = exp(x)     (exponential)
 33: */

 35: static char help[] = "Test combined function.\n\n";

 37: #include <slepcfn.h>

 41: /*
 42:    Compute matrix function B = (I-A^2) exp( -(I+A^2)\A )
 43:  */
 44: PetscErrorCode TestMatCombine(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)
 45: {
 47:   PetscBool      set,flg;
 48:   PetscInt       n;
 49:   Mat            F;
 50:   Vec            v,f0;
 51:   PetscReal      nrm;

 54:   MatGetSize(A,&n,NULL);
 55:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&F);
 56:   PetscObjectSetName((PetscObject)F,"F");
 57:   /* compute square root */
 58:   if (inplace) {
 59:     MatCopy(A,F,SAME_NONZERO_PATTERN);
 60:     MatIsHermitianKnown(A,&set,&flg);
 61:     if (set && flg) { MatSetOption(F,MAT_HERMITIAN,PETSC_TRUE); }
 62:     FNEvaluateFunctionMat(fn,F,NULL);
 63:   } else {
 64:     FNEvaluateFunctionMat(fn,A,F);
 65:   }
 66:   if (verbose) {
 67:     PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");
 68:     MatView(A,viewer);
 69:     PetscPrintf(PETSC_COMM_WORLD,"Computed expm(A) - - - - - - -\n");
 70:     MatView(F,viewer);
 71:   }
 72:   /* print matrix norm for checking */
 73:   MatNorm(F,NORM_1,&nrm);
 74:   PetscPrintf(PETSC_COMM_WORLD,"The 1-norm of f(A) is %g\n",(double)nrm);
 75:   /* check FNEvaluateFunctionMatVec() */
 76:   MatCreateVecs(A,&v,&f0);
 77:   MatGetColumnVector(F,f0,0);
 78:   FNEvaluateFunctionMatVec(fn,A,v);
 79:   VecAXPY(v,-1.0,f0);
 80:   VecNorm(v,NORM_2,&nrm);
 81:   if (nrm>100*PETSC_MACHINE_EPSILON) {
 82:     PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);
 83:   }
 84:   MatDestroy(&F);
 85:   VecDestroy(&v);
 86:   VecDestroy(&f0);
 87:   return(0);
 88: }

 92: int main(int argc,char **argv)
 93: {
 95:   FN             f,g,h,e,r;
 96:   Mat            A;
 97:   PetscInt       i,j,n=10,np,nq;
 98:   PetscScalar    x,y,yp,*As,p[10],q[10];
 99:   char           strx[50],str[50];
100:   PetscViewer    viewer;
101:   PetscBool      verbose,inplace;

103:   SlepcInitialize(&argc,&argv,(char*)0,help);
104:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
105:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
106:   PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);
107:   PetscPrintf(PETSC_COMM_WORLD,"Combined function, n=%D.\n",n);

109:   /* Create function */

111:   /* e(x) = exp(x) */
112:   FNCreate(PETSC_COMM_WORLD,&e);
113:   FNSetType(e,FNEXP);
114:   /* r(x) = x/(1+x^2) */
115:   FNCreate(PETSC_COMM_WORLD,&r);
116:   FNSetType(r,FNRATIONAL);
117:   np = 2; nq = 3;
118:   p[0] = -1.0; p[1] = 0.0;
119:   q[0] = 1.0; q[1] = 0.0; q[2] = 1.0;
120:   FNRationalSetNumerator(r,np,p);
121:   FNRationalSetDenominator(r,nq,q);
122:   /* h(x) */
123:   FNCreate(PETSC_COMM_WORLD,&h);
124:   FNSetType(h,FNCOMBINE);
125:   FNCombineSetChildren(h,FN_COMBINE_COMPOSE,r,e);
126:   /* g(x) = 1-x^2 */
127:   FNCreate(PETSC_COMM_WORLD,&g);
128:   FNSetType(g,FNRATIONAL);
129:   np = 3;
130:   p[0] = -1.0; p[1] = 0.0; p[2] = 1.0;
131:   FNRationalSetNumerator(g,np,p);
132:   /* f(x) */
133:   FNCreate(PETSC_COMM_WORLD,&f);
134:   FNSetType(f,FNCOMBINE);
135:   FNCombineSetChildren(f,FN_COMBINE_MULTIPLY,g,h);

137:   /* Set up viewer */
138:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
139:   FNView(f,viewer);
140:   if (verbose) {
141:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
142:   }

144:   /* Scalar evaluation */
145:   x = 2.2;
146:   SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);
147:   FNEvaluateFunction(f,x,&y);
148:   FNEvaluateDerivative(f,x,&yp);
149:   SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);
150:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
151:   SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);
152:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

154:   /* Create matrices */
155:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);
156:   PetscObjectSetName((PetscObject)A,"A");

158:   /* Fill A with a symmetric Toeplitz matrix */
159:   MatDenseGetArray(A,&As);
160:   for (i=0;i<n;i++) As[i+i*n]=2.0;
161:   for (j=1;j<3;j++) {
162:     for (i=0;i<n-j;i++) { As[i+(i+j)*n]=1.0; As[(i+j)+i*n]=1.0; }
163:   }
164:   MatDenseRestoreArray(A,&As);
165:   MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);
166:   TestMatCombine(f,A,viewer,verbose,inplace);

168:   /* Repeat with same matrix as non-symmetric */
169:   MatSetOption(A,MAT_HERMITIAN,PETSC_FALSE);
170:   TestMatCombine(f,A,viewer,verbose,inplace);

172:   MatDestroy(&A);
173:   FNDestroy(&f);
174:   FNDestroy(&g);
175:   FNDestroy(&h);
176:   FNDestroy(&e);
177:   FNDestroy(&r);
178:   SlepcFinalize();
179:   return ierr;
180: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/test2.c.html0000644000175000017500000001754513107004621022774 0ustar jromanjroman
Actual source code: test2.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test exponential function.\n\n";

 24: #include <slepcfn.h>

 28: int main(int argc,char **argv)
 29: {
 31:   FN             fn;
 32:   PetscScalar    x,y,yp,tau,eta,alpha,beta;
 33:   char           strx[50],str[50];

 35:   SlepcInitialize(&argc,&argv,(char*)0,help);
 36:   FNCreate(PETSC_COMM_WORLD,&fn);

 38:   /* plain exponential exp(x) */
 39:   FNSetType(fn,FNEXP);
 40:   FNView(fn,NULL);
 41:   x = 2.2;
 42:   SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);
 43:   FNEvaluateFunction(fn,x,&y);
 44:   FNEvaluateDerivative(fn,x,&yp);
 45:   SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);
 46:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
 47:   SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);
 48:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

 50:   /* exponential with scaling factors eta*exp(tau*x) */
 51:   FNSetType(fn,FNEXP);
 52:   tau = -0.2;
 53:   eta = 1.3;
 54:   FNSetScale(fn,tau,eta);
 55:   FNView(fn,NULL);
 56:   x = 2.2;
 57:   SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);
 58:   FNEvaluateFunction(fn,x,&y);
 59:   FNEvaluateDerivative(fn,x,&yp);
 60:   SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);
 61:   PetscPrintf(PETSC_COMM_WORLD,"  f(%s)=%s\n",strx,str);
 62:   SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);
 63:   PetscPrintf(PETSC_COMM_WORLD,"  f'(%s)=%s\n",strx,str);

 65:   /* test FNGetScale */
 66:   FNGetScale(fn,&alpha,&beta);
 67:   PetscPrintf(PETSC_COMM_WORLD,"Parameters:\n - alpha: ");
 68:   SlepcSNPrintfScalar(str,50,alpha,PETSC_FALSE);
 69:   PetscPrintf(PETSC_COMM_WORLD,"%s ",str);
 70:   PetscPrintf(PETSC_COMM_WORLD,"\n - beta: ");
 71:   SlepcSNPrintfScalar(str,50,beta,PETSC_FALSE);
 72:   PetscPrintf(PETSC_COMM_WORLD,"%s ",str);
 73:   PetscPrintf(PETSC_COMM_WORLD,"\n");

 75:   FNDestroy(&fn);
 76:   SlepcFinalize();
 77:   return ierr;
 78: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/test7.c0000644000175000017500000001456313107004621022033 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test matrix square root.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "TestMatSqrt" /* Compute matrix square root B = sqrtm(A) Check result as norm(B*B-A) */ PetscErrorCode TestMatSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace) { PetscErrorCode ierr; PetscScalar tau,eta; PetscReal nrm; PetscBool set,flg; PetscInt n; Mat S,R; Vec v,f0; PetscFunctionBeginUser; ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&S);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)S,"S");CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&R);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)R,"R");CHKERRQ(ierr); ierr = FNGetScale(fn,&tau,&eta);CHKERRQ(ierr); /* compute square root */ if (inplace) { ierr = MatCopy(A,S,SAME_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); if (set && flg) { ierr = MatSetOption(S,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); } ierr = FNEvaluateFunctionMat(fn,S,NULL);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMat(fn,A,S);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(A,viewer);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed sqrtm(A) - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(S,viewer);CHKERRQ(ierr); } /* check error ||S*S-A||_F */ ierr = MatMatMult(S,S,MAT_REUSE_MATRIX,PETSC_DEFAULT,&R);CHKERRQ(ierr); if (eta!=1.0) { ierr = MatScale(R,1.0/(eta*eta));CHKERRQ(ierr); } ierr = MatAXPY(R,-tau,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatNorm(R,NORM_FROBENIUS,&nrm);CHKERRQ(ierr); if (nrm<100*PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"||S*S-A||_F < 100*eps\n");CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD,"||S*S-A||_F = %g\n",(double)nrm);CHKERRQ(ierr); } /* check FNEvaluateFunctionMatVec() */ ierr = MatCreateVecs(A,&v,&f0);CHKERRQ(ierr); ierr = MatGetColumnVector(S,f0,0);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(fn,A,v);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,f0);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&nrm);CHKERRQ(ierr); if (nrm>100*PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);CHKERRQ(ierr); } ierr = MatDestroy(&S);CHKERRQ(ierr); ierr = MatDestroy(&R);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&f0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN fn; Mat A; PetscInt i,j,n=10; PetscScalar *As,tau=1.0,eta=1.0; PetscViewer viewer; PetscBool verbose,inplace; PetscRandom myrand; PetscReal v; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-eta",&eta,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix square root, n=%D.\n",n);CHKERRQ(ierr); /* Create function eta*sqrt(tau*x) */ ierr = FNCreate(PETSC_COMM_WORLD,&fn);CHKERRQ(ierr); ierr = FNSetType(fn,FNSQRT);CHKERRQ(ierr); ierr = FNSetScale(fn,tau,eta);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = FNView(fn,viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Create matrix */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)A,"A");CHKERRQ(ierr); /* Compute square root of a symmetric matrix A */ ierr = MatDenseGetArray(A,&As);CHKERRQ(ierr); for (i=0;iActual source code: test5.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test matrix rational function.\n\n";

 24: #include <slepcfn.h>

 28: /*
 29:    Compute matrix rational function B = q(A)\p(A)
 30:  */
 31: PetscErrorCode TestMatRational(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)
 32: {
 34:   PetscBool      set,flg;
 35:   PetscInt       n;
 36:   Mat            F;
 37:   Vec            v,f0;
 38:   PetscReal      nrm;

 41:   MatGetSize(A,&n,NULL);
 42:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&F);
 43:   PetscObjectSetName((PetscObject)F,"F");
 44:   /* compute square root */
 45:   if (inplace) {
 46:     MatCopy(A,F,SAME_NONZERO_PATTERN);
 47:     MatIsHermitianKnown(A,&set,&flg);
 48:     if (set && flg) { MatSetOption(F,MAT_HERMITIAN,PETSC_TRUE); }
 49:     FNEvaluateFunctionMat(fn,F,NULL);
 50:   } else {
 51:     FNEvaluateFunctionMat(fn,A,F);
 52:   }
 53:   if (verbose) {
 54:     PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");
 55:     MatView(A,viewer);
 56:     PetscPrintf(PETSC_COMM_WORLD,"Computed f(A) - - - - - - -\n");
 57:     MatView(F,viewer);
 58:   }
 59:   /* print matrix norm for checking */
 60:   MatNorm(F,NORM_1,&nrm);
 61:   PetscPrintf(PETSC_COMM_WORLD,"The 1-norm of f(A) is %g\n",(double)nrm);
 62:   /* check FNEvaluateFunctionMatVec() */
 63:   MatCreateVecs(A,&v,&f0);
 64:   MatGetColumnVector(F,f0,0);
 65:   FNEvaluateFunctionMatVec(fn,A,v);
 66:   VecAXPY(v,-1.0,f0);
 67:   VecNorm(v,NORM_2,&nrm);
 68:   if (nrm>100*PETSC_MACHINE_EPSILON) {
 69:     PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);
 70:   }
 71:   MatDestroy(&F);
 72:   VecDestroy(&v);
 73:   VecDestroy(&f0);
 74:   return(0);
 75: }

 79: int main(int argc,char **argv)
 80: {
 82:   FN             fn;
 83:   Mat            A;
 84:   PetscInt       i,j,n=10,np,nq;
 85:   PetscScalar    *As,p[10],q[10];
 86:   PetscViewer    viewer;
 87:   PetscBool      verbose,inplace;

 89:   SlepcInitialize(&argc,&argv,(char*)0,help);
 90:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 91:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 92:   PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);
 93:   PetscPrintf(PETSC_COMM_WORLD,"Matrix rational function, n=%D.\n",n);

 95:   /* Create rational function r(x)=p(x)/q(x) */
 96:   FNCreate(PETSC_COMM_WORLD,&fn);
 97:   FNSetType(fn,FNRATIONAL);
 98:   np = 2; nq = 3;
 99:   p[0] = -3.1; p[1] = 1.1;
100:   q[0] = 1.0; q[1] = -2.0; q[2] = 3.5;
101:   FNRationalSetNumerator(fn,np,p);
102:   FNRationalSetDenominator(fn,nq,q);
103:   FNSetFromOptions(fn);

105:   /* Set up viewer */
106:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
107:   FNView(fn,viewer);
108:   if (verbose) {
109:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
110:   }

112:   /* Create matrices */
113:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);
114:   PetscObjectSetName((PetscObject)A,"A");

116:   /* Fill A with a symmetric Toeplitz matrix */
117:   MatDenseGetArray(A,&As);
118:   for (i=0;i<n;i++) As[i+i*n]=2.0;
119:   for (j=1;j<3;j++) {
120:     for (i=0;i<n-j;i++) { As[i+(i+j)*n]=1.0; As[(i+j)+i*n]=1.0; }
121:   }
122:   MatDenseRestoreArray(A,&As);
123:   MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);
124:   TestMatRational(fn,A,viewer,verbose,inplace);

126:   /* Repeat with same matrix as non-symmetric */
127:   MatSetOption(A,MAT_HERMITIAN,PETSC_FALSE);
128:   TestMatRational(fn,A,viewer,verbose,inplace);

130:   MatDestroy(&A);
131:   FNDestroy(&fn);
132:   SlepcFinalize();
133:   return ierr;
134: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/index.html0000644000175000017500000000313713107004621022611 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

test1.c: Test rational function
test2.c: Test exponential function
test3.c: Test matrix exponential
test4.c: Test setting FN parameters from the command line
test5.c: Test matrix rational function
test6.c: Test combined function
test7.c: Test matrix square root
test8.c: Test matrix inverse square root
makefile
slepc-3.7.4/src/sys/classes/fn/examples/tests/test8.c0000644000175000017500000001515213107004621022027 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test matrix inverse square root.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "TestMatInvSqrt" /* Compute matrix inverse square root B = inv(sqrtm(A)) Check result as norm(B*B*A-I) */ PetscErrorCode TestMatInvSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace) { PetscErrorCode ierr; PetscScalar tau,eta; PetscReal nrm; PetscBool set,flg; PetscInt n; Mat S,R; Vec v,f0; PetscFunctionBeginUser; ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&S);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)S,"S");CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&R);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)R,"R");CHKERRQ(ierr); ierr = FNGetScale(fn,&tau,&eta);CHKERRQ(ierr); /* compute inverse square root */ if (inplace) { ierr = MatCopy(A,S,SAME_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); if (set && flg) { ierr = MatSetOption(S,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); } ierr = FNEvaluateFunctionMat(fn,S,NULL);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMat(fn,A,S);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(A,viewer);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed inv(sqrtm(A)) - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(S,viewer);CHKERRQ(ierr); } /* check error ||S*S*A-I||_F */ ierr = MatMatMult(S,S,MAT_REUSE_MATRIX,PETSC_DEFAULT,&R);CHKERRQ(ierr); if (eta!=1.0) { ierr = MatScale(R,1.0/(eta*eta));CHKERRQ(ierr); } ierr = MatCreateVecs(A,&v,&f0);CHKERRQ(ierr); ierr = MatGetColumnVector(S,f0,0);CHKERRQ(ierr); ierr = MatCopy(R,S,SAME_NONZERO_PATTERN);CHKERRQ(ierr); if (tau!=1.0) { ierr = MatScale(S,tau);CHKERRQ(ierr); } ierr = MatMatMult(S,A,MAT_REUSE_MATRIX,PETSC_DEFAULT,&R);CHKERRQ(ierr); ierr = MatShift(R,-1.0);CHKERRQ(ierr); ierr = MatNorm(R,NORM_FROBENIUS,&nrm);CHKERRQ(ierr); if (nrm<100*PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"||S*S*A-I||_F < 100*eps\n");CHKERRQ(ierr); } else { ierr = PetscPrintf(PETSC_COMM_WORLD,"||S*S*A-I||_F = %g\n",(double)nrm);CHKERRQ(ierr); } /* check FNEvaluateFunctionMatVec() */ ierr = FNEvaluateFunctionMatVec(fn,A,v);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,f0);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&nrm);CHKERRQ(ierr); if (nrm>100*PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);CHKERRQ(ierr); } ierr = MatDestroy(&S);CHKERRQ(ierr); ierr = MatDestroy(&R);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&f0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN fn; Mat A; PetscInt i,j,n=10; PetscScalar *As,tau=1.0,eta=1.0; PetscViewer viewer; PetscBool verbose,inplace; PetscRandom myrand; PetscReal v; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-eta",&eta,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix inverse square root, n=%D.\n",n);CHKERRQ(ierr); /* Create function eta*inv(sqrt(tau*x)) */ ierr = FNCreate(PETSC_COMM_WORLD,&fn);CHKERRQ(ierr); ierr = FNSetType(fn,FNINVSQRT);CHKERRQ(ierr); ierr = FNSetScale(fn,tau,eta);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = FNView(fn,viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Create matrix */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)A,"A");CHKERRQ(ierr); /* Compute square root of a symmetric matrix A */ ierr = MatDenseGetArray(A,&As);CHKERRQ(ierr); for (i=0;iActual source code: test7.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test matrix square root.\n\n";

 24: #include <slepcfn.h>

 28: /*
 29:    Compute matrix square root B = sqrtm(A)
 30:    Check result as norm(B*B-A)
 31:  */
 32: PetscErrorCode TestMatSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)
 33: {
 35:   PetscScalar    tau,eta;
 36:   PetscReal      nrm;
 37:   PetscBool      set,flg;
 38:   PetscInt       n;
 39:   Mat            S,R;
 40:   Vec            v,f0;

 43:   MatGetSize(A,&n,NULL);
 44:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&S);
 45:   PetscObjectSetName((PetscObject)S,"S");
 46:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&R);
 47:   PetscObjectSetName((PetscObject)R,"R");
 48:   FNGetScale(fn,&tau,&eta);
 49:   /* compute square root */
 50:   if (inplace) {
 51:     MatCopy(A,S,SAME_NONZERO_PATTERN);
 52:     MatIsHermitianKnown(A,&set,&flg);
 53:     if (set && flg) { MatSetOption(S,MAT_HERMITIAN,PETSC_TRUE); }
 54:     FNEvaluateFunctionMat(fn,S,NULL);
 55:   } else {
 56:     FNEvaluateFunctionMat(fn,A,S);
 57:   }
 58:   if (verbose) {
 59:     PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");
 60:     MatView(A,viewer);
 61:     PetscPrintf(PETSC_COMM_WORLD,"Computed sqrtm(A) - - - - - - -\n");
 62:     MatView(S,viewer);
 63:   }
 64:   /* check error ||S*S-A||_F */
 65:   MatMatMult(S,S,MAT_REUSE_MATRIX,PETSC_DEFAULT,&R);
 66:   if (eta!=1.0) {
 67:     MatScale(R,1.0/(eta*eta));
 68:   }
 69:   MatAXPY(R,-tau,A,SAME_NONZERO_PATTERN);
 70:   MatNorm(R,NORM_FROBENIUS,&nrm);
 71:   if (nrm<100*PETSC_MACHINE_EPSILON) {
 72:     PetscPrintf(PETSC_COMM_WORLD,"||S*S-A||_F < 100*eps\n");
 73:   } else {
 74:     PetscPrintf(PETSC_COMM_WORLD,"||S*S-A||_F = %g\n",(double)nrm);
 75:   }
 76:   /* check FNEvaluateFunctionMatVec() */
 77:   MatCreateVecs(A,&v,&f0);
 78:   MatGetColumnVector(S,f0,0);
 79:   FNEvaluateFunctionMatVec(fn,A,v);
 80:   VecAXPY(v,-1.0,f0);
 81:   VecNorm(v,NORM_2,&nrm);
 82:   if (nrm>100*PETSC_MACHINE_EPSILON) {
 83:     PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);
 84:   }
 85:   MatDestroy(&S);
 86:   MatDestroy(&R);
 87:   VecDestroy(&v);
 88:   VecDestroy(&f0);
 89:   return(0);
 90: }

 94: int main(int argc,char **argv)
 95: {
 97:   FN             fn;
 98:   Mat            A;
 99:   PetscInt       i,j,n=10;
100:   PetscScalar    *As,tau=1.0,eta=1.0;
101:   PetscViewer    viewer;
102:   PetscBool      verbose,inplace;
103:   PetscRandom    myrand;
104:   PetscReal      v;

106:   SlepcInitialize(&argc,&argv,(char*)0,help);
107:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
108:   PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);
109:   PetscOptionsGetScalar(NULL,NULL,"-eta",&eta,NULL);
110:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
111:   PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);
112:   PetscPrintf(PETSC_COMM_WORLD,"Matrix square root, n=%D.\n",n);

114:   /* Create function eta*sqrt(tau*x) */
115:   FNCreate(PETSC_COMM_WORLD,&fn);
116:   FNSetType(fn,FNSQRT);
117:   FNSetScale(fn,tau,eta);

119:   /* Set up viewer */
120:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
121:   FNView(fn,viewer);
122:   if (verbose) {
123:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
124:   }

126:   /* Create matrix */
127:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);
128:   PetscObjectSetName((PetscObject)A,"A");

130:   /* Compute square root of a symmetric matrix A */
131:   MatDenseGetArray(A,&As);
132:   for (i=0;i<n;i++) As[i+i*n]=2.5;
133:   for (j=1;j<3;j++) {
134:     for (i=0;i<n-j;i++) { As[i+(i+j)*n]=1.0; As[(i+j)+i*n]=1.0; }
135:   }
136:   MatDenseRestoreArray(A,&As);
137:   MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);
138:   TestMatSqrt(fn,A,viewer,verbose,inplace);

140:   /* Repeat with upper triangular A */
141:   MatDenseGetArray(A,&As);
142:   for (j=1;j<3;j++) {
143:     for (i=0;i<n-j;i++) As[(i+j)+i*n]=0.0;
144:   }
145:   MatDenseRestoreArray(A,&As);
146:   MatSetOption(A,MAT_HERMITIAN,PETSC_FALSE);
147:   TestMatSqrt(fn,A,viewer,verbose,inplace);

149:   /* Repeat with non-symmetic A */
150:   PetscRandomCreate(PETSC_COMM_WORLD,&myrand);
151:   PetscRandomSetFromOptions(myrand);
152:   PetscRandomSetInterval(myrand,0.0,1.0);
153:   MatDenseGetArray(A,&As);
154:   for (j=1;j<3;j++) {
155:     for (i=0;i<n-j;i++) { 
156:       PetscRandomGetValueReal(myrand,&v);
157:       As[(i+j)+i*n]=v;
158:     }
159:   }
160:   MatDenseRestoreArray(A,&As);
161:   PetscRandomDestroy(&myrand);
162:   MatSetOption(A,MAT_HERMITIAN,PETSC_FALSE);
163:   TestMatSqrt(fn,A,viewer,verbose,inplace);

165:   MatDestroy(&A);
166:   FNDestroy(&fn);
167:   SlepcFinalize();
168:   return ierr;
169: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/test5.c0000644000175000017500000001200613107004621022017 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test matrix rational function.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "TestMatRational" /* Compute matrix rational function B = q(A)\p(A) */ PetscErrorCode TestMatRational(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace) { PetscErrorCode ierr; PetscBool set,flg; PetscInt n; Mat F; Vec v,f0; PetscReal nrm; PetscFunctionBeginUser; ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&F);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)F,"F");CHKERRQ(ierr); /* compute square root */ if (inplace) { ierr = MatCopy(A,F,SAME_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); if (set && flg) { ierr = MatSetOption(F,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); } ierr = FNEvaluateFunctionMat(fn,F,NULL);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMat(fn,A,F);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(A,viewer);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed f(A) - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(F,viewer);CHKERRQ(ierr); } /* print matrix norm for checking */ ierr = MatNorm(F,NORM_1,&nrm);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"The 1-norm of f(A) is %g\n",(double)nrm);CHKERRQ(ierr); /* check FNEvaluateFunctionMatVec() */ ierr = MatCreateVecs(A,&v,&f0);CHKERRQ(ierr); ierr = MatGetColumnVector(F,f0,0);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(fn,A,v);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,f0);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&nrm);CHKERRQ(ierr); if (nrm>100*PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);CHKERRQ(ierr); } ierr = MatDestroy(&F);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&f0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN fn; Mat A; PetscInt i,j,n=10,np,nq; PetscScalar *As,p[10],q[10]; PetscViewer viewer; PetscBool verbose,inplace; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix rational function, n=%D.\n",n);CHKERRQ(ierr); /* Create rational function r(x)=p(x)/q(x) */ ierr = FNCreate(PETSC_COMM_WORLD,&fn);CHKERRQ(ierr); ierr = FNSetType(fn,FNRATIONAL);CHKERRQ(ierr); np = 2; nq = 3; p[0] = -3.1; p[1] = 1.1; q[0] = 1.0; q[1] = -2.0; q[2] = 3.5; ierr = FNRationalSetNumerator(fn,np,p);CHKERRQ(ierr); ierr = FNRationalSetDenominator(fn,nq,q);CHKERRQ(ierr); ierr = FNSetFromOptions(fn);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = FNView(fn,viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Create matrices */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)A,"A");CHKERRQ(ierr); /* Fill A with a symmetric Toeplitz matrix */ ierr = MatDenseGetArray(A,&As);CHKERRQ(ierr); for (i=0;iActual source code: test8.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test matrix inverse square root.\n\n";

 24: #include <slepcfn.h>

 28: /*
 29:    Compute matrix inverse square root B = inv(sqrtm(A))
 30:    Check result as norm(B*B*A-I)
 31:  */
 32: PetscErrorCode TestMatInvSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)
 33: {
 35:   PetscScalar    tau,eta;
 36:   PetscReal      nrm;
 37:   PetscBool      set,flg;
 38:   PetscInt       n;
 39:   Mat            S,R;
 40:   Vec            v,f0;

 43:   MatGetSize(A,&n,NULL);
 44:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&S);
 45:   PetscObjectSetName((PetscObject)S,"S");
 46:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&R);
 47:   PetscObjectSetName((PetscObject)R,"R");
 48:   FNGetScale(fn,&tau,&eta);
 49:   /* compute inverse square root */
 50:   if (inplace) {
 51:     MatCopy(A,S,SAME_NONZERO_PATTERN);
 52:     MatIsHermitianKnown(A,&set,&flg);
 53:     if (set && flg) { MatSetOption(S,MAT_HERMITIAN,PETSC_TRUE); }
 54:     FNEvaluateFunctionMat(fn,S,NULL);
 55:   } else {
 56:     FNEvaluateFunctionMat(fn,A,S);
 57:   }
 58:   if (verbose) {
 59:     PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");
 60:     MatView(A,viewer);
 61:     PetscPrintf(PETSC_COMM_WORLD,"Computed inv(sqrtm(A)) - - - - - - -\n");
 62:     MatView(S,viewer);
 63:   }
 64:   /* check error ||S*S*A-I||_F */
 65:   MatMatMult(S,S,MAT_REUSE_MATRIX,PETSC_DEFAULT,&R);
 66:   if (eta!=1.0) {
 67:     MatScale(R,1.0/(eta*eta));
 68:   }
 69:   MatCreateVecs(A,&v,&f0);
 70:   MatGetColumnVector(S,f0,0);
 71:   MatCopy(R,S,SAME_NONZERO_PATTERN);
 72:   if (tau!=1.0) {
 73:     MatScale(S,tau);
 74:   }
 75:   MatMatMult(S,A,MAT_REUSE_MATRIX,PETSC_DEFAULT,&R);
 76:   MatShift(R,-1.0);
 77:   MatNorm(R,NORM_FROBENIUS,&nrm);
 78:   if (nrm<100*PETSC_MACHINE_EPSILON) {
 79:     PetscPrintf(PETSC_COMM_WORLD,"||S*S*A-I||_F < 100*eps\n");
 80:   } else {
 81:     PetscPrintf(PETSC_COMM_WORLD,"||S*S*A-I||_F = %g\n",(double)nrm);
 82:   }
 83:   /* check FNEvaluateFunctionMatVec() */
 84:   FNEvaluateFunctionMatVec(fn,A,v);
 85:   VecAXPY(v,-1.0,f0);
 86:   VecNorm(v,NORM_2,&nrm);
 87:   if (nrm>100*PETSC_MACHINE_EPSILON) {
 88:     PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);
 89:   }
 90:   MatDestroy(&S);
 91:   MatDestroy(&R);
 92:   VecDestroy(&v);
 93:   VecDestroy(&f0);
 94:   return(0);
 95: }

 99: int main(int argc,char **argv)
100: {
102:   FN             fn;
103:   Mat            A;
104:   PetscInt       i,j,n=10;
105:   PetscScalar    *As,tau=1.0,eta=1.0;
106:   PetscViewer    viewer;
107:   PetscBool      verbose,inplace;
108:   PetscRandom    myrand;
109:   PetscReal      v;

111:   SlepcInitialize(&argc,&argv,(char*)0,help);
112:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
113:   PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);
114:   PetscOptionsGetScalar(NULL,NULL,"-eta",&eta,NULL);
115:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
116:   PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);
117:   PetscPrintf(PETSC_COMM_WORLD,"Matrix inverse square root, n=%D.\n",n);

119:   /* Create function eta*inv(sqrt(tau*x)) */
120:   FNCreate(PETSC_COMM_WORLD,&fn);
121:   FNSetType(fn,FNINVSQRT);
122:   FNSetScale(fn,tau,eta);

124:   /* Set up viewer */
125:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
126:   FNView(fn,viewer);
127:   if (verbose) {
128:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
129:   }

131:   /* Create matrix */
132:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);
133:   PetscObjectSetName((PetscObject)A,"A");

135:   /* Compute square root of a symmetric matrix A */
136:   MatDenseGetArray(A,&As);
137:   for (i=0;i<n;i++) As[i+i*n]=2.5;
138:   for (j=1;j<3;j++) {
139:     for (i=0;i<n-j;i++) { As[i+(i+j)*n]=1.0; As[(i+j)+i*n]=1.0; }
140:   }
141:   MatDenseRestoreArray(A,&As);
142:   MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);
143:   TestMatInvSqrt(fn,A,viewer,verbose,inplace);

145:   /* Repeat with upper triangular A */
146:   MatDenseGetArray(A,&As);
147:   for (j=1;j<3;j++) {
148:     for (i=0;i<n-j;i++) As[(i+j)+i*n]=0.0;
149:   }
150:   MatDenseRestoreArray(A,&As);
151:   MatSetOption(A,MAT_HERMITIAN,PETSC_FALSE);
152:   TestMatInvSqrt(fn,A,viewer,verbose,inplace);

154:   /* Repeat with non-symmetic A */
155:   PetscRandomCreate(PETSC_COMM_WORLD,&myrand);
156:   PetscRandomSetFromOptions(myrand);
157:   PetscRandomSetInterval(myrand,0.0,1.0);
158:   MatDenseGetArray(A,&As);
159:   for (j=1;j<3;j++) {
160:     for (i=0;i<n-j;i++) { 
161:       PetscRandomGetValueReal(myrand,&v);
162:       As[(i+j)+i*n]=v;
163:     }
164:   }
165:   MatDenseRestoreArray(A,&As);
166:   PetscRandomDestroy(&myrand);
167:   MatSetOption(A,MAT_HERMITIAN,PETSC_FALSE);
168:   TestMatInvSqrt(fn,A,viewer,verbose,inplace);

170:   MatDestroy(&A);
171:   FNDestroy(&fn);
172:   SlepcFinalize();
173:   return ierr;
174: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/test3.c.html0000644000175000017500000002470513107004621022771 0ustar jromanjroman
Actual source code: test3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test matrix exponential.\n\n";

 24: #include <slepcfn.h>

 28: /*
 29:    Compute matrix exponential B = expm(A)
 30:  */
 31: PetscErrorCode TestMatExp(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)
 32: {
 34:   PetscBool      set,flg;
 35:   PetscInt       n;
 36:   Mat            F;
 37:   Vec            v,f0;
 38:   PetscReal      nrm;

 41:   MatGetSize(A,&n,NULL);
 42:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&F);
 43:   PetscObjectSetName((PetscObject)F,"F");
 44:   /* compute square root */
 45:   if (inplace) {
 46:     MatCopy(A,F,SAME_NONZERO_PATTERN);
 47:     MatIsHermitianKnown(A,&set,&flg);
 48:     if (set && flg) { MatSetOption(F,MAT_HERMITIAN,PETSC_TRUE); }
 49:     FNEvaluateFunctionMat(fn,F,NULL);
 50:   } else {
 51:     FNEvaluateFunctionMat(fn,A,F);
 52:   }
 53:   if (verbose) {
 54:     PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");
 55:     MatView(A,viewer);
 56:     PetscPrintf(PETSC_COMM_WORLD,"Computed expm(A) - - - - - - -\n");
 57:     MatView(F,viewer);
 58:   }
 59:   /* print matrix norm for checking */
 60:   MatNorm(F,NORM_1,&nrm);
 61:   PetscPrintf(PETSC_COMM_WORLD,"The 1-norm of f(A) is %g\n",(double)nrm);
 62:   /* check FNEvaluateFunctionMatVec() */
 63:   MatCreateVecs(A,&v,&f0);
 64:   MatGetColumnVector(F,f0,0);
 65:   FNEvaluateFunctionMatVec(fn,A,v);
 66:   VecAXPY(v,-1.0,f0);
 67:   VecNorm(v,NORM_2,&nrm);
 68:   if (nrm>100*PETSC_MACHINE_EPSILON) {
 69:     PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);
 70:   }
 71:   MatDestroy(&F);
 72:   VecDestroy(&v);
 73:   VecDestroy(&f0);
 74:   return(0);
 75: }

 79: int main(int argc,char **argv)
 80: {
 82:   FN             fn;
 83:   Mat            A;
 84:   PetscInt       i,j,n=10;
 85:   PetscScalar    *As,tau=1.0,eta=1.0;
 86:   PetscViewer    viewer;
 87:   PetscBool      verbose,inplace;

 89:   SlepcInitialize(&argc,&argv,(char*)0,help);
 90:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 91:   PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);
 92:   PetscOptionsGetScalar(NULL,NULL,"-eta",&eta,NULL);
 93:   PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);
 94:   PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);
 95:   PetscPrintf(PETSC_COMM_WORLD,"Matrix exponential, n=%D.\n",n);

 97:   /* Create exponential function eta*exp(tau*x) */
 98:   FNCreate(PETSC_COMM_WORLD,&fn);
 99:   FNSetType(fn,FNEXP);
100:   FNSetScale(fn,tau,eta);

102:   /* Set up viewer */
103:   PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);
104:   FNView(fn,viewer);
105:   if (verbose) {
106:     PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);
107:   }

109:   /* Create matrices */
110:   MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);
111:   PetscObjectSetName((PetscObject)A,"A");

113:   /* Fill A with a symmetric Toeplitz matrix */
114:   MatDenseGetArray(A,&As);
115:   for (i=0;i<n;i++) As[i+i*n]=2.0;
116:   for (j=1;j<3;j++) {
117:     for (i=0;i<n-j;i++) { As[i+(i+j)*n]=1.0; As[(i+j)+i*n]=1.0; }
118:   }
119:   MatDenseRestoreArray(A,&As);
120:   MatSetOption(A,MAT_HERMITIAN,PETSC_TRUE);
121:   TestMatExp(fn,A,viewer,verbose,inplace);

123:   /* Repeat with non-symmetric A */
124:   MatDenseGetArray(A,&As);
125:   for (j=1;j<3;j++) {
126:     for (i=0;i<n-j;i++) { As[(i+j)+i*n]=-1.0; }
127:   }
128:   MatDenseRestoreArray(A,&As);
129:   MatSetOption(A,MAT_HERMITIAN,PETSC_FALSE);
130:   TestMatExp(fn,A,viewer,verbose,inplace);

132:   MatDestroy(&A);
133:   FNDestroy(&fn);
134:   SlepcFinalize();
135:   return ierr;
136: }
slepc-3.7.4/src/sys/classes/fn/examples/tests/test2.c0000644000175000017500000000622313107004621022020 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test exponential function.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN fn; PetscScalar x,y,yp,tau,eta,alpha,beta; char strx[50],str[50]; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = FNCreate(PETSC_COMM_WORLD,&fn);CHKERRQ(ierr); /* plain exponential exp(x) */ ierr = FNSetType(fn,FNEXP);CHKERRQ(ierr); ierr = FNView(fn,NULL);CHKERRQ(ierr); x = 2.2; ierr = SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);CHKERRQ(ierr); ierr = FNEvaluateFunction(fn,x,&y);CHKERRQ(ierr); ierr = FNEvaluateDerivative(fn,x,&yp);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f'(%s)=%s\n",strx,str);CHKERRQ(ierr); /* exponential with scaling factors eta*exp(tau*x) */ ierr = FNSetType(fn,FNEXP);CHKERRQ(ierr); tau = -0.2; eta = 1.3; ierr = FNSetScale(fn,tau,eta);CHKERRQ(ierr); ierr = FNView(fn,NULL);CHKERRQ(ierr); x = 2.2; ierr = SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);CHKERRQ(ierr); ierr = FNEvaluateFunction(fn,x,&y);CHKERRQ(ierr); ierr = FNEvaluateDerivative(fn,x,&yp);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f'(%s)=%s\n",strx,str);CHKERRQ(ierr); /* test FNGetScale */ ierr = FNGetScale(fn,&alpha,&beta);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Parameters:\n - alpha: ");CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,alpha,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"%s ",str);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n - beta: ");CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,beta,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"%s ",str);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\n");CHKERRQ(ierr); ierr = FNDestroy(&fn);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/sys/classes/fn/examples/tests/test6.c0000644000175000017500000001542313107004621022026 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Define the function f(x) = (1-x^2) exp( -x/(1+x^2) ) with the following tree: f(x) f(x) (combined by product) / \ g(x) = 1-x^2 (polynomial) g(x) h(x) h(x) (combined by composition) / \ r(x) = -x/(1+x^2) (rational) r(x) e(x) e(x) = exp(x) (exponential) */ static char help[] = "Test combined function.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "TestMatCombine" /* Compute matrix function B = (I-A^2) exp( -(I+A^2)\A ) */ PetscErrorCode TestMatCombine(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace) { PetscErrorCode ierr; PetscBool set,flg; PetscInt n; Mat F; Vec v,f0; PetscReal nrm; PetscFunctionBeginUser; ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&F);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)F,"F");CHKERRQ(ierr); /* compute square root */ if (inplace) { ierr = MatCopy(A,F,SAME_NONZERO_PATTERN);CHKERRQ(ierr); ierr = MatIsHermitianKnown(A,&set,&flg);CHKERRQ(ierr); if (set && flg) { ierr = MatSetOption(F,MAT_HERMITIAN,PETSC_TRUE);CHKERRQ(ierr); } ierr = FNEvaluateFunctionMat(fn,F,NULL);CHKERRQ(ierr); } else { ierr = FNEvaluateFunctionMat(fn,A,F);CHKERRQ(ierr); } if (verbose) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Matrix A - - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(A,viewer);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Computed expm(A) - - - - - - -\n");CHKERRQ(ierr); ierr = MatView(F,viewer);CHKERRQ(ierr); } /* print matrix norm for checking */ ierr = MatNorm(F,NORM_1,&nrm);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"The 1-norm of f(A) is %g\n",(double)nrm);CHKERRQ(ierr); /* check FNEvaluateFunctionMatVec() */ ierr = MatCreateVecs(A,&v,&f0);CHKERRQ(ierr); ierr = MatGetColumnVector(F,f0,0);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(fn,A,v);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,f0);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&nrm);CHKERRQ(ierr); if (nrm>100*PETSC_MACHINE_EPSILON) { ierr = PetscPrintf(PETSC_COMM_WORLD,"Warning: the norm of f(A)*e_1-v is %g\n",(double)nrm);CHKERRQ(ierr); } ierr = MatDestroy(&F);CHKERRQ(ierr); ierr = VecDestroy(&v);CHKERRQ(ierr); ierr = VecDestroy(&f0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; FN f,g,h,e,r; Mat A; PetscInt i,j,n=10,np,nq; PetscScalar x,y,yp,*As,p[10],q[10]; char strx[50],str[50]; PetscViewer viewer; PetscBool verbose,inplace; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-verbose",&verbose);CHKERRQ(ierr); ierr = PetscOptionsHasName(NULL,NULL,"-inplace",&inplace);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Combined function, n=%D.\n",n);CHKERRQ(ierr); /* Create function */ /* e(x) = exp(x) */ ierr = FNCreate(PETSC_COMM_WORLD,&e);CHKERRQ(ierr); ierr = FNSetType(e,FNEXP);CHKERRQ(ierr); /* r(x) = x/(1+x^2) */ ierr = FNCreate(PETSC_COMM_WORLD,&r);CHKERRQ(ierr); ierr = FNSetType(r,FNRATIONAL);CHKERRQ(ierr); np = 2; nq = 3; p[0] = -1.0; p[1] = 0.0; q[0] = 1.0; q[1] = 0.0; q[2] = 1.0; ierr = FNRationalSetNumerator(r,np,p);CHKERRQ(ierr); ierr = FNRationalSetDenominator(r,nq,q);CHKERRQ(ierr); /* h(x) */ ierr = FNCreate(PETSC_COMM_WORLD,&h);CHKERRQ(ierr); ierr = FNSetType(h,FNCOMBINE);CHKERRQ(ierr); ierr = FNCombineSetChildren(h,FN_COMBINE_COMPOSE,r,e);CHKERRQ(ierr); /* g(x) = 1-x^2 */ ierr = FNCreate(PETSC_COMM_WORLD,&g);CHKERRQ(ierr); ierr = FNSetType(g,FNRATIONAL);CHKERRQ(ierr); np = 3; p[0] = -1.0; p[1] = 0.0; p[2] = 1.0; ierr = FNRationalSetNumerator(g,np,p);CHKERRQ(ierr); /* f(x) */ ierr = FNCreate(PETSC_COMM_WORLD,&f);CHKERRQ(ierr); ierr = FNSetType(f,FNCOMBINE);CHKERRQ(ierr); ierr = FNCombineSetChildren(f,FN_COMBINE_MULTIPLY,g,h);CHKERRQ(ierr); /* Set up viewer */ ierr = PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer);CHKERRQ(ierr); ierr = FNView(f,viewer);CHKERRQ(ierr); if (verbose) { ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr); } /* Scalar evaluation */ x = 2.2; ierr = SlepcSNPrintfScalar(strx,50,x,PETSC_FALSE);CHKERRQ(ierr); ierr = FNEvaluateFunction(f,x,&y);CHKERRQ(ierr); ierr = FNEvaluateDerivative(f,x,&yp);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,y,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f(%s)=%s\n",strx,str);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,yp,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," f'(%s)=%s\n",strx,str);CHKERRQ(ierr); /* Create matrices */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,n,n,NULL,&A);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)A,"A");CHKERRQ(ierr); /* Fill A with a symmetric Toeplitz matrix */ ierr = MatDenseGetArray(A,&As);CHKERRQ(ierr); for (i=0;i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../../../include/slepc/private/fnimpl.h ../../../../include/slepcfn.h
DIRS     = interface impls examples
LOCDIR   = src/sys/classes/fn/
MANSEC   = FN

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/index.html0000644000175000017500000000251213107004621017625 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

interface/
impls/
examples/
../../../../include/slepc/private/fnimpl.h
../../../../include/slepcfn.h
makefile
slepc-3.7.4/src/sys/classes/fn/impls/0000755000175000017500000000000013107004621016754 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/makefile0000644000175000017500000000223213107004621020453 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fnutil.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = combine exp log phi rational sqrt invsqrt LOCDIR = src/sys/classes/fn/impls/ MANSEC = FN include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/sqrt/0000755000175000017500000000000013107004621017745 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/sqrt/makefile0000644000175000017500000000216513107004621021451 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fnsqrt.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/impls/sqrt/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/sqrt/fnsqrt.c.html0000644000175000017500000002210413107004621022370 0ustar jromanjroman

Actual source code: fnsqrt.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Square root function  sqrt(x)

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/
 25: #include <slepcblaslapack.h>

 29: PetscErrorCode FNEvaluateFunction_Sqrt(FN fn,PetscScalar x,PetscScalar *y)
 30: {
 32:   *y = PetscSqrtScalar(x);
 33:   return(0);
 34: }

 38: PetscErrorCode FNEvaluateDerivative_Sqrt(FN fn,PetscScalar x,PetscScalar *y)
 39: {
 41:   if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value");
 42:   *y = 1.0/(2.0*PetscSqrtScalar(x));
 43:   return(0);
 44: }

 48: PetscErrorCode FNEvaluateFunctionMat_Sqrt(FN fn,Mat A,Mat B)
 49: {
 51:   PetscBLASInt   n;
 52:   PetscScalar    *T;
 53:   PetscInt       m;

 56:   if (A!=B) { MatCopy(A,B,SAME_NONZERO_PATTERN); }
 57:   MatDenseGetArray(B,&T);
 58:   MatGetSize(A,&m,NULL);
 59:   PetscBLASIntCast(m,&n);
 60:   SlepcSchurParlettSqrt(n,T,n,PETSC_FALSE);
 61:   MatDenseRestoreArray(B,&T);
 62:   return(0);
 63: }

 67: PetscErrorCode FNEvaluateFunctionMatVec_Sqrt(FN fn,Mat A,Vec v)
 68: {
 70:   PetscBLASInt   n;
 71:   PetscScalar    *T;
 72:   PetscInt       m;
 73:   Mat            B;

 76:   FN_AllocateWorkMat(fn,A,&B);
 77:   MatDenseGetArray(B,&T);
 78:   MatGetSize(A,&m,NULL);
 79:   PetscBLASIntCast(m,&n);
 80:   SlepcSchurParlettSqrt(n,T,n,PETSC_TRUE);
 81:   MatDenseRestoreArray(B,&T);
 82:   MatGetColumnVector(B,v,0);
 83:   FN_FreeWorkMat(fn,&B);
 84:   return(0);
 85: }

 89: PetscErrorCode FNView_Sqrt(FN fn,PetscViewer viewer)
 90: {
 92:   PetscBool      isascii;
 93:   char           str[50];

 96:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
 97:   if (isascii) {
 98:     if (fn->beta==(PetscScalar)1.0) {
 99:       if (fn->alpha==(PetscScalar)1.0) {
100:         PetscViewerASCIIPrintf(viewer,"  Square root: sqrt(x)\n");
101:       } else {
102:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
103:         PetscViewerASCIIPrintf(viewer,"  Square root: sqrt(%s*x)\n",str);
104:       }
105:     } else {
106:       SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);
107:       if (fn->alpha==(PetscScalar)1.0) {
108:         PetscViewerASCIIPrintf(viewer,"  Square root: %s*sqrt(x)\n",str);
109:       } else {
110:         PetscViewerASCIIPrintf(viewer,"  Square root: %s",str);
111:         PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
112:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
113:         PetscViewerASCIIPrintf(viewer,"*sqrt(%s*x)\n",str);
114:         PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
115:       }
116:     }
117:   }
118:   return(0);
119: }

123: PETSC_EXTERN PetscErrorCode FNCreate_Sqrt(FN fn)
124: {
126:   fn->ops->evaluatefunction       = FNEvaluateFunction_Sqrt;
127:   fn->ops->evaluatederivative     = FNEvaluateDerivative_Sqrt;
128:   fn->ops->evaluatefunctionmat    = FNEvaluateFunctionMat_Sqrt;
129:   fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Sqrt;
130:   fn->ops->view                   = FNView_Sqrt;
131:   return(0);
132: }

slepc-3.7.4/src/sys/classes/fn/impls/sqrt/makefile.html0000644000175000017500000000470613107004621022417 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fnsqrt.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/impls/sqrt/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/sqrt/fnsqrt.c0000644000175000017500000001110713107004621021426 0ustar jromanjroman/* Square root function sqrt(x) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction_Sqrt" PetscErrorCode FNEvaluateFunction_Sqrt(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; *y = PetscSqrtScalar(x); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative_Sqrt" PetscErrorCode FNEvaluateDerivative_Sqrt(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value"); *y = 1.0/(2.0*PetscSqrtScalar(x)); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMat_Sqrt" PetscErrorCode FNEvaluateFunctionMat_Sqrt(FN fn,Mat A,Mat B) { PetscErrorCode ierr; PetscBLASInt n; PetscScalar *T; PetscInt m; PetscFunctionBegin; if (A!=B) { ierr = MatCopy(A,B,SAME_NONZERO_PATTERN);CHKERRQ(ierr); } ierr = MatDenseGetArray(B,&T);CHKERRQ(ierr); ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ierr = SlepcSchurParlettSqrt(n,T,n,PETSC_FALSE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(B,&T);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMatVec_Sqrt" PetscErrorCode FNEvaluateFunctionMatVec_Sqrt(FN fn,Mat A,Vec v) { PetscErrorCode ierr; PetscBLASInt n; PetscScalar *T; PetscInt m; Mat B; PetscFunctionBegin; ierr = FN_AllocateWorkMat(fn,A,&B);CHKERRQ(ierr); ierr = MatDenseGetArray(B,&T);CHKERRQ(ierr); ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ierr = SlepcSchurParlettSqrt(n,T,n,PETSC_TRUE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(B,&T);CHKERRQ(ierr); ierr = MatGetColumnVector(B,v,0);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&B);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNView_Sqrt" PetscErrorCode FNView_Sqrt(FN fn,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (fn->beta==(PetscScalar)1.0) { if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Square root: sqrt(x)\n");CHKERRQ(ierr); } else { ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Square root: sqrt(%s*x)\n",str);CHKERRQ(ierr); } } else { ierr = SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);CHKERRQ(ierr); if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Square root: %s*sqrt(x)\n",str);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," Square root: %s",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"*sqrt(%s*x)\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate_Sqrt" PETSC_EXTERN PetscErrorCode FNCreate_Sqrt(FN fn) { PetscFunctionBegin; fn->ops->evaluatefunction = FNEvaluateFunction_Sqrt; fn->ops->evaluatederivative = FNEvaluateDerivative_Sqrt; fn->ops->evaluatefunctionmat = FNEvaluateFunctionMat_Sqrt; fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Sqrt; fn->ops->view = FNView_Sqrt; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/impls/sqrt/index.html0000644000175000017500000000213313107004621021741 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fnsqrt.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/log/0000755000175000017500000000000013107004621017535 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/log/makefile0000644000175000017500000000216313107004621021237 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fnlog.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/impls/log/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/log/fnlog.c.html0000644000175000017500000001550313107004621021755 0ustar jromanjroman

Actual source code: fnlog.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Logarithm function  log(x)

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/

 28: PetscErrorCode FNEvaluateFunction_Log(FN fn,PetscScalar x,PetscScalar *y)
 29: {
 31:   *y = PetscLogScalar(x);
 32:   return(0);
 33: }

 37: PetscErrorCode FNEvaluateDerivative_Log(FN fn,PetscScalar x,PetscScalar *y)
 38: {
 40:   if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value");
 41:   *y = 1.0/x;
 42:   return(0);
 43: }

 47: PetscErrorCode FNView_Log(FN fn,PetscViewer viewer)
 48: {
 50:   PetscBool      isascii;
 51:   char           str[50];

 54:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
 55:   if (isascii) {
 56:     if (fn->beta==(PetscScalar)1.0) {
 57:       if (fn->alpha==(PetscScalar)1.0) {
 58:         PetscViewerASCIIPrintf(viewer,"  Logarithm: log(x)\n");
 59:       } else {
 60:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
 61:         PetscViewerASCIIPrintf(viewer,"  Logarithm: log(%s*x)\n",str);
 62:       }
 63:     } else {
 64:       SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);
 65:       if (fn->alpha==(PetscScalar)1.0) {
 66:         PetscViewerASCIIPrintf(viewer,"  Logarithm: %s*log(x)\n",str);
 67:       } else {
 68:         PetscViewerASCIIPrintf(viewer,"  Logarithm: %s",str);
 69:         PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
 70:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
 71:         PetscViewerASCIIPrintf(viewer,"*log(%s*x)\n",str);
 72:         PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
 73:       }
 74:     }
 75:   }
 76:   return(0);
 77: }

 81: PETSC_EXTERN PetscErrorCode FNCreate_Log(FN fn)
 82: {
 84:   fn->ops->evaluatefunction    = FNEvaluateFunction_Log;
 85:   fn->ops->evaluatederivative  = FNEvaluateDerivative_Log;
 86:   fn->ops->view                = FNView_Log;
 87:   return(0);
 88: }

slepc-3.7.4/src/sys/classes/fn/impls/log/makefile.html0000644000175000017500000000470213107004621022203 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fnlog.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/impls/log/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/log/index.html0000644000175000017500000000212713107004621021534 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fnlog.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/log/fnlog.c0000644000175000017500000000615113107004621021011 0ustar jromanjroman/* Logarithm function log(x) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction_Log" PetscErrorCode FNEvaluateFunction_Log(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; *y = PetscLogScalar(x); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative_Log" PetscErrorCode FNEvaluateDerivative_Log(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value"); *y = 1.0/x; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNView_Log" PetscErrorCode FNView_Log(FN fn,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (fn->beta==(PetscScalar)1.0) { if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Logarithm: log(x)\n");CHKERRQ(ierr); } else { ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Logarithm: log(%s*x)\n",str);CHKERRQ(ierr); } } else { ierr = SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);CHKERRQ(ierr); if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Logarithm: %s*log(x)\n",str);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," Logarithm: %s",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"*log(%s*x)\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate_Log" PETSC_EXTERN PetscErrorCode FNCreate_Log(FN fn) { PetscFunctionBegin; fn->ops->evaluatefunction = FNEvaluateFunction_Log; fn->ops->evaluatederivative = FNEvaluateDerivative_Log; fn->ops->view = FNView_Log; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/impls/makefile.html0000644000175000017500000000474113107004621021425 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fnutil.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     = combine exp log phi rational sqrt invsqrt
LOCDIR   = src/sys/classes/fn/impls/
MANSEC   = FN

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/invsqrt/0000755000175000017500000000000013107004621020462 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/invsqrt/makefile0000644000175000017500000000217313107004621022165 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fninvsqrt.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/impls/invsqrt/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/invsqrt/fninvsqrt.c0000644000175000017500000001354513107004621022670 0ustar jromanjroman/* Inverse square root function x^(-1/2) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction_Invsqrt" PetscErrorCode FNEvaluateFunction_Invsqrt(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Function not defined in the requested value"); *y = 1.0/PetscSqrtScalar(x); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative_Invsqrt" PetscErrorCode FNEvaluateDerivative_Invsqrt(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value"); *y = -1.0/(2.0*PetscPowScalarReal(x,1.5)); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMat_Invsqrt" PetscErrorCode FNEvaluateFunctionMat_Invsqrt(FN fn,Mat A,Mat B) { PetscErrorCode ierr; PetscBLASInt n,ld,*ipiv,info; PetscScalar *Ba,*Wa; PetscInt m; Mat W; PetscFunctionBegin; ierr = FN_AllocateWorkMat(fn,A,&W);CHKERRQ(ierr); if (A!=B) { ierr = MatCopy(A,B,SAME_NONZERO_PATTERN);CHKERRQ(ierr); } ierr = MatDenseGetArray(B,&Ba);CHKERRQ(ierr); ierr = MatDenseGetArray(W,&Wa);CHKERRQ(ierr); /* compute B = sqrtm(A) */ ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ld = n; ierr = SlepcSchurParlettSqrt(n,Ba,n,PETSC_FALSE);CHKERRQ(ierr); /* compute B = A\B */ ierr = PetscMalloc1(ld,&ipiv);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&n,Wa,&ld,ipiv,Ba,&ld,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info); ierr = PetscFree(ipiv);CHKERRQ(ierr); ierr = MatDenseRestoreArray(W,&Wa);CHKERRQ(ierr); ierr = MatDenseRestoreArray(B,&Ba);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&W);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMatVec_Invsqrt" PetscErrorCode FNEvaluateFunctionMatVec_Invsqrt(FN fn,Mat A,Vec v) { PetscErrorCode ierr; PetscBLASInt n,ld,*ipiv,info,one=1; PetscScalar *Ba,*Wa; PetscInt m; Mat B,W; PetscFunctionBegin; ierr = FN_AllocateWorkMat(fn,A,&B);CHKERRQ(ierr); ierr = FN_AllocateWorkMat(fn,A,&W);CHKERRQ(ierr); ierr = MatDenseGetArray(B,&Ba);CHKERRQ(ierr); ierr = MatDenseGetArray(W,&Wa);CHKERRQ(ierr); /* compute B_1 = sqrtm(A)*e_1 */ ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ld = n; ierr = SlepcSchurParlettSqrt(n,Ba,n,PETSC_TRUE);CHKERRQ(ierr); /* compute B_1 = A\B_1 */ ierr = PetscMalloc1(ld,&ipiv);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&one,Wa,&ld,ipiv,Ba,&ld,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info); ierr = PetscFree(ipiv);CHKERRQ(ierr); ierr = MatDenseRestoreArray(W,&Wa);CHKERRQ(ierr); ierr = MatDenseRestoreArray(B,&Ba);CHKERRQ(ierr); ierr = MatGetColumnVector(B,v,0);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&W);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&B);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNView_Invsqrt" PetscErrorCode FNView_Invsqrt(FN fn,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isascii; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (fn->beta==(PetscScalar)1.0) { if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Inverse square root: x^(-1/2)\n");CHKERRQ(ierr); } else { ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Inverse square root: (%s*x)^(-1/2)\n",str);CHKERRQ(ierr); } } else { ierr = SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);CHKERRQ(ierr); if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Inverse square root: %s*x^(-1/2)\n",str);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," Inverse square root: %s",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"*(%s*x)^(-1/2)\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate_Invsqrt" PETSC_EXTERN PetscErrorCode FNCreate_Invsqrt(FN fn) { PetscFunctionBegin; fn->ops->evaluatefunction = FNEvaluateFunction_Invsqrt; fn->ops->evaluatederivative = FNEvaluateDerivative_Invsqrt; fn->ops->evaluatefunctionmat = FNEvaluateFunctionMat_Invsqrt; fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Invsqrt; fn->ops->view = FNView_Invsqrt; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/impls/invsqrt/makefile.html0000644000175000017500000000472213107004621023132 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fninvsqrt.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/impls/invsqrt/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/invsqrt/index.html0000644000175000017500000000214713107004621022463 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fninvsqrt.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/invsqrt/fninvsqrt.c.html0000644000175000017500000002624613107004621023635 0ustar jromanjroman

Actual source code: fninvsqrt.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Inverse square root function  x^(-1/2)

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/
 25: #include <slepcblaslapack.h>

 29: PetscErrorCode FNEvaluateFunction_Invsqrt(FN fn,PetscScalar x,PetscScalar *y)
 30: {
 32:   if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Function not defined in the requested value");
 33:   *y = 1.0/PetscSqrtScalar(x);
 34:   return(0);
 35: }

 39: PetscErrorCode FNEvaluateDerivative_Invsqrt(FN fn,PetscScalar x,PetscScalar *y)
 40: {
 42:   if (x==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value");
 43:   *y = -1.0/(2.0*PetscPowScalarReal(x,1.5));
 44:   return(0);
 45: }

 49: PetscErrorCode FNEvaluateFunctionMat_Invsqrt(FN fn,Mat A,Mat B)
 50: {
 52:   PetscBLASInt   n,ld,*ipiv,info;
 53:   PetscScalar    *Ba,*Wa;
 54:   PetscInt       m;
 55:   Mat            W;

 58:   FN_AllocateWorkMat(fn,A,&W);
 59:   if (A!=B) { MatCopy(A,B,SAME_NONZERO_PATTERN); }
 60:   MatDenseGetArray(B,&Ba);
 61:   MatDenseGetArray(W,&Wa);
 62:   /* compute B = sqrtm(A) */
 63:   MatGetSize(A,&m,NULL);
 64:   PetscBLASIntCast(m,&n);
 65:   ld = n;
 66:   SlepcSchurParlettSqrt(n,Ba,n,PETSC_FALSE);
 67:   /* compute B = A\B */
 68:   PetscMalloc1(ld,&ipiv);
 69:   PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&n,Wa,&ld,ipiv,Ba,&ld,&info));
 70:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
 71:   PetscFree(ipiv);
 72:   MatDenseRestoreArray(W,&Wa);
 73:   MatDenseRestoreArray(B,&Ba);
 74:   FN_FreeWorkMat(fn,&W);
 75:   return(0);
 76: }

 80: PetscErrorCode FNEvaluateFunctionMatVec_Invsqrt(FN fn,Mat A,Vec v)
 81: {
 83:   PetscBLASInt   n,ld,*ipiv,info,one=1;
 84:   PetscScalar    *Ba,*Wa;
 85:   PetscInt       m;
 86:   Mat            B,W;

 89:   FN_AllocateWorkMat(fn,A,&B);
 90:   FN_AllocateWorkMat(fn,A,&W);
 91:   MatDenseGetArray(B,&Ba);
 92:   MatDenseGetArray(W,&Wa);
 93:   /* compute B_1 = sqrtm(A)*e_1 */
 94:   MatGetSize(A,&m,NULL);
 95:   PetscBLASIntCast(m,&n);
 96:   ld = n;
 97:   SlepcSchurParlettSqrt(n,Ba,n,PETSC_TRUE);
 98:   /* compute B_1 = A\B_1 */
 99:   PetscMalloc1(ld,&ipiv);
100:   PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&one,Wa,&ld,ipiv,Ba,&ld,&info));
101:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
102:   PetscFree(ipiv);
103:   MatDenseRestoreArray(W,&Wa);
104:   MatDenseRestoreArray(B,&Ba);
105:   MatGetColumnVector(B,v,0);
106:   FN_FreeWorkMat(fn,&W);
107:   FN_FreeWorkMat(fn,&B);
108:   return(0);
109: }

113: PetscErrorCode FNView_Invsqrt(FN fn,PetscViewer viewer)
114: {
116:   PetscBool      isascii;
117:   char           str[50];

120:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
121:   if (isascii) {
122:     if (fn->beta==(PetscScalar)1.0) {
123:       if (fn->alpha==(PetscScalar)1.0) {
124:         PetscViewerASCIIPrintf(viewer,"  Inverse square root: x^(-1/2)\n");
125:       } else {
126:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
127:         PetscViewerASCIIPrintf(viewer,"  Inverse square root: (%s*x)^(-1/2)\n",str);
128:       }
129:     } else {
130:       SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);
131:       if (fn->alpha==(PetscScalar)1.0) {
132:         PetscViewerASCIIPrintf(viewer,"  Inverse square root: %s*x^(-1/2)\n",str);
133:       } else {
134:         PetscViewerASCIIPrintf(viewer,"  Inverse square root: %s",str);
135:         PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
136:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
137:         PetscViewerASCIIPrintf(viewer,"*(%s*x)^(-1/2)\n",str);
138:         PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
139:       }
140:     }
141:   }
142:   return(0);
143: }

147: PETSC_EXTERN PetscErrorCode FNCreate_Invsqrt(FN fn)
148: {
150:   fn->ops->evaluatefunction       = FNEvaluateFunction_Invsqrt;
151:   fn->ops->evaluatederivative     = FNEvaluateDerivative_Invsqrt;
152:   fn->ops->evaluatefunctionmat    = FNEvaluateFunctionMat_Invsqrt;
153:   fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Invsqrt;
154:   fn->ops->view                   = FNView_Invsqrt;
155:   return(0);
156: }

slepc-3.7.4/src/sys/classes/fn/impls/rational/0000755000175000017500000000000013107004621020565 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/rational/makefile0000644000175000017500000000217513107004621022272 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fnrational.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/impls/rational/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/rational/makefile.html0000644000175000017500000000472613107004621023241 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fnrational.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/impls/rational/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/rational/fnrational.c0000644000175000017500000004776013107004621023104 0ustar jromanjroman/* Rational function r(x) = p(x)/q(x), where p(x) and q(x) are polynomials - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #include typedef struct { PetscScalar *pcoeff; /* numerator coefficients */ PetscInt np; /* length of array pcoeff, p(x) has degree np-1 */ PetscScalar *qcoeff; /* denominator coefficients */ PetscInt nq; /* length of array qcoeff, q(x) has degree nq-1 */ } FN_RATIONAL; #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction_Rational" PetscErrorCode FNEvaluateFunction_Rational(FN fn,PetscScalar x,PetscScalar *y) { FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscInt i; PetscScalar p,q; PetscFunctionBegin; if (!ctx->np) p = 1.0; else { p = ctx->pcoeff[0]; for (i=1;inp;i++) p = ctx->pcoeff[i]+x*p; } if (!ctx->nq) *y = p; else { q = ctx->qcoeff[0]; for (i=1;inq;i++) q = ctx->qcoeff[i]+x*q; if (q==0.0) SETERRQ(PETSC_COMM_SELF,1,"Function not defined in the requested value"); *y = p/q; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMat_Private" static PetscErrorCode FNEvaluateFunctionMat_Private(FN fn,PetscScalar *Aa,PetscScalar *Ba,PetscInt m,PetscBool firstonly) { #if defined(PETSC_MISSING_LAPACK_GESV) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV - Lapack routines are unavailable"); #else PetscErrorCode ierr; FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscBLASInt n,k,ld,*ipiv,info; PetscInt i,j; PetscScalar *W,*P,*Q,one=1.0,zero=0.0; PetscFunctionBegin; ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ld = n; k = firstonly? 1: n; if (Aa==Ba) { ierr = PetscMalloc4(m*m,&P,m*m,&Q,m*m,&W,ld,&ipiv);CHKERRQ(ierr); } else { P = Ba; ierr = PetscMalloc3(m*m,&Q,m*m,&W,ld,&ipiv);CHKERRQ(ierr); } ierr = PetscMemzero(P,m*m*sizeof(PetscScalar));CHKERRQ(ierr); if (!ctx->np) { for (i=0;ipcoeff[0]; for (j=1;jnp;j++) { PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,P,&ld,Aa,&ld,&zero,W,&ld)); ierr = PetscMemcpy(P,W,m*m*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;ipcoeff[j]; } } if (ctx->nq) { ierr = PetscMemzero(Q,m*m*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;iqcoeff[0]; for (j=1;jnq;j++) { PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,Q,&ld,Aa,&ld,&zero,W,&ld)); ierr = PetscMemcpy(Q,W,m*m*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;iqcoeff[j]; } PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&k,Q,&ld,ipiv,P,&ld,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info); } if (Aa==Ba) { ierr = PetscMemcpy(Aa,P,m*k*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscFree4(P,Q,W,ipiv);CHKERRQ(ierr); } else { ierr = PetscFree3(Q,W,ipiv);CHKERRQ(ierr); } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMat_Rational" PetscErrorCode FNEvaluateFunctionMat_Rational(FN fn,Mat A,Mat B) { PetscErrorCode ierr; PetscInt m; PetscScalar *Aa,*Ba; PetscFunctionBegin; ierr = MatDenseGetArray(A,&Aa);CHKERRQ(ierr); ierr = MatDenseGetArray(B,&Ba);CHKERRQ(ierr); ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat_Private(fn,Aa,Ba,m,PETSC_FALSE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(A,&Aa);CHKERRQ(ierr); ierr = MatDenseRestoreArray(B,&Ba);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMatVec_Rational" PetscErrorCode FNEvaluateFunctionMatVec_Rational(FN fn,Mat A,Vec v) { PetscErrorCode ierr; PetscInt m; PetscScalar *Aa,*Ba; Mat B; PetscFunctionBegin; ierr = FN_AllocateWorkMat(fn,A,&B);CHKERRQ(ierr); ierr = MatDenseGetArray(A,&Aa);CHKERRQ(ierr); ierr = MatDenseGetArray(B,&Ba);CHKERRQ(ierr); ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat_Private(fn,Aa,Ba,m,PETSC_TRUE);CHKERRQ(ierr); ierr = MatDenseRestoreArray(A,&Aa);CHKERRQ(ierr); ierr = MatDenseRestoreArray(B,&Ba);CHKERRQ(ierr); ierr = MatGetColumnVector(B,v,0);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&B);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative_Rational" PetscErrorCode FNEvaluateDerivative_Rational(FN fn,PetscScalar x,PetscScalar *yp) { FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscInt i; PetscScalar p,q,pp,qp; PetscFunctionBegin; if (!ctx->np) { p = 1.0; pp = 0.0; } else { p = ctx->pcoeff[0]; pp = 0.0; for (i=1;inp;i++) { pp = p+x*pp; p = ctx->pcoeff[i]+x*p; } } if (!ctx->nq) *yp = pp; else { q = ctx->qcoeff[0]; qp = 0.0; for (i=1;inq;i++) { qp = q+x*qp; q = ctx->qcoeff[i]+x*q; } if (q==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value"); *yp = (pp*q-p*qp)/(q*q); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNView_Rational" PetscErrorCode FNView_Rational(FN fn,PetscViewer viewer) { PetscErrorCode ierr; FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscBool isascii; PetscInt i; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (fn->alpha!=(PetscScalar)1.0 || fn->beta!=(PetscScalar)1.0) { ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Scale factors: alpha=%s,",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,fn->beta,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," beta=%s\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } if (!ctx->nq) { if (!ctx->np) { ierr = PetscViewerASCIIPrintf(viewer," Constant: 1.0\n");CHKERRQ(ierr); } else if (ctx->np==1) { ierr = SlepcSNPrintfScalar(str,50,ctx->pcoeff[0],PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Constant: %s\n",str);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," Polynomial: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;inp-1;i++) { ierr = SlepcSNPrintfScalar(str,50,ctx->pcoeff[i],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->np-i-1);CHKERRQ(ierr); } ierr = SlepcSNPrintfScalar(str,50,ctx->pcoeff[ctx->np-1],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } } else if (!ctx->np) { ierr = PetscViewerASCIIPrintf(viewer," Inverse polinomial: 1 / (");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;inq-1;i++) { ierr = SlepcSNPrintfScalar(str,50,ctx->qcoeff[i],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->nq-i-1);CHKERRQ(ierr); } ierr = SlepcSNPrintfScalar(str,50,ctx->qcoeff[ctx->nq-1],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s)\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," Rational function: (");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;inp-1;i++) { ierr = SlepcSNPrintfScalar(str,50,ctx->pcoeff[i],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->np-i-1);CHKERRQ(ierr); } ierr = SlepcSNPrintfScalar(str,50,ctx->pcoeff[ctx->np-1],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s) / (",str);CHKERRQ(ierr); for (i=0;inq-1;i++) { ierr = SlepcSNPrintfScalar(str,50,ctx->qcoeff[i],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->nq-i-1);CHKERRQ(ierr); } ierr = SlepcSNPrintfScalar(str,50,ctx->qcoeff[ctx->nq-1],PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s)\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalSetNumerator_Rational" static PetscErrorCode FNRationalSetNumerator_Rational(FN fn,PetscInt np,PetscScalar *pcoeff) { PetscErrorCode ierr; FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscInt i; PetscFunctionBegin; ctx->np = np; ierr = PetscFree(ctx->pcoeff);CHKERRQ(ierr); if (np) { ierr = PetscMalloc1(np,&ctx->pcoeff);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)fn,np*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;ipcoeff[i] = pcoeff[i]; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalSetNumerator" /*@ FNRationalSetNumerator - Sets the parameters defining the numerator of the rational function. Logically Collective on FN Input Parameters: + fn - the math function context . np - number of coefficients - pcoeff - coefficients (array of scalar values) Notes: Let the rational function r(x) = p(x)/q(x), where p(x) and q(x) are polynomials. This function provides the coefficients of the numerator p(x). Hence, p(x) is of degree np-1. If np is zero, then the numerator is assumed to be p(x)=1. In polynomials, high order coefficients are stored in the first positions of the array, e.g. to represent x^2-3 use {1,0,-3}. Level: intermediate .seealso: FNRationalSetDenominator(), FNRationalGetNumerator() @*/ PetscErrorCode FNRationalSetNumerator(FN fn,PetscInt np,PetscScalar *pcoeff) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidLogicalCollectiveInt(fn,np,2); if (np<0) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Argument np cannot be negative"); if (np) PetscValidPointer(pcoeff,3); ierr = PetscTryMethod(fn,"FNRationalSetNumerator_C",(FN,PetscInt,PetscScalar*),(fn,np,pcoeff));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalGetNumerator_Rational" static PetscErrorCode FNRationalGetNumerator_Rational(FN fn,PetscInt *np,PetscScalar *pcoeff[]) { PetscErrorCode ierr; FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscInt i; PetscFunctionBegin; if (np) *np = ctx->np; if (pcoeff) { if (!ctx->np) *pcoeff = NULL; else { ierr = PetscMalloc1(ctx->np,pcoeff);CHKERRQ(ierr); for (i=0;inp;i++) (*pcoeff)[i] = ctx->pcoeff[i]; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalGetNumerator" /*@ FNRationalGetNumerator - Gets the parameters that define the numerator of the rational function. Not Collective Input Parameter: . fn - the math function context Output Parameters: + np - number of coefficients - pcoeff - coefficients (array of scalar values, length nq) Notes: The values passed by user with FNRationalSetNumerator() are returned (or null pointers otherwise). The pcoeff array should be freed by the user when no longer needed. Level: intermediate .seealso: FNRationalSetNumerator() @*/ PetscErrorCode FNRationalGetNumerator(FN fn,PetscInt *np,PetscScalar *pcoeff[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); ierr = PetscUseMethod(fn,"FNRationalGetNumerator_C",(FN,PetscInt*,PetscScalar**),(fn,np,pcoeff));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalSetDenominator_Rational" static PetscErrorCode FNRationalSetDenominator_Rational(FN fn,PetscInt nq,PetscScalar *qcoeff) { PetscErrorCode ierr; FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscInt i; PetscFunctionBegin; ctx->nq = nq; ierr = PetscFree(ctx->qcoeff);CHKERRQ(ierr); if (nq) { ierr = PetscMalloc1(nq,&ctx->qcoeff);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)fn,nq*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;iqcoeff[i] = qcoeff[i]; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalSetDenominator" /*@ FNRationalSetDenominator - Sets the parameters defining the denominator of the rational function. Logically Collective on FN Input Parameters: + fn - the math function context . nq - number of coefficients - qcoeff - coefficients (array of scalar values) Notes: Let the rational function r(x) = p(x)/q(x), where p(x) and q(x) are polynomials. This function provides the coefficients of the denominator q(x). Hence, q(x) is of degree nq-1. If nq is zero, then the function is assumed to be polynomial, r(x) = p(x). In polynomials, high order coefficients are stored in the first positions of the array, e.g. to represent x^2-3 use {1,0,-3}. Level: intermediate .seealso: FNRationalSetNumerator(), FNRationalGetDenominator() @*/ PetscErrorCode FNRationalSetDenominator(FN fn,PetscInt nq,PetscScalar *qcoeff) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidLogicalCollectiveInt(fn,nq,2); if (nq<0) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Argument nq cannot be negative"); if (nq) PetscValidPointer(qcoeff,3); ierr = PetscTryMethod(fn,"FNRationalSetDenominator_C",(FN,PetscInt,PetscScalar*),(fn,nq,qcoeff));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalGetDenominator_Rational" static PetscErrorCode FNRationalGetDenominator_Rational(FN fn,PetscInt *nq,PetscScalar *qcoeff[]) { PetscErrorCode ierr; FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscInt i; PetscFunctionBegin; if (nq) *nq = ctx->nq; if (qcoeff) { if (!ctx->nq) *qcoeff = NULL; else { ierr = PetscMalloc1(ctx->nq,qcoeff);CHKERRQ(ierr); for (i=0;inq;i++) (*qcoeff)[i] = ctx->qcoeff[i]; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNRationalGetDenominator" /*@ FNRationalGetDenominator - Gets the parameters that define the denominator of the rational function. Not Collective Input Parameter: . fn - the math function context Output Parameters: + nq - number of coefficients - qcoeff - coefficients (array of scalar values, length nq) Notes: The values passed by user with FNRationalSetDenominator() are returned (or null pointers otherwise). The qcoeff array should be freed by the user when no longer needed. Level: intermediate .seealso: FNRationalSetDenominator() @*/ PetscErrorCode FNRationalGetDenominator(FN fn,PetscInt *nq,PetscScalar *qcoeff[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); ierr = PetscUseMethod(fn,"FNRationalGetDenominator_C",(FN,PetscInt*,PetscScalar**),(fn,nq,qcoeff));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNSetFromOptions_Rational" PetscErrorCode FNSetFromOptions_Rational(PetscOptionItems *PetscOptionsObject,FN fn) { PetscErrorCode ierr; #define PARMAX 10 PetscScalar array[PARMAX]; PetscInt i,k; PetscBool flg; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"FN Rational Options");CHKERRQ(ierr); k = PARMAX; for (i=0;idata,*ctx2 = (FN_RATIONAL*)(*newfn)->data; PetscInt i; PetscFunctionBegin; ctx2->np = ctx->np; if (ctx->np) { ierr = PetscMalloc1(ctx->np,&ctx2->pcoeff);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)(*newfn),ctx->np*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;inp;i++) ctx2->pcoeff[i] = ctx->pcoeff[i]; } ctx2->nq = ctx->nq; if (ctx->nq) { ierr = PetscMalloc1(ctx->nq,&ctx2->qcoeff);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)(*newfn),ctx->nq*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;inq;i++) ctx2->qcoeff[i] = ctx->qcoeff[i]; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNDestroy_Rational" PetscErrorCode FNDestroy_Rational(FN fn) { PetscErrorCode ierr; FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data; PetscFunctionBegin; ierr = PetscFree(ctx->pcoeff);CHKERRQ(ierr); ierr = PetscFree(ctx->qcoeff);CHKERRQ(ierr); ierr = PetscFree(fn->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetNumerator_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetNumerator_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetDenominator_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetDenominator_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate_Rational" PETSC_EXTERN PetscErrorCode FNCreate_Rational(FN fn) { PetscErrorCode ierr; FN_RATIONAL *ctx; PetscFunctionBegin; ierr = PetscNewLog(fn,&ctx);CHKERRQ(ierr); fn->data = (void*)ctx; fn->ops->evaluatefunction = FNEvaluateFunction_Rational; fn->ops->evaluatederivative = FNEvaluateDerivative_Rational; fn->ops->evaluatefunctionmat = FNEvaluateFunctionMat_Rational; fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Rational; fn->ops->setfromoptions = FNSetFromOptions_Rational; fn->ops->view = FNView_Rational; fn->ops->duplicate = FNDuplicate_Rational; fn->ops->destroy = FNDestroy_Rational; ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetNumerator_C",FNRationalSetNumerator_Rational);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetNumerator_C",FNRationalGetNumerator_Rational);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetDenominator_C",FNRationalSetDenominator_Rational);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetDenominator_C",FNRationalGetDenominator_Rational);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/impls/rational/index.html0000644000175000017500000000215313107004621022563 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fnrational.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/rational/ftn-auto/0000755000175000017500000000000013107004621022322 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/rational/ftn-auto/makefile0000644000175000017500000000040213107004621024016 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = fnrationalf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/fn/impls/rational/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/rational/ftn-auto/fnrationalf.c0000644000175000017500000000460713107004621025000 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* fnrational.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnrationalsetnumerator_ FNRATIONALSETNUMERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnrationalsetnumerator_ fnrationalsetnumerator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnrationalgetnumerator_ FNRATIONALGETNUMERATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnrationalgetnumerator_ fnrationalgetnumerator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnrationalsetdenominator_ FNRATIONALSETDENOMINATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnrationalsetdenominator_ fnrationalsetdenominator #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnrationalgetdenominator_ FNRATIONALGETDENOMINATOR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnrationalgetdenominator_ fnrationalgetdenominator #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL fnrationalsetnumerator_(FN fn,PetscInt *np,PetscScalar *pcoeff, int *__ierr ){ *__ierr = FNRationalSetNumerator( (FN)PetscToPointer((fn) ),*np,pcoeff); } PETSC_EXTERN void PETSC_STDCALL fnrationalgetnumerator_(FN fn,PetscInt *np,PetscScalar *pcoeff[], int *__ierr ){ *__ierr = FNRationalGetNumerator( (FN)PetscToPointer((fn) ),np,pcoeff); } PETSC_EXTERN void PETSC_STDCALL fnrationalsetdenominator_(FN fn,PetscInt *nq,PetscScalar *qcoeff, int *__ierr ){ *__ierr = FNRationalSetDenominator( (FN)PetscToPointer((fn) ),*nq,qcoeff); } PETSC_EXTERN void PETSC_STDCALL fnrationalgetdenominator_(FN fn,PetscInt *nq,PetscScalar *qcoeff[], int *__ierr ){ *__ierr = FNRationalGetDenominator( (FN)PetscToPointer((fn) ),nq,qcoeff); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/fn/impls/rational/fnrational.c.html0000644000175000017500000012246213107004621024040 0ustar jromanjroman

Actual source code: fnrational.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Rational function  r(x) = p(x)/q(x), where p(x) and q(x) are polynomials

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/
 25: #include <slepcblaslapack.h>

 27: typedef struct {
 28:   PetscScalar *pcoeff;    /* numerator coefficients */
 29:   PetscInt    np;         /* length of array pcoeff, p(x) has degree np-1 */
 30:   PetscScalar *qcoeff;    /* denominator coefficients */
 31:   PetscInt    nq;         /* length of array qcoeff, q(x) has degree nq-1 */
 32: } FN_RATIONAL;

 36: PetscErrorCode FNEvaluateFunction_Rational(FN fn,PetscScalar x,PetscScalar *y)
 37: {
 38:   FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data;
 39:   PetscInt    i;
 40:   PetscScalar p,q;

 43:   if (!ctx->np) p = 1.0;
 44:   else {
 45:     p = ctx->pcoeff[0];
 46:     for (i=1;i<ctx->np;i++)
 47:       p = ctx->pcoeff[i]+x*p;
 48:   }
 49:   if (!ctx->nq) *y = p;
 50:   else {
 51:     q = ctx->qcoeff[0];
 52:     for (i=1;i<ctx->nq;i++)
 53:       q = ctx->qcoeff[i]+x*q;
 54:     if (q==0.0) SETERRQ(PETSC_COMM_SELF,1,"Function not defined in the requested value");
 55:     *y = p/q;
 56:   }
 57:   return(0);
 58: }

 62: static PetscErrorCode FNEvaluateFunctionMat_Private(FN fn,PetscScalar *Aa,PetscScalar *Ba,PetscInt m,PetscBool firstonly)
 63: {
 64: #if defined(PETSC_MISSING_LAPACK_GESV)
 66:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV - Lapack routines are unavailable");
 67: #else
 69:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data;
 70:   PetscBLASInt   n,k,ld,*ipiv,info;
 71:   PetscInt       i,j;
 72:   PetscScalar    *W,*P,*Q,one=1.0,zero=0.0;

 75:   PetscBLASIntCast(m,&n);
 76:   ld = n;
 77:   k  = firstonly? 1: n;
 78:   if (Aa==Ba) {
 79:     PetscMalloc4(m*m,&P,m*m,&Q,m*m,&W,ld,&ipiv);
 80:   } else {
 81:     P = Ba;
 82:     PetscMalloc3(m*m,&Q,m*m,&W,ld,&ipiv);
 83:   }
 84:   PetscMemzero(P,m*m*sizeof(PetscScalar));
 85:   if (!ctx->np) {
 86:     for (i=0;i<m;i++) P[i+i*ld] = 1.0;
 87:   } else {
 88:     for (i=0;i<m;i++) P[i+i*ld] = ctx->pcoeff[0];
 89:     for (j=1;j<ctx->np;j++) {
 90:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,P,&ld,Aa,&ld,&zero,W,&ld));
 91:       PetscMemcpy(P,W,m*m*sizeof(PetscScalar));
 92:       for (i=0;i<m;i++) P[i+i*ld] += ctx->pcoeff[j];
 93:     }
 94:   }
 95:   if (ctx->nq) {
 96:     PetscMemzero(Q,m*m*sizeof(PetscScalar));
 97:     for (i=0;i<m;i++) Q[i+i*ld] = ctx->qcoeff[0];
 98:     for (j=1;j<ctx->nq;j++) {
 99:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,Q,&ld,Aa,&ld,&zero,W,&ld));
100:       PetscMemcpy(Q,W,m*m*sizeof(PetscScalar));
101:       for (i=0;i<m;i++) Q[i+i*ld] += ctx->qcoeff[j];
102:     }
103:     PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&k,Q,&ld,ipiv,P,&ld,&info));
104:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
105:   }
106:   if (Aa==Ba) {
107:     PetscMemcpy(Aa,P,m*k*sizeof(PetscScalar));
108:     PetscFree4(P,Q,W,ipiv);
109:   } else {
110:     PetscFree3(Q,W,ipiv);
111:   }
112:   return(0);
113: #endif
114: }

118: PetscErrorCode FNEvaluateFunctionMat_Rational(FN fn,Mat A,Mat B)
119: {
121:   PetscInt       m;
122:   PetscScalar    *Aa,*Ba;

125:   MatDenseGetArray(A,&Aa);
126:   MatDenseGetArray(B,&Ba);
127:   MatGetSize(A,&m,NULL);
128:   FNEvaluateFunctionMat_Private(fn,Aa,Ba,m,PETSC_FALSE);
129:   MatDenseRestoreArray(A,&Aa);
130:   MatDenseRestoreArray(B,&Ba);
131:   return(0);
132: }

136: PetscErrorCode FNEvaluateFunctionMatVec_Rational(FN fn,Mat A,Vec v)
137: {
139:   PetscInt       m;
140:   PetscScalar    *Aa,*Ba;
141:   Mat            B;

144:   FN_AllocateWorkMat(fn,A,&B);
145:   MatDenseGetArray(A,&Aa);
146:   MatDenseGetArray(B,&Ba);
147:   MatGetSize(A,&m,NULL);
148:   FNEvaluateFunctionMat_Private(fn,Aa,Ba,m,PETSC_TRUE);
149:   MatDenseRestoreArray(A,&Aa);
150:   MatDenseRestoreArray(B,&Ba);
151:   MatGetColumnVector(B,v,0);
152:   FN_FreeWorkMat(fn,&B);
153:   return(0);
154: }

158: PetscErrorCode FNEvaluateDerivative_Rational(FN fn,PetscScalar x,PetscScalar *yp)
159: {
160:   FN_RATIONAL *ctx = (FN_RATIONAL*)fn->data;
161:   PetscInt    i;
162:   PetscScalar p,q,pp,qp;

165:   if (!ctx->np) {
166:     p = 1.0;
167:     pp = 0.0;
168:   } else {
169:     p = ctx->pcoeff[0];
170:     pp = 0.0;
171:     for (i=1;i<ctx->np;i++) {
172:       pp = p+x*pp;
173:       p = ctx->pcoeff[i]+x*p;
174:     }
175:   }
176:   if (!ctx->nq) *yp = pp;
177:   else {
178:     q = ctx->qcoeff[0];
179:     qp = 0.0;
180:     for (i=1;i<ctx->nq;i++) {
181:       qp = q+x*qp;
182:       q = ctx->qcoeff[i]+x*q;
183:     }
184:     if (q==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value");
185:     *yp = (pp*q-p*qp)/(q*q);
186:   }
187:   return(0);
188: }

192: PetscErrorCode FNView_Rational(FN fn,PetscViewer viewer)
193: {
195:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data;
196:   PetscBool      isascii;
197:   PetscInt       i;
198:   char           str[50];

201:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
202:   if (isascii) {
203:     if (fn->alpha!=(PetscScalar)1.0 || fn->beta!=(PetscScalar)1.0) {
204:       SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_FALSE);
205:       PetscViewerASCIIPrintf(viewer,"  Scale factors: alpha=%s,",str);
206:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
207:       SlepcSNPrintfScalar(str,50,fn->beta,PETSC_FALSE);
208:       PetscViewerASCIIPrintf(viewer," beta=%s\n",str);
209:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
210:     }
211:     if (!ctx->nq) {
212:       if (!ctx->np) {
213:         PetscViewerASCIIPrintf(viewer,"  Constant: 1.0\n");
214:       } else if (ctx->np==1) {
215:         SlepcSNPrintfScalar(str,50,ctx->pcoeff[0],PETSC_FALSE);
216:         PetscViewerASCIIPrintf(viewer,"  Constant: %s\n",str);
217:       } else {
218:         PetscViewerASCIIPrintf(viewer,"  Polynomial: ");
219:         PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
220:         for (i=0;i<ctx->np-1;i++) {
221:           SlepcSNPrintfScalar(str,50,ctx->pcoeff[i],PETSC_TRUE);
222:           PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->np-i-1);
223:         }
224:         SlepcSNPrintfScalar(str,50,ctx->pcoeff[ctx->np-1],PETSC_TRUE);
225:         PetscViewerASCIIPrintf(viewer,"%s\n",str);
226:         PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
227:       }
228:     } else if (!ctx->np) {
229:       PetscViewerASCIIPrintf(viewer,"  Inverse polinomial: 1 / (");
230:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
231:       for (i=0;i<ctx->nq-1;i++) {
232:         SlepcSNPrintfScalar(str,50,ctx->qcoeff[i],PETSC_TRUE);
233:         PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->nq-i-1);
234:       }
235:       SlepcSNPrintfScalar(str,50,ctx->qcoeff[ctx->nq-1],PETSC_TRUE);
236:       PetscViewerASCIIPrintf(viewer,"%s)\n",str);
237:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
238:     } else {
239:       PetscViewerASCIIPrintf(viewer,"  Rational function: (");
240:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
241:       for (i=0;i<ctx->np-1;i++) {
242:         SlepcSNPrintfScalar(str,50,ctx->pcoeff[i],PETSC_TRUE);
243:         PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->np-i-1);
244:       }
245:       SlepcSNPrintfScalar(str,50,ctx->pcoeff[ctx->np-1],PETSC_TRUE);
246:       PetscViewerASCIIPrintf(viewer,"%s) / (",str);
247:       for (i=0;i<ctx->nq-1;i++) {
248:         SlepcSNPrintfScalar(str,50,ctx->qcoeff[i],PETSC_TRUE);
249:         PetscViewerASCIIPrintf(viewer,"%s*x^%1D",str,ctx->nq-i-1);
250:       }
251:       SlepcSNPrintfScalar(str,50,ctx->qcoeff[ctx->nq-1],PETSC_TRUE);
252:       PetscViewerASCIIPrintf(viewer,"%s)\n",str);
253:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
254:     }
255:   }
256:   return(0);
257: }

261: static PetscErrorCode FNRationalSetNumerator_Rational(FN fn,PetscInt np,PetscScalar *pcoeff)
262: {
264:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data;
265:   PetscInt       i;

268:   ctx->np = np;
269:   PetscFree(ctx->pcoeff);
270:   if (np) {
271:     PetscMalloc1(np,&ctx->pcoeff);
272:     PetscLogObjectMemory((PetscObject)fn,np*sizeof(PetscScalar));
273:     for (i=0;i<np;i++) ctx->pcoeff[i] = pcoeff[i];
274:   }
275:   return(0);
276: }

280: /*@
281:    FNRationalSetNumerator - Sets the parameters defining the numerator of the
282:    rational function.

284:    Logically Collective on FN

286:    Input Parameters:
287: +  fn     - the math function context
288: .  np     - number of coefficients
289: -  pcoeff - coefficients (array of scalar values)

291:    Notes:
292:    Let the rational function r(x) = p(x)/q(x), where p(x) and q(x) are polynomials.
293:    This function provides the coefficients of the numerator p(x).
294:    Hence, p(x) is of degree np-1.
295:    If np is zero, then the numerator is assumed to be p(x)=1.

297:    In polynomials, high order coefficients are stored in the first positions
298:    of the array, e.g. to represent x^2-3 use {1,0,-3}.

300:    Level: intermediate

302: .seealso: FNRationalSetDenominator(), FNRationalGetNumerator()
303: @*/
304: PetscErrorCode FNRationalSetNumerator(FN fn,PetscInt np,PetscScalar *pcoeff)
305: {

311:   if (np<0) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Argument np cannot be negative");
313:   PetscTryMethod(fn,"FNRationalSetNumerator_C",(FN,PetscInt,PetscScalar*),(fn,np,pcoeff));
314:   return(0);
315: }

319: static PetscErrorCode FNRationalGetNumerator_Rational(FN fn,PetscInt *np,PetscScalar *pcoeff[])
320: {
322:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data;
323:   PetscInt       i;

326:   if (np) *np = ctx->np;
327:   if (pcoeff) {
328:     if (!ctx->np) *pcoeff = NULL;
329:     else {
330:       PetscMalloc1(ctx->np,pcoeff);
331:       for (i=0;i<ctx->np;i++) (*pcoeff)[i] = ctx->pcoeff[i];
332:     }
333:   }
334:   return(0);
335: }

339: /*@
340:    FNRationalGetNumerator - Gets the parameters that define the numerator of the
341:    rational function.

343:    Not Collective

345:    Input Parameter:
346: .  fn     - the math function context

348:    Output Parameters:
349: +  np     - number of coefficients
350: -  pcoeff - coefficients (array of scalar values, length nq)

352:    Notes:
353:    The values passed by user with FNRationalSetNumerator() are returned (or null
354:    pointers otherwise).
355:    The pcoeff array should be freed by the user when no longer needed.

357:    Level: intermediate

359: .seealso: FNRationalSetNumerator()
360: @*/
361: PetscErrorCode FNRationalGetNumerator(FN fn,PetscInt *np,PetscScalar *pcoeff[])
362: {

367:   PetscUseMethod(fn,"FNRationalGetNumerator_C",(FN,PetscInt*,PetscScalar**),(fn,np,pcoeff));
368:   return(0);
369: }

373: static PetscErrorCode FNRationalSetDenominator_Rational(FN fn,PetscInt nq,PetscScalar *qcoeff)
374: {
376:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data;
377:   PetscInt       i;

380:   ctx->nq = nq;
381:   PetscFree(ctx->qcoeff);
382:   if (nq) {
383:     PetscMalloc1(nq,&ctx->qcoeff);
384:     PetscLogObjectMemory((PetscObject)fn,nq*sizeof(PetscScalar));
385:     for (i=0;i<nq;i++) ctx->qcoeff[i] = qcoeff[i];
386:   }
387:   return(0);
388: }

392: /*@
393:    FNRationalSetDenominator - Sets the parameters defining the denominator of the
394:    rational function.

396:    Logically Collective on FN

398:    Input Parameters:
399: +  fn     - the math function context
400: .  nq     - number of coefficients
401: -  qcoeff - coefficients (array of scalar values)

403:    Notes:
404:    Let the rational function r(x) = p(x)/q(x), where p(x) and q(x) are polynomials.
405:    This function provides the coefficients of the denominator q(x).
406:    Hence, q(x) is of degree nq-1.
407:    If nq is zero, then the function is assumed to be polynomial, r(x) = p(x).

409:    In polynomials, high order coefficients are stored in the first positions
410:    of the array, e.g. to represent x^2-3 use {1,0,-3}.

412:    Level: intermediate

414: .seealso: FNRationalSetNumerator(), FNRationalGetDenominator()
415: @*/
416: PetscErrorCode FNRationalSetDenominator(FN fn,PetscInt nq,PetscScalar *qcoeff)
417: {

423:   if (nq<0) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Argument nq cannot be negative");
425:   PetscTryMethod(fn,"FNRationalSetDenominator_C",(FN,PetscInt,PetscScalar*),(fn,nq,qcoeff));
426:   return(0);
427: }

431: static PetscErrorCode FNRationalGetDenominator_Rational(FN fn,PetscInt *nq,PetscScalar *qcoeff[])
432: {
434:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data;
435:   PetscInt       i;

438:   if (nq) *nq = ctx->nq;
439:   if (qcoeff) {
440:     if (!ctx->nq) *qcoeff = NULL;
441:     else {
442:       PetscMalloc1(ctx->nq,qcoeff);
443:       for (i=0;i<ctx->nq;i++) (*qcoeff)[i] = ctx->qcoeff[i];
444:     }
445:   }
446:   return(0);
447: }

451: /*@
452:    FNRationalGetDenominator - Gets the parameters that define the denominator of the
453:    rational function.

455:    Not Collective

457:    Input Parameter:
458: .  fn     - the math function context

460:    Output Parameters:
461: +  nq     - number of coefficients
462: -  qcoeff - coefficients (array of scalar values, length nq)

464:    Notes:
465:    The values passed by user with FNRationalSetDenominator() are returned (or null
466:    pointers otherwise).
467:    The qcoeff array should be freed by the user when no longer needed.

469:    Level: intermediate

471: .seealso: FNRationalSetDenominator()
472: @*/
473: PetscErrorCode FNRationalGetDenominator(FN fn,PetscInt *nq,PetscScalar *qcoeff[])
474: {

479:   PetscUseMethod(fn,"FNRationalGetDenominator_C",(FN,PetscInt*,PetscScalar**),(fn,nq,qcoeff));
480:   return(0);
481: }

485: PetscErrorCode FNSetFromOptions_Rational(PetscOptionItems *PetscOptionsObject,FN fn)
486: {
488: #define PARMAX 10
489:   PetscScalar    array[PARMAX];
490:   PetscInt       i,k;
491:   PetscBool      flg;

494:   PetscOptionsHead(PetscOptionsObject,"FN Rational Options");

496:   k = PARMAX;
497:   for (i=0;i<k;i++) array[i] = 0;
498:   PetscOptionsScalarArray("-fn_rational_numerator","Numerator coefficients (one or more scalar values separated with a comma without spaces)","FNRationalSetNumerator",array,&k,&flg);
499:   if (flg) {
500:     FNRationalSetNumerator(fn,k,array);
501:   }

503:   k = PARMAX;
504:   for (i=0;i<k;i++) array[i] = 0;
505:   PetscOptionsScalarArray("-fn_rational_denominator","Denominator coefficients (one or more scalar values separated with a comma without spaces)","FNRationalSetDenominator",array,&k,&flg);
506:   if (flg) {
507:     FNRationalSetDenominator(fn,k,array);
508:   }

510:   PetscOptionsTail();
511:   return(0);
512: }

516: PetscErrorCode FNDuplicate_Rational(FN fn,MPI_Comm comm,FN *newfn)
517: {
519:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data,*ctx2 = (FN_RATIONAL*)(*newfn)->data;
520:   PetscInt       i;

523:   ctx2->np = ctx->np;
524:   if (ctx->np) {
525:     PetscMalloc1(ctx->np,&ctx2->pcoeff);
526:     PetscLogObjectMemory((PetscObject)(*newfn),ctx->np*sizeof(PetscScalar));
527:     for (i=0;i<ctx->np;i++) ctx2->pcoeff[i] = ctx->pcoeff[i];
528:   }
529:   ctx2->nq = ctx->nq;
530:   if (ctx->nq) {
531:     PetscMalloc1(ctx->nq,&ctx2->qcoeff);
532:     PetscLogObjectMemory((PetscObject)(*newfn),ctx->nq*sizeof(PetscScalar));
533:     for (i=0;i<ctx->nq;i++) ctx2->qcoeff[i] = ctx->qcoeff[i];
534:   }
535:   return(0);
536: }

540: PetscErrorCode FNDestroy_Rational(FN fn)
541: {
543:   FN_RATIONAL    *ctx = (FN_RATIONAL*)fn->data;

546:   PetscFree(ctx->pcoeff);
547:   PetscFree(ctx->qcoeff);
548:   PetscFree(fn->data);
549:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetNumerator_C",NULL);
550:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetNumerator_C",NULL);
551:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetDenominator_C",NULL);
552:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetDenominator_C",NULL);
553:   return(0);
554: }

558: PETSC_EXTERN PetscErrorCode FNCreate_Rational(FN fn)
559: {
561:   FN_RATIONAL    *ctx;

564:   PetscNewLog(fn,&ctx);
565:   fn->data = (void*)ctx;

567:   fn->ops->evaluatefunction       = FNEvaluateFunction_Rational;
568:   fn->ops->evaluatederivative     = FNEvaluateDerivative_Rational;
569:   fn->ops->evaluatefunctionmat    = FNEvaluateFunctionMat_Rational;
570:   fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Rational;
571:   fn->ops->setfromoptions         = FNSetFromOptions_Rational;
572:   fn->ops->view                   = FNView_Rational;
573:   fn->ops->duplicate              = FNDuplicate_Rational;
574:   fn->ops->destroy                = FNDestroy_Rational;
575:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetNumerator_C",FNRationalSetNumerator_Rational);
576:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetNumerator_C",FNRationalGetNumerator_Rational);
577:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalSetDenominator_C",FNRationalSetDenominator_Rational);
578:   PetscObjectComposeFunction((PetscObject)fn,"FNRationalGetDenominator_C",FNRationalGetDenominator_Rational);
579:   return(0);
580: }

slepc-3.7.4/src/sys/classes/fn/impls/phi/0000755000175000017500000000000013107004621017534 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/phi/makefile0000644000175000017500000000216313107004621021236 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fnphi.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/impls/phi/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/phi/makefile.html0000644000175000017500000000470213107004621022202 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fnphi.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/impls/phi/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/phi/fnphi.c0000644000175000017500000001724613107004621021016 0ustar jromanjroman/* Phi functions phi_0(x) = exp(x) phi_1(x) = (exp(x)-1)/x phi_k(x) = (phi_{k-1}(x)-1/(k-1)!)/x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ typedef struct { PetscInt k; /* index of the phi-function, defaults to k=1 */ } FN_PHI; const static PetscReal rfactorial[] = { 1, 1, 0.5, 1.0/6, 1.0/24, 1.0/120, 1.0/720, 1.0/5040, 1.0/40320, 1.0/362880 }; static void PhiFunction(PetscScalar x,PetscScalar *y,PetscInt k) { PetscScalar phi; if (!k) *y = PetscExpScalar(x); else if (k==1) *y = (PetscExpScalar(x)-1.0)/x; else { /* phi_k(x) = (phi_{k-1}(x)-1/(k-1)!)/x */ PhiFunction(x,&phi,k-1); *y = (phi-rfactorial[k-1])/x; } } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction_Phi" PetscErrorCode FNEvaluateFunction_Phi(FN fn,PetscScalar x,PetscScalar *y) { FN_PHI *ctx = (FN_PHI*)fn->data; PetscFunctionBegin; PhiFunction(x,y,ctx->k); PetscFunctionReturn(0); } static void PhiDerivative(PetscScalar x,PetscScalar *y,PetscInt k) { PetscScalar der,phi; if (!k) *y = PetscExpScalar(x); else if (k==1) { der = PetscExpScalar(x); phi = (der-1.0)/x; *y = (der-phi)/x; } else { PhiDerivative(x,&der,k-1); PhiFunction(x,&phi,k); *y = (der-phi)/x; } } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative_Phi" PetscErrorCode FNEvaluateDerivative_Phi(FN fn,PetscScalar x,PetscScalar *y) { FN_PHI *ctx = (FN_PHI*)fn->data; PetscFunctionBegin; PhiDerivative(x,y,ctx->k); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNPhiSetIndex_Phi" static PetscErrorCode FNPhiSetIndex_Phi(FN fn,PetscInt k) { FN_PHI *ctx = (FN_PHI*)fn->data; PetscFunctionBegin; ctx->k = k; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNPhiSetIndex" /*@ FNPhiSetIndex - Sets the index of the phi-function. Logically Collective on FN Input Parameters: + fn - the math function context - k - the index Notes: The phi-functions are defined as follows. The default is k=1. .vb phi_0(x) = exp(x) phi_1(x) = (exp(x)-1)/x phi_k(x) = (phi_{k-1}(x)-1/(k-1)!)/x .ve Level: intermediate .seealso: FNPhiGetIndex() @*/ PetscErrorCode FNPhiSetIndex(FN fn,PetscInt k) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidLogicalCollectiveInt(fn,k,2); if (k<0) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Index cannot be negative"); if (k>10) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Only implemented for k<=10"); ierr = PetscTryMethod(fn,"FNPhiSetIndex_C",(FN,PetscInt),(fn,k));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNPhiGetIndex_Phi" static PetscErrorCode FNPhiGetIndex_Phi(FN fn,PetscInt *k) { FN_PHI *ctx = (FN_PHI*)fn->data; PetscFunctionBegin; *k = ctx->k; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNPhiGetIndex" /*@ FNPhiGetIndex - Gets the index of the phi-function. Not Collective Input Parameter: . fn - the math function context Output Parameter: . k - the index Level: intermediate .seealso: FNPhiSetIndex() @*/ PetscErrorCode FNPhiGetIndex(FN fn,PetscInt *k) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidPointer(k,2); ierr = PetscUseMethod(fn,"FNPhiGetIndex_C",(FN,PetscInt*),(fn,k));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNView_Phi" PetscErrorCode FNView_Phi(FN fn,PetscViewer viewer) { PetscErrorCode ierr; FN_PHI *ctx = (FN_PHI*)fn->data; PetscBool isascii; char str[50],strx[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," Phi_%D: ",ctx->k);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); if (fn->beta!=(PetscScalar)1.0) { ierr = SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%s*",str);CHKERRQ(ierr); } if (fn->alpha==(PetscScalar)1.0) { ierr = PetscSNPrintf(strx,50,"x");CHKERRQ(ierr); } else { ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscSNPrintf(strx,50,"(%s*x)",str);CHKERRQ(ierr); } if (!ctx->k) { ierr = PetscViewerASCIIPrintf(viewer,"exp(%s)\n",strx);CHKERRQ(ierr); } else if (ctx->k==1) { ierr = PetscViewerASCIIPrintf(viewer,"(exp(%s)-1)/%s\n",strx,strx);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"(phi_%D(%s)-1/%D!)/%s\n",ctx->k-1,strx,ctx->k-1,strx);CHKERRQ(ierr); } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNSetFromOptions_Phi" PetscErrorCode FNSetFromOptions_Phi(PetscOptionItems *PetscOptionsObject,FN fn) { PetscErrorCode ierr; FN_PHI *ctx = (FN_PHI*)fn->data; PetscInt k; PetscBool flag; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"FN Phi Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-fn_phi_index","Index of the phi-function","FNPhiSetIndex",ctx->k,&k,&flag);CHKERRQ(ierr); if (flag) { ierr = FNPhiSetIndex(fn,k);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNDuplicate_Phi" PetscErrorCode FNDuplicate_Phi(FN fn,MPI_Comm comm,FN *newfn) { FN_PHI *ctx = (FN_PHI*)fn->data,*ctx2 = (FN_PHI*)(*newfn)->data; PetscFunctionBegin; ctx2->k = ctx->k; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNDestroy_Phi" PetscErrorCode FNDestroy_Phi(FN fn) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(fn->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNPhiSetIndex_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNPhiGetIndex_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate_Phi" PETSC_EXTERN PetscErrorCode FNCreate_Phi(FN fn) { PetscErrorCode ierr; FN_PHI *ctx; PetscFunctionBegin; ierr = PetscNewLog(fn,&ctx);CHKERRQ(ierr); fn->data = (void*)ctx; ctx->k = 1; fn->ops->evaluatefunction = FNEvaluateFunction_Phi; fn->ops->evaluatederivative = FNEvaluateDerivative_Phi; fn->ops->setfromoptions = FNSetFromOptions_Phi; fn->ops->view = FNView_Phi; fn->ops->duplicate = FNDuplicate_Phi; fn->ops->destroy = FNDestroy_Phi; ierr = PetscObjectComposeFunction((PetscObject)fn,"FNPhiSetIndex_C",FNPhiSetIndex_Phi);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNPhiGetIndex_C",FNPhiGetIndex_Phi);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/impls/phi/index.html0000644000175000017500000000212713107004621021533 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fnphi.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/phi/ftn-auto/0000755000175000017500000000000013107004621021271 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/phi/ftn-auto/makefile0000644000175000017500000000037013107004621022771 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = fnphif.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/fn/impls/phi/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/phi/ftn-auto/fnphif.c0000644000175000017500000000257313107004621022716 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* fnphi.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnphisetindex_ FNPHISETINDEX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnphisetindex_ fnphisetindex #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fnphigetindex_ FNPHIGETINDEX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fnphigetindex_ fnphigetindex #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL fnphisetindex_(FN fn,PetscInt *k, int *__ierr ){ *__ierr = FNPhiSetIndex( (FN)PetscToPointer((fn) ),*k); } PETSC_EXTERN void PETSC_STDCALL fnphigetindex_(FN fn,PetscInt *k, int *__ierr ){ *__ierr = FNPhiGetIndex( (FN)PetscToPointer((fn) ),k); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/fn/impls/phi/fnphi.c.html0000644000175000017500000004245113107004621021755 0ustar jromanjroman

Actual source code: fnphi.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Phi functions
  3:       phi_0(x) = exp(x)
  4:       phi_1(x) = (exp(x)-1)/x
  5:       phi_k(x) = (phi_{k-1}(x)-1/(k-1)!)/x

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

 11:    This file is part of SLEPc.

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

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

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

 27: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/

 29: typedef struct {
 30:   PetscInt k;    /* index of the phi-function, defaults to k=1 */
 31: } FN_PHI;

 33: const static PetscReal rfactorial[] = { 1, 1, 0.5, 1.0/6, 1.0/24, 1.0/120, 1.0/720, 1.0/5040, 1.0/40320, 1.0/362880 };

 35: static void PhiFunction(PetscScalar x,PetscScalar *y,PetscInt k)
 36: {
 37:   PetscScalar phi;

 39:   if (!k) *y = PetscExpScalar(x);
 40:   else if (k==1) *y = (PetscExpScalar(x)-1.0)/x;
 41:   else {
 42:     /* phi_k(x) = (phi_{k-1}(x)-1/(k-1)!)/x */
 43:     PhiFunction(x,&phi,k-1);
 44:     *y = (phi-rfactorial[k-1])/x;
 45:   }
 46: }

 50: PetscErrorCode FNEvaluateFunction_Phi(FN fn,PetscScalar x,PetscScalar *y)
 51: {
 52:   FN_PHI *ctx = (FN_PHI*)fn->data;

 55:   PhiFunction(x,y,ctx->k);
 56:   return(0);
 57: }

 59: static void PhiDerivative(PetscScalar x,PetscScalar *y,PetscInt k)
 60: {
 61:   PetscScalar der,phi;

 63:   if (!k) *y = PetscExpScalar(x);
 64:   else if (k==1) {
 65:     der = PetscExpScalar(x);
 66:     phi = (der-1.0)/x;
 67:     *y = (der-phi)/x;
 68:   } else {
 69:     PhiDerivative(x,&der,k-1);
 70:     PhiFunction(x,&phi,k);
 71:     *y = (der-phi)/x;
 72:   }
 73: }

 77: PetscErrorCode FNEvaluateDerivative_Phi(FN fn,PetscScalar x,PetscScalar *y)
 78: {
 79:   FN_PHI *ctx = (FN_PHI*)fn->data;

 82:   PhiDerivative(x,y,ctx->k);
 83:   return(0);
 84: }

 88: static PetscErrorCode FNPhiSetIndex_Phi(FN fn,PetscInt k)
 89: {
 90:   FN_PHI *ctx = (FN_PHI*)fn->data;

 93:   ctx->k = k;
 94:   return(0);
 95: }

 99: /*@
100:    FNPhiSetIndex - Sets the index of the phi-function.

102:    Logically Collective on FN

104:    Input Parameters:
105: +  fn - the math function context
106: -  k  - the index

108:    Notes:
109:    The phi-functions are defined as follows. The default is k=1.
110: .vb
111:       phi_0(x) = exp(x)
112:       phi_1(x) = (exp(x)-1)/x
113:       phi_k(x) = (phi_{k-1}(x)-1/(k-1)!)/x
114: .ve

116:    Level: intermediate

118: .seealso: FNPhiGetIndex()
119: @*/
120: PetscErrorCode FNPhiSetIndex(FN fn,PetscInt k)
121: {

127:   if (k<0) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Index cannot be negative");
128:   if (k>10) SETERRQ(PetscObjectComm((PetscObject)fn),PETSC_ERR_ARG_OUTOFRANGE,"Only implemented for k<=10");
129:   PetscTryMethod(fn,"FNPhiSetIndex_C",(FN,PetscInt),(fn,k));
130:   return(0);
131: }

135: static PetscErrorCode FNPhiGetIndex_Phi(FN fn,PetscInt *k)
136: {
137:   FN_PHI *ctx = (FN_PHI*)fn->data;

140:   *k = ctx->k;
141:   return(0);
142: }

146: /*@
147:    FNPhiGetIndex - Gets the index of the phi-function.

149:    Not Collective

151:    Input Parameter:
152: .  fn - the math function context

154:    Output Parameter:
155: .  k  - the index

157:    Level: intermediate

159: .seealso: FNPhiSetIndex()
160: @*/
161: PetscErrorCode FNPhiGetIndex(FN fn,PetscInt *k)
162: {

168:   PetscUseMethod(fn,"FNPhiGetIndex_C",(FN,PetscInt*),(fn,k));
169:   return(0);
170: }

174: PetscErrorCode FNView_Phi(FN fn,PetscViewer viewer)
175: {
177:   FN_PHI         *ctx = (FN_PHI*)fn->data;
178:   PetscBool      isascii;
179:   char           str[50],strx[50];

182:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
183:   if (isascii) {
184:     PetscViewerASCIIPrintf(viewer,"  Phi_%D: ",ctx->k);
185:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
186:     if (fn->beta!=(PetscScalar)1.0) {
187:       SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);
188:       PetscViewerASCIIPrintf(viewer,"%s*",str);
189:     }
190:     if (fn->alpha==(PetscScalar)1.0) {
191:       PetscSNPrintf(strx,50,"x");
192:     } else {
193:       SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
194:       PetscSNPrintf(strx,50,"(%s*x)",str);
195:     }
196:     if (!ctx->k) {
197:       PetscViewerASCIIPrintf(viewer,"exp(%s)\n",strx);
198:     } else if (ctx->k==1) {
199:       PetscViewerASCIIPrintf(viewer,"(exp(%s)-1)/%s\n",strx,strx);
200:     } else {
201:       PetscViewerASCIIPrintf(viewer,"(phi_%D(%s)-1/%D!)/%s\n",ctx->k-1,strx,ctx->k-1,strx);
202:     }
203:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
204:   }
205:   return(0);
206: }

210: PetscErrorCode FNSetFromOptions_Phi(PetscOptionItems *PetscOptionsObject,FN fn)
211: {
213:   FN_PHI         *ctx = (FN_PHI*)fn->data;
214:   PetscInt       k;
215:   PetscBool      flag;

218:   PetscOptionsHead(PetscOptionsObject,"FN Phi Options");
219:     PetscOptionsInt("-fn_phi_index","Index of the phi-function","FNPhiSetIndex",ctx->k,&k,&flag);
220:     if (flag) {
221:       FNPhiSetIndex(fn,k);
222:     }
223:   PetscOptionsTail();
224:   return(0);
225: }

229: PetscErrorCode FNDuplicate_Phi(FN fn,MPI_Comm comm,FN *newfn)
230: {
231:   FN_PHI *ctx = (FN_PHI*)fn->data,*ctx2 = (FN_PHI*)(*newfn)->data;

234:   ctx2->k = ctx->k;
235:   return(0);
236: }

240: PetscErrorCode FNDestroy_Phi(FN fn)
241: {

245:   PetscFree(fn->data);
246:   PetscObjectComposeFunction((PetscObject)fn,"FNPhiSetIndex_C",NULL);
247:   PetscObjectComposeFunction((PetscObject)fn,"FNPhiGetIndex_C",NULL);
248:   return(0);
249: }

253: PETSC_EXTERN PetscErrorCode FNCreate_Phi(FN fn)
254: {
256:   FN_PHI         *ctx;

259:   PetscNewLog(fn,&ctx);
260:   fn->data = (void*)ctx;
261:   ctx->k   = 1;

263:   fn->ops->evaluatefunction    = FNEvaluateFunction_Phi;
264:   fn->ops->evaluatederivative  = FNEvaluateDerivative_Phi;
265:   fn->ops->setfromoptions      = FNSetFromOptions_Phi;
266:   fn->ops->view                = FNView_Phi;
267:   fn->ops->duplicate           = FNDuplicate_Phi;
268:   fn->ops->destroy             = FNDestroy_Phi;
269:   PetscObjectComposeFunction((PetscObject)fn,"FNPhiSetIndex_C",FNPhiSetIndex_Phi);
270:   PetscObjectComposeFunction((PetscObject)fn,"FNPhiGetIndex_C",FNPhiGetIndex_Phi);
271:   return(0);
272: }

slepc-3.7.4/src/sys/classes/fn/impls/combine/0000755000175000017500000000000013107004621020370 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/combine/makefile0000644000175000017500000000217313107004621022073 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fncombine.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/impls/combine/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/combine/fncombine.c0000644000175000017500000003545113107004621022504 0ustar jromanjroman/* A function that is obtained by combining two other functions (either by addition, multiplication, division or composition) addition: f(x) = f1(x)+f2(x) multiplication: f(x) = f1(x)*f2(x) division: f(x) = f1(x)/f2(x) f(A) = f2(A)\f1(A) composition: f(x) = f2(f1(x)) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #include typedef struct { FN f1,f2; /* functions */ FNCombineType comb; /* how the functions are combined */ } FN_COMBINE; #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction_Combine" PetscErrorCode FNEvaluateFunction_Combine(FN fn,PetscScalar x,PetscScalar *y) { PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscScalar a,b; PetscFunctionBegin; ierr = FNEvaluateFunction(ctx->f1,x,&a);CHKERRQ(ierr); switch (ctx->comb) { case FN_COMBINE_ADD: ierr = FNEvaluateFunction(ctx->f2,x,&b);CHKERRQ(ierr); *y = a+b; break; case FN_COMBINE_MULTIPLY: ierr = FNEvaluateFunction(ctx->f2,x,&b);CHKERRQ(ierr); *y = a*b; break; case FN_COMBINE_DIVIDE: ierr = FNEvaluateFunction(ctx->f2,x,&b);CHKERRQ(ierr); if (b==0.0) SETERRQ(PETSC_COMM_SELF,1,"Function not defined in the requested value"); *y = a/b; break; case FN_COMBINE_COMPOSE: ierr = FNEvaluateFunction(ctx->f2,a,y);CHKERRQ(ierr); break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative_Combine" PetscErrorCode FNEvaluateDerivative_Combine(FN fn,PetscScalar x,PetscScalar *yp) { PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscScalar a,b,ap,bp; PetscFunctionBegin; switch (ctx->comb) { case FN_COMBINE_ADD: ierr = FNEvaluateDerivative(ctx->f1,x,&ap);CHKERRQ(ierr); ierr = FNEvaluateDerivative(ctx->f2,x,&bp);CHKERRQ(ierr); *yp = ap+bp; break; case FN_COMBINE_MULTIPLY: ierr = FNEvaluateDerivative(ctx->f1,x,&ap);CHKERRQ(ierr); ierr = FNEvaluateDerivative(ctx->f2,x,&bp);CHKERRQ(ierr); ierr = FNEvaluateFunction(ctx->f1,x,&a);CHKERRQ(ierr); ierr = FNEvaluateFunction(ctx->f2,x,&b);CHKERRQ(ierr); *yp = ap*b+a*bp; break; case FN_COMBINE_DIVIDE: ierr = FNEvaluateDerivative(ctx->f1,x,&ap);CHKERRQ(ierr); ierr = FNEvaluateDerivative(ctx->f2,x,&bp);CHKERRQ(ierr); ierr = FNEvaluateFunction(ctx->f1,x,&a);CHKERRQ(ierr); ierr = FNEvaluateFunction(ctx->f2,x,&b);CHKERRQ(ierr); if (b==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value"); *yp = (ap*b-a*bp)/(b*b); break; case FN_COMBINE_COMPOSE: ierr = FNEvaluateFunction(ctx->f1,x,&a);CHKERRQ(ierr); ierr = FNEvaluateDerivative(ctx->f1,x,&ap);CHKERRQ(ierr); ierr = FNEvaluateDerivative(ctx->f2,a,yp);CHKERRQ(ierr); *yp *= ap; break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMat_Combine" PetscErrorCode FNEvaluateFunctionMat_Combine(FN fn,Mat A,Mat B) { #if defined(PETSC_MISSING_LAPACK_GESV) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV - Lapack routines are unavailable"); #else PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscScalar *Aa,*Ba,*Wa,*Za,one=1.0,zero=0.0; PetscBLASInt n,ld,ld2,inc=1,*ipiv,info; PetscInt m; Mat W,Z; PetscFunctionBegin; ierr = FN_AllocateWorkMat(fn,A,&W);CHKERRQ(ierr); ierr = MatDenseGetArray(A,&Aa);CHKERRQ(ierr); ierr = MatDenseGetArray(B,&Ba);CHKERRQ(ierr); ierr = MatDenseGetArray(W,&Wa);CHKERRQ(ierr); ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ld = n; ld2 = ld*ld; switch (ctx->comb) { case FN_COMBINE_ADD: ierr = FNEvaluateFunctionMat(ctx->f1,A,W);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f2,A,B);CHKERRQ(ierr); PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&ld2,&one,Wa,&inc,Ba,&inc)); break; case FN_COMBINE_MULTIPLY: ierr = FN_AllocateWorkMat(fn,A,&Z);CHKERRQ(ierr); ierr = MatDenseGetArray(Z,&Za);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f1,A,W);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f2,A,Z);CHKERRQ(ierr); PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,Wa,&ld,Za,&ld,&zero,Ba,&ld)); ierr = MatDenseRestoreArray(Z,&Za);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&Z);CHKERRQ(ierr); break; case FN_COMBINE_DIVIDE: ierr = FNEvaluateFunctionMat(ctx->f2,A,W);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f1,A,B);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ipiv);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&n,Wa,&ld,ipiv,Ba,&ld,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info); ierr = PetscFree(ipiv);CHKERRQ(ierr); break; case FN_COMBINE_COMPOSE: ierr = FNEvaluateFunctionMat(ctx->f1,A,W);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f2,W,B);CHKERRQ(ierr); break; } ierr = MatDenseRestoreArray(A,&Aa);CHKERRQ(ierr); ierr = MatDenseRestoreArray(B,&Ba);CHKERRQ(ierr); ierr = MatDenseRestoreArray(W,&Wa);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&W);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMatVec_Combine" PetscErrorCode FNEvaluateFunctionMatVec_Combine(FN fn,Mat A,Vec v) { #if defined(PETSC_MISSING_LAPACK_GESV) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV - Lapack routines are unavailable"); #else PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscScalar *va,*Za; PetscBLASInt n,ld,*ipiv,info,one=1; PetscInt m; Mat Z; Vec w; PetscFunctionBegin; ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ld = n; switch (ctx->comb) { case FN_COMBINE_ADD: ierr = VecDuplicate(v,&w);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(ctx->f1,A,w);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(ctx->f2,A,v);CHKERRQ(ierr); ierr = VecAXPY(v,1.0,w);CHKERRQ(ierr); ierr = VecDestroy(&w);CHKERRQ(ierr); break; case FN_COMBINE_MULTIPLY: ierr = VecDuplicate(v,&w);CHKERRQ(ierr); ierr = FN_AllocateWorkMat(fn,A,&Z);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f1,A,Z);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(ctx->f2,A,w);CHKERRQ(ierr); ierr = MatMult(Z,w,v);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&Z);CHKERRQ(ierr); ierr = VecDestroy(&w);CHKERRQ(ierr); break; case FN_COMBINE_DIVIDE: ierr = VecDuplicate(v,&w);CHKERRQ(ierr); ierr = FN_AllocateWorkMat(fn,A,&Z);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f2,A,Z);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(ctx->f1,A,v);CHKERRQ(ierr); ierr = PetscMalloc1(ld,&ipiv);CHKERRQ(ierr); ierr = MatDenseGetArray(Z,&Za);CHKERRQ(ierr); ierr = VecGetArray(v,&va);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&one,Za,&ld,ipiv,va,&ld,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info); ierr = VecRestoreArray(v,&va);CHKERRQ(ierr); ierr = MatDenseRestoreArray(Z,&Za);CHKERRQ(ierr); ierr = PetscFree(ipiv);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&Z);CHKERRQ(ierr); ierr = VecDestroy(&w);CHKERRQ(ierr); break; case FN_COMBINE_COMPOSE: ierr = FN_AllocateWorkMat(fn,A,&Z);CHKERRQ(ierr); ierr = FNEvaluateFunctionMat(ctx->f1,A,Z);CHKERRQ(ierr); ierr = FNEvaluateFunctionMatVec(ctx->f2,Z,v);CHKERRQ(ierr); ierr = FN_FreeWorkMat(fn,&Z);CHKERRQ(ierr); break; } PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "FNView_Combine" PetscErrorCode FNView_Combine(FN fn,PetscViewer viewer) { PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { switch (ctx->comb) { case FN_COMBINE_ADD: ierr = PetscViewerASCIIPrintf(viewer," Two added functions f1+f2\n");CHKERRQ(ierr); break; case FN_COMBINE_MULTIPLY: ierr = PetscViewerASCIIPrintf(viewer," Two multiplied functions f1*f2\n");CHKERRQ(ierr); break; case FN_COMBINE_DIVIDE: ierr = PetscViewerASCIIPrintf(viewer," A quotient of two functions f1/f2\n");CHKERRQ(ierr); break; case FN_COMBINE_COMPOSE: ierr = PetscViewerASCIIPrintf(viewer," Two composed functions f2(f1(.))\n");CHKERRQ(ierr); break; } ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = FNView(ctx->f1,viewer);CHKERRQ(ierr); ierr = FNView(ctx->f2,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCombineSetChildren_Combine" static PetscErrorCode FNCombineSetChildren_Combine(FN fn,FNCombineType comb,FN f1,FN f2) { PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscFunctionBegin; ctx->comb = comb; ierr = PetscObjectReference((PetscObject)f1);CHKERRQ(ierr); ierr = FNDestroy(&ctx->f1);CHKERRQ(ierr); ctx->f1 = f1; ierr = PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f1);CHKERRQ(ierr); ierr = PetscObjectReference((PetscObject)f2);CHKERRQ(ierr); ierr = FNDestroy(&ctx->f2);CHKERRQ(ierr); ctx->f2 = f2; ierr = PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCombineSetChildren" /*@ FNCombineSetChildren - Sets the two child functions that constitute this combined function, and the way they must be combined. Logically Collective on FN Input Parameters: + fn - the math function context . comb - how to combine the functions (addition, multiplication, division or composition) . f1 - first function - f2 - second function Level: intermediate .seealso: FNCombineGetChildren() @*/ PetscErrorCode FNCombineSetChildren(FN fn,FNCombineType comb,FN f1,FN f2) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); PetscValidLogicalCollectiveEnum(fn,comb,2); PetscValidHeaderSpecific(f1,FN_CLASSID,3); PetscValidHeaderSpecific(f2,FN_CLASSID,4); ierr = PetscTryMethod(fn,"FNCombineSetChildren_C",(FN,FNCombineType,FN,FN),(fn,comb,f1,f2));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCombineGetChildren_Combine" static PetscErrorCode FNCombineGetChildren_Combine(FN fn,FNCombineType *comb,FN *f1,FN *f2) { PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscFunctionBegin; if (comb) *comb = ctx->comb; if (f1) { if (!ctx->f1) { ierr = FNCreate(PetscObjectComm((PetscObject)fn),&ctx->f1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f1);CHKERRQ(ierr); } *f1 = ctx->f1; } if (f2) { if (!ctx->f2) { ierr = FNCreate(PetscObjectComm((PetscObject)fn),&ctx->f2);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f2);CHKERRQ(ierr); } *f2 = ctx->f2; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCombineGetChildren" /*@ FNCombineGetChildren - Gets the two child functions that constitute this combined function, and the way they are combined. Not Collective Input Parameter: . fn - the math function context Output Parameters: + comb - how to combine the functions (addition, multiplication, division or composition) . f1 - first function - f2 - second function Level: intermediate .seealso: FNCombineSetChildren() @*/ PetscErrorCode FNCombineGetChildren(FN fn,FNCombineType *comb,FN *f1,FN *f2) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(fn,FN_CLASSID,1); ierr = PetscUseMethod(fn,"FNCombineGetChildren_C",(FN,FNCombineType*,FN*,FN*),(fn,comb,f1,f2));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNDuplicate_Combine" PetscErrorCode FNDuplicate_Combine(FN fn,MPI_Comm comm,FN *newfn) { PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data,*ctx2 = (FN_COMBINE*)(*newfn)->data; PetscFunctionBegin; ctx2->comb = ctx->comb; ierr = FNDuplicate(ctx->f1,comm,&ctx2->f1);CHKERRQ(ierr); ierr = FNDuplicate(ctx->f2,comm,&ctx2->f2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNDestroy_Combine" PetscErrorCode FNDestroy_Combine(FN fn) { PetscErrorCode ierr; FN_COMBINE *ctx = (FN_COMBINE*)fn->data; PetscFunctionBegin; ierr = FNDestroy(&ctx->f1);CHKERRQ(ierr); ierr = FNDestroy(&ctx->f2);CHKERRQ(ierr); ierr = PetscFree(fn->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNCombineSetChildren_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNCombineGetChildren_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate_Combine" PETSC_EXTERN PetscErrorCode FNCreate_Combine(FN fn) { PetscErrorCode ierr; FN_COMBINE *ctx; PetscFunctionBegin; ierr = PetscNewLog(fn,&ctx);CHKERRQ(ierr); fn->data = (void*)ctx; fn->ops->evaluatefunction = FNEvaluateFunction_Combine; fn->ops->evaluatederivative = FNEvaluateDerivative_Combine; fn->ops->evaluatefunctionmat = FNEvaluateFunctionMat_Combine; fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Combine; fn->ops->view = FNView_Combine; fn->ops->duplicate = FNDuplicate_Combine; fn->ops->destroy = FNDestroy_Combine; ierr = PetscObjectComposeFunction((PetscObject)fn,"FNCombineSetChildren_C",FNCombineSetChildren_Combine);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)fn,"FNCombineGetChildren_C",FNCombineGetChildren_Combine);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/impls/combine/makefile.html0000644000175000017500000000472213107004621023040 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fncombine.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/impls/combine/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/combine/fncombine.c.html0000644000175000017500000010222413107004621023440 0ustar jromanjroman
Actual source code: fncombine.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    A function that is obtained by combining two other functions (either by
  3:    addition, multiplication, division or composition)

  5:       addition:          f(x) = f1(x)+f2(x)
  6:       multiplication:    f(x) = f1(x)*f2(x)
  7:       division:          f(x) = f1(x)/f2(x)      f(A) = f2(A)\f1(A)
  8:       composition:       f(x) = f2(f1(x))

 10:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 11:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 12:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 14:    This file is part of SLEPc.

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

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

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

 30: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/
 31: #include <slepcblaslapack.h>

 33: typedef struct {
 34:   FN            f1,f2;    /* functions */
 35:   FNCombineType comb;     /* how the functions are combined */
 36: } FN_COMBINE;

 40: PetscErrorCode FNEvaluateFunction_Combine(FN fn,PetscScalar x,PetscScalar *y)
 41: {
 43:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;
 44:   PetscScalar    a,b;

 47:   FNEvaluateFunction(ctx->f1,x,&a);
 48:   switch (ctx->comb) {
 49:     case FN_COMBINE_ADD:
 50:       FNEvaluateFunction(ctx->f2,x,&b);
 51:       *y = a+b;
 52:       break;
 53:     case FN_COMBINE_MULTIPLY:
 54:       FNEvaluateFunction(ctx->f2,x,&b);
 55:       *y = a*b;
 56:       break;
 57:     case FN_COMBINE_DIVIDE:
 58:       FNEvaluateFunction(ctx->f2,x,&b);
 59:       if (b==0.0) SETERRQ(PETSC_COMM_SELF,1,"Function not defined in the requested value");
 60:       *y = a/b;
 61:       break;
 62:     case FN_COMBINE_COMPOSE:
 63:       FNEvaluateFunction(ctx->f2,a,y);
 64:       break;
 65:   }
 66:   return(0);
 67: }

 71: PetscErrorCode FNEvaluateDerivative_Combine(FN fn,PetscScalar x,PetscScalar *yp)
 72: {
 74:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;
 75:   PetscScalar    a,b,ap,bp;

 78:   switch (ctx->comb) {
 79:     case FN_COMBINE_ADD:
 80:       FNEvaluateDerivative(ctx->f1,x,&ap);
 81:       FNEvaluateDerivative(ctx->f2,x,&bp);
 82:       *yp = ap+bp;
 83:       break;
 84:     case FN_COMBINE_MULTIPLY:
 85:       FNEvaluateDerivative(ctx->f1,x,&ap);
 86:       FNEvaluateDerivative(ctx->f2,x,&bp);
 87:       FNEvaluateFunction(ctx->f1,x,&a);
 88:       FNEvaluateFunction(ctx->f2,x,&b);
 89:       *yp = ap*b+a*bp;
 90:       break;
 91:     case FN_COMBINE_DIVIDE:
 92:       FNEvaluateDerivative(ctx->f1,x,&ap);
 93:       FNEvaluateDerivative(ctx->f2,x,&bp);
 94:       FNEvaluateFunction(ctx->f1,x,&a);
 95:       FNEvaluateFunction(ctx->f2,x,&b);
 96:       if (b==0.0) SETERRQ(PETSC_COMM_SELF,1,"Derivative not defined in the requested value");
 97:       *yp = (ap*b-a*bp)/(b*b);
 98:       break;
 99:     case FN_COMBINE_COMPOSE:
100:       FNEvaluateFunction(ctx->f1,x,&a);
101:       FNEvaluateDerivative(ctx->f1,x,&ap);
102:       FNEvaluateDerivative(ctx->f2,a,yp);
103:       *yp *= ap;
104:       break;
105:   }
106:   return(0);
107: }

111: PetscErrorCode FNEvaluateFunctionMat_Combine(FN fn,Mat A,Mat B)
112: {
113: #if defined(PETSC_MISSING_LAPACK_GESV)
115:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV - Lapack routines are unavailable");
116: #else
118:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;
119:   PetscScalar    *Aa,*Ba,*Wa,*Za,one=1.0,zero=0.0;
120:   PetscBLASInt   n,ld,ld2,inc=1,*ipiv,info;
121:   PetscInt       m;
122:   Mat            W,Z;

125:   FN_AllocateWorkMat(fn,A,&W);
126:   MatDenseGetArray(A,&Aa);
127:   MatDenseGetArray(B,&Ba);
128:   MatDenseGetArray(W,&Wa);
129:   MatGetSize(A,&m,NULL);
130:   PetscBLASIntCast(m,&n);
131:   ld  = n;
132:   ld2 = ld*ld;

134:   switch (ctx->comb) {
135:     case FN_COMBINE_ADD:
136:       FNEvaluateFunctionMat(ctx->f1,A,W);
137:       FNEvaluateFunctionMat(ctx->f2,A,B);
138:       PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&ld2,&one,Wa,&inc,Ba,&inc));
139:       break;
140:     case FN_COMBINE_MULTIPLY:
141:       FN_AllocateWorkMat(fn,A,&Z);
142:       MatDenseGetArray(Z,&Za);
143:       FNEvaluateFunctionMat(ctx->f1,A,W);
144:       FNEvaluateFunctionMat(ctx->f2,A,Z);
145:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,Wa,&ld,Za,&ld,&zero,Ba,&ld));
146:       MatDenseRestoreArray(Z,&Za);
147:       FN_FreeWorkMat(fn,&Z);
148:       break;
149:     case FN_COMBINE_DIVIDE:
150:       FNEvaluateFunctionMat(ctx->f2,A,W);
151:       FNEvaluateFunctionMat(ctx->f1,A,B);
152:       PetscMalloc1(ld,&ipiv);
153:       PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&n,Wa,&ld,ipiv,Ba,&ld,&info));
154:       if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
155:       PetscFree(ipiv);
156:       break;
157:     case FN_COMBINE_COMPOSE:
158:       FNEvaluateFunctionMat(ctx->f1,A,W);
159:       FNEvaluateFunctionMat(ctx->f2,W,B);
160:       break;
161:   }

163:   MatDenseRestoreArray(A,&Aa);
164:   MatDenseRestoreArray(B,&Ba);
165:   MatDenseRestoreArray(W,&Wa);
166:   FN_FreeWorkMat(fn,&W);
167:   return(0);
168: #endif
169: }

173: PetscErrorCode FNEvaluateFunctionMatVec_Combine(FN fn,Mat A,Vec v)
174: {
175: #if defined(PETSC_MISSING_LAPACK_GESV)
177:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV - Lapack routines are unavailable");
178: #else
180:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;
181:   PetscScalar    *va,*Za;
182:   PetscBLASInt   n,ld,*ipiv,info,one=1;
183:   PetscInt       m;
184:   Mat            Z;
185:   Vec            w;

188:   MatGetSize(A,&m,NULL);
189:   PetscBLASIntCast(m,&n);
190:   ld = n;

192:   switch (ctx->comb) {
193:     case FN_COMBINE_ADD:
194:       VecDuplicate(v,&w);
195:       FNEvaluateFunctionMatVec(ctx->f1,A,w);
196:       FNEvaluateFunctionMatVec(ctx->f2,A,v);
197:       VecAXPY(v,1.0,w);
198:       VecDestroy(&w);
199:       break;
200:     case FN_COMBINE_MULTIPLY:
201:       VecDuplicate(v,&w);
202:       FN_AllocateWorkMat(fn,A,&Z);
203:       FNEvaluateFunctionMat(ctx->f1,A,Z);
204:       FNEvaluateFunctionMatVec(ctx->f2,A,w);
205:       MatMult(Z,w,v);
206:       FN_FreeWorkMat(fn,&Z);
207:       VecDestroy(&w);
208:       break;
209:     case FN_COMBINE_DIVIDE:
210:       VecDuplicate(v,&w);
211:       FN_AllocateWorkMat(fn,A,&Z);
212:       FNEvaluateFunctionMat(ctx->f2,A,Z);
213:       FNEvaluateFunctionMatVec(ctx->f1,A,v);
214:       PetscMalloc1(ld,&ipiv);
215:       MatDenseGetArray(Z,&Za);
216:       VecGetArray(v,&va);
217:       PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&one,Za,&ld,ipiv,va,&ld,&info));
218:       if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
219:       VecRestoreArray(v,&va);
220:       MatDenseRestoreArray(Z,&Za);
221:       PetscFree(ipiv);
222:       FN_FreeWorkMat(fn,&Z);
223:       VecDestroy(&w);
224:       break;
225:     case FN_COMBINE_COMPOSE:
226:       FN_AllocateWorkMat(fn,A,&Z);
227:       FNEvaluateFunctionMat(ctx->f1,A,Z);
228:       FNEvaluateFunctionMatVec(ctx->f2,Z,v);
229:       FN_FreeWorkMat(fn,&Z);
230:       break;
231:   }
232:   return(0);
233: #endif
234: }

238: PetscErrorCode FNView_Combine(FN fn,PetscViewer viewer)
239: {
241:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;
242:   PetscBool      isascii;

245:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
246:   if (isascii) {
247:     switch (ctx->comb) {
248:       case FN_COMBINE_ADD:
249:         PetscViewerASCIIPrintf(viewer,"  Two added functions f1+f2\n");
250:         break;
251:       case FN_COMBINE_MULTIPLY:
252:         PetscViewerASCIIPrintf(viewer,"  Two multiplied functions f1*f2\n");
253:         break;
254:       case FN_COMBINE_DIVIDE:
255:         PetscViewerASCIIPrintf(viewer,"  A quotient of two functions f1/f2\n");
256:         break;
257:       case FN_COMBINE_COMPOSE:
258:         PetscViewerASCIIPrintf(viewer,"  Two composed functions f2(f1(.))\n");
259:         break;
260:     }
261:     PetscViewerASCIIPushTab(viewer);
262:     FNView(ctx->f1,viewer);
263:     FNView(ctx->f2,viewer);
264:     PetscViewerASCIIPopTab(viewer);
265:   }
266:   return(0);
267: }

271: static PetscErrorCode FNCombineSetChildren_Combine(FN fn,FNCombineType comb,FN f1,FN f2)
272: {
274:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;

277:   ctx->comb = comb;
278:   PetscObjectReference((PetscObject)f1);
279:   FNDestroy(&ctx->f1);
280:   ctx->f1 = f1;
281:   PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f1);
282:   PetscObjectReference((PetscObject)f2);
283:   FNDestroy(&ctx->f2);
284:   ctx->f2 = f2;
285:   PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f2);
286:   return(0);
287: }

291: /*@
292:    FNCombineSetChildren - Sets the two child functions that constitute this
293:    combined function, and the way they must be combined.

295:    Logically Collective on FN

297:    Input Parameters:
298: +  fn   - the math function context
299: .  comb - how to combine the functions (addition, multiplication, division or composition)
300: .  f1   - first function
301: -  f2   - second function

303:    Level: intermediate

305: .seealso: FNCombineGetChildren()
306: @*/
307: PetscErrorCode FNCombineSetChildren(FN fn,FNCombineType comb,FN f1,FN f2)
308: {

316:   PetscTryMethod(fn,"FNCombineSetChildren_C",(FN,FNCombineType,FN,FN),(fn,comb,f1,f2));
317:   return(0);
318: }

322: static PetscErrorCode FNCombineGetChildren_Combine(FN fn,FNCombineType *comb,FN *f1,FN *f2)
323: {
325:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;

328:   if (comb) *comb = ctx->comb;
329:   if (f1) {
330:     if (!ctx->f1) {
331:       FNCreate(PetscObjectComm((PetscObject)fn),&ctx->f1);
332:       PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f1);
333:     }
334:     *f1 = ctx->f1;
335:   }
336:   if (f2) {
337:     if (!ctx->f2) {
338:       FNCreate(PetscObjectComm((PetscObject)fn),&ctx->f2);
339:       PetscLogObjectParent((PetscObject)fn,(PetscObject)ctx->f2);
340:     }
341:     *f2 = ctx->f2;
342:   }
343:   return(0);
344: }

348: /*@
349:    FNCombineGetChildren - Gets the two child functions that constitute this
350:    combined function, and the way they are combined.

352:    Not Collective

354:    Input Parameter:
355: .  fn   - the math function context

357:    Output Parameters:
358: +  comb - how to combine the functions (addition, multiplication, division or composition)
359: .  f1   - first function
360: -  f2   - second function

362:    Level: intermediate

364: .seealso: FNCombineSetChildren()
365: @*/
366: PetscErrorCode FNCombineGetChildren(FN fn,FNCombineType *comb,FN *f1,FN *f2)
367: {

372:   PetscUseMethod(fn,"FNCombineGetChildren_C",(FN,FNCombineType*,FN*,FN*),(fn,comb,f1,f2));
373:   return(0);
374: }

378: PetscErrorCode FNDuplicate_Combine(FN fn,MPI_Comm comm,FN *newfn)
379: {
381:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data,*ctx2 = (FN_COMBINE*)(*newfn)->data;

384:   ctx2->comb = ctx->comb;
385:   FNDuplicate(ctx->f1,comm,&ctx2->f1);
386:   FNDuplicate(ctx->f2,comm,&ctx2->f2);
387:   return(0);
388: }

392: PetscErrorCode FNDestroy_Combine(FN fn)
393: {
395:   FN_COMBINE     *ctx = (FN_COMBINE*)fn->data;

398:   FNDestroy(&ctx->f1);
399:   FNDestroy(&ctx->f2);
400:   PetscFree(fn->data);
401:   PetscObjectComposeFunction((PetscObject)fn,"FNCombineSetChildren_C",NULL);
402:   PetscObjectComposeFunction((PetscObject)fn,"FNCombineGetChildren_C",NULL);
403:   return(0);
404: }

408: PETSC_EXTERN PetscErrorCode FNCreate_Combine(FN fn)
409: {
411:   FN_COMBINE     *ctx;

414:   PetscNewLog(fn,&ctx);
415:   fn->data = (void*)ctx;

417:   fn->ops->evaluatefunction       = FNEvaluateFunction_Combine;
418:   fn->ops->evaluatederivative     = FNEvaluateDerivative_Combine;
419:   fn->ops->evaluatefunctionmat    = FNEvaluateFunctionMat_Combine;
420:   fn->ops->evaluatefunctionmatvec = FNEvaluateFunctionMatVec_Combine;
421:   fn->ops->view                   = FNView_Combine;
422:   fn->ops->duplicate              = FNDuplicate_Combine;
423:   fn->ops->destroy                = FNDestroy_Combine;
424:   PetscObjectComposeFunction((PetscObject)fn,"FNCombineSetChildren_C",FNCombineSetChildren_Combine);
425:   PetscObjectComposeFunction((PetscObject)fn,"FNCombineGetChildren_C",FNCombineGetChildren_Combine);
426:   return(0);
427: }

slepc-3.7.4/src/sys/classes/fn/impls/combine/index.html0000644000175000017500000000214713107004621022371 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fncombine.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/combine/ftn-auto/0000755000175000017500000000000013107004621022125 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/combine/ftn-auto/makefile0000644000175000017500000000040013107004621023617 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = fncombinef.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/fn/impls/combine/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/combine/ftn-auto/fncombinef.c0000644000175000017500000000310113107004621024372 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* fncombine.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcfn.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define fncombinesetchildren_ FNCOMBINESETCHILDREN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fncombinesetchildren_ fncombinesetchildren #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define fncombinegetchildren_ FNCOMBINEGETCHILDREN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define fncombinegetchildren_ fncombinegetchildren #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL fncombinesetchildren_(FN fn,FNCombineType *comb,FN f1,FN f2, int *__ierr ){ *__ierr = FNCombineSetChildren( (FN)PetscToPointer((fn) ),*comb, (FN)PetscToPointer((f1) ), (FN)PetscToPointer((f2) )); } PETSC_EXTERN void PETSC_STDCALL fncombinegetchildren_(FN fn,FNCombineType *comb,FN *f1,FN *f2, int *__ierr ){ *__ierr = FNCombineGetChildren( (FN)PetscToPointer((fn) ),comb,f1,f2); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/fn/impls/index.html0000644000175000017500000000246113107004621020754 0ustar jromanjroman Mathematical Function - FN

slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

combine/
exp/
log/
phi/
rational/
sqrt/
invsqrt/
fnutil.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/fnutil.c0000644000175000017500000001441113107004621020422 0ustar jromanjroman/* Utility subroutines common to several impls - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "SlepcMatDenseSqrt" /* Compute the square root of an upper quasi-triangular matrix T, using Higham's algorithm (LAA 88, 1987). T is overwritten with sqrtm(T). */ PetscErrorCode SlepcMatDenseSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld) { #if defined(SLEPC_MISSING_LAPACK_TRSYL) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TRSYL - Lapack routine unavailable"); #else PetscScalar one=1.0,mone=-1.0; PetscReal done=1.0; PetscBLASInt i,j,si,sj,r,ione=1,info; #if !defined(PETSC_USE_COMPLEX) PetscReal alpha,theta,mu,mu2; #endif PetscFunctionBegin; for (j=0;j0.0) alpha = PetscSqrtReal((theta+PetscSqrtReal(theta*theta+mu2))/2.0); else alpha = mu/PetscSqrtReal(2.0*(-theta+PetscSqrtReal(theta*theta+mu2))); T[j+j*ld] /= 2.0*alpha; T[j+1+(j+1)*ld] /= 2.0*alpha; T[j+(j+1)*ld] /= 2.0*alpha; T[j+1+j*ld] /= 2.0*alpha; T[j+j*ld] += alpha-theta/(2.0*alpha); T[j+1+(j+1)*ld] += alpha-theta/(2.0*alpha); } #endif for (i=j-1;i>=0;i--) { #if defined(PETSC_USE_COMPLEX) si = 1; #else si = (i==0 || T[i+(i-1)*ld] == 0.0)? 1: 2; if (si==2) i--; #endif /* solve Sylvester equation of order si x sj */ r = j-i-si; if (r) PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&si,&sj,&r,&mone,T+i+(i+si)*ld,&ld,T+i+si+j*ld,&ld,&one,T+i+j*ld,&ld)); PetscStackCallBLAS("LAPACKtrsyl",LAPACKtrsyl_("N","N",&ione,&si,&sj,T+i+i*ld,&ld,T+j+j*ld,&ld,T+i+j*ld,&ld,&done,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTRSYL %d",info); } if (sj==2) j++; } PetscFunctionReturn(0); #endif } #define BLOCKSIZE 64 #undef __FUNCT__ #define __FUNCT__ "SlepcSchurParlettSqrt" /* Simplified Schur-Parlett algorithm on an upper quasi-triangular matrix T, particularized for the square root function. T is overwritten with sqrtm(T). If firstonly then only the first column of T will contain relevant values. */ PetscErrorCode SlepcSchurParlettSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld,PetscBool firstonly) { #if defined(SLEPC_MISSING_LAPACK_GEES) || defined(SLEPC_MISSING_LAPACK_TRSYL) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEES/TRSYL - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscBLASInt i,j,k,r,ione=1,sdim,lwork,*s,*p,info,bs=BLOCKSIZE; PetscScalar *wr,*W,*Q,*work,one=1.0,zero=0.0,mone=-1.0; PetscInt m,nblk; PetscReal done=1.0; #if defined(PETSC_USE_COMPLEX) PetscReal *rwork; #else PetscReal *wi; #endif PetscFunctionBegin; m = n; nblk = (m+bs-1)/bs; lwork = 5*n; k = firstonly? 1: n; /* compute Schur decomposition A*Q = Q*T */ #if !defined(PETSC_USE_COMPLEX) ierr = PetscMalloc7(m,&wr,m,&wi,m*k,&W,m*m,&Q,lwork,&work,nblk,&s,nblk,&p);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgees",LAPACKgees_("V","N",NULL,&n,T,&ld,&sdim,wr,wi,Q,&ld,work,&lwork,NULL,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEES %d",info); #else ierr = PetscMalloc7(m,&wr,m,&rwork,m*k,&W,m*m,&Q,lwork,&work,nblk,&s,nblk,&p);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgees",LAPACKgees_("V","N",NULL,&n,T,&ld,&sdim,wr,Q,&ld,work,&lwork,rwork,NULL,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEES %d",info); #endif /* determine block sizes and positions, to avoid cutting 2x2 blocks */ j = 0; p[j] = 0; do { s[j] = PetscMin(bs,n-p[j]); #if !defined(PETSC_USE_COMPLEX) if (p[j]+s[j]!=n && T[p[j]+s[j]+(p[j]+s[j]-1)*ld]!=0.0) s[j]++; #endif if (p[j]+s[j]==n) break; j++; p[j] = p[j-1]+s[j-1]; } while (1); nblk = j+1; for (j=0;j=0;i--) { /* solve Sylvester equation for block (i,j) */ r = p[j]-p[i]-s[i]; if (r) PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",s+i,s+j,&r,&mone,T+p[i]+(p[i]+s[i])*ld,&ld,T+p[i]+s[i]+p[j]*ld,&ld,&one,T+p[i]+p[j]*ld,&ld)); PetscStackCallBLAS("LAPACKtrsyl",LAPACKtrsyl_("N","N",&ione,s+i,s+j,T+p[i]+p[i]*ld,&ld,T+p[j]+p[j]*ld,&ld,T+p[i]+p[j]*ld,&ld,&done,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTRSYL %d",info); } } /* backtransform B = Q*T*Q' */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N","C",&n,&k,&n,&one,T,&ld,Q,&ld,&zero,W,&ld)); PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&k,&n,&one,Q,&ld,W,&ld,&zero,T,&ld)); #if !defined(PETSC_USE_COMPLEX) ierr = PetscFree7(wr,wi,W,Q,work,s,p);CHKERRQ(ierr); #else ierr = PetscFree7(wr,rwork,W,Q,work,s,p);CHKERRQ(ierr); #endif PetscFunctionReturn(0); #endif } slepc-3.7.4/src/sys/classes/fn/impls/exp/0000755000175000017500000000000013107004621017550 5ustar jromanjromanslepc-3.7.4/src/sys/classes/fn/impls/exp/makefile0000644000175000017500000000216313107004621021252 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = fnexp.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = FN LOCDIR = src/sys/classes/fn/impls/exp/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/fn/impls/exp/makefile.html0000644000175000017500000000470213107004621022216 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = fnexp.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = FN
LOCDIR   = src/sys/classes/fn/impls/exp/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/fn/impls/exp/fnexp.c0000644000175000017500000001535513107004621021045 0ustar jromanjroman/* Exponential function exp(x) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcfn.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunction_Exp" PetscErrorCode FNEvaluateFunction_Exp(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; *y = PetscExpScalar(x); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNEvaluateDerivative_Exp" PetscErrorCode FNEvaluateDerivative_Exp(FN fn,PetscScalar x,PetscScalar *y) { PetscFunctionBegin; *y = PetscExpScalar(x); PetscFunctionReturn(0); } #define MAX_PADE 6 #define SWAP(a,b,t) {t=a;a=b;b=t;} #undef __FUNCT__ #define __FUNCT__ "FNEvaluateFunctionMat_Exp" PetscErrorCode FNEvaluateFunctionMat_Exp(FN fn,Mat A,Mat B) { #if defined(PETSC_MISSING_LAPACK_GESV) || defined(SLEPC_MISSING_LAPACK_LANGE) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV/LANGE - Lapack routines are unavailable"); #else PetscErrorCode ierr; PetscBLASInt n,ld,ld2,*ipiv,info,inc=1; PetscInt m,j,k,sexp; PetscBool odd; const PetscInt p=MAX_PADE; PetscReal c[MAX_PADE+1],s,*rwork; PetscScalar scale,mone=-1.0,one=1.0,two=2.0,zero=0.0; PetscScalar *Aa,*Ba,*As,*A2,*Q,*P,*W,*aux; PetscFunctionBegin; ierr = MatDenseGetArray(A,&Aa);CHKERRQ(ierr); ierr = MatDenseGetArray(B,&Ba);CHKERRQ(ierr); ierr = MatGetSize(A,&m,NULL);CHKERRQ(ierr); ierr = PetscBLASIntCast(m,&n);CHKERRQ(ierr); ld = n; ld2 = ld*ld; P = Ba; ierr = PetscMalloc6(m*m,&Q,m*m,&W,m*m,&As,m*m,&A2,ld,&rwork,ld,&ipiv);CHKERRQ(ierr); ierr = PetscMemcpy(As,Aa,ld2*sizeof(PetscScalar));CHKERRQ(ierr); /* Pade' coefficients */ c[0] = 1.0; for (k=1;k<=p;k++) c[k] = c[k-1]*(p+1-k)/(k*(2*p+1-k)); /* Scaling */ s = LAPACKlange_("I",&n,&n,As,&ld,rwork); if (s>0.5) { sexp = PetscMax(0,(int)(PetscLogReal(s)/PetscLogReal(2.0))+2); scale = PetscPowRealInt(2.0,-sexp); PetscStackCallBLAS("BLASscal",BLASscal_(&ld2,&scale,As,&inc)); } else sexp = 0; /* Horner evaluation */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,As,&ld,As,&ld,&zero,A2,&ld)); ierr = PetscMemzero(Q,ld2*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMemzero(P,ld2*sizeof(PetscScalar));CHKERRQ(ierr); for (j=0;j0;k--) { if (odd) { PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,Q,&ld,A2,&ld,&zero,W,&ld)); SWAP(Q,W,aux); for (j=0;jbeta==(PetscScalar)1.0) { if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Exponential: exp(x)\n");CHKERRQ(ierr); } else { ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Exponential: exp(%s*x)\n",str);CHKERRQ(ierr); } } else { ierr = SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);CHKERRQ(ierr); if (fn->alpha==(PetscScalar)1.0) { ierr = PetscViewerASCIIPrintf(viewer," Exponential: %s*exp(x)\n",str);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," Exponential: %s",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"*exp(%s*x)\n",str);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "FNCreate_Exp" PETSC_EXTERN PetscErrorCode FNCreate_Exp(FN fn) { PetscFunctionBegin; fn->ops->evaluatefunction = FNEvaluateFunction_Exp; fn->ops->evaluatederivative = FNEvaluateDerivative_Exp; fn->ops->evaluatefunctionmat = FNEvaluateFunctionMat_Exp; fn->ops->view = FNView_Exp; PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/fn/impls/exp/index.html0000644000175000017500000000212713107004621021547 0ustar jromanjroman Mathematical Function - FN
slepc-3.7.4 2017-05-17

Mathematical Function - FN

The FN package provides the functionality to represent a simple mathematical function such as an exponential, a polynomial or a rational function. This is used as a building block for defining the function associated to the nonlinear eigenproblem, as well as for specifying which function to use when computing the action of a matrix function on a vector.

fnexp.c
makefile
slepc-3.7.4/src/sys/classes/fn/impls/exp/fnexp.c.html0000644000175000017500000003506313107004621022006 0ustar jromanjroman

Actual source code: fnexp.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Exponential function  exp(x)

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/
 25: #include <slepcblaslapack.h>

 29: PetscErrorCode FNEvaluateFunction_Exp(FN fn,PetscScalar x,PetscScalar *y)
 30: {
 32:   *y = PetscExpScalar(x);
 33:   return(0);
 34: }

 38: PetscErrorCode FNEvaluateDerivative_Exp(FN fn,PetscScalar x,PetscScalar *y)
 39: {
 41:   *y = PetscExpScalar(x);
 42:   return(0);
 43: }

 45: #define MAX_PADE 6
 46: #define SWAP(a,b,t) {t=a;a=b;b=t;}

 50: PetscErrorCode FNEvaluateFunctionMat_Exp(FN fn,Mat A,Mat B)
 51: {
 52: #if defined(PETSC_MISSING_LAPACK_GESV) || defined(SLEPC_MISSING_LAPACK_LANGE)
 54:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV/LANGE - Lapack routines are unavailable");
 55: #else
 57:   PetscBLASInt   n,ld,ld2,*ipiv,info,inc=1;
 58:   PetscInt       m,j,k,sexp;
 59:   PetscBool      odd;
 60:   const PetscInt p=MAX_PADE;
 61:   PetscReal      c[MAX_PADE+1],s,*rwork;
 62:   PetscScalar    scale,mone=-1.0,one=1.0,two=2.0,zero=0.0;
 63:   PetscScalar    *Aa,*Ba,*As,*A2,*Q,*P,*W,*aux;

 66:   MatDenseGetArray(A,&Aa);
 67:   MatDenseGetArray(B,&Ba);
 68:   MatGetSize(A,&m,NULL);
 69:   PetscBLASIntCast(m,&n);
 70:   ld  = n;
 71:   ld2 = ld*ld;
 72:   P   = Ba;
 73:   PetscMalloc6(m*m,&Q,m*m,&W,m*m,&As,m*m,&A2,ld,&rwork,ld,&ipiv);
 74:   PetscMemcpy(As,Aa,ld2*sizeof(PetscScalar));

 76:   /* Pade' coefficients */
 77:   c[0] = 1.0;
 78:   for (k=1;k<=p;k++) c[k] = c[k-1]*(p+1-k)/(k*(2*p+1-k));

 80:   /* Scaling */
 81:   s = LAPACKlange_("I",&n,&n,As,&ld,rwork);
 82:   if (s>0.5) {
 83:     sexp = PetscMax(0,(int)(PetscLogReal(s)/PetscLogReal(2.0))+2);
 84:     scale = PetscPowRealInt(2.0,-sexp);
 85:     PetscStackCallBLAS("BLASscal",BLASscal_(&ld2,&scale,As,&inc));
 86:   } else sexp = 0;

 88:   /* Horner evaluation */
 89:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,As,&ld,As,&ld,&zero,A2,&ld));
 90:   PetscMemzero(Q,ld2*sizeof(PetscScalar));
 91:   PetscMemzero(P,ld2*sizeof(PetscScalar));
 92:   for (j=0;j<n;j++) {
 93:     Q[j+j*ld] = c[p];
 94:     P[j+j*ld] = c[p-1];
 95:   }

 97:   odd = PETSC_TRUE;
 98:   for (k=p-1;k>0;k--) {
 99:     if (odd) {
100:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,Q,&ld,A2,&ld,&zero,W,&ld));
101:       SWAP(Q,W,aux);
102:       for (j=0;j<n;j++) Q[j+j*ld] += c[k-1];
103:       odd = PETSC_FALSE;
104:     } else {
105:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,P,&ld,A2,&ld,&zero,W,&ld));
106:       SWAP(P,W,aux);
107:       for (j=0;j<n;j++) P[j+j*ld] += c[k-1];
108:       odd = PETSC_TRUE;
109:     }
110:   }
111:   if (odd) {
112:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,Q,&ld,As,&ld,&zero,W,&ld));
113:     SWAP(Q,W,aux);
114:     PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&ld2,&mone,P,&inc,Q,&inc));
115:     PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&n,Q,&ld,ipiv,P,&ld,&info));
116:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
117:     PetscStackCallBLAS("BLASscal",BLASscal_(&ld2,&two,P,&inc));
118:     for (j=0;j<n;j++) P[j+j*ld] += 1.0;
119:     PetscStackCallBLAS("BLASscal",BLASscal_(&ld2,&mone,P,&inc));
120:   } else {
121:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,P,&ld,As,&ld,&zero,W,&ld));
122:     SWAP(P,W,aux);
123:     PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&ld2,&mone,P,&inc,Q,&inc));
124:     PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&n,&n,Q,&ld,ipiv,P,&ld,&info));
125:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
126:     PetscStackCallBLAS("BLASscal",BLASscal_(&ld2,&two,P,&inc));
127:     for (j=0;j<n;j++) P[j+j*ld] += 1.0;
128:   }

130:   for (k=1;k<=sexp;k++) {
131:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&n,&n,&one,P,&ld,P,&ld,&zero,W,&ld));
132:     PetscMemcpy(P,W,ld2*sizeof(PetscScalar));
133:   }
134:   if (P!=Ba) { PetscMemcpy(Ba,P,ld2*sizeof(PetscScalar)); }

136:   PetscFree6(Q,W,As,A2,rwork,ipiv);
137:   MatDenseRestoreArray(A,&Aa);
138:   MatDenseRestoreArray(B,&Ba);
139:   return(0);
140: #endif
141: }

145: PetscErrorCode FNView_Exp(FN fn,PetscViewer viewer)
146: {
148:   PetscBool      isascii;
149:   char           str[50];

152:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
153:   if (isascii) {
154:     if (fn->beta==(PetscScalar)1.0) {
155:       if (fn->alpha==(PetscScalar)1.0) {
156:         PetscViewerASCIIPrintf(viewer,"  Exponential: exp(x)\n");
157:       } else {
158:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
159:         PetscViewerASCIIPrintf(viewer,"  Exponential: exp(%s*x)\n",str);
160:       }
161:     } else {
162:       SlepcSNPrintfScalar(str,50,fn->beta,PETSC_TRUE);
163:       if (fn->alpha==(PetscScalar)1.0) {
164:         PetscViewerASCIIPrintf(viewer,"  Exponential: %s*exp(x)\n",str);
165:       } else {
166:         PetscViewerASCIIPrintf(viewer,"  Exponential: %s",str);
167:         PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
168:         SlepcSNPrintfScalar(str,50,fn->alpha,PETSC_TRUE);
169:         PetscViewerASCIIPrintf(viewer,"*exp(%s*x)\n",str);
170:         PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
171:       }
172:     }
173:   }
174:   return(0);
175: }

179: PETSC_EXTERN PetscErrorCode FNCreate_Exp(FN fn)
180: {
182:   fn->ops->evaluatefunction    = FNEvaluateFunction_Exp;
183:   fn->ops->evaluatederivative  = FNEvaluateDerivative_Exp;
184:   fn->ops->evaluatefunctionmat = FNEvaluateFunctionMat_Exp;
185:   fn->ops->view                = FNView_Exp;
186:   return(0);
187: }

slepc-3.7.4/src/sys/classes/fn/impls/fnutil.c.html0000644000175000017500000003435313107004621021374 0ustar jromanjroman
Actual source code: fnutil.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Utility subroutines common to several impls

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/fnimpl.h>      /*I "slepcfn.h" I*/
 25: #include <slepcblaslapack.h>

 29: /*
 30:    Compute the square root of an upper quasi-triangular matrix T,
 31:    using Higham's algorithm (LAA 88, 1987). T is overwritten with sqrtm(T).
 32:  */
 33: PetscErrorCode SlepcMatDenseSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld)
 34: {
 35: #if defined(SLEPC_MISSING_LAPACK_TRSYL)
 37:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TRSYL - Lapack routine unavailable");
 38: #else
 39:   PetscScalar  one=1.0,mone=-1.0;
 40:   PetscReal    done=1.0;
 41:   PetscBLASInt i,j,si,sj,r,ione=1,info;
 42: #if !defined(PETSC_USE_COMPLEX)
 43:   PetscReal    alpha,theta,mu,mu2;
 44: #endif

 47:   for (j=0;j<n;j++) {
 48: #if defined(PETSC_USE_COMPLEX)
 49:     sj = 1;
 50:     T[j+j*ld] = PetscSqrtScalar(T[j+j*ld]);
 51: #else
 52:     sj = (j==n-1 || T[j+1+j*ld] == 0.0)? 1: 2;
 53:     if (sj==1) {
 54:       if (T[j+j*ld]<0.0) SETERRQ(PETSC_COMM_SELF,1,"Matrix has a real negative eigenvalue, no real primary square root exists");
 55:       T[j+j*ld] = PetscSqrtReal(T[j+j*ld]);
 56:     } else {
 57:       /* square root of 2x2 block */
 58:       theta = (T[j+j*ld]+T[j+1+(j+1)*ld])/2.0;
 59:       mu    = (T[j+j*ld]-T[j+1+(j+1)*ld])/2.0;
 60:       mu2   = -mu*mu-T[j+1+j*ld]*T[j+(j+1)*ld];
 61:       mu    = PetscSqrtReal(mu2);
 62:       if (theta>0.0) alpha = PetscSqrtReal((theta+PetscSqrtReal(theta*theta+mu2))/2.0);
 63:       else alpha = mu/PetscSqrtReal(2.0*(-theta+PetscSqrtReal(theta*theta+mu2)));
 64:       T[j+j*ld]       /= 2.0*alpha;
 65:       T[j+1+(j+1)*ld] /= 2.0*alpha;
 66:       T[j+(j+1)*ld]   /= 2.0*alpha;
 67:       T[j+1+j*ld]     /= 2.0*alpha;
 68:       T[j+j*ld]       += alpha-theta/(2.0*alpha);
 69:       T[j+1+(j+1)*ld] += alpha-theta/(2.0*alpha);
 70:     }
 71: #endif
 72:     for (i=j-1;i>=0;i--) {
 73: #if defined(PETSC_USE_COMPLEX)
 74:       si = 1;
 75: #else
 76:       si = (i==0 || T[i+(i-1)*ld] == 0.0)? 1: 2;
 77:       if (si==2) i--;
 78: #endif
 79:       /* solve Sylvester equation of order si x sj */
 80:       r = j-i-si;
 81:       if (r) PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&si,&sj,&r,&mone,T+i+(i+si)*ld,&ld,T+i+si+j*ld,&ld,&one,T+i+j*ld,&ld));
 82:       PetscStackCallBLAS("LAPACKtrsyl",LAPACKtrsyl_("N","N",&ione,&si,&sj,T+i+i*ld,&ld,T+j+j*ld,&ld,T+i+j*ld,&ld,&done,&info));
 83:       if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTRSYL %d",info);
 84:     }
 85:     if (sj==2) j++;
 86:   }
 87:   return(0);
 88: #endif
 89: }

 91: #define BLOCKSIZE 64

 95: /*
 96:    Simplified Schur-Parlett algorithm on an upper quasi-triangular matrix T,
 97:    particularized for the square root function. T is overwritten with sqrtm(T).
 98:    If firstonly then only the first column of T will contain relevant values.
 99:  */
100: PetscErrorCode SlepcSchurParlettSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld,PetscBool firstonly)
101: {
102: #if defined(SLEPC_MISSING_LAPACK_GEES) || defined(SLEPC_MISSING_LAPACK_TRSYL)
104:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEES/TRSYL - Lapack routines are unavailable");
105: #else
107:   PetscBLASInt   i,j,k,r,ione=1,sdim,lwork,*s,*p,info,bs=BLOCKSIZE;
108:   PetscScalar    *wr,*W,*Q,*work,one=1.0,zero=0.0,mone=-1.0;
109:   PetscInt       m,nblk;
110:   PetscReal      done=1.0;
111: #if defined(PETSC_USE_COMPLEX)
112:   PetscReal      *rwork;
113: #else
114:   PetscReal      *wi;
115: #endif

118:   m     = n;
119:   nblk  = (m+bs-1)/bs;
120:   lwork = 5*n;
121:   k     = firstonly? 1: n;

123:   /* compute Schur decomposition A*Q = Q*T */
124: #if !defined(PETSC_USE_COMPLEX)
125:   PetscMalloc7(m,&wr,m,&wi,m*k,&W,m*m,&Q,lwork,&work,nblk,&s,nblk,&p);
126:   PetscStackCallBLAS("LAPACKgees",LAPACKgees_("V","N",NULL,&n,T,&ld,&sdim,wr,wi,Q,&ld,work,&lwork,NULL,&info));
127:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEES %d",info);
128: #else
129:   PetscMalloc7(m,&wr,m,&rwork,m*k,&W,m*m,&Q,lwork,&work,nblk,&s,nblk,&p);
130:   PetscStackCallBLAS("LAPACKgees",LAPACKgees_("V","N",NULL,&n,T,&ld,&sdim,wr,Q,&ld,work,&lwork,rwork,NULL,&info));
131:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEES %d",info);
132: #endif

134:   /* determine block sizes and positions, to avoid cutting 2x2 blocks */
135:   j = 0;
136:   p[j] = 0;
137:   do {
138:     s[j] = PetscMin(bs,n-p[j]);
139: #if !defined(PETSC_USE_COMPLEX)
140:     if (p[j]+s[j]!=n && T[p[j]+s[j]+(p[j]+s[j]-1)*ld]!=0.0) s[j]++;
141: #endif
142:     if (p[j]+s[j]==n) break;
143:     j++;
144:     p[j] = p[j-1]+s[j-1];
145:   } while (1);
146:   nblk = j+1;

148:   for (j=0;j<nblk;j++) {
149:     /* evaluate f(T_jj) */
150:     SlepcMatDenseSqrt(s[j],T+p[j]+p[j]*ld,ld);
151:     for (i=j-1;i>=0;i--) {
152:       /* solve Sylvester equation for block (i,j) */
153:       r = p[j]-p[i]-s[i];
154:       if (r) PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",s+i,s+j,&r,&mone,T+p[i]+(p[i]+s[i])*ld,&ld,T+p[i]+s[i]+p[j]*ld,&ld,&one,T+p[i]+p[j]*ld,&ld));
155:       PetscStackCallBLAS("LAPACKtrsyl",LAPACKtrsyl_("N","N",&ione,s+i,s+j,T+p[i]+p[i]*ld,&ld,T+p[j]+p[j]*ld,&ld,T+p[i]+p[j]*ld,&ld,&done,&info));
156:       if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xTRSYL %d",info);
157:     }
158:   }

160:   /* backtransform B = Q*T*Q' */
161:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","C",&n,&k,&n,&one,T,&ld,Q,&ld,&zero,W,&ld));
162:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n,&k,&n,&one,Q,&ld,W,&ld,&zero,T,&ld));

164: #if !defined(PETSC_USE_COMPLEX)
165:   PetscFree7(wr,wi,W,Q,work,s,p);
166: #else
167:   PetscFree7(wr,rwork,W,Q,work,s,p);
168: #endif
169:   return(0);
170: #endif
171: }

slepc-3.7.4/src/sys/classes/makefile.html0000644000175000017500000000456113107004621017676 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  =
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
MANSEC   = sys
LOCDIR   = src/sys/classes/
DIRS     = ds fn st bv rg

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/index.html0000644000175000017500000000241013107004621017217 0ustar jromanjroman SLEPc System Routines
slepc-3.7.4 2017-05-17

SLEPc System routines

SLEPc provides a variety of "system" level routines. These routines are generally tools used by other SLEPc routines and are not intended for application programmers (except the basic SlepcInitialize() / SlepcFinalize()).

Useful tools for application programmers can be found in PETSc's system routines, including parallel file access, synchronized printing to screen, and many other programming aids.

ds/
fn/
st/
bv/
rg/
makefile
slepc-3.7.4/src/sys/classes/rg/0000755000175000017500000000000013107004621015635 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/makefile0000644000175000017500000000224313107004621017336 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../../../include/slepc/private/rgimpl.h ../../../../include/slepcrg.h ../../../../include/slepcrgtypes.h DIRS = interface impls examples LOCDIR = src/sys/classes/rg/ MANSEC = RG include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/interface/0000755000175000017500000000000013107004621017575 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/interface/makefile0000644000175000017500000000216413107004621021300 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = rgbasic.c rgregis.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = RG LOCDIR = src/sys/classes/rg/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/interface/rgregis.c.html0000644000175000017500000001170513107004621022352 0ustar jromanjroman

Actual source code: rgregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/rgimpl.h>      /*I "slepcrg.h" I*/

 24: PETSC_EXTERN PetscErrorCode RGCreate_Interval(RG);
 25: PETSC_EXTERN PetscErrorCode RGCreate_Ellipse(RG);
 26: PETSC_EXTERN PetscErrorCode RGCreate_Ring(RG);
 27: PETSC_EXTERN PetscErrorCode RGCreate_Polygon(RG);

 31: /*@C
 32:    RGRegisterAll - Registers all of the regions in the RG package.

 34:    Not Collective

 36:    Level: advanced
 37: @*/
 38: PetscErrorCode RGRegisterAll(void)
 39: {

 43:   if (RGRegisterAllCalled) return(0);
 44:   RGRegisterAllCalled = PETSC_TRUE;
 45:   RGRegister(RGINTERVAL,RGCreate_Interval);
 46:   RGRegister(RGELLIPSE,RGCreate_Ellipse);
 47:   RGRegister(RGRING,RGCreate_Ring);
 48:   RGRegister(RGPOLYGON,RGCreate_Polygon);
 49:   return(0);
 50: }

slepc-3.7.4/src/sys/classes/rg/interface/rgbasic.c.html0000644000175000017500000014243613107004621022330 0ustar jromanjroman
Actual source code: rgbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Basic routines

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/rgimpl.h>      /*I "slepcrg.h" I*/

 26: PetscFunctionList RGList = 0;
 27: PetscBool         RGRegisterAllCalled = PETSC_FALSE;
 28: PetscClassId      RG_CLASSID = 0;
 29: static PetscBool  RGPackageInitialized = PETSC_FALSE;

 33: /*@C
 34:    RGFinalizePackage - This function destroys everything in the Slepc interface
 35:    to the RG package. It is called from SlepcFinalize().

 37:    Level: developer

 39: .seealso: SlepcFinalize()
 40: @*/
 41: PetscErrorCode RGFinalizePackage(void)
 42: {

 46:   PetscFunctionListDestroy(&RGList);
 47:   RGPackageInitialized = PETSC_FALSE;
 48:   RGRegisterAllCalled  = PETSC_FALSE;
 49:   return(0);
 50: }

 54: /*@C
 55:   RGInitializePackage - This function initializes everything in the RG package.
 56:   It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 57:   on the first call to RGCreate() when using static libraries.

 59:   Level: developer

 61: .seealso: SlepcInitialize()
 62: @*/
 63: PetscErrorCode RGInitializePackage(void)
 64: {
 65:   char             logList[256];
 66:   char             *className;
 67:   PetscBool        opt;
 68:   PetscErrorCode   ierr;

 71:   if (RGPackageInitialized) return(0);
 72:   RGPackageInitialized = PETSC_TRUE;
 73:   /* Register Classes */
 74:   PetscClassIdRegister("Region",&RG_CLASSID);
 75:   /* Register Constructors */
 76:   RGRegisterAll();
 77:   /* Process info exclusions */
 78:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 79:   if (opt) {
 80:     PetscStrstr(logList,"rg",&className);
 81:     if (className) {
 82:       PetscInfoDeactivateClass(RG_CLASSID);
 83:     }
 84:   }
 85:   /* Process summary exclusions */
 86:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 87:   if (opt) {
 88:     PetscStrstr(logList,"rg",&className);
 89:     if (className) {
 90:       PetscLogEventDeactivateClass(RG_CLASSID);
 91:     }
 92:   }
 93:   PetscRegisterFinalize(RGFinalizePackage);
 94:   return(0);
 95: }

 99: /*@
100:    RGCreate - Creates an RG context.

102:    Collective on MPI_Comm

104:    Input Parameter:
105: .  comm - MPI communicator

107:    Output Parameter:
108: .  newrg - location to put the RG context

110:    Level: beginner

112: .seealso: RGDestroy(), RG
113: @*/
114: PetscErrorCode RGCreate(MPI_Comm comm,RG *newrg)
115: {
116:   RG             rg;

121:   *newrg = 0;
122:   RGInitializePackage();
123:   SlepcHeaderCreate(rg,RG_CLASSID,"RG","Region","RG",comm,RGDestroy,RGView);
124:   rg->complement = PETSC_FALSE;
125:   rg->sfactor    = 1.0;
126:   rg->osfactor   = 0.0;
127:   rg->data       = NULL;

129:   *newrg = rg;
130:   return(0);
131: }

135: /*@C
136:    RGSetOptionsPrefix - Sets the prefix used for searching for all
137:    RG options in the database.

139:    Logically Collective on RG

141:    Input Parameters:
142: +  rg     - the region context
143: -  prefix - the prefix string to prepend to all RG option requests

145:    Notes:
146:    A hyphen (-) must NOT be given at the beginning of the prefix name.
147:    The first character of all runtime options is AUTOMATICALLY the
148:    hyphen.

150:    Level: advanced

152: .seealso: RGAppendOptionsPrefix()
153: @*/
154: PetscErrorCode RGSetOptionsPrefix(RG rg,const char *prefix)
155: {

160:   PetscObjectSetOptionsPrefix((PetscObject)rg,prefix);
161:   return(0);
162: }

166: /*@C
167:    RGAppendOptionsPrefix - Appends to the prefix used for searching for all
168:    RG options in the database.

170:    Logically Collective on RG

172:    Input Parameters:
173: +  rg     - the region context
174: -  prefix - the prefix string to prepend to all RG option requests

176:    Notes:
177:    A hyphen (-) must NOT be given at the beginning of the prefix name.
178:    The first character of all runtime options is AUTOMATICALLY the hyphen.

180:    Level: advanced

182: .seealso: RGSetOptionsPrefix()
183: @*/
184: PetscErrorCode RGAppendOptionsPrefix(RG rg,const char *prefix)
185: {

190:   PetscObjectAppendOptionsPrefix((PetscObject)rg,prefix);
191:   return(0);
192: }

196: /*@C
197:    RGGetOptionsPrefix - Gets the prefix used for searching for all
198:    RG options in the database.

200:    Not Collective

202:    Input Parameters:
203: .  rg - the region context

205:    Output Parameters:
206: .  prefix - pointer to the prefix string used is returned

208:    Note:
209:    On the Fortran side, the user should pass in a string 'prefix' of
210:    sufficient length to hold the prefix.

212:    Level: advanced

214: .seealso: RGSetOptionsPrefix(), RGAppendOptionsPrefix()
215: @*/
216: PetscErrorCode RGGetOptionsPrefix(RG rg,const char *prefix[])
217: {

223:   PetscObjectGetOptionsPrefix((PetscObject)rg,prefix);
224:   return(0);
225: }

229: /*@C
230:    RGSetType - Selects the type for the RG object.

232:    Logically Collective on RG

234:    Input Parameter:
235: +  rg   - the region context
236: -  type - a known type

238:    Level: intermediate

240: .seealso: RGGetType()
241: @*/
242: PetscErrorCode RGSetType(RG rg,RGType type)
243: {
244:   PetscErrorCode ierr,(*r)(RG);
245:   PetscBool      match;


251:   PetscObjectTypeCompare((PetscObject)rg,type,&match);
252:   if (match) return(0);

254:    PetscFunctionListFind(RGList,type,&r);
255:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested RG type %s",type);

257:   if (rg->ops->destroy) { (*rg->ops->destroy)(rg); }
258:   PetscMemzero(rg->ops,sizeof(struct _RGOps));

260:   PetscObjectChangeTypeName((PetscObject)rg,type);
261:   (*r)(rg);
262:   return(0);
263: }

267: /*@C
268:    RGGetType - Gets the RG type name (as a string) from the RG context.

270:    Not Collective

272:    Input Parameter:
273: .  rg - the region context

275:    Output Parameter:
276: .  name - name of the region

278:    Level: intermediate

280: .seealso: RGSetType()
281: @*/
282: PetscErrorCode RGGetType(RG rg,RGType *type)
283: {
287:   *type = ((PetscObject)rg)->type_name;
288:   return(0);
289: }

293: /*@
294:    RGSetFromOptions - Sets RG options from the options database.

296:    Collective on RG

298:    Input Parameters:
299: .  rg - the region context

301:    Notes:
302:    To see all options, run your program with the -help option.

304:    Level: beginner
305: @*/
306: PetscErrorCode RGSetFromOptions(RG rg)
307: {
309:   char           type[256];
310:   PetscBool      flg;
311:   PetscReal      sfactor;

315:   RGRegisterAll();
316:   PetscObjectOptionsBegin((PetscObject)rg);
317:     PetscOptionsFList("-rg_type","Region type","RGSetType",RGList,(char*)(((PetscObject)rg)->type_name?((PetscObject)rg)->type_name:RGINTERVAL),type,256,&flg);
318:     if (flg) {
319:       RGSetType(rg,type);
320:     }
321:     /*
322:       Set the type if it was never set.
323:     */
324:     if (!((PetscObject)rg)->type_name) {
325:       RGSetType(rg,RGINTERVAL);
326:     }

328:     PetscOptionsBool("-rg_complement","Whether region is complemented or not","RGSetComplement",rg->complement,&rg->complement,NULL);
329:     PetscOptionsReal("-rg_scale","Scaling factor","RGSetScale",1.0,&sfactor,&flg);
330:     if (flg) {
331:       RGSetScale(rg,sfactor);
332:     }

334:     if (rg->ops->setfromoptions) {
335:       (*rg->ops->setfromoptions)(PetscOptionsObject,rg);
336:     }
337:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)rg);
338:   PetscOptionsEnd();
339:   return(0);
340: }

344: /*@C
345:    RGView - Prints the RG data structure.

347:    Collective on RG

349:    Input Parameters:
350: +  rg - the region context
351: -  viewer - optional visualization context

353:    Note:
354:    The available visualization contexts include
355: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
356: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
357:          output where only the first processor opens
358:          the file.  All other processors send their
359:          data to the first processor to print.

361:    The user can open an alternative visualization context with
362:    PetscViewerASCIIOpen() - output to a specified file.

364:    Level: beginner
365: @*/
366: PetscErrorCode RGView(RG rg,PetscViewer viewer)
367: {
368:   PetscBool      isascii;

373:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)rg));
376:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
377:   if (isascii) {
378:     PetscObjectPrintClassNamePrefixType((PetscObject)rg,viewer);
379:     if (rg->ops->view) {
380:       PetscViewerASCIIPushTab(viewer);
381:       (*rg->ops->view)(rg,viewer);
382:       PetscViewerASCIIPopTab(viewer);
383:     }
384:     if (rg->complement) {
385:       PetscViewerASCIIPrintf(viewer,"  selected region is the complement of the specified one\n");
386:     }
387:     if (rg->sfactor!=1.0) {
388:       PetscViewerASCIIPrintf(viewer,"  scaling factor = %g\n",(double)rg->sfactor);
389:     }
390:   }
391:   return(0);
392: }

396: /*@
397:    RGIsTrivial - Whether it is the trivial region (whole complex plane).

399:    Not Collective

401:    Input Parameter:
402: .  rg - the region context

404:    Output Parameter:
405: .  trivial - true if the region is equal to the whole complex plane, e.g.,
406:              an interval region with all four endpoints unbounded or an
407:              ellipse with infinite radius.

409:    Level: beginner
410: @*/
411: PetscErrorCode RGIsTrivial(RG rg,PetscBool *trivial)
412: {

419:   if (rg->ops->istrivial) {
420:     (*rg->ops->istrivial)(rg,trivial);
421:   } else *trivial = PETSC_FALSE;
422:   return(0);
423: }

427: /*@
428:    RGCheckInside - Determines if a set of given points are inside the region or not.

430:    Not Collective

432:    Input Parameters:
433: +  rg - the region context
434: .  n  - number of points to check
435: .  ar - array of real parts
436: -  ai - array of imaginary parts

438:    Output Parameter:
439: .  inside - array of results (1=inside, 0=on the contour, -1=outside)

441:    Note:
442:    The point a is expressed as a couple of PetscScalar variables ar,ai.
443:    If built with complex scalars, the point is supposed to be stored in ar,
444:    otherwise ar,ai contain the real and imaginary parts, respectively.

446:    If a scaling factor was set, the points are scaled before checking.

448:    Level: intermediate

450: .seealso: RGSetScale(), RGSetComplement()
451: @*/
452: PetscErrorCode RGCheckInside(RG rg,PetscInt n,PetscScalar *ar,PetscScalar *ai,PetscInt *inside)
453: {
455:   PetscReal      px,py;
456:   PetscInt       i;

462: #if !defined(PETSC_USE_COMPLEX)
464: #endif

467:   for (i=0;i<n;i++) {
468: #if defined(PETSC_USE_COMPLEX)
469:     px = PetscRealPart(ar[i]);
470:     py = PetscImaginaryPart(ar[i]);
471: #else
472:     px = ar[i];
473:     py = ai[i];
474: #endif
475:     if (rg->sfactor != 1.0) {
476:       px /= rg->sfactor;
477:       py /= rg->sfactor;
478:     }
479:     (*rg->ops->checkinside)(rg,px,py,inside+i);
480:     if (rg->complement) inside[i] = -inside[i];
481:   }
482:   return(0);
483: }

487: /*@
488:    RGComputeContour - Computes the coordinates of several points lying in the
489:    contour of the region.

491:    Not Collective

493:    Input Parameters:
494: +  rg - the region context
495: -  n  - number of points to compute

497:    Output Parameter:
498: +  cr - location to store real parts
499: -  ci - location to store imaginary parts

501:    Level: intermediate
502: @*/
503: PetscErrorCode RGComputeContour(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)
504: {
505:   PetscInt       i;

512: #if !defined(PETSC_USE_COMPLEX)
514: #endif
515:   (*rg->ops->computecontour)(rg,n,cr,ci);
516:   for (i=0;i<n;i++) {
517:     cr[i] *= rg->sfactor;
518:     ci[i] *= rg->sfactor;
519:   }
520:   return(0);
521: }

525: /*@
526:    RGSetComplement - Sets a flag to indicate that the region is the complement
527:    of the specified one.

529:    Logically Collective on RG

531:    Input Parameters:
532: +  rg  - the region context
533: -  flg - the boolean flag

535:    Options Database Key:
536: .  -rg_complement <bool> - Activate/deactivate the complementation of the region

538:    Level: intermediate

540: .seealso: RGGetComplement()
541: @*/
542: PetscErrorCode RGSetComplement(RG rg,PetscBool flg)
543: {
547:   rg->complement = flg;
548:   return(0);
549: }

553: /*@
554:    RGGetComplement - Gets a flag that that indicates whether the region
555:    is complemented or not.

557:    Not Collective

559:    Input Parameter:
560: .  rg - the region context

562:    Output Parameter:
563: .  flg - the flag

565:    Level: intermediate

567: .seealso: RGSetComplement()
568: @*/
569: PetscErrorCode RGGetComplement(RG rg,PetscBool *flg)
570: {
574:   *flg = rg->complement;
575:   return(0);
576: }

580: /*@
581:    RGSetScale - Sets the scaling factor to be used when checking that a
582:    point is inside the region and when computing the contour.

584:    Logically Collective on RG

586:    Input Parameters:
587: +  rg      - the region context
588: -  sfactor - the scaling factor

590:    Options Database Key:
591: .  -rg_scale <real> - Sets the scaling factor

593:    Level: advanced

595: .seealso: RGGetScale(), RGCheckInside()
596: @*/
597: PetscErrorCode RGSetScale(RG rg,PetscReal sfactor)
598: {
602:   if (sfactor == PETSC_DEFAULT || sfactor == PETSC_DECIDE) rg->sfactor = 1.0;
603:   else {
604:     if (sfactor<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of scaling factor. Must be > 0");
605:     rg->sfactor = sfactor;
606:   }
607:   return(0);
608: }

612: /*@
613:    RGGetScale - Gets the scaling factor.

615:    Not Collective

617:    Input Parameter:
618: .  rg - the region context

620:    Output Parameter:
621: .  flg - the flag

623:    Level: advanced

625: .seealso: RGSetScale()
626: @*/
627: PetscErrorCode RGGetScale(RG rg,PetscReal *sfactor)
628: {
632:   *sfactor = rg->sfactor;
633:   return(0);
634: }

638: /*@
639:    RGPushScale - Sets an additional scaling factor, that will multiply the
640:    user-defined scaling factor.

642:    Logically Collective on RG

644:    Input Parameters:
645: +  rg      - the region context
646: -  sfactor - the scaling factor

648:    Notes:
649:    The current implementation does not allow pushing several scaling factors.

651:    This is intended for internal use, for instance in polynomial eigensolvers
652:    that use parameter scaling.

654:    Level: developer

656: .seealso: RGPopScale(), RGSetScale()
657: @*/
658: PetscErrorCode RGPushScale(RG rg,PetscReal sfactor)
659: {
663:   if (sfactor<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of scaling factor. Must be > 0");
664:   if (rg->osfactor) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_SUP,"Current implementation does not allow pushing several scaling factors");
665:   rg->osfactor = rg->sfactor;
666:   rg->sfactor *= sfactor;
667:   return(0);
668: }

672: /*@
673:    RGPopScale - Pops the scaling factor set with RGPushScale().

675:    Not Collective

677:    Input Parameter:
678: .  rg - the region context

680:    Level: developer

682: .seealso: RGPushScale()
683: @*/
684: PetscErrorCode RGPopScale(RG rg)
685: {
688:   if (!rg->osfactor) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ORDER,"Must call RGPushScale first");
689:   rg->sfactor  = rg->osfactor;
690:   rg->osfactor = 0.0;
691:   return(0);
692: }

696: /*@
697:    RGDestroy - Destroys RG context that was created with RGCreate().

699:    Collective on RG

701:    Input Parameter:
702: .  rg - the region context

704:    Level: beginner

706: .seealso: RGCreate()
707: @*/
708: PetscErrorCode RGDestroy(RG *rg)
709: {

713:   if (!*rg) return(0);
715:   if (--((PetscObject)(*rg))->refct > 0) { *rg = 0; return(0); }
716:   if ((*rg)->ops->destroy) { (*(*rg)->ops->destroy)(*rg); }
717:   PetscHeaderDestroy(rg);
718:   return(0);
719: }

723: /*@C
724:    RGRegister - Adds a region to the RG package.

726:    Not collective

728:    Input Parameters:
729: +  name - name of a new user-defined RG
730: -  function - routine to create context

732:    Notes:
733:    RGRegister() may be called multiple times to add several user-defined regions.

735:    Level: advanced

737: .seealso: RGRegisterAll()
738: @*/
739: PetscErrorCode RGRegister(const char *name,PetscErrorCode (*function)(RG))
740: {

744:   PetscFunctionListAdd(&RGList,name,function);
745:   return(0);
746: }

slepc-3.7.4/src/sys/classes/rg/interface/rgbasic.c0000644000175000017500000004641013107004621021360 0ustar jromanjroman/* Basic routines - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcrg.h" I*/ PetscFunctionList RGList = 0; PetscBool RGRegisterAllCalled = PETSC_FALSE; PetscClassId RG_CLASSID = 0; static PetscBool RGPackageInitialized = PETSC_FALSE; #undef __FUNCT__ #define __FUNCT__ "RGFinalizePackage" /*@C RGFinalizePackage - This function destroys everything in the Slepc interface to the RG package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode RGFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&RGList);CHKERRQ(ierr); RGPackageInitialized = PETSC_FALSE; RGRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGInitializePackage" /*@C RGInitializePackage - This function initializes everything in the RG package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to RGCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode RGInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (RGPackageInitialized) PetscFunctionReturn(0); RGPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("Region",&RG_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = RGRegisterAll();CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"rg",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(RG_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"rg",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(RG_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(RGFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCreate" /*@ RGCreate - Creates an RG context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . newrg - location to put the RG context Level: beginner .seealso: RGDestroy(), RG @*/ PetscErrorCode RGCreate(MPI_Comm comm,RG *newrg) { RG rg; PetscErrorCode ierr; PetscFunctionBegin; PetscValidPointer(newrg,2); *newrg = 0; ierr = RGInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(rg,RG_CLASSID,"RG","Region","RG",comm,RGDestroy,RGView);CHKERRQ(ierr); rg->complement = PETSC_FALSE; rg->sfactor = 1.0; rg->osfactor = 0.0; rg->data = NULL; *newrg = rg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetOptionsPrefix" /*@C RGSetOptionsPrefix - Sets the prefix used for searching for all RG options in the database. Logically Collective on RG Input Parameters: + rg - the region context - prefix - the prefix string to prepend to all RG option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: RGAppendOptionsPrefix() @*/ PetscErrorCode RGSetOptionsPrefix(RG rg,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = PetscObjectSetOptionsPrefix((PetscObject)rg,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGAppendOptionsPrefix" /*@C RGAppendOptionsPrefix - Appends to the prefix used for searching for all RG options in the database. Logically Collective on RG Input Parameters: + rg - the region context - prefix - the prefix string to prepend to all RG option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: RGSetOptionsPrefix() @*/ PetscErrorCode RGAppendOptionsPrefix(RG rg,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)rg,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGGetOptionsPrefix" /*@C RGGetOptionsPrefix - Gets the prefix used for searching for all RG options in the database. Not Collective Input Parameters: . rg - the region context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: RGSetOptionsPrefix(), RGAppendOptionsPrefix() @*/ PetscErrorCode RGGetOptionsPrefix(RG rg,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)rg,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetType" /*@C RGSetType - Selects the type for the RG object. Logically Collective on RG Input Parameter: + rg - the region context - type - a known type Level: intermediate .seealso: RGGetType() @*/ PetscErrorCode RGSetType(RG rg,RGType type) { PetscErrorCode ierr,(*r)(RG); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)rg,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(RGList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested RG type %s",type); if (rg->ops->destroy) { ierr = (*rg->ops->destroy)(rg);CHKERRQ(ierr); } ierr = PetscMemzero(rg->ops,sizeof(struct _RGOps));CHKERRQ(ierr); ierr = PetscObjectChangeTypeName((PetscObject)rg,type);CHKERRQ(ierr); ierr = (*r)(rg);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGGetType" /*@C RGGetType - Gets the RG type name (as a string) from the RG context. Not Collective Input Parameter: . rg - the region context Output Parameter: . name - name of the region Level: intermediate .seealso: RGSetType() @*/ PetscErrorCode RGGetType(RG rg,RGType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)rg)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetFromOptions" /*@ RGSetFromOptions - Sets RG options from the options database. Collective on RG Input Parameters: . rg - the region context Notes: To see all options, run your program with the -help option. Level: beginner @*/ PetscErrorCode RGSetFromOptions(RG rg) { PetscErrorCode ierr; char type[256]; PetscBool flg; PetscReal sfactor; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = RGRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)rg);CHKERRQ(ierr); ierr = PetscOptionsFList("-rg_type","Region type","RGSetType",RGList,(char*)(((PetscObject)rg)->type_name?((PetscObject)rg)->type_name:RGINTERVAL),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = RGSetType(rg,type);CHKERRQ(ierr); } /* Set the type if it was never set. */ if (!((PetscObject)rg)->type_name) { ierr = RGSetType(rg,RGINTERVAL);CHKERRQ(ierr); } ierr = PetscOptionsBool("-rg_complement","Whether region is complemented or not","RGSetComplement",rg->complement,&rg->complement,NULL);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_scale","Scaling factor","RGSetScale",1.0,&sfactor,&flg);CHKERRQ(ierr); if (flg) { ierr = RGSetScale(rg,sfactor);CHKERRQ(ierr); } if (rg->ops->setfromoptions) { ierr = (*rg->ops->setfromoptions)(PetscOptionsObject,rg);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)rg);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGView" /*@C RGView - Prints the RG data structure. Collective on RG Input Parameters: + rg - the region context - viewer - optional visualization context Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner @*/ PetscErrorCode RGView(RG rg,PetscViewer viewer) { PetscBool isascii; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)rg)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(rg,1,viewer,2); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)rg,viewer);CHKERRQ(ierr); if (rg->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*rg->ops->view)(rg,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } if (rg->complement) { ierr = PetscViewerASCIIPrintf(viewer," selected region is the complement of the specified one\n");CHKERRQ(ierr); } if (rg->sfactor!=1.0) { ierr = PetscViewerASCIIPrintf(viewer," scaling factor = %g\n",(double)rg->sfactor);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIsTrivial" /*@ RGIsTrivial - Whether it is the trivial region (whole complex plane). Not Collective Input Parameter: . rg - the region context Output Parameter: . trivial - true if the region is equal to the whole complex plane, e.g., an interval region with all four endpoints unbounded or an ellipse with infinite radius. Level: beginner @*/ PetscErrorCode RGIsTrivial(RG rg,PetscBool *trivial) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidType(rg,1); PetscValidPointer(trivial,2); if (rg->ops->istrivial) { ierr = (*rg->ops->istrivial)(rg,trivial);CHKERRQ(ierr); } else *trivial = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCheckInside" /*@ RGCheckInside - Determines if a set of given points are inside the region or not. Not Collective Input Parameters: + rg - the region context . n - number of points to check . ar - array of real parts - ai - array of imaginary parts Output Parameter: . inside - array of results (1=inside, 0=on the contour, -1=outside) Note: The point a is expressed as a couple of PetscScalar variables ar,ai. If built with complex scalars, the point is supposed to be stored in ar, otherwise ar,ai contain the real and imaginary parts, respectively. If a scaling factor was set, the points are scaled before checking. Level: intermediate .seealso: RGSetScale(), RGSetComplement() @*/ PetscErrorCode RGCheckInside(RG rg,PetscInt n,PetscScalar *ar,PetscScalar *ai,PetscInt *inside) { PetscErrorCode ierr; PetscReal px,py; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidType(rg,1); PetscValidPointer(ar,3); #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(ai,4); #endif PetscValidPointer(inside,5); for (i=0;isfactor != 1.0) { px /= rg->sfactor; py /= rg->sfactor; } ierr = (*rg->ops->checkinside)(rg,px,py,inside+i);CHKERRQ(ierr); if (rg->complement) inside[i] = -inside[i]; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGComputeContour" /*@ RGComputeContour - Computes the coordinates of several points lying in the contour of the region. Not Collective Input Parameters: + rg - the region context - n - number of points to compute Output Parameter: + cr - location to store real parts - ci - location to store imaginary parts Level: intermediate @*/ PetscErrorCode RGComputeContour(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci) { PetscInt i; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidType(rg,1); PetscValidPointer(cr,3); #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(ci,4); #endif ierr = (*rg->ops->computecontour)(rg,n,cr,ci);CHKERRQ(ierr); for (i=0;isfactor; ci[i] *= rg->sfactor; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetComplement" /*@ RGSetComplement - Sets a flag to indicate that the region is the complement of the specified one. Logically Collective on RG Input Parameters: + rg - the region context - flg - the boolean flag Options Database Key: . -rg_complement - Activate/deactivate the complementation of the region Level: intermediate .seealso: RGGetComplement() @*/ PetscErrorCode RGSetComplement(RG rg,PetscBool flg) { PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidLogicalCollectiveBool(rg,flg,2); rg->complement = flg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGGetComplement" /*@ RGGetComplement - Gets a flag that that indicates whether the region is complemented or not. Not Collective Input Parameter: . rg - the region context Output Parameter: . flg - the flag Level: intermediate .seealso: RGSetComplement() @*/ PetscErrorCode RGGetComplement(RG rg,PetscBool *flg) { PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidPointer(flg,2); *flg = rg->complement; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetScale" /*@ RGSetScale - Sets the scaling factor to be used when checking that a point is inside the region and when computing the contour. Logically Collective on RG Input Parameters: + rg - the region context - sfactor - the scaling factor Options Database Key: . -rg_scale - Sets the scaling factor Level: advanced .seealso: RGGetScale(), RGCheckInside() @*/ PetscErrorCode RGSetScale(RG rg,PetscReal sfactor) { PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidLogicalCollectiveReal(rg,sfactor,2); if (sfactor == PETSC_DEFAULT || sfactor == PETSC_DECIDE) rg->sfactor = 1.0; else { if (sfactor<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of scaling factor. Must be > 0"); rg->sfactor = sfactor; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGGetScale" /*@ RGGetScale - Gets the scaling factor. Not Collective Input Parameter: . rg - the region context Output Parameter: . flg - the flag Level: advanced .seealso: RGSetScale() @*/ PetscErrorCode RGGetScale(RG rg,PetscReal *sfactor) { PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidPointer(sfactor,2); *sfactor = rg->sfactor; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGPushScale" /*@ RGPushScale - Sets an additional scaling factor, that will multiply the user-defined scaling factor. Logically Collective on RG Input Parameters: + rg - the region context - sfactor - the scaling factor Notes: The current implementation does not allow pushing several scaling factors. This is intended for internal use, for instance in polynomial eigensolvers that use parameter scaling. Level: developer .seealso: RGPopScale(), RGSetScale() @*/ PetscErrorCode RGPushScale(RG rg,PetscReal sfactor) { PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidLogicalCollectiveReal(rg,sfactor,2); if (sfactor<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of scaling factor. Must be > 0"); if (rg->osfactor) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_SUP,"Current implementation does not allow pushing several scaling factors"); rg->osfactor = rg->sfactor; rg->sfactor *= sfactor; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGPopScale" /*@ RGPopScale - Pops the scaling factor set with RGPushScale(). Not Collective Input Parameter: . rg - the region context Level: developer .seealso: RGPushScale() @*/ PetscErrorCode RGPopScale(RG rg) { PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); if (!rg->osfactor) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ORDER,"Must call RGPushScale first"); rg->sfactor = rg->osfactor; rg->osfactor = 0.0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGDestroy" /*@ RGDestroy - Destroys RG context that was created with RGCreate(). Collective on RG Input Parameter: . rg - the region context Level: beginner .seealso: RGCreate() @*/ PetscErrorCode RGDestroy(RG *rg) { PetscErrorCode ierr; PetscFunctionBegin; if (!*rg) PetscFunctionReturn(0); PetscValidHeaderSpecific(*rg,RG_CLASSID,1); if (--((PetscObject)(*rg))->refct > 0) { *rg = 0; PetscFunctionReturn(0); } if ((*rg)->ops->destroy) { ierr = (*(*rg)->ops->destroy)(*rg);CHKERRQ(ierr); } ierr = PetscHeaderDestroy(rg);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGRegister" /*@C RGRegister - Adds a region to the RG package. Not collective Input Parameters: + name - name of a new user-defined RG - function - routine to create context Notes: RGRegister() may be called multiple times to add several user-defined regions. Level: advanced .seealso: RGRegisterAll() @*/ PetscErrorCode RGRegister(const char *name,PetscErrorCode (*function)(RG)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&RGList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/rg/interface/makefile.html0000644000175000017500000000470313107004621022244 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = rgbasic.c rgregis.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = RG
LOCDIR   = src/sys/classes/rg/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common
slepc-3.7.4/src/sys/classes/rg/interface/rgregis.c0000644000175000017500000000340413107004621021404 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcrg.h" I*/ PETSC_EXTERN PetscErrorCode RGCreate_Interval(RG); PETSC_EXTERN PetscErrorCode RGCreate_Ellipse(RG); PETSC_EXTERN PetscErrorCode RGCreate_Ring(RG); PETSC_EXTERN PetscErrorCode RGCreate_Polygon(RG); #undef __FUNCT__ #define __FUNCT__ "RGRegisterAll" /*@C RGRegisterAll - Registers all of the regions in the RG package. Not Collective Level: advanced @*/ PetscErrorCode RGRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (RGRegisterAllCalled) PetscFunctionReturn(0); RGRegisterAllCalled = PETSC_TRUE; ierr = RGRegister(RGINTERVAL,RGCreate_Interval);CHKERRQ(ierr); ierr = RGRegister(RGELLIPSE,RGCreate_Ellipse);CHKERRQ(ierr); ierr = RGRegister(RGRING,RGCreate_Ring);CHKERRQ(ierr); ierr = RGRegister(RGPOLYGON,RGCreate_Polygon);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/rg/interface/index.html0000644000175000017500000000164513107004621021600 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

rgbasic.c
rgregis.c
makefile
slepc-3.7.4/src/sys/classes/rg/interface/ftn-auto/0000755000175000017500000000000013107004621021332 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/interface/ftn-auto/makefile0000644000175000017500000000036013107004621023031 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = rgbasicf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/rg/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/interface/ftn-auto/rgbasicf.c0000644000175000017500000001126713107004621023265 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* rgbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcrg.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgcreate_ RGCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgcreate_ rgcreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgsetfromoptions_ RGSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgsetfromoptions_ rgsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgistrivial_ RGISTRIVIAL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgistrivial_ rgistrivial #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgcheckinside_ RGCHECKINSIDE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgcheckinside_ rgcheckinside #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgcomputecontour_ RGCOMPUTECONTOUR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgcomputecontour_ rgcomputecontour #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgsetcomplement_ RGSETCOMPLEMENT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgsetcomplement_ rgsetcomplement #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rggetcomplement_ RGGETCOMPLEMENT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rggetcomplement_ rggetcomplement #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgsetscale_ RGSETSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgsetscale_ rgsetscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rggetscale_ RGGETSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rggetscale_ rggetscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgpushscale_ RGPUSHSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgpushscale_ rgpushscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgpopscale_ RGPOPSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgpopscale_ rgpopscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgdestroy_ RGDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgdestroy_ rgdestroy #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL rgcreate_(MPI_Fint * comm,RG *newrg, int *__ierr ){ *__ierr = RGCreate( MPI_Comm_f2c(*(comm)),newrg); } PETSC_EXTERN void PETSC_STDCALL rgsetfromoptions_(RG rg, int *__ierr ){ *__ierr = RGSetFromOptions( (RG)PetscToPointer((rg) )); } PETSC_EXTERN void PETSC_STDCALL rgistrivial_(RG rg,PetscBool *trivial, int *__ierr ){ *__ierr = RGIsTrivial( (RG)PetscToPointer((rg) ),trivial); } PETSC_EXTERN void PETSC_STDCALL rgcheckinside_(RG rg,PetscInt *n,PetscScalar *ar,PetscScalar *ai,PetscInt *inside, int *__ierr ){ *__ierr = RGCheckInside( (RG)PetscToPointer((rg) ),*n,ar,ai,inside); } PETSC_EXTERN void PETSC_STDCALL rgcomputecontour_(RG rg,PetscInt *n,PetscScalar *cr,PetscScalar *ci, int *__ierr ){ *__ierr = RGComputeContour( (RG)PetscToPointer((rg) ),*n,cr,ci); } PETSC_EXTERN void PETSC_STDCALL rgsetcomplement_(RG rg,PetscBool *flg, int *__ierr ){ *__ierr = RGSetComplement( (RG)PetscToPointer((rg) ),*flg); } PETSC_EXTERN void PETSC_STDCALL rggetcomplement_(RG rg,PetscBool *flg, int *__ierr ){ *__ierr = RGGetComplement( (RG)PetscToPointer((rg) ),flg); } PETSC_EXTERN void PETSC_STDCALL rgsetscale_(RG rg,PetscReal *sfactor, int *__ierr ){ *__ierr = RGSetScale( (RG)PetscToPointer((rg) ),*sfactor); } PETSC_EXTERN void PETSC_STDCALL rggetscale_(RG rg,PetscReal *sfactor, int *__ierr ){ *__ierr = RGGetScale( (RG)PetscToPointer((rg) ),sfactor); } PETSC_EXTERN void PETSC_STDCALL rgpushscale_(RG rg,PetscReal *sfactor, int *__ierr ){ *__ierr = RGPushScale( (RG)PetscToPointer((rg) ),*sfactor); } PETSC_EXTERN void PETSC_STDCALL rgpopscale_(RG rg, int *__ierr ){ *__ierr = RGPopScale( (RG)PetscToPointer((rg) )); } PETSC_EXTERN void PETSC_STDCALL rgdestroy_(RG *rg, int *__ierr ){ *__ierr = RGDestroy(rg); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/rg/interface/ftn-custom/0000755000175000017500000000000013107004621021674 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/interface/ftn-custom/makefile0000644000175000017500000000222313107004621023373 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zrgf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/rg/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/interface/ftn-custom/zrgf.c0000644000175000017500000000603513107004621023014 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define rgsettype_ RGSETTYPE #define rggettype_ RGGETTYPE #define rgsetoptionsprefix_ RGSETOPTIONSPREFIX #define rgappendoptionsprefix_ RGAPPENDOPTIONSPREFIX #define rggetoptionsprefix_ RGGETOPTIONSPREFIX #define rgview_ RGVIEW #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define rgsettype_ rgsettype #define rggettype_ rggettype #define rgsetoptionsprefix_ rgsetoptionsprefix #define rgappendoptionsprefix_ rgappendoptionsprefix #define rggetoptionsprefix_ rggetoptionsprefix #define rgview_ rgview #endif PETSC_EXTERN void PETSC_STDCALL rgsettype_(RG *rg,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = RGSetType(*rg,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL rggettype_(RG *rg,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { RGType tname; *ierr = RGGetType(*rg,&tname); if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL rgsetoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = RGSetOptionsPrefix(*rg,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL rgappendoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = RGAppendOptionsPrefix(*rg,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL rggetoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = RGGetOptionsPrefix(*rg,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL rgview_(RG *rg,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = RGView(*rg,v); } slepc-3.7.4/src/sys/classes/rg/examples/0000755000175000017500000000000013107004621017453 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/examples/makefile0000644000175000017500000000202013107004621021145 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/sys/classes/rg/examples/ DIRS = tests include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/examples/makefile.html0000644000175000017500000000445313107004621022124 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/sys/classes/rg/examples/
DIRS     = tests

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/rg/examples/index.html0000644000175000017500000000124013107004621021445 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
makefile
slepc-3.7.4/src/sys/classes/rg/examples/tests/0000755000175000017500000000000013107004621020615 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/examples/tests/makefile0000644000175000017500000000306213107004621022316 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/sys/classes/rg/examples/tests/ EXAMPLESC = test1.c EXAMPLESF = MANSEC = RG TESTS = test1 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB} ${RM} test1.o #------------------------------------------------------------------------------------ runtest1_1: -@${MPIEXEC} -n 1 ./test1 > test1_1.tmp 2>&1; \ if (${DIFF} output/test1_1.out test1_1.tmp) then true; \ else echo "Possible problem with test1_1, diffs above"; fi; \ ${RM} -f test1_1.tmp slepc-3.7.4/src/sys/classes/rg/examples/tests/test1.c.html0000644000175000017500000002345013107004621022770 0ustar jromanjroman

Actual source code: test1.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test RG interface functions.\n\n";

 24: #include <slepcrg.h>

 28: int main(int argc,char **argv)
 29: {
 31:   RG             rg;
 32:   PetscInt       i,inside;
 33:   PetscReal      re,im;
 34:   PetscScalar    ar,ai,cr[10],ci[10],vr[7],vi[7];

 36:   SlepcInitialize(&argc,&argv,(char*)0,help);
 37:   RGCreate(PETSC_COMM_WORLD,&rg);

 39:   /* ellipse */
 40:   RGSetType(rg,RGELLIPSE);
 41:   RGEllipseSetParameters(rg,1.1,2,0.1);
 42:   RGSetFromOptions(rg);
 43:   RGView(rg,NULL);
 44:   re = 0.1; im = 0.3;
 45: #if defined(PETSC_USE_COMPLEX)
 46:   ar = re+im*PETSC_i;
 47: #else
 48:   ar = re; ai = im;
 49: #endif
 50:   RGCheckInside(rg,1,&ar,&ai,&inside);
 51:   PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside");

 53:   PetscPrintf(PETSC_COMM_WORLD,"Contour points: ");
 54:   RGComputeContour(rg,10,cr,ci);
 55:   for (i=0;i<10;i++) {
 56: #if defined(PETSC_USE_COMPLEX)
 57:     re = PetscRealPart(cr[i]);
 58:     im = PetscImaginaryPart(cr[i]);
 59: #else
 60:     re = cr[i];
 61:     im = ci[i];
 62: #endif
 63:     PetscPrintf(PETSC_COMM_WORLD,"(%.3g,%.3g) ",(double)re,(double)im);
 64:   }
 65:   PetscPrintf(PETSC_COMM_WORLD,"\n");

 67:   /* interval */
 68:   RGSetType(rg,RGINTERVAL);
 69:   RGIntervalSetEndpoints(rg,-1,1,-0.1,0.1);
 70:   RGSetFromOptions(rg);
 71:   RGView(rg,NULL);
 72:   re = 0.2; im = 0;
 73: #if defined(PETSC_USE_COMPLEX)
 74:   ar = re+im*PETSC_i;
 75: #else
 76:   ar = re; ai = im;
 77: #endif
 78:   RGCheckInside(rg,1,&ar,&ai,&inside);
 79:   PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside");

 81:   /* polygon */
 82: #if defined(PETSC_USE_COMPLEX)
 83:   vr[0] = 0.0+2.0*PETSC_i;
 84:   vr[1] = 1.0+4.0*PETSC_i;
 85:   vr[2] = 2.0+5.0*PETSC_i;
 86:   vr[3] = 4.0+3.0*PETSC_i;
 87:   vr[4] = 5.0+4.0*PETSC_i;
 88:   vr[5] = 6.0+1.0*PETSC_i;
 89:   vr[6] = 2.0+0.0*PETSC_i;
 90: #else
 91:   vr[0] = 0.0; vi[0] = 2.0;
 92:   vr[1] = 1.0; vi[1] = 4.0;
 93:   vr[2] = 2.0; vi[2] = 5.0;
 94:   vr[3] = 4.0; vi[3] = 3.0;
 95:   vr[4] = 5.0; vi[4] = 4.0;
 96:   vr[5] = 6.0; vi[5] = 1.0;
 97:   vr[6] = 2.0; vi[6] = 0.0;
 98: #endif
 99:   RGSetType(rg,RGPOLYGON);
100:   RGPolygonSetVertices(rg,7,vr,vi);
101:   RGSetFromOptions(rg);
102:   RGView(rg,NULL);
103:   re = 5; im = 0.9;
104: #if defined(PETSC_USE_COMPLEX)
105:   ar = re+im*PETSC_i;
106: #else
107:   ar = re; ai = im;
108: #endif
109:   RGCheckInside(rg,1,&ar,&ai,&inside);
110:   PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside");

112:   RGDestroy(&rg);
113:   SlepcFinalize();
114:   return ierr;
115: }
slepc-3.7.4/src/sys/classes/rg/examples/tests/makefile.html0000644000175000017500000000606713107004621023271 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/sys/classes/rg/examples/tests/
EXAMPLESC  = test1.c
EXAMPLESF  =
MANSEC     = RG
TESTS      = test1

TESTEXAMPLES_C       = test1.PETSc runtest1_1 test1.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_SYS_LIB}
	${RM} test1.o

#------------------------------------------------------------------------------------

runtest1_1:
	-@${MPIEXEC} -n 1 ./test1 > test1_1.tmp 2>&1; \
	  if (${DIFF} output/test1_1.out test1_1.tmp) then true; \
	  else echo "Possible problem with test1_1, diffs above"; fi; \
	  ${RM} -f test1_1.tmp

slepc-3.7.4/src/sys/classes/rg/examples/tests/test1.c0000644000175000017500000000726513107004621022033 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test RG interface functions.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { PetscErrorCode ierr; RG rg; PetscInt i,inside; PetscReal re,im; PetscScalar ar,ai,cr[10],ci[10],vr[7],vi[7]; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = RGCreate(PETSC_COMM_WORLD,&rg);CHKERRQ(ierr); /* ellipse */ ierr = RGSetType(rg,RGELLIPSE);CHKERRQ(ierr); ierr = RGEllipseSetParameters(rg,1.1,2,0.1);CHKERRQ(ierr); ierr = RGSetFromOptions(rg);CHKERRQ(ierr); ierr = RGView(rg,NULL);CHKERRQ(ierr); re = 0.1; im = 0.3; #if defined(PETSC_USE_COMPLEX) ar = re+im*PETSC_i; #else ar = re; ai = im; #endif ierr = RGCheckInside(rg,1,&ar,&ai,&inside);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside"); ierr = PetscPrintf(PETSC_COMM_WORLD,"Contour points: "); ierr = RGComputeContour(rg,10,cr,ci);CHKERRQ(ierr); for (i=0;i<10;i++) { #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(cr[i]); im = PetscImaginaryPart(cr[i]); #else re = cr[i]; im = ci[i]; #endif ierr = PetscPrintf(PETSC_COMM_WORLD,"(%.3g,%.3g) ",(double)re,(double)im); } ierr = PetscPrintf(PETSC_COMM_WORLD,"\n"); /* interval */ ierr = RGSetType(rg,RGINTERVAL);CHKERRQ(ierr); ierr = RGIntervalSetEndpoints(rg,-1,1,-0.1,0.1);CHKERRQ(ierr); ierr = RGSetFromOptions(rg);CHKERRQ(ierr); ierr = RGView(rg,NULL);CHKERRQ(ierr); re = 0.2; im = 0; #if defined(PETSC_USE_COMPLEX) ar = re+im*PETSC_i; #else ar = re; ai = im; #endif ierr = RGCheckInside(rg,1,&ar,&ai,&inside);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside"); /* polygon */ #if defined(PETSC_USE_COMPLEX) vr[0] = 0.0+2.0*PETSC_i; vr[1] = 1.0+4.0*PETSC_i; vr[2] = 2.0+5.0*PETSC_i; vr[3] = 4.0+3.0*PETSC_i; vr[4] = 5.0+4.0*PETSC_i; vr[5] = 6.0+1.0*PETSC_i; vr[6] = 2.0+0.0*PETSC_i; #else vr[0] = 0.0; vi[0] = 2.0; vr[1] = 1.0; vi[1] = 4.0; vr[2] = 2.0; vi[2] = 5.0; vr[3] = 4.0; vi[3] = 3.0; vr[4] = 5.0; vi[4] = 4.0; vr[5] = 6.0; vi[5] = 1.0; vr[6] = 2.0; vi[6] = 0.0; #endif ierr = RGSetType(rg,RGPOLYGON);CHKERRQ(ierr); ierr = RGPolygonSetVertices(rg,7,vr,vi);CHKERRQ(ierr); ierr = RGSetFromOptions(rg);CHKERRQ(ierr); ierr = RGView(rg,NULL);CHKERRQ(ierr); re = 5; im = 0.9; #if defined(PETSC_USE_COMPLEX) ar = re+im*PETSC_i; #else ar = re; ai = im; #endif ierr = RGCheckInside(rg,1,&ar,&ai,&inside);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"Point (%g,%g) is %s the region\n",(double)re,(double)im,(inside>=0)?"inside":"outside"); ierr = RGDestroy(&rg);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } slepc-3.7.4/src/sys/classes/rg/examples/tests/output/0000755000175000017500000000000013107004621022155 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/examples/tests/output/test1_1.out0000644000175000017500000000102013107004621024157 0ustar jromanjromanRG Object: 1 MPI processes type: ellipse center: 1.1, radius: 2., vscale: 0.1 Point (0.1,0.3) is outside the region Contour points: (3,0.0618) (2.28,0.162) (1.1,0.2) (-0.0756,0.162) (-0.802,0.0618) (-0.802,-0.0618) (-0.0756,-0.162) (1.1,-0.2) (2.28,-0.162) (3,-0.0618) RG Object: 1 MPI processes type: interval region: [-1.,1.]x[-0.1,0.1] Point (0.2,0.) is inside the region RG Object: 1 MPI processes type: polygon vertices: 0.+2i, 1.+4i, 2.+5i, 4.+3i, 5.+4i, 6.+1i, 2. Point (5.,0.9) is inside the region slepc-3.7.4/src/sys/classes/rg/examples/tests/index.html0000644000175000017500000000163313107004621022615 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

test1.c: Test RG interface functions
makefile
slepc-3.7.4/src/sys/classes/rg/makefile.html0000644000175000017500000000473613107004621020312 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../../../include/slepc/private/rgimpl.h ../../../../include/slepcrg.h ../../../../include/slepcrgtypes.h
DIRS     = interface impls examples
LOCDIR   = src/sys/classes/rg/
MANSEC   = RG

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/rg/index.html0000644000175000017500000000230613107004621017633 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

interface/
impls/
examples/
../../../../include/slepc/private/rgimpl.h
../../../../include/slepcrg.h
../../../../include/slepcrgtypes.h
makefile
slepc-3.7.4/src/sys/classes/rg/impls/0000755000175000017500000000000013107004621016761 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/makefile0000644000175000017500000000211613107004621020461 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcsys DIRS = ellipse interval polygon ring LOCDIR = src/sys/classes/rg/impls/ MANSEC = RG include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/ring/0000755000175000017500000000000013107004621017720 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/ring/makefile0000644000175000017500000000216613107004621021425 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = rgring.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = RG LOCDIR = src/sys/classes/rg/impls/ring/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/ring/rgring.c.html0000644000175000017500000006765413107004621022341 0ustar jromanjroman

Actual source code: rgring.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Ring region, similar to the ellipse but with a start and end angle,
  3:    together with the width.

  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: */

 25: #include <slepc/private/rgimpl.h>      /*I "slepcrg.h" I*/

 27: typedef struct {
 28:   PetscScalar center;     /* center of the ellipse */
 29:   PetscReal   radius;     /* radius of the ellipse */
 30:   PetscReal   vscale;     /* vertical scale of the ellipse */
 31:   PetscReal   start_ang;  /* start angle */
 32:   PetscReal   end_ang;    /* end angle */
 33:   PetscReal   width;      /* ring width */
 34: } RG_RING;

 38: static PetscErrorCode RGRingSetParameters_Ring(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width)
 39: {
 40:   RG_RING *ctx = (RG_RING*)rg->data;

 43:   ctx->center = center;
 44:   if (radius == PETSC_DEFAULT) {
 45:     ctx->radius = 1.0;
 46:   } else {
 47:     if (radius<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The radius argument must be > 0.0");
 48:     ctx->radius = radius;
 49:   }
 50:   if (vscale<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The vscale argument must be > 0.0");
 51:   ctx->vscale = vscale;
 52:   if (start_ang == PETSC_DEFAULT) {
 53:     ctx->start_ang = 0.0;
 54:   } else {
 55:     if (start_ang<0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The right-hand side angle argument must be >= 0.0");
 56:     if (start_ang>1.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The right-hand side angle argument must be <= 1.0");
 57:     ctx->start_ang = start_ang;
 58:   }
 59:   if (end_ang == PETSC_DEFAULT) {
 60:     ctx->end_ang = 1.0;
 61:   } else {
 62:     if (end_ang<0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The left-hand side angle argument must be >= 0.0");
 63:     if (end_ang>1.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The left-hand side angle argument must be <= 1.0");
 64:     ctx->end_ang = end_ang;
 65:   }
 66:   if (ctx->start_ang>ctx->end_ang) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The right-hand side angle argument must be smaller than left one");
 67:   if (width == PETSC_DEFAULT) {
 68:     ctx->width = 0.1;
 69:   } else {
 70:     if (width<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The width argument must be > 0.0");
 71:     ctx->width = width;
 72:   }
 73:   return(0);
 74: }

 78: /*@
 79:    RGRingSetParameters - Sets the parameters defining the ring region.

 81:    Logically Collective on RG

 83:    Input Parameters:
 84: +  rg        - the region context
 85: .  center    - center of the ellipse
 86: .  radius    - radius of the ellipse
 87: .  vscale    - vertical scale of the ellipse
 88: .  start_ang - the right-hand side angle
 89: .  end_ang   - the left-hand side angle
 90: -  width     - width of the ring

 92:    Options Database Keys:
 93: +  -rg_ring_center     - Sets the center
 94: .  -rg_ring_radius     - Sets the radius
 95: .  -rg_ring_vscale     - Sets the vertical scale
 96: .  -rg_ring_startangle - Sets the right-hand side angle
 97: .  -rg_ring_endangle   - Sets the left-hand side angle
 98: -  -rg_ring_width      - Sets the width of the ring

100:    Notes:
101:    The values of center, radius and vscale have the same meaning as in the
102:    ellipse region. The startangle and endangle define the span of the ring
103:    (by default it is the whole ring), while the width is the separation
104:    between the two concentric ellipses (above and below the radius by
105:    width/2). The start and end angles are expressed as a fraction of the
106:    circumference: the allowed range is [0..1], with 0 corresponding to 0
107:    radians, 0.25 to pi/2 radians, and so on.

109:    In the case of complex scalars, a complex center can be provided in the
110:    command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g.
111:    -rg_ring_center 1.0+2.0i

113:    When PETSc is built with real scalars, the center is restricted to a real value.

115:    Level: advanced

117: .seealso: RGRingGetParameters()
118: @*/
119: PetscErrorCode RGRingSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width)
120: {

131:   PetscTryMethod(rg,"RGRingSetParameters_C",(RG,PetscScalar,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal),(rg,center,radius,vscale,start_ang,end_ang,width));
132:   return(0);
133: }

137: static PetscErrorCode RGRingGetParameters_Ring(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width)
138: {
139:   RG_RING *ctx = (RG_RING*)rg->data;

142:   if (center)    *center    = ctx->center;
143:   if (radius)    *radius    = ctx->radius;
144:   if (vscale)    *vscale    = ctx->vscale;
145:   if (start_ang) *start_ang = ctx->start_ang;
146:   if (end_ang)   *end_ang   = ctx->end_ang;
147:   if (width)     *width     = ctx->width;
148:   return(0);
149: }

153: /*@
154:    RGRingGetParameters - Gets the parameters that define the ring region.

156:    Not Collective

158:    Input Parameter:
159: .  rg     - the region context

161:    Output Parameters:
162: +  center    - center of the region
163: .  radius    - radius of the region
164: .  vscale    - vertical scale of the region
165: .  start_ang - the right-hand side angle
166: .  end_ang   - the left-hand side angle
167: -  width     - width of the ring

169:    Level: advanced

171: .seealso: RGRingSetParameters()
172: @*/
173: PetscErrorCode RGRingGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width)
174: {

179:   PetscUseMethod(rg,"RGRingGetParameters_C",(RG,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*),(rg,center,radius,vscale,start_ang,end_ang,width));
180:   return(0);
181: }

185: PetscErrorCode RGView_Ring(RG rg,PetscViewer viewer)
186: {
188:   RG_RING        *ctx = (RG_RING*)rg->data;
189:   PetscBool      isascii;
190:   char           str[50];

193:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
194:   if (isascii) {
195:     SlepcSNPrintfScalar(str,50,ctx->center,PETSC_FALSE);
196:     PetscViewerASCIIPrintf(viewer,"center: %s, radius: %g, vscale: %g, start angle: %g, end angle: %g, ring width: %g\n",str,RGShowReal(ctx->radius),RGShowReal(ctx->vscale),ctx->start_ang,ctx->end_ang,ctx->width);
197:   }
198:   return(0);
199: }

203: PetscErrorCode RGIsTrivial_Ring(RG rg,PetscBool *trivial)
204: {
205:   RG_RING *ctx = (RG_RING*)rg->data;

208:   if (rg->complement) *trivial = PetscNot(ctx->radius);
209:   else *trivial = PetscNot(ctx->radius<PETSC_MAX_REAL);
210:   return(0);
211: }

215: PetscErrorCode RGComputeContour_Ring(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)
216: {
217:   RG_RING   *ctx = (RG_RING*)rg->data;
218:   PetscReal theta;
219:   PetscInt  i,n2=n/2;

222:   for (i=0;i<n;i++) {
223:     if (i < n2) {
224:       theta = ((ctx->end_ang-ctx->start_ang)*i/n2 + ctx->start_ang)*2.0*PETSC_PI;
225: #if defined(PETSC_USE_COMPLEX)
226:       cr[i] = ctx->center + (ctx->radius+ctx->width/2.0)*(PetscCosReal(theta)+ctx->vscale*PetscSinReal(theta)*PETSC_i);
227: #else
228:       cr[i] = ctx->center + (ctx->radius+ctx->width/2.0)*PetscCosReal(theta);
229:       ci[i] = (ctx->radius+ctx->width/2.0)*ctx->vscale*PetscSinReal(theta);
230: #endif
231:     } else {
232:       theta = ((ctx->end_ang-ctx->start_ang)*(n-i)/n2 + ctx->start_ang)*2.0*PETSC_PI;
233: #if defined(PETSC_USE_COMPLEX)
234:       cr[i] = ctx->center + (ctx->radius-ctx->width/2.0)*(PetscCosReal(theta)+ctx->vscale*PetscSinReal(theta)*PETSC_i);
235: #else
236:       cr[i] = ctx->center + (ctx->radius-ctx->width/2.0)*PetscCosReal(theta);
237:       ci[i] = (ctx->radius-ctx->width/2.0)*ctx->vscale*PetscSinReal(theta);
238: #endif
239:     }
240:   }
241:   return(0);
242: }

246: PetscErrorCode RGCheckInside_Ring(RG rg,PetscReal px,PetscReal py,PetscInt *inside)
247: {
248:   RG_RING   *ctx = (RG_RING*)rg->data;
249:   PetscReal dx,dy,r;

252:   /* outer ellipse */
253: #if defined(PETSC_USE_COMPLEX)
254:   dx = (px-PetscRealPart(ctx->center))/(ctx->radius+ctx->width/2.0);
255:   dy = (py-PetscImaginaryPart(ctx->center))/(ctx->radius+ctx->width/2.0);
256: #else
257:   dx = (px-ctx->center)/(ctx->radius+ctx->width/2.0);
258:   dy = py/(ctx->radius+ctx->width/2.0);
259: #endif
260:   r = 1.0-dx*dx-(dy*dy)/(ctx->vscale*ctx->vscale);
261:   *inside = PetscSign(r);
262:   /* inner ellipse */
263: #if defined(PETSC_USE_COMPLEX)
264:   dx = (px-PetscRealPart(ctx->center))/(ctx->radius-ctx->width/2.0);
265:   dy = (py-PetscImaginaryPart(ctx->center))/(ctx->radius-ctx->width/2.0);
266: #else
267:   dx = (px-ctx->center)/(ctx->radius-ctx->width/2.0);
268:   dy = py/(ctx->radius-ctx->width/2.0);
269: #endif
270:   r = -1.0+dx*dx+(dy*dy)/(ctx->vscale*ctx->vscale);
271:   *inside *= PetscSign(r);
272:   /* check angles */
273: #if defined(PETSC_USE_COMPLEX)
274:   dx = (px-PetscRealPart(ctx->center));
275:   dy = (py-PetscImaginaryPart(ctx->center));
276: #else
277:   dx = px-ctx->center;
278:   dy = py;
279: #endif
280:   if (dx == 0) {
281:     if (dy == 0) r = -1;
282:     else if (dy > 0) r = 0.25;
283:     else r = 0.75;
284:   } else if (dx > 0) {
285:     r = PetscAtanReal((dy/ctx->vscale)/dx);
286:     if (dy >= 0) r /= 2*PETSC_PI;
287:     else r = r/(2*PETSC_PI)+1;
288:   } else r = PetscAtanReal((dy/ctx->vscale)/dx)/(2*PETSC_PI)+0.5;
289:   if (r>=ctx->start_ang && r<=ctx->end_ang && *inside == 1) *inside = 1;
290:   else *inside = -1;
291:   return(0);
292: }

296: PetscErrorCode RGSetFromOptions_Ring(PetscOptionItems *PetscOptionsObject,RG rg)
297: {
299:   PetscScalar    s;
300:   PetscReal      r1,r2,r3,r4,r5;
301:   PetscBool      flg1,flg2,flg3,flg4,flg5,flg6;

304:   PetscOptionsHead(PetscOptionsObject,"RG Ring Options");

306:   RGRingGetParameters(rg,&s,&r1,&r2,&r3,&r4,&r5);
307:   PetscOptionsScalar("-rg_ring_center","Center of ellipse","RGRingSetParameters",s,&s,&flg1);
308:   PetscOptionsReal("-rg_ring_radius","Radius of ellipse","RGRingSetParameters",r1,&r1,&flg2);
309:   PetscOptionsReal("-rg_ring_vscale","Vertical scale of ellipse","RGRingSetParameters",r2,&r2,&flg3);
310:   PetscOptionsReal("-rg_ring_startangle","Right-hand side angle","RGRingSetParameters",r3,&r3,&flg4);
311:   PetscOptionsReal("-rg_ring_endangle","Left-hand side angle","RGRingSetParameters",r4,&r4,&flg5);
312:   PetscOptionsReal("-rg_ring_width","Width of ring","RGRingSetParameters",r5,&r5,&flg6);
313:   if (flg1 || flg2 || flg3 || flg4 || flg5 || flg6) {
314:     RGRingSetParameters(rg,s,r1,r2,r3,r4,r5);
315:   }

317:   PetscOptionsTail();
318:   return(0);
319: }

323: PetscErrorCode RGDestroy_Ring(RG rg)
324: {

328:   PetscFree(rg->data);
329:   PetscObjectComposeFunction((PetscObject)rg,"RGRingSetParameters_C",NULL);
330:   PetscObjectComposeFunction((PetscObject)rg,"RGRingGetParameters_C",NULL);
331:   return(0);
332: }

336: PETSC_EXTERN PetscErrorCode RGCreate_Ring(RG rg)
337: {
338:   RG_RING        *ring;

342:   PetscNewLog(rg,&ring);
343:   ring->center    = 0.0;
344:   ring->radius    = 1.0;
345:   ring->vscale    = 1.0;
346:   ring->start_ang = 0.0;
347:   ring->end_ang   = 1.0;
348:   ring->width     = 0.1;
349:   rg->data = (void*)ring;

351:   rg->ops->istrivial      = RGIsTrivial_Ring;
352:   rg->ops->computecontour = RGComputeContour_Ring;
353:   rg->ops->checkinside    = RGCheckInside_Ring;
354:   rg->ops->setfromoptions = RGSetFromOptions_Ring;
355:   rg->ops->view           = RGView_Ring;
356:   rg->ops->destroy        = RGDestroy_Ring;
357:   PetscObjectComposeFunction((PetscObject)rg,"RGRingSetParameters_C",RGRingSetParameters_Ring);
358:   PetscObjectComposeFunction((PetscObject)rg,"RGRingGetParameters_C",RGRingGetParameters_Ring);
359:   return(0);
360: }

slepc-3.7.4/src/sys/classes/rg/impls/ring/makefile.html0000644000175000017500000000470713107004621022373 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = rgring.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = RG
LOCDIR   = src/sys/classes/rg/impls/ring/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/rg/impls/ring/index.html0000644000175000017500000000157213107004621021722 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

rgring.c
makefile
slepc-3.7.4/src/sys/classes/rg/impls/ring/ftn-auto/0000755000175000017500000000000013107004621021455 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/ring/ftn-auto/makefile0000644000175000017500000000037213107004621023157 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = rgringf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/rg/impls/ring/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/ring/ftn-auto/rgringf.c0000644000175000017500000000335113107004621023261 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* rgring.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcrg.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgringsetparameters_ RGRINGSETPARAMETERS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgringsetparameters_ rgringsetparameters #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgringgetparameters_ RGRINGGETPARAMETERS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgringgetparameters_ rgringgetparameters #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL rgringsetparameters_(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width, int *__ierr ){ *__ierr = RGRingSetParameters( (RG)PetscToPointer((rg) ),*center,*radius,*vscale,*start_ang,*end_ang,*width); } PETSC_EXTERN void PETSC_STDCALL rgringgetparameters_(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width, int *__ierr ){ *__ierr = RGRingGetParameters( (RG)PetscToPointer((rg) ),center,radius,vscale,start_ang,end_ang,width); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/rg/impls/ring/rgring.c0000644000175000017500000003246213107004621021363 0ustar jromanjroman/* Ring region, similar to the ellipse but with a start and end angle, together with the width. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcrg.h" I*/ typedef struct { PetscScalar center; /* center of the ellipse */ PetscReal radius; /* radius of the ellipse */ PetscReal vscale; /* vertical scale of the ellipse */ PetscReal start_ang; /* start angle */ PetscReal end_ang; /* end angle */ PetscReal width; /* ring width */ } RG_RING; #undef __FUNCT__ #define __FUNCT__ "RGRingSetParameters_Ring" static PetscErrorCode RGRingSetParameters_Ring(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width) { RG_RING *ctx = (RG_RING*)rg->data; PetscFunctionBegin; ctx->center = center; if (radius == PETSC_DEFAULT) { ctx->radius = 1.0; } else { if (radius<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The radius argument must be > 0.0"); ctx->radius = radius; } if (vscale<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The vscale argument must be > 0.0"); ctx->vscale = vscale; if (start_ang == PETSC_DEFAULT) { ctx->start_ang = 0.0; } else { if (start_ang<0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The right-hand side angle argument must be >= 0.0"); if (start_ang>1.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The right-hand side angle argument must be <= 1.0"); ctx->start_ang = start_ang; } if (end_ang == PETSC_DEFAULT) { ctx->end_ang = 1.0; } else { if (end_ang<0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The left-hand side angle argument must be >= 0.0"); if (end_ang>1.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The left-hand side angle argument must be <= 1.0"); ctx->end_ang = end_ang; } if (ctx->start_ang>ctx->end_ang) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The right-hand side angle argument must be smaller than left one"); if (width == PETSC_DEFAULT) { ctx->width = 0.1; } else { if (width<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The width argument must be > 0.0"); ctx->width = width; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGRingSetParameters" /*@ RGRingSetParameters - Sets the parameters defining the ring region. Logically Collective on RG Input Parameters: + rg - the region context . center - center of the ellipse . radius - radius of the ellipse . vscale - vertical scale of the ellipse . start_ang - the right-hand side angle . end_ang - the left-hand side angle - width - width of the ring Options Database Keys: + -rg_ring_center - Sets the center . -rg_ring_radius - Sets the radius . -rg_ring_vscale - Sets the vertical scale . -rg_ring_startangle - Sets the right-hand side angle . -rg_ring_endangle - Sets the left-hand side angle - -rg_ring_width - Sets the width of the ring Notes: The values of center, radius and vscale have the same meaning as in the ellipse region. The startangle and endangle define the span of the ring (by default it is the whole ring), while the width is the separation between the two concentric ellipses (above and below the radius by width/2). The start and end angles are expressed as a fraction of the circumference: the allowed range is [0..1], with 0 corresponding to 0 radians, 0.25 to pi/2 radians, and so on. In the case of complex scalars, a complex center can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -rg_ring_center 1.0+2.0i When PETSc is built with real scalars, the center is restricted to a real value. Level: advanced .seealso: RGRingGetParameters() @*/ PetscErrorCode RGRingSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidLogicalCollectiveScalar(rg,center,2); PetscValidLogicalCollectiveReal(rg,radius,3); PetscValidLogicalCollectiveReal(rg,vscale,4); PetscValidLogicalCollectiveReal(rg,start_ang,5); PetscValidLogicalCollectiveReal(rg,end_ang,6); PetscValidLogicalCollectiveReal(rg,width,7); ierr = PetscTryMethod(rg,"RGRingSetParameters_C",(RG,PetscScalar,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal),(rg,center,radius,vscale,start_ang,end_ang,width));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGRingGetParameters_Ring" static PetscErrorCode RGRingGetParameters_Ring(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width) { RG_RING *ctx = (RG_RING*)rg->data; PetscFunctionBegin; if (center) *center = ctx->center; if (radius) *radius = ctx->radius; if (vscale) *vscale = ctx->vscale; if (start_ang) *start_ang = ctx->start_ang; if (end_ang) *end_ang = ctx->end_ang; if (width) *width = ctx->width; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGRingGetParameters" /*@ RGRingGetParameters - Gets the parameters that define the ring region. Not Collective Input Parameter: . rg - the region context Output Parameters: + center - center of the region . radius - radius of the region . vscale - vertical scale of the region . start_ang - the right-hand side angle . end_ang - the left-hand side angle - width - width of the ring Level: advanced .seealso: RGRingSetParameters() @*/ PetscErrorCode RGRingGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = PetscUseMethod(rg,"RGRingGetParameters_C",(RG,PetscScalar*,PetscReal*,PetscReal*,PetscReal*,PetscReal*,PetscReal*),(rg,center,radius,vscale,start_ang,end_ang,width));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGView_Ring" PetscErrorCode RGView_Ring(RG rg,PetscViewer viewer) { PetscErrorCode ierr; RG_RING *ctx = (RG_RING*)rg->data; PetscBool isascii; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = SlepcSNPrintfScalar(str,50,ctx->center,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"center: %s, radius: %g, vscale: %g, start angle: %g, end angle: %g, ring width: %g\n",str,RGShowReal(ctx->radius),RGShowReal(ctx->vscale),ctx->start_ang,ctx->end_ang,ctx->width);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIsTrivial_Ring" PetscErrorCode RGIsTrivial_Ring(RG rg,PetscBool *trivial) { RG_RING *ctx = (RG_RING*)rg->data; PetscFunctionBegin; if (rg->complement) *trivial = PetscNot(ctx->radius); else *trivial = PetscNot(ctx->radiusdata; PetscReal theta; PetscInt i,n2=n/2; PetscFunctionBegin; for (i=0;iend_ang-ctx->start_ang)*i/n2 + ctx->start_ang)*2.0*PETSC_PI; #if defined(PETSC_USE_COMPLEX) cr[i] = ctx->center + (ctx->radius+ctx->width/2.0)*(PetscCosReal(theta)+ctx->vscale*PetscSinReal(theta)*PETSC_i); #else cr[i] = ctx->center + (ctx->radius+ctx->width/2.0)*PetscCosReal(theta); ci[i] = (ctx->radius+ctx->width/2.0)*ctx->vscale*PetscSinReal(theta); #endif } else { theta = ((ctx->end_ang-ctx->start_ang)*(n-i)/n2 + ctx->start_ang)*2.0*PETSC_PI; #if defined(PETSC_USE_COMPLEX) cr[i] = ctx->center + (ctx->radius-ctx->width/2.0)*(PetscCosReal(theta)+ctx->vscale*PetscSinReal(theta)*PETSC_i); #else cr[i] = ctx->center + (ctx->radius-ctx->width/2.0)*PetscCosReal(theta); ci[i] = (ctx->radius-ctx->width/2.0)*ctx->vscale*PetscSinReal(theta); #endif } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCheckInside_Ring" PetscErrorCode RGCheckInside_Ring(RG rg,PetscReal px,PetscReal py,PetscInt *inside) { RG_RING *ctx = (RG_RING*)rg->data; PetscReal dx,dy,r; PetscFunctionBegin; /* outer ellipse */ #if defined(PETSC_USE_COMPLEX) dx = (px-PetscRealPart(ctx->center))/(ctx->radius+ctx->width/2.0); dy = (py-PetscImaginaryPart(ctx->center))/(ctx->radius+ctx->width/2.0); #else dx = (px-ctx->center)/(ctx->radius+ctx->width/2.0); dy = py/(ctx->radius+ctx->width/2.0); #endif r = 1.0-dx*dx-(dy*dy)/(ctx->vscale*ctx->vscale); *inside = PetscSign(r); /* inner ellipse */ #if defined(PETSC_USE_COMPLEX) dx = (px-PetscRealPart(ctx->center))/(ctx->radius-ctx->width/2.0); dy = (py-PetscImaginaryPart(ctx->center))/(ctx->radius-ctx->width/2.0); #else dx = (px-ctx->center)/(ctx->radius-ctx->width/2.0); dy = py/(ctx->radius-ctx->width/2.0); #endif r = -1.0+dx*dx+(dy*dy)/(ctx->vscale*ctx->vscale); *inside *= PetscSign(r); /* check angles */ #if defined(PETSC_USE_COMPLEX) dx = (px-PetscRealPart(ctx->center)); dy = (py-PetscImaginaryPart(ctx->center)); #else dx = px-ctx->center; dy = py; #endif if (dx == 0) { if (dy == 0) r = -1; else if (dy > 0) r = 0.25; else r = 0.75; } else if (dx > 0) { r = PetscAtanReal((dy/ctx->vscale)/dx); if (dy >= 0) r /= 2*PETSC_PI; else r = r/(2*PETSC_PI)+1; } else r = PetscAtanReal((dy/ctx->vscale)/dx)/(2*PETSC_PI)+0.5; if (r>=ctx->start_ang && r<=ctx->end_ang && *inside == 1) *inside = 1; else *inside = -1; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetFromOptions_Ring" PetscErrorCode RGSetFromOptions_Ring(PetscOptionItems *PetscOptionsObject,RG rg) { PetscErrorCode ierr; PetscScalar s; PetscReal r1,r2,r3,r4,r5; PetscBool flg1,flg2,flg3,flg4,flg5,flg6; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"RG Ring Options");CHKERRQ(ierr); ierr = RGRingGetParameters(rg,&s,&r1,&r2,&r3,&r4,&r5);CHKERRQ(ierr); ierr = PetscOptionsScalar("-rg_ring_center","Center of ellipse","RGRingSetParameters",s,&s,&flg1);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_ring_radius","Radius of ellipse","RGRingSetParameters",r1,&r1,&flg2);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_ring_vscale","Vertical scale of ellipse","RGRingSetParameters",r2,&r2,&flg3);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_ring_startangle","Right-hand side angle","RGRingSetParameters",r3,&r3,&flg4);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_ring_endangle","Left-hand side angle","RGRingSetParameters",r4,&r4,&flg5);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_ring_width","Width of ring","RGRingSetParameters",r5,&r5,&flg6);CHKERRQ(ierr); if (flg1 || flg2 || flg3 || flg4 || flg5 || flg6) { ierr = RGRingSetParameters(rg,s,r1,r2,r3,r4,r5);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGDestroy_Ring" PetscErrorCode RGDestroy_Ring(RG rg) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(rg->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGRingSetParameters_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGRingGetParameters_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCreate_Ring" PETSC_EXTERN PetscErrorCode RGCreate_Ring(RG rg) { RG_RING *ring; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(rg,&ring);CHKERRQ(ierr); ring->center = 0.0; ring->radius = 1.0; ring->vscale = 1.0; ring->start_ang = 0.0; ring->end_ang = 1.0; ring->width = 0.1; rg->data = (void*)ring; rg->ops->istrivial = RGIsTrivial_Ring; rg->ops->computecontour = RGComputeContour_Ring; rg->ops->checkinside = RGCheckInside_Ring; rg->ops->setfromoptions = RGSetFromOptions_Ring; rg->ops->view = RGView_Ring; rg->ops->destroy = RGDestroy_Ring; ierr = PetscObjectComposeFunction((PetscObject)rg,"RGRingSetParameters_C",RGRingSetParameters_Ring);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGRingGetParameters_C",RGRingGetParameters_Ring);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/rg/impls/makefile.html0000644000175000017500000000462513107004621021433 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcsys
DIRS     = ellipse interval polygon ring
LOCDIR   = src/sys/classes/rg/impls/
MANSEC   = RG

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/classes/rg/impls/ellipse/0000755000175000017500000000000013107004621020416 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/ellipse/makefile0000644000175000017500000000217413107004621022122 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = rgellipse.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = RG LOCDIR = src/sys/classes/rg/impls/ellipse/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/ellipse/rgellipse.c.html0000644000175000017500000004470313107004621023523 0ustar jromanjroman
Actual source code: rgellipse.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Region enclosed in an ellipse (aligned with the coordinate axes).

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/rgimpl.h>      /*I "slepcrg.h" I*/

 26: typedef struct {
 27:   PetscScalar center;     /* center of the ellipse */
 28:   PetscReal   radius;     /* radius of the ellipse */
 29:   PetscReal   vscale;     /* vertical scale of the ellipse */
 30: } RG_ELLIPSE;

 34: static PetscErrorCode RGEllipseSetParameters_Ellipse(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale)
 35: {
 36:   RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data;

 39:   ctx->center = center;
 40:   if (radius == PETSC_DEFAULT) {
 41:     ctx->radius = 1.0;
 42:   } else {
 43:     if (radius<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The radius argument must be > 0.0");
 44:     ctx->radius = radius;
 45:   }
 46:   if (vscale<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The vscale argument must be > 0.0");
 47:   ctx->vscale = vscale;
 48:   return(0);
 49: }

 53: /*@
 54:    RGEllipseSetParameters - Sets the parameters defining the ellipse region.

 56:    Logically Collective on RG

 58:    Input Parameters:
 59: +  rg     - the region context
 60: .  center - center of the ellipse
 61: .  radius - radius of the ellipse
 62: -  vscale - vertical scale of the ellipse

 64:    Options Database Keys:
 65: +  -rg_ellipse_center - Sets the center
 66: .  -rg_ellipse_radius - Sets the radius
 67: -  -rg_ellipse_vscale - Sets the vertical scale

 69:    Notes:
 70:    In the case of complex scalars, a complex center can be provided in the
 71:    command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g.
 72:    -rg_ellipse_center 1.0+2.0i

 74:    When PETSc is built with real scalars, the center is restricted to a real value.

 76:    Level: advanced

 78: .seealso: RGEllipseGetParameters()
 79: @*/
 80: PetscErrorCode RGEllipseSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale)
 81: {

 89:   PetscTryMethod(rg,"RGEllipseSetParameters_C",(RG,PetscScalar,PetscReal,PetscReal),(rg,center,radius,vscale));
 90:   return(0);
 91: }

 95: static PetscErrorCode RGEllipseGetParameters_Ellipse(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale)
 96: {
 97:   RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data;

100:   if (center) *center = ctx->center;
101:   if (radius) *radius = ctx->radius;
102:   if (vscale) *vscale = ctx->vscale;
103:   return(0);
104: }

108: /*@
109:    RGEllipseGetParameters - Gets the parameters that define the ellipse region.

111:    Not Collective

113:    Input Parameter:
114: .  rg     - the region context

116:    Output Parameters:
117: +  center - center of the region
118: .  radius - radius of the region
119: -  vscale - vertical scale of the region

121:    Level: advanced

123: .seealso: RGEllipseSetParameters()
124: @*/
125: PetscErrorCode RGEllipseGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale)
126: {

131:   PetscUseMethod(rg,"RGEllipseGetParameters_C",(RG,PetscScalar*,PetscReal*,PetscReal*),(rg,center,radius,vscale));
132:   return(0);
133: }

137: PetscErrorCode RGView_Ellipse(RG rg,PetscViewer viewer)
138: {
140:   RG_ELLIPSE     *ctx = (RG_ELLIPSE*)rg->data;
141:   PetscBool      isascii;
142:   char           str[50];

145:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
146:   if (isascii) {
147:     SlepcSNPrintfScalar(str,50,ctx->center,PETSC_FALSE);
148:     PetscViewerASCIIPrintf(viewer,"center: %s, radius: %g, vscale: %g\n",str,RGShowReal(ctx->radius),RGShowReal(ctx->vscale));
149:   }
150:   return(0);
151: }

155: PetscErrorCode RGIsTrivial_Ellipse(RG rg,PetscBool *trivial)
156: {
157:   RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data;

160:   if (rg->complement) *trivial = PetscNot(ctx->radius);
161:   else *trivial = PetscNot(ctx->radius<PETSC_MAX_REAL);
162:   return(0);
163: }

167: PetscErrorCode RGComputeContour_Ellipse(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)
168: {
169:   RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data;
170:   PetscReal  theta;
171:   PetscInt   i;

174:   for (i=0;i<n;i++) {
175:     theta = 2.0*PETSC_PI*(i+0.5)/n;
176: #if defined(PETSC_USE_COMPLEX)
177:     cr[i] = ctx->center + ctx->radius*(PetscCosReal(theta)+ctx->vscale*PetscSinReal(theta)*PETSC_i);
178: #else
179:     cr[i] = ctx->center + ctx->radius*PetscCosReal(theta);
180:     ci[i] = ctx->radius*ctx->vscale*PetscSinReal(theta);
181: #endif
182:   }
183:   return(0);
184: }

188: PetscErrorCode RGCheckInside_Ellipse(RG rg,PetscReal px,PetscReal py,PetscInt *inside)
189: {
190:   RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data;
191:   PetscReal  dx,dy,r;

194: #if defined(PETSC_USE_COMPLEX)
195:   dx = (px-PetscRealPart(ctx->center))/ctx->radius;
196:   dy = (py-PetscImaginaryPart(ctx->center))/ctx->radius;
197: #else
198:   dx = (px-ctx->center)/ctx->radius;
199:   dy = py/ctx->radius;
200: #endif
201:   r = 1.0-dx*dx-(dy*dy)/(ctx->vscale*ctx->vscale);
202:   *inside = PetscSign(r);
203:   return(0);
204: }

208: PetscErrorCode RGSetFromOptions_Ellipse(PetscOptionItems *PetscOptionsObject,RG rg)
209: {
211:   PetscScalar    s;
212:   PetscReal      r1,r2;
213:   PetscBool      flg1,flg2,flg3;

216:   PetscOptionsHead(PetscOptionsObject,"RG Ellipse Options");

218:   RGEllipseGetParameters(rg,&s,&r1,&r2);
219:   PetscOptionsScalar("-rg_ellipse_center","Center of ellipse","RGEllipseSetParameters",s,&s,&flg1);
220:   PetscOptionsReal("-rg_ellipse_radius","Radius of ellipse","RGEllipseSetParameters",r1,&r1,&flg2);
221:   PetscOptionsReal("-rg_ellipse_vscale","Vertical scale of ellipse","RGEllipseSetParameters",r2,&r2,&flg3);
222:   if (flg1 || flg2 || flg3) {
223:     RGEllipseSetParameters(rg,s,r1,r2);
224:   }

226:   PetscOptionsTail();
227:   return(0);
228: }

232: PetscErrorCode RGDestroy_Ellipse(RG rg)
233: {

237:   PetscFree(rg->data);
238:   PetscObjectComposeFunction((PetscObject)rg,"RGEllipseSetParameters_C",NULL);
239:   PetscObjectComposeFunction((PetscObject)rg,"RGEllipseGetParameters_C",NULL);
240:   return(0);
241: }

245: PETSC_EXTERN PetscErrorCode RGCreate_Ellipse(RG rg)
246: {
247:   RG_ELLIPSE     *ellipse;

251:   PetscNewLog(rg,&ellipse);
252:   ellipse->center = 0.0;
253:   ellipse->radius = 1.0;
254:   ellipse->vscale = 1.0;
255:   rg->data = (void*)ellipse;

257:   rg->ops->istrivial      = RGIsTrivial_Ellipse;
258:   rg->ops->computecontour = RGComputeContour_Ellipse;
259:   rg->ops->checkinside    = RGCheckInside_Ellipse;
260:   rg->ops->setfromoptions = RGSetFromOptions_Ellipse;
261:   rg->ops->view           = RGView_Ellipse;
262:   rg->ops->destroy        = RGDestroy_Ellipse;
263:   PetscObjectComposeFunction((PetscObject)rg,"RGEllipseSetParameters_C",RGEllipseSetParameters_Ellipse);
264:   PetscObjectComposeFunction((PetscObject)rg,"RGEllipseGetParameters_C",RGEllipseGetParameters_Ellipse);
265:   return(0);
266: }

slepc-3.7.4/src/sys/classes/rg/impls/ellipse/makefile.html0000644000175000017500000000472313107004621023067 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = rgellipse.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = RG
LOCDIR   = src/sys/classes/rg/impls/ellipse/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/rg/impls/ellipse/index.html0000644000175000017500000000160613107004621022416 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

rgellipse.c
makefile
slepc-3.7.4/src/sys/classes/rg/impls/ellipse/ftn-auto/0000755000175000017500000000000013107004621022153 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/ellipse/ftn-auto/makefile0000644000175000017500000000040013107004621023645 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = rgellipsef.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/rg/impls/ellipse/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/ellipse/ftn-auto/rgellipsef.c0000644000175000017500000000315313107004621024455 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* rgellipse.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcrg.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgellipsesetparameters_ RGELLIPSESETPARAMETERS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgellipsesetparameters_ rgellipsesetparameters #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgellipsegetparameters_ RGELLIPSEGETPARAMETERS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgellipsegetparameters_ rgellipsegetparameters #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL rgellipsesetparameters_(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale, int *__ierr ){ *__ierr = RGEllipseSetParameters( (RG)PetscToPointer((rg) ),*center,*radius,*vscale); } PETSC_EXTERN void PETSC_STDCALL rgellipsegetparameters_(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale, int *__ierr ){ *__ierr = RGEllipseGetParameters( (RG)PetscToPointer((rg) ),center,radius,vscale); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/rg/impls/ellipse/rgellipse.c0000644000175000017500000002115313107004621022552 0ustar jromanjroman/* Region enclosed in an ellipse (aligned with the coordinate axes). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcrg.h" I*/ typedef struct { PetscScalar center; /* center of the ellipse */ PetscReal radius; /* radius of the ellipse */ PetscReal vscale; /* vertical scale of the ellipse */ } RG_ELLIPSE; #undef __FUNCT__ #define __FUNCT__ "RGEllipseSetParameters_Ellipse" static PetscErrorCode RGEllipseSetParameters_Ellipse(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale) { RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data; PetscFunctionBegin; ctx->center = center; if (radius == PETSC_DEFAULT) { ctx->radius = 1.0; } else { if (radius<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The radius argument must be > 0.0"); ctx->radius = radius; } if (vscale<=0.0) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"The vscale argument must be > 0.0"); ctx->vscale = vscale; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGEllipseSetParameters" /*@ RGEllipseSetParameters - Sets the parameters defining the ellipse region. Logically Collective on RG Input Parameters: + rg - the region context . center - center of the ellipse . radius - radius of the ellipse - vscale - vertical scale of the ellipse Options Database Keys: + -rg_ellipse_center - Sets the center . -rg_ellipse_radius - Sets the radius - -rg_ellipse_vscale - Sets the vertical scale Notes: In the case of complex scalars, a complex center can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -rg_ellipse_center 1.0+2.0i When PETSc is built with real scalars, the center is restricted to a real value. Level: advanced .seealso: RGEllipseGetParameters() @*/ PetscErrorCode RGEllipseSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidLogicalCollectiveScalar(rg,center,2); PetscValidLogicalCollectiveReal(rg,radius,3); PetscValidLogicalCollectiveReal(rg,vscale,4); ierr = PetscTryMethod(rg,"RGEllipseSetParameters_C",(RG,PetscScalar,PetscReal,PetscReal),(rg,center,radius,vscale));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGEllipseGetParameters_Ellipse" static PetscErrorCode RGEllipseGetParameters_Ellipse(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale) { RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data; PetscFunctionBegin; if (center) *center = ctx->center; if (radius) *radius = ctx->radius; if (vscale) *vscale = ctx->vscale; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGEllipseGetParameters" /*@ RGEllipseGetParameters - Gets the parameters that define the ellipse region. Not Collective Input Parameter: . rg - the region context Output Parameters: + center - center of the region . radius - radius of the region - vscale - vertical scale of the region Level: advanced .seealso: RGEllipseSetParameters() @*/ PetscErrorCode RGEllipseGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = PetscUseMethod(rg,"RGEllipseGetParameters_C",(RG,PetscScalar*,PetscReal*,PetscReal*),(rg,center,radius,vscale));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGView_Ellipse" PetscErrorCode RGView_Ellipse(RG rg,PetscViewer viewer) { PetscErrorCode ierr; RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data; PetscBool isascii; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = SlepcSNPrintfScalar(str,50,ctx->center,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"center: %s, radius: %g, vscale: %g\n",str,RGShowReal(ctx->radius),RGShowReal(ctx->vscale));CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIsTrivial_Ellipse" PetscErrorCode RGIsTrivial_Ellipse(RG rg,PetscBool *trivial) { RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data; PetscFunctionBegin; if (rg->complement) *trivial = PetscNot(ctx->radius); else *trivial = PetscNot(ctx->radiusdata; PetscReal theta; PetscInt i; PetscFunctionBegin; for (i=0;icenter + ctx->radius*(PetscCosReal(theta)+ctx->vscale*PetscSinReal(theta)*PETSC_i); #else cr[i] = ctx->center + ctx->radius*PetscCosReal(theta); ci[i] = ctx->radius*ctx->vscale*PetscSinReal(theta); #endif } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCheckInside_Ellipse" PetscErrorCode RGCheckInside_Ellipse(RG rg,PetscReal px,PetscReal py,PetscInt *inside) { RG_ELLIPSE *ctx = (RG_ELLIPSE*)rg->data; PetscReal dx,dy,r; PetscFunctionBegin; #if defined(PETSC_USE_COMPLEX) dx = (px-PetscRealPart(ctx->center))/ctx->radius; dy = (py-PetscImaginaryPart(ctx->center))/ctx->radius; #else dx = (px-ctx->center)/ctx->radius; dy = py/ctx->radius; #endif r = 1.0-dx*dx-(dy*dy)/(ctx->vscale*ctx->vscale); *inside = PetscSign(r); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetFromOptions_Ellipse" PetscErrorCode RGSetFromOptions_Ellipse(PetscOptionItems *PetscOptionsObject,RG rg) { PetscErrorCode ierr; PetscScalar s; PetscReal r1,r2; PetscBool flg1,flg2,flg3; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"RG Ellipse Options");CHKERRQ(ierr); ierr = RGEllipseGetParameters(rg,&s,&r1,&r2);CHKERRQ(ierr); ierr = PetscOptionsScalar("-rg_ellipse_center","Center of ellipse","RGEllipseSetParameters",s,&s,&flg1);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_ellipse_radius","Radius of ellipse","RGEllipseSetParameters",r1,&r1,&flg2);CHKERRQ(ierr); ierr = PetscOptionsReal("-rg_ellipse_vscale","Vertical scale of ellipse","RGEllipseSetParameters",r2,&r2,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = RGEllipseSetParameters(rg,s,r1,r2);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGDestroy_Ellipse" PetscErrorCode RGDestroy_Ellipse(RG rg) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(rg->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGEllipseSetParameters_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGEllipseGetParameters_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCreate_Ellipse" PETSC_EXTERN PetscErrorCode RGCreate_Ellipse(RG rg) { RG_ELLIPSE *ellipse; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(rg,&ellipse);CHKERRQ(ierr); ellipse->center = 0.0; ellipse->radius = 1.0; ellipse->vscale = 1.0; rg->data = (void*)ellipse; rg->ops->istrivial = RGIsTrivial_Ellipse; rg->ops->computecontour = RGComputeContour_Ellipse; rg->ops->checkinside = RGCheckInside_Ellipse; rg->ops->setfromoptions = RGSetFromOptions_Ellipse; rg->ops->view = RGView_Ellipse; rg->ops->destroy = RGDestroy_Ellipse; ierr = PetscObjectComposeFunction((PetscObject)rg,"RGEllipseSetParameters_C",RGEllipseSetParameters_Ellipse);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGEllipseGetParameters_C",RGEllipseGetParameters_Ellipse);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/rg/impls/polygon/0000755000175000017500000000000013107004621020450 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/polygon/makefile0000644000175000017500000000217413107004621022154 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = rgpolygon.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = RG LOCDIR = src/sys/classes/rg/impls/polygon/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/polygon/makefile.html0000644000175000017500000000472313107004621023121 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = rgpolygon.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = RG
LOCDIR   = src/sys/classes/rg/impls/polygon/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/rg/impls/polygon/index.html0000644000175000017500000000160613107004621022450 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

rgpolygon.c
makefile
slepc-3.7.4/src/sys/classes/rg/impls/polygon/rgpolygon.c.html0000644000175000017500000006371213107004621023610 0ustar jromanjroman

Actual source code: rgpolygon.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Region defined by a set of vertices.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/rgimpl.h>      /*I "slepcrg.h" I*/

 26: #define VERTMAX 30

 28: typedef struct {
 29:   PetscInt    n;         /* number of vertices */
 30:   PetscScalar *vr,*vi;   /* array of vertices (vi not used in complex scalars) */
 31: } RG_POLYGON;

 35: static PetscErrorCode RGPolygonSetVertices_Polygon(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi)
 36: {
 38:   PetscInt       i;
 39:   RG_POLYGON     *ctx = (RG_POLYGON*)rg->data;

 42:   if (n<3) SETERRQ1(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"At least 3 vertices required, you provided %s",n);
 43:   if (n>VERTMAX) SETERRQ1(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"Too many points, maximum allowed is %d",VERTMAX);
 44:   if (ctx->n) {
 45:     PetscFree(ctx->vr);
 46: #if !defined(PETSC_USE_COMPLEX)
 47:     PetscFree(ctx->vi);
 48: #endif
 49:   }
 50:   ctx->n = n;
 51:   PetscMalloc1(n,&ctx->vr);
 52: #if !defined(PETSC_USE_COMPLEX)
 53:   PetscMalloc1(n,&ctx->vi);
 54: #endif
 55:   for (i=0;i<n;i++) {
 56:     ctx->vr[i] = vr[i];
 57: #if !defined(PETSC_USE_COMPLEX)
 58:     ctx->vi[i] = vi[i];
 59: #endif
 60:   }
 61:   return(0);
 62: }

 66: /*@
 67:    RGPolygonSetVertices - Sets the vertices that define the polygon region.

 69:    Logically Collective on RG

 71:    Input Parameters:
 72: +  rg - the region context
 73: .  n  - number of vertices
 74: .  vr - array of vertices
 75: -  vi - array of vertices (imaginary part)

 77:    Options Database Keys:
 78: +  -rg_polygon_vertices - Sets the vertices
 79: -  -rg_polygon_verticesi - Sets the vertices (imaginary part)

 81:    Notes:
 82:    In the case of complex scalars, only argument vr is used, containing
 83:    the complex vertices; the list of vertices can be provided in the
 84:    command line with a comma-separated list of complex values
 85:    [+/-][realnumber][+/-]realnumberi with no spaces.

 87:    When PETSc is built with real scalars, the real and imaginary parts of
 88:    the vertices must be provided in two separate arrays (or two lists in
 89:    the command line).

 91:    Level: advanced

 93: .seealso: RGPolygonGetVertices()
 94: @*/
 95: PetscErrorCode RGPolygonSetVertices(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi)
 96: {

103: #if !defined(PETSC_USE_COMPLEX)
105: #endif
106:   PetscTryMethod(rg,"RGPolygonSetVertices_C",(RG,PetscInt,PetscScalar*,PetscScalar*),(rg,n,vr,vi));
107:   return(0);
108: }

112: static PetscErrorCode RGPolygonGetVertices_Polygon(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi)
113: {
114:   RG_POLYGON *ctx = (RG_POLYGON*)rg->data;

117:   if (n)  *n  = ctx->n;
118:   if (vr) *vr = ctx->vr;
119:   if (vi) *vi = ctx->vi;
120:   return(0);
121: }

125: /*@
126:    RGPolygonGetVertices - Gets the vertices that define the polygon region.

128:    Not Collective

130:    Input Parameter:
131: .  rg     - the region context

133:    Output Parameters:
134: +  n  - number of vertices
135: .  vr - array of vertices
136: -  vi - array of vertices (imaginary part)

138:    Notes:
139:    The returned arrays must NOT be freed by the calling application.

141:    Level: advanced

143: .seealso: RGPolygonSetVertices()
144: @*/
145: PetscErrorCode RGPolygonGetVertices(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi)
146: {

151:   PetscUseMethod(rg,"RGPolygonGetVertices_C",(RG,PetscInt*,PetscScalar**,PetscScalar**),(rg,n,vr,vi));
152:   return(0);
153: }

157: PetscErrorCode RGView_Polygon(RG rg,PetscViewer viewer)
158: {
160:   RG_POLYGON     *ctx = (RG_POLYGON*)rg->data;
161:   PetscBool      isascii;
162:   PetscInt       i;
163:   char           str[50];

166:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
167:   if (isascii) {
168:     PetscViewerASCIIPrintf(viewer,"vertices: ");
169:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
170:     for (i=0;i<ctx->n;i++) {
171: #if defined(PETSC_USE_COMPLEX)
172:       SlepcSNPrintfScalar(str,50,ctx->vr[i],PETSC_FALSE);
173: #else
174:       if (ctx->vi[i]!=0.0) {
175:         PetscSNPrintf(str,50,"%g%+gi",(double)ctx->vr[i],(double)ctx->vi[i]);
176:       } else {
177:         PetscSNPrintf(str,50,"%g",(double)ctx->vr[i]);
178:       }
179: #endif
180:       PetscViewerASCIIPrintf(viewer,"%s%s",str,(i<ctx->n-1)?",":"");
181:     }
182:     PetscViewerASCIIPrintf(viewer,"\n");
183:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
184:   }
185:   return(0);
186: }

190: PetscErrorCode RGIsTrivial_Polygon(RG rg,PetscBool *trivial)
191: {
192:   RG_POLYGON *ctx = (RG_POLYGON*)rg->data;

195:   *trivial = PetscNot(ctx->n);
196:   return(0);
197: }

201: PetscErrorCode RGComputeContour_Polygon(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)
202: {
203:   RG_POLYGON  *ctx = (RG_POLYGON*)rg->data;
204:   PetscReal   length,h,d,rem=0.0;
205:   PetscInt    k=1,idx=ctx->n-1,i;
206:   PetscBool   ini=PETSC_FALSE;
207:   PetscScalar incr;
208: #if !defined(PETSC_USE_COMPLEX)
209:   PetscScalar inci;
210: #endif

213:   if (!ctx->n) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONGSTATE,"No vertices have been set yet");
214:   length = SlepcAbsEigenvalue(ctx->vr[0]-ctx->vr[ctx->n-1],ctx->vi[0]-ctx->vi[ctx->n-1]);
215:   for (i=0;i<ctx->n-1;i++) length += SlepcAbsEigenvalue(ctx->vr[i]-ctx->vr[i+1],ctx->vi[i]-ctx->vi[i+1]);
216:   h = length/n;
217:   cr[0] = ctx->vr[0];
218: #if !defined(PETSC_USE_COMPLEX)
219:   ci[0] = ctx->vi[0];
220: #endif
221:   incr = ctx->vr[ctx->n-1]-ctx->vr[0];
222: #if !defined(PETSC_USE_COMPLEX)
223:   inci = ctx->vi[ctx->n-1]-ctx->vi[0];
224: #endif
225:   d = SlepcAbsEigenvalue(incr,inci);
226:   incr /= d;
227: #if !defined(PETSC_USE_COMPLEX)
228:   inci /= d;
229: #endif
230:   while (k<n) {
231:     if (ini) {
232:       incr = ctx->vr[idx]-ctx->vr[idx+1];
233: #if !defined(PETSC_USE_COMPLEX)
234:       inci = ctx->vi[idx]-ctx->vi[idx+1];
235: #endif
236:       d = SlepcAbsEigenvalue(incr,inci);
237:       incr /= d;
238: #if !defined(PETSC_USE_COMPLEX)
239:       inci /= d;
240: #endif
241:       if (rem+d>h) {
242:         cr[k] = ctx->vr[idx+1]+incr*(h-rem);
243: #if !defined(PETSC_USE_COMPLEX)
244:         ci[k] = ctx->vi[idx+1]+inci*(h-rem);
245: #endif
246:         k++;
247:         ini = PETSC_FALSE;
248:       } else {rem += d; idx--;}
249:     } else {
250: #if !defined(PETSC_USE_COMPLEX)
251:       rem = SlepcAbsEigenvalue(ctx->vr[idx]-cr[k-1],ctx->vi[idx]-ci[k-1]);
252: #else
253:       rem = PetscAbsScalar(ctx->vr[idx]-cr[k-1]);
254: #endif
255:       if (rem>h) {
256:         cr[k] = cr[k-1]+incr*h;
257: #if !defined(PETSC_USE_COMPLEX)
258:         ci[k] = ci[k-1]+inci*h;
259: #endif
260:         k++;
261:       } else {ini = PETSC_TRUE; idx--;}
262:     }
263:   }
264:   return(0);
265: }

269: PetscErrorCode RGCheckInside_Polygon(RG rg,PetscReal px,PetscReal py,PetscInt *inout)
270: {
271:   RG_POLYGON *ctx = (RG_POLYGON*)rg->data;
272:   PetscReal  val,x[VERTMAX],y[VERTMAX];
273:   PetscBool  mx,my,nx,ny;
274:   PetscInt   i,j;

277:   for (i=0;i<ctx->n;i++) {
278: #if defined(PETSC_USE_COMPLEX)
279:     x[i] = PetscRealPart(ctx->vr[i])-px;
280:     y[i] = PetscImaginaryPart(ctx->vr[i])-py;
281: #else
282:     x[i] = ctx->vr[i]-px;
283:     y[i] = ctx->vi[i]-py;
284: #endif
285:   }
286:   *inout = -1;
287:   for (i=0;i<ctx->n;i++) {
288:     j = (i+1)%ctx->n;
289:     mx = PetscNot(x[i]<0.0);
290:     nx = PetscNot(x[j]<0.0);
291:     my = PetscNot(y[i]<0.0);
292:     ny = PetscNot(y[j]<0.0);
293:     if (!((my||ny) && (mx||nx)) || (mx&&nx)) continue;
294:     if (((my && ny && (mx||nx)) && (!(mx&&nx)))) {
295:       *inout = -*inout;
296:       continue;
297:     }
298:     val = (y[i]*x[j]-x[i]*y[j])/(x[j]-x[i]);
299:     if (PetscAbs(val)<10*PETSC_MACHINE_EPSILON) {
300:       *inout = 0;
301:       return(0);
302:     } else if (val>0.0) *inout = -*inout;
303:   }
304:   return(0);
305: }

309: PetscErrorCode RGSetFromOptions_Polygon(PetscOptionItems *PetscOptionsObject,RG rg)
310: {
312:   PetscScalar    array[VERTMAX];
313:   PetscInt       i,k;
314:   PetscBool      flg,flgi=PETSC_FALSE;
315: #if !defined(PETSC_USE_COMPLEX)
316:   PetscScalar    arrayi[VERTMAX];
317:   PetscInt       ki;
318: #else
319:   PetscScalar    *arrayi=NULL;
320: #endif

323:   PetscOptionsHead(PetscOptionsObject,"RG Polygon Options");

325:   k = VERTMAX;
326:   for (i=0;i<k;i++) array[i] = 0;
327:   PetscOptionsScalarArray("-rg_polygon_vertices","Vertices of polygon","RGPolygonSetVertices",array,&k,&flg);
328: #if !defined(PETSC_USE_COMPLEX)
329:   ki = VERTMAX;
330:   for (i=0;i<ki;i++) arrayi[i] = 0;
331:   PetscOptionsScalarArray("-rg_polygon_verticesi","Vertices of polygon (imaginary part)","RGPolygonSetVertices",arrayi,&ki,&flgi);
332:   if (ki!=k) SETERRQ2(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_SIZ,"The number of real %D and imaginary %D parts do not match",k,ki);
333: #endif
334:   if (flg || flgi) {
335:     RGPolygonSetVertices(rg,k,array,arrayi);
336:   }

338:   PetscOptionsTail();
339:   return(0);
340: }

344: PetscErrorCode RGDestroy_Polygon(RG rg)
345: {
347:   RG_POLYGON     *ctx = (RG_POLYGON*)rg->data;

350:   if (ctx->n) {
351:     PetscFree(ctx->vr);
352: #if !defined(PETSC_USE_COMPLEX)
353:     PetscFree(ctx->vi);
354: #endif
355:   }
356:   PetscFree(rg->data);
357:   PetscObjectComposeFunction((PetscObject)rg,"RGPolygonSetVertices_C",NULL);
358:   PetscObjectComposeFunction((PetscObject)rg,"RGPolygonGetVertices_C",NULL);
359:   return(0);
360: }

364: PETSC_EXTERN PetscErrorCode RGCreate_Polygon(RG rg)
365: {
366:   RG_POLYGON     *polygon;

370:   PetscNewLog(rg,&polygon);
371:   rg->data = (void*)polygon;

373:   rg->ops->istrivial      = RGIsTrivial_Polygon;
374:   rg->ops->computecontour = RGComputeContour_Polygon;
375:   rg->ops->checkinside    = RGCheckInside_Polygon;
376:   rg->ops->setfromoptions = RGSetFromOptions_Polygon;
377:   rg->ops->view           = RGView_Polygon;
378:   rg->ops->destroy        = RGDestroy_Polygon;
379:   PetscObjectComposeFunction((PetscObject)rg,"RGPolygonSetVertices_C",RGPolygonSetVertices_Polygon);
380:   PetscObjectComposeFunction((PetscObject)rg,"RGPolygonGetVertices_C",RGPolygonGetVertices_Polygon);
381:   return(0);
382: }

slepc-3.7.4/src/sys/classes/rg/impls/polygon/ftn-auto/0000755000175000017500000000000013107004621022205 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/polygon/ftn-auto/makefile0000644000175000017500000000040013107004621023677 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = rgpolygonf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/rg/impls/polygon/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/polygon/ftn-auto/rgpolygonf.c0000644000175000017500000000304113107004621024535 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* rgpolygon.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcrg.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgpolygonsetvertices_ RGPOLYGONSETVERTICES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgpolygonsetvertices_ rgpolygonsetvertices #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgpolygongetvertices_ RGPOLYGONGETVERTICES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgpolygongetvertices_ rgpolygongetvertices #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL rgpolygonsetvertices_(RG rg,PetscInt *n,PetscScalar *vr,PetscScalar *vi, int *__ierr ){ *__ierr = RGPolygonSetVertices( (RG)PetscToPointer((rg) ),*n,vr,vi); } PETSC_EXTERN void PETSC_STDCALL rgpolygongetvertices_(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi, int *__ierr ){ *__ierr = RGPolygonGetVertices( (RG)PetscToPointer((rg) ),n,vr,vi); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/classes/rg/impls/polygon/rgpolygon.c0000644000175000017500000002703213107004621022640 0ustar jromanjroman/* Region defined by a set of vertices. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcrg.h" I*/ #define VERTMAX 30 typedef struct { PetscInt n; /* number of vertices */ PetscScalar *vr,*vi; /* array of vertices (vi not used in complex scalars) */ } RG_POLYGON; #undef __FUNCT__ #define __FUNCT__ "RGPolygonSetVertices_Polygon" static PetscErrorCode RGPolygonSetVertices_Polygon(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi) { PetscErrorCode ierr; PetscInt i; RG_POLYGON *ctx = (RG_POLYGON*)rg->data; PetscFunctionBegin; if (n<3) SETERRQ1(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"At least 3 vertices required, you provided %s",n); if (n>VERTMAX) SETERRQ1(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_OUTOFRANGE,"Too many points, maximum allowed is %d",VERTMAX); if (ctx->n) { ierr = PetscFree(ctx->vr);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = PetscFree(ctx->vi);CHKERRQ(ierr); #endif } ctx->n = n; ierr = PetscMalloc1(n,&ctx->vr);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = PetscMalloc1(n,&ctx->vi);CHKERRQ(ierr); #endif for (i=0;ivr[i] = vr[i]; #if !defined(PETSC_USE_COMPLEX) ctx->vi[i] = vi[i]; #endif } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGPolygonSetVertices" /*@ RGPolygonSetVertices - Sets the vertices that define the polygon region. Logically Collective on RG Input Parameters: + rg - the region context . n - number of vertices . vr - array of vertices - vi - array of vertices (imaginary part) Options Database Keys: + -rg_polygon_vertices - Sets the vertices - -rg_polygon_verticesi - Sets the vertices (imaginary part) Notes: In the case of complex scalars, only argument vr is used, containing the complex vertices; the list of vertices can be provided in the command line with a comma-separated list of complex values [+/-][realnumber][+/-]realnumberi with no spaces. When PETSc is built with real scalars, the real and imaginary parts of the vertices must be provided in two separate arrays (or two lists in the command line). Level: advanced .seealso: RGPolygonGetVertices() @*/ PetscErrorCode RGPolygonSetVertices(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidLogicalCollectiveInt(rg,n,2); PetscValidPointer(vr,3); #if !defined(PETSC_USE_COMPLEX) PetscValidPointer(vi,4); #endif ierr = PetscTryMethod(rg,"RGPolygonSetVertices_C",(RG,PetscInt,PetscScalar*,PetscScalar*),(rg,n,vr,vi));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGPolygonGetVertices_Polygon" static PetscErrorCode RGPolygonGetVertices_Polygon(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi) { RG_POLYGON *ctx = (RG_POLYGON*)rg->data; PetscFunctionBegin; if (n) *n = ctx->n; if (vr) *vr = ctx->vr; if (vi) *vi = ctx->vi; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGPolygonGetVertices" /*@ RGPolygonGetVertices - Gets the vertices that define the polygon region. Not Collective Input Parameter: . rg - the region context Output Parameters: + n - number of vertices . vr - array of vertices - vi - array of vertices (imaginary part) Notes: The returned arrays must NOT be freed by the calling application. Level: advanced .seealso: RGPolygonSetVertices() @*/ PetscErrorCode RGPolygonGetVertices(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = PetscUseMethod(rg,"RGPolygonGetVertices_C",(RG,PetscInt*,PetscScalar**,PetscScalar**),(rg,n,vr,vi));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGView_Polygon" PetscErrorCode RGView_Polygon(RG rg,PetscViewer viewer) { PetscErrorCode ierr; RG_POLYGON *ctx = (RG_POLYGON*)rg->data; PetscBool isascii; PetscInt i; char str[50]; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer,"vertices: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;in;i++) { #if defined(PETSC_USE_COMPLEX) ierr = SlepcSNPrintfScalar(str,50,ctx->vr[i],PETSC_FALSE);CHKERRQ(ierr); #else if (ctx->vi[i]!=0.0) { ierr = PetscSNPrintf(str,50,"%g%+gi",(double)ctx->vr[i],(double)ctx->vi[i]);CHKERRQ(ierr); } else { ierr = PetscSNPrintf(str,50,"%g",(double)ctx->vr[i]);CHKERRQ(ierr); } #endif ierr = PetscViewerASCIIPrintf(viewer,"%s%s",str,(in-1)?",":"");CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIsTrivial_Polygon" PetscErrorCode RGIsTrivial_Polygon(RG rg,PetscBool *trivial) { RG_POLYGON *ctx = (RG_POLYGON*)rg->data; PetscFunctionBegin; *trivial = PetscNot(ctx->n); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGComputeContour_Polygon" PetscErrorCode RGComputeContour_Polygon(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci) { RG_POLYGON *ctx = (RG_POLYGON*)rg->data; PetscReal length,h,d,rem=0.0; PetscInt k=1,idx=ctx->n-1,i; PetscBool ini=PETSC_FALSE; PetscScalar incr; #if !defined(PETSC_USE_COMPLEX) PetscScalar inci; #endif PetscFunctionBegin; if (!ctx->n) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONGSTATE,"No vertices have been set yet"); length = SlepcAbsEigenvalue(ctx->vr[0]-ctx->vr[ctx->n-1],ctx->vi[0]-ctx->vi[ctx->n-1]); for (i=0;in-1;i++) length += SlepcAbsEigenvalue(ctx->vr[i]-ctx->vr[i+1],ctx->vi[i]-ctx->vi[i+1]); h = length/n; cr[0] = ctx->vr[0]; #if !defined(PETSC_USE_COMPLEX) ci[0] = ctx->vi[0]; #endif incr = ctx->vr[ctx->n-1]-ctx->vr[0]; #if !defined(PETSC_USE_COMPLEX) inci = ctx->vi[ctx->n-1]-ctx->vi[0]; #endif d = SlepcAbsEigenvalue(incr,inci); incr /= d; #if !defined(PETSC_USE_COMPLEX) inci /= d; #endif while (kvr[idx]-ctx->vr[idx+1]; #if !defined(PETSC_USE_COMPLEX) inci = ctx->vi[idx]-ctx->vi[idx+1]; #endif d = SlepcAbsEigenvalue(incr,inci); incr /= d; #if !defined(PETSC_USE_COMPLEX) inci /= d; #endif if (rem+d>h) { cr[k] = ctx->vr[idx+1]+incr*(h-rem); #if !defined(PETSC_USE_COMPLEX) ci[k] = ctx->vi[idx+1]+inci*(h-rem); #endif k++; ini = PETSC_FALSE; } else {rem += d; idx--;} } else { #if !defined(PETSC_USE_COMPLEX) rem = SlepcAbsEigenvalue(ctx->vr[idx]-cr[k-1],ctx->vi[idx]-ci[k-1]); #else rem = PetscAbsScalar(ctx->vr[idx]-cr[k-1]); #endif if (rem>h) { cr[k] = cr[k-1]+incr*h; #if !defined(PETSC_USE_COMPLEX) ci[k] = ci[k-1]+inci*h; #endif k++; } else {ini = PETSC_TRUE; idx--;} } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCheckInside_Polygon" PetscErrorCode RGCheckInside_Polygon(RG rg,PetscReal px,PetscReal py,PetscInt *inout) { RG_POLYGON *ctx = (RG_POLYGON*)rg->data; PetscReal val,x[VERTMAX],y[VERTMAX]; PetscBool mx,my,nx,ny; PetscInt i,j; PetscFunctionBegin; for (i=0;in;i++) { #if defined(PETSC_USE_COMPLEX) x[i] = PetscRealPart(ctx->vr[i])-px; y[i] = PetscImaginaryPart(ctx->vr[i])-py; #else x[i] = ctx->vr[i]-px; y[i] = ctx->vi[i]-py; #endif } *inout = -1; for (i=0;in;i++) { j = (i+1)%ctx->n; mx = PetscNot(x[i]<0.0); nx = PetscNot(x[j]<0.0); my = PetscNot(y[i]<0.0); ny = PetscNot(y[j]<0.0); if (!((my||ny) && (mx||nx)) || (mx&&nx)) continue; if (((my && ny && (mx||nx)) && (!(mx&&nx)))) { *inout = -*inout; continue; } val = (y[i]*x[j]-x[i]*y[j])/(x[j]-x[i]); if (PetscAbs(val)<10*PETSC_MACHINE_EPSILON) { *inout = 0; PetscFunctionReturn(0); } else if (val>0.0) *inout = -*inout; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetFromOptions_Polygon" PetscErrorCode RGSetFromOptions_Polygon(PetscOptionItems *PetscOptionsObject,RG rg) { PetscErrorCode ierr; PetscScalar array[VERTMAX]; PetscInt i,k; PetscBool flg,flgi=PETSC_FALSE; #if !defined(PETSC_USE_COMPLEX) PetscScalar arrayi[VERTMAX]; PetscInt ki; #else PetscScalar *arrayi=NULL; #endif PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"RG Polygon Options");CHKERRQ(ierr); k = VERTMAX; for (i=0;idata; PetscFunctionBegin; if (ctx->n) { ierr = PetscFree(ctx->vr);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = PetscFree(ctx->vi);CHKERRQ(ierr); #endif } ierr = PetscFree(rg->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGPolygonSetVertices_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGPolygonGetVertices_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCreate_Polygon" PETSC_EXTERN PetscErrorCode RGCreate_Polygon(RG rg) { RG_POLYGON *polygon; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(rg,&polygon);CHKERRQ(ierr); rg->data = (void*)polygon; rg->ops->istrivial = RGIsTrivial_Polygon; rg->ops->computecontour = RGComputeContour_Polygon; rg->ops->checkinside = RGCheckInside_Polygon; rg->ops->setfromoptions = RGSetFromOptions_Polygon; rg->ops->view = RGView_Polygon; rg->ops->destroy = RGDestroy_Polygon; ierr = PetscObjectComposeFunction((PetscObject)rg,"RGPolygonSetVertices_C",RGPolygonSetVertices_Polygon);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGPolygonGetVertices_C",RGPolygonGetVertices_Polygon);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/rg/impls/index.html0000644000175000017500000000172313107004621020761 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

ellipse/
interval/
polygon/
ring/
makefile
slepc-3.7.4/src/sys/classes/rg/impls/interval/0000755000175000017500000000000013107004621020605 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/interval/makefile0000644000175000017500000000217613107004621022313 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = rginterval.c SOURCEF = SOURCEH = LIBBASE = libslepcsys DIRS = MANSEC = RG LOCDIR = src/sys/classes/rg/impls/interval/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/interval/rginterval.c.html0000644000175000017500000005214713107004621024102 0ustar jromanjroman

Actual source code: rginterval.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Interval of the real axis or more generally a (possibly open) rectangle
  3:    of the complex plane.

  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: */

 25: #include <slepc/private/rgimpl.h>      /*I "slepcrg.h" I*/

 27: typedef struct {
 28:   PetscReal   a,b;     /* interval in the real axis */
 29:   PetscReal   c,d;     /* interval in the imaginary axis */
 30: } RG_INTERVAL;

 34: static PetscErrorCode RGIntervalSetEndpoints_Interval(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d)
 35: {
 36:   RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data;

 39:   if (!a && !b && !c && !d) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"At least one argument must be nonzero");
 40:   if (a==b && a) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"Badly defined interval, endpoints must be distinct (or both zero)");
 41:   if (a>b) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"Badly defined interval, must be a<b");
 42:   if (c==d && c) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"Badly defined interval, endpoints must be distinct (or both zero)");
 43:   if (c>d) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"Badly defined interval, must be c<d");
 44: #if !defined(PETSC_USE_COMPLEX)
 45:   if (c!=-d) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"In real scalars the region must be symmetric wrt real axis");
 46: #endif
 47:   ctx->a = a;
 48:   ctx->b = b;
 49:   ctx->c = c;
 50:   ctx->d = d;
 51:   return(0);
 52: }

 56: /*@
 57:    RGIntervalSetEndpoints - Sets the parameters defining the interval region.

 59:    Logically Collective on RG

 61:    Input Parameters:
 62: +  rg  - the region context
 63: .  a,b - endpoints of the interval in the real axis
 64: -  c,d - endpoints of the interval in the imaginary axis

 66:    Options Database Keys:
 67: .  -rg_interval_endpoints - the four endpoints

 69:    Note:
 70:    The region is defined as [a,b]x[c,d]. Particular cases are an interval on
 71:    the real axis (c=d=0), similar for the imaginary axis (a=b=0), the whole
 72:    complex plane (a=-inf,b=inf,c=-inf,d=inf), and so on.

 74:    Level: advanced

 76: .seealso: RGIntervalGetEndpoints()
 77: @*/
 78: PetscErrorCode RGIntervalSetEndpoints(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d)
 79: {

 88:   PetscTryMethod(rg,"RGIntervalSetEndpoints_C",(RG,PetscReal,PetscReal,PetscReal,PetscReal),(rg,a,b,c,d));
 89:   return(0);
 90: }

 94: static PetscErrorCode RGIntervalGetEndpoints_Interval(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d)
 95: {
 96:   RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data;

 99:   if (a) *a = ctx->a;
100:   if (b) *b = ctx->b;
101:   if (c) *c = ctx->c;
102:   if (d) *d = ctx->d;
103:   return(0);
104: }

108: /*@
109:    RGIntervalGetEndpoints - Gets the parameters that define the interval region.

111:    Not Collective

113:    Input Parameter:
114: .  rg - the region context

116:    Output Parameters:
117: +  a,b - endpoints of the interval in the real axis
118: -  c,d - endpoints of the interval in the imaginary axis

120:    Level: advanced

122: .seealso: RGIntervalSetEndpoints()
123: @*/
124: PetscErrorCode RGIntervalGetEndpoints(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d)
125: {

130:   PetscUseMethod(rg,"RGIntervalGetEndpoints_C",(RG,PetscReal*,PetscReal*,PetscReal*,PetscReal*),(rg,a,b,c,d));
131:   return(0);
132: }

136: PetscErrorCode RGView_Interval(RG rg,PetscViewer viewer)
137: {
139:   RG_INTERVAL    *ctx = (RG_INTERVAL*)rg->data;
140:   PetscBool      isascii;

143:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
144:   if (isascii) {
145:     PetscViewerASCIIPrintf(viewer,"region: [%g,%g]x[%g,%g]\n",RGShowReal(ctx->a),RGShowReal(ctx->b),RGShowReal(ctx->c),RGShowReal(ctx->d));
146:   }
147:   return(0);
148: }

152: PetscErrorCode RGIsTrivial_Interval(RG rg,PetscBool *trivial)
153: {
154:   RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data;

157:   if (rg->complement) *trivial = (ctx->a==ctx->b && ctx->c==ctx->d)? PETSC_TRUE: PETSC_FALSE;
158:   else *trivial = (ctx->a<=-PETSC_MAX_REAL && ctx->b>=PETSC_MAX_REAL && ctx->c<=-PETSC_MAX_REAL && ctx->d>=PETSC_MAX_REAL)? PETSC_TRUE: PETSC_FALSE;
159:   return(0);
160: }

164: PetscErrorCode RGComputeContour_Interval(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)
165: {
166:   RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data;
167:   PetscInt    i,pt,idx,j;
168:   PetscReal   hr[4],hi[4],h,off,d[4];
169:   PetscScalar vr[4],vi[4];

172:   if (!(ctx->a>-PETSC_MAX_REAL && ctx->b<PETSC_MAX_REAL && ctx->c>-PETSC_MAX_REAL && ctx->d<PETSC_MAX_REAL)) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_SUP,"Contour not defined in unbounded regions");
173:   if (ctx->a==ctx->b || ctx->c==ctx->d) {
174:     if (ctx->a==ctx->b) {hi[0] = (ctx->d-ctx->c)/(n-1); hr[0] = 0.0;}
175:     else {hr[0] = (ctx->b-ctx->a)/(n-1); hi[0] = 0.0;}
176:     for (i=0;i<n;i++) {
177: #if defined(PETSC_USE_COMPLEX)
178:       cr[i] = ctx->a+hr[0]*i + (ctx->c+hi[0]*i)*PETSC_i;
179: #else
180:       cr[i] = ctx->a+hr[0]*i; ci[i] = ctx->c+hi[0]*i;
181: #endif
182:     }
183:   } else {
184:     d[1] = d[3] = ctx->d-ctx->c; d[0] = d[2] = ctx->b-ctx->a;
185:     h = (2*(d[0]+d[1]))/n;
186:     vr[0] = ctx->a; vr[1] = ctx->b; vr[2] = ctx->b; vr[3] = ctx->a;
187:     vi[0] = ctx->c; vi[1] = ctx->c; vi[2] = ctx->d; vi[3] = ctx->d;
188:     hr[0] = h;   hr[1] = 0.0; hr[2] = -h;  hr[3] = 0.0;
189:     hi[0] = 0.0; hi[1] = h;   hi[2] = 0.0; hi[3] = -h;
190:     off = 0.0; idx = 0;
191:     for (i=0;i<4;i++) {
192: #if defined(PETSC_USE_COMPLEX)
193:       cr[idx] = vr[i]+off*(hr[i]/h)+ (vi[i]+off*(hi[i]/h))*PETSC_i; 
194: #else
195:       cr[idx] = vr[i]+off*(hr[i]/h); ci[idx]=vi[i]+off*(hi[i]/h);
196: #endif 
197:       idx++;
198:       pt = (d[i]-off)/h+1;
199:       for (j=1;j<pt && idx<n;j++) {
200: #if defined(PETSC_USE_COMPLEX)
201:         cr[idx] = cr[idx-1]+(hr[i]+hi[i]*PETSC_i);
202: #else
203:         cr[idx] = cr[idx-1]+hr[i]; ci[idx] = ci[idx-1]+hi[i];
204: #endif
205:         idx++;
206:       }
207:       off = off+pt*h-d[i];
208:       if (off>=d[i+1]) {off -= d[i+1]; i++;}
209:     }  
210:   }
211:   return(0);
212: }

216: PetscErrorCode RGCheckInside_Interval(RG rg,PetscReal dx,PetscReal dy,PetscInt *inside)
217: {
218:   RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data;

221:   if (dx>ctx->a && dx<ctx->b) *inside = 1;
222:   else if (dx==ctx->a || dx==ctx->b) *inside = 0;
223:   else *inside = -1;
224:   if (*inside>=0) {
225:     if (dy>ctx->c && dy<ctx->d) ;
226:     else if (dy==ctx->c || dy==ctx->d) *inside = 0;
227:     else *inside = -1;
228:   }
229:   return(0);
230: }

234: PetscErrorCode RGSetFromOptions_Interval(PetscOptionItems *PetscOptionsObject,RG rg)
235: {
237:   PetscBool      flg;
238:   PetscInt       k;
239:   PetscReal      array[4]={0,0,0,0};

242:   PetscOptionsHead(PetscOptionsObject,"RG Interval Options");

244:   k = 4;
245:   PetscOptionsRealArray("-rg_interval_endpoints","Interval endpoints (four real values separated with a comma without spaces)","RGIntervalSetEndpoints",array,&k,&flg);
246:   if (flg) {
247:     if (k<2) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_SIZ,"Must pass at leat two values in -rg_interval_endpoints (comma-separated without spaces)");
248:     RGIntervalSetEndpoints(rg,array[0],array[1],array[2],array[3]);
249:   }

251:   PetscOptionsTail();
252:   return(0);
253: }

257: PetscErrorCode RGDestroy_Interval(RG rg)
258: {

262:   PetscFree(rg->data);
263:   PetscObjectComposeFunction((PetscObject)rg,"RGIntervalSetEndpoints_C",NULL);
264:   PetscObjectComposeFunction((PetscObject)rg,"RGIntervalGetEndpoints_C",NULL);
265:   return(0);
266: }

270: PETSC_EXTERN PetscErrorCode RGCreate_Interval(RG rg)
271: {
272:   RG_INTERVAL    *interval;

276:   PetscNewLog(rg,&interval);
277:   interval->a = -PETSC_MAX_REAL;
278:   interval->b = PETSC_MAX_REAL;
279:   interval->c = -PETSC_MAX_REAL;
280:   interval->d = PETSC_MAX_REAL;
281:   rg->data = (void*)interval;

283:   rg->ops->istrivial      = RGIsTrivial_Interval;
284:   rg->ops->computecontour = RGComputeContour_Interval;
285:   rg->ops->checkinside    = RGCheckInside_Interval;
286:   rg->ops->setfromoptions = RGSetFromOptions_Interval;
287:   rg->ops->view           = RGView_Interval;
288:   rg->ops->destroy        = RGDestroy_Interval;
289:   PetscObjectComposeFunction((PetscObject)rg,"RGIntervalSetEndpoints_C",RGIntervalSetEndpoints_Interval);
290:   PetscObjectComposeFunction((PetscObject)rg,"RGIntervalGetEndpoints_C",RGIntervalGetEndpoints_Interval);
291:   return(0);
292: }

slepc-3.7.4/src/sys/classes/rg/impls/interval/makefile.html0000644000175000017500000000472713107004621023262 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = rginterval.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcsys
DIRS     =
MANSEC   = RG
LOCDIR   = src/sys/classes/rg/impls/interval/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/sys/classes/rg/impls/interval/rginterval.c0000644000175000017500000002413413107004621023132 0ustar jromanjroman/* Interval of the real axis or more generally a (possibly open) rectangle of the complex plane. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcrg.h" I*/ typedef struct { PetscReal a,b; /* interval in the real axis */ PetscReal c,d; /* interval in the imaginary axis */ } RG_INTERVAL; #undef __FUNCT__ #define __FUNCT__ "RGIntervalSetEndpoints_Interval" static PetscErrorCode RGIntervalSetEndpoints_Interval(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d) { RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data; PetscFunctionBegin; if (!a && !b && !c && !d) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"At least one argument must be nonzero"); if (a==b && a) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"Badly defined interval, endpoints must be distinct (or both zero)"); if (a>b) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"Badly defined interval, must be ad) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_WRONG,"Badly defined interval, must be ca = a; ctx->b = b; ctx->c = c; ctx->d = d; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIntervalSetEndpoints" /*@ RGIntervalSetEndpoints - Sets the parameters defining the interval region. Logically Collective on RG Input Parameters: + rg - the region context . a,b - endpoints of the interval in the real axis - c,d - endpoints of the interval in the imaginary axis Options Database Keys: . -rg_interval_endpoints - the four endpoints Note: The region is defined as [a,b]x[c,d]. Particular cases are an interval on the real axis (c=d=0), similar for the imaginary axis (a=b=0), the whole complex plane (a=-inf,b=inf,c=-inf,d=inf), and so on. Level: advanced .seealso: RGIntervalGetEndpoints() @*/ PetscErrorCode RGIntervalSetEndpoints(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); PetscValidLogicalCollectiveReal(rg,a,2); PetscValidLogicalCollectiveReal(rg,b,3); PetscValidLogicalCollectiveReal(rg,c,4); PetscValidLogicalCollectiveReal(rg,d,5); ierr = PetscTryMethod(rg,"RGIntervalSetEndpoints_C",(RG,PetscReal,PetscReal,PetscReal,PetscReal),(rg,a,b,c,d));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIntervalGetEndpoints_Interval" static PetscErrorCode RGIntervalGetEndpoints_Interval(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d) { RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data; PetscFunctionBegin; if (a) *a = ctx->a; if (b) *b = ctx->b; if (c) *c = ctx->c; if (d) *d = ctx->d; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIntervalGetEndpoints" /*@ RGIntervalGetEndpoints - Gets the parameters that define the interval region. Not Collective Input Parameter: . rg - the region context Output Parameters: + a,b - endpoints of the interval in the real axis - c,d - endpoints of the interval in the imaginary axis Level: advanced .seealso: RGIntervalSetEndpoints() @*/ PetscErrorCode RGIntervalGetEndpoints(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = PetscUseMethod(rg,"RGIntervalGetEndpoints_C",(RG,PetscReal*,PetscReal*,PetscReal*,PetscReal*),(rg,a,b,c,d));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGView_Interval" PetscErrorCode RGView_Interval(RG rg,PetscViewer viewer) { PetscErrorCode ierr; RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer,"region: [%g,%g]x[%g,%g]\n",RGShowReal(ctx->a),RGShowReal(ctx->b),RGShowReal(ctx->c),RGShowReal(ctx->d));CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGIsTrivial_Interval" PetscErrorCode RGIsTrivial_Interval(RG rg,PetscBool *trivial) { RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data; PetscFunctionBegin; if (rg->complement) *trivial = (ctx->a==ctx->b && ctx->c==ctx->d)? PETSC_TRUE: PETSC_FALSE; else *trivial = (ctx->a<=-PETSC_MAX_REAL && ctx->b>=PETSC_MAX_REAL && ctx->c<=-PETSC_MAX_REAL && ctx->d>=PETSC_MAX_REAL)? PETSC_TRUE: PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGComputeContour_Interval" PetscErrorCode RGComputeContour_Interval(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci) { RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data; PetscInt i,pt,idx,j; PetscReal hr[4],hi[4],h,off,d[4]; PetscScalar vr[4],vi[4]; PetscFunctionBegin; if (!(ctx->a>-PETSC_MAX_REAL && ctx->bc>-PETSC_MAX_REAL && ctx->da==ctx->b || ctx->c==ctx->d) { if (ctx->a==ctx->b) {hi[0] = (ctx->d-ctx->c)/(n-1); hr[0] = 0.0;} else {hr[0] = (ctx->b-ctx->a)/(n-1); hi[0] = 0.0;} for (i=0;ia+hr[0]*i + (ctx->c+hi[0]*i)*PETSC_i; #else cr[i] = ctx->a+hr[0]*i; ci[i] = ctx->c+hi[0]*i; #endif } } else { d[1] = d[3] = ctx->d-ctx->c; d[0] = d[2] = ctx->b-ctx->a; h = (2*(d[0]+d[1]))/n; vr[0] = ctx->a; vr[1] = ctx->b; vr[2] = ctx->b; vr[3] = ctx->a; vi[0] = ctx->c; vi[1] = ctx->c; vi[2] = ctx->d; vi[3] = ctx->d; hr[0] = h; hr[1] = 0.0; hr[2] = -h; hr[3] = 0.0; hi[0] = 0.0; hi[1] = h; hi[2] = 0.0; hi[3] = -h; off = 0.0; idx = 0; for (i=0;i<4;i++) { #if defined(PETSC_USE_COMPLEX) cr[idx] = vr[i]+off*(hr[i]/h)+ (vi[i]+off*(hi[i]/h))*PETSC_i; #else cr[idx] = vr[i]+off*(hr[i]/h); ci[idx]=vi[i]+off*(hi[i]/h); #endif idx++; pt = (d[i]-off)/h+1; for (j=1;j=d[i+1]) {off -= d[i+1]; i++;} } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCheckInside_Interval" PetscErrorCode RGCheckInside_Interval(RG rg,PetscReal dx,PetscReal dy,PetscInt *inside) { RG_INTERVAL *ctx = (RG_INTERVAL*)rg->data; PetscFunctionBegin; if (dx>ctx->a && dxb) *inside = 1; else if (dx==ctx->a || dx==ctx->b) *inside = 0; else *inside = -1; if (*inside>=0) { if (dy>ctx->c && dyd) ; else if (dy==ctx->c || dy==ctx->d) *inside = 0; else *inside = -1; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGSetFromOptions_Interval" PetscErrorCode RGSetFromOptions_Interval(PetscOptionItems *PetscOptionsObject,RG rg) { PetscErrorCode ierr; PetscBool flg; PetscInt k; PetscReal array[4]={0,0,0,0}; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"RG Interval Options");CHKERRQ(ierr); k = 4; ierr = PetscOptionsRealArray("-rg_interval_endpoints","Interval endpoints (four real values separated with a comma without spaces)","RGIntervalSetEndpoints",array,&k,&flg);CHKERRQ(ierr); if (flg) { if (k<2) SETERRQ(PetscObjectComm((PetscObject)rg),PETSC_ERR_ARG_SIZ,"Must pass at leat two values in -rg_interval_endpoints (comma-separated without spaces)"); ierr = RGIntervalSetEndpoints(rg,array[0],array[1],array[2],array[3]);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGDestroy_Interval" PetscErrorCode RGDestroy_Interval(RG rg) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(rg->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGIntervalSetEndpoints_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGIntervalGetEndpoints_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "RGCreate_Interval" PETSC_EXTERN PetscErrorCode RGCreate_Interval(RG rg) { RG_INTERVAL *interval; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(rg,&interval);CHKERRQ(ierr); interval->a = -PETSC_MAX_REAL; interval->b = PETSC_MAX_REAL; interval->c = -PETSC_MAX_REAL; interval->d = PETSC_MAX_REAL; rg->data = (void*)interval; rg->ops->istrivial = RGIsTrivial_Interval; rg->ops->computecontour = RGComputeContour_Interval; rg->ops->checkinside = RGCheckInside_Interval; rg->ops->setfromoptions = RGSetFromOptions_Interval; rg->ops->view = RGView_Interval; rg->ops->destroy = RGDestroy_Interval; ierr = PetscObjectComposeFunction((PetscObject)rg,"RGIntervalSetEndpoints_C",RGIntervalSetEndpoints_Interval);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)rg,"RGIntervalGetEndpoints_C",RGIntervalGetEndpoints_Interval);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/sys/classes/rg/impls/interval/index.html0000644000175000017500000000161213107004621022602 0ustar jromanjroman Region - RG
slepc-3.7.4 2017-05-17

Region - RG

The RG package provides a way to define a region of the complex plane. This is used in various eigensolvers to specify where the wanted eigenvalues are located.

rginterval.c
makefile
slepc-3.7.4/src/sys/classes/rg/impls/interval/ftn-auto/0000755000175000017500000000000013107004621022342 5ustar jromanjromanslepc-3.7.4/src/sys/classes/rg/impls/interval/ftn-auto/makefile0000644000175000017500000000040213107004621024036 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = rgintervalf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/classes/rg/impls/interval/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/classes/rg/impls/interval/ftn-auto/rgintervalf.c0000644000175000017500000000311313107004621025027 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* rginterval.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcrg.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgintervalsetendpoints_ RGINTERVALSETENDPOINTS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgintervalsetendpoints_ rgintervalsetendpoints #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define rgintervalgetendpoints_ RGINTERVALGETENDPOINTS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define rgintervalgetendpoints_ rgintervalgetendpoints #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL rgintervalsetendpoints_(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d, int *__ierr ){ *__ierr = RGIntervalSetEndpoints( (RG)PetscToPointer((rg) ),*a,*b,*c,*d); } PETSC_EXTERN void PETSC_STDCALL rgintervalgetendpoints_(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d, int *__ierr ){ *__ierr = RGIntervalGetEndpoints( (RG)PetscToPointer((rg) ),a,b,c,d); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/slepcsc.c0000644000175000017500000002436413107004621015401 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcsys.h" I*/ #include #include #undef __FUNCT__ #define __FUNCT__ "SlepcSCCompare" /*@ SlepcSCCompare - Compares two (possibly complex) values according to a certain criterion. Not Collective Input Parameters: + sc - the sorting criterion context . ar - real part of the 1st value . ai - imaginary part of the 1st value . br - real part of the 2nd value - bi - imaginary part of the 2nd value Output Parameter: . res - result of comparison Notes: Returns an integer less than, equal to, or greater than zero if the first value is considered to be respectively less than, equal to, or greater than the second one. Level: developer .seealso: SlepcSortEigenvalues(), SlepcSC @*/ PetscErrorCode SlepcSCCompare(SlepcSC sc,PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res) { PetscErrorCode ierr; PetscScalar re[2],im[2]; PetscInt cin[2]; PetscBool inside[2]; PetscFunctionBegin; PetscValidIntPointer(res,6); #if defined(PETSC_USE_DEBUG) if (!sc->comparison) SETERRQ(PETSC_COMM_SELF,1,"Undefined comparison function"); #endif re[0] = ar; re[1] = br; im[0] = ai; im[1] = bi; if (sc->map) { ierr = (*sc->map)(sc->mapobj,2,re,im);CHKERRQ(ierr); } if (sc->rg) { ierr = RGCheckInside(sc->rg,2,re,im,cin);CHKERRQ(ierr); inside[0] = PetscNot(cin[0]<0); inside[1] = PetscNot(cin[1]<0); if (inside[0] && !inside[1]) *res = -1; else if (!inside[0] && inside[1]) *res = 1; else { ierr = (*sc->comparison)(re[0],im[0],re[1],im[1],res,sc->comparisonctx);CHKERRQ(ierr); } } else { ierr = (*sc->comparison)(re[0],im[0],re[1],im[1],res,sc->comparisonctx);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcSortEigenvalues" /*@ SlepcSortEigenvalues - Sorts a list of eigenvalues according to the sorting criterion specified in a SlepcSC context. Not Collective Input Parameters: + sc - the sorting criterion context . n - number of eigenvalues in the list . eigr - pointer to the array containing the eigenvalues - eigi - imaginary part of the eigenvalues (only when using real numbers) Input/Output Parameter: . perm - permutation array. Must be initialized to 0:n-1 on input. Note: The result is a list of indices in the original eigenvalue array corresponding to the first n eigenvalues sorted in the specified criterion. Level: developer .seealso: SlepcSCCompare(), SlepcSC @*/ PetscErrorCode SlepcSortEigenvalues(SlepcSC sc,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm) { PetscErrorCode ierr; PetscScalar re,im; PetscInt i,j,result,tmp; PetscFunctionBegin; PetscValidPointer(sc,1); PetscValidScalarPointer(eigr,3); PetscValidScalarPointer(eigi,4); PetscValidIntPointer(perm,5); /* insertion sort */ for (i=n-1;i>=0;i--) { re = eigr[perm[i]]; im = eigi[perm[i]]; j = i+1; #if !defined(PETSC_USE_COMPLEX) if (im!=0) { /* complex eigenvalue */ i--; im = eigi[perm[i]]; } #endif while (jb) *result = -1; else *result = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcCompareSmallestMagnitude" PetscErrorCode SlepcCompareSmallestMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx) { PetscReal a,b; PetscFunctionBegin; a = SlepcAbsEigenvalue(ar,ai); b = SlepcAbsEigenvalue(br,bi); if (a>b) *result = 1; else if (ab) *result = -1; else *result = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcCompareSmallestReal" PetscErrorCode SlepcCompareSmallestReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx) { PetscReal a,b; PetscFunctionBegin; a = PetscRealPart(ar); b = PetscRealPart(br); if (a>b) *result = 1; else if (ab) *result = -1; else *result = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "SlepcCompareSmallestImaginary" PetscErrorCode SlepcCompareSmallestImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx) { PetscReal a,b; PetscFunctionBegin; #if defined(PETSC_USE_COMPLEX) a = PetscImaginaryPart(ar); b = PetscImaginaryPart(br); #else a = PetscAbsReal(ai); b = PetscAbsReal(bi); #endif if (a>b) *result = 1; else if (ab) *result = 1; else if (ab) *result = 1; else if (ab) *result = 1; else if (a0.0) aisright = PETSC_TRUE; else aisright = PETSC_FALSE; if (PetscRealPart(br)>0.0) bisright = PETSC_TRUE; else bisright = PETSC_FALSE; if (aisright == bisright) { /* same sign */ a = SlepcAbsEigenvalue(ar,ai); b = SlepcAbsEigenvalue(br,bi); if (a>b) *result = 1; else if (a. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #include #include #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) #if defined(PETSC_USE_SINGLE_LIBRARY) PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepceps(void); PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcnep(void); PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcpep(void); PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsvd(void); PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn(void); #endif #undef __FUNCT__ #if defined(PETSC_USE_SINGLE_LIBRARY) #define __FUNCT__ "PetscDLLibraryRegister_slepc" #else #define __FUNCT__ "PetscDLLibraryRegister_slepcsys" #endif /* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the basic objects ST, FN, DS, BV, RG. */ #if defined(PETSC_USE_SINGLE_LIBRARY) PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepc(void) #else PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsys(void) #endif { PetscErrorCode ierr; PetscFunctionBegin; ierr = STInitializePackage();CHKERRQ(ierr); ierr = DSInitializePackage();CHKERRQ(ierr); ierr = FNInitializePackage();CHKERRQ(ierr); ierr = BVInitializePackage();CHKERRQ(ierr); ierr = RGInitializePackage();CHKERRQ(ierr); #if defined(PETSC_USE_SINGLE_LIBRARY) ierr = PetscDLLibraryRegister_slepceps();CHKERRQ(ierr); ierr = PetscDLLibraryRegister_slepcnep();CHKERRQ(ierr); ierr = PetscDLLibraryRegister_slepcpep();CHKERRQ(ierr); ierr = PetscDLLibraryRegister_slepcsvd();CHKERRQ(ierr); ierr = PetscDLLibraryRegister_slepcmfn();CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ slepc-3.7.4/src/sys/index.html0000644000175000017500000000263013107004621015566 0ustar jromanjroman SLEPc System Routines

slepc-3.7.4 2017-05-17

SLEPc System routines

SLEPc provides a variety of "system" level routines. These routines are generally tools used by other SLEPc routines and are not intended for application programmers (except the basic SlepcInitialize() / SlepcFinalize()).

Useful tools for application programmers can be found in PETSc's system routines, including parallel file access, synchronized printing to screen, and many other programming aids.

classes/
vec/
f90-mod/
slepcinit.c
slepcutil.c
slepcsc.c
dlregisslepc.c
makefile
slepc-3.7.4/src/sys/ftn-auto/0000755000175000017500000000000013107004621015325 5ustar jromanjromanslepc-3.7.4/src/sys/ftn-auto/makefile0000644000175000017500000000037713107004621017034 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = slepcscf.c slepcutilf.c slepcinitf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys LOCDIR = src/sys/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/ftn-auto/slepcscf.c0000644000175000017500000000304013107004621017270 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* slepcsc.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsys.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define slepcsccompare_ SLEPCSCCOMPARE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define slepcsccompare_ slepcsccompare #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define slepcsorteigenvalues_ SLEPCSORTEIGENVALUES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define slepcsorteigenvalues_ slepcsorteigenvalues #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL slepcsccompare_(SlepcSC *sc,PetscScalar *ar,PetscScalar *ai,PetscScalar *br,PetscScalar *bi,PetscInt *res, int *__ierr ){ *__ierr = SlepcSCCompare(*sc,*ar,*ai,*br,*bi,res); } PETSC_EXTERN void PETSC_STDCALL slepcsorteigenvalues_(SlepcSC *sc,PetscInt *n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm, int *__ierr ){ *__ierr = SlepcSortEigenvalues(*sc,*n,eigr,eigi,perm); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/ftn-auto/slepcutilf.c0000644000175000017500000000232313107004621017643 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* slepcutil.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsys.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define slepcmattile_ SLEPCMATTILE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define slepcmattile_ slepcmattile #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL slepcmattile_(PetscScalar *a,Mat A,PetscScalar *b,Mat B,PetscScalar *c,Mat C,PetscScalar *d,Mat D,Mat *G, int *__ierr ){ *__ierr = SlepcMatTile(*a, (Mat)PetscToPointer((A) ),*b, (Mat)PetscToPointer((B) ),*c, (Mat)PetscToPointer((C) ),*d, (Mat)PetscToPointer((D) ),G); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/ftn-auto/slepcinitf.c0000644000175000017500000000253013107004621017631 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* slepcinit.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcsys.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define slepcfinalize_ SLEPCFINALIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define slepcfinalize_ slepcfinalize #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define slepcinitialized_ SLEPCINITIALIZED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define slepcinitialized_ slepcinitialized #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL slepcfinalize_(int *__ierr ){ *__ierr = SlepcFinalize(); } PETSC_EXTERN void PETSC_STDCALL slepcinitialized_(PetscBool *isInitialized, int *__ierr ){ *__ierr = SlepcInitialized(isInitialized); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/sys/f90-mod/0000755000175000017500000000000013107004621014743 5ustar jromanjromanslepc-3.7.4/src/sys/f90-mod/slepcsysmod.F.html0000644000175000017500000001264613107004621020373 0ustar jromanjroman

Actual source code: slepcsysmod.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 20: #define PETSC_USE_FORTRAN_MODULES

 22:         module slepcsysdef
 23: #include <slepc/finclude/slepcsys.h>
 24:         end module

 26:         module slepcsys
 27:         use slepcsysdef
 28:         end module

 30:         module slepcrgdef
 31: #include <slepc/finclude/slepcrg.h>
 32: #include <slepc/finclude/ftn-custom/slepcrgdef.h90>
 33:         end module

 35:         module slepcrg
 36:         use slepcrgdef
 37: #include <slepc/finclude/slepcrg.h90>
 38:         end module

 40:         module slepcfndef
 41: #include <slepc/finclude/slepcfn.h>
 42: #include <slepc/finclude/ftn-custom/slepcfndef.h90>
 43:         end module

 45:         module slepcfn
 46:         use slepcfndef
 47: #include <slepc/finclude/slepcfn.h90>
 48:         end module

 50:         module slepcdsdef
 51:         use slepcsys
 52:         use slepcfn
 53: #include <slepc/finclude/slepcds.h>
 54: #include <slepc/finclude/ftn-custom/slepcdsdef.h90>
 55:         end module

 57:         module slepcds
 58:         use slepcdsdef
 59: #include <slepc/finclude/slepcds.h90>
 60:         end module

 62:         module slepcbvdef
 63: #include <slepc/finclude/slepcbv.h>
 64: #include <slepc/finclude/ftn-custom/slepcbvdef.h90>
 65:         end module

 67:         module slepcbv
 68:         use slepcbvdef
 69: #include <slepc/finclude/slepcbv.h90>
 70:         end module

 72:         module slepcstdef
 73:         use petscksp
 74: #include <slepc/finclude/slepcst.h>
 75: #include <slepc/finclude/ftn-custom/slepcstdef.h90>
 76:         end module

 78:         module slepcst
 79:         use slepcstdef
 80: #include <slepc/finclude/slepcst.h90>
 81:         end module

slepc-3.7.4/src/sys/f90-mod/makefile0000644000175000017500000000255113107004621016446 0ustar jromanjroman # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_USING_F90' # # Makes Fortran module functions from *.h90 files in include/slepc/finclude # ALL: buildmod_slepc speciallib: buildmod_slepc specialfastlib: buildmod_slepc SPECIALLIB = yes SPECIALFASTLIB = yes CFLAGS = FFLAGS = SOURCEC = SOURCEF = slepcsysmod.F SOURCEH = LIBBASE = libslepcsys MANSEC = sys LOCDIR = src/sys/f90-mod/ CLEANFILES = *.mod include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/f90-mod/slepcsysmod.F0000644000175000017500000000450113107004621017417 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define PETSC_USE_FORTRAN_MODULES module slepcsysdef #include end module module slepcsys use slepcsysdef end module module slepcrgdef #include #include end module module slepcrg use slepcrgdef #include end module module slepcfndef #include #include end module module slepcfn use slepcfndef #include end module module slepcdsdef use slepcsys use slepcfn #include #include end module module slepcds use slepcdsdef #include end module module slepcbvdef #include #include end module module slepcbv use slepcbvdef #include end module module slepcstdef use petscksp #include #include end module module slepcst use slepcstdef #include end module slepc-3.7.4/src/sys/f90-mod/makefile.html0000644000175000017500000000543713107004621017417 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#requiresdefine   'PETSC_USING_F90'
#
#   Makes Fortran module functions from *.h90 files in include/slepc/finclude
#
ALL: buildmod_slepc
speciallib: buildmod_slepc
specialfastlib: buildmod_slepc
SPECIALLIB     = yes
SPECIALFASTLIB = yes


CFLAGS     =
FFLAGS     =
SOURCEC    =
SOURCEF    = slepcsysmod.F
SOURCEH    =
LIBBASE    = libslepcsys
MANSEC     = sys
LOCDIR     = src/sys/f90-mod/
CLEANFILES = *.mod

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/sys/f90-mod/index.html0000644000175000017500000000227113107004621016742 0ustar jromanjroman SLEPc System Routines
slepc-3.7.4 2017-05-17

SLEPc System routines

SLEPc provides a variety of "system" level routines. These routines are generally tools used by other SLEPc routines and are not intended for application programmers (except the basic SlepcInitialize() / SlepcFinalize()).

Useful tools for application programmers can be found in PETSc's system routines, including parallel file access, synchronized printing to screen, and many other programming aids.

slepcsysmod.F
makefile
slepc-3.7.4/src/sys/dlregisslepc.c.html0000644000175000017500000001524413107004621017365 0ustar jromanjroman

Actual source code: dlregisslepc.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepcst.h>
 23: #include <slepcds.h>
 24: #include <slepcfn.h>
 25: #include <slepcbv.h>
 26: #include <slepcrg.h>

 28: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

 30: #if defined(PETSC_USE_SINGLE_LIBRARY)
 31: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepceps(void);
 32: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcnep(void);
 33: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcpep(void);
 34: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsvd(void);
 35: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn(void);
 36: #endif

 39: #if defined(PETSC_USE_SINGLE_LIBRARY)
 41: #else
 43: #endif
 44: /*
 45:   PetscDLLibraryRegister - This function is called when the dynamic library
 46:   it is in is opened.

 48:   This one registers all the basic objects ST, FN, DS, BV, RG.
 49:  */
 50: #if defined(PETSC_USE_SINGLE_LIBRARY)
 51: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepc(void)
 52: #else
 53: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsys(void)
 54: #endif
 55: {

 59:   STInitializePackage();
 60:   DSInitializePackage();
 61:   FNInitializePackage();
 62:   BVInitializePackage();
 63:   RGInitializePackage();

 65: #if defined(PETSC_USE_SINGLE_LIBRARY)
 66:   PetscDLLibraryRegister_slepceps();
 67:   PetscDLLibraryRegister_slepcnep();
 68:   PetscDLLibraryRegister_slepcpep();
 69:   PetscDLLibraryRegister_slepcsvd();
 70:   PetscDLLibraryRegister_slepcmfn();
 71: #endif
 72:   return(0);
 73: }
 74: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */

slepc-3.7.4/src/sys/ftn-custom/0000755000175000017500000000000013107004621015667 5ustar jromanjromanslepc-3.7.4/src/sys/ftn-custom/zslepcutil.c0000644000175000017500000000327713107004621020242 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define slepcconvmonitorcreate_ SLEPCCONVMONITORCREATE #define slepcconvmonitordestroy_ SLEPCCONVMONITORDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define slepcconvmonitorcreate_ slepcconvmonitorcreate #define slepcconvmonitordestroy_ slepcconvmonitordestroy #endif PETSC_EXTERN void PETSC_STDCALL slepcconvmonitorcreate_(PetscViewer *vin,PetscViewerFormat *format,SlepcConvMonitor *ctx,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(vin,v); *ierr = SlepcConvMonitorCreate(v,*format,ctx); } PETSC_EXTERN void slepcconvmonitordestroy_(SlepcConvMonitor *ctx,PetscErrorCode *ierr) { *ierr = SlepcConvMonitorDestroy(ctx); } slepc-3.7.4/src/sys/ftn-custom/makefile0000644000175000017500000000226213107004621017371 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zslepcutil.c zslepc_start.c zslepc_startf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcsys MANSEC = sys LOCDIR = src/sys/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/sys/ftn-custom/zslepc_start.c0000644000175000017500000000551413107004621020555 0ustar jromanjroman/* This file contains the Fortran version of SlepcInitialize(). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define petscinitialize_ PETSCINITIALIZE #define slepcinitialize_ SLEPCINITIALIZE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define petscinitialize_ petscinitialize #define slepcinitialize_ slepcinitialize #endif PETSC_EXTERN void PETSC_STDCALL petscinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)); /* SlepcInitialize - Version called from Fortran. Notes: Since this routine is called from Fortran it does not return error codes. */ PETSC_EXTERN void PETSC_STDCALL slepcinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { PetscBool flg; *ierr = 1; if (SlepcInitializeCalled) { *ierr = 0; return; } *ierr = PetscInitialized(&flg); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:PetscInitialized failed");return; } if (!flg) { #if defined(PETSC_HAVE_FORTRAN_MIXED_STR_ARG) petscinitialize_(filename,len,ierr); #else petscinitialize_(filename,ierr,len); #endif if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:PetscInitialize failed");return; } SlepcBeganPetsc = PETSC_TRUE; } *ierr = SlepcCitationsInitialize(); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:SlepcCitationsInitialize()\n");return; } #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) *ierr = SlepcInitialize_DynamicLibraries(); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Initializing dynamic libraries\n");return; } #endif #if defined(PETSC_HAVE_DRAND48) /* work-around for Cygwin drand48() initialization bug */ srand48(0); #endif SlepcInitializeCalled = PETSC_TRUE; *ierr = PetscInfo(0,"SLEPc successfully started from Fortran\n"); if (*ierr) { (*PetscErrorPrintf)("SlepcInitialize:Calling PetscInfo()");return; } } slepc-3.7.4/src/sys/ftn-custom/zslepc_startf.c0000644000175000017500000000374013107004621020722 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define slepcinitializefortran_ SLEPCINITIALIZEFORTRAN #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define slepcinitializefortran_ slepcinitializefortran #endif /*@C SlepcInitializeFortran - Routine that should be called from C after the call to SlepcInitialize() if one is using a C main program that calls Fortran routines that in turn call SLEPc routines. Collective on PETSC_COMM_WORLD Level: beginner Notes: SlepcInitializeFortran() initializes some of the default SLEPc variables for use in Fortran if a user's main program is written in C. SlepcInitializeFortran() is NOT needed if a user's main program is written in Fortran; in this case, just calling SlepcInitialize() in the main (Fortran) program is sufficient. .seealso: SlepcInitialize() @*/ PetscErrorCode SlepcInitializeFortran(void) { PetscInitializeFortran(); return 0; } PETSC_EXTERN void PETSC_STDCALL slepcinitializefortran_(PetscErrorCode *info) { *info = SlepcInitializeFortran(); } slepc-3.7.4/src/sys/slepcutil.c.html0000644000175000017500000013370513107004621016714 0ustar jromanjroman
Actual source code: slepcutil.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/slepcimpl.h>            /*I "slepcsys.h" I*/

 26: /*@C
 27:    SlepcVecNormalize - Normalizes a possibly complex vector by the 2-norm.

 29:    Collective on Vec

 31:    Input parameters:
 32: +  xr - the real part of the vector (overwritten on output)
 33: .  xi - the imaginary part of the vector (not referenced if iscomplex is false)
 34: -  iscomplex - a flag indicating if the vector is complex

 36:    Output parameter:
 37: .  norm - the vector norm before normalization (can be set to NULL)

 39:    Level: developer
 40: @*/
 41: PetscErrorCode SlepcVecNormalize(Vec xr,Vec xi,PetscBool iscomplex,PetscReal *norm)
 42: {
 44: #if !defined(PETSC_USE_COMPLEX)
 45:   PetscReal      normr,normi,alpha;
 46: #endif

 50: #if !defined(PETSC_USE_COMPLEX)
 51:   if (iscomplex) {
 53:     VecNormBegin(xr,NORM_2,&normr);
 54:     VecNormBegin(xi,NORM_2,&normi);
 55:     VecNormEnd(xr,NORM_2,&normr);
 56:     VecNormEnd(xi,NORM_2,&normi);
 57:     alpha = SlepcAbsEigenvalue(normr,normi);
 58:     if (norm) *norm = alpha;
 59:     alpha = 1.0 / alpha;
 60:     VecScale(xr,alpha);
 61:     VecScale(xi,alpha);
 62:   } else
 63: #endif
 64:   {
 65:     VecNormalize(xr,norm);
 66:   }
 67:   return(0);
 68: }

 72: /*@C
 73:    SlepcMatConvertSeqDense - Converts a parallel matrix to another one in sequential
 74:    dense format replicating the values in every processor.

 76:    Collective on Mat

 78:    Input parameters:
 79: +  A  - the source matrix
 80: -  B  - the target matrix

 82:    Level: developer
 83: @*/
 84: PetscErrorCode SlepcMatConvertSeqDense(Mat mat,Mat *newmat)
 85: {
 87:   PetscInt       m,n;
 88:   PetscMPIInt    size;
 89:   PetscBool      flg;
 90:   Mat            *M;
 91:   IS             isrow,iscol;

 96:   MPI_Comm_size(PetscObjectComm((PetscObject)mat),&size);
 97:   if (size > 1) {
 98:     MatHasOperation(mat,MATOP_GET_SUBMATRICES,&flg);
 99:     if (!flg) SETERRQ1(PetscObjectComm((PetscObject)mat),PETSC_ERR_SUP,"Mat type %s",((PetscObject)mat)->type_name);

101:     /* assemble full matrix on every processor */
102:     MatGetSize(mat,&m,&n);
103:     ISCreateStride(PETSC_COMM_SELF,m,0,1,&isrow);
104:     ISCreateStride(PETSC_COMM_SELF,n,0,1,&iscol);
105:     MatGetSubMatrices(mat,1,&isrow,&iscol,MAT_INITIAL_MATRIX,&M);
106:     ISDestroy(&isrow);
107:     ISDestroy(&iscol);

109:     /* Fake support for "inplace" convert */
110:     if (*newmat == mat) {
111:       MatDestroy(&mat);
112:     }

114:     /* convert matrix to MatSeqDense */
115:     MatConvert(*M,MATSEQDENSE,MAT_INITIAL_MATRIX,newmat);
116:     MatDestroyMatrices(1,&M);
117:   } else {
118:     /* convert matrix to MatSeqDense */
119:     MatConvert(mat,MATSEQDENSE,MAT_INITIAL_MATRIX,newmat);
120:   }
121:   return(0);
122: }

126: static PetscErrorCode SlepcMatTile_SeqAIJ(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat G)
127: {
128:   PetscErrorCode    ierr;
129:   PetscInt          i,j,M1,M2,N1,N2,*nnz,ncols,*scols;
130:   PetscScalar       *svals,*buf;
131:   const PetscInt    *cols;
132:   const PetscScalar *vals;

135:   MatGetSize(A,&M1,&N1);
136:   MatGetSize(D,&M2,&N2);

138:   PetscCalloc1(M1+M2,&nnz);
139:   /* Preallocate for A */
140:   if (a!=0.0) {
141:     for (i=0;i<M1;i++) {
142:       MatGetRow(A,i,&ncols,NULL,NULL);
143:       nnz[i] += ncols;
144:       MatRestoreRow(A,i,&ncols,NULL,NULL);
145:     }
146:   }
147:   /* Preallocate for B */
148:   if (b!=0.0) {
149:     for (i=0;i<M1;i++) {
150:       MatGetRow(B,i,&ncols,NULL,NULL);
151:       nnz[i] += ncols;
152:       MatRestoreRow(B,i,&ncols,NULL,NULL);
153:     }
154:   }
155:   /* Preallocate for C */
156:   if (c!=0.0) {
157:     for (i=0;i<M2;i++) {
158:       MatGetRow(C,i,&ncols,NULL,NULL);
159:       nnz[i+M1] += ncols;
160:       MatRestoreRow(C,i,&ncols,NULL,NULL);
161:     }
162:   }
163:   /* Preallocate for D */
164:   if (d!=0.0) {
165:     for (i=0;i<M2;i++) {
166:       MatGetRow(D,i,&ncols,NULL,NULL);
167:       nnz[i+M1] += ncols;
168:       MatRestoreRow(D,i,&ncols,NULL,NULL);
169:     }
170:   }
171:   MatSeqAIJSetPreallocation(G,0,nnz);
172:   PetscFree(nnz);

174:   PetscMalloc2(PetscMax(N1,N2),&buf,PetscMax(N1,N2),&scols);
175:   /* Transfer A */
176:   if (a!=0.0) {
177:     for (i=0;i<M1;i++) {
178:       MatGetRow(A,i,&ncols,&cols,&vals);
179:       if (a!=1.0) {
180:         svals=buf;
181:         for (j=0;j<ncols;j++) svals[j] = vals[j]*a;
182:       } else svals=(PetscScalar*)vals;
183:       MatSetValues(G,1,&i,ncols,cols,svals,INSERT_VALUES);
184:       MatRestoreRow(A,i,&ncols,&cols,&vals);
185:     }
186:   }
187:   /* Transfer B */
188:   if (b!=0.0) {
189:     for (i=0;i<M1;i++) {
190:       MatGetRow(B,i,&ncols,&cols,&vals);
191:       if (b!=1.0) {
192:         svals=buf;
193:         for (j=0;j<ncols;j++) svals[j] = vals[j]*b;
194:       } else svals=(PetscScalar*)vals;
195:       for (j=0;j<ncols;j++) scols[j] = cols[j]+N1;
196:       MatSetValues(G,1,&i,ncols,scols,svals,INSERT_VALUES);
197:       MatRestoreRow(B,i,&ncols,&cols,&vals);
198:     }
199:   }
200:   /* Transfer C */
201:   if (c!=0.0) {
202:     for (i=0;i<M2;i++) {
203:       MatGetRow(C,i,&ncols,&cols,&vals);
204:       if (c!=1.0) {
205:         svals=buf;
206:         for (j=0;j<ncols;j++) svals[j] = vals[j]*c;
207:       } else svals=(PetscScalar*)vals;
208:       j = i+M1;
209:       MatSetValues(G,1,&j,ncols,cols,svals,INSERT_VALUES);
210:       MatRestoreRow(C,i,&ncols,&cols,&vals);
211:     }
212:   }
213:   /* Transfer D */
214:   if (d!=0.0) {
215:     for (i=0;i<M2;i++) {
216:       MatGetRow(D,i,&ncols,&cols,&vals);
217:       if (d!=1.0) {
218:         svals=buf;
219:         for (j=0;j<ncols;j++) svals[j] = vals[j]*d;
220:       } else svals=(PetscScalar*)vals;
221:       for (j=0;j<ncols;j++) scols[j] = cols[j]+N1;
222:       j = i+M1;
223:       MatSetValues(G,1,&j,ncols,scols,svals,INSERT_VALUES);
224:       MatRestoreRow(D,i,&ncols,&cols,&vals);
225:     }
226:   }
227:   PetscFree2(buf,scols);
228:   return(0);
229: }

233: static PetscErrorCode SlepcMatTile_MPIAIJ(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat G)
234: {
236:   PetscMPIInt       np;
237:   PetscInt          p,i,j,N1,N2,m1,m2,n1,n2,*map1,*map2;
238:   PetscInt          *dnz,*onz,ncols,*scols,start,gstart;
239:   PetscScalar       *svals,*buf;
240:   const PetscInt    *cols,*mapptr1,*mapptr2;
241:   const PetscScalar *vals;

244:   MatGetSize(A,NULL,&N1);
245:   MatGetLocalSize(A,&m1,&n1);
246:   MatGetSize(D,NULL,&N2);
247:   MatGetLocalSize(D,&m2,&n2);

249:   /* Create mappings */
250:   MPI_Comm_size(PetscObjectComm((PetscObject)G),&np);
251:   MatGetOwnershipRangesColumn(A,&mapptr1);
252:   MatGetOwnershipRangesColumn(B,&mapptr2);
253:   PetscMalloc4(PetscMax(N1,N2),&buf,PetscMax(N1,N2),&scols,N1,&map1,N2,&map2);
254:   for (p=0;p<np;p++) {
255:     for (i=mapptr1[p];i<mapptr1[p+1];i++) map1[i] = i+mapptr2[p];
256:   }
257:   for (p=0;p<np;p++) {
258:     for (i=mapptr2[p];i<mapptr2[p+1];i++) map2[i] = i+mapptr1[p+1];
259:   }

261:   MatPreallocateInitialize(PetscObjectComm((PetscObject)G),m1+m2,n1+n2,dnz,onz);
262:   MatGetOwnershipRange(G,&gstart,NULL);
263:   /* Preallocate for A */
264:   if (a!=0.0) {
265:     MatGetOwnershipRange(A,&start,NULL);
266:     for (i=0;i<m1;i++) {
267:       MatGetRow(A,i+start,&ncols,&cols,NULL);
268:       for (j=0;j<ncols;j++) scols[j] = map1[cols[j]];
269:       MatPreallocateSet(gstart+i,ncols,scols,dnz,onz);
270:       MatRestoreRow(A,i+start,&ncols,&cols,NULL);
271:     }
272:   }
273:   /* Preallocate for B */
274:   if (b!=0.0) {
275:     MatGetOwnershipRange(B,&start,NULL);
276:     for (i=0;i<m1;i++) {
277:       MatGetRow(B,i+start,&ncols,&cols,NULL);
278:       for (j=0;j<ncols;j++) scols[j] = map2[cols[j]];
279:       MatPreallocateSet(gstart+i,ncols,scols,dnz,onz);
280:       MatRestoreRow(B,i+start,&ncols,&cols,NULL);
281:     }
282:   }
283:   /* Preallocate for C */
284:   if (c!=0.0) {
285:     MatGetOwnershipRange(C,&start,NULL);
286:     for (i=0;i<m2;i++) {
287:       MatGetRow(C,i+start,&ncols,&cols,NULL);
288:       for (j=0;j<ncols;j++) scols[j] = map1[cols[j]];
289:       MatPreallocateSet(gstart+m1+i,ncols,scols,dnz,onz);
290:       MatRestoreRow(C,i+start,&ncols,&cols,NULL);
291:     }
292:   }
293:   /* Preallocate for D */
294:   if (d!=0.0) {
295:     MatGetOwnershipRange(D,&start,NULL);
296:     for (i=0;i<m2;i++) {
297:       MatGetRow(D,i+start,&ncols,&cols,NULL);
298:       for (j=0;j<ncols;j++) scols[j] = map2[cols[j]];
299:       MatPreallocateSet(gstart+m1+i,ncols,scols,dnz,onz);
300:       MatRestoreRow(D,i+start,&ncols,&cols,NULL);
301:     }
302:   }
303:   MatMPIAIJSetPreallocation(G,0,dnz,0,onz);
304:   MatPreallocateFinalize(dnz,onz);

306:   /* Transfer A */
307:   if (a!=0.0) {
308:     MatGetOwnershipRange(A,&start,NULL);
309:     for (i=0;i<m1;i++) {
310:       MatGetRow(A,i+start,&ncols,&cols,&vals);
311:       if (a!=1.0) {
312:         svals=buf;
313:         for (j=0;j<ncols;j++) svals[j] = vals[j]*a;
314:       } else svals=(PetscScalar*)vals;
315:       for (j=0;j<ncols;j++) scols[j] = map1[cols[j]];
316:       j = gstart+i;
317:       MatSetValues(G,1,&j,ncols,scols,svals,INSERT_VALUES);
318:       MatRestoreRow(A,i+start,&ncols,&cols,&vals);
319:     }
320:   }
321:   /* Transfer B */
322:   if (b!=0.0) {
323:     MatGetOwnershipRange(B,&start,NULL);
324:     for (i=0;i<m1;i++) {
325:       MatGetRow(B,i+start,&ncols,&cols,&vals);
326:       if (b!=1.0) {
327:         svals=buf;
328:         for (j=0;j<ncols;j++) svals[j] = vals[j]*b;
329:       } else svals=(PetscScalar*)vals;
330:       for (j=0;j<ncols;j++) scols[j] = map2[cols[j]];
331:       j = gstart+i;
332:       MatSetValues(G,1,&j,ncols,scols,svals,INSERT_VALUES);
333:       MatRestoreRow(B,i+start,&ncols,&cols,&vals);
334:     }
335:   }
336:   /* Transfer C */
337:   if (c!=0.0) {
338:     MatGetOwnershipRange(C,&start,NULL);
339:     for (i=0;i<m2;i++) {
340:       MatGetRow(C,i+start,&ncols,&cols,&vals);
341:       if (c!=1.0) {
342:         svals=buf;
343:         for (j=0;j<ncols;j++) svals[j] = vals[j]*c;
344:       } else svals=(PetscScalar*)vals;
345:       for (j=0;j<ncols;j++) scols[j] = map1[cols[j]];
346:       j = gstart+m1+i;
347:       MatSetValues(G,1,&j,ncols,scols,svals,INSERT_VALUES);
348:       MatRestoreRow(C,i+start,&ncols,&cols,&vals);
349:     }
350:   }
351:   /* Transfer D */
352:   if (d!=0.0) {
353:     MatGetOwnershipRange(D,&start,NULL);
354:     for (i=0;i<m2;i++) {
355:       MatGetRow(D,i+start,&ncols,&cols,&vals);
356:       if (d!=1.0) {
357:         svals=buf;
358:         for (j=0;j<ncols;j++) svals[j] = vals[j]*d;
359:       } else svals=(PetscScalar*)vals;
360:       for (j=0;j<ncols;j++) scols[j] = map2[cols[j]];
361:       j = gstart+m1+i;
362:       MatSetValues(G,1,&j,ncols,scols,svals,INSERT_VALUES);
363:       MatRestoreRow(D,i+start,&ncols,&cols,&vals);
364:     }
365:   }
366:   PetscFree4(buf,scols,map1,map2);
367:   return(0);
368: }

372: /*@
373:    SlepcMatTile - Explicitly build a matrix from four blocks, G = [ a*A b*B; c*C d*D ].

375:    Collective on Mat

377:    Input parameters:
378: +  A - matrix for top-left block
379: .  a - scaling factor for block A
380: .  B - matrix for top-right block
381: .  b - scaling factor for block B
382: .  C - matrix for bottom-left block
383: .  c - scaling factor for block C
384: .  D - matrix for bottom-right block
385: -  d - scaling factor for block D

387:    Output parameter:
388: .  G  - the resulting matrix

390:    Notes:
391:    In the case of a parallel matrix, a permuted version of G is returned. The permutation
392:    is a perfect shuffle such that the local parts of A, B, C, D remain in the local part of
393:    G for the same process.

395:    Matrix G must be destroyed by the user.

397:    Level: developer
398: @*/
399: PetscErrorCode SlepcMatTile(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat *G)
400: {
402:   PetscInt       M1,M2,N1,N2,M,N,m1,m2,n1,n2,m,n;
403:   PetscBool      flg1,flg2;


415:   /* check row 1 */
416:   MatGetSize(A,&M1,NULL);
417:   MatGetLocalSize(A,&m1,NULL);
418:   MatGetSize(B,&M,NULL);
419:   MatGetLocalSize(B,&m,NULL);
420:   if (M!=M1 || m!=m1) SETERRQ(PetscObjectComm((PetscObject)A),PETSC_ERR_ARG_INCOMP,"Incompatible dimensions");
421:   /* check row 2 */
422:   MatGetSize(C,&M2,NULL);
423:   MatGetLocalSize(C,&m2,NULL);
424:   MatGetSize(D,&M,NULL);
425:   MatGetLocalSize(D,&m,NULL);
426:   if (M!=M2 || m!=m2) SETERRQ(PetscObjectComm((PetscObject)A),PETSC_ERR_ARG_INCOMP,"Incompatible dimensions");
427:   /* check column 1 */
428:   MatGetSize(A,NULL,&N1);
429:   MatGetLocalSize(A,NULL,&n1);
430:   MatGetSize(C,NULL,&N);
431:   MatGetLocalSize(C,NULL,&n);
432:   if (N!=N1 || n!=n1) SETERRQ(PetscObjectComm((PetscObject)A),PETSC_ERR_ARG_INCOMP,"Incompatible dimensions");
433:   /* check column 2 */
434:   MatGetSize(B,NULL,&N2);
435:   MatGetLocalSize(B,NULL,&n2);
436:   MatGetSize(D,NULL,&N);
437:   MatGetLocalSize(D,NULL,&n);
438:   if (N!=N2 || n!=n2) SETERRQ(PetscObjectComm((PetscObject)A),PETSC_ERR_ARG_INCOMP,"Incompatible dimensions");

440:   MatCreate(PetscObjectComm((PetscObject)A),G);
441:   MatSetSizes(*G,m1+m2,n1+n2,M1+M2,N1+N2);
442:   MatSetFromOptions(*G);
443:   MatSetUp(*G);

445:   PetscObjectTypeCompare((PetscObject)*G,MATMPIAIJ,&flg1);
446:   PetscObjectTypeCompare((PetscObject)A,MATMPIAIJ,&flg2);
447:   if (flg1 && flg2) {
448:     SlepcMatTile_MPIAIJ(a,A,b,B,c,C,d,D,*G);
449:   } else {
450:     PetscObjectTypeCompare((PetscObject)*G,MATSEQAIJ,&flg1);
451:     PetscObjectTypeCompare((PetscObject)A,MATSEQAIJ,&flg2);
452:     if (flg1 && flg2) {
453:       SlepcMatTile_SeqAIJ(a,A,b,B,c,C,d,D,*G);
454:     } else SETERRQ(PetscObjectComm((PetscObject)A),PETSC_ERR_SUP,"Not implemented for this matrix type");
455:   }
456:   MatAssemblyBegin(*G,MAT_FINAL_ASSEMBLY);
457:   MatAssemblyEnd(*G,MAT_FINAL_ASSEMBLY);
458:   return(0);
459: }

463: /*@C
464:    SlepcCheckOrthogonality - Checks (or prints) the level of orthogonality
465:    of a set of vectors.

467:    Collective on Vec

469:    Input parameters:
470: +  V  - a set of vectors
471: .  nv - number of V vectors
472: .  W  - an alternative set of vectors (optional)
473: .  nw - number of W vectors
474: .  B  - matrix defining the inner product (optional)
475: -  viewer - optional visualization context

477:    Output parameter:
478: .  lev - level of orthogonality (optional)

480:    Notes:
481:    This function computes W'*V and prints the result. It is intended to check
482:    the level of bi-orthogonality of the vectors in the two sets. If W is equal
483:    to NULL then V is used, thus checking the orthogonality of the V vectors.

485:    If matrix B is provided then the check uses the B-inner product, W'*B*V.

487:    If lev is not NULL, it will contain the maximum entry of matrix
488:    W'*V - I (in absolute value). Otherwise, the matrix W'*V is printed.

490:    Level: developer
491: @*/
492: PetscErrorCode SlepcCheckOrthogonality(Vec *V,PetscInt nv,Vec *W,PetscInt nw,Mat B,PetscViewer viewer,PetscReal *lev)
493: {
495:   PetscInt       i,j;
496:   PetscScalar    *vals;
497:   PetscBool      isascii;
498:   Vec            w;

501:   if (nv<=0 || nw<=0) return(0);
504:   if (!lev) {
505:     if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)*V));
508:     PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
509:     if (!isascii) return(0);
510:   }

512:   PetscMalloc1(nv,&vals);
513:   if (B) {
514:     VecDuplicate(V[0],&w);
515:   }
516:   if (lev) *lev = 0.0;
517:   for (i=0;i<nw;i++) {
518:     if (B) {
519:       if (W) {
520:         MatMultTranspose(B,W[i],w);
521:       } else {
522:         MatMultTranspose(B,V[i],w);
523:       }
524:     } else {
525:       if (W) w = W[i];
526:       else w = V[i];
527:     }
528:     VecMDot(w,nv,V,vals);
529:     for (j=0;j<nv;j++) {
530:       if (lev) *lev = PetscMax(*lev,PetscAbsScalar((j==i)? (vals[j]-1.0): vals[j]));
531:       else {
532: #if !defined(PETSC_USE_COMPLEX)
533:         PetscViewerASCIIPrintf(viewer," %12g  ",(double)vals[j]);
534: #else
535:         PetscViewerASCIIPrintf(viewer," %12g%+12gi ",(double)PetscRealPart(vals[j]),(double)PetscImaginaryPart(vals[j]));
536: #endif
537:       }
538:     }
539:     if (!lev) { PetscViewerASCIIPrintf(viewer,"\n"); }
540:   }
541:   PetscFree(vals);
542:   if (B) {
543:     VecDestroy(&w);
544:   }
545:   return(0);
546: }

550: /*@C
551:    SlepcConvMonitorCreate - Creates a SlepcConvMonitor context.

553:    Collective on PetscViewer

555:    Input Parameters:
556: +  viewer - the viewer where the monitor must send data
557: -  format - the format 

559:    Output Parameter:
560: .  ctx - the created context

562:    Notes:
563:    The created context is used for EPS, SVD, PEP, and NEP monitor functions that just
564:    print the iteration numbers at which convergence takes place (XXXMonitorConverged).

566:    This function increases the reference count of the viewer so you can destroy the
567:    viewer object after this call.

569:    Level: developer

571: .seealso: SlepcConvMonitorDestroy()
572: @*/
573: PetscErrorCode SlepcConvMonitorCreate(PetscViewer viewer,PetscViewerFormat format,SlepcConvMonitor *ctx)
574: {

578:   PetscObjectReference((PetscObject)viewer);
579:   PetscNew(ctx);
580:   (*ctx)->viewer = viewer;
581:   (*ctx)->format = format;
582:   return(0);
583: }

587: /*@C
588:    SlepcConvMonitorDestroy - Destroys a SlepcConvMonitor context.

590:    Collective on PetscViewer

592:    Input Parameters:
593: .  ctx - the SlepcConvMonitor context to be destroyed.

595:    Level: developer

597: .seealso: SlepcConvMonitorCreate()
598: @*/
599: PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor *ctx)
600: {

604:   if (!*ctx) return(0);
605:   PetscViewerDestroy(&(*ctx)->viewer);
606:   PetscFree(*ctx);
607:   return(0);
608: }

612: /*
613:    Given n vectors in V, this function gets references of them into W.
614:    If m<0 then some previous non-processed vectors remain in W and must be freed.
615:  */
616: PetscErrorCode SlepcBasisReference_Private(PetscInt n,Vec *V,PetscInt *m,Vec **W)
617: {
619:   PetscInt       i;

622:   SlepcBasisDestroy_Private(m,W);
623:   if (n>0) {
624:     PetscMalloc1(n,W);
625:     for (i=0;i<n;i++) {
626:       PetscObjectReference((PetscObject)V[i]);
627:       (*W)[i] = V[i];
628:     }
629:     *m = -n;
630:   }
631:   return(0);
632: }

636: /*
637:    Destroys a set of vectors.
638:    A negative value of m indicates that W contains vectors to be destroyed.
639:  */
640: PetscErrorCode SlepcBasisDestroy_Private(PetscInt *m,Vec **W)
641: {
643:   PetscInt       i;

646:   if (*m<0) {
647:     for (i=0;i<-(*m);i++) {
648:       VecDestroy(&(*W)[i]);
649:     }
650:     PetscFree(*W);
651:   }
652:   *m = 0;
653:   return(0);
654: }

658: /*@C
659:    SlepcSNPrintfScalar - Prints a PetscScalar variable to a string of
660:    given length.

662:    Not Collective

664:    Input Parameters:
665: +  str - the string to print to
666: .  len - the length of str
667: .  val - scalar value to be printed
668: -  exp - to be used within an expression, print leading sign and parentheses
669:          in case of nonzero imaginary part

671:    Level: developer
672: @*/
673: PetscErrorCode SlepcSNPrintfScalar(char *str,size_t len,PetscScalar val,PetscBool exp)
674: {
676: #if defined(PETSC_USE_COMPLEX)
677:   PetscReal      re,im;
678: #endif

681: #if !defined(PETSC_USE_COMPLEX)
682:   if (exp) {
683:     PetscSNPrintf(str,len,"%+g",(double)val);
684:   } else {
685:     PetscSNPrintf(str,len,"%g",(double)val);
686:   }
687: #else
688:   re = PetscRealPart(val);
689:   im = PetscImaginaryPart(val);
690:   if (im!=0.0) {
691:     if (exp) {
692:       PetscSNPrintf(str,len,"+(%g%+gi)",(double)re,(double)im);
693:     } else {
694:       PetscSNPrintf(str,len,"%g%+gi",(double)re,(double)im);
695:     }
696:   } else {
697:     if (exp) {
698:       PetscSNPrintf(str,len,"%+g",(double)re);
699:     } else {
700:       PetscSNPrintf(str,len,"%g",(double)re);
701:     }
702:   }
703: #endif
704:   return(0);
705: }

slepc-3.7.4/src/pep/0000755000175000017500000000000013107004621013536 5ustar jromanjromanslepc-3.7.4/src/pep/makefile0000644000175000017500000000216513107004621015242 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib SOURCEH = ../../include/slepc/private/pepimpl.h ../../include/slepcpep.h DIRS = interface impls examples f90-mod LOCDIR = src/pep/ MANSEC = PEP include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/interface/0000755000175000017500000000000013107004621015476 5ustar jromanjromanslepc-3.7.4/src/pep/interface/makefile0000644000175000017500000000232113107004621017174 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = pepmon.c pepbasic.c pepview.c pepdefault.c pepregis.c pepopts.c pepsetup.c pepsolve.c peprefine.c dlregispep.c SOURCEF = SOURCEH = LIBBASE = libslepcpep DIRS = MANSEC = PEP LOCDIR = src/pep/interface/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/interface/pepbasic.c0000644000175000017500000004567213107004621017446 0ustar jromanjroman/* The basic PEP routines, Create, Destroy, etc. are here. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ PetscFunctionList PEPList = 0; PetscBool PEPRegisterAllCalled = PETSC_FALSE; PetscClassId PEP_CLASSID = 0; PetscLogEvent PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0; #undef __FUNCT__ #define __FUNCT__ "PEPCreate" /*@ PEPCreate - Creates the default PEP context. Collective on MPI_Comm Input Parameter: . comm - MPI communicator Output Parameter: . pep - location to put the PEP context Note: The default PEP type is PEPTOAR Level: beginner .seealso: PEPSetUp(), PEPSolve(), PEPDestroy(), PEP @*/ PetscErrorCode PEPCreate(MPI_Comm comm,PEP *outpep) { PetscErrorCode ierr; PEP pep; PetscFunctionBegin; PetscValidPointer(outpep,2); *outpep = 0; ierr = PEPInitializePackage();CHKERRQ(ierr); ierr = SlepcHeaderCreate(pep,PEP_CLASSID,"PEP","Polynomial Eigenvalue Problem","PEP",comm,PEPDestroy,PEPView);CHKERRQ(ierr); pep->max_it = 0; pep->nev = 1; pep->ncv = 0; pep->mpd = 0; pep->nini = 0; pep->target = 0.0; pep->tol = PETSC_DEFAULT; pep->conv = PEP_CONV_REL; pep->stop = PEP_STOP_BASIC; pep->which = (PEPWhich)0; pep->basis = PEP_BASIS_MONOMIAL; pep->problem_type = (PEPProblemType)0; pep->scale = PEP_SCALE_NONE; pep->sfactor = 1.0; pep->dsfactor = 1.0; pep->sits = 5; pep->slambda = 1.0; pep->refine = PEP_REFINE_NONE; pep->npart = 1; pep->rtol = PETSC_DEFAULT; pep->rits = PETSC_DEFAULT; pep->scheme = (PEPRefineScheme)0; pep->extract = (PEPExtract)0; pep->trackall = PETSC_FALSE; pep->converged = PEPConvergedRelative; pep->convergeddestroy= NULL; pep->stopping = PEPStoppingBasic; pep->stoppingdestroy = NULL; pep->convergedctx = NULL; pep->stoppingctx = NULL; pep->numbermonitors = 0; pep->st = NULL; pep->ds = NULL; pep->V = NULL; pep->rg = NULL; pep->A = NULL; pep->nmat = 0; pep->Dl = NULL; pep->Dr = NULL; pep->IS = NULL; pep->eigr = NULL; pep->eigi = NULL; pep->errest = NULL; pep->perm = NULL; pep->pbc = NULL; pep->solvematcoeffs = NULL; pep->nwork = 0; pep->work = NULL; pep->refineksp = NULL; pep->refinesubc = NULL; pep->data = NULL; pep->state = PEP_STATE_INITIAL; pep->nconv = 0; pep->its = 0; pep->n = 0; pep->nloc = 0; pep->nrma = NULL; pep->sfactor_set = PETSC_FALSE; pep->lineariz = PETSC_FALSE; pep->reason = PEP_CONVERGED_ITERATING; ierr = PetscNewLog(pep,&pep->sc);CHKERRQ(ierr); *outpep = pep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetType" /*@C PEPSetType - Selects the particular solver to be used in the PEP object. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context - type - a known method Options Database Key: . -pep_type - Sets the method; use -help for a list of available methods Notes: See "slepc/include/slepcpep.h" for available methods. The default is PEPTOAR. Normally, it is best to use the PEPSetFromOptions() command and then set the PEP type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the different available methods. The PEPSetType() routine is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database. Level: intermediate .seealso: PEPType @*/ PetscErrorCode PEPSetType(PEP pep,PEPType type) { PetscErrorCode ierr,(*r)(PEP); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)pep,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); ierr = PetscFunctionListFind(PEPList,type,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown PEP type given: %s",type); if (pep->ops->destroy) { ierr = (*pep->ops->destroy)(pep);CHKERRQ(ierr); } ierr = PetscMemzero(pep->ops,sizeof(struct _PEPOps));CHKERRQ(ierr); pep->state = PEP_STATE_INITIAL; ierr = PetscObjectChangeTypeName((PetscObject)pep,type);CHKERRQ(ierr); ierr = (*r)(pep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetType" /*@C PEPGetType - Gets the PEP type as a string from the PEP object. Not Collective Input Parameter: . pep - the eigensolver context Output Parameter: . name - name of PEP method Level: intermediate .seealso: PEPSetType() @*/ PetscErrorCode PEPGetType(PEP pep,PEPType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(type,2); *type = ((PetscObject)pep)->type_name; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPRegister" /*@C PEPRegister - Adds a method to the polynomial eigenproblem solver package. Not Collective Input Parameters: + name - name of a new user-defined solver - function - routine to create the solver context Notes: PEPRegister() may be called multiple times to add several user-defined solvers. Sample usage: .vb PEPRegister("my_solver",MySolverCreate); .ve Then, your solver can be chosen with the procedural interface via $ PEPSetType(pep,"my_solver") or at runtime via the option $ -pep_type my_solver Level: advanced .seealso: PEPRegisterAll() @*/ PetscErrorCode PEPRegister(const char *name,PetscErrorCode (*function)(PEP)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListAdd(&PEPList,name,function);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPReset" /*@ PEPReset - Resets the PEP context to the initial state and removes any allocated objects. Collective on PEP Input Parameter: . pep - eigensolver context obtained from PEPCreate() Level: advanced .seealso: PEPDestroy() @*/ PetscErrorCode PEPReset(PEP pep) { PetscErrorCode ierr; PetscInt ncols; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (pep->ops->reset) { ierr = (pep->ops->reset)(pep);CHKERRQ(ierr); } if (pep->st) { ierr = STReset(pep->st);CHKERRQ(ierr); } if (pep->ds) { ierr = DSReset(pep->ds);CHKERRQ(ierr); } if (pep->nmat) { ierr = MatDestroyMatrices(pep->nmat,&pep->A);CHKERRQ(ierr); ierr = PetscFree2(pep->pbc,pep->nrma);CHKERRQ(ierr); ierr = PetscFree(pep->solvematcoeffs);CHKERRQ(ierr); pep->nmat = 0; } ierr = VecDestroy(&pep->Dl);CHKERRQ(ierr); ierr = VecDestroy(&pep->Dr);CHKERRQ(ierr); ierr = BVGetSizes(pep->V,NULL,NULL,&ncols);CHKERRQ(ierr); if (ncols) { ierr = PetscFree4(pep->eigr,pep->eigi,pep->errest,pep->perm);CHKERRQ(ierr); } ierr = BVDestroy(&pep->V);CHKERRQ(ierr); ierr = VecDestroyVecs(pep->nwork,&pep->work);CHKERRQ(ierr); ierr = KSPDestroy(&pep->refineksp);CHKERRQ(ierr); ierr = PetscSubcommDestroy(&pep->refinesubc);CHKERRQ(ierr); pep->nwork = 0; pep->state = PEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPDestroy" /*@ PEPDestroy - Destroys the PEP context. Collective on PEP Input Parameter: . pep - eigensolver context obtained from PEPCreate() Level: beginner .seealso: PEPCreate(), PEPSetUp(), PEPSolve() @*/ PetscErrorCode PEPDestroy(PEP *pep) { PetscErrorCode ierr; PetscFunctionBegin; if (!*pep) PetscFunctionReturn(0); PetscValidHeaderSpecific(*pep,PEP_CLASSID,1); if (--((PetscObject)(*pep))->refct > 0) { *pep = 0; PetscFunctionReturn(0); } ierr = PEPReset(*pep);CHKERRQ(ierr); if ((*pep)->ops->destroy) { ierr = (*(*pep)->ops->destroy)(*pep);CHKERRQ(ierr); } ierr = STDestroy(&(*pep)->st);CHKERRQ(ierr); ierr = RGDestroy(&(*pep)->rg);CHKERRQ(ierr); ierr = DSDestroy(&(*pep)->ds);CHKERRQ(ierr); ierr = PetscFree((*pep)->sc);CHKERRQ(ierr); /* just in case the initial vectors have not been used */ ierr = SlepcBasisDestroy_Private(&(*pep)->nini,&(*pep)->IS);CHKERRQ(ierr); if ((*pep)->convergeddestroy) { ierr = (*(*pep)->convergeddestroy)((*pep)->convergedctx);CHKERRQ(ierr); } ierr = PEPMonitorCancel(*pep);CHKERRQ(ierr); ierr = PetscHeaderDestroy(pep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetBV" /*@ PEPSetBV - Associates a basis vectors object to the polynomial eigensolver. Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() - bv - the basis vectors object Note: Use PEPGetBV() to retrieve the basis vectors context (for example, to free it at the end of the computations). Level: advanced .seealso: PEPGetBV() @*/ PetscErrorCode PEPSetBV(PEP pep,BV bv) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidHeaderSpecific(bv,BV_CLASSID,2); PetscCheckSameComm(pep,1,bv,2); ierr = PetscObjectReference((PetscObject)bv);CHKERRQ(ierr); ierr = BVDestroy(&pep->V);CHKERRQ(ierr); pep->V = bv; ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->V);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetBV" /*@ PEPGetBV - Obtain the basis vectors object associated to the polynomial eigensolver object. Not Collective Input Parameters: . pep - eigensolver context obtained from PEPCreate() Output Parameter: . bv - basis vectors context Level: advanced .seealso: PEPSetBV() @*/ PetscErrorCode PEPGetBV(PEP pep,BV *bv) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(bv,2); if (!pep->V) { ierr = BVCreate(PetscObjectComm((PetscObject)pep),&pep->V);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->V);CHKERRQ(ierr); } *bv = pep->V; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetRG" /*@ PEPSetRG - Associates a region object to the polynomial eigensolver. Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() - rg - the region object Note: Use PEPGetRG() to retrieve the region context (for example, to free it at the end of the computations). Level: advanced .seealso: PEPGetRG() @*/ PetscErrorCode PEPSetRG(PEP pep,RG rg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidHeaderSpecific(rg,RG_CLASSID,2); PetscCheckSameComm(pep,1,rg,2); ierr = PetscObjectReference((PetscObject)rg);CHKERRQ(ierr); ierr = RGDestroy(&pep->rg);CHKERRQ(ierr); pep->rg = rg; ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->rg);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetRG" /*@ PEPGetRG - Obtain the region object associated to the polynomial eigensolver object. Not Collective Input Parameters: . pep - eigensolver context obtained from PEPCreate() Output Parameter: . rg - region context Level: advanced .seealso: PEPSetRG() @*/ PetscErrorCode PEPGetRG(PEP pep,RG *rg) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(rg,2); if (!pep->rg) { ierr = RGCreate(PetscObjectComm((PetscObject)pep),&pep->rg);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->rg);CHKERRQ(ierr); } *rg = pep->rg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetDS" /*@ PEPSetDS - Associates a direct solver object to the polynomial eigensolver. Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() - ds - the direct solver object Note: Use PEPGetDS() to retrieve the direct solver context (for example, to free it at the end of the computations). Level: advanced .seealso: PEPGetDS() @*/ PetscErrorCode PEPSetDS(PEP pep,DS ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidHeaderSpecific(ds,DS_CLASSID,2); PetscCheckSameComm(pep,1,ds,2); ierr = PetscObjectReference((PetscObject)ds);CHKERRQ(ierr); ierr = DSDestroy(&pep->ds);CHKERRQ(ierr); pep->ds = ds; ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->ds);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetDS" /*@ PEPGetDS - Obtain the direct solver object associated to the polynomial eigensolver object. Not Collective Input Parameters: . pep - eigensolver context obtained from PEPCreate() Output Parameter: . ds - direct solver context Level: advanced .seealso: PEPSetDS() @*/ PetscErrorCode PEPGetDS(PEP pep,DS *ds) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(ds,2); if (!pep->ds) { ierr = DSCreate(PetscObjectComm((PetscObject)pep),&pep->ds);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->ds);CHKERRQ(ierr); } *ds = pep->ds; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetST" /*@ PEPSetST - Associates a spectral transformation object to the eigensolver. Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() - st - the spectral transformation object Note: Use PEPGetST() to retrieve the spectral transformation context (for example, to free it at the end of the computations). Level: advanced .seealso: PEPGetST() @*/ PetscErrorCode PEPSetST(PEP pep,ST st) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidHeaderSpecific(st,ST_CLASSID,2); PetscCheckSameComm(pep,1,st,2); ierr = PetscObjectReference((PetscObject)st);CHKERRQ(ierr); ierr = STDestroy(&pep->st);CHKERRQ(ierr); pep->st = st; ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->st);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetST" /*@ PEPGetST - Obtain the spectral transformation (ST) object associated to the eigensolver object. Not Collective Input Parameters: . pep - eigensolver context obtained from PEPCreate() Output Parameter: . st - spectral transformation context Level: intermediate .seealso: PEPSetST() @*/ PetscErrorCode PEPGetST(PEP pep,ST *st) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(st,2); if (!pep->st) { ierr = STCreate(PetscObjectComm((PetscObject)pep),&pep->st);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->st);CHKERRQ(ierr); } *st = pep->st; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPRefineGetKSP" /*@ PEPRefineGetKSP - Obtain the ksp object used by the eigensolver object in the refinement phase. Not Collective Input Parameters: . pep - eigensolver context obtained from PEPCreate() Output Parameter: . ksp - ksp context Level: advanced .seealso: PEPSetRefine() @*/ PetscErrorCode PEPRefineGetKSP(PEP pep,KSP *ksp) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(ksp,2); if (!pep->refineksp) { if (pep->npart>1) { /* Split in subcomunicators */ ierr = PetscSubcommCreate(PetscObjectComm((PetscObject)pep),&pep->refinesubc);CHKERRQ(ierr); ierr = PetscSubcommSetNumber(pep->refinesubc,pep->npart);CHKERRQ(ierr);CHKERRQ(ierr); ierr = PetscSubcommSetType(pep->refinesubc,PETSC_SUBCOMM_CONTIGUOUS);CHKERRQ(ierr); ierr = PetscLogObjectMemory((PetscObject)pep,sizeof(PetscSubcomm));CHKERRQ(ierr); } ierr = KSPCreate((pep->npart==1)?PetscObjectComm((PetscObject)pep):PetscSubcommChild(pep->refinesubc),&pep->refineksp);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->refineksp);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(*ksp,((PetscObject)pep)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(*ksp,"pep_refine_");CHKERRQ(ierr); } *ksp = pep->refineksp; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetTarget" /*@ PEPSetTarget - Sets the value of the target. Logically Collective on PEP Input Parameters: + pep - eigensolver context - target - the value of the target Options Database Key: . -pep_target - the value of the target Notes: The target is a scalar value used to determine the portion of the spectrum of interest. It is used in combination with PEPSetWhichEigenpairs(). In the case of complex scalars, a complex value can be provided in the command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g. -pep_target 1.0+2.0i Level: intermediate .seealso: PEPGetTarget(), PEPSetWhichEigenpairs() @*/ PetscErrorCode PEPSetTarget(PEP pep,PetscScalar target) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveScalar(pep,target,2); pep->target = target; if (!pep->st) { ierr = PEPGetST(pep,&pep->st);CHKERRQ(ierr); } ierr = STSetDefaultShift(pep->st,target);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetTarget" /*@ PEPGetTarget - Gets the value of the target. Not Collective Input Parameter: . pep - eigensolver context Output Parameter: . target - the value of the target Note: If the target was not set by the user, then zero is returned. Level: intermediate .seealso: PEPSetTarget() @*/ PetscErrorCode PEPGetTarget(PEP pep,PetscScalar* target) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidScalarPointer(target,2); *target = pep->target; PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/pepsolve.c.html0000644000175000017500000012425413107004621020452 0ustar jromanjroman
Actual source code: pepsolve.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       PEP routines related to the solution process.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>       /*I "slepcpep.h" I*/
 25: #include <petscdraw.h>

 27: static PetscBool  cited = PETSC_FALSE;
 28: static const char citation[] =
 29:   "@Article{slepc-pep-refine,\n"
 30:   "   author = \"C. Campos and J. E. Roman\",\n"
 31:   "   title = \"Parallel iterative refinement in polynomial eigenvalue problems\",\n"
 32:   "   journal = \"Numer. Linear Algebra Appl.\",\n"
 33:   "   volume = \"to appear\",\n"
 34:   "   number = \"\",\n"
 35:   "   pages = \"\",\n"
 36:   "   year = \"2016,\"\n"
 37:   "   doi = \"http://dx.doi.org/10.1002/nla.2052\"\n"
 38:   "}\n";

 42: PetscErrorCode PEPComputeVectors(PEP pep)
 43: {

 47:   PEPCheckSolved(pep,1);
 48:   switch (pep->state) {
 49:   case PEP_STATE_SOLVED:
 50:     if (pep->ops->computevectors) {
 51:       (*pep->ops->computevectors)(pep);
 52:     }
 53:     break;
 54:   default:
 55:     break;
 56:   }
 57:   pep->state = PEP_STATE_EIGENVECTORS;
 58:   return(0);
 59: }

 63: PetscErrorCode PEPExtractVectors(PEP pep)
 64: {

 68:   PEPCheckSolved(pep,1);
 69:   switch (pep->state) {
 70:   case PEP_STATE_SOLVED:
 71:     BVSetActiveColumns(pep->V,0,pep->nconv);
 72:     if (pep->ops->extractvectors) {
 73:       (*pep->ops->extractvectors)(pep);
 74:     }
 75:     break;
 76:   default:
 77:     break;
 78:   }
 79:   return(0);
 80: }

 84: /*@
 85:    PEPSolve - Solves the polynomial eigensystem.

 87:    Collective on PEP

 89:    Input Parameter:
 90: .  pep - eigensolver context obtained from PEPCreate()

 92:    Options Database Keys:
 93: +  -pep_view - print information about the solver used
 94: .  -pep_view_matk binary - save any of the coefficient matrices (Ak) to the
 95:                 default binary viewer (replace k by an integer from 0 to nmat-1)
 96: .  -pep_view_vectors binary - save the computed eigenvectors to the default binary viewer
 97: .  -pep_view_values - print computed eigenvalues
 98: .  -pep_converged_reason - print reason for convergence, and number of iterations
 99: .  -pep_error_absolute - print absolute errors of each eigenpair
100: .  -pep_error_relative - print relative errors of each eigenpair
101: -  -pep_error_backward - print backward errors of each eigenpair

103:    Level: beginner

105: .seealso: PEPCreate(), PEPSetUp(), PEPDestroy(), PEPSetTolerances()
106: @*/
107: PetscErrorCode PEPSolve(PEP pep)
108: {
110:   PetscInt       i,k;
111:   PetscBool      flg,islinear;
112: #define OPTLEN 16
113:   char           str[OPTLEN];

117:   if (pep->state>=PEP_STATE_SOLVED) return(0);
118:   PetscLogEventBegin(PEP_Solve,pep,0,0,0);

120:   /* call setup */
121:   PEPSetUp(pep);
122:   pep->nconv = 0;
123:   pep->its   = 0;
124:   k = pep->lineariz? pep->ncv: pep->ncv*(pep->nmat-1);
125:   for (i=0;i<k;i++) {
126:     pep->eigr[i]   = 0.0;
127:     pep->eigi[i]   = 0.0;
128:     pep->errest[i] = 0.0;
129:     pep->perm[i]   = i;
130:   }
131:   PEPViewFromOptions(pep,NULL,"-pep_view_pre");

133:   (*pep->ops->solve)(pep);
134:   
135:   if (!pep->reason) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason");

137:   PetscObjectTypeCompare((PetscObject)pep,PEPLINEAR,&islinear);
138:   if (!islinear) {
139:     STPostSolve(pep->st);
140:     /* Map eigenvalues back to the original problem */
141:     STGetTransform(pep->st,&flg);
142:     if (flg && pep->ops->backtransform) {
143:       (*pep->ops->backtransform)(pep);
144:     }
145:   }

147:   pep->state = PEP_STATE_SOLVED;

149: #if !defined(PETSC_USE_COMPLEX)
150:   /* reorder conjugate eigenvalues (positive imaginary first) */
151:   for (i=0;i<pep->nconv-1;i++) {
152:     if (pep->eigi[i] != 0) {
153:       if (pep->eigi[i] < 0) {
154:         pep->eigi[i] = -pep->eigi[i];
155:         pep->eigi[i+1] = -pep->eigi[i+1];
156:         /* the next correction only works with eigenvectors */
157:         PEPComputeVectors(pep);
158:         BVScaleColumn(pep->V,i+1,-1.0);
159:       }
160:       i++;
161:     }
162:   }
163: #endif

165:   if (pep->refine!=PEP_REFINE_NONE) {
166:     PetscCitationsRegister(citation,&cited);
167:   }

169:   if (pep->refine==PEP_REFINE_SIMPLE && pep->rits>0 && pep->nconv>0) {
170:     PEPComputeVectors(pep);
171:     PEPNewtonRefinementSimple(pep,&pep->rits,pep->rtol,pep->nconv);
172:   }

174:   /* sort eigenvalues according to pep->which parameter */
175:   SlepcSortEigenvalues(pep->sc,pep->nconv,pep->eigr,pep->eigi,pep->perm);
176:   PetscLogEventEnd(PEP_Solve,pep,0,0,0);

178:   /* various viewers */
179:   PEPViewFromOptions(pep,NULL,"-pep_view");
180:   PEPReasonViewFromOptions(pep);
181:   PEPErrorViewFromOptions(pep);
182:   PEPValuesViewFromOptions(pep);
183:   PEPVectorsViewFromOptions(pep);
184:   for (i=0;i<pep->nmat;i++) {
185:     PetscSNPrintf(str,OPTLEN,"-pep_view_mat%d",(int)i);
186:     MatViewFromOptions(pep->A[i],(PetscObject)pep,str);
187:   }

189:   /* Remove the initial subspace */
190:   pep->nini = 0;
191:   return(0);
192: }

196: /*@
197:    PEPGetIterationNumber - Gets the current iteration number. If the
198:    call to PEPSolve() is complete, then it returns the number of iterations
199:    carried out by the solution method.

201:    Not Collective

203:    Input Parameter:
204: .  pep - the polynomial eigensolver context

206:    Output Parameter:
207: .  its - number of iterations

209:    Level: intermediate

211:    Note:
212:    During the i-th iteration this call returns i-1. If PEPSolve() is
213:    complete, then parameter "its" contains either the iteration number at
214:    which convergence was successfully reached, or failure was detected.
215:    Call PEPGetConvergedReason() to determine if the solver converged or
216:    failed and why.

218: .seealso: PEPGetConvergedReason(), PEPSetTolerances()
219: @*/
220: PetscErrorCode PEPGetIterationNumber(PEP pep,PetscInt *its)
221: {
225:   *its = pep->its;
226:   return(0);
227: }

231: /*@
232:    PEPGetConverged - Gets the number of converged eigenpairs.

234:    Not Collective

236:    Input Parameter:
237: .  pep - the polynomial eigensolver context

239:    Output Parameter:
240: .  nconv - number of converged eigenpairs

242:    Note:
243:    This function should be called after PEPSolve() has finished.

245:    Level: beginner

247: .seealso: PEPSetDimensions(), PEPSolve()
248: @*/
249: PetscErrorCode PEPGetConverged(PEP pep,PetscInt *nconv)
250: {
254:   PEPCheckSolved(pep,1);
255:   *nconv = pep->nconv;
256:   return(0);
257: }

261: /*@
262:    PEPGetConvergedReason - Gets the reason why the PEPSolve() iteration was
263:    stopped.

265:    Not Collective

267:    Input Parameter:
268: .  pep - the polynomial eigensolver context

270:    Output Parameter:
271: .  reason - negative value indicates diverged, positive value converged

273:    Notes:

275:    Possible values for reason are
276: +  PEP_CONVERGED_TOL - converged up to tolerance
277: .  PEP_CONVERGED_USER - converged due to a user-defined condition
278: .  PEP_DIVERGED_ITS - required more than max_it iterations to reach convergence
279: .  PEP_DIVERGED_BREAKDOWN - generic breakdown in method
280: -  PEP_DIVERGED_SYMMETRY_LOST - pseudo-Lanczos was not able to keep symmetry

282:    Can only be called after the call to PEPSolve() is complete.

284:    Level: intermediate

286: .seealso: PEPSetTolerances(), PEPSolve(), PEPConvergedReason
287: @*/
288: PetscErrorCode PEPGetConvergedReason(PEP pep,PEPConvergedReason *reason)
289: {
293:   PEPCheckSolved(pep,1);
294:   *reason = pep->reason;
295:   return(0);
296: }

300: /*@
301:    PEPGetEigenpair - Gets the i-th solution of the eigenproblem as computed by
302:    PEPSolve(). The solution consists in both the eigenvalue and the eigenvector.

304:    Logically Collective on EPS

306:    Input Parameters:
307: +  pep - polynomial eigensolver context
308: -  i   - index of the solution

310:    Output Parameters:
311: +  eigr - real part of eigenvalue
312: .  eigi - imaginary part of eigenvalue
313: .  Vr   - real part of eigenvector
314: -  Vi   - imaginary part of eigenvector

316:    Notes:
317:    It is allowed to pass NULL for Vr and Vi, if the eigenvector is not
318:    required. Otherwise, the caller must provide valid Vec objects, i.e.,
319:    they must be created by the calling program with e.g. MatCreateVecs().

321:    If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is
322:    configured with complex scalars the eigenvalue is stored
323:    directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is
324:    set to zero). In both cases, the user can pass NULL in eigi and Vi.

326:    The index i should be a value between 0 and nconv-1 (see PEPGetConverged()).
327:    Eigenpairs are indexed according to the ordering criterion established
328:    with PEPSetWhichEigenpairs().

330:    Level: beginner

332: .seealso: PEPSolve(), PEPGetConverged(), PEPSetWhichEigenpairs()
333: @*/
334: PetscErrorCode PEPGetEigenpair(PEP pep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)
335: {
336:   PetscInt       k;

344:   PEPCheckSolved(pep,1);
345:   if (i<0 || i>=pep->nconv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");

347:   PEPComputeVectors(pep);
348:   k = pep->perm[i];

350:   /* eigenvalue */
351: #if defined(PETSC_USE_COMPLEX)
352:   if (eigr) *eigr = pep->eigr[k];
353:   if (eigi) *eigi = 0;
354: #else
355:   if (eigr) *eigr = pep->eigr[k];
356:   if (eigi) *eigi = pep->eigi[k];
357: #endif

359:   /* eigenvector */
360: #if defined(PETSC_USE_COMPLEX)
361:   if (Vr) { BVCopyVec(pep->V,k,Vr); }
362:   if (Vi) { VecSet(Vi,0.0); }
363: #else
364:   if (pep->eigi[k]>0) { /* first value of conjugate pair */
365:     if (Vr) { BVCopyVec(pep->V,k,Vr); }
366:     if (Vi) { BVCopyVec(pep->V,k+1,Vi); }
367:   } else if (pep->eigi[k]<0) { /* second value of conjugate pair */
368:     if (Vr) { BVCopyVec(pep->V,k-1,Vr); }
369:     if (Vi) {
370:       BVCopyVec(pep->V,k,Vi);
371:       VecScale(Vi,-1.0);
372:     }
373:   } else { /* real eigenvalue */
374:     if (Vr) { BVCopyVec(pep->V,k,Vr); }
375:     if (Vi) { VecSet(Vi,0.0); }
376:   }
377: #endif
378:   return(0);
379: }

383: /*@
384:    PEPGetErrorEstimate - Returns the error estimate associated to the i-th
385:    computed eigenpair.

387:    Not Collective

389:    Input Parameter:
390: +  pep - polynomial eigensolver context
391: -  i   - index of eigenpair

393:    Output Parameter:
394: .  errest - the error estimate

396:    Notes:
397:    This is the error estimate used internally by the eigensolver. The actual
398:    error bound can be computed with PEPComputeError(). See also the users
399:    manual for details.

401:    Level: advanced

403: .seealso: PEPComputeError()
404: @*/
405: PetscErrorCode PEPGetErrorEstimate(PEP pep,PetscInt i,PetscReal *errest)
406: {
410:   PEPCheckSolved(pep,1);
411:   if (i<0 || i>=pep->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range");
412:   if (errest) *errest = pep->errest[pep->perm[i]];
413:   return(0);
414: }

418: /*
419:    PEPComputeResidualNorm_Private - Computes the norm of the residual vector
420:    associated with an eigenpair.

422:    Input Parameters:
423:      kr,ki - eigenvalue
424:      xr,xi - eigenvector
425:      z     - array of 4 work vectors (z[2],z[3] not referenced in complex scalars)
426: */
427: PetscErrorCode PEPComputeResidualNorm_Private(PEP pep,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm)
428: {
430:   Mat            *A=pep->A;
431:   PetscInt       i,nmat=pep->nmat;
432:   PetscScalar    t[20],*vals=t,*ivals=NULL;
433:   Vec            u,w;
434: #if !defined(PETSC_USE_COMPLEX)
435:   Vec            ui,wi;
436:   PetscReal      ni;
437:   PetscBool      imag;
438:   PetscScalar    it[20];
439: #endif

442:   u = z[0]; w = z[1];
443:   VecSet(u,0.0);
444: #if !defined(PETSC_USE_COMPLEX)
445:   ui = z[2]; wi = z[3];
446:   ivals = it; 
447: #endif
448:   if (nmat>20) {
449:     PetscMalloc1(nmat,&vals);
450: #if !defined(PETSC_USE_COMPLEX)
451:     PetscMalloc1(nmat,&ivals);
452: #endif
453:   }
454:   PEPEvaluateBasis(pep,kr,ki,vals,ivals);
455: #if !defined(PETSC_USE_COMPLEX)
456:   if (ki == 0 || PetscAbsScalar(ki) < PetscAbsScalar(kr*PETSC_MACHINE_EPSILON))
457:     imag = PETSC_FALSE;
458:   else {
459:     imag = PETSC_TRUE;
460:     VecSet(ui,0.0);
461:   }
462: #endif
463:   for (i=0;i<nmat;i++) {
464:     if (vals[i]!=0.0) {
465:       MatMult(A[i],xr,w);
466:       VecAXPY(u,vals[i],w);
467:     }
468: #if !defined(PETSC_USE_COMPLEX)
469:     if (imag) {
470:       if (ivals[i]!=0 || vals[i]!=0) {
471:         MatMult(A[i],xi,wi);
472:         if (vals[i]==0) {
473:           MatMult(A[i],xr,w);
474:         }
475:       }
476:       if (ivals[i]!=0){
477:         VecAXPY(u,-ivals[i],wi);
478:         VecAXPY(ui,ivals[i],w);
479:       }
480:       if (vals[i]!=0) {
481:         VecAXPY(ui,vals[i],wi);
482:       }
483:     }
484: #endif
485:   }
486:   VecNorm(u,NORM_2,norm);
487: #if !defined(PETSC_USE_COMPLEX)
488:   if (imag) {
489:     VecNorm(ui,NORM_2,&ni);
490:     *norm = SlepcAbsEigenvalue(*norm,ni);
491:   }
492: #endif
493:   if (nmat>20) {
494:     PetscFree(vals);
495: #if !defined(PETSC_USE_COMPLEX)
496:     PetscFree(ivals);
497: #endif
498:   }
499:   return(0);
500: }

504: /*@
505:    PEPComputeError - Computes the error (based on the residual norm) associated
506:    with the i-th computed eigenpair.

508:    Collective on PEP

510:    Input Parameter:
511: +  pep  - the polynomial eigensolver context
512: .  i    - the solution index
513: -  type - the type of error to compute

515:    Output Parameter:
516: .  error - the error

518:    Notes:
519:    The error can be computed in various ways, all of them based on the residual
520:    norm ||P(l)x||_2 where l is the eigenvalue and x is the eigenvector.
521:    See the users guide for additional details.

523:    Level: beginner

525: .seealso: PEPErrorType, PEPSolve(), PEPGetErrorEstimate()
526: @*/
527: PetscErrorCode PEPComputeError(PEP pep,PetscInt i,PEPErrorType type,PetscReal *error)
528: {
530:   Vec            xr,xi,w[4];
531:   PetscScalar    kr,ki;
532:   PetscReal      t,z=0.0;
533:   PetscInt       j;
534:   PetscBool      flg;

541:   PEPCheckSolved(pep,1);

543:   /* allocate work vectors */
544: #if defined(PETSC_USE_COMPLEX)
545:   PEPSetWorkVecs(pep,3);
546:   xi   = NULL;
547:   w[2] = NULL;
548:   w[3] = NULL;
549: #else
550:   PEPSetWorkVecs(pep,6);
551:   xi   = pep->work[3];
552:   w[2] = pep->work[4];
553:   w[3] = pep->work[5];
554: #endif
555:   xr   = pep->work[0];
556:   w[0] = pep->work[1];
557:   w[1] = pep->work[2];

559:   /* compute residual norms */
560:   PEPGetEigenpair(pep,i,&kr,&ki,xr,xi);
561:   PEPComputeResidualNorm_Private(pep,kr,ki,xr,xi,w,error);

563:   /* compute error */
564:   switch (type) {
565:     case PEP_ERROR_ABSOLUTE:
566:       break;
567:     case PEP_ERROR_RELATIVE:
568:       *error /= SlepcAbsEigenvalue(kr,ki);
569:       break;
570:     case PEP_ERROR_BACKWARD:
571:       /* initialization of matrix norms */
572:       if (!pep->nrma[pep->nmat-1]) {
573:         for (j=0;j<pep->nmat;j++) {
574:           MatHasOperation(pep->A[j],MATOP_NORM,&flg);
575:           if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation");
576:           MatNorm(pep->A[j],NORM_INFINITY,&pep->nrma[j]);
577:         }
578:       }
579:       t = SlepcAbsEigenvalue(kr,ki);
580:       for (j=pep->nmat-1;j>=0;j--) {
581:         z = z*t+pep->nrma[j];
582:       }
583:       *error /= z;
584:       break;
585:     default:
586:       SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type");
587:   }
588:   return(0);
589: }

slepc-3.7.4/src/pep/interface/pepsetup.c0000644000175000017500000004043513107004621017515 0ustar jromanjroman/* PEP routines related to problem setup. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #undef __FUNCT__ #define __FUNCT__ "PEPSetUp" /*@ PEPSetUp - Sets up all the internal data structures necessary for the execution of the PEP solver. Collective on PEP Input Parameter: . pep - solver context Notes: This function need not be called explicitly in most cases, since PEPSolve() calls it. It can be useful when one wants to measure the set-up time separately from the solve time. Level: developer .seealso: PEPCreate(), PEPSolve(), PEPDestroy() @*/ PetscErrorCode PEPSetUp(PEP pep) { PetscErrorCode ierr; SlepcSC sc; PetscBool istrivial,flg; PetscInt k; KSP ksp; PC pc; PetscMPIInt size; const MatSolverPackage stype; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (pep->state) PetscFunctionReturn(0); ierr = PetscLogEventBegin(PEP_SetUp,pep,0,0,0);CHKERRQ(ierr); /* reset the convergence flag from the previous solves */ pep->reason = PEP_CONVERGED_ITERATING; /* set default solver type (PEPSetFromOptions was not called) */ if (!((PetscObject)pep)->type_name) { ierr = PEPSetType(pep,PEPTOAR);CHKERRQ(ierr); } if (!pep->st) { ierr = PEPGetST(pep,&pep->st);CHKERRQ(ierr); } if (!pep->ds) { ierr = PEPGetDS(pep,&pep->ds);CHKERRQ(ierr); } ierr = DSReset(pep->ds);CHKERRQ(ierr); if (!pep->rg) { ierr = PEPGetRG(pep,&pep->rg);CHKERRQ(ierr); } if (!((PetscObject)pep->rg)->type_name) { ierr = RGSetType(pep->rg,RGINTERVAL);CHKERRQ(ierr); } /* check matrices, transfer them to ST */ if (!pep->A) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONGSTATE,"PEPSetOperators must be called first"); ierr = STSetOperators(pep->st,pep->nmat,pep->A);CHKERRQ(ierr); /* set problem dimensions */ ierr = MatGetSize(pep->A[0],&pep->n,NULL);CHKERRQ(ierr); ierr = MatGetLocalSize(pep->A[0],&pep->nloc,NULL);CHKERRQ(ierr); /* set default problem type */ if (!pep->problem_type) { ierr = PEPSetProblemType(pep,PEP_GENERAL);CHKERRQ(ierr); } /* check consistency of refinement options */ if (pep->refine) { if (!pep->scheme) { /* set default scheme */ ierr = PEPRefineGetKSP(pep,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");CHKERRQ(ierr); } pep->scheme = flg? PEP_REFINE_SCHEME_MBE: PEP_REFINE_SCHEME_SCHUR; } if (pep->scheme==PEP_REFINE_SCHEME_MBE) { ierr = PEPRefineGetKSP(pep,&ksp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");CHKERRQ(ierr); } if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"The MBE scheme for refinement requires a direct solver in KSP"); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pc),&size);CHKERRQ(ierr); if (size>1) { /* currently selected PC is a factorization */ ierr = PCFactorGetMatSolverPackage(pc,&stype);CHKERRQ(ierr); ierr = PetscStrcmp(stype,MATSOLVERPETSC,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"For Newton refinement, you chose to solve linear systems with a factorization, but in parallel runs you need to select an external package"); } } if (pep->scheme==PEP_REFINE_SCHEME_SCHUR) { if (pep->npart>1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"The Schur scheme for refinement does not support subcommunicators"); } } /* call specific solver setup */ ierr = (*pep->ops->setup)(pep);CHKERRQ(ierr); /* set tolerance if not yet set */ if (pep->tol==PETSC_DEFAULT) pep->tol = SLEPC_DEFAULT_TOL; if (pep->refine) { if (pep->rtol==PETSC_DEFAULT) pep->rtol = PetscMax(pep->tol/1000,PETSC_MACHINE_EPSILON); if (pep->rits==PETSC_DEFAULT) pep->rits = (pep->refine==PEP_REFINE_SIMPLE)? 10: 1; } /* set default extraction */ if (!pep->extract) { pep->extract = (pep->basis==PEP_BASIS_MONOMIAL)? PEP_EXTRACT_NORM: PEP_EXTRACT_NONE; } /* fill sorting criterion context */ switch (pep->which) { case PEP_LARGEST_MAGNITUDE: pep->sc->comparison = SlepcCompareLargestMagnitude; pep->sc->comparisonctx = NULL; break; case PEP_SMALLEST_MAGNITUDE: pep->sc->comparison = SlepcCompareSmallestMagnitude; pep->sc->comparisonctx = NULL; break; case PEP_LARGEST_REAL: pep->sc->comparison = SlepcCompareLargestReal; pep->sc->comparisonctx = NULL; break; case PEP_SMALLEST_REAL: pep->sc->comparison = SlepcCompareSmallestReal; pep->sc->comparisonctx = NULL; break; case PEP_LARGEST_IMAGINARY: pep->sc->comparison = SlepcCompareLargestImaginary; pep->sc->comparisonctx = NULL; break; case PEP_SMALLEST_IMAGINARY: pep->sc->comparison = SlepcCompareSmallestImaginary; pep->sc->comparisonctx = NULL; break; case PEP_TARGET_MAGNITUDE: pep->sc->comparison = SlepcCompareTargetMagnitude; pep->sc->comparisonctx = &pep->target; break; case PEP_TARGET_REAL: pep->sc->comparison = SlepcCompareTargetReal; pep->sc->comparisonctx = &pep->target; break; case PEP_TARGET_IMAGINARY: pep->sc->comparison = SlepcCompareTargetImaginary; pep->sc->comparisonctx = &pep->target; break; case PEP_WHICH_USER: break; } pep->sc->map = NULL; pep->sc->mapobj = NULL; /* fill sorting criterion for DS */ ierr = DSGetSlepcSC(pep->ds,&sc);CHKERRQ(ierr); ierr = RGIsTrivial(pep->rg,&istrivial);CHKERRQ(ierr); sc->rg = istrivial? NULL: pep->rg; sc->comparison = pep->sc->comparison; sc->comparisonctx = pep->sc->comparisonctx; sc->map = SlepcMap_ST; sc->mapobj = (PetscObject)pep->st; /* setup ST */ ierr = STSetUp(pep->st);CHKERRQ(ierr); /* compute matrix coefficients */ ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) { if (pep->solvematcoeffs) { ierr = STMatSetUp(pep->st,1.0,pep->solvematcoeffs);CHKERRQ(ierr); } } else { if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Cannot use ST-transform with non-monomial basis in PEP"); } /* compute scale factor if no set by user */ ierr = PEPComputeScaleFactor(pep);CHKERRQ(ierr); /* build balancing matrix if required */ if (pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) { if (!pep->Dl) { ierr = BVCreateVec(pep->V,&pep->Dl);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->Dl);CHKERRQ(ierr); } if (!pep->Dr) { ierr = BVCreateVec(pep->V,&pep->Dr);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->Dr);CHKERRQ(ierr); } ierr = PEPBuildDiagonalScaling(pep);CHKERRQ(ierr); } /* process initial vectors */ if (pep->nini<0) { k = -pep->nini; if (k>pep->ncv) SETERRQ(PetscObjectComm((PetscObject)pep),1,"The number of initial vectors is larger than ncv"); ierr = BVInsertVecs(pep->V,0,&k,pep->IS,PETSC_TRUE);CHKERRQ(ierr); ierr = SlepcBasisDestroy_Private(&pep->nini,&pep->IS);CHKERRQ(ierr); pep->nini = k; } ierr = PetscLogEventEnd(PEP_SetUp,pep,0,0,0);CHKERRQ(ierr); pep->state = PEP_STATE_SETUP; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetOperators" /*@ PEPSetOperators - Sets the coefficient matrices associated with the polynomial eigenvalue problem. Collective on PEP and Mat Input Parameters: + pep - the eigenproblem solver context . nmat - number of matrices in array A - A - the array of matrices associated with the eigenproblem Notes: The polynomial eigenproblem is defined as P(l)*x=0, where l is the eigenvalue, x is the eigenvector, and P(l) is defined as P(l) = A_0 + l*A_1 + ... + l^d*A_d, with d=nmat-1 (the degree of P). For non-monomial bases, this expression is different. Level: beginner .seealso: PEPSolve(), PEPGetOperators(), PEPGetNumMatrices(), PEPSetBasis() @*/ PetscErrorCode PEPSetOperators(PEP pep,PetscInt nmat,Mat A[]) { PetscErrorCode ierr; PetscInt i,n,m,m0=0; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveInt(pep,nmat,2); if (nmat <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Non-positive value of nmat: %D",nmat); if (nmat <= 2) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot solve linear eigenproblems with PEP; use EPS instead"); PetscValidPointer(A,3); if (pep->state) { ierr = PEPReset(pep);CHKERRQ(ierr); } ierr = PetscMalloc1(nmat,&pep->A);CHKERRQ(ierr); ierr = PetscCalloc2(3*nmat,&pep->pbc,nmat,&pep->nrma);CHKERRQ(ierr); for (i=0;ipbc[i] = 1.0; /* default to monomial basis */ ierr = PetscLogObjectMemory((PetscObject)pep,nmat*sizeof(Mat)+4*nmat*sizeof(PetscReal)+nmat*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;iA[i] = A[i]; } pep->nmat = nmat; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetOperators" /*@ PEPGetOperators - Gets the matrices associated with the polynomial eigensystem. Not collective, though parallel Mats are returned if the PEP is parallel Input Parameters: + pep - the PEP context - k - the index of the requested matrix (starting in 0) Output Parameter: . A - the requested matrix Level: intermediate .seealso: PEPSolve(), PEPSetOperators(), PEPGetNumMatrices() @*/ PetscErrorCode PEPGetOperators(PEP pep,PetscInt k,Mat *A) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(A,3); if (k<0 || k>=pep->nmat) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",pep->nmat-1); *A = pep->A[k]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetNumMatrices" /*@ PEPGetNumMatrices - Returns the number of matrices stored in the PEP. Not collective Input Parameter: . pep - the PEP context Output Parameters: . nmat - the number of matrices passed in PEPSetOperators() Level: intermediate .seealso: PEPSetOperators() @*/ PetscErrorCode PEPGetNumMatrices(PEP pep,PetscInt *nmat) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(nmat,2); *nmat = pep->nmat; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetInitialSpace" /*@ PEPSetInitialSpace - Specify a basis of vectors that constitute the initial space, that is, the subspace from which the solver starts to iterate. Collective on PEP and Vec Input Parameter: + pep - the polynomial eigensolver context . n - number of vectors - is - set of basis vectors of the initial space Notes: Some solvers start to iterate on a single vector (initial vector). In that case, the other vectors are ignored. These vectors do not persist from one PEPSolve() call to the other, so the initial space should be set every time. The vectors do not need to be mutually orthonormal, since they are explicitly orthonormalized internally. Common usage of this function is when the user can provide a rough approximation of the wanted eigenspace. Then, convergence may be faster. Level: intermediate @*/ PetscErrorCode PEPSetInitialSpace(PEP pep,PetscInt n,Vec *is) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveInt(pep,n,2); if (n<0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative"); ierr = SlepcBasisReference_Private(n,is,&pep->nini,&pep->IS);CHKERRQ(ierr); if (n>0) pep->state = PEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetDimensions_Default" /* PEPSetDimensions_Default - Set reasonable values for ncv, mpd if not set by the user. This is called at setup. */ PetscErrorCode PEPSetDimensions_Default(PEP pep,PetscInt nev,PetscInt *ncv,PetscInt *mpd) { PetscErrorCode ierr; PetscBool krylov; PetscInt dim; PetscFunctionBegin; ierr = PetscObjectTypeCompareAny((PetscObject)pep,&krylov,PEPTOAR,PEPQARNOLDI,"");CHKERRQ(ierr); dim = krylov?(pep->nmat-1)*pep->n:pep->n; if (*ncv) { /* ncv set */ if (krylov) { if (*ncvlineariz? pep->ncv: pep->ncv*(pep->nmat-1)) + extra; requestedbv = pep->ncv + extra; /* oldsize is zero if this is the first time setup is called */ ierr = BVGetSizes(pep->V,NULL,NULL,&oldsize);CHKERRQ(ierr); /* allocate space for eigenvalues and friends */ if (requested != oldsize || !pep->eigr) { if (oldsize) { ierr = PetscFree4(pep->eigr,pep->eigi,pep->errest,pep->perm);CHKERRQ(ierr); } ierr = PetscMalloc4(requested,&pep->eigr,requested,&pep->eigi,requested,&pep->errest,requested,&pep->perm);CHKERRQ(ierr); newc = PetscMax(0,requested-oldsize); cnt = 2*newc*sizeof(PetscScalar) + newc*sizeof(PetscReal) + newc*sizeof(PetscInt); ierr = PetscLogObjectMemory((PetscObject)pep,cnt);CHKERRQ(ierr); } /* allocate V */ if (!pep->V) { ierr = PEPGetBV(pep,&pep->V);CHKERRQ(ierr); } if (!oldsize) { if (!((PetscObject)(pep->V))->type_name) { ierr = BVSetType(pep->V,BVSVEC);CHKERRQ(ierr); } ierr = STMatCreateVecs(pep->st,&t,NULL);CHKERRQ(ierr); ierr = BVSetSizesFromVec(pep->V,t,requestedbv);CHKERRQ(ierr); ierr = VecDestroy(&t);CHKERRQ(ierr); } else { ierr = BVResize(pep->V,requestedbv,PETSC_FALSE);CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/peprefine.c0000644000175000017500000005624613107004621017634 0ustar jromanjroman/* Newton refinement for PEP, simple version. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #define NREF_MAXIT 10 typedef struct { VecScatter *scatter_id,nst; Mat *A; Vec nv,vg,v,w; } PEPSimpNRefctx; typedef struct { Mat M1; Vec M2,M3; PetscScalar M4,m3; } FSubctx; #undef __FUNCT__ #define __FUNCT__ "MatFSMult" static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y) { PetscErrorCode ierr; FSubctx *ctx; PetscScalar t; PetscFunctionBegin; ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); ierr = VecDot(x,ctx->M3,&t);CHKERRQ(ierr); t *= ctx->m3/ctx->M4; ierr = MatMult(ctx->M1,x,y);CHKERRQ(ierr); ierr = VecAXPY(y,-t,ctx->M2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSimpleNRefSetUp" static PetscErrorCode PEPSimpleNRefSetUp(PEP pep,PEPSimpNRefctx **ctx_) { PetscErrorCode ierr; PetscInt i,si,j,n0,m0,nloc,*idx1,*idx2,ne; IS is1,is2; PEPSimpNRefctx *ctx; Vec v; PetscMPIInt rank,size; PetscFunctionBegin; ierr = PetscCalloc1(1,ctx_);CHKERRQ(ierr); ctx = *ctx_; if (pep->npart==1) { pep->refinesubc = NULL; ctx->scatter_id = NULL; ctx->A = pep->A; } else { ierr = PetscMalloc2(pep->nmat,&ctx->A,pep->npart,&ctx->scatter_id);CHKERRQ(ierr); /* Duplicate matrices */ for (i=0;inmat;i++) { ierr = MatCreateRedundantMatrix(pep->A[i],0,PetscSubcommChild(pep->refinesubc),MAT_INITIAL_MATRIX,&ctx->A[i]);CHKERRQ(ierr); } ierr = MatCreateVecs(ctx->A[0],&ctx->v,NULL);CHKERRQ(ierr); /* Create scatters for sending vectors to each subcommucator */ ierr = BVGetColumn(pep->V,0,&v);CHKERRQ(ierr); ierr = VecGetOwnershipRange(v,&n0,&m0);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,0,&v);CHKERRQ(ierr); ierr = VecGetLocalSize(ctx->v,&nloc);CHKERRQ(ierr); ierr = PetscMalloc2(m0-n0,&idx1,m0-n0,&idx2);CHKERRQ(ierr); ierr = VecCreateMPI(PetscObjectComm((PetscObject)pep),nloc,PETSC_DECIDE,&ctx->vg);CHKERRQ(ierr); for (si=0;sinpart;si++) { j = 0; for (i=n0;in*si; } ierr = ISCreateGeneral(PetscObjectComm((PetscObject)pep),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr); ierr = ISCreateGeneral(PetscObjectComm((PetscObject)pep),(m0-n0),idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr); ierr = BVGetColumn(pep->V,0,&v);CHKERRQ(ierr); ierr = VecScatterCreate(v,is1,ctx->vg,is2,&ctx->scatter_id[si]);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,0,&v);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); ierr = ISDestroy(&is2);CHKERRQ(ierr); } ierr = PetscFree2(idx1,idx2);CHKERRQ(ierr); } if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT){ ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)ctx->A[0]),&rank);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)ctx->A[0]),&size);CHKERRQ(ierr); if (size>1) { if (pep->npart==1) { ierr = BVGetColumn(pep->V,0,&v);CHKERRQ(ierr); } else v = ctx->v; ierr = VecGetOwnershipRange(v,&n0,&m0);CHKERRQ(ierr); ne = (rank == size-1)?pep->n:0; ierr = VecCreateMPI(PetscObjectComm((PetscObject)ctx->A[0]),ne,PETSC_DECIDE,&ctx->nv);CHKERRQ(ierr); ierr = PetscMalloc1(m0-n0,&idx1);CHKERRQ(ierr); for (i=n0;inv,is1,&ctx->nst);CHKERRQ(ierr); if (pep->npart==1) { ierr = BVRestoreColumn(pep->V,0,&v);CHKERRQ(ierr); } ierr = PetscFree(idx1);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); } } PetscFunctionReturn(0); } /* Gather Eigenpair idx from subcommunicator with color sc */ #undef __FUNCT__ #define __FUNCT__ "PEPSimpleNRefGatherEigenpair" static PetscErrorCode PEPSimpleNRefGatherEigenpair(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail) { PetscErrorCode ierr; PetscMPIInt nproc,p; MPI_Comm comm=((PetscObject)pep)->comm; Vec v; const PetscScalar *array; PetscFunctionBegin; if (pep->npart>1) { ierr = MPI_Comm_size(comm,&nproc);CHKERRQ(ierr); p = (nproc/pep->npart)*sc+PetscMin(sc,nproc%pep->npart); /* Communicate convergence successful */ ierr = MPI_Bcast(fail,1,MPIU_INT,p,comm);CHKERRQ(ierr); if (!(*fail)) { /* Process 0 of subcommunicator sc broadcasts the eigenvalue */ ierr = MPI_Bcast(&pep->eigr[idx],1,MPIU_SCALAR,p,comm);CHKERRQ(ierr); /* Gather pep->V[idx] from the subcommuniator sc */ ierr = BVGetColumn(pep->V,idx,&v);CHKERRQ(ierr); if (pep->refinesubc->color==sc) { ierr = VecGetArrayRead(ctx->v,&array);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->vg,array);CHKERRQ(ierr); } ierr = VecScatterBegin(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); if (pep->refinesubc->color==sc) { ierr = VecResetArray(ctx->vg);CHKERRQ(ierr); ierr = VecRestoreArrayRead(ctx->v,&array);CHKERRQ(ierr); } ierr = BVRestoreColumn(pep->V,idx,&v);CHKERRQ(ierr); } } else { if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT && !(*fail)) { ierr = MPI_Comm_size(comm,&nproc);CHKERRQ(ierr); p = (nproc/pep->npart)*sc+PetscMin(sc,nproc%pep->npart); ierr = MPI_Bcast(&pep->eigr[idx],1,MPIU_SCALAR,p,comm);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSimpleNRefScatterEigenvector" static PetscErrorCode PEPSimpleNRefScatterEigenvector(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx) { PetscErrorCode ierr; Vec v; const PetscScalar *array; PetscFunctionBegin; if (pep->npart>1) { ierr = BVGetColumn(pep->V,idx,&v);CHKERRQ(ierr); if (pep->refinesubc->color==sc) { ierr = VecGetArrayRead(ctx->v,&array);CHKERRQ(ierr); ierr = VecPlaceArray(ctx->vg,array);CHKERRQ(ierr); } ierr = VecScatterBegin(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); if (pep->refinesubc->color==sc) { ierr = VecResetArray(ctx->vg);CHKERRQ(ierr); ierr = VecRestoreArrayRead(ctx->v,&array);CHKERRQ(ierr); } ierr = BVRestoreColumn(pep->V,idx,&v);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPEvaluateFunctionDerivatives" static PetscErrorCode PEPEvaluateFunctionDerivatives(PEP pep,PetscScalar alpha,PetscScalar *vals) { PetscInt i,nmat=pep->nmat; PetscScalar a0,a1,a2; PetscReal *a=pep->pbc,*b=a+nmat,*g=b+nmat; PetscFunctionBegin; a0 = 0.0; a1 = 1.0; vals[0] = 0.0; if (nmat>1) vals[1] = 1/a[0]; for (i=2;inmat,ml,m0,n0,m1,mg; PetscInt *dnz,*onz,ncols,*cols2=NULL,*nnz; PetscScalar zero=0.0,*coeffs,*coeffs2; PetscMPIInt rank,size; MPI_Comm comm; const PetscInt *cols; const PetscScalar *vals,*array; MatStructure str; FSubctx *fctx; Vec w=ctx->w; Mat M; PetscFunctionBegin; ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = PetscMalloc2(nmat,&coeffs,nmat,&coeffs2);CHKERRQ(ierr); switch (pep->scheme) { case PEP_REFINE_SCHEME_SCHUR: if (ini) { ierr = PetscCalloc1(1,&fctx);CHKERRQ(ierr); ierr = MatGetSize(A[0],&m0,&n0);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)A[0]),PETSC_DECIDE,PETSC_DECIDE,m0,n0,fctx,T);CHKERRQ(ierr); ierr = MatShellSetOperation(*T,MATOP_MULT,(void(*)(void))MatFSMult);CHKERRQ(ierr); } else { ierr = MatShellGetContext(*T,&fctx);CHKERRQ(ierr); } M=fctx->M1; break; case PEP_REFINE_SCHEME_MBE: M=*T; break; case PEP_REFINE_SCHEME_EXPLICIT: M=*Mt; break; } if (ini) { ierr = MatDuplicate(A[0],MAT_COPY_VALUES,&M);CHKERRQ(ierr); } else { ierr = MatCopy(A[0],M,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); } ierr = PEPEvaluateBasis(pep,pep->eigr[idx],0,coeffs,NULL);CHKERRQ(ierr); ierr = MatScale(M,coeffs[0]);CHKERRQ(ierr); for (i=1;ieigr[idx],coeffs2);CHKERRQ(ierr); for (i=0;ischeme) { case PEP_REFINE_SCHEME_EXPLICIT: comm = PetscObjectComm((PetscObject)A[0]); ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr); ierr = MatGetSize(M,&mg,NULL);CHKERRQ(ierr); ierr = MatGetOwnershipRange(M,&m0,&m1);CHKERRQ(ierr); if (ini) { ierr = MatCreate(comm,T);CHKERRQ(ierr); ierr = MatGetLocalSize(M,&ml,NULL);CHKERRQ(ierr); if (rank==size-1) ml++; ierr = MatSetSizes(*T,ml,ml,mg+1,mg+1);CHKERRQ(ierr); ierr = MatSetFromOptions(*T);CHKERRQ(ierr); ierr = MatSetUp(*T);CHKERRQ(ierr); /* Preallocate M */ if (size>1) { ierr = MatPreallocateInitialize(comm,ml,ml,dnz,onz);CHKERRQ(ierr); for (i=m0;i1) { if (rank==size-1) { ierr = PetscMalloc1(pep->n,&cols2);CHKERRQ(ierr); for (i=0;in;i++) cols2[i]=i; } ierr = VecScatterBegin(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecGetArrayRead(ctx->nv,&array);CHKERRQ(ierr); if (rank==size-1) { ierr = MatSetValues(*T,1,&mg,pep->n,cols2,array,INSERT_VALUES);CHKERRQ(ierr); ierr = MatSetValues(*T,1,&mg,1,&mg,&zero,INSERT_VALUES);CHKERRQ(ierr); } ierr = VecRestoreArrayRead(ctx->nv,&array);CHKERRQ(ierr); } else { ierr = PetscMalloc1(m1-m0,&cols2);CHKERRQ(ierr); for (i=0;iM2 = ctx->w; fctx->M3 = v; fctx->m3 = 0.0; for (i=1;im3 += PetscConj(coeffs[i])*coeffs[i]; fctx->M4 = 0.0; for (i=1;iM4 += PetscConj(coeffs[i])*coeffs2[i]; fctx->M1 = M; if (ini) { ierr = MatDuplicate(M,MAT_COPY_VALUES,P);CHKERRQ(ierr); } else { ierr = MatCopy(M,*P,SAME_NONZERO_PATTERN);CHKERRQ(ierr); } ierr = VecConjugate(v);CHKERRQ(ierr); ierr = VecPointwiseMult(t,v,w);CHKERRQ(ierr); ierr = VecConjugate(v);CHKERRQ(ierr); ierr = VecScale(t,-fctx->m3/fctx->M4);CHKERRQ(ierr); ierr = MatDiagonalSet(*P,t,ADD_VALUES);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_MBE: *T = M; *P = M; break; } ierr = PetscFree2(coeffs,coeffs2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPNewtonRefinementSimple" PetscErrorCode PEPNewtonRefinementSimple(PEP pep,PetscInt *maxits,PetscReal tol,PetscInt k) { PetscErrorCode ierr; PetscInt i,n,its,idx=0,*idx_sc,*its_sc,color,*fail_sc; PetscMPIInt rank,size; Mat Mt=NULL,T=NULL,P=NULL; MPI_Comm comm; Vec r,v,dv,rr=NULL,dvv=NULL,t[2]; PetscScalar *array2,deig=0.0,tt[2],ttt; const PetscScalar *array; PetscReal norm,error; PetscBool ini=PETSC_TRUE,sc_pend,solved=PETSC_FALSE; PEPSimpNRefctx *ctx; FSubctx *fctx=NULL; KSPConvergedReason reason; PetscFunctionBegin; ierr = PetscLogEventBegin(PEP_Refine,pep,0,0,0);CHKERRQ(ierr); ierr = PEPSimpleNRefSetUp(pep,&ctx);CHKERRQ(ierr); its = (maxits)?*maxits:NREF_MAXIT; if (!pep->refineksp) { ierr = PEPRefineGetKSP(pep,&pep->refineksp);CHKERRQ(ierr); } comm = (pep->npart==1)?PetscObjectComm((PetscObject)pep):PetscSubcommChild(pep->refinesubc); if (pep->npart==1) { ierr = BVGetColumn(pep->V,0,&v);CHKERRQ(ierr); } else v = ctx->v; ierr = VecDuplicate(v,&ctx->w);CHKERRQ(ierr); ierr = VecDuplicate(v,&r);CHKERRQ(ierr); ierr = VecDuplicate(v,&dv);CHKERRQ(ierr); ierr = VecDuplicate(v,&t[0]);CHKERRQ(ierr); ierr = VecDuplicate(v,&t[1]);CHKERRQ(ierr); if (pep->npart==1) { ierr = BVRestoreColumn(pep->V,0,&v);CHKERRQ(ierr); } ierr = MPI_Comm_size(comm,&size);CHKERRQ(ierr); ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr); ierr = VecGetLocalSize(r,&n);CHKERRQ(ierr); ierr = PetscMalloc3(pep->npart,&idx_sc,pep->npart,&its_sc,pep->npart,&fail_sc);CHKERRQ(ierr); for (i=0;inpart;i++) fail_sc[i] = 0; for (i=0;inpart;i++) its_sc[i] = 0; color = (pep->npart==1)?0:pep->refinesubc->color; /* Loop performing iterative refinements */ while (!solved) { for (i=0;inpart;i++) { sc_pend = PETSC_TRUE; if (its_sc[i]==0) { idx_sc[i] = idx++; if (idx_sc[i]>=k) { sc_pend = PETSC_FALSE; } else { ierr = PEPSimpleNRefScatterEigenvector(pep,ctx,i,idx_sc[i]);CHKERRQ(ierr); } } else { /* Gather Eigenpair from subcommunicator i */ ierr = PEPSimpleNRefGatherEigenpair(pep,ctx,i,idx_sc[i],&fail_sc[i]);CHKERRQ(ierr); } while (sc_pend) { if (!fail_sc[i]) { ierr = PEPComputeError(pep,idx_sc[i],PEP_ERROR_BACKWARD,&error);CHKERRQ(ierr); } if (error<=tol || its_sc[i]>=its || fail_sc[i]) { idx_sc[i] = idx++; its_sc[i] = 0; if (idx_sc[i]=k) sc_pend = PETSC_FALSE; } } solved = PETSC_TRUE; for (i=0;inpart&&solved;i++) solved = PetscNot(idx_sc[i]eigi[idx_sc[color]]!=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),1,"Simple Refinement not implemented in real scalars for complex eigenvalues"); #endif if (pep->npart==1) { ierr = BVGetColumn(pep->V,idx_sc[color],&v);CHKERRQ(ierr); } else v = ctx->v; ierr = PEPSimpleNRefSetUpSystem(pep,ctx->A,ctx,idx_sc[color],&Mt,&T,&P,ini,t[0],v);CHKERRQ(ierr); ierr = KSPSetOperators(pep->refineksp,T,P);CHKERRQ(ierr); if (ini) { ierr = KSPSetFromOptions(pep->refineksp);CHKERRQ(ierr); if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) { ierr = MatCreateVecs(T,&dvv,NULL);CHKERRQ(ierr); ierr = VecDuplicate(dvv,&rr);CHKERRQ(ierr); } ini = PETSC_FALSE; } switch (pep->scheme) { case PEP_REFINE_SCHEME_EXPLICIT: ierr = MatMult(Mt,v,r);CHKERRQ(ierr); ierr = VecGetArrayRead(r,&array);CHKERRQ(ierr); if (rank==size-1) { ierr = VecGetArray(rr,&array2);CHKERRQ(ierr); ierr = PetscMemcpy(array2,array,n*sizeof(PetscScalar));CHKERRQ(ierr); array2[n] = 0.0; ierr = VecRestoreArray(rr,&array2);CHKERRQ(ierr); } else { ierr = VecPlaceArray(rr,array);CHKERRQ(ierr); } ierr = KSPSolve(pep->refineksp,rr,dvv);CHKERRQ(ierr); ierr = KSPGetConvergedReason(pep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { if (rank != size-1) { ierr = VecResetArray(rr);CHKERRQ(ierr); } ierr = VecRestoreArrayRead(r,&array);CHKERRQ(ierr); ierr = VecGetArrayRead(dvv,&array);CHKERRQ(ierr); ierr = VecPlaceArray(dv,array);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,dv);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); ierr = VecResetArray(dv);CHKERRQ(ierr); if (rank==size-1) pep->eigr[idx_sc[color]] -= array[n]; ierr = VecRestoreArrayRead(dvv,&array);CHKERRQ(ierr); } else fail_sc[color] = 1; break; case PEP_REFINE_SCHEME_MBE: ierr = MatMult(T,v,r);CHKERRQ(ierr); /* Mixed block elimination */ ierr = VecConjugate(v);CHKERRQ(ierr); ierr = KSPSolveTranspose(pep->refineksp,v,t[0]);CHKERRQ(ierr); ierr = KSPGetConvergedReason(pep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecConjugate(t[0]);CHKERRQ(ierr); ierr = VecDot(ctx->w,t[0],&tt[0]);CHKERRQ(ierr); ierr = KSPSolve(pep->refineksp,ctx->w,t[1]);CHKERRQ(ierr); ierr = KSPGetConvergedReason(pep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecDot(t[1],v,&tt[1]);CHKERRQ(ierr); ierr = VecDot(r,t[0],&ttt);CHKERRQ(ierr); tt[0] = ttt/tt[0]; ierr = VecAXPY(r,-tt[0],ctx->w);CHKERRQ(ierr); ierr = KSPSolve(pep->refineksp,r,dv);CHKERRQ(ierr); ierr = KSPGetConvergedReason(pep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecDot(dv,v,&ttt);CHKERRQ(ierr); tt[1] = ttt/tt[1]; ierr = VecAXPY(dv,-tt[1],t[1]);CHKERRQ(ierr); deig = tt[0]+tt[1]; } } ierr = VecConjugate(v);CHKERRQ(ierr); ierr = VecAXPY(v,-1.0,dv);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); pep->eigr[idx_sc[color]] -= deig; fail_sc[color] = 0; } else { ierr = VecConjugate(v);CHKERRQ(ierr); fail_sc[color] = 1; } break; case PEP_REFINE_SCHEME_SCHUR: ierr = MatShellGetContext(T,&fctx);CHKERRQ(ierr); ierr = MatMult(fctx->M1,v,r);CHKERRQ(ierr); ierr = KSPSolve(pep->refineksp,r,dv);CHKERRQ(ierr); ierr = KSPGetConvergedReason(pep->refineksp,&reason);CHKERRQ(ierr); if (reason>0) { ierr = VecDot(dv,v,&deig);CHKERRQ(ierr); deig *= -fctx->m3/fctx->M4; ierr = VecAXPY(v,-1.0,dv);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&norm);CHKERRQ(ierr); ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); pep->eigr[idx_sc[color]] -= deig; fail_sc[color] = 0; } else fail_sc[color] = 1; break; } if (pep->npart==1) { ierr = BVRestoreColumn(pep->V,idx_sc[color],&v);CHKERRQ(ierr); } } } ierr = VecDestroy(&t[0]);CHKERRQ(ierr); ierr = VecDestroy(&t[1]);CHKERRQ(ierr); ierr = VecDestroy(&dv);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w);CHKERRQ(ierr); ierr = VecDestroy(&r);CHKERRQ(ierr); ierr = PetscFree3(idx_sc,its_sc,fail_sc);CHKERRQ(ierr); ierr = VecScatterDestroy(&ctx->nst);CHKERRQ(ierr); if (pep->npart>1) { ierr = VecDestroy(&ctx->vg);CHKERRQ(ierr); ierr = VecDestroy(&ctx->v);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = MatDestroy(&ctx->A[i]);CHKERRQ(ierr); } for (i=0;inpart;i++) { ierr = VecScatterDestroy(&ctx->scatter_id[i]);CHKERRQ(ierr); } ierr = PetscFree2(ctx->A,ctx->scatter_id);CHKERRQ(ierr); } if (fctx && pep->scheme==PEP_REFINE_SCHEME_SCHUR) { ierr = MatDestroy(&P);CHKERRQ(ierr); ierr = MatDestroy(&fctx->M1);CHKERRQ(ierr); ierr = PetscFree(fctx);CHKERRQ(ierr); } if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) { ierr = MatDestroy(&Mt);CHKERRQ(ierr); ierr = VecDestroy(&dvv);CHKERRQ(ierr); ierr = VecDestroy(&rr);CHKERRQ(ierr); ierr = VecDestroy(&ctx->nv);CHKERRQ(ierr); } ierr = MatDestroy(&T);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); ierr = PetscLogEventEnd(PEP_Refine,pep,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/pepview.c.html0000644000175000017500000016647613107004621020310 0ustar jromanjroman
Actual source code: pepview.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    The PEP routines related to various viewers.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>      /*I "slepcpep.h" I*/
 25: #include <petscdraw.h>

 29: /*@C
 30:    PEPView - Prints the PEP data structure.

 32:    Collective on PEP

 34:    Input Parameters:
 35: +  pep - the polynomial eigenproblem solver context
 36: -  viewer - optional visualization context

 38:    Options Database Key:
 39: .  -pep_view -  Calls PEPView() at end of PEPSolve()

 41:    Note:
 42:    The available visualization contexts include
 43: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
 44: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
 45:          output where only the first processor opens
 46:          the file.  All other processors send their
 47:          data to the first processor to print.

 49:    The user can open an alternative visualization context with
 50:    PetscViewerASCIIOpen() - output to a specified file.

 52:    Level: beginner

 54: .seealso: PetscViewerASCIIOpen()
 55: @*/
 56: PetscErrorCode PEPView(PEP pep,PetscViewer viewer)
 57: {
 59:   const char     *type;
 60:   char           str[50];
 61:   PetscBool      isascii,islinear,istrivial;
 62:   PetscInt       i;
 63:   PetscViewer    sviewer;

 67:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep));

 71: #if defined(PETSC_USE_COMPLEX)
 72: #define HERM "hermitian"
 73: #else
 74: #define HERM "symmetric"
 75: #endif
 76:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
 77:   if (isascii) {
 78:     PetscObjectPrintClassNamePrefixType((PetscObject)pep,viewer);
 79:     if (pep->ops->view) {
 80:       PetscViewerASCIIPushTab(viewer);
 81:       (*pep->ops->view)(pep,viewer);
 82:       PetscViewerASCIIPopTab(viewer);
 83:     }
 84:     if (pep->problem_type) {
 85:       switch (pep->problem_type) {
 86:         case PEP_GENERAL:    type = "general polynomial eigenvalue problem"; break;
 87:         case PEP_HERMITIAN:  type = HERM " polynomial eigenvalue problem"; break;
 88:         case PEP_GYROSCOPIC: type = "gyroscopic polynomial eigenvalue problem"; break;
 89:         default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of pep->problem_type");
 90:       }
 91:     } else type = "not yet set";
 92:     PetscViewerASCIIPrintf(viewer,"  problem type: %s\n",type);
 93:     PetscViewerASCIIPrintf(viewer,"  polynomial represented in %s basis\n",PEPBasisTypes[pep->basis]);
 94:     switch (pep->scale) {
 95:       case PEP_SCALE_NONE:
 96:         break;
 97:       case PEP_SCALE_SCALAR:
 98:         PetscViewerASCIIPrintf(viewer,"  parameter scaling enabled, with scaling factor=%g\n",(double)pep->sfactor);
 99:         break;
100:       case PEP_SCALE_DIAGONAL:
101:         PetscViewerASCIIPrintf(viewer,"  diagonal balancing enabled, with its=%D and lambda=%g\n",pep->sits,(double)pep->slambda);
102:         break;
103:       case PEP_SCALE_BOTH:
104:         PetscViewerASCIIPrintf(viewer,"  parameter scaling & diagonal balancing enabled, with scaling factor=%g, its=%D and lambda=%g\n",(double)pep->sfactor,pep->sits,(double)pep->slambda);
105:         break;
106:     }
107:     PetscViewerASCIIPrintf(viewer,"  selected portion of the spectrum: ");
108:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
109:     SlepcSNPrintfScalar(str,50,pep->target,PETSC_FALSE);
110:     if (!pep->which) {
111:       PetscViewerASCIIPrintf(viewer,"not yet set\n");
112:     } else switch (pep->which) {
113:       case PEP_WHICH_USER:
114:         PetscViewerASCIIPrintf(viewer,"user defined\n");
115:         break;
116:       case PEP_TARGET_MAGNITUDE:
117:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (in magnitude)\n",str);
118:         break;
119:       case PEP_TARGET_REAL:
120:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the real axis)\n",str);
121:         break;
122:       case PEP_TARGET_IMAGINARY:
123:         PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the imaginary axis)\n",str);
124:         break;
125:       case PEP_LARGEST_MAGNITUDE:
126:         PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");
127:         break;
128:       case PEP_SMALLEST_MAGNITUDE:
129:         PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");
130:         break;
131:       case PEP_LARGEST_REAL:
132:         PetscViewerASCIIPrintf(viewer,"largest real parts\n");
133:         break;
134:       case PEP_SMALLEST_REAL:
135:         PetscViewerASCIIPrintf(viewer,"smallest real parts\n");
136:         break;
137:       case PEP_LARGEST_IMAGINARY:
138:         PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");
139:         break;
140:       case PEP_SMALLEST_IMAGINARY:
141:         PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");
142:         break;
143:       default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of pep->which");
144:     }
145:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
146:     PetscViewerASCIIPrintf(viewer,"  number of eigenvalues (nev): %D\n",pep->nev);
147:     PetscViewerASCIIPrintf(viewer,"  number of column vectors (ncv): %D\n",pep->ncv);
148:     PetscViewerASCIIPrintf(viewer,"  maximum dimension of projected problem (mpd): %D\n",pep->mpd);
149:     PetscViewerASCIIPrintf(viewer,"  maximum number of iterations: %D\n",pep->max_it);
150:     PetscViewerASCIIPrintf(viewer,"  tolerance: %g\n",(double)pep->tol);
151:     PetscViewerASCIIPrintf(viewer,"  convergence test: ");
152:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
153:     switch (pep->conv) {
154:     case PEP_CONV_ABS:
155:       PetscViewerASCIIPrintf(viewer,"absolute\n");break;
156:     case PEP_CONV_REL:
157:       PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue\n");break;
158:     case PEP_CONV_NORM:
159:       PetscViewerASCIIPrintf(viewer,"relative to the matrix norms\n");
160:       if (pep->nrma) {
161:         PetscViewerASCIIPrintf(viewer,"  computed matrix norms: %g",(double)pep->nrma[0]);
162:         for (i=1;i<pep->nmat;i++) {
163:           PetscViewerASCIIPrintf(viewer,", %g",(double)pep->nrma[i]);
164:         }
165:         PetscViewerASCIIPrintf(viewer,"\n");
166:       }
167:       break;
168:     case PEP_CONV_USER:
169:       PetscViewerASCIIPrintf(viewer,"user-defined\n");break;
170:     }
171:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
172:     PetscViewerASCIIPrintf(viewer,"  extraction type: %s\n",PEPExtractTypes[pep->extract]);
173:     if (pep->refine) {
174:       PetscViewerASCIIPrintf(viewer,"  iterative refinement: %s, with %s scheme\n",PEPRefineTypes[pep->refine],PEPRefineSchemes[pep->scheme]);
175:       PetscViewerASCIIPrintf(viewer,"  refinement stopping criterion: tol=%g, its=%D\n",(double)pep->rtol,pep->rits);
176:       if (pep->npart>1) {
177:         PetscViewerASCIIPrintf(viewer,"  splitting communicator in %D partitions for refinement\n",pep->npart);
178:       }
179:     }
180:     if (pep->nini) {
181:       PetscViewerASCIIPrintf(viewer,"  dimension of user-provided initial space: %D\n",PetscAbs(pep->nini));
182:     }
183:   } else {
184:     if (pep->ops->view) {
185:       (*pep->ops->view)(pep,viewer);
186:     }
187:   }
188:   PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);
189:   if (!pep->V) { PEPGetBV(pep,&pep->V); }
190:   BVView(pep->V,viewer);
191:   if (!pep->rg) { PEPGetRG(pep,&pep->rg); }
192:   RGIsTrivial(pep->rg,&istrivial);
193:   if (!istrivial) { RGView(pep->rg,viewer); }
194:   PetscObjectTypeCompare((PetscObject)pep,PEPLINEAR,&islinear);
195:   if (!islinear) {
196:     if (!pep->ds) { PEPGetDS(pep,&pep->ds); }
197:     DSView(pep->ds,viewer);
198:   }
199:   PetscViewerPopFormat(viewer);
200:   if (!pep->st) { PEPGetST(pep,&pep->st); }
201:   STView(pep->st,viewer);
202:   if (pep->refine!=PEP_REFINE_NONE) {
203:     if (pep->npart>1) {
204:       if (pep->refinesubc->color==0) {
205:         PetscViewerASCIIGetStdout(PetscSubcommChild(pep->refinesubc),&sviewer);
206:         KSPView(pep->refineksp,sviewer);
207:       }
208:     } else {
209:       KSPView(pep->refineksp,viewer);
210:     }
211:   } 
212:   return(0);
213: }

217: /*@C
218:    PEPReasonView - Displays the reason a PEP solve converged or diverged.

220:    Collective on PEP

222:    Parameter:
223: +  pep - the eigensolver context
224: -  viewer - the viewer to display the reason

226:    Options Database Keys:
227: .  -pep_converged_reason - print reason for convergence, and number of iterations

229:    Level: intermediate

231: .seealso: PEPSetConvergenceTest(), PEPSetTolerances(), PEPGetIterationNumber()
232: @*/
233: PetscErrorCode PEPReasonView(PEP pep,PetscViewer viewer)
234: {
236:   PetscBool      isAscii;

239:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);
240:   if (isAscii) {
241:     PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);
242:     if (pep->reason > 0) {
243:       PetscViewerASCIIPrintf(viewer,"%s Polynomial eigensolve converged (%D eigenpair%s) due to %s; iterations %D\n",((PetscObject)pep)->prefix?((PetscObject)pep)->prefix:"",pep->nconv,(pep->nconv>1)?"s":"",PEPConvergedReasons[pep->reason],pep->its);
244:     } else {
245:       PetscViewerASCIIPrintf(viewer,"%s Polynomial eigensolve did not converge due to %s; iterations %D\n",((PetscObject)pep)->prefix?((PetscObject)pep)->prefix:"",PEPConvergedReasons[pep->reason],pep->its);
246:     }
247:     PetscViewerASCIISubtractTab(viewer,((PetscObject)pep)->tablevel);
248:   }
249:   return(0);
250: }

254: /*@
255:    PEPReasonViewFromOptions - Processes command line options to determine if/how
256:    the PEP converged reason is to be viewed. 

258:    Collective on PEP

260:    Input Parameters:
261: .  pep - the eigensolver context

263:    Level: developer
264: @*/
265: PetscErrorCode PEPReasonViewFromOptions(PEP pep)
266: {
267:   PetscErrorCode    ierr;
268:   PetscViewer       viewer;
269:   PetscBool         flg;
270:   static PetscBool  incall = PETSC_FALSE;
271:   PetscViewerFormat format;

274:   if (incall) return(0);
275:   incall = PETSC_TRUE;
276:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_converged_reason",&viewer,&format,&flg);
277:   if (flg) {
278:     PetscViewerPushFormat(viewer,format);
279:     PEPReasonView(pep,viewer);
280:     PetscViewerPopFormat(viewer);
281:     PetscViewerDestroy(&viewer);
282:   }
283:   incall = PETSC_FALSE;
284:   return(0);
285: }

289: static PetscErrorCode PEPErrorView_ASCII(PEP pep,PEPErrorType etype,PetscViewer viewer)
290: {
291:   PetscBool      errok;
292:   PetscReal      error,re,im;
293:   PetscScalar    kr,ki;
294:   PetscInt       i,j;

298:   if (pep->nconv<pep->nev) {
299:     PetscViewerASCIIPrintf(viewer," Problem: less than %D eigenvalues converged\n\n",pep->nev);
300:     return(0);
301:   }
302:   errok = PETSC_TRUE;
303:   for (i=0;i<pep->nev;i++) {
304:     PEPComputeError(pep,i,etype,&error);
305:     errok = (errok && error<5.0*pep->tol)? PETSC_TRUE: PETSC_FALSE;
306:   }
307:   if (!errok) {
308:     PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",pep->nev);
309:     return(0);
310:   }
311:   PetscViewerASCIIPrintf(viewer," All requested eigenvalues computed up to the required tolerance:");
312:   for (i=0;i<=(pep->nev-1)/8;i++) {
313:     PetscViewerASCIIPrintf(viewer,"\n     ");
314:     for (j=0;j<PetscMin(8,pep->nev-8*i);j++) {
315:       PEPGetEigenpair(pep,8*i+j,&kr,&ki,NULL,NULL);
316: #if defined(PETSC_USE_COMPLEX)
317:       re = PetscRealPart(kr);
318:       im = PetscImaginaryPart(kr);
319: #else
320:       re = kr;
321:       im = ki;
322: #endif
323:       if (PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0;
324:       if (PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0;
325:       if (im!=0.0) {
326:         PetscViewerASCIIPrintf(viewer,"%.5f%+.5fi",(double)re,(double)im);
327:       } else {
328:         PetscViewerASCIIPrintf(viewer,"%.5f",(double)re);
329:       }
330:       if (8*i+j+1<pep->nev) { PetscViewerASCIIPrintf(viewer,", "); }
331:     }
332:   }
333:   PetscViewerASCIIPrintf(viewer,"\n\n");
334:   return(0);
335: }

339: static PetscErrorCode PEPErrorView_DETAIL(PEP pep,PEPErrorType etype,PetscViewer viewer)
340: {
342:   PetscReal      error,re,im;
343:   PetscScalar    kr,ki;
344:   PetscInt       i;
345: #define EXLEN 30
346:   char           ex[EXLEN],sep[]=" ---------------------- --------------------\n";

349:   if (!pep->nconv) return(0);
350:   switch (etype) {
351:     case PEP_ERROR_ABSOLUTE:
352:       PetscSNPrintf(ex,EXLEN,"   ||P(k)x||");
353:       break;
354:     case PEP_ERROR_RELATIVE:
355:       PetscSNPrintf(ex,EXLEN,"||P(k)x||/||kx||");
356:       break;
357:     case PEP_ERROR_BACKWARD:
358:       PetscSNPrintf(ex,EXLEN,"    eta(x,k)");
359:       break;
360:   }
361:   PetscViewerASCIIPrintf(viewer,"%s            k             %s\n%s",sep,ex,sep);
362:   for (i=0;i<pep->nconv;i++) {
363:     PEPGetEigenpair(pep,i,&kr,&ki,NULL,NULL);
364:     PEPComputeError(pep,i,etype,&error);
365: #if defined(PETSC_USE_COMPLEX)
366:     re = PetscRealPart(kr);
367:     im = PetscImaginaryPart(kr);
368: #else
369:     re = kr;
370:     im = ki;
371: #endif
372:     if (im!=0.0) {
373:       PetscViewerASCIIPrintf(viewer,"  % 9f%+9fi      %12g\n",(double)re,(double)im,(double)error);
374:     } else {
375:       PetscViewerASCIIPrintf(viewer,"    % 12f           %12g\n",(double)re,(double)error);
376:     }
377:   }
378:   PetscViewerASCIIPrintf(viewer,sep);
379:   return(0);
380: }

384: static PetscErrorCode PEPErrorView_MATLAB(PEP pep,PEPErrorType etype,PetscViewer viewer)
385: {
387:   PetscReal      error;
388:   PetscInt       i;
389:   const char     *name;

392:   PetscObjectGetName((PetscObject)pep,&name);
393:   PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);
394:   for (i=0;i<pep->nconv;i++) {
395:     PEPComputeError(pep,i,etype,&error);
396:     PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);
397:   }
398:   PetscViewerASCIIPrintf(viewer,"];\n");
399:   return(0);
400: }

404: /*@C
405:    PEPErrorView - Displays the errors associated with the computed solution
406:    (as well as the eigenvalues).

408:    Collective on PEP

410:    Input Parameters:
411: +  pep    - the eigensolver context
412: .  etype  - error type
413: -  viewer - optional visualization context

415:    Options Database Key:
416: +  -pep_error_absolute - print absolute errors of each eigenpair
417: .  -pep_error_relative - print relative errors of each eigenpair
418: -  -pep_error_backward - print backward errors of each eigenpair

420:    Notes:
421:    By default, this function checks the error of all eigenpairs and prints
422:    the eigenvalues if all of them are below the requested tolerance.
423:    If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with
424:    eigenvalues and corresponding errors is printed.

426:    Level: intermediate

428: .seealso: PEPSolve(), PEPValuesView(), PEPVectorsView()
429: @*/
430: PetscErrorCode PEPErrorView(PEP pep,PEPErrorType etype,PetscViewer viewer)
431: {
432:   PetscBool         isascii;
433:   PetscViewerFormat format;
434:   PetscErrorCode    ierr;

438:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep));
441:   PEPCheckSolved(pep,1);
442:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
443:   if (!isascii) return(0);

445:   PetscViewerGetFormat(viewer,&format);
446:   switch (format) {
447:     case PETSC_VIEWER_DEFAULT:
448:     case PETSC_VIEWER_ASCII_INFO:
449:       PEPErrorView_ASCII(pep,etype,viewer);
450:       break;
451:     case PETSC_VIEWER_ASCII_INFO_DETAIL:
452:       PEPErrorView_DETAIL(pep,etype,viewer);
453:       break;
454:     case PETSC_VIEWER_ASCII_MATLAB:
455:       PEPErrorView_MATLAB(pep,etype,viewer);
456:       break;
457:     default:
458:       PetscInfo1(pep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
459:   }
460:   return(0);
461: }

465: /*@
466:    PEPErrorViewFromOptions - Processes command line options to determine if/how
467:    the errors of the computed solution are to be viewed. 

469:    Collective on PEP

471:    Input Parameters:
472: .  pep - the eigensolver context

474:    Level: developer
475: @*/
476: PetscErrorCode PEPErrorViewFromOptions(PEP pep)
477: {
478:   PetscErrorCode    ierr;
479:   PetscViewer       viewer;
480:   PetscBool         flg;
481:   static PetscBool  incall = PETSC_FALSE;
482:   PetscViewerFormat format;

485:   if (incall) return(0);
486:   incall = PETSC_TRUE;
487:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_error_absolute",&viewer,&format,&flg);
488:   if (flg) {
489:     PetscViewerPushFormat(viewer,format);
490:     PEPErrorView(pep,PEP_ERROR_ABSOLUTE,viewer);
491:     PetscViewerPopFormat(viewer);
492:     PetscViewerDestroy(&viewer);
493:   }
494:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_error_relative",&viewer,&format,&flg);
495:   if (flg) {
496:     PetscViewerPushFormat(viewer,format);
497:     PEPErrorView(pep,PEP_ERROR_RELATIVE,viewer);
498:     PetscViewerPopFormat(viewer);
499:     PetscViewerDestroy(&viewer);
500:   }
501:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_error_backward",&viewer,&format,&flg);
502:   if (flg) {
503:     PetscViewerPushFormat(viewer,format);
504:     PEPErrorView(pep,PEP_ERROR_BACKWARD,viewer);
505:     PetscViewerPopFormat(viewer);
506:     PetscViewerDestroy(&viewer);
507:   }
508:   incall = PETSC_FALSE;
509:   return(0);
510: }

514: static PetscErrorCode PEPValuesView_DRAW(PEP pep,PetscViewer viewer)
515: {
517:   PetscDraw      draw;
518:   PetscDrawSP    drawsp;
519:   PetscReal      re,im;
520:   PetscInt       i,k;

523:   if (!pep->nconv) return(0);
524:   PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed Eigenvalues",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);
525:   PetscViewerDrawGetDraw(viewer,0,&draw);
526:   PetscDrawSPCreate(draw,1,&drawsp);
527:   for (i=0;i<pep->nconv;i++) {
528:     k = pep->perm[i];
529: #if defined(PETSC_USE_COMPLEX)
530:     re = PetscRealPart(pep->eigr[k]);
531:     im = PetscImaginaryPart(pep->eigr[k]);
532: #else
533:     re = pep->eigr[k];
534:     im = pep->eigi[k];
535: #endif
536:     PetscDrawSPAddPoint(drawsp,&re,&im);
537:   }
538:   PetscDrawSPDraw(drawsp,PETSC_TRUE);
539:   PetscDrawSPSave(drawsp);
540:   PetscDrawSPDestroy(&drawsp);
541:   PetscViewerDestroy(&viewer);
542:   return(0);
543: }

547: static PetscErrorCode PEPValuesView_ASCII(PEP pep,PetscViewer viewer)
548: {
549:   PetscReal      re,im;
550:   PetscInt       i,k;

554:   PetscViewerASCIIPrintf(viewer,"Eigenvalues = \n");
555:   for (i=0;i<pep->nconv;i++) {
556:     k = pep->perm[i];
557: #if defined(PETSC_USE_COMPLEX)
558:     re = PetscRealPart(pep->eigr[k]);
559:     im = PetscImaginaryPart(pep->eigr[k]);
560: #else
561:     re = pep->eigr[k];
562:     im = pep->eigi[k];
563: #endif
564:     if (PetscAbs(re)/PetscAbs(im)<PETSC_SMALL) re = 0.0;
565:     if (PetscAbs(im)/PetscAbs(re)<PETSC_SMALL) im = 0.0;
566:     if (im!=0.0) {
567:       PetscViewerASCIIPrintf(viewer,"   %.5f%+.5fi\n",(double)re,(double)im);
568:     } else {
569:       PetscViewerASCIIPrintf(viewer,"   %.5f\n",(double)re);
570:     }
571:   }
572:   PetscViewerASCIIPrintf(viewer,"\n");
573:   return(0);
574: }

578: static PetscErrorCode PEPValuesView_MATLAB(PEP pep,PetscViewer viewer)
579: {
581:   PetscInt       i,k;
582:   PetscReal      re,im;
583:   const char     *name;

586:   PetscObjectGetName((PetscObject)pep,&name);
587:   PetscViewerASCIIPrintf(viewer,"Lambda_%s = [\n",name);
588:   for (i=0;i<pep->nconv;i++) {
589:     k = pep->perm[i];
590: #if defined(PETSC_USE_COMPLEX)
591:     re = PetscRealPart(pep->eigr[k]);
592:     im = PetscImaginaryPart(pep->eigr[k]);
593: #else
594:     re = pep->eigr[k];
595:     im = pep->eigi[k];
596: #endif
597:     if (im!=0.0) {
598:       PetscViewerASCIIPrintf(viewer,"%18.16e%+18.16ei\n",(double)re,(double)im);
599:     } else {
600:       PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)re);
601:     }
602:   }
603:   PetscViewerASCIIPrintf(viewer,"];\n");
604:   return(0);
605: }

609: /*@C
610:    PEPValuesView - Displays the computed eigenvalues in a viewer.

612:    Collective on PEP

614:    Input Parameters:
615: +  pep    - the eigensolver context
616: -  viewer - the viewer

618:    Options Database Key:
619: .  -pep_view_values - print computed eigenvalues

621:    Level: intermediate

623: .seealso: PEPSolve(), PEPVectorsView(), PEPErrorView()
624: @*/
625: PetscErrorCode PEPValuesView(PEP pep,PetscViewer viewer)
626: {
627:   PetscBool         isascii,isdraw;
628:   PetscViewerFormat format;
629:   PetscErrorCode    ierr;

633:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep));
636:   PEPCheckSolved(pep,1);
637:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);
638:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
639:   if (isdraw) {
640:     PEPValuesView_DRAW(pep,viewer);
641:   } else if (isascii) {
642:     PetscViewerGetFormat(viewer,&format);
643:     switch (format) {
644:       case PETSC_VIEWER_DEFAULT:
645:       case PETSC_VIEWER_ASCII_INFO:
646:       case PETSC_VIEWER_ASCII_INFO_DETAIL:
647:         PEPValuesView_ASCII(pep,viewer);
648:         break;
649:       case PETSC_VIEWER_ASCII_MATLAB:
650:         PEPValuesView_MATLAB(pep,viewer);
651:         break;
652:       default:
653:         PetscInfo1(pep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);
654:     }
655:   }
656:   return(0);
657: }

661: /*@
662:    PEPValuesViewFromOptions - Processes command line options to determine if/how
663:    the computed eigenvalues are to be viewed. 

665:    Collective on PEP

667:    Input Parameters:
668: .  pep - the eigensolver context

670:    Level: developer
671: @*/
672: PetscErrorCode PEPValuesViewFromOptions(PEP pep)
673: {
674:   PetscErrorCode    ierr;
675:   PetscViewer       viewer;
676:   PetscBool         flg;
677:   static PetscBool  incall = PETSC_FALSE;
678:   PetscViewerFormat format;

681:   if (incall) return(0);
682:   incall = PETSC_TRUE;
683:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_view_values",&viewer,&format,&flg);
684:   if (flg) {
685:     PetscViewerPushFormat(viewer,format);
686:     PEPValuesView(pep,viewer);
687:     PetscViewerPopFormat(viewer);
688:     PetscViewerDestroy(&viewer);
689:   }
690:   incall = PETSC_FALSE;
691:   return(0);
692: }

696: /*@C
697:    PEPVectorsView - Outputs computed eigenvectors to a viewer.

699:    Collective on PEP

701:    Parameter:
702: +  pep    - the eigensolver context
703: -  viewer - the viewer

705:    Options Database Keys:
706: .  -pep_view_vectors - output eigenvectors.

708:    Note:
709:    If PETSc was configured with real scalars, complex conjugate eigenvectors
710:    will be viewed as two separate real vectors, one containing the real part
711:    and another one containing the imaginary part.

713:    Level: intermediate

715: .seealso: PEPSolve(), PEPValuesView(), PEPErrorView()
716: @*/
717: PetscErrorCode PEPVectorsView(PEP pep,PetscViewer viewer)
718: {
720:   PetscInt       i,k;
721:   Vec            x;
722: #define NMLEN 30
723:   char           vname[NMLEN];
724:   const char     *ename;

728:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep));
731:   PEPCheckSolved(pep,1);
732:   if (pep->nconv) {
733:     PetscObjectGetName((PetscObject)pep,&ename);
734:     PEPComputeVectors(pep);
735:     for (i=0;i<pep->nconv;i++) {
736:       k = pep->perm[i];
737:       PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);
738:       BVGetColumn(pep->V,k,&x);
739:       PetscObjectSetName((PetscObject)x,vname);
740:       VecView(x,viewer);
741:       BVRestoreColumn(pep->V,k,&x);
742:     }
743:   }
744:   return(0);
745: }

749: /*@
750:    PEPVectorsViewFromOptions - Processes command line options to determine if/how
751:    the computed eigenvectors are to be viewed. 

753:    Collective on PEP

755:    Input Parameters:
756: .  pep - the eigensolver context

758:    Level: developer
759: @*/
760: PetscErrorCode PEPVectorsViewFromOptions(PEP pep)
761: {
762:   PetscErrorCode    ierr;
763:   PetscViewer       viewer;
764:   PetscBool         flg = PETSC_FALSE;
765:   static PetscBool  incall = PETSC_FALSE;
766:   PetscViewerFormat format;

769:   if (incall) return(0);
770:   incall = PETSC_TRUE;
771:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_view_vectors",&viewer,&format,&flg);
772:   if (flg) {
773:     PetscViewerPushFormat(viewer,format);
774:     PEPVectorsView(pep,viewer);
775:     PetscViewerPopFormat(viewer);
776:     PetscViewerDestroy(&viewer);
777:   }
778:   incall = PETSC_FALSE;
779:   return(0);
780: }

slepc-3.7.4/src/pep/interface/dlregispep.c.html0000644000175000017500000003031713107004621020747 0ustar jromanjroman
Actual source code: dlregispep.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/pepimpl.h>

 24: static PetscBool PEPPackageInitialized = PETSC_FALSE;

 26: const char *PEPBasisTypes[] = {"MONOMIAL","CHEBYSHEV1","CHEBYSHEV2","LEGENDRE","LAGUERRE","HERMITE","PEPBasis","PEP_BASIS_",0};
 27: const char *PEPScaleTypes[] = {"NONE","SCALAR","DIAGONAL","BOTH","PEPScale","PEP_SCALE_",0};
 28: const char *PEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","PEPRefine","PEP_REFINE_",0};
 29: const char *PEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","PEPRefineScheme","PEP_REFINE_SCHEME_",0};
 30: const char *PEPExtractTypes[] = {"","NONE","NORM","RESIDUAL","STRUCTURED","PEPExtract","PEP_EXTRACT_",0};
 31: const char *PEPErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","PEPErrorType","PEP_ERROR_",0};
 32: const char *const PEPConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","PEPConvergedReason","PEP_",0};
 33: const char *const*PEPConvergedReasons = PEPConvergedReasons_Shifted + 4;

 37: /*@C
 38:    PEPFinalizePackage - This function destroys everything in the Slepc interface
 39:    to the PEP package. It is called from SlepcFinalize().

 41:    Level: developer

 43: .seealso: SlepcFinalize()
 44: @*/
 45: PetscErrorCode PEPFinalizePackage(void)
 46: {

 50:   PetscFunctionListDestroy(&PEPList);
 51:   PEPPackageInitialized = PETSC_FALSE;
 52:   PEPRegisterAllCalled  = PETSC_FALSE;
 53:   return(0);
 54: }

 58: /*@C
 59:    PEPInitializePackage - This function initializes everything in the PEP package.
 60:    It is called from PetscDLLibraryRegister() when using dynamic libraries, and
 61:    on the first call to PEPCreate() when using static libraries.

 63:    Level: developer

 65: .seealso: SlepcInitialize()
 66: @*/
 67: PetscErrorCode PEPInitializePackage(void)
 68: {
 69:   char           logList[256];
 70:   char           *className;
 71:   PetscBool      opt;

 75:   if (PEPPackageInitialized) return(0);
 76:   PEPPackageInitialized = PETSC_TRUE;
 77:   /* Register Classes */
 78:   PetscClassIdRegister("PEP Solver",&PEP_CLASSID);
 79:   /* Register Constructors */
 80:   PEPRegisterAll();
 81:   /* Register Events */
 82:   PetscLogEventRegister("PEPSetUp",PEP_CLASSID,&PEP_SetUp);
 83:   PetscLogEventRegister("PEPSolve",PEP_CLASSID,&PEP_Solve);
 84:   PetscLogEventRegister("PEPRefine",PEP_CLASSID,&PEP_Refine);
 85:   /* Process info exclusions */
 86:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);
 87:   if (opt) {
 88:     PetscStrstr(logList,"pep",&className);
 89:     if (className) {
 90:       PetscInfoDeactivateClass(PEP_CLASSID);
 91:     }
 92:   }
 93:   /* Process summary exclusions */
 94:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);
 95:   if (opt) {
 96:     PetscStrstr(logList,"pep",&className);
 97:     if (className) {
 98:       PetscLogEventDeactivateClass(PEP_CLASSID);
 99:     }
100:   }
101:   PetscRegisterFinalize(PEPFinalizePackage);
102:   return(0);
103: }

105: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

109: /*
110:   PetscDLLibraryRegister - This function is called when the dynamic library
111:   it is in is opened.

113:   This one registers all the PEP methods that are in the basic SLEPc libslepcpep
114:   library.
115:  */
116: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcpep()
117: {

121:   PEPInitializePackage();
122:   return(0);
123: }
124: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */

slepc-3.7.4/src/pep/interface/pepsolve.c0000644000175000017500000004257313107004621017512 0ustar jromanjroman/* PEP routines related to the solution process. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include static PetscBool cited = PETSC_FALSE; static const char citation[] = "@Article{slepc-pep-refine,\n" " author = \"C. Campos and J. E. Roman\",\n" " title = \"Parallel iterative refinement in polynomial eigenvalue problems\",\n" " journal = \"Numer. Linear Algebra Appl.\",\n" " volume = \"to appear\",\n" " number = \"\",\n" " pages = \"\",\n" " year = \"2016,\"\n" " doi = \"http://dx.doi.org/10.1002/nla.2052\"\n" "}\n"; #undef __FUNCT__ #define __FUNCT__ "PEPComputeVectors" PetscErrorCode PEPComputeVectors(PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; PEPCheckSolved(pep,1); switch (pep->state) { case PEP_STATE_SOLVED: if (pep->ops->computevectors) { ierr = (*pep->ops->computevectors)(pep);CHKERRQ(ierr); } break; default: break; } pep->state = PEP_STATE_EIGENVECTORS; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPExtractVectors" PetscErrorCode PEPExtractVectors(PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; PEPCheckSolved(pep,1); switch (pep->state) { case PEP_STATE_SOLVED: ierr = BVSetActiveColumns(pep->V,0,pep->nconv);CHKERRQ(ierr); if (pep->ops->extractvectors) { ierr = (*pep->ops->extractvectors)(pep);CHKERRQ(ierr); } break; default: break; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSolve" /*@ PEPSolve - Solves the polynomial eigensystem. Collective on PEP Input Parameter: . pep - eigensolver context obtained from PEPCreate() Options Database Keys: + -pep_view - print information about the solver used . -pep_view_matk binary - save any of the coefficient matrices (Ak) to the default binary viewer (replace k by an integer from 0 to nmat-1) . -pep_view_vectors binary - save the computed eigenvectors to the default binary viewer . -pep_view_values - print computed eigenvalues . -pep_converged_reason - print reason for convergence, and number of iterations . -pep_error_absolute - print absolute errors of each eigenpair . -pep_error_relative - print relative errors of each eigenpair - -pep_error_backward - print backward errors of each eigenpair Level: beginner .seealso: PEPCreate(), PEPSetUp(), PEPDestroy(), PEPSetTolerances() @*/ PetscErrorCode PEPSolve(PEP pep) { PetscErrorCode ierr; PetscInt i,k; PetscBool flg,islinear; #define OPTLEN 16 char str[OPTLEN]; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (pep->state>=PEP_STATE_SOLVED) PetscFunctionReturn(0); ierr = PetscLogEventBegin(PEP_Solve,pep,0,0,0);CHKERRQ(ierr); /* call setup */ ierr = PEPSetUp(pep);CHKERRQ(ierr); pep->nconv = 0; pep->its = 0; k = pep->lineariz? pep->ncv: pep->ncv*(pep->nmat-1); for (i=0;ieigr[i] = 0.0; pep->eigi[i] = 0.0; pep->errest[i] = 0.0; pep->perm[i] = i; } ierr = PEPViewFromOptions(pep,NULL,"-pep_view_pre");CHKERRQ(ierr); ierr = (*pep->ops->solve)(pep);CHKERRQ(ierr); if (!pep->reason) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_PLIB,"Internal error, solver returned without setting converged reason"); ierr = PetscObjectTypeCompare((PetscObject)pep,PEPLINEAR,&islinear);CHKERRQ(ierr); if (!islinear) { ierr = STPostSolve(pep->st);CHKERRQ(ierr); /* Map eigenvalues back to the original problem */ ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg && pep->ops->backtransform) { ierr = (*pep->ops->backtransform)(pep);CHKERRQ(ierr); } } pep->state = PEP_STATE_SOLVED; #if !defined(PETSC_USE_COMPLEX) /* reorder conjugate eigenvalues (positive imaginary first) */ for (i=0;inconv-1;i++) { if (pep->eigi[i] != 0) { if (pep->eigi[i] < 0) { pep->eigi[i] = -pep->eigi[i]; pep->eigi[i+1] = -pep->eigi[i+1]; /* the next correction only works with eigenvectors */ ierr = PEPComputeVectors(pep);CHKERRQ(ierr); ierr = BVScaleColumn(pep->V,i+1,-1.0);CHKERRQ(ierr); } i++; } } #endif if (pep->refine!=PEP_REFINE_NONE) { ierr = PetscCitationsRegister(citation,&cited);CHKERRQ(ierr); } if (pep->refine==PEP_REFINE_SIMPLE && pep->rits>0 && pep->nconv>0) { ierr = PEPComputeVectors(pep);CHKERRQ(ierr); ierr = PEPNewtonRefinementSimple(pep,&pep->rits,pep->rtol,pep->nconv);CHKERRQ(ierr); } /* sort eigenvalues according to pep->which parameter */ ierr = SlepcSortEigenvalues(pep->sc,pep->nconv,pep->eigr,pep->eigi,pep->perm);CHKERRQ(ierr); ierr = PetscLogEventEnd(PEP_Solve,pep,0,0,0);CHKERRQ(ierr); /* various viewers */ ierr = PEPViewFromOptions(pep,NULL,"-pep_view");CHKERRQ(ierr); ierr = PEPReasonViewFromOptions(pep);CHKERRQ(ierr); ierr = PEPErrorViewFromOptions(pep);CHKERRQ(ierr); ierr = PEPValuesViewFromOptions(pep);CHKERRQ(ierr); ierr = PEPVectorsViewFromOptions(pep);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = PetscSNPrintf(str,OPTLEN,"-pep_view_mat%d",(int)i);CHKERRQ(ierr); ierr = MatViewFromOptions(pep->A[i],(PetscObject)pep,str);CHKERRQ(ierr); } /* Remove the initial subspace */ pep->nini = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetIterationNumber" /*@ PEPGetIterationNumber - Gets the current iteration number. If the call to PEPSolve() is complete, then it returns the number of iterations carried out by the solution method. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameter: . its - number of iterations Level: intermediate Note: During the i-th iteration this call returns i-1. If PEPSolve() is complete, then parameter "its" contains either the iteration number at which convergence was successfully reached, or failure was detected. Call PEPGetConvergedReason() to determine if the solver converged or failed and why. .seealso: PEPGetConvergedReason(), PEPSetTolerances() @*/ PetscErrorCode PEPGetIterationNumber(PEP pep,PetscInt *its) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidIntPointer(its,2); *its = pep->its; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetConverged" /*@ PEPGetConverged - Gets the number of converged eigenpairs. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameter: . nconv - number of converged eigenpairs Note: This function should be called after PEPSolve() has finished. Level: beginner .seealso: PEPSetDimensions(), PEPSolve() @*/ PetscErrorCode PEPGetConverged(PEP pep,PetscInt *nconv) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidIntPointer(nconv,2); PEPCheckSolved(pep,1); *nconv = pep->nconv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetConvergedReason" /*@ PEPGetConvergedReason - Gets the reason why the PEPSolve() iteration was stopped. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameter: . reason - negative value indicates diverged, positive value converged Notes: Possible values for reason are + PEP_CONVERGED_TOL - converged up to tolerance . PEP_CONVERGED_USER - converged due to a user-defined condition . PEP_DIVERGED_ITS - required more than max_it iterations to reach convergence . PEP_DIVERGED_BREAKDOWN - generic breakdown in method - PEP_DIVERGED_SYMMETRY_LOST - pseudo-Lanczos was not able to keep symmetry Can only be called after the call to PEPSolve() is complete. Level: intermediate .seealso: PEPSetTolerances(), PEPSolve(), PEPConvergedReason @*/ PetscErrorCode PEPGetConvergedReason(PEP pep,PEPConvergedReason *reason) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(reason,2); PEPCheckSolved(pep,1); *reason = pep->reason; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetEigenpair" /*@ PEPGetEigenpair - Gets the i-th solution of the eigenproblem as computed by PEPSolve(). The solution consists in both the eigenvalue and the eigenvector. Logically Collective on EPS Input Parameters: + pep - polynomial eigensolver context - i - index of the solution Output Parameters: + eigr - real part of eigenvalue . eigi - imaginary part of eigenvalue . Vr - real part of eigenvector - Vi - imaginary part of eigenvector Notes: It is allowed to pass NULL for Vr and Vi, if the eigenvector is not required. Otherwise, the caller must provide valid Vec objects, i.e., they must be created by the calling program with e.g. MatCreateVecs(). If the eigenvalue is real, then eigi and Vi are set to zero. If PETSc is configured with complex scalars the eigenvalue is stored directly in eigr (eigi is set to zero) and the eigenvector in Vr (Vi is set to zero). In both cases, the user can pass NULL in eigi and Vi. The index i should be a value between 0 and nconv-1 (see PEPGetConverged()). Eigenpairs are indexed according to the ordering criterion established with PEPSetWhichEigenpairs(). Level: beginner .seealso: PEPSolve(), PEPGetConverged(), PEPSetWhichEigenpairs() @*/ PetscErrorCode PEPGetEigenpair(PEP pep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi) { PetscInt k; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveInt(pep,i,2); if (Vr) { PetscValidHeaderSpecific(Vr,VEC_CLASSID,5); PetscCheckSameComm(pep,1,Vr,5); } if (Vi) { PetscValidHeaderSpecific(Vi,VEC_CLASSID,6); PetscCheckSameComm(pep,1,Vi,6); } PEPCheckSolved(pep,1); if (i<0 || i>=pep->nconv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); ierr = PEPComputeVectors(pep);CHKERRQ(ierr); k = pep->perm[i]; /* eigenvalue */ #if defined(PETSC_USE_COMPLEX) if (eigr) *eigr = pep->eigr[k]; if (eigi) *eigi = 0; #else if (eigr) *eigr = pep->eigr[k]; if (eigi) *eigi = pep->eigi[k]; #endif /* eigenvector */ #if defined(PETSC_USE_COMPLEX) if (Vr) { ierr = BVCopyVec(pep->V,k,Vr);CHKERRQ(ierr); } if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } #else if (pep->eigi[k]>0) { /* first value of conjugate pair */ if (Vr) { ierr = BVCopyVec(pep->V,k,Vr);CHKERRQ(ierr); } if (Vi) { ierr = BVCopyVec(pep->V,k+1,Vi);CHKERRQ(ierr); } } else if (pep->eigi[k]<0) { /* second value of conjugate pair */ if (Vr) { ierr = BVCopyVec(pep->V,k-1,Vr);CHKERRQ(ierr); } if (Vi) { ierr = BVCopyVec(pep->V,k,Vi);CHKERRQ(ierr); ierr = VecScale(Vi,-1.0);CHKERRQ(ierr); } } else { /* real eigenvalue */ if (Vr) { ierr = BVCopyVec(pep->V,k,Vr);CHKERRQ(ierr); } if (Vi) { ierr = VecSet(Vi,0.0);CHKERRQ(ierr); } } #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetErrorEstimate" /*@ PEPGetErrorEstimate - Returns the error estimate associated to the i-th computed eigenpair. Not Collective Input Parameter: + pep - polynomial eigensolver context - i - index of eigenpair Output Parameter: . errest - the error estimate Notes: This is the error estimate used internally by the eigensolver. The actual error bound can be computed with PEPComputeError(). See also the users manual for details. Level: advanced .seealso: PEPComputeError() @*/ PetscErrorCode PEPGetErrorEstimate(PEP pep,PetscInt i,PetscReal *errest) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(errest,3); PEPCheckSolved(pep,1); if (i<0 || i>=pep->nconv) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Argument 2 out of range"); if (errest) *errest = pep->errest[pep->perm[i]]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPComputeResidualNorm_Private" /* PEPComputeResidualNorm_Private - Computes the norm of the residual vector associated with an eigenpair. Input Parameters: kr,ki - eigenvalue xr,xi - eigenvector z - array of 4 work vectors (z[2],z[3] not referenced in complex scalars) */ PetscErrorCode PEPComputeResidualNorm_Private(PEP pep,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm) { PetscErrorCode ierr; Mat *A=pep->A; PetscInt i,nmat=pep->nmat; PetscScalar t[20],*vals=t,*ivals=NULL; Vec u,w; #if !defined(PETSC_USE_COMPLEX) Vec ui,wi; PetscReal ni; PetscBool imag; PetscScalar it[20]; #endif PetscFunctionBegin; u = z[0]; w = z[1]; ierr = VecSet(u,0.0);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ui = z[2]; wi = z[3]; ivals = it; #endif if (nmat>20) { ierr = PetscMalloc1(nmat,&vals);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = PetscMalloc1(nmat,&ivals);CHKERRQ(ierr); #endif } ierr = PEPEvaluateBasis(pep,kr,ki,vals,ivals);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) if (ki == 0 || PetscAbsScalar(ki) < PetscAbsScalar(kr*PETSC_MACHINE_EPSILON)) imag = PETSC_FALSE; else { imag = PETSC_TRUE; ierr = VecSet(ui,0.0);CHKERRQ(ierr); } #endif for (i=0;i20) { ierr = PetscFree(vals);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = PetscFree(ivals);CHKERRQ(ierr); #endif } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPComputeError" /*@ PEPComputeError - Computes the error (based on the residual norm) associated with the i-th computed eigenpair. Collective on PEP Input Parameter: + pep - the polynomial eigensolver context . i - the solution index - type - the type of error to compute Output Parameter: . error - the error Notes: The error can be computed in various ways, all of them based on the residual norm ||P(l)x||_2 where l is the eigenvalue and x is the eigenvector. See the users guide for additional details. Level: beginner .seealso: PEPErrorType, PEPSolve(), PEPGetErrorEstimate() @*/ PetscErrorCode PEPComputeError(PEP pep,PetscInt i,PEPErrorType type,PetscReal *error) { PetscErrorCode ierr; Vec xr,xi,w[4]; PetscScalar kr,ki; PetscReal t,z=0.0; PetscInt j; PetscBool flg; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveInt(pep,i,2); PetscValidLogicalCollectiveEnum(pep,type,3); PetscValidPointer(error,4); PEPCheckSolved(pep,1); /* allocate work vectors */ #if defined(PETSC_USE_COMPLEX) ierr = PEPSetWorkVecs(pep,3);CHKERRQ(ierr); xi = NULL; w[2] = NULL; w[3] = NULL; #else ierr = PEPSetWorkVecs(pep,6);CHKERRQ(ierr); xi = pep->work[3]; w[2] = pep->work[4]; w[3] = pep->work[5]; #endif xr = pep->work[0]; w[0] = pep->work[1]; w[1] = pep->work[2]; /* compute residual norms */ ierr = PEPGetEigenpair(pep,i,&kr,&ki,xr,xi);CHKERRQ(ierr); ierr = PEPComputeResidualNorm_Private(pep,kr,ki,xr,xi,w,error);CHKERRQ(ierr); /* compute error */ switch (type) { case PEP_ERROR_ABSOLUTE: break; case PEP_ERROR_RELATIVE: *error /= SlepcAbsEigenvalue(kr,ki); break; case PEP_ERROR_BACKWARD: /* initialization of matrix norms */ if (!pep->nrma[pep->nmat-1]) { for (j=0;jnmat;j++) { ierr = MatHasOperation(pep->A[j],MATOP_NORM,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONG,"The computation of backward errors requires a matrix norm operation"); ierr = MatNorm(pep->A[j],NORM_INFINITY,&pep->nrma[j]);CHKERRQ(ierr); } } t = SlepcAbsEigenvalue(kr,ki); for (j=pep->nmat-1;j>=0;j--) { z = z*t+pep->nrma[j]; } *error /= z; break; default: SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid error type"); } PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/makefile.html0000644000175000017500000000501513107004621020142 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = pepmon.c pepbasic.c pepview.c pepdefault.c pepregis.c pepopts.c pepsetup.c pepsolve.c peprefine.c dlregispep.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcpep
DIRS     =
MANSEC   = PEP
LOCDIR   = src/pep/interface/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/pep/interface/pepregis.c.html0000644000175000017500000001262313107004621020427 0ustar jromanjroman
Actual source code: pepregis.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: #include <slepc/private/pepimpl.h>      /*I "slepcpep.h" I*/

 24: PETSC_EXTERN PetscErrorCode PEPCreate_Linear(PEP);
 25: PETSC_EXTERN PetscErrorCode PEPCreate_QArnoldi(PEP);
 26: PETSC_EXTERN PetscErrorCode PEPCreate_TOAR(PEP);
 27: PETSC_EXTERN PetscErrorCode PEPCreate_STOAR(PEP);
 28: PETSC_EXTERN PetscErrorCode PEPCreate_JD(PEP);

 32: /*@C
 33:    PEPRegisterAll - Registers all the solvers in the PEP package.

 35:    Not Collective

 37:    Level: advanced

 39: .seealso:  PEPRegister()
 40: @*/
 41: PetscErrorCode PEPRegisterAll(void)
 42: {

 46:   if (PEPRegisterAllCalled) return(0);
 47:   PEPRegisterAllCalled = PETSC_TRUE;
 48:   PEPRegister(PEPLINEAR,PEPCreate_Linear);
 49:   PEPRegister(PEPQARNOLDI,PEPCreate_QArnoldi);
 50:   PEPRegister(PEPTOAR,PEPCreate_TOAR);
 51:   PEPRegister(PEPSTOAR,PEPCreate_STOAR);
 52:   PEPRegister(PEPJD,PEPCreate_JD);
 53:   return(0);
 54: }

slepc-3.7.4/src/pep/interface/pepbasic.c.html0000644000175000017500000013676113107004621020411 0ustar jromanjroman
Actual source code: pepbasic.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    The basic PEP routines, Create, Destroy, etc. are here.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>      /*I "slepcpep.h" I*/

 26: PetscFunctionList PEPList = 0;
 27: PetscBool         PEPRegisterAllCalled = PETSC_FALSE;
 28: PetscClassId      PEP_CLASSID = 0;
 29: PetscLogEvent     PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0;

 33: /*@
 34:    PEPCreate - Creates the default PEP context.

 36:    Collective on MPI_Comm

 38:    Input Parameter:
 39: .  comm - MPI communicator

 41:    Output Parameter:
 42: .  pep - location to put the PEP context

 44:    Note:
 45:    The default PEP type is PEPTOAR

 47:    Level: beginner

 49: .seealso: PEPSetUp(), PEPSolve(), PEPDestroy(), PEP
 50: @*/
 51: PetscErrorCode PEPCreate(MPI_Comm comm,PEP *outpep)
 52: {
 54:   PEP            pep;

 58:   *outpep = 0;
 59:   PEPInitializePackage();
 60:   SlepcHeaderCreate(pep,PEP_CLASSID,"PEP","Polynomial Eigenvalue Problem","PEP",comm,PEPDestroy,PEPView);

 62:   pep->max_it          = 0;
 63:   pep->nev             = 1;
 64:   pep->ncv             = 0;
 65:   pep->mpd             = 0;
 66:   pep->nini            = 0;
 67:   pep->target          = 0.0;
 68:   pep->tol             = PETSC_DEFAULT;
 69:   pep->conv            = PEP_CONV_REL;
 70:   pep->stop            = PEP_STOP_BASIC;
 71:   pep->which           = (PEPWhich)0;
 72:   pep->basis           = PEP_BASIS_MONOMIAL;
 73:   pep->problem_type    = (PEPProblemType)0;
 74:   pep->scale           = PEP_SCALE_NONE;
 75:   pep->sfactor         = 1.0;
 76:   pep->dsfactor        = 1.0;
 77:   pep->sits            = 5;
 78:   pep->slambda         = 1.0;
 79:   pep->refine          = PEP_REFINE_NONE;
 80:   pep->npart           = 1;
 81:   pep->rtol            = PETSC_DEFAULT;
 82:   pep->rits            = PETSC_DEFAULT;
 83:   pep->scheme          = (PEPRefineScheme)0;
 84:   pep->extract         = (PEPExtract)0;
 85:   pep->trackall        = PETSC_FALSE;

 87:   pep->converged       = PEPConvergedRelative;
 88:   pep->convergeddestroy= NULL;
 89:   pep->stopping        = PEPStoppingBasic;
 90:   pep->stoppingdestroy = NULL;
 91:   pep->convergedctx    = NULL;
 92:   pep->stoppingctx     = NULL;
 93:   pep->numbermonitors  = 0;

 95:   pep->st              = NULL;
 96:   pep->ds              = NULL;
 97:   pep->V               = NULL;
 98:   pep->rg              = NULL;
 99:   pep->A               = NULL;
100:   pep->nmat            = 0;
101:   pep->Dl              = NULL;
102:   pep->Dr              = NULL;
103:   pep->IS              = NULL;
104:   pep->eigr            = NULL;
105:   pep->eigi            = NULL;
106:   pep->errest          = NULL;
107:   pep->perm            = NULL;
108:   pep->pbc             = NULL;
109:   pep->solvematcoeffs  = NULL;
110:   pep->nwork           = 0;
111:   pep->work            = NULL;
112:   pep->refineksp       = NULL;
113:   pep->refinesubc      = NULL;
114:   pep->data            = NULL;

116:   pep->state           = PEP_STATE_INITIAL;
117:   pep->nconv           = 0;
118:   pep->its             = 0;
119:   pep->n               = 0;
120:   pep->nloc            = 0;
121:   pep->nrma            = NULL;
122:   pep->sfactor_set     = PETSC_FALSE;
123:   pep->lineariz        = PETSC_FALSE;
124:   pep->reason          = PEP_CONVERGED_ITERATING;

126:   PetscNewLog(pep,&pep->sc);
127:   *outpep = pep;
128:   return(0);
129: }

133: /*@C
134:    PEPSetType - Selects the particular solver to be used in the PEP object.

136:    Logically Collective on PEP

138:    Input Parameters:
139: +  pep      - the polynomial eigensolver context
140: -  type     - a known method

142:    Options Database Key:
143: .  -pep_type <method> - Sets the method; use -help for a list
144:     of available methods

146:    Notes:
147:    See "slepc/include/slepcpep.h" for available methods. The default
148:    is PEPTOAR.

150:    Normally, it is best to use the PEPSetFromOptions() command and
151:    then set the PEP type from the options database rather than by using
152:    this routine.  Using the options database provides the user with
153:    maximum flexibility in evaluating the different available methods.
154:    The PEPSetType() routine is provided for those situations where it
155:    is necessary to set the iterative solver independently of the command
156:    line or options database.

158:    Level: intermediate

160: .seealso: PEPType
161: @*/
162: PetscErrorCode PEPSetType(PEP pep,PEPType type)
163: {
164:   PetscErrorCode ierr,(*r)(PEP);
165:   PetscBool      match;


171:   PetscObjectTypeCompare((PetscObject)pep,type,&match);
172:   if (match) return(0);

174:   PetscFunctionListFind(PEPList,type,&r);
175:   if (!r) SETERRQ1(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown PEP type given: %s",type);

177:   if (pep->ops->destroy) { (*pep->ops->destroy)(pep); }
178:   PetscMemzero(pep->ops,sizeof(struct _PEPOps));

180:   pep->state = PEP_STATE_INITIAL;
181:   PetscObjectChangeTypeName((PetscObject)pep,type);
182:   (*r)(pep);
183:   return(0);
184: }

188: /*@C
189:    PEPGetType - Gets the PEP type as a string from the PEP object.

191:    Not Collective

193:    Input Parameter:
194: .  pep - the eigensolver context

196:    Output Parameter:
197: .  name - name of PEP method

199:    Level: intermediate

201: .seealso: PEPSetType()
202: @*/
203: PetscErrorCode PEPGetType(PEP pep,PEPType *type)
204: {
208:   *type = ((PetscObject)pep)->type_name;
209:   return(0);
210: }

214: /*@C
215:    PEPRegister - Adds a method to the polynomial eigenproblem solver package.

217:    Not Collective

219:    Input Parameters:
220: +  name - name of a new user-defined solver
221: -  function - routine to create the solver context

223:    Notes:
224:    PEPRegister() may be called multiple times to add several user-defined solvers.

226:    Sample usage:
227: .vb
228:     PEPRegister("my_solver",MySolverCreate);
229: .ve

231:    Then, your solver can be chosen with the procedural interface via
232: $     PEPSetType(pep,"my_solver")
233:    or at runtime via the option
234: $     -pep_type my_solver

236:    Level: advanced

238: .seealso: PEPRegisterAll()
239: @*/
240: PetscErrorCode PEPRegister(const char *name,PetscErrorCode (*function)(PEP))
241: {

245:   PetscFunctionListAdd(&PEPList,name,function);
246:   return(0);
247: }

251: /*@
252:    PEPReset - Resets the PEP context to the initial state and removes any
253:    allocated objects.

255:    Collective on PEP

257:    Input Parameter:
258: .  pep - eigensolver context obtained from PEPCreate()

260:    Level: advanced

262: .seealso: PEPDestroy()
263: @*/
264: PetscErrorCode PEPReset(PEP pep)
265: {
267:   PetscInt       ncols;

271:   if (pep->ops->reset) { (pep->ops->reset)(pep); }
272:   if (pep->st) { STReset(pep->st); }
273:   if (pep->ds) { DSReset(pep->ds); }
274:   if (pep->nmat) {
275:     MatDestroyMatrices(pep->nmat,&pep->A);
276:     PetscFree2(pep->pbc,pep->nrma);
277:     PetscFree(pep->solvematcoeffs);
278:     pep->nmat = 0;
279:   }
280:   VecDestroy(&pep->Dl);
281:   VecDestroy(&pep->Dr);
282:   BVGetSizes(pep->V,NULL,NULL,&ncols);
283:   if (ncols) {
284:     PetscFree4(pep->eigr,pep->eigi,pep->errest,pep->perm);
285:   }
286:   BVDestroy(&pep->V);
287:   VecDestroyVecs(pep->nwork,&pep->work);
288:   KSPDestroy(&pep->refineksp);
289:   PetscSubcommDestroy(&pep->refinesubc);
290:   pep->nwork = 0;
291:   pep->state = PEP_STATE_INITIAL;
292:   return(0);
293: }

297: /*@
298:    PEPDestroy - Destroys the PEP context.

300:    Collective on PEP

302:    Input Parameter:
303: .  pep - eigensolver context obtained from PEPCreate()

305:    Level: beginner

307: .seealso: PEPCreate(), PEPSetUp(), PEPSolve()
308: @*/
309: PetscErrorCode PEPDestroy(PEP *pep)
310: {

314:   if (!*pep) return(0);
316:   if (--((PetscObject)(*pep))->refct > 0) { *pep = 0; return(0); }
317:   PEPReset(*pep);
318:   if ((*pep)->ops->destroy) { (*(*pep)->ops->destroy)(*pep); }
319:   STDestroy(&(*pep)->st);
320:   RGDestroy(&(*pep)->rg);
321:   DSDestroy(&(*pep)->ds);
322:   PetscFree((*pep)->sc);
323:   /* just in case the initial vectors have not been used */
324:   SlepcBasisDestroy_Private(&(*pep)->nini,&(*pep)->IS);
325:   if ((*pep)->convergeddestroy) {
326:     (*(*pep)->convergeddestroy)((*pep)->convergedctx);
327:   }
328:   PEPMonitorCancel(*pep);
329:   PetscHeaderDestroy(pep);
330:   return(0);
331: }

335: /*@
336:    PEPSetBV - Associates a basis vectors object to the polynomial eigensolver.

338:    Collective on PEP

340:    Input Parameters:
341: +  pep - eigensolver context obtained from PEPCreate()
342: -  bv  - the basis vectors object

344:    Note:
345:    Use PEPGetBV() to retrieve the basis vectors context (for example,
346:    to free it at the end of the computations).

348:    Level: advanced

350: .seealso: PEPGetBV()
351: @*/
352: PetscErrorCode PEPSetBV(PEP pep,BV bv)
353: {

360:   PetscObjectReference((PetscObject)bv);
361:   BVDestroy(&pep->V);
362:   pep->V = bv;
363:   PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->V);
364:   return(0);
365: }

369: /*@
370:    PEPGetBV - Obtain the basis vectors object associated to the polynomial
371:    eigensolver object.

373:    Not Collective

375:    Input Parameters:
376: .  pep - eigensolver context obtained from PEPCreate()

378:    Output Parameter:
379: .  bv - basis vectors context

381:    Level: advanced

383: .seealso: PEPSetBV()
384: @*/
385: PetscErrorCode PEPGetBV(PEP pep,BV *bv)
386: {

392:   if (!pep->V) {
393:     BVCreate(PetscObjectComm((PetscObject)pep),&pep->V);
394:     PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->V);
395:   }
396:   *bv = pep->V;
397:   return(0);
398: }

402: /*@
403:    PEPSetRG - Associates a region object to the polynomial eigensolver.

405:    Collective on PEP

407:    Input Parameters:
408: +  pep - eigensolver context obtained from PEPCreate()
409: -  rg  - the region object

411:    Note:
412:    Use PEPGetRG() to retrieve the region context (for example,
413:    to free it at the end of the computations).

415:    Level: advanced

417: .seealso: PEPGetRG()
418: @*/
419: PetscErrorCode PEPSetRG(PEP pep,RG rg)
420: {

427:   PetscObjectReference((PetscObject)rg);
428:   RGDestroy(&pep->rg);
429:   pep->rg = rg;
430:   PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->rg);
431:   return(0);
432: }

436: /*@
437:    PEPGetRG - Obtain the region object associated to the
438:    polynomial eigensolver object.

440:    Not Collective

442:    Input Parameters:
443: .  pep - eigensolver context obtained from PEPCreate()

445:    Output Parameter:
446: .  rg - region context

448:    Level: advanced

450: .seealso: PEPSetRG()
451: @*/
452: PetscErrorCode PEPGetRG(PEP pep,RG *rg)
453: {

459:   if (!pep->rg) {
460:     RGCreate(PetscObjectComm((PetscObject)pep),&pep->rg);
461:     PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->rg);
462:   }
463:   *rg = pep->rg;
464:   return(0);
465: }

469: /*@
470:    PEPSetDS - Associates a direct solver object to the polynomial eigensolver.

472:    Collective on PEP

474:    Input Parameters:
475: +  pep - eigensolver context obtained from PEPCreate()
476: -  ds  - the direct solver object

478:    Note:
479:    Use PEPGetDS() to retrieve the direct solver context (for example,
480:    to free it at the end of the computations).

482:    Level: advanced

484: .seealso: PEPGetDS()
485: @*/
486: PetscErrorCode PEPSetDS(PEP pep,DS ds)
487: {

494:   PetscObjectReference((PetscObject)ds);
495:   DSDestroy(&pep->ds);
496:   pep->ds = ds;
497:   PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->ds);
498:   return(0);
499: }

503: /*@
504:    PEPGetDS - Obtain the direct solver object associated to the
505:    polynomial eigensolver object.

507:    Not Collective

509:    Input Parameters:
510: .  pep - eigensolver context obtained from PEPCreate()

512:    Output Parameter:
513: .  ds - direct solver context

515:    Level: advanced

517: .seealso: PEPSetDS()
518: @*/
519: PetscErrorCode PEPGetDS(PEP pep,DS *ds)
520: {

526:   if (!pep->ds) {
527:     DSCreate(PetscObjectComm((PetscObject)pep),&pep->ds);
528:     PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->ds);
529:   }
530:   *ds = pep->ds;
531:   return(0);
532: }

536: /*@
537:    PEPSetST - Associates a spectral transformation object to the eigensolver.

539:    Collective on PEP

541:    Input Parameters:
542: +  pep - eigensolver context obtained from PEPCreate()
543: -  st   - the spectral transformation object

545:    Note:
546:    Use PEPGetST() to retrieve the spectral transformation context (for example,
547:    to free it at the end of the computations).

549:    Level: advanced

551: .seealso: PEPGetST()
552: @*/
553: PetscErrorCode PEPSetST(PEP pep,ST st)
554: {

561:   PetscObjectReference((PetscObject)st);
562:   STDestroy(&pep->st);
563:   pep->st = st;
564:   PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->st);
565:   return(0);
566: }

570: /*@
571:    PEPGetST - Obtain the spectral transformation (ST) object associated
572:    to the eigensolver object.

574:    Not Collective

576:    Input Parameters:
577: .  pep - eigensolver context obtained from PEPCreate()

579:    Output Parameter:
580: .  st - spectral transformation context

582:    Level: intermediate

584: .seealso: PEPSetST()
585: @*/
586: PetscErrorCode PEPGetST(PEP pep,ST *st)
587: {

593:   if (!pep->st) {
594:     STCreate(PetscObjectComm((PetscObject)pep),&pep->st);
595:     PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->st);
596:   }
597:   *st = pep->st;
598:   return(0);
599: }

603: /*@
604:    PEPRefineGetKSP - Obtain the ksp object used by the eigensolver
605:    object in the refinement phase.

607:    Not Collective

609:    Input Parameters:
610: .  pep - eigensolver context obtained from PEPCreate()

612:    Output Parameter:
613: .  ksp - ksp context

615:    Level: advanced

617: .seealso: PEPSetRefine()
618: @*/
619: PetscErrorCode PEPRefineGetKSP(PEP pep,KSP *ksp)
620: {

626:   if (!pep->refineksp) {
627:     if (pep->npart>1) {
628:       /* Split in subcomunicators */
629:       PetscSubcommCreate(PetscObjectComm((PetscObject)pep),&pep->refinesubc);
630:       PetscSubcommSetNumber(pep->refinesubc,pep->npart);
631:       PetscSubcommSetType(pep->refinesubc,PETSC_SUBCOMM_CONTIGUOUS);
632:       PetscLogObjectMemory((PetscObject)pep,sizeof(PetscSubcomm));
633:     }
634:     KSPCreate((pep->npart==1)?PetscObjectComm((PetscObject)pep):PetscSubcommChild(pep->refinesubc),&pep->refineksp);
635:     PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->refineksp);
636:     KSPSetOptionsPrefix(*ksp,((PetscObject)pep)->prefix);
637:     KSPAppendOptionsPrefix(*ksp,"pep_refine_");
638:   }
639:   *ksp = pep->refineksp;
640:   return(0);
641: }

645: /*@
646:    PEPSetTarget - Sets the value of the target.

648:    Logically Collective on PEP

650:    Input Parameters:
651: +  pep    - eigensolver context
652: -  target - the value of the target

654:    Options Database Key:
655: .  -pep_target <scalar> - the value of the target

657:    Notes:
658:    The target is a scalar value used to determine the portion of the spectrum
659:    of interest. It is used in combination with PEPSetWhichEigenpairs().

661:    In the case of complex scalars, a complex value can be provided in the
662:    command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g.
663:    -pep_target 1.0+2.0i

665:    Level: intermediate

667: .seealso: PEPGetTarget(), PEPSetWhichEigenpairs()
668: @*/
669: PetscErrorCode PEPSetTarget(PEP pep,PetscScalar target)
670: {

676:   pep->target = target;
677:   if (!pep->st) { PEPGetST(pep,&pep->st); }
678:   STSetDefaultShift(pep->st,target);
679:   return(0);
680: }

684: /*@
685:    PEPGetTarget - Gets the value of the target.

687:    Not Collective

689:    Input Parameter:
690: .  pep - eigensolver context

692:    Output Parameter:
693: .  target - the value of the target

695:    Note:
696:    If the target was not set by the user, then zero is returned.

698:    Level: intermediate

700: .seealso: PEPSetTarget()
701: @*/
702: PetscErrorCode PEPGetTarget(PEP pep,PetscScalar* target)
703: {
707:   *target = pep->target;
708:   return(0);
709: }

slepc-3.7.4/src/pep/interface/dlregispep.c0000644000175000017500000001112213107004621017775 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include static PetscBool PEPPackageInitialized = PETSC_FALSE; const char *PEPBasisTypes[] = {"MONOMIAL","CHEBYSHEV1","CHEBYSHEV2","LEGENDRE","LAGUERRE","HERMITE","PEPBasis","PEP_BASIS_",0}; const char *PEPScaleTypes[] = {"NONE","SCALAR","DIAGONAL","BOTH","PEPScale","PEP_SCALE_",0}; const char *PEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","PEPRefine","PEP_REFINE_",0}; const char *PEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","PEPRefineScheme","PEP_REFINE_SCHEME_",0}; const char *PEPExtractTypes[] = {"","NONE","NORM","RESIDUAL","STRUCTURED","PEPExtract","PEP_EXTRACT_",0}; const char *PEPErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","PEPErrorType","PEP_ERROR_",0}; const char *const PEPConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","PEPConvergedReason","PEP_",0}; const char *const*PEPConvergedReasons = PEPConvergedReasons_Shifted + 4; #undef __FUNCT__ #define __FUNCT__ "PEPFinalizePackage" /*@C PEPFinalizePackage - This function destroys everything in the Slepc interface to the PEP package. It is called from SlepcFinalize(). Level: developer .seealso: SlepcFinalize() @*/ PetscErrorCode PEPFinalizePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFunctionListDestroy(&PEPList);CHKERRQ(ierr); PEPPackageInitialized = PETSC_FALSE; PEPRegisterAllCalled = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPInitializePackage" /*@C PEPInitializePackage - This function initializes everything in the PEP package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PEPCreate() when using static libraries. Level: developer .seealso: SlepcInitialize() @*/ PetscErrorCode PEPInitializePackage(void) { char logList[256]; char *className; PetscBool opt; PetscErrorCode ierr; PetscFunctionBegin; if (PEPPackageInitialized) PetscFunctionReturn(0); PEPPackageInitialized = PETSC_TRUE; /* Register Classes */ ierr = PetscClassIdRegister("PEP Solver",&PEP_CLASSID);CHKERRQ(ierr); /* Register Constructors */ ierr = PEPRegisterAll();CHKERRQ(ierr); /* Register Events */ ierr = PetscLogEventRegister("PEPSetUp",PEP_CLASSID,&PEP_SetUp);CHKERRQ(ierr); ierr = PetscLogEventRegister("PEPSolve",PEP_CLASSID,&PEP_Solve);CHKERRQ(ierr); ierr = PetscLogEventRegister("PEPRefine",PEP_CLASSID,&PEP_Refine);CHKERRQ(ierr); /* Process info exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"pep",&className);CHKERRQ(ierr); if (className) { ierr = PetscInfoDeactivateClass(PEP_CLASSID);CHKERRQ(ierr); } } /* Process summary exclusions */ ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscStrstr(logList,"pep",&className);CHKERRQ(ierr); if (className) { ierr = PetscLogEventDeactivateClass(PEP_CLASSID);CHKERRQ(ierr); } } ierr = PetscRegisterFinalize(PEPFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); } #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) #undef __FUNCT__ #define __FUNCT__ "PetscDLLibraryRegister_slepcpep" /* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the PEP methods that are in the basic SLEPc libslepcpep library. */ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcpep() { PetscErrorCode ierr; PetscFunctionBegin; ierr = PEPInitializePackage();CHKERRQ(ierr); PetscFunctionReturn(0); } #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ slepc-3.7.4/src/pep/interface/pepdefault.c0000644000175000017500000004463213107004621020004 0ustar jromanjroman/* This file contains some simple default routines for common PEP operations. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #undef __FUNCT__ #define __FUNCT__ "PEPSetWorkVecs" /*@ PEPSetWorkVecs - Sets a number of work vectors into a PEP object. Collective on PEP Input Parameters: + pep - polynomial eigensolver context - nw - number of work vectors to allocate Developers Note: This is PETSC_EXTERN because it may be required by user plugin PEP implementations. Level: developer @*/ PetscErrorCode PEPSetWorkVecs(PEP pep,PetscInt nw) { PetscErrorCode ierr; Vec t; PetscFunctionBegin; if (pep->nwork < nw) { ierr = VecDestroyVecs(pep->nwork,&pep->work);CHKERRQ(ierr); pep->nwork = nw; ierr = BVGetColumn(pep->V,0,&t);CHKERRQ(ierr); ierr = VecDuplicateVecs(t,nw,&pep->work);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,0,&t);CHKERRQ(ierr); ierr = PetscLogObjectParents(pep,nw,pep->work);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPConvergedRelative" /* PEPConvergedRelative - Checks convergence relative to the eigenvalue. */ PetscErrorCode PEPConvergedRelative(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscReal w; PetscFunctionBegin; w = SlepcAbsEigenvalue(eigr,eigi); *errest = res/w; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPConvergedNorm" /* PEPConvergedNorm - Checks convergence relative to the matrix norms. */ PetscErrorCode PEPConvergedNorm(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscReal w=0.0,t; PetscInt j; PetscBool flg; PetscErrorCode ierr; PetscFunctionBegin; /* initialization of matrix norms */ if (!pep->nrma[pep->nmat-1]) { for (j=0;jnmat;j++) { ierr = MatHasOperation(pep->A[j],MATOP_NORM,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONG,"The convergence test related to the matrix norms requires a matrix norm operation"); ierr = MatNorm(pep->A[j],NORM_INFINITY,&pep->nrma[j]);CHKERRQ(ierr); } } t = SlepcAbsEigenvalue(eigr,eigi); for (j=pep->nmat-1;j>=0;j--) { w = w*t+pep->nrma[j]; } *errest = res/w; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPConvergedAbsolute" /* PEPConvergedAbsolute - Checks convergence absolutely. */ PetscErrorCode PEPConvergedAbsolute(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscFunctionBegin; *errest = res; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPStoppingBasic" /*@C PEPStoppingBasic - Default routine to determine whether the outer eigensolver iteration must be stopped. Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged eigenpairs . nev - number of requested eigenpairs - ctx - context (not used here) Output Parameter: . reason - result of the stopping test Notes: A positive value of reason indicates that the iteration has finished successfully (converged), and a negative value indicates an error condition (diverged). If the iteration needs to be continued, reason must be set to PEP_CONVERGED_ITERATING (zero). PEPStoppingBasic() will stop if all requested eigenvalues are converged, or if the maximum number of iterations has been reached. Use PEPSetStoppingTest() to provide your own test instead of using this one. Level: advanced .seealso: PEPSetStoppingTest(), PEPConvergedReason, PEPGetConvergedReason() @*/ PetscErrorCode PEPStoppingBasic(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx) { PetscErrorCode ierr; PetscFunctionBegin; *reason = PEP_CONVERGED_ITERATING; if (nconv >= nev) { ierr = PetscInfo2(pep,"Polynomial eigensolver finished successfully: %D eigenpairs converged at iteration %D\n",nconv,its);CHKERRQ(ierr); *reason = PEP_CONVERGED_TOL; } else if (its >= max_it) { *reason = PEP_DIVERGED_ITS; ierr = PetscInfo1(pep,"Polynomial eigensolver iteration reached maximum number of iterations (%D)\n",its);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPBackTransform_Default" PetscErrorCode PEPBackTransform_Default(PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; ierr = STBackTransform(pep->st,pep->nconv,pep->eigr,pep->eigi);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPComputeVectors_Default" PetscErrorCode PEPComputeVectors_Default(PEP pep) { PetscErrorCode ierr; PetscInt i; Vec v; #if !defined(PETSC_USE_COMPLEX) Vec v1; #endif PetscFunctionBegin; ierr = PEPExtractVectors(pep);CHKERRQ(ierr); /* Fix eigenvectors if balancing was used */ if ((pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) && pep->Dr && (pep->refine!=PEP_REFINE_MULTIPLE)) { for (i=0;inconv;i++) { ierr = BVGetColumn(pep->V,i,&v);CHKERRQ(ierr); ierr = VecPointwiseMult(v,v,pep->Dr);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i,&v);CHKERRQ(ierr); } } /* normalization */ for (i=0;inconv;i++) { #if !defined(PETSC_USE_COMPLEX) if (pep->eigi[i]!=0.0) { /* first eigenvalue of a complex conjugate pair */ ierr = BVGetColumn(pep->V,i,&v);CHKERRQ(ierr); ierr = BVGetColumn(pep->V,i+1,&v1);CHKERRQ(ierr); ierr = SlepcVecNormalize(v,v1,PETSC_TRUE,NULL);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i,&v);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i+1,&v1);CHKERRQ(ierr); i++; } else /* real eigenvalue */ #endif { ierr = BVGetColumn(pep->V,i,&v);CHKERRQ(ierr); ierr = SlepcVecNormalize(v,NULL,PETSC_FALSE,NULL);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i,&v);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPKrylovConvergence" /* PEPKrylovConvergence - This is the analogue to EPSKrylovConvergence, but for polynomial Krylov methods. Differences: - Always non-symmetric - Does not check for STSHIFT - No correction factor - No support for true residual */ PetscErrorCode PEPKrylovConvergence(PEP pep,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscInt *kout) { PetscErrorCode ierr; PetscInt k,newk,marker,inside; PetscScalar re,im; PetscReal resnorm; PetscBool istrivial; PetscFunctionBegin; ierr = RGIsTrivial(pep->rg,&istrivial);CHKERRQ(ierr); marker = -1; if (pep->trackall) getall = PETSC_TRUE; for (k=kini;keigr[k]; im = pep->eigi[k]; if (!istrivial) { ierr = STBackTransform(pep->st,1,&re,&im);CHKERRQ(ierr); ierr = RGCheckInside(pep->rg,1,&re,&im,&inside);CHKERRQ(ierr); if (marker==-1 && inside<0) marker = k; re = pep->eigr[k]; im = pep->eigi[k]; } newk = k; ierr = DSVectors(pep->ds,DS_MAT_X,&newk,&resnorm);CHKERRQ(ierr); resnorm *= beta; /* error estimate */ ierr = (*pep->converged)(pep,re,im,resnorm,&pep->errest[k],pep->convergedctx);CHKERRQ(ierr); if (marker==-1 && pep->errest[k] >= pep->tol) marker = k; if (newk==k+1) { pep->errest[k+1] = pep->errest[k]; k++; } if (marker!=-1 && !getall) break; } if (marker!=-1) k = marker; *kout = k; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPBuildDiagonalScaling" /* PEPBuildDiagonalScaling - compute two diagonal matrices to be applied for balancing in polynomial eigenproblems. */ PetscErrorCode PEPBuildDiagonalScaling(PEP pep) { PetscErrorCode ierr; PetscInt it,i,j,k,nmat,nr,e,nz,lst,lend,nc=0,*cols,emax,emin,emaxl,eminl; const PetscInt *cidx,*ridx; Mat M,*T,A; PetscMPIInt n; PetscBool cont=PETSC_TRUE,flg=PETSC_FALSE; PetscScalar *array,*Dr,*Dl,t; PetscReal l2,d,*rsum,*aux,*csum,w=1.0; MatStructure str; MatInfo info; PetscFunctionBegin; l2 = 2*PetscLogReal(2.0); nmat = pep->nmat; ierr = PetscMPIIntCast(pep->n,&n);CHKERRQ(ierr); ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = PetscMalloc1(nmat,&T);CHKERRQ(ierr); for (k=0;kst,k,&T[k]);CHKERRQ(ierr); } /* Form local auxiliar matrix M */ ierr = PetscObjectTypeCompareAny((PetscObject)T[0],&cont,MATMPIAIJ,MATSEQAIJ,"");CHKERRQ(ierr); if (!cont) SETERRQ(PetscObjectComm((PetscObject)T[0]),PETSC_ERR_SUP,"Only for MPIAIJ or SEQAIJ matrix types"); ierr = PetscObjectTypeCompare((PetscObject)T[0],MATMPIAIJ,&cont);CHKERRQ(ierr); if (cont) { ierr = MatMPIAIJGetLocalMat(T[0],MAT_INITIAL_MATRIX,&M);CHKERRQ(ierr); flg = PETSC_TRUE; } else { ierr = MatDuplicate(T[0],MAT_COPY_VALUES,&M);CHKERRQ(ierr); } ierr = MatGetInfo(M,MAT_LOCAL,&info);CHKERRQ(ierr); nz = (PetscInt)info.nz_used; ierr = MatSeqAIJGetArray(M,&array);CHKERRQ(ierr); for (i=0;islambda*pep->slambda*pep->sfactor; ierr = MatAXPY(M,w,A,str);CHKERRQ(ierr); if (flg || str!=SAME_NONZERO_PATTERN || k==nmat-2) { ierr = MatDestroy(&A);CHKERRQ(ierr); } } ierr = MatGetRowIJ(M,0,PETSC_FALSE,PETSC_FALSE,&nr,&ridx,&cidx,&cont);CHKERRQ(ierr); if (!cont) SETERRQ(PetscObjectComm((PetscObject)T[0]), PETSC_ERR_SUP,"It is not possible to compute scaling diagonals for these PEP matrices"); ierr = MatGetInfo(M,MAT_LOCAL,&info);CHKERRQ(ierr); nz = (PetscInt)info.nz_used; ierr = VecGetOwnershipRange(pep->Dl,&lst,&lend);CHKERRQ(ierr); ierr = PetscMalloc4(nr,&rsum,pep->n,&csum,pep->n,&aux,PetscMin(pep->n-lend+lst,nz),&cols);CHKERRQ(ierr); ierr = VecSet(pep->Dr,1.0);CHKERRQ(ierr); ierr = VecSet(pep->Dl,1.0);CHKERRQ(ierr); ierr = VecGetArray(pep->Dl,&Dl);CHKERRQ(ierr); ierr = VecGetArray(pep->Dr,&Dr);CHKERRQ(ierr); ierr = MatSeqAIJGetArray(M,&array);CHKERRQ(ierr); ierr = PetscMemzero(aux,pep->n*sizeof(PetscReal));CHKERRQ(ierr); for (j=0;jsits && cont;it++) { emaxl = 0; eminl = 0; /* Column sum */ if (it>0) { /* it=0 has been already done*/ ierr = MatSeqAIJGetArray(M,&array);CHKERRQ(ierr); ierr = PetscMemzero(aux,pep->n*sizeof(PetscReal));CHKERRQ(ierr); for (j=0;jDr));CHKERRQ(ierr); /* Update Dr */ for (j=lst;jDl));CHKERRQ(ierr); ierr = MPI_Allreduce(&eminl,&emin,1,MPIU_INT,MPI_MIN,PetscObjectComm((PetscObject)pep->Dl));CHKERRQ(ierr); if (emax<=emin+2) cont = PETSC_FALSE; } ierr = VecRestoreArray(pep->Dr,&Dr);CHKERRQ(ierr); ierr = VecRestoreArray(pep->Dl,&Dl);CHKERRQ(ierr); /* Free memory*/ ierr = MatDestroy(&M);CHKERRQ(ierr); ierr = PetscFree4(rsum,csum,aux,cols);CHKERRQ(ierr); ierr = PetscFree(T);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPComputeScaleFactor" /* PEPComputeScaleFactor - compute sfactor as described in [Betcke 2008]. */ PetscErrorCode PEPComputeScaleFactor(PEP pep) { PetscErrorCode ierr; PetscBool has0,has1,flg; PetscReal norm0,norm1; Mat T[2]; PEPBasis basis; PetscInt i; PetscFunctionBegin; if (pep->scale==PEP_SCALE_NONE || pep->scale==PEP_SCALE_DIAGONAL) { /* no scalar scaling */ pep->sfactor = 1.0; pep->dsfactor = 1.0; PetscFunctionReturn(0); } if (pep->sfactor_set) PetscFunctionReturn(0); /* user provided value */ pep->sfactor = 1.0; pep->dsfactor = 1.0; ierr = PEPGetBasis(pep,&basis);CHKERRQ(ierr); if (basis==PEP_BASIS_MONOMIAL) { ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) { ierr = STGetTOperators(pep->st,0,&T[0]);CHKERRQ(ierr); ierr = STGetTOperators(pep->st,pep->nmat-1,&T[1]);CHKERRQ(ierr); } else { T[0] = pep->A[0]; T[1] = pep->A[pep->nmat-1]; } if (pep->nmat>2) { ierr = MatHasOperation(T[0],MATOP_NORM,&has0);CHKERRQ(ierr); ierr = MatHasOperation(T[1],MATOP_NORM,&has1);CHKERRQ(ierr); if (has0 && has1) { ierr = MatNorm(T[0],NORM_INFINITY,&norm0);CHKERRQ(ierr); ierr = MatNorm(T[1],NORM_INFINITY,&norm1);CHKERRQ(ierr); pep->sfactor = PetscPowReal(norm0/norm1,1.0/(pep->nmat-1)); pep->dsfactor = norm1; for (i=pep->nmat-2;i>0;i--) { ierr = STGetTOperators(pep->st,i,&T[1]);CHKERRQ(ierr); ierr = MatHasOperation(T[1],MATOP_NORM,&has1);CHKERRQ(ierr); if (has1) { ierr = MatNorm(T[1],NORM_INFINITY,&norm1);CHKERRQ(ierr); pep->dsfactor = pep->dsfactor*pep->sfactor+norm1; } else break; } if (has1) { pep->dsfactor = pep->dsfactor*pep->sfactor+norm0; pep->dsfactor = pep->nmat/pep->dsfactor; } else pep->dsfactor = 1.0; } } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPBasisCoefficients" /* PEPBasisCoefficients - compute polynomial basis coefficients */ PetscErrorCode PEPBasisCoefficients(PEP pep,PetscReal *pbc) { PetscReal *ca,*cb,*cg; PetscInt k,nmat=pep->nmat; PetscFunctionBegin; ca = pbc; cb = pbc+nmat; cg = pbc+2*nmat; switch (pep->basis) { case PEP_BASIS_MONOMIAL: for (k=0;knmat,k; PetscReal *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat; PetscFunctionBegin; if (ivals) for (k=0;kActual source code: pepopts.c
slepc-3.7.4 2017-05-17
  1: /*
  2:       PEP routines related to options that can be set via the command-line
  3:       or procedurally.

  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: */

 25: #include <slepc/private/pepimpl.h>       /*I "slepcpep.h" I*/
 26: #include <petscdraw.h>

 30: /*@C
 31:    PEPMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 32:    indicated by the user.

 34:    Collective on PEP

 36:    Input Parameters:
 37: +  pep      - the polynomial eigensolver context
 38: .  name     - the monitor option name
 39: .  help     - message indicating what monitoring is done
 40: .  manual   - manual page for the monitor
 41: .  monitor  - the monitor function, whose context is a PetscViewerAndFormat
 42: -  trackall - whether this monitor tracks all eigenvalues or not

 44:    Level: developer

 46: .seealso: PEPMonitorSet(), PEPSetTrackAll(), PEPConvMonitorSetFromOptions()
 47: @*/
 48: PetscErrorCode PEPMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)
 49: {
 50:   PetscErrorCode       ierr;
 51:   PetscBool            flg;
 52:   PetscViewer          viewer;
 53:   PetscViewerFormat    format;
 54:   PetscViewerAndFormat *vf;

 57:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,name,&viewer,&format,&flg);
 58:   if (flg) {
 59:     PetscViewerAndFormatCreate(viewer,format,&vf);
 60:     PetscObjectDereference((PetscObject)viewer);
 61:     PEPMonitorSet(pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
 62:     if (trackall) {
 63:       PEPSetTrackAll(pep,PETSC_TRUE);
 64:     }
 65:   }
 66:   return(0);
 67: }

 71: /*@C
 72:    PEPConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
 73:    indicated by the user (for monitors that only show iteration numbers of convergence).

 75:    Collective on PEP

 77:    Input Parameters:
 78: +  pep      - the polynomial eigensolver context
 79: .  name     - the monitor option name
 80: .  help     - message indicating what monitoring is done
 81: .  manual   - manual page for the monitor
 82: -  monitor  - the monitor function, whose context is a SlepcConvMonitor

 84:    Level: developer

 86: .seealso: PEPMonitorSet(), PEPMonitorSetFromOptions()
 87: @*/
 88: PetscErrorCode PEPConvMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))
 89: {
 90:   PetscErrorCode    ierr;
 91:   PetscBool         flg;
 92:   PetscViewer       viewer;
 93:   PetscViewerFormat format;
 94:   SlepcConvMonitor  ctx;

 97:   PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,name,&viewer,&format,&flg);
 98:   if (flg) {
 99:     SlepcConvMonitorCreate(viewer,format,&ctx);
100:     PetscObjectDereference((PetscObject)viewer);
101:     PEPMonitorSet(pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);
102:   }
103:   return(0);
104: }

108: /*@
109:    PEPSetFromOptions - Sets PEP options from the options database.
110:    This routine must be called before PEPSetUp() if the user is to be
111:    allowed to set the solver type.

113:    Collective on PEP

115:    Input Parameters:
116: .  pep - the polynomial eigensolver context

118:    Notes:
119:    To see all options, run your program with the -help option.

121:    Level: beginner
122: @*/
123: PetscErrorCode PEPSetFromOptions(PEP pep)
124: {
126:   char           type[256];
127:   PetscBool      set,flg,flg1,flg2,flg3;
128:   PetscReal      r,t;
129:   PetscScalar    s;
130:   PetscInt       i,j,k;
131:   PetscDrawLG    lg;

135:   PEPRegisterAll();
136:   PetscObjectOptionsBegin((PetscObject)pep);
137:     PetscOptionsFList("-pep_type","Polynomial Eigenvalue Problem method","PEPSetType",PEPList,(char*)(((PetscObject)pep)->type_name?((PetscObject)pep)->type_name:PEPTOAR),type,256,&flg);
138:     if (flg) {
139:       PEPSetType(pep,type);
140:     } else if (!((PetscObject)pep)->type_name) {
141:       PEPSetType(pep,PEPTOAR);
142:     }

144:     PetscOptionsBoolGroupBegin("-pep_general","general polynomial eigenvalue problem","PEPSetProblemType",&flg);
145:     if (flg) { PEPSetProblemType(pep,PEP_GENERAL); }
146:     PetscOptionsBoolGroup("-pep_hermitian","hermitian polynomial eigenvalue problem","PEPSetProblemType",&flg);
147:     if (flg) { PEPSetProblemType(pep,PEP_HERMITIAN); }
148:     PetscOptionsBoolGroupEnd("-pep_gyroscopic","gyroscopic polynomial eigenvalue problem","PEPSetProblemType",&flg);
149:     if (flg) { PEPSetProblemType(pep,PEP_GYROSCOPIC); }

151:     PetscOptionsEnum("-pep_scale","Scaling strategy","PEPSetScale",PEPScaleTypes,(PetscEnum)pep->scale,(PetscEnum*)&pep->scale,NULL);

153:     r = pep->sfactor;
154:     PetscOptionsReal("-pep_scale_factor","Scale factor","PEPSetScale",pep->sfactor,&r,&flg1);
155:     j = pep->sits;
156:     PetscOptionsInt("-pep_scale_its","Number of iterations in diagonal scaling","PEPSetScale",pep->sits,&j,&flg2);
157:     t = pep->slambda;
158:     PetscOptionsReal("-pep_scale_lambda","Estimate of eigenvalue (modulus) for diagonal scaling","PEPSetScale",pep->slambda,&t,&flg3);
159:     if (flg1 || flg2 || flg3) {
160:       PEPSetScale(pep,pep->scale,r,NULL,NULL,j,t);
161:     }

163:     PetscOptionsEnum("-pep_extract","Extraction method","PEPSetExtract",PEPExtractTypes,(PetscEnum)pep->extract,(PetscEnum*)&pep->extract,NULL);

165:     PetscOptionsEnum("-pep_refine","Iterative refinement method","PEPSetRefine",PEPRefineTypes,(PetscEnum)pep->refine,(PetscEnum*)&pep->refine,NULL);

167:     i = pep->npart;
168:     PetscOptionsInt("-pep_refine_partitions","Number of partitions of the communicator for iterative refinement","PEPSetRefine",pep->npart,&i,&flg1);
169:     r = pep->rtol;
170:     PetscOptionsReal("-pep_refine_tol","Tolerance for iterative refinement","PEPSetRefine",pep->rtol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/1000:pep->rtol,&r,&flg2);
171:     j = pep->rits;
172:     PetscOptionsInt("-pep_refine_its","Maximum number of iterations for iterative refinement","PEPSetRefine",pep->rits,&j,&flg3);
173:     if (flg1 || flg2 || flg3) {
174:       PEPSetRefine(pep,pep->refine,i,r,j,pep->scheme);
175:     }

177:     PetscOptionsEnum("-pep_refine_scheme","Scheme used for linear systems within iterative refinement","PEPSetRefine",PEPRefineSchemes,(PetscEnum)pep->scheme,(PetscEnum*)&pep->scheme,NULL);

179:     i = pep->max_it? pep->max_it: PETSC_DEFAULT;
180:     PetscOptionsInt("-pep_max_it","Maximum number of iterations","PEPSetTolerances",pep->max_it,&i,&flg1);
181:     r = pep->tol;
182:     PetscOptionsReal("-pep_tol","Tolerance","PEPSetTolerances",pep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:pep->tol,&r,&flg2);
183:     if (flg1 || flg2) {
184:       PEPSetTolerances(pep,r,i);
185:     }

187:     PetscOptionsBoolGroupBegin("-pep_conv_rel","Relative error convergence test","PEPSetConvergenceTest",&flg);
188:     if (flg) { PEPSetConvergenceTest(pep,PEP_CONV_REL); }
189:     PetscOptionsBoolGroupBegin("-pep_conv_norm","Convergence test relative to the matrix norms","PEPSetConvergenceTest",&flg);
190:     if (flg) { PEPSetConvergenceTest(pep,PEP_CONV_NORM); }
191:     PetscOptionsBoolGroup("-pep_conv_abs","Absolute error convergence test","PEPSetConvergenceTest",&flg);
192:     if (flg) { PEPSetConvergenceTest(pep,PEP_CONV_ABS); }
193:     PetscOptionsBoolGroupEnd("-pep_conv_user","User-defined convergence test","PEPSetConvergenceTest",&flg);
194:     if (flg) { PEPSetConvergenceTest(pep,PEP_CONV_USER); }

196:     PetscOptionsBoolGroupBegin("-pep_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","PEPSetStoppingTest",&flg);
197:     if (flg) { PEPSetStoppingTest(pep,PEP_STOP_BASIC); }
198:     PetscOptionsBoolGroupEnd("-pep_stop_user","User-defined stopping test","PEPSetStoppingTest",&flg);
199:     if (flg) { PEPSetStoppingTest(pep,PEP_STOP_USER); }

201:     i = pep->nev;
202:     PetscOptionsInt("-pep_nev","Number of eigenvalues to compute","PEPSetDimensions",pep->nev,&i,&flg1);
203:     j = pep->ncv? pep->ncv: PETSC_DEFAULT;
204:     PetscOptionsInt("-pep_ncv","Number of basis vectors","PEPSetDimensions",pep->ncv,&j,&flg2);
205:     k = pep->mpd? pep->mpd: PETSC_DEFAULT;
206:     PetscOptionsInt("-pep_mpd","Maximum dimension of projected problem","PEPSetDimensions",pep->mpd,&k,&flg3);
207:     if (flg1 || flg2 || flg3) {
208:       PEPSetDimensions(pep,i,j,k);
209:     }

211:     PetscOptionsScalar("-pep_target","Value of the target","PEPSetTarget",pep->target,&s,&flg);
212:     if (flg) {
213:       PEPSetWhichEigenpairs(pep,PEP_TARGET_MAGNITUDE);
214:       PEPSetTarget(pep,s);
215:     }

217:     PetscOptionsEnum("-pep_basis","Polynomial basis","PEPSetBasis",PEPBasisTypes,(PetscEnum)pep->basis,(PetscEnum*)&pep->basis,NULL);

219:     /* -----------------------------------------------------------------------*/
220:     /*
221:       Cancels all monitors hardwired into code before call to PEPSetFromOptions()
222:     */
223:     PetscOptionsBool("-pep_monitor_cancel","Remove any hardwired monitor routines","PEPMonitorCancel",PETSC_FALSE,&flg,&set);
224:     if (set && flg) {
225:       PEPMonitorCancel(pep);
226:     }
227:     /*
228:       Text monitors
229:     */
230:     PEPMonitorSetFromOptions(pep,"-pep_monitor","Monitor first unconverged approximate eigenvalue and error estimate","PEPMonitorFirst",PEPMonitorFirst,PETSC_FALSE);
231:     PEPConvMonitorSetFromOptions(pep,"-pep_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","PEPMonitorConverged",PEPMonitorConverged);
232:     PEPMonitorSetFromOptions(pep,"-pep_monitor_all","Monitor approximate eigenvalues and error estimates","PEPMonitorAll",PEPMonitorAll,PETSC_TRUE);
233:     /*
234:       Line graph monitors
235:     */
236:     PetscOptionsBool("-pep_monitor_lg","Monitor first unconverged approximate error estimate graphically","PEPMonitorSet",PETSC_FALSE,&flg,&set);
237:     if (set && flg) {
238:       PEPMonitorLGCreate(PetscObjectComm((PetscObject)pep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
239:       PEPMonitorSet(pep,PEPMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
240:     }
241:     PetscOptionsBool("-pep_monitor_lg_all","Monitor error estimates graphically","PEPMonitorSet",PETSC_FALSE,&flg,&set);
242:     if (set && flg) {
243:       PEPMonitorLGCreate(PetscObjectComm((PetscObject)pep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);
244:       PEPMonitorSet(pep,PEPMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);
245:       PEPSetTrackAll(pep,PETSC_TRUE);
246:     }
247:   /* -----------------------------------------------------------------------*/

249:     PetscOptionsBoolGroupBegin("-pep_largest_magnitude","compute largest eigenvalues in magnitude","PEPSetWhichEigenpairs",&flg);
250:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_LARGEST_MAGNITUDE); }
251:     PetscOptionsBoolGroup("-pep_smallest_magnitude","compute smallest eigenvalues in magnitude","PEPSetWhichEigenpairs",&flg);
252:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_SMALLEST_MAGNITUDE); }
253:     PetscOptionsBoolGroup("-pep_largest_real","compute largest real parts","PEPSetWhichEigenpairs",&flg);
254:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_LARGEST_REAL); }
255:     PetscOptionsBoolGroup("-pep_smallest_real","compute smallest real parts","PEPSetWhichEigenpairs",&flg);
256:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_SMALLEST_REAL); }
257:     PetscOptionsBoolGroup("-pep_largest_imaginary","compute largest imaginary parts","PEPSetWhichEigenpairs",&flg);
258:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_LARGEST_IMAGINARY); }
259:     PetscOptionsBoolGroup("-pep_smallest_imaginary","compute smallest imaginary parts","PEPSetWhichEigenpairs",&flg);
260:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_SMALLEST_IMAGINARY); }
261:     PetscOptionsBoolGroup("-pep_target_magnitude","compute nearest eigenvalues to target","PEPSetWhichEigenpairs",&flg);
262:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_TARGET_MAGNITUDE); }
263:     PetscOptionsBoolGroup("-pep_target_real","compute eigenvalues with real parts close to target","PEPSetWhichEigenpairs",&flg);
264:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_TARGET_REAL); }
265:     PetscOptionsBoolGroupEnd("-pep_target_imaginary","compute eigenvalues with imaginary parts close to target","PEPSetWhichEigenpairs",&flg);
266:     if (flg) { PEPSetWhichEigenpairs(pep,PEP_TARGET_IMAGINARY); }

268:     PetscOptionsName("-pep_view","Print detailed information on solver used","PEPView",NULL);
269:     PetscOptionsName("-pep_view_vectors","View computed eigenvectors","PEPVectorsView",NULL);
270:     PetscOptionsName("-pep_view_values","View computed eigenvalues","PEPValuesView",NULL);
271:     PetscOptionsName("-pep_converged_reason","Print reason for convergence, and number of iterations","PEPReasonView",NULL);
272:     PetscOptionsName("-pep_error_absolute","Print absolute errors of each eigenpair","PEPErrorView",NULL);
273:     PetscOptionsName("-pep_error_relative","Print relative errors of each eigenpair","PEPErrorView",NULL);
274:     PetscOptionsName("-pep_error_backward","Print backward errors of each eigenpair","PEPErrorView",NULL);

276:     if (pep->ops->setfromoptions) {
277:       (*pep->ops->setfromoptions)(PetscOptionsObject,pep);
278:     }
279:     PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)pep);
280:   PetscOptionsEnd();

282:   if (!pep->V) { PEPGetBV(pep,&pep->V); }
283:   BVSetFromOptions(pep->V);
284:   if (!pep->rg) { PEPGetRG(pep,&pep->rg); }
285:   RGSetFromOptions(pep->rg);
286:   if (!pep->ds) { PEPGetDS(pep,&pep->ds); }
287:   DSSetFromOptions(pep->ds);
288:   if (!pep->st) { PEPGetST(pep,&pep->st); }
289:   STSetFromOptions(pep->st);
290:   if (!pep->refineksp) { PEPRefineGetKSP(pep,&pep->refineksp); }
291:   KSPSetFromOptions(pep->refineksp);
292:   return(0);
293: }

297: /*@
298:    PEPGetTolerances - Gets the tolerance and maximum iteration count used
299:    by the PEP convergence tests.

301:    Not Collective

303:    Input Parameter:
304: .  pep - the polynomial eigensolver context

306:    Output Parameters:
307: +  tol - the convergence tolerance
308: -  maxits - maximum number of iterations

310:    Notes:
311:    The user can specify NULL for any parameter that is not needed.

313:    Level: intermediate

315: .seealso: PEPSetTolerances()
316: @*/
317: PetscErrorCode PEPGetTolerances(PEP pep,PetscReal *tol,PetscInt *maxits)
318: {
321:   if (tol)    *tol    = pep->tol;
322:   if (maxits) *maxits = pep->max_it;
323:   return(0);
324: }

328: /*@
329:    PEPSetTolerances - Sets the tolerance and maximum iteration count used
330:    by the PEP convergence tests.

332:    Logically Collective on PEP

334:    Input Parameters:
335: +  pep - the polynomial eigensolver context
336: .  tol - the convergence tolerance
337: -  maxits - maximum number of iterations to use

339:    Options Database Keys:
340: +  -pep_tol <tol> - Sets the convergence tolerance
341: -  -pep_max_it <maxits> - Sets the maximum number of iterations allowed

343:    Notes:
344:    Use PETSC_DEFAULT for either argument to assign a reasonably good value.

346:    Level: intermediate

348: .seealso: PEPGetTolerances()
349: @*/
350: PetscErrorCode PEPSetTolerances(PEP pep,PetscReal tol,PetscInt maxits)
351: {
356:   if (tol == PETSC_DEFAULT) {
357:     pep->tol   = PETSC_DEFAULT;
358:     pep->state = PEP_STATE_INITIAL;
359:   } else {
360:     if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
361:     pep->tol = tol;
362:   }
363:   if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
364:     pep->max_it = 0;
365:     pep->state  = PEP_STATE_INITIAL;
366:   } else {
367:     if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
368:     pep->max_it = maxits;
369:   }
370:   return(0);
371: }

375: /*@
376:    PEPGetDimensions - Gets the number of eigenvalues to compute
377:    and the dimension of the subspace.

379:    Not Collective

381:    Input Parameter:
382: .  pep - the polynomial eigensolver context

384:    Output Parameters:
385: +  nev - number of eigenvalues to compute
386: .  ncv - the maximum dimension of the subspace to be used by the solver
387: -  mpd - the maximum dimension allowed for the projected problem

389:    Notes:
390:    The user can specify NULL for any parameter that is not needed.

392:    Level: intermediate

394: .seealso: PEPSetDimensions()
395: @*/
396: PetscErrorCode PEPGetDimensions(PEP pep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
397: {
400:   if (nev) *nev = pep->nev;
401:   if (ncv) *ncv = pep->ncv;
402:   if (mpd) *mpd = pep->mpd;
403:   return(0);
404: }

408: /*@
409:    PEPSetDimensions - Sets the number of eigenvalues to compute
410:    and the dimension of the subspace.

412:    Logically Collective on PEP

414:    Input Parameters:
415: +  pep - the polynomial eigensolver context
416: .  nev - number of eigenvalues to compute
417: .  ncv - the maximum dimension of the subspace to be used by the solver
418: -  mpd - the maximum dimension allowed for the projected problem

420:    Options Database Keys:
421: +  -pep_nev <nev> - Sets the number of eigenvalues
422: .  -pep_ncv <ncv> - Sets the dimension of the subspace
423: -  -pep_mpd <mpd> - Sets the maximum projected dimension

425:    Notes:
426:    Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is
427:    dependent on the solution method.

429:    The parameters ncv and mpd are intimately related, so that the user is advised
430:    to set one of them at most. Normal usage is that
431:    (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and
432:    (b) in cases where nev is large, the user sets mpd.

434:    The value of ncv should always be between nev and (nev+mpd), typically
435:    ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise
436:    a smaller value should be used.

438:    Level: intermediate

440: .seealso: PEPGetDimensions()
441: @*/
442: PetscErrorCode PEPSetDimensions(PEP pep,PetscInt nev,PetscInt ncv,PetscInt mpd)
443: {
449:   if (nev<1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
450:   pep->nev = nev;
451:   if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) {
452:     pep->ncv = 0;
453:   } else {
454:     if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
455:     pep->ncv = ncv;
456:   }
457:   if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) {
458:     pep->mpd = 0;
459:   } else {
460:     if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
461:     pep->mpd = mpd;
462:   }
463:   pep->state = PEP_STATE_INITIAL;
464:   return(0);
465: }

469: /*@
470:    PEPSetWhichEigenpairs - Specifies which portion of the spectrum is
471:    to be sought.

473:    Logically Collective on PEP

475:    Input Parameters:
476: +  pep   - eigensolver context obtained from PEPCreate()
477: -  which - the portion of the spectrum to be sought

479:    Possible values:
480:    The parameter 'which' can have one of these values

482: +     PEP_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default)
483: .     PEP_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude
484: .     PEP_LARGEST_REAL - largest real parts
485: .     PEP_SMALLEST_REAL - smallest real parts
486: .     PEP_LARGEST_IMAGINARY - largest imaginary parts
487: .     PEP_SMALLEST_IMAGINARY - smallest imaginary parts
488: .     PEP_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude)
489: .     PEP_TARGET_REAL - eigenvalues with real part closest to target
490: .     PEP_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target
491: -     PEP_WHICH_USER - user defined ordering set with PEPSetEigenvalueComparison()

493:    Options Database Keys:
494: +   -pep_largest_magnitude - Sets largest eigenvalues in magnitude
495: .   -pep_smallest_magnitude - Sets smallest eigenvalues in magnitude
496: .   -pep_largest_real - Sets largest real parts
497: .   -pep_smallest_real - Sets smallest real parts
498: .   -pep_largest_imaginary - Sets largest imaginary parts
499: .   -pep_smallest_imaginary - Sets smallest imaginary parts
500: .   -pep_target_magnitude - Sets eigenvalues closest to target
501: .   -pep_target_real - Sets real parts closest to target
502: -   -pep_target_imaginary - Sets imaginary parts closest to target

504:    Notes:
505:    Not all eigensolvers implemented in PEP account for all the possible values
506:    stated above. If SLEPc is compiled for real numbers PEP_LARGEST_IMAGINARY
507:    and PEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part
508:    for eigenvalue selection.

510:    The target is a scalar value provided with PEPSetTarget().

512:    The criterion PEP_TARGET_IMAGINARY is available only in case PETSc and
513:    SLEPc have been built with complex scalars.

515:    Level: intermediate

517: .seealso: PEPGetWhichEigenpairs(), PEPSetTarget(), PEPSetEigenvalueComparison(), PEPWhich
518: @*/
519: PetscErrorCode PEPSetWhichEigenpairs(PEP pep,PEPWhich which)
520: {
524:   switch (which) {
525:     case PEP_LARGEST_MAGNITUDE:
526:     case PEP_SMALLEST_MAGNITUDE:
527:     case PEP_LARGEST_REAL:
528:     case PEP_SMALLEST_REAL:
529:     case PEP_LARGEST_IMAGINARY:
530:     case PEP_SMALLEST_IMAGINARY:
531:     case PEP_TARGET_MAGNITUDE:
532:     case PEP_TARGET_REAL:
533: #if defined(PETSC_USE_COMPLEX)
534:     case PEP_TARGET_IMAGINARY:
535: #endif
536:     case PEP_WHICH_USER:
537:       if (pep->which != which) {
538:         pep->state = PEP_STATE_INITIAL;
539:         pep->which = which;
540:       }
541:       break;
542:     default:
543:       SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
544:   }
545:   return(0);
546: }

550: /*@
551:     PEPGetWhichEigenpairs - Returns which portion of the spectrum is to be
552:     sought.

554:     Not Collective

556:     Input Parameter:
557: .   pep - eigensolver context obtained from PEPCreate()

559:     Output Parameter:
560: .   which - the portion of the spectrum to be sought

562:     Notes:
563:     See PEPSetWhichEigenpairs() for possible values of 'which'.

565:     Level: intermediate

567: .seealso: PEPSetWhichEigenpairs(), PEPWhich
568: @*/
569: PetscErrorCode PEPGetWhichEigenpairs(PEP pep,PEPWhich *which)
570: {
574:   *which = pep->which;
575:   return(0);
576: }

580: /*@C
581:    PEPSetEigenvalueComparison - Specifies the eigenvalue comparison function
582:    when PEPSetWhichEigenpairs() is set to PEP_WHICH_USER.

584:    Logically Collective on PEP

586:    Input Parameters:
587: +  pep  - eigensolver context obtained from PEPCreate()
588: .  func - a pointer to the comparison function
589: -  ctx  - a context pointer (the last parameter to the comparison function)

591:    Calling Sequence of func:
592: $   func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx)

594: +   ar     - real part of the 1st eigenvalue
595: .   ai     - imaginary part of the 1st eigenvalue
596: .   br     - real part of the 2nd eigenvalue
597: .   bi     - imaginary part of the 2nd eigenvalue
598: .   res    - result of comparison
599: -   ctx    - optional context, as set by PEPSetEigenvalueComparison()

601:    Note:
602:    The returning parameter 'res' can be
603: +  negative - if the 1st eigenvalue is preferred to the 2st one
604: .  zero     - if both eigenvalues are equally preferred
605: -  positive - if the 2st eigenvalue is preferred to the 1st one

607:    Level: advanced

609: .seealso: PEPSetWhichEigenpairs(), PEPWhich
610: @*/
611: PetscErrorCode PEPSetEigenvalueComparison(PEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)
612: {
615:   pep->sc->comparison    = func;
616:   pep->sc->comparisonctx = ctx;
617:   pep->which             = PEP_WHICH_USER;
618:   return(0);
619: }

623: /*@
624:    PEPSetProblemType - Specifies the type of the polynomial eigenvalue problem.

626:    Logically Collective on PEP

628:    Input Parameters:
629: +  pep  - the polynomial eigensolver context
630: -  type - a known type of polynomial eigenvalue problem

632:    Options Database Keys:
633: +  -pep_general - general problem with no particular structure
634: .  -pep_hermitian - problem whose coefficient matrices are Hermitian
635: -  -pep_gyroscopic - problem with Hamiltonian structure

637:    Notes:
638:    Allowed values for the problem type are: general (PEP_GENERAL), Hermitian
639:    (PEP_HERMITIAN), and gyroscopic (PEP_GYROSCOPIC).

641:    This function is used to instruct SLEPc to exploit certain structure in
642:    the polynomial eigenproblem. By default, no particular structure is assumed.

644:    If the problem matrices are Hermitian (symmetric in the real case) or
645:    Hermitian/skew-Hermitian then the solver can exploit this fact to perform
646:    less operations or provide better stability.

648:    Level: intermediate

650: .seealso: PEPSetOperators(), PEPSetType(), PEPGetProblemType(), PEPProblemType
651: @*/
652: PetscErrorCode PEPSetProblemType(PEP pep,PEPProblemType type)
653: {
657:   if (type!=PEP_GENERAL && type!=PEP_HERMITIAN && type!=PEP_GYROSCOPIC) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type");
658:   if (type != pep->problem_type) {
659:     pep->problem_type = type;
660:     pep->state = PEP_STATE_INITIAL;
661:   }
662:   return(0);
663: }

667: /*@
668:    PEPGetProblemType - Gets the problem type from the PEP object.

670:    Not Collective

672:    Input Parameter:
673: .  pep - the polynomial eigensolver context

675:    Output Parameter:
676: .  type - name of PEP problem type

678:    Level: intermediate

680: .seealso: PEPSetProblemType(), PEPProblemType
681: @*/
682: PetscErrorCode PEPGetProblemType(PEP pep,PEPProblemType *type)
683: {
687:   *type = pep->problem_type;
688:   return(0);
689: }

693: /*@
694:    PEPSetBasis - Specifies the type of polynomial basis used to describe the
695:    polynomial eigenvalue problem.

697:    Logically Collective on PEP

699:    Input Parameters:
700: +  pep   - the polynomial eigensolver context
701: -  basis - the type of polynomial basis

703:    Options Database Key:
704: .  -pep_basis <basis> - Select the basis type

706:    Notes:
707:    By default, the coefficient matrices passed via PEPSetOperators() are
708:    expressed in the monomial basis, i.e. 
709:    P(lambda) = A_0 + lambda*A_1 + lambda^2*A_2 + ... + lambda^d*A_d.
710:    Other polynomial bases may have better numerical behaviour, but the user
711:    must then pass the coefficient matrices accordingly.

713:    Level: intermediate

715: .seealso: PEPSetOperators(), PEPGetBasis(), PEPBasis
716: @*/
717: PetscErrorCode PEPSetBasis(PEP pep,PEPBasis basis)
718: {
722:   pep->basis = basis;
723:   return(0);
724: }

728: /*@
729:    PEPGetBasis - Gets the type of polynomial basis from the PEP object.

731:    Not Collective

733:    Input Parameter:
734: .  pep - the polynomial eigensolver context

736:    Output Parameter:
737: .  basis - the polynomial basis

739:    Level: intermediate

741: .seealso: PEPSetBasis(), PEPBasis
742: @*/
743: PetscErrorCode PEPGetBasis(PEP pep,PEPBasis *basis)
744: {
748:   *basis = pep->basis;
749:   return(0);
750: }

754: /*@
755:    PEPSetTrackAll - Specifies if the solver must compute the residual of all
756:    approximate eigenpairs or not.

758:    Logically Collective on PEP

760:    Input Parameters:
761: +  pep      - the eigensolver context
762: -  trackall - whether compute all residuals or not

764:    Notes:
765:    If the user sets trackall=PETSC_TRUE then the solver explicitly computes
766:    the residual for each eigenpair approximation. Computing the residual is
767:    usually an expensive operation and solvers commonly compute the associated
768:    residual to the first unconverged eigenpair.
769:    The options '-pep_monitor_all' and '-pep_monitor_lg_all' automatically
770:    activate this option.

772:    Level: developer

774: .seealso: PEPGetTrackAll()
775: @*/
776: PetscErrorCode PEPSetTrackAll(PEP pep,PetscBool trackall)
777: {
781:   pep->trackall = trackall;
782:   return(0);
783: }

787: /*@
788:    PEPGetTrackAll - Returns the flag indicating whether all residual norms must
789:    be computed or not.

791:    Not Collective

793:    Input Parameter:
794: .  pep - the eigensolver context

796:    Output Parameter:
797: .  trackall - the returned flag

799:    Level: developer

801: .seealso: PEPSetTrackAll()
802: @*/
803: PetscErrorCode PEPGetTrackAll(PEP pep,PetscBool *trackall)
804: {
808:   *trackall = pep->trackall;
809:   return(0);
810: }

814: /*@C
815:    PEPSetConvergenceTestFunction - Sets a function to compute the error estimate
816:    used in the convergence test.

818:    Logically Collective on PEP

820:    Input Parameters:
821: +  pep     - eigensolver context obtained from PEPCreate()
822: .  func    - a pointer to the convergence test function
823: .  ctx     - context for private data for the convergence routine (may be null)
824: -  destroy - a routine for destroying the context (may be null)

826:    Calling Sequence of func:
827: $   func(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)

829: +   pep    - eigensolver context obtained from PEPCreate()
830: .   eigr   - real part of the eigenvalue
831: .   eigi   - imaginary part of the eigenvalue
832: .   res    - residual norm associated to the eigenpair
833: .   errest - (output) computed error estimate
834: -   ctx    - optional context, as set by PEPSetConvergenceTestFunction()

836:    Note:
837:    If the error estimate returned by the convergence test function is less than
838:    the tolerance, then the eigenvalue is accepted as converged.

840:    Level: advanced

842: .seealso: PEPSetConvergenceTest(), PEPSetTolerances()
843: @*/
844: PetscErrorCode PEPSetConvergenceTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
845: {

850:   if (pep->convergeddestroy) {
851:     (*pep->convergeddestroy)(pep->convergedctx);
852:   }
853:   pep->converged        = func;
854:   pep->convergeddestroy = destroy;
855:   pep->convergedctx     = ctx;
856:   if (func == PEPConvergedRelative) pep->conv = PEP_CONV_REL;
857:   else if (func == PEPConvergedNorm) pep->conv = PEP_CONV_NORM;
858:   else if (func == PEPConvergedAbsolute) pep->conv = PEP_CONV_ABS;
859:   else pep->conv = PEP_CONV_USER;
860:   return(0);
861: }

865: /*@
866:    PEPSetConvergenceTest - Specifies how to compute the error estimate
867:    used in the convergence test.

869:    Logically Collective on PEP

871:    Input Parameters:
872: +  pep  - eigensolver context obtained from PEPCreate()
873: -  conv - the type of convergence test

875:    Options Database Keys:
876: +  -pep_conv_abs    - Sets the absolute convergence test
877: .  -pep_conv_rel    - Sets the convergence test relative to the eigenvalue
878: .  -pep_conv_norm   - Sets the convergence test relative to the matrix norms
879: -  -pep_conv_user   - Selects the user-defined convergence test

881:    Note:
882:    The parameter 'conv' can have one of these values
883: +     PEP_CONV_ABS    - absolute error ||r||
884: .     PEP_CONV_REL    - error relative to the eigenvalue l, ||r||/|l|
885: .     PEP_CONV_NORM   - error relative matrix norms, ||r||/sum_i(l^i*||A_i||)
886: -     PEP_CONV_USER   - function set by PEPSetConvergenceTestFunction()

888:    Level: intermediate

890: .seealso: PEPGetConvergenceTest(), PEPSetConvergenceTestFunction(), PEPSetStoppingTest(), PEPConv
891: @*/
892: PetscErrorCode PEPSetConvergenceTest(PEP pep,PEPConv conv)
893: {
897:   switch (conv) {
898:     case PEP_CONV_ABS:    pep->converged = PEPConvergedAbsolute; break;
899:     case PEP_CONV_REL:    pep->converged = PEPConvergedRelative; break;
900:     case PEP_CONV_NORM:   pep->converged = PEPConvergedNorm; break;
901:     case PEP_CONV_USER: break;
902:     default:
903:       SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value");
904:   }
905:   pep->conv = conv;
906:   return(0);
907: }

911: /*@
912:    PEPGetConvergenceTest - Gets the method used to compute the error estimate
913:    used in the convergence test.

915:    Not Collective

917:    Input Parameters:
918: .  pep   - eigensolver context obtained from PEPCreate()

920:    Output Parameters:
921: .  conv  - the type of convergence test

923:    Level: intermediate

925: .seealso: PEPSetConvergenceTest(), PEPConv
926: @*/
927: PetscErrorCode PEPGetConvergenceTest(PEP pep,PEPConv *conv)
928: {
932:   *conv = pep->conv;
933:   return(0);
934: }

938: /*@C
939:    PEPSetStoppingTestFunction - Sets a function to decide when to stop the outer
940:    iteration of the eigensolver.

942:    Logically Collective on PEP

944:    Input Parameters:
945: +  pep     - eigensolver context obtained from PEPCreate()
946: .  func    - pointer to the stopping test function
947: .  ctx     - context for private data for the stopping routine (may be null)
948: -  destroy - a routine for destroying the context (may be null)

950:    Calling Sequence of func:
951: $   func(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)

953: +   pep    - eigensolver context obtained from PEPCreate()
954: .   its    - current number of iterations
955: .   max_it - maximum number of iterations
956: .   nconv  - number of currently converged eigenpairs
957: .   nev    - number of requested eigenpairs
958: .   reason - (output) result of the stopping test
959: -   ctx    - optional context, as set by PEPSetStoppingTestFunction()

961:    Note:
962:    Normal usage is to first call the default routine PEPStoppingBasic() and then
963:    set reason to PEP_CONVERGED_USER if some user-defined conditions have been
964:    met. To let the eigensolver continue iterating, the result must be left as
965:    PEP_CONVERGED_ITERATING.

967:    Level: advanced

969: .seealso: PEPSetStoppingTest(), PEPStoppingBasic()
970: @*/
971: PetscErrorCode PEPSetStoppingTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))
972: {

977:   if (pep->stoppingdestroy) {
978:     (*pep->stoppingdestroy)(pep->stoppingctx);
979:   }
980:   pep->stopping        = func;
981:   pep->stoppingdestroy = destroy;
982:   pep->stoppingctx     = ctx;
983:   if (func == PEPStoppingBasic) pep->stop = PEP_STOP_BASIC;
984:   else pep->stop = PEP_STOP_USER;
985:   return(0);
986: }

990: /*@
991:    PEPSetStoppingTest - Specifies how to decide the termination of the outer
992:    loop of the eigensolver.

994:    Logically Collective on PEP

996:    Input Parameters:
997: +  pep  - eigensolver context obtained from PEPCreate()
998: -  stop - the type of stopping test

1000:    Options Database Keys:
1001: +  -pep_stop_basic - Sets the default stopping test
1002: -  -pep_stop_user  - Selects the user-defined stopping test

1004:    Note:
1005:    The parameter 'stop' can have one of these values
1006: +     PEP_STOP_BASIC - default stopping test
1007: -     PEP_STOP_USER  - function set by PEPSetStoppingTestFunction()

1009:    Level: advanced

1011: .seealso: PEPGetStoppingTest(), PEPSetStoppingTestFunction(), PEPSetConvergenceTest(), PEPStop
1012: @*/
1013: PetscErrorCode PEPSetStoppingTest(PEP pep,PEPStop stop)
1014: {
1018:   switch (stop) {
1019:     case PEP_STOP_BASIC: pep->stopping = PEPStoppingBasic; break;
1020:     case PEP_STOP_USER:  break;
1021:     default:
1022:       SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value");
1023:   }
1024:   pep->stop = stop;
1025:   return(0);
1026: }

1030: /*@
1031:    PEPGetStoppingTest - Gets the method used to decide the termination of the outer
1032:    loop of the eigensolver.

1034:    Not Collective

1036:    Input Parameters:
1037: .  pep   - eigensolver context obtained from PEPCreate()

1039:    Output Parameters:
1040: .  stop  - the type of stopping test

1042:    Level: advanced

1044: .seealso: PEPSetStoppingTest(), PEPStop
1045: @*/
1046: PetscErrorCode PEPGetStoppingTest(PEP pep,PEPStop *stop)
1047: {
1051:   *stop = pep->stop;
1052:   return(0);
1053: }

1057: /*@
1058:    PEPSetScale - Specifies the scaling strategy to be used.

1060:    Logically Collective on PEP

1062:    Input Parameters:
1063: +  pep    - the eigensolver context
1064: .  scale  - scaling strategy
1065: .  alpha  - the scaling factor used in the scalar strategy
1066: .  Dl     - the left diagonal matrix of the diagonal scaling algorithm
1067: .  Dr     - the right diagonal matrix of the diagonal scaling algorithm
1068: .  its    - number of iterations of the diagonal scaling algorithm
1069: -  lambda - approximation to wanted eigenvalues (modulus)

1071:    Options Database Keys:
1072: +  -pep_scale <type> - scaling type, one of <none,scalar,diagonal,both>
1073: .  -pep_scale_factor <alpha> - the scaling factor
1074: .  -pep_scale_its <its> - number of iterations
1075: -  -pep_scale_lambda <lambda> - approximation to eigenvalues

1077:    Notes:
1078:    There are two non-exclusive scaling strategies: scalar and diagonal.

1080:    In the scalar strategy, scaling is applied to the eigenvalue, that is,
1081:    mu = lambda/alpha is the new eigenvalue and all matrices are scaled
1082:    accordingly. After solving the scaled problem, the original lambda is
1083:    recovered. Parameter 'alpha' must be positive. Use PETSC_DECIDE to let
1084:    the solver compute a reasonable scaling factor.

1086:    In the diagonal strategy, the solver works implicitly with matrix Dl*A*Dr,
1087:    where Dl and Dr are appropriate diagonal matrices. This improves the accuracy
1088:    of the computed results in some cases. The user may provide the Dr and Dl
1089:    matrices represented as Vec objects storing diagonal elements. If not
1090:    provided, these matrices are computed internally. This option requires
1091:    that the polynomial coefficient matrices are of MATAIJ type.
1092:    The parameter 'its' is the number of iterations performed by the method.
1093:    Parameter 'lambda' must be positive. Use PETSC_DECIDE or set lambda = 1.0 if
1094:    no information about eigenvalues is available.

1096:    Level: intermediate

1098: .seealso: PEPGetScale()
1099: @*/
1100: PetscErrorCode PEPSetScale(PEP pep,PEPScale scale,PetscReal alpha,Vec Dl,Vec Dr,PetscInt its,PetscReal lambda)
1101: {

1107:   pep->scale = scale;
1108:   if (scale==PEP_SCALE_SCALAR || scale==PEP_SCALE_BOTH) {
1110:     if (alpha == PETSC_DEFAULT || alpha == PETSC_DECIDE) {
1111:       pep->sfactor = 0.0;
1112:       pep->sfactor_set = PETSC_FALSE;
1113:     } else {
1114:       if (alpha<=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of alpha. Must be > 0");
1115:       pep->sfactor = alpha;
1116:       pep->sfactor_set = PETSC_TRUE;
1117:     }
1118:   }
1119:   if (scale==PEP_SCALE_DIAGONAL || scale==PEP_SCALE_BOTH) {
1120:     if (Dl) {
1123:       PetscObjectReference((PetscObject)Dl);
1124:       VecDestroy(&pep->Dl);
1125:       pep->Dl = Dl;
1126:     }
1127:     if (Dr) {
1130:       PetscObjectReference((PetscObject)Dr);
1131:       VecDestroy(&pep->Dr);
1132:       pep->Dr = Dr;
1133:     }
1136:     if (its==PETSC_DECIDE || its==PETSC_DEFAULT) pep->sits = 5;
1137:     else pep->sits = its;
1138:     if (lambda==PETSC_DECIDE || lambda==PETSC_DEFAULT) pep->slambda = 1.0;
1139:     else if (lambda<=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of lambda. Must be > 0");
1140:     else pep->slambda = lambda;
1141:   }
1142:   pep->state = PEP_STATE_INITIAL;
1143:   return(0);
1144: }

1148: /*@
1149:    PEPGetScale - Gets the scaling strategy used by the PEP object, and the
1150:    associated parameters.

1152:    Not Collectiv, but vectors are shared by all processors that share the PEP

1154:    Input Parameter:
1155: .  pep - the eigensolver context

1157:    Output Parameters:
1158: +  scale  - scaling strategy
1159: .  alpha  - the scaling factor used in the scalar strategy
1160: .  Dl     - the left diagonal matrix of the diagonal scaling algorithm
1161: .  Dr     - the right diagonal matrix of the diagonal scaling algorithm
1162: .  its    - number of iterations of the diagonal scaling algorithm
1163: -  lambda - approximation to wanted eigenvalues (modulus)

1165:    Level: intermediate

1167:    Note:
1168:    The user can specify NULL for any parameter that is not needed.

1170:    If Dl or Dr were not set by the user, then the ones computed internally are
1171:    returned (or a null pointer if called before PEPSetUp).

1173: .seealso: PEPSetScale(), PEPSetUp()
1174: @*/
1175: PetscErrorCode PEPGetScale(PEP pep,PEPScale *scale,PetscReal *alpha,Vec *Dl,Vec *Dr,PetscInt *its,PetscReal *lambda)
1176: {
1179:   if (scale)  *scale  = pep->scale;
1180:   if (alpha)  *alpha  = pep->sfactor;
1181:   if (Dl)     *Dl     = pep->Dl;
1182:   if (Dr)     *Dr     = pep->Dr;
1183:   if (its)    *its    = pep->sits;
1184:   if (lambda) *lambda = pep->slambda;
1185:   return(0);
1186: }

1190: /*@
1191:    PEPSetExtract - Specifies the extraction strategy to be used.

1193:    Logically Collective on PEP

1195:    Input Parameters:
1196: +  pep     - the eigensolver context
1197: -  extract - extraction strategy

1199:    Options Database Keys:
1200: .  -pep_extract <type> - extraction type, one of <none,norm,residual,structured>

1202:    Level: intermediate

1204: .seealso: PEPGetExtract()
1205: @*/
1206: PetscErrorCode PEPSetExtract(PEP pep,PEPExtract extract)
1207: {
1211:   pep->extract = extract;
1212:   return(0);
1213: }

1217: /*@
1218:    PEPGetExtract - Gets the extraction strategy used by the PEP object.

1220:    Not Collective

1222:    Input Parameter:
1223: .  pep - the eigensolver context

1225:    Output Parameter:
1226: .  extract - extraction strategy

1228:    Level: intermediate

1230: .seealso: PEPSetExtract()
1231: @*/
1232: PetscErrorCode PEPGetExtract(PEP pep,PEPExtract *extract)
1233: {
1236:   if (extract) *extract = pep->extract;
1237:   return(0);
1238: }

1242: /*@
1243:    PEPSetRefine - Specifies the refinement type (and options) to be used
1244:    after the solve.

1246:    Logically Collective on PEP

1248:    Input Parameters:
1249: +  pep    - the polynomial eigensolver context
1250: .  refine - refinement type
1251: .  npart  - number of partitions of the communicator
1252: .  tol    - the convergence tolerance
1253: .  its    - maximum number of refinement iterations
1254: -  scheme - which scheme to be used for solving the involved linear systems

1256:    Options Database Keys:
1257: +  -pep_refine <type> - refinement type, one of <none,simple,multiple>
1258: .  -pep_refine_partitions <n> - the number of partitions
1259: .  -pep_refine_tol <tol> - the tolerance
1260: .  -pep_refine_its <its> - number of iterations
1261: -  -pep_refine_scheme - to set the scheme for the linear solves

1263:    Notes:
1264:    By default, iterative refinement is disabled, since it may be very
1265:    costly. There are two possible refinement strategies: simple and multiple.
1266:    The simple approach performs iterative refinement on each of the
1267:    converged eigenpairs individually, whereas the multiple strategy works
1268:    with the invariant pair as a whole, refining all eigenpairs simultaneously.
1269:    The latter may be required for the case of multiple eigenvalues.

1271:    In some cases, especially when using direct solvers within the
1272:    iterative refinement method, it may be helpful for improved scalability
1273:    to split the communicator in several partitions. The npart parameter
1274:    indicates how many partitions to use (defaults to 1).

1276:    The tol and its parameters specify the stopping criterion. In the simple
1277:    method, refinement continues until the residual of each eigenpair is
1278:    below the tolerance (tol defaults to the PEP tol, but may be set to a
1279:    different value). In contrast, the multiple method simply performs its
1280:    refinement iterations (just one by default).

1282:    The scheme argument is used to change the way in which linear systems are
1283:    solved. Possible choices are: explicit, mixed block elimination (MBE), 
1284:    and Schur complement.

1286:    Level: intermediate

1288: .seealso: PEPGetRefine()
1289: @*/
1290: PetscErrorCode PEPSetRefine(PEP pep,PEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,PEPRefineScheme scheme)
1291: {
1293:   PetscMPIInt    size;

1302:   pep->refine = refine;
1303:   if (refine) {  /* process parameters only if not REFINE_NONE */
1304:     if (npart!=pep->npart) {
1305:       PetscSubcommDestroy(&pep->refinesubc);
1306:       KSPDestroy(&pep->refineksp);
1307:     }
1308:     if (npart == PETSC_DEFAULT || npart == PETSC_DECIDE) {
1309:       pep->npart = 1;
1310:     } else {
1311:       MPI_Comm_size(PetscObjectComm((PetscObject)pep),&size);
1312:       if (npart<1 || npart>size) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart");
1313:       pep->npart = npart;
1314:     }
1315:     if (tol == PETSC_DEFAULT || tol == PETSC_DECIDE) {
1316:       pep->rtol = PetscMax(pep->tol/1000,PETSC_MACHINE_EPSILON);
1317:     } else {
1318:       if (tol<=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
1319:       pep->rtol = tol;
1320:     }
1321:     if (its==PETSC_DECIDE || its==PETSC_DEFAULT) {
1322:       pep->rits = PETSC_DEFAULT;
1323:     } else {
1324:       if (its<0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be >= 0");
1325:       pep->rits = its;
1326:     }
1327:     pep->scheme = scheme;
1328:   }
1329:   pep->state = PEP_STATE_INITIAL;
1330:   return(0);
1331: }

1335: /*@
1336:    PEPGetRefine - Gets the refinement strategy used by the PEP object, and the
1337:    associated parameters.

1339:    Not Collective

1341:    Input Parameter:
1342: .  pep - the polynomial eigensolver context

1344:    Output Parameters:
1345: +  refine - refinement type
1346: .  npart  - number of partitions of the communicator
1347: .  tol    - the convergence tolerance
1348: .  its    - maximum number of refinement iterations
1349: -  scheme - the scheme used for solving linear systems

1351:    Level: intermediate

1353:    Note:
1354:    The user can specify NULL for any parameter that is not needed.

1356: .seealso: PEPSetRefine()
1357: @*/
1358: PetscErrorCode PEPGetRefine(PEP pep,PEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,PEPRefineScheme *scheme)
1359: {
1362:   if (refine) *refine = pep->refine;
1363:   if (npart)  *npart  = pep->npart;
1364:   if (tol)    *tol    = pep->rtol;
1365:   if (its)    *its    = pep->rits;
1366:   if (scheme) *scheme = pep->scheme;
1367:   return(0);
1368: }

1372: /*@C
1373:    PEPSetOptionsPrefix - Sets the prefix used for searching for all
1374:    PEP options in the database.

1376:    Logically Collective on PEP

1378:    Input Parameters:
1379: +  pep - the polynomial eigensolver context
1380: -  prefix - the prefix string to prepend to all PEP option requests

1382:    Notes:
1383:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1384:    The first character of all runtime options is AUTOMATICALLY the
1385:    hyphen.

1387:    For example, to distinguish between the runtime options for two
1388:    different PEP contexts, one could call
1389: .vb
1390:       PEPSetOptionsPrefix(pep1,"qeig1_")
1391:       PEPSetOptionsPrefix(pep2,"qeig2_")
1392: .ve

1394:    Level: advanced

1396: .seealso: PEPAppendOptionsPrefix(), PEPGetOptionsPrefix()
1397: @*/
1398: PetscErrorCode PEPSetOptionsPrefix(PEP pep,const char *prefix)
1399: {

1404:   if (!pep->st) { PEPGetST(pep,&pep->st); }
1405:   STSetOptionsPrefix(pep->st,prefix);
1406:   if (!pep->V) { PEPGetBV(pep,&pep->V); }
1407:   BVSetOptionsPrefix(pep->V,prefix);
1408:   if (!pep->ds) { PEPGetDS(pep,&pep->ds); }
1409:   DSSetOptionsPrefix(pep->ds,prefix);
1410:   if (!pep->rg) { PEPGetRG(pep,&pep->rg); }
1411:   RGSetOptionsPrefix(pep->rg,prefix);
1412:   PetscObjectSetOptionsPrefix((PetscObject)pep,prefix);
1413:   return(0);
1414: }

1418: /*@C
1419:    PEPAppendOptionsPrefix - Appends to the prefix used for searching for all
1420:    PEP options in the database.

1422:    Logically Collective on PEP

1424:    Input Parameters:
1425: +  pep - the polynomial eigensolver context
1426: -  prefix - the prefix string to prepend to all PEP option requests

1428:    Notes:
1429:    A hyphen (-) must NOT be given at the beginning of the prefix name.
1430:    The first character of all runtime options is AUTOMATICALLY the hyphen.

1432:    Level: advanced

1434: .seealso: PEPSetOptionsPrefix(), PEPGetOptionsPrefix()
1435: @*/
1436: PetscErrorCode PEPAppendOptionsPrefix(PEP pep,const char *prefix)
1437: {
1439:   PetscBool      flg;
1440:   EPS            eps;

1444:   if (!pep->st) { PEPGetST(pep,&pep->st); }
1445:   STAppendOptionsPrefix(pep->st,prefix);
1446:   if (!pep->V) { PEPGetBV(pep,&pep->V); }
1447:   BVSetOptionsPrefix(pep->V,prefix);
1448:   if (!pep->ds) { PEPGetDS(pep,&pep->ds); }
1449:   DSSetOptionsPrefix(pep->ds,prefix);
1450:   if (!pep->rg) { PEPGetRG(pep,&pep->rg); }
1451:   RGSetOptionsPrefix(pep->rg,prefix);
1452:   PetscObjectAppendOptionsPrefix((PetscObject)pep,prefix);
1453:   PetscObjectTypeCompare((PetscObject)pep,PEPLINEAR,&flg);
1454:   if (flg) {
1455:     PEPLinearGetEPS(pep,&eps);
1456:     EPSSetOptionsPrefix(eps,((PetscObject)pep)->prefix);
1457:     EPSAppendOptionsPrefix(eps,"pep_");
1458:   }
1459:   return(0);
1460: }

1464: /*@C
1465:    PEPGetOptionsPrefix - Gets the prefix used for searching for all
1466:    PEP options in the database.

1468:    Not Collective

1470:    Input Parameters:
1471: .  pep - the polynomial eigensolver context

1473:    Output Parameters:
1474: .  prefix - pointer to the prefix string used is returned

1476:    Note:
1477:    On the Fortran side, the user should pass in a string 'prefix' of
1478:    sufficient length to hold the prefix.

1480:    Level: advanced

1482: .seealso: PEPSetOptionsPrefix(), PEPAppendOptionsPrefix()
1483: @*/
1484: PetscErrorCode PEPGetOptionsPrefix(PEP pep,const char *prefix[])
1485: {

1491:   PetscObjectGetOptionsPrefix((PetscObject)pep,prefix);
1492:   return(0);
1493: }

slepc-3.7.4/src/pep/interface/pepmon.c0000644000175000017500000004075213107004621017150 0ustar jromanjroman/* PEP routines related to monitors. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "PEPMonitor" /* Runs the user provided monitor routines, if any. */ PetscErrorCode PEPMonitor(PEP pep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest) { PetscErrorCode ierr; PetscInt i,n = pep->numbermonitors; PetscFunctionBegin; for (i=0;imonitor[i])(pep,it,nconv,eigr,eigi,errest,nest,pep->monitorcontext[i]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorSet" /*@C PEPMonitorSet - Sets an ADDITIONAL function to be called at every iteration to monitor the error estimates for each requested eigenpair. Logically Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() . monitor - pointer to function (if this is NULL, it turns off monitoring) . mctx - [optional] context for private data for the monitor routine (use NULL if no context is desired) - monitordestroy - [optional] routine that frees monitor context (may be NULL) Calling Sequence of monitor: $ monitor(PEP pep,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx) + pep - polynomial eigensolver context obtained from PEPCreate() . its - iteration number . nconv - number of converged eigenpairs . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - relative error estimates for each eigenpair . nest - number of error estimates - mctx - optional monitoring context, as set by PEPMonitorSet() Options Database Keys: + -pep_monitor - print only the first error estimate . -pep_monitor_all - print error estimates at each iteration . -pep_monitor_conv - print the eigenvalue approximations only when convergence has been reached . -pep_monitor_lg - sets line graph monitor for the first unconverged approximate eigenvalue . -pep_monitor_lg_all - sets line graph monitor for all unconverged approximate eigenvalues - -pep_monitor_cancel - cancels all monitors that have been hardwired into a code by calls to PEPMonitorSet(), but does not cancel those set via the options database. Notes: Several different monitoring routines may be set by calling PEPMonitorSet() multiple times; all will be called in the order in which they were set. Level: intermediate .seealso: PEPMonitorFirst(), PEPMonitorAll(), PEPMonitorCancel() @*/ PetscErrorCode PEPMonitorSet(PEP pep,PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**)) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (pep->numbermonitors >= MAXPEPMONITORS) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Too many PEP monitors set"); pep->monitor[pep->numbermonitors] = monitor; pep->monitorcontext[pep->numbermonitors] = (void*)mctx; pep->monitordestroy[pep->numbermonitors++] = monitordestroy; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorCancel" /*@ PEPMonitorCancel - Clears all monitors for a PEP object. Logically Collective on PEP Input Parameters: . pep - eigensolver context obtained from PEPCreate() Options Database Key: . -pep_monitor_cancel - Cancels all monitors that have been hardwired into a code by calls to PEPMonitorSet(), but does not cancel those set via the options database. Level: intermediate .seealso: PEPMonitorSet() @*/ PetscErrorCode PEPMonitorCancel(PEP pep) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); for (i=0; inumbermonitors; i++) { if (pep->monitordestroy[i]) { ierr = (*pep->monitordestroy[i])(&pep->monitorcontext[i]);CHKERRQ(ierr); } } pep->numbermonitors = 0; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetMonitorContext" /*@C PEPGetMonitorContext - Gets the monitor context, as set by PEPMonitorSet() for the FIRST monitor only. Not Collective Input Parameter: . pep - eigensolver context obtained from PEPCreate() Output Parameter: . ctx - monitor context Level: intermediate .seealso: PEPMonitorSet(), PEPDefaultMonitor() @*/ PetscErrorCode PEPGetMonitorContext(PEP pep,void **ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); *ctx = pep->monitorcontext[0]; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorGetTrueEig" /* Helper function to compute eigenvalue that must be viewed in monitor */ static PetscErrorCode PEPMonitorGetTrueEig(PEP pep,PetscScalar *er,PetscScalar *ei) { PetscErrorCode ierr; PetscBool flg; PetscFunctionBegin; ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) { *er *= pep->sfactor; *ei *= pep->sfactor; } ierr = STBackTransform(pep->st,1,er,ei);CHKERRQ(ierr); if (!flg) { *er *= pep->sfactor; *ei *= pep->sfactor; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorAll" /*@C PEPMonitorAll - Print the current approximate values and error estimates at each iteration of the polynomial eigensolver. Collective on PEP Input Parameters: + pep - polynomial eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: PEPMonitorSet(), PEPMonitorFirst(), PEPMonitorConverged() @*/ PetscErrorCode PEPMonitorAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscInt i; PetscScalar er,ei; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(vf,8); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); ierr = PetscViewerPushFormat(viewer,vf->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);CHKERRQ(ierr); if (its==1 && ((PetscObject)pep)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)pep)->prefix);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"%3D PEP nconv=%D Values (Errors)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); for (i=0;itablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorFirst" /*@C PEPMonitorFirst - Print the first unconverged approximate value and error estimate at each iteration of the polynomial eigensolver. Collective on PEP Input Parameters: + pep - polynomial eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - vf - viewer and format for monitoring Level: intermediate .seealso: PEPMonitorSet(), PEPMonitorAll(), PEPMonitorConverged() @*/ PetscErrorCode PEPMonitorFirst(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf) { PetscErrorCode ierr; PetscScalar er,ei; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(vf,8); viewer = vf->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); if (its==1 && ((PetscObject)pep)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)pep)->prefix);CHKERRQ(ierr); } if (nconvformat);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%3D PEP nconv=%D first unconverged value (error)",its,nconv);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); er = eigr[nconv]; ei = eigi[nconv]; ierr = PEPMonitorGetTrueEig(pep,&er,&ei);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));CHKERRQ(ierr); #else ierr = PetscViewerASCIIPrintf(viewer," %g",(double)er);CHKERRQ(ierr); if (eigi[nconv]!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei);CHKERRQ(ierr); } #endif ierr = PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)pep)->tablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorConverged" /*@C PEPMonitorConverged - Print the approximate values and error estimates as they converge. Collective on PEP Input Parameters: + pep - polynomial eigensolver context . its - iteration number . nconv - number of converged eigenpairs so far . eigr - real part of the eigenvalues . eigi - imaginary part of the eigenvalues . errest - error estimates . nest - number of error estimates to display - ctx - monitor context Level: intermediate .seealso: PEPMonitorSet(), PEPMonitorFirst(), PEPMonitorAll() @*/ PetscErrorCode PEPMonitorConverged(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx) { PetscErrorCode ierr; PetscInt i; PetscScalar er,ei; PetscViewer viewer; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(ctx,8); viewer = ctx->viewer; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,8); if (its==1 && ((PetscObject)pep)->prefix) { ierr = PetscViewerASCIIPrintf(viewer," Convergence history for %s solve.\n",((PetscObject)pep)->prefix);CHKERRQ(ierr); } if (its==1) ctx->oldnconv = 0; if (ctx->oldnconv!=nconv) { ierr = PetscViewerPushFormat(viewer,ctx->format);CHKERRQ(ierr); ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);CHKERRQ(ierr); for (i=ctx->oldnconv;itablevel);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ctx->oldnconv = nconv; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorLGCreate" /*@C PEPMonitorLGCreate - Creates a line graph context for use with PEP to monitor convergence. Collective on MPI_Comm Input Parameters: + comm - communicator context . host - the X display to open, or null for the local machine . label - the title to put in the title bar . x, y - the screen coordinates of the upper left coordinate of the window - m, n - the screen width and height in pixels Output Parameter: . lgctx - the drawing context Options Database Keys: + -pep_monitor_lg - Sets line graph monitor for the first residual - -pep_monitor_lg_all - Sets line graph monitor for all residuals Notes: Use PetscDrawLGDestroy() to destroy this line graph. Level: intermediate .seealso: PEPMonitorSet() @*/ PetscErrorCode PEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx) { PetscDraw draw; PetscDrawLG lg; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscDrawCreate(comm,host,label,x,y,m,n,&draw);CHKERRQ(ierr); ierr = PetscDrawSetFromOptions(draw);CHKERRQ(ierr); ierr = PetscDrawLGCreate(draw,1,&lg);CHKERRQ(ierr); ierr = PetscDrawLGSetFromOptions(lg);CHKERRQ(ierr); ierr = PetscDrawDestroy(&draw);CHKERRQ(ierr); *lgctx = lg; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorLG" PetscErrorCode PEPMonitorLG(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscReal x,y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,1);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(pep->tol)-2,0.0);CHKERRQ(ierr); } x = (PetscReal)its; if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]); else y = 0.0; ierr = PetscDrawLGAddPoint(lg,&x,&y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || pep->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPMonitorLGAll" PetscErrorCode PEPMonitorLGAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PetscDrawLG lg = (PetscDrawLG)ctx; PetscInt i,n = PetscMin(pep->nev,255); PetscReal *x,*y; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,8); if (its==1) { ierr = PetscDrawLGReset(lg);CHKERRQ(ierr); ierr = PetscDrawLGSetDimension(lg,n);CHKERRQ(ierr); ierr = PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(pep->tol)-2,0.0);CHKERRQ(ierr); } ierr = PetscMalloc2(n,&x,n,&y);CHKERRQ(ierr); for (i=0;i 0.0) y[i] = PetscLog10Real(errest[i]); else y[i] = 0.0; } ierr = PetscDrawLGAddPoint(lg,x,y);CHKERRQ(ierr); if (its <= 20 || !(its % 5) || pep->reason) { ierr = PetscDrawLGDraw(lg);CHKERRQ(ierr); ierr = PetscDrawLGSave(lg);CHKERRQ(ierr); } ierr = PetscFree2(x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/peprefine.c.html0000644000175000017500000012500513107004621020565 0ustar jromanjroman
Actual source code: peprefine.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Newton refinement for PEP, simple version.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>
 25: #include <slepcblaslapack.h>

 27: #define NREF_MAXIT 10

 29: typedef struct {
 30:   VecScatter *scatter_id,nst;
 31:   Mat        *A;
 32:   Vec        nv,vg,v,w;
 33: } PEPSimpNRefctx;

 35: typedef struct {
 36:   Mat          M1;
 37:   Vec          M2,M3;
 38:   PetscScalar  M4,m3;
 39: } FSubctx;

 43: static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)
 44: {
 46:   FSubctx        *ctx;
 47:   PetscScalar    t;
 48:   
 50:   MatShellGetContext(M,&ctx);
 51:   VecDot(x,ctx->M3,&t);
 52:   t *= ctx->m3/ctx->M4;
 53:   MatMult(ctx->M1,x,y);
 54:   VecAXPY(y,-t,ctx->M2);
 55:   return(0);
 56: }

 60: static PetscErrorCode PEPSimpleNRefSetUp(PEP pep,PEPSimpNRefctx **ctx_)
 61: {
 63:   PetscInt       i,si,j,n0,m0,nloc,*idx1,*idx2,ne;
 64:   IS             is1,is2;
 65:   PEPSimpNRefctx *ctx;
 66:   Vec            v;
 67:   PetscMPIInt    rank,size;

 70:   PetscCalloc1(1,ctx_);
 71:   ctx = *ctx_;
 72:   if (pep->npart==1) {
 73:     pep->refinesubc = NULL;
 74:     ctx->scatter_id = NULL;
 75:     ctx->A = pep->A;
 76:   } else {
 77:     PetscMalloc2(pep->nmat,&ctx->A,pep->npart,&ctx->scatter_id);

 79:     /* Duplicate matrices */
 80:     for (i=0;i<pep->nmat;i++) {
 81:       MatCreateRedundantMatrix(pep->A[i],0,PetscSubcommChild(pep->refinesubc),MAT_INITIAL_MATRIX,&ctx->A[i]);
 82:     }
 83:     MatCreateVecs(ctx->A[0],&ctx->v,NULL);

 85:     /* Create scatters for sending vectors to each subcommucator */
 86:     BVGetColumn(pep->V,0,&v);
 87:     VecGetOwnershipRange(v,&n0,&m0);
 88:     BVRestoreColumn(pep->V,0,&v);
 89:     VecGetLocalSize(ctx->v,&nloc);
 90:     PetscMalloc2(m0-n0,&idx1,m0-n0,&idx2);
 91:     VecCreateMPI(PetscObjectComm((PetscObject)pep),nloc,PETSC_DECIDE,&ctx->vg);
 92:     for (si=0;si<pep->npart;si++) {
 93:       j = 0;
 94:       for (i=n0;i<m0;i++) {
 95:         idx1[j]   = i;
 96:         idx2[j++] = i+pep->n*si;
 97:       }
 98:       ISCreateGeneral(PetscObjectComm((PetscObject)pep),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);
 99:       ISCreateGeneral(PetscObjectComm((PetscObject)pep),(m0-n0),idx2,PETSC_COPY_VALUES,&is2);
100:       BVGetColumn(pep->V,0,&v);
101:       VecScatterCreate(v,is1,ctx->vg,is2,&ctx->scatter_id[si]);
102:       BVRestoreColumn(pep->V,0,&v);
103:       ISDestroy(&is1);
104:       ISDestroy(&is2);
105:     }
106:     PetscFree2(idx1,idx2);
107:   }
108:   if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT){
109:     MPI_Comm_rank(PetscObjectComm((PetscObject)ctx->A[0]),&rank);
110:     MPI_Comm_size(PetscObjectComm((PetscObject)ctx->A[0]),&size);
111:     if (size>1) {
112:       if (pep->npart==1) {
113:         BVGetColumn(pep->V,0,&v);
114:       } else v = ctx->v;
115:       VecGetOwnershipRange(v,&n0,&m0);
116:       ne = (rank == size-1)?pep->n:0;
117:       VecCreateMPI(PetscObjectComm((PetscObject)ctx->A[0]),ne,PETSC_DECIDE,&ctx->nv);
118:       PetscMalloc1(m0-n0,&idx1);
119:       for (i=n0;i<m0;i++) idx1[i-n0] = i;
120:       ISCreateGeneral(PetscObjectComm((PetscObject)pep),(m0-n0),idx1,PETSC_COPY_VALUES,&is1);
121:       VecScatterCreate(v,is1,ctx->nv,is1,&ctx->nst);
122:       if (pep->npart==1) {
123:         BVRestoreColumn(pep->V,0,&v);
124:       }
125:       PetscFree(idx1);
126:       ISDestroy(&is1);
127:     }
128:   } 
129:   return(0);  
130: }

132: /*
133:   Gather Eigenpair idx from subcommunicator with color sc
134: */
137: static PetscErrorCode PEPSimpleNRefGatherEigenpair(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail)
138: {
139:   PetscErrorCode    ierr;
140:   PetscMPIInt       nproc,p;
141:   MPI_Comm          comm=((PetscObject)pep)->comm;
142:   Vec               v;
143:   const PetscScalar *array;

146:   if (pep->npart>1) {
147:     MPI_Comm_size(comm,&nproc);
148:     p = (nproc/pep->npart)*sc+PetscMin(sc,nproc%pep->npart);
149:     /* Communicate convergence successful */
150:     MPI_Bcast(fail,1,MPIU_INT,p,comm);
151:     if (!(*fail)) {
152:       /* Process 0 of subcommunicator sc broadcasts the eigenvalue */ 
153:       MPI_Bcast(&pep->eigr[idx],1,MPIU_SCALAR,p,comm);
154:       /* Gather pep->V[idx] from the subcommuniator sc */
155:       BVGetColumn(pep->V,idx,&v);
156:       if (pep->refinesubc->color==sc) {
157:         VecGetArrayRead(ctx->v,&array);
158:         VecPlaceArray(ctx->vg,array);
159:       }
160:       VecScatterBegin(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);
161:       VecScatterEnd(ctx->scatter_id[sc],ctx->vg,v,INSERT_VALUES,SCATTER_REVERSE);
162:       if (pep->refinesubc->color==sc) {
163:         VecResetArray(ctx->vg);
164:         VecRestoreArrayRead(ctx->v,&array);
165:       }
166:       BVRestoreColumn(pep->V,idx,&v);
167:     }
168:   } else {
169:     if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT && !(*fail)) {
170:       MPI_Comm_size(comm,&nproc);
171:       p = (nproc/pep->npart)*sc+PetscMin(sc,nproc%pep->npart);
172:       MPI_Bcast(&pep->eigr[idx],1,MPIU_SCALAR,p,comm);
173:     }
174:   }
175:   return(0);
176: }

180: static PetscErrorCode PEPSimpleNRefScatterEigenvector(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx)
181: {
182:   PetscErrorCode    ierr;
183:   Vec               v;
184:   const PetscScalar *array;
185:   
187:   if (pep->npart>1) {
188:     BVGetColumn(pep->V,idx,&v);
189:     if (pep->refinesubc->color==sc) {
190:       VecGetArrayRead(ctx->v,&array);
191:       VecPlaceArray(ctx->vg,array);
192:     }
193:     VecScatterBegin(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);
194:     VecScatterEnd(ctx->scatter_id[sc],v,ctx->vg,INSERT_VALUES,SCATTER_FORWARD);
195:     if (pep->refinesubc->color==sc) {
196:       VecResetArray(ctx->vg);
197:       VecRestoreArrayRead(ctx->v,&array);
198:     }
199:     BVRestoreColumn(pep->V,idx,&v);
200:   }
201:   return(0);
202: }

206: static PetscErrorCode PEPEvaluateFunctionDerivatives(PEP pep,PetscScalar alpha,PetscScalar *vals)
207: {
208:   PetscInt    i,nmat=pep->nmat;
209:   PetscScalar a0,a1,a2;
210:   PetscReal   *a=pep->pbc,*b=a+nmat,*g=b+nmat;

213:   a0 = 0.0;
214:   a1 = 1.0;
215:   vals[0] = 0.0;
216:   if (nmat>1) vals[1] = 1/a[0];
217:   for (i=2;i<nmat;i++) {
218:     a2 = ((alpha-b[i-2])*a1-g[i-2]*a0)/a[i-2];
219:     vals[i] = (a2+(alpha-b[i-1])*vals[i-1]-g[i-1]*vals[i-2])/a[i-1];
220:     a0 = a1; a1 = a2;
221:   }
222:   return(0);
223: }

227: static PetscErrorCode PEPSimpleNRefSetUpSystem(PEP pep,Mat *A,PEPSimpNRefctx *ctx,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v)
228: {
229:   PetscErrorCode    ierr;
230:   PetscInt          i,nmat=pep->nmat,ml,m0,n0,m1,mg;
231:   PetscInt          *dnz,*onz,ncols,*cols2=NULL,*nnz;
232:   PetscScalar       zero=0.0,*coeffs,*coeffs2;
233:   PetscMPIInt       rank,size;
234:   MPI_Comm          comm;
235:   const PetscInt    *cols;
236:   const PetscScalar *vals,*array;
237:   MatStructure      str;
238:   FSubctx           *fctx;
239:   Vec               w=ctx->w;
240:   Mat               M;

243:   STGetMatStructure(pep->st,&str);
244:   PetscMalloc2(nmat,&coeffs,nmat,&coeffs2);
245:   switch (pep->scheme) {
246:   case PEP_REFINE_SCHEME_SCHUR:
247:     if (ini) {
248:       PetscCalloc1(1,&fctx);
249:       MatGetSize(A[0],&m0,&n0);
250:       MatCreateShell(PetscObjectComm((PetscObject)A[0]),PETSC_DECIDE,PETSC_DECIDE,m0,n0,fctx,T);
251:       MatShellSetOperation(*T,MATOP_MULT,(void(*)(void))MatFSMult);
252:     } else {
253:       MatShellGetContext(*T,&fctx);
254:     }    
255:     M=fctx->M1;
256:     break;
257:   case PEP_REFINE_SCHEME_MBE:
258:     M=*T;
259:     break;
260:   case PEP_REFINE_SCHEME_EXPLICIT:
261:     M=*Mt;
262:     break;
263:   }
264:   if (ini) {
265:     MatDuplicate(A[0],MAT_COPY_VALUES,&M);
266:   } else {
267:     MatCopy(A[0],M,DIFFERENT_NONZERO_PATTERN);
268:   }
269:   PEPEvaluateBasis(pep,pep->eigr[idx],0,coeffs,NULL);
270:   MatScale(M,coeffs[0]);
271:   for (i=1;i<nmat;i++) {
272:     MatAXPY(M,coeffs[i],A[i],(ini)?str:SUBSET_NONZERO_PATTERN);
273:   }
274:   PEPEvaluateFunctionDerivatives(pep,pep->eigr[idx],coeffs2);
275:   for (i=0;i<nmat && PetscAbsScalar(coeffs2[i])==0.0;i++);
276:   MatMult(A[i],v,w);
277:   if (coeffs2[i]!=1.0) {
278:     VecScale(w,coeffs2[i]);
279:   }
280:   for (i++;i<nmat;i++) {
281:     MatMult(A[i],v,t);
282:     VecAXPY(w,coeffs2[i],t);
283:   }
284:   switch (pep->scheme) {
285:   case PEP_REFINE_SCHEME_EXPLICIT:
286:     comm = PetscObjectComm((PetscObject)A[0]);
287:     MPI_Comm_rank(comm,&rank);
288:     MPI_Comm_size(comm,&size);
289:     MatGetSize(M,&mg,NULL);
290:     MatGetOwnershipRange(M,&m0,&m1);
291:     if (ini) {
292:       MatCreate(comm,T);
293:       MatGetLocalSize(M,&ml,NULL);
294:       if (rank==size-1) ml++;
295:       MatSetSizes(*T,ml,ml,mg+1,mg+1);
296:       MatSetFromOptions(*T);
297:       MatSetUp(*T);
298:       /* Preallocate M */
299:       if (size>1) {
300:         MatPreallocateInitialize(comm,ml,ml,dnz,onz);
301:         for (i=m0;i<m1;i++) {
302:           MatGetRow(M,i,&ncols,&cols,NULL);
303:           MatPreallocateSet(i,ncols,cols,dnz,onz);
304:           MatPreallocateSet(i,1,&mg,dnz,onz);
305:           MatRestoreRow(M,i,&ncols,&cols,NULL);
306:         }
307:         if (rank==size-1) {
308:           PetscCalloc1(mg+1,&cols2);
309:           for (i=0;i<mg+1;i++) cols2[i]=i;
310:           MatPreallocateSet(m1,mg+1,cols2,dnz,onz);
311:           PetscFree(cols2);
312:         }
313:         MatMPIAIJSetPreallocation(*T,0,dnz,0,onz);
314:         MatPreallocateFinalize(dnz,onz);
315:       } else {
316:         PetscCalloc1(mg+1,&nnz);
317:         for (i=0;i<mg;i++) {
318:           MatGetRow(M,i,&ncols,NULL,NULL);
319:           nnz[i] = ncols+1;
320:           MatRestoreRow(M,i,&ncols,NULL,NULL);
321:         }
322:         nnz[mg] = mg+1;
323:         MatSeqAIJSetPreallocation(*T,0,nnz);
324:         PetscFree(nnz);
325:       }
326:       *Mt = M;
327:       *P  = *T;
328:     }
329:   
330:     /* Set values */
331:     VecGetArrayRead(w,&array);
332:     for (i=m0;i<m1;i++) {
333:       MatGetRow(M,i,&ncols,&cols,&vals);
334:       MatSetValues(*T,1,&i,ncols,cols,vals,INSERT_VALUES);
335:       MatRestoreRow(M,i,&ncols,&cols,&vals);
336:       MatSetValues(*T,1,&i,1,&mg,array+i-m0,INSERT_VALUES);
337:     }
338:     VecRestoreArrayRead(w,&array);
339:     VecConjugate(v);
340:     MPI_Comm_size(PetscObjectComm((PetscObject)A[0]),&size);
341:     MPI_Comm_rank(PetscObjectComm((PetscObject)A[0]),&rank);
342:     if (size>1) {
343:       if (rank==size-1) {
344:         PetscMalloc1(pep->n,&cols2);
345:         for (i=0;i<pep->n;i++) cols2[i]=i;
346:       }
347:       VecScatterBegin(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);
348:       VecScatterEnd(ctx->nst,v,ctx->nv,INSERT_VALUES,SCATTER_FORWARD);
349:       VecGetArrayRead(ctx->nv,&array);
350:       if (rank==size-1) {
351:         MatSetValues(*T,1,&mg,pep->n,cols2,array,INSERT_VALUES);
352:         MatSetValues(*T,1,&mg,1,&mg,&zero,INSERT_VALUES);
353:       }
354:         VecRestoreArrayRead(ctx->nv,&array);
355:     } else {
356:       PetscMalloc1(m1-m0,&cols2);
357:       for (i=0;i<m1-m0;i++) cols2[i]=m0+i;
358:       VecGetArrayRead(v,&array);
359:       MatSetValues(*T,1,&mg,m1-m0,cols2,array,INSERT_VALUES);
360:       MatSetValues(*T,1,&mg,1,&mg,&zero,INSERT_VALUES);
361:       VecRestoreArrayRead(v,&array);
362:     }
363:     VecConjugate(v);
364:     MatAssemblyBegin(*T,MAT_FINAL_ASSEMBLY);
365:     MatAssemblyEnd(*T,MAT_FINAL_ASSEMBLY); 
366:     PetscFree(cols2);
367:     break; 
368:   case PEP_REFINE_SCHEME_SCHUR:
369:     fctx->M2 = ctx->w;
370:     fctx->M3 = v;
371:     fctx->m3 = 0.0;
372:     for (i=1;i<nmat-1;i++) fctx->m3 += PetscConj(coeffs[i])*coeffs[i];
373:     fctx->M4 = 0.0;
374:     for (i=1;i<nmat-1;i++) fctx->M4 += PetscConj(coeffs[i])*coeffs2[i];
375:     fctx->M1 = M;
376:     if (ini) {
377:       MatDuplicate(M,MAT_COPY_VALUES,P);
378:     } else {
379:       MatCopy(M,*P,SAME_NONZERO_PATTERN);
380:     }
381:     VecConjugate(v);
382:     VecPointwiseMult(t,v,w);
383:     VecConjugate(v);
384:     VecScale(t,-fctx->m3/fctx->M4);
385:     MatDiagonalSet(*P,t,ADD_VALUES);
386:     break;
387:   case PEP_REFINE_SCHEME_MBE:
388:     *T = M;
389:     *P = M;
390:     break;
391:   }
392:   PetscFree2(coeffs,coeffs2);
393:   return(0);
394: }

398: PetscErrorCode PEPNewtonRefinementSimple(PEP pep,PetscInt *maxits,PetscReal tol,PetscInt k)
399: {
400:   PetscErrorCode     ierr;
401:   PetscInt           i,n,its,idx=0,*idx_sc,*its_sc,color,*fail_sc;
402:   PetscMPIInt        rank,size;
403:   Mat                Mt=NULL,T=NULL,P=NULL;
404:   MPI_Comm           comm;
405:   Vec                r,v,dv,rr=NULL,dvv=NULL,t[2];
406:   PetscScalar        *array2,deig=0.0,tt[2],ttt;
407:   const PetscScalar  *array;
408:   PetscReal          norm,error;
409:   PetscBool          ini=PETSC_TRUE,sc_pend,solved=PETSC_FALSE;
410:   PEPSimpNRefctx     *ctx;
411:   FSubctx            *fctx=NULL;
412:   KSPConvergedReason reason;

415:   PetscLogEventBegin(PEP_Refine,pep,0,0,0);
416:   PEPSimpleNRefSetUp(pep,&ctx);
417:   its = (maxits)?*maxits:NREF_MAXIT;
418:   if (!pep->refineksp) { PEPRefineGetKSP(pep,&pep->refineksp); }
419:   comm = (pep->npart==1)?PetscObjectComm((PetscObject)pep):PetscSubcommChild(pep->refinesubc);
420:   if (pep->npart==1) {
421:     BVGetColumn(pep->V,0,&v);
422:   } else v = ctx->v;
423:   VecDuplicate(v,&ctx->w);
424:   VecDuplicate(v,&r);
425:   VecDuplicate(v,&dv);
426:   VecDuplicate(v,&t[0]);
427:   VecDuplicate(v,&t[1]);
428:   if (pep->npart==1) { BVRestoreColumn(pep->V,0,&v); }
429:   MPI_Comm_size(comm,&size);
430:   MPI_Comm_rank(comm,&rank);
431:   VecGetLocalSize(r,&n);
432:   PetscMalloc3(pep->npart,&idx_sc,pep->npart,&its_sc,pep->npart,&fail_sc);
433:   for (i=0;i<pep->npart;i++) fail_sc[i] = 0;
434:   for (i=0;i<pep->npart;i++) its_sc[i] = 0;
435:   color = (pep->npart==1)?0:pep->refinesubc->color;
436:    
437:   /* Loop performing iterative refinements */
438:   while (!solved) {
439:     for (i=0;i<pep->npart;i++) {
440:       sc_pend = PETSC_TRUE;
441:       if (its_sc[i]==0) {
442:         idx_sc[i] = idx++;
443:         if (idx_sc[i]>=k) {
444:           sc_pend = PETSC_FALSE;
445:         } else {
446:           PEPSimpleNRefScatterEigenvector(pep,ctx,i,idx_sc[i]);
447:         }
448:       }  else { /* Gather Eigenpair from subcommunicator i */
449:         PEPSimpleNRefGatherEigenpair(pep,ctx,i,idx_sc[i],&fail_sc[i]);
450:       }
451:       while (sc_pend) {
452:         if (!fail_sc[i]) {
453:           PEPComputeError(pep,idx_sc[i],PEP_ERROR_BACKWARD,&error);
454:         }
455:         if (error<=tol || its_sc[i]>=its || fail_sc[i]) {
456:           idx_sc[i] = idx++;
457:           its_sc[i] = 0;
458:           if (idx_sc[i]<k) { PEPSimpleNRefScatterEigenvector(pep,ctx,i,idx_sc[i]); }
459:         } else {
460:           sc_pend = PETSC_FALSE;
461:           its_sc[i]++;
462:         }
463:         if (idx_sc[i]>=k) sc_pend = PETSC_FALSE;
464:       }
465:     }
466:     solved = PETSC_TRUE;
467:     for (i=0;i<pep->npart&&solved;i++) solved = PetscNot(idx_sc[i]<k);
468:     if (idx_sc[color]<k) {
469: #if !defined(PETSC_USE_COMPLEX)
470:       if (pep->eigi[idx_sc[color]]!=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),1,"Simple Refinement not implemented in real scalars for complex eigenvalues");
471: #endif
472:       if (pep->npart==1) {
473:         BVGetColumn(pep->V,idx_sc[color],&v);
474:       } else v = ctx->v; 
475:       PEPSimpleNRefSetUpSystem(pep,ctx->A,ctx,idx_sc[color],&Mt,&T,&P,ini,t[0],v);
476:       KSPSetOperators(pep->refineksp,T,P);
477:       if (ini) {
478:         KSPSetFromOptions(pep->refineksp);
479:         if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) {
480:           MatCreateVecs(T,&dvv,NULL);
481:           VecDuplicate(dvv,&rr);
482:         }
483:         ini = PETSC_FALSE;
484:       }

486:       switch (pep->scheme) {
487:       case PEP_REFINE_SCHEME_EXPLICIT: 
488:         MatMult(Mt,v,r);
489:         VecGetArrayRead(r,&array);
490:         if (rank==size-1) {
491:           VecGetArray(rr,&array2);
492:           PetscMemcpy(array2,array,n*sizeof(PetscScalar));
493:           array2[n] = 0.0;
494:           VecRestoreArray(rr,&array2);
495:         } else {
496:           VecPlaceArray(rr,array);
497:         }
498:         KSPSolve(pep->refineksp,rr,dvv);
499:         KSPGetConvergedReason(pep->refineksp,&reason);
500:         if (reason>0) {
501:           if (rank != size-1) {
502:             VecResetArray(rr);
503:           }
504:           VecRestoreArrayRead(r,&array);
505:           VecGetArrayRead(dvv,&array);
506:           VecPlaceArray(dv,array);
507:           VecAXPY(v,-1.0,dv);
508:           VecNorm(v,NORM_2,&norm);
509:           VecScale(v,1.0/norm);
510:           VecResetArray(dv);
511:           if (rank==size-1) pep->eigr[idx_sc[color]] -= array[n];
512:           VecRestoreArrayRead(dvv,&array);
513:         } else fail_sc[color] = 1;
514:         break;
515:       case PEP_REFINE_SCHEME_MBE:
516:         MatMult(T,v,r);
517:         /* Mixed block elimination */
518:         VecConjugate(v);
519:         KSPSolveTranspose(pep->refineksp,v,t[0]);
520:         KSPGetConvergedReason(pep->refineksp,&reason);
521:         if (reason>0) {
522:           VecConjugate(t[0]);
523:           VecDot(ctx->w,t[0],&tt[0]);
524:           KSPSolve(pep->refineksp,ctx->w,t[1]);
525:           KSPGetConvergedReason(pep->refineksp,&reason);
526:           if (reason>0) {
527:             VecDot(t[1],v,&tt[1]);
528:             VecDot(r,t[0],&ttt);
529:             tt[0] = ttt/tt[0];
530:             VecAXPY(r,-tt[0],ctx->w);
531:             KSPSolve(pep->refineksp,r,dv);
532:             KSPGetConvergedReason(pep->refineksp,&reason);
533:             if (reason>0) {
534:               VecDot(dv,v,&ttt);
535:               tt[1] = ttt/tt[1];
536:               VecAXPY(dv,-tt[1],t[1]);
537:               deig = tt[0]+tt[1];
538:             }
539:           }
540:           VecConjugate(v);
541:           VecAXPY(v,-1.0,dv);
542:           VecNorm(v,NORM_2,&norm);
543:           VecScale(v,1.0/norm);
544:           pep->eigr[idx_sc[color]] -= deig;
545:           fail_sc[color] = 0;
546:         } else {
547:           VecConjugate(v);
548:           fail_sc[color] = 1;
549:         }
550:         break;
551:       case PEP_REFINE_SCHEME_SCHUR:
552:         MatShellGetContext(T,&fctx);
553:         MatMult(fctx->M1,v,r);
554:         KSPSolve(pep->refineksp,r,dv);
555:         KSPGetConvergedReason(pep->refineksp,&reason);
556:         if (reason>0) {
557:           VecDot(dv,v,&deig);
558:           deig *= -fctx->m3/fctx->M4;
559:           VecAXPY(v,-1.0,dv);
560:           VecNorm(v,NORM_2,&norm);
561:           VecScale(v,1.0/norm);
562:           pep->eigr[idx_sc[color]] -= deig;
563:           fail_sc[color] = 0;
564:         } else fail_sc[color] = 1;
565:         break;
566:       }
567:       if (pep->npart==1) { BVRestoreColumn(pep->V,idx_sc[color],&v); } 
568:     }
569:   }
570:   VecDestroy(&t[0]);
571:   VecDestroy(&t[1]);
572:   VecDestroy(&dv);
573:   VecDestroy(&ctx->w);
574:   VecDestroy(&r);
575:   PetscFree3(idx_sc,its_sc,fail_sc);
576:   VecScatterDestroy(&ctx->nst);
577:   if (pep->npart>1) {
578:     VecDestroy(&ctx->vg);
579:     VecDestroy(&ctx->v);
580:     for (i=0;i<pep->nmat;i++) {
581:       MatDestroy(&ctx->A[i]);
582:     }
583:     for (i=0;i<pep->npart;i++) {
584:       VecScatterDestroy(&ctx->scatter_id[i]);
585:     }
586:     PetscFree2(ctx->A,ctx->scatter_id);
587:   }
588:   if (fctx && pep->scheme==PEP_REFINE_SCHEME_SCHUR) {
589:     MatDestroy(&P);
590:     MatDestroy(&fctx->M1);
591:     PetscFree(fctx);
592:   }
593:   if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) {
594:     MatDestroy(&Mt);
595:     VecDestroy(&dvv);
596:     VecDestroy(&rr);
597:     VecDestroy(&ctx->nv);
598:   }
599:   MatDestroy(&T);
600:   PetscFree(ctx);
601:   PetscLogEventEnd(PEP_Refine,pep,0,0,0);
602:   return(0);
603: }

slepc-3.7.4/src/pep/interface/pepsetup.c.html0000644000175000017500000011317213107004621020457 0ustar jromanjroman
Actual source code: pepsetup.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       PEP routines related to problem setup.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>       /*I "slepcpep.h" I*/

 28: /*@
 29:    PEPSetUp - Sets up all the internal data structures necessary for the
 30:    execution of the PEP solver.

 32:    Collective on PEP

 34:    Input Parameter:
 35: .  pep   - solver context

 37:    Notes:
 38:    This function need not be called explicitly in most cases, since PEPSolve()
 39:    calls it. It can be useful when one wants to measure the set-up time
 40:    separately from the solve time.

 42:    Level: developer

 44: .seealso: PEPCreate(), PEPSolve(), PEPDestroy()
 45: @*/
 46: PetscErrorCode PEPSetUp(PEP pep)
 47: {
 49:   SlepcSC        sc;
 50:   PetscBool      istrivial,flg;
 51:   PetscInt       k;
 52:   KSP            ksp;
 53:   PC             pc;
 54:   PetscMPIInt    size;
 55:   const MatSolverPackage stype;

 59:   if (pep->state) return(0);
 60:   PetscLogEventBegin(PEP_SetUp,pep,0,0,0);

 62:   /* reset the convergence flag from the previous solves */
 63:   pep->reason = PEP_CONVERGED_ITERATING;

 65:   /* set default solver type (PEPSetFromOptions was not called) */
 66:   if (!((PetscObject)pep)->type_name) {
 67:     PEPSetType(pep,PEPTOAR);
 68:   }
 69:   if (!pep->st) { PEPGetST(pep,&pep->st); }
 70:   if (!pep->ds) { PEPGetDS(pep,&pep->ds); }
 71:   DSReset(pep->ds);
 72:   if (!pep->rg) { PEPGetRG(pep,&pep->rg); }
 73:   if (!((PetscObject)pep->rg)->type_name) {
 74:     RGSetType(pep->rg,RGINTERVAL);
 75:   }

 77:   /* check matrices, transfer them to ST */
 78:   if (!pep->A) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONGSTATE,"PEPSetOperators must be called first");
 79:   STSetOperators(pep->st,pep->nmat,pep->A);

 81:   /* set problem dimensions */
 82:   MatGetSize(pep->A[0],&pep->n,NULL);
 83:   MatGetLocalSize(pep->A[0],&pep->nloc,NULL);

 85:   /* set default problem type */
 86:   if (!pep->problem_type) {
 87:     PEPSetProblemType(pep,PEP_GENERAL);
 88:   }

 90:   /* check consistency of refinement options */
 91:   if (pep->refine) {
 92:     if (!pep->scheme) {  /* set default scheme */
 93:       PEPRefineGetKSP(pep,&ksp);
 94:       KSPGetPC(ksp,&pc);
 95:       PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);
 96:       if (flg) {
 97:         PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");
 98:       }
 99:       pep->scheme = flg? PEP_REFINE_SCHEME_MBE: PEP_REFINE_SCHEME_SCHUR;
100:     }
101:     if (pep->scheme==PEP_REFINE_SCHEME_MBE) {
102:       PEPRefineGetKSP(pep,&ksp);
103:       KSPGetPC(ksp,&pc);
104:       PetscObjectTypeCompare((PetscObject)ksp,KSPPREONLY,&flg);
105:       if (flg) {
106:         PetscObjectTypeCompareAny((PetscObject)pc,&flg,PCLU,PCCHOLESKY,"");
107:       }
108:       if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"The MBE scheme for refinement requires a direct solver in KSP");
109:       MPI_Comm_size(PetscObjectComm((PetscObject)pc),&size);
110:       if (size>1) {   /* currently selected PC is a factorization */
111:         PCFactorGetMatSolverPackage(pc,&stype);
112:         PetscStrcmp(stype,MATSOLVERPETSC,&flg);
113:         if (flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"For Newton refinement, you chose to solve linear systems with a factorization, but in parallel runs you need to select an external package");
114:       }
115:     }
116:     if (pep->scheme==PEP_REFINE_SCHEME_SCHUR) {
117:       if (pep->npart>1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"The Schur scheme for refinement does not support subcommunicators"); 
118:     }
119:   }
120:   /* call specific solver setup */
121:   (*pep->ops->setup)(pep);

123:   /* set tolerance if not yet set */
124:   if (pep->tol==PETSC_DEFAULT) pep->tol = SLEPC_DEFAULT_TOL;
125:   if (pep->refine) {
126:     if (pep->rtol==PETSC_DEFAULT) pep->rtol = PetscMax(pep->tol/1000,PETSC_MACHINE_EPSILON);
127:     if (pep->rits==PETSC_DEFAULT) pep->rits = (pep->refine==PEP_REFINE_SIMPLE)? 10: 1;
128:   }

130:   /* set default extraction */
131:   if (!pep->extract) {
132:     pep->extract = (pep->basis==PEP_BASIS_MONOMIAL)? PEP_EXTRACT_NORM: PEP_EXTRACT_NONE;
133:   }

135:   /* fill sorting criterion context */
136:   switch (pep->which) {
137:     case PEP_LARGEST_MAGNITUDE:
138:       pep->sc->comparison    = SlepcCompareLargestMagnitude;
139:       pep->sc->comparisonctx = NULL;
140:       break;
141:     case PEP_SMALLEST_MAGNITUDE:
142:       pep->sc->comparison    = SlepcCompareSmallestMagnitude;
143:       pep->sc->comparisonctx = NULL;
144:       break;
145:     case PEP_LARGEST_REAL:
146:       pep->sc->comparison    = SlepcCompareLargestReal;
147:       pep->sc->comparisonctx = NULL;
148:       break;
149:     case PEP_SMALLEST_REAL:
150:       pep->sc->comparison    = SlepcCompareSmallestReal;
151:       pep->sc->comparisonctx = NULL;
152:       break;
153:     case PEP_LARGEST_IMAGINARY:
154:       pep->sc->comparison    = SlepcCompareLargestImaginary;
155:       pep->sc->comparisonctx = NULL;
156:       break;
157:     case PEP_SMALLEST_IMAGINARY:
158:       pep->sc->comparison    = SlepcCompareSmallestImaginary;
159:       pep->sc->comparisonctx = NULL;
160:       break;
161:     case PEP_TARGET_MAGNITUDE:
162:       pep->sc->comparison    = SlepcCompareTargetMagnitude;
163:       pep->sc->comparisonctx = &pep->target;
164:       break;
165:     case PEP_TARGET_REAL:
166:       pep->sc->comparison    = SlepcCompareTargetReal;
167:       pep->sc->comparisonctx = &pep->target;
168:       break;
169:     case PEP_TARGET_IMAGINARY:
170:       pep->sc->comparison    = SlepcCompareTargetImaginary;
171:       pep->sc->comparisonctx = &pep->target;
172:       break;
173:     case PEP_WHICH_USER:
174:       break;
175:   }
176:   pep->sc->map    = NULL;
177:   pep->sc->mapobj = NULL;

179:   /* fill sorting criterion for DS */
180:   DSGetSlepcSC(pep->ds,&sc);
181:   RGIsTrivial(pep->rg,&istrivial);
182:   sc->rg            = istrivial? NULL: pep->rg;
183:   sc->comparison    = pep->sc->comparison;
184:   sc->comparisonctx = pep->sc->comparisonctx;
185:   sc->map           = SlepcMap_ST;
186:   sc->mapobj        = (PetscObject)pep->st;

188:   /* setup ST */
189:   STSetUp(pep->st);
190:   /* compute matrix coefficients */
191:   STGetTransform(pep->st,&flg);
192:   if (!flg) {
193:     if (pep->solvematcoeffs) { STMatSetUp(pep->st,1.0,pep->solvematcoeffs); }
194:   } else {
195:     if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Cannot use ST-transform with non-monomial basis in PEP");
196:   }

198:   /* compute scale factor if no set by user */
199:   PEPComputeScaleFactor(pep);

201:   /* build balancing matrix if required */
202:   if (pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) {
203:     if (!pep->Dl) {
204:       BVCreateVec(pep->V,&pep->Dl);
205:       PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->Dl);
206:     }
207:     if (!pep->Dr) {
208:       BVCreateVec(pep->V,&pep->Dr);
209:       PetscLogObjectParent((PetscObject)pep,(PetscObject)pep->Dr);
210:     }
211:     PEPBuildDiagonalScaling(pep);
212:   }

214:   /* process initial vectors */
215:   if (pep->nini<0) {
216:     k = -pep->nini;
217:     if (k>pep->ncv) SETERRQ(PetscObjectComm((PetscObject)pep),1,"The number of initial vectors is larger than ncv");
218:     BVInsertVecs(pep->V,0,&k,pep->IS,PETSC_TRUE);
219:     SlepcBasisDestroy_Private(&pep->nini,&pep->IS);
220:     pep->nini = k;
221:   }
222:   PetscLogEventEnd(PEP_SetUp,pep,0,0,0);
223:   pep->state = PEP_STATE_SETUP;
224:   return(0);
225: }

229: /*@
230:    PEPSetOperators - Sets the coefficient matrices associated with the polynomial
231:    eigenvalue problem.

233:    Collective on PEP and Mat

235:    Input Parameters:
236: +  pep  - the eigenproblem solver context
237: .  nmat - number of matrices in array A
238: -  A    - the array of matrices associated with the eigenproblem

240:    Notes:
241:    The polynomial eigenproblem is defined as P(l)*x=0, where l is
242:    the eigenvalue, x is the eigenvector, and P(l) is defined as
243:    P(l) = A_0 + l*A_1 + ... + l^d*A_d, with d=nmat-1 (the degree of P).
244:    For non-monomial bases, this expression is different.

246:    Level: beginner

248: .seealso: PEPSolve(), PEPGetOperators(), PEPGetNumMatrices(), PEPSetBasis()
249: @*/
250: PetscErrorCode PEPSetOperators(PEP pep,PetscInt nmat,Mat A[])
251: {
253:   PetscInt       i,n,m,m0=0;

258:   if (nmat <= 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Non-positive value of nmat: %D",nmat);
259:   if (nmat <= 2) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Cannot solve linear eigenproblems with PEP; use EPS instead");

262:   if (pep->state) { PEPReset(pep); }
263:   PetscMalloc1(nmat,&pep->A);
264:   PetscCalloc2(3*nmat,&pep->pbc,nmat,&pep->nrma);
265:   for (i=0;i<nmat;i++) pep->pbc[i] = 1.0;  /* default to monomial basis */
266:   PetscLogObjectMemory((PetscObject)pep,nmat*sizeof(Mat)+4*nmat*sizeof(PetscReal)+nmat*sizeof(PetscScalar));
267:   for (i=0;i<nmat;i++) {
270:     MatGetSize(A[i],&m,&n);
271:     if (m!=n) SETERRQ1(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONG,"A[%D] is a non-square matrix",i);
272:     if (!i) m0 = m;
273:     if (m!=m0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_INCOMP,"Dimensions of matrices do not match with each other");
274:     PetscObjectReference((PetscObject)A[i]);
275:     pep->A[i] = A[i];
276:   }
277:   pep->nmat = nmat;
278:   return(0);
279: }

283: /*@
284:    PEPGetOperators - Gets the matrices associated with the polynomial eigensystem.

286:    Not collective, though parallel Mats are returned if the PEP is parallel

288:    Input Parameters:
289: +  pep - the PEP context
290: -  k   - the index of the requested matrix (starting in 0)

292:    Output Parameter:
293: .  A - the requested matrix

295:    Level: intermediate

297: .seealso: PEPSolve(), PEPSetOperators(), PEPGetNumMatrices()
298: @*/
299: PetscErrorCode PEPGetOperators(PEP pep,PetscInt k,Mat *A)
300: {
304:   if (k<0 || k>=pep->nmat) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"k must be between 0 and %D",pep->nmat-1);
305:   *A = pep->A[k];
306:   return(0);
307: }

311: /*@
312:    PEPGetNumMatrices - Returns the number of matrices stored in the PEP.

314:    Not collective

316:    Input Parameter:
317: .  pep - the PEP context

319:    Output Parameters:
320: .  nmat - the number of matrices passed in PEPSetOperators()

322:    Level: intermediate

324: .seealso: PEPSetOperators()
325: @*/
326: PetscErrorCode PEPGetNumMatrices(PEP pep,PetscInt *nmat)
327: {
331:   *nmat = pep->nmat;
332:   return(0);
333: }

337: /*@
338:    PEPSetInitialSpace - Specify a basis of vectors that constitute the initial
339:    space, that is, the subspace from which the solver starts to iterate.

341:    Collective on PEP and Vec

343:    Input Parameter:
344: +  pep   - the polynomial eigensolver context
345: .  n     - number of vectors
346: -  is    - set of basis vectors of the initial space

348:    Notes:
349:    Some solvers start to iterate on a single vector (initial vector). In that case,
350:    the other vectors are ignored.

352:    These vectors do not persist from one PEPSolve() call to the other, so the
353:    initial space should be set every time.

355:    The vectors do not need to be mutually orthonormal, since they are explicitly
356:    orthonormalized internally.

358:    Common usage of this function is when the user can provide a rough approximation
359:    of the wanted eigenspace. Then, convergence may be faster.

361:    Level: intermediate
362: @*/
363: PetscErrorCode PEPSetInitialSpace(PEP pep,PetscInt n,Vec *is)
364: {

370:   if (n<0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Argument n cannot be negative");
371:   SlepcBasisReference_Private(n,is,&pep->nini,&pep->IS);
372:   if (n>0) pep->state = PEP_STATE_INITIAL;
373:   return(0);
374: }

378: /*
379:   PEPSetDimensions_Default - Set reasonable values for ncv, mpd if not set
380:   by the user. This is called at setup.
381:  */
382: PetscErrorCode PEPSetDimensions_Default(PEP pep,PetscInt nev,PetscInt *ncv,PetscInt *mpd)
383: {
385:   PetscBool      krylov;
386:   PetscInt       dim;

389:   PetscObjectTypeCompareAny((PetscObject)pep,&krylov,PEPTOAR,PEPQARNOLDI,"");
390:   dim = krylov?(pep->nmat-1)*pep->n:pep->n;
391:   if (*ncv) { /* ncv set */
392:     if (krylov) {
393:       if (*ncv<nev+1 && !(*ncv==nev && *ncv==dim)) SETERRQ(PetscObjectComm((PetscObject)pep),1,"The value of ncv must be at least nev+1");
394:     } else {
395:       if (*ncv<nev) SETERRQ(PetscObjectComm((PetscObject)pep),1,"The value of ncv must be at least nev");
396:     }
397:   } else if (*mpd) { /* mpd set */
398:     *ncv = PetscMin(dim,nev+(*mpd));
399:   } else { /* neither set: defaults depend on nev being small or large */
400:     if (nev<500) *ncv = PetscMin(dim,PetscMax(2*nev,nev+15));
401:     else {
402:       *mpd = 500;
403:       *ncv = PetscMin(dim,nev+(*mpd));
404:     }
405:   }
406:   if (!*mpd) *mpd = *ncv;
407:   return(0);
408: }

412: /*@
413:    PEPAllocateSolution - Allocate memory storage for common variables such
414:    as eigenvalues and eigenvectors.

416:    Collective on PEP

418:    Input Parameters:
419: +  pep   - eigensolver context
420: -  extra - number of additional positions, used for methods that require a
421:            working basis slightly larger than ncv

423:    Developers Note:
424:    This is PETSC_EXTERN because it may be required by user plugin PEP
425:    implementations.

427:    Level: developer
428: @*/
429: PetscErrorCode PEPAllocateSolution(PEP pep,PetscInt extra)
430: {
432:   PetscInt       oldsize,newc,requested,requestedbv;
433:   PetscLogDouble cnt;
434:   Vec            t;

437:   requested = (pep->lineariz? pep->ncv: pep->ncv*(pep->nmat-1)) + extra;
438:   requestedbv = pep->ncv + extra;

440:   /* oldsize is zero if this is the first time setup is called */
441:   BVGetSizes(pep->V,NULL,NULL,&oldsize);

443:   /* allocate space for eigenvalues and friends */
444:   if (requested != oldsize || !pep->eigr) {
445:     if (oldsize) {
446:       PetscFree4(pep->eigr,pep->eigi,pep->errest,pep->perm);
447:     }
448:     PetscMalloc4(requested,&pep->eigr,requested,&pep->eigi,requested,&pep->errest,requested,&pep->perm);
449:     newc = PetscMax(0,requested-oldsize);
450:     cnt = 2*newc*sizeof(PetscScalar) + newc*sizeof(PetscReal) + newc*sizeof(PetscInt);
451:     PetscLogObjectMemory((PetscObject)pep,cnt);
452:   }

454:   /* allocate V */
455:   if (!pep->V) { PEPGetBV(pep,&pep->V); }
456:   if (!oldsize) {
457:     if (!((PetscObject)(pep->V))->type_name) {
458:       BVSetType(pep->V,BVSVEC);
459:     }
460:     STMatCreateVecs(pep->st,&t,NULL);
461:     BVSetSizesFromVec(pep->V,t,requestedbv);
462:     VecDestroy(&t);
463:   } else {
464:     BVResize(pep->V,requestedbv,PETSC_FALSE);
465:   }
466:   return(0);
467: }

slepc-3.7.4/src/pep/interface/pepmon.c.html0000644000175000017500000010612113107004621020104 0ustar jromanjroman
Actual source code: pepmon.c

slepc-3.7.4 2017-05-17
  1: /*
  2:       PEP routines related to monitors.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>      /*I "slepcpep.h" I*/
 25: #include <petscdraw.h>

 29: /*
 30:    Runs the user provided monitor routines, if any.
 31: */
 32: PetscErrorCode PEPMonitor(PEP pep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)
 33: {
 35:   PetscInt       i,n = pep->numbermonitors;

 38:   for (i=0;i<n;i++) {
 39:     (*pep->monitor[i])(pep,it,nconv,eigr,eigi,errest,nest,pep->monitorcontext[i]);
 40:   }
 41:   return(0);
 42: }

 46: /*@C
 47:    PEPMonitorSet - Sets an ADDITIONAL function to be called at every
 48:    iteration to monitor the error estimates for each requested eigenpair.

 50:    Logically Collective on PEP

 52:    Input Parameters:
 53: +  pep     - eigensolver context obtained from PEPCreate()
 54: .  monitor - pointer to function (if this is NULL, it turns off monitoring)
 55: .  mctx    - [optional] context for private data for the
 56:              monitor routine (use NULL if no context is desired)
 57: -  monitordestroy - [optional] routine that frees monitor context (may be NULL)

 59:    Calling Sequence of monitor:
 60: $   monitor(PEP pep,int its,int nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal* errest,int nest,void *mctx)

 62: +  pep    - polynomial eigensolver context obtained from PEPCreate()
 63: .  its    - iteration number
 64: .  nconv  - number of converged eigenpairs
 65: .  eigr   - real part of the eigenvalues
 66: .  eigi   - imaginary part of the eigenvalues
 67: .  errest - relative error estimates for each eigenpair
 68: .  nest   - number of error estimates
 69: -  mctx   - optional monitoring context, as set by PEPMonitorSet()

 71:    Options Database Keys:
 72: +    -pep_monitor        - print only the first error estimate
 73: .    -pep_monitor_all    - print error estimates at each iteration
 74: .    -pep_monitor_conv   - print the eigenvalue approximations only when
 75:       convergence has been reached
 76: .    -pep_monitor_lg     - sets line graph monitor for the first unconverged
 77:       approximate eigenvalue
 78: .    -pep_monitor_lg_all - sets line graph monitor for all unconverged
 79:       approximate eigenvalues
 80: -    -pep_monitor_cancel - cancels all monitors that have been hardwired into
 81:       a code by calls to PEPMonitorSet(), but does not cancel those set via
 82:       the options database.

 84:    Notes:
 85:    Several different monitoring routines may be set by calling
 86:    PEPMonitorSet() multiple times; all will be called in the
 87:    order in which they were set.

 89:    Level: intermediate

 91: .seealso: PEPMonitorFirst(), PEPMonitorAll(), PEPMonitorCancel()
 92: @*/
 93: PetscErrorCode PEPMonitorSet(PEP pep,PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))
 94: {
 97:   if (pep->numbermonitors >= MAXPEPMONITORS) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Too many PEP monitors set");
 98:   pep->monitor[pep->numbermonitors]           = monitor;
 99:   pep->monitorcontext[pep->numbermonitors]    = (void*)mctx;
100:   pep->monitordestroy[pep->numbermonitors++]  = monitordestroy;
101:   return(0);
102: }

106: /*@
107:    PEPMonitorCancel - Clears all monitors for a PEP object.

109:    Logically Collective on PEP

111:    Input Parameters:
112: .  pep - eigensolver context obtained from PEPCreate()

114:    Options Database Key:
115: .    -pep_monitor_cancel - Cancels all monitors that have been hardwired
116:       into a code by calls to PEPMonitorSet(),
117:       but does not cancel those set via the options database.

119:    Level: intermediate

121: .seealso: PEPMonitorSet()
122: @*/
123: PetscErrorCode PEPMonitorCancel(PEP pep)
124: {
126:   PetscInt       i;

130:   for (i=0; i<pep->numbermonitors; i++) {
131:     if (pep->monitordestroy[i]) {
132:       (*pep->monitordestroy[i])(&pep->monitorcontext[i]);
133:     }
134:   }
135:   pep->numbermonitors = 0;
136:   return(0);
137: }

141: /*@C
142:    PEPGetMonitorContext - Gets the monitor context, as set by
143:    PEPMonitorSet() for the FIRST monitor only.

145:    Not Collective

147:    Input Parameter:
148: .  pep - eigensolver context obtained from PEPCreate()

150:    Output Parameter:
151: .  ctx - monitor context

153:    Level: intermediate

155: .seealso: PEPMonitorSet(), PEPDefaultMonitor()
156: @*/
157: PetscErrorCode PEPGetMonitorContext(PEP pep,void **ctx)
158: {
161:   *ctx = pep->monitorcontext[0];
162:   return(0);
163: }

167: /*
168:    Helper function to compute eigenvalue that must be viewed in monitor
169:  */
170: static PetscErrorCode PEPMonitorGetTrueEig(PEP pep,PetscScalar *er,PetscScalar *ei)
171: {
173:   PetscBool      flg;

176:   STGetTransform(pep->st,&flg);
177:   if (flg) {
178:     *er *= pep->sfactor; *ei *= pep->sfactor;
179:   }
180:   STBackTransform(pep->st,1,er,ei);
181:   if (!flg) {
182:     *er *= pep->sfactor; *ei *= pep->sfactor;
183:   }
184:   return(0);
185: }

189: /*@C
190:    PEPMonitorAll - Print the current approximate values and
191:    error estimates at each iteration of the polynomial eigensolver.

193:    Collective on PEP

195:    Input Parameters:
196: +  pep    - polynomial eigensolver context
197: .  its    - iteration number
198: .  nconv  - number of converged eigenpairs so far
199: .  eigr   - real part of the eigenvalues
200: .  eigi   - imaginary part of the eigenvalues
201: .  errest - error estimates
202: .  nest   - number of error estimates to display
203: -  vf     - viewer and format for monitoring

205:    Level: intermediate

207: .seealso: PEPMonitorSet(), PEPMonitorFirst(), PEPMonitorConverged()
208: @*/
209: PetscErrorCode PEPMonitorAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
210: {
212:   PetscInt       i;
213:   PetscScalar    er,ei;
214:   PetscViewer    viewer;

219:   viewer = vf->viewer;
221:   PetscViewerPushFormat(viewer,vf->format);
222:   PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);
223:   if (its==1 && ((PetscObject)pep)->prefix) {
224:     PetscViewerASCIIPrintf(viewer,"  Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)pep)->prefix);
225:   }
226:   PetscViewerASCIIPrintf(viewer,"%3D PEP nconv=%D Values (Errors)",its,nconv);
227:   PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
228:   for (i=0;i<nest;i++) {
229:     er = eigr[i]; ei = eigi[i];
230:     PEPMonitorGetTrueEig(pep,&er,&ei);
231: #if defined(PETSC_USE_COMPLEX)
232:     PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));
233: #else
234:     PetscViewerASCIIPrintf(viewer," %g",(double)er);
235:     if (eigi[i]!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei); }
236: #endif
237:     PetscViewerASCIIPrintf(viewer," (%10.8e)",(double)errest[i]);
238:   }
239:   PetscViewerASCIIPrintf(viewer,"\n");
240:   PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
241:   PetscViewerASCIISubtractTab(viewer,((PetscObject)pep)->tablevel);
242:   PetscViewerPopFormat(viewer);
243:   return(0);
244: }

248: /*@C
249:    PEPMonitorFirst - Print the first unconverged approximate value and
250:    error estimate at each iteration of the polynomial eigensolver.

252:    Collective on PEP

254:    Input Parameters:
255: +  pep    - polynomial eigensolver context
256: .  its    - iteration number
257: .  nconv  - number of converged eigenpairs so far
258: .  eigr   - real part of the eigenvalues
259: .  eigi   - imaginary part of the eigenvalues
260: .  errest - error estimates
261: .  nest   - number of error estimates to display
262: -  vf     - viewer and format for monitoring

264:    Level: intermediate

266: .seealso: PEPMonitorSet(), PEPMonitorAll(), PEPMonitorConverged()
267: @*/
268: PetscErrorCode PEPMonitorFirst(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)
269: {
271:   PetscScalar    er,ei;
272:   PetscViewer    viewer;

277:   viewer = vf->viewer;
279:   if (its==1 && ((PetscObject)pep)->prefix) {
280:     PetscViewerASCIIPrintf(viewer,"  Eigenvalue approximations and residual norms for %s solve.\n",((PetscObject)pep)->prefix);
281:   }
282:   if (nconv<nest) {
283:     PetscViewerPushFormat(viewer,vf->format);
284:     PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);
285:     PetscViewerASCIIPrintf(viewer,"%3D PEP nconv=%D first unconverged value (error)",its,nconv);
286:     PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
287:     er = eigr[nconv]; ei = eigi[nconv];
288:     PEPMonitorGetTrueEig(pep,&er,&ei);
289: #if defined(PETSC_USE_COMPLEX)
290:     PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));
291: #else
292:     PetscViewerASCIIPrintf(viewer," %g",(double)er);
293:     if (eigi[nconv]!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei); }
294: #endif
295:     PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[nconv]);
296:     PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
297:     PetscViewerASCIISubtractTab(viewer,((PetscObject)pep)->tablevel);
298:     PetscViewerPopFormat(viewer);
299:   }
300:   return(0);
301: }

305: /*@C
306:    PEPMonitorConverged - Print the approximate values and
307:    error estimates as they converge.

309:    Collective on PEP

311:    Input Parameters:
312: +  pep    - polynomial eigensolver context
313: .  its    - iteration number
314: .  nconv  - number of converged eigenpairs so far
315: .  eigr   - real part of the eigenvalues
316: .  eigi   - imaginary part of the eigenvalues
317: .  errest - error estimates
318: .  nest   - number of error estimates to display
319: -  ctx    - monitor context

321:    Level: intermediate

323: .seealso: PEPMonitorSet(), PEPMonitorFirst(), PEPMonitorAll()
324: @*/
325: PetscErrorCode PEPMonitorConverged(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)
326: {
328:   PetscInt       i;
329:   PetscScalar    er,ei;
330:   PetscViewer    viewer;

335:   viewer = ctx->viewer;
337:   if (its==1 && ((PetscObject)pep)->prefix) {
338:     PetscViewerASCIIPrintf(viewer,"  Convergence history for %s solve.\n",((PetscObject)pep)->prefix);
339:   }
340:   if (its==1) ctx->oldnconv = 0;
341:   if (ctx->oldnconv!=nconv) {
342:     PetscViewerPushFormat(viewer,ctx->format);
343:     PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);
344:     for (i=ctx->oldnconv;i<nconv;i++) {
345:       PetscViewerASCIIPrintf(viewer,"%3D PEP converged value (error) #%D",its,i);
346:       PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);
347:       er = eigr[i]; ei = eigi[i];
348:       PEPMonitorGetTrueEig(pep,&er,&ei);
349: #if defined(PETSC_USE_COMPLEX)
350:       PetscViewerASCIIPrintf(viewer," %g%+gi",(double)PetscRealPart(er),(double)PetscImaginaryPart(er));
351: #else
352:       PetscViewerASCIIPrintf(viewer," %g",(double)er);
353:       if (eigi[i]!=0.0) { PetscViewerASCIIPrintf(viewer,"%+gi",(double)ei); }
354: #endif
355:       PetscViewerASCIIPrintf(viewer," (%10.8e)\n",(double)errest[i]);
356:       PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);
357:     }
358:     PetscViewerASCIISubtractTab(viewer,((PetscObject)pep)->tablevel);
359:     PetscViewerPopFormat(viewer);
360:     ctx->oldnconv = nconv;
361:   }
362:   return(0);
363: }

367: /*@C
368:    PEPMonitorLGCreate - Creates a line graph context for use with
369:    PEP to monitor convergence.

371:    Collective on MPI_Comm

373:    Input Parameters:
374: +  comm - communicator context
375: .  host - the X display to open, or null for the local machine
376: .  label - the title to put in the title bar
377: .  x, y - the screen coordinates of the upper left coordinate of
378:           the window
379: -  m, n - the screen width and height in pixels

381:    Output Parameter:
382: .  lgctx - the drawing context

384:    Options Database Keys:
385: +  -pep_monitor_lg - Sets line graph monitor for the first residual
386: -  -pep_monitor_lg_all - Sets line graph monitor for all residuals

388:    Notes:
389:    Use PetscDrawLGDestroy() to destroy this line graph.

391:    Level: intermediate

393: .seealso: PEPMonitorSet()
394: @*/
395: PetscErrorCode PEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)
396: {
397:   PetscDraw      draw;
398:   PetscDrawLG    lg;

402:   PetscDrawCreate(comm,host,label,x,y,m,n,&draw);
403:   PetscDrawSetFromOptions(draw);
404:   PetscDrawLGCreate(draw,1,&lg);
405:   PetscDrawLGSetFromOptions(lg);
406:   PetscDrawDestroy(&draw);
407:   *lgctx = lg;
408:   return(0);
409: }

413: PetscErrorCode PEPMonitorLG(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
414: {
415:   PetscDrawLG    lg = (PetscDrawLG)ctx;
416:   PetscReal      x,y;

421:   if (its==1) {
422:     PetscDrawLGReset(lg);
423:     PetscDrawLGSetDimension(lg,1);
424:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(pep->tol)-2,0.0);
425:   }
426:   x = (PetscReal)its;
427:   if (errest[nconv] > 0.0) y = PetscLog10Real(errest[nconv]);
428:   else y = 0.0;
429:   PetscDrawLGAddPoint(lg,&x,&y);
430:   if (its <= 20 || !(its % 5) || pep->reason) {
431:     PetscDrawLGDraw(lg);
432:     PetscDrawLGSave(lg);
433:   }
434:   return(0);
435: }

439: PetscErrorCode PEPMonitorLGAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
440: {
441:   PetscDrawLG    lg = (PetscDrawLG)ctx;
442:   PetscInt       i,n = PetscMin(pep->nev,255);
443:   PetscReal      *x,*y;

448:   if (its==1) {
449:     PetscDrawLGReset(lg);
450:     PetscDrawLGSetDimension(lg,n);
451:     PetscDrawLGSetLimits(lg,1,1.0,PetscLog10Real(pep->tol)-2,0.0);
452:   }
453:   PetscMalloc2(n,&x,n,&y);
454:   for (i=0;i<n;i++) {
455:     x[i] = (PetscReal)its;
456:     if (i < nest && errest[i] > 0.0) y[i] = PetscLog10Real(errest[i]);
457:     else y[i] = 0.0;
458:   }
459:   PetscDrawLGAddPoint(lg,x,y);
460:   if (its <= 20 || !(its % 5) || pep->reason) {
461:     PetscDrawLGDraw(lg);
462:     PetscDrawLGSave(lg);
463:   }
464:   PetscFree2(x,y);
465:   return(0);
466: }

slepc-3.7.4/src/pep/interface/index.html0000644000175000017500000000370413107004621017477 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

pepmon.c
pepbasic.c
pepview.c
pepdefault.c
pepregis.c
pepopts.c
pepsetup.c
pepsolve.c
peprefine.c
dlregispep.c
makefile
slepc-3.7.4/src/pep/interface/pepopts.c0000644000175000017500000015417013107004621017344 0ustar jromanjroman/* PEP routines related to options that can be set via the command-line or procedurally. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "PEPMonitorSetFromOptions" /*@C PEPMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user. Collective on PEP Input Parameters: + pep - the polynomial eigensolver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor . monitor - the monitor function, whose context is a PetscViewerAndFormat - trackall - whether this monitor tracks all eigenvalues or not Level: developer .seealso: PEPMonitorSet(), PEPSetTrackAll(), PEPConvMonitorSetFromOptions() @*/ PetscErrorCode PEPMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; PetscViewerAndFormat *vf; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerAndFormatCreate(viewer,format,&vf);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = PEPMonitorSet(pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);CHKERRQ(ierr); if (trackall) { ierr = PEPSetTrackAll(pep,PETSC_TRUE);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPConvMonitorSetFromOptions" /*@C PEPConvMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type indicated by the user (for monitors that only show iteration numbers of convergence). Collective on PEP Input Parameters: + pep - the polynomial eigensolver context . name - the monitor option name . help - message indicating what monitoring is done . manual - manual page for the monitor - monitor - the monitor function, whose context is a SlepcConvMonitor Level: developer .seealso: PEPMonitorSet(), PEPMonitorSetFromOptions() @*/ PetscErrorCode PEPConvMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor)) { PetscErrorCode ierr; PetscBool flg; PetscViewer viewer; PetscViewerFormat format; SlepcConvMonitor ctx; PetscFunctionBegin; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = SlepcConvMonitorCreate(viewer,format,&ctx);CHKERRQ(ierr); ierr = PetscObjectDereference((PetscObject)viewer);CHKERRQ(ierr); ierr = PEPMonitorSet(pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))monitor,ctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetFromOptions" /*@ PEPSetFromOptions - Sets PEP options from the options database. This routine must be called before PEPSetUp() if the user is to be allowed to set the solver type. Collective on PEP Input Parameters: . pep - the polynomial eigensolver context Notes: To see all options, run your program with the -help option. Level: beginner @*/ PetscErrorCode PEPSetFromOptions(PEP pep) { PetscErrorCode ierr; char type[256]; PetscBool set,flg,flg1,flg2,flg3; PetscReal r,t; PetscScalar s; PetscInt i,j,k; PetscDrawLG lg; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); ierr = PEPRegisterAll();CHKERRQ(ierr); ierr = PetscObjectOptionsBegin((PetscObject)pep);CHKERRQ(ierr); ierr = PetscOptionsFList("-pep_type","Polynomial Eigenvalue Problem method","PEPSetType",PEPList,(char*)(((PetscObject)pep)->type_name?((PetscObject)pep)->type_name:PEPTOAR),type,256,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetType(pep,type);CHKERRQ(ierr); } else if (!((PetscObject)pep)->type_name) { ierr = PEPSetType(pep,PEPTOAR);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-pep_general","general polynomial eigenvalue problem","PEPSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetProblemType(pep,PEP_GENERAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_hermitian","hermitian polynomial eigenvalue problem","PEPSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetProblemType(pep,PEP_HERMITIAN);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-pep_gyroscopic","gyroscopic polynomial eigenvalue problem","PEPSetProblemType",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetProblemType(pep,PEP_GYROSCOPIC);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-pep_scale","Scaling strategy","PEPSetScale",PEPScaleTypes,(PetscEnum)pep->scale,(PetscEnum*)&pep->scale,NULL);CHKERRQ(ierr); r = pep->sfactor; ierr = PetscOptionsReal("-pep_scale_factor","Scale factor","PEPSetScale",pep->sfactor,&r,&flg1);CHKERRQ(ierr); j = pep->sits; ierr = PetscOptionsInt("-pep_scale_its","Number of iterations in diagonal scaling","PEPSetScale",pep->sits,&j,&flg2);CHKERRQ(ierr); t = pep->slambda; ierr = PetscOptionsReal("-pep_scale_lambda","Estimate of eigenvalue (modulus) for diagonal scaling","PEPSetScale",pep->slambda,&t,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = PEPSetScale(pep,pep->scale,r,NULL,NULL,j,t);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-pep_extract","Extraction method","PEPSetExtract",PEPExtractTypes,(PetscEnum)pep->extract,(PetscEnum*)&pep->extract,NULL);CHKERRQ(ierr); ierr = PetscOptionsEnum("-pep_refine","Iterative refinement method","PEPSetRefine",PEPRefineTypes,(PetscEnum)pep->refine,(PetscEnum*)&pep->refine,NULL);CHKERRQ(ierr); i = pep->npart; ierr = PetscOptionsInt("-pep_refine_partitions","Number of partitions of the communicator for iterative refinement","PEPSetRefine",pep->npart,&i,&flg1);CHKERRQ(ierr); r = pep->rtol; ierr = PetscOptionsReal("-pep_refine_tol","Tolerance for iterative refinement","PEPSetRefine",pep->rtol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL/1000:pep->rtol,&r,&flg2);CHKERRQ(ierr); j = pep->rits; ierr = PetscOptionsInt("-pep_refine_its","Maximum number of iterations for iterative refinement","PEPSetRefine",pep->rits,&j,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = PEPSetRefine(pep,pep->refine,i,r,j,pep->scheme);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-pep_refine_scheme","Scheme used for linear systems within iterative refinement","PEPSetRefine",PEPRefineSchemes,(PetscEnum)pep->scheme,(PetscEnum*)&pep->scheme,NULL);CHKERRQ(ierr); i = pep->max_it? pep->max_it: PETSC_DEFAULT; ierr = PetscOptionsInt("-pep_max_it","Maximum number of iterations","PEPSetTolerances",pep->max_it,&i,&flg1);CHKERRQ(ierr); r = pep->tol; ierr = PetscOptionsReal("-pep_tol","Tolerance","PEPSetTolerances",pep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:pep->tol,&r,&flg2);CHKERRQ(ierr); if (flg1 || flg2) { ierr = PEPSetTolerances(pep,r,i);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-pep_conv_rel","Relative error convergence test","PEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetConvergenceTest(pep,PEP_CONV_REL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-pep_conv_norm","Convergence test relative to the matrix norms","PEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetConvergenceTest(pep,PEP_CONV_NORM);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_conv_abs","Absolute error convergence test","PEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetConvergenceTest(pep,PEP_CONV_ABS);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-pep_conv_user","User-defined convergence test","PEPSetConvergenceTest",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetConvergenceTest(pep,PEP_CONV_USER);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupBegin("-pep_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","PEPSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetStoppingTest(pep,PEP_STOP_BASIC);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-pep_stop_user","User-defined stopping test","PEPSetStoppingTest",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetStoppingTest(pep,PEP_STOP_USER);CHKERRQ(ierr); } i = pep->nev; ierr = PetscOptionsInt("-pep_nev","Number of eigenvalues to compute","PEPSetDimensions",pep->nev,&i,&flg1);CHKERRQ(ierr); j = pep->ncv? pep->ncv: PETSC_DEFAULT; ierr = PetscOptionsInt("-pep_ncv","Number of basis vectors","PEPSetDimensions",pep->ncv,&j,&flg2);CHKERRQ(ierr); k = pep->mpd? pep->mpd: PETSC_DEFAULT; ierr = PetscOptionsInt("-pep_mpd","Maximum dimension of projected problem","PEPSetDimensions",pep->mpd,&k,&flg3);CHKERRQ(ierr); if (flg1 || flg2 || flg3) { ierr = PEPSetDimensions(pep,i,j,k);CHKERRQ(ierr); } ierr = PetscOptionsScalar("-pep_target","Value of the target","PEPSetTarget",pep->target,&s,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_TARGET_MAGNITUDE);CHKERRQ(ierr); ierr = PEPSetTarget(pep,s);CHKERRQ(ierr); } ierr = PetscOptionsEnum("-pep_basis","Polynomial basis","PEPSetBasis",PEPBasisTypes,(PetscEnum)pep->basis,(PetscEnum*)&pep->basis,NULL);CHKERRQ(ierr); /* -----------------------------------------------------------------------*/ /* Cancels all monitors hardwired into code before call to PEPSetFromOptions() */ ierr = PetscOptionsBool("-pep_monitor_cancel","Remove any hardwired monitor routines","PEPMonitorCancel",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = PEPMonitorCancel(pep);CHKERRQ(ierr); } /* Text monitors */ ierr = PEPMonitorSetFromOptions(pep,"-pep_monitor","Monitor first unconverged approximate eigenvalue and error estimate","PEPMonitorFirst",PEPMonitorFirst,PETSC_FALSE);CHKERRQ(ierr); ierr = PEPConvMonitorSetFromOptions(pep,"-pep_monitor_conv","Monitor approximate eigenvalues and error estimates as they converge","PEPMonitorConverged",PEPMonitorConverged);CHKERRQ(ierr); ierr = PEPMonitorSetFromOptions(pep,"-pep_monitor_all","Monitor approximate eigenvalues and error estimates","PEPMonitorAll",PEPMonitorAll,PETSC_TRUE);CHKERRQ(ierr); /* Line graph monitors */ ierr = PetscOptionsBool("-pep_monitor_lg","Monitor first unconverged approximate error estimate graphically","PEPMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = PEPMonitorLGCreate(PetscObjectComm((PetscObject)pep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = PEPMonitorSet(pep,PEPMonitorLG,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); } ierr = PetscOptionsBool("-pep_monitor_lg_all","Monitor error estimates graphically","PEPMonitorSet",PETSC_FALSE,&flg,&set);CHKERRQ(ierr); if (set && flg) { ierr = PEPMonitorLGCreate(PetscObjectComm((PetscObject)pep),NULL,"Error estimates",PETSC_DECIDE,PETSC_DECIDE,300,300,&lg);CHKERRQ(ierr); ierr = PEPMonitorSet(pep,PEPMonitorLGAll,lg,(PetscErrorCode (*)(void**))PetscDrawLGDestroy);CHKERRQ(ierr); ierr = PEPSetTrackAll(pep,PETSC_TRUE);CHKERRQ(ierr); } /* -----------------------------------------------------------------------*/ ierr = PetscOptionsBoolGroupBegin("-pep_largest_magnitude","compute largest eigenvalues in magnitude","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_LARGEST_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_smallest_magnitude","compute smallest eigenvalues in magnitude","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_SMALLEST_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_largest_real","compute largest real parts","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_LARGEST_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_smallest_real","compute smallest real parts","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_SMALLEST_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_largest_imaginary","compute largest imaginary parts","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_LARGEST_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_smallest_imaginary","compute smallest imaginary parts","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_SMALLEST_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_target_magnitude","compute nearest eigenvalues to target","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_TARGET_MAGNITUDE);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroup("-pep_target_real","compute eigenvalues with real parts close to target","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_TARGET_REAL);CHKERRQ(ierr); } ierr = PetscOptionsBoolGroupEnd("-pep_target_imaginary","compute eigenvalues with imaginary parts close to target","PEPSetWhichEigenpairs",&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSetWhichEigenpairs(pep,PEP_TARGET_IMAGINARY);CHKERRQ(ierr); } ierr = PetscOptionsName("-pep_view","Print detailed information on solver used","PEPView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-pep_view_vectors","View computed eigenvectors","PEPVectorsView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-pep_view_values","View computed eigenvalues","PEPValuesView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-pep_converged_reason","Print reason for convergence, and number of iterations","PEPReasonView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-pep_error_absolute","Print absolute errors of each eigenpair","PEPErrorView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-pep_error_relative","Print relative errors of each eigenpair","PEPErrorView",NULL);CHKERRQ(ierr); ierr = PetscOptionsName("-pep_error_backward","Print backward errors of each eigenpair","PEPErrorView",NULL);CHKERRQ(ierr); if (pep->ops->setfromoptions) { ierr = (*pep->ops->setfromoptions)(PetscOptionsObject,pep);CHKERRQ(ierr); } ierr = PetscObjectProcessOptionsHandlers(PetscOptionsObject,(PetscObject)pep);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (!pep->V) { ierr = PEPGetBV(pep,&pep->V);CHKERRQ(ierr); } ierr = BVSetFromOptions(pep->V);CHKERRQ(ierr); if (!pep->rg) { ierr = PEPGetRG(pep,&pep->rg);CHKERRQ(ierr); } ierr = RGSetFromOptions(pep->rg);CHKERRQ(ierr); if (!pep->ds) { ierr = PEPGetDS(pep,&pep->ds);CHKERRQ(ierr); } ierr = DSSetFromOptions(pep->ds);CHKERRQ(ierr); if (!pep->st) { ierr = PEPGetST(pep,&pep->st);CHKERRQ(ierr); } ierr = STSetFromOptions(pep->st);CHKERRQ(ierr); if (!pep->refineksp) { ierr = PEPRefineGetKSP(pep,&pep->refineksp);CHKERRQ(ierr); } ierr = KSPSetFromOptions(pep->refineksp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetTolerances" /*@ PEPGetTolerances - Gets the tolerance and maximum iteration count used by the PEP convergence tests. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameters: + tol - the convergence tolerance - maxits - maximum number of iterations Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: PEPSetTolerances() @*/ PetscErrorCode PEPGetTolerances(PEP pep,PetscReal *tol,PetscInt *maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (tol) *tol = pep->tol; if (maxits) *maxits = pep->max_it; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetTolerances" /*@ PEPSetTolerances - Sets the tolerance and maximum iteration count used by the PEP convergence tests. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context . tol - the convergence tolerance - maxits - maximum number of iterations to use Options Database Keys: + -pep_tol - Sets the convergence tolerance - -pep_max_it - Sets the maximum number of iterations allowed Notes: Use PETSC_DEFAULT for either argument to assign a reasonably good value. Level: intermediate .seealso: PEPGetTolerances() @*/ PetscErrorCode PEPSetTolerances(PEP pep,PetscReal tol,PetscInt maxits) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveReal(pep,tol,2); PetscValidLogicalCollectiveInt(pep,maxits,3); if (tol == PETSC_DEFAULT) { pep->tol = PETSC_DEFAULT; pep->state = PEP_STATE_INITIAL; } else { if (tol <= 0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); pep->tol = tol; } if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) { pep->max_it = 0; pep->state = PEP_STATE_INITIAL; } else { if (maxits <= 0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0"); pep->max_it = maxits; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetDimensions" /*@ PEPGetDimensions - Gets the number of eigenvalues to compute and the dimension of the subspace. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameters: + nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Notes: The user can specify NULL for any parameter that is not needed. Level: intermediate .seealso: PEPSetDimensions() @*/ PetscErrorCode PEPGetDimensions(PEP pep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (nev) *nev = pep->nev; if (ncv) *ncv = pep->ncv; if (mpd) *mpd = pep->mpd; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetDimensions" /*@ PEPSetDimensions - Sets the number of eigenvalues to compute and the dimension of the subspace. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context . nev - number of eigenvalues to compute . ncv - the maximum dimension of the subspace to be used by the solver - mpd - the maximum dimension allowed for the projected problem Options Database Keys: + -pep_nev - Sets the number of eigenvalues . -pep_ncv - Sets the dimension of the subspace - -pep_mpd - Sets the maximum projected dimension Notes: Use PETSC_DEFAULT for ncv and mpd to assign a reasonably good value, which is dependent on the solution method. The parameters ncv and mpd are intimately related, so that the user is advised to set one of them at most. Normal usage is that (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and (b) in cases where nev is large, the user sets mpd. The value of ncv should always be between nev and (nev+mpd), typically ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise a smaller value should be used. Level: intermediate .seealso: PEPGetDimensions() @*/ PetscErrorCode PEPSetDimensions(PEP pep,PetscInt nev,PetscInt ncv,PetscInt mpd) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveInt(pep,nev,2); PetscValidLogicalCollectiveInt(pep,ncv,3); PetscValidLogicalCollectiveInt(pep,mpd,4); if (nev<1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0"); pep->nev = nev; if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) { pep->ncv = 0; } else { if (ncv<1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0"); pep->ncv = ncv; } if (mpd == PETSC_DECIDE || mpd == PETSC_DEFAULT) { pep->mpd = 0; } else { if (mpd<1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0"); pep->mpd = mpd; } pep->state = PEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetWhichEigenpairs" /*@ PEPSetWhichEigenpairs - Specifies which portion of the spectrum is to be sought. Logically Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() - which - the portion of the spectrum to be sought Possible values: The parameter 'which' can have one of these values + PEP_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default) . PEP_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude . PEP_LARGEST_REAL - largest real parts . PEP_SMALLEST_REAL - smallest real parts . PEP_LARGEST_IMAGINARY - largest imaginary parts . PEP_SMALLEST_IMAGINARY - smallest imaginary parts . PEP_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude) . PEP_TARGET_REAL - eigenvalues with real part closest to target . PEP_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target - PEP_WHICH_USER - user defined ordering set with PEPSetEigenvalueComparison() Options Database Keys: + -pep_largest_magnitude - Sets largest eigenvalues in magnitude . -pep_smallest_magnitude - Sets smallest eigenvalues in magnitude . -pep_largest_real - Sets largest real parts . -pep_smallest_real - Sets smallest real parts . -pep_largest_imaginary - Sets largest imaginary parts . -pep_smallest_imaginary - Sets smallest imaginary parts . -pep_target_magnitude - Sets eigenvalues closest to target . -pep_target_real - Sets real parts closest to target - -pep_target_imaginary - Sets imaginary parts closest to target Notes: Not all eigensolvers implemented in PEP account for all the possible values stated above. If SLEPc is compiled for real numbers PEP_LARGEST_IMAGINARY and PEP_SMALLEST_IMAGINARY use the absolute value of the imaginary part for eigenvalue selection. The target is a scalar value provided with PEPSetTarget(). The criterion PEP_TARGET_IMAGINARY is available only in case PETSc and SLEPc have been built with complex scalars. Level: intermediate .seealso: PEPGetWhichEigenpairs(), PEPSetTarget(), PEPSetEigenvalueComparison(), PEPWhich @*/ PetscErrorCode PEPSetWhichEigenpairs(PEP pep,PEPWhich which) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,which,2); switch (which) { case PEP_LARGEST_MAGNITUDE: case PEP_SMALLEST_MAGNITUDE: case PEP_LARGEST_REAL: case PEP_SMALLEST_REAL: case PEP_LARGEST_IMAGINARY: case PEP_SMALLEST_IMAGINARY: case PEP_TARGET_MAGNITUDE: case PEP_TARGET_REAL: #if defined(PETSC_USE_COMPLEX) case PEP_TARGET_IMAGINARY: #endif case PEP_WHICH_USER: if (pep->which != which) { pep->state = PEP_STATE_INITIAL; pep->which = which; } break; default: SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetWhichEigenpairs" /*@ PEPGetWhichEigenpairs - Returns which portion of the spectrum is to be sought. Not Collective Input Parameter: . pep - eigensolver context obtained from PEPCreate() Output Parameter: . which - the portion of the spectrum to be sought Notes: See PEPSetWhichEigenpairs() for possible values of 'which'. Level: intermediate .seealso: PEPSetWhichEigenpairs(), PEPWhich @*/ PetscErrorCode PEPGetWhichEigenpairs(PEP pep,PEPWhich *which) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(which,2); *which = pep->which; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetEigenvalueComparison" /*@C PEPSetEigenvalueComparison - Specifies the eigenvalue comparison function when PEPSetWhichEigenpairs() is set to PEP_WHICH_USER. Logically Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() . func - a pointer to the comparison function - ctx - a context pointer (the last parameter to the comparison function) Calling Sequence of func: $ func(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res,void *ctx) + ar - real part of the 1st eigenvalue . ai - imaginary part of the 1st eigenvalue . br - real part of the 2nd eigenvalue . bi - imaginary part of the 2nd eigenvalue . res - result of comparison - ctx - optional context, as set by PEPSetEigenvalueComparison() Note: The returning parameter 'res' can be + negative - if the 1st eigenvalue is preferred to the 2st one . zero - if both eigenvalues are equally preferred - positive - if the 2st eigenvalue is preferred to the 1st one Level: advanced .seealso: PEPSetWhichEigenpairs(), PEPWhich @*/ PetscErrorCode PEPSetEigenvalueComparison(PEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); pep->sc->comparison = func; pep->sc->comparisonctx = ctx; pep->which = PEP_WHICH_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetProblemType" /*@ PEPSetProblemType - Specifies the type of the polynomial eigenvalue problem. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context - type - a known type of polynomial eigenvalue problem Options Database Keys: + -pep_general - general problem with no particular structure . -pep_hermitian - problem whose coefficient matrices are Hermitian - -pep_gyroscopic - problem with Hamiltonian structure Notes: Allowed values for the problem type are: general (PEP_GENERAL), Hermitian (PEP_HERMITIAN), and gyroscopic (PEP_GYROSCOPIC). This function is used to instruct SLEPc to exploit certain structure in the polynomial eigenproblem. By default, no particular structure is assumed. If the problem matrices are Hermitian (symmetric in the real case) or Hermitian/skew-Hermitian then the solver can exploit this fact to perform less operations or provide better stability. Level: intermediate .seealso: PEPSetOperators(), PEPSetType(), PEPGetProblemType(), PEPProblemType @*/ PetscErrorCode PEPSetProblemType(PEP pep,PEPProblemType type) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,type,2); if (type!=PEP_GENERAL && type!=PEP_HERMITIAN && type!=PEP_GYROSCOPIC) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type"); if (type != pep->problem_type) { pep->problem_type = type; pep->state = PEP_STATE_INITIAL; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetProblemType" /*@ PEPGetProblemType - Gets the problem type from the PEP object. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameter: . type - name of PEP problem type Level: intermediate .seealso: PEPSetProblemType(), PEPProblemType @*/ PetscErrorCode PEPGetProblemType(PEP pep,PEPProblemType *type) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(type,2); *type = pep->problem_type; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetBasis" /*@ PEPSetBasis - Specifies the type of polynomial basis used to describe the polynomial eigenvalue problem. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context - basis - the type of polynomial basis Options Database Key: . -pep_basis - Select the basis type Notes: By default, the coefficient matrices passed via PEPSetOperators() are expressed in the monomial basis, i.e. P(lambda) = A_0 + lambda*A_1 + lambda^2*A_2 + ... + lambda^d*A_d. Other polynomial bases may have better numerical behaviour, but the user must then pass the coefficient matrices accordingly. Level: intermediate .seealso: PEPSetOperators(), PEPGetBasis(), PEPBasis @*/ PetscErrorCode PEPSetBasis(PEP pep,PEPBasis basis) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,basis,2); pep->basis = basis; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetBasis" /*@ PEPGetBasis - Gets the type of polynomial basis from the PEP object. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameter: . basis - the polynomial basis Level: intermediate .seealso: PEPSetBasis(), PEPBasis @*/ PetscErrorCode PEPGetBasis(PEP pep,PEPBasis *basis) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(basis,2); *basis = pep->basis; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetTrackAll" /*@ PEPSetTrackAll - Specifies if the solver must compute the residual of all approximate eigenpairs or not. Logically Collective on PEP Input Parameters: + pep - the eigensolver context - trackall - whether compute all residuals or not Notes: If the user sets trackall=PETSC_TRUE then the solver explicitly computes the residual for each eigenpair approximation. Computing the residual is usually an expensive operation and solvers commonly compute the associated residual to the first unconverged eigenpair. The options '-pep_monitor_all' and '-pep_monitor_lg_all' automatically activate this option. Level: developer .seealso: PEPGetTrackAll() @*/ PetscErrorCode PEPSetTrackAll(PEP pep,PetscBool trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveBool(pep,trackall,2); pep->trackall = trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetTrackAll" /*@ PEPGetTrackAll - Returns the flag indicating whether all residual norms must be computed or not. Not Collective Input Parameter: . pep - the eigensolver context Output Parameter: . trackall - the returned flag Level: developer .seealso: PEPSetTrackAll() @*/ PetscErrorCode PEPGetTrackAll(PEP pep,PetscBool *trackall) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(trackall,2); *trackall = pep->trackall; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetConvergenceTestFunction" /*@C PEPSetConvergenceTestFunction - Sets a function to compute the error estimate used in the convergence test. Logically Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() . func - a pointer to the convergence test function . ctx - context for private data for the convergence routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) + pep - eigensolver context obtained from PEPCreate() . eigr - real part of the eigenvalue . eigi - imaginary part of the eigenvalue . res - residual norm associated to the eigenpair . errest - (output) computed error estimate - ctx - optional context, as set by PEPSetConvergenceTestFunction() Note: If the error estimate returned by the convergence test function is less than the tolerance, then the eigenvalue is accepted as converged. Level: advanced .seealso: PEPSetConvergenceTest(), PEPSetTolerances() @*/ PetscErrorCode PEPSetConvergenceTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (pep->convergeddestroy) { ierr = (*pep->convergeddestroy)(pep->convergedctx);CHKERRQ(ierr); } pep->converged = func; pep->convergeddestroy = destroy; pep->convergedctx = ctx; if (func == PEPConvergedRelative) pep->conv = PEP_CONV_REL; else if (func == PEPConvergedNorm) pep->conv = PEP_CONV_NORM; else if (func == PEPConvergedAbsolute) pep->conv = PEP_CONV_ABS; else pep->conv = PEP_CONV_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetConvergenceTest" /*@ PEPSetConvergenceTest - Specifies how to compute the error estimate used in the convergence test. Logically Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() - conv - the type of convergence test Options Database Keys: + -pep_conv_abs - Sets the absolute convergence test . -pep_conv_rel - Sets the convergence test relative to the eigenvalue . -pep_conv_norm - Sets the convergence test relative to the matrix norms - -pep_conv_user - Selects the user-defined convergence test Note: The parameter 'conv' can have one of these values + PEP_CONV_ABS - absolute error ||r|| . PEP_CONV_REL - error relative to the eigenvalue l, ||r||/|l| . PEP_CONV_NORM - error relative matrix norms, ||r||/sum_i(l^i*||A_i||) - PEP_CONV_USER - function set by PEPSetConvergenceTestFunction() Level: intermediate .seealso: PEPGetConvergenceTest(), PEPSetConvergenceTestFunction(), PEPSetStoppingTest(), PEPConv @*/ PetscErrorCode PEPSetConvergenceTest(PEP pep,PEPConv conv) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,conv,2); switch (conv) { case PEP_CONV_ABS: pep->converged = PEPConvergedAbsolute; break; case PEP_CONV_REL: pep->converged = PEPConvergedRelative; break; case PEP_CONV_NORM: pep->converged = PEPConvergedNorm; break; case PEP_CONV_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value"); } pep->conv = conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetConvergenceTest" /*@ PEPGetConvergenceTest - Gets the method used to compute the error estimate used in the convergence test. Not Collective Input Parameters: . pep - eigensolver context obtained from PEPCreate() Output Parameters: . conv - the type of convergence test Level: intermediate .seealso: PEPSetConvergenceTest(), PEPConv @*/ PetscErrorCode PEPGetConvergenceTest(PEP pep,PEPConv *conv) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(conv,2); *conv = pep->conv; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetStoppingTestFunction" /*@C PEPSetStoppingTestFunction - Sets a function to decide when to stop the outer iteration of the eigensolver. Logically Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() . func - pointer to the stopping test function . ctx - context for private data for the stopping routine (may be null) - destroy - a routine for destroying the context (may be null) Calling Sequence of func: $ func(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx) + pep - eigensolver context obtained from PEPCreate() . its - current number of iterations . max_it - maximum number of iterations . nconv - number of currently converged eigenpairs . nev - number of requested eigenpairs . reason - (output) result of the stopping test - ctx - optional context, as set by PEPSetStoppingTestFunction() Note: Normal usage is to first call the default routine PEPStoppingBasic() and then set reason to PEP_CONVERGED_USER if some user-defined conditions have been met. To let the eigensolver continue iterating, the result must be left as PEP_CONVERGED_ITERATING. Level: advanced .seealso: PEPSetStoppingTest(), PEPStoppingBasic() @*/ PetscErrorCode PEPSetStoppingTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*)) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (pep->stoppingdestroy) { ierr = (*pep->stoppingdestroy)(pep->stoppingctx);CHKERRQ(ierr); } pep->stopping = func; pep->stoppingdestroy = destroy; pep->stoppingctx = ctx; if (func == PEPStoppingBasic) pep->stop = PEP_STOP_BASIC; else pep->stop = PEP_STOP_USER; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetStoppingTest" /*@ PEPSetStoppingTest - Specifies how to decide the termination of the outer loop of the eigensolver. Logically Collective on PEP Input Parameters: + pep - eigensolver context obtained from PEPCreate() - stop - the type of stopping test Options Database Keys: + -pep_stop_basic - Sets the default stopping test - -pep_stop_user - Selects the user-defined stopping test Note: The parameter 'stop' can have one of these values + PEP_STOP_BASIC - default stopping test - PEP_STOP_USER - function set by PEPSetStoppingTestFunction() Level: advanced .seealso: PEPGetStoppingTest(), PEPSetStoppingTestFunction(), PEPSetConvergenceTest(), PEPStop @*/ PetscErrorCode PEPSetStoppingTest(PEP pep,PEPStop stop) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,stop,2); switch (stop) { case PEP_STOP_BASIC: pep->stopping = PEPStoppingBasic; break; case PEP_STOP_USER: break; default: SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value"); } pep->stop = stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetStoppingTest" /*@ PEPGetStoppingTest - Gets the method used to decide the termination of the outer loop of the eigensolver. Not Collective Input Parameters: . pep - eigensolver context obtained from PEPCreate() Output Parameters: . stop - the type of stopping test Level: advanced .seealso: PEPSetStoppingTest(), PEPStop @*/ PetscErrorCode PEPGetStoppingTest(PEP pep,PEPStop *stop) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(stop,2); *stop = pep->stop; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetScale" /*@ PEPSetScale - Specifies the scaling strategy to be used. Logically Collective on PEP Input Parameters: + pep - the eigensolver context . scale - scaling strategy . alpha - the scaling factor used in the scalar strategy . Dl - the left diagonal matrix of the diagonal scaling algorithm . Dr - the right diagonal matrix of the diagonal scaling algorithm . its - number of iterations of the diagonal scaling algorithm - lambda - approximation to wanted eigenvalues (modulus) Options Database Keys: + -pep_scale - scaling type, one of . -pep_scale_factor - the scaling factor . -pep_scale_its - number of iterations - -pep_scale_lambda - approximation to eigenvalues Notes: There are two non-exclusive scaling strategies: scalar and diagonal. In the scalar strategy, scaling is applied to the eigenvalue, that is, mu = lambda/alpha is the new eigenvalue and all matrices are scaled accordingly. After solving the scaled problem, the original lambda is recovered. Parameter 'alpha' must be positive. Use PETSC_DECIDE to let the solver compute a reasonable scaling factor. In the diagonal strategy, the solver works implicitly with matrix Dl*A*Dr, where Dl and Dr are appropriate diagonal matrices. This improves the accuracy of the computed results in some cases. The user may provide the Dr and Dl matrices represented as Vec objects storing diagonal elements. If not provided, these matrices are computed internally. This option requires that the polynomial coefficient matrices are of MATAIJ type. The parameter 'its' is the number of iterations performed by the method. Parameter 'lambda' must be positive. Use PETSC_DECIDE or set lambda = 1.0 if no information about eigenvalues is available. Level: intermediate .seealso: PEPGetScale() @*/ PetscErrorCode PEPSetScale(PEP pep,PEPScale scale,PetscReal alpha,Vec Dl,Vec Dr,PetscInt its,PetscReal lambda) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,scale,2); pep->scale = scale; if (scale==PEP_SCALE_SCALAR || scale==PEP_SCALE_BOTH) { PetscValidLogicalCollectiveReal(pep,alpha,3); if (alpha == PETSC_DEFAULT || alpha == PETSC_DECIDE) { pep->sfactor = 0.0; pep->sfactor_set = PETSC_FALSE; } else { if (alpha<=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of alpha. Must be > 0"); pep->sfactor = alpha; pep->sfactor_set = PETSC_TRUE; } } if (scale==PEP_SCALE_DIAGONAL || scale==PEP_SCALE_BOTH) { if (Dl) { PetscValidHeaderSpecific(Dl,VEC_CLASSID,4); PetscCheckSameComm(pep,1,Dl,4); ierr = PetscObjectReference((PetscObject)Dl);CHKERRQ(ierr); ierr = VecDestroy(&pep->Dl);CHKERRQ(ierr); pep->Dl = Dl; } if (Dr) { PetscValidHeaderSpecific(Dr,VEC_CLASSID,5); PetscCheckSameComm(pep,1,Dr,5); ierr = PetscObjectReference((PetscObject)Dr);CHKERRQ(ierr); ierr = VecDestroy(&pep->Dr);CHKERRQ(ierr); pep->Dr = Dr; } PetscValidLogicalCollectiveInt(pep,its,6); PetscValidLogicalCollectiveReal(pep,lambda,7); if (its==PETSC_DECIDE || its==PETSC_DEFAULT) pep->sits = 5; else pep->sits = its; if (lambda==PETSC_DECIDE || lambda==PETSC_DEFAULT) pep->slambda = 1.0; else if (lambda<=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of lambda. Must be > 0"); else pep->slambda = lambda; } pep->state = PEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetScale" /*@ PEPGetScale - Gets the scaling strategy used by the PEP object, and the associated parameters. Not Collectiv, but vectors are shared by all processors that share the PEP Input Parameter: . pep - the eigensolver context Output Parameters: + scale - scaling strategy . alpha - the scaling factor used in the scalar strategy . Dl - the left diagonal matrix of the diagonal scaling algorithm . Dr - the right diagonal matrix of the diagonal scaling algorithm . its - number of iterations of the diagonal scaling algorithm - lambda - approximation to wanted eigenvalues (modulus) Level: intermediate Note: The user can specify NULL for any parameter that is not needed. If Dl or Dr were not set by the user, then the ones computed internally are returned (or a null pointer if called before PEPSetUp). .seealso: PEPSetScale(), PEPSetUp() @*/ PetscErrorCode PEPGetScale(PEP pep,PEPScale *scale,PetscReal *alpha,Vec *Dl,Vec *Dr,PetscInt *its,PetscReal *lambda) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (scale) *scale = pep->scale; if (alpha) *alpha = pep->sfactor; if (Dl) *Dl = pep->Dl; if (Dr) *Dr = pep->Dr; if (its) *its = pep->sits; if (lambda) *lambda = pep->slambda; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetExtract" /*@ PEPSetExtract - Specifies the extraction strategy to be used. Logically Collective on PEP Input Parameters: + pep - the eigensolver context - extract - extraction strategy Options Database Keys: . -pep_extract - extraction type, one of Level: intermediate .seealso: PEPGetExtract() @*/ PetscErrorCode PEPSetExtract(PEP pep,PEPExtract extract) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,extract,2); pep->extract = extract; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetExtract" /*@ PEPGetExtract - Gets the extraction strategy used by the PEP object. Not Collective Input Parameter: . pep - the eigensolver context Output Parameter: . extract - extraction strategy Level: intermediate .seealso: PEPSetExtract() @*/ PetscErrorCode PEPGetExtract(PEP pep,PEPExtract *extract) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (extract) *extract = pep->extract; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetRefine" /*@ PEPSetRefine - Specifies the refinement type (and options) to be used after the solve. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context . refine - refinement type . npart - number of partitions of the communicator . tol - the convergence tolerance . its - maximum number of refinement iterations - scheme - which scheme to be used for solving the involved linear systems Options Database Keys: + -pep_refine - refinement type, one of . -pep_refine_partitions - the number of partitions . -pep_refine_tol - the tolerance . -pep_refine_its - number of iterations - -pep_refine_scheme - to set the scheme for the linear solves Notes: By default, iterative refinement is disabled, since it may be very costly. There are two possible refinement strategies: simple and multiple. The simple approach performs iterative refinement on each of the converged eigenpairs individually, whereas the multiple strategy works with the invariant pair as a whole, refining all eigenpairs simultaneously. The latter may be required for the case of multiple eigenvalues. In some cases, especially when using direct solvers within the iterative refinement method, it may be helpful for improved scalability to split the communicator in several partitions. The npart parameter indicates how many partitions to use (defaults to 1). The tol and its parameters specify the stopping criterion. In the simple method, refinement continues until the residual of each eigenpair is below the tolerance (tol defaults to the PEP tol, but may be set to a different value). In contrast, the multiple method simply performs its refinement iterations (just one by default). The scheme argument is used to change the way in which linear systems are solved. Possible choices are: explicit, mixed block elimination (MBE), and Schur complement. Level: intermediate .seealso: PEPGetRefine() @*/ PetscErrorCode PEPSetRefine(PEP pep,PEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,PEPRefineScheme scheme) { PetscErrorCode ierr; PetscMPIInt size; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveEnum(pep,refine,2); PetscValidLogicalCollectiveInt(pep,npart,3); PetscValidLogicalCollectiveReal(pep,tol,4); PetscValidLogicalCollectiveInt(pep,its,5); PetscValidLogicalCollectiveEnum(pep,scheme,6); pep->refine = refine; if (refine) { /* process parameters only if not REFINE_NONE */ if (npart!=pep->npart) { ierr = PetscSubcommDestroy(&pep->refinesubc);CHKERRQ(ierr); ierr = KSPDestroy(&pep->refineksp);CHKERRQ(ierr); } if (npart == PETSC_DEFAULT || npart == PETSC_DECIDE) { pep->npart = 1; } else { ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pep),&size);CHKERRQ(ierr); if (npart<1 || npart>size) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of npart"); pep->npart = npart; } if (tol == PETSC_DEFAULT || tol == PETSC_DECIDE) { pep->rtol = PetscMax(pep->tol/1000,PETSC_MACHINE_EPSILON); } else { if (tol<=0.0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0"); pep->rtol = tol; } if (its==PETSC_DECIDE || its==PETSC_DEFAULT) { pep->rits = PETSC_DEFAULT; } else { if (its<0) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be >= 0"); pep->rits = its; } pep->scheme = scheme; } pep->state = PEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetRefine" /*@ PEPGetRefine - Gets the refinement strategy used by the PEP object, and the associated parameters. Not Collective Input Parameter: . pep - the polynomial eigensolver context Output Parameters: + refine - refinement type . npart - number of partitions of the communicator . tol - the convergence tolerance . its - maximum number of refinement iterations - scheme - the scheme used for solving linear systems Level: intermediate Note: The user can specify NULL for any parameter that is not needed. .seealso: PEPSetRefine() @*/ PetscErrorCode PEPGetRefine(PEP pep,PEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,PEPRefineScheme *scheme) { PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (refine) *refine = pep->refine; if (npart) *npart = pep->npart; if (tol) *tol = pep->rtol; if (its) *its = pep->rits; if (scheme) *scheme = pep->scheme; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetOptionsPrefix" /*@C PEPSetOptionsPrefix - Sets the prefix used for searching for all PEP options in the database. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context - prefix - the prefix string to prepend to all PEP option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. For example, to distinguish between the runtime options for two different PEP contexts, one could call .vb PEPSetOptionsPrefix(pep1,"qeig1_") PEPSetOptionsPrefix(pep2,"qeig2_") .ve Level: advanced .seealso: PEPAppendOptionsPrefix(), PEPGetOptionsPrefix() @*/ PetscErrorCode PEPSetOptionsPrefix(PEP pep,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (!pep->st) { ierr = PEPGetST(pep,&pep->st);CHKERRQ(ierr); } ierr = STSetOptionsPrefix(pep->st,prefix);CHKERRQ(ierr); if (!pep->V) { ierr = PEPGetBV(pep,&pep->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(pep->V,prefix);CHKERRQ(ierr); if (!pep->ds) { ierr = PEPGetDS(pep,&pep->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(pep->ds,prefix);CHKERRQ(ierr); if (!pep->rg) { ierr = PEPGetRG(pep,&pep->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(pep->rg,prefix);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)pep,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPAppendOptionsPrefix" /*@C PEPAppendOptionsPrefix - Appends to the prefix used for searching for all PEP options in the database. Logically Collective on PEP Input Parameters: + pep - the polynomial eigensolver context - prefix - the prefix string to prepend to all PEP option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: PEPSetOptionsPrefix(), PEPGetOptionsPrefix() @*/ PetscErrorCode PEPAppendOptionsPrefix(PEP pep,const char *prefix) { PetscErrorCode ierr; PetscBool flg; EPS eps; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (!pep->st) { ierr = PEPGetST(pep,&pep->st);CHKERRQ(ierr); } ierr = STAppendOptionsPrefix(pep->st,prefix);CHKERRQ(ierr); if (!pep->V) { ierr = PEPGetBV(pep,&pep->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(pep->V,prefix);CHKERRQ(ierr); if (!pep->ds) { ierr = PEPGetDS(pep,&pep->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(pep->ds,prefix);CHKERRQ(ierr); if (!pep->rg) { ierr = PEPGetRG(pep,&pep->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(pep->rg,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)pep,prefix);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pep,PEPLINEAR,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPLinearGetEPS(pep,&eps);CHKERRQ(ierr); ierr = EPSSetOptionsPrefix(eps,((PetscObject)pep)->prefix);CHKERRQ(ierr); ierr = EPSAppendOptionsPrefix(eps,"pep_");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPGetOptionsPrefix" /*@C PEPGetOptionsPrefix - Gets the prefix used for searching for all PEP options in the database. Not Collective Input Parameters: . pep - the polynomial eigensolver context Output Parameters: . prefix - pointer to the prefix string used is returned Note: On the Fortran side, the user should pass in a string 'prefix' of sufficient length to hold the prefix. Level: advanced .seealso: PEPSetOptionsPrefix(), PEPAppendOptionsPrefix() @*/ PetscErrorCode PEPGetOptionsPrefix(PEP pep,const char *prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(prefix,2); ierr = PetscObjectGetOptionsPrefix((PetscObject)pep,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/ftn-auto/0000755000175000017500000000000013107004621017233 5ustar jromanjromanslepc-3.7.4/src/pep/interface/ftn-auto/makefile0000644000175000017500000000046613107004621020741 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = pepdefaultf.c pepmonf.c pepsetupf.c pepsolvef.c pepoptsf.c pepviewf.c pepbasicf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcpep LOCDIR = src/pep/interface/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/interface/ftn-auto/pepdefaultf.c0000644000175000017500000000207613107004621021703 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pepdefault.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetworkvecs_ PEPSETWORKVECS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetworkvecs_ pepsetworkvecs #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepsetworkvecs_(PEP pep,PetscInt *nw, int *__ierr ){ *__ierr = PEPSetWorkVecs( (PEP)PetscToPointer((pep) ),*nw); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/interface/ftn-auto/pepmonf.c0000644000175000017500000000206513107004621021046 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pepmon.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepmonitorcancel_ PEPMONITORCANCEL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepmonitorcancel_ pepmonitorcancel #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepmonitorcancel_(PEP pep, int *__ierr ){ *__ierr = PEPMonitorCancel( (PEP)PetscToPointer((pep) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/interface/ftn-auto/pepsetupf.c0000644000175000017500000000551613107004621021421 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pepsetup.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetup_ PEPSETUP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetup_ pepsetup #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetoperators_ PEPSETOPERATORS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetoperators_ pepsetoperators #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetoperators_ PEPGETOPERATORS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetoperators_ pepgetoperators #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetnummatrices_ PEPGETNUMMATRICES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetnummatrices_ pepgetnummatrices #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetinitialspace_ PEPSETINITIALSPACE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetinitialspace_ pepsetinitialspace #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepallocatesolution_ PEPALLOCATESOLUTION #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepallocatesolution_ pepallocatesolution #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepsetup_(PEP pep, int *__ierr ){ *__ierr = PEPSetUp( (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL pepsetoperators_(PEP pep,PetscInt *nmat,Mat A[], int *__ierr ){ *__ierr = PEPSetOperators( (PEP)PetscToPointer((pep) ),*nmat,A); } PETSC_EXTERN void PETSC_STDCALL pepgetoperators_(PEP pep,PetscInt *k,Mat *A, int *__ierr ){ *__ierr = PEPGetOperators( (PEP)PetscToPointer((pep) ),*k,A); } PETSC_EXTERN void PETSC_STDCALL pepgetnummatrices_(PEP pep,PetscInt *nmat, int *__ierr ){ *__ierr = PEPGetNumMatrices( (PEP)PetscToPointer((pep) ),nmat); } PETSC_EXTERN void PETSC_STDCALL pepsetinitialspace_(PEP pep,PetscInt *n,Vec *is, int *__ierr ){ *__ierr = PEPSetInitialSpace( (PEP)PetscToPointer((pep) ),*n,is); } PETSC_EXTERN void PETSC_STDCALL pepallocatesolution_(PEP pep,PetscInt *extra, int *__ierr ){ *__ierr = PEPAllocateSolution( (PEP)PetscToPointer((pep) ),*extra); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/interface/ftn-auto/pepsolvef.c0000644000175000017500000000660313107004621021407 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pepsolve.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsolve_ PEPSOLVE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsolve_ pepsolve #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetiterationnumber_ PEPGETITERATIONNUMBER #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetiterationnumber_ pepgetiterationnumber #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetconverged_ PEPGETCONVERGED #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetconverged_ pepgetconverged #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetconvergedreason_ PEPGETCONVERGEDREASON #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetconvergedreason_ pepgetconvergedreason #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgeteigenpair_ PEPGETEIGENPAIR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgeteigenpair_ pepgeteigenpair #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgeterrorestimate_ PEPGETERRORESTIMATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgeterrorestimate_ pepgeterrorestimate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepcomputeerror_ PEPCOMPUTEERROR #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepcomputeerror_ pepcomputeerror #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepsolve_(PEP pep, int *__ierr ){ *__ierr = PEPSolve( (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL pepgetiterationnumber_(PEP pep,PetscInt *its, int *__ierr ){ *__ierr = PEPGetIterationNumber( (PEP)PetscToPointer((pep) ),its); } PETSC_EXTERN void PETSC_STDCALL pepgetconverged_(PEP pep,PetscInt *nconv, int *__ierr ){ *__ierr = PEPGetConverged( (PEP)PetscToPointer((pep) ),nconv); } PETSC_EXTERN void PETSC_STDCALL pepgetconvergedreason_(PEP pep,PEPConvergedReason *reason, int *__ierr ){ *__ierr = PEPGetConvergedReason( (PEP)PetscToPointer((pep) ),reason); } PETSC_EXTERN void PETSC_STDCALL pepgeteigenpair_(PEP pep,PetscInt *i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi, int *__ierr ){ *__ierr = PEPGetEigenpair( (PEP)PetscToPointer((pep) ),*i,eigr,eigi, (Vec)PetscToPointer((Vr) ), (Vec)PetscToPointer((Vi) )); } PETSC_EXTERN void PETSC_STDCALL pepgeterrorestimate_(PEP pep,PetscInt *i,PetscReal *errest, int *__ierr ){ *__ierr = PEPGetErrorEstimate( (PEP)PetscToPointer((pep) ),*i,errest); } PETSC_EXTERN void PETSC_STDCALL pepcomputeerror_(PEP pep,PetscInt *i,PEPErrorType *type,PetscReal *error, int *__ierr ){ *__ierr = PEPComputeError( (PEP)PetscToPointer((pep) ),*i,*type,error); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/interface/ftn-auto/pepoptsf.c0000644000175000017500000002260313107004621021242 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pepopts.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetfromoptions_ PEPSETFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetfromoptions_ pepsetfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgettolerances_ PEPGETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgettolerances_ pepgettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsettolerances_ PEPSETTOLERANCES #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsettolerances_ pepsettolerances #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetdimensions_ PEPGETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetdimensions_ pepgetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetdimensions_ PEPSETDIMENSIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetdimensions_ pepsetdimensions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetwhicheigenpairs_ PEPSETWHICHEIGENPAIRS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetwhicheigenpairs_ pepsetwhicheigenpairs #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetwhicheigenpairs_ PEPGETWHICHEIGENPAIRS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetwhicheigenpairs_ pepgetwhicheigenpairs #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetproblemtype_ PEPSETPROBLEMTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetproblemtype_ pepsetproblemtype #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetproblemtype_ PEPGETPROBLEMTYPE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetproblemtype_ pepgetproblemtype #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetbasis_ PEPSETBASIS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetbasis_ pepsetbasis #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetbasis_ PEPGETBASIS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetbasis_ pepgetbasis #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsettrackall_ PEPSETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsettrackall_ pepsettrackall #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgettrackall_ PEPGETTRACKALL #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgettrackall_ pepgettrackall #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetconvergencetest_ PEPSETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetconvergencetest_ pepsetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetconvergencetest_ PEPGETCONVERGENCETEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetconvergencetest_ pepgetconvergencetest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetstoppingtest_ PEPSETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetstoppingtest_ pepsetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetstoppingtest_ PEPGETSTOPPINGTEST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetstoppingtest_ pepgetstoppingtest #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetscale_ PEPSETSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetscale_ pepsetscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetscale_ PEPGETSCALE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetscale_ pepgetscale #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetextract_ PEPSETEXTRACT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetextract_ pepsetextract #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetextract_ PEPGETEXTRACT #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetextract_ pepgetextract #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetrefine_ PEPSETREFINE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetrefine_ pepsetrefine #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetrefine_ PEPGETREFINE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetrefine_ pepgetrefine #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepsetfromoptions_(PEP pep, int *__ierr ){ *__ierr = PEPSetFromOptions( (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL pepgettolerances_(PEP pep,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = PEPGetTolerances( (PEP)PetscToPointer((pep) ),tol,maxits); } PETSC_EXTERN void PETSC_STDCALL pepsettolerances_(PEP pep,PetscReal *tol,PetscInt *maxits, int *__ierr ){ *__ierr = PEPSetTolerances( (PEP)PetscToPointer((pep) ),*tol,*maxits); } PETSC_EXTERN void PETSC_STDCALL pepgetdimensions_(PEP pep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = PEPGetDimensions( (PEP)PetscToPointer((pep) ),nev,ncv,mpd); } PETSC_EXTERN void PETSC_STDCALL pepsetdimensions_(PEP pep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd, int *__ierr ){ *__ierr = PEPSetDimensions( (PEP)PetscToPointer((pep) ),*nev,*ncv,*mpd); } PETSC_EXTERN void PETSC_STDCALL pepsetwhicheigenpairs_(PEP pep,PEPWhich *which, int *__ierr ){ *__ierr = PEPSetWhichEigenpairs( (PEP)PetscToPointer((pep) ),*which); } PETSC_EXTERN void PETSC_STDCALL pepgetwhicheigenpairs_(PEP pep,PEPWhich *which, int *__ierr ){ *__ierr = PEPGetWhichEigenpairs( (PEP)PetscToPointer((pep) ),which); } PETSC_EXTERN void PETSC_STDCALL pepsetproblemtype_(PEP pep,PEPProblemType *type, int *__ierr ){ *__ierr = PEPSetProblemType( (PEP)PetscToPointer((pep) ),*type); } PETSC_EXTERN void PETSC_STDCALL pepgetproblemtype_(PEP pep,PEPProblemType *type, int *__ierr ){ *__ierr = PEPGetProblemType( (PEP)PetscToPointer((pep) ),type); } PETSC_EXTERN void PETSC_STDCALL pepsetbasis_(PEP pep,PEPBasis *basis, int *__ierr ){ *__ierr = PEPSetBasis( (PEP)PetscToPointer((pep) ),*basis); } PETSC_EXTERN void PETSC_STDCALL pepgetbasis_(PEP pep,PEPBasis *basis, int *__ierr ){ *__ierr = PEPGetBasis( (PEP)PetscToPointer((pep) ),basis); } PETSC_EXTERN void PETSC_STDCALL pepsettrackall_(PEP pep,PetscBool *trackall, int *__ierr ){ *__ierr = PEPSetTrackAll( (PEP)PetscToPointer((pep) ),*trackall); } PETSC_EXTERN void PETSC_STDCALL pepgettrackall_(PEP pep,PetscBool *trackall, int *__ierr ){ *__ierr = PEPGetTrackAll( (PEP)PetscToPointer((pep) ),trackall); } PETSC_EXTERN void PETSC_STDCALL pepsetconvergencetest_(PEP pep,PEPConv *conv, int *__ierr ){ *__ierr = PEPSetConvergenceTest( (PEP)PetscToPointer((pep) ),*conv); } PETSC_EXTERN void PETSC_STDCALL pepgetconvergencetest_(PEP pep,PEPConv *conv, int *__ierr ){ *__ierr = PEPGetConvergenceTest( (PEP)PetscToPointer((pep) ),conv); } PETSC_EXTERN void PETSC_STDCALL pepsetstoppingtest_(PEP pep,PEPStop *stop, int *__ierr ){ *__ierr = PEPSetStoppingTest( (PEP)PetscToPointer((pep) ),*stop); } PETSC_EXTERN void PETSC_STDCALL pepgetstoppingtest_(PEP pep,PEPStop *stop, int *__ierr ){ *__ierr = PEPGetStoppingTest( (PEP)PetscToPointer((pep) ),stop); } PETSC_EXTERN void PETSC_STDCALL pepsetscale_(PEP pep,PEPScale *scale,PetscReal *alpha,Vec Dl,Vec Dr,PetscInt *its,PetscReal *lambda, int *__ierr ){ *__ierr = PEPSetScale( (PEP)PetscToPointer((pep) ),*scale,*alpha, (Vec)PetscToPointer((Dl) ), (Vec)PetscToPointer((Dr) ),*its,*lambda); } PETSC_EXTERN void PETSC_STDCALL pepgetscale_(PEP pep,PEPScale *scale,PetscReal *alpha,Vec *Dl,Vec *Dr,PetscInt *its,PetscReal *lambda, int *__ierr ){ *__ierr = PEPGetScale( (PEP)PetscToPointer((pep) ),scale,alpha,Dl,Dr,its,lambda); } PETSC_EXTERN void PETSC_STDCALL pepsetextract_(PEP pep,PEPExtract *extract, int *__ierr ){ *__ierr = PEPSetExtract( (PEP)PetscToPointer((pep) ),*extract); } PETSC_EXTERN void PETSC_STDCALL pepgetextract_(PEP pep,PEPExtract *extract, int *__ierr ){ *__ierr = PEPGetExtract( (PEP)PetscToPointer((pep) ),extract); } PETSC_EXTERN void PETSC_STDCALL pepsetrefine_(PEP pep,PEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,PEPRefineScheme *scheme, int *__ierr ){ *__ierr = PEPSetRefine( (PEP)PetscToPointer((pep) ),*refine,*npart,*tol,*its,*scheme); } PETSC_EXTERN void PETSC_STDCALL pepgetrefine_(PEP pep,PEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,PEPRefineScheme *scheme, int *__ierr ){ *__ierr = PEPGetRefine( (PEP)PetscToPointer((pep) ),refine,npart,tol,its,scheme); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/interface/ftn-auto/pepviewf.c0000644000175000017500000000437313107004621021233 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pepview.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepreasonviewfromoptions_ PEPREASONVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepreasonviewfromoptions_ pepreasonviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peperrorviewfromoptions_ PEPERRORVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peperrorviewfromoptions_ peperrorviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepvaluesviewfromoptions_ PEPVALUESVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepvaluesviewfromoptions_ pepvaluesviewfromoptions #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepvectorsviewfromoptions_ PEPVECTORSVIEWFROMOPTIONS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepvectorsviewfromoptions_ pepvectorsviewfromoptions #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepreasonviewfromoptions_(PEP pep, int *__ierr ){ *__ierr = PEPReasonViewFromOptions( (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL peperrorviewfromoptions_(PEP pep, int *__ierr ){ *__ierr = PEPErrorViewFromOptions( (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL pepvaluesviewfromoptions_(PEP pep, int *__ierr ){ *__ierr = PEPValuesViewFromOptions( (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL pepvectorsviewfromoptions_(PEP pep, int *__ierr ){ *__ierr = PEPVectorsViewFromOptions( (PEP)PetscToPointer((pep) )); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/interface/ftn-auto/pepbasicf.c0000644000175000017500000001213613107004621021336 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pepbasic.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepcreate_ PEPCREATE #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepcreate_ pepcreate #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepreset_ PEPRESET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepreset_ pepreset #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepdestroy_ PEPDESTROY #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepdestroy_ pepdestroy #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetbv_ PEPSETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetbv_ pepsetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetbv_ PEPGETBV #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetbv_ pepgetbv #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetrg_ PEPSETRG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetrg_ pepsetrg #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetrg_ PEPGETRG #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetrg_ pepgetrg #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetds_ PEPSETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetds_ pepsetds #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetds_ PEPGETDS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetds_ pepgetds #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsetst_ PEPSETST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsetst_ pepsetst #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgetst_ PEPGETST #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgetst_ pepgetst #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peprefinegetksp_ PEPREFINEGETKSP #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peprefinegetksp_ peprefinegetksp #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepsettarget_ PEPSETTARGET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepsettarget_ pepsettarget #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepgettarget_ PEPGETTARGET #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepgettarget_ pepgettarget #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepcreate_(MPI_Fint * comm,PEP *outpep, int *__ierr ){ *__ierr = PEPCreate( MPI_Comm_f2c(*(comm)),outpep); } PETSC_EXTERN void PETSC_STDCALL pepreset_(PEP pep, int *__ierr ){ *__ierr = PEPReset( (PEP)PetscToPointer((pep) )); } PETSC_EXTERN void PETSC_STDCALL pepdestroy_(PEP *pep, int *__ierr ){ *__ierr = PEPDestroy(pep); } PETSC_EXTERN void PETSC_STDCALL pepsetbv_(PEP pep,BV bv, int *__ierr ){ *__ierr = PEPSetBV( (PEP)PetscToPointer((pep) ), (BV)PetscToPointer((bv) )); } PETSC_EXTERN void PETSC_STDCALL pepgetbv_(PEP pep,BV *bv, int *__ierr ){ *__ierr = PEPGetBV( (PEP)PetscToPointer((pep) ),bv); } PETSC_EXTERN void PETSC_STDCALL pepsetrg_(PEP pep,RG rg, int *__ierr ){ *__ierr = PEPSetRG( (PEP)PetscToPointer((pep) ), (RG)PetscToPointer((rg) )); } PETSC_EXTERN void PETSC_STDCALL pepgetrg_(PEP pep,RG *rg, int *__ierr ){ *__ierr = PEPGetRG( (PEP)PetscToPointer((pep) ),rg); } PETSC_EXTERN void PETSC_STDCALL pepsetds_(PEP pep,DS ds, int *__ierr ){ *__ierr = PEPSetDS( (PEP)PetscToPointer((pep) ), (DS)PetscToPointer((ds) )); } PETSC_EXTERN void PETSC_STDCALL pepgetds_(PEP pep,DS *ds, int *__ierr ){ *__ierr = PEPGetDS( (PEP)PetscToPointer((pep) ),ds); } PETSC_EXTERN void PETSC_STDCALL pepsetst_(PEP pep,ST st, int *__ierr ){ *__ierr = PEPSetST( (PEP)PetscToPointer((pep) ), (ST)PetscToPointer((st) )); } PETSC_EXTERN void PETSC_STDCALL pepgetst_(PEP pep,ST *st, int *__ierr ){ *__ierr = PEPGetST( (PEP)PetscToPointer((pep) ),st); } PETSC_EXTERN void PETSC_STDCALL peprefinegetksp_(PEP pep,KSP *ksp, int *__ierr ){ *__ierr = PEPRefineGetKSP( (PEP)PetscToPointer((pep) ),ksp); } PETSC_EXTERN void PETSC_STDCALL pepsettarget_(PEP pep,PetscScalar *target, int *__ierr ){ *__ierr = PEPSetTarget( (PEP)PetscToPointer((pep) ),*target); } PETSC_EXTERN void PETSC_STDCALL pepgettarget_(PEP pep,PetscScalar* target, int *__ierr ){ *__ierr = PEPGetTarget( (PEP)PetscToPointer((pep) ),target); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/interface/pepregis.c0000644000175000017500000000362513107004621017466 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ PETSC_EXTERN PetscErrorCode PEPCreate_Linear(PEP); PETSC_EXTERN PetscErrorCode PEPCreate_QArnoldi(PEP); PETSC_EXTERN PetscErrorCode PEPCreate_TOAR(PEP); PETSC_EXTERN PetscErrorCode PEPCreate_STOAR(PEP); PETSC_EXTERN PetscErrorCode PEPCreate_JD(PEP); #undef __FUNCT__ #define __FUNCT__ "PEPRegisterAll" /*@C PEPRegisterAll - Registers all the solvers in the PEP package. Not Collective Level: advanced .seealso: PEPRegister() @*/ PetscErrorCode PEPRegisterAll(void) { PetscErrorCode ierr; PetscFunctionBegin; if (PEPRegisterAllCalled) PetscFunctionReturn(0); PEPRegisterAllCalled = PETSC_TRUE; ierr = PEPRegister(PEPLINEAR,PEPCreate_Linear);CHKERRQ(ierr); ierr = PEPRegister(PEPQARNOLDI,PEPCreate_QArnoldi);CHKERRQ(ierr); ierr = PEPRegister(PEPTOAR,PEPCreate_TOAR);CHKERRQ(ierr); ierr = PEPRegister(PEPSTOAR,PEPCreate_STOAR);CHKERRQ(ierr); ierr = PEPRegister(PEPJD,PEPCreate_JD);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/pepview.c0000644000175000017500000006757513107004621017345 0ustar jromanjroman/* The PEP routines related to various viewers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include #undef __FUNCT__ #define __FUNCT__ "PEPView" /*@C PEPView - Prints the PEP data structure. Collective on PEP Input Parameters: + pep - the polynomial eigenproblem solver context - viewer - optional visualization context Options Database Key: . -pep_view - Calls PEPView() at end of PEPSolve() Note: The available visualization contexts include + PETSC_VIEWER_STDOUT_SELF - standard output (default) - PETSC_VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with PetscViewerASCIIOpen() - output to a specified file. Level: beginner .seealso: PetscViewerASCIIOpen() @*/ PetscErrorCode PEPView(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; const char *type; char str[50]; PetscBool isascii,islinear,istrivial; PetscInt i; PetscViewer sviewer; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(pep,1,viewer,2); #if defined(PETSC_USE_COMPLEX) #define HERM "hermitian" #else #define HERM "symmetric" #endif ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscObjectPrintClassNamePrefixType((PetscObject)pep,viewer);CHKERRQ(ierr); if (pep->ops->view) { ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = (*pep->ops->view)(pep,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } if (pep->problem_type) { switch (pep->problem_type) { case PEP_GENERAL: type = "general polynomial eigenvalue problem"; break; case PEP_HERMITIAN: type = HERM " polynomial eigenvalue problem"; break; case PEP_GYROSCOPIC: type = "gyroscopic polynomial eigenvalue problem"; break; default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of pep->problem_type"); } } else type = "not yet set"; ierr = PetscViewerASCIIPrintf(viewer," problem type: %s\n",type);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," polynomial represented in %s basis\n",PEPBasisTypes[pep->basis]);CHKERRQ(ierr); switch (pep->scale) { case PEP_SCALE_NONE: break; case PEP_SCALE_SCALAR: ierr = PetscViewerASCIIPrintf(viewer," parameter scaling enabled, with scaling factor=%g\n",(double)pep->sfactor);CHKERRQ(ierr); break; case PEP_SCALE_DIAGONAL: ierr = PetscViewerASCIIPrintf(viewer," diagonal balancing enabled, with its=%D and lambda=%g\n",pep->sits,(double)pep->slambda);CHKERRQ(ierr); break; case PEP_SCALE_BOTH: ierr = PetscViewerASCIIPrintf(viewer," parameter scaling & diagonal balancing enabled, with scaling factor=%g, its=%D and lambda=%g\n",(double)pep->sfactor,pep->sits,(double)pep->slambda);CHKERRQ(ierr); break; } ierr = PetscViewerASCIIPrintf(viewer," selected portion of the spectrum: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,pep->target,PETSC_FALSE);CHKERRQ(ierr); if (!pep->which) { ierr = PetscViewerASCIIPrintf(viewer,"not yet set\n");CHKERRQ(ierr); } else switch (pep->which) { case PEP_WHICH_USER: ierr = PetscViewerASCIIPrintf(viewer,"user defined\n");CHKERRQ(ierr); break; case PEP_TARGET_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (in magnitude)\n",str);CHKERRQ(ierr); break; case PEP_TARGET_REAL: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the real axis)\n",str);CHKERRQ(ierr); break; case PEP_TARGET_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %s (along the imaginary axis)\n",str);CHKERRQ(ierr); break; case PEP_LARGEST_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");CHKERRQ(ierr); break; case PEP_SMALLEST_MAGNITUDE: ierr = PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");CHKERRQ(ierr); break; case PEP_LARGEST_REAL: ierr = PetscViewerASCIIPrintf(viewer,"largest real parts\n");CHKERRQ(ierr); break; case PEP_SMALLEST_REAL: ierr = PetscViewerASCIIPrintf(viewer,"smallest real parts\n");CHKERRQ(ierr); break; case PEP_LARGEST_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");CHKERRQ(ierr); break; case PEP_SMALLEST_IMAGINARY: ierr = PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");CHKERRQ(ierr); break; default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of pep->which"); } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of eigenvalues (nev): %D\n",pep->nev);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," number of column vectors (ncv): %D\n",pep->ncv);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum dimension of projected problem (mpd): %D\n",pep->mpd);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," maximum number of iterations: %D\n",pep->max_it);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," tolerance: %g\n",(double)pep->tol);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," convergence test: ");CHKERRQ(ierr); ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr); switch (pep->conv) { case PEP_CONV_ABS: ierr = PetscViewerASCIIPrintf(viewer,"absolute\n");CHKERRQ(ierr);break; case PEP_CONV_REL: ierr = PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue\n");CHKERRQ(ierr);break; case PEP_CONV_NORM: ierr = PetscViewerASCIIPrintf(viewer,"relative to the matrix norms\n");CHKERRQ(ierr); if (pep->nrma) { ierr = PetscViewerASCIIPrintf(viewer," computed matrix norms: %g",(double)pep->nrma[0]);CHKERRQ(ierr); for (i=1;inmat;i++) { ierr = PetscViewerASCIIPrintf(viewer,", %g",(double)pep->nrma[i]);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr); } break; case PEP_CONV_USER: ierr = PetscViewerASCIIPrintf(viewer,"user-defined\n");CHKERRQ(ierr);break; } ierr = PetscViewerASCIIUseTabs(viewer,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," extraction type: %s\n",PEPExtractTypes[pep->extract]);CHKERRQ(ierr); if (pep->refine) { ierr = PetscViewerASCIIPrintf(viewer," iterative refinement: %s, with %s scheme\n",PEPRefineTypes[pep->refine],PEPRefineSchemes[pep->scheme]);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," refinement stopping criterion: tol=%g, its=%D\n",(double)pep->rtol,pep->rits);CHKERRQ(ierr); if (pep->npart>1) { ierr = PetscViewerASCIIPrintf(viewer," splitting communicator in %D partitions for refinement\n",pep->npart);CHKERRQ(ierr); } } if (pep->nini) { ierr = PetscViewerASCIIPrintf(viewer," dimension of user-provided initial space: %D\n",PetscAbs(pep->nini));CHKERRQ(ierr); } } else { if (pep->ops->view) { ierr = (*pep->ops->view)(pep,viewer);CHKERRQ(ierr); } } ierr = PetscViewerPushFormat(viewer,PETSC_VIEWER_ASCII_INFO);CHKERRQ(ierr); if (!pep->V) { ierr = PEPGetBV(pep,&pep->V);CHKERRQ(ierr); } ierr = BVView(pep->V,viewer);CHKERRQ(ierr); if (!pep->rg) { ierr = PEPGetRG(pep,&pep->rg);CHKERRQ(ierr); } ierr = RGIsTrivial(pep->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) { ierr = RGView(pep->rg,viewer);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)pep,PEPLINEAR,&islinear);CHKERRQ(ierr); if (!islinear) { if (!pep->ds) { ierr = PEPGetDS(pep,&pep->ds);CHKERRQ(ierr); } ierr = DSView(pep->ds,viewer);CHKERRQ(ierr); } ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); if (!pep->st) { ierr = PEPGetST(pep,&pep->st);CHKERRQ(ierr); } ierr = STView(pep->st,viewer);CHKERRQ(ierr); if (pep->refine!=PEP_REFINE_NONE) { if (pep->npart>1) { if (pep->refinesubc->color==0) { ierr = PetscViewerASCIIGetStdout(PetscSubcommChild(pep->refinesubc),&sviewer);CHKERRQ(ierr); ierr = KSPView(pep->refineksp,sviewer);CHKERRQ(ierr); } } else { ierr = KSPView(pep->refineksp,viewer);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPReasonView" /*@C PEPReasonView - Displays the reason a PEP solve converged or diverged. Collective on PEP Parameter: + pep - the eigensolver context - viewer - the viewer to display the reason Options Database Keys: . -pep_converged_reason - print reason for convergence, and number of iterations Level: intermediate .seealso: PEPSetConvergenceTest(), PEPSetTolerances(), PEPGetIterationNumber() @*/ PetscErrorCode PEPReasonView(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PetscBool isAscii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isAscii);CHKERRQ(ierr); if (isAscii) { ierr = PetscViewerASCIIAddTab(viewer,((PetscObject)pep)->tablevel);CHKERRQ(ierr); if (pep->reason > 0) { ierr = PetscViewerASCIIPrintf(viewer,"%s Polynomial eigensolve converged (%D eigenpair%s) due to %s; iterations %D\n",((PetscObject)pep)->prefix?((PetscObject)pep)->prefix:"",pep->nconv,(pep->nconv>1)?"s":"",PEPConvergedReasons[pep->reason],pep->its);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%s Polynomial eigensolve did not converge due to %s; iterations %D\n",((PetscObject)pep)->prefix?((PetscObject)pep)->prefix:"",PEPConvergedReasons[pep->reason],pep->its);CHKERRQ(ierr); } ierr = PetscViewerASCIISubtractTab(viewer,((PetscObject)pep)->tablevel);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPReasonViewFromOptions" /*@ PEPReasonViewFromOptions - Processes command line options to determine if/how the PEP converged reason is to be viewed. Collective on PEP Input Parameters: . pep - the eigensolver context Level: developer @*/ PetscErrorCode PEPReasonViewFromOptions(PEP pep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_converged_reason",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = PEPReasonView(pep,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPErrorView_ASCII" static PetscErrorCode PEPErrorView_ASCII(PEP pep,PEPErrorType etype,PetscViewer viewer) { PetscBool errok; PetscReal error,re,im; PetscScalar kr,ki; PetscInt i,j; PetscErrorCode ierr; PetscFunctionBegin; if (pep->nconvnev) { ierr = PetscViewerASCIIPrintf(viewer," Problem: less than %D eigenvalues converged\n\n",pep->nev);CHKERRQ(ierr); PetscFunctionReturn(0); } errok = PETSC_TRUE; for (i=0;inev;i++) { ierr = PEPComputeError(pep,i,etype,&error);CHKERRQ(ierr); errok = (errok && error<5.0*pep->tol)? PETSC_TRUE: PETSC_FALSE; } if (!errok) { ierr = PetscViewerASCIIPrintf(viewer," Problem: some of the first %D relative errors are higher than the tolerance\n\n",pep->nev);CHKERRQ(ierr); PetscFunctionReturn(0); } ierr = PetscViewerASCIIPrintf(viewer," All requested eigenvalues computed up to the required tolerance:");CHKERRQ(ierr); for (i=0;i<=(pep->nev-1)/8;i++) { ierr = PetscViewerASCIIPrintf(viewer,"\n ");CHKERRQ(ierr); for (j=0;jnev-8*i);j++) { ierr = PEPGetEigenpair(pep,8*i+j,&kr,&ki,NULL,NULL);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(kr); im = PetscImaginaryPart(kr); #else re = kr; im = ki; #endif if (PetscAbs(re)/PetscAbs(im)nev) { ierr = PetscViewerASCIIPrintf(viewer,", ");CHKERRQ(ierr); } } } ierr = PetscViewerASCIIPrintf(viewer,"\n\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPErrorView_DETAIL" static PetscErrorCode PEPErrorView_DETAIL(PEP pep,PEPErrorType etype,PetscViewer viewer) { PetscErrorCode ierr; PetscReal error,re,im; PetscScalar kr,ki; PetscInt i; #define EXLEN 30 char ex[EXLEN],sep[]=" ---------------------- --------------------\n"; PetscFunctionBegin; if (!pep->nconv) PetscFunctionReturn(0); switch (etype) { case PEP_ERROR_ABSOLUTE: ierr = PetscSNPrintf(ex,EXLEN," ||P(k)x||");CHKERRQ(ierr); break; case PEP_ERROR_RELATIVE: ierr = PetscSNPrintf(ex,EXLEN,"||P(k)x||/||kx||");CHKERRQ(ierr); break; case PEP_ERROR_BACKWARD: ierr = PetscSNPrintf(ex,EXLEN," eta(x,k)");CHKERRQ(ierr); break; } ierr = PetscViewerASCIIPrintf(viewer,"%s k %s\n%s",sep,ex,sep);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = PEPGetEigenpair(pep,i,&kr,&ki,NULL,NULL);CHKERRQ(ierr); ierr = PEPComputeError(pep,i,etype,&error);CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(kr); im = PetscImaginaryPart(kr); #else re = kr; im = ki; #endif if (im!=0.0) { ierr = PetscViewerASCIIPrintf(viewer," % 9f%+9fi %12g\n",(double)re,(double)im,(double)error);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer," % 12f %12g\n",(double)re,(double)error);CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,sep);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPErrorView_MATLAB" static PetscErrorCode PEPErrorView_MATLAB(PEP pep,PEPErrorType etype,PetscViewer viewer) { PetscErrorCode ierr; PetscReal error; PetscInt i; const char *name; PetscFunctionBegin; ierr = PetscObjectGetName((PetscObject)pep,&name);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"Error_%s = [\n",name);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = PEPComputeError(pep,i,etype,&error);CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",error);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPErrorView" /*@C PEPErrorView - Displays the errors associated with the computed solution (as well as the eigenvalues). Collective on PEP Input Parameters: + pep - the eigensolver context . etype - error type - viewer - optional visualization context Options Database Key: + -pep_error_absolute - print absolute errors of each eigenpair . -pep_error_relative - print relative errors of each eigenpair - -pep_error_backward - print backward errors of each eigenpair Notes: By default, this function checks the error of all eigenpairs and prints the eigenvalues if all of them are below the requested tolerance. If the viewer has format=PETSC_VIEWER_ASCII_INFO_DETAIL then a table with eigenvalues and corresponding errors is printed. Level: intermediate .seealso: PEPSolve(), PEPValuesView(), PEPVectorsView() @*/ PetscErrorCode PEPErrorView(PEP pep,PEPErrorType etype,PetscViewer viewer) { PetscBool isascii; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(pep,1,viewer,2); PEPCheckSolved(pep,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (!isascii) PetscFunctionReturn(0); ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: ierr = PEPErrorView_ASCII(pep,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = PEPErrorView_DETAIL(pep,etype,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = PEPErrorView_MATLAB(pep,etype,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(pep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPErrorViewFromOptions" /*@ PEPErrorViewFromOptions - Processes command line options to determine if/how the errors of the computed solution are to be viewed. Collective on PEP Input Parameters: . pep - the eigensolver context Level: developer @*/ PetscErrorCode PEPErrorViewFromOptions(PEP pep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_error_absolute",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = PEPErrorView(pep,PEP_ERROR_ABSOLUTE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_error_relative",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = PEPErrorView(pep,PEP_ERROR_RELATIVE,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_error_backward",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = PEPErrorView(pep,PEP_ERROR_BACKWARD,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPValuesView_DRAW" static PetscErrorCode PEPValuesView_DRAW(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PetscDraw draw; PetscDrawSP drawsp; PetscReal re,im; PetscInt i,k; PetscFunctionBegin; if (!pep->nconv) PetscFunctionReturn(0); ierr = PetscViewerDrawOpen(PETSC_COMM_SELF,0,"Computed Eigenvalues",PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);CHKERRQ(ierr); ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); ierr = PetscDrawSPCreate(draw,1,&drawsp);CHKERRQ(ierr); for (i=0;inconv;i++) { k = pep->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(pep->eigr[k]); im = PetscImaginaryPart(pep->eigr[k]); #else re = pep->eigr[k]; im = pep->eigi[k]; #endif ierr = PetscDrawSPAddPoint(drawsp,&re,&im);CHKERRQ(ierr); } ierr = PetscDrawSPDraw(drawsp,PETSC_TRUE);CHKERRQ(ierr); ierr = PetscDrawSPSave(drawsp);CHKERRQ(ierr); ierr = PetscDrawSPDestroy(&drawsp);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPValuesView_ASCII" static PetscErrorCode PEPValuesView_ASCII(PEP pep,PetscViewer viewer) { PetscReal re,im; PetscInt i,k; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscViewerASCIIPrintf(viewer,"Eigenvalues = \n");CHKERRQ(ierr); for (i=0;inconv;i++) { k = pep->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(pep->eigr[k]); im = PetscImaginaryPart(pep->eigr[k]); #else re = pep->eigr[k]; im = pep->eigi[k]; #endif if (PetscAbs(re)/PetscAbs(im)nconv;i++) { k = pep->perm[i]; #if defined(PETSC_USE_COMPLEX) re = PetscRealPart(pep->eigr[k]); im = PetscImaginaryPart(pep->eigr[k]); #else re = pep->eigr[k]; im = pep->eigi[k]; #endif if (im!=0.0) { ierr = PetscViewerASCIIPrintf(viewer,"%18.16e%+18.16ei\n",(double)re,(double)im);CHKERRQ(ierr); } else { ierr = PetscViewerASCIIPrintf(viewer,"%18.16e\n",(double)re);CHKERRQ(ierr); } } ierr = PetscViewerASCIIPrintf(viewer,"];\n");CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPValuesView" /*@C PEPValuesView - Displays the computed eigenvalues in a viewer. Collective on PEP Input Parameters: + pep - the eigensolver context - viewer - the viewer Options Database Key: . -pep_view_values - print computed eigenvalues Level: intermediate .seealso: PEPSolve(), PEPVectorsView(), PEPErrorView() @*/ PetscErrorCode PEPValuesView(PEP pep,PetscViewer viewer) { PetscBool isascii,isdraw; PetscViewerFormat format; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(pep,1,viewer,2); PEPCheckSolved(pep,1); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isdraw) { ierr = PEPValuesView_DRAW(pep,viewer);CHKERRQ(ierr); } else if (isascii) { ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr); switch (format) { case PETSC_VIEWER_DEFAULT: case PETSC_VIEWER_ASCII_INFO: case PETSC_VIEWER_ASCII_INFO_DETAIL: ierr = PEPValuesView_ASCII(pep,viewer);CHKERRQ(ierr); break; case PETSC_VIEWER_ASCII_MATLAB: ierr = PEPValuesView_MATLAB(pep,viewer);CHKERRQ(ierr); break; default: ierr = PetscInfo1(pep,"Unsupported viewer format %s\n",PetscViewerFormats[format]);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPValuesViewFromOptions" /*@ PEPValuesViewFromOptions - Processes command line options to determine if/how the computed eigenvalues are to be viewed. Collective on PEP Input Parameters: . pep - the eigensolver context Level: developer @*/ PetscErrorCode PEPValuesViewFromOptions(PEP pep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_view_values",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = PEPValuesView(pep,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPVectorsView" /*@C PEPVectorsView - Outputs computed eigenvectors to a viewer. Collective on PEP Parameter: + pep - the eigensolver context - viewer - the viewer Options Database Keys: . -pep_view_vectors - output eigenvectors. Note: If PETSc was configured with real scalars, complex conjugate eigenvectors will be viewed as two separate real vectors, one containing the real part and another one containing the imaginary part. Level: intermediate .seealso: PEPSolve(), PEPValuesView(), PEPErrorView() @*/ PetscErrorCode PEPVectorsView(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PetscInt i,k; Vec x; #define NMLEN 30 char vname[NMLEN]; const char *ename; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); if (!viewer) viewer = PETSC_VIEWER_STDOUT_(PetscObjectComm((PetscObject)pep)); PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2); PetscCheckSameComm(pep,1,viewer,2); PEPCheckSolved(pep,1); if (pep->nconv) { ierr = PetscObjectGetName((PetscObject)pep,&ename);CHKERRQ(ierr); ierr = PEPComputeVectors(pep);CHKERRQ(ierr); for (i=0;inconv;i++) { k = pep->perm[i]; ierr = PetscSNPrintf(vname,NMLEN,"V%d_%s",(int)i,ename);CHKERRQ(ierr); ierr = BVGetColumn(pep->V,k,&x);CHKERRQ(ierr); ierr = PetscObjectSetName((PetscObject)x,vname);CHKERRQ(ierr); ierr = VecView(x,viewer);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,k,&x);CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPVectorsViewFromOptions" /*@ PEPVectorsViewFromOptions - Processes command line options to determine if/how the computed eigenvectors are to be viewed. Collective on PEP Input Parameters: . pep - the eigensolver context Level: developer @*/ PetscErrorCode PEPVectorsViewFromOptions(PEP pep) { PetscErrorCode ierr; PetscViewer viewer; PetscBool flg = PETSC_FALSE; static PetscBool incall = PETSC_FALSE; PetscViewerFormat format; PetscFunctionBegin; if (incall) PetscFunctionReturn(0); incall = PETSC_TRUE; ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)pep),((PetscObject)pep)->prefix,"-pep_view_vectors",&viewer,&format,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); ierr = PEPVectorsView(pep,viewer);CHKERRQ(ierr); ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); } incall = PETSC_FALSE; PetscFunctionReturn(0); } slepc-3.7.4/src/pep/interface/ftn-custom/0000755000175000017500000000000013107004621017575 5ustar jromanjromanslepc-3.7.4/src/pep/interface/ftn-custom/makefile0000644000175000017500000000221113107004621021271 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = zpepf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcpep LOCDIR = src/pep/interface/ftn-custom/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/interface/ftn-custom/zpepf.c0000644000175000017500000003516013107004621021072 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include #include #if defined(PETSC_HAVE_FORTRAN_CAPS) #define pepview_ PEPVIEW #define peperrorview_ PEPERRORVIEW #define pepreasonview_ PEPREASONVIEW #define pepvaluesview_ PEPVALUESVIEW #define pepvectorsview_ PEPVECTORSVIEW #define pepsetoptionsprefix_ PEPSETOPTIONSPREFIX #define pepappendoptionsprefix_ PEPAPPENDOPTIONSPREFIX #define pepgetoptionsprefix_ PEPGETOPTIONSPREFIX #define pepsettype_ PEPSETTYPE #define pepgettype_ PEPGETTYPE #define pepmonitorall_ PEPMONITORALL #define pepmonitorlg_ PEPMONITORLG #define pepmonitorlgall_ PEPMONITORLGALL #define pepmonitorset_ PEPMONITORSET #define pepmonitorconverged_ PEPMONITORCONVERGED #define pepmonitorfirst_ PEPMONITORFIRST #define pepconvergedabsolute_ PEPCONVERGEDABSOLUTE #define pepconvergedrelative_ PEPCONVERGEDRELATIVE #define pepsetconvergencetestfunction_ PEPSETCONVERGENCETESTFUNCTION #define pepsetstoppingtestfunction_ PEPSETSTOPPINGTESTFUNCTION #define pepseteigenvaluecomparison_ PEPSETEIGENVALUECOMPARISON #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) #define pepview_ pepview #define peperrorview_ peperrorview #define pepreasonview_ pepreasonview #define pepvaluesview_ pepvaluesview #define pepvectorsview_ pepvectorsview #define pepsetoptionsprefix_ pepsetoptionsprefix #define pepappendoptionsprefix_ pepappendoptionsprefix #define pepgetoptionsprefix_ pepgetoptionsprefix #define pepsettype_ pepsettype #define pepgettype_ pepgettype #define pepmonitorall_ pepmonitorall #define pepmonitorlg_ pepmonitorlg #define pepmonitorlgall_ pepmonitorlgall #define pepmonitorset_ pepmonitorset #define pepmonitorconverged_ pepmonitorconverged #define pepmonitorfirst_ pepmonitorfirst #define pepconvergedabsolute_ pepconvergedabsolute #define pepconvergedrelative_ pepconvergedrelative #define pepsetconvergencetestfunction_ pepsetconvergencetestfunction #define pepsetstoppingtestfunction_ pepsetstoppingtestfunction #define pepseteigenvaluecomparison_ pepseteigenvaluecomparison #endif /* These are not usually called from Fortran but allow Fortran users to transparently set these monitors from .F code, hence no STDCALL */ PETSC_EXTERN void pepmonitorall_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = PEPMonitorAll(*pep,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void pepmonitorconverged_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr) { *ierr = PEPMonitorConverged(*pep,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void pepmonitorfirst_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr) { *ierr = PEPMonitorFirst(*pep,*it,*nconv,eigr,eigi,errest,*nest,*ctx); } PETSC_EXTERN void pepmonitorlg_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = PEPMonitorLG(*pep,*it,*nconv,eigr,eigi,errest,*nest,ctx); } PETSC_EXTERN void pepmonitorlgall_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr) { *ierr = PEPMonitorLGAll(*pep,*it,*nconv,eigr,eigi,errest,*nest,ctx); } static struct { PetscFortranCallbackId monitor; PetscFortranCallbackId monitordestroy; PetscFortranCallbackId convergence; PetscFortranCallbackId convdestroy; PetscFortranCallbackId stopping; PetscFortranCallbackId stopdestroy; PetscFortranCallbackId comparison; } _cb; /* These are not extern C because they are passed into non-extern C user level functions */ #undef __FUNCT__ #define __FUNCT__ "ourmonitor" static PetscErrorCode ourmonitor(PEP pep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx) { PetscObjectUseFortranCallback(pep,_cb.monitor,(PEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),(&pep,&i,&nc,er,ei,d,&l,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourdestroy" static PetscErrorCode ourdestroy(void** ctx) { PEP pep = (PEP)*ctx; PetscObjectUseFortranCallback(pep,_cb.monitordestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvergence" static PetscErrorCode ourconvergence(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx) { PetscObjectUseFortranCallback(pep,_cb.convergence,(PEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),(&pep,&eigr,&eigi,&res,errest,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourconvdestroy" static PetscErrorCode ourconvdestroy(void *ctx) { PEP pep = (PEP)ctx; PetscObjectUseFortranCallback(pep,_cb.convdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopping" static PetscErrorCode ourstopping(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx) { PetscObjectUseFortranCallback(pep,_cb.stopping,(PEP*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PEPConvergedReason*,void*,PetscErrorCode*),(&pep,&its,&max_it,&nconv,&nev,reason,_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "ourstopdestroy" static PetscErrorCode ourstopdestroy(void *ctx) { PEP pep = (PEP)ctx; PetscObjectUseFortranCallback(pep,_cb.stopdestroy,(void*,PetscErrorCode*),(_ctx,&ierr)); } #undef __FUNCT__ #define __FUNCT__ "oureigenvaluecomparison" static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx) { PEP eps = (PEP)ctx; PetscObjectUseFortranCallback(eps,_cb.comparison,(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*,PetscErrorCode*),(&ar,&ai,&br,&bi,r,_ctx,&ierr)); } PETSC_EXTERN void PETSC_STDCALL pepview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = PEPView(*pep,v); } PETSC_EXTERN void PETSC_STDCALL pepreasonview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = PEPReasonView(*pep,v); } PETSC_EXTERN void PETSC_STDCALL peperrorview_(PEP *pep,PEPErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = PEPErrorView(*pep,*etype,v); } PETSC_EXTERN void PETSC_STDCALL pepvaluesview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = PEPValuesView(*pep,v); } PETSC_EXTERN void PETSC_STDCALL pepvectorsview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr) { PetscViewer v; PetscPatchDefaultViewers_Fortran(viewer,v); *ierr = PEPVectorsView(*pep,v); } PETSC_EXTERN void PETSC_STDCALL pepsettype_(PEP *pep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(type,len,t); *ierr = PEPSetType(*pep,t); FREECHAR(type,t); } PETSC_EXTERN void PETSC_STDCALL pepgettype_(PEP *pep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { PEPType tname; *ierr = PEPGetType(*pep,&tname);if (*ierr) return; *ierr = PetscStrncpy(name,tname,len); FIXRETURNCHAR(PETSC_TRUE,name,len); } PETSC_EXTERN void PETSC_STDCALL pepsetoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = PEPSetOptionsPrefix(*pep,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL pepappendoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { char *t; FIXCHAR(prefix,len,t); *ierr = PEPAppendOptionsPrefix(*pep,t); FREECHAR(prefix,t); } PETSC_EXTERN void PETSC_STDCALL pepgetoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) { const char *tname; *ierr = PEPGetOptionsPrefix(*pep,&tname); if (*ierr) return; *ierr = PetscStrncpy(prefix,tname,len); FIXRETURNCHAR(PETSC_TRUE,prefix,len); } PETSC_EXTERN void PETSC_STDCALL pepmonitorset_(PEP *pep,void (PETSC_STDCALL *monitor)(PEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(mctx); CHKFORTRANNULLFUNCTION(monitordestroy); if ((PetscVoidFunction)monitor == (PetscVoidFunction)pepmonitorall_) { *ierr = PEPMonitorSet(*pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))PEPMonitorAll,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)pepmonitorconverged_) { *ierr = PEPMonitorSet(*pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))PEPMonitorConverged,*(SlepcConvMonitor*)mctx,(PetscErrorCode (*)(void**))SlepcConvMonitorDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)pepmonitorfirst_) { *ierr = PEPMonitorSet(*pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))PEPMonitorFirst,*(PetscViewerAndFormat**)mctx,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)pepmonitorlg_) { *ierr = PEPMonitorSet(*pep,PEPMonitorLG,0,0); } else if ((PetscVoidFunction)monitor == (PetscVoidFunction)pepmonitorlgall_) { *ierr = PEPMonitorSet(*pep,PEPMonitorLGAll,0,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*pep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitor,(PetscVoidFunction)monitor,mctx); if (*ierr) return; if (!monitordestroy) { *ierr = PEPMonitorSet(*pep,ourmonitor,*pep,0); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*pep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.monitordestroy,(PetscVoidFunction)monitordestroy,mctx); if (*ierr) return; *ierr = PEPMonitorSet(*pep,ourmonitor,*pep,ourdestroy); } } } PETSC_EXTERN void PETSC_STDCALL pepconvergedabsolute_(PEP *pep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = PEPConvergedAbsolute(*pep,*eigr,*eigi,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL pepconvergedrelative_(PEP *pep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr) { *ierr = PEPConvergedRelative(*pep,*eigr,*eigi,*res,errest,ctx); } PETSC_EXTERN void PETSC_STDCALL pepsetconvergencetestfunction_(PEP *pep,void (PETSC_STDCALL *func)(PEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)pepconvergedabsolute_) { *ierr = PEPSetConvergenceTest(*pep,PEP_CONV_ABS); } else if ((PetscVoidFunction)func == (PetscVoidFunction)pepconvergedrelative_) { *ierr = PEPSetConvergenceTest(*pep,PEP_CONV_REL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*pep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convergence,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = PEPSetConvergenceTestFunction(*pep,ourconvergence,*pep,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*pep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.convdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = PEPSetConvergenceTestFunction(*pep,ourconvergence,*pep,ourconvdestroy); } } } PETSC_EXTERN void PETSC_STDCALL pepstoppingbasic_(PEP *pep,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,PEPConvergedReason *reason,void *ctx,PetscErrorCode *ierr) { *ierr = PEPStoppingBasic(*pep,*its,*max_it,*nconv,*nev,reason,ctx); } PETSC_EXTERN void PETSC_STDCALL pepsetstoppingtestfunction_(PEP *pep,void (PETSC_STDCALL *func)(PEP*,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); CHKFORTRANNULLFUNCTION(destroy); if ((PetscVoidFunction)func == (PetscVoidFunction)pepstoppingbasic_) { *ierr = PEPSetStoppingTest(*pep,PEP_STOP_BASIC); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*pep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopping,(PetscVoidFunction)func,ctx); if (*ierr) return; if (!destroy) { *ierr = PEPSetStoppingTestFunction(*pep,ourstopping,*pep,NULL); } else { *ierr = PetscObjectSetFortranCallback((PetscObject)*pep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.stopdestroy,(PetscVoidFunction)destroy,ctx); if (*ierr) return; *ierr = PEPSetStoppingTestFunction(*pep,ourstopping,*pep,ourstopdestroy); } } } PETSC_EXTERN void PETSC_STDCALL pepseteigenvaluecomparison_(PEP *pep,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr) { CHKFORTRANNULLOBJECT(ctx); *ierr = PetscObjectSetFortranCallback((PetscObject)*pep,PETSC_FORTRAN_CALLBACK_CLASS,&_cb.comparison,(PetscVoidFunction)func,ctx); if (*ierr) return; *ierr = PEPSetEigenvalueComparison(*pep,oureigenvaluecomparison,*pep); } slepc-3.7.4/src/pep/interface/pepdefault.c.html0000644000175000017500000012162213107004621020742 0ustar jromanjroman

Actual source code: pepdefault.c

slepc-3.7.4 2017-05-17
  1: /*
  2:      This file contains some simple default routines for common PEP operations.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>     /*I "slepcpep.h" I*/

 28: /*@
 29:    PEPSetWorkVecs - Sets a number of work vectors into a PEP object.

 31:    Collective on PEP

 33:    Input Parameters:
 34: +  pep - polynomial eigensolver context
 35: -  nw  - number of work vectors to allocate

 37:    Developers Note:
 38:    This is PETSC_EXTERN because it may be required by user plugin PEP
 39:    implementations.

 41:    Level: developer
 42: @*/
 43: PetscErrorCode PEPSetWorkVecs(PEP pep,PetscInt nw)
 44: {
 46:   Vec            t;

 49:   if (pep->nwork < nw) {
 50:     VecDestroyVecs(pep->nwork,&pep->work);
 51:     pep->nwork = nw;
 52:     BVGetColumn(pep->V,0,&t);
 53:     VecDuplicateVecs(t,nw,&pep->work);
 54:     BVRestoreColumn(pep->V,0,&t);
 55:     PetscLogObjectParents(pep,nw,pep->work);
 56:   }
 57:   return(0);
 58: }

 62: /*
 63:   PEPConvergedRelative - Checks convergence relative to the eigenvalue.
 64: */
 65: PetscErrorCode PEPConvergedRelative(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
 66: {
 67:   PetscReal w;

 70:   w = SlepcAbsEigenvalue(eigr,eigi);
 71:   *errest = res/w;
 72:   return(0);
 73: }

 77: /*
 78:   PEPConvergedNorm - Checks convergence relative to the matrix norms.
 79: */
 80: PetscErrorCode PEPConvergedNorm(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
 81: {
 82:   PetscReal      w=0.0,t;
 83:   PetscInt       j;
 84:   PetscBool      flg;

 88:   /* initialization of matrix norms */
 89:   if (!pep->nrma[pep->nmat-1]) {
 90:     for (j=0;j<pep->nmat;j++) {
 91:       MatHasOperation(pep->A[j],MATOP_NORM,&flg);
 92:       if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_WRONG,"The convergence test related to the matrix norms requires a matrix norm operation");
 93:       MatNorm(pep->A[j],NORM_INFINITY,&pep->nrma[j]);
 94:     }
 95:   }
 96:   t = SlepcAbsEigenvalue(eigr,eigi);
 97:   for (j=pep->nmat-1;j>=0;j--) {
 98:     w = w*t+pep->nrma[j];
 99:   }
100:   *errest = res/w;
101:   return(0);
102: }

106: /*
107:   PEPConvergedAbsolute - Checks convergence absolutely.
108: */
109: PetscErrorCode PEPConvergedAbsolute(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)
110: {
112:   *errest = res;
113:   return(0);
114: }

118: /*@C
119:    PEPStoppingBasic - Default routine to determine whether the outer eigensolver
120:    iteration must be stopped.

122:    Collective on PEP

124:    Input Parameters:
125: +  pep    - eigensolver context obtained from PEPCreate()
126: .  its    - current number of iterations
127: .  max_it - maximum number of iterations
128: .  nconv  - number of currently converged eigenpairs
129: .  nev    - number of requested eigenpairs
130: -  ctx    - context (not used here)

132:    Output Parameter:
133: .  reason - result of the stopping test

135:    Notes:
136:    A positive value of reason indicates that the iteration has finished successfully
137:    (converged), and a negative value indicates an error condition (diverged). If
138:    the iteration needs to be continued, reason must be set to PEP_CONVERGED_ITERATING
139:    (zero).

141:    PEPStoppingBasic() will stop if all requested eigenvalues are converged, or if
142:    the maximum number of iterations has been reached.

144:    Use PEPSetStoppingTest() to provide your own test instead of using this one.

146:    Level: advanced

148: .seealso: PEPSetStoppingTest(), PEPConvergedReason, PEPGetConvergedReason()
149: @*/
150: PetscErrorCode PEPStoppingBasic(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)
151: {

155:   *reason = PEP_CONVERGED_ITERATING;
156:   if (nconv >= nev) {
157:     PetscInfo2(pep,"Polynomial eigensolver finished successfully: %D eigenpairs converged at iteration %D\n",nconv,its);
158:     *reason = PEP_CONVERGED_TOL;
159:   } else if (its >= max_it) {
160:     *reason = PEP_DIVERGED_ITS;
161:     PetscInfo1(pep,"Polynomial eigensolver iteration reached maximum number of iterations (%D)\n",its);
162:   }
163:   return(0);
164: }

168: PetscErrorCode PEPBackTransform_Default(PEP pep)
169: {

173:   STBackTransform(pep->st,pep->nconv,pep->eigr,pep->eigi);
174:   return(0);
175: }

179: PetscErrorCode PEPComputeVectors_Default(PEP pep)
180: {
182:   PetscInt       i;
183:   Vec            v;
184: #if !defined(PETSC_USE_COMPLEX)
185:   Vec            v1;
186: #endif

189:   PEPExtractVectors(pep);

191:   /* Fix eigenvectors if balancing was used */
192:   if ((pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) && pep->Dr && (pep->refine!=PEP_REFINE_MULTIPLE)) {
193:     for (i=0;i<pep->nconv;i++) {
194:       BVGetColumn(pep->V,i,&v);
195:       VecPointwiseMult(v,v,pep->Dr);
196:       BVRestoreColumn(pep->V,i,&v);
197:     }
198:   }

200:   /* normalization */
201:   for (i=0;i<pep->nconv;i++) {
202: #if !defined(PETSC_USE_COMPLEX)
203:     if (pep->eigi[i]!=0.0) {   /* first eigenvalue of a complex conjugate pair */
204:       BVGetColumn(pep->V,i,&v);
205:       BVGetColumn(pep->V,i+1,&v1);
206:       SlepcVecNormalize(v,v1,PETSC_TRUE,NULL);
207:       BVRestoreColumn(pep->V,i,&v);
208:       BVRestoreColumn(pep->V,i+1,&v1);
209:       i++;
210:     } else   /* real eigenvalue */
211: #endif
212:     {
213:       BVGetColumn(pep->V,i,&v);
214:       SlepcVecNormalize(v,NULL,PETSC_FALSE,NULL);
215:       BVRestoreColumn(pep->V,i,&v);
216:     }
217:   }
218:   return(0);
219: }

223: /*
224:    PEPKrylovConvergence - This is the analogue to EPSKrylovConvergence, but
225:    for polynomial Krylov methods.

227:    Differences:
228:    - Always non-symmetric
229:    - Does not check for STSHIFT
230:    - No correction factor
231:    - No support for true residual
232: */
233: PetscErrorCode PEPKrylovConvergence(PEP pep,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscInt *kout)
234: {
236:   PetscInt       k,newk,marker,inside;
237:   PetscScalar    re,im;
238:   PetscReal      resnorm;
239:   PetscBool      istrivial;

242:   RGIsTrivial(pep->rg,&istrivial);
243:   marker = -1;
244:   if (pep->trackall) getall = PETSC_TRUE;
245:   for (k=kini;k<kini+nits;k++) {
246:     /* eigenvalue */
247:     re = pep->eigr[k];
248:     im = pep->eigi[k];
249:     if (!istrivial) {
250:       STBackTransform(pep->st,1,&re,&im);
251:       RGCheckInside(pep->rg,1,&re,&im,&inside);
252:       if (marker==-1 && inside<0) marker = k;
253:       re = pep->eigr[k];
254:       im = pep->eigi[k];
255:     }
256:     newk = k;
257:     DSVectors(pep->ds,DS_MAT_X,&newk,&resnorm);
258:     resnorm *= beta;
259:     /* error estimate */
260:     (*pep->converged)(pep,re,im,resnorm,&pep->errest[k],pep->convergedctx);
261:     if (marker==-1 && pep->errest[k] >= pep->tol) marker = k;
262:     if (newk==k+1) {
263:       pep->errest[k+1] = pep->errest[k];
264:       k++;
265:     }
266:     if (marker!=-1 && !getall) break;
267:   }
268:   if (marker!=-1) k = marker;
269:   *kout = k;
270:   return(0);
271: }

275: /*
276:   PEPBuildDiagonalScaling - compute two diagonal matrices to be applied for balancing 
277:   in polynomial eigenproblems.
278: */
279: PetscErrorCode PEPBuildDiagonalScaling(PEP pep)
280: {
282:   PetscInt       it,i,j,k,nmat,nr,e,nz,lst,lend,nc=0,*cols,emax,emin,emaxl,eminl;
283:   const PetscInt *cidx,*ridx;
284:   Mat            M,*T,A;
285:   PetscMPIInt    n;
286:   PetscBool      cont=PETSC_TRUE,flg=PETSC_FALSE;
287:   PetscScalar    *array,*Dr,*Dl,t;
288:   PetscReal      l2,d,*rsum,*aux,*csum,w=1.0;
289:   MatStructure   str;
290:   MatInfo        info;

293:   l2 = 2*PetscLogReal(2.0);
294:   nmat = pep->nmat;
295:   PetscMPIIntCast(pep->n,&n);
296:   STGetMatStructure(pep->st,&str);
297:   PetscMalloc1(nmat,&T);
298:   for (k=0;k<nmat;k++) {
299:     STGetTOperators(pep->st,k,&T[k]);
300:   }
301:   /* Form local auxiliar matrix M */
302:   PetscObjectTypeCompareAny((PetscObject)T[0],&cont,MATMPIAIJ,MATSEQAIJ,"");
303:   if (!cont) SETERRQ(PetscObjectComm((PetscObject)T[0]),PETSC_ERR_SUP,"Only for MPIAIJ or SEQAIJ matrix types");
304:   PetscObjectTypeCompare((PetscObject)T[0],MATMPIAIJ,&cont);
305:   if (cont) {
306:     MatMPIAIJGetLocalMat(T[0],MAT_INITIAL_MATRIX,&M);
307:     flg = PETSC_TRUE; 
308:   } else {
309:     MatDuplicate(T[0],MAT_COPY_VALUES,&M);
310:   }
311:   MatGetInfo(M,MAT_LOCAL,&info);
312:   nz = (PetscInt)info.nz_used;
313:   MatSeqAIJGetArray(M,&array);
314:   for (i=0;i<nz;i++) {
315:     t = PetscAbsScalar(array[i]);
316:     array[i] = t*t;
317:   }
318:   MatSeqAIJRestoreArray(M,&array);
319:   for (k=1;k<nmat;k++) {
320:     if (flg) {
321:       MatMPIAIJGetLocalMat(T[k],MAT_INITIAL_MATRIX,&A);
322:     } else {
323:       if (str==SAME_NONZERO_PATTERN) {
324:         MatCopy(T[k],A,SAME_NONZERO_PATTERN);
325:       } else {
326:         MatDuplicate(T[k],MAT_COPY_VALUES,&A);
327:       }
328:     }
329:     MatGetInfo(A,MAT_LOCAL,&info);
330:     nz = (PetscInt)info.nz_used;
331:     MatSeqAIJGetArray(A,&array);
332:     for (i=0;i<nz;i++) {
333:       t = PetscAbsScalar(array[i]);
334:       array[i] = t*t;
335:     }
336:     MatSeqAIJRestoreArray(A,&array);
337:     w *= pep->slambda*pep->slambda*pep->sfactor;
338:     MatAXPY(M,w,A,str);
339:     if (flg || str!=SAME_NONZERO_PATTERN || k==nmat-2) {
340:       MatDestroy(&A);
341:     } 
342:   }
343:   MatGetRowIJ(M,0,PETSC_FALSE,PETSC_FALSE,&nr,&ridx,&cidx,&cont);
344:   if (!cont) SETERRQ(PetscObjectComm((PetscObject)T[0]), PETSC_ERR_SUP,"It is not possible to compute scaling diagonals for these PEP matrices");
345:   MatGetInfo(M,MAT_LOCAL,&info);
346:   nz = (PetscInt)info.nz_used;
347:   VecGetOwnershipRange(pep->Dl,&lst,&lend);
348:   PetscMalloc4(nr,&rsum,pep->n,&csum,pep->n,&aux,PetscMin(pep->n-lend+lst,nz),&cols);
349:   VecSet(pep->Dr,1.0);
350:   VecSet(pep->Dl,1.0);
351:   VecGetArray(pep->Dl,&Dl);
352:   VecGetArray(pep->Dr,&Dr);
353:   MatSeqAIJGetArray(M,&array);
354:   PetscMemzero(aux,pep->n*sizeof(PetscReal));
355:   for (j=0;j<nz;j++) {
356:     /* Search non-zero columns outsize lst-lend */
357:     if (aux[cidx[j]]==0 && (cidx[j]<lst || lend<=cidx[j])) cols[nc++] = cidx[j];
358:     /* Local column sums */
359:     aux[cidx[j]] += PetscAbsScalar(array[j]);
360:   }
361:   for (it=0;it<pep->sits && cont;it++) {
362:     emaxl = 0; eminl = 0;
363:     /* Column sum  */    
364:     if (it>0) { /* it=0 has been already done*/
365:       MatSeqAIJGetArray(M,&array);
366:       PetscMemzero(aux,pep->n*sizeof(PetscReal));
367:       for (j=0;j<nz;j++) aux[cidx[j]] += PetscAbsScalar(array[j]);
368:       MatSeqAIJRestoreArray(M,&array); 
369:     }
370:     MPI_Allreduce(aux,csum,n,MPIU_REAL,MPIU_SUM,PetscObjectComm((PetscObject)pep->Dr));
371:     /* Update Dr */
372:     for (j=lst;j<lend;j++) {
373:       d = PetscLogReal(csum[j])/l2;
374:       e = -(PetscInt)((d < 0)?(d-0.5):(d+0.5));
375:       d = PetscPowReal(2.0,e);
376:       Dr[j-lst] *= d;
377:       aux[j] = d*d;
378:       emaxl = PetscMax(emaxl,e);
379:       eminl = PetscMin(eminl,e);
380:     }
381:     for (j=0;j<nc;j++) {
382:       d = PetscLogReal(csum[cols[j]])/l2;
383:       e = -(PetscInt)((d < 0)?(d-0.5):(d+0.5));
384:       d = PetscPowReal(2.0,e);
385:       aux[cols[j]] = d*d;
386:       emaxl = PetscMax(emaxl,e);
387:       eminl = PetscMin(eminl,e);
388:     }
389:     /* Scale M */
390:     MatSeqAIJGetArray(M,&array);
391:     for (j=0;j<nz;j++) {
392:       array[j] *= aux[cidx[j]];
393:     }
394:     MatSeqAIJRestoreArray(M,&array);
395:     /* Row sum */    
396:     PetscMemzero(rsum,nr*sizeof(PetscReal));
397:     MatSeqAIJGetArray(M,&array);
398:     for (i=0;i<nr;i++) {
399:       for (j=ridx[i];j<ridx[i+1];j++) rsum[i] += PetscAbsScalar(array[j]);
400:       /* Update Dl */
401:       d = PetscLogReal(rsum[i])/l2;
402:       e = -(PetscInt)((d < 0)?(d-0.5):(d+0.5));
403:       d = PetscPowReal(2.0,e);
404:       Dl[i] *= d;
405:       /* Scale M */
406:       for (j=ridx[i];j<ridx[i+1];j++) array[j] *= d*d;
407:       emaxl = PetscMax(emaxl,e);
408:       eminl = PetscMin(eminl,e);      
409:     }
410:     MatSeqAIJRestoreArray(M,&array);  
411:     /* Compute global max and min */
412:     MPI_Allreduce(&emaxl,&emax,1,MPIU_INT,MPI_MAX,PetscObjectComm((PetscObject)pep->Dl));
413:     MPI_Allreduce(&eminl,&emin,1,MPIU_INT,MPI_MIN,PetscObjectComm((PetscObject)pep->Dl));
414:     if (emax<=emin+2) cont = PETSC_FALSE;
415:   }
416:   VecRestoreArray(pep->Dr,&Dr);
417:   VecRestoreArray(pep->Dl,&Dl);
418:   /* Free memory*/
419:   MatDestroy(&M);
420:   PetscFree4(rsum,csum,aux,cols);
421:   PetscFree(T);
422:   return(0);
423: }

427: /*
428:    PEPComputeScaleFactor - compute sfactor as described in [Betcke 2008].
429: */
430: PetscErrorCode PEPComputeScaleFactor(PEP pep)
431: {
433:   PetscBool      has0,has1,flg;
434:   PetscReal      norm0,norm1;
435:   Mat            T[2];
436:   PEPBasis       basis;
437:   PetscInt       i;

440:   if (pep->scale==PEP_SCALE_NONE || pep->scale==PEP_SCALE_DIAGONAL) {  /* no scalar scaling */
441:     pep->sfactor = 1.0;
442:     pep->dsfactor = 1.0;
443:     return(0);
444:   }
445:   if (pep->sfactor_set) return(0);  /* user provided value */
446:   pep->sfactor = 1.0;
447:   pep->dsfactor = 1.0;
448:   PEPGetBasis(pep,&basis);
449:   if (basis==PEP_BASIS_MONOMIAL) {
450:     STGetTransform(pep->st,&flg);
451:     if (flg) {
452:       STGetTOperators(pep->st,0,&T[0]);
453:       STGetTOperators(pep->st,pep->nmat-1,&T[1]);
454:     } else {
455:       T[0] = pep->A[0];
456:       T[1] = pep->A[pep->nmat-1];
457:     }
458:     if (pep->nmat>2) {
459:       MatHasOperation(T[0],MATOP_NORM,&has0);
460:       MatHasOperation(T[1],MATOP_NORM,&has1);
461:       if (has0 && has1) {
462:         MatNorm(T[0],NORM_INFINITY,&norm0);
463:         MatNorm(T[1],NORM_INFINITY,&norm1);
464:         pep->sfactor = PetscPowReal(norm0/norm1,1.0/(pep->nmat-1));
465:         pep->dsfactor = norm1;
466:         for (i=pep->nmat-2;i>0;i--) {
467:           STGetTOperators(pep->st,i,&T[1]);
468:           MatHasOperation(T[1],MATOP_NORM,&has1);
469:           if (has1) {
470:             MatNorm(T[1],NORM_INFINITY,&norm1);
471:             pep->dsfactor = pep->dsfactor*pep->sfactor+norm1;
472:           } else break;
473:         }
474:         if (has1) {
475:           pep->dsfactor = pep->dsfactor*pep->sfactor+norm0;
476:           pep->dsfactor = pep->nmat/pep->dsfactor;
477:         } else pep->dsfactor = 1.0;
478:       } 
479:     }
480:   } 
481:   return(0);
482: }

486: /*
487:    PEPBasisCoefficients - compute polynomial basis coefficients
488: */
489: PetscErrorCode PEPBasisCoefficients(PEP pep,PetscReal *pbc)
490: {
491:   PetscReal *ca,*cb,*cg;
492:   PetscInt  k,nmat=pep->nmat;
493:   
495:   ca = pbc;
496:   cb = pbc+nmat;
497:   cg = pbc+2*nmat;
498:   switch (pep->basis) {
499:   case PEP_BASIS_MONOMIAL:
500:     for (k=0;k<nmat;k++) {
501:       ca[k] = 1.0; cb[k] = 0.0; cg[k] = 0.0;
502:     }
503:     break;
504:   case PEP_BASIS_CHEBYSHEV1:
505:     ca[0] = 1.0; cb[0] = 0.0; cg[0] = 0.0;
506:     for (k=1;k<nmat;k++) {
507:       ca[k] = .5; cb[k] = 0.0; cg[k] = .5;
508:     }
509:     break;
510:   case PEP_BASIS_CHEBYSHEV2:
511:     ca[0] = .5; cb[0] = 0.0; cg[0] = 0.0;
512:     for (k=1;k<nmat;k++) {
513:       ca[k] = .5; cb[k] = 0.0; cg[k] = .5;
514:     }    
515:     break;
516:   case PEP_BASIS_LEGENDRE:
517:     ca[0] = 1.0; cb[0] = 0.0; cg[0] = 0.0;
518:     for (k=1;k<nmat;k++) {
519:       ca[k] = k+1; cb[k] = -2*k; cg[k] = k;
520:     }
521:     break;
522:   case PEP_BASIS_LAGUERRE:
523:     ca[0] = -1.0; cb[0] = 0.0; cg[0] = 0.0;
524:     for (k=1;k<nmat;k++) {
525:       ca[k] = -(k+1); cb[k] = 2*k+1; cg[k] = -k;
526:     }
527:     break;
528:   case PEP_BASIS_HERMITE:
529:     ca[0] = .5; cb[0] = 0.0; cg[0] = 0.0;
530:     for (k=1;k<nmat;k++) {
531:       ca[k] = .5; cb[k] = 0.0; cg[k] = -k;
532:     }
533:     break;
534:   default:
535:     SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'basis' value");
536:   }
537:   return(0);
538: }

542: /*
543:    PEPEvaluateBasis - evaluate the polynomial basis on a given parameter sigma
544: */
545: PetscErrorCode PEPEvaluateBasis(PEP pep,PetscScalar sigma,PetscScalar isigma,PetscScalar *vals,PetscScalar *ivals)
546: {
547:   PetscInt   nmat=pep->nmat,k;
548:   PetscReal  *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat;
549:   
551:   if (ivals) for (k=0;k<nmat;k++) ivals[k] = 0.0;
552:   vals[0] = 1.0;
553:   vals[1] = (sigma-b[0])/a[0];
554: #if !defined(PETSC_USE_COMPLEX)
555:   if (ivals) ivals[1] = isigma/a[0];
556: #endif
557:   for (k=2;k<nmat;k++) {
558:     vals[k] = ((sigma-b[k-1])*vals[k-1]-g[k-1]*vals[k-2])/a[k-1];
559:     if (ivals) vals[k] -= isigma*ivals[k-1]/a[k-1];
560: #if !defined(PETSC_USE_COMPLEX)
561:     if (ivals) ivals[k] = ((sigma-b[k-1])*ivals[k-1]+isigma*vals[k-1]-g[k-1]*ivals[k-2])/a[k-1];
562: #endif
563:   }
564:   return(0);
565: }

slepc-3.7.4/src/pep/examples/0000755000175000017500000000000013107004621015354 5ustar jromanjromanslepc-3.7.4/src/pep/examples/makefile0000644000175000017500000000202513107004621017053 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: LOCDIR = src/pep/examples/ DIRS = tests tutorials nlevp include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/examples/makefile.html0000644000175000017500000000443213107004621020022 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL:

LOCDIR   = src/pep/examples/
DIRS     = tests tutorials nlevp

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/pep/examples/nlevp/0000755000175000017500000000000013107004621016500 5ustar jromanjromanslepc-3.7.4/src/pep/examples/nlevp/makefile0000644000175000017500000001244313107004621020204 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/pep/examples/nlevp/ EXAMPLESC = acoustic_wave_1d.c acoustic_wave_2d.c butterfly.c damped_beam.c \ pdde_stability.c planar_waveguide.c sleeper.c spring.c EXAMPLESF = MANSEC = PEP TESTS = acoustic_wave_1d acoustic_wave_2d butterfly damped_beam \ pdde_stability planar_waveguide sleeper spring TESTEXAMPLES_C = acoustic_wave_1d.PETSc runacoustic_wave_1d_1 acoustic_wave_1d.rm \ acoustic_wave_2d.PETSc runacoustic_wave_2d_1 acoustic_wave_2d.rm \ butterfly.PETSc runbutterfly butterfly.rm \ damped_beam.PETSc rundamped_beam damped_beam.rm \ planar_waveguide.PETSc runplanar_waveguide planar_waveguide.rm \ sleeper.PETSc runsleeper sleeper.rm \ spring.PETSc runspring spring.rm TESTEXAMPLES_C_COMPLEX = pdde_stability.PETSc runpdde_stability pdde_stability.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common acoustic_wave_1d: acoustic_wave_1d.o chkopts -${CLINKER} -o acoustic_wave_1d acoustic_wave_1d.o ${SLEPC_PEP_LIB} ${RM} acoustic_wave_1d.o acoustic_wave_2d: acoustic_wave_2d.o chkopts -${CLINKER} -o acoustic_wave_2d acoustic_wave_2d.o ${SLEPC_PEP_LIB} ${RM} acoustic_wave_2d.o butterfly: butterfly.o chkopts -${CLINKER} -o butterfly butterfly.o ${SLEPC_PEP_LIB} ${RM} butterfly.o damped_beam: damped_beam.o chkopts -${CLINKER} -o damped_beam damped_beam.o ${SLEPC_PEP_LIB} ${RM} damped_beam.o pdde_stability: pdde_stability.o chkopts -${CLINKER} -o pdde_stability pdde_stability.o ${SLEPC_PEP_LIB} ${RM} pdde_stability.o planar_waveguide: planar_waveguide.o chkopts -${CLINKER} -o planar_waveguide planar_waveguide.o ${SLEPC_PEP_LIB} ${RM} planar_waveguide.o sleeper: sleeper.o chkopts -${CLINKER} -o sleeper sleeper.o ${SLEPC_PEP_LIB} ${RM} sleeper.o spring: spring.o chkopts -${CLINKER} -o spring spring.o ${SLEPC_PEP_LIB} ${RM} spring.o #------------------------------------------------------------------------------------ runacoustic_wave_1d_1: -@${MPIEXEC} -n 1 ./acoustic_wave_1d -pep_nev 4 -pep_tol 1e-7 -n 24 -st_type sinvert -terse > acoustic_wave_1d_1.tmp 2>&1; \ if (${DIFF} output/acoustic_wave_1d_1.out acoustic_wave_1d_1.tmp) then true; \ else echo "Possible problem with acoustic_wave_1d_1, diffs above"; fi; \ ${RM} -f acoustic_wave_1d_1.tmp runacoustic_wave_2d_1: -@${MPIEXEC} -n 1 ./acoustic_wave_2d -pep_nev 2 -terse > acoustic_wave_2d_1.tmp 2>&1; \ if (${DIFF} output/acoustic_wave_2d_1.out acoustic_wave_2d_1.tmp) then true; \ else echo "Possible problem with acoustic_wave_2d_1, diffs above"; fi; \ ${RM} -f acoustic_wave_2d_1.tmp runbutterfly: -@${MPIEXEC} -n 1 ./butterfly -pep_nev 4 -st_type sinvert -pep_target 0.01 -terse > butterfly_1.tmp 2>&1; \ if (${DIFF} output/butterfly_1.out butterfly_1.tmp) then true; \ else echo "Possible problem with butterfly_1, diffs above"; fi; \ ${RM} -f butterfly_1.tmp rundamped_beam: -@${MPIEXEC} -n 1 ./damped_beam -pep_nev 2 -pep_ncv 12 -st_type sinvert -pep_target -7 -terse > damped_beam_1.tmp 2>&1; \ if (${DIFF} output/damped_beam_1.out damped_beam_1.tmp) then true; \ else echo "Possible problem with damped_beam_1, diffs above"; fi; \ ${RM} -f damped_beam_1.tmp runpdde_stability: -@${MPIEXEC} -n 1 ./pdde_stability -terse > pdde_stability_1.tmp 2>&1; \ if (${DIFF} output/pdde_stability_1.out pdde_stability_1.tmp) then true; \ else echo "Possible problem with pdde_stability_1, diffs above"; fi; \ ${RM} -f pdde_stability_1.tmp runplanar_waveguide: -@${MPIEXEC} -n 1 ./planar_waveguide -pep_nev 4 -st_type sinvert -terse > planar_waveguide_1.tmp 2>&1; \ if (${DIFF} output/planar_waveguide_1.out planar_waveguide_1.tmp) then true; \ else echo "Possible problem with planar_waveguide_1, diffs above"; fi; \ ${RM} -f planar_waveguide_1.tmp runsleeper: -@${MPIEXEC} -n 1 ./sleeper -pep_nev 4 -pep_ncv 24 -st_type sinvert -n 100 -terse > sleeper_1.tmp 2>&1; \ if (${DIFF} output/sleeper_1.out sleeper_1.tmp) then true; \ else echo "Possible problem with sleeper_1, diffs above"; fi; \ ${RM} -f sleeper_1.tmp runspring: -@${MPIEXEC} -n 1 ./spring -pep_nev 4 -n 24 -st_type sinvert -pep_ncv 18 -terse > spring_1.tmp 2>&1; \ if (${DIFF} output/spring_1.out spring_1.tmp) then true; \ else echo "Possible problem with spring_1, diffs above"; fi; \ ${RM} -f spring_1.tmp slepc-3.7.4/src/pep/examples/nlevp/spring.c.html0000644000175000017500000003027413107004621021117 0ustar jromanjroman
Actual source code: spring.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The spring problem is a QEP from the finite element model of a damped
 30:    mass-spring system. This implementation supports only scalar parameters,
 31:    that is all masses, dampers and springs have the same constants.
 32:    Furthermore, this implementation does not consider different constants
 33:    for dampers and springs connecting adjacent masses or masses to the ground.
 34: */

 36: static char help[] = "FEM model of a damped mass-spring system.\n\n"
 37:   "The command line options are:\n"
 38:   "  -n <n> ... dimension of the matrices.\n"
 39:   "  -mu <value> ... mass (default 1).\n"
 40:   "  -tau <value> ... damping constant of the dampers (default 10).\n"
 41:   "  -kappa <value> ... damping constant of the springs (default 5).\n\n";

 43: #include <slepcpep.h>

 47: int main(int argc,char **argv)
 48: {
 49:   Mat            M,C,K,A[3];      /* problem matrices */
 50:   PEP            pep;             /* polynomial eigenproblem solver context */
 51:   PetscInt       n=5,Istart,Iend,i;
 52:   PetscReal      mu=1,tau=10,kappa=5;
 53:   PetscBool      terse;

 56:   SlepcInitialize(&argc,&argv,(char*)0,help);

 58:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 59:   PetscOptionsGetReal(NULL,NULL,"-mu",&mu,NULL);
 60:   PetscOptionsGetReal(NULL,NULL,"-tau",&tau,NULL);
 61:   PetscOptionsGetReal(NULL,NULL,"-kappa",&kappa,NULL);
 62:   PetscPrintf(PETSC_COMM_WORLD,"\nDamped mass-spring system, n=%D mu=%g tau=%g kappa=%g\n\n",n,(double)mu,(double)tau,(double)kappa);

 64:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 65:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 66:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 68:   /* K is a tridiagonal */
 69:   MatCreate(PETSC_COMM_WORLD,&K);
 70:   MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);
 71:   MatSetFromOptions(K);
 72:   MatSetUp(K);
 73:   
 74:   MatGetOwnershipRange(K,&Istart,&Iend);
 75:   for (i=Istart;i<Iend;i++) {
 76:     if (i>0) {
 77:       MatSetValue(K,i,i-1,-kappa,INSERT_VALUES);
 78:     }
 79:     MatSetValue(K,i,i,kappa*3.0,INSERT_VALUES);
 80:     if (i<n-1) {
 81:       MatSetValue(K,i,i+1,-kappa,INSERT_VALUES);
 82:     }
 83:   }

 85:   MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY);
 86:   MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY);

 88:   /* C is a tridiagonal */
 89:   MatCreate(PETSC_COMM_WORLD,&C);
 90:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n);
 91:   MatSetFromOptions(C);
 92:   MatSetUp(C);
 93:   
 94:   MatGetOwnershipRange(C,&Istart,&Iend);
 95:   for (i=Istart;i<Iend;i++) {
 96:     if (i>0) {
 97:       MatSetValue(C,i,i-1,-tau,INSERT_VALUES);
 98:     }
 99:     MatSetValue(C,i,i,tau*3.0,INSERT_VALUES);
100:     if (i<n-1) {
101:       MatSetValue(C,i,i+1,-tau,INSERT_VALUES);
102:     }
103:   }

105:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
106:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
107:   
108:   /* M is a diagonal matrix */
109:   MatCreate(PETSC_COMM_WORLD,&M);
110:   MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,n,n);
111:   MatSetFromOptions(M);
112:   MatSetUp(M);
113:   MatGetOwnershipRange(M,&Istart,&Iend);
114:   for (i=Istart;i<Iend;i++) {
115:     MatSetValue(M,i,i,mu,INSERT_VALUES);
116:   }
117:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
118:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);

120:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
121:                 Create the eigensolver and solve the problem
122:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

124:   PEPCreate(PETSC_COMM_WORLD,&pep);
125:   A[0] = K; A[1] = C; A[2] = M;
126:   PEPSetOperators(pep,3,A);
127:   PEPSetFromOptions(pep);
128:   PEPSolve(pep);

130:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131:                     Display solution and clean up
132:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
133:   
134:   /* show detailed info unless -terse option is given by user */
135:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
136:   if (terse) {
137:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
138:   } else {
139:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
140:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
141:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
142:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
143:   }
144:   PEPDestroy(&pep);
145:   MatDestroy(&M);
146:   MatDestroy(&C);
147:   MatDestroy(&K);
148:   SlepcFinalize();
149:   return ierr;
150: }
slepc-3.7.4/src/pep/examples/nlevp/makefile.html0000644000175000017500000002010013107004621021134 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/pep/examples/nlevp/
EXAMPLESC  = acoustic_wave_1d.c acoustic_wave_2d.c butterfly.c damped_beam.c \
             pdde_stability.c planar_waveguide.c sleeper.c spring.c
EXAMPLESF  = 
MANSEC     = PEP
TESTS      = acoustic_wave_1d acoustic_wave_2d butterfly damped_beam \
             pdde_stability planar_waveguide sleeper spring

TESTEXAMPLES_C = acoustic_wave_1d.PETSc runacoustic_wave_1d_1 acoustic_wave_1d.rm \
                 acoustic_wave_2d.PETSc runacoustic_wave_2d_1 acoustic_wave_2d.rm \
                 butterfly.PETSc runbutterfly butterfly.rm \
                 damped_beam.PETSc rundamped_beam damped_beam.rm \
                 planar_waveguide.PETSc runplanar_waveguide planar_waveguide.rm \
                 sleeper.PETSc runsleeper sleeper.rm \
                 spring.PETSc runspring spring.rm
TESTEXAMPLES_C_COMPLEX = pdde_stability.PETSc runpdde_stability pdde_stability.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

acoustic_wave_1d: acoustic_wave_1d.o chkopts
	-${CLINKER} -o acoustic_wave_1d acoustic_wave_1d.o ${SLEPC_PEP_LIB}
	${RM} acoustic_wave_1d.o

acoustic_wave_2d: acoustic_wave_2d.o chkopts
	-${CLINKER} -o acoustic_wave_2d acoustic_wave_2d.o ${SLEPC_PEP_LIB}
	${RM} acoustic_wave_2d.o

butterfly: butterfly.o chkopts
	-${CLINKER} -o butterfly butterfly.o ${SLEPC_PEP_LIB}
	${RM} butterfly.o

damped_beam: damped_beam.o chkopts
	-${CLINKER} -o damped_beam damped_beam.o ${SLEPC_PEP_LIB}
	${RM} damped_beam.o

pdde_stability: pdde_stability.o chkopts
	-${CLINKER} -o pdde_stability pdde_stability.o ${SLEPC_PEP_LIB}
	${RM} pdde_stability.o

planar_waveguide: planar_waveguide.o chkopts
	-${CLINKER} -o planar_waveguide planar_waveguide.o ${SLEPC_PEP_LIB}
	${RM} planar_waveguide.o

sleeper: sleeper.o chkopts
	-${CLINKER} -o sleeper sleeper.o ${SLEPC_PEP_LIB}
	${RM} sleeper.o

spring: spring.o chkopts
	-${CLINKER} -o spring spring.o ${SLEPC_PEP_LIB}
	${RM} spring.o

#------------------------------------------------------------------------------------
runacoustic_wave_1d_1:
	-@${MPIEXEC} -n 1 ./acoustic_wave_1d -pep_nev 4 -pep_tol 1e-7 -n 24 -st_type sinvert -terse > acoustic_wave_1d_1.tmp 2>&1; \
	   if (${DIFF} output/acoustic_wave_1d_1.out acoustic_wave_1d_1.tmp) then true; \
	   else echo "Possible problem with acoustic_wave_1d_1, diffs above"; fi; \
	   ${RM} -f acoustic_wave_1d_1.tmp

runacoustic_wave_2d_1:
	-@${MPIEXEC} -n 1 ./acoustic_wave_2d -pep_nev 2 -terse > acoustic_wave_2d_1.tmp 2>&1; \
	   if (${DIFF} output/acoustic_wave_2d_1.out acoustic_wave_2d_1.tmp) then true; \
	   else echo "Possible problem with acoustic_wave_2d_1, diffs above"; fi; \
	   ${RM} -f acoustic_wave_2d_1.tmp

runbutterfly:
	-@${MPIEXEC} -n 1 ./butterfly -pep_nev 4 -st_type sinvert -pep_target 0.01 -terse > butterfly_1.tmp 2>&1; \
	   if (${DIFF} output/butterfly_1.out butterfly_1.tmp) then true; \
	   else echo "Possible problem with butterfly_1, diffs above"; fi; \
	   ${RM} -f butterfly_1.tmp

rundamped_beam:
	-@${MPIEXEC} -n 1 ./damped_beam -pep_nev 2 -pep_ncv 12 -st_type sinvert -pep_target -7 -terse > damped_beam_1.tmp 2>&1; \
	   if (${DIFF} output/damped_beam_1.out damped_beam_1.tmp) then true; \
	   else echo "Possible problem with damped_beam_1, diffs above"; fi; \
	   ${RM} -f damped_beam_1.tmp

runpdde_stability:
	-@${MPIEXEC} -n 1 ./pdde_stability -terse > pdde_stability_1.tmp 2>&1; \
	   if (${DIFF} output/pdde_stability_1.out pdde_stability_1.tmp) then true; \
	   else echo "Possible problem with pdde_stability_1, diffs above"; fi; \
	   ${RM} -f pdde_stability_1.tmp

runplanar_waveguide:
	-@${MPIEXEC} -n 1 ./planar_waveguide -pep_nev 4 -st_type sinvert -terse > planar_waveguide_1.tmp 2>&1; \
	   if (${DIFF} output/planar_waveguide_1.out planar_waveguide_1.tmp) then true; \
	   else echo "Possible problem with planar_waveguide_1, diffs above"; fi; \
	   ${RM} -f planar_waveguide_1.tmp

runsleeper:
	-@${MPIEXEC} -n 1 ./sleeper -pep_nev 4 -pep_ncv 24 -st_type sinvert -n 100 -terse > sleeper_1.tmp 2>&1; \
	   if (${DIFF} output/sleeper_1.out sleeper_1.tmp) then true; \
	   else echo "Possible problem with sleeper_1, diffs above"; fi; \
	   ${RM} -f sleeper_1.tmp

runspring:
	-@${MPIEXEC} -n 1 ./spring -pep_nev 4 -n 24 -st_type sinvert -pep_ncv 18 -terse > spring_1.tmp 2>&1; \
	   if (${DIFF} output/spring_1.out spring_1.tmp) then true; \
	   else echo "Possible problem with spring_1, diffs above"; fi; \
	   ${RM} -f spring_1.tmp

slepc-3.7.4/src/pep/examples/nlevp/spring.c0000644000175000017500000001440613107004621020153 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The spring problem is a QEP from the finite element model of a damped mass-spring system. This implementation supports only scalar parameters, that is all masses, dampers and springs have the same constants. Furthermore, this implementation does not consider different constants for dampers and springs connecting adjacent masses or masses to the ground. */ static char help[] = "FEM model of a damped mass-spring system.\n\n" "The command line options are:\n" " -n ... dimension of the matrices.\n" " -mu ... mass (default 1).\n" " -tau ... damping constant of the dampers (default 10).\n" " -kappa ... damping constant of the springs (default 5).\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PetscInt n=5,Istart,Iend,i; PetscReal mu=1,tau=10,kappa=5; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-mu",&mu,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-tau",&tau,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetReal(NULL,NULL,"-kappa",&kappa,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nDamped mass-spring system, n=%D mu=%g tau=%g kappa=%g\n\n",n,(double)mu,(double)tau,(double)kappa);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is a tridiagonal */ ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr); ierr = MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatSetUp(K);CHKERRQ(ierr); ierr = MatGetOwnershipRange(K,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(K,i,i-1,-kappa,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(K,i,i,kappa*3.0,INSERT_VALUES);CHKERRQ(ierr); if (i0) { ierr = MatSetValue(C,i,i-1,-tau,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(C,i,i,tau*3.0,INSERT_VALUES);CHKERRQ(ierr); if (i. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The planar_waveguide problem is a quartic PEP with symmetric matrices, arising from a finite element solution of the propagation constants in a six-layer planar waveguide. */ static char help[] = "FEM solution of the propagation constants in a six-layer planar waveguide.\n\n" "The command line options are:\n" " -n , the dimension of the matrices.\n\n"; #include #define NMAT 5 #define NL 6 #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A[NMAT]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PetscInt n=128,nlocal,k,Istart,Iend,i,j,start_ct,end_ct; PetscReal w=9.92918,a=0.0,b=2.0,h,deltasq; PetscReal nref[NL],K2[NL],q[NL],*md,*supd,*subd; PetscScalar v,alpha; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); n = (n/4)*4; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nPlanar waveguide, n=%D\n\n",n+1);CHKERRQ(ierr); h = (b-a)/n; nlocal = (n/4)-1; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set waveguide parameters used in construction of matrices - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* refractive indices in each layer */ nref[0] = 1.5; nref[1] = 1.66; nref[2] = 1.6; nref[3] = 1.53; nref[4] = 1.66; nref[5] = 1.0; for (i=0;i0) { ierr = MatSetValue(A[0],i,i-1,alpha,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[2],i,i-1,-alpha,ADD_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[2],i,i-1,subd[i-1]*alpha,ADD_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[4],i,i-1,alpha,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: sleeper.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The sleeper problem is a proportionally damped QEP describing the
 30:    oscillations of a rail track resting on sleepers.
 31: */

 33: static char help[] = "Oscillations of a rail track resting on sleepers.\n\n"
 34:   "The command line options are:\n"
 35:   "  -n <n>, where <n> = dimension of the matrices.\n\n";

 37: #include <slepcpep.h>

 41: int main(int argc,char **argv)
 42: {
 43:   Mat            M,C,K,A[3];      /* problem matrices */
 44:   PEP            pep;             /* polynomial eigenproblem solver context */
 45:   PetscInt       n=10,Istart,Iend,i;
 46:   PetscBool      terse;

 49:   SlepcInitialize(&argc,&argv,(char*)0,help);

 51:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 52:   PetscPrintf(PETSC_COMM_WORLD,"\nRailtrack resting on sleepers, n=%D\n\n",n);

 54:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 55:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 56:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 58:   /* K is a pentadiagonal */
 59:   MatCreate(PETSC_COMM_WORLD,&K);
 60:   MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);
 61:   MatSetFromOptions(K);
 62:   MatSetUp(K);
 63:   
 64:   MatGetOwnershipRange(K,&Istart,&Iend);
 65:   for (i=Istart;i<Iend;i++) {
 66:     if (i==0) { 
 67:       MatSetValue(K,i,n-1,-3.0,INSERT_VALUES);
 68:       MatSetValue(K,i,n-2,1.0,INSERT_VALUES);
 69:     }
 70:     if (i==1) { MatSetValue(K,i,n-1,1.0,INSERT_VALUES); }
 71:     if (i>0) { MatSetValue(K,i,i-1,-3.0,INSERT_VALUES); }
 72:     if (i>1) { MatSetValue(K,i,i-2,1.0,INSERT_VALUES); }
 73:     MatSetValue(K,i,i,5.0,INSERT_VALUES);
 74:     if (i==n-1) { 
 75:       MatSetValue(K,i,0,-3.0,INSERT_VALUES);
 76:       MatSetValue(K,i,1,1.0,INSERT_VALUES);
 77:     }
 78:     if (i==n-2) { MatSetValue(K,i,0,1.0,INSERT_VALUES); }
 79:     if (i<n-1) { MatSetValue(K,i,i+1,-3.0,INSERT_VALUES); }
 80:     if (i<n-2) { MatSetValue(K,i,i+2,1.0,INSERT_VALUES); }
 81:   }

 83:   MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY);
 84:   MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY);

 86:   /* C is a circulant matrix */
 87:   MatCreate(PETSC_COMM_WORLD,&C);
 88:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n);
 89:   MatSetFromOptions(C);
 90:   MatSetUp(C);
 91:   
 92:   MatGetOwnershipRange(C,&Istart,&Iend);
 93:   for (i=Istart;i<Iend;i++) {
 94:     if (i==0) { 
 95:       MatSetValue(C,i,n-1,-4.0,INSERT_VALUES);
 96:       MatSetValue(C,i,n-2,1.0,INSERT_VALUES);
 97:     }
 98:     if (i==1) { MatSetValue(C,i,n-1,1.0,INSERT_VALUES); }
 99:     if (i>0) { MatSetValue(C,i,i-1,-4.0,INSERT_VALUES); }
100:     if (i>1) { MatSetValue(C,i,i-2,1.0,INSERT_VALUES); }
101:     MatSetValue(C,i,i,7.0,INSERT_VALUES);
102:     if (i==n-1) { 
103:       MatSetValue(C,i,0,-4.0,INSERT_VALUES);
104:       MatSetValue(C,i,1,1.0,INSERT_VALUES);
105:     }
106:     if (i==n-2) { MatSetValue(C,i,0,1.0,INSERT_VALUES); }
107:     if (i<n-1) { MatSetValue(C,i,i+1,-4.0,INSERT_VALUES); }
108:     if (i<n-2) { MatSetValue(C,i,i+2,1.0,INSERT_VALUES); }
109:   }

111:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
112:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
113:   
114:   /* M is the identity matrix */
115:   MatCreate(PETSC_COMM_WORLD,&M);
116:   MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,n,n);
117:   MatSetFromOptions(M);
118:   MatSetUp(M);
119:   MatGetOwnershipRange(M,&Istart,&Iend);
120:   for (i=Istart;i<Iend;i++) {
121:     MatSetValue(M,i,i,1.0,INSERT_VALUES);
122:   }
123:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
124:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);

126:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
127:                 Create the eigensolver and solve the problem
128:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

130:   PEPCreate(PETSC_COMM_WORLD,&pep);
131:   A[0] = K; A[1] = C; A[2] = M;
132:   PEPSetOperators(pep,3,A);
133:   PEPSetFromOptions(pep);
134:   PEPSolve(pep);

136:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
137:                     Display solution and clean up
138:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
139:   
140:   /* show detailed info unless -terse option is given by user */
141:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
142:   if (terse) {
143:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
144:   } else {
145:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
146:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
147:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
148:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
149:   }
150:   PEPDestroy(&pep);
151:   MatDestroy(&M);
152:   MatDestroy(&C);
153:   MatDestroy(&K);
154:   SlepcFinalize();
155:   return ierr;
156: }
slepc-3.7.4/src/pep/examples/nlevp/planar_waveguide.c.html0000644000175000017500000003614213107004621023132 0ustar jromanjroman
Actual source code: planar_waveguide.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The planar_waveguide problem is a quartic PEP with symmetric matrices,
 30:    arising from a finite element solution of the propagation constants in a
 31:    six-layer planar waveguide.
 32: */

 34: static char help[] = "FEM solution of the propagation constants in a six-layer planar waveguide.\n\n"
 35:   "The command line options are:\n"
 36:   "  -n <n>, the dimension of the matrices.\n\n";

 38: #include <slepcpep.h>

 40: #define NMAT 5
 41: #define NL   6

 45: int main(int argc,char **argv)
 46: {
 47:   Mat            A[NMAT];         /* problem matrices */
 48:   PEP            pep;             /* polynomial eigenproblem solver context */
 49:   PetscInt       n=128,nlocal,k,Istart,Iend,i,j,start_ct,end_ct;
 50:   PetscReal      w=9.92918,a=0.0,b=2.0,h,deltasq;
 51:   PetscReal      nref[NL],K2[NL],q[NL],*md,*supd,*subd;
 52:   PetscScalar    v,alpha;
 53:   PetscBool      terse;

 56:   SlepcInitialize(&argc,&argv,(char*)0,help);

 58:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 59:   n = (n/4)*4;
 60:   PetscPrintf(PETSC_COMM_WORLD,"\nPlanar waveguide, n=%D\n\n",n+1);
 61:   h = (b-a)/n;
 62:   nlocal = (n/4)-1;

 64:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 65:           Set waveguide parameters used in construction of matrices 
 66:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 68:   /* refractive indices in each layer */
 69:   nref[0] = 1.5;
 70:   nref[1] = 1.66;
 71:   nref[2] = 1.6;
 72:   nref[3] = 1.53;
 73:   nref[4] = 1.66;
 74:   nref[5] = 1.0;

 76:   for (i=0;i<NL;i++) K2[i] = w*w*nref[i]*nref[i];
 77:   deltasq = K2[0] - K2[NL-1];
 78:   for (i=0;i<NL;i++) q[i] = K2[i] - (K2[0] + K2[NL-1])/2;

 80:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 81:                      Compute the polynomial matrices 
 82:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 84:   /* initialize matrices */
 85:   for (i=0;i<NMAT;i++) {
 86:     MatCreate(PETSC_COMM_WORLD,&A[i]);
 87:     MatSetSizes(A[i],PETSC_DECIDE,PETSC_DECIDE,n+1,n+1);
 88:     MatSetFromOptions(A[i]);
 89:     MatSetUp(A[i]);
 90:   }
 91:   MatGetOwnershipRange(A[0],&Istart,&Iend);

 93:   /* A0 */
 94:   alpha = (h/6)*(deltasq*deltasq/16);
 95:   for (i=Istart;i<Iend;i++) {
 96:     v = 4.0;
 97:     if (i==0 || i==n) v = 2.0;
 98:     MatSetValue(A[0],i,i,v*alpha,INSERT_VALUES);
 99:     if (i>0) { MatSetValue(A[0],i,i-1,alpha,INSERT_VALUES); }
100:     if (i<n) { MatSetValue(A[0],i,i+1,alpha,INSERT_VALUES); }
101:   }

103:   /* A1 */
104:   if (Istart==0) { MatSetValue(A[1],0,0,-deltasq/4,INSERT_VALUES); }
105:   if (Iend==n+1) { MatSetValue(A[1],n,n,deltasq/4,INSERT_VALUES); }

107:   /* A2 */
108:   alpha = 1.0/h;
109:   for (i=Istart;i<Iend;i++) {
110:     v = 2.0;
111:     if (i==0 || i==n) v = 1.0;
112:     MatSetValue(A[2],i,i,v*alpha,ADD_VALUES);
113:     if (i>0) { MatSetValue(A[2],i,i-1,-alpha,ADD_VALUES); }
114:     if (i<n) { MatSetValue(A[2],i,i+1,-alpha,ADD_VALUES); }
115:   }
116:   PetscMalloc3(n+1,&md,n+1,&supd,n+1,&subd);

118:   md[0]   = 2.0*q[1];
119:   supd[1] = q[1];
120:   subd[0] = q[1];

122:   for (k=1;k<=NL-2;k++) {

124:     end_ct = k*(nlocal+1);
125:     start_ct = end_ct-nlocal;

127:     for (j=start_ct;j<end_ct;j++) {
128:       md[j] = 4*q[k];
129:       supd[j+1] = q[k];
130:       subd[j] = q[k];
131:     }

133:     if (k < 4) {  /* interface points */
134:       md[end_ct] = 4*(q[k] + q[k+1])/2.0;
135:       supd[end_ct+1] = q[k+1];
136:       subd[end_ct] = q[k+1];
137:     }

139:   }

141:   md[n] = 2*q[NL-2];
142:   supd[n] = q[NL-2];
143:   subd[n] = q[NL-2];

145:   alpha = -h/6.0;
146:   for (i=Istart;i<Iend;i++) {
147:     MatSetValue(A[2],i,i,md[i]*alpha,ADD_VALUES);
148:     if (i>0) { MatSetValue(A[2],i,i-1,subd[i-1]*alpha,ADD_VALUES); }
149:     if (i<n) { MatSetValue(A[2],i,i+1,supd[i+1]*alpha,ADD_VALUES); }
150:   }
151:   PetscFree3(md,supd,subd);

153:   /* A3 */
154:   if (Istart==0) { MatSetValue(A[3],0,0,1.0,INSERT_VALUES); }
155:   if (Iend==n+1) { MatSetValue(A[3],n,n,1.0,INSERT_VALUES); }

157:   /* A4 */
158:   alpha = (h/6);
159:   for (i=Istart;i<Iend;i++) {
160:     v = 4.0;
161:     if (i==0 || i==n) v = 2.0;
162:     MatSetValue(A[4],i,i,v*alpha,INSERT_VALUES);
163:     if (i>0) { MatSetValue(A[4],i,i-1,alpha,INSERT_VALUES); }
164:     if (i<n) { MatSetValue(A[4],i,i+1,alpha,INSERT_VALUES); }
165:   }

167:   /* assemble matrices */
168:   for (i=0;i<NMAT;i++) {
169:     MatAssemblyBegin(A[i],MAT_FINAL_ASSEMBLY);
170:   }
171:   for (i=0;i<NMAT;i++) {
172:     MatAssemblyEnd(A[i],MAT_FINAL_ASSEMBLY);
173:   }

175:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
176:                 Create the eigensolver and solve the problem
177:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

179:   PEPCreate(PETSC_COMM_WORLD,&pep);
180:   PEPSetOperators(pep,NMAT,A);
181:   PEPSetFromOptions(pep);
182:   PEPSolve(pep);

184:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
185:                     Display solution and clean up
186:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
187:   
188:   /* show detailed info unless -terse option is given by user */
189:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
190:   if (terse) {
191:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
192:   } else {
193:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
194:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
195:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
196:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
197:   }
198:   PEPDestroy(&pep);
199:   for (i=0;i<NMAT;i++) {
200:     MatDestroy(&A[i]);
201:   }
202:   SlepcFinalize();
203:   return ierr;
204: }
slepc-3.7.4/src/pep/examples/nlevp/butterfly.c0000644000175000017500000001544213107004621020672 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The butterfly problem is a quartic PEP with T-even structure. */ static char help[] = "Quartic polynomial eigenproblem with T-even structure.\n\n" "The command line options are:\n" " -m , grid size, the dimension of the matrices is n=m*m.\n" " -c , problem parameters, must be 10 comma-separated real values.\n\n"; #include #define NMAT 5 #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A[NMAT]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PetscInt n,m=8,k,II,Istart,Iend,i,j; PetscReal c[10] = { 0.6, 1.3, 1.3, 0.1, 0.1, 1.2, 1.0, 1.0, 1.2, 1.0 }; PetscBool flg; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); n = m*m; k = 10; ierr = PetscOptionsGetRealArray(NULL,NULL,"-c",c,&k,&flg);CHKERRQ(ierr); if (flg && k!=10) SETERRQ1(PETSC_COMM_WORLD,1,"The number of parameters -c should be 10, you provided %D",k); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nButterfly problem, n=%D (m=%D)\n\n",n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the polynomial matrices - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* initialize matrices */ for (i=0;i0) { ierr = MatSetValue(A[0],II,II-1,c[0]/6.0,INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(A[0],II,II-m,c[1]/6.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[1],II,II-1,c[2],INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(A[1],II,II-m,c[3],INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[2],II,II-1,c[4],INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(A[2],II,II-m,c[5],INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[3],II,II-1,c[6],INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(A[3],II,II-m,c[7],INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(A[4],II,II-1,-c[8],INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(A[4],II,II-m,-c[9],INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: pdde_stability.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The pdde_stability problem is a complex-symmetric QEP from the stability
 30:    analysis of a discretized partial delay-differential equation. It requires
 31:    complex scalars.
 32: */

 34: static char help[] = "Stability analysis of a discretized partial delay-differential equation.\n\n"
 35:   "The command line options are:\n"
 36:   "  -m <m>, grid size, the matrices have dimension n=m*m.\n"
 37:   "  -c <a0,b0,a1,b1,a2,b2,phi1>, comma-separated list of 7 real parameters.\n\n";

 39: #include <slepcpep.h>

 41: #define NMAT 3

 45: /*
 46:     Function for user-defined eigenvalue ordering criterion.

 48:     Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose
 49:     one of them as the preferred one according to the criterion.
 50:     In this example, the preferred value is the one with absolute value closest to 1.
 51: */
 52: PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)
 53: {
 54:   PetscReal aa,ab;

 57:   aa = PetscAbsReal(SlepcAbsEigenvalue(ar,ai)-1.0);
 58:   ab = PetscAbsReal(SlepcAbsEigenvalue(br,bi)-1.0);
 59:   *r = aa > ab ? 1 : (aa < ab ? -1 : 0);
 60:   return(0);
 61: }

 65: int main(int argc,char **argv)
 66: {
 67:   Mat            A[NMAT];         /* problem matrices */
 68:   PEP            pep;             /* polynomial eigenproblem solver context */
 69:   PetscInt       m=15,n,II,Istart,Iend,i,j,k;
 70:   PetscReal      h,xi,xj,c[7] = { 2, .3, -2, .2, -2, -.3, -PETSC_PI/2 };
 71:   PetscScalar    alpha,beta,gamma;
 72:   PetscBool      flg,terse;

 75:   SlepcInitialize(&argc,&argv,(char*)0,help);
 76: #if !defined(PETSC_USE_COMPLEX)
 77:   SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP, "This example requires complex scalars");
 78: #endif

 80:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 81:   n = m*m;
 82:   h = PETSC_PI/(m+1);
 83:   gamma = PetscExpScalar(PETSC_i*c[6]);
 84:   gamma = gamma/PetscAbsScalar(gamma);
 85:   k = 7;
 86:   PetscOptionsGetRealArray(NULL,NULL,"-c",c,&k,&flg);
 87:   if (flg && k!=7) SETERRQ1(PETSC_COMM_WORLD,1,"The number of parameters -c should be 7, you provided %D",k); 
 88:   PetscPrintf(PETSC_COMM_WORLD,"\nPDDE stability, n=%D (m=%D)\n\n",n,m);

 90:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 91:                      Compute the polynomial matrices 
 92:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 94:   /* initialize matrices */
 95:   for (i=0;i<NMAT;i++) {
 96:     MatCreate(PETSC_COMM_WORLD,&A[i]);
 97:     MatSetSizes(A[i],PETSC_DECIDE,PETSC_DECIDE,n,n);
 98:     MatSetFromOptions(A[i]);
 99:     MatSetUp(A[i]);
100:   }
101:   MatGetOwnershipRange(A[0],&Istart,&Iend);

103:   /* A[1] has a pattern similar to the 2D Laplacian */
104:   for (II=Istart;II<Iend;II++) {
105:     i = II/m; j = II-i*m;
106:     xi = (i+1)*h; xj = (j+1)*h;
107:     alpha = c[0]+c[1]*PetscSinReal(xi)+gamma*(c[2]+c[3]*xi*(1.0-PetscExpReal(xi-PETSC_PI)));
108:     beta = c[0]+c[1]*PetscSinReal(xj)-gamma*(c[2]+c[3]*xj*(1.0-PetscExpReal(xj-PETSC_PI)));
109:     MatSetValue(A[1],II,II,alpha+beta-4.0/(h*h),INSERT_VALUES);
110:     if (j>0) { MatSetValue(A[1],II,II-1,1.0/(h*h),INSERT_VALUES); }
111:     if (j<m-1) { MatSetValue(A[1],II,II+1,1.0/(h*h),INSERT_VALUES); }
112:     if (i>0) { MatSetValue(A[1],II,II-m,1.0/(h*h),INSERT_VALUES); }
113:     if (i<m-1) { MatSetValue(A[1],II,II+m,1.0/(h*h),INSERT_VALUES); }
114:   }

116:   /* A[0] and A[2] are diagonal */
117:   for (II=Istart;II<Iend;II++) {
118:     i = II/m; j = II-i*m;
119:     xi = (i+1)*h; xj = (j+1)*h;
120:     alpha = c[4]+c[5]*xi*(PETSC_PI-xi);
121:     beta = c[4]+c[5]*xj*(PETSC_PI-xj);
122:     MatSetValue(A[0],II,II,alpha,INSERT_VALUES);
123:     MatSetValue(A[2],II,II,beta,INSERT_VALUES);
124:   }
125:   
126:   /* assemble matrices */
127:   for (i=0;i<NMAT;i++) {
128:     MatAssemblyBegin(A[i],MAT_FINAL_ASSEMBLY);
129:   }
130:   for (i=0;i<NMAT;i++) {
131:     MatAssemblyEnd(A[i],MAT_FINAL_ASSEMBLY);
132:   }

134:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
135:                 Create the eigensolver and solve the problem
136:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

138:   PEPCreate(PETSC_COMM_WORLD,&pep);
139:   PEPSetOperators(pep,NMAT,A);
140:   PEPSetEigenvalueComparison(pep,MyEigenSort,NULL);
141:   PEPSetDimensions(pep,4,PETSC_DEFAULT,PETSC_DEFAULT);
142:   PEPSetFromOptions(pep);
143:   PEPSolve(pep);

145:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
146:                     Display solution and clean up
147:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
148:   
149:   /* show detailed info unless -terse option is given by user */
150:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
151:   if (terse) {
152:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
153:   } else {
154:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
155:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
156:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
157:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
158:   }
159:   PEPDestroy(&pep);
160:   for (i=0;i<NMAT;i++) {
161:     MatDestroy(&A[i]);
162:   }
163:   SlepcFinalize();
164:   return ierr;
165: }
slepc-3.7.4/src/pep/examples/nlevp/output/0000755000175000017500000000000013107004621020040 5ustar jromanjromanslepc-3.7.4/src/pep/examples/nlevp/output/spring_1.out0000644000175000017500000000025013107004621022310 0ustar jromanjroman Damped mass-spring system, n=24 mu=1. tau=10. kappa=5. All requested eigenvalues computed up to the required tolerance: -0.50512, -0.50517, -0.50525, -0.50537 slepc-3.7.4/src/pep/examples/nlevp/output/pdde_stability_1.out0000644000175000017500000000026013107004621024007 0ustar jromanjroman PDDE stability, n=225 (m=15) All requested eigenvalues computed up to the required tolerance: 0.47542+0.87976i, 0.47479-0.88010i, -0.68925-0.72452i, -0.68870+0.72504i slepc-3.7.4/src/pep/examples/nlevp/output/butterfly_1.out0000644000175000017500000000026113107004621023030 0ustar jromanjroman Butterfly problem, n=64 (m=8) All requested eigenvalues computed up to the required tolerance: 0.26912+0.23699i, 0.26912-0.23699i, -0.26912+0.23699i, -0.26912-0.23699i slepc-3.7.4/src/pep/examples/nlevp/output/acoustic_wave_2d_1.out0000644000175000017500000000022113107004621024225 0ustar jromanjroman Acoustic wave 2-D, n=30 (m=6), z=1. All requested eigenvalues computed up to the required tolerance: 0.00536+2.60937i, 0.00536-2.60937i slepc-3.7.4/src/pep/examples/nlevp/output/damped_beam_1.out0000644000175000017500000000025613107004621023232 0ustar jromanjroman Simply supported beam damped in the middle, n=200 (nele=100) All requested eigenvalues computed up to the required tolerance: -7.42298+72.23065i, -7.42298-72.23065i slepc-3.7.4/src/pep/examples/nlevp/output/acoustic_wave_1d_1.out0000644000175000017500000000025613107004621024234 0ustar jromanjroman Acoustic wave 1-D, n=24 z=1. All requested eigenvalues computed up to the required tolerance: 0.52633+0.19430i, 0.52633-0.19430i, 0.47425+0.60655i, 0.47425-0.60655i slepc-3.7.4/src/pep/examples/nlevp/output/planar_waveguide_1.out0000644000175000017500000000025313107004621024326 0ustar jromanjroman Planar waveguide, n=129 All requested eigenvalues computed up to the required tolerance: -0.00000+0.13912i, -0.00000-0.13912i, 0.00000+0.13923i, 0.00000-0.13923i slepc-3.7.4/src/pep/examples/nlevp/output/sleeper_1.out0000644000175000017500000000022613107004621022450 0ustar jromanjroman Railtrack resting on sleepers, n=100 All requested eigenvalues computed up to the required tolerance: -0.68106, -0.68121, -0.68457, -0.68751 slepc-3.7.4/src/pep/examples/nlevp/acoustic_wave_1d.c.html0000644000175000017500000002754613107004621023045 0ustar jromanjroman
Actual source code: acoustic_wave_1d.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The acoustic_wave_1d problem is a QEP from an acoustics application.
 30:    Here we solve it with the eigenvalue scaled by the imaginary unit, to be
 31:    able to use real arithmetic, so the computed eigenvalues should be scaled
 32:    back.
 33: */

 35: static char help[] = "Quadratic eigenproblem from an acoustics application (1-D).\n\n"
 36:   "The command line options are:\n"
 37:   "  -n <n>, where <n> = dimension of the matrices.\n"
 38:   "  -z <z>, where <z> = impedance (default 1.0).\n\n";

 40: #include <slepcpep.h>

 44: int main(int argc,char **argv)
 45: {
 46:   Mat            M,C,K,A[3];      /* problem matrices */
 47:   PEP            pep;             /* polynomial eigenproblem solver context */
 48:   PetscInt       n=10,Istart,Iend,i;
 49:   PetscScalar    z=1.0;
 50:   char           str[50];
 51:   PetscBool      terse;

 54:   SlepcInitialize(&argc,&argv,(char*)0,help);

 56:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 57:   PetscOptionsGetScalar(NULL,NULL,"-z",&z,NULL);
 58:   SlepcSNPrintfScalar(str,50,z,PETSC_FALSE);
 59:   PetscPrintf(PETSC_COMM_WORLD,"\nAcoustic wave 1-D, n=%D z=%s\n\n",n,str);

 61:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 62:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 63:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 65:   /* K is a tridiagonal */
 66:   MatCreate(PETSC_COMM_WORLD,&K);
 67:   MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);
 68:   MatSetFromOptions(K);
 69:   MatSetUp(K);
 70:   
 71:   MatGetOwnershipRange(K,&Istart,&Iend);
 72:   for (i=Istart;i<Iend;i++) {
 73:     if (i>0) {
 74:       MatSetValue(K,i,i-1,-1.0*n,INSERT_VALUES);
 75:     }
 76:     if (i<n-1) {
 77:       MatSetValue(K,i,i,2.0*n,INSERT_VALUES);
 78:       MatSetValue(K,i,i+1,-1.0*n,INSERT_VALUES);
 79:     } else {
 80:       MatSetValue(K,i,i,1.0*n,INSERT_VALUES);
 81:     }
 82:   }

 84:   MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY);
 85:   MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY);

 87:   /* C is the zero matrix but one element*/
 88:   MatCreate(PETSC_COMM_WORLD,&C);
 89:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n);
 90:   MatSetFromOptions(C);
 91:   MatSetUp(C);

 93:   MatGetOwnershipRange(C,&Istart,&Iend);
 94:   if (n-1>=Istart && n-1<Iend) { 
 95:     MatSetValue(C,n-1,n-1,-2*PETSC_PI/z,INSERT_VALUES);
 96:   }
 97:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
 98:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
 99:   
100:   /* M is a diagonal matrix */
101:   MatCreate(PETSC_COMM_WORLD,&M);
102:   MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,n,n);
103:   MatSetFromOptions(M);
104:   MatSetUp(M);

106:   MatGetOwnershipRange(M,&Istart,&Iend);
107:   for (i=Istart;i<Iend;i++) {
108:     if (i<n-1) {
109:       MatSetValue(M,i,i,4*PETSC_PI*PETSC_PI/n,INSERT_VALUES);
110:     } else {
111:       MatSetValue(M,i,i,2*PETSC_PI*PETSC_PI/n,INSERT_VALUES);
112:     }
113:   }
114:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
115:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);
116:   
117:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
118:                 Create the eigensolver and solve the problem
119:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

121:   PEPCreate(PETSC_COMM_WORLD,&pep);
122:   A[0] = K; A[1] = C; A[2] = M;
123:   PEPSetOperators(pep,3,A);
124:   PEPSetFromOptions(pep);
125:   PEPSolve(pep);

127:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
128:                     Display solution and clean up
129:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
130:   
131:   /* show detailed info unless -terse option is given by user */
132:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
133:   if (terse) {
134:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
135:   } else {
136:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
137:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
138:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
139:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
140:   }
141:   PEPDestroy(&pep);
142:   MatDestroy(&M);
143:   MatDestroy(&C);
144:   MatDestroy(&K);
145:   SlepcFinalize();
146:   return ierr;
147: }
slepc-3.7.4/src/pep/examples/nlevp/index.html0000644000175000017500000000461313107004621020501 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

acoustic_wave_1d.c: Quadratic eigenproblem from an acoustics application (1-D)
acoustic_wave_2d.c: Quadratic eigenproblem from an acoustics application (2-D)
butterfly.c: Quartic polynomial eigenproblem with T-even structure
damped_beam.c: Quadratic eigenproblem from the vibrarion analysis of a beam
pdde_stability.c: Stability analysis of a discretized partial delay-differential equation
planar_waveguide.c: FEM solution of the propagation constants in a six-layer planar waveguide
sleeper.c: Oscillations of a rail track resting on sleepers
spring.c: FEM model of a damped mass-spring system
makefile
slepc-3.7.4/src/pep/examples/nlevp/damped_beam.c0000644000175000017500000001747213107004621021075 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The damped_beam problem is a QEP from the vibrarion analysis of a beam simply supported at both ends and damped in the middle. */ static char help[] = "Quadratic eigenproblem from the vibrarion analysis of a beam.\n\n" "The command line options are:\n" " -n ... dimension of the matrices.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,Mo,C,K,Ko,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ IS isf,isbc,is; PetscInt n=200,nele,Istart,Iend,i,j,mloc,nloc,bc[2]; PetscReal width=0.05,height=0.005,glength=1.0,dlen,EI,area,rho; PetscScalar K1[4],K2[4],K2t[4],K3[4],M1[4],M2[4],M2t[4],M3[4],damp=5.0; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); nele = n/2; n = 2*nele; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nSimply supported beam damped in the middle, n=%D (nele=%D)\n\n",n,nele);CHKERRQ(ierr); dlen = glength/nele; EI = 7e10*width*height*height*height/12.0; area = width*height; rho = 0.674/(area*glength); K1[0] = 12; K1[1] = 6*dlen; K1[2] = 6*dlen; K1[3] = 4*dlen*dlen; K2[0] = -12; K2[1] = 6*dlen; K2[2] = -6*dlen; K2[3] = 2*dlen*dlen; K2t[0] = -12; K2t[1] = -6*dlen; K2t[2] = 6*dlen; K2t[3] = 2*dlen*dlen; K3[0] = 12; K3[1] = -6*dlen; K3[2] = -6*dlen; K3[3] = 4*dlen*dlen; M1[0] = 156; M1[1] = 22*dlen; M1[2] = 22*dlen; M1[3] = 4*dlen*dlen; M2[0] = 54; M2[1] = -13*dlen; M2[2] = 13*dlen; M2[3] = -3*dlen*dlen; M2t[0] = 54; M2t[1] = 13*dlen; M2t[2] = -13*dlen; M2t[3] = -3*dlen*dlen; M3[0] = 156; M3[1] = -22*dlen; M3[2] = -22*dlen; M3[3] = 4*dlen*dlen; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is block-tridiagonal */ ierr = MatCreate(PETSC_COMM_WORLD,&Ko);CHKERRQ(ierr); ierr = MatSetSizes(Ko,PETSC_DECIDE,PETSC_DECIDE,n+2,n+2);CHKERRQ(ierr); ierr = MatSetBlockSize(Ko,2);CHKERRQ(ierr); ierr = MatSetFromOptions(Ko);CHKERRQ(ierr); ierr = MatSetUp(Ko);CHKERRQ(ierr); ierr = MatGetOwnershipRange(Ko,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart/2;i0) { j = i-1; ierr = MatSetValuesBlocked(Ko,1,&i,1,&j,K2t,ADD_VALUES);CHKERRQ(ierr); ierr = MatSetValuesBlocked(Ko,1,&i,1,&i,K3,ADD_VALUES);CHKERRQ(ierr); } if (i0) { j = i-1; ierr = MatSetValuesBlocked(Mo,1,&i,1,&j,M2t,ADD_VALUES);CHKERRQ(ierr); ierr = MatSetValuesBlocked(Mo,1,&i,1,&i,M3,ADD_VALUES);CHKERRQ(ierr); } if (i=Istart && nele-1. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The sleeper problem is a proportionally damped QEP describing the oscillations of a rail track resting on sleepers. */ static char help[] = "Oscillations of a rail track resting on sleepers.\n\n" "The command line options are:\n" " -n , where = dimension of the matrices.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PetscInt n=10,Istart,Iend,i; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nRailtrack resting on sleepers, n=%D\n\n",n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is a pentadiagonal */ ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr); ierr = MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatSetUp(K);CHKERRQ(ierr); ierr = MatGetOwnershipRange(K,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(K,i,i-1,-3.0,INSERT_VALUES);CHKERRQ(ierr); } if (i>1) { ierr = MatSetValue(K,i,i-2,1.0,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(K,i,i,5.0,INSERT_VALUES);CHKERRQ(ierr); if (i==n-1) { ierr = MatSetValue(K,i,0,-3.0,INSERT_VALUES);CHKERRQ(ierr); ierr = MatSetValue(K,i,1,1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i==n-2) { ierr = MatSetValue(K,i,0,1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(C,i,i-1,-4.0,INSERT_VALUES);CHKERRQ(ierr); } if (i>1) { ierr = MatSetValue(C,i,i-2,1.0,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(C,i,i,7.0,INSERT_VALUES);CHKERRQ(ierr); if (i==n-1) { ierr = MatSetValue(C,i,0,-4.0,INSERT_VALUES);CHKERRQ(ierr); ierr = MatSetValue(C,i,1,1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i==n-2) { ierr = MatSetValue(C,i,0,1.0,INSERT_VALUES);CHKERRQ(ierr); } if (iActual source code: butterfly.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The butterfly problem is a quartic PEP with T-even structure.
 30: */

 32: static char help[] = "Quartic polynomial eigenproblem with T-even structure.\n\n"
 33:   "The command line options are:\n"
 34:   "  -m <m>, grid size, the dimension of the matrices is n=m*m.\n"
 35:   "  -c <array>, problem parameters, must be 10 comma-separated real values.\n\n";

 37: #include <slepcpep.h>

 39: #define NMAT 5

 43: int main(int argc,char **argv)
 44: {
 45:   Mat            A[NMAT];         /* problem matrices */
 46:   PEP            pep;             /* polynomial eigenproblem solver context */
 47:   PetscInt       n,m=8,k,II,Istart,Iend,i,j;
 48:   PetscReal      c[10] = { 0.6, 1.3, 1.3, 0.1, 0.1, 1.2, 1.0, 1.0, 1.2, 1.0 };
 49:   PetscBool      flg;
 50:   PetscBool      terse;

 53:   SlepcInitialize(&argc,&argv,(char*)0,help);

 55:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 56:   n = m*m;
 57:   k = 10;
 58:   PetscOptionsGetRealArray(NULL,NULL,"-c",c,&k,&flg);
 59:   if (flg && k!=10) SETERRQ1(PETSC_COMM_WORLD,1,"The number of parameters -c should be 10, you provided %D",k); 
 60:   PetscPrintf(PETSC_COMM_WORLD,"\nButterfly problem, n=%D (m=%D)\n\n",n,m);

 62:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 63:                      Compute the polynomial matrices 
 64:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 66:   /* initialize matrices */
 67:   for (i=0;i<NMAT;i++) {
 68:     MatCreate(PETSC_COMM_WORLD,&A[i]);
 69:     MatSetSizes(A[i],PETSC_DECIDE,PETSC_DECIDE,n,n);
 70:     MatSetFromOptions(A[i]);
 71:     MatSetUp(A[i]);
 72:   }
 73:   MatGetOwnershipRange(A[0],&Istart,&Iend);

 75:   /* A0 */
 76:   for (II=Istart;II<Iend;II++) {
 77:     i = II/m; j = II-i*m;
 78:     MatSetValue(A[0],II,II,4.0*c[0]/6.0+4.0*c[1]/6.0,INSERT_VALUES);
 79:     if (j>0) { MatSetValue(A[0],II,II-1,c[0]/6.0,INSERT_VALUES); }
 80:     if (j<m-1) { MatSetValue(A[0],II,II+1,c[0]/6.0,INSERT_VALUES); }
 81:     if (i>0) { MatSetValue(A[0],II,II-m,c[1]/6.0,INSERT_VALUES); }
 82:     if (i<m-1) { MatSetValue(A[0],II,II+m,c[1]/6.0,INSERT_VALUES); }
 83:   }

 85:   /* A1 */
 86:   for (II=Istart;II<Iend;II++) {
 87:     i = II/m; j = II-i*m;
 88:     if (j>0) { MatSetValue(A[1],II,II-1,c[2],INSERT_VALUES); }
 89:     if (j<m-1) { MatSetValue(A[1],II,II+1,-c[2],INSERT_VALUES); }
 90:     if (i>0) { MatSetValue(A[1],II,II-m,c[3],INSERT_VALUES); }
 91:     if (i<m-1) { MatSetValue(A[1],II,II+m,-c[3],INSERT_VALUES); }
 92:   }

 94:   /* A2 */
 95:   for (II=Istart;II<Iend;II++) {
 96:     i = II/m; j = II-i*m;
 97:     MatSetValue(A[2],II,II,-2.0*c[4]-2.0*c[5],INSERT_VALUES);
 98:     if (j>0) { MatSetValue(A[2],II,II-1,c[4],INSERT_VALUES); }
 99:     if (j<m-1) { MatSetValue(A[2],II,II+1,c[4],INSERT_VALUES); }
100:     if (i>0) { MatSetValue(A[2],II,II-m,c[5],INSERT_VALUES); }
101:     if (i<m-1) { MatSetValue(A[2],II,II+m,c[5],INSERT_VALUES); }
102:   }

104:   /* A3 */
105:   for (II=Istart;II<Iend;II++) {
106:     i = II/m; j = II-i*m;
107:     if (j>0) { MatSetValue(A[3],II,II-1,c[6],INSERT_VALUES); }
108:     if (j<m-1) { MatSetValue(A[3],II,II+1,-c[6],INSERT_VALUES); }
109:     if (i>0) { MatSetValue(A[3],II,II-m,c[7],INSERT_VALUES); }
110:     if (i<m-1) { MatSetValue(A[3],II,II+m,-c[7],INSERT_VALUES); }
111:   }

113:   /* A4 */
114:   for (II=Istart;II<Iend;II++) {
115:     i = II/m; j = II-i*m;
116:     MatSetValue(A[4],II,II,2.0*c[8]+2.0*c[9],INSERT_VALUES);
117:     if (j>0) { MatSetValue(A[4],II,II-1,-c[8],INSERT_VALUES); }
118:     if (j<m-1) { MatSetValue(A[4],II,II+1,-c[8],INSERT_VALUES); }
119:     if (i>0) { MatSetValue(A[4],II,II-m,-c[9],INSERT_VALUES); }
120:     if (i<m-1) { MatSetValue(A[4],II,II+m,-c[9],INSERT_VALUES); }
121:   }

123:   /* assemble matrices */
124:   for (i=0;i<NMAT;i++) {
125:     MatAssemblyBegin(A[i],MAT_FINAL_ASSEMBLY);
126:   }
127:   for (i=0;i<NMAT;i++) {
128:     MatAssemblyEnd(A[i],MAT_FINAL_ASSEMBLY);
129:   }

131:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
132:                 Create the eigensolver and solve the problem
133:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

135:   PEPCreate(PETSC_COMM_WORLD,&pep);
136:   PEPSetOperators(pep,NMAT,A);
137:   PEPSetFromOptions(pep);
138:   PEPSolve(pep);

140:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141:                     Display solution and clean up
142:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
143:   
144:   /* show detailed info unless -terse option is given by user */
145:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
146:   if (terse) {
147:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
148:   } else {
149:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
150:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
151:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
152:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
153:   }
154:   PEPDestroy(&pep);
155:   for (i=0;i<NMAT;i++) {
156:     MatDestroy(&A[i]);
157:   }
158:   SlepcFinalize();
159:   return ierr;
160: }
slepc-3.7.4/src/pep/examples/nlevp/acoustic_wave_2d.c0000644000175000017500000001431313107004621022067 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The acoustic_wave_2d problem is a 2-D version of acoustic_wave_1d, also scaled for real arithmetic. */ static char help[] = "Quadratic eigenproblem from an acoustics application (2-D).\n\n" "The command line options are:\n" " -m , where = grid size, the matrices have dimension m*(m-1).\n" " -z , where = impedance (default 1.0).\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PetscInt m=6,n,II,Istart,Iend,i,j; PetscScalar z=1.0; PetscReal h; char str[50]; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); if (m<2) SETERRQ(PETSC_COMM_SELF,1,"m must be at least 2"); ierr = PetscOptionsGetScalar(NULL,NULL,"-z",&z,NULL);CHKERRQ(ierr); h = 1.0/m; n = m*(m-1); ierr = SlepcSNPrintfScalar(str,50,z,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nAcoustic wave 2-D, n=%D (m=%D), z=%s\n\n",n,m,str);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K has a pattern similar to the 2D Laplacian */ ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr); ierr = MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatSetUp(K);CHKERRQ(ierr); ierr = MatGetOwnershipRange(K,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(K,II,II-m,(j==m-1)?-0.5:-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(K,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (jActual source code: acoustic_wave_2d.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The acoustic_wave_2d problem is a 2-D version of acoustic_wave_1d, also
 30:    scaled for real arithmetic.
 31: */

 33: static char help[] = "Quadratic eigenproblem from an acoustics application (2-D).\n\n"
 34:   "The command line options are:\n"
 35:   "  -m <m>, where <m> = grid size, the matrices have dimension m*(m-1).\n"
 36:   "  -z <z>, where <z> = impedance (default 1.0).\n\n";

 38: #include <slepcpep.h>

 42: int main(int argc,char **argv)
 43: {
 44:   Mat            M,C,K,A[3];      /* problem matrices */
 45:   PEP            pep;             /* polynomial eigenproblem solver context */
 46:   PetscInt       m=6,n,II,Istart,Iend,i,j;
 47:   PetscScalar    z=1.0;
 48:   PetscReal      h;
 49:   char           str[50];
 50:   PetscBool      terse;

 53:   SlepcInitialize(&argc,&argv,(char*)0,help);

 55:   PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);
 56:   if (m<2) SETERRQ(PETSC_COMM_SELF,1,"m must be at least 2");
 57:   PetscOptionsGetScalar(NULL,NULL,"-z",&z,NULL);
 58:   h = 1.0/m;
 59:   n = m*(m-1);
 60:   SlepcSNPrintfScalar(str,50,z,PETSC_FALSE);
 61:   PetscPrintf(PETSC_COMM_WORLD,"\nAcoustic wave 2-D, n=%D (m=%D), z=%s\n\n",n,m,str);

 63:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 64:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 65:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 67:   /* K has a pattern similar to the 2D Laplacian */
 68:   MatCreate(PETSC_COMM_WORLD,&K);
 69:   MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);
 70:   MatSetFromOptions(K);
 71:   MatSetUp(K);
 72:   
 73:   MatGetOwnershipRange(K,&Istart,&Iend);
 74:   for (II=Istart;II<Iend;II++) {
 75:     i = II/m; j = II-i*m;
 76:     if (i>0) { MatSetValue(K,II,II-m,(j==m-1)?-0.5:-1.0,INSERT_VALUES); }
 77:     if (i<m-2) { MatSetValue(K,II,II+m,(j==m-1)?-0.5:-1.0,INSERT_VALUES); }
 78:     if (j>0) { MatSetValue(K,II,II-1,-1.0,INSERT_VALUES); }
 79:     if (j<m-1) { MatSetValue(K,II,II+1,-1.0,INSERT_VALUES); }
 80:     MatSetValue(K,II,II,(j==m-1)?2.0:4.0,INSERT_VALUES);
 81:   }

 83:   MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY);
 84:   MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY);

 86:   /* C is the zero matrix except for a few nonzero elements on the diagonal */
 87:   MatCreate(PETSC_COMM_WORLD,&C);
 88:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n);
 89:   MatSetFromOptions(C);
 90:   MatSetUp(C);

 92:   MatGetOwnershipRange(C,&Istart,&Iend);
 93:   for (i=Istart;i<Iend;i++) {
 94:     if (i%m==m-1) {
 95:       MatSetValue(C,i,i,-2*PETSC_PI*h/z,INSERT_VALUES);
 96:     }
 97:   }
 98:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
 99:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
100:   
101:   /* M is a diagonal matrix */
102:   MatCreate(PETSC_COMM_WORLD,&M);
103:   MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,n,n);
104:   MatSetFromOptions(M);
105:   MatSetUp(M);

107:   MatGetOwnershipRange(M,&Istart,&Iend);
108:   for (i=Istart;i<Iend;i++) {
109:     if (i%m==m-1) {
110:       MatSetValue(M,i,i,2*PETSC_PI*PETSC_PI*h*h,INSERT_VALUES);
111:     } else {
112:       MatSetValue(M,i,i,4*PETSC_PI*PETSC_PI*h*h,INSERT_VALUES);
113:     }
114:   }
115:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
116:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);
117:   
118:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
119:                 Create the eigensolver and solve the problem
120:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

122:   PEPCreate(PETSC_COMM_WORLD,&pep);
123:   A[0] = K; A[1] = C; A[2] = M;
124:   PEPSetOperators(pep,3,A);
125:   PEPSetFromOptions(pep);
126:   PEPSolve(pep);

128:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
129:                     Display solution and clean up
130:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
131:   
132:   /* show detailed info unless -terse option is given by user */
133:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
134:   if (terse) {
135:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
136:   } else {
137:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
138:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
139:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
140:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
141:   }
142:   PEPDestroy(&pep);
143:   MatDestroy(&M);
144:   MatDestroy(&C);
145:   MatDestroy(&K);
146:   SlepcFinalize();
147:   return ierr;
148: }
slepc-3.7.4/src/pep/examples/nlevp/damped_beam.c.html0000644000175000017500000003417513107004621022037 0ustar jromanjroman
Actual source code: damped_beam.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: */
 21: /*
 22:    This example implements one of the problems found at
 23:        NLEVP: A Collection of Nonlinear Eigenvalue Problems,
 24:        The University of Manchester.
 25:    The details of the collection can be found at:
 26:        [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue
 27:            Problems", ACM Trans. Math. Software 39(2), Article 7, 2013.

 29:    The damped_beam problem is a QEP from the vibrarion analysis of a beam
 30:    simply supported at both ends and damped in the middle.
 31: */

 33: static char help[] = "Quadratic eigenproblem from the vibrarion analysis of a beam.\n\n"
 34:   "The command line options are:\n"
 35:   "  -n <n> ... dimension of the matrices.\n\n";

 37: #include <slepcpep.h>

 41: int main(int argc,char **argv)
 42: {
 43:   Mat            M,Mo,C,K,Ko,A[3]; /* problem matrices */
 44:   PEP            pep;              /* polynomial eigenproblem solver context */
 45:   IS             isf,isbc,is;
 46:   PetscInt       n=200,nele,Istart,Iend,i,j,mloc,nloc,bc[2];
 47:   PetscReal      width=0.05,height=0.005,glength=1.0,dlen,EI,area,rho;
 48:   PetscScalar    K1[4],K2[4],K2t[4],K3[4],M1[4],M2[4],M2t[4],M3[4],damp=5.0;
 49:   PetscBool      terse;

 52:   SlepcInitialize(&argc,&argv,(char*)0,help);

 54:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 55:   nele = n/2;
 56:   n    = 2*nele;
 57:   PetscPrintf(PETSC_COMM_WORLD,"\nSimply supported beam damped in the middle, n=%D (nele=%D)\n\n",n,nele);

 59:   dlen = glength/nele;
 60:   EI   = 7e10*width*height*height*height/12.0;
 61:   area = width*height;
 62:   rho  = 0.674/(area*glength);

 64:   K1[0]  =  12;  K1[1]  =   6*dlen;  K1[2]  =   6*dlen;  K1[3]  =  4*dlen*dlen;
 65:   K2[0]  = -12;  K2[1]  =   6*dlen;  K2[2]  =  -6*dlen;  K2[3]  =  2*dlen*dlen;
 66:   K2t[0] = -12;  K2t[1] =  -6*dlen;  K2t[2] =   6*dlen;  K2t[3] =  2*dlen*dlen;
 67:   K3[0]  =  12;  K3[1]  =  -6*dlen;  K3[2]  =  -6*dlen;  K3[3]  =  4*dlen*dlen;
 68:   M1[0]  = 156;  M1[1]  =  22*dlen;  M1[2]  =  22*dlen;  M1[3]  =  4*dlen*dlen;
 69:   M2[0]  =  54;  M2[1]  = -13*dlen;  M2[2]  =  13*dlen;  M2[3]  = -3*dlen*dlen;
 70:   M2t[0] =  54;  M2t[1] =  13*dlen;  M2t[2] = -13*dlen;  M2t[3] = -3*dlen*dlen;
 71:   M3[0]  = 156;  M3[1]  = -22*dlen;  M3[2]  = -22*dlen;  M3[3]  =  4*dlen*dlen;

 73:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 74:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 75:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 77:   /* K is block-tridiagonal */
 78:   MatCreate(PETSC_COMM_WORLD,&Ko);
 79:   MatSetSizes(Ko,PETSC_DECIDE,PETSC_DECIDE,n+2,n+2);
 80:   MatSetBlockSize(Ko,2);
 81:   MatSetFromOptions(Ko);
 82:   MatSetUp(Ko);
 83:   
 84:   MatGetOwnershipRange(Ko,&Istart,&Iend);
 85:   for (i=Istart/2;i<Iend/2;i++) {
 86:     if (i>0) {
 87:       j = i-1;
 88:       MatSetValuesBlocked(Ko,1,&i,1,&j,K2t,ADD_VALUES);
 89:       MatSetValuesBlocked(Ko,1,&i,1,&i,K3,ADD_VALUES);
 90:     }
 91:     if (i<nele) {
 92:       j = i+1;
 93:       MatSetValuesBlocked(Ko,1,&i,1,&j,K2,ADD_VALUES);
 94:       MatSetValuesBlocked(Ko,1,&i,1,&i,K1,ADD_VALUES);
 95:     }
 96:   }
 97:   MatAssemblyBegin(Ko,MAT_FINAL_ASSEMBLY);
 98:   MatAssemblyEnd(Ko,MAT_FINAL_ASSEMBLY);
 99:   MatScale(Ko,EI/(dlen*dlen*dlen));

101:   /* M is block-tridiagonal */
102:   MatCreate(PETSC_COMM_WORLD,&Mo);
103:   MatSetSizes(Mo,PETSC_DECIDE,PETSC_DECIDE,n+2,n+2);
104:   MatSetBlockSize(Mo,2);
105:   MatSetFromOptions(Mo);
106:   MatSetUp(Mo);

108:   MatGetOwnershipRange(Mo,&Istart,&Iend);
109:   for (i=Istart/2;i<Iend/2;i++) {
110:     if (i>0) {
111:       j = i-1;
112:       MatSetValuesBlocked(Mo,1,&i,1,&j,M2t,ADD_VALUES);
113:       MatSetValuesBlocked(Mo,1,&i,1,&i,M3,ADD_VALUES);
114:     }
115:     if (i<nele) {
116:       j = i+1;
117:       MatSetValuesBlocked(Mo,1,&i,1,&j,M2,ADD_VALUES);
118:       MatSetValuesBlocked(Mo,1,&i,1,&i,M1,ADD_VALUES);
119:     }
120:   }
121:   MatAssemblyBegin(Mo,MAT_FINAL_ASSEMBLY);
122:   MatAssemblyEnd(Mo,MAT_FINAL_ASSEMBLY);
123:   MatScale(Mo,rho*area*dlen/420);

125:   /* remove rows/columns from K and M corresponding to boundary conditions */
126:   ISCreateStride(PETSC_COMM_WORLD,Iend-Istart,Istart,1,&isf);
127:   bc[0] = 0; bc[1] = n;
128:   ISCreateGeneral(PETSC_COMM_SELF,2,bc,PETSC_USE_POINTER,&isbc);
129:   ISDifference(isf,isbc,&is);
130:   MatGetSubMatrix(Ko,is,is,MAT_INITIAL_MATRIX,&K);
131:   MatGetSubMatrix(Mo,is,is,MAT_INITIAL_MATRIX,&M);
132:   MatGetLocalSize(M,&mloc,&nloc);

134:   /* C is zero except for the (nele,nele)-entry */
135:   MatCreate(PETSC_COMM_WORLD,&C);
136:   MatSetSizes(C,mloc,nloc,PETSC_DECIDE,PETSC_DECIDE);
137:   MatSetFromOptions(C);
138:   MatSetUp(C);
139:   
140:   MatGetOwnershipRange(C,&Istart,&Iend);
141:   if (nele-1>=Istart && nele-1<Iend) { 
142:     MatSetValue(C,nele-1,nele-1,damp,INSERT_VALUES);
143:   }
144:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
145:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
146:   
147:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
148:                 Create the eigensolver and solve the problem
149:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

151:   PEPCreate(PETSC_COMM_WORLD,&pep);
152:   A[0] = K; A[1] = C; A[2] = M;
153:   PEPSetOperators(pep,3,A);
154:   PEPSetFromOptions(pep);
155:   PEPSolve(pep);

157:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
158:                     Display solution and clean up
159:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
160:   
161:   /* show detailed info unless -terse option is given by user */
162:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
163:   if (terse) {
164:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
165:   } else {
166:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
167:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
168:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
169:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
170:   }
171:   PEPDestroy(&pep);
172:   ISDestroy(&isf);
173:   ISDestroy(&isbc);
174:   ISDestroy(&is);
175:   MatDestroy(&M);
176:   MatDestroy(&C);
177:   MatDestroy(&K);
178:   MatDestroy(&Ko);
179:   MatDestroy(&Mo);
180:   SlepcFinalize();
181:   return ierr;
182: }
slepc-3.7.4/src/pep/examples/nlevp/acoustic_wave_1d.c0000644000175000017500000001373313107004621022073 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The acoustic_wave_1d problem is a QEP from an acoustics application. Here we solve it with the eigenvalue scaled by the imaginary unit, to be able to use real arithmetic, so the computed eigenvalues should be scaled back. */ static char help[] = "Quadratic eigenproblem from an acoustics application (1-D).\n\n" "The command line options are:\n" " -n , where = dimension of the matrices.\n" " -z , where = impedance (default 1.0).\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PetscInt n=10,Istart,Iend,i; PetscScalar z=1.0; char str[50]; PetscBool terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-z",&z,NULL);CHKERRQ(ierr); ierr = SlepcSNPrintfScalar(str,50,z,PETSC_FALSE);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nAcoustic wave 1-D, n=%D z=%s\n\n",n,str);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is a tridiagonal */ ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr); ierr = MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatSetUp(K);CHKERRQ(ierr); ierr = MatGetOwnershipRange(K,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(K,i,i-1,-1.0*n,INSERT_VALUES);CHKERRQ(ierr); } if (i=Istart && n-1. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* This example implements one of the problems found at NLEVP: A Collection of Nonlinear Eigenvalue Problems, The University of Manchester. The details of the collection can be found at: [1] T. Betcke et al., "NLEVP: A Collection of Nonlinear Eigenvalue Problems", ACM Trans. Math. Software 39(2), Article 7, 2013. The pdde_stability problem is a complex-symmetric QEP from the stability analysis of a discretized partial delay-differential equation. It requires complex scalars. */ static char help[] = "Stability analysis of a discretized partial delay-differential equation.\n\n" "The command line options are:\n" " -m , grid size, the matrices have dimension n=m*m.\n" " -c , comma-separated list of 7 real parameters.\n\n"; #include #define NMAT 3 #undef __FUNCT__ #define __FUNCT__ "MyEigenSort" /* Function for user-defined eigenvalue ordering criterion. Given two eigenvalues ar+i*ai and br+i*bi, the subroutine must choose one of them as the preferred one according to the criterion. In this example, the preferred value is the one with absolute value closest to 1. */ PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx) { PetscReal aa,ab; PetscFunctionBeginUser; aa = PetscAbsReal(SlepcAbsEigenvalue(ar,ai)-1.0); ab = PetscAbsReal(SlepcAbsEigenvalue(br,bi)-1.0); *r = aa > ab ? 1 : (aa < ab ? -1 : 0); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A[NMAT]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PetscInt m=15,n,II,Istart,Iend,i,j,k; PetscReal h,xi,xj,c[7] = { 2, .3, -2, .2, -2, -.3, -PETSC_PI/2 }; PetscScalar alpha,beta,gamma; PetscBool flg,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); #if !defined(PETSC_USE_COMPLEX) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP, "This example requires complex scalars"); #endif ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL);CHKERRQ(ierr); n = m*m; h = PETSC_PI/(m+1); gamma = PetscExpScalar(PETSC_i*c[6]); gamma = gamma/PetscAbsScalar(gamma); k = 7; ierr = PetscOptionsGetRealArray(NULL,NULL,"-c",c,&k,&flg);CHKERRQ(ierr); if (flg && k!=7) SETERRQ1(PETSC_COMM_WORLD,1,"The number of parameters -c should be 7, you provided %D",k); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nPDDE stability, n=%D (m=%D)\n\n",n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the polynomial matrices - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* initialize matrices */ for (i=0;i0) { ierr = MatSetValue(A[1],II,II-1,1.0/(h*h),INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(A[1],II,II-m,1.0/(h*h),INSERT_VALUES);CHKERRQ(ierr); } if (i. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/pep/examples/tutorials/ EXAMPLESC = ex16.c ex17.c ex28.c EXAMPLESF = ex16f90.F90 MANSEC = PEP TESTEXAMPLES_C = ex16.PETSc runex16_1 ex16.rm \ ex28.PETSc runex28_1 ex28.rm TESTEXAMPLES_C_NOCOMPLEX = ex17.PETSc runex17_1 ex17.rm TESTEXAMPLES_F90 = ex16f90.PETSc runex16f90_1 ex16f90.rm include ${SLEPC_DIR}/lib/slepc/conf/slepc_common ex16: ex16.o chkopts -${CLINKER} -o ex16 ex16.o ${SLEPC_PEP_LIB} ${RM} ex16.o ex16f90: ex16f90.o chkopts -${FLINKER} -o ex16f90 ex16f90.o ${SLEPC_PEP_LIB} ${RM} ex16f90.o ex17: ex17.o chkopts -${CLINKER} -o ex17 ex17.o ${SLEPC_PEP_LIB} ${RM} ex17.o ex28: ex28.o chkopts -${CLINKER} -o ex28 ex28.o ${SLEPC_PEP_LIB} ${RM} ex28.o #------------------------------------------------------------------------------------ DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices runex16_1: -@${MPIEXEC} -n 1 ./ex16 -pep_nev 4 -terse > ex16_1.tmp 2>&1; \ if (${DIFF} output/ex16_1.out ex16_1.tmp) then true; \ else echo "Possible problem with ex16_1, diffs above"; fi; \ ${RM} -f ex16_1.tmp runex16f90_1: -@${MPIEXEC} -n 1 ./ex16f90 -pep_nev 4 -terse > ex16f90_1.tmp 2>&1; \ if (${DIFF} output/ex16f90_1.out ex16f90_1.tmp) then true; \ else echo "Possible problem with ex16f90_1, diffs above"; fi; \ ${RM} -f ex16f90_1.tmp runex17_1: -@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \ echo "Skipping ex17 test"; \ else \ ${MPIEXEC} -n 1 ./ex17 -A ${DATAPATH}/speaker107k.petsc,${DATAPATH}/speaker107c.petsc,${DATAPATH}/speaker107m.petsc -pep_nev 4 -pep_ncv 20 -pep_tol 1e-14 -pep_scale both -terse > ex17_1.tmp 2>&1; \ if (${DIFF} output/ex17_1.out ex17_1.tmp) then true; \ else echo "Possible problem with ex17_1, diffs above"; fi; \ ${RM} -f ex17_1.tmp; \ fi runex28_1: -@${MPIEXEC} -n 1 ./ex28 -pep_nev 4 -terse > ex28_1.tmp 2>&1; \ if (${DIFF} output/ex28_1.out ex28_1.tmp) then true; \ else echo "Possible problem with ex28_1, diffs above"; fi; \ ${RM} -f ex28_1.tmp slepc-3.7.4/src/pep/examples/tutorials/ex17.c.html0000644000175000017500000002603713107004621021305 0ustar jromanjroman
Actual source code: ex17.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Solves a polynomial eigenproblem P(l)x = 0 with matrices loaded from a file.\n\n"
 23:   "The command line options are:\n"
 24:   "-A <filename1,filename2, ...> , where <filename1,.. > = matrices A0 ... files in PETSc binary form.\n\n";

 26: #include <slepcpep.h>

 28: #define MAX_MATRICES 40

 32: int main(int argc,char **argv)
 33: {
 34:   Mat            A[MAX_MATRICES]; /* problem matrices */
 35:   PEP            pep;             /* polynomial eigenproblem solver context */
 36:   PEPType        type;
 37:   PetscReal      tol;
 38:   PetscInt       nev,maxit,its,nmat=MAX_MATRICES,i;
 39:   char*          filenames[MAX_MATRICES];
 40:   PetscViewer    viewer;
 41:   PetscBool      flg,terse;

 44:   SlepcInitialize(&argc,&argv,(char*)0,help);

 46:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 47:         Load the matrices that define the polynomial eigenproblem
 48:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 50:   PetscPrintf(PETSC_COMM_WORLD,"\nPolynomial eigenproblem stored in file.\n\n");
 51: #if defined(PETSC_USE_COMPLEX)
 52:   PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrices from binary files...\n");
 53: #else
 54:   PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrices from binary files...\n");
 55: #endif
 56:   PetscOptionsGetStringArray(NULL,NULL,"-A",filenames,&nmat,&flg);
 57:   if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a comma-separated list of file names with the -A option");
 58:   for (i=0;i<nmat;i++) { 
 59:     PetscViewerBinaryOpen(PETSC_COMM_WORLD,filenames[i],FILE_MODE_READ,&viewer);
 60:     MatCreate(PETSC_COMM_WORLD,&A[i]);
 61:     MatSetFromOptions(A[i]);
 62:     MatLoad(A[i],viewer);
 63:     PetscViewerDestroy(&viewer);
 64:   }
 65:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 66:                 Create the eigensolver and set various options
 67:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 69:   /*
 70:      Create eigensolver context
 71:   */
 72:   PEPCreate(PETSC_COMM_WORLD,&pep);

 74:   /*
 75:      Set matrices
 76:   */
 77:   PEPSetOperators(pep,nmat,A);
 78:   /*
 79:      Set solver parameters at runtime
 80:   */
 81:   PEPSetFromOptions(pep);

 83:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 84:                       Solve the eigensystem
 85:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 86:   
 87:   PEPSolve(pep);
 88:   PEPGetIterationNumber(pep,&its);
 89:   PetscPrintf(PETSC_COMM_WORLD," Number of iterations of the method: %D\n",its);

 91:   /*
 92:      Optional: Get some information from the solver and display it
 93:   */
 94:   PEPGetType(pep,&type);
 95:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
 96:   PEPGetDimensions(pep,&nev,NULL,NULL);
 97:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
 98:   PEPGetTolerances(pep,&tol,&maxit);
 99:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: tol=%.4g, maxit=%D\n",(double)tol,maxit);

101:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102:                     Display solution and clean up
103:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

105:   /* show detailed info unless -terse option is given by user */
106:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
107:   if (terse) {
108:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
109:   } else {
110:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
111:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
112:     PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_VIEWER_STDOUT_WORLD);
113:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
114:   }
115:   PEPDestroy(&pep);
116:   for (i=0;i<nmat;i++) {
117:     MatDestroy(&A[i]);
118:     PetscFree(filenames[i]);
119:   }
120:   SlepcFinalize();
121:   return ierr;
122: }
slepc-3.7.4/src/pep/examples/tutorials/ex28.c0000644000175000017500000002160113107004621020334 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "A quadratic eigenproblem defined using shell matrices.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x and y dimensions.\n\n"; #include /* User-defined routines */ PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y); PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag); PetscErrorCode MatMult_Zero(Mat A,Vec x,Vec y); PetscErrorCode MatGetDiagonal_Zero(Mat A,Vec diag); PetscErrorCode MatMult_Identity(Mat A,Vec x,Vec y); PetscErrorCode MatGetDiagonal_Identity(Mat A,Vec diag); #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PEPType type; PetscInt N,n=10,nev; PetscMPIInt size; PetscBool terse; PetscErrorCode ierr; ST st; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); if (size != 1) SETERRQ(PETSC_COMM_WORLD,1,"This is a uniprocessor example only"); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); N = n*n; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nQuadratic Eigenproblem with shell matrices, N=%D (%Dx%D grid)\n\n",N,n,n);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is the 2-D Laplacian */ ierr = MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,&n,&K);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatShellSetOperation(K,MATOP_MULT,(void(*)())MatMult_Laplacian2D);CHKERRQ(ierr); ierr = MatShellSetOperation(K,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Laplacian2D);CHKERRQ(ierr); ierr = MatShellSetOperation(K,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Laplacian2D);CHKERRQ(ierr); /* C is the zero matrix */ ierr = MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,NULL,&C);CHKERRQ(ierr); ierr = MatSetFromOptions(C);CHKERRQ(ierr); ierr = MatShellSetOperation(C,MATOP_MULT,(void(*)())MatMult_Zero);CHKERRQ(ierr); ierr = MatShellSetOperation(C,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Zero);CHKERRQ(ierr); ierr = MatShellSetOperation(C,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Zero);CHKERRQ(ierr); /* M is the identity matrix */ ierr = MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,NULL,&M);CHKERRQ(ierr); ierr = MatSetFromOptions(M);CHKERRQ(ierr); ierr = MatShellSetOperation(M,MATOP_MULT,(void(*)())MatMult_Identity);CHKERRQ(ierr); ierr = MatShellSetOperation(M,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Identity);CHKERRQ(ierr); ierr = MatShellSetOperation(M,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Identity);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create the eigensolver and set various options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Create eigensolver context */ ierr = PEPCreate(PETSC_COMM_WORLD,&pep);CHKERRQ(ierr); /* Set matrices and problem type */ A[0] = K; A[1] = C; A[2] = M; ierr = PEPSetOperators(pep,3,A);CHKERRQ(ierr); ierr = PEPGetST(pep,&st);CHKERRQ(ierr); ierr = STSetMatMode(st,ST_MATMODE_SHELL);CHKERRQ(ierr); /* Set solver parameters at runtime */ ierr = PEPSetFromOptions(pep);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Solve the eigensystem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PEPSolve(pep);CHKERRQ(ierr); /* Optional: Get some information from the solver and display it */ ierr = PEPGetType(pep,&type);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);CHKERRQ(ierr); ierr = PEPGetDimensions(pep,&nev,NULL,NULL);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Display solution and clean up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* show detailed info unless -terse option is given by user */ ierr = PetscOptionsHasName(NULL,NULL,"-terse",&terse);CHKERRQ(ierr); if (terse) { ierr = PEPErrorView(pep,PEP_ERROR_RELATIVE,NULL);CHKERRQ(ierr); } else { ierr = PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);CHKERRQ(ierr); ierr = PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PEPErrorView(pep,PEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); ierr = PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr); } ierr = PEPDestroy(&pep);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); ierr = MatDestroy(&C);CHKERRQ(ierr); ierr = MatDestroy(&K);CHKERRQ(ierr); ierr = SlepcFinalize(); return ierr; } /* Compute the matrix vector multiplication y<---T*x where T is a nx by nx tridiagonal matrix with DD on the diagonal, DL on the subdiagonal, and DU on the superdiagonal. */ static void tv(int nx,const PetscScalar *x,PetscScalar *y) { PetscScalar dd,dl,du; int j; dd = 4.0; dl = -1.0; du = -1.0; y[0] = dd*x[0] + du*x[1]; for (j=1;j
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/pep/examples/tutorials/
EXAMPLESC  = ex16.c ex17.c ex28.c
EXAMPLESF  = ex16f90.F90
MANSEC     = PEP

TESTEXAMPLES_C           = ex16.PETSc runex16_1 ex16.rm \
                           ex28.PETSc runex28_1 ex28.rm
TESTEXAMPLES_C_NOCOMPLEX = ex17.PETSc runex17_1 ex17.rm
TESTEXAMPLES_F90         = ex16f90.PETSc runex16f90_1 ex16f90.rm

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

ex16: ex16.o chkopts
	-${CLINKER} -o ex16 ex16.o ${SLEPC_PEP_LIB}
	${RM} ex16.o

ex16f90: ex16f90.o chkopts
	-${FLINKER} -o ex16f90 ex16f90.o ${SLEPC_PEP_LIB}
	${RM} ex16f90.o

ex17: ex17.o chkopts
	-${CLINKER} -o ex17 ex17.o ${SLEPC_PEP_LIB}
	${RM} ex17.o

ex28: ex28.o chkopts
	-${CLINKER} -o ex28 ex28.o ${SLEPC_PEP_LIB}
	${RM} ex28.o

#------------------------------------------------------------------------------------
DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matrices

runex16_1:
	-@${MPIEXEC} -n 1 ./ex16 -pep_nev 4 -terse > ex16_1.tmp 2>&1; \
	   if (${DIFF} output/ex16_1.out ex16_1.tmp) then true; \
	   else echo "Possible problem with ex16_1, diffs above"; fi; \
	   ${RM} -f ex16_1.tmp

runex16f90_1:
	-@${MPIEXEC} -n 1 ./ex16f90 -pep_nev 4 -terse > ex16f90_1.tmp 2>&1; \
	   if (${DIFF} output/ex16f90_1.out ex16f90_1.tmp) then true; \
	   else echo "Possible problem with ex16f90_1, diffs above"; fi; \
	   ${RM} -f ex16f90_1.tmp

runex17_1:
	-@if [ "${PETSC_PRECISION}" != "double" ] || (${GREP} USE_64BIT_INDICES ${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h > /dev/null 2>&1) then \
           echo "Skipping ex17 test"; \
         else \
	   ${MPIEXEC} -n 1 ./ex17 -A ${DATAPATH}/speaker107k.petsc,${DATAPATH}/speaker107c.petsc,${DATAPATH}/speaker107m.petsc -pep_nev 4 -pep_ncv 20 -pep_tol 1e-14 -pep_scale both -terse > ex17_1.tmp 2>&1; \
	   if (${DIFF} output/ex17_1.out ex17_1.tmp) then true; \
	   else echo "Possible problem with ex17_1, diffs above"; fi; \
	   ${RM} -f ex17_1.tmp; \
         fi

runex28_1:
	-@${MPIEXEC} -n 1 ./ex28 -pep_nev 4 -terse > ex28_1.tmp 2>&1; \
	   if (${DIFF} output/ex28_1.out ex28_1.tmp) then true; \
	   else echo "Possible problem with ex28_1, diffs above"; fi; \
	   ${RM} -f ex28_1.tmp

slepc-3.7.4/src/pep/examples/tutorials/ex16f90.F90.html0000644000175000017500000003677513107004621021751 0ustar jromanjroman
Actual source code: ex16f90.F90

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Program usage: mpiexec -n <np> ./ex16f90 [-help] [-n <n>] [-m <m>] [SLEPc opts] 
 21: !
 22: !  Description: Simple example that solves a quadratic eigensystem with the
 23: !  PEP object. This is the Fortran90 equivalent to ex16.c
 24: !
 25: !  The command line options are:
 26: !    -n <n>, where <n> = number of grid subdivisions in x dimension
 27: !    -m <m>, where <m> = number of grid subdivisions in y dimension
 28: !
 29: ! ---------------------------------------------------------------------- 
 30: !
 31:       program main

 33: #include <slepc/finclude/slepcpepdef.h>
 34:       use slepcpep

 36:       implicit none

 38: ! For usage without modules, uncomment the following lines and remove 
 39: ! the previous lines between 'program main' and 'implicit none'
 40: !
 41: !#include <petsc/finclude/petsc.h>
 42: !#include <slepc/finclude/slepc.h>

 44: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 45: !     Declarations
 46: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 47: !
 48: !  Variables:
 49: !     M,C,K  problem matrices
 50: !     pep    polynomial eigenproblem solver context

 52: #if defined(PETSC_USE_FORTRAN_DATATYPES)
 53:       type(Mat)      M, C, K, A(3)
 54:       type(PEP)      pep
 55: #else
 56:       Mat            M, C, K, A(3)
 57:       PEP            pep
 58: #endif
 59:       PEPType        tname
 60:       PetscInt       N, nx, ny, i, j, Istart, Iend, II
 61:       PetscInt       nev, ithree
 62:       PetscMPIInt    rank
 63:       PetscErrorCode ierr
 64:       PetscBool      flg, terse
 65:       PetscScalar    mone, two, four, val

 67: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 68: !     Beginning of program
 69: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 71:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 72:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 73:       nx = 10
 74:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 75:      &                        '-n',nx,flg,ierr)
 76:       call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,   &
 77:      &                        '-m',ny,flg,ierr)
 78:       if (.not. flg) then
 79:         ny = nx
 80:       endif
 81:       N = nx*ny
 82:       if (rank .eq. 0) then
 83:         write(*,100) N, nx, ny
 84:       endif
 85:  100  format (/'Quadratic Eigenproblem, N=',I6,' (',I4,'x',I4,' grid)')

 87: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 88: !     Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 89: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 91: !     ** K is the 2-D Laplacian
 92:       call MatCreate(PETSC_COMM_WORLD,K,ierr)
 93:       call MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,N,N,ierr)
 94:       call MatSetFromOptions(K,ierr)
 95:       call MatSetUp(K,ierr)
 96:       call MatGetOwnershipRange(K,Istart,Iend,ierr)
 97:       mone = -1.0
 98:       four = 4.0
 99:       do II=Istart,Iend-1
100:         i = II/nx
101:         j = II-i*nx
102:         if (i .gt. 0) then 
103:           call MatSetValue(K,II,II-nx,mone,INSERT_VALUES,ierr)
104:         endif
105:         if (i .lt. ny-1) then 
106:           call MatSetValue(K,II,II+nx,mone,INSERT_VALUES,ierr)
107:         endif
108:         if (j .gt. 0) then 
109:           call MatSetValue(K,II,II-1,mone,INSERT_VALUES,ierr)
110:         endif
111:         if (j .lt. nx-1) then 
112:           call MatSetValue(K,II,II+1,mone,INSERT_VALUES,ierr)
113:         endif
114:         call MatSetValue(K,II,II,four,INSERT_VALUES,ierr)
115:       end do
116:       call MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY,ierr)
117:       call MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY,ierr)

119: !     ** C is the 1-D Laplacian on horizontal lines
120:       call MatCreate(PETSC_COMM_WORLD,C,ierr)
121:       call MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,N,N,ierr)
122:       call MatSetFromOptions(C,ierr)
123:       call MatSetUp(C,ierr)
124:       call MatGetOwnershipRange(C,Istart,Iend,ierr)
125:       two = 2.0
126:       do II=Istart,Iend-1
127:         i = II/nx
128:         j = II-i*nx
129:         if (j .gt. 0) then 
130:           call MatSetValue(C,II,II-1,mone,INSERT_VALUES,ierr)
131:         endif
132:         if (j .lt. nx-1) then 
133:           call MatSetValue(C,II,II+1,mone,INSERT_VALUES,ierr)
134:         endif
135:         call MatSetValue(C,II,II,two,INSERT_VALUES,ierr)
136:       end do
137:       call MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY,ierr)
138:       call MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY,ierr)

140: !     ** M is a diagonal matrix
141:       call MatCreate(PETSC_COMM_WORLD,M,ierr)
142:       call MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,N,N,ierr)
143:       call MatSetFromOptions(M,ierr)
144:       call MatSetUp(M,ierr)
145:       call MatGetOwnershipRange(M,Istart,Iend,ierr)
146:       do II=Istart,Iend-1
147:         val = II+1
148:         call MatSetValue(M,II,II,val,INSERT_VALUES,ierr)
149:       end do
150:       call MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY,ierr)
151:       call MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY,ierr)

153: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
154: !     Create the eigensolver and set various options
155: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

157: !     ** Create eigensolver context
158:       call PEPCreate(PETSC_COMM_WORLD,pep,ierr)

160: !     ** Set matrices and problem type
161:       A(1) = K
162:       A(2) = C
163:       A(3) = M
164:       ithree = 3
165:       call PEPSetOperators(pep,ithree,A,ierr)
166:       call PEPSetProblemType(pep,PEP_GENERAL,ierr)

168: !     ** Set solver parameters at runtime
169:       call PEPSetFromOptions(pep,ierr)

171: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
172: !     Solve the eigensystem
173: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

175:       call PEPSolve(pep,ierr) 

177: !     ** Optional: Get some information from the solver and display it
178:       call PEPGetType(pep,tname,ierr)
179:       if (rank .eq. 0) then
180:         write(*,120) tname
181:       endif
182:  120  format (' Solution method: ',A)
183:       call PEPGetDimensions(pep,nev,PETSC_NULL_INTEGER,                 &
184:      &                      PETSC_NULL_INTEGER,ierr)
185:       if (rank .eq. 0) then
186:         write(*,130) nev
187:       endif
188:  130  format (' Number of requested eigenvalues:',I4)

190: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
191: !     Display solution and clean up
192: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

194: !     ** show detailed info unless -terse option is given by user
195:       call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER,  &
196:      &                        '-terse',terse,ierr)
197:       if (terse) then
198:         call PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_NULL_OBJECT,ierr)
199:       else
200:         call PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,           &
201:      &                   PETSC_VIEWER_ASCII_INFO_DETAIL,ierr)
202:         call PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD,ierr)
203:         call PEPErrorView(pep,PEP_ERROR_BACKWARD,                       &
204:      &                   PETSC_VIEWER_STDOUT_WORLD,ierr)
205:         call PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD,ierr)
206:       endif
207:       call PEPDestroy(pep,ierr)
208:       call MatDestroy(K,ierr)
209:       call MatDestroy(C,ierr)
210:       call MatDestroy(M,ierr)
211:       call SlepcFinalize(ierr)
212:       end

slepc-3.7.4/src/pep/examples/tutorials/ex16.c.html0000644000175000017500000003502313107004621021277 0ustar jromanjroman
Actual source code: ex16.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Simple quadratic eigenvalue problem.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 25:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n\n";

 27: #include <slepcpep.h>

 31: int main(int argc,char **argv)
 32: {
 33:   Mat            M,C,K,A[3];      /* problem matrices */
 34:   PEP            pep;             /* polynomial eigenproblem solver context */
 35:   PEPType        type;
 36:   PetscInt       N,n=10,m,Istart,Iend,II,nev,i,j,nconv;
 37:   PetscBool      flag,terse;
 38:   PetscReal      error,re,im;
 39:   PetscScalar    kr,ki;
 40:   Vec            xr,xi;

 43:   SlepcInitialize(&argc,&argv,(char*)0,help);

 45:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 46:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 47:   if (!flag) m=n;
 48:   N = n*m;
 49:   PetscPrintf(PETSC_COMM_WORLD,"\nQuadratic Eigenproblem, N=%D (%Dx%D grid)\n\n",N,n,m);

 51:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 52:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 53:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 55:   /* K is the 2-D Laplacian */
 56:   MatCreate(PETSC_COMM_WORLD,&K);
 57:   MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,N,N);
 58:   MatSetFromOptions(K);
 59:   MatSetUp(K);
 60:   MatGetOwnershipRange(K,&Istart,&Iend);
 61:   for (II=Istart;II<Iend;II++) {
 62:     i = II/n; j = II-i*n;
 63:     if (i>0) { MatSetValue(K,II,II-n,-1.0,INSERT_VALUES); }
 64:     if (i<m-1) { MatSetValue(K,II,II+n,-1.0,INSERT_VALUES); }
 65:     if (j>0) { MatSetValue(K,II,II-1,-1.0,INSERT_VALUES); }
 66:     if (j<n-1) { MatSetValue(K,II,II+1,-1.0,INSERT_VALUES); }
 67:     MatSetValue(K,II,II,4.0,INSERT_VALUES);
 68:   }
 69:   MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY);
 70:   MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY);

 72:   /* C is the 1-D Laplacian on horizontal lines */
 73:   MatCreate(PETSC_COMM_WORLD,&C);
 74:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,N,N);
 75:   MatSetFromOptions(C);
 76:   MatSetUp(C);
 77:   MatGetOwnershipRange(C,&Istart,&Iend);
 78:   for (II=Istart;II<Iend;II++) {
 79:     i = II/n; j = II-i*n;
 80:     if (j>0) { MatSetValue(C,II,II-1,-1.0,INSERT_VALUES); }
 81:     if (j<n-1) { MatSetValue(C,II,II+1,-1.0,INSERT_VALUES); }
 82:     MatSetValue(C,II,II,2.0,INSERT_VALUES);
 83:   }
 84:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
 85:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);

 87:   /* M is a diagonal matrix */
 88:   MatCreate(PETSC_COMM_WORLD,&M);
 89:   MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,N,N);
 90:   MatSetFromOptions(M);
 91:   MatSetUp(M);
 92:   MatGetOwnershipRange(M,&Istart,&Iend);
 93:   for (II=Istart;II<Iend;II++) {
 94:     MatSetValue(M,II,II,(PetscReal)(II+1),INSERT_VALUES);
 95:   }
 96:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
 97:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);

 99:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100:                 Create the eigensolver and set various options
101:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

103:   /*
104:      Create eigensolver context
105:   */
106:   PEPCreate(PETSC_COMM_WORLD,&pep);

108:   /*
109:      Set matrices and problem type
110:   */
111:   A[0] = K; A[1] = C; A[2] = M;
112:   PEPSetOperators(pep,3,A);
113:   PEPSetProblemType(pep,PEP_HERMITIAN);

115:   /*
116:      Set solver parameters at runtime
117:   */
118:   PEPSetFromOptions(pep);

120:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121:                       Solve the eigensystem
122:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

124:   PEPSolve(pep);

126:   /*
127:      Optional: Get some information from the solver and display it
128:   */
129:   PEPGetType(pep,&type);
130:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
131:   PEPGetDimensions(pep,&nev,NULL,NULL);
132:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

134:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
135:                     Display solution and clean up
136:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

138:   /* show detailed info unless -terse option is given by user */
139:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
140:   if (terse) {
141:     PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
142:   } else {
143:     PEPGetConverged(pep,&nconv);
144:     if (nconv>0) {
145:       MatCreateVecs(M,&xr,&xi);
146:       /* display eigenvalues and relative errors */
147:       PetscPrintf(PETSC_COMM_WORLD,
148:            "\n           k          ||P(k)x||/||kx||\n"
149:            "   ----------------- ------------------\n");
150:       for (i=0;i<nconv;i++) {
151:         /* get converged eigenpairs */
152:         PEPGetEigenpair(pep,i,&kr,&ki,xr,xi);
153:         /* compute the relative error associated to each eigenpair */
154:         PEPComputeError(pep,i,PEP_ERROR_RELATIVE,&error);
155: #if defined(PETSC_USE_COMPLEX)
156:         re = PetscRealPart(kr);
157:         im = PetscImaginaryPart(kr);
158: #else
159:         re = kr;
160:         im = ki;
161: #endif
162:         if (im!=0.0) {
163:           PetscPrintf(PETSC_COMM_WORLD," %9f%+9fi   %12g\n",(double)re,(double)im,(double)error);
164:         } else {
165:           PetscPrintf(PETSC_COMM_WORLD,"   %12f       %12g\n",(double)re,(double)error);
166:         }
167:       }
168:       PetscPrintf(PETSC_COMM_WORLD,"\n");
169:       VecDestroy(&xr);
170:       VecDestroy(&xi);
171:     }
172:   }
173:   PEPDestroy(&pep);
174:   MatDestroy(&M);
175:   MatDestroy(&C);
176:   MatDestroy(&K);
177:   SlepcFinalize();
178:   return ierr;
179: }

slepc-3.7.4/src/pep/examples/tutorials/ex16.c0000644000175000017500000001631513107004621020337 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Simple quadratic eigenvalue problem.\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PEPType type; PetscInt N,n=10,m,Istart,Iend,II,nev,i,j,nconv; PetscBool flag,terse; PetscReal error,re,im; PetscScalar kr,ki; Vec xr,xi; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscPrintf(PETSC_COMM_WORLD,"\nQuadratic Eigenproblem, N=%D (%Dx%D grid)\n\n",N,n,m);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is the 2-D Laplacian */ ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr); ierr = MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatSetUp(K);CHKERRQ(ierr); ierr = MatGetOwnershipRange(K,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(K,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(K,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(C,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatCreateVecs(M,&xr,&xi);CHKERRQ(ierr); /* display eigenvalues and relative errors */ ierr = PetscPrintf(PETSC_COMM_WORLD, "\n k ||P(k)x||/||kx||\n" " ----------------- ------------------\n");CHKERRQ(ierr); for (i=0;i Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

ex16.c: Simple quadratic eigenvalue problem
ex17.c: Solves a polynomial eigenproblem P(l)x = 0 with matrices loaded from a file
ex28.c: A quadratic eigenproblem defined using shell matrices
makefile
slepc-3.7.4/src/pep/examples/tutorials/ex16f90.F900000644000175000017500000001724013107004621020770 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Program usage: mpiexec -n ./ex16f90 [-help] [-n ] [-m ] [SLEPc opts] ! ! Description: Simple example that solves a quadratic eigensystem with the ! PEP object. This is the Fortran90 equivalent to ex16.c ! ! The command line options are: ! -n , where = number of grid subdivisions in x dimension ! -m , where = number of grid subdivisions in y dimension ! ! ---------------------------------------------------------------------- ! program main #include use slepcpep implicit none ! For usage without modules, uncomment the following lines and remove ! the previous lines between 'program main' and 'implicit none' ! !#include !#include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Variables: ! M,C,K problem matrices ! pep polynomial eigenproblem solver context #if defined(PETSC_USE_FORTRAN_DATATYPES) type(Mat) M, C, K, A(3) type(PEP) pep #else Mat M, C, K, A(3) PEP pep #endif PEPType tname PetscInt N, nx, ny, i, j, Istart, Iend, II PetscInt nev, ithree PetscMPIInt rank PetscErrorCode ierr PetscBool flg, terse PetscScalar mone, two, four, val ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) nx = 10 call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-n',nx,flg,ierr) call PetscOptionsGetInt(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-m',ny,flg,ierr) if (.not. flg) then ny = nx endif N = nx*ny if (rank .eq. 0) then write(*,100) N, nx, ny endif 100 format (/'Quadratic Eigenproblem, N=',I6,' (',I4,'x',I4,' grid)') ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** K is the 2-D Laplacian call MatCreate(PETSC_COMM_WORLD,K,ierr) call MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,N,N,ierr) call MatSetFromOptions(K,ierr) call MatSetUp(K,ierr) call MatGetOwnershipRange(K,Istart,Iend,ierr) mone = -1.0 four = 4.0 do II=Istart,Iend-1 i = II/nx j = II-i*nx if (i .gt. 0) then call MatSetValue(K,II,II-nx,mone,INSERT_VALUES,ierr) endif if (i .lt. ny-1) then call MatSetValue(K,II,II+nx,mone,INSERT_VALUES,ierr) endif if (j .gt. 0) then call MatSetValue(K,II,II-1,mone,INSERT_VALUES,ierr) endif if (j .lt. nx-1) then call MatSetValue(K,II,II+1,mone,INSERT_VALUES,ierr) endif call MatSetValue(K,II,II,four,INSERT_VALUES,ierr) end do call MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY,ierr) ! ** C is the 1-D Laplacian on horizontal lines call MatCreate(PETSC_COMM_WORLD,C,ierr) call MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,N,N,ierr) call MatSetFromOptions(C,ierr) call MatSetUp(C,ierr) call MatGetOwnershipRange(C,Istart,Iend,ierr) two = 2.0 do II=Istart,Iend-1 i = II/nx j = II-i*nx if (j .gt. 0) then call MatSetValue(C,II,II-1,mone,INSERT_VALUES,ierr) endif if (j .lt. nx-1) then call MatSetValue(C,II,II+1,mone,INSERT_VALUES,ierr) endif call MatSetValue(C,II,II,two,INSERT_VALUES,ierr) end do call MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY,ierr) ! ** M is a diagonal matrix call MatCreate(PETSC_COMM_WORLD,M,ierr) call MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,N,N,ierr) call MatSetFromOptions(M,ierr) call MatSetUp(M,ierr) call MatGetOwnershipRange(M,Istart,Iend,ierr) do II=Istart,Iend-1 val = II+1 call MatSetValue(M,II,II,val,INSERT_VALUES,ierr) end do call MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create the eigensolver and set various options ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** Create eigensolver context call PEPCreate(PETSC_COMM_WORLD,pep,ierr) ! ** Set matrices and problem type A(1) = K A(2) = C A(3) = M ithree = 3 call PEPSetOperators(pep,ithree,A,ierr) call PEPSetProblemType(pep,PEP_GENERAL,ierr) ! ** Set solver parameters at runtime call PEPSetFromOptions(pep,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Solve the eigensystem ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call PEPSolve(pep,ierr) ! ** Optional: Get some information from the solver and display it call PEPGetType(pep,tname,ierr) if (rank .eq. 0) then write(*,120) tname endif 120 format (' Solution method: ',A) call PEPGetDimensions(pep,nev,PETSC_NULL_INTEGER, & & PETSC_NULL_INTEGER,ierr) if (rank .eq. 0) then write(*,130) nev endif 130 format (' Number of requested eigenvalues:',I4) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ** show detailed info unless -terse option is given by user call PetscOptionsHasName(PETSC_NULL_OBJECT,PETSC_NULL_CHARACTER, & & '-terse',terse,ierr) if (terse) then call PEPErrorView(pep,PEP_ERROR_BACKWARD,PETSC_NULL_OBJECT,ierr) else call PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD, & & PETSC_VIEWER_ASCII_INFO_DETAIL,ierr) call PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD,ierr) call PEPErrorView(pep,PEP_ERROR_BACKWARD, & & PETSC_VIEWER_STDOUT_WORLD,ierr) call PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD,ierr) endif call PEPDestroy(pep,ierr) call MatDestroy(K,ierr) call MatDestroy(C,ierr) call MatDestroy(M,ierr) call SlepcFinalize(ierr) end slepc-3.7.4/src/pep/examples/tutorials/ex17.c0000644000175000017500000001214013107004621020330 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Solves a polynomial eigenproblem P(l)x = 0 with matrices loaded from a file.\n\n" "The command line options are:\n" "-A , where = matrices A0 ... files in PETSc binary form.\n\n"; #include #define MAX_MATRICES 40 #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A[MAX_MATRICES]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PEPType type; PetscReal tol; PetscInt nev,maxit,its,nmat=MAX_MATRICES,i; char* filenames[MAX_MATRICES]; PetscViewer viewer; PetscBool flg,terse; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Load the matrices that define the polynomial eigenproblem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ ierr = PetscPrintf(PETSC_COMM_WORLD,"\nPolynomial eigenproblem stored in file.\n\n");CHKERRQ(ierr); #if defined(PETSC_USE_COMPLEX) ierr = PetscPrintf(PETSC_COMM_WORLD," Reading COMPLEX matrices from binary files...\n");CHKERRQ(ierr); #else ierr = PetscPrintf(PETSC_COMM_WORLD," Reading REAL matrices from binary files...\n");CHKERRQ(ierr); #endif ierr = PetscOptionsGetStringArray(NULL,NULL,"-A",filenames,&nmat,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PETSC_COMM_WORLD,1,"Must indicate a comma-separated list of file names with the -A option"); for (i=0;iActual source code: ex28.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "A quadratic eigenproblem defined using shell matrices.\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions in x and y dimensions.\n\n";

 26: #include <slepcpep.h>

 28: /*
 29:    User-defined routines
 30: */
 31: PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y);
 32: PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag);
 33: PetscErrorCode MatMult_Zero(Mat A,Vec x,Vec y);
 34: PetscErrorCode MatGetDiagonal_Zero(Mat A,Vec diag);
 35: PetscErrorCode MatMult_Identity(Mat A,Vec x,Vec y);
 36: PetscErrorCode MatGetDiagonal_Identity(Mat A,Vec diag);

 40: int main(int argc,char **argv)
 41: {
 42:   Mat            M,C,K,A[3];      /* problem matrices */
 43:   PEP            pep;             /* polynomial eigenproblem solver context */
 44:   PEPType        type;
 45:   PetscInt       N,n=10,nev;
 46:   PetscMPIInt    size;
 47:   PetscBool      terse;
 49:   ST             st;

 51:   SlepcInitialize(&argc,&argv,(char*)0,help);
 52:   MPI_Comm_size(PETSC_COMM_WORLD,&size);
 53:   if (size != 1) SETERRQ(PETSC_COMM_WORLD,1,"This is a uniprocessor example only");

 55:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 56:   N = n*n;
 57:   PetscPrintf(PETSC_COMM_WORLD,"\nQuadratic Eigenproblem with shell matrices, N=%D (%Dx%D grid)\n\n",N,n,n);

 59:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 60:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 61:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 63:   /* K is the 2-D Laplacian */
 64:   MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,&n,&K);
 65:   MatSetFromOptions(K);
 66:   MatShellSetOperation(K,MATOP_MULT,(void(*)())MatMult_Laplacian2D);
 67:   MatShellSetOperation(K,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Laplacian2D);
 68:   MatShellSetOperation(K,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Laplacian2D);

 70:   /* C is the zero matrix */
 71:   MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,NULL,&C);
 72:   MatSetFromOptions(C);
 73:   MatShellSetOperation(C,MATOP_MULT,(void(*)())MatMult_Zero);
 74:   MatShellSetOperation(C,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Zero);
 75:   MatShellSetOperation(C,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Zero);

 77:   /* M is the identity matrix */
 78:   MatCreateShell(PETSC_COMM_WORLD,N,N,N,N,NULL,&M);
 79:   MatSetFromOptions(M);
 80:   MatShellSetOperation(M,MATOP_MULT,(void(*)())MatMult_Identity);
 81:   MatShellSetOperation(M,MATOP_MULT_TRANSPOSE,(void(*)())MatMult_Identity);
 82:   MatShellSetOperation(M,MATOP_GET_DIAGONAL,(void(*)())MatGetDiagonal_Identity);

 84:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 85:                 Create the eigensolver and set various options
 86:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 88:   /*
 89:      Create eigensolver context
 90:   */
 91:   PEPCreate(PETSC_COMM_WORLD,&pep);

 93:   /*
 94:      Set matrices and problem type
 95:   */
 96:   A[0] = K; A[1] = C; A[2] = M;
 97:   PEPSetOperators(pep,3,A);
 98:   PEPGetST(pep,&st);
 99:   STSetMatMode(st,ST_MATMODE_SHELL);

101:   /*
102:      Set solver parameters at runtime
103:   */
104:   PEPSetFromOptions(pep);

106:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107:                       Solve the eigensystem
108:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

110:   PEPSolve(pep);

112:   /*
113:      Optional: Get some information from the solver and display it
114:   */
115:   PEPGetType(pep,&type);
116:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
117:   PEPGetDimensions(pep,&nev,NULL,NULL);
118:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);

120:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121:                     Display solution and clean up
122:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

124:   /* show detailed info unless -terse option is given by user */
125:   PetscOptionsHasName(NULL,NULL,"-terse",&terse);
126:   if (terse) {
127:     PEPErrorView(pep,PEP_ERROR_RELATIVE,NULL);
128:   } else {
129:     PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_INFO_DETAIL);
130:     PEPReasonView(pep,PETSC_VIEWER_STDOUT_WORLD);
131:     PEPErrorView(pep,PEP_ERROR_RELATIVE,PETSC_VIEWER_STDOUT_WORLD);
132:     PetscViewerPopFormat(PETSC_VIEWER_STDOUT_WORLD);
133:   }
134:   PEPDestroy(&pep);
135:   MatDestroy(&M);
136:   MatDestroy(&C);
137:   MatDestroy(&K);
138:   SlepcFinalize();
139:   return ierr;
140: }

142: /*
143:     Compute the matrix vector multiplication y<---T*x where T is a nx by nx
144:     tridiagonal matrix with DD on the diagonal, DL on the subdiagonal, and
145:     DU on the superdiagonal.
146:  */
147: static void tv(int nx,const PetscScalar *x,PetscScalar *y)
148: {
149:   PetscScalar dd,dl,du;
150:   int         j;

152:   dd  = 4.0;
153:   dl  = -1.0;
154:   du  = -1.0;

156:   y[0] =  dd*x[0] + du*x[1];
157:   for (j=1;j<nx-1;j++)
158:     y[j] = dl*x[j-1] + dd*x[j] + du*x[j+1];
159:   y[nx-1] = dl*x[nx-2] + dd*x[nx-1];
160: }

164: /*
165:     Matrix-vector product subroutine for the 2D Laplacian.

167:     The matrix used is the 2 dimensional discrete Laplacian on unit square with
168:     zero Dirichlet boundary condition.

170:     Computes y <-- A*x, where A is the block tridiagonal matrix

172:                  | T -I          |
173:                  |-I  T -I       |
174:              A = |   -I  T       |
175:                  |        ...  -I|
176:                  |           -I T|

178:     The subroutine TV is called to compute y<--T*x.
179:  */
180: PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)
181: {
182:   void              *ctx;
183:   int               nx,lo,i,j;
184:   const PetscScalar *px;
185:   PetscScalar       *py;
186:   PetscErrorCode    ierr;

189:   MatShellGetContext(A,&ctx);
190:   nx = *(int*)ctx;
191:   VecGetArrayRead(x,&px);
192:   VecGetArray(y,&py);

194:   tv(nx,&px[0],&py[0]);
195:   for (i=0;i<nx;i++) py[i] -= px[nx+i];

197:   for (j=2;j<nx;j++) {
198:     lo = (j-1)*nx;
199:     tv(nx,&px[lo],&py[lo]);
200:     for (i=0;i<nx;i++) py[lo+i] -= px[lo-nx+i] + px[lo+nx+i];
201:   }

203:   lo = (nx-1)*nx;
204:   tv(nx,&px[lo],&py[lo]);
205:   for (i=0;i<nx;i++) py[lo+i] -= px[lo-nx+i];

207:   VecRestoreArrayRead(x,&px);
208:   VecRestoreArray(y,&py);
209:   return(0);
210: }

214: PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)
215: {

219:   VecSet(diag,4.0);
220:   return(0);
221: }

225: /*
226:     Matrix-vector product subroutine for the Null matrix.
227:  */
228: PetscErrorCode MatMult_Zero(Mat A,Vec x,Vec y)
229: {

233:   VecSet(y,0.0);
234:   return(0);
235: }

239: PetscErrorCode MatGetDiagonal_Zero(Mat A,Vec diag)
240: {

244:   VecSet(diag,0.0);
245:   return(0);
246: }

250: /*
251:     Matrix-vector product subroutine for the Identity matrix.
252:  */
253: PetscErrorCode MatMult_Identity(Mat A,Vec x,Vec y)
254: {
255:   PetscErrorCode    ierr;

258:   VecCopy(x,y);
259:   return(0);
260: }

264: PetscErrorCode MatGetDiagonal_Identity(Mat A,Vec diag)
265: {

269:   VecSet(diag,1.0);
270:   return(0);
271: }

slepc-3.7.4/src/pep/examples/index.html0000644000175000017500000000132213107004621017347 0ustar jromanjroman Generic SLEPc Manual Pages
slepc-3.7.4 2017-05-17

tests/
tutorials/
nlevp/
makefile
slepc-3.7.4/src/pep/examples/tests/0000755000175000017500000000000013107004621016516 5ustar jromanjromanslepc-3.7.4/src/pep/examples/tests/makefile0000644000175000017500000001257513107004621020230 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # CFLAGS = FFLAGS = CPPFLAGS = FPPFLAGS = LOCDIR = src/pep/examples/tests/ EXAMPLESC = test1.c test2.c test3.c EXAMPLESF = test3f.F MANSEC = PEP TESTS = test1 test2 test3 test3f TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \ test2.PETSc runtest2_1 runtest2_2 runtest2_3 runtest2_4 test2.rm \ test3.PETSc runtest3_1 test3.rm TESTEXAMPLES_FORTRAN = test3f.PETSc runtest3f_1 test3f.rm \ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common test1: test1.o chkopts -${CLINKER} -o test1 test1.o ${SLEPC_PEP_LIB} ${RM} test1.o test2: test2.o chkopts -${CLINKER} -o test2 test2.o ${SLEPC_PEP_LIB} ${RM} test2.o test3: test3.o chkopts -${CLINKER} -o test3 test3.o ${SLEPC_PEP_LIB} ${RM} test3.o test3f: test3f.o chkopts -${FLINKER} -o test3f test3f.o ${SLEPC_PEP_LIB} ${RM} test3f.o #------------------------------------------------------------------------------------ PEP = toar qarnoldi EPS = krylovschur gd TESTCODE = \ [ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \ ${DIFF} output/$${test}.out $${test}.tmp || \ echo "Possible problem with $${test}, diffs above"; \ ${RM} -f $${test}.tmp runtest1_1: -@test=test1_1; \ for pep in ${PEP}; do \ echo "pep type $$pep"; \ ${MPIEXEC} -n 1 ./test1 -type $$pep -m 11 2>&1; \ done > $${test}.tmp; \ for eps in ${EPS}; do \ echo "pep type linear, eps type $$eps"; \ ${MPIEXEC} -n 1 ./test1 -type linear -epstype $$eps -m 11 2>&1; \ done >> $${test}.tmp; \ ${TESTCODE} runtest2_1: -@test=test2_1; \ for pep in ${PEP}; do \ echo "pep type $$pep"; \ if [ $$pep = qarnoldi ]; then EXTRA="-st_transform"; else EXTRA=""; fi; \ ${MPIEXEC} -n 1 ./test2 -pep_type $$pep -pep_nev 4 $$EXTRA 2>&1; \ done > $${test}.tmp; \ for eps in ${EPS}; do \ echo "pep type linear, eps type $$eps"; \ ${MPIEXEC} -n 1 ./test2 -pep_type linear -pep_linear_eps_type $$eps -pep_nev 4 -pep_linear_explicitmatrix 2>&1; \ done >> $${test}.tmp; \ ${TESTCODE} runtest2_2: -@test=test2_2; \ echo "toar with shift-and-invert" > $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_type toar -st_type sinvert -pep_target -0.4 -pep_nev 4 2>&1 >> $${test}.tmp; \ echo "toar with shift-and-invert (with scale=both)" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_type toar -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_scale both 2>&1 >> $${test}.tmp; \ echo "toar with shift-and-invert (transform)" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_type toar -st_type sinvert -pep_target -0.4 -pep_nev 4 -st_transform 2>&1 >> $${test}.tmp; \ echo "qarnoldi with shift-and-invert (transform)" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_type qarnoldi -st_type sinvert -pep_target -0.4 -pep_nev 4 -st_transform 2>&1 >> $${test}.tmp; \ echo "linear with shift-and-invert" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_type linear -pep_target -0.4 -pep_nev 4 -st_type sinvert 2>&1 >> $${test}.tmp; \ ${TESTCODE} runtest2_3: -@test=test2_3; \ echo "no extraction" > $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract none 2>&1 >> $${test}.tmp; \ echo "norm extraction" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract norm 2>&1 >> $${test}.tmp; \ echo "residual extraction" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract residual 2>&1 >> $${test}.tmp; \ echo "structured extraction" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract structured 2>&1 >> $${test}.tmp; \ ${TESTCODE} runtest2_4: -@test=test2_4; \ echo "simple refinement schur" > $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine simple -pep_refine_scheme schur 2>&1 >> $${test}.tmp; \ echo "simple refinement mbe" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine simple -pep_refine_scheme mbe -pep_refine_ksp_type preonly -pep_refine_pc_type lu >> $${test}.tmp; \ echo "simple refinement explicit" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine simple -pep_refine_scheme explicit >> $${test}.tmp; \ echo "multiple refinement" >> $${test}.tmp; \ ${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine multiple 2>&1 >> $${test}.tmp; \ ${TESTCODE} runtest3_1: -@test=test3_1; \ ${MPIEXEC} -n 1 ./test3 -pep_tol 1e-7 2>&1 > $${test}.tmp; \ ${TESTCODE} runtest3f_1: -@test=test3f_1; \ ${MPIEXEC} -n 1 ./test3f -pep_tol 1e-7 2>&1 > $${test}.tmp; \ ${TESTCODE} slepc-3.7.4/src/pep/examples/tests/test1.c.html0000644000175000017500000003662513107004621020701 0ustar jromanjroman

Actual source code: test1.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test the solution of a PEP without calling PEPSetFromOptions (based on ex16.c).\n\n"
 23:   "The command line options are:\n"
 24:   "  -n <n>, where <n> = number of grid subdivisions in x dimension.\n"
 25:   "  -m <m>, where <m> = number of grid subdivisions in y dimension.\n"
 26:   "  -type <pep_type> = pep type to test.\n"
 27:   "  -epstype <eps_type> = eps type to test (for linear).\n\n";

 29: #include <slepcpep.h>

 33: int main(int argc,char **argv)
 34: {
 35:   Mat            M,C,K,A[3];      /* problem matrices */
 36:   PEP            pep;             /* polynomial eigenproblem solver context */
 37:   PEPType        type;
 38:   PetscInt       N,n=10,m,Istart,Iend,II,nev,maxit,i,j;
 39:   PetscBool      flag,isgd2,epsgiven;
 40:   char           peptype[30] = "linear",epstype[30] = "";
 41:   EPS            eps;
 42:   ST             st;
 43:   KSP            ksp;
 44:   PC             pc;

 47:   SlepcInitialize(&argc,&argv,(char*)0,help);

 49:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 50:   PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);
 51:   if (!flag) m=n;
 52:   N = n*m;
 53:   PetscOptionsGetString(NULL,NULL,"-type",peptype,30,NULL);
 54:   PetscOptionsGetString(NULL,NULL,"-epstype",epstype,30,&epsgiven);
 55:   PetscPrintf(PETSC_COMM_WORLD,"\nQuadratic Eigenproblem, N=%D (%Dx%D grid)",N,n,m);
 56:   PetscPrintf(PETSC_COMM_WORLD,"\nPEP type: %s",peptype);
 57:   if (epsgiven) {
 58:     PetscPrintf(PETSC_COMM_WORLD,"\nEPS type: %s",epstype);
 59:   }
 60:   PetscPrintf(PETSC_COMM_WORLD,"\n\n");

 62:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 63:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 64:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 66:   /* K is the 2-D Laplacian */
 67:   MatCreate(PETSC_COMM_WORLD,&K);
 68:   MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,N,N);
 69:   MatSetFromOptions(K);
 70:   MatSetUp(K);
 71:   MatGetOwnershipRange(K,&Istart,&Iend);
 72:   for (II=Istart;II<Iend;II++) {
 73:     i = II/n; j = II-i*n;
 74:     if (i>0) { MatSetValue(K,II,II-n,-1.0,INSERT_VALUES); }
 75:     if (i<m-1) { MatSetValue(K,II,II+n,-1.0,INSERT_VALUES); }
 76:     if (j>0) { MatSetValue(K,II,II-1,-1.0,INSERT_VALUES); }
 77:     if (j<n-1) { MatSetValue(K,II,II+1,-1.0,INSERT_VALUES); }
 78:     MatSetValue(K,II,II,4.0,INSERT_VALUES);
 79:   }
 80:   MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY);
 81:   MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY);

 83:   /* C is the 1-D Laplacian on horizontal lines */
 84:   MatCreate(PETSC_COMM_WORLD,&C);
 85:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,N,N);
 86:   MatSetFromOptions(C);
 87:   MatSetUp(C);
 88:   MatGetOwnershipRange(C,&Istart,&Iend);
 89:   for (II=Istart;II<Iend;II++) {
 90:     i = II/n; j = II-i*n;
 91:     if (j>0) { MatSetValue(C,II,II-1,-1.0,INSERT_VALUES); }
 92:     if (j<n-1) { MatSetValue(C,II,II+1,-1.0,INSERT_VALUES); }
 93:     MatSetValue(C,II,II,2.0,INSERT_VALUES);
 94:   }
 95:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
 96:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);

 98:   /* M is a diagonal matrix */
 99:   MatCreate(PETSC_COMM_WORLD,&M);
100:   MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,N,N);
101:   MatSetFromOptions(M);
102:   MatSetUp(M);
103:   MatGetOwnershipRange(M,&Istart,&Iend);
104:   for (II=Istart;II<Iend;II++) {
105:     MatSetValue(M,II,II,(PetscReal)(II+1),INSERT_VALUES);
106:   }
107:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
108:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);

110:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111:                 Create the eigensolver and set various options
112:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

114:   PEPCreate(PETSC_COMM_WORLD,&pep);
115:   A[0] = K; A[1] = C; A[2] = M;
116:   PEPSetOperators(pep,3,A);
117:   PEPSetProblemType(pep,PEP_GENERAL);
118:   PEPSetDimensions(pep,4,20,PETSC_DEFAULT);
119:   PEPSetTolerances(pep,PETSC_SMALL,PETSC_DEFAULT);

121:   /*
122:      Set solver type at runtime
123:   */
124:   PEPSetType(pep,peptype);
125:   if (epsgiven) {
126:     PetscObjectTypeCompare((PetscObject)pep,PEPLINEAR,&flag);
127:     if (flag) {
128:       PEPLinearGetEPS(pep,&eps);
129:       PetscStrcmp(epstype,"gd2",&isgd2);
130:       if (isgd2) {
131:         EPSSetType(eps,EPSGD);
132:         EPSGDSetDoubleExpansion(eps,PETSC_TRUE);
133:       } else {
134:         EPSSetType(eps,epstype);
135:       }
136:       EPSGetST(eps,&st);
137:       STGetKSP(st,&ksp);
138:       KSPGetPC(ksp,&pc);
139:       PCSetType(pc,PCJACOBI);
140:       PetscObjectTypeCompare((PetscObject)eps,EPSGD,&flag);
141:     }
142:     PEPLinearSetExplicitMatrix(pep,PETSC_TRUE);
143:   }
144:   PetscObjectTypeCompare((PetscObject)pep,PEPQARNOLDI,&flag);
145:   if (flag) {
146:     PEPGetST(pep,&st);
147:     STSetTransform(st,PETSC_TRUE);
148:   }

150:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
151:                       Solve the eigensystem
152:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

154:   PEPSolve(pep);

156:   /*
157:      Optional: Get some information from the solver and display it
158:   */
159:   PEPGetType(pep,&type);
160:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
161:   PEPGetDimensions(pep,&nev,NULL,NULL);
162:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
163:   PEPGetTolerances(pep,NULL,&maxit);
164:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: maxit=%D\n",maxit);

166:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
167:                     Display solution and clean up
168:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

170:   PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
171:   PEPDestroy(&pep);
172:   MatDestroy(&M);
173:   MatDestroy(&C);
174:   MatDestroy(&K);
175:   SlepcFinalize();
176:   return ierr;
177: }

slepc-3.7.4/src/pep/examples/tests/test3f.F.html0000644000175000017500000005433613107004621021013 0ustar jromanjroman
Actual source code: test3f.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 19: !
 20: !  Description: Simple example to test the PEP Fortran interface.
 21: !
 22: ! ---------------------------------------------------------------------- 
 23: !
 24:       program main
 25:       implicit none

 27: #include <petsc/finclude/petscsys.h>
 28: #include <petsc/finclude/petscvec.h>
 29: #include <petsc/finclude/petscmat.h>
 30: #include <petsc/finclude/petscviewer.h>
 31: #include <slepc/finclude/slepcsys.h>
 32: #include <slepc/finclude/slepcpep.h>

 34: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 35: !     Declarations
 36: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 37:       Mat                A(3),B
 38:       PEP                pep
 39:       ST                 st
 40:       KSP                ksp
 41:       DS                 ds
 42:       PetscReal          tol,tolabs,alpha,lambda
 43:       PetscScalar        tget,val
 44:       PetscInt           n,i,its,Istart,Iend
 45:       PetscInt           nev,ncv,mpd,nmat,np
 46:       PEPWhich           which
 47:       PEPConvergedReason reason
 48:       PEPType            tname
 49:       PEPExtract         extr
 50:       PEPBasis           basis
 51:       PEPScale           scal
 52:       PEPRefine          refine
 53:       PEPRefineScheme    rscheme
 54:       PEPConv            conv
 55:       PEPStop            stp
 56:       PEPProblemType     ptype
 57:       PetscMPIInt        rank
 58:       PetscErrorCode     ierr
 59:       SlepcConvMonitor   ctx
 60:       PetscViewerAndFormat vf

 62: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 63: !     Beginning of program
 64: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

 66:       call SlepcInitialize(PETSC_NULL_CHARACTER,ierr)
 67:       call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
 68:       n = 20
 69:       if (rank .eq. 0) then
 70:         write(*,100) n
 71:       endif
 72:  100  format (/'Diagonal Quadratic Eigenproblem, n =',I3,' (Fortran)')

 74:       call MatCreate(PETSC_COMM_WORLD,A(1),ierr)
 75:       call MatSetSizes(A(1),PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
 76:       call MatSetFromOptions(A(1),ierr)
 77:       call MatSetUp(A(1),ierr)
 78:       call MatGetOwnershipRange(A(1),Istart,Iend,ierr)
 79:       do i=Istart,Iend-1
 80:         val = i+1.
 81:         call MatSetValue(A(1),i,i,val,INSERT_VALUES,ierr)
 82:       enddo
 83:       call MatAssemblyBegin(A(1),MAT_FINAL_ASSEMBLY,ierr)
 84:       call MatAssemblyEnd(A(1),MAT_FINAL_ASSEMBLY,ierr)

 86:       call MatCreate(PETSC_COMM_WORLD,A(2),ierr)
 87:       call MatSetSizes(A(2),PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
 88:       call MatSetFromOptions(A(2),ierr)
 89:       call MatSetUp(A(2),ierr)
 90:       call MatGetOwnershipRange(A(2),Istart,Iend,ierr)
 91:       do i=Istart,Iend-1
 92:         val = 1
 93:         call MatSetValue(A(2),i,i,val,INSERT_VALUES,ierr)
 94:       enddo
 95:       call MatAssemblyBegin(A(2),MAT_FINAL_ASSEMBLY,ierr)
 96:       call MatAssemblyEnd(A(2),MAT_FINAL_ASSEMBLY,ierr)

 98:       call MatCreate(PETSC_COMM_WORLD,A(3),ierr)
 99:       call MatSetSizes(A(3),PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)
100:       call MatSetFromOptions(A(3),ierr)
101:       call MatSetUp(A(3),ierr)
102:       call MatGetOwnershipRange(A(3),Istart,Iend,ierr)
103:       do i=Istart,Iend-1
104:         val = n/(i+1.)
105:         call MatSetValue(A(3),i,i,val,INSERT_VALUES,ierr)
106:       enddo
107:       call MatAssemblyBegin(A(3),MAT_FINAL_ASSEMBLY,ierr)
108:       call MatAssemblyEnd(A(3),MAT_FINAL_ASSEMBLY,ierr)

110: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
111: !     Create eigensolver and test interface functions
112: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

114:       call PEPCreate(PETSC_COMM_WORLD,pep,ierr)
115:       nmat = 3
116:       call PEPSetOperators(pep,nmat,A,ierr)
117:       call PEPGetNumMatrices(pep,nmat,ierr)
118:       if (rank .eq. 0) then
119:         write(*,110) nmat-1
120:       endif
121:  110  format (' Polynomial of degree ',I2)
122:       i = 0
123:       call PEPGetOperators(pep,i,B,ierr)
124:       call MatView(B,PETSC_NULL_OBJECT,ierr)

126:       call PEPSetType(pep,PEPTOAR,ierr)
127:       call PEPGetType(pep,tname,ierr)
128:       if (rank .eq. 0) then
129:         write(*,120) tname
130:       endif
131:  120  format (' Type set to ',A)

133:       call PEPGetProblemType(pep,ptype,ierr)
134:       if (rank .eq. 0) then
135:         write(*,130) ptype
136:       endif
137:  130  format (' Problem type before changing = ',I2)
138:       call PEPSetProblemType(pep,PEP_HERMITIAN,ierr)
139:       call PEPGetProblemType(pep,ptype,ierr)
140:       if (rank .eq. 0) then
141:         write(*,140) ptype
142:       endif
143:  140  format (' ... changed to ',I2)

145:       call PEPGetExtract(pep,extr,ierr)
146:       if (rank .eq. 0) then
147:         write(*,150) extr
148:       endif
149:  150  format (' Extraction before changing = ',I2)
150:       call PEPSetExtract(pep,PEP_EXTRACT_STRUCTURED,ierr)
151:       call PEPGetExtract(pep,extr,ierr)
152:       if (rank .eq. 0) then
153:         write(*,160) extr
154:       endif
155:  160  format (' ... changed to ',I2)

157:       alpha = .1
158:       its = 5
159:       lambda = 1.
160:       scal = PEP_SCALE_SCALAR
161:       call PEPSetScale(pep,scal,alpha,PETSC_NULL_OBJECT,                &
162:      &                 PETSC_NULL_OBJECT,its,lambda,ierr)
163:       call PEPGetScale(pep,scal,alpha,PETSC_NULL_OBJECT,                &
164:      &                 PETSC_NULL_OBJECT,its,lambda,ierr)
165:       if (rank .eq. 0) then
166:         write(*,170) scal,alpha,its
167:       endif
168:  170  format (' Scaling: ',I2,', alpha=',F6.4,', its=',I2)

170:       basis = PEP_BASIS_CHEBYSHEV1
171:       call PEPSetBasis(pep,basis,ierr)
172:       call PEPGetBasis(pep,basis,ierr)
173:       if (rank .eq. 0) then
174:         write(*,180) basis
175:       endif
176:  180  format (' Polynomial basis: ',I2)
177:  
178:       np = 1
179:       tol = 1e-9
180:       its = 2
181:       refine = PEP_REFINE_SIMPLE
182:       rscheme = PEP_REFINE_SCHEME_SCHUR
183:       call PEPSetRefine(pep,refine,np,tol,its,rscheme,ierr)
184:       call PEPGetRefine(pep,refine,np,tol,its,rscheme,ierr)
185:       if (rank .eq. 0) then
186:         write(*,190) refine,tol,its,rscheme
187:       endif
188:  190  format (' Refinement: ',I2,', tol=',F6.4,', its=',I2', schem=',I2)

190:       tget = 4.8
191:       call PEPSetTarget(pep,tget,ierr)
192:       call PEPGetTarget(pep,tget,ierr)
193:       call PEPSetWhichEigenpairs(pep,PEP_TARGET_MAGNITUDE,ierr)
194:       call PEPGetWhichEigenpairs(pep,which,ierr)
195:       if (rank .eq. 0) then
196:         write(*,200) which,PetscRealPart(tget)
197:       endif
198:  200  format (' Which = ',I2,', target = ',F3.1)

200:       nev = 4
201:       call PEPSetDimensions(pep,nev,PETSC_DEFAULT_INTEGER,              &
202:      &                      PETSC_DEFAULT_INTEGER,ierr)
203:       call PEPGetDimensions(pep,nev,ncv,mpd,ierr)
204:       if (rank .eq. 0) then
205:         write(*,210) nev,ncv,mpd
206:       endif
207:  210  format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2)

209:       tol = 2.2e-4
210:       its = 200
211:       call PEPSetTolerances(pep,tol,its,ierr)
212:       call PEPGetTolerances(pep,tol,its,ierr)
213:       if (rank .eq. 0) then
214:         write(*,220) tol,its
215:       endif
216:  220  format (' Tolerance =',F7.5,', max_its =',I4)

218:       call PEPSetConvergenceTest(pep,PEP_CONV_ABS,ierr)
219:       call PEPGetConvergenceTest(pep,conv,ierr)
220:       call PEPSetStoppingTest(pep,PEP_STOP_BASIC,ierr)
221:       call PEPGetStoppingTest(pep,stp,ierr)
222:       if (rank .eq. 0) then
223:         write(*,230) conv,stp
224:       endif
225:  230  format (' Convergence test =',I2,', stopping test =',I2)

227:       call PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,        &
228:      &                   PETSC_VIEWER_DEFAULT,vf,ierr)
229:       call PEPMonitorSet(pep,PEPMONITORFIRST,vf,                        &
230:      &                   PetscViewerAndFormatDestroy,ierr)
231:       call SlepcConvMonitorCreate(PETSC_VIEWER_STDOUT_WORLD,            &
232:      &                   PETSC_VIEWER_DEFAULT,ctx,ierr)
233:       call PEPMonitorSet(pep,PEPMONITORCONVERGED,ctx,                   &
234:      &                   SlepcConvMonitorDestroy,ierr)
235:       call PEPMonitorCancel(pep,ierr)

237:       call PEPGetST(pep,st,ierr) 
238:       call STGetKSP(st,ksp,ierr) 
239:       tol = 1.e-8
240:       tolabs = 1.e-35
241:       call KSPSetTolerances(ksp,tol,tolabs,PETSC_DEFAULT_REAL,          &
242:      &                      PETSC_DEFAULT_INTEGER,ierr)
243:       call STView(st,PETSC_NULL_OBJECT,ierr) 
244:       call PEPGetDS(pep,ds,ierr) 
245:       call DSView(ds,PETSC_NULL_OBJECT,ierr) 

247:       call PEPSetFromOptions(pep,ierr)
248:       call PEPSolve(pep,ierr) 
249:       call PEPGetConvergedReason(pep,reason,ierr)
250:       call PEPGetIterationNumber(pep,its,ierr)
251:       if (rank .eq. 0) then
252:         write(*,240) reason,its
253:       endif
254:  240  format (' Finished - converged reason =',I2,', its=',I4)

256: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
257: !     Display solution and clean up
258: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
259:       call PEPErrorView(pep,PEP_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr)
260:       call PEPDestroy(pep,ierr)
261:       call MatDestroy(A(1),ierr)
262:       call MatDestroy(A(2),ierr)
263:       call MatDestroy(A(3),ierr)

265:       call SlepcFinalize(ierr)
266:       end
slepc-3.7.4/src/pep/examples/tests/test3f.F0000644000175000017500000002257513107004621020050 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! ! Description: Simple example to test the PEP Fortran interface. ! ! ---------------------------------------------------------------------- ! program main implicit none #include #include #include #include #include #include ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Declarations ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mat A(3),B PEP pep ST st KSP ksp DS ds PetscReal tol,tolabs,alpha,lambda PetscScalar tget,val PetscInt n,i,its,Istart,Iend PetscInt nev,ncv,mpd,nmat,np PEPWhich which PEPConvergedReason reason PEPType tname PEPExtract extr PEPBasis basis PEPScale scal PEPRefine refine PEPRefineScheme rscheme PEPConv conv PEPStop stp PEPProblemType ptype PetscMPIInt rank PetscErrorCode ierr SlepcConvMonitor ctx PetscViewerAndFormat vf ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Beginning of program ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call SlepcInitialize(PETSC_NULL_CHARACTER,ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) n = 20 if (rank .eq. 0) then write(*,100) n endif 100 format (/'Diagonal Quadratic Eigenproblem, n =',I3,' (Fortran)') call MatCreate(PETSC_COMM_WORLD,A(1),ierr) call MatSetSizes(A(1),PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A(1),ierr) call MatSetUp(A(1),ierr) call MatGetOwnershipRange(A(1),Istart,Iend,ierr) do i=Istart,Iend-1 val = i+1. call MatSetValue(A(1),i,i,val,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A(1),MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A(1),MAT_FINAL_ASSEMBLY,ierr) call MatCreate(PETSC_COMM_WORLD,A(2),ierr) call MatSetSizes(A(2),PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A(2),ierr) call MatSetUp(A(2),ierr) call MatGetOwnershipRange(A(2),Istart,Iend,ierr) do i=Istart,Iend-1 val = 1 call MatSetValue(A(2),i,i,val,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A(2),MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A(2),MAT_FINAL_ASSEMBLY,ierr) call MatCreate(PETSC_COMM_WORLD,A(3),ierr) call MatSetSizes(A(3),PETSC_DECIDE,PETSC_DECIDE,n,n,ierr) call MatSetFromOptions(A(3),ierr) call MatSetUp(A(3),ierr) call MatGetOwnershipRange(A(3),Istart,Iend,ierr) do i=Istart,Iend-1 val = n/(i+1.) call MatSetValue(A(3),i,i,val,INSERT_VALUES,ierr) enddo call MatAssemblyBegin(A(3),MAT_FINAL_ASSEMBLY,ierr) call MatAssemblyEnd(A(3),MAT_FINAL_ASSEMBLY,ierr) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Create eigensolver and test interface functions ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call PEPCreate(PETSC_COMM_WORLD,pep,ierr) nmat = 3 call PEPSetOperators(pep,nmat,A,ierr) call PEPGetNumMatrices(pep,nmat,ierr) if (rank .eq. 0) then write(*,110) nmat-1 endif 110 format (' Polynomial of degree ',I2) i = 0 call PEPGetOperators(pep,i,B,ierr) call MatView(B,PETSC_NULL_OBJECT,ierr) call PEPSetType(pep,PEPTOAR,ierr) call PEPGetType(pep,tname,ierr) if (rank .eq. 0) then write(*,120) tname endif 120 format (' Type set to ',A) call PEPGetProblemType(pep,ptype,ierr) if (rank .eq. 0) then write(*,130) ptype endif 130 format (' Problem type before changing = ',I2) call PEPSetProblemType(pep,PEP_HERMITIAN,ierr) call PEPGetProblemType(pep,ptype,ierr) if (rank .eq. 0) then write(*,140) ptype endif 140 format (' ... changed to ',I2) call PEPGetExtract(pep,extr,ierr) if (rank .eq. 0) then write(*,150) extr endif 150 format (' Extraction before changing = ',I2) call PEPSetExtract(pep,PEP_EXTRACT_STRUCTURED,ierr) call PEPGetExtract(pep,extr,ierr) if (rank .eq. 0) then write(*,160) extr endif 160 format (' ... changed to ',I2) alpha = .1 its = 5 lambda = 1. scal = PEP_SCALE_SCALAR call PEPSetScale(pep,scal,alpha,PETSC_NULL_OBJECT, & & PETSC_NULL_OBJECT,its,lambda,ierr) call PEPGetScale(pep,scal,alpha,PETSC_NULL_OBJECT, & & PETSC_NULL_OBJECT,its,lambda,ierr) if (rank .eq. 0) then write(*,170) scal,alpha,its endif 170 format (' Scaling: ',I2,', alpha=',F6.4,', its=',I2) basis = PEP_BASIS_CHEBYSHEV1 call PEPSetBasis(pep,basis,ierr) call PEPGetBasis(pep,basis,ierr) if (rank .eq. 0) then write(*,180) basis endif 180 format (' Polynomial basis: ',I2) np = 1 tol = 1e-9 its = 2 refine = PEP_REFINE_SIMPLE rscheme = PEP_REFINE_SCHEME_SCHUR call PEPSetRefine(pep,refine,np,tol,its,rscheme,ierr) call PEPGetRefine(pep,refine,np,tol,its,rscheme,ierr) if (rank .eq. 0) then write(*,190) refine,tol,its,rscheme endif 190 format (' Refinement: ',I2,', tol=',F6.4,', its=',I2', schem=',I2) tget = 4.8 call PEPSetTarget(pep,tget,ierr) call PEPGetTarget(pep,tget,ierr) call PEPSetWhichEigenpairs(pep,PEP_TARGET_MAGNITUDE,ierr) call PEPGetWhichEigenpairs(pep,which,ierr) if (rank .eq. 0) then write(*,200) which,PetscRealPart(tget) endif 200 format (' Which = ',I2,', target = ',F3.1) nev = 4 call PEPSetDimensions(pep,nev,PETSC_DEFAULT_INTEGER, & & PETSC_DEFAULT_INTEGER,ierr) call PEPGetDimensions(pep,nev,ncv,mpd,ierr) if (rank .eq. 0) then write(*,210) nev,ncv,mpd endif 210 format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2) tol = 2.2e-4 its = 200 call PEPSetTolerances(pep,tol,its,ierr) call PEPGetTolerances(pep,tol,its,ierr) if (rank .eq. 0) then write(*,220) tol,its endif 220 format (' Tolerance =',F7.5,', max_its =',I4) call PEPSetConvergenceTest(pep,PEP_CONV_ABS,ierr) call PEPGetConvergenceTest(pep,conv,ierr) call PEPSetStoppingTest(pep,PEP_STOP_BASIC,ierr) call PEPGetStoppingTest(pep,stp,ierr) if (rank .eq. 0) then write(*,230) conv,stp endif 230 format (' Convergence test =',I2,', stopping test =',I2) call PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD, & & PETSC_VIEWER_DEFAULT,vf,ierr) call PEPMonitorSet(pep,PEPMONITORFIRST,vf, & & PetscViewerAndFormatDestroy,ierr) call SlepcConvMonitorCreate(PETSC_VIEWER_STDOUT_WORLD, & & PETSC_VIEWER_DEFAULT,ctx,ierr) call PEPMonitorSet(pep,PEPMONITORCONVERGED,ctx, & & SlepcConvMonitorDestroy,ierr) call PEPMonitorCancel(pep,ierr) call PEPGetST(pep,st,ierr) call STGetKSP(st,ksp,ierr) tol = 1.e-8 tolabs = 1.e-35 call KSPSetTolerances(ksp,tol,tolabs,PETSC_DEFAULT_REAL, & & PETSC_DEFAULT_INTEGER,ierr) call STView(st,PETSC_NULL_OBJECT,ierr) call PEPGetDS(pep,ds,ierr) call DSView(ds,PETSC_NULL_OBJECT,ierr) call PEPSetFromOptions(pep,ierr) call PEPSolve(pep,ierr) call PEPGetConvergedReason(pep,reason,ierr) call PEPGetIterationNumber(pep,its,ierr) if (rank .eq. 0) then write(*,240) reason,its endif 240 format (' Finished - converged reason =',I2,', its=',I4) ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! Display solution and clean up ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call PEPErrorView(pep,PEP_ERROR_RELATIVE,PETSC_NULL_OBJECT,ierr) call PEPDestroy(pep,ierr) call MatDestroy(A(1),ierr) call MatDestroy(A(2),ierr) call MatDestroy(A(3),ierr) call SlepcFinalize(ierr) end slepc-3.7.4/src/pep/examples/tests/makefile.html0000644000175000017500000002117213107004621021164 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

CFLAGS     =
FFLAGS     =
CPPFLAGS   =
FPPFLAGS   =
LOCDIR     = src/pep/examples/tests/
EXAMPLESC  = test1.c test2.c test3.c
EXAMPLESF  = test3f.F
MANSEC     = PEP
TESTS      = test1 test2 test3 test3f

TESTEXAMPLES_C       = test1.PETSc runtest1_1 test1.rm \
                       test2.PETSc runtest2_1 runtest2_2 runtest2_3 runtest2_4 test2.rm \
                       test3.PETSc runtest3_1 test3.rm
TESTEXAMPLES_FORTRAN = test3f.PETSc runtest3f_1 test3f.rm \

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

test1: test1.o chkopts
	-${CLINKER} -o test1 test1.o ${SLEPC_PEP_LIB}
	${RM} test1.o

test2: test2.o chkopts
	-${CLINKER} -o test2 test2.o ${SLEPC_PEP_LIB}
	${RM} test2.o

test3: test3.o chkopts
	-${CLINKER} -o test3 test3.o ${SLEPC_PEP_LIB}
	${RM} test3.o

test3f: test3f.o chkopts
	-${FLINKER} -o test3f test3f.o ${SLEPC_PEP_LIB}
	${RM} test3f.o

#------------------------------------------------------------------------------------
PEP = toar qarnoldi
EPS = krylovschur gd

TESTCODE = \
	[ x${SAVE_OUTPUT} = xyes ] && cp $${test}.tmp output/$${test}.out; \
	${DIFF} output/$${test}.out $${test}.tmp || \
	echo "Possible problem with $${test}, diffs above"; \
	${RM} -f $${test}.tmp

runtest1_1:
	-@test=test1_1; \
	for pep in ${PEP}; do \
	   echo "pep type $$pep"; \
	   ${MPIEXEC} -n 1 ./test1 -type $$pep -m 11 2>&1; \
	done > $${test}.tmp; \
	for eps in ${EPS}; do \
	    echo "pep type linear, eps type $$eps"; \
	    ${MPIEXEC} -n 1 ./test1 -type linear -epstype $$eps -m 11 2>&1; \
	done >> $${test}.tmp; \
	${TESTCODE}

runtest2_1:
	-@test=test2_1; \
	for pep in ${PEP}; do \
	   echo "pep type $$pep"; \
	   if [ $$pep = qarnoldi ]; then EXTRA="-st_transform"; else EXTRA=""; fi; \
	   ${MPIEXEC} -n 1 ./test2 -pep_type $$pep -pep_nev 4 $$EXTRA 2>&1; \
	done > $${test}.tmp; \
	for eps in ${EPS}; do \
	   echo "pep type linear, eps type $$eps"; \
	   ${MPIEXEC} -n 1 ./test2 -pep_type linear -pep_linear_eps_type $$eps -pep_nev 4 -pep_linear_explicitmatrix 2>&1; \
	done >> $${test}.tmp; \
	${TESTCODE}

runtest2_2:
	-@test=test2_2; \
	echo "toar with shift-and-invert" > $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_type toar -st_type sinvert -pep_target -0.4 -pep_nev 4 2>&1 >> $${test}.tmp; \
	echo "toar with shift-and-invert (with scale=both)" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_type toar -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_scale both 2>&1 >> $${test}.tmp; \
	echo "toar with shift-and-invert (transform)" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_type toar -st_type sinvert -pep_target -0.4 -pep_nev 4 -st_transform 2>&1 >> $${test}.tmp; \
	echo "qarnoldi with shift-and-invert (transform)" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_type qarnoldi -st_type sinvert -pep_target -0.4 -pep_nev 4 -st_transform 2>&1 >> $${test}.tmp; \
	echo "linear with shift-and-invert" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_type linear -pep_target -0.4 -pep_nev 4 -st_type sinvert 2>&1 >> $${test}.tmp; \
	${TESTCODE}

runtest2_3:
	-@test=test2_3; \
	echo "no extraction" > $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract none 2>&1 >> $${test}.tmp; \
	echo "norm extraction" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract norm 2>&1 >> $${test}.tmp; \
	echo "residual extraction" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract residual 2>&1 >> $${test}.tmp; \
	echo "structured extraction" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -pep_nev 12 -pep_extract structured 2>&1 >> $${test}.tmp; \
	${TESTCODE}

runtest2_4:
	-@test=test2_4; \
	echo "simple refinement schur" > $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine simple -pep_refine_scheme schur 2>&1 >> $${test}.tmp; \
	echo "simple refinement mbe" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine simple -pep_refine_scheme mbe -pep_refine_ksp_type preonly -pep_refine_pc_type lu >> $${test}.tmp; \
	echo "simple refinement explicit" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine simple -pep_refine_scheme explicit >> $${test}.tmp; \
	echo "multiple refinement" >> $${test}.tmp; \
	${MPIEXEC} -n 1 ./test2 -st_type sinvert -pep_target -0.4 -pep_nev 4 -pep_refine multiple 2>&1 >> $${test}.tmp; \
	${TESTCODE}

runtest3_1:
	-@test=test3_1; \
	${MPIEXEC} -n 1 ./test3 -pep_tol 1e-7 2>&1 > $${test}.tmp; \
	${TESTCODE}

runtest3f_1:
	-@test=test3f_1; \
	${MPIEXEC} -n 1 ./test3f -pep_tol 1e-7 2>&1 > $${test}.tmp; \
	${TESTCODE}

slepc-3.7.4/src/pep/examples/tests/test1.c0000644000175000017500000001720113107004621017723 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test the solution of a PEP without calling PEPSetFromOptions (based on ex16.c).\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions in x dimension.\n" " -m , where = number of grid subdivisions in y dimension.\n" " -type = pep type to test.\n" " -epstype = eps type to test (for linear).\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PEPType type; PetscInt N,n=10,m,Istart,Iend,II,nev,maxit,i,j; PetscBool flag,isgd2,epsgiven; char peptype[30] = "linear",epstype[30] = ""; EPS eps; ST st; KSP ksp; PC pc; PetscErrorCode ierr; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag);CHKERRQ(ierr); if (!flag) m=n; N = n*m; ierr = PetscOptionsGetString(NULL,NULL,"-type",peptype,30,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetString(NULL,NULL,"-epstype",epstype,30,&epsgiven);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nQuadratic Eigenproblem, N=%D (%Dx%D grid)",N,n,m);CHKERRQ(ierr); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nPEP type: %s",peptype);CHKERRQ(ierr); if (epsgiven) { ierr = PetscPrintf(PETSC_COMM_WORLD,"\nEPS type: %s",epstype);CHKERRQ(ierr); } ierr = PetscPrintf(PETSC_COMM_WORLD,"\n\n");CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is the 2-D Laplacian */ ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr); ierr = MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,N,N);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatSetUp(K);CHKERRQ(ierr); ierr = MatGetOwnershipRange(K,&Istart,&Iend);CHKERRQ(ierr); for (II=Istart;II0) { ierr = MatSetValue(K,II,II-n,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (i0) { ierr = MatSetValue(K,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j0) { ierr = MatSetValue(C,II,II-1,-1.0,INSERT_VALUES);CHKERRQ(ierr); } if (j. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static char help[] = "Test PEP interface functions.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat A[3],B; /* problem matrices */ PEP pep; /* eigenproblem solver context */ ST st; KSP ksp; DS ds; PetscReal tol,alpha; PetscScalar target; PetscInt n=20,i,its,nev,ncv,mpd,Istart,Iend,nmat; PEPWhich which; PEPConvergedReason reason; PEPType type; PEPExtract extr; PEPBasis basis; PEPScale scale; PEPRefine refine; PEPRefineScheme rscheme; PEPConv conv; PEPStop stop; PEPProblemType ptype; PetscErrorCode ierr; PetscViewerAndFormat *vf; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Quadratic Eigenproblem, n=%D\n\n",n);CHKERRQ(ierr); ierr = MatCreate(PETSC_COMM_WORLD,&A[0]);CHKERRQ(ierr); ierr = MatSetSizes(A[0],PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(A[0]);CHKERRQ(ierr); ierr = MatSetUp(A[0]);CHKERRQ(ierr); ierr = MatGetOwnershipRange(A[0],&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;iActual source code: test2.c
slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 21:    Example based on spring problem in NLEVP collection [1]. See the parameters
 22:    meaning at Example 2 in [2].

 24:    [1] T. Betcke, N. J. Higham, V. Mehrmann, C. Schroder, and F. Tisseur,
 25:        NLEVP: A Collection of Nonlinear Eigenvalue Problems, MIMS EPrint
 26:        2010.98, November 2010.
 27:    [2] F. Tisseur, Backward error and condition of polynomial eigenvalue
 28:        problems, Linear Algebra and its Applications, 309 (2000), pp. 339--361,
 29:        April 2000.
 30: */

 32: static char help[] = "Test the solution of a PEP from a finite element model of "
 33:   "damped mass-spring system (problem from NLEVP collection).\n\n"
 34:   "The command line options are:\n"
 35:   "  -n <n>, where <n> = number of grid subdivisions.\n"
 36:   "  -tau <tau>, where <tau> = tau parameter.\n"
 37:   "  -kappa <kappa>, where <kappa> = kappa parameter.\n\n";

 39: #include <slepcpep.h>

 43: int main(int argc,char **argv)
 44: {
 45:   Mat            M,C,K,A[3];      /* problem matrices */
 46:   PEP            pep;             /* polynomial eigenproblem solver context */
 47:   PEPType        type;
 49:   PetscInt       n=30,Istart,Iend,i,maxit,nev;
 50:   PetscScalar    mu=1.0,tau=10.0,kappa=5.0;

 52:   SlepcInitialize(&argc,&argv,(char*)0,help);

 54:   PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);
 55:   PetscOptionsGetScalar(NULL,NULL,"-mu",&mu,NULL);
 56:   PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);
 57:   PetscOptionsGetScalar(NULL,NULL,"-kappa",&kappa,NULL);

 59:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 60:      Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0
 61:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 63:   /* K is a tridiagonal */
 64:   MatCreate(PETSC_COMM_WORLD,&K);
 65:   MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);
 66:   MatSetFromOptions(K);
 67:   MatSetUp(K);

 69:   MatGetOwnershipRange(K,&Istart,&Iend);
 70:   for (i=Istart;i<Iend;i++) {
 71:     if (i>0) {
 72:       MatSetValue(K,i,i-1,-kappa,INSERT_VALUES);
 73:     }
 74:     MatSetValue(K,i,i,kappa*3.0,INSERT_VALUES);
 75:     if (i<n-1) {
 76:       MatSetValue(K,i,i+1,-kappa,INSERT_VALUES);
 77:     }
 78:   }

 80:   MatAssemblyBegin(K,MAT_FINAL_ASSEMBLY);
 81:   MatAssemblyEnd(K,MAT_FINAL_ASSEMBLY);

 83:   /* C is a tridiagonal */
 84:   MatCreate(PETSC_COMM_WORLD,&C);
 85:   MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n);
 86:   MatSetFromOptions(C);
 87:   MatSetUp(C);

 89:   MatGetOwnershipRange(C,&Istart,&Iend);
 90:   for (i=Istart;i<Iend;i++) {
 91:     if (i>0) {
 92:       MatSetValue(C,i,i-1,-tau,INSERT_VALUES);
 93:     }
 94:     MatSetValue(C,i,i,tau*3.0,INSERT_VALUES);
 95:     if (i<n-1) {
 96:       MatSetValue(C,i,i+1,-tau,INSERT_VALUES);
 97:     }
 98:   }

100:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
101:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);

103:   /* M is a diagonal matrix */
104:   MatCreate(PETSC_COMM_WORLD,&M);
105:   MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,n,n);
106:   MatSetFromOptions(M);
107:   MatSetUp(M);
108:   MatGetOwnershipRange(M,&Istart,&Iend);
109:   for (i=Istart;i<Iend;i++) {
110:     MatSetValue(M,i,i,mu,INSERT_VALUES);
111:   }
112:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
113:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);

115:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
116:                 Create the eigensolver and set various options
117:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

119:   PEPCreate(PETSC_COMM_WORLD,&pep);
120:   A[0] = K; A[1] = C; A[2] = M;
121:   PEPSetOperators(pep,3,A);
122:   PEPSetProblemType(pep,PEP_GENERAL);
123:   PEPSetTolerances(pep,PETSC_SMALL,PETSC_DEFAULT);
124:   PEPSetFromOptions(pep);

126:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
127:                       Solve the eigensystem
128:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

130:   PEPSolve(pep);

132:   /*
133:      Optional: Get some information from the solver and display it
134:   */
135:   PEPGetType(pep,&type);
136:   PetscPrintf(PETSC_COMM_WORLD," Solution method: %s\n\n",type);
137:   PEPGetDimensions(pep,&nev,NULL,NULL);
138:   PetscPrintf(PETSC_COMM_WORLD," Number of requested eigenvalues: %D\n",nev);
139:   PEPGetTolerances(pep,NULL,&maxit);
140:   PetscPrintf(PETSC_COMM_WORLD," Stopping condition: maxit=%D\n",maxit);

142:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
143:                     Display solution and clean up
144:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

146:   PEPErrorView(pep,PEP_ERROR_BACKWARD,NULL);
147:   PEPDestroy(&pep);
148:   MatDestroy(&M);
149:   MatDestroy(&C);
150:   MatDestroy(&K);
151:   SlepcFinalize();
152:   return ierr;
153: }
slepc-3.7.4/src/pep/examples/tests/output/0000755000175000017500000000000013107004621020056 5ustar jromanjromanslepc-3.7.4/src/pep/examples/tests/output/test2_1.out0000644000175000017500000000164413107004621022075 0ustar jromanjromanpep type toar Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388 pep type qarnoldi Solution method: qarnoldi Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388 pep type linear, eps type krylovschur Solution method: linear Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388 pep type linear, eps type gd Solution method: linear Number of requested eigenvalues: 4 Stopping condition: maxit=2000 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388 slepc-3.7.4/src/pep/examples/tests/output/test3_1.out0000644000175000017500000000270513107004621022075 0ustar jromanjroman Diagonal Quadratic Eigenproblem, n=20 Polynomial of degree 2 Mat Object: 1 MPI processes type: seqaij row 0: (0, 1.) row 1: (1, 2.) row 2: (2, 3.) row 3: (3, 4.) row 4: (4, 5.) row 5: (5, 6.) row 6: (6, 7.) row 7: (7, 8.) row 8: (8, 9.) row 9: (9, 10.) row 10: (10, 11.) row 11: (11, 12.) row 12: (12, 13.) row 13: (13, 14.) row 14: (14, 15.) row 15: (15, 16.) row 16: (16, 17.) row 17: (17, 18.) row 18: (18, 19.) row 19: (19, 20.) Type set to toar Problem type before changing = 0 ... changed to 2. Extraction before changing = 0 ... changed to 4 Scaling: SCALAR, alpha=0.1, its=5 Polynomial basis: CHEBYSHEV1 Refinement: SIMPLE, tol=1e-09, its=2, scheme=SCHUR Which = 7, target = 4.8 Dimensions: nev=4, ncv=0, mpd=0 Tolerance = 0.00022, max_its = 200 Convergence test = 0, stopping test = 0 ST Object: 1 MPI processes type not yet set shift: 0. number of matrices: 0 KSP Object: (st_) 1 MPI processes type not yet set maximum iterations=10000, initial guess is zero tolerances: relative=1e-08, absolute=1e-50, divergence=10000. left preconditioning using DEFAULT norm type for convergence test PC Object: (st_) 1 MPI processes type not yet set PC has not been set up so information may be incomplete DS Object: 1 MPI processes type not yet set Finished - converged reason = 1, its=17 All requested eigenvalues computed up to the required tolerance: 0.67682, 0.60795, 0.48824, 0.27016 slepc-3.7.4/src/pep/examples/tests/output/test2_4.out0000644000175000017500000000160513107004621022075 0ustar jromanjromansimple refinement schur Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 simple refinement mbe Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 simple refinement explicit Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 multiple refinement Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 slepc-3.7.4/src/pep/examples/tests/output/test1_1.out0000644000175000017500000000247713107004621022101 0ustar jromanjromanpep type toar Quadratic Eigenproblem, N=110 (10x11 grid) PEP type: toar Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -1.16404+1.65363i, -1.16404-1.65363i, -0.51784+1.31039i, -0.51784-1.31039i pep type qarnoldi Quadratic Eigenproblem, N=110 (10x11 grid) PEP type: qarnoldi Solution method: qarnoldi Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -1.16404+1.65363i, -1.16404-1.65363i, -0.51784+1.31039i, -0.51784-1.31039i pep type linear, eps type krylovschur Quadratic Eigenproblem, N=110 (10x11 grid) PEP type: linear EPS type: krylovschur Solution method: linear Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -1.16404+1.65363i, -1.16404-1.65363i, -0.51784+1.31039i, -0.51784-1.31039i pep type linear, eps type gd Quadratic Eigenproblem, N=110 (10x11 grid) PEP type: linear EPS type: gd Solution method: linear Number of requested eigenvalues: 4 Stopping condition: maxit=2000 All requested eigenvalues computed up to the required tolerance: -1.16404+1.65363i, -1.16404-1.65363i, -0.51784+1.31039i, -0.51784-1.31039i slepc-3.7.4/src/pep/examples/tests/output/test2_2.out0000644000175000017500000000225713107004621022077 0ustar jromanjromantoar with shift-and-invert Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 toar with shift-and-invert (with scale=both) Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 toar with shift-and-invert (transform) Solution method: toar Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 qarnoldi with shift-and-invert (transform) Solution method: qarnoldi Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 linear with shift-and-invert Solution method: linear Number of requested eigenvalues: 4 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -0.50511, -0.50515, -0.50520, -0.50528 slepc-3.7.4/src/pep/examples/tests/output/test2_3.out0000644000175000017500000000237413107004621022100 0ustar jromanjromanno extraction Solution method: toar Number of requested eigenvalues: 12 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388, -46.98155, -45.90976, -44.66950, -43.27349, -41.73606, -40.07296, -38.30127, -36.43915 norm extraction Solution method: toar Number of requested eigenvalues: 12 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388, -46.98155, -45.90976, -44.66950, -43.27349, -41.73606, -40.07296, -38.30127, -36.43915 residual extraction Solution method: toar Number of requested eigenvalues: 12 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388, -46.98155, -45.90976, -44.66950, -43.27349, -41.73606, -40.07296, -38.30127, -36.43915 structured extraction Solution method: toar Number of requested eigenvalues: 12 Stopping condition: maxit=100 All requested eigenvalues computed up to the required tolerance: -49.39227, -49.08545, -48.57759, -47.87388, -46.98155, -45.90976, -44.66950, -43.27349, -41.73606, -40.07296, -38.30127, -36.43915 slepc-3.7.4/src/pep/examples/tests/output/test3f_1.out0000644000175000017500000000303113107004621022234 0ustar jromanjroman Diagonal Quadratic Eigenproblem, n = 20 (Fortran) Polynomial of degree 2 Mat Object: 1 MPI processes type: seqaij row 0: (0, 1.) row 1: (1, 2.) row 2: (2, 3.) row 3: (3, 4.) row 4: (4, 5.) row 5: (5, 6.) row 6: (6, 7.) row 7: (7, 8.) row 8: (8, 9.) row 9: (9, 10.) row 10: (10, 11.) row 11: (11, 12.) row 12: (12, 13.) row 13: (13, 14.) row 14: (14, 15.) row 15: (15, 16.) row 16: (16, 17.) row 17: (17, 18.) row 18: (18, 19.) row 19: (19, 20.) Type set to toar Problem type before changing = 0 ... changed to 2 Extraction before changing = 0 ... changed to 4 Scaling: 1, alpha=0.1000, its= 5 Polynomial basis: 1 Refinement: 1, tol=0.0000, its= 2, schem= 1 Which = 7, target = 4.8 Dimensions: nev= 4, ncv= 0, mpd= 0 Tolerance =0.00022, max_its = 200 Convergence test = 0, stopping test = 0 ST Object: 1 MPI processes type not yet set shift: 0. number of matrices: 0 KSP Object: (st_) 1 MPI processes type not yet set maximum iterations=10000, initial guess is zero tolerances: relative=1e-08, absolute=1e-35, divergence=10000. left preconditioning using DEFAULT norm type for convergence test PC Object: (st_) 1 MPI processes type not yet set PC has not been set up so information may be incomplete DS Object: 1 MPI processes type not yet set Finished - converged reason = 1, its= 17 All requested eigenvalues computed up to the required tolerance: 0.67682, 0.60795, 0.48824, 0.27016 slepc-3.7.4/src/pep/examples/tests/index.html0000644000175000017500000000344413107004621020520 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

test1.c: Test the solution of a PEP without calling PEPSetFromOptions (based on ex16
test2.c: Test the solution of a PEP from a finite element model of
test3.c: Test PEP interface functions
makefile
slepc-3.7.4/src/pep/examples/tests/test3.c.html0000644000175000017500000004207313107004621020675 0ustar jromanjroman

Actual source code: test3.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
  4:    Copyright (c) 2002-2016, 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: static char help[] = "Test PEP interface functions.\n\n";

 24: #include <slepcpep.h>

 28: int main(int argc,char **argv)
 29: {
 30:   Mat                A[3],B;      /* problem matrices */
 31:   PEP                pep;         /* eigenproblem solver context */
 32:   ST                 st;
 33:   KSP                ksp;
 34:   DS                 ds;
 35:   PetscReal          tol,alpha;
 36:   PetscScalar        target;
 37:   PetscInt           n=20,i,its,nev,ncv,mpd,Istart,Iend,nmat;
 38:   PEPWhich           which;
 39:   PEPConvergedReason reason;
 40:   PEPType            type;
 41:   PEPExtract         extr;
 42:   PEPBasis           basis;
 43:   PEPScale           scale;
 44:   PEPRefine          refine;
 45:   PEPRefineScheme    rscheme;
 46:   PEPConv            conv;
 47:   PEPStop            stop;
 48:   PEPProblemType     ptype;
 49:   PetscErrorCode     ierr;
 50:   PetscViewerAndFormat *vf;

 52:   SlepcInitialize(&argc,&argv,(char*)0,help);
 53:   PetscPrintf(PETSC_COMM_WORLD,"\nDiagonal Quadratic Eigenproblem, n=%D\n\n",n);

 55:   MatCreate(PETSC_COMM_WORLD,&A[0]);
 56:   MatSetSizes(A[0],PETSC_DECIDE,PETSC_DECIDE,n,n);
 57:   MatSetFromOptions(A[0]);
 58:   MatSetUp(A[0]);
 59:   MatGetOwnershipRange(A[0],&Istart,&Iend);
 60:   for (i=Istart;i<Iend;i++) {
 61:     MatSetValue(A[0],i,i,i+1,INSERT_VALUES);
 62:   }
 63:   MatAssemblyBegin(A[0],MAT_FINAL_ASSEMBLY);
 64:   MatAssemblyEnd(A[0],MAT_FINAL_ASSEMBLY);

 66:   MatCreate(PETSC_COMM_WORLD,&A[1]);
 67:   MatSetSizes(A[1],PETSC_DECIDE,PETSC_DECIDE,n,n);
 68:   MatSetFromOptions(A[1]);
 69:   MatSetUp(A[1]);
 70:   MatGetOwnershipRange(A[1],&Istart,&Iend);
 71:   for (i=Istart;i<Iend;i++) {
 72:     MatSetValue(A[1],i,i,1.0,INSERT_VALUES);
 73:   }
 74:   MatAssemblyBegin(A[1],MAT_FINAL_ASSEMBLY);
 75:   MatAssemblyEnd(A[1],MAT_FINAL_ASSEMBLY);

 77:   MatCreate(PETSC_COMM_WORLD,&A[2]);
 78:   MatSetSizes(A[2],PETSC_DECIDE,PETSC_DECIDE,n,n);
 79:   MatSetFromOptions(A[2]);
 80:   MatSetUp(A[2]);
 81:   MatGetOwnershipRange(A[1],&Istart,&Iend);
 82:   for (i=Istart;i<Iend;i++) {
 83:     MatSetValue(A[2],i,i,n/(PetscReal)(i+1),INSERT_VALUES);
 84:   }
 85:   MatAssemblyBegin(A[2],MAT_FINAL_ASSEMBLY);
 86:   MatAssemblyEnd(A[2],MAT_FINAL_ASSEMBLY);

 88:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 89:              Create eigensolver and test interface functions
 90:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 91:   PEPCreate(PETSC_COMM_WORLD,&pep);
 92:   PEPSetOperators(pep,3,A);
 93:   PEPGetNumMatrices(pep,&nmat);
 94:   PetscPrintf(PETSC_COMM_WORLD," Polynomial of degree %d\n",(int)nmat-1);
 95:   PEPGetOperators(pep,0,&B);
 96:   MatView(B,NULL);

 98:   PEPSetType(pep,PEPTOAR);
 99:   PEPGetType(pep,&type);
100:   PetscPrintf(PETSC_COMM_WORLD," Type set to %s\n",type);

102:   PEPGetProblemType(pep,&ptype);
103:   PetscPrintf(PETSC_COMM_WORLD," Problem type before changing = %d",(int)ptype);
104:   PEPSetProblemType(pep,PEP_HERMITIAN);
105:   PEPGetProblemType(pep,&ptype);
106:   PetscPrintf(PETSC_COMM_WORLD," ... changed to %d.",(int)ptype);

108:   PEPGetExtract(pep,&extr);
109:   PetscPrintf(PETSC_COMM_WORLD,"\n Extraction before changing = %d",(int)extr);
110:   PEPSetExtract(pep,PEP_EXTRACT_STRUCTURED);
111:   PEPGetExtract(pep,&extr);
112:   PetscPrintf(PETSC_COMM_WORLD," ... changed to %d\n",(int)extr);

114:   PEPSetScale(pep,PEP_SCALE_SCALAR,.1,NULL,NULL,5,1.0);
115:   PEPGetScale(pep,&scale,&alpha,NULL,NULL,&its,NULL);
116:   PetscPrintf(PETSC_COMM_WORLD," Scaling: %s, alpha=%g, its=%D\n",PEPScaleTypes[scale],(double)alpha,its);

118:   PEPSetBasis(pep,PEP_BASIS_CHEBYSHEV1);
119:   PEPGetBasis(pep,&basis);
120:   PetscPrintf(PETSC_COMM_WORLD," Polynomial basis: %s\n",PEPBasisTypes[basis]);

122:   PEPSetRefine(pep,PEP_REFINE_SIMPLE,1,1e-9,2,PEP_REFINE_SCHEME_SCHUR);
123:   PEPGetRefine(pep,&refine,NULL,&tol,&its,&rscheme);
124:   PetscPrintf(PETSC_COMM_WORLD," Refinement: %s, tol=%g, its=%D, scheme=%s\n",PEPRefineTypes[refine],(double)tol,its,PEPRefineSchemes[rscheme]);

126:   PEPSetTarget(pep,4.8);
127:   PEPGetTarget(pep,&target);
128:   PEPSetWhichEigenpairs(pep,PEP_TARGET_MAGNITUDE);
129:   PEPGetWhichEigenpairs(pep,&which);
130:   PetscPrintf(PETSC_COMM_WORLD," Which = %d, target = %g\n",(int)which,(double)PetscRealPart(target));

132:   PEPSetDimensions(pep,4,PETSC_DEFAULT,PETSC_DEFAULT);
133:   PEPGetDimensions(pep,&nev,&ncv,&mpd);
134:   PetscPrintf(PETSC_COMM_WORLD," Dimensions: nev=%D, ncv=%D, mpd=%D\n",nev,ncv,mpd);

136:   PEPSetTolerances(pep,2.2e-4,200);
137:   PEPGetTolerances(pep,&tol,&its);
138:   PetscPrintf(PETSC_COMM_WORLD," Tolerance = %.5f, max_its = %D\n",(double)tol,its);

140:   PEPSetConvergenceTest(pep,PEP_CONV_ABS);
141:   PEPGetConvergenceTest(pep,&conv);
142:   PEPSetStoppingTest(pep,PEP_STOP_BASIC);
143:   PEPGetStoppingTest(pep,&stop);
144:   PetscPrintf(PETSC_COMM_WORLD," Convergence test = %d, stopping test = %d\n",(int)conv,(int)stop);

146:   PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_DEFAULT,&vf);
147:   PEPMonitorSet(pep,(PetscErrorCode (*)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*))PEPMonitorFirst,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);
148:   PEPMonitorCancel(pep);

150:   PEPGetST(pep,&st);
151:   STGetKSP(st,&ksp);
152:   KSPSetTolerances(ksp,1e-8,1e-50,PETSC_DEFAULT,PETSC_DEFAULT);
153:   STView(st,NULL);
154:   PEPGetDS(pep,&ds);
155:   DSView(ds,NULL);

157:   PEPSetFromOptions(pep);
158:   PEPSolve(pep);
159:   PEPGetConvergedReason(pep,&reason);
160:   PEPGetIterationNumber(pep,&its);
161:   PetscPrintf(PETSC_COMM_WORLD," Finished - converged reason = %d, its=%D\n",(int)reason,its);

163:   /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
164:                     Display solution and clean up
165:      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
166:   PEPErrorView(pep,PEP_ERROR_RELATIVE,NULL);
167:   PEPDestroy(&pep);
168:   MatDestroy(&A[0]);
169:   MatDestroy(&A[1]);
170:   MatDestroy(&A[2]);
171:   SlepcFinalize();
172:   return ierr;
173: }
slepc-3.7.4/src/pep/examples/tests/test2.c0000644000175000017500000001432113107004621017724 0ustar jromanjroman/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Example based on spring problem in NLEVP collection [1]. See the parameters meaning at Example 2 in [2]. [1] T. Betcke, N. J. Higham, V. Mehrmann, C. Schroder, and F. Tisseur, NLEVP: A Collection of Nonlinear Eigenvalue Problems, MIMS EPrint 2010.98, November 2010. [2] F. Tisseur, Backward error and condition of polynomial eigenvalue problems, Linear Algebra and its Applications, 309 (2000), pp. 339--361, April 2000. */ static char help[] = "Test the solution of a PEP from a finite element model of " "damped mass-spring system (problem from NLEVP collection).\n\n" "The command line options are:\n" " -n , where = number of grid subdivisions.\n" " -tau , where = tau parameter.\n" " -kappa , where = kappa parameter.\n\n"; #include #undef __FUNCT__ #define __FUNCT__ "main" int main(int argc,char **argv) { Mat M,C,K,A[3]; /* problem matrices */ PEP pep; /* polynomial eigenproblem solver context */ PEPType type; PetscErrorCode ierr; PetscInt n=30,Istart,Iend,i,maxit,nev; PetscScalar mu=1.0,tau=10.0,kappa=5.0; SlepcInitialize(&argc,&argv,(char*)0,help); ierr = PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-mu",&mu,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-tau",&tau,NULL);CHKERRQ(ierr); ierr = PetscOptionsGetScalar(NULL,NULL,"-kappa",&kappa,NULL);CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compute the matrices that define the eigensystem, (k^2*M+k*C+K)x=0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* K is a tridiagonal */ ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr); ierr = MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,n,n);CHKERRQ(ierr); ierr = MatSetFromOptions(K);CHKERRQ(ierr); ierr = MatSetUp(K);CHKERRQ(ierr); ierr = MatGetOwnershipRange(K,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;i0) { ierr = MatSetValue(K,i,i-1,-kappa,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(K,i,i,kappa*3.0,INSERT_VALUES);CHKERRQ(ierr); if (i0) { ierr = MatSetValue(C,i,i-1,-tau,INSERT_VALUES);CHKERRQ(ierr); } ierr = MatSetValue(C,i,i,tau*3.0,INSERT_VALUES);CHKERRQ(ierr); if (i
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

SOURCEH  = ../../include/slepc/private/pepimpl.h ../../include/slepcpep.h
DIRS     = interface impls examples f90-mod
LOCDIR   = src/pep/
MANSEC   = PEP

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/pep/index.html0000644000175000017500000000345213107004621015537 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

interface/
impls/
examples/
f90-mod/
../../include/slepc/private/pepimpl.h
../../include/slepcpep.h
makefile
slepc-3.7.4/src/pep/f90-mod/0000755000175000017500000000000013107004621014711 5ustar jromanjromanslepc-3.7.4/src/pep/f90-mod/makefile0000644000175000017500000000255113107004621016414 0ustar jromanjroman # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # #requiresdefine 'PETSC_USING_F90' # # Makes Fortran module functions from *.h90 files in include/slepc/finclude # ALL: buildmod_slepc speciallib: buildmod_slepc specialfastlib: buildmod_slepc SPECIALLIB = yes SPECIALFASTLIB = yes CFLAGS = FFLAGS = SOURCEC = SOURCEF = slepcpepmod.F SOURCEH = LIBBASE = libslepcpep MANSEC = PEP LOCDIR = src/pep/f90-mod/ CLEANFILES = *.mod include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/f90-mod/slepcpepmod.F.html0000644000175000017500000000602413107004621020300 0ustar jromanjroman

Actual source code: slepcpepmod.F

slepc-3.7.4 2017-05-17
  1: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2: !  SLEPc - Scalable Library for Eigenvalue Problem Computations
  3: !  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
  4: !
  5: !  This file is part of SLEPc.
  6: !     
  7: !  SLEPc is free software: you can redistribute it and/or modify it under  the
  8: !  terms of version 3 of the GNU Lesser General Public License as published by
  9: !  the Free Software Foundation.
 10: !
 11: !  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY 
 12: !  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS 
 13: !  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for 
 14: !  more details.
 15: !
 16: !  You  should have received a copy of the GNU Lesser General  Public  License
 17: !  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
 18: !  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 20: #define PETSC_USE_FORTRAN_MODULES

 22:         module slepcpepdef
 23:         use slepcst
 24:         use slepcbv
 25:         use slepcrg
 26:         use slepcds
 27:         use slepceps
 28: #include <slepc/finclude/slepcpep.h>
 29: #include <slepc/finclude/ftn-custom/slepcpepdef.h90>
 30:         end module

 32:         module slepcpep
 33:         use slepcpepdef
 34: #include <slepc/finclude/slepcpep.h90>
 35:         end module

slepc-3.7.4/src/pep/f90-mod/slepcpepmod.F0000644000175000017500000000243613107004621017340 0ustar jromanjroman! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ! SLEPc - Scalable Library for Eigenvalue Problem Computations ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain ! ! This file is part of SLEPc. ! ! SLEPc is free software: you can redistribute it and/or modify it under the ! terms of version 3 of the GNU Lesser General Public License as published by ! the Free Software Foundation. ! ! SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for ! more details. ! ! You should have received a copy of the GNU Lesser General Public License ! along with SLEPc. If not, see . ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define PETSC_USE_FORTRAN_MODULES module slepcpepdef use slepcst use slepcbv use slepcrg use slepcds use slepceps #include #include end module module slepcpep use slepcpepdef #include end module slepc-3.7.4/src/pep/f90-mod/makefile.html0000644000175000017500000000552413107004621017362 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#requiresdefine   'PETSC_USING_F90'
#
#   Makes Fortran module functions from *.h90 files in include/slepc/finclude
#
ALL: buildmod_slepc
speciallib: buildmod_slepc
specialfastlib: buildmod_slepc
SPECIALLIB     = yes
SPECIALFASTLIB = yes


CFLAGS     =
FFLAGS     =
SOURCEC    =
SOURCEF    = slepcpepmod.F
SOURCEH    =
LIBBASE    = libslepcpep
MANSEC     = PEP
LOCDIR     = src/pep/f90-mod/
CLEANFILES = *.mod

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/pep/f90-mod/index.html0000644000175000017500000000305713107004621016713 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

slepcpepmod.F
makefile
slepc-3.7.4/src/pep/impls/0000755000175000017500000000000013107004621014662 5ustar jromanjromanslepc-3.7.4/src/pep/impls/makefile0000644000175000017500000000206713107004621016367 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib LIBBASE = libslepcpep DIRS = linear krylov jd LOCDIR = src/pep/impls/ MANSEC = PEP include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/makefile.html0000644000175000017500000000455313107004621017334 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

LIBBASE  = libslepcpep
DIRS     = linear krylov jd
LOCDIR   = src/pep/impls/
MANSEC   = PEP

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/pep/impls/jd/0000755000175000017500000000000013107004621015257 5ustar jromanjromanslepc-3.7.4/src/pep/impls/jd/makefile0000644000175000017500000000216713107004621016765 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = pjd.c pjdopt.c SOURCEF = SOURCEH = pjdp.h LIBBASE = libslepcpep DIRS = MANSEC = PEP LOCDIR = src/pep/impls/jd/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/jd/pjdopt.c.html0000644000175000017500000002604513107004621017675 0ustar jromanjroman
Actual source code: pjdopt.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Options of polynomial JD solver.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>    /*I "slepcpep.h" I*/
 25:  #include pjdp.h

 29: PetscErrorCode PEPJDSetRestart_JD(PEP pep,PetscReal keep)
 30: {
 31:   PEP_JD *pjd = (PEP_JD*)pep->data;

 34:   if (keep==PETSC_DEFAULT) pjd->keep = 0.5;
 35:   else {
 36:     if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]");
 37:     pjd->keep = keep;
 38:   }
 39:   return(0);
 40: }

 44: /*@
 45:    PEPJDSetRestart - Sets the restart parameter for the Jacobi-Davidson
 46:    method, in particular the proportion of basis vectors that must be kept
 47:    after restart.

 49:    Logically Collective on PEP

 51:    Input Parameters:
 52: +  pep  - the eigenproblem solver context
 53: -  keep - the number of vectors to be kept at restart

 55:    Options Database Key:
 56: .  -pep_jd_restart - Sets the restart parameter

 58:    Notes:
 59:    Allowed values are in the range [0.1,0.9]. The default is 0.5.

 61:    Level: advanced

 63: .seealso: PEPJDGetRestart()
 64: @*/
 65: PetscErrorCode PEPJDSetRestart(PEP pep,PetscReal keep)
 66: {

 72:   PetscTryMethod(pep,"PEPJDSetRestart_C",(PEP,PetscReal),(pep,keep));
 73:   return(0);
 74: }

 78: PetscErrorCode PEPJDGetRestart_JD(PEP pep,PetscReal *keep)
 79: {
 80:   PEP_JD *pjd = (PEP_JD*)pep->data;

 83:   *keep = pjd->keep;
 84:   return(0);
 85: }

 89: /*@
 90:    PEPJDGetRestart - Gets the restart parameter used in the Jacobi-Davidson method.

 92:    Not Collective

 94:    Input Parameter:
 95: .  pep - the eigenproblem solver context

 97:    Output Parameter:
 98: .  keep - the restart parameter

100:    Level: advanced

102: .seealso: PEPJDSetRestart()
103: @*/
104: PetscErrorCode PEPJDGetRestart(PEP pep,PetscReal *keep)
105: {

111:   PetscUseMethod(pep,"PEPJDGetRestart_C",(PEP,PetscReal*),(pep,keep));
112:   return(0);
113: }

117: PetscErrorCode PEPSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,PEP pep)
118: {
120:   PetscBool      flg;
121:   PetscReal      r1;
122:   KSP            ksp;

125:   PetscOptionsHead(PetscOptionsObject,"PEP JD Options");
126:   PetscOptionsReal("-pep_jd_restart","Proportion of vectors kept after restart","PEPJDSetRestart",0.5,&r1,&flg);
127:   if (flg) {
128:     PEPJDSetRestart(pep,r1);
129:   }
130:   /* Set STPRECOND as the default ST */
131:   if (!pep->st) { PEPGetST(pep,&pep->st); }
132:   if (!((PetscObject)pep->st)->type_name) {
133:     STSetType(pep->st,STPRECOND);
134:   }

136:   /* Set the default options of the KSP */
137:   STGetKSP(pep->st,&ksp);
138:   if (!((PetscObject)ksp)->type_name) {
139:     KSPSetType(ksp,KSPBCGSL);
140:     KSPSetTolerances(ksp,1e-5,PETSC_DEFAULT,PETSC_DEFAULT,100);
141:   }
142:   PetscOptionsTail();
143:   return(0);
144: }

148: PetscErrorCode PEPView_JD(PEP pep,PetscViewer viewer)
149: {
151:   PEP_JD         *pjd = (PEP_JD*)pep->data;
152:   PetscBool      isascii;

155:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
156:   if (isascii) {
157:     PetscViewerASCIIPrintf(viewer,"  JD: %d%% of basis vectors kept after restart\n",(int)(100*pjd->keep));
158:   }
159:   return(0);
160: }

slepc-3.7.4/src/pep/impls/jd/pjd.c0000644000175000017500000012533113107004621016205 0ustar jromanjroman/* SLEPc polynomial eigensolver: "jd" Method: Jacobi-Davidson Algorithm: Jacobi-Davidson for polynomial eigenvalue problems. Based on code contributed by the authors of [2] below. References: [1] G.L.G. Sleijpen et al., "Jacobi-Davidson type methods for generalized eigenproblems and polynomial eigenproblems", BIT 36(3):595-633, 1996. [2] Feng-Nan Hwang, Zih-Hao Wei, Tsung-Ming Huang, Weichung Wang, "A Parallel Additive Schwarz Preconditioned Jacobi-Davidson Algorithm for Polynomial Eigenvalue Problems in Quantum Dot Simulation", J. Comput. Phys. 229(8):2932-2947, 2010. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include "pjdp.h" #include #undef __FUNCT__ #define __FUNCT__ "PEPJDDuplicateBasis" /* Duplicate and resize auxiliary basis */ static PetscErrorCode PEPJDDuplicateBasis(PEP pep,BV *basis) { PetscErrorCode ierr; PetscInt nloc,m; PetscMPIInt rank,nproc; BVType type; BVOrthogType otype; BVOrthogRefineType oref; PetscReal oeta; BVOrthogBlockType oblock; PetscFunctionBegin; if (pep->nev>1) { ierr = BVCreate(PetscObjectComm((PetscObject)pep),basis);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rank);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pep),&nproc);CHKERRQ(ierr); ierr = BVGetSizes(pep->V,&nloc,NULL,&m);CHKERRQ(ierr); if (rank==nproc-1) nloc += pep->nev-1; ierr = BVSetSizes(*basis,nloc,PETSC_DECIDE,m);CHKERRQ(ierr); ierr = BVGetType(pep->V,&type);CHKERRQ(ierr); ierr = BVSetType(*basis,type);CHKERRQ(ierr); ierr = BVGetOrthogonalization(pep->V,&otype,&oref,&oeta,&oblock);CHKERRQ(ierr); ierr = BVSetOrthogonalization(*basis,otype,oref,oeta,oblock);CHKERRQ(ierr); ierr = PetscObjectStateIncrease((PetscObject)*basis);CHKERRQ(ierr); } else { ierr = BVDuplicate(pep->V,basis);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetUp_JD" PetscErrorCode PEPSetUp_JD(PEP pep) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PetscBool isprecond,flg; PetscInt i; KSP ksp; PetscFunctionBegin; pep->lineariz = PETSC_FALSE; ierr = PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);CHKERRQ(ierr); if (!pep->max_it) pep->max_it = PetscMax(100,2*pep->n/pep->ncv); if (!pep->which) pep->which = PEP_TARGET_MAGNITUDE; if (pep->which != PEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"PEPJD only supports which=target_magnitude");; /* Set STPRECOND as the default ST */ if (!((PetscObject)pep->st)->type_name) { ierr = STSetType(pep->st,STPRECOND);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)pep->st,STPRECOND,&isprecond);CHKERRQ(ierr); if (!isprecond) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"JD only works with PRECOND spectral transformation"); if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver not implemented for non-monomial bases"); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver requires the ST transformation flag unset, see STSetTransform()"); /* Set the default options of the KSP */ ierr = STGetKSP(pep->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPBCGSL);CHKERRQ(ierr); ierr = KSPSetTolerances(ksp,1e-5,PETSC_DEFAULT,PETSC_DEFAULT,100);CHKERRQ(ierr); } if (!pjd->keep) pjd->keep = 0.5; ierr = PEPAllocateSolution(pep,0);CHKERRQ(ierr); ierr = PEPSetWorkVecs(pep,5);CHKERRQ(ierr); ierr = PetscMalloc2(pep->nmat,&pjd->TV,pep->nmat,&pjd->AX);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = PEPJDDuplicateBasis(pep,pjd->TV+i);CHKERRQ(ierr); } ierr = PEPJDDuplicateBasis(pep,&pjd->W);CHKERRQ(ierr); if (pep->nev>1) { ierr = PEPJDDuplicateBasis(pep,&pjd->V);CHKERRQ(ierr); ierr = BVSetFromOptions(pjd->V);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = BVDuplicateResize(pep->V,pep->nev-1,pjd->AX+i);CHKERRQ(ierr); } ierr = BVDuplicateResize(pep->V,pep->nev,&pjd->X);CHKERRQ(ierr); ierr = PetscCalloc3((pep->nev)*(pep->nev),&pjd->XpX,pep->nev*pep->nev,&pjd->T,pep->nev*pep->nev*pep->nmat,&pjd->Tj);CHKERRQ(ierr); } else pjd->V = pep->V; ierr = DSSetType(pep->ds,DSPEP);CHKERRQ(ierr); ierr = DSPEPSetDegree(pep->ds,pep->nmat-1);CHKERRQ(ierr); ierr = DSAllocate(pep->ds,pep->ncv);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDUpdateTV" /* Updates columns (low to (high-1)) of TV[i] */ static PetscErrorCode PEPJDUpdateTV(PEP pep,PetscInt low,PetscInt high,Vec *w) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PetscInt pp,col,i,j,nloc,nconv,deg=pep->nmat-1; Vec v1,v2,t1,t2; PetscScalar *array1,*array2,*x2,*tt,*xx,*y2,zero=0.0,sone=1.0; PetscMPIInt rk,np,count; PetscBLASInt n,ld,one=1; PetscFunctionBegin; nconv = pjd->nconv; ierr = PetscMalloc3(nconv,&tt,nconv,&x2,nconv,&xx);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);CHKERRQ(ierr); ierr = BVGetSizes(pep->V,&nloc,NULL,NULL);CHKERRQ(ierr); t1 = w[0]; t2 = w[1]; for (col=low;colV,col,&v1);CHKERRQ(ierr); ierr = VecGetArray(v1,&array1);CHKERRQ(ierr); if (nconv>0) { if (rk==np-1) { for (i=0;inmat;pp++) { ierr = BVGetColumn(pjd->TV[pp],col,&v2);CHKERRQ(ierr); ierr = VecGetArray(v2,&array2);CHKERRQ(ierr); ierr = VecPlaceArray(t2,array2);CHKERRQ(ierr); ierr = MatMult(pep->A[pp],t1,t2);CHKERRQ(ierr); if (nconv) { ierr = PetscBLASIntCast(pjd->nconv,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(pep->nev,&ld);CHKERRQ(ierr); for (j=0;jnmat;i++) { ierr = BVMultVec(pjd->AX[i],1.0,1.0,t2,tt);CHKERRQ(ierr); if (i!=pep->nmat-1) PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,tt,&one)); } ierr = BVDotVec(pjd->X,t1,xx);CHKERRQ(ierr); if (rk==np-1 && ppTj+ld*ld*pp,&ld,y2,&one)); for (i=pp+1;inmat-1;i++) { PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&sone,pjd->XpX,&ld,xx,&one,&zero,tt,&one)); PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&n,pjd->Tj+ld*ld*i,&ld,tt,&one)); for (j=0;jnmat-2) PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,xx,&one)); } } } ierr = VecResetArray(t2);CHKERRQ(ierr); ierr = VecRestoreArray(v2,&array2);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->TV[pp],col,&v2);CHKERRQ(ierr); } ierr = VecResetArray(t1);CHKERRQ(ierr); ierr = VecRestoreArray(v1,&array1);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->V,col,&v1);CHKERRQ(ierr); } ierr = PetscFree3(tt,x2,xx);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDOrthogonalize" /* RRQR of X. Xin*P=Xou*R. Rank of R is rk */ static PetscErrorCode PEPJDOrthogonalize(PetscInt row,PetscInt col,PetscScalar *X,PetscInt ldx,PetscInt *rk,PetscInt *P,PetscScalar *R,PetscInt ldr) { #if defined(SLEPC_MISSING_LAPACK_GEQP3) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQP3 - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,j,n,r; PetscBLASInt row_,col_,ldx_,*p,lwork,info,n_; PetscScalar *tau,*work; PetscReal tol,*rwork; PetscFunctionBegin; ierr = PetscBLASIntCast(row,&row_);CHKERRQ(ierr); ierr = PetscBLASIntCast(col,&col_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldx,&ldx_);CHKERRQ(ierr); n = PetscMin(row,col); ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); lwork = 3*col_+1; ierr = PetscMalloc4(col,&p,n,&tau,lwork,&work,2*col,&rwork);CHKERRQ(ierr); for (i=1;itol) r++; else break; } if (rk) *rk=r; /* copy upper triangular matrix if requested */ if (R) { for (i=0;in; ps = ctx->ps; ld = ctx->ld; if (n) { ierr = PetscMalloc2(n,&x2,n,&t);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)pc),&rk);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pc),&np);CHKERRQ(ierr); if (rk==np-1) { ierr = VecGetLocalSize(ctx->work[0],&nloc);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&array1);CHKERRQ(ierr); for (i=0;iwork[0]; ty = ctx->work[1]; ierr = VecGetArrayRead(x,&array1);CHKERRQ(ierr); ierr = VecPlaceArray(tx,array1);CHKERRQ(ierr); ierr = VecGetArray(y,&array2);CHKERRQ(ierr); ierr = VecPlaceArray(ty,array2);CHKERRQ(ierr); ierr = PCApply(ctx->pc,tx,ty);CHKERRQ(ierr); if (n) { for (j=0;jM[i+j*ld]*x2[i]; } if (rk==np-1) for (i=0;iX,-1.0,1.0,ty,t);CHKERRQ(ierr); ierr = PetscFree2(x2,t);CHKERRQ(ierr); } ierr = VecResetArray(tx);CHKERRQ(ierr); ierr = VecResetArray(ty);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x,&array1);CHKERRQ(ierr); ierr = VecRestoreArray(y,&array2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PCShellApply_PEPJD" /* Application of shell preconditioner: y = B\x - eta*B\p, with eta = (u'*B\x)/(u'*B\p) */ static PetscErrorCode PCShellApply_PEPJD(PC pc,Vec x,Vec y) { PetscErrorCode ierr; PetscScalar eta; PEP_JD_PCSHELL *ctx; PetscFunctionBegin; ierr = PCShellGetContext(pc,(void**)&ctx);CHKERRQ(ierr); /* y = B\x apply extended PC */ ierr = PEPJDExtendedPCApply(pc,x,y);CHKERRQ(ierr); /* Compute eta = u'*y / u'*Bp */ ierr = VecDot(y,ctx->u,&eta);CHKERRQ(ierr); eta /= ctx->gamma; /* y = y - eta*Bp */ ierr = VecAXPY(y,-eta,ctx->Bp);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDCopyToExtendedVec" static PetscErrorCode PEPJDCopyToExtendedVec(PEP pep,Vec v,PetscScalar *a,PetscInt na,PetscInt off,Vec vex,PetscBool back) { PetscErrorCode ierr; PetscMPIInt np,rk,count; PetscScalar *array1,*array2; PetscInt nloc; PetscFunctionBegin; ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);CHKERRQ(ierr); ierr = BVGetSizes(pep->V,&nloc,NULL,NULL);CHKERRQ(ierr); if (v) { ierr = VecGetArray(v,&array1);CHKERRQ(ierr); ierr = VecGetArray(vex,&array2);CHKERRQ(ierr); if (back) { ierr = PetscMemcpy(array1,array2,nloc*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemcpy(array2,array1,nloc*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = VecRestoreArray(v,&array1);CHKERRQ(ierr); ierr = VecRestoreArray(vex,&array2);CHKERRQ(ierr); } if (a) { if (rk==np-1) { ierr = VecGetArray(vex,&array2);CHKERRQ(ierr); if (back) { ierr = PetscMemcpy(a,array2+nloc+off,na*sizeof(PetscScalar));CHKERRQ(ierr); } else { ierr = PetscMemcpy(array2+nloc+off,a,na*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = VecRestoreArray(vex,&array2);CHKERRQ(ierr); } if (back) { ierr = PetscMPIIntCast(na,&count);CHKERRQ(ierr); ierr = MPI_Bcast(a,count,MPIU_SCALAR,np-1,PetscObjectComm((PetscObject)pep));CHKERRQ(ierr); } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDComputePResidual" static PetscErrorCode PEPJDComputePResidual(PEP pep,Vec u,PetscScalar theta,Vec p,Vec *work) { PEP_JD *pjd = (PEP_JD*)pep->data; PetscErrorCode ierr; PetscMPIInt rk,np,count; Vec tu,tp,w; PetscScalar *array1,*array2,*x2=NULL,*y2,fact=1.0,*q=NULL,*tt=NULL,*xx=NULL,sone=1.0,zero=0.0; PetscInt i,j,nconv=pjd->nconv,nloc,deg=pep->nmat-1; PetscBLASInt n,ld,one=1; PetscFunctionBegin; if (nconv>0) { ierr = PetscMalloc4(nconv,&xx,nconv,&tt,nconv,&x2,nconv,&q);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);CHKERRQ(ierr); if (rk==np-1) { ierr = BVGetSizes(pep->V,&nloc,NULL,NULL);CHKERRQ(ierr); ierr = VecGetArray(u,&array1);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = MatMult(pep->A[i],tu,w);CHKERRQ(ierr); ierr = VecAXPY(tp,fact*(PetscReal)i,w);CHKERRQ(ierr); fact *= theta; } if (nconv) { ierr = PetscBLASIntCast(nconv,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(pep->nev,&ld);CHKERRQ(ierr); for (j=0;jnmat;i++) { ierr = BVMultVec(pjd->AX[i],1.0,1.0,tp,q);CHKERRQ(ierr); PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,q,&one)); for (j=0;jX,0,nconv);CHKERRQ(ierr); ierr = BVDotVec(pjd->X,tu,xx);CHKERRQ(ierr); if (rk==np-1) { y2 = array2+nloc; for (i=0;iTj+ld*ld,&ld,y2,&one)); fact = theta; for (j=2;jXpX,&ld,q,&one,&zero,tt,&one)); for (i=0;iTj+ld*ld*j,&ld,tt,&one)); for (i=0;iT,&ld,q,&one)); for (i=0;idata; PetscErrorCode ierr; PetscScalar *tt; Vec vg,wg; PetscInt i; PetscReal norm; PetscFunctionBegin; ierr = PetscMalloc1(pep->nev-1,&tt);CHKERRQ(ierr); if (pep->nini==0) { ierr = BVSetRandomColumn(pjd->V,0);CHKERRQ(ierr); for (i=0;inev-1;i++) tt[i] = 0.0; ierr = BVGetColumn(pjd->V,0,&vg);CHKERRQ(ierr); ierr = PEPJDCopyToExtendedVec(pep,NULL,tt,pep->nev-1,0,vg,PETSC_FALSE);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->V,0,&vg);CHKERRQ(ierr); ierr = BVNormColumn(pjd->V,0,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(pjd->V,0,1.0/norm);CHKERRQ(ierr); ierr = BVGetColumn(pjd->V,0,&vg);CHKERRQ(ierr); ierr = BVGetColumn(pjd->W,0,&wg);CHKERRQ(ierr); ierr = VecSet(wg,0.0);CHKERRQ(ierr); ierr = PEPJDComputePResidual(pep,vg,pep->target,wg,w);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->W,0,&wg);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->V,0,&vg);CHKERRQ(ierr); ierr = BVNormColumn(pjd->W,0,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(pjd->W,0,1.0/norm);CHKERRQ(ierr); } else { SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TO DO"); } ierr = PetscFree(tt);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDShellMatMult" static PetscErrorCode PEPJDShellMatMult(Mat P,Vec x,Vec y) { PetscErrorCode ierr; PEP_JD_MATSHELL *matctx; PEP_JD *pjd; PetscMPIInt rk,np,count; PetscInt i,j,nconv,nloc,nmat,ldt,deg; Vec tx,ty; PetscScalar *array2,*x2=NULL,*y2,fact=1.0,*q=NULL,*tt=NULL,*xx=NULL,theta,*yy=NULL,sone=1.0,zero=0.0; PetscBLASInt n,ld,one=1; const PetscScalar *array1; PetscFunctionBegin; ierr = MatShellGetContext(P,(void**)&matctx);CHKERRQ(ierr); pjd = (PEP_JD*)(matctx->pep->data); nconv = pjd->nconv; theta = matctx->theta; nmat = matctx->pep->nmat; deg = nmat-1; ldt = matctx->pep->nev; if (nconv>0) { ierr = PetscMalloc5(nconv,&tt,nconv,&x2,nconv,&q,nconv,&xx,nconv,&yy);CHKERRQ(ierr); ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)P),&rk);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)P),&np);CHKERRQ(ierr); if (rk==np-1) { ierr = BVGetSizes(matctx->pep->V,&nloc,NULL,NULL);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&array1);CHKERRQ(ierr); for (i=0;iwork[0]; ty = matctx->work[1]; ierr = VecGetArrayRead(x,&array1);CHKERRQ(ierr); ierr = VecPlaceArray(tx,array1);CHKERRQ(ierr); ierr = VecGetArray(y,&array2);CHKERRQ(ierr); ierr = VecPlaceArray(ty,array2);CHKERRQ(ierr); ierr = VecSet(ty,0.0);CHKERRQ(ierr); ierr = MatMult(matctx->P,tx,ty);CHKERRQ(ierr); if (nconv) { ierr = PetscBLASIntCast(pjd->nconv,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldt,&ld);CHKERRQ(ierr); for (j=0;jAX[i],1.0,1.0,ty,q);CHKERRQ(ierr); PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,q,&one)); for (j=0;jX,0,nconv);CHKERRQ(ierr); ierr = BVDotVec(pjd->X,tx,xx);CHKERRQ(ierr); if (rk==np-1) { y2 = array2+nloc; for (i=0;iXpX,&ld,q,&one,&zero,tt,&one)); for (i=0;iTj+ld*ld*j,&ld,tt,&one)); for (i=0;iT,&ld,q,&one)); for (i=0;idata; PEP_JD_PCSHELL *pcctx; PEP_JD_MATSHELL *matctx; KSP ksp; PetscInt nloc,mloc; PetscMPIInt np,rk; PetscErrorCode ierr; PetscFunctionBegin; ierr = PCCreate(PetscObjectComm((PetscObject)pep),&pjd->pcshell);CHKERRQ(ierr); ierr = PCSetType(pjd->pcshell,PCSHELL);CHKERRQ(ierr); ierr = PCShellSetName(pjd->pcshell,"PCPEPJD");CHKERRQ(ierr); ierr = PCShellSetApply(pjd->pcshell,PCShellApply_PEPJD);CHKERRQ(ierr); ierr = PetscNew(&pcctx);CHKERRQ(ierr); ierr = PCShellSetContext(pjd->pcshell,pcctx);CHKERRQ(ierr); ierr = STGetKSP(pep->st,&ksp);CHKERRQ(ierr); ierr = BVCreateVec(pjd->V,&pcctx->Bp);CHKERRQ(ierr); ierr = KSPGetPC(ksp,&pcctx->pc);CHKERRQ(ierr); ierr = PetscObjectReference((PetscObject)pcctx->pc);CHKERRQ(ierr); ierr = MatGetLocalSize(pep->A[0],&mloc,&nloc);CHKERRQ(ierr); if (pep->nev>1) { ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);CHKERRQ(ierr); if (rk==np-1) { nloc += pep->nev-1; mloc += pep->nev-1; } } ierr = PetscNew(&matctx);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)pep),nloc,mloc,PETSC_DETERMINE,PETSC_DETERMINE,matctx,&pjd->Pshell);CHKERRQ(ierr); ierr = MatShellSetOperation(pjd->Pshell,MATOP_MULT,(void(*)())PEPJDShellMatMult);CHKERRQ(ierr); matctx->pep = pep; ierr = MatDuplicate(pep->A[0],MAT_DO_NOT_COPY_VALUES,&matctx->P);CHKERRQ(ierr); ierr = PCSetOperators(pcctx->pc,matctx->P,matctx->P);CHKERRQ(ierr); ierr = KSPSetPC(ksp,pjd->pcshell);CHKERRQ(ierr); ierr = KSPSetOperators(ksp,pjd->Pshell,pjd->Pshell);CHKERRQ(ierr); if (pep->nev>1) { ierr = PetscMalloc2(pep->nev*pep->nev,&pcctx->M,pep->nev*pep->nev,&pcctx->ps);CHKERRQ(ierr); pcctx->X = pjd->X; pcctx->ld = pep->nev; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDUpdateExtendedPC" static PetscErrorCode PEPJDUpdateExtendedPC(PEP pep,PetscScalar theta) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PEP_JD_PCSHELL *pcctx; PetscInt i,j,k,n=pjd->nconv,ld=pep->nev,deg=pep->nmat-1; PetscScalar fact,*M,*ps,*work,*U,*V,*S,sone=1.0,zero=0.0; PetscReal tol,maxeig=0.0,*sg,*rwork; PetscBLASInt n_,info,ld_,*p,lw_,rk=0; PetscFunctionBegin; #if defined(PETSC_MISSING_LAPACK_GESVD) || defined(PETSC_MISSING_LAPACK_GETRI) || defined(PETSC_MISSING_LAPACK_GETRF) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD/GETRI/GETRF - Lapack routine is unavailable"); #else if (n) { ierr = PCShellGetContext(pjd->pcshell,(void**)&pcctx);CHKERRQ(ierr); pcctx->n = n; M = pcctx->M; ps = pcctx->ps; /* h, and q are vectors containing diagonal matrices */ ierr = PetscCalloc7(n*n,&U,n*n,&V,n*n,&S,n,&sg,10*n,&work,5*n,&rwork,n,&p);CHKERRQ(ierr); /* pseudo-inverse */ for (j=0;jT[pep->nev*j+i]; S[n*j+j] = theta-pjd->T[pep->nev*j+j]; } ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ld,&ld_);CHKERRQ(ierr); lw_ = 10*n_; #if !defined (PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&n_,&n_,S,&n_,sg,U,&n_,V,&n_,work,&lw_,&info)); #else PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&n_,&n_,S,&n_,sg,U,&n_,V,&n_,work,&lw_,rwork,&info)); #endif for (i=0;itol) { for (i=0;iXpX,&ld_,ps,&ld_,&zero,M,&ld_)); fact = theta; ierr = PetscMemzero(S,n*n*sizeof(PetscScalar));CHKERRQ(ierr); for (j=0;jXpX,&ld_,V,&n_,&zero,U,&n_)); PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&n_,&n_,&n_,&sone,pjd->Tj+k*ld*ld,&ld_,U,&n_,&sone,M,&ld_)); PetscStackCallBLAS("BLAStrmm",BLAStrmm_("L","U","N","N",&n_,&n_,&sone,pjd->T,&ld_,S,&n_)); for (j=0;jdata; PEP_JD_MATSHELL *matctx; PEP_JD_PCSHELL *pcctx; MatStructure str; PetscScalar t; PetscInt i; PetscFunctionBegin; ierr = MatShellGetContext(pjd->Pshell,(void**)&matctx);CHKERRQ(ierr); ierr = PCShellGetContext(pjd->pcshell,(void**)&pcctx);CHKERRQ(ierr); ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = MatCopy(pep->A[0],matctx->P,str);CHKERRQ(ierr); t = theta; for (i=1;inmat;i++) { if (t!=0.0) { ierr = MatAXPY(matctx->P,t,pep->A[i],str);CHKERRQ(ierr); } t *= theta; } ierr = PCSetOperators(pcctx->pc,matctx->P,matctx->P);CHKERRQ(ierr); ierr = PCSetUp(pcctx->pc);CHKERRQ(ierr); matctx->theta = theta; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDEigenvectors" static PetscErrorCode PEPJDEigenvectors(PEP pep) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PetscBLASInt ld,nconv,info,nc; PetscScalar *Z,*w; PetscReal *wr,norm; PetscInt i; Mat U; PetscFunctionBegin; #if defined(SLEPC_MISSING_LAPACK_TREVC) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREVC - Lapack routine is unavailable"); #else ierr = PetscMalloc3(pjd->nconv*pjd->nconv,&Z,3*pep->nev,&wr,2*pep->nev,&w);CHKERRQ(ierr); ierr = PetscBLASIntCast(pep->nev,&ld);CHKERRQ(ierr); ierr = PetscBLASIntCast(pjd->nconv,&nconv);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_("R","A",NULL,&nconv,pjd->T,&ld,NULL,&nconv,Z,&nconv,&nconv,&nc,wr,&info)); #else PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_("R","A",NULL,&nconv,pjd->T,&ld,NULL,&nconv,Z,&nconv,&nconv,&nc,w,wr,&info)); #endif ierr = MatCreateSeqDense(PETSC_COMM_SELF,nconv,nconv,Z,&U);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->X,0,pjd->nconv);CHKERRQ(ierr); ierr = BVMultInPlace(pjd->X,U,0,pjd->nconv);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = BVNormColumn(pjd->X,i,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(pjd->X,i,1.0/norm);CHKERRQ(ierr); } ierr = MatDestroy(&U);CHKERRQ(ierr); ierr = PetscFree3(Z,wr,w);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "PEPJDLockConverged" static PetscErrorCode PEPJDLockConverged(PEP pep,PetscInt *nv) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PetscInt j,i,ldds,rk=0,*P,nvv=*nv; Vec v,x; PetscBLASInt n,ld,rk_,nv_,info,one=1; PetscScalar sone=1.0,*Tj,*R,*r,*tt,*pX; Mat X; PetscFunctionBegin; #if defined(SLEPC_MISSING_LAPACK_TRTRI) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TRTRI - Lapack routine is unavailable"); #else /* update AX and XpX */ ierr = BVGetColumn(pjd->X,pjd->nconv-1,&x);CHKERRQ(ierr); for (j=0;jnmat;j++) { ierr = BVGetColumn(pjd->AX[j],pjd->nconv-1,&v);CHKERRQ(ierr); ierr = MatMult(pep->A[j],x,v);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->AX[j],pjd->nconv-1,&v);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->AX[j],0,pjd->nconv);CHKERRQ(ierr); } ierr = BVRestoreColumn(pjd->X,pjd->nconv-1,&x);CHKERRQ(ierr); ierr = BVDotColumn(pjd->X,(pjd->nconv-1),pjd->XpX+(pjd->nconv-1)*(pep->nev));CHKERRQ(ierr); pjd->XpX[(pjd->nconv-1)*(1+pep->nev)] = 1.0; for (j=0;jnconv-1;j++) pjd->XpX[j*(pep->nev)+pjd->nconv-1] = PetscConj(pjd->XpX[(pjd->nconv-1)*(pep->nev)+j]); /* Compute powers of T */ ierr = PetscBLASIntCast(pjd->nconv,&n);CHKERRQ(ierr); ierr = PetscBLASIntCast(pep->nev,&ld);CHKERRQ(ierr); ierr = PetscMemzero(pjd->Tj,pep->nev*pep->nev*pep->nmat*sizeof(PetscScalar));CHKERRQ(ierr); Tj = pjd->Tj; for (j=0;jnconv;j++) Tj[(pep->nev+1)*j] = 1.0; Tj = pjd->Tj+pep->nev*pep->nev; ierr = PetscMemcpy(Tj,pjd->T,pep->nev*pjd->nconv*sizeof(PetscScalar));CHKERRQ(ierr); for (j=2;jnmat;j++) { ierr = PetscMemcpy(Tj+pep->nev*pep->nev,Tj,pep->nev*pjd->nconv*sizeof(PetscScalar));CHKERRQ(ierr); Tj += pep->nev*pep->nev; PetscStackCallBLAS("BLAStrmm",BLAStrmm_("L","U","N","N",&n,&n,&sone,pjd->T,&ld,Tj,&ld)); } /* Extend search space */ ierr = PetscCalloc4(nvv,&P,nvv*nvv,&R,nvv,&r,pep->nev-1,&tt);CHKERRQ(ierr); ierr = DSGetLeadingDimension(pep->ds,&ldds);CHKERRQ(ierr); ierr = DSGetArray(pep->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = PEPJDOrthogonalize(nvv,nvv,pX,ldds,&rk,P,R,nvv);CHKERRQ(ierr); for (i=0;ieigr[P[i+1]]); /* first row scaled with permuted diagonal */ ierr = PetscBLASIntCast(rk,&rk_);CHKERRQ(ierr); ierr = PetscBLASIntCast(nvv,&nv_);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKtrtri",LAPACKtrtri_("U","N",&rk_,R,&nv_,&info)); if (info) SETERRQ1(PETSC_COMM_SELF,1,"Error in xTRTRI, info=%D",(PetscInt)info); PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&rk_,R,&nv_,r,&one)); for (i=0;iV,0,nvv);CHKERRQ(ierr); for (j=0;jds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,nvv,rk-1,R,&X);CHKERRQ(ierr); ierr = BVMultInPlace(pjd->V,X,0,rk-1);CHKERRQ(ierr); ierr = MatDestroy(&X);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->V,0,rk-1);CHKERRQ(ierr); for (j=0;jV,j,&v);CHKERRQ(ierr); ierr = PEPJDCopyToExtendedVec(pep,NULL,r+j,1,pjd->nconv-1,v,PETSC_FALSE);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->V,j,&v);CHKERRQ(ierr); } ierr = BVOrthogonalize(pjd->V,NULL);CHKERRQ(ierr); for (j=0;jW,j,&v);CHKERRQ(ierr); ierr = PEPJDCopyToExtendedVec(pep,NULL,tt,pep->nev-1,0,v,PETSC_FALSE);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->W,j,&v);CHKERRQ(ierr); } *nv = rk-1; ierr = PetscFree4(P,R,r,tt);CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSolve_JD" PetscErrorCode PEPSolve_JD(PEP pep) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PetscInt k,nv,ld,minv,low,high,dim; PetscScalar theta=0.0,*pX,*eig; PetscReal norm,*res; PetscBool lindep,initial=PETSC_FALSE,flglk=PETSC_FALSE,flgre=PETSC_FALSE; Vec t,u,p,r,*ww=pep->work,v; Mat G,X,Y; KSP ksp; PEP_JD_PCSHELL *pcctx; PEP_JD_MATSHELL *matctx; PetscFunctionBegin; ierr = DSGetLeadingDimension(pep->ds,&ld);CHKERRQ(ierr); ierr = PetscMalloc2(pep->ncv,&eig,pep->ncv,&res);CHKERRQ(ierr); ierr = BVCreateVec(pjd->V,&u);CHKERRQ(ierr); ierr = VecDuplicate(u,&p);CHKERRQ(ierr); ierr = VecDuplicate(u,&r);CHKERRQ(ierr); ierr = STGetKSP(pep->st,&ksp);CHKERRQ(ierr); if (pep->nini) { nv = pep->nini; initial = PETSC_TRUE; } else { theta = pep->target; nv = 1; } ierr = PEPJDProcessInitialSpace(pep,ww);CHKERRQ(ierr); ierr = BVCopyVec(pjd->V,0,u);CHKERRQ(ierr); /* Restart loop */ while (pep->reason == PEP_CONVERGED_ITERATING) { pep->its++; low = (flglk || flgre)? 0: nv-1; high = nv; ierr = DSSetDimensions(pep->ds,nv,0,0,0);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->V,low,high);CHKERRQ(ierr); ierr = PEPJDUpdateTV(pep,low,high,ww);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->W,low,high);CHKERRQ(ierr); for (k=0;knmat;k++) { ierr = BVSetActiveColumns(pjd->TV[k],low,high);CHKERRQ(ierr); ierr = DSGetMat(pep->ds,DSMatExtra[k],&G);CHKERRQ(ierr); ierr = BVMatProject(pjd->TV[k],NULL,pjd->W,G);CHKERRQ(ierr); ierr = DSRestoreMat(pep->ds,DSMatExtra[k],&G);CHKERRQ(ierr); } ierr = BVSetActiveColumns(pjd->V,0,nv);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->W,0,nv);CHKERRQ(ierr); /* Solve projected problem */ if (nv>1 || initial ) { ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = DSSolve(pep->ds,pep->eigr+pep->nconv,pep->eigi+pep->nconv);CHKERRQ(ierr); ierr = DSSort(pep->ds,pep->eigr+pep->nconv,pep->eigi+pep->nconv,NULL,NULL,NULL);CHKERRQ(ierr); theta = pep->eigr[0]; #if !defined(PETSC_USE_COMPLEX) if (PetscAbsScalar(pep->eigi[pep->nconv])!=0.0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"PJD solver not implemented for complex Ritz values in real arithmetic"); #endif /* Compute Ritz vector u=V*X(:,1) */ ierr = DSGetArray(pep->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->V,0,nv);CHKERRQ(ierr); ierr = BVMultVec(pjd->V,1.0,0.0,u,pX);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_X,&pX);CHKERRQ(ierr); } ierr = PEPJDUpdateExtendedPC(pep,theta);CHKERRQ(ierr); /* Replace preconditioner with one containing projectors */ if (!pjd->pcshell) { ierr = PEPJDCreateShellPC(pep);CHKERRQ(ierr); ierr = PCShellGetContext(pjd->pcshell,(void**)&pcctx);CHKERRQ(ierr); ierr = MatShellGetContext(pjd->Pshell,(void**)&matctx);CHKERRQ(ierr); matctx->work = ww; pcctx->work = ww; } ierr = PEPJDPCMatSetUp(pep,theta);CHKERRQ(ierr); /* Compute r and r' */ ierr = MatMult(pjd->Pshell,u,r);CHKERRQ(ierr); ierr = PEPJDComputePResidual(pep,u,theta,p,ww);CHKERRQ(ierr); pcctx->u = u; /* Check convergence */ ierr = VecNorm(r,NORM_2,&norm);CHKERRQ(ierr); ierr = (*pep->converged)(pep,theta,0,norm,&pep->errest[pep->nconv],pep->convergedctx);CHKERRQ(ierr); ierr = (*pep->stopping)(pep,pep->its,pep->max_it,(pep->errest[pep->nconv]tol)?pjd->nconv+1:pjd->nconv,pep->nev,&pep->reason,pep->stoppingctx);CHKERRQ(ierr); if (pep->errest[pep->nconv]tol) { /* Ritz pair converged */ minv = PetscMin(nv,(PetscInt)(pjd->keep*pep->ncv)); if (pep->nev>1) { ierr = BVGetColumn(pjd->X,pjd->nconv,&v);CHKERRQ(ierr); ierr = PEPJDCopyToExtendedVec(pep,v,pjd->T+pep->nev*pjd->nconv,pep->nev-1,0,u,PETSC_TRUE);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->X,pjd->nconv,&v);CHKERRQ(ierr); ierr = BVSetActiveColumns(pjd->X,0,pjd->nconv+1);CHKERRQ(ierr); ierr = BVNormColumn(pjd->X,pjd->nconv,NORM_2,&norm);CHKERRQ(ierr); ierr = BVScaleColumn(pjd->X,pjd->nconv,1.0/norm);CHKERRQ(ierr); for (k=0;knconv;k++) pjd->T[pep->nev*pjd->nconv+k] /= norm; pjd->T[(pep->nev+1)*pjd->nconv] = pep->eigr[0]; } else { ierr = BVInsertVec(pep->V,pep->nconv,u);CHKERRQ(ierr); } pjd->nconv++; if (pep->reason==PEP_CONVERGED_ITERATING) { ierr = PEPJDLockConverged(pep,&nv);CHKERRQ(ierr); ierr = BVCopyVec(pjd->V,nv-1,u);CHKERRQ(ierr); if (nv==1) theta = pep->target; } flglk = PETSC_TRUE; } else if (nv==pep->ncv-1) { /* Basis full, force restart */ minv = PetscMin(nv,(PetscInt)(pjd->keep*pep->ncv)); ierr = DSGetDimensions(pep->ds,&dim,NULL,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSGetArray(pep->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = PEPJDOrthogonalize(dim,minv,pX,ld,&minv,NULL,NULL,ld);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_X,&pX);CHKERRQ(ierr); ierr = DSGetArray(pep->ds,DS_MAT_Y,&pX);CHKERRQ(ierr); ierr = PEPJDOrthogonalize(dim,minv,pX,ld,&minv,NULL,NULL,ld);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_Y,&pX);CHKERRQ(ierr); ierr = DSGetMat(pep->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = BVMultInPlace(pjd->V,X,pep->nconv,minv);CHKERRQ(ierr); ierr = DSRestoreMat(pep->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = DSGetMat(pep->ds,DS_MAT_Y,&Y);CHKERRQ(ierr); ierr = BVMultInPlace(pjd->W,Y,pep->nconv,minv);CHKERRQ(ierr); ierr = DSRestoreMat(pep->ds,DS_MAT_Y,&Y);CHKERRQ(ierr); nv = minv; flgre = PETSC_TRUE; } else { /* Solve correction equation to expand basis */ ierr = PEPJDExtendedPCApply(pjd->pcshell,p,pcctx->Bp);CHKERRQ(ierr); ierr = VecDot(pcctx->Bp,u,&pcctx->gamma);CHKERRQ(ierr); ierr = BVGetColumn(pjd->V,nv,&t);CHKERRQ(ierr); ierr = KSPSolve(ksp,r,t);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->V,nv,&t);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(pjd->V,nv,NULL,&norm,&lindep);CHKERRQ(ierr); if (lindep || norm==0.0) SETERRQ(PETSC_COMM_SELF,1,"Linearly dependent continuation vector"); ierr = BVScaleColumn(pjd->V,nv,1.0/norm);CHKERRQ(ierr); ierr = BVInsertVec(pjd->W,nv,r);CHKERRQ(ierr); ierr = BVOrthogonalizeColumn(pjd->W,nv,NULL,&norm,&lindep);CHKERRQ(ierr); if (lindep) SETERRQ(PETSC_COMM_SELF,1,"Linearly dependent continuation vector"); ierr = BVScaleColumn(pjd->W,nv,1.0/norm);CHKERRQ(ierr); nv++; flglk = PETSC_FALSE; flgre = PETSC_FALSE; } for (k=pjd->nconv;keigr[k-pjd->nconv]; res[k] = pep->errest[k-pjd->nconv]; #if !defined(PETSC_USE_COMPLEX) pep->eigi[k-pjd->nconv] = 0.0; #endif } ierr = PEPMonitor(pep,pep->its,pjd->nconv,eig,pep->eigi,res,pjd->nconv+1);CHKERRQ(ierr); } if (pep->nev>1) { if (pjd->nconv>0) { ierr = PEPJDEigenvectors(pep);CHKERRQ(ierr); } for (k=0;knconv;k++) { ierr = BVGetColumn(pjd->X,k,&v);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,k,v);CHKERRQ(ierr); ierr = BVRestoreColumn(pjd->X,k,&v);CHKERRQ(ierr); pep->eigr[k] = pjd->T[(pep->nev+1)*k]; pep->eigi[k] = 0.0; } ierr = PetscFree2(pcctx->M,pcctx->ps);CHKERRQ(ierr); } pep->nconv = pjd->nconv; ierr = KSPSetPC(ksp,pcctx->pc);CHKERRQ(ierr); ierr = MatDestroy(&matctx->P);CHKERRQ(ierr); ierr = VecDestroy(&pcctx->Bp);CHKERRQ(ierr); ierr = MatDestroy(&pjd->Pshell);CHKERRQ(ierr); ierr = PCDestroy(&pcctx->pc);CHKERRQ(ierr); ierr = PetscFree(pcctx);CHKERRQ(ierr); ierr = PetscFree(matctx);CHKERRQ(ierr); ierr = PCDestroy(&pjd->pcshell);CHKERRQ(ierr); ierr = PetscFree2(eig,res);CHKERRQ(ierr); ierr = VecDestroy(&u);CHKERRQ(ierr); ierr = VecDestroy(&r);CHKERRQ(ierr); ierr = VecDestroy(&p);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPReset_JD" PetscErrorCode PEPReset_JD(PEP pep) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PetscInt i; PetscFunctionBegin; for (i=0;inmat;i++) { ierr = BVDestroy(pjd->TV+i);CHKERRQ(ierr); } ierr = BVDestroy(&pjd->W);CHKERRQ(ierr); if (pep->nev>1) { ierr = BVDestroy(&pjd->V);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = BVDestroy(pjd->AX+i);CHKERRQ(ierr); } ierr = BVDestroy(&pjd->X);CHKERRQ(ierr); ierr = PetscFree3(pjd->XpX,pjd->T,pjd->Tj);CHKERRQ(ierr); } ierr = PetscFree2(pjd->TV,pjd->AX);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPDestroy_JD" PetscErrorCode PEPDestroy_JD(PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(pep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPJDSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPJDGetRestart_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPCreate_JD" PETSC_EXTERN PetscErrorCode PEPCreate_JD(PEP pep) { PEP_JD *pjd; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(pep,&pjd);CHKERRQ(ierr); pep->data = (void*)pjd; pjd->keep = 0; pep->ops->solve = PEPSolve_JD; pep->ops->setup = PEPSetUp_JD; pep->ops->setfromoptions = PEPSetFromOptions_JD; pep->ops->reset = PEPReset_JD; pep->ops->destroy = PEPDestroy_JD; pep->ops->view = PEPView_JD; ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPJDSetRestart_C",PEPJDSetRestart_JD);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPJDGetRestart_C",PEPJDGetRestart_JD);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/impls/jd/makefile.html0000644000175000017500000000466113107004621017731 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = pjd.c pjdopt.c
SOURCEF  =
SOURCEH  = pjdp.h
LIBBASE  = libslepcpep
DIRS     =
MANSEC   = PEP
LOCDIR   = src/pep/impls/jd/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/pep/impls/jd/pjd.c.html0000644000175000017500000026000013107004621017141 0ustar jromanjroman
Actual source code: pjd.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc polynomial eigensolver: "jd"

  5:    Method: Jacobi-Davidson

  7:    Algorithm:

  9:        Jacobi-Davidson for polynomial eigenvalue problems.
 10:        Based on code contributed by the authors of [2] below.

 12:    References:

 14:        [1] G.L.G. Sleijpen et al., "Jacobi-Davidson type methods for
 15:            generalized eigenproblems and polynomial eigenproblems", BIT
 16:            36(3):595-633, 1996.

 18:        [2] Feng-Nan Hwang, Zih-Hao Wei, Tsung-Ming Huang, Weichung Wang,
 19:            "A Parallel Additive Schwarz Preconditioned Jacobi-Davidson
 20:            Algorithm for Polynomial Eigenvalue Problems in Quantum Dot
 21:            Simulation", J. Comput. Phys. 229(8):2932-2947, 2010.

 23:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 24:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 25:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 27:    This file is part of SLEPc.

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

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

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

 43: #include <slepc/private/pepimpl.h>    /*I "slepcpep.h" I*/
 44:  #include pjdp.h
 45: #include <slepcblaslapack.h>

 49: /*
 50:    Duplicate and resize auxiliary basis
 51: */
 52: static PetscErrorCode PEPJDDuplicateBasis(PEP pep,BV *basis)
 53: {
 54:   PetscErrorCode     ierr;
 55:   PetscInt           nloc,m;
 56:   PetscMPIInt        rank,nproc;
 57:   BVType             type;
 58:   BVOrthogType       otype;
 59:   BVOrthogRefineType oref;
 60:   PetscReal          oeta;
 61:   BVOrthogBlockType  oblock;

 64:   if (pep->nev>1) {
 65:     BVCreate(PetscObjectComm((PetscObject)pep),basis);
 66:     MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rank);
 67:     MPI_Comm_size(PetscObjectComm((PetscObject)pep),&nproc);
 68:     BVGetSizes(pep->V,&nloc,NULL,&m);
 69:     if (rank==nproc-1) nloc += pep->nev-1;
 70:     BVSetSizes(*basis,nloc,PETSC_DECIDE,m);
 71:     BVGetType(pep->V,&type);
 72:     BVSetType(*basis,type);
 73:     BVGetOrthogonalization(pep->V,&otype,&oref,&oeta,&oblock);
 74:     BVSetOrthogonalization(*basis,otype,oref,oeta,oblock);
 75:     PetscObjectStateIncrease((PetscObject)*basis);
 76:   } else {
 77:     BVDuplicate(pep->V,basis);
 78:   }
 79:   return(0);
 80: }

 84: PetscErrorCode PEPSetUp_JD(PEP pep)
 85: {
 87:   PEP_JD         *pjd = (PEP_JD*)pep->data;
 88:   PetscBool      isprecond,flg;
 89:   PetscInt       i;
 90:   KSP            ksp;

 93:   pep->lineariz = PETSC_FALSE;
 94:   PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);
 95:   if (!pep->max_it) pep->max_it = PetscMax(100,2*pep->n/pep->ncv);
 96:   if (!pep->which) pep->which = PEP_TARGET_MAGNITUDE;
 97:   if (pep->which != PEP_TARGET_MAGNITUDE) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"PEPJD only supports which=target_magnitude");;

 99:   /* Set STPRECOND as the default ST */
100:   if (!((PetscObject)pep->st)->type_name) {
101:     STSetType(pep->st,STPRECOND);
102:   }
103:   PetscObjectTypeCompare((PetscObject)pep->st,STPRECOND,&isprecond);
104:   if (!isprecond) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"JD only works with PRECOND spectral transformation");

106:   if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver not implemented for non-monomial bases");
107:   STGetTransform(pep->st,&flg);
108:   if (flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver requires the ST transformation flag unset, see STSetTransform()");

110:   /* Set the default options of the KSP */
111:   STGetKSP(pep->st,&ksp);
112:   if (!((PetscObject)ksp)->type_name) {
113:     KSPSetType(ksp,KSPBCGSL);
114:     KSPSetTolerances(ksp,1e-5,PETSC_DEFAULT,PETSC_DEFAULT,100);
115:   }

117:   if (!pjd->keep) pjd->keep = 0.5;

119:   PEPAllocateSolution(pep,0);
120:   PEPSetWorkVecs(pep,5);
121:   PetscMalloc2(pep->nmat,&pjd->TV,pep->nmat,&pjd->AX);
122:   for (i=0;i<pep->nmat;i++) {
123:     PEPJDDuplicateBasis(pep,pjd->TV+i);
124:   }
125:   PEPJDDuplicateBasis(pep,&pjd->W);
126:   if (pep->nev>1) {
127:     PEPJDDuplicateBasis(pep,&pjd->V);
128:     BVSetFromOptions(pjd->V);
129:     for (i=0;i<pep->nmat;i++) {
130:       BVDuplicateResize(pep->V,pep->nev-1,pjd->AX+i);
131:     }
132:     BVDuplicateResize(pep->V,pep->nev,&pjd->X);
133:     PetscCalloc3((pep->nev)*(pep->nev),&pjd->XpX,pep->nev*pep->nev,&pjd->T,pep->nev*pep->nev*pep->nmat,&pjd->Tj);
134:   } else pjd->V = pep->V;
135:   DSSetType(pep->ds,DSPEP);
136:   DSPEPSetDegree(pep->ds,pep->nmat-1);
137:   DSAllocate(pep->ds,pep->ncv);
138:   return(0);
139: }

143: /*
144:    Updates columns (low to (high-1)) of TV[i]
145: */
146: static PetscErrorCode PEPJDUpdateTV(PEP pep,PetscInt low,PetscInt high,Vec *w)
147: {
149:   PEP_JD         *pjd = (PEP_JD*)pep->data;
150:   PetscInt       pp,col,i,j,nloc,nconv,deg=pep->nmat-1;
151:   Vec            v1,v2,t1,t2;
152:   PetscScalar    *array1,*array2,*x2,*tt,*xx,*y2,zero=0.0,sone=1.0;
153:   PetscMPIInt    rk,np,count;
154:   PetscBLASInt   n,ld,one=1;

157:   nconv = pjd->nconv;
158:   PetscMalloc3(nconv,&tt,nconv,&x2,nconv,&xx);
159:   MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);
160:   MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);
161:   BVGetSizes(pep->V,&nloc,NULL,NULL); 
162:   t1 = w[0];
163:   t2 = w[1];
164:   for (col=low;col<high;col++) {
165:     BVGetColumn(pjd->V,col,&v1);
166:     VecGetArray(v1,&array1);
167:     if (nconv>0) {
168:       if (rk==np-1) { for (i=0;i<nconv;i++) x2[i] = array1[nloc+i]; }
169:       PetscMPIIntCast(nconv,&count);
170:       MPI_Bcast(x2,nconv,MPIU_SCALAR,np-1,PetscObjectComm((PetscObject)pep));
171:     }
172:     VecPlaceArray(t1,array1);
173:     for (pp=0;pp<pep->nmat;pp++) {
174:       BVGetColumn(pjd->TV[pp],col,&v2);
175:       VecGetArray(v2,&array2);
176:       VecPlaceArray(t2,array2);
177:       MatMult(pep->A[pp],t1,t2);
178:       if (nconv) {
179:         PetscBLASIntCast(pjd->nconv,&n);
180:         PetscBLASIntCast(pep->nev,&ld);
181:         for (j=0;j<nconv;j++) tt[j] = x2[j];
182:         for (i=pp+1;i<pep->nmat;i++) {
183:           BVMultVec(pjd->AX[i],1.0,1.0,t2,tt);
184:           if (i!=pep->nmat-1) PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,tt,&one));
185:         }
186:         BVDotVec(pjd->X,t1,xx);
187:         if (rk==np-1 && pp<deg) {
188:           y2 = array2+nloc;
189:           for (j=0;j<nconv;j++) { y2[j] = xx[j]; xx[j] = x2[j]; }
190:           PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&n,pjd->Tj+ld*ld*pp,&ld,y2,&one));
191:           for (i=pp+1;i<pep->nmat-1;i++) {
192:             PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&sone,pjd->XpX,&ld,xx,&one,&zero,tt,&one));
193:             PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&n,pjd->Tj+ld*ld*i,&ld,tt,&one));
194:             for (j=0;j<nconv;j++) y2[j] += tt[j];
195:             if (i<pep->nmat-2) PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,xx,&one));
196:           }
197:         }
198:       }
199:       VecResetArray(t2);
200:       VecRestoreArray(v2,&array2);
201:       BVRestoreColumn(pjd->TV[pp],col,&v2);        
202:     }
203:     VecResetArray(t1);
204:     VecRestoreArray(v1,&array1);
205:     BVRestoreColumn(pjd->V,col,&v1);
206:   }
207:   PetscFree3(tt,x2,xx);
208:   return(0);
209: }

213: /*
214:    RRQR of X. Xin*P=Xou*R. Rank of R is rk
215: */
216: static PetscErrorCode PEPJDOrthogonalize(PetscInt row,PetscInt col,PetscScalar *X,PetscInt ldx,PetscInt *rk,PetscInt *P,PetscScalar *R,PetscInt ldr)
217: {
218: #if defined(SLEPC_MISSING_LAPACK_GEQP3)
220:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQP3 - Lapack routine is unavailable");
221: #else
223:   PetscInt       i,j,n,r;
224:   PetscBLASInt   row_,col_,ldx_,*p,lwork,info,n_;
225:   PetscScalar    *tau,*work;
226:   PetscReal      tol,*rwork;

229:   PetscBLASIntCast(row,&row_);
230:   PetscBLASIntCast(col,&col_);
231:   PetscBLASIntCast(ldx,&ldx_);
232:   n = PetscMin(row,col);
233:   PetscBLASIntCast(n,&n_);
234:   lwork = 3*col_+1;
235:   PetscMalloc4(col,&p,n,&tau,lwork,&work,2*col,&rwork);
236:   for (i=1;i<col;i++) p[i] = 0;
237:   p[0] = 1;

239:   /* rank revealing QR */
240: #if defined(PETSC_USE_COMPLEX)
241:   PetscStackCallBLAS("LAPACKgeqp3",LAPACKgeqp3_(&row_,&col_,X,&ldx_,p,tau,work,&lwork,rwork,&info));
242: #else
243:   PetscStackCallBLAS("LAPACKgeqp3",LAPACKgeqp3_(&row_,&col_,X,&ldx_,p,tau,work,&lwork,&info));
244: #endif
245:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQP3 %d",info);
246:   if (P) for (i=0;i<col;i++) P[i] = p[i];

248:   /* rank computation */
249:   tol = PetscMax(row,col)*PETSC_MACHINE_EPSILON*PetscAbsScalar(X[0]);
250:   r = 1;
251:   for (i=1;i<n;i++) { 
252:     if (PetscAbsScalar(X[i+ldx*i])>tol) r++;
253:     else break;
254:   }
255:   if (rk) *rk=r;

257:   /* copy upper triangular matrix if requested */
258:   if (R) {
259:      for (i=0;i<r;i++) {
260:        PetscMemzero(R+i*ldr,r*sizeof(PetscScalar));
261:        for (j=0;j<=i;j++) R[i*ldr+j] = X[i*ldx+j];
262:      }
263:   }
264:   PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&row_,&n_,&n_,X,&ldx_,tau,work,&lwork,&info));
265:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info);
266:   PetscFree4(p,tau,work,rwork);
267:   return(0);
268: #endif
269: }

273: /*
274:    Application of extended preconditioner
275: */
276: static PetscErrorCode PEPJDExtendedPCApply(PC pc,Vec x,Vec y)
277: {
278:   PetscInt          i,j,nloc,n,ld;
279:   PetscMPIInt       rk,np,count;
280:   Vec               tx,ty;
281:   PEP_JD_PCSHELL    *ctx;
282:   PetscErrorCode    ierr;
283:   const PetscScalar *array1;
284:   PetscScalar       *x2=NULL,*t=NULL,*ps,*array2;
285:   PetscBLASInt      one=1.0,ld_,n_;

288:   PCShellGetContext(pc,(void**)&ctx);
289:   n  = ctx->n;
290:   ps = ctx->ps;
291:   ld = ctx->ld;
292:   if (n) {
293:     PetscMalloc2(n,&x2,n,&t);
294:     MPI_Comm_rank(PetscObjectComm((PetscObject)pc),&rk);
295:     MPI_Comm_size(PetscObjectComm((PetscObject)pc),&np);
296:     if (rk==np-1) {
297:       VecGetLocalSize(ctx->work[0],&nloc); 
298:       VecGetArrayRead(x,&array1);
299:       for (i=0;i<n;i++) x2[i] = array1[nloc+i];
300:       VecRestoreArrayRead(x,&array1);
301:     }
302:     PetscMPIIntCast(n,&count);
303:     MPI_Bcast(x2,count,MPIU_SCALAR,np-1,PetscObjectComm((PetscObject)pc));
304:   }

306:   /* y = B\x apply PC */
307:   tx = ctx->work[0];
308:   ty = ctx->work[1];
309:   VecGetArrayRead(x,&array1);
310:   VecPlaceArray(tx,array1);
311:   VecGetArray(y,&array2);
312:   VecPlaceArray(ty,array2);
313:   PCApply(ctx->pc,tx,ty);
314:   if (n) {
315:     for (j=0;j<n;j++) {
316:       t[j] = 0.0;
317:       for (i=0;i<n;i++) t[j] += ctx->M[i+j*ld]*x2[i];
318:     }
319:     if (rk==np-1) for (i=0;i<n;i++) array2[nloc+i] = t[i];
320:     PetscBLASIntCast(ld,&ld_);
321:     PetscBLASIntCast(n,&n_);
322:     PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n_,ps,&ld_,t,&one));
323:     BVMultVec(ctx->X,-1.0,1.0,ty,t);
324:     PetscFree2(x2,t);
325:   }
326:   VecResetArray(tx);
327:   VecResetArray(ty);
328:   VecRestoreArrayRead(x,&array1);
329:   VecRestoreArray(y,&array2);
330:   return(0);
331: }

335: /*
336:    Application of shell preconditioner:
337:       y = B\x - eta*B\p,  with eta = (u'*B\x)/(u'*B\p)
338: */
339: static PetscErrorCode PCShellApply_PEPJD(PC pc,Vec x,Vec y)
340: {
342:   PetscScalar    eta;
343:   PEP_JD_PCSHELL *ctx;

346:   PCShellGetContext(pc,(void**)&ctx);

348:   /* y = B\x apply extended PC */
349:   PEPJDExtendedPCApply(pc,x,y);

351:   /* Compute eta = u'*y / u'*Bp */
352:   VecDot(y,ctx->u,&eta);
353:   eta /= ctx->gamma;
354:   
355:   /* y = y - eta*Bp */
356:   VecAXPY(y,-eta,ctx->Bp); 
357:   return(0);
358: }

362: static PetscErrorCode PEPJDCopyToExtendedVec(PEP pep,Vec v,PetscScalar *a,PetscInt na,PetscInt off,Vec vex,PetscBool back)
363: {
365:   PetscMPIInt    np,rk,count;
366:   PetscScalar    *array1,*array2;
367:   PetscInt       nloc;

370:   MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);
371:   MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);
372:   BVGetSizes(pep->V,&nloc,NULL,NULL);
373:   if (v) {
374:     VecGetArray(v,&array1);
375:     VecGetArray(vex,&array2);
376:     if (back) {
377:       PetscMemcpy(array1,array2,nloc*sizeof(PetscScalar));
378:     } else {
379:       PetscMemcpy(array2,array1,nloc*sizeof(PetscScalar));
380:     }
381:     VecRestoreArray(v,&array1);
382:     VecRestoreArray(vex,&array2);
383:   }
384:   if (a) {
385:     if (rk==np-1) {
386:       VecGetArray(vex,&array2);
387:       if (back) {
388:         PetscMemcpy(a,array2+nloc+off,na*sizeof(PetscScalar));
389:       } else {
390:         PetscMemcpy(array2+nloc+off,a,na*sizeof(PetscScalar));
391:       }
392:       VecRestoreArray(vex,&array2);
393:     }
394:     if (back) {
395:       PetscMPIIntCast(na,&count);
396:       MPI_Bcast(a,count,MPIU_SCALAR,np-1,PetscObjectComm((PetscObject)pep));
397:     }
398:   }
399:   return(0);
400: }

404: static PetscErrorCode PEPJDComputePResidual(PEP pep,Vec u,PetscScalar theta,Vec p,Vec *work)
405: {
406:   PEP_JD         *pjd = (PEP_JD*)pep->data;
408:   PetscMPIInt    rk,np,count;
409:   Vec            tu,tp,w;
410:   PetscScalar    *array1,*array2,*x2=NULL,*y2,fact=1.0,*q=NULL,*tt=NULL,*xx=NULL,sone=1.0,zero=0.0;
411:   PetscInt       i,j,nconv=pjd->nconv,nloc,deg=pep->nmat-1;
412:   PetscBLASInt   n,ld,one=1;

415:   if (nconv>0) {
416:     PetscMalloc4(nconv,&xx,nconv,&tt,nconv,&x2,nconv,&q);
417:     MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);
418:     MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);
419:     if (rk==np-1) {
420:       BVGetSizes(pep->V,&nloc,NULL,NULL); 
421:       VecGetArray(u,&array1);
422:       for (i=0;i<nconv;i++) x2[i] = array1[nloc+i];
423:       VecRestoreArray(u,&array1);
424:     }
425:     PetscMPIIntCast(nconv,&count);
426:     MPI_Bcast(x2,count,MPIU_SCALAR,np-1,PetscObjectComm((PetscObject)pep));
427:   }
428:   tu = work[0];
429:   tp = work[1];
430:   w  = work[2];
431:   VecGetArray(u,&array1);
432:   VecPlaceArray(tu,array1);
433:   VecGetArray(p,&array2);
434:   VecPlaceArray(tp,array2);
435:   VecSet(tp,0.0);
436:   for (i=1;i<pep->nmat;i++) {
437:     MatMult(pep->A[i],tu,w);
438:     VecAXPY(tp,fact*(PetscReal)i,w);
439:     fact *= theta;
440:   }
441:   if (nconv) {
442:     PetscBLASIntCast(nconv,&n);
443:     PetscBLASIntCast(pep->nev,&ld);
444:     for (j=0;j<nconv;j++) q[j] = x2[j];
445:     fact = theta;
446:     for (i=2;i<pep->nmat;i++) {
447:       BVMultVec(pjd->AX[i],1.0,1.0,tp,q);
448:       PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,q,&one));
449:       for (j=0;j<nconv;j++) q[j] += (PetscReal)i*fact*x2[j];
450:       fact *= theta;
451:     }
452:     BVSetActiveColumns(pjd->X,0,nconv);
453:     BVDotVec(pjd->X,tu,xx);
454:     if (rk==np-1) {
455:       y2 = array2+nloc;
456:       for (i=0;i<nconv;i++) { q[i] = x2[i]; y2[i] = xx[i]; }
457:       PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&n,pjd->Tj+ld*ld,&ld,y2,&one));
458:       fact = theta;
459:       for (j=2;j<deg;j++) {
460:         PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&sone,pjd->XpX,&ld,q,&one,&zero,tt,&one));
461:         for (i=0;i<nconv;i++) tt[i] += (PetscReal)j*fact*xx[i];
462:         PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&n,pjd->Tj+ld*ld*j,&ld,tt,&one));
463:         for (i=0;i<nconv;i++) y2[i] += tt[i];
464:         PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,q,&one));
465:         for (i=0;i<nconv;i++) q[i] += (PetscReal)j*fact*x2[i];
466:         fact *= theta;
467:       }
468:     }
469:     PetscFree4(xx,tt,x2,q);
470:   }
471:   VecResetArray(tu);
472:   VecRestoreArray(u,&array1);
473:   VecResetArray(tp);
474:   VecRestoreArray(p,&array2);
475:   return(0);
476: }

480: static PetscErrorCode PEPJDProcessInitialSpace(PEP pep,Vec *w)
481: {
482:   PEP_JD         *pjd = (PEP_JD*)pep->data;
484:   PetscScalar    *tt;
485:   Vec            vg,wg;
486:   PetscInt       i;
487:   PetscReal      norm;

490:   PetscMalloc1(pep->nev-1,&tt);
491:   if (pep->nini==0) {
492:     BVSetRandomColumn(pjd->V,0);
493:     for (i=0;i<pep->nev-1;i++) tt[i] = 0.0;
494:     BVGetColumn(pjd->V,0,&vg);
495:     PEPJDCopyToExtendedVec(pep,NULL,tt,pep->nev-1,0,vg,PETSC_FALSE);
496:     BVRestoreColumn(pjd->V,0,&vg);
497:     BVNormColumn(pjd->V,0,NORM_2,&norm);
498:     BVScaleColumn(pjd->V,0,1.0/norm);
499:     BVGetColumn(pjd->V,0,&vg);
500:     BVGetColumn(pjd->W,0,&wg);
501:     VecSet(wg,0.0);
502:     PEPJDComputePResidual(pep,vg,pep->target,wg,w);
503:     BVRestoreColumn(pjd->W,0,&wg);
504:     BVRestoreColumn(pjd->V,0,&vg);
505:     BVNormColumn(pjd->W,0,NORM_2,&norm);
506:     BVScaleColumn(pjd->W,0,1.0/norm);
507:   } else {
508:    SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TO DO");
509:   }
510:   PetscFree(tt);
511:   return(0);
512: }

516: static PetscErrorCode PEPJDShellMatMult(Mat P,Vec x,Vec y)
517: {
518:   PetscErrorCode    ierr;
519:   PEP_JD_MATSHELL   *matctx;
520:   PEP_JD            *pjd;
521:   PetscMPIInt       rk,np,count;
522:   PetscInt          i,j,nconv,nloc,nmat,ldt,deg;
523:   Vec               tx,ty;
524:   PetscScalar       *array2,*x2=NULL,*y2,fact=1.0,*q=NULL,*tt=NULL,*xx=NULL,theta,*yy=NULL,sone=1.0,zero=0.0;
525:   PetscBLASInt      n,ld,one=1;
526:   const PetscScalar *array1;

529:   MatShellGetContext(P,(void**)&matctx);
530:   pjd   = (PEP_JD*)(matctx->pep->data);
531:   nconv = pjd->nconv;
532:   theta = matctx->theta;
533:   nmat  = matctx->pep->nmat;
534:   deg   = nmat-1;
535:   ldt   = matctx->pep->nev;
536:   if (nconv>0) {
537:     PetscMalloc5(nconv,&tt,nconv,&x2,nconv,&q,nconv,&xx,nconv,&yy);
538:     MPI_Comm_rank(PetscObjectComm((PetscObject)P),&rk);
539:     MPI_Comm_size(PetscObjectComm((PetscObject)P),&np);
540:     if (rk==np-1) {
541:       BVGetSizes(matctx->pep->V,&nloc,NULL,NULL); 
542:       VecGetArrayRead(x,&array1);
543:       for (i=0;i<nconv;i++) x2[i] = array1[nloc+i];
544:       VecRestoreArrayRead(x,&array1);
545:     }
546:     PetscMPIIntCast(nconv,&count);
547:     MPI_Bcast(x2,nconv,MPIU_SCALAR,np-1,PetscObjectComm((PetscObject)P));
548:   }
549:   tx = matctx->work[0];
550:   ty = matctx->work[1];
551:   VecGetArrayRead(x,&array1);
552:   VecPlaceArray(tx,array1);
553:   VecGetArray(y,&array2);
554:   VecPlaceArray(ty,array2);
555:   VecSet(ty,0.0);
556:   MatMult(matctx->P,tx,ty);
557:   if (nconv) {
558:     PetscBLASIntCast(pjd->nconv,&n);
559:     PetscBLASIntCast(ldt,&ld);
560:     for (j=0;j<nconv;j++) q[j] = x2[j];
561:     fact = theta;
562:     for (i=1;i<nmat;i++) {
563:       BVMultVec(pjd->AX[i],1.0,1.0,ty,q);
564:       PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,q,&one));
565:       for (j=0;j<nconv;j++) q[j] += fact*x2[j];
566:       fact *= theta;
567:     }
568:     BVSetActiveColumns(pjd->X,0,nconv);    
569:     BVDotVec(pjd->X,tx,xx);
570:     if (rk==np-1) {
571:       y2 = array2+nloc;
572:       for (i=0;i<nconv;i++) { q[i] = x2[i]; y2[i] = xx[i]; }
573:       fact = theta;
574:       for (j=1;j<deg;j++) {
575:         PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n,&n,&sone,pjd->XpX,&ld,q,&one,&zero,tt,&one));
576:         for (i=0;i<nconv;i++) tt[i] += fact*xx[i];
577:         PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&n,pjd->Tj+ld*ld*j,&ld,tt,&one));
578:         for (i=0;i<nconv;i++) y2[i] += tt[i];
579:         PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","N","N",&n,pjd->T,&ld,q,&one));
580:         for (i=0;i<nconv;i++) q[i] += fact*x2[i];
581:         fact *= theta;
582:       }
583:     }
584:     PetscFree5(tt,x2,q,xx,yy);
585:   }
586:   VecResetArray(tx);
587:   VecRestoreArrayRead(x,&array1);
588:   VecResetArray(ty);
589:   VecRestoreArray(y,&array2);
590:   return(0);
591: }

595: static PetscErrorCode PEPJDCreateShellPC(PEP pep)
596: {
597:   PEP_JD          *pjd = (PEP_JD*)pep->data;
598:   PEP_JD_PCSHELL  *pcctx;
599:   PEP_JD_MATSHELL *matctx;
600:   KSP             ksp;
601:   PetscInt        nloc,mloc;
602:   PetscMPIInt     np,rk;
603:   PetscErrorCode  ierr;

606:   PCCreate(PetscObjectComm((PetscObject)pep),&pjd->pcshell);
607:   PCSetType(pjd->pcshell,PCSHELL);
608:   PCShellSetName(pjd->pcshell,"PCPEPJD");
609:   PCShellSetApply(pjd->pcshell,PCShellApply_PEPJD);
610:   PetscNew(&pcctx);
611:   PCShellSetContext(pjd->pcshell,pcctx);
612:   STGetKSP(pep->st,&ksp);
613:   BVCreateVec(pjd->V,&pcctx->Bp);
614:   KSPGetPC(ksp,&pcctx->pc);
615:   PetscObjectReference((PetscObject)pcctx->pc);
616:   MatGetLocalSize(pep->A[0],&mloc,&nloc);
617:   if (pep->nev>1) {
618:     MPI_Comm_rank(PetscObjectComm((PetscObject)pep),&rk);
619:     MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);
620:     if (rk==np-1) { nloc += pep->nev-1; mloc += pep->nev-1; }
621:   }
622:   PetscNew(&matctx);
623:   MatCreateShell(PetscObjectComm((PetscObject)pep),nloc,mloc,PETSC_DETERMINE,PETSC_DETERMINE,matctx,&pjd->Pshell);
624:   MatShellSetOperation(pjd->Pshell,MATOP_MULT,(void(*)())PEPJDShellMatMult);
625:   matctx->pep = pep;
626:   MatDuplicate(pep->A[0],MAT_DO_NOT_COPY_VALUES,&matctx->P);
627:   PCSetOperators(pcctx->pc,matctx->P,matctx->P);
628:   KSPSetPC(ksp,pjd->pcshell);
629:   KSPSetOperators(ksp,pjd->Pshell,pjd->Pshell);
630:   if (pep->nev>1) {
631:     PetscMalloc2(pep->nev*pep->nev,&pcctx->M,pep->nev*pep->nev,&pcctx->ps);
632:     pcctx->X  = pjd->X;
633:     pcctx->ld = pep->nev;
634:   }
635:   return(0);
636: }

640: static PetscErrorCode PEPJDUpdateExtendedPC(PEP pep,PetscScalar theta)
641: {
643:   PEP_JD         *pjd = (PEP_JD*)pep->data;
644:   PEP_JD_PCSHELL *pcctx;  
645:   PetscInt       i,j,k,n=pjd->nconv,ld=pep->nev,deg=pep->nmat-1;
646:   PetscScalar    fact,*M,*ps,*work,*U,*V,*S,sone=1.0,zero=0.0;
647:   PetscReal      tol,maxeig=0.0,*sg,*rwork;
648:   PetscBLASInt   n_,info,ld_,*p,lw_,rk=0;

651: #if defined(PETSC_MISSING_LAPACK_GESVD) || defined(PETSC_MISSING_LAPACK_GETRI) || defined(PETSC_MISSING_LAPACK_GETRF)
653:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD/GETRI/GETRF - Lapack routine is unavailable");
654: #else
655:   if (n) { 
656:     PCShellGetContext(pjd->pcshell,(void**)&pcctx);
657:     pcctx->n = n;
658:     M  = pcctx->M;
659:     ps = pcctx->ps;
660:                       /* h, and q are vectors containing diagonal matrices */
661:     PetscCalloc7(n*n,&U,n*n,&V,n*n,&S,n,&sg,10*n,&work,5*n,&rwork,n,&p);
662:     /* pseudo-inverse */
663:     for (j=0;j<n;j++) {
664:       for (i=0;i<j;i++) S[n*j+i] = -pjd->T[pep->nev*j+i];
665:       S[n*j+j] = theta-pjd->T[pep->nev*j+j];
666:     }
667:     PetscBLASIntCast(n,&n_);
668:     PetscBLASIntCast(ld,&ld_);
669:     lw_ = 10*n_;
670: #if !defined (PETSC_USE_COMPLEX)
671:     PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&n_,&n_,S,&n_,sg,U,&n_,V,&n_,work,&lw_,&info));
672: #else
673:     PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&n_,&n_,S,&n_,sg,U,&n_,V,&n_,work,&lw_,rwork,&info));
674: #endif
675:     for (i=0;i<n;i++) maxeig = PetscMax(maxeig,sg[i]);
676:     tol = 10*PETSC_MACHINE_EPSILON*n*maxeig;
677:     for (j=0;j<n;j++) {
678:       if (sg[j]>tol) {
679:         for (i=0;i<n;i++) U[j*n+i] /= sg[j];
680:         rk++;
681:       } else break;
682:     }
683:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n_,&n_,&rk,&sone,U,&n_,V,&n_,&zero,ps,&ld_));

685:     /* compute M */
686:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n_,&n_,&n_,&sone,pjd->XpX,&ld_,ps,&ld_,&zero,M,&ld_));
687:     fact = theta;
688:     PetscMemzero(S,n*n*sizeof(PetscScalar));
689:     for (j=0;j<n;j++) S[j*(n+1)] = 1.0; /* q=S */
690:     for (k=0;k<deg;k++) {
691:       for (j=0;j<n;j++) for (i=0;i<n;i++) V[j*n+i] = S[j*n+i] + M[j*ld+i]*fact;
692:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&n_,&n_,&n_,&sone,pjd->XpX,&ld_,V,&n_,&zero,U,&n_));
693:       PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&n_,&n_,&n_,&sone,pjd->Tj+k*ld*ld,&ld_,U,&n_,&sone,M,&ld_));
694:       PetscStackCallBLAS("BLAStrmm",BLAStrmm_("L","U","N","N",&n_,&n_,&sone,pjd->T,&ld_,S,&n_));
695:       for (j=0;j<n;j++) S[j*(n+1)] += fact;
696:       fact *=theta;
697:     }
698:     /* inverse */
699:     PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&n_,&n_,M,&ld_,p,&info));
700:     PetscStackCallBLAS("LAPACKgetri",LAPACKgetri_(&n_,M,&ld_,p,work,&n_,&info));
701:     PetscFree7(U,V,S,sg,work,rwork,p);
702:   }
703:   return(0);
704: #endif
705: }

709: static PetscErrorCode PEPJDPCMatSetUp(PEP pep,PetscScalar theta)
710: {
711:   PetscErrorCode  ierr;
712:   PEP_JD          *pjd = (PEP_JD*)pep->data;
713:   PEP_JD_MATSHELL *matctx;
714:   PEP_JD_PCSHELL  *pcctx;  
715:   MatStructure    str;
716:   PetscScalar     t;
717:   PetscInt        i;

720:   MatShellGetContext(pjd->Pshell,(void**)&matctx);
721:   PCShellGetContext(pjd->pcshell,(void**)&pcctx);
722:   STGetMatStructure(pep->st,&str);
723:   MatCopy(pep->A[0],matctx->P,str);
724:   t = theta;
725:   for (i=1;i<pep->nmat;i++) {
726:     if (t!=0.0) { MatAXPY(matctx->P,t,pep->A[i],str); }
727:     t *= theta;
728:   }
729:   PCSetOperators(pcctx->pc,matctx->P,matctx->P);
730:   PCSetUp(pcctx->pc);
731:   matctx->theta = theta;
732:   return(0);
733: }

737: static PetscErrorCode PEPJDEigenvectors(PEP pep)
738: {
740:   PEP_JD         *pjd = (PEP_JD*)pep->data;
741:   PetscBLASInt   ld,nconv,info,nc;
742:   PetscScalar    *Z,*w;
743:   PetscReal      *wr,norm;
744:   PetscInt       i;
745:   Mat            U;
746:  
748: #if defined(SLEPC_MISSING_LAPACK_TREVC)
750:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TREVC - Lapack routine is unavailable");
751: #else
752:   PetscMalloc3(pjd->nconv*pjd->nconv,&Z,3*pep->nev,&wr,2*pep->nev,&w);
753:   PetscBLASIntCast(pep->nev,&ld);
754:   PetscBLASIntCast(pjd->nconv,&nconv);
755: #if !defined(PETSC_USE_COMPLEX)
756:   PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_("R","A",NULL,&nconv,pjd->T,&ld,NULL,&nconv,Z,&nconv,&nconv,&nc,wr,&info));
757: #else
758:   PetscStackCallBLAS("LAPACKtrevc",LAPACKtrevc_("R","A",NULL,&nconv,pjd->T,&ld,NULL,&nconv,Z,&nconv,&nconv,&nc,w,wr,&info));
759: #endif
760:   MatCreateSeqDense(PETSC_COMM_SELF,nconv,nconv,Z,&U);
761:   BVSetActiveColumns(pjd->X,0,pjd->nconv);
762:   BVMultInPlace(pjd->X,U,0,pjd->nconv);
763:   for (i=0;i<pjd->nconv;i++) {
764:     BVNormColumn(pjd->X,i,NORM_2,&norm);
765:     BVScaleColumn(pjd->X,i,1.0/norm);  
766:   }
767:   MatDestroy(&U);
768:   PetscFree3(Z,wr,w);
769:   return(0);
770: #endif
771: }

775: static PetscErrorCode PEPJDLockConverged(PEP pep,PetscInt *nv)
776: {
777:   PetscErrorCode    ierr;
778:   PEP_JD            *pjd = (PEP_JD*)pep->data;
779:   PetscInt          j,i,ldds,rk=0,*P,nvv=*nv;
780:   Vec               v,x;
781:   PetscBLASInt      n,ld,rk_,nv_,info,one=1;
782:   PetscScalar       sone=1.0,*Tj,*R,*r,*tt,*pX;
783:   Mat               X;

786: #if defined(SLEPC_MISSING_LAPACK_TRTRI)
788:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"TRTRI - Lapack routine is unavailable");
789: #else
790:   /* update AX and XpX */
791:   BVGetColumn(pjd->X,pjd->nconv-1,&x);
792:   for (j=0;j<pep->nmat;j++) {
793:     BVGetColumn(pjd->AX[j],pjd->nconv-1,&v);
794:     MatMult(pep->A[j],x,v);
795:     BVRestoreColumn(pjd->AX[j],pjd->nconv-1,&v);
796:     BVSetActiveColumns(pjd->AX[j],0,pjd->nconv);
797:   }
798:   BVRestoreColumn(pjd->X,pjd->nconv-1,&x);
799:   BVDotColumn(pjd->X,(pjd->nconv-1),pjd->XpX+(pjd->nconv-1)*(pep->nev));
800:   pjd->XpX[(pjd->nconv-1)*(1+pep->nev)] = 1.0;
801:   for (j=0;j<pjd->nconv-1;j++) pjd->XpX[j*(pep->nev)+pjd->nconv-1] = PetscConj(pjd->XpX[(pjd->nconv-1)*(pep->nev)+j]);
802:   
803:   /* Compute powers of T */
804:   PetscBLASIntCast(pjd->nconv,&n);
805:   PetscBLASIntCast(pep->nev,&ld);
806:   PetscMemzero(pjd->Tj,pep->nev*pep->nev*pep->nmat*sizeof(PetscScalar));
807:   Tj = pjd->Tj;
808:   for (j=0;j<pjd->nconv;j++) Tj[(pep->nev+1)*j] = 1.0;
809:   Tj = pjd->Tj+pep->nev*pep->nev;
810:   PetscMemcpy(Tj,pjd->T,pep->nev*pjd->nconv*sizeof(PetscScalar));
811:   for (j=2;j<pep->nmat;j++) {
812:     PetscMemcpy(Tj+pep->nev*pep->nev,Tj,pep->nev*pjd->nconv*sizeof(PetscScalar));
813:     Tj += pep->nev*pep->nev;
814:     PetscStackCallBLAS("BLAStrmm",BLAStrmm_("L","U","N","N",&n,&n,&sone,pjd->T,&ld,Tj,&ld));
815:   }

817:   /* Extend search space */
818:   PetscCalloc4(nvv,&P,nvv*nvv,&R,nvv,&r,pep->nev-1,&tt);
819:   DSGetLeadingDimension(pep->ds,&ldds);
820:   DSGetArray(pep->ds,DS_MAT_X,&pX);
821:   PEPJDOrthogonalize(nvv,nvv,pX,ldds,&rk,P,R,nvv);
822:   for (i=0;i<rk-1;i++) r[i] = PetscConj(R[nvv*i]*pep->eigr[P[i+1]]); /* first row scaled with permuted diagonal */
823:   PetscBLASIntCast(rk,&rk_);
824:   PetscBLASIntCast(nvv,&nv_);
825:   PetscStackCallBLAS("LAPACKtrtri",LAPACKtrtri_("U","N",&rk_,R,&nv_,&info));
826:   if (info) SETERRQ1(PETSC_COMM_SELF,1,"Error in xTRTRI, info=%D",(PetscInt)info);
827:   PetscStackCallBLAS("BLAStrmv",BLAStrmv_("U","C","N",&rk_,R,&nv_,r,&one));
828:   for (i=0;i<rk;i++) r[i] = PetscConj(r[i]); /* revert */
829:   BVSetActiveColumns(pjd->V,0,nvv);
830:   for (j=0;j<rk-1;j++) {
831:     PetscMemcpy(R+j*nvv,pX+(j+1)*ldds,nvv*sizeof(PetscScalar));
832:   } 
833:   DSRestoreArray(pep->ds,DS_MAT_X,&pX);
834:   MatCreateSeqDense(PETSC_COMM_SELF,nvv,rk-1,R,&X);
835:   BVMultInPlace(pjd->V,X,0,rk-1);
836:   MatDestroy(&X);
837:   BVSetActiveColumns(pjd->V,0,rk-1);
838:   for (j=0;j<rk-1;j++) {
839:     BVGetColumn(pjd->V,j,&v);
840:     PEPJDCopyToExtendedVec(pep,NULL,r+j,1,pjd->nconv-1,v,PETSC_FALSE);
841:     BVRestoreColumn(pjd->V,j,&v);
842:   }
843:   BVOrthogonalize(pjd->V,NULL); 
844:   for (j=0;j<rk-1;j++) {
845:     BVGetColumn(pjd->W,j,&v);
846:     PEPJDCopyToExtendedVec(pep,NULL,tt,pep->nev-1,0,v,PETSC_FALSE);
847:     BVRestoreColumn(pjd->W,j,&v);
848:   }
849:   *nv = rk-1;
850:   PetscFree4(P,R,r,tt);
851: #endif
852:   return(0);
853: }

857: PetscErrorCode PEPSolve_JD(PEP pep)
858: {
859:   PetscErrorCode  ierr;
860:   PEP_JD          *pjd = (PEP_JD*)pep->data;
861:   PetscInt        k,nv,ld,minv,low,high,dim;
862:   PetscScalar     theta=0.0,*pX,*eig;
863:   PetscReal       norm,*res;
864:   PetscBool       lindep,initial=PETSC_FALSE,flglk=PETSC_FALSE,flgre=PETSC_FALSE;
865:   Vec             t,u,p,r,*ww=pep->work,v;
866:   Mat             G,X,Y;
867:   KSP             ksp;
868:   PEP_JD_PCSHELL  *pcctx;
869:   PEP_JD_MATSHELL *matctx;

872:   DSGetLeadingDimension(pep->ds,&ld);
873:   PetscMalloc2(pep->ncv,&eig,pep->ncv,&res);
874:   BVCreateVec(pjd->V,&u);
875:   VecDuplicate(u,&p);
876:   VecDuplicate(u,&r);
877:   STGetKSP(pep->st,&ksp);

879:   if (pep->nini) {
880:     nv = pep->nini; initial = PETSC_TRUE;
881:   } else {
882:     theta = pep->target;
883:     nv = 1;
884:   }
885:   PEPJDProcessInitialSpace(pep,ww);
886:   BVCopyVec(pjd->V,0,u);

888:   /* Restart loop */
889:   while (pep->reason == PEP_CONVERGED_ITERATING) {
890:     pep->its++;

892:     low = (flglk || flgre)? 0: nv-1;
893:     high = nv;
894:     DSSetDimensions(pep->ds,nv,0,0,0);
895:     BVSetActiveColumns(pjd->V,low,high);
896:     PEPJDUpdateTV(pep,low,high,ww);
897:     BVSetActiveColumns(pjd->W,low,high);
898:     for (k=0;k<pep->nmat;k++) {
899:       BVSetActiveColumns(pjd->TV[k],low,high);
900:       DSGetMat(pep->ds,DSMatExtra[k],&G);
901:       BVMatProject(pjd->TV[k],NULL,pjd->W,G);
902:       DSRestoreMat(pep->ds,DSMatExtra[k],&G);
903:     }
904:     BVSetActiveColumns(pjd->V,0,nv);
905:     BVSetActiveColumns(pjd->W,0,nv);

907:     /* Solve projected problem */
908:     if (nv>1 || initial ) {
909:       DSSetState(pep->ds,DS_STATE_RAW);
910:       DSSolve(pep->ds,pep->eigr+pep->nconv,pep->eigi+pep->nconv);
911:       DSSort(pep->ds,pep->eigr+pep->nconv,pep->eigi+pep->nconv,NULL,NULL,NULL);
912:       theta = pep->eigr[0];
913: #if !defined(PETSC_USE_COMPLEX)
914:       if (PetscAbsScalar(pep->eigi[pep->nconv])!=0.0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"PJD solver not implemented for complex Ritz values in real arithmetic");
915: #endif

917:       /* Compute Ritz vector u=V*X(:,1) */
918:       DSGetArray(pep->ds,DS_MAT_X,&pX);
919:       BVSetActiveColumns(pjd->V,0,nv);
920:       BVMultVec(pjd->V,1.0,0.0,u,pX);
921:       DSRestoreArray(pep->ds,DS_MAT_X,&pX);
922:     }
923:     PEPJDUpdateExtendedPC(pep,theta);

925:     /* Replace preconditioner with one containing projectors */
926:     if (!pjd->pcshell) {
927:       PEPJDCreateShellPC(pep);
928:       PCShellGetContext(pjd->pcshell,(void**)&pcctx);
929:       MatShellGetContext(pjd->Pshell,(void**)&matctx);
930:       matctx->work = ww;
931:       pcctx->work  = ww;
932:     }
933:     PEPJDPCMatSetUp(pep,theta);
934:     
935:     /* Compute r and r' */
936:     MatMult(pjd->Pshell,u,r);
937:     PEPJDComputePResidual(pep,u,theta,p,ww);
938:     pcctx->u = u;

940:     /* Check convergence */
941:     VecNorm(r,NORM_2,&norm);
942:     (*pep->converged)(pep,theta,0,norm,&pep->errest[pep->nconv],pep->convergedctx);
943:     (*pep->stopping)(pep,pep->its,pep->max_it,(pep->errest[pep->nconv]<pep->tol)?pjd->nconv+1:pjd->nconv,pep->nev,&pep->reason,pep->stoppingctx);

945:     if (pep->errest[pep->nconv]<pep->tol) {

947:       /* Ritz pair converged */
948:       minv = PetscMin(nv,(PetscInt)(pjd->keep*pep->ncv));
949:       if (pep->nev>1) {
950:         BVGetColumn(pjd->X,pjd->nconv,&v);
951:         PEPJDCopyToExtendedVec(pep,v,pjd->T+pep->nev*pjd->nconv,pep->nev-1,0,u,PETSC_TRUE);
952:         BVRestoreColumn(pjd->X,pjd->nconv,&v);
953:         BVSetActiveColumns(pjd->X,0,pjd->nconv+1);
954:         BVNormColumn(pjd->X,pjd->nconv,NORM_2,&norm);
955:         BVScaleColumn(pjd->X,pjd->nconv,1.0/norm);
956:         for (k=0;k<pjd->nconv;k++) pjd->T[pep->nev*pjd->nconv+k] /= norm;
957:         pjd->T[(pep->nev+1)*pjd->nconv] = pep->eigr[0];
958:       } else {
959:         BVInsertVec(pep->V,pep->nconv,u);
960:       }
961:       pjd->nconv++;

963:       if (pep->reason==PEP_CONVERGED_ITERATING) {
964:         PEPJDLockConverged(pep,&nv);
965:         BVCopyVec(pjd->V,nv-1,u);
966:         if (nv==1) theta = pep->target;
967:       }
968:       flglk = PETSC_TRUE;
969:     } else if (nv==pep->ncv-1) {

971:       /* Basis full, force restart */
972:       minv = PetscMin(nv,(PetscInt)(pjd->keep*pep->ncv));
973:       DSGetDimensions(pep->ds,&dim,NULL,NULL,NULL,NULL);
974:       DSGetArray(pep->ds,DS_MAT_X,&pX);
975:       PEPJDOrthogonalize(dim,minv,pX,ld,&minv,NULL,NULL,ld);
976:       DSRestoreArray(pep->ds,DS_MAT_X,&pX);
977:       DSGetArray(pep->ds,DS_MAT_Y,&pX);
978:       PEPJDOrthogonalize(dim,minv,pX,ld,&minv,NULL,NULL,ld);
979:       DSRestoreArray(pep->ds,DS_MAT_Y,&pX);
980:       DSGetMat(pep->ds,DS_MAT_X,&X);
981:       BVMultInPlace(pjd->V,X,pep->nconv,minv);
982:       DSRestoreMat(pep->ds,DS_MAT_X,&X);
983:       DSGetMat(pep->ds,DS_MAT_Y,&Y);
984:       BVMultInPlace(pjd->W,Y,pep->nconv,minv);
985:       DSRestoreMat(pep->ds,DS_MAT_Y,&Y);
986:       nv = minv;
987:       flgre = PETSC_TRUE;
988:     } else {
989:       /* Solve correction equation to expand basis */
990:       PEPJDExtendedPCApply(pjd->pcshell,p,pcctx->Bp);
991:       VecDot(pcctx->Bp,u,&pcctx->gamma);
992:       BVGetColumn(pjd->V,nv,&t);
993:       KSPSolve(ksp,r,t);
994:       BVRestoreColumn(pjd->V,nv,&t);
995:       BVOrthogonalizeColumn(pjd->V,nv,NULL,&norm,&lindep);
996:       if (lindep || norm==0.0) SETERRQ(PETSC_COMM_SELF,1,"Linearly dependent continuation vector");
997:       BVScaleColumn(pjd->V,nv,1.0/norm);
998:       BVInsertVec(pjd->W,nv,r);
999:       BVOrthogonalizeColumn(pjd->W,nv,NULL,&norm,&lindep);
1000:       if (lindep) SETERRQ(PETSC_COMM_SELF,1,"Linearly dependent continuation vector");
1001:       BVScaleColumn(pjd->W,nv,1.0/norm);
1002:       nv++;
1003:       flglk = PETSC_FALSE;
1004:       flgre = PETSC_FALSE;
1005:     }
1006:     for (k=pjd->nconv;k<nv;k++) {
1007:       eig[k] = pep->eigr[k-pjd->nconv];
1008:       res[k] = pep->errest[k-pjd->nconv];
1009: #if !defined(PETSC_USE_COMPLEX)
1010:       pep->eigi[k-pjd->nconv] = 0.0;
1011: #endif
1012:     }
1013:     PEPMonitor(pep,pep->its,pjd->nconv,eig,pep->eigi,res,pjd->nconv+1);
1014:   }
1015:   if (pep->nev>1) {
1016:     if (pjd->nconv>0) { PEPJDEigenvectors(pep); }
1017:     for (k=0;k<pjd->nconv;k++) {
1018:       BVGetColumn(pjd->X,k,&v);
1019:       BVInsertVec(pep->V,k,v);
1020:       BVRestoreColumn(pjd->X,k,&v);
1021:       pep->eigr[k] = pjd->T[(pep->nev+1)*k]; 
1022:       pep->eigi[k] = 0.0; 
1023:     }
1024:     PetscFree2(pcctx->M,pcctx->ps); 
1025:   }
1026:   pep->nconv = pjd->nconv; 
1027:   KSPSetPC(ksp,pcctx->pc);
1028:   MatDestroy(&matctx->P);
1029:   VecDestroy(&pcctx->Bp);
1030:   MatDestroy(&pjd->Pshell);
1031:   PCDestroy(&pcctx->pc);
1032:   PetscFree(pcctx);
1033:   PetscFree(matctx);
1034:   PCDestroy(&pjd->pcshell);
1035:   PetscFree2(eig,res);
1036:   VecDestroy(&u);
1037:   VecDestroy(&r);
1038:   VecDestroy(&p);
1039:   return(0);
1040: }

1044: PetscErrorCode PEPReset_JD(PEP pep)
1045: {
1047:   PEP_JD         *pjd = (PEP_JD*)pep->data;
1048:   PetscInt       i;

1051:   for (i=0;i<pep->nmat;i++) {
1052:     BVDestroy(pjd->TV+i);
1053:   }
1054:   BVDestroy(&pjd->W);
1055:   if (pep->nev>1) {
1056:     BVDestroy(&pjd->V);
1057:     for (i=0;i<pep->nmat;i++) {
1058:       BVDestroy(pjd->AX+i);
1059:     }
1060:     BVDestroy(&pjd->X);
1061:     PetscFree3(pjd->XpX,pjd->T,pjd->Tj);
1062:   }
1063:   PetscFree2(pjd->TV,pjd->AX);
1064:   return(0);
1065: }

1069: PetscErrorCode PEPDestroy_JD(PEP pep)
1070: {

1074:   PetscFree(pep->data);
1075:   PetscObjectComposeFunction((PetscObject)pep,"PEPJDSetRestart_C",NULL);
1076:   PetscObjectComposeFunction((PetscObject)pep,"PEPJDGetRestart_C",NULL);
1077:   return(0);
1078: }

1082: PETSC_EXTERN PetscErrorCode PEPCreate_JD(PEP pep)
1083: {
1084:   PEP_JD         *pjd;

1088:   PetscNewLog(pep,&pjd);
1089:   pep->data = (void*)pjd;

1091:   pjd->keep = 0;
1092:   pep->ops->solve          = PEPSolve_JD;
1093:   pep->ops->setup          = PEPSetUp_JD;
1094:   pep->ops->setfromoptions = PEPSetFromOptions_JD;
1095:   pep->ops->reset          = PEPReset_JD;
1096:   pep->ops->destroy        = PEPDestroy_JD;
1097:   pep->ops->view           = PEPView_JD;
1098:   PetscObjectComposeFunction((PetscObject)pep,"PEPJDSetRestart_C",PEPJDSetRestart_JD);
1099:   PetscObjectComposeFunction((PetscObject)pep,"PEPJDGetRestart_C",PEPJDGetRestart_JD);
1100:   return(0);
1101: }
slepc-3.7.4/src/pep/impls/jd/index.html0000644000175000017500000000315713107004621017262 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

pjdp.h
pjd.c
pjdopt.c
makefile
slepc-3.7.4/src/pep/impls/jd/ftn-auto/0000755000175000017500000000000013107004621017014 5ustar jromanjromanslepc-3.7.4/src/pep/impls/jd/ftn-auto/makefile0000644000175000017500000000035513107004621020517 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = pjdoptf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcpep LOCDIR = src/pep/impls/jd/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/jd/ftn-auto/pjdoptf.c0000644000175000017500000000265313107004621020634 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* pjdopt.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepjdsetrestart_ PEPJDSETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepjdsetrestart_ pepjdsetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepjdgetrestart_ PEPJDGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepjdgetrestart_ pepjdgetrestart #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepjdsetrestart_(PEP pep,PetscReal *keep, int *__ierr ){ *__ierr = PEPJDSetRestart( (PEP)PetscToPointer((pep) ),*keep); } PETSC_EXTERN void PETSC_STDCALL pepjdgetrestart_(PEP pep,PetscReal *keep, int *__ierr ){ *__ierr = PEPJDGetRestart( (PEP)PetscToPointer((pep) ),keep); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/impls/jd/pjdopt.c0000644000175000017500000001127513107004621016731 0ustar jromanjroman/* Options of polynomial JD solver. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include "pjdp.h" #undef __FUNCT__ #define __FUNCT__ "PEPJDSetRestart_JD" PetscErrorCode PEPJDSetRestart_JD(PEP pep,PetscReal keep) { PEP_JD *pjd = (PEP_JD*)pep->data; PetscFunctionBegin; if (keep==PETSC_DEFAULT) pjd->keep = 0.5; else { if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]"); pjd->keep = keep; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDSetRestart" /*@ PEPJDSetRestart - Sets the restart parameter for the Jacobi-Davidson method, in particular the proportion of basis vectors that must be kept after restart. Logically Collective on PEP Input Parameters: + pep - the eigenproblem solver context - keep - the number of vectors to be kept at restart Options Database Key: . -pep_jd_restart - Sets the restart parameter Notes: Allowed values are in the range [0.1,0.9]. The default is 0.5. Level: advanced .seealso: PEPJDGetRestart() @*/ PetscErrorCode PEPJDSetRestart(PEP pep,PetscReal keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveReal(pep,keep,2); ierr = PetscTryMethod(pep,"PEPJDSetRestart_C",(PEP,PetscReal),(pep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDGetRestart_JD" PetscErrorCode PEPJDGetRestart_JD(PEP pep,PetscReal *keep) { PEP_JD *pjd = (PEP_JD*)pep->data; PetscFunctionBegin; *keep = pjd->keep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPJDGetRestart" /*@ PEPJDGetRestart - Gets the restart parameter used in the Jacobi-Davidson method. Not Collective Input Parameter: . pep - the eigenproblem solver context Output Parameter: . keep - the restart parameter Level: advanced .seealso: PEPJDSetRestart() @*/ PetscErrorCode PEPJDGetRestart(PEP pep,PetscReal *keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(keep,2); ierr = PetscUseMethod(pep,"PEPJDGetRestart_C",(PEP,PetscReal*),(pep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetFromOptions_JD" PetscErrorCode PEPSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,PEP pep) { PetscErrorCode ierr; PetscBool flg; PetscReal r1; KSP ksp; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"PEP JD Options");CHKERRQ(ierr); ierr = PetscOptionsReal("-pep_jd_restart","Proportion of vectors kept after restart","PEPJDSetRestart",0.5,&r1,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPJDSetRestart(pep,r1);CHKERRQ(ierr); } /* Set STPRECOND as the default ST */ if (!pep->st) { ierr = PEPGetST(pep,&pep->st);CHKERRQ(ierr); } if (!((PetscObject)pep->st)->type_name) { ierr = STSetType(pep->st,STPRECOND);CHKERRQ(ierr); } /* Set the default options of the KSP */ ierr = STGetKSP(pep->st,&ksp);CHKERRQ(ierr); if (!((PetscObject)ksp)->type_name) { ierr = KSPSetType(ksp,KSPBCGSL);CHKERRQ(ierr); ierr = KSPSetTolerances(ksp,1e-5,PETSC_DEFAULT,PETSC_DEFAULT,100);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPView_JD" PetscErrorCode PEPView_JD(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PEP_JD *pjd = (PEP_JD*)pep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," JD: %d%% of basis vectors kept after restart\n",(int)(100*pjd->keep));CHKERRQ(ierr); } PetscFunctionReturn(0); } slepc-3.7.4/src/pep/impls/jd/pjdp.h0000644000175000017500000000526513107004621016375 0ustar jromanjroman/* Private header for PEPJD. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__PJDP_H) #define __PJDP_H typedef struct { PetscReal keep; /* restart parameter */ BV V; /* work basis vectors to store the search space */ BV W; /* work basis vectors to store the test space */ BV *TV; /* work basis vectors to store T*V (each TV[i] is the coefficient for \lambda^i of T*V for the extended T) */ BV *AX; /* work basis vectors to store A_i*X for locked eigenvectors */ BV X; /* locked eigenvectors */ PetscScalar *T; /* matrix of the invariant pair */ PetscScalar *Tj; /* matrix containing the powers of the invariant pair matrix */ PetscScalar *XpX; /* X^H*X */ PC pcshell; /* preconditioner including basic precond+projector */ Mat Pshell; /* auxiliary shell matrix */ PetscInt nconv; /* number of locked vectors in the invariant pair */ } PEP_JD; typedef struct { PC pc; /* basic preconditioner */ Vec Bp; /* preconditioned residual of derivative polynomial, B\p */ Vec u; /* Ritz vector */ PetscScalar gamma; /* precomputed scalar u'*B\p */ PetscScalar *M; PetscScalar *ps; PetscInt ld; Vec *work; BV X; PetscInt n; } PEP_JD_PCSHELL; typedef struct { Mat P; /* */ PEP pep; Vec *work; PetscScalar theta; } PEP_JD_MATSHELL; PETSC_INTERN PetscErrorCode PEPView_JD(PEP,PetscViewer); PETSC_INTERN PetscErrorCode PEPSetFromOptions_JD(PetscOptionItems*,PEP); PETSC_INTERN PetscErrorCode PEPJDSetRestart_JD(PEP,PetscReal); PETSC_INTERN PetscErrorCode PEPJDGetRestart_JD(PEP,PetscReal*); #endif slepc-3.7.4/src/pep/impls/jd/pjdp.h.html0000644000175000017500000001526613107004621017342 0ustar jromanjroman

Actual source code: pjdp.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private header for PEPJD.

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

  8:    This file is part of SLEPc.

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

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

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


 27: typedef struct {
 28:   PetscReal   keep;          /* restart parameter */
 29:   BV          V;             /* work basis vectors to store the search space */
 30:   BV          W;             /* work basis vectors to store the test space */
 31:   BV          *TV;           /* work basis vectors to store T*V (each TV[i] is the coefficient for \lambda^i of T*V for the extended T) */
 32:   BV          *AX;           /* work basis vectors to store A_i*X for locked eigenvectors */
 33:   BV          X;             /* locked eigenvectors */
 34:   PetscScalar *T;            /* matrix of the invariant pair */
 35:   PetscScalar *Tj;           /* matrix containing the powers of the invariant pair matrix */
 36:   PetscScalar *XpX;          /* X^H*X */
 37:   PC          pcshell;       /* preconditioner including basic precond+projector */
 38:   Mat         Pshell;        /* auxiliary shell matrix */
 39:   PetscInt    nconv;         /* number of locked vectors in the invariant pair */
 40: } PEP_JD;

 42: typedef struct {
 43:   PC          pc;            /* basic preconditioner */
 44:   Vec         Bp;            /* preconditioned residual of derivative polynomial, B\p */
 45:   Vec         u;             /* Ritz vector */
 46:   PetscScalar gamma;         /* precomputed scalar u'*B\p */
 47:   PetscScalar *M;
 48:   PetscScalar *ps;
 49:   PetscInt    ld;
 50:   Vec         *work;
 51:   BV          X;
 52:   PetscInt    n;
 53: } PEP_JD_PCSHELL;

 55: typedef struct {
 56:   Mat         P;             /*  */
 57:   PEP         pep;
 58:   Vec         *work;
 59:   PetscScalar theta;
 60: } PEP_JD_MATSHELL;

 62: PETSC_INTERN PetscErrorCode PEPView_JD(PEP,PetscViewer);
 63: PETSC_INTERN PetscErrorCode PEPSetFromOptions_JD(PetscOptionItems*,PEP);
 64: PETSC_INTERN PetscErrorCode PEPJDSetRestart_JD(PEP,PetscReal);
 65: PETSC_INTERN PetscErrorCode PEPJDGetRestart_JD(PEP,PetscReal*);

 67: #endif
slepc-3.7.4/src/pep/impls/index.html0000644000175000017500000000312613107004621016661 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

linear/
krylov/
jd/
makefile
slepc-3.7.4/src/pep/impls/krylov/0000755000175000017500000000000013107004621016210 5ustar jromanjromanslepc-3.7.4/src/pep/impls/krylov/makefile0000644000175000017500000000222013107004621017704 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = pepkrylov.c SOURCEF = SOURCEH = pepkrylov.h LIBBASE = libslepcpep DIRS = qarnoldi toar stoar LOCDIR = src/pep/impls/krylov/ MANSEC = PEP include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/krylov/stoar/0000755000175000017500000000000013107004621017340 5ustar jromanjromanslepc-3.7.4/src/pep/impls/krylov/stoar/makefile0000644000175000017500000000216313107004621021042 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = stoar.c SOURCEF = SOURCEH = LIBBASE = libslepcpep DIRS = MANSEC = PEP LOCDIR = src/pep/impls/krylov/stoar/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/krylov/stoar/stoar.c0000644000175000017500000007012013107004621020634 0ustar jromanjroman/* SLEPc polynomial eigensolver: "stoar" Method: S-TOAR Algorithm: Symmetric Two-Level Orthogonal Arnoldi. References: [1] C. Campos and J.E. Roman, "Restarted Q-Arnoldi-type methods exploiting symmetry in quadratic eigenvalue problems", BIT Numer. Math. (in press), 2016. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include "../src/pep/impls/krylov/pepkrylov.h" #include static PetscBool cited = PETSC_FALSE; static const char citation[] = "@Article{slepc-stoar,\n" " author = \"C. Campos and J. E. Roman\",\n" " title = \"Restarted {Q-Arnoldi-type} methods exploiting symmetry in quadratic eigenvalue problems\",\n" " journal = \"{BIT} Numer. Math.\",\n" " volume = \"to appear\",\n" " number = \"\",\n" " pages = \"\",\n" " year = \"2016,\"\n" " doi = \"http://dx.doi.org/10.1007/s10543-016-0601-5\"\n" "}\n"; #undef __FUNCT__ #define __FUNCT__ "PEPSTOARNorm" /* Compute B-norm of v=[v1;v2] whith B=diag(-pep->T[0],pep->T[2]) */ static PetscErrorCode PEPSTOARNorm(PEP pep,PetscInt j,PetscReal *norm) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscBLASInt n_,one=1,ld_; PetscScalar sone=1.0,szero=0.0,*sp,*sq,*w1,*w2,*qK,*qM; PetscInt n,i,lds=ctx->d*ctx->ld; PetscFunctionBegin; qK = ctx->qB; qM = ctx->qB+ctx->ld*ctx->ld; n = j+2; ierr = PetscMalloc2(n,&w1,n,&w2);CHKERRQ(ierr); sp = ctx->S+lds*j; sq = sp+ctx->ld; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ctx->ld,&ld_);CHKERRQ(ierr); PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qK,&ld_,sp,&one,&szero,w1,&one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qM,&ld_,sq,&one,&szero,w2,&one)); *norm = 0.0; for (i=0;i0.0)?PetscSqrtReal(*norm):-PetscSqrtReal(-*norm); ierr = PetscFree2(w1,w2);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSTOARqKqMupdates" static PetscErrorCode PEPSTOARqKqMupdates(PEP pep,PetscInt j,Vec *wv) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscInt i,ld=ctx->ld; PetscScalar *qK,*qM; Vec vj,v1,v2; PetscFunctionBegin; qK = ctx->qB; qM = ctx->qB+ctx->ld*ctx->ld; v1 = wv[0]; v2 = wv[1]; ierr = BVGetColumn(pep->V,j,&vj);CHKERRQ(ierr); ierr = STMatMult(pep->st,0,vj,v1);CHKERRQ(ierr); ierr = STMatMult(pep->st,2,vj,v2);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,j,&vj);CHKERRQ(ierr); for (i=0;i<=j;i++) { ierr = BVGetColumn(pep->V,i,&vj);CHKERRQ(ierr); ierr = VecDot(v1,vj,qK+j*ld+i);CHKERRQ(ierr); ierr = VecDot(v2,vj,qM+j*ld+i);CHKERRQ(ierr); *(qM+j*ld+i) *= pep->sfactor*pep->sfactor; ierr = BVRestoreColumn(pep->V,i,&vj);CHKERRQ(ierr); } for (i=0;idata; PetscInt ld,i; PetscReal norm,*omega; PetscFunctionBegin; pep->lineariz = PETSC_TRUE; ierr = PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);CHKERRQ(ierr); if (!ctx->lock && pep->mpdncv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant"); if (!pep->max_it) pep->max_it = PetscMax(100,2*pep->n/pep->ncv); /* Set STSHIFT as the default ST */ if (!((PetscObject)pep->st)->type_name) { ierr = STSetType(pep->st,STSHIFT);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);CHKERRQ(ierr); if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used"); if (!pep->which) { if (sinv) pep->which = PEP_TARGET_MAGNITUDE; else pep->which = PEP_LARGEST_MAGNITUDE; } if (pep->problem_type!=PEP_HERMITIAN) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems"); if (pep->nmat!=3) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver only available for quadratic problems"); if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver not implemented for non-monomial bases"); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver requires the ST transformation flag set, see STSetTransform()"); ierr = PEPAllocateSolution(pep,2);CHKERRQ(ierr); ierr = PEPSetWorkVecs(pep,4);CHKERRQ(ierr); ld = pep->ncv+2; ierr = DSSetType(pep->ds,DSGHIEP);CHKERRQ(ierr); ierr = DSSetCompact(pep->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(pep->ds,ld);CHKERRQ(ierr); ierr = STGetNumMatrices(pep->st,&ctx->d);CHKERRQ(ierr); ctx->d--; ctx->ld = ld; ierr = PetscCalloc1(ctx->d*ld*ld,&ctx->S);CHKERRQ(ierr); ierr = PetscCalloc1(2*ld*ld,&ctx->qB);CHKERRQ(ierr); /* process starting vector */ if (pep->nini>-2) { ierr = BVSetRandomColumn(pep->V,0);CHKERRQ(ierr); ierr = BVSetRandomColumn(pep->V,1);CHKERRQ(ierr); } else { ierr = BVInsertVec(pep->V,0,pep->IS[0]);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,1,pep->IS[1]);CHKERRQ(ierr); } ierr = BVOrthogonalizeColumn(pep->V,0,NULL,&norm,&lindep);CHKERRQ(ierr); if (!lindep) { ierr = BVScaleColumn(pep->V,0,1.0/norm);CHKERRQ(ierr); ctx->S[0] = norm; ierr = PEPSTOARqKqMupdates(pep,0,pep->work);CHKERRQ(ierr); } else SETERRQ(PetscObjectComm((PetscObject)pep),1,"Problem with initial vector"); ierr = BVOrthogonalizeColumn(pep->V,1,ctx->S+ld,&norm,&lindep);CHKERRQ(ierr); if (!lindep) { ierr = BVScaleColumn(pep->V,1,1.0/norm);CHKERRQ(ierr); ctx->S[1] = norm; ierr = PEPSTOARqKqMupdates(pep,1,pep->work);CHKERRQ(ierr); } else SETERRQ(PetscObjectComm((PetscObject)pep),1,"Problem with initial vector"); ierr = PEPSTOARNorm(pep,0,&norm);CHKERRQ(ierr); for (i=0;i<2;i++) { ctx->S[i+ld] /= norm; ctx->S[i] /= norm; } ierr = DSGetArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); omega[0] = (norm>0)?1.0:-1.0; ierr = DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); if (pep->nini<0) { ierr = SlepcBasisDestroy_Private(&pep->nini,&pep->IS);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSTOAROrth2" /* Computes GS orthogonalization x = [z;x] - [Sp;Sq]*y, where y = Omega\([Sp;Sq]'*[qK zeros(size(qK,1)) ;zeros(size(qK,1)) qM]*[z;x]). n: Column from S to be orthogonalized against previous columns. */ static PetscErrorCode PEPSTOAROrth2(PEP pep,PetscInt k,PetscReal *Omega,PetscScalar *y) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscBLASInt n_,lds_,k_,one=1,ld_; PetscScalar *S=ctx->S,sonem=-1.0,sone=1.0,szero=0.0,*tp,*tq,*xp,*xq,*c,*qK,*qM; PetscInt i,lds=ctx->d*ctx->ld,n,j; PetscFunctionBegin; qK = ctx->qB; qM = ctx->qB+ctx->ld*ctx->ld; n = k+2; ierr = PetscMalloc3(n,&tp,n,&tq,k,&c);CHKERRQ(ierr); ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); /* Size of qK and qM */ ierr = PetscBLASIntCast(ctx->ld,&ld_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); /* Number of vectors to orthogonalize against */ xp = S+k*lds; xq = S+ctx->ld+k*lds; PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qK,&ld_,xp,&one,&szero,tp,&one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qM,&ld_,xq,&one,&szero,tq,&one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,ctx->S,&lds_,tp,&one,&szero,y,&one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+ctx->ld,&lds_,tq,&one,&sone,y,&one)); for (i=0;ild,&lds_,y,&one,&sone,xq,&one)); /* three times */ for (j=0;j<2;j++) { PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qK,&ld_,xp,&one,&szero,tp,&one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qM,&ld_,xq,&one,&szero,tq,&one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,ctx->S,&lds_,tp,&one,&szero,c,&one)); PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+ctx->ld,&lds_,tq,&one,&sone,c,&one)); for (i=0;ild,&lds_,c,&one,&sone,xq,&one)); for (i=0;ild)*4 */ static PetscErrorCode PEPSTOARrun(PEP pep,PetscReal *a,PetscReal *b,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscScalar *work,Vec *t_) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscInt i,j,m=*M,l; PetscInt lds=ctx->d*ctx->ld,offq=ctx->ld; Vec v=t_[0],t=t_[1],q=t_[2]; PetscReal norm,sym=0.0,fro=0.0,*f; PetscScalar *y,*S=ctx->S; PetscBLASInt j_,one=1; PetscBool lindep; PetscFunctionBegin; *breakdown = PETSC_FALSE; /* ----- */ ierr = DSGetDimensions(pep->ds,NULL,NULL,&l,NULL,NULL);CHKERRQ(ierr); y = work; for (j=k;jV,0,j+2);CHKERRQ(ierr); ierr = BVMultVec(pep->V,1.0,0.0,v,S+j*lds);CHKERRQ(ierr); ierr = STMatMult(pep->st,0,v,t);CHKERRQ(ierr); ierr = BVMultVec(pep->V,1.0,0.0,v,S+offq+j*lds);CHKERRQ(ierr); ierr = STMatMult(pep->st,1,v,q);CHKERRQ(ierr); ierr = VecAXPY(t,pep->sfactor,q);CHKERRQ(ierr); ierr = STMatSolve(pep->st,t,q);CHKERRQ(ierr); ierr = VecScale(q,-1.0/(pep->sfactor*pep->sfactor));CHKERRQ(ierr); /* orthogonalize */ ierr = BVOrthogonalizeVec(pep->V,q,S+offq+(j+1)*lds,&norm,&lindep);CHKERRQ(ierr); if (lindep) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STOAR does not support detection of linearly dependent TOAR vectors"); *(S+offq+(j+1)*lds+j+2) = norm; ierr = VecScale(q,1.0/norm);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,j+2,q);CHKERRQ(ierr); for (i=0;i<=j+1;i++) *(S+(j+1)*lds+i) = *(S+offq+j*lds+i); /* update qK and qM */ ierr = PEPSTOARqKqMupdates(pep,j+2,t_);CHKERRQ(ierr); /* level-2 orthogonalization */ ierr = PEPSTOAROrth2(pep,j+1,omega,y);CHKERRQ(ierr); a[j] = PetscRealPart(y[j])/omega[j]; ierr = PEPSTOARNorm(pep,j+1,&norm);CHKERRQ(ierr); omega[j+1] = (norm > 0)?1.0:-1.0; for (i=0;i<=j+2;i++) { S[i+(j+1)*lds] /= norm; S[i+offq+(j+1)*lds] /= norm; } b[j] = PetscAbsReal(norm); /* check symmetry */ ierr = DSGetArrayReal(pep->ds,DS_MAT_T,&f);CHKERRQ(ierr); if (j==k) { for (i=l;ild+i]); for (i=0;ids,DS_MAT_T,&f);CHKERRQ(ierr); if (j>0) y[j-1] = PetscAbsScalar(y[j-1])-PetscAbsReal(b[j-1]); ierr = PetscBLASIntCast(j,&j_);CHKERRQ(ierr); sym = SlepcAbs(BLASnrm2_(&j_,y,&one),sym); fro = SlepcAbs(fro,SlepcAbs(a[j],b[j])); if (j>0) fro = SlepcAbs(fro,b[j-1]); if (sym/fro>PetscMax(PETSC_SQRT_MACHINE_EPSILON,10*pep->tol)) { *symmlost = PETSC_TRUE; *M=j+1; break; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSTOARTrunc" static PetscErrorCode PEPSTOARTrunc(PEP pep,PetscInt rs1,PetscInt cs1,PetscScalar *work,PetscReal *rwork) { #if defined(PETSC_MISSING_LAPACK_GESVD) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable"); #else PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; Mat G; PetscInt lwa,nwu=0,nrwu=0; PetscInt i,n,lds=2*ctx->ld; PetscScalar *M,*V,*U,*S=ctx->S,sone=1.0,zero=0.0,t,*qK,*qM; PetscReal *sg; PetscBLASInt cs1_,rs1_,cs1t2,cs1p1,n_,info,lw_,lds_,ld_; PetscFunctionBegin; qK = ctx->qB; qM = ctx->qB+ctx->ld*ctx->ld; n = (rs1>2*cs1)?2*cs1:rs1; lwa = cs1*rs1*4+n*(rs1+2*cs1)+(cs1+1)*(cs1+2); M = work+nwu; nwu += rs1*cs1*2; U = work+nwu; nwu += rs1*n; V = work+nwu; nwu += 2*cs1*n; sg = rwork+nrwu; nrwu += n; for (i=0;ild,rs1*sizeof(PetscScalar));CHKERRQ(ierr); } ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(cs1,&cs1_);CHKERRQ(ierr); ierr = PetscBLASIntCast(rs1,&rs1_);CHKERRQ(ierr); ierr = PetscBLASIntCast(cs1*2,&cs1t2);CHKERRQ(ierr); ierr = PetscBLASIntCast(cs1+1,&cs1p1);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ctx->ld,&ld_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lwa-nwu,&lw_);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&rs1_,&cs1t2,M,&rs1_,sg,U,&rs1_,V,&n_,work+nwu,&lw_,&info)); #else PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&rs1_,&cs1t2,M,&rs1_,sg,U,&rs1_,V,&n_,work+nwu,&lw_,rwork+nrwu,&info)); #endif if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info); /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,rs1,2*cs1,U,&G);CHKERRQ(ierr); ierr = BVSetActiveColumns(pep->V,0,rs1);CHKERRQ(ierr); ierr = BVMultInPlace(pep->V,G,0,cs1+1);CHKERRQ(ierr); ierr = MatDestroy(&G);CHKERRQ(ierr); /* Update S */ ierr = PetscMemzero(S,lds*ctx->ld*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;ild+i*lds,V+(cs1+i)*n,(cs1+1)*sizeof(PetscScalar));CHKERRQ(ierr); } /* Update qM and qK */ PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&rs1_,&cs1p1,&rs1_,&sone,qK,&ld_,U,&rs1_,&zero,work+nwu,&rs1_)); PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&cs1p1,&cs1p1,&rs1_,&sone,U,&rs1_,work+nwu,&rs1_,&zero,qK,&ld_)); PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&rs1_,&cs1p1,&rs1_,&sone,qM,&ld_,U,&rs1_,&zero,work+nwu,&rs1_)); PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&cs1p1,&cs1p1,&rs1_,&sone,U,&rs1_,work+nwu,&rs1_,&zero,qM,&ld_)); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "PEPSTOARSupdate" /* S <- S*Q columns s-s+ncu of S rows 0-sr of S size(Q) qr x ncu dim(work)=sr*ncu; */ static PetscErrorCode PEPSTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work) { PetscErrorCode ierr; PetscScalar a=1.0,b=0.0; PetscBLASInt sr_,ncu_,ldq_,lds_,qr_; PetscInt j,lds=2*ld; PetscFunctionBegin; ierr = PetscBLASIntCast(sr,&sr_);CHKERRQ(ierr); ierr = PetscBLASIntCast(qr,&qr_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ncu,&ncu_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldq,&ldq_);CHKERRQ(ierr); PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&sr_,&ncu_,&qr_,&a,S,&lds_,Q,&ldq_,&b,work,&sr_)); for (j=0;jdata; PetscBLASInt n_,one=1; PetscInt lds=2*ctx->ld; PetscReal t1,t2; PetscScalar *S=ctx->S; PetscFunctionBegin; ierr = PetscBLASIntCast(nv+2,&n_);CHKERRQ(ierr); t1 = BLASnrm2_(&n_,S+nv*2*ctx->ld,&one); t2 = BLASnrm2_(&n_,S+(nv*2+1)*ctx->ld,&one); *norm = SlepcAbs(t1,t2); ierr = BVSetActiveColumns(pep->V,0,nv+2);CHKERRQ(ierr); ierr = BVMultVec(pep->V,1.0,0.0,w[1],S+nv*lds);CHKERRQ(ierr); ierr = STMatMult(pep->st,0,w[1],w[2]);CHKERRQ(ierr); ierr = VecNorm(w[2],NORM_2,&t1);CHKERRQ(ierr); ierr = BVMultVec(pep->V,1.0,0.0,w[1],S+ctx->ld+nv*lds);CHKERRQ(ierr); ierr = STMatMult(pep->st,2,w[1],w[2]);CHKERRQ(ierr); ierr = VecNorm(w[2],NORM_2,&t2);CHKERRQ(ierr); t2 *= pep->sfactor*pep->sfactor; *norm = PetscMax(*norm,SlepcAbs(t1,t2)); PetscFunctionReturn(0); } #endif #undef __FUNCT__ #define __FUNCT__ "PEPSolve_STOAR" PetscErrorCode PEPSolve_STOAR(PEP pep) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscInt j,k,l,nv=0,ld=ctx->ld,lds=ctx->d*ctx->ld,off,ldds,t; PetscInt lwa,lrwa,nwu=0,nrwu=0,nconv=0; PetscScalar *S=ctx->S,*Q,*work; PetscReal beta,norm=1.0,*omega,*a,*b,*r,*rwork; PetscBool breakdown,symmlost=PETSC_FALSE,sinv; PetscFunctionBegin; ierr = PetscCitationsRegister(citation,&cited);CHKERRQ(ierr); ierr = BVSetMatrix(pep->V,NULL,PETSC_FALSE);CHKERRQ(ierr); lwa = 9*ld*ld+5*ld; lrwa = 8*ld; ierr = PetscMalloc2(lwa,&work,lrwa,&rwork);CHKERRQ(ierr); /* REVIEW */ ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);CHKERRQ(ierr); ierr = RGPushScale(pep->rg,sinv?pep->sfactor:1.0/pep->sfactor);CHKERRQ(ierr); ierr = STScaleShift(pep->st,sinv?pep->sfactor:1.0/pep->sfactor);CHKERRQ(ierr); /* Restart loop */ l = 0; ierr = DSGetLeadingDimension(pep->ds,&ldds);CHKERRQ(ierr); while (pep->reason == PEP_CONVERGED_ITERATING) { pep->its++; ierr = DSGetArrayReal(pep->ds,DS_MAT_T,&a);CHKERRQ(ierr); b = a+ldds; ierr = DSGetArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); /* Compute an nv-step Lanczos factorization */ nv = PetscMin(pep->nconv+pep->mpd,pep->ncv); ierr = PEPSTOARrun(pep,a,b,omega,pep->nconv+l,&nv,&breakdown,&symmlost,work+nwu,pep->work);CHKERRQ(ierr); beta = b[nv-1]; if (symmlost) { pep->reason = PEP_DIVERGED_SYMMETRY_LOST; if (nv==pep->nconv+l+1) { pep->nconv = nconv; break; } } ierr = DSRestoreArrayReal(pep->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); ierr = DSSetDimensions(pep->ds,nv,0,pep->nconv,pep->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(pep->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); } /* Solve projected problem */ ierr = DSSolve(pep->ds,pep->eigr,pep->eigi);CHKERRQ(ierr); ierr = DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);CHKERRQ(ierr); /* Check convergence */ /* ierr = PEPSTOARpreKConvergence(pep,nv,&norm,pep->work);CHKERRQ(ierr);*/ norm = 1.0; ierr = DSGetDimensions(pep->ds,NULL,NULL,NULL,NULL,&t);CHKERRQ(ierr); ierr = PEPKrylovConvergence(pep,PETSC_FALSE,pep->nconv,t-pep->nconv,PetscAbsReal(beta)*norm,&k);CHKERRQ(ierr); nconv = k; ierr = (*pep->stopping)(pep,pep->its,pep->max_it,k,pep->nev,&pep->reason,pep->stoppingctx);CHKERRQ(ierr); /* Update l */ if (pep->reason != PEP_CONVERGED_ITERATING || breakdown) l = 0; else { l = PetscMax(1,(PetscInt)((nv-k)/2)); l = PetscMin(l,t); ierr = DSGetArrayReal(pep->ds,DS_MAT_T,&a);CHKERRQ(ierr); if (*(a+ldds+k+l-1)!=0) { if (k+lds,DS_MAT_T,&a);CHKERRQ(ierr); } if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */ /* Update S */ off = pep->nconv*ldds; ierr = DSGetArray(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = PEPSTOARSupdate(S,ld,nv+2,pep->nconv,k+l-pep->nconv,nv,Q+off,ldds,work+nwu);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); /* Copy last column of S */ ierr = PetscMemcpy(S+lds*(k+l),S+lds*nv,lds*sizeof(PetscScalar));CHKERRQ(ierr); if (pep->reason == PEP_CONVERGED_ITERATING) { if (breakdown) { /* Stop if breakdown */ ierr = PetscInfo2(pep,"Breakdown STOAR method (it=%D norm=%g)\n",pep->its,(double)beta);CHKERRQ(ierr); pep->reason = PEP_DIVERGED_BREAKDOWN; } else { /* Prepare the Rayleigh quotient for restart */ ierr = DSGetArray(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSGetArrayReal(pep->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSGetArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); r = a + 2*ldds; for (j=k;jds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = DSRestoreArrayReal(pep->ds,DS_MAT_T,&a);CHKERRQ(ierr); ierr = DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); /* Truncate S */ ierr = DSGetArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); ierr = PEPSTOARTrunc(pep,nv+2,k+l+1,work+nwu,rwork+nrwu);CHKERRQ(ierr); ierr = DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); } } pep->nconv = k; ierr = PEPMonitor(pep,pep->its,pep->nconv,pep->eigr,pep->eigi,pep->errest,nv);CHKERRQ(ierr); } if (pep->nconv>0) { /* Truncate S */ ierr = DSGetArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); ierr = PEPSTOARTrunc(pep,nv+2,pep->nconv,work+nwu,rwork+nrwu);CHKERRQ(ierr); ierr = DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);CHKERRQ(ierr); /* Extraction */ ierr = DSSetDimensions(pep->ds,pep->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); for (j=0;jnconv;j++) { pep->eigr[j] *= pep->sfactor; pep->eigi[j] *= pep->sfactor; } } ierr = STScaleShift(pep->st,sinv?1.0/pep->sfactor:pep->sfactor);CHKERRQ(ierr); ierr = RGPopScale(pep->rg);CHKERRQ(ierr); /* truncate Schur decomposition and change the state to raw so that DSVectors() computes eigenvectors from scratch */ ierr = DSSetDimensions(pep->ds,pep->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = PetscFree2(work,rwork);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetFromOptions_STOAR" PetscErrorCode PEPSetFromOptions_STOAR(PetscOptionItems *PetscOptionsObject,PEP pep) { PetscErrorCode ierr; PetscBool flg,lock; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"PEP STOAR Options");CHKERRQ(ierr); ierr = PetscOptionsBool("-pep_stoar_locking","Choose between locking and non-locking variants","PEPSTOARSetLocking",PETSC_FALSE,&lock,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPSTOARSetLocking(pep,lock);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSTOARSetLocking_STOAR" static PetscErrorCode PEPSTOARSetLocking_STOAR(PEP pep,PetscBool lock) { PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscFunctionBegin; ctx->lock = lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSTOARSetLocking" /*@ PEPSTOARSetLocking - Choose between locking and non-locking variants of the STOAR method. Logically Collective on PEP Input Parameters: + pep - the eigenproblem solver context - lock - true if the locking variant must be selected Options Database Key: . -pep_stoar_locking - Sets the locking flag Notes: The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant). Level: advanced .seealso: PEPSTOARGetLocking() @*/ PetscErrorCode PEPSTOARSetLocking(PEP pep,PetscBool lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveBool(pep,lock,2); ierr = PetscTryMethod(pep,"PEPSTOARSetLocking_C",(PEP,PetscBool),(pep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSTOARGetLocking_STOAR" static PetscErrorCode PEPSTOARGetLocking_STOAR(PEP pep,PetscBool *lock) { PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscFunctionBegin; *lock = ctx->lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSTOARGetLocking" /*@ PEPSTOARGetLocking - Gets the locking flag used in the STOAR method. Not Collective Input Parameter: . pep - the eigenproblem solver context Output Parameter: . lock - the locking flag Level: advanced .seealso: PEPSTOARSetLocking() @*/ PetscErrorCode PEPSTOARGetLocking(PEP pep,PetscBool *lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(lock,2); ierr = PetscUseMethod(pep,"PEPSTOARGetLocking_C",(PEP,PetscBool*),(pep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPView_STOAR" PetscErrorCode PEPView_STOAR(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," STOAR: using the %slocking variant\n",ctx->lock?"":"non-");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPDestroy_STOAR" PetscErrorCode PEPDestroy_STOAR(PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(pep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARSetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARGetLocking_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPCreate_STOAR" PETSC_EXTERN PetscErrorCode PEPCreate_STOAR(PEP pep) { PetscErrorCode ierr; PEP_TOAR *ctx; PetscFunctionBegin; ierr = PetscNewLog(pep,&ctx);CHKERRQ(ierr); pep->data = (void*)ctx; ctx->lock = PETSC_TRUE; pep->ops->solve = PEPSolve_STOAR; pep->ops->setup = PEPSetUp_STOAR; pep->ops->setfromoptions = PEPSetFromOptions_STOAR; pep->ops->view = PEPView_STOAR; pep->ops->destroy = PEPDestroy_STOAR; pep->ops->backtransform = PEPBackTransform_Default; pep->ops->computevectors = PEPComputeVectors_Default; pep->ops->extractvectors = PEPExtractVectors_TOAR; pep->ops->reset = PEPReset_TOAR; ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARSetLocking_C",PEPSTOARSetLocking_STOAR);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARGetLocking_C",PEPSTOARGetLocking_STOAR);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/impls/krylov/stoar/stoar.c.html0000644000175000017500000016626413107004621021616 0ustar jromanjroman

Actual source code: stoar.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc polynomial eigensolver: "stoar"

  5:    Method: S-TOAR

  7:    Algorithm:

  9:        Symmetric Two-Level Orthogonal Arnoldi.

 11:    References:

 13:        [1] C. Campos and J.E. Roman, "Restarted Q-Arnoldi-type methods
 14:            exploiting symmetry in quadratic eigenvalue problems", BIT
 15:            Numer. Math. (in press), 2016.

 17:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 19:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 21:    This file is part of SLEPc.

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

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

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

 37: #include <slepc/private/pepimpl.h>         /*I "slepcpep.h" I*/
 38:  #include ../src/pep/impls/krylov/pepkrylov.h
 39: #include <slepcblaslapack.h>

 41: static PetscBool  cited = PETSC_FALSE;
 42: static const char citation[] =
 43:   "@Article{slepc-stoar,\n"
 44:   "   author = \"C. Campos and J. E. Roman\",\n"
 45:   "   title = \"Restarted {Q-Arnoldi-type} methods exploiting symmetry in quadratic eigenvalue problems\",\n"
 46:   "   journal = \"{BIT} Numer. Math.\",\n"
 47:   "   volume = \"to appear\",\n"
 48:   "   number = \"\",\n"
 49:   "   pages = \"\",\n"
 50:   "   year = \"2016,\"\n"
 51:   "   doi = \"http://dx.doi.org/10.1007/s10543-016-0601-5\"\n"
 52:   "}\n";

 56: /*
 57:   Compute B-norm of v=[v1;v2] whith  B=diag(-pep->T[0],pep->T[2])
 58: */
 59: static PetscErrorCode PEPSTOARNorm(PEP pep,PetscInt j,PetscReal *norm)
 60: {
 62:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
 63:   PetscBLASInt   n_,one=1,ld_;
 64:   PetscScalar    sone=1.0,szero=0.0,*sp,*sq,*w1,*w2,*qK,*qM;
 65:   PetscInt       n,i,lds=ctx->d*ctx->ld;

 68:   qK = ctx->qB;
 69:   qM = ctx->qB+ctx->ld*ctx->ld;
 70:   n = j+2;
 71:   PetscMalloc2(n,&w1,n,&w2);
 72:   sp = ctx->S+lds*j;
 73:   sq = sp+ctx->ld;
 74:   PetscBLASIntCast(n,&n_);
 75:   PetscBLASIntCast(ctx->ld,&ld_);
 76:   PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qK,&ld_,sp,&one,&szero,w1,&one));
 77:   PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qM,&ld_,sq,&one,&szero,w2,&one));
 78:   *norm = 0.0;
 79:   for (i=0;i<n;i++) *norm += PetscRealPart(w1[i]*PetscConj(sp[i])+w2[i]*PetscConj(sq[i]));
 80:   *norm = (*norm>0.0)?PetscSqrtReal(*norm):-PetscSqrtReal(-*norm);
 81:   PetscFree2(w1,w2);
 82:   return(0);
 83: }

 87: static PetscErrorCode PEPSTOARqKqMupdates(PEP pep,PetscInt j,Vec *wv)
 88: {
 90:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
 91:   PetscInt       i,ld=ctx->ld;
 92:   PetscScalar    *qK,*qM;
 93:   Vec            vj,v1,v2;

 96:   qK = ctx->qB;
 97:   qM = ctx->qB+ctx->ld*ctx->ld;
 98:   v1 = wv[0];
 99:   v2 = wv[1];
100:   BVGetColumn(pep->V,j,&vj);
101:   STMatMult(pep->st,0,vj,v1);
102:   STMatMult(pep->st,2,vj,v2);
103:   BVRestoreColumn(pep->V,j,&vj);
104:   for (i=0;i<=j;i++) {
105:     BVGetColumn(pep->V,i,&vj);
106:     VecDot(v1,vj,qK+j*ld+i);
107:     VecDot(v2,vj,qM+j*ld+i);
108:     *(qM+j*ld+i) *= pep->sfactor*pep->sfactor;
109:     BVRestoreColumn(pep->V,i,&vj);
110:   }
111:   for (i=0;i<j;i++) {
112:     qK[i+j*ld] = -qK[i+ld*j];
113:     qK[j+i*ld] = PetscConj(qK[i+j*ld]);
114:     qM[j+i*ld] = PetscConj(qM[i+j*ld]);
115:   }
116:   qK[j+j*ld] = -PetscRealPart(qK[j+ld*j]);
117:   qM[j+j*ld] = PetscRealPart(qM[j+ld*j]);
118:   return(0);
119: }

123: PetscErrorCode PEPSetUp_STOAR(PEP pep)
124: {
126:   PetscBool      shift,sinv,flg,lindep;
127:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
128:   PetscInt       ld,i;
129:   PetscReal      norm,*omega;

132:   pep->lineariz = PETSC_TRUE;
133:   PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);
134:   if (!ctx->lock && pep->mpd<pep->ncv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant");
135:   if (!pep->max_it) pep->max_it = PetscMax(100,2*pep->n/pep->ncv);
136:   /* Set STSHIFT as the default ST */
137:   if (!((PetscObject)pep->st)->type_name) {
138:     STSetType(pep->st,STSHIFT);
139:   }
140:   PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);
141:   PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);
142:   if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used");
143:   if (!pep->which) {
144:     if (sinv) pep->which = PEP_TARGET_MAGNITUDE;
145:     else pep->which = PEP_LARGEST_MAGNITUDE;
146:   }
147:   if (pep->problem_type!=PEP_HERMITIAN) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Requested method is only available for Hermitian problems");

149:   if (pep->nmat!=3) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver only available for quadratic problems");
150:   if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver not implemented for non-monomial bases");
151:   STGetTransform(pep->st,&flg);
152:   if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver requires the ST transformation flag set, see STSetTransform()");

154:   PEPAllocateSolution(pep,2);
155:   PEPSetWorkVecs(pep,4);
156:   ld = pep->ncv+2;
157:   DSSetType(pep->ds,DSGHIEP);
158:   DSSetCompact(pep->ds,PETSC_TRUE);
159:   DSAllocate(pep->ds,ld);
160:   STGetNumMatrices(pep->st,&ctx->d);
161:   ctx->d--;
162:   ctx->ld = ld;
163:   PetscCalloc1(ctx->d*ld*ld,&ctx->S);
164:   PetscCalloc1(2*ld*ld,&ctx->qB);

166:   /* process starting vector */
167:   if (pep->nini>-2) {
168:     BVSetRandomColumn(pep->V,0);
169:     BVSetRandomColumn(pep->V,1);
170:   } else {
171:     BVInsertVec(pep->V,0,pep->IS[0]);
172:     BVInsertVec(pep->V,1,pep->IS[1]);
173:   }
174:   BVOrthogonalizeColumn(pep->V,0,NULL,&norm,&lindep);
175:   if (!lindep) {
176:     BVScaleColumn(pep->V,0,1.0/norm);
177:     ctx->S[0] = norm;
178:     PEPSTOARqKqMupdates(pep,0,pep->work);
179:   } else SETERRQ(PetscObjectComm((PetscObject)pep),1,"Problem with initial vector");
180:   BVOrthogonalizeColumn(pep->V,1,ctx->S+ld,&norm,&lindep);
181:   if (!lindep) {
182:     BVScaleColumn(pep->V,1,1.0/norm);
183:     ctx->S[1] = norm;
184:     PEPSTOARqKqMupdates(pep,1,pep->work);
185:   } else SETERRQ(PetscObjectComm((PetscObject)pep),1,"Problem with initial vector");

187:   PEPSTOARNorm(pep,0,&norm);
188:   for (i=0;i<2;i++) { ctx->S[i+ld] /= norm; ctx->S[i] /= norm; }
189:   DSGetArrayReal(pep->ds,DS_MAT_D,&omega);
190:   omega[0] = (norm>0)?1.0:-1.0;
191:   DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);
192:   if (pep->nini<0) {
193:     SlepcBasisDestroy_Private(&pep->nini,&pep->IS);
194:   }
195:   return(0);
196: }

200: /*
201:   Computes GS orthogonalization  x = [z;x] - [Sp;Sq]*y,
202:   where y = Omega\([Sp;Sq]'*[qK zeros(size(qK,1)) ;zeros(size(qK,1)) qM]*[z;x]).
203:   n: Column from S to be orthogonalized against previous columns.
204: */
205: static PetscErrorCode PEPSTOAROrth2(PEP pep,PetscInt k,PetscReal *Omega,PetscScalar *y)
206: {
208:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
209:   PetscBLASInt   n_,lds_,k_,one=1,ld_;
210:   PetscScalar    *S=ctx->S,sonem=-1.0,sone=1.0,szero=0.0,*tp,*tq,*xp,*xq,*c,*qK,*qM;
211:   PetscInt       i,lds=ctx->d*ctx->ld,n,j;

214:   qK = ctx->qB;
215:   qM = ctx->qB+ctx->ld*ctx->ld;
216:   n = k+2;
217:   PetscMalloc3(n,&tp,n,&tq,k,&c);
218:   PetscBLASIntCast(n,&n_); /* Size of qK and qM */
219:   PetscBLASIntCast(ctx->ld,&ld_);
220:   PetscBLASIntCast(lds,&lds_);
221:   PetscBLASIntCast(k,&k_); /* Number of vectors to orthogonalize against */
222:   xp = S+k*lds;
223:   xq = S+ctx->ld+k*lds;
224:   PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qK,&ld_,xp,&one,&szero,tp,&one));
225:   PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qM,&ld_,xq,&one,&szero,tq,&one));
226:   PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,ctx->S,&lds_,tp,&one,&szero,y,&one));
227:   PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+ctx->ld,&lds_,tq,&one,&sone,y,&one));
228:   for (i=0;i<k;i++) y[i] /= Omega[i];
229:   PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S,&lds_,y,&one,&sone,xp,&one));
230:   PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S+ctx->ld,&lds_,y,&one,&sone,xq,&one));
231:   /* three times */
232:   for (j=0;j<2;j++) {
233:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qK,&ld_,xp,&one,&szero,tp,&one));
234:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&n_,&sone,qM,&ld_,xq,&one,&szero,tq,&one));
235:     PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,ctx->S,&lds_,tp,&one,&szero,c,&one));
236:     PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+ctx->ld,&lds_,tq,&one,&sone,c,&one));
237:     for (i=0;i<k;i++) c[i] /= Omega[i];
238:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S,&lds_,c,&one,&sone,xp,&one));
239:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S+ctx->ld,&lds_,c,&one,&sone,xq,&one));
240:     for (i=0;i<k;i++) y[i] += c[i];
241:   }
242:   PetscFree3(tp,tq,c);
243:   return(0);
244: }

248: /*
249:   Compute a run of Lanczos iterations. dim(work)=(ctx->ld)*4
250: */
251: static PetscErrorCode PEPSTOARrun(PEP pep,PetscReal *a,PetscReal *b,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscScalar *work,Vec *t_)
252: {
254:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
255:   PetscInt       i,j,m=*M,l;
256:   PetscInt       lds=ctx->d*ctx->ld,offq=ctx->ld;
257:   Vec            v=t_[0],t=t_[1],q=t_[2];
258:   PetscReal      norm,sym=0.0,fro=0.0,*f;
259:   PetscScalar    *y,*S=ctx->S;
260:   PetscBLASInt   j_,one=1;
261:   PetscBool      lindep;

264:   *breakdown = PETSC_FALSE; /* ----- */
265:   DSGetDimensions(pep->ds,NULL,NULL,&l,NULL,NULL);
266:   y = work;
267:   for (j=k;j<m;j++) {
268:     /* apply operator */
269:     BVSetActiveColumns(pep->V,0,j+2);
270:     BVMultVec(pep->V,1.0,0.0,v,S+j*lds);
271:     STMatMult(pep->st,0,v,t);
272:     BVMultVec(pep->V,1.0,0.0,v,S+offq+j*lds);
273:     STMatMult(pep->st,1,v,q);
274:     VecAXPY(t,pep->sfactor,q);
275:     STMatSolve(pep->st,t,q);
276:     VecScale(q,-1.0/(pep->sfactor*pep->sfactor));

278:     /* orthogonalize */
279:     BVOrthogonalizeVec(pep->V,q,S+offq+(j+1)*lds,&norm,&lindep);
280:     if (lindep) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"STOAR does not support detection of linearly dependent TOAR vectors");
281:     *(S+offq+(j+1)*lds+j+2) = norm;
282:     VecScale(q,1.0/norm);
283:     BVInsertVec(pep->V,j+2,q);
284:     for (i=0;i<=j+1;i++) *(S+(j+1)*lds+i) = *(S+offq+j*lds+i);

286:     /* update qK and qM */
287:     PEPSTOARqKqMupdates(pep,j+2,t_);

289:     /* level-2 orthogonalization */
290:     PEPSTOAROrth2(pep,j+1,omega,y);
291:     a[j] = PetscRealPart(y[j])/omega[j];
292:     PEPSTOARNorm(pep,j+1,&norm);
293:     omega[j+1] = (norm > 0)?1.0:-1.0;
294:     for (i=0;i<=j+2;i++) {
295:       S[i+(j+1)*lds] /= norm;
296:       S[i+offq+(j+1)*lds] /= norm;
297:     }
298:     b[j] = PetscAbsReal(norm);

300:     /* check symmetry */
301:     DSGetArrayReal(pep->ds,DS_MAT_T,&f);
302:     if (j==k) {
303:       for (i=l;i<j-1;i++) y[i] = PetscAbsScalar(y[i])-PetscAbsReal(f[2*ctx->ld+i]);
304:       for (i=0;i<l;i++) y[i] = 0.0;
305:     }
306:     DSRestoreArrayReal(pep->ds,DS_MAT_T,&f);
307:     if (j>0) y[j-1] = PetscAbsScalar(y[j-1])-PetscAbsReal(b[j-1]);
308:     PetscBLASIntCast(j,&j_);
309:     sym = SlepcAbs(BLASnrm2_(&j_,y,&one),sym);
310:     fro = SlepcAbs(fro,SlepcAbs(a[j],b[j]));
311:     if (j>0) fro = SlepcAbs(fro,b[j-1]);
312:     if (sym/fro>PetscMax(PETSC_SQRT_MACHINE_EPSILON,10*pep->tol)) {
313:       *symmlost = PETSC_TRUE;
314:       *M=j+1;
315:       break;
316:     }
317:   }
318:   return(0);
319: }

323: static PetscErrorCode PEPSTOARTrunc(PEP pep,PetscInt rs1,PetscInt cs1,PetscScalar *work,PetscReal *rwork)
324: {
325: #if defined(PETSC_MISSING_LAPACK_GESVD)
327:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD - Lapack routine is unavailable");
328: #else
330:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
331:   Mat            G;
332:   PetscInt       lwa,nwu=0,nrwu=0;
333:   PetscInt       i,n,lds=2*ctx->ld;
334:   PetscScalar    *M,*V,*U,*S=ctx->S,sone=1.0,zero=0.0,t,*qK,*qM;
335:   PetscReal      *sg;
336:   PetscBLASInt   cs1_,rs1_,cs1t2,cs1p1,n_,info,lw_,lds_,ld_;

339:   qK = ctx->qB;
340:   qM = ctx->qB+ctx->ld*ctx->ld;
341:   n = (rs1>2*cs1)?2*cs1:rs1;
342:   lwa = cs1*rs1*4+n*(rs1+2*cs1)+(cs1+1)*(cs1+2);
343:   M = work+nwu;
344:   nwu += rs1*cs1*2;
345:   U = work+nwu;
346:   nwu += rs1*n;
347:   V = work+nwu;
348:   nwu += 2*cs1*n;
349:   sg = rwork+nrwu;
350:   nrwu += n;
351:   for (i=0;i<cs1;i++) {
352:     PetscMemcpy(M+i*rs1,S+i*lds,rs1*sizeof(PetscScalar));
353:     PetscMemcpy(M+(i+cs1)*rs1,S+i*lds+ctx->ld,rs1*sizeof(PetscScalar));
354:   }
355:   PetscBLASIntCast(n,&n_);
356:   PetscBLASIntCast(cs1,&cs1_);
357:   PetscBLASIntCast(rs1,&rs1_);
358:   PetscBLASIntCast(cs1*2,&cs1t2);
359:   PetscBLASIntCast(cs1+1,&cs1p1);
360:   PetscBLASIntCast(lds,&lds_);
361:   PetscBLASIntCast(ctx->ld,&ld_);
362:   PetscBLASIntCast(lwa-nwu,&lw_);
363: #if !defined(PETSC_USE_COMPLEX)
364:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&rs1_,&cs1t2,M,&rs1_,sg,U,&rs1_,V,&n_,work+nwu,&lw_,&info));
365: #else
366:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&rs1_,&cs1t2,M,&rs1_,sg,U,&rs1_,V,&n_,work+nwu,&lw_,rwork+nrwu,&info));
367: #endif
368:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);

370:   /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */
371:   MatCreateSeqDense(PETSC_COMM_SELF,rs1,2*cs1,U,&G);
372:   BVSetActiveColumns(pep->V,0,rs1);
373:   BVMultInPlace(pep->V,G,0,cs1+1);
374:   MatDestroy(&G);

376:   /* Update S */
377:   PetscMemzero(S,lds*ctx->ld*sizeof(PetscScalar));

379:   for (i=0;i<cs1+1;i++) {
380:     t = sg[i];
381:     PetscStackCallBLAS("BLASscal",BLASscal_(&cs1t2,&t,V+i,&n_));
382:   }
383:   for (i=0;i<cs1;i++) {
384:     PetscMemcpy(S+i*lds,V+i*n,(cs1+1)*sizeof(PetscScalar));
385:     PetscMemcpy(S+ctx->ld+i*lds,V+(cs1+i)*n,(cs1+1)*sizeof(PetscScalar));
386:   }

388:   /* Update qM and qK */
389:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&rs1_,&cs1p1,&rs1_,&sone,qK,&ld_,U,&rs1_,&zero,work+nwu,&rs1_));
390:   PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&cs1p1,&cs1p1,&rs1_,&sone,U,&rs1_,work+nwu,&rs1_,&zero,qK,&ld_));
391:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&rs1_,&cs1p1,&rs1_,&sone,qM,&ld_,U,&rs1_,&zero,work+nwu,&rs1_));
392:   PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&cs1p1,&cs1p1,&rs1_,&sone,U,&rs1_,work+nwu,&rs1_,&zero,qM,&ld_));
393:   return(0);
394: #endif
395: }

399: /*
400:   S <- S*Q
401:   columns s-s+ncu of S
402:   rows 0-sr of S
403:   size(Q) qr x ncu
404:   dim(work)=sr*ncu;
405: */
406: static PetscErrorCode PEPSTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)
407: {
409:   PetscScalar    a=1.0,b=0.0;
410:   PetscBLASInt   sr_,ncu_,ldq_,lds_,qr_;
411:   PetscInt       j,lds=2*ld;

414:   PetscBLASIntCast(sr,&sr_);
415:   PetscBLASIntCast(qr,&qr_);
416:   PetscBLASIntCast(ncu,&ncu_);
417:   PetscBLASIntCast(lds,&lds_);
418:   PetscBLASIntCast(ldq,&ldq_);
419:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&sr_,&ncu_,&qr_,&a,S,&lds_,Q,&ldq_,&b,work,&sr_));
420:   for (j=0;j<ncu;j++) {
421:     PetscMemcpy(S+lds*(s+j),work+j*sr,sr*sizeof(PetscScalar));
422:   }
423:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&sr_,&ncu_,&qr_,&a,S+ld,&lds_,Q,&ldq_,&b,work,&sr_));
424:   for (j=0;j<ncu;j++) {
425:     PetscMemcpy(S+lds*(s+j)+ld,work+j*sr,sr*sizeof(PetscScalar));
426:   }
427:   return(0);
428: }

430: #if 0
433: static PetscErrorCode PEPSTOARpreKConvergence(PEP pep,PetscInt nv,PetscReal *norm,Vec *w)
434: {
436:   PEP_TOAR      *ctx = (PEP_TOAR*)pep->data;
437:   PetscBLASInt   n_,one=1;
438:   PetscInt       lds=2*ctx->ld;
439:   PetscReal      t1,t2;
440:   PetscScalar    *S=ctx->S;

443:   PetscBLASIntCast(nv+2,&n_);
444:   t1 = BLASnrm2_(&n_,S+nv*2*ctx->ld,&one);
445:   t2 = BLASnrm2_(&n_,S+(nv*2+1)*ctx->ld,&one);
446:   *norm = SlepcAbs(t1,t2);
447:   BVSetActiveColumns(pep->V,0,nv+2);
448:   BVMultVec(pep->V,1.0,0.0,w[1],S+nv*lds);
449:   STMatMult(pep->st,0,w[1],w[2]);
450:   VecNorm(w[2],NORM_2,&t1);
451:   BVMultVec(pep->V,1.0,0.0,w[1],S+ctx->ld+nv*lds);
452:   STMatMult(pep->st,2,w[1],w[2]);
453:   VecNorm(w[2],NORM_2,&t2);
454:   t2 *= pep->sfactor*pep->sfactor;
455:   *norm = PetscMax(*norm,SlepcAbs(t1,t2));
456:   return(0);
457: }
458: #endif

462: PetscErrorCode PEPSolve_STOAR(PEP pep)
463: {
465:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
466:   PetscInt       j,k,l,nv=0,ld=ctx->ld,lds=ctx->d*ctx->ld,off,ldds,t;
467:   PetscInt       lwa,lrwa,nwu=0,nrwu=0,nconv=0;
468:   PetscScalar    *S=ctx->S,*Q,*work;
469:   PetscReal      beta,norm=1.0,*omega,*a,*b,*r,*rwork;
470:   PetscBool      breakdown,symmlost=PETSC_FALSE,sinv;

473:   PetscCitationsRegister(citation,&cited);
474:   BVSetMatrix(pep->V,NULL,PETSC_FALSE);
475:   lwa = 9*ld*ld+5*ld;
476:   lrwa = 8*ld;
477:   PetscMalloc2(lwa,&work,lrwa,&rwork); /* REVIEW */
478:   PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);
479:   RGPushScale(pep->rg,sinv?pep->sfactor:1.0/pep->sfactor);
480:   STScaleShift(pep->st,sinv?pep->sfactor:1.0/pep->sfactor);

482:   /* Restart loop */
483:   l = 0;
484:   DSGetLeadingDimension(pep->ds,&ldds);
485:   while (pep->reason == PEP_CONVERGED_ITERATING) {
486:     pep->its++;
487:     DSGetArrayReal(pep->ds,DS_MAT_T,&a);
488:     b = a+ldds;
489:     DSGetArrayReal(pep->ds,DS_MAT_D,&omega);

491:     /* Compute an nv-step Lanczos factorization */
492:     nv = PetscMin(pep->nconv+pep->mpd,pep->ncv);
493:     PEPSTOARrun(pep,a,b,omega,pep->nconv+l,&nv,&breakdown,&symmlost,work+nwu,pep->work);
494:     beta = b[nv-1];
495:     if (symmlost) {
496:       pep->reason = PEP_DIVERGED_SYMMETRY_LOST;
497:       if (nv==pep->nconv+l+1) { pep->nconv = nconv; break; }
498:     }
499:     DSRestoreArrayReal(pep->ds,DS_MAT_T,&a);
500:     DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);
501:     DSSetDimensions(pep->ds,nv,0,pep->nconv,pep->nconv+l);
502:     if (l==0) {
503:       DSSetState(pep->ds,DS_STATE_INTERMEDIATE);
504:     } else {
505:       DSSetState(pep->ds,DS_STATE_RAW);
506:     }

508:     /* Solve projected problem */
509:     DSSolve(pep->ds,pep->eigr,pep->eigi);
510:     DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);

512:     /* Check convergence */
513:     /* PEPSTOARpreKConvergence(pep,nv,&norm,pep->work);*/
514:     norm = 1.0;
515:     DSGetDimensions(pep->ds,NULL,NULL,NULL,NULL,&t);
516:     PEPKrylovConvergence(pep,PETSC_FALSE,pep->nconv,t-pep->nconv,PetscAbsReal(beta)*norm,&k);
517:     nconv = k;
518:     (*pep->stopping)(pep,pep->its,pep->max_it,k,pep->nev,&pep->reason,pep->stoppingctx);

520:     /* Update l */
521:     if (pep->reason != PEP_CONVERGED_ITERATING || breakdown) l = 0;
522:     else {
523:       l = PetscMax(1,(PetscInt)((nv-k)/2));
524:       l = PetscMin(l,t);
525:       DSGetArrayReal(pep->ds,DS_MAT_T,&a);
526:       if (*(a+ldds+k+l-1)!=0) {
527:         if (k+l<nv-1) l = l+1;
528:         else l = l-1;
529:       }
530:       DSRestoreArrayReal(pep->ds,DS_MAT_T,&a);
531:     }
532:     if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */

534:     /* Update S */
535:     off = pep->nconv*ldds;
536:     DSGetArray(pep->ds,DS_MAT_Q,&Q);
537:     PEPSTOARSupdate(S,ld,nv+2,pep->nconv,k+l-pep->nconv,nv,Q+off,ldds,work+nwu);
538:     DSRestoreArray(pep->ds,DS_MAT_Q,&Q);

540:     /* Copy last column of S */
541:     PetscMemcpy(S+lds*(k+l),S+lds*nv,lds*sizeof(PetscScalar));

543:     if (pep->reason == PEP_CONVERGED_ITERATING) {
544:       if (breakdown) {
545:         /* Stop if breakdown */
546:         PetscInfo2(pep,"Breakdown STOAR method (it=%D norm=%g)\n",pep->its,(double)beta);
547:         pep->reason = PEP_DIVERGED_BREAKDOWN;
548:       } else {
549:         /* Prepare the Rayleigh quotient for restart */
550:         DSGetArray(pep->ds,DS_MAT_Q,&Q);
551:         DSGetArrayReal(pep->ds,DS_MAT_T,&a);
552:         DSGetArrayReal(pep->ds,DS_MAT_D,&omega);
553:         r = a + 2*ldds;
554:         for (j=k;j<k+l;j++) {
555:           r[j] = PetscRealPart(Q[nv-1+j*ldds]*beta);
556:         }
557:         b = a+ldds;
558:         b[k+l-1] = r[k+l-1];
559:         omega[k+l] = omega[nv];
560:         DSRestoreArray(pep->ds,DS_MAT_Q,&Q);
561:         DSRestoreArrayReal(pep->ds,DS_MAT_T,&a);
562:         DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);
563:         /* Truncate S */
564:         DSGetArrayReal(pep->ds,DS_MAT_D,&omega);
565:         PEPSTOARTrunc(pep,nv+2,k+l+1,work+nwu,rwork+nrwu);
566:         DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);
567:       }
568:     }


571:     pep->nconv = k;
572:     PEPMonitor(pep,pep->its,pep->nconv,pep->eigr,pep->eigi,pep->errest,nv);
573:   }

575:   if (pep->nconv>0) {
576:     /* Truncate S */
577:     DSGetArrayReal(pep->ds,DS_MAT_D,&omega);
578:     PEPSTOARTrunc(pep,nv+2,pep->nconv,work+nwu,rwork+nrwu);
579:     DSRestoreArrayReal(pep->ds,DS_MAT_D,&omega);

581:     /* Extraction */
582:     DSSetDimensions(pep->ds,pep->nconv,0,0,0);
583:     DSSetState(pep->ds,DS_STATE_RAW);

585:     for (j=0;j<pep->nconv;j++) {
586:       pep->eigr[j] *= pep->sfactor;
587:       pep->eigi[j] *= pep->sfactor;
588:     }
589:   }
590:   STScaleShift(pep->st,sinv?1.0/pep->sfactor:pep->sfactor);
591:   RGPopScale(pep->rg);

593:   /* truncate Schur decomposition and change the state to raw so that
594:      DSVectors() computes eigenvectors from scratch */
595:   DSSetDimensions(pep->ds,pep->nconv,0,0,0);
596:   DSSetState(pep->ds,DS_STATE_RAW);
597:   PetscFree2(work,rwork);
598:   return(0);
599: }

603: PetscErrorCode PEPSetFromOptions_STOAR(PetscOptionItems *PetscOptionsObject,PEP pep)
604: {
606:   PetscBool      flg,lock;

609:   PetscOptionsHead(PetscOptionsObject,"PEP STOAR Options");
610:   PetscOptionsBool("-pep_stoar_locking","Choose between locking and non-locking variants","PEPSTOARSetLocking",PETSC_FALSE,&lock,&flg);
611:   if (flg) {
612:     PEPSTOARSetLocking(pep,lock);
613:   }
614:   PetscOptionsTail();
615:   return(0);
616: }

620: static PetscErrorCode PEPSTOARSetLocking_STOAR(PEP pep,PetscBool lock)
621: {
622:   PEP_TOAR *ctx = (PEP_TOAR*)pep->data;

625:   ctx->lock = lock;
626:   return(0);
627: }

631: /*@
632:    PEPSTOARSetLocking - Choose between locking and non-locking variants of
633:    the STOAR method.

635:    Logically Collective on PEP

637:    Input Parameters:
638: +  pep  - the eigenproblem solver context
639: -  lock - true if the locking variant must be selected

641:    Options Database Key:
642: .  -pep_stoar_locking - Sets the locking flag

644:    Notes:
645:    The default is to lock converged eigenpairs when the method restarts.
646:    This behaviour can be changed so that all directions are kept in the
647:    working subspace even if already converged to working accuracy (the
648:    non-locking variant).

650:    Level: advanced

652: .seealso: PEPSTOARGetLocking()
653: @*/
654: PetscErrorCode PEPSTOARSetLocking(PEP pep,PetscBool lock)
655: {

661:   PetscTryMethod(pep,"PEPSTOARSetLocking_C",(PEP,PetscBool),(pep,lock));
662:   return(0);
663: }

667: static PetscErrorCode PEPSTOARGetLocking_STOAR(PEP pep,PetscBool *lock)
668: {
669:   PEP_TOAR *ctx = (PEP_TOAR*)pep->data;

672:   *lock = ctx->lock;
673:   return(0);
674: }

678: /*@
679:    PEPSTOARGetLocking - Gets the locking flag used in the STOAR method.

681:    Not Collective

683:    Input Parameter:
684: .  pep - the eigenproblem solver context

686:    Output Parameter:
687: .  lock - the locking flag

689:    Level: advanced

691: .seealso: PEPSTOARSetLocking()
692: @*/
693: PetscErrorCode PEPSTOARGetLocking(PEP pep,PetscBool *lock)
694: {

700:   PetscUseMethod(pep,"PEPSTOARGetLocking_C",(PEP,PetscBool*),(pep,lock));
701:   return(0);
702: }

706: PetscErrorCode PEPView_STOAR(PEP pep,PetscViewer viewer)
707: {
709:   PEP_TOAR      *ctx = (PEP_TOAR*)pep->data;
710:   PetscBool      isascii;

713:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
714:   if (isascii) {
715:     PetscViewerASCIIPrintf(viewer,"  STOAR: using the %slocking variant\n",ctx->lock?"":"non-");
716:   }
717:   return(0);
718: }

722: PetscErrorCode PEPDestroy_STOAR(PEP pep)
723: {

727:   PetscFree(pep->data);
728:   PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARSetLocking_C",NULL);
729:   PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARGetLocking_C",NULL);
730:   return(0);
731: }

735: PETSC_EXTERN PetscErrorCode PEPCreate_STOAR(PEP pep)
736: {
738:   PEP_TOAR      *ctx;

741:   PetscNewLog(pep,&ctx);
742:   pep->data = (void*)ctx;
743:   ctx->lock = PETSC_TRUE;

745:   pep->ops->solve          = PEPSolve_STOAR;
746:   pep->ops->setup          = PEPSetUp_STOAR;
747:   pep->ops->setfromoptions = PEPSetFromOptions_STOAR;
748:   pep->ops->view           = PEPView_STOAR;
749:   pep->ops->destroy        = PEPDestroy_STOAR;
750:   pep->ops->backtransform  = PEPBackTransform_Default;
751:   pep->ops->computevectors = PEPComputeVectors_Default;
752:   pep->ops->extractvectors = PEPExtractVectors_TOAR;
753:   pep->ops->reset          = PEPReset_TOAR;
754:   PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARSetLocking_C",PEPSTOARSetLocking_STOAR);
755:   PetscObjectComposeFunction((PetscObject)pep,"PEPSTOARGetLocking_C",PEPSTOARGetLocking_STOAR);
756:   return(0);
757: }

slepc-3.7.4/src/pep/impls/krylov/stoar/makefile.html0000644000175000017500000000470113107004621022005 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = stoar.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcpep
DIRS     =
MANSEC   = PEP
LOCDIR   = src/pep/impls/krylov/stoar/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/pep/impls/krylov/stoar/index.html0000644000175000017500000000307113107004621021336 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

stoar.c
makefile
slepc-3.7.4/src/pep/impls/krylov/stoar/ftn-auto/0000755000175000017500000000000013107004621021075 5ustar jromanjromanslepc-3.7.4/src/pep/impls/krylov/stoar/ftn-auto/makefile0000644000175000017500000000036613107004621022602 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = stoarf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcpep LOCDIR = src/pep/impls/krylov/stoar/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/krylov/stoar/ftn-auto/stoarf.c0000644000175000017500000000271613107004621022545 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* stoar.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepstoarsetlocking_ PEPSTOARSETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepstoarsetlocking_ pepstoarsetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepstoargetlocking_ PEPSTOARGETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepstoargetlocking_ pepstoargetlocking #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepstoarsetlocking_(PEP pep,PetscBool *lock, int *__ierr ){ *__ierr = PEPSTOARSetLocking( (PEP)PetscToPointer((pep) ),*lock); } PETSC_EXTERN void PETSC_STDCALL pepstoargetlocking_(PEP pep,PetscBool *lock, int *__ierr ){ *__ierr = PEPSTOARGetLocking( (PEP)PetscToPointer((pep) ),lock); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/impls/krylov/makefile.html0000644000175000017500000000472213107004621020660 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = pepkrylov.c
SOURCEF  =
SOURCEH  = pepkrylov.h
LIBBASE  = libslepcpep
DIRS     = qarnoldi toar stoar
LOCDIR   = src/pep/impls/krylov/
MANSEC   = PEP

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common

slepc-3.7.4/src/pep/impls/krylov/pepkrylov.h.html0000644000175000017500000000765513107004621021374 0ustar jromanjroman
Actual source code: pepkrylov.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private header for TOAR and STOAR.

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

  8:    This file is part of SLEPc.

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

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

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


 27: typedef struct {
 28:   PetscReal   keep;         /* restart parameter */
 29:   PetscBool   lock;         /* locking/non-locking variant */
 30:   PetscReal   dtol;         /* tolerance for deflation */
 31:   PetscInt    d;            /* polynomial degree */
 32:   PetscInt    ld;           /* leading dimension of auxiliary matrices */
 33:   PetscInt    nq;           /* number of TOAR Vectors  */
 34:   PetscScalar *S,*qB;       /* auxiliary matrices */
 35: } PEP_TOAR;

 37: #endif


 40: PETSC_INTERN PetscErrorCode PEPExtractVectors_TOAR(PEP);
 41: PETSC_INTERN PetscErrorCode PEPReset_TOAR(PEP);

slepc-3.7.4/src/pep/impls/krylov/toar/0000755000175000017500000000000013107004621017155 5ustar jromanjromanslepc-3.7.4/src/pep/impls/krylov/toar/makefile0000644000175000017500000000217413107004621020661 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = ptoar.c nrefine.c SOURCEF = SOURCEH = LIBBASE = libslepcpep DIRS = MANSEC = PEP LOCDIR = src/pep/impls/krylov/toar/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/krylov/toar/ptoar.c.html0000644000175000017500000026542413107004621021426 0ustar jromanjroman
Actual source code: ptoar.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc polynomial eigensolver: "toar"

  5:    Method: TOAR

  7:    Algorithm:

  9:        Two-Level Orthogonal Arnoldi.

 11:    References:

 13:        [1] Y. Su, J. Zhang and Z. Bai, "A compact Arnoldi algorithm for
 14:            polynomial eigenvalue problems", talk presented at RANMEP 2008.

 16:        [2] C. Campos and J.E. Roman, "Parallel Krylov solvers for the
 17:            polynomial eigenvalue problem in SLEPc", SIAM J. Sci. Comput.
 18:            to appear, 2016.

 20:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 21:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 22:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 24:    This file is part of SLEPc.

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

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

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

 40: #include <slepc/private/pepimpl.h>    /*I "slepcpep.h" I*/
 41:  #include ../src/pep/impls/krylov/pepkrylov.h
 42: #include <slepcblaslapack.h>

 44: static PetscBool  cited = PETSC_FALSE;
 45: static const char citation[] =
 46:   "@Article{slepc-pep,\n"
 47:   "   author = \"C. Campos and J. E. Roman\",\n"
 48:   "   title = \"Parallel {Krylov} solvers for the polynomial eigenvalue problem in {SLEPc}\",\n"
 49:   "   journal = \"{SIAM} J. Sci. Comput.\",\n"
 50:   "   volume = \"to appear\",\n"
 51:   "   number = \"\",\n"
 52:   "   pages = \"\",\n"
 53:   "   year = \"2016,\"\n"
 54:   "   doi = \"http://dx.doi.org/10.xxxx/yyyy\"\n"
 55:   "}\n";

 59: /*
 60:   Norm of [sp;sq]
 61: */
 62: static PetscErrorCode PEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm)
 63: {
 65:   PetscBLASInt   n_,one=1;

 68:   PetscBLASIntCast(n,&n_);
 69:   *norm = BLASnrm2_(&n_,S,&one);
 70:   return(0);
 71: }

 75: PetscErrorCode PEPSetUp_TOAR(PEP pep)
 76: {
 78:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
 79:   PetscBool      shift,sinv,flg,lindep;
 80:   PetscInt       i,lds,deg=pep->nmat-1,j;
 81:   PetscReal      norm;

 84:   pep->lineariz = PETSC_TRUE;
 85:   PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);
 86:   if (!ctx->lock && pep->mpd<pep->ncv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant");
 87:   if (!pep->max_it) pep->max_it = PetscMax(100,2*(pep->nmat-1)*pep->n/pep->ncv);
 88:   /* Set STSHIFT as the default ST */
 89:   if (!((PetscObject)pep->st)->type_name) {
 90:     STSetType(pep->st,STSHIFT);
 91:   }
 92:   PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);
 93:   PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);
 94:   if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used");
 95:   if (!pep->which) {
 96:     if (sinv) pep->which = PEP_TARGET_MAGNITUDE;
 97:     else pep->which = PEP_LARGEST_MAGNITUDE;
 98:   }
 99:   if (pep->problem_type!=PEP_GENERAL) {
100:     PetscInfo(pep,"Problem type ignored, performing a non-symmetric linearization\n");
101:   }

103:   if (!ctx->keep) ctx->keep = 0.5;

105:   PEPAllocateSolution(pep,pep->nmat-1);
106:   PEPSetWorkVecs(pep,3);
107:   DSSetType(pep->ds,DSNHEP);
108:   DSSetExtraRow(pep->ds,PETSC_TRUE);
109:   DSAllocate(pep->ds,pep->ncv+1);

111:   PEPBasisCoefficients(pep,pep->pbc);
112:   STGetTransform(pep->st,&flg);
113:   if (!flg) {
114:     PetscMalloc1(pep->nmat,&pep->solvematcoeffs);
115:     if (sinv) {
116:       PEPEvaluateBasis(pep,pep->target,0,pep->solvematcoeffs,NULL);
117:     } else {
118:       for (i=0;i<pep->nmat-1;i++) pep->solvematcoeffs[i] = 0.0;
119:       pep->solvematcoeffs[pep->nmat-1] = 1.0;
120:     }
121:   }
122:   ctx->ld = pep->ncv+(pep->nmat-1);   /* number of rows of each fragment of S */
123:   lds = (pep->nmat-1)*ctx->ld;
124:   PetscCalloc1(lds*ctx->ld,&ctx->S);

126:   /* process starting vector */
127:   ctx->nq = 0;
128:   for (i=0;i<deg;i++) {
129:     if (pep->nini>-deg) {
130:       BVSetRandomColumn(pep->V,ctx->nq);
131:     } else {
132:       BVInsertVec(pep->V,ctx->nq,pep->IS[i]);
133:     }
134:     BVOrthogonalizeColumn(pep->V,ctx->nq,ctx->S+i*ctx->ld,&norm,&lindep);
135:     if (!lindep) {
136:       BVScaleColumn(pep->V,ctx->nq,1.0/norm);
137:       ctx->S[ctx->nq+i*ctx->ld] = norm;
138:       ctx->nq++;
139:     }
140:   }
141:   if (ctx->nq==0) SETERRQ(PetscObjectComm((PetscObject)pep),1,"PEP: Problem with initial vector");
142:   PEPTOARSNorm2(lds,ctx->S,&norm);
143:   for (j=0;j<deg;j++) {
144:     for (i=0;i<=j;i++) ctx->S[i+j*ctx->ld] /= norm;
145:   }
146:   if (pep->nini<0) {
147:     SlepcBasisDestroy_Private(&pep->nini,&pep->IS);
148:   }
149:   return(0);
150: }

154: /*
155:  Computes GS orthogonalization   [z;x] - [Sp;Sq]*y,
156:  where y = ([Sp;Sq]'*[z;x]).
157:    k: Column from S to be orthogonalized against previous columns.
158:    Sq = Sp+ld
159:    dim(work)>=k
160: */
161: static PetscErrorCode PEPTOAROrth2(PEP pep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work)
162: {
164:   PetscBLASInt   n_,lds_,k_,one=1;
165:   PetscScalar    sonem=-1.0,sone=1.0,szero=0.0,*x0,*x,*c;
166:   PetscInt       i,lds=deg*ld,n;
167:   PetscReal      eta,onorm;

170:   BVGetOrthogonalization(pep->V,NULL,NULL,&eta,NULL);
171:   n = k+deg-1;
172:   PetscBLASIntCast(n,&n_);
173:   PetscBLASIntCast(deg*ld,&lds_);
174:   PetscBLASIntCast(k,&k_); /* number of vectors to orthogonalize against them */
175:   c = work;
176:   x0 = S+k*lds;
177:   PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S,&lds_,x0,&one,&szero,y,&one));
178:   for (i=1;i<deg;i++) {
179:     x = S+i*ld+k*lds;
180:     PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+i*ld,&lds_,x,&one,&sone,y,&one));
181:   }
182:   for (i=0;i<deg;i++) {
183:     x= S+i*ld+k*lds;
184:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S+i*ld,&lds_,y,&one,&sone,x,&one));
185:   }
186:   PEPTOARSNorm2(lds,S+k*lds,&onorm);
187:   /* twice */
188:   PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S,&lds_,x0,&one,&szero,c,&one));
189:   for (i=1;i<deg;i++) {
190:     x = S+i*ld+k*lds;
191:     PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S+i*ld,&lds_,x,&one,&sone,c,&one));
192:   }
193:   for (i=0;i<deg;i++) {
194:     x= S+i*ld+k*lds;
195:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&n_,&k_,&sonem,S+i*ld,&lds_,c,&one,&sone,x,&one));
196:   }
197:   for (i=0;i<k;i++) y[i] += c[i];
198:   if (norm) {
199:     PEPTOARSNorm2(lds,S+k*lds,norm);
200:     if (lindep) *lindep = (*norm < eta * onorm)?PETSC_TRUE:PETSC_FALSE;
201:   }
202:   return(0);
203: }

207: /*
208:   Extend the TOAR basis by applying the the matrix operator
209:   over a vector which is decomposed in the TOAR way
210:   Input:
211:     - pbc: array containing the polynomial basis coefficients
212:     - S,V: define the latest Arnoldi vector (nv vectors in V)
213:   Output:
214:     - t: new vector extending the TOAR basis
215:     - r: temporary coefficients to compute the TOAR coefficients
216:          for the new Arnoldi vector
217:   Workspace: t_ (two vectors)
218: */
219: static PetscErrorCode PEPTOARExtendBasis(PEP pep,PetscBool sinvert,PetscScalar sigma,PetscScalar *S,PetscInt ls,PetscInt nv,BV V,Vec t,PetscScalar *r,PetscInt lr,Vec *t_)
220: {
222:   PetscInt       nmat=pep->nmat,deg=nmat-1,k,j,off=0,lss;
223:   Vec            v=t_[0],ve=t_[1],q=t_[2];
224:   PetscScalar    alpha=1.0,*ss,a;
225:   PetscReal      *ca=pep->pbc,*cb=pep->pbc+nmat,*cg=pep->pbc+2*nmat;
226:   PetscBool      flg;

229:   BVSetActiveColumns(pep->V,0,nv);
230:   STGetTransform(pep->st,&flg);
231:   if (sinvert) {
232:     for (j=0;j<nv;j++) {
233:       if (deg>1) r[lr+j] = S[j]/ca[0];
234:       if (deg>2) r[2*lr+j] = (S[ls+j]+(sigma-cb[1])*r[lr+j])/ca[1];
235:     }
236:     for (k=2;k<deg-1;k++) {
237:       for (j=0;j<nv;j++) r[(k+1)*lr+j] = (S[k*ls+j]+(sigma-cb[k])*r[k*lr+j]-cg[k]*r[(k-1)*lr+j])/ca[k];
238:     }
239:     k = deg-1;
240:     for (j=0;j<nv;j++) r[j] = (S[k*ls+j]+(sigma-cb[k])*r[k*lr+j]-cg[k]*r[(k-1)*lr+j])/ca[k];
241:     ss = r; lss = lr; off = 1; alpha = -1.0; a = pep->sfactor;
242:   } else {
243:     ss = S; lss = ls; off = 0; alpha = -ca[deg-1]; a = 1.0;
244:   }
245:   BVMultVec(V,1.0,0.0,v,ss+off*lss);
246:   if (pep->Dr) { /* balancing */
247:     VecPointwiseMult(v,v,pep->Dr);
248:   }
249:   STMatMult(pep->st,off,v,q);
250:   VecScale(q,a);
251:   for (j=1+off;j<deg+off-1;j++) {
252:     BVMultVec(V,1.0,0.0,v,ss+j*lss);
253:     if (pep->Dr) {
254:       VecPointwiseMult(v,v,pep->Dr);
255:     }
256:     STMatMult(pep->st,j,v,t);
257:     a *= pep->sfactor;
258:     VecAXPY(q,a,t);
259:   }
260:   if (sinvert) {
261:     BVMultVec(V,1.0,0.0,v,ss);
262:     if (pep->Dr) {
263:       VecPointwiseMult(v,v,pep->Dr);
264:     }
265:     STMatMult(pep->st,deg,v,t);
266:     a *= pep->sfactor;
267:     VecAXPY(q,a,t);
268:   } else {
269:     BVMultVec(V,1.0,0.0,ve,ss+(deg-1)*lss);
270:     if (pep->Dr) {
271:       VecPointwiseMult(ve,ve,pep->Dr);
272:     }
273:     a *= pep->sfactor;
274:     STMatMult(pep->st,deg-1,ve,t);
275:     VecAXPY(q,a,t);
276:     a *= pep->sfactor;
277:   }
278:   if (flg || !sinvert) alpha /= a;
279:   STMatSolve(pep->st,q,t);
280:   VecScale(t,alpha);
281:   if (!sinvert) {
282:     if (cg[deg-1]!=0) { VecAXPY(t,cg[deg-1],v); }
283:     if (cb[deg-1]!=0) { VecAXPY(t,cb[deg-1],ve); }
284:   }
285:   if (pep->Dr) {
286:     VecPointwiseDivide(t,t,pep->Dr);
287:   }
288:   return(0);
289: }

293: /*
294:   Compute TOAR coefficients of the blocks of the new Arnoldi vector computed
295: */
296: static PetscErrorCode PEPTOARCoefficients(PEP pep,PetscBool sinvert,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x)
297: {
298:   PetscInt    k,j,nmat=pep->nmat,d=nmat-1;
299:   PetscReal   *ca=pep->pbc,*cb=pep->pbc+nmat,*cg=pep->pbc+2*nmat;
300:   PetscScalar t=1.0,tp=0.0,tt;

303:   if (sinvert) {
304:     for (k=1;k<d;k++) {
305:       tt = t;
306:       t = ((sigma-cb[k-1])*t-cg[k-1]*tp)/ca[k-1]; /* k-th basis polynomial */
307:       tp = tt;
308:       for (j=0;j<=nv;j++) r[k*lr+j] += t*x[j];
309:     }
310:   } else {
311:     for (j=0;j<=nv;j++) r[j] = (cb[0]-sigma)*S[j]+ca[0]*S[ls+j];
312:     for (k=1;k<d-1;k++) {
313:       for (j=0;j<=nv;j++) r[k*lr+j] = (cb[k]-sigma)*S[k*ls+j]+ca[k]*S[(k+1)*ls+j]+cg[k]*S[(k-1)*ls+j];
314:     }
315:     if (sigma!=0.0) for (j=0;j<=nv;j++) r[(d-1)*lr+j] -= sigma*S[(d-1)*ls+j];
316:   }
317:   return(0);
318: }

322: /*
323:   Compute a run of Arnoldi iterations dim(work)=ld
324: */
325: static PetscErrorCode PEPTOARrun(PEP pep,PetscScalar sigma,PetscInt *nq,PetscScalar *S,PetscInt ld,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscScalar *work,Vec *t_)
326: {
328:   PetscInt       i,j,p,m=*M,nwu=0,deg=pep->nmat-1;
329:   PetscInt       lds=ld*deg,nqt=*nq;
330:   Vec            t;
331:   PetscReal      norm;
332:   PetscBool      flg,sinvert=PETSC_FALSE,lindep;
333:   PetscScalar    *x;

336:   STGetTransform(pep->st,&flg);
337:   if (!flg) {
338:     /* spectral transformation handled by the solver */
339:     PetscObjectTypeCompareAny((PetscObject)pep->st,&flg,STSINVERT,STSHIFT,"");
340:     if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"STtype not supported fr TOAR without transforming matrices");
341:     PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinvert);
342:   }
343:   for (j=k;j<m;j++) {
344:     /* apply operator */
345:     BVGetColumn(pep->V,nqt,&t);
346:     PEPTOARExtendBasis(pep,sinvert,sigma,S+j*lds,ld,nqt,pep->V,t,S+(j+1)*lds,ld,t_);
347:     BVRestoreColumn(pep->V,nqt,&t);

349:     /* orthogonalize */
350:     if (sinvert) x = S+(j+1)*lds;
351:     else x = S+(deg-1)*ld+(j+1)*lds;
352:     BVOrthogonalizeColumn(pep->V,nqt,x,&norm,&lindep);
353:     if (!lindep) {
354:       x[nqt] = norm;
355:       BVScaleColumn(pep->V,nqt,1.0/norm);
356:       nqt++;
357:     }

359:     PEPTOARCoefficients(pep,sinvert,sigma,nqt-1,S+j*lds,ld,S+(j+1)*lds,ld,x);
360:     /* level-2 orthogonalization */
361:     PEPTOAROrth2(pep,S,ld,deg,j+1,H+j*ldh,&norm,breakdown,work+nwu);
362:     H[j+1+ldh*j] = norm;
363:     *nq = nqt;
364:     if (*breakdown) {
365:       *M = j+1;
366:       break;
367:     }
368:     for (p=0;p<deg;p++) {
369:       for (i=0;i<=j+deg;i++) {
370:         S[i+p*ld+(j+1)*lds] /= norm;
371:       }
372:     }
373:   }
374:   return(0);
375: }

379: /*
380:   dim(rwork)=6*n; dim(work)=6*ld*lds+2*cs1
381: */
382: static PetscErrorCode PEPTOARTrunc(PEP pep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt *rs1a,PetscInt cs1,PetscInt lock,PetscInt newc,PetscBool final,PetscScalar *work,PetscReal *rwork)
383: {
384: #if defined(PETSC_MISSING_LAPACK_GESVD) || defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR)
386:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESVD/GEQRF/ORGQR - Lapack routine is unavailable");
387: #else
389:   PetscInt       nwu=0,nrwu=0,nnc,nrow,lwa;
390:   PetscInt       j,i,k,n,lds=deg*ld,rs1=*rs1a,rk=0,offu;
391:   PetscScalar    *M,*V,*pU,*SS,*SS2,t,sone=1.0,zero=0.0,mone=-1.0,*p,*tau;
392:   PetscReal      *sg,tol;
393:   PetscBLASInt   cs1_,rs1_,cs1tdeg,n_,info,lw_,newc_,newctdeg,nnc_,nrow_,nnctdeg,lds_,rk_;
394:   Mat            U;

397:   if (cs1==0) return(0);
398:   lwa = 6*ld*lds+2*cs1;
399:   n = (rs1>deg*cs1)?deg*cs1:rs1;
400:   nnc = cs1-lock-newc;
401:   nrow = rs1-lock;
402:   PetscMalloc4(deg*newc*nnc,&SS,newc*nnc,&SS2,(rs1+lock+newc)*n,&pU,deg*rs1,&tau);
403:   offu = lock*(rs1+1);
404:   M = work+nwu;
405:   nwu += rs1*cs1*deg;
406:   sg = rwork+nrwu;
407:   nrwu += n;
408:   PetscMemzero(pU,rs1*n*sizeof(PetscScalar));
409:   V = work+nwu;
410:   nwu += deg*cs1*n;
411:   PetscBLASIntCast(n,&n_);
412:   PetscBLASIntCast(nnc,&nnc_);
413:   PetscBLASIntCast(cs1,&cs1_);
414:   PetscBLASIntCast(rs1,&rs1_);
415:   PetscBLASIntCast(newc,&newc_);
416:   PetscBLASIntCast(newc*deg,&newctdeg);
417:   PetscBLASIntCast(nnc*deg,&nnctdeg);
418:   PetscBLASIntCast(cs1*deg,&cs1tdeg);
419:   PetscBLASIntCast(lwa-nwu,&lw_);
420:   PetscBLASIntCast(nrow,&nrow_);
421:   PetscBLASIntCast(lds,&lds_);
422:   if (newc>0) {
423:   /* truncate columns associated with new converged eigenpairs */
424:     for (j=0;j<deg;j++) {
425:       for (i=lock;i<lock+newc;i++) {
426:         PetscMemcpy(M+(i-lock+j*newc)*nrow,S+i*lds+j*ld+lock,nrow*sizeof(PetscScalar));
427:       }
428:     }
429: #if !defined (PETSC_USE_COMPLEX)
430:     PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&nrow_,&newctdeg,M,&nrow_,sg,pU+offu,&rs1_,V,&n_,work+nwu,&lw_,&info));
431: #else
432:     PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&nrow_,&newctdeg,M,&nrow_,sg,pU+offu,&rs1_,V,&n_,work+nwu,&lw_,rwork+nrwu,&info));
433: #endif
434:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);
435:     /* SVD has rank min(newc,nrow) */
436:     rk = PetscMin(newc,nrow);
437:     for (i=0;i<rk;i++) {
438:       t = sg[i];
439:       PetscStackCallBLAS("BLASscal",BLASscal_(&newctdeg,&t,V+i,&n_));
440:     }
441:     for (i=0;i<deg;i++) {
442:       for (j=lock;j<lock+newc;j++) {
443:         PetscMemcpy(S+j*lds+i*ld+lock,V+(newc*i+j-lock)*n,rk*sizeof(PetscScalar));
444:         PetscMemzero(S+j*lds+i*ld+lock+rk,(ld-lock-rk)*sizeof(PetscScalar));
445:       }
446:     }
447:     /*
448:       update columns associated with non-converged vectors, orthogonalize
449:        against pU so that next M has rank nnc+d-1 insted of nrow+d-1
450:     */
451:     for (i=0;i<deg;i++) {
452:       PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&newc_,&nnc_,&nrow_,&sone,pU+offu,&rs1_,S+(lock+newc)*lds+i*ld+lock,&lds_,&zero,SS+i*newc*nnc,&newc_));
453:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&nrow_,&nnc_,&newc_,&mone,pU+offu,&rs1_,SS+i*newc*nnc,&newc_,&sone,S+(lock+newc)*lds+i*ld+lock,&lds_));
454:       /* repeat orthogonalization step */
455:       PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&newc_,&nnc_,&nrow_,&sone,pU+offu,&rs1_,S+(lock+newc)*lds+i*ld+lock,&lds_,&zero,SS2,&newc_));
456:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&nrow_,&nnc_,&newc_,&mone,pU+offu,&rs1_,SS2,&newc_,&sone,S+(lock+newc)*lds+i*ld+lock,&lds_));
457:       for (j=0;j<newc*nnc;j++) *(SS+i*newc*nnc+j) += SS2[j];
458:     }
459:   }
460:   /* truncate columns associated with non-converged eigenpairs */
461:   for (j=0;j<deg;j++) {
462:     for (i=lock+newc;i<cs1;i++) {
463:       PetscMemcpy(M+(i-lock-newc+j*nnc)*nrow,S+i*lds+j*ld+lock,nrow*sizeof(PetscScalar));
464:     }
465:   }
466: #if !defined (PETSC_USE_COMPLEX)
467:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&nrow_,&nnctdeg,M,&nrow_,sg,pU+offu+newc*rs1,&rs1_,V,&n_,work+nwu,&lw_,&info));
468: #else
469:   PetscStackCallBLAS("LAPACKgesvd",LAPACKgesvd_("S","S",&nrow_,&nnctdeg,M,&nrow_,sg,pU+offu+newc*rs1,&rs1_,V,&n_,work+nwu,&lw_,rwork+nrwu,&info));
470: #endif
471:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESVD %d",info);
472:   tol = PetscMax(rs1,deg*cs1)*PETSC_MACHINE_EPSILON*sg[0];
473:   for (i=0;i<PetscMin(n_,nnctdeg);i++) if (sg[i]>tol) rk++;
474:   rk = PetscMin(nnc+deg-1,rk);
475:   /* the SVD has rank (atmost) nnc+deg-1 */
476:   for (i=0;i<rk;i++) {
477:     t = sg[i];
478:     PetscStackCallBLAS("BLASscal",BLASscal_(&nnctdeg,&t,V+i,&n_));
479:   }
480:   /* update S */
481:   PetscMemzero(S+cs1*lds,(ld-cs1)*lds*sizeof(PetscScalar));
482:   k = ld-lock-newc-rk;
483:   for (i=0;i<deg;i++) {
484:     for (j=lock+newc;j<cs1;j++) {
485:       PetscMemcpy(S+j*lds+i*ld+lock+newc,V+(nnc*i+j-lock-newc)*n,rk*sizeof(PetscScalar));
486:       PetscMemzero(S+j*lds+i*ld+lock+newc+rk,k*sizeof(PetscScalar));
487:     }
488:   }
489:   if (newc>0) {
490:     for (i=0;i<deg;i++) {
491:       p = SS+nnc*newc*i;
492:       for (j=lock+newc;j<cs1;j++) {
493:         for (k=0;k<newc;k++) S[j*lds+i*ld+lock+k] = *(p++);
494:       }
495:     }
496:   }

498:   /* orthogonalize pU */
499:   rk = rk+newc;
500:   PetscBLASIntCast(rk,&rk_);
501:   PetscBLASIntCast(cs1-lock,&nnc_);
502:   PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&nrow_,&rk_,pU+offu,&rs1_,tau,work+nwu,&lw_,&info));
503:   for (i=0;i<deg;i++) {
504:     PetscStackCallBLAS("BLAStrmm",BLAStrmm_("L","U","N","N",&rk_,&nnc_,&sone,pU+offu,&rs1_,S+lock*lds+lock+i*ld,&lds_));
505:   }
506:   PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&nrow_,&rk_,&rk_,pU+offu,&rs1_,tau,work+nwu,&lw_,&info));

508:   /* update vectors V(:,idx) = V*Q(:,idx) */
509:   rk = rk+lock;
510:   for (i=0;i<lock;i++) pU[(i+1)*rs1] = 1.0;
511:   MatCreateSeqDense(PETSC_COMM_SELF,rs1,rk,pU,&U);
512:   BVSetActiveColumns(pep->V,lock,rs1);
513:   BVMultInPlace(pep->V,U,lock,rk);
514:   BVSetActiveColumns(pep->V,0,rk);
515:   MatDestroy(&U);
516:   *rs1a = rk;

518:   /* free work space */
519:   PetscFree4(SS,SS2,pU,tau);
520:   return(0);
521: #endif
522: }

526: /*
527:   S <- S*Q
528:   columns s-s+ncu of S
529:   rows 0-sr of S
530:   size(Q) qr x ncu
531:   dim(work)=sr*ncu
532: */
533: static PetscErrorCode PEPTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)
534: {
536:   PetscScalar    a=1.0,b=0.0;
537:   PetscBLASInt   sr_,ncu_,ldq_,lds_,qr_;
538:   PetscInt       j,lds=deg*ld,i;

541:   PetscBLASIntCast(sr,&sr_);
542:   PetscBLASIntCast(qr,&qr_);
543:   PetscBLASIntCast(ncu,&ncu_);
544:   PetscBLASIntCast(lds,&lds_);
545:   PetscBLASIntCast(ldq,&ldq_);
546:   for (i=0;i<deg;i++) {
547:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&sr_,&ncu_,&qr_,&a,S+i*ld,&lds_,Q,&ldq_,&b,work,&sr_));
548:     for (j=0;j<ncu;j++) {
549:       PetscMemcpy(S+lds*(s+j)+i*ld,work+j*sr,sr*sizeof(PetscScalar));
550:     }
551:   }
552:   return(0);
553: }

557: /*
558:   Computes T_j = phi_idx(T). In T_j and T_p are phi_{idx-1}(T)
559:    and phi_{idx-2}(T) respectively or null if idx=0,1.
560:    Tp and Tj are input/output arguments
561: */
562: static PetscErrorCode PEPEvaluateBasisM(PEP pep,PetscInt k,PetscScalar *T,PetscInt ldt,PetscInt idx,PetscScalar **Tp,PetscScalar **Tj)
563: {
565:   PetscInt       i;
566:   PetscReal      *ca,*cb,*cg;
567:   PetscScalar    *pt,g,a;
568:   PetscBLASInt   k_,ldt_;

571:   if (idx==0) {
572:     PetscMemzero(*Tj,k*k*sizeof(PetscScalar));
573:     PetscMemzero(*Tp,k*k*sizeof(PetscScalar));
574:     for (i=0;i<k;i++) (*Tj)[i+i*k] = 1.0;
575:   } else {
576:     PetscBLASIntCast(ldt,&ldt_);
577:     PetscBLASIntCast(k,&k_);
578:     ca = pep->pbc; cb = pep->pbc+pep->nmat; cg = pep->pbc+2*pep->nmat;
579:     for (i=0;i<k;i++) T[i*ldt+i] -= cb[idx-1];
580:     a = 1/ca[idx-1];
581:     g = (idx==1)?0.0:-cg[idx-1]/ca[idx-1];
582:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&a,T,&ldt_,*Tj,&k_,&g,*Tp,&k_));
583:     pt = *Tj; *Tj = *Tp; *Tp = pt;
584:     for (i=0;i<k;i++) T[i*ldt+i] += cb[idx-1];
585:   }
586:   return(0);
587: }

591: /* dim(work)=6*sr*k;*/
592: static PetscErrorCode PEPExtractInvariantPair(PEP pep,PetscScalar sigma,PetscInt sr,PetscInt k,PetscScalar *S,PetscInt ld,PetscInt deg,PetscScalar *H,PetscInt ldh,PetscScalar *work)
593: {
594: #if defined(PETSC_MISSING_LAPACK_GESV) || defined(PETSC_MISSING_LAPACK_GETRI) || defined(PETSC_MISSING_LAPACK_GETRF)
596:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV/GETRI/GETRF - Lapack routine is unavailable");
597: #else
599:   PetscInt       nw,i,j,jj,nwu=0,lds,ldt,d=pep->nmat-1,idxcpy=0;
600:   PetscScalar    *At,*Bt,*Hj,*Hp,*T,sone=1.0,g,a,*pM;
601:   PetscBLASInt   k_,sr_,lds_,ldh_,info,*p,lwork,ldt_;
602:   PetscBool      transf=PETSC_FALSE,flg;
603:   PetscReal      nrm,norm,maxnrm,*rwork;
604:   BV             *R,Y;
605:   Mat            M,*A;
606:   Vec            v;

609:   if (k==0) return(0);
610:   nw = 6*sr*k;
611:   lds = deg*ld;
612:   At = work+nwu;
613:   nwu += sr*k;
614:   Bt = work+nwu;
615:   nwu += k*k;
616:   PetscMemzero(Bt,k*k*sizeof(PetscScalar));
617:   Hj = work+nwu;
618:   nwu += k*k;
619:   Hp = work+nwu;
620:   nwu += k*k;
621:   PetscMemzero(Hp,k*k*sizeof(PetscScalar));
622:   PetscMalloc1(k,&p);
623:   PetscBLASIntCast(sr,&sr_);
624:   PetscBLASIntCast(k,&k_);
625:   PetscBLASIntCast(lds,&lds_);
626:   PetscBLASIntCast(ldh,&ldh_);
627:   STGetTransform(pep->st,&flg);
628:   if (!flg) {
629:      PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&flg);
630:     if (flg || sigma!=0.0) transf=PETSC_TRUE;
631:   }
632:   if (transf) {
633:     ldt = k;
634:     T = work+nwu;
635:     nwu += k*k;
636:     for (i=0;i<k;i++) {
637:       PetscMemcpy(T+k*i,H+i*ldh,k*sizeof(PetscScalar));
638:     }
639:     if (flg) {
640:       PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&k_,&k_,T,&k_,p,&info));
641:       PetscBLASIntCast(nw-nwu,&lwork);
642:       PetscStackCallBLAS("LAPACKgetri",LAPACKgetri_(&k_,T,&k_,p,work+nwu,&lwork,&info));
643:     }
644:     if (sigma!=0.0) for (i=0;i<k;i++) T[i+k*i] += sigma;
645:   } else {
646:     T = H; ldt = ldh;
647:   }
648:   PetscBLASIntCast(ldt,&ldt_);
649:   switch (pep->extract) {
650:   case PEP_EXTRACT_NONE:
651:     break;
652:   case PEP_EXTRACT_NORM:
653:     if (pep->basis == PEP_BASIS_MONOMIAL) {
654:       PetscBLASIntCast(ldt,&ldt_);
655:       PetscMalloc1(k,&rwork);
656:       norm = LAPACKlange_("F",&k_,&k_,T,&ldt_,rwork);
657:       PetscFree(rwork);
658:       if (norm>1.0) idxcpy = d-1;
659:     } else {
660:       PetscBLASIntCast(ldt,&ldt_);
661:       PetscMalloc1(k,&rwork);
662:       maxnrm = 0.0;
663:       for (i=0;i<pep->nmat-1;i++) {
664:         PEPEvaluateBasisM(pep,k,T,ldt,i,&Hp,&Hj);
665:         norm = LAPACKlange_("F",&k_,&k_,Hj,&k_,rwork);
666:         if (norm > maxnrm) {
667:           idxcpy = i;
668:           maxnrm = norm;
669:         }
670:       }
671:       PetscFree(rwork);
672:     }
673:     if (idxcpy>0) {
674:       /* copy block idxcpy of S to the first one */
675:       for (j=0;j<k;j++) {
676:         PetscMemcpy(S+j*lds,S+idxcpy*ld+j*lds,sr*sizeof(PetscScalar));
677:       }
678:     }
679:     break;
680:   case PEP_EXTRACT_RESIDUAL:
681:     STGetTransform(pep->st,&flg);
682:     if (flg) {
683:       PetscMalloc1(pep->nmat,&A);
684:       for (i=0;i<pep->nmat;i++) {
685:         STGetTOperators(pep->st,i,A+i);
686:       }
687:     } else A = pep->A;
688:     PetscMalloc1(pep->nmat-1,&R);
689:     for (i=0;i<pep->nmat-1;i++) {
690:       BVDuplicateResize(pep->V,k,R+i);
691:     }
692:     BVDuplicateResize(pep->V,sr,&Y);
693:     MatCreateSeqDense(PETSC_COMM_SELF,sr,k,NULL,&M);
694:     g = 0.0; a = 1.0;
695:     BVSetActiveColumns(pep->V,0,sr);
696:     for (j=0;j<pep->nmat;j++) {
697:       BVMatMult(pep->V,A[j],Y);
698:       PEPEvaluateBasisM(pep,k,T,ldt,i,&Hp,&Hj);
699:       for (i=0;i<pep->nmat-1;i++) {
700:         PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&sr_,&k_,&k_,&a,S+i*ld,&lds_,Hj,&k_,&g,At,&sr_));
701:         MatDenseGetArray(M,&pM);
702:         for (jj=0;jj<k;jj++) {
703:           PetscMemcpy(pM+jj*sr,At+jj*sr,sr*sizeof(PetscScalar));
704:         }
705:         MatDenseRestoreArray(M,&pM);
706:         BVMult(R[i],1.0,(i==0)?0.0:1.0,Y,M);
707:       }
708:     }

710:     /* frobenius norm */
711:     maxnrm = 0.0;
712:     for (i=0;i<pep->nmat-1;i++) {
713:       norm = 0.0;
714:       for (j=0;j<k;j++) {
715:         BVGetColumn(R[i],j,&v);
716:         VecNorm(v,NORM_2,&nrm);
717:         BVRestoreColumn(R[i],j,&v);
718:         norm += nrm*nrm;
719:       }
720:       norm = PetscSqrtReal(norm);
721:       if (maxnrm > norm) {
722:         maxnrm = norm;
723:         idxcpy = i;
724:       }
725:     }
726:     if (idxcpy>0) {
727:       /* copy block idxcpy of S to the first one */
728:       for (j=0;j<k;j++) {
729:         PetscMemcpy(S+j*lds,S+idxcpy*ld+j*lds,sr*sizeof(PetscScalar));
730:       }
731:     }
732:     if (flg) PetscFree(A);
733:     for (i=0;i<pep->nmat-1;i++) {
734:       BVDestroy(&R[i]);
735:     }
736:     PetscFree(R);
737:     BVDestroy(&Y);
738:     MatDestroy(&M);
739:     break;
740:   case PEP_EXTRACT_STRUCTURED:
741:     for (j=0;j<k;j++) Bt[j+j*k] = 1.0;
742:     for (j=0;j<sr;j++) {
743:       for (i=0;i<k;i++) At[j*k+i] = PetscConj(S[i*lds+j]);
744:     }
745:     PEPEvaluateBasisM(pep,k,T,ldt,0,&Hp,&Hj);
746:     for (i=1;i<deg;i++) {
747:       PEPEvaluateBasisM(pep,k,T,ldt,i,&Hp,&Hj);
748:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","C",&k_,&sr_,&k_,&sone,Hj,&k_,S+i*ld,&lds_,&sone,At,&k_));
749:       PetscStackCallBLAS("BLASgemm",BLASgemm_("N","C",&k_,&k_,&k_,&sone,Hj,&k_,Hj,&k_,&sone,Bt,&k_));
750:     }
751:     PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&k_,&sr_,Bt,&k_,p,At,&k_,&info));
752:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGESV %d",info);
753:     for (j=0;j<sr;j++) {
754:       for (i=0;i<k;i++) S[i*lds+j] = PetscConj(At[j*k+i]);
755:     }
756:     break;
757:   default:
758:     SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Extraction not implemented in this solver");
759:   }
760:   PetscFree(p);
761:   return(0);
762: #endif
763: }

767: PetscErrorCode PEPSolve_TOAR(PEP pep)
768: {
770:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
771:   PetscInt       i,j,k,l,nv=0,ld,lds,off,ldds,newn,nq=ctx->nq,nconv=0,locked=0,newc;
772:   PetscInt       lwa,lrwa,nwu=0,nrwu=0,nmat=pep->nmat,deg=nmat-1;
773:   PetscScalar    *S,*Q,*work,*H,sigma;
774:   PetscReal      beta,*rwork;
775:   PetscBool      breakdown=PETSC_FALSE,flg,falselock=PETSC_FALSE,sinv=PETSC_FALSE;

778:   PetscCitationsRegister(citation,&cited);
779:   if (ctx->lock) {
780:     PetscOptionsGetBool(NULL,NULL,"-pep_toar_falselocking",&falselock,NULL);
781:   }
782:   ld = ctx->ld;
783:   S = ctx->S;
784:   lds = deg*ld;        /* leading dimension of S */
785:   lwa = (deg+6)*ld*lds;
786:   lrwa = 7*lds;
787:   PetscMalloc2(lwa,&work,lrwa,&rwork);
788:   DSGetLeadingDimension(pep->ds,&ldds);
789:   STGetShift(pep->st,&sigma);

791:   /* update polynomial basis coefficients */
792:   STGetTransform(pep->st,&flg);
793:   if (pep->sfactor!=1.0) {
794:     for (i=0;i<nmat;i++) {
795:       pep->pbc[nmat+i] /= pep->sfactor;
796:       pep->pbc[2*nmat+i] /= pep->sfactor*pep->sfactor;
797:     }
798:     if (!flg) {
799:       pep->target /= pep->sfactor;
800:       RGPushScale(pep->rg,1.0/pep->sfactor);
801:       STScaleShift(pep->st,1.0/pep->sfactor);
802:       sigma /= pep->sfactor;
803:     } else {
804:       PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);
805:       RGPushScale(pep->rg,sinv?pep->sfactor:1.0/pep->sfactor);
806:       STScaleShift(pep->st,sinv?pep->sfactor:1.0/pep->sfactor);
807:     }
808:   }

810:   if (flg) sigma = 0.0;

812:   /* restart loop */
813:   l = 0;
814:   while (pep->reason == PEP_CONVERGED_ITERATING) {
815:     pep->its++;

817:     /* compute an nv-step Lanczos factorization */
818:     nv = PetscMax(PetscMin(nconv+pep->mpd,pep->ncv),nv);
819:     DSGetArray(pep->ds,DS_MAT_A,&H);
820:     PEPTOARrun(pep,sigma,&nq,S,ld,H,ldds,pep->nconv+l,&nv,&breakdown,work+nwu,pep->work);
821:     beta = PetscAbsScalar(H[(nv-1)*ldds+nv]);
822:     DSRestoreArray(pep->ds,DS_MAT_A,&H);
823:     DSSetDimensions(pep->ds,nv,0,pep->nconv,pep->nconv+l);
824:     if (l==0) {
825:       DSSetState(pep->ds,DS_STATE_INTERMEDIATE);
826:     } else {
827:       DSSetState(pep->ds,DS_STATE_RAW);
828:     }

830:     /* solve projected problem */
831:     DSSolve(pep->ds,pep->eigr,pep->eigi);
832:     DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);
833:     DSUpdateExtraRow(pep->ds);

835:     /* check convergence */
836:     PEPKrylovConvergence(pep,PETSC_FALSE,pep->nconv,nv-pep->nconv,beta,&k);
837:     (*pep->stopping)(pep,pep->its,pep->max_it,k,pep->nev,&pep->reason,pep->stoppingctx);

839:     /* update l */
840:     if (pep->reason != PEP_CONVERGED_ITERATING || breakdown) l = 0;
841:     else {
842:       l = (nv==k)?0:PetscMax(1,(PetscInt)((nv-k)*ctx->keep));
843:       if (!breakdown) {
844:         /* prepare the Rayleigh quotient for restart */
845:         DSTruncate(pep->ds,k+l);
846:         DSGetDimensions(pep->ds,&newn,NULL,NULL,NULL,NULL);
847:         l = newn-k;
848:       }
849:     }
850:     nconv = k;
851:     if (!ctx->lock && pep->reason == PEP_CONVERGED_ITERATING && !breakdown) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */

853:     /* update S */
854:     off = pep->nconv*ldds;
855:     DSGetArray(pep->ds,DS_MAT_Q,&Q);
856:     PEPTOARSupdate(S,ld,deg,nq,pep->nconv,k+l-pep->nconv,nv,Q+off,ldds,work+nwu);
857:     DSRestoreArray(pep->ds,DS_MAT_Q,&Q);

859:     /* copy last column of S */
860:     PetscMemcpy(S+lds*(k+l),S+lds*nv,lds*sizeof(PetscScalar));

862:     if (breakdown) {
863:       /* stop if breakdown */
864:       PetscInfo2(pep,"Breakdown TOAR method (it=%D norm=%g)\n",pep->its,(double)beta);
865:       pep->reason = PEP_DIVERGED_BREAKDOWN;
866:     }
867:     if (pep->reason != PEP_CONVERGED_ITERATING) {l--; flg = PETSC_TRUE;}
868:     else flg = PETSC_FALSE;
869:     /* truncate S */
870:     if (k+l+deg<nq) {
871:       if (!falselock && ctx->lock) {
872:         newc = k-pep->nconv;
873:         PEPTOARTrunc(pep,S,ld,deg,&nq,k+l+1,locked,newc,flg,work+nwu,rwork+nrwu);
874:         locked += newc;
875:       } else {
876:         PEPTOARTrunc(pep,S,ld,deg,&nq,k+l+1,0,0,flg,work+nwu,rwork+nrwu);
877:       }
878:     }
879:     pep->nconv = k;
880:     PEPMonitor(pep,pep->its,nconv,pep->eigr,pep->eigi,pep->errest,nv);
881:   }
882:   if (pep->nconv>0) {
883:     /* {V*S_nconv^i}_{i=0}^{d-1} has rank nconv instead of nconv+d-1. Force zeros in each S_nconv^i block */
884:     nq = pep->nconv;

886:     /* perform Newton refinement if required */
887:     if (pep->refine==PEP_REFINE_MULTIPLE && pep->rits>0) {
888:       /* extract invariant pair */
889:       DSGetArray(pep->ds,DS_MAT_A,&H);
890:       PEPExtractInvariantPair(pep,sigma,nq,pep->nconv,S,ld,deg,H,ldds,work+nwu);
891:       DSRestoreArray(pep->ds,DS_MAT_A,&H);
892:       DSSetDimensions(pep->ds,pep->nconv,0,0,0);
893:       DSSetState(pep->ds,DS_STATE_RAW);
894:       PEPNewtonRefinement_TOAR(pep,sigma,&pep->rits,NULL,pep->nconv,S,lds,&nq);
895:       DSSolve(pep->ds,pep->eigr,pep->eigi);
896:       DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);
897:       DSGetArray(pep->ds,DS_MAT_Q,&Q);
898:       PEPTOARSupdate(S,ld,deg,nq,0,pep->nconv,pep->nconv,Q,ldds,work+nwu);
899:       DSRestoreArray(pep->ds,DS_MAT_Q,&Q);
900:     } else {
901:       DSSetDimensions(pep->ds,pep->nconv,0,0,0);
902:       DSSetState(pep->ds,DS_STATE_RAW);
903:     }
904:   }
905:   if (pep->refine!=PEP_REFINE_MULTIPLE || pep->rits==0) {
906:     STGetTransform(pep->st,&flg);
907:     if (!flg) {
908:       if (pep->ops->backtransform) {
909:         (*pep->ops->backtransform)(pep);
910:       }
911:       /* restore original values */
912:       pep->target *= pep->sfactor;
913:       STScaleShift(pep->st,pep->sfactor);
914:     } else {
915:       STScaleShift(pep->st,sinv?1.0/pep->sfactor:pep->sfactor);
916:     }
917:     if (pep->sfactor!=1.0) {
918:       for (j=0;j<pep->nconv;j++) {
919:         pep->eigr[j] *= pep->sfactor;
920:         pep->eigi[j] *= pep->sfactor;
921:       }
922:       /* restore original values */
923:       for (i=0;i<pep->nmat;i++){
924:         pep->pbc[pep->nmat+i] *= pep->sfactor;
925:         pep->pbc[2*pep->nmat+i] *= pep->sfactor*pep->sfactor;
926:       }
927:     }
928:   }
929:   if (pep->sfactor!=1.0) { RGPopScale(pep->rg); }

931:   /* change the state to raw so that DSVectors() computes eigenvectors from scratch */
932:   DSSetDimensions(pep->ds,pep->nconv,0,0,0);
933:   DSSetState(pep->ds,DS_STATE_RAW);

935:   PetscFree2(work,rwork);
936:   return(0);
937: }

941: static PetscErrorCode PEPTOARSetRestart_TOAR(PEP pep,PetscReal keep)
942: {
943:   PEP_TOAR *ctx = (PEP_TOAR*)pep->data;

946:   if (keep==PETSC_DEFAULT) ctx->keep = 0.5;
947:   else {
948:     if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]");
949:     ctx->keep = keep;
950:   }
951:   return(0);
952: }

956: /*@
957:    PEPTOARSetRestart - Sets the restart parameter for the TOAR
958:    method, in particular the proportion of basis vectors that must be kept
959:    after restart.

961:    Logically Collective on PEP

963:    Input Parameters:
964: +  pep  - the eigenproblem solver context
965: -  keep - the number of vectors to be kept at restart

967:    Options Database Key:
968: .  -pep_toar_restart - Sets the restart parameter

970:    Notes:
971:    Allowed values are in the range [0.1,0.9]. The default is 0.5.

973:    Level: advanced

975: .seealso: PEPTOARGetRestart()
976: @*/
977: PetscErrorCode PEPTOARSetRestart(PEP pep,PetscReal keep)
978: {

984:   PetscTryMethod(pep,"PEPTOARSetRestart_C",(PEP,PetscReal),(pep,keep));
985:   return(0);
986: }

990: static PetscErrorCode PEPTOARGetRestart_TOAR(PEP pep,PetscReal *keep)
991: {
992:   PEP_TOAR *ctx = (PEP_TOAR*)pep->data;

995:   *keep = ctx->keep;
996:   return(0);
997: }

1001: /*@
1002:    PEPTOARGetRestart - Gets the restart parameter used in the TOAR method.

1004:    Not Collective

1006:    Input Parameter:
1007: .  pep - the eigenproblem solver context

1009:    Output Parameter:
1010: .  keep - the restart parameter

1012:    Level: advanced

1014: .seealso: PEPTOARSetRestart()
1015: @*/
1016: PetscErrorCode PEPTOARGetRestart(PEP pep,PetscReal *keep)
1017: {

1023:   PetscUseMethod(pep,"PEPTOARGetRestart_C",(PEP,PetscReal*),(pep,keep));
1024:   return(0);
1025: }

1029: static PetscErrorCode PEPTOARSetLocking_TOAR(PEP pep,PetscBool lock)
1030: {
1031:   PEP_TOAR *ctx = (PEP_TOAR*)pep->data;

1034:   ctx->lock = lock;
1035:   return(0);
1036: }

1040: /*@
1041:    PEPTOARSetLocking - Choose between locking and non-locking variants of
1042:    the TOAR method.

1044:    Logically Collective on PEP

1046:    Input Parameters:
1047: +  pep  - the eigenproblem solver context
1048: -  lock - true if the locking variant must be selected

1050:    Options Database Key:
1051: .  -pep_toar_locking - Sets the locking flag

1053:    Notes:
1054:    The default is to lock converged eigenpairs when the method restarts.
1055:    This behaviour can be changed so that all directions are kept in the
1056:    working subspace even if already converged to working accuracy (the
1057:    non-locking variant).

1059:    Level: advanced

1061: .seealso: PEPTOARGetLocking()
1062: @*/
1063: PetscErrorCode PEPTOARSetLocking(PEP pep,PetscBool lock)
1064: {

1070:   PetscTryMethod(pep,"PEPTOARSetLocking_C",(PEP,PetscBool),(pep,lock));
1071:   return(0);
1072: }

1076: static PetscErrorCode PEPTOARGetLocking_TOAR(PEP pep,PetscBool *lock)
1077: {
1078:   PEP_TOAR *ctx = (PEP_TOAR*)pep->data;

1081:   *lock = ctx->lock;
1082:   return(0);
1083: }

1087: /*@
1088:    PEPTOARGetLocking - Gets the locking flag used in the TOAR method.

1090:    Not Collective

1092:    Input Parameter:
1093: .  pep - the eigenproblem solver context

1095:    Output Parameter:
1096: .  lock - the locking flag

1098:    Level: advanced

1100: .seealso: PEPTOARSetLocking()
1101: @*/
1102: PetscErrorCode PEPTOARGetLocking(PEP pep,PetscBool *lock)
1103: {

1109:   PetscUseMethod(pep,"PEPTOARGetLocking_C",(PEP,PetscBool*),(pep,lock));
1110:   return(0);
1111: }

1115: PetscErrorCode PEPSetFromOptions_TOAR(PetscOptionItems *PetscOptionsObject,PEP pep)
1116: {
1118:   PetscBool      flg,lock;
1119:   PetscReal      keep;

1122:   PetscOptionsHead(PetscOptionsObject,"PEP TOAR Options");
1123:   PetscOptionsReal("-pep_toar_restart","Proportion of vectors kept after restart","PEPTOARSetRestart",0.5,&keep,&flg);
1124:   if (flg) {
1125:     PEPTOARSetRestart(pep,keep);
1126:   }
1127:   PetscOptionsBool("-pep_toar_locking","Choose between locking and non-locking variants","PEPTOARSetLocking",PETSC_FALSE,&lock,&flg);
1128:   if (flg) {
1129:     PEPTOARSetLocking(pep,lock);
1130:   }
1131:   PetscOptionsTail();
1132:   return(0);
1133: }

1137: PetscErrorCode PEPView_TOAR(PEP pep,PetscViewer viewer)
1138: {
1140:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
1141:   PetscBool      isascii;

1144:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
1145:   if (isascii) {
1146:     PetscViewerASCIIPrintf(viewer,"  TOAR: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));
1147:     PetscViewerASCIIPrintf(viewer,"  TOAR: using the %slocking variant\n",ctx->lock?"":"non-");
1148:   }
1149:   return(0);
1150: }

1154: PetscErrorCode PEPDestroy_TOAR(PEP pep)
1155: {

1159:   PetscFree(pep->data);
1160:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetRestart_C",NULL);
1161:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetRestart_C",NULL);
1162:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetLocking_C",NULL);
1163:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetLocking_C",NULL);
1164:   return(0);
1165: }

1169: PETSC_EXTERN PetscErrorCode PEPCreate_TOAR(PEP pep)
1170: {
1171:   PEP_TOAR       *ctx;

1175:   PetscNewLog(pep,&ctx);
1176:   pep->data = (void*)ctx;
1177:   ctx->lock = PETSC_TRUE;

1179:   pep->ops->solve          = PEPSolve_TOAR;
1180:   pep->ops->setup          = PEPSetUp_TOAR;
1181:   pep->ops->setfromoptions = PEPSetFromOptions_TOAR;
1182:   pep->ops->destroy        = PEPDestroy_TOAR;
1183:   pep->ops->view           = PEPView_TOAR;
1184:   pep->ops->backtransform  = PEPBackTransform_Default;
1185:   pep->ops->computevectors = PEPComputeVectors_Default;
1186:   pep->ops->extractvectors = PEPExtractVectors_TOAR;
1187:   pep->ops->reset          = PEPReset_TOAR;
1188:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetRestart_C",PEPTOARSetRestart_TOAR);
1189:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetRestart_C",PEPTOARGetRestart_TOAR);
1190:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetLocking_C",PEPTOARSetLocking_TOAR);
1191:   PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetLocking_C",PEPTOARGetLocking_TOAR);
1192:   return(0);
1193: }

slepc-3.7.4/src/pep/impls/krylov/toar/makefile.html0000644000175000017500000000471013107004621021622 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = ptoar.c nrefine.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcpep
DIRS     =
MANSEC   = PEP
LOCDIR   = src/pep/impls/krylov/toar/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/pep/impls/krylov/toar/nrefine.c0000644000175000017500000020156613107004621020761 0ustar jromanjroman/* Newton refinement for polynomial eigenproblems. References: [1] T. Betcke and D. Kressner, "Perturbation, extraction and refinement of invariant pairs for matrix polynomials", Linear Algebra Appl. 435(3):514-536, 2011. [2] C. Campos and J.E. Roman, "Parallel iterative refinement in polynomial eigenvalue problems", submitted, 2015. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include typedef struct { Mat *A,M1; BV V,M2,M3,W; PetscInt k,nmat; PetscScalar *fih,*work,*M4; PetscBLASInt *pM4; PetscBool compM1; Vec t; } FSubctx; typedef struct { Mat E[2],M1; Vec tN,ttN,t1,vseq; VecScatter scatterctx; PetscBool compM1; PetscInt *map0,*map1,*idxg,*idxp; PetscSubcomm subc; VecScatter scatter_sub; VecScatter *scatter_id,*scatterp_id; Mat *A; BV V,W,M2,M3,Wt; PetscScalar *M4,*w,*wt,*d,*dt; Vec t,tg,Rv,Vi,tp,tpg; PetscInt idx,*cols; } MatExplicitCtx; #undef __FUNCT__ #define __FUNCT__ "MatFSMult" static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y) { #if defined(PETSC_MISSING_LAPACK_GETRS) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routine is unavailable"); #else PetscErrorCode ierr; FSubctx *ctx; PetscInt k,i; PetscScalar *c; PetscBLASInt k_,one=1,info; PetscFunctionBegin; ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); ierr = VecCopy(x,ctx->t);CHKERRQ(ierr); k = ctx->k; c = ctx->work; ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = MatMult(ctx->M1,x,y);CHKERRQ(ierr); ierr = VecConjugate(ctx->t);CHKERRQ(ierr); ierr = BVDotVec(ctx->M3,ctx->t,c);CHKERRQ(ierr); for (i=0;iM4,&k_,ctx->pM4,c,&k_,&info)); ierr = BVMultVec(ctx->M2,-1.0,1.0,y,c);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "PEPEvaluateBasisforMatrix" /* Evaluates the first d elements of the polynomial basis on a given matrix H which is considered to be triangular */ static PetscErrorCode PEPEvaluateBasisforMatrix(PEP pep,PetscInt nm,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH) { PetscErrorCode ierr; PetscInt i,j,ldfh=nm*k,off,nmat=pep->nmat; PetscReal *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat,t; PetscScalar corr=0.0,alpha,beta; PetscBLASInt k_,ldh_,ldfh_; PetscFunctionBegin; ierr = PetscBLASIntCast(ldh,&ldh_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldfh,&ldfh_);CHKERRQ(ierr); ierr = PetscMemzero(fH,nm*k*k*sizeof(PetscScalar));CHKERRQ(ierr); if (nm>0) for (j=0;j1) { t = b[0]/a[0]; off = k; for (j=0;jM4,t,*v,*T; const PetscScalar *m3,*m2; PetscInt i,d,j,nmat=pep->nmat,lda=nmat*k,deg=nmat-1,nloc; PetscReal *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat; PetscBLASInt k_,lda_,lds_,nloc_,one=1,info; Mat *A=ctx->A,Mk,M1=ctx->M1,P; BV V=ctx->V,M2=ctx->M2,M3=ctx->M3,W=ctx->W; MatStructure str; Vec vc; PetscFunctionBegin; ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = PetscMalloc3(nmat*k*k,&T12,k*k,&Tr,PetscMax(k*k,nmat),&Ts);CHKERRQ(ierr); DHii = T12; ierr = PetscMemzero(DHii,k*k*nmat*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;icompM1) { ierr = MatCopy(A[0],M1,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = PEPEvaluateBasis(pep,h,0,Ts,NULL);CHKERRQ(ierr); for (j=1;jt,&nloc);CHKERRQ(ierr); ierr = PetscBLASIntCast(nloc,&nloc_);CHKERRQ(ierr); ierr = PetscMalloc1(nloc*k,&T);CHKERRQ(ierr); ierr = KSPGetOperators(pep->refineksp,NULL,&P);CHKERRQ(ierr); if (!ctx->compM1) { ierr = MatCopy(ctx->M1,P,SAME_NONZERO_PATTERN);CHKERRQ(ierr); } ierr = BVGetArrayRead(ctx->M2,&m2);CHKERRQ(ierr); ierr = BVGetArrayRead(ctx->M3,&m3);CHKERRQ(ierr); ierr = VecGetArray(ctx->t,&v);CHKERRQ(ierr); for (i=0;iM4,&k_,ctx->pM4,T,&k_,&info)); for (i=0;it,&v);CHKERRQ(ierr); ierr = BVRestoreArrayRead(ctx->M2,&m2);CHKERRQ(ierr); ierr = BVRestoreArrayRead(ctx->M3,&m3);CHKERRQ(ierr); ierr = MatDiagonalSet(P,ctx->t,ADD_VALUES);CHKERRQ(ierr); ierr = PetscFree(T);CHKERRQ(ierr); ierr = KSPSetUp(pep->refineksp);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "NRefSysSolve_shell" static PetscErrorCode NRefSysSolve_shell(KSP ksp,PetscInt nmat,Vec Rv,PetscScalar *Rh,PetscInt k,Vec dVi,PetscScalar *dHi) { #if defined(PETSC_MISSING_LAPACK_GETRS) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscScalar *t0; PetscBLASInt k_,one=1,info,lda_; PetscInt i,lda=nmat*k; Mat M; FSubctx *ctx; PetscFunctionBegin; ierr = KSPGetOperators(ksp,&M,NULL);CHKERRQ(ierr); ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); ierr = PetscCalloc1(k,&t0);CHKERRQ(ierr); ierr = PetscBLASIntCast(lda,&lda_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); for (i=0;iM4,&k_,ctx->pM4,t0,&k_,&info)); ierr = BVMultVec(ctx->M2,-1.0,1.0,Rv,t0);CHKERRQ(ierr); ierr = KSPSolve(ksp,Rv,dVi);CHKERRQ(ierr); ierr = VecConjugate(dVi);CHKERRQ(ierr); ierr = BVDotVec(ctx->M3,dVi,dHi);CHKERRQ(ierr); ierr = VecConjugate(dVi);CHKERRQ(ierr); for (i=0;iM4,&k_,ctx->pM4,dHi,&k_,&info)); ierr = PetscFree(t0);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "NRefRightSide" /* Computes the residual P(H,V*S)*e_j for the polynomial */ static PetscErrorCode NRefRightSide(PetscInt nmat,PetscReal *pcf,Mat *A,PetscInt k,BV V,PetscScalar *S,PetscInt lds,PetscInt j,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *DfH,PetscScalar *dH,BV dV,PetscScalar *dVS,PetscInt rds,Vec Rv,PetscScalar *Rh,BV W,Vec t) { PetscErrorCode ierr; PetscScalar *DS0,*DS1,*F,beta=0.0,sone=1.0,none=-1.0,tt=0.0,*h,zero=0.0,*Z,*c0; PetscReal *a=pcf,*b=pcf+nmat,*g=b+nmat; PetscInt i,ii,jj,lda; PetscBLASInt lda_,k_,ldh_,lds_,nmat_,k2_,krds_,j_,one=1; Mat M0; Vec w; PetscFunctionBegin; ierr = PetscMalloc4(k*nmat,&h,k*k,&DS0,k*k,&DS1,k*k,&Z);CHKERRQ(ierr); lda = k*nmat; ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lda,&lda_);CHKERRQ(ierr); ierr = PetscBLASIntCast(nmat,&nmat_);CHKERRQ(ierr); PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&nmat_,&k_,&sone,S,&lds_,fH+j*lda,&k_,&zero,h,&k_)); ierr = MatCreateSeqDense(PETSC_COMM_SELF,k,nmat,h,&M0);CHKERRQ(ierr); ierr = BVSetActiveColumns(W,0,nmat);CHKERRQ(ierr); ierr = BVMult(W,1.0,0.0,V,M0);CHKERRQ(ierr); ierr = MatDestroy(&M0);CHKERRQ(ierr); ierr = BVGetColumn(W,0,&w);CHKERRQ(ierr); ierr = MatMult(A[0],w,Rv);CHKERRQ(ierr); ierr = BVRestoreColumn(W,0,&w);CHKERRQ(ierr); for (i=1;i1) { beta = -g[i-1]; PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,fH+(i-1)*k,&lda_,Z,&k_,&beta,DS0,&k_)); tt += -b[i-1]; for (ii=0;ii0 && i=0;i--) { ierr = BVGetColumn(WW,i,&v);CHKERRQ(ierr); ierr = VecConjugate(v);CHKERRQ(ierr); ierr = VecDot(xx1,v,y+i);CHKERRQ(ierr); ierr = VecConjugate(v);CHKERRQ(ierr); ierr = BVRestoreColumn(WW,i,&v);CHKERRQ(ierr); for (j=0;jnmat,lda=nmat*k,deg=nmat-1; Mat M1=matctx->M1,*A,*At,Mk; PetscReal *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat; PetscScalar s,ss,*DHii,*T12,*array,*Ts,*Tr,*M4=matctx->M4,sone=1.0,zero=0.0; PetscScalar *w=matctx->w,*wt=matctx->wt,*d=matctx->d,*dt=matctx->dt; PetscBLASInt lds_,lda_,k_; MatStructure str; PetscBool flg; BV M2=matctx->M2,M3=matctx->M3,W=matctx->W,Wt=matctx->Wt; Vec vc,vc2; PetscFunctionBegin; ierr = PetscMalloc3(nmat*k*k,&T12,k*k,&Tr,PetscMax(k*k,nmat),&Ts);CHKERRQ(ierr); ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscMalloc1(pep->nmat,&At);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = STGetTOperators(pep->st,i,&At[i]);CHKERRQ(ierr); } } else At = pep->A; if (matctx->subc) A = matctx->A; else A = At; /* Form the explicit system matrix */ DHii = T12; ierr = PetscMemzero(DHii,k*k*nmat*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;icompM1) { ierr = MatCopy(A[0],M1,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = PEPEvaluateBasis(pep,h,0,Ts,NULL);CHKERRQ(ierr); for (j=1;jt);CHKERRQ(ierr); ierr = BVRestoreColumn(M2,i,&vc);CHKERRQ(ierr); ierr = BVGetColumn(M3,i,&vc);CHKERRQ(ierr); ierr = VecConjugate(vc);CHKERRQ(ierr); ierr = VecDot(vc2,vc,&d[i]);CHKERRQ(ierr); ierr = VecConjugate(vc);CHKERRQ(ierr); ierr = BVRestoreColumn(M3,i,&vc);CHKERRQ(ierr); for (j=0;jt);CHKERRQ(ierr); ierr = BVRestoreColumn(M3,i,&vc);CHKERRQ(ierr); ierr = BVGetColumn(M2,i,&vc);CHKERRQ(ierr); ierr = VecConjugate(vc2);CHKERRQ(ierr); ierr = VecDot(vc,vc2,&dt[i]);CHKERRQ(ierr); ierr = VecConjugate(vc2);CHKERRQ(ierr); ierr = BVRestoreColumn(M2,i,&vc);CHKERRQ(ierr); for (j=0;jnmat,lda=nmat*k,deg=nmat-1; PetscInt *idxg=matctx->idxg,*idxp=matctx->idxp,idx,ncols; Mat M,*E=matctx->E,*A,*At,Mk,Md; PetscReal *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat; PetscScalar s,ss,*DHii,*T22,*T21,*T12,*Ts,*Tr,*array,*ts,sone=1.0,zero=0.0; PetscBLASInt lds_,lda_,k_; const PetscInt *idxmc; const PetscScalar *valsc,*carray; MatStructure str; Vec vc,vc0; PetscBool flg; PetscFunctionBegin; ierr = PetscMalloc5(k*k,&T22,k*k,&T21,nmat*k*k,&T12,k*k,&Tr,k*k,&Ts);CHKERRQ(ierr); ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = KSPGetOperators(ksp,&M,NULL);CHKERRQ(ierr); ierr = MatGetOwnershipRange(E[1],&n1,&m1);CHKERRQ(ierr); ierr = MatGetOwnershipRange(E[0],&n0,&m0);CHKERRQ(ierr); ierr = MatGetOwnershipRange(M,&n,NULL);CHKERRQ(ierr); ierr = PetscMalloc1(nmat,&ts);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscMalloc1(pep->nmat,&At);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = STGetTOperators(pep->st,i,&At[i]);CHKERRQ(ierr); } } else At = pep->A; if (matctx->subc) A = matctx->A; else A = At; /* Form the explicit system matrix */ DHii = T12; ierr = PetscMemzero(DHii,k*k*nmat*sizeof(PetscScalar));CHKERRQ(ierr); for (i=0;icompM1) { ierr = MatCopy(A[0],E[0],DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = PEPEvaluateBasis(pep,h,0,Ts,NULL);CHKERRQ(ierr); for (j=1;jmap0[idxmc[j]]; } ierr = MatSetValues(M,1,&idx,ncols,idxg,valsc,INSERT_VALUES);CHKERRQ(ierr); ierr = MatRestoreRow(E[0],i,&ncols,&idxmc,&valsc);CHKERRQ(ierr); } /* T22 */ ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lda,&lda_);CHKERRQ(ierr); PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&k_,&k_,&k_,&sone,S,&lds_,S,&lds_,&zero,Tr,&k_)); for (i=1;imap1[j]; for (i=0;imap1[i]; ierr = MatSetValues(M,1,&idx,m0-n0,matctx->map0+n0,carray,INSERT_VALUES);CHKERRQ(ierr); ierr = VecRestoreArrayRead(vc,&carray);CHKERRQ(ierr); ierr = BVRestoreColumn(W,i,&vc);CHKERRQ(ierr); } /* T12 */ for (i=1;i0;i--) { ierr = BVGetColumn(W,i-1,&vc0);CHKERRQ(ierr); ierr = BVGetColumn(W,i,&vc);CHKERRQ(ierr); ierr = MatMult(A[i],vc0,vc);CHKERRQ(ierr); ierr = BVRestoreColumn(W,i-1,&vc0);CHKERRQ(ierr); ierr = BVRestoreColumn(W,i,&vc);CHKERRQ(ierr); } ierr = BVSetActiveColumns(W,1,nmat);CHKERRQ(ierr); ierr = BVGetColumn(W,0,&vc0);CHKERRQ(ierr); ierr = BVMultVec(W,1.0,0.0,vc0,ts);CHKERRQ(ierr); ierr = VecGetArrayRead(vc0,&carray);CHKERRQ(ierr); idx = matctx->map1[j]; ierr = MatSetValues(M,m0-n0,matctx->map0+n0,1,&idx,carray,INSERT_VALUES);CHKERRQ(ierr); ierr = VecRestoreArrayRead(vc0,&carray);CHKERRQ(ierr); ierr = BVRestoreColumn(W,0,&vc0);CHKERRQ(ierr); } ierr = MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); ierr = KSPSetOperators(ksp,M,M);CHKERRQ(ierr); ierr = KSPSetUp(ksp);CHKERRQ(ierr); ierr = PetscFree(ts);CHKERRQ(ierr); ierr = MatDestroy(&Mk);CHKERRQ(ierr); ierr = MatDestroy(&Md);CHKERRQ(ierr); if (flg) { ierr = PetscFree(At);CHKERRQ(ierr); } ierr = PetscFree5(T22,T21,T12,Tr,Ts);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NRefSysSolve_explicit" static PetscErrorCode NRefSysSolve_explicit(PetscInt k,KSP ksp,Vec Rv,PetscScalar *Rh,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx) { PetscErrorCode ierr; PetscInt n0,m0,n1,m1,i; PetscScalar *arrayV; const PetscScalar *array; PetscFunctionBegin; ierr = MatGetOwnershipRange(matctx->E[1],&n1,&m1);CHKERRQ(ierr); ierr = MatGetOwnershipRange(matctx->E[0],&n0,&m0);CHKERRQ(ierr); /* Right side */ ierr = VecGetArrayRead(Rv,&array);CHKERRQ(ierr); ierr = VecSetValues(matctx->tN,m0-n0,matctx->map0+n0,array,INSERT_VALUES);CHKERRQ(ierr); ierr = VecRestoreArrayRead(Rv,&array);CHKERRQ(ierr); ierr = VecSetValues(matctx->tN,m1-n1,matctx->map1+n1,Rh+n1,INSERT_VALUES);CHKERRQ(ierr); ierr = VecAssemblyBegin(matctx->tN);CHKERRQ(ierr); ierr = VecAssemblyEnd(matctx->tN);CHKERRQ(ierr); /* Solve */ ierr = KSPSolve(ksp,matctx->tN,matctx->ttN);CHKERRQ(ierr); /* Retrieve solution */ ierr = VecGetArray(dVi,&arrayV);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->ttN,&array);CHKERRQ(ierr); ierr = PetscMemcpy(arrayV,array,(m0-n0)*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArray(dVi,&arrayV);CHKERRQ(ierr); if (!matctx->subc) { ierr = VecGetArray(matctx->t1,&arrayV);CHKERRQ(ierr); for (i=0;it1,&arrayV);CHKERRQ(ierr); ierr = VecRestoreArrayRead(matctx->ttN,&array);CHKERRQ(ierr); ierr = VecScatterBegin(matctx->scatterctx,matctx->t1,matctx->vseq,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(matctx->scatterctx,matctx->t1,matctx->vseq,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->vseq,&array);CHKERRQ(ierr); for (i=0;ivseq,&array);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NRefSysIter" static PetscErrorCode NRefSysIter(PetscInt i,PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar *H,PetscInt ldh,Vec Rv,PetscScalar *Rh,BV V,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx,BV W) { PetscErrorCode ierr; PetscInt j,m,lda=pep->nmat*k,n0,m0,idx; PetscMPIInt root,len; PetscScalar *array2,h; const PetscScalar *array; Vec R,Vi; FSubctx *ctx; Mat M; PetscFunctionBegin; if (!matctx || !matctx->subc) { for (j=0;jnmat;j++) fh[j] = fH[j*k+i+i*lda]; h = H[i+i*ldh]; idx = i; R = Rv; Vi = dVi; switch (pep->scheme) { case PEP_REFINE_SCHEME_EXPLICIT: ierr = NRefSysSetup_explicit(pep,k,ksp,fH,S,lds,fh,h,V,matctx,W);CHKERRQ(ierr); matctx->compM1 = PETSC_FALSE; break; case PEP_REFINE_SCHEME_MBE: ierr = NRefSysSetup_mbe(pep,k,ksp,fH,S,lds,fh,h,V,matctx);CHKERRQ(ierr); matctx->compM1 = PETSC_FALSE; break; case PEP_REFINE_SCHEME_SCHUR: ierr = KSPGetOperators(ksp,&M,NULL);CHKERRQ(ierr); ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); ierr = NRefSysSetup_shell(pep,k,fH,S,lds,fh,h,ctx);CHKERRQ(ierr); ctx->compM1 = PETSC_FALSE; break; } } else { if (i%matctx->subc->n==0 && (idx=i+matctx->subc->color)nmat;j++) fh[j] = fH[j*k+idx+idx*lda]; h = H[idx+idx*ldh]; matctx->idx = idx; switch (pep->scheme) { case PEP_REFINE_SCHEME_EXPLICIT: ierr = NRefSysSetup_explicit(pep,k,ksp,fH,S,lds,fh,h,matctx->V,matctx,matctx->W);CHKERRQ(ierr); matctx->compM1 = PETSC_FALSE; break; case PEP_REFINE_SCHEME_MBE: ierr = NRefSysSetup_mbe(pep,k,ksp,fH,S,lds,fh,h,matctx->V,matctx);CHKERRQ(ierr); matctx->compM1 = PETSC_FALSE; break; case PEP_REFINE_SCHEME_SCHUR: break; } } else idx = matctx->idx; ierr = VecScatterBegin(matctx->scatter_id[i%matctx->subc->n],Rv,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(matctx->scatter_id[i%matctx->subc->n],Rv,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->tg,&array);CHKERRQ(ierr); ierr = VecPlaceArray(matctx->t,array);CHKERRQ(ierr); ierr = VecCopy(matctx->t,matctx->Rv);CHKERRQ(ierr); ierr = VecResetArray(matctx->t);CHKERRQ(ierr); ierr = VecRestoreArrayRead(matctx->tg,&array);CHKERRQ(ierr); R = matctx->Rv; Vi = matctx->Vi; } if (idx==i && idxscheme) { case PEP_REFINE_SCHEME_EXPLICIT: ierr = NRefSysSolve_explicit(k,ksp,R,Rh,Vi,dHi,matctx);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_MBE: ierr = NRefSysSolve_mbe(k,k,matctx->W,matctx->w,matctx->Wt,matctx->wt,matctx->d,matctx->dt,ksp,matctx->M2,matctx->M3 ,matctx->M4,PETSC_FALSE,R,Rh,Vi,dHi,matctx->t);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_SCHUR: ierr = NRefSysSolve_shell(ksp,pep->nmat,R,Rh,k,Vi,dHi);CHKERRQ(ierr); break; } } if (matctx && matctx->subc) { ierr = VecGetLocalSize(Vi,&m);CHKERRQ(ierr); ierr = VecGetArrayRead(Vi,&array);CHKERRQ(ierr); ierr = VecGetArray(matctx->tg,&array2);CHKERRQ(ierr); ierr = PetscMemcpy(array2,array,m*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArray(matctx->tg,&array2);CHKERRQ(ierr); ierr = VecRestoreArrayRead(Vi,&array);CHKERRQ(ierr); ierr = VecScatterBegin(matctx->scatter_id[i%matctx->subc->n],matctx->tg,dVi,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); ierr = VecScatterEnd(matctx->scatter_id[i%matctx->subc->n],matctx->tg,dVi,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr); switch (pep->scheme) { case PEP_REFINE_SCHEME_EXPLICIT: ierr = MatGetOwnershipRange(matctx->E[0],&n0,&m0);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->ttN,&array);CHKERRQ(ierr); ierr = VecPlaceArray(matctx->tp,array+m0-n0);CHKERRQ(ierr); ierr = VecScatterBegin(matctx->scatterp_id[i%matctx->subc->n],matctx->tp,matctx->tpg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(matctx->scatterp_id[i%matctx->subc->n],matctx->tp,matctx->tpg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecResetArray(matctx->tp);CHKERRQ(ierr); ierr = VecRestoreArrayRead(matctx->ttN,&array);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->tpg,&array);CHKERRQ(ierr); for (j=0;jtpg,&array);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_MBE: root = 0; for (j=0;jsubc->n;j++) root += matctx->subc->subsize[j]; ierr = PetscMPIIntCast(k,&len);CHKERRQ(ierr); ierr = MPI_Bcast(dHi,len,MPIU_SCALAR,root,matctx->subc->dupparent);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_SCHUR: break; } } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPNRefForwardSubstitution" static PetscErrorCode PEPNRefForwardSubstitution(PEP pep,PetscInt k,PetscScalar *S,PetscInt lds,PetscScalar *H,PetscInt ldh,PetscScalar *fH,BV dV,PetscScalar *dVS,PetscInt *rds,PetscScalar *dH,PetscInt lddh,KSP ksp,MatExplicitCtx *matctx) { PetscErrorCode ierr; PetscInt i,nmat=pep->nmat,lda=nmat*k; PetscScalar *fh,*Rh,*DfH; PetscReal norm; BV W; Vec Rv,t,dvi; FSubctx *ctx; Mat M,*At; PetscBool flg,lindep; PetscFunctionBegin; ierr = PetscMalloc2(nmat*k*k,&DfH,k,&Rh);CHKERRQ(ierr); *rds = 0; ierr = BVCreateVec(pep->V,&Rv);CHKERRQ(ierr); switch (pep->scheme) { case PEP_REFINE_SCHEME_EXPLICIT: ierr = BVCreateVec(pep->V,&t);CHKERRQ(ierr); ierr = BVDuplicateResize(pep->V,PetscMax(k,nmat),&W);CHKERRQ(ierr); ierr = PetscMalloc1(nmat,&fh);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_MBE: if (matctx->subc) { ierr = BVCreateVec(pep->V,&t);CHKERRQ(ierr); ierr = BVDuplicateResize(pep->V,PetscMax(k,nmat),&W);CHKERRQ(ierr); } else { W = matctx->W; ierr = PetscObjectReference((PetscObject)W);CHKERRQ(ierr); t = matctx->t; ierr = PetscObjectReference((PetscObject)t);CHKERRQ(ierr); } ierr = BVScale(matctx->W,0.0);CHKERRQ(ierr); ierr = BVScale(matctx->Wt,0.0);CHKERRQ(ierr); ierr = BVScale(matctx->M2,0.0);CHKERRQ(ierr); ierr = BVScale(matctx->M3,0.0);CHKERRQ(ierr); ierr = PetscMalloc1(nmat,&fh);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_SCHUR: ierr = KSPGetOperators(ksp,&M,NULL);CHKERRQ(ierr); ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); ierr = BVCreateVec(pep->V,&t);CHKERRQ(ierr); ierr = BVDuplicateResize(pep->V,PetscMax(k,nmat),&W);CHKERRQ(ierr); fh = ctx->fih; break; } ierr = PetscMemzero(dVS,2*k*k*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMemzero(DfH,lda*k*sizeof(PetscScalar));CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscMalloc1(pep->nmat,&At);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = STGetTOperators(pep->st,i,&At[i]);CHKERRQ(ierr); } } else At = pep->A; /* Main loop for computing the ith columns of dX and dS */ for (i=0;ipbc,At,k,pep->V,S,lds,i,H,ldh,fH,DfH,dH,dV,dVS,*rds,Rv,Rh,W,t);CHKERRQ(ierr); /* Update and solve system */ ierr = BVGetColumn(dV,i,&dvi);CHKERRQ(ierr); ierr = NRefSysIter(i,pep,k,ksp,fH,S,lds,fh,H,ldh,Rv,Rh,pep->V,dvi,dH+i*k,matctx,W);CHKERRQ(ierr); /* Orthogonalize computed solution */ ierr = BVOrthogonalizeVec(pep->V,dvi,dVS+i*2*k,&norm,&lindep);CHKERRQ(ierr); ierr = BVRestoreColumn(dV,i,&dvi);CHKERRQ(ierr); if (!lindep) { ierr = BVOrthogonalizeColumn(dV,i,dVS+k+i*2*k,&norm,&lindep);CHKERRQ(ierr); if (!lindep) { dVS[k+i+i*2*k] = norm; ierr = BVScaleColumn(dV,i,1.0/norm);CHKERRQ(ierr); (*rds)++; } } } ierr = BVSetActiveColumns(dV,0,*rds);CHKERRQ(ierr); ierr = VecDestroy(&t);CHKERRQ(ierr); ierr = VecDestroy(&Rv);CHKERRQ(ierr); ierr = BVDestroy(&W);CHKERRQ(ierr); if (flg) { ierr = PetscFree(At);CHKERRQ(ierr); } ierr = PetscFree2(DfH,Rh);CHKERRQ(ierr); if (pep->scheme!=PEP_REFINE_SCHEME_SCHUR) { ierr = PetscFree(fh);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NRefOrthogStep" static PetscErrorCode NRefOrthogStep(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscInt *prs) { #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscInt i,j,nmat=pep->nmat,deg=nmat-1,lda=nmat*k,rs=*prs,ldg; PetscScalar *T,*G,*tau,*array,sone=1.0,zero=0.0,*work; PetscBLASInt rs_,lds_,k_,ldh_,info,ldg_,lda_; Mat M0; PetscFunctionBegin; ierr = PetscMalloc4(rs*k,&T,k,&tau,k,&work,deg*k*k,&G);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lda,&lda_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); if (rs>k) { /* Truncate S to have k columns*/ for (j=0;jV,0,rs);CHKERRQ(ierr); ierr = BVMultInPlace(pep->V,M0,0,k);CHKERRQ(ierr); ierr = BVSetActiveColumns(pep->V,0,k);CHKERRQ(ierr); ierr = MatDestroy(&M0);CHKERRQ(ierr); *prs = rs = k; } /* Form auxiliary matrix for the orthogonalization step */ ldg = deg*k; ierr = PEPEvaluateBasisforMatrix(pep,nmat,k,H,ldh,fH);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldg,&ldg_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldh,&ldh_);CHKERRQ(ierr); for (j=0;jnmat,lda=nmat*k; PetscScalar *tau,*array,*work; PetscBLASInt lds_,k_,lda_,ldh_,kdrs_,info,k2_; Mat M0; PetscFunctionBegin; ierr = PetscMalloc2(k,&tau,k,&work);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lda,&lda_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldh,&ldh_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = PetscBLASIntCast(2*k,&k2_);CHKERRQ(ierr); ierr = PetscBLASIntCast((k+rds),&kdrs_);CHKERRQ(ierr); /* Update H */ for (j=0;jV,M0,0,k);CHKERRQ(ierr); if (rds) { ierr = MatDenseGetArray(M0,&array);CHKERRQ(ierr); for (j=0;jV,1.0,1.0,dV,NULL);CHKERRQ(ierr); } ierr = MatDestroy(&M0);CHKERRQ(ierr); ierr = NRefOrthogStep(pep,k,H,ldh,fH,S,lds,&k);CHKERRQ(ierr); ierr = PetscFree2(tau,work);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "PEPNRefSetUp" static PetscErrorCode PEPNRefSetUp(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,MatExplicitCtx *matctx,PetscBool ini) { PetscErrorCode ierr; FSubctx *ctx; PetscScalar t,*coef; const PetscScalar *array; MatStructure str; PetscInt j,nmat=pep->nmat,n0,m0,n1,m1,n0_,m0_,n1_,m1_,N0,N1,p,*idx1,*idx2,count,si,i,l0; MPI_Comm comm; PetscMPIInt np; const PetscInt *rgs0,*rgs1; Mat B,C,*E,*A,*At; IS is1,is2; Vec v; PetscBool flg; Mat M,P; PetscFunctionBegin; ierr = PetscMalloc1(nmat,&coef);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscMalloc1(pep->nmat,&At);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = STGetTOperators(pep->st,i,&At[i]);CHKERRQ(ierr); } } else At = pep->A; switch (pep->scheme) { case PEP_REFINE_SCHEME_EXPLICIT: if (ini) { if (matctx->subc) { A = matctx->A; comm = PetscSubcommChild(matctx->subc); } else { A = At; ierr = PetscObjectGetComm((PetscObject)pep,&comm);CHKERRQ(ierr); } E = matctx->E; ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = MatDuplicate(A[0],MAT_COPY_VALUES,&E[0]);CHKERRQ(ierr); j = (matctx->subc)?matctx->subc->color:0; ierr = PEPEvaluateBasis(pep,H[j+j*ldh],0,coef,NULL);CHKERRQ(ierr); for (j=1;jcompM1 = PETSC_TRUE; ierr = MatGetSize(E[0],NULL,&N0);CHKERRQ(ierr); ierr = MatGetSize(E[1],NULL,&N1);CHKERRQ(ierr); ierr = MPI_Comm_size(PetscObjectComm((PetscObject)M),&np);CHKERRQ(ierr); ierr = MatGetOwnershipRanges(E[0],&rgs0);CHKERRQ(ierr); ierr = MatGetOwnershipRanges(E[1],&rgs1);CHKERRQ(ierr); ierr = PetscMalloc4(PetscMax(k,N1),&matctx->idxp,N0,&matctx->idxg,N0,&matctx->map0,N1,&matctx->map1);CHKERRQ(ierr); /* Create column (and row) mapping */ for (p=0;pmap0[j] = j+rgs1[p]; for (j=rgs1[p];jmap1[j] = j+rgs0[p+1]; } ierr = MatCreateVecs(M,NULL,&matctx->tN);CHKERRQ(ierr); ierr = MatCreateVecs(matctx->E[1],NULL,&matctx->t1);CHKERRQ(ierr); ierr = VecDuplicate(matctx->tN,&matctx->ttN);CHKERRQ(ierr); if (matctx->subc) { ierr = MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);CHKERRQ(ierr); count = np*k; ierr = PetscMalloc2(count,&idx1,count,&idx2);CHKERRQ(ierr); ierr = VecCreateMPI(PetscObjectComm((PetscObject)pep),m1-n1,PETSC_DECIDE,&matctx->tp);CHKERRQ(ierr); ierr = VecGetOwnershipRange(matctx->tp,&l0,NULL);CHKERRQ(ierr); ierr = VecCreateMPI(PetscObjectComm((PetscObject)pep),k,PETSC_DECIDE,&matctx->tpg);CHKERRQ(ierr); for (si=0;sisubc->n;si++) { if (matctx->subc->color==si) { j=0; if (matctx->subc->color==si) { for (p=0;ptp,is1,matctx->tpg,is2,&matctx->scatterp_id[si]);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); ierr = ISDestroy(&is2);CHKERRQ(ierr); } ierr = PetscFree2(idx1,idx2);CHKERRQ(ierr); } else { ierr = VecScatterCreateToAll(matctx->t1,&matctx->scatterctx,&matctx->vseq);CHKERRQ(ierr); } P = M; } else { if (matctx->subc) { /* Scatter vectors pep->V */ for (i=0;iV,i,&v);CHKERRQ(ierr); ierr = VecScatterBegin(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i,&v);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->tg,&array);CHKERRQ(ierr); ierr = VecPlaceArray(matctx->t,(const PetscScalar*)array);CHKERRQ(ierr); ierr = BVInsertVec(matctx->V,i,matctx->t);CHKERRQ(ierr); ierr = VecResetArray(matctx->t);CHKERRQ(ierr); ierr = VecRestoreArrayRead(matctx->tg,&array);CHKERRQ(ierr); } } } break; case PEP_REFINE_SCHEME_MBE: if (ini) { if (matctx->subc) { A = matctx->A; comm = PetscSubcommChild(matctx->subc); } else { matctx->V = pep->V; A = At; ierr = PetscObjectGetComm((PetscObject)pep,&comm);CHKERRQ(ierr); ierr = MatCreateVecs(pep->A[0],&matctx->t,NULL);CHKERRQ(ierr); } ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); ierr = MatDuplicate(A[0],MAT_COPY_VALUES,&matctx->M1);CHKERRQ(ierr); j = (matctx->subc)?matctx->subc->color:0; ierr = PEPEvaluateBasis(pep,H[j+j*ldh],0,coef,NULL);CHKERRQ(ierr); for (j=1;jM1,coef[j],A[j],str);CHKERRQ(ierr); } ierr = BVDuplicateResize(matctx->V,PetscMax(k,pep->nmat),&matctx->W);CHKERRQ(ierr); ierr = BVDuplicateResize(matctx->V,k,&matctx->M2);CHKERRQ(ierr); ierr = BVDuplicate(matctx->M2,&matctx->M3);CHKERRQ(ierr); ierr = BVDuplicate(matctx->M2,&matctx->Wt);CHKERRQ(ierr); ierr = PetscMalloc5(k*k,&matctx->M4,k*k,&matctx->w,k*k,&matctx->wt,k,&matctx->d,k,&matctx->dt);CHKERRQ(ierr); matctx->compM1 = PETSC_TRUE; M = matctx->M1; P = M; } break; case PEP_REFINE_SCHEME_SCHUR: if (ini) { ierr = PetscObjectGetComm((PetscObject)pep,&comm);CHKERRQ(ierr); ierr = MatGetSize(At[0],&m0,&n0);CHKERRQ(ierr); ierr = PetscMalloc1(1,&ctx);CHKERRQ(ierr); ierr = STGetMatStructure(pep->st,&str);CHKERRQ(ierr); /* Create a shell matrix to solve the linear system */ ctx->A = At; ctx->V = pep->V; ctx->k = k; ctx->nmat = nmat; ierr = PetscMalloc4(k*k,&ctx->M4,k,&ctx->pM4,2*k*k,&ctx->work,nmat,&ctx->fih);CHKERRQ(ierr); ierr = PetscMemzero(ctx->M4,k*k*sizeof(PetscScalar));CHKERRQ(ierr); ierr = MatCreateShell(comm,PETSC_DECIDE,PETSC_DECIDE,m0,n0,ctx,&M);CHKERRQ(ierr); ierr = MatShellSetOperation(M,MATOP_MULT,(void(*)(void))MatFSMult);CHKERRQ(ierr); ierr = BVDuplicateResize(ctx->V,PetscMax(k,pep->nmat),&ctx->W);CHKERRQ(ierr); ierr = BVDuplicateResize(ctx->V,k,&ctx->M2);CHKERRQ(ierr); ierr = BVDuplicate(ctx->M2,&ctx->M3);CHKERRQ(ierr); ierr = BVCreateVec(pep->V,&ctx->t);CHKERRQ(ierr); ierr = MatDuplicate(At[0],MAT_COPY_VALUES,&ctx->M1);CHKERRQ(ierr); ierr = PEPEvaluateBasis(pep,H[0],0,coef,NULL);CHKERRQ(ierr); for (j=1;jM1,coef[j],At[j],str);CHKERRQ(ierr); } ierr = MatDuplicate(At[0],MAT_COPY_VALUES,&P);CHKERRQ(ierr); /* Compute a precond matrix for the system */ t = H[0]; ierr = PEPEvaluateBasis(pep,t,0,coef,NULL);CHKERRQ(ierr); for (j=1;jcompM1 = PETSC_TRUE; } break; } if (ini) { ierr = PEPRefineGetKSP(pep,&pep->refineksp);CHKERRQ(ierr); ierr = KSPSetErrorIfNotConverged(pep->refineksp,PETSC_TRUE);CHKERRQ(ierr); ierr = KSPSetOperators(pep->refineksp,M,P);CHKERRQ(ierr); ierr = KSPSetFromOptions(pep->refineksp);CHKERRQ(ierr); } if (!ini && matctx && matctx->subc) { /* Scatter vectors pep->V */ for (i=0;iV,i,&v);CHKERRQ(ierr); ierr = VecScatterBegin(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i,&v);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->tg,&array);CHKERRQ(ierr); ierr = VecPlaceArray(matctx->t,(const PetscScalar*)array);CHKERRQ(ierr); ierr = BVInsertVec(matctx->V,i,matctx->t);CHKERRQ(ierr); ierr = VecResetArray(matctx->t);CHKERRQ(ierr); ierr = VecRestoreArrayRead(matctx->tg,&array);CHKERRQ(ierr); } } ierr = PetscFree(coef);CHKERRQ(ierr); if (flg) { ierr = PetscFree(At);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NRefSubcommSetup" static PetscErrorCode NRefSubcommSetup(PEP pep,PetscInt k,MatExplicitCtx *matctx,PetscInt nsubc) { PetscErrorCode ierr; PetscInt i,si,j,m0,n0,nloc0,nloc_sub,*idx1,*idx2; IS is1,is2; BVType type; Vec v; const PetscScalar *array; Mat *A; PetscBool flg; PetscFunctionBegin; ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscMalloc1(pep->nmat,&A);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = STGetTOperators(pep->st,i,&A[i]);CHKERRQ(ierr); } } else A = pep->A; /* Duplicate pep matrices */ ierr = PetscMalloc3(pep->nmat,&matctx->A,nsubc,&matctx->scatter_id,nsubc,&matctx->scatterp_id);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = MatCreateRedundantMatrix(A[i],0,PetscSubcommChild(matctx->subc),MAT_INITIAL_MATRIX,&matctx->A[i]);CHKERRQ(ierr); } /* Create Scatter */ ierr = MatCreateVecs(matctx->A[0],&matctx->t,NULL);CHKERRQ(ierr); ierr = MatGetLocalSize(matctx->A[0],&nloc_sub,NULL);CHKERRQ(ierr); ierr = VecCreateMPI(PetscSubcommContiguousParent(matctx->subc),nloc_sub,PETSC_DECIDE,&matctx->tg);CHKERRQ(ierr); ierr = BVGetColumn(pep->V,0,&v);CHKERRQ(ierr); ierr = VecGetOwnershipRange(v,&n0,&m0);CHKERRQ(ierr); nloc0 = m0-n0; ierr = PetscMalloc2(matctx->subc->n*nloc0,&idx1,matctx->subc->n*nloc0,&idx2);CHKERRQ(ierr); j = 0; for (si=0;sisubc->n;si++) { for (i=n0;in*si; } } ierr = ISCreateGeneral(PetscObjectComm((PetscObject)pep),matctx->subc->n*nloc0,idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr); ierr = ISCreateGeneral(PetscObjectComm((PetscObject)pep),matctx->subc->n*nloc0,idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr); ierr = VecScatterCreate(v,is1,matctx->tg,is2,&matctx->scatter_sub);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); ierr = ISDestroy(&is2);CHKERRQ(ierr); for (si=0;sisubc->n;si++) { j=0; for (i=n0;in*si; } ierr = ISCreateGeneral(PetscObjectComm((PetscObject)pep),nloc0,idx1,PETSC_COPY_VALUES,&is1);CHKERRQ(ierr); ierr = ISCreateGeneral(PetscObjectComm((PetscObject)pep),nloc0,idx2,PETSC_COPY_VALUES,&is2);CHKERRQ(ierr); ierr = VecScatterCreate(v,is1,matctx->tg,is2,&matctx->scatter_id[si]);CHKERRQ(ierr); ierr = ISDestroy(&is1);CHKERRQ(ierr); ierr = ISDestroy(&is2);CHKERRQ(ierr); } ierr = BVRestoreColumn(pep->V,0,&v);CHKERRQ(ierr); ierr = PetscFree2(idx1,idx2);CHKERRQ(ierr); /* Duplicate pep->V vecs */ ierr = BVGetType(pep->V,&type);CHKERRQ(ierr); ierr = BVCreate(PetscSubcommChild(matctx->subc),&matctx->V);CHKERRQ(ierr); ierr = BVSetType(matctx->V,type);CHKERRQ(ierr); ierr = BVSetSizesFromVec(matctx->V,matctx->t,k);CHKERRQ(ierr); if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) { ierr = BVDuplicateResize(matctx->V,PetscMax(k,pep->nmat),&matctx->W);CHKERRQ(ierr); } for (i=0;iV,i,&v);CHKERRQ(ierr); ierr = VecScatterBegin(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = VecScatterEnd(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i,&v);CHKERRQ(ierr); ierr = VecGetArrayRead(matctx->tg,&array);CHKERRQ(ierr); ierr = VecPlaceArray(matctx->t,(const PetscScalar*)array);CHKERRQ(ierr); ierr = BVInsertVec(matctx->V,i,matctx->t);CHKERRQ(ierr); ierr = VecResetArray(matctx->t);CHKERRQ(ierr); ierr = VecRestoreArrayRead(matctx->tg,&array);CHKERRQ(ierr); } ierr = VecDuplicate(matctx->t,&matctx->Rv);CHKERRQ(ierr); ierr = VecDuplicate(matctx->t,&matctx->Vi);CHKERRQ(ierr); if (flg) { ierr = PetscFree(A);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "NRefSubcommDestroy" static PetscErrorCode NRefSubcommDestroy(PEP pep,MatExplicitCtx *matctx) { PetscErrorCode ierr; PetscInt i; PetscFunctionBegin; ierr = VecScatterDestroy(&matctx->scatter_sub);CHKERRQ(ierr); for (i=0;isubc->n;i++) { ierr = VecScatterDestroy(&matctx->scatter_id[i]);CHKERRQ(ierr); } for (i=0;inmat;i++) { ierr = MatDestroy(&matctx->A[i]);CHKERRQ(ierr); } if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) { for (i=0;isubc->n;i++) { ierr = VecScatterDestroy(&matctx->scatterp_id[i]);CHKERRQ(ierr); } ierr = VecDestroy(&matctx->tp);CHKERRQ(ierr); ierr = VecDestroy(&matctx->tpg);CHKERRQ(ierr); ierr = BVDestroy(&matctx->W);CHKERRQ(ierr); } ierr = PetscFree3(matctx->A,matctx->scatter_id,matctx->scatterp_id);CHKERRQ(ierr); ierr = BVDestroy(&matctx->V);CHKERRQ(ierr); ierr = VecDestroy(&matctx->t);CHKERRQ(ierr); ierr = VecDestroy(&matctx->tg);CHKERRQ(ierr); ierr = VecDestroy(&matctx->Rv);CHKERRQ(ierr); ierr = VecDestroy(&matctx->Vi);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPNewtonRefinement_TOAR" PetscErrorCode PEPNewtonRefinement_TOAR(PEP pep,PetscScalar sigma,PetscInt *maxits,PetscReal *tol,PetscInt k,PetscScalar *S,PetscInt lds,PetscInt *prs) { #if defined(PETSC_MISSING_LAPACK_GETRF) || defined(PETSC_MISSING_LAPACK_GETRI) PetscFunctionBegin; SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF/GETRI - Lapack routine is unavailable"); #else PetscErrorCode ierr; PetscScalar *H,*work,*dH,*fH,*dVS; PetscInt ldh,i,j,its=1,nmat=pep->nmat,nsubc=pep->npart,rds; PetscBLASInt k_,ld_,*p,info; BV dV; PetscBool sinvert,flg; MatExplicitCtx *matctx=NULL; Vec v; Mat M,P; FSubctx *ctx; PetscFunctionBegin; ierr = PetscLogEventBegin(PEP_Refine,pep,0,0,0);CHKERRQ(ierr); if (k > pep->n) SETERRQ1(PetscObjectComm((PetscObject)pep),1,"Multiple Refinement available only for invariant pairs of dimension smaller than n=%D",pep->n); /* the input tolerance is not being taken into account (by the moment) */ its = *maxits; ierr = PetscMalloc3(k*k,&dH,nmat*k*k,&fH,k,&work);CHKERRQ(ierr); ierr = DSGetLeadingDimension(pep->ds,&ldh);CHKERRQ(ierr); ierr = DSGetArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = PetscMalloc1(2*k*k,&dVS);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg && pep->st && pep->ops->backtransform) { /* BackTransform */ ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldh,&ld_);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinvert);CHKERRQ(ierr); if (sinvert) { ierr = DSGetArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = PetscMalloc1(k,&p);CHKERRQ(ierr); PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&k_,&k_,H,&ld_,p,&info)); PetscStackCallBLAS("LAPACKgetri",LAPACKgetri_(&k_,H,&ld_,p,work,&k_,&info)); ierr = DSRestoreArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); pep->ops->backtransform = NULL; } if (sigma!=0.0) { ierr = DSGetArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); for (i=0;ids,DS_MAT_A,&H);CHKERRQ(ierr); pep->ops->backtransform = NULL; } } if ((pep->scale==PEP_SCALE_BOTH || pep->scale==PEP_SCALE_SCALAR) && pep->sfactor!=1.0) { ierr = DSGetArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); for (j=0;jsfactor; } ierr = DSRestoreArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); if (!flg) { /* Restore original values */ for (i=0;inmat;i++){ pep->pbc[pep->nmat+i] *= pep->sfactor; pep->pbc[2*pep->nmat+i] *= pep->sfactor*pep->sfactor; } } } if ((pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) && pep->Dr) { for (i=0;iV,i,&v);CHKERRQ(ierr); ierr = VecPointwiseMult(v,v,pep->Dr);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,i,&v);CHKERRQ(ierr); } } ierr = DSGetArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = NRefOrthogStep(pep,k,H,ldh,fH,S,lds,prs);CHKERRQ(ierr); /* check if H is in Schur form */ for (i=0;ik) SETERRQ(PetscObjectComm((PetscObject)pep),1,"Amount of subcommunicators should not be larger than the invariant pair dimension"); ierr = BVSetActiveColumns(pep->V,0,k);CHKERRQ(ierr); ierr = BVDuplicateResize(pep->V,k,&dV);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)dV);CHKERRQ(ierr); if (pep->scheme!=PEP_REFINE_SCHEME_SCHUR) { ierr = PetscMalloc1(1,&matctx);CHKERRQ(ierr); if (nsubc>1) { /* spliting in subcommunicators */ matctx->subc = pep->refinesubc; ierr = NRefSubcommSetup(pep,k,matctx,nsubc);CHKERRQ(ierr); } else matctx->subc=NULL; } /* Loop performing iterative refinements */ for (i=0;irefineksp,matctx);CHKERRQ(ierr); /* Update X (=V*S) and H, and orthogonalize [X;X*fH1;...;XfH(deg-1)] */ ierr = PEPNRefUpdateInvPair(pep,k,H,ldh,fH,dH,S,lds,dV,dVS,rds);CHKERRQ(ierr); } ierr = DSRestoreArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); if (!flg && sinvert) { ierr = PetscFree(p);CHKERRQ(ierr); } ierr = PetscFree3(dH,fH,work);CHKERRQ(ierr); ierr = PetscFree(dVS);CHKERRQ(ierr); ierr = BVDestroy(&dV);CHKERRQ(ierr); switch (pep->scheme) { case PEP_REFINE_SCHEME_EXPLICIT: for (i=0;i<2;i++) { ierr = MatDestroy(&matctx->E[i]);CHKERRQ(ierr); } ierr = PetscFree4(matctx->idxp,matctx->idxg,matctx->map0,matctx->map1);CHKERRQ(ierr); ierr = VecDestroy(&matctx->tN);CHKERRQ(ierr); ierr = VecDestroy(&matctx->ttN);CHKERRQ(ierr); ierr = VecDestroy(&matctx->t1);CHKERRQ(ierr); if (nsubc>1) { ierr = NRefSubcommDestroy(pep,matctx);CHKERRQ(ierr); } else { ierr = VecDestroy(&matctx->vseq);CHKERRQ(ierr); ierr = VecScatterDestroy(&matctx->scatterctx);CHKERRQ(ierr); } ierr = PetscFree(matctx);CHKERRQ(ierr); ierr = KSPGetOperators(pep->refineksp,&M,NULL);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_MBE: ierr = BVDestroy(&matctx->W);CHKERRQ(ierr); ierr = BVDestroy(&matctx->Wt);CHKERRQ(ierr); ierr = BVDestroy(&matctx->M2);CHKERRQ(ierr); ierr = BVDestroy(&matctx->M3);CHKERRQ(ierr); ierr = MatDestroy(&matctx->M1);CHKERRQ(ierr); ierr = VecDestroy(&matctx->t);CHKERRQ(ierr); ierr = PetscFree5(matctx->M4,matctx->w,matctx->wt,matctx->d,matctx->dt);CHKERRQ(ierr); if (nsubc>1) { ierr = NRefSubcommDestroy(pep,matctx);CHKERRQ(ierr); } ierr = PetscFree(matctx);CHKERRQ(ierr); break; case PEP_REFINE_SCHEME_SCHUR: ierr = KSPGetOperators(pep->refineksp,&M,&P);CHKERRQ(ierr); ierr = MatShellGetContext(M,&ctx);CHKERRQ(ierr); ierr = PetscFree4(ctx->M4,ctx->pM4,ctx->work,ctx->fih);CHKERRQ(ierr); ierr = MatDestroy(&ctx->M1);CHKERRQ(ierr); ierr = BVDestroy(&ctx->M2);CHKERRQ(ierr); ierr = BVDestroy(&ctx->M3);CHKERRQ(ierr); ierr = BVDestroy(&ctx->W);CHKERRQ(ierr); ierr = VecDestroy(&ctx->t);CHKERRQ(ierr); ierr = PetscFree(ctx);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); ierr = MatDestroy(&P);CHKERRQ(ierr); break; } ierr = PetscLogEventEnd(PEP_Refine,pep,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } slepc-3.7.4/src/pep/impls/krylov/toar/nrefine.c.html0000644000175000017500000037701413107004621021726 0ustar jromanjroman
Actual source code: nrefine.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Newton refinement for polynomial eigenproblems.

  4:    References:

  6:        [1] T. Betcke and D. Kressner, "Perturbation, extraction and refinement
  7:            of invariant pairs for matrix polynomials", Linear Algebra Appl.
  8:            435(3):514-536, 2011.

 10:        [2] C. Campos and J.E. Roman, "Parallel iterative refinement in
 11:            polynomial eigenvalue problems", submitted, 2015.

 13:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 14:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 15:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 17:    This file is part of SLEPc.

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

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

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

 33: #include <slepc/private/pepimpl.h>
 34: #include <slepcblaslapack.h>

 36: typedef struct {
 37:   Mat          *A,M1;
 38:   BV           V,M2,M3,W;
 39:   PetscInt     k,nmat;
 40:   PetscScalar  *fih,*work,*M4;
 41:   PetscBLASInt *pM4;
 42:   PetscBool    compM1;
 43:   Vec          t;
 44: } FSubctx;

 46: typedef struct {
 47:   Mat          E[2],M1;
 48:   Vec          tN,ttN,t1,vseq;
 49:   VecScatter   scatterctx;
 50:   PetscBool    compM1;
 51:   PetscInt     *map0,*map1,*idxg,*idxp;
 52:   PetscSubcomm subc;
 53:   VecScatter   scatter_sub;
 54:   VecScatter   *scatter_id,*scatterp_id;
 55:   Mat          *A;
 56:   BV           V,W,M2,M3,Wt;
 57:   PetscScalar  *M4,*w,*wt,*d,*dt;
 58:   Vec          t,tg,Rv,Vi,tp,tpg;
 59:   PetscInt     idx,*cols;
 60: } MatExplicitCtx;

 64: static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)
 65: {
 66: #if defined(PETSC_MISSING_LAPACK_GETRS)
 68:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routine is unavailable");
 69: #else
 71:   FSubctx        *ctx;
 72:   PetscInt       k,i;
 73:   PetscScalar    *c;
 74:   PetscBLASInt   k_,one=1,info;

 77:   MatShellGetContext(M,&ctx);
 78:   VecCopy(x,ctx->t);
 79:   k    = ctx->k;
 80:   c    = ctx->work;
 81:   PetscBLASIntCast(k,&k_);
 82:   MatMult(ctx->M1,x,y);
 83:   VecConjugate(ctx->t);
 84:   BVDotVec(ctx->M3,ctx->t,c);
 85:   for (i=0;i<k;i++) c[i] = PetscConj(c[i]);
 86:   PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("N",&k_,&one,ctx->M4,&k_,ctx->pM4,c,&k_,&info));
 87:   BVMultVec(ctx->M2,-1.0,1.0,y,c);
 88:   return(0);
 89: #endif
 90: }

 94: /*
 95:   Evaluates the first d elements of the polynomial basis
 96:   on a given matrix H which is considered to be triangular
 97: */
 98: static PetscErrorCode PEPEvaluateBasisforMatrix(PEP pep,PetscInt nm,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH)
 99: {
101:   PetscInt       i,j,ldfh=nm*k,off,nmat=pep->nmat;
102:   PetscReal      *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat,t;
103:   PetscScalar    corr=0.0,alpha,beta;
104:   PetscBLASInt   k_,ldh_,ldfh_;

107:   PetscBLASIntCast(ldh,&ldh_);
108:   PetscBLASIntCast(k,&k_);
109:   PetscBLASIntCast(ldfh,&ldfh_);
110:   PetscMemzero(fH,nm*k*k*sizeof(PetscScalar));
111:   if (nm>0) for (j=0;j<k;j++) fH[j+j*ldfh] = 1.0;
112:   if (nm>1) {
113:     t = b[0]/a[0];
114:     off = k;
115:     for (j=0;j<k;j++) {
116:       for (i=0;i<k;i++) fH[off+i+j*ldfh] = H[i+j*ldh]/a[0];
117:       fH[j+j*ldfh] -= t;
118:     }
119:   }
120:   for (i=2;i<nm;i++) {
121:     off = i*k;
122:     if (i==2) {
123:       for (j=0;j<k;j++) {
124:         fH[off+j+j*ldfh] = 1.0;
125:         H[j+j*ldh] -= b[1];
126:       }
127:     } else {
128:       for (j=0;j<k;j++) {
129:         PetscMemcpy(fH+off+j*ldfh,fH+(i-2)*k+j*ldfh,k*sizeof(PetscScalar));
130:         H[j+j*ldh] += corr-b[i-1];
131:       }
132:     }
133:     corr  = b[i-1];
134:     beta  = -g[i-1]/a[i-1];
135:     alpha = 1/a[i-1];
136:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&alpha,H,&ldh_,fH+(i-1)*k,&ldfh_,&beta,fH+off,&ldfh_));
137:   }
138:   for (j=0;j<k;j++) H[j+j*ldh] += corr;
139:   return(0);
140: }

144: static PetscErrorCode NRefSysSetup_shell(PEP pep,PetscInt k,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,FSubctx *ctx)
145: {
146: #if defined(PETSC_MISSING_LAPACK_GESV)
148:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GESV - Lapack routine is unavailable");
149: #else
150:   PetscErrorCode    ierr;
151:   PetscScalar       *DHii,*T12,*Tr,*Ts,*array,s,ss,sone=1.0,zero=0.0,*M4=ctx->M4,t,*v,*T;
152:   const PetscScalar *m3,*m2;
153:   PetscInt          i,d,j,nmat=pep->nmat,lda=nmat*k,deg=nmat-1,nloc;
154:   PetscReal         *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat;
155:   PetscBLASInt      k_,lda_,lds_,nloc_,one=1,info;
156:   Mat               *A=ctx->A,Mk,M1=ctx->M1,P;
157:   BV                V=ctx->V,M2=ctx->M2,M3=ctx->M3,W=ctx->W;
158:   MatStructure      str;
159:   Vec               vc;

162:   STGetMatStructure(pep->st,&str);
163:   PetscMalloc3(nmat*k*k,&T12,k*k,&Tr,PetscMax(k*k,nmat),&Ts);
164:   DHii = T12;
165:   PetscMemzero(DHii,k*k*nmat*sizeof(PetscScalar));
166:   for (i=0;i<k;i++) DHii[k+i+i*lda] = 1.0/a[0];
167:   for (d=2;d<nmat;d++) {
168:     for (j=0;j<k;j++) {
169:       for (i=0;i<k;i++) {
170:         DHii[d*k+i+j*lda] = ((h-b[d-1])*DHii[(d-1)*k+i+j*lda]+fH[(d-1)*k+i+j*lda]-g[d-1]*DHii[(d-2)*k+i+j*lda])/(a[d-1]);
171:       }
172:     }
173:   }
174:   /* T11 */
175:   if (!ctx->compM1) {
176:     MatCopy(A[0],M1,DIFFERENT_NONZERO_PATTERN);
177:     PEPEvaluateBasis(pep,h,0,Ts,NULL);
178:     for (j=1;j<nmat;j++) {
179:       MatAXPY(M1,Ts[j],A[j],str);
180:     }
181:   }

183:   /* T22 */
184:   PetscBLASIntCast(lds,&lds_);
185:   PetscBLASIntCast(k,&k_);
186:   PetscBLASIntCast(lda,&lda_);
187:   PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&k_,&k_,&k_,&sone,S,&lds_,S,&lds_,&zero,Tr,&k_));
188:   for (i=1;i<deg;i++) {
189:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,Tr,&k_,DHii+i*k,&lda_,&zero,Ts,&k_));
190:     s = (i==1)?0.0:1.0;
191:     PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&k_,&k_,&k_,&sone,fH+i*k,&lda_,Ts,&k_,&s,M4,&k_));
192:   }
193:   for (i=0;i<k;i++) for (j=0;j<i;j++) { t=M4[i+j*k];M4[i+j*k]=M4[j+i*k];M4[j+i*k]=t; }

195:   /* T12 */
196:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&Mk);
197:   for (i=1;i<nmat;i++) {
198:     MatDenseGetArray(Mk,&array);
199:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,S,&lds_,DHii+i*k,&lda_,&zero,array,&k_));
200:     MatDenseRestoreArray(Mk,&array);
201:     BVSetActiveColumns(W,0,k);
202:     BVMult(W,1.0,0.0,V,Mk);
203:     if (i==1) {
204:       BVMatMult(W,A[i],M2);
205:     } else {
206:       BVMatMult(W,A[i],M3); /* using M3 as work space */
207:       BVMult(M2,1.0,1.0,M3,NULL);
208:     }
209:   }

211:   /* T21 */
212:   MatDenseGetArray(Mk,&array);
213:   for (i=1;i<deg;i++) {
214:     s = (i==1)?0.0:1.0;
215:     ss = PetscConj(fh[i]);
216:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&ss,S,&lds_,fH+i*k,&lda_,&s,array,&k_));
217:   }
218:   MatDenseRestoreArray(Mk,&array);
219:   BVSetActiveColumns(M3,0,k);
220:   BVMult(M3,1.0,0.0,V,Mk);
221:   for (i=0;i<k;i++) {
222:     BVGetColumn(M3,i,&vc);
223:     VecConjugate(vc);
224:     BVRestoreColumn(M3,i,&vc);
225:   }
226:   MatDestroy(&Mk);
227:   PetscFree3(T12,Tr,Ts);

229:   VecGetLocalSize(ctx->t,&nloc);
230:   PetscBLASIntCast(nloc,&nloc_);
231:   PetscMalloc1(nloc*k,&T);
232:   KSPGetOperators(pep->refineksp,NULL,&P);
233:   if (!ctx->compM1) { MatCopy(ctx->M1,P,SAME_NONZERO_PATTERN); }
234:   BVGetArrayRead(ctx->M2,&m2);
235:   BVGetArrayRead(ctx->M3,&m3);
236:   VecGetArray(ctx->t,&v);
237:   for (i=0;i<nloc;i++) for (j=0;j<k;j++) T[j+i*k] = m3[i+j*nloc];
238:   PetscStackCallBLAS("LAPACKgesv",LAPACKgesv_(&k_,&nloc_,ctx->M4,&k_,ctx->pM4,T,&k_,&info));
239:   for (i=0;i<nloc;i++) v[i] = BLASdot_(&k_,m2+i,&nloc_,T+i*k,&one);
240:   VecRestoreArray(ctx->t,&v);
241:   BVRestoreArrayRead(ctx->M2,&m2);
242:   BVRestoreArrayRead(ctx->M3,&m3);
243:   MatDiagonalSet(P,ctx->t,ADD_VALUES);
244:   PetscFree(T);
245:   KSPSetUp(pep->refineksp);
246:   return(0);
247: #endif
248: }

252: static PetscErrorCode NRefSysSolve_shell(KSP ksp,PetscInt nmat,Vec Rv,PetscScalar *Rh,PetscInt k,Vec dVi,PetscScalar *dHi)
253: {
254: #if defined(PETSC_MISSING_LAPACK_GETRS)
256:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRS - Lapack routine is unavailable");
257: #else
259:   PetscScalar    *t0;
260:   PetscBLASInt   k_,one=1,info,lda_;
261:   PetscInt       i,lda=nmat*k;
262:   Mat            M;
263:   FSubctx        *ctx;

266:   KSPGetOperators(ksp,&M,NULL);
267:   MatShellGetContext(M,&ctx);
268:   PetscCalloc1(k,&t0);
269:   PetscBLASIntCast(lda,&lda_);
270:   PetscBLASIntCast(k,&k_);
271:   for (i=0;i<k;i++) t0[i] = Rh[i];
272:   PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("N",&k_,&one,ctx->M4,&k_,ctx->pM4,t0,&k_,&info));
273:   BVMultVec(ctx->M2,-1.0,1.0,Rv,t0);
274:   KSPSolve(ksp,Rv,dVi);
275:   VecConjugate(dVi);
276:   BVDotVec(ctx->M3,dVi,dHi);
277:   VecConjugate(dVi);
278:   for (i=0;i<k;i++) dHi[i] = Rh[i]-PetscConj(dHi[i]);
279:   PetscStackCallBLAS("LAPACKgetrs",LAPACKgetrs_("N",&k_,&one,ctx->M4,&k_,ctx->pM4,dHi,&k_,&info));
280:   PetscFree(t0);
281:   return(0);
282: #endif
283: }

287: /*
288:    Computes the residual P(H,V*S)*e_j for the polynomial
289: */
290: static PetscErrorCode NRefRightSide(PetscInt nmat,PetscReal *pcf,Mat *A,PetscInt k,BV V,PetscScalar *S,PetscInt lds,PetscInt j,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *DfH,PetscScalar *dH,BV dV,PetscScalar *dVS,PetscInt rds,Vec Rv,PetscScalar *Rh,BV W,Vec t)
291: {
293:   PetscScalar    *DS0,*DS1,*F,beta=0.0,sone=1.0,none=-1.0,tt=0.0,*h,zero=0.0,*Z,*c0;
294:   PetscReal      *a=pcf,*b=pcf+nmat,*g=b+nmat;
295:   PetscInt       i,ii,jj,lda;
296:   PetscBLASInt   lda_,k_,ldh_,lds_,nmat_,k2_,krds_,j_,one=1;
297:   Mat            M0;
298:   Vec            w;

301:   PetscMalloc4(k*nmat,&h,k*k,&DS0,k*k,&DS1,k*k,&Z);
302:   lda = k*nmat;
303:   PetscBLASIntCast(k,&k_);
304:   PetscBLASIntCast(lds,&lds_);
305:   PetscBLASIntCast(lda,&lda_);
306:   PetscBLASIntCast(nmat,&nmat_);
307:   PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&nmat_,&k_,&sone,S,&lds_,fH+j*lda,&k_,&zero,h,&k_));
308:   MatCreateSeqDense(PETSC_COMM_SELF,k,nmat,h,&M0);
309:   BVSetActiveColumns(W,0,nmat);
310:   BVMult(W,1.0,0.0,V,M0);
311:   MatDestroy(&M0);

313:   BVGetColumn(W,0,&w);
314:   MatMult(A[0],w,Rv);
315:   BVRestoreColumn(W,0,&w);
316:   for (i=1;i<nmat;i++) {
317:     BVGetColumn(W,i,&w);
318:     MatMult(A[i],w,t);
319:     BVRestoreColumn(W,i,&w);
320:     VecAXPY(Rv,1.0,t);
321:   }
322:   /* Update right-hand side */
323:   if (j) {
324:     PetscBLASIntCast(ldh,&ldh_);
325:     PetscMemzero(Z,k*k*sizeof(PetscScalar));
326:     PetscMemzero(DS0,k*k*sizeof(PetscScalar));
327:     PetscMemcpy(Z+(j-1)*k,dH+(j-1)*k,k*sizeof(PetscScalar));
328:     /* Update DfH */
329:     for (i=1;i<nmat;i++) {
330:       if (i>1) {
331:         beta = -g[i-1];
332:         PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,fH+(i-1)*k,&lda_,Z,&k_,&beta,DS0,&k_));
333:         tt += -b[i-1];
334:         for (ii=0;ii<k;ii++) H[ii+ii*ldh] += tt;
335:         tt = b[i-1];
336:         beta = 1.0/a[i-1];
337:         PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&beta,DS1,&k_,H,&ldh_,&beta,DS0,&k_));
338:         F = DS0; DS0 = DS1; DS1 = F;
339:       } else {
340:         PetscMemzero(DS1,k*k*sizeof(PetscScalar));
341:         for (ii=0;ii<k;ii++) DS1[ii+(j-1)*k] = Z[ii+(j-1)*k]/a[0];
342:       }
343:       for (jj=j;jj<k;jj++) {
344:         for (ii=0;ii<k;ii++) DfH[k*i+ii+jj*lda] += DS1[ii+jj*k];
345:       }
346:     }
347:     for (ii=0;ii<k;ii++) H[ii+ii*ldh] += tt;
348:     /* Update right-hand side */
349:     PetscBLASIntCast(2*k,&k2_);
350:     PetscBLASIntCast(j,&j_);
351:     PetscBLASIntCast(k+rds,&krds_);
352:     c0 = DS0;
353:     PetscMemzero(Rh,k*sizeof(PetscScalar));
354:     for (i=0;i<nmat;i++) {
355:       PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&krds_,&j_,&sone,dVS,&k2_,fH+j*lda+i*k,&one,&zero,h,&one));
356:       PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S,&lds_,DfH+i*k+j*lda,&one,&sone,h,&one));
357:       BVMultVec(V,1.0,0.0,t,h);
358:       BVSetActiveColumns(dV,0,rds);
359:       BVMultVec(dV,1.0,1.0,t,h+k);
360:       BVGetColumn(W,i,&w);
361:       MatMult(A[i],t,w);
362:       BVRestoreColumn(W,i,&w);
363:       if (i>0 && i<nmat-1) {
364:         PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&k_,&k_,&sone,S,&lds_,h,&one,&zero,c0,&one));
365:         PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&k_,&k_,&none,fH+i*k,&lda_,c0,&one,&sone,Rh,&one));
366:       }
367:     }

369:     for (i=0;i<nmat;i++) h[i] = -1.0;
370:     BVMultVec(W,1.0,1.0,Rv,h);
371:   }
372:   PetscFree4(h,DS0,DS1,Z);
373:   return(0);
374: }

378: static PetscErrorCode NRefSysSolve_mbe(PetscInt k,PetscInt sz,BV W,PetscScalar *w,BV Wt,PetscScalar *wt,PetscScalar *d,PetscScalar *dt,KSP ksp,BV T2,BV T3 ,PetscScalar *T4,PetscBool trans,Vec x1,PetscScalar *x2,Vec sol1,PetscScalar *sol2,Vec vw)
379: {
381:   PetscInt       i,j,incf,incc;
382:   PetscScalar    *y,*g,*xx2,*ww,y2,*dd;
383:   Vec            v,t,xx1;
384:   BV             WW,T;

387:   PetscMalloc3(sz,&y,sz,&g,k,&xx2);
388:   if (trans) {
389:     WW = W; ww = w; dd = d; T = T3; incf = 0; incc = 1;
390:   } else {
391:     WW = Wt; ww = wt; dd = dt; T = T2; incf = 1; incc = 0;
392:   }
393:   xx1 = vw;
394:   VecCopy(x1,xx1);
395:   PetscMemcpy(xx2,x2,sz*sizeof(PetscScalar));
396:   PetscMemzero(sol2,k*sizeof(PetscScalar));
397:   for (i=sz-1;i>=0;i--) {
398:     BVGetColumn(WW,i,&v);
399:     VecConjugate(v);
400:     VecDot(xx1,v,y+i);
401:     VecConjugate(v);
402:     BVRestoreColumn(WW,i,&v);
403:     for (j=0;j<i;j++) y[i] += ww[j+i*k]*xx2[j];
404:     y[i] = -(y[i]-xx2[i])/dd[i];
405:     BVGetColumn(T,i,&t);
406:     VecAXPY(xx1,-y[i],t);
407:     BVRestoreColumn(T,i,&t);
408:     for(j=0;j<=i;j++) xx2[j] -= y[i]*T4[j*incf+incc*i+(i*incf+incc*j)*k];
409:     g[i] = xx2[i];
410:   }
411:   if (trans) {
412:     KSPSolveTranspose(ksp,xx1,sol1);
413:   } else {
414:     KSPSolve(ksp,xx1,sol1);
415:   }
416:   if (trans) {
417:     WW = Wt; ww = wt; dd = dt; T = T2; incf = 1; incc = 0;
418:   } else {
419:     WW = W; ww = w; dd = d; T = T3; incf = 0; incc = 1;
420:   }
421:   for (i=0;i<sz;i++) {
422:     BVGetColumn(T,i,&t);
423:     VecConjugate(t);
424:     VecDot(sol1,t,&y2);
425:     VecConjugate(t);
426:     BVRestoreColumn(T,i,&t);
427:     for (j=0;j<i;j++) y2 += sol2[j]*T4[j*incf+incc*i+(i*incf+incc*j)*k];
428:     y2 = (g[i]-y2)/dd[i];
429:     BVGetColumn(WW,i,&v);
430:     VecAXPY(sol1,-y2,v);
431:     for (j=0;j<i;j++) sol2[j] -= ww[j+i*k]*y2;
432:     sol2[i] = y[i]+y2;
433:     BVRestoreColumn(WW,i,&v);
434:   }
435:   PetscFree3(y,g,xx2);
436:   return(0);
437: }

441: static PetscErrorCode NRefSysSetup_mbe(PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,BV V,MatExplicitCtx *matctx)
442: {
444:   PetscInt       i,j,l,nmat=pep->nmat,lda=nmat*k,deg=nmat-1;
445:   Mat            M1=matctx->M1,*A,*At,Mk;
446:   PetscReal      *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat;
447:   PetscScalar    s,ss,*DHii,*T12,*array,*Ts,*Tr,*M4=matctx->M4,sone=1.0,zero=0.0;
448:   PetscScalar    *w=matctx->w,*wt=matctx->wt,*d=matctx->d,*dt=matctx->dt;
449:   PetscBLASInt   lds_,lda_,k_;
450:   MatStructure   str;
451:   PetscBool      flg;
452:   BV             M2=matctx->M2,M3=matctx->M3,W=matctx->W,Wt=matctx->Wt;
453:   Vec            vc,vc2;

456:   PetscMalloc3(nmat*k*k,&T12,k*k,&Tr,PetscMax(k*k,nmat),&Ts);
457:   STGetMatStructure(pep->st,&str);
458:   STGetTransform(pep->st,&flg);
459:   if (flg) {
460:     PetscMalloc1(pep->nmat,&At);
461:     for (i=0;i<pep->nmat;i++) {
462:       STGetTOperators(pep->st,i,&At[i]);
463:     }
464:   } else At = pep->A;
465:   if (matctx->subc) A = matctx->A;
466:   else A = At;
467:   /* Form the explicit system matrix */
468:   DHii = T12;
469:   PetscMemzero(DHii,k*k*nmat*sizeof(PetscScalar));
470:   for (i=0;i<k;i++) DHii[k+i+i*lda] = 1.0/a[0];
471:   for (l=2;l<nmat;l++) {
472:     for (j=0;j<k;j++) {
473:       for (i=0;i<k;i++) {
474:         DHii[l*k+i+j*lda] = ((h-b[l-1])*DHii[(l-1)*k+i+j*lda]+fH[(l-1)*k+i+j*lda]-g[l-1]*DHii[(l-2)*k+i+j*lda])/a[l-1];
475:       }
476:     }
477:   }

479:   /* T11 */
480:   if (!matctx->compM1) {
481:     MatCopy(A[0],M1,DIFFERENT_NONZERO_PATTERN);
482:     PEPEvaluateBasis(pep,h,0,Ts,NULL);
483:     for (j=1;j<nmat;j++) {
484:       MatAXPY(M1,Ts[j],A[j],str);
485:     }
486:   }

488:   /* T22 */
489:   PetscBLASIntCast(lds,&lds_);
490:   PetscBLASIntCast(k,&k_);
491:   PetscBLASIntCast(lda,&lda_);
492:   PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&k_,&k_,&k_,&sone,S,&lds_,S,&lds_,&zero,Tr,&k_));
493:   for (i=1;i<deg;i++) {
494:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,Tr,&k_,DHii+i*k,&lda_,&zero,Ts,&k_));
495:     s = (i==1)?0.0:1.0;
496:     PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&k_,&k_,&k_,&sone,fH+i*k,&lda_,Ts,&k_,&s,M4,&k_));
497:   }

499:   /* T12 */
500:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&Mk);
501:   for (i=1;i<nmat;i++) {
502:     MatDenseGetArray(Mk,&array);
503:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,S,&lds_,DHii+i*k,&lda_,&zero,array,&k_));
504:     MatDenseRestoreArray(Mk,&array);
505:     BVSetActiveColumns(W,0,k);
506:     BVMult(W,1.0,0.0,V,Mk);
507:     if (i==1) {
508:       BVMatMult(W,A[i],M2);
509:     } else {
510:       BVMatMult(W,A[i],M3); /* using M3 as work space */
511:       BVMult(M2,1.0,1.0,M3,NULL);
512:     }
513:   }

515:   /* T21 */
516:   MatDenseGetArray(Mk,&array);
517:   for (i=1;i<deg;i++) {
518:     s = (i==1)?0.0:1.0;
519:     ss = PetscConj(fh[i]);
520:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&ss,S,&lds_,fH+i*k,&lda_,&s,array,&k_));
521:   }
522:   MatDenseRestoreArray(Mk,&array);
523:   BVSetActiveColumns(M3,0,k);
524:   BVMult(M3,1.0,0.0,V,Mk);
525:   for (i=0;i<k;i++) {
526:     BVGetColumn(M3,i,&vc);
527:     VecConjugate(vc);
528:     BVRestoreColumn(M3,i,&vc);
529:   }

531:   KSPSetOperators(ksp,M1,M1);
532:   KSPSetUp(ksp);
533:   MatDestroy(&Mk);

535:   /* Set up for BEMW */
536:   for (i=0;i<k;i++) {
537:     BVGetColumn(M2,i,&vc);
538:     BVGetColumn(W,i,&vc2);
539:     NRefSysSolve_mbe(k,i,W,w,Wt,wt,d,dt,ksp,M2,M3,M4,PETSC_FALSE,vc,M4+i*k,vc2,w+i*k,matctx->t);
540:     BVRestoreColumn(M2,i,&vc);
541:     BVGetColumn(M3,i,&vc);
542:     VecConjugate(vc);
543:     VecDot(vc2,vc,&d[i]);
544:     VecConjugate(vc);
545:     BVRestoreColumn(M3,i,&vc);
546:     for (j=0;j<i;j++) d[i] += M4[i+j*k]*w[j+i*k];
547:     d[i] = M4[i+i*k]-d[i];
548:     BVRestoreColumn(W,i,&vc2);

550:     BVGetColumn(M3,i,&vc);
551:     BVGetColumn(Wt,i,&vc2);
552:     for (j=0;j<=i;j++) Ts[j] = M4[i+j*k];
553:     NRefSysSolve_mbe(k,i,W,w,Wt,wt,d,dt,ksp,M2,M3,M4,PETSC_TRUE,vc,Ts,vc2,wt+i*k,matctx->t);
554:     BVRestoreColumn(M3,i,&vc);
555:     BVGetColumn(M2,i,&vc);
556:     VecConjugate(vc2);
557:     VecDot(vc,vc2,&dt[i]);
558:     VecConjugate(vc2);
559:     BVRestoreColumn(M2,i,&vc);
560:     for (j=0;j<i;j++) dt[i] += M4[j+i*k]*wt[j+i*k];
561:     dt[i] = M4[i+i*k]-dt[i];
562:     BVRestoreColumn(Wt,i,&vc2);
563:   }

565:   if (flg) {
566:     PetscFree(At);
567:   }
568:   PetscFree3(T12,Tr,Ts);
569:   return(0);
570: }

574: static PetscErrorCode NRefSysSetup_explicit(PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,BV V,MatExplicitCtx *matctx,BV W)
575: {
576:   PetscErrorCode    ierr;
577:   PetscInt          i,j,d,n,n0,m0,n1,m1,nmat=pep->nmat,lda=nmat*k,deg=nmat-1;
578:   PetscInt          *idxg=matctx->idxg,*idxp=matctx->idxp,idx,ncols;
579:   Mat               M,*E=matctx->E,*A,*At,Mk,Md;
580:   PetscReal         *a=pep->pbc,*b=pep->pbc+nmat,*g=pep->pbc+2*nmat;
581:   PetscScalar       s,ss,*DHii,*T22,*T21,*T12,*Ts,*Tr,*array,*ts,sone=1.0,zero=0.0;
582:   PetscBLASInt      lds_,lda_,k_;
583:   const PetscInt    *idxmc;
584:   const PetscScalar *valsc,*carray;
585:   MatStructure      str;
586:   Vec               vc,vc0;
587:   PetscBool         flg;

590:   PetscMalloc5(k*k,&T22,k*k,&T21,nmat*k*k,&T12,k*k,&Tr,k*k,&Ts);
591:   STGetMatStructure(pep->st,&str);
592:   KSPGetOperators(ksp,&M,NULL);
593:   MatGetOwnershipRange(E[1],&n1,&m1);
594:   MatGetOwnershipRange(E[0],&n0,&m0);
595:   MatGetOwnershipRange(M,&n,NULL);
596:   PetscMalloc1(nmat,&ts);
597:   STGetTransform(pep->st,&flg);
598:   if (flg) {
599:     PetscMalloc1(pep->nmat,&At);
600:     for (i=0;i<pep->nmat;i++) {
601:       STGetTOperators(pep->st,i,&At[i]);
602:     }
603:   } else At = pep->A;
604:   if (matctx->subc) A = matctx->A;
605:   else A = At;
606:   /* Form the explicit system matrix */
607:   DHii = T12;
608:   PetscMemzero(DHii,k*k*nmat*sizeof(PetscScalar));
609:   for (i=0;i<k;i++) DHii[k+i+i*lda] = 1.0/a[0];
610:   for (d=2;d<nmat;d++) {
611:     for (j=0;j<k;j++) {
612:       for (i=0;i<k;i++) {
613:         DHii[d*k+i+j*lda] = ((h-b[d-1])*DHii[(d-1)*k+i+j*lda]+fH[(d-1)*k+i+j*lda]-g[d-1]*DHii[(d-2)*k+i+j*lda])/a[d-1];
614:       }
615:     }
616:   }

618:   /* T11 */
619:   if (!matctx->compM1) {
620:     MatCopy(A[0],E[0],DIFFERENT_NONZERO_PATTERN);
621:     PEPEvaluateBasis(pep,h,0,Ts,NULL);
622:     for (j=1;j<nmat;j++) {
623:       MatAXPY(E[0],Ts[j],A[j],str);
624:     }
625:   }
626:   for (i=n0;i<m0;i++) {
627:     MatGetRow(E[0],i,&ncols,&idxmc,&valsc);
628:     idx = n+i-n0;
629:     for (j=0;j<ncols;j++) {
630:       idxg[j] = matctx->map0[idxmc[j]];
631:     }
632:     MatSetValues(M,1,&idx,ncols,idxg,valsc,INSERT_VALUES);
633:     MatRestoreRow(E[0],i,&ncols,&idxmc,&valsc);
634:   }

636:   /* T22 */
637:   PetscBLASIntCast(lds,&lds_);
638:   PetscBLASIntCast(k,&k_);
639:   PetscBLASIntCast(lda,&lda_);
640:   PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&k_,&k_,&k_,&sone,S,&lds_,S,&lds_,&zero,Tr,&k_));
641:   for (i=1;i<deg;i++) {
642:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,Tr,&k_,DHii+i*k,&lda_,&zero,Ts,&k_));
643:     s = (i==1)?0.0:1.0;
644:     PetscStackCallBLAS("BLASgemm",BLASgemm_("C","N",&k_,&k_,&k_,&sone,fH+i*k,&lda_,Ts,&k_,&s,T22,&k_));
645:   }
646:   for (j=0;j<k;j++) idxp[j] = matctx->map1[j];
647:   for (i=0;i<m1-n1;i++) {
648:     idx = n+m0-n0+i;
649:     for (j=0;j<k;j++) {
650:       Tr[j] = T22[n1+i+j*k];
651:     }
652:     MatSetValues(M,1,&idx,k,idxp,Tr,INSERT_VALUES);
653:   }

655:   /* T21 */
656:   for (i=1;i<deg;i++) {
657:     s = (i==1)?0.0:1.0;
658:     ss = PetscConj(fh[i]);
659:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&ss,S,&lds_,fH+i*k,&lda_,&s,T21,&k_));
660:   }
661:   BVSetActiveColumns(W,0,k);
662:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,T21,&Mk);
663:   BVMult(W,1.0,0.0,V,Mk);
664:   for (i=0;i<k;i++) {
665:     BVGetColumn(W,i,&vc);
666:     VecConjugate(vc);
667:     VecGetArrayRead(vc,&carray);
668:     idx = matctx->map1[i];
669:     MatSetValues(M,1,&idx,m0-n0,matctx->map0+n0,carray,INSERT_VALUES);
670:     VecRestoreArrayRead(vc,&carray);
671:     BVRestoreColumn(W,i,&vc);
672:   }

674:   /* T12 */
675:   for (i=1;i<nmat;i++) {
676:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,S,&lds_,DHii+i*k,&lda_,&zero,Ts,&k_));
677:     for (j=0;j<k;j++) {
678:       PetscMemcpy(T12+i*k+j*lda,Ts+j*k,k*sizeof(PetscScalar));
679:     }
680:   }
681:   MatCreateSeqDense(PETSC_COMM_SELF,k,nmat-1,NULL,&Md);
682:   for (i=0;i<nmat;i++) ts[i] = 1.0;
683:   for (j=0;j<k;j++) {
684:     MatDenseGetArray(Md,&array);
685:     PetscMemcpy(array,T12+k+j*lda,(nmat-1)*k*sizeof(PetscScalar));
686:     MatDenseRestoreArray(Md,&array);
687:     BVSetActiveColumns(W,0,nmat-1);
688:     BVMult(W,1.0,0.0,V,Md);
689:     for (i=nmat-1;i>0;i--) {
690:       BVGetColumn(W,i-1,&vc0);
691:       BVGetColumn(W,i,&vc);
692:       MatMult(A[i],vc0,vc);
693:       BVRestoreColumn(W,i-1,&vc0);
694:       BVRestoreColumn(W,i,&vc);
695:     }
696:     BVSetActiveColumns(W,1,nmat);
697:     BVGetColumn(W,0,&vc0);
698:     BVMultVec(W,1.0,0.0,vc0,ts);
699:     VecGetArrayRead(vc0,&carray);
700:     idx = matctx->map1[j];
701:     MatSetValues(M,m0-n0,matctx->map0+n0,1,&idx,carray,INSERT_VALUES);
702:     VecRestoreArrayRead(vc0,&carray);
703:     BVRestoreColumn(W,0,&vc0);
704:   }
705:   MatAssemblyBegin(M,MAT_FINAL_ASSEMBLY);
706:   MatAssemblyEnd(M,MAT_FINAL_ASSEMBLY);
707:   KSPSetOperators(ksp,M,M);
708:   KSPSetUp(ksp);
709:   PetscFree(ts);
710:   MatDestroy(&Mk);
711:   MatDestroy(&Md);
712:   if (flg) {
713:     PetscFree(At);
714:   }
715:   PetscFree5(T22,T21,T12,Tr,Ts);
716:   return(0);
717: }

721: static PetscErrorCode NRefSysSolve_explicit(PetscInt k,KSP ksp,Vec Rv,PetscScalar *Rh,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx)
722: {
723:   PetscErrorCode    ierr;
724:   PetscInt          n0,m0,n1,m1,i;
725:   PetscScalar       *arrayV;
726:   const PetscScalar *array;

729:   MatGetOwnershipRange(matctx->E[1],&n1,&m1);
730:   MatGetOwnershipRange(matctx->E[0],&n0,&m0);

732:   /* Right side */
733:   VecGetArrayRead(Rv,&array);
734:   VecSetValues(matctx->tN,m0-n0,matctx->map0+n0,array,INSERT_VALUES);
735:   VecRestoreArrayRead(Rv,&array);
736:   VecSetValues(matctx->tN,m1-n1,matctx->map1+n1,Rh+n1,INSERT_VALUES);
737:   VecAssemblyBegin(matctx->tN);
738:   VecAssemblyEnd(matctx->tN);

740:   /* Solve */
741:   KSPSolve(ksp,matctx->tN,matctx->ttN);

743:   /* Retrieve solution */
744:   VecGetArray(dVi,&arrayV);
745:   VecGetArrayRead(matctx->ttN,&array);
746:   PetscMemcpy(arrayV,array,(m0-n0)*sizeof(PetscScalar));
747:   VecRestoreArray(dVi,&arrayV);
748:   if (!matctx->subc) {
749:     VecGetArray(matctx->t1,&arrayV);
750:     for (i=0;i<m1-n1;i++) arrayV[i] =  array[m0-n0+i];
751:     VecRestoreArray(matctx->t1,&arrayV);
752:     VecRestoreArrayRead(matctx->ttN,&array);
753:     VecScatterBegin(matctx->scatterctx,matctx->t1,matctx->vseq,INSERT_VALUES,SCATTER_FORWARD);
754:     VecScatterEnd(matctx->scatterctx,matctx->t1,matctx->vseq,INSERT_VALUES,SCATTER_FORWARD);
755:     VecGetArrayRead(matctx->vseq,&array);
756:     for (i=0;i<k;i++) dHi[i] = array[i];
757:     VecRestoreArrayRead(matctx->vseq,&array);
758:   }
759:   return(0);
760: }

764: static PetscErrorCode NRefSysIter(PetscInt i,PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar *H,PetscInt ldh,Vec Rv,PetscScalar *Rh,BV V,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx,BV W)
765: {
766:   PetscErrorCode    ierr;
767:   PetscInt          j,m,lda=pep->nmat*k,n0,m0,idx;
768:   PetscMPIInt       root,len;
769:   PetscScalar       *array2,h;
770:   const PetscScalar *array;
771:   Vec               R,Vi;
772:   FSubctx           *ctx;
773:   Mat               M;

776:   if (!matctx || !matctx->subc) {
777:     for (j=0;j<pep->nmat;j++) fh[j] = fH[j*k+i+i*lda];
778:     h   = H[i+i*ldh];
779:     idx = i;
780:     R   = Rv;
781:     Vi  = dVi;
782:     switch (pep->scheme) {
783:     case PEP_REFINE_SCHEME_EXPLICIT:
784:       NRefSysSetup_explicit(pep,k,ksp,fH,S,lds,fh,h,V,matctx,W);
785:       matctx->compM1 = PETSC_FALSE;
786:       break;
787:     case PEP_REFINE_SCHEME_MBE:
788:       NRefSysSetup_mbe(pep,k,ksp,fH,S,lds,fh,h,V,matctx);
789:       matctx->compM1 = PETSC_FALSE;
790:       break;
791:     case PEP_REFINE_SCHEME_SCHUR:
792:       KSPGetOperators(ksp,&M,NULL);
793:       MatShellGetContext(M,&ctx);
794:       NRefSysSetup_shell(pep,k,fH,S,lds,fh,h,ctx);
795:       ctx->compM1 = PETSC_FALSE;
796:       break;
797:     }
798:   } else {
799:     if (i%matctx->subc->n==0 && (idx=i+matctx->subc->color)<k) {
800:       for (j=0;j<pep->nmat;j++) fh[j] = fH[j*k+idx+idx*lda];
801:       h = H[idx+idx*ldh];
802:       matctx->idx = idx;
803:       switch (pep->scheme) {
804:       case PEP_REFINE_SCHEME_EXPLICIT:
805:         NRefSysSetup_explicit(pep,k,ksp,fH,S,lds,fh,h,matctx->V,matctx,matctx->W);
806:         matctx->compM1 = PETSC_FALSE;
807:         break;
808:       case PEP_REFINE_SCHEME_MBE:
809:         NRefSysSetup_mbe(pep,k,ksp,fH,S,lds,fh,h,matctx->V,matctx);
810:         matctx->compM1 = PETSC_FALSE;
811:         break;
812:       case PEP_REFINE_SCHEME_SCHUR:
813:         break;
814:       }
815:     } else idx = matctx->idx;
816:     VecScatterBegin(matctx->scatter_id[i%matctx->subc->n],Rv,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
817:     VecScatterEnd(matctx->scatter_id[i%matctx->subc->n],Rv,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
818:     VecGetArrayRead(matctx->tg,&array);
819:     VecPlaceArray(matctx->t,array);
820:     VecCopy(matctx->t,matctx->Rv);
821:     VecResetArray(matctx->t);
822:     VecRestoreArrayRead(matctx->tg,&array);
823:     R  = matctx->Rv;
824:     Vi = matctx->Vi;
825:   }
826:   if (idx==i && idx<k) {
827:     switch (pep->scheme) {
828:       case PEP_REFINE_SCHEME_EXPLICIT:
829:         NRefSysSolve_explicit(k,ksp,R,Rh,Vi,dHi,matctx);
830:         break;
831:       case PEP_REFINE_SCHEME_MBE:
832:         NRefSysSolve_mbe(k,k,matctx->W,matctx->w,matctx->Wt,matctx->wt,matctx->d,matctx->dt,ksp,matctx->M2,matctx->M3 ,matctx->M4,PETSC_FALSE,R,Rh,Vi,dHi,matctx->t);
833:         break;
834:       case PEP_REFINE_SCHEME_SCHUR:
835:         NRefSysSolve_shell(ksp,pep->nmat,R,Rh,k,Vi,dHi);
836:         break;
837:     }
838:   }
839:   if (matctx && matctx->subc) {
840:     VecGetLocalSize(Vi,&m);
841:     VecGetArrayRead(Vi,&array);
842:     VecGetArray(matctx->tg,&array2);
843:     PetscMemcpy(array2,array,m*sizeof(PetscScalar));
844:     VecRestoreArray(matctx->tg,&array2);
845:     VecRestoreArrayRead(Vi,&array);
846:     VecScatterBegin(matctx->scatter_id[i%matctx->subc->n],matctx->tg,dVi,INSERT_VALUES,SCATTER_REVERSE);
847:     VecScatterEnd(matctx->scatter_id[i%matctx->subc->n],matctx->tg,dVi,INSERT_VALUES,SCATTER_REVERSE);
848:     switch (pep->scheme) {
849:     case PEP_REFINE_SCHEME_EXPLICIT:
850:       MatGetOwnershipRange(matctx->E[0],&n0,&m0);
851:       VecGetArrayRead(matctx->ttN,&array);
852:       VecPlaceArray(matctx->tp,array+m0-n0);
853:       VecScatterBegin(matctx->scatterp_id[i%matctx->subc->n],matctx->tp,matctx->tpg,INSERT_VALUES,SCATTER_FORWARD);
854:       VecScatterEnd(matctx->scatterp_id[i%matctx->subc->n],matctx->tp,matctx->tpg,INSERT_VALUES,SCATTER_FORWARD);
855:       VecResetArray(matctx->tp);
856:       VecRestoreArrayRead(matctx->ttN,&array);
857:       VecGetArrayRead(matctx->tpg,&array);
858:       for (j=0;j<k;j++) dHi[j] = array[j];
859:       VecRestoreArrayRead(matctx->tpg,&array);
860:       break;
861:      case PEP_REFINE_SCHEME_MBE:
862:       root = 0;
863:       for (j=0;j<i%matctx->subc->n;j++) root += matctx->subc->subsize[j];
864:       PetscMPIIntCast(k,&len);
865:       MPI_Bcast(dHi,len,MPIU_SCALAR,root,matctx->subc->dupparent);
866:       break;
867:     case PEP_REFINE_SCHEME_SCHUR:
868:       break;
869:     }
870:   }
871:   return(0);
872: }

876: static PetscErrorCode PEPNRefForwardSubstitution(PEP pep,PetscInt k,PetscScalar *S,PetscInt lds,PetscScalar *H,PetscInt ldh,PetscScalar *fH,BV dV,PetscScalar *dVS,PetscInt *rds,PetscScalar *dH,PetscInt lddh,KSP ksp,MatExplicitCtx *matctx)
877: {
879:   PetscInt       i,nmat=pep->nmat,lda=nmat*k;
880:   PetscScalar    *fh,*Rh,*DfH;
881:   PetscReal      norm;
882:   BV             W;
883:   Vec            Rv,t,dvi;
884:   FSubctx        *ctx;
885:   Mat            M,*At;
886:   PetscBool      flg,lindep;

889:   PetscMalloc2(nmat*k*k,&DfH,k,&Rh);
890:   *rds = 0;
891:   BVCreateVec(pep->V,&Rv);
892:   switch (pep->scheme) {
893:   case PEP_REFINE_SCHEME_EXPLICIT:
894:     BVCreateVec(pep->V,&t);
895:     BVDuplicateResize(pep->V,PetscMax(k,nmat),&W);
896:     PetscMalloc1(nmat,&fh);
897:     break;
898:   case PEP_REFINE_SCHEME_MBE:
899:     if (matctx->subc) {
900:       BVCreateVec(pep->V,&t);
901:       BVDuplicateResize(pep->V,PetscMax(k,nmat),&W);
902:     } else {
903:       W = matctx->W;
904:       PetscObjectReference((PetscObject)W);
905:       t = matctx->t;
906:       PetscObjectReference((PetscObject)t);
907:     }
908:     BVScale(matctx->W,0.0);
909:     BVScale(matctx->Wt,0.0);
910:     BVScale(matctx->M2,0.0);
911:     BVScale(matctx->M3,0.0);
912:     PetscMalloc1(nmat,&fh);
913:     break;
914:   case PEP_REFINE_SCHEME_SCHUR:
915:     KSPGetOperators(ksp,&M,NULL);
916:     MatShellGetContext(M,&ctx);
917:     BVCreateVec(pep->V,&t);
918:     BVDuplicateResize(pep->V,PetscMax(k,nmat),&W);
919:     fh = ctx->fih;
920:     break;
921:   }
922:   PetscMemzero(dVS,2*k*k*sizeof(PetscScalar));
923:   PetscMemzero(DfH,lda*k*sizeof(PetscScalar));
924:   STGetTransform(pep->st,&flg);
925:   if (flg) {
926:     PetscMalloc1(pep->nmat,&At);
927:     for (i=0;i<pep->nmat;i++) {
928:       STGetTOperators(pep->st,i,&At[i]);
929:     }
930:   } else At = pep->A;

932:   /* Main loop for computing the ith columns of dX and dS */
933:   for (i=0;i<k;i++) {
934:     /* Compute and update i-th column of the right hand side */
935:     PetscMemzero(Rh,k*sizeof(PetscScalar));
936:     NRefRightSide(nmat,pep->pbc,At,k,pep->V,S,lds,i,H,ldh,fH,DfH,dH,dV,dVS,*rds,Rv,Rh,W,t);

938:     /* Update and solve system */
939:     BVGetColumn(dV,i,&dvi);
940:     NRefSysIter(i,pep,k,ksp,fH,S,lds,fh,H,ldh,Rv,Rh,pep->V,dvi,dH+i*k,matctx,W);
941:     /* Orthogonalize computed solution */
942:     BVOrthogonalizeVec(pep->V,dvi,dVS+i*2*k,&norm,&lindep);
943:     BVRestoreColumn(dV,i,&dvi);
944:     if (!lindep) {
945:       BVOrthogonalizeColumn(dV,i,dVS+k+i*2*k,&norm,&lindep);
946:       if (!lindep) {
947:         dVS[k+i+i*2*k] = norm;
948:         BVScaleColumn(dV,i,1.0/norm);
949:         (*rds)++;
950:       }
951:     }
952:   }
953:   BVSetActiveColumns(dV,0,*rds);
954:   VecDestroy(&t);
955:   VecDestroy(&Rv);
956:   BVDestroy(&W);
957:   if (flg) {
958:     PetscFree(At);
959:   }
960:   PetscFree2(DfH,Rh);
961:   if (pep->scheme!=PEP_REFINE_SCHEME_SCHUR) { PetscFree(fh); }
962:   return(0);
963: }

967: static PetscErrorCode NRefOrthogStep(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscInt *prs)
968: {
969: #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR)
971:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routine is unavailable");
972: #else
974:   PetscInt       i,j,nmat=pep->nmat,deg=nmat-1,lda=nmat*k,rs=*prs,ldg;
975:   PetscScalar    *T,*G,*tau,*array,sone=1.0,zero=0.0,*work;
976:   PetscBLASInt   rs_,lds_,k_,ldh_,info,ldg_,lda_;
977:   Mat            M0;

980:   PetscMalloc4(rs*k,&T,k,&tau,k,&work,deg*k*k,&G);
981:   PetscBLASIntCast(lds,&lds_);
982:   PetscBLASIntCast(lda,&lda_);
983:   PetscBLASIntCast(k,&k_);
984:   if (rs>k) { /* Truncate S to have k columns*/
985:     for (j=0;j<k;j++) {
986:       PetscMemcpy(T+j*rs,S+j*lds,rs*sizeof(PetscScalar));
987:     }
988:     PetscBLASIntCast(rs,&rs_);
989:     PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&rs_,&k_,T,&rs_,tau,work,&k_,&info));
990:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);
991:     /* Copy triangular matrix in S */
992:     PetscMemzero(S,lds*k*sizeof(PetscScalar));
993:     for (j=0;j<k;j++) for (i=0;i<=j;i++) S[j*lds+i] = T[j*rs+i];
994:     PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&rs_,&k_,&k_,T,&rs_,tau,work,&k_,&info));
995:     if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info);
996:     MatCreateSeqDense(PETSC_COMM_SELF,rs,k,NULL,&M0);
997:     MatDenseGetArray(M0,&array);
998:     for (j=0;j<k;j++) {
999:       PetscMemcpy(array+j*rs,T+j*rs,rs*sizeof(PetscScalar));
1000:     }
1001:     MatDenseRestoreArray(M0,&array);
1002:     BVSetActiveColumns(pep->V,0,rs);
1003:     BVMultInPlace(pep->V,M0,0,k);
1004:     BVSetActiveColumns(pep->V,0,k);
1005:     MatDestroy(&M0);
1006:     *prs = rs = k;
1007:   }
1008:   /* Form auxiliary matrix for the orthogonalization step */
1009:   ldg = deg*k;
1010:   PEPEvaluateBasisforMatrix(pep,nmat,k,H,ldh,fH);
1011:   PetscBLASIntCast(ldg,&ldg_);
1012:   PetscBLASIntCast(ldh,&ldh_);
1013:   for (j=0;j<deg;j++) {
1014:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,S,&lds_,fH+j*k,&lda_,&zero,G+j*k,&ldg_));
1015:   }
1016:   /* Orthogonalize and update S */
1017:   PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&ldg_,&k_,G,&ldg_,tau,work,&k_,&info));
1018:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);
1019:   PetscStackCallBLAS("BLAStrsm",BLAStrsm_("R","U","N","N",&k_,&k_,&sone,G,&ldg_,S,&lds_));

1021:   /* Update H */
1022:   PetscStackCallBLAS("BLAStrmm",BLAStrmm_("L","U","N","N",&k_,&k_,&sone,G,&ldg_,H,&ldh_));
1023:   PetscStackCallBLAS("BLAStrsm",BLAStrsm_("R","U","N","N",&k_,&k_,&sone,G,&ldg_,H,&ldh_));
1024:   PetscFree4(T,tau,work,G);
1025:   return(0);
1026: #endif
1027: }

1031: static PetscErrorCode PEPNRefUpdateInvPair(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *dH,PetscScalar *S,PetscInt lds,BV dV,PetscScalar *dVS,PetscInt rds)
1032: {
1033: #if defined(PETSC_MISSING_LAPACK_GEQRF) || defined(PETSC_MISSING_LAPACK_ORGQR)
1035:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GEQRF/ORGQR - Lapack routine is unavailable");
1036: #else
1038:   PetscInt       i,j,nmat=pep->nmat,lda=nmat*k;
1039:   PetscScalar    *tau,*array,*work;
1040:   PetscBLASInt   lds_,k_,lda_,ldh_,kdrs_,info,k2_;
1041:   Mat            M0;

1044:   PetscMalloc2(k,&tau,k,&work);
1045:   PetscBLASIntCast(lds,&lds_);
1046:   PetscBLASIntCast(lda,&lda_);
1047:   PetscBLASIntCast(ldh,&ldh_);
1048:   PetscBLASIntCast(k,&k_);
1049:   PetscBLASIntCast(2*k,&k2_);
1050:   PetscBLASIntCast((k+rds),&kdrs_);
1051:   /* Update H */
1052:   for (j=0;j<k;j++) {
1053:     for (i=0;i<k;i++) H[i+j*ldh] -= dH[i+j*k];
1054:   }
1055:   /* Update V */
1056:   for (j=0;j<k;j++) {
1057:     for (i=0;i<k;i++) dVS[i+j*2*k] = -dVS[i+j*2*k]+S[i+j*lds];
1058:     for (i=k;i<2*k;i++) dVS[i+j*2*k] = -dVS[i+j*2*k];
1059:   }
1060:   PetscStackCallBLAS("LAPACKgeqrf",LAPACKgeqrf_(&kdrs_,&k_,dVS,&k2_,tau,work,&k_,&info));
1061:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xGEQRF %d",info);
1062:   /* Copy triangular matrix in S */
1063:   for (j=0;j<k;j++) {
1064:     for (i=0;i<=j;i++) S[i+j*lds] = dVS[i+j*2*k];
1065:     for (i=j+1;i<k;i++) S[i+j*lds] = 0.0;
1066:   }
1067:   PetscStackCallBLAS("LAPACKungqr",LAPACKungqr_(&k2_,&k_,&k_,dVS,&k2_,tau,work,&k_,&info));
1068:   if (info) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"Error in Lapack xORGQR %d",info);
1069:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&M0);
1070:   MatDenseGetArray(M0,&array);
1071:   for (j=0;j<k;j++) {
1072:     PetscMemcpy(array+j*k,dVS+j*2*k,k*sizeof(PetscScalar));
1073:   }
1074:   MatDenseRestoreArray(M0,&array);
1075:   BVMultInPlace(pep->V,M0,0,k);
1076:   if (rds) {
1077:     MatDenseGetArray(M0,&array);
1078:     for (j=0;j<k;j++) {
1079:       PetscMemcpy(array+j*k,dVS+k+j*2*k,rds*sizeof(PetscScalar));
1080:     }
1081:     MatDenseRestoreArray(M0,&array);
1082:     BVMultInPlace(dV,M0,0,k);
1083:     BVMult(pep->V,1.0,1.0,dV,NULL);
1084:   }
1085:   MatDestroy(&M0);
1086:   NRefOrthogStep(pep,k,H,ldh,fH,S,lds,&k);
1087:   PetscFree2(tau,work);
1088:   return(0);
1089: #endif
1090: }

1094: static PetscErrorCode PEPNRefSetUp(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,MatExplicitCtx *matctx,PetscBool ini)
1095: {
1096:   PetscErrorCode    ierr;
1097:   FSubctx           *ctx;
1098:   PetscScalar       t,*coef;
1099:   const PetscScalar *array;
1100:   MatStructure      str;
1101:   PetscInt          j,nmat=pep->nmat,n0,m0,n1,m1,n0_,m0_,n1_,m1_,N0,N1,p,*idx1,*idx2,count,si,i,l0;
1102:   MPI_Comm          comm;
1103:   PetscMPIInt       np;
1104:   const PetscInt    *rgs0,*rgs1;
1105:   Mat               B,C,*E,*A,*At;
1106:   IS                is1,is2;
1107:   Vec               v;
1108:   PetscBool         flg;
1109:   Mat               M,P;

1112:   PetscMalloc1(nmat,&coef);
1113:   STGetTransform(pep->st,&flg);
1114:   if (flg) {
1115:     PetscMalloc1(pep->nmat,&At);
1116:     for (i=0;i<pep->nmat;i++) {
1117:       STGetTOperators(pep->st,i,&At[i]);
1118:     }
1119:   } else At = pep->A;
1120:   switch (pep->scheme) {
1121:   case PEP_REFINE_SCHEME_EXPLICIT:
1122:     if (ini) {
1123:       if (matctx->subc) {
1124:         A = matctx->A;
1125:         comm = PetscSubcommChild(matctx->subc);
1126:       } else {
1127:         A = At;
1128:         PetscObjectGetComm((PetscObject)pep,&comm);
1129:       }
1130:       E = matctx->E;
1131:       STGetMatStructure(pep->st,&str);
1132:       MatDuplicate(A[0],MAT_COPY_VALUES,&E[0]);
1133:       j = (matctx->subc)?matctx->subc->color:0;
1134:       PEPEvaluateBasis(pep,H[j+j*ldh],0,coef,NULL);
1135:       for (j=1;j<nmat;j++) {
1136:         MatAXPY(E[0],coef[j],A[j],str);
1137:       }
1138:       MatCreateDense(comm,PETSC_DECIDE,PETSC_DECIDE,k,k,NULL,&E[1]);
1139:       MatAssemblyBegin(E[1],MAT_FINAL_ASSEMBLY);
1140:       MatAssemblyEnd(E[1],MAT_FINAL_ASSEMBLY);
1141:       MatGetOwnershipRange(E[0],&n0,&m0);
1142:       MatGetOwnershipRange(E[1],&n1,&m1);
1143:       MatGetOwnershipRangeColumn(E[0],&n0_,&m0_);
1144:       MatGetOwnershipRangeColumn(E[1],&n1_,&m1_);
1145:       /* T12 and T21 are computed from V and V*, so,
1146:          they must have the same column and row ranges */
1147:       if (m0_-n0_ != m0-n0) SETERRQ(PETSC_COMM_SELF,1,"Inconsistent dimensions");
1148:       MatCreateDense(comm,m0-n0,m1_-n1_,PETSC_DECIDE,PETSC_DECIDE,NULL,&B);
1149:       MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
1150:       MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);
1151:       MatCreateDense(comm,m1-n1,m0_-n0_,PETSC_DECIDE,PETSC_DECIDE,NULL,&C);
1152:       MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
1153:       MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
1154:       SlepcMatTile(1.0,E[0],1.0,B,1.0,C,1.0,E[1],&M);
1155:       MatDestroy(&B);
1156:       MatDestroy(&C);
1157:       matctx->compM1 = PETSC_TRUE;
1158:       MatGetSize(E[0],NULL,&N0);
1159:       MatGetSize(E[1],NULL,&N1);
1160:       MPI_Comm_size(PetscObjectComm((PetscObject)M),&np);
1161:       MatGetOwnershipRanges(E[0],&rgs0);
1162:       MatGetOwnershipRanges(E[1],&rgs1);
1163:       PetscMalloc4(PetscMax(k,N1),&matctx->idxp,N0,&matctx->idxg,N0,&matctx->map0,N1,&matctx->map1);
1164:       /* Create column (and row) mapping */
1165:       for (p=0;p<np;p++) {
1166:         for (j=rgs0[p];j<rgs0[p+1];j++) matctx->map0[j] = j+rgs1[p];
1167:         for (j=rgs1[p];j<rgs1[p+1];j++) matctx->map1[j] = j+rgs0[p+1];
1168:       }
1169:       MatCreateVecs(M,NULL,&matctx->tN);
1170:       MatCreateVecs(matctx->E[1],NULL,&matctx->t1);
1171:       VecDuplicate(matctx->tN,&matctx->ttN);
1172:       if (matctx->subc) {
1173:         MPI_Comm_size(PetscObjectComm((PetscObject)pep),&np);
1174:         count = np*k;
1175:         PetscMalloc2(count,&idx1,count,&idx2);
1176:         VecCreateMPI(PetscObjectComm((PetscObject)pep),m1-n1,PETSC_DECIDE,&matctx->tp);
1177:         VecGetOwnershipRange(matctx->tp,&l0,NULL);
1178:         VecCreateMPI(PetscObjectComm((PetscObject)pep),k,PETSC_DECIDE,&matctx->tpg);
1179:         for (si=0;si<matctx->subc->n;si++) {
1180:           if (matctx->subc->color==si) {
1181:             j=0;
1182:             if (matctx->subc->color==si) {
1183:               for (p=0;p<np;p++) {
1184:                 for (i=n1;i<m1;i++) {
1185:                   idx1[j] = l0+i-n1;
1186:                   idx2[j++] =p*k+i;
1187:                 }
1188:               }
1189:             }
1190:             count = np*(m1-n1);
1191:           } else count =0;
1192:           ISCreateGeneral(PetscObjectComm((PetscObject)pep),count,idx1,PETSC_COPY_VALUES,&is1);
1193:           ISCreateGeneral(PetscObjectComm((PetscObject)pep),count,idx2,PETSC_COPY_VALUES,&is2);
1194:           VecScatterCreate(matctx->tp,is1,matctx->tpg,is2,&matctx->scatterp_id[si]);
1195:           ISDestroy(&is1);
1196:           ISDestroy(&is2);
1197:         }
1198:         PetscFree2(idx1,idx2);
1199:       } else {
1200:         VecScatterCreateToAll(matctx->t1,&matctx->scatterctx,&matctx->vseq);
1201:       }
1202:       P = M;
1203:     } else {
1204:       if (matctx->subc) {
1205:         /* Scatter vectors pep->V */
1206:         for (i=0;i<k;i++) {
1207:           BVGetColumn(pep->V,i,&v);
1208:           VecScatterBegin(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
1209:           VecScatterEnd(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
1210:           BVRestoreColumn(pep->V,i,&v);
1211:           VecGetArrayRead(matctx->tg,&array);
1212:           VecPlaceArray(matctx->t,(const PetscScalar*)array);
1213:           BVInsertVec(matctx->V,i,matctx->t);
1214:           VecResetArray(matctx->t);
1215:           VecRestoreArrayRead(matctx->tg,&array);
1216:         }
1217:       }
1218:     }
1219:     break;
1220:   case PEP_REFINE_SCHEME_MBE:
1221:     if (ini) {
1222:       if (matctx->subc) {
1223:         A = matctx->A;
1224:         comm = PetscSubcommChild(matctx->subc);
1225:       } else {
1226:         matctx->V = pep->V;
1227:         A = At;
1228:         PetscObjectGetComm((PetscObject)pep,&comm);
1229:         MatCreateVecs(pep->A[0],&matctx->t,NULL);
1230:       }
1231:       STGetMatStructure(pep->st,&str);
1232:       MatDuplicate(A[0],MAT_COPY_VALUES,&matctx->M1);
1233:       j = (matctx->subc)?matctx->subc->color:0;
1234:       PEPEvaluateBasis(pep,H[j+j*ldh],0,coef,NULL);
1235:       for (j=1;j<nmat;j++) {
1236:         MatAXPY(matctx->M1,coef[j],A[j],str);
1237:       }
1238:       BVDuplicateResize(matctx->V,PetscMax(k,pep->nmat),&matctx->W);
1239:       BVDuplicateResize(matctx->V,k,&matctx->M2);
1240:       BVDuplicate(matctx->M2,&matctx->M3);
1241:       BVDuplicate(matctx->M2,&matctx->Wt);
1242:       PetscMalloc5(k*k,&matctx->M4,k*k,&matctx->w,k*k,&matctx->wt,k,&matctx->d,k,&matctx->dt);
1243:       matctx->compM1 = PETSC_TRUE;
1244:       M = matctx->M1;
1245:       P = M;
1246:     }
1247:     break;
1248:   case PEP_REFINE_SCHEME_SCHUR:
1249:     if (ini) {
1250:       PetscObjectGetComm((PetscObject)pep,&comm);
1251:       MatGetSize(At[0],&m0,&n0);
1252:       PetscMalloc1(1,&ctx);
1253:       STGetMatStructure(pep->st,&str);
1254:       /* Create a shell matrix to solve the linear system */
1255:       ctx->A = At;
1256:       ctx->V = pep->V;
1257:       ctx->k = k; ctx->nmat = nmat;
1258:       PetscMalloc4(k*k,&ctx->M4,k,&ctx->pM4,2*k*k,&ctx->work,nmat,&ctx->fih);
1259:       PetscMemzero(ctx->M4,k*k*sizeof(PetscScalar));
1260:       MatCreateShell(comm,PETSC_DECIDE,PETSC_DECIDE,m0,n0,ctx,&M);
1261:       MatShellSetOperation(M,MATOP_MULT,(void(*)(void))MatFSMult);
1262:       BVDuplicateResize(ctx->V,PetscMax(k,pep->nmat),&ctx->W);
1263:       BVDuplicateResize(ctx->V,k,&ctx->M2);
1264:       BVDuplicate(ctx->M2,&ctx->M3);
1265:       BVCreateVec(pep->V,&ctx->t);
1266:       MatDuplicate(At[0],MAT_COPY_VALUES,&ctx->M1);
1267:       PEPEvaluateBasis(pep,H[0],0,coef,NULL);
1268:       for (j=1;j<nmat;j++) {
1269:         MatAXPY(ctx->M1,coef[j],At[j],str);
1270:       }
1271:       MatDuplicate(At[0],MAT_COPY_VALUES,&P);
1272:       /* Compute a precond matrix for the system */
1273:       t = H[0];
1274:       PEPEvaluateBasis(pep,t,0,coef,NULL);
1275:       for (j=1;j<nmat;j++) {
1276:         MatAXPY(P,coef[j],At[j],str);
1277:       }
1278:       ctx->compM1 = PETSC_TRUE;
1279:     }
1280:     break;
1281:   }
1282:   if (ini) {
1283:     PEPRefineGetKSP(pep,&pep->refineksp);
1284:     KSPSetErrorIfNotConverged(pep->refineksp,PETSC_TRUE);
1285:     KSPSetOperators(pep->refineksp,M,P);
1286:     KSPSetFromOptions(pep->refineksp);
1287:   }

1289:   if (!ini && matctx && matctx->subc) {
1290:      /* Scatter vectors pep->V */
1291:     for (i=0;i<k;i++) {
1292:       BVGetColumn(pep->V,i,&v);
1293:       VecScatterBegin(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
1294:       VecScatterEnd(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
1295:       BVRestoreColumn(pep->V,i,&v);
1296:       VecGetArrayRead(matctx->tg,&array);
1297:       VecPlaceArray(matctx->t,(const PetscScalar*)array);
1298:       BVInsertVec(matctx->V,i,matctx->t);
1299:       VecResetArray(matctx->t);
1300:       VecRestoreArrayRead(matctx->tg,&array);
1301:     }
1302:    }
1303:   PetscFree(coef);
1304:   if (flg) {
1305:     PetscFree(At);
1306:   }
1307:   return(0);
1308: }

1312: static PetscErrorCode NRefSubcommSetup(PEP pep,PetscInt k,MatExplicitCtx *matctx,PetscInt nsubc)
1313: {
1314:   PetscErrorCode    ierr;
1315:   PetscInt          i,si,j,m0,n0,nloc0,nloc_sub,*idx1,*idx2;
1316:   IS                is1,is2;
1317:   BVType            type;
1318:   Vec               v;
1319:   const PetscScalar *array;
1320:   Mat               *A;
1321:   PetscBool         flg;

1324:   STGetTransform(pep->st,&flg);
1325:   if (flg) {
1326:     PetscMalloc1(pep->nmat,&A);
1327:     for (i=0;i<pep->nmat;i++) {
1328:       STGetTOperators(pep->st,i,&A[i]);
1329:     }
1330:   } else A = pep->A;

1332:   /* Duplicate pep matrices */
1333:   PetscMalloc3(pep->nmat,&matctx->A,nsubc,&matctx->scatter_id,nsubc,&matctx->scatterp_id);
1334:   for (i=0;i<pep->nmat;i++) {
1335:     MatCreateRedundantMatrix(A[i],0,PetscSubcommChild(matctx->subc),MAT_INITIAL_MATRIX,&matctx->A[i]);
1336:   }

1338:   /* Create Scatter */
1339:   MatCreateVecs(matctx->A[0],&matctx->t,NULL);
1340:   MatGetLocalSize(matctx->A[0],&nloc_sub,NULL);
1341:   VecCreateMPI(PetscSubcommContiguousParent(matctx->subc),nloc_sub,PETSC_DECIDE,&matctx->tg);
1342:   BVGetColumn(pep->V,0,&v);
1343:   VecGetOwnershipRange(v,&n0,&m0);
1344:   nloc0 = m0-n0;
1345:   PetscMalloc2(matctx->subc->n*nloc0,&idx1,matctx->subc->n*nloc0,&idx2);
1346:   j = 0;
1347:   for (si=0;si<matctx->subc->n;si++) {
1348:     for (i=n0;i<m0;i++) {
1349:       idx1[j]   = i;
1350:       idx2[j++] = i+pep->n*si;
1351:     }
1352:   }
1353:   ISCreateGeneral(PetscObjectComm((PetscObject)pep),matctx->subc->n*nloc0,idx1,PETSC_COPY_VALUES,&is1);
1354:   ISCreateGeneral(PetscObjectComm((PetscObject)pep),matctx->subc->n*nloc0,idx2,PETSC_COPY_VALUES,&is2);
1355:   VecScatterCreate(v,is1,matctx->tg,is2,&matctx->scatter_sub);
1356:   ISDestroy(&is1);
1357:   ISDestroy(&is2);
1358:   for (si=0;si<matctx->subc->n;si++) {
1359:     j=0;
1360:     for (i=n0;i<m0;i++) {
1361:       idx1[j] = i;
1362:       idx2[j++] = i+pep->n*si;
1363:     }
1364:     ISCreateGeneral(PetscObjectComm((PetscObject)pep),nloc0,idx1,PETSC_COPY_VALUES,&is1);
1365:     ISCreateGeneral(PetscObjectComm((PetscObject)pep),nloc0,idx2,PETSC_COPY_VALUES,&is2);
1366:     VecScatterCreate(v,is1,matctx->tg,is2,&matctx->scatter_id[si]);
1367:     ISDestroy(&is1);
1368:     ISDestroy(&is2);
1369:   }
1370:   BVRestoreColumn(pep->V,0,&v);
1371:   PetscFree2(idx1,idx2);

1373:   /* Duplicate pep->V vecs */
1374:   BVGetType(pep->V,&type);
1375:   BVCreate(PetscSubcommChild(matctx->subc),&matctx->V);
1376:   BVSetType(matctx->V,type);
1377:   BVSetSizesFromVec(matctx->V,matctx->t,k);
1378:   if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) {
1379:     BVDuplicateResize(matctx->V,PetscMax(k,pep->nmat),&matctx->W);
1380:   }
1381:   for (i=0;i<k;i++) {
1382:     BVGetColumn(pep->V,i,&v);
1383:     VecScatterBegin(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
1384:     VecScatterEnd(matctx->scatter_sub,v,matctx->tg,INSERT_VALUES,SCATTER_FORWARD);
1385:     BVRestoreColumn(pep->V,i,&v);
1386:     VecGetArrayRead(matctx->tg,&array);
1387:     VecPlaceArray(matctx->t,(const PetscScalar*)array);
1388:     BVInsertVec(matctx->V,i,matctx->t);
1389:     VecResetArray(matctx->t);
1390:     VecRestoreArrayRead(matctx->tg,&array);
1391:   }

1393:   VecDuplicate(matctx->t,&matctx->Rv);
1394:   VecDuplicate(matctx->t,&matctx->Vi);
1395:   if (flg) {
1396:     PetscFree(A);
1397:   }
1398:   return(0);
1399: }

1403: static PetscErrorCode NRefSubcommDestroy(PEP pep,MatExplicitCtx *matctx)
1404: {
1406:   PetscInt       i;

1409:   VecScatterDestroy(&matctx->scatter_sub);
1410:   for (i=0;i<matctx->subc->n;i++) {
1411:     VecScatterDestroy(&matctx->scatter_id[i]);
1412:   }
1413:   for (i=0;i<pep->nmat;i++) {
1414:     MatDestroy(&matctx->A[i]);
1415:   }
1416:   if (pep->scheme==PEP_REFINE_SCHEME_EXPLICIT) {
1417:     for (i=0;i<matctx->subc->n;i++) {
1418:       VecScatterDestroy(&matctx->scatterp_id[i]);
1419:     }
1420:     VecDestroy(&matctx->tp);
1421:     VecDestroy(&matctx->tpg);
1422:     BVDestroy(&matctx->W);
1423:   }
1424:   PetscFree3(matctx->A,matctx->scatter_id,matctx->scatterp_id);
1425:   BVDestroy(&matctx->V);
1426:   VecDestroy(&matctx->t);
1427:   VecDestroy(&matctx->tg);
1428:   VecDestroy(&matctx->Rv);
1429:   VecDestroy(&matctx->Vi);
1430:   return(0);
1431: }

1435: PetscErrorCode PEPNewtonRefinement_TOAR(PEP pep,PetscScalar sigma,PetscInt *maxits,PetscReal *tol,PetscInt k,PetscScalar *S,PetscInt lds,PetscInt *prs)
1436: {
1437: #if defined(PETSC_MISSING_LAPACK_GETRF) || defined(PETSC_MISSING_LAPACK_GETRI)
1439:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"GETRF/GETRI - Lapack routine is unavailable");
1440: #else
1442:   PetscScalar    *H,*work,*dH,*fH,*dVS;
1443:   PetscInt       ldh,i,j,its=1,nmat=pep->nmat,nsubc=pep->npart,rds;
1444:   PetscBLASInt   k_,ld_,*p,info;
1445:   BV             dV;
1446:   PetscBool      sinvert,flg;
1447:   MatExplicitCtx *matctx=NULL;
1448:   Vec            v;
1449:   Mat            M,P;
1450:   FSubctx        *ctx;

1453:   PetscLogEventBegin(PEP_Refine,pep,0,0,0);
1454:   if (k > pep->n) SETERRQ1(PetscObjectComm((PetscObject)pep),1,"Multiple Refinement available only for invariant pairs of dimension smaller than n=%D",pep->n);
1455:   /* the input tolerance is not being taken into account (by the moment) */
1456:   its = *maxits;
1457:   PetscMalloc3(k*k,&dH,nmat*k*k,&fH,k,&work);
1458:   DSGetLeadingDimension(pep->ds,&ldh);
1459:   DSGetArray(pep->ds,DS_MAT_A,&H);
1460:   DSRestoreArray(pep->ds,DS_MAT_A,&H);
1461:   PetscMalloc1(2*k*k,&dVS);
1462:   STGetTransform(pep->st,&flg);
1463:   if (!flg && pep->st && pep->ops->backtransform) { /* BackTransform */
1464:     PetscBLASIntCast(k,&k_);
1465:     PetscBLASIntCast(ldh,&ld_);
1466:     PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinvert);
1467:     if (sinvert) {
1468:       DSGetArray(pep->ds,DS_MAT_A,&H);
1469:       PetscMalloc1(k,&p);
1470:       PetscStackCallBLAS("LAPACKgetrf",LAPACKgetrf_(&k_,&k_,H,&ld_,p,&info));
1471:       PetscStackCallBLAS("LAPACKgetri",LAPACKgetri_(&k_,H,&ld_,p,work,&k_,&info));
1472:       DSRestoreArray(pep->ds,DS_MAT_A,&H);
1473:       pep->ops->backtransform = NULL;
1474:     }
1475:     if (sigma!=0.0) {
1476:       DSGetArray(pep->ds,DS_MAT_A,&H);
1477:       for (i=0;i<k;i++) H[i+ldh*i] += sigma;
1478:       DSRestoreArray(pep->ds,DS_MAT_A,&H);
1479:       pep->ops->backtransform = NULL;
1480:     }
1481:   }
1482:   if ((pep->scale==PEP_SCALE_BOTH || pep->scale==PEP_SCALE_SCALAR) && pep->sfactor!=1.0) {
1483:     DSGetArray(pep->ds,DS_MAT_A,&H);
1484:     for (j=0;j<k;j++) {
1485:       for (i=0;i<k;i++) H[i+j*ldh] *= pep->sfactor;
1486:     }
1487:     DSRestoreArray(pep->ds,DS_MAT_A,&H);
1488:     if (!flg) {
1489:       /* Restore original values */
1490:       for (i=0;i<pep->nmat;i++){
1491:         pep->pbc[pep->nmat+i] *= pep->sfactor;
1492:         pep->pbc[2*pep->nmat+i] *= pep->sfactor*pep->sfactor;
1493:       }
1494:     }
1495:   }
1496:   if ((pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) && pep->Dr) {
1497:     for (i=0;i<k;i++) {
1498:       BVGetColumn(pep->V,i,&v);
1499:       VecPointwiseMult(v,v,pep->Dr);
1500:       BVRestoreColumn(pep->V,i,&v);
1501:     }
1502:   }
1503:   DSGetArray(pep->ds,DS_MAT_A,&H);

1505:   NRefOrthogStep(pep,k,H,ldh,fH,S,lds,prs);
1506:   /* check if H is in Schur form */
1507:   for (i=0;i<k-1;i++) {
1508:     if (H[i+1+i*ldh]!=0.0) {
1509: #if !defined(PETSC_USES_COMPLEX)
1510:       SETERRQ(PetscObjectComm((PetscObject)pep),1,"Iterative Refinement requires the complex Schur form of the projected matrix");
1511: #else
1512:       SETERRQ(PetscObjectComm((PetscObject)pep),1,"Iterative Refinement requires an upper triangular projected matrix");
1513: #endif
1514:     }
1515:   }
1516:   if (nsubc>k) SETERRQ(PetscObjectComm((PetscObject)pep),1,"Amount of subcommunicators should not be larger than the invariant pair dimension");
1517:   BVSetActiveColumns(pep->V,0,k);
1518:   BVDuplicateResize(pep->V,k,&dV);
1519:   PetscLogObjectParent((PetscObject)pep,(PetscObject)dV);
1520:   if (pep->scheme!=PEP_REFINE_SCHEME_SCHUR) {
1521:     PetscMalloc1(1,&matctx);
1522:     if (nsubc>1) { /* spliting in subcommunicators */
1523:       matctx->subc = pep->refinesubc;
1524:       NRefSubcommSetup(pep,k,matctx,nsubc);
1525:     } else matctx->subc=NULL;
1526:   }

1528:   /* Loop performing iterative refinements */
1529:   for (i=0;i<its;i++) {
1530:     /* Pre-compute the polynomial basis evaluated in H */
1531:     PEPEvaluateBasisforMatrix(pep,nmat,k,H,ldh,fH);
1532:     PEPNRefSetUp(pep,k,H,ldh,matctx,PetscNot(i));
1533:     /* Solve the linear system */
1534:     PEPNRefForwardSubstitution(pep,k,S,lds,H,ldh,fH,dV,dVS,&rds,dH,k,pep->refineksp,matctx);
1535:     /* Update X (=V*S) and H, and orthogonalize [X;X*fH1;...;XfH(deg-1)] */
1536:     PEPNRefUpdateInvPair(pep,k,H,ldh,fH,dH,S,lds,dV,dVS,rds);
1537:   }
1538:   DSRestoreArray(pep->ds,DS_MAT_A,&H);
1539:   if (!flg && sinvert) {
1540:     PetscFree(p);
1541:   }
1542:   PetscFree3(dH,fH,work);
1543:   PetscFree(dVS);
1544:   BVDestroy(&dV);
1545:   switch (pep->scheme) {
1546:   case PEP_REFINE_SCHEME_EXPLICIT:
1547:     for (i=0;i<2;i++) {
1548:       MatDestroy(&matctx->E[i]);
1549:     }
1550:     PetscFree4(matctx->idxp,matctx->idxg,matctx->map0,matctx->map1);
1551:     VecDestroy(&matctx->tN);
1552:     VecDestroy(&matctx->ttN);
1553:     VecDestroy(&matctx->t1);
1554:     if (nsubc>1) {
1555:       NRefSubcommDestroy(pep,matctx);
1556:     } else {
1557:       VecDestroy(&matctx->vseq);
1558:       VecScatterDestroy(&matctx->scatterctx);
1559:     }
1560:     PetscFree(matctx);
1561:     KSPGetOperators(pep->refineksp,&M,NULL);
1562:     MatDestroy(&M);
1563:     break;
1564:   case PEP_REFINE_SCHEME_MBE:
1565:     BVDestroy(&matctx->W);
1566:     BVDestroy(&matctx->Wt);
1567:     BVDestroy(&matctx->M2);
1568:     BVDestroy(&matctx->M3);
1569:     MatDestroy(&matctx->M1);
1570:     VecDestroy(&matctx->t);
1571:     PetscFree5(matctx->M4,matctx->w,matctx->wt,matctx->d,matctx->dt);
1572:     if (nsubc>1) {
1573:       NRefSubcommDestroy(pep,matctx);
1574:     }
1575:     PetscFree(matctx);
1576:     break;
1577:   case PEP_REFINE_SCHEME_SCHUR:
1578:     KSPGetOperators(pep->refineksp,&M,&P);
1579:     MatShellGetContext(M,&ctx);
1580:     PetscFree4(ctx->M4,ctx->pM4,ctx->work,ctx->fih);
1581:     MatDestroy(&ctx->M1);
1582:     BVDestroy(&ctx->M2);
1583:     BVDestroy(&ctx->M3);
1584:     BVDestroy(&ctx->W);
1585:     VecDestroy(&ctx->t);
1586:     PetscFree(ctx);
1587:     MatDestroy(&M);
1588:     MatDestroy(&P);
1589:     break;
1590:   }
1591:   PetscLogEventEnd(PEP_Refine,pep,0,0,0);
1592:   return(0);
1593: #endif
1594: }

slepc-3.7.4/src/pep/impls/krylov/toar/index.html0000644000175000017500000000314213107004621021152 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

ptoar.c
nrefine.c
makefile
slepc-3.7.4/src/pep/impls/krylov/toar/ftn-auto/0000755000175000017500000000000013107004621020712 5ustar jromanjromanslepc-3.7.4/src/pep/impls/krylov/toar/ftn-auto/makefile0000644000175000017500000000036513107004621022416 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = ptoarf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcpep LOCDIR = src/pep/impls/krylov/toar/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/krylov/toar/ftn-auto/ptoarf.c0000644000175000017500000000424713107004621022360 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* ptoar.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define peptoarsetrestart_ PEPTOARSETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peptoarsetrestart_ peptoarsetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peptoargetrestart_ PEPTOARGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peptoargetrestart_ peptoargetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peptoarsetlocking_ PEPTOARSETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peptoarsetlocking_ peptoarsetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peptoargetlocking_ PEPTOARGETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peptoargetlocking_ peptoargetlocking #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL peptoarsetrestart_(PEP pep,PetscReal *keep, int *__ierr ){ *__ierr = PEPTOARSetRestart( (PEP)PetscToPointer((pep) ),*keep); } PETSC_EXTERN void PETSC_STDCALL peptoargetrestart_(PEP pep,PetscReal *keep, int *__ierr ){ *__ierr = PEPTOARGetRestart( (PEP)PetscToPointer((pep) ),keep); } PETSC_EXTERN void PETSC_STDCALL peptoarsetlocking_(PEP pep,PetscBool *lock, int *__ierr ){ *__ierr = PEPTOARSetLocking( (PEP)PetscToPointer((pep) ),*lock); } PETSC_EXTERN void PETSC_STDCALL peptoargetlocking_(PEP pep,PetscBool *lock, int *__ierr ){ *__ierr = PEPTOARGetLocking( (PEP)PetscToPointer((pep) ),lock); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/impls/krylov/toar/ptoar.c0000644000175000017500000012454513107004621020461 0ustar jromanjroman/* SLEPc polynomial eigensolver: "toar" Method: TOAR Algorithm: Two-Level Orthogonal Arnoldi. References: [1] Y. Su, J. Zhang and Z. Bai, "A compact Arnoldi algorithm for polynomial eigenvalue problems", talk presented at RANMEP 2008. [2] C. Campos and J.E. Roman, "Parallel Krylov solvers for the polynomial eigenvalue problem in SLEPc", SIAM J. Sci. Comput. to appear, 2016. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include "../src/pep/impls/krylov/pepkrylov.h" #include static PetscBool cited = PETSC_FALSE; static const char citation[] = "@Article{slepc-pep,\n" " author = \"C. Campos and J. E. Roman\",\n" " title = \"Parallel {Krylov} solvers for the polynomial eigenvalue problem in {SLEPc}\",\n" " journal = \"{SIAM} J. Sci. Comput.\",\n" " volume = \"to appear\",\n" " number = \"\",\n" " pages = \"\",\n" " year = \"2016,\"\n" " doi = \"http://dx.doi.org/10.xxxx/yyyy\"\n" "}\n"; #undef __FUNCT__ #define __FUNCT__ "PEPTOARSNorm2" /* Norm of [sp;sq] */ static PetscErrorCode PEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm) { PetscErrorCode ierr; PetscBLASInt n_,one=1; PetscFunctionBegin; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); *norm = BLASnrm2_(&n_,S,&one); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetUp_TOAR" PetscErrorCode PEPSetUp_TOAR(PEP pep) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscBool shift,sinv,flg,lindep; PetscInt i,lds,deg=pep->nmat-1,j; PetscReal norm; PetscFunctionBegin; pep->lineariz = PETSC_TRUE; ierr = PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);CHKERRQ(ierr); if (!ctx->lock && pep->mpdncv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant"); if (!pep->max_it) pep->max_it = PetscMax(100,2*(pep->nmat-1)*pep->n/pep->ncv); /* Set STSHIFT as the default ST */ if (!((PetscObject)pep->st)->type_name) { ierr = STSetType(pep->st,STSHIFT);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);CHKERRQ(ierr); if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used"); if (!pep->which) { if (sinv) pep->which = PEP_TARGET_MAGNITUDE; else pep->which = PEP_LARGEST_MAGNITUDE; } if (pep->problem_type!=PEP_GENERAL) { ierr = PetscInfo(pep,"Problem type ignored, performing a non-symmetric linearization\n");CHKERRQ(ierr); } if (!ctx->keep) ctx->keep = 0.5; ierr = PEPAllocateSolution(pep,pep->nmat-1);CHKERRQ(ierr); ierr = PEPSetWorkVecs(pep,3);CHKERRQ(ierr); ierr = DSSetType(pep->ds,DSNHEP);CHKERRQ(ierr); ierr = DSSetExtraRow(pep->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(pep->ds,pep->ncv+1);CHKERRQ(ierr); ierr = PEPBasisCoefficients(pep,pep->pbc);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) { ierr = PetscMalloc1(pep->nmat,&pep->solvematcoeffs);CHKERRQ(ierr); if (sinv) { ierr = PEPEvaluateBasis(pep,pep->target,0,pep->solvematcoeffs,NULL);CHKERRQ(ierr); } else { for (i=0;inmat-1;i++) pep->solvematcoeffs[i] = 0.0; pep->solvematcoeffs[pep->nmat-1] = 1.0; } } ctx->ld = pep->ncv+(pep->nmat-1); /* number of rows of each fragment of S */ lds = (pep->nmat-1)*ctx->ld; ierr = PetscCalloc1(lds*ctx->ld,&ctx->S);CHKERRQ(ierr); /* process starting vector */ ctx->nq = 0; for (i=0;inini>-deg) { ierr = BVSetRandomColumn(pep->V,ctx->nq);CHKERRQ(ierr); } else { ierr = BVInsertVec(pep->V,ctx->nq,pep->IS[i]);CHKERRQ(ierr); } ierr = BVOrthogonalizeColumn(pep->V,ctx->nq,ctx->S+i*ctx->ld,&norm,&lindep);CHKERRQ(ierr); if (!lindep) { ierr = BVScaleColumn(pep->V,ctx->nq,1.0/norm);CHKERRQ(ierr); ctx->S[ctx->nq+i*ctx->ld] = norm; ctx->nq++; } } if (ctx->nq==0) SETERRQ(PetscObjectComm((PetscObject)pep),1,"PEP: Problem with initial vector"); ierr = PEPTOARSNorm2(lds,ctx->S,&norm);CHKERRQ(ierr); for (j=0;jS[i+j*ctx->ld] /= norm; } if (pep->nini<0) { ierr = SlepcBasisDestroy_Private(&pep->nini,&pep->IS);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOAROrth2" /* Computes GS orthogonalization [z;x] - [Sp;Sq]*y, where y = ([Sp;Sq]'*[z;x]). k: Column from S to be orthogonalized against previous columns. Sq = Sp+ld dim(work)>=k */ static PetscErrorCode PEPTOAROrth2(PEP pep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work) { PetscErrorCode ierr; PetscBLASInt n_,lds_,k_,one=1; PetscScalar sonem=-1.0,sone=1.0,szero=0.0,*x0,*x,*c; PetscInt i,lds=deg*ld,n; PetscReal eta,onorm; PetscFunctionBegin; ierr = BVGetOrthogonalization(pep->V,NULL,NULL,&eta,NULL);CHKERRQ(ierr); n = k+deg-1; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(deg*ld,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); /* number of vectors to orthogonalize against them */ c = work; x0 = S+k*lds; PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&n_,&k_,&sone,S,&lds_,x0,&one,&szero,y,&one)); for (i=1;inmat,deg=nmat-1,k,j,off=0,lss; Vec v=t_[0],ve=t_[1],q=t_[2]; PetscScalar alpha=1.0,*ss,a; PetscReal *ca=pep->pbc,*cb=pep->pbc+nmat,*cg=pep->pbc+2*nmat; PetscBool flg; PetscFunctionBegin; ierr = BVSetActiveColumns(pep->V,0,nv);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (sinvert) { for (j=0;j1) r[lr+j] = S[j]/ca[0]; if (deg>2) r[2*lr+j] = (S[ls+j]+(sigma-cb[1])*r[lr+j])/ca[1]; } for (k=2;ksfactor; } else { ss = S; lss = ls; off = 0; alpha = -ca[deg-1]; a = 1.0; } ierr = BVMultVec(V,1.0,0.0,v,ss+off*lss);CHKERRQ(ierr); if (pep->Dr) { /* balancing */ ierr = VecPointwiseMult(v,v,pep->Dr);CHKERRQ(ierr); } ierr = STMatMult(pep->st,off,v,q);CHKERRQ(ierr); ierr = VecScale(q,a);CHKERRQ(ierr); for (j=1+off;jDr) { ierr = VecPointwiseMult(v,v,pep->Dr);CHKERRQ(ierr); } ierr = STMatMult(pep->st,j,v,t);CHKERRQ(ierr); a *= pep->sfactor; ierr = VecAXPY(q,a,t);CHKERRQ(ierr); } if (sinvert) { ierr = BVMultVec(V,1.0,0.0,v,ss);CHKERRQ(ierr); if (pep->Dr) { ierr = VecPointwiseMult(v,v,pep->Dr);CHKERRQ(ierr); } ierr = STMatMult(pep->st,deg,v,t);CHKERRQ(ierr); a *= pep->sfactor; ierr = VecAXPY(q,a,t);CHKERRQ(ierr); } else { ierr = BVMultVec(V,1.0,0.0,ve,ss+(deg-1)*lss);CHKERRQ(ierr); if (pep->Dr) { ierr = VecPointwiseMult(ve,ve,pep->Dr);CHKERRQ(ierr); } a *= pep->sfactor; ierr = STMatMult(pep->st,deg-1,ve,t);CHKERRQ(ierr); ierr = VecAXPY(q,a,t);CHKERRQ(ierr); a *= pep->sfactor; } if (flg || !sinvert) alpha /= a; ierr = STMatSolve(pep->st,q,t);CHKERRQ(ierr); ierr = VecScale(t,alpha);CHKERRQ(ierr); if (!sinvert) { if (cg[deg-1]!=0) { ierr = VecAXPY(t,cg[deg-1],v);CHKERRQ(ierr); } if (cb[deg-1]!=0) { ierr = VecAXPY(t,cb[deg-1],ve);CHKERRQ(ierr); } } if (pep->Dr) { ierr = VecPointwiseDivide(t,t,pep->Dr);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARCoefficients" /* Compute TOAR coefficients of the blocks of the new Arnoldi vector computed */ static PetscErrorCode PEPTOARCoefficients(PEP pep,PetscBool sinvert,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x) { PetscInt k,j,nmat=pep->nmat,d=nmat-1; PetscReal *ca=pep->pbc,*cb=pep->pbc+nmat,*cg=pep->pbc+2*nmat; PetscScalar t=1.0,tp=0.0,tt; PetscFunctionBegin; if (sinvert) { for (k=1;knmat-1; PetscInt lds=ld*deg,nqt=*nq; Vec t; PetscReal norm; PetscBool flg,sinvert=PETSC_FALSE,lindep; PetscScalar *x; PetscFunctionBegin; ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) { /* spectral transformation handled by the solver */ ierr = PetscObjectTypeCompareAny((PetscObject)pep->st,&flg,STSINVERT,STSHIFT,"");CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"STtype not supported fr TOAR without transforming matrices"); ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinvert);CHKERRQ(ierr); } for (j=k;jV,nqt,&t);CHKERRQ(ierr); ierr = PEPTOARExtendBasis(pep,sinvert,sigma,S+j*lds,ld,nqt,pep->V,t,S+(j+1)*lds,ld,t_);CHKERRQ(ierr); ierr = BVRestoreColumn(pep->V,nqt,&t);CHKERRQ(ierr); /* orthogonalize */ if (sinvert) x = S+(j+1)*lds; else x = S+(deg-1)*ld+(j+1)*lds; ierr = BVOrthogonalizeColumn(pep->V,nqt,x,&norm,&lindep);CHKERRQ(ierr); if (!lindep) { x[nqt] = norm; ierr = BVScaleColumn(pep->V,nqt,1.0/norm);CHKERRQ(ierr); nqt++; } ierr = PEPTOARCoefficients(pep,sinvert,sigma,nqt-1,S+j*lds,ld,S+(j+1)*lds,ld,x);CHKERRQ(ierr); /* level-2 orthogonalization */ ierr = PEPTOAROrth2(pep,S,ld,deg,j+1,H+j*ldh,&norm,breakdown,work+nwu);CHKERRQ(ierr); H[j+1+ldh*j] = norm; *nq = nqt; if (*breakdown) { *M = j+1; break; } for (p=0;pdeg*cs1)?deg*cs1:rs1; nnc = cs1-lock-newc; nrow = rs1-lock; ierr = PetscMalloc4(deg*newc*nnc,&SS,newc*nnc,&SS2,(rs1+lock+newc)*n,&pU,deg*rs1,&tau);CHKERRQ(ierr); offu = lock*(rs1+1); M = work+nwu; nwu += rs1*cs1*deg; sg = rwork+nrwu; nrwu += n; ierr = PetscMemzero(pU,rs1*n*sizeof(PetscScalar));CHKERRQ(ierr); V = work+nwu; nwu += deg*cs1*n; ierr = PetscBLASIntCast(n,&n_);CHKERRQ(ierr); ierr = PetscBLASIntCast(nnc,&nnc_);CHKERRQ(ierr); ierr = PetscBLASIntCast(cs1,&cs1_);CHKERRQ(ierr); ierr = PetscBLASIntCast(rs1,&rs1_);CHKERRQ(ierr); ierr = PetscBLASIntCast(newc,&newc_);CHKERRQ(ierr); ierr = PetscBLASIntCast(newc*deg,&newctdeg);CHKERRQ(ierr); ierr = PetscBLASIntCast(nnc*deg,&nnctdeg);CHKERRQ(ierr); ierr = PetscBLASIntCast(cs1*deg,&cs1tdeg);CHKERRQ(ierr); ierr = PetscBLASIntCast(lwa-nwu,&lw_);CHKERRQ(ierr); ierr = PetscBLASIntCast(nrow,&nrow_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); if (newc>0) { /* truncate columns associated with new converged eigenpairs */ for (j=0;jtol) rk++; rk = PetscMin(nnc+deg-1,rk); /* the SVD has rank (atmost) nnc+deg-1 */ for (i=0;i0) { for (i=0;iV,lock,rs1);CHKERRQ(ierr); ierr = BVMultInPlace(pep->V,U,lock,rk);CHKERRQ(ierr); ierr = BVSetActiveColumns(pep->V,0,rk);CHKERRQ(ierr); ierr = MatDestroy(&U);CHKERRQ(ierr); *rs1a = rk; /* free work space */ ierr = PetscFree4(SS,SS2,pU,tau);CHKERRQ(ierr); PetscFunctionReturn(0); #endif } #undef __FUNCT__ #define __FUNCT__ "PEPTOARSupdate" /* S <- S*Q columns s-s+ncu of S rows 0-sr of S size(Q) qr x ncu dim(work)=sr*ncu */ static PetscErrorCode PEPTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work) { PetscErrorCode ierr; PetscScalar a=1.0,b=0.0; PetscBLASInt sr_,ncu_,ldq_,lds_,qr_; PetscInt j,lds=deg*ld,i; PetscFunctionBegin; ierr = PetscBLASIntCast(sr,&sr_);CHKERRQ(ierr); ierr = PetscBLASIntCast(qr,&qr_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ncu,&ncu_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldq,&ldq_);CHKERRQ(ierr); for (i=0;ipbc; cb = pep->pbc+pep->nmat; cg = pep->pbc+2*pep->nmat; for (i=0;inmat-1,idxcpy=0; PetscScalar *At,*Bt,*Hj,*Hp,*T,sone=1.0,g,a,*pM; PetscBLASInt k_,sr_,lds_,ldh_,info,*p,lwork,ldt_; PetscBool transf=PETSC_FALSE,flg; PetscReal nrm,norm,maxnrm,*rwork; BV *R,Y; Mat M,*A; Vec v; PetscFunctionBegin; if (k==0) PetscFunctionReturn(0); nw = 6*sr*k; lds = deg*ld; At = work+nwu; nwu += sr*k; Bt = work+nwu; nwu += k*k; ierr = PetscMemzero(Bt,k*k*sizeof(PetscScalar));CHKERRQ(ierr); Hj = work+nwu; nwu += k*k; Hp = work+nwu; nwu += k*k; ierr = PetscMemzero(Hp,k*k*sizeof(PetscScalar));CHKERRQ(ierr); ierr = PetscMalloc1(k,&p);CHKERRQ(ierr); ierr = PetscBLASIntCast(sr,&sr_);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldh,&ldh_);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) { ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&flg);CHKERRQ(ierr); if (flg || sigma!=0.0) transf=PETSC_TRUE; } if (transf) { ldt = k; T = work+nwu; nwu += k*k; for (i=0;iextract) { case PEP_EXTRACT_NONE: break; case PEP_EXTRACT_NORM: if (pep->basis == PEP_BASIS_MONOMIAL) { ierr = PetscBLASIntCast(ldt,&ldt_);CHKERRQ(ierr); ierr = PetscMalloc1(k,&rwork);CHKERRQ(ierr); norm = LAPACKlange_("F",&k_,&k_,T,&ldt_,rwork); PetscFree(rwork);CHKERRQ(ierr); if (norm>1.0) idxcpy = d-1; } else { ierr = PetscBLASIntCast(ldt,&ldt_);CHKERRQ(ierr); ierr = PetscMalloc1(k,&rwork);CHKERRQ(ierr); maxnrm = 0.0; for (i=0;inmat-1;i++) { ierr = PEPEvaluateBasisM(pep,k,T,ldt,i,&Hp,&Hj);CHKERRQ(ierr); norm = LAPACKlange_("F",&k_,&k_,Hj,&k_,rwork); if (norm > maxnrm) { idxcpy = i; maxnrm = norm; } } PetscFree(rwork);CHKERRQ(ierr); } if (idxcpy>0) { /* copy block idxcpy of S to the first one */ for (j=0;jst,&flg);CHKERRQ(ierr); if (flg) { ierr = PetscMalloc1(pep->nmat,&A);CHKERRQ(ierr); for (i=0;inmat;i++) { ierr = STGetTOperators(pep->st,i,A+i);CHKERRQ(ierr); } } else A = pep->A; ierr = PetscMalloc1(pep->nmat-1,&R);CHKERRQ(ierr); for (i=0;inmat-1;i++) { ierr = BVDuplicateResize(pep->V,k,R+i);CHKERRQ(ierr); } ierr = BVDuplicateResize(pep->V,sr,&Y);CHKERRQ(ierr); ierr = MatCreateSeqDense(PETSC_COMM_SELF,sr,k,NULL,&M);CHKERRQ(ierr); g = 0.0; a = 1.0; ierr = BVSetActiveColumns(pep->V,0,sr);CHKERRQ(ierr); for (j=0;jnmat;j++) { ierr = BVMatMult(pep->V,A[j],Y);CHKERRQ(ierr); ierr = PEPEvaluateBasisM(pep,k,T,ldt,i,&Hp,&Hj);CHKERRQ(ierr); for (i=0;inmat-1;i++) { PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&sr_,&k_,&k_,&a,S+i*ld,&lds_,Hj,&k_,&g,At,&sr_)); ierr = MatDenseGetArray(M,&pM);CHKERRQ(ierr); for (jj=0;jjnmat-1;i++) { norm = 0.0; for (j=0;j norm) { maxnrm = norm; idxcpy = i; } } if (idxcpy>0) { /* copy block idxcpy of S to the first one */ for (j=0;jnmat-1;i++) { ierr = BVDestroy(&R[i]);CHKERRQ(ierr); } ierr = PetscFree(R);CHKERRQ(ierr); ierr = BVDestroy(&Y);CHKERRQ(ierr); ierr = MatDestroy(&M);CHKERRQ(ierr); break; case PEP_EXTRACT_STRUCTURED: for (j=0;jdata; PetscInt i,j,k,l,nv=0,ld,lds,off,ldds,newn,nq=ctx->nq,nconv=0,locked=0,newc; PetscInt lwa,lrwa,nwu=0,nrwu=0,nmat=pep->nmat,deg=nmat-1; PetscScalar *S,*Q,*work,*H,sigma; PetscReal beta,*rwork; PetscBool breakdown=PETSC_FALSE,flg,falselock=PETSC_FALSE,sinv=PETSC_FALSE; PetscFunctionBegin; ierr = PetscCitationsRegister(citation,&cited);CHKERRQ(ierr); if (ctx->lock) { ierr = PetscOptionsGetBool(NULL,NULL,"-pep_toar_falselocking",&falselock,NULL);CHKERRQ(ierr); } ld = ctx->ld; S = ctx->S; lds = deg*ld; /* leading dimension of S */ lwa = (deg+6)*ld*lds; lrwa = 7*lds; ierr = PetscMalloc2(lwa,&work,lrwa,&rwork);CHKERRQ(ierr); ierr = DSGetLeadingDimension(pep->ds,&ldds);CHKERRQ(ierr); ierr = STGetShift(pep->st,&sigma);CHKERRQ(ierr); /* update polynomial basis coefficients */ ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (pep->sfactor!=1.0) { for (i=0;ipbc[nmat+i] /= pep->sfactor; pep->pbc[2*nmat+i] /= pep->sfactor*pep->sfactor; } if (!flg) { pep->target /= pep->sfactor; ierr = RGPushScale(pep->rg,1.0/pep->sfactor);CHKERRQ(ierr); ierr = STScaleShift(pep->st,1.0/pep->sfactor);CHKERRQ(ierr); sigma /= pep->sfactor; } else { ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);CHKERRQ(ierr); ierr = RGPushScale(pep->rg,sinv?pep->sfactor:1.0/pep->sfactor);CHKERRQ(ierr); ierr = STScaleShift(pep->st,sinv?pep->sfactor:1.0/pep->sfactor);CHKERRQ(ierr); } } if (flg) sigma = 0.0; /* restart loop */ l = 0; while (pep->reason == PEP_CONVERGED_ITERATING) { pep->its++; /* compute an nv-step Lanczos factorization */ nv = PetscMax(PetscMin(nconv+pep->mpd,pep->ncv),nv); ierr = DSGetArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = PEPTOARrun(pep,sigma,&nq,S,ld,H,ldds,pep->nconv+l,&nv,&breakdown,work+nwu,pep->work);CHKERRQ(ierr); beta = PetscAbsScalar(H[(nv-1)*ldds+nv]); ierr = DSRestoreArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = DSSetDimensions(pep->ds,nv,0,pep->nconv,pep->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(pep->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); } /* solve projected problem */ ierr = DSSolve(pep->ds,pep->eigr,pep->eigi);CHKERRQ(ierr); ierr = DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSUpdateExtraRow(pep->ds);CHKERRQ(ierr); /* check convergence */ ierr = PEPKrylovConvergence(pep,PETSC_FALSE,pep->nconv,nv-pep->nconv,beta,&k);CHKERRQ(ierr); ierr = (*pep->stopping)(pep,pep->its,pep->max_it,k,pep->nev,&pep->reason,pep->stoppingctx);CHKERRQ(ierr); /* update l */ if (pep->reason != PEP_CONVERGED_ITERATING || breakdown) l = 0; else { l = (nv==k)?0:PetscMax(1,(PetscInt)((nv-k)*ctx->keep)); if (!breakdown) { /* prepare the Rayleigh quotient for restart */ ierr = DSTruncate(pep->ds,k+l);CHKERRQ(ierr); ierr = DSGetDimensions(pep->ds,&newn,NULL,NULL,NULL,NULL);CHKERRQ(ierr); l = newn-k; } } nconv = k; if (!ctx->lock && pep->reason == PEP_CONVERGED_ITERATING && !breakdown) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */ /* update S */ off = pep->nconv*ldds; ierr = DSGetArray(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = PEPTOARSupdate(S,ld,deg,nq,pep->nconv,k+l-pep->nconv,nv,Q+off,ldds,work+nwu);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); /* copy last column of S */ ierr = PetscMemcpy(S+lds*(k+l),S+lds*nv,lds*sizeof(PetscScalar));CHKERRQ(ierr); if (breakdown) { /* stop if breakdown */ ierr = PetscInfo2(pep,"Breakdown TOAR method (it=%D norm=%g)\n",pep->its,(double)beta);CHKERRQ(ierr); pep->reason = PEP_DIVERGED_BREAKDOWN; } if (pep->reason != PEP_CONVERGED_ITERATING) {l--; flg = PETSC_TRUE;} else flg = PETSC_FALSE; /* truncate S */ if (k+l+deglock) { newc = k-pep->nconv; ierr = PEPTOARTrunc(pep,S,ld,deg,&nq,k+l+1,locked,newc,flg,work+nwu,rwork+nrwu);CHKERRQ(ierr); locked += newc; } else { ierr = PEPTOARTrunc(pep,S,ld,deg,&nq,k+l+1,0,0,flg,work+nwu,rwork+nrwu);CHKERRQ(ierr); } } pep->nconv = k; ierr = PEPMonitor(pep,pep->its,nconv,pep->eigr,pep->eigi,pep->errest,nv);CHKERRQ(ierr); } if (pep->nconv>0) { /* {V*S_nconv^i}_{i=0}^{d-1} has rank nconv instead of nconv+d-1. Force zeros in each S_nconv^i block */ nq = pep->nconv; /* perform Newton refinement if required */ if (pep->refine==PEP_REFINE_MULTIPLE && pep->rits>0) { /* extract invariant pair */ ierr = DSGetArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = PEPExtractInvariantPair(pep,sigma,nq,pep->nconv,S,ld,deg,H,ldds,work+nwu);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_A,&H);CHKERRQ(ierr); ierr = DSSetDimensions(pep->ds,pep->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = PEPNewtonRefinement_TOAR(pep,sigma,&pep->rits,NULL,pep->nconv,S,lds,&nq);CHKERRQ(ierr); ierr = DSSolve(pep->ds,pep->eigr,pep->eigi);CHKERRQ(ierr); ierr = DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSGetArray(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = PEPTOARSupdate(S,ld,deg,nq,0,pep->nconv,pep->nconv,Q,ldds,work+nwu);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); } else { ierr = DSSetDimensions(pep->ds,pep->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); } } if (pep->refine!=PEP_REFINE_MULTIPLE || pep->rits==0) { ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) { if (pep->ops->backtransform) { ierr = (*pep->ops->backtransform)(pep);CHKERRQ(ierr); } /* restore original values */ pep->target *= pep->sfactor; ierr = STScaleShift(pep->st,pep->sfactor);CHKERRQ(ierr); } else { ierr = STScaleShift(pep->st,sinv?1.0/pep->sfactor:pep->sfactor);CHKERRQ(ierr); } if (pep->sfactor!=1.0) { for (j=0;jnconv;j++) { pep->eigr[j] *= pep->sfactor; pep->eigi[j] *= pep->sfactor; } /* restore original values */ for (i=0;inmat;i++){ pep->pbc[pep->nmat+i] *= pep->sfactor; pep->pbc[2*pep->nmat+i] *= pep->sfactor*pep->sfactor; } } } if (pep->sfactor!=1.0) { ierr = RGPopScale(pep->rg);CHKERRQ(ierr); } /* change the state to raw so that DSVectors() computes eigenvectors from scratch */ ierr = DSSetDimensions(pep->ds,pep->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = PetscFree2(work,rwork);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARSetRestart_TOAR" static PetscErrorCode PEPTOARSetRestart_TOAR(PEP pep,PetscReal keep) { PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscFunctionBegin; if (keep==PETSC_DEFAULT) ctx->keep = 0.5; else { if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]"); ctx->keep = keep; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARSetRestart" /*@ PEPTOARSetRestart - Sets the restart parameter for the TOAR method, in particular the proportion of basis vectors that must be kept after restart. Logically Collective on PEP Input Parameters: + pep - the eigenproblem solver context - keep - the number of vectors to be kept at restart Options Database Key: . -pep_toar_restart - Sets the restart parameter Notes: Allowed values are in the range [0.1,0.9]. The default is 0.5. Level: advanced .seealso: PEPTOARGetRestart() @*/ PetscErrorCode PEPTOARSetRestart(PEP pep,PetscReal keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveReal(pep,keep,2); ierr = PetscTryMethod(pep,"PEPTOARSetRestart_C",(PEP,PetscReal),(pep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARGetRestart_TOAR" static PetscErrorCode PEPTOARGetRestart_TOAR(PEP pep,PetscReal *keep) { PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscFunctionBegin; *keep = ctx->keep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARGetRestart" /*@ PEPTOARGetRestart - Gets the restart parameter used in the TOAR method. Not Collective Input Parameter: . pep - the eigenproblem solver context Output Parameter: . keep - the restart parameter Level: advanced .seealso: PEPTOARSetRestart() @*/ PetscErrorCode PEPTOARGetRestart(PEP pep,PetscReal *keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(keep,2); ierr = PetscUseMethod(pep,"PEPTOARGetRestart_C",(PEP,PetscReal*),(pep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARSetLocking_TOAR" static PetscErrorCode PEPTOARSetLocking_TOAR(PEP pep,PetscBool lock) { PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscFunctionBegin; ctx->lock = lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARSetLocking" /*@ PEPTOARSetLocking - Choose between locking and non-locking variants of the TOAR method. Logically Collective on PEP Input Parameters: + pep - the eigenproblem solver context - lock - true if the locking variant must be selected Options Database Key: . -pep_toar_locking - Sets the locking flag Notes: The default is to lock converged eigenpairs when the method restarts. This behaviour can be changed so that all directions are kept in the working subspace even if already converged to working accuracy (the non-locking variant). Level: advanced .seealso: PEPTOARGetLocking() @*/ PetscErrorCode PEPTOARSetLocking(PEP pep,PetscBool lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveBool(pep,lock,2); ierr = PetscTryMethod(pep,"PEPTOARSetLocking_C",(PEP,PetscBool),(pep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARGetLocking_TOAR" static PetscErrorCode PEPTOARGetLocking_TOAR(PEP pep,PetscBool *lock) { PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscFunctionBegin; *lock = ctx->lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPTOARGetLocking" /*@ PEPTOARGetLocking - Gets the locking flag used in the TOAR method. Not Collective Input Parameter: . pep - the eigenproblem solver context Output Parameter: . lock - the locking flag Level: advanced .seealso: PEPTOARSetLocking() @*/ PetscErrorCode PEPTOARGetLocking(PEP pep,PetscBool *lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(lock,2); ierr = PetscUseMethod(pep,"PEPTOARGetLocking_C",(PEP,PetscBool*),(pep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetFromOptions_TOAR" PetscErrorCode PEPSetFromOptions_TOAR(PetscOptionItems *PetscOptionsObject,PEP pep) { PetscErrorCode ierr; PetscBool flg,lock; PetscReal keep; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"PEP TOAR Options");CHKERRQ(ierr); ierr = PetscOptionsReal("-pep_toar_restart","Proportion of vectors kept after restart","PEPTOARSetRestart",0.5,&keep,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPTOARSetRestart(pep,keep);CHKERRQ(ierr); } ierr = PetscOptionsBool("-pep_toar_locking","Choose between locking and non-locking variants","PEPTOARSetLocking",PETSC_FALSE,&lock,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPTOARSetLocking(pep,lock);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPView_TOAR" PetscErrorCode PEPView_TOAR(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," TOAR: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," TOAR: using the %slocking variant\n",ctx->lock?"":"non-");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPDestroy_TOAR" PetscErrorCode PEPDestroy_TOAR(PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(pep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetLocking_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPCreate_TOAR" PETSC_EXTERN PetscErrorCode PEPCreate_TOAR(PEP pep) { PEP_TOAR *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(pep,&ctx);CHKERRQ(ierr); pep->data = (void*)ctx; ctx->lock = PETSC_TRUE; pep->ops->solve = PEPSolve_TOAR; pep->ops->setup = PEPSetUp_TOAR; pep->ops->setfromoptions = PEPSetFromOptions_TOAR; pep->ops->destroy = PEPDestroy_TOAR; pep->ops->view = PEPView_TOAR; pep->ops->backtransform = PEPBackTransform_Default; pep->ops->computevectors = PEPComputeVectors_Default; pep->ops->extractvectors = PEPExtractVectors_TOAR; pep->ops->reset = PEPReset_TOAR; ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetRestart_C",PEPTOARSetRestart_TOAR);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetRestart_C",PEPTOARGetRestart_TOAR);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARSetLocking_C",PEPTOARSetLocking_TOAR);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPTOARGetLocking_C",PEPTOARGetLocking_TOAR);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/impls/krylov/qarnoldi/0000755000175000017500000000000013107004621020021 5ustar jromanjromanslepc-3.7.4/src/pep/impls/krylov/qarnoldi/makefile0000644000175000017500000000217113107004621021522 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = qarnoldi.c SOURCEF = SOURCEH = LIBBASE = libslepcpep DIRS = MANSEC = PEP LOCDIR = src/pep/impls/krylov/qarnoldi/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/krylov/qarnoldi/qarnoldi.c0000644000175000017500000005147713107004621022014 0ustar jromanjroman/* SLEPc quadratic eigensolver: "qarnoldi" Method: Q-Arnoldi Algorithm: Quadratic Arnoldi with Krylov-Schur type restart. References: [1] K. Meerbergen, "The Quadratic Arnoldi method for the solution of the quadratic eigenvalue problem", SIAM J. Matrix Anal. Appl. 30(4):1462-1482, 2008. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include typedef struct { PetscReal keep; /* restart parameter */ PetscBool lock; /* locking/non-locking variant */ } PEP_QARNOLDI; #undef __FUNCT__ #define __FUNCT__ "PEPSetUp_QArnoldi" PetscErrorCode PEPSetUp_QArnoldi(PEP pep) { PetscErrorCode ierr; PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data; PetscBool shift,sinv,flg; PetscFunctionBegin; pep->lineariz = PETSC_TRUE; ierr = PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);CHKERRQ(ierr); if (!ctx->lock && pep->mpdncv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant"); if (!pep->max_it) pep->max_it = PetscMax(100,4*pep->n/pep->ncv); /* Set STSHIFT as the default ST */ if (!((PetscObject)pep->st)->type_name) { ierr = STSetType(pep->st,STSHIFT);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);CHKERRQ(ierr); if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used"); if (!pep->which) { if (sinv) pep->which = PEP_TARGET_MAGNITUDE; else pep->which = PEP_LARGEST_MAGNITUDE; } if (pep->nmat!=3) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver only available for quadratic problems"); if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver not implemented for non-monomial bases"); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver requires the ST transformation flag set, see STSetTransform()"); /* set default extraction */ if (!pep->extract) { pep->extract = PEP_EXTRACT_NONE; } if (pep->extract!=PEP_EXTRACT_NONE) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver does not support requested extraction"); if (!ctx->keep) ctx->keep = 0.5; ierr = PEPAllocateSolution(pep,0);CHKERRQ(ierr); ierr = PEPSetWorkVecs(pep,4);CHKERRQ(ierr); ierr = DSSetType(pep->ds,DSNHEP);CHKERRQ(ierr); ierr = DSSetExtraRow(pep->ds,PETSC_TRUE);CHKERRQ(ierr); ierr = DSAllocate(pep->ds,pep->ncv+1);CHKERRQ(ierr); /* process starting vector */ if (pep->nini>-2) { ierr = BVSetRandomColumn(pep->V,0);CHKERRQ(ierr); ierr = BVSetRandomColumn(pep->V,1);CHKERRQ(ierr); } else { ierr = BVInsertVec(pep->V,0,pep->IS[0]);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,1,pep->IS[1]);CHKERRQ(ierr); } if (pep->nini<0) { ierr = SlepcBasisDestroy_Private(&pep->nini,&pep->IS);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPExtractVectors_QArnoldi" PetscErrorCode PEPExtractVectors_QArnoldi(PEP pep) { PetscErrorCode ierr; PetscInt i,k=pep->nconv,ldds; PetscScalar *X,*pX0; Mat X0; PetscFunctionBegin; if (pep->nconv==0) PetscFunctionReturn(0); ierr = DSGetLeadingDimension(pep->ds,&ldds);CHKERRQ(ierr); ierr = DSVectors(pep->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetArray(pep->ds,DS_MAT_X,&X);CHKERRQ(ierr); /* update vectors V = V*X */ ierr = MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&X0);CHKERRQ(ierr); ierr = MatDenseGetArray(X0,&pX0);CHKERRQ(ierr); for (i=0;iV,X0,0,k);CHKERRQ(ierr); ierr = MatDestroy(&X0);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_X,&X);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiCGS" /* Compute a step of Classical Gram-Schmidt orthogonalization */ static PetscErrorCode PEPQArnoldiCGS(PEP pep,PetscScalar *H,PetscBLASInt ldh,PetscScalar *h,PetscBLASInt j,BV V,Vec t,Vec v,Vec w,PetscReal *onorm,PetscReal *norm,PetscScalar *work) { PetscErrorCode ierr; PetscBLASInt ione = 1,j_1 = j+1; PetscReal x,y; PetscScalar dot,one = 1.0,zero = 0.0; PetscFunctionBegin; /* compute norm of v and w */ if (onorm) { ierr = VecNorm(v,NORM_2,&x);CHKERRQ(ierr); ierr = VecNorm(w,NORM_2,&y);CHKERRQ(ierr); *onorm = PetscSqrtReal(x*x+y*y); } /* orthogonalize: compute h */ ierr = BVDotVec(V,v,h);CHKERRQ(ierr); ierr = BVDotVec(V,w,work);CHKERRQ(ierr); if (j>0) PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&j_1,&j,&one,H,&ldh,work,&ione,&one,h,&ione)); ierr = VecDot(w,t,&dot);CHKERRQ(ierr); h[j] += dot; /* orthogonalize: update v and w */ ierr = BVMultVec(V,-1.0,1.0,v,h);CHKERRQ(ierr); if (j>0) { PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&j_1,&j,&one,H,&ldh,h,&ione,&zero,work,&ione)); ierr = BVMultVec(V,-1.0,1.0,w,work);CHKERRQ(ierr); } ierr = VecAXPY(w,-h[j],t);CHKERRQ(ierr); /* compute norm of v and w */ if (norm) { ierr = VecNorm(v,NORM_2,&x);CHKERRQ(ierr); ierr = VecNorm(w,NORM_2,&y);CHKERRQ(ierr); *norm = PetscSqrtReal(x*x+y*y);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldi" /* Compute a run of Q-Arnoldi iterations */ static PetscErrorCode PEPQArnoldi(PEP pep,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,Vec v,Vec w,PetscReal *beta,PetscBool *breakdown,PetscScalar *work) { PetscErrorCode ierr; PetscInt i,j,l,m = *M; Vec t = pep->work[2],u = pep->work[3]; BVOrthogRefineType refinement; PetscReal norm=0.0,onorm,eta; PetscScalar *c = work + m; PetscFunctionBegin; ierr = BVGetOrthogonalization(pep->V,NULL,&refinement,&eta,NULL);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,k,v);CHKERRQ(ierr); for (j=k;jDr) { ierr = VecPointwiseMult(v,v,pep->Dr);CHKERRQ(ierr); } ierr = STMatMult(pep->st,0,v,u);CHKERRQ(ierr); ierr = VecCopy(t,v);CHKERRQ(ierr); if (pep->Dr) { ierr = VecPointwiseMult(t,t,pep->Dr);CHKERRQ(ierr); } ierr = STMatMult(pep->st,1,t,w);CHKERRQ(ierr); ierr = VecAXPY(u,pep->sfactor,w);CHKERRQ(ierr); ierr = STMatSolve(pep->st,u,w);CHKERRQ(ierr); ierr = VecScale(w,-1.0/(pep->sfactor*pep->sfactor));CHKERRQ(ierr); if (pep->Dr) { ierr = VecPointwiseDivide(w,w,pep->Dr);CHKERRQ(ierr); } ierr = VecCopy(v,t);CHKERRQ(ierr); ierr = BVSetActiveColumns(pep->V,0,j+1);CHKERRQ(ierr); /* orthogonalize */ switch (refinement) { case BV_ORTHOG_REFINE_NEVER: ierr = PEPQArnoldiCGS(pep,H,ldh,H+ldh*j,j,pep->V,t,v,w,NULL,&norm,work);CHKERRQ(ierr); *breakdown = PETSC_FALSE; break; case BV_ORTHOG_REFINE_ALWAYS: ierr = PEPQArnoldiCGS(pep,H,ldh,H+ldh*j,j,pep->V,t,v,w,NULL,NULL,work);CHKERRQ(ierr); ierr = PEPQArnoldiCGS(pep,H,ldh,c,j,pep->V,t,v,w,&onorm,&norm,work);CHKERRQ(ierr); for (i=0;i<=j;i++) H[ldh*j+i] += c[i]; if (norm < eta * onorm) *breakdown = PETSC_TRUE; else *breakdown = PETSC_FALSE; break; case BV_ORTHOG_REFINE_IFNEEDED: ierr = PEPQArnoldiCGS(pep,H,ldh,H+ldh*j,j,pep->V,t,v,w,&onorm,&norm,work);CHKERRQ(ierr); /* ||q|| < eta ||h|| */ l = 1; while (l<3 && norm < eta * onorm) { l++; onorm = norm; ierr = PEPQArnoldiCGS(pep,H,ldh,c,j,pep->V,t,v,w,NULL,&norm,work);CHKERRQ(ierr); for (i=0;i<=j;i++) H[ldh*j+i] += c[i]; } if (norm < eta * onorm) *breakdown = PETSC_TRUE; else *breakdown = PETSC_FALSE; break; default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of ip->orth_ref"); } ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); ierr = VecScale(w,1.0/norm);CHKERRQ(ierr); H[j+1+ldh*j] = norm; if (jV,j+1,v);CHKERRQ(ierr); } } *beta = norm; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSolve_QArnoldi" PetscErrorCode PEPSolve_QArnoldi(PEP pep) { PetscErrorCode ierr; PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data; PetscInt j,k,l,lwork,nv,ld,newn,nconv; Vec v=pep->work[0],w=pep->work[1]; Mat Q; PetscScalar *S,*work; PetscReal beta=0.0,norm,x,y; PetscBool breakdown=PETSC_FALSE,sinv; PetscFunctionBegin; ierr = DSGetLeadingDimension(pep->ds,&ld);CHKERRQ(ierr); lwork = 7*pep->ncv; ierr = PetscMalloc1(lwork,&work);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);CHKERRQ(ierr); ierr = RGPushScale(pep->rg,sinv?pep->sfactor:1.0/pep->sfactor);CHKERRQ(ierr); ierr = STScaleShift(pep->st,sinv?pep->sfactor:1.0/pep->sfactor);CHKERRQ(ierr); /* Get the starting Arnoldi vector */ ierr = BVCopyVec(pep->V,0,v);CHKERRQ(ierr); ierr = BVCopyVec(pep->V,1,w);CHKERRQ(ierr); ierr = VecNorm(v,NORM_2,&x);CHKERRQ(ierr); ierr = VecNorm(w,NORM_2,&y);CHKERRQ(ierr); norm = PetscSqrtReal(x*x+y*y);CHKERRQ(ierr); ierr = VecScale(v,1.0/norm);CHKERRQ(ierr); ierr = VecScale(w,1.0/norm);CHKERRQ(ierr); /* Restart loop */ l = 0; while (pep->reason == PEP_CONVERGED_ITERATING) { pep->its++; /* Compute an nv-step Arnoldi factorization */ nv = PetscMin(pep->nconv+pep->mpd,pep->ncv); ierr = DSGetArray(pep->ds,DS_MAT_A,&S);CHKERRQ(ierr); ierr = PEPQArnoldi(pep,S,ld,pep->nconv+l,&nv,v,w,&beta,&breakdown,work);CHKERRQ(ierr); ierr = DSRestoreArray(pep->ds,DS_MAT_A,&S);CHKERRQ(ierr); ierr = DSSetDimensions(pep->ds,nv,0,pep->nconv,pep->nconv+l);CHKERRQ(ierr); if (l==0) { ierr = DSSetState(pep->ds,DS_STATE_INTERMEDIATE);CHKERRQ(ierr); } else { ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); } ierr = BVSetActiveColumns(pep->V,pep->nconv,nv);CHKERRQ(ierr); /* Solve projected problem */ ierr = DSSolve(pep->ds,pep->eigr,pep->eigi);CHKERRQ(ierr); ierr = DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);CHKERRQ(ierr); ierr = DSUpdateExtraRow(pep->ds);CHKERRQ(ierr); /* Check convergence */ ierr = PEPKrylovConvergence(pep,PETSC_FALSE,pep->nconv,nv-pep->nconv,beta,&k);CHKERRQ(ierr); ierr = (*pep->stopping)(pep,pep->its,pep->max_it,k,pep->nev,&pep->reason,pep->stoppingctx);CHKERRQ(ierr); nconv = k; /* Update l */ if (pep->reason != PEP_CONVERGED_ITERATING || breakdown) l = 0; else l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep)); if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */ if (pep->reason == PEP_CONVERGED_ITERATING) { if (breakdown) { /* Stop if breakdown */ ierr = PetscInfo2(pep,"Breakdown Quadratic Arnoldi method (it=%D norm=%g)\n",pep->its,(double)beta);CHKERRQ(ierr); pep->reason = PEP_DIVERGED_BREAKDOWN; } else { /* Prepare the Rayleigh quotient for restart */ ierr = DSTruncate(pep->ds,k+l);CHKERRQ(ierr); ierr = DSGetDimensions(pep->ds,&newn,NULL,NULL,NULL,NULL);CHKERRQ(ierr); l = newn-k; } } /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */ ierr = DSGetMat(pep->ds,DS_MAT_Q,&Q);CHKERRQ(ierr); ierr = BVMultInPlace(pep->V,Q,pep->nconv,k+l);CHKERRQ(ierr); ierr = MatDestroy(&Q);CHKERRQ(ierr); pep->nconv = k; ierr = PEPMonitor(pep,pep->its,nconv,pep->eigr,pep->eigi,pep->errest,nv);CHKERRQ(ierr); } for (j=0;jnconv;j++) { pep->eigr[j] *= pep->sfactor; pep->eigi[j] *= pep->sfactor; } ierr = STScaleShift(pep->st,sinv?1.0/pep->sfactor:pep->sfactor);CHKERRQ(ierr); ierr = RGPopScale(pep->rg);CHKERRQ(ierr); /* truncate Schur decomposition and change the state to raw so that DSVectors() computes eigenvectors from scratch */ ierr = DSSetDimensions(pep->ds,pep->nconv,0,0,0);CHKERRQ(ierr); ierr = DSSetState(pep->ds,DS_STATE_RAW);CHKERRQ(ierr); ierr = PetscFree(work);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiSetRestart_QArnoldi" static PetscErrorCode PEPQArnoldiSetRestart_QArnoldi(PEP pep,PetscReal keep) { PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data; PetscFunctionBegin; if (keep==PETSC_DEFAULT) ctx->keep = 0.5; else { if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]"); ctx->keep = keep; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiSetRestart" /*@ PEPQArnoldiSetRestart - Sets the restart parameter for the Q-Arnoldi method, in particular the proportion of basis vectors that must be kept after restart. Logically Collective on PEP Input Parameters: + pep - the eigenproblem solver context - keep - the number of vectors to be kept at restart Options Database Key: . -pep_qarnoldi_restart - Sets the restart parameter Notes: Allowed values are in the range [0.1,0.9]. The default is 0.5. Level: advanced .seealso: PEPQArnoldiGetRestart() @*/ PetscErrorCode PEPQArnoldiSetRestart(PEP pep,PetscReal keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveReal(pep,keep,2); ierr = PetscTryMethod(pep,"PEPQArnoldiSetRestart_C",(PEP,PetscReal),(pep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiGetRestart_QArnoldi" static PetscErrorCode PEPQArnoldiGetRestart_QArnoldi(PEP pep,PetscReal *keep) { PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data; PetscFunctionBegin; *keep = ctx->keep; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiGetRestart" /*@ PEPQArnoldiGetRestart - Gets the restart parameter used in the Q-Arnoldi method. Not Collective Input Parameter: . pep - the eigenproblem solver context Output Parameter: . keep - the restart parameter Level: advanced .seealso: PEPQArnoldiSetRestart() @*/ PetscErrorCode PEPQArnoldiGetRestart(PEP pep,PetscReal *keep) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(keep,2); ierr = PetscUseMethod(pep,"PEPQArnoldiGetRestart_C",(PEP,PetscReal*),(pep,keep));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiSetLocking_QArnoldi" static PetscErrorCode PEPQArnoldiSetLocking_QArnoldi(PEP pep,PetscBool lock) { PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data; PetscFunctionBegin; ctx->lock = lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiSetLocking" /*@ PEPQArnoldiSetLocking - Choose between locking and non-locking variants of the Q-Arnoldi method. Logically Collective on PEP Input Parameters: + pep - the eigenproblem solver context - lock - true if the locking variant must be selected Options Database Key: . -pep_qarnoldi_locking - Sets the locking flag Notes: The default is to keep all directions in the working subspace even if already converged to working accuracy (the non-locking variant). This behaviour can be changed so that converged eigenpairs are locked when the method restarts. Note that the default behaviour is the opposite to Krylov solvers in EPS. Level: advanced .seealso: PEPQArnoldiGetLocking() @*/ PetscErrorCode PEPQArnoldiSetLocking(PEP pep,PetscBool lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveBool(pep,lock,2); ierr = PetscTryMethod(pep,"PEPQArnoldiSetLocking_C",(PEP,PetscBool),(pep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiGetLocking_QArnoldi" static PetscErrorCode PEPQArnoldiGetLocking_QArnoldi(PEP pep,PetscBool *lock) { PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data; PetscFunctionBegin; *lock = ctx->lock; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPQArnoldiGetLocking" /*@ PEPQArnoldiGetLocking - Gets the locking flag used in the Q-Arnoldi method. Not Collective Input Parameter: . pep - the eigenproblem solver context Output Parameter: . lock - the locking flag Level: advanced .seealso: PEPQArnoldiSetLocking() @*/ PetscErrorCode PEPQArnoldiGetLocking(PEP pep,PetscBool *lock) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(lock,2); ierr = PetscUseMethod(pep,"PEPQArnoldiGetLocking_C",(PEP,PetscBool*),(pep,lock));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetFromOptions_QArnoldi" PetscErrorCode PEPSetFromOptions_QArnoldi(PetscOptionItems *PetscOptionsObject,PEP pep) { PetscErrorCode ierr; PetscBool flg,lock; PetscReal keep; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"PEP Q-Arnoldi Options");CHKERRQ(ierr); ierr = PetscOptionsReal("-pep_qarnoldi_restart","Proportion of vectors kept after restart","PEPQArnoldiSetRestart",0.5,&keep,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPQArnoldiSetRestart(pep,keep);CHKERRQ(ierr); } ierr = PetscOptionsBool("-pep_qarnoldi_locking","Choose between locking and non-locking variants","PEPQArnoldiSetLocking",PETSC_FALSE,&lock,&flg);CHKERRQ(ierr); if (flg) { ierr = PEPQArnoldiSetLocking(pep,lock);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPView_QArnoldi" PetscErrorCode PEPView_QArnoldi(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { ierr = PetscViewerASCIIPrintf(viewer," Q-Arnoldi: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Q-Arnoldi: using the %slocking variant\n",ctx->lock?"":"non-");CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPDestroy_QArnoldi" PetscErrorCode PEPDestroy_QArnoldi(PEP pep) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(pep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetRestart_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetLocking_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetLocking_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPCreate_QArnoldi" PETSC_EXTERN PetscErrorCode PEPCreate_QArnoldi(PEP pep) { PEP_QARNOLDI *ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscNewLog(pep,&ctx);CHKERRQ(ierr); pep->data = (void*)ctx; ctx->lock = PETSC_TRUE; pep->ops->solve = PEPSolve_QArnoldi; pep->ops->setup = PEPSetUp_QArnoldi; pep->ops->setfromoptions = PEPSetFromOptions_QArnoldi; pep->ops->destroy = PEPDestroy_QArnoldi; pep->ops->view = PEPView_QArnoldi; pep->ops->backtransform = PEPBackTransform_Default; pep->ops->computevectors = PEPComputeVectors_Default; pep->ops->extractvectors = PEPExtractVectors_QArnoldi; ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetRestart_C",PEPQArnoldiSetRestart_QArnoldi);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetRestart_C",PEPQArnoldiGetRestart_QArnoldi);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetLocking_C",PEPQArnoldiSetLocking_QArnoldi);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetLocking_C",PEPQArnoldiGetLocking_QArnoldi);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/impls/krylov/qarnoldi/makefile.html0000644000175000017500000000471513107004621022473 0ustar jromanjroman

slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = qarnoldi.c
SOURCEF  =
SOURCEH  =
LIBBASE  = libslepcpep
DIRS     =
MANSEC   = PEP
LOCDIR   = src/pep/impls/krylov/qarnoldi/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/pep/impls/krylov/qarnoldi/qarnoldi.c.html0000644000175000017500000013130713107004621022746 0ustar jromanjroman
Actual source code: qarnoldi.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    SLEPc quadratic eigensolver: "qarnoldi"

  5:    Method: Q-Arnoldi

  7:    Algorithm:

  9:        Quadratic Arnoldi with Krylov-Schur type restart.

 11:    References:

 13:        [1] K. Meerbergen, "The Quadratic Arnoldi method for the solution
 14:            of the quadratic eigenvalue problem", SIAM J. Matrix Anal.
 15:            Appl. 30(4):1462-1482, 2008.

 17:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 18:    SLEPc - Scalable Library for Eigenvalue Problem Computations
 19:    Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain

 21:    This file is part of SLEPc.

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

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

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

 37: #include <slepc/private/pepimpl.h>    /*I "slepcpep.h" I*/
 38: #include <petscblaslapack.h>

 40: typedef struct {
 41:   PetscReal keep;         /* restart parameter */
 42:   PetscBool lock;         /* locking/non-locking variant */
 43: } PEP_QARNOLDI;

 47: PetscErrorCode PEPSetUp_QArnoldi(PEP pep)
 48: {
 50:   PEP_QARNOLDI   *ctx = (PEP_QARNOLDI*)pep->data;
 51:   PetscBool      shift,sinv,flg;

 54:   pep->lineariz = PETSC_TRUE;
 55:   PEPSetDimensions_Default(pep,pep->nev,&pep->ncv,&pep->mpd);
 56:   if (!ctx->lock && pep->mpd<pep->ncv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Should not use mpd parameter in non-locking variant");
 57:   if (!pep->max_it) pep->max_it = PetscMax(100,4*pep->n/pep->ncv);
 58:   /* Set STSHIFT as the default ST */
 59:   if (!((PetscObject)pep->st)->type_name) {
 60:     STSetType(pep->st,STSHIFT);
 61:   }
 62:   PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);
 63:   PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);
 64:   if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used");
 65:   if (!pep->which) {
 66:     if (sinv) pep->which = PEP_TARGET_MAGNITUDE;
 67:     else pep->which = PEP_LARGEST_MAGNITUDE;
 68:   }

 70:   if (pep->nmat!=3) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver only available for quadratic problems");
 71:   if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver not implemented for non-monomial bases");
 72:   STGetTransform(pep->st,&flg);
 73:   if (!flg) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver requires the ST transformation flag set, see STSetTransform()");

 75:   /* set default extraction */
 76:   if (!pep->extract) {
 77:     pep->extract = PEP_EXTRACT_NONE;
 78:   }
 79:   if (pep->extract!=PEP_EXTRACT_NONE) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Solver does not support requested extraction");
 80:  
 81:   if (!ctx->keep) ctx->keep = 0.5;

 83:   PEPAllocateSolution(pep,0);
 84:   PEPSetWorkVecs(pep,4);

 86:   DSSetType(pep->ds,DSNHEP);
 87:   DSSetExtraRow(pep->ds,PETSC_TRUE);
 88:   DSAllocate(pep->ds,pep->ncv+1);

 90:   /* process starting vector */
 91:   if (pep->nini>-2) {
 92:     BVSetRandomColumn(pep->V,0);
 93:     BVSetRandomColumn(pep->V,1);
 94:   } else {
 95:     BVInsertVec(pep->V,0,pep->IS[0]);
 96:     BVInsertVec(pep->V,1,pep->IS[1]);
 97:   }
 98:   if (pep->nini<0) {
 99:     SlepcBasisDestroy_Private(&pep->nini,&pep->IS);
100:   }
101:   return(0);
102: }

106: PetscErrorCode PEPExtractVectors_QArnoldi(PEP pep)
107: {
109:   PetscInt       i,k=pep->nconv,ldds;
110:   PetscScalar    *X,*pX0;
111:   Mat            X0;

114:   if (pep->nconv==0) return(0);
115:   DSGetLeadingDimension(pep->ds,&ldds);
116:   DSVectors(pep->ds,DS_MAT_X,NULL,NULL);
117:   DSGetArray(pep->ds,DS_MAT_X,&X);

119:   /* update vectors V = V*X */ 
120:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&X0);
121:   MatDenseGetArray(X0,&pX0);
122:   for (i=0;i<k;i++) {
123:     PetscMemcpy(pX0+i*k,X+i*ldds,k*sizeof(PetscScalar));
124:   }
125:   MatDenseRestoreArray(X0,&pX0);
126:   BVMultInPlace(pep->V,X0,0,k);
127:   MatDestroy(&X0);
128:   DSRestoreArray(pep->ds,DS_MAT_X,&X);
129:   return(0);
130: }

134: /*
135:   Compute a step of Classical Gram-Schmidt orthogonalization
136: */
137: static PetscErrorCode PEPQArnoldiCGS(PEP pep,PetscScalar *H,PetscBLASInt ldh,PetscScalar *h,PetscBLASInt j,BV V,Vec t,Vec v,Vec w,PetscReal *onorm,PetscReal *norm,PetscScalar *work)
138: {
140:   PetscBLASInt   ione = 1,j_1 = j+1;
141:   PetscReal      x,y;
142:   PetscScalar    dot,one = 1.0,zero = 0.0;

145:   /* compute norm of v and w */
146:   if (onorm) {
147:     VecNorm(v,NORM_2,&x);
148:     VecNorm(w,NORM_2,&y);
149:     *onorm = PetscSqrtReal(x*x+y*y);
150:   }

152:   /* orthogonalize: compute h */
153:   BVDotVec(V,v,h);
154:   BVDotVec(V,w,work);
155:   if (j>0)
156:     PetscStackCallBLAS("BLASgemv",BLASgemv_("C",&j_1,&j,&one,H,&ldh,work,&ione,&one,h,&ione));
157:   VecDot(w,t,&dot);
158:   h[j] += dot;

160:   /* orthogonalize: update v and w */
161:   BVMultVec(V,-1.0,1.0,v,h);
162:   if (j>0) {
163:     PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&j_1,&j,&one,H,&ldh,h,&ione,&zero,work,&ione));
164:     BVMultVec(V,-1.0,1.0,w,work);
165:   }
166:   VecAXPY(w,-h[j],t);

168:   /* compute norm of v and w */
169:   if (norm) {
170:     VecNorm(v,NORM_2,&x);
171:     VecNorm(w,NORM_2,&y);
172:     *norm = PetscSqrtReal(x*x+y*y);
173:   }
174:   return(0);
175: }

179: /*
180:   Compute a run of Q-Arnoldi iterations
181: */
182: static PetscErrorCode PEPQArnoldi(PEP pep,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,Vec v,Vec w,PetscReal *beta,PetscBool *breakdown,PetscScalar *work)
183: {
184:   PetscErrorCode     ierr;
185:   PetscInt           i,j,l,m = *M;
186:   Vec                t = pep->work[2],u = pep->work[3];
187:   BVOrthogRefineType refinement;
188:   PetscReal          norm=0.0,onorm,eta;
189:   PetscScalar        *c = work + m;

192:   BVGetOrthogonalization(pep->V,NULL,&refinement,&eta,NULL);
193:   BVInsertVec(pep->V,k,v);
194:   for (j=k;j<m;j++) {
195:     /* apply operator */
196:     VecCopy(w,t);
197:     if (pep->Dr) {
198:       VecPointwiseMult(v,v,pep->Dr);
199:     }
200:     STMatMult(pep->st,0,v,u);
201:     VecCopy(t,v);
202:     if (pep->Dr) {
203:       VecPointwiseMult(t,t,pep->Dr);
204:     }
205:     STMatMult(pep->st,1,t,w);
206:     VecAXPY(u,pep->sfactor,w);
207:     STMatSolve(pep->st,u,w);
208:     VecScale(w,-1.0/(pep->sfactor*pep->sfactor));
209:     if (pep->Dr) {
210:       VecPointwiseDivide(w,w,pep->Dr);
211:     }
212:     VecCopy(v,t);
213:     BVSetActiveColumns(pep->V,0,j+1);

215:     /* orthogonalize */
216:     switch (refinement) {
217:       case BV_ORTHOG_REFINE_NEVER:
218:         PEPQArnoldiCGS(pep,H,ldh,H+ldh*j,j,pep->V,t,v,w,NULL,&norm,work);
219:         *breakdown = PETSC_FALSE;
220:         break;
221:       case BV_ORTHOG_REFINE_ALWAYS:
222:         PEPQArnoldiCGS(pep,H,ldh,H+ldh*j,j,pep->V,t,v,w,NULL,NULL,work);
223:         PEPQArnoldiCGS(pep,H,ldh,c,j,pep->V,t,v,w,&onorm,&norm,work);
224:         for (i=0;i<=j;i++) H[ldh*j+i] += c[i];
225:         if (norm < eta * onorm) *breakdown = PETSC_TRUE;
226:         else *breakdown = PETSC_FALSE;
227:         break;
228:       case BV_ORTHOG_REFINE_IFNEEDED:
229:         PEPQArnoldiCGS(pep,H,ldh,H+ldh*j,j,pep->V,t,v,w,&onorm,&norm,work);
230:         /* ||q|| < eta ||h|| */
231:         l = 1;
232:         while (l<3 && norm < eta * onorm) {
233:           l++;
234:           onorm = norm;
235:           PEPQArnoldiCGS(pep,H,ldh,c,j,pep->V,t,v,w,NULL,&norm,work);
236:           for (i=0;i<=j;i++) H[ldh*j+i] += c[i];
237:         }
238:         if (norm < eta * onorm) *breakdown = PETSC_TRUE;
239:         else *breakdown = PETSC_FALSE;
240:         break;
241:       default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of ip->orth_ref");
242:     }
243:     VecScale(v,1.0/norm);
244:     VecScale(w,1.0/norm);

246:     H[j+1+ldh*j] = norm;
247:     if (j<m-1) {
248:       BVInsertVec(pep->V,j+1,v);
249:     }
250:   }
251:   *beta = norm;
252:   return(0);
253: }

257: PetscErrorCode PEPSolve_QArnoldi(PEP pep)
258: {
260:   PEP_QARNOLDI   *ctx = (PEP_QARNOLDI*)pep->data;
261:   PetscInt       j,k,l,lwork,nv,ld,newn,nconv;
262:   Vec            v=pep->work[0],w=pep->work[1];
263:   Mat            Q;
264:   PetscScalar    *S,*work;
265:   PetscReal      beta=0.0,norm,x,y;
266:   PetscBool      breakdown=PETSC_FALSE,sinv;

269:   DSGetLeadingDimension(pep->ds,&ld);
270:   lwork = 7*pep->ncv;
271:   PetscMalloc1(lwork,&work);
272:   PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);
273:   RGPushScale(pep->rg,sinv?pep->sfactor:1.0/pep->sfactor);
274:   STScaleShift(pep->st,sinv?pep->sfactor:1.0/pep->sfactor);

276:   /* Get the starting Arnoldi vector */
277:   BVCopyVec(pep->V,0,v);
278:   BVCopyVec(pep->V,1,w);
279:   VecNorm(v,NORM_2,&x);
280:   VecNorm(w,NORM_2,&y);
281:   norm = PetscSqrtReal(x*x+y*y);
282:   VecScale(v,1.0/norm);
283:   VecScale(w,1.0/norm);

285:    /* Restart loop */
286:   l = 0;
287:   while (pep->reason == PEP_CONVERGED_ITERATING) {
288:     pep->its++;

290:     /* Compute an nv-step Arnoldi factorization */
291:     nv = PetscMin(pep->nconv+pep->mpd,pep->ncv);
292:     DSGetArray(pep->ds,DS_MAT_A,&S);
293:     PEPQArnoldi(pep,S,ld,pep->nconv+l,&nv,v,w,&beta,&breakdown,work);
294:     DSRestoreArray(pep->ds,DS_MAT_A,&S);
295:     DSSetDimensions(pep->ds,nv,0,pep->nconv,pep->nconv+l);
296:     if (l==0) {
297:       DSSetState(pep->ds,DS_STATE_INTERMEDIATE);
298:     } else {
299:       DSSetState(pep->ds,DS_STATE_RAW);
300:     }
301:     BVSetActiveColumns(pep->V,pep->nconv,nv);

303:     /* Solve projected problem */
304:     DSSolve(pep->ds,pep->eigr,pep->eigi);
305:     DSSort(pep->ds,pep->eigr,pep->eigi,NULL,NULL,NULL);
306:     DSUpdateExtraRow(pep->ds);

308:     /* Check convergence */
309:     PEPKrylovConvergence(pep,PETSC_FALSE,pep->nconv,nv-pep->nconv,beta,&k);
310:     (*pep->stopping)(pep,pep->its,pep->max_it,k,pep->nev,&pep->reason,pep->stoppingctx);
311:     nconv = k;

313:     /* Update l */
314:     if (pep->reason != PEP_CONVERGED_ITERATING || breakdown) l = 0;
315:     else l = PetscMax(1,(PetscInt)((nv-k)*ctx->keep));
316:     if (!ctx->lock && l>0) { l += k; k = 0; } /* non-locking variant: reset no. of converged pairs */

318:     if (pep->reason == PEP_CONVERGED_ITERATING) {
319:       if (breakdown) {
320:         /* Stop if breakdown */
321:         PetscInfo2(pep,"Breakdown Quadratic Arnoldi method (it=%D norm=%g)\n",pep->its,(double)beta);
322:         pep->reason = PEP_DIVERGED_BREAKDOWN;
323:       } else {
324:         /* Prepare the Rayleigh quotient for restart */
325:         DSTruncate(pep->ds,k+l);
326:         DSGetDimensions(pep->ds,&newn,NULL,NULL,NULL,NULL);
327:         l = newn-k;
328:       }
329:     }
330:     /* Update the corresponding vectors V(:,idx) = V*Q(:,idx) */
331:     DSGetMat(pep->ds,DS_MAT_Q,&Q);
332:     BVMultInPlace(pep->V,Q,pep->nconv,k+l);
333:     MatDestroy(&Q);

335:     pep->nconv = k;
336:     PEPMonitor(pep,pep->its,nconv,pep->eigr,pep->eigi,pep->errest,nv);
337:   }

339:   for (j=0;j<pep->nconv;j++) {
340:     pep->eigr[j] *= pep->sfactor;
341:     pep->eigi[j] *= pep->sfactor;
342:   }

344:   STScaleShift(pep->st,sinv?1.0/pep->sfactor:pep->sfactor);
345:   RGPopScale(pep->rg);

347:   /* truncate Schur decomposition and change the state to raw so that
348:      DSVectors() computes eigenvectors from scratch */
349:   DSSetDimensions(pep->ds,pep->nconv,0,0,0);
350:   DSSetState(pep->ds,DS_STATE_RAW);
351:   PetscFree(work);
352:   return(0);
353: }

357: static PetscErrorCode PEPQArnoldiSetRestart_QArnoldi(PEP pep,PetscReal keep)
358: {
359:   PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data;

362:   if (keep==PETSC_DEFAULT) ctx->keep = 0.5;
363:   else {
364:     if (keep<0.1 || keep>0.9) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"The keep argument must be in the range [0.1,0.9]");
365:     ctx->keep = keep;
366:   }
367:   return(0);
368: }

372: /*@
373:    PEPQArnoldiSetRestart - Sets the restart parameter for the Q-Arnoldi
374:    method, in particular the proportion of basis vectors that must be kept
375:    after restart.

377:    Logically Collective on PEP

379:    Input Parameters:
380: +  pep  - the eigenproblem solver context
381: -  keep - the number of vectors to be kept at restart

383:    Options Database Key:
384: .  -pep_qarnoldi_restart - Sets the restart parameter

386:    Notes:
387:    Allowed values are in the range [0.1,0.9]. The default is 0.5.

389:    Level: advanced

391: .seealso: PEPQArnoldiGetRestart()
392: @*/
393: PetscErrorCode PEPQArnoldiSetRestart(PEP pep,PetscReal keep)
394: {

400:   PetscTryMethod(pep,"PEPQArnoldiSetRestart_C",(PEP,PetscReal),(pep,keep));
401:   return(0);
402: }

406: static PetscErrorCode PEPQArnoldiGetRestart_QArnoldi(PEP pep,PetscReal *keep)
407: {
408:   PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data;

411:   *keep = ctx->keep;
412:   return(0);
413: }

417: /*@
418:    PEPQArnoldiGetRestart - Gets the restart parameter used in the Q-Arnoldi method.

420:    Not Collective

422:    Input Parameter:
423: .  pep - the eigenproblem solver context

425:    Output Parameter:
426: .  keep - the restart parameter

428:    Level: advanced

430: .seealso: PEPQArnoldiSetRestart()
431: @*/
432: PetscErrorCode PEPQArnoldiGetRestart(PEP pep,PetscReal *keep)
433: {

439:   PetscUseMethod(pep,"PEPQArnoldiGetRestart_C",(PEP,PetscReal*),(pep,keep));
440:   return(0);
441: }

445: static PetscErrorCode PEPQArnoldiSetLocking_QArnoldi(PEP pep,PetscBool lock)
446: {
447:   PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data;

450:   ctx->lock = lock;
451:   return(0);
452: }

456: /*@
457:    PEPQArnoldiSetLocking - Choose between locking and non-locking variants of
458:    the Q-Arnoldi method.

460:    Logically Collective on PEP

462:    Input Parameters:
463: +  pep  - the eigenproblem solver context
464: -  lock - true if the locking variant must be selected

466:    Options Database Key:
467: .  -pep_qarnoldi_locking - Sets the locking flag

469:    Notes:
470:    The default is to keep all directions in the working subspace even if
471:    already converged to working accuracy (the non-locking variant).
472:    This behaviour can be changed so that converged eigenpairs are locked
473:    when the method restarts.

475:    Note that the default behaviour is the opposite to Krylov solvers in EPS.

477:    Level: advanced

479: .seealso: PEPQArnoldiGetLocking()
480: @*/
481: PetscErrorCode PEPQArnoldiSetLocking(PEP pep,PetscBool lock)
482: {

488:   PetscTryMethod(pep,"PEPQArnoldiSetLocking_C",(PEP,PetscBool),(pep,lock));
489:   return(0);
490: }

494: static PetscErrorCode PEPQArnoldiGetLocking_QArnoldi(PEP pep,PetscBool *lock)
495: {
496:   PEP_QARNOLDI *ctx = (PEP_QARNOLDI*)pep->data;

499:   *lock = ctx->lock;
500:   return(0);
501: }

505: /*@
506:    PEPQArnoldiGetLocking - Gets the locking flag used in the Q-Arnoldi method.

508:    Not Collective

510:    Input Parameter:
511: .  pep - the eigenproblem solver context

513:    Output Parameter:
514: .  lock - the locking flag

516:    Level: advanced

518: .seealso: PEPQArnoldiSetLocking()
519: @*/
520: PetscErrorCode PEPQArnoldiGetLocking(PEP pep,PetscBool *lock)
521: {

527:   PetscUseMethod(pep,"PEPQArnoldiGetLocking_C",(PEP,PetscBool*),(pep,lock));
528:   return(0);
529: }

533: PetscErrorCode PEPSetFromOptions_QArnoldi(PetscOptionItems *PetscOptionsObject,PEP pep)
534: {
536:   PetscBool      flg,lock;
537:   PetscReal      keep;

540:   PetscOptionsHead(PetscOptionsObject,"PEP Q-Arnoldi Options");
541:   PetscOptionsReal("-pep_qarnoldi_restart","Proportion of vectors kept after restart","PEPQArnoldiSetRestart",0.5,&keep,&flg);
542:   if (flg) {
543:     PEPQArnoldiSetRestart(pep,keep);
544:   }
545:   PetscOptionsBool("-pep_qarnoldi_locking","Choose between locking and non-locking variants","PEPQArnoldiSetLocking",PETSC_FALSE,&lock,&flg);
546:   if (flg) {
547:     PEPQArnoldiSetLocking(pep,lock);
548:   }
549:   PetscOptionsTail();
550:   return(0);
551: }

555: PetscErrorCode PEPView_QArnoldi(PEP pep,PetscViewer viewer)
556: {
558:   PEP_QARNOLDI   *ctx = (PEP_QARNOLDI*)pep->data;
559:   PetscBool      isascii;

562:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
563:   if (isascii) {
564:     PetscViewerASCIIPrintf(viewer,"  Q-Arnoldi: %d%% of basis vectors kept after restart\n",(int)(100*ctx->keep));
565:     PetscViewerASCIIPrintf(viewer,"  Q-Arnoldi: using the %slocking variant\n",ctx->lock?"":"non-");
566:   }
567:   return(0);
568: }

572: PetscErrorCode PEPDestroy_QArnoldi(PEP pep)
573: {

577:   PetscFree(pep->data);
578:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetRestart_C",NULL);
579:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetRestart_C",NULL);
580:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetLocking_C",NULL);
581:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetLocking_C",NULL);
582:   return(0);
583: }

587: PETSC_EXTERN PetscErrorCode PEPCreate_QArnoldi(PEP pep)
588: {
589:   PEP_QARNOLDI   *ctx;

593:   PetscNewLog(pep,&ctx);
594:   pep->data = (void*)ctx;
595:   ctx->lock = PETSC_TRUE;

597:   pep->ops->solve          = PEPSolve_QArnoldi;
598:   pep->ops->setup          = PEPSetUp_QArnoldi;
599:   pep->ops->setfromoptions = PEPSetFromOptions_QArnoldi;
600:   pep->ops->destroy        = PEPDestroy_QArnoldi;
601:   pep->ops->view           = PEPView_QArnoldi;
602:   pep->ops->backtransform  = PEPBackTransform_Default;
603:   pep->ops->computevectors = PEPComputeVectors_Default;
604:   pep->ops->extractvectors = PEPExtractVectors_QArnoldi;
605:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetRestart_C",PEPQArnoldiSetRestart_QArnoldi);
606:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetRestart_C",PEPQArnoldiGetRestart_QArnoldi);
607:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiSetLocking_C",PEPQArnoldiSetLocking_QArnoldi);
608:   PetscObjectComposeFunction((PetscObject)pep,"PEPQArnoldiGetLocking_C",PEPQArnoldiGetLocking_QArnoldi);
609:   return(0);
610: }

slepc-3.7.4/src/pep/impls/krylov/qarnoldi/index.html0000644000175000017500000000310513107004621022015 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

qarnoldi.c
makefile
slepc-3.7.4/src/pep/impls/krylov/qarnoldi/ftn-auto/0000755000175000017500000000000013107004621021556 5ustar jromanjromanslepc-3.7.4/src/pep/impls/krylov/qarnoldi/ftn-auto/makefile0000644000175000017500000000037413107004621023262 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = qarnoldif.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcpep LOCDIR = src/pep/impls/krylov/qarnoldi/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/krylov/qarnoldi/ftn-auto/qarnoldif.c0000644000175000017500000000441213107004621023702 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* qarnoldi.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepqarnoldisetrestart_ PEPQARNOLDISETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepqarnoldisetrestart_ pepqarnoldisetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepqarnoldigetrestart_ PEPQARNOLDIGETRESTART #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepqarnoldigetrestart_ pepqarnoldigetrestart #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepqarnoldisetlocking_ PEPQARNOLDISETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepqarnoldisetlocking_ pepqarnoldisetlocking #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define pepqarnoldigetlocking_ PEPQARNOLDIGETLOCKING #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define pepqarnoldigetlocking_ pepqarnoldigetlocking #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL pepqarnoldisetrestart_(PEP pep,PetscReal *keep, int *__ierr ){ *__ierr = PEPQArnoldiSetRestart( (PEP)PetscToPointer((pep) ),*keep); } PETSC_EXTERN void PETSC_STDCALL pepqarnoldigetrestart_(PEP pep,PetscReal *keep, int *__ierr ){ *__ierr = PEPQArnoldiGetRestart( (PEP)PetscToPointer((pep) ),keep); } PETSC_EXTERN void PETSC_STDCALL pepqarnoldisetlocking_(PEP pep,PetscBool *lock, int *__ierr ){ *__ierr = PEPQArnoldiSetLocking( (PEP)PetscToPointer((pep) ),*lock); } PETSC_EXTERN void PETSC_STDCALL pepqarnoldigetlocking_(PEP pep,PetscBool *lock, int *__ierr ){ *__ierr = PEPQArnoldiGetLocking( (PEP)PetscToPointer((pep) ),lock); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/impls/krylov/index.html0000644000175000017500000000331013107004621020202 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP

slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

qarnoldi/
toar/
stoar/
pepkrylov.h
pepkrylov.c
makefile
slepc-3.7.4/src/pep/impls/krylov/pepkrylov.c.html0000644000175000017500000003766613107004621021374 0ustar jromanjroman

Actual source code: pepkrylov.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Common subroutines for all Krylov-type PEP solvers.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>    /*I "slepcpep.h" I*/
 25: #include <slepcblaslapack.h>
 26:  #include pepkrylov.h

 30: PetscErrorCode PEPExtractVectors_TOAR(PEP pep)
 31: {
 33:   PetscInt       i,j,deg=pep->nmat-1,lds,idxcpy=0,ldds,k,ld;
 34:   PetscScalar    *X,*er,*ei,*SS,*vals,*ivals,sone=1.0,szero=0.0,*yi,*yr,*tr,*ti,alpha,t,*S,*pS0;
 35:   PetscBLASInt   k_,lds_,one=1,ldds_;
 36:   PetscBool      flg;
 37:   PetscReal      norm,max,factor=1.0;
 38:   Vec            xr,xi,w[4];
 39:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;
 40:   Mat            S0;

 43:   S = ctx->S;
 44:   ld = ctx->ld;
 45:   k = pep->nconv;
 46:   if (k==0) return(0);
 47:   lds = deg*ld;
 48:   DSGetLeadingDimension(pep->ds,&ldds);
 49:   PetscCalloc5(k,&er,k,&ei,k*k,&SS,pep->nmat,&vals,pep->nmat,&ivals);
 50:   STGetTransform(pep->st,&flg);
 51:   if (flg) factor = pep->sfactor;
 52:   for (i=0;i<k;i++) {
 53:     er[i] = factor*pep->eigr[i];
 54:     ei[i] = factor*pep->eigi[i];
 55:   }
 56:   STBackTransform(pep->st,k,er,ei);

 58:   DSVectors(pep->ds,DS_MAT_X,NULL,NULL);
 59:   DSGetArray(pep->ds,DS_MAT_X,&X);

 61:   PetscBLASIntCast(k,&k_);
 62:   PetscBLASIntCast(lds,&lds_);
 63:   PetscBLASIntCast(ldds,&ldds_);

 65:   if (pep->extract==PEP_EXTRACT_NONE || pep->refine==PEP_REFINE_MULTIPLE) {
 66:     PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,S,&lds_,X,&ldds_,&szero,SS,&k_));
 67:   } else {
 68:     switch (pep->extract) {
 69:     case PEP_EXTRACT_NONE:
 70:       break;
 71:     case PEP_EXTRACT_NORM:
 72:       for (i=0;i<k;i++) {
 73:         PEPEvaluateBasis(pep,er[i],ei[i],vals,ivals);
 74:         max = 1.0;
 75:         for (j=1;j<deg;j++) {
 76:           norm = SlepcAbsEigenvalue(vals[j],ivals[j]);
 77:           if (max < norm) { max = norm; idxcpy = j; }
 78:         }
 79:         PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+idxcpy*ld,&lds_,X+i*ldds,&one,&szero,SS+i*k,&one));
 80: #if !defined(PETSC_USE_COMPLEX)
 81:         if (PetscRealPart(ei[i])!=0.0) {
 82:           i++;
 83:           PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+idxcpy*ld,&lds_,X+i*ldds,&one,&szero,SS+i*k,&one));
 84:         }
 85: #endif
 86:       }
 87:       break;
 88:     case PEP_EXTRACT_RESIDUAL:
 89:       VecDuplicate(pep->work[0],&xr);
 90:       VecDuplicate(pep->work[0],&w[0]);
 91:       VecDuplicate(pep->work[0],&w[1]);
 92: #if !defined(PETSC_USE_COMPLEX)
 93:       VecDuplicate(pep->work[0],&w[2]);
 94:       VecDuplicate(pep->work[0],&w[3]);
 95:       VecDuplicate(pep->work[0],&xi);
 96: #else
 97:       xi = NULL;
 98: #endif
 99:       for (i=0;i<k;i++) {
100:         max = 0.0;
101:         for (j=0;j<deg;j++) {
102:           PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+j*ld,&lds_,X+i*ldds,&one,&szero,SS+i*k,&one));
103:           BVMultVec(pep->V,1.0,0.0,xr,SS+i*k);
104: #if !defined(PETSC_USE_COMPLEX)
105:           PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+j*ld,&lds_,X+(i+1)*ldds,&one,&szero,SS+i*k,&one));
106:           BVMultVec(pep->V,1.0,0.0,xi,SS+i*k);
107: #endif
108:           PEPComputeResidualNorm_Private(pep,er[i],ei[i],xr,xi,w,&norm);
109:           if (norm>max) { max = norm; idxcpy=j; }
110:         }
111:         PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+idxcpy*ld,&lds_,X+i*ldds,&one,&szero,SS+i*k,&one));
112: #if !defined(PETSC_USE_COMPLEX)
113:         if (PetscRealPart(ei[i])!=0.0) {
114:           i++;
115:           PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+idxcpy*ld,&lds_,X+i*ldds,&one,&szero,SS+i*k,&one));
116:         }
117: #endif
118:       }
119:       VecDestroy(&xr);
120:       VecDestroy(&w[0]);
121:       VecDestroy(&w[1]);
122: #if !defined(PETSC_USE_COMPLEX)
123:       VecDestroy(&w[2]);
124:       VecDestroy(&w[3]);
125:       VecDestroy(&xi);
126: #endif
127:       break;
128:     case PEP_EXTRACT_STRUCTURED:
129:       PetscMalloc2(k,&tr,k,&ti);
130:       for (i=0;i<k;i++) {
131:         t = 0.0;
132:         PEPEvaluateBasis(pep,er[i],ei[i],vals,ivals);
133:         yr = X+i*ldds; yi = NULL;
134:         for (j=0;j<deg;j++) {
135:           alpha = PetscConj(vals[j]);
136: #if !defined(PETSC_USE_COMPLEX)
137:           if (ei[i]!=0.0) {
138:             PetscMemzero(tr,k*sizeof(PetscScalar));
139:             PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&k_,&vals[j],X+i*ldds,&one,tr,&one));
140:             PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&k_,&ivals[j],X+(i+1)*ldds,&one,tr,&one));
141:             yr = tr;
142:             PetscMemzero(ti,k*sizeof(PetscScalar));
143:             PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&k_,&vals[j],X+(i+1)*ldds,&one,ti,&one));
144:             alpha = -ivals[j];
145:             PetscStackCallBLAS("BLASaxpy",BLASaxpy_(&k_,&alpha,X+i*ldds,&one,ti,&one));
146:             yi = ti;
147:             alpha = 1.0;
148:           } else { yr = X+i*ldds; yi = NULL; }
149: #endif
150:           PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&alpha,S+j*ld,&lds_,yr,&one,&sone,SS+i*k,&one));
151:           t += SlepcAbsEigenvalue(vals[j],ivals[j])*SlepcAbsEigenvalue(vals[j],ivals[j]);
152:           if (yi) {
153:             PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&alpha,S+j*ld,&lds_,yi,&one,&sone,SS+(i+1)*k,&one));
154:           }
155:         }
156:         t = 1.0/t;
157:         PetscStackCallBLAS("BLASscal",BLASscal_(&k_,&t,SS+i*k,&one));
158:         if (yi) {
159:           PetscStackCallBLAS("BLASscal",BLASscal_(&k_,&t,SS+(i+1)*k,&one));
160:           i++;
161:         }
162:       }
163:       PetscFree2(tr,ti);
164:       break;
165:     default:
166:         SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Extraction not implemented in this solver");
167:     }
168:   }

170:   /* update vectors V = V*S */ 
171:   MatCreateSeqDense(PETSC_COMM_SELF,k,k,NULL,&S0);
172:   MatDenseGetArray(S0,&pS0);
173:   for (i=0;i<k;i++) {
174:     PetscMemcpy(pS0+i*k,SS+i*k,k*sizeof(PetscScalar));
175:   }
176:   MatDenseRestoreArray(S0,&pS0);
177:   BVMultInPlace(pep->V,S0,0,k);
178:   MatDestroy(&S0);
179:   PetscFree5(er,ei,SS,vals,ivals);
180:   return(0);
181: }

185: PetscErrorCode PEPReset_TOAR(PEP pep)
186: {
187:   PEP_TOAR       *ctx = (PEP_TOAR*)pep->data;

191:   PetscFree(ctx->S);
192:   PetscFree(ctx->qB);
193:   return(0);
194: }
slepc-3.7.4/src/pep/impls/krylov/pepkrylov.c0000644000175000017500000001673613107004621020424 0ustar jromanjroman/* Common subroutines for all Krylov-type PEP solvers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include #include "pepkrylov.h" #undef __FUNCT__ #define __FUNCT__ "PEPExtractVectors_TOAR" PetscErrorCode PEPExtractVectors_TOAR(PEP pep) { PetscErrorCode ierr; PetscInt i,j,deg=pep->nmat-1,lds,idxcpy=0,ldds,k,ld; PetscScalar *X,*er,*ei,*SS,*vals,*ivals,sone=1.0,szero=0.0,*yi,*yr,*tr,*ti,alpha,t,*S,*pS0; PetscBLASInt k_,lds_,one=1,ldds_; PetscBool flg; PetscReal norm,max,factor=1.0; Vec xr,xi,w[4]; PEP_TOAR *ctx = (PEP_TOAR*)pep->data; Mat S0; PetscFunctionBegin; S = ctx->S; ld = ctx->ld; k = pep->nconv; if (k==0) PetscFunctionReturn(0); lds = deg*ld; ierr = DSGetLeadingDimension(pep->ds,&ldds);CHKERRQ(ierr); ierr = PetscCalloc5(k,&er,k,&ei,k*k,&SS,pep->nmat,&vals,pep->nmat,&ivals);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg) factor = pep->sfactor; for (i=0;ieigr[i]; ei[i] = factor*pep->eigi[i]; } ierr = STBackTransform(pep->st,k,er,ei);CHKERRQ(ierr); ierr = DSVectors(pep->ds,DS_MAT_X,NULL,NULL);CHKERRQ(ierr); ierr = DSGetArray(pep->ds,DS_MAT_X,&X);CHKERRQ(ierr); ierr = PetscBLASIntCast(k,&k_);CHKERRQ(ierr); ierr = PetscBLASIntCast(lds,&lds_);CHKERRQ(ierr); ierr = PetscBLASIntCast(ldds,&ldds_);CHKERRQ(ierr); if (pep->extract==PEP_EXTRACT_NONE || pep->refine==PEP_REFINE_MULTIPLE) { PetscStackCallBLAS("BLASgemm",BLASgemm_("N","N",&k_,&k_,&k_,&sone,S,&lds_,X,&ldds_,&szero,SS,&k_)); } else { switch (pep->extract) { case PEP_EXTRACT_NONE: break; case PEP_EXTRACT_NORM: for (i=0;iwork[0],&xr);CHKERRQ(ierr); ierr = VecDuplicate(pep->work[0],&w[0]);CHKERRQ(ierr); ierr = VecDuplicate(pep->work[0],&w[1]);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = VecDuplicate(pep->work[0],&w[2]);CHKERRQ(ierr); ierr = VecDuplicate(pep->work[0],&w[3]);CHKERRQ(ierr); ierr = VecDuplicate(pep->work[0],&xi);CHKERRQ(ierr); #else xi = NULL; #endif for (i=0;iV,1.0,0.0,xr,SS+i*k);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+j*ld,&lds_,X+(i+1)*ldds,&one,&szero,SS+i*k,&one)); ierr = BVMultVec(pep->V,1.0,0.0,xi,SS+i*k);CHKERRQ(ierr); #endif ierr = PEPComputeResidualNorm_Private(pep,er[i],ei[i],xr,xi,w,&norm);CHKERRQ(ierr); if (norm>max) { max = norm; idxcpy=j; } } PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+idxcpy*ld,&lds_,X+i*ldds,&one,&szero,SS+i*k,&one)); #if !defined(PETSC_USE_COMPLEX) if (PetscRealPart(ei[i])!=0.0) { i++; PetscStackCallBLAS("BLASgemv",BLASgemv_("N",&k_,&k_,&sone,S+idxcpy*ld,&lds_,X+i*ldds,&one,&szero,SS+i*k,&one)); } #endif } ierr = VecDestroy(&xr);CHKERRQ(ierr); ierr = VecDestroy(&w[0]);CHKERRQ(ierr); ierr = VecDestroy(&w[1]);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = VecDestroy(&w[2]);CHKERRQ(ierr); ierr = VecDestroy(&w[3]);CHKERRQ(ierr); ierr = VecDestroy(&xi);CHKERRQ(ierr); #endif break; case PEP_EXTRACT_STRUCTURED: ierr = PetscMalloc2(k,&tr,k,&ti);CHKERRQ(ierr); for (i=0;iV,S0,0,k);CHKERRQ(ierr); ierr = MatDestroy(&S0);CHKERRQ(ierr); ierr = PetscFree5(er,ei,SS,vals,ivals);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPReset_TOAR" PetscErrorCode PEPReset_TOAR(PEP pep) { PEP_TOAR *ctx = (PEP_TOAR*)pep->data; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFree(ctx->S);CHKERRQ(ierr); ierr = PetscFree(ctx->qB);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/impls/krylov/pepkrylov.h0000644000175000017500000000302613107004621020415 0ustar jromanjroman/* Private header for TOAR and STOAR. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__TOAR_H) #define __TOAR_H typedef struct { PetscReal keep; /* restart parameter */ PetscBool lock; /* locking/non-locking variant */ PetscReal dtol; /* tolerance for deflation */ PetscInt d; /* polynomial degree */ PetscInt ld; /* leading dimension of auxiliary matrices */ PetscInt nq; /* number of TOAR Vectors */ PetscScalar *S,*qB; /* auxiliary matrices */ } PEP_TOAR; #endif PETSC_INTERN PetscErrorCode PEPExtractVectors_TOAR(PEP); PETSC_INTERN PetscErrorCode PEPReset_TOAR(PEP); slepc-3.7.4/src/pep/impls/linear/0000755000175000017500000000000013107004621016134 5ustar jromanjromanslepc-3.7.4/src/pep/impls/linear/makefile0000644000175000017500000000220113107004621017627 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ALL: lib CFLAGS = FFLAGS = SOURCEC = linear.c qeplin.c SOURCEF = SOURCEH = linearp.h LIBBASE = libslepcpep DIRS = MANSEC = PEP LOCDIR = src/pep/impls/linear/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/linear/linear.c.html0000644000175000017500000024613513107004621020530 0ustar jromanjroman
Actual source code: linear.c

slepc-3.7.4 2017-05-17
  1: /*
  2:    Explicit linearization for polynomial eigenproblems.

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

  8:    This file is part of SLEPc.

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

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

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

 24: #include <slepc/private/pepimpl.h>         /*I "slepcpep.h" I*/
 25:  #include linearp.h

 29: static PetscErrorCode MatMult_Linear_Shift(Mat M,Vec x,Vec y)
 30: {
 31:   PetscErrorCode    ierr;
 32:   PEP_LINEAR        *ctx;
 33:   PEP               pep;
 34:   const PetscScalar *px;
 35:   PetscScalar       *py,a,sigma=0.0;
 36:   PetscInt          nmat,deg,i,m;
 37:   Vec               x1,x2,x3,y1,aux;
 38:   PetscReal         *ca,*cb,*cg;
 39:   PetscBool         flg;

 42:   MatShellGetContext(M,(void**)&ctx);
 43:   pep = ctx->pep;
 44:   STGetTransform(pep->st,&flg);
 45:   if (!flg) {
 46:     STGetShift(pep->st,&sigma);
 47:   }
 48:   nmat = pep->nmat;
 49:   deg = nmat-1;
 50:   m = pep->nloc;
 51:   ca = pep->pbc;
 52:   cb = pep->pbc+nmat;
 53:   cg = pep->pbc+2*nmat;
 54:   x1=ctx->w[0];x2=ctx->w[1];x3=ctx->w[2];y1=ctx->w[3];aux=ctx->w[4];
 55:   
 56:   VecSet(y,0.0);
 57:   VecGetArrayRead(x,&px);
 58:   VecGetArray(y,&py);
 59:   a = 1.0;

 61:   /* first block */
 62:   VecPlaceArray(x2,px);
 63:   VecPlaceArray(x3,px+m);
 64:   VecPlaceArray(y1,py);
 65:   VecAXPY(y1,cb[0]-sigma,x2);
 66:   VecAXPY(y1,ca[0],x3);
 67:   VecResetArray(x2);
 68:   VecResetArray(x3);
 69:   VecResetArray(y1);

 71:   /* inner blocks */
 72:   for (i=1;i<deg-1;i++) {
 73:     VecPlaceArray(x1,px+(i-1)*m);
 74:     VecPlaceArray(x2,px+i*m);
 75:     VecPlaceArray(x3,px+(i+1)*m);
 76:     VecPlaceArray(y1,py+i*m);
 77:     VecAXPY(y1,cg[i],x1);
 78:     VecAXPY(y1,cb[i]-sigma,x2);
 79:     VecAXPY(y1,ca[i],x3);
 80:     VecResetArray(x1);
 81:     VecResetArray(x2);
 82:     VecResetArray(x3);
 83:     VecResetArray(y1);
 84:   }

 86:   /* last block */
 87:   VecPlaceArray(y1,py+(deg-1)*m);
 88:   for (i=0;i<deg;i++) {
 89:     VecPlaceArray(x1,px+i*m);
 90:     STMatMult(pep->st,i,x1,aux);
 91:     VecAXPY(y1,a,aux);
 92:     VecResetArray(x1);
 93:     a *= pep->sfactor;
 94:   }
 95:   VecCopy(y1,aux);
 96:   STMatSolve(pep->st,aux,y1);
 97:   VecScale(y1,-ca[deg-1]/a);
 98:   VecPlaceArray(x1,px+(deg-2)*m);
 99:   VecPlaceArray(x2,px+(deg-1)*m);
100:   VecAXPY(y1,cg[deg-1],x1);
101:   VecAXPY(y1,cb[deg-1]-sigma,x2);
102:   VecResetArray(x1);
103:   VecResetArray(x2);
104:   VecResetArray(y1);

106:   VecRestoreArrayRead(x,&px);
107:   VecRestoreArray(y,&py);
108:   return(0);
109: }

113: static PetscErrorCode MatMult_Linear_Sinvert(Mat M,Vec x,Vec y)
114: {
115:   PetscErrorCode    ierr;
116:   PEP_LINEAR        *ctx;
117:   PEP               pep;
118:   const PetscScalar *px;
119:   PetscScalar       *py,a,sigma,t=1.0,tp=0.0,tt;
120:   PetscInt          nmat,deg,i,m;
121:   Vec               x1,y1,y2,y3,aux,aux2;
122:   PetscReal         *ca,*cb,*cg;

125:   MatShellGetContext(M,(void**)&ctx);
126:   pep = ctx->pep;
127:   nmat = pep->nmat;
128:   deg = nmat-1;
129:   m = pep->nloc;
130:   ca = pep->pbc;
131:   cb = pep->pbc+nmat;
132:   cg = pep->pbc+2*nmat;
133:   x1=ctx->w[0];y1=ctx->w[1];y2=ctx->w[2];y3=ctx->w[3];aux=ctx->w[4];aux2=ctx->w[5];
134:   EPSGetTarget(ctx->eps,&sigma);
135:   VecSet(y,0.0);
136:   VecGetArrayRead(x,&px);
137:   VecGetArray(y,&py);
138:   a = pep->sfactor;

140:   /* first block */
141:   VecPlaceArray(x1,px);
142:   VecPlaceArray(y1,py+m);
143:   VecCopy(x1,y1);
144:   VecScale(y1,1.0/ca[0]);
145:   VecResetArray(x1);
146:   VecResetArray(y1);

148:   /* second block */
149:   if (deg>2) {
150:     VecPlaceArray(x1,px+m);
151:     VecPlaceArray(y1,py+m);
152:     VecPlaceArray(y2,py+2*m);
153:     VecCopy(x1,y2);
154:     VecAXPY(y2,sigma-cb[1],y1);
155:     VecScale(y2,1.0/ca[1]);
156:     VecResetArray(x1);
157:     VecResetArray(y1);
158:     VecResetArray(y2);
159:   }

161:   /* inner blocks */
162:   for (i=2;i<deg-1;i++) {
163:     VecPlaceArray(x1,px+i*m);
164:     VecPlaceArray(y1,py+(i-1)*m);
165:     VecPlaceArray(y2,py+i*m);
166:     VecPlaceArray(y3,py+(i+1)*m);
167:     VecCopy(x1,y3);
168:     VecAXPY(y3,sigma-cb[i],y2);
169:     VecAXPY(y3,-cg[i],y1);
170:     VecScale(y3,1.0/ca[i]);
171:     VecResetArray(x1);
172:     VecResetArray(y1);
173:     VecResetArray(y2);
174:     VecResetArray(y3);
175:   }

177:   /* last block */
178:   VecPlaceArray(y1,py);
179:   for (i=0;i<deg-2;i++) {
180:     VecPlaceArray(y2,py+(i+1)*m);
181:     STMatMult(pep->st,i+1,y2,aux);
182:     VecAXPY(y1,a,aux);
183:     VecResetArray(y2);
184:     a *= pep->sfactor;
185:   }
186:   i = deg-2;
187:   VecPlaceArray(y2,py+(i+1)*m);
188:   VecPlaceArray(y3,py+i*m);
189:   VecCopy(y2,aux2);
190:   VecAXPY(aux2,cg[i+1]/ca[i+1],y3);
191:   STMatMult(pep->st,i+1,aux2,aux);
192:   VecAXPY(y1,a,aux);
193:   VecResetArray(y2);
194:   VecResetArray(y3);
195:   a *= pep->sfactor;
196:   i = deg-1;
197:   VecPlaceArray(x1,px+i*m);
198:   VecPlaceArray(y3,py+i*m);
199:   VecCopy(x1,aux2);
200:   VecAXPY(aux2,sigma-cb[i],y3);
201:   VecScale(aux2,1.0/ca[i]);
202:   STMatMult(pep->st,i+1,aux2,aux);
203:   VecAXPY(y1,a,aux);
204:   VecResetArray(x1);
205:   VecResetArray(y3);

207:   VecCopy(y1,aux);
208:   STMatSolve(pep->st,aux,y1);
209:   VecScale(y1,-1.0);

211:   /* final update */
212:   for (i=1;i<deg;i++) {
213:     VecPlaceArray(y2,py+i*m);
214:     tt = t;
215:     t = ((sigma-cb[i-1])*t-cg[i-1]*tp)/ca[i-1]; /* i-th basis polynomial */
216:     tp = tt;
217:     VecAXPY(y2,t,y1);
218:     VecResetArray(y2);
219:   }
220:   VecResetArray(y1);

222:   VecRestoreArrayRead(x,&px);
223:   VecRestoreArray(y,&py);
224:   return(0);
225: }

229: static PetscErrorCode BackTransform_Linear(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
230: {
232:   PEP_LINEAR     *ctx;
233:   ST             stctx;

236:   STShellGetContext(st,(void**)&ctx);
237:   PEPGetST(ctx->pep,&stctx);
238:   STBackTransform(stctx,n,eigr,eigi);
239:   return(0);
240: }

244: static PetscErrorCode Apply_Linear(ST st,Vec x,Vec y)
245: {
247:   PEP_LINEAR     *ctx;

250:   STShellGetContext(st,(void**)&ctx);
251:   MatMult(ctx->A,x,y);
252:   return(0);
253: }

257: PetscErrorCode PEPSetUp_Linear(PEP pep)
258: {
260:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;
261:   ST             st;
262:   PetscInt       i=0,deg=pep->nmat-1;
263:   EPSWhich       which;
264:   EPSProblemType ptype;
265:   PetscBool      trackall,istrivial,transf,shift,sinv,ks;
266:   PetscScalar    sigma,*epsarray,*peparray;
267:   Vec            veps;
268:   /* function tables */
269:   PetscErrorCode (*fcreate[][2])(MPI_Comm,PEP_LINEAR*,Mat*) = {
270:     { MatCreateExplicit_Linear_N1A, MatCreateExplicit_Linear_N1B },   /* N1 */
271:     { MatCreateExplicit_Linear_N2A, MatCreateExplicit_Linear_N2B },   /* N2 */
272:     { MatCreateExplicit_Linear_S1A, MatCreateExplicit_Linear_S1B },   /* S1 */
273:     { MatCreateExplicit_Linear_S2A, MatCreateExplicit_Linear_S2B },   /* S2 */
274:     { MatCreateExplicit_Linear_H1A, MatCreateExplicit_Linear_H1B },   /* H1 */
275:     { MatCreateExplicit_Linear_H2A, MatCreateExplicit_Linear_H2B }    /* H2 */
276:   };

279:   if (pep->stopping!=PEPStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"User-defined stopping test not supported");
280:   pep->lineariz = PETSC_TRUE;
281:   if (!ctx->cform) ctx->cform = 1;
282:   STGetTransform(pep->st,&transf);
283:   /* Set STSHIFT as the default ST */
284:   if (!((PetscObject)pep->st)->type_name) {
285:     STSetType(pep->st,STSHIFT);
286:   }
287:   PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);
288:   PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);
289:   if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used");
290:   if (!pep->which) {
291:     if (sinv) pep->which = PEP_TARGET_MAGNITUDE;
292:     else pep->which = PEP_LARGEST_MAGNITUDE;
293:   }
294:   STSetUp(pep->st);
295:   if (!ctx->eps) { PEPLinearGetEPS(pep,&ctx->eps); }
296:   EPSGetST(ctx->eps,&st);
297:   if (!transf) { EPSSetTarget(ctx->eps,pep->target); }
298:   if (sinv && !transf) { STSetDefaultShift(st,pep->target); }
299:   /* compute scale factor if not set by user */
300:   PEPComputeScaleFactor(pep);

302:   if (ctx->explicitmatrix) {
303:     if (transf) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Explicit matrix option is not implemented with st-transform flag active");
304:     if (pep->nmat!=3) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Explicit matrix option only available for quadratic problems");
305:     if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Explicit matrix option not implemented for non-monomial bases");
306:     if (pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Diagonal scaling not allowed in PEPLINEAR with explicit matrices");
307:     if (sinv && !transf) { STSetType(st,STSINVERT); }
308:     RGPushScale(pep->rg,1.0/pep->sfactor);
309:     STGetTOperators(pep->st,0,&ctx->K);
310:     STGetTOperators(pep->st,1,&ctx->C);
311:     STGetTOperators(pep->st,2,&ctx->M);
312:     ctx->sfactor = pep->sfactor;
313:     ctx->dsfactor = pep->dsfactor;
314:   
315:     MatDestroy(&ctx->A);
316:     MatDestroy(&ctx->B);
317:     VecDestroy(&ctx->w[0]);
318:     VecDestroy(&ctx->w[1]);
319:     VecDestroy(&ctx->w[2]);
320:     VecDestroy(&ctx->w[3]);
321:   
322:     switch (pep->problem_type) {
323:       case PEP_GENERAL:    i = 0; break;
324:       case PEP_HERMITIAN:  i = 2; break;
325:       case PEP_GYROSCOPIC: i = 4; break;
326:       default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of pep->problem_type");
327:     }
328:     i += ctx->cform-1;

330:     (*fcreate[i][0])(PetscObjectComm((PetscObject)pep),ctx,&ctx->A);
331:     (*fcreate[i][1])(PetscObjectComm((PetscObject)pep),ctx,&ctx->B);
332:     PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->A);
333:     PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->B);

335:   } else {   /* implicit matrix */
336:     if (pep->problem_type!=PEP_GENERAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Must use the explicit matrix option if problem type is not general");
337:     if (!((PetscObject)(ctx->eps))->type_name) {
338:       EPSSetType(ctx->eps,EPSKRYLOVSCHUR);
339:     } else {
340:       PetscObjectTypeCompare((PetscObject)ctx->eps,EPSKRYLOVSCHUR,&ks);
341:       if (!ks) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Implicit matrix option only implemented for Krylov-Schur");
342:     }
343:     if (ctx->cform!=1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Implicit matrix option not available for 2nd companion form");
344:     STSetType(st,STSHELL);
345:     STShellSetContext(st,(PetscObject)ctx);
346:     if (!transf) { STShellSetBackTransform(st,BackTransform_Linear); }
347:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[0]);
348:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[1]);
349:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[2]);
350:     VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[3]);
351:     MatCreateVecs(pep->A[0],&ctx->w[4],NULL);
352:     MatCreateVecs(pep->A[0],&ctx->w[5],NULL);
353:     PetscLogObjectParents(pep,6,ctx->w);
354:     MatCreateShell(PetscObjectComm((PetscObject)pep),deg*pep->nloc,deg*pep->nloc,deg*pep->n,deg*pep->n,ctx,&ctx->A);
355:     if (sinv && !transf) {
356:       MatShellSetOperation(ctx->A,MATOP_MULT,(void(*)(void))MatMult_Linear_Sinvert);
357:     } else {
358:       MatShellSetOperation(ctx->A,MATOP_MULT,(void(*)(void))MatMult_Linear_Shift);
359:     }
360:     STShellSetApply(st,Apply_Linear);
361:     PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->A);
362:     ctx->pep = pep;

364:     PEPBasisCoefficients(pep,pep->pbc);
365:     if (!transf) {
366:       PetscMalloc1(pep->nmat,&pep->solvematcoeffs);
367:       if (sinv) {
368:         PEPEvaluateBasis(pep,pep->target,0,pep->solvematcoeffs,NULL);
369:       } else {
370:         for (i=0;i<deg;i++) pep->solvematcoeffs[i] = 0.0;
371:         pep->solvematcoeffs[deg] = 1.0;
372:       }
373:       STScaleShift(pep->st,1.0/pep->sfactor);
374:       RGPushScale(pep->rg,1.0/pep->sfactor);
375:     }
376:     if (pep->sfactor!=1.0) {
377:       for (i=0;i<pep->nmat;i++) {
378:         pep->pbc[pep->nmat+i] /= pep->sfactor;
379:         pep->pbc[2*pep->nmat+i] /= pep->sfactor*pep->sfactor; 
380:       }
381:     }
382:   }

384:   EPSSetOperators(ctx->eps,ctx->A,ctx->B);
385:   EPSGetProblemType(ctx->eps,&ptype);
386:   if (!ptype) {
387:     if (ctx->explicitmatrix) {
388:       EPSSetProblemType(ctx->eps,EPS_GNHEP);
389:     } else {
390:       EPSSetProblemType(ctx->eps,EPS_NHEP);
391:     }
392:   }
393:   if (transf) which = EPS_LARGEST_MAGNITUDE;
394:   else {
395:     switch (pep->which) {
396:         case PEP_LARGEST_MAGNITUDE:  which = EPS_LARGEST_MAGNITUDE; break;
397:         case PEP_SMALLEST_MAGNITUDE: which = EPS_SMALLEST_MAGNITUDE; break;
398:         case PEP_LARGEST_REAL:       which = EPS_LARGEST_REAL; break;
399:         case PEP_SMALLEST_REAL:      which = EPS_SMALLEST_REAL; break;
400:         case PEP_LARGEST_IMAGINARY:  which = EPS_LARGEST_IMAGINARY; break;
401:         case PEP_SMALLEST_IMAGINARY: which = EPS_SMALLEST_IMAGINARY; break;
402:         case PEP_TARGET_MAGNITUDE:   which = EPS_TARGET_MAGNITUDE; break;
403:         case PEP_TARGET_REAL:        which = EPS_TARGET_REAL; break;
404:         case PEP_TARGET_IMAGINARY:   which = EPS_TARGET_IMAGINARY; break;
405:         case PEP_WHICH_USER:         which = EPS_WHICH_USER;
406:           EPSSetEigenvalueComparison(ctx->eps,pep->sc->comparison,pep->sc->comparisonctx);
407:           break;
408:         default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of which");
409:     }
410:   }
411:   EPSSetWhichEigenpairs(ctx->eps,which);

413:   EPSSetDimensions(ctx->eps,pep->nev,pep->ncv?pep->ncv:PETSC_DEFAULT,pep->mpd?pep->mpd:PETSC_DEFAULT);
414:   EPSSetTolerances(ctx->eps,pep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:pep->tol,pep->max_it?pep->max_it:PETSC_DEFAULT);
415:   RGIsTrivial(pep->rg,&istrivial);
416:   if (!istrivial) {
417:     if (transf) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"PEPLINEAR does not support a nontrivial region with st-transform");
418:     EPSSetRG(ctx->eps,pep->rg);
419:   }
420:   /* Transfer the trackall option from pep to eps */
421:   PEPGetTrackAll(pep,&trackall);
422:   EPSSetTrackAll(ctx->eps,trackall);

424:   /* temporary change of target */
425:   if (pep->sfactor!=1.0) {
426:     EPSGetTarget(ctx->eps,&sigma);
427:     EPSSetTarget(ctx->eps,sigma/pep->sfactor);
428:   }

430:   /* process initial vector */
431:   if (pep->nini<=-deg) {
432:     VecCreateMPI(PetscObjectComm((PetscObject)ctx->eps),deg*pep->nloc,deg*pep->n,&veps);
433:     VecGetArray(veps,&epsarray);
434:     for (i=0;i<deg;i++) {
435:       VecGetArray(pep->IS[i],&peparray);
436:       PetscMemcpy(epsarray+i*pep->nloc,peparray,pep->nloc*sizeof(PetscScalar));
437:       VecRestoreArray(pep->IS[i],&peparray);
438:     }
439:     VecRestoreArray(veps,&epsarray);
440:     EPSSetInitialSpace(ctx->eps,1,&veps);
441:     VecDestroy(&veps);
442:   }
443:   if (pep->nini<0) {
444:     SlepcBasisDestroy_Private(&pep->nini,&pep->IS);
445:   }

447:   EPSSetUp(ctx->eps);
448:   EPSGetDimensions(ctx->eps,NULL,&pep->ncv,&pep->mpd);
449:   EPSGetTolerances(ctx->eps,NULL,&pep->max_it);
450:   if (pep->nini>0) { PetscInfo(pep,"Ignoring initial vectors\n"); }
451:   PEPAllocateSolution(pep,0);
452:   return(0);
453: }

457: /*
458:    PEPLinearExtract_Residual - Auxiliary routine that copies the solution of the
459:    linear eigenproblem to the PEP object. The eigenvector of the generalized
460:    problem is supposed to be
461:                                z = [  x  ]
462:                                    [ l*x ]
463:    The eigenvector is taken from z(1:n) or z(n+1:2*n) depending on the explicitly
464:    computed residual norm.
465:    Finally, x is normalized so that ||x||_2 = 1.
466: */
467: static PetscErrorCode PEPLinearExtract_Residual(PEP pep,EPS eps)
468: {
469:   PetscErrorCode    ierr;
470:   PetscInt          i,k;
471:   const PetscScalar *px;
472:   PetscScalar       *er=pep->eigr,*ei=pep->eigi;
473:   PetscReal         rn1,rn2;
474:   Vec               xr,xi=NULL,wr;
475:   Mat               A;
476: #if !defined(PETSC_USE_COMPLEX)
477:   Vec               wi;
478:   const PetscScalar *py;
479: #endif

482: #if defined(PETSC_USE_COMPLEX)
483:   PEPSetWorkVecs(pep,2);
484: #else
485:   PEPSetWorkVecs(pep,4);
486: #endif
487:   EPSGetOperators(eps,&A,NULL);
488:   MatCreateVecs(A,&xr,NULL);
489:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&wr);
490: #if !defined(PETSC_USE_COMPLEX)
491:   VecDuplicate(xr,&xi);
492:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&wi);
493: #endif
494:   for (i=0;i<pep->nconv;i++) {
495:     EPSGetEigenpair(eps,i,NULL,NULL,xr,xi);
496: #if !defined(PETSC_USE_COMPLEX)
497:     if (ei[i]!=0.0) {   /* complex conjugate pair */
498:       VecGetArrayRead(xr,&px);
499:       VecGetArrayRead(xi,&py);
500:       VecPlaceArray(wr,px);
501:       VecPlaceArray(wi,py);
502:       SlepcVecNormalize(wr,wi,PETSC_TRUE,NULL);
503:       PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,wi,pep->work,&rn1);
504:       BVInsertVec(pep->V,i,wr);
505:       BVInsertVec(pep->V,i+1,wi);
506:       for (k=1;k<pep->nmat-1;k++) {
507:         VecResetArray(wr);
508:         VecResetArray(wi);
509:         VecPlaceArray(wr,px+k*pep->nloc);
510:         VecPlaceArray(wi,py+k*pep->nloc);
511:         SlepcVecNormalize(wr,wi,PETSC_TRUE,NULL);
512:         PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,wi,pep->work,&rn2);
513:         if (rn1>rn2) {
514:           BVInsertVec(pep->V,i,wr);
515:           BVInsertVec(pep->V,i+1,wi);
516:           rn1 = rn2;
517:         }
518:       }
519:       VecResetArray(wr);
520:       VecResetArray(wi);
521:       VecRestoreArrayRead(xr,&px);
522:       VecRestoreArrayRead(xi,&py);
523:       i++;
524:     } else   /* real eigenvalue */
525: #endif
526:     {
527:       VecGetArrayRead(xr,&px);
528:       VecPlaceArray(wr,px);
529:       SlepcVecNormalize(wr,NULL,PETSC_FALSE,NULL);
530:       PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,NULL,pep->work,&rn1);
531:       BVInsertVec(pep->V,i,wr);
532:       for (k=1;k<pep->nmat-1;k++) {
533:         VecResetArray(wr);
534:         VecPlaceArray(wr,px+k*pep->nloc);
535:         SlepcVecNormalize(wr,NULL,PETSC_FALSE,NULL);
536:         PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,NULL,pep->work,&rn2);
537:         if (rn1>rn2) {
538:           BVInsertVec(pep->V,i,wr);
539:           rn1 = rn2;
540:         }
541:       }
542:       VecResetArray(wr);
543:       VecRestoreArrayRead(xr,&px);
544:     }
545:   }
546:   VecDestroy(&wr);
547:   VecDestroy(&xr);
548: #if !defined(PETSC_USE_COMPLEX)
549:   VecDestroy(&wi);
550:   VecDestroy(&xi);
551: #endif
552:   return(0);
553: }

557: /*
558:    PEPLinearExtract_None - Same as PEPLinearExtract_Norm but always takes
559:    the first block.
560: */
561: static PetscErrorCode PEPLinearExtract_None(PEP pep,EPS eps)
562: {
563:   PetscErrorCode    ierr;
564:   PetscInt          i;
565:   const PetscScalar *px;
566:   Mat               A;
567:   Vec               xr,xi,w;
568: #if !defined(PETSC_USE_COMPLEX)
569:   PetscScalar       *ei=pep->eigi;
570: #endif

573:   EPSGetOperators(eps,&A,NULL);
574:   MatCreateVecs(A,&xr,NULL);
575:   VecDuplicate(xr,&xi);
576:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&w);
577:   for (i=0;i<pep->nconv;i++) {
578:     EPSGetEigenpair(eps,i,NULL,NULL,xr,xi);
579: #if !defined(PETSC_USE_COMPLEX)
580:     if (ei[i]!=0.0) {   /* complex conjugate pair */
581:       VecGetArrayRead(xr,&px);
582:       VecPlaceArray(w,px);
583:       BVInsertVec(pep->V,i,w);
584:       VecResetArray(w);
585:       VecRestoreArrayRead(xr,&px);
586:       VecGetArrayRead(xi,&px);
587:       VecPlaceArray(w,px);
588:       BVInsertVec(pep->V,i+1,w);
589:       VecResetArray(w);
590:       VecRestoreArrayRead(xi,&px);
591:       i++;
592:     } else   /* real eigenvalue */
593: #endif
594:     {
595:       VecGetArrayRead(xr,&px);
596:       VecPlaceArray(w,px);
597:       BVInsertVec(pep->V,i,w);
598:       VecResetArray(w);
599:       VecRestoreArrayRead(xr,&px);
600:     }
601:   }
602:   VecDestroy(&w);
603:   VecDestroy(&xr);
604:   VecDestroy(&xi);
605:   return(0);
606: }

610: /*
611:    PEPLinearExtract_Norm - Auxiliary routine that copies the solution of the
612:    linear eigenproblem to the PEP object. The eigenvector of the generalized
613:    problem is supposed to be
614:                                z = [  x  ]
615:                                    [ l*x ]
616:    If |l|<1.0, the eigenvector is taken from z(1:n), otherwise from z(n+1:2*n).
617:    Finally, x is normalized so that ||x||_2 = 1.
618: */
619: static PetscErrorCode PEPLinearExtract_Norm(PEP pep,EPS eps)
620: {
621:   PetscErrorCode    ierr;
622:   PetscInt          i,offset;
623:   const PetscScalar *px;
624:   PetscScalar       *er=pep->eigr;
625:   Mat               A;
626:   Vec               xr,xi=NULL,w;
627: #if !defined(PETSC_USE_COMPLEX)
628:   PetscScalar       *ei=pep->eigi;
629: #endif

632:   EPSGetOperators(eps,&A,NULL);
633:   MatCreateVecs(A,&xr,NULL);
634: #if !defined(PETSC_USE_COMPLEX)
635:   VecDuplicate(xr,&xi);
636: #endif
637:   VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&w);
638:   for (i=0;i<pep->nconv;i++) {
639:     EPSGetEigenpair(eps,i,NULL,NULL,xr,xi);
640:     if (SlepcAbsEigenvalue(er[i],ei[i])>1.0) offset = (pep->nmat-2)*pep->nloc;
641:     else offset = 0;
642: #if !defined(PETSC_USE_COMPLEX)
643:     if (ei[i]!=0.0) {   /* complex conjugate pair */
644:       VecGetArrayRead(xr,&px);
645:       VecPlaceArray(w,px+offset);
646:       BVInsertVec(pep->V,i,w);
647:       VecResetArray(w);
648:       VecRestoreArrayRead(xr,&px);
649:       VecGetArrayRead(xi,&px);
650:       VecPlaceArray(w,px+offset);
651:       BVInsertVec(pep->V,i+1,w);
652:       VecResetArray(w);
653:       VecRestoreArrayRead(xi,&px);
654:       i++;
655:     } else /* real eigenvalue */
656: #endif
657:     {
658:       VecGetArrayRead(xr,&px);
659:       VecPlaceArray(w,px+offset);
660:       BVInsertVec(pep->V,i,w);
661:       VecResetArray(w);
662:       VecRestoreArrayRead(xr,&px);
663:     }
664:   }
665:   VecDestroy(&w);
666:   VecDestroy(&xr);
667: #if !defined(PETSC_USE_COMPLEX)
668:   VecDestroy(&xi);
669: #endif
670:   return(0);
671: }

675: PetscErrorCode PEPExtractVectors_Linear(PEP pep)
676: {
678:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;
679:   
681:   switch (pep->extract) {
682:   case PEP_EXTRACT_NONE:
683:     PEPLinearExtract_None(pep,ctx->eps);
684:     break;
685:   case PEP_EXTRACT_NORM:
686:     PEPLinearExtract_Norm(pep,ctx->eps);
687:     break;
688:   case PEP_EXTRACT_RESIDUAL:
689:     PEPLinearExtract_Residual(pep,ctx->eps);
690:     break;
691:   default:
692:     SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Extraction not implemented in this solver");
693:   }
694:   return(0);
695: }

699: PetscErrorCode PEPSolve_Linear(PEP pep)
700: {
702:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;
703:   PetscScalar    sigma;
704:   PetscBool      flg;
705:   PetscInt       i;

708:   EPSSolve(ctx->eps);
709:   EPSGetConverged(ctx->eps,&pep->nconv);
710:   EPSGetIterationNumber(ctx->eps,&pep->its);
711:   EPSGetConvergedReason(ctx->eps,(EPSConvergedReason*)&pep->reason);

713:   /* recover eigenvalues */
714:   for (i=0;i<pep->nconv;i++) {
715:     EPSGetEigenpair(ctx->eps,i,&pep->eigr[i],&pep->eigi[i],NULL,NULL);
716:     pep->eigr[i] *= pep->sfactor;
717:     pep->eigi[i] *= pep->sfactor;
718:   }

720:   /* restore target */
721:   EPSGetTarget(ctx->eps,&sigma);
722:   EPSSetTarget(ctx->eps,sigma*pep->sfactor);

724:   STGetTransform(pep->st,&flg);
725:   if (flg && pep->ops->backtransform) {
726:     (*pep->ops->backtransform)(pep);
727:   }
728:   if (pep->sfactor!=1.0) {
729:     /* Restore original values */
730:     for (i=0;i<pep->nmat;i++){
731:       pep->pbc[pep->nmat+i] *= pep->sfactor;
732:       pep->pbc[2*pep->nmat+i] *= pep->sfactor*pep->sfactor;
733:     }
734:     if (!flg && !ctx->explicitmatrix) {
735:       STScaleShift(pep->st,pep->sfactor);
736:     } 
737:   }
738:   if (ctx->explicitmatrix) {
739:     RGPopScale(pep->rg);
740:   }
741:   return(0);
742: }

746: static PetscErrorCode EPSMonitor_Linear(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)
747: {
748:   PEP            pep = (PEP)ctx;

752:   PEPMonitor(pep,its,nconv,eigr,eigi,errest,nest);
753:   return(0);
754: }

758: PetscErrorCode PEPSetFromOptions_Linear(PetscOptionItems *PetscOptionsObject,PEP pep)
759: {
761:   PetscBool      set,val;
762:   PetscInt       i;
763:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;

766:   PetscOptionsHead(PetscOptionsObject,"PEP Linear Options");
767:   PetscOptionsInt("-pep_linear_cform","Number of the companion form","PEPLinearSetCompanionForm",ctx->cform,&i,&set);
768:   if (set) {
769:     PEPLinearSetCompanionForm(pep,i);
770:   }
771:   PetscOptionsBool("-pep_linear_explicitmatrix","Use explicit matrix in linearization","PEPLinearSetExplicitMatrix",ctx->explicitmatrix,&val,&set);
772:   if (set) {
773:     PEPLinearSetExplicitMatrix(pep,val);
774:   }
775:   if (!ctx->eps) { PEPLinearGetEPS(pep,&ctx->eps); }
776:   EPSSetFromOptions(ctx->eps);
777:   PetscOptionsTail();
778:   return(0);
779: }

783: static PetscErrorCode PEPLinearSetCompanionForm_Linear(PEP pep,PetscInt cform)
784: {
785:   PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data;

788:   if (!cform) return(0);
789:   if (cform==PETSC_DECIDE || cform==PETSC_DEFAULT) ctx->cform = 1;
790:   else {
791:     if (cform!=1 && cform!=2) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid value of argument 'cform'");
792:     ctx->cform = cform;
793:   }
794:   return(0);
795: }

799: /*@
800:    PEPLinearSetCompanionForm - Choose between the two companion forms available
801:    for the linearization of a quadratic eigenproblem.

803:    Logically Collective on PEP

805:    Input Parameters:
806: +  pep   - polynomial eigenvalue solver
807: -  cform - 1 or 2 (first or second companion form)

809:    Options Database Key:
810: .  -pep_linear_cform <int> - Choose the companion form

812:    Level: advanced

814: .seealso: PEPLinearGetCompanionForm()
815: @*/
816: PetscErrorCode PEPLinearSetCompanionForm(PEP pep,PetscInt cform)
817: {

823:   PetscTryMethod(pep,"PEPLinearSetCompanionForm_C",(PEP,PetscInt),(pep,cform));
824:   return(0);
825: }

829: static PetscErrorCode PEPLinearGetCompanionForm_Linear(PEP pep,PetscInt *cform)
830: {
831:   PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data;

834:   *cform = ctx->cform;
835:   return(0);
836: }

840: /*@
841:    PEPLinearGetCompanionForm - Returns the number of the companion form that
842:    will be used for the linearization of a quadratic eigenproblem.

844:    Not Collective

846:    Input Parameter:
847: .  pep  - polynomial eigenvalue solver

849:    Output Parameter:
850: .  cform - the companion form number (1 or 2)

852:    Level: advanced

854: .seealso: PEPLinearSetCompanionForm()
855: @*/
856: PetscErrorCode PEPLinearGetCompanionForm(PEP pep,PetscInt *cform)
857: {

863:   PetscUseMethod(pep,"PEPLinearGetCompanionForm_C",(PEP,PetscInt*),(pep,cform));
864:   return(0);
865: }

869: static PetscErrorCode PEPLinearSetExplicitMatrix_Linear(PEP pep,PetscBool explicitmatrix)
870: {
871:   PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data;

874:   ctx->explicitmatrix = explicitmatrix;
875:   return(0);
876: }

880: /*@
881:    PEPLinearSetExplicitMatrix - Indicate if the matrices A and B for the
882:    linearization of the problem must be built explicitly.

884:    Logically Collective on PEP

886:    Input Parameters:
887: +  pep      - polynomial eigenvalue solver
888: -  explicit - boolean flag indicating if the matrices are built explicitly

890:    Options Database Key:
891: .  -pep_linear_explicitmatrix <boolean> - Indicates the boolean flag

893:    Level: advanced

895: .seealso: PEPLinearGetExplicitMatrix()
896: @*/
897: PetscErrorCode PEPLinearSetExplicitMatrix(PEP pep,PetscBool explicitmatrix)
898: {

904:   PetscTryMethod(pep,"PEPLinearSetExplicitMatrix_C",(PEP,PetscBool),(pep,explicitmatrix));
905:   return(0);
906: }

910: static PetscErrorCode PEPLinearGetExplicitMatrix_Linear(PEP pep,PetscBool *explicitmatrix)
911: {
912:   PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data;

915:   *explicitmatrix = ctx->explicitmatrix;
916:   return(0);
917: }

921: /*@
922:    PEPLinearGetExplicitMatrix - Returns the flag indicating if the matrices
923:    A and B for the linearization are built explicitly.

925:    Not Collective

927:    Input Parameter:
928: .  pep  - polynomial eigenvalue solver

930:    Output Parameter:
931: .  explicitmatrix - the mode flag

933:    Level: advanced

935: .seealso: PEPLinearSetExplicitMatrix()
936: @*/
937: PetscErrorCode PEPLinearGetExplicitMatrix(PEP pep,PetscBool *explicitmatrix)
938: {

944:   PetscUseMethod(pep,"PEPLinearGetExplicitMatrix_C",(PEP,PetscBool*),(pep,explicitmatrix));
945:   return(0);
946: }

950: static PetscErrorCode PEPLinearSetEPS_Linear(PEP pep,EPS eps)
951: {
953:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;

956:   PetscObjectReference((PetscObject)eps);
957:   EPSDestroy(&ctx->eps);
958:   ctx->eps = eps;
959:   PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->eps);
960:   pep->state = PEP_STATE_INITIAL;
961:   return(0);
962: }

966: /*@
967:    PEPLinearSetEPS - Associate an eigensolver object (EPS) to the
968:    polynomial eigenvalue solver.

970:    Collective on PEP

972:    Input Parameters:
973: +  pep - polynomial eigenvalue solver
974: -  eps - the eigensolver object

976:    Level: advanced

978: .seealso: PEPLinearGetEPS()
979: @*/
980: PetscErrorCode PEPLinearSetEPS(PEP pep,EPS eps)
981: {

988:   PetscTryMethod(pep,"PEPLinearSetEPS_C",(PEP,EPS),(pep,eps));
989:   return(0);
990: }

994: static PetscErrorCode PEPLinearGetEPS_Linear(PEP pep,EPS *eps)
995: {
997:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;
998:   ST             st;

1001:   if (!ctx->eps) {
1002:     EPSCreate(PetscObjectComm((PetscObject)pep),&ctx->eps);
1003:     EPSSetOptionsPrefix(ctx->eps,((PetscObject)pep)->prefix);
1004:     EPSAppendOptionsPrefix(ctx->eps,"pep_linear_");
1005:     EPSGetST(ctx->eps,&st);
1006:     STSetOptionsPrefix(st,((PetscObject)ctx->eps)->prefix);
1007:     PetscObjectIncrementTabLevel((PetscObject)ctx->eps,(PetscObject)pep,1);
1008:     PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->eps);
1009:     EPSMonitorSet(ctx->eps,EPSMonitor_Linear,pep,NULL);
1010:   }
1011:   *eps = ctx->eps;
1012:   return(0);
1013: }

1017: /*@
1018:    PEPLinearGetEPS - Retrieve the eigensolver object (EPS) associated
1019:    to the polynomial eigenvalue solver.

1021:    Not Collective

1023:    Input Parameter:
1024: .  pep - polynomial eigenvalue solver

1026:    Output Parameter:
1027: .  eps - the eigensolver object

1029:    Level: advanced

1031: .seealso: PEPLinearSetEPS()
1032: @*/
1033: PetscErrorCode PEPLinearGetEPS(PEP pep,EPS *eps)
1034: {

1040:   PetscUseMethod(pep,"PEPLinearGetEPS_C",(PEP,EPS*),(pep,eps));
1041:   return(0);
1042: }

1046: PetscErrorCode PEPView_Linear(PEP pep,PetscViewer viewer)
1047: {
1049:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;
1050:   PetscBool      isascii;

1053:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);
1054:   if (isascii) {
1055:     if (!ctx->eps) { PEPLinearGetEPS(pep,&ctx->eps); }
1056:     PetscViewerASCIIPrintf(viewer,"  Linear: %s matrices\n",ctx->explicitmatrix? "explicit": "implicit");
1057:     PetscViewerASCIIPrintf(viewer,"  Linear: %s companion form\n",ctx->cform==1? "1st": "2nd");
1058:     PetscViewerASCIIPushTab(viewer);
1059:     EPSView(ctx->eps,viewer);
1060:     PetscViewerASCIIPopTab(viewer);
1061:   }
1062:   return(0);
1063: }

1067: PetscErrorCode PEPReset_Linear(PEP pep)
1068: {
1070:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;

1073:   if (!ctx->eps) { EPSReset(ctx->eps); }
1074:   MatDestroy(&ctx->A);
1075:   MatDestroy(&ctx->B);
1076:   VecDestroy(&ctx->w[0]);
1077:   VecDestroy(&ctx->w[1]);
1078:   VecDestroy(&ctx->w[2]);
1079:   VecDestroy(&ctx->w[3]);
1080:   VecDestroy(&ctx->w[4]);
1081:   VecDestroy(&ctx->w[5]);
1082:   return(0);
1083: }

1087: PetscErrorCode PEPDestroy_Linear(PEP pep)
1088: {
1090:   PEP_LINEAR     *ctx = (PEP_LINEAR*)pep->data;

1093:   EPSDestroy(&ctx->eps);
1094:   PetscFree(pep->data);
1095:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetCompanionForm_C",NULL);
1096:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetCompanionForm_C",NULL);
1097:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetEPS_C",NULL);
1098:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetEPS_C",NULL);
1099:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetExplicitMatrix_C",NULL);
1100:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetExplicitMatrix_C",NULL);
1101:   return(0);
1102: }

1106: PETSC_EXTERN PetscErrorCode PEPCreate_Linear(PEP pep)
1107: {
1109:   PEP_LINEAR     *ctx;

1112:   PetscNewLog(pep,&ctx);
1113:   ctx->explicitmatrix = PETSC_FALSE;
1114:   pep->data = (void*)ctx;

1116:   pep->ops->solve          = PEPSolve_Linear;
1117:   pep->ops->setup          = PEPSetUp_Linear;
1118:   pep->ops->setfromoptions = PEPSetFromOptions_Linear;
1119:   pep->ops->destroy        = PEPDestroy_Linear;
1120:   pep->ops->reset          = PEPReset_Linear;
1121:   pep->ops->view           = PEPView_Linear;
1122:   pep->ops->backtransform  = PEPBackTransform_Default;
1123:   pep->ops->computevectors = PEPComputeVectors_Default;
1124:   pep->ops->extractvectors = PEPExtractVectors_Linear;
1125:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetCompanionForm_C",PEPLinearSetCompanionForm_Linear);
1126:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetCompanionForm_C",PEPLinearGetCompanionForm_Linear);
1127:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetEPS_C",PEPLinearSetEPS_Linear);
1128:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetEPS_C",PEPLinearGetEPS_Linear);
1129:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetExplicitMatrix_C",PEPLinearSetExplicitMatrix_Linear);
1130:   PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetExplicitMatrix_C",PEPLinearGetExplicitMatrix_Linear);
1131:   return(0);
1132: }

slepc-3.7.4/src/pep/impls/linear/makefile.html0000644000175000017500000000470313107004621020603 0ustar jromanjroman
slepc-3.7.4 2017-05-17
#
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#  SLEPc - Scalable Library for Eigenvalue Problem Computations
#  Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain
#
#  This file is part of SLEPc.
#
#  SLEPc is free software: you can redistribute it and/or modify it under  the
#  terms of version 3 of the GNU Lesser General Public License as published by
#  the Free Software Foundation.
#
#  SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
#  WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
#  FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
#  more details.
#
#  You  should have received a copy of the GNU Lesser General  Public  License
#  along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#

ALL: lib

CFLAGS   =
FFLAGS   =
SOURCEC  = linear.c qeplin.c
SOURCEF  =
SOURCEH  = linearp.h
LIBBASE  = libslepcpep
DIRS     =
MANSEC   = PEP
LOCDIR   = src/pep/impls/linear/

include ${SLEPC_DIR}/lib/slepc/conf/slepc_common


slepc-3.7.4/src/pep/impls/linear/linear.c0000644000175000017500000012264013107004621017557 0ustar jromanjroman/* Explicit linearization for polynomial eigenproblems. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include /*I "slepcpep.h" I*/ #include "linearp.h" #undef __FUNCT__ #define __FUNCT__ "MatMult_Linear_Shift" static PetscErrorCode MatMult_Linear_Shift(Mat M,Vec x,Vec y) { PetscErrorCode ierr; PEP_LINEAR *ctx; PEP pep; const PetscScalar *px; PetscScalar *py,a,sigma=0.0; PetscInt nmat,deg,i,m; Vec x1,x2,x3,y1,aux; PetscReal *ca,*cb,*cg; PetscBool flg; PetscFunctionBegin; ierr = MatShellGetContext(M,(void**)&ctx);CHKERRQ(ierr); pep = ctx->pep; ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (!flg) { ierr = STGetShift(pep->st,&sigma);CHKERRQ(ierr); } nmat = pep->nmat; deg = nmat-1; m = pep->nloc; ca = pep->pbc; cb = pep->pbc+nmat; cg = pep->pbc+2*nmat; x1=ctx->w[0];x2=ctx->w[1];x3=ctx->w[2];y1=ctx->w[3];aux=ctx->w[4]; ierr = VecSet(y,0.0);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); a = 1.0; /* first block */ ierr = VecPlaceArray(x2,px);CHKERRQ(ierr); ierr = VecPlaceArray(x3,px+m);CHKERRQ(ierr); ierr = VecPlaceArray(y1,py);CHKERRQ(ierr); ierr = VecAXPY(y1,cb[0]-sigma,x2);CHKERRQ(ierr); ierr = VecAXPY(y1,ca[0],x3);CHKERRQ(ierr); ierr = VecResetArray(x2);CHKERRQ(ierr); ierr = VecResetArray(x3);CHKERRQ(ierr); ierr = VecResetArray(y1);CHKERRQ(ierr); /* inner blocks */ for (i=1;ist,i,x1,aux);CHKERRQ(ierr); ierr = VecAXPY(y1,a,aux);CHKERRQ(ierr); ierr = VecResetArray(x1);CHKERRQ(ierr); a *= pep->sfactor; } ierr = VecCopy(y1,aux);CHKERRQ(ierr); ierr = STMatSolve(pep->st,aux,y1);CHKERRQ(ierr); ierr = VecScale(y1,-ca[deg-1]/a);CHKERRQ(ierr); ierr = VecPlaceArray(x1,px+(deg-2)*m);CHKERRQ(ierr); ierr = VecPlaceArray(x2,px+(deg-1)*m);CHKERRQ(ierr); ierr = VecAXPY(y1,cg[deg-1],x1);CHKERRQ(ierr); ierr = VecAXPY(y1,cb[deg-1]-sigma,x2);CHKERRQ(ierr); ierr = VecResetArray(x1);CHKERRQ(ierr); ierr = VecResetArray(x2);CHKERRQ(ierr); ierr = VecResetArray(y1);CHKERRQ(ierr); ierr = VecRestoreArrayRead(x,&px);CHKERRQ(ierr); ierr = VecRestoreArray(y,&py);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatMult_Linear_Sinvert" static PetscErrorCode MatMult_Linear_Sinvert(Mat M,Vec x,Vec y) { PetscErrorCode ierr; PEP_LINEAR *ctx; PEP pep; const PetscScalar *px; PetscScalar *py,a,sigma,t=1.0,tp=0.0,tt; PetscInt nmat,deg,i,m; Vec x1,y1,y2,y3,aux,aux2; PetscReal *ca,*cb,*cg; PetscFunctionBegin; ierr = MatShellGetContext(M,(void**)&ctx);CHKERRQ(ierr); pep = ctx->pep; nmat = pep->nmat; deg = nmat-1; m = pep->nloc; ca = pep->pbc; cb = pep->pbc+nmat; cg = pep->pbc+2*nmat; x1=ctx->w[0];y1=ctx->w[1];y2=ctx->w[2];y3=ctx->w[3];aux=ctx->w[4];aux2=ctx->w[5]; ierr = EPSGetTarget(ctx->eps,&sigma);CHKERRQ(ierr); ierr = VecSet(y,0.0);CHKERRQ(ierr); ierr = VecGetArrayRead(x,&px);CHKERRQ(ierr); ierr = VecGetArray(y,&py);CHKERRQ(ierr); a = pep->sfactor; /* first block */ ierr = VecPlaceArray(x1,px);CHKERRQ(ierr); ierr = VecPlaceArray(y1,py+m);CHKERRQ(ierr); ierr = VecCopy(x1,y1);CHKERRQ(ierr); ierr = VecScale(y1,1.0/ca[0]);CHKERRQ(ierr); ierr = VecResetArray(x1);CHKERRQ(ierr); ierr = VecResetArray(y1);CHKERRQ(ierr); /* second block */ if (deg>2) { ierr = VecPlaceArray(x1,px+m);CHKERRQ(ierr); ierr = VecPlaceArray(y1,py+m);CHKERRQ(ierr); ierr = VecPlaceArray(y2,py+2*m);CHKERRQ(ierr); ierr = VecCopy(x1,y2);CHKERRQ(ierr); ierr = VecAXPY(y2,sigma-cb[1],y1);CHKERRQ(ierr); ierr = VecScale(y2,1.0/ca[1]);CHKERRQ(ierr); ierr = VecResetArray(x1);CHKERRQ(ierr); ierr = VecResetArray(y1);CHKERRQ(ierr); ierr = VecResetArray(y2);CHKERRQ(ierr); } /* inner blocks */ for (i=2;ist,i+1,y2,aux);CHKERRQ(ierr); ierr = VecAXPY(y1,a,aux);CHKERRQ(ierr); ierr = VecResetArray(y2);CHKERRQ(ierr); a *= pep->sfactor; } i = deg-2; ierr = VecPlaceArray(y2,py+(i+1)*m);CHKERRQ(ierr); ierr = VecPlaceArray(y3,py+i*m);CHKERRQ(ierr); ierr = VecCopy(y2,aux2);CHKERRQ(ierr); ierr = VecAXPY(aux2,cg[i+1]/ca[i+1],y3);CHKERRQ(ierr); ierr = STMatMult(pep->st,i+1,aux2,aux);CHKERRQ(ierr); ierr = VecAXPY(y1,a,aux);CHKERRQ(ierr); ierr = VecResetArray(y2);CHKERRQ(ierr); ierr = VecResetArray(y3);CHKERRQ(ierr); a *= pep->sfactor; i = deg-1; ierr = VecPlaceArray(x1,px+i*m);CHKERRQ(ierr); ierr = VecPlaceArray(y3,py+i*m);CHKERRQ(ierr); ierr = VecCopy(x1,aux2);CHKERRQ(ierr); ierr = VecAXPY(aux2,sigma-cb[i],y3);CHKERRQ(ierr); ierr = VecScale(aux2,1.0/ca[i]);CHKERRQ(ierr); ierr = STMatMult(pep->st,i+1,aux2,aux);CHKERRQ(ierr); ierr = VecAXPY(y1,a,aux);CHKERRQ(ierr); ierr = VecResetArray(x1);CHKERRQ(ierr); ierr = VecResetArray(y3);CHKERRQ(ierr); ierr = VecCopy(y1,aux);CHKERRQ(ierr); ierr = STMatSolve(pep->st,aux,y1);CHKERRQ(ierr); ierr = VecScale(y1,-1.0);CHKERRQ(ierr); /* final update */ for (i=1;ipep,&stctx);CHKERRQ(ierr); ierr = STBackTransform(stctx,n,eigr,eigi);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "Apply_Linear" static PetscErrorCode Apply_Linear(ST st,Vec x,Vec y) { PetscErrorCode ierr; PEP_LINEAR *ctx; PetscFunctionBegin; ierr = STShellGetContext(st,(void**)&ctx);CHKERRQ(ierr); ierr = MatMult(ctx->A,x,y);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetUp_Linear" PetscErrorCode PEPSetUp_Linear(PEP pep) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; ST st; PetscInt i=0,deg=pep->nmat-1; EPSWhich which; EPSProblemType ptype; PetscBool trackall,istrivial,transf,shift,sinv,ks; PetscScalar sigma,*epsarray,*peparray; Vec veps; /* function tables */ PetscErrorCode (*fcreate[][2])(MPI_Comm,PEP_LINEAR*,Mat*) = { { MatCreateExplicit_Linear_N1A, MatCreateExplicit_Linear_N1B }, /* N1 */ { MatCreateExplicit_Linear_N2A, MatCreateExplicit_Linear_N2B }, /* N2 */ { MatCreateExplicit_Linear_S1A, MatCreateExplicit_Linear_S1B }, /* S1 */ { MatCreateExplicit_Linear_S2A, MatCreateExplicit_Linear_S2B }, /* S2 */ { MatCreateExplicit_Linear_H1A, MatCreateExplicit_Linear_H1B }, /* H1 */ { MatCreateExplicit_Linear_H2A, MatCreateExplicit_Linear_H2B } /* H2 */ }; PetscFunctionBegin; if (pep->stopping!=PEPStoppingBasic) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"User-defined stopping test not supported"); pep->lineariz = PETSC_TRUE; if (!ctx->cform) ctx->cform = 1; ierr = STGetTransform(pep->st,&transf);CHKERRQ(ierr); /* Set STSHIFT as the default ST */ if (!((PetscObject)pep->st)->type_name) { ierr = STSetType(pep->st,STSHIFT);CHKERRQ(ierr); } ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSHIFT,&shift);CHKERRQ(ierr); ierr = PetscObjectTypeCompare((PetscObject)pep->st,STSINVERT,&sinv);CHKERRQ(ierr); if (!shift && !sinv) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Only STSHIFT and STSINVERT spectral transformations can be used"); if (!pep->which) { if (sinv) pep->which = PEP_TARGET_MAGNITUDE; else pep->which = PEP_LARGEST_MAGNITUDE; } ierr = STSetUp(pep->st);CHKERRQ(ierr); if (!ctx->eps) { ierr = PEPLinearGetEPS(pep,&ctx->eps);CHKERRQ(ierr); } ierr = EPSGetST(ctx->eps,&st);CHKERRQ(ierr); if (!transf) { ierr = EPSSetTarget(ctx->eps,pep->target);CHKERRQ(ierr); } if (sinv && !transf) { ierr = STSetDefaultShift(st,pep->target);CHKERRQ(ierr); } /* compute scale factor if not set by user */ ierr = PEPComputeScaleFactor(pep);CHKERRQ(ierr); if (ctx->explicitmatrix) { if (transf) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Explicit matrix option is not implemented with st-transform flag active"); if (pep->nmat!=3) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Explicit matrix option only available for quadratic problems"); if (pep->basis!=PEP_BASIS_MONOMIAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Explicit matrix option not implemented for non-monomial bases"); if (pep->scale==PEP_SCALE_DIAGONAL || pep->scale==PEP_SCALE_BOTH) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Diagonal scaling not allowed in PEPLINEAR with explicit matrices"); if (sinv && !transf) { ierr = STSetType(st,STSINVERT);CHKERRQ(ierr); } ierr = RGPushScale(pep->rg,1.0/pep->sfactor);CHKERRQ(ierr); ierr = STGetTOperators(pep->st,0,&ctx->K);CHKERRQ(ierr); ierr = STGetTOperators(pep->st,1,&ctx->C);CHKERRQ(ierr); ierr = STGetTOperators(pep->st,2,&ctx->M);CHKERRQ(ierr); ctx->sfactor = pep->sfactor; ctx->dsfactor = pep->dsfactor; ierr = MatDestroy(&ctx->A);CHKERRQ(ierr); ierr = MatDestroy(&ctx->B);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[0]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[1]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[2]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[3]);CHKERRQ(ierr); switch (pep->problem_type) { case PEP_GENERAL: i = 0; break; case PEP_HERMITIAN: i = 2; break; case PEP_GYROSCOPIC: i = 4; break; default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of pep->problem_type"); } i += ctx->cform-1; ierr = (*fcreate[i][0])(PetscObjectComm((PetscObject)pep),ctx,&ctx->A);CHKERRQ(ierr); ierr = (*fcreate[i][1])(PetscObjectComm((PetscObject)pep),ctx,&ctx->B);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->A);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->B);CHKERRQ(ierr); } else { /* implicit matrix */ if (pep->problem_type!=PEP_GENERAL) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Must use the explicit matrix option if problem type is not general"); if (!((PetscObject)(ctx->eps))->type_name) { ierr = EPSSetType(ctx->eps,EPSKRYLOVSCHUR);CHKERRQ(ierr); } else { ierr = PetscObjectTypeCompare((PetscObject)ctx->eps,EPSKRYLOVSCHUR,&ks);CHKERRQ(ierr); if (!ks) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Implicit matrix option only implemented for Krylov-Schur"); } if (ctx->cform!=1) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Implicit matrix option not available for 2nd companion form"); ierr = STSetType(st,STSHELL);CHKERRQ(ierr); ierr = STShellSetContext(st,(PetscObject)ctx);CHKERRQ(ierr); if (!transf) { ierr = STShellSetBackTransform(st,BackTransform_Linear);CHKERRQ(ierr); } ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[0]);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[1]);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[2]);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&ctx->w[3]);CHKERRQ(ierr); ierr = MatCreateVecs(pep->A[0],&ctx->w[4],NULL);CHKERRQ(ierr); ierr = MatCreateVecs(pep->A[0],&ctx->w[5],NULL);CHKERRQ(ierr); ierr = PetscLogObjectParents(pep,6,ctx->w);CHKERRQ(ierr); ierr = MatCreateShell(PetscObjectComm((PetscObject)pep),deg*pep->nloc,deg*pep->nloc,deg*pep->n,deg*pep->n,ctx,&ctx->A);CHKERRQ(ierr); if (sinv && !transf) { ierr = MatShellSetOperation(ctx->A,MATOP_MULT,(void(*)(void))MatMult_Linear_Sinvert);CHKERRQ(ierr); } else { ierr = MatShellSetOperation(ctx->A,MATOP_MULT,(void(*)(void))MatMult_Linear_Shift);CHKERRQ(ierr); } ierr = STShellSetApply(st,Apply_Linear);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->A);CHKERRQ(ierr); ctx->pep = pep; ierr = PEPBasisCoefficients(pep,pep->pbc);CHKERRQ(ierr); if (!transf) { ierr = PetscMalloc1(pep->nmat,&pep->solvematcoeffs);CHKERRQ(ierr); if (sinv) { ierr = PEPEvaluateBasis(pep,pep->target,0,pep->solvematcoeffs,NULL);CHKERRQ(ierr); } else { for (i=0;isolvematcoeffs[i] = 0.0; pep->solvematcoeffs[deg] = 1.0; } ierr = STScaleShift(pep->st,1.0/pep->sfactor);CHKERRQ(ierr); ierr = RGPushScale(pep->rg,1.0/pep->sfactor);CHKERRQ(ierr); } if (pep->sfactor!=1.0) { for (i=0;inmat;i++) { pep->pbc[pep->nmat+i] /= pep->sfactor; pep->pbc[2*pep->nmat+i] /= pep->sfactor*pep->sfactor; } } } ierr = EPSSetOperators(ctx->eps,ctx->A,ctx->B);CHKERRQ(ierr); ierr = EPSGetProblemType(ctx->eps,&ptype);CHKERRQ(ierr); if (!ptype) { if (ctx->explicitmatrix) { ierr = EPSSetProblemType(ctx->eps,EPS_GNHEP);CHKERRQ(ierr); } else { ierr = EPSSetProblemType(ctx->eps,EPS_NHEP);CHKERRQ(ierr); } } if (transf) which = EPS_LARGEST_MAGNITUDE; else { switch (pep->which) { case PEP_LARGEST_MAGNITUDE: which = EPS_LARGEST_MAGNITUDE; break; case PEP_SMALLEST_MAGNITUDE: which = EPS_SMALLEST_MAGNITUDE; break; case PEP_LARGEST_REAL: which = EPS_LARGEST_REAL; break; case PEP_SMALLEST_REAL: which = EPS_SMALLEST_REAL; break; case PEP_LARGEST_IMAGINARY: which = EPS_LARGEST_IMAGINARY; break; case PEP_SMALLEST_IMAGINARY: which = EPS_SMALLEST_IMAGINARY; break; case PEP_TARGET_MAGNITUDE: which = EPS_TARGET_MAGNITUDE; break; case PEP_TARGET_REAL: which = EPS_TARGET_REAL; break; case PEP_TARGET_IMAGINARY: which = EPS_TARGET_IMAGINARY; break; case PEP_WHICH_USER: which = EPS_WHICH_USER; ierr = EPSSetEigenvalueComparison(ctx->eps,pep->sc->comparison,pep->sc->comparisonctx);CHKERRQ(ierr); break; default: SETERRQ(PetscObjectComm((PetscObject)pep),1,"Wrong value of which"); } } ierr = EPSSetWhichEigenpairs(ctx->eps,which);CHKERRQ(ierr); ierr = EPSSetDimensions(ctx->eps,pep->nev,pep->ncv?pep->ncv:PETSC_DEFAULT,pep->mpd?pep->mpd:PETSC_DEFAULT);CHKERRQ(ierr); ierr = EPSSetTolerances(ctx->eps,pep->tol==PETSC_DEFAULT?SLEPC_DEFAULT_TOL:pep->tol,pep->max_it?pep->max_it:PETSC_DEFAULT);CHKERRQ(ierr); ierr = RGIsTrivial(pep->rg,&istrivial);CHKERRQ(ierr); if (!istrivial) { if (transf) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"PEPLINEAR does not support a nontrivial region with st-transform"); ierr = EPSSetRG(ctx->eps,pep->rg);CHKERRQ(ierr); } /* Transfer the trackall option from pep to eps */ ierr = PEPGetTrackAll(pep,&trackall);CHKERRQ(ierr); ierr = EPSSetTrackAll(ctx->eps,trackall);CHKERRQ(ierr); /* temporary change of target */ if (pep->sfactor!=1.0) { ierr = EPSGetTarget(ctx->eps,&sigma);CHKERRQ(ierr); ierr = EPSSetTarget(ctx->eps,sigma/pep->sfactor);CHKERRQ(ierr); } /* process initial vector */ if (pep->nini<=-deg) { ierr = VecCreateMPI(PetscObjectComm((PetscObject)ctx->eps),deg*pep->nloc,deg*pep->n,&veps);CHKERRQ(ierr); ierr = VecGetArray(veps,&epsarray);CHKERRQ(ierr); for (i=0;iIS[i],&peparray);CHKERRQ(ierr); ierr = PetscMemcpy(epsarray+i*pep->nloc,peparray,pep->nloc*sizeof(PetscScalar));CHKERRQ(ierr); ierr = VecRestoreArray(pep->IS[i],&peparray);CHKERRQ(ierr); } ierr = VecRestoreArray(veps,&epsarray);CHKERRQ(ierr); ierr = EPSSetInitialSpace(ctx->eps,1,&veps);CHKERRQ(ierr); ierr = VecDestroy(&veps);CHKERRQ(ierr); } if (pep->nini<0) { ierr = SlepcBasisDestroy_Private(&pep->nini,&pep->IS);CHKERRQ(ierr); } ierr = EPSSetUp(ctx->eps);CHKERRQ(ierr); ierr = EPSGetDimensions(ctx->eps,NULL,&pep->ncv,&pep->mpd);CHKERRQ(ierr); ierr = EPSGetTolerances(ctx->eps,NULL,&pep->max_it);CHKERRQ(ierr); if (pep->nini>0) { ierr = PetscInfo(pep,"Ignoring initial vectors\n");CHKERRQ(ierr); } ierr = PEPAllocateSolution(pep,0);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearExtract_Residual" /* PEPLinearExtract_Residual - Auxiliary routine that copies the solution of the linear eigenproblem to the PEP object. The eigenvector of the generalized problem is supposed to be z = [ x ] [ l*x ] The eigenvector is taken from z(1:n) or z(n+1:2*n) depending on the explicitly computed residual norm. Finally, x is normalized so that ||x||_2 = 1. */ static PetscErrorCode PEPLinearExtract_Residual(PEP pep,EPS eps) { PetscErrorCode ierr; PetscInt i,k; const PetscScalar *px; PetscScalar *er=pep->eigr,*ei=pep->eigi; PetscReal rn1,rn2; Vec xr,xi=NULL,wr; Mat A; #if !defined(PETSC_USE_COMPLEX) Vec wi; const PetscScalar *py; #endif PetscFunctionBegin; #if defined(PETSC_USE_COMPLEX) ierr = PEPSetWorkVecs(pep,2);CHKERRQ(ierr); #else ierr = PEPSetWorkVecs(pep,4);CHKERRQ(ierr); #endif ierr = EPSGetOperators(eps,&A,NULL);CHKERRQ(ierr); ierr = MatCreateVecs(A,&xr,NULL);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&wr);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = VecDuplicate(xr,&xi);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&wi);CHKERRQ(ierr); #endif for (i=0;inconv;i++) { ierr = EPSGetEigenpair(eps,i,NULL,NULL,xr,xi);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) if (ei[i]!=0.0) { /* complex conjugate pair */ ierr = VecGetArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecGetArrayRead(xi,&py);CHKERRQ(ierr); ierr = VecPlaceArray(wr,px);CHKERRQ(ierr); ierr = VecPlaceArray(wi,py);CHKERRQ(ierr); ierr = SlepcVecNormalize(wr,wi,PETSC_TRUE,NULL);CHKERRQ(ierr); ierr = PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,wi,pep->work,&rn1);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i,wr);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i+1,wi);CHKERRQ(ierr); for (k=1;knmat-1;k++) { ierr = VecResetArray(wr);CHKERRQ(ierr); ierr = VecResetArray(wi);CHKERRQ(ierr); ierr = VecPlaceArray(wr,px+k*pep->nloc);CHKERRQ(ierr); ierr = VecPlaceArray(wi,py+k*pep->nloc);CHKERRQ(ierr); ierr = SlepcVecNormalize(wr,wi,PETSC_TRUE,NULL);CHKERRQ(ierr); ierr = PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,wi,pep->work,&rn2);CHKERRQ(ierr); if (rn1>rn2) { ierr = BVInsertVec(pep->V,i,wr);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i+1,wi);CHKERRQ(ierr); rn1 = rn2; } } ierr = VecResetArray(wr);CHKERRQ(ierr); ierr = VecResetArray(wi);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xi,&py);CHKERRQ(ierr); i++; } else /* real eigenvalue */ #endif { ierr = VecGetArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecPlaceArray(wr,px);CHKERRQ(ierr); ierr = SlepcVecNormalize(wr,NULL,PETSC_FALSE,NULL);CHKERRQ(ierr); ierr = PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,NULL,pep->work,&rn1);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i,wr);CHKERRQ(ierr); for (k=1;knmat-1;k++) { ierr = VecResetArray(wr);CHKERRQ(ierr); ierr = VecPlaceArray(wr,px+k*pep->nloc);CHKERRQ(ierr); ierr = SlepcVecNormalize(wr,NULL,PETSC_FALSE,NULL);CHKERRQ(ierr); ierr = PEPComputeResidualNorm_Private(pep,er[i],ei[i],wr,NULL,pep->work,&rn2);CHKERRQ(ierr); if (rn1>rn2) { ierr = BVInsertVec(pep->V,i,wr);CHKERRQ(ierr); rn1 = rn2; } } ierr = VecResetArray(wr);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xr,&px);CHKERRQ(ierr); } } ierr = VecDestroy(&wr);CHKERRQ(ierr); ierr = VecDestroy(&xr);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = VecDestroy(&wi);CHKERRQ(ierr); ierr = VecDestroy(&xi);CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearExtract_None" /* PEPLinearExtract_None - Same as PEPLinearExtract_Norm but always takes the first block. */ static PetscErrorCode PEPLinearExtract_None(PEP pep,EPS eps) { PetscErrorCode ierr; PetscInt i; const PetscScalar *px; Mat A; Vec xr,xi,w; #if !defined(PETSC_USE_COMPLEX) PetscScalar *ei=pep->eigi; #endif PetscFunctionBegin; ierr = EPSGetOperators(eps,&A,NULL);CHKERRQ(ierr); ierr = MatCreateVecs(A,&xr,NULL);CHKERRQ(ierr); ierr = VecDuplicate(xr,&xi);CHKERRQ(ierr); ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&w);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = EPSGetEigenpair(eps,i,NULL,NULL,xr,xi);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) if (ei[i]!=0.0) { /* complex conjugate pair */ ierr = VecGetArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecPlaceArray(w,px);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i,w);CHKERRQ(ierr); ierr = VecResetArray(w);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecGetArrayRead(xi,&px);CHKERRQ(ierr); ierr = VecPlaceArray(w,px);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i+1,w);CHKERRQ(ierr); ierr = VecResetArray(w);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xi,&px);CHKERRQ(ierr); i++; } else /* real eigenvalue */ #endif { ierr = VecGetArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecPlaceArray(w,px);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i,w);CHKERRQ(ierr); ierr = VecResetArray(w);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xr,&px);CHKERRQ(ierr); } } ierr = VecDestroy(&w);CHKERRQ(ierr); ierr = VecDestroy(&xr);CHKERRQ(ierr); ierr = VecDestroy(&xi);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearExtract_Norm" /* PEPLinearExtract_Norm - Auxiliary routine that copies the solution of the linear eigenproblem to the PEP object. The eigenvector of the generalized problem is supposed to be z = [ x ] [ l*x ] If |l|<1.0, the eigenvector is taken from z(1:n), otherwise from z(n+1:2*n). Finally, x is normalized so that ||x||_2 = 1. */ static PetscErrorCode PEPLinearExtract_Norm(PEP pep,EPS eps) { PetscErrorCode ierr; PetscInt i,offset; const PetscScalar *px; PetscScalar *er=pep->eigr; Mat A; Vec xr,xi=NULL,w; #if !defined(PETSC_USE_COMPLEX) PetscScalar *ei=pep->eigi; #endif PetscFunctionBegin; ierr = EPSGetOperators(eps,&A,NULL);CHKERRQ(ierr); ierr = MatCreateVecs(A,&xr,NULL);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = VecDuplicate(xr,&xi);CHKERRQ(ierr); #endif ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)pep),1,pep->nloc,pep->n,NULL,&w);CHKERRQ(ierr); for (i=0;inconv;i++) { ierr = EPSGetEigenpair(eps,i,NULL,NULL,xr,xi);CHKERRQ(ierr); if (SlepcAbsEigenvalue(er[i],ei[i])>1.0) offset = (pep->nmat-2)*pep->nloc; else offset = 0; #if !defined(PETSC_USE_COMPLEX) if (ei[i]!=0.0) { /* complex conjugate pair */ ierr = VecGetArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecPlaceArray(w,px+offset);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i,w);CHKERRQ(ierr); ierr = VecResetArray(w);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecGetArrayRead(xi,&px);CHKERRQ(ierr); ierr = VecPlaceArray(w,px+offset);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i+1,w);CHKERRQ(ierr); ierr = VecResetArray(w);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xi,&px);CHKERRQ(ierr); i++; } else /* real eigenvalue */ #endif { ierr = VecGetArrayRead(xr,&px);CHKERRQ(ierr); ierr = VecPlaceArray(w,px+offset);CHKERRQ(ierr); ierr = BVInsertVec(pep->V,i,w);CHKERRQ(ierr); ierr = VecResetArray(w);CHKERRQ(ierr); ierr = VecRestoreArrayRead(xr,&px);CHKERRQ(ierr); } } ierr = VecDestroy(&w);CHKERRQ(ierr); ierr = VecDestroy(&xr);CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = VecDestroy(&xi);CHKERRQ(ierr); #endif PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPExtractVectors_Linear" PetscErrorCode PEPExtractVectors_Linear(PEP pep) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; switch (pep->extract) { case PEP_EXTRACT_NONE: ierr = PEPLinearExtract_None(pep,ctx->eps);CHKERRQ(ierr); break; case PEP_EXTRACT_NORM: ierr = PEPLinearExtract_Norm(pep,ctx->eps);CHKERRQ(ierr); break; case PEP_EXTRACT_RESIDUAL: ierr = PEPLinearExtract_Residual(pep,ctx->eps);CHKERRQ(ierr); break; default: SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Extraction not implemented in this solver"); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSolve_Linear" PetscErrorCode PEPSolve_Linear(PEP pep) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscScalar sigma; PetscBool flg; PetscInt i; PetscFunctionBegin; ierr = EPSSolve(ctx->eps);CHKERRQ(ierr); ierr = EPSGetConverged(ctx->eps,&pep->nconv);CHKERRQ(ierr); ierr = EPSGetIterationNumber(ctx->eps,&pep->its);CHKERRQ(ierr); ierr = EPSGetConvergedReason(ctx->eps,(EPSConvergedReason*)&pep->reason);CHKERRQ(ierr); /* recover eigenvalues */ for (i=0;inconv;i++) { ierr = EPSGetEigenpair(ctx->eps,i,&pep->eigr[i],&pep->eigi[i],NULL,NULL);CHKERRQ(ierr); pep->eigr[i] *= pep->sfactor; pep->eigi[i] *= pep->sfactor; } /* restore target */ ierr = EPSGetTarget(ctx->eps,&sigma);CHKERRQ(ierr); ierr = EPSSetTarget(ctx->eps,sigma*pep->sfactor);CHKERRQ(ierr); ierr = STGetTransform(pep->st,&flg);CHKERRQ(ierr); if (flg && pep->ops->backtransform) { ierr = (*pep->ops->backtransform)(pep);CHKERRQ(ierr); } if (pep->sfactor!=1.0) { /* Restore original values */ for (i=0;inmat;i++){ pep->pbc[pep->nmat+i] *= pep->sfactor; pep->pbc[2*pep->nmat+i] *= pep->sfactor*pep->sfactor; } if (!flg && !ctx->explicitmatrix) { ierr = STScaleShift(pep->st,pep->sfactor);CHKERRQ(ierr); } } if (ctx->explicitmatrix) { ierr = RGPopScale(pep->rg);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "EPSMonitor_Linear" static PetscErrorCode EPSMonitor_Linear(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx) { PEP pep = (PEP)ctx; PetscErrorCode ierr; PetscFunctionBegin; ierr = PEPMonitor(pep,its,nconv,eigr,eigi,errest,nest);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPSetFromOptions_Linear" PetscErrorCode PEPSetFromOptions_Linear(PetscOptionItems *PetscOptionsObject,PEP pep) { PetscErrorCode ierr; PetscBool set,val; PetscInt i; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; ierr = PetscOptionsHead(PetscOptionsObject,"PEP Linear Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-pep_linear_cform","Number of the companion form","PEPLinearSetCompanionForm",ctx->cform,&i,&set);CHKERRQ(ierr); if (set) { ierr = PEPLinearSetCompanionForm(pep,i);CHKERRQ(ierr); } ierr = PetscOptionsBool("-pep_linear_explicitmatrix","Use explicit matrix in linearization","PEPLinearSetExplicitMatrix",ctx->explicitmatrix,&val,&set);CHKERRQ(ierr); if (set) { ierr = PEPLinearSetExplicitMatrix(pep,val);CHKERRQ(ierr); } if (!ctx->eps) { ierr = PEPLinearGetEPS(pep,&ctx->eps);CHKERRQ(ierr); } ierr = EPSSetFromOptions(ctx->eps);CHKERRQ(ierr); ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearSetCompanionForm_Linear" static PetscErrorCode PEPLinearSetCompanionForm_Linear(PEP pep,PetscInt cform) { PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; if (!cform) PetscFunctionReturn(0); if (cform==PETSC_DECIDE || cform==PETSC_DEFAULT) ctx->cform = 1; else { if (cform!=1 && cform!=2) SETERRQ(PetscObjectComm((PetscObject)pep),PETSC_ERR_ARG_OUTOFRANGE,"Invalid value of argument 'cform'"); ctx->cform = cform; } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearSetCompanionForm" /*@ PEPLinearSetCompanionForm - Choose between the two companion forms available for the linearization of a quadratic eigenproblem. Logically Collective on PEP Input Parameters: + pep - polynomial eigenvalue solver - cform - 1 or 2 (first or second companion form) Options Database Key: . -pep_linear_cform - Choose the companion form Level: advanced .seealso: PEPLinearGetCompanionForm() @*/ PetscErrorCode PEPLinearSetCompanionForm(PEP pep,PetscInt cform) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveInt(pep,cform,2); ierr = PetscTryMethod(pep,"PEPLinearSetCompanionForm_C",(PEP,PetscInt),(pep,cform));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearGetCompanionForm_Linear" static PetscErrorCode PEPLinearGetCompanionForm_Linear(PEP pep,PetscInt *cform) { PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; *cform = ctx->cform; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearGetCompanionForm" /*@ PEPLinearGetCompanionForm - Returns the number of the companion form that will be used for the linearization of a quadratic eigenproblem. Not Collective Input Parameter: . pep - polynomial eigenvalue solver Output Parameter: . cform - the companion form number (1 or 2) Level: advanced .seealso: PEPLinearSetCompanionForm() @*/ PetscErrorCode PEPLinearGetCompanionForm(PEP pep,PetscInt *cform) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidIntPointer(cform,2); ierr = PetscUseMethod(pep,"PEPLinearGetCompanionForm_C",(PEP,PetscInt*),(pep,cform));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearSetExplicitMatrix_Linear" static PetscErrorCode PEPLinearSetExplicitMatrix_Linear(PEP pep,PetscBool explicitmatrix) { PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; ctx->explicitmatrix = explicitmatrix; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearSetExplicitMatrix" /*@ PEPLinearSetExplicitMatrix - Indicate if the matrices A and B for the linearization of the problem must be built explicitly. Logically Collective on PEP Input Parameters: + pep - polynomial eigenvalue solver - explicit - boolean flag indicating if the matrices are built explicitly Options Database Key: . -pep_linear_explicitmatrix - Indicates the boolean flag Level: advanced .seealso: PEPLinearGetExplicitMatrix() @*/ PetscErrorCode PEPLinearSetExplicitMatrix(PEP pep,PetscBool explicitmatrix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidLogicalCollectiveBool(pep,explicitmatrix,2); ierr = PetscTryMethod(pep,"PEPLinearSetExplicitMatrix_C",(PEP,PetscBool),(pep,explicitmatrix));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearGetExplicitMatrix_Linear" static PetscErrorCode PEPLinearGetExplicitMatrix_Linear(PEP pep,PetscBool *explicitmatrix) { PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; *explicitmatrix = ctx->explicitmatrix; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearGetExplicitMatrix" /*@ PEPLinearGetExplicitMatrix - Returns the flag indicating if the matrices A and B for the linearization are built explicitly. Not Collective Input Parameter: . pep - polynomial eigenvalue solver Output Parameter: . explicitmatrix - the mode flag Level: advanced .seealso: PEPLinearSetExplicitMatrix() @*/ PetscErrorCode PEPLinearGetExplicitMatrix(PEP pep,PetscBool *explicitmatrix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(explicitmatrix,2); ierr = PetscUseMethod(pep,"PEPLinearGetExplicitMatrix_C",(PEP,PetscBool*),(pep,explicitmatrix));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearSetEPS_Linear" static PetscErrorCode PEPLinearSetEPS_Linear(PEP pep,EPS eps) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; ierr = PetscObjectReference((PetscObject)eps);CHKERRQ(ierr); ierr = EPSDestroy(&ctx->eps);CHKERRQ(ierr); ctx->eps = eps; ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->eps);CHKERRQ(ierr); pep->state = PEP_STATE_INITIAL; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearSetEPS" /*@ PEPLinearSetEPS - Associate an eigensolver object (EPS) to the polynomial eigenvalue solver. Collective on PEP Input Parameters: + pep - polynomial eigenvalue solver - eps - the eigensolver object Level: advanced .seealso: PEPLinearGetEPS() @*/ PetscErrorCode PEPLinearSetEPS(PEP pep,EPS eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidHeaderSpecific(eps,EPS_CLASSID,2); PetscCheckSameComm(pep,1,eps,2); ierr = PetscTryMethod(pep,"PEPLinearSetEPS_C",(PEP,EPS),(pep,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearGetEPS_Linear" static PetscErrorCode PEPLinearGetEPS_Linear(PEP pep,EPS *eps) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; ST st; PetscFunctionBegin; if (!ctx->eps) { ierr = EPSCreate(PetscObjectComm((PetscObject)pep),&ctx->eps);CHKERRQ(ierr); ierr = EPSSetOptionsPrefix(ctx->eps,((PetscObject)pep)->prefix);CHKERRQ(ierr); ierr = EPSAppendOptionsPrefix(ctx->eps,"pep_linear_");CHKERRQ(ierr); ierr = EPSGetST(ctx->eps,&st);CHKERRQ(ierr); ierr = STSetOptionsPrefix(st,((PetscObject)ctx->eps)->prefix);CHKERRQ(ierr); ierr = PetscObjectIncrementTabLevel((PetscObject)ctx->eps,(PetscObject)pep,1);CHKERRQ(ierr); ierr = PetscLogObjectParent((PetscObject)pep,(PetscObject)ctx->eps);CHKERRQ(ierr); ierr = EPSMonitorSet(ctx->eps,EPSMonitor_Linear,pep,NULL);CHKERRQ(ierr); } *eps = ctx->eps; PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPLinearGetEPS" /*@ PEPLinearGetEPS - Retrieve the eigensolver object (EPS) associated to the polynomial eigenvalue solver. Not Collective Input Parameter: . pep - polynomial eigenvalue solver Output Parameter: . eps - the eigensolver object Level: advanced .seealso: PEPLinearSetEPS() @*/ PetscErrorCode PEPLinearGetEPS(PEP pep,EPS *eps) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(pep,PEP_CLASSID,1); PetscValidPointer(eps,2); ierr = PetscUseMethod(pep,"PEPLinearGetEPS_C",(PEP,EPS*),(pep,eps));CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPView_Linear" PetscErrorCode PEPView_Linear(PEP pep,PetscViewer viewer) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscBool isascii; PetscFunctionBegin; ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr); if (isascii) { if (!ctx->eps) { ierr = PEPLinearGetEPS(pep,&ctx->eps);CHKERRQ(ierr); } ierr = PetscViewerASCIIPrintf(viewer," Linear: %s matrices\n",ctx->explicitmatrix? "explicit": "implicit");CHKERRQ(ierr); ierr = PetscViewerASCIIPrintf(viewer," Linear: %s companion form\n",ctx->cform==1? "1st": "2nd");CHKERRQ(ierr); ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr); ierr = EPSView(ctx->eps,viewer);CHKERRQ(ierr); ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr); } PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPReset_Linear" PetscErrorCode PEPReset_Linear(PEP pep) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; if (!ctx->eps) { ierr = EPSReset(ctx->eps);CHKERRQ(ierr); } ierr = MatDestroy(&ctx->A);CHKERRQ(ierr); ierr = MatDestroy(&ctx->B);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[0]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[1]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[2]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[3]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[4]);CHKERRQ(ierr); ierr = VecDestroy(&ctx->w[5]);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPDestroy_Linear" PetscErrorCode PEPDestroy_Linear(PEP pep) { PetscErrorCode ierr; PEP_LINEAR *ctx = (PEP_LINEAR*)pep->data; PetscFunctionBegin; ierr = EPSDestroy(&ctx->eps);CHKERRQ(ierr); ierr = PetscFree(pep->data);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetCompanionForm_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetCompanionForm_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetEPS_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetEPS_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetExplicitMatrix_C",NULL);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetExplicitMatrix_C",NULL);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "PEPCreate_Linear" PETSC_EXTERN PetscErrorCode PEPCreate_Linear(PEP pep) { PetscErrorCode ierr; PEP_LINEAR *ctx; PetscFunctionBegin; ierr = PetscNewLog(pep,&ctx);CHKERRQ(ierr); ctx->explicitmatrix = PETSC_FALSE; pep->data = (void*)ctx; pep->ops->solve = PEPSolve_Linear; pep->ops->setup = PEPSetUp_Linear; pep->ops->setfromoptions = PEPSetFromOptions_Linear; pep->ops->destroy = PEPDestroy_Linear; pep->ops->reset = PEPReset_Linear; pep->ops->view = PEPView_Linear; pep->ops->backtransform = PEPBackTransform_Default; pep->ops->computevectors = PEPComputeVectors_Default; pep->ops->extractvectors = PEPExtractVectors_Linear; ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetCompanionForm_C",PEPLinearSetCompanionForm_Linear);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetCompanionForm_C",PEPLinearGetCompanionForm_Linear);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetEPS_C",PEPLinearSetEPS_Linear);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetEPS_C",PEPLinearGetEPS_Linear);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearSetExplicitMatrix_C",PEPLinearSetExplicitMatrix_Linear);CHKERRQ(ierr); ierr = PetscObjectComposeFunction((PetscObject)pep,"PEPLinearGetExplicitMatrix_C",PEPLinearGetExplicitMatrix_Linear);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/src/pep/impls/linear/linearp.h.html0000644000175000017500000001436013107004621020706 0ustar jromanjroman
Actual source code: linearp.h

slepc-3.7.4 2017-05-17
  1: /*
  2:    Private header for PEPLINEAR.

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

  8:    This file is part of SLEPc.

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

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

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


 27: typedef struct {
 28:   PetscBool  explicitmatrix;
 29:   PEP        pep;
 30:   PetscInt   cform;            /* companion form */
 31:   PetscReal  sfactor,dsfactor; /* scaling factors */
 32:   Mat        A,B;              /* matrices of generalized eigenproblem */
 33:   EPS        eps;              /* linear eigensolver for Az=lBz */
 34:   Mat        M,C,K;            /* copy of PEP coefficient matrices */
 35:   Vec        w[6];             /* work vectors */
 36:   PetscBool  setfromoptionscalled;
 37: } PEP_LINEAR;

 39: /* General case for implicit matrices of degree d */
 40: PETSC_INTERN PetscErrorCode MatMult_Linear(Mat,Vec,Vec);

 42: /* N1 */
 43: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm,PEP_LINEAR*,Mat*);
 44: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm,PEP_LINEAR*,Mat*);

 46: /* N2 */
 47: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N2A(MPI_Comm,PEP_LINEAR*,Mat*);
 48: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N2B(MPI_Comm,PEP_LINEAR*,Mat*);

 50: /* S1 */
 51: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S1A(MPI_Comm,PEP_LINEAR*,Mat*);
 52: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S1B(MPI_Comm,PEP_LINEAR*,Mat*);

 54: /* S2 */
 55: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S2A(MPI_Comm,PEP_LINEAR*,Mat*);
 56: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S2B(MPI_Comm,PEP_LINEAR*,Mat*);

 58: /* H1 */
 59: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm,PEP_LINEAR*,Mat*);
 60: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm,PEP_LINEAR*,Mat*);

 62: /* H2 */
 63: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm,PEP_LINEAR*,Mat*);
 64: PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm,PEP_LINEAR*,Mat*);

 66: #endif
slepc-3.7.4/src/pep/impls/linear/linearp.h0000644000175000017500000000517313107004621017745 0ustar jromanjroman/* Private header for PEPLINEAR. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #if !defined(__LINEARP_H) #define __LINEARP_H typedef struct { PetscBool explicitmatrix; PEP pep; PetscInt cform; /* companion form */ PetscReal sfactor,dsfactor; /* scaling factors */ Mat A,B; /* matrices of generalized eigenproblem */ EPS eps; /* linear eigensolver for Az=lBz */ Mat M,C,K; /* copy of PEP coefficient matrices */ Vec w[6]; /* work vectors */ PetscBool setfromoptionscalled; } PEP_LINEAR; /* General case for implicit matrices of degree d */ PETSC_INTERN PetscErrorCode MatMult_Linear(Mat,Vec,Vec); /* N1 */ PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm,PEP_LINEAR*,Mat*); PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm,PEP_LINEAR*,Mat*); /* N2 */ PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N2A(MPI_Comm,PEP_LINEAR*,Mat*); PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_N2B(MPI_Comm,PEP_LINEAR*,Mat*); /* S1 */ PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S1A(MPI_Comm,PEP_LINEAR*,Mat*); PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S1B(MPI_Comm,PEP_LINEAR*,Mat*); /* S2 */ PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S2A(MPI_Comm,PEP_LINEAR*,Mat*); PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_S2B(MPI_Comm,PEP_LINEAR*,Mat*); /* H1 */ PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm,PEP_LINEAR*,Mat*); PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm,PEP_LINEAR*,Mat*); /* H2 */ PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm,PEP_LINEAR*,Mat*); PETSC_INTERN PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm,PEP_LINEAR*,Mat*); #endif slepc-3.7.4/src/pep/impls/linear/qeplin.c.html0000644000175000017500000003715413107004621020545 0ustar jromanjroman
Actual source code: qeplin.c

slepc-3.7.4 2017-05-17
  1: /*

  3:    Various types of linearization for quadratic eigenvalue problem.

  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: */

 25: #include <slepc/private/pepimpl.h>
 26:  #include linearp.h

 28: /*
 29:     Given the quadratic problem (l^2*M + l*C + K)*x = 0 the linearization is
 30:     A*z = l*B*z for z = [  x  ] and A,B defined as follows:
 31:                         [ l*x ]

 33:             N1:
 34:                      A = [  0   I ]     B = [ I  0 ]
 35:                          [ -K  -C ]         [ 0  M ]

 37:             N2:
 38:                      A = [ -K   0 ]     B = [ C  M ]
 39:                          [  0   I ]         [ I  0 ]

 41:             S1:
 42:                      A = [  0  -K ]     B = [-K  0 ]
 43:                          [ -K  -C ]         [ 0  M ]

 45:             S2:
 46:                      A = [ -K   0 ]     B = [ C  M ]
 47:                          [  0   M ]         [ M  0 ]

 49:             H1:
 50:                      A = [  K   0 ]     B = [ 0  K ]
 51:                          [  C   K ]         [-M  0 ]

 53:             H2:
 54:                      A = [  0  -K ]     B = [ M  C ]
 55:                          [  M   0 ]         [ 0  M ]
 56:  */

 58: /* - - - N1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

 62: PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)
 63: {
 65:   PetscInt       M,N,m,n,i,Istart,Iend;
 66:   Mat            Id;

 69:   MatGetSize(ctx->M,&M,&N);
 70:   MatGetLocalSize(ctx->M,&m,&n);
 71:   MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);
 72:   MatSetSizes(Id,m,n,M,N);
 73:   MatSetFromOptions(Id);
 74:   MatSetUp(Id);
 75:   MatGetOwnershipRange(Id,&Istart,&Iend);
 76:   for (i=Istart;i<Iend;i++) {
 77:     MatSetValue(Id,i,i,1.0,INSERT_VALUES);
 78:   }
 79:   MatAssemblyBegin(Id,MAT_FINAL_ASSEMBLY);
 80:   MatAssemblyEnd(Id,MAT_FINAL_ASSEMBLY);
 81:   SlepcMatTile(0.0,Id,1.0,Id,-ctx->dsfactor,ctx->K,-ctx->sfactor*ctx->dsfactor,ctx->C,A);
 82:   MatDestroy(&Id);
 83:   return(0);
 84: }

 88: PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)
 89: {
 91:   PetscInt       M,N,m,n,i,Istart,Iend;
 92:   Mat            Id;

 95:   MatGetSize(ctx->M,&M,&N);
 96:   MatGetLocalSize(ctx->M,&m,&n);
 97:   MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);
 98:   MatSetSizes(Id,m,n,M,N);
 99:   MatSetFromOptions(Id);
100:   MatSetUp(Id);
101:   MatGetOwnershipRange(Id,&Istart,&Iend);
102:   for (i=Istart;i<Iend;i++) {
103:     MatSetValue(Id,i,i,1.0,INSERT_VALUES);
104:   }
105:   MatAssemblyBegin(Id,MAT_FINAL_ASSEMBLY);
106:   MatAssemblyEnd(Id,MAT_FINAL_ASSEMBLY);
107:   SlepcMatTile(1.0,Id,0.0,Id,0.0,Id,ctx->sfactor*ctx->sfactor*ctx->dsfactor,ctx->M,B);
108:   MatDestroy(&Id);
109:   return(0);
110: }

112: /* - - - N2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

116: PetscErrorCode MatCreateExplicit_Linear_N2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)
117: {
119:   PetscInt       M,N,m,n,i,Istart,Iend;
120:   Mat            Id;

123:   MatGetSize(ctx->M,&M,&N);
124:   MatGetLocalSize(ctx->M,&m,&n);
125:   MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);
126:   MatSetSizes(Id,m,n,M,N);
127:   MatSetFromOptions(Id);
128:   MatSetUp(Id);
129:   MatGetOwnershipRange(Id,&Istart,&Iend);
130:   for (i=Istart;i<Iend;i++) {
131:     MatSetValue(Id,i,i,1.0,INSERT_VALUES);
132:   }
133:   MatAssemblyBegin(Id,MAT_FINAL_ASSEMBLY);
134:   MatAssemblyEnd(Id,MAT_FINAL_ASSEMBLY);
135:   SlepcMatTile(-1.0,ctx->K,0.0,Id,0.0,Id,1.0,Id,A);
136:   MatDestroy(&Id);
137:   return(0);
138: }

142: PetscErrorCode MatCreateExplicit_Linear_N2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)
143: {
145:   PetscInt       M,N,m,n,i,Istart,Iend;
146:   Mat            Id;

149:   MatGetSize(ctx->M,&M,&N);
150:   MatGetLocalSize(ctx->M,&m,&n);
151:   MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);
152:   MatSetSizes(Id,m,n,M,N);
153:   MatSetFromOptions(Id);
154:   MatSetUp(Id);
155:   MatGetOwnershipRange(Id,&Istart,&Iend);
156:   for (i=Istart;i<Iend;i++) {
157:     MatSetValue(Id,i,i,1.0,INSERT_VALUES);
158:   }
159:   MatAssemblyBegin(Id,MAT_FINAL_ASSEMBLY);
160:   MatAssemblyEnd(Id,MAT_FINAL_ASSEMBLY);
161:   SlepcMatTile(ctx->sfactor,ctx->C,ctx->sfactor*ctx->sfactor,ctx->M,1.0,Id,0.0,Id,B);
162:   MatDestroy(&Id);
163:   return(0);
164: }

166: /* - - - S1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

170: PetscErrorCode MatCreateExplicit_Linear_S1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)
171: {

175:   SlepcMatTile(0.0,ctx->K,-1.0,ctx->K,-1.0,ctx->K,-ctx->sfactor,ctx->C,A);
176:   return(0);
177: }

181: PetscErrorCode MatCreateExplicit_Linear_S1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)
182: {

186:   SlepcMatTile(-1.0,ctx->K,0.0,ctx->M,0.0,ctx->M,ctx->sfactor*ctx->sfactor,ctx->M,B);
187:   return(0);
188: }

190: /* - - - S2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

194: PetscErrorCode MatCreateExplicit_Linear_S2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)
195: {

199:   SlepcMatTile(-1.0,ctx->K,0.0,ctx->M,0.0,ctx->M,ctx->sfactor*ctx->sfactor,ctx->M,A);
200:   return(0);
201: }

205: PetscErrorCode MatCreateExplicit_Linear_S2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)
206: {

210:   SlepcMatTile(ctx->sfactor,ctx->C,ctx->sfactor*ctx->sfactor,ctx->M,ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->M,B);
211:   return(0);
212: }

214: /* - - - H1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

218: PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)
219: {

223:   SlepcMatTile(1.0,ctx->K,0.0,ctx->K,ctx->sfactor,ctx->C,1.0,ctx->K,A);
224:   return(0);
225: }

229: PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)
230: {

234:   SlepcMatTile(0.0,ctx->K,1.0,ctx->K,-ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->K,B);
235:   return(0);
236: }

238: /* - - - H2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

242: PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)
243: {

247:   SlepcMatTile(0.0,ctx->K,-1.0,ctx->K,ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->K,A);
248:   return(0);
249: }

253: PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)
254: {

258:   SlepcMatTile(ctx->sfactor*ctx->sfactor,ctx->M,ctx->sfactor,ctx->C,0.0,ctx->C,ctx->sfactor*ctx->sfactor,ctx->M,B);
259:   return(0);
260: }

slepc-3.7.4/src/pep/impls/linear/index.html0000644000175000017500000000320313107004621020127 0ustar jromanjroman Polynomial Eigenvalue Problem Solvers - PEP
slepc-3.7.4 2017-05-17

Polynomial Eigenvalue Problem Solvers - PEP: Examples NLEVP

The Polynomial Eigenvalue Problem (PEP) solver is the object provided by SLEPc for specifying a polynomial eigenvalue problem. Apart from the specific solvers for this type of problems, there is an EPS-based solver, i.e., it uses a solver from EPS to solve a generalized eigenproblem obtained after linearization.

As in the other solver objects, users can set various options at runtime via the options database (e.g., -pep_nev 4 -pep_type linear). Options can also be set directly in application codes by calling the corresponding routines (e.g., PEPSetDimensions() / PEPSetType()).

linearp.h
linear.c
qeplin.c
makefile
slepc-3.7.4/src/pep/impls/linear/ftn-auto/0000755000175000017500000000000013107004621017671 5ustar jromanjromanslepc-3.7.4/src/pep/impls/linear/ftn-auto/makefile0000644000175000017500000000036113107004621021371 0ustar jromanjroman #requiresdefine 'PETSC_HAVE_FORTRAN' ALL: lib CFLAGS = FFLAGS = SOURCEC = linearf.c SOURCEF = SOURCEH = DIRS = LIBBASE = libslepcpep LOCDIR = src/pep/impls/linear/ftn-auto/ include ${SLEPC_DIR}/lib/slepc/conf/slepc_common slepc-3.7.4/src/pep/impls/linear/ftn-auto/linearf.c0000644000175000017500000000616313107004621021463 0ustar jromanjroman#include "petscsys.h" #include "petscfix.h" #include "petsc/private/fortranimpl.h" /* linear.c */ /* Fortran interface file */ /* * This file was generated automatically by bfort from the C source * file. */ #ifdef PETSC_USE_POINTER_CONVERSION #if defined(__cplusplus) extern "C" { #endif extern void *PetscToPointer(void*); extern int PetscFromPointer(void *); extern void PetscRmPointer(void*); #if defined(__cplusplus) } #endif #else #define PetscToPointer(a) (*(PetscFortranAddr *)(a)) #define PetscFromPointer(a) (PetscFortranAddr)(a) #define PetscRmPointer(a) #endif #include "slepcpep.h" #ifdef PETSC_HAVE_FORTRAN_CAPS #define peplinearsetcompanionform_ PEPLINEARSETCOMPANIONFORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peplinearsetcompanionform_ peplinearsetcompanionform #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peplineargetcompanionform_ PEPLINEARGETCOMPANIONFORM #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peplineargetcompanionform_ peplineargetcompanionform #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peplinearsetexplicitmatrix_ PEPLINEARSETEXPLICITMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peplinearsetexplicitmatrix_ peplinearsetexplicitmatrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peplineargetexplicitmatrix_ PEPLINEARGETEXPLICITMATRIX #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peplineargetexplicitmatrix_ peplineargetexplicitmatrix #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peplinearseteps_ PEPLINEARSETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peplinearseteps_ peplinearseteps #endif #ifdef PETSC_HAVE_FORTRAN_CAPS #define peplineargeteps_ PEPLINEARGETEPS #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) && !defined(FORTRANDOUBLEUNDERSCORE) #define peplineargeteps_ peplineargeteps #endif /* Definitions of Fortran Wrapper routines */ #if defined(__cplusplus) extern "C" { #endif PETSC_EXTERN void PETSC_STDCALL peplinearsetcompanionform_(PEP pep,PetscInt *cform, int *__ierr ){ *__ierr = PEPLinearSetCompanionForm( (PEP)PetscToPointer((pep) ),*cform); } PETSC_EXTERN void PETSC_STDCALL peplineargetcompanionform_(PEP pep,PetscInt *cform, int *__ierr ){ *__ierr = PEPLinearGetCompanionForm( (PEP)PetscToPointer((pep) ),cform); } PETSC_EXTERN void PETSC_STDCALL peplinearsetexplicitmatrix_(PEP pep,PetscBool *explicitmatrix, int *__ierr ){ *__ierr = PEPLinearSetExplicitMatrix( (PEP)PetscToPointer((pep) ),*explicitmatrix); } PETSC_EXTERN void PETSC_STDCALL peplineargetexplicitmatrix_(PEP pep,PetscBool *explicitmatrix, int *__ierr ){ *__ierr = PEPLinearGetExplicitMatrix( (PEP)PetscToPointer((pep) ),explicitmatrix); } PETSC_EXTERN void PETSC_STDCALL peplinearseteps_(PEP pep,EPS eps, int *__ierr ){ *__ierr = PEPLinearSetEPS( (PEP)PetscToPointer((pep) ), (EPS)PetscToPointer((eps) )); } PETSC_EXTERN void PETSC_STDCALL peplineargeteps_(PEP pep,EPS *eps, int *__ierr ){ *__ierr = PEPLinearGetEPS( (PEP)PetscToPointer((pep) ),eps); } #if defined(__cplusplus) } #endif slepc-3.7.4/src/pep/impls/linear/qeplin.c0000644000175000017500000002176413107004621017602 0ustar jromanjroman/* Various types of linearization for quadratic eigenvalue problem. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SLEPc - Scalable Library for Eigenvalue Problem Computations Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain This file is part of SLEPc. SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include "linearp.h" /* Given the quadratic problem (l^2*M + l*C + K)*x = 0 the linearization is A*z = l*B*z for z = [ x ] and A,B defined as follows: [ l*x ] N1: A = [ 0 I ] B = [ I 0 ] [ -K -C ] [ 0 M ] N2: A = [ -K 0 ] B = [ C M ] [ 0 I ] [ I 0 ] S1: A = [ 0 -K ] B = [-K 0 ] [ -K -C ] [ 0 M ] S2: A = [ -K 0 ] B = [ C M ] [ 0 M ] [ M 0 ] H1: A = [ K 0 ] B = [ 0 K ] [ C K ] [-M 0 ] H2: A = [ 0 -K ] B = [ M C ] [ M 0 ] [ 0 M ] */ /* - - - N1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_N1A" PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A) { PetscErrorCode ierr; PetscInt M,N,m,n,i,Istart,Iend; Mat Id; PetscFunctionBegin; ierr = MatGetSize(ctx->M,&M,&N);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->M,&m,&n);CHKERRQ(ierr); ierr = MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);CHKERRQ(ierr); ierr = MatSetSizes(Id,m,n,M,N);CHKERRQ(ierr); ierr = MatSetFromOptions(Id);CHKERRQ(ierr); ierr = MatSetUp(Id);CHKERRQ(ierr); ierr = MatGetOwnershipRange(Id,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;idsfactor,ctx->K,-ctx->sfactor*ctx->dsfactor,ctx->C,A);CHKERRQ(ierr); ierr = MatDestroy(&Id);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_N1B" PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B) { PetscErrorCode ierr; PetscInt M,N,m,n,i,Istart,Iend; Mat Id; PetscFunctionBegin; ierr = MatGetSize(ctx->M,&M,&N);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->M,&m,&n);CHKERRQ(ierr); ierr = MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);CHKERRQ(ierr); ierr = MatSetSizes(Id,m,n,M,N);CHKERRQ(ierr); ierr = MatSetFromOptions(Id);CHKERRQ(ierr); ierr = MatSetUp(Id);CHKERRQ(ierr); ierr = MatGetOwnershipRange(Id,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;isfactor*ctx->sfactor*ctx->dsfactor,ctx->M,B);CHKERRQ(ierr); ierr = MatDestroy(&Id);CHKERRQ(ierr); PetscFunctionReturn(0); } /* - - - N2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_N2A" PetscErrorCode MatCreateExplicit_Linear_N2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A) { PetscErrorCode ierr; PetscInt M,N,m,n,i,Istart,Iend; Mat Id; PetscFunctionBegin; ierr = MatGetSize(ctx->M,&M,&N);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->M,&m,&n);CHKERRQ(ierr); ierr = MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);CHKERRQ(ierr); ierr = MatSetSizes(Id,m,n,M,N);CHKERRQ(ierr); ierr = MatSetFromOptions(Id);CHKERRQ(ierr); ierr = MatSetUp(Id);CHKERRQ(ierr); ierr = MatGetOwnershipRange(Id,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;iK,0.0,Id,0.0,Id,1.0,Id,A);CHKERRQ(ierr); ierr = MatDestroy(&Id);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_N2B" PetscErrorCode MatCreateExplicit_Linear_N2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B) { PetscErrorCode ierr; PetscInt M,N,m,n,i,Istart,Iend; Mat Id; PetscFunctionBegin; ierr = MatGetSize(ctx->M,&M,&N);CHKERRQ(ierr); ierr = MatGetLocalSize(ctx->M,&m,&n);CHKERRQ(ierr); ierr = MatCreate(PetscObjectComm((PetscObject)ctx->M),&Id);CHKERRQ(ierr); ierr = MatSetSizes(Id,m,n,M,N);CHKERRQ(ierr); ierr = MatSetFromOptions(Id);CHKERRQ(ierr); ierr = MatSetUp(Id);CHKERRQ(ierr); ierr = MatGetOwnershipRange(Id,&Istart,&Iend);CHKERRQ(ierr); for (i=Istart;isfactor,ctx->C,ctx->sfactor*ctx->sfactor,ctx->M,1.0,Id,0.0,Id,B);CHKERRQ(ierr); ierr = MatDestroy(&Id);CHKERRQ(ierr); PetscFunctionReturn(0); } /* - - - S1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_S1A" PetscErrorCode MatCreateExplicit_Linear_S1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(0.0,ctx->K,-1.0,ctx->K,-1.0,ctx->K,-ctx->sfactor,ctx->C,A);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_S1B" PetscErrorCode MatCreateExplicit_Linear_S1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(-1.0,ctx->K,0.0,ctx->M,0.0,ctx->M,ctx->sfactor*ctx->sfactor,ctx->M,B);CHKERRQ(ierr); PetscFunctionReturn(0); } /* - - - S2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_S2A" PetscErrorCode MatCreateExplicit_Linear_S2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(-1.0,ctx->K,0.0,ctx->M,0.0,ctx->M,ctx->sfactor*ctx->sfactor,ctx->M,A);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_S2B" PetscErrorCode MatCreateExplicit_Linear_S2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(ctx->sfactor,ctx->C,ctx->sfactor*ctx->sfactor,ctx->M,ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->M,B);CHKERRQ(ierr); PetscFunctionReturn(0); } /* - - - H1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_H1A" PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(1.0,ctx->K,0.0,ctx->K,ctx->sfactor,ctx->C,1.0,ctx->K,A);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_H1B" PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(0.0,ctx->K,1.0,ctx->K,-ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->K,B);CHKERRQ(ierr); PetscFunctionReturn(0); } /* - - - H2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_H2A" PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(0.0,ctx->K,-1.0,ctx->K,ctx->sfactor*ctx->sfactor,ctx->M,0.0,ctx->K,A);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatCreateExplicit_Linear_H2B" PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B) { PetscErrorCode ierr; PetscFunctionBegin; ierr = SlepcMatTile(ctx->sfactor*ctx->sfactor,ctx->M,ctx->sfactor,ctx->C,0.0,ctx->C,ctx->sfactor*ctx->sfactor,ctx->M,B);CHKERRQ(ierr); PetscFunctionReturn(0); } slepc-3.7.4/TAGS_PYTHON0000644000175000017500000003001613107004621013745 0ustar jromanjroman config/gmakegen.py,1260 PKGS = 'sys eps svd pep nep mfn'.split()PKGS11,362 LANGS = dict(c='C', cxx='CXX', cu='CU', F='F')LANGS12,403 def all(iterable):all17,529 def _relpath(path, start=os.path.curdir):_relpath26,730 class debuglogger(object):debuglogger45,1414 def __init__(self, log):__init__46,1441 def write(self, string):write49,1495 class Slepc(object):Slepc52,1557 def __init__(self, slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, verbose=False):__init__53,1578 def petsc_path(self, *args):petsc_path76,2764 def arch_path(self, *args):arch_path82,2972 def read_conf(self):read_conf85,3073 def inconf(self, key, val):inconf105,4024 def relpath(self, root, src):relpath116,4473 def get_sources(self, makevars):get_sources119,4580 def gen_pkg(self, pkg):gen_pkg126,4871 def mkrel(src):mkrel147,5923 def gen_gnumake(self, fd):gen_gnumake157,6370 def write(stem, srcs):write158,6401 def summary(self):summary168,6840 def WriteGnuMake(slepc):WriteGnuMake171,6896 def main(slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, output=None, verbose=False):main185,7507 parser = optparse.OptionParser()parser195,7934 config/configure.py,3616 def AddDefine(conffile,name,value,prefix='SLEPC_'):AddDefine25,978 def CreateFile(basedir,fname,log):CreateFile28,1124 def CreateDir(basedir,dirname,log):CreateDir37,1389 def CreateDirTwo(basedir,dir1,dir2,log):CreateDirTwo47,1696 def CreateDirTest(basedir,dirname,log):CreateDirTest63,2208 def WriteModulesFile(modules,version,sdir):WriteModulesFile76,2595 def WritePkgconfigFile(pkgconfig,version,pversion,sdir,isinstall,prefixdir):WritePkgconfigFile88,3245 def WriteCMakeConfigFile(cmakeconf):WriteCMakeConfigFile99,3953 configdir = os.path.abspath('config')configdir128,5593 argdb = argdb.ArgDB(sys.argv)argdb136,5869 log = log.Log()log137,5899 slepc = slepc.SLEPc(argdb,log)slepc141,6062 petsc = petsc.PETSc(argdb,log)petsc142,6095 arpack = arpack.Arpack(argdb,log)arpack143,6128 blopex = blopex.Blopex(argdb,log)blopex144,6163 blzpack = blzpack.Blzpack(argdb,log)blzpack145,6198 feast = feast.Feast(argdb,log)feast146,6235 primme = primme.Primme(argdb,log)primme147,6268 trlan = trlan.Trlan(argdb,log)trlan148,6303 sowing = sowing.Sowing(argdb,log)sowing149,6336 lapack = lapack.Lapack(argdb,log)lapack150,6371 externalpackages = [arpack, blopex, blzpack, feast, primme, trlan]externalpackages152,6407 optionspackages = [slepc, arpack, blopex, blzpack, feast, primme, trlan, sowing]optionspackages153,6474 checkpackages = [arpack, blopex, blzpack, feast, primme, trlan, lapack]checkpackages154,6556 emptyarch = not ('PETSC_ARCH' in os.environ and os.environ['PETSC_ARCH'])emptyarch182,7549 archname = petsc.archarchname186,7680 libdir = CreateDir(archdir,'lib',log)libdir190,7814 confdir = CreateDirTwo(libdir,'slepc','conf',log)confdir191,7853 f = open(os.path.join(confdir,'slepcvariables'),'r')f215,8696 searchlines = f.readlines()searchlines216,8755 includedir = CreateDir(archdir,'include',log)includedir239,9674 modulesdir = CreateDirTwo(confdir,'modules','slepc',log)modulesdir240,9720 pkgconfdir = CreateDir(libdir,'pkgconfig',log)pkgconfdir241,9777 slepcvars = CreateFile(confdir,'slepcvariables',log)slepcvars242,9824 slepcrules = CreateFile(confdir,'slepcrules',log)slepcrules243,9878 slepcconf = CreateFile(includedir,'slepcconf.h',log)slepcconf244,9928 cmakeconf = CreateFile(confdir,'SLEPcBuildInternal.cmake',log)cmakeconf245,9982 pkgconfig = CreateFile(pkgconfdir,'SLEPc.pc',log)pkgconfig246,10046 modules = CreateFile(modulesdir,slepc.lversion,log)modules248,10117 modules = CreateFile(modulesdir,slepc.lversion+'-'+archname,log)modules250,10178 testruns = set(petsc.test_runs.split())testruns256,10405 testruns = testruns.intersection(set(['C','F90','Fortran','C_Complex','Fortran_Complex','C_NoComplex','Fortran_NoComplex']))testruns257,10445 testruns = testruns.union(set(['C_NoF128']))testruns259,10606 testruns = testruns.union(set(['DATAFILESPATH_Complex']))testruns263,10760 testruns = testruns.union(set(['DATAFILESPATH']))testruns265,10830 globconf = CreateFile(os.path.join(slepc.dir,'lib','slepc','conf'),'slepcvariables',log)globconf282,11531 bfort = petsc.bfortbfort333,13770 bfort = sowing.Install(archdir,petsc.make)bfort335,13817 bfort = os.path.join(archdir,'bin','bfort')bfort340,13945 bfort = sowing.Install(archdir,petsc.make)bfort342,14029 cmakeok = Falsecmakeok356,14569 cmakeok = cmakeboot.main(slepc.dir,petsc.dir,log=log)cmakeok373,15182 petscdate = dateutil.parser.parse(petsc.gitdate)petscdate409,16583 slepcdate = dateutil.parser.parse(slepc.gitdate)slepcdate410,16638 config/package.py,767 class Package:Package25,1015 def __init__(self,argdb,log):__init__27,1031 def ProcessArgs(self,argdb):ProcessArgs39,1393 def Process(self,conf,vars,cmake,petsc,archdir=''):Process63,2246 def Precondition(self,petsc):Precondition80,2879 def Download(self,externdir,builddir,prefix=None):Download96,3689 def ShowHelp(self):ShowHelp157,5949 def ShowInfo(self):ShowInfo168,6670 def LinkWithOutput(self,functions,callbacks,flags):LinkWithOutput173,6841 def Link(self,functions,callbacks,flags):Link224,8675 def FortranLink(self,functions,callbacks,flags):FortranLink229,8835 def GenerateGuesses(self,name):GenerateGuesses258,9742 def FortranLib(self,conf,vars,cmake,dirs,libs,functions,callbacks = []):FortranLib277,10334 config/cmakegen.py,1817 class defaultdict(dict):defaultdict24,771 def __init__(self, default_factory=None, *a, **kw):__init__25,800 def __getitem__(self, key):__getitem__31,1127 def __missing__(self, key):__missing__36,1305 def __reduce__(self):__reduce__41,1502 def copy(self):copy47,1733 def __copy__(self):__copy__49,1792 def __deepcopy__(self, memo):__deepcopy__51,1878 def __repr__(self):__repr__55,2051 class StdoutLogger(object):StdoutLogger59,2211 def write(self,str):write60,2239 def cmakeconditional(key,val):cmakeconditional63,2278 def unexpected():unexpected64,2309 AUTODIRS = set('ftn-auto ftn-custom f90-custom'.split()) # Automatically recurse into these, if they existAUTODIRS88,3074 SKIPDIRS = set('benchmarks'.split()) # Skip these during the buildSKIPDIRS89,3181 NOWARNDIRS = set('tests tutorials'.split()) # Do not warn about mismatch in theseNOWARNDIRS90,3268 def pathsplit(path):pathsplit92,3364 class Mistakes(object):Mistakes101,3647 def __init__(self, log, verbose=False):__init__102,3671 def compareDirLists(self,root, mdirs, dirs):compareDirLists107,3797 def compareSourceLists(self, root, msources, files):compareSourceLists123,4586 def summary(self):summary139,5477 def stripsplit(line):stripsplit145,6041 def pkgsources(pkg, mistakes):pkgsources148,6121 def relpath(filename):relpath169,7166 def writeRoot(f,petscdir,petscdestdir):writeRoot180,7724 def writePackage(f,pkg,pkgdeps,mistakes):writePackage223,9399 def body(indentlevel):body226,9520 def main(slepcdir,petscdir,petscdestdir,log=StdoutLogger(), verbose=False):main249,10504 written = Truewritten289,12204 parser = optparse.OptionParser()parser300,12435 config/packages/sowing.py,144 class Sowing(package.Package):Sowing25,972 def __init__(self,argdb,log):__init__27,1004 def Install(self,archdir,make):Install34,1241 config/packages/primme.py,216 class Primme(package.Package):Primme25,975 def __init__(self,argdb,log):__init__27,1007 def Check(self,conf,vars,cmake,petsc):Check38,1415 def Install(self,conf,vars,cmake,petsc,archdir):Install80,2873 config/packages/slepc.py,195 class SLEPc:SLEPc24,959 def __init__(self,argdb,log):__init__26,973 def ShowHelp(self):ShowHelp34,1276 def InitDir(self):InitDir41,1659 def LoadVersion(self):LoadVersion53,2215 config/packages/blopex.py,161 class Blopex(package.Package):Blopex25,975 def __init__(self,argdb,log):__init__27,1007 def Install(self,conf,vars,cmake,petsc,archdir):Install37,1389 config/packages/petsc.py,255 class PETSc(package.Package):PETSc24,961 def __init__(self,argdb,log):__init__26,992 def Check(self):Check30,1101 def InitDir(self,prefixdir):InitDir33,1164 def LoadVersion(self):LoadVersion45,1562 def LoadConf(self):LoadConf77,2903 config/packages/lapack.py,257 class Lapack(package.Package):Lapack24,947 def __init__(self,argdb,log):__init__26,979 def ShowInfo(self):ShowInfo30,1089 def Process(self,conf,vars,cmake,petsc,archdir=''):Process40,1505 def Check(self,conf,vars,cmake,petsc):Check46,1710 config/packages/blzpack.py,150 class Blzpack(package.Package):Blzpack24,947 def __init__(self,argdb,log):__init__26,980 def Check(self,conf,vars,cmake,petsc):Check34,1219 config/packages/trlan.py,213 class Trlan(package.Package):Trlan25,967 def __init__(self,argdb,log):__init__27,998 def Check(self,conf,vars,cmake,petsc):Check39,1481 def Install(self,conf,vars,cmake,petsc,archdir):Install57,1883 config/packages/arpack.py,262 class Arpack(package.Package):Arpack25,967 def __init__(self,argdb,log):__init__27,999 def Functions(self,petsc):Functions39,1481 def Check(self,conf,vars,cmake,petsc):Check65,2290 def Install(self,conf,vars,cmake,petsc,archdir):Install83,2859 config/packages/feast.py,146 class Feast(package.Package):Feast24,947 def __init__(self,argdb,log):__init__26,978 def Check(self,conf,vars,cmake,petsc):Check34,1218 config/log.py,273 class Log:Log24,942 def Open(self,filename):Open26,954 def Println(self,string):Println33,1150 def Print(self,string):Print37,1227 def NewSection(self,string):NewSection41,1302 def write(self,string):write46,1427 def Exit(self,string):Exit49,1485 config/argdb.py,343 class ArgDB:ArgDB24,942 def __init__(self,argv):__init__26,956 def PopString(self,keyword):PopString45,1724 def PopPath(self,keyword):PopPath61,2095 def PopUrl(self,keyword):PopUrl77,2496 def PopBool(self,keyword):PopBool96,2962 def PopHelp(self):PopHelp112,3328 def ErrorIfNotEmpty(self):ErrorIfNotEmpty128,3703 config/install.py,1067 WindowsError = NoneWindowsError7,94 class Installer:Installer9,117 def __init__(self, args = None):__init__10,134 def setupDirectories(self):setupDirectories26,775 def checkDestdir(self):checkDestdir46,1986 def copytree(self, src, dst, symlinks = False, copyFunc = shutil.copy2, exclude = []):copytree70,3424 def fixConfFile(self, src):fixConfFile122,5490 def fixConf(self):fixConf144,6690 def createUninstaller(self):createUninstaller151,6959 def installIncludes(self):installIncludes183,7859 def installConf(self):installConf189,8151 def installBin(self):installBin194,8376 def installShare(self):installShare201,8644 def copyLib(self, src, dst):copyLib205,8758 def installLib(self):installLib230,9912 def outputInstallDone(self):outputInstallDone235,10066 def outputDestDirDone(self):outputDestDirDone245,10374 def runsetup(self):runsetup254,10642 def runcopy(self):runcopy259,10728 def runfix(self):runfix279,11462 def rundone(self):rundone283,11513 def run(self):run291,11687 config/cmakeboot.py,647 def noCheck(command, status, output, error):noCheck20,746 def quoteIfNeeded(path):quoteIfNeeded23,801 class StdoutLogger(object):StdoutLogger31,1064 def write(self,str):write32,1092 class PETScMaker(script.Script):PETScMaker35,1131 def __init__(self, slepcdir, petscdir, petscarch, argDB = None, framework = None):__init__36,1164 def __str__(self):__str__47,1558 def setupModules(self):setupModules50,1592 def setup(self):setup69,2953 def cmakeboot(self, args, log):cmakeboot75,3093 def main(slepcdir, petscdir, petscarch=os.environ['PETSC_ARCH'], argDB=None, framework=None, log=StdoutLogger(), args=[]):main176,8215 slepc-3.7.4/gmakefile0000644000175000017500000002046513107004621014041 0ustar jromanjroman# -*- mode: makefile-gmake -*- include ./lib/slepc/conf/slepc_variables OBJDIR := $(PETSC_ARCH)/obj MODDIR := $(PETSC_ARCH)/include LIBDIR := $(abspath $(PETSC_ARCH)/lib) pkgs := sys eps svd pep nep mfn # $(call SONAME_FUNCTION,libfoo,abiversion) SONAME_FUNCTION ?= $(1).$(SL_LINKER_SUFFIX).$(2) # $(call SL_LINKER_FUNCTION,libfoo,abiversion,libversion) SL_LINKER_FUNCTION ?= -shared -Wl,-soname,$(call SONAME_FUNCTION,$(notdir $(1)),$(2)) SLEPC_VERSION_MAJOR := $(shell awk '/\#define SLEPC_VERSION_MAJOR/{print $$3;}' ./include/slepcversion.h) SLEPC_VERSION_MINOR := $(shell awk '/\#define SLEPC_VERSION_MINOR/{print $$3;}' ./include/slepcversion.h) SLEPC_VERSION_SUBMINOR := $(shell awk '/\#define SLEPC_VERSION_SUBMINOR/{print $$3;}' ./include/slepcversion.h) SLEPC_VERSION_RELEASE := $(shell awk '/\#define SLEPC_VERSION_RELEASE/{print $$3;}' ./include/slepcversion.h) ifeq ($(SLEPC_VERSION_RELEASE),0) SLEPC_VERSION_MINOR := 0$(SLEPC_VERSION_MINOR) endif libslepc_abi_version := $(SLEPC_VERSION_MAJOR).$(SLEPC_VERSION_MINOR) libslepc_lib_version := $(libslepc_abi_version).$(SLEPC_VERSION_SUBMINOR) soname_function = $(call SONAME_FUNCTION,$(1),$(libslepc_abi_version)) libname_function = $(call SONAME_FUNCTION,$(1),$(libslepc_lib_version)) basename_all = $(basename $(basename $(basename $(basename $(1))))) sl_linker_args = $(call SL_LINKER_FUNCTION,$(call basename_all,$@),$(libslepc_abi_version),$(libslepc_lib_version)) libslepc_shared := $(LIBDIR)/libslepc.$(SL_LINKER_SUFFIX) libslepc_soname := $(call soname_function,$(LIBDIR)/libslepc) libslepc_libname := $(call libname_function,$(LIBDIR)/libslepc) libslepc_static := $(LIBDIR)/libslepc.$(AR_LIB_SUFFIX) libslepcpkgs_shared := $(foreach pkg, $(pkgs), $(LIBDIR)/libslepc$(pkg).$(SL_LINKER_SUFFIX)) libslepcpkgs_soname := $(foreach pkg, $(pkgs), $(call soname_function,$(LIBDIR)/libslepc$(pkg))) libslepcpkgs_libname := $(foreach pkg, $(pkgs), $(call libname_function,$(LIBDIR)/libslepc$(pkg))) libslepcpkgs_static := $(foreach pkg, $(pkgs), $(LIBDIR)/libslepc$(pkg).$(AR_LIB_SUFFIX)) ifeq ($(PETSC_WITH_EXTERNAL_LIB),) libslepcall_shared := $(libslepcpkgs_shared) libslepcall_soname := $(libslepcpkgs_soname) libslepcall_libname := $(libslepcpkgs_libname) libslepcall_static := $(libslepcpkgs_static) else libslepcall_shared := $(libslepc_shared) libslepcall_soname := $(libslepc_soname) libslepcall_libname := $(libslepc_libname) libslepcall_static := $(libslepc_static) endif libslepcall := $(if $(filter-out no,$(BUILDSHAREDLIB)),$(libslepcall_shared) $(libslepcall_soname),$(libslepcall_static)) generated := $(PETSC_ARCH)/lib/slepc/conf/files slepcconf := $(PETSC_ARCH)/include/slepcconf.h slepcvariables := $(PETSC_ARCH)/lib/slepc/conf/slepcvariables all : $(generated) $(libslepcall) .SECONDEXPANSION: # to expand $$(@D)/.DIR #workarround old cygwin versions ifeq ($(PETSC_CYGWIN_BROKEN_PIPE),1) ifeq ($(shell basename $(AR)),ar) V ?=1 endif endif ifeq ($(V),) quiet_HELP := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n" quiet = @printf $(quiet_HELP)$(eval quiet_HELP:=)" %10s %s\n" "$1$2" "$@"; $($1) else ifeq ($(V),0) # Same, but do not print any help quiet = @printf " %10s %s\n" "$1$2" "$@"; $($1) else # Show the full command line quiet = $($1) endif $(generated) : $(slepcconf) $(slepcvariables) $(PYTHON) ./config/gmakegen.py --petsc-arch=$(PETSC_ARCH) --installed-petsc=$(INSTALLED_PETSC) -include $(generated) ifeq ($(PETSC_LANGUAGE),CXXONLY) cc_name := CXX else cc_name := CC endif SLEPC_COMPILE.c = $(call quiet,$(cc_name)) -c $(PCC_FLAGS) $(CFLAGS) $(CCPPFLAGS) $(SLEPC_CC_INCLUDES) $(C_DEPFLAGS) SLEPC_COMPILE.cxx = $(call quiet,CXX) -c $(CXX_FLAGS) $(CFLAGS) $(CCPPFLAGS) $(SLEPC_CC_INCLUDES) $(CXX_DEPFLAGS) SLEPC_COMPILE.cu = $(call quiet,CUDAC) -c $(CUDAC_FLAGS) --compiler-options="$(PCC_FLAGS) $(CXXFLAGS) $(CCPPFLAGS)" SLEPC_GENDEPS.cu = $(call quiet,CUDAC,.dep) --generate-dependencies --output-directory=$(@D) $(CUDAC_FLAGS) --compiler-options="$(PCC_FLAGS) $(CXXFLAGS) $(CCPPFLAGS)" SLEPC_COMPILE.F = $(call quiet,FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) langs := c cu cxx F concatlang = $(foreach lang, $(langs), $(srcs-$(1).$(lang):%.$(lang)=$(OBJDIR)/%.o)) srcs.o := $(foreach pkg, $(pkgs), $(call concatlang,$(pkg))) # with-single-library=1 (default) $(libslepc_libname) : $(srcs.o) | $$(@D)/.DIR $(call quiet,CLINKER) $(sl_linker_args) -o $@ $^ $(SLEPC_EXTERNAL_LIB) $(PETSC_KSP_LIB) ifneq ($(DSYMUTIL),true) $(call quiet,DSYMUTIL) $@ endif $(libslepc_static) : obj := $(srcs.o) define ARCHIVE_RECIPE_WIN32FE_LIB @$(RM) $@ $@.args @cygpath -w $^ > $@.args $(call quiet,AR) $(AR_FLAGS) $@ @$@.args @$(RM) $@.args endef define ARCHIVE_RECIPE_DEFAULT @$(RM) $@ $(call quiet,AR) $(AR_FLAGS) $@ $^ $(call quiet,RANLIB) $@ endef %.$(AR_LIB_SUFFIX) : $$(obj) | $$(@D)/.DIR $(if $(findstring win32fe lib,$(AR)),$(ARCHIVE_RECIPE_WIN32FE_LIB),$(ARCHIVE_RECIPE_DEFAULT)) # with-single-library=0 libpkg = $(foreach pkg, $1, $(LIBDIR)/libslepc$(pkg).$(SL_LINKER_SUFFIX)) define pkg_template $(LIBDIR)/libslepc$(1).$(AR_LIB_SUFFIX) : $(call concatlang,$(1)) $(call libname_function,$(LIBDIR)/libslepc$(1)) : $(call concatlang,$(1)) endef $(foreach pkg,$(pkgs),$(eval $(call pkg_template,$(pkg)))) $(call libname_function,$(LIBDIR)/libslepceps) : libdep := $(call libpkg,sys) $(call libname_function,$(LIBDIR)/libslepcsvd) : libdep := $(call libpkg,eps sys) $(call libname_function,$(LIBDIR)/libslepcpep) : libdep := $(call libpkg,eps sys) $(call libname_function,$(LIBDIR)/libslepcnep) : libdep := $(call libpkg,pep eps sys) $(call libname_function,$(LIBDIR)/libslepcmfn) : libdep := $(call libpkg,sys) # The package libraries technically depend on each other (not just in an order-only way), but only # ABI changes like new or removed symbols requires relinking the dependent libraries. ABI should # only occur when a header is changed, which would trigger recompilation and relinking anyway. # RELINK=1 causes dependent libraries to be relinked anyway. ifeq ($(RELINK),1) libdep_true = $$(libdep) libdep_order = else libdep_true = libdep_order = $$(libdep) endif $(libslepcpkgs_libname) : $(libdep_true) | $(libdep_order) $$(@D)/.DIR $(call quiet,CLINKER) $(sl_linker_args) -o $@ $^ $(SLEPC_EXTERNAL_LIB) ifneq ($(DSYMUTIL),true) $(call quiet,DSYMUTIL) $@ endif %.$(SL_LINKER_SUFFIX) : $(call libname_function,%) @ln -sf $(notdir $<) $@ $(call soname_function,%) : $(call libname_function,%) @ln -sf $(notdir $<) $@ $(OBJDIR)/%.o : %.c | $$(@D)/.DIR $(SLEPC_COMPILE.c) $(abspath $<) -o $@ $(OBJDIR)/%.o : %.cxx | $$(@D)/.DIR $(SLEPC_COMPILE.cxx) $(abspath $<) -o $@ $(OBJDIR)/%.o : %.cu | $$(@D)/.DIR $(SLEPC_COMPILE.cu) $(abspath $<) -o $@ # Compile first so that if there is an error, it comes from a normal compile @$(SLEPC_GENDEPS.cu) $(abspath $<) -o $(@:%.o=%.d) # Generate the dependencies for later $(OBJDIR)/%.o : %.F | $$(@D)/.DIR ifeq ($(FC_MODULE_OUTPUT_FLAG),) cd $(MODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) $(abspath $<) -o $(abspath $@) else $(SLEPC_COMPILE.F) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(MODDIR) endif # Hack: manual dependencies on object files $(OBJDIR)/src/mfn/f90-mod/slepcmfnmod.o : $(OBJDIR)/src/sys/f90-mod/slepcsysmod.o $(OBJDIR)/src/eps/f90-mod/slepcepsmod.o : $(OBJDIR)/src/sys/f90-mod/slepcsysmod.o $(OBJDIR)/src/pep/f90-mod/slepcpepmod.o : $(OBJDIR)/src/eps/f90-mod/slepcepsmod.o $(OBJDIR)/src/nep/f90-mod/slepcnepmod.o : $(OBJDIR)/src/pep/f90-mod/slepcpepmod.o $(OBJDIR)/src/svd/f90-mod/slepcsvdmod.o : $(OBJDIR)/src/eps/f90-mod/slepcepsmod.o # all sources should get recompiled when slepcvariables changes (i.e when configure is rerun or when slepcvariables is manually edited.) $(srcs.o) : $(slepcvariables) %/.DIR : @mkdir -p $(@D) @touch $@ .PRECIOUS: %/.DIR .SUFFIXES: # Clear .SUFFIXES because we don't use implicit rules .DELETE_ON_ERROR: # Delete likely-corrupt target file if rule fails .PHONY: clean all print clean: $(RM) -rf $(OBJDIR) $(LIBDIR)/libslepc* $(MODDIR)/slepc*.mod $(MPIUNI_MOD) $(generated) # make print VAR=the-variable print: @echo $($(VAR)) allobj.d := $(srcs.o:%.o=%.d) # Tell make that allobj.d are all up to date. Without this, the include # below has quadratic complexity, taking more than one second for a # do-nothing build of PETSc (much worse for larger projects) $(allobj.d) : ; -include $(allobj.d) slepc-3.7.4/COPYING.LESSER0000644000175000017500000001672713107004621014227 0ustar jromanjroman GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. slepc-3.7.4/bin/0000755000175000017500000000000013107004621012733 5ustar jromanjromanslepc-3.7.4/bin/maint/0000755000175000017500000000000013107004621014043 5ustar jromanjromanslepc-3.7.4/bin/maint/generateetags.py0000755000175000017500000001154213107004621017241 0ustar jromanjroman#!/usr/bin/env python #!/bin/env python # # Generates etag and ctag (use -noctags to skip generation of ctags) files for SLEPc # Adds file names to list of tags in a TAGS file # Also removes the #define somefunction_ somefunction from the tags list # # # # Walks through the SLEPc tree generating the TAGS file # import os import re from exceptions import * import sys from string import * import commands # # Copies structs from filename to filename.tmp def addFileNameTags(filename): removedefines = 0 f = open(filename) g = open('TAGS','w') line = f.readline() while line: if not (removedefines and line.startswith('#define ')): g.write(line) if line.startswith('\f'): line = f.readline() g.write(line) line = line[0:line.index(',')] if os.path.dirname(line).endswith('custom') and not line.endswith('.h'): removedefines = 1 else: removedefines = 0 line = os.path.basename(line) g.write(line+':^?'+line+'^A,1\n') line = f.readline() f.close() g.close() return def createTags(flist,etagfile,ctagfile): # error check for each parameter? frlist = [os.path.relpath(path,os.getcwd()) for path in flist] (status,output) = commands.getstatusoutput('etags -a -o '+etagfile+' '+' '.join(frlist)) if status: raise RuntimeError("Error running etags "+output) # linux can use '--tag-relative=yes --langmap=c:+.cu'. For others [Mac,bsd] try running ctags in root directory - with relative path to file if ctagfile: (status,output) = commands.getstatusoutput('ctags --tag-relative=yes --langmap=c:+.cu -a -f '+ctagfile+' '+' '.join(frlist)) if status: (status,output) = commands.getstatusoutput('ctags -a -f '+ctagfile+' '+' '.join(frlist)) if status: raise RuntimeError("Error running ctags "+output) return def endsWithSuffix(file,suffixes): # returns 1 if any of the suffixes match - else return 0 for suffix in suffixes: if file.endswith(suffix): return 1 return 0 def startsWithPrefix(file,prefixes): # returns 1 if any of the prefix match - else return 0 for prefix in prefixes: if file.startswith(prefix): return 1 return 0 def badWebIndex(dirname,file): # checks if the file is bad index.html document [i.e not generated] if file != 'index.html': return 0 elif file == 'index.html' and dirname.find('docs/website') >=0: return 0 else: return 1 def processDir(flist,dirname,names): newls = [] gsfx = ['.py','.c','.cu','.F','.F90','.h','.h90','.tex','.cxx','.hh','makefile','.bib','.jl'] bpfx = ['.#'] hsfx = ['.html'] bsfx = ['.py.html','.c.html','.F.html','.h.html','.tex.html','.cxx.html','.hh.html','makefile.html','.gcov.html','.cu.html','.cache.html'] for l in names: if endsWithSuffix(l,gsfx) and not startsWithPrefix(l,bpfx): newls.append(l) elif endsWithSuffix(l,hsfx) and not endsWithSuffix(l,bsfx) and not badWebIndex(dirname,l): # if html - and not bad suffix - and not badWebIndex - then add to etags-list newls.append(l) if newls: flist.extend([os.path.join(dirname,name) for name in newls]) # exclude 'docs' for exname in ['docs']: names.remove(exname) # One-level unique dirs for exname in ['.git','.hg','SCCS', 'output', 'BitKeeper', 'externalpackages', 'bilinear', 'ftn-auto','lib','systems']: if exname in names: names.remove(exname) # check for configure generated PETSC_ARCHes rmnames=[] for name in names: if os.path.isdir(os.path.join(dirname,name,'slepc','conf')): rmnames.append(name) for rmname in rmnames: names.remove(rmname) return def processFiles(dirname,flist): # list files that can't be done with global match [as above] with complete paths import glob files= [] lists=['slepc/conf/*'] for glist in lists: gfiles = glob.glob(glist) for file in gfiles: if not (file.endswith('pyc') or file.endswith('/SCCS') or file.endswith('~')): files.append(file) if files: flist.extend([os.path.join(dirname,name) for name in files]) return def main(ctags): try: os.unlink('TAGS') except: pass etagfile = os.path.join(os.getcwd(),'ETAGS') if ctags: try: os.unlink('CTAGS') except: pass ctagfile = os.path.join(os.getcwd(),'CTAGS') else: ctagfile = None flist = [] (status,output) = commands.getstatusoutput('git ls-files| egrep -v \(^\(systems/\|share/slepc/datafiles/\)\|/output/\|\.\(png\|pdf\|ps\|ppt\|jpg\|tex\)$\)') if not status: flist = output.split('\n') else: os.path.walk(os.getcwd(),processDir,flist) processFiles(os.getcwd(),flist) createTags(flist,etagfile,ctagfile) addFileNameTags(etagfile) try: os.unlink('ETAGS') except: pass # # The classes in this file can also be used in other python-programs by using 'import' # if __name__ == '__main__': if (len(sys.argv) > 1 and sys.argv[1] == "-noctags"): ctags = 0 else: ctags = 1 main(ctags) slepc-3.7.4/bin/maint/generatefortranstubs.py0000755000175000017500000002155313107004621020675 0ustar jromanjroman#!/usr/bin/env python #!/bin/env python # # Generates fortran stubs for PETSc using Sowings bfort program # import os # def FixFile(filename): ''' Fixes the C fortran stub files generated by bfort''' import re ff = open(filename) data = ff.read() ff.close() # gotta be a better way to do this data = re.subn('\nvoid ','\nPETSC_EXTERN void PETSC_STDCALL ',data)[0] data = re.subn('\nPetscErrorCode ','\nPETSC_EXTERN void PETSC_STDCALL ',data)[0] data = re.subn('Petsc([ToRm]*)Pointer\(int\)','Petsc\\1Pointer(void*)',data)[0] data = re.subn('PetscToPointer\(a\) \(a\)','PetscToPointer(a) (*(PetscFortranAddr *)(a))',data)[0] data = re.subn('PetscFromPointer\(a\) \(int\)\(a\)','PetscFromPointer(a) (PetscFortranAddr)(a)',data)[0] data = re.subn('PetscToPointer\( \*\(int\*\)','PetscToPointer(',data)[0] data = re.subn('MPI_Comm comm','MPI_Comm *comm',data)[0] data = re.subn('\(MPI_Comm\)PetscToPointer\( \(comm\) \)','MPI_Comm_f2c(*(MPI_Fint*)(comm))',data)[0] data = re.subn('\(PetscInt\* \)PetscToPointer','',data)[0] data = re.subn('\(Tao\* \)PetscToPointer','',data)[0] data = re.subn('\(TaoConvergedReason\* \)PetscToPointer','',data)[0] data = re.subn('\(TaoLineSearch\* \)PetscToPointer','',data)[0] data = re.subn('\(TaoLineSearchConvergedReason\* \)PetscToPointer','',data)[0] match = re.compile(r"""\b(PETSC|TAO)(_DLL|VEC_DLL|MAT_DLL|DM_DLL|KSP_DLL|SNES_DLL|TS_DLL|FORTRAN_DLL)(EXPORT)""") data = match.sub(r'',data) ff = open(filename, 'w') ff.write('#include "petscsys.h"\n#include "petscfix.h"\n#include "petsc/private/fortranimpl.h"\n'+data) ff.close() def FindSource(filename): import os.path gendir, fname = os.path.split(filename) base, ext = os.path.splitext(fname) sdir, ftn_auto = os.path.split(gendir) if ftn_auto != 'ftn-auto': return None # Something is wrong, skip sfname = os.path.join(sdir, base[:-1] + ext) return sfname sourcefile = FindSource(filename) if sourcefile and os.path.isfile(sourcefile): import shutil shutil.copystat(sourcefile, filename) return def FixDir(petscdir,dir,verbose): ''' Fixes a directory of files generated by bfort. + Fixes the C stub files to be compilable C + Generates a makefile + copies over Fortran interface files that are generated''' mansec = 'unknown' cnames = [] hnames = [] parentdir =os.path.abspath(os.path.join(dir,'..')) for f in os.listdir(dir): ext = os.path.splitext(f)[1] if ext == '.c': FixFile(os.path.join(dir, f)) cnames.append(f) elif ext == '.h90': hnames.append(f) if (cnames != [] or hnames != []): mfile=os.path.abspath(os.path.join(parentdir,'makefile')) try: fd=open(mfile,'r') except: print 'Error! missing file:', mfile return inbuf = fd.read() fd.close() cppflags = "" libbase = "" locdir = "" for line in inbuf.splitlines(): if line.find('CPPFLAGS') >=0: cppflags = line if line.find('LIBBASE') >=0: libbase = line elif line.find('LOCDIR') >=0: locdir = line.rstrip() + 'ftn-auto/' elif line.find('SUBMANSEC') >=0: mansec = line.split('=')[1].lower().strip() elif line.find('MANSEC') >=0: mansec = line.split('=')[1].lower().strip() # now assemble the makefile outbuf = '\n' outbuf += "#requiresdefine 'PETSC_HAVE_FORTRAN'\n" outbuf += 'ALL: lib\n' outbuf += cppflags + '\n' outbuf += 'CFLAGS =\n' outbuf += 'FFLAGS =\n' outbuf += 'SOURCEC = ' +' '.join(cnames)+ '\n' outbuf += 'SOURCEF =\n' outbuf += 'SOURCEH = ' +' '.join(hnames)+ '\n' outbuf += 'DIRS =\n' outbuf += libbase + '\n' outbuf += locdir + '\n' outbuf += 'include ${SLEPC_DIR}/lib/slepc/conf/slepc_common\n' ff = open(os.path.join(dir, 'makefile'), 'w') ff.write(outbuf) ff.close() # if dir is empty - remove it if os.path.exists(dir) and os.path.isdir(dir) and os.listdir(dir) == []: os.rmdir(dir) # save Fortran interface file generated (it is merged with others in a post-processing step) modfile = os.path.join(parentdir,'f90module.f90') if os.path.exists(modfile): if verbose: print 'Generating F90 interface for '+modfile fd = open(modfile) txt = fd.read() fd.close() if txt: if not os.path.isdir(os.path.join(petscdir,'include','slepc','finclude','ftn-auto')): os.mkdir(os.path.join(petscdir,'include','slepc','finclude','ftn-auto')) if not os.path.isdir(os.path.join(petscdir,'include','slepc','finclude','ftn-auto',mansec+'-tmpdir')): os.mkdir(os.path.join(petscdir,'include','slepc','finclude','ftn-auto',mansec+'-tmpdir')) fname = os.path.join(petscdir,'include','slepc','finclude','ftn-auto',mansec+'-tmpdir',parentdir.replace('/','_')+'.h90') fd =open(fname,'w') fd.write(txt) fd.close() os.remove(modfile) def PrepFtnDir(dir): ''' Generate a fnt-auto directory if needed''' import shutil if os.path.exists(dir) and not os.path.isdir(dir): raise RuntimeError('Error - specified path is not a dir: ' + dir) elif not os.path.exists(dir): os.mkdir(dir) else: files = os.listdir(dir) for file in files: if os.path.isdir(os.path.join(dir,file)): shutil.rmtree(os.path.join(dir,file)) else: os.remove(os.path.join(dir,file)) return def processDir(arg,dirname,names): ''' Runs bfort on a directory and then fixes the files generated by bfort including moving generated F90 fortran interface files''' import commands petscdir = arg[0] bfort = arg[1] verbose = arg[2] newls = [] outdir = os.path.join(dirname,'ftn-auto') for l in names: if os.path.splitext(l)[1] in ['.c','.h','.cu']: newls.append(l) if newls: PrepFtnDir(outdir) options = ['-dir '+outdir, '-mnative', '-ansi', '-nomsgs', '-noprofile', '-anyname', '-mapptr', '-mpi', '-shortargname', '-ferr', '-ptrprefix Petsc', '-ptr64 PETSC_USE_POINTER_CONVERSION', '-fcaps PETSC_HAVE_FORTRAN_CAPS', '-fuscore PETSC_HAVE_FORTRAN_UNDERSCORE', '-f90mod_skip_header','-f90modfile','f90module.f90'] cmd = 'cd '+dirname+'; BFORT_CONFIG_PATH='+os.path.join(petscdir,'lib','slepc','conf')+' '+bfort+' '+' '.join(options+newls) (status,output) = commands.getstatusoutput(cmd) if status: raise RuntimeError('Error running bfort\n'+cmd+'\n'+output) try: FixDir(petscdir,outdir,verbose) except: print 'Error! with FixDir('+outdir+')' # remove from list of subdirectories all directories without source code rmnames=[] for name in names: if name in ['.git','.hg','SCCS', 'output', 'BitKeeper', 'examples', 'externalpackages', 'bilinear', 'ftn-auto','fortran','bin','maint','ftn-custom','config','f90-custom','ftn-kernels']: rmnames.append(name) # skip for ./configure generated $PETSC_ARCH directories if os.path.isdir(os.path.join(dirname,name,'lib','slepc','conf')): rmnames.append(name) # skip include/slepc directory if name == 'slepc': rmnames.append(name) for rmname in rmnames: if rmname in names: names.remove(rmname) return def processf90interfaces(petscdir,verbose): ''' Takes all the individually generated fortran interface files and merges them into one for each mansec''' for mansec in os.listdir(os.path.join(petscdir,'include','slepc','finclude','ftn-auto')): if verbose: print 'Processing F90 interface for '+mansec if os.path.isdir(os.path.join(petscdir,'include','slepc','finclude','ftn-auto',mansec)): mansec = mansec[:-7] f90inc = os.path.join(petscdir,'include','slepc','finclude','ftn-auto','slepc'+mansec+'.h90') fd = open(f90inc,'w') for sfile in os.listdir(os.path.join(petscdir,'include','slepc','finclude','ftn-auto',mansec+'-tmpdir')): if verbose: print ' Copying in '+sfile fdr = open(os.path.join(petscdir,'include','slepc','finclude','ftn-auto',mansec+'-tmpdir',sfile)) txt = fdr.read() fd.write(txt) fdr.close() fd.close() import shutil shutil.rmtree(os.path.join(petscdir,'include','slepc','finclude','ftn-auto',mansec+'-tmpdir')) FixDir(petscdir,os.path.join(petscdir,'include','slepc','finclude','ftn-auto'),verbose) return def main(petscdir,bfort,dir,verbose): os.path.walk(dir, processDir, [petscdir, bfort,verbose]) return # # generatefortranstubs bfortexectuable -verbose ----- generates fortran stubs for a directory and all its children # generatefortranstubs -merge -verbose ----- merges fortran 90 interfaces definitions that have been generated # if __name__ == '__main__': import sys if len(sys.argv) < 2: sys.exit('Must give the BFORT program or -merge as the first argument') petscdir = os.environ['SLEPC_DIR'] if len(sys.argv) > 2: verbose = 1 else: verbose = 0 if not sys.argv[1].startswith('-'): main(petscdir,sys.argv[1],os.getcwd(),verbose) else: processf90interfaces(petscdir,verbose) slepc-3.7.4/README0000644000175000017500000000701513107004621013046 0ustar jromanjroman=========================================================== SLEPc: Scalable Library for Eigenvalue Problem Computations =========================================================== :Authors: Jose E. Roman, Carmen Campos, Eloy Romero, Andres Tomas :Organization: Universitat Politecnica de Valencia, Spain :Website: http://slepc.upv.es :Contact: slepc-maint@upv.es Overview -------- SLEPc, the Scalable Library for Eigenvalue Problem Computations, is a software package for the solution of *large sparse eigenvalue problems* on parallel computers. It can be used for the solution of problems formulated in either standard or generalized form, as well as other related problems such as the singular value decomposition and the nonlinear eigenproblem. The emphasis of the software is on methods and techniques appropriate for problems in which the associated matrices are sparse. Therefore, most of the methods offered by the library are projection methods such as Krylov-Schur or Jacobi-Davidson. It also provides built-in support for spectral transformation such as shift-and-invert. SLEPc is built on top of PETSc_ the Portable Extensible Toolkit for Scientific Computation. It can be considered an extension of PETSc providing all the functionality necessary for the solution of eigenvalue problems. .. _PETSc: http://www.mcs.anl.gov/petsc/ Documentation ------------- The Users Manual as well as the HTML man pages for the detailed reference of each individual SLEPc routines are included in the SLEPc distribution and can also be found at the SLEPc `online documentation`_. .. _online documentation: http://slepc.upv.es/documentation The main reference for SLEPc is the following paper (see other references at the SLEPc website): - V. Hernandez, J. E. Roman, and V. Vidal, *SLEPc: A Scalable and Flexible Flexible Toolkit for the Solution of Eigenvalue Problems*, ACM Trans. Math. Softw. 31, pp. 351-362 (2005). [DOI_] .. _DOI: http://dx.doi.org/10.1145%2F1089014.1089019 Installation ------------ The installation procedure of SLEPc is very similar to that of PETSc. Briefly, the environment variables ``$SLEPC_DIR`` and ``$PETSC_DIR`` must be set, then the script ``configure`` is executed and finally the libraries are built with the command ``make``. More details can be found in the Users Manual or in the online `installation instructions`_. .. _installation instructions: http://slepc.upv.es/documentation/instal.htm Funding ------- The development of SLEPc has been partially supported by the following grants: - Oficina de Ciencia i Tecnologia, Generalitat Valenciana, CTIDB/2002/54. - Direccio General d'Investigacio i Transferencia de Tecnologia, Generalitat Valenciana, GV06/091. - Ministerio de Ciencia e Innovacion, TIN2009-07519. - Ministerio de Economia y Competitividad, TIN2013-41049-P. Conditions of Use ----------------- Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain SLEPc is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU Lesser General Public License as published by the Free Software Foundation. SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLEPc. If not, see . slepc-3.7.4/COPYING0000644000175000017500000010451313107004621013222 0ustar jromanjroman GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . slepc-3.7.4/lib/0000755000175000017500000000000013107004621012731 5ustar jromanjromanslepc-3.7.4/lib/slepc/0000755000175000017500000000000013107004621014037 5ustar jromanjromanslepc-3.7.4/lib/slepc/conf/0000755000175000017500000000000013107004621014764 5ustar jromanjromanslepc-3.7.4/lib/slepc/conf/slepc_test0000644000175000017500000000345513107004621017063 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # include ${PETSC_DIR}/lib/petsc/conf/test testexamples_BLOPEX: ${TESTEXAMPLES_BLOPEX} testexamples_C_NoF128: ${TESTEXAMPLES_C_NOF128} testexamples_DATAFILESPATH_Complex: ${TESTEXAMPLES_DATAFILESPATH_COMPLEX} buildexamples_BLOPEX: -@${OMAKE} testexamples_BLOPEX TESTEXAMPLES_BLOPEX=`echo ${TESTEXAMPLES_BLOPEX} | sed s/runex[0-9]*[a-z0-9_]*//g` buildexamples_C_NoF128: -@${OMAKE} testexamples_C_NoF128 TESTEXAMPLES_C_NOF128=`echo ${TESTEXAMPLES_C_NOF128} | sed s/runex[0-9]*[a-z0-9_]*//g` slepc_alltests: -@${RM} ${PETSC_ARCH}/lib/slepc/conf/alltests.log alltests.log -@ln -s ${PETSC_ARCH}/lib/slepc/conf/alltests.log alltests.log -@${OMAKE} alltest PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} MPIEXEC="${MPIEXEC}" DATAFILESPATH=${DATAFILESPATH} 2>&1 | tee ${PETSC_ARCH}/lib/slepc/conf/alltests.log @[ `grep Possible ${PETSC_ARCH}/lib/slepc/conf/alltests.log | wc -l` -le 0 ] slepc-3.7.4/lib/slepc/conf/slepc_variables0000644000175000017500000000650213107004621020050 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # include ${PETSC_DIR}/lib/petsc/conf/variables # Variables specific to SLEPc that can be employed in user makefiles SLEPC_LIB_DIR = ${SLEPC_DIR}/${PETSC_ARCH}/lib SLEPC_INCLUDE = -I${SLEPC_DIR}/include -I${SLEPC_DIR}/${PETSC_ARCH}/include SLEPC_CEXT_INCLUDES = ${PRIMME_FLAGS} SLEPC_CC_INCLUDES = ${SLEPC_INCLUDE} ${SLEPC_CEXT_INCLUDES} ${PETSC_CC_INCLUDES} SLEPC_FC_INCLUDES = ${SLEPC_INCLUDE} ${PETSC_FC_INCLUDES} SLEPC_CCPPFLAGS = ${SLEPC_INCLUDE} ${SLEPC_CEXT_INCLUDES} ${PETSC_CCPPFLAGS} SLEPC_FCPPFLAGS = ${SLEPC_INCLUDE} ${PETSC_FCPPFLAGS} SLEPC_C_SH_LIB_PATH = ${CC_LINKER_SLFLAG}${SLEPC_LIB_DIR} SLEPC_F_SH_LIB_PATH = ${FC_LINKER_SLFLAG}${SLEPC_LIB_DIR} # Redefine variables in PETSc makefiles INSTALL_LIB_DIR = ${SLEPC_LIB_DIR} CCPPFLAGS = ${SLEPC_CCPPFLAGS} FCPPFLAGS = ${SLEPC_FCPPFLAGS} # Variables for the different SLEPc modules SLEPC_SYS_LIB_BASIC = -lslepcsys SLEPC_MFN_LIB_BASIC = -lslepcmfn ${SLEPC_SYS_LIB_BASIC} SLEPC_EPS_LIB_BASIC = -lslepceps ${SLEPC_SYS_LIB_BASIC} SLEPC_SVD_LIB_BASIC = -lslepcsvd ${SLEPC_EPS_LIB_BASIC} SLEPC_PEP_LIB_BASIC = -lslepcpep ${SLEPC_EPS_LIB_BASIC} SLEPC_NEP_LIB_BASIC = -lslepcnep ${SLEPC_PEP_LIB_BASIC} SLEPC_LIB_BASIC = -lslepcnep -lslepcpep -lslepcmfn ${SLEPC_SVD_LIB_BASIC} SLEPC_SYS_LIB = ${SLEPC_C_SH_LIB_PATH} -L${SLEPC_LIB_DIR} ${SLEPC_SYS_LIB_BASIC} ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} SLEPC_MFN_LIB = ${SLEPC_C_SH_LIB_PATH} -L${SLEPC_LIB_DIR} ${SLEPC_MFN_LIB_BASIC} ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} SLEPC_EPS_LIB = ${SLEPC_C_SH_LIB_PATH} -L${SLEPC_LIB_DIR} ${SLEPC_EPS_LIB_BASIC} ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} SLEPC_SVD_LIB = ${SLEPC_C_SH_LIB_PATH} -L${SLEPC_LIB_DIR} ${SLEPC_SVD_LIB_BASIC} ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} SLEPC_PEP_LIB = ${SLEPC_C_SH_LIB_PATH} -L${SLEPC_LIB_DIR} ${SLEPC_PEP_LIB_BASIC} ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} SLEPC_NEP_LIB = ${SLEPC_C_SH_LIB_PATH} -L${SLEPC_LIB_DIR} ${SLEPC_NEP_LIB_BASIC} ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} SLEPC_LIB = ${SLEPC_C_SH_LIB_PATH} -L${SLEPC_LIB_DIR} ${SLEPC_LIB_BASIC} ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB} SLEPC_EXTERNAL_LIB = ${ARPACK_LIB} ${BLZPACK_LIB} ${TRLAN_LIB} ${PRIMME_LIB} ${BLOPEX_LIB} ${FEAST_LIB} # Redefine variable used to build shared libraries SHLIBS = libslepcsys libslepcmfn libslepceps libslepcsvd libslepcpep libslepcnep # Include definitions customized by configuration include ${SLEPC_DIR}/${PETSC_ARCH}/lib/slepc/conf/slepcvariables slepc-3.7.4/lib/slepc/conf/bfort-mpi.txt0000644000175000017500000000155513107004621017432 0ustar jromanjroman# Convert Fortran value (passed as pointer) to MPI object in C toptr MPI_Comm MPI_Comm_f2c(*(%s)) toptr MPI_Request MPI_Request_f2c(*(%s)) toptr MPI_Group MPI_Group_f2c(*(%s)) toptr MPI_Op MPI_Op_f2c(*(%s)) toptr MPI_Datatype MPI_Type_f2c(*(%s)) toptr MPI_Win MPI_Win_f2c(*(%s)) toptr MPI_File MPI_File_f2c(*(%s)) toptr MPI_Info MPI_Info_f2c(*(%s)) toptr MPI_Message MPI_Message_f2c(*(%s)) # nativeptr MPI_Comm nativeptr MPI_Request nativeptr MPI_Group nativeptr MPI_Op nativeptr MPI_File nativeptr MPI_Win nativeptr MPI_Datatype nativeptr MPI_Errhandler nativeptr MPI_Info nativeptr MPI_Message native MPI_Aint integer (kind=MPI_ADDRESS_KIND) native MPI_Offset integer (kind=MPI_OFFSET_KIND) native MPI_Count integer (kind=MPI_COUNT_KIND) native MPI_Fint integer # Status is an array, but not an implied pointer native MPI_Status # parm errparm ierr parm errparmlocal __ierr slepc-3.7.4/lib/slepc/conf/bfort-base.txt0000644000175000017500000000065513107004621017557 0ustar jromanjroman# Basic types in C and their Fortran equivalents native int integer native char character native double double precision native float real native short integer*2 native long native size_t native complex complex native dcomplex double precision complex # The default bfort definitions includes petsc. # For this version, to exclude the petsc definitions, # comment out this include include bfort-petsc.txt include bfort-slepc.txt slepc-3.7.4/lib/slepc/conf/slepc_rules0000644000175000017500000002440613107004621017235 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # chk_slepcdir: @mypwd=`pwd`; cd ${SLEPC_DIR} 2>&1 > /dev/null; true_SLEPC_DIR=`pwd`; cd $${mypwd} 2>&1 >/dev/null; \ newpwd=`echo $${mypwd} | sed "s+$${true_SLEPC_DIR}+DUMMY+g"`;\ hasslepc=`echo $${mypwd} | sed "s+slepc-+DUMMY+g"`;\ if [ $${mypwd} = $${newpwd} -a $${hasslepc} != $${mypwd} ]; then \ printf ${PETSC_TEXT_HILIGHT}"*********************Warning*************************\n" ; \ echo "Your SLEPC_DIR may not match the directory you are in";\ echo "SLEPC_DIR " $${true_SLEPC_DIR} "Current directory" $${mypwd};\ printf "******************************************************"${PETSC_TEXT_NORMAL}"\n" ; \ fi slepc_manualpages: -@if [ "${MANSEC}" != "" ] ; then \ DOCTEXT_PATH=${PETSC_DIR}/src/docs/tex/doctext; export DOCTEXT_PATH; \ ${DOCTEXT} -html \ -mpath ${LOC}/docs/manualpages/${MANSEC} -heading SLEPc \ -defn ${SLEPC_DIR}/src/docs/tex/doctext/html.def \ -locdir ${LOCDIR} -mapref ${LOC}/docs/manualpages/manualpages.cit \ ${SOURCEC} ${SOURCEH}; \ chmod -f g+w ${LOC}/docs/manualpages/${MANSEC}/* ; fi slepc_manexamples: -@base=`basename ${LOCDIR}`; \ if [ "$${base}" = "tutorials" -o "$${base}" = "nlevp" ] ; then \ echo "Generating manual example links" ; \ for i in ${EXAMPLESC} ${EXAMPLESF} foo ; do \ if [ "$$i" != "foo" ] ; then \ a=`cat $$i | ${MAPNAMES} -map ${LOC}/docs/manualpages/manualpages.cit \ -printmatch -o /dev/null | sort | uniq` ; \ for j in $$a ; do \ b=`ls ${LOC}/docs/manualpages/*/$${j}.html | cut -f9` ; \ l=`grep -e tutorials -e nlevp $${b} | wc -l`; \ if [ $$l -le 10 ] ; then \ if [ $$l -eq 0 ] ; then \ echo "

Examples

" >> $$b; \ fi; \ echo "BB
" | sed s?BB?${LOCDIR}$$i.html?g >> $$b; \ grep -v /BODY $$b > ltmp; \ echo "" >> ltmp; \ mv -f ltmp $$b; \ fi; \ done; \ fi; \ done; \ fi slepc_html: chk_c2html -@sed -e s?man+../?man+ROOT/docs/manualpages/? ${LOC}/docs/manualpages/manualpages.cit > /tmp/$$USER.htmlmap -@cat ${PETSC_DIR}/src/docs/mpi.www.index >> /tmp/$$USER.htmlmap -@ROOT=`echo ${LOCDIR} | sed -e s?/[a-z]*?/..?g -e s?src/??g -e s?include/??g` ;\ loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; \ ${MKDIR} -p $${loc} ;\ for i in ${SOURCEC} ${SOURCEF} ${SOURCEH} ${EXAMPLESC} ${EXAMPLESF} ${EXAMPLESCH} ${EXAMPLESFH} ${EXAMPLESMATLAB} foo ; do\ if [ -f $$i ]; then \ iroot=`echo $$i | sed -e "s?[a-z.]*/??g"`;\ IROOT=`echo $${i} | sed -e s?[.][.]??g` ;\ if [ "$${IROOT}" != "$${i}" ] ; then \ IROOT=".."; \ else \ IROOT=$${ROOT};\ fi;\ ${RM} $${loc}/$$i.html; \ echo "
Actual source code: $${iroot}

" > $${loc}/$$i.html; \ sed -e "s/CHKERRQ(ierr);//g" -e "s/PetscFunctionReturn(0)/return(0)/g" \ -e "s/ierr [ ]*= //g" $$i | ${C2HTML} -n | ${PETSC_DIR}/bin/maint/fixinclude $$i $${ROOT} | \ egrep -v '(PetscValid|PetscFunctionBegin|PetscCheck|PetscErrorCode ierr;|#if !defined\(__|#define __|#undef __|EXTERN_C )' | \ ${MAPNAMES} -map /tmp/$$USER.htmlmap -inhtml | sed -e s?ROOT?$${IROOT}?g >> $${loc}/$$i.html ; \ fi; \ done -@ROOT=`echo ${LOCDIR} | sed -e s?/[a-z]*?/..?g -e s?src/??g -e s?include/??g` ;\ loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; ${RM} $${loc}/index.html; \ cat ${SLEPC_DIR}/src/docs/manualpages-sec/header_${MANSEC} | sed -e "s?Examples?Manual pages?g" -e "s?PETSC_DIR?$${ROOT}/?g"> $${loc}/index.html; \ echo "

" >> $${loc}/index.html -@loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`;\ if [ "${EXAMPLESC}" != "" ] ; then \ for file in ${EXAMPLESC} foo ; do \ if [ -f $$file ]; then \ cmess=`grep "static char help" $${file} | cut -d\" -f2 | cut -d\. -f1`; \ echo "$${file}: $${cmess}
" >> $${loc}/index.html;\ fi; \ done ;\ else \ for file in ${DIRS} foo; do \ if [ -d $$file ]; then \ echo "$${file}/
" >> $${loc}/index.html; \ fi; \ done; \ echo " " >> $${loc}/index.html; \ for file in ${SOURCEH} ${SOURCEC} ${SOURCEF} foo ; do \ if [ -f $$file ]; then \ echo "$${file}
" >> $${loc}/index.html; \ fi; \ done; \ fi ;\ echo " " >> $${loc}/index.html; \ echo "makefile
" >> $${loc}/index.html -@loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; \ cat makefile | ${C2HTML} | ${MAPNAMES} -map /tmp/$$USER.htmlmap -inhtml > $${loc}/makefile.html -@${RM} /tmp/$$USER.htmlmap tmp buildmod_slepc: -@${OMAKE} clean @${OMAKE} libfastcompile @${OMAKE} modcopy_slepc @${OMAKE} clean modcopy_slepc: @${CP} -f *.mod ${SLEPC_DIR}/${PETSC_ARCH}/include slepc_tree: ${ACTION} -@for dir in ${DIRS} ftn-auto ftn-custom f90-custom; do \ if [ -d $$dir ]; then \ if [ "${INSTALLED_PETSC}" != "" ]; then \ PETSCCONF="${PETSC_DIR}/include/petscconf.h" ; \ else \ PETSCCONF="${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h" ; \ fi; \ r=`grep -w requirespackage $$dir/makefile`; \ if [ "$$?" = 0 ]; then \ PKGFLG=`echo $$r | cut -d \' -f2`;\ grep -w "#define $${PKGFLG}" $${PETSCCONF} > /dev/null; \ if [ "$$?" = 1 ]; then \ continue; \ fi; \ fi; \ r=`grep -w requiresfunction $$dir/makefile`; \ if [ "$$?" = 0 ]; then \ PKGFLG=`echo $$r | cut -d \' -f2`;\ grep -w "#define $${PKGFLG}" $${PETSCCONF} > /dev/null; \ if [ "$$?" = 1 ]; then \ continue; \ fi; \ fi; \ r=`grep -w requiresdefine $$dir/makefile`; \ if [ "$$?" = 0 ]; then \ PKGFLG=`echo $$r | cut -d \' -f2`;\ grep -w "#define $${PKGFLG}" ${SLEPC_DIR}/${PETSC_ARCH}/include/slepcconf.h > /dev/null; \ if [ "$$?" = 1 ]; then \ grep -w "#define $${PKGFLG}" $${PETSCCONF} > /dev/null; \ if [ "$$?" = 1 ]; then \ continue; \ fi; \ fi; \ fi; \ r=`grep -w requireslanguage $$dir/makefile`; \ if [ "$$?" = 0 ]; then \ echo $$r | grep -w ${PETSC_LANGUAGE} > /dev/null; \ if [ "$$?" = 1 ]; then \ continue; \ fi; \ fi; \ r=`grep -w requiresscalar $$dir/makefile`; \ if [ "$$?" = 0 ]; then \ echo $$r | grep -w ${PETSC_SCALAR} > /dev/null; \ if [ "$$?" = 1 ]; then \ continue; \ fi; \ fi; \ r=`grep -w requiresprecision $$dir/makefile`; \ if [ "$$?" = 0 ]; then \ echo $$r | grep -w ${PETSC_PRECISION} > /dev/null; \ if [ "$$?" = 1 ]; then \ continue; \ fi; \ fi; \ else \ continue; \ fi; \ (cd $$dir ; \ if [ ${NO_PRINT_DIR}foo = foo ] ; then echo ${ACTION} in: `pwd`; fi; \ ${OMAKE} slepc_tree ACTION=${ACTION} PETSC_ARCH=${PETSC_ARCH} LOC=${LOC} DATAFILESPATH=${DATAFILESPATH} BASE_DIR=${BASE_DIR} NO_PRINT_DIR=${NO_PRINT_DIR});\ done # builds the SLEPc shared library slepc_shared: chk_makej -@${OMAKE} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} OTHERSHAREDLIBS="${PETSC_KSP_LIB} ${SLEPC_EXTERNAL_LIB}" shared_nomesg # uses the cmake infrastructure to build/rebuild the libraries slepc_ccmake: chk_makej @echo "Building SLEPc using CMake with ${MAKE_NP} build threads" @echo "==========================================" @cd ${SLEPC_DIR}/${PETSC_ARCH} && ${OMAKE} -j ${MAKE_NP} VERBOSE=${VERBOSE} @if [ "${BUILDSHAREDLIB}" = "yes" -a "${DSYMUTIL}" != "true" ]; then \ echo "Running ${DSYMUTIL} on ${SHLIBS}";\ for LIBNAME in ${SHLIBS}; do ${DSYMUTIL} ${INSTALL_LIB_DIR}/$$LIBNAME.${SL_LINKER_SUFFIX}; done; fi @echo "=========================================" slepc_cmake: chk_makej @${OMAKE} slepc_ccmake VERBOSE=1 slepc_gnumake: chk_makej @echo "Building SLEPc using GNU Make with ${MAKE_NP} build threads" @echo "==========================================" @cd ${SLEPC_DIR} && ${OMAKE_PRINTDIR} -f gmakefile -j ${MAKE_NP} V=${V} @echo "=========================================" getlinklibs_slepc: -@echo ${SLEPC_LIB} getincludedirs_slepc: -@echo ${SLEPC_CC_INCLUDES} include ${PETSC_DIR}/lib/petsc/conf/rules include ${SLEPC_DIR}/${PETSC_ARCH}/lib/slepc/conf/slepcrules slepc-3.7.4/lib/slepc/conf/slepc_common0000644000175000017500000000256013107004621017370 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # # SLEPc uses the portable makefile system provided by the PETSc library. # The following include files set customized site, optimization, and version # options. Do NOT remove any of these include files! # # # a dummy target which does nothing - just in case # 'ALL: get mapped into this file' # all_dummy: -@true include ${SLEPC_DIR}/lib/slepc/conf/slepc_variables include ${SLEPC_DIR}/lib/slepc/conf/slepc_rules include ${SLEPC_DIR}/lib/slepc/conf/slepc_test slepc-3.7.4/lib/slepc/conf/bfort-petsc.txt0000644000175000017500000001036013107004621017755 0ustar jromanjroman# these include enums native DMDAStencilType native DMDAInterpolationType native DMDAElementType native DMBoundaryType native PetscDrawMarkerType native ISGlobalToLocalMappingType native ISColoringType native KSPFCGTruncationType native KSPGMRESCGSRefinementType native KSPNormType native KSPCGType native MatSchurComplementAinvType native MatFactorType native MatCompositeType native MatAssemblyType native MatInfoType native MatFactorShiftType native MatColoringWeightType native MPChacoGlobalType native MPChacoLocalType native MPChacoEigenType native MPPTScotchStrategyType native PCJacobiType native PCASMType native PCGASMType native PCCompositeType native PCFieldSplitSchurPreType native PCPARMSGlobalType native PCPARMSLocalType native PCMGType native PCMGCycleType native PCExoticType native PetscSFWindowSyncType native SNESCompositeType native SNESFASType native TaoSubsetType native TSProblemType native TSSundialsLmmType native TSSundialsGramSchmidtType native NormType native PetscViewerVTKFieldType native PetscScalar native PetscReal native PetscBool native PetscSizeT native MatStructure native KSPConvergedReason native SNESConvergedReason native SNESLineSearchReason native TSConvergedReason native BCArrayPart native PetscLogDouble native PetscInt native PetscMPIInt native PetscErrorCode native PetscCookie native PetscEvent native PetscBLASInt native ISColoringValue native MatReal native PetscSysInt # Some structures are like arrays and can be treated as native types native MatInfo native MatStencil native DALocalInfo native MatFactorInfo # Old PETSc types native PetscTruth # nativeptr AO nativeptr DM nativeptr DMLabel nativeptr IS nativeptr ISColoring nativeptr ISLocalToGlobalMapping nativeptr Characteristic nativeptr KSP nativeptr Mat nativeptr MatFDColoring nativeptr MatNullSpace nativeptr MatPartitioning nativeptr PC nativeptr PetscBag nativeptr PetscBagItem nativeptr PetscDraw nativeptr PetscDrawAxis nativeptr PetscDrawHG nativeptr PetscDrawLG nativeptr PetscDrawSP nativeptr PetscDualSpace nativeptr PetscFE nativeptr PetscFV nativeptr PetscLimiter nativeptr PetscMatlabEngine nativeptr PetscObject nativeptr PetscContainer nativeptr PetscProblem nativeptr PetscQuadrature nativeptr PetscRandom nativeptr PetscTable nativeptr PetscViewer nativeptr PetscViewers nativeptr PF nativeptr SNES nativeptr SNESLineSearch nativeptr TS nativeptr TSTrajectory nativeptr Vec nativeptr Vecs nativeptr VecScatter nativeptr PetscSection nativeptr MatMFFD nativeptr TSGLAdapt nativeptr TSAdapt nativeptr PetscCUSPIndices nativeptr PetscSF nativeptr MatColoring nativeptr DMBoundary nativeptr DMInterpolationInfo nativeptr KSPFischerGuess nativeptr MatCoarsen nativeptr MatTransposeColoring nativeptr PetscClassPerfLog nativeptr PetscClassRegLog nativeptr PetscDLLLibrary nativeptr PetscEventPerfLog nativeptr PetscEventRegLog nativeptr PetscFunctionList nativeptr PetscIntStack nativeptr PetscLayout nativeptr PetscObjectList nativeptr PetscOptions nativeptr PetscDS nativeptr PetscSegBuffer nativeptr PetscSpace nativeptr PetscStageLog nativeptr PetscSubcomm nativeptr PetscToken nativeptr PetscViennaCLIndices nativeptr Tao nativeptr TaoDM nativeptr TaoLineSearch nativeptr TSMonitorDrawCtx nativeptr TSMonitorLGCtx nativeptr TSMonitorSPEigCtx nativeptr VecScatterCUSPIndices_PtoP nativeptr VecScatterCUSPIndices_StoS # the following are old PETSc types - they might be requird for older versions # of PETSc nativeptr AOData nativeptr AOData2dGrid nativeptr ClassPerfLog nativeptr ClassRegLog nativeptr DA nativeptr DMMG nativeptr EventPerfLog nativeptr EventRegLog nativeptr IntStack nativeptr ISMapping nativeptr MatSNESMFCtx nativeptr PetscADICFunction nativeptr PetscDLLibraryList nativeptr PetscFList nativeptr PetscFwk nativeptr PetscMap nativeptr PetscOList nativeptr SDA nativeptr SectionReal nativeptr SectionInt nativeptr StageLog nativeptr VecPack nativeptr PetscObjectContainer nativeptr DF nativeptr Discretization nativeptr Draw nativeptr DrawAxis nativeptr DrawLG nativeptr ElementMat nativeptr ElementVec nativeptr FieldClassMap nativeptr GMat nativeptr Grid nativeptr GSNES nativeptr GTS nativeptr GVec nativeptr Mesh nativeptr Partition nativeptr PetscDrawMesh nativeptr SLES nativeptr Stencil nativeptr VarOrdering nativeptr Viewer nativeptr XBWindow # parm errparm z parm errparmlocal __z slepc-3.7.4/lib/slepc/conf/bfort-slepc.txt0000644000175000017500000000207313107004621017747 0ustar jromanjroman# enums native BVOrthogType native BVOrthogRefineType native BVOrthogBlockType native BVMatMultType native DSStateType native DSMatType native EPSProblemType native EPSExtraction native EPSWhich native EPSBalance native EPSErrorType native EPSConv native EPSStop native EPSConvergedReason native EPSPowerShiftType native EPSLanczosReorthogType native EPSPRIMMEMethod native EPSCISSQuadRule native EPSCISSExtraction native FNCombineType native MFNConvergedReason native NEPWhich native NEPConv native NEPStop native NEPErrorType native NEPRefine native NEPRefineScheme native NEPConvergedReason native PEPProblemType native PEPWhich native PEPBasis native PEPScale native PEPRefine native PEPRefineScheme native PEPExtract native PEPErrorType native PEPConv native PEPStop native PEPConvergedReason native STMatMode native SVDWhich native SVDConv native SVDStop native SVDErrorType native SVDConvergedReason # nativeptr EPS nativeptr PEP nativeptr NEP nativeptr SVD nativeptr MFN nativeptr ST nativeptr BV nativeptr FN nativeptr RG nativeptr DS # parm errparm z parm errparmlocal __z slepc-3.7.4/TAGS0000644000175000017500000245705513107004621012666 0ustar jromanjroman bin/maint/generateetags.py,427 generateetags.py:^?generateetags.py^A,1 def addFileNameTags(filename):addFileNameTags22,469 def createTags(flist,etagfile,ctagfile):createTags43,1056 def endsWithSuffix(file,suffixes):endsWithSuffix60,1841 def startsWithPrefix(file,prefixes):startsWithPrefix67,2018 def badWebIndex(dirname,file):badWebIndex74,2197 def processDir(flist,dirname,names):processDir83,2439 def processFiles(dirname,flist):processFiles113,3643 def main(ctags):main127,4082 bin/maint/generatefortranstubs.py,353 generatefortranstubs.py:^?generatefortranstubs.py^A,1 def FixFile(filename):FixFile8,123 def FindSource(filename):FindSource36,1622 def FixDir(petscdir,dir,verbose):FixDir50,2071 def PrepFtnDir(dir):PrepFtnDir130,4922 def processDir(arg,dirname,names):processDir144,5382 def processf90interfaces(petscdir,verbose):processf90interfaces187,7200 def main(petscdir,bfort,dir,verbose):main207,8327 config/argdb.py,343 argdb.py:^?argdb.py^A,1 class ArgDB:ArgDB24,942 def __init__(self,argv):__init__26,956 def PopString(self,keyword):PopString45,1724 def PopPath(self,keyword):PopPath61,2095 def PopUrl(self,keyword):PopUrl77,2496 def PopBool(self,keyword):PopBool96,2962 def PopHelp(self):PopHelp112,3328 def ErrorIfNotEmpty(self):ErrorIfNotEmpty128,3703 config/cmakeboot.py,647 cmakeboot.py:^?cmakeboot.py^A,1 def noCheck(command, status, output, error):noCheck20,746 def quoteIfNeeded(path):quoteIfNeeded23,801 class StdoutLogger(object):StdoutLogger31,1064 def write(self,str):write32,1092 class PETScMaker(script.Script):PETScMaker35,1131 def __init__(self, slepcdir, petscdir, petscarch, argDB = None, framework = None):__init__36,1164 def __str__(self):__str__47,1558 def setupModules(self):setupModules50,1592 def setup(self):setup69,2953 def cmakeboot(self, args, log):cmakeboot75,3093 def main(slepcdir, petscdir, petscarch=os.environ['PETSC_ARCH'], argDB=None, framework=None, log=StdoutLogger(), args=[]):main176,8215 config/cmakegen.py,1817 cmakegen.py:^?cmakegen.py^A,1 class defaultdict(dict):defaultdict24,771 def __init__(self, default_factory=None, *a, **kw):__init__25,800 def __getitem__(self, key):__getitem__31,1127 def __missing__(self, key):__missing__36,1305 def __reduce__(self):__reduce__41,1502 def copy(self):copy47,1733 def __copy__(self):__copy__49,1792 def __deepcopy__(self, memo):__deepcopy__51,1878 def __repr__(self):__repr__55,2051 class StdoutLogger(object):StdoutLogger59,2211 def write(self,str):write60,2239 def cmakeconditional(key,val):cmakeconditional63,2278 def unexpected():unexpected64,2309 AUTODIRS = set('ftn-auto ftn-custom f90-custom'.split()) # Automatically recurse into these, if they existAUTODIRS88,3074 SKIPDIRS = set('benchmarks'.split()) # Skip these during the buildSKIPDIRS89,3181 NOWARNDIRS = set('tests tutorials'.split()) # Do not warn about mismatch in theseNOWARNDIRS90,3268 def pathsplit(path):pathsplit92,3364 class Mistakes(object):Mistakes101,3647 def __init__(self, log, verbose=False):__init__102,3671 def compareDirLists(self,root, mdirs, dirs):compareDirLists107,3797 def compareSourceLists(self, root, msources, files):compareSourceLists123,4586 def summary(self):summary139,5477 def stripsplit(line):stripsplit145,6041 def pkgsources(pkg, mistakes):pkgsources148,6121 def relpath(filename):relpath169,7166 def writeRoot(f,petscdir,petscdestdir):writeRoot180,7724 def writePackage(f,pkg,pkgdeps,mistakes):writePackage223,9399 def body(indentlevel):body226,9520 def main(slepcdir,petscdir,petscdestdir,log=StdoutLogger(), verbose=False):main249,10504 written = Truewritten289,12204 parser = optparse.OptionParser()parser300,12435 config/configure.py,3616 configure.py:^?configure.py^A,1 def AddDefine(conffile,name,value,prefix='SLEPC_'):AddDefine25,978 def CreateFile(basedir,fname,log):CreateFile28,1124 def CreateDir(basedir,dirname,log):CreateDir37,1389 def CreateDirTwo(basedir,dir1,dir2,log):CreateDirTwo47,1696 def CreateDirTest(basedir,dirname,log):CreateDirTest63,2208 def WriteModulesFile(modules,version,sdir):WriteModulesFile76,2595 def WritePkgconfigFile(pkgconfig,version,pversion,sdir,isinstall,prefixdir):WritePkgconfigFile88,3245 def WriteCMakeConfigFile(cmakeconf):WriteCMakeConfigFile99,3953 configdir = os.path.abspath('config')configdir128,5593 argdb = argdb.ArgDB(sys.argv)argdb136,5869 log = log.Log()log137,5899 slepc = slepc.SLEPc(argdb,log)slepc141,6062 petsc = petsc.PETSc(argdb,log)petsc142,6095 arpack = arpack.Arpack(argdb,log)arpack143,6128 blopex = blopex.Blopex(argdb,log)blopex144,6163 blzpack = blzpack.Blzpack(argdb,log)blzpack145,6198 feast = feast.Feast(argdb,log)feast146,6235 primme = primme.Primme(argdb,log)primme147,6268 trlan = trlan.Trlan(argdb,log)trlan148,6303 sowing = sowing.Sowing(argdb,log)sowing149,6336 lapack = lapack.Lapack(argdb,log)lapack150,6371 externalpackages = [arpack, blopex, blzpack, feast, primme, trlan]externalpackages152,6407 optionspackages = [slepc, arpack, blopex, blzpack, feast, primme, trlan, sowing]optionspackages153,6474 checkpackages = [arpack, blopex, blzpack, feast, primme, trlan, lapack]checkpackages154,6556 emptyarch = not ('PETSC_ARCH' in os.environ and os.environ['PETSC_ARCH'])emptyarch182,7549 archname = petsc.archarchname186,7680 libdir = CreateDir(archdir,'lib',log)libdir190,7814 confdir = CreateDirTwo(libdir,'slepc','conf',log)confdir191,7853 f = open(os.path.join(confdir,'slepcvariables'),'r')f215,8696 searchlines = f.readlines()searchlines216,8755 includedir = CreateDir(archdir,'include',log)includedir239,9674 modulesdir = CreateDirTwo(confdir,'modules','slepc',log)modulesdir240,9720 pkgconfdir = CreateDir(libdir,'pkgconfig',log)pkgconfdir241,9777 slepcvars = CreateFile(confdir,'slepcvariables',log)slepcvars242,9824 slepcrules = CreateFile(confdir,'slepcrules',log)slepcrules243,9878 slepcconf = CreateFile(includedir,'slepcconf.h',log)slepcconf244,9928 cmakeconf = CreateFile(confdir,'SLEPcBuildInternal.cmake',log)cmakeconf245,9982 pkgconfig = CreateFile(pkgconfdir,'SLEPc.pc',log)pkgconfig246,10046 modules = CreateFile(modulesdir,slepc.lversion,log)modules248,10117 modules = CreateFile(modulesdir,slepc.lversion+'-'+archname,log)modules250,10178 testruns = set(petsc.test_runs.split())testruns256,10405 testruns = testruns.intersection(set(['C','F90','Fortran','C_Complex','Fortran_Complex','C_NoComplex','Fortran_NoComplex']))testruns257,10445 testruns = testruns.union(set(['C_NoF128']))testruns259,10606 testruns = testruns.union(set(['DATAFILESPATH_Complex']))testruns263,10760 testruns = testruns.union(set(['DATAFILESPATH']))testruns265,10830 globconf = CreateFile(os.path.join(slepc.dir,'lib','slepc','conf'),'slepcvariables',log)globconf282,11531 bfort = petsc.bfortbfort333,13770 bfort = sowing.Install(archdir,petsc.make)bfort335,13817 bfort = os.path.join(archdir,'bin','bfort')bfort340,13945 bfort = sowing.Install(archdir,petsc.make)bfort342,14029 cmakeok = Falsecmakeok356,14569 cmakeok = cmakeboot.main(slepc.dir,petsc.dir,log=log)cmakeok373,15182 petscdate = dateutil.parser.parse(petsc.gitdate)petscdate409,16583 slepcdate = dateutil.parser.parse(slepc.gitdate)slepcdate410,16638 config/gmakegen.py,1260 gmakegen.py:^?gmakegen.py^A,1 PKGS = 'sys eps svd pep nep mfn'.split()PKGS11,362 LANGS = dict(c='C', cxx='CXX', cu='CU', F='F')LANGS12,403 def all(iterable):all17,529 def _relpath(path, start=os.path.curdir):_relpath26,730 class debuglogger(object):debuglogger45,1414 def __init__(self, log):__init__46,1441 def write(self, string):write49,1495 class Slepc(object):Slepc52,1557 def __init__(self, slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, verbose=False):__init__53,1578 def petsc_path(self, *args):petsc_path76,2764 def arch_path(self, *args):arch_path82,2972 def read_conf(self):read_conf85,3073 def inconf(self, key, val):inconf105,4024 def relpath(self, root, src):relpath116,4473 def get_sources(self, makevars):get_sources119,4580 def gen_pkg(self, pkg):gen_pkg126,4871 def mkrel(src):mkrel147,5923 def gen_gnumake(self, fd):gen_gnumake157,6370 def write(stem, srcs):write158,6401 def summary(self):summary168,6840 def WriteGnuMake(slepc):WriteGnuMake171,6896 def main(slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, output=None, verbose=False):main185,7507 parser = optparse.OptionParser()parser195,7934 config/install.py,1067 install.py:^?install.py^A,1 WindowsError = NoneWindowsError7,94 class Installer:Installer9,117 def __init__(self, args = None):__init__10,134 def setupDirectories(self):setupDirectories26,775 def checkDestdir(self):checkDestdir46,1986 def copytree(self, src, dst, symlinks = False, copyFunc = shutil.copy2, exclude = []):copytree70,3424 def fixConfFile(self, src):fixConfFile122,5490 def fixConf(self):fixConf144,6690 def createUninstaller(self):createUninstaller151,6959 def installIncludes(self):installIncludes183,7859 def installConf(self):installConf189,8151 def installBin(self):installBin194,8376 def installShare(self):installShare201,8644 def copyLib(self, src, dst):copyLib205,8758 def installLib(self):installLib230,9912 def outputInstallDone(self):outputInstallDone235,10066 def outputDestDirDone(self):outputDestDirDone245,10374 def runsetup(self):runsetup254,10642 def runcopy(self):runcopy259,10728 def runfix(self):runfix279,11462 def rundone(self):rundone283,11513 def run(self):run291,11687 config/log.py,273 log.py:^?log.py^A,1 class Log:Log24,942 def Open(self,filename):Open26,954 def Println(self,string):Println33,1150 def Print(self,string):Print37,1227 def NewSection(self,string):NewSection41,1302 def write(self,string):write46,1427 def Exit(self,string):Exit49,1485 config/package.py,767 package.py:^?package.py^A,1 class Package:Package25,1015 def __init__(self,argdb,log):__init__27,1031 def ProcessArgs(self,argdb):ProcessArgs39,1393 def Process(self,conf,vars,cmake,petsc,archdir=''):Process63,2246 def Precondition(self,petsc):Precondition80,2879 def Download(self,externdir,builddir,prefix=None):Download96,3689 def ShowHelp(self):ShowHelp157,5949 def ShowInfo(self):ShowInfo168,6670 def LinkWithOutput(self,functions,callbacks,flags):LinkWithOutput173,6841 def Link(self,functions,callbacks,flags):Link224,8675 def FortranLink(self,functions,callbacks,flags):FortranLink229,8835 def GenerateGuesses(self,name):GenerateGuesses258,9742 def FortranLib(self,conf,vars,cmake,dirs,libs,functions,callbacks = []):FortranLib277,10334 config/packages/arpack.py,262 arpack.py:^?arpack.py^A,1 class Arpack(package.Package):Arpack25,967 def __init__(self,argdb,log):__init__27,999 def Functions(self,petsc):Functions39,1481 def Check(self,conf,vars,cmake,petsc):Check65,2290 def Install(self,conf,vars,cmake,petsc,archdir):Install83,2859 config/packages/blopex.py,161 blopex.py:^?blopex.py^A,1 class Blopex(package.Package):Blopex25,975 def __init__(self,argdb,log):__init__27,1007 def Install(self,conf,vars,cmake,petsc,archdir):Install37,1389 config/packages/blzpack.py,150 blzpack.py:^?blzpack.py^A,1 class Blzpack(package.Package):Blzpack24,947 def __init__(self,argdb,log):__init__26,980 def Check(self,conf,vars,cmake,petsc):Check34,1219 config/packages/feast.py,146 feast.py:^?feast.py^A,1 class Feast(package.Package):Feast24,947 def __init__(self,argdb,log):__init__26,978 def Check(self,conf,vars,cmake,petsc):Check34,1218 config/packages/lapack.py,257 lapack.py:^?lapack.py^A,1 class Lapack(package.Package):Lapack24,947 def __init__(self,argdb,log):__init__26,979 def ShowInfo(self):ShowInfo30,1089 def Process(self,conf,vars,cmake,petsc,archdir=''):Process40,1505 def Check(self,conf,vars,cmake,petsc):Check46,1710 config/packages/petsc.py,255 petsc.py:^?petsc.py^A,1 class PETSc(package.Package):PETSc24,961 def __init__(self,argdb,log):__init__26,992 def Check(self):Check30,1101 def InitDir(self,prefixdir):InitDir33,1164 def LoadVersion(self):LoadVersion45,1562 def LoadConf(self):LoadConf77,2903 config/packages/primme.py,216 primme.py:^?primme.py^A,1 class Primme(package.Package):Primme25,975 def __init__(self,argdb,log):__init__27,1007 def Check(self,conf,vars,cmake,petsc):Check38,1415 def Install(self,conf,vars,cmake,petsc,archdir):Install80,2873 config/packages/slepc.py,195 slepc.py:^?slepc.py^A,1 class SLEPc:SLEPc24,959 def __init__(self,argdb,log):__init__26,973 def ShowHelp(self):ShowHelp34,1276 def InitDir(self):InitDir41,1659 def LoadVersion(self):LoadVersion53,2215 config/packages/sowing.py,144 sowing.py:^?sowing.py^A,1 class Sowing(package.Package):Sowing25,972 def __init__(self,argdb,log):__init__27,1004 def Install(self,archdir,make):Install34,1241 config/packages/trlan.py,213 trlan.py:^?trlan.py^A,1 class Trlan(package.Package):Trlan25,967 def __init__(self,argdb,log):__init__27,998 def Check(self,conf,vars,cmake,petsc):Check39,1481 def Install(self,conf,vars,cmake,petsc,archdir):Install57,1883 configure,0 configure:^?configure^A,1 docs/changes.htm,0 changes.htm:^?changes.htm^A,1 docs/faq.htm,0 faq.htm:^?faq.htm^A,1 docs/instal.htm,0 instal.htm:^?instal.htm^A,1 docs/mail_list.htm,0 mail_list.htm:^?mail_list.htm^A,1 docs/makefile,276 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,934 FFLAGS =FFLAGS23,945 SOURCEC =SOURCEC24,956 SOURCEF =SOURCEF25,967 SOURCEH = SOURCEH26,978 DOCS = DOCS27,990 LIBBASE =LIBBASE28,1002 LINCLUDE = ${SOURCEH}LINCLUDE29,1013 DIRS = DIRS30,1035 LOCDIR = docs/LOCDIR31,1047 docs/manual.htm,0 manual.htm:^?manual.htm^A,1 docs/manual/ex1.c,243 ex1.c:^?ex1.c^A,1 static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension.\n\n"help22,924 #undef __FUNCT____FUNCT__28,1178 #define __FUNCT__ __FUNCT__29,1195 int main(int argc,char **argv)main30,1220 docs/manual/ex1f.F,508 ex1f.F:^?ex1f.F^A,1 program mainmain31,1382 100 format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')10076,2741 110 format (/' Number of iterations of the method:',I4)110147,5008 120 format (' Solution method: ',A)120154,5243 130 format (' Number of requested eigenvalues:',I2)130160,5473 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)140165,5647 150 format (' Number of converged eigenpairs:',I2/)150176,6055 160 format (1P,' ',E12.4,' ',E12.4)160194,6786 docs/manual/makefile,218 makefile:^?makefile^A,1 LATEX = pdflatex --shell-escapeLATEX1,0 DOC_TEX = slepc.tex \DOC_TEX3,34 DOC_SRC = $(DOC_TEX) slepc.bblDOC_SRC13,146 DOC_GEN = $(subst .tex,.aux,$(DOC_TEX)) \DOC_GEN15,178 LOCDIR = docs/manual/LOCDIR26,354 include/makefile,348 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,934 FFLAGS =FFLAGS23,945 SOURCEC =SOURCEC24,956 SOURCEF =SOURCEF25,967 SOURCEH = slepc.h slepcsys.h slepcmath.h slepcversion.h slepcblaslapack.h \SOURCEH26,978 LIBBASE = libslepcsysLIBBASE29,1195 DIRS = slepc/finclude slepc/privateDIRS30,1218 LOCDIR = include/LOCDIR31,1258 MANSEC = MANSEC32,1278 include/slepc.h,0 slepc.h:^?slepc.h^A,1 include/slepc/finclude/ftn-custom/makefile,60 makefile:^?makefile^A,1 LOCDIR = include/slepc/finclude/ftn-custom/LOCDIR22,934 include/slepc/finclude/makefile,333 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,971 FFLAGS =FFLAGS25,983 SOURCEC =SOURCEC26,995 SOURCEF =SOURCEF27,1007 SOURCEH = slepc.h slepceps.h slepcst.h slepcsvd.h slepcpep.h \SOURCEH28,1019 LIBBASE = libslepcsysLIBBASE35,1534 DIRS = DIRS36,1558 MANSEC = MANSEC37,1571 LOCDIR = include/slepc/finclude/LOCDIR38,1584 include/slepc/finclude/slepc.h,181 slepc.h:^?slepc.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia3,143 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY12,521 include/slepc/finclude/slepcbv.h,181 slepcbv.h:^?slepcbv.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,205 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,583 include/slepc/finclude/slepcbvdef.h,611 slepcbvdef.h:^?slepcbvdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,205 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,583 #define __SLEPCBVDEF_H__SLEPCBVDEF_H24,1014 #define BV BV27,1080 #define BVType BVType30,1116 #define BVOrthogType BVOrthogType31,1158 #define BVOrthogRefineType BVOrthogRefineType32,1195 #define BVOrthogBlockType BVOrthogBlockType33,1232 #define BVMatMultType BVMatMultType34,1269 #define BVMAT BVMAT36,1307 #define BVSVEC BVSVEC37,1334 #define BVVECS BVVECS38,1362 #define BVCONTIGUOUS BVCONTIGUOUS39,1390 include/slepc/finclude/slepcdef.h,181 slepcdef.h:^?slepcdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,195 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,573 include/slepc/finclude/slepcds.h,181 slepcds.h:^?slepcds.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,207 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,585 include/slepc/finclude/slepcdsdef.h,603 slepcdsdef.h:^?slepcdsdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,205 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,583 #define __SLEPCDSDEF_H__SLEPCDSDEF_H24,1014 #define DS DS27,1080 #define DSType DSType30,1116 #define DSStateType DSStateType31,1151 #define DSMatType DSMatType32,1181 #define DSHEP DSHEP34,1212 #define DSNHEP DSNHEP35,1238 #define DSGHEP DSGHEP36,1265 #define DSGHIEP DSGHIEP37,1292 #define DSGNHEP DSGNHEP38,1320 #define DSSVD DSSVD39,1348 #define DSPEP DSPEP40,1374 #define DSNEP DSNEP41,1400 include/slepc/finclude/slepceps.h,181 slepceps.h:^?slepceps.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,208 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,586 include/slepc/finclude/slepcepsdef.h,1503 slepcepsdef.h:^?slepcepsdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,206 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,584 #define __SLEPCEPSDEF_H__SLEPCEPSDEF_H24,1016 #define EPS EPS32,1240 #define EPSType EPSType35,1277 #define EPSConvergedReason EPSConvergedReason36,1323 #define EPSErrorType EPSErrorType37,1364 #define EPSProblemType EPSProblemType38,1405 #define EPSWhich EPSWhich39,1446 #define EPSExtraction EPSExtraction40,1487 #define EPSBalance EPSBalance41,1528 #define EPSConv EPSConv42,1569 #define EPSStop EPSStop43,1610 #define EPSPowerShiftType EPSPowerShiftType44,1651 #define EPSLanczosReorthogType EPSLanczosReorthogType45,1692 #define EPSPRIMMEMethod EPSPRIMMEMethod46,1733 #define EPSCISSQuadRule EPSCISSQuadRule47,1774 #define EPSCISSExtraction EPSCISSExtraction48,1815 #define EPSPOWER EPSPOWER50,1857 #define EPSSUBSPACE EPSSUBSPACE51,1888 #define EPSARNOLDI EPSARNOLDI52,1922 #define EPSLANCZOS EPSLANCZOS53,1955 #define EPSKRYLOVSCHUR EPSKRYLOVSCHUR54,1988 #define EPSGD EPSGD55,2025 #define EPSJD EPSJD56,2053 #define EPSRQCG EPSRQCG57,2081 #define EPSLOBPCG EPSLOBPCG58,2111 #define EPSCISS EPSCISS59,2143 #define EPSLAPACK EPSLAPACK60,2173 #define EPSARPACK EPSARPACK61,2205 #define EPSBLZPACK EPSBLZPACK62,2237 #define EPSTRLAN EPSTRLAN63,2270 #define EPSBLOPEX EPSBLOPEX64,2301 #define EPSPRIMME EPSPRIMME65,2333 #define EPSFEAST EPSFEAST66,2365 include/slepc/finclude/slepcfn.h,181 slepcfn.h:^?slepcfn.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,207 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,585 include/slepc/finclude/slepcfndef.h,557 slepcfndef.h:^?slepcfndef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,205 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,583 #define __SLEPCFNDEF_H__SLEPCFNDEF_H24,1014 #define FN FN27,1080 #define FNType FNType30,1116 #define FNCombineType FNCombineType31,1153 #define FNCOMBINE FNCOMBINE33,1186 #define FNRATIONAL FNRATIONAL34,1215 #define FNEXP FNEXP35,1245 #define FNLOG FNLOG36,1270 #define FNPHI FNPHI37,1295 #define FNSQRT FNSQRT38,1320 #define FNINVSQRT FNINVSQRT39,1346 include/slepc/finclude/slepcmfn.h,181 slepcmfn.h:^?slepcmfn.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,208 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,586 include/slepc/finclude/slepcmfndef.h,418 slepcmfndef.h:^?slepcmfndef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,206 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,584 #define __SLEPCMFNDEF_H__SLEPCMFNDEF_H24,1016 #define MFN MFN31,1202 #define MFNType MFNType34,1239 #define MFNConvergedReason MFNConvergedReason35,1281 #define MFNKRYLOV MFNKRYLOV37,1319 #define MFNEXPOKIT MFNEXPOKIT38,1351 include/slepc/finclude/slepcnep.h,181 slepcnep.h:^?slepcnep.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,208 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,586 include/slepc/finclude/slepcnepdef.h,786 slepcnepdef.h:^?slepcnepdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,206 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,584 #define __SLEPCNEPDEF_H__SLEPCNEPDEF_H24,1016 #define NEP NEP34,1320 #define NEPType NEPType37,1357 #define NEPConvergedReason NEPConvergedReason38,1399 #define NEPErrorType NEPErrorType39,1436 #define NEPWhich NEPWhich40,1473 #define NEPConv NEPConv41,1510 #define NEPStop NEPStop42,1547 #define NEPRefine NEPRefine43,1584 #define NEPRefineScheme NEPRefineScheme44,1621 #define NEPRII NEPRII46,1659 #define NEPSLP NEPSLP47,1686 #define NEPNARNOLDI NEPNARNOLDI48,1713 #define NEPCISS NEPCISS49,1745 #define NEPINTERPOL NEPINTERPOL50,1773 #define NEPNLEIGS NEPNLEIGS51,1805 include/slepc/finclude/slepcpep.h,181 slepcpep.h:^?slepcpep.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,208 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,586 include/slepc/finclude/slepcpepdef.h,903 slepcpepdef.h:^?slepcpepdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,206 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,584 #define __SLEPCPEPDEF_H__SLEPCPEPDEF_H24,1016 #define PEP PEP33,1280 #define PEPType PEPType36,1317 #define PEPProblemType PEPProblemType37,1359 #define PEPWhich PEPWhich38,1396 #define PEPBasis PEPBasis39,1433 #define PEPScale PEPScale40,1470 #define PEPRefine PEPRefine41,1507 #define PEPRefineScheme PEPRefineScheme42,1544 #define PEPExtract PEPExtract43,1581 #define PEPConv PEPConv44,1618 #define PEPStop PEPStop45,1655 #define PEPErrorType PEPErrorType46,1692 #define PEPConvergedReason PEPConvergedReason47,1729 #define PEPLINEAR PEPLINEAR49,1767 #define PEPQARNOLDI PEPQARNOLDI50,1797 #define PEPTOAR PEPTOAR51,1829 #define PEPSTOAR PEPSTOAR52,1857 #define PEPJD PEPJD53,1886 include/slepc/finclude/slepcrg.h,181 slepcrg.h:^?slepcrg.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,207 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,585 include/slepc/finclude/slepcrgdef.h,425 slepcrgdef.h:^?slepcrgdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,205 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,583 #define __SLEPCRGDEF_H__SLEPCRGDEF_H24,1014 #define RG RG27,1080 #define RGType RGType30,1116 #define RGINTERVAL RGINTERVAL32,1152 #define RGPOLYGON RGPOLYGON33,1183 #define RGELLIPSE RGELLIPSE34,1213 #define RGRING RGRING35,1243 include/slepc/finclude/slepcst.h,181 slepcst.h:^?slepcst.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,205 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,583 include/slepc/finclude/slepcstdef.h,493 slepcstdef.h:^?slepcstdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,205 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,583 #define __SLEPCSTDEF_H__SLEPCSTDEF_H24,1014 #define ST ST29,1121 #define STType STType32,1157 #define STMatMode STMatMode33,1191 #define STSHELL STSHELL35,1221 #define STSHIFT STSHIFT36,1248 #define STSINVERT STSINVERT37,1275 #define STCAYLEY STCAYLEY38,1304 #define STPRECOND STPRECOND39,1332 include/slepc/finclude/slepcsvd.h,181 slepcsvd.h:^?slepcsvd.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia7,208 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY16,586 include/slepc/finclude/slepcsvddef.h,677 slepcsvddef.h:^?slepcsvddef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,206 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,584 #define __SLEPCSVDDEF_H__SLEPCSVDDEF_H24,1016 #define SVD SVD31,1202 #define SVDType SVDType34,1239 #define SVDConvergedReason SVDConvergedReason35,1281 #define SVDErrorType SVDErrorType36,1318 #define SVDWhich SVDWhich37,1355 #define SVDConv SVDConv38,1392 #define SVDStop SVDStop39,1429 #define SVDCROSS SVDCROSS41,1467 #define SVDCYCLIC SVDCYCLIC42,1496 #define SVDLAPACK SVDLAPACK43,1526 #define SVDLANCZOS SVDLANCZOS44,1556 #define SVDTRLANCZOS SVDTRLANCZOS45,1587 include/slepc/finclude/slepcsys.h,181 slepcsys.h:^?slepcsys.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,206 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,584 include/slepc/finclude/slepcsysdef.h,280 slepcsysdef.h:^?slepcsysdef.h^A,1 ! Copyright (c) 2002-2016, Universitat Politecnica de Valencia, SpainValencia6,206 ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESSWARRANTY15,584 #define __SLEPCSYSDEF_H__SLEPCSYSDEF_H25,1017 #define SlepcConvMonitor SlepcConvMonitor27,1042 include/slepc/private/bvimpl.h,10124 bvimpl.h:^?bvimpl.h^A,1 #define _BVIMPL_BVIMPL23,937 PETSC_EXTERN PetscBool BVRegisterAllCalled;BVRegisterAllCalled28,1013 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_Create31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_Copy31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_Mult31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_MultVec31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_MultInPlace31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_Dot31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_DotVec31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_Orthogonalize31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_OrthogonalizeVec31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_Scale31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_Norm31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_NormVec31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_SetRandom31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_MatMult31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_MatMultVec31,1107 PETSC_EXTERN PetscLogEvent BV_Create,BV_Copy,BV_Mult,BV_MultVec,BV_MultInPlace,BV_Dot,BV_DotVec,BV_Orthogonalize,BV_OrthogonalizeVec,BV_Scale,BV_Norm,BV_NormVec,BV_SetRandom,BV_MatMult,BV_MatMultVec,BV_MatProject;BV_MatProject31,1107 typedef struct _BVOps *BVOps;BVOps33,1322 struct _BVOps {_BVOps35,1353 PetscErrorCode (*mult)(BV,PetscScalar,PetscScalar,BV,Mat);mult36,1369 PetscErrorCode (*multvec)(BV,PetscScalar,PetscScalar,Vec,PetscScalar*);multvec37,1430 PetscErrorCode (*multinplace)(BV,Mat,PetscInt,PetscInt);multinplace38,1504 PetscErrorCode (*multinplacetrans)(BV,Mat,PetscInt,PetscInt);multinplacetrans39,1563 PetscErrorCode (*dot)(BV,BV,Mat);dot40,1627 PetscErrorCode (*dotvec)(BV,Vec,PetscScalar*);dotvec41,1663 PetscErrorCode (*dotvec_local)(BV,Vec,PetscScalar*);dotvec_local42,1712 PetscErrorCode (*dotvec_begin)(BV,Vec,PetscScalar*);dotvec_begin43,1767 PetscErrorCode (*dotvec_end)(BV,Vec,PetscScalar*);dotvec_end44,1822 PetscErrorCode (*scale)(BV,PetscInt,PetscScalar);scale45,1875 PetscErrorCode (*norm)(BV,PetscInt,NormType,PetscReal*);norm46,1927 PetscErrorCode (*norm_local)(BV,PetscInt,NormType,PetscReal*);norm_local47,1986 PetscErrorCode (*norm_begin)(BV,PetscInt,NormType,PetscReal*);norm_begin48,2051 PetscErrorCode (*norm_end)(BV,PetscInt,NormType,PetscReal*);norm_end49,2116 PetscErrorCode (*orthogonalize)(BV,Mat);orthogonalize50,2179 PetscErrorCode (*matmult)(BV,Mat,BV);matmult51,2222 PetscErrorCode (*copy)(BV,BV);copy52,2262 PetscErrorCode (*resize)(BV,PetscInt,PetscBool);resize53,2295 PetscErrorCode (*getcolumn)(BV,PetscInt,Vec*);getcolumn54,2346 PetscErrorCode (*restorecolumn)(BV,PetscInt,Vec*);restorecolumn55,2395 PetscErrorCode (*getarray)(BV,PetscScalar**);getarray56,2448 PetscErrorCode (*restorearray)(BV,PetscScalar**);restorearray57,2496 PetscErrorCode (*getarrayread)(BV,const PetscScalar**);getarrayread58,2548 PetscErrorCode (*restorearrayread)(BV,const PetscScalar**);restorearrayread59,2606 PetscErrorCode (*duplicate)(BV,BV*);duplicate60,2668 PetscErrorCode (*create)(BV);create61,2707 PetscErrorCode (*setfromoptions)(PetscOptionItems*,BV);setfromoptions62,2739 PetscErrorCode (*view)(BV,PetscViewer);view63,2797 PetscErrorCode (*destroy)(BV);destroy64,2839 struct _p_BV {_p_BV67,2876 Vec t; /* template vector */t70,2996 PetscInt n,N; /* dimensions of vectors (local, global) */n71,3053 PetscInt n,N; /* dimensions of vectors (local, global) */N71,3053 PetscInt m; /* number of vectors */m72,3132 PetscInt l; /* number of leading columns */l73,3191 PetscInt k; /* number of active columns */k74,3258 PetscInt nc; /* number of constraints */nc75,3324 BVOrthogType orthog_type; /* the method of vector orthogonalization */orthog_type76,3387 BVOrthogRefineType orthog_ref; /* refinement method */orthog_ref77,3467 PetscReal orthog_eta; /* refinement threshold */orthog_eta78,3526 BVOrthogBlockType orthog_block; /* the method of block orthogonalization */orthog_block79,3588 Mat matrix; /* inner product matrix */matrix80,3667 PetscBool indef; /* matrix is indefinite */indef81,3729 BVMatMultType vmm; /* version of matmult operation */vmm82,3791 Vec Bx; /* result of matrix times a vector x */Bx85,3937 PetscObjectId xid; /* object id of vector x */xid86,4012 PetscObjectState xstate; /* state of vector x */xstate87,4075 Vec cv[2]; /* column vectors obtained with BVGetColumn() */cv88,4134 PetscInt ci[2]; /* column indices of obtained vectors */ci89,4218 PetscObjectState st[2]; /* state of obtained vectors */st90,4294 PetscObjectId id[2]; /* object id of obtained vectors */id91,4361 PetscScalar *h,*c; /* orthogonalization coefficients */h92,4432 PetscScalar *h,*c; /* orthogonalization coefficients */c92,4432 PetscReal *omega; /* signature matrix values for indefinite case */omega93,4504 Mat B,C; /* auxiliary dense matrices for matmult operation */B94,4589 Mat B,C; /* auxiliary dense matrices for matmult operation */C94,4589 PetscObjectId Aid; /* object id of matrix A of matmult operation */Aid95,4677 PetscBool defersfo; /* deferred call to setfromoptions */defersfo96,4761 BV cached; /* cached BV to store result of matrix times BV */cached97,4834 PetscObjectState bvstate; /* state of BV when BVApplyMatrixBV() was called */bvstate98,4920 PetscRandom rand; /* random number generator */rand99,5007 PetscBool rrandom; /* reproducible random vectors */rrandom100,5072 PetscScalar *work;work101,5141 PetscInt lwork;lwork102,5169 void *data;data103,5197 #undef __FUNCT____FUNCT__106,5229 #define __FUNCT__ __FUNCT__107,5246 PETSC_STATIC_INLINE PetscErrorCode BV_SafeSqrt(BV bv,PetscScalar alpha,PetscReal *res)BV_SafeSqrt114,5519 #undef __FUNCT____FUNCT__137,6421 #define __FUNCT__ __FUNCT__138,6438 PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMult(BV bv,Vec x)BV_IPMatMult143,6569 #undef __FUNCT____FUNCT__156,6926 #define __FUNCT__ __FUNCT__157,6943 PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCachedBV(BV V)BV_AllocateCachedBV161,7082 #undef __FUNCT____FUNCT__175,7582 #define __FUNCT__ __FUNCT__176,7599 PETSC_STATIC_INLINE PetscErrorCode BV_IPMatMultBV(BV bv)BV_IPMatMultBV181,7745 #undef __FUNCT____FUNCT__199,8246 #define __FUNCT__ __FUNCT__200,8263 PETSC_STATIC_INLINE PetscErrorCode BV_AllocateCoeffs(BV bv)BV_AllocateCoeffs204,8390 #undef __FUNCT____FUNCT__216,8719 #define __FUNCT__ __FUNCT__217,8736 PETSC_STATIC_INLINE PetscErrorCode BV_AllocateSignature(BV bv)BV_AllocateSignature221,8861 #undef __FUNCT____FUNCT__235,9262 #define __FUNCT__ __FUNCT__236,9279 PETSC_STATIC_INLINE PetscErrorCode BV_AllocateMatMult(BV bv,Mat A,PetscInt m)BV_AllocateMatMult240,9416 #define BVAvailableVec BVAvailableVec271,10463 #define BVCheckSizes(BVCheckSizes278,10623 #define BVCheckSizes(BVCheckSizes282,10675 include/slepc/private/dsimpl.h,3316 dsimpl.h:^?dsimpl.h^A,1 #define _DSIMPL_DSIMPL23,946 PETSC_EXTERN PetscBool DSRegisterAllCalled;DSRegisterAllCalled28,1022 PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other;DS_Solve30,1115 PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other;DS_Vectors30,1115 PETSC_EXTERN PetscLogEvent DS_Solve,DS_Vectors,DS_Other;DS_Other30,1115 PETSC_INTERN const char *DSMatName[];DSMatName31,1172 typedef struct _DSOps *DSOps;DSOps33,1211 struct _DSOps {_DSOps35,1242 PetscErrorCode (*allocate)(DS,PetscInt);allocate36,1258 PetscErrorCode (*view)(DS,PetscViewer);view37,1301 PetscErrorCode (*vectors)(DS,DSMatType,PetscInt*,PetscReal*);vectors38,1343 PetscErrorCode (*solve[DS_MAX_SOLVE])(DS,PetscScalar*,PetscScalar*);solve39,1407 PetscErrorCode (*sort)(DS,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*);sort40,1478 PetscErrorCode (*truncate)(DS,PetscInt);truncate41,1570 PetscErrorCode (*update)(DS);update42,1613 PetscErrorCode (*cond)(DS,PetscReal*);cond43,1645 PetscErrorCode (*transharm)(DS,PetscScalar,PetscReal,PetscBool,PetscScalar*,PetscReal*);transharm44,1686 PetscErrorCode (*transrks)(DS,PetscScalar);transrks45,1777 PetscErrorCode (*normalize)(DS,DSMatType,PetscInt);normalize46,1823 PetscErrorCode (*destroy)(DS);destroy47,1877 struct _p_DS {_p_DS50,1914 DSStateType state; /* the current state */state53,2034 PetscInt method; /* identifies the variant to be used */method54,2095 PetscBool compact; /* whether the matrices are stored in compact form */compact55,2172 PetscBool refined; /* get refined vectors instead of regular vectors */refined56,2263 PetscBool extrarow; /* assume the matrix dimension is (n+1) x n */extrarow57,2353 PetscInt ld; /* leading dimension */ld58,2437 PetscInt l; /* number of locked (inactive) leading columns */l59,2498 PetscInt n; /* current dimension */n60,2585 PetscInt m; /* current column dimension (for SVD only) */m61,2646 PetscInt k; /* intermediate dimension (e.g. position of arrow) */k62,2729 PetscInt t; /* length of decomposition when it was truncated */t63,2820 PetscInt bs; /* block size */bs64,2909 SlepcSC sc; /* sorting criterion */sc65,2963 PetscScalar *mat[DS_NUM_MAT]; /* the matrices */mat68,3100 PetscReal *rmat[DS_NUM_MAT]; /* the matrices (real) */rmat69,3156 Mat omat[DS_NUM_MAT]; /* the matrices (PETSc object) */omat70,3219 PetscInt *perm; /* permutation */perm71,3290 void *data; /* placeholder for solver-specific stuff */data72,3345 PetscScalar *work;work73,3426 PetscReal *rwork;rwork74,3450 PetscBLASInt *iwork;iwork75,3475 PetscInt lwork,lrwork,liwork;lwork76,3500 PetscInt lwork,lrwork,liwork;lrwork76,3500 PetscInt lwork,lrwork,liwork;liwork76,3500 #define DSCheckAlloc(DSCheckAlloc84,3617 #define DSCheckSolved(DSCheckSolved85,3661 #define DSCheckAlloc(DSCheckAlloc89,3714 #define DSCheckSolved(DSCheckSolved94,3904 include/slepc/private/epsimpl.h,6663 epsimpl.h:^?epsimpl.h^A,1 #define _EPSIMPL_EPSIMPL23,947 PETSC_EXTERN PetscBool EPSRegisterAllCalled;EPSRegisterAllCalled28,1025 PETSC_EXTERN PetscLogEvent EPS_SetUp,EPS_Solve;EPS_SetUp30,1120 PETSC_EXTERN PetscLogEvent EPS_SetUp,EPS_Solve;EPS_Solve30,1120 typedef struct _EPSOps *EPSOps;EPSOps32,1169 struct _EPSOps {_EPSOps34,1202 PetscErrorCode (*solve)(EPS);solve35,1219 PetscErrorCode (*setup)(EPS);setup36,1251 PetscErrorCode (*setfromoptions)(PetscOptionItems*,EPS);setfromoptions37,1283 PetscErrorCode (*publishoptions)(EPS);publishoptions38,1342 PetscErrorCode (*destroy)(EPS);destroy39,1383 PetscErrorCode (*reset)(EPS);reset40,1417 PetscErrorCode (*view)(EPS,PetscViewer);view41,1449 PetscErrorCode (*backtransform)(EPS);backtransform42,1492 PetscErrorCode (*computevectors)(EPS);computevectors43,1532 #define MAXEPSMONITORS MAXEPSMONITORS49,1645 typedef enum { EPS_STATE_INITIAL,EPS_STATE_INITIAL51,1671 EPS_STATE_SETUP,EPS_STATE_SETUP52,1705 EPS_STATE_SOLVED,EPS_STATE_SOLVED53,1737 EPS_STATE_EIGENVECTORS } EPSStateType;EPS_STATE_EIGENVECTORS54,1770 EPS_STATE_EIGENVECTORS } EPSStateType;EPSStateType54,1770 struct _p_EPS {_p_EPS59,1866 PetscInt max_it; /* maximum number of iterations */max_it62,1989 PetscInt nev; /* number of eigenvalues to compute */nev63,2059 PetscInt ncv; /* number of basis vectors */ncv64,2133 PetscInt mpd; /* maximum dimension of projected problem */mpd65,2198 PetscInt nini; /* number of initial vectors (negative means not copied yet) */nini66,2278 PetscInt nds; /* number of basis vectors of deflation space */nds67,2377 PetscScalar target; /* target value */target68,2461 PetscReal tol; /* tolerance */tol69,2515 EPSConv conv; /* convergence test */conv70,2566 EPSStop stop; /* stopping test */stop71,2624 EPSWhich which; /* which part of the spectrum to be sought */which72,2679 PetscReal inta,intb; /* interval [a,b] for spectrum slicing */inta73,2760 PetscReal inta,intb; /* interval [a,b] for spectrum slicing */intb73,2760 EPSProblemType problem_type; /* which kind of problem to be solved */problem_type74,2837 EPSExtraction extraction; /* which kind of extraction to be applied */extraction75,2913 EPSBalance balance; /* the balancing method */balance76,2993 PetscInt balance_its; /* number of iterations of the balancing method */balance_its77,3055 PetscReal balance_cutoff; /* cutoff value for balancing */balance_cutoff78,3141 PetscBool trueres; /* whether the true residual norm must be computed */trueres79,3209 PetscBool trackall; /* whether all the residuals must be computed */trackall80,3298 PetscBool purify; /* whether eigenvectors need to be purified */purify81,3382 PetscErrorCode (*converged)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);converged84,3541 PetscErrorCode (*convergeddestroy)(void*);convergeddestroy85,3628 PetscErrorCode (*stopping)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*);stopping86,3673 PetscErrorCode (*stoppingdestroy)(void*);stoppingdestroy87,3770 PetscErrorCode (*arbitrary)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*);arbitrary88,3814 void *convergedctx;convergedctx89,3910 void *stoppingctx;stoppingctx90,3942 void *arbitraryctx;arbitraryctx91,3973 PetscErrorCode (*monitor[MAXEPSMONITORS])(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);monitor92,4005 PetscErrorCode (*monitordestroy[MAXEPSMONITORS])(void**);monitordestroy93,4125 void *monitorcontext[MAXEPSMONITORS];monitorcontext94,4185 PetscInt numbermonitors;numbermonitors95,4235 ST st; /* spectral transformation object */st98,4344 DS ds; /* direct solver object */ds99,4416 BV V; /* set of basis vectors and computed eigenvectors */V100,4478 RG rg; /* optional region for filtering */rg101,4566 SlepcSC sc; /* sorting criterion data */sc102,4637 Vec D; /* diagonal matrix for balancing */D103,4701 Vec *IS; /* references to user-provided initial space */IS104,4772 Vec *defl; /* references to user-provided deflation space */defl105,4855 PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */eigr106,4940 PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */eigi106,4940 PetscReal *errest; /* error estimates */errest107,5021 PetscScalar *rr,*ri; /* values computed by user's arbitrary selection function */rr108,5078 PetscScalar *rr,*ri; /* values computed by user's arbitrary selection function */ri108,5078 PetscInt *perm; /* permutation for eigenvalue ordering */perm109,5174 PetscInt nwork; /* number of work vectors */nwork110,5251 Vec *work; /* work vectors */work111,5315 void *data; /* placeholder for solver-specific stuff */data112,5369 EPSStateType state; /* initial -> setup -> solved -> eigenvectors */state115,5524 PetscInt nconv; /* number of converged eigenvalues */nconv116,5608 PetscInt its; /* number of iterations so far computed */its117,5681 PetscInt n,nloc; /* problem dimensions (global, local) */n118,5759 PetscInt n,nloc; /* problem dimensions (global, local) */nloc118,5759 PetscReal nrma,nrmb; /* computed matrix norms */nrma119,5835 PetscReal nrma,nrmb; /* computed matrix norms */nrmb119,5835 PetscBool isgeneralized;isgeneralized120,5898 PetscBool ispositive;ispositive121,5930 PetscBool ishermitian;ishermitian122,5959 EPSConvergedReason reason;reason123,5989 #define EPSCheckSolved(EPSCheckSolved131,6098 #define EPSCheckSolved(EPSCheckSolved135,6152 #undef __FUNCT____FUNCT__142,6369 #define __FUNCT__ __FUNCT__143,6386 PETSC_STATIC_INLINE PetscErrorCode EPS_SetInnerProduct(EPS eps)EPS_SetInnerProduct147,6503 include/slepc/private/fnimpl.h,1812 fnimpl.h:^?fnimpl.h^A,1 #define _FNIMPL_FNIMPL23,946 PETSC_EXTERN PetscBool FNRegisterAllCalled;FNRegisterAllCalled28,1022 PETSC_EXTERN PetscLogEvent FN_Evaluate;FN_Evaluate30,1115 typedef struct _FNOps *FNOps;FNOps32,1156 struct _FNOps {_FNOps34,1187 PetscErrorCode (*evaluatefunction)(FN,PetscScalar,PetscScalar*);evaluatefunction35,1203 PetscErrorCode (*evaluatederivative)(FN,PetscScalar,PetscScalar*);evaluatederivative36,1270 PetscErrorCode (*evaluatefunctionmat)(FN,Mat,Mat);evaluatefunctionmat37,1339 PetscErrorCode (*evaluatefunctionmatsym)(FN,Mat,Mat);evaluatefunctionmatsym38,1392 PetscErrorCode (*evaluatefunctionmatvec)(FN,Mat,Vec);evaluatefunctionmatvec39,1448 PetscErrorCode (*evaluatefunctionmatvecsym)(FN,Mat,Vec);evaluatefunctionmatvecsym40,1504 PetscErrorCode (*setfromoptions)(PetscOptionItems*,FN);setfromoptions41,1563 PetscErrorCode (*view)(FN,PetscViewer);view42,1621 PetscErrorCode (*duplicate)(FN,MPI_Comm,FN*);duplicate43,1663 PetscErrorCode (*destroy)(FN);destroy44,1711 #define FN_MAX_W FN_MAX_W47,1748 struct _p_FN {_p_FN49,1768 PetscScalar alpha; /* inner scaling (argument) */alpha52,1888 PetscScalar beta; /* outer scaling (result) */beta53,1949 Mat W[FN_MAX_W]; /* workspace matrices */W56,2084 PetscInt nw; /* number of allocated W matrices */nw57,2139 PetscInt cw; /* current W matrix */cw58,2206 void *data;data59,2259 #undef __FUNCT____FUNCT__62,2284 #define __FUNCT__ __FUNCT__63,2301 PETSC_STATIC_INLINE PetscErrorCode FN_AllocateWorkMat(FN fn,Mat A,Mat *M)FN_AllocateWorkMat69,2519 #undef __FUNCT____FUNCT__100,3442 #define __FUNCT__ __FUNCT__101,3459 PETSC_STATIC_INLINE PetscErrorCode FN_FreeWorkMat(FN fn,Mat *M)FN_FreeWorkMat105,3576 include/slepc/private/makefile,309 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,934 FFLAGS =FFLAGS23,945 SOURCEC =SOURCEC24,956 SOURCEF =SOURCEF25,967 SOURCEH = epsimpl.h stimpl.h svdimpl.h pepimpl.h \SOURCEH26,978 LIBBASE = libslepcsysLIBBASE28,1109 DIRS = DIRS29,1132 LOCDIR = include/slepc/private/LOCDIR30,1144 MANSEC = MANSEC31,1178 include/slepc/private/mfnimpl.h,2658 mfnimpl.h:^?mfnimpl.h^A,1 #define _MFNIMPL_MFNIMPL23,947 PETSC_EXTERN PetscBool MFNRegisterAllCalled;MFNRegisterAllCalled28,1025 PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve;MFN_SetUp30,1120 PETSC_EXTERN PetscLogEvent MFN_SetUp, MFN_Solve;MFN_Solve30,1120 typedef struct _MFNOps *MFNOps;MFNOps32,1170 struct _MFNOps {_MFNOps34,1203 PetscErrorCode (*solve)(MFN,Vec,Vec);solve35,1220 PetscErrorCode (*setup)(MFN);setup36,1260 PetscErrorCode (*setfromoptions)(PetscOptionItems*,MFN);setfromoptions37,1292 PetscErrorCode (*publishoptions)(MFN);publishoptions38,1351 PetscErrorCode (*destroy)(MFN);destroy39,1392 PetscErrorCode (*reset)(MFN);reset40,1426 PetscErrorCode (*view)(MFN,PetscViewer);view41,1458 #define MAXMFNMONITORS MAXMFNMONITORS47,1573 struct _p_MFN {_p_MFN52,1640 Mat A; /* the problem matrix */A55,1763 FN fn; /* which function to compute */fn56,1821 PetscInt max_it; /* maximum number of iterations */max_it57,1886 PetscInt ncv; /* number of basis vectors */ncv58,1954 PetscReal tol; /* tolerance */tol59,2017 PetscBool errorifnotconverged; /* error out if MFNSolve() does not converge */errorifnotconverged60,2066 PetscErrorCode (*monitor[MAXMFNMONITORS])(MFN,PetscInt,PetscReal,void*);monitor63,2232 PetscErrorCode (*monitordestroy[MAXMFNMONITORS])(void**);monitordestroy64,2307 void *monitorcontext[MAXMFNMONITORS];monitorcontext65,2367 PetscInt numbermonitors;numbermonitors66,2417 BV V; /* set of basis vectors */V69,2526 PetscInt nwork; /* number of work vectors */nwork70,2586 Vec *work; /* work vectors */work71,2648 void *data; /* placeholder for solver-specific stuff */data72,2700 PetscInt its; /* number of iterations so far computed */its75,2854 PetscInt nv; /* size of current Schur decomposition */nv76,2930 PetscReal errest; /* error estimate */errest77,3005 PetscReal bnorm; /* computed norm of right-hand side in current solve */bnorm78,3059 PetscInt setupcalled;setupcalled79,3148 MFNConvergedReason reason;reason80,3178 #undef __FUNCT____FUNCT__83,3211 #define __FUNCT__ __FUNCT__84,3228 PETSC_STATIC_INLINE PetscErrorCode MFN_CreateDenseMat(PetscInt k,Mat *A)MFN_CreateDenseMat88,3359 #undef __FUNCT____FUNCT__109,3847 #define __FUNCT__ __FUNCT__110,3864 PETSC_STATIC_INLINE PetscErrorCode MFN_CreateVec(PetscInt k,Vec *v)MFN_CreateVec114,3979 include/slepc/private/nepimpl.h,7917 nepimpl.h:^?nepimpl.h^A,1 #define _NEPIMPL_NEPIMPL23,947 PETSC_EXTERN PetscBool NEPRegisterAllCalled;NEPRegisterAllCalled28,1025 PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;NEP_SetUp30,1120 PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;NEP_Solve30,1120 PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;NEP_Refine30,1120 PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;NEP_FunctionEval30,1120 PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;NEP_JacobianEval30,1120 PETSC_EXTERN PetscLogEvent NEP_SetUp,NEP_Solve,NEP_Refine,NEP_FunctionEval,NEP_JacobianEval,NEP_DerivativesEval;NEP_DerivativesEval30,1120 typedef struct _NEPOps *NEPOps;NEPOps32,1234 struct _NEPOps {_NEPOps34,1267 PetscErrorCode (*solve)(NEP);solve35,1284 PetscErrorCode (*setup)(NEP);setup36,1316 PetscErrorCode (*setfromoptions)(PetscOptionItems*,NEP);setfromoptions37,1348 PetscErrorCode (*publishoptions)(NEP);publishoptions38,1407 PetscErrorCode (*destroy)(NEP);destroy39,1448 PetscErrorCode (*reset)(NEP);reset40,1482 PetscErrorCode (*view)(NEP,PetscViewer);view41,1514 PetscErrorCode (*computevectors)(NEP);computevectors42,1557 #define MAXNEPMONITORS MAXNEPMONITORS48,1670 typedef enum { NEP_STATE_INITIAL,NEP_STATE_INITIAL50,1696 NEP_STATE_SETUP,NEP_STATE_SETUP51,1730 NEP_STATE_SOLVED,NEP_STATE_SOLVED52,1762 NEP_STATE_EIGENVECTORS } NEPStateType;NEP_STATE_EIGENVECTORS53,1795 NEP_STATE_EIGENVECTORS } NEPStateType;NEPStateType53,1795 typedef enum { NEP_USER_INTERFACE_CALLBACK=1,NEP_USER_INTERFACE_CALLBACK61,2158 NEP_USER_INTERFACE_SPLIT,NEP_USER_INTERFACE_SPLIT62,2204 NEP_USER_INTERFACE_DERIVATIVES } NEPUserInterface;NEP_USER_INTERFACE_DERIVATIVES63,2245 NEP_USER_INTERFACE_DERIVATIVES } NEPUserInterface;NEPUserInterface63,2245 struct _p_NEP {_p_NEP68,2353 PetscInt max_it; /* maximum number of iterations */max_it71,2476 PetscInt nev; /* number of eigenvalues to compute */nev72,2546 PetscInt ncv; /* number of basis vectors */ncv73,2620 PetscInt mpd; /* maximum dimension of projected problem */mpd74,2685 PetscInt nini; /* number of initial vectors (negative means not copied yet) */nini75,2765 PetscScalar target; /* target value */target76,2864 PetscReal tol; /* tolerance */tol77,2918 NEPConv conv; /* convergence test */conv78,2969 NEPStop stop; /* stopping test */stop79,3027 NEPWhich which; /* which part of the spectrum to be sought */which80,3082 NEPRefine refine; /* type of refinement to be applied after solve */refine81,3163 PetscInt npart; /* number of partitions of the communicator */npart82,3249 PetscReal rtol; /* tolerance for refinement */rtol83,3331 PetscInt rits; /* number of iterations of the refinement method */rits84,3397 NEPRefineScheme scheme; /* scheme for solving linear systems within refinement */scheme85,3484 PetscBool trackall; /* whether all the residuals must be computed */trackall86,3577 PetscErrorCode (*computefunction)(NEP,PetscScalar,Mat,Mat,void*);computefunction89,3738 PetscErrorCode (*computejacobian)(NEP,PetscScalar,Mat,void*);computejacobian90,3806 void *functionctx;functionctx91,3870 void *jacobianctx;jacobianctx92,3901 PetscErrorCode (*computederivatives)(NEP,PetscScalar,PetscInt,Mat,void*);computederivatives93,3932 void *derivativesctx;derivativesctx94,4008 PetscErrorCode (*converged)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);converged95,4042 PetscErrorCode (*convergeddestroy)(void*);convergeddestroy96,4129 PetscErrorCode (*stopping)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*);stopping97,4174 PetscErrorCode (*stoppingdestroy)(void*);stoppingdestroy98,4271 void *convergedctx;convergedctx99,4315 void *stoppingctx;stoppingctx100,4347 PetscErrorCode (*monitor[MAXNEPMONITORS])(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);monitor101,4378 PetscErrorCode (*monitordestroy[MAXNEPMONITORS])(void**);monitordestroy102,4498 void *monitorcontext[MAXNEPMONITORS];monitorcontext103,4558 PetscInt numbermonitors;numbermonitors104,4608 DS ds; /* direct solver object */ds107,4717 BV V; /* set of basis vectors and computed eigenvectors */V108,4779 RG rg; /* optional region for filtering */rg109,4867 SlepcSC sc; /* sorting criterion data */sc110,4938 Mat function; /* function matrix */function111,5002 Mat function_pre; /* function matrix (preconditioner) */function_pre112,5059 Mat jacobian; /* Jacobian matrix */jacobian113,5133 Mat derivatives; /* derivatives matrix */derivatives114,5190 Mat *A; /* matrix coefficients of split form */A115,5250 FN *f; /* matrix functions of split form */f116,5325 PetscInt nt; /* number of terms in split form */nt117,5397 MatStructure mstr; /* pattern of split matrices */mstr118,5468 Vec *IS; /* references to user-provided initial space */IS119,5535 PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */eigr120,5618 PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */eigi120,5618 PetscReal *errest; /* error estimates */errest121,5699 PetscInt *perm; /* permutation for eigenvalue ordering */perm122,5756 PetscInt nwork; /* number of work vectors */nwork123,5833 Vec *work; /* work vectors */work124,5897 KSP refineksp; /* ksp used in refinement */refineksp125,5951 PetscSubcomm refinesubc; /* context for sub-communicators */refinesubc126,6015 void *data; /* placeholder for solver-specific stuff */data127,6086 NEPStateType state; /* initial -> setup -> solved -> eigenvectors */state130,6241 PetscInt nconv; /* number of converged eigenvalues */nconv131,6325 PetscInt its; /* number of iterations so far computed */its132,6398 PetscInt n,nloc; /* problem dimensions (global, local) */n133,6476 PetscInt n,nloc; /* problem dimensions (global, local) */nloc133,6476 PetscReal *nrma; /* computed matrix norms */nrma134,6552 NEPUserInterface fui; /* how the user has defined the nonlinear operator */fui135,6615 NEPConvergedReason reason;reason136,6704 #define NEPCheckProblem(NEPCheckProblem144,6813 #define NEPCheckCallback(NEPCheckCallback145,6860 #define NEPCheckSplit(NEPCheckSplit146,6908 #define NEPCheckDerivatives(NEPCheckDerivatives147,6953 #define NEPCheckSolved(NEPCheckSolved148,7004 #define NEPCheckProblem(NEPCheckProblem152,7058 #define NEPCheckCallback(NEPCheckCallback157,7279 #define NEPCheckSplit(NEPCheckSplit162,7549 #define NEPCheckDerivatives(NEPCheckDerivatives167,7802 #define NEPCheckSolved(NEPCheckSolved172,8089 include/slepc/private/pepimpl.h,7129 pepimpl.h:^?pepimpl.h^A,1 #define _PEPIMPL_PEPIMPL23,947 PETSC_EXTERN PetscBool PEPRegisterAllCalled;PEPRegisterAllCalled28,1025 PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine;PEP_SetUp30,1120 PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine;PEP_Solve30,1120 PETSC_EXTERN PetscLogEvent PEP_SetUp,PEP_Solve,PEP_Refine;PEP_Refine30,1120 typedef struct _PEPOps *PEPOps;PEPOps32,1180 struct _PEPOps {_PEPOps34,1213 PetscErrorCode (*solve)(PEP);solve35,1230 PetscErrorCode (*setup)(PEP);setup36,1262 PetscErrorCode (*setfromoptions)(PetscOptionItems*,PEP);setfromoptions37,1294 PetscErrorCode (*publishoptions)(PEP);publishoptions38,1353 PetscErrorCode (*destroy)(PEP);destroy39,1394 PetscErrorCode (*reset)(PEP);reset40,1428 PetscErrorCode (*view)(PEP,PetscViewer);view41,1460 PetscErrorCode (*backtransform)(PEP);backtransform42,1503 PetscErrorCode (*computevectors)(PEP);computevectors43,1543 PetscErrorCode (*extractvectors)(PEP);extractvectors44,1584 #define MAXPEPMONITORS MAXPEPMONITORS50,1697 typedef enum { PEP_STATE_INITIAL,PEP_STATE_INITIAL52,1723 PEP_STATE_SETUP,PEP_STATE_SETUP53,1757 PEP_STATE_SOLVED,PEP_STATE_SOLVED54,1789 PEP_STATE_EIGENVECTORS } PEPStateType;PEP_STATE_EIGENVECTORS55,1822 PEP_STATE_EIGENVECTORS } PEPStateType;PEPStateType55,1822 struct _p_PEP {_p_PEP60,1918 PetscInt max_it; /* maximum number of iterations */max_it63,2041 PetscInt nev; /* number of eigenvalues to compute */nev64,2111 PetscInt ncv; /* number of basis vectors */ncv65,2185 PetscInt mpd; /* maximum dimension of projected problem */mpd66,2250 PetscInt nini; /* number of initial vectors (negative means not copied yet) */nini67,2330 PetscScalar target; /* target value */target68,2429 PetscReal tol; /* tolerance */tol69,2483 PEPConv conv; /* convergence test */conv70,2534 PEPStop stop; /* stopping test */stop71,2592 PEPWhich which; /* which part of the spectrum to be sought */which72,2647 PEPBasis basis; /* polynomial basis used to represent the problem */basis73,2728 PEPProblemType problem_type; /* which kind of problem to be solved */problem_type74,2816 PEPScale scale; /* scaling strategy to be used */scale75,2892 PetscReal sfactor,dsfactor; /* scaling factors */sfactor76,2961 PetscReal sfactor,dsfactor; /* scaling factors */dsfactor76,2961 PetscInt sits; /* number of iterations of the scaling method */sits77,3018 PetscReal slambda; /* norm eigenvalue approximation for scaling */slambda78,3102 PEPRefine refine; /* type of refinement to be applied after solve */refine79,3185 PetscInt npart; /* number of partitions of the communicator */npart80,3271 PetscReal rtol; /* tolerance for refinement */rtol81,3353 PetscInt rits; /* number of iterations of the refinement method */rits82,3419 PEPRefineScheme scheme; /* scheme for solving linear systems within refinement */scheme83,3506 PEPExtract extract; /* type of extraction used */extract84,3599 PetscBool trackall; /* whether all the residuals must be computed */trackall85,3664 PetscErrorCode (*converged)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);converged88,3825 PetscErrorCode (*convergeddestroy)(void*);convergeddestroy89,3912 PetscErrorCode (*stopping)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*);stopping90,3957 PetscErrorCode (*stoppingdestroy)(void*);stoppingdestroy91,4054 void *convergedctx;convergedctx92,4098 void *stoppingctx;stoppingctx93,4130 PetscErrorCode (*monitor[MAXPEPMONITORS])(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);monitor94,4161 PetscErrorCode (*monitordestroy[MAXPEPMONITORS])(void**);monitordestroy95,4281 void *monitorcontext[MAXPEPMONITORS];monitorcontext96,4341 PetscInt numbermonitors;numbermonitors97,4391 ST st; /* spectral transformation object */st100,4501 DS ds; /* direct solver object */ds101,4573 BV V; /* set of basis vectors and computed eigenvectors */V102,4635 RG rg; /* optional region for filtering */rg103,4723 SlepcSC sc; /* sorting criterion data */sc104,4794 Mat *A; /* coefficient matrices of the polynomial */A105,4858 PetscInt nmat; /* number of matrices */nmat106,4938 Vec Dl,Dr; /* diagonal matrices for balancing */Dl107,4998 Vec Dl,Dr; /* diagonal matrices for balancing */Dr107,4998 Vec *IS; /* references to user-provided initial space */IS108,5071 PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */eigr109,5154 PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */eigi109,5154 PetscReal *errest; /* error estimates */errest110,5235 PetscInt *perm; /* permutation for eigenvalue ordering */perm111,5292 PetscReal *pbc; /* coefficients defining the polynomial basis */pbc112,5369 PetscScalar *solvematcoeffs; /* coefficients to compute the matrix to be inverted */solvematcoeffs113,5453 PetscInt nwork; /* number of work vectors */nwork114,5544 Vec *work; /* work vectors */work115,5608 KSP refineksp; /* ksp used in refinement */refineksp116,5662 PetscSubcomm refinesubc; /* context for sub-communicators */refinesubc117,5726 void *data; /* placeholder for solver-specific stuff */data118,5797 PEPStateType state; /* initial -> setup -> solved -> eigenvectors */state121,5952 PetscInt nconv; /* number of converged eigenvalues */nconv122,6036 PetscInt its; /* number of iterations so far computed */its123,6109 PetscInt n,nloc; /* problem dimensions (global, local) */n124,6187 PetscInt n,nloc; /* problem dimensions (global, local) */nloc124,6187 PetscReal *nrma; /* computed matrix norms */nrma125,6263 PetscReal nrml[2]; /* computed matrix norms for the linearization */nrml126,6326 PetscBool sfactor_set; /* flag to indicate the user gave sfactor */sfactor_set127,6411 PetscBool lineariz; /* current solver is based on linearization */lineariz128,6491 PEPConvergedReason reason;reason129,6573 #define PEPCheckSolved(PEPCheckSolved137,6682 #define PEPCheckSolved(PEPCheckSolved141,6736 include/slepc/private/rgimpl.h,971 rgimpl.h:^?rgimpl.h^A,1 #define _RGIMPL_RGIMPL23,946 PETSC_EXTERN PetscBool RGRegisterAllCalled;RGRegisterAllCalled28,1022 typedef struct _RGOps *RGOps;RGOps31,1116 struct _RGOps {_RGOps33,1147 PetscErrorCode (*istrivial)(RG,PetscBool*);istrivial34,1163 PetscErrorCode (*computecontour)(RG,PetscInt,PetscScalar*,PetscScalar*);computecontour35,1209 PetscErrorCode (*checkinside)(RG,PetscReal,PetscReal,PetscInt*);checkinside36,1284 PetscErrorCode (*setfromoptions)(PetscOptionItems*,RG);setfromoptions37,1351 PetscErrorCode (*view)(RG,PetscViewer);view38,1409 PetscErrorCode (*destroy)(RG);destroy39,1451 struct _p_RG {_p_RG42,1488 PetscBool complement; /* region is the complement of the specified one */complement44,1533 PetscReal sfactor; /* scaling factor */sfactor45,1614 PetscReal osfactor; /* old scaling factor, before RGPushScale */osfactor46,1664 void *data;data47,1738 #define RGShowReal(RGShowReal51,1807 include/slepc/private/slepcimpl.h,344 slepcimpl.h:^?slepcimpl.h^A,1 #define _SLEPCIMPL_SLEPCIMPL23,949 PETSC_INTERN PetscBool SlepcBeganPetsc;SlepcBeganPetsc28,1029 #define SlepcHeaderCreate(SlepcHeaderCreate51,1714 struct _n_SlepcConvMonitor {_n_SlepcConvMonitor58,2132 PetscViewer viewer;viewer59,2161 PetscViewerFormat format;format60,2189 PetscInt oldnconv;oldnconv61,2217 include/slepc/private/stimpl.h,4170 stimpl.h:^?stimpl.h^A,1 #define _STIMPL_STIMPL23,937 PETSC_EXTERN PetscBool STRegisterAllCalled;STRegisterAllCalled28,1013 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_SetUp30,1106 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_Apply30,1106 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_ApplyTranspose30,1106 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_MatSetUp30,1106 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_MatMult30,1106 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_MatMultTranspose30,1106 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_MatSolve30,1106 PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;ST_MatSolveTranspose30,1106 typedef struct _STOps *STOps;STOps32,1247 struct _STOps {_STOps34,1278 PetscErrorCode (*setup)(ST);setup35,1294 PetscErrorCode (*apply)(ST,Vec,Vec);apply36,1325 PetscErrorCode (*getbilinearform)(ST,Mat*);getbilinearform37,1364 PetscErrorCode (*applytrans)(ST,Vec,Vec);applytrans38,1410 PetscErrorCode (*setshift)(ST,PetscScalar);setshift39,1454 PetscErrorCode (*setfromoptions)(PetscOptionItems*,ST);setfromoptions40,1500 PetscErrorCode (*postsolve)(ST);postsolve41,1558 PetscErrorCode (*backtransform)(ST,PetscInt,PetscScalar*,PetscScalar*);backtransform42,1593 PetscErrorCode (*destroy)(ST);destroy43,1667 PetscErrorCode (*reset)(ST);reset44,1700 PetscErrorCode (*view)(ST,PetscViewer);view45,1731 PetscErrorCode (*checknullspace)(ST,BV);checknullspace46,1773 typedef enum { ST_STATE_INITIAL,ST_STATE_INITIAL53,1983 ST_STATE_SETUP,ST_STATE_SETUP54,2016 ST_STATE_UPDATED } STStateType;ST_STATE_UPDATED55,2047 ST_STATE_UPDATED } STStateType;STStateType55,2047 struct _p_ST {_p_ST57,2095 Mat *A; /* matrices that define the eigensystem */A60,2215 PetscObjectState *Astate; /* state (to identify the original matrices) */Astate61,2295 Mat *T; /* matrices resulting from transformation */T62,2380 Mat P; /* matrix from which preconditioner is built */P63,2462 PetscInt nmat; /* number of matrices */nmat64,2547 PetscScalar sigma; /* value of the shift */sigma65,2609 PetscBool sigma_set; /* whether the user provided the shift or not */sigma_set66,2671 PetscScalar defsigma; /* default value of the shift */defsigma67,2757 STMatMode shift_matrix;shift_matrix68,2827 MatStructure str; /* whether matrices have the same pattern or not */str69,2860 PetscBool transform; /* whether transformed matrices are computed */transform70,2949 KSP ksp;ksp73,3104 Vec w; /* work vector used in apply operation */w74,3128 Vec D; /* diagonal matrix for balancing */D75,3207 Vec wb; /* balancing requires an extra work vector */wb76,3280 void *data;data77,3363 STStateType state; /* initial -> setup -> with updated matrices */state78,3389 #undef __FUNCT____FUNCT__81,3478 #define __FUNCT__ __FUNCT__82,3495 PETSC_STATIC_INLINE PetscErrorCode ST_AllocateWorkVec(ST st)ST_AllocateWorkVec86,3611 #define STCheckMatrices(STCheckMatrices103,3989 #define STCheckMatrices(STCheckMatrices107,4044 include/slepc/private/svdimpl.h,5140 svdimpl.h:^?svdimpl.h^A,1 #define _SVDIMPL_SVDIMPL23,947 PETSC_EXTERN PetscBool SVDRegisterAllCalled;SVDRegisterAllCalled28,1025 PETSC_EXTERN PetscLogEvent SVD_SetUp,SVD_Solve;SVD_SetUp30,1120 PETSC_EXTERN PetscLogEvent SVD_SetUp,SVD_Solve;SVD_Solve30,1120 typedef struct _SVDOps *SVDOps;SVDOps32,1169 struct _SVDOps {_SVDOps34,1202 PetscErrorCode (*solve)(SVD);solve35,1219 PetscErrorCode (*setup)(SVD);setup36,1251 PetscErrorCode (*setfromoptions)(PetscOptionItems*,SVD);setfromoptions37,1283 PetscErrorCode (*publishoptions)(SVD);publishoptions38,1342 PetscErrorCode (*destroy)(SVD);destroy39,1383 PetscErrorCode (*reset)(SVD);reset40,1417 PetscErrorCode (*view)(SVD,PetscViewer);view41,1449 #define MAXSVDMONITORS MAXSVDMONITORS47,1564 typedef enum { SVD_STATE_INITIAL,SVD_STATE_INITIAL49,1590 SVD_STATE_SETUP,SVD_STATE_SETUP50,1624 SVD_STATE_SOLVED,SVD_STATE_SOLVED51,1656 SVD_STATE_VECTORS } SVDStateType;SVD_STATE_VECTORS52,1689 SVD_STATE_VECTORS } SVDStateType;SVDStateType52,1689 struct _p_SVD {_p_SVD57,1780 Mat OP; /* problem matrix */OP60,1903 PetscInt max_it; /* max iterations */max_it61,1959 PetscInt nsv; /* number of requested values */nsv62,2015 PetscInt ncv; /* basis size */ncv63,2083 PetscInt mpd; /* maximum dimension of projected problem */mpd64,2135 PetscInt nini,ninil; /* number of initial vecs (negative means not copied yet) */nini65,2215 PetscInt nini,ninil; /* number of initial vecs (negative means not copied yet) */ninil65,2215 PetscReal tol; /* tolerance */tol66,2311 SVDConv conv; /* convergence test */conv67,2362 SVDStop stop; /* stopping test */stop68,2420 SVDWhich which; /* which singular values are computed */which69,2475 PetscBool impltrans; /* implicit transpose mode */impltrans70,2551 PetscBool trackall; /* whether all the residuals must be computed */trackall71,2616 PetscErrorCode (*converged)(SVD,PetscReal,PetscReal,PetscReal*,void*);converged74,2777 PetscErrorCode (*convergeddestroy)(void*);convergeddestroy75,2850 PetscErrorCode (*stopping)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*);stopping76,2895 PetscErrorCode (*stoppingdestroy)(void*);stoppingdestroy77,2992 void *convergedctx;convergedctx78,3036 void *stoppingctx;stoppingctx79,3068 PetscErrorCode (*monitor[MAXSVDMONITORS])(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*);monitor80,3099 PetscErrorCode (*monitordestroy[MAXSVDMONITORS])(void**);monitordestroy81,3204 void *monitorcontext[MAXSVDMONITORS];monitorcontext82,3264 PetscInt numbermonitors;numbermonitors83,3314 DS ds; /* direct solver object */ds86,3423 BV U,V; /* left and right singular vectors */U87,3485 BV U,V; /* left and right singular vectors */V87,3485 SlepcSC sc; /* sorting criterion data */sc88,3558 Mat A; /* problem matrix (m>n) */A89,3622 Mat AT; /* transposed matrix */AT90,3684 Vec *IS,*ISL; /* placeholder for references to user initial space */IS91,3743 Vec *IS,*ISL; /* placeholder for references to user initial space */ISL91,3743 PetscReal *sigma; /* singular values */sigma92,3833 PetscInt *perm; /* permutation for singular value ordering */perm93,3890 PetscReal *errest; /* error estimates */errest94,3971 void *data; /* placeholder for solver-specific stuff */data95,4028 SVDStateType state; /* initial -> setup -> solved -> vectors */state98,4184 PetscInt nconv; /* number of converged values */nconv99,4263 PetscInt its; /* iteration counter */its100,4331 PetscBool leftbasis; /* if U is filled by the solver */leftbasis101,4390 SVDConvergedReason reason;reason102,4460 #define SVDCheckSolved(SVDCheckSolved110,4569 #define SVDCheckSolved(SVDCheckSolved114,4623 #undef __FUNCT____FUNCT__121,4840 #define __FUNCT__ __FUNCT__122,4857 PETSC_STATIC_INLINE PetscErrorCode SVDMatMult(SVD svd,PetscBool trans,Vec x,Vec y)SVDMatMult123,4888 #undef __FUNCT____FUNCT__152,5586 #define __FUNCT__ __FUNCT__153,5603 PETSC_STATIC_INLINE PetscErrorCode SVDMatCreateVecs(SVD svd,Vec *x,Vec *y)SVDMatCreateVecs154,5640 #undef __FUNCT____FUNCT__167,5928 #define __FUNCT__ __FUNCT__168,5945 PETSC_STATIC_INLINE PetscErrorCode SVDMatGetSize(SVD svd,PetscInt *m,PetscInt *n)SVDMatGetSize169,5979 #undef __FUNCT____FUNCT__182,6268 #define __FUNCT__ __FUNCT__183,6285 PETSC_STATIC_INLINE PetscErrorCode SVDMatGetLocalSize(SVD svd,PetscInt *m,PetscInt *n)SVDMatGetLocalSize184,6324 include/slepc/private/vecimplslepc.h,2135 vecimplslepc.h:^?vecimplslepc.h^A,1 #define _VECIMPLSLEPC_VECIMPLSLEPC23,946 #define SlepcValidVecComp(SlepcValidVecComp30,1060 #define SlepcValidVecComp(SlepcValidVecComp34,1113 PetscInt n; /* number of active subvectors */n44,1384 PetscInt N; /* virtual global size */N45,1444 PetscInt lN; /* virtual local size */lN46,1496 PetscInt friends; /* number of vectors sharing this structure */friends47,1547 } Vec_Comp_N;Vec_Comp_N48,1620 Vec *x; /* the vectors */x51,1652 PetscInt nx; /* number of available subvectors */nx52,1696 Vec_Comp_N *n; /* structure shared by friend vectors */n53,1759 } Vec_Comp;Vec_Comp54,1826 typedef PetscInt MatType_t;MatType_t96,4221 #define DVD_MAT_HERMITIAN DVD_MAT_HERMITIAN97,4249 #define DVD_MAT_NEG_DEF DVD_MAT_NEG_DEF98,4282 #define DVD_MAT_POS_DEF DVD_MAT_POS_DEF99,4313 #define DVD_MAT_SINGULAR DVD_MAT_SINGULAR100,4344 #define DVD_MAT_COMPLEX DVD_MAT_COMPLEX101,4376 #define DVD_MAT_IMPLICIT DVD_MAT_IMPLICIT102,4407 #define DVD_MAT_IDENTITY DVD_MAT_IDENTITY103,4439 #define DVD_MAT_DIAG DVD_MAT_DIAG104,4471 #define DVD_MAT_TRIANG DVD_MAT_TRIANG105,4499 #define DVD_MAT_UTRIANG DVD_MAT_UTRIANG106,4529 #define DVD_MAT_LTRIANG DVD_MAT_LTRIANG107,4560 #define DVD_MAT_UNITARY DVD_MAT_UNITARY108,4592 typedef PetscInt EPType_t;EPType_t110,4625 #define DVD_EP_STD DVD_EP_STD111,4652 #define DVD_EP_HERMITIAN DVD_EP_HERMITIAN112,4678 #define DVD_EP_INDEFINITE DVD_EP_INDEFINITE113,4710 #define DVD_IS(DVD_IS115,4744 #define DVD_ISNOT(DVD_ISNOT116,4776 typedef struct VecPool_ {VecPool_119,4834 Vec v; /* template vector */v120,4860 Vec *vecs; /* pool of vectors */vecs121,4909 PetscInt n; /* size of vecs */n122,4958 PetscInt used; /* number of already used vectors */used123,5004 PetscInt guess; /* expected maximum number of vectors */guess124,5068 struct VecPool_ *next; /* list of pool of vectors */next125,5136 } VecPool_;VecPool_126,5193 typedef VecPool_* VecPool;VecPool127,5205 include/slepcblaslapack.h,6363 slepcblaslapack.h:^?slepcblaslapack.h^A,1 #define __SLEPCBLASLAPACK_H__SLEPCBLASLAPACK_H25,1034 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL31,1207 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK33,1292 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK35,1348 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL38,1446 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK40,1531 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK42,1587 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL45,1650 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK47,1735 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK49,1791 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL55,1965 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK57,2047 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK59,2100 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL62,2195 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK64,2277 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK66,2330 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL69,2390 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK71,2472 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK73,2525 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL79,2628 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK81,2710 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK83,2763 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL86,2858 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK88,2940 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK90,2993 #define SLEPC_BLASLAPACKREAL(SLEPC_BLASLAPACKREAL93,3053 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK95,3135 #define SLEPC_BLASLAPACK(SLEPC_BLASLAPACK97,3188 #define SlepcLRT SlepcLRT105,3424 #define SlepcLRT SlepcLRT107,3454 #define LAPACKlaev2_ LAPACKlaev2_111,3538 #define LAPACKgehrd_ LAPACKgehrd_112,3589 #define LAPACKgelqf_ LAPACKgelqf_113,3640 #define LAPACKgeqp3_ LAPACKgeqp3_114,3691 #define LAPACKtgexc_ LAPACKtgexc_115,3742 #define LAPACKlarfg_ LAPACKlarfg_116,3793 #define LAPACKlag2_ LAPACKlag2_117,3844 #define LAPACKlasv2_ LAPACKlasv2_118,3897 #define LAPACKlartg_ LAPACKlartg_119,3952 #define LAPACKlaln2_ LAPACKlaln2_120,4007 #define LAPACKlaed4_ LAPACKlaed4_121,4062 #define LAPACKlamrg_ LAPACKlamrg_122,4117 #define LAPACKlapy2_ LAPACKlapy2_123,4172 #define LAPACKorghr_ LAPACKorghr_125,4259 #define LAPACKorghr_ LAPACKorghr_127,4316 #define BLASrot_ BLASrot_132,4505 #define BLASrot_ BLASrot_135,4593 #define BLASrot_ BLASrot_137,4683 #define BLASrot_ BLASrot_139,4738 #define LAPACKlanhs_(LAPACKlanhs_147,4925 #define LAPACKlange_(LAPACKlange_148,5011 #define LAPACKggevx_(LAPACKggevx_149,5103 #define LAPACKggev_(LAPACKggev_150,5345 #define LAPACKpbtrf_(LAPACKpbtrf_151,5502 #define LAPACKlarf_(LAPACKlarf_152,5594 #define BLAStrmm_(BLAStrmm_153,5701 #define LAPACKlacpy_(LAPACKlacpy_154,5824 #define LAPACKlascl_(LAPACKlascl_155,5922 #define LAPACKlansy_(LAPACKlansy_156,6038 #define LAPACKlaset_(LAPACKlaset_157,6132 #define LAPACKtrsyl_(LAPACKtrsyl_158,6230 #define LAPACKtrtri_(LAPACKtrtri_159,6366 #define LAPACKstevr_(LAPACKstevr_161,6562 #define LAPACKbdsdc_(LAPACKbdsdc_162,6744 #define LAPACKlamch_(LAPACKlamch_163,6890 #define LAPACKlamc3_(LAPACKlamc3_164,6956 #define LAPACKsyevr_(LAPACKsyevr_168,7099 #define LAPACKsyevd_(LAPACKsyevd_169,7285 #define LAPACKsygvd_(LAPACKsygvd_170,7409 #define LAPACKormlq_(LAPACKormlq_171,7552 #define LAPACKorgtr_(LAPACKorgtr_172,7688 #define LAPACKsytrd_(LAPACKsytrd_173,7792 #define LAPACKtrevc_(LAPACKtrevc_174,7908 #define LAPACKgeevx_(LAPACKgeevx_175,8050 #define LAPACKgees_(LAPACKgees_176,8250 #define LAPACKtrexc_(LAPACKtrexc_177,8395 #define LAPACKgesdd_(LAPACKgesdd_178,8511 #define LAPACKtgevc_(LAPACKtgevc_179,8651 #define LAPACKhsein_(LAPACKhsein_180,8805 #define LAPACKstedc_(LAPACKstedc_181,8979 #define LAPACKsyevr_(LAPACKsyevr_184,9150 #define LAPACKsyevd_(LAPACKsyevd_185,9348 #define LAPACKsygvd_(LAPACKsygvd_186,9484 #define LAPACKormlq_(LAPACKormlq_187,9638 #define LAPACKorgtr_(LAPACKorgtr_188,9774 #define LAPACKsytrd_(LAPACKsytrd_189,9878 #define LAPACKtrevc_(LAPACKtrevc_190,9994 #define LAPACKgeevx_(LAPACKgeevx_191,10142 #define LAPACKgees_(LAPACKgees_192,10336 #define LAPACKtrexc_(LAPACKtrexc_193,10481 #define LAPACKgesdd_(LAPACKgesdd_194,10591 #define LAPACKtgevc_(LAPACKtgevc_195,10737 #define LAPACKhsein_(LAPACKhsein_196,10897 #define LAPACKstedc_(LAPACKstedc_197,11071 #define LAPACKlanhs_(LAPACKlanhs_203,11288 #define LAPACKlange_(LAPACKlange_204,11374 #define LAPACKggevx_(LAPACKggevx_205,11466 #define LAPACKggev_(LAPACKggev_206,11708 #define LAPACKpbtrf_(LAPACKpbtrf_207,11865 #define LAPACKlarf_(LAPACKlarf_208,11957 #define BLAStrmm_(BLAStrmm_209,12064 #define LAPACKlacpy_(LAPACKlacpy_210,12187 #define LAPACKlascl_(LAPACKlascl_211,12285 #define LAPACKlansy_(LAPACKlansy_212,12401 #define LAPACKlaset_(LAPACKlaset_213,12495 #define LAPACKtrsyl_(LAPACKtrsyl_214,12593 #define LAPACKtrtri_(LAPACKtrtri_215,12729 #define LAPACKstevr_(LAPACKstevr_217,12925 #define LAPACKbdsdc_(LAPACKbdsdc_218,13107 #define LAPACKlamch_(LAPACKlamch_219,13253 #define LAPACKlamc3_(LAPACKlamc3_220,13319 #define LAPACKsyevr_(LAPACKsyevr_224,13462 #define LAPACKsyevd_(LAPACKsyevd_225,13648 #define LAPACKsygvd_(LAPACKsygvd_226,13772 #define LAPACKormlq_(LAPACKormlq_227,13915 #define LAPACKorgtr_(LAPACKorgtr_228,14051 #define LAPACKsytrd_(LAPACKsytrd_229,14155 #define LAPACKtrevc_(LAPACKtrevc_230,14271 #define LAPACKgeevx_(LAPACKgeevx_231,14413 #define LAPACKgees_(LAPACKgees_232,14613 #define LAPACKtrexc_(LAPACKtrexc_233,14758 #define LAPACKgesdd_(LAPACKgesdd_234,14874 #define LAPACKtgevc_(LAPACKtgevc_235,15014 #define LAPACKhsein_(LAPACKhsein_236,15168 #define LAPACKstedc_(LAPACKstedc_237,15342 #define LAPACKsyevr_(LAPACKsyevr_240,15513 #define LAPACKsyevd_(LAPACKsyevd_241,15711 #define LAPACKsygvd_(LAPACKsygvd_242,15847 #define LAPACKormlq_(LAPACKormlq_243,16001 #define LAPACKorgtr_(LAPACKorgtr_244,16137 #define LAPACKsytrd_(LAPACKsytrd_245,16241 #define LAPACKtrevc_(LAPACKtrevc_246,16357 #define LAPACKgeevx_(LAPACKgeevx_247,16505 #define LAPACKgees_(LAPACKgees_248,16699 #define LAPACKtrexc_(LAPACKtrexc_249,16844 #define LAPACKgesdd_(LAPACKgesdd_250,16954 #define LAPACKtgevc_(LAPACKtgevc_251,17100 #define LAPACKhsein_(LAPACKhsein_252,17260 #define LAPACKstedc_(LAPACKstedc_253,17434 include/slepcbv.h,1657 slepcbv.h:^?slepcbv.h^A,1 #define __SLEPCBV_H__SLEPCBV_H23,950 typedef struct _p_BV* BV;BV36,1228 typedef const char* BVType;BVType46,1424 #define BVMAT BVMAT47,1452 #define BVSVEC BVSVEC48,1479 #define BVVECS BVVECS49,1507 #define BVCONTIGUOUS BVCONTIGUOUS50,1535 PETSC_EXTERN PetscClassId BV_CLASSID;BV_CLASSID53,1592 typedef enum { BV_ORTHOG_CGS,BV_ORTHOG_CGS63,1853 BV_ORTHOG_MGS } BVOrthogType;BV_ORTHOG_MGS64,1883 BV_ORTHOG_MGS } BVOrthogType;BVOrthogType64,1883 PETSC_EXTERN const char *BVOrthogTypes[];BVOrthogTypes65,1928 typedef enum { BV_ORTHOG_REFINE_IFNEEDED,BV_ORTHOG_REFINE_IFNEEDED75,2194 BV_ORTHOG_REFINE_NEVER,BV_ORTHOG_REFINE_NEVER76,2236 BV_ORTHOG_REFINE_ALWAYS } BVOrthogRefineType;BV_ORTHOG_REFINE_ALWAYS77,2275 BV_ORTHOG_REFINE_ALWAYS } BVOrthogRefineType;BVOrthogRefineType77,2275 PETSC_EXTERN const char *BVOrthogRefineTypes[];BVOrthogRefineTypes78,2336 typedef enum { BV_ORTHOG_BLOCK_GS,BV_ORTHOG_BLOCK_GS88,2630 BV_ORTHOG_BLOCK_CHOL } BVOrthogBlockType;BV_ORTHOG_BLOCK_CHOL89,2665 BV_ORTHOG_BLOCK_CHOL } BVOrthogBlockType;BVOrthogBlockType89,2665 PETSC_EXTERN const char *BVOrthogBlockTypes[];BVOrthogBlockTypes90,2722 typedef enum { BV_MATMULT_VECS,BV_MATMULT_VECS103,3178 BV_MATMULT_MAT,BV_MATMULT_MAT104,3210 BV_MATMULT_MAT_SAVE } BVMatMultType;BV_MATMULT_MAT_SAVE105,3241 BV_MATMULT_MAT_SAVE } BVMatMultType;BVMatMultType105,3241 PETSC_EXTERN const char *BVMatMultTypes[];BVMatMultTypes106,3293 PETSC_EXTERN PetscFunctionList BVList;BVList189,8325 include/slepcds.h,2029 slepcds.h:^?slepcds.h^A,1 #define __SLEPCDS_H__SLEPCDS_H23,950 #define DS_MAX_SOLVE DS_MAX_SOLVE27,1013 typedef struct _p_DS* DS;DS39,1366 typedef const char* DSType;DSType49,1595 #define DSHEP DSHEP50,1623 #define DSNHEP DSNHEP51,1655 #define DSGHEP DSGHEP52,1688 #define DSGHIEP DSGHIEP53,1721 #define DSGNHEP DSGNHEP54,1755 #define DSSVD DSSVD55,1789 #define DSPEP DSPEP56,1821 #define DSNEP DSNEP57,1853 PETSC_EXTERN PetscClassId DS_CLASSID;DS_CLASSID60,1908 typedef enum { DS_STATE_RAW,DS_STATE_RAW69,2064 DS_STATE_INTERMEDIATE,DS_STATE_INTERMEDIATE70,2093 DS_STATE_CONDENSED,DS_STATE_CONDENSED71,2131 DS_STATE_TRUNCATED } DSStateType;DS_STATE_TRUNCATED72,2166 DS_STATE_TRUNCATED } DSStateType;DSStateType72,2166 typedef enum { DS_MAT_A,DS_MAT_A104,3363 DS_MAT_B,DS_MAT_B105,3388 DS_MAT_C,DS_MAT_C106,3413 DS_MAT_T,DS_MAT_T107,3438 DS_MAT_D,DS_MAT_D108,3463 DS_MAT_Q,DS_MAT_Q109,3488 DS_MAT_Z,DS_MAT_Z110,3513 DS_MAT_X,DS_MAT_X111,3538 DS_MAT_Y,DS_MAT_Y112,3563 DS_MAT_U,DS_MAT_U113,3588 DS_MAT_VT,DS_MAT_VT114,3613 DS_MAT_W,DS_MAT_W115,3639 DS_MAT_E0,DS_MAT_E0116,3664 DS_MAT_E1,DS_MAT_E1117,3690 DS_MAT_E2,DS_MAT_E2118,3716 DS_MAT_E3,DS_MAT_E3119,3742 DS_MAT_E4,DS_MAT_E4120,3768 DS_MAT_E5,DS_MAT_E5121,3794 DS_MAT_E6,DS_MAT_E6122,3820 DS_MAT_E7,DS_MAT_E7123,3846 DS_MAT_E8,DS_MAT_E8124,3872 DS_MAT_E9,DS_MAT_E9125,3898 DS_NUM_MAT } DSMatType;DS_NUM_MAT126,3924 DS_NUM_MAT } DSMatType;DSMatType126,3924 PETSC_EXTERN DSMatType DSMatExtra[];DSMatExtra129,4010 #define DS_NUM_EXTRA DS_NUM_EXTRA130,4047 PETSC_EXTERN PetscFunctionList DSList;DSList191,7520 include/slepceps.h,8267 slepceps.h:^?slepceps.h^A,1 #define __SLEPCEPS_H__SLEPCEPS_H25,1006 typedef struct _p_EPS* EPS;EPS41,1311 typedef const char* EPSType;EPSType50,1456 #define EPSPOWER EPSPOWER51,1485 #define EPSSUBSPACE EPSSUBSPACE52,1516 #define EPSARNOLDI EPSARNOLDI53,1550 #define EPSLANCZOS EPSLANCZOS54,1583 #define EPSKRYLOVSCHUR EPSKRYLOVSCHUR55,1616 #define EPSGD EPSGD56,1653 #define EPSJD EPSJD57,1681 #define EPSRQCG EPSRQCG58,1709 #define EPSLOBPCG EPSLOBPCG59,1739 #define EPSCISS EPSCISS60,1771 #define EPSLAPACK EPSLAPACK61,1801 #define EPSARPACK EPSARPACK62,1833 #define EPSBLZPACK EPSBLZPACK63,1865 #define EPSTRLAN EPSTRLAN64,1898 #define EPSBLOPEX EPSBLOPEX65,1929 #define EPSPRIMME EPSPRIMME66,1961 #define EPSFEAST EPSFEAST67,1993 PETSC_EXTERN PetscClassId EPS_CLASSID;EPS_CLASSID70,2047 typedef enum { EPS_HEP=1,EPS_HEP79,2231 EPS_GHEP,EPS_GHEP80,2257 EPS_NHEP,EPS_NHEP81,2282 EPS_GNHEP,EPS_GNHEP82,2307 EPS_PGNHEP,EPS_PGNHEP83,2333 EPS_GHIEP } EPSProblemType;EPS_GHIEP84,2360 EPS_GHIEP } EPSProblemType;EPSProblemType84,2360 typedef enum { EPS_RITZ,EPS_RITZ94,2579 EPS_HARMONIC,EPS_HARMONIC95,2604 EPS_HARMONIC_RELATIVE,EPS_HARMONIC_RELATIVE96,2633 EPS_HARMONIC_RIGHT,EPS_HARMONIC_RIGHT97,2671 EPS_HARMONIC_LARGEST,EPS_HARMONIC_LARGEST98,2706 EPS_REFINED,EPS_REFINED99,2743 EPS_REFINED_HARMONIC } EPSExtraction;EPS_REFINED_HARMONIC100,2771 EPS_REFINED_HARMONIC } EPSExtraction;EPSExtraction100,2771 typedef enum { EPS_LARGEST_MAGNITUDE=1,EPS_LARGEST_MAGNITUDE109,2984 EPS_SMALLEST_MAGNITUDE,EPS_SMALLEST_MAGNITUDE110,3024 EPS_LARGEST_REAL,EPS_LARGEST_REAL111,3063 EPS_SMALLEST_REAL,EPS_SMALLEST_REAL112,3096 EPS_LARGEST_IMAGINARY,EPS_LARGEST_IMAGINARY113,3130 EPS_SMALLEST_IMAGINARY,EPS_SMALLEST_IMAGINARY114,3168 EPS_TARGET_MAGNITUDE,EPS_TARGET_MAGNITUDE115,3207 EPS_TARGET_REAL,EPS_TARGET_REAL116,3244 EPS_TARGET_IMAGINARY,EPS_TARGET_IMAGINARY117,3276 EPS_ALL,EPS_ALL118,3313 EPS_WHICH_USER } EPSWhich;EPS_WHICH_USER119,3337 EPS_WHICH_USER } EPSWhich;EPSWhich119,3337 typedef enum { EPS_BALANCE_NONE,EPS_BALANCE_NONE128,3511 EPS_BALANCE_ONESIDE,EPS_BALANCE_ONESIDE129,3544 EPS_BALANCE_TWOSIDE,EPS_BALANCE_TWOSIDE130,3580 EPS_BALANCE_USER } EPSBalance;EPS_BALANCE_USER131,3616 EPS_BALANCE_USER } EPSBalance;EPSBalance131,3616 PETSC_EXTERN const char *EPSBalanceTypes[];EPSBalanceTypes132,3662 typedef enum { EPS_ERROR_ABSOLUTE,EPS_ERROR_ABSOLUTE141,3849 EPS_ERROR_RELATIVE,EPS_ERROR_RELATIVE142,3884 EPS_ERROR_BACKWARD } EPSErrorType;EPS_ERROR_BACKWARD143,3919 EPS_ERROR_BACKWARD } EPSErrorType;EPSErrorType143,3919 PETSC_EXTERN const char *EPSErrorTypes[];EPSErrorTypes144,3969 typedef enum { EPS_CONV_ABS,EPS_CONV_ABS153,4159 EPS_CONV_REL,EPS_CONV_REL154,4188 EPS_CONV_NORM,EPS_CONV_NORM155,4217 EPS_CONV_USER } EPSConv;EPS_CONV_USER156,4247 EPS_CONV_USER } EPSConv;EPSConv156,4247 typedef enum { EPS_STOP_BASIC,EPS_STOP_BASIC165,4422 EPS_STOP_USER } EPSStop;EPS_STOP_USER166,4453 EPS_STOP_USER } EPSStop;EPSStop166,4453 EPS_CONVERGED_TOL = 1,EPS_CONVERGED_TOL177,4719 EPS_CONVERGED_USER = 2,EPS_CONVERGED_USER178,4772 EPS_DIVERGED_ITS = -1,EPS_DIVERGED_ITS180,4854 EPS_DIVERGED_BREAKDOWN = -2,EPS_DIVERGED_BREAKDOWN181,4907 EPS_DIVERGED_SYMMETRY_LOST = -3,EPS_DIVERGED_SYMMETRY_LOST182,4960 EPS_CONVERGED_ITERATING = 0} EPSConvergedReason;EPS_CONVERGED_ITERATING183,5013 EPS_CONVERGED_ITERATING = 0} EPSConvergedReason;EPSConvergedReason183,5013 PETSC_EXTERN const char *const*EPSConvergedReasons;EPSConvergedReasons184,5086 PETSC_STATIC_INLINE PetscErrorCode EPSViewFromOptions(EPS eps,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)eps,obj,name);}EPSViewFromOptions203,6124 PETSC_DEPRECATED("Use EPSErrorView()") PETSC_STATIC_INLINE PetscErrorCode EPSPrintSolution(EPS eps,PetscViewer v) {return EPSErrorView(eps,EPS_ERROR_RELATIVE,v);}EPSPrintSolution205,6357 PETSC_DEPRECATED("Use EPSComputeError()") PETSC_STATIC_INLINE PetscErrorCode EPSComputeRelativeError(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_RELATIVE,r);}EPSComputeRelativeError249,9369 PETSC_DEPRECATED("Use EPSComputeError() with EPS_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode EPSComputeResidualNorm(EPS eps,PetscInt i,PetscReal *r) {return EPSComputeError(eps,i,EPS_ERROR_ABSOLUTE,r);}EPSComputeResidualNorm250,9557 PETSC_EXTERN PetscFunctionList EPSList;EPSList291,12869 typedef enum { EPS_POWER_SHIFT_CONSTANT,EPS_POWER_SHIFT_CONSTANT306,13348 EPS_POWER_SHIFT_RAYLEIGH,EPS_POWER_SHIFT_RAYLEIGH307,13389 EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType;EPS_POWER_SHIFT_WILKINSON308,13430 EPS_POWER_SHIFT_WILKINSON } EPSPowerShiftType;EPSPowerShiftType308,13430 PETSC_EXTERN const char *EPSPowerShiftTypes[];EPSPowerShiftTypes309,13492 typedef enum { EPS_LANCZOS_REORTHOG_LOCAL,EPS_LANCZOS_REORTHOG_LOCAL343,15403 EPS_LANCZOS_REORTHOG_FULL,EPS_LANCZOS_REORTHOG_FULL344,15446 EPS_LANCZOS_REORTHOG_SELECTIVE,EPS_LANCZOS_REORTHOG_SELECTIVE345,15488 EPS_LANCZOS_REORTHOG_PERIODIC,EPS_LANCZOS_REORTHOG_PERIODIC346,15535 EPS_LANCZOS_REORTHOG_PARTIAL,EPS_LANCZOS_REORTHOG_PARTIAL347,15581 EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType;EPS_LANCZOS_REORTHOG_DELAYED348,15626 EPS_LANCZOS_REORTHOG_DELAYED } EPSLanczosReorthogType;EPSLanczosReorthogType348,15626 PETSC_EXTERN const char *EPSLanczosReorthogTypes[];EPSLanczosReorthogTypes349,15696 typedef enum { EPS_PRIMME_DYNAMIC,EPS_PRIMME_DYNAMIC364,16197 EPS_PRIMME_DEFAULT_MIN_TIME,EPS_PRIMME_DEFAULT_MIN_TIME365,16232 EPS_PRIMME_DEFAULT_MIN_MATVECS,EPS_PRIMME_DEFAULT_MIN_MATVECS366,16276 EPS_PRIMME_ARNOLDI,EPS_PRIMME_ARNOLDI367,16323 EPS_PRIMME_GD,EPS_PRIMME_GD368,16358 EPS_PRIMME_GD_PLUSK,EPS_PRIMME_GD_PLUSK369,16388 EPS_PRIMME_GD_OLSEN_PLUSK,EPS_PRIMME_GD_OLSEN_PLUSK370,16424 EPS_PRIMME_JD_OLSEN_PLUSK,EPS_PRIMME_JD_OLSEN_PLUSK371,16466 EPS_PRIMME_RQI,EPS_PRIMME_RQI372,16508 EPS_PRIMME_JDQR,EPS_PRIMME_JDQR373,16539 EPS_PRIMME_JDQMR,EPS_PRIMME_JDQMR374,16571 EPS_PRIMME_JDQMR_ETOL,EPS_PRIMME_JDQMR_ETOL375,16604 EPS_PRIMME_SUBSPACE_ITERATION,EPS_PRIMME_SUBSPACE_ITERATION376,16642 EPS_PRIMME_LOBPCG_ORTHOBASIS,EPS_PRIMME_LOBPCG_ORTHOBASIS377,16688 EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod;EPS_PRIMME_LOBPCG_ORTHOBASISW378,16733 EPS_PRIMME_LOBPCG_ORTHOBASISW } EPSPRIMMEMethod;EPSPRIMMEMethod378,16733 PETSC_EXTERN const char *EPSPRIMMEMethods[];EPSPRIMMEMethods379,16797 typedef enum { EPS_CISS_QUADRULE_TRAPEZOIDAL=1,EPS_CISS_QUADRULE_TRAPEZOIDAL435,19734 EPS_CISS_QUADRULE_CHEBYSHEV } EPSCISSQuadRule;EPS_CISS_QUADRULE_CHEBYSHEV436,19782 EPS_CISS_QUADRULE_CHEBYSHEV } EPSCISSQuadRule;EPSCISSQuadRule436,19782 PETSC_EXTERN const char *EPSCISSQuadRules[];EPSCISSQuadRules437,19844 typedef enum { EPS_CISS_EXTRACTION_RITZ,EPS_CISS_EXTRACTION_RITZ446,20056 EPS_CISS_EXTRACTION_HANKEL } EPSCISSExtraction;EPS_CISS_EXTRACTION_HANKEL447,20097 EPS_CISS_EXTRACTION_HANKEL } EPSCISSExtraction;EPSCISSExtraction447,20097 PETSC_EXTERN const char *EPSCISSExtractions[];EPSCISSExtractions448,20160 include/slepcfn.h,790 slepcfn.h:^?slepcfn.h^A,1 #define __SLEPCFN_H__SLEPCFN_H23,950 typedef struct _p_FN* FN;FN34,1146 typedef const char* FNType;FNType43,1291 #define FNCOMBINE FNCOMBINE44,1319 #define FNRATIONAL FNRATIONAL45,1348 #define FNEXP FNEXP46,1378 #define FNLOG FNLOG47,1403 #define FNPHI FNPHI48,1428 #define FNSQRT FNSQRT49,1453 #define FNINVSQRT FNINVSQRT50,1479 PETSC_EXTERN PetscClassId FN_CLASSID;FN_CLASSID53,1531 typedef enum { FN_COMBINE_ADD,FN_COMBINE_ADD62,1695 FN_COMBINE_MULTIPLY,FN_COMBINE_MULTIPLY63,1726 FN_COMBINE_DIVIDE,FN_COMBINE_DIVIDE64,1762 FN_COMBINE_COMPOSE } FNCombineType;FN_COMBINE_COMPOSE65,1796 FN_COMBINE_COMPOSE } FNCombineType;FNCombineType65,1796 PETSC_EXTERN PetscFunctionList FNList;FNList86,2831 include/slepcmath.h,455 slepcmath.h:^?slepcmath.h^A,1 #define __SLEPCMATH_H__SLEPCMATH_H26,1100 # define SLEPC_DEFAULT_TOL SLEPC_DEFAULT_TOL32,1240 # define SLEPC_DEFAULT_TOL SLEPC_DEFAULT_TOL34,1312 # define SLEPC_DEFAULT_TOL SLEPC_DEFAULT_TOL36,1388 # define SLEPC_DEFAULT_TOL SLEPC_DEFAULT_TOL38,1430 PETSC_STATIC_INLINE PetscReal SlepcAbs(PetscReal x,PetscReal y)SlepcAbs58,1794 #define SlepcAbsEigenvalue(SlepcAbsEigenvalue91,2609 #define SlepcAbsEigenvalue(SlepcAbsEigenvalue93,2661 include/slepcmfn.h,1119 slepcmfn.h:^?slepcmfn.h^A,1 #define __SLEPCMFN_H__SLEPCMFN_H25,1008 typedef struct _p_MFN* MFN;MFN38,1259 typedef const char* MFNType;MFNType47,1425 #define MFNKRYLOV MFNKRYLOV48,1454 #define MFNEXPOKIT MFNEXPOKIT49,1483 PETSC_EXTERN PetscClassId MFN_CLASSID;MFN_CLASSID52,1536 PETSC_STATIC_INLINE PetscErrorCode MFNViewFromOptions(MFN mfn,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)mfn,obj,name);}MFNViewFromOptions65,2134 MFN_CONVERGED_TOL = 2,MFN_CONVERGED_TOL105,4263 MFN_CONVERGED_ITS = 3,MFN_CONVERGED_ITS106,4316 MFN_DIVERGED_ITS = -3,MFN_DIVERGED_ITS108,4398 MFN_DIVERGED_BREAKDOWN = -4,MFN_DIVERGED_BREAKDOWN109,4451 MFN_CONVERGED_ITERATING = 0} MFNConvergedReason;MFN_CONVERGED_ITERATING110,4504 MFN_CONVERGED_ITERATING = 0} MFNConvergedReason;MFNConvergedReason110,4504 PETSC_EXTERN const char *const*MFNConvergedReasons;MFNConvergedReasons111,4577 PETSC_EXTERN PetscFunctionList MFNList;MFNList115,4708 include/slepcnep.h,4071 slepcnep.h:^?slepcnep.h^A,1 #define __SLEPCNEP_H__SLEPCNEP_H25,1012 typedef struct _p_NEP* NEP;NEP40,1306 typedef const char* NEPType;NEPType49,1454 #define NEPRII NEPRII50,1483 #define NEPSLP NEPSLP51,1510 #define NEPNARNOLDI NEPNARNOLDI52,1537 #define NEPCISS NEPCISS53,1569 #define NEPINTERPOL NEPINTERPOL54,1597 #define NEPNLEIGS NEPNLEIGS55,1629 PETSC_EXTERN PetscClassId NEP_CLASSID;NEP_CLASSID58,1682 typedef enum { NEP_LARGEST_MAGNITUDE=1,NEP_LARGEST_MAGNITUDE67,1881 NEP_SMALLEST_MAGNITUDE,NEP_SMALLEST_MAGNITUDE68,1921 NEP_LARGEST_REAL,NEP_LARGEST_REAL69,1960 NEP_SMALLEST_REAL,NEP_SMALLEST_REAL70,1993 NEP_LARGEST_IMAGINARY,NEP_LARGEST_IMAGINARY71,2027 NEP_SMALLEST_IMAGINARY,NEP_SMALLEST_IMAGINARY72,2065 NEP_TARGET_MAGNITUDE,NEP_TARGET_MAGNITUDE73,2104 NEP_TARGET_REAL,NEP_TARGET_REAL74,2141 NEP_TARGET_IMAGINARY,NEP_TARGET_IMAGINARY75,2173 NEP_ALL,NEP_ALL76,2210 NEP_WHICH_USER } NEPWhich;NEP_WHICH_USER77,2234 NEP_WHICH_USER } NEPWhich;NEPWhich77,2234 typedef enum { NEP_ERROR_ABSOLUTE,NEP_ERROR_ABSOLUTE86,2419 NEP_ERROR_RELATIVE,NEP_ERROR_RELATIVE87,2454 NEP_ERROR_BACKWARD } NEPErrorType;NEP_ERROR_BACKWARD88,2489 NEP_ERROR_BACKWARD } NEPErrorType;NEPErrorType88,2489 PETSC_EXTERN const char *NEPErrorTypes[];NEPErrorTypes89,2539 typedef enum { NEP_REFINE_NONE,NEP_REFINE_NONE98,2677 NEP_REFINE_SIMPLE,NEP_REFINE_SIMPLE99,2709 NEP_REFINE_MULTIPLE } NEPRefine;NEP_REFINE_MULTIPLE100,2743 NEP_REFINE_MULTIPLE } NEPRefine;NEPRefine100,2743 PETSC_EXTERN const char *NEPRefineTypes[];NEPRefineTypes101,2791 typedef enum { NEP_REFINE_SCHEME_SCHUR=1,NEP_REFINE_SCHEME_SCHUR110,2987 NEP_REFINE_SCHEME_MBE,NEP_REFINE_SCHEME_MBE111,3029 NEP_REFINE_SCHEME_EXPLICIT } NEPRefineScheme;NEP_REFINE_SCHEME_EXPLICIT112,3067 NEP_REFINE_SCHEME_EXPLICIT } NEPRefineScheme;NEPRefineScheme112,3067 PETSC_EXTERN const char *NEPRefineSchemes[];NEPRefineSchemes113,3128 typedef enum { NEP_CONV_ABS,NEP_CONV_ABS122,3321 NEP_CONV_REL,NEP_CONV_REL123,3350 NEP_CONV_NORM,NEP_CONV_NORM124,3379 NEP_CONV_USER } NEPConv;NEP_CONV_USER125,3409 NEP_CONV_USER } NEPConv;NEPConv125,3409 typedef enum { NEP_STOP_BASIC,NEP_STOP_BASIC134,3584 NEP_STOP_USER } NEPStop;NEP_STOP_USER135,3615 NEP_STOP_USER } NEPStop;NEPStop135,3615 NEP_CONVERGED_TOL = 1,NEP_CONVERGED_TOL146,3890 NEP_CONVERGED_USER = 2,NEP_CONVERGED_USER147,3943 NEP_DIVERGED_ITS = -1,NEP_DIVERGED_ITS149,4025 NEP_DIVERGED_BREAKDOWN = -2,NEP_DIVERGED_BREAKDOWN150,4078 NEP_DIVERGED_LINEAR_SOLVE = -4,NEP_DIVERGED_LINEAR_SOLVE152,4186 NEP_CONVERGED_ITERATING = 0} NEPConvergedReason;NEP_CONVERGED_ITERATING153,4239 NEP_CONVERGED_ITERATING = 0} NEPConvergedReason;NEPConvergedReason153,4239 PETSC_EXTERN const char *const*NEPConvergedReasons;NEPConvergedReasons154,4312 PETSC_STATIC_INLINE PetscErrorCode NEPViewFromOptions(NEP nep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)nep,obj,name);}NEPViewFromOptions167,4926 PETSC_DEPRECATED("Use NEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode NEPComputeRelativeError(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_RELATIVE,r);}NEPComputeRelativeError215,8610 PETSC_DEPRECATED("Use NEPComputeError() with NEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode NEPComputeResidualNorm(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_ABSOLUTE,r);}NEPComputeResidualNorm216,8798 PETSC_EXTERN PetscFunctionList NEPList;NEPList254,11856 include/slepcpep.h,5780 slepcpep.h:^?slepcpep.h^A,1 #define __SLEPCPEP_H__SLEPCPEP_H25,1013 typedef struct _p_PEP* PEP;PEP38,1264 typedef const char* PEPType;PEPType47,1413 #define PEPLINEAR PEPLINEAR48,1442 #define PEPQARNOLDI PEPQARNOLDI49,1472 #define PEPTOAR PEPTOAR50,1504 #define PEPSTOAR PEPSTOAR51,1532 #define PEPJD PEPJD52,1561 PETSC_EXTERN PetscClassId PEP_CLASSID;PEP_CLASSID55,1610 typedef enum { PEP_GENERAL=1,PEP_GENERAL64,1807 PEP_HERMITIAN, /* All A_i Hermitian */PEP_HERMITIAN65,1837 PEP_GYROSCOPIC /* QEP with M, K Hermitian, M>0, C skew-Hermitian */PEP_GYROSCOPIC66,1894 } PEPProblemType;PEPProblemType67,1980 typedef enum { PEP_LARGEST_MAGNITUDE=1,PEP_LARGEST_MAGNITUDE76,2171 PEP_SMALLEST_MAGNITUDE,PEP_SMALLEST_MAGNITUDE77,2211 PEP_LARGEST_REAL,PEP_LARGEST_REAL78,2250 PEP_SMALLEST_REAL,PEP_SMALLEST_REAL79,2283 PEP_LARGEST_IMAGINARY,PEP_LARGEST_IMAGINARY80,2317 PEP_SMALLEST_IMAGINARY,PEP_SMALLEST_IMAGINARY81,2355 PEP_TARGET_MAGNITUDE,PEP_TARGET_MAGNITUDE82,2394 PEP_TARGET_REAL,PEP_TARGET_REAL83,2431 PEP_TARGET_IMAGINARY,PEP_TARGET_IMAGINARY84,2463 PEP_WHICH_USER } PEPWhich;PEP_WHICH_USER85,2500 PEP_WHICH_USER } PEPWhich;PEPWhich85,2500 typedef enum { PEP_BASIS_MONOMIAL,PEP_BASIS_MONOMIAL95,2695 PEP_BASIS_CHEBYSHEV1,PEP_BASIS_CHEBYSHEV196,2730 PEP_BASIS_CHEBYSHEV2,PEP_BASIS_CHEBYSHEV297,2767 PEP_BASIS_LEGENDRE,PEP_BASIS_LEGENDRE98,2804 PEP_BASIS_LAGUERRE,PEP_BASIS_LAGUERRE99,2839 PEP_BASIS_HERMITE } PEPBasis;PEP_BASIS_HERMITE100,2874 PEP_BASIS_HERMITE } PEPBasis;PEPBasis100,2874 PETSC_EXTERN const char *PEPBasisTypes[];PEPBasisTypes101,2919 typedef enum { PEP_SCALE_NONE,PEP_SCALE_NONE110,3056 PEP_SCALE_SCALAR,PEP_SCALE_SCALAR111,3087 PEP_SCALE_DIAGONAL,PEP_SCALE_DIAGONAL112,3120 PEP_SCALE_BOTH } PEPScale;PEP_SCALE_BOTH113,3155 PEP_SCALE_BOTH } PEPScale;PEPScale113,3155 PETSC_EXTERN const char *PEPScaleTypes[];PEPScaleTypes114,3197 typedef enum { PEP_REFINE_NONE,PEP_REFINE_NONE123,3335 PEP_REFINE_SIMPLE,PEP_REFINE_SIMPLE124,3367 PEP_REFINE_MULTIPLE } PEPRefine;PEP_REFINE_MULTIPLE125,3401 PEP_REFINE_MULTIPLE } PEPRefine;PEPRefine125,3401 PETSC_EXTERN const char *PEPRefineTypes[];PEPRefineTypes126,3449 typedef enum { PEP_REFINE_SCHEME_SCHUR=1,PEP_REFINE_SCHEME_SCHUR135,3645 PEP_REFINE_SCHEME_MBE,PEP_REFINE_SCHEME_MBE136,3687 PEP_REFINE_SCHEME_EXPLICIT } PEPRefineScheme;PEP_REFINE_SCHEME_EXPLICIT137,3725 PEP_REFINE_SCHEME_EXPLICIT } PEPRefineScheme;PEPRefineScheme137,3725 PETSC_EXTERN const char *PEPRefineSchemes[];PEPRefineSchemes138,3786 typedef enum { PEP_EXTRACT_NONE=1,PEP_EXTRACT_NONE147,3929 PEP_EXTRACT_NORM,PEP_EXTRACT_NORM148,3964 PEP_EXTRACT_RESIDUAL,PEP_EXTRACT_RESIDUAL149,3997 PEP_EXTRACT_STRUCTURED } PEPExtract;PEP_EXTRACT_STRUCTURED150,4034 PEP_EXTRACT_STRUCTURED } PEPExtract;PEPExtract150,4034 PETSC_EXTERN const char *PEPExtractTypes[];PEPExtractTypes151,4086 typedef enum { PEP_ERROR_ABSOLUTE,PEP_ERROR_ABSOLUTE160,4273 PEP_ERROR_RELATIVE,PEP_ERROR_RELATIVE161,4308 PEP_ERROR_BACKWARD } PEPErrorType;PEP_ERROR_BACKWARD162,4343 PEP_ERROR_BACKWARD } PEPErrorType;PEPErrorType162,4343 PETSC_EXTERN const char *PEPErrorTypes[];PEPErrorTypes163,4393 typedef enum { PEP_CONV_ABS,PEP_CONV_ABS172,4583 PEP_CONV_REL,PEP_CONV_REL173,4612 PEP_CONV_NORM,PEP_CONV_NORM174,4641 PEP_CONV_USER } PEPConv;PEP_CONV_USER175,4671 PEP_CONV_USER } PEPConv;PEPConv175,4671 typedef enum { PEP_STOP_BASIC,PEP_STOP_BASIC184,4846 PEP_STOP_USER } PEPStop;PEP_STOP_USER185,4877 PEP_STOP_USER } PEPStop;PEPStop185,4877 PEP_CONVERGED_TOL = 1,PEP_CONVERGED_TOL196,5143 PEP_CONVERGED_USER = 2,PEP_CONVERGED_USER197,5196 PEP_DIVERGED_ITS = -1,PEP_DIVERGED_ITS199,5278 PEP_DIVERGED_BREAKDOWN = -2,PEP_DIVERGED_BREAKDOWN200,5331 PEP_DIVERGED_SYMMETRY_LOST = -3,PEP_DIVERGED_SYMMETRY_LOST201,5384 PEP_CONVERGED_ITERATING = 0} PEPConvergedReason;PEP_CONVERGED_ITERATING202,5437 PEP_CONVERGED_ITERATING = 0} PEPConvergedReason;PEPConvergedReason202,5437 PETSC_EXTERN const char *const*PEPConvergedReasons;PEPConvergedReasons203,5510 PETSC_STATIC_INLINE PetscErrorCode PEPViewFromOptions(PEP pep,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)pep,obj,name);}PEPViewFromOptions221,6450 PETSC_DEPRECATED("Use PEPErrorView()") PETSC_STATIC_INLINE PetscErrorCode PEPPrintSolution(PEP pep,PetscViewer v) {return PEPErrorView(pep,PEP_ERROR_BACKWARD,v);}PEPPrintSolution223,6683 PETSC_DEPRECATED("Use PEPComputeError()") PETSC_STATIC_INLINE PetscErrorCode PEPComputeRelativeError(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_BACKWARD,r);}PEPComputeRelativeError269,9963 PETSC_DEPRECATED("Use PEPComputeError() with PEP_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode PEPComputeResidualNorm(PEP pep,PetscInt i,PetscReal *r) {return PEPComputeError(pep,i,PEP_ERROR_ABSOLUTE,r);}PEPComputeResidualNorm270,10151 PETSC_EXTERN PetscFunctionList PEPList;PEPList300,12755 include/slepcrg.h,337 slepcrg.h:^?slepcrg.h^A,1 #define __SLEPCRG_H__SLEPCRG_H23,950 typedef const char* RGType;RGType36,1178 #define RGINTERVAL RGINTERVAL37,1206 #define RGPOLYGON RGPOLYGON38,1237 #define RGELLIPSE RGELLIPSE39,1267 #define RGRING RGRING40,1297 PETSC_EXTERN PetscClassId RG_CLASSID;RG_CLASSID43,1347 PETSC_EXTERN PetscFunctionList RGList;RGList65,2447 include/slepcrgtypes.h,86 slepcrgtypes.h:^?slepcrgtypes.h^A,1 #define __SLEPCRGTYPES_H__SLEPCRGTYPES_H23,955 typedef struct _p_RG* RG;RG32,1068 include/slepcsc.h,458 slepcsc.h:^?slepcsc.h^A,1 #define __SLEPCSC_H__SLEPCSC_H25,993 struct _n_SlepcSC {_n_SlepcSC60,2108 PetscErrorCode (*map)(PetscObject,PetscInt,PetscScalar*,PetscScalar*);map62,2211 PetscObject mapobj;mapobj63,2284 PetscErrorCode (*comparison)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*);comparison65,2374 void *comparisonctx;comparisonctx66,2471 RG rg;rg68,2542 typedef struct _n_SlepcSC* SlepcSC;SlepcSC70,2566 include/slepcst.h,662 slepcst.h:^?slepcst.h^A,1 #define __SLEPCST_H__SLEPCST_H25,1010 typedef struct _p_ST* ST;ST40,1338 typedef const char* STType;STType49,1490 #define STSHELL STSHELL50,1518 #define STSHIFT STSHIFT51,1546 #define STSINVERT STSINVERT52,1574 #define STCAYLEY STCAYLEY53,1604 #define STPRECOND STPRECOND54,1633 PETSC_EXTERN PetscClassId ST_CLASSID;ST_CLASSID57,1686 typedef enum { ST_MATMODE_COPY,ST_MATMODE_COPY114,4215 ST_MATMODE_INPLACE,ST_MATMODE_INPLACE115,4247 ST_MATMODE_SHELL } STMatMode;ST_MATMODE_SHELL116,4282 ST_MATMODE_SHELL } STMatMode;STMatMode116,4282 PETSC_EXTERN PetscFunctionList STList;STList122,4570 include/slepcsvd.h,2754 slepcsvd.h:^?slepcsvd.h^A,1 #define __SLEPCSVD_H__SLEPCSVD_H25,1006 typedef struct _p_SVD* SVD;SVD40,1292 typedef const char* SVDType;SVDType49,1446 #define SVDCROSS SVDCROSS50,1475 #define SVDCYCLIC SVDCYCLIC51,1506 #define SVDLAPACK SVDLAPACK52,1538 #define SVDLANCZOS SVDLANCZOS53,1570 #define SVDTRLANCZOS SVDTRLANCZOS54,1603 PETSC_EXTERN PetscClassId SVD_CLASSID;SVD_CLASSID57,1661 typedef enum { SVD_LARGEST,SVD_LARGEST67,1901 SVD_SMALLEST } SVDWhich;SVD_SMALLEST68,1929 SVD_SMALLEST } SVDWhich;SVDWhich68,1929 typedef enum { SVD_ERROR_ABSOLUTE,SVD_ERROR_ABSOLUTE77,2112 SVD_ERROR_RELATIVE } SVDErrorType;SVD_ERROR_RELATIVE78,2147 SVD_ERROR_RELATIVE } SVDErrorType;SVDErrorType78,2147 PETSC_EXTERN const char *SVDErrorTypes[];SVDErrorTypes79,2197 typedef enum { SVD_CONV_ABS,SVD_CONV_ABS88,2387 SVD_CONV_REL,SVD_CONV_REL89,2416 SVD_CONV_USER } SVDConv;SVD_CONV_USER90,2445 SVD_CONV_USER } SVDConv;SVDConv90,2445 typedef enum { SVD_STOP_BASIC,SVD_STOP_BASIC99,2620 SVD_STOP_USER } SVDStop;SVD_STOP_USER100,2651 SVD_STOP_USER } SVDStop;SVDStop100,2651 SVD_CONVERGED_TOL = 1,SVD_CONVERGED_TOL111,2925 SVD_CONVERGED_USER = 2,SVD_CONVERGED_USER112,2978 SVD_DIVERGED_ITS = -1,SVD_DIVERGED_ITS114,3060 SVD_DIVERGED_BREAKDOWN = -2,SVD_DIVERGED_BREAKDOWN115,3113 SVD_CONVERGED_ITERATING = 0 } SVDConvergedReason;SVD_CONVERGED_ITERATING116,3166 SVD_CONVERGED_ITERATING = 0 } SVDConvergedReason;SVDConvergedReason116,3166 PETSC_EXTERN const char *const*SVDConvergedReasons;SVDConvergedReasons117,3240 PETSC_DEPRECATED("Use SVDComputeError()") PETSC_STATIC_INLINE PetscErrorCode SVDComputeRelativeError(SVD svd,PetscInt i,PetscReal *r) {return SVDComputeError(svd,i,SVD_ERROR_RELATIVE,r);}SVDComputeRelativeError158,6068 PETSC_DEPRECATED("Use SVDComputeError() with SVD_ERROR_ABSOLUTE") PETSC_STATIC_INLINE PetscErrorCode SVDComputeResidualNorms(SVD svd,PetscInt i,PetscReal *r1,PETSC_UNUSED PetscReal *r2) {return SVDComputeError(svd,i,SVD_ERROR_ABSOLUTE,r1);}SVDComputeResidualNorms159,6256 PETSC_STATIC_INLINE PetscErrorCode SVDViewFromOptions(SVD svd,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)svd,obj,name);}SVDViewFromOptions161,6551 PETSC_DEPRECATED("Use SVDErrorView()") PETSC_STATIC_INLINE PetscErrorCode SVDPrintSolution(SVD svd,PetscViewer v) {return SVDErrorView(svd,SVD_ERROR_RELATIVE,v);}SVDPrintSolution163,6784 PETSC_EXTERN PetscFunctionList SVDList;SVDList204,9641 include/slepcsys.h,250 slepcsys.h:^?slepcsys.h^A,1 #define __SLEPCSYS_H__SLEPCSYS_H26,1067 #define SLEPC_AUTHOR_INFO SLEPC_AUTHOR_INFO38,1415 typedef struct _n_SlepcConvMonitor* SlepcConvMonitor;SlepcConvMonitor57,1910 PETSC_EXTERN PetscBool SlepcInitializeCalled;SlepcInitializeCalled78,3111 include/slepcvec.h,75 slepcvec.h:^?slepcvec.h^A,1 #define __SLEPCVEC_H__SLEPCVEC_H25,1016 #define VECCOMP VECCOMP30,1134 include/slepcversion.h,800 slepcversion.h:^?slepcversion.h^A,1 #define __SLEPCVERSION_H__SLEPCVERSION_H2,31 #define SLEPC_VERSION_RELEASE SLEPC_VERSION_RELEASE4,57 #define SLEPC_VERSION_MAJOR SLEPC_VERSION_MAJOR5,92 #define SLEPC_VERSION_MINOR SLEPC_VERSION_MINOR6,127 #define SLEPC_VERSION_SUBMINOR SLEPC_VERSION_SUBMINOR7,162 #define SLEPC_VERSION_PATCH SLEPC_VERSION_PATCH8,197 #define SLEPC_RELEASE_DATE SLEPC_RELEASE_DATE9,232 #define SLEPC_VERSION_DATE SLEPC_VERSION_DATE10,280 #define SLEPC_VERSION_GIT SLEPC_VERSION_GIT13,357 #define SLEPC_VERSION_DATE_GIT SLEPC_VERSION_DATE_GIT17,445 #define SLEPC_VERSION_(SLEPC_VERSION_20,496 #define SLEPC_VERSION_LT(SLEPC_VERSION_LT26,715 #define SLEPC_VERSION_LE(SLEPC_VERSION_LE34,1114 #define SLEPC_VERSION_GT(SLEPC_VERSION_GT38,1252 #define SLEPC_VERSION_GE(SLEPC_VERSION_GE41,1350 makefile,179 makefile:^?makefile^A,1 LOCDIR = .LOCDIR26,1041 DIRS = src include docsDIRS27,1052 -@grep "define SLEPC_VERSION" ${SLEPC_DIR}/include/slepcversion.h | ${SED} "s/........//"SLEPC_VERSION100,5456 setup.py,1787 setup.py:^?setup.py^A,1 metadata = {metadata56,1655 CONFIGURE_OPTIONS = []CONFIGURE_OPTIONS61,1723 def bootstrap():bootstrap63,1747 def get_petsc_dir():get_petsc_dir100,3087 def get_petsc_arch():get_petsc_arch111,3420 def config(prefix, dry_run=False):config115,3515 def build(dry_run=False):build133,4084 def install(dest_dir, dry_run=False):install145,4487 class context(object):context162,5134 def __init__(self):__init__163,5157 def enter(self):enter166,5249 def exit(self):exit171,5377 class cmd_install(_install):cmd_install175,5462 def initialize_options(self):initialize_options177,5492 def finalize_options(self):finalize_options181,5595 def run(self):run186,5764 def get_outputs(self):get_outputs206,6344 def version():version211,6488 def tarball():tarball231,7338 description = __doc__.split('\n')[1:-1]; del description[1:3]description237,7533 version=version(),version258,8181 description=description.pop(0),description259,8206 long_description='\n'.join(description),long_description260,8244 classifiers= classifiers.split('\n')[1:-1],classifiers261,8291 keywords = ['SLEPc','PETSc', 'MPI'],keywords262,8341 platforms=['POSIX'],platforms263,8384 license='LGPL',license264,8411 url='http://slepc.upv.es/',url266,8434 download_url=tarball(),download_url267,8468 author='SLEPc Team',author269,8499 author_email='slepc-maint@upv.es',author_email270,8526 maintainer='Lisandro Dalcin',maintainer271,8567 maintainer_email='dalcinl@gmail.com',maintainer_email272,8603 packages = ['slepc'],packages274,8648 package_dir = {'slepc': 'pypi'},package_dir275,8676 cmdclass={'install': cmd_install},cmdclass276,8715 src/eps/examples/makefile,82 makefile:^?makefile^A,1 LOCDIR = src/eps/examples/LOCDIR24,932 DIRS = tests tutorialsDIRS25,961 src/eps/examples/tests/makefile,1059 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/eps/examples/tests/LOCDIR26,978 EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c \EXAMPLESC27,1015 EXAMPLESF = test7f.F test14f.F test15f.FEXAMPLESF30,1176 MANSEC = EPSMANSEC31,1218 TESTS = test1 test2 test3 test4 test5 test6 test7f test8 test9 test10 \TESTS32,1235 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \TESTEXAMPLES_C35,1377 TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_2 test1.rmTESTEXAMPLES_C_NOCOMPLEX48,2198 TESTEXAMPLES_C_NOF128 = test5.PETSc runtest5_1 test5.rmTESTEXAMPLES_C_NOF12849,2257 TESTEXAMPLES_FORTRAN = test7f.PETSc runtest7f_1 test7f.rm \TESTEXAMPLES_FORTRAN50,2316 TESTEXAMPLES_BLOPEX = test5.PETSc runtest5_blopex test5.rmTESTEXAMPLES_BLOPEX52,2445 EPSALL = krylovschur arnoldi lanczos gd jd gd2EPSALL125,4163 EPSNS = krylovschur arnoldi gd jd gd2EPSNS126,4210 EPSAR = gd jd gd2EPSAR127,4249 TESTCODE = \TESTCODE129,4269 src/eps/examples/tests/test1.c,214 test1.c:^?test1.c^A,1 static char help[] = "Tests B-orthonormality of eigenvectors in a GHEP problem.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1034 #define __FUNCT__ __FUNCT__27,1051 int main(int argc,char **argv)main28,1076 src/eps/examples/tests/test10.c,226 test10.c:^?test10.c^A,1 static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\n\n"help22,924 #undef __FUNCT____FUNCT__30,1335 #define __FUNCT__ __FUNCT__31,1352 int main (int argc,char **argv)main32,1377 src/eps/examples/tests/test11.c,580 test11.c:^?test11.c^A,1 static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion."help22,924 #undef __FUNCT____FUNCT__37,1557 #define __FUNCT__ __FUNCT__38,1574 int main(int argc,char **argv)main39,1599 #undef __FUNCT____FUNCT__138,5334 #define __FUNCT__ __FUNCT__139,5351 PetscErrorCode MatMarkovModel(PetscInt m,Mat A)MatMarkovModel159,6507 #undef __FUNCT____FUNCT__204,7892 #define __FUNCT__ __FUNCT__205,7909 PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)MyEigenSort214,8250 src/eps/examples/tests/test12.c,359 test12.c:^?test12.c^A,1 static char help[] = "Diagonal eigenproblem. Illustrates use of shell preconditioner.\n\n"help22,924 #undef __FUNCT____FUNCT__29,1220 #define __FUNCT__ __FUNCT__30,1237 PetscErrorCode PCApply_User(PC pc,Vec x,Vec y)PCApply_User31,1270 #undef __FUNCT____FUNCT__40,1435 #define __FUNCT__ __FUNCT__41,1452 int main(int argc,char **argv)main42,1477 src/eps/examples/tests/test13.c,415 test13.c:^?test13.c^A,1 static char help[] = "Test EPSSetArbitrarySelection.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1007 #define __FUNCT__ __FUNCT__27,1024 PetscErrorCode MyArbitrarySelection(PetscScalar eigr,PetscScalar eigi,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)MyArbitrarySelection28,1065 #undef __funct____funct__40,1404 #define __funct__ __funct__41,1421 int main(int argc,char **argv)main42,1446 src/eps/examples/tests/test14.c,186 test14.c:^?test14.c^A,1 static char help[] = "Test EPS interface functions.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1006 #define __FUNCT__ __FUNCT__27,1023 int main(int argc,char **argv)main28,1048 src/eps/examples/tests/test14f.F,784 test14f.F:^?test14f.F^A,1 program mainmain24,1075 100 format (/'Diagonal Eigenproblem, n =',I3,' (Fortran)')10069,2518 110 format (' Type set to ',A)11097,3592 120 format (' Problem type before changing = ',I2)120103,3738 130 format (' ... changed to ',I2)130109,3950 140 format (' Extraction before changing = ',I2)140127,4462 150 format (' ... changed to ',I2)150133,4673 160 format (' Balance: ',I2,', its=',I2,', cutoff=',F8.6)160143,4943 170 format (' Which = ',I2,', target = ',F3.1)170153,5299 180 format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2)180162,5616 190 format (' Tolerance =',F7.5,', max_its =',I4)190171,5875 200 format (' Convergence test =',I2)200178,6098 210 format (' Finished - converged reason =',I2,', its=',I4)210207,7303 src/eps/examples/tests/test15f.F,368 test15f.F:^?test15f.F^A,1 program mainmain30,1292 100 format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')10077,2673 120 format (' Solution method: ',A)120156,5291 130 format (' Number of requested eigenvalues:',I2)130162,5521 subroutine MyEPSMonitor(MyEPSMonitor190,6482 140 format(i3,' EPS nconv=',i2,' first unconverged value (error) ', &140215,7217 src/eps/examples/tests/test16.c,415 test16.c:^?test16.c^A,1 static char help[] = "Tests a user-defined convergence test.\n\n";help22,924 #undef __FUNCT____FUNCT__27,1016 #define __FUNCT__ __FUNCT__28,1033 PetscErrorCode MyConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)MyConvergedAbsolute33,1209 #undef __FUNCT____FUNCT__40,1433 #define __FUNCT__ __FUNCT__41,1450 int main(int argc,char **argv)main42,1475 src/eps/examples/tests/test2.c,211 test2.c:^?test2.c^A,1 static char help[] = "Tests multiple calls to EPSSolve with the same matrix.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1031 #define __FUNCT__ __FUNCT__27,1048 int main(int argc,char **argv)main28,1073 src/eps/examples/tests/test3.c,212 test3.c:^?test3.c^A,1 static char help[] = "Tests multiple calls to EPSSolve with different matrix.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1032 #define __FUNCT__ __FUNCT__27,1049 int main(int argc,char **argv)main28,1074 src/eps/examples/tests/test4.c,234 test4.c:^?test4.c^A,1 static char help[] = "Test the solution of a HEP without calling EPSSetFromOptions (based on ex1.c).\n\n"help22,924 #undef __FUNCT____FUNCT__29,1214 #define __FUNCT__ __FUNCT__30,1231 int main(int argc,char **argv)main31,1256 src/eps/examples/tests/test5.c,218 test5.c:^?test5.c^A,1 static char help[] = "Test EPS with different builds with a matrix loaded from a file.\n"help22,924 #undef __FUNCT____FUNCT__29,1220 #define __FUNCT__ __FUNCT__30,1237 int main(int argc,char **argv)main31,1262 src/eps/examples/tests/test6.c,178 test6.c:^?test6.c^A,1 static char help[] = "Diagonal eigenproblem.\n\n"help22,924 #undef __FUNCT____FUNCT__29,1179 #define __FUNCT__ __FUNCT__30,1196 int main(int argc,char **argv)main31,1221 src/eps/examples/tests/test7f.F,228 test7f.F:^?test7f.F^A,1 program mainmain30,1319 100 format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')10072,2571 120 format (' Solution method: ',A)120143,4863 130 format (' Number of requested eigenvalues:',I2)130149,5093 src/eps/examples/tests/test8.c,622 test8.c:^?test8.c^A,1 static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. "help22,924 #undef __FUNCT____FUNCT__36,1446 #define __FUNCT__ __FUNCT__37,1463 int main(int argc,char **argv)main38,1488 static void tv(int nx,const PetscScalar *x,PetscScalar *y)tv117,4673 #undef __FUNCT____FUNCT__132,4954 #define __FUNCT__ __FUNCT__133,4971 PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)MatMult_Laplacian2D150,5491 #undef __FUNCT____FUNCT__182,6288 #define __FUNCT__ __FUNCT__183,6305 PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)MatGetDiagonal_Laplacian2D184,6352 src/eps/examples/tests/test9.c,592 test9.c:^?test9.c^A,1 static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. "help22,924 #undef __FUNCT____FUNCT__36,1559 #define __FUNCT__ __FUNCT__37,1576 int main(int argc,char **argv)main38,1601 #undef __FUNCT____FUNCT__130,4992 #define __FUNCT__ __FUNCT__131,5009 PetscErrorCode MatMarkovModel(PetscInt m,Mat A)MatMarkovModel151,6165 #undef __FUNCT____FUNCT__196,7550 #define __FUNCT__ __FUNCT__197,7567 PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)MyEigenSort205,7882 src/eps/examples/tutorials/ex1.c,243 ex1.c:^?ex1.c^A,1 static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension.\n\n"help22,924 #undef __FUNCT____FUNCT__28,1178 #define __FUNCT__ __FUNCT__29,1195 int main(int argc,char **argv)main30,1220 src/eps/examples/tutorials/ex10.c,1069 ex10.c:^?ex10.c^A,1 static char help[] = "Illustrates the use of shell spectral transformations. "help22,924 KSP ksp;ksp32,1338 } SampleShellST;SampleShellST33,1356 #undef __FUNCT____FUNCT__42,1699 #define __FUNCT__ __FUNCT__43,1716 int main (int argc,char **argv)main44,1741 #undef __FUNCT____FUNCT__167,6864 #define __FUNCT__ __FUNCT__168,6881 PetscErrorCode STCreate_User(SampleShellST **shell)STCreate_User176,7090 #undef __FUNCT____FUNCT__189,7520 #define __FUNCT__ __FUNCT__190,7537 PetscErrorCode STSetUp_User(SampleShellST *shell,ST st)STSetUp_User208,8164 #undef __FUNCT____FUNCT__220,8552 #define __FUNCT__ __FUNCT__221,8569 PetscErrorCode STApply_User(ST st,Vec x,Vec y)STApply_User238,9025 #undef __FUNCT____FUNCT__249,9361 #define __FUNCT__ __FUNCT__250,9378 PetscErrorCode STBackTransform_User(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)STBackTransform_User269,10021 #undef __FUNCT____FUNCT__280,10311 #define __FUNCT__ __FUNCT__281,10328 PetscErrorCode STDestroy_User(SampleShellST *shell)STDestroy_User289,10539 src/eps/examples/tutorials/ex11.c,226 ex11.c:^?ex11.c^A,1 static char help[] = "Computes the smallest nonzero eigenvalue of the Laplacian of a graph.\n\n"help22,924 #undef __FUNCT____FUNCT__30,1335 #define __FUNCT__ __FUNCT__31,1352 int main (int argc,char **argv)main32,1377 src/eps/examples/tutorials/ex12.c,227 ex12.c:^?ex12.c^A,1 static char help[] = "Compute all eigenvalues in an interval of a symmetric-definite problem.\n\n"help22,924 #undef __FUNCT____FUNCT__29,1230 #define __FUNCT__ __FUNCT__30,1247 int main(int argc,char **argv)main31,1272 src/eps/examples/tutorials/ex13.c,191 ex13.c:^?ex13.c^A,1 static char help[] = "Generalized Symmetric eigenproblem.\n\n"help22,924 #undef __FUNCT____FUNCT__33,1422 #define __FUNCT__ __FUNCT__34,1439 int main(int argc,char **argv)main35,1464 src/eps/examples/tutorials/ex18.c,580 ex18.c:^?ex18.c^A,1 static char help[] = "Solves the same problem as in ex5, but with a user-defined sorting criterion."help22,924 #undef __FUNCT____FUNCT__37,1557 #define __FUNCT__ __FUNCT__38,1574 int main(int argc,char **argv)main39,1599 #undef __FUNCT____FUNCT__131,5198 #define __FUNCT__ __FUNCT__132,5215 PetscErrorCode MatMarkovModel(PetscInt m,Mat A)MatMarkovModel152,6371 #undef __FUNCT____FUNCT__197,7756 #define __FUNCT__ __FUNCT__198,7773 PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)MyEigenSort207,8114 src/eps/examples/tutorials/ex19.c,569 ex19.c:^?ex19.c^A,1 static char help[] = "Standard symmetric eigenproblem for the 3-D Laplacian built with the DM interface.\n\n"help22,924 #undef __FUNCT____FUNCT__30,1219 #define __FUNCT__ __FUNCT__31,1236 PetscErrorCode GetExactEigenvalues(PetscInt M,PetscInt N,PetscInt P,PetscInt nconv,PetscReal *exact)GetExactEigenvalues32,1276 #undef __FUNCT____FUNCT__61,2096 #define __FUNCT__ __FUNCT__62,2113 PetscErrorCode FillMatrix(DM da,Mat A)FillMatrix63,2144 #undef __FUNCT____FUNCT__96,3467 #define __FUNCT__ __FUNCT__97,3484 int main(int argc,char **argv)main98,3509 src/eps/examples/tutorials/ex1f.F,508 ex1f.F:^?ex1f.F^A,1 program mainmain31,1382 100 format (/'1-D Laplacian Eigenproblem, n =',I3,' (Fortran)')10076,2741 110 format (/' Number of iterations of the method:',I4)110147,5008 120 format (' Solution method: ',A)120154,5243 130 format (' Number of requested eigenvalues:',I2)130160,5473 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)140165,5647 150 format (' Number of converged eigenpairs:',I2/)150176,6055 160 format (1P,' ',E12.4,' ',E12.4)160194,6786 src/eps/examples/tutorials/ex1f90.F90,298 ex1f90.F90:^?ex1f90.F90^A,1 program mainmain31,1384 type(Mat) AA53,1974 type(EPS) epseps54,1997 100 format (/'1-D Laplacian Eigenproblem, n =',I4,' (Fortran)')10084,2869 120 format (' Solution method: ',A)120153,5165 130 format (' Number of requested eigenvalues:',I4)130159,5395 src/eps/examples/tutorials/ex2.c,244 ex2.c:^?ex2.c^A,1 static char help[] = "Standard symmetric eigenproblem corresponding to the Laplacian operator in 2 dimensions.\n\n"help22,924 #undef __FUNCT____FUNCT__29,1247 #define __FUNCT__ __FUNCT__30,1264 int main(int argc,char **argv)main31,1289 src/eps/examples/tutorials/ex24.c,811 ex24.c:^?ex24.c^A,1 static char help[] = "Spectrum folding for a standard symmetric eigenproblem.\n\n"help22,924 Mat A;A34,1321 Vec w;w35,1336 PetscReal target;target36,1351 } CTX_FOLD;CTX_FOLD37,1371 #undef __FUNCT____FUNCT__46,1578 #define __FUNCT__ __FUNCT__47,1595 int main(int argc,char **argv)main48,1620 #undef __FUNCT____FUNCT__206,8430 #define __FUNCT__ __FUNCT__207,8447 PetscErrorCode MatMult_Fold(Mat M,Vec x,Vec y)MatMult_Fold212,8575 #undef __FUNCT____FUNCT__228,9019 #define __FUNCT__ __FUNCT__229,9036 PetscErrorCode RayleighQuotient(Mat A,Vec x,PetscScalar *r)RayleighQuotient234,9182 #undef __FUNCT____FUNCT__247,9507 #define __FUNCT__ __FUNCT__248,9524 PetscErrorCode ComputeResidualNorm(Mat A,PetscScalar lambda,Vec x,PetscReal *r)ComputeResidualNorm252,9650 src/eps/examples/tutorials/ex25.c,211 ex25.c:^?ex25.c^A,1 static char help[] = "Spectrum slicing on generalized symmetric eigenproblem.\n\n"help22,924 #undef __FUNCT____FUNCT__30,1254 #define __FUNCT__ __FUNCT__31,1271 int main(int argc,char **argv)main32,1296 src/eps/examples/tutorials/ex29.c,598 ex29.c:^?ex29.c^A,1 static char help[] = "Solves the same problem as in ex5, with a user-defined stopping test."help22,924 #undef __FUNCT____FUNCT__39,1642 #define __FUNCT__ __FUNCT__40,1659 int main(int argc,char **argv)main41,1684 #undef __FUNCT____FUNCT__116,5097 #define __FUNCT__ __FUNCT__117,5114 PetscErrorCode MatMarkovModel(PetscInt m,Mat A)MatMarkovModel137,6270 #undef __FUNCT____FUNCT__182,7655 #define __FUNCT__ __FUNCT__183,7672 PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)MyStoppingTest189,7825 src/eps/examples/tutorials/ex3.c,622 ex3.c:^?ex3.c^A,1 static char help[] = "Solves the same eigenproblem as in example ex2, but using a shell matrix. "help22,924 #undef __FUNCT____FUNCT__36,1446 #define __FUNCT__ __FUNCT__37,1463 int main(int argc,char **argv)main38,1488 static void tv(int nx,const PetscScalar *x,PetscScalar *y)tv125,5092 #undef __FUNCT____FUNCT__140,5373 #define __FUNCT__ __FUNCT__141,5390 PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)MatMult_Laplacian2D158,5910 #undef __FUNCT____FUNCT__190,6707 #define __FUNCT__ __FUNCT__191,6724 PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)MatGetDiagonal_Laplacian2D192,6771 src/eps/examples/tutorials/ex30.c,1650 ex30.c:^?ex30.c^A,1 static char help[] = "Illustrates the use of a region for filtering; the number of wanted eigenvalues in not known a priori.\n\n"help22,924 Mat T;T47,2126 Vec x1,x2,y1,y2;x148,2143 Vec x1,x2,y1,y2;x248,2143 Vec x1,x2,y1,y2;y148,2143 Vec x1,x2,y1,y2;y248,2143 PetscScalar alpha,beta,tau1,tau2,sigma;alpha49,2170 PetscScalar alpha,beta,tau1,tau2,sigma;beta49,2170 PetscScalar alpha,beta,tau1,tau2,sigma;tau149,2170 PetscScalar alpha,beta,tau1,tau2,sigma;tau249,2170 PetscScalar alpha,beta,tau1,tau2,sigma;sigma49,2170 PetscInt lastnconv; /* last value of nconv; used in stopping test */lastnconv50,2212 PetscInt nreps; /* number of repetitions of nconv; used in stopping test */nreps51,2291 } CTX_BRUSSEL;CTX_BRUSSEL52,2381 #undef __FUNCT____FUNCT__54,2397 #define __FUNCT__ __FUNCT__55,2414 int main(int argc,char **argv)main56,2439 #undef __FUNCT____FUNCT__195,8211 #define __FUNCT__ __FUNCT__196,8228 PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y)MatMult_Brussel197,8264 #undef __FUNCT____FUNCT__234,9709 #define __FUNCT__ __FUNCT__235,9726 PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y)MatShift_Brussel236,9763 #undef __FUNCT____FUNCT__247,10000 #define __FUNCT__ __FUNCT__248,10017 PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag)MatGetDiagonal_Brussel249,10060 #undef __FUNCT____FUNCT__275,10987 #define __FUNCT__ __FUNCT__276,11004 PetscErrorCode MyStoppingTest(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ptr)MyStoppingTest286,11398 src/eps/examples/tutorials/ex31.c,4714 ex31.c:^?ex31.c^A,1 static char help[] = "Power grid small signal stability analysis of WECC 9 bus system.\n\help22,924 #define freq freq77,2895 #define w_s w_s78,2911 const PetscInt nbus = 9; /* Number of network buses */nbus81,2966 const PetscInt ngen = 3; /* Number of generators */ngen82,3024 const PetscInt nload = 3; /* Number of loads */nload83,3079 const PetscInt gbus[3] = {0,1,2}; /* Buses at which generators are incident */gbus84,3129 const PetscInt lbus[3] = {4,5,7}; /* Buses at which loads are incident */lbus85,3208 const PetscScalar PG[3] = {0.716786142395021,1.630000000000000,0.850000000000000};PG88,3345 const PetscScalar QG[3] = {0.270702180178785,0.066120127797275,-0.108402221791588};QG89,3428 const PetscScalar H[3] = {23.64,6.4,3.01}; /* Inertia constant */H91,3538 const PetscScalar Rs[3] = {0.0,0.0,0.0}; /* Stator Resistance */Rs92,3609 const PetscScalar Xd[3] = {0.146,0.8958,1.3125}; /* d-axis reactance */Xd93,3676 const PetscScalar Xdp[3] = {0.0608,0.1198,0.1813}; /* d-axis transient reactance */Xdp94,3751 const PetscScalar Xq[3] = {0.0969,0.8645,1.2578}; /* q-axis reactance Xq(1) set to 0.4360, value given in text 0.0969 */Xq95,3836 const PetscScalar Xqp[3] = {0.0969,0.1969,0.25}; /* q-axis transient reactance */Xqp96,3959 const PetscScalar Td0p[3] = {8.96,6.0,5.89}; /* d-axis open circuit time constant */Td0p97,4042 const PetscScalar Tq0p[3] = {0.31,0.535,0.6}; /* q-axis open circuit time constant */Tq0p98,4127 PetscScalar M[3]; /* M = 2*H/w_s */M99,4213 PetscScalar D[3]; /* D = 0.1*M */D100,4249 PetscScalar TM[3]; /* Mechanical Torque */TM102,4284 const PetscScalar KA[3] = {20.0,20.0,20.0}; /* Voltage regulartor gain constant */KA104,4358 const PetscScalar TA[3] = {0.2,0.2,0.2}; /* Voltage regulator time constant */TA105,4442 const PetscScalar KE[3] = {1.0,1.0,1.0}; /* Exciter gain constant */KE106,4525 const PetscScalar TE[3] = {0.314,0.314,0.314}; /* Exciter time constant */TE107,4598 const PetscScalar KF[3] = {0.063,0.063,0.063}; /* Feedback stabilizer gain constant */KF108,4673 const PetscScalar TF[3] = {0.35,0.35,0.35}; /* Feedback stabilizer time constant */TF109,4761 const PetscScalar k1[3] = {0.0039,0.0039,0.0039};k1110,4848 const PetscScalar k2[3] = {1.555,1.555,1.555}; /* k1 and k2 for calculating the saturation function SE = k1*exp(k2*Efd) */k2111,4898 PetscScalar Vref[3];Vref113,5023 const PetscScalar PD0[3] = {1.25,0.9,1.0};PD0129,5864 const PetscScalar QD0[3] = {0.5,0.3,0.35};QD0130,5907 const PetscInt ld_nsegsp[3] = {3,3,3};ld_nsegsp131,5950 const PetscScalar ld_alphap[3] = {0.0,0.0,1.0};ld_alphap132,5992 const PetscScalar ld_betap[3] = {2.0,1.0,0.0};ld_betap133,6040 const PetscInt ld_nsegsq[3] = {3,3,3};ld_nsegsq134,6088 const PetscScalar ld_alphaq[3] = {0.0,0.0,1.0};ld_alphaq135,6130 const PetscScalar ld_betaq[3] = {2.0,1.0,0.0};ld_betaq136,6178 DM dmgen, dmnet; /* DMs to manage generator and network subsystem */dmgen139,6244 DM dmgen, dmnet; /* DMs to manage generator and network subsystem */dmnet139,6244 DM dmpgrid; /* Composite DM to manage the entire power grid */dmpgrid140,6321 Mat Ybus; /* Network admittance matrix */Ybus141,6397 Vec V0; /* Initial voltage vector (Power flow solution) */V0142,6454 PetscInt neqs_gen,neqs_net,neqs_pgrid;neqs_gen143,6530 PetscInt neqs_gen,neqs_net,neqs_pgrid;neqs_net143,6530 PetscInt neqs_gen,neqs_net,neqs_pgrid;neqs_pgrid143,6530 IS is_diff; /* indices for differential equations */is_diff144,6571 IS is_alg; /* indices for algebraic equations */is_alg145,6637 } Userctx;Userctx146,6700 #undef __FUNCT____FUNCT__149,6798 #define __FUNCT__ __FUNCT__150,6815 PetscErrorCode dq2ri(PetscScalar Fd,PetscScalar Fq,PetscScalar delta,PetscScalar *Fr,PetscScalar *Fi)dq2ri151,6841 #undef __FUNCT____FUNCT__160,7207 #define __FUNCT__ __FUNCT__161,7224 PetscErrorCode ri2dq(PetscScalar Fr,PetscScalar Fi,PetscScalar delta,PetscScalar *Fd,PetscScalar *Fq)ri2dq162,7250 #undef __FUNCT____FUNCT__170,7529 #define __FUNCT__ __FUNCT__171,7546 PetscErrorCode SetInitialGuess(Vec X,Userctx *user)SetInitialGuess172,7582 #undef __FUNCT____FUNCT__257,10203 #define __FUNCT__ __FUNCT__258,10220 PetscErrorCode PreallocateJacobian(Mat J,Userctx *user)PreallocateJacobian259,10260 #undef __FUNCT____FUNCT__308,11392 #define __FUNCT__ __FUNCT__309,11409 PetscErrorCode ResidualJacobian(Vec X,Mat J,void *ctx)ResidualJacobian310,11446 #undef __FUNCT____FUNCT__540,21724 #define __FUNCT__ __FUNCT__541,21741 int main(int argc,char **argv)main542,21766 src/eps/examples/tutorials/ex4.c,225 ex4.c:^?ex4.c^A,1 static char help[] = "Solves a standard eigensystem Ax=kx with the matrix loaded from a file.\n"help22,924 #undef __FUNCT____FUNCT__29,1225 #define __FUNCT__ __FUNCT__30,1242 int main(int argc,char **argv)main31,1267 src/eps/examples/tutorials/ex5.c,387 ex5.c:^?ex5.c^A,1 static char help[] = "Eigenvalue problem associated with a Markov model of a random walk on a triangular grid. "help22,924 #undef __FUNCT____FUNCT__35,1448 #define __FUNCT__ __FUNCT__36,1465 int main(int argc,char **argv)main37,1490 #undef __FUNCT____FUNCT__126,4895 #define __FUNCT__ __FUNCT__127,4912 PetscErrorCode MatMarkovModel(PetscInt m,Mat A)MatMarkovModel147,6068 src/eps/examples/tutorials/ex6f.F,356 ex6f.F:^?ex6f.F^A,1 program mainmain32,1467 999 continue999162,6229 subroutine MatIsing_Mult(MatIsing_Mult178,6534 SUBROUTINE MVMISG(MVMISG213,7528 10 CONTINUE10288,9507 20 CONTINUE 20295,9782 30 CONTINUE 30297,9807 40 CONTINUE 40308,10094 50 CONTINUE50314,10365 60 CONTINUE60318,10476 src/eps/examples/tutorials/ex7.c,227 ex7.c:^?ex7.c^A,1 static char help[] = "Solves a generalized eigensystem Ax=kBx with matrices loaded from a file.\n"help22,924 #undef __FUNCT____FUNCT__33,1500 #define __FUNCT__ __FUNCT__34,1517 int main(int argc,char **argv)main35,1542 src/eps/examples/tutorials/ex9.c,1230 ex9.c:^?ex9.c^A,1 static char help[] = "Solves a problem associated to the Brusselator wave model in chemical reactions, illustrating the use of shell matrices.\n\n"help22,924 Mat T;T55,1910 Vec x1,x2,y1,y2;x156,1927 Vec x1,x2,y1,y2;x256,1927 Vec x1,x2,y1,y2;y156,1927 Vec x1,x2,y1,y2;y256,1927 PetscScalar alpha,beta,tau1,tau2,sigma;alpha57,1954 PetscScalar alpha,beta,tau1,tau2,sigma;beta57,1954 PetscScalar alpha,beta,tau1,tau2,sigma;tau157,1954 PetscScalar alpha,beta,tau1,tau2,sigma;tau257,1954 PetscScalar alpha,beta,tau1,tau2,sigma;sigma57,1954 } CTX_BRUSSEL;CTX_BRUSSEL58,1996 #undef __FUNCT____FUNCT__60,2012 #define __FUNCT__ __FUNCT__61,2029 int main(int argc,char **argv)main62,2054 #undef __FUNCT____FUNCT__207,7773 #define __FUNCT__ __FUNCT__208,7790 PetscErrorCode MatMult_Brussel(Mat A,Vec x,Vec y)MatMult_Brussel209,7826 #undef __FUNCT____FUNCT__246,9271 #define __FUNCT__ __FUNCT__247,9288 PetscErrorCode MatShift_Brussel(PetscScalar* a,Mat Y)MatShift_Brussel248,9325 #undef __FUNCT____FUNCT__259,9562 #define __FUNCT__ __FUNCT__260,9579 PetscErrorCode MatGetDiagonal_Brussel(Mat A,Vec diag)MatGetDiagonal_Brussel261,9622 src/eps/examples/tutorials/makefile,944 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/eps/examples/tutorials/LOCDIR26,978 EXAMPLESC = ex1.c ex2.c ex3.c ex4.c ex5.c ex7.c ex9.c ex10.c ex11.c ex12.c ex13.c \EXAMPLESC27,1019 EXAMPLESF = ex1f.F ex1f90.F90 ex6f.FEXAMPLESF29,1166 MANSEC = EPSMANSEC30,1204 TESTEXAMPLES_C = ex2.PETSc runex2_1 runex2_ciss_1 runex2_ciss_2 ex2.rm \TESTEXAMPLES_C32,1222 TESTEXAMPLES_C_NOCOMPLEX = ex4.PETSc runex4_1 ex4.rm \TESTEXAMPLES_C_NOCOMPLEX44,2013 TESTEXAMPLES_FORTRAN_NOCOMPLEX = ex6f.PETSc runex6f_1 ex6f.rmTESTEXAMPLES_FORTRAN_NOCOMPLEX48,2261 TESTEXAMPLES_F90 = ex1f90.PETSc runex1f90_1 ex1f90.rmTESTEXAMPLES_F9049,2323 TESTEXAMPLES_DATAFILESPATH_COMPLEX = ex4.PETSc runex4_ciss_1 ex4.rm \TESTEXAMPLES_DATAFILESPATH_COMPLEX50,2391 DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matricesDATAPATH140,4338 src/eps/f90-mod/makefile,397 makefile:^?makefile^A,1 SPECIALLIB = yesSPECIALLIB28,1120 SPECIALFASTLIB = yesSPECIALFASTLIB29,1141 CFLAGS =CFLAGS32,1164 FFLAGS =FFLAGS33,1177 SOURCEC =SOURCEC34,1190 SOURCEF = slepcepsmod.FSOURCEF35,1203 SOURCEH =SOURCEH36,1230 LIBBASE = libslepcepsLIBBASE37,1243 MANSEC = EPSMANSEC38,1268 LOCDIR = src/eps/f90-mod/LOCDIR39,1285 CLEANFILES = *.modCLEANFILES40,1315 src/eps/f90-mod/slepcepsmod.F,87 slepcepsmod.F:^?slepcepsmod.F^A,1 module slepcepsdefslepcepsdef22,965 module slepcepsslepceps31,1182 src/eps/impls/cg/lobpcg/lobpcg.c,3473 lobpcg.c:^?lobpcg.c^A,1 PetscInt bs; /* block size */bs45,1628 PetscBool lock; /* soft locking active/inactive */lock46,1668 PetscReal restart; /* restart parameter */restart47,1726 } EPS_LOBPCG;EPS_LOBPCG48,1773 #undef __FUNCT____FUNCT__50,1788 #define __FUNCT__ __FUNCT__51,1805 PetscErrorCode EPSSetDimensions_LOBPCG(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)EPSSetDimensions_LOBPCG52,1849 #undef __FUNCT____FUNCT__67,2442 #define __FUNCT__ __FUNCT__68,2459 PetscErrorCode EPSSetUp_LOBPCG(EPS eps)EPSSetUp_LOBPCG69,2495 #undef __FUNCT____FUNCT__102,4334 #define __FUNCT__ __FUNCT__103,4351 PetscErrorCode EPSSolve_LOBPCG(EPS eps)EPSSolve_LOBPCG104,4387 #undef __FUNCT____FUNCT__412,16595 #define __FUNCT__ __FUNCT__413,16612 static PetscErrorCode EPSLOBPCGSetBlockSize_LOBPCG(EPS eps,PetscInt bs)EPSLOBPCGSetBlockSize_LOBPCG414,16661 #undef __FUNCT____FUNCT__423,16847 #define __FUNCT__ __FUNCT__424,16864 PetscErrorCode EPSLOBPCGSetBlockSize(EPS eps,PetscInt bs)EPSLOBPCGSetBlockSize441,17230 #undef __FUNCT____FUNCT__452,17550 #define __FUNCT__ __FUNCT__453,17567 static PetscErrorCode EPSLOBPCGGetBlockSize_LOBPCG(EPS eps,PetscInt *bs)EPSLOBPCGGetBlockSize_LOBPCG454,17616 #undef __FUNCT____FUNCT__463,17804 #define __FUNCT__ __FUNCT__464,17821 PetscErrorCode EPSLOBPCGGetBlockSize(EPS eps,PetscInt *bs)EPSLOBPCGGetBlockSize480,18126 #undef __FUNCT____FUNCT__491,18431 #define __FUNCT__ __FUNCT__492,18448 static PetscErrorCode EPSLOBPCGSetRestart_LOBPCG(EPS eps,PetscReal restart)EPSLOBPCGSetRestart_LOBPCG493,18495 #undef __FUNCT____FUNCT__506,18919 #define __FUNCT__ __FUNCT__507,18936 PetscErrorCode EPSLOBPCGSetRestart(EPS eps,PetscReal restart)EPSLOBPCGSetRestart530,19606 #undef __FUNCT____FUNCT__541,19940 #define __FUNCT__ __FUNCT__542,19957 static PetscErrorCode EPSLOBPCGGetRestart_LOBPCG(EPS eps,PetscReal *restart)EPSLOBPCGGetRestart_LOBPCG543,20004 #undef __FUNCT____FUNCT__552,20206 #define __FUNCT__ __FUNCT__553,20223 PetscErrorCode EPSLOBPCGGetRestart(EPS eps,PetscReal *restart)EPSLOBPCGGetRestart569,20541 #undef __FUNCT____FUNCT__580,20859 #define __FUNCT__ __FUNCT__581,20876 static PetscErrorCode EPSLOBPCGSetLocking_LOBPCG(EPS eps,PetscBool lock)EPSLOBPCGSetLocking_LOBPCG582,20923 #undef __FUNCT____FUNCT__591,21114 #define __FUNCT__ __FUNCT__592,21131 PetscErrorCode EPSLOBPCGSetLocking(EPS eps,PetscBool lock)EPSLOBPCGSetLocking615,21737 #undef __FUNCT____FUNCT__626,22062 #define __FUNCT__ __FUNCT__627,22079 static PetscErrorCode EPSLOBPCGGetLocking_LOBPCG(EPS eps,PetscBool *lock)EPSLOBPCGGetLocking_LOBPCG628,22126 #undef __FUNCT____FUNCT__637,22319 #define __FUNCT__ __FUNCT__638,22336 PetscErrorCode EPSLOBPCGGetLocking(EPS eps,PetscBool *lock)EPSLOBPCGGetLocking654,22641 #undef __FUNCT____FUNCT__665,22950 #define __FUNCT__ __FUNCT__666,22967 PetscErrorCode EPSView_LOBPCG(EPS eps,PetscViewer viewer)EPSView_LOBPCG667,23002 #undef __FUNCT____FUNCT__683,23705 #define __FUNCT__ __FUNCT__684,23722 PetscErrorCode EPSSetFromOptions_LOBPCG(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_LOBPCG685,23767 #undef __FUNCT____FUNCT__722,25144 #define __FUNCT__ __FUNCT__723,25161 PetscErrorCode EPSDestroy_LOBPCG(EPS eps)EPSDestroy_LOBPCG724,25199 #undef __FUNCT____FUNCT__739,25955 #define __FUNCT__ __FUNCT__740,25972 PETSC_EXTERN PetscErrorCode EPSCreate_LOBPCG(EPS eps)EPSCreate_LOBPCG741,26009 src/eps/impls/cg/lobpcg/makefile,281 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = lobpcg.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcepsLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = EPSMANSEC31,1034 LOCDIR = src/eps/impls/cg/lobpcg/LOCDIR32,1049 src/eps/impls/cg/makefile,146 makefile:^?makefile^A,1 LIBBASE = libslepcepsLIBBASE24,936 DIRS = rqcg lobpcgDIRS25,959 LOCDIR = src/eps/impls/cg/LOCDIR26,982 MANSEC = EPSMANSEC27,1011 src/eps/impls/cg/rqcg/makefile,276 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = rqcg.cSOURCEC26,958 SOURCEF =SOURCEF27,976 SOURCEH =SOURCEH28,987 LIBBASE = libslepcepsLIBBASE29,998 DIRS =DIRS30,1021 MANSEC = EPSMANSEC31,1032 LOCDIR = src/eps/impls/cg/rqcg/LOCDIR32,1047 src/eps/impls/cg/rqcg/rqcg.c,2059 rqcg.c:^?rqcg.c^A,1 PetscInt nrest;nrest43,1500 BV AV,W,P,G;AV44,1518 BV AV,W,P,G;W44,1518 BV AV,W,P,G;P44,1518 BV AV,W,P,G;G44,1518 } EPS_RQCG;EPS_RQCG45,1539 #undef __FUNCT____FUNCT__47,1552 #define __FUNCT__ __FUNCT__48,1569 PetscErrorCode EPSSetUp_RQCG(EPS eps)EPSSetUp_RQCG49,1603 #undef __FUNCT____FUNCT__94,3914 #define __FUNCT__ __FUNCT__95,3931 static PetscErrorCode ExtractSubmatrix(Mat A,PetscInt k,Mat *B)ExtractSubmatrix99,4028 #undef __FUNCT____FUNCT__118,4654 #define __FUNCT__ __FUNCT__119,4671 PetscErrorCode EPSSolve_RQCG(EPS eps)EPSSolve_RQCG120,4705 #undef __FUNCT____FUNCT__298,12458 #define __FUNCT__ __FUNCT__299,12475 static PetscErrorCode EPSRQCGSetReset_RQCG(EPS eps,PetscInt nrest)EPSRQCGSetReset_RQCG300,12516 #undef __FUNCT____FUNCT__309,12699 #define __FUNCT__ __FUNCT__310,12716 PetscErrorCode EPSRQCGSetReset(EPS eps,PetscInt nrest)EPSRQCGSetReset328,13176 #undef __FUNCT____FUNCT__339,13493 #define __FUNCT__ __FUNCT__340,13510 static PetscErrorCode EPSRQCGGetReset_RQCG(EPS eps,PetscInt *nrest)EPSRQCGGetReset_RQCG341,13551 #undef __FUNCT____FUNCT__350,13736 #define __FUNCT__ __FUNCT__351,13753 PetscErrorCode EPSRQCGGetReset(EPS eps,PetscInt *nrest)EPSRQCGGetReset367,14051 #undef __FUNCT____FUNCT__378,14353 #define __FUNCT__ __FUNCT__379,14370 PetscErrorCode EPSReset_RQCG(EPS eps)EPSReset_RQCG380,14404 #undef __FUNCT____FUNCT__394,14756 #define __FUNCT__ __FUNCT__395,14773 PetscErrorCode EPSSetFromOptions_RQCG(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_RQCG396,14816 #undef __FUNCT____FUNCT__412,15331 #define __FUNCT__ __FUNCT__413,15348 PetscErrorCode EPSDestroy_RQCG(EPS eps)EPSDestroy_RQCG414,15384 #undef __FUNCT____FUNCT__425,15734 #define __FUNCT__ __FUNCT__426,15751 PetscErrorCode EPSView_RQCG(EPS eps,PetscViewer viewer)EPSView_RQCG427,15784 #undef __FUNCT____FUNCT__441,16210 #define __FUNCT__ __FUNCT__442,16227 PETSC_EXTERN PetscErrorCode EPSCreate_RQCG(EPS eps)EPSCreate_RQCG443,16262 src/eps/impls/ciss/ciss.c,10091 ciss.c:^?ciss.c^A,1 PetscInt N; /* number of integration points (32) */N49,1731 PetscInt L; /* block size (16) */L50,1803 PetscInt M; /* moment degree (N/4 = 4) */M51,1857 PetscReal delta; /* threshold of singular value (1e-12) */delta52,1919 PetscInt L_max; /* maximum number of columns of the source matrix V */L_max53,1993 PetscReal spurious_threshold; /* discard spurious eigenpairs */spurious_threshold54,2080 PetscBool isreal; /* A and B are real */isreal55,2154 PetscInt refine_inner;refine_inner56,2209 PetscInt refine_blocksize;refine_blocksize57,2243 PetscReal *sigma; /* threshold for numerical rank */sigma59,2302 PetscInt num_subcomm;num_subcomm60,2369 PetscInt subcomm_id;subcomm_id61,2402 PetscInt num_solve_point;num_solve_point62,2434 PetscScalar *weight;weight63,2471 PetscScalar *omega;omega64,2500 PetscScalar *pp;pp65,2528 BV V;V66,2553 BV S;S67,2576 BV pV;pV68,2599 BV Y;Y69,2623 Vec xsub;xsub70,2646 Vec xdup;xdup71,2672 KSP *ksp;ksp72,2698 Mat *kspMat;kspMat73,2724 PetscBool useconj;useconj74,2753 PetscReal est_eig;est_eig75,2782 VecScatter scatterin;scatterin76,2811 Mat pA,pB;pA77,2842 Mat pA,pB;pB77,2842 PetscSubcomm subcomm;subcomm78,2869 PetscBool usest;usest79,2898 PetscBool usest_set; /* whether the user set the usest flag or not */usest_set80,2925 EPSCISSQuadRule quad;quad81,3006 EPSCISSExtraction extraction;extraction82,3032 } EPS_CISS;EPS_CISS83,3064 #undef __FUNCT____FUNCT__85,3077 #define __FUNCT__ __FUNCT__86,3094 static PetscErrorCode SetSolverComm(EPS eps)SetSolverComm87,3128 #undef __FUNCT____FUNCT__108,3965 #define __FUNCT__ __FUNCT__109,3982 static PetscErrorCode CISSRedundantMat(EPS eps)CISSRedundantMat110,4019 #undef __FUNCT____FUNCT__133,4795 #define __FUNCT__ __FUNCT__134,4812 static PetscErrorCode CISSScatterVec(EPS eps)CISSScatterVec135,4847 #undef __FUNCT____FUNCT__171,6337 #define __FUNCT__ __FUNCT__172,6354 static PetscErrorCode SetPathParameter(EPS eps)SetPathParameter173,6391 #undef __FUNCT____FUNCT__261,10143 #define __FUNCT__ __FUNCT__262,10160 static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1)CISSVecSetRandom263,10197 #undef __FUNCT____FUNCT__287,10908 #define __FUNCT__ __FUNCT__288,10925 static PetscErrorCode VecScatterVecs(EPS eps,BV Vin,PetscInt n)VecScatterVecs289,10960 #undef __FUNCT____FUNCT__314,11953 #define __FUNCT__ __FUNCT__315,11970 static PetscErrorCode SolveLinearSystem(EPS eps,Mat A,Mat B,BV V,PetscInt L_start,PetscInt L_end,PetscBool initksp)SolveLinearSystem316,12008 #undef __FUNCT____FUNCT__378,14398 #define __FUNCT__ __FUNCT__379,14415 static PetscErrorCode EstimateNumberEigs(EPS eps,PetscInt *L_add)EstimateNumberEigs380,14454 #undef __FUNCT____FUNCT__429,16404 #define __FUNCT__ __FUNCT__430,16421 static PetscErrorCode CalcMu(EPS eps,PetscScalar *Mu)CalcMu431,16448 #undef __FUNCT____FUNCT__484,18668 #define __FUNCT__ __FUNCT__485,18685 static PetscErrorCode BlockHankel(EPS eps,PetscScalar *Mu,PetscInt s,PetscScalar *H)BlockHankel486,18717 #undef __FUNCT____FUNCT__499,19046 #define __FUNCT__ __FUNCT__500,19063 static PetscErrorCode SVD_H0(EPS eps,PetscScalar *S,PetscInt *K)SVD_H0501,19090 #undef __FUNCT____FUNCT__543,20546 #define __FUNCT__ __FUNCT__544,20563 static PetscErrorCode ConstructS(EPS eps)ConstructS545,20594 #undef __FUNCT____FUNCT__593,22460 #define __FUNCT__ __FUNCT__594,22477 static PetscErrorCode SVD_S(BV S,PetscInt ml,PetscReal delta,PetscReal *sigma,PetscInt *K)SVD_S595,22503 #undef __FUNCT____FUNCT__705,27026 #define __FUNCT__ __FUNCT__706,27043 static PetscErrorCode isGhost(EPS eps,PetscInt ld,PetscInt nv,PetscBool *fl)isGhost707,27071 #undef __FUNCT____FUNCT__742,28066 #define __FUNCT__ __FUNCT__743,28083 static PetscErrorCode rescale_eig(EPS eps,PetscInt nv)rescale_eig744,28115 #undef __FUNCT____FUNCT__812,30792 #define __FUNCT__ __FUNCT__813,30809 PetscErrorCode EPSSetUp_CISS(EPS eps)EPSSetUp_CISS814,30843 #undef __FUNCT____FUNCT__963,38255 #define __FUNCT__ __FUNCT__964,38272 PetscErrorCode EPSSolve_CISS(EPS eps)EPSSolve_CISS965,38306 #undef __FUNCT____FUNCT__1184,47481 #define __FUNCT__ __FUNCT__1185,47498 static PetscErrorCode EPSCISSSetSizes_CISS(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)EPSCISSSetSizes_CISS1186,47539 #undef __FUNCT____FUNCT__1231,49630 #define __FUNCT__ __FUNCT__1232,49647 PetscErrorCode EPSCISSSetSizes(EPS eps,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)EPSCISSSetSizes1264,50728 #undef __FUNCT____FUNCT__1280,51415 #define __FUNCT__ __FUNCT__1281,51432 static PetscErrorCode EPSCISSGetSizes_CISS(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)EPSCISSGetSizes_CISS1282,51473 #undef __FUNCT____FUNCT__1296,51897 #define __FUNCT__ __FUNCT__1297,51914 PetscErrorCode EPSCISSGetSizes(EPS eps,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)EPSCISSGetSizes1318,52401 #undef __FUNCT____FUNCT__1328,52823 #define __FUNCT__ __FUNCT__1329,52840 static PetscErrorCode EPSCISSSetThreshold_CISS(EPS eps,PetscReal delta,PetscReal spur)EPSCISSSetThreshold_CISS1330,52885 #undef __FUNCT____FUNCT__1350,53539 #define __FUNCT__ __FUNCT__1351,53556 PetscErrorCode EPSCISSSetThreshold(EPS eps,PetscReal delta,PetscReal spur)EPSCISSSetThreshold1371,54078 #undef __FUNCT____FUNCT__1383,54483 #define __FUNCT__ __FUNCT__1384,54500 static PetscErrorCode EPSCISSGetThreshold_CISS(EPS eps,PetscReal *delta,PetscReal *spur)EPSCISSGetThreshold_CISS1385,54545 #undef __FUNCT____FUNCT__1395,54808 #define __FUNCT__ __FUNCT__1396,54825 PetscErrorCode EPSCISSGetThreshold(EPS eps,PetscReal *delta,PetscReal *spur)EPSCISSGetThreshold1414,55229 #undef __FUNCT____FUNCT__1424,55543 #define __FUNCT__ __FUNCT__1425,55560 static PetscErrorCode EPSCISSSetRefinement_CISS(EPS eps,PetscInt inner,PetscInt blsize)EPSCISSSetRefinement_CISS1426,55606 #undef __FUNCT____FUNCT__1446,56267 #define __FUNCT__ __FUNCT__1447,56284 PetscErrorCode EPSCISSSetRefinement(EPS eps,PetscInt inner,PetscInt blsize)EPSCISSSetRefinement1467,56876 #undef __FUNCT____FUNCT__1479,57283 #define __FUNCT__ __FUNCT__1480,57300 static PetscErrorCode EPSCISSGetRefinement_CISS(EPS eps,PetscInt *inner,PetscInt *blsize)EPSCISSGetRefinement_CISS1481,57346 #undef __FUNCT____FUNCT__1491,57619 #define __FUNCT__ __FUNCT__1492,57636 PetscErrorCode EPSCISSGetRefinement(EPS eps, PetscInt *inner, PetscInt *blsize)EPSCISSGetRefinement1510,58079 #undef __FUNCT____FUNCT__1520,58397 #define __FUNCT__ __FUNCT__1521,58414 static PetscErrorCode EPSCISSSetUseST_CISS(EPS eps,PetscBool usest)EPSCISSSetUseST_CISS1522,58455 #undef __FUNCT____FUNCT__1532,58674 #define __FUNCT__ __FUNCT__1533,58691 PetscErrorCode EPSCISSSetUseST(EPS eps,PetscBool usest)EPSCISSSetUseST1551,59146 #undef __FUNCT____FUNCT__1562,59466 #define __FUNCT__ __FUNCT__1563,59483 static PetscErrorCode EPSCISSGetUseST_CISS(EPS eps,PetscBool *usest)EPSCISSGetUseST_CISS1564,59524 #undef __FUNCT____FUNCT__1573,59710 #define __FUNCT__ __FUNCT__1574,59727 PetscErrorCode EPSCISSGetUseST(EPS eps,PetscBool *usest)EPSCISSGetUseST1591,60072 #undef __FUNCT____FUNCT__1602,60376 #define __FUNCT__ __FUNCT__1603,60393 static PetscErrorCode EPSCISSSetQuadRule_CISS(EPS eps,EPSCISSQuadRule quad)EPSCISSSetQuadRule_CISS1604,60437 #undef __FUNCT____FUNCT__1613,60627 #define __FUNCT__ __FUNCT__1614,60644 PetscErrorCode EPSCISSSetQuadRule(EPS eps,EPSCISSQuadRule quad)EPSCISSSetQuadRule1638,61319 #undef __FUNCT____FUNCT__1649,61654 #define __FUNCT__ __FUNCT__1650,61671 static PetscErrorCode EPSCISSGetQuadRule_CISS(EPS eps,EPSCISSQuadRule *quad)EPSCISSGetQuadRule_CISS1651,61715 #undef __FUNCT____FUNCT__1660,61907 #define __FUNCT__ __FUNCT__1661,61924 PetscErrorCode EPSCISSGetQuadRule(EPS eps, EPSCISSQuadRule *quad)EPSCISSGetQuadRule1677,62246 #undef __FUNCT____FUNCT__1688,62566 #define __FUNCT__ __FUNCT__1689,62583 static PetscErrorCode EPSCISSSetExtraction_CISS(EPS eps,EPSCISSExtraction extraction)EPSCISSSetExtraction_CISS1690,62629 #undef __FUNCT____FUNCT__1699,62841 #define __FUNCT__ __FUNCT__1700,62858 PetscErrorCode EPSCISSSetExtraction(EPS eps,EPSCISSExtraction extraction)EPSCISSSetExtraction1724,63570 #undef __FUNCT____FUNCT__1735,63931 #define __FUNCT__ __FUNCT__1736,63948 static PetscErrorCode EPSCISSGetExtraction_CISS(EPS eps,EPSCISSExtraction *extraction)EPSCISSGetExtraction_CISS1737,63994 #undef __FUNCT____FUNCT__1746,64208 #define __FUNCT__ __FUNCT__1747,64225 PetscErrorCode EPSCISSGetExtraction(EPS eps,EPSCISSExtraction *extraction)EPSCISSGetExtraction1763,64568 #undef __FUNCT____FUNCT__1775,64914 #define __FUNCT__ __FUNCT__1776,64931 PetscErrorCode EPSReset_CISS(EPS eps)EPSReset_CISS1777,64965 #undef __FUNCT____FUNCT__1809,66017 #define __FUNCT__ __FUNCT__1810,66034 PetscErrorCode EPSSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_CISS1811,66077 #undef __FUNCT____FUNCT__1856,68978 #define __FUNCT__ __FUNCT__1857,68995 PetscErrorCode EPSDestroy_CISS(EPS eps)EPSDestroy_CISS1858,69031 #undef __FUNCT____FUNCT__1879,70355 #define __FUNCT__ __FUNCT__1880,70372 PetscErrorCode EPSView_CISS(EPS eps,PetscViewer viewer)EPSView_CISS1881,70405 #undef __FUNCT____FUNCT__1909,71993 #define __FUNCT__ __FUNCT__1910,72010 PETSC_EXTERN PetscErrorCode EPSCreate_CISS(EPS eps)EPSCreate_CISS1911,72045 src/eps/impls/ciss/makefile,273 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = ciss.cSOURCEC26,958 SOURCEF =SOURCEF27,976 SOURCEH =SOURCEH28,987 LIBBASE = libslepcepsLIBBASE29,998 DIRS =DIRS30,1021 MANSEC = EPSMANSEC31,1032 LOCDIR = src/eps/impls/ciss/LOCDIR32,1047 src/eps/impls/davidson/davidson.c,3451 davidson.c:^?davidson.c^A,1 static PetscBool cited = PETSC_FALSE;cited26,1010 static const char citation[] =citation27,1049 #undef __FUNCT____FUNCT__39,1503 #define __FUNCT__ __FUNCT__40,1520 PetscErrorCode EPSSetUp_XD(EPS eps)EPSSetUp_XD41,1552 #undef __FUNCT____FUNCT__221,10217 #define __FUNCT__ __FUNCT__222,10234 PetscErrorCode EPSSolve_XD(EPS eps)EPSSolve_XD223,10266 #undef __FUNCT____FUNCT__263,11551 #define __FUNCT__ __FUNCT__264,11568 PetscErrorCode EPSReset_XD(EPS eps)EPSReset_XD265,11600 #undef __FUNCT____FUNCT__280,12102 #define __FUNCT__ __FUNCT__281,12119 PetscErrorCode EPSXDSetKrylovStart_XD(EPS eps,PetscBool krylovstart)EPSXDSetKrylovStart_XD282,12162 #undef __FUNCT____FUNCT__291,12369 #define __FUNCT__ __FUNCT__292,12386 PetscErrorCode EPSXDGetKrylovStart_XD(EPS eps,PetscBool *krylovstart)EPSXDGetKrylovStart_XD293,12429 #undef __FUNCT____FUNCT__302,12638 #define __FUNCT__ __FUNCT__303,12655 PetscErrorCode EPSXDSetBlockSize_XD(EPS eps,PetscInt blocksize)EPSXDSetBlockSize_XD304,12696 #undef __FUNCT____FUNCT__315,13089 #define __FUNCT__ __FUNCT__316,13106 PetscErrorCode EPSXDGetBlockSize_XD(EPS eps,PetscInt *blocksize)EPSXDGetBlockSize_XD317,13147 #undef __FUNCT____FUNCT__326,13347 #define __FUNCT__ __FUNCT__327,13364 PetscErrorCode EPSXDSetRestart_XD(EPS eps,PetscInt minv,PetscInt plusk)EPSXDSetRestart_XD328,13403 #undef __FUNCT____FUNCT__342,13966 #define __FUNCT__ __FUNCT__343,13983 PetscErrorCode EPSXDGetRestart_XD(EPS eps,PetscInt *minv,PetscInt *plusk)EPSXDGetRestart_XD344,14022 #undef __FUNCT____FUNCT__354,14266 #define __FUNCT__ __FUNCT__355,14283 PetscErrorCode EPSXDGetInitialSize_XD(EPS eps,PetscInt *initialsize)EPSXDGetInitialSize_XD356,14326 #undef __FUNCT____FUNCT__365,14534 #define __FUNCT__ __FUNCT__366,14551 PetscErrorCode EPSXDSetInitialSize_XD(EPS eps,PetscInt initialsize)EPSXDSetInitialSize_XD367,14594 #undef __FUNCT____FUNCT__378,15006 #define __FUNCT__ __FUNCT__379,15023 PetscErrorCode EPSXDGetFix_XD(EPS eps,PetscReal *fix)EPSXDGetFix_XD380,15058 #undef __FUNCT____FUNCT__389,15235 #define __FUNCT__ __FUNCT__390,15252 PetscErrorCode EPSJDSetFix_JD(EPS eps,PetscReal fix)EPSJDSetFix_JD391,15287 #undef __FUNCT____FUNCT__402,15631 #define __FUNCT__ __FUNCT__403,15648 PetscErrorCode EPSXDSetBOrth_XD(EPS eps,PetscBool borth)EPSXDSetBOrth_XD404,15685 #undef __FUNCT____FUNCT__413,15866 #define __FUNCT__ __FUNCT__414,15883 PetscErrorCode EPSXDGetBOrth_XD(EPS eps,PetscBool *borth)EPSXDGetBOrth_XD415,15920 #undef __FUNCT____FUNCT__424,16103 #define __FUNCT__ __FUNCT__425,16120 PetscErrorCode EPSJDSetConstCorrectionTol_JD(EPS eps,PetscBool constant)EPSJDSetConstCorrectionTol_JD426,16170 #undef __FUNCT____FUNCT__435,16384 #define __FUNCT__ __FUNCT__436,16401 PetscErrorCode EPSJDGetConstCorrectionTol_JD(EPS eps,PetscBool *constant)EPSJDGetConstCorrectionTol_JD437,16451 #undef __FUNCT____FUNCT__446,16667 #define __FUNCT__ __FUNCT__447,16684 PetscErrorCode EPSXDSetWindowSizes_XD(EPS eps,PetscInt pwindow,PetscInt qwindow)EPSXDSetWindowSizes_XD448,16727 #undef __FUNCT____FUNCT__462,17339 #define __FUNCT__ __FUNCT__463,17356 PetscErrorCode EPSXDGetWindowSizes_XD(EPS eps,PetscInt *pwindow,PetscInt *qwindow)EPSXDGetWindowSizes_XD464,17399 #undef __FUNCT____FUNCT__474,17673 #define __FUNCT__ __FUNCT__475,17690 PetscErrorCode EPSComputeVectors_XD(EPS eps)EPSComputeVectors_XD484,18103 src/eps/impls/davidson/davidson.h,9609 davidson.h:^?davidson.h^A,1 typedef PetscErrorCode (*dvdCallback)(struct _dvdDashboard*);dvdCallback32,1200 typedef struct _dvdFunctionList {_dvdFunctionList33,1262 dvdCallback f;f34,1296 struct _dvdFunctionList *next;next35,1313 } dvdFunctionList;dvdFunctionList36,1346 DVD_HARM_NONE,DVD_HARM_NONE39,1381 DVD_HARM_RR,DVD_HARM_RR40,1398 DVD_HARM_RRR,DVD_HARM_RRR41,1413 DVD_HARM_REIGS,DVD_HARM_REIGS42,1429 DVD_HARM_LEIGSDVD_HARM_LEIGS43,1447 } HarmType_t;HarmType_t44,1464 DVD_INITV_CLASSIC,DVD_INITV_CLASSIC47,1494 DVD_INITV_KRYLOVDVD_INITV_KRYLOV48,1515 } InitType_t;InitType_t49,1534 DVD_PROJ_KXX,DVD_PROJ_KXX52,1564 DVD_PROJ_KZXDVD_PROJ_KZX53,1580 } ProjType_t;ProjType_t54,1595 typedef struct _dvdDashboard {_dvdDashboard61,1708 PetscErrorCode (*initV)(struct _dvdDashboard*);initV64,1789 void *initV_data;initV_data65,1839 PetscErrorCode (*calcPairs)(struct _dvdDashboard*);calcPairs68,1907 void *calcPairs_data;calcPairs_data69,1961 PetscBool (*testConv)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscReal,PetscReal*);testConv72,2025 void *testConv_data;testConv_data73,2118 PetscErrorCode (*improveX)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt*);improveX76,2182 void *improveX_data;improveX_data77,2263 PetscErrorCode (*isRestarting)(struct _dvdDashboard*,PetscBool*);isRestarting80,2316 void *isRestarting_data;isRestarting_data81,2384 PetscErrorCode (*restartV)(struct _dvdDashboard*);restartV84,2439 void *restartV_data;restartV_data85,2492 PetscErrorCode (*updateV)(struct _dvdDashboard*);updateV88,2533 void *updateV_data;updateV_data89,2585 Mat A,B; /* problem matrices */A92,2644 Mat A,B; /* problem matrices */B92,2644 MatType_t sA,sB; /* matrix specifications */sA93,2697 MatType_t sA,sB; /* matrix specifications */sB93,2697 EPType_t sEP; /* problem specifications */sEP94,2755 PetscInt nev; /* number of eigenpairs */nev95,2814 EPSWhich which; /* spectrum selection */which96,2871 PetscBool withTarget; /* if there is a target */withTarget97,2926 PetscScalar target[2]; /* target value */target98,2983 PetscReal tol; /* tolerance */tol99,3032 PetscBool correctXnorm; /* if true, norm of X are computed */correctXnorm100,3078 PetscInt nconv; /* number of converged eigenpairs */nconv103,3185 PetscInt npreconv; /* number of pairs ready to converge */npreconv104,3252 BV W; /* left basis for harmonic case */W106,3323 BV AX; /* A*V */AX107,3388 BV BX; /* B*V */BX108,3428 PetscInt size_D; /* active vectors */size_D109,3468 PetscInt max_size_proj; /* max size projected problem */max_size_proj110,3519 PetscInt max_cX_in_proj; /* max vectors from cX in the projected problem */max_cX_in_proj111,3582 PetscInt max_cX_in_impr; /* max vectros from cX in the projector */max_cX_in_impr112,3663 PetscInt max_size_P; /* max unconverged vectors in the projector */max_size_P113,3736 PetscInt bs; /* max vectors that expands the subspace every iteration */bs114,3813 EPS eps; /* connection to SLEPc */eps115,3903 VecPool auxV; /* auxiliary vectors */auxV118,3990 BV auxBV; /* auxiliary vectors */auxBV119,4044 PetscScalar *ceigr,*ceigi; /* converged eigenvalues */ceigr122,4136 PetscScalar *ceigr,*ceigi; /* converged eigenvalues */ceigi122,4136 PetscScalar *eigr,*eigi; /* current eigenvalues */eigr123,4194 PetscScalar *eigr,*eigi; /* current eigenvalues */eigi123,4194 PetscReal *nR; /* residual norm */nR124,4250 PetscReal *real_nR; /* original nR */real_nR125,4300 PetscReal *nX; /* X norm */nX126,4348 PetscReal *real_nX; /* original nX */real_nX127,4391 PetscReal *errest; /* relative error eigenpairs */errest128,4439 PetscReal *nBds; /* B-norms of projected problem */nBds129,4501 PetscErrorCode (*e_Vchanged)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt);e_Vchanged132,4612 void *e_Vchanged_data;e_Vchanged_data133,4703 PetscErrorCode (*calcpairs_residual)(struct _dvdDashboard*,PetscInt,PetscInt);calcpairs_residual134,4728 PetscErrorCode (*calcpairs_selectPairs)(struct _dvdDashboard*,PetscInt);calcpairs_selectPairs135,4809 void *calcpairs_residual_data;calcpairs_residual_data136,4884 PetscErrorCode (*improvex_precond)(struct _dvdDashboard*,PetscInt,Vec,Vec);improvex_precond137,4917 void *improvex_precond_data;improvex_precond_data138,4995 PetscErrorCode (*improvex_jd_proj_uv)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*,Vec*,Vec*,PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt);improvex_jd_proj_uv139,5026 PetscErrorCode (*improvex_jd_lit)(struct _dvdDashboard*,PetscInt,PetscScalar*,PetscScalar*,PetscInt*,PetscReal*);improvex_jd_lit140,5184 PetscErrorCode (*calcpairs_W)(struct _dvdDashboard*);calcpairs_W141,5300 void *calcpairs_W_data;calcpairs_W_data142,5356 PetscErrorCode (*calcpairs_proj_trans)(struct _dvdDashboard*);calcpairs_proj_trans143,5382 PetscErrorCode (*calcpairs_eigs_trans)(struct _dvdDashboard*);calcpairs_eigs_trans144,5447 PetscErrorCode (*calcpairs_eig_backtrans)(struct _dvdDashboard*,PetscScalar,PetscScalar,PetscScalar*,PetscScalar*);calcpairs_eig_backtrans145,5512 PetscErrorCode (*calcpairs_proj_res)(struct _dvdDashboard*,PetscInt,PetscInt,Vec*);calcpairs_proj_res146,5630 PetscErrorCode (*preTestConv)(struct _dvdDashboard*,PetscInt,PetscInt,PetscInt,PetscInt*);preTestConv147,5716 PetscErrorCode (*e_newIteration)(struct _dvdDashboard*);e_newIteration148,5809 void *e_newIteration_data;e_newIteration_data149,5868 dvdFunctionList *startList; /* starting list */startList151,5898 dvdFunctionList *endList; /* ending list */endList152,5949 dvdFunctionList *destroyList;/* destructor list */destroyList153,5998 Mat H,G; /* projected problem matrices */H155,6052 Mat H,G; /* projected problem matrices */G155,6052 Mat auxM; /* auxiliary dense matrix */auxM156,6116 PetscInt size_MT; /* rows in MT */size_MT157,6176 PetscInt V_tra_s;V_tra_s159,6225 PetscInt V_tra_e; /* cX <- [cX V*MT(0:V_tra_s-1)], V <- V*MT(V_tra_s:V_tra_e) */V_tra_e160,6246 PetscInt V_new_s;V_new_s161,6336 PetscInt V_new_e; /* added to V the columns V_new_s:V_new_e */V_new_e162,6357 PetscBool BV_shift; /* if true BV is shifted when vectors converge */BV_shift163,6433 PetscBool W_shift; /* if true W is shifted when vectors converge */W_shift164,6514 } dvdDashboard;dvdDashboard165,6594 PetscInt blocksize; /* block size */blocksize169,6704 PetscInt initialsize; /* initial size of V */initialsize170,6748 PetscInt minv; /* size of V after restarting */minv171,6799 PetscInt plusk; /* keep plusk eigenvectors from the last iteration */plusk172,6859 PetscBool ipB; /* true if B-ortho is used */ipB173,6940 PetscReal fix; /* the fix parameter */fix174,6997 PetscBool krylovstart; /* true if the starting subspace is a Krylov basis */krylovstart175,7048 PetscBool dynamic; /* true if dynamic stopping criterion is used */dynamic176,7129 PetscInt cX_in_proj; /* converged vectors in the projected problem */cX_in_proj177,7205 PetscInt cX_in_impr; /* converged vectors in the projector */cX_in_impr178,7281 PetscBool doubleexp; /* double expansion in GD (GD2) */doubleexp179,7349 dvdDashboard ddb;ddb182,7487 } EPS_DAVIDSON;EPS_DAVIDSON183,7507 #undef __FUNCT____FUNCT__185,7524 #define __FUNCT__ __FUNCT__186,7541 PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLAdd(dvdFunctionList **fl,dvdCallback f)EPSDavidsonFLAdd187,7578 #undef __FUNCT____FUNCT__200,7844 #define __FUNCT__ __FUNCT__201,7861 PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLCall(dvdFunctionList *fl,dvdDashboard *d)EPSDavidsonFLCall202,7899 #undef __FUNCT____FUNCT__212,8149 #define __FUNCT__ __FUNCT__213,8166 PETSC_STATIC_INLINE PetscErrorCode EPSDavidsonFLDestroy(dvdFunctionList **fl)EPSDavidsonFLDestroy214,8207 PetscInt max_size_V; /* max size of the searching subspace (mpd) */max_size_V247,9194 PetscInt max_size_X; /* max size of X (bs) */max_size_X248,9272 PetscInt size_V; /* real size of V (nev+size_P+mpd) */size_V249,9328 PetscInt max_size_oldX; /* max size of oldX */max_size_oldX250,9397 PetscInt max_nev; /* max number of converged pairs */max_nev251,9451 PetscInt max_size_P; /* number of computed vectors for the projector */max_size_P252,9518 PetscInt max_size_cP; /* number of converged vectors in the projectors */max_size_cP253,9600 PetscInt max_size_proj; /* max size projected problem */max_size_proj254,9683 PetscInt max_size_cX_proj; /* max converged vectors in the projected problem */max_size_cX_proj255,9747 PetscInt state; /* method states:state256,9831 } dvdBlackboard;dvdBlackboard260,10032 #define DVD_STATE_PRECONF DVD_STATE_PRECONF262,10050 #define DVD_STATE_CONF DVD_STATE_CONF263,10078 #define DVD_STATE_RUN DVD_STATE_RUN264,10103 src/eps/impls/davidson/dvdcalcpairs.c,2445 dvdcalcpairs.c:^?dvdcalcpairs.c^A,1 #undef __FUNCT____FUNCT__36,1259 #define __FUNCT__ __FUNCT__37,1276 static PetscErrorCode dvd_calcpairs_qz_start(dvdDashboard *d)dvd_calcpairs_qz_start38,1319 #undef __FUNCT____FUNCT__50,1706 #define __FUNCT__ __FUNCT__51,1723 static PetscErrorCode dvd_calcpairs_qz_d(dvdDashboard *d)dvd_calcpairs_qz_d52,1762 #undef __FUNCT____FUNCT__70,2368 #define __FUNCT__ __FUNCT__71,2385 static PetscErrorCode dvd_calcpairs_projeig_solve(dvdDashboard *d)dvd_calcpairs_projeig_solve72,2433 #undef __FUNCT____FUNCT__108,3834 #define __FUNCT__ __FUNCT__109,3851 static PetscErrorCode EPSXDUpdateProj(Mat Q,Mat Z,PetscInt l,Mat A,PetscInt lA,PetscInt kA,Mat aux)EPSXDUpdateProj113,3970 #undef __FUNCT____FUNCT__167,6512 #define __FUNCT__ __FUNCT__168,6529 static PetscErrorCode dvd_calcpairs_updateproj(dvdDashboard *d)dvd_calcpairs_updateproj169,6574 #undef __FUNCT____FUNCT__215,8743 #define __FUNCT__ __FUNCT__216,8760 PETSC_STATIC_INLINE PetscErrorCode dvd_calcpairs_updateBV0_gen(dvdDashboard *d,BV bv,DSMatType mat)dvd_calcpairs_updateBV0_gen220,8830 #undef __FUNCT____FUNCT__238,9563 #define __FUNCT__ __FUNCT__239,9580 static PetscErrorCode dvd_calcpairs_proj(dvdDashboard *d)dvd_calcpairs_proj240,9619 #undef __FUNCT____FUNCT__332,13678 #define __FUNCT__ __FUNCT__333,13695 static PetscErrorCode dvd_calcpairs_apply_arbitrary(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscScalar *rr,PetscScalar *ri)dvd_calcpairs_apply_arbitrary334,13745 #undef __FUNCT____FUNCT__397,15702 #define __FUNCT__ __FUNCT__398,15719 static PetscErrorCode dvd_calcpairs_selectPairs(dvdDashboard *d,PetscInt n)dvd_calcpairs_selectPairs399,15765 #undef __FUNCT____FUNCT__442,17099 #define __FUNCT__ __FUNCT__443,17116 static PetscErrorCode EPSXDComputeDSConv(dvdDashboard *d)EPSXDComputeDSConv444,17155 #undef __FUNCT____FUNCT__485,18928 #define __FUNCT__ __FUNCT__486,18945 static PetscErrorCode dvd_calcpairs_res_0(dvdDashboard *d,PetscInt r_s,PetscInt r_e)dvd_calcpairs_res_0491,19126 #undef __FUNCT____FUNCT__517,20137 #define __FUNCT__ __FUNCT__518,20154 static PetscErrorCode dvd_calcpairs_proj_res(dvdDashboard *d,PetscInt r_s,PetscInt r_e,Vec *R)dvd_calcpairs_proj_res519,20197 #undef __FUNCT____FUNCT__552,21465 #define __FUNCT__ __FUNCT__553,21482 PetscErrorCode dvd_calcpairs_qz(dvdDashboard *d,dvdBlackboard *b,PetscBool borth,PetscInt cX_proj,PetscBool harm)dvd_calcpairs_qz554,21519 src/eps/impls/davidson/dvdgd2.c,628 dvdgd2.c:^?dvdgd2.c^A,1 PetscInt size_X;size_X29,1042 } dvdImprovex_gd2;dvdImprovex_gd230,1061 #undef __FUNCT____FUNCT__32,1081 #define __FUNCT__ __FUNCT__33,1098 static PetscErrorCode dvd_improvex_gd2_d(dvdDashboard *d)dvd_improvex_gd2_d34,1137 #undef __FUNCT____FUNCT__45,1411 #define __FUNCT__ __FUNCT__46,1428 static PetscErrorCode dvd_improvex_gd2_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D)dvd_improvex_gd2_gen47,1469 #undef __FUNCT____FUNCT__215,7321 #define __FUNCT__ __FUNCT__216,7338 PetscErrorCode dvd_improvex_gd2(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs)dvd_improvex_gd2217,7375 src/eps/impls/davidson/dvdimprovex.c,7186 dvdimprovex.c:^?dvdimprovex.c^A,1 PetscInt size_X;size_X32,1160 KSP ksp; /* correction equation solver */ksp33,1183 Vec friends; /* reference vector for composite vectors */friends34,1251 PetscScalar theta[4],thetai[2]; /* the shifts used in the correction eq. */theta35,1331 PetscScalar theta[4],thetai[2]; /* the shifts used in the correction eq. */thetai35,1331 PetscInt maxits; /* maximum number of iterations */maxits36,1410 PetscInt r_s,r_e; /* the selected eigenpairs to improve */r_s37,1480 PetscInt r_s,r_e; /* the selected eigenpairs to improve */r_e37,1480 PetscInt ksp_max_size; /* the ksp maximum subvectors size */ksp_max_size38,1556 PetscReal tol; /* the maximum solution tolerance */tol39,1629 PetscReal lastTol; /* last tol for dynamic stopping criterion */lastTol40,1701 PetscReal fix; /* tolerance for using the approx. eigenvalue */fix41,1782 PetscBool dynamic; /* if the dynamic stopping criterion is applied */dynamic42,1866 dvdDashboard *d; /* the currect dvdDashboard reference */d43,1952 PC old_pc; /* old pc in ksp */old_pc44,2028 BV KZ; /* KZ vecs for the projector KZ*inv(X'*KZ)*X' */KZ45,2083 BV U; /* new X vectors */U46,2167 PetscScalar *XKZ; /* X'*KZ */XKZ47,2222 PetscScalar *iXKZ; /* inverse of XKZ */iXKZ48,2269 PetscInt ldXKZ; /* leading dimension of XKZ */ldXKZ49,2325 PetscInt size_iXKZ; /* size of iXKZ */size_iXKZ50,2391 PetscInt ldiXKZ; /* leading dimension of iXKZ */ldiXKZ51,2445 PetscInt size_cX; /* last value of d->size_cX */size_cX52,2512 PetscInt old_size_X; /* last number of improved vectors */old_size_X53,2578 PetscBLASInt *iXKZPivots; /* array of pivots */iXKZPivots54,2651 } dvdImprovex_jd;dvdImprovex_jd55,2708 #undef __FUNCT____FUNCT__57,2727 #define __FUNCT__ __FUNCT__58,2744 static PetscErrorCode dvd_improvex_apply_proj(dvdDashboard *d,Vec *V,PetscInt cV)dvd_improvex_apply_proj64,2908 #undef __FUNCT____FUNCT__117,4804 #define __FUNCT__ __FUNCT__118,4821 static PetscErrorCode dvd_improvex_applytrans_proj(dvdDashboard *d,Vec *V,PetscInt cV)dvd_improvex_applytrans_proj124,4990 #undef __FUNCT____FUNCT__178,6918 #define __FUNCT__ __FUNCT__179,6935 static PetscErrorCode dvd_improvex_jd_end(dvdDashboard *d)dvd_improvex_jd_end180,6975 #undef __FUNCT____FUNCT__196,7413 #define __FUNCT__ __FUNCT__197,7430 static PetscErrorCode dvd_improvex_jd_d(dvdDashboard *d)dvd_improvex_jd_d198,7468 #undef __FUNCT____FUNCT__214,7970 #define __FUNCT__ __FUNCT__215,7987 PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmult(dvdImprovex_jd *data,const Vec *x,const Vec *y)dvd_aux_matmult220,8096 #undef __FUNCT____FUNCT__262,9502 #define __FUNCT__ __FUNCT__263,9519 PETSC_STATIC_INLINE PetscErrorCode dvd_aux_matmulttrans(dvdImprovex_jd *data,const Vec *x,const Vec *y)dvd_aux_matmulttrans267,9607 #undef __FUNCT____FUNCT__309,11076 #define __FUNCT__ __FUNCT__310,11093 static PetscErrorCode PCApplyBA_dvd(PC pc,PCSide side,Vec in,Vec out,Vec w)PCApplyBA_dvd311,11127 #undef __FUNCT____FUNCT__370,13012 #define __FUNCT__ __FUNCT__371,13029 static PetscErrorCode PCApply_dvd(PC pc,Vec in,Vec out)PCApply_dvd372,13061 #undef __FUNCT____FUNCT__395,13782 #define __FUNCT__ __FUNCT__396,13799 static PetscErrorCode PCApplyTranspose_dvd(PC pc,Vec in,Vec out)PCApplyTranspose_dvd397,13840 #undef __FUNCT____FUNCT__427,14816 #define __FUNCT__ __FUNCT__428,14833 static PetscErrorCode MatMult_dvd_jd(Mat A,Vec in,Vec out)MatMult_dvd_jd429,14868 #undef __FUNCT____FUNCT__452,15593 #define __FUNCT__ __FUNCT__453,15610 static PetscErrorCode MatMultTranspose_dvd_jd(Mat A,Vec in,Vec out)MatMultTranspose_dvd_jd454,15654 #undef __FUNCT____FUNCT__487,16722 #define __FUNCT__ __FUNCT__488,16739 static PetscErrorCode MatCreateVecs_dvd_jd(Mat A,Vec *right,Vec *left)MatCreateVecs_dvd_jd489,16780 #undef __FUNCT____FUNCT__530,17772 #define __FUNCT__ __FUNCT__531,17789 static PetscErrorCode dvd_improvex_jd_start(dvdDashboard *d)dvd_improvex_jd_start532,17831 #undef __FUNCT____FUNCT__603,20907 #define __FUNCT__ __FUNCT__604,20924 static PetscErrorCode dvd_improvex_jd_proj_cuv(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)dvd_improvex_jd_proj_cuv612,21221 #undef __FUNCT____FUNCT__694,24707 #define __FUNCT__ __FUNCT__695,24724 static PetscErrorCode dvd_improvex_jd_gen(dvdDashboard *d,PetscInt r_s,PetscInt r_e,PetscInt *size_D)dvd_improvex_jd_gen696,24764 #undef __FUNCT____FUNCT__825,29880 #define __FUNCT__ __FUNCT__826,29897 PetscErrorCode dvd_improvex_jd(dvdDashboard *d,dvdBlackboard *b,KSP ksp,PetscInt max_bs,PetscInt cX_impr,PetscBool dynamic)dvd_improvex_jd827,29933 #undef __FUNCT____FUNCT__893,32171 #define __FUNCT__ __FUNCT__894,32188 PETSC_STATIC_INLINE PetscErrorCode dvd_complex_rayleigh_quotient(Vec ur,Vec ui,Vec Axr,Vec Axi,Vec Bxr,Vec Bxi,PetscScalar *eigr,PetscScalar *eigi)dvd_complex_rayleigh_quotient895,32238 #undef __FUNCT____FUNCT__931,33911 #define __FUNCT__ __FUNCT__932,33928 PETSC_STATIC_INLINE PetscErrorCode dvd_compute_n_rr(PetscInt i_s,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,Vec *u,Vec *Ax,Vec *Bx)dvd_compute_n_rr933,33965 #undef __FUNCT____FUNCT__965,35433 #define __FUNCT__ __FUNCT__966,35450 static PetscErrorCode dvd_improvex_jd_proj_uv_KZX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)dvd_improvex_jd_proj_uv_KZX974,35750 #undef __FUNCT____FUNCT__1084,39636 #define __FUNCT__ __FUNCT__1085,39653 static PetscErrorCode dvd_improvex_jd_proj_uv_KXX(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u,Vec *v,Vec *kr,PetscScalar *theta,PetscScalar *thetai,PetscScalar *pX,PetscScalar *pY,PetscInt ld)dvd_improvex_jd_proj_uv_KXX1093,39911 #undef __FUNCT____FUNCT__1174,42660 #define __FUNCT__ __FUNCT__1175,42677 static PetscErrorCode dvd_improvex_jd_lit_const_0(dvdDashboard *d,PetscInt i,PetscScalar* theta,PetscScalar* thetai,PetscInt *maxits,PetscReal *tol)dvd_improvex_jd_lit_const_01176,42725 #undef __FUNCT____FUNCT__1206,43445 #define __FUNCT__ __FUNCT__1207,43462 PetscErrorCode dvd_improvex_jd_lit_const(dvdDashboard *d,dvdBlackboard *b,PetscInt maxits,PetscReal tol,PetscReal fix)dvd_improvex_jd_lit_const1208,43508 #undef __FUNCT____FUNCT__1223,43928 #define __FUNCT__ __FUNCT__1224,43945 PetscErrorCode dvd_improvex_jd_proj_uv(dvdDashboard *d,dvdBlackboard *b,ProjType_t p)dvd_improvex_jd_proj_uv1225,43989 #undef __FUNCT____FUNCT__1242,44406 #define __FUNCT__ __FUNCT__1243,44423 PetscErrorCode dvd_improvex_compute_X(dvdDashboard *d,PetscInt i_s,PetscInt i_e,Vec *u_,PetscScalar *pX,PetscInt ld)dvd_improvex_compute_X1244,44466 src/eps/impls/davidson/dvdinitv.c,1076 dvdinitv.c:^?dvdinitv.c^A,1 PetscInt k; /* desired initial subspace size */k29,1022 PetscInt user; /* number of user initial vectors */user30,1088 void *old_initV_data; /* old initV data */old_initV_data31,1155 } dvdInitV;dvdInitV32,1206 #undef __FUNCT____FUNCT__34,1219 #define __FUNCT__ __FUNCT__35,1236 static PetscErrorCode dvd_initV_classic_0(dvdDashboard *d)dvd_initV_classic_036,1276 #undef __FUNCT____FUNCT__58,2095 #define __FUNCT__ __FUNCT__59,2112 static PetscErrorCode dvd_initV_krylov_0(dvdDashboard *d)dvd_initV_krylov_060,2151 #undef __FUNCT____FUNCT__108,3995 #define __FUNCT__ __FUNCT__109,4012 static PetscErrorCode dvd_initV_d(dvdDashboard *d)dvd_initV_d110,4044 #undef __FUNCT____FUNCT__124,4368 #define __FUNCT__ __FUNCT__125,4385 PetscErrorCode dvd_initV(dvdDashboard *d, dvdBlackboard *b, PetscInt k,PetscInt user, PetscBool krylov)dvd_initV126,4415 #undef __FUNCT____FUNCT__149,5091 #define __FUNCT__ __FUNCT__150,5108 PetscErrorCode dvd_orthV(BV V,PetscInt V_new_s,PetscInt V_new_e)dvd_orthV151,5138 src/eps/impls/davidson/dvdschm.c,926 dvdschm.c:^?dvdschm.c^A,1 #define DVD_CHECKSUM(DVD_CHECKSUM24,947 #undef __FUNCT____FUNCT__26,1011 #define __FUNCT__ __FUNCT__27,1028 PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,KSP ksp,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool doubleexp)dvd_schm_basic_preconf28,1071 #undef __FUNCT____FUNCT__66,2822 #define __FUNCT__ __FUNCT__67,2839 PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d,dvdBlackboard *b,PetscInt mpd,PetscInt min_size_V,PetscInt bs,PetscInt ini_size_V,PetscInt size_initV,PetscInt plusk,HarmType_t harmMode,PetscBool fixedTarget,PetscScalar t,KSP ksp,PetscReal fix,InitType_t init,PetscBool allResiduals,PetscBool orth,PetscInt cX_proj,PetscInt cX_impr,PetscBool dynamic,PetscBool doubleexp)dvd_schm_basic_conf68,2879 src/eps/impls/davidson/dvdtestconv.c,774 dvdtestconv.c:^?dvdtestconv.c^A,1 #undef __FUNCT____FUNCT__28,1010 #define __FUNCT__ __FUNCT__29,1027 static PetscBool dvd_testconv_basic_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err)dvd_testconv_basic_030,1068 #undef __FUNCT____FUNCT__43,1422 #define __FUNCT__ __FUNCT__44,1439 PetscErrorCode dvd_testconv_basic(dvdDashboard *d, dvdBlackboard *b)dvd_testconv_basic45,1478 #undef __FUNCT____FUNCT__58,1781 #define __FUNCT__ __FUNCT__59,1798 static PetscBool dvd_testconv_slepc_0(dvdDashboard *d,PetscScalar eigvr,PetscScalar eigvi,PetscReal r,PetscReal *err)dvd_testconv_slepc_060,1839 #undef __FUNCT____FUNCT__69,2193 #define __FUNCT__ __FUNCT__70,2210 PetscErrorCode dvd_testconv_slepc(dvdDashboard *d, dvdBlackboard *b)dvd_testconv_slepc71,2249 src/eps/impls/davidson/dvdupdatev.c,2577 dvdupdatev.c:^?dvdupdatev.c^A,1 PetscInt min_size_V; /* restart with this number of eigenvectors */min_size_V29,1045 PetscInt plusk; /* at restart, save plusk vectors from last iteration */plusk30,1131 PetscInt mpd; /* max size of the searching subspace */mpd31,1227 void *old_updateV_data; /* old updateV data */old_updateV_data32,1307 PetscErrorCode (*old_isRestarting)(dvdDashboard*,PetscBool*); /* old isRestarting */old_isRestarting33,1369 Mat oldU; /* previous projected right igenvectors */oldU34,1460 Mat oldV; /* previous projected left eigenvectors */oldV35,1542 PetscInt size_oldU; /* size of oldU */size_oldU36,1624 PetscBool allResiduals; /* if computing all the residuals */allResiduals37,1682 } dvdManagV_basic;dvdManagV_basic38,1758 #undef __FUNCT____FUNCT__40,1778 #define __FUNCT__ __FUNCT__41,1795 static PetscErrorCode dvd_updateV_start(dvdDashboard *d)dvd_updateV_start42,1833 #undef __FUNCT____FUNCT__61,2368 #define __FUNCT__ __FUNCT__62,2385 static PetscErrorCode dvd_isrestarting_fullV(dvdDashboard *d,PetscBool *r)dvd_isrestarting_fullV63,2428 #undef __FUNCT____FUNCT__82,2976 #define __FUNCT__ __FUNCT__83,2993 static PetscErrorCode dvd_managementV_basic_d(dvdDashboard *d)dvd_managementV_basic_d84,3037 #undef __FUNCT____FUNCT__102,3616 #define __FUNCT__ __FUNCT__103,3633 static PetscErrorCode dvd_updateV_conv_gen(dvdDashboard *d)dvd_updateV_conv_gen104,3674 #undef __FUNCT____FUNCT__167,5854 #define __FUNCT__ __FUNCT__168,5871 static PetscErrorCode dvd_updateV_restart_gen(dvdDashboard *d)dvd_updateV_restart_gen169,5915 #undef __FUNCT____FUNCT__223,8192 #define __FUNCT__ __FUNCT__224,8209 static PetscErrorCode dvd_updateV_testConv(dvdDashboard *d,PetscInt s,PetscInt pre,PetscInt e,PetscInt *nConv)dvd_updateV_testConv225,8250 #undef __FUNCT____FUNCT__265,9408 #define __FUNCT__ __FUNCT__266,9425 static PetscErrorCode dvd_updateV_update_gen(dvdDashboard *d)dvd_updateV_update_gen267,9468 #undef __FUNCT____FUNCT__314,10945 #define __FUNCT__ __FUNCT__315,10962 static PetscErrorCode dvd_updateV_extrapol(dvdDashboard *d)dvd_updateV_extrapol316,11003 #undef __FUNCT____FUNCT__351,12007 #define __FUNCT__ __FUNCT__352,12024 PetscErrorCode dvd_managementV_basic(dvdDashboard *d,dvdBlackboard *b,PetscInt bs,PetscInt mpd,PetscInt min_size_V,PetscInt plusk,PetscBool harm,PetscBool allResiduals)dvd_managementV_basic353,12066 src/eps/impls/davidson/dvdutils.c,3427 dvdutils.c:^?dvdutils.c^A,1 PC pc;pc29,1011 } dvdPCWrapper;dvdPCWrapper30,1020 PetscScalar Wa,Wb; /* span{W} = span{Wa*AV - Wb*BV} */Wa44,1363 PetscScalar Wa,Wb; /* span{W} = span{Wa*AV - Wb*BV} */Wb44,1363 PetscScalar Pa,Pb; /* H=W'*(Pa*AV - Pb*BV), G=W'*(Wa*AV - Wb*BV) */Pa45,1426 PetscScalar Pa,Pb; /* H=W'*(Pa*AV - Pb*BV), G=W'*(Wa*AV - Wb*BV) */Pb45,1426 PetscBool withTarget;withTarget46,1502 HarmType_t mode;mode47,1528 } dvdHarmonic;dvdHarmonic48,1548 Vec diagA, diagB;diagA51,1581 Vec diagA, diagB;diagB51,1581 } dvdJacobiPrecond;dvdJacobiPrecond52,1601 #undef __FUNCT____FUNCT__54,1622 #define __FUNCT__ __FUNCT__55,1639 static PetscErrorCode dvd_improvex_precond_d(dvdDashboard *d)dvd_improvex_precond_d56,1682 #undef __FUNCT____FUNCT__68,2037 #define __FUNCT__ __FUNCT__69,2054 static PetscErrorCode dvd_static_precond_PC_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px)dvd_static_precond_PC_070,2098 #undef __FUNCT____FUNCT__80,2377 #define __FUNCT__ __FUNCT__81,2394 static PetscErrorCode dvd_precond_none(dvdDashboard *d,PetscInt i,Vec x,Vec Px)dvd_precond_none85,2471 #undef __FUNCT____FUNCT__94,2666 #define __FUNCT__ __FUNCT__95,2683 PetscErrorCode dvd_static_precond_PC(dvdDashboard *d,dvdBlackboard *b,PC pc)dvd_static_precond_PC99,2774 #undef __FUNCT____FUNCT__143,4409 #define __FUNCT__ __FUNCT__144,4426 static PetscErrorCode dvd_jacobi_precond_0(dvdDashboard *d,PetscInt i,Vec x,Vec Px)dvd_jacobi_precond_0145,4467 #undef __FUNCT____FUNCT__166,5091 #define __FUNCT__ __FUNCT__167,5108 static PetscErrorCode dvd_jacobi_precond_d(dvdDashboard *d)dvd_jacobi_precond_d168,5149 #undef __FUNCT____FUNCT__180,5565 #define __FUNCT__ __FUNCT__181,5582 PetscErrorCode dvd_jacobi_precond(dvdDashboard *d,dvdBlackboard *b)dvd_jacobi_precond185,5692 #undef __FUNCT____FUNCT__222,6865 #define __FUNCT__ __FUNCT__223,6882 static PetscErrorCode dvd_harm_d(dvdDashboard *d)dvd_harm_d224,6913 #undef __FUNCT____FUNCT__234,7119 #define __FUNCT__ __FUNCT__235,7136 static PetscErrorCode dvd_harm_transf(dvdHarmonic *dvdh,PetscScalar t)dvd_harm_transf236,7172 #undef __FUNCT____FUNCT__267,8159 #define __FUNCT__ __FUNCT__268,8176 static PetscErrorCode dvd_harm_updateW(dvdDashboard *d)dvd_harm_updateW269,8213 #undef __FUNCT____FUNCT__297,9311 #define __FUNCT__ __FUNCT__298,9328 static PetscErrorCode dvd_harm_proj(dvdDashboard *d)dvd_harm_proj299,9362 #undef __FUNCT____FUNCT__337,10428 #define __FUNCT__ __FUNCT__338,10445 PetscErrorCode dvd_harm_updateproj(dvdDashboard *d)dvd_harm_updateproj339,10485 #undef __FUNCT____FUNCT__376,11532 #define __FUNCT__ __FUNCT__377,11549 static PetscErrorCode dvd_harm_backtrans(dvdHarmonic *data,PetscScalar *ar,PetscScalar *ai)dvd_harm_backtrans378,11588 #undef __FUNCT____FUNCT__402,12276 #define __FUNCT__ __FUNCT__403,12293 static PetscErrorCode dvd_harm_eig_backtrans(dvdDashboard *d,PetscScalar ar,PetscScalar ai,PetscScalar *br,PetscScalar *bi)dvd_harm_eig_backtrans404,12336 #undef __FUNCT____FUNCT__416,12678 #define __FUNCT__ __FUNCT__417,12695 static PetscErrorCode dvd_harm_eigs_trans(dvdDashboard *d)dvd_harm_eigs_trans418,12735 #undef __FUNCT____FUNCT__432,13118 #define __FUNCT__ __FUNCT__433,13135 PetscErrorCode dvd_harm_conf(dvdDashboard *d,dvdBlackboard *b,HarmType_t mode,PetscBool fixedTarget,PetscScalar t)dvd_harm_conf434,13169 src/eps/impls/davidson/gd/gd.c,3522 gd.c:^?gd.c^A,1 #undef __FUNCT____FUNCT__44,1538 #define __FUNCT__ __FUNCT__45,1555 PetscErrorCode EPSSetFromOptions_GD(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_GD46,1596 #undef __FUNCT____FUNCT__106,4822 #define __FUNCT__ __FUNCT__107,4839 PetscErrorCode EPSSetUp_GD(EPS eps)EPSSetUp_GD108,4871 #undef __FUNCT____FUNCT__130,5506 #define __FUNCT__ __FUNCT__131,5523 PetscErrorCode EPSView_GD(EPS eps,PetscViewer viewer)EPSView_GD132,5554 #undef __FUNCT____FUNCT__167,7135 #define __FUNCT__ __FUNCT__168,7152 PetscErrorCode EPSDestroy_GD(EPS eps)EPSDestroy_GD169,7186 #undef __FUNCT____FUNCT__192,8703 #define __FUNCT__ __FUNCT__193,8720 PetscErrorCode EPSGDSetKrylovStart(EPS eps,PetscBool krylovstart)EPSGDSetKrylovStart212,9170 #undef __FUNCT____FUNCT__223,9516 #define __FUNCT__ __FUNCT__224,9533 PetscErrorCode EPSGDGetKrylovStart(EPS eps,PetscBool *krylovstart)EPSGDGetKrylovStart242,9945 #undef __FUNCT____FUNCT__253,10275 #define __FUNCT__ __FUNCT__254,10292 PetscErrorCode EPSGDSetBlockSize(EPS eps,PetscInt blocksize)EPSGDSetBlockSize272,10784 #undef __FUNCT____FUNCT__283,11117 #define __FUNCT__ __FUNCT__284,11134 PetscErrorCode EPSGDGetBlockSize(EPS eps,PetscInt *blocksize)EPSGDGetBlockSize301,11523 #undef __FUNCT____FUNCT__312,11844 #define __FUNCT__ __FUNCT__313,11861 PetscErrorCode EPSGDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)EPSGDGetRestart331,12343 #undef __FUNCT____FUNCT__341,12645 #define __FUNCT__ __FUNCT__342,12662 PetscErrorCode EPSGDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)EPSGDSetRestart362,13313 #undef __FUNCT____FUNCT__374,13704 #define __FUNCT__ __FUNCT__375,13721 PetscErrorCode EPSGDGetInitialSize(EPS eps,PetscInt *initialsize)EPSGDGetInitialSize399,14560 #undef __FUNCT____FUNCT__410,14891 #define __FUNCT__ __FUNCT__411,14908 PetscErrorCode EPSGDSetInitialSize(EPS eps,PetscInt initialsize)EPSGDSetInitialSize436,15840 #undef __FUNCT____FUNCT__447,16183 #define __FUNCT__ __FUNCT__448,16200 PetscErrorCode EPSGDSetBOrth(EPS eps,PetscBool borth)EPSGDSetBOrth466,16679 #undef __FUNCT____FUNCT__477,16995 #define __FUNCT__ __FUNCT__478,17012 PetscErrorCode EPSGDGetBOrth(EPS eps,PetscBool *borth)EPSGDGetBOrth495,17386 #undef __FUNCT____FUNCT__506,17686 #define __FUNCT__ __FUNCT__507,17703 PetscErrorCode EPSGDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)EPSGDGetWindowSizes526,18205 #undef __FUNCT____FUNCT__536,18525 #define __FUNCT__ __FUNCT__537,18542 PetscErrorCode EPSGDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)EPSGDSetWindowSizes558,19219 #undef __FUNCT____FUNCT__570,19633 #define __FUNCT__ __FUNCT__571,19650 static PetscErrorCode EPSGDGetDoubleExpansion_GD(EPS eps,PetscBool *doubleexp)EPSGDGetDoubleExpansion_GD572,19697 #undef __FUNCT____FUNCT__581,19911 #define __FUNCT__ __FUNCT__582,19928 PetscErrorCode EPSGDGetDoubleExpansion(EPS eps,PetscBool *doubleexp)EPSGDGetDoubleExpansion599,20283 #undef __FUNCT____FUNCT__610,20615 #define __FUNCT__ __FUNCT__611,20632 static PetscErrorCode EPSGDSetDoubleExpansion_GD(EPS eps,PetscBool doubleexp)EPSGDSetDoubleExpansion_GD612,20679 #undef __FUNCT____FUNCT__621,20891 #define __FUNCT__ __FUNCT__622,20908 PetscErrorCode EPSGDSetDoubleExpansion(EPS eps,PetscBool doubleexp)EPSGDSetDoubleExpansion640,21475 #undef __FUNCT____FUNCT__651,21823 #define __FUNCT__ __FUNCT__652,21840 PETSC_EXTERN PetscErrorCode EPSCreate_GD(EPS eps)EPSCreate_GD653,21873 src/eps/impls/davidson/gd/makefile,278 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = gd.cSOURCEC26,958 SOURCEF =SOURCEF27,974 SOURCEH =SOURCEH28,985 LIBBASE = libslepcepsLIBBASE29,996 DIRS =DIRS30,1019 MANSEC = EPSMANSEC31,1030 LOCDIR = src/eps/impls/davidson/gd/LOCDIR32,1045 src/eps/impls/davidson/jd/jd.c,3449 jd.c:^?jd.c^A,1 #undef __FUNCT____FUNCT__45,1616 #define __FUNCT__ __FUNCT__46,1633 PetscErrorCode EPSSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_JD47,1674 #undef __FUNCT____FUNCT__114,5358 #define __FUNCT__ __FUNCT__115,5375 PetscErrorCode EPSSetUp_JD(EPS eps)EPSSetUp_JD116,5407 #undef __FUNCT____FUNCT__139,6135 #define __FUNCT__ __FUNCT__140,6152 PetscErrorCode EPSView_JD(EPS eps,PetscViewer viewer)EPSView_JD141,6183 #undef __FUNCT____FUNCT__172,7574 #define __FUNCT__ __FUNCT__173,7591 PetscErrorCode EPSDestroy_JD(EPS eps)EPSDestroy_JD174,7625 #undef __FUNCT____FUNCT__199,9328 #define __FUNCT__ __FUNCT__200,9345 PetscErrorCode EPSJDSetKrylovStart(EPS eps,PetscBool krylovstart)EPSJDSetKrylovStart219,9795 #undef __FUNCT____FUNCT__230,10141 #define __FUNCT__ __FUNCT__231,10158 PetscErrorCode EPSJDGetKrylovStart(EPS eps,PetscBool *krylovstart)EPSJDGetKrylovStart249,10576 #undef __FUNCT____FUNCT__260,10906 #define __FUNCT__ __FUNCT__261,10923 PetscErrorCode EPSJDSetBlockSize(EPS eps,PetscInt blocksize)EPSJDSetBlockSize279,11415 #undef __FUNCT____FUNCT__290,11748 #define __FUNCT__ __FUNCT__291,11765 PetscErrorCode EPSJDGetBlockSize(EPS eps,PetscInt *blocksize)EPSJDGetBlockSize308,12154 #undef __FUNCT____FUNCT__319,12475 #define __FUNCT__ __FUNCT__320,12492 PetscErrorCode EPSJDGetRestart(EPS eps,PetscInt *minv,PetscInt *plusk)EPSJDGetRestart338,12974 #undef __FUNCT____FUNCT__348,13276 #define __FUNCT__ __FUNCT__349,13293 PetscErrorCode EPSJDSetRestart(EPS eps,PetscInt minv,PetscInt plusk)EPSJDSetRestart369,13944 #undef __FUNCT____FUNCT__381,14335 #define __FUNCT__ __FUNCT__382,14352 PetscErrorCode EPSJDGetInitialSize(EPS eps,PetscInt *initialsize)EPSJDGetInitialSize406,15191 #undef __FUNCT____FUNCT__417,15522 #define __FUNCT__ __FUNCT__418,15539 PetscErrorCode EPSJDSetInitialSize(EPS eps,PetscInt initialsize)EPSJDSetInitialSize443,16471 #undef __FUNCT____FUNCT__454,16814 #define __FUNCT__ __FUNCT__455,16831 PetscErrorCode EPSJDGetFix(EPS eps,PetscReal *fix)EPSJDGetFix477,17364 #undef __FUNCT____FUNCT__488,17654 #define __FUNCT__ __FUNCT__489,17671 PetscErrorCode EPSJDSetFix(EPS eps,PetscReal fix)EPSJDSetFix512,18250 #undef __FUNCT____FUNCT__523,18556 #define __FUNCT__ __FUNCT__524,18573 PetscErrorCode EPSJDSetConstCorrectionTol(EPS eps,PetscBool constant)EPSJDSetConstCorrectionTol543,19186 #undef __FUNCT____FUNCT__554,19537 #define __FUNCT__ __FUNCT__555,19554 PetscErrorCode EPSJDGetConstCorrectionTol(EPS eps,PetscBool *constant)EPSJDGetConstCorrectionTol573,20140 #undef __FUNCT____FUNCT__584,20475 #define __FUNCT__ __FUNCT__585,20492 PetscErrorCode EPSJDGetWindowSizes(EPS eps,PetscInt *pwindow,PetscInt *qwindow)EPSJDGetWindowSizes604,20994 #undef __FUNCT____FUNCT__614,21314 #define __FUNCT__ __FUNCT__615,21331 PetscErrorCode EPSJDSetWindowSizes(EPS eps,PetscInt pwindow,PetscInt qwindow)EPSJDSetWindowSizes636,22008 #undef __FUNCT____FUNCT__648,22422 #define __FUNCT__ __FUNCT__649,22439 PetscErrorCode EPSJDSetBOrth(EPS eps,PetscBool borth)EPSJDSetBOrth667,22918 #undef __FUNCT____FUNCT__678,23234 #define __FUNCT__ __FUNCT__679,23251 PetscErrorCode EPSJDGetBOrth(EPS eps,PetscBool *borth)EPSJDGetBOrth696,23625 #undef __FUNCT____FUNCT__707,23925 #define __FUNCT__ __FUNCT__708,23942 PETSC_EXTERN PetscErrorCode EPSCreate_JD(EPS eps)EPSCreate_JD709,23975 src/eps/impls/davidson/jd/makefile,278 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = jd.cSOURCEC26,958 SOURCEF =SOURCEF27,974 SOURCEH =SOURCEH28,985 LIBBASE = libslepcepsLIBBASE29,996 DIRS =DIRS30,1019 MANSEC = EPSMANSEC31,1030 LOCDIR = src/eps/impls/davidson/jd/LOCDIR32,1045 src/eps/impls/davidson/makefile,343 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = davidson.c dvdcalcpairs.c dvdimprovex.c dvdinitv.c \SOURCEC26,958 SOURCEF =SOURCEF28,1090 SOURCEH = davidson.hSOURCEH29,1101 LIBBASE = libslepcepsLIBBASE30,1123 DIRS = gd jdDIRS31,1146 LOCDIR = src/eps/impls/davidson/LOCDIR32,1163 MANSEC = EPSMANSEC33,1198 src/eps/impls/external/arpack/arpack.c,875 arpack.c:^?arpack.c^A,1 #undef __FUNCT____FUNCT__29,1109 #define __FUNCT__ __FUNCT__30,1126 PetscErrorCode EPSSetUp_ARPACK(EPS eps)EPSSetUp_ARPACK31,1162 #undef __FUNCT____FUNCT__95,4479 #define __FUNCT__ __FUNCT__96,4496 PetscErrorCode EPSSolve_ARPACK(EPS eps)EPSSolve_ARPACK97,4532 #undef __FUNCT____FUNCT__294,13331 #define __FUNCT__ __FUNCT__295,13348 PetscErrorCode EPSBackTransform_ARPACK(EPS eps)EPSBackTransform_ARPACK296,13392 #undef __FUNCT____FUNCT__309,13706 #define __FUNCT__ __FUNCT__310,13723 PetscErrorCode EPSReset_ARPACK(EPS eps)EPSReset_ARPACK311,13759 #undef __FUNCT____FUNCT__327,14188 #define __FUNCT__ __FUNCT__328,14205 PetscErrorCode EPSDestroy_ARPACK(EPS eps)EPSDestroy_ARPACK329,14243 #undef __FUNCT____FUNCT__338,14407 #define __FUNCT__ __FUNCT__339,14424 PETSC_EXTERN PetscErrorCode EPSCreate_ARPACK(EPS eps)EPSCreate_ARPACK340,14461 src/eps/impls/external/arpack/arpackp.h,1942 arpackp.h:^?arpackp.h^A,1 #define __ARPACKP_H__ARPACKP_H25,1006 PetscBool *select;select28,1044 PetscScalar *workev;workev29,1068 PetscScalar *workd;workd30,1092 PetscScalar *workl;workl31,1115 PetscBLASInt lworkl;lworkl32,1138 PetscReal *rwork;rwork33,1161 } EPS_ARPACK;EPS_ARPACK34,1184 #define SLEPC_ARPACK(SLEPC_ARPACK47,1398 #define SLEPC_ARPACK(SLEPC_ARPACK49,1482 #define SLEPC_ARPACK(SLEPC_ARPACK51,1531 #define SLEPC_ARPACK(SLEPC_ARPACK57,1631 #define SLEPC_ARPACK(SLEPC_ARPACK59,1715 #define SLEPC_ARPACK(SLEPC_ARPACK61,1764 #define SLEPC_ARPACK(SLEPC_ARPACK71,1908 #define SLEPC_ARPACK(SLEPC_ARPACK73,1992 #define SLEPC_ARPACK(SLEPC_ARPACK75,2041 #define SLEPC_ARPACK(SLEPC_ARPACK81,2141 #define SLEPC_ARPACK(SLEPC_ARPACK83,2225 #define SLEPC_ARPACK(SLEPC_ARPACK85,2274 #define SLEPC_ARPACK(SLEPC_ARPACK99,2476 #define SLEPC_ARPACK(SLEPC_ARPACK101,2561 #define SLEPC_ARPACK(SLEPC_ARPACK103,2611 #define SLEPC_ARPACK(SLEPC_ARPACK109,2712 #define SLEPC_ARPACK(SLEPC_ARPACK111,2797 #define SLEPC_ARPACK(SLEPC_ARPACK113,2847 #define SLEPC_ARPACK(SLEPC_ARPACK123,2992 #define SLEPC_ARPACK(SLEPC_ARPACK125,3077 #define SLEPC_ARPACK(SLEPC_ARPACK127,3127 #define SLEPC_ARPACK(SLEPC_ARPACK133,3228 #define SLEPC_ARPACK(SLEPC_ARPACK135,3313 #define SLEPC_ARPACK(SLEPC_ARPACK137,3363 #define COMM_ARGCOMM_ARG148,3471 #define ARPACKnaupd_(ARPACKnaupd_152,3522 #define ARPACKneupd_(ARPACKneupd_153,3677 #define ARPACKsaupd_(ARPACKsaupd_154,3888 #define ARPACKseupd_(ARPACKseupd_155,4043 #define ARPACKnaupd_(ARPACKnaupd_159,4244 #define ARPACKneupd_(ARPACKneupd_160,4405 #define COMM_ARG COMM_ARG166,4643 #define ARPACKnaupd_(ARPACKnaupd_170,4705 #define ARPACKneupd_(ARPACKneupd_171,4867 #define ARPACKsaupd_(ARPACKsaupd_172,5085 #define ARPACKseupd_(ARPACKseupd_173,5247 #define ARPACKnaupd_(ARPACKnaupd_177,5455 #define ARPACKneupd_(ARPACKneupd_178,5623 src/eps/impls/external/arpack/makefile,299 makefile:^?makefile^A,1 CFLAGS =CFLAGS26,974 FFLAGS =FFLAGS27,985 SOURCEC = arpack.cSOURCEC28,996 SOURCEF =SOURCEF29,1016 SOURCEH = arpackp.hSOURCEH30,1027 LIBBASE = libslepcepsLIBBASE31,1048 DIRS =DIRS32,1071 MANSEC = EPSMANSEC33,1082 LOCDIR = src/eps/impls/external/arpack/LOCDIR34,1097 src/eps/impls/external/blopex/blopex.c,3369 blopex.c:^?blopex.c^A,1 PetscInt slepc_blopex_useconstr = -1;slepc_blopex_useconstr31,1210 lobpcg_Tolerance tol;tol36,1304 lobpcg_BLASLAPACKFunctions blap_fn;blap_fn37,1338 mv_InterfaceInterpreter ii;ii38,1376 ST st;st39,1409 Vec w;w40,1442 PetscInt bs; /* block size */bs41,1474 } EPS_BLOPEX;EPS_BLOPEX42,1528 #undef __FUNCT____FUNCT__44,1543 #define __FUNCT__ __FUNCT__45,1560 static void Precond_FnSingleVector(void *data,void *x,void *y)Precond_FnSingleVector46,1603 #undef __FUNCT____FUNCT__59,2000 #define __FUNCT__ __FUNCT__60,2017 static void Precond_FnMultiVector(void *data,void *x,void *y)Precond_FnMultiVector61,2059 #undef __FUNCT____FUNCT__70,2272 #define __FUNCT__ __FUNCT__71,2289 static void OperatorASingleVector(void *data,void *x,void *y)OperatorASingleVector72,2331 #undef __FUNCT____FUNCT__98,3248 #define __FUNCT__ __FUNCT__99,3265 static void OperatorAMultiVector(void *data,void *x,void *y)OperatorAMultiVector100,3306 #undef __FUNCT____FUNCT__109,3517 #define __FUNCT__ __FUNCT__110,3534 static void OperatorBSingleVector(void *data,void *x,void *y)OperatorBSingleVector111,3576 #undef __FUNCT____FUNCT__124,3973 #define __FUNCT__ __FUNCT__125,3990 static void OperatorBMultiVector(void *data,void *x,void *y)OperatorBMultiVector126,4031 #undef __FUNCT____FUNCT__135,4242 #define __FUNCT__ __FUNCT__136,4259 PetscErrorCode EPSSetDimensions_BLOPEX(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)EPSSetDimensions_BLOPEX137,4303 #undef __FUNCT____FUNCT__153,4845 #define __FUNCT__ __FUNCT__154,4862 PetscErrorCode EPSSetUp_BLOPEX(EPS eps)EPSSetUp_BLOPEX155,4898 #undef __FUNCT____FUNCT__217,7996 #define __FUNCT__ __FUNCT__218,8013 PetscErrorCode EPSSolve_BLOPEX(EPS eps)EPSSolve_BLOPEX219,8049 #undef __FUNCT____FUNCT__319,11947 #define __FUNCT__ __FUNCT__320,11964 static PetscErrorCode EPSBLOPEXSetBlockSize_BLOPEX(EPS eps,PetscInt bs)EPSBLOPEXSetBlockSize_BLOPEX321,12013 #undef __FUNCT____FUNCT__330,12199 #define __FUNCT__ __FUNCT__331,12216 PetscErrorCode EPSBLOPEXSetBlockSize(EPS eps,PetscInt bs)EPSBLOPEXSetBlockSize348,12582 #undef __FUNCT____FUNCT__359,12902 #define __FUNCT__ __FUNCT__360,12919 static PetscErrorCode EPSBLOPEXGetBlockSize_BLOPEX(EPS eps,PetscInt *bs)EPSBLOPEXGetBlockSize_BLOPEX361,12968 #undef __FUNCT____FUNCT__370,13156 #define __FUNCT__ __FUNCT__371,13173 PetscErrorCode EPSBLOPEXGetBlockSize(EPS eps,PetscInt *bs)EPSBLOPEXGetBlockSize387,13478 #undef __FUNCT____FUNCT__398,13783 #define __FUNCT__ __FUNCT__399,13800 PetscErrorCode EPSReset_BLOPEX(EPS eps)EPSReset_BLOPEX400,13836 #undef __FUNCT____FUNCT__410,14051 #define __FUNCT__ __FUNCT__411,14068 PetscErrorCode EPSDestroy_BLOPEX(EPS eps)EPSDestroy_BLOPEX412,14106 #undef __FUNCT____FUNCT__424,14503 #define __FUNCT__ __FUNCT__425,14520 PetscErrorCode EPSView_BLOPEX(EPS eps,PetscViewer viewer)EPSView_BLOPEX426,14555 #undef __FUNCT____FUNCT__440,14972 #define __FUNCT__ __FUNCT__441,14989 PetscErrorCode EPSSetFromOptions_BLOPEX(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_BLOPEX442,15034 #undef __FUNCT____FUNCT__472,16019 #define __FUNCT__ __FUNCT__473,16036 PETSC_EXTERN PetscErrorCode EPSCreate_BLOPEX(EPS eps)EPSCreate_BLOPEX474,16073 src/eps/impls/external/blopex/makefile,402 makefile:^?makefile^A,1 CFLAGS = ${BLOPEX_INCLUDE} -DBlopexInt=PetscIntCFLAGS26,974 FFLAGS =FFLAGS27,1024 SOURCEC = blopex.c slepc-interface.c petsc-interface.cSOURCEC28,1035 SOURCEF =SOURCEF29,1091 SOURCEH = slepc-interface.h petsc-interface.hSOURCEH30,1102 LIBBASE = libslepcepsLIBBASE31,1149 DIRS =DIRS32,1172 MANSEC = EPSMANSEC33,1183 LOCDIR = src/eps/impls/external/blopex/LOCDIR34,1198 src/eps/impls/external/blopex/petsc-interface.c,1792 petsc-interface.c:^?petsc-interface.c^A,1 static PetscRandom LOBPCG_RandomContext = NULL;LOBPCG_RandomContext13,557 BlopexInt PETSC_dpotrf_interface (char *uplo,BlopexInt *n,double *a,BlopexInt * lda,BlopexInt *info)PETSC_dpotrf_interface15,606 BlopexInt PETSC_zpotrf_interface (char *uplo,BlopexInt *n,komplex *a,BlopexInt* lda,BlopexInt *info)PETSC_zpotrf_interface30,896 BlopexInt PETSC_dsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,double *a,BlopexInt *lda,double *b,BlopexInt *ldb,double *w,double *work,BlopexInt *lwork,BlopexInt *info)PETSC_dsygv_interface44,1183 BlopexInt PETSC_zsygv_interface (BlopexInt *itype,char *jobz,char *uplo,BlopexInt *n,komplex *a,BlopexInt *lda,komplex *b,BlopexInt *ldb,double *w,komplex *work,BlopexInt *lwork,double *rwork,BlopexInt *info)PETSC_zsygv_interface63,1728 void *PETSC_MimicVector(void *vvector)PETSC_MimicVector82,2305 BlopexInt PETSC_DestroyVector(void *vvector)PETSC_DestroyVector91,2485 BlopexInt PETSC_InnerProd(void *x,void *y,void *result)PETSC_InnerProd100,2634 BlopexInt PETSC_CopyVector(void *x,void *y)PETSC_CopyVector108,2798 BlopexInt PETSC_ClearVector(void *x)PETSC_ClearVector116,2931 BlopexInt PETSC_SetRandomValues(void* v,BlopexInt seed)PETSC_SetRandomValues124,3053 BlopexInt PETSC_ScaleVector(double alpha,void *x)PETSC_ScaleVector135,3376 BlopexInt PETSC_Axpy(void *alpha,void *x,void *y)PETSC_Axpy143,3514 BlopexInt PETSC_VectorSize(void *x)PETSC_VectorSize151,3673 int LOBPCG_InitRandomContext(MPI_Comm comm,PetscRandom rand)LOBPCG_InitRandomContext158,3765 int LOBPCG_SetFromOptionsRandomContext(void)LOBPCG_SetFromOptionsRandomContext173,4172 int LOBPCG_DestroyRandomContext(void)LOBPCG_DestroyRandomContext186,4606 int PETSCSetupInterpreter(mv_InterfaceInterpreter *i)PETSCSetupInterpreter194,4751 src/eps/impls/external/blopex/petsc-interface.h,60 petsc-interface.h:^?petsc-interface.h^A,1 #define PETSC_INTERFACE_HEADERPETSC_INTERFACE_HEADER7,334 src/eps/impls/external/blopex/slepc-interface.c,414 slepc-interface.c:^?slepc-interface.c^A,1 static void* mv_TempMultiVectorCreateFromBV(void* ii_,BlopexInt n,void* sample)mv_TempMultiVectorCreateFromBV31,1208 static void mv_TempMultiPETSCVectorDestroy(void* x_)mv_TempMultiPETSCVectorDestroy69,2680 int SLEPCSetupInterpreter(mv_InterfaceInterpreter *i)SLEPCSetupInterpreter85,3067 void SLEPCSetupInterpreterForDignifiedDeath(mv_InterfaceInterpreter *i)SLEPCSetupInterpreterForDignifiedDeath97,3353 src/eps/impls/external/blopex/slepc-interface.h,139 slepc-interface.h:^?slepc-interface.h^A,1 #define SLEPC_INTERFACE_HEADERSLEPC_INTERFACE_HEADER26,1092 PETSC_INTERN PetscInt slepc_blopex_useconstr;slepc_blopex_useconstr31,1181 src/eps/impls/external/blzpack/blzpack.c,2020 blzpack.c:^?blzpack.c^A,1 const char* blzpack_error[33] = {blzpack_error29,1137 #undef __FUNCT____FUNCT__65,2524 #define __FUNCT__ __FUNCT__66,2541 PetscErrorCode EPSSetUp_BLZPACK(EPS eps)EPSSetUp_BLZPACK67,2578 #undef __FUNCT____FUNCT__152,7011 #define __FUNCT__ __FUNCT__153,7028 PetscErrorCode EPSSolve_BLZPACK(EPS eps)EPSSolve_BLZPACK154,7065 #undef __FUNCT____FUNCT__284,12498 #define __FUNCT__ __FUNCT__285,12515 PetscErrorCode EPSBackTransform_BLZPACK(EPS eps)EPSBackTransform_BLZPACK286,12560 #undef __FUNCT____FUNCT__298,12839 #define __FUNCT__ __FUNCT__299,12856 PetscErrorCode EPSReset_BLZPACK(EPS eps)EPSReset_BLZPACK300,12893 #undef __FUNCT____FUNCT__314,13280 #define __FUNCT__ __FUNCT__315,13297 PetscErrorCode EPSDestroy_BLZPACK(EPS eps)EPSDestroy_BLZPACK316,13336 #undef __FUNCT____FUNCT__327,13700 #define __FUNCT__ __FUNCT__328,13717 PetscErrorCode EPSView_BLZPACK(EPS eps,PetscViewer viewer)EPSView_BLZPACK329,13753 #undef __FUNCT____FUNCT__347,14453 #define __FUNCT__ __FUNCT__348,14470 PetscErrorCode EPSSetFromOptions_BLZPACK(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_BLZPACK349,14516 #undef __FUNCT____FUNCT__375,15320 #define __FUNCT__ __FUNCT__376,15337 static PetscErrorCode EPSBlzpackSetBlockSize_BLZPACK(EPS eps,PetscInt bs)EPSBlzpackSetBlockSize_BLZPACK377,15388 #undef __FUNCT____FUNCT__391,15832 #define __FUNCT__ __FUNCT__392,15849 PetscErrorCode EPSBlzpackSetBlockSize(EPS eps,PetscInt bs)EPSBlzpackSetBlockSize407,16185 #undef __FUNCT____FUNCT__418,16507 #define __FUNCT__ __FUNCT__419,16524 static PetscErrorCode EPSBlzpackSetNSteps_BLZPACK(EPS eps,PetscInt nsteps)EPSBlzpackSetNSteps_BLZPACK420,16572 #undef __FUNCT____FUNCT__433,16898 #define __FUNCT__ __FUNCT__434,16915 PetscErrorCode EPSBlzpackSetNSteps(EPS eps,PetscInt nsteps)EPSBlzpackSetNSteps451,17296 #undef __FUNCT____FUNCT__462,17624 #define __FUNCT__ __FUNCT__463,17641 PETSC_EXTERN PetscErrorCode EPSCreate_BLZPACK(EPS eps)EPSCreate_BLZPACK464,17679 src/eps/impls/external/blzpack/blzpackp.h,815 blzpackp.h:^?blzpackp.h^A,1 #define __BLZPACKP_H__BLZPACKP_H25,1008 PetscBLASInt block_size; /* block size */block_size28,1047 PetscBLASInt slice; /* use spectrum slicing */slice29,1104 PetscBLASInt nsteps; /* maximum number of steps per run */nsteps30,1171 PetscBLASInt *istor;istor31,1249 PetscReal *rstor;rstor32,1280 PetscScalar *u;u33,1311 PetscScalar *v;v34,1338 PetscScalar *eig;eig35,1365 } EPS_BLZPACK;EPS_BLZPACK36,1394 #define SLEPC_BLZPACK(SLEPC_BLZPACK43,1511 #define SLEPC_BLZPACK(SLEPC_BLZPACK45,1594 #define SLEPC_BLZPACK(SLEPC_BLZPACK47,1641 #define BLZpack_ BLZpack_59,1889 #define BLZpack_ BLZpack_61,1941 #define BLZistorr_ BLZistorr_64,1995 #define BLZrstorr_ BLZrstorr_65,2043 src/eps/impls/external/blzpack/makefile,302 makefile:^?makefile^A,1 CFLAGS =CFLAGS26,975 FFLAGS =FFLAGS27,986 SOURCEC = blzpack.cSOURCEC28,997 SOURCEF =SOURCEF29,1018 SOURCEH = blzpackp.hSOURCEH30,1029 LIBBASE = libslepcepsLIBBASE31,1051 DIRS =DIRS32,1074 MANSEC = EPSMANSEC33,1085 LOCDIR = src/eps/impls/external/blzpack/LOCDIR34,1100 src/eps/impls/external/feast/feast.c,1763 feast.c:^?feast.c^A,1 #undef __FUNCT____FUNCT__29,1133 #define __FUNCT__ __FUNCT__30,1150 PetscErrorCode EPSSetUp_FEAST(EPS eps)EPSSetUp_FEAST31,1185 #undef __FUNCT____FUNCT__80,4076 #define __FUNCT__ __FUNCT__81,4093 PetscErrorCode EPSSolve_FEAST(EPS eps)EPSSolve_FEAST82,4128 #undef __FUNCT____FUNCT__179,8144 #define __FUNCT__ __FUNCT__180,8161 PetscErrorCode EPSReset_FEAST(EPS eps)EPSReset_FEAST181,8196 #undef __FUNCT____FUNCT__191,8433 #define __FUNCT__ __FUNCT__192,8450 PetscErrorCode EPSDestroy_FEAST(EPS eps)EPSDestroy_FEAST193,8487 #undef __FUNCT____FUNCT__204,8848 #define __FUNCT__ __FUNCT__205,8865 PetscErrorCode EPSSetFromOptions_FEAST(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_FEAST206,8909 #undef __FUNCT____FUNCT__226,9514 #define __FUNCT__ __FUNCT__227,9531 PetscErrorCode EPSView_FEAST(EPS eps,PetscViewer viewer)EPSView_FEAST228,9565 #undef __FUNCT____FUNCT__242,10010 #define __FUNCT__ __FUNCT__243,10027 static PetscErrorCode EPSFEASTSetNumPoints_FEAST(EPS eps,PetscInt npoints)EPSFEASTSetNumPoints_FEAST244,10074 #undef __FUNCT____FUNCT__257,10402 #define __FUNCT__ __FUNCT__258,10419 PetscErrorCode EPSFEASTSetNumPoints(EPS eps,PetscInt npoints)EPSFEASTSetNumPoints276,10838 #undef __FUNCT____FUNCT__287,11171 #define __FUNCT__ __FUNCT__288,11188 static PetscErrorCode EPSFEASTGetNumPoints_FEAST(EPS eps,PetscInt *npoints)EPSFEASTGetNumPoints_FEAST289,11235 #undef __FUNCT____FUNCT__298,11434 #define __FUNCT__ __FUNCT__299,11451 PetscErrorCode EPSFEASTGetNumPoints(EPS eps,PetscInt *npoints)EPSFEASTGetNumPoints316,11812 #undef __FUNCT____FUNCT__327,12130 #define __FUNCT__ __FUNCT__328,12147 PETSC_EXTERN PetscErrorCode EPSCreate_FEAST(EPS eps)EPSCreate_FEAST329,12183 src/eps/impls/external/feast/feastp.h,1145 feastp.h:^?feastp.h^A,1 #define __FEASTP_H__FEASTP_H25,1004 PetscScalar *work1,*work2,*Aq,*Bq; /* workspace */work128,1041 PetscScalar *work1,*work2,*Aq,*Bq; /* workspace */work228,1041 PetscScalar *work1,*work2,*Aq,*Bq; /* workspace */Aq28,1041 PetscScalar *work1,*work2,*Aq,*Bq; /* workspace */Bq28,1041 PetscBLASInt npoints; /* number of contour points */npoints29,1097 } EPS_FEAST;EPS_FEAST30,1168 #define SLEPC_FEAST(SLEPC_FEAST37,1279 #define SLEPC_FEAST(SLEPC_FEAST39,1358 #define SLEPC_FEAST(SLEPC_FEAST41,1403 #define SLEPC_FEASTM(SLEPC_FEASTM49,1559 #define SLEPC_FEASTM(SLEPC_FEASTM51,1649 #define SLEPC_FEASTM(SLEPC_FEASTM53,1705 #define SLEPC_FEASTM(SLEPC_FEASTM59,1811 #define SLEPC_FEASTM(SLEPC_FEASTM61,1901 #define SLEPC_FEASTM(SLEPC_FEASTM63,1957 #define SLEPC_FEASTM(SLEPC_FEASTM73,2107 #define SLEPC_FEASTM(SLEPC_FEASTM75,2197 #define SLEPC_FEASTM(SLEPC_FEASTM77,2253 #define SLEPC_FEASTM(SLEPC_FEASTM83,2359 #define SLEPC_FEASTM(SLEPC_FEASTM85,2449 #define SLEPC_FEASTM(SLEPC_FEASTM87,2505 #define FEASTinit_(FEASTinit_94,2579 #define FEASTrci_(FEASTrci_95,2640 src/eps/impls/external/feast/makefile,296 makefile:^?makefile^A,1 CFLAGS =CFLAGS26,973 FFLAGS =FFLAGS27,984 SOURCEC = feast.cSOURCEC28,995 SOURCEF =SOURCEF29,1014 SOURCEH = feastp.hSOURCEH30,1025 LIBBASE = libslepcepsLIBBASE31,1045 DIRS =DIRS32,1068 MANSEC = EPSMANSEC33,1079 LOCDIR = src/eps/impls/external/feast/LOCDIR34,1094 src/eps/impls/external/makefile,182 makefile:^?makefile^A,1 LIBBASE = libslepcepsLIBBASE24,936 DIRS = arpack blopex blzpack primme trlan feastDIRS25,959 LOCDIR = src/eps/impls/external/LOCDIR26,1011 MANSEC = EPSMANSEC27,1046 src/eps/impls/external/primme/makefile,307 makefile:^?makefile^A,1 CFLAGS = ${PRIMME_FLAGS}CFLAGS26,974 FFLAGS =FFLAGS27,1001 SOURCEC = primme.cSOURCEC28,1012 SOURCEF =SOURCEF29,1032 SOURCEH =SOURCEH30,1043 LIBBASE = libslepcepsLIBBASE31,1054 DIRS =DIRS32,1077 MANSEC = EPSMANSEC33,1088 LOCDIR = src/eps/impls/external/primme/LOCDIR34,1103 src/eps/impls/external/primme/primme.c,3640 primme.c:^?primme.c^A,1 primme_params primme; /* param struc */primme33,1145 primme_preset_method method; /* primme method */method34,1197 Mat A; /* problem matrix */A35,1251 EPS eps; /* EPS current context */eps36,1306 KSP ksp; /* linear solver and preconditioner */ksp37,1366 Vec x,y; /* auxiliary vectors */x38,1439 Vec x,y; /* auxiliary vectors */y38,1439 PetscReal target; /* a copy of eps's target */target39,1497 } EPS_PRIMME;EPS_PRIMME40,1560 static void par_GlobalSumDouble(void *sendBuf,void *recvBuf,int *count,primme_params *primme)par_GlobalSumDouble45,1768 #undef __FUNCT____FUNCT__51,2087 #define __FUNCT__ __FUNCT__52,2104 PetscErrorCode EPSSetUp_PRIMME(EPS eps)EPSSetUp_PRIMME53,2140 #undef __FUNCT____FUNCT__149,6816 #define __FUNCT__ __FUNCT__150,6833 PetscErrorCode EPSSolve_PRIMME(EPS eps)EPSSolve_PRIMME151,6869 #undef __FUNCT____FUNCT__191,8356 #define __FUNCT__ __FUNCT__192,8373 static void multMatvec_PRIMME(void *in,void *out,int *blockSize,primme_params *primme)multMatvec_PRIMME193,8411 #undef __FUNCT____FUNCT__215,9261 #define __FUNCT__ __FUNCT__216,9278 static void applyPreconditioner_PRIMME(void *in,void *out,int *blockSize,struct primme_params *primme)applyPreconditioner_PRIMME217,9325 #undef __FUNCT____FUNCT__236,10203 #define __FUNCT__ __FUNCT__237,10220 PetscErrorCode EPSReset_PRIMME(EPS eps)EPSReset_PRIMME238,10256 #undef __FUNCT____FUNCT__250,10538 #define __FUNCT__ __FUNCT__251,10555 PetscErrorCode EPSDestroy_PRIMME(EPS eps)EPSDestroy_PRIMME252,10593 #undef __FUNCT____FUNCT__265,11151 #define __FUNCT__ __FUNCT__266,11168 PetscErrorCode EPSView_PRIMME(EPS eps,PetscViewer viewer)EPSView_PRIMME267,11203 #undef __FUNCT____FUNCT__289,12036 #define __FUNCT__ __FUNCT__290,12053 PetscErrorCode EPSSetFromOptions_PRIMME(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_PRIMME291,12098 #undef __FUNCT____FUNCT__326,13401 #define __FUNCT__ __FUNCT__327,13418 static PetscErrorCode EPSPRIMMESetBlockSize_PRIMME(EPS eps,PetscInt bs)EPSPRIMMESetBlockSize_PRIMME328,13467 #undef __FUNCT____FUNCT__339,13859 #define __FUNCT__ __FUNCT__340,13876 PetscErrorCode EPSPRIMMESetBlockSize(EPS eps,PetscInt bs)EPSPRIMMESetBlockSize366,14659 #undef __FUNCT____FUNCT__377,14979 #define __FUNCT__ __FUNCT__378,14996 static PetscErrorCode EPSPRIMMEGetBlockSize_PRIMME(EPS eps,PetscInt *bs)EPSPRIMMEGetBlockSize_PRIMME379,15045 #undef __FUNCT____FUNCT__388,15250 #define __FUNCT__ __FUNCT__389,15267 PetscErrorCode EPSPRIMMEGetBlockSize(EPS eps,PetscInt *bs)EPSPRIMMEGetBlockSize405,15583 #undef __FUNCT____FUNCT__416,15888 #define __FUNCT__ __FUNCT__417,15905 static PetscErrorCode EPSPRIMMESetMethod_PRIMME(EPS eps,EPSPRIMMEMethod method)EPSPRIMMESetMethod_PRIMME418,15951 #undef __FUNCT____FUNCT__427,16175 #define __FUNCT__ __FUNCT__428,16192 PetscErrorCode EPSPRIMMESetMethod(EPS eps,EPSPRIMMEMethod method)EPSPRIMMESetMethod448,16680 #undef __FUNCT____FUNCT__459,17021 #define __FUNCT__ __FUNCT__460,17038 static PetscErrorCode EPSPRIMMEGetMethod_PRIMME(EPS eps,EPSPRIMMEMethod *method)EPSPRIMMEGetMethod_PRIMME461,17084 #undef __FUNCT____FUNCT__470,17305 #define __FUNCT__ __FUNCT__471,17322 PetscErrorCode EPSPRIMMEGetMethod(EPS eps,EPSPRIMMEMethod *method)EPSPRIMMEGetMethod487,17652 #undef __FUNCT____FUNCT__498,17977 #define __FUNCT__ __FUNCT__499,17994 PETSC_EXTERN PetscErrorCode EPSCreate_PRIMME(EPS eps)EPSCreate_PRIMME500,18031 src/eps/impls/external/trlan/makefile,296 makefile:^?makefile^A,1 CFLAGS =CFLAGS26,973 FFLAGS =FFLAGS27,984 SOURCEC = trlan.cSOURCEC28,995 SOURCEF =SOURCEF29,1014 SOURCEH = trlanp.hSOURCEH30,1025 LIBBASE = libslepcepsLIBBASE31,1045 DIRS =DIRS32,1068 MANSEC = EPSMANSEC33,1079 LOCDIR = src/eps/impls/external/trlan/LOCDIR34,1094 src/eps/impls/external/trlan/trlan.c,969 trlan.c:^?trlan.c^A,1 static EPS globaleps;globaleps30,1164 #undef __FUNCT____FUNCT__32,1187 #define __FUNCT__ __FUNCT__33,1204 PetscErrorCode EPSSetUp_TRLAN(EPS eps)EPSSetUp_TRLAN34,1239 #undef __FUNCT____FUNCT__77,3475 #define __FUNCT__ __FUNCT__78,3492 static PetscBLASInt MatMult_TRLAN(PetscBLASInt *n,PetscBLASInt *m,PetscReal *xin,PetscBLASInt *ldx,PetscReal *yout,PetscBLASInt *ldy)MatMult_TRLAN79,3526 #undef __FUNCT____FUNCT__101,4466 #define __FUNCT__ __FUNCT__102,4483 PetscErrorCode EPSSolve_TRLAN(EPS eps)EPSSolve_TRLAN103,4518 #undef __FUNCT____FUNCT__160,6953 #define __FUNCT__ __FUNCT__161,6970 PetscErrorCode EPSReset_TRLAN(EPS eps)EPSReset_TRLAN162,7005 #undef __FUNCT____FUNCT__172,7211 #define __FUNCT__ __FUNCT__173,7228 PetscErrorCode EPSDestroy_TRLAN(EPS eps)EPSDestroy_TRLAN174,7265 #undef __FUNCT____FUNCT__183,7428 #define __FUNCT__ __FUNCT__184,7445 PETSC_EXTERN PetscErrorCode EPSCreate_TRLAN(EPS eps)EPSCreate_TRLAN185,7481 src/eps/impls/external/trlan/trlanp.h,335 trlanp.h:^?trlanp.h^A,1 #define __TRLANP_H__TRLANP_H25,1004 PetscBLASInt maxlan;maxlan28,1041 PetscBLASInt restart;restart29,1070 PetscReal *work;work30,1100 PetscBLASInt lwork;lwork31,1128 } EPS_TRLAN;EPS_TRLAN32,1156 #define TRLan_ TRLan_40,1341 #define TRLan_ TRLan_42,1402 #define TRLan_ TRLan_44,1431 src/eps/impls/krylov/arnoldi/arnoldi.c,1725 arnoldi.c:^?arnoldi.c^A,1 PetscBool delayed;delayed41,1333 } EPS_ARNOLDI;EPS_ARNOLDI42,1354 #undef __FUNCT____FUNCT__44,1370 #define __FUNCT__ __FUNCT__45,1387 PetscErrorCode EPSSetUp_Arnoldi(EPS eps)EPSSetUp_Arnoldi46,1424 #undef __FUNCT____FUNCT__77,2986 #define __FUNCT__ __FUNCT__78,3003 PetscErrorCode EPSSolve_Arnoldi(EPS eps)EPSSolve_Arnoldi79,3040 #undef __FUNCT____FUNCT__163,6807 #define __FUNCT__ __FUNCT__164,6824 PetscErrorCode EPSSetFromOptions_Arnoldi(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_Arnoldi165,6870 #undef __FUNCT____FUNCT__181,7470 #define __FUNCT__ __FUNCT__182,7487 static PetscErrorCode EPSArnoldiSetDelayed_Arnoldi(EPS eps,PetscBool delayed)EPSArnoldiSetDelayed_Arnoldi183,7536 #undef __FUNCT____FUNCT__192,7748 #define __FUNCT__ __FUNCT__193,7765 PetscErrorCode EPSArnoldiSetDelayed(EPS eps,PetscBool delayed)EPSArnoldiSetDelayed216,8413 #undef __FUNCT____FUNCT__227,8749 #define __FUNCT__ __FUNCT__228,8766 static PetscErrorCode EPSArnoldiGetDelayed_Arnoldi(EPS eps,PetscBool *delayed)EPSArnoldiGetDelayed_Arnoldi229,8815 #undef __FUNCT____FUNCT__238,9029 #define __FUNCT__ __FUNCT__239,9046 PetscErrorCode EPSArnoldiGetDelayed(EPS eps,PetscBool *delayed)EPSArnoldiGetDelayed256,9437 #undef __FUNCT____FUNCT__267,9757 #define __FUNCT__ __FUNCT__268,9774 PetscErrorCode EPSDestroy_Arnoldi(EPS eps)EPSDestroy_Arnoldi269,9813 #undef __FUNCT____FUNCT__280,10176 #define __FUNCT__ __FUNCT__281,10193 PetscErrorCode EPSView_Arnoldi(EPS eps,PetscViewer viewer)EPSView_Arnoldi282,10229 #undef __FUNCT____FUNCT__298,10701 #define __FUNCT__ __FUNCT__299,10718 PETSC_EXTERN PetscErrorCode EPSCreate_Arnoldi(EPS eps)EPSCreate_Arnoldi300,10756 src/eps/impls/krylov/arnoldi/makefile,287 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = arnoldi.cSOURCEC26,958 SOURCEF =SOURCEF27,979 SOURCEH =SOURCEH28,990 LIBBASE = libslepcepsLIBBASE29,1001 DIRS =DIRS30,1024 MANSEC = EPSMANSEC31,1035 LOCDIR = src/eps/impls/krylov/arnoldi/LOCDIR32,1050 src/eps/impls/krylov/epskrylov.c,1437 epskrylov.c:^?epskrylov.c^A,1 #undef __FUNCT____FUNCT__28,1078 #define __FUNCT__ __FUNCT__29,1095 PetscErrorCode EPSBasicArnoldi(EPS eps,PetscBool trans,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)EPSBasicArnoldi41,1617 #undef __FUNCT____FUNCT__72,2615 #define __FUNCT__ __FUNCT__73,2632 PetscErrorCode EPSDelayedArnoldi(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)EPSDelayedArnoldi80,2957 #undef __FUNCT____FUNCT__186,6497 #define __FUNCT__ __FUNCT__187,6514 PetscErrorCode EPSDelayedArnoldi1(EPS eps,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)EPSDelayedArnoldi1192,6695 #undef __FUNCT____FUNCT__235,8063 #define __FUNCT__ __FUNCT__236,8080 PetscErrorCode EPSKrylovConvergence(EPS eps,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscReal corrf,PetscInt *kout)EPSKrylovConvergence254,8866 #undef __FUNCT____FUNCT__331,11630 #define __FUNCT__ __FUNCT__332,11647 PetscErrorCode EPSFullLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown)EPSFullLanczos351,12577 #undef __FUNCT____FUNCT__385,13627 #define __FUNCT__ __FUNCT__386,13644 PetscErrorCode EPSPseudoLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscReal *cos,Vec w)EPSPseudoLanczos387,13681 src/eps/impls/krylov/krylovschur/krylovschur.c,8515 krylovschur.c:^?krylovschur.c^A,1 #undef __FUNCT____FUNCT__46,1620 #define __FUNCT__ __FUNCT__47,1637 PetscErrorCode EPSGetArbitraryValues(EPS eps,PetscScalar *rr,PetscScalar *ri)EPSGetArbitraryValues48,1679 #undef __FUNCT____FUNCT__75,2640 #define __FUNCT__ __FUNCT__76,2657 PetscErrorCode EPSSetUp_KrylovSchur(EPS eps)EPSSetUp_KrylovSchur77,2698 #undef __FUNCT____FUNCT__173,7449 #define __FUNCT__ __FUNCT__174,7466 PetscErrorCode EPSSolve_KrylovSchur_Default(EPS eps)EPSSolve_KrylovSchur_Default175,7515 #undef __FUNCT____FUNCT__296,12404 #define __FUNCT__ __FUNCT__297,12421 static PetscErrorCode EPSKrylovSchurSetRestart_KrylovSchur(EPS eps,PetscReal keep)EPSKrylovSchurSetRestart_KrylovSchur298,12478 #undef __FUNCT____FUNCT__311,12898 #define __FUNCT__ __FUNCT__312,12915 PetscErrorCode EPSKrylovSchurSetRestart(EPS eps,PetscReal keep)EPSKrylovSchurSetRestart334,13506 #undef __FUNCT____FUNCT__345,13841 #define __FUNCT__ __FUNCT__346,13858 static PetscErrorCode EPSKrylovSchurGetRestart_KrylovSchur(EPS eps,PetscReal *keep)EPSKrylovSchurGetRestart_KrylovSchur347,13915 #undef __FUNCT____FUNCT__356,14128 #define __FUNCT__ __FUNCT__357,14145 PetscErrorCode EPSKrylovSchurGetRestart(EPS eps,PetscReal *keep)EPSKrylovSchurGetRestart374,14484 #undef __FUNCT____FUNCT__385,14803 #define __FUNCT__ __FUNCT__386,14820 static PetscErrorCode EPSKrylovSchurSetLocking_KrylovSchur(EPS eps,PetscBool lock)EPSKrylovSchurSetLocking_KrylovSchur387,14877 #undef __FUNCT____FUNCT__396,15088 #define __FUNCT__ __FUNCT__397,15105 PetscErrorCode EPSKrylovSchurSetLocking(EPS eps,PetscBool lock)EPSKrylovSchurSetLocking421,15806 #undef __FUNCT____FUNCT__432,16141 #define __FUNCT__ __FUNCT__433,16158 static PetscErrorCode EPSKrylovSchurGetLocking_KrylovSchur(EPS eps,PetscBool *lock)EPSKrylovSchurGetLocking_KrylovSchur434,16215 #undef __FUNCT____FUNCT__443,16428 #define __FUNCT__ __FUNCT__444,16445 PetscErrorCode EPSKrylovSchurGetLocking(EPS eps,PetscBool *lock)EPSKrylovSchurGetLocking461,16774 #undef __FUNCT____FUNCT__472,17093 #define __FUNCT__ __FUNCT__473,17110 static PetscErrorCode EPSKrylovSchurSetPartitions_KrylovSchur(EPS eps,PetscInt npart)EPSKrylovSchurSetPartitions_KrylovSchur474,17170 #undef __FUNCT____FUNCT__496,17946 #define __FUNCT__ __FUNCT__497,17963 PetscErrorCode EPSKrylovSchurSetPartitions(EPS eps,PetscInt npart)EPSKrylovSchurSetPartitions525,18899 #undef __FUNCT____FUNCT__536,19240 #define __FUNCT__ __FUNCT__537,19257 static PetscErrorCode EPSKrylovSchurGetPartitions_KrylovSchur(EPS eps,PetscInt *npart)EPSKrylovSchurGetPartitions_KrylovSchur538,19317 #undef __FUNCT____FUNCT__547,19536 #define __FUNCT__ __FUNCT__548,19553 PetscErrorCode EPSKrylovSchurGetPartitions(EPS eps,PetscInt *npart)EPSKrylovSchurGetPartitions565,19920 #undef __FUNCT____FUNCT__576,20246 #define __FUNCT__ __FUNCT__577,20263 static PetscErrorCode EPSKrylovSchurSetDetectZeros_KrylovSchur(EPS eps,PetscBool detect)EPSKrylovSchurSetDetectZeros_KrylovSchur578,20324 #undef __FUNCT____FUNCT__588,20580 #define __FUNCT__ __FUNCT__589,20597 PetscErrorCode EPSKrylovSchurSetDetectZeros(EPS eps,PetscBool detect)EPSKrylovSchurSetDetectZeros616,21495 #undef __FUNCT____FUNCT__627,21844 #define __FUNCT__ __FUNCT__628,21861 static PetscErrorCode EPSKrylovSchurGetDetectZeros_KrylovSchur(EPS eps,PetscBool *detect)EPSKrylovSchurGetDetectZeros_KrylovSchur629,21922 #undef __FUNCT____FUNCT__638,22145 #define __FUNCT__ __FUNCT__639,22162 PetscErrorCode EPSKrylovSchurGetDetectZeros(EPS eps,PetscBool *detect)EPSKrylovSchurGetDetectZeros656,22555 #undef __FUNCT____FUNCT__667,22888 #define __FUNCT__ __FUNCT__668,22905 static PetscErrorCode EPSKrylovSchurSetDimensions_KrylovSchur(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)EPSKrylovSchurSetDimensions_KrylovSchur669,22965 #undef __FUNCT____FUNCT__692,23805 #define __FUNCT__ __FUNCT__693,23822 PetscErrorCode EPSKrylovSchurSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)EPSKrylovSchurSetDimensions716,24697 #undef __FUNCT____FUNCT__729,25174 #define __FUNCT__ __FUNCT__730,25191 static PetscErrorCode EPSKrylovSchurGetDimensions_KrylovSchur(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)EPSKrylovSchurGetDimensions_KrylovSchur731,25251 #undef __FUNCT____FUNCT__742,25556 #define __FUNCT__ __FUNCT__743,25573 PetscErrorCode EPSKrylovSchurGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)EPSKrylovSchurGetDimensions762,26123 #undef __FUNCT____FUNCT__772,26471 #define __FUNCT__ __FUNCT__773,26488 static PetscErrorCode EPSKrylovSchurSetSubintervals_KrylovSchur(EPS eps,PetscReal* subint)EPSKrylovSchurSetSubintervals_KrylovSchur774,26550 #undef __FUNCT____FUNCT__791,27436 #define __FUNCT__ __FUNCT__792,27453 PetscErrorCode EPSKrylovSchurSetSubintervals(EPS eps,PetscReal *subint)EPSKrylovSchurSetSubintervals817,28374 #undef __FUNCT____FUNCT__827,28678 #define __FUNCT__ __FUNCT__828,28695 static PetscErrorCode EPSKrylovSchurGetSubintervals_KrylovSchur(EPS eps,PetscReal **subint)EPSKrylovSchurGetSubintervals_KrylovSchur829,28757 #undef __FUNCT____FUNCT__845,29426 #define __FUNCT__ __FUNCT__846,29443 PetscErrorCode EPSKrylovSchurGetSubintervals(EPS eps,PetscReal** subint)EPSKrylovSchurGetSubintervals880,30439 #undef __FUNCT____FUNCT__891,30776 #define __FUNCT__ __FUNCT__892,30793 static PetscErrorCode EPSKrylovSchurGetInertias_KrylovSchur(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)EPSKrylovSchurGetInertias_KrylovSchur893,30851 #undef __FUNCT____FUNCT__936,32321 #define __FUNCT__ __FUNCT__937,32338 PetscErrorCode EPSKrylovSchurGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)EPSKrylovSchurGetInertias967,33334 #undef __FUNCT____FUNCT__978,33725 #define __FUNCT__ __FUNCT__979,33742 static PetscErrorCode EPSKrylovSchurGetSubcommInfo_KrylovSchur(EPS eps,PetscInt *k,PetscInt *n,Vec *v)EPSKrylovSchurGetSubcommInfo_KrylovSchur980,33803 #undef __FUNCT____FUNCT__997,34508 #define __FUNCT__ __FUNCT__998,34525 PetscErrorCode EPSKrylovSchurGetSubcommInfo(EPS eps,PetscInt *k,PetscInt *n,Vec *v)EPSKrylovSchurGetSubcommInfo1024,35373 #undef __FUNCT____FUNCT__1034,35701 #define __FUNCT__ __FUNCT__1035,35718 static PetscErrorCode EPSKrylovSchurGetSubcommPairs_KrylovSchur(EPS eps,PetscInt i,PetscScalar *eig,Vec v)EPSKrylovSchurGetSubcommPairs_KrylovSchur1036,35780 #undef __FUNCT____FUNCT__1051,36487 #define __FUNCT__ __FUNCT__1052,36504 PetscErrorCode EPSKrylovSchurGetSubcommPairs(EPS eps,PetscInt i,PetscScalar *eig,Vec v)EPSKrylovSchurGetSubcommPairs1079,37447 #undef __FUNCT____FUNCT__1090,37831 #define __FUNCT__ __FUNCT__1091,37848 static PetscErrorCode EPSKrylovSchurGetSubcommMats_KrylovSchur(EPS eps,Mat *A,Mat *B)EPSKrylovSchurGetSubcommMats_KrylovSchur1092,37909 #undef __FUNCT____FUNCT__1104,38447 #define __FUNCT__ __FUNCT__1105,38464 PetscErrorCode EPSKrylovSchurGetSubcommMats(EPS eps,Mat *A,Mat *B)EPSKrylovSchurGetSubcommMats1129,39248 #undef __FUNCT____FUNCT__1139,39542 #define __FUNCT__ __FUNCT__1140,39559 static PetscErrorCode EPSKrylovSchurUpdateSubcommMats_KrylovSchur(EPS eps,PetscScalar a,PetscScalar ap,Mat Au,PetscScalar b,PetscScalar bp, Mat Bu,MatStructure str,PetscBool globalup)EPSKrylovSchurUpdateSubcommMats_KrylovSchur1141,39623 #undef __FUNCT____FUNCT__1197,42242 #define __FUNCT__ __FUNCT__1198,42259 PetscErrorCode EPSKrylovSchurUpdateSubcommMats(EPS eps,PetscScalar s,PetscScalar a,Mat Au,PetscScalar t,PetscScalar b, Mat Bu,MatStructure str,PetscBool globalup)EPSKrylovSchurUpdateSubcommMats1237,43874 #undef __FUNCT____FUNCT__1255,44748 #define __FUNCT__ __FUNCT__1256,44765 PetscErrorCode EPSSetFromOptions_KrylovSchur(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_KrylovSchur1257,44815 #undef __FUNCT____FUNCT__1297,46975 #define __FUNCT__ __FUNCT__1298,46992 PetscErrorCode EPSView_KrylovSchur(EPS eps,PetscViewer viewer)EPSView_KrylovSchur1299,47032 #undef __FUNCT____FUNCT__1321,48169 #define __FUNCT__ __FUNCT__1322,48186 PetscErrorCode EPSDestroy_KrylovSchur(EPS eps)EPSDestroy_KrylovSchur1323,48229 #undef __FUNCT____FUNCT__1349,50200 #define __FUNCT__ __FUNCT__1350,50217 PetscErrorCode EPSReset_KrylovSchur(EPS eps)EPSReset_KrylovSchur1351,50258 #undef __FUNCT____FUNCT__1361,50470 #define __FUNCT__ __FUNCT__1362,50487 PETSC_EXTERN PetscErrorCode EPSCreate_KrylovSchur(EPS eps)EPSCreate_KrylovSchur1363,50529 src/eps/impls/krylov/krylovschur/krylovschur.h,5416 krylovschur.h:^?krylovschur.h^A,1 #define __KRYLOVSCHUR_H__KRYLOVSCHUR_H25,991 typedef struct _n_shift *EPS_shift;EPS_shift36,1530 struct _n_shift {_n_shift37,1566 PetscReal value;value38,1584 PetscInt inertia;inertia39,1607 PetscBool comp[2]; /* Shows completion of subintervals (left and right) */comp40,1632 EPS_shift neighb[2]; /* Adjacent shifts */neighb41,1718 PetscInt index; /* Index in eig where found values are stored */index42,1770 PetscInt neigs; /* Number of values found */neigs43,1849 PetscReal ext[2]; /* Limits for accepted values */ext44,1908 PetscInt nsch[2]; /* Number of missing values for each subinterval */nsch45,1971 PetscInt nconv[2]; /* Converged on each side (accepted or not) */nconv46,2053 struct _n_SR {_n_SR50,2192 PetscReal int0,int1; /* Extremes of the interval */int051,2207 PetscReal int0,int1; /* Extremes of the interval */int151,2207 PetscInt dir; /* Determines the order of values in eig (+1 incr, -1 decr) */dir52,2268 PetscBool hasEnd; /* Tells whether the interval has an end */hasEnd53,2361 PetscInt inertia0,inertia1;inertia054,2435 PetscInt inertia0,inertia1;inertia154,2435 PetscScalar *back;back55,2470 PetscInt numEigs; /* Number of eigenvalues in the interval */numEigs56,2493 PetscInt indexEig;indexEig57,2567 EPS_shift sPres; /* Present shift */sPres58,2593 EPS_shift *pending; /* Pending shifts array */pending59,2643 PetscInt nPend; /* Number of pending shifts */nPend60,2700 PetscInt maxPend; /* Size of "pending" array */maxPend61,2761 PetscInt *idxDef; /* For deflation */idxDef62,2821 PetscInt nMAXCompl;nMAXCompl63,2871 PetscInt iterCompl;iterCompl64,2898 PetscInt itsKs; /* Krylovschur restarts */itsKs65,2925 PetscInt nleap;nleap66,2982 EPS_shift s0; /* Initial shift */s067,3005 PetscScalar *S; /* Matrix for projected problem */S68,3055 PetscInt nS;nS69,3120 EPS_shift sPrev;sPrev70,3140 PetscInt nv; /* position of restart vector */nv71,3163 BV V; /* working basis (for subsolve) */V72,3226 BV Vnext; /* temporary working basis during change of shift */Vnext73,3291 PetscScalar *eigr,*eigi; /* eigenvalues (for subsolve) */eigr74,3374 PetscScalar *eigr,*eigi; /* eigenvalues (for subsolve) */eigi74,3374 PetscReal *errest; /* error estimates (for subsolve) */errest75,3437 PetscInt *perm; /* permutation (for subsolve) */perm76,3504 typedef struct _n_SR *EPS_SR;EPS_SR78,3570 PetscReal keep; /* restart parameter */keep81,3618 PetscBool lock; /* locking/non-locking variant */lock82,3681 EPS_SR sr; /* spectrum slicing context */sr84,3810 PetscInt nev; /* number of eigenvalues to compute */nev85,3880 PetscInt ncv; /* number of basis vectors */ncv86,3958 PetscInt mpd; /* maximum dimension of projected problem */mpd87,4027 PetscInt npart; /* number of partitions of subcommunicator */npart88,4111 PetscBool detect; /* check for zeros during factorizations */detect89,4196 PetscReal *subintervals; /* partition of global interval */subintervals90,4279 PetscBool subintset; /* subintervals set by user */subintset91,4353 PetscMPIInt *nconv_loc; /* converged eigenpairs for each subinterval */nconv_loc92,4423 EPS eps; /* additional eps for slice runs */eps93,4510 PetscBool global; /* flag distinguishing global from local eps */global94,4585 PetscReal *shifts; /* array containing global shifts */shifts95,4672 PetscInt *inertias; /* array containing global inertias */inertias96,4748 PetscInt nshifts; /* elements in the arrays of shifts and inertias */nshifts97,4826 PetscSubcomm subc; /* context for subcommunicators */subc98,4917 MPI_Comm commrank; /* group processes with same rank in subcommunicators */commrank99,4991 PetscBool commset; /* flag indicating that commrank was created */commset100,5087 PetscObjectState Astate,Bstate; /* state of subcommunicator matrices */Astate101,5174 PetscObjectState Astate,Bstate; /* state of subcommunicator matrices */Bstate101,5174 PetscObjectId Aid,Bid; /* Id of subcommunicator matrices */Aid102,5253 PetscObjectId Aid,Bid; /* Id of subcommunicator matrices */Bid102,5253 IS isrow,iscol; /* index sets used in update of subcomm mats */isrow103,5329 IS isrow,iscol; /* index sets used in update of subcomm mats */iscol103,5329 Mat *submata,*submatb; /* seq matrices used in update of subcomm mats */submata104,5416 Mat *submata,*submatb; /* seq matrices used in update of subcomm mats */submatb104,5416 } EPS_KRYLOVSCHUR;EPS_KRYLOVSCHUR105,5505 src/eps/impls/krylov/krylovschur/ks-indef.c,168 ks-indef.c:^?ks-indef.c^A,1 #undef __FUNCT____FUNCT__29,1086 #define __FUNCT__ __FUNCT__30,1103 PetscErrorCode EPSSolve_KrylovSchur_Indefinite(EPS eps)EPSSolve_KrylovSchur_Indefinite31,1155 src/eps/impls/krylov/krylovschur/ks-slice.c,3421 ks-slice.c:^?ks-slice.c^A,1 static PetscBool cited = PETSC_FALSE;cited40,1469 static const char citation[] =citation41,1508 #define SLICE_PTOL SLICE_PTOL53,1930 #undef __FUNCT____FUNCT__55,1977 #define __FUNCT__ __FUNCT__56,1994 static PetscErrorCode EPSSliceResetSR(EPS eps) {EPSSliceResetSR57,2030 #undef __FUNCT____FUNCT__84,2729 #define __FUNCT__ __FUNCT__85,2746 PetscErrorCode EPSReset_KrylovSchur_Slice(EPS eps)EPSReset_KrylovSchur_Slice86,2793 #undef __FUNCT____FUNCT__117,3842 #define __FUNCT__ __FUNCT__118,3859 static PetscErrorCode EPSSliceAllocateSolution(EPS eps,PetscInt extra)EPSSliceAllocateSolution124,4120 #undef __FUNCT____FUNCT__169,6031 #define __FUNCT__ __FUNCT__170,6048 static PetscErrorCode EPSSliceGetEPS(EPS eps)EPSSliceGetEPS171,6083 #undef __FUNCT____FUNCT__328,12711 #define __FUNCT__ __FUNCT__329,12728 static PetscErrorCode EPSSliceGetInertia(EPS eps,PetscReal shift,PetscInt *inertia,PetscInt *zeros)EPSSliceGetInertia330,12767 #undef __FUNCT____FUNCT__359,13789 #define __FUNCT__ __FUNCT__360,13806 PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS eps)EPSSetUp_KrylovSchur_Slice361,13853 #undef __FUNCT____FUNCT__537,23105 #define __FUNCT__ __FUNCT__538,23122 static PetscErrorCode EPSSliceGatherEigenVectors(EPS eps)EPSSliceGatherEigenVectors539,23169 #undef __FUNCT____FUNCT__601,25677 #define __FUNCT__ __FUNCT__602,25694 PetscErrorCode EPSComputeVectors_Slice(EPS eps)EPSComputeVectors_Slice606,25815 #define SWAP(SWAP619,26146 #undef __FUNCT____FUNCT__621,26182 #define __FUNCT__ __FUNCT__622,26199 static PetscErrorCode EPSSliceGetInertias(EPS eps,PetscInt *n,PetscReal **shifts,PetscInt **inertias)EPSSliceGetInertias623,26239 #undef __FUNCT____FUNCT__677,27885 #define __FUNCT__ __FUNCT__678,27902 static PetscErrorCode EPSSliceGatherSolution(EPS eps)EPSSliceGatherSolution679,27945 #undef __FUNCT____FUNCT__773,32905 #define __FUNCT__ __FUNCT__774,32922 static PetscErrorCode EPSCreateShift(EPS eps,PetscReal val,EPS_shift neighb0,EPS_shift neighb1)EPSCreateShift775,32957 #undef __FUNCT____FUNCT__812,34116 #define __FUNCT__ __FUNCT__813,34133 static PetscErrorCode EPSPrepareRational(EPS eps)EPSPrepareRational814,34172 #undef __FUNCT____FUNCT__858,35630 #define __FUNCT__ __FUNCT__859,35647 static PetscErrorCode EPSExtractShift(EPS eps)EPSExtractShift860,35683 #undef __FUNCT____FUNCT__897,37107 #define __FUNCT__ __FUNCT__898,37124 static PetscErrorCode EPSKrylovSchur_Slice(EPS eps)EPSKrylovSchur_Slice899,37165 #undef __FUNCT____FUNCT__1120,45856 #define __FUNCT__ __FUNCT__1121,45873 static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS)EPSGetNewShiftValue1122,45913 #undef __FUNCT____FUNCT__1200,49968 #define __FUNCT__ __FUNCT__1201,49985 static PetscErrorCode sortRealEigenvalues(PetscScalar *r,PetscInt *perm,PetscInt nr,PetscBool prev,PetscInt dir)sortRealEigenvalues1202,50025 #undef __FUNCT____FUNCT__1221,50591 #define __FUNCT__ __FUNCT__1222,50608 static PetscErrorCode EPSStoreEigenpairs(EPS eps)EPSStoreEigenpairs1223,50647 #undef __FUNCT____FUNCT__1278,52899 #define __FUNCT__ __FUNCT__1279,52916 static PetscErrorCode EPSLookForDeflation(EPS eps)EPSLookForDeflation1280,52956 #undef __FUNCT____FUNCT__1350,55700 #define __FUNCT__ __FUNCT__1351,55717 PetscErrorCode EPSSolve_KrylovSchur_Slice(EPS eps)EPSSolve_KrylovSchur_Slice1352,55764 src/eps/impls/krylov/krylovschur/ks-symm.c,156 ks-symm.c:^?ks-symm.c^A,1 #undef __FUNCT____FUNCT__30,1076 #define __FUNCT__ __FUNCT__31,1093 PetscErrorCode EPSSolve_KrylovSchur_Symm(EPS eps)EPSSolve_KrylovSchur_Symm32,1139 src/eps/impls/krylov/krylovschur/makefile,343 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = krylovschur.c ks-symm.c ks-slice.c ks-indef.cSOURCEC26,958 SOURCEF =SOURCEF27,1015 SOURCEH = krylovschur.hSOURCEH28,1026 LIBBASE = libslepcepsLIBBASE29,1051 DIRS =DIRS30,1074 MANSEC = EPSMANSEC31,1085 LOCDIR = src/eps/impls/krylov/krylovschur/LOCDIR32,1100 src/eps/impls/krylov/lanczos/lanczos.c,3609 lanczos.c:^?lanczos.c^A,1 EPSLanczosReorthogType reorthog;reorthog44,1488 BV AV;AV45,1523 } EPS_LANCZOS;EPS_LANCZOS46,1552 #undef __FUNCT____FUNCT__48,1568 #define __FUNCT__ __FUNCT__49,1585 PetscErrorCode EPSSetUp_Lanczos(EPS eps)EPSSetUp_Lanczos50,1622 #undef __FUNCT____FUNCT__100,4056 #define __FUNCT__ __FUNCT__101,4073 static PetscErrorCode EPSLocalLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown)EPSLocalLanczos111,4568 #undef __FUNCT____FUNCT__152,5831 #define __FUNCT__ __FUNCT__153,5848 static PetscErrorCode DenseTridiagonal(PetscInt n_,PetscReal *D,PetscReal *E,PetscReal *w,PetscScalar *V)DenseTridiagonal171,6413 #undef __FUNCT____FUNCT__218,8066 #define __FUNCT__ __FUNCT__219,8083 static PetscErrorCode EPSSelectiveLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscReal anorm)EPSSelectiveLanczos223,8185 #undef __FUNCT____FUNCT__302,10881 #define __FUNCT__ __FUNCT__303,10898 static void update_omega(PetscReal *omega,PetscReal *omega_old,PetscInt j,PetscReal *alpha,PetscReal *beta,PetscReal eps1,PetscReal anorm)update_omega304,10931 #undef __FUNCT____FUNCT__339,12103 #define __FUNCT__ __FUNCT__340,12120 static void compute_int(PetscBool *which,PetscReal *mu,PetscInt j,PetscReal delta,PetscReal eta)compute_int341,12152 #undef __FUNCT____FUNCT__381,13104 #define __FUNCT__ __FUNCT__382,13121 static PetscErrorCode EPSPartialLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscReal anorm)EPSPartialLanczos386,13217 #undef __FUNCT____FUNCT__493,17126 #define __FUNCT__ __FUNCT__494,17143 static PetscErrorCode EPSBasicLanczos(EPS eps,PetscReal *alpha,PetscReal *beta,PetscInt k,PetscInt *m,PetscBool *breakdown,PetscReal anorm)EPSBasicLanczos512,17984 #undef __FUNCT____FUNCT__558,19751 #define __FUNCT__ __FUNCT__559,19768 PetscErrorCode EPSSolve_Lanczos(EPS eps)EPSSolve_Lanczos560,19805 #undef __FUNCT____FUNCT__746,26834 #define __FUNCT__ __FUNCT__747,26851 PetscErrorCode EPSSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_Lanczos748,26897 #undef __FUNCT____FUNCT__765,27600 #define __FUNCT__ __FUNCT__766,27617 static PetscErrorCode EPSLanczosSetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType reorthog)EPSLanczosSetReorthog_Lanczos767,27667 #undef __FUNCT____FUNCT__787,28294 #define __FUNCT__ __FUNCT__788,28311 PetscErrorCode EPSLanczosSetReorthog(EPS eps,EPSLanczosReorthogType reorthog)EPSLanczosSetReorthog807,28869 #undef __FUNCT____FUNCT__818,29236 #define __FUNCT__ __FUNCT__819,29253 static PetscErrorCode EPSLanczosGetReorthog_Lanczos(EPS eps,EPSLanczosReorthogType *reorthog)EPSLanczosGetReorthog_Lanczos820,29303 #undef __FUNCT____FUNCT__829,29534 #define __FUNCT__ __FUNCT__830,29551 PetscErrorCode EPSLanczosGetReorthog(EPS eps,EPSLanczosReorthogType *reorthog)EPSLanczosGetReorthog847,29931 #undef __FUNCT____FUNCT__858,30282 #define __FUNCT__ __FUNCT__859,30299 PetscErrorCode EPSReset_Lanczos(EPS eps)EPSReset_Lanczos860,30336 #undef __FUNCT____FUNCT__870,30555 #define __FUNCT__ __FUNCT__871,30572 PetscErrorCode EPSDestroy_Lanczos(EPS eps)EPSDestroy_Lanczos872,30611 #undef __FUNCT____FUNCT__883,30976 #define __FUNCT__ __FUNCT__884,30993 PetscErrorCode EPSView_Lanczos(EPS eps,PetscViewer viewer)EPSView_Lanczos885,31029 #undef __FUNCT____FUNCT__899,31497 #define __FUNCT__ __FUNCT__900,31514 PETSC_EXTERN PetscErrorCode EPSCreate_Lanczos(EPS eps)EPSCreate_Lanczos901,31552 src/eps/impls/krylov/lanczos/makefile,287 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = lanczos.cSOURCEC26,958 SOURCEF =SOURCEF27,979 SOURCEH =SOURCEH28,990 LIBBASE = libslepcepsLIBBASE29,1001 DIRS =DIRS30,1024 MANSEC = EPSMANSEC31,1035 LOCDIR = src/eps/impls/krylov/lanczos/LOCDIR32,1050 src/eps/impls/krylov/makefile,309 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = epskrylov.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcepsLIBBASE29,1003 DIRS = arnoldi lanczos krylovschurDIRS30,1026 LOCDIR = src/eps/impls/krylov/LOCDIR31,1065 MANSEC = EPSMANSEC32,1098 src/eps/impls/lapack/lapack.c,429 lapack.c:^?lapack.c^A,1 #undef __FUNCT____FUNCT__27,1109 #define __FUNCT__ __FUNCT__28,1126 PetscErrorCode EPSSetUp_LAPACK(EPS eps)EPSSetUp_LAPACK29,1162 #undef __FUNCT____FUNCT__134,5237 #define __FUNCT__ __FUNCT__135,5254 PetscErrorCode EPSSolve_LAPACK(EPS eps)EPSSolve_LAPACK136,5290 #undef __FUNCT____FUNCT__166,6306 #define __FUNCT__ __FUNCT__167,6323 PETSC_EXTERN PetscErrorCode EPSCreate_LAPACK(EPS eps)EPSCreate_LAPACK168,6360 src/eps/impls/lapack/makefile,278 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = lapack.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcepsLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = EPSMANSEC31,1034 LOCDIR = src/eps/impls/lapack/LOCDIR32,1049 src/eps/impls/makefile,187 makefile:^?makefile^A,1 LIBBASE = libslepcepsLIBBASE24,936 DIRS = power subspace krylov davidson cg ciss lapack externalDIRS25,959 LOCDIR = src/eps/impls/LOCDIR26,1025 MANSEC = EPSMANSEC27,1051 src/eps/impls/power/makefile,275 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = power.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcepsLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = EPSMANSEC31,1033 LOCDIR = src/eps/impls/power/LOCDIR32,1048 src/eps/impls/power/power.c,1892 power.c:^?power.c^A,1 EPSPowerShiftType shift_type;shift_type45,1618 } EPS_POWER;EPS_POWER46,1650 #undef __FUNCT____FUNCT__48,1664 #define __FUNCT__ __FUNCT__49,1681 PetscErrorCode EPSSetUp_Power(EPS eps)EPSSetUp_Power50,1716 #undef __FUNCT____FUNCT__82,3695 #define __FUNCT__ __FUNCT__83,3712 PetscErrorCode EPSSolve_Power(EPS eps)EPSSolve_Power84,3747 #undef __FUNCT____FUNCT__214,8600 #define __FUNCT__ __FUNCT__215,8617 PetscErrorCode EPSBackTransform_Power(EPS eps)EPSBackTransform_Power216,8660 #undef __FUNCT____FUNCT__228,8948 #define __FUNCT__ __FUNCT__229,8965 PetscErrorCode EPSSetFromOptions_Power(PetscOptionItems *PetscOptionsObject,EPS eps)EPSSetFromOptions_Power230,9009 #undef __FUNCT____FUNCT__250,9765 #define __FUNCT__ __FUNCT__251,9782 static PetscErrorCode EPSPowerSetShiftType_Power(EPS eps,EPSPowerShiftType shift)EPSPowerSetShiftType_Power252,9829 #undef __FUNCT____FUNCT__269,10293 #define __FUNCT__ __FUNCT__270,10310 PetscErrorCode EPSPowerSetShiftType(EPS eps,EPSPowerShiftType shift)EPSPowerSetShiftType299,11298 #undef __FUNCT____FUNCT__310,11644 #define __FUNCT__ __FUNCT__311,11661 static PetscErrorCode EPSPowerGetShiftType_Power(EPS eps,EPSPowerShiftType *shift)EPSPowerGetShiftType_Power312,11708 #undef __FUNCT____FUNCT__321,11920 #define __FUNCT__ __FUNCT__322,11937 PetscErrorCode EPSPowerGetShiftType(EPS eps,EPSPowerShiftType *shift)EPSPowerGetShiftType339,12276 #undef __FUNCT____FUNCT__350,12606 #define __FUNCT__ __FUNCT__351,12623 PetscErrorCode EPSDestroy_Power(EPS eps)EPSDestroy_Power352,12660 #undef __FUNCT____FUNCT__363,13021 #define __FUNCT__ __FUNCT__364,13038 PetscErrorCode EPSView_Power(EPS eps,PetscViewer viewer)EPSView_Power365,13072 #undef __FUNCT____FUNCT__379,13514 #define __FUNCT__ __FUNCT__380,13531 PETSC_EXTERN PetscErrorCode EPSCreate_Power(EPS eps)EPSCreate_Power381,13567 src/eps/impls/subspace/makefile,282 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = subspace.cSOURCEC26,958 SOURCEF =SOURCEF27,980 SOURCEH =SOURCEH28,991 LIBBASE = libslepcepsLIBBASE29,1002 DIRS =DIRS30,1025 MANSEC = EPSMANSEC31,1036 LOCDIR = src/eps/impls/subspace/LOCDIR32,1051 src/eps/impls/subspace/subspace.c,1123 subspace.c:^?subspace.c^A,1 #undef __FUNCT____FUNCT__39,1287 #define __FUNCT__ __FUNCT__40,1304 PetscErrorCode EPSSetUp_Subspace(EPS eps)EPSSetUp_Subspace41,1342 #undef __FUNCT____FUNCT__69,2724 #define __FUNCT__ __FUNCT__70,2741 static PetscErrorCode EPSSubspaceFindGroup(PetscInt l,PetscInt m,PetscScalar *wr,PetscScalar *wi,PetscReal *rsd,PetscReal grptol,PetscInt *ngrp,PetscReal *ctr,PetscReal *ae,PetscReal *arsd)EPSSubspaceFindGroup82,3236 #undef __FUNCT____FUNCT__118,4064 #define __FUNCT__ __FUNCT__119,4081 static PetscErrorCode EPSSubspaceResidualNorms(BV V,BV AV,PetscScalar *T,PetscInt l,PetscInt m,PetscInt ldt,Vec w,PetscReal *rsd)EPSSubspaceResidualNorms126,4394 #undef __FUNCT____FUNCT__156,5223 #define __FUNCT__ __FUNCT__157,5240 PetscErrorCode EPSSolve_Subspace(EPS eps)EPSSolve_Subspace158,5278 #undef __FUNCT____FUNCT__322,11935 #define __FUNCT__ __FUNCT__323,11952 PetscErrorCode EPSDestroy_Subspace(EPS eps)EPSDestroy_Subspace324,11992 #undef __FUNCT____FUNCT__333,12158 #define __FUNCT__ __FUNCT__334,12175 PETSC_EXTERN PetscErrorCode EPSCreate_Subspace(EPS eps)EPSCreate_Subspace335,12214 src/eps/interface/dlregiseps.c,2014 dlregiseps.c:^?dlregiseps.c^A,1 static PetscBool EPSPackageInitialized = PETSC_FALSE;EPSPackageInitialized24,960 const char *EPSBalanceTypes[] = {"NONE","ONESIDE","TWOSIDE","USER","EPSBalance","EPS_BALANCE_",0};EPSBalanceTypes26,1015 const char *EPSErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","EPSErrorType","EPS_ERROR_",0};EPSErrorTypes27,1114 const char *EPSPowerShiftTypes[] = {"CONSTANT","RAYLEIGH","WILKINSON","EPSPowerShiftType","EPS_POWER_SHIFT_",0};EPSPowerShiftTypes28,1210 const char *EPSLanczosReorthogTypes[] = {"LOCAL","FULL","SELECTIVE","PERIODIC","PARTIAL","DELAYED","EPSLanczosReorthogType","EPS_LANCZOS_REORTHOG_",0};EPSLanczosReorthogTypes29,1323 const char *EPSPRIMMEMethods[] = {"DYNAMIC","DEFAULT_MIN_TIME","DEFAULT_MIN_MATVECS","ARNOLDI","GD","GD_PLUSK","GD_OLSEN_PLUSK","JD_OLSEN_PLUSK","RQI","JDQR","JDQMR","JDQMR_ETOL","SUBSPACE_ITERATION","LOBPCG_ORTHOBASIS","LOBPCG_ORTHOBASISW","EPSPRIMMEMethod","EPS_PRIMME_",0};EPSPRIMMEMethods30,1475 const char *EPSCISSQuadRules[] = {"(not set yet)","TRAPEZOIDAL","CHEBYSHEV","EPSCISSQuadRule","EPS_CISS_QUADRULE_",0};EPSCISSQuadRules31,1752 const char *EPSCISSExtractions[] = {"RITZ","HANKEL","EPSCISSExtraction","EPS_CISS_EXTRACTION_",0};EPSCISSExtractions32,1871 const char *const EPSConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","EPSConvergedReason","EPS_",0};EPSConvergedReasons_Shifted33,1970 const char *const*EPSConvergedReasons = EPSConvergedReasons_Shifted + 4;EPSConvergedReasons34,2172 #undef __FUNCT____FUNCT__36,2246 #define __FUNCT__ __FUNCT__37,2263 PetscErrorCode EPSFinalizePackage(void)EPSFinalizePackage46,2495 #undef __FUNCT____FUNCT__57,2749 #define __FUNCT__ __FUNCT__58,2766 PetscErrorCode EPSInitializePackage()EPSInitializePackage68,3090 #undef __FUNCT____FUNCT__107,4439 #define __FUNCT__ __FUNCT__108,4456 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepceps()PetscDLLibraryRegister_slepceps116,4706 src/eps/interface/epsbasic.c,3358 epsbasic.c:^?epsbasic.c^A,1 PetscFunctionList EPSList = 0;EPSList26,1046 PetscBool EPSRegisterAllCalled = PETSC_FALSE;EPSRegisterAllCalled27,1077 PetscClassId EPS_CLASSID = 0;EPS_CLASSID28,1131 PetscLogEvent EPS_SetUp = 0,EPS_Solve = 0;EPS_SetUp29,1166 PetscLogEvent EPS_SetUp = 0,EPS_Solve = 0;EPS_Solve29,1166 #undef __FUNCT____FUNCT__31,1214 #define __FUNCT__ __FUNCT__32,1231 PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps)EPSCreate51,1580 #undef __FUNCT____FUNCT__127,3878 #define __FUNCT__ __FUNCT__128,3895 PetscErrorCode EPSSetType(EPS eps,EPSType type)EPSSetType158,4845 #undef __FUNCT____FUNCT__182,5669 #define __FUNCT__ __FUNCT__183,5686 PetscErrorCode EPSGetType(EPS eps,EPSType *type)EPSGetType199,5965 #undef __FUNCT____FUNCT__208,6184 #define __FUNCT__ __FUNCT__209,6201 PetscErrorCode EPSRegister(const char *name,PetscErrorCode (*function)(EPS))EPSRegister236,6820 #undef __FUNCT____FUNCT__245,7043 #define __FUNCT__ __FUNCT__246,7060 PetscErrorCode EPSReset(EPS eps)EPSReset260,7335 #undef __FUNCT____FUNCT__283,8118 #define __FUNCT__ __FUNCT__284,8135 PetscErrorCode EPSDestroy(EPS *eps)EPSDestroy297,8381 #undef __FUNCT____FUNCT__322,9393 #define __FUNCT__ __FUNCT__323,9410 PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)EPSSetTarget348,10108 #undef __FUNCT____FUNCT__361,10486 #define __FUNCT__ __FUNCT__362,10503 PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)EPSGetTarget381,10844 #undef __FUNCT____FUNCT__390,11063 #define __FUNCT__ __FUNCT__391,11080 PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb)EPSSetInterval420,12069 #undef __FUNCT____FUNCT__433,12532 #define __FUNCT__ __FUNCT__434,12549 PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb)EPSGetInterval454,12960 #undef __FUNCT____FUNCT__465,13251 #define __FUNCT__ __FUNCT__466,13268 PetscErrorCode EPSSetST(EPS eps,ST st)EPSSetST484,13706 #undef __FUNCT____FUNCT__499,14154 #define __FUNCT__ __FUNCT__500,14171 PetscErrorCode EPSGetST(EPS eps,ST *st)EPSGetST517,14514 #undef __FUNCT____FUNCT__532,14909 #define __FUNCT__ __FUNCT__533,14926 PetscErrorCode EPSSetBV(EPS eps,BV V)EPSSetBV551,15335 #undef __FUNCT____FUNCT__566,15775 #define __FUNCT__ __FUNCT__567,15792 PetscErrorCode EPSGetBV(EPS eps,BV *V)EPSGetBV583,16102 #undef __FUNCT____FUNCT__598,16490 #define __FUNCT__ __FUNCT__599,16507 PetscErrorCode EPSSetRG(EPS eps,RG rg)EPSSetRG617,16893 #undef __FUNCT____FUNCT__632,17341 #define __FUNCT__ __FUNCT__633,17358 PetscErrorCode EPSGetRG(EPS eps,RG *rg)EPSGetRG649,17648 #undef __FUNCT____FUNCT__664,18043 #define __FUNCT__ __FUNCT__665,18060 PetscErrorCode EPSSetDS(EPS eps,DS ds)EPSSetDS683,18467 #undef __FUNCT____FUNCT__698,18915 #define __FUNCT__ __FUNCT__699,18932 PetscErrorCode EPSGetDS(EPS eps,DS *ds)EPSGetDS715,19243 #undef __FUNCT____FUNCT__730,19638 #define __FUNCT__ __FUNCT__731,19655 PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is)EPSIsGeneralized748,19987 #undef __FUNCT____FUNCT__757,20197 #define __FUNCT__ __FUNCT__758,20214 PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is)EPSIsHermitian775,20542 #undef __FUNCT____FUNCT__784,20748 #define __FUNCT__ __FUNCT__785,20765 PetscErrorCode EPSIsPositive(EPS eps,PetscBool* is)EPSIsPositive802,21139 src/eps/interface/epsdefault.c,2207 epsdefault.c:^?epsdefault.c^A,1 #undef __FUNCT____FUNCT__27,1082 #define __FUNCT__ __FUNCT__28,1099 PetscErrorCode EPSBackTransform_Default(EPS eps)EPSBackTransform_Default29,1144 #undef __FUNCT____FUNCT__38,1350 #define __FUNCT__ __FUNCT__39,1367 PetscErrorCode EPSComputeVectors_Hermitian(EPS eps)EPSComputeVectors_Hermitian44,1549 #undef __FUNCT____FUNCT__68,2283 #define __FUNCT__ __FUNCT__69,2300 PetscErrorCode EPSComputeVectors_Indefinite(EPS eps)EPSComputeVectors_Indefinite74,2448 #undef __FUNCT____FUNCT__131,4255 #define __FUNCT__ __FUNCT__132,4272 PetscErrorCode EPSComputeVectors_Schur(EPS eps)EPSComputeVectors_Schur141,4659 #undef __FUNCT____FUNCT__221,7257 #define __FUNCT__ __FUNCT__222,7274 PetscErrorCode EPSSetWorkVecs(EPS eps,PetscInt nw)EPSSetWorkVecs238,7636 #undef __FUNCT____FUNCT__255,8130 #define __FUNCT__ __FUNCT__256,8147 PetscErrorCode EPSSetWhichEigenpairs_Default(EPS eps)EPSSetWhichEigenpairs_Default261,8295 #undef __FUNCT____FUNCT__273,8645 #define __FUNCT__ __FUNCT__274,8662 PetscErrorCode EPSConvergedRelative(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)EPSConvergedRelative278,8781 #undef __FUNCT____FUNCT__288,9027 #define __FUNCT__ __FUNCT__289,9044 PetscErrorCode EPSConvergedAbsolute(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)EPSConvergedAbsolute293,9147 #undef __FUNCT____FUNCT__300,9338 #define __FUNCT__ __FUNCT__301,9355 PetscErrorCode EPSConvergedNorm(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)EPSConvergedNorm306,9489 #undef __FUNCT____FUNCT__316,9757 #define __FUNCT__ __FUNCT__317,9774 PetscErrorCode EPSStoppingBasic(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)EPSStoppingBasic350,10898 #undef __FUNCT____FUNCT__366,11527 #define __FUNCT__ __FUNCT__367,11544 PetscErrorCode EPSComputeRitzVector(EPS eps,PetscScalar *Zr,PetscScalar *Zi,BV V,Vec x,Vec y)EPSComputeRitzVector377,11840 #undef __FUNCT____FUNCT__427,13474 #define __FUNCT__ __FUNCT__428,13491 PetscErrorCode EPSBuildBalance_Krylov(EPS eps)EPSBuildBalance_Krylov433,13685 src/eps/interface/epsmon.c,2314 epsmon.c:^?epsmon.c^A,1 #undef __FUNCT____FUNCT__27,1047 #define __FUNCT__ __FUNCT__28,1064 PetscErrorCode EPSMonitor(EPS eps,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)EPSMonitor32,1153 #undef __FUNCT____FUNCT__44,1534 #define __FUNCT__ __FUNCT__45,1551 PetscErrorCode EPSMonitorSet(EPS eps,PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))EPSMonitorSet93,3565 #undef __FUNCT____FUNCT__104,4180 #define __FUNCT__ __FUNCT__105,4197 PetscErrorCode EPSMonitorCancel(EPS eps)EPSMonitorCancel123,4671 #undef __FUNCT____FUNCT__139,5048 #define __FUNCT__ __FUNCT__140,5065 PetscErrorCode EPSGetMonitorContext(EPS eps,void **ctx)EPSGetMonitorContext157,5417 #undef __FUNCT____FUNCT__165,5606 #define __FUNCT__ __FUNCT__166,5623 PetscErrorCode EPSMonitorAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)EPSMonitorAll187,6240 #undef __FUNCT____FUNCT__224,8029 #define __FUNCT__ __FUNCT__225,8046 PetscErrorCode EPSMonitorFirst(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)EPSMonitorFirst246,8661 #undef __FUNCT____FUNCT__281,10411 #define __FUNCT__ __FUNCT__282,10428 PetscErrorCode EPSMonitorConverged(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)EPSMonitorConverged303,11006 #undef __FUNCT____FUNCT__343,12859 #define __FUNCT__ __FUNCT__344,12876 PetscErrorCode EPSMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)EPSMonitorLGCreate373,13676 #undef __FUNCT____FUNCT__389,14222 #define __FUNCT__ __FUNCT__390,14239 PetscErrorCode EPSMonitorLG(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)EPSMonitorLG391,14272 #undef __FUNCT____FUNCT__415,15118 #define __FUNCT__ __FUNCT__416,15135 PetscErrorCode EPSMonitorLGAll(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)EPSMonitorLGAll417,15171 src/eps/interface/epsopts.c,6189 epsopts.c:^?epsopts.c^A,1 #undef __FUNCT____FUNCT__28,1105 #define __FUNCT__ __FUNCT__29,1122 PetscErrorCode EPSMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)EPSMonitorSetFromOptions48,1750 #undef __FUNCT____FUNCT__69,2777 #define __FUNCT__ __FUNCT__70,2794 PetscErrorCode EPSConvMonitorSetFromOptions(EPS eps,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))EPSConvMonitorSetFromOptions88,3402 #undef __FUNCT____FUNCT__106,4303 #define __FUNCT__ __FUNCT__107,4320 PetscErrorCode EPSSetFromOptions(EPS eps)EPSSetFromOptions123,4709 #undef __FUNCT____FUNCT__311,18295 #define __FUNCT__ __FUNCT__312,18312 PetscErrorCode EPSGetTolerances(EPS eps,PetscReal *tol,PetscInt *maxits)EPSGetTolerances333,18768 #undef __FUNCT____FUNCT__342,19012 #define __FUNCT__ __FUNCT__343,19029 PetscErrorCode EPSSetTolerances(EPS eps,PetscReal tol,PetscInt maxits)EPSSetTolerances366,19642 #undef __FUNCT____FUNCT__389,20452 #define __FUNCT__ __FUNCT__390,20469 PetscErrorCode EPSGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)EPSGetDimensions409,20945 #undef __FUNCT____FUNCT__419,21212 #define __FUNCT__ __FUNCT__420,21229 PetscErrorCode EPSSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)EPSSetDimensions459,22710 #undef __FUNCT____FUNCT__484,23647 #define __FUNCT__ __FUNCT__485,23664 PetscErrorCode EPSSetWhichEigenpairs(EPS eps,EPSWhich which)EPSSetWhichEigenpairs546,26431 #undef __FUNCT____FUNCT__576,27251 #define __FUNCT__ __FUNCT__577,27268 PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which)EPSGetWhichEigenpairs597,27715 #undef __FUNCT____FUNCT__606,27930 #define __FUNCT__ __FUNCT__607,27947 PetscErrorCode EPSSetEigenvalueComparison(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)EPSSetEigenvalueComparison639,29089 #undef __FUNCT____FUNCT__649,29446 #define __FUNCT__ __FUNCT__650,29463 PetscErrorCode EPSSetArbitrarySelection(EPS eps,PetscErrorCode (*func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*),void* ctx)EPSSetArbitrarySelection698,31648 #undef __FUNCT____FUNCT__708,31991 #define __FUNCT__ __FUNCT__709,32008 PetscErrorCode EPSSetConvergenceTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))EPSSetConvergenceTestFunction740,33168 #undef __FUNCT____FUNCT__759,33898 #define __FUNCT__ __FUNCT__760,33915 PetscErrorCode EPSSetConvergenceTest(EPS eps,EPSConv conv)EPSSetConvergenceTest788,34959 #undef __FUNCT____FUNCT__805,35555 #define __FUNCT__ __FUNCT__806,35572 PetscErrorCode EPSGetConvergenceTest(EPS eps,EPSConv *conv)EPSGetConvergenceTest823,35962 #undef __FUNCT____FUNCT__832,36172 #define __FUNCT__ __FUNCT__833,36189 PetscErrorCode EPSSetStoppingTestFunction(EPS eps,PetscErrorCode (*func)(EPS,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))EPSSetStoppingTestFunction867,37515 #undef __FUNCT____FUNCT__884,38114 #define __FUNCT__ __FUNCT__885,38131 PetscErrorCode EPSSetStoppingTest(EPS eps,EPSStop stop)EPSSetStoppingTest909,38860 #undef __FUNCT____FUNCT__924,39314 #define __FUNCT__ __FUNCT__925,39331 PetscErrorCode EPSGetStoppingTest(EPS eps,EPSStop *stop)EPSGetStoppingTest942,39709 #undef __FUNCT____FUNCT__951,39916 #define __FUNCT__ __FUNCT__952,39933 PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type)EPSSetProblemType987,41404 #undef __FUNCT____FUNCT__1032,42747 #define __FUNCT__ __FUNCT__1033,42764 PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type)EPSGetProblemType1049,43077 #undef __FUNCT____FUNCT__1058,43298 #define __FUNCT__ __FUNCT__1059,43315 PetscErrorCode EPSSetExtraction(EPS eps,EPSExtraction extr)EPSSetExtraction1093,44447 #undef __FUNCT____FUNCT__1102,44680 #define __FUNCT__ __FUNCT__1103,44697 PetscErrorCode EPSGetExtraction(EPS eps,EPSExtraction *extr)EPSGetExtraction1119,45007 #undef __FUNCT____FUNCT__1128,45224 #define __FUNCT__ __FUNCT__1129,45241 PetscErrorCode EPSSetBalance(EPS eps,EPSBalance bal,PetscInt its,PetscReal cutoff)EPSSetBalance1172,46957 #undef __FUNCT____FUNCT__1202,48068 #define __FUNCT__ __FUNCT__1203,48085 PetscErrorCode EPSGetBalance(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff)EPSGetBalance1225,48582 #undef __FUNCT____FUNCT__1235,48887 #define __FUNCT__ __FUNCT__1236,48904 PetscErrorCode EPSSetTrueResidual(EPS eps,PetscBool trueres)EPSSetTrueResidual1264,49964 #undef __FUNCT____FUNCT__1273,50201 #define __FUNCT__ __FUNCT__1274,50218 PetscErrorCode EPSGetTrueResidual(EPS eps,PetscBool *trueres)EPSGetTrueResidual1291,50557 #undef __FUNCT____FUNCT__1300,50778 #define __FUNCT__ __FUNCT__1301,50795 PetscErrorCode EPSSetTrackAll(EPS eps,PetscBool trackall)EPSSetTrackAll1325,51552 #undef __FUNCT____FUNCT__1334,51789 #define __FUNCT__ __FUNCT__1335,51806 PetscErrorCode EPSGetTrackAll(EPS eps,PetscBool *trackall)EPSGetTrackAll1352,52128 #undef __FUNCT____FUNCT__1361,52349 #define __FUNCT__ __FUNCT__1362,52366 PetscErrorCode EPSSetPurify(EPS eps,PetscBool purify)EPSSetPurify1385,53139 #undef __FUNCT____FUNCT__1394,53366 #define __FUNCT__ __FUNCT__1395,53383 PetscErrorCode EPSGetPurify(EPS eps,PetscBool *purify)EPSGetPurify1412,53690 #undef __FUNCT____FUNCT__1421,53901 #define __FUNCT__ __FUNCT__1422,53918 PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix)EPSSetOptionsPrefix1449,54659 #undef __FUNCT____FUNCT__1467,55416 #define __FUNCT__ __FUNCT__1468,55433 PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix)EPSAppendOptionsPrefix1487,55982 #undef __FUNCT____FUNCT__1505,56748 #define __FUNCT__ __FUNCT__1506,56765 PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[])EPSGetOptionsPrefix1527,57268 src/eps/interface/epsregis.c,131 epsregis.c:^?epsregis.c^A,1 #undef __FUNCT____FUNCT__54,2096 #define __FUNCT__ __FUNCT__55,2113 PetscErrorCode EPSRegisterAll(void)EPSRegisterAll65,2296 src/eps/interface/epssetup.c,1132 epssetup.c:^?epssetup.c^A,1 #undef __FUNCT____FUNCT__26,1033 #define __FUNCT__ __FUNCT__27,1050 PetscErrorCode EPSSetUp(EPS eps)EPSSetUp47,1654 #undef __FUNCT____FUNCT__235,8886 #define __FUNCT__ __FUNCT__236,8903 PetscErrorCode EPSSetOperators(EPS eps,Mat A,Mat B)EPSSetOperators257,9522 #undef __FUNCT____FUNCT__292,10729 #define __FUNCT__ __FUNCT__293,10746 PetscErrorCode EPSGetOperators(EPS eps,Mat *A,Mat *B)EPSGetOperators310,11173 #undef __FUNCT____FUNCT__330,11649 #define __FUNCT__ __FUNCT__331,11666 PetscErrorCode EPSSetDeflationSpace(EPS eps,PetscInt n,Vec *v)EPSSetDeflationSpace359,12575 #undef __FUNCT____FUNCT__372,13032 #define __FUNCT__ __FUNCT__373,13049 PetscErrorCode EPSSetInitialSpace(EPS eps,PetscInt n,Vec *is)EPSSetInitialSpace402,13987 #undef __FUNCT____FUNCT__415,14449 #define __FUNCT__ __FUNCT__416,14466 PetscErrorCode EPSSetDimensions_Default(EPS eps,PetscInt nev,PetscInt *ncv,PetscInt *mpd)EPSSetDimensions_Default421,14633 #undef __FUNCT____FUNCT__447,15577 #define __FUNCT__ __FUNCT__448,15594 PetscErrorCode EPSAllocateSolution(EPS eps,PetscInt extra)EPSAllocateSolution466,16085 src/eps/interface/epssolve.c,2271 epssolve.c:^?epssolve.c^A,1 #undef __FUNCT____FUNCT__27,1059 #define __FUNCT__ __FUNCT__28,1076 PetscErrorCode EPSComputeVectors(EPS eps)EPSComputeVectors29,1114 #undef __FUNCT____FUNCT__48,1486 #define __FUNCT__ __FUNCT__49,1503 PetscErrorCode EPSSolve(EPS eps)EPSSolve73,2428 #undef __FUNCT____FUNCT__176,6051 #define __FUNCT__ __FUNCT__177,6068 PetscErrorCode EPSGetIterationNumber(EPS eps,PetscInt *its)EPSGetIterationNumber202,6822 #undef __FUNCT____FUNCT__211,7032 #define __FUNCT__ __FUNCT__212,7049 PetscErrorCode EPSGetConverged(EPS eps,PetscInt *nconv)EPSGetConverged231,7429 #undef __FUNCT____FUNCT__241,7666 #define __FUNCT__ __FUNCT__242,7683 PetscErrorCode EPSGetConvergedReason(EPS eps,EPSConvergedReason *reason)EPSGetConvergedReason270,8513 #undef __FUNCT____FUNCT__280,8770 #define __FUNCT__ __FUNCT__281,8787 PetscErrorCode EPSGetInvariantSubspace(EPS eps,Vec *v)EPSGetInvariantSubspace311,9784 #undef __FUNCT____FUNCT__332,10574 #define __FUNCT__ __FUNCT__333,10591 PetscErrorCode EPSGetEigenpair(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)EPSGetEigenpair373,12129 #undef __FUNCT____FUNCT__387,12676 #define __FUNCT__ __FUNCT__388,12693 PetscErrorCode EPSGetEigenvalue(EPS eps,PetscInt i,PetscScalar *eigr,PetscScalar *eigi)EPSGetEigenvalue415,13484 #undef __FUNCT____FUNCT__434,14006 #define __FUNCT__ __FUNCT__435,14023 PetscErrorCode EPSGetEigenvector(EPS eps,PetscInt i,Vec Vr,Vec Vi)EPSGetEigenvector469,15204 #undef __FUNCT____FUNCT__507,16546 #define __FUNCT__ __FUNCT__508,16563 PetscErrorCode EPSGetErrorEstimate(EPS eps,PetscInt i,PetscReal *errest)EPSGetErrorEstimate531,17093 #undef __FUNCT____FUNCT__542,17478 #define __FUNCT__ __FUNCT__543,17495 PetscErrorCode EPSComputeResidualNorm_Private(EPS eps,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm)EPSComputeResidualNorm_Private553,17816 #undef __FUNCT____FUNCT__605,20076 #define __FUNCT__ __FUNCT__606,20093 PetscErrorCode EPSComputeError(EPS eps,PetscInt i,EPSErrorType type,PetscReal *error)EPSComputeError629,20685 #undef __FUNCT____FUNCT__695,22906 #define __FUNCT__ __FUNCT__696,22923 PetscErrorCode EPSGetStartVector(EPS eps,PetscInt i,PetscBool *breakdown)EPSGetStartVector721,23875 src/eps/interface/epsview.c,2626 epsview.c:^?epsview.c^A,1 #undef __FUNCT____FUNCT__27,1058 #define __FUNCT__ __FUNCT__28,1075 PetscErrorCode EPSView(EPS eps,PetscViewer viewer)EPSView56,1872 #define HERM HERM70,2344 #undef __FUNCT____FUNCT__236,11135 #define __FUNCT__ __FUNCT__237,11152 PetscErrorCode EPSReasonView(EPS eps,PetscViewer viewer)EPSReasonView254,11598 #undef __FUNCT____FUNCT__273,12589 #define __FUNCT__ __FUNCT__274,12606 PetscErrorCode EPSReasonViewFromOptions(EPS eps)EPSReasonViewFromOptions286,12884 #undef __FUNCT____FUNCT__308,13615 #define __FUNCT__ __FUNCT__309,13632 static PetscErrorCode EPSErrorView_ASCII(EPS eps,EPSErrorType etype,PetscViewer viewer)EPSErrorView_ASCII310,13671 #undef __FUNCT____FUNCT__363,15734 #define __FUNCT__ __FUNCT__364,15751 static PetscErrorCode EPSErrorView_DETAIL(EPS eps,EPSErrorType etype,PetscViewer viewer)EPSErrorView_DETAIL365,15791 #define EXLEN EXLEN371,15979 #undef __FUNCT____FUNCT__408,17313 #define __FUNCT__ __FUNCT__409,17330 static PetscErrorCode EPSErrorView_MATLAB(EPS eps,EPSErrorType etype,PetscViewer viewer)EPSErrorView_MATLAB410,17370 #undef __FUNCT____FUNCT__428,17982 #define __FUNCT__ __FUNCT__429,17999 PetscErrorCode EPSErrorView(EPS eps,EPSErrorType etype,PetscViewer viewer)EPSErrorView456,18882 #undef __FUNCT____FUNCT__489,20059 #define __FUNCT__ __FUNCT__490,20076 PetscErrorCode EPSErrorViewFromOptions(EPS eps)EPSErrorViewFromOptions502,20364 #undef __FUNCT____FUNCT__538,21930 #define __FUNCT__ __FUNCT__539,21947 static PetscErrorCode EPSValuesView_DRAW(EPS eps,PetscViewer viewer)EPSValuesView_DRAW540,21986 #undef __FUNCT____FUNCT__571,23019 #define __FUNCT__ __FUNCT__572,23036 static PetscErrorCode EPSValuesView_ASCII(EPS eps,PetscViewer viewer)EPSValuesView_ASCII573,23076 #undef __FUNCT____FUNCT__602,23964 #define __FUNCT__ __FUNCT__603,23981 static PetscErrorCode EPSValuesView_MATLAB(EPS eps,PetscViewer viewer)EPSValuesView_MATLAB604,24022 #undef __FUNCT____FUNCT__633,24897 #define __FUNCT__ __FUNCT__634,24914 PetscErrorCode EPSValuesView(EPS eps,PetscViewer viewer)EPSValuesView651,25281 #undef __FUNCT____FUNCT__685,26536 #define __FUNCT__ __FUNCT__686,26553 PetscErrorCode EPSValuesViewFromOptions(EPS eps)EPSValuesViewFromOptions698,26832 #undef __FUNCT____FUNCT__720,27558 #define __FUNCT__ __FUNCT__721,27575 PetscErrorCode EPSVectorsView(EPS eps,PetscViewer viewer)EPSVectorsView743,28142 #define NMLEN NMLEN748,28267 #undef __FUNCT____FUNCT__773,29150 #define __FUNCT__ __FUNCT__774,29167 PetscErrorCode EPSVectorsViewFromOptions(EPS eps)EPSVectorsViewFromOptions786,29449 src/eps/interface/ftn-custom/makefile,257 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zepsf.cSOURCEC26,996 SOURCEF =SOURCEF27,1015 SOURCEH =SOURCEH28,1026 DIRS =DIRS29,1037 LIBBASE = libslepcepsLIBBASE30,1048 LOCDIR = src/eps/interface/ftn-custom/LOCDIR31,1071 src/eps/interface/ftn-custom/zepsf.c,10138 zepsf.c:^?zepsf.c^A,1 PETSC_EXTERN void epsmonitorall_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)epsmonitorall_86,4292 PETSC_EXTERN void epsmonitorconverged_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)epsmonitorconverged_91,4556 PETSC_EXTERN void epsmonitorfirst_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)epsmonitorfirst_96,4827 PETSC_EXTERN void epsmonitorlg_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)epsmonitorlg_101,5095 PETSC_EXTERN void epsmonitorlgall_(EPS *eps,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)epsmonitorlgall_106,5339 PetscFortranCallbackId monitor;monitor112,5605 PetscFortranCallbackId monitordestroy;monitordestroy113,5639 PetscFortranCallbackId convergence;convergence114,5680 PetscFortranCallbackId convdestroy;convdestroy115,5718 PetscFortranCallbackId stopping;stopping116,5756 PetscFortranCallbackId stopdestroy;stopdestroy117,5791 PetscFortranCallbackId comparison;comparison118,5829 PetscFortranCallbackId arbitrary;arbitrary119,5866 } _cb;_cb120,5902 #undef __FUNCT____FUNCT__123,6002 static PetscErrorCode ourmonitor(EPS eps,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx)ourmonitor125,6050 #undef __FUNCT____FUNCT__130,6368 static PetscErrorCode ourdestroy(void** ctx)ourdestroy132,6416 #undef __FUNCT____FUNCT__138,6583 static PetscErrorCode ourconvergence(EPS eps,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)ourconvergence140,6635 #undef __FUNCT____FUNCT__145,6935 static PetscErrorCode ourconvdestroy(void *ctx)ourconvdestroy147,6987 #undef __FUNCT____FUNCT__153,7153 static PetscErrorCode ourstopping(EPS eps,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,EPSConvergedReason *reason,void *ctx)ourstopping155,7202 #undef __FUNCT____FUNCT__160,7534 static PetscErrorCode ourstopdestroy(void *ctx)ourstopdestroy162,7586 #undef __FUNCT____FUNCT__168,7752 static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)oureigenvaluecomparison170,7813 #undef __FUNCT____FUNCT__176,8139 static PetscErrorCode ourarbitraryfunc(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)ourarbitraryfunc178,8193 PETSC_EXTERN void PETSC_STDCALL epsview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)epsview_184,8519 PETSC_EXTERN void PETSC_STDCALL epsreasonview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)epsreasonview_191,8706 PETSC_EXTERN void PETSC_STDCALL epserrorview_(EPS *eps,EPSErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)epserrorview_198,8905 PETSC_EXTERN void PETSC_STDCALL epsvaluesview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)epsvaluesview_205,9129 PETSC_EXTERN void PETSC_STDCALL epsvectorsview_(EPS *eps,PetscViewer *viewer,PetscErrorCode *ierr)epsvectorsview_212,9328 PETSC_EXTERN void PETSC_STDCALL epssettype_(EPS *eps,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))epssettype_219,9529 PETSC_EXTERN void PETSC_STDCALL epsgettype_(EPS *eps,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))epsgettype_228,9744 PETSC_EXTERN void PETSC_STDCALL epssetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))epssetoptionsprefix_237,10023 PETSC_EXTERN void PETSC_STDCALL epsappendoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))epsappendoptionsprefix_246,10262 PETSC_EXTERN void PETSC_STDCALL epsgetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))epsgetoptionsprefix_255,10507 PETSC_EXTERN void PETSC_STDCALL epsmonitorset_(EPS *eps,void (PETSC_STDCALL *monitor)(EPS*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)epsmonitorset_264,10815 PETSC_EXTERN void PETSC_STDCALL epsconvergedabsolute_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)epsconvergedabsolute_289,12857 PETSC_EXTERN void PETSC_STDCALL epsconvergedrelative_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)epsconvergedrelative_294,13092 PETSC_EXTERN void PETSC_STDCALL epsconvergednorm_(EPS *eps,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)epsconvergednorm_299,13327 PETSC_EXTERN void PETSC_STDCALL epssetconvergencetestfunction_(EPS *eps,void (PETSC_STDCALL *func)(EPS*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)epssetconvergencetestfunction_304,13554 PETSC_EXTERN void PETSC_STDCALL epsstoppingbasic_(EPS *eps,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,EPSConvergedReason *reason,void *ctx,PetscErrorCode *ierr)epsstoppingbasic_325,14818 PETSC_EXTERN void PETSC_STDCALL epssetstoppingtestfunction_(EPS *eps,void (PETSC_STDCALL *func)(EPS*,PetscInt,PetscInt,PetscInt,PetscInt,EPSConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)epssetstoppingtestfunction_330,15072 PETSC_EXTERN void PETSC_STDCALL epsseteigenvaluecomparison_(EPS *eps,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr)epsseteigenvaluecomparison_347,16048 PETSC_EXTERN void PETSC_STDCALL epssetarbitraryselection_(EPS *eps,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,Vec*,Vec*,PetscScalar*,PetscScalar*,void*,PetscErrorCode*),void *ctx,PetscErrorCode *ierr)epssetarbitraryselection_354,16504 PETSC_EXTERN void PETSC_STDCALL epskrylovschursetsubintervals_(EPS *eps,PetscReal *subint,PetscErrorCode *ierr)epskrylovschursetsubintervals_361,16964 PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetsubintervals_(EPS *eps,PetscReal *subint,PetscErrorCode *ierr)epskrylovschurgetsubintervals_367,17165 PETSC_EXTERN void PETSC_STDCALL epskrylovschurgetinertias_(EPS *eps,PetscInt *nshift,PetscReal *shifts,PetscInt *inertias,PetscErrorCode *ierr)epskrylovschurgetinertias_379,17616 src/eps/interface/makefile,367 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = epsmon.c epsbasic.c epsview.c epsdefault.c epsregis.c epsopts.c epssetup.c epssolve.c dlregiseps.cSOURCEC26,958 SOURCEF =SOURCEF27,1068 SOURCEH =SOURCEH28,1079 LIBBASE = libslepcepsLIBBASE29,1090 DIRS =DIRS30,1113 MANSEC = EPSMANSEC31,1124 LOCDIR = src/eps/interface/LOCDIR32,1139 src/eps/makefile,211 makefile:^?makefile^A,1 SOURCEH = ../../include/slepc/private/epsimpl.h ../../include/slepceps.hSOURCEH24,936 DIRS = interface impls examples f90-modDIRS25,1010 LOCDIR = src/eps/LOCDIR26,1054 MANSEC = EPSMANSEC27,1074 src/makefile,77 makefile:^?makefile^A,1 DIRS = sys eps svd pep nep mfnDIRS22,926 LOCDIR = src/LOCDIR24,962 src/mfn/examples/makefile,82 makefile:^?makefile^A,1 LOCDIR = src/mfn/examples/LOCDIR24,932 DIRS = tests tutorialsDIRS25,961 src/mfn/examples/tests/makefile,467 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/mfn/examples/tests/LOCDIR26,978 EXAMPLESC = test1.cEXAMPLESC27,1015 EXAMPLESF =EXAMPLESF28,1036 MANSEC = MFNMANSEC29,1049 TESTS =TESTS30,1066 TESTEXAMPLES_C_NOCOMPLEX = test1.PETSc runtest1_1 runtest1_2 test1.rmTESTEXAMPLES_C_NOCOMPLEX32,1080 DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matricesDATAPATH41,1373 src/mfn/examples/tests/test1.c,204 test1.c:^?test1.c^A,1 static char help[] = "Computes exp(A)*v for a matrix loaded from file.\n\n"help22,924 #undef __FUNCT____FUNCT__28,1142 #define __FUNCT__ __FUNCT__29,1159 int main(int argc,char **argv)main30,1184 src/mfn/examples/tutorials/ex23.c,366 ex23.c:^?ex23.c^A,1 static char help[] = "Computes exp(t*A)*v for a matrix associated with a Markov model.\n\n"help22,924 #undef __FUNCT____FUNCT__34,1305 #define __FUNCT__ __FUNCT__35,1322 int main(int argc,char **argv)main36,1347 #undef __FUNCT____FUNCT__136,5256 #define __FUNCT__ __FUNCT__137,5273 PetscErrorCode MatMarkovModel(PetscInt m,Mat A)MatMarkovModel142,5431 src/mfn/examples/tutorials/ex26.c,216 ex26.c:^?ex26.c^A,1 static char help[] = "Computes the action of the square root of the 2-D Laplacian.\n\n"help22,924 #undef __FUNCT____FUNCT__29,1219 #define __FUNCT__ __FUNCT__30,1236 int main(int argc,char **argv)main31,1261 src/mfn/examples/tutorials/makefile,373 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/mfn/examples/tutorials/LOCDIR26,978 EXAMPLESC = ex23.c ex26.cEXAMPLESC27,1019 EXAMPLESF =EXAMPLESF28,1046 MANSEC = MFNMANSEC29,1059 TESTEXAMPLES_C = ex23.PETSc runex23_1 ex23.rm ex26.PETSc runex26_1 ex26.rmTESTEXAMPLES_C31,1077 src/mfn/f90-mod/makefile,397 makefile:^?makefile^A,1 SPECIALLIB = yesSPECIALLIB28,1120 SPECIALFASTLIB = yesSPECIALFASTLIB29,1141 CFLAGS =CFLAGS32,1164 FFLAGS =FFLAGS33,1177 SOURCEC =SOURCEC34,1190 SOURCEF = slepcmfnmod.FSOURCEF35,1203 SOURCEH =SOURCEH36,1230 LIBBASE = libslepcmfnLIBBASE37,1243 MANSEC = MFNMANSEC38,1268 LOCDIR = src/mfn/f90-mod/LOCDIR39,1285 CLEANFILES = *.modCLEANFILES40,1315 src/mfn/f90-mod/slepcmfnmod.F,87 slepcmfnmod.F:^?slepcmfnmod.F^A,1 module slepcmfndefslepcmfndef22,965 module slepcmfnslepcmfn30,1163 src/mfn/impls/expokit/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = mfnexpokit.cSOURCEC26,958 SOURCEF =SOURCEF27,982 SOURCEH =SOURCEH28,993 LIBBASE = libslepcmfnLIBBASE29,1004 DIRS =DIRS30,1027 MANSEC = MFNMANSEC31,1038 LOCDIR = src/mfn/impls/expokit/LOCDIR32,1053 src/mfn/impls/expokit/mfnexpokit.c,444 mfnexpokit.c:^?mfnexpokit.c^A,1 #undef __FUNCT____FUNCT__39,1336 #define __FUNCT__ __FUNCT__40,1353 PetscErrorCode MFNSetUp_Expokit(MFN mfn)MFNSetUp_Expokit41,1390 #undef __FUNCT____FUNCT__58,1927 #define __FUNCT__ __FUNCT__59,1944 PetscErrorCode MFNSolve_Expokit(MFN mfn,Vec b,Vec x)MFNSolve_Expokit60,1981 #undef __FUNCT____FUNCT__198,6670 #define __FUNCT__ __FUNCT__199,6687 PETSC_EXTERN PetscErrorCode MFNCreate_Expokit(MFN mfn)MFNCreate_Expokit200,6725 src/mfn/impls/krylov/makefile,281 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = mfnkrylov.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcmfnLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = MFNMANSEC31,1037 LOCDIR = src/mfn/impls/krylov/LOCDIR32,1052 src/mfn/impls/krylov/mfnkrylov.c,662 mfnkrylov.c:^?mfnkrylov.c^A,1 #undef __FUNCT____FUNCT__41,1431 #define __FUNCT__ __FUNCT__42,1448 PetscErrorCode MFNSetUp_Krylov(MFN mfn)MFNSetUp_Krylov43,1484 #undef __FUNCT____FUNCT__56,1806 #define __FUNCT__ __FUNCT__57,1823 PetscErrorCode MFNBasicArnoldi(MFN mfn,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscReal *beta,PetscBool *breakdown)MFNBasicArnoldi58,1859 #undef __FUNCT____FUNCT__84,2713 #define __FUNCT__ __FUNCT__85,2730 PetscErrorCode MFNSolve_Krylov(MFN mfn,Vec b,Vec x)MFNSolve_Krylov86,2766 #undef __FUNCT____FUNCT__179,5958 #define __FUNCT__ __FUNCT__180,5975 PETSC_EXTERN PetscErrorCode MFNCreate_Krylov(MFN mfn)MFNCreate_Krylov181,6012 src/mfn/impls/makefile,146 makefile:^?makefile^A,1 LIBBASE = libslepcmfnLIBBASE24,936 DIRS = krylov expokitDIRS25,959 LOCDIR = src/mfn/impls/LOCDIR26,985 MANSEC = MFNMANSEC27,1011 src/mfn/interface/dlregismfn.c,861 dlregismfn.c:^?dlregismfn.c^A,1 static PetscBool MFNPackageInitialized = PETSC_FALSE;MFNPackageInitialized24,960 const char *const MFNConvergedReasons_Shifted[] = {"DIVERGED_BREAKDOWN","DIVERGED_ITS","","","CONVERGED_ITERATING","","CONVERGED_TOL","CONVERGED_ITS","MFNConvergedReason","MFN_",0};MFNConvergedReasons_Shifted26,1015 const char *const*MFNConvergedReasons = MFNConvergedReasons_Shifted + 4;MFNConvergedReasons27,1197 #undef __FUNCT____FUNCT__29,1271 #define __FUNCT__ __FUNCT__30,1288 PetscErrorCode MFNFinalizePackage(void)MFNFinalizePackage39,1520 #undef __FUNCT____FUNCT__50,1774 #define __FUNCT__ __FUNCT__51,1791 PetscErrorCode MFNInitializePackage(void)MFNInitializePackage61,2115 #undef __FUNCT____FUNCT__100,3473 #define __FUNCT__ __FUNCT__101,3490 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcmfn()PetscDLLibraryRegister_slepcmfn109,3740 src/mfn/interface/ftn-custom/makefile,257 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zmfnf.cSOURCEC26,996 SOURCEF =SOURCEF27,1015 SOURCEH =SOURCEH28,1026 DIRS =DIRS29,1037 LIBBASE = libslepcmfnLIBBASE30,1048 LOCDIR = src/mfn/interface/ftn-custom/LOCDIR31,1071 src/mfn/interface/ftn-custom/zmfnf.c,2980 zmfnf.c:^?zmfnf.c^A,1 PETSC_EXTERN void mfnmonitordefault_(MFN *mfn,PetscInt *it,PetscReal *errest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)mfnmonitordefault_53,2259 PETSC_EXTERN void mfnmonitorlg_(MFN *mfn,PetscInt *it,PetscReal *errest,void *ctx,PetscErrorCode *ierr)mfnmonitorlg_58,2442 PetscFortranCallbackId monitor;monitor64,2613 PetscFortranCallbackId monitordestroy;monitordestroy65,2647 } _cb;_cb66,2688 #undef __FUNCT____FUNCT__69,2788 static PetscErrorCode ourmonitor(MFN mfn,PetscInt i,PetscReal d,void* ctx)ourmonitor71,2836 #undef __FUNCT____FUNCT__76,3040 static PetscErrorCode ourdestroy(void** ctx)ourdestroy78,3088 PETSC_EXTERN void PETSC_STDCALL mfnview_(MFN *mfn,PetscViewer *viewer,PetscErrorCode *ierr)mfnview_84,3255 PETSC_EXTERN void PETSC_STDCALL mfnreasonview_(MFN *mfn,PetscViewer *viewer,PetscErrorCode *ierr)mfnreasonview_91,3442 PETSC_EXTERN void PETSC_STDCALL mfnsettype_(MFN *mfn,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))mfnsettype_98,3641 PETSC_EXTERN void PETSC_STDCALL mfngettype_(MFN *mfn,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))mfngettype_107,3856 PETSC_EXTERN void PETSC_STDCALL mfnsetoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))mfnsetoptionsprefix_116,4135 PETSC_EXTERN void PETSC_STDCALL mfnappendoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))mfnappendoptionsprefix_125,4374 PETSC_EXTERN void PETSC_STDCALL mfngetoptionsprefix_(MFN *mfn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))mfngetoptionsprefix_134,4619 PETSC_EXTERN void PETSC_STDCALL mfnmonitorset_(MFN *mfn,void (PETSC_STDCALL *monitor)(MFN*,PetscInt*,PetscReal*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)mfnmonitorset_143,4927 src/mfn/interface/makefile,344 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = mfnmon.c mfnbasic.c mfnregis.c mfnopts.c mfnsetup.c mfnsolve.c dlregismfn.cSOURCEC26,958 SOURCEF =SOURCEF27,1045 SOURCEH =SOURCEH28,1056 LIBBASE = libslepcmfnLIBBASE29,1067 DIRS =DIRS30,1090 MANSEC = MFNMANSEC31,1101 LOCDIR = src/mfn/interface/LOCDIR32,1116 src/mfn/interface/mfnbasic.c,2165 mfnbasic.c:^?mfnbasic.c^A,1 PetscFunctionList MFNList = 0;MFNList26,1045 PetscBool MFNRegisterAllCalled = PETSC_FALSE;MFNRegisterAllCalled27,1076 PetscClassId MFN_CLASSID = 0;MFN_CLASSID28,1130 PetscLogEvent MFN_SetUp = 0,MFN_Solve = 0;MFN_SetUp29,1165 PetscLogEvent MFN_SetUp = 0,MFN_Solve = 0;MFN_Solve29,1165 #undef __FUNCT____FUNCT__31,1213 #define __FUNCT__ __FUNCT__32,1230 PetscErrorCode MFNView(MFN mfn,PetscViewer viewer)MFNView60,2020 #undef __FUNCT____FUNCT__96,3572 #define __FUNCT__ __FUNCT__97,3589 PetscErrorCode MFNReasonView(MFN mfn,PetscViewer viewer)MFNReasonView114,4014 #undef __FUNCT____FUNCT__133,4963 #define __FUNCT__ __FUNCT__134,4980 PetscErrorCode MFNReasonViewFromOptions(MFN mfn)MFNReasonViewFromOptions146,5262 #undef __FUNCT____FUNCT__168,5993 #define __FUNCT__ __FUNCT__169,6010 PetscErrorCode MFNCreate(MPI_Comm comm,MFN *outmfn)MFNCreate188,6354 #undef __FUNCT____FUNCT__223,7244 #define __FUNCT__ __FUNCT__224,7261 PetscErrorCode MFNSetType(MFN mfn,MFNType type)MFNSetType254,8196 #undef __FUNCT____FUNCT__278,9010 #define __FUNCT__ __FUNCT__279,9027 PetscErrorCode MFNGetType(MFN mfn,MFNType *type)MFNGetType295,9310 #undef __FUNCT____FUNCT__304,9529 #define __FUNCT__ __FUNCT__305,9546 PetscErrorCode MFNRegister(const char *name,PetscErrorCode (*function)(MFN))MFNRegister332,10168 #undef __FUNCT____FUNCT__341,10391 #define __FUNCT__ __FUNCT__342,10408 PetscErrorCode MFNReset(MFN mfn)MFNReset356,10693 #undef __FUNCT____FUNCT__367,10946 #define __FUNCT__ __FUNCT__368,10963 PetscErrorCode MFNDestroy(MFN *mfn)MFNDestroy381,11213 #undef __FUNCT____FUNCT__399,11849 #define __FUNCT__ __FUNCT__400,11866 PetscErrorCode MFNSetBV(MFN mfn,BV bv)MFNSetBV418,12288 #undef __FUNCT____FUNCT__433,12733 #define __FUNCT__ __FUNCT__434,12750 PetscErrorCode MFNGetBV(MFN mfn,BV *bv)MFNGetBV451,13072 #undef __FUNCT____FUNCT__466,13463 #define __FUNCT__ __FUNCT__467,13480 PetscErrorCode MFNSetFN(MFN mfn,FN fn)MFNSetFN485,13876 #undef __FUNCT____FUNCT__500,14324 #define __FUNCT__ __FUNCT__501,14341 PetscErrorCode MFNGetFN(MFN mfn,FN *fn)MFNGetFN517,14648 src/mfn/interface/mfnmon.c,1296 mfnmon.c:^?mfnmon.c^A,1 #undef __FUNCT____FUNCT__27,1047 #define __FUNCT__ __FUNCT__28,1064 PetscErrorCode MFNMonitor(MFN mfn,PetscInt it,PetscReal errest)MFNMonitor32,1153 #undef __FUNCT____FUNCT__44,1447 #define __FUNCT__ __FUNCT__45,1464 PetscErrorCode MFNMonitorSet(MFN mfn,PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))MFNMonitorSet83,2877 #undef __FUNCT____FUNCT__94,3447 #define __FUNCT__ __FUNCT__95,3464 PetscErrorCode MFNMonitorCancel(MFN mfn)MFNMonitorCancel113,3942 #undef __FUNCT____FUNCT__129,4319 #define __FUNCT__ __FUNCT__130,4336 PetscErrorCode MFNGetMonitorContext(MFN mfn,void **ctx)MFNGetMonitorContext147,4692 #undef __FUNCT____FUNCT__155,4881 #define __FUNCT__ __FUNCT__156,4898 PetscErrorCode MFNMonitorDefault(MFN mfn,PetscInt its,PetscReal errest,PetscViewerAndFormat *vf)MFNMonitorDefault173,5306 #undef __FUNCT____FUNCT__194,6233 #define __FUNCT__ __FUNCT__195,6250 PetscErrorCode MFNMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)MFNMonitorLGCreate223,6960 #undef __FUNCT____FUNCT__239,7506 #define __FUNCT__ __FUNCT__240,7523 PetscErrorCode MFNMonitorLG(MFN mfn,PetscInt its,PetscReal errest,void *ctx)MFNMonitorLG241,7556 src/mfn/interface/mfnopts.c,1944 mfnopts.c:^?mfnopts.c^A,1 #undef __FUNCT____FUNCT__28,1105 #define __FUNCT__ __FUNCT__29,1122 PetscErrorCode MFNMonitorSetFromOptions(MFN mfn,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(MFN,PetscInt,PetscReal,PetscViewerAndFormat*))MFNMonitorSetFromOptions48,1750 #undef __FUNCT____FUNCT__66,2583 #define __FUNCT__ __FUNCT__67,2600 PetscErrorCode MFNSetFromOptions(MFN mfn)MFNSetFromOptions83,2993 #undef __FUNCT____FUNCT__160,6352 #define __FUNCT__ __FUNCT__161,6369 PetscErrorCode MFNGetTolerances(MFN mfn,PetscReal *tol,PetscInt *maxits)MFNGetTolerances182,6829 #undef __FUNCT____FUNCT__191,7073 #define __FUNCT__ __FUNCT__192,7090 PetscErrorCode MFNSetTolerances(MFN mfn,PetscReal tol,PetscInt maxits)MFNSetTolerances215,7707 #undef __FUNCT____FUNCT__238,8494 #define __FUNCT__ __FUNCT__239,8511 PetscErrorCode MFNGetDimensions(MFN mfn,PetscInt *ncv)MFNGetDimensions255,8858 #undef __FUNCT____FUNCT__264,9060 #define __FUNCT__ __FUNCT__265,9077 PetscErrorCode MFNSetDimensions(MFN mfn,PetscInt ncv)MFNSetDimensions286,9625 #undef __FUNCT____FUNCT__301,10074 #define __FUNCT__ __FUNCT__302,10091 PetscErrorCode MFNSetErrorIfNotConverged(MFN mfn,PetscBool flg)MFNSetErrorIfNotConverged324,10747 #undef __FUNCT____FUNCT__333,10991 #define __FUNCT__ __FUNCT__334,11008 PetscErrorCode MFNGetErrorIfNotConverged(MFN mfn,PetscBool *flag)MFNGetErrorIfNotConverged351,11427 #undef __FUNCT____FUNCT__360,11658 #define __FUNCT__ __FUNCT__361,11675 PetscErrorCode MFNSetOptionsPrefix(MFN mfn,const char *prefix)MFNSetOptionsPrefix388,12420 #undef __FUNCT____FUNCT__402,12929 #define __FUNCT__ __FUNCT__403,12946 PetscErrorCode MFNAppendOptionsPrefix(MFN mfn,const char *prefix)MFNAppendOptionsPrefix422,13499 #undef __FUNCT____FUNCT__436,14014 #define __FUNCT__ __FUNCT__437,14031 PetscErrorCode MFNGetOptionsPrefix(MFN mfn,const char *prefix[])MFNGetOptionsPrefix458,14538 src/mfn/interface/mfnregis.c,131 mfnregis.c:^?mfnregis.c^A,1 #undef __FUNCT____FUNCT__27,1086 #define __FUNCT__ __FUNCT__28,1103 PetscErrorCode MFNRegisterAll(void)MFNRegisterAll38,1284 src/mfn/interface/mfnsetup.c,569 mfnsetup.c:^?mfnsetup.c^A,1 #undef __FUNCT____FUNCT__26,1033 #define __FUNCT__ __FUNCT__27,1050 PetscErrorCode MFNSetUp(MFN mfn)MFNSetUp46,1549 #undef __FUNCT____FUNCT__85,2781 #define __FUNCT__ __FUNCT__86,2798 PetscErrorCode MFNSetOperator(MFN mfn,Mat A)MFNSetOperator104,3232 #undef __FUNCT____FUNCT__123,3832 #define __FUNCT__ __FUNCT__124,3849 PetscErrorCode MFNGetOperator(MFN mfn,Mat *A)MFNGetOperator140,4190 #undef __FUNCT____FUNCT__149,4377 #define __FUNCT__ __FUNCT__150,4394 PetscErrorCode MFNAllocateSolution(MFN mfn,PetscInt extra)MFNAllocateSolution168,4874 src/mfn/interface/mfnsolve.c,477 mfnsolve.c:^?mfnsolve.c^A,1 #undef __FUNCT____FUNCT__26,1036 #define __FUNCT__ __FUNCT__27,1053 PetscErrorCode MFNSolve(MFN mfn,Vec b,Vec x)MFNSolve58,2115 #undef __FUNCT____FUNCT__100,3815 #define __FUNCT__ __FUNCT__101,3832 PetscErrorCode MFNGetIterationNumber(MFN mfn,PetscInt *its)MFNGetIterationNumber126,4590 #undef __FUNCT____FUNCT__135,4800 #define __FUNCT__ __FUNCT__136,4817 PetscErrorCode MFNGetConvergedReason(MFN mfn,MFNConvergedReason *reason)MFNGetConvergedReason169,5943 src/mfn/makefile,211 makefile:^?makefile^A,1 SOURCEH = ../../include/slepc/private/mfnimpl.h ../../include/slepcmfn.hSOURCEH24,936 DIRS = interface impls examples f90-modDIRS25,1010 LOCDIR = src/mfn/LOCDIR26,1054 MANSEC = MFNMANSEC27,1074 src/nep/examples/makefile,88 makefile:^?makefile^A,1 LOCDIR = src/nep/examples/LOCDIR24,932 DIRS = tests tutorials nlevpDIRS25,961 src/nep/examples/nlevp/gun.c,430 gun.c:^?gun.c^A,1 static char help[] = "Radio-frequency gun cavity.\n\n"help36,1533 #define NMAT NMAT42,1830 #define SIGMA SIGMA43,1845 #undef __FUNCT____FUNCT__47,1941 #define __FUNCT__ __FUNCT__48,1958 int main(int argc,char **argv)main49,1983 #undef __FUNCT____FUNCT__159,6623 #define __FUNCT__ __FUNCT__160,6640 PetscErrorCode ComputeSingularities(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *pt)ComputeSingularities167,6913 src/nep/examples/nlevp/loaded_string.c,234 loaded_string.c:^?loaded_string.c^A,1 static char help[] = "Finite element model of a loaded vibrating string.\n\n"help33,1405 #define NMAT NMAT41,1688 #undef __FUNCT____FUNCT__43,1704 #define __FUNCT__ __FUNCT__44,1721 int main(int argc,char **argv)main45,1746 src/nep/examples/nlevp/makefile,523 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/nep/examples/nlevp/LOCDIR26,978 EXAMPLESC = loaded_string.c gun.cEXAMPLESC27,1015 EXAMPLESF = EXAMPLESF28,1050 MANSEC = NEPMANSEC29,1064 TESTS = loaded_string gunTESTS30,1081 TESTEXAMPLES_C = loaded_string.PETSc runloaded_string loaded_string.rmTESTEXAMPLES_C32,1113 TESTEXAMPLES_DATAFILESPATH_COMPLEX = gun.PETSc rungun gun.rmTESTEXAMPLES_DATAFILESPATH_COMPLEX33,1184 src/nep/examples/tests/makefile,330 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/nep/examples/tests/LOCDIR26,978 EXAMPLESC =EXAMPLESC27,1015 EXAMPLESF =EXAMPLESF28,1028 MANSEC = NEPMANSEC29,1041 TESTS =TESTS30,1058 TESTEXAMPLES_C =TESTEXAMPLES_C32,1072 src/nep/examples/tutorials/ex20.c,1172 ex20.c:^?ex20.c^A,1 static char help[] = "Simple 1-D nonlinear eigenproblem.\n\n"help22,924 PetscScalar kappa; /* ratio between stiffness of spring and attached mass */kappa49,1628 PetscReal h; /* mesh spacing */h50,1709 } ApplicationCtx;ApplicationCtx51,1751 #undef __FUNCT____FUNCT__53,1770 #define __FUNCT__ __FUNCT__54,1787 int main(int argc,char **argv)main55,1812 #undef __FUNCT____FUNCT__214,8184 #define __FUNCT__ __FUNCT__215,8201 PetscErrorCode FormInitialGuess(Vec x)FormInitialGuess222,8345 #undef __FUNCT____FUNCT__232,8577 #define __FUNCT__ __FUNCT__233,8594 PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)FormFunction246,8940 #undef __FUNCT____FUNCT__306,10695 #define __FUNCT__ __FUNCT__307,10712 PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx)FormJacobian320,11059 #undef __FUNCT____FUNCT__375,12587 #define __FUNCT__ __FUNCT__376,12604 PetscErrorCode CheckSolution(PetscScalar lambda,Vec y,PetscReal *error,void *ctx)CheckSolution388,12938 #undef __FUNCT____FUNCT__416,13859 #define __FUNCT__ __FUNCT__417,13876 PetscErrorCode FixSign(Vec x)FixSign426,14131 src/nep/examples/tutorials/ex21.c,1918 ex21.c:^?ex21.c^A,1 static char help[] = "Simple 1-D nonlinear eigenproblem (matrix-free version, sequential).\n\n"help22,924 PetscScalar lambda,kappa;lambda53,1776 PetscScalar lambda,kappa;kappa53,1776 PetscReal h;h54,1804 } MatCtx;MatCtx55,1821 PetscScalar kappa; /* ratio between stiffness of spring and attached mass */kappa61,1891 PetscReal h; /* mesh spacing */h62,1972 } ApplicationCtx;ApplicationCtx63,2014 #undef __FUNCT____FUNCT__65,2033 #define __FUNCT__ __FUNCT__66,2050 int main(int argc,char **argv)main67,2075 #undef __FUNCT____FUNCT__181,6957 #define __FUNCT__ __FUNCT__182,6974 PetscErrorCode FormInitialGuess(Vec x)FormInitialGuess189,7118 #undef __FUNCT____FUNCT__199,7350 #define __FUNCT__ __FUNCT__200,7367 PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)FormFunction213,7726 #undef __FUNCT____FUNCT__225,8072 #define __FUNCT__ __FUNCT__226,8089 PetscErrorCode FormJacobian(NEP nep,PetscScalar lambda,Mat jac,void *ctx)FormJacobian239,8449 #undef __FUNCT____FUNCT__251,8789 #define __FUNCT__ __FUNCT__252,8806 PetscErrorCode MatMult_Fun(Mat A,Vec x,Vec y)MatMult_Fun253,8838 #undef __FUNCT____FUNCT__284,9859 #define __FUNCT__ __FUNCT__285,9876 PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag)MatGetDiagonal_Fun286,9915 #undef __FUNCT____FUNCT__308,10599 #define __FUNCT__ __FUNCT__309,10616 PetscErrorCode MatDestroy_Fun(Mat A)MatDestroy_Fun310,10651 #undef __FUNCT____FUNCT__322,10960 #define __FUNCT__ __FUNCT__323,10977 PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B)MatDuplicate_Fun324,11014 #undef __FUNCT____FUNCT__350,12036 #define __FUNCT__ __FUNCT__351,12053 PetscErrorCode MatMult_Jac(Mat A,Vec x,Vec y)MatMult_Jac352,12085 #undef __FUNCT____FUNCT__382,13045 #define __FUNCT__ __FUNCT__383,13062 PetscErrorCode MatDestroy_Jac(Mat A)MatDestroy_Jac384,13097 src/nep/examples/tutorials/ex22.c,184 ex22.c:^?ex22.c^A,1 static char help[] = "Delay differential equation.\n\n"help22,924 #undef __FUNCT____FUNCT__46,1552 #define __FUNCT__ __FUNCT__47,1569 int main(int argc,char **argv)main48,1594 src/nep/examples/tutorials/ex27.c,576 ex27.c:^?ex27.c^A,1 static char help[] = "Simple nonlinear eigenproblem using the NLEIGS solver.\n\n"help22,924 #undef __FUNCT____FUNCT__43,1570 #define __FUNCT__ __FUNCT__44,1587 int main(int argc,char **argv)main45,1612 #undef __FUNCT____FUNCT__179,7325 #define __FUNCT__ __FUNCT__180,7342 PetscErrorCode FormFunction(NEP nep,PetscScalar lambda,Mat fun,Mat B,void *ctx)FormFunction184,7435 #undef __FUNCT____FUNCT__226,8853 #define __FUNCT__ __FUNCT__227,8870 PetscErrorCode ComputeSingularities(NEP nep,PetscInt *maxnp,PetscScalar *xi,void *pt)ComputeSingularities234,9121 src/nep/examples/tutorials/makefile,514 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/nep/examples/tutorials/LOCDIR26,978 EXAMPLESC = ex20.c ex21.c ex22.c ex27.cEXAMPLESC27,1019 EXAMPLESF =EXAMPLESF28,1060 MANSEC = NEPMANSEC29,1073 TESTEXAMPLES_C = ex21.PETSc runex21_1 ex21.rm \TESTEXAMPLES_C31,1091 TESTEXAMPLES_C_COMPLEX = ex22.PETSc runex22_ciss_1 ex22.rmTESTEXAMPLES_C_COMPLEX34,1273 TESTEXAMPLES_F90 =TESTEXAMPLES_F9035,1334 src/nep/f90-mod/makefile,397 makefile:^?makefile^A,1 SPECIALLIB = yesSPECIALLIB28,1120 SPECIALFASTLIB = yesSPECIALFASTLIB29,1141 CFLAGS =CFLAGS32,1164 FFLAGS =FFLAGS33,1177 SOURCEC =SOURCEC34,1190 SOURCEF = slepcnepmod.FSOURCEF35,1203 SOURCEH =SOURCEH36,1230 LIBBASE = libslepcnepLIBBASE37,1243 MANSEC = NEPMANSEC38,1268 LOCDIR = src/nep/f90-mod/LOCDIR39,1285 CLEANFILES = *.modCLEANFILES40,1315 src/nep/f90-mod/slepcnepmod.F,87 slepcnepmod.F:^?slepcnepmod.F^A,1 module slepcnepdefslepcnepdef22,965 module slepcnepslepcnep33,1224 src/nep/impls/ciss/makefile,277 makefile:^?makefile^A,1 CFLAGS =CFLAGS26,964 FFLAGS =FFLAGS27,975 SOURCEC = nciss.cSOURCEC28,986 SOURCEF =SOURCEF29,1005 SOURCEH =SOURCEH30,1016 LIBBASE = libslepcnepLIBBASE31,1027 DIRS =DIRS32,1050 MANSEC = NEPMANSEC33,1061 LOCDIR = src/nep/impls/ciss/LOCDIR34,1076 src/nep/impls/ciss/nciss.c,6530 nciss.c:^?nciss.c^A,1 PetscInt N; /* number of integration points (32) */N49,1724 PetscInt L; /* block size (16) */L50,1791 PetscInt M; /* moment degree (N/4 = 4) */M51,1840 PetscReal delta; /* threshold of singular value (1e-12) */delta52,1897 PetscInt L_max; /* maximum number of columns of the source matrix V */L_max53,1966 PetscReal spurious_threshold; /* discard spurious eigenpairs */spurious_threshold54,2048 PetscBool isreal; /* T(z) is real for real z */isreal55,2117 PetscInt refine_inner;refine_inner56,2174 PetscInt refine_blocksize;refine_blocksize57,2203 PetscReal *sigma; /* threshold for numerical rank */sigma59,2257 PetscInt num_subcomm;num_subcomm60,2319 PetscInt subcomm_id;subcomm_id61,2347 PetscInt num_solve_point;num_solve_point62,2374 PetscScalar *weight;weight63,2406 PetscScalar *omega;omega64,2430 PetscScalar *pp;pp65,2453 BV V;V66,2473 BV S;S67,2491 BV Y;Y68,2509 KSP *ksp;ksp69,2527 Mat *kspMat;kspMat70,2548 PetscBool useconj;useconj71,2572 PetscReal est_eig;est_eig72,2596 PetscSubcomm subcomm;subcomm73,2620 PetscBool usest;usest74,2644 } NEP_CISS;NEP_CISS75,2666 #undef __FUNCT____FUNCT__77,2679 #define __FUNCT__ __FUNCT__78,2696 static PetscErrorCode SetSolverComm(NEP nep)SetSolverComm79,2730 #undef __FUNCT____FUNCT__100,3567 #define __FUNCT__ __FUNCT__101,3584 static PetscErrorCode SetPathParameter(NEP nep)SetPathParameter102,3621 #undef __FUNCT____FUNCT__126,4572 #define __FUNCT__ __FUNCT__127,4589 static PetscErrorCode CISSVecSetRandom(BV V,PetscInt i0,PetscInt i1)CISSVecSetRandom128,4626 #undef __FUNCT____FUNCT__152,5337 #define __FUNCT__ __FUNCT__153,5354 static PetscErrorCode SolveLinearSystem(NEP nep,Mat T,Mat dT,BV V,PetscInt L_start,PetscInt L_end,PetscBool initksp)SolveLinearSystem154,5392 #undef __FUNCT____FUNCT__212,7768 #define __FUNCT__ __FUNCT__213,7785 static PetscErrorCode EstimateNumberEigs(NEP nep,PetscInt *L_add)EstimateNumberEigs214,7824 #undef __FUNCT____FUNCT__255,9443 #define __FUNCT__ __FUNCT__256,9460 static PetscErrorCode CalcMu(NEP nep, PetscScalar *Mu)CalcMu257,9487 #undef __FUNCT____FUNCT__305,11560 #define __FUNCT__ __FUNCT__306,11577 static PetscErrorCode BlockHankel(NEP nep,PetscScalar *Mu,PetscInt s,PetscScalar *H)BlockHankel307,11609 #undef __FUNCT____FUNCT__320,11941 #define __FUNCT__ __FUNCT__321,11958 static PetscErrorCode SVD_H0(NEP nep,PetscScalar *S,PetscInt *K)SVD_H0322,11985 #undef __FUNCT____FUNCT__364,13441 #define __FUNCT__ __FUNCT__365,13458 static PetscErrorCode ConstructS(NEP nep)ConstructS366,13489 #undef __FUNCT____FUNCT__408,15078 #define __FUNCT__ __FUNCT__409,15095 static PetscErrorCode isGhost(NEP nep,PetscInt ld,PetscInt nv,PetscBool *fl)isGhost410,15123 #undef __FUNCT____FUNCT__445,16112 #define __FUNCT__ __FUNCT__446,16129 PetscErrorCode NEPSetUp_CISS(NEP nep)NEPSetUp_CISS447,16163 #undef __FUNCT____FUNCT__517,19599 #define __FUNCT__ __FUNCT__518,19616 PetscErrorCode NEPSolve_CISS(NEP nep)NEPSolve_CISS519,19650 #undef __FUNCT____FUNCT__668,26309 #define __FUNCT__ __FUNCT__669,26326 static PetscErrorCode NEPCISSSetSizes_CISS(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)NEPCISSSetSizes_CISS670,26367 #undef __FUNCT____FUNCT__713,28340 #define __FUNCT__ __FUNCT__714,28357 PetscErrorCode NEPCISSSetSizes(NEP nep,PetscInt ip,PetscInt bs,PetscInt ms,PetscInt npart,PetscInt bsmax,PetscBool realmats)NEPCISSSetSizes750,29683 #undef __FUNCT____FUNCT__766,30370 #define __FUNCT__ __FUNCT__767,30387 static PetscErrorCode NEPCISSGetSizes_CISS(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)NEPCISSGetSizes_CISS768,30428 #undef __FUNCT____FUNCT__782,30852 #define __FUNCT__ __FUNCT__783,30869 PetscErrorCode NEPCISSGetSizes(NEP nep,PetscInt *ip,PetscInt *bs,PetscInt *ms,PetscInt *npart,PetscInt *bsmax,PetscBool *realmats)NEPCISSGetSizes804,31363 #undef __FUNCT____FUNCT__814,31785 #define __FUNCT__ __FUNCT__815,31802 static PetscErrorCode NEPCISSSetThreshold_CISS(NEP nep,PetscReal delta,PetscReal spur)NEPCISSSetThreshold_CISS816,31847 #undef __FUNCT____FUNCT__836,32501 #define __FUNCT__ __FUNCT__837,32518 PetscErrorCode NEPCISSSetThreshold(NEP nep,PetscReal delta,PetscReal spur)NEPCISSSetThreshold857,33040 #undef __FUNCT____FUNCT__869,33445 #define __FUNCT__ __FUNCT__870,33462 static PetscErrorCode NEPCISSGetThreshold_CISS(NEP nep,PetscReal *delta,PetscReal *spur)NEPCISSGetThreshold_CISS871,33507 #undef __FUNCT____FUNCT__881,33770 #define __FUNCT__ __FUNCT__882,33787 PetscErrorCode NEPCISSGetThreshold(NEP nep,PetscReal *delta,PetscReal *spur)NEPCISSGetThreshold900,34191 #undef __FUNCT____FUNCT__910,34505 #define __FUNCT__ __FUNCT__911,34522 static PetscErrorCode NEPCISSSetRefinement_CISS(NEP nep,PetscInt inner,PetscInt blsize)NEPCISSSetRefinement_CISS912,34568 #undef __FUNCT____FUNCT__932,35229 #define __FUNCT__ __FUNCT__933,35246 PetscErrorCode NEPCISSSetRefinement(NEP nep,PetscInt inner,PetscInt blsize)NEPCISSSetRefinement953,35838 #undef __FUNCT____FUNCT__965,36245 #define __FUNCT__ __FUNCT__966,36262 static PetscErrorCode NEPCISSGetRefinement_CISS(NEP nep,PetscInt *inner,PetscInt *blsize)NEPCISSGetRefinement_CISS967,36308 #undef __FUNCT____FUNCT__977,36581 #define __FUNCT__ __FUNCT__978,36598 PetscErrorCode NEPCISSGetRefinement(NEP nep, PetscInt *inner, PetscInt *blsize)NEPCISSGetRefinement996,37041 #undef __FUNCT____FUNCT__1006,37359 #define __FUNCT__ __FUNCT__1007,37376 PetscErrorCode NEPReset_CISS(NEP nep)NEPReset_CISS1008,37410 #undef __FUNCT____FUNCT__1032,38148 #define __FUNCT__ __FUNCT__1033,38165 PetscErrorCode NEPSetFromOptions_CISS(PetscOptionItems *PetscOptionsObject,NEP nep)NEPSetFromOptions_CISS1034,38208 #undef __FUNCT____FUNCT__1067,40288 #define __FUNCT__ __FUNCT__1068,40305 PetscErrorCode NEPDestroy_CISS(NEP nep)NEPDestroy_CISS1069,40341 #undef __FUNCT____FUNCT__1084,41085 #define __FUNCT__ __FUNCT__1085,41102 PetscErrorCode NEPView_CISS(NEP nep,PetscViewer viewer)NEPView_CISS1086,41135 #undef __FUNCT____FUNCT__1108,42355 #define __FUNCT__ __FUNCT__1109,42372 PETSC_EXTERN PetscErrorCode NEPCreate_CISS(NEP nep)NEPCreate_CISS1110,42407 src/nep/impls/interpol/interpol.c,3027 interpol.c:^?interpol.c^A,1 PEP pep;pep41,1448 PetscInt deg;deg42,1465 } NEP_INTERPOL;NEP_INTERPOL43,1482 #undef __FUNCT____FUNCT__45,1499 #define __FUNCT__ __FUNCT__46,1516 PetscErrorCode NEPSetUp_Interpol(NEP nep)NEPSetUp_Interpol47,1554 #undef __FUNCT____FUNCT__103,4605 #define __FUNCT__ __FUNCT__104,4622 static PetscErrorCode ChebyshevNodes(PetscInt d,PetscReal a,PetscReal b,PetscScalar *x,PetscReal *dct2)ChebyshevNodes113,4889 #undef __FUNCT____FUNCT__127,5256 #define __FUNCT__ __FUNCT__128,5273 PetscErrorCode NEPSolve_Interpol(NEP nep)NEPSolve_Interpol129,5311 #undef __FUNCT____FUNCT__187,7260 #define __FUNCT__ __FUNCT__188,7277 static PetscErrorCode PEPMonitor_Interpol(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)PEPMonitor_Interpol189,7317 #undef __FUNCT____FUNCT__215,8131 #define __FUNCT__ __FUNCT__216,8148 PetscErrorCode NEPSetFromOptions_Interpol(PetscOptionItems *PetscOptionsObject,NEP nep)NEPSetFromOptions_Interpol217,8195 #undef __FUNCT____FUNCT__231,8813 #define __FUNCT__ __FUNCT__232,8830 static PetscErrorCode NEPInterpolSetDegree_Interpol(NEP nep,PetscInt deg)NEPInterpolSetDegree_Interpol233,8880 #undef __FUNCT____FUNCT__242,9074 #define __FUNCT__ __FUNCT__243,9091 PetscErrorCode NEPInterpolSetDegree(NEP nep,PetscInt deg)NEPInterpolSetDegree257,9377 #undef __FUNCT____FUNCT__268,9698 #define __FUNCT__ __FUNCT__269,9715 static PetscErrorCode NEPInterpolGetDegree_Interpol(NEP nep,PetscInt *deg)NEPInterpolGetDegree_Interpol270,9765 #undef __FUNCT____FUNCT__279,9961 #define __FUNCT__ __FUNCT__280,9978 PetscErrorCode NEPInterpolGetDegree(NEP nep,PetscInt *deg)NEPInterpolGetDegree296,10286 #undef __FUNCT____FUNCT__307,10592 #define __FUNCT__ __FUNCT__308,10609 static PetscErrorCode NEPInterpolSetPEP_Interpol(NEP nep,PEP pep)NEPInterpolSetPEP_Interpol309,10656 #undef __FUNCT____FUNCT__323,11095 #define __FUNCT__ __FUNCT__324,11112 PetscErrorCode NEPInterpolSetPEP(NEP nep,PEP pep)NEPInterpolSetPEP339,11443 #undef __FUNCT____FUNCT__351,11785 #define __FUNCT__ __FUNCT__352,11802 static PetscErrorCode NEPInterpolGetPEP_Interpol(NEP nep,PEP *pep)NEPInterpolGetPEP_Interpol353,11849 #undef __FUNCT____FUNCT__374,12738 #define __FUNCT__ __FUNCT__375,12755 PetscErrorCode NEPInterpolGetPEP(NEP nep,PEP *pep)NEPInterpolGetPEP392,13118 #undef __FUNCT____FUNCT__403,13408 #define __FUNCT__ __FUNCT__404,13425 PetscErrorCode NEPView_Interpol(NEP nep,PetscViewer viewer)NEPView_Interpol405,13462 #undef __FUNCT____FUNCT__423,14137 #define __FUNCT__ __FUNCT__424,14154 PetscErrorCode NEPReset_Interpol(NEP nep)NEPReset_Interpol425,14192 #undef __FUNCT____FUNCT__435,14423 #define __FUNCT__ __FUNCT__436,14440 PetscErrorCode NEPDestroy_Interpol(NEP nep)NEPDestroy_Interpol437,14480 #undef __FUNCT____FUNCT__452,15132 #define __FUNCT__ __FUNCT__453,15149 PETSC_EXTERN PetscErrorCode NEPCreate_Interpol(NEP nep)NEPCreate_Interpol454,15188 src/nep/impls/interpol/makefile,282 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = interpol.cSOURCEC26,958 SOURCEF =SOURCEF27,980 SOURCEH =SOURCEH28,991 LIBBASE = libslepcnepLIBBASE29,1002 DIRS =DIRS30,1025 MANSEC = NEPMANSEC31,1036 LOCDIR = src/nep/impls/interpol/LOCDIR32,1051 src/nep/impls/makefile,170 makefile:^?makefile^A,1 LIBBASE = libslepcnepLIBBASE24,936 DIRS = rii slp narnoldi interpol ciss nleigsDIRS25,959 LOCDIR = src/nep/impls/LOCDIR26,1008 MANSEC = NEPMANSEC27,1034 src/nep/impls/narnoldi/makefile,284 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,944 FFLAGS =FFLAGS25,955 SOURCEC = narnoldi.cSOURCEC26,966 SOURCEF = SOURCEF27,988 SOURCEH =SOURCEH28,1000 LIBBASE = libslepcnepLIBBASE29,1011 DIRS =DIRS30,1034 MANSEC = NEPMANSEC31,1045 LOCDIR = src/nep/impls/narnoldi/LOCDIR32,1060 src/nep/impls/narnoldi/narnoldi.c,1891 narnoldi.c:^?narnoldi.c^A,1 KSP ksp; /* linear solver object */ksp39,1266 } NEP_NARNOLDI;NEP_NARNOLDI40,1322 #undef __FUNCT____FUNCT__42,1339 #define __FUNCT__ __FUNCT__43,1356 PETSC_STATIC_INLINE PetscErrorCode NEPNArnoldi_KSPSolve(NEP nep,Vec b,Vec x)NEPNArnoldi_KSPSolve44,1397 #undef __FUNCT____FUNCT__57,1827 #define __FUNCT__ __FUNCT__58,1844 PetscErrorCode NEPSetUp_NArnoldi(NEP nep)NEPSetUp_NArnoldi59,1882 #undef __FUNCT____FUNCT__86,3336 #define __FUNCT__ __FUNCT__87,3353 PetscErrorCode NEPSolve_NArnoldi(NEP nep)NEPSolve_NArnoldi88,3391 #undef __FUNCT____FUNCT__181,7042 #define __FUNCT__ __FUNCT__182,7059 PetscErrorCode NEPSetFromOptions_NArnoldi(PetscOptionItems *PetscOptionsObject,NEP nep)NEPSetFromOptions_NArnoldi183,7106 #undef __FUNCT____FUNCT__195,7531 #define __FUNCT__ __FUNCT__196,7548 static PetscErrorCode NEPNArnoldiSetKSP_NArnoldi(NEP nep,KSP ksp)NEPNArnoldiSetKSP_NArnoldi197,7595 #undef __FUNCT____FUNCT__211,8034 #define __FUNCT__ __FUNCT__212,8051 PetscErrorCode NEPNArnoldiSetKSP(NEP nep,KSP ksp)NEPNArnoldiSetKSP227,8354 #undef __FUNCT____FUNCT__239,8696 #define __FUNCT__ __FUNCT__240,8713 static PetscErrorCode NEPNArnoldiGetKSP_NArnoldi(NEP nep,KSP *ksp)NEPNArnoldiGetKSP_NArnoldi241,8760 #undef __FUNCT____FUNCT__259,9492 #define __FUNCT__ __FUNCT__260,9509 PetscErrorCode NEPNArnoldiGetKSP(NEP nep,KSP *ksp)NEPNArnoldiGetKSP277,9854 #undef __FUNCT____FUNCT__288,10144 #define __FUNCT__ __FUNCT__289,10161 PetscErrorCode NEPView_NArnoldi(NEP nep,PetscViewer viewer)NEPView_NArnoldi290,10198 #undef __FUNCT____FUNCT__307,10770 #define __FUNCT__ __FUNCT__308,10787 PetscErrorCode NEPDestroy_NArnoldi(NEP nep)NEPDestroy_NArnoldi309,10827 #undef __FUNCT____FUNCT__322,11281 #define __FUNCT__ __FUNCT__323,11298 PETSC_EXTERN PetscErrorCode NEPCreate_NArnoldi(NEP nep)NEPCreate_NArnoldi324,11337 src/nep/impls/nleigs/makefile,276 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,944 FFLAGS =FFLAGS25,955 SOURCEC = nleigs.cSOURCEC26,966 SOURCEF = SOURCEF27,986 SOURCEH =SOURCEH28,998 LIBBASE = libslepcLIBBASE29,1009 DIRS =DIRS30,1029 MANSEC = NEPMANSEC31,1040 LOCDIR = src/nep/impls/nleigs/LOCDIR32,1055 src/nep/impls/nleigs/nleigs.c,13562 nleigs.c:^?nleigs.c^A,1 #define MAX_LBPOINTS MAX_LBPOINTS40,1373 #define NDPOINTS NDPOINTS41,1400 #define MAX_NSHIFTS MAX_NSHIFTS42,1427 PetscInt nmat; /* number of interpolation points */nmat45,1472 PetscScalar *s,*xi; /* Leja-Bagby points */s46,1537 PetscScalar *s,*xi; /* Leja-Bagby points */xi46,1537 PetscScalar *beta; /* scaling factors */beta47,1589 Mat *D; /* divided difference matrices */D48,1639 PetscScalar *coeffD; /* coefficients for divided differences in split form */coeffD49,1701 PetscInt nshifts; /* provided number of shifts */nshifts50,1786 PetscScalar *shifts; /* user-provided shifts for the Rational Krylov variant */shifts51,1846 PetscInt nshiftsw; /* actual number of shifts (1 if Krylov-Schur) */nshiftsw52,1933 PetscReal ddtol; /* tolerance for divided difference convergence */ddtol53,2011 PetscInt ddmaxit; /* maximum number of divided difference terms */ddmaxit54,2090 BV W; /* auxiliary BV object */W55,2167 PetscReal keep; /* restart parameter */keep56,2221 PetscBool lock; /* locking/non-locking variant */lock57,2273 PetscBool trueres; /* whether the true residual norm must be computed */trueres58,2335 PetscInt idxrk; /* index of next shift to use */idxrk59,2417 KSP *ksp; /* ksp array for storing shift factorizations */ksp60,2478 Vec vrn; /* random vector with normally distributed value */vrn61,2555 void *singularitiesctx;singularitiesctx62,2635 PetscErrorCode (*computesingularities)(NEP,PetscInt*,PetscScalar*,void*);computesingularities63,2671 } NEP_NLEIGS;NEP_NLEIGS64,2747 PetscInt nmat;nmat67,2779 PetscScalar coeff[MAX_NSHIFTS];coeff68,2799 Mat A[MAX_NSHIFTS];A69,2833 Vec t;t70,2863 } ShellMatCtx;ShellMatCtx71,2880 #undef __FUNCT____FUNCT__73,2896 #define __FUNCT__ __FUNCT__74,2913 PETSC_STATIC_INLINE PetscErrorCode NEPNLEIGSSetShifts(NEP nep)NEPNLEIGSSetShifts75,2952 #undef __FUNCT____FUNCT__87,3231 #define __FUNCT__ __FUNCT__88,3248 static PetscErrorCode NEPNLEIGSBackTransform(PetscObject ob,PetscInt n,PetscScalar *valr,PetscScalar *vali)NEPNLEIGSBackTransform89,3291 #undef __FUNCT____FUNCT__116,3903 #define __FUNCT__ __FUNCT__117,3920 static PetscErrorCode NEPNLEIGSLejaBagbyPoints(NEP nep)NEPNLEIGSLejaBagbyPoints118,3965 #undef __FUNCT____FUNCT__176,6185 #define __FUNCT__ __FUNCT__177,6202 static PetscErrorCode NEPNLEIGSEvalNRTFunct(NEP nep,PetscInt k,PetscScalar sigma,PetscScalar *b)NEPNLEIGSEvalNRTFunct178,6244 #undef __FUNCT____FUNCT__192,6620 #define __FUNCT__ __FUNCT__193,6637 static PetscErrorCode MatMult_Fun(Mat A,Vec x,Vec y)MatMult_Fun194,6669 #undef __FUNCT____FUNCT__211,7176 #define __FUNCT__ __FUNCT__212,7193 static PetscErrorCode MatMultTranspose_Fun(Mat A,Vec x,Vec y)MatMultTranspose_Fun213,7234 #undef __FUNCT____FUNCT__230,7768 #define __FUNCT__ __FUNCT__231,7785 static PetscErrorCode MatGetDiagonal_Fun(Mat A,Vec diag)MatGetDiagonal_Fun232,7824 #undef __FUNCT____FUNCT__249,8354 #define __FUNCT__ __FUNCT__250,8371 static PetscErrorCode MatDuplicate_Fun(Mat A,MatDuplicateOption op,Mat *B)MatDuplicate_Fun251,8408 #undef __FUNCT____FUNCT__285,9957 #define __FUNCT__ __FUNCT__286,9974 static PetscErrorCode MatDestroy_Fun(Mat A)MatDestroy_Fun287,10009 #undef __FUNCT____FUNCT__305,10429 #define __FUNCT__ __FUNCT__306,10446 static PetscErrorCode MatAXPY_Fun(Mat Y,PetscScalar a,Mat X,MatStructure str)MatAXPY_Fun307,10478 #undef __FUNCT____FUNCT__334,11246 #define __FUNCT__ __FUNCT__335,11263 static PetscErrorCode MatScale_Fun(Mat M,PetscScalar a)MatScale_Fun336,11296 #undef __FUNCT____FUNCT__348,11583 #define __FUNCT__ __FUNCT__349,11600 static PetscErrorCode NLEIGSMatToMatShellArray(Mat M,Mat *Ms)NLEIGSMatToMatShellArray350,11645 #undef __FUNCT____FUNCT__377,12985 #define __FUNCT__ __FUNCT__378,13002 static PetscErrorCode NEPNLEIGSNormEstimation(NEP nep,Mat M,PetscReal *norm,Vec *w)NEPNLEIGSNormEstimation379,13046 #undef __FUNCT____FUNCT__422,14842 #define __FUNCT__ __FUNCT__423,14859 static PetscErrorCode NEPNLEIGSDividedDifferences_split(NEP nep)NEPNLEIGSDividedDifferences_split424,14913 #undef __FUNCT____FUNCT__493,17376 #define __FUNCT__ __FUNCT__494,17393 static PetscErrorCode NEPNLEIGSDividedDifferences_callback(NEP nep)NEPNLEIGSDividedDifferences_callback495,17450 #undef __FUNCT____FUNCT__578,20481 #define __FUNCT__ __FUNCT__579,20498 static PetscErrorCode NEPNLEIGSRitzVector(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscInt k,Vec t)NEPNLEIGSRitzVector580,20538 #undef __FUNCT____FUNCT__609,21839 #define __FUNCT__ __FUNCT__610,21856 static PetscErrorCode NEPNLEIGSKrylovConvergence(NEP nep,PetscScalar *S,PetscInt ld,PetscInt nq,PetscScalar *H,PetscBool getall,PetscInt kini,PetscInt nits,PetscScalar betak,PetscReal betah,PetscInt *kout,Vec *w)NEPNLEIGSKrylovConvergence614,21981 #undef __FUNCT____FUNCT__664,23869 #define __FUNCT__ __FUNCT__665,23886 PetscErrorCode NEPSetUp_NLEIGS(NEP nep)NEPSetUp_NLEIGS666,23922 #undef __FUNCT____FUNCT__721,26249 #define __FUNCT__ __FUNCT__722,26266 static PetscErrorCode NEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm)NEPTOARSNorm2726,26325 #undef __FUNCT____FUNCT__737,26589 #define __FUNCT__ __FUNCT__738,26606 static PetscErrorCode NEPTOAROrth2(NEP nep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work)NEPTOAROrth2746,26823 #undef __FUNCT____FUNCT__790,28549 #define __FUNCT__ __FUNCT__791,28566 static PetscErrorCode NEPTOARExtendBasis(NEP nep,PetscInt idxrktg,PetscScalar *S,PetscInt ls,PetscInt nv,BV V,Vec t,PetscScalar *r,PetscInt lr,Vec *t_)NEPTOARExtendBasis803,28981 #undef __FUNCT____FUNCT__860,31685 #define __FUNCT__ __FUNCT__861,31702 static PetscErrorCode NEPTOARCoefficients(NEP nep,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x,PetscScalar *work)NEPTOARCoefficients865,31825 #undef __FUNCT____FUNCT__881,32368 #define __FUNCT__ __FUNCT__882,32385 static PetscErrorCode NEPNLEIGS_RKcontinuation(NEP nep,PetscInt ini,PetscInt end,PetscScalar *K,PetscScalar *H,PetscInt ld,PetscScalar sigma,PetscScalar *S,PetscInt lds,PetscScalar *cont,PetscScalar *t,PetscScalar *work)NEPNLEIGS_RKcontinuation887,32585 #undef __FUNCT____FUNCT__936,34475 #define __FUNCT__ __FUNCT__937,34492 static PetscErrorCode NEPNLEIGSTOARrun(NEP nep,PetscInt *nq,PetscScalar *S,PetscInt ld,PetscScalar *K,PetscScalar *H,PetscInt ldh,BV V,PetscInt k,PetscInt *M,PetscBool *breakdown,Vec *t_)NEPNLEIGSTOARrun941,34573 #undef __FUNCT____FUNCT__997,36498 #define __FUNCT__ __FUNCT__998,36515 static PetscErrorCode NEPTOARTrunc(NEP nep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt *nq,PetscInt cs1,PetscScalar *work,PetscReal *rwork)NEPTOARTrunc1000,36588 #undef __FUNCT____FUNCT__1064,38885 #define __FUNCT__ __FUNCT__1065,38902 static PetscErrorCode NEPTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)NEPTOARSupdate1073,39033 #undef __FUNCT____FUNCT__1095,39897 #define __FUNCT__ __FUNCT__1096,39914 PetscErrorCode NEPSolve_NLEIGS(NEP nep)NEPSolve_NLEIGS1097,39950 #undef __FUNCT____FUNCT__1267,47050 #define __FUNCT__ __FUNCT__1268,47067 static PetscErrorCode NEPNLEIGSSetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx)NEPNLEIGSSetSingularitiesFunction_NLEIGS1269,47128 #undef __FUNCT____FUNCT__1279,47459 #define __FUNCT__ __FUNCT__1280,47476 PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP nep,PetscErrorCode (*fun)(NEP,PetscInt*,PetscScalar*,void*),void *ctx)NEPNLEIGSSetSingularitiesFunction1308,48470 #undef __FUNCT____FUNCT__1318,48878 #define __FUNCT__ __FUNCT__1319,48895 static PetscErrorCode NEPNLEIGSGetSingularitiesFunction_NLEIGS(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx)NEPNLEIGSGetSingularitiesFunction_NLEIGS1320,48956 #undef __FUNCT____FUNCT__1330,49287 #define __FUNCT__ __FUNCT__1331,49304 PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP nep,PetscErrorCode (**fun)(NEP,PetscInt*,PetscScalar*,void*),void **ctx)NEPNLEIGSGetSingularitiesFunction1349,49805 #undef __FUNCT____FUNCT__1359,50217 #define __FUNCT__ __FUNCT__1360,50234 static PetscErrorCode NEPNLEIGSSetRestart_NLEIGS(NEP nep,PetscReal keep)NEPNLEIGSSetRestart_NLEIGS1361,50281 #undef __FUNCT____FUNCT__1374,50679 #define __FUNCT__ __FUNCT__1375,50696 PetscErrorCode NEPNLEIGSSetRestart(NEP nep,PetscReal keep)NEPNLEIGSSetRestart1397,51264 #undef __FUNCT____FUNCT__1408,51589 #define __FUNCT__ __FUNCT__1409,51606 static PetscErrorCode NEPNLEIGSGetRestart_NLEIGS(NEP nep,PetscReal *keep)NEPNLEIGSGetRestart_NLEIGS1410,51653 #undef __FUNCT____FUNCT__1419,51844 #define __FUNCT__ __FUNCT__1420,51861 PetscErrorCode NEPNLEIGSGetRestart(NEP nep,PetscReal *keep)NEPNLEIGSGetRestart1436,52178 #undef __FUNCT____FUNCT__1447,52487 #define __FUNCT__ __FUNCT__1448,52504 static PetscErrorCode NEPNLEIGSSetLocking_NLEIGS(NEP nep,PetscBool lock)NEPNLEIGSSetLocking_NLEIGS1449,52551 #undef __FUNCT____FUNCT__1458,52740 #define __FUNCT__ __FUNCT__1459,52757 PetscErrorCode NEPNLEIGSSetLocking(NEP nep,PetscBool lock)NEPNLEIGSSetLocking1483,53434 #undef __FUNCT____FUNCT__1494,53759 #define __FUNCT__ __FUNCT__1495,53776 static PetscErrorCode NEPNLEIGSGetLocking_NLEIGS(NEP nep,PetscBool *lock)NEPNLEIGSGetLocking_NLEIGS1496,53823 #undef __FUNCT____FUNCT__1505,54014 #define __FUNCT__ __FUNCT__1506,54031 PetscErrorCode NEPNLEIGSGetLocking(NEP nep,PetscBool *lock)NEPNLEIGSGetLocking1522,54338 #undef __FUNCT____FUNCT__1533,54647 #define __FUNCT__ __FUNCT__1534,54664 static PetscErrorCode NEPNLEIGSSetInterpolation_NLEIGS(NEP nep,PetscReal tol,PetscInt maxits)NEPNLEIGSSetInterpolation_NLEIGS1535,54717 #undef __FUNCT____FUNCT__1557,55457 #define __FUNCT__ __FUNCT__1558,55474 PetscErrorCode NEPNLEIGSSetInterpolation(NEP nep,PetscReal tol,PetscInt maxits)NEPNLEIGSSetInterpolation1581,56207 #undef __FUNCT____FUNCT__1593,56621 #define __FUNCT__ __FUNCT__1594,56638 static PetscErrorCode NEPNLEIGSGetInterpolation_NLEIGS(NEP nep,PetscReal *tol,PetscInt *maxits)NEPNLEIGSGetInterpolation_NLEIGS1595,56691 #undef __FUNCT____FUNCT__1605,56957 #define __FUNCT__ __FUNCT__1606,56974 PetscErrorCode NEPNLEIGSGetInterpolation(NEP nep,PetscReal *tol,PetscInt *maxits)NEPNLEIGSGetInterpolation1624,57435 #undef __FUNCT____FUNCT__1634,57759 #define __FUNCT__ __FUNCT__1635,57776 static PetscErrorCode NEPNLEIGSSetTrueResidual_NLEIGS(NEP nep,PetscBool trueres)NEPNLEIGSSetTrueResidual_NLEIGS1636,57828 #undef __FUNCT____FUNCT__1645,58031 #define __FUNCT__ __FUNCT__1646,58048 PetscErrorCode NEPNLEIGSSetTrueResidual(NEP nep,PetscBool trueres)NEPNLEIGSSetTrueResidual1670,58811 #undef __FUNCT____FUNCT__1681,59155 #define __FUNCT__ __FUNCT__1682,59172 static PetscErrorCode NEPNLEIGSGetTrueResidual_NLEIGS(NEP nep,PetscBool *trueres)NEPNLEIGSGetTrueResidual_NLEIGS1683,59224 #undef __FUNCT____FUNCT__1692,59429 #define __FUNCT__ __FUNCT__1693,59446 PetscErrorCode NEPNLEIGSGetTrueResidual(NEP nep,PetscBool *trueres)NEPNLEIGSGetTrueResidual1710,59813 #undef __FUNCT____FUNCT__1721,60141 #define __FUNCT__ __FUNCT__1722,60158 static PetscErrorCode NEPNLEIGSSetRKShifts_NLEIGS(NEP nep,PetscInt ns,PetscScalar *shifts)NEPNLEIGSSetRKShifts_NLEIGS1723,60206 #undef __FUNCT____FUNCT__1742,60928 #define __FUNCT__ __FUNCT__1743,60945 PetscErrorCode NEPNLEIGSSetRKShifts(NEP nep,PetscInt ns,PetscScalar *shifts)NEPNLEIGSSetRKShifts1771,61795 #undef __FUNCT____FUNCT__1783,62186 #define __FUNCT__ __FUNCT__1784,62203 static PetscErrorCode NEPNLEIGSGetRKShifts_NLEIGS(NEP nep,PetscInt *ns,PetscScalar **shifts)NEPNLEIGSGetRKShifts_NLEIGS1785,62251 #undef __FUNCT____FUNCT__1800,62659 #define __FUNCT__ __FUNCT__1801,62676 PetscErrorCode NEPNLEIGSGetRKShifts(NEP nep,PetscInt *ns,PetscScalar **shifts)NEPNLEIGSGetRKShifts1819,63031 #define SHIFTMAX SHIFTMAX1831,63411 #undef __FUNCT____FUNCT__1833,63432 #define __FUNCT__ __FUNCT__1834,63449 PetscErrorCode NEPSetFromOptions_NLEIGS(PetscOptionItems *PetscOptionsObject,NEP nep)NEPSetFromOptions_NLEIGS1835,63494 #undef __FUNCT____FUNCT__1891,66038 #define __FUNCT__ __FUNCT__1892,66055 static PetscErrorCode NEPNLEIGSGetKSPs_NLEIGS(NEP nep,KSP **ksp)NEPNLEIGSGetKSPs_NLEIGS1893,66099 #undef __FUNCT____FUNCT__1916,67031 #define __FUNCT__ __FUNCT__1917,67048 PetscErrorCode NEPNLEIGSGetKSPs(NEP nep,KSP **ksp)NEPNLEIGSGetKSPs1932,67370 #undef __FUNCT____FUNCT__1943,67660 #define __FUNCT__ __FUNCT__1944,67677 PetscErrorCode NEPView_NLEIGS(NEP nep,PetscViewer viewer)NEPView_NLEIGS1945,67712 #undef __FUNCT____FUNCT__1979,69543 #define __FUNCT__ __FUNCT__1980,69560 PetscErrorCode NEPReset_NLEIGS(NEP nep)NEPReset_NLEIGS1981,69596 #undef __FUNCT____FUNCT__1999,70036 #define __FUNCT__ __FUNCT__2000,70053 PetscErrorCode NEPDestroy_NLEIGS(NEP nep)NEPDestroy_NLEIGS2001,70091 #undef __FUNCT____FUNCT__2029,71910 #define __FUNCT__ __FUNCT__2030,71927 PETSC_EXTERN PetscErrorCode NEPCreate_NLEIGS(NEP nep)NEPCreate_NLEIGS2031,71964 src/nep/impls/rii/makefile,271 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = rii.cSOURCEC26,958 SOURCEF =SOURCEF27,975 SOURCEH =SOURCEH28,986 LIBBASE = libslepcnepLIBBASE29,997 DIRS =DIRS30,1020 MANSEC = NEPMANSEC31,1031 LOCDIR = src/nep/impls/rii/LOCDIR32,1046 src/nep/impls/rii/rii.c,4240 rii.c:^?rii.c^A,1 PetscInt max_inner_it; /* maximum number of Newton iterations */max_inner_it39,1323 PetscInt lag; /* interval to rebuild preconditioner */lag40,1395 PetscBool cctol; /* constant correction tolerance */cctol41,1466 KSP ksp; /* linear solver object */ksp42,1532 } NEP_RII;NEP_RII43,1589 #undef __FUNCT____FUNCT__45,1601 #define __FUNCT__ __FUNCT__46,1618 PETSC_STATIC_INLINE PetscErrorCode NEPRII_KSPSolve(NEP nep,Vec b,Vec x)NEPRII_KSPSolve47,1654 #undef __FUNCT____FUNCT__60,2074 #define __FUNCT__ __FUNCT__61,2091 PetscErrorCode NEPSetUp_RII(NEP nep)NEPSetUp_RII62,2124 #undef __FUNCT____FUNCT__84,3126 #define __FUNCT__ __FUNCT__85,3143 PetscErrorCode NEPSolve_RII(NEP nep)NEPSolve_RII86,3176 #undef __FUNCT____FUNCT__180,6886 #define __FUNCT__ __FUNCT__181,6903 PetscErrorCode NEPSetFromOptions_RII(PetscOptionItems *PetscOptionsObject,NEP nep)NEPSetFromOptions_RII182,6945 #undef __FUNCT____FUNCT__203,8150 #define __FUNCT__ __FUNCT__204,8167 static PetscErrorCode NEPRIISetMaximumIterations_RII(NEP nep,PetscInt its)NEPRIISetMaximumIterations_RII205,8218 #undef __FUNCT____FUNCT__214,8412 #define __FUNCT__ __FUNCT__215,8429 PetscErrorCode NEPRIISetMaximumIterations(NEP nep,PetscInt its)NEPRIISetMaximumIterations231,8878 #undef __FUNCT____FUNCT__242,9211 #define __FUNCT__ __FUNCT__243,9228 static PetscErrorCode NEPRIIGetMaximumIterations_RII(NEP nep,PetscInt *its)NEPRIIGetMaximumIterations_RII244,9279 #undef __FUNCT____FUNCT__253,9475 #define __FUNCT__ __FUNCT__254,9492 PetscErrorCode NEPRIIGetMaximumIterations(NEP nep,PetscInt *its)NEPRIIGetMaximumIterations270,9824 #undef __FUNCT____FUNCT__281,10142 #define __FUNCT__ __FUNCT__282,10159 static PetscErrorCode NEPRIISetLagPreconditioner_RII(NEP nep,PetscInt lag)NEPRIISetLagPreconditioner_RII283,10210 #undef __FUNCT____FUNCT__293,10486 #define __FUNCT__ __FUNCT__294,10503 PetscErrorCode NEPRIISetLagPreconditioner(NEP nep,PetscInt lag)NEPRIISetLagPreconditioner318,11192 #undef __FUNCT____FUNCT__329,11525 #define __FUNCT__ __FUNCT__330,11542 static PetscErrorCode NEPRIIGetLagPreconditioner_RII(NEP nep,PetscInt *lag)NEPRIIGetLagPreconditioner_RII331,11593 #undef __FUNCT____FUNCT__340,11780 #define __FUNCT__ __FUNCT__341,11797 PetscErrorCode NEPRIIGetLagPreconditioner(NEP nep,PetscInt *lag)NEPRIIGetLagPreconditioner357,12125 #undef __FUNCT____FUNCT__368,12443 #define __FUNCT__ __FUNCT__369,12460 static PetscErrorCode NEPRIISetConstCorrectionTol_RII(NEP nep,PetscBool cct)NEPRIISetConstCorrectionTol_RII370,12512 #undef __FUNCT____FUNCT__379,12701 #define __FUNCT__ __FUNCT__380,12718 PetscErrorCode NEPRIISetConstCorrectionTol(NEP nep,PetscBool cct)NEPRIISetConstCorrectionTol404,13418 #undef __FUNCT____FUNCT__415,13755 #define __FUNCT__ __FUNCT__416,13772 static PetscErrorCode NEPRIIGetConstCorrectionTol_RII(NEP nep,PetscBool *cct)NEPRIIGetConstCorrectionTol_RII417,13824 #undef __FUNCT____FUNCT__426,14015 #define __FUNCT__ __FUNCT__427,14032 PetscErrorCode NEPRIIGetConstCorrectionTol(NEP nep,PetscBool *cct)NEPRIIGetConstCorrectionTol443,14372 #undef __FUNCT____FUNCT__454,14694 #define __FUNCT__ __FUNCT__455,14711 static PetscErrorCode NEPRIISetKSP_RII(NEP nep,KSP ksp)NEPRIISetKSP_RII456,14748 #undef __FUNCT____FUNCT__470,15172 #define __FUNCT__ __FUNCT__471,15189 PetscErrorCode NEPRIISetKSP(NEP nep,KSP ksp)NEPRIISetKSP486,15477 #undef __FUNCT____FUNCT__498,15809 #define __FUNCT__ __FUNCT__499,15826 static PetscErrorCode NEPRIIGetKSP_RII(NEP nep,KSP *ksp)NEPRIIGetKSP_RII500,15863 #undef __FUNCT____FUNCT__518,16575 #define __FUNCT__ __FUNCT__519,16592 PetscErrorCode NEPRIIGetKSP(NEP nep,KSP *ksp)NEPRIIGetKSP536,16922 #undef __FUNCT____FUNCT__547,17202 #define __FUNCT__ __FUNCT__548,17219 PetscErrorCode NEPView_RII(NEP nep,PetscViewer viewer)NEPView_RII549,17251 #undef __FUNCT____FUNCT__573,18233 #define __FUNCT__ __FUNCT__574,18250 PetscErrorCode NEPDestroy_RII(NEP nep)NEPDestroy_RII575,18285 #undef __FUNCT____FUNCT__594,19351 #define __FUNCT__ __FUNCT__595,19368 PETSC_EXTERN PetscErrorCode NEPCreate_RII(NEP nep)NEPCreate_RII596,19402 src/nep/impls/slp/makefile,271 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = slp.cSOURCEC26,958 SOURCEF =SOURCEF27,975 SOURCEH =SOURCEH28,986 LIBBASE = libslepcnepLIBBASE29,997 DIRS =DIRS30,1020 MANSEC = NEPMANSEC31,1031 LOCDIR = src/nep/impls/slp/LOCDIR32,1046 src/nep/impls/slp/slp.c,1726 slp.c:^?slp.c^A,1 EPS eps; /* linear eigensolver for T*z = mu*Tp*z */eps39,1313 } NEP_SLP;NEP_SLP40,1385 #undef __FUNCT____FUNCT__42,1397 #define __FUNCT__ __FUNCT__43,1414 PetscErrorCode NEPSetUp_SLP(NEP nep)NEPSetUp_SLP44,1447 #undef __FUNCT____FUNCT__76,3091 #define __FUNCT__ __FUNCT__77,3108 PetscErrorCode NEPSolve_SLP(NEP nep)NEPSolve_SLP78,3141 #undef __FUNCT____FUNCT__139,5529 #define __FUNCT__ __FUNCT__140,5546 PetscErrorCode NEPSetFromOptions_SLP(PetscOptionItems *PetscOptionsObject,NEP nep)NEPSetFromOptions_SLP141,5588 #undef __FUNCT____FUNCT__154,6038 #define __FUNCT__ __FUNCT__155,6055 static PetscErrorCode NEPSLPSetEPS_SLP(NEP nep,EPS eps)NEPSLPSetEPS_SLP156,6092 #undef __FUNCT____FUNCT__170,6516 #define __FUNCT__ __FUNCT__171,6533 PetscErrorCode NEPSLPSetEPS(NEP nep,EPS eps)NEPSLPSetEPS186,6834 #undef __FUNCT____FUNCT__198,7166 #define __FUNCT__ __FUNCT__199,7183 static PetscErrorCode NEPSLPGetEPS_SLP(NEP nep,EPS *eps)NEPSLPGetEPS_SLP200,7220 #undef __FUNCT____FUNCT__220,8010 #define __FUNCT__ __FUNCT__221,8027 PetscErrorCode NEPSLPGetEPS(NEP nep,EPS *eps)NEPSLPGetEPS238,8358 #undef __FUNCT____FUNCT__249,8638 #define __FUNCT__ __FUNCT__250,8655 PetscErrorCode NEPView_SLP(NEP nep,PetscViewer viewer)NEPView_SLP251,8687 #undef __FUNCT____FUNCT__268,9244 #define __FUNCT__ __FUNCT__269,9261 PetscErrorCode NEPReset_SLP(NEP nep)NEPReset_SLP270,9294 #undef __FUNCT____FUNCT__280,9515 #define __FUNCT__ __FUNCT__281,9532 PetscErrorCode NEPDestroy_SLP(NEP nep)NEPDestroy_SLP282,9567 #undef __FUNCT____FUNCT__295,10001 #define __FUNCT__ __FUNCT__296,10018 PETSC_EXTERN PetscErrorCode NEPCreate_SLP(NEP nep)NEPCreate_SLP297,10052 src/nep/interface/dlregisnep.c,1229 dlregisnep.c:^?dlregisnep.c^A,1 static PetscBool NEPPackageInitialized = PETSC_FALSE;NEPPackageInitialized24,960 const char *NEPErrorTypes[] = {"ABSOLUTE","RELATIVE","NEPErrorType","NEP_ERROR_",0};NEPErrorTypes26,1015 const char *NEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","NEPRefine","NEP_REFINE_",0};NEPRefineTypes27,1100 const char *NEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","NEPRefineScheme","NEP_REFINE_SCHEME_",0};NEPRefineSchemes28,1189 const char *const NEPConvergedReasons_Shifted[] = {"DIVERGED_LINEAR_SOLVE","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","NEPConvergedReason","NEP_",0};NEPConvergedReasons_Shifted29,1294 const char *const*NEPConvergedReasons = NEPConvergedReasons_Shifted + 4;NEPConvergedReasons30,1495 #undef __FUNCT____FUNCT__32,1569 #define __FUNCT__ __FUNCT__33,1586 PetscErrorCode NEPFinalizePackage(void)NEPFinalizePackage42,1821 #undef __FUNCT____FUNCT__53,2075 #define __FUNCT__ __FUNCT__54,2092 PetscErrorCode NEPInitializePackage(void)NEPInitializePackage64,2420 #undef __FUNCT____FUNCT__107,4147 #define __FUNCT__ __FUNCT__108,4164 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcnep()PetscDLLibraryRegister_slepcnep116,4414 src/nep/interface/ftn-custom/makefile,257 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = znepf.cSOURCEC26,996 SOURCEF =SOURCEF27,1015 SOURCEH =SOURCEH28,1026 DIRS =DIRS29,1037 LIBBASE = libslepcnepLIBBASE30,1048 LOCDIR = src/nep/interface/ftn-custom/LOCDIR31,1071 src/nep/interface/ftn-custom/znepf.c,8227 znepf.c:^?znepf.c^A,1 PETSC_EXTERN void nepmonitorall_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)nepmonitorall_76,3526 PETSC_EXTERN void nepmonitorconverged_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)nepmonitorconverged_81,3790 PETSC_EXTERN void nepmonitorfirst_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)nepmonitorfirst_86,4061 PETSC_EXTERN void nepmonitorlg_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)nepmonitorlg_91,4329 PETSC_EXTERN void nepmonitorlgall_(NEP *nep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)nepmonitorlgall_96,4573 PetscFortranCallbackId monitor;monitor102,4839 PetscFortranCallbackId monitordestroy;monitordestroy103,4873 PetscFortranCallbackId convergence;convergence104,4914 PetscFortranCallbackId convdestroy;convdestroy105,4952 PetscFortranCallbackId stopping;stopping106,4990 PetscFortranCallbackId stopdestroy;stopdestroy107,5025 PetscFortranCallbackId comparison;comparison108,5063 } _cb;_cb109,5100 #undef __FUNCT____FUNCT__112,5200 static PetscErrorCode ourmonitor(NEP nep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx)ourmonitor114,5248 #undef __FUNCT____FUNCT__119,5566 static PetscErrorCode ourdestroy(void** ctx)ourdestroy121,5614 #undef __FUNCT____FUNCT__127,5781 static PetscErrorCode ourconvergence(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)ourconvergence129,5833 #undef __FUNCT____FUNCT__134,6133 static PetscErrorCode ourconvdestroy(void *ctx)ourconvdestroy136,6185 #undef __FUNCT____FUNCT__142,6351 static PetscErrorCode ourstopping(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)ourstopping144,6400 #undef __FUNCT____FUNCT__149,6732 static PetscErrorCode ourstopdestroy(void *ctx)ourstopdestroy151,6784 #undef __FUNCT____FUNCT__157,6950 static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)oureigenvaluecomparison159,7011 PETSC_EXTERN void PETSC_STDCALL nepview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)nepview_165,7337 PETSC_EXTERN void PETSC_STDCALL nepreasonview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)nepreasonview_172,7524 PETSC_EXTERN void PETSC_STDCALL neperrorview_(NEP *nep,NEPErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)neperrorview_179,7723 PETSC_EXTERN void PETSC_STDCALL nepvaluesview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)nepvaluesview_186,7947 PETSC_EXTERN void PETSC_STDCALL nepvectorsview_(NEP *nep,PetscViewer *viewer,PetscErrorCode *ierr)nepvectorsview_193,8146 PETSC_EXTERN void PETSC_STDCALL nepsettype_(NEP *nep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))nepsettype_200,8347 PETSC_EXTERN void PETSC_STDCALL nepgettype_(NEP *nep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))nepgettype_209,8562 PETSC_EXTERN void PETSC_STDCALL nepsetoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))nepsetoptionsprefix_218,8841 PETSC_EXTERN void PETSC_STDCALL nepappendoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))nepappendoptionsprefix_227,9080 PETSC_EXTERN void PETSC_STDCALL nepgetoptionsprefix_(NEP *nep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))nepgetoptionsprefix_236,9325 PETSC_EXTERN void PETSC_STDCALL nepmonitorset_(NEP *nep,void (PETSC_STDCALL *monitor)(NEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)nepmonitorset_245,9633 PETSC_EXTERN void PETSC_STDCALL nepconvergedabsolute_(NEP *nep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)nepconvergedabsolute_270,11675 PETSC_EXTERN void PETSC_STDCALL nepconvergedrelative_(NEP *nep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)nepconvergedrelative_275,11910 PETSC_EXTERN void PETSC_STDCALL nepsetconvergencetestfunction_(NEP *nep,void (PETSC_STDCALL *func)(NEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)nepsetconvergencetestfunction_280,12145 PETSC_EXTERN void PETSC_STDCALL nepstoppingbasic_(NEP *nep,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,NEPConvergedReason *reason,void *ctx,PetscErrorCode *ierr)nepstoppingbasic_299,13274 PETSC_EXTERN void PETSC_STDCALL nepsetstoppingtestfunction_(NEP *nep,void (PETSC_STDCALL *func)(NEP*,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)nepsetstoppingtestfunction_304,13528 PETSC_EXTERN void PETSC_STDCALL nepseteigenvaluecomparison_(NEP *nep,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr)nepseteigenvaluecomparison_321,14504 src/nep/interface/makefile,379 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = nepmon.c nepbasic.c nepview.c nepdefault.c nepregis.c nepopts.c nepsetup.c nepsolve.c neprefine.c dlregisnep.cSOURCEC26,958 SOURCEF =SOURCEF27,1080 SOURCEH =SOURCEH28,1091 LIBBASE = libslepcnepLIBBASE29,1102 DIRS =DIRS30,1125 MANSEC = NEPMANSEC31,1136 LOCDIR = src/nep/interface/LOCDIR32,1151 src/nep/interface/nepbasic.c,5206 nepbasic.c:^?nepbasic.c^A,1 PetscFunctionList NEPList = 0;NEPList26,1029 PetscBool NEPRegisterAllCalled = PETSC_FALSE;NEPRegisterAllCalled27,1060 PetscClassId NEP_CLASSID = 0;NEP_CLASSID28,1114 PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;NEP_SetUp29,1149 PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;NEP_Solve29,1149 PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;NEP_Refine29,1149 PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;NEP_FunctionEval29,1149 PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;NEP_JacobianEval29,1149 PetscLogEvent NEP_SetUp = 0,NEP_Solve = 0,NEP_Refine = 0,NEP_FunctionEval = 0,NEP_JacobianEval = 0,NEP_DerivativesEval = 0;NEP_DerivativesEval29,1149 #undef __FUNCT____FUNCT__31,1278 #define __FUNCT__ __FUNCT__32,1295 PetscErrorCode NEPCreate(MPI_Comm comm,NEP *outnep)NEPCreate48,1592 #undef __FUNCT____FUNCT__124,3913 #define __FUNCT__ __FUNCT__125,3930 PetscErrorCode NEPSetType(NEP nep,NEPType type)NEPSetType154,4851 #undef __FUNCT____FUNCT__178,5675 #define __FUNCT__ __FUNCT__179,5692 PetscErrorCode NEPGetType(NEP nep,NEPType *type)NEPGetType195,5971 #undef __FUNCT____FUNCT__204,6190 #define __FUNCT__ __FUNCT__205,6207 PetscErrorCode NEPRegister(const char *name,PetscErrorCode (*function)(NEP))NEPRegister232,6836 #undef __FUNCT____FUNCT__241,7059 #define __FUNCT__ __FUNCT__242,7076 PetscErrorCode NEPReset_Problem(NEP nep)NEPReset_Problem246,7173 #undef __FUNCT____FUNCT__267,7855 #define __FUNCT__ __FUNCT__268,7872 PetscErrorCode NEPReset(NEP nep)NEPReset282,8147 #undef __FUNCT____FUNCT__305,8934 #define __FUNCT__ __FUNCT__306,8951 PetscErrorCode NEPDestroy(NEP *nep)NEPDestroy319,9197 #undef __FUNCT____FUNCT__342,10084 #define __FUNCT__ __FUNCT__343,10101 PetscErrorCode NEPSetBV(NEP nep,BV bv)NEPSetBV361,10518 #undef __FUNCT____FUNCT__376,10963 #define __FUNCT__ __FUNCT__377,10980 PetscErrorCode NEPGetBV(NEP nep,BV *bv)NEPGetBV394,11304 #undef __FUNCT____FUNCT__409,11695 #define __FUNCT__ __FUNCT__410,11712 PetscErrorCode NEPSetRG(NEP nep,RG rg)NEPSetRG428,12108 #undef __FUNCT____FUNCT__443,12556 #define __FUNCT__ __FUNCT__444,12573 PetscErrorCode NEPGetRG(NEP nep,RG *rg)NEPGetRG461,12883 #undef __FUNCT____FUNCT__476,13278 #define __FUNCT__ __FUNCT__477,13295 PetscErrorCode NEPSetDS(NEP nep,DS ds)NEPSetDS495,13712 #undef __FUNCT____FUNCT__510,14160 #define __FUNCT__ __FUNCT__511,14177 PetscErrorCode NEPGetDS(NEP nep,DS *ds)NEPGetDS528,14501 #undef __FUNCT____FUNCT__543,14896 #define __FUNCT__ __FUNCT__544,14913 PetscErrorCode NEPRefineGetKSP(NEP nep,KSP *ksp)NEPRefineGetKSP561,15244 #undef __FUNCT____FUNCT__586,16383 #define __FUNCT__ __FUNCT__587,16400 PetscErrorCode NEPSetTarget(NEP nep,PetscScalar target)NEPSetTarget612,17098 #undef __FUNCT____FUNCT__621,17329 #define __FUNCT__ __FUNCT__622,17346 PetscErrorCode NEPGetTarget(NEP nep,PetscScalar* target)NEPGetTarget641,17687 #undef __FUNCT____FUNCT__650,17906 #define __FUNCT__ __FUNCT__651,17923 PetscErrorCode NEPSetFunction(NEP nep,Mat A,Mat B,PetscErrorCode (*fun)(NEP,PetscScalar,Mat,Mat,void*),void *ctx)NEPSetFunction681,18977 #undef __FUNCT____FUNCT__712,19980 #define __FUNCT__ __FUNCT__713,19997 PetscErrorCode NEPGetFunction(NEP nep,Mat *A,Mat *B,PetscErrorCode (**fun)(NEP,PetscScalar,Mat,Mat,void*),void **ctx)NEPGetFunction733,20585 #undef __FUNCT____FUNCT__745,20976 #define __FUNCT__ __FUNCT__746,20993 PetscErrorCode NEPSetJacobian(NEP nep,Mat A,PetscErrorCode (*jac)(NEP,PetscScalar,Mat,void*),void *ctx)NEPSetJacobian774,21900 #undef __FUNCT____FUNCT__798,22639 #define __FUNCT__ __FUNCT__799,22656 PetscErrorCode NEPGetJacobian(NEP nep,Mat *A,PetscErrorCode (**jac)(NEP,PetscScalar,Mat,void*),void **ctx)NEPGetJacobian818,23197 #undef __FUNCT____FUNCT__829,23540 #define __FUNCT__ __FUNCT__830,23557 PetscErrorCode NEPSetSplitOperator(NEP nep,PetscInt n,Mat A[],FN f[],MatStructure str)NEPSetSplitOperator862,24654 #undef __FUNCT____FUNCT__901,26148 #define __FUNCT__ __FUNCT__902,26165 PetscErrorCode NEPGetSplitOperatorTerm(NEP nep,PetscInt k,Mat *A,FN *f)NEPGetSplitOperatorTerm921,26730 #undef __FUNCT____FUNCT__932,27092 #define __FUNCT__ __FUNCT__933,27109 PetscErrorCode NEPGetSplitOperatorInfo(NEP nep,PetscInt *n,MatStructure *str)NEPGetSplitOperatorInfo951,27628 #undef __FUNCT____FUNCT__961,27884 #define __FUNCT__ __FUNCT__962,27901 PetscErrorCode NEPSetDerivatives(NEP nep,Mat A,PetscErrorCode (*der)(NEP,PetscScalar,PetscInt,Mat,void*),void *ctx)NEPSetDerivatives982,28616 #undef __FUNCT____FUNCT__1006,29385 #define __FUNCT__ __FUNCT__1007,29402 PetscErrorCode NEPGetDerivatives(NEP nep,Mat *A,PetscErrorCode (**der)(NEP,PetscScalar,PetscInt,Mat,void*),void **ctx)NEPGetDerivatives1026,29971 src/nep/interface/nepdefault.c,1362 nepdefault.c:^?nepdefault.c^A,1 #undef __FUNCT____FUNCT__26,1066 #define __FUNCT__ __FUNCT__27,1083 PetscErrorCode NEPSetWorkVecs(NEP nep,PetscInt nw)NEPSetWorkVecs43,1453 #undef __FUNCT____FUNCT__60,1947 #define __FUNCT__ __FUNCT__61,1964 PetscErrorCode NEPGetDefaultShift(NEP nep,PetscScalar *sigma)NEPGetDefaultShift65,2093 #undef __FUNCT____FUNCT__95,2801 #define __FUNCT__ __FUNCT__96,2818 PetscErrorCode NEPConvergedRelative(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)NEPConvergedRelative100,2937 #undef __FUNCT____FUNCT__110,3183 #define __FUNCT__ __FUNCT__111,3200 PetscErrorCode NEPConvergedAbsolute(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)NEPConvergedAbsolute115,3303 #undef __FUNCT____FUNCT__122,3494 #define __FUNCT__ __FUNCT__123,3511 PetscErrorCode NEPConvergedNorm(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)NEPConvergedNorm127,3624 #undef __FUNCT____FUNCT__153,4621 #define __FUNCT__ __FUNCT__154,4638 PetscErrorCode NEPStoppingBasic(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,void *ctx)NEPStoppingBasic187,5772 #undef __FUNCT____FUNCT__203,6407 #define __FUNCT__ __FUNCT__204,6424 PetscErrorCode NEPComputeVectors_Schur(NEP nep)NEPComputeVectors_Schur205,6468 src/nep/interface/nepmon.c,2314 nepmon.c:^?nepmon.c^A,1 #undef __FUNCT____FUNCT__27,1050 #define __FUNCT__ __FUNCT__28,1067 PetscErrorCode NEPMonitor(NEP nep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)NEPMonitor32,1156 #undef __FUNCT____FUNCT__44,1537 #define __FUNCT__ __FUNCT__45,1554 PetscErrorCode NEPMonitorSet(NEP nep,PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))NEPMonitorSet94,3582 #undef __FUNCT____FUNCT__105,4197 #define __FUNCT__ __FUNCT__106,4214 PetscErrorCode NEPMonitorCancel(NEP nep)NEPMonitorCancel124,4687 #undef __FUNCT____FUNCT__140,5064 #define __FUNCT__ __FUNCT__141,5081 PetscErrorCode NEPGetMonitorContext(NEP nep,void **ctx)NEPGetMonitorContext158,5454 #undef __FUNCT____FUNCT__166,5643 #define __FUNCT__ __FUNCT__167,5660 PetscErrorCode NEPMonitorAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)NEPMonitorAll188,6297 #undef __FUNCT____FUNCT__222,7994 #define __FUNCT__ __FUNCT__223,8011 PetscErrorCode NEPMonitorFirst(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)NEPMonitorFirst244,8658 #undef __FUNCT____FUNCT__276,10328 #define __FUNCT__ __FUNCT__277,10345 PetscErrorCode NEPMonitorConverged(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)NEPMonitorConverged298,10933 #undef __FUNCT____FUNCT__335,12690 #define __FUNCT__ __FUNCT__336,12707 PetscErrorCode NEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)NEPMonitorLGCreate365,13507 #undef __FUNCT____FUNCT__381,14053 #define __FUNCT__ __FUNCT__382,14070 PetscErrorCode NEPMonitorLG(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)NEPMonitorLG383,14103 #undef __FUNCT____FUNCT__407,14949 #define __FUNCT__ __FUNCT__408,14966 PetscErrorCode NEPMonitorLGAll(NEP nep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)NEPMonitorLGAll409,15002 src/nep/interface/nepopts.c,4671 nepopts.c:^?nepopts.c^A,1 #undef __FUNCT____FUNCT__28,1109 #define __FUNCT__ __FUNCT__29,1126 PetscErrorCode NEPMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)NEPMonitorSetFromOptions48,1764 #undef __FUNCT____FUNCT__69,2791 #define __FUNCT__ __FUNCT__70,2808 PetscErrorCode NEPConvMonitorSetFromOptions(NEP nep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(NEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))NEPConvMonitorSetFromOptions88,3426 #undef __FUNCT____FUNCT__106,4327 #define __FUNCT__ __FUNCT__107,4344 PetscErrorCode NEPSetFromOptions(NEP nep)NEPSetFromOptions123,4743 #undef __FUNCT____FUNCT__271,14964 #define __FUNCT__ __FUNCT__272,14981 PetscErrorCode NEPGetTolerances(NEP nep,PetscReal *tol,PetscInt *maxits)NEPGetTolerances293,15447 #undef __FUNCT____FUNCT__302,15691 #define __FUNCT__ __FUNCT__303,15708 PetscErrorCode NEPSetTolerances(NEP nep,PetscReal tol,PetscInt maxits)NEPSetTolerances326,16337 #undef __FUNCT____FUNCT__349,17147 #define __FUNCT__ __FUNCT__350,17164 PetscErrorCode NEPGetDimensions(NEP nep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)NEPGetDimensions372,17728 #undef __FUNCT____FUNCT__382,17995 #define __FUNCT__ __FUNCT__383,18012 PetscErrorCode NEPSetDimensions(NEP nep,PetscInt nev,PetscInt ncv,PetscInt mpd)NEPSetDimensions418,19282 #undef __FUNCT____FUNCT__443,20219 #define __FUNCT__ __FUNCT__444,20236 PetscErrorCode NEPSetWhichEigenpairs(NEP nep,NEPWhich which)NEPSetWhichEigenpairs497,22512 #undef __FUNCT____FUNCT__527,23332 #define __FUNCT__ __FUNCT__528,23349 PetscErrorCode NEPGetWhichEigenpairs(NEP nep,NEPWhich *which)NEPGetWhichEigenpairs548,23806 #undef __FUNCT____FUNCT__557,24021 #define __FUNCT__ __FUNCT__558,24038 PetscErrorCode NEPSetEigenvalueComparison(NEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)NEPSetEigenvalueComparison590,25180 #undef __FUNCT____FUNCT__600,25537 #define __FUNCT__ __FUNCT__601,25554 PetscErrorCode NEPSetConvergenceTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))NEPSetConvergenceTestFunction632,26734 #undef __FUNCT____FUNCT__651,27464 #define __FUNCT__ __FUNCT__652,27481 PetscErrorCode NEPSetConvergenceTest(NEP nep,NEPConv conv)NEPSetConvergenceTest679,28459 #undef __FUNCT____FUNCT__696,29055 #define __FUNCT__ __FUNCT__697,29072 PetscErrorCode NEPGetConvergenceTest(NEP nep,NEPConv *conv)NEPGetConvergenceTest714,29472 #undef __FUNCT____FUNCT__723,29682 #define __FUNCT__ __FUNCT__724,29699 PetscErrorCode NEPSetStoppingTestFunction(NEP nep,PetscErrorCode (*func)(NEP,PetscInt,PetscInt,PetscInt,PetscInt,NEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))NEPSetStoppingTestFunction758,31045 #undef __FUNCT____FUNCT__775,31644 #define __FUNCT__ __FUNCT__776,31661 PetscErrorCode NEPSetStoppingTest(NEP nep,NEPStop stop)NEPSetStoppingTest800,32400 #undef __FUNCT____FUNCT__815,32854 #define __FUNCT__ __FUNCT__816,32871 PetscErrorCode NEPGetStoppingTest(NEP nep,NEPStop *stop)NEPGetStoppingTest833,33259 #undef __FUNCT____FUNCT__842,33466 #define __FUNCT__ __FUNCT__843,33483 PetscErrorCode NEPSetTrackAll(NEP nep,PetscBool trackall)NEPSetTrackAll866,34217 #undef __FUNCT____FUNCT__875,34454 #define __FUNCT__ __FUNCT__876,34471 PetscErrorCode NEPGetTrackAll(NEP nep,PetscBool *trackall)NEPGetTrackAll893,34793 #undef __FUNCT____FUNCT__902,35014 #define __FUNCT__ __FUNCT__903,35031 PetscErrorCode NEPSetRefine(NEP nep,NEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,NEPRefineScheme scheme)NEPSetRefine952,37111 #undef __FUNCT____FUNCT__991,38639 #define __FUNCT__ __FUNCT__992,38656 PetscErrorCode NEPGetRefine(NEP nep,NEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,NEPRefineScheme *scheme)NEPGetRefine1016,39261 #undef __FUNCT____FUNCT__1028,39665 #define __FUNCT__ __FUNCT__1029,39682 PetscErrorCode NEPSetOptionsPrefix(NEP nep,const char *prefix)NEPSetOptionsPrefix1056,40435 #undef __FUNCT____FUNCT__1072,41068 #define __FUNCT__ __FUNCT__1073,41085 PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char *prefix)NEPAppendOptionsPrefix1092,41644 #undef __FUNCT____FUNCT__1108,42283 #define __FUNCT__ __FUNCT__1109,42300 PetscErrorCode NEPGetOptionsPrefix(NEP nep,const char *prefix[])NEPGetOptionsPrefix1130,42813 src/nep/interface/neprefine.c,1837 neprefine.c:^?neprefine.c^A,1 #define NREF_MAXIT NREF_MAXIT27,1036 PetscSubcomm subc;subc30,1076 VecScatter *scatter_id,nst;scatter_id31,1098 VecScatter *scatter_id,nst;nst31,1098 Mat *A;A32,1131 Vec nv,vg,v,w;nv33,1151 Vec nv,vg,v,w;vg33,1151 Vec nv,vg,v,w;v33,1151 Vec nv,vg,v,w;w33,1151 FN *fn;fn34,1178 } NEPSimpNRefctx;NEPSimpNRefctx35,1199 Mat M1;M138,1235 Vec M2,M3;M239,1254 Vec M2,M3;M339,1254 PetscScalar M4,m3;M440,1276 PetscScalar M4,m3;m340,1276 } FSubctx;FSubctx41,1298 #undef __FUNCT____FUNCT__43,1310 #define __FUNCT__ __FUNCT__44,1327 static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)MatFSMult45,1357 #undef __FUNCT____FUNCT__60,1742 #define __FUNCT__ __FUNCT__61,1759 static PetscErrorCode NEPSimpleNRefSetUp(NEP nep,NEPSimpNRefctx **ctx_)NEPSimpleNRefSetUp62,1798 #undef __FUNCT____FUNCT__143,5061 #define __FUNCT__ __FUNCT__144,5078 static PetscErrorCode NEPSimpleNRefGatherEigenpair(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail)NEPSimpleNRefGatherEigenpair145,5127 #undef __FUNCT____FUNCT__186,6829 #define __FUNCT__ __FUNCT__187,6846 static PetscErrorCode NEPSimpleNRefScatterEigenvector(NEP nep,NEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx)NEPSimpleNRefScatterEigenvector188,6898 #undef __FUNCT____FUNCT__212,7768 #define __FUNCT__ __FUNCT__213,7785 static PetscErrorCode NEPSimpleNRefSetUpSystem(NEP nep,NEPSimpNRefctx *ctx,Mat *A,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v)NEPSimpleNRefSetUpSystem214,7830 #undef __FUNCT____FUNCT__389,14598 #define __FUNCT__ __FUNCT__390,14615 PetscErrorCode NEPNewtonRefinementSimple(NEP nep,PetscInt *maxits,PetscReal tol,PetscInt k)NEPNewtonRefinementSimple391,14661 src/nep/interface/nepregis.c,131 nepregis.c:^?nepregis.c^A,1 #undef __FUNCT____FUNCT__31,1289 #define __FUNCT__ __FUNCT__32,1306 PetscErrorCode NEPRegisterAll(void)NEPRegisterAll42,1481 src/nep/interface/nepsetup.c,652 nepsetup.c:^?nepsetup.c^A,1 #undef __FUNCT____FUNCT__26,1033 #define __FUNCT__ __FUNCT__27,1050 PetscErrorCode NEPSetUp(NEP nep)NEPSetUp46,1528 #undef __FUNCT____FUNCT__220,8799 #define __FUNCT__ __FUNCT__221,8816 PetscErrorCode NEPSetInitialSpace(NEP nep,PetscInt n,Vec *is)NEPSetInitialSpace248,9728 #undef __FUNCT____FUNCT__261,10190 #define __FUNCT__ __FUNCT__262,10207 PetscErrorCode NEPSetDimensions_Default(NEP nep,PetscInt nev,PetscInt *ncv,PetscInt *mpd)NEPSetDimensions_Default267,10374 #undef __FUNCT____FUNCT__285,10970 #define __FUNCT__ __FUNCT__286,10987 PetscErrorCode NEPAllocateSolution(NEP nep,PetscInt extra)NEPAllocateSolution304,11478 src/nep/interface/nepsolve.c,2449 nepsolve.c:^?nepsolve.c^A,1 #undef __FUNCT____FUNCT__27,1063 #define __FUNCT__ __FUNCT__28,1080 PetscErrorCode NEPComputeVectors(NEP nep)NEPComputeVectors29,1118 #undef __FUNCT____FUNCT__48,1490 #define __FUNCT__ __FUNCT__49,1507 PetscErrorCode NEPSolve(NEP nep)NEPSolve70,2212 #undef __FUNCT____FUNCT__119,3870 #define __FUNCT__ __FUNCT__120,3887 PetscErrorCode NEPProjectOperator(NEP nep,PetscInt j0,PetscInt j1)NEPProjectOperator145,4670 #undef __FUNCT____FUNCT__166,5320 #define __FUNCT__ __FUNCT__167,5337 PetscErrorCode NEPApplyFunction(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A,Mat B)NEPApplyFunction195,6215 #undef __FUNCT____FUNCT__224,7178 #define __FUNCT__ __FUNCT__225,7195 PetscErrorCode NEPApplyJacobian(NEP nep,PetscScalar lambda,Vec x,Vec v,Vec y,Mat A)NEPApplyJacobian252,8028 #undef __FUNCT____FUNCT__280,8933 #define __FUNCT__ __FUNCT__281,8950 PetscErrorCode NEPGetIterationNumber(NEP nep,PetscInt *its)NEPGetIterationNumber306,9714 #undef __FUNCT____FUNCT__315,9924 #define __FUNCT__ __FUNCT__316,9941 PetscErrorCode NEPGetConverged(NEP nep,PetscInt *nconv)NEPGetConverged335,10331 #undef __FUNCT____FUNCT__345,10568 #define __FUNCT__ __FUNCT__346,10585 PetscErrorCode NEPGetConvergedReason(NEP nep,NEPConvergedReason *reason)NEPGetConvergedReason374,11405 #undef __FUNCT____FUNCT__384,11659 #define __FUNCT__ __FUNCT__385,11676 PetscErrorCode NEPGetEigenpair(NEP nep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)NEPGetEigenpair420,12961 #undef __FUNCT____FUNCT__467,14592 #define __FUNCT__ __FUNCT__468,14609 PetscErrorCode NEPGetErrorEstimate(NEP nep,PetscInt i,PetscReal *errest)NEPGetErrorEstimate490,15123 #undef __FUNCT____FUNCT__501,15508 #define __FUNCT__ __FUNCT__502,15525 PetscErrorCode NEPComputeResidualNorm_Private(NEP nep,PetscScalar lambda,Vec x,Vec *w,PetscReal *norm)NEPComputeResidualNorm_Private512,15851 #undef __FUNCT____FUNCT__525,16260 #define __FUNCT__ __FUNCT__526,16277 PetscErrorCode NEPComputeError(NEP nep,PetscInt i,NEPErrorType type,PetscReal *error)NEPComputeError550,16903 #undef __FUNCT____FUNCT__623,19259 #define __FUNCT__ __FUNCT__624,19276 PetscErrorCode NEPComputeFunction(NEP nep,PetscScalar lambda,Mat A,Mat B)NEPComputeFunction648,19868 #undef __FUNCT____FUNCT__685,21332 #define __FUNCT__ __FUNCT__686,21349 PetscErrorCode NEPComputeJacobian(NEP nep,PetscScalar lambda,Mat A)NEPComputeJacobian708,21868 src/nep/interface/nepview.c,2594 nepview.c:^?nepview.c^A,1 #undef __FUNCT____FUNCT__27,1058 #define __FUNCT__ __FUNCT__28,1075 PetscErrorCode NEPView(NEP nep,PetscViewer viewer)NEPView56,1872 #undef __FUNCT____FUNCT__190,8510 #define __FUNCT__ __FUNCT__191,8527 PetscErrorCode NEPReasonView(NEP nep,PetscViewer viewer)NEPReasonView208,8982 #undef __FUNCT____FUNCT__227,9979 #define __FUNCT__ __FUNCT__228,9996 PetscErrorCode NEPReasonViewFromOptions(NEP nep)NEPReasonViewFromOptions240,10284 #undef __FUNCT____FUNCT__262,11015 #define __FUNCT__ __FUNCT__263,11032 static PetscErrorCode NEPErrorView_ASCII(NEP nep,NEPErrorType etype,PetscViewer viewer)NEPErrorView_ASCII264,11071 #undef __FUNCT____FUNCT__317,13134 #define __FUNCT__ __FUNCT__318,13151 static PetscErrorCode NEPErrorView_DETAIL(NEP nep,NEPErrorType etype,PetscViewer viewer)NEPErrorView_DETAIL319,13191 #define EXLEN EXLEN325,13379 #undef __FUNCT____FUNCT__362,14659 #define __FUNCT__ __FUNCT__363,14676 static PetscErrorCode NEPErrorView_MATLAB(NEP nep,NEPErrorType etype,PetscViewer viewer)NEPErrorView_MATLAB364,14716 #undef __FUNCT____FUNCT__382,15328 #define __FUNCT__ __FUNCT__383,15345 PetscErrorCode NEPErrorView(NEP nep,NEPErrorType etype,PetscViewer viewer)NEPErrorView410,16238 #undef __FUNCT____FUNCT__443,17415 #define __FUNCT__ __FUNCT__444,17432 PetscErrorCode NEPErrorViewFromOptions(NEP nep)NEPErrorViewFromOptions456,17730 #undef __FUNCT____FUNCT__492,19296 #define __FUNCT__ __FUNCT__493,19313 static PetscErrorCode NEPValuesView_DRAW(NEP nep,PetscViewer viewer)NEPValuesView_DRAW494,19352 #undef __FUNCT____FUNCT__525,20385 #define __FUNCT__ __FUNCT__526,20402 static PetscErrorCode NEPValuesView_ASCII(NEP nep,PetscViewer viewer)NEPValuesView_ASCII527,20442 #undef __FUNCT____FUNCT__556,21330 #define __FUNCT__ __FUNCT__557,21347 static PetscErrorCode NEPValuesView_MATLAB(NEP nep,PetscViewer viewer)NEPValuesView_MATLAB558,21388 #undef __FUNCT____FUNCT__587,22263 #define __FUNCT__ __FUNCT__588,22280 PetscErrorCode NEPValuesView(NEP nep,PetscViewer viewer)NEPValuesView605,22657 #undef __FUNCT____FUNCT__639,23912 #define __FUNCT__ __FUNCT__640,23929 PetscErrorCode NEPValuesViewFromOptions(NEP nep)NEPValuesViewFromOptions652,24218 #undef __FUNCT____FUNCT__674,24944 #define __FUNCT__ __FUNCT__675,24961 PetscErrorCode NEPVectorsView(NEP nep,PetscViewer viewer)NEPVectorsView697,25538 #define NMLEN NMLEN702,25663 #undef __FUNCT____FUNCT__727,26546 #define __FUNCT__ __FUNCT__728,26563 PetscErrorCode NEPVectorsViewFromOptions(NEP nep)NEPVectorsViewFromOptions740,26855 src/nep/makefile,211 makefile:^?makefile^A,1 SOURCEH = ../../include/slepc/private/nepimpl.h ../../include/slepcnep.hSOURCEH24,936 DIRS = interface impls examples f90-modDIRS25,1010 LOCDIR = src/nep/LOCDIR26,1054 MANSEC = NEPMANSEC27,1074 src/pep/examples/makefile,88 makefile:^?makefile^A,1 LOCDIR = src/pep/examples/LOCDIR24,932 DIRS = tests tutorials nlevpDIRS25,961 src/pep/examples/nlevp/acoustic_wave_1d.c,216 acoustic_wave_1d.c:^?acoustic_wave_1d.c^A,1 static char help[] = "Quadratic eigenproblem from an acoustics application (1-D).\n\n"help35,1515 #undef __FUNCT____FUNCT__42,1773 #define __FUNCT__ __FUNCT__43,1790 int main(int argc,char **argv)main44,1815 src/pep/examples/nlevp/acoustic_wave_2d.c,216 acoustic_wave_2d.c:^?acoustic_wave_2d.c^A,1 static char help[] = "Quadratic eigenproblem from an acoustics application (2-D).\n\n"help33,1387 #undef __FUNCT____FUNCT__40,1666 #define __FUNCT__ __FUNCT__41,1683 int main(int argc,char **argv)main42,1708 src/pep/examples/nlevp/butterfly.c,238 butterfly.c:^?butterfly.c^A,1 static char help[] = "Quartic polynomial eigenproblem with T-even structure.\n\n"help32,1346 #define NMAT NMAT39,1638 #undef __FUNCT____FUNCT__41,1654 #define __FUNCT__ __FUNCT__42,1671 int main(int argc,char **argv)main43,1696 src/pep/examples/nlevp/damped_beam.c,218 damped_beam.c:^?damped_beam.c^A,1 static char help[] = "Quadratic eigenproblem from the vibrarion analysis of a beam.\n\n"help33,1414 #undef __FUNCT____FUNCT__39,1612 #define __FUNCT__ __FUNCT__40,1629 int main(int argc,char **argv)main41,1654 src/pep/examples/nlevp/makefile,629 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/pep/examples/nlevp/LOCDIR26,978 EXAMPLESC = acoustic_wave_1d.c acoustic_wave_2d.c butterfly.c damped_beam.c \EXAMPLESC27,1015 EXAMPLESF = EXAMPLESF29,1162 MANSEC = PEPMANSEC30,1176 TESTS = acoustic_wave_1d acoustic_wave_2d butterfly damped_beam \TESTS31,1193 TESTEXAMPLES_C = acoustic_wave_1d.PETSc runacoustic_wave_1d_1 acoustic_wave_1d.rm \TESTEXAMPLES_C34,1325 TESTEXAMPLES_C_COMPLEX = pdde_stability.PETSc runpdde_stability pdde_stability.rmTESTEXAMPLES_C_COMPLEX41,1808 src/pep/examples/nlevp/pdde_stability.c,458 pdde_stability.c:^?pdde_stability.c^A,1 static char help[] = "Stability analysis of a discretized partial delay-differential equation.\n\n"help34,1455 #define NMAT NMAT41,1760 #undef __FUNCT____FUNCT__43,1776 #define __FUNCT__ __FUNCT__44,1793 PetscErrorCode MyEigenSort(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)MyEigenSort52,2118 #undef __FUNCT____FUNCT__63,2450 #define __FUNCT__ __FUNCT__64,2467 int main(int argc,char **argv)main65,2492 src/pep/examples/nlevp/planar_waveguide.c,281 planar_waveguide.c:^?planar_waveguide.c^A,1 static char help[] = "FEM solution of the propagation constants in a six-layer planar waveguide.\n\n"help34,1462 #define NMAT NMAT40,1674 #define NL NL41,1689 #undef __FUNCT____FUNCT__43,1705 #define __FUNCT__ __FUNCT__44,1722 int main(int argc,char **argv)main45,1747 src/pep/examples/nlevp/sleeper.c,206 sleeper.c:^?sleeper.c^A,1 static char help[] = "Oscillations of a rail track resting on sleepers.\n\n"help33,1403 #undef __FUNCT____FUNCT__39,1598 #define __FUNCT__ __FUNCT__40,1615 int main(int argc,char **argv)main41,1640 src/pep/examples/nlevp/spring.c,198 spring.c:^?spring.c^A,1 static char help[] = "FEM model of a damped mass-spring system.\n\n"help36,1651 #undef __FUNCT____FUNCT__45,2014 #define __FUNCT__ __FUNCT__46,2031 int main(int argc,char **argv)main47,2056 src/pep/examples/tests/makefile,606 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/pep/examples/tests/LOCDIR26,978 EXAMPLESC = test1.c test2.c test3.cEXAMPLESC27,1015 EXAMPLESF = test3f.FEXAMPLESF28,1052 MANSEC = PEPMANSEC29,1074 TESTS = test1 test2 test3 test3fTESTS30,1091 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \TESTEXAMPLES_C32,1130 TESTEXAMPLES_FORTRAN = test3f.PETSc runtest3f_1 test3f.rm \TESTEXAMPLES_FORTRAN35,1332 PEP = toar qarnoldiPEP56,1878 EPS = krylovschur gdEPS57,1898 TESTCODE = \TESTCODE59,1920 src/pep/examples/tests/test1.c,235 test1.c:^?test1.c^A,1 static char help[] = "Test the solution of a PEP without calling PEPSetFromOptions (based on ex16.c).\n\n"help22,924 #undef __FUNCT____FUNCT__31,1344 #define __FUNCT__ __FUNCT__32,1361 int main(int argc,char **argv)main33,1386 src/pep/examples/tests/test2.c,211 test2.c:^?test2.c^A,1 static char help[] = "Test the solution of a PEP from a finite element model of "help32,1387 #undef __FUNCT____FUNCT__41,1762 #define __FUNCT__ __FUNCT__42,1779 int main(int argc,char **argv)main43,1804 src/pep/examples/tests/test3.c,186 test3.c:^?test3.c^A,1 static char help[] = "Test PEP interface functions.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1006 #define __FUNCT__ __FUNCT__27,1023 int main(int argc,char **argv)main28,1048 src/pep/examples/tests/test3f.F,1012 test3f.F:^?test3f.F^A,1 program mainmain24,1075 100 format (/'Diagonal Quadratic Eigenproblem, n =',I3,' (Fortran)')10072,2633 110 format (' Polynomial of degree ',I2)110121,4534 120 format (' Type set to ',A)120131,4821 130 format (' Problem type before changing = ',I2)130137,4967 140 format (' ... changed to ',I2)140143,5185 150 format (' Extraction before changing = ',I2)150149,5329 160 format (' ... changed to ',I2)160155,5544 170 format (' Scaling: ',I2,', alpha=',F6.4,', its=',I2)170168,6001 180 format (' Polynomial basis: ',I2)180176,6241 190 format (' Refinement: ',I2,', tol=',F6.4,', its=',I2', schem=',I2)190188,6604 200 format (' Which = ',I2,', target = ',F3.1)200198,6973 210 format (' Dimensions: nev=',I2,', ncv=',I2,', mpd=',I2)210207,7290 220 format (' Tolerance =',F7.5,', max_its =',I4)220216,7549 230 format (' Convergence test =',I2,', stopping test =',I2)230225,7875 240 format (' Finished - converged reason =',I2,', its=',I4)240254,9103 src/pep/examples/tutorials/ex16.c,192 ex16.c:^?ex16.c^A,1 static char help[] = "Simple quadratic eigenvalue problem.\n\n"help22,924 #undef __FUNCT____FUNCT__29,1195 #define __FUNCT__ __FUNCT__30,1212 int main(int argc,char **argv)main31,1237 src/pep/examples/tutorials/ex16f90.F90,415 ex16f90.F90:^?ex16f90.F90^A,1 program mainmain31,1400 type(MaM53,2002 type(Mat) M, C,C53,2002 type(Mat) M, C, K,K53,2002 type(Mat) M, C, K, A(A53,2002 type(PEP) peppep54,2037 100 format (/'Quadratic Eigenproblem, N=',I6,' (',I4,'x',I4,' grid)')10085,3060 120 format (' Solution method: ',A)120182,6499 130 format (' Number of requested eigenvalues:',I4)130188,6729 src/pep/examples/tutorials/ex17.c,275 ex17.c:^?ex17.c^A,1 static char help[] = "Solves a polynomial eigenproblem P(l)x = 0 with matrices loaded from a file.\n\n"help22,924 #define MAX_MATRICES MAX_MATRICES28,1197 #undef __FUNCT____FUNCT__30,1222 #define __FUNCT__ __FUNCT__31,1239 int main(int argc,char **argv)main32,1264 src/pep/examples/tutorials/ex28.c,1216 ex28.c:^?ex28.c^A,1 static char help[] = "A quadratic eigenproblem defined using shell matrices.\n\n"help22,924 #undef __FUNCT____FUNCT__38,1502 #define __FUNCT__ __FUNCT__39,1519 int main(int argc,char **argv)main40,1544 static void tv(int nx,const PetscScalar *x,PetscScalar *y)tv147,6186 #undef __FUNCT____FUNCT__162,6467 #define __FUNCT__ __FUNCT__163,6484 PetscErrorCode MatMult_Laplacian2D(Mat A,Vec x,Vec y)MatMult_Laplacian2D180,7004 #undef __FUNCT____FUNCT__212,7801 #define __FUNCT__ __FUNCT__213,7818 PetscErrorCode MatGetDiagonal_Laplacian2D(Mat A,Vec diag)MatGetDiagonal_Laplacian2D214,7865 #undef __FUNCT____FUNCT__223,8045 #define __FUNCT__ __FUNCT__224,8062 PetscErrorCode MatMult_Zero(Mat A,Vec x,Vec y)MatMult_Zero228,8160 #undef __FUNCT____FUNCT__237,8326 #define __FUNCT__ __FUNCT__238,8343 PetscErrorCode MatGetDiagonal_Zero(Mat A,Vec diag)MatGetDiagonal_Zero239,8383 #undef __FUNCT____FUNCT__248,8556 #define __FUNCT__ __FUNCT__249,8573 PetscErrorCode MatMult_Identity(Mat A,Vec x,Vec y)MatMult_Identity253,8679 #undef __FUNCT____FUNCT__262,8851 #define __FUNCT__ __FUNCT__263,8868 PetscErrorCode MatGetDiagonal_Identity(Mat A,Vec diag)MatGetDiagonal_Identity264,8912 src/pep/examples/tutorials/makefile,626 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/pep/examples/tutorials/LOCDIR26,978 EXAMPLESC = ex16.c ex17.c ex28.cEXAMPLESC27,1019 EXAMPLESF = ex16f90.F90EXAMPLESF28,1053 MANSEC = PEPMANSEC29,1078 TESTEXAMPLES_C = ex16.PETSc runex16_1 ex16.rm \TESTEXAMPLES_C31,1096 TESTEXAMPLES_C_NOCOMPLEX = ex17.PETSc runex17_1 ex17.rmTESTEXAMPLES_C_NOCOMPLEX33,1210 TESTEXAMPLES_F90 = ex16f90.PETSc runex16f90_1 ex16f90.rmTESTEXAMPLES_F9034,1266 DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matricesDATAPATH55,1807 src/pep/f90-mod/makefile,397 makefile:^?makefile^A,1 SPECIALLIB = yesSPECIALLIB28,1120 SPECIALFASTLIB = yesSPECIALFASTLIB29,1141 CFLAGS =CFLAGS32,1164 FFLAGS =FFLAGS33,1177 SOURCEC =SOURCEC34,1190 SOURCEF = slepcpepmod.FSOURCEF35,1203 SOURCEH =SOURCEH36,1230 LIBBASE = libslepcpepLIBBASE37,1243 MANSEC = PEPMANSEC38,1268 LOCDIR = src/pep/f90-mod/LOCDIR39,1285 CLEANFILES = *.modCLEANFILES40,1315 src/pep/f90-mod/slepcpepmod.F,87 slepcpepmod.F:^?slepcpepmod.F^A,1 module slepcpepdefslepcpepdef22,965 module slepcpepslepcpep32,1203 src/pep/impls/jd/makefile,287 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = pjd.c pjdopt.cSOURCEC26,958 SOURCEF =SOURCEF27,984 SOURCEH = pjdp.hSOURCEH28,995 LIBBASE = libslepcpepLIBBASE29,1013 DIRS =DIRS30,1036 MANSEC = PEPMANSEC31,1047 LOCDIR = src/pep/impls/jd/LOCDIR32,1062 src/pep/impls/jd/pjd.c,3206 pjd.c:^?pjd.c^A,1 #undef __FUNCT____FUNCT__47,1707 #define __FUNCT__ __FUNCT__48,1724 static PetscErrorCode PEPJDDuplicateBasis(PEP pep,BV *basis)PEPJDDuplicateBasis52,1810 #undef __FUNCT____FUNCT__82,2980 #define __FUNCT__ __FUNCT__83,2997 PetscErrorCode PEPSetUp_JD(PEP pep)PEPSetUp_JD84,3029 #undef __FUNCT____FUNCT__141,5612 #define __FUNCT__ __FUNCT__142,5629 static PetscErrorCode PEPJDUpdateTV(PEP pep,PetscInt low,PetscInt high,Vec *w)PEPJDUpdateTV146,5715 #undef __FUNCT____FUNCT__211,8663 #define __FUNCT__ __FUNCT__212,8680 static PetscErrorCode PEPJDOrthogonalize(PetscInt row,PetscInt col,PetscScalar *X,PetscInt ldx,PetscInt *rk,PetscInt *P,PetscScalar *R,PetscInt ldr)PEPJDOrthogonalize216,8768 #undef __FUNCT____FUNCT__271,10716 #define __FUNCT__ __FUNCT__272,10733 static PetscErrorCode PEPJDExtendedPCApply(PC pc,Vec x,Vec y)PEPJDExtendedPCApply276,10822 #undef __FUNCT____FUNCT__333,12887 #define __FUNCT__ __FUNCT__334,12904 static PetscErrorCode PCShellApply_PEPJD(PC pc,Vec x,Vec y)PCShellApply_PEPJD339,13044 #undef __FUNCT____FUNCT__360,13551 #define __FUNCT__ __FUNCT__361,13568 static PetscErrorCode PEPJDCopyToExtendedVec(PEP pep,Vec v,PetscScalar *a,PetscInt na,PetscInt off,Vec vex,PetscBool back)PEPJDCopyToExtendedVec362,13611 #undef __FUNCT____FUNCT__402,15064 #define __FUNCT__ __FUNCT__403,15081 static PetscErrorCode PEPJDComputePResidual(PEP pep,Vec u,PetscScalar theta,Vec p,Vec *work)PEPJDComputePResidual404,15123 #undef __FUNCT____FUNCT__478,18210 #define __FUNCT__ __FUNCT__479,18227 static PetscErrorCode PEPJDProcessInitialSpace(PEP pep,Vec *w)PEPJDProcessInitialSpace480,18272 #undef __FUNCT____FUNCT__514,19592 #define __FUNCT__ __FUNCT__515,19609 static PetscErrorCode PEPJDShellMatMult(Mat P,Vec x,Vec y)PEPJDShellMatMult516,19647 #undef __FUNCT____FUNCT__593,22763 #define __FUNCT__ __FUNCT__594,22780 static PetscErrorCode PEPJDCreateShellPC(PEP pep)PEPJDCreateShellPC595,22819 #undef __FUNCT____FUNCT__638,24766 #define __FUNCT__ __FUNCT__639,24783 static PetscErrorCode PEPJDUpdateExtendedPC(PEP pep,PetscScalar theta)PEPJDUpdateExtendedPC640,24825 #undef __FUNCT____FUNCT__707,27688 #define __FUNCT__ __FUNCT__708,27705 static PetscErrorCode PEPJDPCMatSetUp(PEP pep,PetscScalar theta)PEPJDPCMatSetUp709,27741 #undef __FUNCT____FUNCT__735,28583 #define __FUNCT__ __FUNCT__736,28600 static PetscErrorCode PEPJDEigenvectors(PEP pep)PEPJDEigenvectors737,28638 #undef __FUNCT____FUNCT__773,30033 #define __FUNCT__ __FUNCT__774,30050 static PetscErrorCode PEPJDLockConverged(PEP pep,PetscInt *nv)PEPJDLockConverged775,30089 #undef __FUNCT____FUNCT__855,33838 #define __FUNCT__ __FUNCT__856,33855 PetscErrorCode PEPSolve_JD(PEP pep)PEPSolve_JD857,33887 #undef __FUNCT____FUNCT__1042,41906 #define __FUNCT__ __FUNCT__1043,41923 PetscErrorCode PEPReset_JD(PEP pep)PEPReset_JD1044,41955 #undef __FUNCT____FUNCT__1067,42571 #define __FUNCT__ __FUNCT__1068,42588 PetscErrorCode PEPDestroy_JD(PEP pep)PEPDestroy_JD1069,42622 #undef __FUNCT____FUNCT__1080,42970 #define __FUNCT__ __FUNCT__1081,42987 PETSC_EXTERN PetscErrorCode PEPCreate_JD(PEP pep)PEPCreate_JD1082,43020 src/pep/impls/jd/pjdopt.c,953 pjdopt.c:^?pjdopt.c^A,1 #undef __FUNCT____FUNCT__27,1039 #define __FUNCT__ __FUNCT__28,1056 PetscErrorCode PEPJDSetRestart_JD(PEP pep,PetscReal keep)PEPJDSetRestart_JD29,1095 #undef __FUNCT____FUNCT__42,1472 #define __FUNCT__ __FUNCT__43,1489 PetscErrorCode PEPJDSetRestart(PEP pep,PetscReal keep)PEPJDSetRestart65,2048 #undef __FUNCT____FUNCT__76,2365 #define __FUNCT__ __FUNCT__77,2382 PetscErrorCode PEPJDGetRestart_JD(PEP pep,PetscReal *keep)PEPJDGetRestart_JD78,2421 #undef __FUNCT____FUNCT__87,2591 #define __FUNCT__ __FUNCT__88,2608 PetscErrorCode PEPJDGetRestart(PEP pep,PetscReal *keep)PEPJDGetRestart104,2920 #undef __FUNCT____FUNCT__115,3221 #define __FUNCT__ __FUNCT__116,3238 PetscErrorCode PEPSetFromOptions_JD(PetscOptionItems *PetscOptionsObject,PEP pep)PEPSetFromOptions_JD117,3279 #undef __FUNCT____FUNCT__146,4304 #define __FUNCT__ __FUNCT__147,4321 PetscErrorCode PEPView_JD(PEP pep,PetscViewer viewer)PEPView_JD148,4352 src/pep/impls/jd/pjdp.h,1825 pjdp.h:^?pjdp.h^A,1 #define __PJDP_H__PJDP_H25,977 PetscReal keep; /* restart parameter */keep28,1012 BV V; /* work basis vectors to store the search space */V29,1065 BV W; /* work basis vectors to store the test space */W30,1145 BV *TV; /* work basis vectors to store T*V (each TV[i] is the coefficient for \lambda^i of T*V for the extended T) */TV31,1223 BV *AX; /* work basis vectors to store A_i*X for locked eigenvectors */AX32,1362 BV X; /* locked eigenvectors */X33,1455 PetscScalar *T; /* matrix of the invariant pair */T34,1510 PetscScalar *Tj; /* matrix containing the powers of the invariant pair matrix */Tj35,1574 PetscScalar *XpX; /* X^H*X */XpX36,1667 PC pcshell; /* preconditioner including basic precond+projector */pcshell37,1708 Mat Pshell; /* auxiliary shell matrix */Pshell38,1792 PetscInt nconv; /* number of locked vectors in the invariant pair */nconv39,1850 } PEP_JD;PEP_JD40,1932 PC pc; /* basic preconditioner */pc43,1960 Vec Bp; /* preconditioned residual of derivative polynomial, B\p */Bp44,2016 Vec u; /* Ritz vector */u45,2105 PetscScalar gamma; /* precomputed scalar u'*B\p */gamma46,2152 PetscScalar *M;M47,2213 PetscScalar *ps;ps48,2231 PetscInt ld;ld49,2250 Vec *work;work50,2268 BV X;X51,2289 PetscInt n;n52,2306 } PEP_JD_PCSHELL;PEP_JD_PCSHELL53,2323 Mat P; /* */P56,2359 PEP pep;pep57,2395 Vec *work;work58,2414 PetscScalar theta;theta59,2435 } PEP_JD_MATSHELL;PEP_JD_MATSHELL60,2456 src/pep/impls/krylov/makefile,313 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = pepkrylov.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH = pepkrylov.hSOURCEH28,992 LIBBASE = libslepcpepLIBBASE29,1015 DIRS = qarnoldi toar stoarDIRS30,1038 LOCDIR = src/pep/impls/krylov/LOCDIR31,1069 MANSEC = PEPMANSEC32,1102 src/pep/impls/krylov/pepkrylov.c,285 pepkrylov.c:^?pepkrylov.c^A,1 #undef __FUNCT____FUNCT__28,1092 #define __FUNCT__ __FUNCT__29,1109 PetscErrorCode PEPExtractVectors_TOAR(PEP pep)PEPExtractVectors_TOAR30,1152 #undef __FUNCT____FUNCT__183,7350 #define __FUNCT__ __FUNCT__184,7367 PetscErrorCode PEPReset_TOAR(PEP pep)PEPReset_TOAR185,7401 src/pep/impls/krylov/pepkrylov.h,616 pepkrylov.h:^?pepkrylov.h^A,1 #define __TOAR_H__TOAR_H25,986 PetscReal keep; /* restart parameter */keep28,1021 PetscBool lock; /* locking/non-locking variant */lock29,1073 PetscReal dtol; /* tolerance for deflation */dtol30,1135 PetscInt d; /* polynomial degree */d31,1193 PetscInt ld; /* leading dimension of auxiliary matrices */ld32,1245 PetscInt nq; /* number of TOAR Vectors */nq33,1319 PetscScalar *S,*qB; /* auxiliary matrices */S34,1377 PetscScalar *S,*qB; /* auxiliary matrices */qB34,1377 } PEP_TOAR;PEP_TOAR35,1430 src/pep/impls/krylov/qarnoldi/makefile,289 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = qarnoldi.cSOURCEC26,958 SOURCEF =SOURCEF27,980 SOURCEH =SOURCEH28,991 LIBBASE = libslepcpepLIBBASE29,1002 DIRS =DIRS30,1025 MANSEC = PEPMANSEC31,1036 LOCDIR = src/pep/impls/krylov/qarnoldi/LOCDIR32,1051 src/pep/impls/krylov/qarnoldi/qarnoldi.c,3284 qarnoldi.c:^?qarnoldi.c^A,1 PetscReal keep; /* restart parameter */keep41,1370 PetscBool lock; /* locking/non-locking variant */lock42,1420 } PEP_QARNOLDI;PEP_QARNOLDI43,1480 #undef __FUNCT____FUNCT__45,1497 #define __FUNCT__ __FUNCT__46,1514 PetscErrorCode PEPSetUp_QArnoldi(PEP pep)PEPSetUp_QArnoldi47,1552 #undef __FUNCT____FUNCT__104,4055 #define __FUNCT__ __FUNCT__105,4072 PetscErrorCode PEPExtractVectors_QArnoldi(PEP pep)PEPExtractVectors_QArnoldi106,4119 #undef __FUNCT____FUNCT__132,5022 #define __FUNCT__ __FUNCT__133,5039 static PetscErrorCode PEPQArnoldiCGS(PEP pep,PetscScalar *H,PetscBLASInt ldh,PetscScalar *h,PetscBLASInt j,BV V,Vec t,Vec v,Vec w,PetscReal *onorm,PetscReal *norm,PetscScalar *work)PEPQArnoldiCGS137,5141 #undef __FUNCT____FUNCT__177,6458 #define __FUNCT__ __FUNCT__178,6475 static PetscErrorCode PEPQArnoldi(PEP pep,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,Vec v,Vec w,PetscReal *beta,PetscBool *breakdown,PetscScalar *work)PEPQArnoldi182,6553 #undef __FUNCT____FUNCT__255,9324 #define __FUNCT__ __FUNCT__256,9341 PetscErrorCode PEPSolve_QArnoldi(PEP pep)PEPSolve_QArnoldi257,9379 #undef __FUNCT____FUNCT__355,13333 #define __FUNCT__ __FUNCT__356,13350 static PetscErrorCode PEPQArnoldiSetRestart_QArnoldi(PEP pep,PetscReal keep)PEPQArnoldiSetRestart_QArnoldi357,13401 #undef __FUNCT____FUNCT__370,13809 #define __FUNCT__ __FUNCT__371,13826 PetscErrorCode PEPQArnoldiSetRestart(PEP pep,PetscReal keep)PEPQArnoldiSetRestart393,14403 #undef __FUNCT____FUNCT__404,14732 #define __FUNCT__ __FUNCT__405,14749 static PetscErrorCode PEPQArnoldiGetRestart_QArnoldi(PEP pep,PetscReal *keep)PEPQArnoldiGetRestart_QArnoldi406,14800 #undef __FUNCT____FUNCT__415,15001 #define __FUNCT__ __FUNCT__416,15018 PetscErrorCode PEPQArnoldiGetRestart(PEP pep,PetscReal *keep)PEPQArnoldiGetRestart432,15342 #undef __FUNCT____FUNCT__443,15655 #define __FUNCT__ __FUNCT__444,15672 static PetscErrorCode PEPQArnoldiSetLocking_QArnoldi(PEP pep,PetscBool lock)PEPQArnoldiSetLocking_QArnoldi445,15723 #undef __FUNCT____FUNCT__454,15922 #define __FUNCT__ __FUNCT__455,15939 PetscErrorCode PEPQArnoldiSetLocking(PEP pep,PetscBool lock)PEPQArnoldiSetLocking481,16705 #undef __FUNCT____FUNCT__492,17034 #define __FUNCT__ __FUNCT__493,17051 static PetscErrorCode PEPQArnoldiGetLocking_QArnoldi(PEP pep,PetscBool *lock)PEPQArnoldiGetLocking_QArnoldi494,17102 #undef __FUNCT____FUNCT__503,17303 #define __FUNCT__ __FUNCT__504,17320 PetscErrorCode PEPQArnoldiGetLocking(PEP pep,PetscBool *lock)PEPQArnoldiGetLocking520,17634 #undef __FUNCT____FUNCT__531,17947 #define __FUNCT__ __FUNCT__532,17964 PetscErrorCode PEPSetFromOptions_QArnoldi(PetscOptionItems *PetscOptionsObject,PEP pep)PEPSetFromOptions_QArnoldi533,18011 #undef __FUNCT____FUNCT__553,18815 #define __FUNCT__ __FUNCT__554,18832 PetscErrorCode PEPView_QArnoldi(PEP pep,PetscViewer viewer)PEPView_QArnoldi555,18869 #undef __FUNCT____FUNCT__570,19455 #define __FUNCT__ __FUNCT__571,19472 PetscErrorCode PEPDestroy_QArnoldi(PEP pep)PEPDestroy_QArnoldi572,19512 #undef __FUNCT____FUNCT__585,20078 #define __FUNCT__ __FUNCT__586,20095 PETSC_EXTERN PetscErrorCode PEPCreate_QArnoldi(PEP pep)PEPCreate_QArnoldi587,20134 src/pep/impls/krylov/stoar/makefile,282 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = stoar.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcpepLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = PEPMANSEC31,1033 LOCDIR = src/pep/impls/krylov/stoar/LOCDIR32,1048 src/pep/impls/krylov/stoar/stoar.c,2982 stoar.c:^?stoar.c^A,1 static PetscBool cited = PETSC_FALSE;cited41,1390 static const char citation[] =citation42,1429 #undef __FUNCT____FUNCT__54,1869 #define __FUNCT__ __FUNCT__55,1886 static PetscErrorCode PEPSTOARNorm(PEP pep,PetscInt j,PetscReal *norm)PEPSTOARNorm59,1991 #undef __FUNCT____FUNCT__85,2973 #define __FUNCT__ __FUNCT__86,2990 static PetscErrorCode PEPSTOARqKqMupdates(PEP pep,PetscInt j,Vec *wv)PEPSTOARqKqMupdates87,3030 #undef __FUNCT____FUNCT__121,4092 #define __FUNCT__ __FUNCT__122,4109 PetscErrorCode PEPSetUp_STOAR(PEP pep)PEPSetUp_STOAR123,4144 #undef __FUNCT____FUNCT__198,7719 #define __FUNCT__ __FUNCT__199,7736 static PetscErrorCode PEPSTOAROrth2(PEP pep,PetscInt k,PetscReal *Omega,PetscScalar *y)PEPSTOAROrth2205,7979 #undef __FUNCT____FUNCT__246,10163 #define __FUNCT__ __FUNCT__247,10180 static PetscErrorCode PEPSTOARrun(PEP pep,PetscReal *a,PetscReal *b,PetscReal *omega,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscBool *symmlost,PetscScalar *work,Vec *t_)PEPSTOARrun251,10279 #undef __FUNCT____FUNCT__321,13016 #define __FUNCT__ __FUNCT__322,13033 static PetscErrorCode PEPSTOARTrunc(PEP pep,PetscInt rs1,PetscInt cs1,PetscScalar *work,PetscReal *rwork)PEPSTOARTrunc323,13067 #undef __FUNCT____FUNCT__397,16135 #define __FUNCT__ __FUNCT__398,16152 static PetscErrorCode PEPSTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)PEPSTOARSupdate406,16284 #undef __FUNCT____FUNCT__460,18354 #define __FUNCT__ __FUNCT__461,18371 PetscErrorCode PEPSolve_STOAR(PEP pep)PEPSolve_STOAR462,18406 #undef __FUNCT____FUNCT__601,24137 #define __FUNCT__ __FUNCT__602,24154 PetscErrorCode PEPSetFromOptions_STOAR(PetscOptionItems *PetscOptionsObject,PEP pep)PEPSetFromOptions_STOAR603,24198 #undef __FUNCT____FUNCT__618,24740 #define __FUNCT__ __FUNCT__619,24757 static PetscErrorCode PEPSTOARSetLocking_STOAR(PEP pep,PetscBool lock)PEPSTOARSetLocking_STOAR620,24802 #undef __FUNCT____FUNCT__629,24987 #define __FUNCT__ __FUNCT__630,25004 PetscErrorCode PEPSTOARSetLocking(PEP pep,PetscBool lock)PEPSTOARSetLocking654,25674 #undef __FUNCT____FUNCT__665,25997 #define __FUNCT__ __FUNCT__666,26014 static PetscErrorCode PEPSTOARGetLocking_STOAR(PEP pep,PetscBool *lock)PEPSTOARGetLocking_STOAR667,26059 #undef __FUNCT____FUNCT__676,26246 #define __FUNCT__ __FUNCT__677,26263 PetscErrorCode PEPSTOARGetLocking(PEP pep,PetscBool *lock)PEPSTOARGetLocking693,26564 #undef __FUNCT____FUNCT__704,26871 #define __FUNCT__ __FUNCT__705,26888 PetscErrorCode PEPView_STOAR(PEP pep,PetscViewer viewer)PEPView_STOAR706,26922 #undef __FUNCT____FUNCT__720,27360 #define __FUNCT__ __FUNCT__721,27377 PetscErrorCode PEPDestroy_STOAR(PEP pep)PEPDestroy_STOAR722,27414 #undef __FUNCT____FUNCT__733,27771 #define __FUNCT__ __FUNCT__734,27788 PETSC_EXTERN PetscErrorCode PEPCreate_STOAR(PEP pep)PEPCreate_STOAR735,27824 src/pep/impls/krylov/toar/makefile,292 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = ptoar.c nrefine.cSOURCEC26,958 SOURCEF =SOURCEF27,987 SOURCEH =SOURCEH28,998 LIBBASE = libslepcpepLIBBASE29,1009 DIRS =DIRS30,1032 MANSEC = PEPMANSEC31,1043 LOCDIR = src/pep/impls/krylov/toar/LOCDIR32,1058 src/pep/impls/krylov/toar/nrefine.c,6590 nrefine.c:^?nrefine.c^A,1 Mat *A,M1;A37,1396 Mat *A,M1;M137,1396 BV V,M2,M3,W;V38,1418 BV V,M2,M3,W;M238,1418 BV V,M2,M3,W;M338,1418 BV V,M2,M3,W;W38,1418 PetscInt k,nmat;k39,1444 PetscInt k,nmat;nmat39,1444 PetscScalar *fih,*work,*M4;fih40,1467 PetscScalar *fih,*work,*M4;work40,1467 PetscScalar *fih,*work,*M4;M440,1467 PetscBLASInt *pM4;pM441,1498 PetscBool compM1;compM142,1519 Vec t;t43,1542 } FSubctx;FSubctx44,1560 Mat E[2],M1;E47,1589 Mat E[2],M1;M147,1589 Vec tN,ttN,t1,vseq;tN48,1613 Vec tN,ttN,t1,vseq;ttN48,1613 Vec tN,ttN,t1,vseq;t148,1613 Vec tN,ttN,t1,vseq;vseq48,1613 VecScatter scatterctx;scatterctx49,1644 PetscBool compM1;compM150,1671 PetscInt *map0,*map1,*idxg,*idxp;map051,1694 PetscInt *map0,*map1,*idxg,*idxp;map151,1694 PetscInt *map0,*map1,*idxg,*idxp;idxg51,1694 PetscInt *map0,*map1,*idxg,*idxp;idxp51,1694 PetscSubcomm subc;subc52,1734 VecScatter scatter_sub;scatter_sub53,1755 VecScatter *scatter_id,*scatterp_id;scatter_id54,1783 VecScatter *scatter_id,*scatterp_id;scatterp_id54,1783 Mat *A;A55,1824 BV V,W,M2,M3,Wt;V56,1843 BV V,W,M2,M3,Wt;W56,1843 BV V,W,M2,M3,Wt;M256,1843 BV V,W,M2,M3,Wt;M356,1843 BV V,W,M2,M3,Wt;Wt56,1843 PetscScalar *M4,*w,*wt,*d,*dt;M457,1872 PetscScalar *M4,*w,*wt,*d,*dt;w57,1872 PetscScalar *M4,*w,*wt,*d,*dt;wt57,1872 PetscScalar *M4,*w,*wt,*d,*dt;d57,1872 PetscScalar *M4,*w,*wt,*d,*dt;dt57,1872 Vec t,tg,Rv,Vi,tp,tpg;t58,1906 Vec t,tg,Rv,Vi,tp,tpg;tg58,1906 Vec t,tg,Rv,Vi,tp,tpg;Rv58,1906 Vec t,tg,Rv,Vi,tp,tpg;Vi58,1906 Vec t,tg,Rv,Vi,tp,tpg;tp58,1906 Vec t,tg,Rv,Vi,tp,tpg;tpg58,1906 PetscInt idx,*cols;idx59,1940 PetscInt idx,*cols;cols59,1940 } MatExplicitCtx;MatExplicitCtx60,1966 #undef __FUNCT____FUNCT__62,1985 #define __FUNCT__ __FUNCT__63,2002 static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)MatFSMult64,2032 #undef __FUNCT____FUNCT__92,2932 #define __FUNCT__ __FUNCT__93,2949 static PetscErrorCode PEPEvaluateBasisforMatrix(PEP pep,PetscInt nm,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH)PEPEvaluateBasisforMatrix98,3117 #undef __FUNCT____FUNCT__142,4511 #define __FUNCT__ __FUNCT__143,4528 static PetscErrorCode NRefSysSetup_shell(PEP pep,PetscInt k,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,FSubctx *ctx)NRefSysSetup_shell144,4567 #undef __FUNCT____FUNCT__250,9082 #define __FUNCT__ __FUNCT__251,9099 static PetscErrorCode NRefSysSolve_shell(KSP ksp,PetscInt nmat,Vec Rv,PetscScalar *Rh,PetscInt k,Vec dVi,PetscScalar *dHi)NRefSysSolve_shell252,9138 #undef __FUNCT____FUNCT__285,10437 #define __FUNCT__ __FUNCT__286,10454 static PetscErrorCode NRefRightSide(PetscInt nmat,PetscReal *pcf,Mat *A,PetscInt k,BV V,PetscScalar *S,PetscInt lds,PetscInt j,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *DfH,PetscScalar *dH,BV dV,PetscScalar *dVS,PetscInt rds,Vec Rv,PetscScalar *Rh,BV W,Vec t)NRefRightSide290,10551 #undef __FUNCT____FUNCT__376,14440 #define __FUNCT__ __FUNCT__377,14457 static PetscErrorCode NRefSysSolve_mbe(PetscInt k,PetscInt sz,BV W,PetscScalar *w,BV Wt,PetscScalar *wt,PetscScalar *d,PetscScalar *dt,KSP ksp,BV T2,BV T3 ,PetscScalar *T4,PetscBool trans,Vec x1,PetscScalar *x2,Vec sol1,PetscScalar *sol2,Vec vw)NRefSysSolve_mbe378,14494 #undef __FUNCT____FUNCT__439,16788 #define __FUNCT__ __FUNCT__440,16805 static PetscErrorCode NRefSysSetup_mbe(PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,BV V,MatExplicitCtx *matctx)NRefSysSetup_mbe441,16842 #undef __FUNCT____FUNCT__572,22008 #define __FUNCT__ __FUNCT__573,22025 static PetscErrorCode NRefSysSetup_explicit(PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar h,BV V,MatExplicitCtx *matctx,BV W)NRefSysSetup_explicit574,22067 #undef __FUNCT____FUNCT__719,27949 #define __FUNCT__ __FUNCT__720,27966 static PetscErrorCode NRefSysSolve_explicit(PetscInt k,KSP ksp,Vec Rv,PetscScalar *Rh,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx)NRefSysSolve_explicit721,28008 #undef __FUNCT____FUNCT__762,29873 #define __FUNCT__ __FUNCT__763,29890 static PetscErrorCode NRefSysIter(PetscInt i,PEP pep,PetscInt k,KSP ksp,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscScalar *fh,PetscScalar *H,PetscInt ldh,Vec Rv,PetscScalar *Rh,BV V,Vec dVi,PetscScalar *dHi,MatExplicitCtx *matctx,BV W)NRefSysIter764,29922 #undef __FUNCT____FUNCT__874,34877 #define __FUNCT__ __FUNCT__875,34894 static PetscErrorCode PEPNRefForwardSubstitution(PEP pep,PetscInt k,PetscScalar *S,PetscInt lds,PetscScalar *H,PetscInt ldh,PetscScalar *fH,BV dV,PetscScalar *dVS,PetscInt *rds,PetscScalar *dH,PetscInt lddh,KSP ksp,MatExplicitCtx *matctx)PEPNRefForwardSubstitution876,34941 #undef __FUNCT____FUNCT__965,38432 #define __FUNCT__ __FUNCT__966,38449 static PetscErrorCode NRefOrthogStep(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *S,PetscInt lds,PetscInt *prs)NRefOrthogStep967,38484 #undef __FUNCT____FUNCT__1029,41542 #define __FUNCT__ __FUNCT__1030,41559 static PetscErrorCode PEPNRefUpdateInvPair(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,PetscScalar *fH,PetscScalar *dH,PetscScalar *S,PetscInt lds,BV dV,PetscScalar *dVS,PetscInt rds)PEPNRefUpdateInvPair1031,41600 #undef __FUNCT____FUNCT__1092,44188 #define __FUNCT__ __FUNCT__1093,44205 static PetscErrorCode PEPNRefSetUp(PEP pep,PetscInt k,PetscScalar *H,PetscInt ldh,MatExplicitCtx *matctx,PetscBool ini)PEPNRefSetUp1094,44238 #undef __FUNCT____FUNCT__1310,54311 #define __FUNCT__ __FUNCT__1311,54328 static PetscErrorCode NRefSubcommSetup(PEP pep,PetscInt k,MatExplicitCtx *matctx,PetscInt nsubc)NRefSubcommSetup1312,54365 #undef __FUNCT____FUNCT__1401,58215 #define __FUNCT__ __FUNCT__1402,58232 static PetscErrorCode NRefSubcommDestroy(PEP pep,MatExplicitCtx *matctx)NRefSubcommDestroy1403,58271 #undef __FUNCT____FUNCT__1433,59338 #define __FUNCT__ __FUNCT__1434,59355 PetscErrorCode PEPNewtonRefinement_TOAR(PEP pep,PetscScalar sigma,PetscInt *maxits,PetscReal *tol,PetscInt k,PetscScalar *S,PetscInt lds,PetscInt *prs)PEPNewtonRefinement_TOAR1435,59400 src/pep/impls/krylov/toar/ptoar.c,4767 ptoar.c:^?ptoar.c^A,1 static PetscBool cited = PETSC_FALSE;cited44,1508 static const char citation[] =citation45,1547 #undef __FUNCT____FUNCT__57,1963 #define __FUNCT__ __FUNCT__58,1980 static PetscErrorCode PEPTOARSNorm2(PetscInt n,PetscScalar *S,PetscReal *norm)PEPTOARSNorm262,2038 #undef __FUNCT____FUNCT__73,2302 #define __FUNCT__ __FUNCT__74,2319 PetscErrorCode PEPSetUp_TOAR(PEP pep)PEPSetUp_TOAR75,2353 #undef __FUNCT____FUNCT__152,5430 #define __FUNCT__ __FUNCT__153,5447 static PetscErrorCode PEPTOAROrth2(PEP pep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt k,PetscScalar *y,PetscReal *norm,PetscBool *lindep,PetscScalar *work)PEPTOAROrth2161,5664 #undef __FUNCT____FUNCT__205,7412 #define __FUNCT__ __FUNCT__206,7429 static PetscErrorCode PEPTOARExtendBasis(PEP pep,PetscBool sinvert,PetscScalar sigma,PetscScalar *S,PetscInt ls,PetscInt nv,BV V,Vec t,PetscScalar *r,PetscInt lr,Vec *t_)PEPTOARExtendBasis219,7905 #undef __FUNCT____FUNCT__291,10507 #define __FUNCT__ __FUNCT__292,10524 static PetscErrorCode PEPTOARCoefficients(PEP pep,PetscBool sinvert,PetscScalar sigma,PetscInt nv,PetscScalar *S,PetscInt ls,PetscScalar *r,PetscInt lr,PetscScalar *x)PEPTOARCoefficients296,10647 #undef __FUNCT____FUNCT__320,11503 #define __FUNCT__ __FUNCT__321,11520 static PetscErrorCode PEPTOARrun(PEP pep,PetscScalar sigma,PetscInt *nq,PetscScalar *S,PetscInt ld,PetscScalar *H,PetscInt ldh,PetscInt k,PetscInt *M,PetscBool *breakdown,PetscScalar *work,Vec *t_)PEPTOARrun325,11608 #undef __FUNCT____FUNCT__377,13526 #define __FUNCT__ __FUNCT__378,13543 static PetscErrorCode PEPTOARTrunc(PEP pep,PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt *rs1a,PetscInt cs1,PetscInt lock,PetscInt newc,PetscBool final,PetscScalar *work,PetscReal *rwork)PEPTOARTrunc382,13625 #undef __FUNCT____FUNCT__524,20051 #define __FUNCT__ __FUNCT__525,20068 static PetscErrorCode PEPTOARSupdate(PetscScalar *S,PetscInt ld,PetscInt deg,PetscInt sr,PetscInt s,PetscInt ncu,PetscInt qr,PetscScalar *Q,PetscInt ldq,PetscScalar *work)PEPTOARSupdate533,20198 #undef __FUNCT____FUNCT__555,21066 #define __FUNCT__ __FUNCT__556,21083 static PetscErrorCode PEPEvaluateBasisM(PEP pep,PetscInt k,PetscScalar *T,PetscInt ldt,PetscInt idx,PetscScalar **Tp,PetscScalar **Tj)PEPEvaluateBasisM562,21285 #undef __FUNCT____FUNCT__589,22273 #define __FUNCT__ __FUNCT__590,22290 static PetscErrorCode PEPExtractInvariantPair(PEP pep,PetscScalar sigma,PetscInt sr,PetscInt k,PetscScalar *S,PetscInt ld,PetscInt deg,PetscScalar *H,PetscInt ldh,PetscScalar *work)PEPExtractInvariantPair592,22357 #undef __FUNCT____FUNCT__765,28661 #define __FUNCT__ __FUNCT__766,28678 PetscErrorCode PEPSolve_TOAR(PEP pep)PEPSolve_TOAR767,28712 #undef __FUNCT____FUNCT__939,35790 #define __FUNCT__ __FUNCT__940,35807 static PetscErrorCode PEPTOARSetRestart_TOAR(PEP pep,PetscReal keep)PEPTOARSetRestart_TOAR941,35850 #undef __FUNCT____FUNCT__954,36242 #define __FUNCT__ __FUNCT__955,36259 PetscErrorCode PEPTOARSetRestart(PEP pep,PetscReal keep)PEPTOARSetRestart977,36815 #undef __FUNCT____FUNCT__988,37136 #define __FUNCT__ __FUNCT__989,37153 static PetscErrorCode PEPTOARGetRestart_TOAR(PEP pep,PetscReal *keep)PEPTOARGetRestart_TOAR990,37196 #undef __FUNCT____FUNCT__999,37381 #define __FUNCT__ __FUNCT__1000,37398 PetscErrorCode PEPTOARGetRestart(PEP pep,PetscReal *keep)PEPTOARGetRestart1016,37705 #undef __FUNCT____FUNCT__1027,38010 #define __FUNCT__ __FUNCT__1028,38027 static PetscErrorCode PEPTOARSetLocking_TOAR(PEP pep,PetscBool lock)PEPTOARSetLocking_TOAR1029,38070 #undef __FUNCT____FUNCT__1038,38253 #define __FUNCT__ __FUNCT__1039,38270 PetscErrorCode PEPTOARSetLocking(PEP pep,PetscBool lock)PEPTOARSetLocking1063,38935 #undef __FUNCT____FUNCT__1074,39256 #define __FUNCT__ __FUNCT__1075,39273 static PetscErrorCode PEPTOARGetLocking_TOAR(PEP pep,PetscBool *lock)PEPTOARGetLocking_TOAR1076,39316 #undef __FUNCT____FUNCT__1085,39501 #define __FUNCT__ __FUNCT__1086,39518 PetscErrorCode PEPTOARGetLocking(PEP pep,PetscBool *lock)PEPTOARGetLocking1102,39815 #undef __FUNCT____FUNCT__1113,40120 #define __FUNCT__ __FUNCT__1114,40137 PetscErrorCode PEPSetFromOptions_TOAR(PetscOptionItems *PetscOptionsObject,PEP pep)PEPSetFromOptions_TOAR1115,40180 #undef __FUNCT____FUNCT__1135,40951 #define __FUNCT__ __FUNCT__1136,40968 PetscErrorCode PEPView_TOAR(PEP pep,PetscViewer viewer)PEPView_TOAR1137,41001 #undef __FUNCT____FUNCT__1152,41569 #define __FUNCT__ __FUNCT__1153,41586 PetscErrorCode PEPDestroy_TOAR(PEP pep)PEPDestroy_TOAR1154,41622 #undef __FUNCT____FUNCT__1167,42168 #define __FUNCT__ __FUNCT__1168,42185 PETSC_EXTERN PetscErrorCode PEPCreate_TOAR(PEP pep)PEPCreate_TOAR1169,42220 src/pep/impls/linear/linear.c,4911 linear.c:^?linear.c^A,1 #undef __FUNCT____FUNCT__27,1067 #define __FUNCT__ __FUNCT__28,1084 static PetscErrorCode MatMult_Linear_Shift(Mat M,Vec x,Vec y)MatMult_Linear_Shift29,1125 #undef __FUNCT____FUNCT__111,3903 #define __FUNCT__ __FUNCT__112,3920 static PetscErrorCode MatMult_Linear_Sinvert(Mat M,Vec x,Vec y)MatMult_Linear_Sinvert113,3963 #undef __FUNCT____FUNCT__227,7932 #define __FUNCT__ __FUNCT__228,7949 static PetscErrorCode BackTransform_Linear(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)BackTransform_Linear229,7990 #undef __FUNCT____FUNCT__242,8379 #define __FUNCT__ __FUNCT__243,8396 static PetscErrorCode Apply_Linear(ST st,Vec x,Vec y)Apply_Linear244,8429 #undef __FUNCT____FUNCT__255,8686 #define __FUNCT__ __FUNCT__256,8703 PetscErrorCode PEPSetUp_Linear(PEP pep)PEPSetUp_Linear257,8739 #undef __FUNCT____FUNCT__455,19186 #define __FUNCT__ __FUNCT__456,19203 static PetscErrorCode PEPLinearExtract_Residual(PEP pep,EPS eps)PEPLinearExtract_Residual467,19686 #undef __FUNCT____FUNCT__555,23249 #define __FUNCT__ __FUNCT__556,23266 static PetscErrorCode PEPLinearExtract_None(PEP pep,EPS eps)PEPLinearExtract_None561,23408 #undef __FUNCT____FUNCT__608,25109 #define __FUNCT__ __FUNCT__609,25126 static PetscErrorCode PEPLinearExtract_Norm(PEP pep,EPS eps)PEPLinearExtract_Norm619,25572 #undef __FUNCT____FUNCT__673,27517 #define __FUNCT__ __FUNCT__674,27534 PetscErrorCode PEPExtractVectors_Linear(PEP pep)PEPExtractVectors_Linear675,27579 #undef __FUNCT____FUNCT__697,28204 #define __FUNCT__ __FUNCT__698,28221 PetscErrorCode PEPSolve_Linear(PEP pep)PEPSolve_Linear699,28257 #undef __FUNCT____FUNCT__744,29669 #define __FUNCT__ __FUNCT__745,29686 static PetscErrorCode EPSMonitor_Linear(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)EPSMonitor_Linear746,29724 #undef __FUNCT____FUNCT__756,30061 #define __FUNCT__ __FUNCT__757,30078 PetscErrorCode PEPSetFromOptions_Linear(PetscOptionItems *PetscOptionsObject,PEP pep)PEPSetFromOptions_Linear758,30123 #undef __FUNCT____FUNCT__781,31094 #define __FUNCT__ __FUNCT__782,31111 static PetscErrorCode PEPLinearSetCompanionForm_Linear(PEP pep,PetscInt cform)PEPLinearSetCompanionForm_Linear783,31164 #undef __FUNCT____FUNCT__797,31618 #define __FUNCT__ __FUNCT__798,31635 PetscErrorCode PEPLinearSetCompanionForm(PEP pep,PetscInt cform)PEPLinearSetCompanionForm816,32108 #undef __FUNCT____FUNCT__827,32445 #define __FUNCT__ __FUNCT__828,32462 static PetscErrorCode PEPLinearGetCompanionForm_Linear(PEP pep,PetscInt *cform)PEPLinearGetCompanionForm_Linear829,32515 #undef __FUNCT____FUNCT__838,32716 #define __FUNCT__ __FUNCT__839,32733 PetscErrorCode PEPLinearGetCompanionForm(PEP pep,PetscInt *cform)PEPLinearGetCompanionForm856,33137 #undef __FUNCT____FUNCT__867,33462 #define __FUNCT__ __FUNCT__868,33479 static PetscErrorCode PEPLinearSetExplicitMatrix_Linear(PEP pep,PetscBool explicitmatrix)PEPLinearSetExplicitMatrix_Linear869,33533 #undef __FUNCT____FUNCT__878,33761 #define __FUNCT__ __FUNCT__879,33778 PetscErrorCode PEPLinearSetExplicitMatrix(PEP pep,PetscBool explicitmatrix)PEPLinearSetExplicitMatrix897,34291 #undef __FUNCT____FUNCT__908,34660 #define __FUNCT__ __FUNCT__909,34677 static PetscErrorCode PEPLinearGetExplicitMatrix_Linear(PEP pep,PetscBool *explicitmatrix)PEPLinearGetExplicitMatrix_Linear910,34731 #undef __FUNCT____FUNCT__919,34961 #define __FUNCT__ __FUNCT__920,34978 PetscErrorCode PEPLinearGetExplicitMatrix(PEP pep,PetscBool *explicitmatrix)PEPLinearGetExplicitMatrix937,35359 #undef __FUNCT____FUNCT__948,35712 #define __FUNCT__ __FUNCT__949,35729 static PetscErrorCode PEPLinearSetEPS_Linear(PEP pep,EPS eps)PEPLinearSetEPS_Linear950,35772 #undef __FUNCT____FUNCT__964,36205 #define __FUNCT__ __FUNCT__965,36222 PetscErrorCode PEPLinearSetEPS(PEP pep,EPS eps)PEPLinearSetEPS980,36528 #undef __FUNCT____FUNCT__992,36866 #define __FUNCT__ __FUNCT__993,36883 static PetscErrorCode PEPLinearGetEPS_Linear(PEP pep,EPS *eps)PEPLinearGetEPS_Linear994,36926 #undef __FUNCT____FUNCT__1015,37805 #define __FUNCT__ __FUNCT__1016,37822 PetscErrorCode PEPLinearGetEPS(PEP pep,EPS *eps)PEPLinearGetEPS1033,38157 #undef __FUNCT____FUNCT__1044,38443 #define __FUNCT__ __FUNCT__1045,38460 PetscErrorCode PEPView_Linear(PEP pep,PetscViewer viewer)PEPView_Linear1046,38495 #undef __FUNCT____FUNCT__1065,39305 #define __FUNCT__ __FUNCT__1066,39322 PetscErrorCode PEPReset_Linear(PEP pep)PEPReset_Linear1067,39358 #undef __FUNCT____FUNCT__1085,39955 #define __FUNCT__ __FUNCT__1086,39972 PetscErrorCode PEPDestroy_Linear(PEP pep)PEPDestroy_Linear1087,40010 #undef __FUNCT____FUNCT__1104,40874 #define __FUNCT__ __FUNCT__1105,40891 PETSC_EXTERN PetscErrorCode PEPCreate_Linear(PEP pep)PEPCreate_Linear1106,40928 src/pep/impls/linear/linearp.h,970 linearp.h:^?linearp.h^A,1 #define __LINEARP_H__LINEARP_H25,984 PetscBool explicitmatrix;explicitmatrix28,1022 PEP pep;pep29,1051 PetscInt cform; /* companion form */cform30,1069 PetscReal sfactor,dsfactor; /* scaling factors */sfactor31,1121 PetscReal sfactor,dsfactor; /* scaling factors */dsfactor31,1121 Mat A,B; /* matrices of generalized eigenproblem */A32,1174 Mat A,B; /* matrices of generalized eigenproblem */B32,1174 EPS eps; /* linear eigensolver for Az=lBz */eps33,1248 Mat M,C,K; /* copy of PEP coefficient matrices */M34,1315 Mat M,C,K; /* copy of PEP coefficient matrices */C34,1315 Mat M,C,K; /* copy of PEP coefficient matrices */K34,1315 Vec w[6]; /* work vectors */w35,1385 PetscBool setfromoptionscalled;setfromoptionscalled36,1435 } PEP_LINEAR;PEP_LINEAR37,1470 src/pep/impls/linear/makefile,297 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = linear.c qeplin.cSOURCEC26,958 SOURCEF =SOURCEF27,987 SOURCEH = linearp.hSOURCEH28,998 LIBBASE = libslepcpepLIBBASE29,1019 DIRS =DIRS30,1042 MANSEC = PEPMANSEC31,1053 LOCDIR = src/pep/impls/linear/LOCDIR32,1068 src/pep/impls/linear/qeplin.c,2322 qeplin.c:^?qeplin.c^A,1 #undef __FUNCT____FUNCT__60,2042 #define __FUNCT__ __FUNCT__61,2059 PetscErrorCode MatCreateExplicit_Linear_N1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)MatCreateExplicit_Linear_N1A62,2108 #undef __FUNCT____FUNCT__86,3076 #define __FUNCT__ __FUNCT__87,3093 PetscErrorCode MatCreateExplicit_Linear_N1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)MatCreateExplicit_Linear_N1B88,3142 #undef __FUNCT____FUNCT__114,4183 #define __FUNCT__ __FUNCT__115,4200 PetscErrorCode MatCreateExplicit_Linear_N2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)MatCreateExplicit_Linear_N2A116,4249 #undef __FUNCT____FUNCT__140,5179 #define __FUNCT__ __FUNCT__141,5196 PetscErrorCode MatCreateExplicit_Linear_N2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)MatCreateExplicit_Linear_N2B142,5245 #undef __FUNCT____FUNCT__168,6285 #define __FUNCT__ __FUNCT__169,6302 PetscErrorCode MatCreateExplicit_Linear_S1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)MatCreateExplicit_Linear_S1A170,6351 #undef __FUNCT____FUNCT__179,6606 #define __FUNCT__ __FUNCT__180,6623 PetscErrorCode MatCreateExplicit_Linear_S1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)MatCreateExplicit_Linear_S1B181,6672 #undef __FUNCT____FUNCT__192,7014 #define __FUNCT__ __FUNCT__193,7031 PetscErrorCode MatCreateExplicit_Linear_S2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)MatCreateExplicit_Linear_S2A194,7080 #undef __FUNCT____FUNCT__203,7346 #define __FUNCT__ __FUNCT__204,7363 PetscErrorCode MatCreateExplicit_Linear_S2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)MatCreateExplicit_Linear_S2B205,7412 #undef __FUNCT____FUNCT__216,7784 #define __FUNCT__ __FUNCT__217,7801 PetscErrorCode MatCreateExplicit_Linear_H1A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)MatCreateExplicit_Linear_H1A218,7850 #undef __FUNCT____FUNCT__227,8102 #define __FUNCT__ __FUNCT__228,8119 PetscErrorCode MatCreateExplicit_Linear_H1B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)MatCreateExplicit_Linear_H1B229,8168 #undef __FUNCT____FUNCT__240,8510 #define __FUNCT__ __FUNCT__241,8527 PetscErrorCode MatCreateExplicit_Linear_H2A(MPI_Comm comm,PEP_LINEAR *ctx,Mat *A)MatCreateExplicit_Linear_H2A242,8576 #undef __FUNCT____FUNCT__251,8842 #define __FUNCT__ __FUNCT__252,8859 PetscErrorCode MatCreateExplicit_Linear_H2B(MPI_Comm comm,PEP_LINEAR *ctx,Mat *B)MatCreateExplicit_Linear_H2B253,8908 src/pep/impls/makefile,148 makefile:^?makefile^A,1 LIBBASE = libslepcpepLIBBASE24,936 DIRS = linear krylov jdDIRS25,959 LOCDIR = src/pep/impls/LOCDIR26,987 MANSEC = PEPMANSEC27,1013 src/pep/interface/dlregispep.c,1636 dlregispep.c:^?dlregispep.c^A,1 static PetscBool PEPPackageInitialized = PETSC_FALSE;PEPPackageInitialized24,960 const char *PEPBasisTypes[] = {"MONOMIAL","CHEBYSHEV1","CHEBYSHEV2","LEGENDRE","LAGUERRE","HERMITE","PEPBasis","PEP_BASIS_",0};PEPBasisTypes26,1015 const char *PEPScaleTypes[] = {"NONE","SCALAR","DIAGONAL","BOTH","PEPScale","PEP_SCALE_",0};PEPScaleTypes27,1143 const char *PEPRefineTypes[] = {"NONE","SIMPLE","MULTIPLE","PEPRefine","PEP_REFINE_",0};PEPRefineTypes28,1236 const char *PEPRefineSchemes[] = {"","SCHUR","MBE","EXPLICIT","PEPRefineScheme","PEP_REFINE_SCHEME_",0};PEPRefineSchemes29,1325 const char *PEPExtractTypes[] = {"","NONE","NORM","RESIDUAL","STRUCTURED","PEPExtract","PEP_EXTRACT_",0};PEPExtractTypes30,1430 const char *PEPErrorTypes[] = {"ABSOLUTE","RELATIVE","BACKWARD","PEPErrorType","PEP_ERROR_",0};PEPErrorTypes31,1536 const char *const PEPConvergedReasons_Shifted[] = {"","DIVERGED_SYMMETRY_LOST","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","PEPConvergedReason","PEP_",0};PEPConvergedReasons_Shifted32,1632 const char *const*PEPConvergedReasons = PEPConvergedReasons_Shifted + 4;PEPConvergedReasons33,1834 #undef __FUNCT____FUNCT__35,1908 #define __FUNCT__ __FUNCT__36,1925 PetscErrorCode PEPFinalizePackage(void)PEPFinalizePackage45,2160 #undef __FUNCT____FUNCT__56,2414 #define __FUNCT__ __FUNCT__57,2431 PetscErrorCode PEPInitializePackage(void)PEPInitializePackage67,2759 #undef __FUNCT____FUNCT__107,4195 #define __FUNCT__ __FUNCT__108,4212 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcpep()PetscDLLibraryRegister_slepcpep116,4462 src/pep/interface/ftn-custom/makefile,257 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zpepf.cSOURCEC26,996 SOURCEF =SOURCEF27,1015 SOURCEH =SOURCEH28,1026 DIRS =DIRS29,1037 LIBBASE = libslepcpepLIBBASE30,1048 LOCDIR = src/pep/interface/ftn-custom/LOCDIR31,1071 src/pep/interface/ftn-custom/zpepf.c,8227 zpepf.c:^?zpepf.c^A,1 PETSC_EXTERN void pepmonitorall_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)pepmonitorall_76,3526 PETSC_EXTERN void pepmonitorconverged_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)pepmonitorconverged_81,3790 PETSC_EXTERN void pepmonitorfirst_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)pepmonitorfirst_86,4061 PETSC_EXTERN void pepmonitorlg_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)pepmonitorlg_91,4329 PETSC_EXTERN void pepmonitorlgall_(PEP *pep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)pepmonitorlgall_96,4573 PetscFortranCallbackId monitor;monitor102,4839 PetscFortranCallbackId monitordestroy;monitordestroy103,4873 PetscFortranCallbackId convergence;convergence104,4914 PetscFortranCallbackId convdestroy;convdestroy105,4952 PetscFortranCallbackId stopping;stopping106,4990 PetscFortranCallbackId stopdestroy;stopdestroy107,5025 PetscFortranCallbackId comparison;comparison108,5063 } _cb;_cb109,5100 #undef __FUNCT____FUNCT__112,5200 static PetscErrorCode ourmonitor(PEP pep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx)ourmonitor114,5248 #undef __FUNCT____FUNCT__119,5566 static PetscErrorCode ourdestroy(void** ctx)ourdestroy121,5614 #undef __FUNCT____FUNCT__127,5781 static PetscErrorCode ourconvergence(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)ourconvergence129,5833 #undef __FUNCT____FUNCT__134,6133 static PetscErrorCode ourconvdestroy(void *ctx)ourconvdestroy136,6185 #undef __FUNCT____FUNCT__142,6351 static PetscErrorCode ourstopping(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)ourstopping144,6400 #undef __FUNCT____FUNCT__149,6732 static PetscErrorCode ourstopdestroy(void *ctx)ourstopdestroy151,6784 #undef __FUNCT____FUNCT__157,6950 static PetscErrorCode oureigenvaluecomparison(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *r,void *ctx)oureigenvaluecomparison159,7011 PETSC_EXTERN void PETSC_STDCALL pepview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)pepview_165,7337 PETSC_EXTERN void PETSC_STDCALL pepreasonview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)pepreasonview_172,7524 PETSC_EXTERN void PETSC_STDCALL peperrorview_(PEP *pep,PEPErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)peperrorview_179,7723 PETSC_EXTERN void PETSC_STDCALL pepvaluesview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)pepvaluesview_186,7947 PETSC_EXTERN void PETSC_STDCALL pepvectorsview_(PEP *pep,PetscViewer *viewer,PetscErrorCode *ierr)pepvectorsview_193,8146 PETSC_EXTERN void PETSC_STDCALL pepsettype_(PEP *pep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))pepsettype_200,8347 PETSC_EXTERN void PETSC_STDCALL pepgettype_(PEP *pep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))pepgettype_209,8562 PETSC_EXTERN void PETSC_STDCALL pepsetoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))pepsetoptionsprefix_218,8841 PETSC_EXTERN void PETSC_STDCALL pepappendoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))pepappendoptionsprefix_227,9080 PETSC_EXTERN void PETSC_STDCALL pepgetoptionsprefix_(PEP *pep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))pepgetoptionsprefix_236,9325 PETSC_EXTERN void PETSC_STDCALL pepmonitorset_(PEP *pep,void (PETSC_STDCALL *monitor)(PEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)pepmonitorset_245,9633 PETSC_EXTERN void PETSC_STDCALL pepconvergedabsolute_(PEP *pep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)pepconvergedabsolute_270,11675 PETSC_EXTERN void PETSC_STDCALL pepconvergedrelative_(PEP *pep,PetscScalar *eigr,PetscScalar *eigi,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)pepconvergedrelative_275,11910 PETSC_EXTERN void PETSC_STDCALL pepsetconvergencetestfunction_(PEP *pep,void (PETSC_STDCALL *func)(PEP*,PetscScalar*,PetscScalar*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)pepsetconvergencetestfunction_280,12145 PETSC_EXTERN void PETSC_STDCALL pepstoppingbasic_(PEP *pep,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nev,PEPConvergedReason *reason,void *ctx,PetscErrorCode *ierr)pepstoppingbasic_299,13274 PETSC_EXTERN void PETSC_STDCALL pepsetstoppingtestfunction_(PEP *pep,void (PETSC_STDCALL *func)(PEP*,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)pepsetstoppingtestfunction_304,13528 PETSC_EXTERN void PETSC_STDCALL pepseteigenvaluecomparison_(PEP *pep,void (PETSC_STDCALL *func)(PetscScalar*,PetscScalar*,PetscScalar*,PetscScalar*,PetscInt*,void*),void* ctx,PetscErrorCode *ierr)pepseteigenvaluecomparison_321,14504 src/pep/interface/makefile,379 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = pepmon.c pepbasic.c pepview.c pepdefault.c pepregis.c pepopts.c pepsetup.c pepsolve.c peprefine.c dlregispep.cSOURCEC26,958 SOURCEF =SOURCEF27,1080 SOURCEH =SOURCEH28,1091 LIBBASE = libslepcpepLIBBASE29,1102 DIRS =DIRS30,1125 MANSEC = PEPMANSEC31,1136 LOCDIR = src/pep/interface/LOCDIR32,1151 src/pep/interface/pepbasic.c,2816 pepbasic.c:^?pepbasic.c^A,1 PetscFunctionList PEPList = 0;PEPList26,1046 PetscBool PEPRegisterAllCalled = PETSC_FALSE;PEPRegisterAllCalled27,1077 PetscClassId PEP_CLASSID = 0;PEP_CLASSID28,1131 PetscLogEvent PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0;PEP_SetUp29,1166 PetscLogEvent PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0;PEP_Solve29,1166 PetscLogEvent PEP_SetUp = 0,PEP_Solve = 0,PEP_Refine = 0;PEP_Refine29,1166 #undef __FUNCT____FUNCT__31,1229 #define __FUNCT__ __FUNCT__32,1246 PetscErrorCode PEPCreate(MPI_Comm comm,PEP *outpep)PEPCreate51,1588 #undef __FUNCT____FUNCT__131,4049 #define __FUNCT__ __FUNCT__132,4066 PetscErrorCode PEPSetType(PEP pep,PEPType type)PEPSetType162,5015 #undef __FUNCT____FUNCT__186,5839 #define __FUNCT__ __FUNCT__187,5856 PetscErrorCode PEPGetType(PEP pep,PEPType *type)PEPGetType203,6135 #undef __FUNCT____FUNCT__212,6354 #define __FUNCT__ __FUNCT__213,6371 PetscErrorCode PEPRegister(const char *name,PetscErrorCode (*function)(PEP))PEPRegister240,7001 #undef __FUNCT____FUNCT__249,7224 #define __FUNCT__ __FUNCT__250,7241 PetscErrorCode PEPReset(PEP pep)PEPReset264,7516 #undef __FUNCT____FUNCT__295,8625 #define __FUNCT__ __FUNCT__296,8642 PetscErrorCode PEPDestroy(PEP *pep)PEPDestroy309,8888 #undef __FUNCT____FUNCT__333,9822 #define __FUNCT__ __FUNCT__334,9839 PetscErrorCode PEPSetBV(PEP pep,BV bv)PEPSetBV352,10257 #undef __FUNCT____FUNCT__367,10702 #define __FUNCT__ __FUNCT__368,10719 PetscErrorCode PEPGetBV(PEP pep,BV *bv)PEPGetBV385,11044 #undef __FUNCT____FUNCT__400,11435 #define __FUNCT__ __FUNCT__401,11452 PetscErrorCode PEPSetRG(PEP pep,RG rg)PEPSetRG419,11849 #undef __FUNCT____FUNCT__434,12297 #define __FUNCT__ __FUNCT__435,12314 PetscErrorCode PEPGetRG(PEP pep,RG *rg)PEPGetRG452,12625 #undef __FUNCT____FUNCT__467,13020 #define __FUNCT__ __FUNCT__468,13037 PetscErrorCode PEPSetDS(PEP pep,DS ds)PEPSetDS486,13455 #undef __FUNCT____FUNCT__501,13903 #define __FUNCT__ __FUNCT__502,13920 PetscErrorCode PEPGetDS(PEP pep,DS *ds)PEPGetDS519,14245 #undef __FUNCT____FUNCT__534,14640 #define __FUNCT__ __FUNCT__535,14657 PetscErrorCode PEPSetST(PEP pep,ST st)PEPSetST553,15095 #undef __FUNCT____FUNCT__568,15543 #define __FUNCT__ __FUNCT__569,15560 PetscErrorCode PEPGetST(PEP pep,ST *st)PEPGetST586,15903 #undef __FUNCT____FUNCT__601,16298 #define __FUNCT__ __FUNCT__602,16315 PetscErrorCode PEPRefineGetKSP(PEP pep,KSP *ksp)PEPRefineGetKSP619,16646 #undef __FUNCT____FUNCT__643,17716 #define __FUNCT__ __FUNCT__644,17733 PetscErrorCode PEPSetTarget(PEP pep,PetscScalar target)PEPSetTarget669,18431 #undef __FUNCT____FUNCT__682,18809 #define __FUNCT__ __FUNCT__683,18826 PetscErrorCode PEPGetTarget(PEP pep,PetscScalar* target)PEPGetTarget702,19167 src/pep/interface/pepdefault.c,2276 pepdefault.c:^?pepdefault.c^A,1 #undef __FUNCT____FUNCT__26,1066 #define __FUNCT__ __FUNCT__27,1083 PetscErrorCode PEPSetWorkVecs(PEP pep,PetscInt nw)PEPSetWorkVecs43,1455 #undef __FUNCT____FUNCT__60,1949 #define __FUNCT__ __FUNCT__61,1966 PetscErrorCode PEPConvergedRelative(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)PEPConvergedRelative65,2085 #undef __FUNCT____FUNCT__75,2331 #define __FUNCT__ __FUNCT__76,2348 PetscErrorCode PEPConvergedNorm(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)PEPConvergedNorm80,2461 #undef __FUNCT____FUNCT__104,3266 #define __FUNCT__ __FUNCT__105,3283 PetscErrorCode PEPConvergedAbsolute(PEP pep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,void *ctx)PEPConvergedAbsolute109,3386 #undef __FUNCT____FUNCT__116,3577 #define __FUNCT__ __FUNCT__117,3594 PetscErrorCode PEPStoppingBasic(PEP pep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,PEPConvergedReason *reason,void *ctx)PEPStoppingBasic150,4718 #undef __FUNCT____FUNCT__166,5355 #define __FUNCT__ __FUNCT__167,5372 PetscErrorCode PEPBackTransform_Default(PEP pep)PEPBackTransform_Default168,5417 #undef __FUNCT____FUNCT__177,5623 #define __FUNCT__ __FUNCT__178,5640 PetscErrorCode PEPComputeVectors_Default(PEP pep)PEPComputeVectors_Default179,5686 #undef __FUNCT____FUNCT__221,7052 #define __FUNCT__ __FUNCT__222,7069 PetscErrorCode PEPKrylovConvergence(PEP pep,PetscBool getall,PetscInt kini,PetscInt nits,PetscReal beta,PetscInt *kout)PEPKrylovConvergence233,7361 #undef __FUNCT____FUNCT__273,8596 #define __FUNCT__ __FUNCT__274,8613 PetscErrorCode PEPBuildDiagonalScaling(PEP pep)PEPBuildDiagonalScaling279,8781 #undef __FUNCT____FUNCT__425,14576 #define __FUNCT__ __FUNCT__426,14593 PetscErrorCode PEPComputeScaleFactor(PEP pep)PEPComputeScaleFactor430,14715 #undef __FUNCT____FUNCT__484,16585 #define __FUNCT__ __FUNCT__485,16602 PetscErrorCode PEPBasisCoefficients(PEP pep,PetscReal *pbc)PEPBasisCoefficients489,16713 #undef __FUNCT____FUNCT__540,17982 #define __FUNCT__ __FUNCT__541,17999 PetscErrorCode PEPEvaluateBasis(PEP pep,PetscScalar sigma,PetscScalar isigma,PetscScalar *vals,PetscScalar *ivals)PEPEvaluateBasis545,18121 src/pep/interface/pepmon.c,2502 pepmon.c:^?pepmon.c^A,1 #undef __FUNCT____FUNCT__27,1050 #define __FUNCT__ __FUNCT__28,1067 PetscErrorCode PEPMonitor(PEP pep,PetscInt it,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest)PEPMonitor32,1156 #undef __FUNCT____FUNCT__44,1537 #define __FUNCT__ __FUNCT__45,1554 PetscErrorCode PEPMonitorSet(PEP pep,PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))PEPMonitorSet93,3579 #undef __FUNCT____FUNCT__104,4194 #define __FUNCT__ __FUNCT__105,4211 PetscErrorCode PEPMonitorCancel(PEP pep)PEPMonitorCancel123,4684 #undef __FUNCT____FUNCT__139,5061 #define __FUNCT__ __FUNCT__140,5078 PetscErrorCode PEPGetMonitorContext(PEP pep,void **ctx)PEPGetMonitorContext157,5451 #undef __FUNCT____FUNCT__165,5640 #define __FUNCT__ __FUNCT__166,5657 static PetscErrorCode PEPMonitorGetTrueEig(PEP pep,PetscScalar *er,PetscScalar *ei)PEPMonitorGetTrueEig170,5777 #undef __FUNCT____FUNCT__187,6197 #define __FUNCT__ __FUNCT__188,6214 PetscErrorCode PEPMonitorAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)PEPMonitorAll209,6853 #undef __FUNCT____FUNCT__246,8646 #define __FUNCT__ __FUNCT__247,8663 PetscErrorCode PEPMonitorFirst(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)PEPMonitorFirst268,9312 #undef __FUNCT____FUNCT__303,11070 #define __FUNCT__ __FUNCT__304,11087 PetscErrorCode PEPMonitorConverged(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)PEPMonitorConverged325,11676 #undef __FUNCT____FUNCT__365,13533 #define __FUNCT__ __FUNCT__366,13550 PetscErrorCode PEPMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)PEPMonitorLGCreate395,14350 #undef __FUNCT____FUNCT__411,14896 #define __FUNCT__ __FUNCT__412,14913 PetscErrorCode PEPMonitorLG(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)PEPMonitorLG413,14946 #undef __FUNCT____FUNCT__437,15792 #define __FUNCT__ __FUNCT__438,15809 PetscErrorCode PEPMonitorLGAll(PEP pep,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)PEPMonitorLGAll439,15845 src/pep/interface/pepopts.c,6063 pepopts.c:^?pepopts.c^A,1 #undef __FUNCT____FUNCT__28,1109 #define __FUNCT__ __FUNCT__29,1126 PetscErrorCode PEPMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)PEPMonitorSetFromOptions48,1765 #undef __FUNCT____FUNCT__69,2792 #define __FUNCT__ __FUNCT__70,2809 PetscErrorCode PEPConvMonitorSetFromOptions(PEP pep,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(PEP,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,SlepcConvMonitor))PEPConvMonitorSetFromOptions88,3428 #undef __FUNCT____FUNCT__106,4329 #define __FUNCT__ __FUNCT__107,4346 PetscErrorCode PEPSetFromOptions(PEP pep)PEPSetFromOptions123,4746 #undef __FUNCT____FUNCT__295,16712 #define __FUNCT__ __FUNCT__296,16729 PetscErrorCode PEPGetTolerances(PEP pep,PetscReal *tol,PetscInt *maxits)PEPGetTolerances317,17196 #undef __FUNCT____FUNCT__326,17440 #define __FUNCT__ __FUNCT__327,17457 PetscErrorCode PEPSetTolerances(PEP pep,PetscReal tol,PetscInt maxits)PEPSetTolerances350,18081 #undef __FUNCT____FUNCT__373,18891 #define __FUNCT__ __FUNCT__374,18908 PetscErrorCode PEPGetDimensions(PEP pep,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)PEPGetDimensions396,19473 #undef __FUNCT____FUNCT__406,19740 #define __FUNCT__ __FUNCT__407,19757 PetscErrorCode PEPSetDimensions(PEP pep,PetscInt nev,PetscInt ncv,PetscInt mpd)PEPSetDimensions442,21028 #undef __FUNCT____FUNCT__467,21965 #define __FUNCT__ __FUNCT__468,21982 PetscErrorCode PEPSetWhichEigenpairs(PEP pep,PEPWhich which)PEPSetWhichEigenpairs519,24142 #undef __FUNCT____FUNCT__548,24944 #define __FUNCT__ __FUNCT__549,24961 PetscErrorCode PEPGetWhichEigenpairs(PEP pep,PEPWhich *which)PEPGetWhichEigenpairs569,25418 #undef __FUNCT____FUNCT__578,25633 #define __FUNCT__ __FUNCT__579,25650 PetscErrorCode PEPSetEigenvalueComparison(PEP pep,PetscErrorCode (*func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*),void* ctx)PEPSetEigenvalueComparison611,26792 #undef __FUNCT____FUNCT__621,27149 #define __FUNCT__ __FUNCT__622,27166 PetscErrorCode PEPSetProblemType(PEP pep,PEPProblemType type)PEPSetProblemType652,28262 #undef __FUNCT____FUNCT__665,28746 #define __FUNCT__ __FUNCT__666,28763 PetscErrorCode PEPGetProblemType(PEP pep,PEPProblemType *type)PEPGetProblemType682,29087 #undef __FUNCT____FUNCT__691,29308 #define __FUNCT__ __FUNCT__692,29325 PetscErrorCode PEPSetBasis(PEP pep,PEPBasis basis)PEPSetBasis717,30093 #undef __FUNCT____FUNCT__726,30314 #define __FUNCT__ __FUNCT__727,30331 PetscErrorCode PEPGetBasis(PEP pep,PEPBasis *basis)PEPGetBasis743,30640 #undef __FUNCT____FUNCT__752,30845 #define __FUNCT__ __FUNCT__753,30862 PetscErrorCode PEPSetTrackAll(PEP pep,PetscBool trackall)PEPSetTrackAll776,31596 #undef __FUNCT____FUNCT__785,31833 #define __FUNCT__ __FUNCT__786,31850 PetscErrorCode PEPGetTrackAll(PEP pep,PetscBool *trackall)PEPGetTrackAll803,32172 #undef __FUNCT____FUNCT__812,32393 #define __FUNCT__ __FUNCT__813,32410 PetscErrorCode PEPSetConvergenceTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))PEPSetConvergenceTestFunction844,33570 #undef __FUNCT____FUNCT__863,34300 #define __FUNCT__ __FUNCT__864,34317 PetscErrorCode PEPSetConvergenceTest(PEP pep,PEPConv conv)PEPSetConvergenceTest892,35371 #undef __FUNCT____FUNCT__909,35973 #define __FUNCT__ __FUNCT__910,35990 PetscErrorCode PEPGetConvergenceTest(PEP pep,PEPConv *conv)PEPGetConvergenceTest927,36380 #undef __FUNCT____FUNCT__936,36590 #define __FUNCT__ __FUNCT__937,36607 PetscErrorCode PEPSetStoppingTestFunction(PEP pep,PetscErrorCode (*func)(PEP,PetscInt,PetscInt,PetscInt,PetscInt,PEPConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))PEPSetStoppingTestFunction971,37933 #undef __FUNCT____FUNCT__988,38532 #define __FUNCT__ __FUNCT__989,38549 PetscErrorCode PEPSetStoppingTest(PEP pep,PEPStop stop)PEPSetStoppingTest1013,39278 #undef __FUNCT____FUNCT__1028,39732 #define __FUNCT__ __FUNCT__1029,39749 PetscErrorCode PEPGetStoppingTest(PEP pep,PEPStop *stop)PEPGetStoppingTest1046,40127 #undef __FUNCT____FUNCT__1055,40334 #define __FUNCT__ __FUNCT__1056,40351 PetscErrorCode PEPSetScale(PEP pep,PEPScale scale,PetscReal alpha,Vec Dl,Vec Dr,PetscInt its,PetscReal lambda)PEPSetScale1100,42284 #undef __FUNCT____FUNCT__1146,44050 #define __FUNCT__ __FUNCT__1147,44067 PetscErrorCode PEPGetScale(PEP pep,PEPScale *scale,PetscReal *alpha,Vec *Dl,Vec *Dr,PetscInt *its,PetscReal *lambda)PEPGetScale1175,44997 #undef __FUNCT____FUNCT__1188,45427 #define __FUNCT__ __FUNCT__1189,45444 PetscErrorCode PEPSetExtract(PEP pep,PEPExtract extract)PEPSetExtract1206,45834 #undef __FUNCT____FUNCT__1215,46067 #define __FUNCT__ __FUNCT__1216,46084 PetscErrorCode PEPGetExtract(PEP pep,PEPExtract *extract)PEPGetExtract1232,46377 #undef __FUNCT____FUNCT__1240,46575 #define __FUNCT__ __FUNCT__1241,46592 PetscErrorCode PEPSetRefine(PEP pep,PEPRefine refine,PetscInt npart,PetscReal tol,PetscInt its,PEPRefineScheme scheme)PEPSetRefine1290,48673 #undef __FUNCT____FUNCT__1333,50358 #define __FUNCT__ __FUNCT__1334,50375 PetscErrorCode PEPGetRefine(PEP pep,PEPRefine *refine,PetscInt *npart,PetscReal *tol,PetscInt *its,PEPRefineScheme *scheme)PEPGetRefine1358,50981 #undef __FUNCT____FUNCT__1370,51385 #define __FUNCT__ __FUNCT__1371,51402 PetscErrorCode PEPSetOptionsPrefix(PEP pep,const char *prefix)PEPSetOptionsPrefix1398,52156 #undef __FUNCT____FUNCT__1416,52913 #define __FUNCT__ __FUNCT__1417,52930 PetscErrorCode PEPAppendOptionsPrefix(PEP pep,const char *prefix)PEPAppendOptionsPrefix1436,53490 #undef __FUNCT____FUNCT__1462,54588 #define __FUNCT__ __FUNCT__1463,54605 PetscErrorCode PEPGetOptionsPrefix(PEP pep,const char *prefix[])PEPGetOptionsPrefix1484,55119 src/pep/interface/peprefine.c,1961 peprefine.c:^?peprefine.c^A,1 #define NREF_MAXIT NREF_MAXIT27,1036 VecScatter *scatter_id,nst;scatter_id30,1076 VecScatter *scatter_id,nst;nst30,1076 Mat *A;A31,1106 Vec nv,vg,v,w;nv32,1123 Vec nv,vg,v,w;vg32,1123 Vec nv,vg,v,w;v32,1123 Vec nv,vg,v,w;w32,1123 } PEPSimpNRefctx;PEPSimpNRefctx33,1147 Mat M1;M136,1183 Vec M2,M3;M237,1202 Vec M2,M3;M337,1202 PetscScalar M4,m3;M438,1224 PetscScalar M4,m3;m338,1224 } FSubctx;FSubctx39,1246 #undef __FUNCT____FUNCT__41,1258 #define __FUNCT__ __FUNCT__42,1275 static PetscErrorCode MatFSMult(Mat M ,Vec x,Vec y)MatFSMult43,1305 #undef __FUNCT____FUNCT__58,1690 #define __FUNCT__ __FUNCT__59,1707 static PetscErrorCode PEPSimpleNRefSetUp(PEP pep,PEPSimpNRefctx **ctx_)PEPSimpleNRefSetUp60,1746 #undef __FUNCT____FUNCT__135,4825 #define __FUNCT__ __FUNCT__136,4842 static PetscErrorCode PEPSimpleNRefGatherEigenpair(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx,PetscInt *fail)PEPSimpleNRefGatherEigenpair137,4891 #undef __FUNCT____FUNCT__178,6628 #define __FUNCT__ __FUNCT__179,6645 static PetscErrorCode PEPSimpleNRefScatterEigenvector(PEP pep,PEPSimpNRefctx *ctx,PetscInt sc,PetscInt idx)PEPSimpleNRefScatterEigenvector180,6697 #undef __FUNCT____FUNCT__204,7596 #define __FUNCT__ __FUNCT__205,7613 static PetscErrorCode PEPEvaluateFunctionDerivatives(PEP pep,PetscScalar alpha,PetscScalar *vals)PEPEvaluateFunctionDerivatives206,7664 #undef __FUNCT____FUNCT__225,8159 #define __FUNCT__ __FUNCT__226,8176 static PetscErrorCode PEPSimpleNRefSetUpSystem(PEP pep,Mat *A,PEPSimpNRefctx *ctx,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v)PEPSimpleNRefSetUpSystem227,8221 #undef __FUNCT____FUNCT__396,14970 #define __FUNCT__ __FUNCT__397,14987 PetscErrorCode PEPNewtonRefinementSimple(PEP pep,PetscInt *maxits,PetscReal tol,PetscInt k)PEPNewtonRefinementSimple398,15033 src/pep/interface/pepregis.c,131 pepregis.c:^?pepregis.c^A,1 #undef __FUNCT____FUNCT__30,1237 #define __FUNCT__ __FUNCT__31,1254 PetscErrorCode PEPRegisterAll(void)PEPRegisterAll41,1429 src/pep/interface/pepsetup.c,1137 pepsetup.c:^?pepsetup.c^A,1 #undef __FUNCT____FUNCT__26,1033 #define __FUNCT__ __FUNCT__27,1050 PetscErrorCode PEPSetUp(PEP pep)PEPSetUp46,1528 #undef __FUNCT____FUNCT__227,8641 #define __FUNCT__ __FUNCT__228,8658 PetscErrorCode PEPSetOperators(PEP pep,PetscInt nmat,Mat A[])PEPSetOperators250,9373 #undef __FUNCT____FUNCT__281,10823 #define __FUNCT__ __FUNCT__282,10840 PetscErrorCode PEPGetOperators(PEP pep,PetscInt k,Mat *A)PEPGetOperators299,11286 #undef __FUNCT____FUNCT__309,11608 #define __FUNCT__ __FUNCT__310,11625 PetscErrorCode PEPGetNumMatrices(PEP pep,PetscInt *nmat)PEPGetNumMatrices326,11946 #undef __FUNCT____FUNCT__335,12153 #define __FUNCT__ __FUNCT__336,12170 PetscErrorCode PEPSetInitialSpace(PEP pep,PetscInt n,Vec *is)PEPSetInitialSpace363,13083 #undef __FUNCT____FUNCT__376,13545 #define __FUNCT__ __FUNCT__377,13562 PetscErrorCode PEPSetDimensions_Default(PEP pep,PetscInt nev,PetscInt *ncv,PetscInt *mpd)PEPSetDimensions_Default382,13729 #undef __FUNCT____FUNCT__410,14708 #define __FUNCT__ __FUNCT__411,14725 PetscErrorCode PEPAllocateSolution(PEP pep,PetscInt extra)PEPAllocateSolution429,15216 src/pep/interface/pepsolve.c,1841 pepsolve.c:^?pepsolve.c^A,1 static PetscBool cited = PETSC_FALSE;cited27,1063 static const char citation[] =citation28,1102 #undef __FUNCT____FUNCT__40,1523 #define __FUNCT__ __FUNCT__41,1540 PetscErrorCode PEPComputeVectors(PEP pep)PEPComputeVectors42,1578 #undef __FUNCT____FUNCT__61,1950 #define __FUNCT__ __FUNCT__62,1967 PetscErrorCode PEPExtractVectors(PEP pep)PEPExtractVectors63,2005 #undef __FUNCT____FUNCT__82,2404 #define __FUNCT__ __FUNCT__83,2421 PetscErrorCode PEPSolve(PEP pep)PEPSolve107,3349 #define OPTLEN OPTLEN112,3460 #undef __FUNCT____FUNCT__194,6254 #define __FUNCT__ __FUNCT__195,6271 PetscErrorCode PEPGetIterationNumber(PEP pep,PetscInt *its)PEPGetIterationNumber220,7036 #undef __FUNCT____FUNCT__229,7246 #define __FUNCT__ __FUNCT__230,7263 PetscErrorCode PEPGetConverged(PEP pep,PetscInt *nconv)PEPGetConverged249,7654 #undef __FUNCT____FUNCT__259,7891 #define __FUNCT__ __FUNCT__260,7908 PetscErrorCode PEPGetConvergedReason(PEP pep,PEPConvergedReason *reason)PEPGetConvergedReason288,8749 #undef __FUNCT____FUNCT__298,9003 #define __FUNCT__ __FUNCT__299,9020 PetscErrorCode PEPGetEigenpair(PEP pep,PetscInt i,PetscScalar *eigr,PetscScalar *eigi,Vec Vr,Vec Vi)PEPGetEigenpair334,10306 #undef __FUNCT____FUNCT__381,11937 #define __FUNCT__ __FUNCT__382,11954 PetscErrorCode PEPGetErrorEstimate(PEP pep,PetscInt i,PetscReal *errest)PEPGetErrorEstimate405,12495 #undef __FUNCT____FUNCT__416,12880 #define __FUNCT__ __FUNCT__417,12897 PetscErrorCode PEPComputeResidualNorm_Private(PEP pep,PetscScalar kr,PetscScalar ki,Vec xr,Vec xi,Vec *z,PetscReal *norm)PEPComputeResidualNorm_Private427,13218 #undef __FUNCT____FUNCT__502,15226 #define __FUNCT__ __FUNCT__503,15243 PetscErrorCode PEPComputeError(PEP pep,PetscInt i,PEPErrorType type,PetscReal *error)PEPComputeError527,15892 src/pep/interface/pepview.c,2624 pepview.c:^?pepview.c^A,1 #undef __FUNCT____FUNCT__27,1058 #define __FUNCT__ __FUNCT__28,1075 PetscErrorCode PEPView(PEP pep,PetscViewer viewer)PEPView56,1873 #define HERM HERM72,2370 #undef __FUNCT____FUNCT__215,9787 #define __FUNCT__ __FUNCT__216,9804 PetscErrorCode PEPReasonView(PEP pep,PetscViewer viewer)PEPReasonView233,10249 #undef __FUNCT____FUNCT__252,11248 #define __FUNCT__ __FUNCT__253,11265 PetscErrorCode PEPReasonViewFromOptions(PEP pep)PEPReasonViewFromOptions265,11543 #undef __FUNCT____FUNCT__287,12274 #define __FUNCT__ __FUNCT__288,12291 static PetscErrorCode PEPErrorView_ASCII(PEP pep,PEPErrorType etype,PetscViewer viewer)PEPErrorView_ASCII289,12330 #undef __FUNCT____FUNCT__337,14139 #define __FUNCT__ __FUNCT__338,14156 static PetscErrorCode PEPErrorView_DETAIL(PEP pep,PEPErrorType etype,PetscViewer viewer)PEPErrorView_DETAIL339,14196 #define EXLEN EXLEN345,14384 #undef __FUNCT____FUNCT__382,15662 #define __FUNCT__ __FUNCT__383,15679 static PetscErrorCode PEPErrorView_MATLAB(PEP pep,PEPErrorType etype,PetscViewer viewer)PEPErrorView_MATLAB384,15719 #undef __FUNCT____FUNCT__402,16331 #define __FUNCT__ __FUNCT__403,16348 PetscErrorCode PEPErrorView(PEP pep,PEPErrorType etype,PetscViewer viewer)PEPErrorView430,17231 #undef __FUNCT____FUNCT__463,18408 #define __FUNCT__ __FUNCT__464,18425 PetscErrorCode PEPErrorViewFromOptions(PEP pep)PEPErrorViewFromOptions476,18713 #undef __FUNCT____FUNCT__512,20279 #define __FUNCT__ __FUNCT__513,20296 static PetscErrorCode PEPValuesView_DRAW(PEP pep,PetscViewer viewer)PEPValuesView_DRAW514,20335 #undef __FUNCT____FUNCT__545,21368 #define __FUNCT__ __FUNCT__546,21385 static PetscErrorCode PEPValuesView_ASCII(PEP pep,PetscViewer viewer)PEPValuesView_ASCII547,21425 #undef __FUNCT____FUNCT__576,22313 #define __FUNCT__ __FUNCT__577,22330 static PetscErrorCode PEPValuesView_MATLAB(PEP pep,PetscViewer viewer)PEPValuesView_MATLAB578,22371 #undef __FUNCT____FUNCT__607,23246 #define __FUNCT__ __FUNCT__608,23263 PetscErrorCode PEPValuesView(PEP pep,PetscViewer viewer)PEPValuesView625,23630 #undef __FUNCT____FUNCT__659,24885 #define __FUNCT__ __FUNCT__660,24902 PetscErrorCode PEPValuesViewFromOptions(PEP pep)PEPValuesViewFromOptions672,25181 #undef __FUNCT____FUNCT__694,25907 #define __FUNCT__ __FUNCT__695,25924 PetscErrorCode PEPVectorsView(PEP pep,PetscViewer viewer)PEPVectorsView717,26491 #define NMLEN NMLEN722,26616 #undef __FUNCT____FUNCT__747,27499 #define __FUNCT__ __FUNCT__748,27516 PetscErrorCode PEPVectorsViewFromOptions(PEP pep)PEPVectorsViewFromOptions760,27798 src/pep/makefile,211 makefile:^?makefile^A,1 SOURCEH = ../../include/slepc/private/pepimpl.h ../../include/slepcpep.hSOURCEH24,936 DIRS = interface impls examples f90-modDIRS25,1010 LOCDIR = src/pep/LOCDIR26,1054 MANSEC = PEPMANSEC27,1074 src/svd/examples/makefile,82 makefile:^?makefile^A,1 LOCDIR = src/svd/examples/LOCDIR24,932 DIRS = tests tutorialsDIRS25,961 src/svd/examples/tests/makefile,623 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/svd/examples/tests/LOCDIR26,978 EXAMPLESC = test1.c test2.c test3.cEXAMPLESC27,1015 EXAMPLESF =EXAMPLESF28,1052 MANSEC = SVDMANSEC29,1065 TESTS = test1 test2 test3TESTS30,1082 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \TESTEXAMPLES_C32,1114 TESTEXAMPLES_C_NOF128= test2.PETSc runtest2_1 test2.rmTESTEXAMPLES_C_NOF12834,1226 SVD = lanczos lapack trlanczosSVD51,1676 SVDEPS = cross cyclicSVDEPS52,1707 EPS = krylovschur arnoldi lanczos gd jdEPS53,1729 src/svd/examples/tests/test1.c,234 test1.c:^?test1.c^A,1 static char help[] = "Test the solution of a SVD without calling SVDSetFromOptions (based on ex8.c).\n\n"help22,924 #undef __FUNCT____FUNCT__45,1703 #define __FUNCT__ __FUNCT__46,1720 int main(int argc,char **argv)main47,1745 src/svd/examples/tests/test2.c,215 test2.c:^?test2.c^A,1 static char help[] = "Test SVD with different builds with a matrix loaded from a file"help22,924 #undef __FUNCT____FUNCT__27,1091 #define __FUNCT__ __FUNCT__28,1108 int main(int argc,char **argv)main29,1133 src/svd/examples/tests/test3.c,200 test3.c:^?test3.c^A,1 static char help[] = "Test SVD with user-provided initial vectors.\n\n"help22,924 #undef __FUNCT____FUNCT__42,1546 #define __FUNCT__ __FUNCT__43,1563 int main(int argc,char **argv)main44,1588 src/svd/examples/tutorials/ex14.c,221 ex14.c:^?ex14.c^A,1 static char help[] = "Solves a singular value problem with the matrix loaded from a file.\n"help22,924 #undef __FUNCT____FUNCT__29,1221 #define __FUNCT__ __FUNCT__30,1238 int main(int argc,char **argv)main31,1263 src/svd/examples/tutorials/ex15.c,205 ex15.c:^?ex15.c^A,1 static char help[] = "Singular value decomposition of the Lauchli matrix.\n"help22,924 #undef __FUNCT____FUNCT__29,1160 #define __FUNCT__ __FUNCT__30,1177 int main(int argc,char **argv)main31,1202 src/svd/examples/tutorials/ex15f.F,530 ex15f.F:^?ex15f.F^A,1 program mainmain30,1296 100 format (/'Lauchli SVD, n =',I3,', mu=',E12.4,' (Fortran)')10074,2719 110 format (/' Number of iterations of the method:',I4)110125,4443 120 format (' Solution method: ',A)120132,4678 130 format (' Number of requested singular values:',I2)130138,4908 140 format (' Stopping condition: tol=',1P,E10.4,', maxit=',I4)140143,5086 150 format (' Number of converged approximate singular triplets:',I2/)150154,5501 160 format (1P,' ',E12.4,' ',E12.4)160172,6264 src/svd/examples/tutorials/ex8.c,277 ex8.c:^?ex8.c^A,1 static char help[] = "Estimates the 2-norm condition number of a matrix A, that is, the ratio of the largest to the smallest singular values of A. "help22,924 #undef __FUNCT____FUNCT__45,1739 #define __FUNCT__ __FUNCT__46,1756 int main(int argc,char **argv)main47,1781 src/svd/examples/tutorials/makefile,582 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/svd/examples/tutorials/LOCDIR26,978 EXAMPLESC = ex8.c ex14.c ex15.cEXAMPLESC27,1019 EXAMPLESF = ex15f.FEXAMPLESF28,1052 MANSEC = SVDMANSEC29,1073 TESTEXAMPLES_C = ex8.PETSc runex8_1 ex8.rmTESTEXAMPLES_C31,1091 TESTEXAMPLES_C_NOCOMPLEX = ex14.PETSc runex14_1 ex14.rmTESTEXAMPLES_C_NOCOMPLEX32,1144 TESTEXAMPLES_FORTRAN =TESTEXAMPLES_FORTRAN33,1200 DATAPATH = ${SLEPC_DIR}/share/slepc/datafiles/matricesDATAPATH54,1688 src/svd/f90-mod/makefile,397 makefile:^?makefile^A,1 SPECIALLIB = yesSPECIALLIB28,1120 SPECIALFASTLIB = yesSPECIALFASTLIB29,1141 CFLAGS =CFLAGS32,1164 FFLAGS =FFLAGS33,1177 SOURCEC =SOURCEC34,1190 SOURCEF = slepcsvdmod.FSOURCEF35,1203 SOURCEH =SOURCEH36,1230 LIBBASE = libslepcsvdLIBBASE37,1243 MANSEC = SVDMANSEC38,1268 LOCDIR = src/svd/f90-mod/LOCDIR39,1285 CLEANFILES = *.modCLEANFILES40,1315 src/svd/f90-mod/slepcsvdmod.F,87 slepcsvdmod.F:^?slepcsvdmod.F^A,1 module slepcsvddefslepcsvddef22,965 module slepcsvdslepcsvd29,1143 src/svd/impls/cross/cross.c,2571 cross.c:^?cross.c^A,1 EPS eps;eps31,1177 Mat mat;mat32,1194 Vec w,diag;w33,1211 Vec w,diag;diag33,1211 } SVD_CROSS;SVD_CROSS34,1231 #undef __FUNCT____FUNCT__36,1245 #define __FUNCT__ __FUNCT__37,1262 static PetscErrorCode MatMult_Cross(Mat B,Vec x,Vec y)MatMult_Cross38,1296 #undef __FUNCT____FUNCT__52,1692 #define __FUNCT__ __FUNCT__53,1709 static PetscErrorCode MatCreateVecs_Cross(Mat B,Vec *right,Vec *left)MatCreateVecs_Cross54,1749 #undef __FUNCT____FUNCT__70,2190 #define __FUNCT__ __FUNCT__71,2207 static PetscErrorCode MatGetDiagonal_Cross(Mat B,Vec d)MatGetDiagonal_Cross72,2248 #undef __FUNCT____FUNCT__122,4243 #define __FUNCT__ __FUNCT__123,4260 PetscErrorCode SVDSetUp_Cross(SVD svd)SVDSetUp_Cross124,4295 #undef __FUNCT____FUNCT__175,7136 #define __FUNCT__ __FUNCT__176,7153 PetscErrorCode SVDSolve_Cross(SVD svd)SVDSolve_Cross177,7188 #undef __FUNCT____FUNCT__200,8077 #define __FUNCT__ __FUNCT__201,8094 static PetscErrorCode EPSMonitor_Cross(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)EPSMonitor_Cross202,8131 #undef __FUNCT____FUNCT__220,8744 #define __FUNCT__ __FUNCT__221,8761 PetscErrorCode SVDSetFromOptions_Cross(PetscOptionItems *PetscOptionsObject,SVD svd)SVDSetFromOptions_Cross222,8805 #undef __FUNCT____FUNCT__235,9271 #define __FUNCT__ __FUNCT__236,9288 static PetscErrorCode SVDCrossSetEPS_Cross(SVD svd,EPS eps)SVDCrossSetEPS_Cross237,9329 #undef __FUNCT____FUNCT__251,9767 #define __FUNCT__ __FUNCT__252,9784 PetscErrorCode SVDCrossSetEPS(SVD svd,EPS eps)SVDCrossSetEPS267,10073 #undef __FUNCT____FUNCT__279,10409 #define __FUNCT__ __FUNCT__280,10426 static PetscErrorCode SVDCrossGetEPS_Cross(SVD svd,EPS *eps)SVDCrossGetEPS_Cross281,10467 #undef __FUNCT____FUNCT__303,11417 #define __FUNCT__ __FUNCT__304,11434 PetscErrorCode SVDCrossGetEPS(SVD svd,EPS *eps)SVDCrossGetEPS321,11752 #undef __FUNCT____FUNCT__332,12036 #define __FUNCT__ __FUNCT__333,12053 PetscErrorCode SVDView_Cross(SVD svd,PetscViewer viewer)SVDView_Cross334,12087 #undef __FUNCT____FUNCT__351,12658 #define __FUNCT__ __FUNCT__352,12675 PetscErrorCode SVDReset_Cross(SVD svd)SVDReset_Cross353,12710 #undef __FUNCT____FUNCT__366,13083 #define __FUNCT__ __FUNCT__367,13100 PetscErrorCode SVDDestroy_Cross(SVD svd)SVDDestroy_Cross368,13137 #undef __FUNCT____FUNCT__381,13583 #define __FUNCT__ __FUNCT__382,13600 PETSC_EXTERN PetscErrorCode SVDCreate_Cross(SVD svd)SVDCreate_Cross383,13636 src/svd/impls/cross/makefile,275 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = cross.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsvdLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = SVDMANSEC31,1033 LOCDIR = src/svd/impls/cross/LOCDIR32,1048 src/svd/impls/cyclic/cyclic.c,3381 cyclic.c:^?cyclic.c^A,1 PetscBool explicitmatrix;explicitmatrix31,1196 EPS eps;eps32,1224 Mat mat;mat33,1241 Vec x1,x2,y1,y2;x134,1258 Vec x1,x2,y1,y2;x234,1258 Vec x1,x2,y1,y2;y134,1258 Vec x1,x2,y1,y2;y234,1258 } SVD_CYCLIC;SVD_CYCLIC35,1283 #undef __FUNCT____FUNCT__37,1298 #define __FUNCT__ __FUNCT__38,1315 static PetscErrorCode MatMult_Cyclic(Mat B,Vec x,Vec y)MatMult_Cyclic39,1350 #undef __FUNCT____FUNCT__69,2514 #define __FUNCT__ __FUNCT__70,2531 static PetscErrorCode MatGetDiagonal_Cyclic(Mat B,Vec diag)MatGetDiagonal_Cyclic71,2573 #undef __FUNCT____FUNCT__80,2751 #define __FUNCT__ __FUNCT__81,2768 PetscErrorCode SVDSetUp_Cyclic(SVD svd)SVDSetUp_Cyclic82,2804 #undef __FUNCT____FUNCT__214,10091 #define __FUNCT__ __FUNCT__215,10108 PetscErrorCode SVDSolve_Cyclic(SVD svd)SVDSolve_Cyclic216,10144 #undef __FUNCT____FUNCT__261,11966 #define __FUNCT__ __FUNCT__262,11983 static PetscErrorCode EPSMonitor_Cyclic(EPS eps,PetscInt its,PetscInt nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt nest,void *ctx)EPSMonitor_Cyclic263,12021 #undef __FUNCT____FUNCT__287,12761 #define __FUNCT__ __FUNCT__288,12778 PetscErrorCode SVDSetFromOptions_Cyclic(PetscOptionItems *PetscOptionsObject,SVD svd)SVDSetFromOptions_Cyclic289,12823 #undef __FUNCT____FUNCT__313,13794 #define __FUNCT__ __FUNCT__314,13811 static PetscErrorCode SVDCyclicSetExplicitMatrix_Cyclic(SVD svd,PetscBool explicitmatrix)SVDCyclicSetExplicitMatrix_Cyclic315,13865 #undef __FUNCT____FUNCT__324,14099 #define __FUNCT__ __FUNCT__325,14116 PetscErrorCode SVDCyclicSetExplicitMatrix(SVD svd,PetscBool explicitmatrix)SVDCyclicSetExplicitMatrix343,14607 #undef __FUNCT____FUNCT__354,14976 #define __FUNCT__ __FUNCT__355,14993 static PetscErrorCode SVDCyclicGetExplicitMatrix_Cyclic(SVD svd,PetscBool *explicitmatrix)SVDCyclicGetExplicitMatrix_Cyclic356,15047 #undef __FUNCT____FUNCT__365,15283 #define __FUNCT__ __FUNCT__366,15300 PetscErrorCode SVDCyclicGetExplicitMatrix(SVD svd,PetscBool *explicitmatrix)SVDCyclicGetExplicitMatrix382,15625 #undef __FUNCT____FUNCT__393,15978 #define __FUNCT__ __FUNCT__394,15995 static PetscErrorCode SVDCyclicSetEPS_Cyclic(SVD svd,EPS eps)SVDCyclicSetEPS_Cyclic395,16038 #undef __FUNCT____FUNCT__409,16485 #define __FUNCT__ __FUNCT__410,16502 PetscErrorCode SVDCyclicSetEPS(SVD svd,EPS eps)SVDCyclicSetEPS425,16794 #undef __FUNCT____FUNCT__437,17132 #define __FUNCT__ __FUNCT__438,17149 static PetscErrorCode SVDCyclicGetEPS_Cyclic(SVD svd,EPS *eps)SVDCyclicGetEPS_Cyclic439,17192 #undef __FUNCT____FUNCT__458,18025 #define __FUNCT__ __FUNCT__459,18042 PetscErrorCode SVDCyclicGetEPS(SVD svd,EPS *eps)SVDCyclicGetEPS476,18363 #undef __FUNCT____FUNCT__487,18649 #define __FUNCT__ __FUNCT__488,18666 PetscErrorCode SVDView_Cyclic(SVD svd,PetscViewer viewer)SVDView_Cyclic489,18701 #undef __FUNCT____FUNCT__507,19405 #define __FUNCT__ __FUNCT__508,19422 PetscErrorCode SVDReset_Cyclic(SVD svd)SVDReset_Cyclic509,19458 #undef __FUNCT____FUNCT__524,19935 #define __FUNCT__ __FUNCT__525,19952 PetscErrorCode SVDDestroy_Cyclic(SVD svd)SVDDestroy_Cyclic526,19990 #undef __FUNCT____FUNCT__541,20652 #define __FUNCT__ __FUNCT__542,20669 PETSC_EXTERN PetscErrorCode SVDCreate_Cyclic(SVD svd)SVDCreate_Cyclic543,20706 src/svd/impls/cyclic/makefile,278 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = cyclic.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsvdLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = SVDMANSEC31,1034 LOCDIR = src/svd/impls/cyclic/LOCDIR32,1049 src/svd/impls/lanczos/gklanczos.c,2193 gklanczos.c:^?gklanczos.c^A,1 PetscBool oneside;oneside45,1586 } SVD_LANCZOS;SVD_LANCZOS46,1607 #undef __FUNCT____FUNCT__48,1623 #define __FUNCT__ __FUNCT__49,1640 PetscErrorCode SVDSetUp_Lanczos(SVD svd)SVDSetUp_Lanczos50,1677 #undef __FUNCT____FUNCT__69,2421 #define __FUNCT__ __FUNCT__70,2438 PetscErrorCode SVDTwoSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt k,PetscInt n)SVDTwoSideLanczos71,2476 #undef __FUNCT____FUNCT__113,4274 #define __FUNCT__ __FUNCT__114,4291 static PetscErrorCode SVDOneSideLanczos(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,Vec u,Vec u_1,PetscInt k,PetscInt n,PetscScalar* work)SVDOneSideLanczos115,4329 #undef __FUNCT____FUNCT__179,6766 #define __FUNCT__ __FUNCT__180,6783 PetscErrorCode SVDSolve_Lanczos(SVD svd)SVDSolve_Lanczos181,6820 #undef __FUNCT____FUNCT__284,10625 #define __FUNCT__ __FUNCT__285,10642 PetscErrorCode SVDSetFromOptions_Lanczos(PetscOptionItems *PetscOptionsObject,SVD svd)SVDSetFromOptions_Lanczos286,10688 #undef __FUNCT____FUNCT__302,11284 #define __FUNCT__ __FUNCT__303,11301 static PetscErrorCode SVDLanczosSetOneSide_Lanczos(SVD svd,PetscBool oneside)SVDLanczosSetOneSide_Lanczos304,11350 #undef __FUNCT____FUNCT__316,11641 #define __FUNCT__ __FUNCT__317,11658 PetscErrorCode SVDLanczosSetOneSide(SVD svd,PetscBool oneside)SVDLanczosSetOneSide341,12411 #undef __FUNCT____FUNCT__352,12747 #define __FUNCT__ __FUNCT__353,12764 static PetscErrorCode SVDLanczosGetOneSide_Lanczos(SVD svd,PetscBool *oneside)SVDLanczosGetOneSide_Lanczos354,12813 #undef __FUNCT____FUNCT__363,13027 #define __FUNCT__ __FUNCT__364,13044 PetscErrorCode SVDLanczosGetOneSide(SVD svd,PetscBool *oneside)SVDLanczosGetOneSide381,13426 #undef __FUNCT____FUNCT__392,13746 #define __FUNCT__ __FUNCT__393,13763 PetscErrorCode SVDDestroy_Lanczos(SVD svd)SVDDestroy_Lanczos394,13802 #undef __FUNCT____FUNCT__405,14165 #define __FUNCT__ __FUNCT__406,14182 PetscErrorCode SVDView_Lanczos(SVD svd,PetscViewer viewer)SVDView_Lanczos407,14218 #undef __FUNCT____FUNCT__421,14680 #define __FUNCT__ __FUNCT__422,14697 PETSC_EXTERN PetscErrorCode SVDCreate_Lanczos(SVD svd)SVDCreate_Lanczos423,14735 src/svd/impls/lanczos/makefile,282 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = gklanczos.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcsvdLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = SVDMANSEC31,1037 LOCDIR = src/svd/impls/lanczos/LOCDIR32,1052 src/svd/impls/lapack/makefile,281 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = svdlapack.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcsvdLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = SVDMANSEC31,1037 LOCDIR = src/svd/impls/lapack/LOCDIR32,1052 src/svd/impls/lapack/svdlapack.c,426 svdlapack.c:^?svdlapack.c^A,1 #undef __FUNCT____FUNCT__26,1026 #define __FUNCT__ __FUNCT__27,1043 PetscErrorCode SVDSetUp_LAPACK(SVD svd)SVDSetUp_LAPACK28,1079 #undef __FUNCT____FUNCT__46,1732 #define __FUNCT__ __FUNCT__47,1749 PetscErrorCode SVDSolve_LAPACK(SVD svd)SVDSolve_LAPACK48,1785 #undef __FUNCT____FUNCT__109,3970 #define __FUNCT__ __FUNCT__110,3987 PETSC_EXTERN PetscErrorCode SVDCreate_LAPACK(SVD svd)SVDCreate_LAPACK111,4024 src/svd/impls/makefile,170 makefile:^?makefile^A,1 LIBBASE = libslepcsvdLIBBASE24,936 DIRS = cross cyclic lapack lanczos trlanczosDIRS25,959 LOCDIR = src/svd/impls/LOCDIR26,1008 MANSEC = SVDMANSEC27,1034 src/svd/impls/trlanczos/makefile,284 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = trlanczos.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcsvdLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = SVDMANSEC31,1037 LOCDIR = src/svd/impls/trlanczos/LOCDIR32,1052 src/svd/impls/trlanczos/trlanczos.c,2660 trlanczos.c:^?trlanczos.c^A,1 static PetscBool cited = PETSC_FALSE;cited44,1555 static const char citation[] =citation45,1594 PetscBool oneside;oneside56,2006 } SVD_TRLANCZOS;SVD_TRLANCZOS57,2027 #undef __FUNCT____FUNCT__59,2045 #define __FUNCT__ __FUNCT__60,2062 PetscErrorCode SVDSetUp_TRLanczos(SVD svd)SVDSetUp_TRLanczos61,2101 #undef __FUNCT____FUNCT__79,2778 #define __FUNCT__ __FUNCT__80,2795 static PetscErrorCode SVDOneSideTRLanczosMGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work)SVDOneSideTRLanczosMGS81,2838 #undef __FUNCT____FUNCT__135,4920 #define __FUNCT__ __FUNCT__136,4937 static PetscErrorCode SVDOrthogonalizeCGS(BV V,PetscInt i,PetscScalar* h,PetscReal a,BVOrthogRefineType refine,PetscReal eta,PetscReal *norm)SVDOrthogonalizeCGS140,5056 #undef __FUNCT____FUNCT__181,6346 #define __FUNCT__ __FUNCT__182,6363 static PetscErrorCode SVDOneSideTRLanczosCGS(SVD svd,PetscReal *alpha,PetscReal *beta,BV V,BV U,PetscInt nconv,PetscInt l,PetscInt n,PetscScalar* work)SVDOneSideTRLanczosCGS183,6406 #undef __FUNCT____FUNCT__280,10314 #define __FUNCT__ __FUNCT__281,10331 PetscErrorCode SVDSolve_TRLanczos(SVD svd)SVDSolve_TRLanczos282,10370 #undef __FUNCT____FUNCT__398,14775 #define __FUNCT__ __FUNCT__399,14792 PetscErrorCode SVDSetFromOptions_TRLanczos(PetscOptionItems *PetscOptionsObject,SVD svd)SVDSetFromOptions_TRLanczos400,14840 #undef __FUNCT____FUNCT__416,15448 #define __FUNCT__ __FUNCT__417,15465 static PetscErrorCode SVDTRLanczosSetOneSide_TRLanczos(SVD svd,PetscBool oneside)SVDTRLanczosSetOneSide_TRLanczos418,15518 #undef __FUNCT____FUNCT__427,15738 #define __FUNCT__ __FUNCT__428,15755 PetscErrorCode SVDTRLanczosSetOneSide(SVD svd,PetscBool oneside)SVDTRLanczosSetOneSide451,16449 #undef __FUNCT____FUNCT__462,16789 #define __FUNCT__ __FUNCT__463,16806 static PetscErrorCode SVDTRLanczosGetOneSide_TRLanczos(SVD svd,PetscBool *oneside)SVDTRLanczosGetOneSide_TRLanczos464,16859 #undef __FUNCT____FUNCT__473,17081 #define __FUNCT__ __FUNCT__474,17098 PetscErrorCode SVDTRLanczosGetOneSide(SVD svd,PetscBool *oneside)SVDTRLanczosGetOneSide491,17486 #undef __FUNCT____FUNCT__502,17810 #define __FUNCT__ __FUNCT__503,17827 PetscErrorCode SVDDestroy_TRLanczos(SVD svd)SVDDestroy_TRLanczos504,17868 #undef __FUNCT____FUNCT__515,18237 #define __FUNCT__ __FUNCT__516,18254 PetscErrorCode SVDView_TRLanczos(SVD svd,PetscViewer viewer)SVDView_TRLanczos517,18292 #undef __FUNCT____FUNCT__531,18760 #define __FUNCT__ __FUNCT__532,18777 PETSC_EXTERN PetscErrorCode SVDCreate_TRLanczos(SVD svd)SVDCreate_TRLanczos533,18817 src/svd/interface/dlregissvd.c,966 dlregissvd.c:^?dlregissvd.c^A,1 static PetscBool SVDPackageInitialized = PETSC_FALSE;SVDPackageInitialized24,960 const char *SVDErrorTypes[] = {"ABSOLUTE","RELATIVE","SVDErrorType","SVD_ERROR_",0};SVDErrorTypes26,1015 const char *const SVDConvergedReasons_Shifted[] = {"","","DIVERGED_BREAKDOWN","DIVERGED_ITS","CONVERGED_ITERATING","CONVERGED_TOL","CONVERGED_USER","SVDConvergedReason","SVD_",0};SVDConvergedReasons_Shifted27,1100 const char *const*SVDConvergedReasons = SVDConvergedReasons_Shifted + 4;SVDConvergedReasons28,1280 #undef __FUNCT____FUNCT__30,1354 #define __FUNCT__ __FUNCT__31,1371 PetscErrorCode SVDFinalizePackage(void)SVDFinalizePackage40,1606 #undef __FUNCT____FUNCT__51,1860 #define __FUNCT__ __FUNCT__52,1877 PetscErrorCode SVDInitializePackage(void)SVDInitializePackage62,2205 #undef __FUNCT____FUNCT__101,3558 #define __FUNCT__ __FUNCT__102,3575 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepcsvd()PetscDLLibraryRegister_slepcsvd110,3825 src/svd/interface/ftn-custom/makefile,257 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zsvdf.cSOURCEC26,996 SOURCEF =SOURCEF27,1015 SOURCEH =SOURCEH28,1026 DIRS =DIRS29,1037 LIBBASE = libslepcsvdLIBBASE30,1048 LOCDIR = src/svd/interface/ftn-custom/LOCDIR31,1071 src/svd/interface/ftn-custom/zsvdf.c,7360 zsvdf.c:^?zsvdf.c^A,1 PETSC_EXTERN void svdmonitorall_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)svdmonitorall_74,3425 PETSC_EXTERN void svdmonitorconverged_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,SlepcConvMonitor *ctx,PetscErrorCode *ierr)svdmonitorconverged_79,3666 PETSC_EXTERN void svdmonitorfirst_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,PetscViewerAndFormat **ctx,PetscErrorCode *ierr)svdmonitorfirst_84,3914 PETSC_EXTERN void svdmonitorlg_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)svdmonitorlg_89,4159 PETSC_EXTERN void svdmonitorlgall_(SVD *svd,PetscInt *it,PetscInt *nconv,PetscReal *sigma,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)svdmonitorlgall_94,4380 PetscFortranCallbackId monitor;monitor100,4623 PetscFortranCallbackId monitordestroy;monitordestroy101,4657 PetscFortranCallbackId convergence;convergence102,4698 PetscFortranCallbackId convdestroy;convdestroy103,4736 PetscFortranCallbackId stopping;stopping104,4774 PetscFortranCallbackId stopdestroy;stopdestroy105,4809 } _cb;_cb106,4847 #undef __FUNCT____FUNCT__109,4947 static PetscErrorCode ourmonitor(SVD svd,PetscInt i,PetscInt nc,PetscReal *sigma,PetscReal *d,PetscInt l,void* ctx)ourmonitor111,4995 #undef __FUNCT____FUNCT__116,5283 static PetscErrorCode ourdestroy(void** ctx)ourdestroy118,5331 #undef __FUNCT____FUNCT__124,5498 static PetscErrorCode ourconvergence(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)ourconvergence126,5550 #undef __FUNCT____FUNCT__131,5812 static PetscErrorCode ourconvdestroy(void *ctx)ourconvdestroy133,5864 #undef __FUNCT____FUNCT__139,6030 static PetscErrorCode ourstopping(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)ourstopping141,6079 #undef __FUNCT____FUNCT__146,6411 static PetscErrorCode ourstopdestroy(void *ctx)ourstopdestroy148,6463 PETSC_EXTERN void PETSC_STDCALL svdview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)svdview_154,6629 PETSC_EXTERN void PETSC_STDCALL svdreasonview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)svdreasonview_161,6816 PETSC_EXTERN void PETSC_STDCALL svderrorview_(SVD *svd,SVDErrorType *etype,PetscViewer *viewer,PetscErrorCode *ierr)svderrorview_168,7015 PETSC_EXTERN void PETSC_STDCALL svdvaluesview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)svdvaluesview_175,7239 PETSC_EXTERN void PETSC_STDCALL svdvectorsview_(SVD *svd,PetscViewer *viewer,PetscErrorCode *ierr)svdvectorsview_182,7438 PETSC_EXTERN void PETSC_STDCALL svdsettype_(SVD *svd,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))svdsettype_189,7639 PETSC_EXTERN void PETSC_STDCALL svdgettype_(SVD *svd,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))svdgettype_198,7854 PETSC_EXTERN void PETSC_STDCALL svdmonitorset_(SVD *svd,void (PETSC_STDCALL *monitor)(SVD*,PetscInt*,PetscInt*,PetscReal*,PetscReal*,PetscInt*,void*,PetscErrorCode*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode*),PetscErrorCode *ierr)svdmonitorset_207,8133 PETSC_EXTERN void PETSC_STDCALL svdsetoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))svdsetoptionsprefix_232,10115 PETSC_EXTERN void PETSC_STDCALL svdappendoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))svdappendoptionsprefix_241,10354 PETSC_EXTERN void PETSC_STDCALL svdgetoptionsprefix_(SVD *svd,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))svdgetoptionsprefix_250,10599 PETSC_EXTERN void PETSC_STDCALL svdconvergedabsolute_(SVD *svd,PetscReal *sigma,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)svdconvergedabsolute_259,10907 PETSC_EXTERN void PETSC_STDCALL svdconvergedrelative_(SVD *svd,PetscReal *sigma,PetscReal *res,PetscReal *errest,void *ctx,PetscErrorCode *ierr)svdconvergedrelative_264,11118 PETSC_EXTERN void PETSC_STDCALL svdsetconvergencetestfunction_(SVD *svd,void (PETSC_STDCALL *func)(SVD*,PetscReal*,PetscReal*,PetscReal*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)svdsetconvergencetestfunction_269,11329 PETSC_EXTERN void PETSC_STDCALL svdstoppingbasic_(SVD *svd,PetscInt *its,PetscInt *max_it,PetscInt *nconv,PetscInt *nsv,SVDConvergedReason *reason,void *ctx,PetscErrorCode *ierr)svdstoppingbasic_288,12443 PETSC_EXTERN void PETSC_STDCALL svdsetstoppingtestfunction_(SVD *svd,void (PETSC_STDCALL *func)(SVD*,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*,PetscErrorCode*),void* ctx,void (PETSC_STDCALL *destroy)(void*,PetscErrorCode*),PetscErrorCode *ierr)svdsetstoppingtestfunction_293,12697 src/svd/interface/makefile,367 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = svdregis.c svdbasic.c svddefault.c svdview.c svdopts.c svdsetup.c svdsolve.c svdmon.c dlregissvd.cSOURCEC26,958 SOURCEF =SOURCEF27,1068 SOURCEH =SOURCEH28,1079 LIBBASE = libslepcsvdLIBBASE29,1090 DIRS =DIRS30,1113 MANSEC = SVDMANSEC31,1124 LOCDIR = src/svd/interface/LOCDIR32,1139 src/svd/interface/svdbasic.c,1711 svdbasic.c:^?svdbasic.c^A,1 PetscFunctionList SVDList = 0;SVDList26,1046 PetscBool SVDRegisterAllCalled = PETSC_FALSE;SVDRegisterAllCalled27,1077 PetscClassId SVD_CLASSID = 0;SVD_CLASSID28,1131 PetscLogEvent SVD_SetUp = 0,SVD_Solve = 0;SVD_SetUp29,1166 PetscLogEvent SVD_SetUp = 0,SVD_Solve = 0;SVD_Solve29,1166 #undef __FUNCT____FUNCT__31,1214 #define __FUNCT__ __FUNCT__32,1231 PetscErrorCode SVDCreate(MPI_Comm comm,SVD *outsvd)SVDCreate51,1574 #undef __FUNCT____FUNCT__107,3256 #define __FUNCT__ __FUNCT__108,3273 PetscErrorCode SVDReset(SVD svd)SVDReset122,3558 #undef __FUNCT____FUNCT__144,4273 #define __FUNCT__ __FUNCT__145,4290 PetscErrorCode SVDDestroy(SVD *svd)SVDDestroy158,4546 #undef __FUNCT____FUNCT__178,5351 #define __FUNCT__ __FUNCT__179,5368 PetscErrorCode SVDSetType(SVD svd,SVDType type)SVDSetType209,6317 #undef __FUNCT____FUNCT__233,7141 #define __FUNCT__ __FUNCT__234,7158 PetscErrorCode SVDGetType(SVD svd,SVDType *type)SVDGetType250,7447 #undef __FUNCT____FUNCT__259,7666 #define __FUNCT__ __FUNCT__260,7683 PetscErrorCode SVDRegister(const char *name,PetscErrorCode (*function)(SVD))SVDRegister287,8304 #undef __FUNCT____FUNCT__296,8527 #define __FUNCT__ __FUNCT__297,8544 PetscErrorCode SVDSetBV(SVD svd,BV V,BV U)SVDSetBV316,9060 #undef __FUNCT____FUNCT__341,9837 #define __FUNCT__ __FUNCT__342,9854 PetscErrorCode SVDGetBV(SVD svd,BV *V,BV *U)SVDGetBV360,10270 #undef __FUNCT____FUNCT__383,10887 #define __FUNCT__ __FUNCT__384,10904 PetscErrorCode SVDSetDS(SVD svd,DS ds)SVDSetDS402,11331 #undef __FUNCT____FUNCT__417,11779 #define __FUNCT__ __FUNCT__418,11796 PetscErrorCode SVDGetDS(SVD svd,DS *ds)SVDGetDS435,12130 src/svd/interface/svddefault.c,640 svddefault.c:^?svddefault.c^A,1 #undef __FUNCT____FUNCT__26,1063 #define __FUNCT__ __FUNCT__27,1080 PetscErrorCode SVDConvergedRelative(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)SVDConvergedRelative31,1199 #undef __FUNCT____FUNCT__38,1378 #define __FUNCT__ __FUNCT__39,1395 PetscErrorCode SVDConvergedAbsolute(SVD svd,PetscReal sigma,PetscReal res,PetscReal *errest,void *ctx)SVDConvergedAbsolute43,1498 #undef __FUNCT____FUNCT__50,1671 #define __FUNCT__ __FUNCT__51,1688 PetscErrorCode SVDStoppingBasic(SVD svd,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nsv,SVDConvergedReason *reason,void *ctx)SVDStoppingBasic84,2850 src/svd/interface/svdmon.c,2182 svdmon.c:^?svdmon.c^A,1 #undef __FUNCT____FUNCT__27,1047 #define __FUNCT__ __FUNCT__28,1064 PetscErrorCode SVDMonitor(SVD svd,PetscInt it,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest)SVDMonitor32,1153 #undef __FUNCT____FUNCT__44,1511 #define __FUNCT__ __FUNCT__45,1528 PetscErrorCode SVDMonitorSet(SVD svd,PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,void*),void *mctx,PetscErrorCode (*monitordestroy)(void**))SVDMonitorSet91,3442 #undef __FUNCT____FUNCT__102,4042 #define __FUNCT__ __FUNCT__103,4059 PetscErrorCode SVDMonitorCancel(SVD svd)SVDMonitorCancel121,4533 #undef __FUNCT____FUNCT__137,4910 #define __FUNCT__ __FUNCT__138,4927 PetscErrorCode SVDGetMonitorContext(SVD svd,void **ctx)SVDGetMonitorContext155,5289 #undef __FUNCT____FUNCT__163,5478 #define __FUNCT__ __FUNCT__164,5495 PetscErrorCode SVDMonitorAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)SVDMonitorAll184,6080 #undef __FUNCT____FUNCT__212,7423 #define __FUNCT__ __FUNCT__213,7440 PetscErrorCode SVDMonitorFirst(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,PetscViewerAndFormat *vf)SVDMonitorFirst233,8037 #undef __FUNCT____FUNCT__259,9337 #define __FUNCT__ __FUNCT__260,9354 PetscErrorCode SVDMonitorConverged(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,SlepcConvMonitor ctx)SVDMonitorConverged279,9887 #undef __FUNCT____FUNCT__310,11280 #define __FUNCT__ __FUNCT__311,11297 PetscErrorCode SVDMonitorLGCreate(MPI_Comm comm,const char host[],const char label[],int x,int y,int m,int n,PetscDrawLG *lgctx)SVDMonitorLGCreate340,12097 #undef __FUNCT____FUNCT__356,12643 #define __FUNCT__ __FUNCT__357,12660 PetscErrorCode SVDMonitorLG(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx)SVDMonitorLG358,12693 #undef __FUNCT____FUNCT__382,13520 #define __FUNCT__ __FUNCT__383,13537 PetscErrorCode SVDMonitorLGAll(SVD svd,PetscInt its,PetscInt nconv,PetscReal *sigma,PetscReal *errest,PetscInt nest,void *ctx)SVDMonitorLGAll384,13573 src/svd/interface/svdopts.c,4269 svdopts.c:^?svdopts.c^A,1 #undef __FUNCT____FUNCT__27,1056 #define __FUNCT__ __FUNCT__28,1073 PetscErrorCode SVDSetImplicitTranspose(SVD svd,PetscBool impl)SVDSetImplicitTranspose56,2050 #undef __FUNCT____FUNCT__68,2361 #define __FUNCT__ __FUNCT__69,2378 PetscErrorCode SVDGetImplicitTranspose(SVD svd,PetscBool *impl)SVDGetImplicitTranspose86,2814 #undef __FUNCT____FUNCT__95,3033 #define __FUNCT__ __FUNCT__96,3050 PetscErrorCode SVDSetTolerances(SVD svd,PetscReal tol,PetscInt maxits)SVDSetTolerances120,3765 #undef __FUNCT____FUNCT__143,4575 #define __FUNCT__ __FUNCT__144,4592 PetscErrorCode SVDGetTolerances(SVD svd,PetscReal *tol,PetscInt *maxits)SVDGetTolerances165,5066 #undef __FUNCT____FUNCT__174,5310 #define __FUNCT__ __FUNCT__175,5327 PetscErrorCode SVDSetDimensions(SVD svd,PetscInt nsv,PetscInt ncv,PetscInt mpd)SVDSetDimensions210,6652 #undef __FUNCT____FUNCT__235,7589 #define __FUNCT__ __FUNCT__236,7606 PetscErrorCode SVDGetDimensions(SVD svd,PetscInt *nsv,PetscInt *ncv,PetscInt *mpd)SVDGetDimensions258,8171 #undef __FUNCT____FUNCT__268,8438 #define __FUNCT__ __FUNCT__269,8455 PetscErrorCode SVDSetWhichSingularTriplets(SVD svd,SVDWhich which)SVDSetWhichSingularTriplets296,9170 #undef __FUNCT____FUNCT__315,9687 #define __FUNCT__ __FUNCT__316,9704 PetscErrorCode SVDGetWhichSingularTriplets(SVD svd,SVDWhich *which)SVDGetWhichSingularTriplets336,10187 #undef __FUNCT____FUNCT__345,10408 #define __FUNCT__ __FUNCT__346,10425 PetscErrorCode SVDSetConvergenceTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscReal,PetscReal,PetscReal*,void*),void* ctx,PetscErrorCode (*destroy)(void*))SVDSetConvergenceTestFunction376,11548 #undef __FUNCT____FUNCT__394,12200 #define __FUNCT__ __FUNCT__395,12217 PetscErrorCode SVDSetConvergenceTest(SVD svd,SVDConv conv)SVDSetConvergenceTest421,13124 #undef __FUNCT____FUNCT__437,13654 #define __FUNCT__ __FUNCT__438,13671 PetscErrorCode SVDGetConvergenceTest(SVD svd,SVDConv *conv)SVDGetConvergenceTest455,14071 #undef __FUNCT____FUNCT__464,14281 #define __FUNCT__ __FUNCT__465,14298 PetscErrorCode SVDSetStoppingTestFunction(SVD svd,PetscErrorCode (*func)(SVD,PetscInt,PetscInt,PetscInt,PetscInt,SVDConvergedReason*,void*),void* ctx,PetscErrorCode (*destroy)(void*))SVDSetStoppingTestFunction499,15678 #undef __FUNCT____FUNCT__516,16277 #define __FUNCT__ __FUNCT__517,16294 PetscErrorCode SVDSetStoppingTest(SVD svd,SVDStop stop)SVDSetStoppingTest541,17043 #undef __FUNCT____FUNCT__556,17497 #define __FUNCT__ __FUNCT__557,17514 PetscErrorCode SVDGetStoppingTest(SVD svd,SVDStop *stop)SVDGetStoppingTest574,17912 #undef __FUNCT____FUNCT__583,18119 #define __FUNCT__ __FUNCT__584,18136 PetscErrorCode SVDMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscBool trackall)SVDMonitorSetFromOptions603,18778 #undef __FUNCT____FUNCT__624,19775 #define __FUNCT__ __FUNCT__625,19792 PetscErrorCode SVDConvMonitorSetFromOptions(SVD svd,const char name[],const char help[],const char manual[],PetscErrorCode (*monitor)(SVD,PetscInt,PetscInt,PetscReal*,PetscReal*,PetscInt,SlepcConvMonitor))SVDConvMonitorSetFromOptions643,20410 #undef __FUNCT____FUNCT__661,21281 #define __FUNCT__ __FUNCT__662,21298 PetscErrorCode SVDSetFromOptions(SVD svd)SVDSetFromOptions680,21708 #undef __FUNCT____FUNCT__790,28563 #define __FUNCT__ __FUNCT__791,28580 PetscErrorCode SVDSetTrackAll(SVD svd,PetscBool trackall)SVDSetTrackAll815,29361 #undef __FUNCT____FUNCT__824,29598 #define __FUNCT__ __FUNCT__825,29615 PetscErrorCode SVDGetTrackAll(SVD svd,PetscBool *trackall)SVDGetTrackAll842,29947 #undef __FUNCT____FUNCT__852,30169 #define __FUNCT__ __FUNCT__853,30186 PetscErrorCode SVDSetOptionsPrefix(SVD svd,const char *prefix)SVDSetOptionsPrefix880,30937 #undef __FUNCT____FUNCT__908,32012 #define __FUNCT__ __FUNCT__909,32029 PetscErrorCode SVDAppendOptionsPrefix(SVD svd,const char *prefix)SVDAppendOptionsPrefix928,32588 #undef __FUNCT____FUNCT__956,33687 #define __FUNCT__ __FUNCT__957,33704 PetscErrorCode SVDGetOptionsPrefix(SVD svd,const char *prefix[])SVDGetOptionsPrefix978,34217 src/svd/interface/svdregis.c,131 svdregis.c:^?svdregis.c^A,1 #undef __FUNCT____FUNCT__30,1246 #define __FUNCT__ __FUNCT__31,1263 PetscErrorCode SVDRegisterAll(void)SVDRegisterAll41,1453 src/svd/interface/svdsetup.c,1064 svdsetup.c:^?svdsetup.c^A,1 #undef __FUNCT____FUNCT__26,1032 #define __FUNCT__ __FUNCT__27,1049 PetscErrorCode SVDSetOperator(SVD svd,Mat mat)SVDSetOperator41,1388 #undef __FUNCT____FUNCT__56,1824 #define __FUNCT__ __FUNCT__57,1841 PetscErrorCode SVDGetOperator(SVD svd,Mat *A)SVDGetOperator73,2251 #undef __FUNCT____FUNCT__82,2439 #define __FUNCT__ __FUNCT__83,2456 PetscErrorCode SVDSetUp(SVD svd)SVDSetUp102,2960 #undef __FUNCT____FUNCT__214,6749 #define __FUNCT__ __FUNCT__215,6766 PetscErrorCode SVDSetInitialSpace(SVD svd,PetscInt n,Vec *is)SVDSetInitialSpace245,7769 #undef __FUNCT____FUNCT__258,8231 #define __FUNCT__ __FUNCT__259,8248 PetscErrorCode SVDSetInitialSpaceLeft(SVD svd,PetscInt n,Vec *is)SVDSetInitialSpaceLeft289,9251 #undef __FUNCT____FUNCT__302,9719 #define __FUNCT__ __FUNCT__303,9736 PetscErrorCode SVDSetDimensions_Default(SVD svd)SVDSetDimensions_Default308,9903 #undef __FUNCT____FUNCT__330,10603 #define __FUNCT__ __FUNCT__331,10620 PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra)SVDAllocateSolution351,11208 src/svd/interface/svdsolve.c,1362 svdsolve.c:^?svdsolve.c^A,1 #undef __FUNCT____FUNCT__26,1036 #define __FUNCT__ __FUNCT__27,1053 PetscErrorCode SVDComputeVectors(SVD svd)SVDComputeVectors28,1091 #undef __FUNCT____FUNCT__67,2382 #define __FUNCT__ __FUNCT__68,2399 PetscErrorCode SVDSolve(SVD svd)SVDSolve90,3188 #undef __FUNCT____FUNCT__140,4899 #define __FUNCT__ __FUNCT__141,4916 PetscErrorCode SVDGetIterationNumber(SVD svd,PetscInt *its)SVDGetIterationNumber166,5680 #undef __FUNCT____FUNCT__175,5890 #define __FUNCT__ __FUNCT__176,5907 PetscErrorCode SVDGetConvergedReason(SVD svd,SVDConvergedReason *reason)SVDGetConvergedReason204,6698 #undef __FUNCT____FUNCT__214,6955 #define __FUNCT__ __FUNCT__215,6972 PetscErrorCode SVDGetConverged(SVD svd,PetscInt *nconv)SVDGetConverged233,7331 #undef __FUNCT____FUNCT__243,7568 #define __FUNCT__ __FUNCT__244,7585 PetscErrorCode SVDGetSingularTriplet(SVD svd,PetscInt i,PetscReal *sigma,Vec u,Vec v)SVDGetSingularTriplet274,8629 #undef __FUNCT____FUNCT__300,9566 #define __FUNCT__ __FUNCT__301,9583 static PetscErrorCode SVDComputeResidualNorms_Private(SVD svd,PetscInt i,PetscReal *norm1,PetscReal *norm2)SVDComputeResidualNorms_Private306,9785 #undef __FUNCT____FUNCT__351,11179 #define __FUNCT__ __FUNCT__352,11196 PetscErrorCode SVDComputeError(SVD svd,PetscInt i,SVDErrorType type,PetscReal *error)SVDComputeError377,11901 src/svd/interface/svdview.c,2586 svdview.c:^?svdview.c^A,1 #undef __FUNCT____FUNCT__27,1058 #define __FUNCT__ __FUNCT__28,1075 PetscErrorCode SVDView(SVD svd,PetscViewer viewer)SVDView56,1874 #undef __FUNCT____FUNCT__120,5093 #define __FUNCT__ __FUNCT__121,5110 PetscErrorCode SVDReasonView(SVD svd,PetscViewer viewer)SVDReasonView138,5541 #undef __FUNCT____FUNCT__157,6523 #define __FUNCT__ __FUNCT__158,6540 PetscErrorCode SVDReasonViewFromOptions(SVD svd)SVDReasonViewFromOptions170,6828 #undef __FUNCT____FUNCT__192,7559 #define __FUNCT__ __FUNCT__193,7576 static PetscErrorCode SVDErrorView_ASCII(SVD svd,SVDErrorType etype,PetscViewer viewer)SVDErrorView_ASCII194,7615 #undef __FUNCT____FUNCT__228,9017 #define __FUNCT__ __FUNCT__229,9034 static PetscErrorCode SVDErrorView_DETAIL(SVD svd,SVDErrorType etype,PetscViewer viewer)SVDErrorView_DETAIL230,9074 #define EXLEN EXLEN235,9238 #undef __FUNCT____FUNCT__258,10126 #define __FUNCT__ __FUNCT__259,10143 static PetscErrorCode SVDErrorView_MATLAB(SVD svd,SVDErrorType etype,PetscViewer viewer)SVDErrorView_MATLAB260,10183 #undef __FUNCT____FUNCT__278,10795 #define __FUNCT__ __FUNCT__279,10812 PetscErrorCode SVDErrorView(SVD svd,SVDErrorType etype,PetscViewer viewer)SVDErrorView305,11673 #undef __FUNCT____FUNCT__338,12850 #define __FUNCT__ __FUNCT__339,12867 PetscErrorCode SVDErrorViewFromOptions(SVD svd)SVDErrorViewFromOptions351,13165 #undef __FUNCT____FUNCT__380,14321 #define __FUNCT__ __FUNCT__381,14338 static PetscErrorCode SVDValuesView_DRAW(SVD svd,PetscViewer viewer)SVDValuesView_DRAW382,14377 #undef __FUNCT____FUNCT__406,15258 #define __FUNCT__ __FUNCT__407,15275 static PetscErrorCode SVDValuesView_ASCII(SVD svd,PetscViewer viewer)SVDValuesView_ASCII408,15315 #undef __FUNCT____FUNCT__422,15757 #define __FUNCT__ __FUNCT__423,15774 static PetscErrorCode SVDValuesView_MATLAB(SVD svd,PetscViewer viewer)SVDValuesView_MATLAB424,15815 #undef __FUNCT____FUNCT__440,16350 #define __FUNCT__ __FUNCT__441,16367 PetscErrorCode SVDValuesView(SVD svd,PetscViewer viewer)SVDValuesView458,16752 #undef __FUNCT____FUNCT__492,18007 #define __FUNCT__ __FUNCT__493,18024 PetscErrorCode SVDValuesViewFromOptions(SVD svd)SVDValuesViewFromOptions505,18317 #undef __FUNCT____FUNCT__527,19043 #define __FUNCT__ __FUNCT__528,19060 PetscErrorCode SVDVectorsView(SVD svd,PetscViewer viewer)SVDVectorsView545,19430 #define NMLEN NMLEN550,19555 #undef __FUNCT____FUNCT__580,20740 #define __FUNCT__ __FUNCT__581,20757 PetscErrorCode SVDVectorsViewFromOptions(SVD svd)SVDVectorsViewFromOptions593,21053 src/svd/makefile,211 makefile:^?makefile^A,1 SOURCEH = ../../include/slepc/private/svdimpl.h ../../include/slepcsvd.hSOURCEH24,936 DIRS = interface impls examples f90-modDIRS25,1010 LOCDIR = src/svd/LOCDIR26,1054 MANSEC = SVDMANSEC27,1074 src/sys/classes/bv/examples/makefile,83 makefile:^?makefile^A,1 LOCDIR = src/sys/classes/bv/examples/LOCDIR24,932 DIRS = testsDIRS25,972 src/sys/classes/bv/examples/tests/makefile,611 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/sys/classes/bv/examples/tests/LOCDIR26,978 EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c test10.c test11.c test12.cEXAMPLESC27,1026 EXAMPLESF =EXAMPLESF28,1138 MANSEC = BVMANSEC29,1151 TESTS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12TESTS30,1167 TESTEXAMPLES_C = test1.PETSc runtest1_1 runtest1_2 runtest1_3 runtest1_4 test1.rm \TESTEXAMPLES_C32,1256 TESTCODE = \TESTCODE99,3668 src/sys/classes/bv/examples/tests/test1.c,175 test1.c:^?test1.c^A,1 static char help[] = "Test BV operations.\n\n";help22,924 #undef __FUNCT____FUNCT__26,995 #define __FUNCT__ __FUNCT__27,1012 int main(int argc,char **argv)main28,1037 src/sys/classes/bv/examples/tests/test10.c,185 test10.c:^?test10.c^A,1 static char help[] = "Test split reductions in BV.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1004 #define __FUNCT__ __FUNCT__27,1021 int main(int argc,char **argv)main28,1046 src/sys/classes/bv/examples/tests/test11.c,189 test11.c:^?test11.c^A,1 static char help[] = "Test BV block orthogonalization.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1008 #define __FUNCT__ __FUNCT__27,1025 int main(int argc,char **argv)main28,1050 src/sys/classes/bv/examples/tests/test12.c,209 test12.c:^?test12.c^A,1 static char help[] = "Test block orthogonalization on a rank-deficient BV.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1028 #define __FUNCT__ __FUNCT__27,1045 int main(int argc,char **argv)main28,1070 src/sys/classes/bv/examples/tests/test2.c,193 test2.c:^?test2.c^A,1 static char help[] = "Test BV orthogonalization functions.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1012 #define __FUNCT__ __FUNCT__27,1029 int main(int argc,char **argv)main28,1054 src/sys/classes/bv/examples/tests/test3.c,208 test3.c:^?test3.c^A,1 static char help[] = "Test BV operations with non-standard inner product.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1027 #define __FUNCT__ __FUNCT__27,1044 int main(int argc,char **argv)main28,1069 src/sys/classes/bv/examples/tests/test4.c,215 test4.c:^?test4.c^A,1 static char help[] = "Test BV operations, changing the number of active columns.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1034 #define __FUNCT__ __FUNCT__27,1051 int main(int argc,char **argv)main28,1076 src/sys/classes/bv/examples/tests/test5.c,206 test5.c:^?test5.c^A,1 static char help[] = "Test BV operations with indefinite inner product.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1025 #define __FUNCT__ __FUNCT__27,1042 int main(int argc,char **argv)main28,1067 src/sys/classes/bv/examples/tests/test6.c,210 test6.c:^?test6.c^A,1 static char help[] = "Test BV orthogonalization functions with constraints.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1029 #define __FUNCT__ __FUNCT__27,1046 int main(int argc,char **argv)main28,1071 src/sys/classes/bv/examples/tests/test7.c,197 test7.c:^?test7.c^A,1 static char help[] = "Test multiplication of a Mat times a BV.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1016 #define __FUNCT__ __FUNCT__27,1033 int main(int argc,char **argv)main28,1058 src/sys/classes/bv/examples/tests/test8.c,205 test8.c:^?test8.c^A,1 static char help[] = "Test BV orthogonalization with selected columns.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1024 #define __FUNCT__ __FUNCT__27,1041 int main(int argc,char **argv)main28,1066 src/sys/classes/bv/examples/tests/test9.c,183 test9.c:^?test9.c^A,1 static char help[] = "Test BV matrix projection.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1002 #define __FUNCT__ __FUNCT__27,1019 int main(int argc,char **argv)main28,1044 src/sys/classes/bv/impls/contiguous/contig.c,3399 contig.c:^?contig.c^A,1 Vec *V;V27,1055 PetscScalar *array;array28,1073 PetscBool mpi;mpi29,1095 } BV_CONTIGUOUS;BV_CONTIGUOUS30,1114 #undef __FUNCT____FUNCT__32,1132 #define __FUNCT__ __FUNCT__33,1149 PetscErrorCode BVMult_Contiguous(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)BVMult_Contiguous34,1187 #undef __FUNCT____FUNCT__53,1934 #define __FUNCT__ __FUNCT__54,1951 PetscErrorCode BVMultVec_Contiguous(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)BVMultVec_Contiguous55,1992 #undef __FUNCT____FUNCT__68,2434 #define __FUNCT__ __FUNCT__69,2451 PetscErrorCode BVMultInPlace_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlace_Contiguous70,2496 #undef __FUNCT____FUNCT__85,3029 #define __FUNCT__ __FUNCT__86,3046 PetscErrorCode BVMultInPlaceTranspose_Contiguous(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlaceTranspose_Contiguous87,3100 #undef __FUNCT____FUNCT__102,3641 #define __FUNCT__ __FUNCT__103,3658 PetscErrorCode BVDot_Contiguous(BV X,BV Y,Mat M)BVDot_Contiguous104,3695 #undef __FUNCT____FUNCT__119,4238 #define __FUNCT__ __FUNCT__120,4255 PetscErrorCode BVDotVec_Contiguous(BV X,Vec y,PetscScalar *m)BVDotVec_Contiguous121,4295 #undef __FUNCT____FUNCT__139,4822 #define __FUNCT__ __FUNCT__140,4839 PetscErrorCode BVDotVec_Local_Contiguous(BV X,Vec y,PetscScalar *m)BVDotVec_Local_Contiguous141,4885 #undef __FUNCT____FUNCT__159,5403 #define __FUNCT__ __FUNCT__160,5420 PetscErrorCode BVScale_Contiguous(BV bv,PetscInt j,PetscScalar alpha)BVScale_Contiguous161,5459 #undef __FUNCT____FUNCT__175,5884 #define __FUNCT__ __FUNCT__176,5901 PetscErrorCode BVNorm_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Contiguous177,5939 #undef __FUNCT____FUNCT__191,6400 #define __FUNCT__ __FUNCT__192,6417 PetscErrorCode BVNorm_Local_Contiguous(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Local_Contiguous193,6461 #undef __FUNCT____FUNCT__207,6934 #define __FUNCT__ __FUNCT__208,6951 PetscErrorCode BVOrthogonalize_Contiguous(BV V,Mat R)BVOrthogonalize_Contiguous209,6998 #undef __FUNCT____FUNCT__222,7425 #define __FUNCT__ __FUNCT__223,7442 PetscErrorCode BVMatMult_Contiguous(BV V,Mat A,BV W)BVMatMult_Contiguous224,7483 #undef __FUNCT____FUNCT__263,8967 #define __FUNCT__ __FUNCT__264,8984 PetscErrorCode BVCopy_Contiguous(BV V,BV W)BVCopy_Contiguous265,9022 #undef __FUNCT____FUNCT__278,9401 #define __FUNCT__ __FUNCT__279,9418 PetscErrorCode BVResize_Contiguous(BV bv,PetscInt m,PetscBool copy)BVResize_Contiguous280,9458 #undef __FUNCT____FUNCT__318,10849 #define __FUNCT__ __FUNCT__319,10866 PetscErrorCode BVGetColumn_Contiguous(BV bv,PetscInt j,Vec *v)BVGetColumn_Contiguous320,10909 #undef __FUNCT____FUNCT__331,11148 #define __FUNCT__ __FUNCT__332,11165 PetscErrorCode BVGetArray_Contiguous(BV bv,PetscScalar **a)BVGetArray_Contiguous333,11207 #undef __FUNCT____FUNCT__342,11389 #define __FUNCT__ __FUNCT__343,11406 PetscErrorCode BVGetArrayRead_Contiguous(BV bv,const PetscScalar **a)BVGetArrayRead_Contiguous344,11452 #undef __FUNCT____FUNCT__353,11644 #define __FUNCT__ __FUNCT__354,11661 PetscErrorCode BVDestroy_Contiguous(BV bv)BVDestroy_Contiguous355,11702 #undef __FUNCT____FUNCT__367,12023 #define __FUNCT__ __FUNCT__368,12040 PETSC_EXTERN PetscErrorCode BVCreate_Contiguous(BV bv)BVCreate_Contiguous369,12080 src/sys/classes/bv/impls/contiguous/makefile,292 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = contig.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsysLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = BVMANSEC31,1034 LOCDIR = src/sys/classes/bv/impls/contiguous/LOCDIR32,1048 src/sys/classes/bv/impls/makefile,166 makefile:^?makefile^A,1 LIBBASE = libslepcsysLIBBASE24,936 DIRS = vecs contiguous svec matDIRS25,959 LOCDIR = src/sys/classes/bv/impls/LOCDIR26,995 MANSEC = BVMANSEC27,1032 src/sys/classes/bv/impls/mat/bvmat.c,3737 bvmat.c:^?bvmat.c^A,1 Mat A;A27,1012 PetscBool mpi;mpi28,1027 } BV_MAT;BV_MAT29,1044 #undef __FUNCT____FUNCT__31,1055 #define __FUNCT__ __FUNCT__32,1072 PetscErrorCode BVMult_Mat(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)BVMult_Mat33,1103 #undef __FUNCT____FUNCT__56,2025 #define __FUNCT__ __FUNCT__57,2042 PetscErrorCode BVMultVec_Mat(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)BVMultVec_Mat58,2076 #undef __FUNCT____FUNCT__73,2608 #define __FUNCT__ __FUNCT__74,2625 PetscErrorCode BVMultInPlace_Mat(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlace_Mat75,2663 #undef __FUNCT____FUNCT__92,3288 #define __FUNCT__ __FUNCT__93,3305 PetscErrorCode BVMultInPlaceTranspose_Mat(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlaceTranspose_Mat94,3352 #undef __FUNCT____FUNCT__111,3985 #define __FUNCT__ __FUNCT__112,4002 PetscErrorCode BVDot_Mat(BV X,BV Y,Mat M)BVDot_Mat113,4032 #undef __FUNCT____FUNCT__132,4762 #define __FUNCT__ __FUNCT__133,4779 PetscErrorCode BVDotVec_Mat(BV X,Vec y,PetscScalar *m)BVDotVec_Mat134,4812 #undef __FUNCT____FUNCT__155,5450 #define __FUNCT__ __FUNCT__156,5467 PetscErrorCode BVDotVec_Local_Mat(BV X,Vec y,PetscScalar *m)BVDotVec_Local_Mat157,5506 #undef __FUNCT____FUNCT__177,6114 #define __FUNCT__ __FUNCT__178,6131 PetscErrorCode BVScale_Mat(BV bv,PetscInt j,PetscScalar alpha)BVScale_Mat179,6163 #undef __FUNCT____FUNCT__196,6705 #define __FUNCT__ __FUNCT__197,6722 PetscErrorCode BVNorm_Mat(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Mat198,6753 #undef __FUNCT____FUNCT__215,7331 #define __FUNCT__ __FUNCT__216,7348 PetscErrorCode BVNorm_Local_Mat(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Local_Mat217,7385 #undef __FUNCT____FUNCT__234,7975 #define __FUNCT__ __FUNCT__235,7992 PetscErrorCode BVOrthogonalize_Mat(BV V,Mat R)BVOrthogonalize_Mat236,8032 #undef __FUNCT____FUNCT__251,8551 #define __FUNCT__ __FUNCT__252,8568 PetscErrorCode BVMatMult_Mat(BV V,Mat A,BV W)BVMatMult_Mat253,8602 #undef __FUNCT____FUNCT__300,10501 #define __FUNCT__ __FUNCT__301,10518 PetscErrorCode BVCopy_Mat(BV V,BV W)BVCopy_Mat302,10549 #undef __FUNCT____FUNCT__319,11115 #define __FUNCT__ __FUNCT__320,11132 PetscErrorCode BVResize_Mat(BV bv,PetscInt m,PetscBool copy)BVResize_Mat321,11165 #undef __FUNCT____FUNCT__350,12309 #define __FUNCT__ __FUNCT__351,12326 PetscErrorCode BVGetColumn_Mat(BV bv,PetscInt j,Vec *v)BVGetColumn_Mat352,12362 #undef __FUNCT____FUNCT__366,12724 #define __FUNCT__ __FUNCT__367,12741 PetscErrorCode BVRestoreColumn_Mat(BV bv,PetscInt j,Vec *v)BVRestoreColumn_Mat368,12781 #undef __FUNCT____FUNCT__382,13137 #define __FUNCT__ __FUNCT__383,13154 PetscErrorCode BVGetArray_Mat(BV bv,PetscScalar **a)BVGetArray_Mat384,13189 #undef __FUNCT____FUNCT__394,13413 #define __FUNCT__ __FUNCT__395,13430 PetscErrorCode BVRestoreArray_Mat(BV bv,PetscScalar **a)BVRestoreArray_Mat396,13469 #undef __FUNCT____FUNCT__406,13712 #define __FUNCT__ __FUNCT__407,13729 PetscErrorCode BVGetArrayRead_Mat(BV bv,const PetscScalar **a)BVGetArrayRead_Mat408,13768 #undef __FUNCT____FUNCT__418,14017 #define __FUNCT__ __FUNCT__419,14034 PetscErrorCode BVRestoreArrayRead_Mat(BV bv,const PetscScalar **a)BVRestoreArrayRead_Mat420,14077 #undef __FUNCT____FUNCT__430,14345 #define __FUNCT__ __FUNCT__431,14362 PetscErrorCode BVView_Mat(BV bv,PetscViewer viewer)BVView_Mat432,14393 #undef __FUNCT____FUNCT__457,15315 #define __FUNCT__ __FUNCT__458,15332 PetscErrorCode BVDestroy_Mat(BV bv)BVDestroy_Mat459,15366 #undef __FUNCT____FUNCT__472,15704 #define __FUNCT__ __FUNCT__473,15721 PETSC_EXTERN PetscErrorCode BVCreate_Mat(BV bv)BVCreate_Mat474,15754 src/sys/classes/bv/impls/mat/makefile,284 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = bvmat.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = BVMANSEC31,1033 LOCDIR = src/sys/classes/bv/impls/svec/LOCDIR32,1047 src/sys/classes/bv/impls/svec/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = svec.cSOURCEC26,958 SOURCEF =SOURCEF27,976 SOURCEH =SOURCEH28,987 LIBBASE = libslepcsysLIBBASE29,998 DIRS =DIRS30,1021 MANSEC = BVMANSEC31,1032 LOCDIR = src/sys/classes/bv/impls/svec/LOCDIR32,1046 src/sys/classes/bv/impls/svec/svec.c,3785 svec.c:^?svec.c^A,1 Vec v;v27,1011 PetscBool mpi;mpi28,1026 } BV_SVEC;BV_SVEC29,1043 #undef __FUNCT____FUNCT__31,1055 #define __FUNCT__ __FUNCT__32,1072 PetscErrorCode BVMult_Svec(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)BVMult_Svec33,1104 #undef __FUNCT____FUNCT__57,2050 #define __FUNCT__ __FUNCT__58,2067 PetscErrorCode BVMultVec_Svec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)BVMultVec_Svec59,2102 #undef __FUNCT____FUNCT__74,2626 #define __FUNCT__ __FUNCT__75,2643 PetscErrorCode BVMultInPlace_Svec(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlace_Svec76,2682 #undef __FUNCT____FUNCT__93,3299 #define __FUNCT__ __FUNCT__94,3316 PetscErrorCode BVMultInPlaceTranspose_Svec(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlaceTranspose_Svec95,3364 #undef __FUNCT____FUNCT__112,3989 #define __FUNCT__ __FUNCT__113,4006 PetscErrorCode BVDot_Svec(BV X,BV Y,Mat M)BVDot_Svec114,4037 #undef __FUNCT____FUNCT__134,4799 #define __FUNCT__ __FUNCT__135,4816 PetscErrorCode BVDotVec_Svec(BV X,Vec y,PetscScalar *m)BVDotVec_Svec136,4850 #undef __FUNCT____FUNCT__156,5467 #define __FUNCT__ __FUNCT__157,5484 PetscErrorCode BVDotVec_Local_Svec(BV X,Vec y,PetscScalar *m)BVDotVec_Local_Svec158,5524 #undef __FUNCT____FUNCT__178,6124 #define __FUNCT__ __FUNCT__179,6141 PetscErrorCode BVScale_Svec(BV bv,PetscInt j,PetscScalar alpha)BVScale_Svec180,6174 #undef __FUNCT____FUNCT__197,6708 #define __FUNCT__ __FUNCT__198,6725 PetscErrorCode BVNorm_Svec(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Svec199,6757 #undef __FUNCT____FUNCT__216,7327 #define __FUNCT__ __FUNCT__217,7344 PetscErrorCode BVNorm_Local_Svec(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Local_Svec218,7382 #undef __FUNCT____FUNCT__235,7964 #define __FUNCT__ __FUNCT__236,7981 PetscErrorCode BVOrthogonalize_Svec(BV V,Mat R)BVOrthogonalize_Svec237,8022 #undef __FUNCT____FUNCT__252,8533 #define __FUNCT__ __FUNCT__253,8550 PetscErrorCode BVMatMult_Svec(BV V,Mat A,BV W)BVMatMult_Svec254,8585 #undef __FUNCT____FUNCT__301,10467 #define __FUNCT__ __FUNCT__302,10484 PetscErrorCode BVCopy_Svec(BV V,BV W)BVCopy_Svec303,10516 #undef __FUNCT____FUNCT__320,11065 #define __FUNCT__ __FUNCT__321,11082 PetscErrorCode BVResize_Svec(BV bv,PetscInt m,PetscBool copy)BVResize_Svec322,11116 #undef __FUNCT____FUNCT__354,12352 #define __FUNCT__ __FUNCT__355,12369 PetscErrorCode BVGetColumn_Svec(BV bv,PetscInt j,Vec *v)BVGetColumn_Svec356,12406 #undef __FUNCT____FUNCT__370,12765 #define __FUNCT__ __FUNCT__371,12782 PetscErrorCode BVRestoreColumn_Svec(BV bv,PetscInt j,Vec *v)BVRestoreColumn_Svec372,12823 #undef __FUNCT____FUNCT__385,13155 #define __FUNCT__ __FUNCT__386,13172 PetscErrorCode BVGetArray_Svec(BV bv,PetscScalar **a)BVGetArray_Svec387,13208 #undef __FUNCT____FUNCT__397,13429 #define __FUNCT__ __FUNCT__398,13446 PetscErrorCode BVRestoreArray_Svec(BV bv,PetscScalar **a)BVRestoreArray_Svec399,13486 #undef __FUNCT____FUNCT__409,13715 #define __FUNCT__ __FUNCT__410,13732 PetscErrorCode BVGetArrayRead_Svec(BV bv,const PetscScalar **a)BVGetArrayRead_Svec411,13772 #undef __FUNCT____FUNCT__421,14007 #define __FUNCT__ __FUNCT__422,14024 PetscErrorCode BVRestoreArrayRead_Svec(BV bv,const PetscScalar **a)BVRestoreArrayRead_Svec423,14068 #undef __FUNCT____FUNCT__433,14311 #define __FUNCT__ __FUNCT__434,14328 PetscErrorCode BVView_Svec(BV bv,PetscViewer viewer)BVView_Svec435,14360 #undef __FUNCT____FUNCT__460,15318 #define __FUNCT__ __FUNCT__461,15335 PetscErrorCode BVDestroy_Svec(BV bv)BVDestroy_Svec462,15370 #undef __FUNCT____FUNCT__475,15710 #define __FUNCT__ __FUNCT__476,15727 PETSC_EXTERN PetscErrorCode BVCreate_Svec(BV bv)BVCreate_Svec477,15761 src/sys/classes/bv/impls/vecs/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = vecs.cSOURCEC26,958 SOURCEF =SOURCEF27,976 SOURCEH =SOURCEH28,987 LIBBASE = libslepcsysLIBBASE29,998 DIRS =DIRS30,1021 MANSEC = BVMANSEC31,1032 LOCDIR = src/sys/classes/bv/impls/vecs/LOCDIR32,1046 src/sys/classes/bv/impls/vecs/vecs.c,4533 vecs.c:^?vecs.c^A,1 Vec *V;V27,1027 PetscInt vmip; /* Version of BVMultInPlace:vmip28,1042 } BV_VECS;BV_VECS31,1246 #undef __FUNCT____FUNCT__33,1258 #define __FUNCT__ __FUNCT__34,1275 PetscErrorCode BVMult_Vecs(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)BVMult_Vecs35,1307 #undef __FUNCT____FUNCT__67,2342 #define __FUNCT__ __FUNCT__68,2359 PetscErrorCode BVMultVec_Vecs(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)BVMultVec_Vecs69,2394 #undef __FUNCT____FUNCT__89,2943 #define __FUNCT__ __FUNCT__90,2960 PetscErrorCode BVMultInPlace_Vecs_ME(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlace_Vecs_ME100,3326 #undef __FUNCT____FUNCT__125,4112 #define __FUNCT__ __FUNCT__126,4129 PetscErrorCode BVMultInPlace_Vecs_Alloc(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlace_Vecs_Alloc132,4334 #undef __FUNCT____FUNCT__155,5035 #define __FUNCT__ __FUNCT__156,5052 PetscErrorCode BVMultInPlaceTranspose_Vecs(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlaceTranspose_Vecs160,5187 #undef __FUNCT____FUNCT__185,5980 #define __FUNCT__ __FUNCT__186,5997 PetscErrorCode BVDot_Vecs(BV X,BV Y,Mat M)BVDot_Vecs187,6028 #undef __FUNCT____FUNCT__204,6523 #define __FUNCT__ __FUNCT__205,6540 PetscErrorCode BVDotVec_Vecs(BV X,Vec y,PetscScalar *m)BVDotVec_Vecs206,6574 #undef __FUNCT____FUNCT__221,6917 #define __FUNCT__ __FUNCT__222,6934 PetscErrorCode BVDotVec_Begin_Vecs(BV X,Vec y,PetscScalar *m)BVDotVec_Begin_Vecs223,6974 #undef __FUNCT____FUNCT__238,7328 #define __FUNCT__ __FUNCT__239,7345 PetscErrorCode BVDotVec_End_Vecs(BV X,Vec y,PetscScalar *m)BVDotVec_End_Vecs240,7383 #undef __FUNCT____FUNCT__250,7627 #define __FUNCT__ __FUNCT__251,7644 PetscErrorCode BVScale_Vecs(BV bv,PetscInt j,PetscScalar alpha)BVScale_Vecs252,7677 #undef __FUNCT____FUNCT__269,8068 #define __FUNCT__ __FUNCT__270,8085 PetscErrorCode BVNorm_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Vecs271,8117 #undef __FUNCT____FUNCT__298,8796 #define __FUNCT__ __FUNCT__299,8813 PetscErrorCode BVNorm_Begin_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_Begin_Vecs300,8851 #undef __FUNCT____FUNCT__317,9274 #define __FUNCT__ __FUNCT__318,9291 PetscErrorCode BVNorm_End_Vecs(BV bv,PetscInt j,NormType type,PetscReal *val)BVNorm_End_Vecs319,9327 #undef __FUNCT____FUNCT__336,9746 #define __FUNCT__ __FUNCT__337,9763 PetscErrorCode BVMatMult_Vecs(BV V,Mat A,BV W)BVMatMult_Vecs338,9798 #undef __FUNCT____FUNCT__352,10204 #define __FUNCT__ __FUNCT__353,10221 PetscErrorCode BVCopy_Vecs(BV V,BV W)BVCopy_Vecs354,10253 #undef __FUNCT____FUNCT__367,10559 #define __FUNCT__ __FUNCT__368,10576 PetscErrorCode BVResize_Vecs(BV bv,PetscInt m,PetscBool copy)BVResize_Vecs369,10610 #undef __FUNCT____FUNCT__396,11390 #define __FUNCT__ __FUNCT__397,11407 PetscErrorCode BVGetColumn_Vecs(BV bv,PetscInt j,Vec *v)BVGetColumn_Vecs398,11444 #undef __FUNCT____FUNCT__409,11661 #define __FUNCT__ __FUNCT__410,11678 PetscErrorCode BVGetArray_Vecs(BV bv,PetscScalar **a)BVGetArray_Vecs411,11714 #undef __FUNCT____FUNCT__428,12234 #define __FUNCT__ __FUNCT__429,12251 PetscErrorCode BVRestoreArray_Vecs(BV bv,PetscScalar **a)BVRestoreArray_Vecs430,12291 #undef __FUNCT____FUNCT__447,12772 #define __FUNCT__ __FUNCT__448,12789 PetscErrorCode BVGetArrayRead_Vecs(BV bv,const PetscScalar **a)BVGetArrayRead_Vecs449,12829 #undef __FUNCT____FUNCT__466,13373 #define __FUNCT__ __FUNCT__467,13390 PetscErrorCode BVRestoreArrayRead_Vecs(BV bv,const PetscScalar **a)BVRestoreArrayRead_Vecs468,13434 #undef __FUNCT____FUNCT__477,13617 #define __FUNCT__ __FUNCT__478,13634 PETSC_STATIC_INLINE PetscErrorCode BVVecsSetVmip(BV bv,PetscInt vmip)BVVecsSetVmip482,13746 #undef __FUNCT____FUNCT__494,14138 #define __FUNCT__ __FUNCT__495,14155 PetscErrorCode BVSetFromOptions_Vecs(PetscOptionItems *PetscOptionsObject,BV bv)BVSetFromOptions_Vecs496,14197 #undef __FUNCT____FUNCT__510,14837 #define __FUNCT__ __FUNCT__511,14854 PetscErrorCode BVView_Vecs(BV bv,PetscViewer viewer)BVView_Vecs512,14886 #undef __FUNCT____FUNCT__541,15919 #define __FUNCT__ __FUNCT__542,15936 PetscErrorCode BVDestroy_Vecs(BV bv)BVDestroy_Vecs543,15971 #undef __FUNCT____FUNCT__554,16234 #define __FUNCT__ __FUNCT__555,16251 PetscErrorCode BVDuplicate_Vecs(BV V,BV *W)BVDuplicate_Vecs556,16288 #undef __FUNCT____FUNCT__566,16504 #define __FUNCT__ __FUNCT__567,16521 PETSC_EXTERN PetscErrorCode BVCreate_Vecs(BV bv)BVCreate_Vecs568,16555 src/sys/classes/bv/interface/bvbasic.c,6032 bvbasic.c:^?bvbasic.c^A,1 PetscBool BVRegisterAllCalled = PETSC_FALSE;BVRegisterAllCalled26,1007 PetscFunctionList BVList = 0;BVList27,1060 #undef __FUNCT____FUNCT__29,1091 #define __FUNCT__ __FUNCT__30,1108 PetscErrorCode BVSetType(BV bv,BVType type)BVSetType47,1416 #undef __FUNCT____FUNCT__76,2401 #define __FUNCT__ __FUNCT__77,2418 PetscErrorCode BVGetType(BV bv,BVType *type)BVGetType93,2716 #undef __FUNCT____FUNCT__102,2928 #define __FUNCT__ __FUNCT__103,2945 PetscErrorCode BVSetSizes(BV bv,PetscInt n,PetscInt N,PetscInt m)BVSetSizes124,3501 #undef __FUNCT____FUNCT__162,5430 #define __FUNCT__ __FUNCT__163,5447 PetscErrorCode BVSetSizesFromVec(BV bv,Vec t,PetscInt m)BVSetSizesFromVec179,5854 #undef __FUNCT____FUNCT__208,7000 #define __FUNCT__ __FUNCT__209,7017 PetscErrorCode BVGetSizes(BV bv,PetscInt *n,PetscInt *N,PetscInt *m)BVGetSizes234,7720 #undef __FUNCT____FUNCT__250,8122 #define __FUNCT__ __FUNCT__251,8139 PetscErrorCode BVSetNumConstraints(BV V,PetscInt nc)BVSetNumConstraints273,8763 #undef __FUNCT____FUNCT__310,10085 #define __FUNCT__ __FUNCT__311,10102 PetscErrorCode BVGetNumConstraints(BV bv,PetscInt *nc)BVGetNumConstraints327,10400 #undef __FUNCT____FUNCT__336,10596 #define __FUNCT__ __FUNCT__337,10613 PetscErrorCode BVResize(BV bv,PetscInt m,PetscBool copy)BVResize356,11081 #undef __FUNCT____FUNCT__391,12343 #define __FUNCT__ __FUNCT__392,12360 PetscErrorCode BVSetActiveColumns(BV bv,PetscInt l,PetscInt k)BVSetActiveColumns420,13266 #undef __FUNCT____FUNCT__442,13993 #define __FUNCT__ __FUNCT__443,14010 PetscErrorCode BVGetActiveColumns(BV bv,PetscInt *l,PetscInt *k)BVGetActiveColumns460,14339 #undef __FUNCT____FUNCT__469,14544 #define __FUNCT__ __FUNCT__470,14561 PetscErrorCode BVSetMatrix(BV bv,Mat B,PetscBool indef)BVSetMatrix500,15638 #undef __FUNCT____FUNCT__525,16508 #define __FUNCT__ __FUNCT__526,16525 PetscErrorCode BVGetMatrix(BV bv,Mat *B,PetscBool *indef)BVGetMatrix543,16939 #undef __FUNCT____FUNCT__552,17162 #define __FUNCT__ __FUNCT__553,17179 PetscErrorCode BVApplyMatrix(BV bv,Vec x,Vec y)BVApplyMatrix574,17609 #undef __FUNCT____FUNCT__591,18032 #define __FUNCT__ __FUNCT__592,18049 PetscErrorCode BVApplyMatrixBV(BV X,BV Y)BVApplyMatrixBV616,18726 #undef __FUNCT____FUNCT__635,19138 #define __FUNCT__ __FUNCT__636,19155 PetscErrorCode BVGetCachedBV(BV bv,BV *cached)BVGetCachedBV656,19582 #undef __FUNCT____FUNCT__665,19782 #define __FUNCT__ __FUNCT__666,19799 PetscErrorCode BVSetSignature(BV bv,Vec omega)BVSetSignature683,20231 #undef __FUNCT____FUNCT__708,21095 #define __FUNCT__ __FUNCT__709,21112 PetscErrorCode BVGetSignature(BV bv,Vec omega)BVGetSignature728,21555 #undef __FUNCT____FUNCT__752,22303 #define __FUNCT__ __FUNCT__753,22320 PetscErrorCode BVSetRandomContext(BV bv,PetscRandom rand)BVSetRandomContext768,22710 #undef __FUNCT____FUNCT__783,23203 #define __FUNCT__ __FUNCT__784,23220 PetscErrorCode BVGetRandomContext(BV bv,PetscRandom* rand)BVGetRandomContext800,23573 #undef __FUNCT____FUNCT__819,24151 #define __FUNCT__ __FUNCT__820,24168 PetscErrorCode BVSetFromOptions(BV bv)BVSetFromOptions831,24374 #undef __FUNCT____FUNCT__877,26873 #define __FUNCT__ __FUNCT__878,26890 PetscErrorCode BVSetOrthogonalization(BV bv,BVOrthogType type,BVOrthogRefineType refine,PetscReal eta,BVOrthogBlockType block)BVSetOrthogonalization916,28469 #undef __FUNCT____FUNCT__958,29857 #define __FUNCT__ __FUNCT__959,29874 PetscErrorCode BVGetOrthogonalization(BV bv,BVOrthogType *type,BVOrthogRefineType *refine,PetscReal *eta,BVOrthogBlockType *block)BVGetOrthogonalization978,30414 #undef __FUNCT____FUNCT__989,30806 #define __FUNCT__ __FUNCT__990,30823 PetscErrorCode BVSetMatMultMethod(BV bv,BVMatMultType method)BVSetMatMultMethod1014,31554 #undef __FUNCT____FUNCT__1031,32011 #define __FUNCT__ __FUNCT__1032,32028 PetscErrorCode BVGetMatMultMethod(BV bv,BVMatMultType *method)BVGetMatMultMethod1048,32376 #undef __FUNCT____FUNCT__1057,32590 #define __FUNCT__ __FUNCT__1058,32607 PetscErrorCode BVGetColumn(BV bv,PetscInt j,Vec *v)BVGetColumn1088,33545 #undef __FUNCT____FUNCT__1111,34727 #define __FUNCT__ __FUNCT__1112,34744 PetscErrorCode BVRestoreColumn(BV bv,PetscInt j,Vec *v)BVRestoreColumn1130,35141 #undef __FUNCT____FUNCT__1164,36609 #define __FUNCT__ __FUNCT__1165,36626 PetscErrorCode BVGetArray(BV bv,PetscScalar **a)BVGetArray1190,37352 #undef __FUNCT____FUNCT__1202,37620 #define __FUNCT__ __FUNCT__1203,37637 PetscErrorCode BVRestoreArray(BV bv,PetscScalar **a)BVRestoreArray1221,38069 #undef __FUNCT____FUNCT__1237,38468 #define __FUNCT__ __FUNCT__1238,38485 PetscErrorCode BVGetArrayRead(BV bv,const PetscScalar **a)BVGetArrayRead1263,39221 #undef __FUNCT____FUNCT__1275,39503 #define __FUNCT__ __FUNCT__1276,39520 PetscErrorCode BVRestoreArrayRead(BV bv,const PetscScalar **a)BVRestoreArrayRead1291,39857 #undef __FUNCT____FUNCT__1306,40208 #define __FUNCT__ __FUNCT__1307,40225 PetscErrorCode BVCreateVec(BV bv,Vec *v)BVCreateVec1325,40601 #undef __FUNCT____FUNCT__1337,40858 #define __FUNCT__ __FUNCT__1338,40875 PETSC_STATIC_INLINE PetscErrorCode BVDuplicate_Private(BV V,PetscInt m,BV *W)BVDuplicate_Private1339,40915 #undef __FUNCT____FUNCT__1356,41625 #define __FUNCT__ __FUNCT__1357,41642 PetscErrorCode BVDuplicate(BV V,BV *W)BVDuplicate1382,42335 #undef __FUNCT____FUNCT__1395,42619 #define __FUNCT__ __FUNCT__1396,42636 PetscErrorCode BVDuplicateResize(BV V,PetscInt m,BV *W)BVDuplicateResize1418,43187 #undef __FUNCT____FUNCT__1432,43526 #define __FUNCT__ __FUNCT__1433,43543 PetscErrorCode BVCopy(BV V,BV W)BVCopy1455,44125 #undef __FUNCT____FUNCT__1482,45187 #define __FUNCT__ __FUNCT__1483,45204 PetscErrorCode BVCopyVec(BV V,PetscInt j,Vec w)BVCopyVec1503,45647 #undef __FUNCT____FUNCT__1529,46537 #define __FUNCT__ __FUNCT__1530,46554 PetscErrorCode BVCopyColumn(BV V,PetscInt j,PetscInt i)BVCopyColumn1545,46888 src/sys/classes/bv/interface/bvblas.c,2515 bvblas.c:^?bvblas.c^A,1 #define BLOCKSIZE BLOCKSIZE27,1030 #undef __FUNCT____FUNCT__29,1052 #define __FUNCT__ __FUNCT__30,1069 PetscErrorCode BVMult_BLAS_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,PetscInt ldb_,PetscScalar alpha,const PetscScalar *A,const PetscScalar *B,PetscScalar beta,PetscScalar *C)BVMult_BLAS_Private36,1200 #undef __FUNCT____FUNCT__62,2353 #define __FUNCT__ __FUNCT__63,2370 PetscErrorCode BVMultVec_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,PetscScalar alpha,const PetscScalar *A,const PetscScalar *x,PetscScalar beta,PetscScalar *y)BVMultVec_BLAS_Private69,2468 #undef __FUNCT____FUNCT__82,2971 #define __FUNCT__ __FUNCT__83,2988 PetscErrorCode BVMultInPlace_BLAS_Private(BV bv,PetscInt m_,PetscInt k_,PetscInt ldb_,PetscInt s,PetscInt e,PetscScalar *A,const PetscScalar *B,PetscBool btrans)BVMultInPlace_BLAS_Private89,3119 #undef __FUNCT____FUNCT__127,4409 #define __FUNCT__ __FUNCT__128,4426 PetscErrorCode BVMultInPlace_Vecs_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,Vec *V,const PetscScalar *B,PetscBool btrans)BVMultInPlace_Vecs_Private134,4530 #undef __FUNCT____FUNCT__182,6401 #define __FUNCT__ __FUNCT__183,6418 PetscErrorCode BVAXPY_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,PetscScalar alpha,const PetscScalar *A,PetscScalar beta,PetscScalar *B)BVAXPY_BLAS_Private189,6514 #undef __FUNCT____FUNCT__205,7061 #define __FUNCT__ __FUNCT__206,7078 PetscErrorCode BVDot_BLAS_Private(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,PetscInt ldc_,const PetscScalar *A,const PetscScalar *B,PetscScalar *C,PetscBool mpi)BVDot_BLAS_Private212,7195 #undef __FUNCT____FUNCT__248,8974 #define __FUNCT__ __FUNCT__249,8991 PetscErrorCode BVDotVec_BLAS_Private(BV bv,PetscInt n_,PetscInt k_,const PetscScalar *A,const PetscScalar *x,PetscScalar *y,PetscBool mpi)BVDotVec_BLAS_Private255,9074 #undef __FUNCT____FUNCT__280,10041 #define __FUNCT__ __FUNCT__281,10058 PetscErrorCode BVScale_BLAS_Private(BV bv,PetscInt n_,PetscScalar *A,PetscScalar alpha)BVScale_BLAS_Private285,10125 #undef __FUNCT____FUNCT__301,10617 #define __FUNCT__ __FUNCT__302,10634 PetscErrorCode BVNorm_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,const PetscScalar *A,NormType type,PetscReal *nrm,PetscBool mpi)BVNorm_LAPACK_Private306,10718 #undef __FUNCT____FUNCT__358,12771 #define __FUNCT__ __FUNCT__359,12788 PetscErrorCode BVOrthogonalize_LAPACK_Private(BV bv,PetscInt m_,PetscInt n_,PetscScalar *Q,PetscScalar *R,PetscBool mpi)BVOrthogonalize_LAPACK_Private363,12883 src/sys/classes/bv/interface/bvfunc.c,7380 bvfunc.c:^?bvfunc.c^A,1 PetscClassId BV_CLASSID = 0;BV_CLASSID26,1052 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_Create27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_Copy27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_Mult27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_MultVec27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_MultInPlace27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_Dot27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_DotVec27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_Orthogonalize27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_OrthogonalizeVec27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_Scale27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_Norm27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_NormVec27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_SetRandom27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_MatMult27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_MatMultVec27,1085 PetscLogEvent BV_Create = 0,BV_Copy = 0,BV_Mult = 0,BV_MultVec = 0,BV_MultInPlace = 0,BV_Dot = 0,BV_DotVec = 0,BV_Orthogonalize = 0,BV_OrthogonalizeVec = 0,BV_Scale = 0,BV_Norm = 0,BV_NormVec = 0,BV_SetRandom = 0,BV_MatMult = 0,BV_MatMultVec = 0,BV_MatProject = 0;BV_MatProject27,1085 static PetscBool BVPackageInitialized = PETSC_FALSE;BVPackageInitialized28,1353 const char *BVOrthogTypes[] = {"CGS","MGS","BVOrthogType","BV_ORTHOG_",0};BVOrthogTypes30,1407 const char *BVOrthogRefineTypes[] = {"IFNEEDED","NEVER","ALWAYS","BVOrthogRefineType","BV_ORTHOG_REFINE_",0};BVOrthogRefineTypes31,1482 const char *BVOrthogBlockTypes[] = {"GS","CHOL","BVOrthogBlockType","BV_ORTHOG_BLOCK_",0};BVOrthogBlockTypes32,1592 const char *BVMatMultTypes[] = {"VECS","MAT","MAT_SAVE","BVMatMultType","BV_MATMULT_",0};BVMatMultTypes33,1683 #undef __FUNCT____FUNCT__35,1774 #define __FUNCT__ __FUNCT__36,1791 PetscErrorCode BVFinalizePackage(void)BVFinalizePackage45,2023 #undef __FUNCT____FUNCT__56,2273 #define __FUNCT__ __FUNCT__57,2290 PetscErrorCode BVInitializePackage(void)BVInitializePackage67,2614 #undef __FUNCT____FUNCT__118,5085 #define __FUNCT__ __FUNCT__119,5102 PetscErrorCode BVDestroy(BV *bv)BVDestroy132,5327 #undef __FUNCT____FUNCT__155,6217 #define __FUNCT__ __FUNCT__156,6234 PetscErrorCode BVCreate(MPI_Comm comm,BV *newbv)BVCreate172,6523 #undef __FUNCT____FUNCT__228,7968 #define __FUNCT__ __FUNCT__229,7985 PetscErrorCode BVInsertVec(BV V,PetscInt j,Vec w)BVInsertVec244,8271 #undef __FUNCT____FUNCT__270,9282 #define __FUNCT__ __FUNCT__271,9299 PetscErrorCode BVInsertVecs(BV V,PetscInt s,PetscInt *m,Vec *W,PetscBool orth)BVInsertVecs297,10100 #undef __FUNCT____FUNCT__345,12028 #define __FUNCT__ __FUNCT__346,12045 PetscErrorCode BVInsertConstraints(BV V,PetscInt *nc,Vec *C)BVInsertConstraints382,13418 #undef __FUNCT____FUNCT__412,14548 #define __FUNCT__ __FUNCT__413,14565 PetscErrorCode BVSetOptionsPrefix(BV bv,const char *prefix)BVSetOptionsPrefix433,15106 #undef __FUNCT____FUNCT__443,15364 #define __FUNCT__ __FUNCT__444,15381 PetscErrorCode BVAppendOptionsPrefix(BV bv,const char *prefix)BVAppendOptionsPrefix464,15931 #undef __FUNCT____FUNCT__474,16195 #define __FUNCT__ __FUNCT__475,16212 PetscErrorCode BVGetOptionsPrefix(BV bv,const char *prefix[])BVGetOptionsPrefix496,16712 #undef __FUNCT____FUNCT__507,17003 #define __FUNCT__ __FUNCT__508,17020 static PetscErrorCode BVView_Default(BV bv,PetscViewer viewer)BVView_Default509,17055 #undef __FUNCT____FUNCT__540,18150 #define __FUNCT__ __FUNCT__541,18167 PetscErrorCode BVView(BV bv,PetscViewer viewer)BVView566,18858 #undef __FUNCT____FUNCT__638,22286 #define __FUNCT__ __FUNCT__639,22303 PetscErrorCode BVRegister(const char *name,PetscErrorCode (*function)(BV))BVRegister657,22678 #undef __FUNCT____FUNCT__666,22898 #define __FUNCT__ __FUNCT__667,22915 PetscErrorCode BVAllocateWork_Private(BV bv,PetscInt s)BVAllocateWork_Private668,22958 src/sys/classes/bv/interface/bvglobal.c,4029 bvglobal.c:^?bvglobal.c^A,1 #undef __FUNCT____FUNCT__26,1034 #define __FUNCT__ __FUNCT__27,1051 PETSC_STATIC_INLINE PetscErrorCode BVDot_Private(BV X,BV Y,Mat M)BVDot_Private32,1226 #undef __FUNCT____FUNCT__62,2176 #define __FUNCT__ __FUNCT__63,2193 PetscErrorCode BVDot(BV X,BV Y,Mat M)BVDot96,3327 #undef __FUNCT____FUNCT__143,5183 #define __FUNCT__ __FUNCT__144,5200 PetscErrorCode BVDotVec(BV X,Vec y,PetscScalar *m)BVDotVec174,6110 #undef __FUNCT____FUNCT__196,6782 #define __FUNCT__ __FUNCT__197,6799 PetscErrorCode BVDotVecBegin(BV X,Vec y,PetscScalar *m)BVDotVecBegin213,7166 #undef __FUNCT____FUNCT__253,8591 #define __FUNCT__ __FUNCT__254,8608 PetscErrorCode BVDotVecEnd(BV X,Vec y,PetscScalar *m)BVDotVecEnd270,8957 #undef __FUNCT____FUNCT__305,10298 #define __FUNCT__ __FUNCT__306,10315 PetscErrorCode BVDotColumn(BV X,PetscInt j,PetscScalar *m)BVDotColumn332,11123 #undef __FUNCT____FUNCT__358,11980 #define __FUNCT__ __FUNCT__359,11997 PetscErrorCode BVDotColumnBegin(BV X,PetscInt j,PetscScalar *m)BVDotColumnBegin375,12390 #undef __FUNCT____FUNCT__419,14005 #define __FUNCT__ __FUNCT__420,14022 PetscErrorCode BVDotColumnEnd(BV X,PetscInt j,PetscScalar *m)BVDotColumnEnd436,14398 #undef __FUNCT____FUNCT__481,16199 #define __FUNCT__ __FUNCT__482,16216 PETSC_STATIC_INLINE PetscErrorCode BVNorm_Private(BV bv,Vec z,NormType type,PetscReal *val)BVNorm_Private483,16251 #undef __FUNCT____FUNCT__495,16573 #define __FUNCT__ __FUNCT__496,16590 PETSC_STATIC_INLINE PetscErrorCode BVNorm_Begin_Private(BV bv,Vec z,NormType type,PetscReal *val)BVNorm_Begin_Private497,16631 #undef __FUNCT____FUNCT__508,16918 #define __FUNCT__ __FUNCT__509,16935 PETSC_STATIC_INLINE PetscErrorCode BVNorm_End_Private(BV bv,Vec z,NormType type,PetscReal *val)BVNorm_End_Private510,16974 #undef __FUNCT____FUNCT__521,17260 #define __FUNCT__ __FUNCT__522,17277 PetscErrorCode BVNorm(BV bv,NormType type,PetscReal *val)BVNorm546,17846 #undef __FUNCT____FUNCT__566,18589 #define __FUNCT__ __FUNCT__567,18606 PetscErrorCode BVNormVec(BV bv,Vec v,NormType type,PetscReal *val)BVNormVec591,19233 #undef __FUNCT____FUNCT__620,20238 #define __FUNCT__ __FUNCT__621,20255 PetscErrorCode BVNormVecBegin(BV bv,Vec v,NormType type,PetscReal *val)BVNormVecBegin638,20617 #undef __FUNCT____FUNCT__667,21645 #define __FUNCT__ __FUNCT__668,21662 PetscErrorCode BVNormVecEnd(BV bv,Vec v,NormType type,PetscReal *val)BVNormVecEnd685,22020 #undef __FUNCT____FUNCT__706,22625 #define __FUNCT__ __FUNCT__707,22642 PetscErrorCode BVNormColumn(BV bv,PetscInt j,NormType type,PetscReal *val)BVNormColumn731,23282 #undef __FUNCT____FUNCT__759,24344 #define __FUNCT__ __FUNCT__760,24361 PetscErrorCode BVNormColumnBegin(BV bv,PetscInt j,NormType type,PetscReal *val)BVNormColumnBegin777,24755 #undef __FUNCT____FUNCT__821,26646 #define __FUNCT__ __FUNCT__822,26663 PetscErrorCode BVNormColumnEnd(BV bv,PetscInt j,NormType type,PetscReal *val)BVNormColumnEnd839,27053 #undef __FUNCT____FUNCT__881,28911 #define __FUNCT__ __FUNCT__882,28928 PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Vec(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm)BVMatProject_Vec887,29127 #undef __FUNCT____FUNCT__926,30388 #define __FUNCT__ __FUNCT__927,30405 PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm)BVMatProject_MatMult935,30690 #undef __FUNCT____FUNCT__983,32217 #define __FUNCT__ __FUNCT__984,32234 PETSC_STATIC_INLINE PetscErrorCode BVMatProject_MatMult_2(BV X,Mat A,BV Y,PetscScalar *marray,PetscInt ldm,PetscBool symm)BVMatProject_MatMult_2992,32570 #undef __FUNCT____FUNCT__1049,34436 #define __FUNCT__ __FUNCT__1050,34453 PETSC_STATIC_INLINE PetscErrorCode BVMatProject_Dot(BV X,BV Y,PetscScalar *marray,PetscInt ldm)BVMatProject_Dot1057,34696 #undef __FUNCT____FUNCT__1100,36047 #define __FUNCT__ __FUNCT__1101,36064 PetscErrorCode BVMatProject(BV X,Mat A,BV Y,Mat M)BVMatProject1145,37775 src/sys/classes/bv/interface/bvops.c,1933 bvops.c:^?bvops.c^A,1 #undef __FUNCT____FUNCT__26,1048 #define __FUNCT__ __FUNCT__27,1065 PetscErrorCode BVMult(BV Y,PetscScalar alpha,PetscScalar beta,BV X,Mat Q)BVMult61,2288 #undef __FUNCT____FUNCT__96,3879 #define __FUNCT__ __FUNCT__97,3896 PetscErrorCode BVMultVec(BV X,PetscScalar alpha,PetscScalar beta,Vec y,PetscScalar *q)BVMultVec128,4795 #undef __FUNCT____FUNCT__154,5745 #define __FUNCT__ __FUNCT__155,5762 PetscErrorCode BVMultColumn(BV X,PetscScalar alpha,PetscScalar beta,PetscInt j,PetscScalar *q)BVMultColumn180,6585 #undef __FUNCT____FUNCT__209,7613 #define __FUNCT__ __FUNCT__210,7630 PetscErrorCode BVMultInPlace(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlace237,8475 #undef __FUNCT____FUNCT__268,10041 #define __FUNCT__ __FUNCT__269,10058 PetscErrorCode BVMultInPlaceTranspose(BV V,Mat Q,PetscInt s,PetscInt e)BVMultInPlaceTranspose291,10566 #undef __FUNCT____FUNCT__322,12155 #define __FUNCT__ __FUNCT__323,12172 PetscErrorCode BVScale(BV bv,PetscScalar alpha)BVScale340,12511 #undef __FUNCT____FUNCT__360,13098 #define __FUNCT__ __FUNCT__361,13115 PetscErrorCode BVScaleColumn(BV bv,PetscInt j,PetscScalar alpha)BVScaleColumn376,13411 #undef __FUNCT____FUNCT__399,14218 #define __FUNCT__ __FUNCT__400,14235 PetscErrorCode BVSetRandom(BV bv)BVSetRandom416,14577 #undef __FUNCT____FUNCT__450,15710 #define __FUNCT__ __FUNCT__451,15727 PetscErrorCode BVSetRandomColumn(BV bv,PetscInt j)BVSetRandomColumn465,16034 #undef __FUNCT____FUNCT__499,17325 #define __FUNCT__ __FUNCT__500,17342 PetscErrorCode BVMatMult(BV V,Mat A,BV Y)BVMatMult525,18081 #undef __FUNCT____FUNCT__549,18960 #define __FUNCT__ __FUNCT__550,18977 PetscErrorCode BVMatMultHermitianTranspose(BV V,Mat A,BV Y)BVMatMultHermitianTranspose576,19765 #undef __FUNCT____FUNCT__608,20959 #define __FUNCT__ __FUNCT__609,20976 PetscErrorCode BVMatMultColumn(BV V,Mat A,PetscInt j)BVMatMultColumn628,21370 src/sys/classes/bv/interface/bvorthog.c,2147 bvorthog.c:^?bvorthog.c^A,1 #undef __FUNCT____FUNCT__27,1056 #define __FUNCT__ __FUNCT__28,1073 static PetscErrorCode BVOrthogonalizeMGS1(BV bv,PetscInt k,Vec v,PetscBool *which,PetscScalar *H)BVOrthogonalizeMGS132,1186 #undef __FUNCT____FUNCT__60,1974 #define __FUNCT__ __FUNCT__61,1991 PetscErrorCode BVOrthogonalizeCGS1(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *onorm,PetscReal *norm)BVOrthogonalizeCGS166,2152 #undef __FUNCT____FUNCT__125,3955 #define __FUNCT__ __FUNCT__126,3972 static PetscErrorCode BVOrthogonalizeMGS(BV bv,PetscInt j,Vec v,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep)BVOrthogonalizeMGS130,4081 #undef __FUNCT____FUNCT__197,6130 #define __FUNCT__ __FUNCT__198,6147 static PetscErrorCode BVOrthogonalizeCGS(BV bv,PetscInt j,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep)BVOrthogonalizeCGS202,6257 #undef __FUNCT____FUNCT__253,7883 #define __FUNCT__ __FUNCT__254,7900 PetscErrorCode BVOrthogonalizeVec(BV bv,Vec v,PetscScalar *H,PetscReal *norm,PetscBool *lindep)BVOrthogonalizeVec280,8741 #undef __FUNCT____FUNCT__314,9838 #define __FUNCT__ __FUNCT__315,9855 PetscErrorCode BVOrthogonalizeColumn(BV bv,PetscInt j,PetscScalar *H,PetscReal *norm,PetscBool *lindep)BVOrthogonalizeColumn350,11170 #undef __FUNCT____FUNCT__384,12462 #define __FUNCT__ __FUNCT__385,12479 PetscErrorCode BVOrthogonalizeSomeColumn(BV bv,PetscInt j,PetscBool *which,PetscScalar *H,PetscReal *norm,PetscBool *lindep)BVOrthogonalizeSomeColumn414,13468 #undef __FUNCT____FUNCT__443,14789 #define __FUNCT__ __FUNCT__444,14806 static PetscErrorCode BVOrthogonalize_GS(BV V,Mat R)BVOrthogonalize_GS448,14923 #undef __FUNCT____FUNCT__484,16071 #define __FUNCT__ __FUNCT__485,16088 static PetscErrorCode MatCholeskyFactorInvert(Mat R,PetscInt l,Mat *S)MatCholeskyFactorInvert489,16203 #undef __FUNCT____FUNCT__551,18595 #define __FUNCT__ __FUNCT__552,18612 static PetscErrorCode BVOrthogonalize_Chol(BV V,Mat Rin)BVOrthogonalize_Chol556,18734 #undef __FUNCT____FUNCT__575,19238 #define __FUNCT__ __FUNCT__576,19255 PetscErrorCode BVOrthogonalize(BV V,Mat R)BVOrthogonalize614,20708 src/sys/classes/bv/interface/bvregis.c,129 bvregis.c:^?bvregis.c^A,1 #undef __FUNCT____FUNCT__29,1186 #define __FUNCT__ __FUNCT__30,1203 PetscErrorCode BVRegisterAll(void)BVRegisterAll40,1385 src/sys/classes/bv/interface/ftn-custom/makefile,267 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zbvf.cSOURCEC26,996 SOURCEF =SOURCEF27,1014 SOURCEH =SOURCEH28,1025 DIRS =DIRS29,1036 LIBBASE = libslepcsysLIBBASE30,1047 LOCDIR = src/sys/classes/bv/interface/ftn-custom/LOCDIR31,1070 src/sys/classes/bv/interface/ftn-custom/zbvf.c,1452 zbvf.c:^?zbvf.c^A,1 PETSC_EXTERN void PETSC_STDCALL bvsettype_(BV *bv,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))bvsettype_41,1658 PETSC_EXTERN void PETSC_STDCALL bvgettype_(BV *bv,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))bvgettype_50,1868 PETSC_EXTERN void PETSC_STDCALL bvsetoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))bvsetoptionsprefix_59,2142 PETSC_EXTERN void PETSC_STDCALL bvappendoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))bvappendoptionsprefix_68,2376 PETSC_EXTERN void PETSC_STDCALL bvgetoptionsprefix_(BV *bv,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))bvgetoptionsprefix_77,2616 PETSC_EXTERN void PETSC_STDCALL bvview_(BV *bv,PetscViewer *viewer,PetscErrorCode *ierr)bvview_86,2919 src/sys/classes/bv/interface/makefile,346 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = bvbasic.c bvfunc.c bvops.c bvglobal.c bvblas.c bvorthog.c bvregis.cSOURCEC26,958 SOURCEF =SOURCEF27,1037 SOURCEH =SOURCEH28,1048 LIBBASE = libslepcsysLIBBASE29,1059 DIRS =DIRS30,1082 MANSEC = BVMANSEC31,1093 LOCDIR = src/sys/classes/bv/interface/LOCDIR32,1107 src/sys/classes/bv/makefile,223 makefile:^?makefile^A,1 SOURCEH = ../../../../include/slepc/private/bvimpl.h ../../../../include/slepcbv.hSOURCEH24,936 DIRS = interface impls examplesDIRS25,1020 LOCDIR = src/sys/classes/bv/LOCDIR26,1056 MANSEC = BVMANSEC27,1087 src/sys/classes/ds/examples/makefile,83 makefile:^?makefile^A,1 LOCDIR = src/sys/classes/ds/examples/LOCDIR24,932 DIRS = testsDIRS25,972 src/sys/classes/ds/examples/tests/makefile,721 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/sys/classes/ds/examples/tests/LOCDIR26,978 EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.c test9.c \EXAMPLESC27,1026 EXAMPLESF = test14f.FEXAMPLESF29,1153 MANSEC = DSMANSEC30,1176 TESTS = test1 test2 test3 test4 test5 test6 test7 test8 test9 test12 test13 \TESTS31,1192 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \TESTEXAMPLES_C34,1304 TESTEXAMPLES_C_NOCOMPLEX = test13.PETSc runtest13_1 test13.rmTESTEXAMPLES_C_NOCOMPLEX45,1979 TESTEXAMPLES_FORTRAN = test14f.PETSc runtest14f_1 test14f.rmTESTEXAMPLES_FORTRAN46,2041 src/sys/classes/ds/examples/tests/test1.c,168 test1.c:^?test1.c^A,1 static char help[] = "Test DSNHEP.\n\n";help22,924 #undef __FUNCT____FUNCT__26,988 #define __FUNCT__ __FUNCT__27,1005 int main(int argc,char **argv)main28,1030 src/sys/classes/ds/examples/tests/test12.c,167 test12.c:^?test12.c^A,1 static char help[] = "Test DSNEP.\n\n";help22,924 #undef __FUNCT____FUNCT__26,987 #define __FUNCT__ __FUNCT__27,1004 int main(int argc,char **argv)main28,1029 src/sys/classes/ds/examples/tests/test13.c,200 test13.c:^?test13.c^A,1 static char help[] = "Test DSHEP with block size larger than one.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1019 #define __FUNCT__ __FUNCT__27,1036 int main(int argc,char **argv)main28,1061 src/sys/classes/ds/examples/tests/test14f.F,338 test14f.F:^?test14f.F^A,1 program mainmain29,1233 100 format (/'Program currently limited to n=100, you set n=',I3)10070,2457 110 format (/'Solve a Dense System of type NHEP, n =',I3,' (Fortran)')11075,2589 120 format (' ',F8.5)120124,4258 130 format (' ',F8.5,SP,F8.5,'i')130125,4283 subroutine FillUpMatrix(FillUpMatrix134,4481 src/sys/classes/ds/examples/tests/test15.c,167 test15.c:^?test15.c^A,1 static char help[] = "Test DSPEP.\n\n";help22,924 #undef __FUNCT____FUNCT__26,987 #define __FUNCT__ __FUNCT__27,1004 int main(int argc,char **argv)main28,1029 src/sys/classes/ds/examples/tests/test2.c,167 test2.c:^?test2.c^A,1 static char help[] = "Test DSHEP.\n\n";help22,924 #undef __FUNCT____FUNCT__26,987 #define __FUNCT__ __FUNCT__27,1004 int main(int argc,char **argv)main28,1029 src/sys/classes/ds/examples/tests/test3.c,189 test3.c:^?test3.c^A,1 static char help[] = "Test DSHEP with compact storage.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1008 #define __FUNCT__ __FUNCT__27,1025 int main(int argc,char **argv)main28,1050 src/sys/classes/ds/examples/tests/test4.c,169 test4.c:^?test4.c^A,1 static char help[] = "Test DSGNHEP.\n\n";help22,924 #undef __FUNCT____FUNCT__26,989 #define __FUNCT__ __FUNCT__27,1006 int main(int argc,char **argv)main28,1031 src/sys/classes/ds/examples/tests/test5.c,169 test5.c:^?test5.c^A,1 static char help[] = "Test DSGHIEP.\n\n";help22,924 #undef __FUNCT____FUNCT__26,989 #define __FUNCT__ __FUNCT__27,1006 int main(int argc,char **argv)main28,1031 src/sys/classes/ds/examples/tests/test6.c,191 test6.c:^?test6.c^A,1 static char help[] = "Test DSGHIEP with compact storage.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1010 #define __FUNCT__ __FUNCT__27,1027 int main(int argc,char **argv)main28,1052 src/sys/classes/ds/examples/tests/test7.c,167 test7.c:^?test7.c^A,1 static char help[] = "Test DSSVD.\n\n";help22,924 #undef __FUNCT____FUNCT__26,987 #define __FUNCT__ __FUNCT__27,1004 int main(int argc,char **argv)main28,1029 src/sys/classes/ds/examples/tests/test8.c,189 test8.c:^?test8.c^A,1 static char help[] = "Test DSSVD with compact storage.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1008 #define __FUNCT__ __FUNCT__27,1025 int main(int argc,char **argv)main28,1050 src/sys/classes/ds/examples/tests/test9.c,168 test9.c:^?test9.c^A,1 static char help[] = "Test DSGHEP.\n\n";help22,924 #undef __FUNCT____FUNCT__26,988 #define __FUNCT__ __FUNCT__27,1005 int main(int argc,char **argv)main28,1030 src/sys/classes/ds/impls/ghep/dsghep.c,1142 dsghep.c:^?dsghep.c^A,1 #undef __FUNCT____FUNCT__25,988 #define __FUNCT__ __FUNCT__26,1005 PetscErrorCode DSAllocate_GHEP(DS ds,PetscInt ld)DSAllocate_GHEP27,1041 #undef __FUNCT____FUNCT__41,1522 #define __FUNCT__ __FUNCT__42,1539 PetscErrorCode DSView_GHEP(DS ds,PetscViewer viewer)DSView_GHEP43,1571 #undef __FUNCT____FUNCT__56,1910 #define __FUNCT__ __FUNCT__57,1927 PetscErrorCode DSVectors_GHEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)DSVectors_GHEP58,1962 #undef __FUNCT____FUNCT__95,3220 #define __FUNCT__ __FUNCT__96,3237 PetscErrorCode DSNormalize_GHEP(DS ds,DSMatType mat,PetscInt col)DSNormalize_GHEP97,3274 #undef __FUNCT____FUNCT__135,4341 #define __FUNCT__ __FUNCT__136,4358 PetscErrorCode DSSort_GHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_GHEP137,4390 #undef __FUNCT____FUNCT__161,5129 #define __FUNCT__ __FUNCT__162,5146 PetscErrorCode DSSolve_GHEP(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_GHEP163,5179 #undef __FUNCT____FUNCT__220,7366 #define __FUNCT__ __FUNCT__221,7383 PETSC_EXTERN PetscErrorCode DSCreate_GHEP(DS ds)DSCreate_GHEP222,7417 src/sys/classes/ds/impls/ghep/makefile,286 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dsghep.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsysLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = DSMANSEC31,1034 LOCDIR = src/sys/classes/ds/impls/ghep/LOCDIR32,1048 src/sys/classes/ds/impls/ghiep/dqds.c,1913 dqds.c:^?dqds.c^A,1 #undef __FUNCT____FUNCT__35,1379 #define __FUNCT__ __FUNCT__36,1396 static PetscErrorCode ScanJ(PetscInt n,PetscReal *a,PetscReal *b,PetscReal *gl,PetscReal *gr,PetscReal *sigma)ScanJ48,1644 #undef __FUNCT____FUNCT__84,2667 #define __FUNCT__ __FUNCT__85,2684 static PetscErrorCode Prologue(PetscInt n,PetscReal *a,PetscReal *b,PetscReal gl,PetscReal gr,PetscInt *m,PetscReal *shift,PetscReal *work)Prologue99,3133 #undef __FUNCT____FUNCT__161,4983 #define __FUNCT__ __FUNCT__162,5000 static PetscErrorCode LUfac(PetscInt n,PetscReal *a,PetscReal *b,PetscReal shift,PetscReal tol,PetscReal norm,PetscReal *L,PetscReal *U,PetscInt *fail,PetscReal *work)LUfac163,5026 #undef __FUNCT____FUNCT__194,5920 #define __FUNCT__ __FUNCT__195,5937 static PetscErrorCode RealDQDS(PetscInt n,PetscReal *L,PetscReal *U,PetscReal shift,PetscReal tol,PetscReal norm,PetscReal *L1,PetscReal *U1,PetscInt *fail)RealDQDS196,5966 #undef __FUNCT____FUNCT__225,6783 #define __FUNCT__ __FUNCT__226,6800 static PetscErrorCode TridqdsZhuang3(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscInt *fail)TridqdsZhuang3227,6835 #undef __FUNCT____FUNCT__303,8932 #define __FUNCT__ __FUNCT__304,8949 static PetscErrorCode TridqdsZhuang(PetscInt n,PetscReal *e,PetscReal *q,PetscReal sum,PetscReal prod,PetscReal tol,PetscReal norm,PetscReal tolDef,PetscReal *e1,PetscReal *q1,PetscInt *fail)TridqdsZhuang305,8983 #undef __FUNCT____FUNCT__444,12835 #define __FUNCT__ __FUNCT__445,12852 static PetscErrorCode DSGHIEP_Eigen3DQDS(PetscInt n,PetscReal *a,PetscReal *b,PetscReal *c,PetscScalar *wr,PetscScalar *wi,PetscReal *work)DSGHIEP_Eigen3DQDS446,12891 #undef __FUNCT____FUNCT__741,24996 #define __FUNCT__ __FUNCT__742,25013 PetscErrorCode DSSolve_GHIEP_DQDS_II(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_GHIEP_DQDS_II743,25055 src/sys/classes/ds/impls/ghiep/dsghiep.c,2258 dsghiep.c:^?dsghiep.c^A,1 #undef __FUNCT____FUNCT__24,987 #define __FUNCT__ __FUNCT__25,1004 PetscErrorCode DSAllocate_GHIEP(DS ds,PetscInt ld)DSAllocate_GHIEP26,1041 #undef __FUNCT____FUNCT__42,1649 #define __FUNCT__ __FUNCT__43,1666 PetscErrorCode DSSwitchFormat_GHIEP(DS ds,PetscBool tocompact)DSSwitchFormat_GHIEP44,1707 #undef __FUNCT____FUNCT__88,3071 #define __FUNCT__ __FUNCT__89,3088 PetscErrorCode DSView_GHIEP(DS ds,PetscViewer viewer)DSView_GHIEP90,3121 #undef __FUNCT____FUNCT__179,7255 #define __FUNCT__ __FUNCT__180,7272 static PetscErrorCode DSVectors_GHIEP_Eigen_Some(DS ds,PetscInt *idx,PetscReal *rnorm)DSVectors_GHIEP_Eigen_Some181,7319 #undef __FUNCT____FUNCT__280,11094 #define __FUNCT__ __FUNCT__281,11111 PetscErrorCode DSVectors_GHIEP(DS ds,DSMatType mat,PetscInt *k,PetscReal *rnorm)DSVectors_GHIEP282,11147 #undef __FUNCT____FUNCT__320,12409 #define __FUNCT__ __FUNCT__321,12426 PetscErrorCode DSGHIEPComplexEigs(DS ds,PetscInt n0,PetscInt n1,PetscScalar *wr,PetscScalar *wi)DSGHIEPComplexEigs326,12600 #undef __FUNCT____FUNCT__406,14823 #define __FUNCT__ __FUNCT__407,14840 PetscErrorCode DSSort_GHIEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_GHIEP408,14873 #undef __FUNCT____FUNCT__451,16475 #define __FUNCT__ __FUNCT__452,16492 PetscErrorCode DSGHIEPInverseIteration(DS ds,PetscScalar *wr,PetscScalar *wi)DSGHIEPInverseIteration457,16628 #undef __FUNCT____FUNCT__537,19541 #define __FUNCT__ __FUNCT__538,19558 PetscErrorCode DSGHIEPRealBlocks(DS ds)DSGHIEPRealBlocks542,19649 #undef __FUNCT____FUNCT__662,23938 #define __FUNCT__ __FUNCT__663,23955 PetscErrorCode DSSolve_GHIEP_QR_II(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_GHIEP_QR_II664,23995 #undef __FUNCT____FUNCT__773,27615 #define __FUNCT__ __FUNCT__774,27632 PetscErrorCode DSSolve_GHIEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_GHIEP_QR775,27669 #undef __FUNCT____FUNCT__911,32304 #define __FUNCT__ __FUNCT__912,32321 PetscErrorCode DSNormalize_GHIEP(DS ds,DSMatType mat,PetscInt col)DSNormalize_GHIEP913,32359 #undef __FUNCT____FUNCT__968,33909 #define __FUNCT__ __FUNCT__969,33926 PETSC_EXTERN PetscErrorCode DSCreate_GHIEP(DS ds)DSCreate_GHIEP970,33961 src/sys/classes/ds/impls/ghiep/hz.c,907 hz.c:^?hz.c^A,1 #undef __FUNCT____FUNCT__36,1453 #define __FUNCT__ __FUNCT__37,1470 static PetscErrorCode UnifiedRotation(PetscReal x,PetscReal y,PetscReal sygn,PetscReal *rot,PetscReal *rcond,PetscBool *swap)UnifiedRotation42,1646 #undef __FUNCT____FUNCT__77,2898 #define __FUNCT__ __FUNCT__78,2915 static PetscErrorCode HZStep(PetscBLASInt ntop,PetscBLASInt nn,PetscReal tr,PetscReal dt,PetscReal *aa,PetscReal *bb,PetscReal *dd,PetscScalar *uu,PetscInt n,PetscInt ld,PetscBool *flag)HZStep79,2942 #undef __FUNCT____FUNCT__236,9164 #define __FUNCT__ __FUNCT__237,9181 static PetscErrorCode HZIteration(PetscBLASInt nn,PetscBLASInt cgd,PetscReal *aa,PetscReal *bb,PetscReal *dd,PetscScalar *uu,PetscBLASInt ld)HZIteration238,9213 #undef __FUNCT____FUNCT__304,11601 #define __FUNCT__ __FUNCT__305,11618 PetscErrorCode DSSolve_GHIEP_HZ(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_GHIEP_HZ306,11655 src/sys/classes/ds/impls/ghiep/invit.c,2343 invit.c:^?invit.c^A,1 struct HRtrHRtr25,988 PetscScalar *data;data27,1002 PetscInt m;m28,1023 PetscInt idx[2];idx29,1040 PetscInt n[2];n30,1062 PetscScalar tau[2];tau31,1082 PetscReal alpha;alpha32,1104 PetscReal cs;cs33,1125 PetscReal sn;sn34,1143 PetscInt type;type35,1161 #undef __FUNCT____FUNCT__38,1185 #define __FUNCT__ __FUNCT__39,1202 static PetscErrorCode HRGen(PetscReal x1,PetscReal x2,PetscInt *type,PetscReal *c,PetscReal *s,PetscReal *r,PetscReal *cond)HRGen51,1501 #undef __FUNCT____FUNCT__90,2489 #define __FUNCT__ __FUNCT__91,2506 static PetscErrorCode HRApply(PetscInt n,PetscScalar *x1,PetscInt inc1,PetscScalar *x2,PetscInt inc2,PetscReal c,PetscReal s)HRApply98,2654 #undef __FUNCT____FUNCT__122,3265 #define __FUNCT__ __FUNCT__123,3282 static PetscErrorCode TridiagDiag_HHR(PetscInt n,PetscScalar *A,PetscInt lda,PetscReal *s,PetscScalar* Q,PetscInt ldq,PetscBool flip,PetscReal *d,PetscReal *e,PetscInt *perm_,PetscScalar *work,PetscReal *rwork,PetscBLASInt *iwork)TridiagDiag_HHR135,3609 #undef __FUNCT____FUNCT__309,9510 #define __FUNCT__ __FUNCT__310,9527 static PetscErrorCode MadeHRtr(PetscInt sz,PetscInt n,PetscInt idx0,PetscInt n0,PetscInt idx1,PetscInt n1,struct HRtr *tr1,struct HRtr *tr2,PetscReal *ncond,PetscScalar *work)MadeHRtr311,9556 #undef __FUNCT____FUNCT__391,12697 #define __FUNCT__ __FUNCT__392,12714 static PetscErrorCode TryHRIt(PetscInt n,PetscInt j,PetscInt sz,PetscScalar *H,PetscInt ldh,PetscScalar *R,PetscInt ldr,PetscReal *s,PetscBool *exg,PetscBool *ok,PetscInt *n0,PetscInt *n1,PetscInt *idx0,PetscInt *idx1,PetscReal *cond,PetscScalar *work)TryHRIt399,13001 #undef __FUNCT____FUNCT__547,19249 #define __FUNCT__ __FUNCT__548,19266 static PetscErrorCode PseudoOrthog_HR(PetscInt *nv,PetscScalar *V,PetscInt ldv,PetscReal *s,PetscScalar *R,PetscInt ldr,PetscBLASInt *perm,PetscBLASInt *cmplxEig,PetscBool *breakdown,PetscScalar *work)PseudoOrthog_HR552,19368 #undef __FUNCT____FUNCT__646,22296 #define __FUNCT__ __FUNCT__647,22313 PetscErrorCode DSGHIEPOrthogEigenv(DS ds,DSMatType mat,PetscScalar *wr,PetscScalar *wi,PetscBool accum)DSGHIEPOrthogEigenv648,22353 #undef __FUNCT____FUNCT__744,25460 #define __FUNCT__ __FUNCT__745,25477 PetscErrorCode DSIntermediate_GHIEP(DS ds)DSIntermediate_GHIEP749,25592 src/sys/classes/ds/impls/ghiep/makefile,309 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dsghiep.c invit.c hz.c dqds.cSOURCEC26,958 SOURCEF =SOURCEF27,999 SOURCEH =SOURCEH28,1010 LIBBASE = libslepcsysLIBBASE29,1021 DIRS =DIRS30,1044 MANSEC = DSMANSEC31,1055 LOCDIR = src/sys/classes/ds/impls/ghiep/LOCDIR32,1069 src/sys/classes/ds/impls/gnhep/dsgnhep.c,2272 dsgnhep.c:^?dsgnhep.c^A,1 #undef __FUNCT____FUNCT__44,1750 #define __FUNCT__ __FUNCT__45,1767 PetscErrorCode DSAllocate_GNHEP(DS ds,PetscInt ld)DSAllocate_GNHEP46,1804 #undef __FUNCT____FUNCT__61,2345 #define __FUNCT__ __FUNCT__62,2362 PetscErrorCode DSView_GNHEP(DS ds,PetscViewer viewer)DSView_GNHEP63,2395 #undef __FUNCT____FUNCT__83,2965 #define __FUNCT__ __FUNCT__84,2982 static PetscErrorCode DSVectors_GNHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)DSVectors_GNHEP_Eigen_Some85,3029 #undef __FUNCT____FUNCT__165,6040 #define __FUNCT__ __FUNCT__166,6057 static PetscErrorCode DSVectors_GNHEP_Eigen_All(DS ds,PetscBool left)DSVectors_GNHEP_Eigen_All167,6103 #undef __FUNCT____FUNCT__237,8562 #define __FUNCT__ __FUNCT__238,8579 PetscErrorCode DSVectors_GNHEP(DS ds,DSMatType mat,PetscInt *k,PetscReal *rnorm)DSVectors_GNHEP239,8615 #undef __FUNCT____FUNCT__259,9201 #define __FUNCT__ __FUNCT__260,9218 PetscErrorCode DSNormalize_GNHEP(DS ds,DSMatType mat,PetscInt col)DSNormalize_GNHEP261,9256 #undef __FUNCT____FUNCT__317,10922 #define __FUNCT__ __FUNCT__318,10939 static PetscErrorCode DSSort_GNHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_GNHEP_Arbitrary319,10982 #undef __FUNCT____FUNCT__370,13080 #define __FUNCT__ __FUNCT__371,13097 static PetscErrorCode DSSort_GNHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi)DSSort_GNHEP_Total372,13136 #undef __FUNCT____FUNCT__469,16436 #define __FUNCT__ __FUNCT__470,16453 PetscErrorCode DSSort_GNHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_GNHEP471,16486 #undef __FUNCT____FUNCT__484,16836 #define __FUNCT__ __FUNCT__485,16853 static PetscErrorCode CleanDenseSchur(PetscInt n,PetscInt k,PetscScalar *S,PetscInt ldS,PetscScalar *T,PetscInt ldT,PetscScalar *X,PetscInt ldX,PetscScalar *Y,PetscInt ldY,PetscBool doProd)CleanDenseSchur491,17083 #undef __FUNCT____FUNCT__586,20946 #define __FUNCT__ __FUNCT__587,20963 PetscErrorCode DSSolve_GNHEP(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_GNHEP588,20997 #undef __FUNCT____FUNCT__639,23161 #define __FUNCT__ __FUNCT__640,23178 PETSC_EXTERN PetscErrorCode DSCreate_GNHEP(DS ds)DSCreate_GNHEP641,23213 src/sys/classes/ds/impls/gnhep/makefile,288 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dsgnhep.cSOURCEC26,958 SOURCEF =SOURCEF27,979 SOURCEH =SOURCEH28,990 LIBBASE = libslepcsysLIBBASE29,1001 DIRS =DIRS30,1024 MANSEC = DSMANSEC31,1035 LOCDIR = src/sys/classes/ds/impls/gnhep/LOCDIR32,1049 src/sys/classes/ds/impls/hep/bdc/dibtdc.c,200 dibtdc.c:^?dibtdc.c^A,1 static PetscErrorCode cutlr_(PetscBLASInt start,PetscBLASInt n,PetscBLASInt blkct, cutlr_27,1057 PetscErrorCode BDC_dibtdc_(const char *jobz,PetscBLASInt n,PetscBLASInt nblks, BDC_dibtdc_183,5951 src/sys/classes/ds/impls/hep/bdc/dlaed3m.c,114 dlaed3m.c:^?dlaed3m.c^A,1 PetscErrorCode BDC_dlaed3m_(const char *jobz,const char *defl,PetscBLASInt k,PetscBLASInt n,BDC_dlaed3m_27,1057 src/sys/classes/ds/impls/hep/bdc/dmerg2.c,99 dmerg2.c:^?dmerg2.c^A,1 PetscErrorCode BDC_dmerg2_(const char *jobz,PetscBLASInt rkct,PetscBLASInt n, BDC_dmerg2_27,1057 src/sys/classes/ds/impls/hep/bdc/dsbtdc.c,133 dsbtdc.c:^?dsbtdc.c^A,1 PetscErrorCode BDC_dsbtdc_(const char *jobz,const char *jobacc,PetscBLASInt n, BDC_dsbtdc_27,1057 #define TOLMAX TOLMAX264,13701 src/sys/classes/ds/impls/hep/bdc/dsrtdf.c,96 dsrtdf.c:^?dsrtdf.c^A,1 PetscErrorCode BDC_dsrtdf_(PetscBLASInt *k,PetscBLASInt n,PetscBLASInt n1, BDC_dsrtdf_27,1057 src/sys/classes/ds/impls/hep/bdc/makefile,328 makefile:^?makefile^A,1 CFLAGS =CFLAGS26,961 FFLAGS =FFLAGS27,972 SOURCEC = dibtdc.c dlaed3m.c dmerg2.c dsbtdc.c dsrtdf.cSOURCEC28,983 SOURCEF =SOURCEF29,1040 SOURCEH =SOURCEH30,1051 LIBBASE = libslepcsysLIBBASE31,1062 DIRS =DIRS32,1085 MANSEC = DSMANSEC33,1096 LOCDIR = src/sys/classes/ds/impls/hep/bdc/LOCDIR34,1110 src/sys/classes/ds/impls/hep/dshep.c,2802 dshep.c:^?dshep.c^A,1 #undef __FUNCT____FUNCT__25,988 #define __FUNCT__ __FUNCT__26,1005 PetscErrorCode DSAllocate_HEP(DS ds,PetscInt ld)DSAllocate_HEP27,1040 #undef __FUNCT____FUNCT__66,2587 #define __FUNCT__ __FUNCT__67,2604 static PetscErrorCode DSSwitchFormat_HEP(DS ds,PetscBool tocompact)DSSwitchFormat_HEP68,2643 #undef __FUNCT____FUNCT__106,3820 #define __FUNCT__ __FUNCT__107,3837 PetscErrorCode DSView_HEP(DS ds,PetscViewer viewer)DSView_HEP108,3868 #undef __FUNCT____FUNCT__178,7001 #define __FUNCT__ __FUNCT__179,7018 PetscErrorCode DSVectors_HEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)DSVectors_HEP180,7052 #undef __FUNCT____FUNCT__217,8301 #define __FUNCT__ __FUNCT__218,8318 PetscErrorCode DSNormalize_HEP(DS ds,DSMatType mat,PetscInt col)DSNormalize_HEP219,8354 #undef __FUNCT____FUNCT__238,8883 #define __FUNCT__ __FUNCT__239,8900 static PetscErrorCode ArrowTridiag(PetscBLASInt n,PetscReal *d,PetscReal *e,PetscScalar *Q,PetscBLASInt ld)ArrowTridiag287,10322 #undef __FUNCT____FUNCT__336,11732 #define __FUNCT__ __FUNCT__337,11749 static PetscErrorCode DSIntermediate_HEP(DS ds)DSIntermediate_HEP341,11850 #undef __FUNCT____FUNCT__396,13878 #define __FUNCT__ __FUNCT__397,13895 PetscErrorCode DSSort_HEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_HEP398,13926 #undef __FUNCT____FUNCT__426,14730 #define __FUNCT__ __FUNCT__427,14747 PetscErrorCode DSUpdateExtraRow_HEP(DS ds)DSUpdateExtraRow_HEP428,14788 #undef __FUNCT____FUNCT__459,15729 #define __FUNCT__ __FUNCT__460,15746 PetscErrorCode DSSolve_HEP_QR(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_HEP_QR461,15781 #undef __FUNCT____FUNCT__514,17557 #define __FUNCT__ __FUNCT__515,17574 PetscErrorCode DSSolve_HEP_MRRR(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_HEP_MRRR516,17611 #undef __FUNCT____FUNCT__599,20702 #define __FUNCT__ __FUNCT__600,20719 PetscErrorCode DSSolve_HEP_DC(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_HEP_DC601,20754 #undef __FUNCT____FUNCT__667,22935 #define __FUNCT__ __FUNCT__668,22952 PetscErrorCode DSSolve_HEP_BDC(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_HEP_BDC669,22988 #undef __FUNCT____FUNCT__736,25165 #define __FUNCT__ __FUNCT__737,25182 PetscErrorCode DSTruncate_HEP(DS ds,PetscInt n)DSTruncate_HEP738,25217 #undef __FUNCT____FUNCT__755,25624 #define __FUNCT__ __FUNCT__756,25641 PetscErrorCode DSCond_HEP(DS ds,PetscReal *cond)DSCond_HEP757,25672 #undef __FUNCT____FUNCT__801,27214 #define __FUNCT__ __FUNCT__802,27231 PetscErrorCode DSTranslateRKS_HEP(DS ds,PetscScalar alpha)DSTranslateRKS_HEP803,27270 #undef __FUNCT____FUNCT__855,29200 #define __FUNCT__ __FUNCT__856,29217 PETSC_EXTERN PetscErrorCode DSCreate_HEP(DS ds)DSCreate_HEP857,29250 src/sys/classes/ds/impls/hep/makefile,287 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dshep.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS = bdcDIRS30,1022 MANSEC = DSMANSEC31,1037 LOCDIR = src/sys/classes/ds/impls/hep/LOCDIR32,1051 src/sys/classes/ds/impls/makefile,180 makefile:^?makefile^A,1 LIBBASE = libslepcsysLIBBASE24,936 DIRS = hep nhep ghep ghiep gnhep svd pep nepDIRS25,959 LOCDIR = src/sys/classes/ds/impls/LOCDIR26,1008 MANSEC = DSMANSEC27,1045 src/sys/classes/ds/impls/nep/dsnep.c,2602 dsnep.c:^?dsnep.c^A,1 PetscInt nf; /* number of functions in f[] */nf26,1031 FN f[DS_NUM_EXTRA]; /* functions defining the nonlinear operator */f27,1095 } DS_NEP;DS_NEP28,1174 #undef __FUNCT____FUNCT__30,1185 #define __FUNCT__ __FUNCT__31,1202 static PetscErrorCode DSNEPComputeMatrix(DS ds,PetscScalar lambda,PetscBool deriv,DSMatType mat)DSNEPComputeMatrix37,1470 #undef __FUNCT____FUNCT__66,2536 #define __FUNCT__ __FUNCT__67,2553 PetscErrorCode DSAllocate_NEP(DS ds,PetscInt ld)DSAllocate_NEP68,2588 #undef __FUNCT____FUNCT__86,3232 #define __FUNCT__ __FUNCT__87,3249 PetscErrorCode DSView_NEP(DS ds,PetscViewer viewer)DSView_NEP88,3280 #undef __FUNCT____FUNCT__109,4017 #define __FUNCT__ __FUNCT__110,4034 PetscErrorCode DSVectors_NEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)DSVectors_NEP111,4068 #undef __FUNCT____FUNCT__127,4539 #define __FUNCT__ __FUNCT__128,4556 PetscErrorCode DSNormalize_NEP(DS ds,DSMatType mat,PetscInt col)DSNormalize_NEP129,4592 #undef __FUNCT____FUNCT__162,5472 #define __FUNCT__ __FUNCT__163,5489 PetscErrorCode DSSort_NEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_NEP164,5520 #undef __FUNCT____FUNCT__188,6258 #define __FUNCT__ __FUNCT__189,6275 PetscErrorCode DSSolve_NEP_SLP(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_NEP_SLP190,6311 #undef __FUNCT____FUNCT__312,10332 #define __FUNCT__ __FUNCT__313,10349 static PetscErrorCode DSNEPSetFN_NEP(DS ds,PetscInt n,FN fn[])DSNEPSetFN_NEP314,10384 #undef __FUNCT____FUNCT__335,11190 #define __FUNCT__ __FUNCT__336,11207 PetscErrorCode DSNEPSetFN(DS ds,PetscInt n,FN fn[])DSNEPSetFN360,11829 #undef __FUNCT____FUNCT__377,12293 #define __FUNCT__ __FUNCT__378,12310 static PetscErrorCode DSNEPGetFN_NEP(DS ds,PetscInt k,FN *fn)DSNEPGetFN_NEP379,12345 #undef __FUNCT____FUNCT__389,12648 #define __FUNCT__ __FUNCT__390,12665 PetscErrorCode DSNEPGetFN(DS ds,PetscInt k,FN *fn)DSNEPGetFN407,13050 #undef __FUNCT____FUNCT__418,13336 #define __FUNCT__ __FUNCT__419,13353 static PetscErrorCode DSNEPGetNumFN_NEP(DS ds,PetscInt *n)DSNEPGetNumFN_NEP420,13391 #undef __FUNCT____FUNCT__429,13555 #define __FUNCT__ __FUNCT__430,13572 PetscErrorCode DSNEPGetNumFN(DS ds,PetscInt *n)DSNEPGetNumFN447,13892 #undef __FUNCT____FUNCT__458,14171 #define __FUNCT__ __FUNCT__459,14188 PetscErrorCode DSDestroy_NEP(DS ds)DSDestroy_NEP460,14222 #undef __FUNCT____FUNCT__477,14789 #define __FUNCT__ __FUNCT__478,14806 PETSC_EXTERN PetscErrorCode DSCreate_NEP(DS ds)DSCreate_NEP479,14839 src/sys/classes/ds/impls/nep/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dsnep.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = DSMANSEC31,1033 LOCDIR = src/sys/classes/ds/impls/nep/LOCDIR32,1047 src/sys/classes/ds/impls/nhep/dsnhep.c,3045 dsnhep.c:^?dsnhep.c^A,1 #undef __FUNCT____FUNCT__25,988 #define __FUNCT__ __FUNCT__26,1005 PetscErrorCode DSAllocate_NHEP(DS ds,PetscInt ld)DSAllocate_NHEP27,1041 #undef __FUNCT____FUNCT__40,1463 #define __FUNCT__ __FUNCT__41,1480 PetscErrorCode DSView_NHEP(DS ds,PetscViewer viewer)DSView_NHEP42,1512 #undef __FUNCT____FUNCT__60,1971 #define __FUNCT__ __FUNCT__61,1988 static PetscErrorCode DSVectors_NHEP_Refined_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)DSVectors_NHEP_Refined_Some62,2036 #undef __FUNCT____FUNCT__117,4162 #define __FUNCT__ __FUNCT__118,4179 static PetscErrorCode DSVectors_NHEP_Refined_All(DS ds,PetscBool left)DSVectors_NHEP_Refined_All119,4226 #undef __FUNCT____FUNCT__131,4495 #define __FUNCT__ __FUNCT__132,4512 static PetscErrorCode DSVectors_NHEP_Eigen_Some(DS ds,PetscInt *k,PetscReal *rnorm,PetscBool left)DSVectors_NHEP_Eigen_Some133,4558 #undef __FUNCT____FUNCT__204,7297 #define __FUNCT__ __FUNCT__205,7314 static PetscErrorCode DSVectors_NHEP_Eigen_All(DS ds,PetscBool left)DSVectors_NHEP_Eigen_All206,7359 #undef __FUNCT____FUNCT__268,9406 #define __FUNCT__ __FUNCT__269,9423 PetscErrorCode DSVectors_NHEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)DSVectors_NHEP270,9458 #undef __FUNCT____FUNCT__313,10875 #define __FUNCT__ __FUNCT__314,10892 PetscErrorCode DSNormalize_NHEP(DS ds,DSMatType mat,PetscInt col)DSNormalize_NHEP315,10929 #undef __FUNCT____FUNCT__370,12476 #define __FUNCT__ __FUNCT__371,12493 static PetscErrorCode DSSort_NHEP_Arbitrary(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_NHEP_Arbitrary372,12535 #undef __FUNCT____FUNCT__420,14341 #define __FUNCT__ __FUNCT__421,14358 static PetscErrorCode DSSort_NHEP_Total(DS ds,PetscScalar *wr,PetscScalar *wi)DSSort_NHEP_Total422,14396 #undef __FUNCT____FUNCT__509,16913 #define __FUNCT__ __FUNCT__510,16930 PetscErrorCode DSSort_NHEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_NHEP511,16962 #undef __FUNCT____FUNCT__524,17309 #define __FUNCT__ __FUNCT__525,17326 PetscErrorCode DSUpdateExtraRow_NHEP(DS ds)DSUpdateExtraRow_NHEP526,17368 #undef __FUNCT____FUNCT__548,18036 #define __FUNCT__ __FUNCT__549,18053 PetscErrorCode DSSolve_NHEP(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_NHEP550,18086 #undef __FUNCT____FUNCT__626,20630 #define __FUNCT__ __FUNCT__627,20647 PetscErrorCode DSTruncate_NHEP(DS ds,PetscInt n)DSTruncate_NHEP628,20683 #undef __FUNCT____FUNCT__652,21331 #define __FUNCT__ __FUNCT__653,21348 PetscErrorCode DSCond_NHEP(DS ds,PetscReal *cond)DSCond_NHEP654,21380 #undef __FUNCT____FUNCT__698,22992 #define __FUNCT__ __FUNCT__699,23009 PetscErrorCode DSTranslateHarmonic_NHEP(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *gin,PetscReal *gamma)DSTranslateHarmonic_NHEP700,23054 #undef __FUNCT____FUNCT__781,25845 #define __FUNCT__ __FUNCT__782,25862 PETSC_EXTERN PetscErrorCode DSCreate_NHEP(DS ds)DSCreate_NHEP783,25896 src/sys/classes/ds/impls/nhep/makefile,286 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dsnhep.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsysLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = DSMANSEC31,1034 LOCDIR = src/sys/classes/ds/impls/nhep/LOCDIR32,1048 src/sys/classes/ds/impls/pep/dspep.c,1986 dspep.c:^?dspep.c^A,1 PetscInt d; /* polynomial degree */d26,1031 } DS_PEP;DS_PEP27,1082 #undef __FUNCT____FUNCT__29,1093 #define __FUNCT__ __FUNCT__30,1110 PetscErrorCode DSAllocate_PEP(DS ds,PetscInt ld)DSAllocate_PEP31,1145 #undef __FUNCT____FUNCT__50,1878 #define __FUNCT__ __FUNCT__51,1895 PetscErrorCode DSView_PEP(DS ds,PetscViewer viewer)DSView_PEP52,1926 #undef __FUNCT____FUNCT__74,2691 #define __FUNCT__ __FUNCT__75,2708 PetscErrorCode DSVectors_PEP(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)DSVectors_PEP76,2742 #undef __FUNCT____FUNCT__91,3145 #define __FUNCT__ __FUNCT__92,3162 PetscErrorCode DSNormalize_PEP(DS ds,DSMatType mat,PetscInt col)DSNormalize_PEP93,3198 #undef __FUNCT____FUNCT__107,3512 #define __FUNCT__ __FUNCT__108,3529 PetscErrorCode DSSort_PEP(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *kout)DSSort_PEP109,3560 #undef __FUNCT____FUNCT__154,4973 #define __FUNCT__ __FUNCT__155,4990 PetscErrorCode DSSolve_PEP_QZ(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_PEP_QZ156,5025 #undef __FUNCT____FUNCT__277,9315 #define __FUNCT__ __FUNCT__278,9332 static PetscErrorCode DSPEPSetDegree_PEP(DS ds,PetscInt d)DSPEPSetDegree_PEP279,9371 #undef __FUNCT____FUNCT__290,9819 #define __FUNCT__ __FUNCT__291,9836 PetscErrorCode DSPEPSetDegree(DS ds,PetscInt d)DSPEPSetDegree305,10097 #undef __FUNCT____FUNCT__316,10392 #define __FUNCT__ __FUNCT__317,10409 static PetscErrorCode DSPEPGetDegree_PEP(DS ds,PetscInt *d)DSPEPGetDegree_PEP318,10448 #undef __FUNCT____FUNCT__327,10612 #define __FUNCT__ __FUNCT__328,10629 PetscErrorCode DSPEPGetDegree(DS ds,PetscInt *d)DSPEPGetDegree344,10902 #undef __FUNCT____FUNCT__355,11183 #define __FUNCT__ __FUNCT__356,11200 PetscErrorCode DSDestroy_PEP(DS ds)DSDestroy_PEP357,11234 #undef __FUNCT____FUNCT__368,11575 #define __FUNCT__ __FUNCT__369,11592 PETSC_EXTERN PetscErrorCode DSCreate_PEP(DS ds)DSCreate_PEP370,11625 src/sys/classes/ds/impls/pep/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dspep.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = DSMANSEC31,1033 LOCDIR = src/sys/classes/ds/impls/pep/LOCDIR32,1047 src/sys/classes/ds/impls/svd/dssvd.c,1149 dssvd.c:^?dssvd.c^A,1 #undef __FUNCT____FUNCT__25,988 #define __FUNCT__ __FUNCT__26,1005 PetscErrorCode DSAllocate_SVD(DS ds,PetscInt ld)DSAllocate_SVD27,1040 #undef __FUNCT____FUNCT__67,2647 #define __FUNCT__ __FUNCT__68,2664 static PetscErrorCode DSSwitchFormat_SVD(DS ds,PetscBool tocompact)DSSwitchFormat_SVD69,2703 #undef __FUNCT____FUNCT__104,3798 #define __FUNCT__ __FUNCT__105,3815 PetscErrorCode DSView_SVD(DS ds,PetscViewer viewer)DSView_SVD106,3846 #undef __FUNCT____FUNCT__158,6072 #define __FUNCT__ __FUNCT__159,6089 PetscErrorCode DSVectors_SVD(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)DSVectors_SVD160,6123 #undef __FUNCT____FUNCT__173,6439 #define __FUNCT__ __FUNCT__174,6456 PetscErrorCode DSSort_SVD(DS ds,PetscScalar *wr,PetscScalar *wi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort_SVD175,6487 #undef __FUNCT____FUNCT__203,7314 #define __FUNCT__ __FUNCT__204,7331 PetscErrorCode DSSolve_SVD_DC(DS ds,PetscScalar *wr,PetscScalar *wi)DSSolve_SVD_DC205,7366 #undef __FUNCT____FUNCT__302,11239 #define __FUNCT__ __FUNCT__303,11256 PETSC_EXTERN PetscErrorCode DSCreate_SVD(DS ds)DSCreate_SVD304,11289 src/sys/classes/ds/impls/svd/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dssvd.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = DSMANSEC31,1033 LOCDIR = src/sys/classes/ds/impls/svd/LOCDIR32,1047 src/sys/classes/ds/interface/dsbasic.c,4771 dsbasic.c:^?dsbasic.c^A,1 PetscFunctionList DSList = 0;DSList26,1006 PetscBool DSRegisterAllCalled = PETSC_FALSE;DSRegisterAllCalled27,1036 PetscClassId DS_CLASSID = 0;DS_CLASSID28,1089 PetscLogEvent DS_Solve = 0,DS_Vectors = 0,DS_Other = 0;DS_Solve29,1123 PetscLogEvent DS_Solve = 0,DS_Vectors = 0,DS_Other = 0;DS_Vectors29,1123 PetscLogEvent DS_Solve = 0,DS_Vectors = 0,DS_Other = 0;DS_Other29,1123 static PetscBool DSPackageInitialized = PETSC_FALSE;DSPackageInitialized30,1183 const char *DSMatName[DS_NUM_MAT] = {"A","B","C","T","D","Q","Z","X","Y","U","VT","W","E0","E1","E2","E3","E4","E5","E6","E7","E8","E9"};DSMatName31,1237 DSMatType DSMatExtra[DS_NUM_EXTRA] = {DS_MAT_E0,DS_MAT_E1,DS_MAT_E2,DS_MAT_E3,DS_MAT_E4,DS_MAT_E5,DS_MAT_E6,DS_MAT_E7,DS_MAT_E8,DS_MAT_E9};DSMatExtra32,1382 #undef __FUNCT____FUNCT__34,1531 #define __FUNCT__ __FUNCT__35,1548 PetscErrorCode DSFinalizePackage(void)DSFinalizePackage44,1780 #undef __FUNCT____FUNCT__55,2030 #define __FUNCT__ __FUNCT__56,2047 PetscErrorCode DSInitializePackage()DSInitializePackage66,2367 #undef __FUNCT____FUNCT__104,3750 #define __FUNCT__ __FUNCT__105,3767 PetscErrorCode DSCreate(MPI_Comm comm,DS *newds)DSCreate125,4161 #undef __FUNCT____FUNCT__169,5262 #define __FUNCT__ __FUNCT__170,5279 PetscErrorCode DSSetOptionsPrefix(DS ds,const char *prefix)DSSetOptionsPrefix190,5794 #undef __FUNCT____FUNCT__200,6052 #define __FUNCT__ __FUNCT__201,6069 PetscErrorCode DSAppendOptionsPrefix(DS ds,const char *prefix)DSAppendOptionsPrefix220,6590 #undef __FUNCT____FUNCT__230,6854 #define __FUNCT__ __FUNCT__231,6871 PetscErrorCode DSGetOptionsPrefix(DS ds,const char *prefix[])DSGetOptionsPrefix252,7370 #undef __FUNCT____FUNCT__263,7661 #define __FUNCT__ __FUNCT__264,7678 PetscErrorCode DSSetType(DS ds,DSType type)DSSetType278,7926 #undef __FUNCT____FUNCT__300,8635 #define __FUNCT__ __FUNCT__301,8652 PetscErrorCode DSGetType(DS ds,DSType *type)DSGetType317,8942 #undef __FUNCT____FUNCT__326,9154 #define __FUNCT__ __FUNCT__327,9171 PetscErrorCode DSSetMethod(DS ds,PetscInt meth)DSSetMethod341,9460 #undef __FUNCT____FUNCT__352,9924 #define __FUNCT__ __FUNCT__353,9941 PetscErrorCode DSGetMethod(DS ds,PetscInt *meth)DSGetMethod369,10220 #undef __FUNCT____FUNCT__378,10418 #define __FUNCT__ __FUNCT__379,10435 PetscErrorCode DSSetCompact(DS ds,PetscBool comp)DSSetCompact401,10996 #undef __FUNCT____FUNCT__410,11212 #define __FUNCT__ __FUNCT__411,11229 PetscErrorCode DSGetCompact(DS ds,PetscBool *comp)DSGetCompact427,11480 #undef __FUNCT____FUNCT__436,11681 #define __FUNCT__ __FUNCT__437,11698 PetscErrorCode DSSetExtraRow(DS ds,PetscBool ext)DSSetExtraRow460,12372 #undef __FUNCT____FUNCT__470,12720 #define __FUNCT__ __FUNCT__471,12737 PetscErrorCode DSGetExtraRow(DS ds,PetscBool *ext)DSGetExtraRow487,12984 #undef __FUNCT____FUNCT__496,13184 #define __FUNCT__ __FUNCT__497,13201 PetscErrorCode DSSetRefined(DS ds,PetscBool ref)DSSetRefined522,13901 #undef __FUNCT____FUNCT__531,14114 #define __FUNCT__ __FUNCT__532,14131 PetscErrorCode DSGetRefined(DS ds,PetscBool *ref)DSGetRefined548,14381 #undef __FUNCT____FUNCT__557,14579 #define __FUNCT__ __FUNCT__558,14596 PetscErrorCode DSSetBlockSize(DS ds,PetscInt bs)DSSetBlockSize572,14841 #undef __FUNCT____FUNCT__582,15164 #define __FUNCT__ __FUNCT__583,15181 PetscErrorCode DSGetBlockSize(DS ds,PetscInt *bs)DSGetBlockSize599,15432 #undef __FUNCT____FUNCT__608,15623 #define __FUNCT__ __FUNCT__609,15640 PetscErrorCode DSSetSlepcSC(DS ds,SlepcSC sc)DSSetSlepcSC623,15919 #undef __FUNCT____FUNCT__637,16193 #define __FUNCT__ __FUNCT__638,16210 PetscErrorCode DSGetSlepcSC(DS ds,SlepcSC *sc)DSGetSlepcSC654,16511 #undef __FUNCT____FUNCT__668,16794 #define __FUNCT__ __FUNCT__669,16811 PetscErrorCode DSSetFromOptions(DS ds)DSSetFromOptions683,17092 #undef __FUNCT____FUNCT__706,18096 #define __FUNCT__ __FUNCT__707,18113 PetscErrorCode DSView(DS ds,PetscViewer viewer)DSView732,18799 #undef __FUNCT____FUNCT__779,20988 #define __FUNCT__ __FUNCT__780,21005 PetscErrorCode DSAllocate(DS ds,PetscInt ld)DSAllocate795,21414 #undef __FUNCT____FUNCT__808,21814 #define __FUNCT__ __FUNCT__809,21831 PetscErrorCode DSReset(DS ds)DSReset822,22043 #undef __FUNCT____FUNCT__853,22872 #define __FUNCT__ __FUNCT__854,22889 PetscErrorCode DSDestroy(DS *ds)DSDestroy867,23114 #undef __FUNCT____FUNCT__882,23594 #define __FUNCT__ __FUNCT__883,23611 PetscErrorCode DSRegister(const char *name,PetscErrorCode (*function)(DS))DSRegister901,23984 #undef __FUNCT____FUNCT__919,24579 #define __FUNCT__ __FUNCT__920,24596 PetscErrorCode DSRegisterAll(void)DSRegisterAll928,24752 src/sys/classes/ds/interface/dsops.c,3511 dsops.c:^?dsops.c^A,1 #undef __FUNCT____FUNCT__26,1031 #define __FUNCT__ __FUNCT__27,1048 PetscErrorCode DSGetLeadingDimension(DS ds,PetscInt *ld)DSGetLeadingDimension44,1415 #undef __FUNCT____FUNCT__53,1613 #define __FUNCT__ __FUNCT__54,1630 PetscErrorCode DSSetState(DS ds,DSStateType state)DSSetState77,2261 #undef __FUNCT____FUNCT__98,2850 #define __FUNCT__ __FUNCT__99,2867 PetscErrorCode DSGetState(DS ds,DSStateType *state)DSGetState115,3114 #undef __FUNCT____FUNCT__124,3316 #define __FUNCT__ __FUNCT__125,3333 PetscErrorCode DSSetDimensions(DS ds,PetscInt n,PetscInt m,PetscInt l,PetscInt k)DSSetDimensions147,3895 #undef __FUNCT____FUNCT__187,5453 #define __FUNCT__ __FUNCT__188,5470 PetscErrorCode DSGetDimensions(DS ds,PetscInt *n,PetscInt *m,PetscInt *l,PetscInt *k,PetscInt *t)DSGetDimensions212,6050 #undef __FUNCT____FUNCT__225,6373 #define __FUNCT__ __FUNCT__226,6390 PetscErrorCode DSTruncate(DS ds,PetscInt n)DSTruncate244,6836 #undef __FUNCT____FUNCT__265,7728 #define __FUNCT__ __FUNCT__266,7745 PetscErrorCode DSGetMat(DS ds,DSMatType m,Mat *A)DSGetMat294,8622 #undef __FUNCT____FUNCT__333,9959 #define __FUNCT__ __FUNCT__334,9976 PetscErrorCode DSRestoreMat(DS ds,DSMatType m,Mat *A)DSRestoreMat357,10648 #undef __FUNCT____FUNCT__383,11694 #define __FUNCT__ __FUNCT__384,11711 PetscErrorCode DSGetArray(DS ds,DSMatType m,PetscScalar *a[])DSGetArray403,12147 #undef __FUNCT____FUNCT__416,12619 #define __FUNCT__ __FUNCT__417,12636 PetscErrorCode DSRestoreArray(DS ds,DSMatType m,PetscScalar *a[])DSRestoreArray432,12947 #undef __FUNCT____FUNCT__447,13371 #define __FUNCT__ __FUNCT__448,13388 PetscErrorCode DSGetArrayReal(DS ds,DSMatType m,PetscReal *a[])DSGetArrayReal467,13841 #undef __FUNCT____FUNCT__480,14317 #define __FUNCT__ __FUNCT__481,14334 PetscErrorCode DSRestoreArrayReal(DS ds,DSMatType m,PetscReal *a[])DSRestoreArrayReal496,14657 #undef __FUNCT____FUNCT__511,15083 #define __FUNCT__ __FUNCT__512,15100 PetscErrorCode DSSolve(DS ds,PetscScalar *eigr,PetscScalar *eigi)DSSolve531,15594 #undef __FUNCT____FUNCT__551,16444 #define __FUNCT__ __FUNCT__552,16461 PetscErrorCode DSSort(DS ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k)DSSort586,17799 #undef __FUNCT____FUNCT__611,19060 #define __FUNCT__ __FUNCT__612,19077 PetscErrorCode DSVectors(DS ds,DSMatType mat,PetscInt *j,PetscReal *rnorm)DSVectors650,20305 #undef __FUNCT____FUNCT__670,21226 #define __FUNCT__ __FUNCT__671,21243 PetscErrorCode DSNormalize(DS ds,DSMatType mat,PetscInt col)DSNormalize693,21864 #undef __FUNCT____FUNCT__712,22683 #define __FUNCT__ __FUNCT__713,22700 PetscErrorCode DSUpdateExtraRow(DS ds)DSUpdateExtraRow727,23002 #undef __FUNCT____FUNCT__744,23702 #define __FUNCT__ __FUNCT__745,23719 PetscErrorCode DSCond(DS ds,PetscReal *cond)DSCond760,24018 #undef __FUNCT____FUNCT__777,24630 #define __FUNCT__ __FUNCT__778,24647 PetscErrorCode DSTranslateHarmonic(DS ds,PetscScalar tau,PetscReal beta,PetscBool recover,PetscScalar *g,PetscReal *gamma)DSTranslateHarmonic809,25744 #undef __FUNCT____FUNCT__827,26529 #define __FUNCT__ __FUNCT__828,26546 PetscErrorCode DSTranslateRKS(DS ds,PetscScalar alpha)DSTranslateRKS853,27417 #undef __FUNCT____FUNCT__872,28144 #define __FUNCT__ __FUNCT__873,28161 PetscErrorCode DSCopyMat(DS ds,DSMatType m,PetscInt mr,PetscInt mc,Mat A,PetscInt Ar,PetscInt Ac,PetscInt rows,PetscInt cols,PetscBool out)DSCopyMat900,28905 src/sys/classes/ds/interface/dspriv.c,2790 dspriv.c:^?dspriv.c^A,1 #undef __FUNCT____FUNCT__27,1037 #define __FUNCT__ __FUNCT__28,1054 PetscErrorCode DSAllocateMat_Private(DS ds,DSMatType m)DSAllocateMat_Private29,1096 #undef __FUNCT____FUNCT__69,2190 #define __FUNCT__ __FUNCT__70,2207 PetscErrorCode DSAllocateMatReal_Private(DS ds,DSMatType m)DSAllocateMatReal_Private71,2253 #undef __FUNCT____FUNCT__88,2764 #define __FUNCT__ __FUNCT__89,2781 PetscErrorCode DSAllocateWork_Private(DS ds,PetscInt s,PetscInt r,PetscInt i)DSAllocateWork_Private90,2824 #undef __FUNCT____FUNCT__116,3708 #define __FUNCT__ __FUNCT__117,3725 PetscErrorCode DSViewMat(DS ds,PetscViewer viewer,DSMatType m)DSViewMat136,4113 #undef __FUNCT____FUNCT__200,6605 #define __FUNCT__ __FUNCT__201,6622 PetscErrorCode DSSortEigenvalues_Private(DS ds,PetscScalar *wr,PetscScalar *wi,PetscInt *perm,PetscBool isghiep)DSSortEigenvalues_Private202,6668 #undef __FUNCT____FUNCT__255,8142 #define __FUNCT__ __FUNCT__256,8159 PetscErrorCode DSSortEigenvaluesReal_Private(DS ds,PetscReal *eig,PetscInt *perm)DSSortEigenvaluesReal_Private257,8209 #undef __FUNCT____FUNCT__281,8877 #define __FUNCT__ __FUNCT__282,8894 PetscErrorCode DSCopyMatrix_Private(DS ds,DSMatType dst,DSMatType src)DSCopyMatrix_Private287,9034 #undef __FUNCT____FUNCT__305,9443 #define __FUNCT__ __FUNCT__306,9460 PetscErrorCode DSPermuteColumns_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat,PetscInt *perm)DSPermuteColumns_Private307,9505 #undef __FUNCT____FUNCT__330,10024 #define __FUNCT__ __FUNCT__331,10041 PetscErrorCode DSPermuteRows_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat,PetscInt *perm)DSPermuteRows_Private332,10083 #undef __FUNCT____FUNCT__356,10693 #define __FUNCT__ __FUNCT__357,10710 PetscErrorCode DSPermuteBoth_Private(DS ds,PetscInt l,PetscInt n,DSMatType mat1,DSMatType mat2,PetscInt *perm)DSPermuteBoth_Private358,10752 #undef __FUNCT____FUNCT__387,11554 #define __FUNCT__ __FUNCT__388,11571 PetscErrorCode DSSetIdentity(DS ds,DSMatType mat)DSSetIdentity401,11863 #undef __FUNCT____FUNCT__421,12498 #define __FUNCT__ __FUNCT__422,12515 PetscErrorCode DSOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscInt *lindcols)DSOrthogonalize440,12957 #undef __FUNCT____FUNCT__491,15198 #define __FUNCT__ __FUNCT__492,15215 static PetscErrorCode SlepcMatDenseMult(PetscScalar *C,PetscInt _ldC,PetscScalar b,PetscScalar a,const PetscScalar *A,PetscInt _ldA,PetscInt rA,PetscInt cA,PetscBool At,const PetscScalar *B,PetscInt _ldB,PetscInt rB,PetscInt cB,PetscBool Bt)SlepcMatDenseMult503,15569 #undef __FUNCT____FUNCT__539,16865 #define __FUNCT__ __FUNCT__540,16882 PetscErrorCode DSPseudoOrthogonalize(DS ds,DSMatType mat,PetscInt cols,PetscReal *s,PetscInt *lindcols,PetscReal *ns)DSPseudoOrthogonalize561,17517 src/sys/classes/ds/interface/ftn-custom/makefile,267 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zdsf.cSOURCEC26,996 SOURCEF =SOURCEF27,1014 SOURCEH =SOURCEH28,1025 DIRS =DIRS29,1036 LIBBASE = libslepcsysLIBBASE30,1047 LOCDIR = src/sys/classes/ds/interface/ftn-custom/LOCDIR31,1070 src/sys/classes/ds/interface/ftn-custom/zdsf.c,2100 zdsf.c:^?zdsf.c^A,1 PETSC_EXTERN void PETSC_STDCALL dssettype_(DS *ds,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))dssettype_47,1916 PETSC_EXTERN void PETSC_STDCALL dsgettype_(DS *ds,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))dsgettype_56,2126 PETSC_EXTERN void PETSC_STDCALL dssetoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))dssetoptionsprefix_65,2399 PETSC_EXTERN void PETSC_STDCALL dsappendoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))dsappendoptionsprefix_74,2633 PETSC_EXTERN void PETSC_STDCALL dsgetoptionsprefix_(DS *ds,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))dsgetoptionsprefix_83,2873 PETSC_EXTERN void PETSC_STDCALL dsview_(DS *ds,PetscViewer *viewer,PetscErrorCode *ierr)dsview_92,3176 PETSC_EXTERN void PETSC_STDCALL dsviewmat_(DS *ds,PetscViewer *viewer,DSMatType *m,PetscErrorCode *ierr)dsviewmat_99,3358 PETSC_EXTERN void PETSC_STDCALL dsvectors_(DS *ds,DSMatType *mat,PetscInt *j,PetscReal *rnorm,PetscErrorCode *ierr)dsvectors_106,3562 PETSC_EXTERN void PETSC_STDCALL dssort_(DS *ds,PetscScalar *eigr,PetscScalar *eigi,PetscScalar *rr,PetscScalar *ri,PetscInt *k,PetscErrorCode *ierr)dssort_113,3779 src/sys/classes/ds/interface/makefile,304 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = dsbasic.c dsops.c dspriv.cSOURCEC26,958 SOURCEF =SOURCEF27,996 SOURCEH =SOURCEH28,1007 LIBBASE = libslepcsysLIBBASE29,1018 DIRS =DIRS30,1041 MANSEC = DSMANSEC31,1052 LOCDIR = src/sys/classes/ds/interface/LOCDIR32,1066 src/sys/classes/ds/makefile,223 makefile:^?makefile^A,1 SOURCEH = ../../../../include/slepc/private/dsimpl.h ../../../../include/slepcds.hSOURCEH24,936 DIRS = interface impls examplesDIRS25,1020 LOCDIR = src/sys/classes/ds/LOCDIR26,1056 MANSEC = DSMANSEC27,1087 src/sys/classes/fn/examples/makefile,83 makefile:^?makefile^A,1 LOCDIR = src/sys/classes/fn/examples/LOCDIR24,932 DIRS = testsDIRS25,972 src/sys/classes/fn/examples/tests/makefile,486 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/sys/classes/fn/examples/tests/LOCDIR26,978 EXAMPLESC = test1.c test2.c test3.c test4.c test5.c test6.c test7.c test8.cEXAMPLESC27,1026 EXAMPLESF =EXAMPLESF28,1103 MANSEC = FNMANSEC29,1116 TESTS = test1 test2 test3 test4 test5 test6 test7 test8TESTS30,1132 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rm \TESTEXAMPLES_C32,1194 src/sys/classes/fn/examples/tests/test1.c,179 test1.c:^?test1.c^A,1 static char help[] = "Test rational function.\n\n";help22,924 #undef __FUNCT____FUNCT__26,999 #define __FUNCT__ __FUNCT__27,1016 int main(int argc,char **argv)main28,1041 src/sys/classes/fn/examples/tests/test2.c,183 test2.c:^?test2.c^A,1 static char help[] = "Test exponential function.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1002 #define __FUNCT__ __FUNCT__27,1019 int main(int argc,char **argv)main28,1044 src/sys/classes/fn/examples/tests/test3.c,366 test3.c:^?test3.c^A,1 static char help[] = "Test matrix exponential.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1000 #define __FUNCT__ __FUNCT__27,1017 PetscErrorCode TestMatExp(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)TestMatExp31,1097 #undef __FUNCT____FUNCT__77,2968 #define __FUNCT__ __FUNCT__78,2985 int main(int argc,char **argv)main79,3010 src/sys/classes/fn/examples/tests/test4.c,206 test4.c:^?test4.c^A,1 static char help[] = "Test setting FN parameters from the command line.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1025 #define __FUNCT__ __FUNCT__27,1042 int main(int argc,char **argv)main28,1067 src/sys/classes/fn/examples/tests/test5.c,382 test5.c:^?test5.c^A,1 static char help[] = "Test matrix rational function.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1006 #define __FUNCT__ __FUNCT__27,1023 PetscErrorCode TestMatRational(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)TestMatRational31,1116 #undef __FUNCT____FUNCT__77,2989 #define __FUNCT__ __FUNCT__78,3006 int main(int argc,char **argv)main79,3031 src/sys/classes/fn/examples/tests/test6.c,374 test6.c:^?test6.c^A,1 static char help[] = "Test combined function.\n\n";help35,1371 #undef __FUNCT____FUNCT__39,1446 #define __FUNCT__ __FUNCT__40,1463 PetscErrorCode TestMatCombine(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)TestMatCombine44,1562 #undef __FUNCT____FUNCT__90,3437 #define __FUNCT__ __FUNCT__91,3454 int main(int argc,char **argv)main92,3479 src/sys/classes/fn/examples/tests/test7.c,368 test7.c:^?test7.c^A,1 static char help[] = "Test matrix square root.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1000 #define __FUNCT__ __FUNCT__27,1017 PetscErrorCode TestMatSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)TestMatSqrt32,1130 #undef __FUNCT____FUNCT__92,3595 #define __FUNCT__ __FUNCT__93,3612 int main(int argc,char **argv)main94,3637 src/sys/classes/fn/examples/tests/test8.c,382 test8.c:^?test8.c^A,1 static char help[] = "Test matrix inverse square root.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1008 #define __FUNCT__ __FUNCT__27,1025 PetscErrorCode TestMatInvSqrt(FN fn,Mat A,PetscViewer viewer,PetscBool verbose,PetscBool inplace)TestMatInvSqrt32,1156 #undef __FUNCT____FUNCT__97,3817 #define __FUNCT__ __FUNCT__98,3834 int main(int argc,char **argv)main99,3859 src/sys/classes/fn/impls/combine/fncombine.c,2351 fncombine.c:^?fncombine.c^A,1 FN f1,f2; /* functions */f134,1359 FN f1,f2; /* functions */f234,1359 FNCombineType comb; /* how the functions are combined */comb35,1401 } FN_COMBINE;FN_COMBINE36,1464 #undef __FUNCT____FUNCT__38,1479 #define __FUNCT__ __FUNCT__39,1496 PetscErrorCode FNEvaluateFunction_Combine(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction_Combine40,1543 #undef __FUNCT____FUNCT__69,2398 #define __FUNCT__ __FUNCT__70,2415 PetscErrorCode FNEvaluateDerivative_Combine(FN fn,PetscScalar x,PetscScalar *yp)FNEvaluateDerivative_Combine71,2464 #undef __FUNCT____FUNCT__109,3888 #define __FUNCT__ __FUNCT__110,3905 PetscErrorCode FNEvaluateFunctionMat_Combine(FN fn,Mat A,Mat B)FNEvaluateFunctionMat_Combine111,3955 #undef __FUNCT____FUNCT__171,6306 #define __FUNCT__ __FUNCT__172,6323 PetscErrorCode FNEvaluateFunctionMatVec_Combine(FN fn,Mat A,Vec v)FNEvaluateFunctionMatVec_Combine173,6376 #undef __FUNCT____FUNCT__236,8816 #define __FUNCT__ __FUNCT__237,8833 PetscErrorCode FNView_Combine(FN fn,PetscViewer viewer)FNView_Combine238,8868 #undef __FUNCT____FUNCT__269,10005 #define __FUNCT__ __FUNCT__270,10022 static PetscErrorCode FNCombineSetChildren_Combine(FN fn,FNCombineType comb,FN f1,FN f2)FNCombineSetChildren_Combine271,10071 #undef __FUNCT____FUNCT__289,10714 #define __FUNCT__ __FUNCT__290,10731 PetscErrorCode FNCombineSetChildren(FN fn,FNCombineType comb,FN f1,FN f2)FNCombineSetChildren307,11202 #undef __FUNCT____FUNCT__320,11643 #define __FUNCT__ __FUNCT__321,11660 static PetscErrorCode FNCombineGetChildren_Combine(FN fn,FNCombineType *comb,FN *f1,FN *f2)FNCombineGetChildren_Combine322,11709 #undef __FUNCT____FUNCT__346,12412 #define __FUNCT__ __FUNCT__347,12429 PetscErrorCode FNCombineGetChildren(FN fn,FNCombineType *comb,FN *f1,FN *f2)FNCombineGetChildren366,12906 #undef __FUNCT____FUNCT__376,13217 #define __FUNCT__ __FUNCT__377,13234 PetscErrorCode FNDuplicate_Combine(FN fn,MPI_Comm comm,FN *newfn)FNDuplicate_Combine378,13274 #undef __FUNCT____FUNCT__390,13646 #define __FUNCT__ __FUNCT__391,13663 PetscErrorCode FNDestroy_Combine(FN fn)FNDestroy_Combine392,13701 #undef __FUNCT____FUNCT__406,14193 #define __FUNCT__ __FUNCT__407,14210 PETSC_EXTERN PetscErrorCode FNCreate_Combine(FN fn)FNCreate_Combine408,14247 src/sys/classes/fn/impls/combine/makefile,292 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fncombine.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcsysLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = FNMANSEC31,1037 LOCDIR = src/sys/classes/fn/impls/combine/LOCDIR32,1051 src/sys/classes/fn/impls/exp/fnexp.c,876 fnexp.c:^?fnexp.c^A,1 #undef __FUNCT____FUNCT__27,1046 #define __FUNCT__ __FUNCT__28,1063 PetscErrorCode FNEvaluateFunction_Exp(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction_Exp29,1106 #undef __FUNCT____FUNCT__36,1259 #define __FUNCT__ __FUNCT__37,1276 PetscErrorCode FNEvaluateDerivative_Exp(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateDerivative_Exp38,1321 #define MAX_PADE MAX_PADE45,1476 #define SWAP(SWAP46,1495 #undef __FUNCT____FUNCT__48,1531 #define __FUNCT__ __FUNCT__49,1548 PetscErrorCode FNEvaluateFunctionMat_Exp(FN fn,Mat A,Mat B)FNEvaluateFunctionMat_Exp50,1594 #undef __FUNCT____FUNCT__143,5171 #define __FUNCT__ __FUNCT__144,5188 PetscErrorCode FNView_Exp(FN fn,PetscViewer viewer)FNView_Exp145,5219 #undef __FUNCT____FUNCT__177,6521 #define __FUNCT__ __FUNCT__178,6538 PETSC_EXTERN PetscErrorCode FNCreate_Exp(FN fn)FNCreate_Exp179,6571 src/sys/classes/fn/impls/exp/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fnexp.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = FNMANSEC31,1033 LOCDIR = src/sys/classes/fn/impls/exp/LOCDIR32,1047 src/sys/classes/fn/impls/fnutil.c,422 fnutil.c:^?fnutil.c^A,1 #undef __FUNCT____FUNCT__27,1061 #define __FUNCT__ __FUNCT__28,1078 PetscErrorCode SlepcMatDenseSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld)SlepcMatDenseSqrt33,1265 #define BLOCKSIZE BLOCKSIZE91,3340 #undef __FUNCT____FUNCT__93,3362 #define __FUNCT__ __FUNCT__94,3379 PetscErrorCode SlepcSchurParlettSqrt(PetscBLASInt n,PetscScalar *T,PetscBLASInt ld,PetscBool firstonly)SlepcSchurParlettSqrt100,3663 src/sys/classes/fn/impls/invsqrt/fninvsqrt.c,1034 fninvsqrt.c:^?fninvsqrt.c^A,1 #undef __FUNCT____FUNCT__27,1056 #define __FUNCT__ __FUNCT__28,1073 PetscErrorCode FNEvaluateFunction_Invsqrt(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction_Invsqrt29,1120 #undef __FUNCT____FUNCT__37,1370 #define __FUNCT__ __FUNCT__38,1387 PetscErrorCode FNEvaluateDerivative_Invsqrt(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateDerivative_Invsqrt39,1436 #undef __FUNCT____FUNCT__47,1704 #define __FUNCT__ __FUNCT__48,1721 PetscErrorCode FNEvaluateFunctionMat_Invsqrt(FN fn,Mat A,Mat B)FNEvaluateFunctionMat_Invsqrt49,1771 #undef __FUNCT____FUNCT__78,2856 #define __FUNCT__ __FUNCT__79,2873 PetscErrorCode FNEvaluateFunctionMatVec_Invsqrt(FN fn,Mat A,Vec v)FNEvaluateFunctionMatVec_Invsqrt80,2926 #undef __FUNCT____FUNCT__111,4109 #define __FUNCT__ __FUNCT__112,4126 PetscErrorCode FNView_Invsqrt(FN fn,PetscViewer viewer)FNView_Invsqrt113,4161 #undef __FUNCT____FUNCT__145,5511 #define __FUNCT__ __FUNCT__146,5528 PETSC_EXTERN PetscErrorCode FNCreate_Invsqrt(FN fn)FNCreate_Invsqrt147,5565 src/sys/classes/fn/impls/invsqrt/makefile,292 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fninvsqrt.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcsysLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = FNMANSEC31,1037 LOCDIR = src/sys/classes/fn/impls/invsqrt/LOCDIR32,1051 src/sys/classes/fn/impls/log/fnlog.c,642 fnlog.c:^?fnlog.c^A,1 #undef __FUNCT____FUNCT__26,1015 #define __FUNCT__ __FUNCT__27,1032 PetscErrorCode FNEvaluateFunction_Log(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction_Log28,1075 #undef __FUNCT____FUNCT__35,1228 #define __FUNCT__ __FUNCT__36,1245 PetscErrorCode FNEvaluateDerivative_Log(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateDerivative_Log37,1290 #undef __FUNCT____FUNCT__45,1523 #define __FUNCT__ __FUNCT__46,1540 PetscErrorCode FNView_Log(FN fn,PetscViewer viewer)FNView_Log47,1571 #undef __FUNCT____FUNCT__79,2865 #define __FUNCT__ __FUNCT__80,2882 PETSC_EXTERN PetscErrorCode FNCreate_Log(FN fn)FNCreate_Log81,2915 src/sys/classes/fn/impls/log/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fnlog.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = FNMANSEC31,1033 LOCDIR = src/sys/classes/fn/impls/log/LOCDIR32,1047 src/sys/classes/fn/impls/makefile,323 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fnutil.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsysLIBBASE29,1000 DIRS = combine exp log phi rational sqrt invsqrtDIRS30,1023 LOCDIR = src/sys/classes/fn/impls/LOCDIR31,1076 MANSEC = FNMANSEC32,1113 src/sys/classes/fn/impls/phi/fnphi.c,2142 fnphi.c:^?fnphi.c^A,1 PetscInt k; /* index of the phi-function, defaults to k=1 */k30,1116 } FN_PHI;FN_PHI31,1182 const static PetscReal rfactorial[] = { 1, 1, 0.5, 1.0/6, 1.0/24, 1.0/120, 1.0/720, 1.0/5040, 1.0/40320, 1.0/362880 };rfactorial33,1193 static void PhiFunction(PetscScalar x,PetscScalar *y,PetscInt k)PhiFunction35,1313 #undef __FUNCT____FUNCT__48,1609 #define __FUNCT__ __FUNCT__49,1626 PetscErrorCode FNEvaluateFunction_Phi(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction_Phi50,1669 static void PhiDerivative(PetscScalar x,PetscScalar *y,PetscInt k)PhiDerivative59,1859 #undef __FUNCT____FUNCT__75,2177 #define __FUNCT__ __FUNCT__76,2194 PetscErrorCode FNEvaluateDerivative_Phi(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateDerivative_Phi77,2239 #undef __FUNCT____FUNCT__86,2433 #define __FUNCT__ __FUNCT__87,2450 static PetscErrorCode FNPhiSetIndex_Phi(FN fn,PetscInt k)FNPhiSetIndex_Phi88,2488 #undef __FUNCT____FUNCT__97,2649 #define __FUNCT__ __FUNCT__98,2666 PetscErrorCode FNPhiSetIndex(FN fn,PetscInt k)FNPhiSetIndex120,3100 #undef __FUNCT____FUNCT__133,3608 #define __FUNCT__ __FUNCT__134,3625 static PetscErrorCode FNPhiGetIndex_Phi(FN fn,PetscInt *k)FNPhiGetIndex_Phi135,3663 #undef __FUNCT____FUNCT__144,3826 #define __FUNCT__ __FUNCT__145,3843 PetscErrorCode FNPhiGetIndex(FN fn,PetscInt *k)FNPhiGetIndex161,4105 #undef __FUNCT____FUNCT__172,4384 #define __FUNCT__ __FUNCT__173,4401 PetscErrorCode FNView_Phi(FN fn,PetscViewer viewer)FNView_Phi174,4432 #undef __FUNCT____FUNCT__208,5782 #define __FUNCT__ __FUNCT__209,5799 PetscErrorCode FNSetFromOptions_Phi(PetscOptionItems *PetscOptionsObject,FN fn)FNSetFromOptions_Phi210,5840 #undef __FUNCT____FUNCT__227,6393 #define __FUNCT__ __FUNCT__228,6410 PetscErrorCode FNDuplicate_Phi(FN fn,MPI_Comm comm,FN *newfn)FNDuplicate_Phi229,6446 #undef __FUNCT____FUNCT__238,6649 #define __FUNCT__ __FUNCT__239,6666 PetscErrorCode FNDestroy_Phi(FN fn)FNDestroy_Phi240,6700 #undef __FUNCT____FUNCT__251,7039 #define __FUNCT__ __FUNCT__252,7056 PETSC_EXTERN PetscErrorCode FNCreate_Phi(FN fn)FNCreate_Phi253,7089 src/sys/classes/fn/impls/phi/makefile,283 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fnphi.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = FNMANSEC31,1033 LOCDIR = src/sys/classes/fn/impls/phi/LOCDIR32,1047 src/sys/classes/fn/impls/rational/fnrational.c,3807 fnrational.c:^?fnrational.c^A,1 PetscScalar *pcoeff; /* numerator coefficients */pcoeff28,1107 PetscInt np; /* length of array pcoeff, p(x) has degree np-1 */np29,1162 PetscScalar *qcoeff; /* denominator coefficients */qcoeff30,1239 PetscInt nq; /* length of array qcoeff, q(x) has degree nq-1 */nq31,1296 } FN_RATIONAL;FN_RATIONAL32,1373 #undef __FUNCT____FUNCT__34,1389 #define __FUNCT__ __FUNCT__35,1406 PetscErrorCode FNEvaluateFunction_Rational(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction_Rational36,1454 #undef __FUNCT____FUNCT__60,2011 #define __FUNCT__ __FUNCT__61,2028 static PetscErrorCode FNEvaluateFunctionMat_Private(FN fn,PetscScalar *Aa,PetscScalar *Ba,PetscInt m,PetscBool firstonly)FNEvaluateFunctionMat_Private62,2078 #undef __FUNCT____FUNCT__116,4034 #define __FUNCT__ __FUNCT__117,4051 PetscErrorCode FNEvaluateFunctionMat_Rational(FN fn,Mat A,Mat B)FNEvaluateFunctionMat_Rational118,4102 #undef __FUNCT____FUNCT__134,4614 #define __FUNCT__ __FUNCT__135,4631 PetscErrorCode FNEvaluateFunctionMatVec_Rational(FN fn,Mat A,Vec v)FNEvaluateFunctionMatVec_Rational136,4685 #undef __FUNCT____FUNCT__156,5367 #define __FUNCT__ __FUNCT__157,5384 PetscErrorCode FNEvaluateDerivative_Rational(FN fn,PetscScalar x,PetscScalar *yp)FNEvaluateDerivative_Rational158,5434 #undef __FUNCT____FUNCT__190,6123 #define __FUNCT__ __FUNCT__191,6140 PetscErrorCode FNView_Rational(FN fn,PetscViewer viewer)FNView_Rational192,6176 #undef __FUNCT____FUNCT__259,9675 #define __FUNCT__ __FUNCT__260,9692 static PetscErrorCode FNRationalSetNumerator_Rational(FN fn,PetscInt np,PetscScalar *pcoeff)FNRationalSetNumerator_Rational261,9744 #undef __FUNCT____FUNCT__278,10255 #define __FUNCT__ __FUNCT__279,10272 PetscErrorCode FNRationalSetNumerator(FN fn,PetscInt np,PetscScalar *pcoeff)FNRationalSetNumerator304,11077 #undef __FUNCT____FUNCT__317,11583 #define __FUNCT__ __FUNCT__318,11600 static PetscErrorCode FNRationalGetNumerator_Rational(FN fn,PetscInt *np,PetscScalar *pcoeff[])FNRationalGetNumerator_Rational319,11652 #undef __FUNCT____FUNCT__337,12107 #define __FUNCT__ __FUNCT__338,12124 PetscErrorCode FNRationalGetNumerator(FN fn,PetscInt *np,PetscScalar *pcoeff[])FNRationalGetNumerator361,12722 #undef __FUNCT____FUNCT__371,13038 #define __FUNCT__ __FUNCT__372,13055 static PetscErrorCode FNRationalSetDenominator_Rational(FN fn,PetscInt nq,PetscScalar *qcoeff)FNRationalSetDenominator_Rational373,13109 #undef __FUNCT____FUNCT__390,13622 #define __FUNCT__ __FUNCT__391,13639 PetscErrorCode FNRationalSetDenominator(FN fn,PetscInt nq,PetscScalar *qcoeff)FNRationalSetDenominator416,14468 #undef __FUNCT____FUNCT__429,14978 #define __FUNCT__ __FUNCT__430,14995 static PetscErrorCode FNRationalGetDenominator_Rational(FN fn,PetscInt *nq,PetscScalar *qcoeff[])FNRationalGetDenominator_Rational431,15049 #undef __FUNCT____FUNCT__449,15506 #define __FUNCT__ __FUNCT__450,15523 PetscErrorCode FNRationalGetDenominator(FN fn,PetscInt *nq,PetscScalar *qcoeff[])FNRationalGetDenominator473,16131 #undef __FUNCT____FUNCT__483,16451 #define __FUNCT__ __FUNCT__484,16468 PetscErrorCode FNSetFromOptions_Rational(PetscOptionItems *PetscOptionsObject,FN fn)FNSetFromOptions_Rational485,16514 #define PARMAX PARMAX488,16624 #undef __FUNCT____FUNCT__514,17567 #define __FUNCT__ __FUNCT__515,17584 PetscErrorCode FNDuplicate_Rational(FN fn,MPI_Comm comm,FN *newfn)FNDuplicate_Rational516,17625 #undef __FUNCT____FUNCT__538,18404 #define __FUNCT__ __FUNCT__539,18421 PetscErrorCode FNDestroy_Rational(FN fn)FNDestroy_Rational540,18460 #undef __FUNCT____FUNCT__556,19168 #define __FUNCT__ __FUNCT__557,19185 PETSC_EXTERN PetscErrorCode FNCreate_Rational(FN fn)FNCreate_Rational558,19223 src/sys/classes/fn/impls/rational/makefile,294 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fnrational.cSOURCEC26,958 SOURCEF =SOURCEF27,982 SOURCEH =SOURCEH28,993 LIBBASE = libslepcsysLIBBASE29,1004 DIRS =DIRS30,1027 MANSEC = FNMANSEC31,1038 LOCDIR = src/sys/classes/fn/impls/rational/LOCDIR32,1052 src/sys/classes/fn/impls/sqrt/fnsqrt.c,995 fnsqrt.c:^?fnsqrt.c^A,1 #undef __FUNCT____FUNCT__27,1047 #define __FUNCT__ __FUNCT__28,1064 PetscErrorCode FNEvaluateFunction_Sqrt(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction_Sqrt29,1108 #undef __FUNCT____FUNCT__36,1263 #define __FUNCT__ __FUNCT__37,1280 PetscErrorCode FNEvaluateDerivative_Sqrt(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateDerivative_Sqrt38,1326 #undef __FUNCT____FUNCT__46,1583 #define __FUNCT__ __FUNCT__47,1600 PetscErrorCode FNEvaluateFunctionMat_Sqrt(FN fn,Mat A,Mat B)FNEvaluateFunctionMat_Sqrt48,1647 #undef __FUNCT____FUNCT__65,2174 #define __FUNCT__ __FUNCT__66,2191 PetscErrorCode FNEvaluateFunctionMatVec_Sqrt(FN fn,Mat A,Vec v)FNEvaluateFunctionMatVec_Sqrt67,2241 #undef __FUNCT____FUNCT__87,2866 #define __FUNCT__ __FUNCT__88,2883 PetscErrorCode FNView_Sqrt(FN fn,PetscViewer viewer)FNView_Sqrt89,2915 #undef __FUNCT____FUNCT__121,4222 #define __FUNCT__ __FUNCT__122,4239 PETSC_EXTERN PetscErrorCode FNCreate_Sqrt(FN fn)FNCreate_Sqrt123,4273 src/sys/classes/fn/impls/sqrt/makefile,286 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fnsqrt.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsysLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = FNMANSEC31,1034 LOCDIR = src/sys/classes/fn/impls/sqrt/LOCDIR32,1048 src/sys/classes/fn/interface/fnbasic.c,4092 fnbasic.c:^?fnbasic.c^A,1 PetscFunctionList FNList = 0;FNList27,1034 PetscBool FNRegisterAllCalled = PETSC_FALSE;FNRegisterAllCalled28,1064 PetscClassId FN_CLASSID = 0;FN_CLASSID29,1117 PetscLogEvent FN_Evaluate = 0;FN_Evaluate30,1151 static PetscBool FNPackageInitialized = PETSC_FALSE;FNPackageInitialized31,1186 #undef __FUNCT____FUNCT__33,1241 #define __FUNCT__ __FUNCT__34,1258 PetscErrorCode FNFinalizePackage(void)FNFinalizePackage43,1490 #undef __FUNCT____FUNCT__54,1740 #define __FUNCT__ __FUNCT__55,1757 PetscErrorCode FNInitializePackage(void)FNInitializePackage65,2077 #undef __FUNCT____FUNCT__101,3310 #define __FUNCT__ __FUNCT__102,3327 PetscErrorCode FNCreate(MPI_Comm comm,FN *newfn)FNCreate118,3587 #undef __FUNCT____FUNCT__140,4054 #define __FUNCT__ __FUNCT__141,4071 PetscErrorCode FNSetOptionsPrefix(FN fn,const char *prefix)FNSetOptionsPrefix161,4586 #undef __FUNCT____FUNCT__171,4844 #define __FUNCT__ __FUNCT__172,4861 PetscErrorCode FNAppendOptionsPrefix(FN fn,const char *prefix)FNAppendOptionsPrefix191,5382 #undef __FUNCT____FUNCT__201,5646 #define __FUNCT__ __FUNCT__202,5663 PetscErrorCode FNGetOptionsPrefix(FN fn,const char *prefix[])FNGetOptionsPrefix223,6162 #undef __FUNCT____FUNCT__234,6453 #define __FUNCT__ __FUNCT__235,6470 PetscErrorCode FNSetType(FN fn,FNType type)FNSetType253,6872 #undef __FUNCT____FUNCT__276,7655 #define __FUNCT__ __FUNCT__277,7672 PetscErrorCode FNGetType(FN fn,FNType *type)FNGetType293,7962 #undef __FUNCT____FUNCT__302,8174 #define __FUNCT__ __FUNCT__303,8191 PetscErrorCode FNSetScale(FN fn,PetscScalar alpha,PetscScalar beta)FNSetScale328,9046 #undef __FUNCT____FUNCT__339,9350 #define __FUNCT__ __FUNCT__340,9367 PetscErrorCode FNGetScale(FN fn,PetscScalar *alpha,PetscScalar *beta)FNGetScale357,9706 #undef __FUNCT____FUNCT__366,9939 #define __FUNCT__ __FUNCT__367,9956 PetscErrorCode FNEvaluateFunction(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateFunction388,10489 #undef __FUNCT____FUNCT__406,11032 #define __FUNCT__ __FUNCT__407,11049 PetscErrorCode FNEvaluateDerivative(FN fn,PetscScalar x,PetscScalar *y)FNEvaluateDerivative428,11560 #undef __FUNCT____FUNCT__446,12117 #define __FUNCT__ __FUNCT__447,12134 static PetscErrorCode FNEvaluateFunctionMat_Sym_Private(FN fn,PetscScalar *As,PetscScalar *Bs,PetscInt m,PetscBool firstonly)FNEvaluateFunctionMat_Sym_Private448,12188 #undef __FUNCT____FUNCT__506,14385 #define __FUNCT__ __FUNCT__507,14402 static PetscErrorCode FNEvaluateFunctionMat_Sym_Default(FN fn,Mat A,Mat B)FNEvaluateFunctionMat_Sym_Default513,14631 #undef __FUNCT____FUNCT__529,15157 #define __FUNCT__ __FUNCT__530,15174 PetscErrorCode FNEvaluateFunctionMat(FN fn,Mat A,Mat B)FNEvaluateFunctionMat562,16357 #undef __FUNCT____FUNCT__630,18980 #define __FUNCT__ __FUNCT__631,18997 static PetscErrorCode FNEvaluateFunctionMatVec_Default(FN fn,Mat A,Vec v)FNEvaluateFunctionMatVec_Default636,19161 #undef __FUNCT____FUNCT__651,19728 #define __FUNCT__ __FUNCT__652,19745 static PetscErrorCode FNEvaluateFunctionMatVec_Sym_Default(FN fn,Mat A,Vec v)FNEvaluateFunctionMatVec_Sym_Default658,20016 #undef __FUNCT____FUNCT__674,20534 #define __FUNCT__ __FUNCT__675,20551 PetscErrorCode FNEvaluateFunctionMatVec(FN fn,Mat A,Vec v)FNEvaluateFunctionMatVec697,21147 #undef __FUNCT____FUNCT__756,23253 #define __FUNCT__ __FUNCT__757,23270 PetscErrorCode FNSetFromOptions(FN fn)FNSetFromOptions771,23551 #undef __FUNCT____FUNCT__810,24914 #define __FUNCT__ __FUNCT__811,24931 PetscErrorCode FNView(FN fn,PetscViewer viewer)FNView834,25594 #undef __FUNCT____FUNCT__856,26373 #define __FUNCT__ __FUNCT__857,26390 PetscErrorCode FNDuplicate(FN fn,MPI_Comm comm,FN *newfn)FNDuplicate879,26882 #undef __FUNCT____FUNCT__900,27505 #define __FUNCT__ __FUNCT__901,27522 PetscErrorCode FNDestroy(FN *fn)FNDestroy914,27747 #undef __FUNCT____FUNCT__931,28250 #define __FUNCT__ __FUNCT__932,28267 PetscErrorCode FNRegister(const char *name,PetscErrorCode (*function)(FN))FNRegister949,28634 src/sys/classes/fn/interface/fnregis.c,129 fnregis.c:^?fnregis.c^A,1 #undef __FUNCT____FUNCT__32,1321 #define __FUNCT__ __FUNCT__33,1338 PetscErrorCode FNRegisterAll(void)FNRegisterAll41,1494 src/sys/classes/fn/interface/ftn-custom/makefile,257 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zfnf.cSOURCEC26,996 SOURCEF =SOURCEF27,1014 SOURCEH =SOURCEH28,1025 DIRS =DIRS29,1036 LIBBASE = libslepcsysLIBBASE30,1047 LOCDIR = src/sys/classes/fn/ftn-custom/LOCDIR31,1070 src/sys/classes/fn/interface/ftn-custom/zfnf.c,1452 zfnf.c:^?zfnf.c^A,1 PETSC_EXTERN void PETSC_STDCALL fnview_(FN *fn,PetscViewer *viewer,PetscErrorCode *ierr)fnview_42,1720 PETSC_EXTERN void PETSC_STDCALL fnsetoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))fnsetoptionsprefix_49,1902 PETSC_EXTERN void PETSC_STDCALL fnappendoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))fnappendoptionsprefix_58,2136 PETSC_EXTERN void PETSC_STDCALL fngetoptionsprefix_(FN *fn,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))fngetoptionsprefix_67,2376 PETSC_EXTERN void PETSC_STDCALL fnsettype_(FN *fn,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))fnsettype_76,2679 PETSC_EXTERN void PETSC_STDCALL fngettype_(FN *fn,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))fngettype_85,2889 src/sys/classes/fn/interface/makefile,297 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = fnbasic.c fnregis.cSOURCEC26,958 SOURCEF =SOURCEF27,989 SOURCEH =SOURCEH28,1000 LIBBASE = libslepcsysLIBBASE29,1011 DIRS =DIRS30,1034 MANSEC = FNMANSEC31,1045 LOCDIR = src/sys/classes/fn/interface/LOCDIR32,1059 src/sys/classes/fn/makefile,223 makefile:^?makefile^A,1 SOURCEH = ../../../../include/slepc/private/fnimpl.h ../../../../include/slepcfn.hSOURCEH24,936 DIRS = interface impls examplesDIRS25,1020 LOCDIR = src/sys/classes/fn/LOCDIR26,1056 MANSEC = FNMANSEC27,1087 src/sys/classes/makefile,278 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC =SOURCEC26,958 SOURCEF =SOURCEF27,969 SOURCEH =SOURCEH28,980 LIBBASE = libslepcsysLIBBASE29,991 MANSEC = sysMANSEC30,1014 LOCDIR = src/sys/classes/LOCDIR31,1029 DIRS = ds fn st bv rgDIRS32,1057 src/sys/classes/rg/examples/makefile,83 makefile:^?makefile^A,1 LOCDIR = src/sys/classes/rg/examples/LOCDIR24,932 DIRS = testsDIRS25,972 src/sys/classes/rg/examples/tests/makefile,386 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/sys/classes/rg/examples/tests/LOCDIR26,978 EXAMPLESC = test1.cEXAMPLESC27,1026 EXAMPLESF =EXAMPLESF28,1047 MANSEC = RGMANSEC29,1060 TESTS = test1TESTS30,1076 TESTEXAMPLES_C = test1.PETSc runtest1_1 test1.rmTESTEXAMPLES_C32,1096 src/sys/classes/rg/examples/tests/test1.c,185 test1.c:^?test1.c^A,1 static char help[] = "Test RG interface functions.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1004 #define __FUNCT__ __FUNCT__27,1021 int main(int argc,char **argv)main28,1046 src/sys/classes/rg/impls/ellipse/makefile,292 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = rgellipse.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcsysLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = RGMANSEC31,1037 LOCDIR = src/sys/classes/rg/impls/ellipse/LOCDIR32,1051 src/sys/classes/rg/impls/ellipse/rgellipse.c,2300 rgellipse.c:^?rgellipse.c^A,1 PetscScalar center; /* center of the ellipse */center27,1071 PetscReal radius; /* radius of the ellipse */radius28,1125 PetscReal vscale; /* vertical scale of the ellipse */vscale29,1179 } RG_ELLIPSE;RG_ELLIPSE30,1241 #undef __FUNCT____FUNCT__32,1256 #define __FUNCT__ __FUNCT__33,1273 static PetscErrorCode RGEllipseSetParameters_Ellipse(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale)RGEllipseSetParameters_Ellipse34,1324 #undef __FUNCT____FUNCT__51,1927 #define __FUNCT__ __FUNCT__52,1944 PetscErrorCode RGEllipseSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale)RGEllipseSetParameters80,2755 #undef __FUNCT____FUNCT__93,3254 #define __FUNCT__ __FUNCT__94,3271 static PetscErrorCode RGEllipseGetParameters_Ellipse(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale)RGEllipseGetParameters_Ellipse95,3322 #undef __FUNCT____FUNCT__106,3646 #define __FUNCT__ __FUNCT__107,3663 PetscErrorCode RGEllipseGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale)RGEllipseGetParameters125,4051 #undef __FUNCT____FUNCT__135,4410 #define __FUNCT__ __FUNCT__136,4427 PetscErrorCode RGView_Ellipse(RG rg,PetscViewer viewer)RGView_Ellipse137,4462 #undef __FUNCT____FUNCT__153,5035 #define __FUNCT__ __FUNCT__154,5052 PetscErrorCode RGIsTrivial_Ellipse(RG rg,PetscBool *trivial)RGIsTrivial_Ellipse155,5092 #undef __FUNCT____FUNCT__165,5362 #define __FUNCT__ __FUNCT__166,5379 PetscErrorCode RGComputeContour_Ellipse(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)RGComputeContour_Ellipse167,5424 #undef __FUNCT____FUNCT__186,5970 #define __FUNCT__ __FUNCT__187,5987 PetscErrorCode RGCheckInside_Ellipse(RG rg,PetscReal px,PetscReal py,PetscInt *inside)RGCheckInside_Ellipse188,6029 #undef __FUNCT____FUNCT__206,6525 #define __FUNCT__ __FUNCT__207,6542 PetscErrorCode RGSetFromOptions_Ellipse(PetscOptionItems *PetscOptionsObject,RG rg)RGSetFromOptions_Ellipse208,6587 #undef __FUNCT____FUNCT__230,7480 #define __FUNCT__ __FUNCT__231,7497 PetscErrorCode RGDestroy_Ellipse(RG rg)RGDestroy_Ellipse232,7535 #undef __FUNCT____FUNCT__243,7896 #define __FUNCT__ __FUNCT__244,7913 PETSC_EXTERN PetscErrorCode RGCreate_Ellipse(RG rg)RGCreate_Ellipse245,7950 src/sys/classes/rg/impls/interval/makefile,294 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = rginterval.cSOURCEC26,958 SOURCEF =SOURCEF27,982 SOURCEH =SOURCEH28,993 LIBBASE = libslepcsysLIBBASE29,1004 DIRS =DIRS30,1027 MANSEC = RGMANSEC31,1038 LOCDIR = src/sys/classes/rg/impls/interval/LOCDIR32,1052 src/sys/classes/rg/impls/interval/rginterval.c,2357 rginterval.c:^?rginterval.c^A,1 PetscReal a,b; /* interval in the real axis */a28,1102 PetscReal a,b; /* interval in the real axis */b28,1102 PetscReal c,d; /* interval in the imaginary axis */c29,1157 PetscReal c,d; /* interval in the imaginary axis */d29,1157 } RG_INTERVAL;RG_INTERVAL30,1217 #undef __FUNCT____FUNCT__32,1233 #define __FUNCT__ __FUNCT__33,1250 static PetscErrorCode RGIntervalSetEndpoints_Interval(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d)RGIntervalSetEndpoints_Interval34,1302 #undef __FUNCT____FUNCT__54,2393 #define __FUNCT__ __FUNCT__55,2410 PetscErrorCode RGIntervalSetEndpoints(RG rg,PetscReal a,PetscReal b,PetscReal c,PetscReal d)RGIntervalSetEndpoints78,3079 #undef __FUNCT____FUNCT__92,3594 #define __FUNCT__ __FUNCT__93,3611 static PetscErrorCode RGIntervalGetEndpoints_Interval(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d)RGIntervalGetEndpoints_Interval94,3663 #undef __FUNCT____FUNCT__106,3963 #define __FUNCT__ __FUNCT__107,3980 PetscErrorCode RGIntervalGetEndpoints(RG rg,PetscReal *a,PetscReal *b,PetscReal *c,PetscReal *d)RGIntervalGetEndpoints124,4367 #undef __FUNCT____FUNCT__134,4718 #define __FUNCT__ __FUNCT__135,4735 PetscErrorCode RGView_Interval(RG rg,PetscViewer viewer)RGView_Interval136,4771 #undef __FUNCT____FUNCT__150,5255 #define __FUNCT__ __FUNCT__151,5272 PetscErrorCode RGIsTrivial_Interval(RG rg,PetscBool *trivial)RGIsTrivial_Interval152,5313 #undef __FUNCT____FUNCT__162,5717 #define __FUNCT__ __FUNCT__163,5734 PetscErrorCode RGComputeContour_Interval(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)RGComputeContour_Interval164,5780 #undef __FUNCT____FUNCT__214,7537 #define __FUNCT__ __FUNCT__215,7554 PetscErrorCode RGCheckInside_Interval(RG rg,PetscReal dx,PetscReal dy,PetscInt *inside)RGCheckInside_Interval216,7597 #undef __FUNCT____FUNCT__232,8031 #define __FUNCT__ __FUNCT__233,8048 PetscErrorCode RGSetFromOptions_Interval(PetscOptionItems *PetscOptionsObject,RG rg)RGSetFromOptions_Interval234,8094 #undef __FUNCT____FUNCT__255,8931 #define __FUNCT__ __FUNCT__256,8948 PetscErrorCode RGDestroy_Interval(RG rg)RGDestroy_Interval257,8987 #undef __FUNCT____FUNCT__268,9349 #define __FUNCT__ __FUNCT__269,9366 PETSC_EXTERN PetscErrorCode RGCreate_Interval(RG rg)RGCreate_Interval270,9404 src/sys/classes/rg/impls/makefile,172 makefile:^?makefile^A,1 LIBBASE = libslepcsysLIBBASE24,936 DIRS = ellipse interval polygon ringDIRS25,959 LOCDIR = src/sys/classes/rg/impls/LOCDIR26,1000 MANSEC = RGMANSEC27,1037 src/sys/classes/rg/impls/polygon/makefile,292 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = rgpolygon.cSOURCEC26,958 SOURCEF =SOURCEF27,981 SOURCEH =SOURCEH28,992 LIBBASE = libslepcsysLIBBASE29,1003 DIRS =DIRS30,1026 MANSEC = RGMANSEC31,1037 LOCDIR = src/sys/classes/rg/impls/polygon/LOCDIR32,1051 src/sys/classes/rg/impls/polygon/rgpolygon.c,2316 rgpolygon.c:^?rgpolygon.c^A,1 #define VERTMAX VERTMAX26,1025 PetscInt n; /* number of vertices */n29,1062 PetscScalar *vr,*vi; /* array of vertices (vi not used in complex scalars) */vr30,1112 PetscScalar *vr,*vi; /* array of vertices (vi not used in complex scalars) */vi30,1112 } RG_POLYGON;RG_POLYGON31,1194 #undef __FUNCT____FUNCT__33,1209 #define __FUNCT__ __FUNCT__34,1226 static PetscErrorCode RGPolygonSetVertices_Polygon(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi)RGPolygonSetVertices_Polygon35,1275 #undef __FUNCT____FUNCT__64,2198 #define __FUNCT__ __FUNCT__65,2215 PetscErrorCode RGPolygonSetVertices(RG rg,PetscInt n,PetscScalar *vr,PetscScalar *vi)RGPolygonSetVertices95,3140 #undef __FUNCT____FUNCT__110,3604 #define __FUNCT__ __FUNCT__111,3621 static PetscErrorCode RGPolygonGetVertices_Polygon(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi)RGPolygonGetVertices_Polygon112,3670 #undef __FUNCT____FUNCT__123,3945 #define __FUNCT__ __FUNCT__124,3962 PetscErrorCode RGPolygonGetVertices(RG rg,PetscInt *n,PetscScalar **vr,PetscScalar **vi)RGPolygonGetVertices145,4411 #undef __FUNCT____FUNCT__155,4746 #define __FUNCT__ __FUNCT__156,4763 PetscErrorCode RGView_Polygon(RG rg,PetscViewer viewer)RGView_Polygon157,4798 #undef __FUNCT____FUNCT__188,5911 #define __FUNCT__ __FUNCT__189,5928 PetscErrorCode RGIsTrivial_Polygon(RG rg,PetscBool *trivial)RGIsTrivial_Polygon190,5968 #undef __FUNCT____FUNCT__199,6157 #define __FUNCT__ __FUNCT__200,6174 PetscErrorCode RGComputeContour_Polygon(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)RGComputeContour_Polygon201,6219 #undef __FUNCT____FUNCT__267,8072 #define __FUNCT__ __FUNCT__268,8089 PetscErrorCode RGCheckInside_Polygon(RG rg,PetscReal px,PetscReal py,PetscInt *inout)RGCheckInside_Polygon269,8131 #undef __FUNCT____FUNCT__307,9133 #define __FUNCT__ __FUNCT__308,9150 PetscErrorCode RGSetFromOptions_Polygon(PetscOptionItems *PetscOptionsObject,RG rg)RGSetFromOptions_Polygon309,9195 #undef __FUNCT____FUNCT__342,10362 #define __FUNCT__ __FUNCT__343,10379 PetscErrorCode RGDestroy_Polygon(RG rg)RGDestroy_Polygon344,10417 #undef __FUNCT____FUNCT__362,10970 #define __FUNCT__ __FUNCT__363,10987 PETSC_EXTERN PetscErrorCode RGCreate_Polygon(RG rg)RGCreate_Polygon364,11024 src/sys/classes/rg/impls/ring/makefile,286 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = rgring.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsysLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = RGMANSEC31,1034 LOCDIR = src/sys/classes/rg/impls/ring/LOCDIR32,1048 src/sys/classes/rg/impls/ring/rgring.c,2628 rgring.c:^?rgring.c^A,1 PetscScalar center; /* center of the ellipse */center28,1101 PetscReal radius; /* radius of the ellipse */radius29,1155 PetscReal vscale; /* vertical scale of the ellipse */vscale30,1209 PetscReal start_ang; /* start angle */start_ang31,1271 PetscReal end_ang; /* end angle */end_ang32,1315 PetscReal width; /* ring width */width33,1357 } RG_RING;RG_RING34,1400 #undef __FUNCT____FUNCT__36,1412 #define __FUNCT__ __FUNCT__37,1429 static PetscErrorCode RGRingSetParameters_Ring(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width)RGRingSetParameters_Ring38,1474 #undef __FUNCT____FUNCT__76,3281 #define __FUNCT__ __FUNCT__77,3298 PetscErrorCode RGRingSetParameters(RG rg,PetscScalar center,PetscReal radius,PetscReal vscale,PetscReal start_ang,PetscReal end_ang,PetscReal width)RGRingSetParameters119,4870 #undef __FUNCT____FUNCT__135,5618 #define __FUNCT__ __FUNCT__136,5635 static PetscErrorCode RGRingGetParameters_Ring(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width)RGRingGetParameters_Ring137,5680 #undef __FUNCT____FUNCT__151,6199 #define __FUNCT__ __FUNCT__152,6216 PetscErrorCode RGRingGetParameters(RG rg,PetscScalar *center,PetscReal *radius,PetscReal *vscale,PetscReal *start_ang,PetscReal *end_ang,PetscReal *width)RGRingGetParameters173,6715 #undef __FUNCT____FUNCT__183,7182 #define __FUNCT__ __FUNCT__184,7199 PetscErrorCode RGView_Ring(RG rg,PetscViewer viewer)RGView_Ring185,7231 #undef __FUNCT____FUNCT__201,7885 #define __FUNCT__ __FUNCT__202,7902 PetscErrorCode RGIsTrivial_Ring(RG rg,PetscBool *trivial)RGIsTrivial_Ring203,7939 #undef __FUNCT____FUNCT__213,8200 #define __FUNCT__ __FUNCT__214,8217 PetscErrorCode RGComputeContour_Ring(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)RGComputeContour_Ring215,8259 #undef __FUNCT____FUNCT__244,9347 #define __FUNCT__ __FUNCT__245,9364 PetscErrorCode RGCheckInside_Ring(RG rg,PetscReal px,PetscReal py,PetscInt *inside)RGCheckInside_Ring246,9403 #undef __FUNCT____FUNCT__294,10931 #define __FUNCT__ __FUNCT__295,10948 PetscErrorCode RGSetFromOptions_Ring(PetscOptionItems *PetscOptionsObject,RG rg)RGSetFromOptions_Ring296,10990 #undef __FUNCT____FUNCT__321,12275 #define __FUNCT__ __FUNCT__322,12292 PetscErrorCode RGDestroy_Ring(RG rg)RGDestroy_Ring323,12327 #undef __FUNCT____FUNCT__334,12679 #define __FUNCT__ __FUNCT__335,12696 PETSC_EXTERN PetscErrorCode RGCreate_Ring(RG rg)RGCreate_Ring336,12730 src/sys/classes/rg/interface/ftn-custom/makefile,267 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zrgf.cSOURCEC26,996 SOURCEF =SOURCEF27,1014 SOURCEH =SOURCEH28,1025 DIRS =DIRS29,1036 LIBBASE = libslepcsysLIBBASE30,1047 LOCDIR = src/sys/classes/rg/interface/ftn-custom/LOCDIR31,1070 src/sys/classes/rg/interface/ftn-custom/zrgf.c,1452 zrgf.c:^?zrgf.c^A,1 PETSC_EXTERN void PETSC_STDCALL rgsettype_(RG *rg,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))rgsettype_41,1658 PETSC_EXTERN void PETSC_STDCALL rggettype_(RG *rg,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))rggettype_50,1868 PETSC_EXTERN void PETSC_STDCALL rgsetoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))rgsetoptionsprefix_59,2142 PETSC_EXTERN void PETSC_STDCALL rgappendoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))rgappendoptionsprefix_68,2376 PETSC_EXTERN void PETSC_STDCALL rggetoptionsprefix_(RG *rg,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))rggetoptionsprefix_77,2616 PETSC_EXTERN void PETSC_STDCALL rgview_(RG *rg,PetscViewer *viewer,PetscErrorCode *ierr)rgview_86,2919 src/sys/classes/rg/interface/makefile,287 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = rgbasic.c rgregis.cSOURCEC26,958 SOURCEF =SOURCEF27,989 SOURCEH =SOURCEH28,1000 LIBBASE = libslepcsysLIBBASE29,1011 DIRS =DIRS30,1034 MANSEC = RGMANSEC31,1045 LOCDIR = src/sys/classes/rg/LOCDIR32,1059 src/sys/classes/rg/interface/rgbasic.c,3445 rgbasic.c:^?rgbasic.c^A,1 PetscFunctionList RGList = 0;RGList26,1003 PetscBool RGRegisterAllCalled = PETSC_FALSE;RGRegisterAllCalled27,1033 PetscClassId RG_CLASSID = 0;RG_CLASSID28,1086 static PetscBool RGPackageInitialized = PETSC_FALSE;RGPackageInitialized29,1120 #undef __FUNCT____FUNCT__31,1175 #define __FUNCT__ __FUNCT__32,1192 PetscErrorCode RGFinalizePackage(void)RGFinalizePackage41,1424 #undef __FUNCT____FUNCT__52,1674 #define __FUNCT__ __FUNCT__53,1691 PetscErrorCode RGInitializePackage(void)RGInitializePackage63,2011 #undef __FUNCT____FUNCT__97,3129 #define __FUNCT__ __FUNCT__98,3146 PetscErrorCode RGCreate(MPI_Comm comm,RG *newrg)RGCreate114,3406 #undef __FUNCT____FUNCT__133,3862 #define __FUNCT__ __FUNCT__134,3879 PetscErrorCode RGSetOptionsPrefix(RG rg,const char *prefix)RGSetOptionsPrefix154,4391 #undef __FUNCT____FUNCT__164,4649 #define __FUNCT__ __FUNCT__165,4666 PetscErrorCode RGAppendOptionsPrefix(RG rg,const char *prefix)RGAppendOptionsPrefix184,5184 #undef __FUNCT____FUNCT__194,5448 #define __FUNCT__ __FUNCT__195,5465 PetscErrorCode RGGetOptionsPrefix(RG rg,const char *prefix[])RGGetOptionsPrefix216,5957 #undef __FUNCT____FUNCT__227,6248 #define __FUNCT__ __FUNCT__228,6265 PetscErrorCode RGSetType(RG rg,RGType type)RGSetType242,6506 #undef __FUNCT____FUNCT__265,7289 #define __FUNCT__ __FUNCT__266,7306 PetscErrorCode RGGetType(RG rg,RGType *type)RGGetType282,7582 #undef __FUNCT____FUNCT__291,7794 #define __FUNCT__ __FUNCT__292,7811 PetscErrorCode RGSetFromOptions(RG rg)RGSetFromOptions306,8085 #undef __FUNCT____FUNCT__342,9420 #define __FUNCT__ __FUNCT__343,9437 PetscErrorCode RGView(RG rg,PetscViewer viewer)RGView366,10093 #undef __FUNCT____FUNCT__394,11163 #define __FUNCT__ __FUNCT__395,11180 PetscErrorCode RGIsTrivial(RG rg,PetscBool *trivial)RGIsTrivial411,11592 #undef __FUNCT____FUNCT__425,11944 #define __FUNCT__ __FUNCT__426,11961 PetscErrorCode RGCheckInside(RG rg,PetscInt n,PetscScalar *ar,PetscScalar *ai,PetscInt *inside)RGCheckInside452,12711 #undef __FUNCT____FUNCT__485,13494 #define __FUNCT__ __FUNCT__486,13511 PetscErrorCode RGComputeContour(RG rg,PetscInt n,PetscScalar *cr,PetscScalar *ci)RGComputeContour503,13889 #undef __FUNCT____FUNCT__523,14371 #define __FUNCT__ __FUNCT__524,14388 PetscErrorCode RGSetComplement(RG rg,PetscBool flg)RGSetComplement542,14803 #undef __FUNCT____FUNCT__551,15022 #define __FUNCT__ __FUNCT__552,15039 PetscErrorCode RGGetComplement(RG rg,PetscBool *flg)RGGetComplement569,15342 #undef __FUNCT____FUNCT__578,15546 #define __FUNCT__ __FUNCT__579,15563 PetscErrorCode RGSetScale(RG rg,PetscReal sfactor)RGSetScale597,15986 #undef __FUNCT____FUNCT__610,16439 #define __FUNCT__ __FUNCT__611,16456 PetscErrorCode RGGetScale(RG rg,PetscReal *sfactor)RGGetScale627,16687 #undef __FUNCT____FUNCT__636,16895 #define __FUNCT__ __FUNCT__637,16912 PetscErrorCode RGPushScale(RG rg,PetscReal sfactor)RGPushScale658,17434 #undef __FUNCT____FUNCT__670,17973 #define __FUNCT__ __FUNCT__671,17990 PetscErrorCode RGPopScale(RG rg)RGPopScale684,18206 #undef __FUNCT____FUNCT__694,18500 #define __FUNCT__ __FUNCT__695,18517 PetscErrorCode RGDestroy(RG *rg)RGDestroy708,18735 #undef __FUNCT____FUNCT__721,19133 #define __FUNCT__ __FUNCT__722,19150 PetscErrorCode RGRegister(const char *name,PetscErrorCode (*function)(RG))RGRegister739,19500 src/sys/classes/rg/interface/rgregis.c,129 rgregis.c:^?rgregis.c^A,1 #undef __FUNCT____FUNCT__29,1183 #define __FUNCT__ __FUNCT__30,1200 PetscErrorCode RGRegisterAll(void)RGRegisterAll38,1349 src/sys/classes/rg/makefile,258 makefile:^?makefile^A,1 SOURCEH = ../../../../include/slepc/private/rgimpl.h ../../../../include/slepcrg.h ../../../../include/slepcrgtypes.hSOURCEH24,936 DIRS = interface impls examplesDIRS25,1055 LOCDIR = src/sys/classes/rg/LOCDIR26,1091 MANSEC = RGMANSEC27,1122 src/sys/classes/st/examples/makefile,83 makefile:^?makefile^A,1 LOCDIR = src/sys/classes/st/examples/LOCDIR24,932 DIRS = testsDIRS25,972 src/sys/classes/st/examples/tests/makefile,471 makefile:^?makefile^A,1 CFLAGS =CFLAGS22,926 FFLAGS =FFLAGS23,939 CPPFLAGS =CPPFLAGS24,952 FPPFLAGS =FPPFLAGS25,965 LOCDIR = src/sys/classes/st/examples/tests/LOCDIR26,978 EXAMPLESC = test1.c test2.c test3.c test4.cEXAMPLESC27,1026 EXAMPLESF =EXAMPLESF28,1071 MANSEC = STMANSEC29,1084 TESTS = test1 test2 test3 test4TESTS30,1100 TESTEXAMPLES_C = test1.PETSc runtest1_1 runtest1_2 test1.rm \TESTEXAMPLES_C32,1138 TESTCODE = \TESTCODE57,1934 src/sys/classes/st/examples/tests/test1.c,1000 test1.c:^?test1.c^A,1 static char help[] = "Test ST with shell matrices.\n\n";help22,924 #undef __FUNCT____FUNCT__31,1264 #define __FUNCT__ __FUNCT__32,1281 static PetscErrorCode MyShellMatCreate(Mat *A,Mat *M)MyShellMatCreate33,1318 #undef __FUNCT____FUNCT__51,2118 #define __FUNCT__ __FUNCT__52,2135 int main(int argc,char **argv)main53,2160 #undef __FUNCT____FUNCT__155,6124 #define __FUNCT__ __FUNCT__156,6141 static PetscErrorCode MatMult_Shell(Mat S,Vec x,Vec y)MatMult_Shell157,6175 #undef __FUNCT____FUNCT__168,6427 #define __FUNCT__ __FUNCT__169,6444 static PetscErrorCode MatMultTranspose_Shell(Mat S,Vec x,Vec y)MatMultTranspose_Shell170,6487 #undef __FUNCT____FUNCT__181,6757 #define __FUNCT__ __FUNCT__182,6774 static PetscErrorCode MatGetDiagonal_Shell(Mat S,Vec diag)MatGetDiagonal_Shell183,6815 #undef __FUNCT____FUNCT__194,7079 #define __FUNCT__ __FUNCT__195,7096 static PetscErrorCode MatDuplicate_Shell(Mat S,MatDuplicateOption op,Mat *M)MatDuplicate_Shell196,7135 src/sys/classes/st/examples/tests/test2.c,181 test2.c:^?test2.c^A,1 static char help[] = "Test ST with one matrix.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1000 #define __FUNCT__ __FUNCT__27,1017 int main(int argc,char **argv)main28,1042 src/sys/classes/st/examples/tests/test3.c,183 test3.c:^?test3.c^A,1 static char help[] = "Test ST with two matrices.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1002 #define __FUNCT__ __FUNCT__27,1019 int main(int argc,char **argv)main28,1044 src/sys/classes/st/examples/tests/test4.c,184 test4.c:^?test4.c^A,1 static char help[] = "Test ST with four matrices.\n\n";help22,924 #undef __FUNCT____FUNCT__26,1003 #define __FUNCT__ __FUNCT__27,1020 int main(int argc,char **argv)main28,1045 src/sys/classes/st/impls/cayley/cayley.c,2862 cayley.c:^?cayley.c^A,1 PetscScalar nu;nu27,1054 PetscBool nu_set;nu_set28,1072 Vec w2;w229,1094 } ST_CAYLEY;ST_CAYLEY30,1112 #undef __FUNCT____FUNCT__32,1126 #define __FUNCT__ __FUNCT__33,1143 PetscErrorCode STApply_Cayley(ST st,Vec x,Vec y)STApply_Cayley34,1178 #undef __FUNCT____FUNCT__46,1518 #define __FUNCT__ __FUNCT__47,1535 PetscErrorCode STApplyTranspose_Cayley(ST st,Vec x,Vec y)STApplyTranspose_Cayley48,1579 #undef __FUNCT____FUNCT__60,1953 #define __FUNCT__ __FUNCT__61,1970 static PetscErrorCode MatMult_Cayley(Mat B,Vec x,Vec y)MatMult_Cayley62,2005 #undef __FUNCT____FUNCT__89,2753 #define __FUNCT__ __FUNCT__90,2770 PetscErrorCode STGetBilinearForm_Cayley(ST st,Mat *B)STGetBilinearForm_Cayley91,2815 #undef __FUNCT____FUNCT__102,3061 #define __FUNCT__ __FUNCT__103,3078 PetscErrorCode STBackTransform_Cayley(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)STBackTransform_Cayley104,3121 #undef __FUNCT____FUNCT__134,3878 #define __FUNCT__ __FUNCT__135,3895 PetscErrorCode STPostSolve_Cayley(ST st)STPostSolve_Cayley136,3934 #undef __FUNCT____FUNCT__153,4361 #define __FUNCT__ __FUNCT__154,4378 PetscErrorCode STSetUp_Cayley(ST st)STSetUp_Cayley155,4413 #undef __FUNCT____FUNCT__198,6292 #define __FUNCT__ __FUNCT__199,6309 PetscErrorCode STSetShift_Cayley(ST st,PetscScalar newshift)STSetShift_Cayley200,6347 #undef __FUNCT____FUNCT__225,7275 #define __FUNCT__ __FUNCT__226,7292 PetscErrorCode STSetFromOptions_Cayley(PetscOptionItems *PetscOptionsObject,ST st)STSetFromOptions_Cayley227,7336 #undef __FUNCT____FUNCT__263,8612 #define __FUNCT__ __FUNCT__264,8629 static PetscErrorCode STCayleySetAntishift_Cayley(ST st,PetscScalar newshift)STCayleySetAntishift_Cayley265,8677 #undef __FUNCT____FUNCT__279,9085 #define __FUNCT__ __FUNCT__280,9102 PetscErrorCode STCayleySetAntishift(ST st,PetscScalar nu)STCayleySetAntishift303,9727 #undef __FUNCT____FUNCT__313,10045 #define __FUNCT__ __FUNCT__314,10062 static PetscErrorCode STCayleyGetAntishift_Cayley(ST st,PetscScalar *nu)STCayleyGetAntishift_Cayley315,10110 #undef __FUNCT____FUNCT__324,10295 #define __FUNCT__ __FUNCT__325,10312 PetscErrorCode STCayleyGetAntishift(ST st,PetscScalar *nu)STCayleyGetAntishift342,10670 #undef __FUNCT____FUNCT__353,10978 #define __FUNCT__ __FUNCT__354,10995 PetscErrorCode STView_Cayley(ST st,PetscViewer viewer)STView_Cayley355,11029 #undef __FUNCT____FUNCT__371,11537 #define __FUNCT__ __FUNCT__372,11554 PetscErrorCode STReset_Cayley(ST st)STReset_Cayley373,11589 #undef __FUNCT____FUNCT__383,11794 #define __FUNCT__ __FUNCT__384,11811 PetscErrorCode STDestroy_Cayley(ST st)STDestroy_Cayley385,11848 #undef __FUNCT____FUNCT__396,12204 #define __FUNCT__ __FUNCT__397,12221 PETSC_EXTERN PetscErrorCode STCreate_Cayley(ST st)STCreate_Cayley398,12257 src/sys/classes/st/impls/cayley/makefile,288 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = cayley.cSOURCEC26,958 SOURCEF =SOURCEF27,978 SOURCEH =SOURCEH28,989 LIBBASE = libslepcsysLIBBASE29,1000 DIRS =DIRS30,1023 MANSEC = STMANSEC31,1034 LOCDIR = src/sys/classes/st/impls/cayley/LOCDIR32,1048 src/sys/classes/st/impls/makefile,177 makefile:^?makefile^A,1 LIBBASE = libslepcsysLIBBASE24,936 DIRS = shell shift sinvert cayley precondDIRS25,959 LOCDIR = src/sys/classes/st/impls/LOCDIR26,1005 MANSEC = STMANSEC27,1042 src/sys/classes/st/impls/precond/makefile,290 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = precond.cSOURCEC26,958 SOURCEF =SOURCEF27,979 SOURCEH =SOURCEH28,990 LIBBASE = libslepcsysLIBBASE29,1001 DIRS =DIRS30,1024 MANSEC = STMANSEC31,1035 LOCDIR = src/sys/classes/st/impls/precond/LOCDIR32,1049 src/sys/classes/st/impls/precond/precond.c,2389 precond.c:^?precond.c^A,1 PetscBool setmat;setmat27,1075 } ST_PRECOND;ST_PRECOND28,1095 #undef __FUNCT____FUNCT__30,1110 #define __FUNCT__ __FUNCT__31,1127 static PetscErrorCode STSetDefaultPrecond(ST st)STSetDefaultPrecond32,1167 #undef __FUNCT____FUNCT__60,2042 #define __FUNCT__ __FUNCT__61,2059 PetscErrorCode STSetFromOptions_Precond(PetscOptionItems *PetscOptionsObject,ST st)STSetFromOptions_Precond62,2104 #undef __FUNCT____FUNCT__71,2313 #define __FUNCT__ __FUNCT__72,2330 PetscErrorCode STSetUp_Precond(ST st)STSetUp_Precond73,2366 #undef __FUNCT____FUNCT__157,5248 #define __FUNCT__ __FUNCT__158,5265 PetscErrorCode STSetShift_Precond(ST st,PetscScalar newshift)STSetShift_Precond159,5304 #undef __FUNCT____FUNCT__173,5667 #define __FUNCT__ __FUNCT__174,5684 static PetscErrorCode STPrecondGetMatForPC_Precond(ST st,Mat *mat)STPrecondGetMatForPC_Precond175,5733 #undef __FUNCT____FUNCT__191,6178 #define __FUNCT__ __FUNCT__192,6195 PetscErrorCode STPrecondGetMatForPC(ST st,Mat *mat)STPrecondGetMatForPC209,6682 #undef __FUNCT____FUNCT__220,6971 #define __FUNCT__ __FUNCT__221,6988 static PetscErrorCode STPrecondSetMatForPC_Precond(ST st,Mat mat)STPrecondSetMatForPC_Precond222,7037 #undef __FUNCT____FUNCT__247,7911 #define __FUNCT__ __FUNCT__248,7928 PetscErrorCode STPrecondSetMatForPC(ST st,Mat mat)STPrecondSetMatForPC268,8604 #undef __FUNCT____FUNCT__280,8944 #define __FUNCT__ __FUNCT__281,8961 static PetscErrorCode STPrecondSetKSPHasMat_Precond(ST st,PetscBool setmat)STPrecondSetKSPHasMat_Precond282,9011 #undef __FUNCT____FUNCT__291,9210 #define __FUNCT__ __FUNCT__292,9227 PetscErrorCode STPrecondSetKSPHasMat(ST st,PetscBool setmat)STPrecondSetKSPHasMat313,9828 #undef __FUNCT____FUNCT__324,10155 #define __FUNCT__ __FUNCT__325,10172 static PetscErrorCode STPrecondGetKSPHasMat_Precond(ST st,PetscBool *setmat)STPrecondGetKSPHasMat_Precond326,10222 #undef __FUNCT____FUNCT__335,10423 #define __FUNCT__ __FUNCT__336,10440 PetscErrorCode STPrecondGetKSPHasMat(ST st,PetscBool *setmat)STPrecondGetKSPHasMat354,10859 #undef __FUNCT____FUNCT__365,11171 #define __FUNCT__ __FUNCT__366,11188 PetscErrorCode STDestroy_Precond(ST st)STDestroy_Precond367,11226 #undef __FUNCT____FUNCT__380,11781 #define __FUNCT__ __FUNCT__381,11798 PETSC_EXTERN PetscErrorCode STCreate_Precond(ST st)STCreate_Precond382,11835 src/sys/classes/st/impls/shell/ftn-custom/makefile,271 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zshell.cSOURCEC26,996 SOURCEF =SOURCEF27,1016 SOURCEH =SOURCEH28,1027 DIRS =DIRS29,1038 LIBBASE = libslepcsysLIBBASE30,1049 LOCDIR = src/sys/classes/st/impls/shell/ftn-custom/LOCDIR31,1072 src/sys/classes/st/impls/shell/ftn-custom/zshell.c,1868 zshell.c:^?zshell.c^A,1 PetscFortranCallbackId apply;apply38,1530 PetscFortranCallbackId applytranspose;applytranspose39,1562 PetscFortranCallbackId backtransform;backtransform40,1603 } _cb;_cb41,1643 #undef __FUNCT____FUNCT__44,1743 static PetscErrorCode ourshellapply(ST st,Vec x,Vec y)ourshellapply46,1794 #undef __FUNCT____FUNCT__51,1951 static PetscErrorCode ourshellapplytranspose(ST st,Vec x,Vec y)ourshellapplytranspose53,2011 #undef __FUNCT____FUNCT__58,2186 static PetscErrorCode ourshellbacktransform(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)ourshellbacktransform60,2245 PETSC_EXTERN void PETSC_STDCALL stshellgetcontext_(ST *st,void **ctx,PetscErrorCode *ierr)stshellgetcontext_65,2486 PETSC_EXTERN void PETSC_STDCALL stshellsetapply_(ST *st,void (PETSC_STDCALL *apply)(void*,Vec*,Vec*,PetscErrorCode*),PetscErrorCode *ierr)stshellsetapply_70,2620 PETSC_EXTERN void PETSC_STDCALL stshellsetapplytranspose_(ST *st,void (PETSC_STDCALL *applytranspose)(void*,Vec*,Vec*,PetscErrorCode*),PetscErrorCode *ierr)stshellsetapplytranspose_76,2958 PETSC_EXTERN void PETSC_STDCALL stshellsetbacktransform_(ST *st,void (PETSC_STDCALL *backtransform)(void*,PetscScalar*,PetscScalar*,PetscErrorCode*),PetscErrorCode *ierr)stshellsetbacktransform_82,3350 src/sys/classes/st/impls/shell/makefile,285 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = shell.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = STMANSEC31,1033 LOCDIR = src/sys/classes/st/impls/shell/LOCDIR32,1047 src/sys/classes/st/impls/shell/shell.c,2834 shell.c:^?shell.c^A,1 void *ctx; /* user provided context */ctx29,1150 PetscErrorCode (*apply)(ST,Vec,Vec);apply30,1223 PetscErrorCode (*applytrans)(ST,Vec,Vec);applytrans31,1262 PetscErrorCode (*backtransform)(ST,PetscInt n,PetscScalar*,PetscScalar*);backtransform32,1306 } ST_SHELL;ST_SHELL33,1382 #undef __FUNCT____FUNCT__35,1395 #define __FUNCT__ __FUNCT__36,1412 PetscErrorCode STShellGetContext(ST st,void **ctx)STShellGetContext55,1808 #undef __FUNCT____FUNCT__69,2179 #define __FUNCT__ __FUNCT__70,2196 PetscErrorCode STShellSetContext(ST st,void *ctx)STShellSetContext89,2654 #undef __FUNCT____FUNCT__102,3001 #define __FUNCT__ __FUNCT__103,3018 PetscErrorCode STApply_Shell(ST st,Vec x,Vec y)STApply_Shell104,3052 #undef __FUNCT____FUNCT__122,3786 #define __FUNCT__ __FUNCT__123,3803 PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y)STApplyTranspose_Shell124,3846 #undef __FUNCT____FUNCT__142,4609 #define __FUNCT__ __FUNCT__143,4626 PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)STBackTransform_Shell144,4668 #undef __FUNCT____FUNCT__154,5029 #define __FUNCT__ __FUNCT__155,5046 PetscErrorCode STDestroy_Shell(ST st)STDestroy_Shell156,5082 #undef __FUNCT____FUNCT__168,5537 #define __FUNCT__ __FUNCT__169,5554 static PetscErrorCode STShellSetApply_Shell(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))STShellSetApply_Shell170,5596 #undef __FUNCT____FUNCT__179,5802 #define __FUNCT__ __FUNCT__180,5819 static PetscErrorCode STShellSetApplyTranspose_Shell(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))STShellSetApplyTranspose_Shell181,5870 #undef __FUNCT____FUNCT__190,6100 #define __FUNCT__ __FUNCT__191,6117 static PetscErrorCode STShellSetBackTransform_Shell(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))STShellSetBackTransform_Shell192,6167 #undef __FUNCT____FUNCT__201,6418 #define __FUNCT__ __FUNCT__202,6435 PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))STShellSetApply224,7019 #undef __FUNCT____FUNCT__234,7325 #define __FUNCT__ __FUNCT__235,7342 PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))STShellSetApplyTranspose257,7961 #undef __FUNCT____FUNCT__267,8295 #define __FUNCT__ __FUNCT__268,8312 PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))STShellSetBackTransform291,9009 #undef __FUNCT____FUNCT__301,9387 #define __FUNCT__ __FUNCT__302,9404 PetscErrorCode STSetFromOptions_Shell(PetscOptionItems *PetscOptionsObject,ST st)STSetFromOptions_Shell303,9447 #undef __FUNCT____FUNCT__348,10962 #define __FUNCT__ __FUNCT__349,10979 PETSC_EXTERN PetscErrorCode STCreate_Shell(ST st)STCreate_Shell350,11014 src/sys/classes/st/impls/shift/makefile,285 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = shift.cSOURCEC26,958 SOURCEF =SOURCEF27,977 SOURCEH =SOURCEH28,988 LIBBASE = libslepcsysLIBBASE29,999 DIRS =DIRS30,1022 MANSEC = STMANSEC31,1033 LOCDIR = src/sys/classes/st/impls/shift/LOCDIR32,1047 src/sys/classes/st/impls/shift/shift.c,1259 shift.c:^?shift.c^A,1 #undef __FUNCT____FUNCT__27,1082 #define __FUNCT__ __FUNCT__28,1099 PetscErrorCode STApply_Shift(ST st,Vec x,Vec y)STApply_Shift29,1133 #undef __FUNCT____FUNCT__45,1546 #define __FUNCT__ __FUNCT__46,1563 PetscErrorCode STApplyTranspose_Shift(ST st,Vec x,Vec y)STApplyTranspose_Shift47,1606 #undef __FUNCT____FUNCT__63,2060 #define __FUNCT__ __FUNCT__64,2077 PetscErrorCode STBackTransform_Shift(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)STBackTransform_Shift65,2119 #undef __FUNCT____FUNCT__76,2330 #define __FUNCT__ __FUNCT__77,2347 PetscErrorCode STPostSolve_Shift(ST st)STPostSolve_Shift78,2385 #undef __FUNCT____FUNCT__95,2811 #define __FUNCT__ __FUNCT__96,2828 PetscErrorCode STSetUp_Shift(ST st)STSetUp_Shift97,2862 #undef __FUNCT____FUNCT__145,4501 #define __FUNCT__ __FUNCT__146,4518 PetscErrorCode STSetShift_Shift(ST st,PetscScalar newshift)STSetShift_Shift147,4555 #undef __FUNCT____FUNCT__171,5347 #define __FUNCT__ __FUNCT__172,5364 PetscErrorCode STSetFromOptions_Shift(PetscOptionItems *PetscOptionsObject,ST st)STSetFromOptions_Shift173,5407 #undef __FUNCT____FUNCT__199,6265 #define __FUNCT__ __FUNCT__200,6282 PETSC_EXTERN PetscErrorCode STCreate_Shift(ST st)STCreate_Shift201,6317 src/sys/classes/st/impls/sinvert/makefile,290 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = sinvert.cSOURCEC26,958 SOURCEF =SOURCEF27,979 SOURCEH =SOURCEH28,990 LIBBASE = libslepcsysLIBBASE29,1001 DIRS =DIRS30,1024 MANSEC = STMANSEC31,1035 LOCDIR = src/sys/classes/st/impls/sinvert/LOCDIR32,1049 src/sys/classes/st/impls/sinvert/sinvert.c,1294 sinvert.c:^?sinvert.c^A,1 #undef __FUNCT____FUNCT__26,1033 #define __FUNCT__ __FUNCT__27,1050 PetscErrorCode STApply_Sinvert(ST st,Vec x,Vec y)STApply_Sinvert28,1086 #undef __FUNCT____FUNCT__44,1501 #define __FUNCT__ __FUNCT__45,1518 PetscErrorCode STApplyTranspose_Sinvert(ST st,Vec x,Vec y)STApplyTranspose_Sinvert46,1563 #undef __FUNCT____FUNCT__62,2016 #define __FUNCT__ __FUNCT__63,2033 PetscErrorCode STBackTransform_Sinvert(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)STBackTransform_Sinvert64,2077 #undef __FUNCT____FUNCT__89,2632 #define __FUNCT__ __FUNCT__90,2649 PetscErrorCode STPostSolve_Sinvert(ST st)STPostSolve_Sinvert91,2689 #undef __FUNCT____FUNCT__108,3117 #define __FUNCT__ __FUNCT__109,3134 PetscErrorCode STSetUp_Sinvert(ST st)STSetUp_Sinvert110,3170 #undef __FUNCT____FUNCT__158,4868 #define __FUNCT__ __FUNCT__159,4885 PetscErrorCode STSetShift_Sinvert(ST st,PetscScalar newshift)STSetShift_Sinvert160,4924 #undef __FUNCT____FUNCT__194,6084 #define __FUNCT__ __FUNCT__195,6101 PetscErrorCode STSetFromOptions_Sinvert(PetscOptionItems *PetscOptionsObject,ST st)STSetFromOptions_Sinvert196,6146 #undef __FUNCT____FUNCT__222,7006 #define __FUNCT__ __FUNCT__223,7023 PETSC_EXTERN PetscErrorCode STCreate_Sinvert(ST st)STCreate_Sinvert224,7060 src/sys/classes/st/interface/ftn-custom/makefile,267 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zstf.cSOURCEC26,996 SOURCEF =SOURCEF27,1014 SOURCEH =SOURCEH28,1025 DIRS =DIRS29,1036 LIBBASE = libslepcsysLIBBASE30,1047 LOCDIR = src/sys/classes/st/interface/ftn-custom/LOCDIR31,1070 src/sys/classes/st/interface/ftn-custom/zstf.c,1452 zstf.c:^?zstf.c^A,1 PETSC_EXTERN void PETSC_STDCALL stsettype_(ST *st,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))stsettype_41,1658 PETSC_EXTERN void PETSC_STDCALL stgettype_(ST *st,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))stgettype_50,1868 PETSC_EXTERN void PETSC_STDCALL stsetoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))stsetoptionsprefix_59,2142 PETSC_EXTERN void PETSC_STDCALL stappendoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))stappendoptionsprefix_68,2376 PETSC_EXTERN void PETSC_STDCALL stgetoptionsprefix_(ST *st,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))stgetoptionsprefix_77,2616 PETSC_EXTERN void PETSC_STDCALL stview_(ST *st,PetscViewer *viewer,PetscErrorCode *ierr)stview_86,2919 src/sys/classes/st/interface/makefile,337 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = stfunc.c stset.c stsolve.c stsles.c stregis.c stshellmat.cSOURCEC26,958 SOURCEF =SOURCEF27,1028 SOURCEH =SOURCEH28,1039 LIBBASE = libslepcsysLIBBASE29,1050 DIRS =DIRS30,1073 MANSEC = STMANSEC31,1084 LOCDIR = src/sys/classes/st/interface/LOCDIR32,1098 src/sys/classes/st/interface/stfunc.c,5117 stfunc.c:^?stfunc.c^A,1 PetscClassId ST_CLASSID = 0;ST_CLASSID26,1067 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_SetUp27,1100 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_Apply27,1100 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_ApplyTranspose27,1100 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_MatSetUp27,1100 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_MatMult27,1100 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_MatMultTranspose27,1100 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_MatSolve27,1100 PetscLogEvent ST_SetUp = 0,ST_Apply = 0,ST_ApplyTranspose = 0,ST_MatSetUp = 0,ST_MatMult = 0,ST_MatMultTranspose = 0,ST_MatSolve = 0,ST_MatSolveTranspose = 0;ST_MatSolveTranspose27,1100 static PetscBool STPackageInitialized = PETSC_FALSE;STPackageInitialized28,1262 #undef __FUNCT____FUNCT__30,1316 #define __FUNCT__ __FUNCT__31,1333 PetscErrorCode STFinalizePackage(void)STFinalizePackage40,1565 #undef __FUNCT____FUNCT__51,1815 #define __FUNCT__ __FUNCT__52,1832 PetscErrorCode STInitializePackage(void)STInitializePackage62,2156 #undef __FUNCT____FUNCT__105,4006 #define __FUNCT__ __FUNCT__106,4023 PetscErrorCode STReset(ST st)STReset119,4258 #undef __FUNCT____FUNCT__134,4730 #define __FUNCT__ __FUNCT__135,4747 PetscErrorCode STDestroy(ST *st)STDestroy148,4993 #undef __FUNCT____FUNCT__167,5695 #define __FUNCT__ __FUNCT__168,5712 PetscErrorCode STCreate(MPI_Comm comm,ST *newst)STCreate184,6032 #undef __FUNCT____FUNCT__218,6914 #define __FUNCT__ __FUNCT__219,6931 PetscErrorCode STSetOperators(ST st,PetscInt n,Mat A[])STSetOperators238,7462 #undef __FUNCT____FUNCT__282,9002 #define __FUNCT__ __FUNCT__283,9019 PetscErrorCode STGetOperators(ST st,PetscInt k,Mat *A)STGetOperators300,9464 #undef __FUNCT____FUNCT__313,9995 #define __FUNCT__ __FUNCT__314,10012 PetscErrorCode STGetTOperators(ST st,PetscInt k,Mat *T)STGetTOperators331,10459 #undef __FUNCT____FUNCT__344,10935 #define __FUNCT__ __FUNCT__345,10952 PetscErrorCode STGetNumMatrices(ST st,PetscInt *n)STGetNumMatrices361,11284 #undef __FUNCT____FUNCT__370,11476 #define __FUNCT__ __FUNCT__371,11493 PetscErrorCode STSetShift(ST st,PetscScalar shift)STSetShift392,12086 #undef __FUNCT____FUNCT__409,12514 #define __FUNCT__ __FUNCT__410,12531 PetscErrorCode STGetShift(ST st,PetscScalar* shift)STGetShift426,12834 #undef __FUNCT____FUNCT__435,13042 #define __FUNCT__ __FUNCT__436,13059 PetscErrorCode STSetDefaultShift(ST st,PetscScalar defaultshift)STSetDefaultShift451,13407 #undef __FUNCT____FUNCT__460,13657 #define __FUNCT__ __FUNCT__461,13674 PetscErrorCode STScaleShift(ST st,PetscScalar factor)STScaleShift479,14053 #undef __FUNCT____FUNCT__488,14278 #define __FUNCT__ __FUNCT__489,14295 PetscErrorCode STSetBalanceMatrix(ST st,Vec D)STSetBalanceMatrix509,14862 #undef __FUNCT____FUNCT__524,15257 #define __FUNCT__ __FUNCT__525,15274 PetscErrorCode STGetBalanceMatrix(ST st,Vec *D)STGetBalanceMatrix544,15750 #undef __FUNCT____FUNCT__553,15936 #define __FUNCT__ __FUNCT__554,15953 PetscErrorCode STMatCreateVecs(ST st,Vec *right,Vec *left)STMatCreateVecs569,16344 #undef __FUNCT____FUNCT__579,16564 #define __FUNCT__ __FUNCT__580,16581 PetscErrorCode STMatGetSize(ST st,PetscInt *m,PetscInt *n)STMatGetSize595,16896 #undef __FUNCT____FUNCT__605,17106 #define __FUNCT__ __FUNCT__606,17123 PetscErrorCode STMatGetLocalSize(ST st,PetscInt *m,PetscInt *n)STMatGetLocalSize621,17452 #undef __FUNCT____FUNCT__631,17673 #define __FUNCT__ __FUNCT__632,17690 PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix)STSetOptionsPrefix652,18241 #undef __FUNCT____FUNCT__665,18685 #define __FUNCT__ __FUNCT__666,18702 PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix)STAppendOptionsPrefix686,19262 #undef __FUNCT____FUNCT__699,19731 #define __FUNCT__ __FUNCT__700,19748 PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[])STGetOptionsPrefix721,20258 #undef __FUNCT____FUNCT__732,20549 #define __FUNCT__ __FUNCT__733,20566 PetscErrorCode STView(ST st,PetscViewer viewer)STView758,21264 #undef __FUNCT____FUNCT__821,24039 #define __FUNCT__ __FUNCT__822,24056 PetscErrorCode STRegister(const char *name,PetscErrorCode (*function)(ST))STRegister850,24719 src/sys/classes/st/interface/stregis.c,129 stregis.c:^?stregis.c^A,1 #undef __FUNCT____FUNCT__30,1238 #define __FUNCT__ __FUNCT__31,1255 PetscErrorCode STRegisterAll(void)STRegisterAll41,1445 src/sys/classes/st/interface/stset.c,1451 stset.c:^?stset.c^A,1 PetscBool STRegisterAllCalled = PETSC_FALSE;STRegisterAllCalled26,1029 PetscFunctionList STList = 0;STList27,1082 #undef __FUNCT____FUNCT__29,1113 #define __FUNCT__ __FUNCT__30,1130 PetscErrorCode STSetType(ST st,STType type)STSetType58,1871 #undef __FUNCT____FUNCT__82,2686 #define __FUNCT__ __FUNCT__83,2703 PetscErrorCode STGetType(ST st,STType *type)STGetType100,3014 #undef __FUNCT____FUNCT__109,3226 #define __FUNCT__ __FUNCT__110,3243 PetscErrorCode STSetFromOptions(ST st)STSetFromOptions123,3574 #undef __FUNCT____FUNCT__177,5872 #define __FUNCT__ __FUNCT__178,5889 PetscErrorCode STSetMatStructure(ST st,MatStructure str)STSetMatStructure207,6921 #undef __FUNCT____FUNCT__224,7395 #define __FUNCT__ __FUNCT__225,7412 PetscErrorCode STGetMatStructure(ST st,MatStructure *str)STGetMatStructure243,7888 #undef __FUNCT____FUNCT__252,8090 #define __FUNCT__ __FUNCT__253,8107 PetscErrorCode STSetMatMode(ST st,STMatMode mode)STSetMatMode292,9674 #undef __FUNCT____FUNCT__302,9927 #define __FUNCT__ __FUNCT__303,9944 PetscErrorCode STGetMatMode(ST st,STMatMode *mode)STGetMatMode320,10293 #undef __FUNCT____FUNCT__329,10499 #define __FUNCT__ __FUNCT__330,10516 PetscErrorCode STSetTransform(ST st,PetscBool flg)STSetTransform354,11263 #undef __FUNCT____FUNCT__366,11550 #define __FUNCT__ __FUNCT__367,11567 PetscErrorCode STGetTransform(ST st,PetscBool *flg)STGetTransform384,11892 src/sys/classes/st/interface/stshellmat.c,1229 stshellmat.c:^?stshellmat.c^A,1 PetscScalar alpha;alpha29,1185 PetscScalar *coeffs;coeffs30,1206 ST st;st31,1229 Vec z;z32,1247 PetscInt nmat;nmat33,1264 PetscInt *matIdx;matIdx34,1284 } ST_SHELLMAT;ST_SHELLMAT35,1307 #undef __FUNCT____FUNCT__37,1323 #define __FUNCT__ __FUNCT__38,1340 PetscErrorCode STMatShellShift(Mat A,PetscScalar alpha)STMatShellShift39,1376 #undef __FUNCT____FUNCT__50,1613 #define __FUNCT__ __FUNCT__51,1630 static PetscErrorCode MatMult_Shell(Mat A,Vec x,Vec y)MatMult_Shell56,1790 #undef __FUNCT____FUNCT__85,2608 #define __FUNCT__ __FUNCT__86,2625 static PetscErrorCode MatMultTranspose_Shell(Mat A,Vec x,Vec y)MatMultTranspose_Shell87,2668 #undef __FUNCT____FUNCT__116,3513 #define __FUNCT__ __FUNCT__117,3530 static PetscErrorCode MatGetDiagonal_Shell(Mat A,Vec diag)MatGetDiagonal_Shell118,3571 #undef __FUNCT____FUNCT__151,4562 #define __FUNCT__ __FUNCT__152,4579 static PetscErrorCode MatDestroy_Shell(Mat A)MatDestroy_Shell153,4616 #undef __FUNCT____FUNCT__167,4998 #define __FUNCT__ __FUNCT__168,5015 PetscErrorCode STMatShellCreate(ST st,PetscScalar alpha,PetscInt nmat,PetscInt *matIdx,PetscScalar *coeffs,Mat *mat)STMatShellCreate169,5052 src/sys/classes/st/interface/stsles.c,1472 stsles.c:^?stsles.c^A,1 #undef __FUNCT____FUNCT__27,1095 #define __FUNCT__ __FUNCT__28,1112 PetscErrorCode STMatMult(ST st,PetscInt k,Vec x,Vec y)STMatMult47,1524 #undef __FUNCT____FUNCT__75,2553 #define __FUNCT__ __FUNCT__76,2570 PetscErrorCode STMatMultTranspose(ST st,PetscInt k,Vec x,Vec y)STMatMultTranspose95,2992 #undef __FUNCT____FUNCT__123,4057 #define __FUNCT__ __FUNCT__124,4074 PetscErrorCode STMatSolve(ST st,Vec b,Vec x)STMatSolve142,4474 #undef __FUNCT____FUNCT__174,5677 #define __FUNCT__ __FUNCT__175,5694 PetscErrorCode STMatSolveTranspose(ST st,Vec b,Vec x)STMatSolveTranspose193,6104 #undef __FUNCT____FUNCT__225,7343 #define __FUNCT__ __FUNCT__226,7360 PetscErrorCode STMatSetHermitian(ST st,Mat M)STMatSetHermitian234,7550 #undef __FUNCT____FUNCT__257,8205 #define __FUNCT__ __FUNCT__258,8222 PetscErrorCode STCheckFactorPackage(ST st)STCheckFactorPackage259,8263 #undef __FUNCT____FUNCT__279,9093 #define __FUNCT__ __FUNCT__280,9110 PetscErrorCode STSetKSP(ST st,KSP ksp)STSetKSP293,9374 #undef __FUNCT____FUNCT__308,9824 #define __FUNCT__ __FUNCT__309,9841 PetscErrorCode STGetKSP(ST st,KSP* ksp)STGetKSP324,10126 #undef __FUNCT____FUNCT__343,10872 #define __FUNCT__ __FUNCT__344,10889 PetscErrorCode STCheckNullSpace_Default(ST st,BV V)STCheckNullSpace_Default345,10934 #undef __FUNCT____FUNCT__387,12317 #define __FUNCT__ __FUNCT__388,12334 PetscErrorCode STCheckNullSpace(ST st,BV V)STCheckNullSpace409,12970 src/sys/classes/st/interface/stsolve.c,1764 stsolve.c:^?stsolve.c^A,1 #undef __FUNCT____FUNCT__26,1067 #define __FUNCT__ __FUNCT__27,1084 PetscErrorCode STApply(ST st,Vec x,Vec y)STApply46,1515 #undef __FUNCT____FUNCT__76,2599 #define __FUNCT__ __FUNCT__77,2616 PetscErrorCode STApplyTranspose(ST st,Vec x,Vec y)STApplyTranspose96,3050 #undef __FUNCT____FUNCT__126,4181 #define __FUNCT__ __FUNCT__127,4198 PetscErrorCode STGetBilinearForm(ST st,Mat *B)STGetBilinearForm146,4669 #undef __FUNCT____FUNCT__159,4971 #define __FUNCT__ __FUNCT__160,4988 PetscErrorCode STGetBilinearForm_Default(ST st,Mat *B)STGetBilinearForm_Default161,5034 #undef __FUNCT____FUNCT__174,5292 #define __FUNCT__ __FUNCT__175,5309 PetscErrorCode STComputeExplicitOperator(ST st,Mat *mat)STComputeExplicitOperator200,6036 #undef __FUNCT____FUNCT__254,8127 #define __FUNCT__ __FUNCT__255,8144 PetscErrorCode STSetUp(ST st)STSetUp268,8396 #undef __FUNCT____FUNCT__307,9911 #define __FUNCT__ __FUNCT__308,9928 PetscErrorCode STMatMAXPY_Private(ST st,PetscScalar alpha,PetscScalar beta,PetscInt k,PetscScalar *coeffs,PetscBool initial,Mat *S)STMatMAXPY_Private319,10374 #undef __FUNCT____FUNCT__401,13305 #define __FUNCT__ __FUNCT__402,13322 PetscErrorCode STCoeffs_Monomial(ST st, PetscScalar *coeffs)STCoeffs_Monomial407,13475 #undef __FUNCT____FUNCT__424,13909 #define __FUNCT__ __FUNCT__425,13926 PetscErrorCode STPostSolve(ST st)STPostSolve439,14245 #undef __FUNCT____FUNCT__452,14509 #define __FUNCT__ __FUNCT__453,14526 PetscErrorCode STBackTransform(ST st,PetscInt n,PetscScalar* eigr,PetscScalar* eigi)STBackTransform468,14958 #undef __FUNCT____FUNCT__481,15293 #define __FUNCT__ __FUNCT__482,15310 PetscErrorCode STMatSetUp(ST st,PetscScalar sigma,PetscScalar *coeffs)STMatSetUp505,15914 src/sys/classes/st/makefile,223 makefile:^?makefile^A,1 SOURCEH = ../../../../include/slepc/private/stimpl.h ../../../../include/slepcst.hSOURCEH24,936 DIRS = interface impls examplesDIRS25,1020 LOCDIR = src/sys/classes/st/LOCDIR26,1056 MANSEC = STMANSEC27,1087 src/sys/dlregisslepc.c,209 dlregisslepc.c:^?dlregisslepc.c^A,1 #undef __FUNCT____FUNCT__38,1454 #define __FUNCT__ __FUNCT__40,1509 #define __FUNCT__ __FUNCT__42,1564 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_slepc(void)PetscDLLibraryRegister_slepc51,1830 src/sys/f90-mod/makefile,397 makefile:^?makefile^A,1 SPECIALLIB = yesSPECIALLIB28,1120 SPECIALFASTLIB = yesSPECIALFASTLIB29,1141 CFLAGS =CFLAGS32,1164 FFLAGS =FFLAGS33,1177 SOURCEC =SOURCEC34,1190 SOURCEF = slepcsysmod.FSOURCEF35,1203 SOURCEH =SOURCEH36,1230 LIBBASE = libslepcsysLIBBASE37,1243 MANSEC = sysMANSEC38,1268 LOCDIR = src/sys/f90-mod/LOCDIR39,1285 CLEANFILES = *.modCLEANFILES40,1315 src/sys/f90-mod/slepcsysmod.F,507 slepcsysmod.F:^?slepcsysmod.F^A,1 module slepcsysdefslepcsysdef22,965 module slepcsysslepcsys26,1049 module slepcrgdefslepcrgdef30,1117 module slepcrgslepcrg35,1251 module slepcfndefslepcfndef40,1355 module slepcfnslepcfn45,1489 module slepcdsdefslepcdsdef50,1593 module slepcdsslepcds57,1768 module slepcbvdefslepcbvdef62,1872 module slepcbvslepcbv67,2006 module slepcstdefslepcstdef72,2110 module slepcstslepcst78,2265 src/sys/ftn-custom/makefile,313 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,974 FFLAGS =FFLAGS25,985 SOURCEC = zslepcutil.c zslepc_start.c zslepc_startf.cSOURCEC26,996 SOURCEF =SOURCEF27,1051 SOURCEH =SOURCEH28,1062 DIRS =DIRS29,1073 LIBBASE = libslepcsysLIBBASE30,1084 MANSEC = sysMANSEC31,1107 LOCDIR = src/sys/ftn-custom/LOCDIR32,1122 src/sys/ftn-custom/zslepc_start.c,351 zslepc_start.c:^?zslepc_start.c^A,1 PETSC_EXTERN void PETSC_STDCALL slepcinitialize_(CHAR filename PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))PETSC_END_LEN43,1646 src/sys/ftn-custom/zslepc_startf.c,315 zslepc_startf.c:^?zslepc_startf.c^A,1 PetscErrorCode SlepcInitializeFortran(void)SlepcInitializeFortran50,1808 PETSC_EXTERN void PETSC_STDCALL slepcinitializefortran_(PetscErrorCode *info)slepcinitializefortran_56,1897 src/sys/ftn-custom/zslepcutil.c,559 zslepcutil.c:^?zslepcutil.c^A,1 PETSC_EXTERN void PETSC_STDCALL slepcconvmonitorcreate_(PetscViewer *vin,PetscViewerFormat *format,SlepcConvMonitor *ctx,PetscErrorCode *ierr)slepcconvmonitorcreate_33,1338 PETSC_EXTERN void slepcconvmonitordestroy_(SlepcConvMonitor *ctx,PetscErrorCode *ierr)slepcconvmonitordestroy_40,1595 src/sys/makefile,327 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = slepcinit.c slepcutil.c slepcsc.c dlregisslepc.cSOURCEC26,958 SOURCEF =SOURCEF27,1018 SOURCEH =SOURCEH28,1029 LIBBASE = libslepcsysLIBBASE29,1040 MANSEC = sysMANSEC30,1063 LOCDIR = src/sys/LOCDIR31,1078 DIRS = classes vec f90-modDIRS32,1098 src/sys/slepcinit.c,2034 slepcinit.c:^?slepcinit.c^A,1 #undef __FUNCT____FUNCT__25,1033 #define __FUNCT__ __FUNCT__26,1050 PetscErrorCode SlepcGetVersion(char version[],size_t len)SlepcGetVersion41,1360 #undef __FUNCT____FUNCT__54,1854 #define __FUNCT__ __FUNCT__55,1871 static PetscErrorCode SlepcPrintVersion(MPI_Comm comm)SlepcPrintVersion61,1992 #undef __FUNCT____FUNCT__76,2649 #define __FUNCT__ __FUNCT__77,2666 static PetscErrorCode SlepcPrintHelpIntro(MPI_Comm comm)SlepcPrintHelpIntro83,2801 PetscBool SlepcBeganPetsc = PETSC_FALSE;SlepcBeganPetsc99,3503 PetscBool SlepcInitializeCalled = PETSC_FALSE;SlepcInitializeCalled100,3544 #undef __FUNCT____FUNCT__104,3635 #define __FUNCT__ __FUNCT__105,3652 static PetscErrorCode SlepcLoadDynamicLibrary(const char *name,PetscBool *found)SlepcLoadDynamicLibrary106,3696 #undef __FUNCT____FUNCT__122,4279 #define __FUNCT__ __FUNCT__123,4296 PetscErrorCode SlepcInitialize_DynamicLibraries(void)SlepcInitialize_DynamicLibraries128,4458 #undef __FUNCT____FUNCT__173,6795 #define __FUNCT__ __FUNCT__174,6812 PetscErrorCode SlepcCitationsInitialize()SlepcCitationsInitialize175,6857 #undef __FUNCT____FUNCT__200,7894 #define __FUNCT__ __FUNCT__201,7911 PetscErrorCode SlepcInitialize(int *argc,char ***args,const char file[],const char help[])SlepcInitialize223,8669 #undef __FUNCT____FUNCT__253,9548 #define __FUNCT__ __FUNCT__254,9565 PetscErrorCode SlepcFinalize(void)SlepcFinalize265,9828 #undef __FUNCT____FUNCT__278,10107 #define __FUNCT__ __FUNCT__279,10124 PetscErrorCode SlepcInitializeNoArguments(void)SlepcInitializeNoArguments290,10376 #undef __FUNCT____FUNCT__301,10609 #define __FUNCT__ __FUNCT__302,10626 PetscErrorCode SlepcInitialized(PetscBool *isInitialized)SlepcInitialized310,10808 PETSC_EXTERN PetscBool PetscBeganMPI;PetscBeganMPI318,10999 #undef __FUNCT____FUNCT__320,11038 #define __FUNCT__ __FUNCT__321,11055 PetscErrorCode SlepcInitializeNoPointers(int argc,char **args,const char *filename,const char *help)SlepcInitializeNoPointers332,11319 src/sys/slepcsc.c,3017 slepcsc.c:^?slepcsc.c^A,1 #undef __FUNCT____FUNCT__26,1029 #define __FUNCT__ __FUNCT__27,1046 PetscErrorCode SlepcSCCompare(SlepcSC sc,PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *res)SlepcSCCompare53,1721 #undef __FUNCT____FUNCT__85,2733 #define __FUNCT__ __FUNCT__86,2750 PetscErrorCode SlepcSortEigenvalues(SlepcSC sc,PetscInt n,PetscScalar *eigr,PetscScalar *eigi,PetscInt *perm)SlepcSortEigenvalues111,3496 #undef __FUNCT____FUNCT__165,4984 #define __FUNCT__ __FUNCT__166,5001 PetscErrorCode SlepcMap_ST(PetscObject obj,PetscInt n,PetscScalar* eigr,PetscScalar* eigi)SlepcMap_ST170,5114 #undef __FUNCT____FUNCT__179,5343 #define __FUNCT__ __FUNCT__180,5360 PetscErrorCode SlepcCompareLargestMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareLargestMagnitude181,5409 #undef __FUNCT____FUNCT__194,5752 #define __FUNCT__ __FUNCT__195,5769 PetscErrorCode SlepcCompareSmallestMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareSmallestMagnitude196,5819 #undef __FUNCT____FUNCT__209,6163 #define __FUNCT__ __FUNCT__210,6180 PetscErrorCode SlepcCompareLargestReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareLargestReal211,6224 #undef __FUNCT____FUNCT__224,6546 #define __FUNCT__ __FUNCT__225,6563 PetscErrorCode SlepcCompareSmallestReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareSmallestReal226,6608 #undef __FUNCT____FUNCT__239,6931 #define __FUNCT__ __FUNCT__240,6948 PetscErrorCode SlepcCompareLargestImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareLargestImaginary241,6997 #undef __FUNCT____FUNCT__259,7426 #define __FUNCT__ __FUNCT__260,7443 PetscErrorCode SlepcCompareSmallestImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareSmallestImaginary261,7493 #undef __FUNCT____FUNCT__279,7923 #define __FUNCT__ __FUNCT__280,7940 PetscErrorCode SlepcCompareTargetMagnitude(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareTargetMagnitude281,7988 #undef __FUNCT____FUNCT__296,8453 #define __FUNCT__ __FUNCT__297,8470 PetscErrorCode SlepcCompareTargetReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareTargetReal298,8513 #undef __FUNCT____FUNCT__312,8927 #define __FUNCT__ __FUNCT__313,8944 PetscErrorCode SlepcCompareTargetImaginary(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareTargetImaginary314,8992 #undef __FUNCT____FUNCT__336,9610 #define __FUNCT__ __FUNCT__337,9627 PetscErrorCode SlepcCompareSmallestPosReal(PetscScalar ar,PetscScalar ai,PetscScalar br,PetscScalar bi,PetscInt *result,void *ctx)SlepcCompareSmallestPosReal342,9766 src/sys/slepcutil.c,2201 slepcutil.c:^?slepcutil.c^A,1 #undef __FUNCT____FUNCT__24,994 #define __FUNCT__ __FUNCT__25,1011 PetscErrorCode SlepcVecNormalize(Vec xr,Vec xi,PetscBool iscomplex,PetscReal *norm)SlepcVecNormalize41,1486 #undef __FUNCT____FUNCT__70,2352 #define __FUNCT__ __FUNCT__71,2369 PetscErrorCode SlepcMatConvertSeqDense(Mat mat,Mat *newmat)SlepcMatConvertSeqDense84,2683 #undef __FUNCT____FUNCT__124,4149 #define __FUNCT__ __FUNCT__125,4166 static PetscErrorCode SlepcMatTile_SeqAIJ(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat G)SlepcMatTile_SeqAIJ126,4206 #undef __FUNCT____FUNCT__231,7596 #define __FUNCT__ __FUNCT__232,7613 static PetscErrorCode SlepcMatTile_MPIAIJ(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat G)SlepcMatTile_MPIAIJ233,7653 #undef __FUNCT____FUNCT__370,13024 #define __FUNCT__ __FUNCT__371,13041 PetscErrorCode SlepcMatTile(PetscScalar a,Mat A,PetscScalar b,Mat B,PetscScalar c,Mat C,PetscScalar d,Mat D,Mat *G)SlepcMatTile399,13826 #undef __FUNCT____FUNCT__461,16699 #define __FUNCT__ __FUNCT__462,16716 PetscErrorCode SlepcCheckOrthogonality(Vec *V,PetscInt nv,Vec *W,PetscInt nw,Mat B,PetscViewer viewer,PetscReal *lev)SlepcCheckOrthogonality492,17686 #undef __FUNCT____FUNCT__548,19449 #define __FUNCT__ __FUNCT__549,19466 PetscErrorCode SlepcConvMonitorCreate(PetscViewer viewer,PetscViewerFormat format,SlepcConvMonitor *ctx)SlepcConvMonitorCreate573,20126 #undef __FUNCT____FUNCT__585,20466 #define __FUNCT__ __FUNCT__586,20483 PetscErrorCode SlepcConvMonitorDestroy(SlepcConvMonitor *ctx)SlepcConvMonitorDestroy599,20766 #undef __FUNCT____FUNCT__610,21042 #define __FUNCT__ __FUNCT__611,21059 PetscErrorCode SlepcBasisReference_Private(PetscInt n,Vec *V,PetscInt *m,Vec **W)SlepcBasisReference_Private616,21267 #undef __FUNCT____FUNCT__634,21695 #define __FUNCT__ __FUNCT__635,21712 PetscErrorCode SlepcBasisDestroy_Private(PetscInt *m,Vec **W)SlepcBasisDestroy_Private640,21871 #undef __FUNCT____FUNCT__656,22181 #define __FUNCT__ __FUNCT__657,22198 PetscErrorCode SlepcSNPrintfScalar(char *str,size_t len,PetscScalar val,PetscBool exp)SlepcSNPrintfScalar673,22611 src/sys/vec/makefile,288 makefile:^?makefile^A,1 CFLAGS =CFLAGS24,936 FFLAGS =FFLAGS25,947 SOURCEC = veccomp.c pool.cSOURCEC26,958 SOURCEF =SOURCEF27,986 SOURCEH = veccomp0.hSOURCEH28,997 LIBBASE = libslepcsysLIBBASE29,1019 DIRS =DIRS30,1042 MANSEC = sysMANSEC31,1053 LOCDIR = src/sys/vec/LOCDIR32,1068 src/sys/vec/pool.c,665 pool.c:^?pool.c^A,1 #undef __FUNCT____FUNCT__26,1052 #define __FUNCT__ __FUNCT__27,1069 PetscErrorCode SlepcVecPoolCreate(Vec v,PetscInt init_size,VecPool *p)SlepcVecPoolCreate44,1409 #undef __FUNCT____FUNCT__62,1979 #define __FUNCT__ __FUNCT__63,1996 PetscErrorCode SlepcVecPoolDestroy(VecPool *p)SlepcVecPoolDestroy76,2242 #undef __FUNCT____FUNCT__94,2754 #define __FUNCT__ __FUNCT__95,2771 PetscErrorCode SlepcVecPoolGetVecs(VecPool p,PetscInt n,Vec **vecs)SlepcVecPoolGetVecs112,3075 #undef __FUNCT____FUNCT__139,3950 #define __FUNCT__ __FUNCT__140,3967 PetscErrorCode SlepcVecPoolRestoreVecs(VecPool p,PetscInt n,Vec **vecs)SlepcVecPoolRestoreVecs156,4292 src/sys/vec/veccomp.c,6453 veccomp.c:^?veccomp.c^A,1 static MPI_Datatype MPIU_NORM2=0, MPIU_NORM1_AND_2=0;MPIU_NORM225,1032 static MPI_Datatype MPIU_NORM2=0, MPIU_NORM1_AND_2=0;MPIU_NORM1_AND_225,1032 static MPI_Op MPIU_NORM2_SUM=0;MPIU_NORM2_SUM26,1086 static PetscBool VecCompInitialized = PETSC_FALSE;VecCompInitialized27,1118 #define __WITH_MPI____WITH_MPI__36,1440 PETSC_STATIC_INLINE void SumNorm2(PetscReal *ssq0,PetscReal *scale0,PetscReal *ssq1,PetscReal *scale1)SumNorm239,1484 PETSC_STATIC_INLINE PetscReal GetNorm2(PetscReal ssq,PetscReal scale)GetNorm252,1785 PETSC_STATIC_INLINE void AddNorm2(PetscReal *ssq,PetscReal *scale,PetscReal x)AddNorm257,1895 #undef __FUNCT____FUNCT__73,2206 #define __FUNCT__ __FUNCT__74,2223 static void SlepcSumNorm2_Local(void *in,void *out,PetscMPIInt *cnt,MPI_Datatype *datatype)SlepcSumNorm2_Local75,2263 #undef __FUNCT____FUNCT__98,2984 #define __FUNCT__ __FUNCT__99,3001 static PetscErrorCode VecNormCompEnd(void)VecNormCompEnd100,3036 #undef __FUNCT____FUNCT__112,3353 #define __FUNCT__ __FUNCT__113,3370 static PetscErrorCode VecNormCompInit()VecNormCompInit114,3406 #undef __FUNCT____FUNCT__128,3952 #define __FUNCT__ __FUNCT__129,3969 PetscErrorCode VecDestroy_Comp(Vec v)VecDestroy_Comp130,4005 static struct _VecOps DvOps = {VecDuplicate_Comp, /* 1 */DvOps151,4514 #undef __FUNCT____FUNCT__213,6226 #define __FUNCT__ __FUNCT__214,6243 PetscErrorCode VecDuplicateVecs_Comp(Vec w,PetscInt m,Vec *V[])VecDuplicateVecs_Comp215,6285 #undef __FUNCT____FUNCT__229,6716 #define __FUNCT__ __FUNCT__230,6733 PetscErrorCode VecDestroyVecs_Comp(PetscInt m,Vec v[])VecDestroyVecs_Comp231,6773 #undef __FUNCT____FUNCT__244,7152 #define __FUNCT__ __FUNCT__245,7169 static PetscErrorCode VecCreate_Comp_Private(Vec v,Vec *x,PetscInt nx,PetscBool x_to_me,Vec_Comp_N *n)VecCreate_Comp_Private246,7212 #undef __FUNCT____FUNCT__300,8785 #define __FUNCT__ __FUNCT__301,8802 PETSC_EXTERN PetscErrorCode VecCreate_Comp(Vec V)VecCreate_Comp302,8837 #undef __FUNCT____FUNCT__311,9038 #define __FUNCT__ __FUNCT__312,9055 PetscErrorCode VecCreateComp(MPI_Comm comm,PetscInt *Nx,PetscInt n,VecType t,Vec Vparent,Vec *V)VecCreateComp337,9749 #undef __FUNCT____FUNCT__356,10416 #define __FUNCT__ __FUNCT__357,10433 PetscErrorCode VecCreateCompWithVecs(Vec *x,PetscInt n,Vec Vparent,Vec *V)VecCreateCompWithVecs376,10837 #undef __FUNCT____FUNCT__390,11283 #define __FUNCT__ __FUNCT__391,11300 PetscErrorCode VecDuplicate_Comp(Vec win,Vec *V)VecDuplicate_Comp392,11338 #undef __FUNCT____FUNCT__413,11977 #define __FUNCT__ __FUNCT__414,11994 PetscErrorCode VecCompGetSubVecs(Vec win,PetscInt *n,const Vec **x)VecCompGetSubVecs432,12331 #undef __FUNCT____FUNCT__443,12558 #define __FUNCT__ __FUNCT__444,12575 PetscErrorCode VecCompSetSubVecs(Vec win,PetscInt n,Vec *x)VecCompSetSubVecs460,12914 #undef __FUNCT____FUNCT__478,13332 #define __FUNCT__ __FUNCT__479,13349 PetscErrorCode VecAXPY_Comp(Vec v,PetscScalar alpha,Vec w)VecAXPY_Comp480,13382 #undef __FUNCT____FUNCT__495,13746 #define __FUNCT__ __FUNCT__496,13763 PetscErrorCode VecAYPX_Comp(Vec v,PetscScalar alpha,Vec w)VecAYPX_Comp497,13796 #undef __FUNCT____FUNCT__512,14160 #define __FUNCT__ __FUNCT__513,14177 PetscErrorCode VecAXPBY_Comp(Vec v,PetscScalar alpha,PetscScalar beta,Vec w)VecAXPBY_Comp514,14211 #undef __FUNCT____FUNCT__529,14599 #define __FUNCT__ __FUNCT__530,14616 PetscErrorCode VecMAXPY_Comp(Vec v,PetscInt n,const PetscScalar *alpha,Vec *w)VecMAXPY_Comp531,14650 #undef __FUNCT____FUNCT__553,15208 #define __FUNCT__ __FUNCT__554,15225 PetscErrorCode VecWAXPY_Comp(Vec v,PetscScalar alpha,Vec w,Vec z)VecWAXPY_Comp555,15259 #undef __FUNCT____FUNCT__571,15689 #define __FUNCT__ __FUNCT__572,15706 PetscErrorCode VecAXPBYPCZ_Comp(Vec v,PetscScalar alpha,PetscScalar beta,PetscScalar gamma,Vec w,Vec z)VecAXPBYPCZ_Comp573,15743 #undef __FUNCT____FUNCT__589,16228 #define __FUNCT__ __FUNCT__590,16245 PetscErrorCode VecGetSize_Comp(Vec v,PetscInt *size)VecGetSize_Comp591,16281 #undef __FUNCT____FUNCT__602,16501 #define __FUNCT__ __FUNCT__603,16518 PetscErrorCode VecGetLocalSize_Comp(Vec v,PetscInt *size)VecGetLocalSize_Comp604,16559 #undef __FUNCT____FUNCT__615,16785 #define __FUNCT__ __FUNCT__616,16802 PetscErrorCode VecMax_Comp(Vec v,PetscInt *idx,PetscReal *z)VecMax_Comp617,16834 #undef __FUNCT____FUNCT__648,17553 #define __FUNCT__ __FUNCT__649,17570 PetscErrorCode VecMin_Comp(Vec v,PetscInt *idx,PetscReal *z)VecMin_Comp650,17602 #undef __FUNCT____FUNCT__681,18321 #define __FUNCT__ __FUNCT__682,18338 PetscErrorCode VecMaxPointwiseDivide_Comp(Vec v,Vec w,PetscReal *m)VecMaxPointwiseDivide_Comp683,18385 #define __QUOTEME__(__QUOTEME__703,18942 #define __COMPOSE2__(__COMPOSE2__704,18968 #define __COMPOSE3__(__COMPOSE3__705,18999 #define __FUNC_TEMPLATE1__(__FUNC_TEMPLATE1__707,19036 #undef __FUNCT____FUNCT__722,19403 #define __FUNCT__ __FUNCT__723,19420 #undef __FUNCT____FUNCT__726,19489 #define __FUNCT__ __FUNCT__727,19506 #undef __FUNCT____FUNCT__730,19577 #define __FUNCT__ __FUNCT__731,19594 #undef __FUNCT____FUNCT__734,19659 #define __FUNCT__ __FUNCT__735,19676 #undef __FUNCT____FUNCT__738,19733 #define __FUNCT__ __FUNCT__739,19750 #undef __FUNCT____FUNCT__742,19807 #define __FUNCT__ __FUNCT__743,19824 #define __FUNC_TEMPLATE2__(__FUNC_TEMPLATE2__747,19882 #undef __FUNCT____FUNCT__762,20263 #define __FUNCT__ __FUNCT__763,20280 #undef __FUNCT____FUNCT__766,20349 #define __FUNCT__ __FUNCT__767,20366 #undef __FUNCT____FUNCT__770,20437 #define __FUNCT__ __FUNCT__771,20454 #undef __FUNCT____FUNCT__774,20527 #define __FUNCT__ __FUNCT__775,20544 #undef __FUNCT____FUNCT__778,20625 #define __FUNCT__ __FUNCT__779,20642 #define __FUNC_TEMPLATE3__(__FUNC_TEMPLATE3__783,20716 #undef __FUNCT____FUNCT__800,21169 #define __FUNCT__ __FUNCT__801,21186 #undef __FUNCT____FUNCT__804,21245 #define __FUNCT__ __FUNCT__805,21262 #define __FUNC_TEMPLATE4__(__FUNC_TEMPLATE4__809,21322 #undef __FUNCT____FUNCT__828,21863 #define __FUNCT__ __FUNCT__829,21880 #undef __FUNCT____FUNCT__832,21955 #define __FUNCT__ __FUNCT__833,21972 #undef __FUNCT____FUNCT__836,22053 #define __FUNCT__ __FUNCT__837,22070 #undef __FUNCT____FUNCT__840,22145 #define __FUNCT__ __FUNCT__841,22162 #undef __FUNCT____FUNCT__844,22239 #define __FUNCT__ __FUNCT__845,22256 src/sys/vec/veccomp0.h,1314 veccomp0.h:^?veccomp0.h^A,1 #define __SUF__(__SUF__25,986 #define __SUF__(__SUF__27,1019 #define __QUOTEME_(__QUOTEME_29,1053 #define __QUOTEME(__QUOTEME30,1078 #define __SUF_C__(__SUF_C__31,1113 #undef __FUNCT____FUNCT__34,1158 #define __FUNCT__ __FUNCT__35,1175 PetscErrorCode __SUF__(VecDot_Comp)(Vec a,Vec b,PetscScalar *z)VecDot_Comp36,1216 #undef __FUNCT____FUNCT__65,2009 #define __FUNCT__ __FUNCT__66,2026 PetscErrorCode __SUF__(VecMDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z)VecMDot_Comp67,2068 #undef __FUNCT____FUNCT__124,3563 #define __FUNCT__ __FUNCT__125,3580 PetscErrorCode __SUF__(VecTDot_Comp)(Vec a,Vec b,PetscScalar *z)VecTDot_Comp126,3622 #undef __FUNCT____FUNCT__155,4419 #define __FUNCT__ __FUNCT__156,4436 PetscErrorCode __SUF__(VecMTDot_Comp)(Vec a,PetscInt n,const Vec b[],PetscScalar *z)VecMTDot_Comp157,4479 #undef __FUNCT____FUNCT__214,5984 #define __FUNCT__ __FUNCT__215,6001 PetscErrorCode __SUF__(VecNorm_Comp)(Vec a,NormType t,PetscReal *norm)VecNorm_Comp216,6043 #undef __FUNCT____FUNCT__284,8318 #define __FUNCT__ __FUNCT__285,8335 PetscErrorCode __SUF__(VecDotNorm2_Comp)(Vec v,Vec w,PetscScalar *dp,PetscScalar *nm)VecDotNorm2_Comp286,8381 #undef __SUF____SUF__334,10002 #undef __QUOTEME__QUOTEME335,10017 #undef __SUF_C____SUF_C__336,10034 slepc-3.7.4/config/0000755000175000017500000000000013107004621013430 5ustar jromanjromanslepc-3.7.4/config/gmakegen.py0000755000175000017500000002100013107004621015554 0ustar jromanjroman#!/usr/bin/env python import os from distutils.sysconfig import parse_makefile import sys import logging sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'config')) from cmakegen import Mistakes, stripsplit, AUTODIRS, SKIPDIRS from cmakegen import defaultdict # collections.defaultdict, with fallback for python-2.4 PKGS = 'sys eps svd pep nep mfn'.split() LANGS = dict(c='C', cxx='CXX', cu='CU', F='F') try: all([True, True]) except NameError: # needs python-2.5 def all(iterable): for i in iterable: if not i: return False return True try: os.path.relpath # needs python-2.6 except AttributeError: def _relpath(path, start=os.path.curdir): """Return a relative version of a path""" from os.path import curdir, abspath, commonprefix, sep, pardir, join if not path: raise ValueError("no path specified") start_list = [x for x in abspath(start).split(sep) if x] path_list = [x for x in abspath(path).split(sep) if x] # Work out how much of the filepath is shared by start and path. i = len(commonprefix([start_list, path_list])) rel_list = [pardir] * (len(start_list)-i) + path_list[i:] if not rel_list: return curdir return join(*rel_list) os.path.relpath = _relpath class debuglogger(object): def __init__(self, log): self._log = log def write(self, string): self._log.debug(string) class Slepc(object): def __init__(self, slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, verbose=False): if slepc_dir is None: slepc_dir = os.environ.get('SLEPC_DIR') if slepc_dir is None: raise RuntimeError('Could not determine SLEPC_DIR, please set in environment') if petsc_dir is None: petsc_dir = os.environ.get('PETSC_DIR') if petsc_dir is None: raise RuntimeError('Could not determine PETSC_DIR, please set in environment') if petsc_arch is None: petsc_arch = os.environ.get('PETSC_ARCH') if petsc_arch is None: raise RuntimeError('Could not determine PETSC_ARCH, please set in environment') self.slepc_dir = slepc_dir self.petsc_dir = petsc_dir self.petsc_arch = petsc_arch self.installed_petsc = installed_petsc self.read_conf() logging.basicConfig(filename=self.arch_path('lib','slepc','conf', 'gmake.log'), level=logging.DEBUG) self.log = logging.getLogger('gmakegen') self.mistakes = Mistakes(debuglogger(self.log), verbose=verbose) self.gendeps = [] def petsc_path(self, *args): if self.installed_petsc: return os.path.join(self.petsc_dir, *args) else: return os.path.join(self.petsc_dir, self.petsc_arch, *args) def arch_path(self, *args): return os.path.join(self.slepc_dir, self.petsc_arch, *args) def read_conf(self): self.conf = dict() for line in open(self.petsc_path('include', 'petscconf.h')): if line.startswith('#define '): define = line[len('#define '):] space = define.find(' ') key = define[:space] val = define[space+1:] self.conf[key] = val self.conf.update(parse_makefile(self.petsc_path('lib','petsc','conf', 'petscvariables'))) for line in open(self.arch_path('include', 'slepcconf.h')): if line.startswith('#define '): define = line[len('#define '):] space = define.find(' ') key = define[:space] val = define[space+1:] self.conf[key] = val self.conf.update(parse_makefile(self.arch_path('lib','slepc','conf', 'slepcvariables'))) self.have_fortran = int(self.conf.get('PETSC_HAVE_FORTRAN', '0')) def inconf(self, key, val): if key in ['package', 'function', 'define']: return self.conf.get(val) elif key == 'precision': return val == self.conf['PETSC_PRECISION'] elif key == 'scalar': return val == self.conf['PETSC_SCALAR'] elif key == 'language': return val == self.conf['PETSC_LANGUAGE'] raise RuntimeError('Unknown conf check: %s %s' % (key, val)) def relpath(self, root, src): return os.path.relpath(os.path.join(root, src), self.slepc_dir) def get_sources(self, makevars): """Return dict {lang: list_of_source_files}""" source = dict() for lang, sourcelang in LANGS.items(): source[lang] = [f for f in makevars.get('SOURCE'+sourcelang,'').split() if f.endswith(lang)] return source def gen_pkg(self, pkg): pkgsrcs = dict() for lang in LANGS: pkgsrcs[lang] = [] for root, dirs, files in os.walk(os.path.join(self.slepc_dir, 'src', pkg)): makefile = os.path.join(root,'makefile') if not os.path.exists(makefile): dirs[:] = [] continue mklines = open(makefile) conditions = set(tuple(stripsplit(line)) for line in mklines if line.startswith('#requires')) mklines.close() if not all(self.inconf(key, val) for key, val in conditions): dirs[:] = [] continue makevars = parse_makefile(makefile) mdirs = makevars.get('DIRS','').split() # Directories specified in the makefile self.mistakes.compareDirLists(root, mdirs, dirs) # diagnostic output to find unused directories candidates = set(mdirs).union(AUTODIRS).difference(SKIPDIRS) dirs[:] = list(candidates.intersection(dirs)) allsource = [] def mkrel(src): return self.relpath(root, src) source = self.get_sources(makevars) for lang, s in source.items(): pkgsrcs[lang] += map(mkrel, s) allsource += s self.mistakes.compareSourceLists(root, allsource, files) # Diagnostic output about unused source files self.gendeps.append(self.relpath(root, 'makefile')) return pkgsrcs def gen_gnumake(self, fd): def write(stem, srcs): fd.write('%s :=\n' % stem) for lang in LANGS: fd.write('%(stem)s.%(lang)s := %(srcs)s\n' % dict(stem=stem, lang=lang, srcs=' '.join(srcs[lang]))) fd.write('%(stem)s += $(%(stem)s.%(lang)s)\n' % dict(stem=stem, lang=lang)) for pkg in PKGS: srcs = self.gen_pkg(pkg) write('srcs-' + pkg, srcs) return self.gendeps def summary(self): self.mistakes.summary() def WriteGnuMake(slepc): arch_files = slepc.arch_path('lib','slepc','conf', 'files') fd = open(arch_files, 'w') gendeps = slepc.gen_gnumake(fd) fd.write('\n') fd.write('# Dependency to regenerate this file\n') fd.write('%s : %s %s\n' % (os.path.relpath(arch_files, slepc.slepc_dir), os.path.relpath(__file__, os.path.realpath(slepc.slepc_dir)), ' '.join(gendeps))) fd.write('\n') fd.write('# Dummy dependencies in case makefiles are removed\n') fd.write(''.join([dep + ':\n' for dep in gendeps])) fd.close() def main(slepc_dir=None, petsc_dir=None, petsc_arch=None, installed_petsc=False, output=None, verbose=False): if output is None: output = 'gnumake' writer = dict(gnumake=WriteGnuMake) slepc = Slepc(slepc_dir=slepc_dir, petsc_dir=petsc_dir, petsc_arch=petsc_arch, installed_petsc=installed_petsc, verbose=verbose) writer[output](slepc) slepc.summary() if __name__ == '__main__': import optparse parser = optparse.OptionParser() parser.add_option('--verbose', help='Show mismatches between makefiles and the filesystem', action='store_true', default=False) parser.add_option('--petsc-arch', help='Set PETSC_ARCH different from environment', default=os.environ.get('PETSC_ARCH')) parser.add_option('--installed-petsc', help='Using a prefix PETSc installation', default=False) parser.add_option('--output', help='Location to write output file', default=None) opts, extra_args = parser.parse_args() if extra_args: import sys sys.stderr.write('Unknown arguments: %s\n' % ' '.join(extra_args)) exit(1) main(petsc_arch=opts.petsc_arch, installed_petsc=opts.installed_petsc, output=opts.output, verbose=opts.verbose) slepc-3.7.4/config/configure.py0000755000175000017500000004252413107004621015775 0ustar jromanjroman#!/usr/bin/env python # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, sys, time, shutil def AddDefine(conffile,name,value,prefix='SLEPC_'): conffile.write('#ifndef '+prefix+name+'\n#define '+prefix+name+' "'+value+'"\n#endif\n\n') def CreateFile(basedir,fname,log): ''' Create file basedir/fname and return path string ''' newfile = os.path.join(basedir,fname) try: newfile = open(newfile,'w') except: log.Exit('ERROR: Cannot create '+fname+' file in '+basedir) return newfile def CreateDir(basedir,dirname,log): ''' Create directory basedir/dirname and return path string ''' newdir = os.path.join(basedir,dirname) if not os.path.exists(newdir): try: os.mkdir(newdir) except: log.Exit('ERROR: Cannot create '+dirname+' directory: '+newdir) return newdir def CreateDirTwo(basedir,dir1,dir2,log): ''' Create directory basedir/dir1/dir2 and return path string ''' newbasedir = os.path.join(basedir,dir1) if not os.path.exists(newbasedir): try: os.mkdir(newbasedir) except: log.Exit('ERROR: Cannot create '+dir1+' directory: '+newbasedir) newdir = os.path.join(newbasedir,dir2) if not os.path.exists(newdir): try: os.mkdir(newdir) except: log.Exit('ERROR: Cannot create '+dirname+' directory: '+newdir) return newdir def CreateDirTest(basedir,dirname,log): ''' Create directory, return path string and flag indicating if already existed ''' newdir = os.path.join(basedir,dirname) if not os.path.exists(newdir): existed = False try: os.mkdir(newdir) except: log.Exit('ERROR: Cannot create '+dirname+' directory: '+newdir) else: existed = True return newdir, existed def WriteModulesFile(modules,version,sdir): ''' Write the contents of the Modules file ''' modules.write('#%Module\n\n') modules.write('proc ModulesHelp { } {\n') modules.write(' puts stderr "This module sets the path and environment variables for slepc-%s"\n' % version) modules.write(' puts stderr " see http://slepc.upv.es/ for more information"\n') modules.write(' puts stderr ""\n}\n') modules.write('module-whatis "SLEPc - Scalable Library for Eigenvalue Problem Computations"\n\n') modules.write('module load petsc\n') modules.write('set slepc_dir %s\n' % sdir) modules.write('setenv SLEPC_DIR $slepc_dir\n') def WritePkgconfigFile(pkgconfig,version,pversion,sdir,isinstall,prefixdir): ''' Write the contents of the pkg-config file ''' pkgconfig.write('Name: SLEPc, the Scalable Library for Eigenvalue Problem Computations\n') pkgconfig.write('Description: A parallel library to compute eigenvalues and eigenvectors of large, sparse matrices with iterative methods. It is based on PETSc.\n') pkgconfig.write('Version: %s\n' % version) pkgconfig.write('Requires: PETSc = %s\n' % pversion) pkgconfig.write('Cflags: -I'+os.path.join(prefixdir,'include')) if not isinstall: pkgconfig.write(' -I'+os.path.join(sdir,'include')) pkgconfig.write('\nLibs: -L%s -lslepc\n' % os.path.join(prefixdir,'lib')) def WriteCMakeConfigFile(cmakeconf): ''' Write the contents of the CMake configuration file ''' cmakeconf.write(''' set (SLEPC_PACKAGE_LIBS "${ARPACK_LIB}" "${BLZPACK_LIB}" "${TRLAN_LIB}" "${PRIMME_LIB}" "${FEAST_LIB}" "${BLOPEX_LIB}" ) set (SLEPC_PACKAGE_INCLUDES "${PRIMME_INCLUDE}") find_library (PETSC_LIB petsc HINTS ${PETSc_BINARY_DIR}/lib ) if (NOT PETSC_LIB) # Interpret missing libpetsc to mean that PETSc was built --with-single-library=0 set (PETSC_LIB "") foreach (pkg sys vec mat dm ksp snes ts tao) string (TOUPPER ${pkg} PKG) find_library (PETSC${PKG}_LIB "petsc${pkg}" HINTS ${PETSc_BINARY_DIR}/lib) list (APPEND PETSC_LIB "${PETSC${PKG}_LIB}") endforeach () endif () ''') # Use en_US as language so that compiler messages are in English if 'LC_LOCAL' in os.environ and os.environ['LC_LOCAL'] != '' and os.environ['LC_LOCAL'] != 'en_US' and os.environ['LC_LOCAL']!= 'en_US.UTF-8': os.environ['LC_LOCAL'] = 'en_US.UTF-8' if 'LANG' in os.environ and os.environ['LANG'] != '' and os.environ['LANG'] != 'en_US' and os.environ['LANG'] != 'en_US.UTF-8': os.environ['LANG'] = 'en_US.UTF-8' # Check python version if not hasattr(sys, 'version_info') or not sys.version_info[0] == 2 or not sys.version_info[1] >= 6: print '*******************************************************************************' print '* Python2 version 2.6 or higher is required to run ./configure *' print '* Try: "python2.7 ./configure" or "python2.6 ./configure" *' print '*******************************************************************************' sys.exit(4) # Set python path configdir = os.path.abspath('config') if not os.path.isdir(configdir): sys.exit('ERROR: Run configure from $SLEPC_DIR, not '+os.path.abspath('.')) sys.path.insert(0,configdir) sys.path.insert(0,os.path.join(configdir,'packages')) # Load auxiliary classes import argdb, log argdb = argdb.ArgDB(sys.argv) log = log.Log() # Load classes for packages and process command-line options import slepc, petsc, arpack, blzpack, trlan, feast, primme, blopex, sowing, lapack slepc = slepc.SLEPc(argdb,log) petsc = petsc.PETSc(argdb,log) arpack = arpack.Arpack(argdb,log) blopex = blopex.Blopex(argdb,log) blzpack = blzpack.Blzpack(argdb,log) feast = feast.Feast(argdb,log) primme = primme.Primme(argdb,log) trlan = trlan.Trlan(argdb,log) sowing = sowing.Sowing(argdb,log) lapack = lapack.Lapack(argdb,log) externalpackages = [arpack, blopex, blzpack, feast, primme, trlan] optionspackages = [slepc, arpack, blopex, blzpack, feast, primme, trlan, sowing] checkpackages = [arpack, blopex, blzpack, feast, primme, trlan, lapack] # Print help if requested and check for wrong command-line options if argdb.PopHelp(): print 'SLEPc Configure Help' print '-'*80 for pkg in optionspackages: pkg.ShowHelp() sys.exit(0) argdb.ErrorIfNotEmpty() # Check enviroment and PETSc version print 'Checking environment...', petsc.InitDir(slepc.prefixdir) slepc.InitDir() petsc.LoadVersion() slepc.LoadVersion() if petsc.version != slepc.version: sys.exit('ERROR: This SLEPc version is not compatible with PETSc version '+petsc.version) # Check some information about PETSc configuration petsc.LoadConf() if not petsc.precision in ['double','single','__float128']: sys.exit('ERROR: This SLEPc version does not work with '+petsc.precision+' precision') if slepc.isinstall and not petsc.isinstall: sys.exit('ERROR: SLEPc cannot be configured for non-source installation if PETSc is not configured in the same way.') # Check for empty PETSC_ARCH emptyarch = not ('PETSC_ARCH' in os.environ and os.environ['PETSC_ARCH']) if emptyarch: archname = 'installed-'+petsc.arch else: archname = petsc.arch # Create directories for configuration files archdir, archdirexisted = CreateDirTest(slepc.dir,archname,log) libdir = CreateDir(archdir,'lib',log) confdir = CreateDirTwo(libdir,'slepc','conf',log) # Open log file log.Open(os.path.join(confdir,'configure.log')) log.write('='*80) log.write('Starting Configure Run at '+time.ctime(time.time())) log.write('Configure Options: '+' '.join(sys.argv[1:])) log.write('Working directory: '+os.getcwd()) log.write('Python version:\n'+sys.version) log.write('make: '+petsc.make) log.write('PETSc source directory: '+petsc.dir) log.write('PETSc install directory: '+petsc.destdir) log.write('PETSc version: '+petsc.lversion) if not emptyarch: log.write('PETSc architecture: '+petsc.arch) log.write('SLEPc source directory: '+slepc.dir) if slepc.isinstall: log.write('SLEPc install directory: '+slepc.prefixdir) log.write('SLEPc version: '+slepc.lversion) # Clean previous configuration if needed if archdirexisted: if not slepc.clean: try: f = open(os.path.join(confdir,'slepcvariables'),'r') searchlines = f.readlines() f.close() if any(pkg.packagename.upper() in ''.join(searchlines) for pkg in externalpackages) and not any(pkg.requested for pkg in externalpackages): log.Print('\nWARNING: forcing --with-clean=1 because previous configuration had external packages') slepc.clean = True except: pass if slepc.clean: log.Print('\nCleaning arch dir '+archdir+'...') try: for root, dirs, files in os.walk(archdir,topdown=False): for name in files: if name!='configure.log': os.remove(os.path.join(root,name)) except: log.Exit('ERROR: Cannot remove existing files in '+archdir) for rdir in ['CMakeFiles','obj','externalpackages']: try: shutil.rmtree(os.path.join(archdir,rdir)) except: pass # Create other directories and configuration files if not slepc.prefixdir: slepc.prefixdir = archdir includedir = CreateDir(archdir,'include',log) modulesdir = CreateDirTwo(confdir,'modules','slepc',log) pkgconfdir = CreateDir(libdir,'pkgconfig',log) slepcvars = CreateFile(confdir,'slepcvariables',log) slepcrules = CreateFile(confdir,'slepcrules',log) slepcconf = CreateFile(includedir,'slepcconf.h',log) cmakeconf = CreateFile(confdir,'SLEPcBuildInternal.cmake',log) pkgconfig = CreateFile(pkgconfdir,'SLEPc.pc',log) if slepc.isinstall: modules = CreateFile(modulesdir,slepc.lversion,log) else: modules = CreateFile(modulesdir,slepc.lversion+'-'+archname,log) # Write initial part of file slepcvariables slepcvars.write('SLEPC_DESTDIR = '+slepc.prefixdir+'\n') if emptyarch: slepcvars.write('INSTALLED_PETSC = 1\n') testruns = set(petsc.test_runs.split()) testruns = testruns.intersection(set(['C','F90','Fortran','C_Complex','Fortran_Complex','C_NoComplex','Fortran_NoComplex'])) if petsc.precision != '__float128': testruns = testruns.union(set(['C_NoF128'])) if slepc.datadir: slepcvars.write('DATAFILESPATH = '+slepc.datadir+'\n') if petsc.scalar == 'complex': testruns = testruns.union(set(['DATAFILESPATH_Complex'])) else: testruns = testruns.union(set(['DATAFILESPATH'])) slepcvars.write('TEST_RUNS = '+' '.join(testruns)+'\n') # Write initial part of file slepcconf.h slepcconf.write('#if !defined(__SLEPCCONF_H)\n') slepcconf.write('#define __SLEPCCONF_H\n\n') AddDefine(slepcconf,'PETSC_DIR',petsc.dir) AddDefine(slepcconf,'PETSC_ARCH',petsc.arch) AddDefine(slepcconf,'DIR',slepc.dir) AddDefine(slepcconf,'LIB_DIR',os.path.join(slepc.prefixdir,'lib')) if slepc.isrepo: AddDefine(slepcconf,'VERSION_GIT',slepc.gitrev) AddDefine(slepcconf,'VERSION_DATE_GIT',slepc.gitdate) AddDefine(slepcconf,'VERSION_BRANCH_GIT',slepc.branch) # Create global configuration file for the case of empty PETSC_ARCH if emptyarch: globconf = CreateFile(os.path.join(slepc.dir,'lib','slepc','conf'),'slepcvariables',log) globconf.write('SLEPC_DIR = '+slepc.dir+'\n') globconf.write('PETSC_ARCH = '+archname+'\n') globconf.close() # Check if PETSc is working log.NewSection('Checking PETSc installation...') if petsc.version > slepc.version: log.Println('\nWARNING: PETSc version '+petsc.version+' is newer than SLEPc version '+slepc.version) if petsc.release != slepc.release: log.Exit('ERROR: Cannot mix release and development versions of SLEPc and PETSc') if petsc.isinstall: if os.path.realpath(petsc.destdir) != os.path.realpath(petsc.dir): log.Println('\nWARNING: PETSC_DIR does not point to PETSc installation path') petsc.Check() if not petsc.havepackage: log.Exit('ERROR: Unable to link with PETSc') # Single library installation if petsc.singlelib: slepcvars.write('SHLIBS = libslepc\n') slepcvars.write('LIBNAME = '+os.path.join('${INSTALL_LIB_DIR}','libslepc.${AR_LIB_SUFFIX}')+'\n') for module in ['SYS','MFN','EPS','SVD','PEP','NEP']: slepcvars.write('SLEPC_'+module+'_LIB = ${CC_LINKER_SLFLAG}${SLEPC_LIB_DIR} -L${SLEPC_LIB_DIR} -lslepc ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB}\n') slepcvars.write('SLEPC_LIB = ${CC_LINKER_SLFLAG}${SLEPC_LIB_DIR} -L${SLEPC_LIB_DIR} -lslepc ${SLEPC_EXTERNAL_LIB} ${PETSC_KSP_LIB}\n') # Check for external packages and for missing LAPACK functions for pkg in checkpackages: pkg.Process(slepcconf,slepcvars,cmakeconf,petsc,archdir) # Write Modules, pkg-config and CMake configuration files log.NewSection('Writing various configuration files...') log.write('Modules file in '+modulesdir) if slepc.isinstall: WriteModulesFile(modules,slepc.lversion,slepc.prefixdir) else: WriteModulesFile(modules,slepc.lversion,slepc.dir) log.write('pkg-config file in '+pkgconfdir) WritePkgconfigFile(pkgconfig,slepc.lversion,petsc.lversion,slepc.dir,slepc.isinstall,slepc.prefixdir) log.write('CMake configure file in '+confdir) WriteCMakeConfigFile(cmakeconf) # Finish with configuration files (except slepcvars) slepcrules.close() slepcconf.write('#endif\n') slepcconf.close() modules.close() pkgconfig.close() cmakeconf.close() # Download sowing if requested and make Fortran stubs if necessary bfort = petsc.bfort if sowing.downloadpackage: bfort = sowing.Install(archdir,petsc.make) if slepc.isrepo and hasattr(petsc,'fc'): try: if not os.path.exists(bfort): bfort = os.path.join(archdir,'bin','bfort') if not os.path.exists(bfort): bfort = sowing.Install(archdir,petsc.make) log.NewSection('Generating Fortran stubs...') log.write('Using BFORT='+bfort) sys.path.insert(0, os.path.abspath(os.path.join('bin','maint'))) import generatefortranstubs generatefortranstubs.main(slepc.dir,bfort,os.getcwd(),0) generatefortranstubs.processf90interfaces(slepc.dir,0) except: log.Exit('ERROR: Try configuring with --download-sowing or use a git version of PETSc') if bfort != petsc.bfort: slepcvars.write('BFORT = '+bfort+'\n') # CMake stuff cmakeok = False if slepc.cmake: log.NewSection('Configuring CMake builds...') if sys.version_info < (2,5): log.Exit('ERROR: python version should be 2.5 or higher') elif petsc.isinstall: log.Exit('ERROR: CMake builds cannot be used with prefix-installed PETSc') elif not petsc.build_using_cmake: log.Exit('ERROR: CMake builds need a PETSc configured --with-cmake') else: import cmakegen try: cmakegen.main(slepc.dir,petsc.dir,petscdestdir=petsc.destdir) except (OSError), e: log.Exit('ERROR: Generating CMakeLists.txt failed:\n'+str(e)) import cmakeboot try: cmakeok = cmakeboot.main(slepc.dir,petsc.dir,log=log) except (OSError), e: log.Exit('ERROR: Booting CMake in PETSC_ARCH failed:\n'+str(e)) except (ImportError, KeyError), e: log.Exit('ERROR: Importing cmakeboot failed:\n'+str(e)) except (AttributeError), e: log.Println('\nxxx'+'='*73+'xxx') log.Println('WARNING: CMake builds are not available (initialization failed)') log.Println('You can ignore this warning (use default build), or try reconfiguring PETSc') log.Println('xxx'+'='*73+'xxx') # remove files created by PETSc's script for f in ['build.log','build.log.bkp','RDict.log']: try: os.remove(f) except OSError: pass if cmakeok: slepcvars.write('SLEPC_BUILD_USING_CMAKE = 1\n') # Finally we can close the slepcvariables file slepcvars.close() # Print summary log.NewSection('\n') log.Println('='*79) log.Println('SLEPc Configuration') log.Println('='*79) log.Println('\nSLEPc directory:\n '+slepc.dir) if slepc.isrepo: log.Println(' It is a git repository on branch: '+slepc.branch) if slepc.isinstall: log.Println('SLEPc prefix directory:\n '+slepc.prefixdir) log.Println('PETSc directory:\n '+petsc.dir) if petsc.isrepo: log.Println(' It is a git repository on branch: '+petsc.branch) if slepc.isrepo and petsc.branch!='maint' and slepc.branch!='maint': try: import dateutil.parser, datetime petscdate = dateutil.parser.parse(petsc.gitdate) slepcdate = dateutil.parser.parse(slepc.gitdate) if abs(petscdate-slepcdate)>datetime.timedelta(days=30): log.Println('xxx'+'='*73+'xxx') log.Println('WARNING: your PETSc and SLEPc repos may not be in sync (more than 30 days apart)') log.Println('xxx'+'='*73+'xxx') except ImportError: pass if emptyarch and slepc.isinstall: log.Println('Prefix install with '+petsc.precision+' precision '+petsc.scalar+' numbers') else: log.Println('Architecture "'+archname+'" with '+petsc.precision+' precision '+petsc.scalar+' numbers') for pkg in checkpackages: pkg.ShowInfo() log.write('\nFinishing Configure Run at '+time.ctime(time.time())) log.write('='*79) print print 'xxx'+'='*73+'xxx' if petsc.make_is_gnumake: buildtype = 'gnumake' elif cmakeok: buildtype = 'cmake' else: buildtype = 'legacy' print ' Configure stage complete. Now build the SLEPc library with ('+buildtype+' build):' if emptyarch: print ' make SLEPC_DIR=$PWD PETSC_DIR='+petsc.dir else: print ' make SLEPC_DIR=$PWD PETSC_DIR='+petsc.dir+' PETSC_ARCH='+archname print 'xxx'+'='*73+'xxx' print slepc-3.7.4/config/package.py0000644000175000017500000002677613107004621015417 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, sys, commands, tempfile, shutil, urllib, urlparse, tarfile import log, argdb class Package: def __init__(self,argdb,log): self.installable = False self.downloadable = False self.downloadpackage = 0 self.packagedir = '' self.packagelibs = [] self.packageurl = '' self.log = log self.supportsscalar = ['real', 'complex'] self.supportssingle = False self.supports64bint = False def ProcessArgs(self,argdb): self.requested = False self.havepackage = False if self.installable: string,found = argdb.PopPath('with-'+self.packagename+'-dir') if found: self.requested = True self.packagedir = string string,found = argdb.PopString('with-'+self.packagename+'-flags') if found: self.requested = True self.packagelibs = string.split(',') if argdb.PopBool('with-'+self.packagename): self.requested = True if self.downloadable: url,flag,found = argdb.PopUrl('download-'+self.packagename) if found: if self.requested: self.log.Exit('ERROR: Cannot request both download and install simultaneously') self.requested = True self.download = True self.packageurl = url self.downloadpackage = flag def Process(self,conf,vars,cmake,petsc,archdir=''): self.make = petsc.make self.slflag = petsc.slflag if self.requested: name = self.packagename.upper() if self.downloadpackage: if hasattr(self,'version'): self.log.NewSection('Installing '+name+' version '+self.version+'...') else: self.log.NewSection('Installing '+name+'...') self.Precondition(petsc) self.Install(conf,vars,cmake,petsc,archdir) elif self.installable: self.log.NewSection('Checking '+name+'...') self.Precondition(petsc) self.Check(conf,vars,cmake,petsc) def Precondition(self,petsc): package = self.packagename.upper() if petsc.scalar == 'complex': if 'complex' not in self.supportsscalar: self.log.Exit('ERROR: '+package+' does not support complex scalars.') elif petsc.scalar == 'real': if 'real' not in self.supportsscalar: self.log.Exit('ERROR: '+package+' is supported only with complex scalars.') if petsc.precision == 'single': if not self.supportssingle: self.log.Exit('ERROR: '+package+' is supported only in double precision.') elif petsc.precision != 'double': self.log.Exit('ERROR: precision '+petsc.precision+' is not supported for external packages.') if petsc.ind64 and not self.supports64bint: self.log.Exit('ERROR: '+package+' cannot be used with 64-bit integers.') def Download(self,externdir,builddir,prefix=None): # Create externalpackages directory if not os.path.exists(externdir): try: os.mkdir(externdir) except: self.log.Exit('ERROR: Cannot create directory ' + externdir) # Check if source is already available if os.path.exists(builddir): self.log.write('Using '+builddir) else: # Download tarball url = self.packageurl if url=='': url = self.url localFile = os.path.join(externdir,self.archive) self.log.write('Downloading '+url+' to '+localFile) if os.path.exists(localFile): os.remove(localFile) try: urllib.urlretrieve(url, localFile) except Exception, e: filename = os.path.basename(urlparse.urlparse(url)[2]) failureMessage = '''\ Unable to download package %s from: %s * If your network is disconnected - please reconnect and rerun ./configure * Alternatively, you can download the above URL manually, to /yourselectedlocation/%s and use the configure option: --download-%s=/yourselectedlocation/%s ''' % (self.packagename, url, filename, self.packagename, filename) self.log.Exit(failureMessage) # Uncompress tarball self.log.write('Uncompressing '+localFile+' to directory '+builddir) if os.path.exists(builddir): for root, dirs, files in os.walk(builddir, topdown=False): for name in files: os.remove(os.path.join(root,name)) for name in dirs: os.rmdir(os.path.join(root,name)) try: if sys.version_info >= (2,5): tar = tarfile.open(localFile, 'r:gz') tar.extractall(path=externdir) tar.close() os.remove(localFile) else: result,output = commands.getstatusoutput('cd '+externdir+'; gunzip '+self.archive+'; tar -xf '+self.archive.split('.gz')[0]) os.remove(localFile.split('.gz')[0]) except RuntimeError, e: self.log.Exit('Error uncompressing '+self.archive+': '+str(e)) # Rename directory if prefix is not None: for filename in os.listdir(externdir): if filename.startswith(prefix): os.rename(os.path.join(externdir,filename),builddir) def ShowHelp(self): wd = 31 if self.downloadable or self.installable: print self.packagename.upper()+':' if self.downloadable: print (' --download-'+self.packagename+'[=]').ljust(wd)+': Download and install '+self.packagename.upper()+' in SLEPc directory' if self.installable: print (' --with-'+self.packagename+'=').ljust(wd)+': Indicate if you wish to test for '+self.packagename.upper() print (' --with-'+self.packagename+'-dir=

').ljust(wd)+': Indicate the directory for '+self.packagename.upper()+' libraries' print (' --with-'+self.packagename+'-flags=').ljust(wd)+': Indicate comma-separated flags for linking '+self.packagename.upper() def ShowInfo(self): if self.havepackage: self.log.Println(self.packagename.upper()+' library flags:') self.log.Println(' '+' '.join(self.packageflags)) def LinkWithOutput(self,functions,callbacks,flags): # Create temporary directory and makefile try: tmpdir = tempfile.mkdtemp(prefix='slepc-') if not os.path.isdir(tmpdir): os.mkdir(tmpdir) except: self.log.Exit('ERROR: Cannot create temporary directory') try: makefile = open(os.path.join(tmpdir,'makefile'),'w') makefile.write('checklink: checklink.o chkopts\n') makefile.write('\t${CLINKER} -o checklink checklink.o ${TESTFLAGS} ${PETSC_KSP_LIB}\n') makefile.write('\t@${RM} -f checklink checklink.o\n') makefile.write('LOCDIR = ./\n') makefile.write('include '+os.path.join('${PETSC_DIR}','lib','petsc','conf','variables')+'\n') makefile.write('include '+os.path.join('${PETSC_DIR}','lib','petsc','conf','rules')+'\n') makefile.close() except: self.log.Exit('ERROR: Cannot create makefile in temporary directory') # Create source file code = '#include "petscksp.h"\n' for f in functions: code += 'PETSC_EXTERN int\n' + f + '();\n' for c in callbacks: code += 'int '+ c + '() { return 0; } \n' code += 'int main() {\n' code += 'Vec v; Mat m; KSP k;\n' code += 'PetscInitializeNoArguments();\n' code += 'VecCreate(PETSC_COMM_WORLD,&v);\n' code += 'MatCreate(PETSC_COMM_WORLD,&m);\n' code += 'KSPCreate(PETSC_COMM_WORLD,&k);\n' for f in functions: code += f + '();\n' code += 'return 0;\n}\n' cfile = open(os.path.join(tmpdir,'checklink.c'),'w') cfile.write(code) cfile.close() # Try to compile test program (result, output) = commands.getstatusoutput('cd ' + tmpdir + ';' + self.make + ' checklink TESTFLAGS="'+' '.join(flags)+'"') shutil.rmtree(tmpdir) if result: return (0,code + output) else: return (1,code + output) def Link(self,functions,callbacks,flags): (result, output) = self.LinkWithOutput(functions,callbacks,flags) self.log.write(output) return result def FortranLink(self,functions,callbacks,flags): output = '\n=== With linker flags: '+' '.join(flags) f = [] for i in functions: f.append(i+'_') c = [] for i in callbacks: c.append(i+'_') (result, output1) = self.LinkWithOutput(f,c,flags) output1 = '\n====== With underscore Fortran names\n' + output1 if result: return ('UNDERSCORE',output1) f = [] for i in functions: f.append(i.upper()) c = [] for i in callbacks: c.append(i.upper()) (result, output2) = self.LinkWithOutput(f,c,flags) output2 = '\n====== With capital Fortran names\n' + output2 if result: return ('CAPS',output2) (result, output3) = self.LinkWithOutput(functions,callbacks,flags) output3 = '\n====== With unmodified Fortran names\n' + output3 if result: return ('STDCALL',output3) return ('',output + output1 + output2 + output3) def GenerateGuesses(self,name): installdirs = [os.path.join(os.path.sep,'usr','local'),os.path.join(os.path.sep,'opt')] if 'HOME' in os.environ: installdirs.insert(0,os.environ['HOME']) dirs = [] for i in installdirs: dirs = dirs + [os.path.join(i,'lib')] for d in [name,name.upper(),name.lower()]: dirs = dirs + [os.path.join(i,d)] dirs = dirs + [os.path.join(i,d,'lib')] dirs = dirs + [os.path.join(i,'lib',d)] for d in dirs[:]: if not os.path.exists(d): dirs.remove(d) dirs = [''] + dirs return dirs def FortranLib(self,conf,vars,cmake,dirs,libs,functions,callbacks = []): name = self.packagename.upper() error = '' mangling = '' for d in dirs: for l in libs: if d: if 'rpath' in self.slflag: flags = [self.slflag + d] + ['-L' + d] + l else: flags = ['-L' + d] + l else: flags = l (mangling, output) = self.FortranLink(functions,callbacks,flags) error += output if mangling: break if mangling: break if mangling: self.log.write(output) else: self.log.write(error) self.log.Println('\nERROR: Unable to link with library '+ name) self.log.Println('ERROR: In directories '+' '.join(dirs)) self.log.Println('ERROR: With flags '+' '.join(flags)) self.log.Exit('') conf.write('#ifndef SLEPC_HAVE_' + name + '\n#define SLEPC_HAVE_' + name + ' 1\n#define SLEPC_' + name + '_HAVE_'+mangling+' 1\n#endif\n\n') vars.write(name + '_LIB = '+' '.join(flags)+'\n') cmake.write('set (SLEPC_HAVE_' + name + ' YES)\n') libname = ' '.join([s.lstrip('-l') for s in l]) cmake.write('set (' + name + '_LIB "")\nforeach (libname ' + libname + ')\n string (TOUPPER ${libname} LIBNAME)\n find_library (${LIBNAME}LIB ${libname} HINTS '+ d +')\n list (APPEND ' + name + '_LIB "${${LIBNAME}LIB}")\nendforeach()\n') self.havepackage = True self.packageflags = flags slepc-3.7.4/config/cmakegen.py0000755000175000017500000003104013107004621015555 0ustar jromanjroman#!/usr/bin/env python # This file generates $SLEPC_DIR/CMakeLists.txt by parsing the makefiles # throughout the source tree, reading their constraints and included # sources, and encoding the rules through CMake conditionals. When CMake # runs, it will use the conditionals written to # # $SLEPC_DIR/$PETSC_ARCH/lib/slepc/conf/SLEPcBuildInternal.cmake # # after a successful configure. # # The generated CMakeLists.txt is independent of PETSC_ARCH. # # This script supports one option: # --verbose : Show mismatches between makefiles and the filesystem import os from collections import deque # compatibility code for python-2.4 from http://code.activestate.com/recipes/523034-emulate-collectionsdefaultdict/ try: from collections import defaultdict except: class defaultdict(dict): def __init__(self, default_factory=None, *a, **kw): if (default_factory is not None and not hasattr(default_factory, '__call__')): raise TypeError('first argument must be callable') dict.__init__(self, *a, **kw) self.default_factory = default_factory def __getitem__(self, key): try: return dict.__getitem__(self, key) except KeyError: return self.__missing__(key) def __missing__(self, key): if self.default_factory is None: raise KeyError(key) self[key] = value = self.default_factory() return value def __reduce__(self): if self.default_factory is None: args = tuple() else: args = self.default_factory, return type(self), args, None, None, self.items() def copy(self): return self.__copy__() def __copy__(self): return type(self)(self.default_factory, self) def __deepcopy__(self, memo): import copy return type(self)(self.default_factory, copy.deepcopy(self.items())) def __repr__(self): return 'defaultdict(%s, %s)' % (self.default_factory, dict.__repr__(self)) class StdoutLogger(object): def write(self,str): print(str) def cmakeconditional(key,val): def unexpected(): raise RuntimeError('Unexpected') if key in ['package', 'function', 'define']: return val if key == 'precision': if val == 'double': return 'PETSC_USE_REAL_DOUBLE' elif val == 'single': return 'PETSC_USE_REAL_SINGLE' raise RuntimeError('Unexpected precision: %r'%val) if key == 'scalar': if val == 'real': return 'NOT PETSC_USE_COMPLEX' if val == 'complex': return 'PETSC_USE_COMPLEX' raise RuntimeError('Unexpected scalar: %r'%val) if key == 'language': if val == 'CXXONLY': return 'PETSC_CLANGUAGE_Cxx' if val == 'CONLY': return 'PETSC_CLANGUAGE_C' raise RuntimeError('Unexpected language: %r'%val) raise RuntimeError('Unhandled case: %r=%r'%(key,val)) AUTODIRS = set('ftn-auto ftn-custom f90-custom'.split()) # Automatically recurse into these, if they exist SKIPDIRS = set('benchmarks'.split()) # Skip these during the build NOWARNDIRS = set('tests tutorials'.split()) # Do not warn about mismatch in these def pathsplit(path): """Recursively split a path, returns a tuple""" stem, basename = os.path.split(path) if stem == '': return (basename,) if stem == path: # fixed point, likely '/' return (path,) return pathsplit(stem) + (basename,) class Mistakes(object): def __init__(self, log, verbose=False): self.mistakes = [] self.verbose = verbose self.log = log def compareDirLists(self,root, mdirs, dirs): if NOWARNDIRS.intersection(pathsplit(root)): return smdirs = set(mdirs) sdirs = set(dirs).difference(AUTODIRS) if not smdirs.issubset(sdirs): self.mistakes.append('Makefile contains directory not on filesystem: %s: %r' % (root, sorted(smdirs - sdirs))) if not self.verbose: return if smdirs != sdirs: from sys import stderr stderr.write('Directory mismatch at %s:\n\t%s: %r\n\t%s: %r\n\t%s: %r\n' % (root, 'in makefile ',sorted(smdirs), 'on filesystem ',sorted(sdirs), 'symmetric diff',sorted(smdirs.symmetric_difference(sdirs)))) def compareSourceLists(self, root, msources, files): if NOWARNDIRS.intersection(pathsplit(root)): return smsources = set(msources) ssources = set(f for f in files if os.path.splitext(f)[1] in ['.c', '.cxx', '.cc', '.cu', '.cpp', '.F']) if not smsources.issubset(ssources): self.mistakes.append('Makefile contains file not on filesystem: %s: %r' % (root, sorted(smsources - ssources))) if not self.verbose: return if smsources != ssources: from sys import stderr stderr.write('Source mismatch at %s:\n\t%s: %r\n\t%s: %r\n\t%s: %r\n' % (root, 'in makefile ',sorted(smsources), 'on filesystem ',sorted(ssources), 'symmetric diff',sorted(smsources.symmetric_difference(ssources)))) def summary(self): for m in self.mistakes: self.log.write(m + '\n') if self.mistakes: raise RuntimeError('SLEPc makefiles contain mistakes or files are missing on filesystem.\n%s\nPossible reasons:\n\t1. Files were deleted locally, try "hg revert filename" or "git checkout filename".\n\t2. Files were deleted from repository, but were not removed from makefile. Send mail to slepc-maint@upv.es.\n\t3. Someone forgot to "add" new files to the repository. Send mail to slepc-maint@upv.es.' % ('\n'.join(self.mistakes))) def stripsplit(line): return line[len('#requires'):].replace("'","").split() def pkgsources(pkg, mistakes): ''' Walks the source tree associated with 'pkg', analyzes the conditional written into the makefiles, and returns a list of sources associated with each unique conditional (as a dictionary). ''' from distutils.sysconfig import parse_makefile allconditions = defaultdict(set) sources = defaultdict(deque) for root,dirs,files in os.walk(os.path.join('src',pkg)): conditions = allconditions[os.path.dirname(root)].copy() makefile = os.path.join(root,'makefile') if not os.path.exists(makefile): continue makevars = parse_makefile(makefile) mdirs = makevars.get('DIRS','').split() # Directories specified in the makefile mistakes.compareDirLists(root,mdirs,dirs) # diagnostic output to find unused directories candidates = set(mdirs).union(AUTODIRS).difference(SKIPDIRS) dirs[:] = list(candidates.intersection(dirs)) lines = open(makefile) conditions.update(set(tuple(stripsplit(line)) for line in lines if line.startswith('#requires'))) lines.close() def relpath(filename): return os.path.join(root,filename) sourcecu = makevars.get('SOURCECU','').split() sourcec = makevars.get('SOURCEC','').split() sourcecxx = makevars.get('SOURCECXX','').split() sourcef = makevars.get('SOURCEF','').split() mistakes.compareSourceLists(root,sourcec+sourcecxx+sourcef+sourcecu, files) # Diagnostic output about unused source files sources[repr(sorted(conditions))].extend(relpath(f) for f in sourcec + sourcecxx + sourcef + sourcecu) allconditions[root] = conditions return sources def writeRoot(f,petscdir,petscdestdir): f.write(r'''cmake_minimum_required (VERSION 2.6.2) project (SLEPc C) set (PETSc_SOURCE_DIR %s) set (PETSc_BINARY_DIR %s) include (${PETSc_BINARY_DIR}/lib/petsc/conf/PETScBuildInternal.cmake) include (${PETSC_CMAKE_ARCH}/lib/slepc/conf/SLEPcBuildInternal.cmake) if (PETSC_HAVE_FORTRAN) enable_language (Fortran) endif () if (PETSC_CLANGUAGE_Cxx OR PETSC_HAVE_CXX) enable_language (CXX) endif () if (APPLE) SET(CMAKE_C_ARCHIVE_FINISH " -c ") SET(CMAKE_CXX_ARCHIVE_FINISH " -c ") SET(CMAKE_Fortran_ARCHIVE_FINISH " -c ") endif () if (PETSC_HAVE_CUDA) find_package (CUDA REQUIRED) set (CUDA_PROPAGATE_HOST_FLAGS OFF) set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --compiler-options ${PETSC_CUDA_HOST_FLAGS}) endif () include_directories ("${PETSc_SOURCE_DIR}/include" "${PETSc_BINARY_DIR}/include") include_directories ("${SLEPc_SOURCE_DIR}/include" "${SLEPc_BINARY_DIR}/include") set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${SLEPc_BINARY_DIR}/lib" CACHE PATH "Output directory for SLEPc archives") set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${SLEPc_BINARY_DIR}/lib" CACHE PATH "Output directory for SLEPc libraries") set (CMAKE_Fortran_MODULE_DIRECTORY "${SLEPc_BINARY_DIR}/include" CACHE PATH "Output directory for fortran *.mod files") mark_as_advanced (CMAKE_ARCHIVE_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_Fortran_MODULE_DIRECTORY) set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) ################### The following describes the build #################### ''' % (petscdir,petscdestdir)) def writePackage(f,pkg,pkgdeps,mistakes): for conds, srcs in pkgsources(pkg,mistakes).items(): conds = eval(conds) def body(indentlevel): indent = ' '*(indentlevel+2) lfindent = '\n'+indent return ' '*indentlevel + 'list (APPEND SLEPC' + pkg.upper() + '_SRCS' + lfindent + lfindent.join(srcs) + lfindent + ')\n' if conds: f.write('if (%s)\n%sendif ()\n' % (' AND '.join(cmakeconditional(*c) for c in conds), body(2))) else: f.write(body(0)) f.write(''' if (NOT PETSC_USE_SINGLE_LIBRARY) if (PETSC_HAVE_CUDA) cuda_add_library (slepc%(pkg)s ${SLEPC%(PKG)s_SRCS}) else () add_library (slepc%(pkg)s ${SLEPC%(PKG)s_SRCS}) endif () target_link_libraries (slepc%(pkg)s %(pkgdeps)s ${PETSC_LIB} ${SLEPC_PACKAGE_LIBS} ${PETSC_PACKAGE_LIBS}) if (PETSC_WIN32FE) set_target_properties (slepc%(pkg)s PROPERTIES RULE_LAUNCH_COMPILE "${PETSC_WIN32FE}") set_target_properties (slepc%(pkg)s PROPERTIES RULE_LAUNCH_LINK "${PETSC_WIN32FE}") endif () endif () ''' % dict(pkg=pkg, PKG=pkg.upper(), pkgdeps=' '.join('slepc%s'%p for p in pkgdeps))) def main(slepcdir,petscdir,petscdestdir,log=StdoutLogger(), verbose=False): import tempfile, shutil written = False # We delete the temporary file if it wasn't finished, otherwise rename (atomic) mistakes = Mistakes(log=log, verbose=verbose) fd,tmplists = tempfile.mkstemp(prefix='CMakeLists.txt.',dir=slepcdir,text=True) try: f = os.fdopen(fd,'w') writeRoot(f,petscdir,petscdestdir) f.write('include_directories (${PETSC_PACKAGE_INCLUDES} ${SLEPC_PACKAGE_INCLUDES})\n') pkglist = [('sys' , ''), ('eps' , 'sys'), ('svd' , 'eps sys'), ('pep' , 'eps sys'), ('nep' , 'pep eps sys'), ('mfn' , 'sys')] for pkg,deps in pkglist: writePackage(f,pkg,deps.split(),mistakes) f.write (''' if (PETSC_USE_SINGLE_LIBRARY) if (PETSC_HAVE_CUDA) cuda_add_library (slepc %(allsrc)s) else () add_library (slepc %(allsrc)s) endif () target_link_libraries (slepc ${PETSC_LIB} ${SLEPC_PACKAGE_LIBS} ${PETSC_PACKAGE_LIBS}) if (PETSC_WIN32FE) set_target_properties (slepc PROPERTIES RULE_LAUNCH_COMPILE "${PETSC_WIN32FE}") set_target_properties (slepc PROPERTIES RULE_LAUNCH_LINK "${PETSC_WIN32FE}") endif () endif () ''' % dict(allsrc=' '.join([r'${SLEPC' + pkg.upper() + r'_SRCS}' for pkg,deps in pkglist]),)) f.write(''' if (PETSC_CLANGUAGE_Cxx) foreach (file IN LISTS %s) if (file MATCHES "^.*\\\\.c$") set_source_files_properties(${file} PROPERTIES LANGUAGE CXX) endif () endforeach () endif()''' % ('\n '.join([r'SLEPC' + pkg.upper() + r'_SRCS' for (pkg,_) in pkglist]))) written = True finally: f.close() if written: shutil.move(tmplists,os.path.join(slepcdir,'CMakeLists.txt')) else: os.remove(tmplists) mistakes.summary() if __name__ == "__main__": import optparse parser = optparse.OptionParser() parser.add_option('--verbose', help='Show mismatches between makefiles and the filesystem', dest='verbose', action='store_true', default=False) (opts, extra_args) = parser.parse_args() main(slepcdir=os.environ['SLEPC_DIR'],petscdir=os.environ['PETSC_DIR'],petscdestdir=os.sep.join([os.environ['PETSC_DIR'],os.environ['PETSC_ARCH']]), verbose=opts.verbose) slepc-3.7.4/config/packages/0000755000175000017500000000000013107004621015206 5ustar jromanjromanslepc-3.7.4/config/packages/sowing.py0000644000175000017500000000450713107004621017074 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, sys, commands import log, package class Sowing(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'sowing' self.downloadable = True self.url = 'https://bitbucket.org/petsc/pkg-sowing.git' self.ProcessArgs(argdb) def Install(self,archdir,make): name = self.packagename.upper() self.log.NewSection('Installing '+name+'...') # Create externalpackages directory externdir = os.path.join(archdir,'externalpackages') if not os.path.exists(externdir): try: os.mkdir(externdir) except: self.log.Exit('ERROR: cannot create directory ' + externdir) # Check if source is already available builddir = os.path.join(externdir,'pkg-sowing') if os.path.exists(builddir): self.log.write('Using '+builddir) else: # clone Sowing repo url = self.packageurl if url=='': url = self.url try: result,output = commands.getstatusoutput('cd '+externdir+'&& git clone '+url) self.log.write(output) except RuntimeError, e: self.log.Exit('Error cloning '+url+': '+str(e)) # Configure, build and install package result,output = commands.getstatusoutput('cd '+builddir+'&& ./configure --prefix='+archdir+'&&'+make+'&&'+make+' install') self.log.write(output) self.havepackage = True return os.path.join(archdir,'bin','bfort') slepc-3.7.4/config/packages/primme.py0000644000175000017500000001217613107004621017060 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, commands, shutil import log, package class Primme(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'primme' self.installable = True self.downloadable = True self.version = '1.2.2' self.url = 'https://github.com/primme/primme/tarball/release-'+self.version self.archive = 'primme-'+self.version+'.tar.gz' self.dirname = 'PRIMME' self.ProcessArgs(argdb) def Check(self,conf,vars,cmake,petsc): functions_base = ['primme_set_method','primme_Free','primme_initialize'] if self.packagedir: dirs = [self.packagedir] else: dirs = self.GenerateGuesses('Primme') libs = self.packagelibs if not libs: libs = ['-lprimme'] if petsc.scalar == 'real': functions = functions_base + ['dprimme'] else: functions = functions_base + ['zprimme'] for d in dirs: if d: if 'rpath' in petsc.slflag: l = [petsc.slflag + d] + ['-L' + d] + libs else: l = ['-L' + d] + libs f = ['-I' + os.path.join(d,'PRIMMESRC','COMMONSRC')] else: l = libs f = [] if self.Link(functions,[],l+f): conf.write('#ifndef SLEPC_HAVE_PRIMME\n#define SLEPC_HAVE_PRIMME 1\n#endif\n\n') vars.write('PRIMME_LIB = ' + ' '.join(l) + '\n') vars.write('PRIMME_FLAGS = ' + ' '.join(f) + '\n') cmake.write('set (SLEPC_HAVE_PRIMME YES)\n') cmake.write('find_library (PRIMME_LIB primme HINTS '+ d +')\n') cmake.write('find_path (PRIMME_INCLUDE primme.h ' + d + '/PRIMMESRC/COMMONSRC)\n') self.havepackage = True self.packageflags = l+f return self.log.Println('\nERROR: Unable to link with PRIMME library') self.log.Println('ERROR: In directories '+' '.join(dirs)) self.log.Println('ERROR: With flags '+' '.join(libs)) self.log.Exit('') def Install(self,conf,vars,cmake,petsc,archdir): externdir = os.path.join(archdir,'externalpackages') builddir = os.path.join(externdir,self.dirname) self.Download(externdir,builddir,'primme-') # Configure g = open(os.path.join(builddir,'Make_flags'),'w') g.write('LIBRARY = libprimme.a\n') g.write('DLIBRARY = libdprimme.a\n') g.write('ZLIBRARY = libzprimme.a\n') g.write('CC = '+petsc.cc+'\n') g.write('DEFINES = ') if petsc.blaslapackunderscore: g.write('-DF77UNDERSCORE ') if petsc.blaslapackint64: g.write('-DPRIMME_BLASINT_SIZE=64') g.write('\n') g.write('INCLUDE = \n') g.write('CFLAGS = '+petsc.cc_flags.replace('-Wall','').replace('-Wshadow','')+'\n') g.write('RANLIB = '+petsc.ranlib+'\n') g.close() # Build package result,output = commands.getstatusoutput('cd '+builddir+'&&'+petsc.make+' clean &&'+petsc.make) self.log.write(output) if result: self.log.Exit('ERROR: installation of PRIMME failed.') # Move files incDir = os.path.join(archdir,'include') libDir = os.path.join(archdir,'lib') os.rename(os.path.join(builddir,'libprimme.'+petsc.ar_lib_suffix),os.path.join(libDir,'libprimme.'+petsc.ar_lib_suffix)) for name in ['primme.h','primme_f77.h','Complexz.h']: shutil.copyfile(os.path.join(builddir,'PRIMMESRC','COMMONSRC',name),os.path.join(incDir,name)) if 'rpath' in petsc.slflag: l = petsc.slflag + libDir + ' -L' + libDir + ' -lprimme' else: l = '-L' + libDir + ' -lprimme' f = '-I' + incDir # Check build functions_base = ['primme_set_method','primme_Free','primme_initialize'] if petsc.scalar == 'real': functions = functions_base + ['dprimme'] else: functions = functions_base + ['zprimme'] if not self.Link(functions,[],[l]+[f]): self.log.Exit('\nERROR: Unable to link with downloaded PRIMME') # Write configuration files conf.write('#ifndef SLEPC_HAVE_PRIMME\n#define SLEPC_HAVE_PRIMME 1\n#endif\n\n') vars.write('PRIMME_LIB = ' + l + '\n') cmake.write('set (SLEPC_HAVE_PRIMME YES)\n') cmake.write('find_library (PRIMME_LIB primme HINTS '+ libDir +')\n') cmake.write('find_path (PRIMME_INCLUDE primme.h ' + incDir + ')\n') self.havepackage = True self.packageflags = [l] + [f] slepc-3.7.4/config/packages/slepc.py0000644000175000017500000000725513107004621016677 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import argdb, os, sys, commands class SLEPc: def __init__(self,argdb,log): self.log = log self.clean = argdb.PopBool('with-clean') self.cmake = argdb.PopBool('with-cmake') self.prefixdir = argdb.PopPath('prefix')[0] self.isinstall = not self.prefixdir=='' self.datadir = argdb.PopPath('DATAFILESPATH')[0] def ShowHelp(self): print '''SLEPc: --with-clean= : Delete prior build files including externalpackages --with-cmake= : Enable builds with CMake (disabled by default) --prefix= : Specify location to install SLEPc (e.g., /usr/local) --DATAFILESPATH= : Specify location of datafiles (for SLEPc developers)''' def InitDir(self): if 'SLEPC_DIR' in os.environ: self.dir = os.environ['SLEPC_DIR'] if not os.path.exists(self.dir) or not os.path.exists(os.path.join(self.dir,'config')): sys.exit('ERROR: SLEPC_DIR enviroment variable is not valid') if os.path.realpath(os.getcwd()) != os.path.realpath(self.dir): sys.exit('ERROR: SLEPC_DIR is not the current directory') else: self.dir = os.getcwd() if not os.path.exists(os.path.join(self.dir,'config')): sys.exit('ERROR: Current directory is not valid') def LoadVersion(self): try: f = open(os.path.join(self.dir,'include','slepcversion.h')) for l in f.readlines(): l = l.split() if len(l) == 3: if l[1] == 'SLEPC_VERSION_RELEASE': self.release = l[2] if l[1] == 'SLEPC_VERSION_MAJOR': major = l[2] elif l[1] == 'SLEPC_VERSION_MINOR': minor = l[2] elif l[1] == 'SLEPC_VERSION_SUBMINOR': subminor = l[2] elif l[1] == 'SLEPC_VERSION_PATCH': patchlevel = l[2] f.close() self.version = major + '.' + minor self.lversion = major + '.' + minor + '.' + subminor except: self.log.Exit('ERROR: file error while reading SLEPc version') # Check whether this is a working copy of the repository self.isrepo = False if os.path.exists(os.path.join(self.dir,'src','docs')) and os.path.exists(os.path.join(self.dir,'.git')): (status, output) = commands.getstatusoutput('git rev-parse') if status: print 'WARNING: SLEPC_DIR appears to be a git working copy, but git is not found in PATH' else: self.isrepo = True (status, self.gitrev) = commands.getstatusoutput('git describe') if not self.gitrev: (status, self.gitrev) = commands.getstatusoutput('git log -1 --pretty=format:%H') (status, self.gitdate) = commands.getstatusoutput('git log -1 --pretty=format:%ci') (status, self.branch) = commands.getstatusoutput('git describe --contains --all HEAD') slepc-3.7.4/config/packages/blopex.py0000644000175000017500000000670413107004621017060 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, commands, shutil import log, package class Blopex(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'blopex' self.downloadable = True self.version = '1.1.2' self.url = 'http://slepc.upv.es/download/external/blopex-'+self.version+'.tar.gz' self.archive = 'blopex.tar.gz' self.dirname = 'blopex-'+self.version self.ProcessArgs(argdb) def Install(self,conf,vars,cmake,petsc,archdir): externdir = os.path.join(archdir,'externalpackages') builddir = os.path.join(externdir,self.dirname) self.Download(externdir,builddir) # Configure g = open(os.path.join(builddir,'Makefile.inc'),'w') g.write('CC = '+petsc.cc+'\n') if petsc.ind64: blopexint = ' -DBlopexInt="long long" ' else: blopexint = '' g.write('CFLAGS = '+petsc.cc_flags.replace('-Wall','').replace('-Wshadow','')+blopexint+'\n') g.write('AR = '+petsc.ar+' '+petsc.ar_flags+'\n') g.write('AR_LIB_SUFFIX = '+petsc.ar_lib_suffix+'\n') g.write('RANLIB = '+petsc.ranlib+'\n') g.write('TARGET_ARCH = \n') g.close() # Build package result,output = commands.getstatusoutput('cd '+builddir+'&&'+petsc.make+' clean &&'+petsc.make) self.log.write(output) if result: self.log.Exit('ERROR: installation of BLOPEX failed.') # Move files incDir = os.path.join(archdir,'include') libDir = os.path.join(archdir,'lib') os.rename(os.path.join(builddir,'lib','libBLOPEX.'+petsc.ar_lib_suffix),os.path.join(libDir,'libBLOPEX.'+petsc.ar_lib_suffix)) for root, dirs, files in os.walk(os.path.join(builddir,'include')): for name in files: shutil.copyfile(os.path.join(builddir,'include',name),os.path.join(incDir,name)) if 'rpath' in petsc.slflag: l = petsc.slflag + libDir + ' -L' + libDir + ' -lBLOPEX' else: l = '-L' + libDir + ' -lBLOPEX' f = '-I' + incDir # Check build if petsc.scalar == 'real': functions = ['lobpcg_solve_double'] else: functions = ['lobpcg_solve_complex'] if not self.Link(functions,[],[l]+[f]): self.log.Exit('\nERROR: Unable to link with downloaded BLOPEX') # Write configuration files conf.write('#ifndef SLEPC_HAVE_BLOPEX\n#define SLEPC_HAVE_BLOPEX 1\n#endif\n\n') vars.write('BLOPEX_LIB = ' + l + '\n') cmake.write('set (SLEPC_HAVE_BLOPEX YES)\n') cmake.write('find_library (BLOPEX_LIB BLOPEX HINTS '+ libDir +')\n') self.havepackage = True self.packageflags = [l] + [f] slepc-3.7.4/config/packages/petsc.py0000644000175000017500000001473413107004621016707 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import package, os, sys, commands class PETSc(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'petsc' def Check(self): self.havepackage = self.Link([],[],[]) def InitDir(self,prefixdir): if 'PETSC_DIR' in os.environ: self.dir = os.environ['PETSC_DIR'] if not os.path.exists(self.dir): sys.exit('ERROR: PETSC_DIR enviroment variable is not valid') else: if prefixdir: self.dir = prefixdir os.environ['PETSC_DIR'] = self.dir else: sys.exit('ERROR: PETSC_DIR enviroment variable is not set') def LoadVersion(self): try: f = open(os.path.join(self.dir,'include','petscversion.h')) for l in f.readlines(): l = l.split() if len(l) == 3: if l[1] == 'PETSC_VERSION_RELEASE': self.release = l[2] if l[1] == 'PETSC_VERSION_MAJOR': major = l[2] elif l[1] == 'PETSC_VERSION_MINOR': minor = l[2] elif l[1] == 'PETSC_VERSION_SUBMINOR': subminor = l[2] elif l[1] == 'PETSC_VERSION_PATCH': patchlevel = l[2] f.close() self.version = major + '.' + minor self.lversion = major + '.' + minor + '.' + subminor except: self.log.Exit('ERROR: File error while reading PETSc version') # Check whether this is a working copy of the repository self.isrepo = False if os.path.exists(os.path.join(self.dir,'.git')): (status, output) = commands.getstatusoutput('cd '+self.dir+';git rev-parse') if not status: self.isrepo = True (status, self.gitrev) = commands.getstatusoutput('cd '+self.dir+';git log -1 --pretty=format:%H') (status, self.gitdate) = commands.getstatusoutput('cd '+self.dir+';git log -1 --pretty=format:%ci') (status, self.branch) = commands.getstatusoutput('cd '+self.dir+';git describe --contains --all HEAD') def LoadConf(self): if 'PETSC_ARCH' in os.environ and os.environ['PETSC_ARCH']: self.isinstall = False self.arch = os.environ['PETSC_ARCH'] petscvariables = os.path.join(self.dir,self.arch,'lib','petsc','conf','petscvariables') petscconf_h = os.path.join(self.dir,self.arch,'include','petscconf.h') else: self.isinstall = True petscvariables = os.path.join(self.dir,'lib','petsc','conf','petscvariables') petscconf_h = os.path.join(self.dir,'include','petscconf.h') self.build_using_cmake = 0 self.make_is_gnumake = 0 self.language = 'c' self.bfort = 'nobfortinpetsc' try: f = open(petscvariables) for l in f.readlines(): r = l.split('=',1) if len(r)!=2: continue k = r[0].strip() v = r[1].strip() if k == 'PETSC_SCALAR': self.scalar = v elif k == 'PETSC_PRECISION': self.precision = v elif k == 'MAKE': self.make = v elif k == 'DESTDIR': self.destdir = v elif k == 'BFORT': self.bfort = v elif k == 'TEST_RUNS': self.test_runs = v elif k == 'CC': self.cc = v elif k == 'CC_FLAGS': self.cc_flags = v elif k == 'FC' and not v=='': self.fc = v elif k == 'FC_FLAGS': self.fc_flags = v elif k == 'AR': self.ar = v elif k == 'AR_FLAGS': self.ar_flags = v elif k == 'AR_LIB_SUFFIX': self.ar_lib_suffix = v elif k == 'CC_LINKER_SLFLAG': self.slflag = v elif k == 'RANLIB': self.ranlib = v elif k == 'PETSC_BUILD_USING_CMAKE': self.build_using_cmake = v elif k == 'MAKE_IS_GNUMAKE': self.make_is_gnumake = v elif k == 'PETSC_LANGUAGE' and v=='CXXONLY': self.language = 'c++' f.close() except: self.log.Exit('ERROR: cannot process file ' + petscvariables) self.ind64 = False self.mpiuni = False self.debug = False self.singlelib = False self.blaslapackunderscore = False self.blaslapackint64 = False try: f = open(petscconf_h) for l in f.readlines(): l = l.split() if len(l)==3 and l[0]=='#define' and l[1]=='PETSC_USE_64BIT_INDICES' and l[2]=='1': self.ind64 = True elif len(l)==3 and l[0]=='#define' and l[1]=='PETSC_HAVE_MPIUNI' and l[2]=='1': self.mpiuni = True elif len(l)==3 and l[0]=='#define' and l[1]=='PETSC_USE_DEBUG' and l[2]=='1': self.debug = True elif len(l)==3 and l[0]=='#define' and l[1]=='PETSC_USE_SINGLE_LIBRARY' and l[2]=='1': self.singlelib = True elif len(l)==3 and l[0]=='#define' and l[1]=='PETSC_BLASLAPACK_UNDERSCORE' and l[2]=='1': self.blaslapackunderscore = True elif len(l)==3 and l[0]=='#define' and l[1]=='HAVE_64BIT_BLAS_INDICES' and l[2]=='1': self.blaslapackint64 = True elif self.isinstall and len(l)==3 and l[0]=='#define' and l[1]=='PETSC_ARCH': self.arch = l[2].strip('"') f.close() except: if self.isinstall: self.log.Exit('ERROR: cannot process file ' + petscconf_h + ', maybe you forgot to set PETSC_ARCH') else: self.log.Exit('ERROR: cannot process file ' + petscconf_h) # empty PETSC_ARCH, guess an arch name if self.isinstall and not self.arch: self.arch = 'arch-' + sys.platform.replace('cygwin','mswin')+ '-' + self.language if self.debug: self.arch += '-debug' else: self.arch += '-opt' if not 'real' in self.scalar: self.arch += '-' + self.scalar slepc-3.7.4/config/packages/lapack.py0000644000175000017500000001121613107004621017014 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import log, package class Lapack(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'lapack' def ShowInfo(self): if hasattr(self,'missing'): self.log.Println('LAPACK missing functions:') self.log.Print(' ') for i in self.missing: self.log.Print(i) self.log.Println('') self.log.Println('') self.log.Println('WARNING: Some SLEPc functionality will not be available') self.log.Println('PLEASE reconfigure and recompile PETSc with a full LAPACK implementation') def Process(self,conf,vars,cmake,petsc,archdir=''): self.make = petsc.make self.slflag = petsc.slflag self.log.NewSection('Checking LAPACK library...') self.Check(conf,vars,cmake,petsc) def Check(self,conf,vars,cmake,petsc): # LAPACK standard functions l = ['laev2','gehrd','lanhs','lange','trexc','trevc','geevx','gees','ggev','ggevx','gelqf','geqp3','gesdd','tgexc','tgevc','pbtrf','stedc','hsein','larfg','larf','lacpy','lascl','lansy','laset','trsyl','trtri'] # LAPACK functions with different real and complex versions if petsc.scalar == 'real': l += ['orghr','syevr','syevd','sytrd','sygvd','ormlq','orgtr'] if petsc.precision == 'single': prefix = 's' elif petsc.precision == '__float128': prefix = 'q' else: prefix = 'd' else: l += ['unghr','heevr','heevd','hetrd','hegvd','unmlq','ungtr'] if petsc.precision == 'single': prefix = 'c' elif petsc.precision == '__float128': prefix = 'w' else: prefix = 'z' # add prefix to LAPACK names functions = [] for i in l: functions.append(prefix + i) # in this case, the real name represents both versions namesubst = {'unghr':'orghr', 'heevr':'syevr', 'heevd':'syevd', 'hetrd':'sytrd', 'hegvd':'sygvd', 'unmlq':'ormlq', 'ungtr':'orgtr'} # LAPACK functions which are always used in real version if petsc.precision == 'single': functions += ['sstevr','sbdsdc','slamch','slag2','slasv2','slartg','slaln2','slaed4','slamrg','slapy2'] elif petsc.precision == '__float128': functions += ['qstevr','qbdsdc','qlamch','qlag2','qlasv2','qlartg','qlaln2','qlaed4','qlamrg','qlapy2'] else: functions += ['dstevr','dbdsdc','dlamch','dlag2','dlasv2','dlartg','dlaln2','dlaed4','dlamrg','dlapy2'] # check for all functions at once all = [] for i in functions: f = '#if defined(PETSC_BLASLAPACK_UNDERSCORE)\n' f += i + '_\n' f += '#elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL)\n' f += i.upper() + '\n' f += '#else\n' f += i + '\n' f += '#endif\n' all.append(f) self.log.write('=== Checking all LAPACK functions...') if self.Link(all,[],[]): return # check functions one by one self.missing = [] for i in functions: f = '#if defined(PETSC_BLASLAPACK_UNDERSCORE)\n' f += i + '_\n' f += '#elif defined(PETSC_BLASLAPACK_CAPS) || defined(PETSC_BLASLAPACK_STDCALL)\n' f += i.upper() + '\n' f += '#else\n' f += i + '\n' f += '#endif\n' self.log.write('=== Checking LAPACK '+i+' function...') if not self.Link([f],[],[]): self.missing.append(i) # some complex functions are represented by their real names if i[1:] in namesubst: nf = namesubst[i[1:]] else: nf = i[1:] conf.write('#ifndef SLEPC_MISSING_LAPACK_' + nf.upper() + '\n#define SLEPC_MISSING_LAPACK_' + nf.upper() + ' 1\n#endif\n\n') cmake.write('set (SLEPC_MISSING_LAPACK_' + nf.upper() + ' YES)\n') if self.missing: cmake.write('mark_as_advanced (' + ' '.join([s.upper() for s in self.missing]) + ')\n') slepc-3.7.4/config/packages/blzpack.py0000644000175000017500000000313713107004621017212 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import log, package class Blzpack(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'blzpack' self.installable = True self.supportsscalar = ['real'] self.supportssingle = True self.ProcessArgs(argdb) def Check(self,conf,vars,cmake,petsc): if petsc.precision == 'single': functions = ['blzdrs'] else: functions = ['blzdrd'] if self.packagelibs: libs = [self.packagelibs] else: libs = [['-lblzpack']] if self.packagedir: dirs = [self.packagedir] else: dirs = self.GenerateGuesses('Blzpack') self.FortranLib(conf,vars,cmake,dirs,libs,functions) slepc-3.7.4/config/packages/trlan.py0000644000175000017500000000615713107004621016711 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, commands import log, package class Trlan(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'trlan' self.installable = True self.downloadable = True self.version = '201009' self.url = 'https://codeforge.lbl.gov/frs/download.php/210/trlan-'+self.version+'.tar.gz' self.archive = 'trlan-'+self.version+'.tar.gz' self.dirname = 'trlan-'+self.version self.supportsscalar = ['real'] self.ProcessArgs(argdb) def Check(self,conf,vars,cmake,petsc): functions = ['trlan77'] if self.packagelibs: libs = [self.packagelibs] else: if petsc.mpiuni: libs = [['-ltrlan']] else: libs = [['-ltrlan_mpi']] if self.packagedir: dirs = [self.packagedir] else: dirs = self.GenerateGuesses('TRLan') self.FortranLib(conf,vars,cmake,dirs,libs,functions) def Install(self,conf,vars,cmake,petsc,archdir): externdir = os.path.join(archdir,'externalpackages') builddir = os.path.join(externdir,self.dirname) self.Download(externdir,builddir) # Configure g = open(os.path.join(builddir,'Make.inc'),'w') g.write('FC = '+petsc.fc+'\n') g.write('F90 = '+petsc.fc+'\n') g.write('FFLAGS = '+petsc.fc_flags.replace('-Wall','').replace('-Wshadow','')+'\n') g.write('SHELL = /bin/sh\n') g.close() # Build package if petsc.mpiuni: target = 'lib' else: target = 'plib' result,output = commands.getstatusoutput('cd '+builddir+'&&'+petsc.make+' clean &&'+petsc.make+' '+target) self.log.write(output) if result: self.log.Exit('ERROR: installation of TRLAN failed.') # Move files libDir = os.path.join(archdir,'lib') if petsc.mpiuni: libName = 'libtrlan.a' else: libName = 'libtrlan_mpi.a' os.rename(os.path.join(builddir,libName),os.path.join(libDir,libName)) # Check build functions = ['trlan77'] if petsc.mpiuni: libs = [['-ltrlan']] else: libs = [['-ltrlan_mpi']] libDir = os.path.join(archdir,'lib') dirs = [libDir] self.FortranLib(conf,vars,cmake,dirs,libs,functions) self.havepackage = True slepc-3.7.4/config/packages/arpack.py0000644000175000017500000000772013107004621017027 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, commands import log, package class Arpack(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'arpack' self.installable = True self.downloadable = True self.version = '3.3.0' self.url = 'https://github.com/opencollab/arpack-ng/archive/'+self.version+'.tar.gz' self.archive = 'arpack-ng-'+self.version+'.tar.gz' self.dirname = 'arpack-ng-'+self.version self.supportssingle = True self.ProcessArgs(argdb) def Functions(self,petsc): if petsc.mpiuni: if petsc.scalar == 'real': if petsc.precision == 'single': functions = ['snaupd','sneupd','ssaupd','sseupd'] else: functions = ['dnaupd','dneupd','dsaupd','dseupd'] else: if petsc.precision == 'single': functions = ['cnaupd','cneupd'] else: functions = ['znaupd','zneupd'] else: if petsc.scalar == 'real': if petsc.precision == 'single': functions = ['psnaupd','psneupd','pssaupd','psseupd'] else: functions = ['pdnaupd','pdneupd','pdsaupd','pdseupd'] else: if petsc.precision == 'single': functions = ['pcnaupd','pcneupd'] else: functions = ['pznaupd','pzneupd'] return functions def Check(self,conf,vars,cmake,petsc): functions = self.Functions(petsc) if self.packagelibs: libs = [self.packagelibs] else: if petsc.mpiuni: libs = [['-larpack'],['-larpack_LINUX'],['-larpack_SUN4']] else: libs = [['-lparpack','-larpack'],['-lparpack_MPI','-larpack'],['-lparpack_MPI-LINUX','-larpack_LINUX'],['-lparpack_MPI-SUN4','-larpack_SUN4']] if self.packagedir: dirs = [self.packagedir] else: dirs = self.GenerateGuesses('Arpack') self.FortranLib(conf,vars,cmake,dirs,libs,functions) def Install(self,conf,vars,cmake,petsc,archdir): externdir = os.path.join(archdir,'externalpackages') builddir = os.path.join(externdir,self.dirname) self.Download(externdir,builddir) # Check for autoreconf result,output = commands.getstatusoutput('autoreconf --help') if result: self.log.Exit('ERROR: --download-arpack requires that the command autoreconf is available on your PATH.') # Build package confopt = '--prefix='+archdir+' F77="'+petsc.fc+'" FFLAGS="'+petsc.fc_flags.replace('-Wall','').replace('-Wshadow','')+'"' if not petsc.mpiuni: confopt = confopt+' --enable-mpi' result,output = commands.getstatusoutput('cd '+builddir+'&& sh bootstrap && ./configure '+confopt+' && '+petsc.make+' && '+petsc.make+' install') self.log.write(output) if result: self.log.Exit('ERROR: installation of ARPACK failed.') # Check build functions = self.Functions(petsc) if petsc.mpiuni: libs = [['-larpack']] else: libs = [['-lparpack','-larpack']] libDir = os.path.join(archdir,'lib') dirs = [libDir] self.FortranLib(conf,vars,cmake,dirs,libs,functions) self.havepackage = True slepc-3.7.4/config/packages/feast.py0000644000175000017500000000356413107004621016672 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import log, package class Feast(package.Package): def __init__(self,argdb,log): package.Package.__init__(self,argdb,log) self.packagename = 'feast' self.installable = True self.supportsscalar = ['complex'] self.supportssingle = True self.ProcessArgs(argdb) def Check(self,conf,vars,cmake,petsc): functions = ['feastinit'] if petsc.scalar == 'real': if petsc.precision == 'single': functions += ['sfeast_srci'] else: functions += ['dfeast_srci'] else: if petsc.precision == 'single': functions += ['cfeast_hrci'] else: functions += ['zfeast_hrci'] if self.packagelibs: libs = [self.packagelibs] else: if petsc.mpiuni: libs = [['-lfeast']] else: libs = [['-lpfeast']] if self.packagedir: dirs = [self.packagedir] else: dirs = self.GenerateGuesses('Feast') self.FortranLib(conf,vars,cmake,dirs,libs,functions) slepc-3.7.4/config/log.py0000644000175000017500000000335713107004621014573 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, sys class Log: def Open(self,filename): self.fd = open(filename,'w') try: self.filename = os.path.relpath(filename) # needs python-2.6 except AttributeError: self.filename = filename def Println(self,string): print string self.fd.write(string+'\n') def Print(self,string): print string, self.fd.write(string+' ') def NewSection(self,string): print 'done\n'+string, sys.stdout.flush() self.fd.write('='*80+'\n'+string+'\n') def write(self,string): self.fd.write(string+'\n') def Exit(self,string): print '\n'+string if hasattr(self,'fd'): self.fd.write('\n'+string+'\n') self.fd.close() msg = 'ERROR: See "' + self.filename + '" file for details' else: msg = 'ERROR during configure (log file not open yet)' sys.exit(msg) slepc-3.7.4/config/argdb.py0000644000175000017500000000737513107004621015075 0ustar jromanjroman# # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # SLEPc - Scalable Library for Eigenvalue Problem Computations # Copyright (c) 2002-2016, Universitat Politecnica de Valencia, Spain # # This file is part of SLEPc. # # SLEPc is free software: you can redistribute it and/or modify it under the # terms of version 3 of the GNU Lesser General Public License as published by # the Free Software Foundation. # # SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for # more details. # # You should have received a copy of the GNU Lesser General Public License # along with SLEPc. If not, see . # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # import os, sys class ArgDB: def __init__(self,argv): # standardize options for l in range(1,len(argv)): name = argv[l] if name.startswith('--enable'): argv[l] = name.replace('--enable','--with') if name.find('=') == -1: argv[l] += '=1' elif name.startswith('--disable'): argv[l] = name.replace('--disable','--with') if name.find('=') == -1: argv[l] += '=0' elif name.endswith('=1'): argv[l].replace('=1','=0') elif name.startswith('--without'): argv[l] = name.replace('--without','--with') if name.find('=') == -1: argv[l] += '=0' elif name.endswith('=1'): argv[l].replace('=1','=0') elif name.startswith('--with'): if name.find('=') == -1: argv[l] += '=1' self.argdb = argv[1:] def PopString(self,keyword): string = '' numhits = 0 while True: found = 0 for i, s in enumerate(self.argdb): if s.startswith('--'+keyword+'='): string = s.split('=')[1] found = 1 numhits = numhits + 1 del self.argdb[i] break if not found: break return string,numhits def PopPath(self,keyword): string = '' numhits = 0 while True: found = 0 for i, s in enumerate(self.argdb): if s.startswith('--'+keyword+'='): string = os.path.expanduser(s.split('=')[1].rstrip('/')) found = 1 numhits = numhits + 1 del self.argdb[i] break if not found: break return string,numhits def PopUrl(self,keyword): value = False string = '' numhits = 0 while True: found = 0 for i, s in enumerate(self.argdb): if s.startswith('--'+keyword): value = not s.endswith('=0') try: string = s.split('=')[1] except IndexError: pass found = 1 numhits = numhits + 1 del self.argdb[i] break if not found: break return string,value,numhits def PopBool(self,keyword): value = False numhits = 0 while True: found = 0 for i, s in enumerate(self.argdb): if s.startswith('--'+keyword+'='): value = not s.endswith('=0') found = 1 numhits = numhits + 1 del self.argdb[i] break if not found: break return value def PopHelp(self): value = False numhits = 0 while True: found = 0 for i, s in enumerate(self.argdb): if s.startswith('--h') or s.startswith('-h') or s.startswith('-?'): value = True found = 1 numhits = numhits + 1 del self.argdb[i] break if not found: break return value def ErrorIfNotEmpty(self): if self.argdb: sys.exit('ERROR: Invalid arguments '+' '.join(self.argdb)+'\nUse -h for help') slepc-3.7.4/config/install.py0000755000175000017500000002711313107004621015457 0ustar jromanjroman#!/usr/bin/env python import os, sys, shutil, commands try: WindowsError except NameError: WindowsError = None class Installer: def __init__(self, args = None): if len(args)<6: print '********************************************************************' print 'Installation script error - not enough arguments:' print './config/install.py SLEPC_DIR PETSC_DIR PETSC_ARCH DESTDIR LIB_SUFFIX RANLIB' print '********************************************************************' sys.exit(1) self.rootDir = args[0] self.petscDir = args[1] self.destDir = os.path.abspath(args[2]) self.arch = args[3] self.arLibSuffix = args[4] self.ranlib = ' '.join(args[5:]) self.copies = [] return def setupDirectories(self): self.installDir = self.destDir self.archDir = os.path.join(self.rootDir, self.arch) self.rootIncludeDir = os.path.join(self.rootDir, 'include') self.archIncludeDir = os.path.join(self.rootDir, self.arch, 'include') self.rootConfDir = os.path.join(self.rootDir, 'lib','slepc','conf') self.archConfDir = os.path.join(self.rootDir, self.arch, 'lib','slepc','conf') self.rootBinDir = os.path.join(self.rootDir, 'bin') self.archBinDir = os.path.join(self.rootDir, self.arch, 'bin') self.archLibDir = os.path.join(self.rootDir, self.arch, 'lib') self.destIncludeDir = os.path.join(self.destDir, 'include') self.destConfDir = os.path.join(self.destDir, 'lib','slepc','conf') self.destLibDir = os.path.join(self.destDir, 'lib') self.destBinDir = os.path.join(self.destDir, 'bin') self.installIncludeDir = os.path.join(self.installDir, 'include') self.installBinDir = os.path.join(self.installDir, 'bin') self.rootShareDir = os.path.join(self.rootDir, 'share') self.destShareDir = os.path.join(self.destDir, 'share') return def checkDestdir(self): if os.path.exists(self.destDir): if os.path.samefile(self.destDir, self.rootDir): print '********************************************************************' print 'Incorrect prefix usage. Specified destDir same as current SLEPC_DIR' print '********************************************************************' sys.exit(1) if os.path.samefile(self.destDir, os.path.join(self.rootDir,self.arch)): print '********************************************************************' print 'Incorrect prefix usage. Specified destDir same as current SLEPC_DIR/PETSC_ARCH' print '********************************************************************' sys.exit(1) if not os.path.isdir(os.path.realpath(self.destDir)): print '********************************************************************' print 'Specified destDir', self.destDir, 'is not a directory. Cannot proceed!' print '********************************************************************' sys.exit(1) if not os.access(self.destDir, os.W_OK): print '********************************************************************' print 'Unable to write to ', self.destDir, 'Perhaps you need to do "sudo make install"' print '********************************************************************' sys.exit(1) return def copytree(self, src, dst, symlinks = False, copyFunc = shutil.copy2, exclude = []): """Recursively copy a directory tree using copyFunc, which defaults to shutil.copy2(). The copyFunc() you provide is only used on the top level, lower levels always use shutil.copy2 The destination directory must not already exist. If exception(s) occur, an shutil.Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. """ copies = [] names = os.listdir(src) if not os.path.exists(dst): os.makedirs(dst) elif not os.path.isdir(dst): raise shutil.Error, 'Destination is not a directory' errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copies.extend(self.copytree(srcname, dstname, symlinks,exclude = exclude)) elif not (os.path.basename(srcname) in exclude or os.path.splitext(os.path.basename(srcname))[1]=='.html'): copyFunc(srcname, dstname) copies.append((srcname, dstname)) # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, str(why))) # catch the Error from the recursive copytree so that we can # continue with other files except shutil.Error, err: errors.extend((srcname,dstname,str(err.args[0]))) try: shutil.copystat(src, dst) except OSError, e: if WindowsError is not None and isinstance(e, WindowsError): # Copying file access times may fail on Windows pass else: errors.extend((src, dst, str(e))) if errors: raise shutil.Error, errors return copies def fixConfFile(self, src): lines = [] oldFile = open(src, 'r') for line in oldFile.readlines(): # paths generated by configure could be different link-path than whats used by user, so fix both line = line.replace(os.path.join(self.rootDir, self.arch), self.installDir) line = line.replace(os.path.realpath(os.path.join(self.rootDir, self.arch)), self.installDir) line = line.replace(os.path.join(self.rootDir, 'bin'), self.installBinDir) line = line.replace(os.path.realpath(os.path.join(self.rootDir, 'bin')), self.installBinDir) line = line.replace(os.path.join(self.rootDir, 'include'), self.installIncludeDir) line = line.replace(os.path.realpath(os.path.join(self.rootDir, 'include')), self.installIncludeDir) # remove SLEPC_DIR/PETSC_ARCH variables from conf-makefiles. They are no longer necessary line = line.replace('${SLEPC_DIR}/${PETSC_ARCH}', self.installDir) line = line.replace('PETSC_ARCH=${PETSC_ARCH}', '') line = line.replace('${SLEPC_DIR}', self.installDir) lines.append(line) oldFile.close() newFile = open(src, 'w') newFile.write(''.join(lines)) newFile.close() return def fixConf(self): import shutil for file in ['slepc_rules', 'slepc_variables','slepcrules', 'slepcvariables']: self.fixConfFile(os.path.join(self.destConfDir,file)) self.fixConfFile(os.path.join(self.destLibDir,'pkgconfig','SLEPc.pc')) return def createUninstaller(self): uninstallscript = os.path.join(self.destConfDir, 'uninstall.py') f = open(uninstallscript, 'w') # Could use the Python AST to do this f.write('#!'+sys.executable+'\n') f.write('import os\n') f.write('copies = '+repr(self.copies).replace(self.destDir,self.installDir)) f.write(''' for src, dst in copies: try: os.remove(dst) except: pass ''') #TODO: need to delete libXXX.YYY.dylib.dSYM directory on Mac dirs = [os.path.join('include','slepc','finclude'),os.path.join('include','slepc','private'),os.path.join('lib','slepc','conf')] newdirs = [] for dir in dirs: newdirs.append(os.path.join(self.installDir,dir)) f.write('dirs = '+str(newdirs)) f.write(''' for dir in dirs: import shutil try: shutil.rmtree(dir) except: pass ''') f.close() os.chmod(uninstallscript,0744) return def installIncludes(self): # TODO: should exclude slepc/finclude except for fortran builds self.copies.extend(self.copytree(self.rootIncludeDir, self.destIncludeDir,exclude = ['makefile'])) self.copies.extend(self.copytree(self.archIncludeDir, self.destIncludeDir)) return def installConf(self): self.copies.extend(self.copytree(self.rootConfDir, self.destConfDir, exclude = ['gmakegen.py','install.py'])) self.copies.extend(self.copytree(self.archConfDir, self.destConfDir)) return def installBin(self): #if os.path.exists(self.rootBinDir): # self.copies.extend(self.copytree(self.rootBinDir, self.destBinDir)) #if os.path.exists(self.archBinDir): # self.copies.extend(self.copytree(self.archBinDir, self.destBinDir)) return def installShare(self): self.copies.extend(self.copytree(self.rootShareDir, self.destShareDir)) return def copyLib(self, src, dst): '''Run ranlib on the destination library if it is an archive. Also run install_name_tool on dylib on Mac''' # Symlinks (assumed local) are recreated at dst if os.path.islink(src): linkto = os.readlink(src) try: os.remove(dst) # In case it already exists except OSError: pass os.symlink(linkto, dst) return # Do not install object files if not os.path.splitext(src)[1] == '.o': shutil.copy2(src, dst) if os.path.splitext(dst)[1] == '.'+self.arLibSuffix: (result, output) = commands.getstatusoutput(self.ranlib+' '+dst) if os.path.splitext(dst)[1] == '.dylib' and os.path.isfile('/usr/bin/install_name_tool'): (result, output) = commands.getstatusoutput('otool -D '+src) oldname = output[output.find("\n")+1:] installName = oldname.replace(self.archDir, self.installDir) (result, output) = commands.getstatusoutput('/usr/bin/install_name_tool -id ' + installName + ' ' + dst) # preserve the original timestamps - so that the .a vs .so time order is preserved shutil.copystat(src,dst) return def installLib(self): self.copies.extend(self.copytree(self.archLibDir, self.destLibDir, copyFunc = self.copyLib, exclude = ['.DIR'])) return def outputInstallDone(self): print '''\ ==================================== Install complete. Now to check if the libraries are working do (in current directory): make SLEPC_DIR=%s PETSC_DIR=%s PETSC_ARCH="" test ====================================\ ''' % (self.installDir,self.petscDir) return def outputDestDirDone(self): print '''\ ==================================== Copy to DESTDIR %s is now complete. Before use - please copy/install over to specified prefix: %s ====================================\ ''' % (self.destDir,self.installDir) return def runsetup(self): self.setupDirectories() self.checkDestdir() return def runcopy(self): if self.destDir == self.installDir: print '*** Installing SLEPc at prefix location:',self.destDir, ' ***' else: print '*** Copying SLEPc to DESTDIR location:',self.destDir, ' ***' if not os.path.exists(self.destDir): try: os.makedirs(self.destDir) except: print '********************************************************************' print 'Unable to create', self.destDir, 'Perhaps you need to do "sudo make install"' print '********************************************************************' sys.exit(1) self.installIncludes() self.installConf() self.installBin() self.installLib() self.installShare() return def runfix(self): self.fixConf() return def rundone(self): self.createUninstaller() if self.destDir == self.installDir: self.outputInstallDone() else: self.outputDestDirDone() return def run(self): self.runsetup() self.runcopy() self.runfix() self.rundone() return if __name__ == '__main__': Installer(sys.argv[1:]).run() slepc-3.7.4/config/cmakeboot.py0000755000175000017500000002173213107004621015756 0ustar jromanjroman#!/usr/bin/env python # This file initializes a CMake build in $SLEPC_DIR/$PETSC_ARCH using # the compilers and flags determined by BuildSystem. It is imported and # called by configure.py during configures in which CMake was detected, # but it can also be run as a stand-alone program. The library paths and # flags should have been written to # # $PETSC_DIR/$PETSC_ARCH/lib/petsc/conf/PETScBuildInternal.cmake # $SLEPC_DIR/$PETSC_ARCH/lib/slepc/conf/SLEPcBuildInternal.cmake # # by configure before running this script. import os,sys,string from collections import deque sys.path.insert(0, os.path.join(os.environ['PETSC_DIR'],'config')) sys.path.insert(0, os.path.join(os.environ['PETSC_DIR'],'config','BuildSystem')) import script def noCheck(command, status, output, error): return def quoteIfNeeded(path): "Don't need quotes unless the path has bits that would confuse the shell" safe = string.letters + string.digits + os.path.sep + os.path.pardir + '-_' if set(path).issubset(safe): return path else: return '"' + path + '"' class StdoutLogger(object): def write(self,str): print(str) class PETScMaker(script.Script): def __init__(self, slepcdir, petscdir, petscarch, argDB = None, framework = None): import RDict if not argDB: argDB = RDict.RDict(None, None, 0, 0, readonly = True) argDB.saveFilename = os.path.join(petscdir,petscarch,'lib','petsc','conf','RDict.db') argDB.load() script.Script.__init__(self, argDB = argDB) self.framework = framework self.slepcdir = slepcdir def __str__(self): return '' def setupModules(self): self.mpi = self.framework.require('config.packages.MPI', None) self.base = self.framework.require('config.base', None) self.setCompilers = self.framework.require('config.setCompilers', None) self.arch = self.framework.require('PETSc.options.arch', None) self.petscdir = self.framework.require('PETSc.options.petscdir', None) self.languages = self.framework.require('PETSc.options.languages', None) self.debugging = self.framework.require('PETSc.options.debugging', None) self.cmake = self.framework.require('config.packages.cmake', None) self.compilers = self.framework.require('config.compilers', None) self.types = self.framework.require('config.types', None) self.headers = self.framework.require('config.headers', None) self.functions = self.framework.require('config.functions', None) self.libraries = self.framework.require('config.libraries', None) self.scalarType = self.framework.require('PETSc.options.scalarTypes', None) self.memAlign = self.framework.require('PETSc.options.memAlign', None) self.compilerFlags = self.framework.require('config.compilerFlags', self) return def setup(self): script.Script.setup(self) if not self.framework: self.framework = self.loadConfigure() self.setupModules() def cmakeboot(self, args, log): import shlex self.setup() options = deque() output,error,retcode = self.executeShellCommand([self.cmake.cmake, '--version'], checkCommand=noCheck, log=log) import re m = re.match(r'cmake version (.+)', output) if not m: self.logPrint('Could not parse CMake version: %s, disabling cmake build option' % output) return False from distutils.version import LooseVersion version = LooseVersion(m.groups()[0]) if version < LooseVersion('2.6.2'): self.logPrint('CMake version %s < 2.6.2, disabling cmake build option' % version.vstring) return False if self.languages.clanguage == 'Cxx' and version < LooseVersion('2.8'): self.logPrint('Cannot use --with-clanguage=C++ with CMake version %s < 2.8, disabling cmake build option' % version.vstring) return False # no support for: set_source_files_properties(${file} PROPERTIES LANGUAGE CXX) langlist = [('C','C')] if hasattr(self.compilers,'FC'): langlist.append(('FC','Fortran')) if hasattr(self.compilers,'CUDAC'): langlist.append(('CUDA','CUDA')) if hasattr(self.compilers,'CXX'): langlist.append(('Cxx','CXX')) win32fe = None for petsclanguage,cmakelanguage in langlist: self.setCompilers.pushLanguage(petsclanguage) compiler = self.setCompilers.getCompiler() if (cmakelanguage == 'CUDA'): self.cuda = self.framework.require('config.packages.cuda', None) if (self.cuda.directory != None): options.append('CUDA_TOOLKIT_ROOT_DIR ' + self.cuda.directory + ' CACHE FILEPATH') options.append('CUDA_NVCC_FLAGS ' + self.setCompilers.getCompilerFlags() + ' CACHE STRING') else: flags = [self.setCompilers.getCompilerFlags(), self.setCompilers.CPPFLAGS] if compiler.split()[0].endswith('win32fe'): # Hack to support win32fe without changing the rest of configure win32fe = compiler.split()[0] + '.exe' compiler = ' '.join(compiler.split()[1:]) options.append('CMAKE_'+cmakelanguage+'_COMPILER ' + compiler + ' CACHE FILEPATH') options.append('CMAKE_'+cmakelanguage+'_FLAGS "' + ''.join(flags) + '" CACHE STRING') if (petsclanguage == self.languages.clanguage): #CUDA host compiler is fed with the flags for the standard host compiler flagstring = '' for flag in flags: for f in flag.split(): flagstring += ',' + f options.append('PETSC_CUDA_HOST_FLAGS ' + flagstring + ' CACHE STRING') self.setCompilers.popLanguage() options.append('CMAKE_AR '+self.setCompilers.AR + " CACHE FILEPATH") ranlib = shlex.split(self.setCompilers.RANLIB)[0] options.append('CMAKE_RANLIB '+ranlib + " CACHE FILEPATH") if win32fe: options.append('PETSC_WIN32FE %s' % win32fe) archdir = os.path.join(self.slepcdir, self.arch.arch) initial_cache_filename = os.path.join(archdir, 'initial_cache_file.cmake') cmd = [self.cmake.cmake, '--trace', '--debug-output', '-C' + str(initial_cache_filename), '-DPETSC_CMAKE_ARCH:STRING='+str(self.arch.arch), self.slepcdir] + args if win32fe: # Default on Windows is to generate Visual Studio project files, but # 1. the build process for those is different, need to give different build instructions # 2. the current WIN32FE workaround does not work with VS project files cmd.append('-GUnix Makefiles') # Create inital cache file: initial_cache_file = open(initial_cache_filename, 'w') self.logPrint('Contents of initial cache file %s :' % initial_cache_filename) for option in options: initial_cache_file.write('SET (' + option + ' "Dummy comment" FORCE)\n') self.logPrint('SET (' + option + ' "Dummy comment" FORCE)\n') initial_cache_file.close() try: # Try to remove the old cache because some versions of CMake lose CMAKE_C_FLAGS when reconfiguring this way self.logPrint('Removing: %s' % os.path.join(archdir, 'CMakeCache.txt')) os.remove(os.path.join(archdir, 'CMakeCache.txt')) except OSError: pass import shutil # Try to remove all the old CMake files to avoid infinite loop (CMake-2.8.10.2, maybe other versions) # http://www.mail-archive.com/cmake@cmake.org/msg44765.html self.logPrint('Removing: %s' % os.path.join(archdir, 'CMakeFiles', version.vstring)) shutil.rmtree(os.path.join(archdir, 'CMakeFiles', version.vstring), ignore_errors=True) log.write('Invoking: %s\n' % cmd) output,error,retcode = self.executeShellCommand(cmd, checkCommand = noCheck, log=log, cwd=archdir,timeout=300) if retcode: self.logPrint('CMake setup incomplete (status %d), disabling cmake build option' % (retcode,)) self.logPrint('Output: '+output+'\nError: '+error) cachetxt = os.path.join(archdir, 'CMakeCache.txt') try: f = open(cachetxt, 'r') log.write('Contents of %s:\n' % cachetxt) log.write(f.read()) f.close() except IOError, e: log.write('Could not read file %s: %r\n' % (cachetxt, e)) return False else: return True # Configure successful def main(slepcdir, petscdir, petscarch=os.environ['PETSC_ARCH'], argDB=None, framework=None, log=StdoutLogger(), args=[]): # This can be called as a stand-alone program, or by importing it from # python. The latter functionality is needed because argDB does not # get written until the very end of configure, but we want to run this # automatically during configure (if CMake is available). # # Strangely, we can't store log in the PETScMaker because # (somewhere) it creeps into framework (which I don't want to modify) # and makes the result unpickleable. This is not a problem when run # as a standalone program (because the database is read-only), but is # not okay when called from configure. return PETScMaker(slepcdir,petscdir,petscarch,argDB,framework).cmakeboot(args,log) if __name__ == "__main__": main(slepcdir=os.environ['SLEPC_DIR'], petscdir=os.environ['PETSC_DIR'], petscarch=os.environ['PETSC_ARCH'], args=sys.argv[1:]) slepc-3.7.4/share/0000755000175000017500000000000013107004621013265 5ustar jromanjromanslepc-3.7.4/share/slepc/0000755000175000017500000000000013107004621014373 5ustar jromanjromanslepc-3.7.4/share/slepc/datafiles/0000755000175000017500000000000013107004621016327 5ustar jromanjromanslepc-3.7.4/share/slepc/datafiles/matrices/0000755000175000017500000000000013107004621020136 5ustar jromanjromanslepc-3.7.4/share/slepc/datafiles/matrices/speaker107c.petsc0000644000175000017500000003361413107004621023232 0ustar jromanjroman{Pkk|RRRRRRR  $%)*+,-./0123489=>?@ABCDEFGHLMQRSTUVWXYZ[\]^_`abcdefghij  $%)*+,-./0123489=>?@ABCDEFGHLMQRSTUVWXYZ[\]^_`abcdefghij  $%)*+,-./0123489=>?@ABCDEFGHLMQRSTUVWXYZ[\]^_`abcdefghij  $%)*+,-./0123489=>?@ABCDEFGHLMQRSTUVWXYZ[\]^_`abcdefghij  $%)*+,-./0123489=>?@ABCDEFGHLMQRSTUVWXYZ[\]^_`abcdefghij  $%)*+,-./0123489=>?@ABCDEFGHLMQRSTUVWXYZ[\]^_`abcdefghij  $%)*+,-./0123489=>?@ABCDEFGHLMQRSTUVWXYZ[\]^_`abcdefghij?/ -=!Ѡ3vk!Ѡ?/ -/?I?Rlpl;w?^-ѧ?Rlpl;w?I?Lٕ\Z@?U 3Ļ?aa?U 3Ļ?Lٕ\Ze$ hfW5F`H\+W5F$ hA?7Slտ^B^ dPA^B^i?7Sl?ju]4z?ju]4?n2?n2ĿP+=sBrӉ sBrſP+/?Mqs[b ܿh<%,M[b f?Mqs0?te? }?te? }.?xuS?xuSY5gjTۿNjTۿY5gt?L0F0ϿR9C6FF0?L0$?j7P;u?j7P;?nP,E?nP,sWȱ|ŷwW??9_?=7\P ?>?=7\P ?9_?ETA?J|[?XUGW[׻?J|[?ETB?O,o?W(&?c)\*?W(?O,o׿<`5;?P`5ydvQ7`5y<`5;?P*?*JԿDgE^hsdCx%?DgE^/*Jh?W㌍@/s*7&.?CCs2SV'S]?)6ZL:Uꢢ?)6VV'S]w'w'vv׿SĖ?c>?-?y.:02l:02kB?qD?zU ?qg?U>BX?C~6i?b!?m}C?b"8?C~5g?&>v ?RIP?`/?RIP(?&>v CPFAӁORۘZc¦WOR^PFAӁ.?f A ?f ??Y{dB?Y{d?La`p?u b?Ȉ% ?u cW?La`p?C b:3zw79t^Tٿzw79t?C b:j?q?q?fVߎ?fVߌp?A)zx?t ǽŔ?V ?t ǽ?A)zx?X(OtT)N ZlkR߿T)N ?X(O?a0S?a/?U`ʢ?U`ʢYWѕ Yހ(˦YހWWѕT?TUf;?de>ݖ&?e螎?de>ݖ=?TUf;?QwyZ?t;dl6? Mh?t;dl6?Qwy[?VGS?vSmn?S+?vSmn?VGTK'N~4fzڿN~7K'? ?Rݷa{Rݷz M?ZM0< ڿZM0e?M1L#2I?[iuߏ8Tz߭?MSnsGƯt eA>t1`Hj?Y G?0~યK<r˿0~યY ߏ?cZŨ.ȝ<.ylM?.ȝcZő?[ H@yiB<0+`?@yiBN[ H?U'bX?6: 6Yr~96: 6\U'b?/ -=?*J?4Ce U!F?$|^iH[]W? !Ѡ3DgE^h?caٌ?H'?E@S ?RݷvksdCx%?bŭkg?N~?S:`Pa{!Ѡ?DgE^/?caٌ?H'?E@&S NRݷz?/ -/*Jh?4C U!F?$|^f0H[]W ?I?W㌍@Q3=O2?X?z?U>BM?Rlpl;w/s*7&3x۩?n?"?qD?ZM0?^-ѧBX?M1?Lٕ\Z@?WZPY(,2$0 ?Ww?C~6iL#2I?U 3ĻpDAFÃ?pSE?^X?b!?[iuߏ8?aav >Tz߭W5F"n%D9#v?C?Yة?RIP?MSnο`H\+i Ař ?Dr>.?awD?`/v CTzߨx?7Sl?T'6?Ib˿V'S]]ބ(cPFAӁ8$^B^ dp.?6?)6Zz vzORۘ?mjQzdPAo6}e?9L:Uꢢip\Zc¦W*<ӿ^B^i?dp-?S?)6Vz vcOR^mjS?7SlT'7 ?IbV'S]]ބ(cPFAӁ.?8$?ju]4z?}7xN+Uﲿw'fЭT?f A ef?ju]4}7͓xN+U_w'fЭ?f ??e?n2?|ztQivf:?Y{dBqP?n2Ŀ|ztQiv׿f:B?Y{d?qPP+=?X^b׿U 8SĖlkR<9aF0?g7?J#-]Xw@X^?c>T)N ftq?L0$h^"?c[+߽Rhd?-?y.?X(OeHs|ŷt1W?ha`khfsz0KB{?@~vݿWѕT`Hj?9_?S92?RѪ1*AgAT5263?TUf;?Y G?=7\P P<,@@?qۿ?H_h9G?de>ݖ&?0~યK?>eX?o`?A$[LPV)T?e螎<r?=7\P ?P<,@@d?q?ȿH_h9G{?de>ݖ=0~ય?9_S92q?RѪ1AgAT68263G?TUf;տY ߏ?ETA?kr+P̿WȺl?DᓙTS%?QwyZ?cZŨ?J|[O:"YMzx?@w䓿x+&?t;dl6.ȝ?XUGW[׻>V   # $!% !) '(+/ ,0 #-1 -5 %)34: &*7; /8 26!#"$! " !() "*!# "$!#%'"$& #%'-/ $&.0#%'() ()+- *,.)+-45*,.6 %)+-/&*,.0 %-/13&.02/138: 029; /13 +45 +458 ,679 679 158:2679; 18:= 29;<;<:=5Թ>fFQE>fFQE>fFQE5Թ>fFQE>fFQE>fFQE>fFQE>fFQE5Թ>fFQE>fFQE>fFQE>fFQE>fFQE>fFQE>fFQE>fFQE>fFQE5Թ>fFQE>fFQE>fFQE>fFQE>fFQE>fFQE5Թ>fFQE>fFQE>fFQE>fFQE>fFQE>fFQE>fFQE.>u >6C->fFQE>fFQE>6C->fFQE>fFQE>u ã*>u >6C->6C->fFQE>fFQE>fFQE>6C->6C->6C->fFQEã*>6C->fFQE>fFQE>6C->6C->fFQE>u UD;T{>6C->6C->fFQE>6C->6C->6C->6C-}H˒>6C->6C->6C->6C->6C->6C->6C- }H˒>6C->6C->6C->6C->6C->6C->6C- }H˒>6C->6C->6C->6C->6C->6C->6C-}H˒>6C->6C->6C-}H˒>6C->6C-fH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;Mt>fFQEfEcR9fH;MtfH;MtfH;MtfH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;Mt>fFQEfH;MtfH;MtfEcR9fH;MtfH;MtfH;MtfEcR9fH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;Mt>fFQEfH;MtfH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;Mt>fFQEfH;MtfH;MtfH;Mt>fFQEfH;MtfH;MtfH;Mt>fFQE>fFQEfH;MtfH;MtfEcR9fH;MtfH;Mt>fFQEfH;MtfEcR9fH;MtfH;Mt>fFQE>6C-fH;Mtu\fH;Mt6C-6C->fFQEfH;Mtu\fH;Mt6C->fFQE>fFQEfH;MtfH;MtfH;MtfEcR9fH;MtfH;MtfH;MtfH;MtfEcR9fH;Mt>fFQE>fFQEfH;MtfH;MtfEcR9fH;MtfH;Mt>fFQEfH;MtfH;MtfEcR9fH;Mt>fFQE>6C-fH;Mtu\fH;Mt6C-6C->6C-fH;Mtu\6C-6C->fFQEfH;MtfH;MtfH;Mt>6C-6C- 6C-6C->6C->6C-6C-6C-6C-6C-6C->6C-6C-6C-6C-6C->6C-6C-6C-6C-6C-6C->6C-6C-6C-6C-6C->6C->6C-6C-6C-6C-6C-6C-6C-6C-6C-6C-6C->6C->6C-6C-6C-6C-6C-6C->6C-6C-6C-6C-6C->6C-6C-6C-6C-6C-6C->6C-6C-6C-6C-6C->6C-6C-6C- 6C->6C-6C- 6C-6C->6C-6C-6C-6C-6C->6C-6C-6C-6C-6C->6C-6C- 6C-6C->6C-6C-6C-6C-6C-6C-6C-6C-6C-6C->6C-6C-6C-6C-6C->6C-6C-6C-6C-6C-6C- 6C-6C- 6C-slepc-3.7.4/share/slepc/datafiles/matrices/speaker107k.petsc0000644000175000017500000005051013107004621023234 0ustar jromanjroman{Pkk                      !  !" !"# "#$ #$  !%&  !"%&' !"#&'( "#$'() #$()  !%&*+  !"%&'*+, !"#&'(+,-"#$'(),-.#$()-.%&*+%&'*+,&'(+,-'(),-.()-.  !/045  !"/01456 !"#012567 "#$123678 #$2378  !%&/0459:  !"%&'/014569:; !"#&'(012567:;< "#$'()123678;<= #$()2378<=  !%&*+459:>?  !"%&'*+,4569:;>?@ !"#&'(+,-567:;<?@A"#$'(),-.678;<=@AB#$()-.78<=AB%&*+9:>?%&'*+,9:;>?@&'(+,-:;<?@A'(),-.;<=@AB()-.<=AB !/045CDHI !"/01456CDEHIJ!"#012567DEFIJK"#$123678EFGJKL#$2378FGKL !%&/0459:CDHIMN !"%&'/014569:;CDEHIJMNO!"#&'(012567:;<DEFIJKNOP"#$'()123678;<=EFGJKLOPQ#$()2378<=FGKLPQ !%&*+459:>?HIMNRS !"%&'*+,4569:;>?@HIJMNORST!"#&'(+,-567:;<?@AIJKNOPSTU"#$'(),-.678;<=@ABJKLOPQTUV#$()-.78<=ABKLPQUV%&*+9:>?MNRS%&'*+,9:;>?@MNORST&'(+,-:;<?@ANOPSTU'(),-.;<=@ABOPQTUV()-.<=ABPQUV/045CDHIWX\]/01456CDEHIJWXY\]^012567DEFIJKXYZ]^_123678EFGJKLYZ[^_`2378FGKLZ[_`/0459:CDHIMNWX\]ab/014569:;CDEHIJMNOWXY\]^abc012567:;<DEFIJKNOPXYZ]^_bcd123678;<=EFGJKLOPQYZ[^_`cde2378<=FGKLPQZ[_`de459:>?HIMNRS\]abfg4569:;>?@HIJMNORST\]^abcfgh567:;<?@AIJKNOPSTU]^_bcdghi678;<=@ABJKLOPQTUV^_`cdehij78<=ABKLPQUV_`deij9:>?MNRSabfg9:;>?@MNORSTabcfgh:;<?@ANOPSTUbcdghi;<=@ABOPQTUVcdehij<=ABPQUVdeijCDHIWX\]CDEHIJWXY\]^DEFIJKXYZ]^_EFGJKLYZ[^_`FGKLZ[_`CDHIMNWX\]abCDEHIJMNOWXY\]^abcDEFIJKNOPXYZ]^_bcdEFGJKLOPQYZ[^_`cdeFGKLPQZ[_`deHIMNRS\]abfgHIJMNORST\]^abcfghIJKNOPSTU]^_bcdghiJKLOPQTUV^_`cdehijKLPQUV_`deijMNRSabfgMNORSTabcfghNOPSTUbcdghiOPQTUVcdehijPQUVdeijAICx'ARYATcA\X;EA]g0&AbH1)Ab-"9l2Y?pu뇼9?P$WF?_h] r[k?za?5)?y|:?pu뇼9̰*?l3@[?}B7?[A#a?UP?A>?ai=4DD-?s>?^=c6?t ?F?l3@[b?[A#a?}B7?s>4DD-?ai=?F?t ?^=c6?pu뇼99l2Y?_h] ?P$WF?zar[k?y|s?5.?P$WF?}B7u3c?}/\?@R'k?xCD?X5?6a蒿TĢb?klE?{g?n?_h] ?[A#a?4?}/\$>'?|+3Ue?xCD?PR'p?xCD?離%?/TF???0)J17?Ş[?n?{g?n?UP?A>?BF7Z-?UP?A>?|+3Ue딗?|+3Up?xCD?PR'p?xCD?#ҥ&?<?#ҥ&?=*խ?=?n?{g?n?4?[A#a?_h] ?|+3Up$>'?}/\?xCD?PR'p?xCD???/TF?離%?Ş[17?0)J?n?{g?n?}B7?P$WF?}/\u3c?xCD?@R't?6a?X5?klETĢ]?n?{g?@R'k?xCD;?{ᕩ'z?@s]?-jW?{g?nZ>U?~??ut\?xCD?PR'p?xCD?{ᕩ'z;?{ᕩ'z?-jW?Ps]?-jW?n?{g?n?~Z>U?~?ut\??ut\?xCD?PR'p?xCD?{ᕩ'z;?{ᕩ'z?-jW?Ps]?-jW?n?{g?n?~Z>U?~?ut\??ut\?xCD?PR'p?xCD?{ᕩ'z;?{ᕩ'z?-jW?Ps]?-jW?n?{g?n?~Z>U?~?ut\??ut\?xCD?@R't?{ᕩ'z;?-jW?@s];?n?{g ?~Z>U?ut\??@s]?-jWutj?kC??ut\pg?{9ٽP3?-jW?Ps]?-jW?kCutj?kC?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?Ps]?-jW?kCutj?kC?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?Ps]?-jW?kCutj?kC?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?@s];?kCutj?ut\??{9ٽP3pgr[k?ai=?X5?離%5H> 7?~rh?2%'.?n뗿tR)$ޟ!?cs?~p z?v B?za4DD-?~ֈ?6a?/TF?#ҥ&?~rhʳӡk?~&*?}-?QaDI?2n? QŬ q?':p?DXCy:?m=K?k?s>jѺɬ?s>???<???~&*Pg?~&A?Y\Qk?y{2?Y\Qk?ke޿-]s?ke?1 a?J?1 a?~ֈ̿4DD-?za?#ҥ&?/TF?6a?~&Aʳӡk?~rs?2n?QaD?}-?':pQŬ q? ?k?m=K?DXCy:?ai=r[k?離%?X5?~rs5H> 7?n?2%'?cstR)$ޟ!?v B?~p z?5)?^=c6TĢb?0)J?{g?n?2%'.?}-9?M?Ev?PR'~?xCD?zN@~t?~qh?!՞?{g?n?y|:?t ?K5]?klE17?=?n?{g?n?n?QaDI?Y\Qk?Ev6||L?=-mTw?xCD?`R't?xCD?VV߭6? t?" ?~}Z׿ @?"B*?n?{g?n?F?9T?F?Ş[*խ?Ş[?n?{g?n?2n?y{2?2n?=-mTwgД?=-mTw?xCD?`R't?xCD?z= +?ٝr?z= 6?@sJ v7?@sJ ?n?{g?n?K5]?t ?y|s?=17?klE?n?{g?n?Y\Qk?QaD?n?=-mTw6||L?Ev?xCD?`R't?xCD?" ? t?VV߭6?"B*ֿ @?~}Z?n?{g?n?^=c6?5.?0)JTĢ]?n?{g ?}-?2%'?Ev9?M?xCD?PR'k?~q?zN@~t?!՞h?n?{g?{g?nZ>U?~??ut\?PR'~?xCD;?ᕩ'W?Ps]?-jW?{g?nZ>I?~??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R't?xCD?ᕩ'W;?ᕩ'W?-jW8?`s]6?-jW?n?{g?n?~Z>U?~?ut\??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R't?xCD?ᕩ'W;?ᕩ'W?-jW8?`s]6?-jW?n?{g?n?~Z>U?~?ut\??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R't?xCD?ᕩ'W;?ᕩ'W?-jW8?`s]6?-jW?n?{g?n?~Z>U?~?ut\??ut\?n?{g?~Z>U?ut\??xCD?PR'k?ᕩ'W;?-jW8?Ps]?n?{g ?~Z>I?ut\???ut\pg?{9ٽP3?Ps]?-jW8utj?{C??ut\pg?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?`s]6?-jW8?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?`s]6?-jW8?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?`s]6?-jW8?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??{9ٽP3pg?-jW?Ps]?{Cutj?ut\??{9ٽP3pgtR)$ޟ!? ?zN@~t?VV߭6R?>wsYe4?p9itR)$ޟ!? ?zN@~t?VV߭wrδPwdS?vl^[?cB>?5C#?csQŬ q?ke?~q? t?z= 6?':p-]s?':p?" ?ٝr?" տwdSۿgCwdS?!9Ju? x?!9Ju?':p-]?':p?" ?ٝr?" ?ke޿QŬ q?cs?z= 6? t?~qwdSۿrδP?>w?5C#?cB>?vl^[?ke޿QŬ ?cs?z= 6? t?~q? tR)$ޟ!?VV߭6?zN@~t?>wR?p9isYe4? tR)$ޟ!?VV߭?!9Ju?@ڤ,Õ4?|{ |?xCD?`R']?xCD?v H?m=K?1 g?!՞ @?@sJ ?n?{g?n?k?J?k?"B*v7?"B*?n?{g?n?5C#? x?5C#?|{ |Ԭhk?|{ |?xCD?`R']?xCD?k"?J?k?"B*ֿv7?"B*?n?{g?n?1 a?m=K?v B?@sJ @?!՞?n?{g?n?!9Ju?cB>?p9i?|{ |,Õ4?@ڤ?xCD?`R']?xCD?1 a?m=K?v H?@sJ @?!՞?n?{g?n?DXCy:?~p z?~}Z׿h?n?{g ?vl^[sYe4?@ڤ4ϓ?xCD?PR'Y?DXCy:?~p z?~}Z׿h?n?{g?{g?nZ>I?~??ut\?PR'g?xCD;?ᕩ'W?Ps]?-jW?{g?nZ>I?~??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R']?xCD?ᕩ'W;?ᕩ'W?-jW?`s]?-jW?n?{g?n?~Z>U?~?ut\??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R']?xCD?ᕩ'W;?ᕩ'W?-jW?`s]?-jW?n?{g?n?~Z>U?~?ut\??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R']?xCD?ᕩ'W;?ᕩ'W?-jW?`s]?-jW?n?{g?n?~Z>U?~?ut\??ut\?n?{g?~Z>I?ut\??xCD?PR'Y?ᕩ'W;?-jW?Ps]?n?{g ?~Z>I?ut\???ut\pg?{9ٽP3?Ps]?-jWutj?{C??ut\pg?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?`s]?-jW?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?`s]?-jW?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?`s]?-jW?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??{9ٽP3pg?-jW?Ps]?{Cutj?ut\??{9ٽP3pgtR)$ޟ!?cs?~p z?v H5H> E?~r?2%'c?n봿r[k?aiw?X5?離%? QŬ q?':p?DXCy:?m=K?k"?~rʳӡk?~&5?}-?QaD?2n?za 4DD-?~ֈ?6a?/TF?#ҥ&?ke޿-]?ke?1 g?J?1 a?~&5Pg?~&*?Y\Qk?y{I?Y\Qk?s>jѺɬ?s>???<???':pQŬ ? ?k?m=K?DXCy:?~&*ʳӡk?~rs?2n?QaD?}-?~ֈؿ4DD-?za?#ҥ,?/TF?6a?cstR)$ޟ!?v H?~p z?~rs5H> >?n?2%'Q?ai=r[k?離%?X5?zN@~t?~qh?!՞?{g?n?2%'c?}-9?q?Ev?PR'k?xCD?54?^=c6TĢh?0)J?{g?n?VV߭I?~??ut\?PR'k?xCD;?ᕩ'W?Ps]?-jW8?{g?nZ>U?~??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R't?xCD?ᕩ'W;?ᕩ'W?-jW8?`s]?-jW8?n?{g?n?~Z>U?~?ut\??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R't?xCD?ᕩ'W;?ᕩ'W?-jW8?`s]?-jW8?n?{g?n?~Z>U?~?ut\??ut\?n?{g?n?~Z>U?~?ut\??ut\?xCD?`R't?xCD?ᕩ'W;?ᕩ'W?-jW8?`s]?-jW8?n?{g?n?~Z>U?~?ut\??ut\?n?{g?~Z>I?ut\??xCD?PR'g?ᕩ'W;?-jW8?Ps]?n?{g?~Z>U?ut\???ut\pg?{9ٽP3?Ps]?-jW8utj?{C??ut\pg ?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW8?`s]?-jW8?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW8?`s]?-jW8?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??ut\?{9ٽP3g?{9ٽP3?-jW8?`s]?-jW8?{Cutr?{C?ut\??ut\?{9ٽP3g?{9ٽP3?ut\??{9ٽP3pg?-jW8?Ps]?{Cutj?ut\??{9ٽP3pgr[k?za ?54?y|s9l2h?pu뇼E?P$WF?_h] ?aiw4DD-?s>?^=c6?t ?F?pu뇼Ḛ*?l3@[?}B7?[A#a?UP?A>?~ֈ̿jѺɬ?~ֈ?K5c?9T?K5c?l3@[b4DD-?ai=?F?t ?^=c6?l3@[̰*?pu뇼E?UP?A>?[A#a?}B7?zar[k?y|s?5.?pu뇼E9l2Y?_h] ?P$WF?X5?6a蝿TĢh?kla?{g?n?P$WF?}B7u3c?}/g?@R'͐?xCD?離%?/TF???0)J1T?Ş[?n?{g?n?_h] ?[A#a?4?}/g$>'?|+3Up?xCD?PR'͐?xCD?#ҥ&?<?#ҥ,?=*խ?=?n?{g?n?UP?A>?BF7Z[?UP?A>?|+3Up딗?|+3Up?xCD?PR'͐?xCD???/TF?離%?Ş[1T?0)J?n?{g?n?4?[A#a?_h] ?|+3Up$>'?}/g?xCD?PR'͐?xCD?6a?X5?klaTĢb?n?{g?}B7?P$WF?}/gu3c?xCD?@R'͐?{g?nZ>U?~??ut\?@R'͐?xCD;?{ᕩ'z?@s]M?-jW?n?{g?n?~Z>U?~?ut\??ut\?xCD?PR'͐?xCD?{ᕩ'z;?{ᕩ'z?-jW?Ps]M?-jW?n?{g?n?~Z>U?~?ut\??ut\?xCD?PR'͐?xCD?{ᕩ'z;?{ᕩ'z?-jW?Ps]M?-jW?n?{g?n?~Z>U?~?ut\??ut\?xCD?PR'͐?xCD?{ᕩ'z;?{ᕩ'z?-jW?Ps]M?-jW?n?{g?~Z>U?ut\??xCD?@R'͐?{ᕩ'z;?-jW?@s])??ut\pg ?{9ٽP3?@s]M?-jWutj?kC?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?Ps]M?-jW?kCutj?kC?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?Ps]M?-jW?kCutj?kC?ut\??ut\?{9ٽP3g?{9ٽP3?-jW?Ps]M?-jW?kCutj?kC?ut\??{9ٽP3pg?-jW?@s])?kCutjslepc-3.7.4/share/slepc/datafiles/matrices/readme0000644000175000017500000000077513107004621021327 0ustar jromanjroman SLEPc example matrices ---------------------- Saved in MATMPIAIJ format with a PetscViewerBinary. File Name Description ---------------------------------------------------------------------------- rdb200 Brusselator real unsymmetric, 200 by 200, 1120 entries bfw62a Waveguide real unsymmetric, 62 by 62, 450 entries bfw62b real symmetric indefinite, 62 by 62, 342 entries speaker107m Speaker quadratic eigenvalue problem speaker107c speaker107k slepc-3.7.4/share/slepc/datafiles/matrices/bfw62a.petsc0000644000175000017500000001304013107004621022263 0ustar jromanjroman{P>>        !# "$!%'  !()  !#%&'()+-/  "&,.0 #%&'-/13 (+-45 %)+-1348: &*,.279; /138= 2679<!#"$! " !() "*!# "$!#%'"$& #%'-/ $&.0#%' () ()+- *,. )+-45 *,.6 %)+-/ &*,.0 %-/13&.02 /138: 029; /13 +45 +458 ,679 679 158: 2679; 18:= 29;< ;< :=?Z&~ ?3H+XRm?6y'YtK+w?6y'XRm?Z&~ ?X?3H+YtK+wXRm?6y'YtK+w?6y'?X?Zx_?X?{6!z#1?3H+?6y'XRmYtK+wXRm?6y'?6y'?6y'YtK+w?6y'?3H+?Zx_?3H+?6y'XRmYtK+w?6y'XRm?6y'YtK+w?6y'?X?Z\-@?{6!z#1?3H+?6y'XRmYtK+w?6y'?6y'YtK+w?3H+?+?$ Rif-[ݕWG?V{6?6y'YtK+w zg*?b0v?$V!?6y'G#?6y'?؞avؤ?+? b?9@ ]r/Zf-[ݕ?gΕ?U?6y'?6y'^BR1H zg*?b0v?$V!?6y'?6y'״$_Zj?6y'-w1?6y'?3H+@?? 6?6y'?6y' gΕYtK+w gΕ?6y'$_Zj?6y'?ӑt|? b?9?_ċ@KC%?gΕ? l%?6y'^BR["`B?6y'״$_Zj?6y'&x9́? l%?{6!z#1?8R}?Ӡ 8Bf?6y'&x9́333333?6y'&x9́?6y'? 6?{6!z#1?Ӡ 8Bf@8R}?Ӡ 8Bf?6y'?6y'333333$_Zj333333?6y'?6y'$_Zj?6y'? 6@8R}? 6?6y'?6y'333333$_Zj333333?6y'$_Zj?6y'? l%?Ӡ 8Bf?8R}?6y'333333&x9́?6y'&x9́? 6?8R}?6y'?6y'333333$_Zj333333YtK+w?;.7w_?6y'_?6&,s L_?6y'?6&,s L L_XRm L?;.7wXRmXRm?6y' L?6&,s6"Ѽֿ6"Ѽֿ L?6y'XRm L?6&,s6"Ѽֿ L?6y'YtK+w_򶿫6"Ѽ?6&,s_YtK+wYtK+w_򶿫6"Ѽ?6&,s_򶿫6"Ѽ?6y'_?6&,s L_?6y'_?6&,s L LXRm?6y'6"Ѽֿ L?;.7wXRmXRm?6y' L?6&,s6"Ѽֿ6"Ѽֿ LXRm?6y' L?6&,s6"Ѽֿ L?6y'YtK+w_򶿫6"Ѽ?;.7wYtK+w?6y'YtK+w6"Ѽ?;.7w_?6y'?6y' L_?6&,s L_?6y' L?6&,s L_?vSӽ^BR?b0v?$V!?؍#@y2 *cPgΕ3/ek?6y' gΕ L@ !laR6"Ѽֿ/^ YtK+w?6y'?6y'YtK+w6"Ѽֿ_򶿫6"Ѽ?6&,s_YtK+wYtK+w6"Ѽֿ_򶿫6"Ѽ?6&,s_?6y'?6y' L_?6&,s L_?6y' L_?6&,s L?vSӽ^BR?b0v?؍#@y2 *cPgΕ3/ek gΕ?6y' L@ !laR6"Ѽֿ/^ YtK+w?6y'YtK+w_򶿫6"Ѽ?;.7w&x9́?6y'&x9́6"Ѽ@6ҿ ?6y'?6y'/^ @2/^ ?6y'/^ @2/^ ?6y'333333333333/^ @26"Ѽֿ6"Ѽֿ/^ ?6y'333333/^ @26"Ѽֿ/^ $_Zj?6y'?6y'$_Zj6"Ѽֿ 鿫6"Ѽ@2 $_Zj$_Zj6"Ѽֿ 鿫6"Ѽ@2 ?6y'?6y'/^ @2/^ ?6y'/^ @2/^ ?6y'333333333333/^ @26"Ѽֿ6"Ѽֿ/^ 333333?6y'/^ @26"Ѽֿ/^ &x9́?6y'&x9́ 鿫6"Ѽ@6ҿ&x9́?6y'6"Ѽ@6ҿ ?6y'/^ @2 ?6y'/^ @2/^ ?6y'333333/^ @6ҿ6"Ѽֿ$_Zj?6y'6"Ѽֿ @2 $_Zj$_Zj6"Ѽֿ 鿫6"Ѽ@2 ?6y'/^ @2 ?6y'/^ @2/^ 333333/^ @6ҿ&x9́ @6slepc-3.7.4/share/slepc/datafiles/matrices/rdb200.petsc0000644000175000017500000003366013107004621022177 0ustar jromanjroman{P`       ! " #$%&'()*+,-./0 1  2 !3  !"4  !#5 "#$6!"#%7"$%&8#$%'9$&':%&';()*<()+=(*+,>)*+-?*,-.@+,-/A,./0B-./1C.012D/013E0234F1235G 2456H!3457I"4678J#5679K$689:L%789;M&8:;N'9:;O(<=>P)<=?Q*<>?@R+=>?AS,>@ABT-?@ACU.@BCDV/ABCEW0BDEFX1CDEGY2DFGHZ3EFGI[4FHIJ\5GHIK]6HJKL^7IJKM_8JLMN`9KLMOa:LNOb;MNOc<PQRd=PQSe>PRSTf?QRSUg@RTUVhASTUWiBTVWXjCUVWYkDVXYZlEWXY[mFXZ[\nGYZ[]oHZ\]^pI[\]_qJ\^_`rK]^_asL^`abtM_`acuN`bcvOabcwPdefxQdegyRdfghzSefgi{Tfhij|Ughik}Vhjkl~WijkmXjlmnYklmoZlnop[mnoq\npqr]opqs^prst_qrsu`rtuvastuwbtvwcuvwdxyzexy{fxz{|gyz{}hz|}~i{|}j|~k}~l~mnopqrstuvwxyz{|}~ Z1'@?"`?"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"` Z1'@?"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`?"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`?"`@"`@"`@3|hr@"`@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"` Z1'@?"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@?"`@"`@"`@3|hr@"`?"`?"` Z1'@@"`@"`@3|hrslepc-3.7.4/share/slepc/datafiles/matrices/speaker107m.petsc0000644000175000017500000005051013107004621023236 0ustar jromanjroman{Pkk                      !  !" !"# "#$ #$  !%&  !"%&' !"#&'( "#$'() #$()  !%&*+  !"%&'*+, !"#&'(+,-"#$'(),-.#$()-.%&*+%&'*+,&'(+,-'(),-.()-.  !/045  !"/01456 !"#012567 "#$123678 #$2378  !%&/0459:  !"%&'/014569:; !"#&'(012567:;< "#$'()123678;<= #$()2378<=  !%&*+459:>?  !"%&'*+,4569:;>?@ !"#&'(+,-567:;<?@A"#$'(),-.678;<=@AB#$()-.78<=AB%&*+9:>?%&'*+,9:;>?@&'(+,-:;<?@A'(),-.;<=@AB()-.<=AB !/045CDHI !"/01456CDEHIJ!"#012567DEFIJK"#$123678EFGJKL#$2378FGKL !%&/0459:CDHIMN !"%&'/014569:;CDEHIJMNO!"#&'(012567:;<DEFIJKNOP"#$'()123678;<=EFGJKLOPQ#$()2378<=FGKLPQ !%&*+459:>?HIMNRS !"%&'*+,4569:;>?@HIJMNORST!"#&'(+,-567:;<?@AIJKNOPSTU"#$'(),-.678;<=@ABJKLOPQTUV#$()-.78<=ABKLPQUV%&*+9:>?MNRS%&'*+,9:;>?@MNORST&'(+,-:;<?@ANOPSTU'(),-.;<=@ABOPQTUV()-.<=ABPQUV/045CDHIWX\]/01456CDEHIJWXY\]^012567DEFIJKXYZ]^_123678EFGJKLYZ[^_`2378FGKLZ[_`/0459:CDHIMNWX\]ab/014569:;CDEHIJMNOWXY\]^abc012567:;<DEFIJKNOPXYZ]^_bcd123678;<=EFGJKLOPQYZ[^_`cde2378<=FGKLPQZ[_`de459:>?HIMNRS\]abfg4569:;>?@HIJMNORST\]^abcfgh567:;<?@AIJKNOPSTU]^_bcdghi678;<=@ABJKLOPQTUV^_`cdehij78<=ABKLPQUV_`deij9:>?MNRSabfg9:;>?@MNORSTabcfgh:;<?@ANOPSTUbcdghi;<=@ABOPQTUVcdehij<=ABPQUVdeijCDHIWX\]CDEHIJWXY\]^DEFIJKXYZ]^_EFGJKLYZ[^_`FGKLZ[_`CDHIMNWX\]abCDEHIJMNOWXY\]^abcDEFIJKNOPXYZ]^_bcdEFGJKLOPQYZ[^_`cdeFGKLPQZ[_`deHIMNRS\]abfgHIJMNORST\]^abcfghIJKNOPSTU]^_bcdghiJKLOPQTUV^_`cdehijKLPQUV_`deijMNRSabfgMNORSTabcfghNOPSTUbcdghiOPQTUVcdehijPQUVdeij??????? V^EWPXM@I)P6ϒ|_TEWPLʽU᳎߽M@I pmbBUP6 NO5=%V3_TEZ[ˆ1MϽU᳎߾HAX\U᳎߽BU> BU=%V3㜽=%V31MϽ-me1MϽU᳎߾LʽWPBU pmbM@I=%V3 NO5P61MϽZ[ˆ_TEWP V^EM@IXP6)_TEϒ|XM@IF,3{jǷðMðMϒ|_TEJ{䗽n<ɽðMðM M@I pmbBUjǷ({ 'F3 ðMðMðM_TEZ[ˆ1MϽn<ɾ{2!"_z6ðM ðMðM BU> BU'F3 ',p)'F3 ðMðMðM1MϽ-me1Mǽ"_z6E"_z6ðM ðMðM BU pmbM@I'F3 ({ jǷðMðMðM1MǽZ[ˆ_TE"_z6{2!n<ɽðM ðMðM M@IXjǷF,3{ðMðM_TEϒ|n<ܾJ{䗽ðM ðMðMðM*aDA*aD-\;U\;BðMðM *aD-*aD-\;B\;QðMðMðM*aD-(*aD(*aD-\;B\;U\;BðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aD-(*aD(*aD-\;B\;U\;BðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aD-(*aD(*aD-\;B\;U\;BðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðM*aD-*aDA\;B\;UðM ðM*aD-*aD-\;Q\;B\;U\;B\;U\;U\;B\;Q\;U\;B\;B\;U\;B\;U\;K\;U\;Q\;U\;Q\;B\;U\;B\;B\;U\;B\;U\;K\;U\;Q\;U\;Q\;B\;U\;B\;B\;U\;B\;U\;K\;U\;Q\;U\;Q\;B\;U\;B\;B\;U\;U\;U\;Q\;B\;B\;U)P6ϒ|_TE]h[ lH:F۽ P=d P6 NO5=%V3_TEZ[ˆ1MϾ'/ȨCq[ l +>ս{o˙:n}fn=%V3 NO5P61MǽZ[ˆ_TECq'/Ȩս[ lo˙:W:F۽nt X=dP6)_TEϒ|][ lh:F۽H=d Pϒ|_TEJ{䗽n<ɽðMðM h[ l(Sľ 0AuðMðM P=d tU'g!ðMðM _TEZ[ˆ1MϽn<ɾ{2!"_z6ðM ðMðM [ l +>սս[ l!LG8 B 0AuðMðMðMnt X=d ,ypiS]U'g!ðM ðMðM _TEϒ|n<ɾJ{䗽ðM ðM[ lh 0Au(SĽðMðM=d PU'g!tðM ðMðMðM *aD-*aD-\;B\;QðMðM(*aD(*aDA\;U\;UðMðM *aD-*aD-\;B\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD5*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD5*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD5*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðM*aD-*aD-\;Q\;BðMðM*aDA(*aD(\;U\;UðM ðM*aD-*aD-\;Q\;B\;B\;Q\;U\;B\;U\;U\;K\;U\;B\;Q\;U\;B\;Q\;U\;Q\;B\;U\;B\;U\;K\;U\;U(\;K\;U\;Q\;U\;Q\;B\;K\;B\;Q\;U\;Q\;B\;U\;B\;U\;K\;U\;U(\;K\;U\;Q\;U\;Q\;B\;K\;B\;Q\;U\;Q\;B\;U\;B\;U\;K\;U\;U(\;K\;U\;Q\;U\;Q\;B\;K\;B\;Q\;B\;B\;U\;U\;U\;U\;K\;Q\;B\;B\;UH:F۽ P=d uN)L@=Q WʏkH:F۽ P=d:F۾Wo˙:=d t Xn}@=$+ܽʏkIH7]:GWo˙`=dt Xno˙:E1>{o˙:n}fn+ܾ()+ܽ7]@b甑7]o˙:E1>{o˙:nfno˙:W:F۽nt X=d+ܾ$@=7]IHʏko˙:W:Gnt X=d:F۽H=d P@=uN)LʏkQ W:GH=d P P=d tU'g!ðMðM Q Wʏk'&uנ(u)ðMðM P=dtU'g!ðMðM =d t Xn}U'g!ypiS] ,ðM ðMðM ʏkIH7](u)7S|`PCqOðMðMðM=dt XnU'g!ypiS] ,ðM ðMðM n}fn ,S7kȽ ,ðM ðMðM 7]@b甑7]PCqO6V0xPCqOðMðMðMnfn ,S7kȽ ,ðM ðMðM nt X=d ,ypiS]U'g!ðM ðMðM 7]IHʏkPCqO7S|`(u)ðMðMðMnt X=d ,ypiS]U'g!ðM ðMðM =d PU'g!tðM ðMʏkQ W(u)'&uנðMðM=d PU'g!tðM ðMðMðM *aD-*aD-\;B\;QðMðM(*aD(*aDA\;K\;UðMðM *aD-*aD-\;B\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD(*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD(*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD(*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðM*aD-*aD-\;Q\;BðMðM*aDA(*aD(\;U\;KðM ðM*aD-*aD-\;Q\;B\;B\;Q\;U\;B\;K\;U\;K\;K\;B\;Q\;U\;B\;Q\;U\;Q\;B\;K\;B\;U\;K\;U\;K(\;K\;K\;Q\;U\;Q\;B\;K\;B\;Q\;U\;Q\;B\;K\;B\;U\;K\;U\;K(\;K\;K\;Q\;U\;Q\;B\;K\;B\;Q\;U\;Q\;B\;K\;B\;U\;K\;U\;K(\;K\;K\;Q\;U\;Q\;B\;K\;B\;Q\;B\;B\;U\;U\;K\;K\;K\;Q\;B\;B\;UH:G P=d]h[ l)P6ϒ|_TE:F۾Wo˙:=dt Xn'/Cq[ l +>ս<هP6 NO5=%V3_TEZ[ˆ1MϽo˙`E1>{o˙:nfnCq'LrzCq<ه05e<ه=%V3㜽=%V31MϽ-mx1M׽o˙:W:Gnt X=dCq'/<ه +>ս[ l=%V3 NO5P61M׽Z[ˆ_TE:GH=d P][ lhP6)_TEϒ| P=dtU'g!ðMðM h[ l(Sľ 0AuðMðMϒ|_TEJ{䠽n<ܽðMðM =dt XnU'g!ypiS] ,ðM ðMðM [ l +>ս<ه 0Au8 B!LGðMðMðM_TEZ[ˆ1MϽn<ܾ{2!"_zIðM ðMðM nfn ,S7kȽ ,ðM ðMðM <ه05e<ه!LG7ѭqNd!LGðMðMðM1MϽ-mx1M׽"_z6E@"_zIðM ðMðM nt X=d ,ypiS]U'g!ðM ðMðM <ه +>ս[ l!LG8 B 0AuðMðMðM1M׽Z[ˆ_TE"_zI{2!n<ܽðM ðMðM =d PU'g!tðM ðM[ lh 0Au(SĽðMðM_TEϒ|n<ܾJ{䗽ðM ðMðMðM *aD-*aD-\;B\;QðMðM(*aD(*aDA\;U\;UðMðM *aD-*aD-\;B\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD5*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD5*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aDA8*aD5*aDA\;U\;K\;UðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðM ðM*aD-*aD-\;Q\;BðMðM*aDA(*aD(\;U\;KðM ðM*aD-*aD-\;Q\;B\;B\;Q\;U\;B\;U\;U\;K\;U\;B\;Q\;U\;B\;Q\;U\;Q\;B\;K\;B\;U\;K\;U\;U(\;K\;U\;Q\;U\;Q\;B\;U\;B\;Q\;U\;Q\;B\;K\;B\;U\;K\;U\;U(\;K\;U\;Q\;U\;Q\;B\;U\;B\;Q\;U\;Q\;B\;K\;B\;U\;K\;U\;U(\;K\;U\;Q\;U\;Q\;B\;U\;B\;Q\;B\;B\;U\;U\;K\;U\;K\;Q\;B\;B\;U)P6ϒ|_TE V^YWPXM@IP6 NO5=%V3_TEZ[ˆ1MϽWPLʽU᳎߽M@I pmlBU=%V3㜽=%V31MϽ-mx1M׽U᳎߾HAX\U᳎߽BU> BU=%V3 NO5P61M׽Z[ˆ_TEU᳎߾LʽWPBU pmlM@IP6)_TEϒ|WP V^EM@IXϒ|_TEJ{䠽n<ܽðMðM XM@IF,3{jðMðM_TEZ[ˆ1MϽn<ܾ{2!"_z6ðM ðMðM M@I pmlBUj({ 'F3ðMðMðM1MϽ-mx1M׽"_zIE@"_zIðM ðMðM BU> BU'F3',p)'F3ðMðMðM1M׽Z[ˆ_TE"_zI{2!n<ܽðM ðMðM BU pmlM@I'F3({ jðMðMðM_TEϒ|n<ܾJ{䗽ðM ðMM@IXjF,3{ðMðMðMðM *aD-*aD-\;B\;QðMðM*aDA*aD-\;U\;BðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aD-(*aD(*aD-\;B\;U\;BðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aD-(*aD(*aD-\;B\;U\;BðM ðMðM *aD-*aDA*aD-\;Q\;U\;QðMðMðM*aD-(*aD(*aD-\;B\;U\;BðM ðM*aD-*aD-\;Q\;BðMðM*aD-*aDA\;B\;U\;B\;Q\;U\;B\;U\;B\;U\;U\;Q\;U\;Q\;B\;U\;B\;B\;U\;B\;U\;K\;U\;Q\;U\;Q\;B\;U\;B\;B\;U\;B\;U\;K\;U\;Q\;U\;Q\;B\;U\;B\;B\;U\;B\;U\;K\;U\;Q\;B\;B\;U\;B\;U\;U\;Uslepc-3.7.4/setup.py0000644000175000017500000002110613107004621013675 0ustar jromanjroman#!/usr/bin/env python """ SLEPc: Scalable Library for Eigenvalue Problem Computations =========================================================== SLEPc is a software library for the solution of large scale sparse eigenvalue problems on parallel computers. It is an extension of PETSc and can be used for either standard or generalized eigenproblems, with real or complex arithmetic. It can also be used for computing a partial SVD of a large, sparse, rectangular matrix, and to solve nonlinear eigenvalue problems .. note:: To install ``PETSc``, ``SLEPc``, ``petsc4py``, and ``slepc4py`` (``mpi4py`` is optional but highly recommended) use:: $ pip install numpy mpi4py $ pip install petsc petsc4py $ pip install slepc slepc4py .. tip:: You can also install the in-development versions with:: $ pip install Cython numpy mpi4py $ pip install --no-deps https://bitbucket.org/petsc/petsc/get/master.tar.gz $ pip install --no-deps https://bitbucket.org/petsc/petsc4py/get/master.tar.gz $ pip install --no-deps https://bitbucket.org/slepc/slepc/get/master.tar.gz $ pip install --no-deps https://bitbucket.org/slepc/slepc4py/get/master.tar.gz """ import sys, os from setuptools import setup from setuptools.command.install import install as _install from distutils.util import get_platform, split_quoted from distutils.spawn import find_executable from distutils import log init_py = """\ # Author: SLEPc Team # Contact: slepc-maint@upv.es def get_slepc_dir(): import os return os.path.dirname(__file__) def get_config(): conf = {} conf['SLEPC_DIR'] = get_slepc_dir() return conf """ metadata = { 'provides' : ['slepc'], 'zip_safe' : False, } CONFIGURE_OPTIONS = [] def bootstrap(): from os.path import join, isdir, abspath # Set SLEPC_DIR SLEPC_DIR = abspath(os.getcwd()) os.environ['SLEPC_DIR'] = SLEPC_DIR # Check PETSC_DIR/PETSC_ARCH PETSC_DIR = os.environ.get('PETSC_DIR', "") PETSC_ARCH = os.environ.get('PETSC_ARCH', "") if not (PETSC_DIR and isdir(PETSC_DIR)): PETSC_DIR = None try: del os.environ['PETSC_DIR'] except KeyError: pass PETSC_ARCH = None try: del os.environ['PETSC_ARCH'] except KeyError: pass elif not (PETSC_ARCH and isdir(join(PETSC_DIR, PETSC_ARCH))): PETSC_ARCH = None try: del os.environ['PETSC_ARCH'] except KeyError: pass # Generate package __init__.py file from distutils.dir_util import mkpath pkgdir = os.path.join(SLEPC_DIR, 'pypi') pkgfile = os.path.join(pkgdir, '__init__.py') if not os.path.exists(pkgdir): mkpath(pkgdir) fh = open(pkgfile, 'wt') fh.write(init_py) fh.close() # Configure options options = os.environ.get('PETSC_CONFIGURE_OPTIONS', '') CONFIGURE_OPTIONS.extend(split_quoted(options)) # if not PETSC_DIR: vstr = version().split('.')[:2] x, y = int(vstr[0]), int(vstr[1]) reqs = ">=%s.%s,<%s.%s" % (x, y, x, y+1) metadata['install_requires'] = ['petsc'+reqs] def get_petsc_dir(): PETSC_DIR = os.environ.get('PETSC_DIR') if PETSC_DIR: return PETSC_DIR try: import petsc PETSC_DIR = petsc.get_petsc_dir() except ImportError: log.warn("PETSC_DIR not specified") PETSC_DIR = os.path.join(os.path.sep, 'usr', 'local', 'petsc') return PETSC_DIR def get_petsc_arch(): PETSC_ARCH = os.environ.get('PETSC_ARCH', "") return PETSC_ARCH def config(prefix, dry_run=False): log.info('SLEPc: configure') options = [ '--prefix=' + prefix, ] options.extend(CONFIGURE_OPTIONS) # log.info('configure options:') for opt in options: log.info(' '*4 + opt) # Run SLEPc configure if dry_run: return os.environ['PETSC_DIR'] = get_petsc_dir() python = find_executable('python2') or find_executable('python') command = [python, './configure', '--prefix='+prefix] status = os.system(" ".join(command)) if status != 0: raise RuntimeError(status) def build(dry_run=False): log.info('SLEPc: build') # Run SLEPc build if dry_run: return PETSC_ARCH = get_petsc_arch() if PETSC_ARCH: PETSC_ARCH = 'PETSC_ARCH=' + PETSC_ARCH make = find_executable('make') command = [make, 'all', 'PETSC_DIR='+get_petsc_dir(), PETSC_ARCH] status = os.system(" ".join(command)) if status != 0: raise RuntimeError(status) def install(dest_dir, dry_run=False): log.info('SLEPc: install') # Run SLEPc install if dry_run: return PETSC_ARCH = get_petsc_arch() if PETSC_ARCH: PETSC_ARCH = 'PETSC_ARCH=' + PETSC_ARCH make = find_executable('make') command = [make, 'install', 'PETSC_DIR='+get_petsc_dir(), PETSC_ARCH, 'SLEPC_DESTDIR='+dest_dir] status = os.system(" ".join(command)) if status != 0: raise RuntimeError(status) slepcvariables = os.path.join(dest_dir, 'lib', 'slepc', 'conf', 'slepcvariables') fh = open(slepcvariables, 'a') fh.write('SLEPC_DESTDIR=%s\n' % dest_dir) fh.close() class context(object): def __init__(self): self.sys_argv = sys.argv[:] self.wdir = os.getcwd() def enter(self): del sys.argv[1:] pdir = os.environ['SLEPC_DIR'] os.chdir(pdir) return self def exit(self): sys.argv[:] = self.sys_argv os.chdir(self.wdir) class cmd_install(_install): def initialize_options(self): _install.initialize_options(self) self.optimize = 1 def finalize_options(self): _install.finalize_options(self) self.install_lib = self.install_platlib self.install_libbase = self.install_lib def run(self): root_dir = os.path.abspath(self.install_lib) dest_dir = prefix = os.path.join(root_dir, 'slepc') # # ctx = context().enter() try: config(prefix, self.dry_run) build(self.dry_run) install(dest_dir, self.dry_run) finally: ctx.exit() # self.outputs = [] for dirpath, _, filenames in os.walk(dest_dir): for fn in filenames: self.outputs.append(os.path.join(dirpath, fn)) # _install.run(self) def get_outputs(self): outputs = getattr(self, 'outputs', []) outputs += _install.get_outputs(self) return outputs def version(): import re version_re = { 'major' : re.compile(r"#define\s+SLEPC_VERSION_MAJOR\s+(\d+)"), 'minor' : re.compile(r"#define\s+SLEPC_VERSION_MINOR\s+(\d+)"), 'micro' : re.compile(r"#define\s+SLEPC_VERSION_SUBMINOR\s+(\d+)"), 'release': re.compile(r"#define\s+SLEPC_VERSION_RELEASE\s+(\d+)"), } slepcversion_h = os.path.join('include','slepcversion.h') data = open(slepcversion_h, 'r').read() major = int(version_re['major'].search(data).groups()[0]) minor = int(version_re['minor'].search(data).groups()[0]) micro = int(version_re['micro'].search(data).groups()[0]) release = int(version_re['release'].search(data).groups()[0]) if release: v = "%d.%d.%d" % (major, minor, micro) else: v = "%d.%d.0.dev%d" % (major, minor+1, 0) return v def tarball(): VERSION = version() if '.dev' in VERSION: return None return ('http://slepc.upv.es/download/distrib/' 'slepc-%s.tar.gz#egg=slepc-%s' % (VERSION, VERSION)) description = __doc__.split('\n')[1:-1]; del description[1:3] classifiers = """ Development Status :: 5 - Production/Stable Intended Audience :: Developers Intended Audience :: Science/Research License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Operating System :: POSIX Programming Language :: C Programming Language :: C++ Programming Language :: Fortran Programming Language :: Python Topic :: Scientific/Engineering Topic :: Software Development :: Libraries """ if 'bdist_wheel' in sys.argv: sys.stderr.write("slepc: this package cannot be built as a wheel\n") sys.exit(1) bootstrap() setup(name='slepc', version=version(), description=description.pop(0), long_description='\n'.join(description), classifiers= classifiers.split('\n')[1:-1], keywords = ['SLEPc','PETSc', 'MPI'], platforms=['POSIX'], license='LGPL', url='http://slepc.upv.es/', download_url=tarball(), author='SLEPc Team', author_email='slepc-maint@upv.es', maintainer='Lisandro Dalcin', maintainer_email='dalcinl@gmail.com', packages = ['slepc'], package_dir = {'slepc': 'pypi'}, cmdclass={'install': cmd_install}, **metadata)